Compare commits
26 Commits
eager-exec
...
feat/queue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fba5f8914 | ||
|
|
72124a9fb0 | ||
|
|
c06a7279e2 | ||
|
|
ffc17c054b | ||
|
|
ddb00d02d5 | ||
|
|
4815d6b14c | ||
|
|
a9653ba9c7 | ||
|
|
30bafcd019 | ||
|
|
b789791fd9 | ||
|
|
723f53751e | ||
|
|
2539a7d2ce | ||
|
|
c9556d7aff | ||
|
|
58b051a473 | ||
|
|
0b33470744 | ||
|
|
fb3ce74d2f | ||
|
|
86d3f0ebd5 | ||
|
|
09c888e338 | ||
|
|
6d41e8b6e4 | ||
|
|
274f77869b | ||
|
|
f5c9f69678 | ||
|
|
c1e237255a | ||
|
|
a91b9f288f | ||
|
|
4adcf09cca | ||
|
|
1dbb3fc1b9 | ||
|
|
d6c5b33fce | ||
|
|
f5608435b4 |
@@ -1,5 +1,5 @@
|
||||
# Description: When upstream electron API is updated, click dispatch to update the TypeScript type definitions in this repo
|
||||
name: 'Api: Update Electron API Types'
|
||||
description: 'When upstream electron API is updated, click dispatch to update the TypeScript type definitions in this repo'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Description: When upstream ComfyUI-Manager API is updated, click dispatch to update the TypeScript type definitions in this repo
|
||||
name: 'Api: Update Manager API Types'
|
||||
description: 'When upstream ComfyUI-Manager API is updated, click dispatch to update the TypeScript type definitions in this repo'
|
||||
|
||||
on:
|
||||
# Manual trigger
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Description: When upstream comfy-api is updated, click dispatch to update the TypeScript type definitions in this repo
|
||||
name: 'Api: Update Registry API Types'
|
||||
description: 'When upstream comfy-api is updated, click dispatch to update the TypeScript type definitions in this repo'
|
||||
|
||||
on:
|
||||
# Manual trigger
|
||||
|
||||
2
.github/workflows/ci-json-validation.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Validates JSON syntax in all tracked .json files (excluding tsconfig*.json) using jq
|
||||
name: "CI: JSON Validation"
|
||||
description: "Validates JSON syntax in all tracked .json files (excluding tsconfig*.json) using jq"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
2
.github/workflows/ci-lint-format.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Linting and code formatting validation for pull requests
|
||||
name: "CI: Lint Format"
|
||||
description: "Linting and code formatting validation for pull requests"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
2
.github/workflows/ci-python-validation.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Validates Python code in tools/devtools directory
|
||||
name: "CI: Python Validation"
|
||||
description: "Validates Python code in tools/devtools directory"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
2
.github/workflows/ci-tests-e2e-forks.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Deploys test results from forked PRs (forks can't access deployment secrets)
|
||||
name: "CI: Tests E2E (Deploy for Forks)"
|
||||
description: "Deploys test results from forked PRs (forks can't access deployment secrets)"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
|
||||
2
.github/workflows/ci-tests-e2e.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: End-to-end testing with Playwright across multiple browsers, deploys test reports to Cloudflare Pages
|
||||
name: "CI: Tests E2E"
|
||||
description: "End-to-end testing with Playwright across multiple browsers, deploys test reports to Cloudflare Pages"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Description: Deploys Storybook previews from forked PRs (forks can't access deployment secrets)
|
||||
name: "CI: Tests Storybook (Deploy for Forks)"
|
||||
description: "Deploys Storybook previews from forked PRs (forks can't access deployment secrets)"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
|
||||
3
.github/workflows/ci-tests-storybook.yaml
vendored
@@ -1,10 +1,9 @@
|
||||
# Description: Builds Storybook and runs visual regression testing via Chromatic, deploys previews to Cloudflare Pages
|
||||
name: "CI: Tests Storybook"
|
||||
description: "Builds Storybook and runs visual regression testing via Chromatic, deploys previews to Cloudflare Pages"
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
# Post starting comment for non-forked PRs
|
||||
|
||||
2
.github/workflows/ci-tests-unit.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Unit and component testing with Vitest
|
||||
name: "CI: Tests Unit"
|
||||
description: "Unit and component testing with Vitest"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
2
.github/workflows/ci-yaml-validation.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Validates YAML syntax and style using yamllint with relaxed rules
|
||||
name: "CI: YAML Validation"
|
||||
description: "Validates YAML syntax and style using yamllint with relaxed rules"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
2
.github/workflows/i18n-update-core.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Generates and updates translations for core ComfyUI components using OpenAI
|
||||
name: "i18n: Update Core"
|
||||
description: "Generates and updates translations for core ComfyUI components using OpenAI"
|
||||
|
||||
on:
|
||||
# Manual dispatch for urgent translation updates
|
||||
|
||||
2
.github/workflows/pr-claude-review.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: AI-powered code review triggered by adding the 'claude-review' label to a PR
|
||||
name: "PR: Claude Review"
|
||||
description: "AI-powered code review triggered by adding the 'claude-review' label to a PR"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
4
.github/workflows/release-branch-create.yaml
vendored
@@ -148,10 +148,10 @@ jobs:
|
||||
done
|
||||
|
||||
{
|
||||
echo "results<<'EOF'"
|
||||
echo "results<<EOF"
|
||||
cat "$RESULTS_FILE"
|
||||
echo "EOF"
|
||||
} >> $GITHUB_OUTPUT
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Ensure release labels
|
||||
if: steps.check_version.outputs.is_minor_bump == 'true'
|
||||
|
||||
2
.github/workflows/release-version-bump.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Manual workflow to increment package version with semantic versioning support
|
||||
name: "Release: Version Bump"
|
||||
description: "Manual workflow to increment package version with semantic versioning support"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
2
.github/workflows/weekly-docs-check.yaml
vendored
@@ -1,5 +1,5 @@
|
||||
# Description: Automated weekly documentation accuracy check and update via Claude
|
||||
name: "Weekly Documentation Check"
|
||||
description: "Automated weekly documentation accuracy check and update via Claude"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
<h1 v-if="title" class="font-inter font-bold text-3xl text-neutral-300">
|
||||
{{ title }}
|
||||
</h1>
|
||||
<p v-if="statusText" class="text-lg text-neutral-400">
|
||||
<p
|
||||
v-if="statusText"
|
||||
class="text-lg text-neutral-400"
|
||||
data-testid="startup-status-text"
|
||||
>
|
||||
{{ statusText }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
@@ -9,9 +9,9 @@ test.beforeEach(async ({ comfyPage }) => {
|
||||
test.describe('Vue Nodes - LOD', () => {
|
||||
test.beforeEach(async ({ comfyPage }) => {
|
||||
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
||||
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
|
||||
await comfyPage.setup()
|
||||
await comfyPage.loadWorkflow('default')
|
||||
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
|
||||
})
|
||||
|
||||
test('should toggle LOD based on zoom threshold', async ({ comfyPage }) => {
|
||||
|
||||
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 80 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@comfyorg/comfyui-frontend",
|
||||
"private": true,
|
||||
"version": "1.33.5",
|
||||
"version": "1.33.8",
|
||||
"type": "module",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"homepage": "https://comfy.org",
|
||||
@@ -75,6 +75,7 @@
|
||||
"@vitest/coverage-v8": "catalog:",
|
||||
"@vitest/ui": "catalog:",
|
||||
"@vue/test-utils": "catalog:",
|
||||
"@webgpu/types": "catalog:",
|
||||
"cross-env": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"eslint-config-prettier": "catalog:",
|
||||
@@ -112,6 +113,7 @@
|
||||
"typescript": "catalog:",
|
||||
"typescript-eslint": "catalog:",
|
||||
"unplugin-icons": "catalog:",
|
||||
"unplugin-typegpu": "catalog:",
|
||||
"unplugin-vue-components": "catalog:",
|
||||
"uuid": "^11.1.0",
|
||||
"vite": "catalog:",
|
||||
@@ -176,6 +178,7 @@
|
||||
"semver": "^7.7.2",
|
||||
"three": "^0.170.0",
|
||||
"tiptap-markdown": "^0.8.10",
|
||||
"typegpu": "catalog:",
|
||||
"vue": "catalog:",
|
||||
"vue-i18n": "catalog:",
|
||||
"vue-router": "catalog:",
|
||||
|
||||
86
pnpm-lock.yaml
generated
@@ -126,6 +126,9 @@ catalogs:
|
||||
'@vueuse/integrations':
|
||||
specifier: ^13.9.0
|
||||
version: 13.9.0
|
||||
'@webgpu/types':
|
||||
specifier: ^0.1.66
|
||||
version: 0.1.66
|
||||
algoliasearch:
|
||||
specifier: ^5.21.0
|
||||
version: 5.21.0
|
||||
@@ -246,6 +249,9 @@ catalogs:
|
||||
tw-animate-css:
|
||||
specifier: ^1.3.8
|
||||
version: 1.3.8
|
||||
typegpu:
|
||||
specifier: ^0.8.2
|
||||
version: 0.8.2
|
||||
typescript:
|
||||
specifier: ^5.9.2
|
||||
version: 5.9.2
|
||||
@@ -255,6 +261,9 @@ catalogs:
|
||||
unplugin-icons:
|
||||
specifier: ^0.22.0
|
||||
version: 0.22.0
|
||||
unplugin-typegpu:
|
||||
specifier: 0.8.0
|
||||
version: 0.8.0
|
||||
unplugin-vue-components:
|
||||
specifier: ^0.28.0
|
||||
version: 0.28.0
|
||||
@@ -464,6 +473,9 @@ importers:
|
||||
tiptap-markdown:
|
||||
specifier: ^0.8.10
|
||||
version: 0.8.10(@tiptap/core@2.10.4(@tiptap/pm@2.10.4))
|
||||
typegpu:
|
||||
specifier: 'catalog:'
|
||||
version: 0.8.2
|
||||
vue:
|
||||
specifier: 'catalog:'
|
||||
version: 3.5.13(typescript@5.9.2)
|
||||
@@ -561,6 +573,9 @@ importers:
|
||||
'@vue/test-utils':
|
||||
specifier: 'catalog:'
|
||||
version: 2.4.6
|
||||
'@webgpu/types':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.66
|
||||
cross-env:
|
||||
specifier: 'catalog:'
|
||||
version: 10.1.0
|
||||
@@ -672,6 +687,9 @@ importers:
|
||||
unplugin-icons:
|
||||
specifier: 'catalog:'
|
||||
version: 0.22.0(@vue/compiler-sfc@3.5.13)
|
||||
unplugin-typegpu:
|
||||
specifier: 'catalog:'
|
||||
version: 0.8.0(typegpu@0.8.2)
|
||||
unplugin-vue-components:
|
||||
specifier: 'catalog:'
|
||||
version: 0.28.0(@babel/parser@7.28.4)(rollup@4.22.4)(vue@3.5.13(typescript@5.9.2))
|
||||
@@ -1431,6 +1449,10 @@ packages:
|
||||
resolution: {integrity: sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/standalone@7.28.5':
|
||||
resolution: {integrity: sha512-1DViPYJpRU50irpGMfLBQ9B4kyfQuL6X7SS7pwTeWeZX0mNkjzPi0XFqxCjSdddZXUQy4AhnQnnesA/ZHnvAdw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -3790,8 +3812,8 @@ packages:
|
||||
peerDependencies:
|
||||
vue: ^3.5.0
|
||||
|
||||
'@webgpu/types@0.1.51':
|
||||
resolution: {integrity: sha512-ktR3u64NPjwIViNCck+z9QeyN0iPkQCUOQ07ZCV1RzlkfP+olLTeEZ95O1QHS+v4w9vJeY9xj/uJuSphsHy5rQ==}
|
||||
'@webgpu/types@0.1.66':
|
||||
resolution: {integrity: sha512-YA2hLrwLpDsRueNDXIMqN9NTzD6bCDkuXbOSe0heS+f8YE8usA6Gbv1prj81pzVHrbaAma7zObnIC+I6/sXJgA==}
|
||||
|
||||
'@xstate/fsm@1.6.5':
|
||||
resolution: {integrity: sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==}
|
||||
@@ -6038,6 +6060,10 @@ packages:
|
||||
resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
|
||||
hasBin: true
|
||||
|
||||
magic-string-ast@1.0.3:
|
||||
resolution: {integrity: sha512-CvkkH1i81zl7mmb94DsRiFeG9V2fR2JeuK8yDgS8oiZSFa++wWLEgZ5ufEOyLHbvSbD1gTRKv9NdX69Rnvr9JA==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
|
||||
magic-string@0.30.19:
|
||||
resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==}
|
||||
|
||||
@@ -7411,6 +7437,14 @@ packages:
|
||||
tinybench@2.9.0:
|
||||
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
||||
|
||||
tinyest-for-wgsl@0.1.3:
|
||||
resolution: {integrity: sha512-Wm5ADG1UyDxykf42S1gLYP4U9e1QP/TdtJeovQi6y68zttpiFLKqQGioHmPs9Mjysh7YMSAr/Lpuk0cD2MVdGA==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
|
||||
tinyest@0.1.2:
|
||||
resolution: {integrity: sha512-aHRmouyowIq1P5jrTF+YK6pGX+WuvFtSCLbqk91yHnU3SWQRIcNIamZLM5XF6lLqB13AWz0PGPXRff2QGDsxIg==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
|
||||
tinyexec@0.3.2:
|
||||
resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
|
||||
|
||||
@@ -7537,6 +7571,13 @@ packages:
|
||||
resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
typed-binary@4.3.2:
|
||||
resolution: {integrity: sha512-HT3pIBM2njCZUmeczDaQUUErGiM6GXFCqMsHegE12HCoBtvHCkfR10JJni0TeGOTnLilTd6YFyj+YhflqQDrDQ==}
|
||||
|
||||
typegpu@0.8.2:
|
||||
resolution: {integrity: sha512-wkMJWhJE0pSkw2G/FesjqjbtHkREyOKu1Zmyj19xfmaX5+65YFwgfQNKSK8CxqN4kJkP7JFelLDJTSYY536TYg==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
|
||||
typescript-eslint@8.44.0:
|
||||
resolution: {integrity: sha512-ib7mCkYuIzYonCq9XWF5XNw+fkj2zg629PSa9KNIQ47RXFF763S5BIX4wqz1+FLPogTZoiw8KmCiRPRa8bL3qw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
@@ -7641,6 +7682,11 @@ packages:
|
||||
vue-template-es2015-compiler:
|
||||
optional: true
|
||||
|
||||
unplugin-typegpu@0.8.0:
|
||||
resolution: {integrity: sha512-VJHdXSXGOkAx0WhwFczhVUjAI6HyDkrQXk20HnwyuzIE3FdqE5l9sJTCYZzoVGo3z8i/IA5TMHCDzzP0Bc97Cw==}
|
||||
peerDependencies:
|
||||
typegpu: ^0.8.0
|
||||
|
||||
unplugin-vue-components@0.28.0:
|
||||
resolution: {integrity: sha512-jiTGtJ3JsRFBjgvyilfrX7yUoGKScFgbdNw+6p6kEXU+Spf/rhxzgvdfuMcvhCcLmflB/dY3pGQshYBVGOUx7Q==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -8969,6 +9015,8 @@ snapshots:
|
||||
|
||||
'@babel/runtime@7.28.4': {}
|
||||
|
||||
'@babel/standalone@7.28.5': {}
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.27.1
|
||||
@@ -11016,7 +11064,7 @@ snapshots:
|
||||
'@tweenjs/tween.js': 23.1.3
|
||||
'@types/stats.js': 0.17.3
|
||||
'@types/webxr': 0.5.20
|
||||
'@webgpu/types': 0.1.51
|
||||
'@webgpu/types': 0.1.66
|
||||
fflate: 0.8.2
|
||||
meshoptimizer: 0.18.1
|
||||
|
||||
@@ -11519,7 +11567,7 @@ snapshots:
|
||||
dependencies:
|
||||
vue: 3.5.13(typescript@5.9.2)
|
||||
|
||||
'@webgpu/types@0.1.51': {}
|
||||
'@webgpu/types@0.1.66': {}
|
||||
|
||||
'@xstate/fsm@1.6.5': {}
|
||||
|
||||
@@ -14000,6 +14048,10 @@ snapshots:
|
||||
|
||||
lz-string@1.5.0: {}
|
||||
|
||||
magic-string-ast@1.0.3:
|
||||
dependencies:
|
||||
magic-string: 0.30.19
|
||||
|
||||
magic-string@0.30.19:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
@@ -15864,6 +15916,12 @@ snapshots:
|
||||
|
||||
tinybench@2.9.0: {}
|
||||
|
||||
tinyest-for-wgsl@0.1.3:
|
||||
dependencies:
|
||||
tinyest: 0.1.2
|
||||
|
||||
tinyest@0.1.2: {}
|
||||
|
||||
tinyexec@0.3.2: {}
|
||||
|
||||
tinyexec@1.0.1: {}
|
||||
@@ -15995,6 +16053,13 @@ snapshots:
|
||||
reflect.getprototypeof: 1.0.10
|
||||
optional: true
|
||||
|
||||
typed-binary@4.3.2: {}
|
||||
|
||||
typegpu@0.8.2:
|
||||
dependencies:
|
||||
tinyest: 0.1.2
|
||||
typed-binary: 4.3.2
|
||||
|
||||
typescript-eslint@8.44.0(eslint@9.35.0(jiti@2.4.2))(typescript@5.9.2):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.44.0(@typescript-eslint/parser@8.44.0(eslint@9.35.0(jiti@2.4.2))(typescript@5.9.2))(eslint@9.35.0(jiti@2.4.2))(typescript@5.9.2)
|
||||
@@ -16090,6 +16155,19 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
unplugin-typegpu@0.8.0(typegpu@0.8.2):
|
||||
dependencies:
|
||||
'@babel/standalone': 7.28.5
|
||||
defu: 6.1.4
|
||||
estree-walker: 3.0.3
|
||||
magic-string-ast: 1.0.3
|
||||
pathe: 2.0.3
|
||||
picomatch: 4.0.3
|
||||
tinyest: 0.1.2
|
||||
tinyest-for-wgsl: 0.1.3
|
||||
typegpu: 0.8.2
|
||||
unplugin: 2.3.5
|
||||
|
||||
unplugin-vue-components@0.28.0(@babel/parser@7.28.4)(rollup@4.22.4)(vue@3.5.13(typescript@5.9.2)):
|
||||
dependencies:
|
||||
'@antfu/utils': 0.7.10
|
||||
|
||||
@@ -43,6 +43,7 @@ catalog:
|
||||
'@vue/test-utils': ^2.4.6
|
||||
'@vueuse/core': ^11.0.0
|
||||
'@vueuse/integrations': ^13.9.0
|
||||
'@webgpu/types': ^0.1.66
|
||||
algoliasearch: ^5.21.0
|
||||
axios: ^1.8.2
|
||||
cross-env: ^10.1.0
|
||||
@@ -83,9 +84,11 @@ catalog:
|
||||
tailwindcss-primeui: ^0.6.1
|
||||
tsx: ^4.15.6
|
||||
tw-animate-css: ^1.3.8
|
||||
typegpu: ^0.8.2
|
||||
typescript: ^5.9.2
|
||||
typescript-eslint: ^8.44.0
|
||||
unplugin-icons: ^0.22.0
|
||||
unplugin-typegpu: 0.8.0
|
||||
unplugin-vue-components: ^0.28.0
|
||||
vite: ^5.4.19
|
||||
vite-plugin-dts: ^4.5.4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<SubgraphBreadcrumb />
|
||||
</div>
|
||||
|
||||
<div class="mx-1 flex flex-col items-end gap-1">
|
||||
<div ref="queueAreaRef" class="mx-1 flex flex-col items-end gap-1">
|
||||
<div
|
||||
class="actionbar-container pointer-events-auto flex h-12 items-center rounded-lg border border-interface-stroke px-2 shadow-interface"
|
||||
>
|
||||
@@ -40,12 +40,16 @@
|
||||
<CurrentUserButton v-if="isLoggedIn" class="shrink-0" />
|
||||
<LoginButton v-else-if="isDesktop" />
|
||||
</div>
|
||||
<QueueProgressOverlay v-model:expanded="isQueueOverlayExpanded" />
|
||||
<QueueProgressOverlay
|
||||
v-model:expanded="isQueueOverlayExpanded"
|
||||
:external-hovered="isQueueAreaHovered"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useElementBounding, useMouse } from '@vueuse/core'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
@@ -68,6 +72,20 @@ const { isLoggedIn } = useCurrentUser()
|
||||
const isDesktop = isElectron()
|
||||
const { t } = useI18n()
|
||||
const isQueueOverlayExpanded = ref(false)
|
||||
|
||||
// Track hover over the rectangular bounding box of the queue area
|
||||
// Using mouse position + element bounds instead of mouseenter/mouseleave
|
||||
// because QueueProgressOverlay has pointer-events-none on its wrapper
|
||||
const queueAreaRef = ref<HTMLElement | null>(null)
|
||||
const { x: mouseX, y: mouseY } = useMouse()
|
||||
const { left, top, right, bottom } = useElementBounding(queueAreaRef)
|
||||
const isQueueAreaHovered = computed(
|
||||
() =>
|
||||
mouseX.value >= left.value &&
|
||||
mouseX.value <= right.value &&
|
||||
mouseY.value >= top.value &&
|
||||
mouseY.value <= bottom.value
|
||||
)
|
||||
const queueStore = useQueueStore()
|
||||
const queuedCount = computed(() => queueStore.pendingTasks.length)
|
||||
const queueHistoryTooltipConfig = computed(() =>
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
class="w-62.5"
|
||||
>
|
||||
<template #icon>
|
||||
<i class="icon-[lucide--arrow-up-down]" />
|
||||
<i class="icon-[lucide--arrow-up-down] text-muted-foreground" />
|
||||
</template>
|
||||
</SingleSelect>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
root: ({ props }: MultiSelectPassThroughMethodOptions) => ({
|
||||
class: cn(
|
||||
'h-10 relative inline-flex cursor-pointer select-none',
|
||||
'rounded-lg bg-base-background text-base-foreground',
|
||||
'rounded-lg bg-secondary-background text-base-foreground',
|
||||
'transition-all duration-200 ease-in-out',
|
||||
'border-[2.5px] border-solid',
|
||||
selectedCount > 0
|
||||
@@ -83,7 +83,7 @@
|
||||
role="combobox"
|
||||
:aria-expanded="false"
|
||||
aria-haspopup="listbox"
|
||||
tabindex="0"
|
||||
:tabindex="0"
|
||||
>
|
||||
<template
|
||||
v-if="showSearchBox || showSelectedCount || showClearButton"
|
||||
@@ -127,7 +127,7 @@
|
||||
|
||||
<!-- Trigger value (keep text scale identical) -->
|
||||
<template #value>
|
||||
<span class="text-sm text-muted-foreground">
|
||||
<span class="text-sm">
|
||||
{{ label }}
|
||||
</span>
|
||||
<span
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
<!-- Chevron size identical to current -->
|
||||
<template #dropdownicon>
|
||||
<i class="icon-[lucide--chevron-down] text-lg text-neutral-400" />
|
||||
<i class="icon-[lucide--chevron-down] text-muted-foreground" />
|
||||
</template>
|
||||
|
||||
<!-- Custom option row: square checkbox + label (unchanged layout/colors) -->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div :class="wrapperStyle" @click="focusInput">
|
||||
<i class="icon-[lucide--search] text-muted" />
|
||||
<i class="icon-[lucide--search] text-muted-foreground" />
|
||||
<InputText
|
||||
ref="input"
|
||||
v-model="internalSearchQuery"
|
||||
@@ -73,7 +73,7 @@ onMounted(() => autofocus && focusInput())
|
||||
|
||||
const wrapperStyle = computed(() => {
|
||||
const baseClasses =
|
||||
'relative flex w-full items-center gap-2 bg-base-background cursor-text'
|
||||
'relative flex w-full items-center gap-2 bg-secondary-background cursor-text'
|
||||
|
||||
if (showBorder) {
|
||||
return cn(
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
'h-10 relative inline-flex cursor-pointer select-none items-center',
|
||||
// trigger surface
|
||||
'rounded-lg',
|
||||
'bg-base-background text-base-foreground',
|
||||
'bg-secondary-background text-base-foreground',
|
||||
'border-[2.5px] border-solid border-transparent',
|
||||
'transition-all duration-200 ease-in-out',
|
||||
'focus-within:border-node-component-border',
|
||||
@@ -84,7 +84,7 @@
|
||||
>
|
||||
<!-- Trigger value -->
|
||||
<template #value="slotProps">
|
||||
<div class="flex items-center gap-2 text-sm text-neutral-500">
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<slot name="icon" />
|
||||
<span
|
||||
v-if="slotProps.value !== null && slotProps.value !== undefined"
|
||||
@@ -100,7 +100,7 @@
|
||||
|
||||
<!-- Trigger caret -->
|
||||
<template #dropdownicon>
|
||||
<i class="icon-[lucide--chevron-down] text-base text-neutral-500" />
|
||||
<i class="icon-[lucide--chevron-down] text-muted-foreground" />
|
||||
</template>
|
||||
|
||||
<!-- Option row -->
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
import {
|
||||
getEffectiveBrushSize,
|
||||
getEffectiveHardness
|
||||
} from '@/composables/maskeditor/brushUtils'
|
||||
import { BrushShape } from '@/extensions/core/maskeditor/types'
|
||||
import { useMaskEditorStore } from '@/stores/maskEditorStore'
|
||||
|
||||
@@ -36,11 +40,14 @@ const { containerRef } = defineProps<{
|
||||
const store = useMaskEditorStore()
|
||||
|
||||
const brushOpacity = computed(() => {
|
||||
return store.brushVisible ? '1' : '0'
|
||||
return store.brushVisible ? 1 : 0
|
||||
})
|
||||
|
||||
const brushRadius = computed(() => {
|
||||
return store.brushSettings.size * store.zoomRatio
|
||||
const size = store.brushSettings.size
|
||||
const hardness = store.brushSettings.hardness
|
||||
const effectiveSize = getEffectiveBrushSize(size, hardness)
|
||||
return effectiveSize * store.zoomRatio
|
||||
})
|
||||
|
||||
const brushSize = computed(() => {
|
||||
@@ -78,19 +85,26 @@ const gradientVisible = computed(() => {
|
||||
})
|
||||
|
||||
const gradientBackground = computed(() => {
|
||||
const size = store.brushSettings.size
|
||||
const hardness = store.brushSettings.hardness
|
||||
const effectiveSize = getEffectiveBrushSize(size, hardness)
|
||||
const effectiveHardness = getEffectiveHardness(size, hardness, effectiveSize)
|
||||
|
||||
if (hardness === 1) {
|
||||
if (effectiveHardness === 1) {
|
||||
return 'rgba(255, 0, 0, 0.5)'
|
||||
}
|
||||
|
||||
const midStop = hardness * 100
|
||||
const midStop = effectiveHardness * 100
|
||||
const outerStop = 100
|
||||
// Add an intermediate stop to approximate the squared falloff
|
||||
// At 50% of the fade region, squared falloff is 0.25 (relative to max)
|
||||
const fadeMidStop = midStop + (outerStop - midStop) * 0.5
|
||||
|
||||
return `radial-gradient(
|
||||
circle,
|
||||
rgba(255, 0, 0, 0.5) 0%,
|
||||
rgba(255, 0, 0, 0.25) ${midStop}%,
|
||||
rgba(255, 0, 0, 0.5) ${midStop}%,
|
||||
rgba(255, 0, 0, 0.125) ${fadeMidStop}%,
|
||||
rgba(255, 0, 0, 0) ${outerStop}%
|
||||
)`
|
||||
})
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<SliderControl
|
||||
:label="t('maskEditor.thickness')"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:max="500"
|
||||
:step="1"
|
||||
:model-value="store.brushSettings.size"
|
||||
@update:model-value="onThicknessChange"
|
||||
@@ -80,12 +80,12 @@
|
||||
/>
|
||||
|
||||
<SliderControl
|
||||
:label="t('maskEditor.smoothingPrecision')"
|
||||
label="Stepsize"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:step="1"
|
||||
:model-value="store.brushSettings.smoothingPrecision"
|
||||
@update:model-value="onSmoothingPrecisionChange"
|
||||
:model-value="store.brushSettings.stepSize"
|
||||
@update:model-value="onStepSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -119,8 +119,8 @@ const onHardnessChange = (value: number) => {
|
||||
store.setBrushHardness(value)
|
||||
}
|
||||
|
||||
const onSmoothingPrecisionChange = (value: number) => {
|
||||
store.setBrushSmoothingPrecision(value)
|
||||
const onStepSizeChange = (value: number) => {
|
||||
store.setBrushStepSize(value)
|
||||
}
|
||||
|
||||
const resetToDefault = () => {
|
||||
|
||||
@@ -12,19 +12,28 @@
|
||||
>
|
||||
<canvas
|
||||
ref="imgCanvasRef"
|
||||
class="absolute top-0 left-0 w-full h-full"
|
||||
class="absolute top-0 left-0 w-full h-full z-0"
|
||||
@contextmenu.prevent
|
||||
/>
|
||||
<canvas
|
||||
ref="rgbCanvasRef"
|
||||
class="absolute top-0 left-0 w-full h-full"
|
||||
class="absolute top-0 left-0 w-full h-full z-10"
|
||||
@contextmenu.prevent
|
||||
/>
|
||||
<canvas
|
||||
ref="maskCanvasRef"
|
||||
class="absolute top-0 left-0 w-full h-full"
|
||||
class="absolute top-0 left-0 w-full h-full z-30"
|
||||
@contextmenu.prevent
|
||||
/>
|
||||
<!-- GPU Preview Canvas -->
|
||||
<canvas
|
||||
ref="gpuCanvasRef"
|
||||
class="absolute top-0 left-0 w-full h-full pointer-events-none"
|
||||
:class="{
|
||||
'z-20': store.activeLayer === 'rgb',
|
||||
'z-40': store.activeLayer === 'mask'
|
||||
}"
|
||||
/>
|
||||
<div ref="canvasBackgroundRef" class="bg-white w-full h-full" />
|
||||
</div>
|
||||
|
||||
@@ -87,6 +96,7 @@ const canvasContainerRef = ref<HTMLDivElement>()
|
||||
const imgCanvasRef = ref<HTMLCanvasElement>()
|
||||
const maskCanvasRef = ref<HTMLCanvasElement>()
|
||||
const rgbCanvasRef = ref<HTMLCanvasElement>()
|
||||
const gpuCanvasRef = ref<HTMLCanvasElement>()
|
||||
const canvasBackgroundRef = ref<HTMLDivElement>()
|
||||
|
||||
const toolPanelRef = ref<InstanceType<typeof ToolPanel>>()
|
||||
@@ -97,7 +107,7 @@ const initialized = ref(false)
|
||||
const keyboard = useKeyboard()
|
||||
const panZoom = usePanAndZoom()
|
||||
|
||||
let toolManager: ReturnType<typeof useToolManager> | null = null
|
||||
const toolManager = useToolManager(keyboard, panZoom)
|
||||
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
@@ -135,8 +145,6 @@ const initUI = async () => {
|
||||
try {
|
||||
await loader.loadFromNode(node)
|
||||
|
||||
toolManager = useToolManager(keyboard, panZoom)
|
||||
|
||||
const imageLoader = useImageLoader()
|
||||
const image = await imageLoader.loadImages()
|
||||
|
||||
@@ -149,6 +157,18 @@ const initUI = async () => {
|
||||
|
||||
store.canvasHistory.saveInitialState()
|
||||
|
||||
// Initialize GPU resources
|
||||
if (toolManager.brushDrawing) {
|
||||
await toolManager.brushDrawing.initGPUResources()
|
||||
if (gpuCanvasRef.value && toolManager.brushDrawing.initPreviewCanvas) {
|
||||
// Match preview canvas resolution to mask canvas
|
||||
gpuCanvasRef.value.width = maskCanvasRef.value.width
|
||||
gpuCanvasRef.value.height = maskCanvasRef.value.height
|
||||
|
||||
toolManager.brushDrawing.initPreviewCanvas(gpuCanvasRef.value)
|
||||
}
|
||||
}
|
||||
|
||||
initialized.value = true
|
||||
} catch (error) {
|
||||
console.error('[MaskEditorContent] Initialization failed:', error)
|
||||
@@ -172,7 +192,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
toolManager?.brushDrawing.saveBrushSettings()
|
||||
toolManager.brushDrawing.saveBrushSettings()
|
||||
|
||||
keyboard?.removeListeners()
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ const onInvert = () => {
|
||||
|
||||
const onClear = () => {
|
||||
canvasTools.clearMask()
|
||||
store.triggerClear()
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
v-tooltip.top="cancelJobTooltip"
|
||||
type="secondary"
|
||||
size="sm"
|
||||
class="size-6 bg-secondary-background hover:bg-destructive-background"
|
||||
class="size-6 bg-destructive-background hover:bg-destructive-background-hover"
|
||||
:aria-label="t('sideToolbar.queueProgressOverlay.interruptAll')"
|
||||
@click="$emit('interruptAll')"
|
||||
>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<div
|
||||
class="pointer-events-auto flex w-[350px] min-w-[310px] max-h-[60vh] flex-col overflow-hidden rounded-lg border font-inter transition-colors duration-200 ease-in-out"
|
||||
:class="containerClass"
|
||||
@mouseenter="isHovered = true"
|
||||
@mouseleave="isHovered = false"
|
||||
@mouseenter="isHoveredInternal = true"
|
||||
@mouseleave="isHoveredInternal = false"
|
||||
>
|
||||
<!-- Expanded state -->
|
||||
<QueueOverlayExpanded
|
||||
@@ -87,6 +87,8 @@ type OverlayState = 'hidden' | 'empty' | 'active' | 'expanded'
|
||||
|
||||
const props = defineProps<{
|
||||
expanded?: boolean
|
||||
/** External hover state from parent container */
|
||||
externalHovered?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -109,7 +111,10 @@ const {
|
||||
totalProgressStyle,
|
||||
currentNodeProgressStyle
|
||||
} = useQueueProgress()
|
||||
const isHovered = ref(false)
|
||||
const isHoveredInternal = ref(false)
|
||||
const isHovered = computed(
|
||||
() => isHoveredInternal.value || props.externalHovered
|
||||
)
|
||||
const internalExpanded = ref(false)
|
||||
const isExpanded = computed({
|
||||
get: () =>
|
||||
|
||||
@@ -82,7 +82,16 @@
|
||||
:src="iconImageUrl"
|
||||
class="h-full w-full object-cover"
|
||||
/>
|
||||
<i v-else :class="[iconClass, 'size-4']" />
|
||||
<i
|
||||
v-else
|
||||
:class="
|
||||
cn(
|
||||
iconClass,
|
||||
'size-4',
|
||||
props.state === 'pending' && 'animate-spin'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,6 +102,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
TODO: Refactor action buttons to use a declarative config system.
|
||||
|
||||
Instead of hardcoding button visibility logic in the template, define an array of
|
||||
action button configs with properties like:
|
||||
- icon, label, action, tooltip
|
||||
- visibleStates: JobState[] (which job states show this button)
|
||||
- alwaysVisible: boolean (show without hover)
|
||||
- destructive: boolean (use destructive styling)
|
||||
|
||||
Then render buttons in two groups:
|
||||
1. Always-visible buttons (outside Transition)
|
||||
2. Hover-only buttons (inside Transition)
|
||||
|
||||
This would eliminate the current duplication where the cancel button exists
|
||||
both outside (for running) and inside (for pending) the Transition.
|
||||
-->
|
||||
<div class="relative z-[1] flex items-center gap-2 text-text-secondary">
|
||||
<Transition
|
||||
mode="out-in"
|
||||
@@ -113,18 +139,22 @@
|
||||
v-tooltip.top="deleteTooltipConfig"
|
||||
type="transparent"
|
||||
size="sm"
|
||||
class="h-6 transform gap-1 rounded bg-modal-card-button-surface px-1 py-0 text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background hover:opacity-95"
|
||||
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
|
||||
:aria-label="t('g.delete')"
|
||||
@click.stop="emit('delete')"
|
||||
>
|
||||
<i class="icon-[lucide--trash-2] size-4" />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
v-else-if="props.state !== 'completed' && computedShowClear"
|
||||
v-else-if="
|
||||
props.state !== 'completed' &&
|
||||
props.state !== 'running' &&
|
||||
computedShowClear
|
||||
"
|
||||
v-tooltip.top="cancelTooltipConfig"
|
||||
type="transparent"
|
||||
size="sm"
|
||||
class="h-6 transform gap-1 rounded bg-modal-card-button-surface px-1 py-0 text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background hover:opacity-95"
|
||||
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
|
||||
:aria-label="t('g.cancel')"
|
||||
@click.stop="emit('cancel')"
|
||||
>
|
||||
@@ -143,17 +173,33 @@
|
||||
v-tooltip.top="moreTooltipConfig"
|
||||
type="transparent"
|
||||
size="sm"
|
||||
class="h-6 transform gap-1 rounded bg-modal-card-button-surface px-1 py-0 text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:opacity-95"
|
||||
class="size-6 transform gap-1 rounded bg-modal-card-button-surface text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:opacity-95"
|
||||
:aria-label="t('g.more')"
|
||||
@click.stop="emit('menu', $event)"
|
||||
>
|
||||
<i class="icon-[lucide--more-horizontal] size-4" />
|
||||
</IconButton>
|
||||
</div>
|
||||
<div v-else key="secondary" class="pr-2">
|
||||
<div
|
||||
v-else-if="props.state !== 'running'"
|
||||
key="secondary"
|
||||
class="pr-2"
|
||||
>
|
||||
<slot name="secondary">{{ props.rightText }}</slot>
|
||||
</div>
|
||||
</Transition>
|
||||
<!-- Running job cancel button - always visible -->
|
||||
<IconButton
|
||||
v-if="props.state === 'running' && computedShowClear"
|
||||
v-tooltip.top="cancelTooltipConfig"
|
||||
type="transparent"
|
||||
size="sm"
|
||||
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
|
||||
:aria-label="t('g.cancel')"
|
||||
@click.stop="emit('cancel')"
|
||||
>
|
||||
<i class="icon-[lucide--x] size-4" />
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -170,6 +216,7 @@ import QueueAssetPreview from '@/components/queue/job/QueueAssetPreview.vue'
|
||||
import { buildTooltipConfig } from '@/composables/useTooltipConfig'
|
||||
import type { JobState } from '@/types/queue'
|
||||
import { iconForJobState } from '@/utils/queueDisplay'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
|
||||
@@ -214,7 +214,7 @@ const shouldShowDeleteButton = computed(() => {
|
||||
|
||||
const getOutputCount = (item: AssetItem): number => {
|
||||
const count = item.user_metadata?.outputCount
|
||||
return typeof count === 'number' && count > 0 ? count : 0
|
||||
return typeof count === 'number' && count > 0 ? count : 1
|
||||
}
|
||||
|
||||
const shouldShowOutputCount = (item: AssetItem): boolean => {
|
||||
|
||||
84
src/composables/maskeditor/ShiftClick.test.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { resampleSegment } from './splineUtils'
|
||||
import type { Point } from '@/extensions/core/maskeditor/types'
|
||||
|
||||
describe('Shift+Click Drawing Logic', () => {
|
||||
it('should generate equidistant points across connected segments', () => {
|
||||
const spacing = 4
|
||||
let remainder = spacing // Simulate start point already painted
|
||||
const outputPoints: Point[] = []
|
||||
|
||||
// Define points: A -> B -> C
|
||||
// A(0,0) -> B(10,0) -> C(20,0)
|
||||
// Total length 20. Spacing 4.
|
||||
// Expected points at x = 4, 8, 12, 16, 20
|
||||
const pA = { x: 0, y: 0 }
|
||||
const pB = { x: 10, y: 0 }
|
||||
const pC = { x: 20, y: 0 }
|
||||
|
||||
// Segment 1: A -> B
|
||||
const result1 = resampleSegment([pA, pB], spacing, remainder)
|
||||
outputPoints.push(...result1.points)
|
||||
remainder = result1.remainder
|
||||
|
||||
// Verify intermediate state
|
||||
// Length 10. Spacing 4. Start offset 4.
|
||||
// Points at 4, 8. Next at 12.
|
||||
// Remainder = 12 - 10 = 2.
|
||||
expect(result1.points.length).toBe(2)
|
||||
expect(result1.points[0].x).toBeCloseTo(4)
|
||||
expect(result1.points[1].x).toBeCloseTo(8)
|
||||
expect(remainder).toBeCloseTo(2)
|
||||
|
||||
// Segment 2: B -> C
|
||||
const result2 = resampleSegment([pB, pC], spacing, remainder)
|
||||
outputPoints.push(...result2.points)
|
||||
remainder = result2.remainder
|
||||
|
||||
// Verify final state
|
||||
// Start offset 2. Points at 2, 6, 10 (relative to B).
|
||||
// Absolute x: 12, 16, 20.
|
||||
expect(result2.points.length).toBe(3)
|
||||
expect(result2.points[0].x).toBeCloseTo(12)
|
||||
expect(result2.points[1].x).toBeCloseTo(16)
|
||||
expect(result2.points[2].x).toBeCloseTo(20)
|
||||
|
||||
// Verify all distances
|
||||
// Note: The first point is at distance `spacing` from start (0,0)
|
||||
// Subsequent points are `spacing` apart.
|
||||
let prevX = 0
|
||||
for (const p of outputPoints) {
|
||||
const dist = p.x - prevX
|
||||
expect(dist).toBeCloseTo(spacing)
|
||||
prevX = p.x
|
||||
}
|
||||
})
|
||||
|
||||
it('should handle segments shorter than spacing', () => {
|
||||
const spacing = 10
|
||||
let remainder = spacing // Simulate start point already painted
|
||||
|
||||
// A(0,0) -> B(5,0) -> C(15,0)
|
||||
const pA = { x: 0, y: 0 }
|
||||
const pB = { x: 5, y: 0 }
|
||||
const pC = { x: 15, y: 0 }
|
||||
|
||||
// Segment 1: A -> B (Length 5)
|
||||
// Spacing 10. No points should be generated.
|
||||
// Remainder should be 5 (next point needs 5 more units).
|
||||
const result1 = resampleSegment([pA, pB], spacing, remainder)
|
||||
expect(result1.points.length).toBe(0)
|
||||
expect(result1.remainder).toBeCloseTo(5)
|
||||
remainder = result1.remainder
|
||||
|
||||
// Segment 2: B -> C (Length 10)
|
||||
// Start offset 5. First point at 5 (relative to B).
|
||||
// Absolute x = 10.
|
||||
// Next point at 15 (relative to B). Segment ends at 10.
|
||||
// Remainder = 15 - 10 = 5.
|
||||
const result2 = resampleSegment([pB, pC], spacing, remainder)
|
||||
expect(result2.points.length).toBe(1)
|
||||
expect(result2.points[0].x).toBeCloseTo(10)
|
||||
expect(result2.remainder).toBeCloseTo(5)
|
||||
})
|
||||
})
|
||||
108
src/composables/maskeditor/StrokeProcessor.test.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { StrokeProcessor } from './StrokeProcessor'
|
||||
import type { Point } from '@/extensions/core/maskeditor/types'
|
||||
|
||||
describe('StrokeProcessor', () => {
|
||||
it('should generate equidistant points from irregular input', () => {
|
||||
const spacing = 10
|
||||
const processor = new StrokeProcessor(spacing)
|
||||
const outputPoints: Point[] = []
|
||||
|
||||
// Simulate a horizontal line drawn with irregular speed
|
||||
// Points: (0,0) -> (5,0) -> (25,0) -> (30,0) -> (100,0)
|
||||
const inputPoints: Point[] = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 5, y: 0 }, // dist 5
|
||||
{ x: 25, y: 0 }, // dist 20
|
||||
{ x: 30, y: 0 }, // dist 5
|
||||
{ x: 100, y: 0 } // dist 70
|
||||
]
|
||||
|
||||
for (const p of inputPoints) {
|
||||
outputPoints.push(...processor.addPoint(p))
|
||||
}
|
||||
outputPoints.push(...processor.endStroke())
|
||||
|
||||
// Verify we have points
|
||||
expect(outputPoints.length).toBeGreaterThan(0)
|
||||
|
||||
// Verify spacing
|
||||
// Note: The first few points might be affected by the start condition,
|
||||
// but the middle section should be perfectly spaced.
|
||||
// Also, Catmull-Rom splines don't necessarily pass through control points in a straight line
|
||||
// if the points are collinear, they should be straight.
|
||||
|
||||
// Let's check distances between consecutive points
|
||||
const distances: number[] = []
|
||||
for (let i = 1; i < outputPoints.length; i++) {
|
||||
const dx = outputPoints[i].x - outputPoints[i - 1].x
|
||||
const dy = outputPoints[i].y - outputPoints[i - 1].y
|
||||
distances.push(Math.hypot(dx, dy))
|
||||
}
|
||||
|
||||
// Check that distances are close to spacing
|
||||
// We allow a small epsilon because of floating point and spline approximation
|
||||
// Filter out the very last segment which might be shorter (remainder)
|
||||
// But wait, our logic doesn't output the last point if it's not a full spacing step?
|
||||
// resampleSegment outputs points at [start + spacing, start + 2*spacing, ...]
|
||||
// It does NOT output the end point of the segment.
|
||||
// So all distances between output points should be exactly `spacing`.
|
||||
// EXCEPT possibly if the spline curvature makes the straight-line distance slightly different
|
||||
// from the arc length. But for a straight line input, it should be exact.
|
||||
|
||||
// However, catmull-rom with collinear points IS a straight line.
|
||||
|
||||
// Let's log the distances for debugging if test fails
|
||||
// console.log('Distances:', distances)
|
||||
|
||||
// All distances should be approximately equal to spacing
|
||||
// We might have a gap between segments if the logic isn't perfect,
|
||||
// but within a segment it's guaranteed by resampleSegment.
|
||||
// The critical part is the transition between segments.
|
||||
|
||||
for (let i = 0; i < distances.length; i++) {
|
||||
const d = distances[i]
|
||||
if (Math.abs(d - spacing) > 0.5) {
|
||||
console.log(
|
||||
`Distance mismatch at index ${i}: ${d} (expected ${spacing})`
|
||||
)
|
||||
console.log(`Point ${i}:`, outputPoints[i])
|
||||
console.log(`Point ${i + 1}:`, outputPoints[i + 1])
|
||||
}
|
||||
expect(d).toBeCloseTo(spacing, 1)
|
||||
}
|
||||
})
|
||||
|
||||
it('should handle a simple 3-point stroke', () => {
|
||||
const spacing = 5
|
||||
const processor = new StrokeProcessor(spacing)
|
||||
const points: Point[] = []
|
||||
|
||||
points.push(...processor.addPoint({ x: 0, y: 0 }))
|
||||
points.push(...processor.addPoint({ x: 10, y: 0 }))
|
||||
points.push(...processor.addPoint({ x: 20, y: 0 }))
|
||||
points.push(...processor.endStroke())
|
||||
|
||||
expect(points.length).toBeGreaterThan(0)
|
||||
|
||||
// Check distances
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
const dx = points[i].x - points[i - 1].x
|
||||
const dy = points[i].y - points[i - 1].y
|
||||
const d = Math.hypot(dx, dy)
|
||||
expect(d).toBeCloseTo(spacing, 1)
|
||||
}
|
||||
})
|
||||
|
||||
it('should handle a single point click', () => {
|
||||
const spacing = 5
|
||||
const processor = new StrokeProcessor(spacing)
|
||||
const points: Point[] = []
|
||||
|
||||
points.push(...processor.addPoint({ x: 100, y: 100 }))
|
||||
points.push(...processor.endStroke())
|
||||
|
||||
expect(points.length).toBe(1)
|
||||
expect(points[0]).toEqual({ x: 100, y: 100 })
|
||||
})
|
||||
})
|
||||
115
src/composables/maskeditor/StrokeProcessor.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import type { Point } from '@/extensions/core/maskeditor/types'
|
||||
import { catmullRomSpline, resampleSegment } from './splineUtils'
|
||||
|
||||
export class StrokeProcessor {
|
||||
private controlPoints: Point[] = []
|
||||
private remainder: number = 0
|
||||
private spacing: number
|
||||
private isFirstPoint: boolean = true
|
||||
private hasProcessedSegment: boolean = false
|
||||
|
||||
constructor(spacing: number) {
|
||||
this.spacing = spacing
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a point to the stroke and returns any new equidistant points generated.
|
||||
* Maintain a sliding window of 4 control points for spline generation
|
||||
*/
|
||||
public addPoint(point: Point): Point[] {
|
||||
// Initialize buffer with the first point
|
||||
if (this.isFirstPoint) {
|
||||
this.controlPoints.push(point) // p0: phantom start point
|
||||
this.controlPoints.push(point) // p1: actual start point
|
||||
this.isFirstPoint = false
|
||||
return [] // Wait for more points to form a segment
|
||||
}
|
||||
|
||||
this.controlPoints.push(point)
|
||||
|
||||
// Require 4 points for a spline segment
|
||||
if (this.controlPoints.length < 4) {
|
||||
return []
|
||||
}
|
||||
|
||||
// Generate segment p1->p2
|
||||
const p0 = this.controlPoints[0]
|
||||
const p1 = this.controlPoints[1]
|
||||
const p2 = this.controlPoints[2]
|
||||
const p3 = this.controlPoints[3]
|
||||
|
||||
const newPoints = this.processSegment(p0, p1, p2, p3)
|
||||
|
||||
// Slide window
|
||||
this.controlPoints.shift()
|
||||
|
||||
return newPoints
|
||||
}
|
||||
|
||||
/**
|
||||
* End stroke and flush remaining segments
|
||||
*/
|
||||
public endStroke(): Point[] {
|
||||
if (this.controlPoints.length < 2) {
|
||||
// Insufficient points for a segment
|
||||
return []
|
||||
}
|
||||
|
||||
// Process remaining segments by duplicating the last point
|
||||
|
||||
const newPoints: Point[] = []
|
||||
|
||||
// Flush the buffer by processing the final segment
|
||||
|
||||
while (this.controlPoints.length >= 3) {
|
||||
const p0 = this.controlPoints[0]
|
||||
const p1 = this.controlPoints[1]
|
||||
const p2 = this.controlPoints[2]
|
||||
const p3 = p2 // Duplicate last point as phantom end
|
||||
|
||||
const points = this.processSegment(p0, p1, p2, p3)
|
||||
newPoints.push(...points)
|
||||
|
||||
this.controlPoints.shift()
|
||||
}
|
||||
|
||||
// Handle single point click
|
||||
if (!this.hasProcessedSegment && this.controlPoints.length >= 2) {
|
||||
// Process zero-length segment for single point
|
||||
const p = this.controlPoints[1]
|
||||
const points = this.processSegment(p, p, p, p)
|
||||
newPoints.push(...points)
|
||||
}
|
||||
|
||||
return newPoints
|
||||
}
|
||||
|
||||
private processSegment(p0: Point, p1: Point, p2: Point, p3: Point): Point[] {
|
||||
this.hasProcessedSegment = true
|
||||
// Generate dense points for the segment
|
||||
const densePoints: Point[] = []
|
||||
|
||||
// Adaptive sampling based on segment length
|
||||
const dist = Math.hypot(p2.x - p1.x, p2.y - p1.y)
|
||||
// Use 1 sample per pixel, but at least 5 samples to ensure smoothness for short segments
|
||||
// and cap at a reasonable maximum if needed (though not strictly necessary with density)
|
||||
const samples = Math.max(5, Math.ceil(dist))
|
||||
|
||||
for (let i = 0; i < samples; i++) {
|
||||
const t = i / samples
|
||||
densePoints.push(catmullRomSpline(p0, p1, p2, p3, t))
|
||||
}
|
||||
// Add segment end point
|
||||
densePoints.push(p2)
|
||||
|
||||
// Resample points with carried-over remainder
|
||||
const { points, remainder } = resampleSegment(
|
||||
densePoints,
|
||||
this.spacing,
|
||||
this.remainder
|
||||
)
|
||||
|
||||
this.remainder = remainder
|
||||
return points
|
||||
}
|
||||
}
|
||||
47
src/composables/maskeditor/brushUtils.test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { getEffectiveBrushSize, getEffectiveHardness } from './brushUtils'
|
||||
|
||||
describe('brushUtils', () => {
|
||||
describe('getEffectiveBrushSize', () => {
|
||||
it('should return original size when hardness is 1.0', () => {
|
||||
const size = 100
|
||||
const hardness = 1.0
|
||||
expect(getEffectiveBrushSize(size, hardness)).toBe(100)
|
||||
})
|
||||
|
||||
it('should return 1.5x size when hardness is 0.0', () => {
|
||||
const size = 100
|
||||
const hardness = 0.0
|
||||
expect(getEffectiveBrushSize(size, hardness)).toBe(150)
|
||||
})
|
||||
|
||||
it('should interpolate linearly', () => {
|
||||
const size = 100
|
||||
const hardness = 0.5
|
||||
// Scale should be 1.0 + 0.5 * 0.5 = 1.25
|
||||
expect(getEffectiveBrushSize(size, hardness)).toBe(125)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getEffectiveHardness', () => {
|
||||
it('should return same hardness if effective size matches size', () => {
|
||||
const size = 100
|
||||
const hardness = 0.8
|
||||
const effectiveSize = 100
|
||||
expect(getEffectiveHardness(size, hardness, effectiveSize)).toBe(0.8)
|
||||
})
|
||||
|
||||
it('should scale hardness down as effective size increases', () => {
|
||||
const size = 100
|
||||
const hardness = 0.5
|
||||
// Effective size at 0.5 hardness is 125
|
||||
const effectiveSize = 125
|
||||
// Hard core radius = 50. New hardness = 50 / 125 = 0.4
|
||||
expect(getEffectiveHardness(size, hardness, effectiveSize)).toBe(0.4)
|
||||
})
|
||||
|
||||
it('should return 0 if effective size is 0', () => {
|
||||
expect(getEffectiveHardness(100, 0.5, 0)).toBe(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
34
src/composables/maskeditor/brushUtils.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Calculates the effective brush size based on the base size and hardness.
|
||||
* As hardness decreases, the effective size increases to allow for a softer falloff.
|
||||
*
|
||||
* @param size - The base radius of the brush
|
||||
* @param hardness - The hardness of the brush (0.0 to 1.0)
|
||||
* @returns The effective radius of the brush
|
||||
*/
|
||||
export function getEffectiveBrushSize(size: number, hardness: number): number {
|
||||
// Scale factor for maximum softness
|
||||
const MAX_SCALE = 1.5
|
||||
const scale = 1.0 + (1.0 - hardness) * (MAX_SCALE - 1.0)
|
||||
return size * scale
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the effective hardness to maintain the visual "hard core" of the brush.
|
||||
* Since the effective size is larger, we need to adjust the hardness value so that
|
||||
* the inner hard circle remains at the same physical radius as the original size * hardness.
|
||||
*
|
||||
* @param size - The base radius of the brush
|
||||
* @param hardness - The base hardness of the brush
|
||||
* @param effectiveSize - The effective radius (calculated by getEffectiveBrushSize)
|
||||
* @returns The adjusted hardness value (0.0 to 1.0)
|
||||
*/
|
||||
export function getEffectiveHardness(
|
||||
size: number,
|
||||
hardness: number,
|
||||
effectiveSize: number
|
||||
): number {
|
||||
if (effectiveSize <= 0) return 0
|
||||
// Adjust hardness to maintain the physical radius of the hard core
|
||||
return (size * hardness) / effectiveSize
|
||||
}
|
||||
805
src/composables/maskeditor/gpu/GPUBrushRenderer.ts
Normal file
@@ -0,0 +1,805 @@
|
||||
import * as d from 'typegpu/data'
|
||||
import { StrokePoint } from './gpuSchema'
|
||||
import {
|
||||
brushFragment,
|
||||
brushVertex,
|
||||
blitShader,
|
||||
compositeShader,
|
||||
readbackShader
|
||||
} from './brushShaders'
|
||||
|
||||
// ... (rest of the file)
|
||||
|
||||
const QUAD_VERTS = new Float32Array([-1, -1, 1, -1, 1, 1, -1, 1])
|
||||
const QUAD_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3])
|
||||
|
||||
const UNIFORM_SIZE = 48 // Uniform buffer size aligned to 16 bytes
|
||||
const STROKE_STRIDE = d.sizeOf(StrokePoint) // 16
|
||||
const MAX_STROKES = 10000
|
||||
|
||||
export class GPUBrushRenderer {
|
||||
private device: GPUDevice
|
||||
|
||||
// Buffers
|
||||
private quadVertexBuffer: GPUBuffer
|
||||
private indexBuffer: GPUBuffer
|
||||
private instanceBuffer: GPUBuffer
|
||||
private uniformBuffer: GPUBuffer
|
||||
|
||||
// Pipelines
|
||||
private renderPipeline: GPURenderPipeline // Standard alpha blending pipeline
|
||||
private accumulatePipeline: GPURenderPipeline // SourceOver blending pipeline for stroke accumulation
|
||||
private blitPipeline: GPURenderPipeline
|
||||
private compositePipeline: GPURenderPipeline // Composite pipeline that applies opacity
|
||||
private compositePipelinePreview: GPURenderPipeline // Pipeline for rendering to the preview canvas
|
||||
private erasePipeline: GPURenderPipeline // Pipeline for erasing (Destination Out)
|
||||
private erasePipelinePreview: GPURenderPipeline // Eraser pipeline for the preview canvas
|
||||
readbackPipeline: GPUComputePipeline // Compute pipeline for texture readback
|
||||
|
||||
// Bind Group Layouts
|
||||
private uniformBindGroupLayout: GPUBindGroupLayout
|
||||
private textureBindGroupLayout: GPUBindGroupLayout
|
||||
|
||||
// Shared Bind Groups
|
||||
private mainUniformBindGroup: GPUBindGroup
|
||||
|
||||
// Textures
|
||||
private currentStrokeTexture: GPUTexture | null = null
|
||||
private currentStrokeView: GPUTextureView | null = null
|
||||
|
||||
// Cached Bind Groups
|
||||
private compositeTextureBindGroup: GPUBindGroup | null = null
|
||||
private previewTextureBindGroup: GPUBindGroup | null = null
|
||||
|
||||
// Removed separate uniform bind groups as we will use mainUniformBindGroup
|
||||
|
||||
private lastReadbackTexture: GPUTexture | null = null
|
||||
private lastReadbackBuffer: GPUBuffer | null = null
|
||||
private readbackBindGroup: GPUBindGroup | null = null
|
||||
|
||||
private lastBackgroundTexture: GPUTexture | null = null
|
||||
private backgroundBindGroup: GPUBindGroup | null = null
|
||||
|
||||
constructor(
|
||||
device: GPUDevice,
|
||||
presentationFormat: GPUTextureFormat = 'rgba8unorm'
|
||||
) {
|
||||
this.device = device
|
||||
|
||||
// --- 1. Initialize Buffers ---
|
||||
this.quadVertexBuffer = device.createBuffer({
|
||||
size: QUAD_VERTS.byteLength,
|
||||
usage: GPUBufferUsage.VERTEX,
|
||||
mappedAtCreation: true
|
||||
})
|
||||
new Float32Array(this.quadVertexBuffer.getMappedRange()).set(QUAD_VERTS)
|
||||
this.quadVertexBuffer.unmap()
|
||||
|
||||
this.indexBuffer = device.createBuffer({
|
||||
size: QUAD_INDICES.byteLength,
|
||||
usage: GPUBufferUsage.INDEX,
|
||||
mappedAtCreation: true
|
||||
})
|
||||
new Uint16Array(this.indexBuffer.getMappedRange()).set(QUAD_INDICES)
|
||||
this.indexBuffer.unmap()
|
||||
|
||||
this.instanceBuffer = device.createBuffer({
|
||||
size: MAX_STROKES * STROKE_STRIDE,
|
||||
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
||||
})
|
||||
|
||||
this.uniformBuffer = device.createBuffer({
|
||||
size: UNIFORM_SIZE,
|
||||
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
||||
})
|
||||
|
||||
// --- 2. Brush Shader (Drawing) ---
|
||||
const brushModuleV = device.createShaderModule({ code: brushVertex })
|
||||
const brushModuleF = device.createShaderModule({ code: brushFragment })
|
||||
|
||||
// Create explicit bind group layouts
|
||||
this.uniformBindGroupLayout = device.createBindGroupLayout({
|
||||
entries: [
|
||||
{
|
||||
binding: 0,
|
||||
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
||||
buffer: { type: 'uniform' }
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
this.textureBindGroupLayout = device.createBindGroupLayout({
|
||||
entries: [
|
||||
{
|
||||
binding: 0,
|
||||
visibility: GPUShaderStage.FRAGMENT,
|
||||
texture: {} // default is float, 2d
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
this.mainUniformBindGroup = device.createBindGroup({
|
||||
layout: this.uniformBindGroupLayout,
|
||||
entries: [{ binding: 0, resource: { buffer: this.uniformBuffer } }]
|
||||
})
|
||||
|
||||
const renderPipelineLayout = device.createPipelineLayout({
|
||||
bindGroupLayouts: [this.uniformBindGroupLayout]
|
||||
})
|
||||
|
||||
// Standard Render Pipeline (Alpha Blend)
|
||||
this.renderPipeline = device.createRenderPipeline({
|
||||
layout: renderPipelineLayout,
|
||||
vertex: {
|
||||
module: brushModuleV,
|
||||
entryPoint: 'vs',
|
||||
buffers: [
|
||||
{
|
||||
arrayStride: 8,
|
||||
stepMode: 'vertex',
|
||||
attributes: [{ shaderLocation: 0, offset: 0, format: 'float32x2' }] // Quad vertex attributes
|
||||
},
|
||||
{
|
||||
arrayStride: 16,
|
||||
stepMode: 'instance',
|
||||
attributes: [
|
||||
{ shaderLocation: 1, offset: 0, format: 'float32x2' }, // Instance attributes: position
|
||||
{ shaderLocation: 2, offset: 8, format: 'float32' }, // size
|
||||
{ shaderLocation: 3, offset: 12, format: 'float32' } // pressure
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
fragment: {
|
||||
module: brushModuleF,
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: 'rgba8unorm',
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// Accumulate strokes using SourceOver blending to ensure smooth intersections.
|
||||
this.accumulatePipeline = device.createRenderPipeline({
|
||||
layout: renderPipelineLayout,
|
||||
vertex: {
|
||||
module: brushModuleV,
|
||||
entryPoint: 'vs',
|
||||
buffers: [
|
||||
{
|
||||
arrayStride: 8,
|
||||
stepMode: 'vertex',
|
||||
attributes: [{ shaderLocation: 0, offset: 0, format: 'float32x2' }]
|
||||
},
|
||||
{
|
||||
arrayStride: 16,
|
||||
stepMode: 'instance',
|
||||
attributes: [
|
||||
{ shaderLocation: 1, offset: 0, format: 'float32x2' },
|
||||
{ shaderLocation: 2, offset: 8, format: 'float32' },
|
||||
{ shaderLocation: 3, offset: 12, format: 'float32' }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
fragment: {
|
||||
module: brushModuleF,
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: 'rgba8unorm',
|
||||
blend: {
|
||||
// Use SourceOver blending for smooth stroke intersections.
|
||||
color: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// --- 3. Blit Pipeline (For Preview) ---
|
||||
const blitPipelineLayout = device.createPipelineLayout({
|
||||
bindGroupLayouts: [this.textureBindGroupLayout]
|
||||
})
|
||||
|
||||
this.blitPipeline = device.createRenderPipeline({
|
||||
layout: blitPipelineLayout,
|
||||
vertex: {
|
||||
module: device.createShaderModule({ code: blitShader }),
|
||||
entryPoint: 'vs'
|
||||
},
|
||||
fragment: {
|
||||
module: device.createShaderModule({ code: blitShader }),
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: presentationFormat, // Use the presentation format
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// --- 4. Composite Pipeline ---
|
||||
|
||||
const compositePipelineLayout = device.createPipelineLayout({
|
||||
bindGroupLayouts: [
|
||||
this.textureBindGroupLayout,
|
||||
this.uniformBindGroupLayout
|
||||
]
|
||||
})
|
||||
|
||||
// Standard composite pipeline for offscreen textures
|
||||
this.compositePipeline = device.createRenderPipeline({
|
||||
layout: compositePipelineLayout,
|
||||
vertex: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'vs'
|
||||
},
|
||||
fragment: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: 'rgba8unorm',
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// Composite pipeline for the preview canvas
|
||||
this.compositePipelinePreview = device.createRenderPipeline({
|
||||
layout: compositePipelineLayout,
|
||||
vertex: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'vs'
|
||||
},
|
||||
fragment: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: presentationFormat,
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// --- 5. Erase Pipeline (Destination Out) ---
|
||||
// Standard erase pipeline for offscreen textures
|
||||
this.erasePipeline = device.createRenderPipeline({
|
||||
layout: compositePipelineLayout,
|
||||
vertex: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'vs'
|
||||
},
|
||||
fragment: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: 'rgba8unorm',
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'zero',
|
||||
dstFactor: 'one-minus-src-alpha', // dst * (1 - src_alpha)
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'zero',
|
||||
dstFactor: 'one-minus-src-alpha', // dst_alpha * (1 - src_alpha)
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// Erase pipeline for the preview canvas
|
||||
this.erasePipelinePreview = device.createRenderPipeline({
|
||||
layout: compositePipelineLayout,
|
||||
vertex: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'vs'
|
||||
},
|
||||
fragment: {
|
||||
module: device.createShaderModule({ code: compositeShader }),
|
||||
entryPoint: 'fs',
|
||||
targets: [
|
||||
{
|
||||
format: presentationFormat,
|
||||
blend: {
|
||||
color: {
|
||||
srcFactor: 'zero',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
},
|
||||
alpha: {
|
||||
srcFactor: 'zero',
|
||||
dstFactor: 'one-minus-src-alpha',
|
||||
operation: 'add'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
primitive: { topology: 'triangle-list' }
|
||||
})
|
||||
|
||||
// --- 6. Readback Pipeline (Compute) ---
|
||||
this.readbackPipeline = device.createComputePipeline({
|
||||
layout: 'auto',
|
||||
compute: {
|
||||
module: device.createShaderModule({ code: readbackShader }),
|
||||
entryPoint: 'main'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public prepareStroke(width: number, height: number) {
|
||||
// Initialize or resize the accumulation texture
|
||||
if (
|
||||
!this.currentStrokeTexture ||
|
||||
this.currentStrokeTexture.width !== width ||
|
||||
this.currentStrokeTexture.height !== height
|
||||
) {
|
||||
if (this.currentStrokeTexture) this.currentStrokeTexture.destroy()
|
||||
this.currentStrokeTexture = this.device.createTexture({
|
||||
size: [width, height],
|
||||
format: 'rgba8unorm',
|
||||
usage:
|
||||
GPUTextureUsage.RENDER_ATTACHMENT |
|
||||
GPUTextureUsage.TEXTURE_BINDING |
|
||||
GPUTextureUsage.COPY_SRC
|
||||
})
|
||||
this.currentStrokeView = this.currentStrokeTexture.createView()
|
||||
|
||||
// Invalidate texture-dependent bind groups
|
||||
this.compositeTextureBindGroup = null
|
||||
this.previewTextureBindGroup = null
|
||||
// Readback bind group might also be invalid if it was using the old texture
|
||||
if (this.lastReadbackTexture === this.currentStrokeTexture) {
|
||||
this.readbackBindGroup = null
|
||||
this.lastReadbackTexture = null
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the accumulation texture
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
const pass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: this.currentStrokeView!,
|
||||
loadOp: 'clear',
|
||||
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
pass.end()
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
}
|
||||
|
||||
public renderStrokeToAccumulator(
|
||||
points: { x: number; y: number; pressure: number }[],
|
||||
settings: {
|
||||
size: number
|
||||
opacity: number
|
||||
hardness: number
|
||||
color: [number, number, number]
|
||||
width: number
|
||||
height: number
|
||||
brushShape: number
|
||||
}
|
||||
) {
|
||||
if (!this.currentStrokeView) return
|
||||
// Render stroke using accumulation pipeline
|
||||
this.renderStrokeInternal(
|
||||
this.currentStrokeView,
|
||||
this.accumulatePipeline,
|
||||
points,
|
||||
settings
|
||||
)
|
||||
}
|
||||
|
||||
public compositeStroke(
|
||||
targetView: GPUTextureView,
|
||||
settings: {
|
||||
opacity: number
|
||||
color: [number, number, number]
|
||||
hardness: number // Required for uniform buffer layout
|
||||
screenSize: [number, number]
|
||||
brushShape: number
|
||||
isErasing?: boolean
|
||||
}
|
||||
) {
|
||||
if (!this.currentStrokeTexture) return
|
||||
|
||||
// Update uniforms for the composite pass
|
||||
const buffer = new ArrayBuffer(UNIFORM_SIZE)
|
||||
const f32 = new Float32Array(buffer)
|
||||
const u32 = new Uint32Array(buffer)
|
||||
|
||||
f32[0] = settings.color[0]
|
||||
f32[1] = settings.color[1]
|
||||
f32[2] = settings.color[2]
|
||||
f32[3] = settings.opacity
|
||||
f32[4] = settings.hardness
|
||||
f32[5] = 0 // Padding
|
||||
f32[6] = settings.screenSize[0]
|
||||
f32[7] = settings.screenSize[1]
|
||||
u32[8] = settings.brushShape // Brush shape: 0=Circle, 1=Square
|
||||
this.device.queue.writeBuffer(this.uniformBuffer, 0, buffer)
|
||||
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
|
||||
// Choose pipeline based on operation
|
||||
const pipeline = settings.isErasing
|
||||
? this.erasePipeline
|
||||
: this.compositePipeline
|
||||
|
||||
// 1. Texture Bind Group (Group 0)
|
||||
if (!this.compositeTextureBindGroup) {
|
||||
this.compositeTextureBindGroup = this.device.createBindGroup({
|
||||
layout: this.textureBindGroupLayout,
|
||||
entries: [
|
||||
{ binding: 0, resource: this.currentStrokeTexture.createView() }
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Uniform Bind Group (Group 1) - Use shared mainUniformBindGroup
|
||||
// It is compatible because we used the same layout
|
||||
|
||||
const pass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: targetView,
|
||||
loadOp: 'load',
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
pass.setPipeline(pipeline)
|
||||
pass.setBindGroup(0, this.compositeTextureBindGroup)
|
||||
pass.setBindGroup(1, this.mainUniformBindGroup)
|
||||
pass.draw(3)
|
||||
pass.end()
|
||||
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
}
|
||||
|
||||
// Direct rendering method
|
||||
public renderStroke(
|
||||
targetView: GPUTextureView,
|
||||
points: { x: number; y: number; pressure: number }[],
|
||||
settings: {
|
||||
size: number
|
||||
opacity: number
|
||||
hardness: number
|
||||
color: [number, number, number]
|
||||
width: number
|
||||
height: number
|
||||
brushShape: number
|
||||
}
|
||||
) {
|
||||
this.renderStrokeInternal(targetView, this.renderPipeline, points, settings)
|
||||
}
|
||||
|
||||
private renderStrokeInternal(
|
||||
targetView: GPUTextureView,
|
||||
pipeline: GPURenderPipeline,
|
||||
points: { x: number; y: number; pressure: number }[],
|
||||
settings: {
|
||||
size: number
|
||||
opacity: number
|
||||
hardness: number
|
||||
color: [number, number, number]
|
||||
width: number
|
||||
height: number
|
||||
brushShape: number
|
||||
}
|
||||
) {
|
||||
if (points.length === 0) return
|
||||
|
||||
// 1. Update Uniforms
|
||||
const buffer = new ArrayBuffer(UNIFORM_SIZE)
|
||||
const f32 = new Float32Array(buffer)
|
||||
const u32 = new Uint32Array(buffer)
|
||||
|
||||
f32[0] = settings.color[0]
|
||||
f32[1] = settings.color[1]
|
||||
f32[2] = settings.color[2]
|
||||
f32[3] = settings.opacity
|
||||
f32[4] = settings.hardness
|
||||
f32[5] = 0 // Padding
|
||||
f32[6] = settings.width
|
||||
f32[7] = settings.height
|
||||
u32[8] = settings.brushShape
|
||||
this.device.queue.writeBuffer(this.uniformBuffer, 0, buffer)
|
||||
|
||||
// 2. Batch Rendering
|
||||
let processedPoints = 0
|
||||
while (processedPoints < points.length) {
|
||||
const batchSize = Math.min(points.length - processedPoints, MAX_STROKES)
|
||||
const iData = new Float32Array(batchSize * 4)
|
||||
|
||||
for (let i = 0; i < batchSize; i++) {
|
||||
const p = points[processedPoints + i]
|
||||
iData[i * 4 + 0] = p.x
|
||||
iData[i * 4 + 1] = p.y
|
||||
iData[i * 4 + 2] = settings.size
|
||||
iData[i * 4 + 3] = p.pressure
|
||||
}
|
||||
|
||||
this.device.queue.writeBuffer(this.instanceBuffer, 0, iData)
|
||||
|
||||
// 3. Render Pass
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
const pass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: targetView,
|
||||
loadOp: 'load',
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
pass.setPipeline(pipeline)
|
||||
pass.setBindGroup(0, this.mainUniformBindGroup)
|
||||
pass.setVertexBuffer(0, this.quadVertexBuffer)
|
||||
pass.setVertexBuffer(1, this.instanceBuffer)
|
||||
pass.setIndexBuffer(this.indexBuffer, 'uint16')
|
||||
pass.drawIndexed(6, batchSize)
|
||||
pass.end()
|
||||
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
|
||||
processedPoints += batchSize
|
||||
}
|
||||
}
|
||||
|
||||
// Blit the accumulated stroke to the preview canvas
|
||||
public blitToCanvas(
|
||||
destinationCtx: GPUCanvasContext,
|
||||
settings: {
|
||||
opacity: number
|
||||
color: [number, number, number]
|
||||
hardness: number
|
||||
screenSize: [number, number]
|
||||
brushShape: number
|
||||
isErasing?: boolean
|
||||
},
|
||||
backgroundTexture?: GPUTexture
|
||||
) {
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
const destView = destinationCtx.getCurrentTexture().createView()
|
||||
|
||||
if (backgroundTexture) {
|
||||
// Draw background texture to allow erasing effect on existing content
|
||||
if (
|
||||
this.lastBackgroundTexture !== backgroundTexture ||
|
||||
!this.backgroundBindGroup
|
||||
) {
|
||||
this.backgroundBindGroup = this.device.createBindGroup({
|
||||
layout: this.textureBindGroupLayout,
|
||||
entries: [{ binding: 0, resource: backgroundTexture.createView() }]
|
||||
})
|
||||
this.lastBackgroundTexture = backgroundTexture
|
||||
}
|
||||
|
||||
const pass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: destView,
|
||||
loadOp: 'clear', // Clear attachment before drawing
|
||||
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
pass.setPipeline(this.blitPipeline)
|
||||
pass.setBindGroup(0, this.backgroundBindGroup)
|
||||
pass.draw(3)
|
||||
pass.end()
|
||||
} else {
|
||||
// Clear the destination texture
|
||||
const clearPass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: destView,
|
||||
loadOp: 'clear',
|
||||
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
clearPass.end()
|
||||
}
|
||||
|
||||
// Draw the accumulated stroke
|
||||
if (this.currentStrokeTexture) {
|
||||
// Update uniforms for the preview pass
|
||||
const buffer = new ArrayBuffer(UNIFORM_SIZE)
|
||||
const f32 = new Float32Array(buffer)
|
||||
const u32 = new Uint32Array(buffer)
|
||||
|
||||
f32[0] = settings.color[0]
|
||||
f32[1] = settings.color[1]
|
||||
f32[2] = settings.color[2]
|
||||
f32[3] = settings.opacity
|
||||
f32[4] = settings.hardness
|
||||
f32[5] = 0 // Padding
|
||||
f32[6] = settings.screenSize[0]
|
||||
f32[7] = settings.screenSize[1]
|
||||
u32[8] = settings.brushShape
|
||||
this.device.queue.writeBuffer(this.uniformBuffer, 0, buffer)
|
||||
|
||||
// Select preview pipeline based on operation
|
||||
const pipeline = settings.isErasing
|
||||
? this.erasePipelinePreview
|
||||
: this.compositePipelinePreview
|
||||
|
||||
// 1. Texture Bind Group (Group 0)
|
||||
if (!this.previewTextureBindGroup) {
|
||||
this.previewTextureBindGroup = this.device.createBindGroup({
|
||||
layout: this.textureBindGroupLayout,
|
||||
entries: [
|
||||
{ binding: 0, resource: this.currentStrokeTexture.createView() }
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Uniform Bind Group (Group 1) - Use shared mainUniformBindGroup
|
||||
|
||||
const passStroke = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: destView,
|
||||
loadOp: 'load', // Load the previous pass result
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
passStroke.setPipeline(pipeline)
|
||||
passStroke.setBindGroup(0, this.previewTextureBindGroup)
|
||||
passStroke.setBindGroup(1, this.mainUniformBindGroup)
|
||||
passStroke.draw(3)
|
||||
passStroke.end()
|
||||
}
|
||||
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
}
|
||||
|
||||
// Clear the preview canvas
|
||||
public clearPreview(destinationCtx: GPUCanvasContext) {
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
const pass = encoder.beginRenderPass({
|
||||
colorAttachments: [
|
||||
{
|
||||
view: destinationCtx.getCurrentTexture().createView(),
|
||||
loadOp: 'clear',
|
||||
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
||||
storeOp: 'store'
|
||||
}
|
||||
]
|
||||
})
|
||||
pass.end()
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
}
|
||||
|
||||
public prepareReadback(texture: GPUTexture, outputBuffer: GPUBuffer) {
|
||||
if (
|
||||
this.lastReadbackTexture !== texture ||
|
||||
this.lastReadbackBuffer !== outputBuffer ||
|
||||
!this.readbackBindGroup
|
||||
) {
|
||||
this.readbackBindGroup = this.device.createBindGroup({
|
||||
layout: this.readbackPipeline.getBindGroupLayout(0),
|
||||
entries: [
|
||||
{ binding: 0, resource: texture.createView() },
|
||||
{ binding: 1, resource: { buffer: outputBuffer } }
|
||||
]
|
||||
})
|
||||
this.lastReadbackTexture = texture
|
||||
this.lastReadbackBuffer = outputBuffer
|
||||
}
|
||||
|
||||
const encoder = this.device.createCommandEncoder()
|
||||
const pass = encoder.beginComputePass()
|
||||
pass.setPipeline(this.readbackPipeline)
|
||||
pass.setBindGroup(0, this.readbackBindGroup)
|
||||
|
||||
const width = texture.width
|
||||
const height = texture.height
|
||||
// Dispatch workgroups based on texture dimensions (8x8 block size)
|
||||
pass.dispatchWorkgroups(Math.ceil(width / 8), Math.ceil(height / 8))
|
||||
pass.end()
|
||||
|
||||
this.device.queue.submit([encoder.finish()])
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.quadVertexBuffer.destroy()
|
||||
this.indexBuffer.destroy()
|
||||
this.instanceBuffer.destroy()
|
||||
this.uniformBuffer.destroy()
|
||||
if (this.currentStrokeTexture) this.currentStrokeTexture.destroy()
|
||||
|
||||
// Clear cached bind groups
|
||||
this.compositeTextureBindGroup = null
|
||||
this.previewTextureBindGroup = null
|
||||
this.readbackBindGroup = null
|
||||
this.backgroundBindGroup = null
|
||||
this.lastReadbackTexture = null
|
||||
this.lastReadbackBuffer = null
|
||||
this.lastBackgroundTexture = null
|
||||
}
|
||||
}
|
||||
171
src/composables/maskeditor/gpu/brushShaders.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import tgpu from 'typegpu'
|
||||
import * as d from 'typegpu/data'
|
||||
import { BrushUniforms } from './gpuSchema'
|
||||
|
||||
const VertexOutput = d.struct({
|
||||
position: d.builtin.position,
|
||||
localUV: d.location(0, d.vec2f),
|
||||
color: d.location(1, d.vec3f),
|
||||
opacity: d.location(2, d.f32),
|
||||
hardness: d.location(3, d.f32)
|
||||
})
|
||||
|
||||
const brushVertexTemplate = `
|
||||
@group(0) @binding(0) var<uniform> globals: BrushUniforms;
|
||||
|
||||
@vertex
|
||||
fn vs(
|
||||
@location(0) quadPos: vec2<f32>,
|
||||
@location(1) pos: vec2<f32>,
|
||||
@location(2) size: f32,
|
||||
@location(3) pressure: f32
|
||||
) -> VertexOutput {
|
||||
// Convert diameter to radius
|
||||
let radius = size * pressure;
|
||||
let pixelPos = pos + (quadPos * radius);
|
||||
|
||||
// Convert pixel coordinates to Normalized Device Coordinates (NDC)
|
||||
let ndcX = (pixelPos.x / globals.screenSize.x) * 2.0 - 1.0;
|
||||
let ndcY = 1.0 - ((pixelPos.y / globals.screenSize.y) * 2.0); // Flip Y axis for WebGPU coordinate system
|
||||
|
||||
return VertexOutput(
|
||||
vec4<f32>(ndcX, ndcY, 0.0, 1.0),
|
||||
quadPos,
|
||||
globals.brushColor,
|
||||
pressure * globals.brushOpacity,
|
||||
globals.hardness
|
||||
);
|
||||
}
|
||||
`
|
||||
|
||||
export const brushVertex = tgpu.resolve({
|
||||
template: brushVertexTemplate,
|
||||
externals: {
|
||||
BrushUniforms,
|
||||
VertexOutput
|
||||
}
|
||||
})
|
||||
|
||||
const brushFragmentTemplate = `
|
||||
@group(0) @binding(0) var<uniform> globals: BrushUniforms;
|
||||
|
||||
@fragment
|
||||
fn fs(v: VertexOutput) -> @location(0) vec4<f32> {
|
||||
var dist: f32;
|
||||
if (globals.brushShape == 1u) {
|
||||
// Calculate Chebyshev distance for square shape
|
||||
dist = max(abs(v.localUV.x), abs(v.localUV.y));
|
||||
} else {
|
||||
// Calculate Euclidean distance for circle shape
|
||||
dist = length(v.localUV);
|
||||
}
|
||||
|
||||
if (dist > 1.0) { discard; }
|
||||
|
||||
// Calculate alpha with hardness and anti-aliasing
|
||||
let edgeWidth = fwidth(dist);
|
||||
let startFade = min(v.hardness, 1.0 - edgeWidth * 2.0);
|
||||
let linearAlpha = 1.0 - smoothstep(startFade, 1.0, dist);
|
||||
// Apply quadratic falloff for smoother edges
|
||||
let alphaShape = pow(linearAlpha, 2.0);
|
||||
|
||||
// Return premultiplied alpha color
|
||||
let alpha = alphaShape * v.opacity;
|
||||
return vec4<f32>(v.color * alpha, alpha);
|
||||
}
|
||||
`
|
||||
|
||||
export const brushFragment = tgpu.resolve({
|
||||
template: brushFragmentTemplate,
|
||||
externals: {
|
||||
VertexOutput,
|
||||
BrushUniforms
|
||||
}
|
||||
})
|
||||
|
||||
const blitShaderTemplate = `
|
||||
@vertex fn vs(@builtin(vertex_index) vIdx: u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, -1.0), vec2<f32>(3.0, -1.0), vec2<f32>(-1.0, 3.0)
|
||||
);
|
||||
return vec4<f32>(pos[vIdx], 0.0, 1.0);
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var myTexture: texture_2d<f32>;
|
||||
|
||||
@fragment fn fs(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
let c = textureLoad(myTexture, vec2<i32>(pos.xy), 0);
|
||||
// Treat texture as premultiplied to prevent double-darkening on overlaps
|
||||
return c;
|
||||
}
|
||||
`
|
||||
|
||||
export const blitShader = tgpu.resolve({
|
||||
template: blitShaderTemplate,
|
||||
externals: {}
|
||||
})
|
||||
|
||||
const compositeShaderTemplate = `
|
||||
@vertex fn vs(@builtin(vertex_index) vIdx: u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, -1.0), vec2<f32>(3.0, -1.0), vec2<f32>(-1.0, 3.0)
|
||||
);
|
||||
return vec4<f32>(pos[vIdx], 0.0, 1.0);
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var myTexture: texture_2d<f32>;
|
||||
@group(1) @binding(0) var<uniform> globals: BrushUniforms;
|
||||
|
||||
@fragment fn fs(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
let sampled = textureLoad(myTexture, vec2<i32>(pos.xy), 0);
|
||||
// Apply global brush opacity to accumulated coverage
|
||||
return sampled * globals.brushOpacity;
|
||||
}
|
||||
`
|
||||
|
||||
export const compositeShader = tgpu.resolve({
|
||||
template: compositeShaderTemplate,
|
||||
externals: {
|
||||
BrushUniforms
|
||||
}
|
||||
})
|
||||
|
||||
const readbackShaderTemplate = `
|
||||
@group(0) @binding(0) var inputTex: texture_2d<f32>;
|
||||
@group(0) @binding(1) var<storage, read_write> outputBuf: array<u32>;
|
||||
|
||||
@compute @workgroup_size(8, 8)
|
||||
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
let dims = textureDimensions(inputTex);
|
||||
if (id.x >= dims.x || id.y >= dims.y) { return; }
|
||||
|
||||
let color = textureLoad(inputTex, vec2<i32>(id.xy), 0);
|
||||
|
||||
var r = color.r;
|
||||
var g = color.g;
|
||||
var b = color.b;
|
||||
let a = color.a;
|
||||
|
||||
if (a > 0.0) {
|
||||
r = r / a;
|
||||
g = g / a;
|
||||
b = b / a;
|
||||
}
|
||||
|
||||
let ir = u32(clamp(r * 255.0, 0.0, 255.0));
|
||||
let ig = u32(clamp(g * 255.0, 0.0, 255.0));
|
||||
let ib = u32(clamp(b * 255.0, 0.0, 255.0));
|
||||
let ia = u32(clamp(a * 255.0, 0.0, 255.0));
|
||||
|
||||
// Pack RGBA channels into a single u32 (Little Endian)
|
||||
let packed = ir | (ig << 8u) | (ib << 16u) | (ia << 24u);
|
||||
|
||||
let index = id.y * dims.x + id.x;
|
||||
outputBuf[index] = packed;
|
||||
}
|
||||
`
|
||||
|
||||
export const readbackShader = tgpu.resolve({
|
||||
template: readbackShaderTemplate,
|
||||
externals: {}
|
||||
})
|
||||
17
src/composables/maskeditor/gpu/gpuSchema.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as d from 'typegpu/data'
|
||||
|
||||
// Global brush uniforms
|
||||
export const BrushUniforms = d.struct({
|
||||
brushColor: d.vec3f,
|
||||
brushOpacity: d.f32,
|
||||
hardness: d.f32,
|
||||
screenSize: d.vec2f,
|
||||
brushShape: d.u32 // 0: Circle, 1: Square
|
||||
})
|
||||
|
||||
// Per-point instance data
|
||||
export const StrokePoint = d.struct({
|
||||
pos: d.location(0, d.vec2f), // Center position
|
||||
size: d.location(1, d.f32), // Brush radius
|
||||
pressure: d.location(2, d.f32) // Pressure value (0.0 - 1.0)
|
||||
})
|
||||
126
src/composables/maskeditor/splineUtils.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import type { Point } from '@/extensions/core/maskeditor/types'
|
||||
|
||||
/**
|
||||
* Evaluates a Catmull-Rom spline at parameter t between p1 and p2
|
||||
* @param p0 Previous control point
|
||||
* @param p1 Start point of the curve segment
|
||||
* @param p2 End point of the curve segment
|
||||
* @param p3 Next control point
|
||||
* @param t Parameter in range [0, 1]
|
||||
* @returns Interpolated point on the curve
|
||||
*/
|
||||
export function catmullRomSpline(
|
||||
p0: Point,
|
||||
p1: Point,
|
||||
p2: Point,
|
||||
p3: Point,
|
||||
t: number
|
||||
): Point {
|
||||
// Centripetal Catmull-Rom Spline (alpha = 0.5) to prevent loops and overshoots
|
||||
const alpha = 0.5
|
||||
|
||||
const getT = (t: number, p0: Point, p1: Point) => {
|
||||
const d = Math.hypot(p1.x - p0.x, p1.y - p0.y)
|
||||
return t + Math.pow(d, alpha)
|
||||
}
|
||||
|
||||
const t0 = 0
|
||||
const t1 = getT(t0, p0, p1)
|
||||
const t2 = getT(t1, p1, p2)
|
||||
const t3 = getT(t2, p2, p3)
|
||||
|
||||
// Map normalized t to parameter range
|
||||
const tInterp = t1 + (t2 - t1) * t
|
||||
|
||||
// Safe interpolation for coincident points
|
||||
const interp = (
|
||||
pA: Point,
|
||||
pB: Point,
|
||||
tA: number,
|
||||
tB: number,
|
||||
t: number
|
||||
): Point => {
|
||||
if (Math.abs(tB - tA) < 0.0001) return pA
|
||||
const k = (t - tA) / (tB - tA)
|
||||
return add(mul(pA, 1 - k), mul(pB, k))
|
||||
}
|
||||
|
||||
// Barry-Goldman pyramidal interpolation
|
||||
const A1 = interp(p0, p1, t0, t1, tInterp)
|
||||
const A2 = interp(p1, p2, t1, t2, tInterp)
|
||||
const A3 = interp(p2, p3, t2, t3, tInterp)
|
||||
|
||||
const B1 = interp(A1, A2, t0, t2, tInterp)
|
||||
const B2 = interp(A2, A3, t1, t3, tInterp)
|
||||
|
||||
const C = interp(B1, B2, t1, t2, tInterp)
|
||||
|
||||
return C
|
||||
}
|
||||
|
||||
function add(p1: Point, p2: Point): Point {
|
||||
return { x: p1.x + p2.x, y: p1.y + p2.y }
|
||||
}
|
||||
|
||||
function mul(p: Point, s: number): Point {
|
||||
return { x: p.x * s, y: p.y * s }
|
||||
}
|
||||
|
||||
/**
|
||||
* Resamples a curve segment with a starting offset (remainder from previous segment).
|
||||
* Returns the resampled points and the new remainder distance.
|
||||
*
|
||||
* @param points Points defining the curve segment
|
||||
* @param spacing Desired spacing between points
|
||||
* @param startOffset Distance to travel before placing the first point (remainder)
|
||||
* @returns Object containing points and new remainder
|
||||
*/
|
||||
export function resampleSegment(
|
||||
points: Point[],
|
||||
spacing: number,
|
||||
startOffset: number
|
||||
): { points: Point[]; remainder: number } {
|
||||
if (points.length === 0) return { points: [], remainder: startOffset }
|
||||
|
||||
const result: Point[] = []
|
||||
let currentDist = 0
|
||||
let nextSampleDist = startOffset
|
||||
|
||||
// Iterate through segment points
|
||||
for (let i = 0; i < points.length - 1; i++) {
|
||||
const p1 = points[i]
|
||||
const p2 = points[i + 1]
|
||||
|
||||
const dx = p2.x - p1.x
|
||||
const dy = p2.y - p1.y
|
||||
const segmentLen = Math.hypot(dx, dy)
|
||||
|
||||
// Handle zero-length segments
|
||||
if (segmentLen < 0.0001) {
|
||||
while (nextSampleDist <= currentDist) {
|
||||
result.push(p1)
|
||||
nextSampleDist += spacing
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Generate samples within the segment
|
||||
while (nextSampleDist <= currentDist + segmentLen) {
|
||||
const t = (nextSampleDist - currentDist) / segmentLen
|
||||
|
||||
// Interpolate
|
||||
const x = p1.x + t * dx
|
||||
const y = p1.y + t * dy
|
||||
result.push({ x, y })
|
||||
|
||||
nextSampleDist += spacing
|
||||
}
|
||||
|
||||
currentDist += segmentLen
|
||||
}
|
||||
|
||||
// Calculate remainder distance for the next segment
|
||||
const remainder = nextSampleDist - currentDist
|
||||
|
||||
return { points: result, remainder }
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import { useMaskEditorStore } from '@/stores/maskEditorStore'
|
||||
export function useCanvasHistory(maxStates = 20) {
|
||||
const store = useMaskEditorStore()
|
||||
|
||||
const states = ref<{ mask: ImageData; rgb: ImageData }[]>([])
|
||||
const states = ref<
|
||||
{ mask: ImageData | ImageBitmap; rgb: ImageData | ImageBitmap }[]
|
||||
>([])
|
||||
const currentStateIndex = ref(-1)
|
||||
const initialized = ref(false)
|
||||
|
||||
@@ -53,7 +55,10 @@ export function useCanvasHistory(maxStates = 20) {
|
||||
initialized.value = true
|
||||
}
|
||||
|
||||
const saveState = () => {
|
||||
const saveState = (
|
||||
providedMaskData?: ImageData | ImageBitmap,
|
||||
providedRgbData?: ImageData | ImageBitmap
|
||||
) => {
|
||||
const maskCtx = store.maskCtx
|
||||
const rgbCtx = store.rgbCtx
|
||||
const maskCanvas = store.maskCanvas
|
||||
@@ -68,23 +73,32 @@ export function useCanvasHistory(maxStates = 20) {
|
||||
|
||||
states.value = states.value.slice(0, currentStateIndex.value + 1)
|
||||
|
||||
const maskState = maskCtx.getImageData(
|
||||
0,
|
||||
0,
|
||||
maskCanvas.width,
|
||||
maskCanvas.height
|
||||
)
|
||||
const rgbState = rgbCtx.getImageData(
|
||||
0,
|
||||
0,
|
||||
rgbCanvas.width,
|
||||
rgbCanvas.height
|
||||
)
|
||||
let maskState: ImageData | ImageBitmap
|
||||
let rgbState: ImageData | ImageBitmap
|
||||
|
||||
if (providedMaskData && providedRgbData) {
|
||||
maskState = providedMaskData
|
||||
rgbState = providedRgbData
|
||||
} else {
|
||||
maskState = maskCtx.getImageData(
|
||||
0,
|
||||
0,
|
||||
maskCanvas.width,
|
||||
maskCanvas.height
|
||||
)
|
||||
rgbState = rgbCtx.getImageData(0, 0, rgbCanvas.width, rgbCanvas.height)
|
||||
}
|
||||
|
||||
states.value.push({ mask: maskState, rgb: rgbState })
|
||||
currentStateIndex.value++
|
||||
|
||||
if (states.value.length > maxStates) {
|
||||
states.value.shift()
|
||||
const removed = states.value.shift()
|
||||
// Cleanup ImageBitmaps to avoid memory leaks
|
||||
if (removed) {
|
||||
if (removed.mask instanceof ImageBitmap) removed.mask.close()
|
||||
if (removed.rgb instanceof ImageBitmap) removed.rgb.close()
|
||||
}
|
||||
currentStateIndex.value--
|
||||
}
|
||||
}
|
||||
@@ -109,16 +123,35 @@ export function useCanvasHistory(maxStates = 20) {
|
||||
restoreState(states.value[currentStateIndex.value])
|
||||
}
|
||||
|
||||
const restoreState = (state: { mask: ImageData; rgb: ImageData }) => {
|
||||
const restoreState = (state: {
|
||||
mask: ImageData | ImageBitmap
|
||||
rgb: ImageData | ImageBitmap
|
||||
}) => {
|
||||
const maskCtx = store.maskCtx
|
||||
const rgbCtx = store.rgbCtx
|
||||
if (!maskCtx || !rgbCtx) return
|
||||
|
||||
maskCtx.putImageData(state.mask, 0, 0)
|
||||
rgbCtx.putImageData(state.rgb, 0, 0)
|
||||
if (state.mask instanceof ImageBitmap) {
|
||||
maskCtx.clearRect(0, 0, state.mask.width, state.mask.height)
|
||||
maskCtx.drawImage(state.mask, 0, 0)
|
||||
} else {
|
||||
maskCtx.putImageData(state.mask, 0, 0)
|
||||
}
|
||||
|
||||
if (state.rgb instanceof ImageBitmap) {
|
||||
rgbCtx.clearRect(0, 0, state.rgb.width, state.rgb.height)
|
||||
rgbCtx.drawImage(state.rgb, 0, 0)
|
||||
} else {
|
||||
rgbCtx.putImageData(state.rgb, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
const clearStates = () => {
|
||||
// Cleanup bitmaps
|
||||
states.value.forEach((state) => {
|
||||
if (state.mask instanceof ImageBitmap) state.mask.close()
|
||||
if (state.rgb instanceof ImageBitmap) state.rgb.close()
|
||||
})
|
||||
states.value = []
|
||||
currentStateIndex.value = -1
|
||||
initialized.value = false
|
||||
@@ -127,6 +160,7 @@ export function useCanvasHistory(maxStates = 20) {
|
||||
return {
|
||||
canUndo,
|
||||
canRedo,
|
||||
currentStateIndex,
|
||||
saveInitialState,
|
||||
saveState,
|
||||
undo,
|
||||
|
||||
48
src/composables/maskeditor/useMaskEditor.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
import TopBarHeader from '@/components/maskeditor/dialog/TopBarHeader.vue'
|
||||
import MaskEditorContent from '@/components/maskeditor/MaskEditorContent.vue'
|
||||
|
||||
export function useMaskEditor() {
|
||||
const openMaskEditor = (node: LGraphNode) => {
|
||||
if (!node) {
|
||||
console.error('[MaskEditor] No node provided')
|
||||
return
|
||||
}
|
||||
|
||||
if (!node.imgs?.length && node.previewMediaType !== 'image') {
|
||||
console.error('[MaskEditor] Node has no images')
|
||||
return
|
||||
}
|
||||
|
||||
useDialogStore().showDialog({
|
||||
key: 'global-mask-editor',
|
||||
headerComponent: TopBarHeader,
|
||||
component: MaskEditorContent,
|
||||
props: {
|
||||
node
|
||||
},
|
||||
dialogComponentProps: {
|
||||
style: 'width: 90vw; height: 90vh;',
|
||||
modal: true,
|
||||
maximizable: true,
|
||||
closable: true,
|
||||
pt: {
|
||||
root: {
|
||||
class: 'mask-editor-dialog flex flex-col'
|
||||
},
|
||||
content: {
|
||||
class: 'flex flex-col min-h-0 flex-1 !p-0'
|
||||
},
|
||||
header: {
|
||||
class: '!p-2'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
openMaskEditor
|
||||
}
|
||||
}
|
||||
@@ -80,21 +80,64 @@ export function useMaskEditorLoader() {
|
||||
try {
|
||||
validateNode(node)
|
||||
|
||||
const nodeImageUrl = getNodeImageUrl(node)
|
||||
let nodeImageUrl = getNodeImageUrl(node)
|
||||
|
||||
const nodeImageRef = parseImageRef(nodeImageUrl)
|
||||
let nodeImageRef = parseImageRef(nodeImageUrl)
|
||||
|
||||
let widgetFilename: string | undefined
|
||||
if (node.widgets) {
|
||||
const imageWidget = node.widgets.find((w) => w.name === 'image')
|
||||
if (
|
||||
imageWidget &&
|
||||
typeof imageWidget.value === 'object' &&
|
||||
imageWidget.value &&
|
||||
'filename' in imageWidget.value &&
|
||||
typeof imageWidget.value.filename === 'string'
|
||||
) {
|
||||
widgetFilename = imageWidget.value.filename
|
||||
if (imageWidget) {
|
||||
if (typeof imageWidget.value === 'string') {
|
||||
widgetFilename = imageWidget.value
|
||||
} else if (
|
||||
typeof imageWidget.value === 'object' &&
|
||||
imageWidget.value &&
|
||||
'filename' in imageWidget.value &&
|
||||
typeof imageWidget.value.filename === 'string'
|
||||
) {
|
||||
widgetFilename = imageWidget.value.filename
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a widget filename, we should prioritize it over the node image
|
||||
// because the node image might be stale (e.g. from a previous save)
|
||||
// while the widget value reflects the current selection.
|
||||
if (widgetFilename) {
|
||||
try {
|
||||
// Parse the widget value which might be in format "subfolder/filename [type]" or just "filename"
|
||||
let filename = widgetFilename
|
||||
let subfolder: string | undefined = undefined
|
||||
let type: string | undefined = 'input' // Default to input for widget values
|
||||
|
||||
// Check for type in brackets at the end
|
||||
const typeMatch = filename.match(/ \[([^\]]+)\]$/)
|
||||
if (typeMatch) {
|
||||
type = typeMatch[1]
|
||||
filename = filename.substring(
|
||||
0,
|
||||
filename.length - typeMatch[0].length
|
||||
)
|
||||
}
|
||||
|
||||
// Check for subfolder (forward slash separator)
|
||||
const lastSlashIndex = filename.lastIndexOf('/')
|
||||
if (lastSlashIndex !== -1) {
|
||||
subfolder = filename.substring(0, lastSlashIndex)
|
||||
filename = filename.substring(lastSlashIndex + 1)
|
||||
}
|
||||
|
||||
nodeImageRef = {
|
||||
filename,
|
||||
type,
|
||||
subfolder
|
||||
}
|
||||
|
||||
// We also need to update nodeImageUrl to match this new ref so subsequent logic works
|
||||
nodeImageUrl = mkFileUrl({ ref: nodeImageRef })
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse widget filename as ref', e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
|
||||
export const CORE_MENU_COMMANDS = [
|
||||
[[], ['Comfy.NewBlankWorkflow']],
|
||||
[[], []], // Separator after New
|
||||
@@ -14,13 +16,16 @@ export const CORE_MENU_COMMANDS = [
|
||||
[['Edit'], ['Comfy.Undo', 'Comfy.Redo']],
|
||||
[['Edit'], ['Comfy.ClearWorkflow']],
|
||||
[['Edit'], ['Comfy.OpenClipspace']],
|
||||
[['Edit'], ['Comfy.RefreshNodeDefinitions']],
|
||||
[
|
||||
['Edit'],
|
||||
[
|
||||
'Comfy.RefreshNodeDefinitions',
|
||||
'Comfy.Memory.UnloadModels',
|
||||
'Comfy.Memory.UnloadModelsAndExecutionCache'
|
||||
...(isCloud
|
||||
? []
|
||||
: [
|
||||
'Comfy.Memory.UnloadModels',
|
||||
'Comfy.Memory.UnloadModelsAndExecutionCache'
|
||||
])
|
||||
]
|
||||
],
|
||||
[['View'], []],
|
||||
|
||||
@@ -5,10 +5,9 @@ import { app } from '@/scripts/app'
|
||||
import { ComfyApp } from '@/scripts/app'
|
||||
import { useMaskEditorStore } from '@/stores/maskEditorStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
import MaskEditorContent from '@/components/maskeditor/MaskEditorContent.vue'
|
||||
import TopBarHeader from '@/components/maskeditor/dialog/TopBarHeader.vue'
|
||||
import { MaskEditorDialogOld } from './maskEditorOld'
|
||||
import { ClipspaceDialog } from './clipspace'
|
||||
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
|
||||
|
||||
function openMaskEditor(node: LGraphNode): void {
|
||||
if (!node) {
|
||||
@@ -26,32 +25,7 @@ function openMaskEditor(node: LGraphNode): void {
|
||||
)
|
||||
|
||||
if (useNewEditor) {
|
||||
// Use new refactored editor
|
||||
useDialogStore().showDialog({
|
||||
key: 'global-mask-editor',
|
||||
headerComponent: TopBarHeader,
|
||||
component: MaskEditorContent,
|
||||
props: {
|
||||
node
|
||||
},
|
||||
dialogComponentProps: {
|
||||
style: 'width: 90vw; height: 90vh;',
|
||||
modal: true,
|
||||
maximizable: true,
|
||||
closable: true,
|
||||
pt: {
|
||||
root: {
|
||||
class: 'mask-editor-dialog flex flex-col'
|
||||
},
|
||||
content: {
|
||||
class: 'flex flex-col min-h-0 flex-1 !p-0'
|
||||
},
|
||||
header: {
|
||||
class: '!p-2'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
useMaskEditor().openMaskEditor(node)
|
||||
} else {
|
||||
// Use old editor
|
||||
ComfyApp.copyToClipspace(node)
|
||||
|
||||
@@ -61,5 +61,5 @@ export interface Brush {
|
||||
size: number
|
||||
opacity: number
|
||||
hardness: number
|
||||
smoothingPrecision: number
|
||||
stepSize: number
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export type {
|
||||
LGraphTriggerParam
|
||||
} from './types/graphTriggers'
|
||||
|
||||
export type rendererType = 'LG' | 'Vue'
|
||||
export type RendererType = 'LG' | 'Vue'
|
||||
|
||||
export interface LGraphState {
|
||||
lastGroupId: number
|
||||
@@ -106,7 +106,7 @@ export interface LGraphExtra extends Dictionary<unknown> {
|
||||
reroutes?: SerialisableReroute[]
|
||||
linkExtensions?: { id: number; parentId: number | undefined }[]
|
||||
ds?: DragAndScaleState
|
||||
workflowRendererVersion?: rendererType
|
||||
workflowRendererVersion?: RendererType
|
||||
}
|
||||
|
||||
export interface BaseLGraph {
|
||||
|
||||
@@ -1186,7 +1186,8 @@
|
||||
"Vue Nodes": "Vue Nodes",
|
||||
"Canvas Navigation": "Canvas Navigation",
|
||||
"PlanCredits": "Plan & Credits",
|
||||
"VueNodes": "Vue Nodes"
|
||||
"VueNodes": "Vue Nodes",
|
||||
"Nodes 2_0": "Nodes 2.0"
|
||||
},
|
||||
"serverConfigItems": {
|
||||
"listen": {
|
||||
@@ -2198,6 +2199,10 @@
|
||||
"vueNodesMigrationMainMenu": {
|
||||
"message": "Switch back to Nodes 2.0 anytime from the main menu."
|
||||
},
|
||||
"linearMode": {
|
||||
"share": "Share",
|
||||
"openWorkflow": "Open Workflow"
|
||||
},
|
||||
"missingNodes": {
|
||||
"cloud": {
|
||||
"title": "These nodes aren't available on Comfy Cloud yet",
|
||||
|
||||
@@ -2001,7 +2001,7 @@
|
||||
}
|
||||
},
|
||||
"EmptyHunyuanLatentVideo": {
|
||||
"display_name": "EmptyHunyuanLatentVideo",
|
||||
"display_name": "Empty HunyuanVideo 1.0 Latent",
|
||||
"inputs": {
|
||||
"width": {
|
||||
"name": "width"
|
||||
@@ -2023,7 +2023,7 @@
|
||||
}
|
||||
},
|
||||
"EmptyHunyuanVideo15Latent": {
|
||||
"display_name": "EmptyHunyuanVideo15Latent",
|
||||
"display_name": "Empty HunyuanVideo 1.5 Latent",
|
||||
"inputs": {
|
||||
"width": {
|
||||
"name": "width"
|
||||
|
||||
@@ -335,11 +335,11 @@
|
||||
"name": "Validate workflows"
|
||||
},
|
||||
"Comfy_VueNodes_AutoScaleLayout": {
|
||||
"name": "Auto-scale layout (Vue nodes)",
|
||||
"name": "Auto-scale layout (Nodes 2.0)",
|
||||
"tooltip": "Automatically scale node positions when switching to Vue rendering to prevent overlap"
|
||||
},
|
||||
"Comfy_VueNodes_Enabled": {
|
||||
"name": "Modern Node Design (Vue Nodes)",
|
||||
"name": "Modern Node Design (Nodes 2.0)",
|
||||
"tooltip": "Modern: DOM-based rendering with enhanced interactivity, native browser features, and updated visual design. Classic: Traditional canvas rendering."
|
||||
},
|
||||
"Comfy_WidgetControlMode": {
|
||||
|
||||
@@ -107,10 +107,17 @@ const {
|
||||
|
||||
const authActions = useFirebaseAuthActions()
|
||||
|
||||
// Get max sortOrder from settings in a group
|
||||
const getGroupSortOrder = (group: SettingTreeNode): number =>
|
||||
Math.max(0, ...flattenTree<SettingParams>(group).map((s) => s.sortOrder ?? 0))
|
||||
|
||||
// Sort groups for a category
|
||||
const sortedGroups = (category: SettingTreeNode): ISettingGroup[] => {
|
||||
return [...(category.children ?? [])]
|
||||
.sort((a, b) => a.label.localeCompare(b.label))
|
||||
.sort((a, b) => {
|
||||
const orderDiff = getGroupSortOrder(b) - getGroupSortOrder(a)
|
||||
return orderDiff !== 0 ? orderDiff : a.label.localeCompare(b.label)
|
||||
})
|
||||
.map((group) => ({
|
||||
label: group.label,
|
||||
settings: flattenTree<SettingParams>(group).sort((a, b) => {
|
||||
|
||||
@@ -1082,24 +1082,28 @@ export const CORE_SETTINGS: SettingParams[] = [
|
||||
},
|
||||
|
||||
/**
|
||||
* Vue Node System Settings
|
||||
* Nodes 2.0 Settings
|
||||
*/
|
||||
{
|
||||
id: 'Comfy.VueNodes.Enabled',
|
||||
name: 'Modern Node Design (Vue Nodes)',
|
||||
category: ['Comfy', 'Nodes 2.0', 'VueNodesEnabled'],
|
||||
name: 'Modern Node Design (Nodes 2.0)',
|
||||
type: 'boolean',
|
||||
tooltip:
|
||||
'Modern: DOM-based rendering with enhanced interactivity, native browser features, and updated visual design. Classic: Traditional canvas rendering.',
|
||||
defaultValue: false,
|
||||
sortOrder: 100,
|
||||
experimental: true,
|
||||
versionAdded: '1.27.1'
|
||||
},
|
||||
{
|
||||
id: 'Comfy.VueNodes.AutoScaleLayout',
|
||||
name: 'Auto-scale layout (Vue nodes)',
|
||||
category: ['Comfy', 'Nodes 2.0', 'AutoScaleLayout'],
|
||||
name: 'Auto-scale layout (Nodes 2.0)',
|
||||
tooltip:
|
||||
'Automatically scale node positions when switching to Vue rendering to prevent overlap',
|
||||
type: 'boolean',
|
||||
sortOrder: 50,
|
||||
experimental: true,
|
||||
defaultValue: true,
|
||||
versionAdded: '1.30.3'
|
||||
|
||||
@@ -38,8 +38,9 @@ function onChange(
|
||||
}
|
||||
// Backward compatibility with old settings dialog.
|
||||
// Some extensions still listens event emitted by the old settings dialog.
|
||||
// @ts-expect-error 'setting' is possibly 'undefined'.ts(18048)
|
||||
app.ui.settings.dispatchChange(setting.id, newValue, oldValue)
|
||||
if (setting) {
|
||||
app.ui.settings.dispatchChange(setting.id, newValue, oldValue)
|
||||
}
|
||||
}
|
||||
|
||||
export const useSettingStore = defineStore('setting', () => {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<SlotConnectionDot
|
||||
ref="connectionDotRef"
|
||||
:color="slotColor"
|
||||
:class="cn('-translate-x-1/2', 'w-3', errorClassesDot)"
|
||||
:class="cn('-translate-x-1/2 w-3', errorClassesDot)"
|
||||
@pointerdown="onPointerDown"
|
||||
/>
|
||||
|
||||
@@ -48,6 +48,7 @@ interface InputSlotProps {
|
||||
connected?: boolean
|
||||
compatible?: boolean
|
||||
dotOnly?: boolean
|
||||
socketless?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<InputSlotProps>()
|
||||
@@ -121,7 +122,8 @@ const slotWrapperClass = computed(() =>
|
||||
'lg-slot--connected': props.connected,
|
||||
'lg-slot--compatible': props.compatible,
|
||||
'opacity-40': shouldDim.value
|
||||
}
|
||||
},
|
||||
props.socketless && 'pointer-events-none invisible'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -154,7 +154,6 @@ import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { useCanvasInteractions } from '@/renderer/core/canvas/useCanvasInteractions'
|
||||
import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
|
||||
import { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
|
||||
import SlotConnectionDot from '@/renderer/extensions/vueNodes/components/SlotConnectionDot.vue'
|
||||
import { useNodeEventHandlers } from '@/renderer/extensions/vueNodes/composables/useNodeEventHandlers'
|
||||
import { useNodePointerInteractions } from '@/renderer/extensions/vueNodes/composables/useNodePointerInteractions'
|
||||
@@ -201,13 +200,6 @@ const { bringNodeToFront } = useNodeZIndex()
|
||||
|
||||
useVueElementTracking(() => nodeData.id, 'node')
|
||||
|
||||
const transformState = useTransformState()
|
||||
if (!transformState) {
|
||||
throw new Error(
|
||||
'TransformState must be provided for node resize functionality'
|
||||
)
|
||||
}
|
||||
|
||||
const { selectedNodeIds } = storeToRefs(useCanvasStore())
|
||||
const isSelected = computed(() => {
|
||||
return selectedNodeIds.value.has(nodeData.id)
|
||||
@@ -364,29 +356,24 @@ const cornerResizeHandles: CornerResizeHandle[] = [
|
||||
|
||||
const MIN_NODE_WIDTH = 225
|
||||
|
||||
const { startResize } = useNodeResize(
|
||||
(result, element) => {
|
||||
if (isCollapsed.value) return
|
||||
const { startResize } = useNodeResize((result, element) => {
|
||||
if (isCollapsed.value) return
|
||||
|
||||
// Clamp width to minimum to avoid conflicts with CSS min-width
|
||||
const clampedWidth = Math.max(result.size.width, MIN_NODE_WIDTH)
|
||||
// Clamp width to minimum to avoid conflicts with CSS min-width
|
||||
const clampedWidth = Math.max(result.size.width, MIN_NODE_WIDTH)
|
||||
|
||||
// Apply size directly to DOM element - ResizeObserver will pick this up
|
||||
element.style.setProperty('--node-width', `${clampedWidth}px`)
|
||||
element.style.setProperty('--node-height', `${result.size.height}px`)
|
||||
// Apply size directly to DOM element - ResizeObserver will pick this up
|
||||
element.style.setProperty('--node-width', `${clampedWidth}px`)
|
||||
element.style.setProperty('--node-height', `${result.size.height}px`)
|
||||
|
||||
const currentPosition = position.value
|
||||
const deltaX = Math.abs(result.position.x - currentPosition.x)
|
||||
const deltaY = Math.abs(result.position.y - currentPosition.y)
|
||||
const currentPosition = position.value
|
||||
const deltaX = Math.abs(result.position.x - currentPosition.x)
|
||||
const deltaY = Math.abs(result.position.y - currentPosition.y)
|
||||
|
||||
if (deltaX > POSITION_EPSILON || deltaY > POSITION_EPSILON) {
|
||||
moveNodeTo(result.position)
|
||||
}
|
||||
},
|
||||
{
|
||||
transformState
|
||||
if (deltaX > POSITION_EPSILON || deltaY > POSITION_EPSILON) {
|
||||
moveNodeTo(result.position)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const handleResizePointerDown = (direction: ResizeHandleDirection) => {
|
||||
return (event: PointerEvent) => {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
v-else
|
||||
:class="
|
||||
cn(
|
||||
'lg-node-widgets flex flex-col has-[.widget-expands]:flex-1 gap-1 pr-3',
|
||||
'lg-node-widgets grid grid-cols-[min-content_minmax(80px,max-content)_minmax(125px,auto)] has-[.widget-expands]:flex-1 gap-1 pr-3',
|
||||
shouldHandleNodePointerEvents
|
||||
? 'pointer-events-auto'
|
||||
: 'pointer-events-none'
|
||||
@@ -19,7 +19,7 @@
|
||||
<div
|
||||
v-for="(widget, index) in processedWidgets"
|
||||
:key="`widget-${index}-${widget.name}`"
|
||||
class="lg-node-widget group flex items-stretch has-[.widget-expands]:flex-1"
|
||||
class="lg-node-widget group col-span-full grid grid-cols-subgrid items-stretch has-[.widget-expands]:flex-1"
|
||||
>
|
||||
<!-- Widget Input Slot Dot -->
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
}"
|
||||
:node-id="nodeData?.id != null ? String(nodeData.id) : ''"
|
||||
:index="widget.slotMetadata.index"
|
||||
:socketless="widget.simplified.spec?.socketless"
|
||||
dot-only
|
||||
/>
|
||||
</div>
|
||||
@@ -51,7 +52,7 @@
|
||||
:model-value="widget.value"
|
||||
:node-id="nodeData?.id != null ? String(nodeData.id) : ''"
|
||||
:node-type="nodeType"
|
||||
class="flex-1"
|
||||
class="flex-1 col-span-2"
|
||||
@update:model-value="widget.updateHandler"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -7,12 +7,7 @@ import { useShiftKeySync } from '@/renderer/extensions/vueNodes/composables/useS
|
||||
|
||||
import type { ResizeHandleDirection } from './resizeMath'
|
||||
import { createResizeSession, toCanvasDelta } from './resizeMath'
|
||||
import type { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
|
||||
|
||||
interface UseNodeResizeOptions {
|
||||
/** Transform state for coordinate conversion */
|
||||
transformState: ReturnType<typeof useTransformState>
|
||||
}
|
||||
import { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
|
||||
|
||||
interface ResizeCallbackPayload {
|
||||
size: Size
|
||||
@@ -26,13 +21,9 @@ interface ResizeCallbackPayload {
|
||||
* Handles pointer capture, coordinate calculations, and size constraints.
|
||||
*/
|
||||
export function useNodeResize(
|
||||
resizeCallback: (
|
||||
payload: ResizeCallbackPayload,
|
||||
element: HTMLElement
|
||||
) => void,
|
||||
options: UseNodeResizeOptions
|
||||
resizeCallback: (payload: ResizeCallbackPayload, element: HTMLElement) => void
|
||||
) {
|
||||
const { transformState } = options
|
||||
const transformState = useTransformState()
|
||||
|
||||
const isResizing = ref(false)
|
||||
const resizeStartPointer = ref<Point | null>(null)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
|
||||
import type { LGraph, rendererType } from '@/lib/litegraph/src/LGraph'
|
||||
import type { LGraph, RendererType } from '@/lib/litegraph/src/LGraph'
|
||||
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
|
||||
import { createBounds } from '@/lib/litegraph/src/measure'
|
||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||
@@ -13,135 +13,108 @@ import type { SubgraphOutputNode } from '@/lib/litegraph/src/subgraph/SubgraphOu
|
||||
const SCALE_FACTOR = 1.2
|
||||
|
||||
export function ensureCorrectLayoutScale(
|
||||
renderer?: rendererType,
|
||||
renderer: RendererType = 'LG',
|
||||
targetGraph?: LGraph
|
||||
) {
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
const autoScaleLayoutSetting = settingStore.get(
|
||||
const autoScaleLayoutSetting = useSettingStore().get(
|
||||
'Comfy.VueNodes.AutoScaleLayout'
|
||||
)
|
||||
|
||||
if (autoScaleLayoutSetting === false) {
|
||||
return
|
||||
}
|
||||
|
||||
const { shouldRenderVueNodes } = useVueFeatureFlags()
|
||||
if (!autoScaleLayoutSetting) return
|
||||
|
||||
const canvas = comfyApp.canvas
|
||||
const graph = targetGraph ?? canvas?.graph
|
||||
|
||||
if (!graph || !graph.nodes) return
|
||||
if (!graph?.nodes) return
|
||||
|
||||
// Use renderer from graph, default to 'LG' for the check (but don't modify graph yet)
|
||||
if (!renderer) {
|
||||
// Always assume legacy LG format when unknown (pre-dates this feature)
|
||||
renderer = 'LG'
|
||||
}
|
||||
const { shouldRenderVueNodes } = useVueFeatureFlags()
|
||||
|
||||
const doesntNeedScale =
|
||||
(renderer === 'LG' && shouldRenderVueNodes.value === false) ||
|
||||
(renderer === 'Vue' && shouldRenderVueNodes.value === true)
|
||||
const needsUpscale = renderer === 'LG' && shouldRenderVueNodes.value
|
||||
const needsDownscale = renderer === 'Vue' && !shouldRenderVueNodes.value
|
||||
|
||||
if (doesntNeedScale) {
|
||||
if (!needsUpscale && !needsDownscale) {
|
||||
// Don't scale, but ensure workflowRendererVersion is set for future checks
|
||||
if (!graph.extra.workflowRendererVersion) {
|
||||
graph.extra.workflowRendererVersion = renderer
|
||||
}
|
||||
graph.extra.workflowRendererVersion ??= renderer
|
||||
return
|
||||
}
|
||||
|
||||
const needsUpscale = renderer === 'LG' && shouldRenderVueNodes.value === true
|
||||
const needsDownscale =
|
||||
renderer === 'Vue' && shouldRenderVueNodes.value === false
|
||||
|
||||
const lgBounds = createBounds(graph.nodes)
|
||||
|
||||
if (!lgBounds) return
|
||||
|
||||
const originX = lgBounds[0]
|
||||
const originY = lgBounds[1]
|
||||
const [originX, originY] = lgBounds
|
||||
|
||||
const lgNodesById = new Map(graph.nodes.map((node) => [node.id, node]))
|
||||
|
||||
const yjsMoveNodeUpdates: NodeBoundsUpdate[] = []
|
||||
|
||||
const scaleFactor = needsUpscale
|
||||
? SCALE_FACTOR
|
||||
: needsDownscale
|
||||
? 1 / SCALE_FACTOR
|
||||
: 1
|
||||
const scaleFactor = needsUpscale ? SCALE_FACTOR : 1 / SCALE_FACTOR
|
||||
|
||||
const onActiveGraph = !targetGraph || targetGraph === canvas?.graph
|
||||
|
||||
//TODO: once we remove the need for LiteGraph.NODE_TITLE_HEIGHT in vue nodes we nned to remove everything here.
|
||||
for (const node of graph.nodes) {
|
||||
const lgNode = lgNodesById.get(node.id)
|
||||
if (!lgNode) continue
|
||||
|
||||
const lgBodyY = lgNode.pos[1]
|
||||
const [oldX, oldY] = lgNode.pos
|
||||
|
||||
const adjustedY = needsDownscale
|
||||
? lgBodyY - LiteGraph.NODE_TITLE_HEIGHT / 2
|
||||
: lgBodyY
|
||||
const adjustedY = oldY - (needsUpscale ? LiteGraph.NODE_TITLE_HEIGHT : 0)
|
||||
|
||||
const relativeX = lgNode.pos[0] - originX
|
||||
const relativeX = oldX - originX
|
||||
const relativeY = adjustedY - originY
|
||||
const newX = originX + relativeX * scaleFactor
|
||||
const scaledY = originY + relativeY * scaleFactor
|
||||
const newWidth = lgNode.width * scaleFactor
|
||||
const newHeight = lgNode.height * scaleFactor
|
||||
|
||||
const finalY = needsUpscale
|
||||
? scaledY + LiteGraph.NODE_TITLE_HEIGHT / 2
|
||||
: scaledY
|
||||
const scaledX = originX + relativeX * scaleFactor
|
||||
const scaledY = originY + relativeY * scaleFactor
|
||||
|
||||
const scaledWidth = lgNode.width * scaleFactor
|
||||
const scaledHeight =
|
||||
lgNode.height * scaleFactor -
|
||||
(needsUpscale ? 0 : LiteGraph.NODE_TITLE_HEIGHT)
|
||||
|
||||
const finalY = scaledY + (needsUpscale ? 0 : LiteGraph.NODE_TITLE_HEIGHT) // Litegraph Position further down
|
||||
|
||||
// Directly update LiteGraph node to ensure immediate consistency
|
||||
// Dont need to reference vue directly because the pos and dims are already in yjs
|
||||
lgNode.pos[0] = newX
|
||||
lgNode.pos[0] = scaledX
|
||||
lgNode.pos[1] = finalY
|
||||
lgNode.size[0] = newWidth
|
||||
lgNode.size[1] =
|
||||
newHeight - (needsDownscale ? LiteGraph.NODE_TITLE_HEIGHT : 0)
|
||||
lgNode.size[0] = scaledWidth
|
||||
lgNode.size[1] = scaledHeight
|
||||
|
||||
// Track updates for layout store (only if this is the active graph)
|
||||
if (!targetGraph || targetGraph === canvas?.graph) {
|
||||
if (onActiveGraph) {
|
||||
yjsMoveNodeUpdates.push({
|
||||
nodeId: String(lgNode.id),
|
||||
bounds: {
|
||||
x: newX,
|
||||
x: scaledX,
|
||||
y: finalY,
|
||||
width: newWidth,
|
||||
height: newHeight - (needsDownscale ? LiteGraph.NODE_TITLE_HEIGHT : 0)
|
||||
width: scaledWidth,
|
||||
height: scaledHeight
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(!targetGraph || targetGraph === canvas?.graph) &&
|
||||
yjsMoveNodeUpdates.length > 0
|
||||
) {
|
||||
if (onActiveGraph && yjsMoveNodeUpdates.length > 0) {
|
||||
layoutStore.batchUpdateNodeBounds(yjsMoveNodeUpdates)
|
||||
}
|
||||
|
||||
for (const reroute of graph.reroutes.values()) {
|
||||
const oldX = reroute.pos[0]
|
||||
const oldY = reroute.pos[1]
|
||||
const [oldX, oldY] = reroute.pos
|
||||
|
||||
const relativeX = oldX - originX
|
||||
const relativeY = oldY - originY
|
||||
const newX = originX + relativeX * scaleFactor
|
||||
const newY = originY + relativeY * scaleFactor
|
||||
|
||||
reroute.pos = [newX, newY]
|
||||
const scaledX = originX + relativeX * scaleFactor
|
||||
const scaledY = originY + relativeY * scaleFactor
|
||||
|
||||
if (
|
||||
(!targetGraph || targetGraph === canvas?.graph) &&
|
||||
shouldRenderVueNodes.value
|
||||
) {
|
||||
reroute.pos = [scaledX, scaledY]
|
||||
|
||||
if (onActiveGraph && shouldRenderVueNodes.value) {
|
||||
const layoutMutations = useLayoutMutations()
|
||||
layoutMutations.moveReroute(
|
||||
reroute.id,
|
||||
{ x: newX, y: newY },
|
||||
{ x: scaledX, y: scaledY },
|
||||
{ x: oldX, y: oldY }
|
||||
)
|
||||
}
|
||||
@@ -153,60 +126,48 @@ export function ensureCorrectLayoutScale(
|
||||
graph.outputNode as SubgraphOutputNode
|
||||
]
|
||||
for (const ioNode of ioNodes) {
|
||||
const oldX = ioNode.pos[0]
|
||||
const oldY = ioNode.pos[1]
|
||||
const oldWidth = ioNode.size[0]
|
||||
const oldHeight = ioNode.size[1]
|
||||
const [oldX, oldY] = ioNode.pos
|
||||
const [oldWidth, oldHeight] = ioNode.size
|
||||
|
||||
const relativeX = oldX - originX
|
||||
const relativeY = oldY - originY
|
||||
const newX = originX + relativeX * scaleFactor
|
||||
const newY = originY + relativeY * scaleFactor
|
||||
const newWidth = oldWidth * scaleFactor
|
||||
const newHeight = oldHeight * scaleFactor
|
||||
|
||||
ioNode.pos = [newX, newY]
|
||||
ioNode.size = [newWidth, newHeight]
|
||||
const scaledX = originX + relativeX * scaleFactor
|
||||
const scaledY = originY + relativeY * scaleFactor
|
||||
|
||||
const scaledWidth = oldWidth * scaleFactor
|
||||
const scaledHeight = oldHeight * scaleFactor
|
||||
|
||||
ioNode.pos = [scaledX, scaledY]
|
||||
ioNode.size = [scaledWidth, scaledHeight]
|
||||
}
|
||||
}
|
||||
|
||||
graph.groups.forEach((group) => {
|
||||
const originalPosX = group.pos[0]
|
||||
const originalPosY = group.pos[1]
|
||||
const originalWidth = group.size[0]
|
||||
const originalHeight = group.size[1]
|
||||
const [oldX, oldY] = group.pos
|
||||
const [oldWidth, oldHeight] = group.size
|
||||
|
||||
const adjustedY = needsDownscale
|
||||
? originalPosY - LiteGraph.NODE_TITLE_HEIGHT
|
||||
: originalPosY
|
||||
const adjustedY = oldY - (needsUpscale ? LiteGraph.NODE_TITLE_HEIGHT : 0)
|
||||
|
||||
const relativeX = originalPosX - originX
|
||||
const relativeX = oldX - originX
|
||||
const relativeY = adjustedY - originY
|
||||
|
||||
const newWidth = originalWidth * scaleFactor
|
||||
const newHeight = originalHeight * scaleFactor
|
||||
|
||||
const scaledX = originX + relativeX * scaleFactor
|
||||
const scaledY = originY + relativeY * scaleFactor
|
||||
|
||||
const finalY = needsUpscale
|
||||
? scaledY + LiteGraph.NODE_TITLE_HEIGHT
|
||||
: scaledY
|
||||
const scaledWidth = oldWidth * scaleFactor
|
||||
const scaledHeight = oldHeight * scaleFactor
|
||||
|
||||
const finalY = scaledY + (needsUpscale ? 0 : LiteGraph.NODE_TITLE_HEIGHT)
|
||||
|
||||
group.pos = [scaledX, finalY]
|
||||
group.size = [newWidth, newHeight]
|
||||
group.size = [scaledWidth, scaledHeight]
|
||||
})
|
||||
|
||||
if ((!targetGraph || targetGraph === canvas?.graph) && canvas) {
|
||||
if (onActiveGraph && canvas) {
|
||||
const originScreen = canvas.ds.convertOffsetToCanvas([originX, originY])
|
||||
canvas.ds.changeScale(canvas.ds.scale / scaleFactor, originScreen)
|
||||
}
|
||||
|
||||
if (needsUpscale) {
|
||||
graph.extra.workflowRendererVersion = 'Vue'
|
||||
}
|
||||
|
||||
if (needsDownscale) {
|
||||
graph.extra.workflowRendererVersion = 'LG'
|
||||
}
|
||||
graph.extra.workflowRendererVersion = needsUpscale ? 'Vue' : 'LG'
|
||||
}
|
||||
|
||||
@@ -82,21 +82,11 @@ describe('WidgetButton Interactions', () => {
|
||||
expect(button.exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('renders widget label when name is provided', () => {
|
||||
it('renders widget text when name is provided', () => {
|
||||
const widget = createMockWidget()
|
||||
const wrapper = mountComponent(widget)
|
||||
|
||||
const label = wrapper.find('label')
|
||||
expect(label.exists()).toBe(true)
|
||||
expect(label.text()).toBe('test_button')
|
||||
})
|
||||
|
||||
it('does not render label when widget name is empty', () => {
|
||||
const widget = createMockWidget({}, undefined, '')
|
||||
const wrapper = mountComponent(widget)
|
||||
|
||||
const label = wrapper.find('label')
|
||||
expect(label.exists()).toBe(false)
|
||||
expect(wrapper.text()).toBe('test_button')
|
||||
})
|
||||
|
||||
it('sets button size to small', () => {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-1">
|
||||
<label v-if="widget.name" class="text-secondary text-sm">{{
|
||||
widget.name
|
||||
}}</label>
|
||||
<Button
|
||||
v-bind="filteredProps"
|
||||
:aria-label="widget.name || widget.label"
|
||||
size="small"
|
||||
@click="handleClick"
|
||||
/>
|
||||
>
|
||||
<template v-if="widget.name">
|
||||
{{ widget.name }}
|
||||
</template>
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ const outputItems = computed<DropdownItem[]>(() => {
|
||||
})
|
||||
})
|
||||
|
||||
return Array.from(outputs).map((output, index) => ({
|
||||
id: `output-${index}`,
|
||||
return Array.from(outputs).map((output) => ({
|
||||
id: `output-${output}`,
|
||||
mediaSrc: getMediaUrl(output.replace(' [output]', ''), 'output'),
|
||||
name: output,
|
||||
label: getDisplayLabel(output),
|
||||
@@ -215,16 +215,14 @@ const layoutMode = ref<LayoutMode>(props.defaultLayoutMode ?? 'grid')
|
||||
watch(
|
||||
modelValue,
|
||||
(currentValue) => {
|
||||
if (currentValue !== undefined) {
|
||||
const item = dropdownItems.value.find(
|
||||
(item) => item.name === currentValue
|
||||
)
|
||||
if (item) {
|
||||
selectedSet.value.clear()
|
||||
selectedSet.value.add(item.id)
|
||||
}
|
||||
} else {
|
||||
if (currentValue === undefined) {
|
||||
selectedSet.value.clear()
|
||||
return
|
||||
}
|
||||
const item = dropdownItems.value.find((item) => item.name === currentValue)
|
||||
if (item) {
|
||||
selectedSet.value.clear()
|
||||
selectedSet.value.add(item.id)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
fluid
|
||||
data-capture-wheel="true"
|
||||
@pointerdown.capture.stop
|
||||
@pointermove.capture.stop
|
||||
@pointerup.capture.stop
|
||||
@contextmenu.capture.stop
|
||||
/>
|
||||
<LODFallback />
|
||||
</div>
|
||||
|
||||
@@ -32,24 +32,13 @@ const selectedItems = computed(() => {
|
||||
return props.items.filter((item) => props.selected.has(item.id))
|
||||
})
|
||||
|
||||
const chevronClass = computed(() =>
|
||||
cn(
|
||||
'mr-2 size-4 transition-transform duration-200 flex-shrink-0 text-component-node-foreground-secondary',
|
||||
{
|
||||
'rotate-180': props.isOpen
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
const theButtonStyle = computed(() =>
|
||||
cn(
|
||||
'border-0 bg-component-node-widget-background outline-none text-text-secondary',
|
||||
{
|
||||
'hover:bg-component-node-widget-background-hovered cursor-pointer':
|
||||
!props.disabled,
|
||||
'cursor-not-allowed': props.disabled,
|
||||
'text-text-primary': selectedItems.value.length > 0
|
||||
}
|
||||
props.disabled
|
||||
? 'cursor-not-allowed'
|
||||
: 'hover:bg-component-node-widget-background-hovered cursor-pointer',
|
||||
selectedItems.value.length > 0 && 'text-text-primary'
|
||||
)
|
||||
)
|
||||
</script>
|
||||
@@ -78,13 +67,21 @@ const theButtonStyle = computed(() =>
|
||||
>
|
||||
<span class="min-w-0 flex-1 px-1 py-2 text-left truncate">
|
||||
<span v-if="!selectedItems.length">
|
||||
{{ props.placeholder }}
|
||||
{{ placeholder }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ selectedItems.map((item) => item.label ?? item.name).join(', ') }}
|
||||
</span>
|
||||
</span>
|
||||
<i class="icon-[lucide--chevron-down]" :class="chevronClass" />
|
||||
<i
|
||||
class="icon-[lucide--chevron-down]"
|
||||
:class="
|
||||
cn(
|
||||
'mr-2 size-4 transition-transform duration-200 flex-shrink-0 text-component-node-foreground-secondary',
|
||||
isOpen && 'rotate-180'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</button>
|
||||
<!-- Open File -->
|
||||
<label
|
||||
|
||||
@@ -11,8 +11,10 @@ defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-[30px] min-w-0 items-center justify-between gap-1">
|
||||
<div class="relative flex h-full min-w-0 w-20 items-center">
|
||||
<div
|
||||
class="grid grid-cols-subgrid h-7.5 min-w-0 items-center justify-between gap-1"
|
||||
>
|
||||
<div class="relative flex h-full min-w-0 items-center">
|
||||
<p
|
||||
v-if="widget.name"
|
||||
class="lod-toggle flex-1 truncate text-xs font-normal text-node-component-slot-text"
|
||||
|
||||
@@ -236,9 +236,7 @@ export function useRemoteWidget<
|
||||
* Add a refresh button to the node that, when clicked, will force the widget to refresh
|
||||
*/
|
||||
function addRefreshButton() {
|
||||
node.addWidget('button', 'refresh', 'refresh', widget.refresh, {
|
||||
canvasOnly: true
|
||||
})
|
||||
node.addWidget('button', 'refresh', 'refresh', widget.refresh)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,8 +261,7 @@ export function useRemoteWidget<
|
||||
autoRefreshEnabled = value
|
||||
},
|
||||
{
|
||||
serialize: false,
|
||||
canvasOnly: true
|
||||
serialize: false
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ export const zBaseInputOptions = z
|
||||
defaultInput: z.boolean().optional(),
|
||||
forceInput: z.boolean().optional(),
|
||||
tooltip: z.string().optional(),
|
||||
socketless: z.boolean().optional(),
|
||||
hidden: z.boolean().optional(),
|
||||
advanced: z.boolean().optional(),
|
||||
widgetType: z.string().optional(),
|
||||
|
||||
@@ -59,6 +59,7 @@ import {
|
||||
import { getOrderedInputSpecs } from '@/workbench/utils/nodeDefOrderingUtil'
|
||||
|
||||
import { useExtensionService } from './extensionService'
|
||||
import { useMaskEditor } from '@/composables/maskeditor/useMaskEditor'
|
||||
|
||||
export interface HasInitialMinSize {
|
||||
_initialMinSize: { width: number; height: number }
|
||||
@@ -638,11 +639,7 @@ export const useLitegraphService = () => {
|
||||
options.push({
|
||||
content: 'Open in MaskEditor | Image Canvas',
|
||||
callback: () => {
|
||||
ComfyApp.copyToClipspace(this)
|
||||
// @ts-expect-error fixme ts strict error
|
||||
ComfyApp.clipspace_return_node = this
|
||||
// @ts-expect-error fixme ts strict error
|
||||
ComfyApp.open_maskeditor()
|
||||
useMaskEditor().openMaskEditor(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,9 +79,22 @@ export class NodeSearchService {
|
||||
const results = matchedNodes.filter((node) => {
|
||||
return filters.every((filterAndValue) => {
|
||||
const { filterDef, value } = filterAndValue
|
||||
return filterDef.matches(node, value, { wildcard })
|
||||
return filterDef.matches(node, value)
|
||||
})
|
||||
})
|
||||
if (matchWildcards) {
|
||||
const alreadyValid = new Set(results.map((result) => result.name))
|
||||
results.push(
|
||||
...matchedNodes
|
||||
.filter((node) => !alreadyValid.has(node.name))
|
||||
.filter((node) => {
|
||||
return filters.every((filterAndValue) => {
|
||||
const { filterDef, value } = filterAndValue
|
||||
return filterDef.matches(node, value, { wildcard })
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return options?.limit ? results.slice(0, options.limit) : results
|
||||
}
|
||||
|
||||
@@ -24,7 +24,12 @@ export const useApiKeyAuthStore = defineStore('apiKeyAuth', () => {
|
||||
const isAuthenticated = computed(() => !!currentUser.value)
|
||||
|
||||
const initializeUserFromApiKey = async () => {
|
||||
const createCustomerResponse = await firebaseAuthStore.createCustomer()
|
||||
const createCustomerResponse = await firebaseAuthStore
|
||||
.createCustomer()
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
return
|
||||
})
|
||||
if (!createCustomerResponse) {
|
||||
apiKey.value = null
|
||||
throw new Error(t('auth.login.noAssociatedUser'))
|
||||
|
||||
@@ -22,7 +22,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
size: 10,
|
||||
opacity: 0.7,
|
||||
hardness: 1,
|
||||
smoothingPrecision: 10
|
||||
stepSize: 10
|
||||
})
|
||||
|
||||
const maskBlendMode = ref<MaskBlendMode>(MaskBlendMode.Black)
|
||||
@@ -50,6 +50,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
const panOffset = ref<Offset>({ x: 0, y: 0 })
|
||||
const cursorPoint = ref<Point>({ x: 0, y: 0 })
|
||||
const resetZoomTrigger = ref<number>(0)
|
||||
const clearTrigger = ref<number>(0)
|
||||
|
||||
const maskCanvas = ref<HTMLCanvasElement | null>(null)
|
||||
const maskCtx = ref<CanvasRenderingContext2D | null>(null)
|
||||
@@ -70,6 +71,8 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
|
||||
const canvasHistory = useCanvasHistory(20)
|
||||
|
||||
const tgpuRoot = ref<any>(null)
|
||||
|
||||
watch(maskCanvas, (canvas) => {
|
||||
if (canvas) {
|
||||
maskCtx.value = canvas.getContext('2d', { willReadFrequently: true })
|
||||
@@ -110,7 +113,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
})
|
||||
|
||||
function setBrushSize(size: number): void {
|
||||
brushSettings.value.size = _.clamp(size, 1, 100)
|
||||
brushSettings.value.size = _.clamp(size, 1, 500)
|
||||
}
|
||||
|
||||
function setBrushOpacity(opacity: number): void {
|
||||
@@ -121,8 +124,8 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
brushSettings.value.hardness = _.clamp(hardness, 0, 1)
|
||||
}
|
||||
|
||||
function setBrushSmoothingPrecision(precision: number): void {
|
||||
brushSettings.value.smoothingPrecision = _.clamp(precision, 1, 100)
|
||||
function setBrushStepSize(step: number): void {
|
||||
brushSettings.value.stepSize = _.clamp(step, 1, 100)
|
||||
}
|
||||
|
||||
function resetBrushToDefault(): void {
|
||||
@@ -130,7 +133,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
brushSettings.value.size = 20
|
||||
brushSettings.value.opacity = 1
|
||||
brushSettings.value.hardness = 1
|
||||
brushSettings.value.smoothingPrecision = 60
|
||||
brushSettings.value.stepSize = 5
|
||||
}
|
||||
|
||||
function setPaintBucketTolerance(tolerance: number): void {
|
||||
@@ -169,6 +172,10 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
resetZoomTrigger.value++
|
||||
}
|
||||
|
||||
function triggerClear(): void {
|
||||
clearTrigger.value++
|
||||
}
|
||||
|
||||
function setMaskOpacity(opacity: number): void {
|
||||
maskOpacity.value = _.clamp(opacity, 0, 1)
|
||||
}
|
||||
@@ -179,7 +186,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
size: 10,
|
||||
opacity: 0.7,
|
||||
hardness: 1,
|
||||
smoothingPrecision: 10
|
||||
stepSize: 5
|
||||
}
|
||||
maskBlendMode.value = MaskBlendMode.Black
|
||||
activeLayer.value = 'mask'
|
||||
@@ -243,10 +250,12 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
|
||||
canvasHistory,
|
||||
|
||||
tgpuRoot,
|
||||
|
||||
setBrushSize,
|
||||
setBrushOpacity,
|
||||
setBrushHardness,
|
||||
setBrushSmoothingPrecision,
|
||||
setBrushStepSize,
|
||||
resetBrushToDefault,
|
||||
setPaintBucketTolerance,
|
||||
setFillOpacity,
|
||||
@@ -257,6 +266,8 @@ export const useMaskEditorStore = defineStore('maskEditor', () => {
|
||||
setPanOffset,
|
||||
setCursorPoint,
|
||||
resetZoom,
|
||||
triggerClear,
|
||||
clearTrigger,
|
||||
setMaskOpacity,
|
||||
resetState
|
||||
}
|
||||
|
||||
@@ -62,10 +62,9 @@ export class FuseFilter<T, O = string> {
|
||||
return true
|
||||
}
|
||||
const options = this.getItemOptions(item)
|
||||
return (
|
||||
options.includes(value) ||
|
||||
(!!wildcard && options.some((option) => option === wildcard))
|
||||
)
|
||||
return wildcard
|
||||
? options.some((option) => option === wildcard)
|
||||
: options.includes(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ type JobDisplay = {
|
||||
export const iconForJobState = (state: JobState): string => {
|
||||
switch (state) {
|
||||
case 'pending':
|
||||
return 'icon-[lucide--clock]'
|
||||
return 'icon-[lucide--loader-circle]'
|
||||
case 'initialization':
|
||||
return 'icon-[lucide--server-crash]'
|
||||
case 'running':
|
||||
|
||||
@@ -5,6 +5,7 @@ import Splitter from 'primevue/splitter'
|
||||
import SplitterPanel from 'primevue/splitterpanel'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import ExtensionSlot from '@/components/common/ExtensionSlot.vue'
|
||||
import CurrentUserButton from '@/components/topbar/CurrentUserButton.vue'
|
||||
import LoginButton from '@/components/topbar/LoginButton.vue'
|
||||
import TopbarBadges from '@/components/topbar/TopbarBadges.vue'
|
||||
@@ -14,20 +15,20 @@ import {
|
||||
isValidWidgetValue,
|
||||
safeWidgetMapper
|
||||
} from '@/composables/graph/useGraphNodeManager'
|
||||
import { useAssetsSidebarTab } from '@/composables/sidebarTabs/useAssetsSidebarTab'
|
||||
import { t } from '@/i18n'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import NodeWidgets from '@/renderer/extensions/vueNodes/components/NodeWidgets.vue'
|
||||
import WidgetInputNumberInput from '@/renderer/extensions/vueNodes/widgets/components/WidgetInputNumber.vue'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useCommandStore } from '@/stores/commandStore'
|
||||
import { useNodeOutputStore } from '@/stores/imagePreviewStore'
|
||||
//import { useQueueStore } from '@/stores/queueStore'
|
||||
import { useQueueSettingsStore } from '@/stores/queueStore'
|
||||
import { isElectron } from '@/utils/envUtil'
|
||||
|
||||
//const queueStore = useQueueStore()
|
||||
const nodeOutputStore = useNodeOutputStore()
|
||||
const commandStore = useCommandStore()
|
||||
const nodeDatas = computed(() => {
|
||||
@@ -114,9 +115,16 @@ function openFeedback() {
|
||||
class="h-[calc(100%-38px)] w-full bg-comfy-menu-secondary-bg"
|
||||
:pt="{ gutter: { class: 'bg-transparent w-4 -mx-3' } }"
|
||||
>
|
||||
<SplitterPanel :size="1" class="min-w-min bg-comfy-menu-bg">
|
||||
<div
|
||||
class="sidebar-content-container h-full w-full overflow-x-hidden overflow-y-auto border-r-1 border-node-component-border"
|
||||
>
|
||||
<ExtensionSlot :extension="useAssetsSidebarTab()" />
|
||||
</div>
|
||||
</SplitterPanel>
|
||||
<SplitterPanel
|
||||
:size="99"
|
||||
class="flex flex-row overflow-y-auto flex-wrap min-w-min gap-4"
|
||||
:size="98"
|
||||
class="flex flex-row overflow-y-auto flex-wrap min-w-min gap-4 m-4"
|
||||
>
|
||||
<img
|
||||
v-for="previewUrl in nodeOutputStore.latestOutput"
|
||||
@@ -132,18 +140,26 @@ function openFeedback() {
|
||||
</SplitterPanel>
|
||||
<SplitterPanel :size="1" class="flex flex-col gap-1 p-1 min-w-min">
|
||||
<div
|
||||
class="actionbar-container flex h-12 items-center rounded-lg border border-[var(--interface-stroke)] p-2 gap-2 bg-comfy-menu-bg justify-center"
|
||||
class="actionbar-container flex h-12 items-center rounded-lg border border-[var(--interface-stroke)] p-2 gap-2 bg-comfy-menu-bg justify-end"
|
||||
>
|
||||
<Button label="Feedback" severity="secondary" @click="openFeedback" />
|
||||
<Button
|
||||
label="Open Workflow"
|
||||
:label="t('g.feedback')"
|
||||
severity="secondary"
|
||||
@click="openFeedback"
|
||||
/>
|
||||
<Button
|
||||
:label="t('linearMode.openWorkflow')"
|
||||
severity="secondary"
|
||||
class="min-w-max"
|
||||
icon="icon-[comfy--workflow]"
|
||||
icon-pos="right"
|
||||
@click="useCanvasStore().linearMode = false"
|
||||
/>
|
||||
<!--<Button label="Share" severity="contrast" /> Temporarily disabled-->
|
||||
<Button
|
||||
:label="t('linearMode.share')"
|
||||
severity="contrast"
|
||||
@click="useWorkflowService().exportWorkflow('workflow', 'workflow')"
|
||||
/>
|
||||
<CurrentUserButton v-if="isLoggedIn" />
|
||||
<LoginButton v-else-if="isDesktop" />
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,19 @@ vi.mock('@/stores/maskEditorStore', () => ({
|
||||
useMaskEditorStore: vi.fn(() => mockStore)
|
||||
}))
|
||||
|
||||
// Mock ImageBitmap for test environment
|
||||
if (typeof globalThis.ImageBitmap === 'undefined') {
|
||||
globalThis.ImageBitmap = class ImageBitmap {
|
||||
width: number
|
||||
height: number
|
||||
constructor(width = 100, height = 100) {
|
||||
this.width = width
|
||||
this.height = height
|
||||
}
|
||||
close() {}
|
||||
} as any
|
||||
}
|
||||
|
||||
describe('useCanvasHistory', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
@@ -42,12 +55,16 @@ describe('useCanvasHistory', () => {
|
||||
|
||||
mockMaskCtx = {
|
||||
getImageData: vi.fn(() => createMockImageData()),
|
||||
putImageData: vi.fn()
|
||||
putImageData: vi.fn(),
|
||||
clearRect: vi.fn(),
|
||||
drawImage: vi.fn()
|
||||
}
|
||||
|
||||
mockRgbCtx = {
|
||||
getImageData: vi.fn(() => createMockImageData()),
|
||||
putImageData: vi.fn()
|
||||
putImageData: vi.fn(),
|
||||
clearRect: vi.fn(),
|
||||
drawImage: vi.fn()
|
||||
}
|
||||
|
||||
mockMaskCanvas = {
|
||||
|
||||
@@ -610,8 +610,7 @@ describe('useRemoteWidget', () => {
|
||||
false,
|
||||
expect.any(Function),
|
||||
{
|
||||
serialize: false,
|
||||
canvasOnly: true
|
||||
serialize: false
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||