@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-caps.d.ts +35 -14
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +286 -55
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -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 +62 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
- 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 +43 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +48 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +156 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +228 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +86 -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/{chunks/behaviours → behaviours}/spec.js +6 -29
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +26 -0
- package/dist/bindings.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.map +1 -0
- package/dist/checkpoint.d.ts +42 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +249 -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 +17 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/{chunks/color → color}/contrast.js +2 -24
- 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/{chunks/comments → comments}/document.js +2 -1
- 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/{chunks/comments → comments}/merge.js +1 -1
- 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/{chunks/comments/list.js → comments/threads.js} +3 -53
- 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 +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/properties.d.ts +32 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +180 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +33 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +58 -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 +47 -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 +156 -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 +208 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +11 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +94 -2
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +268 -1
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +49 -2
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +264 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/{chunks/css → css}/grid.js +2 -33
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +7 -0
- package/dist/css/index.js +7 -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/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +25 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +47 -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.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 +64 -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 +270 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +439 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +70 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +95 -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 +44 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +27 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +43 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +135 -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 +233 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +89 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +306 -2
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +13 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +178 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +625 -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/{chunks/group-bounds.js → group-bounds.js} +56 -14
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +21 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +5 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +48 -2
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +75 -57
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/{chunks/icons → icons}/glyph.js +2 -40
- 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 -2
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +67 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -23
- 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 +161 -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 +90 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +38 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +180 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +13 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +50 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +51 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +158 -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/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/swap.js +288 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +327 -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.js → layout/index.js} +4 -3
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +59 -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 -2
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +119 -1
- 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/node-defaults.d.ts +22 -2
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +254 -2
- package/dist/node-defaults.js.map +1 -0
- package/dist/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.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 +77 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +56 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +9 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +39 -2
- package/dist/parse-path.js.map +1 -1
- 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 +73 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +143 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +168 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +3 -0
- package/dist/plugin-data/index.js +3 -0
- package/dist/polygon.d.ts +4 -2
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +17 -2
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +12 -2
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +62 -1
- package/dist/preview.js.map +1 -0
- package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
- 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.js +24 -1
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +6 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +287 -2
- 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 +148 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +7 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +47 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.js +4 -0
- package/dist/shaders/model.d.ts +41 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +71 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +41 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +36 -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 +51 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +186 -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 +77 -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 +105 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +40 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +118 -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 +21 -2
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +109 -1
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.js +10 -1
- 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 → text/direction.d.ts} +2 -2
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/{text-direction.js → text/direction.js} +1 -1
- 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 +24 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +49 -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 → text/picture.d.ts} +3 -4
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +38 -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/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.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 +8 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +78 -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 +195 -2007
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +89 -2
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -2
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +235 -1
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +83 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +314 -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 +43 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +104 -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 +238 -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 +16 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +49 -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/vector-network.d.ts +65 -2
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +375 -2
- package/dist/vector-network.js.map +1 -0
- package/package.json +303 -137
- package/src/arrow-caps.ts +279 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +5 -3
- package/src/behaviours/model.ts +25 -22
- package/src/behaviours/schema.ts +64 -13
- package/src/behaviours/spec.ts +11 -50
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +252 -5
- package/src/clipping.ts +112 -0
- package/src/color/index.ts +1 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +1 -1
- package/src/comments/index.ts +5 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +1 -1
- package/src/components/exposure.ts +1 -1
- package/src/components/index.ts +8 -0
- package/src/components/properties.ts +94 -4
- package/src/components/variants.ts +52 -31
- 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 +49 -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 +141 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +203 -0
- package/src/coordinate.ts +10 -3
- package/src/copy.ts +71 -31
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +2 -0
- package/src/css/text.ts +84 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +30 -1
- package/src/fields/appearance.ts +35 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +32 -1
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +473 -0
- package/src/figjam/text.ts +83 -0
- package/src/font-style.ts +58 -14
- package/src/generated/index.ts +76 -0
- package/src/generated/kind.ts +24 -0
- package/src/generated/shape-with-text.ts +157 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +102 -312
- package/src/gradient.ts +14 -0
- package/src/graph.ts +849 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +6 -1
- package/src/hit-test.ts +118 -74
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +9 -0
- package/src/icons/schema.ts +19 -3
- package/src/ids.ts +34 -0
- package/src/images.ts +71 -8
- package/src/index.ts +2 -976
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +23 -2
- package/src/instances/copies.ts +7 -10
- package/src/instances/cycles.ts +1 -1
- package/src/instances/fields.ts +47 -92
- package/src/{instances.ts → instances/index.ts} +69 -44
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +55 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/swap.ts +451 -0
- package/src/instances/sync.ts +166 -177
- package/src/instances/vector-geometry.ts +3 -3
- package/src/layout/aspect-ratio.ts +1 -1
- package/src/layout/sizing.ts +1 -1
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +1 -1
- package/src/mutation-impact.ts +1 -1
- package/src/node-defaults.ts +43 -3
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +67 -0
- package/src/parse-path.ts +49 -4
- package/src/plugin-data/fields.ts +69 -77
- package/src/plugin-data/index.ts +2 -0
- package/src/polygon.ts +17 -0
- package/src/preview.ts +1 -1
- package/src/{primitives.ts → primitives/index.ts} +2 -0
- package/src/primitives/schema.ts +14 -0
- package/src/resize.ts +32 -6
- package/src/scaling/node.ts +10 -6
- package/src/scaling/tree.ts +2 -1
- package/src/shaders/index.ts +3 -0
- package/src/shaders/schema.ts +3 -3
- 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 +169 -17
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +10 -5
- package/src/slots/frames.ts +12 -10
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +1 -1
- package/src/snap.ts +3 -1
- 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/index.ts +3 -0
- package/src/text/lengths.ts +44 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/picture.ts +0 -4
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +1 -1
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/history.ts +1 -1
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +18 -19
- package/src/transfer/plan.ts +1 -1
- package/src/transfer/remove.ts +1 -1
- package/src/transfer/validation.ts +1 -1
- package/src/transfer/variables.ts +7 -6
- package/src/types.ts +246 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +166 -66
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +83 -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.ts → variables/index.ts} +86 -146
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +51 -0
- package/src/variables/token.ts +27 -1
- package/src/variables/value.ts +92 -0
- package/src/vector-network.ts +263 -22
- package/dist/chunks/asset-keys.js.map +0 -1
- package/dist/chunks/behaviours/kinds.js.map +0 -1
- package/dist/chunks/behaviours/layers.js +0 -611
- package/dist/chunks/behaviours/layers.js.map +0 -1
- package/dist/chunks/behaviours/spec.js.map +0 -1
- package/dist/chunks/bindings.js +0 -18
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js +0 -78
- package/dist/chunks/checkpoint.js.map +0 -1
- package/dist/chunks/color/contrast.js.map +0 -1
- package/dist/chunks/color/index.js +0 -1662
- package/dist/chunks/color/index.js.map +0 -1
- package/dist/chunks/comments/document.js.map +0 -1
- package/dist/chunks/comments/list.js.map +0 -1
- package/dist/chunks/comments/merge.js.map +0 -1
- package/dist/chunks/components/exposure.js +0 -2291
- package/dist/chunks/components/exposure.js.map +0 -1
- package/dist/chunks/components/variants.js +0 -32
- package/dist/chunks/components/variants.js.map +0 -1
- package/dist/chunks/coordinate.js +0 -385
- package/dist/chunks/coordinate.js.map +0 -1
- package/dist/chunks/css/grid.js.map +0 -1
- package/dist/chunks/css/index.js +0 -160
- package/dist/chunks/css/index.js.map +0 -1
- package/dist/chunks/events.js.map +0 -1
- package/dist/chunks/fields/geometry.js.map +0 -1
- package/dist/chunks/font-style.js +0 -96
- package/dist/chunks/font-style.js.map +0 -1
- package/dist/chunks/group-bounds.js.map +0 -1
- package/dist/chunks/icons/glyph.js.map +0 -1
- package/dist/chunks/index.js +0 -2430
- package/dist/chunks/index.js.map +0 -1
- package/dist/color.d.ts +0 -78
- package/dist/color.d.ts.map +0 -1
- package/dist/color.js +0 -3
- package/dist/constants2.d.ts +0 -11
- package/dist/constants2.d.ts.map +0 -1
- package/dist/css.d.ts +0 -39
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -3
- package/dist/images2.d.ts +0 -16
- package/dist/images2.d.ts.map +0 -1
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +0 -2
- package/dist/layout.d.ts +0 -2
- package/dist/matrix2.d.ts +0 -16
- package/dist/matrix2.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -2
- package/dist/primitives.js +0 -0
- package/dist/primitives2.d.ts.map +0 -1
- package/dist/text-direction.d.ts.map +0 -1
- package/dist/text-direction.js.map +0 -1
- package/dist/text-picture.d.ts.map +0 -1
- package/dist/text-picture.js +0 -2
- package/dist/text.d.ts +0 -2
- package/dist/text.js +0 -3
- package/dist/types2.d.ts +0 -2
- package/dist/undo2.d.ts +0 -73
- package/dist/undo2.d.ts.map +0 -1
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -2
- /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
- /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
package/dist/graph.js
ADDED
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import { BufferedSceneEmitter } from "./buffered-events.js";
|
|
2
|
+
import { removeStaleBindings } from "./bindings.js";
|
|
3
|
+
import Matrix from "./matrix.js";
|
|
4
|
+
import { CONTAINER_TYPES, createDefaultNode } from "./node-defaults.js";
|
|
5
|
+
import { getAbsolutePosition, getNodeLocalMatrix, getParentWorldMatrix, isTranslationOnly, localTransformFromWorld } from "./coordinate.js";
|
|
6
|
+
import { cloneNodeProps } from "./copy.js";
|
|
7
|
+
import { bindNodeEvents } from "./events.js";
|
|
8
|
+
import { TRANSFORM_FIELDS } from "./fields/geometry.js";
|
|
9
|
+
import { LAYOUT_AFFECTING_KEYS } from "./fields/layout.js";
|
|
10
|
+
import { withGeneratedFrameSize } from "./generated/index.js";
|
|
11
|
+
import { hitTest, hitTestDeep, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, isOpenContainer, isPointInNode } from "./hit-test.js";
|
|
12
|
+
import { generateId } from "./ids.js";
|
|
13
|
+
import { normalizeVectorNetwork } from "./vector-network.js";
|
|
14
|
+
import { createInstance, detachInstance, getInstances, getMainComponent, populateInstanceChildren, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether } from "./instances/index.js";
|
|
15
|
+
import { LayoutWrites } from "./layout/writes.js";
|
|
16
|
+
import { textCacheInvalidationChanges } from "./text/picture.js";
|
|
17
|
+
import { updateNodePreview } from "./preview.js";
|
|
18
|
+
import { markSourceFieldsEdited } from "./source-metadata.js";
|
|
19
|
+
import { remapCopiedReferences } from "./transfer/copied.js";
|
|
20
|
+
import { getActiveModeId, getNodeVariableModeId, resolveColorVariable, resolveColorVariableForNode, resolveNumberVariable, resolveNumberVariableForNode, resolveStringVariableForNode, resolveVariable, resolveVariableForNode } from "./variables/resolution.js";
|
|
21
|
+
import { addCollection, addMode, addVariable, bindVariable, createCollection, createMode, createVariable, getVariablesByType, getVariablesForCollection, removeCollection, removeMode, removeVariable, renameMode, setActiveMode, setDefaultMode, unbindVariable } from "./variables/index.js";
|
|
22
|
+
import { omitBy, pick } from "es-toolkit/object";
|
|
23
|
+
import { isUndefined } from "es-toolkit/predicate";
|
|
24
|
+
//#region src/graph.ts
|
|
25
|
+
var SceneGraph = class {
|
|
26
|
+
idGenerator;
|
|
27
|
+
nodes = /* @__PURE__ */ new Map();
|
|
28
|
+
images = /* @__PURE__ */ new Map();
|
|
29
|
+
variables = /* @__PURE__ */ new Map();
|
|
30
|
+
variableCollections = /* @__PURE__ */ new Map();
|
|
31
|
+
activeMode = /* @__PURE__ */ new Map();
|
|
32
|
+
rootId;
|
|
33
|
+
figKiwiVersion = null;
|
|
34
|
+
/** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */
|
|
35
|
+
figSchemaDeflated = null;
|
|
36
|
+
documentColorSpace = "srgb";
|
|
37
|
+
documentKind = "design";
|
|
38
|
+
enabledLibraries = /* @__PURE__ */ new Map();
|
|
39
|
+
emitter = new BufferedSceneEmitter();
|
|
40
|
+
absPosCache = /* @__PURE__ */ new Map();
|
|
41
|
+
scopeDepths = {
|
|
42
|
+
preview: 0,
|
|
43
|
+
sourceMetadata: 0,
|
|
44
|
+
importedState: 0,
|
|
45
|
+
layout: 0,
|
|
46
|
+
derivedLayout: 0
|
|
47
|
+
};
|
|
48
|
+
previewObservers = [];
|
|
49
|
+
changeObservers = /* @__PURE__ */ new Set();
|
|
50
|
+
importedIdGenerator;
|
|
51
|
+
layoutWrites = null;
|
|
52
|
+
positionPreviewVersion = 0;
|
|
53
|
+
instanceIndex = /* @__PURE__ */ new Map();
|
|
54
|
+
/** Every connector in the graph, so routing need not scan every layer. */
|
|
55
|
+
connectorIds = /* @__PURE__ */ new Set();
|
|
56
|
+
constructor(idGenerator = generateId) {
|
|
57
|
+
this.idGenerator = idGenerator;
|
|
58
|
+
const root = createDefaultNode(this.idGenerator, "FRAME", {
|
|
59
|
+
name: "Document",
|
|
60
|
+
width: 0,
|
|
61
|
+
height: 0
|
|
62
|
+
});
|
|
63
|
+
this.rootId = root.id;
|
|
64
|
+
this.nodes.set(root.id, root);
|
|
65
|
+
this.addPage("Page 1");
|
|
66
|
+
}
|
|
67
|
+
addPage(name) {
|
|
68
|
+
return this.createNode("CANVAS", this.rootId, {
|
|
69
|
+
name,
|
|
70
|
+
width: 0,
|
|
71
|
+
height: 0
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getPages(includeInternal = false) {
|
|
75
|
+
return this.getChildren(this.rootId).filter((n) => n.type === "CANVAS" && (includeInternal || !n.internalOnly));
|
|
76
|
+
}
|
|
77
|
+
getAllNodes() {
|
|
78
|
+
return this.nodes.values();
|
|
79
|
+
}
|
|
80
|
+
getNode(id) {
|
|
81
|
+
return this.nodes.get(id);
|
|
82
|
+
}
|
|
83
|
+
onNodeEvents(handlers) {
|
|
84
|
+
return bindNodeEvents(this.emitter, handlers);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Tells `observer` about each node an edit adds and, before it changes, each node it is about
|
|
88
|
+
* to change, so a recorder can keep the node as it was. Unlike node events these are never
|
|
89
|
+
* buffered. Graph methods report the nodes they change; code that writes into a node directly
|
|
90
|
+
* reports it with `willChangeNode` first.
|
|
91
|
+
*/
|
|
92
|
+
observeNodeChanges(observer) {
|
|
93
|
+
this.changeObservers.add(observer);
|
|
94
|
+
return () => this.changeObservers.delete(observer);
|
|
95
|
+
}
|
|
96
|
+
/** Tells `observeNodeChanges` observers that `node` is about to change. */
|
|
97
|
+
willChangeNode(node) {
|
|
98
|
+
if (!node) return;
|
|
99
|
+
for (const observer of this.changeObservers) observer.before(node);
|
|
100
|
+
}
|
|
101
|
+
countDescendants(nodeId) {
|
|
102
|
+
const node = this.nodes.get(nodeId);
|
|
103
|
+
if (!node) return 0;
|
|
104
|
+
let count = 0;
|
|
105
|
+
const stack = [...node.childIds];
|
|
106
|
+
while (stack.length > 0) {
|
|
107
|
+
const id = stack.pop();
|
|
108
|
+
if (id === void 0) break;
|
|
109
|
+
count++;
|
|
110
|
+
const child = this.nodes.get(id);
|
|
111
|
+
if (child) for (const childId of child.childIds) stack.push(childId);
|
|
112
|
+
}
|
|
113
|
+
return count;
|
|
114
|
+
}
|
|
115
|
+
addVariable(variable) {
|
|
116
|
+
addVariable(this, variable);
|
|
117
|
+
}
|
|
118
|
+
removeVariable(id) {
|
|
119
|
+
removeVariable(this, id);
|
|
120
|
+
}
|
|
121
|
+
addCollection(collection) {
|
|
122
|
+
addCollection(this, collection);
|
|
123
|
+
}
|
|
124
|
+
createVariable(name, type, collectionId, value) {
|
|
125
|
+
return createVariable(this, () => this.generateEntityId(), name, type, collectionId, value);
|
|
126
|
+
}
|
|
127
|
+
createCollection(name) {
|
|
128
|
+
const issued = /* @__PURE__ */ new Set();
|
|
129
|
+
return createCollection(this, () => this.generateEntityId(issued), name);
|
|
130
|
+
}
|
|
131
|
+
createMode(collectionId, name, sourceModeId) {
|
|
132
|
+
return createMode(this, () => this.generateEntityId(), collectionId, name, sourceModeId);
|
|
133
|
+
}
|
|
134
|
+
removeCollection(id) {
|
|
135
|
+
removeCollection(this, id);
|
|
136
|
+
}
|
|
137
|
+
getActiveModeId(collectionId) {
|
|
138
|
+
return getActiveModeId(this, collectionId);
|
|
139
|
+
}
|
|
140
|
+
getNodeVariableModeId(nodeId, collectionId) {
|
|
141
|
+
return getNodeVariableModeId(this, nodeId, collectionId);
|
|
142
|
+
}
|
|
143
|
+
setActiveMode(collectionId, modeId) {
|
|
144
|
+
setActiveMode(this, collectionId, modeId);
|
|
145
|
+
}
|
|
146
|
+
addMode(collectionId, modeId, name, sourceMode) {
|
|
147
|
+
addMode(this, collectionId, modeId, name, sourceMode);
|
|
148
|
+
}
|
|
149
|
+
removeMode(collectionId, modeId) {
|
|
150
|
+
removeMode(this, collectionId, modeId);
|
|
151
|
+
}
|
|
152
|
+
renameMode(collectionId, modeId, name) {
|
|
153
|
+
renameMode(this, collectionId, modeId, name);
|
|
154
|
+
}
|
|
155
|
+
setDefaultMode(collectionId, modeId) {
|
|
156
|
+
setDefaultMode(this, collectionId, modeId);
|
|
157
|
+
}
|
|
158
|
+
resolveVariable(variableId, modeId, visited) {
|
|
159
|
+
return resolveVariable(this, variableId, modeId, visited);
|
|
160
|
+
}
|
|
161
|
+
resolveColorVariable(variableId) {
|
|
162
|
+
return resolveColorVariable(this, variableId);
|
|
163
|
+
}
|
|
164
|
+
resolveNumberVariable(variableId) {
|
|
165
|
+
return resolveNumberVariable(this, variableId);
|
|
166
|
+
}
|
|
167
|
+
resolveColorVariableForNode(nodeId, variableId, fallback) {
|
|
168
|
+
return resolveColorVariableForNode(this, nodeId, variableId, fallback);
|
|
169
|
+
}
|
|
170
|
+
resolveNumberVariableForNode(nodeId, variableId, fallback) {
|
|
171
|
+
return resolveNumberVariableForNode(this, nodeId, variableId, fallback);
|
|
172
|
+
}
|
|
173
|
+
resolveVariableForNode(nodeId, variableId, fallback) {
|
|
174
|
+
return resolveVariableForNode(this, nodeId, variableId, fallback);
|
|
175
|
+
}
|
|
176
|
+
resolveStringVariableForNode(nodeId, variableId, fallback) {
|
|
177
|
+
return resolveStringVariableForNode(this, nodeId, variableId, fallback);
|
|
178
|
+
}
|
|
179
|
+
getVariablesForCollection(collectionId) {
|
|
180
|
+
return getVariablesForCollection(this, collectionId);
|
|
181
|
+
}
|
|
182
|
+
getVariablesByType(type) {
|
|
183
|
+
return getVariablesByType(this, type);
|
|
184
|
+
}
|
|
185
|
+
bindVariable(nodeId, field, variableId) {
|
|
186
|
+
bindVariable(this, nodeId, field, variableId);
|
|
187
|
+
}
|
|
188
|
+
unbindVariable(nodeId, field) {
|
|
189
|
+
unbindVariable(this, nodeId, field);
|
|
190
|
+
}
|
|
191
|
+
getChildren(id) {
|
|
192
|
+
const node = this.nodes.get(id);
|
|
193
|
+
if (!node) return [];
|
|
194
|
+
return node.childIds.map((cid) => this.nodes.get(cid)).filter((n) => n !== void 0);
|
|
195
|
+
}
|
|
196
|
+
isContainer(id) {
|
|
197
|
+
const node = this.nodes.get(id);
|
|
198
|
+
return node ? CONTAINER_TYPES.has(node.type) : false;
|
|
199
|
+
}
|
|
200
|
+
isDescendant(childId, ancestorId) {
|
|
201
|
+
return this.closest(childId, (node) => node.id === ancestorId) !== void 0;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The node itself or its nearest ancestor that matches. The walk visits at most as many nodes
|
|
205
|
+
* as the graph holds, so a parent cycle in bad data cannot hang it.
|
|
206
|
+
*/
|
|
207
|
+
closest(id, match) {
|
|
208
|
+
let current = this.nodes.get(id);
|
|
209
|
+
for (let steps = 0; current && steps < this.nodes.size; steps++) {
|
|
210
|
+
if (match(current)) return current;
|
|
211
|
+
current = current.parentId ? this.nodes.get(current.parentId) : void 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The page a node is on: the node itself for a page, its nearest page ancestor otherwise, and
|
|
216
|
+
* null for the document root or a node on no page.
|
|
217
|
+
*/
|
|
218
|
+
pageOf(id) {
|
|
219
|
+
return this.closest(id, (node) => node.type === "CANVAS")?.id ?? null;
|
|
220
|
+
}
|
|
221
|
+
clearAbsPosCache() {
|
|
222
|
+
this.absPosCache.clear();
|
|
223
|
+
}
|
|
224
|
+
getAbsolutePosition(id) {
|
|
225
|
+
const cached = this.absPosCache.get(id);
|
|
226
|
+
if (cached) return cached;
|
|
227
|
+
const node = this.getNode(id);
|
|
228
|
+
if (!node) return {
|
|
229
|
+
x: 0,
|
|
230
|
+
y: 0
|
|
231
|
+
};
|
|
232
|
+
const result = getAbsolutePosition(node, this);
|
|
233
|
+
this.absPosCache.set(id, result);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
getAbsoluteBounds(id) {
|
|
237
|
+
const pos = this.getAbsolutePosition(id);
|
|
238
|
+
const node = this.nodes.get(id);
|
|
239
|
+
return {
|
|
240
|
+
x: pos.x,
|
|
241
|
+
y: pos.y,
|
|
242
|
+
width: node?.width ?? 0,
|
|
243
|
+
height: node?.height ?? 0
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* An ID no entity uses; `issued` also excludes IDs handed out earlier in the same creation.
|
|
248
|
+
* A generator that returns more taken IDs than the graph holds must be repeating itself, so
|
|
249
|
+
* it counts as exhausted then; a fixed cap would reject a sequence walking past a large import.
|
|
250
|
+
*/
|
|
251
|
+
generateEntityId(issued) {
|
|
252
|
+
let limit = Infinity;
|
|
253
|
+
for (let attempt = 0; attempt < limit; attempt++) {
|
|
254
|
+
const id = (this.importedIdGenerator ?? this.idGenerator)();
|
|
255
|
+
if (this.isEntityIdTaken(id) || issued?.has(id)) {
|
|
256
|
+
if (limit === Infinity) limit = this.entityIdCount() + (issued?.size ?? 0) + 1;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
issued?.add(id);
|
|
260
|
+
return id;
|
|
261
|
+
}
|
|
262
|
+
throw new Error("The ID generator only returned IDs that are in use");
|
|
263
|
+
}
|
|
264
|
+
entityIdCount() {
|
|
265
|
+
let count = this.nodes.size + this.variables.size + this.variableCollections.size;
|
|
266
|
+
for (const collection of this.variableCollections.values()) count += collection.modes.length;
|
|
267
|
+
return count;
|
|
268
|
+
}
|
|
269
|
+
/** Whether a node, variable, collection, or mode has this id. */
|
|
270
|
+
isEntityIdTaken(id) {
|
|
271
|
+
if (this.nodes.has(id) || this.variables.has(id) || this.variableCollections.has(id)) return true;
|
|
272
|
+
for (const collection of this.variableCollections.values()) for (const mode of collection.modes) if (mode.modeId === id) return true;
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
indexInstance(componentId, instanceId) {
|
|
276
|
+
let set = this.instanceIndex.get(componentId);
|
|
277
|
+
if (!set) {
|
|
278
|
+
set = /* @__PURE__ */ new Set();
|
|
279
|
+
this.instanceIndex.set(componentId, set);
|
|
280
|
+
}
|
|
281
|
+
set.add(instanceId);
|
|
282
|
+
}
|
|
283
|
+
unindexInstance(componentId, instanceId) {
|
|
284
|
+
this.instanceIndex.get(componentId)?.delete(instanceId);
|
|
285
|
+
}
|
|
286
|
+
registerNode(node, parentId) {
|
|
287
|
+
node.parentId = parentId;
|
|
288
|
+
this.nodes.set(node.id, node);
|
|
289
|
+
if (node.type === "CONNECTOR") this.connectorIds.add(node.id);
|
|
290
|
+
for (const observer of this.changeObservers) observer.created(node);
|
|
291
|
+
if (node.type === "INSTANCE" && node.componentId) this.indexInstance(node.componentId, node.id);
|
|
292
|
+
this.emitter.emit("node:created", node);
|
|
293
|
+
return node;
|
|
294
|
+
}
|
|
295
|
+
/** Publish synchronous graph events only after the supplied mutation succeeds. */
|
|
296
|
+
withBufferedEvents(action) {
|
|
297
|
+
return this.emitter.batch(action);
|
|
298
|
+
}
|
|
299
|
+
createNode(type, parentId, overrides = {}) {
|
|
300
|
+
const node = createDefaultNode(() => this.generateEntityId(), type, overrides);
|
|
301
|
+
const parent = this.nodes.get(parentId);
|
|
302
|
+
this.willChangeNode(parent);
|
|
303
|
+
parent?.childIds.push(node.id);
|
|
304
|
+
return this.registerNode(node, parentId);
|
|
305
|
+
}
|
|
306
|
+
createNodeWithId(id, type, parentId, overrides = {}) {
|
|
307
|
+
const node = createDefaultNode(() => id, type, overrides);
|
|
308
|
+
node.id = id;
|
|
309
|
+
const parent = parentId ? this.nodes.get(parentId) : void 0;
|
|
310
|
+
if (parent && !parent.childIds.includes(id)) {
|
|
311
|
+
this.willChangeNode(parent);
|
|
312
|
+
parent.childIds.push(id);
|
|
313
|
+
}
|
|
314
|
+
return this.registerNode(node, parentId);
|
|
315
|
+
}
|
|
316
|
+
withScope(scope, fn) {
|
|
317
|
+
this.scopeDepths[scope]++;
|
|
318
|
+
try {
|
|
319
|
+
return fn();
|
|
320
|
+
} finally {
|
|
321
|
+
this.scopeDepths[scope]--;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
runPreviewUpdates(fn, beforeUpdate) {
|
|
325
|
+
if (beforeUpdate) this.previewObservers.push(beforeUpdate);
|
|
326
|
+
try {
|
|
327
|
+
this.withScope("preview", fn);
|
|
328
|
+
} finally {
|
|
329
|
+
if (beforeUpdate) this.previewObservers.pop();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
preserveSourceMetadataDuring(fn) {
|
|
333
|
+
return this.withScope("sourceMetadata", fn);
|
|
334
|
+
}
|
|
335
|
+
get isPreservingSourceMetadata() {
|
|
336
|
+
return this.scopeDepths.sourceMetadata > 0;
|
|
337
|
+
}
|
|
338
|
+
applyImportedStateDuring(fn, idGenerator) {
|
|
339
|
+
const previousGenerator = this.importedIdGenerator;
|
|
340
|
+
this.importedIdGenerator = idGenerator ?? previousGenerator;
|
|
341
|
+
try {
|
|
342
|
+
return this.withScope("importedState", () => this.preserveSourceMetadataDuring(fn));
|
|
343
|
+
} finally {
|
|
344
|
+
this.importedIdGenerator = previousGenerator;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
get isApplyingImportedState() {
|
|
348
|
+
return this.scopeDepths.importedState > 0;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Lays out what the document already holds: a page as it loads, or again once its fonts
|
|
352
|
+
* arrive. What this writes derives from the document; an edit's own layout is not this.
|
|
353
|
+
*/
|
|
354
|
+
applyDerivedLayoutDuring(fn) {
|
|
355
|
+
this.withScope("derivedLayout", fn);
|
|
356
|
+
}
|
|
357
|
+
get isApplyingDerivedLayout() {
|
|
358
|
+
return this.scopeDepths.derivedLayout > 0;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Runs `fn` as layout. Its updates are published once the outermost layout ends, still as
|
|
362
|
+
* layout, and without values a pass changed and a later pass put back (`LayoutWrites`). Outside
|
|
363
|
+
* derived layout, the positions and sizes it publishes count as edited, so formats save them.
|
|
364
|
+
*/
|
|
365
|
+
withLayoutMutations(fn) {
|
|
366
|
+
const outermost = this.scopeDepths.layout === 0;
|
|
367
|
+
this.scopeDepths.layout++;
|
|
368
|
+
if (outermost) this.layoutWrites = new LayoutWrites();
|
|
369
|
+
try {
|
|
370
|
+
fn();
|
|
371
|
+
} finally {
|
|
372
|
+
try {
|
|
373
|
+
if (outermost) this.publishLayoutUpdates();
|
|
374
|
+
} finally {
|
|
375
|
+
this.scopeDepths.layout--;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
publishLayoutUpdates() {
|
|
380
|
+
const writes = this.layoutWrites;
|
|
381
|
+
this.layoutWrites = null;
|
|
382
|
+
if (!writes) return;
|
|
383
|
+
for (const [node, changes, edited] of writes.updates((nodeId) => this.nodes.get(nodeId))) {
|
|
384
|
+
markSourceFieldsEdited(node, edited);
|
|
385
|
+
this.emitter.emit("node:updated", node.id, changes);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
get isApplyingLayout() {
|
|
389
|
+
return this.scopeDepths.layout > 0;
|
|
390
|
+
}
|
|
391
|
+
updateNodePositionPreview(id, x, y) {
|
|
392
|
+
this.updateNodePreview(id, {
|
|
393
|
+
x,
|
|
394
|
+
y
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
updateNodePreview(id, changes) {
|
|
398
|
+
const node = this.nodes.get(id);
|
|
399
|
+
if (node) changes = this.sizedChanges(node, changes);
|
|
400
|
+
const appliedChanges = updateNodePreview(this, id, changes, (node, applied) => {
|
|
401
|
+
for (const observe of this.previewObservers) observe(node, applied);
|
|
402
|
+
});
|
|
403
|
+
if (appliedChanges) this.emitter.emit("node:previewUpdated", id, appliedChanges);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Writes fields as given. Edits detach the shared styles whose fields they change before
|
|
407
|
+
* they get here (`styleDetachmentChanges`); resolving bindings or loading a file does not.
|
|
408
|
+
*/
|
|
409
|
+
updateNode(id, changes) {
|
|
410
|
+
if (this.scopeDepths.preview > 0) {
|
|
411
|
+
this.updateNodePreview(id, changes);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const node = this.nodes.get(id);
|
|
415
|
+
if (!node) return;
|
|
416
|
+
this.applyNodeChanges(node, this.sizedChanges(node, omitBy(changes, isUndefined)));
|
|
417
|
+
}
|
|
418
|
+
/** A size set from outside layout, with what it also sets on a generated frame. */
|
|
419
|
+
sizedChanges(node, changes) {
|
|
420
|
+
return this.isApplyingLayout ? changes : withGeneratedFrameSize(node, changes);
|
|
421
|
+
}
|
|
422
|
+
/** Replay captured properties without dropping explicit undefined values or absent keys. */
|
|
423
|
+
restoreNodeProperties(id, changes, absent) {
|
|
424
|
+
const node = this.nodes.get(id);
|
|
425
|
+
if (node) this.applyNodeChanges(node, changes, absent);
|
|
426
|
+
}
|
|
427
|
+
applyNodeChanges(node, changes, absent = []) {
|
|
428
|
+
const { id } = node;
|
|
429
|
+
this.willChangeNode(node);
|
|
430
|
+
if (absent.length) {
|
|
431
|
+
changes = { ...changes };
|
|
432
|
+
for (const key of absent) Reflect.set(changes, key, void 0);
|
|
433
|
+
}
|
|
434
|
+
if (Object.keys(changes).some((k) => LAYOUT_AFFECTING_KEYS.has(k))) this.absPosCache.clear();
|
|
435
|
+
if (node.type === "INSTANCE" && "componentId" in changes && changes.componentId !== node.componentId) {
|
|
436
|
+
if (node.componentId) this.unindexInstance(node.componentId, id);
|
|
437
|
+
if (changes.componentId) this.indexInstance(changes.componentId, id);
|
|
438
|
+
}
|
|
439
|
+
this.markEdited(node, Object.keys(changes));
|
|
440
|
+
if (node.type === "TEXT") changes = {
|
|
441
|
+
...omitBy(textCacheInvalidationChanges(node, changes), (value, key) => Object.is(node[key], value)),
|
|
442
|
+
...changes
|
|
443
|
+
};
|
|
444
|
+
if (changes.vectorNetwork) changes = {
|
|
445
|
+
...changes,
|
|
446
|
+
vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)
|
|
447
|
+
};
|
|
448
|
+
this.layoutWrites?.record(node, changes, this.scopeDepths.sourceMetadata === 0 && !this.isApplyingDerivedLayout);
|
|
449
|
+
Object.assign(node, changes);
|
|
450
|
+
if (changes.fills) removeStaleBindings(node, "fills", changes);
|
|
451
|
+
if (changes.strokes) removeStaleBindings(node, "strokes", changes);
|
|
452
|
+
if (changes.effects) removeStaleBindings(node, "effects", changes);
|
|
453
|
+
for (const key of absent) Reflect.deleteProperty(node, key);
|
|
454
|
+
this.publishNodeUpdate(id, changes);
|
|
455
|
+
}
|
|
456
|
+
/** Marks fields an edit changed, unless metadata is being restored or layout is writing them. */
|
|
457
|
+
markEdited(node, keys) {
|
|
458
|
+
if (this.scopeDepths.sourceMetadata === 0 && !this.isApplyingLayout) markSourceFieldsEdited(node, keys);
|
|
459
|
+
}
|
|
460
|
+
/** Publishes an update now, or leaves it to the running layout, which publishes once it ends. */
|
|
461
|
+
publishNodeUpdate(id, changes) {
|
|
462
|
+
if (!this.layoutWrites) this.emitter.emit("node:updated", id, changes);
|
|
463
|
+
}
|
|
464
|
+
reparentNode(nodeId, newParentId) {
|
|
465
|
+
const node = this.nodes.get(nodeId);
|
|
466
|
+
if (!node || nodeId === this.rootId) return;
|
|
467
|
+
if (this.isDescendant(newParentId, nodeId)) return;
|
|
468
|
+
const oldParent = node.parentId ? this.nodes.get(node.parentId) : void 0;
|
|
469
|
+
const newParent = this.nodes.get(newParentId);
|
|
470
|
+
if (!newParent) return;
|
|
471
|
+
if (node.parentId === newParentId) return;
|
|
472
|
+
const oldParentId = node.parentId;
|
|
473
|
+
this.willChangeNode(node);
|
|
474
|
+
this.willChangeNode(oldParent);
|
|
475
|
+
this.willChangeNode(newParent);
|
|
476
|
+
this.absPosCache.clear();
|
|
477
|
+
const oldParentWorld = getParentWorldMatrix(oldParent, this);
|
|
478
|
+
const newParentWorld = getParentWorldMatrix(newParent, this);
|
|
479
|
+
if (oldParent) oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId);
|
|
480
|
+
node.parentId = newParentId;
|
|
481
|
+
newParent.childIds.push(nodeId);
|
|
482
|
+
const before = pick(node, TRANSFORM_FIELDS);
|
|
483
|
+
if (isTranslationOnly(oldParentWorld) && isTranslationOnly(newParentWorld)) {
|
|
484
|
+
node.x += oldParentWorld[2] - newParentWorld[2];
|
|
485
|
+
node.y += oldParentWorld[5] - newParentWorld[5];
|
|
486
|
+
} else {
|
|
487
|
+
const world = Matrix.multiply(oldParentWorld, getNodeLocalMatrix(node));
|
|
488
|
+
const local = localTransformFromWorld(node, world, newParentWorld);
|
|
489
|
+
if (local) Object.assign(node, local);
|
|
490
|
+
}
|
|
491
|
+
this.markEdited(node, TRANSFORM_FIELDS.filter((key) => node[key] !== before[key]));
|
|
492
|
+
this.emitter.emit("node:reparented", nodeId, oldParentId, newParentId);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Moves a node to `index` among `parentId`'s children, from wherever it was, without changing
|
|
496
|
+
* its own coordinates. An index past the end appends; a move into the node itself or one of
|
|
497
|
+
* its descendants is ignored.
|
|
498
|
+
*/
|
|
499
|
+
insertChildAt(childId, parentId, index) {
|
|
500
|
+
const node = this.nodes.get(childId);
|
|
501
|
+
const newParent = this.nodes.get(parentId);
|
|
502
|
+
if (!node || !newParent || this.isDescendant(parentId, childId)) return;
|
|
503
|
+
const previousParentId = node.parentId;
|
|
504
|
+
const oldParent = previousParentId ? this.nodes.get(previousParentId) : void 0;
|
|
505
|
+
this.willChangeNode(node);
|
|
506
|
+
this.willChangeNode(oldParent);
|
|
507
|
+
this.willChangeNode(newParent);
|
|
508
|
+
if (oldParent) oldParent.childIds = oldParent.childIds.filter((id) => id !== childId);
|
|
509
|
+
newParent.childIds = newParent.childIds.filter((id) => id !== childId);
|
|
510
|
+
const at = Math.min(index, newParent.childIds.length);
|
|
511
|
+
newParent.childIds.splice(at, 0, childId);
|
|
512
|
+
node.parentId = parentId;
|
|
513
|
+
this.absPosCache.clear();
|
|
514
|
+
this.emitter.emit("node:reordered", childId, parentId, at, previousParentId);
|
|
515
|
+
}
|
|
516
|
+
deleteNode(id) {
|
|
517
|
+
const node = this.nodes.get(id);
|
|
518
|
+
if (!node || id === this.rootId) return;
|
|
519
|
+
this.willChangeNode(node);
|
|
520
|
+
if (node.parentId) {
|
|
521
|
+
const parent = this.nodes.get(node.parentId);
|
|
522
|
+
this.willChangeNode(parent);
|
|
523
|
+
if (parent) parent.childIds = parent.childIds.filter((cid) => cid !== id);
|
|
524
|
+
}
|
|
525
|
+
for (const childId of Array.from(node.childIds)) this.deleteNode(childId);
|
|
526
|
+
if (node.type === "INSTANCE" && node.componentId) this.unindexInstance(node.componentId, id);
|
|
527
|
+
this.connectorIds.delete(id);
|
|
528
|
+
this.nodes.delete(id);
|
|
529
|
+
this.emitter.emit("node:deleted", id, node.parentId);
|
|
530
|
+
}
|
|
531
|
+
hitTest(px, py, scopeId) {
|
|
532
|
+
return hitTest(this, px, py, scopeId);
|
|
533
|
+
}
|
|
534
|
+
/** `pad`, in canvas units, grows each shape's box, as Figma takes clicks just outside one. */
|
|
535
|
+
hitTestDeep(px, py, scopeId, pad = 0) {
|
|
536
|
+
return hitTestDeep(this, px, py, scopeId, pad);
|
|
537
|
+
}
|
|
538
|
+
hitTestSelectable(px, py, scopeId, selectedIds, options) {
|
|
539
|
+
return hitTestSelectable(this, px, py, scopeId, selectedIds, options);
|
|
540
|
+
}
|
|
541
|
+
hitTestOpenContainer(px, py, scopeId) {
|
|
542
|
+
return hitTestOpenContainer(this, px, py, scopeId);
|
|
543
|
+
}
|
|
544
|
+
isOpenContainer(nodeId, framesOpen = true) {
|
|
545
|
+
return isOpenContainer(this, nodeId, framesOpen);
|
|
546
|
+
}
|
|
547
|
+
isPointInNode(nodeId, px, py) {
|
|
548
|
+
return isPointInNode(this, nodeId, px, py);
|
|
549
|
+
}
|
|
550
|
+
hitTestDropTarget(px, py, excludeIds, scopeId, options) {
|
|
551
|
+
return hitTestDropTarget(this, px, py, excludeIds, scopeId, options);
|
|
552
|
+
}
|
|
553
|
+
cloneTree(sourceId, parentId, overrides = {}) {
|
|
554
|
+
const ids = /* @__PURE__ */ new Map();
|
|
555
|
+
const clone = this.cloneSubtree(sourceId, parentId, overrides, ids);
|
|
556
|
+
remapCopiedReferences(this, ids);
|
|
557
|
+
return clone;
|
|
558
|
+
}
|
|
559
|
+
cloneSubtree(sourceId, parentId, overrides, ids) {
|
|
560
|
+
const src = this.nodes.get(sourceId);
|
|
561
|
+
if (!src) return null;
|
|
562
|
+
const props = cloneNodeProps(src, null);
|
|
563
|
+
if (props.source) props.source = {
|
|
564
|
+
...props.source,
|
|
565
|
+
id: null,
|
|
566
|
+
orderKey: null
|
|
567
|
+
};
|
|
568
|
+
props.status = null;
|
|
569
|
+
const clone = this.createNode(src.type, parentId, {
|
|
570
|
+
...props,
|
|
571
|
+
...overrides
|
|
572
|
+
});
|
|
573
|
+
if (src.status) markSourceFieldsEdited(clone, ["status"]);
|
|
574
|
+
ids.set(src.id, clone.id);
|
|
575
|
+
for (const childId of src.childIds) this.cloneSubtree(childId, clone.id, {}, ids);
|
|
576
|
+
return clone;
|
|
577
|
+
}
|
|
578
|
+
createInstance(componentId, parentId, overrides = {}) {
|
|
579
|
+
return createInstance(this, componentId, parentId, overrides);
|
|
580
|
+
}
|
|
581
|
+
populateInstanceChildren(instanceId, componentId, mode = "deep") {
|
|
582
|
+
populateInstanceChildren(this, instanceId, componentId, mode);
|
|
583
|
+
}
|
|
584
|
+
swapInstanceComponent(instanceId, componentId, options) {
|
|
585
|
+
swapInstanceComponent(this, instanceId, componentId, options);
|
|
586
|
+
}
|
|
587
|
+
syncInstances(componentId) {
|
|
588
|
+
syncInstances(this, componentId);
|
|
589
|
+
}
|
|
590
|
+
syncInstancesTogether(componentIds) {
|
|
591
|
+
syncInstancesTogether(this, componentIds);
|
|
592
|
+
}
|
|
593
|
+
syncInstance(instanceId) {
|
|
594
|
+
syncInstance(this, instanceId);
|
|
595
|
+
}
|
|
596
|
+
detachInstance(instanceId) {
|
|
597
|
+
detachInstance(this, instanceId);
|
|
598
|
+
}
|
|
599
|
+
getMainComponent(instanceId) {
|
|
600
|
+
return getMainComponent(this, instanceId);
|
|
601
|
+
}
|
|
602
|
+
getInstances(componentId) {
|
|
603
|
+
return getInstances(this, componentId);
|
|
604
|
+
}
|
|
605
|
+
flattenTree(parentId, depth = 0) {
|
|
606
|
+
const id = parentId ?? this.rootId;
|
|
607
|
+
const parent = this.nodes.get(id);
|
|
608
|
+
if (!parent) return [];
|
|
609
|
+
const result = [];
|
|
610
|
+
for (const childId of parent.childIds) {
|
|
611
|
+
const child = this.nodes.get(childId);
|
|
612
|
+
if (!child) continue;
|
|
613
|
+
result.push({
|
|
614
|
+
node: child,
|
|
615
|
+
depth
|
|
616
|
+
});
|
|
617
|
+
if (child.childIds.length > 0) result.push(...this.flattenTree(childId, depth + 1));
|
|
618
|
+
}
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
//#endregion
|
|
623
|
+
export { SceneGraph };
|
|
624
|
+
|
|
625
|
+
//# sourceMappingURL=graph.js.map
|