mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-10 01:50:08 +00:00
[Doc] Add JSDoc linter & general comment clean up (#611)
- Prefer comments above lines over end-of-line comments - Makes auto-formatting easier - Subjective, but it is generally easier to read in JS - Standardises JSdoc format - Auto-fixes for many issues (applies on save w/ESLint extension)
This commit is contained in:
@@ -2,6 +2,7 @@ import globals from "globals"
|
||||
import eslint from "@eslint/js"
|
||||
import tseslint from "typescript-eslint"
|
||||
import stylistic from "@stylistic/eslint-plugin"
|
||||
import jsdoc from "eslint-plugin-jsdoc"
|
||||
import unusedImports from "eslint-plugin-unused-imports"
|
||||
|
||||
export default tseslint.config(
|
||||
@@ -27,10 +28,45 @@ export default tseslint.config(
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
jsdoc: {
|
||||
mode: "typescript",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ["./dist/**/*"],
|
||||
},
|
||||
|
||||
// JSDoc
|
||||
jsdoc.configs["flat/contents-typescript-error"],
|
||||
jsdoc.configs["flat/logical-typescript-error"],
|
||||
jsdoc.configs["flat/stylistic-typescript-error"],
|
||||
{
|
||||
rules: {
|
||||
"jsdoc/check-param-names": [
|
||||
"error",
|
||||
{
|
||||
disableMissingParamChecks: true,
|
||||
disableExtraPropertyReporting: true,
|
||||
checkRestProperty: false,
|
||||
checkDestructured: false,
|
||||
},
|
||||
],
|
||||
"jsdoc/check-tag-names": ["error", { definedTags: ["remarks"] }],
|
||||
"jsdoc/multiline-blocks": "error",
|
||||
// Disabling
|
||||
"jsdoc/empty-tags": "off",
|
||||
"jsdoc/lines-before-block": "off",
|
||||
"jsdoc/match-description": "off",
|
||||
"jsdoc/no-undefined-types": "off",
|
||||
"jsdoc/text-escaping": "off",
|
||||
"jsdoc/valid-types": "off",
|
||||
"jsdoc/informative-docs": "off",
|
||||
},
|
||||
},
|
||||
|
||||
// Base, TypeScript, and Stylistic
|
||||
{
|
||||
rules: {
|
||||
// TODO: Update when TypeScript has been cleaned
|
||||
|
||||
367
package-lock.json
generated
367
package-lock.json
generated
@@ -14,6 +14,7 @@
|
||||
"@types/eslint__js": "^8.42.3",
|
||||
"@types/node": "^22.1.0",
|
||||
"eslint": "^9.14.0",
|
||||
"eslint-plugin-jsdoc": "^50.6.3",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"globals": "^15.12.0",
|
||||
"husky": "^9.1.7",
|
||||
@@ -22,7 +23,7 @@
|
||||
"prettier": "^3.3.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.14.0",
|
||||
"typescript-eslint": "^8.25.0",
|
||||
"typescript-strict-plugin": "^2.4.4",
|
||||
"vite": "^6.2.0",
|
||||
"vite-plugin-dts": "^4.3.0",
|
||||
@@ -104,6 +105,21 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@es-joy/jsdoccomment": {
|
||||
"version": "0.49.0",
|
||||
"resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.49.0.tgz",
|
||||
"integrity": "sha512-xjZTSFgECpb9Ohuk5yMX5RhUEbfeQcuOp8IF60e+wyzWEF0M5xeSgqsfLtvPEX8BIyOX9saZqzuGPmZ8oWc+5Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"comment-parser": "1.4.1",
|
||||
"esquery": "^1.6.0",
|
||||
"jsdoc-type-pratt-parser": "~4.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz",
|
||||
@@ -957,6 +973,19 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgr/core": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
|
||||
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/pluginutils": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz",
|
||||
@@ -1497,21 +1526,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.14.0.tgz",
|
||||
"integrity": "sha512-tqp8H7UWFaZj0yNO6bycd5YjMwxa6wIHOLZvWPkidwbgLCsBMetQoGj7DPuAlWa2yGO3H48xmPwjhsSPPCGU5w==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.25.0.tgz",
|
||||
"integrity": "sha512-VM7bpzAe7JO/BFf40pIT1lJqS/z1F8OaSsUB3rpFJucQA4cOSuH2RVVVkFULN+En0Djgr29/jb4EQnedUo95KA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.10.0",
|
||||
"@typescript-eslint/scope-manager": "8.14.0",
|
||||
"@typescript-eslint/type-utils": "8.14.0",
|
||||
"@typescript-eslint/utils": "8.14.0",
|
||||
"@typescript-eslint/visitor-keys": "8.14.0",
|
||||
"@typescript-eslint/scope-manager": "8.25.0",
|
||||
"@typescript-eslint/type-utils": "8.25.0",
|
||||
"@typescript-eslint/utils": "8.25.0",
|
||||
"@typescript-eslint/visitor-keys": "8.25.0",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.3.1",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
"ts-api-utils": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1522,25 +1551,21 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0",
|
||||
"eslint": "^8.57.0 || ^9.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.14.0.tgz",
|
||||
"integrity": "sha512-2p82Yn9juUJq0XynBXtFCyrBDb6/dJombnz6vbo6mgQEtWHfvHbQuEa9kAOVIt1c9YFwi7H6WxtPj1kg+80+RA==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.25.0.tgz",
|
||||
"integrity": "sha512-4gbs64bnbSzu4FpgMiQ1A+D+urxkoJk/kqlDJ2W//5SygaEiAP2B4GoS7TEdxgwol2el03gckFV9lJ4QOMiiHg==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.14.0",
|
||||
"@typescript-eslint/types": "8.14.0",
|
||||
"@typescript-eslint/typescript-estree": "8.14.0",
|
||||
"@typescript-eslint/visitor-keys": "8.14.0",
|
||||
"@typescript-eslint/scope-manager": "8.25.0",
|
||||
"@typescript-eslint/types": "8.25.0",
|
||||
"@typescript-eslint/typescript-estree": "8.25.0",
|
||||
"@typescript-eslint/visitor-keys": "8.25.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1551,23 +1576,19 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.14.0.tgz",
|
||||
"integrity": "sha512-aBbBrnW9ARIDn92Zbo7rguLnqQ/pOrUguVpbUwzOhkFg2npFDwTgPGqFqE0H5feXcOoJOfX3SxlJaKEVtq54dw==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.25.0.tgz",
|
||||
"integrity": "sha512-6PPeiKIGbgStEyt4NNXa2ru5pMzQ8OYKO1hX1z53HMomrmiSB+R5FmChgQAP1ro8jMtNawz+TRQo/cSXrauTpg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.14.0",
|
||||
"@typescript-eslint/visitor-keys": "8.14.0"
|
||||
"@typescript-eslint/types": "8.25.0",
|
||||
"@typescript-eslint/visitor-keys": "8.25.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1578,16 +1599,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.14.0.tgz",
|
||||
"integrity": "sha512-Xcz9qOtZuGusVOH5Uk07NGs39wrKkf3AxlkK79RBK6aJC1l03CobXjJbwBPSidetAOV+5rEVuiT1VSBUOAsanQ==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.25.0.tgz",
|
||||
"integrity": "sha512-d77dHgHWnxmXOPJuDWO4FDWADmGQkN5+tt6SFRZz/RtCWl4pHgFl3+WdYCn16+3teG09DY6XtEpf3gGD0a186g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "8.14.0",
|
||||
"@typescript-eslint/utils": "8.14.0",
|
||||
"@typescript-eslint/typescript-estree": "8.25.0",
|
||||
"@typescript-eslint/utils": "8.25.0",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
"ts-api-utils": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1596,16 +1617,15 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.14.0.tgz",
|
||||
"integrity": "sha512-yjeB9fnO/opvLJFAsPNYlKPnEM8+z4og09Pk504dkqonT02AyL5Z9SSqlE0XqezS93v6CXn49VHvB2G7XSsl0g==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.25.0.tgz",
|
||||
"integrity": "sha512-+vUe0Zb4tkNgznQwicsvLUJgZIRs6ITeWSCclX1q85pR1iOiaj+4uZJIUp//Z27QWu5Cseiw3O3AR8hVpax7Aw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1617,45 +1637,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.14.0.tgz",
|
||||
"integrity": "sha512-OPXPLYKGZi9XS/49rdaCbR5j/S14HazviBlUQFvSKz3npr3NikF+mrgK7CFVur6XEt95DZp/cmke9d5i3vtVnQ==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.25.0.tgz",
|
||||
"integrity": "sha512-ZPaiAKEZ6Blt/TPAx5Ot0EIB/yGtLI2EsGoY6F7XKklfMxYQyvtL+gT/UCqkMzO0BVFHLDlzvFqQzurYahxv9Q==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.14.0",
|
||||
"@typescript-eslint/visitor-keys": "8.14.0",
|
||||
"@typescript-eslint/types": "8.25.0",
|
||||
"@typescript-eslint/visitor-keys": "8.25.0",
|
||||
"debug": "^4.3.4",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "^9.0.4",
|
||||
"semver": "^7.6.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.14.0.tgz",
|
||||
"integrity": "sha512-OGqj6uB8THhrHj0Fk27DcHPojW7zKwKkPmHXHvQ58pLYp4hy8CSUdTKykKeh+5vFqTTVmjz0zCOOPKRovdsgHA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "8.14.0",
|
||||
"@typescript-eslint/types": "8.14.0",
|
||||
"@typescript-eslint/typescript-estree": "8.14.0"
|
||||
"ts-api-utils": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1665,18 +1660,20 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0"
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.14.0.tgz",
|
||||
"integrity": "sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==",
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.25.0.tgz",
|
||||
"integrity": "sha512-syqRbrEv0J1wywiLsK60XzHnQe/kRViI3zwFALrNEgnntn1l24Ra2KvOAWwWbWZ1lBZxZljPDGOq967dsl6fkA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.14.0",
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "8.25.0",
|
||||
"@typescript-eslint/types": "8.25.0",
|
||||
"@typescript-eslint/typescript-estree": "8.25.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1684,19 +1681,28 @@
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
||||
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.25.0.tgz",
|
||||
"integrity": "sha512-kCYXKAum9CecGVHGij7muybDfTS2sD3t0L4bJsEZLkyrXUImiCTq1M3LG2SRtOhiHFwMR9wAFplpT6XHYjTkwQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.25.0",
|
||||
"eslint-visitor-keys": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/expect": {
|
||||
@@ -2077,6 +2083,16 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/are-docs-informative": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz",
|
||||
"integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/arg": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
||||
@@ -2455,6 +2471,16 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/comment-parser": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz",
|
||||
"integrity": "sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/compare-versions": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-6.1.1.tgz",
|
||||
@@ -2789,6 +2815,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-jsdoc": {
|
||||
"version": "50.6.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.6.3.tgz",
|
||||
"integrity": "sha512-NxbJyt1M5zffPcYZ8Nb53/8nnbIScmiLAMdoe0/FAszwb7lcSiX3iYBTsuF7RV84dZZJC8r3NghomrUXsmWvxQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@es-joy/jsdoccomment": "~0.49.0",
|
||||
"are-docs-informative": "^0.0.2",
|
||||
"comment-parser": "1.4.1",
|
||||
"debug": "^4.3.6",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"espree": "^10.1.0",
|
||||
"esquery": "^1.6.0",
|
||||
"parse-imports": "^2.1.1",
|
||||
"semver": "^7.6.3",
|
||||
"spdx-expression-parse": "^4.0.0",
|
||||
"synckit": "^0.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-unused-imports": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz",
|
||||
@@ -2992,9 +3044,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
||||
"integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -3002,7 +3054,7 @@
|
||||
"@nodelib/fs.walk": "^1.2.3",
|
||||
"glob-parent": "^5.1.2",
|
||||
"merge2": "^1.3.0",
|
||||
"micromatch": "^4.0.4"
|
||||
"micromatch": "^4.0.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.6.0"
|
||||
@@ -3036,9 +3088,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
|
||||
"integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.0.tgz",
|
||||
"integrity": "sha512-7SFSRCNjBQIZH/xZR3iy5iQYR8aGBE0h3VG6/cwlbrpdciNYBMotQav8c1XI3HjHH+NikUpP53nPdlZSdWmFzA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -3577,6 +3629,16 @@
|
||||
"dev": true,
|
||||
"license": "Python-2.0"
|
||||
},
|
||||
"node_modules/jsdoc-type-pratt-parser": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.1.0.tgz",
|
||||
"integrity": "sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom": {
|
||||
"version": "25.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz",
|
||||
@@ -4297,6 +4359,20 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-imports": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.2.1.tgz",
|
||||
"integrity": "sha512-OL/zLggRp8mFhKL0rNORUTR4yBYujK/uU+xZL+/0Rgm2QE4nLO9v8PzEweSJEbMGKmDRjJE4R3IMJlL2di4JeQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"dependencies": {
|
||||
"es-module-lexer": "^1.5.3",
|
||||
"slashes": "^3.0.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz",
|
||||
@@ -4600,9 +4676,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/reusify": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
|
||||
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
|
||||
"integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -4784,6 +4860,13 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/slashes": {
|
||||
"version": "3.0.12",
|
||||
"resolved": "https://registry.npmjs.org/slashes/-/slashes-3.0.12.tgz",
|
||||
"integrity": "sha512-Q9VME8WyGkc7pJf6QEkj3wE+2CnvZMI+XJhwdTPR8Z/kWQRXi7boAWLDibRPyHRTUTPx5FaU7MsyrjI3yLB4HA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/slice-ansi": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz",
|
||||
@@ -4834,6 +4917,31 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/spdx-exceptions": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz",
|
||||
"integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==",
|
||||
"dev": true,
|
||||
"license": "CC-BY-3.0"
|
||||
},
|
||||
"node_modules/spdx-expression-parse": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz",
|
||||
"integrity": "sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"spdx-exceptions": "^2.1.0",
|
||||
"spdx-license-ids": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/spdx-license-ids": {
|
||||
"version": "3.0.21",
|
||||
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz",
|
||||
"integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==",
|
||||
"dev": true,
|
||||
"license": "CC0-1.0"
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
@@ -4968,6 +5076,23 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/synckit": {
|
||||
"version": "0.9.2",
|
||||
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz",
|
||||
"integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pkgr/core": "^0.1.0",
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/text-table": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
|
||||
@@ -5089,16 +5214,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ts-api-utils": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz",
|
||||
"integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz",
|
||||
"integrity": "sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.2.0"
|
||||
"typescript": ">=4.8.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-node": {
|
||||
@@ -5145,6 +5270,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@@ -5173,15 +5305,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.14.0.tgz",
|
||||
"integrity": "sha512-K8fBJHxVL3kxMmwByvz8hNdBJ8a0YqKzKDX6jRlrjMuNXyd5T2V02HIq37+OiWXvUUOXgOOGiSSOh26Mh8pC3w==",
|
||||
"version": "8.25.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.25.0.tgz",
|
||||
"integrity": "sha512-TxRdQQLH4g7JkoFlYG3caW5v1S6kEkz8rqt80iQJZUYPq1zD1Ra7HfQBJJ88ABRaMvHAXnwRvRB4V+6sQ9xN5Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "8.14.0",
|
||||
"@typescript-eslint/parser": "8.14.0",
|
||||
"@typescript-eslint/utils": "8.14.0"
|
||||
"@typescript-eslint/eslint-plugin": "8.25.0",
|
||||
"@typescript-eslint/parser": "8.25.0",
|
||||
"@typescript-eslint/utils": "8.25.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -5190,10 +5322,9 @@
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-strict-plugin": {
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"@types/eslint__js": "^8.42.3",
|
||||
"@types/node": "^22.1.0",
|
||||
"eslint": "^9.14.0",
|
||||
"eslint-plugin-jsdoc": "^50.6.3",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"globals": "^15.12.0",
|
||||
"husky": "^9.1.7",
|
||||
@@ -59,7 +60,7 @@
|
||||
"prettier": "^3.3.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.14.0",
|
||||
"typescript-eslint": "^8.25.0",
|
||||
"typescript-strict-plugin": "^2.4.4",
|
||||
"vite": "^6.2.0",
|
||||
"vite-plugin-dts": "^4.3.0",
|
||||
|
||||
@@ -78,7 +78,8 @@ export class ContextMenu {
|
||||
root.style.pointerEvents = "none"
|
||||
setTimeout(function () {
|
||||
root.style.pointerEvents = "auto"
|
||||
}, 100) // delay so the mouse up event is not caught by this element
|
||||
// delay so the mouse up event is not caught by this element
|
||||
}, 100)
|
||||
|
||||
// this prevents the default context browser menu to open in case this menu was created when pressing right button
|
||||
LiteGraph.pointerListenerAdd(
|
||||
@@ -348,7 +349,7 @@ export class ContextMenu {
|
||||
params: MouseEvent,
|
||||
): CustomEvent {
|
||||
const evt = document.createEvent("CustomEvent")
|
||||
evt.initCustomEvent(event_name, true, true, params) // canBubble, cancelable, detail
|
||||
evt.initCustomEvent(event_name, true, true, params)
|
||||
if (element.dispatchEvent) element.dispatchEvent(evt)
|
||||
// @ts-expect-error
|
||||
else if (element.__events) element.__events.dispatchEvent(evt)
|
||||
|
||||
@@ -17,7 +17,8 @@ export class CurveEditor {
|
||||
this.points = points
|
||||
this.selected = -1
|
||||
this.nearest = -1
|
||||
this.size = null // stores last size used
|
||||
// stores last size used
|
||||
this.size = null
|
||||
this.must_update = true
|
||||
this.margin = 5
|
||||
}
|
||||
|
||||
@@ -254,7 +254,8 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
lastRerouteId: 0,
|
||||
}
|
||||
|
||||
this._version = -1 // used to detect changes
|
||||
// used to detect changes
|
||||
this._version = -1
|
||||
|
||||
// safe clear
|
||||
if (this._nodes) {
|
||||
@@ -266,8 +267,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
// nodes
|
||||
this._nodes = []
|
||||
this._nodes_by_id = {}
|
||||
this._nodes_in_order = [] // nodes sorted in execution order
|
||||
this._nodes_executable = null // nodes that contain onExecute sorted in execution order
|
||||
// nodes sorted in execution order
|
||||
this._nodes_in_order = []
|
||||
// nodes that contain onExecute sorted in execution order
|
||||
this._nodes_executable = null
|
||||
|
||||
this._links.clear()
|
||||
this.reroutes.clear()
|
||||
@@ -281,7 +284,8 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
// custom data
|
||||
this.config = {}
|
||||
this.vars = {}
|
||||
this.extra = {} // to store custom data
|
||||
// to store custom data
|
||||
this.extra = {}
|
||||
|
||||
// timing
|
||||
this.globaltime = 0
|
||||
@@ -508,8 +512,9 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
const L: LGraphNode[] = []
|
||||
const S: LGraphNode[] = []
|
||||
const M: Dictionary<LGraphNode> = {}
|
||||
const visited_links: Record<NodeId, boolean> = {} // to avoid repeating links
|
||||
const remaining_links: Record<NodeId, number> = {} // to a
|
||||
// to avoid repeating links
|
||||
const visited_links: Record<NodeId, boolean> = {}
|
||||
const remaining_links: Record<NodeId, number> = {}
|
||||
|
||||
// search for the nodes without inputs (starting nodes)
|
||||
for (const node of this._nodes) {
|
||||
@@ -517,9 +522,11 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
continue
|
||||
}
|
||||
|
||||
M[node.id] = node // add to pending nodes
|
||||
// add to pending nodes
|
||||
M[node.id] = node
|
||||
|
||||
let num = 0 // num of input connections
|
||||
// num of input connections
|
||||
let num = 0
|
||||
if (node.inputs) {
|
||||
for (const input of node.inputs) {
|
||||
if (input?.link != null) {
|
||||
@@ -544,8 +551,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
const node = S.shift()
|
||||
if (node === undefined) break
|
||||
|
||||
L.push(node) // add to ordered list
|
||||
delete M[node.id] // remove from the pending nodes
|
||||
// add to ordered list
|
||||
L.push(node)
|
||||
// remove from the pending nodes
|
||||
delete M[node.id]
|
||||
|
||||
if (!node.outputs) continue
|
||||
|
||||
@@ -858,7 +867,8 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
this.setDirtyCanvas(true)
|
||||
this.change()
|
||||
|
||||
return node // to chain actions
|
||||
// to chain actions
|
||||
return node
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -884,7 +894,8 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
// cannot be removed
|
||||
if (node.ignore_remove) return
|
||||
|
||||
this.beforeChange() // sure? - almost sure is wrong
|
||||
// sure? - almost sure is wrong
|
||||
this.beforeChange()
|
||||
|
||||
const { inputs, outputs } = node
|
||||
|
||||
@@ -929,7 +940,8 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
this.canvasAction(c => c.checkPanels())
|
||||
|
||||
this.setDirtyCanvas(true, true)
|
||||
this.afterChange() // sure? - almost sure is wrong
|
||||
// sure? - almost sure is wrong
|
||||
this.afterChange()
|
||||
this.change()
|
||||
|
||||
this.updateExecutionOrder()
|
||||
@@ -1637,8 +1649,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
// continue;
|
||||
}
|
||||
|
||||
node.id = n_info.id // id it or it will create a new id
|
||||
this.add(node, true) // add before configure, otherwise configure cannot create links
|
||||
// id it or it will create a new id
|
||||
node.id = n_info.id
|
||||
// add before configure, otherwise configure cannot create links
|
||||
this.add(node, true)
|
||||
}
|
||||
|
||||
// configure nodes afterwards so they can reach each other
|
||||
|
||||
@@ -106,11 +106,11 @@ interface ICreateNodeOptions {
|
||||
|
||||
// FIXME: Should not be optional
|
||||
/** choose a nodetype to add, AUTO to set at first good */
|
||||
nodeType?: string // nodeNewType
|
||||
nodeType?: string
|
||||
/** adjust x,y */
|
||||
posAdd?: Point // -alphaPosY*30]
|
||||
posAdd?: Point
|
||||
/** alpha, adjust the position x,y based on the new node size w,h */
|
||||
posSizeFix?: Point // -alphaPosY*2*/
|
||||
posSizeFix?: Point
|
||||
e?: CanvasMouseEvent
|
||||
allow_searchbox?: boolean
|
||||
/** See {@link LGraphCanvas.showSearchBox} */
|
||||
@@ -170,7 +170,7 @@ interface ClipboardPasteResult {
|
||||
|
||||
/** Options for {@link LGraphCanvas.pasteFromClipboard}. */
|
||||
interface IPasteFromClipboardOptions {
|
||||
/** If true, connect the inputs of the pasted items to the outputs of the nodes they are connected to. */
|
||||
/** If `true`, always attempt to connect inputs of pasted nodes - including to nodes that were not pasted. */
|
||||
connectInputs?: boolean
|
||||
/** The position to paste the items at. */
|
||||
position?: Point
|
||||
@@ -197,7 +197,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
|
||||
/** Initialised from LiteGraphGlobal static block to avoid circular dependency. */
|
||||
static link_type_colors: Record<string, string>
|
||||
static gradients: Record<string, CanvasGradient> = {} // cache of gradients
|
||||
static gradients: Record<string, CanvasGradient> = {}
|
||||
|
||||
static search_limit = -1
|
||||
static node_colors: Record<string, ColorOption> = {
|
||||
@@ -357,9 +357,9 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
default_link_color: string
|
||||
default_connection_color: {
|
||||
input_off: string
|
||||
input_on: string // "#BBD"
|
||||
input_on: string
|
||||
output_off: string
|
||||
output_on: string // "#BBD"
|
||||
output_on: string
|
||||
}
|
||||
|
||||
default_connection_color_byType: Dictionary<CanvasColour>
|
||||
@@ -581,16 +581,18 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
|
||||
this.ds = new DragAndScale()
|
||||
this.pointer = new CanvasPointer(this.canvas)
|
||||
this.zoom_modify_alpha = true // otherwise it generates ugly patterns when scaling down too much
|
||||
this.zoom_speed = 1.1 // in range (1.01, 2.5). Less than 1 will invert the zoom direction
|
||||
// otherwise it generates ugly patterns when scaling down too much
|
||||
this.zoom_modify_alpha = true
|
||||
// in range (1.01, 2.5). Less than 1 will invert the zoom direction
|
||||
this.zoom_speed = 1.1
|
||||
|
||||
this.node_title_color = LiteGraph.NODE_TITLE_COLOR
|
||||
this.default_link_color = LiteGraph.LINK_COLOR
|
||||
this.default_connection_color = {
|
||||
input_off: "#778",
|
||||
input_on: "#7F7", // "#BBD"
|
||||
input_on: "#7F7",
|
||||
output_off: "#778",
|
||||
output_on: "#7F7", // "#BBD"
|
||||
output_on: "#7F7",
|
||||
}
|
||||
this.default_connection_color_byType = {
|
||||
/* number: "#7F7",
|
||||
@@ -604,8 +606,10 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
}
|
||||
|
||||
this.highquality_render = true
|
||||
this.use_gradients = false // set to true to render titlebar with gradients
|
||||
this.editor_alpha = 1 // used for transition
|
||||
// set to true to render titlebar with gradients
|
||||
this.use_gradients = false
|
||||
// used for transition
|
||||
this.editor_alpha = 1
|
||||
this.pause_rendering = false
|
||||
this.clear_background = true
|
||||
this.clear_background_color = "#222"
|
||||
@@ -614,22 +618,29 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
this.show_info = true
|
||||
this.allow_dragcanvas = true
|
||||
this.allow_dragnodes = true
|
||||
this.allow_interaction = true // allow to control widgets, buttons, collapse, etc
|
||||
this.multi_select = false // allow selecting multi nodes without pressing extra keys
|
||||
// allow to control widgets, buttons, collapse, etc
|
||||
this.allow_interaction = true
|
||||
// allow selecting multi nodes without pressing extra keys
|
||||
this.multi_select = false
|
||||
this.allow_searchbox = true
|
||||
this.allow_reconnect_links = true // allows to change a connection with having to redo it again
|
||||
this.align_to_grid = false // snap to grid
|
||||
// allows to change a connection with having to redo it again
|
||||
this.allow_reconnect_links = true
|
||||
// snap to grid
|
||||
this.align_to_grid = false
|
||||
|
||||
this.drag_mode = false
|
||||
this.dragging_rectangle = null
|
||||
|
||||
this.filter = null // allows to filter to only accept some type of nodes in a graph
|
||||
// allows to filter to only accept some type of nodes in a graph
|
||||
this.filter = null
|
||||
|
||||
this.set_canvas_dirty_on_mouse_event = true // forces to redraw the canvas on mouse events (except move)
|
||||
// forces to redraw the canvas on mouse events (except move)
|
||||
this.set_canvas_dirty_on_mouse_event = true
|
||||
this.always_render_background = false
|
||||
this.render_shadows = true
|
||||
this.render_canvas_border = true
|
||||
this.render_connections_shadows = false // too much cpu
|
||||
// too much cpu
|
||||
this.render_connections_shadows = false
|
||||
this.render_connections_border = true
|
||||
this.render_curved_connections = false
|
||||
this.render_connection_arrows = false
|
||||
@@ -666,9 +677,11 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
this.last_mouse_position = [0, 0]
|
||||
this.visible_area = this.ds.visible_area
|
||||
this.visible_links = []
|
||||
this.connecting_links = null // Explicitly null-checked
|
||||
// Explicitly null-checked
|
||||
this.connecting_links = null
|
||||
|
||||
this.viewport = options.viewport || null // to constraint render area to a portion of the canvas
|
||||
// to constraint render area to a portion of the canvas
|
||||
this.viewport = options.viewport || null
|
||||
|
||||
// link canvas and graph
|
||||
graph?.attachCanvas(this)
|
||||
@@ -890,7 +903,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
static onMenuCollapseAll() {}
|
||||
static onMenuNodeEdit() {}
|
||||
|
||||
/** @param options Parameter is never used */
|
||||
/** @param _options Parameter is never used */
|
||||
static showMenuNodeOptionalInputs(
|
||||
v: unknown,
|
||||
/** Unused - immediately overwritten */
|
||||
@@ -971,7 +984,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
return false
|
||||
}
|
||||
|
||||
/** @param options Parameter is never used */
|
||||
/** @param _options Parameter is never used */
|
||||
static showMenuNodeOptionalOutputs(
|
||||
v: unknown,
|
||||
/** Unused - immediately overwritten */
|
||||
@@ -1004,8 +1017,9 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
node.flags.skip_repeated_outputs &&
|
||||
node.findOutputSlot(entry[0]) != -1
|
||||
) {
|
||||
// skip the ones already on
|
||||
continue
|
||||
} // skip the ones already on
|
||||
}
|
||||
let label = entry[0]
|
||||
entry[2] ||= {}
|
||||
if (entry[2].label) {
|
||||
@@ -1025,7 +1039,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
// canvas.allow_addOutSlot_onExecuted
|
||||
if (node.findOutputSlot("onExecuted") == -1) {
|
||||
// @ts-expect-error Events
|
||||
entries.push({ content: "On Executed", value: ["onExecuted", LiteGraph.EVENT, { nameLocked: true }], className: "event" }) // , opts: {}
|
||||
entries.push({ content: "On Executed", value: ["onExecuted", LiteGraph.EVENT, { nameLocked: true }], className: "event" })
|
||||
}
|
||||
}
|
||||
// add callback for modifing the menu elements onMenuNodeOutputs
|
||||
@@ -1214,7 +1228,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
// ESC
|
||||
dialog.close()
|
||||
} else if (e.keyCode == 13) {
|
||||
inner() // save
|
||||
// save
|
||||
inner()
|
||||
// @ts-expect-error Intentional - undefined if not present
|
||||
} else if (e.keyCode != 13 && e.target.localName != "textarea") {
|
||||
return
|
||||
@@ -1256,7 +1271,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
dialogCloseTimer = setTimeout(
|
||||
dialog.close,
|
||||
LiteGraph.dialog_close_on_mouse_leave_delay,
|
||||
) // dialog.close();
|
||||
)
|
||||
})
|
||||
dialog.addEventListener("mouseenter", function () {
|
||||
if (LiteGraph.dialog_close_on_mouse_leave)
|
||||
@@ -1305,7 +1320,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
menu: ContextMenu,
|
||||
node: LGraphNode,
|
||||
): void {
|
||||
node.graph.beforeChange(/* ? */)
|
||||
node.graph.beforeChange()
|
||||
|
||||
const fApplyMultiNode = function (node) {
|
||||
node.collapse()
|
||||
@@ -1320,7 +1335,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
}
|
||||
}
|
||||
|
||||
node.graph.afterChange(/* ? */)
|
||||
node.graph.afterChange()
|
||||
}
|
||||
|
||||
static onMenuToggleAdvanced(
|
||||
@@ -1330,7 +1345,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
menu: ContextMenu,
|
||||
node: LGraphNode,
|
||||
): void {
|
||||
node.graph.beforeChange(/* ? */)
|
||||
node.graph.beforeChange()
|
||||
const fApplyMultiNode = function (node: LGraphNode) {
|
||||
node.toggleAdvanced()
|
||||
}
|
||||
@@ -1343,7 +1358,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
fApplyMultiNode(graphcanvas.selected_nodes[i])
|
||||
}
|
||||
}
|
||||
node.graph.afterChange(/* ? */)
|
||||
node.graph.afterChange()
|
||||
}
|
||||
|
||||
static onMenuNodePin(): void {}
|
||||
@@ -1464,7 +1479,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
function inner_clicked(v) {
|
||||
if (!node) return
|
||||
|
||||
node.graph.beforeChange(/* ? */) // node
|
||||
node.graph.beforeChange()
|
||||
|
||||
const fApplyMultiNode = function (node) {
|
||||
node.shape = v
|
||||
@@ -1479,7 +1494,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
}
|
||||
}
|
||||
|
||||
node.graph.afterChange(/* ? */) // node
|
||||
node.graph.afterChange()
|
||||
canvas.setDirty(true)
|
||||
}
|
||||
|
||||
@@ -1637,7 +1652,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
element.className += " lgraphcanvas"
|
||||
element.data = this
|
||||
// @ts-expect-error Likely safe to remove. A decent default, but expectation is to be configured by calling app.
|
||||
element.tabindex = "1" // to allow key events
|
||||
// to allow key events
|
||||
element.tabindex = "1"
|
||||
|
||||
// Background canvas: To render objects behind nodes (background, links, groups)
|
||||
this.bgcanvas = null
|
||||
@@ -1692,7 +1708,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
const canvas = this.canvas
|
||||
|
||||
const ref_window = this.getCanvasWindow()
|
||||
const document = ref_window.document // hack used when moving canvas between windows
|
||||
// hack used when moving canvas between windows
|
||||
const document = ref_window.document
|
||||
|
||||
this._mousedown_callback = this.processMouseDown.bind(this)
|
||||
this._mousewheel_callback = this.processMouseWheel.bind(this)
|
||||
@@ -1702,10 +1719,12 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
this._mouseout_callback = this.processMouseOut.bind(this)
|
||||
this._mousecancel_callback = this.processMouseCancel.bind(this)
|
||||
|
||||
LiteGraph.pointerListenerAdd(canvas, "down", this._mousedown_callback, true) // down do not need to store the binded
|
||||
// down do not need to store the binded
|
||||
LiteGraph.pointerListenerAdd(canvas, "down", this._mousedown_callback, true)
|
||||
canvas.addEventListener("mousewheel", this._mousewheel_callback, false)
|
||||
|
||||
LiteGraph.pointerListenerAdd(canvas, "up", this._mouseup_callback, true) // CHECK: ??? binded or not
|
||||
// CHECK: ??? binded or not
|
||||
LiteGraph.pointerListenerAdd(canvas, "up", this._mouseup_callback, true)
|
||||
LiteGraph.pointerListenerAdd(canvas, "move", this._mousemove_callback)
|
||||
canvas.addEventListener("pointerout", this._mouseout_callback)
|
||||
canvas.addEventListener("pointercancel", this._mousecancel_callback, true)
|
||||
@@ -1721,7 +1740,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
this._key_callback = this.processKey.bind(this)
|
||||
|
||||
canvas.addEventListener("keydown", this._key_callback, true)
|
||||
document.addEventListener("keyup", this._key_callback, true) // in document, otherwise it doesn't fire keyup
|
||||
// in document, otherwise it doesn't fire keyup
|
||||
document.addEventListener("keyup", this._key_callback, true)
|
||||
|
||||
// Dropping Stuff over nodes ************************************
|
||||
this._ondrop_callback = this.processDrop.bind(this)
|
||||
@@ -2820,7 +2840,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
LiteGraph.isValidConnection(firstLink.output.type, node.inputs[inputId].type)
|
||||
) {
|
||||
highlightPos = pos
|
||||
highlightInput = node.inputs[inputId] // XXX CHECK THIS
|
||||
// XXX CHECK THIS
|
||||
highlightInput = node.inputs[inputId]
|
||||
}
|
||||
}
|
||||
} else if (firstLink.input) {
|
||||
@@ -2875,7 +2896,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
underPointer |= CanvasItem.ResizeSe
|
||||
}
|
||||
}
|
||||
} // end
|
||||
}
|
||||
|
||||
// send event to node if capturing input (used with widgets that allow drag outside of the area of the node)
|
||||
if (this.node_capturing_input && this.node_capturing_input != node) {
|
||||
@@ -3032,7 +3053,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
const slot = this.isOverNodeOutput(node, x, y)
|
||||
|
||||
if (slot != -1) {
|
||||
node.connect(slot, link.node, link.slot, link.afterRerouteId) // this is inverted has output-input nature like
|
||||
// this is inverted has output-input nature like
|
||||
node.connect(slot, link.node, link.slot, link.afterRerouteId)
|
||||
} else {
|
||||
// not on top of an input
|
||||
// look for a good slot
|
||||
@@ -3235,7 +3257,6 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
if (!this.graph) return
|
||||
|
||||
let block_default = false
|
||||
// console.log(e); //debug
|
||||
// @ts-expect-error
|
||||
if (e.target.localName == "input") return
|
||||
|
||||
@@ -3381,7 +3402,6 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
|
||||
/**
|
||||
* Pastes the items from the canvas "clipbaord" - a local storage variable.
|
||||
* @param connectInputs If `true`, always attempt to connect inputs of pasted nodes - including to nodes that were not pasted.
|
||||
*/
|
||||
_pasteFromClipboard(options: IPasteFromClipboardOptions = {}): ClipboardPasteResult {
|
||||
const {
|
||||
@@ -5297,7 +5317,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
}
|
||||
} else {
|
||||
return
|
||||
} // unknown
|
||||
}
|
||||
}
|
||||
|
||||
// rendering the outline of the connection can be a little bit slow
|
||||
@@ -5494,7 +5514,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
/**
|
||||
* draws the widgets stored inside a node
|
||||
* @deprecated Use {@link LGraphNode.drawWidgets} instead.
|
||||
* @note Currently there are extensions hijacking this function, so we cannot remove it.
|
||||
* @remarks Currently there are extensions hijacking this function, so we cannot remove it.
|
||||
*/
|
||||
drawNodeWidgets(
|
||||
node: LGraphNode,
|
||||
@@ -5523,9 +5543,10 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
const drawSnapGuides = this.#snapToGrid && this.isDragging
|
||||
|
||||
for (const group of groups) {
|
||||
// out of the visible area
|
||||
if (!overlapBounding(this.visible_area, group._bounding)) {
|
||||
continue
|
||||
} // out of the visible area
|
||||
}
|
||||
|
||||
// Draw snap shadow
|
||||
if (drawSnapGuides && this.selectedItems.has(group))
|
||||
@@ -5911,7 +5932,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
dialogCloseTimer = setTimeout(
|
||||
dialog.close,
|
||||
LiteGraph.dialog_close_on_mouse_leave_delay,
|
||||
) // dialog.close();
|
||||
)
|
||||
})
|
||||
LiteGraph.pointerListenerAdd(dialog, "enter", function () {
|
||||
if (LiteGraph.dialog_close_on_mouse_leave && dialogCloseTimer)
|
||||
@@ -6012,10 +6033,13 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
slot_from: null,
|
||||
node_from: null,
|
||||
node_to: null,
|
||||
do_type_filter: LiteGraph.search_filter_enabled, // TODO check for registered_slot_[in/out]_types not empty // this will be checked for functionality enabled : filter on slot type, in and out
|
||||
// TODO check for registered_slot_[in/out]_types not empty
|
||||
// this will be checked for functionality enabled : filter on slot type, in and out
|
||||
do_type_filter: LiteGraph.search_filter_enabled,
|
||||
|
||||
// these are default: pass to set initially set values
|
||||
// @ts-expect-error
|
||||
type_filter_in: false, // these are default: pass to set initially set values
|
||||
type_filter_in: false,
|
||||
|
||||
type_filter_out: false,
|
||||
show_general_if_none_on_typefilter: true,
|
||||
@@ -6063,9 +6087,10 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
canvas.focus()
|
||||
root_document.body.style.overflow = ""
|
||||
|
||||
// important, if canvas loses focus keys wont be captured
|
||||
setTimeout(function () {
|
||||
that.canvas.focus()
|
||||
}, 20) // important, if canvas loses focus keys wont be captured
|
||||
}, 20)
|
||||
dialog.parentNode?.removeChild(dialog)
|
||||
}
|
||||
|
||||
@@ -6168,7 +6193,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
if (options.do_type_filter) {
|
||||
if (selIn) {
|
||||
const aSlots = LiteGraph.slot_types_in
|
||||
const nSlots = aSlots.length // this for object :: Object.keys(aSlots).length;
|
||||
// this for object :: Object.keys(aSlots).length;
|
||||
const nSlots = aSlots.length
|
||||
|
||||
if (
|
||||
options.type_filter_in == LiteGraph.EVENT ||
|
||||
@@ -6202,7 +6228,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
}
|
||||
if (selOut) {
|
||||
const aSlots = LiteGraph.slot_types_out
|
||||
const nSlots = aSlots.length // this for object :: Object.keys(aSlots).length;
|
||||
// this for object :: Object.keys(aSlots).length;
|
||||
const nSlots = aSlots.length
|
||||
|
||||
if (
|
||||
options.type_filter_out == LiteGraph.EVENT ||
|
||||
@@ -6279,7 +6306,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
iS = options.slot_from
|
||||
break
|
||||
default:
|
||||
iS = 0 // try with first if no name set
|
||||
// try with first if no name set
|
||||
iS = 0
|
||||
}
|
||||
if (typeof options.node_from.outputs[iS] !== "undefined") {
|
||||
if (iS !== false && iS > -1) {
|
||||
@@ -6307,7 +6335,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
iS = options.slot_from
|
||||
break
|
||||
default:
|
||||
iS = 0 // try with first if no name set
|
||||
// try with first if no name set
|
||||
iS = 0
|
||||
}
|
||||
if (typeof options.node_to.inputs[iS] !== "undefined") {
|
||||
if (iS !== false && iS > -1) {
|
||||
@@ -6377,7 +6406,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
let filtered = null
|
||||
if (Array.prototype.filter) {
|
||||
// filter supported
|
||||
const keys = Object.keys(LiteGraph.registered_node_types) // types
|
||||
// types
|
||||
const keys = Object.keys(LiteGraph.registered_node_types)
|
||||
filtered = keys.filter(inner_test_filter)
|
||||
} else {
|
||||
filtered = []
|
||||
@@ -6611,7 +6641,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
dialog.close()
|
||||
} else if (e.keyCode == 13) {
|
||||
// ENTER
|
||||
inner() // save
|
||||
// save
|
||||
inner()
|
||||
} else if (e.keyCode != 13) {
|
||||
dialog.modified()
|
||||
return
|
||||
@@ -6734,7 +6765,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
dialogCloseTimer = setTimeout(
|
||||
dialog.close,
|
||||
LiteGraph.dialog_close_on_mouse_leave_delay,
|
||||
) // dialog.close();
|
||||
)
|
||||
})
|
||||
dialog.addEventListener("mouseenter", function () {
|
||||
if (options.closeOnLeave || LiteGraph.dialog_close_on_mouse_leave)
|
||||
@@ -7034,7 +7065,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
|
||||
node.onShowCustomPanelInfo?.(panel)
|
||||
|
||||
panel.footer.innerHTML = "" // clear
|
||||
// clear
|
||||
panel.footer.innerHTML = ""
|
||||
panel.addButton("Delete", function () {
|
||||
if (node.block_delete)
|
||||
return
|
||||
@@ -7408,7 +7440,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
// ESC
|
||||
dialog.close()
|
||||
} else if (e.keyCode == 13) {
|
||||
inner() // save
|
||||
// save
|
||||
inner()
|
||||
} else if (
|
||||
e.keyCode != 13 &&
|
||||
(e.target as Element).localName != "textarea"
|
||||
|
||||
@@ -823,8 +823,6 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
if (!this.outputs) return
|
||||
|
||||
// this maybe slow and a niche case
|
||||
// if(slot && slot.constructor === String)
|
||||
// slot = this.findOutputSlot(slot);
|
||||
if (slot == -1 || slot >= this.outputs.length) return
|
||||
|
||||
const output_info = this.outputs[slot]
|
||||
@@ -1107,9 +1105,6 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
onAfterExecuteNode(param: unknown, options?: { action_call?: any }) {
|
||||
const trigS = this.findOutputSlot("onExecuted")
|
||||
if (trigS != -1) {
|
||||
// console.debug(this.id+":"+this.order+" triggering slot onAfterExecute");
|
||||
// console.debug(param);
|
||||
// console.debug(options);
|
||||
this.triggerSlot(trigS, param, null, options)
|
||||
}
|
||||
}
|
||||
@@ -1117,7 +1112,6 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
changeMode(modeTo: number): boolean {
|
||||
switch (modeTo) {
|
||||
case LGraphEventMode.ON_EVENT:
|
||||
// this.addOnExecutedOutput();
|
||||
break
|
||||
|
||||
case LGraphEventMode.ON_TRIGGER:
|
||||
@@ -1152,19 +1146,20 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
// enable this to give the event an ID
|
||||
options.action_call ||= this.id + "_exec_" + Math.floor(Math.random() * 9999)
|
||||
|
||||
this.graph.nodes_executing[this.id] = true // .push(this.id);
|
||||
this.graph.nodes_executing[this.id] = true
|
||||
this.onExecute(param, options)
|
||||
this.graph.nodes_executing[this.id] = false // .pop();
|
||||
this.graph.nodes_executing[this.id] = false
|
||||
|
||||
// save execution/action ref
|
||||
this.exec_version = this.graph.iteration
|
||||
if (options?.action_call) {
|
||||
this.action_call = options.action_call // if (param)
|
||||
this.action_call = options.action_call
|
||||
this.graph.nodes_executedAction[this.id] = options.action_call
|
||||
}
|
||||
}
|
||||
this.execute_triggered = 2 // the nFrames it will be used (-- each step), means "how old" is the event
|
||||
this.onAfterExecuteNode?.(param, options) // callback
|
||||
// the nFrames it will be used (-- each step), means "how old" is the event
|
||||
this.execute_triggered = 2
|
||||
this.onAfterExecuteNode?.(param, options)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1181,17 +1176,18 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
// enable this to give the event an ID
|
||||
options.action_call ||= this.id + "_" + (action ? action : "action") + "_" + Math.floor(Math.random() * 9999)
|
||||
|
||||
this.graph.nodes_actioning[this.id] = action ? action : "actioning" // .push(this.id);
|
||||
this.graph.nodes_actioning[this.id] = action ? action : "actioning"
|
||||
this.onAction(action, param, options)
|
||||
this.graph.nodes_actioning[this.id] = false // .pop();
|
||||
this.graph.nodes_actioning[this.id] = false
|
||||
|
||||
// save execution/action ref
|
||||
if (options?.action_call) {
|
||||
this.action_call = options.action_call // if (param)
|
||||
this.action_call = options.action_call
|
||||
this.graph.nodes_executedAction[this.id] = options.action_call
|
||||
}
|
||||
}
|
||||
this.action_triggered = 2 // the nFrames it will be used (-- each step), means "how old" is the event
|
||||
// the nFrames it will be used (-- each step), means "how old" is the event
|
||||
this.action_triggered = 2
|
||||
this.onAfterExecuteNode?.(param, options)
|
||||
}
|
||||
|
||||
@@ -1279,7 +1275,6 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
options.action_call = this.id + "_act_" + Math.floor(Math.random() * 9999)
|
||||
// pass the action name
|
||||
const target_connection = node.inputs[link_info.target_slot]
|
||||
// wrap node.onAction(target_connection.name, param);
|
||||
node.actionDo(target_connection.name, param, options)
|
||||
}
|
||||
}
|
||||
@@ -1544,7 +1539,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
)
|
||||
const size = out || new Float32Array([0, 0])
|
||||
rows = Math.max(rows, 1)
|
||||
const font_size = LiteGraph.NODE_TEXT_SIZE // although it should be graphcanvas.inner_text_font size
|
||||
// although it should be graphcanvas.inner_text_font size
|
||||
const font_size = LiteGraph.NODE_TEXT_SIZE
|
||||
|
||||
const title_width = compute_text_size(this.title)
|
||||
let input_width = 0
|
||||
@@ -2139,7 +2135,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
const length = slots?.length
|
||||
if (!length) return -1
|
||||
|
||||
// !! empty string type is considered 0, * !!
|
||||
// Empty string and * match anything (type: 0)
|
||||
if (type == "" || type == "*") type = 0
|
||||
const sourceTypes = String(type).toLowerCase()
|
||||
.split(",")
|
||||
@@ -2519,9 +2515,11 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
// is the link we are searching for...
|
||||
if (link_info?.target_id == target.id) {
|
||||
links.splice(i, 1) // remove here
|
||||
// remove here
|
||||
links.splice(i, 1)
|
||||
const input = target.inputs[link_info.target_slot]
|
||||
input.link = null // remove there
|
||||
// remove there
|
||||
input.link = null
|
||||
|
||||
// remove the link from the links pool
|
||||
graph._links.delete(link_id)
|
||||
@@ -3060,8 +3058,9 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
if (this.collapsed) {
|
||||
ctx.textAlign = "left"
|
||||
ctx.fillText(
|
||||
title.substr(0, 20), // avoid urls too long
|
||||
title_height, // + measure.width * 0.5,
|
||||
// avoid urls too long
|
||||
title.substr(0, 20),
|
||||
title_height,
|
||||
LiteGraph.NODE_TITLE_TEXT_Y - title_height,
|
||||
)
|
||||
ctx.textAlign = "left"
|
||||
@@ -3227,7 +3226,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
if (input_slot) {
|
||||
const x = 0
|
||||
const y = LiteGraph.NODE_TITLE_HEIGHT * -0.5 // center
|
||||
const y = LiteGraph.NODE_TITLE_HEIGHT * -0.5
|
||||
toClass(NodeInputSlot, input_slot).drawCollapsed(ctx, {
|
||||
pos: [x, y],
|
||||
})
|
||||
@@ -3235,7 +3234,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
if (output_slot) {
|
||||
const x = this._collapsed_width
|
||||
const y = LiteGraph.NODE_TITLE_HEIGHT * -0.5 // center
|
||||
const y = LiteGraph.NODE_TITLE_HEIGHT * -0.5
|
||||
toClass(NodeOutputSlot, output_slot).drawCollapsed(ctx, {
|
||||
pos: [x, y],
|
||||
})
|
||||
|
||||
@@ -73,7 +73,8 @@ export class LLink implements LinkSegment, Serialisable<SerialisableLLink> {
|
||||
this.parentId = parentId
|
||||
|
||||
this._data = null
|
||||
this._pos = new Float32Array(2) // center
|
||||
// center
|
||||
this._pos = new Float32Array(2)
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link LLink.create} */
|
||||
|
||||
@@ -134,7 +134,8 @@ export class LiteGraphGlobal {
|
||||
debug = false
|
||||
catch_exceptions = true
|
||||
throw_errors = true
|
||||
allow_scripts = false // if set to true some nodes like Formula would be allowed to evaluate code that comes from unsafe sources (like node configuration), which could lead to exploits
|
||||
/** if set to true some nodes like Formula would be allowed to evaluate code that comes from unsafe sources (like node configuration), which could lead to exploits */
|
||||
allow_scripts = false
|
||||
/** nodetypes by string */
|
||||
registered_node_types: Record<string, typeof LGraphNode> = {}
|
||||
/** used for dropping files in the canvas */
|
||||
@@ -787,7 +788,8 @@ export class LiteGraphGlobal {
|
||||
hex2num(hex: string): number[] {
|
||||
if (hex.charAt(0) == "#") {
|
||||
hex = hex.slice(1)
|
||||
} // Remove the '#' char - if there is one.
|
||||
// Remove the '#' char - if there is one.
|
||||
}
|
||||
hex = hex.toUpperCase()
|
||||
const hex_alphabets = "0123456789ABCDEF"
|
||||
const value = new Array(3)
|
||||
|
||||
@@ -55,7 +55,7 @@ export function toNodeSlotClass(slot: INodeSlot): NodeSlot {
|
||||
|
||||
/**
|
||||
* Whether this slot is an input slot and attached to a widget.
|
||||
* @param slot - The slot to check.
|
||||
* @param slot The slot to check.
|
||||
*/
|
||||
export function isWidgetInputSlot(slot: INodeSlot): slot is IWidgetInputSlot {
|
||||
return isINodeInputSlot(slot) && !!slot.widget
|
||||
@@ -84,7 +84,7 @@ export abstract class NodeSlot implements INodeSlot {
|
||||
|
||||
/**
|
||||
* Whether this slot is a valid target for a dragging link.
|
||||
* @param link - The link to check against.
|
||||
* @param link The link to check against.
|
||||
*/
|
||||
abstract isValidTarget(link: ConnectingLink | null): boolean
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ export class Reroute implements Positionable, LinkSegment, Serialisable<Serialis
|
||||
#network: WeakRef<LinkNetwork>
|
||||
|
||||
#parentId?: RerouteId
|
||||
/** @inheritdoc */
|
||||
public get parentId(): RerouteId | undefined {
|
||||
return this.#parentId
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ export interface Positionable extends Parent<Positionable> {
|
||||
|
||||
/**
|
||||
* Cached position & size as `x, y, width, height`.
|
||||
* @readonly See {@link move}
|
||||
* @readonly
|
||||
* @see {@link move}
|
||||
*/
|
||||
readonly boundingRect: ReadOnlyRect
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export function loadPolyfills() {
|
||||
this.lineTo(x, y + bottom_left_radius)
|
||||
this.quadraticCurveTo(x, y, x + top_left_radius, y)
|
||||
}
|
||||
} // if
|
||||
}
|
||||
|
||||
if (typeof window != "undefined" && !window["requestAnimationFrame"]) {
|
||||
window.requestAnimationFrame =
|
||||
|
||||
@@ -216,7 +216,7 @@ export interface IBaseWidget<TElement extends HTMLElement = HTMLElement> {
|
||||
* @param pointer The CanvasPointer handling this event
|
||||
* @param node The node this widget belongs to
|
||||
* @param canvas The LGraphCanvas where this event originated
|
||||
* @return Returning `true` from this callback forces Litegraph to ignore the event and
|
||||
* @returns Returning `true` from this callback forces Litegraph to ignore the event and
|
||||
* not process it any further.
|
||||
*/
|
||||
onPointerDown?(pointer: CanvasPointer, node: LGraphNode, canvas: LGraphCanvas): boolean
|
||||
|
||||
@@ -64,10 +64,9 @@ export abstract class BaseWidget implements IBaseWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
*
|
||||
* @note Not naming this `draw` as `draw` conflicts with the `draw` method in
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
* @remarks Not naming this `draw` as `draw` conflicts with the `draw` method in
|
||||
* custom widgets.
|
||||
*/
|
||||
abstract drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
@@ -79,7 +78,7 @@ export abstract class BaseWidget implements IBaseWidget {
|
||||
|
||||
/**
|
||||
* Handles the click event for the widget
|
||||
* @param options - The options for handling the click event
|
||||
* @param options The options for handling the click event
|
||||
*/
|
||||
abstract onClick(options: {
|
||||
e: CanvasMouseEvent
|
||||
@@ -89,7 +88,7 @@ export abstract class BaseWidget implements IBaseWidget {
|
||||
|
||||
/**
|
||||
* Handles the drag event for the widget
|
||||
* @param options - The options for handling the drag event
|
||||
* @param options The options for handling the drag event
|
||||
*/
|
||||
onDrag?(options: {
|
||||
e: CanvasMouseEvent
|
||||
@@ -99,8 +98,8 @@ export abstract class BaseWidget implements IBaseWidget {
|
||||
|
||||
/**
|
||||
* Sets the value of the widget
|
||||
* @param value - The value to set
|
||||
* @param options - The options for setting the value
|
||||
* @param value The value to set
|
||||
* @param options The options for setting the value
|
||||
*/
|
||||
setValue(value: TWidgetValue, options: {
|
||||
e: CanvasMouseEvent
|
||||
|
||||
@@ -19,8 +19,8 @@ export class ButtonWidget extends BaseWidget implements IButtonWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
*/
|
||||
override drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
y: number
|
||||
|
||||
@@ -19,8 +19,8 @@ export class ComboWidget extends BaseWidget implements IComboWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
*/
|
||||
override drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
y: number
|
||||
@@ -100,7 +100,8 @@ export class ComboWidget extends BaseWidget implements IComboWidget {
|
||||
const charWidthAvg = ctx.measureText("a").width
|
||||
|
||||
if (availableWidth <= ellipsisWidth) {
|
||||
displayValue = "\u2024" // One dot leader
|
||||
// One dot leader
|
||||
displayValue = "\u2024"
|
||||
} else {
|
||||
displayValue = `${displayValue}`
|
||||
const overflowWidth = (textWidth + ellipsisWidth) - availableWidth
|
||||
@@ -160,7 +161,8 @@ export class ComboWidget extends BaseWidget implements IComboWidget {
|
||||
// Handle left/right arrow clicks
|
||||
if (delta) {
|
||||
let index = -1
|
||||
canvas.last_mouseclick = 0 // avoids double click event
|
||||
// avoids double click event
|
||||
canvas.last_mouseclick = 0
|
||||
index = typeof values === "object"
|
||||
? values_list.indexOf(String(this.value)) + delta
|
||||
// @ts-expect-error handle non-string values
|
||||
|
||||
@@ -18,8 +18,8 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
*/
|
||||
override drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
y: number
|
||||
@@ -141,7 +141,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
|
||||
|
||||
/**
|
||||
* Handles drag events for the number widget
|
||||
* @param options - The options for handling the drag event
|
||||
* @param options The options for handling the drag event
|
||||
*/
|
||||
override onDrag(options: {
|
||||
e: CanvasMouseEvent
|
||||
|
||||
@@ -22,8 +22,8 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
*/
|
||||
override drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
y: number
|
||||
|
||||
@@ -18,8 +18,8 @@ export class TextWidget extends BaseWidget implements IStringWidget {
|
||||
|
||||
/**
|
||||
* Draws the widget
|
||||
* @param ctx - The canvas context
|
||||
* @param options - The options for drawing the widget
|
||||
* @param ctx The canvas context
|
||||
* @param options The options for drawing the widget
|
||||
*/
|
||||
override drawWidget(ctx: CanvasRenderingContext2D, options: {
|
||||
y: number
|
||||
@@ -65,7 +65,8 @@ export class TextWidget extends BaseWidget implements IStringWidget {
|
||||
ctx.fillStyle = this.text_color
|
||||
ctx.textAlign = "right"
|
||||
ctx.fillText(
|
||||
String(this.value).substr(0, 30), // 30 chars max
|
||||
// 30 chars max
|
||||
String(this.value).substr(0, 30),
|
||||
widget_width - margin * 2,
|
||||
y + H * 0.7,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user