@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,180 @@
|
|
|
1
|
+
import { setInstanceOverride } from "../instances/overrides.js";
|
|
2
|
+
import { randomHex } from "../random.js";
|
|
3
|
+
import { findInstanceAncestor, instanceMainComponent } from "../instances/main-component.js";
|
|
4
|
+
import { walkInstanceSources } from "../instances/source-walk.js";
|
|
5
|
+
//#region src/components/properties.ts
|
|
6
|
+
function componentPropertyOwners(graph, instance) {
|
|
7
|
+
if (instance.type !== "INSTANCE") return [];
|
|
8
|
+
const component = instanceMainComponent(graph, instance);
|
|
9
|
+
if (!component) return [];
|
|
10
|
+
const parent = component.parentId ? graph.getNode(component.parentId) : null;
|
|
11
|
+
return parent?.type === "COMPONENT_SET" ? [parent, component] : [component];
|
|
12
|
+
}
|
|
13
|
+
function componentPropertyDefinitions(graph, instance) {
|
|
14
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const owner of componentPropertyOwners(graph, instance)) for (const definition of owner.componentPropertyDefinitions) if (!definitions.has(definition.id)) definitions.set(definition.id, definition);
|
|
16
|
+
return [...definitions.values()];
|
|
17
|
+
}
|
|
18
|
+
function resolveComponentPropertyValue(graph, value) {
|
|
19
|
+
const direct = graph.getNode(value);
|
|
20
|
+
if (direct?.type === "COMPONENT") return direct;
|
|
21
|
+
if (direct?.type === "COMPONENT_SET") {
|
|
22
|
+
const componentId = direct.childIds.find((id) => graph.getNode(id)?.type === "COMPONENT");
|
|
23
|
+
return componentId ? graph.getNode(componentId) ?? null : null;
|
|
24
|
+
}
|
|
25
|
+
for (const node of graph.getAllNodes()) if (node.type === "COMPONENT" && (node.componentKey === value || node.sourceLibraryKey === value || node.source.id === value)) return node;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function findComponentPropertyTarget(graph, instance, propertyId) {
|
|
29
|
+
return findComponentPropertyTargets(graph, instance, propertyId)[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
function findComponentPropertyTargets(graph, instance, propertyId) {
|
|
32
|
+
const targets = [];
|
|
33
|
+
walkInstanceSources(graph, instance, (source, target) => {
|
|
34
|
+
const reference = source.componentPropertyReferences.find((candidate) => candidate.propertyId === propertyId);
|
|
35
|
+
if (reference) targets.push({
|
|
36
|
+
node: target,
|
|
37
|
+
field: reference.field,
|
|
38
|
+
source
|
|
39
|
+
});
|
|
40
|
+
return true;
|
|
41
|
+
}, true);
|
|
42
|
+
return targets;
|
|
43
|
+
}
|
|
44
|
+
function applyTextProperty(graph, owner, targets, value) {
|
|
45
|
+
for (const item of targets) {
|
|
46
|
+
if (item.field !== "TEXT" || item.node.type !== "TEXT") continue;
|
|
47
|
+
graph.updateNode(item.node.id, { text: value });
|
|
48
|
+
if (findInstanceAncestor(graph, item.node.id)) setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "text", value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function applyBooleanProperty(graph, owner, targets, value) {
|
|
52
|
+
for (const item of targets) {
|
|
53
|
+
if (item.field !== "VISIBLE") continue;
|
|
54
|
+
const instance = findInstanceAncestor(graph, item.node.id);
|
|
55
|
+
graph.updateNode(item.node.id, { visible: value === "true" });
|
|
56
|
+
if (instance) setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "visible", value === "true");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function applyInstanceSwapProperty(graph, owner, targets, target) {
|
|
60
|
+
for (const item of targets) {
|
|
61
|
+
if (item.field !== "INSTANCE_SWAP" || item.node.type !== "INSTANCE") continue;
|
|
62
|
+
graph.swapInstanceComponent(item.node.id, target.id);
|
|
63
|
+
setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "name", target.name);
|
|
64
|
+
setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "componentId", target.id);
|
|
65
|
+
setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, "sourceComponentId", item.source.id);
|
|
66
|
+
graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function applyComponentPropertyValue(graph, instanceId, definition, value) {
|
|
70
|
+
const instance = graph.getNode(instanceId);
|
|
71
|
+
if (instance?.type !== "INSTANCE") return null;
|
|
72
|
+
if (definition.type === "VARIANT") return null;
|
|
73
|
+
const targets = findComponentPropertyTargets(graph, instance, definition.id);
|
|
74
|
+
const target = definition.type === "INSTANCE_SWAP" ? resolveComponentPropertyValue(graph, value) : null;
|
|
75
|
+
if (definition.type === "INSTANCE_SWAP" && !target) return null;
|
|
76
|
+
if (definition.type === "TEXT") applyTextProperty(graph, instance, targets, value);
|
|
77
|
+
else if (definition.type === "BOOLEAN") applyBooleanProperty(graph, instance, targets, value);
|
|
78
|
+
else if (target) applyInstanceSwapProperty(graph, instance, targets, target);
|
|
79
|
+
graph.updateNode(instance.id, { componentPropertyAssignments: {
|
|
80
|
+
...instance.componentPropertyAssignments,
|
|
81
|
+
[definition.id]: definition.type === "INSTANCE_SWAP" && target ? target.id : value
|
|
82
|
+
} });
|
|
83
|
+
return definition.type === "INSTANCE_SWAP" ? target : instance;
|
|
84
|
+
}
|
|
85
|
+
function reapplyComponentPropertyAssignments(graph, instanceId) {
|
|
86
|
+
const instance = graph.getNode(instanceId);
|
|
87
|
+
if (instance?.type !== "INSTANCE") return [];
|
|
88
|
+
const definitions = new Map(componentPropertyDefinitions(graph, instance).map((definition) => [definition.id, definition]));
|
|
89
|
+
const applied = [];
|
|
90
|
+
for (const [propertyId, value] of Object.entries(instance.componentPropertyAssignments)) {
|
|
91
|
+
const definition = definitions.get(propertyId);
|
|
92
|
+
if (definition && definition.type !== "VARIANT") {
|
|
93
|
+
applyComponentPropertyValue(graph, instanceId, definition, value);
|
|
94
|
+
applied.push(definition);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return applied;
|
|
98
|
+
}
|
|
99
|
+
const ASSIGNMENT_OVERRIDE_PREFIX = "componentPropertyAssignments/";
|
|
100
|
+
function assignmentOverrideField(propertyId) {
|
|
101
|
+
return `${ASSIGNMENT_OVERRIDE_PREFIX}${propertyId}`;
|
|
102
|
+
}
|
|
103
|
+
function overriddenAssignmentId(field) {
|
|
104
|
+
return field.startsWith(ASSIGNMENT_OVERRIDE_PREFIX) ? field.slice(29) : void 0;
|
|
105
|
+
}
|
|
106
|
+
function recordAssignmentOverride(graph, instanceId, propertyId) {
|
|
107
|
+
const instance = graph.getNode(instanceId);
|
|
108
|
+
const owner = instance?.parentId ? findInstanceAncestor(graph, instance.parentId) : void 0;
|
|
109
|
+
if (!instance || !owner) return;
|
|
110
|
+
setInstanceOverride(owner.instanceOverrides, owner.id, instance.id, assignmentOverrideField(propertyId), instance.componentPropertyAssignments[propertyId]);
|
|
111
|
+
graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides });
|
|
112
|
+
}
|
|
113
|
+
function componentSubtree(graph, componentId) {
|
|
114
|
+
const component = graph.getNode(componentId);
|
|
115
|
+
if (!component) return [];
|
|
116
|
+
const nodes = [component];
|
|
117
|
+
const visit = (node) => {
|
|
118
|
+
for (const child of graph.getChildren(node.id)) {
|
|
119
|
+
nodes.push(child);
|
|
120
|
+
visit(child);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
visit(component);
|
|
124
|
+
return nodes;
|
|
125
|
+
}
|
|
126
|
+
function componentInstances(graph, componentId) {
|
|
127
|
+
return [...graph.getAllNodes()].filter((node) => node.type === "INSTANCE" && node.componentId === componentId);
|
|
128
|
+
}
|
|
129
|
+
function removePropertyFromNode(graph, node, propertyId) {
|
|
130
|
+
if (node.componentPropertyReferences.some((reference) => reference.propertyId === propertyId)) graph.updateNode(node.id, { componentPropertyReferences: node.componentPropertyReferences.filter((reference) => reference.propertyId !== propertyId) });
|
|
131
|
+
if (node.type === "INSTANCE" && propertyId in node.componentPropertyAssignments) graph.updateNode(node.id, { componentPropertyAssignments: Object.fromEntries(Object.entries(node.componentPropertyAssignments).filter(([id]) => id !== propertyId)) });
|
|
132
|
+
}
|
|
133
|
+
function removeComponentProperty(graph, ownerId, propertyId) {
|
|
134
|
+
const owner = graph.getNode(ownerId);
|
|
135
|
+
if (!owner || owner.type !== "COMPONENT" && owner.type !== "COMPONENT_SET") return false;
|
|
136
|
+
graph.updateNode(owner.id, { componentPropertyDefinitions: owner.componentPropertyDefinitions.filter((definition) => definition.id !== propertyId) });
|
|
137
|
+
const nodes = [
|
|
138
|
+
...componentSubtree(graph, owner.id),
|
|
139
|
+
...componentInstances(graph, owner.id),
|
|
140
|
+
...owner.type === "COMPONENT_SET" ? owner.childIds.flatMap((id) => [...componentSubtree(graph, id), ...componentInstances(graph, id)]) : []
|
|
141
|
+
];
|
|
142
|
+
for (const node of nodes) removePropertyFromNode(graph, node, propertyId);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Moves the boolean, text, instance swap, and slot properties a set's variants define themselves
|
|
147
|
+
* onto the set, under their IDs, so the layers and instances naming them still do: a variant's
|
|
148
|
+
* properties are its set's, as Figma keeps them, and combining components moves theirs to the
|
|
149
|
+
* set (desktop 126). A property the set already has under that ID is not added again. Returns
|
|
150
|
+
* the IDs of the set and the variants it changed.
|
|
151
|
+
*/
|
|
152
|
+
function moveVariantPropertiesToSet(graph, setId) {
|
|
153
|
+
const set = graph.getNode(setId);
|
|
154
|
+
if (set?.type !== "COMPONENT_SET") return [];
|
|
155
|
+
const changed = [];
|
|
156
|
+
const known = new Set(set.componentPropertyDefinitions.map((definition) => definition.id));
|
|
157
|
+
const moved = [];
|
|
158
|
+
for (const variant of graph.getChildren(setId)) {
|
|
159
|
+
const own = variant.componentPropertyDefinitions.filter((definition) => definition.type !== "VARIANT");
|
|
160
|
+
if (variant.type !== "COMPONENT" || own.length === 0) continue;
|
|
161
|
+
for (const definition of own) {
|
|
162
|
+
if (known.has(definition.id)) continue;
|
|
163
|
+
known.add(definition.id);
|
|
164
|
+
moved.push(definition);
|
|
165
|
+
}
|
|
166
|
+
graph.updateNode(variant.id, { componentPropertyDefinitions: variant.componentPropertyDefinitions.filter((definition) => definition.type === "VARIANT") });
|
|
167
|
+
changed.push(variant.id);
|
|
168
|
+
}
|
|
169
|
+
if (moved.length === 0) return changed;
|
|
170
|
+
graph.updateNode(setId, { componentPropertyDefinitions: [...moved, ...set.componentPropertyDefinitions] });
|
|
171
|
+
return [setId, ...changed];
|
|
172
|
+
}
|
|
173
|
+
/** A new component property ID, in the `prop:` form the editor, plugin API, and design JSX share. */
|
|
174
|
+
function createComponentPropertyId() {
|
|
175
|
+
return `prop:${randomHex(8)}`;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { applyComponentPropertyValue, assignmentOverrideField, componentPropertyDefinitions, componentPropertyOwners, createComponentPropertyId, findComponentPropertyTarget, findComponentPropertyTargets, moveVariantPropertiesToSet, overriddenAssignmentId, reapplyComponentPropertyAssignments, recordAssignmentOverride, removeComponentProperty, resolveComponentPropertyValue };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","names":[],"sources":["../../src/components/properties.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport { findInstanceAncestor, instanceMainComponent } from '../instances/main-component'\nimport { setInstanceOverride } from '../instances/overrides'\nimport { walkInstanceSources } from '../instances/source-walk'\nimport { randomHex } from '../random'\nimport type {\n ComponentPropertyDefinition,\n ComponentPropertyReferenceField,\n SceneNode\n} from '../types'\n\nexport interface ComponentPropertyTarget {\n node: SceneNode\n field: ComponentPropertyReferenceField\n source: SceneNode\n}\n\nexport function componentPropertyOwners(graph: SceneGraph, instance: SceneNode): SceneNode[] {\n if (instance.type !== 'INSTANCE') return []\n const component = instanceMainComponent(graph, instance)\n if (!component) return []\n const parent = component.parentId ? graph.getNode(component.parentId) : null\n return parent?.type === 'COMPONENT_SET' ? [parent, component] : [component]\n}\n\nexport function componentPropertyDefinitions(\n graph: SceneGraph,\n instance: SceneNode\n): ComponentPropertyDefinition[] {\n const definitions = new Map<string, ComponentPropertyDefinition>()\n for (const owner of componentPropertyOwners(graph, instance)) {\n for (const definition of owner.componentPropertyDefinitions) {\n if (!definitions.has(definition.id)) definitions.set(definition.id, definition)\n }\n }\n return [...definitions.values()]\n}\n\nexport function resolveComponentPropertyValue(graph: SceneGraph, value: string): SceneNode | null {\n const direct = graph.getNode(value)\n if (direct?.type === 'COMPONENT') return direct\n if (direct?.type === 'COMPONENT_SET') {\n const componentId = direct.childIds.find((id) => graph.getNode(id)?.type === 'COMPONENT')\n return componentId ? (graph.getNode(componentId) ?? null) : null\n }\n for (const node of graph.getAllNodes()) {\n if (\n node.type === 'COMPONENT' &&\n (node.componentKey === value || node.sourceLibraryKey === value || node.source.id === value)\n ) {\n return node\n }\n }\n return null\n}\n\nexport function findComponentPropertyTarget(\n graph: SceneGraph,\n instance: SceneNode,\n propertyId: string\n): ComponentPropertyTarget | null {\n return findComponentPropertyTargets(graph, instance, propertyId)[0] ?? null\n}\n\nexport function findComponentPropertyTargets(\n graph: SceneGraph,\n instance: SceneNode,\n propertyId: string\n): ComponentPropertyTarget[] {\n const targets: ComponentPropertyTarget[] = []\n walkInstanceSources(\n graph,\n instance,\n (source, target) => {\n const reference = source.componentPropertyReferences.find(\n (candidate) => candidate.propertyId === propertyId\n )\n if (reference) targets.push({ node: target, field: reference.field, source })\n return true\n },\n true\n )\n return targets\n}\n\nfunction applyTextProperty(\n graph: SceneGraph,\n owner: SceneNode,\n targets: ComponentPropertyTarget[],\n value: string\n): void {\n for (const item of targets) {\n if (item.field !== 'TEXT' || item.node.type !== 'TEXT') continue\n graph.updateNode(item.node.id, { text: value })\n if (findInstanceAncestor(graph, item.node.id)) {\n setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, 'text', value)\n }\n }\n}\n\nfunction applyBooleanProperty(\n graph: SceneGraph,\n owner: SceneNode,\n targets: ComponentPropertyTarget[],\n value: string\n): void {\n for (const item of targets) {\n if (item.field !== 'VISIBLE') continue\n const instance = findInstanceAncestor(graph, item.node.id)\n graph.updateNode(item.node.id, { visible: value === 'true' })\n if (instance) {\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n item.node.id,\n 'visible',\n value === 'true'\n )\n }\n }\n}\n\nfunction applyInstanceSwapProperty(\n graph: SceneGraph,\n owner: SceneNode,\n targets: ComponentPropertyTarget[],\n target: SceneNode\n): void {\n for (const item of targets) {\n if (item.field !== 'INSTANCE_SWAP' || item.node.type !== 'INSTANCE') continue\n graph.swapInstanceComponent(item.node.id, target.id)\n setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, 'name', target.name)\n setInstanceOverride(owner.instanceOverrides, owner.id, item.node.id, 'componentId', target.id)\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n item.node.id,\n 'sourceComponentId',\n item.source.id\n )\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n }\n}\n\nexport function applyComponentPropertyValue(\n graph: SceneGraph,\n instanceId: string,\n definition: ComponentPropertyDefinition,\n value: string\n): SceneNode | null {\n const instance = graph.getNode(instanceId)\n if (instance?.type !== 'INSTANCE') return null\n if (definition.type === 'VARIANT') return null\n const targets = findComponentPropertyTargets(graph, instance, definition.id)\n const target =\n definition.type === 'INSTANCE_SWAP' ? resolveComponentPropertyValue(graph, value) : null\n if (definition.type === 'INSTANCE_SWAP' && !target) return null\n if (definition.type === 'TEXT') {\n applyTextProperty(graph, instance, targets, value)\n } else if (definition.type === 'BOOLEAN') {\n applyBooleanProperty(graph, instance, targets, value)\n } else if (target) {\n applyInstanceSwapProperty(graph, instance, targets, target)\n }\n graph.updateNode(instance.id, {\n componentPropertyAssignments: {\n ...instance.componentPropertyAssignments,\n [definition.id]: definition.type === 'INSTANCE_SWAP' && target ? target.id : value\n }\n })\n return definition.type === 'INSTANCE_SWAP' ? target : instance\n}\n\nexport function reapplyComponentPropertyAssignments(\n graph: SceneGraph,\n instanceId: string\n): ComponentPropertyDefinition[] {\n const instance = graph.getNode(instanceId)\n if (instance?.type !== 'INSTANCE') {\n return []\n }\n const definitions = new Map(\n componentPropertyDefinitions(graph, instance).map((definition) => [definition.id, definition])\n )\n const applied: ComponentPropertyDefinition[] = []\n for (const [propertyId, value] of Object.entries(instance.componentPropertyAssignments)) {\n const definition = definitions.get(propertyId)\n if (definition && definition.type !== 'VARIANT') {\n applyComponentPropertyValue(graph, instanceId, definition, value)\n applied.push(definition)\n }\n }\n return applied\n}\n\nconst ASSIGNMENT_OVERRIDE_PREFIX = 'componentPropertyAssignments/'\n\nexport function assignmentOverrideField(propertyId: string): string {\n return `${ASSIGNMENT_OVERRIDE_PREFIX}${propertyId}`\n}\n\nexport function overriddenAssignmentId(field: string): string | undefined {\n return field.startsWith(ASSIGNMENT_OVERRIDE_PREFIX)\n ? field.slice(ASSIGNMENT_OVERRIDE_PREFIX.length)\n : undefined\n}\n\nexport function recordAssignmentOverride(\n graph: SceneGraph,\n instanceId: string,\n propertyId: string\n): void {\n const instance = graph.getNode(instanceId)\n const owner = instance?.parentId ? findInstanceAncestor(graph, instance.parentId) : undefined\n if (!instance || !owner) {\n return\n }\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n instance.id,\n assignmentOverrideField(propertyId),\n instance.componentPropertyAssignments[propertyId]\n )\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n}\n\nfunction componentSubtree(graph: SceneGraph, componentId: string): SceneNode[] {\n const component = graph.getNode(componentId)\n if (!component) return []\n const nodes = [component]\n const visit = (node: SceneNode): void => {\n for (const child of graph.getChildren(node.id)) {\n nodes.push(child)\n visit(child)\n }\n }\n visit(component)\n return nodes\n}\n\nfunction componentInstances(graph: SceneGraph, componentId: string): SceneNode[] {\n return [...graph.getAllNodes()].filter(\n (node) => node.type === 'INSTANCE' && node.componentId === componentId\n )\n}\n\nfunction removePropertyFromNode(graph: SceneGraph, node: SceneNode, propertyId: string): void {\n if (node.componentPropertyReferences.some((reference) => reference.propertyId === propertyId)) {\n graph.updateNode(node.id, {\n componentPropertyReferences: node.componentPropertyReferences.filter(\n (reference) => reference.propertyId !== propertyId\n )\n })\n }\n if (node.type === 'INSTANCE' && propertyId in node.componentPropertyAssignments) {\n graph.updateNode(node.id, {\n componentPropertyAssignments: Object.fromEntries(\n Object.entries(node.componentPropertyAssignments).filter(([id]) => id !== propertyId)\n )\n })\n }\n}\n\nexport function removeComponentProperty(\n graph: SceneGraph,\n ownerId: string,\n propertyId: string\n): boolean {\n const owner = graph.getNode(ownerId)\n if (!owner || (owner.type !== 'COMPONENT' && owner.type !== 'COMPONENT_SET')) return false\n graph.updateNode(owner.id, {\n componentPropertyDefinitions: owner.componentPropertyDefinitions.filter(\n (definition) => definition.id !== propertyId\n )\n })\n const nodes = [\n ...componentSubtree(graph, owner.id),\n ...componentInstances(graph, owner.id),\n ...(owner.type === 'COMPONENT_SET'\n ? owner.childIds.flatMap((id) => [\n ...componentSubtree(graph, id),\n ...componentInstances(graph, id)\n ])\n : [])\n ]\n for (const node of nodes) removePropertyFromNode(graph, node, propertyId)\n return true\n}\n\n/**\n * Moves the boolean, text, instance swap, and slot properties a set's variants define themselves\n * onto the set, under their IDs, so the layers and instances naming them still do: a variant's\n * properties are its set's, as Figma keeps them, and combining components moves theirs to the\n * set (desktop 126). A property the set already has under that ID is not added again. Returns\n * the IDs of the set and the variants it changed.\n */\nexport function moveVariantPropertiesToSet(graph: SceneGraph, setId: string): string[] {\n const set = graph.getNode(setId)\n if (set?.type !== 'COMPONENT_SET') return []\n const changed: string[] = []\n const known = new Set(set.componentPropertyDefinitions.map((definition) => definition.id))\n const moved: ComponentPropertyDefinition[] = []\n for (const variant of graph.getChildren(setId)) {\n const own = variant.componentPropertyDefinitions.filter(\n (definition) => definition.type !== 'VARIANT'\n )\n if (variant.type !== 'COMPONENT' || own.length === 0) continue\n for (const definition of own) {\n if (known.has(definition.id)) continue\n known.add(definition.id)\n moved.push(definition)\n }\n graph.updateNode(variant.id, {\n componentPropertyDefinitions: variant.componentPropertyDefinitions.filter(\n (definition) => definition.type === 'VARIANT'\n )\n })\n changed.push(variant.id)\n }\n if (moved.length === 0) return changed\n graph.updateNode(setId, {\n componentPropertyDefinitions: [...moved, ...set.componentPropertyDefinitions]\n })\n return [setId, ...changed]\n}\n\n/** A new component property ID, in the `prop:` form the editor, plugin API, and design JSX share. */\nexport function createComponentPropertyId(): string {\n return `prop:${randomHex(8)}`\n}\n"],"mappings":";;;;;AAiBA,SAAgB,wBAAwB,OAAmB,UAAkC;CAC3F,IAAI,SAAS,SAAS,YAAY,OAAO,CAAC;CAC1C,MAAM,YAAY,sBAAsB,OAAO,QAAQ;CACvD,IAAI,CAAC,WAAW,OAAO,CAAC;CACxB,MAAM,SAAS,UAAU,WAAW,MAAM,QAAQ,UAAU,QAAQ,IAAI;CACxE,OAAO,QAAQ,SAAS,kBAAkB,CAAC,QAAQ,SAAS,IAAI,CAAC,SAAS;AAC5E;AAEA,SAAgB,6BACd,OACA,UAC+B;CAC/B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,QAAQ,UAAU,CAAC;AAC5B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { ComponentPropertyDefinition, SceneNode } from "../types.js";
|
|
3
|
+
//#region src/components/variants.d.ts
|
|
4
|
+
/** Variants in reading order on the canvas: top to bottom, then left to right, then by name. */
|
|
5
|
+
declare function compareCanvasPosition(a: SceneNode, b: SceneNode): number;
|
|
6
|
+
/**
|
|
7
|
+
* A component set's default variant, the one an instance starts as: the first in reading order,
|
|
8
|
+
* and the first in layer order of those at the same place (measured in Figma desktop 126).
|
|
9
|
+
*/
|
|
10
|
+
declare function defaultVariant(graph: SceneGraph, set: SceneNode): SceneNode | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The value a variant property starts at: the default variant's, as Figma reads it whatever
|
|
13
|
+
* default the document records, and follows when another variant moves to the top left. The
|
|
14
|
+
* recorded default stands only while the default variant has no value for the property.
|
|
15
|
+
*/
|
|
16
|
+
declare function variantDefaultValue(graph: SceneGraph, set: SceneNode, property: {
|
|
17
|
+
name: string;
|
|
18
|
+
defaultValue: string;
|
|
19
|
+
}): string;
|
|
20
|
+
/**
|
|
21
|
+
* A variant property's values: the ones the document records, then any its variants use that it
|
|
22
|
+
* does not, since older documents record none and a set's page may have loaded only some
|
|
23
|
+
* variants.
|
|
24
|
+
*/
|
|
25
|
+
declare function variantOptions(graph: SceneGraph, set: SceneNode, property: {
|
|
26
|
+
name: string;
|
|
27
|
+
variantOptions?: string[];
|
|
28
|
+
}): string[];
|
|
29
|
+
/** A set's definition with a variant property's values and default filled in from its variants. */
|
|
30
|
+
declare function resolvedVariantDefinition(graph: SceneGraph, set: SceneNode, definition: ComponentPropertyDefinition): ComponentPropertyDefinition;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { compareCanvasPosition, defaultVariant, resolvedVariantDefinition, variantDefaultValue, variantOptions };
|
|
33
|
+
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.d.ts","names":[],"sources":["../../src/components/variants.ts"],"mappings":";;;;iBAMgB,sBAAsB,GAAG,WAAW,GAAG;;;;;iBAiBvC,eAAe,OAAO,YAAY,KAAK,YAAY;;;;;;iBAcnD,oBACd,OAAO,YACP,KAAK,WACL;EAAY;EAAc;;;;;;;iBAWZ,eACd,OAAO,YACP,KAAK,WACL;EAAY;EAAc;;;iBAWZ,0BACd,OAAO,YACP,KAAK,WACL,YAAY,8BACX"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { compact, uniq } from "es-toolkit/array";
|
|
2
|
+
//#region src/components/variants.ts
|
|
3
|
+
/** Variants in reading order on the canvas: top to bottom, then left to right, then by name. */
|
|
4
|
+
function compareCanvasPosition(a, b) {
|
|
5
|
+
return a.y - b.y || a.x - b.x || a.name.localeCompare(b.name);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether `a` comes before `b` reading the set as Figma does: variants whose rows overlap, edges
|
|
9
|
+
* touching included, read left to right, and others top to bottom.
|
|
10
|
+
*/
|
|
11
|
+
function readsBefore(a, b) {
|
|
12
|
+
return a.y <= b.y + b.height && b.y <= a.y + a.height ? a.x < b.x || a.x === b.x && a.y < b.y : a.y < b.y;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A component set's default variant, the one an instance starts as: the first in reading order,
|
|
16
|
+
* and the first in layer order of those at the same place (measured in Figma desktop 126).
|
|
17
|
+
*/
|
|
18
|
+
function defaultVariant(graph, set) {
|
|
19
|
+
let first;
|
|
20
|
+
for (const child of graph.getChildren(set.id)) {
|
|
21
|
+
if (child.type !== "COMPONENT") continue;
|
|
22
|
+
if (!first || readsBefore(child, first)) first = child;
|
|
23
|
+
}
|
|
24
|
+
return first;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The value a variant property starts at: the default variant's, as Figma reads it whatever
|
|
28
|
+
* default the document records, and follows when another variant moves to the top left. The
|
|
29
|
+
* recorded default stands only while the default variant has no value for the property.
|
|
30
|
+
*/
|
|
31
|
+
function variantDefaultValue(graph, set, property) {
|
|
32
|
+
return defaultVariant(graph, set)?.componentPropertyValues[property.name] || property.defaultValue;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A variant property's values: the ones the document records, then any its variants use that it
|
|
36
|
+
* does not, since older documents record none and a set's page may have loaded only some
|
|
37
|
+
* variants.
|
|
38
|
+
*/
|
|
39
|
+
function variantOptions(graph, set, property) {
|
|
40
|
+
const used = graph.getChildren(set.id).map((child) => child.type === "COMPONENT" ? child.componentPropertyValues[property.name] : "");
|
|
41
|
+
return compact(uniq([...property.variantOptions ?? [], ...used]));
|
|
42
|
+
}
|
|
43
|
+
/** A set's definition with a variant property's values and default filled in from its variants. */
|
|
44
|
+
function resolvedVariantDefinition(graph, set, definition) {
|
|
45
|
+
if (definition.type !== "VARIANT") return definition;
|
|
46
|
+
const options = {
|
|
47
|
+
...definition,
|
|
48
|
+
variantOptions: variantOptions(graph, set, definition)
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
...options,
|
|
52
|
+
defaultValue: variantDefaultValue(graph, set, options)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { compareCanvasPosition, defaultVariant, resolvedVariantDefinition, variantDefaultValue, variantOptions };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.js","names":[],"sources":["../../src/components/variants.ts"],"sourcesContent":["import { compact, uniq } from 'es-toolkit/array'\n\nimport type { SceneGraph } from '../graph'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\n\n/** Variants in reading order on the canvas: top to bottom, then left to right, then by name. */\nexport function compareCanvasPosition(a: SceneNode, b: SceneNode): number {\n return a.y - b.y || a.x - b.x || a.name.localeCompare(b.name)\n}\n\n/**\n * Whether `a` comes before `b` reading the set as Figma does: variants whose rows overlap, edges\n * touching included, read left to right, and others top to bottom.\n */\nfunction readsBefore(a: SceneNode, b: SceneNode): boolean {\n const sameRow = a.y <= b.y + b.height && b.y <= a.y + a.height\n return sameRow ? a.x < b.x || (a.x === b.x && a.y < b.y) : a.y < b.y\n}\n\n/**\n * A component set's default variant, the one an instance starts as: the first in reading order,\n * and the first in layer order of those at the same place (measured in Figma desktop 126).\n */\nexport function defaultVariant(graph: SceneGraph, set: SceneNode): SceneNode | undefined {\n let first: SceneNode | undefined\n for (const child of graph.getChildren(set.id)) {\n if (child.type !== 'COMPONENT') continue\n if (!first || readsBefore(child, first)) first = child\n }\n return first\n}\n\n/**\n * The value a variant property starts at: the default variant's, as Figma reads it whatever\n * default the document records, and follows when another variant moves to the top left. The\n * recorded default stands only while the default variant has no value for the property.\n */\nexport function variantDefaultValue(\n graph: SceneGraph,\n set: SceneNode,\n property: { name: string; defaultValue: string }\n): string {\n const value = defaultVariant(graph, set)?.componentPropertyValues[property.name]\n return value || property.defaultValue\n}\n\n/**\n * A variant property's values: the ones the document records, then any its variants use that it\n * does not, since older documents record none and a set's page may have loaded only some\n * variants.\n */\nexport function variantOptions(\n graph: SceneGraph,\n set: SceneNode,\n property: { name: string; variantOptions?: string[] }\n): string[] {\n const used = graph\n .getChildren(set.id)\n .map((child) =>\n child.type === 'COMPONENT' ? child.componentPropertyValues[property.name] : ''\n )\n return compact(uniq([...(property.variantOptions ?? []), ...used]))\n}\n\n/** A set's definition with a variant property's values and default filled in from its variants. */\nexport function resolvedVariantDefinition(\n graph: SceneGraph,\n set: SceneNode,\n definition: ComponentPropertyDefinition\n): ComponentPropertyDefinition {\n if (definition.type !== 'VARIANT') return definition\n const options = { ...definition, variantOptions: variantOptions(graph, set, definition) }\n return { ...options, defaultValue: variantDefaultValue(graph, set, options) }\n}\n"],"mappings":";;;AAMA,SAAgB,sBAAsB,GAAc,GAAsB;CACxE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,cAAc,EAAE,IAAI;AAC9D;;;;;AAMA,SAAS,YAAY,GAAc,GAAuB;CAExD,OADgB,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,SACvC,EAAE,IAAI,EAAE,KAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAK,EAAE,IAAI,EAAE;AACrE;;;;;AAMA,SAAgB,eAAe,OAAmB,KAAuC;CACvF,IAAI;CACJ,KAAK,MAAM,SAAS,MAAM,YAAY,IAAI,EAAE,GAAG;EAC7C,IAAI,MAAM,SAAS,aAAa;EAChC,IAAI,CAAC,SAAS,YAAY,OAAO,KAAK,GAAG,QAAQ;CACnD;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,oBACd,OACA,KACA,UACQ;CAER,OADc,eAAe,OAAO,GAAG,CAAC,EAAE,wBAAwB,SAAS,SAC3D,SAAS;AAC3B;;;;;;AAOA,SAAgB,eACd,OACA,KACA,UACU;CACV,MAAM,OAAO,MACV,YAAY,IAAI,EAAE,CAAC,CACnB,KAAK,UACJ,MAAM,SAAS,cAAc,MAAM,wBAAwB,SAAS,QAAQ,EAC9E;CACF,OAAO,QAAQ,KAAK,CAAC,GAAI,SAAS,kBAAkB,CAAC,GAAI,GAAG,IAAI,CAAC,CAAC;AACpE;;AAGA,SAAgB,0BACd,OACA,KACA,YAC6B;CAC7B,IAAI,WAAW,SAAS,WAAW,OAAO;CAC1C,MAAM,UAAU;EAAE,GAAG;EAAY,gBAAgB,eAAe,OAAO,KAAK,UAAU;CAAE;CACxF,OAAO;EAAE,GAAG;EAAS,cAAc,oBAAoB,OAAO,KAAK,OAAO;CAAE;AAC9E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Vector } from "../primitives/index.js";
|
|
2
|
+
import { ConnectorControlPoint } from "../types.js";
|
|
3
|
+
import { ConnectorPiece } from "./pieces.js";
|
|
4
|
+
import { ConnectorRouteEnd, ConnectorSide } from "./sides.js";
|
|
5
|
+
//#region src/connectors/controls.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The control points an elbow keeps for its route as drawn: one for each segment between its
|
|
8
|
+
* first and its last, at the segment's midpoint, as FigJam records them after an edit.
|
|
9
|
+
*/
|
|
10
|
+
declare function elbowControlPoints(pieces: ConnectorPiece[]): ConnectorControlPoint[];
|
|
11
|
+
/**
|
|
12
|
+
* Where an elbow's ends turn when its first or last segment is dragged: a stub's length out of
|
|
13
|
+
* each layer, or at a free end's point.
|
|
14
|
+
*/
|
|
15
|
+
declare function elbowJoints(start: ConnectorRouteEnd, end: ConnectorRouteEnd, [startSide, endSide]: [ConnectorSide, ConnectorSide]): [Vector, Vector];
|
|
16
|
+
/**
|
|
17
|
+
* The control points an elbow takes when its segment `index` is dragged across to `offset`: an x
|
|
18
|
+
* for a vertical segment, a y for a horizontal one. A segment between others moves alone. Its
|
|
19
|
+
* first or last segment turns at its end's joint, by a new segment across, and then runs at
|
|
20
|
+
* `offset`, as FigJam splits one.
|
|
21
|
+
*/
|
|
22
|
+
declare function dragElbowSegment(pieces: ConnectorPiece[], [startJoint, endJoint]: [Vector, Vector], index: number, offset: number): ConnectorControlPoint[];
|
|
23
|
+
/** A curve's control points as drawn: where its handles reach. */
|
|
24
|
+
declare function curveControlPoints(piece: ConnectorPiece): [Vector, Vector];
|
|
25
|
+
/** The point midway along a curve, where its handle sits. */
|
|
26
|
+
declare function curveMidpoint(piece: ConnectorPiece): Vector;
|
|
27
|
+
/**
|
|
28
|
+
* The control points a curve takes when the point midway along it is dragged by `delta`: both
|
|
29
|
+
* move by 4/3 of it, which moves the midpoint by exactly `delta`.
|
|
30
|
+
*/
|
|
31
|
+
declare function dragCurve(handles: [Vector, Vector], delta: Vector): [Vector, Vector];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { curveControlPoints, curveMidpoint, dragCurve, dragElbowSegment, elbowControlPoints, elbowJoints };
|
|
34
|
+
//# sourceMappingURL=controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.d.ts","names":[],"sources":["../../src/connectors/controls.ts"],"mappings":";;;;;;;;;iBAkJgB,mBAAmB,QAAQ,mBAAmB;;;;;iBAiB9C,YACd,OAAO,mBACP,KAAK,oBACJ,WAAW,WAAW,eAAe,kBACpC,QAAQ;;;;;;;iBAUI,iBACd,QAAQ,mBACP,YAAY,YAAY,QAAQ,SACjC,eACA,iBACC;;iBAwBa,mBAAmB,OAAO,kBAAkB,QAAQ;;iBAQpD,cAAc,OAAO,iBAAiB;;;;;iBAQtC,UAAU,UAAU,QAAQ,SAAS,OAAO,UAAU,QAAQ"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { EPSILON, along, pointAt, straightPieces } from "./pieces.js";
|
|
2
|
+
import { OUTWARD, attachment } from "./sides.js";
|
|
3
|
+
import { simplify } from "./elbow.js";
|
|
4
|
+
//#region src/connectors/controls.ts
|
|
5
|
+
function directionOf(side) {
|
|
6
|
+
return side === "LEFT" || side === "RIGHT" ? "HORIZONTAL" : "VERTICAL";
|
|
7
|
+
}
|
|
8
|
+
function routeSide(end, side) {
|
|
9
|
+
const at = attachment(end, side);
|
|
10
|
+
return {
|
|
11
|
+
at,
|
|
12
|
+
direction: directionOf(side),
|
|
13
|
+
joint: end.box ? along(at, OUTWARD[side], 48) : at
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** The coordinate a control line fixes: x for a vertical segment, y for a horizontal one. */
|
|
17
|
+
function lineOf(point) {
|
|
18
|
+
return point.direction === "VERTICAL" ? point.position.x : point.position.y;
|
|
19
|
+
}
|
|
20
|
+
/** Where a run along `direction` through `from` meets the perpendicular line `to`. */
|
|
21
|
+
function meet(from, direction, to) {
|
|
22
|
+
return direction === "HORIZONTAL" ? {
|
|
23
|
+
x: to,
|
|
24
|
+
y: from.y
|
|
25
|
+
} : {
|
|
26
|
+
x: from.x,
|
|
27
|
+
y: to
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Moves an end along its segment by its gap, towards the next point, unless the segment is no
|
|
32
|
+
* longer than the gap.
|
|
33
|
+
*/
|
|
34
|
+
function inset(point, toward, gap) {
|
|
35
|
+
return Math.hypot(toward.x - point.x, toward.y - point.y) <= gap ? point : towards(point, toward, gap);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An elbow through its control lines: from the start's side to each line in turn, then to the end's
|
|
39
|
+
* side. A line parallel to the run before it is reached by a segment across, at the stub of the
|
|
40
|
+
* end it follows or leads to, or midway between two control lines. Points in line merge, so ends
|
|
41
|
+
* that face each other in line draw straight. Each end then stops short by its gap along its own
|
|
42
|
+
* segment, which may point back into its layer.
|
|
43
|
+
*/
|
|
44
|
+
function controlledElbowRoute(start, end, [startSide, endSide], [startGap, endGap], controls) {
|
|
45
|
+
const from = routeSide(start, startSide);
|
|
46
|
+
const to = routeSide(end, endSide);
|
|
47
|
+
const points = [from.at];
|
|
48
|
+
let at = from.at;
|
|
49
|
+
let direction = from.direction;
|
|
50
|
+
let joint = from.joint;
|
|
51
|
+
const turnOnto = (line, lineDirection) => {
|
|
52
|
+
if (lineDirection === direction) {
|
|
53
|
+
const across = meet(at, direction, direction === "HORIZONTAL" ? joint.x : joint.y);
|
|
54
|
+
points.push(across);
|
|
55
|
+
at = across;
|
|
56
|
+
direction = direction === "HORIZONTAL" ? "VERTICAL" : "HORIZONTAL";
|
|
57
|
+
}
|
|
58
|
+
at = meet(at, direction, line);
|
|
59
|
+
points.push(at);
|
|
60
|
+
direction = lineDirection;
|
|
61
|
+
};
|
|
62
|
+
controls.forEach((control, index) => {
|
|
63
|
+
const next = controls.at(index + 1);
|
|
64
|
+
turnOnto(lineOf(control), control.direction);
|
|
65
|
+
joint = next && next.direction === control.direction ? {
|
|
66
|
+
x: (control.position.x + next.position.x) / 2,
|
|
67
|
+
y: (control.position.y + next.position.y) / 2
|
|
68
|
+
} : to.joint;
|
|
69
|
+
});
|
|
70
|
+
turnOnto(to.direction === "HORIZONTAL" ? to.at.y : to.at.x, to.direction);
|
|
71
|
+
points.push(to.at);
|
|
72
|
+
const route = simplify(points);
|
|
73
|
+
if (route.length < 2) return straightPieces([from.at, from.at]);
|
|
74
|
+
route[0] = inset(route[0], route[1], startGap);
|
|
75
|
+
route[route.length - 1] = inset(route.at(-1) ?? to.at, route.at(-2) ?? from.at, endGap);
|
|
76
|
+
return straightPieces(route);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A curve through the control points it was dragged to: each end leaves its side's midpoint, less
|
|
80
|
+
* its gap, towards its own control point.
|
|
81
|
+
*/
|
|
82
|
+
function controlledCurveRoute(start, end, [startSide, endSide], [startGap, endGap], [startHandle, endHandle]) {
|
|
83
|
+
const from = towards(attachment(start, startSide), startHandle, startGap);
|
|
84
|
+
const to = towards(attachment(end, endSide), endHandle, endGap);
|
|
85
|
+
return [{
|
|
86
|
+
from,
|
|
87
|
+
to,
|
|
88
|
+
handleFrom: {
|
|
89
|
+
x: startHandle.x - from.x,
|
|
90
|
+
y: startHandle.y - from.y
|
|
91
|
+
},
|
|
92
|
+
handleTo: {
|
|
93
|
+
x: endHandle.x - to.x,
|
|
94
|
+
y: endHandle.y - to.y
|
|
95
|
+
}
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
/** `point` moved `distance` towards `toward`. */
|
|
99
|
+
function towards(point, toward, distance) {
|
|
100
|
+
const length = Math.hypot(toward.x - point.x, toward.y - point.y);
|
|
101
|
+
if (length < 1e-6) return point;
|
|
102
|
+
return along(point, {
|
|
103
|
+
x: (toward.x - point.x) / length,
|
|
104
|
+
y: (toward.y - point.y) / length
|
|
105
|
+
}, distance);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The control points an elbow keeps for its route as drawn: one for each segment between its
|
|
109
|
+
* first and its last, at the segment's midpoint, as FigJam records them after an edit.
|
|
110
|
+
*/
|
|
111
|
+
function elbowControlPoints(pieces) {
|
|
112
|
+
return pieces.slice(1, -1).flatMap(({ from, to }) => {
|
|
113
|
+
const vertical = Math.abs(from.x - to.x) < EPSILON;
|
|
114
|
+
if (vertical && Math.abs(from.y - to.y) < 1e-6) return [];
|
|
115
|
+
return [{
|
|
116
|
+
position: {
|
|
117
|
+
x: (from.x + to.x) / 2,
|
|
118
|
+
y: (from.y + to.y) / 2
|
|
119
|
+
},
|
|
120
|
+
direction: vertical ? "VERTICAL" : "HORIZONTAL"
|
|
121
|
+
}];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Where an elbow's ends turn when its first or last segment is dragged: a stub's length out of
|
|
126
|
+
* each layer, or at a free end's point.
|
|
127
|
+
*/
|
|
128
|
+
function elbowJoints(start, end, [startSide, endSide]) {
|
|
129
|
+
return [routeSide(start, startSide).joint, routeSide(end, endSide).joint];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The control points an elbow takes when its segment `index` is dragged across to `offset`: an x
|
|
133
|
+
* for a vertical segment, a y for a horizontal one. A segment between others moves alone. Its
|
|
134
|
+
* first or last segment turns at its end's joint, by a new segment across, and then runs at
|
|
135
|
+
* `offset`, as FigJam splits one.
|
|
136
|
+
*/
|
|
137
|
+
function dragElbowSegment(pieces, [startJoint, endJoint], index, offset) {
|
|
138
|
+
const piece = pieces.at(index);
|
|
139
|
+
if (!piece || index < 0) return elbowControlPoints(pieces);
|
|
140
|
+
const direction = Math.abs(piece.from.x - piece.to.x) < 1e-6 ? "VERTICAL" : "HORIZONTAL";
|
|
141
|
+
const across = direction === "VERTICAL" ? "HORIZONTAL" : "VERTICAL";
|
|
142
|
+
const x = (piece.from.x + piece.to.x) / 2;
|
|
143
|
+
const y = (piece.from.y + piece.to.y) / 2;
|
|
144
|
+
const moved = {
|
|
145
|
+
position: direction === "VERTICAL" ? {
|
|
146
|
+
x: offset,
|
|
147
|
+
y
|
|
148
|
+
} : {
|
|
149
|
+
x,
|
|
150
|
+
y: offset
|
|
151
|
+
},
|
|
152
|
+
direction
|
|
153
|
+
};
|
|
154
|
+
const before = index === 0 ? [{
|
|
155
|
+
position: startJoint,
|
|
156
|
+
direction: across
|
|
157
|
+
}] : elbowControlPoints(pieces.slice(0, index + 1));
|
|
158
|
+
const after = index === pieces.length - 1 ? [{
|
|
159
|
+
position: endJoint,
|
|
160
|
+
direction: across
|
|
161
|
+
}] : elbowControlPoints(pieces.slice(index));
|
|
162
|
+
return [
|
|
163
|
+
...before,
|
|
164
|
+
moved,
|
|
165
|
+
...after
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
/** A curve's control points as drawn: where its handles reach. */
|
|
169
|
+
function curveControlPoints(piece) {
|
|
170
|
+
return [{
|
|
171
|
+
x: piece.from.x + piece.handleFrom.x,
|
|
172
|
+
y: piece.from.y + piece.handleFrom.y
|
|
173
|
+
}, {
|
|
174
|
+
x: piece.to.x + piece.handleTo.x,
|
|
175
|
+
y: piece.to.y + piece.handleTo.y
|
|
176
|
+
}];
|
|
177
|
+
}
|
|
178
|
+
/** The point midway along a curve, where its handle sits. */
|
|
179
|
+
function curveMidpoint(piece) {
|
|
180
|
+
return pointAt(piece, .5);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The control points a curve takes when the point midway along it is dragged by `delta`: both
|
|
184
|
+
* move by 4/3 of it, which moves the midpoint by exactly `delta`.
|
|
185
|
+
*/
|
|
186
|
+
function dragCurve(handles, delta) {
|
|
187
|
+
const shift = (point) => ({
|
|
188
|
+
x: point.x + delta.x * 4 / 3,
|
|
189
|
+
y: point.y + delta.y * 4 / 3
|
|
190
|
+
});
|
|
191
|
+
return [shift(handles[0]), shift(handles[1])];
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { controlledCurveRoute, controlledElbowRoute, curveControlPoints, curveMidpoint, dragCurve, dragElbowSegment, elbowControlPoints, elbowJoints };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","names":[],"sources":["../../src/connectors/controls.ts"],"sourcesContent":["import type { Vector } from '../primitives'\nimport type { ConnectorControlPoint } from '../types'\nimport { ELBOW_STUB, simplify } from './elbow'\nimport { along, EPSILON, pointAt, straightPieces, type ConnectorPiece } from './pieces'\nimport { attachment, OUTWARD, type ConnectorRouteEnd, type ConnectorSide } from './sides'\n\n/**\n * Elbows and curves dragged into place, as FigJam keeps them\n * (`packages/scene-graph/tests/connectors/figma-control-routes.json`): an elbow runs along each\n * dragged segment's line in turn, and a curve takes its two control points as they were left.\n */\n\ntype Direction = ConnectorControlPoint['direction']\n\n/** A route end's side, with the line it leaves or arrives along and where it attaches. */\ninterface RouteSide {\n at: Vector\n direction: Direction\n /** Where a segment joining a parallel control line runs: a stub's length out of the layer. */\n joint: Vector\n}\n\nfunction directionOf(side: ConnectorSide): Direction {\n return side === 'LEFT' || side === 'RIGHT' ? 'HORIZONTAL' : 'VERTICAL'\n}\n\nfunction routeSide(end: ConnectorRouteEnd, side: ConnectorSide): RouteSide {\n const at = attachment(end, side)\n return {\n at,\n direction: directionOf(side),\n joint: end.box ? along(at, OUTWARD[side], ELBOW_STUB) : at\n }\n}\n\n/** The coordinate a control line fixes: x for a vertical segment, y for a horizontal one. */\nfunction lineOf(point: ConnectorControlPoint): number {\n return point.direction === 'VERTICAL' ? point.position.x : point.position.y\n}\n\n/** Where a run along `direction` through `from` meets the perpendicular line `to`. */\nfunction meet(from: Vector, direction: Direction, to: number): Vector {\n return direction === 'HORIZONTAL' ? { x: to, y: from.y } : { x: from.x, y: to }\n}\n\n/**\n * Moves an end along its segment by its gap, towards the next point, unless the segment is no\n * longer than the gap.\n */\nfunction inset(point: Vector, toward: Vector, gap: number): Vector {\n const length = Math.hypot(toward.x - point.x, toward.y - point.y)\n return length <= gap ? point : towards(point, toward, gap)\n}\n\n/**\n * An elbow through its control lines: from the start's side to each line in turn, then to the end's\n * side. A line parallel to the run before it is reached by a segment across, at the stub of the\n * end it follows or leads to, or midway between two control lines. Points in line merge, so ends\n * that face each other in line draw straight. Each end then stops short by its gap along its own\n * segment, which may point back into its layer.\n */\nexport function controlledElbowRoute(\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n [startSide, endSide]: [ConnectorSide, ConnectorSide],\n [startGap, endGap]: [number, number],\n controls: ConnectorControlPoint[]\n): ConnectorPiece[] {\n const from = routeSide(start, startSide)\n const to = routeSide(end, endSide)\n const points: Vector[] = [from.at]\n let at = from.at\n let direction = from.direction\n let joint = from.joint\n const turnOnto = (line: number, lineDirection: Direction) => {\n if (lineDirection === direction) {\n // A parallel line is reached by a segment across it.\n const across = meet(at, direction, direction === 'HORIZONTAL' ? joint.x : joint.y)\n points.push(across)\n at = across\n direction = direction === 'HORIZONTAL' ? 'VERTICAL' : 'HORIZONTAL'\n }\n at = meet(at, direction, line)\n points.push(at)\n direction = lineDirection\n }\n controls.forEach((control, index) => {\n const next = controls.at(index + 1)\n turnOnto(lineOf(control), control.direction)\n // Between two parallel control lines, the segment across runs midway.\n joint =\n next && next.direction === control.direction\n ? {\n x: (control.position.x + next.position.x) / 2,\n y: (control.position.y + next.position.y) / 2\n }\n : to.joint\n })\n // The end's own line, which its last segment arrives along.\n turnOnto(to.direction === 'HORIZONTAL' ? to.at.y : to.at.x, to.direction)\n points.push(to.at)\n const route = simplify(points)\n if (route.length < 2) return straightPieces([from.at, from.at])\n route[0] = inset(route[0], route[1], startGap)\n route[route.length - 1] = inset(route.at(-1) ?? to.at, route.at(-2) ?? from.at, endGap)\n return straightPieces(route)\n}\n\n/**\n * A curve through the control points it was dragged to: each end leaves its side's midpoint, less\n * its gap, towards its own control point.\n */\nexport function controlledCurveRoute(\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n [startSide, endSide]: [ConnectorSide, ConnectorSide],\n [startGap, endGap]: [number, number],\n [startHandle, endHandle]: [Vector, Vector]\n): ConnectorPiece[] {\n const from = towards(attachment(start, startSide), startHandle, startGap)\n const to = towards(attachment(end, endSide), endHandle, endGap)\n return [\n {\n from,\n to,\n handleFrom: { x: startHandle.x - from.x, y: startHandle.y - from.y },\n handleTo: { x: endHandle.x - to.x, y: endHandle.y - to.y }\n }\n ]\n}\n\n/** `point` moved `distance` towards `toward`. */\nfunction towards(point: Vector, toward: Vector, distance: number): Vector {\n const length = Math.hypot(toward.x - point.x, toward.y - point.y)\n if (length < EPSILON) return point\n return along(\n point,\n { x: (toward.x - point.x) / length, y: (toward.y - point.y) / length },\n distance\n )\n}\n\n/**\n * The control points an elbow keeps for its route as drawn: one for each segment between its\n * first and its last, at the segment's midpoint, as FigJam records them after an edit.\n */\nexport function elbowControlPoints(pieces: ConnectorPiece[]): ConnectorControlPoint[] {\n return pieces.slice(1, -1).flatMap(({ from, to }) => {\n const vertical = Math.abs(from.x - to.x) < EPSILON\n if (vertical && Math.abs(from.y - to.y) < EPSILON) return []\n return [\n {\n position: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 },\n direction: vertical ? 'VERTICAL' : 'HORIZONTAL'\n }\n ]\n })\n}\n\n/**\n * Where an elbow's ends turn when its first or last segment is dragged: a stub's length out of\n * each layer, or at a free end's point.\n */\nexport function elbowJoints(\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n [startSide, endSide]: [ConnectorSide, ConnectorSide]\n): [Vector, Vector] {\n return [routeSide(start, startSide).joint, routeSide(end, endSide).joint]\n}\n\n/**\n * The control points an elbow takes when its segment `index` is dragged across to `offset`: an x\n * for a vertical segment, a y for a horizontal one. A segment between others moves alone. Its\n * first or last segment turns at its end's joint, by a new segment across, and then runs at\n * `offset`, as FigJam splits one.\n */\nexport function dragElbowSegment(\n pieces: ConnectorPiece[],\n [startJoint, endJoint]: [Vector, Vector],\n index: number,\n offset: number\n): ConnectorControlPoint[] {\n const piece = pieces.at(index)\n if (!piece || index < 0) return elbowControlPoints(pieces)\n const direction: Direction =\n Math.abs(piece.from.x - piece.to.x) < EPSILON ? 'VERTICAL' : 'HORIZONTAL'\n const across: Direction = direction === 'VERTICAL' ? 'HORIZONTAL' : 'VERTICAL'\n const x = (piece.from.x + piece.to.x) / 2\n const y = (piece.from.y + piece.to.y) / 2\n const moved: ConnectorControlPoint = {\n position: direction === 'VERTICAL' ? { x: offset, y } : { x, y: offset },\n direction\n }\n const before =\n index === 0\n ? [{ position: startJoint, direction: across }]\n : elbowControlPoints(pieces.slice(0, index + 1))\n const after =\n index === pieces.length - 1\n ? [{ position: endJoint, direction: across }]\n : elbowControlPoints(pieces.slice(index))\n return [...before, moved, ...after]\n}\n\n/** A curve's control points as drawn: where its handles reach. */\nexport function curveControlPoints(piece: ConnectorPiece): [Vector, Vector] {\n return [\n { x: piece.from.x + piece.handleFrom.x, y: piece.from.y + piece.handleFrom.y },\n { x: piece.to.x + piece.handleTo.x, y: piece.to.y + piece.handleTo.y }\n ]\n}\n\n/** The point midway along a curve, where its handle sits. */\nexport function curveMidpoint(piece: ConnectorPiece): Vector {\n return pointAt(piece, 0.5)\n}\n\n/**\n * The control points a curve takes when the point midway along it is dragged by `delta`: both\n * move by 4/3 of it, which moves the midpoint by exactly `delta`.\n */\nexport function dragCurve(handles: [Vector, Vector], delta: Vector): [Vector, Vector] {\n const shift = (point: Vector) => ({\n x: point.x + (delta.x * 4) / 3,\n y: point.y + (delta.y * 4) / 3\n })\n return [shift(handles[0]), shift(handles[1])]\n}\n"],"mappings":";;;;AAsBA,SAAS,YAAY,MAAgC;CACnD,OAAO,SAAS,UAAU,SAAS,UAAU,eAAe;AAC9D;AAEA,SAAS,UAAU,KAAwB,MAAgC;CACzE,MAAM,KAAK,WAAW,KAAK,IAAI;CAC/B,OAAO;EACL;EACA,WAAW,YAAY,IAAI;EAC3B,OAAO,IAAI,MAAM,MAAM,IAAI,QAAQ,OAAA,EAAiB,IAAI;CAC1D;AACF;;AAGA,SAAS,OAAO,OAAsC;CACpD,OAAO,MAAM,cAAc,aAAa,MAAM,SAAS,IAAI,MAAM,SAAS;AAC5E;;AAGA,SAAS,KA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,MAAM,WAAW;CAAE,GAC7E;EAAE,GAAG,MAAM,GAAG,IAAI,MAAM,SAAS;EAAG,GAAG,MAAM,GAAG,IAAI,MAAM,SAAS;CAAE,CACvE;AACF;;AAGA,SAAgB,cAAc,OAA+B;CAC3D,OAAO,QAAQ,OAAO,EAAG;AAC3B;;;;;AAMA,SAAgB,UAAU,SAA2B,OAAiC;CACpF,MAAM,SAAS,WAAmB;EAChC,GAAG,MAAM,IAAK,MAAM,IAAI,IAAK;EAC7B,GAAG,MAAM,IAAK,MAAM,IAAI,IAAK;CAC/B;CACA,OAAO,CAAC,MAAM,QAAQ,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;AAC9C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { ConnectorEndpoint, ConnectorLineType, SceneNode, StrokeCap } from "../types.js";
|
|
3
|
+
//#region src/connectors/create.d.ts
|
|
4
|
+
/** What a new connector joins and how it looks; anything left out takes Figma's defaults. */
|
|
5
|
+
interface ConnectorContent {
|
|
6
|
+
start: ConnectorEndpoint;
|
|
7
|
+
end: ConnectorEndpoint;
|
|
8
|
+
lineType?: ConnectorLineType;
|
|
9
|
+
startCap?: StrokeCap;
|
|
10
|
+
endCap?: StrokeCap;
|
|
11
|
+
/** The label on the line. */
|
|
12
|
+
text?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Makes a connector in `parentId` with its line and label, routed between its ends. Figma names
|
|
16
|
+
* a new connector "Connector line".
|
|
17
|
+
*/
|
|
18
|
+
/** The name FigJam gives a connector it draws. */
|
|
19
|
+
declare const CONNECTOR_NAME = "Connector line";
|
|
20
|
+
declare function createConnector(graph: SceneGraph, parentId: string, content: ConnectorContent, props?: Partial<SceneNode>): SceneNode;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CONNECTOR_NAME, ConnectorContent, createConnector };
|
|
23
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","names":[],"sources":["../../src/connectors/create.ts"],"mappings":";;;;UAMiB;EACf,OAAO;EACP,KAAK;EACL,WAAW;EACX,WAAW;EACX,SAAS;;EAET;;;;;;;cAQW;iBAEG,gBACd,OAAO,YACP,kBACA,SAAS,kBACT,QAAO,QAAQ,aACd"}
|