@pairdraw/scene-graph 0.0.0-stage → 0.16.1
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/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/agent-notes/index.d.ts +3 -0
- package/dist/agent-notes/index.js +3 -0
- package/dist/agent-notes/model.d.ts +23 -0
- package/dist/agent-notes/model.d.ts.map +1 -0
- package/dist/agent-notes/model.js +36 -0
- package/dist/agent-notes/model.js.map +1 -0
- package/dist/agent-notes/schema.d.ts +19 -0
- package/dist/agent-notes/schema.d.ts.map +1 -0
- package/dist/agent-notes/schema.js +17 -0
- package/dist/agent-notes/schema.js.map +1 -0
- package/dist/arrow-caps.d.ts +65 -0
- package/dist/arrow-caps.d.ts.map +1 -0
- package/dist/arrow-caps.js +365 -0
- package/dist/arrow-caps.js.map +1 -0
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js +27 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +56 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/behaviours/kinds.js +273 -0
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +42 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +45 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +149 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +114 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +71 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/behaviours/spec.js +157 -0
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +18 -0
- package/dist/bindings.js.map +1 -0
- package/dist/browser-node/index.d.ts +3 -0
- package/dist/browser-node/index.js +3 -0
- package/dist/browser-node/model.d.ts +18 -0
- package/dist/browser-node/model.d.ts.map +1 -0
- package/dist/browser-node/model.js +31 -0
- package/dist/browser-node/model.js.map +1 -0
- package/dist/browser-node/schema.d.ts +23 -0
- package/dist/browser-node/schema.d.ts.map +1 -0
- package/dist/browser-node/schema.js +44 -0
- package/dist/browser-node/schema.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js +57 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +28 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +246 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +20 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/color/contrast.js +69 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/comments/document.js +33 -0
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/comments/merge.js +58 -0
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/comments/threads.js +132 -0
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/library-page.d.ts +11 -0
- package/dist/components/library-page.d.ts.map +1 -0
- package/dist/components/library-page.js +21 -0
- package/dist/components/library-page.js.map +1 -0
- package/dist/components/properties.d.ts +20 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +125 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +27 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +32 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +53 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +159 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +209 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +99 -0
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +276 -0
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +45 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +256 -0
- package/dist/copy.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/css/grid.js +63 -0
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +6 -0
- package/dist/css/index.js +6 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/events.js +18 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +19 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +33 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js +14 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +63 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +199 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +277 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +68 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +89 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +46 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +62 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +29 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +38 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +119 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +234 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +105 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +374 -0
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +74 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +211 -0
- package/dist/gradient.js.map +1 -0
- package/dist/graph.d.ts +186 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +630 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/group-bounds.js +146 -0
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +19 -0
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +39 -0
- package/dist/guides.js.map +1 -0
- package/dist/hit-test.d.ts +49 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +315 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/icons/glyph.js +109 -0
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +85 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +162 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +82 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +63 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +305 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/main-component.d.ts +11 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +42 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/modes.js +26 -0
- package/dist/instances/modes.js.map +1 -0
- package/dist/instances/overrides.d.ts +63 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +164 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/replacements.d.ts +19 -0
- package/dist/instances/replacements.d.ts.map +1 -0
- package/dist/instances/replacements.js +67 -0
- package/dist/instances/replacements.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/sync.js +305 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +60 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +120 -0
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/naming.d.ts +9 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +16 -0
- package/dist/naming.js.map +1 -0
- package/dist/node-defaults.d.ts +19 -0
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +243 -0
- package/dist/node-defaults.js.map +1 -0
- package/dist/order-keys.d.ts +39 -0
- package/dist/order-keys.d.ts.map +1 -0
- package/dist/order-keys.js +136 -0
- package/dist/order-keys.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +103 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +64 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +36 -0
- package/dist/parse-path.d.ts.map +1 -0
- package/dist/parse-path.js +200 -0
- package/dist/parse-path.js.map +1 -0
- package/dist/plugin-data/citation.d.ts +13 -0
- package/dist/plugin-data/citation.d.ts.map +1 -0
- package/dist/plugin-data/citation.js +23 -0
- package/dist/plugin-data/citation.js.map +1 -0
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +79 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +220 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +214 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +5 -0
- package/dist/plugin-data/index.js +5 -0
- package/dist/plugin-data/schema.d.ts +18 -0
- package/dist/plugin-data/schema.d.ts.map +1 -0
- package/dist/plugin-data/schema.js +29 -0
- package/dist/plugin-data/schema.js.map +1 -0
- package/dist/polygon.d.ts +55 -0
- package/dist/polygon.d.ts.map +1 -0
- package/dist/polygon.js +220 -0
- package/dist/polygon.js.map +1 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +63 -0
- package/dist/preview.js.map +1 -0
- package/dist/primitives/index.d.ts +43 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.d.ts +7 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +25 -0
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +41 -0
- package/dist/resize.d.ts.map +1 -0
- package/dist/resize.js +288 -0
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +150 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +22 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +71 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/script/index.d.ts +2 -0
- package/dist/script/index.js +2 -0
- package/dist/script/schema.d.ts +29 -0
- package/dist/script/schema.d.ts.map +1 -0
- package/dist/script/schema.js +51 -0
- package/dist/script/schema.js.map +1 -0
- package/dist/shaders/directives.d.ts +43 -0
- package/dist/shaders/directives.d.ts.map +1 -0
- package/dist/shaders/directives.js +293 -0
- package/dist/shaders/directives.js.map +1 -0
- package/dist/shaders/index.d.ts +5 -0
- package/dist/shaders/index.js +5 -0
- package/dist/shaders/model.d.ts +58 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +109 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +86 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +65 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +36 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +116 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +74 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +103 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +38 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +113 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +61 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +264 -0
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.d.ts +6 -0
- package/dist/source-metadata.d.ts.map +1 -0
- package/dist/source-metadata.js +11 -0
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/text/direction.d.ts +13 -0
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/text/direction.js +31 -0
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +19 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +40 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/text/picture.d.ts +18 -0
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +41 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +7 -0
- package/dist/transfer/index.js +7 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +82 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +910 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +89 -0
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +236 -0
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +66 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +251 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +30 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +89 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +246 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +21 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +58 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/variant-name.d.ts +6 -0
- package/dist/variant-name.d.ts.map +1 -0
- package/dist/variant-name.js +17 -0
- package/dist/variant-name.js.map +1 -0
- package/dist/variant-properties.d.ts +18 -0
- package/dist/variant-properties.d.ts.map +1 -0
- package/dist/variant-properties.js +74 -0
- package/dist/variant-properties.js.map +1 -0
- package/dist/vector-network.d.ts +48 -0
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +352 -0
- package/dist/vector-network.js.map +1 -0
- package/package.json +364 -4
- package/src/agent-notes/index.ts +2 -0
- package/src/agent-notes/model.ts +46 -0
- package/src/agent-notes/schema.ts +28 -0
- package/src/arrow-caps.ts +364 -0
- package/src/asset-keys.ts +25 -0
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +185 -0
- package/src/behaviours/layers.ts +51 -0
- package/src/behaviours/model.ts +184 -0
- package/src/behaviours/schema.ts +93 -0
- package/src/behaviours/spec.ts +178 -0
- package/src/bindings.ts +20 -0
- package/src/browser-node/index.ts +2 -0
- package/src/browser-node/model.ts +35 -0
- package/src/browser-node/schema.ts +62 -0
- package/src/buffered-events.ts +64 -0
- package/src/checkpoint.ts +325 -0
- package/src/clipping.ts +112 -0
- package/src/color/contrast.ts +71 -0
- package/src/color/index.ts +89 -0
- package/src/color/management.ts +210 -0
- package/src/color/normalize.ts +7 -0
- package/src/color/okhcl.ts +201 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +51 -0
- package/src/comments/index.ts +5 -0
- package/src/comments/list.ts +52 -0
- package/src/comments/merge.ts +63 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +156 -0
- package/src/components/exposure.ts +61 -0
- package/src/components/index.ts +9 -0
- package/src/components/library-page.ts +17 -0
- package/src/components/properties.ts +241 -0
- package/src/components/variants.ts +53 -0
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +60 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +144 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +204 -0
- package/src/constants.ts +13 -0
- package/src/coordinate.ts +298 -0
- package/src/copy.ts +341 -0
- package/src/css/grid.ts +70 -0
- package/src/css/index.ts +10 -0
- package/src/css/layout.ts +53 -0
- package/src/css/shadows.ts +68 -0
- package/src/css/text.ts +84 -0
- package/src/css/values.ts +42 -0
- package/src/events.ts +21 -0
- package/src/export-format.ts +33 -0
- package/src/export-scale.ts +16 -0
- package/src/fields/appearance.ts +35 -0
- package/src/fields/geometry.ts +11 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +64 -0
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +308 -0
- package/src/figjam/text.ts +78 -0
- package/src/font-style.ts +121 -0
- package/src/generated/index.ts +81 -0
- package/src/generated/kind.ts +26 -0
- package/src/generated/shape-with-text.ts +132 -0
- package/src/generated/sticky.ts +214 -0
- package/src/geometry.ts +490 -0
- package/src/gradient.ts +275 -0
- package/src/graph.ts +842 -0
- package/src/group-bounds.ts +178 -0
- package/src/guides.ts +47 -0
- package/src/hit-test.ts +501 -0
- package/src/icons/glyph.ts +128 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +63 -0
- package/src/icons/schema.ts +34 -0
- package/src/ids.ts +34 -0
- package/src/images.ts +89 -0
- package/src/index.ts +4 -0
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +84 -0
- package/src/instances/copies.ts +244 -0
- package/src/instances/cycles.ts +73 -0
- package/src/instances/fields.ts +90 -0
- package/src/instances/index.ts +467 -0
- package/src/instances/main-component.ts +61 -0
- package/src/instances/modes.ts +39 -0
- package/src/instances/overrides.ts +240 -0
- package/src/instances/placement.ts +29 -0
- package/src/instances/replacements.ts +80 -0
- package/src/instances/source-walk.ts +35 -0
- package/src/instances/sync.ts +556 -0
- package/src/instances/vector-geometry.ts +81 -0
- package/src/layout/aspect-ratio.ts +51 -0
- package/src/layout/guides.ts +132 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/keywords.ts +74 -0
- package/src/layout/sizing.ts +196 -0
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +116 -0
- package/src/mutation-impact.ts +85 -0
- package/src/naming.ts +11 -0
- package/src/node-defaults.ts +260 -0
- package/src/order-keys.ts +162 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +72 -0
- package/src/parse-path.ts +244 -0
- package/src/plugin-data/citation.ts +27 -0
- package/src/plugin-data/field.ts +140 -0
- package/src/plugin-data/fields.ts +306 -0
- package/src/plugin-data/index.ts +3 -0
- package/src/plugin-data/schema.ts +35 -0
- package/src/polygon.ts +228 -0
- package/src/preview.ts +80 -0
- package/src/primitives/index.ts +44 -0
- package/src/primitives/schema.ts +14 -0
- package/src/random.ts +28 -0
- package/src/resize.ts +415 -0
- package/src/scaling/index.ts +9 -0
- package/src/scaling/node.ts +168 -0
- package/src/scaling/tree.ts +85 -0
- package/src/script/index.ts +1 -0
- package/src/script/schema.ts +65 -0
- package/src/shaders/directives.ts +366 -0
- package/src/shaders/index.ts +4 -0
- package/src/shaders/model.ts +147 -0
- package/src/shaders/schema.ts +84 -0
- package/src/shaders/still.ts +41 -0
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +137 -0
- package/src/slots/authoring.ts +101 -0
- package/src/slots/content.ts +127 -0
- package/src/slots/frames.ts +160 -0
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +49 -0
- package/src/snap.ts +349 -0
- package/src/source-metadata.ts +8 -0
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/direction.ts +55 -0
- package/src/text/index.ts +6 -0
- package/src/text/lengths.ts +34 -0
- package/src/text/lists.ts +138 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/paragraphs.ts +241 -0
- package/src/text/picture.ts +57 -0
- package/src/text/references.ts +50 -0
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +84 -0
- package/src/transfer/history.ts +49 -0
- package/src/transfer/identity.ts +16 -0
- package/src/transfer/index.ts +6 -0
- package/src/transfer/nodes.ts +128 -0
- package/src/transfer/plan.ts +130 -0
- package/src/transfer/references.ts +9 -0
- package/src/transfer/remove.ts +39 -0
- package/src/transfer/validation.ts +59 -0
- package/src/transfer/variables.ts +83 -0
- package/src/types.ts +1205 -0
- package/src/undo.ts +285 -0
- package/src/variables/bindings.ts +310 -0
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +109 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/variables/index.ts +400 -0
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +61 -0
- package/src/variables/token.ts +40 -0
- package/src/variables/units.ts +15 -0
- package/src/variables/value.ts +92 -0
- package/src/variant-name.ts +15 -0
- package/src/variant-properties.ts +98 -0
- package/src/vector-network.ts +489 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { mapValues } from 'es-toolkit'
|
|
2
|
+
|
|
3
|
+
import type { SceneGraph } from '../graph'
|
|
4
|
+
import { readPluginData, withPluginData } from '../plugin-data/field'
|
|
5
|
+
import { PAIRDRAW_PLUGIN_DATA } from '../plugin-data/fields'
|
|
6
|
+
import type { ComponentPropertyDefinition, SceneNode } from '../types'
|
|
7
|
+
import {
|
|
8
|
+
behaviourContract,
|
|
9
|
+
INTERACTION_STATES,
|
|
10
|
+
type BehaviourKind,
|
|
11
|
+
type InteractionState
|
|
12
|
+
} from './kinds'
|
|
13
|
+
import type {
|
|
14
|
+
Behaviour,
|
|
15
|
+
BehaviourBooleanBinding,
|
|
16
|
+
BehaviourInteractionStates,
|
|
17
|
+
BehaviourNumberSettings
|
|
18
|
+
} from './schema'
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_NUMBER_SETTINGS: BehaviourNumberSettings = {
|
|
21
|
+
min: 0,
|
|
22
|
+
max: 100,
|
|
23
|
+
step: 1,
|
|
24
|
+
default: 50
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A boolean value's binding, if the behaviour has one. */
|
|
28
|
+
export function booleanBinding(
|
|
29
|
+
behaviour: Behaviour,
|
|
30
|
+
valueId: string
|
|
31
|
+
): BehaviourBooleanBinding | undefined {
|
|
32
|
+
return Object.hasOwn(behaviour.booleans, valueId) ? behaviour.booleans[valueId] : undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The slot property a part is bound to, if any. */
|
|
36
|
+
export function partBinding(behaviour: Behaviour, partId: string): string | undefined {
|
|
37
|
+
return Object.hasOwn(behaviour.parts, partId) ? behaviour.parts[partId] : undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The text property a text value is bound to, if any. */
|
|
41
|
+
export function textBinding(behaviour: Behaviour, valueId: string): string | undefined {
|
|
42
|
+
return Object.hasOwn(behaviour.texts, valueId) ? behaviour.texts[valueId].propertyId : undefined
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A number value's range, if the behaviour has one. */
|
|
46
|
+
export function numberSettings(
|
|
47
|
+
behaviour: Behaviour,
|
|
48
|
+
valueId: string
|
|
49
|
+
): BehaviourNumberSettings | undefined {
|
|
50
|
+
return Object.hasOwn(behaviour.numbers, valueId) ? behaviour.numbers[valueId] : undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A new behaviour of a kind, its number values at their defaults and nothing bound. */
|
|
54
|
+
export function emptyBehaviour(kind: BehaviourKind): Behaviour {
|
|
55
|
+
const contract = behaviourContract(kind)
|
|
56
|
+
const numbers = Object.fromEntries(
|
|
57
|
+
contract.values
|
|
58
|
+
.filter((value) => value.type === 'number')
|
|
59
|
+
.map((value) => [value.id, { ...DEFAULT_NUMBER_SETTINGS }])
|
|
60
|
+
)
|
|
61
|
+
return { kind, booleans: {}, texts: {}, numbers, parts: {} }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The node that keeps the behaviour: a component set for its variants, otherwise the main
|
|
66
|
+
* component itself.
|
|
67
|
+
*/
|
|
68
|
+
export function behaviourOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined {
|
|
69
|
+
if (node.type === 'COMPONENT_SET') return node
|
|
70
|
+
if (node.type !== 'COMPONENT') return undefined
|
|
71
|
+
const parent = node.parentId ? graph.getNode(node.parentId) : undefined
|
|
72
|
+
return parent?.type === 'COMPONENT_SET' ? parent : node
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The behaviour a component or component set keeps, or null when it has none or it is unreadable. */
|
|
76
|
+
export function readBehaviour(owner: SceneNode): Behaviour | null {
|
|
77
|
+
return readPluginData(owner.pluginData, PAIRDRAW_PLUGIN_DATA.behaviour) ?? null
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The owner's plugin data with the behaviour set, or removed when null. */
|
|
81
|
+
export function withBehaviour(
|
|
82
|
+
owner: SceneNode,
|
|
83
|
+
behaviour: Behaviour | null
|
|
84
|
+
): SceneNode['pluginData'] {
|
|
85
|
+
return withPluginData(owner.pluginData, PAIRDRAW_PLUGIN_DATA.behaviour, behaviour ?? undefined)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Component properties the behaviour can bind to: the owner's, and a set's variants' own. */
|
|
89
|
+
export function behaviourProperties(
|
|
90
|
+
graph: SceneGraph,
|
|
91
|
+
owner: SceneNode
|
|
92
|
+
): ComponentPropertyDefinition[] {
|
|
93
|
+
const variants =
|
|
94
|
+
owner.type === 'COMPONENT_SET'
|
|
95
|
+
? owner.childIds.flatMap((id) => graph.getNode(id)?.componentPropertyDefinitions ?? [])
|
|
96
|
+
: []
|
|
97
|
+
const seen = new Set<string>()
|
|
98
|
+
return [...owner.componentPropertyDefinitions, ...variants].filter((definition) => {
|
|
99
|
+
if (seen.has(definition.id)) return false
|
|
100
|
+
seen.add(definition.id)
|
|
101
|
+
return true
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Required values and parts that are unbound, or bound to a property the component no longer
|
|
107
|
+
* has, by value or part id; `states` when the interaction states lost their variant property.
|
|
108
|
+
*/
|
|
109
|
+
export function missingBindings(
|
|
110
|
+
graph: SceneGraph,
|
|
111
|
+
owner: SceneNode,
|
|
112
|
+
behaviour: Behaviour
|
|
113
|
+
): string[] {
|
|
114
|
+
const contract = behaviourContract(behaviour.kind)
|
|
115
|
+
const properties = new Map(
|
|
116
|
+
behaviourProperties(graph, owner).map((definition) => [definition.id, definition])
|
|
117
|
+
)
|
|
118
|
+
const bound = (propertyId: string | undefined, type: ComponentPropertyDefinition['type'][]) => {
|
|
119
|
+
const definition = propertyId ? properties.get(propertyId) : undefined
|
|
120
|
+
return !!definition && type.includes(definition.type)
|
|
121
|
+
}
|
|
122
|
+
const values = contract.values
|
|
123
|
+
.filter((value) => value.required)
|
|
124
|
+
.filter((value) =>
|
|
125
|
+
value.type === 'text'
|
|
126
|
+
? !bound(textBinding(behaviour, value.id), ['TEXT'])
|
|
127
|
+
: value.type === 'boolean' &&
|
|
128
|
+
!bound(booleanBinding(behaviour, value.id)?.propertyId, ['VARIANT', 'BOOLEAN'])
|
|
129
|
+
)
|
|
130
|
+
.map((value) => value.id)
|
|
131
|
+
const parts = contract.parts
|
|
132
|
+
.filter((part) => part.required && !bound(partBinding(behaviour, part.id), ['SLOT']))
|
|
133
|
+
.map((part) => part.id)
|
|
134
|
+
const states =
|
|
135
|
+
behaviour.states && !bound(behaviour.states.propertyId, ['VARIANT']) ? ['states'] : []
|
|
136
|
+
return [...values, ...parts, ...states]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Variant value names that usually mean each interaction state, compared case-insensitively. */
|
|
140
|
+
const STATE_NAMES: Record<InteractionState, readonly string[]> = {
|
|
141
|
+
rest: ['default', 'rest', 'idle', 'normal', 'enabled'],
|
|
142
|
+
hover: ['hover', 'hovered', 'hovering'],
|
|
143
|
+
pressed: ['pressed', 'active', 'down', 'pressing'],
|
|
144
|
+
focus: ['focus', 'focused', 'focus visible', 'focus-visible'],
|
|
145
|
+
disabled: ['disabled', 'inactive']
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Interaction states for a variant property, each mapped to the value whose name means it, such
|
|
150
|
+
* as `Hover` or `Pressed`; states without such a value are left unset.
|
|
151
|
+
*/
|
|
152
|
+
export function guessInteractionStates(
|
|
153
|
+
propertyId: string,
|
|
154
|
+
values: readonly string[]
|
|
155
|
+
): BehaviourInteractionStates {
|
|
156
|
+
const states: BehaviourInteractionStates = { propertyId }
|
|
157
|
+
for (const state of INTERACTION_STATES) {
|
|
158
|
+
const match = values.find((value) => STATE_NAMES[state].includes(value.trim().toLowerCase()))
|
|
159
|
+
if (match) states[state] = match
|
|
160
|
+
}
|
|
161
|
+
return states
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The behaviour with every component property id it binds renamed by `rename`, for formats that
|
|
166
|
+
* give properties new ids on write, such as `.fig` with its GUIDs.
|
|
167
|
+
*/
|
|
168
|
+
export function renameBehaviourProperties(
|
|
169
|
+
behaviour: Behaviour,
|
|
170
|
+
rename: (propertyId: string) => string
|
|
171
|
+
): Behaviour {
|
|
172
|
+
return {
|
|
173
|
+
...behaviour,
|
|
174
|
+
booleans: mapValues(behaviour.booleans, (binding) => ({
|
|
175
|
+
...binding,
|
|
176
|
+
propertyId: rename(binding.propertyId)
|
|
177
|
+
})),
|
|
178
|
+
texts: mapValues(behaviour.texts, (binding) => ({ propertyId: rename(binding.propertyId) })),
|
|
179
|
+
parts: mapValues(behaviour.parts, rename),
|
|
180
|
+
...(behaviour.states
|
|
181
|
+
? { states: { ...behaviour.states, propertyId: rename(behaviour.states.propertyId) } }
|
|
182
|
+
: {})
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
import { BEHAVIOUR_KINDS, type InteractionState } from './kinds'
|
|
4
|
+
|
|
5
|
+
const booleanBindingSchema = v.object({
|
|
6
|
+
propertyId: v.string(),
|
|
7
|
+
/** For a variant property: the values that mean on and off. */
|
|
8
|
+
on: v.optional(v.string()),
|
|
9
|
+
off: v.optional(v.string())
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
/** Whether a number value's range can be stepped through: `max` above `min`, a positive step. */
|
|
13
|
+
export function isNumberRange(settings: { min: number; max: number; step: number }): boolean {
|
|
14
|
+
return settings.max > settings.min && settings.step > 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const numberSettingsSchema = v.pipe(
|
|
18
|
+
v.object({
|
|
19
|
+
min: v.pipe(v.number(), v.finite()),
|
|
20
|
+
max: v.pipe(v.number(), v.finite()),
|
|
21
|
+
step: v.pipe(v.number(), v.finite()),
|
|
22
|
+
default: v.pipe(v.number(), v.finite())
|
|
23
|
+
}),
|
|
24
|
+
v.check(
|
|
25
|
+
(settings) => isNumberRange(settings),
|
|
26
|
+
'A number value needs max above min and a positive step'
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
/** Each interaction state's variant value, by state; a state left out shows the rest value. */
|
|
31
|
+
export const interactionStateValues = {
|
|
32
|
+
rest: v.optional(v.string()),
|
|
33
|
+
hover: v.optional(v.string()),
|
|
34
|
+
pressed: v.optional(v.string()),
|
|
35
|
+
focus: v.optional(v.string()),
|
|
36
|
+
disabled: v.optional(v.string())
|
|
37
|
+
} satisfies Record<InteractionState, unknown>
|
|
38
|
+
|
|
39
|
+
const interactionStatesSchema = v.object({ propertyId: v.string(), ...interactionStateValues })
|
|
40
|
+
|
|
41
|
+
export const behaviourSchema = v.object({
|
|
42
|
+
kind: v.picklist(BEHAVIOUR_KINDS),
|
|
43
|
+
/** Boolean values, by value id, bound to component properties. */
|
|
44
|
+
booleans: v.record(v.string(), booleanBindingSchema),
|
|
45
|
+
/** Text values, by value id, bound to text properties. */
|
|
46
|
+
texts: v.optional(v.record(v.string(), v.object({ propertyId: v.string() })), {}),
|
|
47
|
+
/** Number values, by value id: the range the behaviour keeps itself. */
|
|
48
|
+
numbers: v.record(v.string(), numberSettingsSchema),
|
|
49
|
+
/** Parts, by part id, bound to slot properties. */
|
|
50
|
+
parts: v.record(v.string(), v.string()),
|
|
51
|
+
states: v.optional(interactionStatesSchema)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
/** How a main component behaves as a control, as kept in its plugin data. */
|
|
55
|
+
export type Behaviour = v.InferOutput<typeof behaviourSchema>
|
|
56
|
+
export type BehaviourBooleanBinding = v.InferOutput<typeof booleanBindingSchema>
|
|
57
|
+
export type BehaviourNumberSettings = v.InferOutput<typeof numberSettingsSchema>
|
|
58
|
+
export type BehaviourInteractionStates = v.InferOutput<typeof interactionStatesSchema>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A behaviour as scripts, tools, and JSX write it: component properties and slots by name, not
|
|
62
|
+
* by id. Values are boolean or text values by their contract id; numbers are a slider's or
|
|
63
|
+
* number field's own range.
|
|
64
|
+
*/
|
|
65
|
+
export const behaviourSpecSchema = v.object({
|
|
66
|
+
kind: v.picklist(BEHAVIOUR_KINDS),
|
|
67
|
+
values: v.optional(
|
|
68
|
+
v.record(
|
|
69
|
+
v.string(),
|
|
70
|
+
v.union([
|
|
71
|
+
v.string(),
|
|
72
|
+
v.object({ property: v.string(), on: v.optional(v.string()), off: v.optional(v.string()) })
|
|
73
|
+
])
|
|
74
|
+
)
|
|
75
|
+
),
|
|
76
|
+
numbers: v.optional(
|
|
77
|
+
v.record(
|
|
78
|
+
v.string(),
|
|
79
|
+
v.object({
|
|
80
|
+
min: v.optional(v.number()),
|
|
81
|
+
max: v.optional(v.number()),
|
|
82
|
+
step: v.optional(v.number()),
|
|
83
|
+
default: v.optional(v.number())
|
|
84
|
+
})
|
|
85
|
+
)
|
|
86
|
+
),
|
|
87
|
+
parts: v.optional(v.record(v.string(), v.string())),
|
|
88
|
+
states: v.optional(
|
|
89
|
+
v.union([v.string(), v.object({ property: v.string(), ...interactionStateValues })])
|
|
90
|
+
)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
export type BehaviourSpec = v.InferOutput<typeof behaviourSpecSchema>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { omitBy } from 'es-toolkit/object'
|
|
2
|
+
|
|
3
|
+
import type { SceneGraph } from '../graph'
|
|
4
|
+
import type { ComponentPropertyDefinition, SceneNode } from '../types'
|
|
5
|
+
import { behaviourContract } from './kinds'
|
|
6
|
+
import { behaviourProperties, emptyBehaviour, guessInteractionStates, textBinding } from './model'
|
|
7
|
+
import { isNumberRange, type Behaviour, type BehaviourSpec } from './schema'
|
|
8
|
+
|
|
9
|
+
/** Variant values that usually mean on, compared case-insensitively. */
|
|
10
|
+
const ON_NAMES = ['on', 'true', 'yes', 'checked', 'pressed', 'open', 'selected', 'active']
|
|
11
|
+
const OFF_NAMES = ['off', 'false', 'no', 'unchecked', 'closed', 'default', 'inactive']
|
|
12
|
+
|
|
13
|
+
function named(names: readonly string[], options: readonly string[]): string | undefined {
|
|
14
|
+
return options.find((option) => names.includes(option.trim().toLowerCase()))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The variant values that likely mean on and off: names such as On, True, or Checked first,
|
|
19
|
+
* then the values in order.
|
|
20
|
+
*/
|
|
21
|
+
export function guessOnOff(
|
|
22
|
+
options: readonly string[],
|
|
23
|
+
explicit: { on?: string; off?: string } = {}
|
|
24
|
+
): { on?: string; off?: string } {
|
|
25
|
+
const on = explicit.on ?? named(ON_NAMES, options) ?? options[0]
|
|
26
|
+
const off = explicit.off ?? named(OFF_NAMES, options) ?? options.find((option) => option !== on)
|
|
27
|
+
return { on, off }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function findProperty(
|
|
31
|
+
properties: readonly ComponentPropertyDefinition[],
|
|
32
|
+
name: string,
|
|
33
|
+
types: readonly ComponentPropertyDefinition['type'][],
|
|
34
|
+
what: string
|
|
35
|
+
): ComponentPropertyDefinition {
|
|
36
|
+
const found = properties.find((item) => item.name === name && types.includes(item.type))
|
|
37
|
+
if (found) return found
|
|
38
|
+
const available = properties.filter((item) => types.includes(item.type)).map((item) => item.name)
|
|
39
|
+
throw new Error(
|
|
40
|
+
`${what} needs a ${types.join(' or ')} property named "${name}"; the component has ${
|
|
41
|
+
available.length ? available.map((item) => `"${item}"`).join(', ') : 'none'
|
|
42
|
+
}`
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type ValueBinding = NonNullable<BehaviourSpec['values']>[string]
|
|
47
|
+
type StatesSpec = NonNullable<BehaviourSpec['states']>
|
|
48
|
+
|
|
49
|
+
function listed(items: readonly { id: string }[]): string {
|
|
50
|
+
return items.map((item) => `"${item.id}"`).join(', ')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Bind a boolean or text value to the property named in its binding. */
|
|
54
|
+
function resolveValue(
|
|
55
|
+
behaviour: Behaviour,
|
|
56
|
+
properties: readonly ComponentPropertyDefinition[],
|
|
57
|
+
valueId: string,
|
|
58
|
+
binding: ValueBinding
|
|
59
|
+
): void {
|
|
60
|
+
const contract = behaviourContract(behaviour.kind)
|
|
61
|
+
const bindable = contract.values.filter((item) => item.type === 'boolean' || item.type === 'text')
|
|
62
|
+
const value = bindable.find((item) => item.id === valueId)
|
|
63
|
+
if (!value)
|
|
64
|
+
throw new Error(
|
|
65
|
+
`A ${behaviour.kind} has no boolean or text value "${valueId}"; it has ${listed(bindable)}`
|
|
66
|
+
)
|
|
67
|
+
const name = typeof binding === 'string' ? binding : binding.property
|
|
68
|
+
if (value.type === 'text') {
|
|
69
|
+
behaviour.texts[valueId] = { propertyId: findProperty(properties, name, ['TEXT'], valueId).id }
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
const definition = findProperty(properties, name, ['VARIANT', 'BOOLEAN'], valueId)
|
|
73
|
+
if (definition.type === 'BOOLEAN') {
|
|
74
|
+
behaviour.booleans[valueId] = { propertyId: definition.id }
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
const options = definition.variantOptions ?? []
|
|
78
|
+
const explicit: { on?: string; off?: string } = typeof binding === 'string' ? {} : binding
|
|
79
|
+
const { on, off } = guessOnOff(options, explicit)
|
|
80
|
+
for (const choice of [on, off])
|
|
81
|
+
if (choice !== undefined && !options.includes(choice))
|
|
82
|
+
throw new Error(`"${definition.name}" has no value "${choice}"; it has ${options.join(', ')}`)
|
|
83
|
+
behaviour.booleans[valueId] = { propertyId: definition.id, on, off }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function resolveStates(
|
|
87
|
+
behaviour: Behaviour,
|
|
88
|
+
properties: readonly ComponentPropertyDefinition[],
|
|
89
|
+
states: StatesSpec
|
|
90
|
+
): void {
|
|
91
|
+
const name = typeof states === 'string' ? states : states.property
|
|
92
|
+
const definition = findProperty(properties, name, ['VARIANT'], 'states')
|
|
93
|
+
const guessed = guessInteractionStates(definition.id, definition.variantOptions ?? [])
|
|
94
|
+
if (typeof states === 'string') {
|
|
95
|
+
behaviour.states = guessed
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
const { property: _property, ...values } = states
|
|
99
|
+
behaviour.states = { ...guessed, ...stripUndefined(values) }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The stored behaviour for a spec, with names resolved to the owner's property and slot ids. A
|
|
104
|
+
* name the component lacks, a value the kind does not have, or a variant value the property
|
|
105
|
+
* does not offer fails with a message naming what exists.
|
|
106
|
+
*/
|
|
107
|
+
export function behaviourFromSpec(
|
|
108
|
+
graph: SceneGraph,
|
|
109
|
+
owner: SceneNode,
|
|
110
|
+
spec: BehaviourSpec
|
|
111
|
+
): Behaviour {
|
|
112
|
+
const contract = behaviourContract(spec.kind)
|
|
113
|
+
const properties = behaviourProperties(graph, owner)
|
|
114
|
+
const behaviour = emptyBehaviour(spec.kind)
|
|
115
|
+
for (const [valueId, binding] of Object.entries(spec.values ?? {}))
|
|
116
|
+
resolveValue(behaviour, properties, valueId, binding)
|
|
117
|
+
const numbers = contract.values.filter((item) => item.type === 'number')
|
|
118
|
+
for (const [valueId, settings] of Object.entries(spec.numbers ?? {})) {
|
|
119
|
+
if (!numbers.some((item) => item.id === valueId))
|
|
120
|
+
throw new Error(`A ${spec.kind} has no number value "${valueId}"; it has ${listed(numbers)}`)
|
|
121
|
+
const range = { ...behaviour.numbers[valueId], ...stripUndefined(settings) }
|
|
122
|
+
if (!isNumberRange(range))
|
|
123
|
+
throw new Error(`"${valueId}" needs max above min and a positive step`)
|
|
124
|
+
behaviour.numbers[valueId] = range
|
|
125
|
+
}
|
|
126
|
+
for (const [partId, slotName] of Object.entries(spec.parts ?? {})) {
|
|
127
|
+
if (!contract.parts.some((item) => item.id === partId))
|
|
128
|
+
throw new Error(`A ${spec.kind} has no part "${partId}"; it has ${listed(contract.parts)}`)
|
|
129
|
+
const id = findProperty(properties, slotName, ['SLOT'], partId).id
|
|
130
|
+
const taken = Object.entries(behaviour.parts).find(([, slot]) => slot === id)?.[0]
|
|
131
|
+
if (taken) throw new Error(`"${slotName}" is already the ${taken}; a slot draws one part`)
|
|
132
|
+
behaviour.parts[partId] = id
|
|
133
|
+
}
|
|
134
|
+
if (spec.states !== undefined) resolveStates(behaviour, properties, spec.states)
|
|
135
|
+
return behaviour
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function stripUndefined<T extends Record<string, unknown>>(record: T): Partial<T> {
|
|
139
|
+
return omitBy(record, (value) => value === undefined)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The spec a stored behaviour reads as, with ids back to names; unresolved bindings are left out. */
|
|
143
|
+
export function behaviourToSpec(
|
|
144
|
+
graph: SceneGraph,
|
|
145
|
+
owner: SceneNode,
|
|
146
|
+
behaviour: Behaviour
|
|
147
|
+
): BehaviourSpec {
|
|
148
|
+
const properties = behaviourProperties(graph, owner)
|
|
149
|
+
const nameOf = (id: string | undefined) => properties.find((item) => item.id === id)?.name
|
|
150
|
+
const values: NonNullable<BehaviourSpec['values']> = {}
|
|
151
|
+
for (const [valueId, binding] of Object.entries(behaviour.booleans)) {
|
|
152
|
+
const name = nameOf(binding.propertyId)
|
|
153
|
+
if (name)
|
|
154
|
+
values[valueId] =
|
|
155
|
+
binding.on || binding.off ? { property: name, on: binding.on, off: binding.off } : name
|
|
156
|
+
}
|
|
157
|
+
for (const valueId of Object.keys(behaviour.texts)) {
|
|
158
|
+
const name = nameOf(textBinding(behaviour, valueId))
|
|
159
|
+
if (name) values[valueId] = name
|
|
160
|
+
}
|
|
161
|
+
const parts = Object.fromEntries(
|
|
162
|
+
Object.entries(behaviour.parts).flatMap(([partId, id]) => {
|
|
163
|
+
const name = nameOf(id)
|
|
164
|
+
return name ? [[partId, name]] : []
|
|
165
|
+
})
|
|
166
|
+
)
|
|
167
|
+
const statesName = nameOf(behaviour.states?.propertyId)
|
|
168
|
+
const spec: BehaviourSpec = { kind: behaviour.kind }
|
|
169
|
+
if (Object.keys(values).length) spec.values = values
|
|
170
|
+
if (Object.keys(behaviour.numbers).length) spec.numbers = structuredClone(behaviour.numbers)
|
|
171
|
+
if (Object.keys(parts).length) spec.parts = parts
|
|
172
|
+
if (behaviour.states && statesName)
|
|
173
|
+
spec.states = {
|
|
174
|
+
...stripUndefined({ ...behaviour.states, propertyId: undefined }),
|
|
175
|
+
property: statesName
|
|
176
|
+
}
|
|
177
|
+
return spec
|
|
178
|
+
}
|
package/src/bindings.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { omit } from 'es-toolkit/object'
|
|
2
|
+
|
|
3
|
+
import type { SceneNode } from './types'
|
|
4
|
+
|
|
5
|
+
export function removeStaleBindings(
|
|
6
|
+
node: SceneNode,
|
|
7
|
+
field: 'fills' | 'strokes',
|
|
8
|
+
changes: Partial<SceneNode>
|
|
9
|
+
): void {
|
|
10
|
+
const length = node[field].length
|
|
11
|
+
const stale = Object.keys(node.boundVariables).filter((key) => {
|
|
12
|
+
if (key === field) return true
|
|
13
|
+
if (!key.startsWith(`${field}/`)) return false
|
|
14
|
+
const index = Number.parseInt(key.split('/')[1] ?? '', 10)
|
|
15
|
+
return Number.isNaN(index) || index < 0 || index >= length
|
|
16
|
+
})
|
|
17
|
+
if (stale.length === 0) return
|
|
18
|
+
node.boundVariables = omit(node.boundVariables, stale)
|
|
19
|
+
changes.boundVariables = { ...node.boundVariables }
|
|
20
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
import { hasPluginData, readPluginData, withPluginData } from '../plugin-data/field'
|
|
4
|
+
import { PAIRDRAW_PLUGIN_DATA } from '../plugin-data/fields'
|
|
5
|
+
import type { PluginDataEntry, SceneNode } from '../types'
|
|
6
|
+
import { browserNodeSchema, type BrowserNodeRecord } from './schema'
|
|
7
|
+
|
|
8
|
+
const field = PAIRDRAW_PLUGIN_DATA.browserNode
|
|
9
|
+
|
|
10
|
+
/** The snapshot a layer stores, or null when it has none or the address is not a page. */
|
|
11
|
+
export function readBrowserNode(node: Pick<SceneNode, 'pluginData'>): BrowserNodeRecord | null {
|
|
12
|
+
return readPluginData(node.pluginData, field) ?? null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Plugin data with this snapshot, or without it when `record` is null or not a page snapshot.
|
|
17
|
+
* The picture stays in the layer's image fill either way.
|
|
18
|
+
*/
|
|
19
|
+
export function withBrowserNode(
|
|
20
|
+
node: Pick<SceneNode, 'pluginData'>,
|
|
21
|
+
record: BrowserNodeRecord | null
|
|
22
|
+
): SceneNode['pluginData'] {
|
|
23
|
+
const parsed = record === null ? null : v.safeParse(browserNodeSchema, record)
|
|
24
|
+
return withPluginData(node.pluginData, field, parsed?.success ? parsed.output : undefined)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Plugin data as a file should open it. A browser snapshot whose address is not an http or
|
|
29
|
+
* https page is removed, and the layer's image is left alone. Nothing here loads a page.
|
|
30
|
+
*/
|
|
31
|
+
export function settleBrowserNodeData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {
|
|
32
|
+
const stored = [...entries]
|
|
33
|
+
if (!hasPluginData(stored, field) || readPluginData(stored, field)) return stored
|
|
34
|
+
return withPluginData(stored, field, undefined)
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
/** The longest page address a browser node stores. A longer one is not a page address. */
|
|
4
|
+
export const BROWSER_NODE_URL_LIMIT = 2000
|
|
5
|
+
|
|
6
|
+
/** The largest viewport, in pixels, a browser node stores for either side. */
|
|
7
|
+
export const BROWSER_NODE_SIZE_LIMIT = 8192
|
|
8
|
+
|
|
9
|
+
/** The longest preset id a browser node stores. The toolbar's ids are shorter. */
|
|
10
|
+
export const BROWSER_NODE_PRESET_LIMIT = 40
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A stored page address: the canonical `href` of an `http` or `https` URL that has a host.
|
|
14
|
+
* That is the form the browser window's address policy returns. Anything else, including a
|
|
15
|
+
* `file:` address or a host with no scheme, does not decode, so the layer stays an image.
|
|
16
|
+
*/
|
|
17
|
+
function isStoredPageURL(value: string): boolean {
|
|
18
|
+
let url: URL
|
|
19
|
+
try {
|
|
20
|
+
url = new URL(value)
|
|
21
|
+
} catch {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
(url.protocol === 'http:' || url.protocol === 'https:') &&
|
|
26
|
+
url.hostname !== '' &&
|
|
27
|
+
url.href === value
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `Date.toISOString()`, so a stored instant is not a sliced or local clock reading. */
|
|
32
|
+
function isIsoInstant(value: string): boolean {
|
|
33
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value)) return false
|
|
34
|
+
const parsed = Date.parse(value)
|
|
35
|
+
return Number.isFinite(parsed) && new Date(parsed).toISOString() === value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sizeSchema = v.pipe(
|
|
39
|
+
v.number(),
|
|
40
|
+
v.integer(),
|
|
41
|
+
v.minValue(1),
|
|
42
|
+
v.maxValue(BROWSER_NODE_SIZE_LIMIT)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* What a browser snapshot node remembers besides its image fill: the page address, the viewport
|
|
47
|
+
* it was shot at, which toolbar preset that size came from, and when it was last refreshed.
|
|
48
|
+
*/
|
|
49
|
+
export const browserNodeSchema = v.object({
|
|
50
|
+
url: v.pipe(
|
|
51
|
+
v.string(),
|
|
52
|
+
v.minLength(1),
|
|
53
|
+
v.maxLength(BROWSER_NODE_URL_LIMIT),
|
|
54
|
+
v.check(isStoredPageURL)
|
|
55
|
+
),
|
|
56
|
+
width: sizeSchema,
|
|
57
|
+
height: sizeSchema,
|
|
58
|
+
preset: v.pipe(v.string(), v.minLength(1), v.maxLength(BROWSER_NODE_PRESET_LIMIT)),
|
|
59
|
+
refreshedAt: v.pipe(v.string(), v.check(isIsoInstant))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export type BrowserNodeRecord = v.InferOutput<typeof browserNodeSchema>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createNanoEvents, type Emitter } from 'nanoevents'
|
|
2
|
+
|
|
3
|
+
import type { SceneGraphEvents } from './types'
|
|
4
|
+
|
|
5
|
+
export class CommittedGraphEventError extends AggregateError {
|
|
6
|
+
readonly committed = true
|
|
7
|
+
|
|
8
|
+
constructor(errors: readonly unknown[]) {
|
|
9
|
+
super(errors, 'Committed graph event delivery failed')
|
|
10
|
+
this.name = 'CommittedGraphEventError'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Stable emitter identity with synchronous, nestable event buffering. */
|
|
15
|
+
export class BufferedSceneEmitter implements Emitter<SceneGraphEvents> {
|
|
16
|
+
private readonly delegate = createNanoEvents<SceneGraphEvents>()
|
|
17
|
+
private readonly buffers: Array<Array<() => void>> = []
|
|
18
|
+
|
|
19
|
+
get events(): Emitter<SceneGraphEvents>['events'] {
|
|
20
|
+
return this.delegate.events
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
set events(events: Emitter<SceneGraphEvents>['events']) {
|
|
24
|
+
this.delegate.events = events
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
on<K extends keyof SceneGraphEvents>(event: K, listener: SceneGraphEvents[K]) {
|
|
28
|
+
return this.delegate.on(event, listener)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
emit<K extends keyof SceneGraphEvents>(event: K, ...args: Parameters<SceneGraphEvents[K]>): void {
|
|
32
|
+
const buffer = this.buffers.at(-1)
|
|
33
|
+
if (buffer) buffer.push(() => this.delegate.emit(event, ...args))
|
|
34
|
+
else this.delegate.emit(event, ...args)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Buffers events, not mutations. Callers own rollback if the action throws. */
|
|
38
|
+
batch<T>(action: () => T): T {
|
|
39
|
+
const pending: Array<() => void> = []
|
|
40
|
+
this.buffers.push(pending)
|
|
41
|
+
let result: T
|
|
42
|
+
try {
|
|
43
|
+
result = action()
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.buffers.pop()
|
|
46
|
+
throw error
|
|
47
|
+
}
|
|
48
|
+
this.buffers.pop()
|
|
49
|
+
const outer = this.buffers.at(-1)
|
|
50
|
+
if (outer) outer.push(...pending)
|
|
51
|
+
else {
|
|
52
|
+
const errors: unknown[] = []
|
|
53
|
+
for (const publish of pending) {
|
|
54
|
+
try {
|
|
55
|
+
publish()
|
|
56
|
+
} catch (error) {
|
|
57
|
+
errors.push(error)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (errors.length) throw new CommittedGraphEventError(errors)
|
|
61
|
+
}
|
|
62
|
+
return result
|
|
63
|
+
}
|
|
64
|
+
}
|