@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { variableIdentityReferences } from "./identity.js";
|
|
2
|
+
import { validateTransferReferences } from "./validation.js";
|
|
3
|
+
import { prepareVariableTransfer } from "./variables.js";
|
|
4
|
+
import { isEqual } from "es-toolkit/predicate";
|
|
5
|
+
//#region src/transfer/apply.ts
|
|
6
|
+
function validate(target, plan) {
|
|
7
|
+
validateTransferReferences(target, plan);
|
|
8
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
9
|
+
...target.nodes.keys(),
|
|
10
|
+
...target.variables.keys(),
|
|
11
|
+
...target.variableCollections.keys()
|
|
12
|
+
]);
|
|
13
|
+
const claim = (id) => {
|
|
14
|
+
if (reserved.has(id)) throw new Error(`Transfer identity collision ${id}`);
|
|
15
|
+
reserved.add(id);
|
|
16
|
+
};
|
|
17
|
+
prepareVariableTransfer(plan.variables, plan.collections, variableIdentityReferences(plan.variables, plan.collections));
|
|
18
|
+
for (const [id, mode] of plan.activeModes) if (!plan.collections.find((collection) => collection.id === id)?.modes.some((entry) => entry.modeId === mode)) throw new Error(`Invalid transferred active mode ${id}:${mode}`);
|
|
19
|
+
for (const collection of plan.collections) claim(collection.id);
|
|
20
|
+
for (const variable of plan.variables) claim(variable.id);
|
|
21
|
+
const parents = new Set(target.nodes.keys());
|
|
22
|
+
for (const node of plan.nodes) {
|
|
23
|
+
claim(node.id);
|
|
24
|
+
if ("id" in node.props || "parentId" in node.props || "childIds" in node.props) throw new Error("Transfer props cannot override hierarchy identity");
|
|
25
|
+
if (!parents.has(node.parentId)) throw new Error(`Missing transfer parent ${node.parentId}`);
|
|
26
|
+
parents.add(node.id);
|
|
27
|
+
}
|
|
28
|
+
for (const id of [...plan.rootIds, ...plan.dependencyPageIds]) if (!plan.nodes.some((node) => node.id === id)) throw new Error(`Missing transfer root ${id}`);
|
|
29
|
+
for (const node of plan.nodes) if (node.props.componentId && !parents.has(node.props.componentId)) throw new Error(`Missing transfer component ${node.props.componentId}`);
|
|
30
|
+
for (const [hash, bytes] of plan.images) {
|
|
31
|
+
const existing = target.images.get(hash);
|
|
32
|
+
if (existing && !isEqual(existing, bytes)) throw new Error(`Transfer image collision ${hash}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Revalidate at insertion time. Event-delivery failures after commit are not rollback failures. */
|
|
36
|
+
function applyGraphTransfer(target, input) {
|
|
37
|
+
const plan = structuredClone(input);
|
|
38
|
+
validate(target, plan);
|
|
39
|
+
const imageIds = [...plan.images.keys()].filter((hash) => !target.images.has(hash));
|
|
40
|
+
target.withBufferedEvents(() => {
|
|
41
|
+
try {
|
|
42
|
+
for (const collection of plan.collections) target.addCollection(collection);
|
|
43
|
+
for (const variable of plan.variables) target.addVariable(variable);
|
|
44
|
+
for (const [id, mode] of plan.activeModes) target.activeMode.set(id, mode);
|
|
45
|
+
for (const [hash, bytes] of plan.images) if (!target.images.has(hash)) target.images.set(hash, bytes);
|
|
46
|
+
for (const node of plan.nodes) target.createNodeWithId(node.id, node.type, node.parentId, {
|
|
47
|
+
...node.props,
|
|
48
|
+
childIds: []
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
for (const node of plan.nodes.toReversed()) if (target.getNode(node.id)) target.deleteNode(node.id);
|
|
52
|
+
for (const variable of plan.variables) target.variables.delete(variable.id);
|
|
53
|
+
for (const collection of plan.collections) {
|
|
54
|
+
target.variableCollections.delete(collection.id);
|
|
55
|
+
target.activeMode.delete(collection.id);
|
|
56
|
+
}
|
|
57
|
+
for (const hash of imageIds) target.images.delete(hash);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { applyGraphTransfer };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","names":[],"sources":["../../src/transfer/apply.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph } from '../graph'\nimport { variableIdentityReferences } from './identity'\nimport type { prepareGraphTransfer } from './plan'\nimport { validateTransferReferences } from './validation'\nimport { prepareVariableTransfer } from './variables'\n\nexport type GraphTransferPlan = ReturnType<typeof prepareGraphTransfer>\n\nfunction validate(target: SceneGraph, plan: GraphTransferPlan): void {\n validateTransferReferences(target, plan)\n const reserved = new Set([\n ...target.nodes.keys(),\n ...target.variables.keys(),\n ...target.variableCollections.keys()\n ])\n const claim = (id: string): void => {\n if (reserved.has(id)) throw new Error(`Transfer identity collision ${id}`)\n reserved.add(id)\n }\n prepareVariableTransfer(\n plan.variables,\n plan.collections,\n variableIdentityReferences(plan.variables, plan.collections)\n )\n for (const [id, mode] of plan.activeModes) {\n if (\n !plan.collections\n .find((collection) => collection.id === id)\n ?.modes.some((entry) => entry.modeId === mode)\n )\n throw new Error(`Invalid transferred active mode ${id}:${mode}`)\n }\n for (const collection of plan.collections) claim(collection.id)\n for (const variable of plan.variables) claim(variable.id)\n const parents = new Set(target.nodes.keys())\n for (const node of plan.nodes) {\n claim(node.id)\n if ('id' in node.props || 'parentId' in node.props || 'childIds' in node.props)\n throw new Error('Transfer props cannot override hierarchy identity')\n if (!parents.has(node.parentId)) throw new Error(`Missing transfer parent ${node.parentId}`)\n parents.add(node.id)\n }\n for (const id of [...plan.rootIds, ...plan.dependencyPageIds]) {\n if (!plan.nodes.some((node) => node.id === id)) throw new Error(`Missing transfer root ${id}`)\n }\n for (const node of plan.nodes) {\n if (node.props.componentId && !parents.has(node.props.componentId))\n throw new Error(`Missing transfer component ${node.props.componentId}`)\n }\n for (const [hash, bytes] of plan.images) {\n const existing = target.images.get(hash)\n if (existing && !isEqual(existing, bytes)) throw new Error(`Transfer image collision ${hash}`)\n }\n}\n\n/** Revalidate at insertion time. Event-delivery failures after commit are not rollback failures. */\nexport function applyGraphTransfer(target: SceneGraph, input: GraphTransferPlan): void {\n const plan = structuredClone(input)\n validate(target, plan)\n const imageIds = [...plan.images.keys()].filter((hash) => !target.images.has(hash))\n target.withBufferedEvents(() => {\n try {\n for (const collection of plan.collections) target.addCollection(collection)\n for (const variable of plan.variables) target.addVariable(variable)\n for (const [id, mode] of plan.activeModes) target.activeMode.set(id, mode)\n for (const [hash, bytes] of plan.images)\n if (!target.images.has(hash)) target.images.set(hash, bytes)\n for (const node of plan.nodes)\n target.createNodeWithId(node.id, node.type, node.parentId, { ...node.props, childIds: [] })\n } catch (error) {\n for (const node of plan.nodes.toReversed())\n if (target.getNode(node.id)) target.deleteNode(node.id)\n for (const variable of plan.variables) target.variables.delete(variable.id)\n for (const collection of plan.collections) {\n target.variableCollections.delete(collection.id)\n target.activeMode.delete(collection.id)\n }\n for (const hash of imageIds) target.images.delete(hash)\n throw error\n }\n })\n}\n"],"mappings":";;;;;AAUA,SAAS,SAAS,QAAoB,MAA+B;CACnE,2BAA2B,QAAQ,IAAI;CACvC,MAAM,2BAAW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;GACxC;GACA,KAAK,MAAM,QAAQ,UAAU,OAAO,OAAO,OAAO,IAAI;GACtD,MAAM;EACR;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
//#region src/transfer/copied.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's
|
|
5
|
+
* main component, the layers its overrides change and the components they swap in, the
|
|
6
|
+
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
7
|
+
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
8
|
+
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
9
|
+
* so do variable IDs, since the copies keep their source's variables.
|
|
10
|
+
*/
|
|
11
|
+
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string>): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { remapCopiedReferences };
|
|
14
|
+
//# sourceMappingURL=copied.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copied.d.ts","names":[],"sources":["../../src/transfer/copied.ts"],"mappings":";;;;;;;;;;iBAuDgB,sBACd,OAAO,YACP,WAAW"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { remapInstanceOverrideState } from "../instances/overrides.js";
|
|
2
|
+
import { componentPropertyDefinitions } from "../components/properties.js";
|
|
3
|
+
import { isEqual, mapValues } from "es-toolkit";
|
|
4
|
+
//#region src/transfer/copied.ts
|
|
5
|
+
function swapPropertyIds(definitions) {
|
|
6
|
+
return definitions.filter((definition) => definition.type === "INSTANCE_SWAP").map((definition) => definition.id);
|
|
7
|
+
}
|
|
8
|
+
function remappedReferences(node, mapped, swapProperties) {
|
|
9
|
+
const changes = {};
|
|
10
|
+
if (node.componentId && mapped(node.componentId) !== node.componentId) changes.componentId = mapped(node.componentId);
|
|
11
|
+
const overrides = remapInstanceOverrideState(node.instanceOverrides, {
|
|
12
|
+
node: mapped,
|
|
13
|
+
variable: (id) => id
|
|
14
|
+
});
|
|
15
|
+
if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides;
|
|
16
|
+
const definitions = node.componentPropertyDefinitions.map((definition) => definition.type === "INSTANCE_SWAP" && definition.defaultValue ? {
|
|
17
|
+
...definition,
|
|
18
|
+
defaultValue: mapped(definition.defaultValue)
|
|
19
|
+
} : definition);
|
|
20
|
+
if (!isEqual(definitions, node.componentPropertyDefinitions)) changes.componentPropertyDefinitions = definitions;
|
|
21
|
+
const assignments = mapValues(node.componentPropertyAssignments, (value, id) => swapProperties.has(id) ? mapped(value) : value);
|
|
22
|
+
if (!isEqual(assignments, node.componentPropertyAssignments)) changes.componentPropertyAssignments = assignments;
|
|
23
|
+
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
24
|
+
const endpoint = node[field];
|
|
25
|
+
if (endpoint?.nodeId && mapped(endpoint.nodeId) !== endpoint.nodeId) changes[field] = {
|
|
26
|
+
...endpoint,
|
|
27
|
+
nodeId: mapped(endpoint.nodeId)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return changes;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's
|
|
34
|
+
* main component, the layers its overrides change and the components they swap in, the
|
|
35
|
+
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
36
|
+
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
37
|
+
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
38
|
+
* so do variable IDs, since the copies keep their source's variables.
|
|
39
|
+
*/
|
|
40
|
+
function remapCopiedReferences(graph, mappedIds) {
|
|
41
|
+
const mapped = (id) => mappedIds.get(id) ?? id;
|
|
42
|
+
const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? []);
|
|
43
|
+
const copiedSwaps = copies.flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions));
|
|
44
|
+
for (const node of copies) {
|
|
45
|
+
const changes = remappedReferences(node, mapped, /* @__PURE__ */ new Set([...copiedSwaps, ...swapPropertyIds(componentPropertyDefinitions(graph, node))]));
|
|
46
|
+
if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { remapCopiedReferences };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=copied.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copied.js","names":[],"sources":["../../src/transfer/copied.ts"],"sourcesContent":["import { isEqual, mapValues } from 'es-toolkit'\n\nimport { componentPropertyDefinitions } from '../components/properties'\nimport type { SceneGraph } from '../graph'\nimport { remapInstanceOverrideState } from '../instances/overrides'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\n\nfunction swapPropertyIds(definitions: readonly ComponentPropertyDefinition[]): string[] {\n return definitions\n .filter((definition) => definition.type === 'INSTANCE_SWAP')\n .map((definition) => definition.id)\n}\n\nfunction remappedReferences(\n node: SceneNode,\n mapped: (id: string) => string,\n swapProperties: ReadonlySet<string>\n): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n if (node.componentId && mapped(node.componentId) !== node.componentId)\n changes.componentId = mapped(node.componentId)\n // Only what a mapping changes: every write is an update collaboration sends.\n const overrides = remapInstanceOverrideState(node.instanceOverrides, {\n node: mapped,\n variable: (id) => id\n })\n if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides\n const definitions = node.componentPropertyDefinitions.map((definition) =>\n definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? { ...definition, defaultValue: mapped(definition.defaultValue) }\n : definition\n )\n if (!isEqual(definitions, node.componentPropertyDefinitions))\n changes.componentPropertyDefinitions = definitions\n const assignments = mapValues(node.componentPropertyAssignments, (value, id) =>\n swapProperties.has(id) ? mapped(value) : value\n )\n if (!isEqual(assignments, node.componentPropertyAssignments))\n changes.componentPropertyAssignments = assignments\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = node[field]\n if (endpoint?.nodeId && mapped(endpoint.nodeId) !== endpoint.nodeId)\n changes[field] = { ...endpoint, nodeId: mapped(endpoint.nodeId) }\n }\n return changes\n}\n\n/**\n * Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's\n * main component, the layers its overrides change and the components they swap in, the\n * components an instance-swap property defaults to or is set to, and the layers a connector's\n * ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design\n * JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and\n * so do variable IDs, since the copies keep their source's variables.\n */\nexport function remapCopiedReferences(\n graph: SceneGraph,\n mappedIds: ReadonlyMap<string, string>\n): void {\n const mapped = (id: string) => mappedIds.get(id) ?? id\n const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? [])\n const copiedSwaps = copies.flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions))\n for (const node of copies) {\n // An instance's swap property may be defined on a component the copy leaves behind.\n const swapProperties = new Set([\n ...copiedSwaps,\n ...swapPropertyIds(componentPropertyDefinitions(graph, node))\n ])\n const changes = remappedReferences(node, mapped, swapProperties)\n if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes)\n }\n}\n"],"mappings":";;;;AAOA,SAAS,gBAAgB,aAA+D;CACtF,OAAO,YACJ,QAAQ,eAAe,WAAW,SAAS,eAAe,CAAC,CAC3D,KAAK,eAAe,WAAW,EAAE;AACtC;AAEA,SAAS,mBACP,MACA,QACA,gBACoB;CACpB,MAAM,UAA8B,CAAC;CACrC,IAAI,KAAK,eAAe,OAAO,KAAK,WAAW,MAAM,KAAK,aACxD,QAAQ,cAAc,OAAO,KAAK,WAAW;CAE/C,MAAM,YAAY,2BAA2B,KAAK,mBAAmB;EACnE,MAAM;EACN,WAAW,OAAO;CACpB,CAAC;CACD,IAAI,CAAC,QAAQ,WAAW,KAAK,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ferPlan } from "./apply.js";
|
|
3
|
+
//#region src/transfer/history.d.ts
|
|
4
|
+
/** Capture post-placement state for redo; this does not authorize deleting shared resources. */
|
|
5
|
+
declare function captureTransferredState(graph: SceneGraph, original: GraphTransferPlan): GraphTransferPlan;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { captureTransferredState };
|
|
8
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","names":[],"sources":["../../src/transfer/history.ts"],"mappings":";;;;iBAKgB,wBACd,OAAO,YACP,UAAU,oBACT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cloneNodeProps } from "../copy.js";
|
|
2
|
+
//#region src/transfer/history.ts
|
|
3
|
+
/** Capture post-placement state for redo; this does not authorize deleting shared resources. */
|
|
4
|
+
function captureTransferredState(graph, original) {
|
|
5
|
+
const requireValue = (value, kind, id) => {
|
|
6
|
+
if (value === void 0) throw new Error(`Missing transferred ${kind} ${id}`);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
nodeIds: new Map(original.nodeIds),
|
|
11
|
+
rootIds: [...original.rootIds],
|
|
12
|
+
dependencyPageIds: [...original.dependencyPageIds],
|
|
13
|
+
nodes: original.nodes.map((entry) => {
|
|
14
|
+
const node = requireValue(graph.getNode(entry.id), "node", entry.id);
|
|
15
|
+
if (!node.parentId) throw new Error(`Missing transferred parent ${entry.id}`);
|
|
16
|
+
return {
|
|
17
|
+
id: node.id,
|
|
18
|
+
type: node.type,
|
|
19
|
+
parentId: node.parentId,
|
|
20
|
+
props: cloneNodeProps(node, null)
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
variables: original.variables.map((variable) => structuredClone(requireValue(graph.variables.get(variable.id), "variable", variable.id))),
|
|
24
|
+
collections: original.collections.map((collection) => structuredClone(requireValue(graph.variableCollections.get(collection.id), "collection", collection.id))),
|
|
25
|
+
activeModes: new Map(original.collections.map((collection) => [collection.id, requireValue(graph.activeMode.get(collection.id), "active mode", collection.id)])),
|
|
26
|
+
images: new Map([...original.images.keys()].map((hash) => [hash, requireValue(graph.images.get(hash), "image", hash).slice()]))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { captureTransferredState };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","names":[],"sources":["../../src/transfer/history.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\n\n/** Capture post-placement state for redo; this does not authorize deleting shared resources. */\nexport function captureTransferredState(\n graph: SceneGraph,\n original: GraphTransferPlan\n): GraphTransferPlan {\n const requireValue = <T>(value: T | undefined, kind: string, id: string): T => {\n if (value === undefined) throw new Error(`Missing transferred ${kind} ${id}`)\n return value\n }\n return {\n nodeIds: new Map(original.nodeIds),\n rootIds: [...original.rootIds],\n dependencyPageIds: [...original.dependencyPageIds],\n nodes: original.nodes.map((entry) => {\n const node = requireValue(graph.getNode(entry.id), 'node', entry.id)\n if (!node.parentId) throw new Error(`Missing transferred parent ${entry.id}`)\n return {\n id: node.id,\n type: node.type,\n parentId: node.parentId,\n props: cloneNodeProps(node, null)\n }\n }),\n variables: original.variables.map((variable) =>\n structuredClone(requireValue(graph.variables.get(variable.id), 'variable', variable.id))\n ),\n collections: original.collections.map((collection) =>\n structuredClone(\n requireValue(graph.variableCollections.get(collection.id), 'collection', collection.id)\n )\n ),\n activeModes: new Map(\n original.collections.map((collection) => [\n collection.id,\n requireValue(graph.activeMode.get(collection.id), 'active mode', collection.id)\n ])\n ),\n images: new Map(\n [...original.images.keys()].map((hash) => [\n hash,\n requireValue(graph.images.get(hash), 'image', hash).slice()\n ])\n )\n }\n}\n"],"mappings":";;;AAKA,SAAgB,wBACd,OACA,UACmB;CACnB,MAAM,gBAAmB,OAAsB,MAAc,OAAkB;EAC7E,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,uBAAuB,KAAK,GAAG,IAAI;EAC5E,OAAO;CACT;CACA,OAAO;EACL,SAAS,IAAI,IAAI,SAAS,OAAO;EACjC,SAAS,CAAC,GAAG,SAAS,OAAO;EAC7B,mBAAmB,CAAC,GAAG,SAAS,iBAAiB;EACjD,OAAO,SAAS,MAAM,KAAK,UAAU;GACnC,MAAM,OAAO,aAAa,MAAM,QAAQ,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE;GACnE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,8BAA8B,MAAM,IAAI;GAC5E,OAAO;IACL,IAAI,KAAK;IACT,MAAM,KAAK;IACX,UAAU,KAAK;IACf,OAAO,eAAe,MAAM,IAAI;GAClC;EACF,CAAC;EACD,WAAW,SAAS,UAAU,KAAK,aACjC,gBAAgB,aAAa,MAAM,UAAU,IAAI,SAAS,EAAE,GAAG,YAAY,SAAS,EAAE,CAAC,CACzF;EACA,aAAa,SAAS,YAAY,KAAK,eACrC,gBACE,aAAa,MAAM,oBAAoB,IAAI,WAAW,EAAE,GAAG,cAAc,WAAW,EAAE,CACxF,CACF;EACA,aAAa,IAAI,IACf,SAAS,YAAY,KAAK,eAAe,CACvC,WAAW,IACX,aAAa,MAAM,WAAW,IAAI,WAAW,EAAE,GAAG,eAAe,WAAW,EAAE,CAChF,CAAC,CACH;EACA,QAAQ,IAAI,IACV,CAAC,GAAG,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CACxC,MACA,aAAa,MAAM,OAAO,IAAI,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,MAAM,CAC5D,CAAC,CACH;CACF;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/transfer/identity.ts
|
|
2
|
+
function variableIdentityReferences(variables, collections) {
|
|
3
|
+
return {
|
|
4
|
+
variables: new Map(variables.map((variable) => [variable.id, variable.id])),
|
|
5
|
+
collections: new Map(collections.map((collection) => [collection.id, collection.id])),
|
|
6
|
+
modes: new Map(collections.flatMap((collection) => collection.modes.map((mode) => [mode.modeId, mode.modeId])))
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { variableIdentityReferences };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/transfer/identity.ts"],"sourcesContent":["import type { Variable, VariableCollection } from '../types'\n\nexport function variableIdentityReferences(\n variables: readonly Variable[],\n collections: readonly VariableCollection[]\n) {\n return {\n variables: new Map(variables.map((variable) => [variable.id, variable.id])),\n collections: new Map(collections.map((collection) => [collection.id, collection.id])),\n modes: new Map(\n collections.flatMap((collection) =>\n collection.modes.map((mode) => [mode.modeId, mode.modeId] as const)\n )\n )\n }\n}\n"],"mappings":";AAEA,SAAgB,2BACd,WACA,aACA;CACA,OAAO;EACL,WAAW,IAAI,IAAI,UAAU,KAAK,aAAa,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;EAC1E,aAAa,IAAI,IAAI,YAAY,KAAK,eAAe,CAAC,WAAW,IAAI,WAAW,EAAE,CAAC,CAAC;EACpF,OAAO,IAAI,IACT,YAAY,SAAS,eACnB,WAAW,MAAM,KAAK,SAAS,CAAC,KAAK,QAAQ,KAAK,MAAM,CAAU,CACpE,CACF;CACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GraphTransferInput, prepareGraphTransfer } from "./plan.js";
|
|
2
|
+
import { GraphTransferPlan, applyGraphTransfer } from "./apply.js";
|
|
3
|
+
import { removeGraphTransfer } from "./remove.js";
|
|
4
|
+
import { captureTransferredState } from "./history.js";
|
|
5
|
+
import { VariableTransferReferences, prepareVariableTransfer } from "./variables.js";
|
|
6
|
+
import { NodeTransferReferences, prepareNodeTransfer } from "./nodes.js";
|
|
7
|
+
import { remapCopiedReferences } from "./copied.js";
|
|
8
|
+
export { type GraphTransferInput, type GraphTransferPlan, type NodeTransferReferences, type VariableTransferReferences, applyGraphTransfer, captureTransferredState, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, removeGraphTransfer };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { remapCopiedReferences } from "./copied.js";
|
|
2
|
+
import { prepareNodeTransfer } from "./nodes.js";
|
|
3
|
+
import { removeGraphTransfer } from "./remove.js";
|
|
4
|
+
import { captureTransferredState } from "./history.js";
|
|
5
|
+
import { prepareVariableTransfer } from "./variables.js";
|
|
6
|
+
import { applyGraphTransfer } from "./apply.js";
|
|
7
|
+
import { prepareGraphTransfer } from "./plan.js";
|
|
8
|
+
export { applyGraphTransfer, captureTransferredState, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, removeGraphTransfer };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentPropertyType, SceneNode } from "../types.js";
|
|
2
|
+
import { VariableTransferReferences } from "./variables.js";
|
|
3
|
+
//#region src/transfer/nodes.d.ts
|
|
4
|
+
interface NodeTransferReferences extends VariableTransferReferences {
|
|
5
|
+
nodes: ReadonlyMap<string, string>;
|
|
6
|
+
styles: ReadonlyMap<string, string>;
|
|
7
|
+
properties: ReadonlyMap<string, string>;
|
|
8
|
+
propertyTypes: ReadonlyMap<string, ComponentPropertyType>;
|
|
9
|
+
}
|
|
10
|
+
/** Prepare runtime references without rewriting original format identities or ordinary text. */
|
|
11
|
+
declare function prepareNodeTransfer(source: SceneNode, refs: NodeTransferReferences): Partial<SceneNode>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { NodeTransferReferences, prepareNodeTransfer };
|
|
14
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/transfer/nodes.ts"],"mappings":";;;UAsCiB,+BAA+B;EAC9C,OAAO;EACP,QAAQ;EACR,YAAY;EACZ,eAAe,oBAAoB;;;iBAIrB,oBACd,QAAQ,WACR,MAAM,yBACL,QAAQ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { overriddenBindingField, remapInstanceOverrideState } from "../instances/overrides.js";
|
|
2
|
+
import { cloneNodeProps } from "../copy.js";
|
|
3
|
+
import { remapStyleRunReferences, styleRunReferences } from "../text/references.js";
|
|
4
|
+
import { referencedStyleIds } from "../shared-styles.js";
|
|
5
|
+
import { requireTransferReference } from "./references.js";
|
|
6
|
+
//#region src/transfer/nodes.ts
|
|
7
|
+
function semanticTransferReferences(node) {
|
|
8
|
+
const runs = styleRunReferences(node.styleRuns);
|
|
9
|
+
return [
|
|
10
|
+
...node.componentId ? [node.componentId] : [],
|
|
11
|
+
...Object.values(node.boundVariables),
|
|
12
|
+
...runs.variables,
|
|
13
|
+
...referencedStyleIds(node),
|
|
14
|
+
...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),
|
|
15
|
+
...node.componentPropertyReferences.map((reference) => reference.propertyId),
|
|
16
|
+
...node.componentPropertyDefinitions.flatMap((definition) => [definition.id, ...definition.type === "INSTANCE_SWAP" && definition.defaultValue ? [definition.defaultValue] : []]),
|
|
17
|
+
...node.instanceOverrides.descendants.keys(),
|
|
18
|
+
...[...node.instanceOverrides.self, ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])].flatMap(([field, value]) => typeof value === "string" && (field === "componentId" || field === "sourceComponentId" || overriddenBindingField(field) !== null) ? [value] : [])
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
/** Prepare runtime references without rewriting original format identities or ordinary text. */
|
|
22
|
+
function prepareNodeTransfer(source, refs) {
|
|
23
|
+
const node = (id) => requireTransferReference(refs.nodes, id, "node");
|
|
24
|
+
const variable = (id) => requireTransferReference(refs.variables, id, "variable");
|
|
25
|
+
const property = (id) => requireTransferReference(refs.properties, id, "property");
|
|
26
|
+
const style = (id) => requireTransferReference(refs.styles, id, "style");
|
|
27
|
+
const propertyValue = (id, value) => {
|
|
28
|
+
const type = refs.propertyTypes.get(id);
|
|
29
|
+
if (!type) throw new Error(`Missing property transfer type: ${id}`);
|
|
30
|
+
return type === "INSTANCE_SWAP" && value ? node(value) : value;
|
|
31
|
+
};
|
|
32
|
+
const values = (entries) => Object.fromEntries(Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)]));
|
|
33
|
+
const result = cloneNodeProps(source, null);
|
|
34
|
+
result.componentId = source.componentId ? node(source.componentId) : null;
|
|
35
|
+
result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {
|
|
36
|
+
node,
|
|
37
|
+
variable,
|
|
38
|
+
collection: (id) => refs.collections.get(id)
|
|
39
|
+
});
|
|
40
|
+
result.boundVariables = Object.fromEntries(Object.entries(source.boundVariables).map(([field, id]) => [field, variable(id)]));
|
|
41
|
+
result.variableModes = Object.fromEntries(Object.entries(source.variableModes).map(([collection, mode]) => [requireTransferReference(refs.collections, collection, "collection"), requireTransferReference(refs.modes, mode, "mode")]));
|
|
42
|
+
for (const field of [
|
|
43
|
+
"fillStyleId",
|
|
44
|
+
"strokeStyleId",
|
|
45
|
+
"textStyleId",
|
|
46
|
+
"effectStyleId",
|
|
47
|
+
"gridStyleId"
|
|
48
|
+
]) result[field] = source[field] ? style(source[field]) : null;
|
|
49
|
+
if (result.styleRuns) result.styleRuns = remapStyleRunReferences(result.styleRuns, {
|
|
50
|
+
variable,
|
|
51
|
+
style,
|
|
52
|
+
node: (id) => refs.nodes.get(id) ?? id
|
|
53
|
+
});
|
|
54
|
+
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
55
|
+
const endpoint = result[field];
|
|
56
|
+
if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId;
|
|
57
|
+
}
|
|
58
|
+
for (const region of result.vectorNetwork?.regions ?? []) if (region.fillStyleId) region.fillStyleId = style(region.fillStyleId);
|
|
59
|
+
result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({
|
|
60
|
+
...structuredClone(definition),
|
|
61
|
+
id: property(definition.id),
|
|
62
|
+
defaultValue: propertyValue(definition.id, definition.defaultValue)
|
|
63
|
+
}));
|
|
64
|
+
result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {
|
|
65
|
+
const propertyId = refs.properties.get(reference.propertyId);
|
|
66
|
+
return propertyId ? [{
|
|
67
|
+
...reference,
|
|
68
|
+
propertyId
|
|
69
|
+
}] : [];
|
|
70
|
+
});
|
|
71
|
+
result.componentPropertyAssignments = values(source.componentPropertyAssignments);
|
|
72
|
+
result.componentPropertyValues = { ...source.componentPropertyValues };
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { prepareNodeTransfer, semanticTransferReferences };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","names":["required"],"sources":["../../src/transfer/nodes.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport { overriddenBindingField, remapInstanceOverrideState } from '../instances/overrides'\nimport { referencedStyleIds } from '../shared-styles'\nimport { remapStyleRunReferences, styleRunReferences } from '../text/references'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { requireTransferReference as required } from './references'\nimport type { VariableTransferReferences } from './variables'\n\nexport function semanticTransferReferences(node: SceneNode): string[] {\n const runs = styleRunReferences(node.styleRuns)\n return [\n ...(node.componentId ? [node.componentId] : []),\n ...Object.values(node.boundVariables),\n ...runs.variables,\n ...referencedStyleIds(node),\n ...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),\n ...node.componentPropertyReferences.map((reference) => reference.propertyId),\n ...node.componentPropertyDefinitions.flatMap((definition) => [\n definition.id,\n ...(definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? [definition.defaultValue]\n : [])\n ]),\n ...node.instanceOverrides.descendants.keys(),\n ...[\n ...node.instanceOverrides.self,\n ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])\n ].flatMap(([field, value]) =>\n typeof value === 'string' &&\n (field === 'componentId' ||\n field === 'sourceComponentId' ||\n overriddenBindingField(field) !== null)\n ? [value]\n : []\n )\n ]\n}\n\nexport interface NodeTransferReferences extends VariableTransferReferences {\n nodes: ReadonlyMap<string, string>\n styles: ReadonlyMap<string, string>\n properties: ReadonlyMap<string, string>\n propertyTypes: ReadonlyMap<string, ComponentPropertyType>\n}\n\n/** Prepare runtime references without rewriting original format identities or ordinary text. */\nexport function prepareNodeTransfer(\n source: SceneNode,\n refs: NodeTransferReferences\n): Partial<SceneNode> {\n const node = (id: string) => required(refs.nodes, id, 'node')\n const variable = (id: string) => required(refs.variables, id, 'variable')\n const property = (id: string) => required(refs.properties, id, 'property')\n const style = (id: string) => required(refs.styles, id, 'style')\n const propertyValue = (id: string, value: string): string => {\n const type = refs.propertyTypes.get(id)\n if (!type) throw new Error(`Missing property transfer type: ${id}`)\n return type === 'INSTANCE_SWAP' && value ? node(value) : value\n }\n const values = (entries: Record<string, string>) =>\n Object.fromEntries(\n Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)])\n )\n const result = cloneNodeProps(source, null)\n result.componentId = source.componentId ? node(source.componentId) : null\n result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {\n node,\n variable,\n collection: (id) => refs.collections.get(id)\n })\n result.boundVariables = Object.fromEntries(\n Object.entries(source.boundVariables).map(([field, id]) => [field, variable(id)])\n )\n result.variableModes = Object.fromEntries(\n Object.entries(source.variableModes).map(([collection, mode]) => [\n required(refs.collections, collection, 'collection'),\n required(refs.modes, mode, 'mode')\n ])\n )\n for (const field of [\n 'fillStyleId',\n 'strokeStyleId',\n 'textStyleId',\n 'effectStyleId',\n 'gridStyleId'\n ] as const) {\n result[field] = source[field] ? style(source[field]) : null\n }\n if (result.styleRuns) {\n // A link to a layer the transfer leaves behind keeps naming it.\n result.styleRuns = remapStyleRunReferences(result.styleRuns, {\n variable,\n style,\n node: (id) => refs.nodes.get(id) ?? id\n })\n }\n // A connector keeps the layers it was attached to when they are left behind; the end becomes\n // free where nothing by that ID exists, as a pasted Figma connector does.\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = result[field]\n if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId\n }\n for (const region of result.vectorNetwork?.regions ?? [])\n if (region.fillStyleId) region.fillStyleId = style(region.fillStyleId)\n result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({\n ...structuredClone(definition),\n id: property(definition.id),\n defaultValue: propertyValue(definition.id, definition.defaultValue)\n }))\n // A reference to a property that neither the transfer nor its destination defines names nothing.\n result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {\n const propertyId = refs.properties.get(reference.propertyId)\n return propertyId ? [{ ...reference, propertyId }] : []\n })\n result.componentPropertyAssignments = values(source.componentPropertyAssignments)\n // Variant values are keyed by display names, unlike definition-ID assignments.\n result.componentPropertyValues = { ...source.componentPropertyValues }\n return result\n}\n"],"mappings":";;;;;;AAQA,SAAgB,2BAA2B,MAA2B;CACpE,MAAM,OAAO,mBAAmB,KAAK,SAAS;CAC9C,OAAO;EACL,GAAI,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC;EAC7C,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,GAAG,KAAK;EACR,GAAG,mBAAmB,IAAI;EAC1B,GAAG,OAAO,QAAQ,KAAK,4BAA4B,CAAC,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC;EACzF,GAAG,KAAK,4BAA4B,KAAK,cAAc,UAAU,UAAU;EAC3E,GAAG,KAAK,6BAA6B,SAAS,eAAe,CAC3D,WAAW,IACX,GAAI,WAAW,SAAS,mBAAmB,WAAW,eAClD,CAAC,WAAW,YA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+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { NodeType, SceneNode, Variable, VariableCollection } from "../types.js";
|
|
3
|
+
//#region src/transfer/plan.d.ts
|
|
4
|
+
interface GraphTransferInput {
|
|
5
|
+
source: SceneGraph;
|
|
6
|
+
rootIds: readonly string[];
|
|
7
|
+
dependencyPageIds: readonly string[];
|
|
8
|
+
target: SceneGraph;
|
|
9
|
+
parentId: string;
|
|
10
|
+
}
|
|
11
|
+
/** Preflight a self-contained fragment; allocation does not insert anything into the target. */
|
|
12
|
+
declare function prepareGraphTransfer(input: GraphTransferInput): {
|
|
13
|
+
activeModes: Map<string, string>;
|
|
14
|
+
images: Map<string, Uint8Array<ArrayBuffer>>;
|
|
15
|
+
variables: Variable[];
|
|
16
|
+
collections: VariableCollection[];
|
|
17
|
+
nodeIds: Map<string, string>;
|
|
18
|
+
rootIds: string[];
|
|
19
|
+
dependencyPageIds: string[];
|
|
20
|
+
nodes: {
|
|
21
|
+
id: string;
|
|
22
|
+
type: NodeType;
|
|
23
|
+
parentId: string;
|
|
24
|
+
props: Partial<SceneNode>;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { GraphTransferInput, prepareGraphTransfer };
|
|
29
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","names":[],"sources":["../../src/transfer/plan.ts"],"mappings":";;;UAMiB;EACf,QAAQ;EACR;EACA;EACA,QAAQ;EACR;;;iBAgBc,qBAAqB,OAAO"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { requireTransferReference } from "./references.js";
|
|
2
|
+
import { prepareNodeTransfer } from "./nodes.js";
|
|
3
|
+
import { prepareVariableTransfer } from "./variables.js";
|
|
4
|
+
//#region src/transfer/plan.ts
|
|
5
|
+
/** A transferred style's props under the ID the transfer gives it. */
|
|
6
|
+
function withStyleId(node, props, styles) {
|
|
7
|
+
const id = node.sharedStyleType !== null && node.source.id ? styles.get(node.source.id) : void 0;
|
|
8
|
+
if (!id || id === node.source.id) return props;
|
|
9
|
+
return {
|
|
10
|
+
...props,
|
|
11
|
+
source: {
|
|
12
|
+
...props.source ?? node.source,
|
|
13
|
+
id
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Preflight a self-contained fragment; allocation does not insert anything into the target. */
|
|
18
|
+
function prepareGraphTransfer(input) {
|
|
19
|
+
const { source, target, parentId } = input;
|
|
20
|
+
if (!target.getNode(parentId)) throw new Error(`Missing transfer parent ${parentId}`);
|
|
21
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
22
|
+
...target.nodes.keys(),
|
|
23
|
+
...target.variables.keys(),
|
|
24
|
+
...target.variableCollections.keys()
|
|
25
|
+
]);
|
|
26
|
+
for (const collection of target.variableCollections.values()) for (const mode of collection.modes) reserved.add(mode.modeId);
|
|
27
|
+
let sequence = 0;
|
|
28
|
+
const namespace = crypto.randomUUID();
|
|
29
|
+
const allocate = () => {
|
|
30
|
+
let id = `${namespace}:${sequence++}`;
|
|
31
|
+
while (reserved.has(id)) id = `${namespace}:${sequence++}`;
|
|
32
|
+
reserved.add(id);
|
|
33
|
+
return id;
|
|
34
|
+
};
|
|
35
|
+
const ordered = [];
|
|
36
|
+
const seen = /* @__PURE__ */ new Set();
|
|
37
|
+
const visit = (id) => {
|
|
38
|
+
if (seen.has(id)) throw new Error(`Repeated transfer node ${id}`);
|
|
39
|
+
const node = source.getNode(id);
|
|
40
|
+
if (!node) throw new Error(`Missing transfer source ${id}`);
|
|
41
|
+
seen.add(id);
|
|
42
|
+
ordered.push(node);
|
|
43
|
+
for (const child of node.childIds) visit(child);
|
|
44
|
+
};
|
|
45
|
+
for (const id of [...input.dependencyPageIds, ...input.rootIds]) visit(id);
|
|
46
|
+
const nodes = new Map(ordered.map((node) => [node.id, allocate()]));
|
|
47
|
+
const variables = new Map([...source.variables.keys()].map((id) => [id, allocate()]));
|
|
48
|
+
const collections = new Map([...source.variableCollections.keys()].map((id) => [id, allocate()]));
|
|
49
|
+
const modes = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const collection of source.variableCollections.values()) for (const mode of collection.modes) if (!modes.has(mode.modeId)) modes.set(mode.modeId, allocate());
|
|
51
|
+
const properties = /* @__PURE__ */ new Map();
|
|
52
|
+
const propertyTypes = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const node of ordered) for (const definition of node.componentPropertyDefinitions) {
|
|
54
|
+
if (propertyTypes.has(definition.id) && propertyTypes.get(definition.id) !== definition.type) throw new Error(`Conflicting property type ${definition.id}`);
|
|
55
|
+
propertyTypes.set(definition.id, definition.type);
|
|
56
|
+
if (!properties.has(definition.id)) properties.set(definition.id, allocate());
|
|
57
|
+
}
|
|
58
|
+
const targetStyleIds = /* @__PURE__ */ new Set();
|
|
59
|
+
for (const node of target.getAllNodes()) if (node.sharedStyleType !== null && node.source.id) targetStyleIds.add(node.source.id);
|
|
60
|
+
const styles = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const node of ordered) {
|
|
62
|
+
const id = node.source.id;
|
|
63
|
+
if (node.sharedStyleType === null || !id) continue;
|
|
64
|
+
styles.set(id, targetStyleIds.has(id) ? allocate() : id);
|
|
65
|
+
}
|
|
66
|
+
const references = {
|
|
67
|
+
nodes,
|
|
68
|
+
variables,
|
|
69
|
+
collections,
|
|
70
|
+
modes,
|
|
71
|
+
properties,
|
|
72
|
+
propertyTypes,
|
|
73
|
+
styles
|
|
74
|
+
};
|
|
75
|
+
const resources = prepareVariableTransfer([...source.variables.values()], [...source.variableCollections.values()], references);
|
|
76
|
+
const mapped = (id) => {
|
|
77
|
+
const value = nodes.get(id);
|
|
78
|
+
if (!value) throw new Error(`Missing transfer node mapping ${id}`);
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
const roots = new Set(input.rootIds);
|
|
82
|
+
const dependencies = new Set(input.dependencyPageIds);
|
|
83
|
+
const destinationParent = (node) => {
|
|
84
|
+
if (roots.has(node.id)) return parentId;
|
|
85
|
+
if (dependencies.has(node.id)) return target.rootId;
|
|
86
|
+
return mapped(node.parentId ?? "");
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
nodeIds: nodes,
|
|
90
|
+
rootIds: input.rootIds.map(mapped),
|
|
91
|
+
dependencyPageIds: input.dependencyPageIds.map(mapped),
|
|
92
|
+
nodes: ordered.map((node) => ({
|
|
93
|
+
id: mapped(node.id),
|
|
94
|
+
type: node.type,
|
|
95
|
+
parentId: destinationParent(node),
|
|
96
|
+
props: withStyleId(node, prepareNodeTransfer(node, references), styles)
|
|
97
|
+
})),
|
|
98
|
+
...resources,
|
|
99
|
+
activeModes: new Map([...source.activeMode].map(([collection, mode]) => [requireTransferReference(collections, collection, "collection"), requireTransferReference(modes, mode, "mode")])),
|
|
100
|
+
images: new Map([...source.images].map(([hash, bytes]) => [hash, bytes.slice()]))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { prepareGraphTransfer };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","names":[],"sources":["../../src/transfer/plan.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { prepareNodeTransfer } from './nodes'\nimport { requireTransferReference } from './references'\nimport { prepareVariableTransfer } from './variables'\n\nexport interface GraphTransferInput {\n source: SceneGraph\n rootIds: readonly string[]\n dependencyPageIds: readonly string[]\n target: SceneGraph\n parentId: string\n}\n\n/** A transferred style's props under the ID the transfer gives it. */\nfunction withStyleId(\n node: SceneNode,\n props: Partial<SceneNode>,\n styles: ReadonlyMap<string, string>\n): Partial<SceneNode> {\n const id =\n node.sharedStyleType !== null && node.source.id ? styles.get(node.source.id) : undefined\n if (!id || id === node.source.id) return props\n return { ...props, source: { ...(props.source ?? node.source), id } }\n}\n\n/** Preflight a self-contained fragment; allocation does not insert anything into the target. */\nexport function prepareGraphTransfer(input: GraphTransferInput) {\n const { source, target, parentId } = input\n if (!target.getNode(parentId)) throw new Error(`Missing transfer parent ${parentId}`)\n const reserved = new Set([\n ...target.nodes.keys(),\n ...target.variables.keys(),\n ...target.variableCollections.keys()\n ])\n for (const collection of target.variableCollections.values())\n for (const mode of collection.modes) reserved.add(mode.modeId)\n let sequence = 0\n const namespace = crypto.randomUUID()\n const allocate = (): string => {\n let id = `${namespace}:${sequence++}`\n while (reserved.has(id)) id = `${namespace}:${sequence++}`\n reserved.add(id)\n return id\n }\n const ordered: SceneNode[] = []\n const seen = new Set<string>()\n const visit = (id: string): void => {\n if (seen.has(id)) throw new Error(`Repeated transfer node ${id}`)\n const node = source.getNode(id)\n if (!node) throw new Error(`Missing transfer source ${id}`)\n seen.add(id)\n ordered.push(node)\n for (const child of node.childIds) visit(child)\n }\n for (const id of [...input.dependencyPageIds, ...input.rootIds]) visit(id)\n const nodes = new Map(ordered.map((node) => [node.id, allocate()]))\n const variables = new Map([...source.variables.keys()].map((id) => [id, allocate()]))\n const collections = new Map([...source.variableCollections.keys()].map((id) => [id, allocate()]))\n const modes = new Map<string, string>()\n for (const collection of source.variableCollections.values()) {\n for (const mode of collection.modes)\n if (!modes.has(mode.modeId)) modes.set(mode.modeId, allocate())\n }\n const properties = new Map<string, string>()\n const propertyTypes = new Map<string, ComponentPropertyType>()\n for (const node of ordered)\n for (const definition of node.componentPropertyDefinitions) {\n if (propertyTypes.has(definition.id) && propertyTypes.get(definition.id) !== definition.type)\n throw new Error(`Conflicting property type ${definition.id}`)\n propertyTypes.set(definition.id, definition.type)\n if (!properties.has(definition.id)) properties.set(definition.id, allocate())\n }\n // Layers name a style by the style's own ID, which a transferred style keeps unless the\n // target already holds another style by it: IDs read from Figma are only unique in one file.\n const targetStyleIds = new Set<string>()\n for (const node of target.getAllNodes())\n if (node.sharedStyleType !== null && node.source.id) targetStyleIds.add(node.source.id)\n const styles = new Map<string, string>()\n for (const node of ordered) {\n const id = node.source.id\n if (node.sharedStyleType === null || !id) continue\n styles.set(id, targetStyleIds.has(id) ? allocate() : id)\n }\n const references = {\n nodes,\n variables,\n collections,\n modes,\n properties,\n propertyTypes,\n styles\n }\n const resources = prepareVariableTransfer(\n [...source.variables.values()],\n [...source.variableCollections.values()],\n references\n )\n const mapped = (id: string): string => {\n const value = nodes.get(id)\n if (!value) throw new Error(`Missing transfer node mapping ${id}`)\n return value\n }\n const roots = new Set(input.rootIds)\n const dependencies = new Set(input.dependencyPageIds)\n const destinationParent = (node: SceneNode): string => {\n if (roots.has(node.id)) return parentId\n if (dependencies.has(node.id)) return target.rootId\n return mapped(node.parentId ?? '')\n }\n return {\n nodeIds: nodes,\n rootIds: input.rootIds.map(mapped),\n dependencyPageIds: input.dependencyPageIds.map(mapped),\n nodes: ordered.map((node) => ({\n id: mapped(node.id),\n type: node.type,\n parentId: destinationParent(node),\n props: withStyleId(node, prepareNodeTransfer(node, references), styles)\n })),\n ...resources,\n activeModes: new Map(\n [...source.activeMode].map(([collection, mode]) => [\n requireTransferReference(collections, collection, 'collection'),\n requireTransferReference(modes, mode, 'mode')\n ])\n ),\n images: new Map([...source.images].map(([hash, bytes]) => [hash, bytes.slice()]))\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,YACP,MACA,OACA,QACoB;CACpB,MAAM,KACJ,KAAK,oBAAoB,QAAQ,KAAK,OAAO,KAAK,OAAO,IAAI,KAAK,OAAO,EAAE,IAAI,KAAA;CACjF,IAAI,CAAC,MAAM,OAAO,KAAK,OAAO,IAAI,OAAO;CACzC,OAAO;EAAE,GAAG;EAAO,QAAQ;GAAE,GAAI,MAAM,UAAU,KAAK;GAAS;EAAG;CAAE;AACtE;;AAGA,SAAgB,qBAAqB,OAA2B;CAC9D,MAAM,EAAE,QAAQ,QAAQ,aAAa;CACrC,IAAI,CAAC,OAAO,QAAQ,QAAQ,GAAG,MAAM,IAAI,MAAM,2BAA2B,UAAU;CAC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iC,IAAI;EACjE,OAAO;CACT;CACA,MAAM,QAAQ,IAAI,IAAI,MAAM,OAAO;CACnC,MAAM,eAAe,IAAI,IAAI,MAAM,iBAAiB;CACpD,MAAM,qBAAqB,SAA4B;EACrD,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG,OAAO;EAC/B,IAAI,aAAa,IAAI,KAAK,EAAE,GAAG,OAAO,OAAO;EAC7C,OAAO,OAAO,KAAK,YAAY,EAAE;CACnC;CACA,OAAO;EACL,SAAS;EACT,SAAS,MAAM,QAAQ,IAAI,MAAM;EACjC,mBAAmB,MAAM,kBAAkB,IAAI,MAAM;EACrD,OAAO,QAAQ,KAAK,UAAU;GAC5B,IAAI,OAAO,KAAK,EAAE;GAClB,MAAM,KAAK;GACX,UAAU,kBAAkB,IAAI;GAChC,OAAO,YAAY,MAAM,oBAAoB,MAAM,UAAU,GAAG,MAAM;EACxE,EAAE;EACF,GAAG;EACH,aAAa,IAAI,IACf,CAAC,GAAG,OAAO,UAAU,CAAC,CAAC,KAAK,CAAC,YAAY,UAAU,CACjD,yBAAyB,aAAa,YAAY,YAAY,GAC9D,yBAAyB,OAAO,MAAM,MAAM,CAC9C,CAAC,CACH;EACA,QAAQ,IAAI,IAAI,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,MAAM,MAAM,CAAC,CAAC,CAAC;CAClF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/transfer/references.ts
|
|
2
|
+
function requireTransferReference(ids, id, kind) {
|
|
3
|
+
const value = ids.get(id);
|
|
4
|
+
if (!value) throw new Error(`Missing ${kind} transfer mapping: ${id}`);
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { requireTransferReference };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","names":[],"sources":["../../src/transfer/references.ts"],"sourcesContent":["export function requireTransferReference(\n ids: ReadonlyMap<string, string>,\n id: string,\n kind: string\n): string {\n const value = ids.get(id)\n if (!value) throw new Error(`Missing ${kind} transfer mapping: ${id}`)\n return value\n}\n"],"mappings":";AAAA,SAAgB,yBACd,KACA,IACA,MACQ;CACR,MAAM,QAAQ,IAAI,IAAI,EAAE;CACxB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,WAAW,KAAK,qBAAqB,IAAI;CACrE,OAAO;AACT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { GraphTransferPlan } from "./apply.js";
|
|
3
|
+
//#region src/transfer/remove.d.ts
|
|
4
|
+
/** Refuse to remove transferred content that has acquired external dependents. */
|
|
5
|
+
declare function removeGraphTransfer(graph: SceneGraph, plan: GraphTransferPlan): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { removeGraphTransfer };
|
|
8
|
+
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","names":[],"sources":["../../src/transfer/remove.ts"],"mappings":";;;;iBAKgB,oBAAoB,OAAO,YAAY,MAAM"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { semanticTransferReferences } from "./nodes.js";
|
|
2
|
+
//#region src/transfer/remove.ts
|
|
3
|
+
/** Refuse to remove transferred content that has acquired external dependents. */
|
|
4
|
+
function removeGraphTransfer(graph, plan) {
|
|
5
|
+
const nodes = new Set(plan.nodes.map((node) => node.id));
|
|
6
|
+
const variables = new Set(plan.variables.map((variable) => variable.id));
|
|
7
|
+
const collections = new Set(plan.collections.map((collection) => collection.id));
|
|
8
|
+
const referencesOwned = (value) => {
|
|
9
|
+
if (typeof value === "string") return nodes.has(value) || variables.has(value) || collections.has(value);
|
|
10
|
+
if (!value || typeof value !== "object" || ArrayBuffer.isView(value)) return false;
|
|
11
|
+
if (value instanceof Map) return [...value].some(([key, item]) => referencesOwned(key) || referencesOwned(item));
|
|
12
|
+
return Object.values(value).some(referencesOwned);
|
|
13
|
+
};
|
|
14
|
+
for (const node of graph.getAllNodes()) {
|
|
15
|
+
if (nodes.has(node.id)) {
|
|
16
|
+
if (node.childIds.some((id) => !nodes.has(id))) throw new Error("Transferred node has non-owned children");
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (semanticTransferReferences(node).some(referencesOwned)) throw new Error(`Transferred content is referenced by ${node.id}`);
|
|
20
|
+
}
|
|
21
|
+
for (const variable of graph.variables.values()) if (!variables.has(variable.id) && referencesOwned(variable.valuesByMode)) throw new Error("Transferred variable has external aliases");
|
|
22
|
+
graph.withBufferedEvents(() => {
|
|
23
|
+
for (const node of plan.nodes.toReversed()) graph.deleteNode(node.id);
|
|
24
|
+
for (const id of variables) graph.variables.delete(id);
|
|
25
|
+
for (const id of collections) {
|
|
26
|
+
graph.variableCollections.delete(id);
|
|
27
|
+
graph.activeMode.delete(id);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { removeGraphTransfer };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=remove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.js","names":[],"sources":["../../src/transfer/remove.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\nimport { semanticTransferReferences } from './nodes'\n\n/** Refuse to remove transferred content that has acquired external dependents. */\nexport function removeGraphTransfer(graph: SceneGraph, plan: GraphTransferPlan): void {\n const nodes = new Set(plan.nodes.map((node) => node.id))\n const variables = new Set(plan.variables.map((variable) => variable.id))\n const collections = new Set(plan.collections.map((collection) => collection.id))\n const referencesOwned = (value: unknown): boolean => {\n if (typeof value === 'string')\n return nodes.has(value) || variables.has(value) || collections.has(value)\n if (!value || typeof value !== 'object' || ArrayBuffer.isView(value)) return false\n if (value instanceof Map)\n return [...value].some(([key, item]) => referencesOwned(key) || referencesOwned(item))\n return Object.values(value).some(referencesOwned)\n }\n for (const node of graph.getAllNodes()) {\n if (nodes.has(node.id)) {\n if (node.childIds.some((id) => !nodes.has(id)))\n throw new Error('Transferred node has non-owned children')\n continue\n }\n if (semanticTransferReferences(node).some(referencesOwned))\n throw new Error(`Transferred content is referenced by ${node.id}`)\n }\n for (const variable of graph.variables.values()) {\n if (!variables.has(variable.id) && referencesOwned(variable.valuesByMode))\n throw new Error('Transferred variable has external aliases')\n }\n graph.withBufferedEvents(() => {\n for (const node of plan.nodes.toReversed()) graph.deleteNode(node.id)\n for (const id of variables) graph.variables.delete(id)\n for (const id of collections) {\n graph.variableCollections.delete(id)\n graph.activeMode.delete(id)\n }\n })\n}\n"],"mappings":";;;AAKA,SAAgB,oBAAoB,OAAmB,MAA+B;CACpF,MAAM,QAAQ,IAAI,IAAI,KAAK,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC;CACvD,MAAM,YAAY,IAAI,IAAI,KAAK,UAAU,KAAK,aAAa,SAAS,EAAE,CAAC;CACvE,MAAM,cAAc,IAAI,IAAI,KAAK,YAAY,KAAK,eAAe,WAAW,EAAE,CAAC;CAC/E,MAAM,mBAAmB,UAA4B;EACnD,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK;EAC1E,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO,KAAK,GAAG,OAAO;EAC7E,IAAI,iBAAiB,KACnB,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,gBAAgB,GAAG,KAAK,gBAAgB,IAAI,CAAC;EACvF,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK,eAAe;CAClD;CACA,KAAK,MAAM,QAAQ,MAAM,YAAY,GAAG;EACtC,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG;GACtB,IAA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