@pairdraw/vue 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/CanvasRoot.vue.js +5 -0
- package/dist/canvas/CanvasRoot.vue.js.map +1 -1
- package/dist/canvas/auto-layout/value-edit.js +1 -1
- package/dist/canvas/auto-layout/value-edit.js.map +1 -1
- package/dist/canvas/eyedropper/index.d.ts +26 -0
- package/dist/canvas/eyedropper/index.d.ts.map +1 -0
- package/dist/canvas/eyedropper/index.js +62 -0
- package/dist/canvas/eyedropper/index.js.map +1 -0
- package/dist/canvas/eyedropper/sample.js +13 -0
- package/dist/canvas/eyedropper/sample.js.map +1 -0
- package/dist/canvas/eyedropper/use.d.ts +33 -0
- package/dist/canvas/eyedropper/use.d.ts.map +1 -0
- package/dist/canvas/eyedropper/use.js +52 -0
- package/dist/canvas/eyedropper/use.js.map +1 -0
- package/dist/canvas/pointer/drag-move.js +4 -0
- package/dist/canvas/pointer/drag-move.js.map +1 -1
- package/dist/canvas/surface/color-space.d.ts +1 -0
- package/dist/canvas/surface/color-space.d.ts.map +1 -1
- package/dist/canvas/surface/gl-surface.js +5 -1
- package/dist/canvas/surface/gl-surface.js.map +1 -1
- package/dist/canvas/surface/kit-loader.js +2 -3
- package/dist/canvas/surface/kit-loader.js.map +1 -1
- package/dist/canvas/surface/lifecycle.js +34 -3
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/origin.js +14 -0
- package/dist/canvas/surface/origin.js.map +1 -0
- package/dist/canvas/surface/shader/plan.js +40 -0
- package/dist/canvas/surface/shader/plan.js.map +1 -0
- package/dist/canvas/surface/shader/playback.js +132 -36
- package/dist/canvas/surface/shader/playback.js.map +1 -1
- package/dist/canvas/surface/shader/stage.d.ts.map +1 -1
- package/dist/canvas/surface/shader/stage.js +42 -5
- package/dist/canvas/surface/shader/stage.js.map +1 -1
- package/dist/canvas/surface/types.d.ts +25 -0
- package/dist/canvas/surface/types.d.ts.map +1 -1
- package/dist/canvas/surface/use.js +3 -1
- package/dist/canvas/surface/use.js.map +1 -1
- package/dist/canvas/text-edit/textarea.d.ts +1 -0
- package/dist/canvas/text-edit/textarea.d.ts.map +1 -1
- package/dist/canvas/tools/registry.js +5 -1
- package/dist/canvas/tools/registry.js.map +1 -1
- package/dist/canvas/useCanvasInput.d.ts +144 -2
- package/dist/canvas/useCanvasInput.d.ts.map +1 -1
- package/dist/canvas/useCanvasInput.js +3 -2
- package/dist/canvas/useCanvasInput.js.map +1 -1
- package/dist/controls/appearance/use.d.ts +1 -1
- package/dist/controls/binding-provider/pairdraw.js +1 -1
- package/dist/controls/binding-provider/pairdraw.js.map +1 -1
- package/dist/controls/color-model/types.d.ts +6 -0
- package/dist/controls/color-model/types.d.ts.map +1 -1
- package/dist/controls/color-model/use.d.ts.map +1 -1
- package/dist/controls/color-model/use.js +5 -3
- package/dist/controls/color-model/use.js.map +1 -1
- package/dist/controls/document-colors/index.d.ts +2 -0
- package/dist/controls/document-colors/index.js +2 -0
- package/dist/controls/document-colors/use.d.ts +20 -0
- package/dist/controls/document-colors/use.d.ts.map +1 -0
- package/dist/controls/document-colors/use.js +35 -0
- package/dist/controls/document-colors/use.js.map +1 -0
- package/dist/controls/effects/helpers.d.ts +13 -2
- package/dist/controls/effects/helpers.d.ts.map +1 -1
- package/dist/controls/effects/helpers.js +89 -34
- package/dist/controls/effects/helpers.js.map +1 -1
- package/dist/controls/effects/index.d.ts +2 -1
- package/dist/controls/effects/index.js +2 -1
- package/dist/controls/effects/use.d.ts +9 -7
- package/dist/controls/effects/use.d.ts.map +1 -1
- package/dist/controls/effects/use.js +6 -3
- package/dist/controls/effects/use.js.map +1 -1
- package/dist/controls/okhcl/use.d.ts +2 -2
- package/dist/controls/shader/catalog.d.ts +11 -0
- package/dist/controls/shader/catalog.d.ts.map +1 -1
- package/dist/controls/shader/catalog.js +35 -6
- package/dist/controls/shader/catalog.js.map +1 -1
- package/dist/controls/shader/gallery.d.ts +1 -1
- package/dist/controls/shader/gallery.d.ts.map +1 -1
- package/dist/controls/shader/gallery.js +292 -0
- package/dist/controls/shader/gallery.js.map +1 -1
- package/dist/controls/shader/index.d.ts +3 -1
- package/dist/controls/shader/index.js +3 -1
- package/dist/controls/shader/shapes.d.ts +18 -0
- package/dist/controls/shader/shapes.d.ts.map +1 -0
- package/dist/controls/shader/shapes.js +227 -0
- package/dist/controls/shader/shapes.js.map +1 -0
- package/dist/controls/shader/stops.d.ts +22 -0
- package/dist/controls/shader/stops.d.ts.map +1 -0
- package/dist/controls/shader/stops.js +73 -0
- package/dist/controls/shader/stops.js.map +1 -0
- package/dist/controls/typography/features.d.ts +24 -0
- package/dist/controls/typography/features.d.ts.map +1 -0
- package/dist/controls/typography/features.js +130 -0
- package/dist/controls/typography/features.js.map +1 -0
- package/dist/controls/typography/index.d.ts +2 -1
- package/dist/controls/typography/index.js +2 -1
- package/dist/controls/typography/use.d.ts +6 -0
- package/dist/controls/typography/use.d.ts.map +1 -1
- package/dist/controls/typography/use.js +4 -1
- package/dist/controls/typography/use.js.map +1 -1
- package/dist/controls/variable-modes/helpers.d.ts.map +1 -1
- package/dist/controls/variable-modes/helpers.js +4 -2
- package/dist/controls/variable-modes/helpers.js.map +1 -1
- package/dist/editor/commands/registry.d.ts +4 -0
- package/dist/editor/commands/registry.d.ts.map +1 -1
- package/dist/editor/commands/registry.js +2 -0
- package/dist/editor/commands/registry.js.map +1 -1
- package/dist/editor/commands/selection.js +22 -0
- package/dist/editor/commands/selection.js.map +1 -1
- package/dist/editor/commands/types.d.ts +1 -1
- package/dist/editor/commands/types.d.ts.map +1 -1
- package/dist/editor/menu-model/canvas.d.ts.map +1 -1
- package/dist/editor/menu-model/canvas.js +7 -1
- package/dist/editor/menu-model/canvas.js.map +1 -1
- package/dist/editor/selection-capabilities/use.d.ts +2 -0
- package/dist/editor/selection-capabilities/use.js +5 -0
- package/dist/editor/selection-capabilities/use.js.map +1 -1
- package/dist/editor/selection-state/use.d.ts +1 -0
- package/dist/editor/selection-state/use.js +5 -0
- package/dist/editor/selection-state/use.js.map +1 -1
- package/dist/editor/tool-cursor/index.d.ts.map +1 -1
- package/dist/editor/tool-cursor/index.js +5 -1
- package/dist/editor/tool-cursor/index.js.map +1 -1
- package/dist/i18n/create.d.ts +1 -1
- package/dist/i18n/create.d.ts.map +1 -1
- package/dist/i18n/create.js +1 -0
- package/dist/i18n/create.js.map +1 -1
- package/dist/i18n/index.d.ts +5 -2
- package/dist/i18n/index.js +5 -2
- package/dist/i18n/locale.d.ts +5 -4
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +4 -0
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/locales/de/ai.json.js +68 -2
- package/dist/i18n/locales/de/commands.json.js +2 -0
- package/dist/i18n/locales/de/comments.json.js +1 -1
- package/dist/i18n/locales/de/design-check.json.js +13 -1
- package/dist/i18n/locales/de/design-memory.json.js +82 -0
- package/dist/i18n/locales/de/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/de/fonts.json.js +10 -0
- package/dist/i18n/locales/de/index.js +5 -1
- package/dist/i18n/locales/de/index.js.map +1 -1
- package/dist/i18n/locales/de/menu.json.js +2 -0
- package/dist/i18n/locales/de/panels.json.js +109 -1
- package/dist/i18n/locales/de/settings.json.js +1 -0
- package/dist/i18n/locales/de/tools.json.js +3 -1
- package/dist/i18n/locales/de/variables/panel.json.js +20 -0
- package/dist/i18n/locales/de/variations.json.js +23 -0
- package/dist/i18n/locales/de/variations.json.js.map +1 -0
- package/dist/i18n/locales/es/ai.json.js +67 -1
- package/dist/i18n/locales/es/commands.json.js +2 -0
- package/dist/i18n/locales/es/comments.json.js +1 -1
- package/dist/i18n/locales/es/design-check.json.js +13 -1
- package/dist/i18n/locales/es/design-memory.json.js +82 -0
- package/dist/i18n/locales/es/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/es/fonts.json.js +10 -0
- package/dist/i18n/locales/es/index.js +5 -1
- package/dist/i18n/locales/es/index.js.map +1 -1
- package/dist/i18n/locales/es/menu.json.js +2 -0
- package/dist/i18n/locales/es/panels.json.js +109 -1
- package/dist/i18n/locales/es/settings.json.js +1 -0
- package/dist/i18n/locales/es/tools.json.js +3 -1
- package/dist/i18n/locales/es/variables/panel.json.js +20 -0
- package/dist/i18n/locales/es/variations.json.js +23 -0
- package/dist/i18n/locales/es/variations.json.js.map +1 -0
- package/dist/i18n/locales/fr/ai.json.js +68 -2
- package/dist/i18n/locales/fr/commands.json.js +2 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -1
- package/dist/i18n/locales/fr/design-check.json.js +13 -1
- package/dist/i18n/locales/fr/design-memory.json.js +82 -0
- package/dist/i18n/locales/fr/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/fr/fonts.json.js +10 -0
- package/dist/i18n/locales/fr/index.js +5 -1
- package/dist/i18n/locales/fr/index.js.map +1 -1
- package/dist/i18n/locales/fr/menu.json.js +2 -0
- package/dist/i18n/locales/fr/panels.json.js +109 -1
- package/dist/i18n/locales/fr/settings.json.js +1 -0
- package/dist/i18n/locales/fr/tools.json.js +3 -1
- package/dist/i18n/locales/fr/variables/panel.json.js +20 -0
- package/dist/i18n/locales/fr/variations.json.js +23 -0
- package/dist/i18n/locales/fr/variations.json.js.map +1 -0
- package/dist/i18n/locales/id/agents.json.js +31 -0
- package/dist/i18n/locales/id/agents.json.js.map +1 -0
- package/dist/i18n/locales/id/ai.json.js +608 -0
- package/dist/i18n/locales/id/ai.json.js.map +1 -0
- package/dist/i18n/locales/id/automation.json.js +150 -0
- package/dist/i18n/locales/id/automation.json.js.map +1 -0
- package/dist/i18n/locales/id/browser.json.js +50 -0
- package/dist/i18n/locales/id/browser.json.js.map +1 -0
- package/dist/i18n/locales/id/chat-context.json.js +62 -0
- package/dist/i18n/locales/id/chat-context.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/editor.json.js +337 -0
- package/dist/i18n/locales/id/cloud/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/portal.json.js +435 -0
- package/dist/i18n/locales/id/cloud/portal.json.js.map +1 -0
- package/dist/i18n/locales/id/code.json.js +43 -0
- package/dist/i18n/locales/id/code.json.js.map +1 -0
- package/dist/i18n/locales/id/collaboration.json.js +84 -0
- package/dist/i18n/locales/id/collaboration.json.js.map +1 -0
- package/dist/i18n/locales/id/commands.json.js +111 -0
- package/dist/i18n/locales/id/commands.json.js.map +1 -0
- package/dist/i18n/locales/id/comments.json.js +37 -0
- package/dist/i18n/locales/id/comments.json.js.map +1 -0
- package/dist/i18n/locales/id/common.json.js +51 -0
- package/dist/i18n/locales/id/common.json.js.map +1 -0
- package/dist/i18n/locales/id/credentials.json.js +21 -0
- package/dist/i18n/locales/id/credentials.json.js.map +1 -0
- package/dist/i18n/locales/id/design-check.json.js +101 -0
- package/dist/i18n/locales/id/design-check.json.js.map +1 -0
- package/dist/i18n/locales/id/design-memory.json.js +61 -0
- package/dist/i18n/locales/id/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/id/diagnostics.json.js +78 -0
- package/dist/i18n/locales/id/diagnostics.json.js.map +1 -0
- package/dist/i18n/locales/id/editor.json.js +62 -0
- package/dist/i18n/locales/id/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/explore.json.js +30 -0
- package/dist/i18n/locales/id/explore.json.js.map +1 -0
- package/dist/i18n/locales/id/figjam.json.js +39 -0
- package/dist/i18n/locales/id/figjam.json.js.map +1 -0
- package/dist/i18n/locales/id/files.json.js +86 -0
- package/dist/i18n/locales/id/files.json.js.map +1 -0
- package/dist/i18n/locales/id/fonts.json.js +54 -0
- package/dist/i18n/locales/id/fonts.json.js.map +1 -0
- package/dist/i18n/locales/id/index.js +85 -0
- package/dist/i18n/locales/id/index.js.map +1 -0
- package/dist/i18n/locales/id/media.json.js +52 -0
- package/dist/i18n/locales/id/media.json.js.map +1 -0
- package/dist/i18n/locales/id/menu.json.js +118 -0
- package/dist/i18n/locales/id/menu.json.js.map +1 -0
- package/dist/i18n/locales/id/pages.json.js +16 -0
- package/dist/i18n/locales/id/pages.json.js.map +1 -0
- package/dist/i18n/locales/id/panels.json.js +838 -0
- package/dist/i18n/locales/id/panels.json.js.map +1 -0
- package/dist/i18n/locales/id/recovery.json.js +36 -0
- package/dist/i18n/locales/id/recovery.json.js.map +1 -0
- package/dist/i18n/locales/id/rename.json.js +19 -0
- package/dist/i18n/locales/id/rename.json.js.map +1 -0
- package/dist/i18n/locales/id/rendering.json.js +18 -0
- package/dist/i18n/locales/id/rendering.json.js.map +1 -0
- package/dist/i18n/locales/id/settings.json.js +169 -0
- package/dist/i18n/locales/id/settings.json.js.map +1 -0
- package/dist/i18n/locales/id/shaders.json.js +24 -0
- package/dist/i18n/locales/id/shaders.json.js.map +1 -0
- package/dist/i18n/locales/id/shapes.json.js +48 -0
- package/dist/i18n/locales/id/shapes.json.js.map +1 -0
- package/dist/i18n/locales/id/slides.json.js +27 -0
- package/dist/i18n/locales/id/slides.json.js.map +1 -0
- package/dist/i18n/locales/id/statuses.json.js +38 -0
- package/dist/i18n/locales/id/statuses.json.js.map +1 -0
- package/dist/i18n/locales/id/storage.json.js +21 -0
- package/dist/i18n/locales/id/storage.json.js.map +1 -0
- package/dist/i18n/locales/id/tools.json.js +27 -0
- package/dist/i18n/locales/id/tools.json.js.map +1 -0
- package/dist/i18n/locales/id/updates.json.js +31 -0
- package/dist/i18n/locales/id/updates.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/panel.json.js +175 -0
- package/dist/i18n/locales/id/variables/panel.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/types.json.js +15 -0
- package/dist/i18n/locales/id/variables/types.json.js.map +1 -0
- package/dist/i18n/locales/id/variations.json.js +23 -0
- package/dist/i18n/locales/id/variations.json.js.map +1 -0
- package/dist/i18n/locales/it/ai.json.js +68 -2
- package/dist/i18n/locales/it/commands.json.js +2 -0
- package/dist/i18n/locales/it/comments.json.js +1 -1
- package/dist/i18n/locales/it/design-check.json.js +13 -1
- package/dist/i18n/locales/it/design-memory.json.js +82 -0
- package/dist/i18n/locales/it/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/it/fonts.json.js +10 -0
- package/dist/i18n/locales/it/index.js +5 -1
- package/dist/i18n/locales/it/index.js.map +1 -1
- package/dist/i18n/locales/it/menu.json.js +2 -0
- package/dist/i18n/locales/it/panels.json.js +109 -1
- package/dist/i18n/locales/it/settings.json.js +1 -0
- package/dist/i18n/locales/it/tools.json.js +3 -1
- package/dist/i18n/locales/it/variables/panel.json.js +20 -0
- package/dist/i18n/locales/it/variations.json.js +23 -0
- package/dist/i18n/locales/it/variations.json.js.map +1 -0
- package/dist/i18n/locales/ja/ai.json.js +68 -2
- package/dist/i18n/locales/ja/commands.json.js +2 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -1
- package/dist/i18n/locales/ja/design-check.json.js +13 -1
- package/dist/i18n/locales/ja/design-memory.json.js +61 -0
- package/dist/i18n/locales/ja/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/ja/fonts.json.js +10 -0
- package/dist/i18n/locales/ja/index.js +5 -1
- package/dist/i18n/locales/ja/index.js.map +1 -1
- package/dist/i18n/locales/ja/menu.json.js +2 -0
- package/dist/i18n/locales/ja/panels.json.js +106 -1
- package/dist/i18n/locales/ja/settings.json.js +1 -0
- package/dist/i18n/locales/ja/tools.json.js +3 -1
- package/dist/i18n/locales/ja/variables/panel.json.js +20 -0
- package/dist/i18n/locales/ja/variations.json.js +23 -0
- package/dist/i18n/locales/ja/variations.json.js.map +1 -0
- package/dist/i18n/locales/pl/ai.json.js +68 -2
- package/dist/i18n/locales/pl/commands.json.js +2 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -1
- package/dist/i18n/locales/pl/design-check.json.js +13 -1
- package/dist/i18n/locales/pl/design-memory.json.js +89 -0
- package/dist/i18n/locales/pl/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/pl/fonts.json.js +10 -0
- package/dist/i18n/locales/pl/index.js +5 -1
- package/dist/i18n/locales/pl/index.js.map +1 -1
- package/dist/i18n/locales/pl/menu.json.js +2 -0
- package/dist/i18n/locales/pl/panels.json.js +110 -1
- package/dist/i18n/locales/pl/settings.json.js +1 -0
- package/dist/i18n/locales/pl/tools.json.js +3 -1
- package/dist/i18n/locales/pl/variables/panel.json.js +20 -0
- package/dist/i18n/locales/pl/variations.json.js +23 -0
- package/dist/i18n/locales/pl/variations.json.js.map +1 -0
- package/dist/i18n/locales/ru/ai.json.js +68 -2
- package/dist/i18n/locales/ru/commands.json.js +3 -1
- package/dist/i18n/locales/ru/comments.json.js +1 -1
- package/dist/i18n/locales/ru/design-check.json.js +13 -1
- package/dist/i18n/locales/ru/design-memory.json.js +89 -0
- package/dist/i18n/locales/ru/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/ru/fonts.json.js +10 -0
- package/dist/i18n/locales/ru/index.js +5 -1
- package/dist/i18n/locales/ru/index.js.map +1 -1
- package/dist/i18n/locales/ru/menu.json.js +2 -0
- package/dist/i18n/locales/ru/panels.json.js +110 -1
- package/dist/i18n/locales/ru/settings.json.js +1 -0
- package/dist/i18n/locales/ru/tools.json.js +3 -1
- package/dist/i18n/locales/ru/variables/panel.json.js +20 -0
- package/dist/i18n/locales/ru/variations.json.js +23 -0
- package/dist/i18n/locales/ru/variations.json.js.map +1 -0
- package/dist/i18n/locales/zh-cn/ai.json.js +68 -2
- package/dist/i18n/locales/zh-cn/commands.json.js +2 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -1
- package/dist/i18n/locales/zh-cn/design-check.json.js +13 -1
- package/dist/i18n/locales/zh-cn/design-memory.json.js +61 -0
- package/dist/i18n/locales/zh-cn/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/zh-cn/fonts.json.js +10 -0
- package/dist/i18n/locales/zh-cn/index.js +5 -1
- package/dist/i18n/locales/zh-cn/index.js.map +1 -1
- package/dist/i18n/locales/zh-cn/menu.json.js +2 -0
- package/dist/i18n/locales/zh-cn/panels.json.js +106 -1
- package/dist/i18n/locales/zh-cn/settings.json.js +1 -0
- package/dist/i18n/locales/zh-cn/tools.json.js +3 -1
- package/dist/i18n/locales/zh-cn/variables/panel.json.js +20 -0
- package/dist/i18n/locales/zh-cn/variations.json.js +23 -0
- package/dist/i18n/locales/zh-cn/variations.json.js.map +1 -0
- package/dist/i18n/messages/ai.d.ts +98 -2
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +70 -2
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/chat-usage.d.ts +34 -0
- package/dist/i18n/messages/chat-usage.d.ts.map +1 -0
- package/dist/i18n/messages/chat-usage.js +25 -0
- package/dist/i18n/messages/chat-usage.js.map +1 -0
- package/dist/i18n/messages/commands.d.ts +2 -0
- package/dist/i18n/messages/commands.d.ts.map +1 -1
- package/dist/i18n/messages/commands.js +2 -0
- package/dist/i18n/messages/commands.js.map +1 -1
- package/dist/i18n/messages/comments.d.ts +2 -2
- package/dist/i18n/messages/comments.js +2 -2
- package/dist/i18n/messages/comments.js.map +1 -1
- package/dist/i18n/messages/design-check.d.ts +12 -0
- package/dist/i18n/messages/design-check.d.ts.map +1 -1
- package/dist/i18n/messages/design-check.js +13 -1
- package/dist/i18n/messages/design-check.js.map +1 -1
- package/dist/i18n/messages/design-memory.d.ts +68 -0
- package/dist/i18n/messages/design-memory.d.ts.map +1 -0
- package/dist/i18n/messages/design-memory.js +85 -0
- package/dist/i18n/messages/design-memory.js.map +1 -0
- package/dist/i18n/messages/fonts.d.ts +12 -0
- package/dist/i18n/messages/fonts.d.ts.map +1 -1
- package/dist/i18n/messages/fonts.js +10 -0
- package/dist/i18n/messages/fonts.js.map +1 -1
- package/dist/i18n/messages/menu.d.ts +2 -0
- package/dist/i18n/messages/menu.d.ts.map +1 -1
- package/dist/i18n/messages/menu.js +2 -0
- package/dist/i18n/messages/menu.js.map +1 -1
- package/dist/i18n/messages/panels.d.ts +131 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +109 -1
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages/settings.d.ts +1 -0
- package/dist/i18n/messages/settings.d.ts.map +1 -1
- package/dist/i18n/messages/settings.js +1 -0
- package/dist/i18n/messages/settings.js.map +1 -1
- package/dist/i18n/messages/tools.d.ts +2 -0
- package/dist/i18n/messages/tools.d.ts.map +1 -1
- package/dist/i18n/messages/tools.js +3 -1
- package/dist/i18n/messages/tools.js.map +1 -1
- package/dist/i18n/messages/variables/panel.d.ts +24 -0
- package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
- package/dist/i18n/messages/variables/panel.js +20 -0
- package/dist/i18n/messages/variables/panel.js.map +1 -1
- package/dist/i18n/messages/variations.d.ts +28 -0
- package/dist/i18n/messages/variations.d.ts.map +1 -0
- package/dist/i18n/messages/variations.js +26 -0
- package/dist/i18n/messages/variations.js.map +1 -0
- package/dist/i18n/messages.d.ts +405 -4
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/i18n/messages.js +8 -2
- package/dist/i18n/messages.js.map +1 -1
- package/dist/i18n/useI18n.d.ts +1389 -13
- package/dist/i18n/useI18n.d.ts.map +1 -1
- package/dist/i18n/useI18n.js +8 -1
- package/dist/i18n/useI18n.js.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts +6 -0
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js +3 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +11 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +15 -5
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/index.d.ts +2 -1
- package/dist/primitives/ColorPicker/index.js +2 -1
- package/dist/primitives/ColorPicker/outside.d.ts +16 -0
- package/dist/primitives/ColorPicker/outside.d.ts.map +1 -0
- package/dist/primitives/ColorPicker/outside.js +20 -0
- package/dist/primitives/ColorPicker/outside.js.map +1 -0
- package/dist/primitives/Fill/FillRoot.vue.d.ts +2 -1
- package/dist/primitives/Fill/FillRoot.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillRoot.vue.js +5 -2
- package/dist/primitives/Fill/FillRoot.vue.js.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.js +2 -1
- package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
- package/dist/primitives/Fill/types.d.ts +6 -1
- package/dist/primitives/Fill/types.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.d.ts +10 -4
- package/dist/primitives/Fill/useFill.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.js +14 -10
- package/dist/primitives/Fill/useFill.js.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +5 -0
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js +63 -56
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts +2 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js +5 -2
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js +4 -3
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/types.d.ts +3 -1
- package/dist/primitives/GradientEditor/types.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.d.ts +5 -3
- package/dist/primitives/GradientEditor/useGradientStops.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.js +9 -4
- package/dist/primitives/GradientEditor/useGradientStops.js.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +6 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +16 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts +3 -0
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js +3 -1
- package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js.map +1 -1
- package/dist/shared/assets/cursors/eyedropper.svg.js +6 -0
- package/dist/shared/assets/cursors/eyedropper.svg.js.map +1 -0
- package/dist/shared/frame.d.ts +28 -0
- package/dist/shared/frame.d.ts.map +1 -0
- package/dist/shared/frame.js +92 -0
- package/dist/shared/frame.js.map +1 -0
- package/dist/shared/input/auto-layout/drag.js +71 -0
- package/dist/shared/input/auto-layout/drag.js.map +1 -0
- package/dist/shared/input/{auto-layout-hover.d.ts → auto-layout/hover.d.ts} +3 -3
- package/dist/shared/input/auto-layout/hover.d.ts.map +1 -0
- package/dist/shared/input/{auto-layout-hover.js → auto-layout/hover.js} +42 -86
- package/dist/shared/input/auto-layout/hover.js.map +1 -0
- package/dist/shared/input/{auto-layout.js → auto-layout/index.js} +2 -2
- package/dist/shared/input/auto-layout/index.js.map +1 -0
- package/dist/shared/input/index.d.ts +1 -1
- package/dist/shared/input/index.js +1 -1
- package/dist/shared/input/move/drag.js +1 -1
- package/dist/shared/input/resize.js +1 -1
- package/dist/shared/input/select.js +5 -3
- package/dist/shared/input/select.js.map +1 -1
- package/dist/shared/input/types.d.ts +10 -2
- package/dist/shared/input/types.d.ts.map +1 -1
- package/dist/shared/input/types.js.map +1 -1
- package/package.json +19 -4
- package/dist/shared/input/auto-layout-hover.d.ts.map +0 -1
- package/dist/shared/input/auto-layout-hover.js.map +0 -1
- package/dist/shared/input/auto-layout.js.map +0 -1
|
@@ -12,6 +12,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
12
12
|
sceneRenderer: {},
|
|
13
13
|
maxPixelRatio: {},
|
|
14
14
|
reducedEffects: { type: Boolean },
|
|
15
|
+
animations: { type: Function },
|
|
16
|
+
warnShaderLimit: { type: Function },
|
|
15
17
|
showRulers: { type: Boolean },
|
|
16
18
|
preserveDrawingBuffer: { type: Boolean },
|
|
17
19
|
onReady: { type: Function },
|
|
@@ -19,8 +21,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
19
21
|
onPresentation: { type: Function },
|
|
20
22
|
getRenderState: { type: Function },
|
|
21
23
|
getSceneScope: { type: Function },
|
|
24
|
+
getPlayScenes: { type: Function },
|
|
25
|
+
getPlayScroll: { type: Function },
|
|
22
26
|
onFrame: { type: Function },
|
|
23
27
|
onViewportResize: { type: Function },
|
|
28
|
+
onViewportMove: { type: Function },
|
|
24
29
|
onContextLost: { type: Function },
|
|
25
30
|
onNodeDrawFailure: { type: Function }
|
|
26
31
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRoot.vue.js","names":[],"sources":["../../src/canvas/CanvasRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport { provideCanvas } from '#vue/canvas/context'\nimport { useCanvas, type UseCanvasOptions } from '#vue/canvas/surface/use'\nimport { useEditor } from '#vue/editor/context'\n\nconst { showRulers, preserveDrawingBuffer } = defineProps<UseCanvasOptions>()\n\nconst editor = useEditor()\nconst canvasRef = ref<HTMLCanvasElement | null>(null)\nconst ready = ref(false)\n\nconst { renderNow, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle } = useCanvas(\n canvasRef,\n editor,\n {\n showRulers,\n preserveDrawingBuffer,\n onReady: () => {\n ready.value = true\n }\n }\n)\n\nprovideCanvas({\n canvasRef,\n ready,\n renderNow,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n})\n</script>\n\n<template>\n <slot :canvas-ref=\"canvasRef\" :ready=\"ready\" :render-now=\"renderNow\" />\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CanvasRoot.vue.js","names":[],"sources":["../../src/canvas/CanvasRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport { provideCanvas } from '#vue/canvas/context'\nimport { useCanvas, type UseCanvasOptions } from '#vue/canvas/surface/use'\nimport { useEditor } from '#vue/editor/context'\n\nconst { showRulers, preserveDrawingBuffer } = defineProps<UseCanvasOptions>()\n\nconst editor = useEditor()\nconst canvasRef = ref<HTMLCanvasElement | null>(null)\nconst ready = ref(false)\n\nconst { renderNow, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle } = useCanvas(\n canvasRef,\n editor,\n {\n showRulers,\n preserveDrawingBuffer,\n onReady: () => {\n ready.value = true\n }\n }\n)\n\nprovideCanvas({\n canvasRef,\n ready,\n renderNow,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n})\n</script>\n\n<template>\n <slot :canvas-ref=\"canvasRef\" :ready=\"ready\" :render-now=\"renderNow\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASA,MAAM,SAAS,UAAU;EACzB,MAAM,YAAY,IAA8B,IAAI;EACpD,MAAM,QAAQ,IAAI,KAAK;EAEvB,MAAM,EAAE,WAAW,qBAAqB,uBAAuB,sBAAsB,UACnF,WACA,QACA;GACE,YAAS,QAAA;GACT,uBAAoB,QAAA;GACpB,eAAe;IACb,MAAM,QAAQ;GAChB;EACF,CACF;EAEA,cAAc;GACZ;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;;GAIC,OAAA,WAAuE,KAAA,QAAA,WAAA;IAAhE,WAAY,UAAA;IAAY,OAAO,MAAA;IAAQ,WAAY,MAAA,SAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { autoLayoutValueField, resolveAutoLayoutHover } from "../../shared/input/auto-layout
|
|
1
|
+
import { autoLayoutValueField, resolveAutoLayoutHover } from "../../shared/input/auto-layout/hover.js";
|
|
2
2
|
import { ref } from "vue";
|
|
3
3
|
//#region src/canvas/auto-layout/value-edit.ts
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-edit.js","names":[],"sources":["../../../src/canvas/auto-layout/value-edit.ts"],"sourcesContent":["import { ref } from 'vue'\n\nimport type { Editor, NodePreview } from '@pairdraw/core'\n\nimport {\n autoLayoutValueField,\n resolveAutoLayoutHover,\n type AutoLayoutValueField\n} from '#vue/shared/input/auto-layout
|
|
1
|
+
{"version":3,"file":"value-edit.js","names":[],"sources":["../../../src/canvas/auto-layout/value-edit.ts"],"sourcesContent":["import { ref } from 'vue'\n\nimport type { Editor, NodePreview } from '@pairdraw/core'\n\nimport {\n autoLayoutValueField,\n resolveAutoLayoutHover,\n type AutoLayoutValueField\n} from '#vue/shared/input/auto-layout/hover'\n\n/**\n * A padding or gap value edited on the canvas, as Figma opens one on a double-click: the editor\n * shows while the edit is open, and the value previews on the frame until it is committed.\n */\nexport function createAutoLayoutValueEdit(editor: Editor) {\n const autoLayoutValueEdit = ref<{\n nodeId: string\n field: AutoLayoutValueField\n /** The gap a double-click opened the gap's editor on, which it sits over. */\n gap: number\n value: number\n } | null>(null)\n // The edit's owned preview: undo takes it back in one step, and a selection, page, or\n // document change cancels it, which closes the editor.\n let valuePreview: NodePreview | null = null\n let stopValuePreview: Array<() => void> = []\n\n function end() {\n for (const stop of stopValuePreview) stop()\n stopValuePreview = []\n valuePreview = null\n autoLayoutValueEdit.value = null\n }\n\n function start(cx: number, cy: number): boolean {\n const hover = resolveAutoLayoutHover(cx, cy, editor)\n const field = hover ? autoLayoutValueField(hover) : null\n const node = hover ? editor.graph.getNode(hover.nodeId) : undefined\n if (!hover || !field || !node) return false\n valuePreview = editor.beginNodePreview(\n field === 'itemSpacing' ? 'Update gap' : 'Update padding'\n )\n const close = () => {\n if (valuePreview?.closed) end()\n }\n stopValuePreview = (['selection:changed', 'page:changed', 'graph:replaced'] as const).map(\n (event) => editor.onEditorEvent(event, close)\n )\n // The preview tracks the frame only once a value changes, so its deletion closes the editor here.\n stopValuePreview.push(\n editor.onEditorEvent('node:deleted', (id) => {\n if (id === node.id) valuePreview?.cancel()\n close()\n })\n )\n autoLayoutValueEdit.value = {\n nodeId: node.id,\n field,\n gap: hover.index ?? 0,\n value: node[field]\n }\n return true\n }\n\n function update(value: number) {\n const edit = autoLayoutValueEdit.value\n if (!edit || !valuePreview || !Number.isFinite(value)) return\n const next = Math.max(0, value)\n autoLayoutValueEdit.value = { ...edit, value: next }\n valuePreview.update(edit.nodeId, { [edit.field]: next })\n }\n\n function commit(value: number) {\n const edit = autoLayoutValueEdit.value\n if (edit && valuePreview && Number.isFinite(value)) {\n valuePreview.update(edit.nodeId, { [edit.field]: Math.max(0, value) })\n valuePreview.commit()\n } else {\n valuePreview?.cancel()\n }\n end()\n }\n\n function cancel() {\n valuePreview?.cancel()\n end()\n }\n\n return { edit: autoLayoutValueEdit, start, update, commit, cancel }\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,0BAA0B,QAAgB;CACxD,MAAM,sBAAsB,IAMlB,IAAI;CAGd,IAAI,eAAmC;CACvC,IAAI,mBAAsC,CAAC;CAE3C,SAAS,MAAM;EACb,KAAK,MAAM,QAAQ,kBAAkB,KAAK;EAC1C,mBAAmB,CAAC;EACpB,eAAe;EACf,oBAAoB,QAAQ;CAC9B;CAEA,SAAS,MAAM,IAAY,IAAqB;EAC9C,MAAM,QAAQ,uBAAuB,IAAI,IAAI,MAAM;EACnD,MAAM,QAAQ,QAAQ,qBAAqB,KAAK,IAAI;EACpD,MAAM,OAA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YEDROPPER_LOUPE_PIXELS, EyedropperLoupe, useEyedropperLoupe } from "./use.js";
|
|
2
|
+
import { Editor } from "@pairdraw/core";
|
|
3
|
+
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
4
|
+
//#region src/canvas/eyedropper/index.d.ts
|
|
5
|
+
/** Whether the editor's profile offers the eyedropper; boards and read-only documents do not. */
|
|
6
|
+
declare function offersEyedropper(editor: Editor): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Switches to the eyedropper and resolves with the next color picked on the canvas instead of
|
|
9
|
+
* applying it to the selection; `null` when the user leaves the tool or the request is cancelled.
|
|
10
|
+
*/
|
|
11
|
+
declare function requestEyedropperSample(editor: Editor): Promise<Color | null>;
|
|
12
|
+
/** Gives up a waiting request, as when its picker closes, and leaves the eyedropper. */
|
|
13
|
+
declare function cancelEyedropperSample(editor: Editor): void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a press answers a picker's request: one on the canvas while a request waits. A picker
|
|
16
|
+
* passes it as `keepOpen`, so the press that samples does not dismiss it.
|
|
17
|
+
*/
|
|
18
|
+
declare function pressAnswersEyedropper(editor: Editor, event: PointerEvent): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A click with the eyedropper: answers a waiting picker request, otherwise paints the selection's
|
|
21
|
+
* fill (Alt: stroke) in one undo step. Either way the Move tool comes back.
|
|
22
|
+
*/
|
|
23
|
+
declare function handleEyedropperDown(editor: Editor, cx: number, cy: number, altKey: boolean): void;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { EYEDROPPER_LOUPE_PIXELS, type EyedropperLoupe, cancelEyedropperSample, handleEyedropperDown, offersEyedropper, pressAnswersEyedropper, requestEyedropperSample, useEyedropperLoupe };
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/canvas/eyedropper/index.ts"],"mappings":";;;;;iBAuBgB,iBAAiB,QAAQ;;;;;iBASzB,wBAAwB,QAAQ,SAAS,QAAQ;;iBAajD,uBAAuB,QAAQ;;;;;iBAU/B,uBAAuB,QAAQ,QAAQ,OAAO;;;;;iBAQ9C,qBAAqB,QAAQ,QAAQ,YAAY,YAAY"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { sampleEyedropperPixels } from "./sample.js";
|
|
2
|
+
import { EYEDROPPER_LOUPE_PIXELS, useEyedropperLoupe } from "./use.js";
|
|
3
|
+
import { applySampledColor, resolveEditorProfile, scenePixelColor } from "@pairdraw/core";
|
|
4
|
+
//#region src/canvas/eyedropper/index.ts
|
|
5
|
+
/** The request a color picker waits on, per editor; a new request replaces the old one. */
|
|
6
|
+
const requests = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function settle(editor, color) {
|
|
8
|
+
const request = requests.get(editor);
|
|
9
|
+
if (!request) return;
|
|
10
|
+
requests.delete(editor);
|
|
11
|
+
request.stop();
|
|
12
|
+
request.resolve(color);
|
|
13
|
+
}
|
|
14
|
+
/** Whether the editor's profile offers the eyedropper; boards and read-only documents do not. */
|
|
15
|
+
function offersEyedropper(editor) {
|
|
16
|
+
const { tools } = resolveEditorProfile(editor.state);
|
|
17
|
+
return !tools || tools.has("EYEDROPPER");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Switches to the eyedropper and resolves with the next color picked on the canvas instead of
|
|
21
|
+
* applying it to the selection; `null` when the user leaves the tool or the request is cancelled.
|
|
22
|
+
*/
|
|
23
|
+
function requestEyedropperSample(editor) {
|
|
24
|
+
settle(editor, null);
|
|
25
|
+
editor.setTool("EYEDROPPER");
|
|
26
|
+
if (editor.state.activeTool !== "EYEDROPPER") return Promise.resolve(null);
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
const stop = editor.onEditorEvent("tool:changed", () => settle(editor, null));
|
|
29
|
+
requests.set(editor, {
|
|
30
|
+
resolve,
|
|
31
|
+
stop
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** Gives up a waiting request, as when its picker closes, and leaves the eyedropper. */
|
|
36
|
+
function cancelEyedropperSample(editor) {
|
|
37
|
+
if (!requests.has(editor)) return;
|
|
38
|
+
settle(editor, null);
|
|
39
|
+
if (editor.state.activeTool === "EYEDROPPER") editor.setTool("SELECT");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether a press answers a picker's request: one on the canvas while a request waits. A picker
|
|
43
|
+
* passes it as `keepOpen`, so the press that samples does not dismiss it.
|
|
44
|
+
*/
|
|
45
|
+
function pressAnswersEyedropper(editor, event) {
|
|
46
|
+
return requests.has(editor) && event.target instanceof HTMLCanvasElement;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A click with the eyedropper: answers a waiting picker request, otherwise paints the selection's
|
|
50
|
+
* fill (Alt: stroke) in one undo step. Either way the Move tool comes back.
|
|
51
|
+
*/
|
|
52
|
+
function handleEyedropperDown(editor, cx, cy, altKey) {
|
|
53
|
+
const pixels = sampleEyedropperPixels(editor, cx, cy, 1);
|
|
54
|
+
const color = pixels ? scenePixelColor(pixels, 0, 0) : null;
|
|
55
|
+
if (requests.has(editor)) settle(editor, color);
|
|
56
|
+
else if (color) applySampledColor(editor, color, altKey ? "stroke" : "fill");
|
|
57
|
+
editor.setTool("SELECT");
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { EYEDROPPER_LOUPE_PIXELS, cancelEyedropperSample, handleEyedropperDown, offersEyedropper, pressAnswersEyedropper, requestEyedropperSample, useEyedropperLoupe };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/canvas/eyedropper/index.ts"],"sourcesContent":["import { applySampledColor, resolveEditorProfile, scenePixelColor } from '@pairdraw/core'\nimport type { Editor, EyedropperTarget } from '@pairdraw/core'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { sampleEyedropperPixels } from './sample'\n\ninterface SampleRequest {\n resolve: (color: Color | null) => void\n stop: () => void\n}\n\n/** The request a color picker waits on, per editor; a new request replaces the old one. */\nconst requests = new WeakMap<Editor, SampleRequest>()\n\nfunction settle(editor: Editor, color: Color | null) {\n const request = requests.get(editor)\n if (!request) return\n requests.delete(editor)\n request.stop()\n request.resolve(color)\n}\n\n/** Whether the editor's profile offers the eyedropper; boards and read-only documents do not. */\nexport function offersEyedropper(editor: Editor): boolean {\n const { tools } = resolveEditorProfile(editor.state)\n return !tools || tools.has('EYEDROPPER')\n}\n\n/**\n * Switches to the eyedropper and resolves with the next color picked on the canvas instead of\n * applying it to the selection; `null` when the user leaves the tool or the request is cancelled.\n */\nexport function requestEyedropperSample(editor: Editor): Promise<Color | null> {\n settle(editor, null)\n editor.setTool('EYEDROPPER')\n if (editor.state.activeTool !== 'EYEDROPPER') return Promise.resolve(null)\n // Subscribed after switching, so the switch to the eyedropper itself does not cancel. The\n // executor runs at once, so the request is stored before anything can settle it.\n return new Promise<Color | null>((resolve) => {\n const stop = editor.onEditorEvent('tool:changed', () => settle(editor, null))\n requests.set(editor, { resolve, stop })\n })\n}\n\n/** Gives up a waiting request, as when its picker closes, and leaves the eyedropper. */\nexport function cancelEyedropperSample(editor: Editor) {\n if (!requests.has(editor)) return\n settle(editor, null)\n if (editor.state.activeTool === 'EYEDROPPER') editor.setTool('SELECT')\n}\n\n/**\n * Whether a press answers a picker's request: one on the canvas while a request waits. A picker\n * passes it as `keepOpen`, so the press that samples does not dismiss it.\n */\nexport function pressAnswersEyedropper(editor: Editor, event: PointerEvent): boolean {\n return requests.has(editor) && event.target instanceof HTMLCanvasElement\n}\n\n/**\n * A click with the eyedropper: answers a waiting picker request, otherwise paints the selection's\n * fill (Alt: stroke) in one undo step. Either way the Move tool comes back.\n */\nexport function handleEyedropperDown(editor: Editor, cx: number, cy: number, altKey: boolean) {\n const pixels = sampleEyedropperPixels(editor, cx, cy, 1)\n const color = pixels ? scenePixelColor(pixels, 0, 0) : null\n if (requests.has(editor)) {\n // Resolve before the tool switch, which would otherwise cancel the request.\n settle(editor, color)\n } else if (color) {\n const target: EyedropperTarget = altKey ? 'stroke' : 'fill'\n applySampledColor(editor, color, target)\n }\n editor.setTool('SELECT')\n}\n\nexport { EYEDROPPER_LOUPE_PIXELS, useEyedropperLoupe } from './use'\nexport type { EyedropperLoupe } from './use'\n"],"mappings":";;;;;AAYA,MAAM,2BAAW,IAAI,QAA+B;AAEpD,SAAS,OAAO,QAAgB,OAAqB;CACnD,MAAM,UAAU,SAAS,IAAI,MAAM;CACnC,IAAI,CAAC,SAAS;CACd,SAAS,OAAO,MAAM;CACtB,QAAQ,KAAK;CACb,QAAQ,QAAQ,KAAK;AACvB;;AAGA,SAAgB,iBAAiB,QAAyB;CACxD,MAAM,EAAE,UAAU,qBAAqB,OAAO,KAAK;CACnD,OAAO,CAAC,SAAS,MAAM,IAAI,YAAY;AACzC;;;;;AAMA,SAAgB,wBAAwB,QAAuC;CAC7E,OAAO,QAAQ,IAAI;CACnB,OAAO,QAAQ,YAAY;CAC3B,IAAI,OAAO,MAAM,eAAe,cAAc,OAAO,QAAQ,QAAQ,IAAI;CAGzE,OAAO,IAAI,SAAuB,YAAY;EAC5C,MAAM,OAAO,OAAO,cAAc,sBAAsB,OAAO,QAAQ,IAAI,CAAC;EAC5E,SAAS,IAAI,QAAQ;GAAE;GAAS;EAAK,CAAC;CACxC,CAAC;AACH;;AAGA,SAAgB,uBAAuB,QAAgB;CACrD,IAAI,CAAC,SAAS,IAAI,MAAM,GAAG;CAC3B,OAAO,QAAQ,IAAI;CACnB,IAAI,OAAO,MAAM,eAAe,cAAc,OAAO,QAAQ,QAAQ;AACvE;;;;;AAMA,SAAgB,uBAAuB,QAAgB,OAA8B;CACnF,OAAO,SAAS,IAAI,MAAM,KAAK,MAAM,kBAAkB;AACzD;;;;;AAMA,SAAgB,qBAAqB,QAAgB,IAAY,IAAY,QAAiB;CAC5F,MAAM,SAAS,uBAAuB,QAAQ,IAAI,IAAI,CAAC;CACvD,MAAM,QAAQ,SAAS,gBAAgB,QAAQ,GAAG,CAAC,IAAI;CACvD,IAAI,SAAS,IAAI,MAAM,GAErB,OAAO,QAAQ,KAAK;MACf,IAAI,OAET,kBAAkB,QAAQ,OADO,SAAS,WAAW,MACd;CAEzC,OAAO,QAAQ,QAAQ;AACzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { sampleScenePixels } from "@pairdraw/core";
|
|
2
|
+
//#region src/canvas/eyedropper/sample.ts
|
|
3
|
+
/** The screen pixels around a world point at the view's zoom, the centre one sampled. */
|
|
4
|
+
function sampleEyedropperPixels(editor, cx, cy, size) {
|
|
5
|
+
const renderer = editor.renderer;
|
|
6
|
+
if (!renderer) return null;
|
|
7
|
+
const { currentPageId, zoom } = editor.state;
|
|
8
|
+
return sampleScenePixels(renderer.ck, renderer, editor.graph, currentPageId, cx, cy, size, zoom);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { sampleEyedropperPixels };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=sample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample.js","names":[],"sources":["../../../src/canvas/eyedropper/sample.ts"],"sourcesContent":["import { sampleScenePixels } from '@pairdraw/core'\nimport type { Editor, ScenePixels } from '@pairdraw/core'\n\n/** The screen pixels around a world point at the view's zoom, the centre one sampled. */\nexport function sampleEyedropperPixels(\n editor: Editor,\n cx: number,\n cy: number,\n size: number\n): ScenePixels | null {\n const renderer = editor.renderer\n if (!renderer) return null\n const { currentPageId, zoom } = editor.state\n return sampleScenePixels(renderer.ck, renderer, editor.graph, currentPageId, cx, cy, size, zoom)\n}\n"],"mappings":";;;AAIA,SAAgB,uBACd,QACA,IACA,IACA,MACoB;CACpB,MAAM,WAAW,OAAO;CACxB,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,EAAE,eAAe,SAAS,OAAO;CACvC,OAAO,kBAAkB,SAAS,IAAI,UAAU,OAAO,OAAO,eAAe,IAAI,IAAI,MAAM,IAAI;AACjG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter, Ref, ShallowRef } from "vue";
|
|
2
|
+
import { Editor, ScenePixels } from "@pairdraw/core";
|
|
3
|
+
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
4
|
+
//#region src/canvas/eyedropper/use.d.ts
|
|
5
|
+
/** How many screen pixels a side the loupe shows; odd, so one pixel is the centre. */
|
|
6
|
+
declare const EYEDROPPER_LOUPE_PIXELS = 9;
|
|
7
|
+
/**
|
|
8
|
+
* A loupe that stands in for the cursor while the eyedropper is active over the canvas: centred
|
|
9
|
+
* on the pointer, so the outlined centre pixel is the one a click picks. The pointer cursor
|
|
10
|
+
* itself should be hidden while it shows, or the cursor, drawn by the system ahead of the page,
|
|
11
|
+
* appears to run ahead of the loupe.
|
|
12
|
+
*/
|
|
13
|
+
interface EyedropperLoupe {
|
|
14
|
+
/** Whether the loupe has pixels to show: the eyedropper is active with the pointer on the canvas. */
|
|
15
|
+
visible: ComputedRef<boolean>;
|
|
16
|
+
/** The pointer in viewport (client) coordinates, updated with each move. */
|
|
17
|
+
clientX: ShallowRef<number>;
|
|
18
|
+
clientY: ShallowRef<number>;
|
|
19
|
+
/** The screen pixels around the pointer, sampled once a frame from the document alone. */
|
|
20
|
+
pixels: ShallowRef<ScenePixels | null>;
|
|
21
|
+
/** The centre pixel's colour: what a click picks. */
|
|
22
|
+
color: ComputedRef<Color | null>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Tracks the pointer over a canvas while the eyedropper is active. The position follows each
|
|
26
|
+
* move at once; the pixels are sampled on the next frame, and again only when the pointer, the
|
|
27
|
+
* view, or the page changed, so a still pointer costs nothing. `enabled` is false for a canvas
|
|
28
|
+
* that takes no input, such as a split view's inactive pane.
|
|
29
|
+
*/
|
|
30
|
+
declare function useEyedropperLoupe(editor: Editor, canvas: Readonly<Ref<HTMLElement | null | undefined>>, enabled?: MaybeRefOrGetter<boolean>): EyedropperLoupe;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { EYEDROPPER_LOUPE_PIXELS, EyedropperLoupe, useEyedropperLoupe };
|
|
33
|
+
//# sourceMappingURL=use.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/canvas/eyedropper/use.ts"],"mappings":";;;;;cAmBa;;;;;;;UAQI;;EAEf,SAAS;;EAET,SAAS;EACT,SAAS;;EAET,QAAQ,WAAW;;EAEnB,OAAO,YAAY;;;;;;;;iBASL,mBACd,QAAQ,QACR,QAAQ,SAAS,IAAI,kCACrB,UAAS,4BACR"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { sampleEyedropperPixels } from "./sample.js";
|
|
2
|
+
import { computed, shallowRef, toValue, watch } from "vue";
|
|
3
|
+
import { useElementHover, useMouseInElement, useRafFn } from "@vueuse/core";
|
|
4
|
+
import { scenePixelColor } from "@pairdraw/core";
|
|
5
|
+
//#region src/canvas/eyedropper/use.ts
|
|
6
|
+
/** How many screen pixels a side the loupe shows; odd, so one pixel is the centre. */
|
|
7
|
+
const EYEDROPPER_LOUPE_PIXELS = 9;
|
|
8
|
+
/**
|
|
9
|
+
* Tracks the pointer over a canvas while the eyedropper is active. The position follows each
|
|
10
|
+
* move at once; the pixels are sampled on the next frame, and again only when the pointer, the
|
|
11
|
+
* view, or the page changed, so a still pointer costs nothing. `enabled` is false for a canvas
|
|
12
|
+
* that takes no input, such as a split view's inactive pane.
|
|
13
|
+
*/
|
|
14
|
+
function useEyedropperLoupe(editor, canvas, enabled = true) {
|
|
15
|
+
const pointer = useMouseInElement(canvas, {
|
|
16
|
+
handleOutside: false,
|
|
17
|
+
type: "client"
|
|
18
|
+
});
|
|
19
|
+
const hovered = useElementHover(canvas);
|
|
20
|
+
const active = computed(() => toValue(enabled) && hovered.value && editor.state.activeTool === "EYEDROPPER");
|
|
21
|
+
const pixels = shallowRef(null);
|
|
22
|
+
let sampledAt = "";
|
|
23
|
+
const { pause, resume } = useRafFn(() => {
|
|
24
|
+
const sx = pointer.elementX.value;
|
|
25
|
+
const sy = pointer.elementY.value;
|
|
26
|
+
const { zoom, panX, panY, currentPageId } = editor.state;
|
|
27
|
+
const at = `${sx} ${sy} ${zoom} ${panX} ${panY} ${currentPageId}`;
|
|
28
|
+
if (at === sampledAt) return;
|
|
29
|
+
sampledAt = at;
|
|
30
|
+
const { x, y } = editor.screenToCanvas(sx, sy);
|
|
31
|
+
pixels.value = sampleEyedropperPixels(editor, x, y, 9);
|
|
32
|
+
}, { immediate: false });
|
|
33
|
+
watch(active, (shown) => {
|
|
34
|
+
if (shown) return resume();
|
|
35
|
+
pause();
|
|
36
|
+
pixels.value = null;
|
|
37
|
+
sampledAt = "";
|
|
38
|
+
}, { immediate: true });
|
|
39
|
+
const centre = 4;
|
|
40
|
+
const color = computed(() => pixels.value ? scenePixelColor(pixels.value, centre, centre) : null);
|
|
41
|
+
return {
|
|
42
|
+
visible: computed(() => active.value && color.value !== null),
|
|
43
|
+
clientX: pointer.x,
|
|
44
|
+
clientY: pointer.y,
|
|
45
|
+
pixels,
|
|
46
|
+
color
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { EYEDROPPER_LOUPE_PIXELS, useEyedropperLoupe };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.js","names":[],"sources":["../../../src/canvas/eyedropper/use.ts"],"sourcesContent":["import { useElementHover, useMouseInElement, useRafFn } from '@vueuse/core'\nimport {\n computed,\n shallowRef,\n toValue,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef\n} from 'vue'\n\nimport { scenePixelColor } from '@pairdraw/core'\nimport type { Editor, ScenePixels } from '@pairdraw/core'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { sampleEyedropperPixels } from './sample'\n\n/** How many screen pixels a side the loupe shows; odd, so one pixel is the centre. */\nexport const EYEDROPPER_LOUPE_PIXELS = 9\n\n/**\n * A loupe that stands in for the cursor while the eyedropper is active over the canvas: centred\n * on the pointer, so the outlined centre pixel is the one a click picks. The pointer cursor\n * itself should be hidden while it shows, or the cursor, drawn by the system ahead of the page,\n * appears to run ahead of the loupe.\n */\nexport interface EyedropperLoupe {\n /** Whether the loupe has pixels to show: the eyedropper is active with the pointer on the canvas. */\n visible: ComputedRef<boolean>\n /** The pointer in viewport (client) coordinates, updated with each move. */\n clientX: ShallowRef<number>\n clientY: ShallowRef<number>\n /** The screen pixels around the pointer, sampled once a frame from the document alone. */\n pixels: ShallowRef<ScenePixels | null>\n /** The centre pixel's colour: what a click picks. */\n color: ComputedRef<Color | null>\n}\n\n/**\n * Tracks the pointer over a canvas while the eyedropper is active. The position follows each\n * move at once; the pixels are sampled on the next frame, and again only when the pointer, the\n * view, or the page changed, so a still pointer costs nothing. `enabled` is false for a canvas\n * that takes no input, such as a split view's inactive pane.\n */\nexport function useEyedropperLoupe(\n editor: Editor,\n canvas: Readonly<Ref<HTMLElement | null | undefined>>,\n enabled: MaybeRefOrGetter<boolean> = true\n): EyedropperLoupe {\n const pointer = useMouseInElement(canvas, { handleOutside: false, type: 'client' })\n const hovered = useElementHover(canvas)\n const active = computed(\n () => toValue(enabled) && hovered.value && editor.state.activeTool === 'EYEDROPPER'\n )\n const pixels = shallowRef<ScenePixels | null>(null)\n let sampledAt = ''\n\n const { pause, resume } = useRafFn(\n () => {\n const sx = pointer.elementX.value\n const sy = pointer.elementY.value\n const { zoom, panX, panY, currentPageId } = editor.state\n const at = `${sx} ${sy} ${zoom} ${panX} ${panY} ${currentPageId}`\n if (at === sampledAt) return\n sampledAt = at\n const { x, y } = editor.screenToCanvas(sx, sy)\n pixels.value = sampleEyedropperPixels(editor, x, y, EYEDROPPER_LOUPE_PIXELS)\n },\n { immediate: false }\n )\n\n watch(\n active,\n (shown) => {\n if (shown) return resume()\n pause()\n pixels.value = null\n sampledAt = ''\n },\n { immediate: true }\n )\n\n const centre = (EYEDROPPER_LOUPE_PIXELS - 1) / 2\n const color = computed(() =>\n pixels.value ? scenePixelColor(pixels.value, centre, centre) : null\n )\n\n return {\n visible: computed(() => active.value && color.value !== null),\n clientX: pointer.x,\n clientY: pointer.y,\n pixels,\n color\n }\n}\n"],"mappings":";;;;;;AAmBA,MAAa,0BAA0B;;;;;;;AA0BvC,SAAgB,mBACd,QACA,QACA,UAAqC,MACpB;CACjB,MAAM,UAAU,kBAAkB,QAAQ;EAAE,eAAe;EAAO,MAAM;CAAS,CAAC;CAClF,MAAM,UAAU,gBAAgB,MAAM;CACtC,MAAM,SAAS,eACP,QAAQ,OAAO,KAAK,QAAQ,SAAS,OAAO,MAAM,eAAe,YACzE;CACA,MAAM,SAAS,WAA+B,IAAI;CAClD,IAAI,YAAY;CAEhB,MAAM,EAAE,OAAO,WAAW,eAClB;EACJ,MAAM,KAAK,QAAQ,SAAS;EAC5B,MAAM,KAAK,QAAQ,SAAS;EAC5B,MAAM,EAAE,MAAM,MAAM,MAAM,kBAAkB,OAAO;EACnD,MAAM,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAClD,IAAI,OAAO,WAAW;EACtB,YAAY;EACZ,MAAM,EAAE,GAAG,MAAM,OAAO,eAAe,IAAI,EAAE;EAC7C,OAAO,QAAQ,uBAAuB,QAAQ,GAAG,GAAA,CAA0B;CAC7E,GACA,EAAE,WAAW,MAAM,CACrB;CAEA,MACE,SACC,UAAU;EACT,IAAI,OAAO,OAAO,OAAO;EACzB,MAAM;EACN,OAAO,QAAQ;EACf,YAAY;CACd,GACA,EAAE,WAAW,KAAK,CACpB;CAEA,MAAM,SAAS;CACf,MAAM,QAAQ,eACZ,OAAO,QAAQ,gBAAgB,OAAO,OAAO,QAAQ,MAAM,IAAI,IACjE;CAEA,OAAO;EACL,SAAS,eAAe,OAAO,SAAS,MAAM,UAAU,IAAI;EAC5D,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB;EACA;CACF;AACF"}
|
|
@@ -16,6 +16,10 @@ function moveDrag(d, e, { sx, sy, cx, cy }, { editor, guideInput, transform, spa
|
|
|
16
16
|
transform.handlePanMove(d, e);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
+
if (d.type === "auto-layout") {
|
|
20
|
+
d.update(sx, sy, e.altKey, e.shiftKey);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
if (d.type === "gradient" || d.type === "shape-handle") {
|
|
20
24
|
d.update(sx, sy, e.shiftKey);
|
|
21
25
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-move.js","names":[],"sources":["../../../src/canvas/pointer/drag-move.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\n\nimport { selectedTopLevelGuideFrameId, type createGuideInput } from '#vue/canvas/guides/input'\nimport { handlePenDragMove } from '#vue/canvas/pen/input'\nimport { handlePencilDragMove } from '#vue/canvas/pencil/input'\nimport type { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { handleBendHandleMove } from '#vue/canvas/vector-input/input'\nimport { attachModifiers, handleConnectorDrawMove } from '#vue/shared/input/connector/draw'\nimport { handleDrawMove } from '#vue/shared/input/draw'\nimport { handleMoveMove } from '#vue/shared/input/move/drag'\nimport { applyResize } from '#vue/shared/input/resize'\nimport { applyStickyScale } from '#vue/shared/input/sticky/scale'\nimport type { DragState } from '#vue/shared/input/types'\nimport { handleNodeEditMarqueeMove, handleNodeEditMove } from '#vue/shared/input/vector'\nimport { handleNodeEditTransformMove } from '#vue/shared/input/vector/transform'\n\ntype TransformInput = ReturnType<typeof createCanvasTransformInput>\n\n/** What a drag in progress reaches while the pointer moves. */\nexport interface DragMoveContext {\n editor: Editor\n guideInput: Pick<ReturnType<typeof createGuideInput>, 'handleMove'>\n transform: Pick<\n TransformInput,\n 'handlePanMove' | 'handleRotateMove' | 'handleTextSelectMove' | 'handleMarqueeMove'\n >\n /** Whether Space is held, which moves a pen handle's anchor instead of the handle. */\n spaceHeld: () => boolean\n}\n\n/** Pointer position on screen (`sx`, `sy`) and on the canvas (`cx`, `cy`). */\ninterface DragMovePointer {\n sx: number\n sy: number\n cx: number\n cy: number\n}\n\n/** Moves the drag in progress to the pointer, for each kind of drag the canvas starts. */\n// Dispatching the full drag union is intentionally centralized here.\n// eslint-disable-next-line complexity\nexport function moveDrag(\n d: DragState,\n e: MouseEvent,\n { sx, sy, cx, cy }: DragMovePointer,\n { editor, guideInput, transform, spaceHeld }: DragMoveContext\n): void {\n if (d.type === 'pan') {\n transform.handlePanMove(d, e)\n return\n }\n\n if (d.type === 'gradient' || d.type === 'shape-handle') {\n d.update(sx, sy, e.shiftKey)\n return\n }\n\n if (d.type === 'image-crop') {\n d.update(sx, sy, { shift: e.shiftKey, alt: e.altKey })\n return\n }\n\n if (d.type === 'guide') {\n const frameId = e.altKey && !d.guideId ? selectedTopLevelGuideFrameId(editor) : null\n guideInput.handleMove(\n d,\n sx,\n sy,\n cx,\n cy,\n frameId ? { frameId, deep: e.metaKey || e.ctrlKey } : undefined\n )\n return\n }\n\n if (d.type === 'rotate') {\n transform.handleRotateMove(d, cx, cy, e.shiftKey)\n return\n }\n if (d.type === 'move') {\n handleMoveMove(d, cx, cy, sx, sy, editor, { ctrlKey: e.ctrlKey, shiftKey: e.shiftKey })\n return\n }\n if (d.type === 'text-select') {\n transform.handleTextSelectMove(cx, cy)\n return\n }\n if (d.type === 'resize') {\n applyResize(d, cx, cy, e.shiftKey, editor, e.ctrlKey)\n return\n }\n\n if (d.type === 'pen-drag') {\n handlePenDragMove(d, cx, cy, spaceHeld(), e, editor)\n return\n }\n\n if (d.type === 'pencil-drag') {\n handlePencilDragMove(cx, cy, e.shiftKey, editor)\n return\n }\n\n if (d.type === 'edit-node' || d.type === 'edit-handle') {\n handleNodeEditMove(d, cx, cy, editor, e.altKey, e.metaKey || e.ctrlKey, e.shiftKey, e.ctrlKey)\n return\n }\n\n if (d.type === 'bend-handle') {\n handleBendHandleMove(d, cx, cy, e, editor)\n return\n }\n\n if (d.type === 'bend-segment' || d.type === 'edit-transform') {\n handleNodeEditTransformMove(d, cx, cy, e, editor)\n return\n }\n\n if (d.type === 'edit-marquee') {\n handleNodeEditMarqueeMove(d, cx, cy, editor)\n return\n }\n\n if (d.type === 'draw') {\n handleDrawMove(d, cx, cy, e.shiftKey)\n return\n }\n\n if (d.type === 'sticky-draw') {\n d.move(cx, cy)\n return\n }\n\n if (d.type === 'connector-draw') {\n handleConnectorDrawMove(d, cx, cy, sx, sy, editor, attachModifiers(e))\n return\n }\n\n if (d.type === 'connector-end') {\n editor.connectorEndpointDrag(cx, cy, attachModifiers(e))\n return\n }\n\n if (d.type === 'connector-line') {\n editor.connectorLineDrag(cx, cy)\n return\n }\n\n if (d.type === 'line-end') {\n editor.lineEndDrag(cx, cy, { shift: e.shiftKey, alt: e.altKey })\n return\n }\n\n if (d.type === 'sticky-scale') {\n applyStickyScale(d, cx, cy, editor)\n return\n }\n\n if (d.type === 'zoom' || d.type === 'scale') {\n d.update(cx, cy, sx, sy, e.altKey)\n return\n }\n\n // While ⌘ or Ctrl is held the marquee reaches nested layers, as in Figma.\n transform.handleMarqueeMove(d, cx, cy, e.metaKey || e.ctrlKey)\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,SACd,GACA,GACA,EAAE,IAAI,IAAI,IAAI,MACd,EAAE,QAAQ,YAAY,WAAW,aAC3B;CACN,IAAI,EAAE,SAAS,OAAO;EACpB,UAAU,cAAc,GAAG,CAAC;EAC5B;CACF;CAEA,IAAI,EAAE,SAAS,cAAc,EAAE,SAAS,gBAAgB;EACtD,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ;EAC3B;CACF;CAEA,IAAI,EAAE,SAAS,cAAc;EAC3B,EAAE,OA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D;CACF;CAEA,IAAI,EAAE,SAAS,gBAAgB;EAC7B,0BAA0B,GAAG,IAAI,IAAI,MAAM;EAC3C;CACF;CAEA,IAAI,EAAE,SAAS,QAAQ;EACrB,eAAe,GAAG,IAAI,IAAI,EAAE,QAAQ;EACpC;CACF;CAEA,IAAI,EAAE,SAAS,eAAe;EAC5B,EAAE,KAAK,IAAI,EAAE;EACb;CACF;CAEA,IAAI,EAAE,SAAS,kBAAkB;EAC/B,wBAAwB,GAAG,IAAI,IAAI,IAAI,IAAI,QAAQ,gBAAgB,CAAC,CAAC;EACrE;CACF;CAEA,IAAI,EAAE,SAAS,iBAAiB;EAC9B,OAAO,sBAAsB,IAAI,IAAI,gBAAgB,CAAC,CAAC;EACvD;CACF;CAEA,IAAI,EAAE,SAAS,kBAAkB;EAC/B,OAAO,kBAAkB,IAAI,EAAE;EAC/B;CACF;CAEA,IAAI,EAAE,SAAS,YAAY;EACzB,OAAO,YAAY,IAAI,IAAI;GAAE,OAAO,EAAE;GAAU,KAAK,EAAE;EAAO,CAAC;EAC/D;CACF;CAEA,IAAI,EAAE,SAAS,gBAAgB;EAC7B,iBAAiB,GAAG,IAAI,IAAI,MAAM;EAClC;CACF;CAEA,IAAI,EAAE,SAAS,UAAU,EAAE,SAAS,SAAS;EAC3C,EAAE,OAAO,IAAI,IAAI,IAAI,IAAI,EAAE,MAAM;EACjC;CACF;CAGA,UAAU,kBAAkB,GAAG,IAAI,IAAI,EAAE,WAAW,EAAE,OAAO;AAC/D"}
|
|
1
|
+
{"version":3,"file":"drag-move.js","names":[],"sources":["../../../src/canvas/pointer/drag-move.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\n\nimport { selectedTopLevelGuideFrameId, type createGuideInput } from '#vue/canvas/guides/input'\nimport { handlePenDragMove } from '#vue/canvas/pen/input'\nimport { handlePencilDragMove } from '#vue/canvas/pencil/input'\nimport type { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { handleBendHandleMove } from '#vue/canvas/vector-input/input'\nimport { attachModifiers, handleConnectorDrawMove } from '#vue/shared/input/connector/draw'\nimport { handleDrawMove } from '#vue/shared/input/draw'\nimport { handleMoveMove } from '#vue/shared/input/move/drag'\nimport { applyResize } from '#vue/shared/input/resize'\nimport { applyStickyScale } from '#vue/shared/input/sticky/scale'\nimport type { DragState } from '#vue/shared/input/types'\nimport { handleNodeEditMarqueeMove, handleNodeEditMove } from '#vue/shared/input/vector'\nimport { handleNodeEditTransformMove } from '#vue/shared/input/vector/transform'\n\ntype TransformInput = ReturnType<typeof createCanvasTransformInput>\n\n/** What a drag in progress reaches while the pointer moves. */\nexport interface DragMoveContext {\n editor: Editor\n guideInput: Pick<ReturnType<typeof createGuideInput>, 'handleMove'>\n transform: Pick<\n TransformInput,\n 'handlePanMove' | 'handleRotateMove' | 'handleTextSelectMove' | 'handleMarqueeMove'\n >\n /** Whether Space is held, which moves a pen handle's anchor instead of the handle. */\n spaceHeld: () => boolean\n}\n\n/** Pointer position on screen (`sx`, `sy`) and on the canvas (`cx`, `cy`). */\ninterface DragMovePointer {\n sx: number\n sy: number\n cx: number\n cy: number\n}\n\n/** Moves the drag in progress to the pointer, for each kind of drag the canvas starts. */\n// Dispatching the full drag union is intentionally centralized here.\n// eslint-disable-next-line complexity\nexport function moveDrag(\n d: DragState,\n e: MouseEvent,\n { sx, sy, cx, cy }: DragMovePointer,\n { editor, guideInput, transform, spaceHeld }: DragMoveContext\n): void {\n if (d.type === 'pan') {\n transform.handlePanMove(d, e)\n return\n }\n\n if (d.type === 'auto-layout') {\n d.update(sx, sy, e.altKey, e.shiftKey)\n return\n }\n\n if (d.type === 'gradient' || d.type === 'shape-handle') {\n d.update(sx, sy, e.shiftKey)\n return\n }\n\n if (d.type === 'image-crop') {\n d.update(sx, sy, { shift: e.shiftKey, alt: e.altKey })\n return\n }\n\n if (d.type === 'guide') {\n const frameId = e.altKey && !d.guideId ? selectedTopLevelGuideFrameId(editor) : null\n guideInput.handleMove(\n d,\n sx,\n sy,\n cx,\n cy,\n frameId ? { frameId, deep: e.metaKey || e.ctrlKey } : undefined\n )\n return\n }\n\n if (d.type === 'rotate') {\n transform.handleRotateMove(d, cx, cy, e.shiftKey)\n return\n }\n if (d.type === 'move') {\n handleMoveMove(d, cx, cy, sx, sy, editor, { ctrlKey: e.ctrlKey, shiftKey: e.shiftKey })\n return\n }\n if (d.type === 'text-select') {\n transform.handleTextSelectMove(cx, cy)\n return\n }\n if (d.type === 'resize') {\n applyResize(d, cx, cy, e.shiftKey, editor, e.ctrlKey)\n return\n }\n\n if (d.type === 'pen-drag') {\n handlePenDragMove(d, cx, cy, spaceHeld(), e, editor)\n return\n }\n\n if (d.type === 'pencil-drag') {\n handlePencilDragMove(cx, cy, e.shiftKey, editor)\n return\n }\n\n if (d.type === 'edit-node' || d.type === 'edit-handle') {\n handleNodeEditMove(d, cx, cy, editor, e.altKey, e.metaKey || e.ctrlKey, e.shiftKey, e.ctrlKey)\n return\n }\n\n if (d.type === 'bend-handle') {\n handleBendHandleMove(d, cx, cy, e, editor)\n return\n }\n\n if (d.type === 'bend-segment' || d.type === 'edit-transform') {\n handleNodeEditTransformMove(d, cx, cy, e, editor)\n return\n }\n\n if (d.type === 'edit-marquee') {\n handleNodeEditMarqueeMove(d, cx, cy, editor)\n return\n }\n\n if (d.type === 'draw') {\n handleDrawMove(d, cx, cy, e.shiftKey)\n return\n }\n\n if (d.type === 'sticky-draw') {\n d.move(cx, cy)\n return\n }\n\n if (d.type === 'connector-draw') {\n handleConnectorDrawMove(d, cx, cy, sx, sy, editor, attachModifiers(e))\n return\n }\n\n if (d.type === 'connector-end') {\n editor.connectorEndpointDrag(cx, cy, attachModifiers(e))\n return\n }\n\n if (d.type === 'connector-line') {\n editor.connectorLineDrag(cx, cy)\n return\n }\n\n if (d.type === 'line-end') {\n editor.lineEndDrag(cx, cy, { shift: e.shiftKey, alt: e.altKey })\n return\n }\n\n if (d.type === 'sticky-scale') {\n applyStickyScale(d, cx, cy, editor)\n return\n }\n\n if (d.type === 'zoom' || d.type === 'scale') {\n d.update(cx, cy, sx, sy, e.altKey)\n return\n }\n\n // While ⌘ or Ctrl is held the marquee reaches nested layers, as in Figma.\n transform.handleMarqueeMove(d, cx, cy, e.metaKey || e.ctrlKey)\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,SACd,GACA,GACA,EAAE,IAAI,IAAI,IAAI,MACd,EAAE,QAAQ,YAAY,WAAW,aAC3B;CACN,IAAI,EAAE,SAAS,OAAO;EACpB,UAAU,cAAc,GAAG,CAAC;EAC5B;CACF;CAEA,IAAI,EAAE,SAAS,eAAe;EAC5B,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ,EAAE,QAAQ;EACrC;CACF;CAEA,IAAI,EAAE,SAAS,cAAc,EAAE,SAAS,gBAAgB;EACtD,EAAE,OAAO,IAAI,IAAI,EAAE,QAAQ;EAC3B;CACF;CAEA,IAAI,EAAE,SAAS,cAAc;EAC3B,EAAE,OAAO,IAAI,IAAI;GAAE,OAAO,EAAE;GAAU,KAAK,EAAE;EAAO,CAAC;EACrD;CACF;CAEA,IAAI,EAAE,SAAS,SAAS;EACtB,MAAM,UAAU,EAAE,UAAU,CAAC,EAAE,UAAU,6BAA6B,MAAM,IAAI;EAChF,WAAW,WACT,GACA,IACA,IACA,IACA,IACA,UAAU;GAAE;GAAS,MAAM,EAAE,WAAW,EAAE;EAAQ,IAAI,KAAA,CACxD;EACA;CACF;CAEA,IAAI,EAAE,SAAS,UAAU;EACvB,UAAU,iBAAiB,GAAG,IAAI,IAAI,EAAE,QAAQ;EAChD;CACF;CACA,IAAI,EAAE,SAAS,QAAQ;EACrB,eAAe,GAAG,IAAI,IAAI,IAAI,IAAI,QAAQ;GAAE,SAAS,EAAE;GAAS,UAAU,EAAE;EAAS,CAAC;EACtF;CACF;CACA,IAAI,EAAE,SAAS,eAAe;EAC5B,UAAU,qBAAqB,IAAI,EAAE;EACrC;CACF;CACA,IAAI,EAAE,SAAS,UAAU;EACvB,YAAY,GA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AO,CAAC;EAC/D;CACF;CAEA,IAAI,EAAE,SAAS,gBAAgB;EAC7B,iBAAiB,GAAG,IAAI,IAAI,MAAM;EAClC;CACF;CAEA,IAAI,EAAE,SAAS,UAAU,EAAE,SAAS,SAAS;EAC3C,EAAE,OAAO,IAAI,IAAI,IAAI,IAAI,EAAE,MAAM;EACjC;CACF;CAGA,UAAU,kBAAkB,GAAG,IAAI,IAAI,EAAE,WAAW,EAAE,OAAO;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-space.d.ts","names":[],"sources":["../../../src/canvas/surface/color-space.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"color-space.d.ts","names":[],"sources":["../../../src/canvas/surface/color-space.ts"],"mappings":";;KAGY;;;;;;iBAuJI"}
|
|
@@ -94,7 +94,7 @@ function rememberWrittenStyle(canvas) {
|
|
|
94
94
|
* one through its margins; pointers map from its box, so they follow. Under a transform, where no
|
|
95
95
|
* snap holds, the canvas takes its layout size rounded and stays where it is. A flex container
|
|
96
96
|
* that centres the canvas moves it by half a margin change, so there the snap can stay a quarter
|
|
97
|
-
* pixel off.
|
|
97
|
+
* pixel off. Returns where the content box now starts on screen.
|
|
98
98
|
*/
|
|
99
99
|
function sizeCanvas(canvas, editor, onViewportResize, maxPixelRatio = Number.POSITIVE_INFINITY) {
|
|
100
100
|
const dpr = canvasPixelRatio(maxPixelRatio);
|
|
@@ -129,6 +129,10 @@ function sizeCanvas(canvas, editor, onViewportResize, maxPixelRatio = Number.POS
|
|
|
129
129
|
rememberWrittenStyle(canvas);
|
|
130
130
|
if (onViewportResize) onViewportResize(width, height);
|
|
131
131
|
else if ("setViewportSize" in editor && typeof editor.setViewportSize === "function") editor.setViewportSize(width, height);
|
|
132
|
+
return {
|
|
133
|
+
x: left,
|
|
134
|
+
y: top
|
|
135
|
+
};
|
|
132
136
|
}
|
|
133
137
|
function makeGLSurface(ck, canvas, options, glContext, documentColorSpace) {
|
|
134
138
|
let context = glContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gl-surface.js","names":[],"sources":["../../../src/canvas/surface/gl-surface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from 'canvaskit-wasm'\n\nimport type { Editor } from '@pairdraw/core'\nimport { IS_BROWSER } from '@pairdraw/core/constants'\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\n\nimport type { UseCanvasOptions } from '#vue/canvas/surface/types'\n\nimport {\n configurePresentation,\n supportsWideGamutPresentation,\n type PresentationColorSpace\n} from './color-space'\n\ntype GLContext = ReturnType<CanvasKit['MakeGrContext']>\ntype GLHandle = ReturnType<CanvasKit['GetWebGLContext']>\n\nexport type CanvasGLContext = GLContext\nexport type CanvasGLHandle = GLHandle\n\nconst parkingHandles = new WeakMap<CanvasKit, GLHandle>()\n\n/** A 1×1 offscreen WebGL context that stays registered, so another context can become current. */\nfunction parkingHandle(ck: CanvasKit): GLHandle | null {\n const existing = parkingHandles.get(ck)\n if (existing !== undefined) return existing\n if (typeof document === 'undefined') return null\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const handle = ck.GetWebGLContext(canvas)\n if (!handle) return null\n parkingHandles.set(ck, handle)\n return handle\n}\n\n/** Makes the parking context current, so CanvasKit lets go of the one it held. */\nfunction park(ck: CanvasKit): void {\n const parking = parkingHandle(ck)\n if (!parking) return\n try {\n ck.MakeGrContext(parking)?.delete()\n } catch {\n // A browser drops a page's oldest WebGL contexts once it holds too many, as WebKit does after\n // a few tabs, and reports it only later; the parking context is the oldest, so it is the one\n // gone, and CanvasKit fails on it. A new parking context takes its place.\n ck.deleteContext(parking)\n parkingHandles.delete(ck)\n const replacement = parkingHandle(ck)\n if (replacement) ck.MakeGrContext(replacement)?.delete()\n }\n}\n\n/**\n * Unregisters a canvas's WebGL context from CanvasKit. `deleteContext` leaves CanvasKit holding\n * the last current context, which keeps the canvas, and every component its element reaches,\n * alive; when this context was current, a parking context takes its place.\n */\nexport function releaseWebGLContext(\n ck: CanvasKit,\n handle: GLHandle,\n canvas: HTMLCanvasElement | null\n): void {\n const context = canvas ? (canvas.getContext('webgl2') ?? canvas.getContext('webgl')) : null\n const wasCurrent = context !== null && Reflect.get(ck, 'ctx') === context\n ck.deleteContext(handle)\n if (wasCurrent) park(ck)\n}\n\n/** The device pixels a canvas draws per CSS pixel: the display's, at most `maxPixelRatio`. */\nexport function canvasPixelRatio(maxPixelRatio = Number.POSITIVE_INFINITY): number {\n return Math.min(IS_BROWSER ? window.devicePixelRatio || 1 : 1, maxPixelRatio)\n}\n\n/** A canvas's inline size and margins. */\ntype PinnedStyle = Pick<CSSStyleDeclaration, 'width' | 'height' | 'marginLeft' | 'marginTop'>\nconst PINNED_PROPERTIES = ['width', 'height', 'marginLeft', 'marginTop'] as const\n/** Per canvas: the inline style its owner set, and the style sizeCanvas last wrote over it. */\nconst pinnedStyles = new WeakMap<HTMLCanvasElement, { own: PinnedStyle; written: PinnedStyle }>()\n\nfunction inlineStyle(canvas: HTMLCanvasElement): PinnedStyle {\n const { width, height, marginLeft, marginTop } = canvas.style\n return { width, height, marginLeft, marginTop }\n}\n\n/**\n * Puts back the inline style the canvas's owner set, so the page's own sizing is measured. A\n * property that differs from what sizeCanvas last wrote was set by the owner since, and becomes\n * theirs; the others keep the owner's earlier value.\n */\nfunction restoreOwnStyle(canvas: HTMLCanvasElement): void {\n const current = inlineStyle(canvas)\n const pinned = pinnedStyles.get(canvas)\n const own = { ...current }\n if (pinned) {\n for (const property of PINNED_PROPERTIES) {\n if (current[property] === pinned.written[property]) own[property] = pinned.own[property]\n }\n }\n pinnedStyles.set(canvas, { own, written: current })\n Object.assign(canvas.style, own)\n}\n\n/** Records the style sizeCanvas wrote, so a later change by the owner can be told apart. */\nfunction rememberWrittenStyle(canvas: HTMLCanvasElement): void {\n const pinned = pinnedStyles.get(canvas)\n if (pinned) pinnedStyles.set(canvas, { own: pinned.own, written: inlineStyle(canvas) })\n}\n\n/**\n * Sizes the canvas bitmap to the content box the page's CSS gives it, pinned to whole CSS pixels\n * as Figma pins its canvas. A panel sized in percent leaves the box at a fraction of a pixel, and\n * the browser shows a canvas at whole pixels, so its bitmap was stretched by one device pixel\n * across the width, softening every line. The canvas moves under a pixel to the nearest whole\n * one through its margins; pointers map from its box, so they follow. Under a transform, where no\n * snap holds, the canvas takes its layout size rounded and stays where it is. A flex container\n * that centres the canvas moves it by half a margin change, so there the snap can stay a quarter\n * pixel off.\n */\nexport function sizeCanvas(\n canvas: HTMLCanvasElement,\n editor: Editor,\n onViewportResize?: (width: number, height: number) => void,\n maxPixelRatio = Number.POSITIVE_INFINITY\n) {\n const dpr = canvasPixelRatio(maxPixelRatio)\n restoreOwnStyle(canvas)\n const box = canvas.getBoundingClientRect()\n const layout = getComputedStyle(canvas)\n const px = (value: string) => Number.parseFloat(value) || 0\n // Border and padding sit outside the bitmap, which fills the content box.\n const inset = {\n left: px(layout.borderLeftWidth) + px(layout.paddingLeft),\n right: px(layout.borderRightWidth) + px(layout.paddingRight),\n top: px(layout.borderTopWidth) + px(layout.paddingTop),\n bottom: px(layout.borderBottomWidth) + px(layout.paddingBottom)\n }\n const borderBox = layout.boxSizing === 'border-box'\n const outerWidth = (px(layout.width) || box.width) + (borderBox ? 0 : inset.left + inset.right)\n const outerHeight = (px(layout.height) || box.height) + (borderBox ? 0 : inset.top + inset.bottom)\n const transformed =\n Math.abs(outerWidth - box.width) > 0.01 || Math.abs(outerHeight - box.height) > 0.01\n const contentLeft = box.left + inset.left\n const contentTop = box.top + inset.top\n const left = transformed ? contentLeft : Math.round(contentLeft)\n const top = transformed ? contentTop : Math.round(contentTop)\n const width = Math.max(\n 1,\n transformed\n ? Math.round(outerWidth - inset.left - inset.right)\n : Math.round(box.right - inset.right) - left\n )\n const height = Math.max(\n 1,\n transformed\n ? Math.round(outerHeight - inset.top - inset.bottom)\n : Math.round(box.bottom - inset.bottom) - top\n )\n canvas.width = Math.round(width * dpr)\n canvas.height = Math.round(height * dpr)\n canvas.style.width = `${borderBox ? width + inset.left + inset.right : width}px`\n canvas.style.height = `${borderBox ? height + inset.top + inset.bottom : height}px`\n // The margins the page resolves, such as auto for a centred canvas, plus the snap. A translate\n // would leave the bitmap a fraction of a pixel off, which the browser smooths over.\n if (!transformed) {\n canvas.style.marginLeft = `${px(layout.marginLeft) + left - contentLeft}px`\n canvas.style.marginTop = `${px(layout.marginTop) + top - contentTop}px`\n }\n rememberWrittenStyle(canvas)\n if (onViewportResize) {\n onViewportResize(width, height)\n } else if ('setViewportSize' in editor && typeof editor.setViewportSize === 'function') {\n editor.setViewportSize(width, height)\n }\n}\n\nexport function makeGLSurface(\n ck: CanvasKit,\n canvas: HTMLCanvasElement,\n options: UseCanvasOptions | undefined,\n glContext: GLContext | null,\n documentColorSpace: DocumentColorSpace\n): {\n surface: Surface | null\n glContext: GLContext | null\n /**\n * The WebGL context this call registered with CanvasKit, which the caller must release with\n * `deleteContext`: CanvasKit's context table otherwise keeps the canvas, and everything its\n * element reaches, alive. Null when the existing context was reused.\n */\n glHandle: GLHandle | null\n presentation: PresentationColorSpace | null\n} {\n let context = glContext\n const glAttrs = options?.preserveDrawingBuffer ? { preserveDrawingBuffer: 1 } : undefined\n const handle = context ? null : ck.GetWebGLContext(canvas, glAttrs)\n if (!context && !handle) {\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n\n const buffer = canvas.getContext('webgl2') ?? canvas.getContext('webgl')\n const presentation = configurePresentation(buffer, {\n documentColorSpace,\n wideGamutDisplay: IS_BROWSER && supportsWideGamutPresentation(),\n width: canvas.width,\n height: canvas.height\n })\n if (!presentation) {\n if (handle) ck.deleteContext(handle)\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n if (!context && handle) context = ck.MakeGrContext(handle)\n if (!context) {\n if (handle) ck.deleteContext(handle)\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n\n return {\n surface: ck.MakeOnScreenGLSurface(\n context,\n canvas.width,\n canvas.height,\n presentation === 'display-p3' ? ck.ColorS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AE,IAAI,KAAA;CAChF,MAAM,SAAS,UAAU,OAAO,GAAG,gBAAgB,QAAQ,OAAO;CAClE,IAAI,CAAC,WAAW,CAAC,QACf,OAAO;EAAE,SAAS;EAAM,WAAW;EAAS,UAAU;EAAM,cAAc;CAAK;CAGjF,MAAM,SAAS,OAAO,WAAW,QAAQ,KAAK,OAAO,WAAW,OAAO;CACvE,MAAM,eAAe,sBAAsB,QAAQ;EACjD;EACA,kBAAkB,cAAc,8BAA8B;EAC9D,OAAO,OAAO;EACd,QAAQ,OAAO;CACjB,CAAC;CACD,IAAI,CAAC,cAAc;EACjB,IAAI,QAAQ,GAAG,cAAc,MAAM;EACnC,OAAO;GAAE,SAAS;GAAM,WAAW;GAAS,UAAU;GAAM,cAAc;EAAK;CACjF;CACA,IAAI,CAAC,WAAW,QAAQ,UAAU,GAAG,cAAc,MAAM;CACzD,IAAI,CAAC,SAAS;EACZ,IAAI,QAAQ,GAAG,cAAc,MAAM;EACnC,OAAO;GAAE,SAAS;GAAM,WAAW;GAAS,UAAU;GAAM,cAAc;EAAK;CACjF;CAEA,OAAO;EACL,SAAS,GAAG,sBACV,SACA,OAAO,OACP,OAAO,QACP,iBAAiB,eAAe,GAAG,WAAW,aAAa,GAAG,WAAW,IAC3E;EACA,WAAW;EACX,UAAU;EACV;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"gl-surface.js","names":[],"sources":["../../../src/canvas/surface/gl-surface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from 'canvaskit-wasm'\n\nimport type { Editor } from '@pairdraw/core'\nimport { IS_BROWSER } from '@pairdraw/core/constants'\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport type { UseCanvasOptions } from '#vue/canvas/surface/types'\n\nimport {\n configurePresentation,\n supportsWideGamutPresentation,\n type PresentationColorSpace\n} from './color-space'\n\ntype GLContext = ReturnType<CanvasKit['MakeGrContext']>\ntype GLHandle = ReturnType<CanvasKit['GetWebGLContext']>\n\nexport type CanvasGLContext = GLContext\nexport type CanvasGLHandle = GLHandle\n\nconst parkingHandles = new WeakMap<CanvasKit, GLHandle>()\n\n/** A 1×1 offscreen WebGL context that stays registered, so another context can become current. */\nfunction parkingHandle(ck: CanvasKit): GLHandle | null {\n const existing = parkingHandles.get(ck)\n if (existing !== undefined) return existing\n if (typeof document === 'undefined') return null\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const handle = ck.GetWebGLContext(canvas)\n if (!handle) return null\n parkingHandles.set(ck, handle)\n return handle\n}\n\n/** Makes the parking context current, so CanvasKit lets go of the one it held. */\nfunction park(ck: CanvasKit): void {\n const parking = parkingHandle(ck)\n if (!parking) return\n try {\n ck.MakeGrContext(parking)?.delete()\n } catch {\n // A browser drops a page's oldest WebGL contexts once it holds too many, as WebKit does after\n // a few tabs, and reports it only later; the parking context is the oldest, so it is the one\n // gone, and CanvasKit fails on it. A new parking context takes its place.\n ck.deleteContext(parking)\n parkingHandles.delete(ck)\n const replacement = parkingHandle(ck)\n if (replacement) ck.MakeGrContext(replacement)?.delete()\n }\n}\n\n/**\n * Unregisters a canvas's WebGL context from CanvasKit. `deleteContext` leaves CanvasKit holding\n * the last current context, which keeps the canvas, and every component its element reaches,\n * alive; when this context was current, a parking context takes its place.\n */\nexport function releaseWebGLContext(\n ck: CanvasKit,\n handle: GLHandle,\n canvas: HTMLCanvasElement | null\n): void {\n const context = canvas ? (canvas.getContext('webgl2') ?? canvas.getContext('webgl')) : null\n const wasCurrent = context !== null && Reflect.get(ck, 'ctx') === context\n ck.deleteContext(handle)\n if (wasCurrent) park(ck)\n}\n\n/** The device pixels a canvas draws per CSS pixel: the display's, at most `maxPixelRatio`. */\nexport function canvasPixelRatio(maxPixelRatio = Number.POSITIVE_INFINITY): number {\n return Math.min(IS_BROWSER ? window.devicePixelRatio || 1 : 1, maxPixelRatio)\n}\n\n/** A canvas's inline size and margins. */\ntype PinnedStyle = Pick<CSSStyleDeclaration, 'width' | 'height' | 'marginLeft' | 'marginTop'>\nconst PINNED_PROPERTIES = ['width', 'height', 'marginLeft', 'marginTop'] as const\n/** Per canvas: the inline style its owner set, and the style sizeCanvas last wrote over it. */\nconst pinnedStyles = new WeakMap<HTMLCanvasElement, { own: PinnedStyle; written: PinnedStyle }>()\n\nfunction inlineStyle(canvas: HTMLCanvasElement): PinnedStyle {\n const { width, height, marginLeft, marginTop } = canvas.style\n return { width, height, marginLeft, marginTop }\n}\n\n/**\n * Puts back the inline style the canvas's owner set, so the page's own sizing is measured. A\n * property that differs from what sizeCanvas last wrote was set by the owner since, and becomes\n * theirs; the others keep the owner's earlier value.\n */\nfunction restoreOwnStyle(canvas: HTMLCanvasElement): void {\n const current = inlineStyle(canvas)\n const pinned = pinnedStyles.get(canvas)\n const own = { ...current }\n if (pinned) {\n for (const property of PINNED_PROPERTIES) {\n if (current[property] === pinned.written[property]) own[property] = pinned.own[property]\n }\n }\n pinnedStyles.set(canvas, { own, written: current })\n Object.assign(canvas.style, own)\n}\n\n/** Records the style sizeCanvas wrote, so a later change by the owner can be told apart. */\nfunction rememberWrittenStyle(canvas: HTMLCanvasElement): void {\n const pinned = pinnedStyles.get(canvas)\n if (pinned) pinnedStyles.set(canvas, { own: pinned.own, written: inlineStyle(canvas) })\n}\n\n/**\n * Sizes the canvas bitmap to the content box the page's CSS gives it, pinned to whole CSS pixels\n * as Figma pins its canvas. A panel sized in percent leaves the box at a fraction of a pixel, and\n * the browser shows a canvas at whole pixels, so its bitmap was stretched by one device pixel\n * across the width, softening every line. The canvas moves under a pixel to the nearest whole\n * one through its margins; pointers map from its box, so they follow. Under a transform, where no\n * snap holds, the canvas takes its layout size rounded and stays where it is. A flex container\n * that centres the canvas moves it by half a margin change, so there the snap can stay a quarter\n * pixel off. Returns where the content box now starts on screen.\n */\nexport function sizeCanvas(\n canvas: HTMLCanvasElement,\n editor: Editor,\n onViewportResize?: (width: number, height: number) => void,\n maxPixelRatio = Number.POSITIVE_INFINITY\n): Vector {\n const dpr = canvasPixelRatio(maxPixelRatio)\n restoreOwnStyle(canvas)\n const box = canvas.getBoundingClientRect()\n const layout = getComputedStyle(canvas)\n const px = (value: string) => Number.parseFloat(value) || 0\n // Border and padding sit outside the bitmap, which fills the content box.\n const inset = {\n left: px(layout.borderLeftWidth) + px(layout.paddingLeft),\n right: px(layout.borderRightWidth) + px(layout.paddingRight),\n top: px(layout.borderTopWidth) + px(layout.paddingTop),\n bottom: px(layout.borderBottomWidth) + px(layout.paddingBottom)\n }\n const borderBox = layout.boxSizing === 'border-box'\n const outerWidth = (px(layout.width) || box.width) + (borderBox ? 0 : inset.left + inset.right)\n const outerHeight = (px(layout.height) || box.height) + (borderBox ? 0 : inset.top + inset.bottom)\n const transformed =\n Math.abs(outerWidth - box.width) > 0.01 || Math.abs(outerHeight - box.height) > 0.01\n const contentLeft = box.left + inset.left\n const contentTop = box.top + inset.top\n const left = transformed ? contentLeft : Math.round(contentLeft)\n const top = transformed ? contentTop : Math.round(contentTop)\n const width = Math.max(\n 1,\n transformed\n ? Math.round(outerWidth - inset.left - inset.right)\n : Math.round(box.right - inset.right) - left\n )\n const height = Math.max(\n 1,\n transformed\n ? Math.round(outerHeight - inset.top - inset.bottom)\n : Math.round(box.bottom - inset.bottom) - top\n )\n canvas.width = Math.round(width * dpr)\n canvas.height = Math.round(height * dpr)\n canvas.style.width = `${borderBox ? width + inset.left + inset.right : width}px`\n canvas.style.height = `${borderBox ? height + inset.top + inset.bottom : height}px`\n // The margins the page resolves, such as auto for a centred canvas, plus the snap. A translate\n // would leave the bitmap a fraction of a pixel off, which the browser smooths over.\n if (!transformed) {\n canvas.style.marginLeft = `${px(layout.marginLeft) + left - contentLeft}px`\n canvas.style.marginTop = `${px(layout.marginTop) + top - contentTop}px`\n }\n rememberWrittenStyle(canvas)\n if (onViewportResize) {\n onViewportResize(width, height)\n } else if ('setViewportSize' in editor && typeof editor.setViewportSize === 'function') {\n editor.setViewportSize(width, height)\n }\n return { x: left, y: top }\n}\n\nexport function makeGLSurface(\n ck: CanvasKit,\n canvas: HTMLCanvasElement,\n options: UseCanvasOptions | undefined,\n glContext: GLContext | null,\n documentColorSpace: DocumentColorSpace\n): {\n surface: Surface | null\n glContext: GLContext | null\n /**\n * The WebGL context this call registered with CanvasKit, which the caller must release with\n * `deleteContext`: CanvasKit's context table otherwise keeps the canvas, and everything its\n * element reaches, alive. Null when the existing context was reused.\n */\n glHandle: GLHandle | null\n presentation: PresentationColorSpace | null\n} {\n let context = glContext\n const glAttrs = options?.preserveDrawingBuffer ? { preserveDrawingBuffer: 1 } : undefined\n const handle = context ? null : ck.GetWebGLContext(canvas, glAttrs)\n if (!context && !handle) {\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n\n const buffer = canvas.getContext('webgl2') ?? canvas.getContext('webgl')\n const presentation = configurePresentation(buffer, {\n documentColorSpace,\n wideGamutDisplay: IS_BROWSER && supportsWideGamutPresentation(),\n width: canvas.width,\n height: canvas.height\n })\n if (!presentation) {\n if (handle) ck.deleteContext(handle)\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n if (!context && handle) context = ck.MakeGrContext(handle)\n if (!context) {\n if (handle) ck.deleteContext(handle)\n return { surface: null, glContext: context, glHandle: null, presentation: null }\n }\n\n return {\n surface: ck.MakeOnScreenGLSurface(\n context,\n canvas.width,\n canvas.height,\n presentation === 'display-p3' ? ck.ColorSpace.DISPLAY_P3 : ck.ColorSpace.SRGB\n ),\n glContext: context,\n glHandle: handle,\n presentation\n }\n}\n"],"mappings":";;;AAqBA,MAAM,iCAAiB,IAAI,QAA6B;;AAGxD,SAAS,cAAc,IAAgC;CACrD,MAAM,WAAW,eAAe,IAAI,EAAE;CACtC,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,OAAO,QAAQ;CACf,OAAO,SAAS;CAChB,MAAM,SAAS,GAAG,gBAAgB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QAAQ,OAAO;CACjB,CAAC;CACD,IAAI,CAAC,cAAc;EACjB,IAAI,QAAQ,GAAG,cAAc,MAAM;EACnC,OAAO;GAAE,SAAS;GAAM,WAAW;GAAS,UAAU;GAAM,cAAc;EAAK;CACjF;CACA,IAAI,CAAC,WAAW,QAAQ,UAAU,GAAG,cAAc,MAAM;CACzD,IAAI,CAAC,SAAS;EACZ,IAAI,QAAQ,GAAG,cAAc,MAAM;EACnC,OAAO;GAAE,SAAS;GAAM,WAAW;GAAS,UAAU;GAAM,cAAc;EAAK;CACjF;CAEA,OAAO;EACL,SAAS,GAAG,sBACV,SACA,OAAO,OACP,OAAO,QACP,iBAAiB,eAAe,GAAG,WAAW,aAAa,GAAG,WAAW,IAC3E;EACA,WAAW;EACX,UAAU;EACV;CACF;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nextFrame } from "../../shared/frame.js";
|
|
1
2
|
import { onScopeDispose, watch } from "vue";
|
|
2
3
|
import { getCanvasKit } from "@pairdraw/core/canvaskit";
|
|
3
4
|
//#region src/canvas/surface/kit-loader.ts
|
|
@@ -9,9 +10,7 @@ function useCanvasKitLoader({ canvasRef, lifecycle, setCanvasKit, createSurface,
|
|
|
9
10
|
if (!stillCurrent()) return;
|
|
10
11
|
setCanvasKit(await loadCanvasKit());
|
|
11
12
|
if (!stillCurrent()) return;
|
|
12
|
-
await
|
|
13
|
-
requestAnimationFrame(resolve);
|
|
14
|
-
});
|
|
13
|
+
await nextFrame();
|
|
15
14
|
if (!stillCurrent()) return;
|
|
16
15
|
if (!createSurface(canvas)) throw new Error("WebGL is unavailable, so the canvas cannot draw");
|
|
17
16
|
await loadFonts();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit-loader.js","names":[],"sources":["../../../src/canvas/surface/kit-loader.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\nimport { onScopeDispose, watch } from 'vue'\nimport type { Ref } from 'vue'\n\nimport { getCanvasKit } from '@pairdraw/core/canvaskit'\n\ntype CanvasKitLoaderOptions = {\n canvasRef: Ref<HTMLCanvasElement | null>\n lifecycle: { destroyed: boolean }\n setCanvasKit: (ck: CanvasKit | null) => void\n /** Whether a surface the canvas can draw on was made. */\n createSurface: (canvas: HTMLCanvasElement) => boolean\n loadFonts: () => Promise<unknown> | undefined\n renderNow: () => void\n onReady?: () => void\n onFailed?: (error: unknown) => void\n /**\n * Loads CanvasKit. Tests pass a stand-in; the canvas uses the shared loader.\n * A default keeps the unit test from downloading the WASM module.\n */\n loadCanvasKit?: () => Promise<CanvasKit>\n}\n\nexport function useCanvasKitLoader({\n canvasRef,\n lifecycle,\n setCanvasKit,\n createSurface,\n loadFonts,\n renderNow,\n onReady,\n onFailed,\n loadCanvasKit = getCanvasKit\n}: CanvasKitLoaderOptions) {\n const isDestroyed = () => lifecycle.destroyed\n // Bumped when a new element arrives, so a start still in flight cannot make a surface\n // on a canvas that has already been replaced.\n let generation = 0\n\n async function init(canvas: HTMLCanvasElement, generationAtStart: number) {\n const stillCurrent = () =>\n !isDestroyed() && canvasRef.value === canvas && generation === generationAtStart\n\n if (!stillCurrent()) return\n\n setCanvasKit(await loadCanvasKit())\n if (!stillCurrent()) return\n\n await
|
|
1
|
+
{"version":3,"file":"kit-loader.js","names":[],"sources":["../../../src/canvas/surface/kit-loader.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\nimport { onScopeDispose, watch } from 'vue'\nimport type { Ref } from 'vue'\n\nimport { getCanvasKit } from '@pairdraw/core/canvaskit'\n\nimport { nextFrame } from '#vue/shared/frame'\n\ntype CanvasKitLoaderOptions = {\n canvasRef: Ref<HTMLCanvasElement | null>\n lifecycle: { destroyed: boolean }\n setCanvasKit: (ck: CanvasKit | null) => void\n /** Whether a surface the canvas can draw on was made. */\n createSurface: (canvas: HTMLCanvasElement) => boolean\n loadFonts: () => Promise<unknown> | undefined\n renderNow: () => void\n onReady?: () => void\n onFailed?: (error: unknown) => void\n /**\n * Loads CanvasKit. Tests pass a stand-in; the canvas uses the shared loader.\n * A default keeps the unit test from downloading the WASM module.\n */\n loadCanvasKit?: () => Promise<CanvasKit>\n}\n\nexport function useCanvasKitLoader({\n canvasRef,\n lifecycle,\n setCanvasKit,\n createSurface,\n loadFonts,\n renderNow,\n onReady,\n onFailed,\n loadCanvasKit = getCanvasKit\n}: CanvasKitLoaderOptions) {\n const isDestroyed = () => lifecycle.destroyed\n // Bumped when a new element arrives, so a start still in flight cannot make a surface\n // on a canvas that has already been replaced.\n let generation = 0\n\n async function init(canvas: HTMLCanvasElement, generationAtStart: number) {\n const stillCurrent = () =>\n !isDestroyed() && canvasRef.value === canvas && generation === generationAtStart\n\n if (!stillCurrent()) return\n\n setCanvasKit(await loadCanvasKit())\n if (!stillCurrent()) return\n\n await nextFrame()\n if (!stillCurrent()) return\n if (!createSurface(canvas)) throw new Error('WebGL is unavailable, so the canvas cannot draw')\n await loadFonts()\n if (!stillCurrent()) return\n renderNow()\n onReady?.()\n }\n\n function start(canvas: HTMLCanvasElement) {\n const generationAtStart = ++generation\n void init(canvas, generationAtStart).catch((error: unknown) => {\n if (!onFailed) throw error\n if (!isDestroyed() && generation === generationAtStart) onFailed(error)\n })\n }\n\n // A CanvasSurface child hands its element over after the root has mounted, so waiting for\n // mount alone would find none. The app replaces the element when the browser keeps a context\n // lost, and that new element has to start too: watching once would leave it blank. The same\n // element does not start again.\n watch(\n canvasRef,\n (canvas, previous) => {\n if (!canvas || canvas === previous) return\n start(canvas)\n },\n { flush: 'post', immediate: true }\n )\n\n onScopeDispose(() => {\n lifecycle.destroyed = true\n generation += 1\n })\n}\n"],"mappings":";;;;AAyBA,SAAgB,mBAAmB,EACjC,WACA,WACA,cACA,eACA,WACA,WACA,SACA,UACA,gBAAgB,gBACS;CACzB,MAAM,oBAAoB,UAAU;CAGpC,IAAI,aAAa;CAEjB,eAAe,KAAK,QAA2B,mBAA2B;EACxE,MAAM,qBACJ,CAAC,YAAY,KAAK,UAAU,UAAU,UAAU,eAAe;EAEjE,IAAI,CAAC,aAAa,GAAG;EAErB,aAAa,MAAM,cAAc,CAAC;EAClC,IAAI,CAAC,aAAa,GAAG;EAErB,MAAM,UAAU;EAChB,IAAI,CAAC,aAAa,GAAG;EACrB,IAAI,CAAC,cAAc,MAAM,GAAG,MAAM,IAAI,MAAM,iDAAiD;EAC7F,MAAM,UAAU;EAChB,IAAI,CAAC,aAAa,GAAG;EACrB,UAAU;EACV,UAAU;CACZ;CAEA,SAAS,MAAM,QAA2B;EACxC,MAAM,oBAAoB,EAAE;EAC5B,KAAU,QAAQ,iBAAiB,CAAC,CAAC,OAAO,UAAmB;GAC7D,IAAI,CAAC,UAAU,MAAM;GACrB,IAAI,CAAC,YAAY,KAAK,eAAe,mBAAmB,SAAS,KAAK;EACxE,CAAC;CACH;CAMA,MACE,YACC,QAAQ,aAAa;EACpB,IAAI,CAAC,UAAU,WAAW,UAAU;EACpC,MAAM,MAAM;CACd,GACA;EAAE,OAAO;EAAQ,WAAW;CAAK,CACnC;CAEA,qBAAqB;EACnB,UAAU,YAAY;EACtB,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -2,13 +2,24 @@ import { supportsWideGamutPresentation } from "./color-space.js";
|
|
|
2
2
|
import { makeGLSurface, releaseWebGLContext, sizeCanvas } from "./gl-surface.js";
|
|
3
3
|
import { createImagePreviewDecoder } from "./image-preview.js";
|
|
4
4
|
import { useCanvasKitLoader } from "./kit-loader.js";
|
|
5
|
+
import { createCanvasOriginTracker } from "./origin.js";
|
|
5
6
|
import { createCanvasRenderLoop } from "./render-loop.js";
|
|
6
7
|
import { useCanvasResizeObserver } from "./resize-observer.js";
|
|
7
8
|
import { createShaderRasterizer } from "./shader/rasterizer.js";
|
|
8
9
|
import { editorMessages } from "../../i18n/messages/editor.js";
|
|
9
10
|
import { onScopeDispose, watch } from "vue";
|
|
11
|
+
import { useDocumentVisibility } from "@vueuse/core";
|
|
10
12
|
import { SkiaRenderer } from "@pairdraw/core/canvas";
|
|
11
13
|
//#region src/canvas/surface/lifecycle.ts
|
|
14
|
+
/**
|
|
15
|
+
* The device's memory in bytes where the browser reports it. Browsers round it and stop at 8 GB,
|
|
16
|
+
* which means at least that much, so a device at the cap is treated as unknown.
|
|
17
|
+
*/
|
|
18
|
+
function reportedDeviceMemory() {
|
|
19
|
+
const gigabytes = Reflect.get(navigator, "deviceMemory");
|
|
20
|
+
if (typeof gigabytes !== "number" || gigabytes >= 8) return void 0;
|
|
21
|
+
return gigabytes * 1024 ** 3;
|
|
22
|
+
}
|
|
12
23
|
/** What a canvas asks of its renderer: its layer, renderer mode, pixel density, and effects. */
|
|
13
24
|
function applyRenderOptions(renderer, options) {
|
|
14
25
|
renderer.tracksSceneSettlement = options?.layer !== "overlays";
|
|
@@ -17,11 +28,18 @@ function applyRenderOptions(renderer, options) {
|
|
|
17
28
|
renderer.reducedEffects = options?.reducedEffects ?? false;
|
|
18
29
|
renderer.onNodeDrawFailure = options?.onNodeDrawFailure ?? null;
|
|
19
30
|
}
|
|
20
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Shows only the scope layer the canvas asks for, or the whole page when it asks for none, with
|
|
33
|
+
* the frames a playing prototype changed drawn from their play scenes, scrolled as play scrolled
|
|
34
|
+
* them.
|
|
35
|
+
*/
|
|
21
36
|
function applySceneScope(renderer, options) {
|
|
22
37
|
renderer.sceneScopeId = options?.getSceneScope?.() ?? null;
|
|
38
|
+
renderer.playScenes = options?.getPlayScenes?.() ?? null;
|
|
39
|
+
renderer.playScroll = options?.getPlayScroll?.() ?? null;
|
|
23
40
|
}
|
|
24
41
|
function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit, isDestroyed, shouldShowRulers }) {
|
|
42
|
+
const origin = createCanvasOriginTracker(options?.onViewportMove);
|
|
25
43
|
const state = {
|
|
26
44
|
renderer: null,
|
|
27
45
|
glContext: null,
|
|
@@ -44,6 +62,16 @@ function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit,
|
|
|
44
62
|
renderer.connectorLabelPlaceholder = connectorLabelPlaceholder;
|
|
45
63
|
if (showsStickyPlaceholder) renderer.stickyPlaceholder = stickyPlaceholder;
|
|
46
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Tells the renderer's tiles what memory they share: a share of the device's where the browser
|
|
67
|
+
* reports it, and only what the canvas showed last while the page is hidden.
|
|
68
|
+
*/
|
|
69
|
+
function applyTileMemory() {
|
|
70
|
+
state.renderer?.tiledScene.setMemory({
|
|
71
|
+
deviceBytes: reportedDeviceMemory(),
|
|
72
|
+
hidden: document.visibilityState === "hidden"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
47
75
|
function clearSceneBackingRenderTimer() {
|
|
48
76
|
if (sceneBackingRenderTimer === null) return;
|
|
49
77
|
clearTimeout(sceneBackingRenderTimer);
|
|
@@ -65,7 +93,7 @@ function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit,
|
|
|
65
93
|
state.renderer?.destroy();
|
|
66
94
|
state.renderer = null;
|
|
67
95
|
releaseGLContext();
|
|
68
|
-
sizeCanvas(canvas, editor, options?.onViewportResize, options?.maxPixelRatio);
|
|
96
|
+
origin.place(sizeCanvas(canvas, editor, options?.onViewportResize, options?.maxPixelRatio));
|
|
69
97
|
const result = makeGLSurface(ck, canvas, options, state.glContext, editor.graph.documentColorSpace);
|
|
70
98
|
state.glContext = result.glContext;
|
|
71
99
|
state.glHandle = result.glHandle;
|
|
@@ -84,6 +112,7 @@ function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit,
|
|
|
84
112
|
state.renderer.presentationColorSpace = result.presentation ?? "srgb";
|
|
85
113
|
applyRenderOptions(state.renderer, options);
|
|
86
114
|
showPlaceholders(state.renderer);
|
|
115
|
+
applyTileMemory();
|
|
87
116
|
editor.setCanvasKit(ck, state.renderer);
|
|
88
117
|
if (options?.layer !== "overlays" && !editor.hasShaderRasterizer()) editor.setShaderRasterizer(createShaderRasterizer());
|
|
89
118
|
canvas.dataset.ready = "1";
|
|
@@ -129,7 +158,7 @@ function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit,
|
|
|
129
158
|
createSurface(canvas);
|
|
130
159
|
return;
|
|
131
160
|
}
|
|
132
|
-
sizeCanvas(canvas, editor, options?.onViewportResize, options?.maxPixelRatio);
|
|
161
|
+
origin.place(sizeCanvas(canvas, editor, options?.onViewportResize, options?.maxPixelRatio));
|
|
133
162
|
const result = makeGLSurface(ck, canvas, options, state.glContext, editor.graph.documentColorSpace);
|
|
134
163
|
state.glContext = result.glContext;
|
|
135
164
|
state.presentation = result.presentation;
|
|
@@ -171,6 +200,7 @@ function createCanvasSurfaceManager({ editor, canvasRef, options, getCanvasKit,
|
|
|
171
200
|
renderNow,
|
|
172
201
|
destroy,
|
|
173
202
|
markDirty: () => renderLoop.markDirty(),
|
|
203
|
+
applyTileMemory,
|
|
174
204
|
getRenderer: () => state.renderer,
|
|
175
205
|
getPresentation: () => state.presentation
|
|
176
206
|
};
|
|
@@ -223,6 +253,7 @@ function useCanvasSurfaceLifecycle({ canvasRef, surface, setCanvasKit, getCanvas
|
|
|
223
253
|
getCanvasKitValue,
|
|
224
254
|
resizeCanvas: surface.resizeCanvas
|
|
225
255
|
});
|
|
256
|
+
watch(useDocumentVisibility(), () => surface.applyTileMemory());
|
|
226
257
|
onScopeDispose(() => {
|
|
227
258
|
lifecycle.destroyed = true;
|
|
228
259
|
cancelResize();
|