@pairdraw/vue 0.20.0 → 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 +3 -0
- package/dist/canvas/CanvasRoot.vue.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/lifecycle.js +4 -2
- 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 +16 -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/useCanvasInput.d.ts +8 -8
- 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 -2
- package/dist/controls/document-colors/index.js +2 -2
- package/dist/controls/document-colors/use.d.ts +7 -1
- package/dist/controls/document-colors/use.d.ts.map +1 -1
- package/dist/controls/document-colors/use.js +9 -1
- package/dist/controls/document-colors/use.js.map +1 -1
- package/dist/controls/node-props/use.d.ts +3 -3
- package/dist/controls/okhcl/use.d.ts +2 -2
- package/dist/controls/position/use.d.ts +1 -1
- 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/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/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/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 +15 -0
- package/dist/i18n/locales/de/comments.json.js +1 -1
- package/dist/i18n/locales/de/panels.json.js +16 -1
- package/dist/i18n/locales/es/ai.json.js +15 -0
- package/dist/i18n/locales/es/comments.json.js +1 -1
- package/dist/i18n/locales/es/panels.json.js +16 -1
- package/dist/i18n/locales/fr/ai.json.js +15 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -1
- package/dist/i18n/locales/fr/panels.json.js +16 -1
- 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 +15 -0
- package/dist/i18n/locales/it/comments.json.js +1 -1
- package/dist/i18n/locales/it/panels.json.js +16 -1
- package/dist/i18n/locales/ja/ai.json.js +15 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -1
- package/dist/i18n/locales/ja/panels.json.js +16 -1
- package/dist/i18n/locales/pl/ai.json.js +15 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -1
- package/dist/i18n/locales/pl/panels.json.js +16 -1
- package/dist/i18n/locales/ru/ai.json.js +15 -0
- package/dist/i18n/locales/ru/comments.json.js +1 -1
- package/dist/i18n/locales/ru/panels.json.js +16 -1
- package/dist/i18n/locales/zh-cn/ai.json.js +15 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -1
- package/dist/i18n/locales/zh-cn/panels.json.js +16 -1
- package/dist/i18n/messages/ai.d.ts +33 -0
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +17 -0
- package/dist/i18n/messages/ai.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/panels.d.ts +17 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +15 -0
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages.d.ts +49 -1
- package/dist/i18n/useI18n.d.ts +196 -4
- package/dist/i18n/useI18n.d.ts.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 +6 -0
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +3 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- 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/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 +7 -2
- 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/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","names":[],"sources":["../../../src/controls/shader/gallery.ts"],"sourcesContent":["import { isEqual, uniq } from 'es-toolkit'\n\nimport type { ShaderPreset } from '@pairdraw/scene-graph/shaders'\n\n/**\n * Complete shaders a shader paint can start from in one click: each stacks a texture with the\n * filters and overlays that finish it, flat at the top level so the picker lists and edits every\n * effect. Colors are written out rather than left to the library's defaults, so a gallery that\n * cannot draw shaders still shows each one's palette.\n */\n\n/** The shaders the gallery offers, by the name the app translates. */\nexport type ShaderGalleryId =\n | 'sunset'\n | 'northernLights'\n | 'retroScreen'\n | 'halftonePrint'\n | 'ditheredDusk'\n | 'glassOrb'\n | 'marble'\n | 'neonGrid'\n | 'velvet'\n\nexport interface ShaderGalleryEntry {\n id: ShaderGalleryId\n preset: ShaderPreset\n}\n\n/** The gallery in the order it is shown. */\nexport const SHADER_GALLERY: readonly ShaderGalleryEntry[] = [\n {\n id: 'sunset',\n preset: {\n components: [\n {\n type: 'MeshGradient',\n props: {\n stops: [\n { color: '#1b0b3a', position: 0 },\n { color: '#7b2cbf', position: 0.3 },\n { color: '#ff5b2e', position: 0.6 },\n { color: '#ff9e44', position: 0.8 },\n { color: '#ffd98e', position: 1 }\n ],\n seed: 12\n }\n },\n { type: 'FilmGrain', props: { strength: 0.2 } }\n ]\n }\n },\n {\n id: 'northernLights',\n preset: {\n components: [\n { type: 'SolidColor', props: { color: '#04101f' } },\n {\n type: 'Aurora',\n props: { colorA: '#7c3aed', colorB: '#22ee88', colorC: '#1694e8', intensity: 85 }\n },\n { type: 'FilmGrain', props: { strength: 0.15 } }\n ]\n }\n },\n {\n id: 'retroScreen',\n preset: {\n components: [\n { type: 'Plasma', props: { colorA: '#ff2e88', colorB: '#120024' } },\n { type: 'CRTScreen', props: { pixelSize: 96, scanlineIntensity: 0.45 } }\n ]\n }\n },\n {\n id: 'halftonePrint',\n preset: {\n components: [\n { type: 'Swirl', props: { colorA: '#1d4ed8', colorB: '#f97316' } },\n { type: 'Halftone', props: { style: 'cmyk', frequency: 80 } }\n ]\n }\n },\n {\n id: 'ditheredDusk',\n preset: {\n components: [\n {\n type: 'FlowingGradient',\n props: { colorA: '#0b1026', colorB: '#3b1d6e', colorC: '#ff5b2e', colorD: '#ffc46b' }\n },\n { type: 'Dither', props: { pattern: 'bayer8', pixelSize: 3, colorMode: 'source' } }\n ]\n }\n },\n {\n id: 'glassOrb',\n preset: {\n components: [\n {\n type: 'MeshGradient',\n props: {\n stops: [\n { color: '#0f172a', position: 0 },\n { color: '#2563eb', position: 0.4 },\n { color: '#22d3ee', position: 0.75 },\n { color: '#a7f3d0', position: 1 }\n ],\n seed: 4\n }\n },\n { type: 'Glass', props: { refraction: 1.2, aberration: 0.6 } }\n ]\n }\n },\n {\n id: 'marble',\n preset: {\n components: [\n { type: 'Marble', props: { colorA: '#f5f5f4', colorB: '#57534e', colorC: '#0c0a09' } },\n { type: 'Vignette', props: { intensity: 0.6 } }\n ]\n }\n },\n {\n id: 'neonGrid',\n preset: {\n components: [\n { type: 'SolidColor', props: { color: '#0a0614' } },\n { type: 'Grid', props: { color: '#ff2ea6', cells: 12, thickness: 2, softness: 0.2 } },\n { type: 'Glow', props: { intensity: 6, threshold: 0.3, size: 30 } }\n ]\n }\n },\n {\n id: 'velvet',\n preset: {\n components: [\n { type: 'Satin', props: { color: '#7f1d3a', highlightColor: '#e8798f' } },\n { type: 'LightLeak', props: { intensity: 0.25 } },\n { type: 'FilmGrain', props: { strength: 0.2 } }\n ]\n }\n }\n]\n\n/** The gallery shader `preset` is, unchanged; null once any of its effects was edited. */\nexport function shaderGalleryEntryOf(preset: ShaderPreset): ShaderGalleryEntry | null {\n return SHADER_GALLERY.find((entry) => isEqual(entry.preset, preset)) ?? null\n}\n\nconst HEX_COLOR = /^#(?:[\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/i\n\nfunction colorsIn(value: unknown): string[] {\n if (typeof value === 'string') return HEX_COLOR.test(value) ? [value.toLowerCase()] : []\n if (Array.isArray(value)) return value.flatMap(colorsIn)\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(colorsIn)\n return []\n}\n\n/**\n * The colors `preset` sets, in the order its effects draw, without repeats and at most `limit` of\n * them: a palette that stands in for the shader where it cannot be drawn.\n */\nexport function shaderPresetColors(preset: ShaderPreset, limit = 4): string[] {\n const colors = preset.components.flatMap((component) => colorsIn(component.props))\n return uniq(colors).slice(0, limit)\n}\n"],"mappings":";;;AA6BA,MAAa,iBAAgD;CAC3D;EACE,IAAI;EACJ,QAAQ,EACN,YAAY,CACV;GACE,MAAM;GACN,OAAO;IACL,OAAO;KACL;MAAE,OAAO;MAAW,UAAU;KAAE;KAChC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;MAAE,OAAO;MAAW,UAAU;KAAE;IAClC;IACA,MAAM;GACR;EACF,GACA;GAAE,MAAM;GAAa,OAAO,EAAE,UAAU,GAAI;EAAE,CAChD,EACF;CACF;CACA;EACE,IAAI;EACJ,QAAQ,EACN,YAAY;GACV;IAAE,MAAM;IAAc,OAAO,EAAE,OAAO,UAAU;GAAE;GAClD;IACE,MAAM;IACN,OAAO;KAAE,QAAQ;KAAW,QAAQ;KAAW,Q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,IAAI;EACJ,QAAQ,EACN,YAAY;GACV;IAAE,MAAM;IAAc,OAAO,EAAE,OAAO,UAAU;GAAE;GAClD;IAAE,MAAM;IAAQ,OAAO;KAAE,OAAO;KAAW,OAAO;KAAI,WAAW;KAAG,UAAU;IAAI;GAAE;GACpF;IAAE,MAAM;IAAQ,OAAO;KAAE,WAAW;KAAG,WAAW;KAAK,MAAM;IAAG;GAAE;EACpE,EACF;CACF;CACA;EACE,IAAI;EACJ,QAAQ,EACN,YAAY;GACV;IAAE,MAAM;IAAS,OAAO;KAAE,OAAO;KAAW,gBAAgB;IAAU;GAAE;GACxE;IAAE,MAAM;IAAa,OAAO,EAAE,WAAW,IAAK;GAAE;GAChD;IAAE,MAAM;IAAa,OAAO,EAAE,UAAU,GAAI;GAAE;EAChD,EACF;CACF;AACF;;AAGA,SAAgB,qBAAqB,QAAiD;CACpF,OAAO,eAAe,MAAM,UAAU,QAAQ,MAAM,QAAQ,MAAM,CAAC,KAAK;AAC1E;AAEA,MAAM,YAAY;AAElB,SAAS,SAAS,OAA0B;CAC1C,IAAI,OAAO,UAAU,UAAU,OAAO,UAAU,KAAK,KAAK,IAAI,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC;CACvF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,QAAQ,QAAQ;CACvD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,QAAQ,QAAQ;CAC7F,OAAO,CAAC;AACV;;;;;AAMA,SAAgB,mBAAmB,QAAsB,QAAQ,GAAa;CAC5E,MAAM,SAAS,OAAO,WAAW,SAAS,cAAc,SAAS,UAAU,KAAK,CAAC;CACjF,OAAO,KAAK,MAAM,CAAC,CAAC,MAAM,GAAG,KAAK;AACpC"}
|
|
1
|
+
{"version":3,"file":"gallery.js","names":[],"sources":["../../../src/controls/shader/gallery.ts"],"sourcesContent":["import { isEqual, uniq } from 'es-toolkit'\n\nimport type { ShaderPreset } from '@pairdraw/scene-graph/shaders'\n\n/**\n * Complete shaders a shader paint can start from in one click: each stacks a texture with the\n * filters and overlays that finish it, flat at the top level so the picker lists and edits every\n * effect. Colors are written out rather than left to the library's defaults, so a gallery that\n * cannot draw shaders still shows each one's palette.\n */\n\n/** The shaders the gallery offers, by the name the app translates. */\nexport type ShaderGalleryId =\n | 'sunset'\n | 'northernLights'\n | 'retroScreen'\n | 'halftonePrint'\n | 'ditheredDusk'\n | 'glassOrb'\n | 'marble'\n | 'neonGrid'\n | 'velvet'\n | 'liquidChrome'\n | 'flutedGlass'\n | 'paperStock'\n | 'godRays'\n | 'thermal'\n | 'voronoiCells'\n | 'deepWater'\n | 'smokePlume'\n | 'neonPulse'\n | 'grainWash'\n | 'obsidian'\n | 'marbleInk'\n\nexport interface ShaderGalleryEntry {\n id: ShaderGalleryId\n preset: ShaderPreset\n}\n\n/** The gallery in the order it is shown. */\nexport const SHADER_GALLERY: readonly ShaderGalleryEntry[] = [\n {\n id: 'sunset',\n preset: {\n components: [\n {\n type: 'MeshGradient',\n props: {\n stops: [\n { color: '#1b0b3a', position: 0 },\n { color: '#7b2cbf', position: 0.3 },\n { color: '#ff5b2e', position: 0.6 },\n { color: '#ff9e44', position: 0.8 },\n { color: '#ffd98e', position: 1 }\n ],\n seed: 12\n }\n },\n { type: 'FilmGrain', props: { strength: 0.2 } }\n ]\n }\n },\n {\n id: 'northernLights',\n preset: {\n components: [\n { type: 'SolidColor', props: { color: '#04101f' } },\n {\n type: 'Aurora',\n props: { colorA: '#7c3aed', colorB: '#22ee88', colorC: '#1694e8', intensity: 85 }\n },\n { type: 'FilmGrain', props: { strength: 0.15 } }\n ]\n }\n },\n {\n id: 'retroScreen',\n preset: {\n components: [\n { type: 'Plasma', props: { colorA: '#ff2e88', colorB: '#120024' } },\n { type: 'CRTScreen', props: { pixelSize: 96, scanlineIntensity: 0.45 } }\n ]\n }\n },\n {\n id: 'halftonePrint',\n preset: {\n components: [\n { type: 'Swirl', props: { colorA: '#1d4ed8', colorB: '#f97316' } },\n { type: 'Halftone', props: { style: 'cmyk', frequency: 80 } }\n ]\n }\n },\n {\n id: 'ditheredDusk',\n preset: {\n components: [\n {\n type: 'FlowingGradient',\n props: { colorA: '#0b1026', colorB: '#3b1d6e', colorC: '#ff5b2e', colorD: '#ffc46b' }\n },\n { type: 'Dither', props: { pattern: 'bayer8', pixelSize: 3, colorMode: 'source' } }\n ]\n }\n },\n {\n id: 'glassOrb',\n preset: {\n components: [\n {\n type: 'MeshGradient',\n props: {\n stops: [\n { color: '#0f172a', position: 0 },\n { color: '#2563eb', position: 0.4 },\n { color: '#22d3ee', position: 0.75 },\n { color: '#a7f3d0', position: 1 }\n ],\n seed: 4\n }\n },\n { type: 'Glass', props: { refraction: 1.2, aberration: 0.6 } }\n ]\n }\n },\n {\n id: 'marble',\n preset: {\n components: [\n { type: 'Marble', props: { colorA: '#f5f5f4', colorB: '#57534e', colorC: '#0c0a09' } },\n { type: 'Vignette', props: { intensity: 0.6 } }\n ]\n }\n },\n {\n id: 'neonGrid',\n preset: {\n components: [\n { type: 'SolidColor', props: { color: '#0a0614' } },\n { type: 'Grid', props: { color: '#ff2ea6', cells: 12, thickness: 2, softness: 0.2 } },\n { type: 'Glow', props: { intensity: 6, threshold: 0.3, size: 30 } }\n ]\n }\n },\n {\n id: 'velvet',\n preset: {\n components: [\n { type: 'Satin', props: { color: '#7f1d3a', highlightColor: '#e8798f' } },\n { type: 'LightLeak', props: { intensity: 0.25 } },\n { type: 'FilmGrain', props: { strength: 0.2 } }\n ]\n }\n },\n {\n id: 'liquidChrome',\n preset: {\n components: [\n {\n type: 'LiquidMetal',\n props: {\n lightColor: '#f5f7fa',\n darkColor: '#1c1f26',\n turbulence: 0.55,\n ripple: 1.2,\n sharpness: 0.8,\n dispersion: 0.25,\n speed: 0.35\n }\n },\n { type: 'FilmGrain', props: { strength: 0.08, bias: 0.04 } }\n ]\n }\n },\n {\n id: 'flutedGlass',\n preset: {\n components: [\n {\n type: 'FlowingGradient',\n props: {\n colorA: '#0f1b2d',\n colorB: '#1f4b6e',\n colorC: '#8fd3ff',\n colorD: '#f5f9ff',\n distortion: 0.7,\n speed: 0.2\n }\n },\n {\n type: 'FlutedGlass',\n props: {\n frequency: 18,\n refraction: 0.6,\n aberration: 0.3,\n highlight: 0.5,\n edges: 'mirror',\n speed: 0.2\n }\n }\n ]\n }\n },\n {\n id: 'paperStock',\n preset: {\n components: [\n {\n type: 'FlowingGradient',\n props: { colorA: '#efe7d8', colorB: '#e2d6c2', distortion: 0.2, speed: 0 }\n },\n {\n type: 'Paper',\n props: { roughness: 0.65, grainScale: 0.8, displacement: 0.25, seed: 7 }\n }\n ]\n }\n },\n {\n id: 'godRays',\n preset: {\n components: [\n {\n type: 'Godrays',\n props: {\n rayColor: '#ffe9b0',\n backgroundColor: '#0b0a12',\n density: 0.7,\n intensity: 0.9,\n spotty: 0.3,\n speed: 0.15\n }\n },\n { type: 'FilmGrain', props: { strength: 0.12 } }\n ]\n }\n },\n {\n id: 'thermal',\n preset: {\n components: [\n {\n type: 'Heatmap',\n props: {\n colorA: '#08131f',\n colorB: '#f7f3cf',\n stops: [\n { color: '#08131f', position: 0 },\n { color: '#1d6fb8', position: 0.3 },\n { color: '#f2d21a', position: 0.55 },\n { color: '#f08a24', position: 0.78 },\n { color: '#e0212f', position: 1 }\n ],\n innerGlow: 0.6,\n outerGlow: 0.4,\n contour: 0.2,\n speed: 0.3\n }\n },\n { type: 'FilmGrain', props: { strength: 0.06 } }\n ]\n }\n },\n {\n id: 'voronoiCells',\n preset: {\n components: [\n {\n type: 'Voronoi',\n props: {\n colorA: '#101820',\n colorB: '#3fb6a8',\n colorBorder: '#e8fff9',\n scale: 9,\n edgeIntensity: 0.7,\n edgeSoftness: 0.15,\n seed: 21,\n speed: 0.1\n }\n },\n { type: 'FilmGrain', props: { strength: 0.08 } }\n ]\n }\n },\n {\n id: 'deepWater',\n preset: {\n components: [\n {\n type: 'Water',\n props: {\n waterColor: '#0a2a43',\n clarity: 0.55,\n depth: 0.8,\n shallows: 0.35,\n caustics: 0.6,\n causticScale: 2.4,\n choppiness: 0.35,\n waveScale: 1.2,\n reflection: 0.4,\n foam: 0.15,\n speed: 0.25\n }\n },\n {\n type: 'LightLeak',\n props: {\n colorHot: '#9fe2ff',\n colorMid: '#1f4b6e',\n intensity: 0.25,\n spread: 0.6,\n speed: 0.15\n }\n },\n { type: 'FilmGrain', props: { strength: 0.06 } }\n ]\n }\n },\n {\n id: 'smokePlume',\n preset: {\n components: [\n {\n type: 'SmokeFill',\n props: {\n colorA: '#ffffff',\n colorB: '#6d6a75',\n direction: 90,\n speed: 0.25,\n spread: 0.5,\n emitRadius: 0.2,\n intensity: 0.8,\n dissipation: 0.55,\n detail: 0.6,\n gravity: 0.05,\n colorDecay: 0.4\n }\n },\n { type: 'FilmGrain', props: { strength: 0.05 } }\n ]\n }\n },\n {\n id: 'neonPulse',\n preset: {\n components: [\n {\n type: 'LightEdge',\n props: {\n colorA: '#ff2fb3',\n colorB: '#22d3ee',\n stops: [\n { color: '#ff2fb3', position: 0 },\n { color: '#22d3ee', position: 1 }\n ],\n thickness: 0.35,\n softness: 0.5,\n intensity: 0.9,\n bloom: 0.7,\n spots: 3,\n pulse: 0.6,\n smoke: 0.2,\n speed: 0.5\n }\n },\n { type: 'FilmGrain', props: { strength: 0.06 } }\n ]\n }\n },\n {\n id: 'grainWash',\n preset: {\n components: [\n {\n type: 'FlowingGradient',\n props: {\n colorA: '#0b1026',\n colorB: '#243b80',\n colorC: '#7c5cff',\n colorD: '#ffb86b',\n distortion: 0.7,\n speed: 0.25\n }\n },\n { type: 'FilmGrain', props: { strength: 0.18, bias: 0.05 } }\n ]\n }\n },\n {\n id: 'obsidian',\n preset: {\n components: [\n {\n type: 'Obsidian',\n props: {\n bodyColor: '#0a0b0f',\n colorA: '#3b0f52',\n colorB: '#0f6b6b',\n iridescence: 0.5,\n rimWidth: 0.25,\n rimSoftness: 0.3,\n flowScale: 1.6,\n gloss: 0.7,\n bevelWidth: 0.2,\n speed: 0.2\n }\n },\n { type: 'FilmGrain', props: { strength: 0.06 } }\n ]\n }\n },\n {\n id: 'marbleInk',\n preset: {\n components: [\n {\n type: 'Marble',\n props: {\n colorA: '#f7f4ee',\n colorB: '#20232b',\n colorC: '#8a8f9a',\n turbulence: 8,\n scale: 1.4,\n speed: 0.05\n }\n },\n {\n type: 'Halftone',\n props: {\n style: 'cmyk',\n frequency: 70,\n paperColor: '#f7f4ee',\n cyanColor: '#00a6c9',\n magentaColor: '#e0218a',\n yellowColor: '#f2d21a',\n blackColor: '#111111',\n misprint: 0.005\n }\n }\n ]\n }\n }\n]\n\n/** The gallery shader `preset` is, unchanged; null once any of its effects was edited. */\nexport function shaderGalleryEntryOf(preset: ShaderPreset): ShaderGalleryEntry | null {\n return SHADER_GALLERY.find((entry) => isEqual(entry.preset, preset)) ?? null\n}\n\nconst HEX_COLOR = /^#(?:[\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/i\n\nfunction colorsIn(value: unknown): string[] {\n if (typeof value === 'string') return HEX_COLOR.test(value) ? [value.toLowerCase()] : []\n if (Array.isArray(value)) return value.flatMap(colorsIn)\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(colorsIn)\n return []\n}\n\n/**\n * The colors `preset` sets, in the order its effects draw, without repeats and at most `limit` of\n * them: a palette that stands in for the shader where it cannot be drawn.\n */\nexport function shaderPresetColors(preset: ShaderPreset, limit = 4): string[] {\n const colors = preset.components.flatMap((component) => colorsIn(component.props))\n return uniq(colors).slice(0, limit)\n}\n"],"mappings":";;;AAyCA,MAAa,iBAAgD;CAC3D;EACE,IAAI;EACJ,QAAQ,EACN,YAAY,CACV;GACE,MAAM;GACN,OAAO;IACL,OAAO;KACL;MAAE,OAAO;MAAW,UAAU;KAAE;KAChC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;MAAE,OAAO;MAAW,UAAU;KAAI;KAClC;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,aAAa;IACb,WAAW;IACX,OAAO;IACP,YAAY;IACZ,OAAO;GACT;EACF,GACA;GAAE,MAAM;GAAa,OAAO,EAAE,UAAU,IAAK;EAAE,CACjD,EACF;CACF;CACA;EACE,IAAI;EACJ,QAAQ,EACN,YAAY,CACV;GACE,MAAM;GACN,OAAO;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,OAAO;GACT;EACF,GACA;GACE,MAAM;GACN,OAAO;IACL,OAAO;IACP,WAAW;IACX,YAAY;IACZ,WAAW;IACX,cAAc;IACd,aAAa;IACb,YAAY;IACZ,UAAU;GACZ;EACF,CACF,EACF;CACF;AACF;;AAGA,SAAgB,qBAAqB,QAAiD;CACpF,OAAO,eAAe,MAAM,UAAU,QAAQ,MAAM,QAAQ,MAAM,CAAC,KAAK;AAC1E;AAEA,MAAM,YAAY;AAElB,SAAS,SAAS,OAA0B;CAC1C,IAAI,OAAO,UAAU,UAAU,OAAO,UAAU,KAAK,KAAK,IAAI,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC;CACvF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,QAAQ,QAAQ;CACvD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,QAAQ,QAAQ;CAC7F,OAAO,CAAC;AACV;;;;;AAMA,SAAgB,mBAAmB,QAAsB,QAAQ,GAAa;CAC5E,MAAM,SAAS,OAAO,WAAW,SAAS,cAAc,SAAS,UAAU,KAAK,CAAC;CACjF,OAAO,KAAK,MAAM,CAAC,CAAC,MAAM,GAAG,KAAK;AACpC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ShaderEffect, ShaderPropControl, loadShaderCatalog, shaderEffectLabel } from "./catalog.js";
|
|
2
2
|
import { SHADER_GALLERY, ShaderGalleryEntry, ShaderGalleryId, shaderGalleryEntryOf, shaderPresetColors } from "./gallery.js";
|
|
3
3
|
import { shaderEffectPreview, shaderGalleryPreview } from "./preview.js";
|
|
4
|
+
import { SHADER_SHAPES, ShaderShape, shaderShapeType, withShapeType } from "./shapes.js";
|
|
5
|
+
import { ShaderStop, addStop, removeStop, setStopColor, setStopPosition, shaderStops } from "./stops.js";
|
|
4
6
|
import { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, addShaderEffect, moveShaderEffect, parseShaderPreset, removeShaderEffect, setShaderEffectProp, shaderPresetJSON } from "./preset.js";
|
|
5
|
-
export { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, SHADER_GALLERY, type ShaderEffect, type ShaderGalleryEntry, type ShaderGalleryId, type ShaderPropControl, addShaderEffect, loadShaderCatalog, moveShaderEffect, parseShaderPreset, removeShaderEffect, setShaderEffectProp, shaderEffectLabel, shaderEffectPreview, shaderGalleryEntryOf, shaderGalleryPreview, shaderPresetColors, shaderPresetJSON };
|
|
7
|
+
export { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, SHADER_GALLERY, SHADER_SHAPES, type ShaderEffect, type ShaderGalleryEntry, type ShaderGalleryId, type ShaderPropControl, type ShaderShape, type ShaderStop, addShaderEffect, addStop, loadShaderCatalog, moveShaderEffect, parseShaderPreset, removeShaderEffect, removeStop, setShaderEffectProp, setStopColor, setStopPosition, shaderEffectLabel, shaderEffectPreview, shaderGalleryEntryOf, shaderGalleryPreview, shaderPresetColors, shaderPresetJSON, shaderShapeType, shaderStops, withShapeType };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { SHADER_SHAPES, shaderShapeType, withShapeType } from "./shapes.js";
|
|
1
2
|
import { loadShaderCatalog, shaderEffectLabel } from "./catalog.js";
|
|
2
3
|
import { SHADER_GALLERY, shaderGalleryEntryOf, shaderPresetColors } from "./gallery.js";
|
|
3
4
|
import { shaderEffectPreview, shaderGalleryPreview } from "./preview.js";
|
|
5
|
+
import { addStop, removeStop, setStopColor, setStopPosition, shaderStops } from "./stops.js";
|
|
4
6
|
import { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, addShaderEffect, moveShaderEffect, parseShaderPreset, removeShaderEffect, setShaderEffectProp, shaderPresetJSON } from "./preset.js";
|
|
5
|
-
export { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, SHADER_GALLERY, addShaderEffect, loadShaderCatalog, moveShaderEffect, parseShaderPreset, removeShaderEffect, setShaderEffectProp, shaderEffectLabel, shaderEffectPreview, shaderGalleryEntryOf, shaderGalleryPreview, shaderPresetColors, shaderPresetJSON };
|
|
7
|
+
export { DEFAULT_SHADER_EFFECT, DEFAULT_SHADER_PRESET, DEFAULT_SHADER_SOURCE, SHADER_GALLERY, SHADER_SHAPES, addShaderEffect, addStop, loadShaderCatalog, moveShaderEffect, parseShaderPreset, removeShaderEffect, removeStop, setShaderEffectProp, setStopColor, setStopPosition, shaderEffectLabel, shaderEffectPreview, shaderGalleryEntryOf, shaderGalleryPreview, shaderPresetColors, shaderPresetJSON, shaderShapeType, shaderStops, withShapeType };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/controls/shader/shapes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The shapes the `shaders` library draws for an effect that takes one, as `SHAPE3D_TYPES` in
|
|
4
|
+
* `shaders/core` names them. The list is local so the panel does not load the WebGPU library;
|
|
5
|
+
* `shapes.test.ts` keeps it equal to the library's.
|
|
6
|
+
*/
|
|
7
|
+
declare const SHADER_SHAPES: readonly ["sphere3D", "cube3D", "torus3D", "octahedron3D", "cylinder3D", "capsule3D", "cone3D", "pyramid3D", "prism3D", "ellipsoid3D", "diamond3D", "link3D", "gem3D", "helix3D", "metaballs3D", "dodecahedron3D", "hemisphere3D", "ribbon3D", "blob3D", "gyroscope3D"];
|
|
8
|
+
type ShaderShape = (typeof SHADER_SHAPES)[number];
|
|
9
|
+
/** The type of the shape `value` holds, or '' when it holds none. */
|
|
10
|
+
declare function shaderShapeType(value: unknown): string;
|
|
11
|
+
/**
|
|
12
|
+
* `value` with its shape type set to `type`: the new shape's own geometry fills in where the
|
|
13
|
+
* old shape had none, and whatever the old shape set for the same fields is kept.
|
|
14
|
+
*/
|
|
15
|
+
declare function withShapeType(value: unknown, type: string): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SHADER_SHAPES, ShaderShape, shaderShapeType, withShapeType };
|
|
18
|
+
//# sourceMappingURL=shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.d.ts","names":[],"sources":["../../../src/controls/shader/shapes.ts"],"mappings":";;;;;;cAKa;KAuBD,sBAAsB;;iBA2ElB,gBAAgB;;;;;iBAShB,cAAc,gBAAgB"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
//#region src/controls/shader/shapes.ts
|
|
2
|
+
/**
|
|
3
|
+
* The shapes the `shaders` library draws for an effect that takes one, as `SHAPE3D_TYPES` in
|
|
4
|
+
* `shaders/core` names them. The list is local so the panel does not load the WebGPU library;
|
|
5
|
+
* `shapes.test.ts` keeps it equal to the library's.
|
|
6
|
+
*/
|
|
7
|
+
const SHADER_SHAPES = [
|
|
8
|
+
"sphere3D",
|
|
9
|
+
"cube3D",
|
|
10
|
+
"torus3D",
|
|
11
|
+
"octahedron3D",
|
|
12
|
+
"cylinder3D",
|
|
13
|
+
"capsule3D",
|
|
14
|
+
"cone3D",
|
|
15
|
+
"pyramid3D",
|
|
16
|
+
"prism3D",
|
|
17
|
+
"ellipsoid3D",
|
|
18
|
+
"diamond3D",
|
|
19
|
+
"link3D",
|
|
20
|
+
"gem3D",
|
|
21
|
+
"helix3D",
|
|
22
|
+
"metaballs3D",
|
|
23
|
+
"dodecahedron3D",
|
|
24
|
+
"hemisphere3D",
|
|
25
|
+
"ribbon3D",
|
|
26
|
+
"blob3D",
|
|
27
|
+
"gyroscope3D"
|
|
28
|
+
];
|
|
29
|
+
/** The geometry each shape starts from, as `SHAPE3D_DEFAULTS` in `shaders/core` gives it. */
|
|
30
|
+
const SHAPE_DEFAULTS = {
|
|
31
|
+
sphere3D: {
|
|
32
|
+
radius: .35,
|
|
33
|
+
rotX: 0,
|
|
34
|
+
rotY: 0,
|
|
35
|
+
rotZ: 0
|
|
36
|
+
},
|
|
37
|
+
cube3D: {
|
|
38
|
+
sizeX: .27,
|
|
39
|
+
sizeY: .27,
|
|
40
|
+
sizeZ: .27,
|
|
41
|
+
rounding: .02,
|
|
42
|
+
rotX: 25,
|
|
43
|
+
rotY: 35,
|
|
44
|
+
rotZ: 0
|
|
45
|
+
},
|
|
46
|
+
torus3D: {
|
|
47
|
+
radius: .3,
|
|
48
|
+
tube: .12,
|
|
49
|
+
rotX: 55,
|
|
50
|
+
rotY: 0,
|
|
51
|
+
rotZ: 0
|
|
52
|
+
},
|
|
53
|
+
octahedron3D: {
|
|
54
|
+
radius: .42,
|
|
55
|
+
rotX: 10,
|
|
56
|
+
rotY: 25,
|
|
57
|
+
rotZ: 0
|
|
58
|
+
},
|
|
59
|
+
cylinder3D: {
|
|
60
|
+
radius: .22,
|
|
61
|
+
height: .26,
|
|
62
|
+
rounding: .02,
|
|
63
|
+
rotX: 60,
|
|
64
|
+
rotY: 0,
|
|
65
|
+
rotZ: 30
|
|
66
|
+
},
|
|
67
|
+
capsule3D: {
|
|
68
|
+
radius: .16,
|
|
69
|
+
height: .2,
|
|
70
|
+
rotX: 0,
|
|
71
|
+
rotY: 0,
|
|
72
|
+
rotZ: 35
|
|
73
|
+
},
|
|
74
|
+
cone3D: {
|
|
75
|
+
radius: .3,
|
|
76
|
+
topRadius: .02,
|
|
77
|
+
height: .3,
|
|
78
|
+
rotX: 25,
|
|
79
|
+
rotY: 0,
|
|
80
|
+
rotZ: 15
|
|
81
|
+
},
|
|
82
|
+
pyramid3D: {
|
|
83
|
+
size: .3,
|
|
84
|
+
height: .45,
|
|
85
|
+
rotX: -10,
|
|
86
|
+
rotY: 30,
|
|
87
|
+
rotZ: 0
|
|
88
|
+
},
|
|
89
|
+
prism3D: {
|
|
90
|
+
radius: .28,
|
|
91
|
+
height: .14,
|
|
92
|
+
rotX: 25,
|
|
93
|
+
rotY: 30,
|
|
94
|
+
rotZ: 0
|
|
95
|
+
},
|
|
96
|
+
ellipsoid3D: {
|
|
97
|
+
radiusX: .38,
|
|
98
|
+
radiusY: .22,
|
|
99
|
+
radiusZ: .3,
|
|
100
|
+
rotX: 0,
|
|
101
|
+
rotY: 0,
|
|
102
|
+
rotZ: 20
|
|
103
|
+
},
|
|
104
|
+
diamond3D: {
|
|
105
|
+
radius: .3,
|
|
106
|
+
height: .42,
|
|
107
|
+
rotX: 15,
|
|
108
|
+
rotY: 0,
|
|
109
|
+
rotZ: 0
|
|
110
|
+
},
|
|
111
|
+
link3D: {
|
|
112
|
+
radius: .18,
|
|
113
|
+
length: .15,
|
|
114
|
+
tube: .08,
|
|
115
|
+
rotX: 20,
|
|
116
|
+
rotY: 30,
|
|
117
|
+
rotZ: 0
|
|
118
|
+
},
|
|
119
|
+
gem3D: {
|
|
120
|
+
radius: .3,
|
|
121
|
+
height: .32,
|
|
122
|
+
facets: 8,
|
|
123
|
+
rotX: 15,
|
|
124
|
+
rotY: 0,
|
|
125
|
+
rotZ: 0
|
|
126
|
+
},
|
|
127
|
+
helix3D: {
|
|
128
|
+
radius: .22,
|
|
129
|
+
tube: .06,
|
|
130
|
+
pitch: .16,
|
|
131
|
+
rotX: 20,
|
|
132
|
+
rotY: 0,
|
|
133
|
+
rotZ: 0
|
|
134
|
+
},
|
|
135
|
+
metaballs3D: {
|
|
136
|
+
balls: 4,
|
|
137
|
+
ballRadius: .16,
|
|
138
|
+
spread: .2,
|
|
139
|
+
blend: .12,
|
|
140
|
+
speed: 1,
|
|
141
|
+
rotX: 0,
|
|
142
|
+
rotY: 0,
|
|
143
|
+
rotZ: 0
|
|
144
|
+
},
|
|
145
|
+
dodecahedron3D: {
|
|
146
|
+
radius: .34,
|
|
147
|
+
rotX: 20,
|
|
148
|
+
rotY: 10,
|
|
149
|
+
rotZ: 0
|
|
150
|
+
},
|
|
151
|
+
hemisphere3D: {
|
|
152
|
+
radius: .4,
|
|
153
|
+
cut: 0,
|
|
154
|
+
rotX: 30,
|
|
155
|
+
rotY: 0,
|
|
156
|
+
rotZ: 0
|
|
157
|
+
},
|
|
158
|
+
ribbon3D: {
|
|
159
|
+
width: .15,
|
|
160
|
+
thickness: .03,
|
|
161
|
+
length: .38,
|
|
162
|
+
wave: .1,
|
|
163
|
+
waveFrequency: 7,
|
|
164
|
+
twist: 140,
|
|
165
|
+
speed: 1,
|
|
166
|
+
rotX: 12,
|
|
167
|
+
rotY: 18,
|
|
168
|
+
rotZ: 0
|
|
169
|
+
},
|
|
170
|
+
blob3D: {
|
|
171
|
+
radius: .3,
|
|
172
|
+
wobble: .07,
|
|
173
|
+
wobbliness: 5,
|
|
174
|
+
speed: 1,
|
|
175
|
+
rotX: 0,
|
|
176
|
+
rotY: 0,
|
|
177
|
+
rotZ: 0
|
|
178
|
+
},
|
|
179
|
+
gyroscope3D: {
|
|
180
|
+
radius: .34,
|
|
181
|
+
width: .1,
|
|
182
|
+
thickness: .028,
|
|
183
|
+
rounding: .006,
|
|
184
|
+
core: .14,
|
|
185
|
+
speed: 1,
|
|
186
|
+
rotX: 15,
|
|
187
|
+
rotY: 0,
|
|
188
|
+
rotZ: 0
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
/** The shape an effect's `shape` prop holds, as the library writes it: JSON with a `type`. */
|
|
192
|
+
function readShape(value) {
|
|
193
|
+
if (typeof value !== "string") return null;
|
|
194
|
+
try {
|
|
195
|
+
const parsed = JSON.parse(value);
|
|
196
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
197
|
+
return parsed;
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/** The type of the shape `value` holds, or '' when it holds none. */
|
|
203
|
+
function shaderShapeType(value) {
|
|
204
|
+
const shape = readShape(value);
|
|
205
|
+
return typeof shape?.type === "string" ? shape.type : "";
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `value` with its shape type set to `type`: the new shape's own geometry fills in where the
|
|
209
|
+
* old shape had none, and whatever the old shape set for the same fields is kept.
|
|
210
|
+
*/
|
|
211
|
+
function withShapeType(value, type) {
|
|
212
|
+
const shape = readShape(value);
|
|
213
|
+
if (shape?.type === type) return value;
|
|
214
|
+
const defaults = SHADER_SHAPES.includes(type) ? SHAPE_DEFAULTS[type] : {};
|
|
215
|
+
return JSON.stringify(shape ? {
|
|
216
|
+
...defaults,
|
|
217
|
+
...shape,
|
|
218
|
+
type
|
|
219
|
+
} : {
|
|
220
|
+
...defaults,
|
|
221
|
+
type
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
export { SHADER_SHAPES, shaderShapeType, withShapeType };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=shapes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.js","names":[],"sources":["../../../src/controls/shader/shapes.ts"],"sourcesContent":["/**\n * The shapes the `shaders` library draws for an effect that takes one, as `SHAPE3D_TYPES` in\n * `shaders/core` names them. The list is local so the panel does not load the WebGPU library;\n * `shapes.test.ts` keeps it equal to the library's.\n */\nexport const SHADER_SHAPES = [\n 'sphere3D',\n 'cube3D',\n 'torus3D',\n 'octahedron3D',\n 'cylinder3D',\n 'capsule3D',\n 'cone3D',\n 'pyramid3D',\n 'prism3D',\n 'ellipsoid3D',\n 'diamond3D',\n 'link3D',\n 'gem3D',\n 'helix3D',\n 'metaballs3D',\n 'dodecahedron3D',\n 'hemisphere3D',\n 'ribbon3D',\n 'blob3D',\n 'gyroscope3D'\n] as const\n\nexport type ShaderShape = (typeof SHADER_SHAPES)[number]\n\n/** The geometry each shape starts from, as `SHAPE3D_DEFAULTS` in `shaders/core` gives it. */\nconst SHAPE_DEFAULTS: Readonly<Record<ShaderShape, Readonly<Record<string, number>>>> = {\n sphere3D: { radius: 0.35, rotX: 0, rotY: 0, rotZ: 0 },\n cube3D: { sizeX: 0.27, sizeY: 0.27, sizeZ: 0.27, rounding: 0.02, rotX: 25, rotY: 35, rotZ: 0 },\n torus3D: { radius: 0.3, tube: 0.12, rotX: 55, rotY: 0, rotZ: 0 },\n octahedron3D: { radius: 0.42, rotX: 10, rotY: 25, rotZ: 0 },\n cylinder3D: { radius: 0.22, height: 0.26, rounding: 0.02, rotX: 60, rotY: 0, rotZ: 30 },\n capsule3D: { radius: 0.16, height: 0.2, rotX: 0, rotY: 0, rotZ: 35 },\n cone3D: { radius: 0.3, topRadius: 0.02, height: 0.3, rotX: 25, rotY: 0, rotZ: 15 },\n pyramid3D: { size: 0.3, height: 0.45, rotX: -10, rotY: 30, rotZ: 0 },\n prism3D: { radius: 0.28, height: 0.14, rotX: 25, rotY: 30, rotZ: 0 },\n ellipsoid3D: { radiusX: 0.38, radiusY: 0.22, radiusZ: 0.3, rotX: 0, rotY: 0, rotZ: 20 },\n diamond3D: { radius: 0.3, height: 0.42, rotX: 15, rotY: 0, rotZ: 0 },\n link3D: { radius: 0.18, length: 0.15, tube: 0.08, rotX: 20, rotY: 30, rotZ: 0 },\n gem3D: { radius: 0.3, height: 0.32, facets: 8, rotX: 15, rotY: 0, rotZ: 0 },\n helix3D: { radius: 0.22, tube: 0.06, pitch: 0.16, rotX: 20, rotY: 0, rotZ: 0 },\n metaballs3D: {\n balls: 4,\n ballRadius: 0.16,\n spread: 0.2,\n blend: 0.12,\n speed: 1,\n rotX: 0,\n rotY: 0,\n rotZ: 0\n },\n dodecahedron3D: { radius: 0.34, rotX: 20, rotY: 10, rotZ: 0 },\n hemisphere3D: { radius: 0.4, cut: 0, rotX: 30, rotY: 0, rotZ: 0 },\n ribbon3D: {\n width: 0.15,\n thickness: 0.03,\n length: 0.38,\n wave: 0.1,\n waveFrequency: 7,\n twist: 140,\n speed: 1,\n rotX: 12,\n rotY: 18,\n rotZ: 0\n },\n blob3D: { radius: 0.3, wobble: 0.07, wobbliness: 5, speed: 1, rotX: 0, rotY: 0, rotZ: 0 },\n gyroscope3D: {\n radius: 0.34,\n width: 0.1,\n thickness: 0.028,\n rounding: 0.006,\n core: 0.14,\n speed: 1,\n rotX: 15,\n rotY: 0,\n rotZ: 0\n }\n}\n\n/** The fields a shape's JSON holds: a type, and whatever that shape's geometry needs. */\ninterface ShaderShapeFields {\n type?: unknown\n [field: string]: unknown\n}\n\n/** The shape an effect's `shape` prop holds, as the library writes it: JSON with a `type`. */\nfunction readShape(value: unknown): ShaderShapeFields | null {\n if (typeof value !== 'string') return null\n try {\n const parsed: unknown = JSON.parse(value)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null\n return parsed as ShaderShapeFields\n } catch {\n return null\n }\n}\n\n/** The type of the shape `value` holds, or '' when it holds none. */\nexport function shaderShapeType(value: unknown): string {\n const shape = readShape(value)\n return typeof shape?.type === 'string' ? shape.type : ''\n}\n\n/**\n * `value` with its shape type set to `type`: the new shape's own geometry fills in where the\n * old shape had none, and whatever the old shape set for the same fields is kept.\n */\nexport function withShapeType(value: unknown, type: string): string {\n const shape = readShape(value)\n if (shape?.type === type) return value as string\n const defaults = SHADER_SHAPES.includes(type as ShaderShape)\n ? SHAPE_DEFAULTS[type as ShaderShape]\n : {}\n return JSON.stringify(shape ? { ...defaults, ...shape, type } : { ...defaults, type })\n}\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAKA,MAAM,iBAAkF;CACtF,UAAU;EAAE,QAAQ;EAAM,MAAM;EAAG,MAAM;EAAG,MAAM;CAAE;CACpD,QAAQ;EAAE,OAAO;EAAM,O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;EAAM,MAAM;EAAI,MAAM;EAAI,MAAM;CAAE;CAC5D,cAAc;EAAE,QAAQ;EAAK,KAAK;EAAG,MAAM;EAAI,MAAM;EAAG,MAAM;CAAE;CAChE,UAAU;EACR,OAAO;EACP,WAAW;EACX,QAAQ;EACR,MAAM;EACN,eAAe;EACf,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;EACN,MAAM;CACR;CACA,QAAQ;EAAE,QAAQ;EAAK,QAAQ;EAAM,YAAY;EAAG,OAAO;EAAG,MAAM;EAAG,MAAM;EAAG,MAAM;CAAE;CACxF,aAAa;EACX,QAAQ;EACR,OAAO;EACP,WAAW;EACX,UAAU;EACV,MAAM;EACN,OAAO;EACP,MAAM;EACN,MAAM;EACN,MAAM;CACR;AACF;;AASA,SAAS,UAAU,OAA0C;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,KAAK;EACxC,IAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO;EACnF,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAgB,gBAAgB,OAAwB;CACtD,MAAM,QAAQ,UAAU,KAAK;CAC7B,OAAO,OAAO,OAAO,SAAS,WAAW,MAAM,OAAO;AACxD;;;;;AAMA,SAAgB,cAAc,OAAgB,MAAsB;CAClE,MAAM,QAAQ,UAAU,KAAK;CAC7B,IAAI,OAAO,SAAS,MAAM,OAAO;CACjC,MAAM,WAAW,cAAc,SAAS,IAAmB,IACvD,eAAe,QACf,CAAC;CACL,OAAO,KAAK,UAAU,QAAQ;EAAE,GAAG;EAAU,GAAG;EAAO;CAAK,IAAI;EAAE,GAAG;EAAU;CAAK,CAAC;AACvF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/controls/shader/stops.d.ts
|
|
2
|
+
/** One colour stop of a shader effect's gradient, as the `shaders` library takes it. */
|
|
3
|
+
interface ShaderStop {
|
|
4
|
+
color: string;
|
|
5
|
+
position: number;
|
|
6
|
+
}
|
|
7
|
+
/** The stops a preset's gradient value holds, sorted along the ramp, positions within it. */
|
|
8
|
+
declare function shaderStops(value: unknown): ShaderStop[];
|
|
9
|
+
/** `stops` with stop `index` at `position`, kept within the ramp. */
|
|
10
|
+
declare function setStopPosition(stops: readonly ShaderStop[], index: number, position: number): ShaderStop[];
|
|
11
|
+
/** `stops` with stop `index` painted `color`. */
|
|
12
|
+
declare function setStopColor(stops: readonly ShaderStop[], index: number, color: string): ShaderStop[];
|
|
13
|
+
/**
|
|
14
|
+
* `stops` with a stop in the widest gap between two, painted the colour on its left, so adding
|
|
15
|
+
* one never flashes a colour the shader did not already show.
|
|
16
|
+
*/
|
|
17
|
+
declare function addStop(stops: readonly ShaderStop[]): ShaderStop[];
|
|
18
|
+
/** `stops` without stop `index`; the last two stay, since a ramp needs two. */
|
|
19
|
+
declare function removeStop(stops: readonly ShaderStop[], index: number): ShaderStop[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ShaderStop, addStop, removeStop, setStopColor, setStopPosition, shaderStops };
|
|
22
|
+
//# sourceMappingURL=stops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stops.d.ts","names":[],"sources":["../../../src/controls/shader/stops.ts"],"mappings":";;UACiB;EACf;EACA;;;iBAmBc,YAAY,iBAAiB;;iBAS7B,gBACd,gBAAgB,cAChB,eACA,mBACC;;iBAMa,aACd,gBAAgB,cAChB,eACA,gBACC;;;;;iBAQa,QAAQ,gBAAgB,eAAe;;iBAyBvC,WAAW,gBAAgB,cAAc,gBAAgB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/controls/shader/stops.ts
|
|
2
|
+
/** The least stops a gradient keeps: fewer stops are a colour, not a ramp. */
|
|
3
|
+
const MIN_STOPS = 2;
|
|
4
|
+
function isStop(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && "color" in value && typeof value.color === "string" && "position" in value && typeof value.position === "number" && Number.isFinite(value.position);
|
|
6
|
+
}
|
|
7
|
+
/** The stops a preset's gradient value holds, sorted along the ramp, positions within it. */
|
|
8
|
+
function shaderStops(value) {
|
|
9
|
+
if (!Array.isArray(value)) return [];
|
|
10
|
+
return value.filter(isStop).map((stop) => ({
|
|
11
|
+
color: stop.color,
|
|
12
|
+
position: Math.min(1, Math.max(0, stop.position))
|
|
13
|
+
})).sort((a, b) => a.position - b.position);
|
|
14
|
+
}
|
|
15
|
+
/** `stops` with stop `index` at `position`, kept within the ramp. */
|
|
16
|
+
function setStopPosition(stops, index, position) {
|
|
17
|
+
const clamped = Math.min(1, Math.max(0, position));
|
|
18
|
+
return stops.map((stop, at) => at === index ? {
|
|
19
|
+
...stop,
|
|
20
|
+
position: clamped
|
|
21
|
+
} : stop);
|
|
22
|
+
}
|
|
23
|
+
/** `stops` with stop `index` painted `color`. */
|
|
24
|
+
function setStopColor(stops, index, color) {
|
|
25
|
+
return stops.map((stop, at) => at === index ? {
|
|
26
|
+
...stop,
|
|
27
|
+
color
|
|
28
|
+
} : stop);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `stops` with a stop in the widest gap between two, painted the colour on its left, so adding
|
|
32
|
+
* one never flashes a colour the shader did not already show.
|
|
33
|
+
*/
|
|
34
|
+
function addStop(stops) {
|
|
35
|
+
if (stops.length === 0) return [{
|
|
36
|
+
color: "#000000",
|
|
37
|
+
position: 0
|
|
38
|
+
}, {
|
|
39
|
+
color: "#ffffff",
|
|
40
|
+
position: 1
|
|
41
|
+
}];
|
|
42
|
+
const sorted = shaderStops(stops);
|
|
43
|
+
let widest = 0;
|
|
44
|
+
let at = 0;
|
|
45
|
+
for (let index = 1; index < sorted.length; index++) {
|
|
46
|
+
const gap = (sorted[index]?.position ?? 1) - (sorted[index - 1]?.position ?? 0);
|
|
47
|
+
if (gap > widest) {
|
|
48
|
+
widest = gap;
|
|
49
|
+
at = index;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const left = sorted.at(Math.max(0, at - 1));
|
|
53
|
+
const right = sorted.at(Math.min(sorted.length - 1, at));
|
|
54
|
+
const position = ((left?.position ?? 0) + (right?.position ?? 1)) / 2;
|
|
55
|
+
const added = {
|
|
56
|
+
color: left?.color ?? "#000000",
|
|
57
|
+
position
|
|
58
|
+
};
|
|
59
|
+
return [
|
|
60
|
+
...sorted.slice(0, at),
|
|
61
|
+
added,
|
|
62
|
+
...sorted.slice(at)
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/** `stops` without stop `index`; the last two stay, since a ramp needs two. */
|
|
66
|
+
function removeStop(stops, index) {
|
|
67
|
+
if (stops.length <= MIN_STOPS) return [...stops];
|
|
68
|
+
return stops.filter((_, at) => at !== index);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { addStop, removeStop, setStopColor, setStopPosition, shaderStops };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=stops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stops.js","names":[],"sources":["../../../src/controls/shader/stops.ts"],"sourcesContent":["/** One colour stop of a shader effect's gradient, as the `shaders` library takes it. */\nexport interface ShaderStop {\n color: string\n position: number\n}\n\n/** The least stops a gradient keeps: fewer stops are a colour, not a ramp. */\nconst MIN_STOPS = 2\n\nfunction isStop(value: unknown): value is ShaderStop {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'color' in value &&\n typeof value.color === 'string' &&\n 'position' in value &&\n typeof value.position === 'number' &&\n Number.isFinite(value.position)\n )\n}\n\n/** The stops a preset's gradient value holds, sorted along the ramp, positions within it. */\nexport function shaderStops(value: unknown): ShaderStop[] {\n if (!Array.isArray(value)) return []\n return value\n .filter(isStop)\n .map((stop) => ({ color: stop.color, position: Math.min(1, Math.max(0, stop.position)) }))\n .sort((a, b) => a.position - b.position)\n}\n\n/** `stops` with stop `index` at `position`, kept within the ramp. */\nexport function setStopPosition(\n stops: readonly ShaderStop[],\n index: number,\n position: number\n): ShaderStop[] {\n const clamped = Math.min(1, Math.max(0, position))\n return stops.map((stop, at) => (at === index ? { ...stop, position: clamped } : stop))\n}\n\n/** `stops` with stop `index` painted `color`. */\nexport function setStopColor(\n stops: readonly ShaderStop[],\n index: number,\n color: string\n): ShaderStop[] {\n return stops.map((stop, at) => (at === index ? { ...stop, color } : stop))\n}\n\n/**\n * `stops` with a stop in the widest gap between two, painted the colour on its left, so adding\n * one never flashes a colour the shader did not already show.\n */\nexport function addStop(stops: readonly ShaderStop[]): ShaderStop[] {\n if (stops.length === 0) {\n return [\n { color: '#000000', position: 0 },\n { color: '#ffffff', position: 1 }\n ]\n }\n const sorted = shaderStops(stops)\n let widest = 0\n let at = 0\n for (let index = 1; index < sorted.length; index++) {\n const gap = (sorted[index]?.position ?? 1) - (sorted[index - 1]?.position ?? 0)\n if (gap > widest) {\n widest = gap\n at = index\n }\n }\n const left = sorted.at(Math.max(0, at - 1))\n const right = sorted.at(Math.min(sorted.length - 1, at))\n const position = ((left?.position ?? 0) + (right?.position ?? 1)) / 2\n const added = { color: left?.color ?? '#000000', position }\n return [...sorted.slice(0, at), added, ...sorted.slice(at)]\n}\n\n/** `stops` without stop `index`; the last two stay, since a ramp needs two. */\nexport function removeStop(stops: readonly ShaderStop[], index: number): ShaderStop[] {\n if (stops.length <= MIN_STOPS) return [...stops]\n return stops.filter((_, at) => at !== index)\n}\n"],"mappings":";;AAOA,MAAM,YAAY;AAElB,SAAS,OAAO,OAAqC;CACnD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAO,MAAM,UAAU,YACvB,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,OAAO,SAAS,MAAM,QAAQ;AAElC;;AAGA,SAAgB,YAAY,OAA8B;CACxD,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MACJ,OAAO,MAAM,CAAC,CACd,KAAK,UAAU;EAAE,OAAO,KAAK;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AgB,WAAW,OAA8B,OAA6B;CACpF,IAAI,MAAM,UAAU,WAAW,OAAO,CAAC,GAAG,KAAK;CAC/C,OAAO,MAAM,QAAQ,GAAG,OAAO,OAAO,KAAK;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/variable-modes/helpers.ts"],"mappings":";;;;;KAcY,qBAAqB,KAAK;;UAGrB;EACf;EACA;;EAEA;EACA,OAAO;;EAEP,OAAO;;EAEP,WAAW;;;;;;iBAiBG,oBAAoB,QAAQ,QAAQ,SAAS,cAAc;;;;;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/variable-modes/helpers.ts"],"mappings":";;;;;KAcY,qBAAqB,KAAK;;UAGrB;EACf;EACA;;EAEA;EACA,OAAO;;EAEP,OAAO;;EAEP,WAAW;;;;;;iBAiBG,oBAAoB,QAAQ,QAAQ,SAAS,cAAc;;;;;iBAsC3D,gBACd,QAAQ,QACR,SAAS,aACT,sBACA"}
|
|
@@ -21,11 +21,13 @@ function shared(values) {
|
|
|
21
21
|
function variableModeChoices(editor, targets) {
|
|
22
22
|
if (targets.length === 0) return [];
|
|
23
23
|
const { graph } = editor;
|
|
24
|
-
const
|
|
24
|
+
const holders = targets.every((target) => target.type === "CANVAS");
|
|
25
|
+
let used;
|
|
26
|
+
const bound = (id) => (used ??= collectionsBoundIn(graph, targets.map((target) => target.id))).has(id);
|
|
25
27
|
const choices = [];
|
|
26
28
|
for (const collection of graph.variableCollections.values()) {
|
|
27
29
|
if (collection.modes.length < 2) continue;
|
|
28
|
-
if (
|
|
30
|
+
if ((!holders || collection.deleted) && !bound(collection.id)) continue;
|
|
29
31
|
const inherited = shared(targets.map((target) => target.parentId ? graph.getNodeVariableModeId(target.parentId, collection.id) : collection.defaultModeId));
|
|
30
32
|
choices.push({
|
|
31
33
|
collectionId: collection.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../../../src/controls/variable-modes/helpers.ts"],"sourcesContent":["import { omit } from 'es-toolkit'\n\nimport type { Editor } from '@pairdraw/core'\nimport {\n isLibraryCollection,\n type SceneNode,\n type VariableCollection,\n type VariableCollectionMode\n} from '@pairdraw/scene-graph'\nimport { collectionsBoundIn } from '@pairdraw/scene-graph/variables'\n\nimport { MIXED, type MixedValue } from '#vue/controls/node-props/use'\n\n/** A mode as the control lists it. */\nexport type VariableModeOption = Pick<VariableCollectionMode, 'modeId' | 'name'>\n\n/** One collection a variable mode can be set for, as Figma's Apply variable mode menu lists it. */\nexport interface VariableModeChoice {\n collectionId: string\n name: string\n /** Whether the collection is a library's copy rather than the file's own. */\n library: boolean\n modes: VariableModeOption[]\n /** The mode every target sets, MIXED when they differ, or null when none sets one (Auto). */\n value: MixedValue<string | null>\n /** The mode the targets show without one of their own, null when they would show different ones. */\n inherited: VariableModeOption | null\n}\n\nfunction modeOption(collection: VariableCollection, modeId: string): VariableModeOption | null {\n const mode = collection.modes.find((candidate) => candidate.modeId === modeId)\n return mode ? { modeId: mode.modeId, name: mode.name } : null\n}\n\nfunction shared<T>(values: readonly T[]): MixedValue<T> {\n const [first] = values\n return values.every((value) => value === first) ? first : MIXED\n}\n\n/**\n * The collections a mode can be set for on `targets`, as Figma offers them: those with more than\n * one mode whose variables the targets' layers use, or every such collection for a page.\n */\nexport function variableModeChoices(editor: Editor, targets: SceneNode[]): VariableModeChoice[] {\n if (targets.length === 0) return []\n const { graph } = editor\n const
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../../../src/controls/variable-modes/helpers.ts"],"sourcesContent":["import { omit } from 'es-toolkit'\n\nimport type { Editor } from '@pairdraw/core'\nimport {\n isLibraryCollection,\n type SceneNode,\n type VariableCollection,\n type VariableCollectionMode\n} from '@pairdraw/scene-graph'\nimport { collectionsBoundIn } from '@pairdraw/scene-graph/variables'\n\nimport { MIXED, type MixedValue } from '#vue/controls/node-props/use'\n\n/** A mode as the control lists it. */\nexport type VariableModeOption = Pick<VariableCollectionMode, 'modeId' | 'name'>\n\n/** One collection a variable mode can be set for, as Figma's Apply variable mode menu lists it. */\nexport interface VariableModeChoice {\n collectionId: string\n name: string\n /** Whether the collection is a library's copy rather than the file's own. */\n library: boolean\n modes: VariableModeOption[]\n /** The mode every target sets, MIXED when they differ, or null when none sets one (Auto). */\n value: MixedValue<string | null>\n /** The mode the targets show without one of their own, null when they would show different ones. */\n inherited: VariableModeOption | null\n}\n\nfunction modeOption(collection: VariableCollection, modeId: string): VariableModeOption | null {\n const mode = collection.modes.find((candidate) => candidate.modeId === modeId)\n return mode ? { modeId: mode.modeId, name: mode.name } : null\n}\n\nfunction shared<T>(values: readonly T[]): MixedValue<T> {\n const [first] = values\n return values.every((value) => value === first) ? first : MIXED\n}\n\n/**\n * The collections a mode can be set for on `targets`, as Figma offers them: those with more than\n * one mode whose variables the targets' layers use, or every such collection for a page.\n */\nexport function variableModeChoices(editor: Editor, targets: SceneNode[]): VariableModeChoice[] {\n if (targets.length === 0) return []\n const { graph } = editor\n const holders = targets.every((target) => target.type === 'CANVAS')\n let used: Set<string> | undefined\n const bound = (id: string) =>\n (used ??= collectionsBoundIn(\n graph,\n targets.map((target) => target.id)\n )).has(id)\n const choices: VariableModeChoice[] = []\n for (const collection of graph.variableCollections.values()) {\n if (collection.modes.length < 2) continue\n // A deleted collection is offered only where its variables are still bound, in what it holds.\n if ((!holders || collection.deleted) && !bound(collection.id)) continue\n const inherited = shared(\n targets.map((target) =>\n target.parentId\n ? graph.getNodeVariableModeId(target.parentId, collection.id)\n : collection.defaultModeId\n )\n )\n choices.push({\n collectionId: collection.id,\n name: collection.name,\n library: isLibraryCollection(collection),\n modes: collection.modes.map((mode) => ({ modeId: mode.modeId, name: mode.name })),\n value: shared(targets.map((target) => target.variableModes[collection.id] ?? null)),\n inherited: inherited === MIXED ? null : modeOption(collection, inherited)\n })\n }\n return choices\n}\n\n/**\n * Sets the mode `targets` show for a collection, or clears it with null so they inherit their\n * parent's again, in one undo step.\n */\nexport function setVariableMode(\n editor: Editor,\n targets: SceneNode[],\n collectionId: string,\n modeId: string | null\n): void {\n const changed = targets.filter(\n (target) => (target.variableModes[collectionId] ?? null) !== modeId\n )\n if (changed.length === 0) return\n const label = modeId ? 'Apply variable mode' : 'Remove variable mode'\n editor.undo.runBatch(label, () => {\n for (const target of changed) {\n const others = omit(target.variableModes, [collectionId])\n const variableModes = modeId ? { ...others, [collectionId]: modeId } : others\n editor.updateNodeWithUndo(target.id, { variableModes }, label)\n }\n })\n}\n"],"mappings":";;;;;AA6BA,SAAS,WAAW,YAAgC,QAA2C;CAC7F,MAAM,OAAO,WAAW,MAAM,MAAM,cAAc,UAAU,WAAW,MAAM;CAC7E,OAAO,OAAO;EAAE,QAAQ,KAAK;EAAQ,MAAM,KAAK;CAAK,IAAI;AAC3D;AAEA,SAAS,OAAU,QAAqC;CACtD,MAAM,CAAC,SAAS;CAChB,OAAO,OAAO,OAAO,UAAU,UAAU,KAAK,IAAI,QAAQ;AAC5D;;;;;AAMA,SAAgB,oBAAoB,QAAgB,SAA4C;CAC9F,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAClC,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,QAAQ,OAAO,WAAW,OAAO,SAAS,QAAQ;CAClE,IAAI;CACJ,MAAM,SAAS,QACZ,SAAS,mBACR,OACA,QAAQ,KAAK,WAAW,OAAO,EAAE,CACnC,EAAA,CAAG,IAAI,EAAE;CACX,MAAM,UAAgC,CAAC;CACvC,KAAK,MAAM,cAAc,MAAM,oBAAoB,OAAO,GAAG;EAC3D,IAAI,WAAW,MAAM,SAAS,GAAG;EAEjC,KAAK,CAAC,WAAW,WAAW,YAAY,CAAC,MAAM,WAAW,EAAE,GAAG;EAC/D,MAAM,YAAY,OAChB,QAAQ,KAAK,WACX,OAAO,WACH,MAAM,sBAAsB,OAAO,UAAU,WAAW,EAAE,IAC1D,WAAW,aACjB,CACF;EACA,QAAQ,KAAK;GACX,cAAc,WAAW;GACzB,MAAM,WAAW;GACjB,SAAS,oBAAoB,UAAU;GACvC,OAAO,WAAW,MAAM,KAAK,UAAU;IAAE,QAAQ,KAAK;IAAQ,MAAM,KAAK;GAAK,EAAE;GAChF,OAAO,OAAO,QAAQ,KAAK,WAAW,OAAO,cAAc,WAAW,OAAO,IAAI,CAAC;GAClF,WAAW,cAAc,QAAQ,OAAO,WAAW,YAAY,SAAS;EAC1E,CAAC;CACH;CACA,OAAO;AACT;;;;;AAMA,SAAgB,gBACd,QACA,SACA,cACA,QACM;CACN,MAAM,UAAU,QAAQ,QACrB,YAAY,OAAO,cAAc,iBAAiB,UAAU,MAC/D;CACA,IAAI,QAAQ,WAAW,GAAG;CAC1B,MAAM,QAAQ,SAAS,wBAAwB;CAC/C,OAAO,KAAK,SAAS,aAAa;EAChC,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,SAAS,KAAK,OAAO,eAAe,CAAC,YAAY,CAAC;GACxD,MAAM,gBAAgB,SAAS;IAAE,GAAG;KAAS,eAAe;GAAO,IAAI;GACvE,OAAO,mBAAmB,OAAO,IAAI,EAAE,cAAc,GAAG,KAAK;EAC/D;CACF,CAAC;AACH"}
|
package/dist/i18n/create.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/i18n/create.d.ts
|
|
2
|
-
declare const i18n: import("@nanostores/i18n").I18n<"en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN">;
|
|
2
|
+
declare const i18n: import("@nanostores/i18n").I18n<"id" | "en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN">;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { i18n };
|
|
5
5
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","names":[],"sources":["../../src/i18n/create.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"create.d.ts","names":[],"sources":["../../src/i18n/create.ts"],"mappings":";cAkBa,iCAAI"}
|
package/dist/i18n/create.js
CHANGED
|
@@ -5,6 +5,7 @@ const localeLoaders = {
|
|
|
5
5
|
de: () => import("./locales/de/index.js"),
|
|
6
6
|
es: () => import("./locales/es/index.js"),
|
|
7
7
|
fr: () => import("./locales/fr/index.js"),
|
|
8
|
+
id: () => import("./locales/id/index.js"),
|
|
8
9
|
it: () => import("./locales/it/index.js"),
|
|
9
10
|
ja: () => import("./locales/ja/index.js"),
|
|
10
11
|
pl: () => import("./locales/pl/index.js"),
|
package/dist/i18n/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","names":[],"sources":["../../src/i18n/create.ts"],"sourcesContent":["import { createI18n } from '@nanostores/i18n'\nimport type { ComponentsJSON } from '@nanostores/i18n'\n\nimport { locale } from '#vue/i18n/locale'\nimport type { Locale, TranslatedLocale } from '#vue/i18n/locale'\n\nconst localeLoaders = {\n de: () => import('#vue/i18n/locales/de'),\n es: () => import('#vue/i18n/locales/es'),\n fr: () => import('#vue/i18n/locales/fr'),\n it: () => import('#vue/i18n/locales/it'),\n ja: () => import('#vue/i18n/locales/ja'),\n pl: () => import('#vue/i18n/locales/pl'),\n ru: () => import('#vue/i18n/locales/ru'),\n 'zh-CN': () => import('#vue/i18n/locales/zh-cn')\n} satisfies Record<TranslatedLocale, () => Promise<{ default: ComponentsJSON }>>\n\nexport const i18n = createI18n<Locale, 'en'>(locale, {\n baseLocale: 'en',\n async get(code) {\n if (code === 'en') return {}\n const mod = await localeLoaders[code]()\n return mod.default\n }\n})\n"],"mappings":";;;AAMA,MAAM,gBAAgB;CACpB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,eAAe,OAAO;AACxB;AAEA,MAAa,OAAO,WAAyB,QAAQ;CACnD,YAAY;CACZ,MAAM,IAAI,MAAM;EACd,IAAI,SAAS,MAAM,OAAO,CAAC;EAE3B,QAAO,MADW,cAAc,KAAK,CAAC,EAAA,CAC3B;CACb;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"create.js","names":[],"sources":["../../src/i18n/create.ts"],"sourcesContent":["import { createI18n } from '@nanostores/i18n'\nimport type { ComponentsJSON } from '@nanostores/i18n'\n\nimport { locale } from '#vue/i18n/locale'\nimport type { Locale, TranslatedLocale } from '#vue/i18n/locale'\n\nconst localeLoaders = {\n de: () => import('#vue/i18n/locales/de'),\n es: () => import('#vue/i18n/locales/es'),\n fr: () => import('#vue/i18n/locales/fr'),\n id: () => import('#vue/i18n/locales/id'),\n it: () => import('#vue/i18n/locales/it'),\n ja: () => import('#vue/i18n/locales/ja'),\n pl: () => import('#vue/i18n/locales/pl'),\n ru: () => import('#vue/i18n/locales/ru'),\n 'zh-CN': () => import('#vue/i18n/locales/zh-cn')\n} satisfies Record<TranslatedLocale, () => Promise<{ default: ComponentsJSON }>>\n\nexport const i18n = createI18n<Locale, 'en'>(locale, {\n baseLocale: 'en',\n async get(code) {\n if (code === 'en') return {}\n const mod = await localeLoaders[code]()\n return mod.default\n }\n})\n"],"mappings":";;;AAMA,MAAM,gBAAgB;CACpB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,UAAU,OAAO;CACjB,eAAe,OAAO;AACxB;AAEA,MAAa,OAAO,WAAyB,QAAQ;CACnD,YAAY;CACZ,MAAM,IAAI,MAAM;EACd,IAAI,SAAS,MAAM,OAAO,CAAC;EAE3B,QAAO,MADW,cAAc,KAAK,CAAC,EAAA,CAC3B;CACb;AACF,CAAC"}
|
package/dist/i18n/locale.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
//#region src/i18n/locale.d.ts
|
|
2
|
-
declare const AVAILABLE_LOCALES: readonly ["en", "de", "es", "fr", "it", "ja", "pl", "ru", "zh-CN"];
|
|
2
|
+
declare const AVAILABLE_LOCALES: readonly ["en", "de", "es", "fr", "id", "it", "ja", "pl", "ru", "zh-CN"];
|
|
3
3
|
type Locale = (typeof AVAILABLE_LOCALES)[number];
|
|
4
4
|
type TranslatedLocale = Exclude<Locale, 'en'>;
|
|
5
|
-
declare const TRANSLATED_LOCALES: readonly ["de", "es", "fr", "it", "ja", "pl", "ru", "zh-CN"];
|
|
5
|
+
declare const TRANSLATED_LOCALES: readonly ["de", "es", "fr", "id", "it", "ja", "pl", "ru", "zh-CN"];
|
|
6
6
|
declare const LOCALE_DIR_NAMES: {
|
|
7
7
|
readonly de: "de";
|
|
8
8
|
readonly es: "es";
|
|
9
9
|
readonly fr: "fr";
|
|
10
|
+
readonly id: "id";
|
|
10
11
|
readonly it: "it";
|
|
11
12
|
readonly ja: "ja";
|
|
12
13
|
readonly pl: "pl";
|
|
@@ -14,8 +15,8 @@ declare const LOCALE_DIR_NAMES: {
|
|
|
14
15
|
readonly 'zh-CN': "zh-cn";
|
|
15
16
|
};
|
|
16
17
|
declare const LOCALE_LABELS: Record<Locale, string>;
|
|
17
|
-
declare const localeSetting: import("nanostores").PreinitializedWritableAtom<"en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN" | undefined> & object;
|
|
18
|
-
declare const locale: import("@nanostores/i18n").LocaleStore<"en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN">;
|
|
18
|
+
declare const localeSetting: import("nanostores").PreinitializedWritableAtom<"id" | "en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN" | undefined> & object;
|
|
19
|
+
declare const locale: import("@nanostores/i18n").LocaleStore<"id" | "en" | "de" | "es" | "fr" | "it" | "ja" | "pl" | "ru" | "zh-CN">;
|
|
19
20
|
declare function setLocale(code: Locale): void;
|
|
20
21
|
//#endregion
|
|
21
22
|
export { AVAILABLE_LOCALES, LOCALE_DIR_NAMES, LOCALE_LABELS, Locale, TRANSLATED_LOCALES, TranslatedLocale, locale, localeSetting, setLocale };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","names":[],"sources":["../../src/i18n/locale.ts"],"mappings":";cAGa;
|
|
1
|
+
{"version":3,"file":"locale.d.ts","names":[],"sources":["../../src/i18n/locale.ts"],"mappings":";cAGa;KAYD,iBAAiB;KACjB,mBAAmB,QAAQ;cAE1B;cAYA;;;;;;;;;;;cAYA,eAAe,OAAO;cAetB,oCAAa;cAmCb,mCAAM;iBASH,UAAU,MAAM"}
|
package/dist/i18n/locale.js
CHANGED
|
@@ -6,6 +6,7 @@ const AVAILABLE_LOCALES = [
|
|
|
6
6
|
"de",
|
|
7
7
|
"es",
|
|
8
8
|
"fr",
|
|
9
|
+
"id",
|
|
9
10
|
"it",
|
|
10
11
|
"ja",
|
|
11
12
|
"pl",
|
|
@@ -16,6 +17,7 @@ const TRANSLATED_LOCALES = [
|
|
|
16
17
|
"de",
|
|
17
18
|
"es",
|
|
18
19
|
"fr",
|
|
20
|
+
"id",
|
|
19
21
|
"it",
|
|
20
22
|
"ja",
|
|
21
23
|
"pl",
|
|
@@ -26,6 +28,7 @@ const LOCALE_DIR_NAMES = {
|
|
|
26
28
|
de: "de",
|
|
27
29
|
es: "es",
|
|
28
30
|
fr: "fr",
|
|
31
|
+
id: "id",
|
|
29
32
|
it: "it",
|
|
30
33
|
ja: "ja",
|
|
31
34
|
pl: "pl",
|
|
@@ -37,6 +40,7 @@ const LOCALE_LABELS = {
|
|
|
37
40
|
de: "Deutsch",
|
|
38
41
|
es: "Español",
|
|
39
42
|
fr: "Français",
|
|
43
|
+
id: "Bahasa Indonesia",
|
|
40
44
|
it: "Italiano",
|
|
41
45
|
ja: "日本語",
|
|
42
46
|
pl: "Polski",
|