@pairdraw/scene-graph 0.0.0-stage → 0.16.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/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 +13 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +78 -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 +352 -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 +123 -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,90 @@
|
|
|
1
|
+
import { difference } from 'es-toolkit/array'
|
|
2
|
+
|
|
3
|
+
import { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from '../fields/appearance'
|
|
4
|
+
import { SIZE_FIELDS, TRANSFORM_FIELDS } from '../fields/geometry'
|
|
5
|
+
import { AUTO_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from '../fields/layout'
|
|
6
|
+
import { TEXT_STYLE_FIELDS } from '../fields/text'
|
|
7
|
+
import { STYLE_LINK_FIELDS } from '../shared-styles'
|
|
8
|
+
import type { SceneNode } from '../types'
|
|
9
|
+
|
|
10
|
+
export const INSTANCE_SYNC_TEXT_PROPS = [
|
|
11
|
+
'name',
|
|
12
|
+
'text',
|
|
13
|
+
...TEXT_STYLE_FIELDS,
|
|
14
|
+
'textDirection',
|
|
15
|
+
'textAutoResize',
|
|
16
|
+
'textTruncation',
|
|
17
|
+
'maxLines',
|
|
18
|
+
'leadingTrim',
|
|
19
|
+
'listSpacing',
|
|
20
|
+
'hangingList',
|
|
21
|
+
// Styled ranges belong to the characters: an instance that overrides its text keeps them.
|
|
22
|
+
'styleRuns',
|
|
23
|
+
'textParagraphs'
|
|
24
|
+
] as const
|
|
25
|
+
|
|
26
|
+
/** Fields that belong to another one: overriding the owner keeps them too. */
|
|
27
|
+
export const INSTANCE_SYNC_FIELD_OWNERS: Readonly<Partial<Record<string, string>>> = {
|
|
28
|
+
fillStyleId: 'fills',
|
|
29
|
+
styleRuns: 'text',
|
|
30
|
+
textParagraphs: 'text'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Where a component's layer sits and how it is shaped, which Figma refuses to override in an
|
|
35
|
+
* instance ("This property cannot be overridden in an instance"), so its copies always follow.
|
|
36
|
+
* A layer in an auto layout flow takes its position from the layout instead.
|
|
37
|
+
*/
|
|
38
|
+
export const INSTANCE_FOLLOWED_FIELDS = [
|
|
39
|
+
...TRANSFORM_FIELDS,
|
|
40
|
+
'horizontalConstraint',
|
|
41
|
+
'verticalConstraint',
|
|
42
|
+
'layoutPositioning',
|
|
43
|
+
'counterAxisAlignContent',
|
|
44
|
+
'isMask',
|
|
45
|
+
'maskType',
|
|
46
|
+
'arcData',
|
|
47
|
+
'pointCount',
|
|
48
|
+
'starInnerRadius',
|
|
49
|
+
'shapeWithTextType',
|
|
50
|
+
'shapeUserHeight',
|
|
51
|
+
'shapeTruncates'
|
|
52
|
+
] as const
|
|
53
|
+
|
|
54
|
+
/** Fields a component's layer gives its copies unless an instance overrides them. */
|
|
55
|
+
export const INSTANCE_SYNC_PROPS: (keyof SceneNode)[] = difference(
|
|
56
|
+
[
|
|
57
|
+
...SIZE_FIELDS,
|
|
58
|
+
...SIZE_CONSTRAINT_FIELDS,
|
|
59
|
+
...PAINT_FIELDS,
|
|
60
|
+
...STROKE_FIELDS,
|
|
61
|
+
...CORNER_FIELDS,
|
|
62
|
+
...AUTO_LAYOUT_FIELDS,
|
|
63
|
+
'itemReverseZIndex',
|
|
64
|
+
'gridPosition',
|
|
65
|
+
'clipsContent',
|
|
66
|
+
'layoutGrids',
|
|
67
|
+
'boundVariables',
|
|
68
|
+
'variableModes',
|
|
69
|
+
// Applied shared styles follow the component unless an instance overrides them.
|
|
70
|
+
...STYLE_LINK_FIELDS
|
|
71
|
+
],
|
|
72
|
+
INSTANCE_FOLLOWED_FIELDS
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
/** How a layer inside an instance sits in its parent and whether it is locked, which its overrides may change. */
|
|
76
|
+
const INSTANCE_SYNC_CHILD_PROPS = ['layoutGrow', 'layoutAlignSelf', 'locked'] as const
|
|
77
|
+
|
|
78
|
+
/** Fields an edit to a layer inside an instance records as that instance's override. */
|
|
79
|
+
export const INSTANCE_OVERRIDE_FIELDS = [
|
|
80
|
+
...INSTANCE_SYNC_PROPS,
|
|
81
|
+
...INSTANCE_SYNC_TEXT_PROPS,
|
|
82
|
+
...INSTANCE_SYNC_CHILD_PROPS,
|
|
83
|
+
'visible'
|
|
84
|
+
] as const
|
|
85
|
+
|
|
86
|
+
/** Fields a component's layer gives the copies of it in every instance. */
|
|
87
|
+
export const INSTANCE_SYNC_FIELDS = [
|
|
88
|
+
...INSTANCE_OVERRIDE_FIELDS,
|
|
89
|
+
...INSTANCE_FOLLOWED_FIELDS
|
|
90
|
+
] as const
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import type { NodeCloneMode } from '../copy'
|
|
2
|
+
import type { SceneGraph } from '../graph'
|
|
3
|
+
import { slotScope } from '../slots/content'
|
|
4
|
+
import { detachOwnedSlotContent, restoreOwnedSlotContent } from '../slots/frames'
|
|
5
|
+
import type { SceneNode } from '../types'
|
|
6
|
+
import { keepOwnContentSize } from './content-size'
|
|
7
|
+
import { createInstanceSyncContext, groupCopyRemovals, removeLeftoverCopies } from './copies'
|
|
8
|
+
import { canCreateInstance, createsComponentCycle } from './cycles'
|
|
9
|
+
import { INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_PROPS } from './fields'
|
|
10
|
+
import { differingVariableModeCollections } from './modes'
|
|
11
|
+
import {
|
|
12
|
+
copiedComponentLayerId,
|
|
13
|
+
createInstanceOverrideState,
|
|
14
|
+
getInstanceOverride,
|
|
15
|
+
hasInstanceOverride as hasNodeInstanceOverride,
|
|
16
|
+
REPLACED_LAYER_OVERRIDE,
|
|
17
|
+
setInstanceOverride,
|
|
18
|
+
variableModeOverrideField
|
|
19
|
+
} from './overrides'
|
|
20
|
+
import { owningInstance, replacedLayerIn } from './replacements'
|
|
21
|
+
import {
|
|
22
|
+
bindingProtection,
|
|
23
|
+
cloneChildrenWithMapping,
|
|
24
|
+
copyProp,
|
|
25
|
+
enclosingInstanceOverrideFields,
|
|
26
|
+
isProtectedSyncField,
|
|
27
|
+
sourceInTargetCoordinates,
|
|
28
|
+
syncBindingFields,
|
|
29
|
+
syncChildren,
|
|
30
|
+
syncVariableModeFields,
|
|
31
|
+
updateSyncedProps
|
|
32
|
+
} from './sync'
|
|
33
|
+
|
|
34
|
+
export { canCreateInstance, createsComponentCycle, cycleSafeParent } from './cycles'
|
|
35
|
+
export { instanceMainComponent } from './main-component'
|
|
36
|
+
export {
|
|
37
|
+
isInShownReplacedLayer,
|
|
38
|
+
isReplacedLayer,
|
|
39
|
+
owningInstance,
|
|
40
|
+
replacedComponentLayerId,
|
|
41
|
+
showsReplacedLayer
|
|
42
|
+
} from './replacements'
|
|
43
|
+
export {
|
|
44
|
+
INSTANCE_FOLLOWED_FIELDS,
|
|
45
|
+
INSTANCE_OVERRIDE_FIELDS,
|
|
46
|
+
INSTANCE_SYNC_FIELDS,
|
|
47
|
+
INSTANCE_SYNC_PROPS,
|
|
48
|
+
INSTANCE_SYNC_TEXT_PROPS
|
|
49
|
+
} from './fields'
|
|
50
|
+
|
|
51
|
+
export function copyInstanceComponentProps(component: SceneNode): Partial<SceneNode> {
|
|
52
|
+
const props: Partial<SceneNode> = {}
|
|
53
|
+
for (const key of INSTANCE_SYNC_PROPS) copyProp(props, component, key)
|
|
54
|
+
return props
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createInstance(
|
|
58
|
+
graph: SceneGraph,
|
|
59
|
+
componentId: string,
|
|
60
|
+
parentId: string,
|
|
61
|
+
overrides: Partial<SceneNode> = {}
|
|
62
|
+
): SceneNode | null {
|
|
63
|
+
const component = graph.nodes.get(componentId)
|
|
64
|
+
if (component?.type !== 'COMPONENT' || !canCreateInstance(graph, componentId, parentId))
|
|
65
|
+
return null
|
|
66
|
+
|
|
67
|
+
const props: Partial<SceneNode> = {
|
|
68
|
+
...copyInstanceComponentProps(component),
|
|
69
|
+
name: component.name
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The component checked above is the one the instance shows, whatever `overrides` holds.
|
|
73
|
+
const instance = graph.createNode('INSTANCE', parentId, { ...props, ...overrides, componentId })
|
|
74
|
+
|
|
75
|
+
cloneChildrenWithMapping(graph, component.id, instance.id)
|
|
76
|
+
|
|
77
|
+
return instance
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function populateInstanceChildren(
|
|
81
|
+
graph: SceneGraph,
|
|
82
|
+
instanceId: string,
|
|
83
|
+
componentId: string,
|
|
84
|
+
mode: NodeCloneMode = 'deep'
|
|
85
|
+
): void {
|
|
86
|
+
const instance = graph.nodes.get(instanceId)
|
|
87
|
+
const component = graph.nodes.get(componentId)
|
|
88
|
+
if (!instance || !component || instance.type !== 'INSTANCE') return
|
|
89
|
+
cloneChildrenWithMapping(graph, componentId, instanceId, mode)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A nested instance's link to the enclosing component's record is its `componentId` when it
|
|
94
|
+
* was populated by cloning. A swap replaces that field, so keep the correspondence as the
|
|
95
|
+
* owner's `sourceComponentId` override and record the swap itself; materialized documents
|
|
96
|
+
* already carry the correspondence and only gain the swap.
|
|
97
|
+
*/
|
|
98
|
+
function recordNestedSwap(graph: SceneGraph, instance: SceneNode, componentId: string): void {
|
|
99
|
+
const owner = instance.parentId ? findInstanceAncestor(graph, instance.parentId) : undefined
|
|
100
|
+
if (!owner) return
|
|
101
|
+
const existing = getInstanceOverride(
|
|
102
|
+
owner.instanceOverrides,
|
|
103
|
+
owner.id,
|
|
104
|
+
instance.id,
|
|
105
|
+
'sourceComponentId'
|
|
106
|
+
)
|
|
107
|
+
if (typeof existing !== 'string' && instance.componentId)
|
|
108
|
+
setInstanceOverride(
|
|
109
|
+
owner.instanceOverrides,
|
|
110
|
+
owner.id,
|
|
111
|
+
instance.id,
|
|
112
|
+
'sourceComponentId',
|
|
113
|
+
instance.componentId
|
|
114
|
+
)
|
|
115
|
+
setInstanceOverride(owner.instanceOverrides, owner.id, instance.id, 'componentId', componentId)
|
|
116
|
+
graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface SwapInstanceOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Keep the instance's name even when it is its old component's. A swap otherwise renames such
|
|
122
|
+
* an instance after the new component, as Figma does; a view that only shows another variant,
|
|
123
|
+
* such as preview, keeps names so layer paths stay the same.
|
|
124
|
+
*/
|
|
125
|
+
keepName?: boolean
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function swapInstanceComponent(
|
|
129
|
+
graph: SceneGraph,
|
|
130
|
+
instanceId: string,
|
|
131
|
+
componentId: string,
|
|
132
|
+
{ keepName = false }: SwapInstanceOptions = {}
|
|
133
|
+
): void {
|
|
134
|
+
const instance = graph.nodes.get(instanceId)
|
|
135
|
+
const component = graph.nodes.get(componentId)
|
|
136
|
+
if (!instance || component?.type !== 'COMPONENT' || instance.type !== 'INSTANCE') return
|
|
137
|
+
if (instance.parentId && !canCreateInstance(graph, componentId, instance.parentId)) return
|
|
138
|
+
|
|
139
|
+
const previousComponent = instance.componentId ? graph.nodes.get(instance.componentId) : undefined
|
|
140
|
+
recordNestedSwap(graph, instance, componentId)
|
|
141
|
+
const updates: Partial<SceneNode> = { componentId }
|
|
142
|
+
const source = sourceInTargetCoordinates(component, instance.componentScale)
|
|
143
|
+
const overridden = (field: string) =>
|
|
144
|
+
hasNodeInstanceOverride(instance.instanceOverrides, instance.id, instance.id, field)
|
|
145
|
+
for (const key of INSTANCE_SYNC_PROPS) {
|
|
146
|
+
if (key === 'variableModes' || overridden(key)) continue
|
|
147
|
+
copyProp(updates, source, key)
|
|
148
|
+
}
|
|
149
|
+
syncVariableModeFields(instance, source, updates, overridden)
|
|
150
|
+
|
|
151
|
+
if (!keepName && (!previousComponent || instance.name === previousComponent.name))
|
|
152
|
+
updates.name = component.name
|
|
153
|
+
|
|
154
|
+
const childIds = Array.from(instance.childIds)
|
|
155
|
+
const slotContent = detachOwnedSlotContent(graph, instance)
|
|
156
|
+
for (const childId of childIds) graph.deleteNode(childId)
|
|
157
|
+
graph.updateNode(instanceId, updates)
|
|
158
|
+
cloneChildrenWithMapping(graph, componentId, instanceId)
|
|
159
|
+
restoreOwnedSlotContent(graph, instance, slotContent)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const syncingComponentsByGraph = new WeakMap<SceneGraph, Set<string>>()
|
|
163
|
+
|
|
164
|
+
export function syncInstances(graph: SceneGraph, componentId: string): void {
|
|
165
|
+
syncInstancesOf(graph, componentId, getInstances(graph, componentId))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Syncs each component's instances, in order, as one edit: the copies they remove stay
|
|
170
|
+
* restorable together for as long as undo keeps that edit.
|
|
171
|
+
*/
|
|
172
|
+
export function syncInstancesTogether(graph: SceneGraph, componentIds: Iterable<string>): void {
|
|
173
|
+
groupCopyRemovals(graph, () => {
|
|
174
|
+
for (const id of componentIds) syncInstances(graph, id)
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Syncs one instance from its component, as `syncInstances` does for every instance. */
|
|
179
|
+
export function syncInstance(graph: SceneGraph, instanceId: string): void {
|
|
180
|
+
const instance = graph.nodes.get(instanceId)
|
|
181
|
+
if (instance?.type !== 'INSTANCE' || !instance.componentId) return
|
|
182
|
+
syncInstancesOf(graph, instance.componentId, [instance])
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function syncInstancesOf(
|
|
186
|
+
graph: SceneGraph,
|
|
187
|
+
componentId: string,
|
|
188
|
+
instances: Iterable<SceneNode>
|
|
189
|
+
): void {
|
|
190
|
+
const component = graph.nodes.get(componentId)
|
|
191
|
+
if (component?.type !== 'COMPONENT') return
|
|
192
|
+
let syncing = syncingComponentsByGraph.get(graph)
|
|
193
|
+
if (!syncing) {
|
|
194
|
+
syncing = new Set()
|
|
195
|
+
syncingComponentsByGraph.set(graph, syncing)
|
|
196
|
+
}
|
|
197
|
+
if (syncing.has(componentId)) return
|
|
198
|
+
syncing.add(componentId)
|
|
199
|
+
try {
|
|
200
|
+
groupCopyRemovals(graph, (removals) => {
|
|
201
|
+
for (const instance of instances) {
|
|
202
|
+
const enclosing = enclosingInstanceOverrideFields(graph, instance)
|
|
203
|
+
enclosing.push(new Set(instance.instanceOverrides.self.keys()))
|
|
204
|
+
const protectedField = bindingProtection(enclosing)
|
|
205
|
+
const source = sourceInTargetCoordinates(component, instance.componentScale)
|
|
206
|
+
const updates: Partial<SceneNode> = {}
|
|
207
|
+
syncBindingFields(instance, source, updates, protectedField)
|
|
208
|
+
syncVariableModeFields(instance, source, updates, protectedField)
|
|
209
|
+
for (const key of INSTANCE_SYNC_PROPS) {
|
|
210
|
+
if (key === 'boundVariables' || key === 'variableModes') continue
|
|
211
|
+
if (isProtectedSyncField(instance, key, protectedField)) continue
|
|
212
|
+
copyProp(updates, source, key)
|
|
213
|
+
}
|
|
214
|
+
// An instance that hugs its layers sizes to what it shows, not to the component.
|
|
215
|
+
keepOwnContentSize(graph, updates, instance, source)
|
|
216
|
+
updateSyncedProps(graph, instance, updates)
|
|
217
|
+
const context = createInstanceSyncContext(instance.id, instance.instanceOverrides)
|
|
218
|
+
syncChildren(graph, component.id, instance.id, instance.instanceOverrides, context)
|
|
219
|
+
removeLeftoverCopies(graph, context, removals)
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
} finally {
|
|
223
|
+
syncing.delete(componentId)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Renames the layers that the copied instances among `copies` record overrides for to their
|
|
229
|
+
* copies, as a copied instance records its own layers' overrides. The values keep naming what
|
|
230
|
+
* they name, since a copy shows the same components as its source.
|
|
231
|
+
*/
|
|
232
|
+
export function retargetCopiedOverrides(
|
|
233
|
+
graph: SceneGraph,
|
|
234
|
+
copies: ReadonlyMap<string, string>
|
|
235
|
+
): void {
|
|
236
|
+
for (const id of copies.values()) {
|
|
237
|
+
const node = graph.nodes.get(id)
|
|
238
|
+
if (node?.type !== 'INSTANCE' || node.instanceOverrides.descendants.size === 0) continue
|
|
239
|
+
const descendants = new Map(
|
|
240
|
+
[...node.instanceOverrides.descendants].map(([target, fields]) => [
|
|
241
|
+
copies.get(target) ?? target,
|
|
242
|
+
fields
|
|
243
|
+
])
|
|
244
|
+
)
|
|
245
|
+
graph.updateNode(id, { instanceOverrides: { ...node.instanceOverrides, descendants } })
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function detachInstance(graph: SceneGraph, instanceId: string): void {
|
|
250
|
+
const node = graph.nodes.get(instanceId)
|
|
251
|
+
if (node?.type !== 'INSTANCE') return
|
|
252
|
+
// Through `updateNode`, so the instance index, change observers, and undo recorders see it.
|
|
253
|
+
graph.updateNode(instanceId, {
|
|
254
|
+
type: 'FRAME',
|
|
255
|
+
componentId: null,
|
|
256
|
+
instanceOverrides: createInstanceOverrideState()
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function getMainComponent(graph: SceneGraph, instanceId: string): SceneNode | undefined {
|
|
261
|
+
const node = graph.nodes.get(instanceId)
|
|
262
|
+
if (!node?.componentId) return undefined
|
|
263
|
+
return graph.nodes.get(node.componentId)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function getInstances(graph: SceneGraph, componentId: string): SceneNode[] {
|
|
267
|
+
const ids = graph.instanceIndex.get(componentId)
|
|
268
|
+
if (!ids) return []
|
|
269
|
+
const instances: SceneNode[] = []
|
|
270
|
+
for (const id of ids) {
|
|
271
|
+
const node = graph.nodes.get(id)
|
|
272
|
+
if (node) instances.push(node)
|
|
273
|
+
}
|
|
274
|
+
return instances
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */
|
|
278
|
+
export function findInstanceAncestor(graph: SceneGraph, nodeId: string): SceneNode | undefined {
|
|
279
|
+
let current = graph.nodes.get(nodeId)
|
|
280
|
+
while (current) {
|
|
281
|
+
if (current.type === 'INSTANCE') return current
|
|
282
|
+
current = current.parentId ? graph.nodes.get(current.parentId) : undefined
|
|
283
|
+
}
|
|
284
|
+
return undefined
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* True when a node field is protected from instance synchronization.
|
|
289
|
+
*/
|
|
290
|
+
export function hasInstanceOverride(graph: SceneGraph, nodeId: string, field: string): boolean {
|
|
291
|
+
const instance = findInstanceAncestor(graph, nodeId)
|
|
292
|
+
if (!instance) return false
|
|
293
|
+
return hasNodeInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The layer of the component an instance layer copies, which its overrides are measured
|
|
298
|
+
* against: the instance's component for the instance itself.
|
|
299
|
+
*/
|
|
300
|
+
function copiedLayer(graph: SceneGraph, instance: SceneNode, node: SceneNode) {
|
|
301
|
+
const id =
|
|
302
|
+
node.id === instance.id
|
|
303
|
+
? instance.componentId
|
|
304
|
+
: copiedComponentLayerId(instance.instanceOverrides, instance.id, node)
|
|
305
|
+
return id ? graph.nodes.get(id) : undefined
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The override fields an edit of these fields records. A mode edit claims only the collections
|
|
310
|
+
* whose mode now differs from the component layer's, so the component's other modes still
|
|
311
|
+
* reach the layer; with no layer to compare, it claims every mode.
|
|
312
|
+
*/
|
|
313
|
+
function overrideFieldsOf(
|
|
314
|
+
graph: SceneGraph,
|
|
315
|
+
instance: SceneNode,
|
|
316
|
+
nodeId: string,
|
|
317
|
+
fields: string[]
|
|
318
|
+
): string[] {
|
|
319
|
+
if (!fields.includes('variableModes')) return fields
|
|
320
|
+
const node = graph.nodes.get(nodeId)
|
|
321
|
+
const source = node && copiedLayer(graph, instance, node)
|
|
322
|
+
if (!node || !source) return fields
|
|
323
|
+
return [
|
|
324
|
+
...fields.filter((field) => field !== 'variableModes'),
|
|
325
|
+
...differingVariableModeCollections(node, source).map(variableModeOverrideField)
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function recordInstanceOverride(
|
|
330
|
+
graph: SceneGraph,
|
|
331
|
+
nodeId: string,
|
|
332
|
+
fields: Iterable<string>
|
|
333
|
+
): void {
|
|
334
|
+
const instance = findInstanceAncestor(graph, nodeId)
|
|
335
|
+
if (!instance) return
|
|
336
|
+
|
|
337
|
+
const relevant = overrideFieldsOf(
|
|
338
|
+
graph,
|
|
339
|
+
instance,
|
|
340
|
+
nodeId,
|
|
341
|
+
[...fields].filter((field) => (INSTANCE_OVERRIDE_FIELDS as readonly string[]).includes(field))
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
if (relevant.length === 0) return
|
|
345
|
+
|
|
346
|
+
for (const field of relevant)
|
|
347
|
+
setInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)
|
|
348
|
+
graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Every layer at or below `rootId`. */
|
|
352
|
+
function subtreeIds(graph: SceneGraph, rootId: string): string[] {
|
|
353
|
+
const ids: string[] = []
|
|
354
|
+
const visit = (id: string) => {
|
|
355
|
+
ids.push(id)
|
|
356
|
+
for (const childId of graph.nodes.get(id)?.childIds ?? []) visit(childId)
|
|
357
|
+
}
|
|
358
|
+
visit(rootId)
|
|
359
|
+
return ids
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Forget what the instances above `nodeId` recorded for it and the layers inside it. */
|
|
363
|
+
function forgetOverridesOf(graph: SceneGraph, nodeId: string): void {
|
|
364
|
+
const ids = subtreeIds(graph, nodeId)
|
|
365
|
+
const parentId = graph.nodes.get(nodeId)?.parentId
|
|
366
|
+
if (!parentId) return
|
|
367
|
+
graph.closest(parentId, (ancestor) => {
|
|
368
|
+
if (ancestor.type !== 'INSTANCE') return false
|
|
369
|
+
const { descendants } = ancestor.instanceOverrides
|
|
370
|
+
if (ids.some((id) => descendants.delete(id)))
|
|
371
|
+
graph.updateNode(ancestor.id, { instanceOverrides: ancestor.instanceOverrides })
|
|
372
|
+
return false
|
|
373
|
+
})
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Whether a layer can be replaced in its instance: it sits in the part the component owns. */
|
|
377
|
+
export function canReplaceInstanceLayer(graph: SceneGraph, nodeId: string): boolean {
|
|
378
|
+
const node = graph.nodes.get(nodeId)
|
|
379
|
+
const owner = node && owningInstance(graph, node)
|
|
380
|
+
if (!node?.parentId || !owner) return false
|
|
381
|
+
// Slot content is the instance's own already, and a generated frame's layers are fixed.
|
|
382
|
+
const scope = slotScope(graph, node.parentId)
|
|
383
|
+
if (scope.kind !== 'locked' || scope.owner.type !== 'INSTANCE') return false
|
|
384
|
+
return (
|
|
385
|
+
replacedLayerIn(owner, node.id) !== undefined ||
|
|
386
|
+
copiedComponentLayerId(owner.instanceOverrides, owner.id, node) !== undefined
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Put `replacementId` in place of `targetId`, a layer an instance copies from its component, as
|
|
392
|
+
* an override of the nearest instance above it, as pen.dev replaces a layer inside an instance.
|
|
393
|
+
* The replacement takes the target's place among its siblings and its position, the target
|
|
394
|
+
* goes, and syncs keep the replacement in place of the component layer the target copied. A
|
|
395
|
+
* replaced layer can be replaced again. Returns false and changes nothing when the target is no
|
|
396
|
+
* such layer, or the replacement cannot go there.
|
|
397
|
+
*/
|
|
398
|
+
export function replaceInstanceLayer(
|
|
399
|
+
graph: SceneGraph,
|
|
400
|
+
targetId: string,
|
|
401
|
+
replacementId: string
|
|
402
|
+
): boolean {
|
|
403
|
+
const target = graph.nodes.get(targetId)
|
|
404
|
+
const replacement = graph.nodes.get(replacementId)
|
|
405
|
+
const parentId = target?.parentId
|
|
406
|
+
if (!target || !replacement || !parentId || targetId === replacementId) return false
|
|
407
|
+
const owner = owningInstance(graph, target)
|
|
408
|
+
if (!owner || graph.isDescendant(parentId, replacementId)) return false
|
|
409
|
+
if (createsComponentCycle(graph, replacementId, parentId)) return false
|
|
410
|
+
const layerId =
|
|
411
|
+
replacedLayerIn(owner, target.id) ??
|
|
412
|
+
copiedComponentLayerId(owner.instanceOverrides, owner.id, target)
|
|
413
|
+
if (!layerId) return false
|
|
414
|
+
|
|
415
|
+
// The replacement copies no layer of the component, so its own layers lose such links; an
|
|
416
|
+
// instance among them keeps its own component and layers.
|
|
417
|
+
const unlink = (id: string) => {
|
|
418
|
+
const node = graph.nodes.get(id)
|
|
419
|
+
if (!node) return
|
|
420
|
+
if (node.type !== 'INSTANCE' && node.componentId) graph.updateNode(id, { componentId: null })
|
|
421
|
+
if (node.type !== 'INSTANCE') node.childIds.forEach(unlink)
|
|
422
|
+
}
|
|
423
|
+
unlink(replacementId)
|
|
424
|
+
|
|
425
|
+
const index = graph.nodes.get(parentId)?.childIds.indexOf(target.id) ?? -1
|
|
426
|
+
forgetOverridesOf(graph, target.id)
|
|
427
|
+
forgetOverridesOf(graph, replacementId)
|
|
428
|
+
graph.insertChildAt(replacementId, parentId, index < 0 ? Number.MAX_SAFE_INTEGER : index)
|
|
429
|
+
graph.updateNode(replacementId, {
|
|
430
|
+
x: target.x,
|
|
431
|
+
y: target.y,
|
|
432
|
+
layoutPositioning: target.layoutPositioning,
|
|
433
|
+
horizontalConstraint: target.horizontalConstraint,
|
|
434
|
+
verticalConstraint: target.verticalConstraint
|
|
435
|
+
})
|
|
436
|
+
graph.deleteNode(target.id)
|
|
437
|
+
setInstanceOverride(
|
|
438
|
+
owner.instanceOverrides,
|
|
439
|
+
owner.id,
|
|
440
|
+
replacementId,
|
|
441
|
+
REPLACED_LAYER_OVERRIDE,
|
|
442
|
+
layerId
|
|
443
|
+
)
|
|
444
|
+
graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })
|
|
445
|
+
return true
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Take a replaced layer out and bring back the component layer it stood in for, synced from the
|
|
450
|
+
* outermost instance as a reset syncs. Returns false when the layer is not a replaced one.
|
|
451
|
+
*/
|
|
452
|
+
export function restoreReplacedLayer(graph: SceneGraph, nodeId: string): boolean {
|
|
453
|
+
const node = graph.nodes.get(nodeId)
|
|
454
|
+
const owner = node && owningInstance(graph, node)
|
|
455
|
+
if (!node || !owner || replacedLayerIn(owner, nodeId) === undefined) return false
|
|
456
|
+
let outermost = owner
|
|
457
|
+
for (let above = owningInstance(graph, owner); above; above = owningInstance(graph, above))
|
|
458
|
+
outermost = above
|
|
459
|
+
forgetOverridesOf(graph, nodeId)
|
|
460
|
+
graph.deleteNode(nodeId)
|
|
461
|
+
syncInstance(graph, outermost.id)
|
|
462
|
+
// An enclosing sync stops at a swapped instance, which brings its layers back itself.
|
|
463
|
+
const above = owningInstance(graph, owner)
|
|
464
|
+
if (above && getInstanceOverride(above.instanceOverrides, above.id, owner.id, 'componentId'))
|
|
465
|
+
syncInstance(graph, owner.id)
|
|
466
|
+
return true
|
|
467
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { SceneGraph } from '../graph'
|
|
2
|
+
import type { SceneNode } from '../types'
|
|
3
|
+
import { paintBindingTarget } from '../variables/fields'
|
|
4
|
+
import { overriddenBindingField } from './overrides'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The main component an instance shows. An instance nested in another instance points at the
|
|
8
|
+
* instance it was cloned from, so follow those links to the component.
|
|
9
|
+
*/
|
|
10
|
+
export function instanceMainComponent(
|
|
11
|
+
graph: SceneGraph,
|
|
12
|
+
instance: SceneNode
|
|
13
|
+
): SceneNode | undefined {
|
|
14
|
+
const seen = new Set<string>()
|
|
15
|
+
let current = instance.componentId ? graph.getNode(instance.componentId) : undefined
|
|
16
|
+
while (current?.type === 'INSTANCE' && current.componentId && !seen.has(current.id)) {
|
|
17
|
+
seen.add(current.id)
|
|
18
|
+
current = graph.getNode(current.componentId)
|
|
19
|
+
}
|
|
20
|
+
return current?.type === 'COMPONENT' ? current : undefined
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Root paint claims also protect a nested copy when its enclosing component syncs it. */
|
|
24
|
+
export function ownsSelfFillField(target: SceneNode, field: string): boolean {
|
|
25
|
+
const own = target.instanceOverrides.self
|
|
26
|
+
if (field === 'fills' || field === 'fillStyleId') return own.has(field) || own.has('fills')
|
|
27
|
+
// A paint the layer set itself owns its bindings too, bound or not.
|
|
28
|
+
const binding = overriddenBindingField(field)
|
|
29
|
+
return (
|
|
30
|
+
binding !== null &&
|
|
31
|
+
paintBindingTarget(binding)?.list === 'fills' &&
|
|
32
|
+
(own.has(field) || own.has('boundVariables') || own.has('fills'))
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A swapped nested root takes its fill from what it shows, not its template's old component. */
|
|
37
|
+
export function sourceWithEffectiveFill(
|
|
38
|
+
graph: SceneGraph,
|
|
39
|
+
source: SceneNode,
|
|
40
|
+
target: SceneNode
|
|
41
|
+
): SceneNode {
|
|
42
|
+
if (source.type !== 'INSTANCE' || target.type !== 'INSTANCE') return source
|
|
43
|
+
const original = instanceMainComponent(graph, source)
|
|
44
|
+
const effective = instanceMainComponent(graph, target)
|
|
45
|
+
if (!original || !effective || original.id === effective.id) return source
|
|
46
|
+
const fillBindings = <T>(from: Record<string, T>, to: Record<string, T>): Record<string, T> =>
|
|
47
|
+
Object.fromEntries([
|
|
48
|
+
...Object.entries(from).filter(([key]) => !key.startsWith('fills/')),
|
|
49
|
+
...Object.entries(to).filter(([key]) => key.startsWith('fills/'))
|
|
50
|
+
])
|
|
51
|
+
return {
|
|
52
|
+
...source,
|
|
53
|
+
fills: effective.fills,
|
|
54
|
+
fillStyleId: effective.fillStyleId,
|
|
55
|
+
boundVariables: fillBindings(source.boundVariables, effective.boundVariables),
|
|
56
|
+
variableBindingScales: fillBindings(
|
|
57
|
+
source.variableBindingScales,
|
|
58
|
+
effective.variableBindingScales
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// How a copy's variable modes follow its component layer one collection at a time.
|
|
2
|
+
import { uniq } from 'es-toolkit/array'
|
|
3
|
+
|
|
4
|
+
import type { SceneNode, VariableModeMap } from '../types'
|
|
5
|
+
import { variableModeOverrideField } from './overrides'
|
|
6
|
+
|
|
7
|
+
/** Collections whose mode a layer sets otherwise than the layer it copies, a cleared one included. */
|
|
8
|
+
export function differingVariableModeCollections(
|
|
9
|
+
node: Pick<SceneNode, 'variableModes'>,
|
|
10
|
+
source: Pick<SceneNode, 'variableModes'>
|
|
11
|
+
): string[] {
|
|
12
|
+
return uniq([...Object.keys(source.variableModes), ...Object.keys(node.variableModes)]).filter(
|
|
13
|
+
(collectionId) => node.variableModes[collectionId] !== source.variableModes[collectionId]
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The modes a copy shows after a sync: its component layer's, but in each collection the copy
|
|
19
|
+
* overrides, the mode the copy set, or none where it cleared one. A copy that overrides its
|
|
20
|
+
* whole map keeps it; null then, as nothing changes.
|
|
21
|
+
*/
|
|
22
|
+
export function syncedVariableModes(
|
|
23
|
+
target: Pick<SceneNode, 'variableModes'>,
|
|
24
|
+
source: Pick<SceneNode, 'variableModes'>,
|
|
25
|
+
overridden: (field: string) => boolean
|
|
26
|
+
): VariableModeMap | null {
|
|
27
|
+
if (overridden('variableModes')) return null
|
|
28
|
+
const modes: VariableModeMap = { ...source.variableModes }
|
|
29
|
+
for (const collectionId of uniq([
|
|
30
|
+
...Object.keys(source.variableModes),
|
|
31
|
+
...Object.keys(target.variableModes)
|
|
32
|
+
])) {
|
|
33
|
+
if (!overridden(variableModeOverrideField(collectionId))) continue
|
|
34
|
+
if (Object.hasOwn(target.variableModes, collectionId)) {
|
|
35
|
+
modes[collectionId] = target.variableModes[collectionId]
|
|
36
|
+
} else Reflect.deleteProperty(modes, collectionId)
|
|
37
|
+
}
|
|
38
|
+
return modes
|
|
39
|
+
}
|