From 284bfde3fac4da77985ac535554a462c9de81d85 Mon Sep 17 00:00:00 2001 From: Crystian Date: Thu, 11 Jan 2024 14:04:08 +0100 Subject: [PATCH] ts added --- .editorconfig | 20 + .eslintrc.cjs | 159 ++++++ .gitignore | 1 + __dev__.py | 23 + __init__.py | 2 +- general/stats.py | 11 +- package-lock.json | 1148 +++++++++++++++++++++++++++++++++++++++++ package.json | 19 + tsconfig.json | 55 ++ web/ts/common.ts | 75 +++ web/ts/debugger.ts | 70 +++ web/ts/extensions.ts | 22 + web/ts/monitor.ts | 371 +++++++++++++ web/ts/progressBar.ts | 191 +++++++ 14 files changed, 2163 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.cjs create mode 100644 __dev__.py create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 tsconfig.json create mode 100644 web/ts/common.ts create mode 100644 web/ts/debugger.ts create mode 100644 web/ts/extensions.ts create mode 100644 web/ts/monitor.ts create mode 100644 web/ts/progressBar.ts diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3df5834 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 2 +max_line_length = 120 + +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..89c4476 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,159 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked' + ], + parser: '@typescript-eslint/parser', + plugins: [], + parserOptions: { + tsconfigRootDir: __dirname, + sourceType: 'module', + ecmaVersion: 'latest', + ecmaFeatures: { + // experimentalObjectRestSpread: true, + modules: true, + legacyDecorators: true, + jsx: true, + }, + project: ['./tsconfig.json'], + }, + rules: { + 'import/extensions': [ + 'error', 'always', { + pattern: { + 'ts': 'never', + 'js': 'never', + }, + }, + ], + 'import/no-unresolved': ['off'], + 'class-methods-use-this': ['off'], + 'radix': ['off'], + 'import/prefer-default-export': ['off'], + 'implicit-arrow-linebreak': ['off'], + 'no-trailing-spaces': [ + 'error', { + 'skipBlankLines': true, + 'ignoreComments': true, + }, + ], + 'max-len': [ + 'error', { + 'code': 120, + }, + ], + + 'import/no-extraneous-dependencies': [ + 'error', { + 'devDependencies': ['**/__tests__/*.ts', '**/__mocks__/*.ts'], + }, + ], + + 'one-var': ['off'], + + // false positive https://github.com/typescript-eslint/typescript-eslint/issues/2483 + 'no-shadow': 'off', + 'object-curly-newline': ["error", { + "ObjectExpression": { "multiline": true, "minProperties": 1 }, + "ObjectPattern": { "multiline": true, "minProperties": 1 }, + "ImportDeclaration": {"multiline": true, "minProperties": 8 }, + "ExportDeclaration": { "multiline": true, "minProperties": 1 } + }], + '@typescript-eslint/no-shadow': 'error', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/prefer-nullish-coalescing': 'off', + '@typescript-eslint/consistent-type-definitions': 'off', + '@typescript-eslint/no-unused-expressions': [ + 'error', + { + 'allowShortCircuit': true, + 'allowTernary': true, + }, + ], + '@typescript-eslint/no-use-before-define': ['off'], + '@typescript-eslint/no-unused-vars': [ + 'error', + {'argsIgnorePattern': '^_'}, + ], + '@typescript-eslint/explicit-module-boundary-types': [ + 'error', { + allowArgumentsExplicitlyTypedAsAny: true, + }, + ], + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': [ + 'error', + {'ts-expect-error': 'allow-with-description'}, + ], + '@typescript-eslint/no-empty-function': [ + 'error', + { + 'allow': [ + 'methods', + 'asyncMethods', + ], + }, + ], + + 'lines-between-class-members': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + + 'curly': ['error', 'multi-line', 'consistent'], + 'no-unused-vars': 'off', + 'jest/no-test-prefixes': 'off', + 'jest/no-focused-tests': 'off', + 'comma-dangle': ['error', 'only-multiline'], + 'linebreak-style': ['error', 'unix'], + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], + 'eqeqeq': ['error', 'always'], + 'complexity': [ + 'error', { + max: 6, + }, + ], + 'block-scoped-var': 'error', + 'no-else-return': [ + 'error', { + allowElseIf: true, + }, + ], + 'no-eval': 'error', + 'no-lone-blocks': 'error', + 'no-multi-spaces': 'error', + 'no-useless-return': 'error', + 'no-var': 'error', + 'no-console': [ + // 'error', { + // allow: ['warn', 'error'], + // }, + 'off', + ], + 'no-throw-literal': 'error', + 'newline-per-chained-call': [ + 'error', { + ignoreChainWithDepth: 4, + }, + ], + 'no-extra-boolean-cast': [ + 'error', { + enforceForLogicalOperands: true, + }, + ], + 'no-fallthrough': 'error', + 'no-use-before-define': 'off', + 'no-case-declarations': 'off', + }, + ignorePatterns: [ + 'node_modules' + ], + globals: {}, +} diff --git a/.gitignore b/.gitignore index 9e50be2..fb9c110 100644 --- a/.gitignore +++ b/.gitignore @@ -153,3 +153,4 @@ cython_debug/ *.pyc .idea +/node_modules diff --git a/__dev__.py b/__dev__.py new file mode 100644 index 0000000..6231b44 --- /dev/null +++ b/__dev__.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import subprocess +import os +import shutil +import glob +import json + +print('Running __dev__.py') +# from config import RGTHREE_CONFIG +# +# THIS_DIR=os.path.dirname(os.path.abspath(__file__)) +# DIR_WEB = os.path.abspath(f'{THIS_DIR}/web/') +# DIR_WEB_COMFYUI = os.path.abspath(f'{DIR_WEB}/comfyui/') +# +# js_files = glob.glob(os.path.join(THIS_DIR, 'web/**/*.js')) +# for file in js_files: +# os.remove(file) +# +# subprocess.run(["./node_modules/typescript/bin/tsc"]) +# +# with open(os.path.join(DIR_WEB_COMFYUI, 'rgthree_config.js'), 'w', encoding = 'UTF-8') as file: +# file.write('export const rgthreeConfig = ' + json.dumps(RGTHREE_CONFIG)) diff --git a/__init__.py b/__init__.py index c9610f3..7f7fd0a 100644 --- a/__init__.py +++ b/__init__.py @@ -94,4 +94,4 @@ NODE_DISPLAY_NAME_MAPPINGS = { } -WEB_DIRECTORY = "./web" +WEB_DIRECTORY = "./web/js" diff --git a/general/stats.py b/general/stats.py index e0cd3ae..0901650 100644 --- a/general/stats.py +++ b/general/stats.py @@ -3,11 +3,16 @@ import cpuinfo import psutil import torch import pynvml -from comfy.model_management import get_torch_device_name, get_torch_device +import comfy.model_management from ..core import logger + class CStats: + """ + This is only class to get information from hardware. + Specially for share it to other software. + """ nvidia = False pynvmlLoaded = False cudaAvailable = False @@ -127,12 +132,12 @@ class CStats: if self.pynvmlLoaded and pynvml.nvmlDeviceGetCount() > 0: self.cudaDevicesFound = pynvml.nvmlDeviceGetCount() self.nvidia = True - logger.info(f'NVIDIA Driver detected - {pynvml.nvmlSystemGetDriverVersion()} - {get_torch_device_name(get_torch_device())}') + logger.info(f'NVIDIA Driver detected - {pynvml.nvmlSystemGetDriverVersion()} - {comfy.model_management.get_torch_device_name(comfy.model_management.get_torch_device())}') else: logger.warn('No NVIDIA GPU detected.') try: - self.torchDevice = get_torch_device_name(get_torch_device()) + self.torchDevice = comfy.model_management.get_torch_device_name(comfy.model_management.get_torch_device()) except Exception as e: logger.error('Could not pick default device.' + str(e)) diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e71e04b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1148 @@ +{ + "name": "crystools-typescript", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "crystools-typescript", + "version": "1.0.0", + "devDependencies": { + "eslint": "^8.56.0", + "typescript": "^5.3.3" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "dev": true + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", + "@humanwhocodes/config-array": "^0.11.13", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "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==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", + "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", + "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", + "dev": true + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6013d07 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "crystools-typescript", + "private": true, + "version": "1.0.0", + "type": "module", + "scripts": { + "start": "tsc", + "build": "tsc && vite build --emptyOutDir", + "tsc": "tsc", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint-fix": "eslint src --fix", + "validate": "npm test && npm run coverage && npm run lintcss && npm run tsc && npm run lint && npm run tsc", + "fix": "npm run lint-fix" + }, + "devDependencies": { + "eslint": "^8.56.0", + "typescript": "^5.3.3" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2fb45ca --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,55 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + // "typeRoots": [ + // "./ts/typings", + // ], + "baseUrl": "./", + "paths": { + "*": ["web/ts/typings/*"], + }, + "outDir": "web/", + "removeComments": true, + "strict": true, + "noImplicitAny": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictBindCallApply": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "useUnknownInCatchVariables": true, + "alwaysStrict": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + "exactOptionalPropertyTypes": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "allowUnusedLabels": true, + "skipLibCheck": true, + + "useDefineForClassFields": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true + }, + "include": [ + "web/ts/*.ts", "web/ts/**/*.ts", "web/ts/typings/index.d.ts", + ], + "exclude": [ + "**/*.spec.ts", + "**/*.d.ts", + "node_modules/**/*.ts" + ], + + + +} diff --git a/web/ts/common.ts b/web/ts/common.ts new file mode 100644 index 0000000..d2c32f1 --- /dev/null +++ b/web/ts/common.ts @@ -0,0 +1,75 @@ +import { ComfyWidgets } from '../../../scripts/widgets.js'; + +export const commonPrefix = '🪛'; + +export function displayContext(nodeType, app, index = 0, serialize_widgets = false, isVirtualNode = false) { + function populate(text) { + if (this.widgets) { + const pos = this.widgets.findIndex((w) => w.name === 'text'); + if (pos !== -1) { + for (let i = pos; i < this.widgets.length; i++) { + this.widgets[i].onRemove?.(); + } + this.widgets.length = pos; + } + } + // if want to not save properties in the node (be careful with F5) + // BUG on isVirtualNode, with "true", it ignores OUTPUT_NODE on py file! + this.serialize_widgets = serialize_widgets; + this.isVirtualNode = isVirtualNode; + + const w = ComfyWidgets['STRING'](this, 'text', ['STRING', {multiline: true}], app).widget; + w.inputEl.readOnly = true; + w.inputEl.style.opacity = 0.6; + if (Array.isArray(text)) { + text = text[index]; + } + w.value = text || ''; + w.serializeValue = async() => {}; // just for no serialized to itself! + + requestAnimationFrame(() => { + const sz = this.computeSize(); + if (sz[0] < this.size[0]) { + sz[0] = this.size[0]; + } + if (sz[1] < this.size[1]) { + sz[1] = this.size[1]; + } + this.onResize?.(sz); + app.graph.setDirtyCanvas(true, false); + }); + } + + // When the node is executed we will be sent the input text, display this in the widget + const onExecuted = nodeType.prototype.onExecuted; + nodeType.prototype.onExecuted = function(message) { + onExecuted?.apply(this, arguments); + populate.call(this, message.text); + }; + + const onConfigure = nodeType.prototype.onConfigure; + nodeType.prototype.onConfigure = function() { + onConfigure?.apply(this, arguments); + if (this.widgets_values?.length) { + populate.call(this, this.widgets_values); + } + }; +} + +// propagate the output value to the dependents nodes, it does not work with some nodes ¯\_(ツ)_/¯ +const propagateOutputToDependentsNodes = function(output, value) { + if (output.links && output.links.length) { + for (const l of output.links) { + const link_info = app.graph.links[l]; + const outNode = app.graph.getNodeById(link_info.target_id); + const outIn = outNode && outNode.inputs && outNode.inputs[link_info.target_slot]; + if (outIn.widget) { + const w = outNode.widgets.find((w) => w.name === outIn.widget.name); + if (!w) { + continue; + } + w.value = value; + } + } + } +}; diff --git a/web/ts/debugger.ts b/web/ts/debugger.ts new file mode 100644 index 0000000..334b376 --- /dev/null +++ b/web/ts/debugger.ts @@ -0,0 +1,70 @@ +import { app } from '../../../scripts/app.js'; +import { api } from '../../../scripts/api.js'; +import { ComfyWidgets } from '../../../scripts/widgets.js'; +import { commonPrefix, displayContext } from './common.js'; + +// "Show any" Node +app.registerExtension({ + name: 'Crystools.Debugger.ConsoleAny', + async beforeRegisterNodeDef(nodeType, nodeData, app) { + if (nodeData.name === 'Show any [Crystools]') { + // 3 is the index of the text field in the node + displayContext(nodeType, app, 3); + } + }, +}); + +app.registerExtension({ + name: 'Crystools.Debugger.Metadata', + + registerCustomNodes() { + class MetadataNode { + constructor() { + this.serialize_widgets = false; + this.isVirtualNode = true; + + const w = ComfyWidgets.STRING(this, '', ['', {default: '', multiline: true}], app).widget; + w.inputEl.readOnly = true; + ComfyWidgets.BOOLEAN(this, 'Active', ['', {default: true}], app); + ComfyWidgets.BOOLEAN(this, 'Parsed', ['', {default: true}], app); + ComfyWidgets.COMBO(this, 'What', [['Prompt', 'Workflow'], {default: 'Prompt'}]); + + // It runs at finish on each prompt queue + api.addEventListener('executed', this.fillMetadataWidget); + } + + fillMetadataWidget = () => { + app.graphToPrompt() + .then(workflow => { + let result = 'inactive'; + // debugger + const output = this.widgets[0]; + const active = this.widgets[1].value; + const parsed = this.widgets[2].value; + let what = this.widgets[3].value.toLowerCase(); + + if (active) { + what = what === 'prompt' ? 'output' : what; // little fix for better understanding + result = workflow[what]; + if (parsed) { + result = JSON.stringify(result, null, 2); + } else { + result = JSON.stringify(result); + } + } + + output.value = result; + }); + } + } + + // I'm not sure for what they're using prototype and lots of black magic, don't change the order! + LiteGraph.registerNodeType('Show Metadata [Crystools]', MetadataNode); + MetadataNode.category = `crystools ${commonPrefix}/Debugger`; + MetadataNode.shape = LiteGraph.BOX_SHAPE; + MetadataNode.title = `Show Metadata ${commonPrefix}`; + // MetadataNode.collapsable = false; + // MetadataNode.color = "#FF2222"; + // MetadataNode.bgcolor = "#000000"; + }, +}); diff --git a/web/ts/extensions.ts b/web/ts/extensions.ts new file mode 100644 index 0000000..edba9dd --- /dev/null +++ b/web/ts/extensions.ts @@ -0,0 +1,22 @@ +import { app } from '../../../scripts/app.js'; +import { displayContext } from './common.js'; + +let crystoolsExtensions = { + 'Get resolution [Crystools]': 'Crystools.Image.GetResolution', + 'Preview from image [Crystools]': 'Crystools.Image.PreviewFromImage', + 'Preview from metadata [Crystools]': 'Crystools.Image.PreviewFromMetadata', + 'Metadata comparator [Crystools]': 'Crystools.Metadata.MetadataComparator', + 'Stats system [Crystools]': 'Crystools.Utils.StatsSystem', + 'Show any to JSON [Crystools]': 'Crystools.Debugger.ConsoleAnyToJson', +}; + +Object.keys(crystoolsExtensions).forEach(key => { + app.registerExtension({ + name: crystoolsExtensions[key], + async beforeRegisterNodeDef(nodeType, nodeData, app) { + if (nodeData.name === key) { + displayContext(nodeType, app, 0); + } + }, + }); +}); diff --git a/web/ts/monitor.ts b/web/ts/monitor.ts new file mode 100644 index 0000000..f0097cb --- /dev/null +++ b/web/ts/monitor.ts @@ -0,0 +1,371 @@ +import { app } from '../../../scripts/app.js'; +import { api } from '../../../scripts/api.js'; +import { commonPrefix } from './common.js'; + +class CrystoolsMonitor { + idExtensionName = 'Crystools.monitor'; + menuPrefix = commonPrefix; + htmlIdCrystoolsRoot = 'crystools-root'; + htmlIdCrystoolsMonitorContainer = 'crystools-monitor-container'; + + idInputRate = 'Crystools.inputRate'; + defaultRate = .5; + + /** MONITORS */ + // CPU Variables + idSwitchCPU = 'Crystools.switchCPU'; + defaultSwitchCPU = true; + htmlMonitorCPURef = null; + htmlMonitorCPUSliderRef = null; + htmlMonitorCPULabelRef = null; + cssColorCPU = '#0AA015'; + + // RAM Variables + idSwitchRAM = 'Crystools.switchRAM'; + defaultSwitchRAM = true; + htmlMonitorRAMRef = null; + htmlMonitorRAMSliderRef = null; + htmlMonitorRAMLabelRef = null; + cssColorRAM = '#07630D'; + + // GPU Variables + idSwitchGPU = 'Crystools.switchGPU'; + defaultSwitchGPU = true; + htmlMonitorGPURef = null; + htmlMonitorGPUSliderRef = null; + htmlMonitorGPULabelRef = null; + cssColorGPU = '#0C86F4'; + + // VRAM Variables + idSwitchVRAM = 'Crystools.switchVRAM'; + defaultSwitchVRAM = true; + htmlMonitorVRAMRef = null; + htmlMonitorVRAMSliderRef = null; + htmlMonitorVRAMLabelRef = null; + cssColorVRAM = '#176EC7'; + + // HDD Variables + idSwitchHDD = 'Crystools.switchHDD'; + defaultSwitchHDD = false; + htmlMonitorHDDRef = null; + htmlMonitorHDDSliderRef = null; + htmlMonitorHDDLabelRef = null; + cssColorHDD = '#730F92'; + + constructor() { + this.createSettings(); + } + + createSettings = () => { + app.ui.settings.addSetting({ + id: this.idSwitchCPU, + name: this.menuPrefix + 'Display CPU monitor [menu]', + type: 'boolean', + defaultValue: this.defaultSwitchCPU, + onChange: async(value) => { + this.updateWidget(this.htmlMonitorCPURef, value); + await this.updateServer({switchCPU: value}); + }, + }); + app.ui.settings.addSetting({ + id: this.idSwitchRAM, + name: this.menuPrefix + 'Display RAM monitor [menu]', + type: 'boolean', + defaultValue: this.defaultSwitchRAM, + onChange: async(value) => { + this.updateWidget(this.htmlMonitorRAMRef, value); + await this.updateServer({switchRAM: value}); + }, + }); + app.ui.settings.addSetting({ + id: this.idSwitchGPU, + name: this.menuPrefix + 'Display GPU monitor [menu]', + type: 'boolean', + defaultValue: this.defaultSwitchGPU, + onChange: async(value) => { + this.updateWidget(this.htmlMonitorGPURef, value); + await this.updateServer({switchGPU: value}); + }, + }); + app.ui.settings.addSetting({ + id: this.idSwitchVRAM, + name: this.menuPrefix + 'Display Video RAM monitor [menu]', + type: 'boolean', + defaultValue: this.defaultSwitchVRAM, + onChange: async(value) => { + this.updateWidget(this.htmlMonitorVRAMRef, value); + await this.updateServer({switchVRAM: value}); + }, + }); + app.ui.settings.addSetting({ + id: this.idSwitchHDD, + name: this.menuPrefix + 'Display Hard disk monitor [menu]', + tooltip: 'Only the drive where the comfyUI is installed', + type: 'boolean', + defaultValue: this.defaultSwitchHDD, + onChange: async(value) => { + this.updateWidget(this.htmlMonitorHDDRef, value); + await this.updateServer({switchHDD: value}); + }, + }); + + app.ui.settings.addSetting({ + id: this.idInputRate, + name: this.menuPrefix + 'Monitors refresh rate (in seconds) [menu]', + tooltip: 'This is the time between each update of the monitors, 0 means no refresh', + type: 'slider', + attrs: { + min: 0, + max: 5, + step: 0.25, + }, + defaultValue: this.defaultRate, + onChange: async(value) => { + try { + value = parseFloat(value); + if (isNaN(value)) { + throw new Error('invalid value'); + } + } catch (error) { + console.error(error); + return; + } + try { + await this.updateServer({rate: value}); + } catch (error) { + console.error(error); + return; + } + + if (value === 0) { + this.updateDisplay({ + cpu_utilization: 0, + device: 'cpu', + + gpus: [{ + gpu_utilization: 0, + vram_total: 0, + vram_used: 0, + vram_used_percent: 0, + }], + hdd_total: 0, + hdd_used: 0, + hdd_used_percent: 0, + ram_total: 0, + ram_used: 0, + ram_used_percent: 0, + }); + } + + if (this.htmlMonitorCPUSliderRef) { // validation because this run before setup + value = value.toFixed(1); + const animationConfig = `width ${value}s`; + this.htmlMonitorCPUSliderRef.style.transition = animationConfig; + this.htmlMonitorGPUSliderRef.style.transition = animationConfig; + this.htmlMonitorHDDSliderRef.style.transition = animationConfig; + this.htmlMonitorRAMSliderRef.style.transition = animationConfig; + this.htmlMonitorVRAMSliderRef.style.transition = animationConfig; + this.htmlMonitorCPUSliderRef.style.width = value; + this.htmlMonitorGPUSliderRef.style.width = value; + this.htmlMonitorHDDSliderRef.style.width = value; + this.htmlMonitorRAMSliderRef.style.width = value; + this.htmlMonitorVRAMSliderRef.style.width = value; + } + }, + }); + }; + + updateServer = async(data) => { + const resp = await api.fetchApi('/crystools/monitor', { + method: 'PATCH', + body: JSON.stringify(data), + cache: 'no-store', + }); + if (resp.status === 200) { + return await resp.text(); + } else { + throw new Error(resp.statusText); + } + }; + + updateAllWidget = () => { + this.updateWidget(this.htmlMonitorCPURef, app.ui.settings.getSettingValue(this.idSwitchCPU, this.defaultSwitchCPU)); + this.updateWidget(this.htmlMonitorGPURef, app.ui.settings.getSettingValue(this.idSwitchGPU, this.defaultSwitchGPU)); + this.updateWidget(this.htmlMonitorHDDRef, app.ui.settings.getSettingValue(this.idSwitchHDD, this.defaultSwitchHDD)); + this.updateWidget(this.htmlMonitorRAMRef, app.ui.settings.getSettingValue(this.idSwitchRAM, this.defaultSwitchRAM)); + this.updateWidget(this.htmlMonitorVRAMRef, app.ui.settings.getSettingValue(this.idSwitchVRAM, this.defaultSwitchVRAM)); + }; + + updateWidget = (container, value) => { + if (container) { + container.style.display = value ? 'flex' : 'none'; + } + }; + + updateDisplay = (data) => { + // console.log('updateDisplay', data); + if (!this.htmlMonitorCPULabelRef) { + return; + } + this.htmlMonitorCPULabelRef.innerHTML = `${Math.floor(data.cpu_utilization)}%`; + this.htmlMonitorCPUSliderRef.style.width = this.htmlMonitorCPULabelRef.innerHTML; + + const gpu = data.gpus[0]; + if (gpu) { + this.htmlMonitorGPULabelRef.innerHTML = `${Math.floor(gpu.gpu_utilization)}%`; + this.htmlMonitorGPUSliderRef.style.width = this.htmlMonitorGPULabelRef.innerHTML; + this.htmlMonitorVRAMLabelRef.innerHTML = `${Math.floor(gpu.vram_used_percent)}%`; + this.htmlMonitorVRAMSliderRef.style.width = this.htmlMonitorVRAMLabelRef.innerHTML; + } else { + console.error('no gpu found'); + } + + this.htmlMonitorHDDLabelRef.innerHTML = `${Math.floor(data.hdd_used_percent)}%`; + this.htmlMonitorHDDSliderRef.style.width = this.htmlMonitorHDDLabelRef.innerHTML; + + this.htmlMonitorRAMLabelRef.innerHTML = `${Math.floor(data.ram_used_percent)}%`; + this.htmlMonitorRAMSliderRef.style.width = this.htmlMonitorRAMLabelRef.innerHTML; + }; + + setup() { + const parentElement = document.getElementById('queue-button'); + + let ctoolsRoot = document.getElementById(this.htmlIdCrystoolsRoot); + if (!ctoolsRoot) { + ctoolsRoot = document.createElement('div'); + ctoolsRoot.setAttribute('id', this.htmlIdCrystoolsRoot); + ctoolsRoot.style.display = 'flex'; + ctoolsRoot.style.width = '100%'; + ctoolsRoot.style.flexDirection = 'column'; + parentElement.insertAdjacentElement('afterend', ctoolsRoot); + } + + const htmlContainer = document.createElement('div'); + htmlContainer.setAttribute('id', this.htmlIdCrystoolsMonitorContainer); + htmlContainer.style.width = '100%'; + htmlContainer.style.cursor = 'crosshair'; + htmlContainer.style.order = '3'; + htmlContainer.style.margin = '4px 0'; + ctoolsRoot.append(htmlContainer); + + htmlContainer.append(this.createMonitorCPU()); + htmlContainer.append(this.createMonitorRAM()); + htmlContainer.append(this.createMonitorGPU()); + htmlContainer.append(this.createMonitorVRAM()); + htmlContainer.append(this.createMonitorHDD()); + + this.updateAllWidget(); + this.registerListeners(); + } + + createMonitor = (id, label, color) => { + const option = { + rootRef: null, + sliderRef: null, + labelRef: null, + }; + + const htmlMain = document.createElement('div'); + htmlMain.setAttribute('id', id); + htmlMain.style.margin = '2px 10px'; + htmlMain.style.height = '12px'; + htmlMain.style.position = 'relative'; + htmlMain.style.display = 'flex'; + htmlMain.style.alignItems = 'center'; + htmlMain.style.flexDirection = 'row'; + option.rootRef = htmlMain; + + const htmlMonitorText = document.createElement('div'); + htmlMonitorText.style.width = '35px'; + htmlMonitorText.style.fontSize = '10px'; + htmlMonitorText.innerHTML = label; + htmlMain.append(htmlMonitorText); + + const htmlMonitorContent = document.createElement('div'); + htmlMonitorContent.style.height = '100%'; + htmlMonitorContent.style.flexGrow = '1'; + htmlMonitorContent.style.position = 'relative'; + htmlMonitorContent.style.backgroundColor = 'var(--bg-color)'; + htmlMain.append(htmlMonitorContent); + + const htmlMonitorSlider = document.createElement('div'); + htmlMonitorSlider.style.position = 'absolute'; + htmlMonitorSlider.style.height = '100%'; + htmlMonitorSlider.style.width = '0'; + htmlMonitorSlider.style.backgroundColor = color; + htmlMonitorSlider.style.transition = 'width 0.5s'; + option.sliderRef = htmlMonitorSlider; + htmlMonitorContent.append(htmlMonitorSlider); + + const htmlMonitorLabel = document.createElement('div'); + htmlMonitorLabel.style.position = 'relative'; + htmlMonitorLabel.style.width = '100%'; + htmlMonitorLabel.style.color = 'var(--drag-text)'; + htmlMonitorLabel.style.fontSize = '10px'; + htmlMonitorLabel.innerHTML = '0%'; + option.labelRef = htmlMonitorLabel; + htmlMonitorContent.append(htmlMonitorLabel); + + return option; + }; + + createMonitorCPU = () => { + const options = this.createMonitor('crystools-monitor-cpu', 'CPU', this.cssColorCPU); + + this.htmlMonitorCPURef = options.rootRef; + this.htmlMonitorCPUSliderRef = options.sliderRef; + this.htmlMonitorCPULabelRef = options.labelRef; + return this.htmlMonitorCPURef; + }; + + createMonitorRAM = () => { + const options = this.createMonitor('crystools-monitor-ram', 'RAM', this.cssColorRAM); + + this.htmlMonitorRAMRef = options.rootRef; + this.htmlMonitorRAMSliderRef = options.sliderRef; + this.htmlMonitorRAMLabelRef = options.labelRef; + return this.htmlMonitorRAMRef; + }; + + createMonitorGPU = () => { + const options = this.createMonitor('crystools-monitor-gpu', 'GPU', this.cssColorGPU); + + this.htmlMonitorGPURef = options.rootRef; + this.htmlMonitorGPUSliderRef = options.sliderRef; + this.htmlMonitorGPULabelRef = options.labelRef; + return this.htmlMonitorGPURef; + }; + + createMonitorVRAM = () => { + const options = this.createMonitor('crystools-monitor-vram', 'VRAM', this.cssColorVRAM); + + this.htmlMonitorVRAMRef = options.rootRef; + this.htmlMonitorVRAMSliderRef = options.sliderRef; + this.htmlMonitorVRAMLabelRef = options.labelRef; + return this.htmlMonitorVRAMRef; + }; + + createMonitorHDD = () => { + const options = this.createMonitor('crystools-monitor-hdd', 'HDD', this.cssColorHDD); + + this.htmlMonitorHDDRef = options.rootRef; + this.htmlMonitorHDDSliderRef = options.sliderRef; + this.htmlMonitorHDDLabelRef = options.labelRef; + return this.htmlMonitorHDDRef; + }; + + registerListeners = () => { + api.addEventListener('crystools.monitor', (event) => { + if (event?.detail === undefined) { + return; + } + this.updateDisplay(event.detail); + }); + }; +} + +const crystoolsMonitor = new CrystoolsMonitor(); +app.registerExtension({ + name: crystoolsMonitor.idExtensionName, + setup: crystoolsMonitor.setup.bind(crystoolsMonitor), +}); diff --git a/web/ts/progressBar.ts b/web/ts/progressBar.ts new file mode 100644 index 0000000..b05c586 --- /dev/null +++ b/web/ts/progressBar.ts @@ -0,0 +1,191 @@ +import { api } from '../../../scripts/api.js'; +import { app } from '../../../scripts/app.js'; +import { commonPrefix } from './common.js'; + +const status = { + executing: 'Executing', + executed: 'Executed', + execution_error: 'Execution error', +}; + +class CrystoolsProgressBar { + idExtensionName = 'Crystools.progressBar'; + idShowProgressBar = 'Crystools.showStatus'; + defaultShowStatus = true; + menuPrefix = commonPrefix; + htmlIdCrystoolsRoot = 'crystools-root'; + htmlIdCrystoolsProgressBarContainer = 'crystools-progress-bar-container'; + + currentStatus = status.executed; + currentProgress = 0; + currentNode = null; + timeStart = 0; + + htmlProgressSliderRef = null; + htmlProgressLabelRef = null; + + constructor() { + this.createSettings(); + } + + // not on setup because this affect the order on settings, I prefer to options at first + createSettings = () => { + app.ui.settings.addSetting({ + id: this.idShowProgressBar, + name: this.menuPrefix + 'Show progress bar [menu]', + type: 'boolean', + defaultValue: this.defaultShowStatus, + onChange: this.showProgressBar, + }); + }; + + showProgressBar = (value) => { + const container = document.getElementById(this.htmlIdCrystoolsProgressBarContainer); + + // validation because this run before setup + if (container) { + container.style.display = value ? 'block' : 'none'; + } + }; + + updateDisplay = () => { + if (this.currentStatus === status.executed) { + // finished + this.htmlProgressLabelRef.innerHTML = 'cached'; + + const timeElapsed = Date.now() - this.timeStart; + if (this.timeStart > 0 && timeElapsed > 0) { + this.htmlProgressLabelRef.innerHTML = new Date(timeElapsed).toISOString().substr(11, 8); + } + this.htmlProgressSliderRef.style.width = '0'; + + } else if (this.currentStatus === status.execution_error) { + // an error occurred + this.htmlProgressLabelRef.innerHTML = 'ERROR'; + this.htmlProgressSliderRef.style.backgroundColor = 'var(--error-text)'; + console.log('execution_error'); + + } else if (this.currentStatus === status.executing) { + // on going + this.htmlProgressLabelRef.innerHTML = `${this.currentProgress}%`; + this.htmlProgressSliderRef.style.width = this.htmlProgressLabelRef.innerHTML; + this.htmlProgressSliderRef.style.backgroundColor = 'green'; // by reset the color + } + }; + + setup() { + const parentElement= document.getElementById('queue-button'); + + let ctoolsRoot = document.getElementById(this.htmlIdCrystoolsRoot); + if(!ctoolsRoot){ + ctoolsRoot = document.createElement('div'); + ctoolsRoot.setAttribute('id', this.htmlIdCrystoolsRoot); + ctoolsRoot.style.display = 'flex'; + ctoolsRoot.style.width = '100%'; + ctoolsRoot.style.flexDirection = 'column'; + parentElement.insertAdjacentElement('afterend', ctoolsRoot); + } + + const htmlContainer = document.createElement('div'); + htmlContainer.setAttribute('id', this.htmlIdCrystoolsProgressBarContainer); + htmlContainer.setAttribute('title', 'click to see the current working node'); + htmlContainer.style.margin = '4px 0'; + htmlContainer.style.width = '100%'; + htmlContainer.style.cursor = 'pointer'; + htmlContainer.style.order = '1'; + htmlContainer.addEventListener('click', this.centerNode); + ctoolsRoot.append(htmlContainer); + + const progressBar = document.createElement('div'); + progressBar.style.margin = '0 10px'; + progressBar.style.height = '18px'; + progressBar.style.position = 'relative'; + progressBar.style.backgroundColor = 'var(--bg-color)'; + htmlContainer.append(progressBar); + + const progressSlider = document.createElement('div'); + progressSlider.style.position = 'absolute'; + progressSlider.style.height = '100%'; + progressSlider.style.width = '0'; + progressSlider.style.transition = 'width 0.2s'; + progressSlider.style.backgroundColor = 'green'; + this.htmlProgressSliderRef = progressSlider; + progressBar.append(this.htmlProgressSliderRef); + + const progressLabel = document.createElement('div'); + progressLabel.style.position = 'absolute'; + progressLabel.style.margin = 'auto 0'; + progressLabel.style.width = '100%'; + progressLabel.style.color = 'var(--drag-text)'; + progressLabel.style.fontSize = '14px'; + progressLabel.innerHTML = '0%'; + this.htmlProgressLabelRef = progressLabel; + progressBar.append(this.htmlProgressLabelRef); + + this.showProgressBar(app.ui.settings.getSettingValue(this.idShowProgressBar, this.defaultShowStatus)); + this.registerListeners(); + } + + registerListeners = () => { + api.addEventListener('status', ({detail}) => { + this.currentStatus = this.currentStatus === status.execution_error ? status.execution_error : status.executed; + let queueRemaining = detail && detail.exec_info.queue_remaining; + + if (queueRemaining) { + this.currentStatus = status.executing; + } + this.updateDisplay(); + }); + + api.addEventListener('progress', ({detail}) => { + const {value, max, node} = detail; + const progress = Math.floor((value / max) * 100); + + if (!isNaN(progress) && progress >= 0 && progress <= 100) { + this.currentProgress = progress; + this.currentNode = node; + } + + this.updateDisplay(); + }); + + api.addEventListener('executed', ({detail}) => { + if (detail?.node) { + this.currentNode = detail.node; + } + + this.updateDisplay(); + }); + + api.addEventListener('execution_start', ({detail}) => { + this.currentStatus = status.executing; + this.timeStart = Date.now(); + + this.updateDisplay(); + }); + + api.addEventListener('execution_error', ({detail}) => { + this.currentStatus = status.execution_error; + + this.updateDisplay(); + }); + }; + + centerNode = () => { + const id = this.currentNode; + if (!id) { + return; + } + const node = app.graph.getNodeById(id); + if (!node) { + return; + } + app.canvas.centerOnNode(node); + }; +} + +const crystoolsProgressBar = new CrystoolsProgressBar(); +app.registerExtension({ + name: crystoolsProgressBar.idExtensionName, + setup: crystoolsProgressBar.setup.bind(crystoolsProgressBar), +})