@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-caps.d.ts +35 -14
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +286 -55
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +62 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +43 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +48 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +156 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +228 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +86 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/spec.js +6 -29
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +26 -0
- package/dist/bindings.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +42 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +249 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +17 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/{chunks/color → color}/contrast.js +2 -24
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/document.js +2 -1
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/merge.js +1 -1
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/properties.d.ts +32 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +180 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +33 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +58 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +47 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +156 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +208 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +11 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +94 -2
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +268 -1
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +49 -2
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +264 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/{chunks/css → css}/grid.js +2 -33
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +7 -0
- package/dist/css/index.js +7 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +25 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +47 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +64 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +270 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +439 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +70 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +95 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +44 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +27 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +43 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +135 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +233 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +89 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +306 -2
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +13 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +178 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +625 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +21 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +5 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +48 -2
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +75 -57
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/{chunks/icons → icons}/glyph.js +2 -40
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -2
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +67 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -23
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +161 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +90 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +38 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +180 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +13 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +50 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +51 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +158 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/swap.js +288 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +327 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/{layout.js → layout/index.js} +4 -3
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +59 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -2
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +119 -1
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/node-defaults.d.ts +22 -2
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +254 -2
- package/dist/node-defaults.js.map +1 -0
- package/dist/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +77 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +56 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +9 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +39 -2
- package/dist/parse-path.js.map +1 -1
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +73 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +143 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +168 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +3 -0
- package/dist/plugin-data/index.js +3 -0
- package/dist/polygon.d.ts +4 -2
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +17 -2
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +12 -2
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +62 -1
- package/dist/preview.js.map +1 -0
- package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.js +24 -1
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +6 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +287 -2
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +148 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +7 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +47 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.js +4 -0
- package/dist/shaders/model.d.ts +41 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +71 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +41 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +36 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +51 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +186 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +77 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +105 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +40 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +118 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +21 -2
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +109 -1
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.js +10 -1
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/{text-direction.js → text/direction.js} +1 -1
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +24 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +49 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/{text-picture.d.ts → text/picture.d.ts} +3 -4
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +38 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +8 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +78 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +195 -2007
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +89 -2
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -2
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +235 -1
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +83 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +314 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +43 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +104 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +238 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +16 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +49 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/vector-network.d.ts +65 -2
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +375 -2
- package/dist/vector-network.js.map +1 -0
- package/package.json +303 -137
- package/src/arrow-caps.ts +279 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +5 -3
- package/src/behaviours/model.ts +25 -22
- package/src/behaviours/schema.ts +64 -13
- package/src/behaviours/spec.ts +11 -50
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +252 -5
- package/src/clipping.ts +112 -0
- package/src/color/index.ts +1 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +1 -1
- package/src/comments/index.ts +5 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +1 -1
- package/src/components/exposure.ts +1 -1
- package/src/components/index.ts +8 -0
- package/src/components/properties.ts +94 -4
- package/src/components/variants.ts +52 -31
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +49 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +141 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +203 -0
- package/src/coordinate.ts +10 -3
- package/src/copy.ts +71 -31
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +2 -0
- package/src/css/text.ts +84 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +30 -1
- package/src/fields/appearance.ts +35 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +32 -1
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +473 -0
- package/src/figjam/text.ts +83 -0
- package/src/font-style.ts +58 -14
- package/src/generated/index.ts +76 -0
- package/src/generated/kind.ts +24 -0
- package/src/generated/shape-with-text.ts +157 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +102 -312
- package/src/gradient.ts +14 -0
- package/src/graph.ts +849 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +6 -1
- package/src/hit-test.ts +118 -74
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +9 -0
- package/src/icons/schema.ts +19 -3
- package/src/ids.ts +34 -0
- package/src/images.ts +71 -8
- package/src/index.ts +2 -976
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +23 -2
- package/src/instances/copies.ts +7 -10
- package/src/instances/cycles.ts +1 -1
- package/src/instances/fields.ts +47 -92
- package/src/{instances.ts → instances/index.ts} +69 -44
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +55 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/swap.ts +451 -0
- package/src/instances/sync.ts +166 -177
- package/src/instances/vector-geometry.ts +3 -3
- package/src/layout/aspect-ratio.ts +1 -1
- package/src/layout/sizing.ts +1 -1
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +1 -1
- package/src/mutation-impact.ts +1 -1
- package/src/node-defaults.ts +43 -3
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +67 -0
- package/src/parse-path.ts +49 -4
- package/src/plugin-data/fields.ts +69 -77
- package/src/plugin-data/index.ts +2 -0
- package/src/polygon.ts +17 -0
- package/src/preview.ts +1 -1
- package/src/{primitives.ts → primitives/index.ts} +2 -0
- package/src/primitives/schema.ts +14 -0
- package/src/resize.ts +32 -6
- package/src/scaling/node.ts +10 -6
- package/src/scaling/tree.ts +2 -1
- package/src/shaders/index.ts +3 -0
- package/src/shaders/schema.ts +3 -3
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +169 -17
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +10 -5
- package/src/slots/frames.ts +12 -10
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +1 -1
- package/src/snap.ts +3 -1
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/index.ts +3 -0
- package/src/text/lengths.ts +44 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/picture.ts +0 -4
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +1 -1
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/history.ts +1 -1
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +18 -19
- package/src/transfer/plan.ts +1 -1
- package/src/transfer/remove.ts +1 -1
- package/src/transfer/validation.ts +1 -1
- package/src/transfer/variables.ts +7 -6
- package/src/types.ts +246 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +166 -66
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +83 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/{variables.ts → variables/index.ts} +86 -146
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +51 -0
- package/src/variables/token.ts +27 -1
- package/src/variables/value.ts +92 -0
- package/src/vector-network.ts +263 -22
- package/dist/chunks/asset-keys.js.map +0 -1
- package/dist/chunks/behaviours/kinds.js.map +0 -1
- package/dist/chunks/behaviours/layers.js +0 -611
- package/dist/chunks/behaviours/layers.js.map +0 -1
- package/dist/chunks/behaviours/spec.js.map +0 -1
- package/dist/chunks/bindings.js +0 -18
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js +0 -78
- package/dist/chunks/checkpoint.js.map +0 -1
- package/dist/chunks/color/contrast.js.map +0 -1
- package/dist/chunks/color/index.js +0 -1662
- package/dist/chunks/color/index.js.map +0 -1
- package/dist/chunks/comments/document.js.map +0 -1
- package/dist/chunks/comments/list.js.map +0 -1
- package/dist/chunks/comments/merge.js.map +0 -1
- package/dist/chunks/components/exposure.js +0 -2291
- package/dist/chunks/components/exposure.js.map +0 -1
- package/dist/chunks/components/variants.js +0 -32
- package/dist/chunks/components/variants.js.map +0 -1
- package/dist/chunks/coordinate.js +0 -385
- package/dist/chunks/coordinate.js.map +0 -1
- package/dist/chunks/css/grid.js.map +0 -1
- package/dist/chunks/css/index.js +0 -160
- package/dist/chunks/css/index.js.map +0 -1
- package/dist/chunks/events.js.map +0 -1
- package/dist/chunks/fields/geometry.js.map +0 -1
- package/dist/chunks/font-style.js +0 -96
- package/dist/chunks/font-style.js.map +0 -1
- package/dist/chunks/group-bounds.js.map +0 -1
- package/dist/chunks/icons/glyph.js.map +0 -1
- package/dist/chunks/index.js +0 -2430
- package/dist/chunks/index.js.map +0 -1
- package/dist/color.d.ts +0 -78
- package/dist/color.d.ts.map +0 -1
- package/dist/color.js +0 -3
- package/dist/constants2.d.ts +0 -11
- package/dist/constants2.d.ts.map +0 -1
- package/dist/css.d.ts +0 -39
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -3
- package/dist/images2.d.ts +0 -16
- package/dist/images2.d.ts.map +0 -1
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +0 -2
- package/dist/layout.d.ts +0 -2
- package/dist/matrix2.d.ts +0 -16
- package/dist/matrix2.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -2
- package/dist/primitives.js +0 -0
- package/dist/primitives2.d.ts.map +0 -1
- package/dist/text-direction.d.ts.map +0 -1
- package/dist/text-direction.js.map +0 -1
- package/dist/text-picture.d.ts.map +0 -1
- package/dist/text-picture.js +0 -2
- package/dist/text.d.ts +0 -2
- package/dist/text.js +0 -3
- package/dist/types2.d.ts +0 -2
- package/dist/undo2.d.ts +0 -73
- package/dist/undo2.d.ts.map +0 -1
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -2
- /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
- /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
package/dist/preview.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { SceneNode } from "./types.js";
|
|
2
|
+
//#region src/preview.d.ts
|
|
3
|
+
type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void;
|
|
4
|
+
type PreviewGraph = {
|
|
5
|
+
nodes: Map<string, SceneNode>;
|
|
6
|
+
positionPreviewVersion: number;
|
|
7
|
+
clearAbsPosCache: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare function updateNodePreview(graph: PreviewGraph, id: string, changes: Partial<SceneNode>, beforeUpdate?: NodePreviewObserver): Partial<SceneNode> | null;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { NodePreviewObserver, updateNodePreview };
|
|
12
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","names":[],"sources":["../src/preview.ts"],"mappings":";;KAIY,uBAAuB,MAAM,WAAW,SAAS,QAAQ;KAEhE;EACH,OAAO,YAAY;EACnB;EACA;;iBAwCc,kBACd,OAAO,cACP,YACA,SAAS,QAAQ,YACjB,eAAe,sBACd,QAAQ"}
|
package/dist/preview.js
CHANGED
|
@@ -1,2 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeVectorNetwork } from "./vector-network.js";
|
|
2
|
+
import { textCacheInvalidationChanges } from "./text/picture.js";
|
|
3
|
+
//#region src/preview.ts
|
|
4
|
+
const LAYOUT_AFFECTING_KEYS = /* @__PURE__ */ new Set([
|
|
5
|
+
"x",
|
|
6
|
+
"y",
|
|
7
|
+
"width",
|
|
8
|
+
"height",
|
|
9
|
+
"rotation",
|
|
10
|
+
"flipX",
|
|
11
|
+
"flipY",
|
|
12
|
+
"parentId",
|
|
13
|
+
"childIds",
|
|
14
|
+
"layoutMode",
|
|
15
|
+
"layoutDirection",
|
|
16
|
+
"layoutWrap",
|
|
17
|
+
"primaryAxisSizing",
|
|
18
|
+
"counterAxisSizing",
|
|
19
|
+
"itemSpacing",
|
|
20
|
+
"counterAxisSpacing",
|
|
21
|
+
"paddingTop",
|
|
22
|
+
"paddingRight",
|
|
23
|
+
"paddingBottom",
|
|
24
|
+
"paddingLeft",
|
|
25
|
+
"layoutGrow",
|
|
26
|
+
"layoutAlignSelf",
|
|
27
|
+
"layoutPositioning",
|
|
28
|
+
"minWidth",
|
|
29
|
+
"maxWidth",
|
|
30
|
+
"minHeight",
|
|
31
|
+
"maxHeight",
|
|
32
|
+
"visible",
|
|
33
|
+
"text",
|
|
34
|
+
"fontSize",
|
|
35
|
+
"lineHeight",
|
|
36
|
+
"letterSpacing",
|
|
37
|
+
"styleRuns",
|
|
38
|
+
"textAutoResize"
|
|
39
|
+
]);
|
|
40
|
+
function updateNodePreview(graph, id, changes, beforeUpdate) {
|
|
41
|
+
const node = graph.nodes.get(id);
|
|
42
|
+
if (!node) return null;
|
|
43
|
+
changes = Object.fromEntries(Object.entries(changes).filter(([, value]) => value !== void 0));
|
|
44
|
+
if (Object.keys(changes).every((key) => node[key] === changes[key])) return null;
|
|
45
|
+
if (Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))) graph.clearAbsPosCache();
|
|
46
|
+
let normalizedChanges = changes;
|
|
47
|
+
if (node.type === "TEXT") normalizedChanges = {
|
|
48
|
+
...textCacheInvalidationChanges(node, changes),
|
|
49
|
+
...changes
|
|
50
|
+
};
|
|
51
|
+
if (changes.vectorNetwork) normalizedChanges = {
|
|
52
|
+
...normalizedChanges,
|
|
53
|
+
vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)
|
|
54
|
+
};
|
|
55
|
+
beforeUpdate?.(node, normalizedChanges);
|
|
56
|
+
graph.positionPreviewVersion++;
|
|
57
|
+
Object.assign(node, normalizedChanges);
|
|
58
|
+
return normalizedChanges;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
2
61
|
export { updateNodePreview };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","names":[],"sources":["../src/preview.ts"],"sourcesContent":["import { textCacheInvalidationChanges } from './text/picture'\nimport type { SceneNode } from './types'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void\n\ntype PreviewGraph = {\n nodes: Map<string, SceneNode>\n positionPreviewVersion: number\n clearAbsPosCache: () => void\n}\n\nconst LAYOUT_AFFECTING_KEYS = new Set<string>([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'parentId',\n 'childIds',\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'layoutPositioning',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'visible',\n 'text',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'styleRuns',\n 'textAutoResize'\n])\n\nexport function updateNodePreview(\n graph: PreviewGraph,\n id: string,\n changes: Partial<SceneNode>,\n beforeUpdate?: NodePreviewObserver\n): Partial<SceneNode> | null {\n const node = graph.nodes.get(id)\n if (!node) return null\n changes = Object.fromEntries(\n (Object.entries(changes) as Array<[string, unknown]>).filter(([, value]) => value !== undefined)\n )\n if ((Object.keys(changes) as (keyof SceneNode)[]).every((key) => node[key] === changes[key])) {\n return null\n }\n const affectsLayout = Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))\n if (affectsLayout) graph.clearAbsPosCache()\n let normalizedChanges = changes\n if (node.type === 'TEXT') {\n normalizedChanges = { ...textCacheInvalidationChanges(node, changes), ...changes }\n }\n if (changes.vectorNetwork) {\n normalizedChanges = {\n ...normalizedChanges,\n vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)\n }\n }\n beforeUpdate?.(node, normalizedChanges)\n graph.positionPreviewVersion++\n Object.assign(node, normalizedChanges)\n return normalizedChanges\n}\n"],"mappings":";;;AAYA,MAAM,wCAAwB,IAAI,IAAY;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,kBACd,OACA,IACA,SACA,cAC2B;CAC3B,MAAM,OAAO,MAAM,MAAM,IAAI,EAAE;CAC/B,IAAI,CAAC,MAAM,OAAO;CAClB,UAAU,OAAO,YACd,OAAO,QAAQ,OAAO,CAAC,CAA8B,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CACjG;CACA,IAAK,OAAO,KAAK,OAAO,CAAC,CAAyB,OAAO,QAAQ,KAAK,SAAS,QAAQ,IAAI,GACzF,OAAO;CAGT,IADsB,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,QAAQ,sBAAsB,IAAI,GAAG,CACtE,GAAG,MAAM,iBAAiB;CAC1C,IAAI,oBAAoB;CACxB,IAAI,KAAK,SAAS,QAChB,oBAAoB;EAAE,GAAG,6BAA6B,MAAM,OAAO;EAAG,GAAG;CAAQ;CAEnF,IAAI,QAAQ,eACV,oBAAoB;EAClB,GAAG;EACH,eAAe,uBAAuB,QAAQ,aAAa;CAC7D;CAEF,eAAe,MAAM,iBAAiB;CACtC,MAAM;CACN,OAAO,OAAO,MAAM,iBAAiB;CACrC,OAAO;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { finiteNumberSchema, matrixSchema, vectorSchema } from "./schema.js";
|
|
2
|
+
//#region src/primitives/index.d.ts
|
|
2
3
|
interface GUID {
|
|
3
4
|
sessionID: number;
|
|
4
5
|
localID: number;
|
|
@@ -38,5 +39,5 @@ type JSONObject = {
|
|
|
38
39
|
};
|
|
39
40
|
type JSONArray = unknown[];
|
|
40
41
|
//#endregion
|
|
41
|
-
export { Color, GUID, JSONArray, JSONObject, JSONPrimitive, JSONValue, Matrix, Rect, Size, Vector };
|
|
42
|
-
//# sourceMappingURL=
|
|
42
|
+
export { Color, GUID, JSONArray, JSONObject, JSONPrimitive, JSONValue, Matrix, Rect, Size, Vector, finiteNumberSchema, matrixSchema, vectorSchema };
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/primitives/index.ts"],"mappings":";;UAAiB;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;;KAGU;KACA,YAAY,gBAAgB,aAAa;KACzC;GAAgB;;KAChB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
//#region src/primitives/schema.d.ts
|
|
3
|
+
declare const finiteNumberSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
4
|
+
declare const vectorSchema: v.ObjectSchema<{
|
|
5
|
+
readonly x: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
6
|
+
readonly y: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
7
|
+
}, undefined>;
|
|
8
|
+
declare const matrixSchema: v.ObjectSchema<{
|
|
9
|
+
readonly m00: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
10
|
+
readonly m01: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
11
|
+
readonly m02: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
12
|
+
readonly m10: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
13
|
+
readonly m11: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
14
|
+
readonly m12: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { finiteNumberSchema, matrixSchema, vectorSchema };
|
|
18
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/primitives/schema.ts"],"mappings":";;cAEa,oBAAkB,EAAA,yBAAA,EAAA,yBAAA,EAAA;cAElB,cAAY,EAAA;;;;cAEZ,cAAY,EAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
//#region src/primitives/schema.ts
|
|
3
|
+
const finiteNumberSchema = v.pipe(v.number(), v.finite());
|
|
4
|
+
const vectorSchema = v.object({
|
|
5
|
+
x: finiteNumberSchema,
|
|
6
|
+
y: finiteNumberSchema
|
|
7
|
+
});
|
|
8
|
+
const matrixSchema = v.object({
|
|
9
|
+
m00: finiteNumberSchema,
|
|
10
|
+
m01: finiteNumberSchema,
|
|
11
|
+
m02: finiteNumberSchema,
|
|
12
|
+
m10: finiteNumberSchema,
|
|
13
|
+
m11: finiteNumberSchema,
|
|
14
|
+
m12: finiteNumberSchema
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { finiteNumberSchema, matrixSchema, vectorSchema };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/primitives/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\nexport const finiteNumberSchema = v.pipe(v.number(), v.finite())\n\nexport const vectorSchema = v.object({ x: finiteNumberSchema, y: finiteNumberSchema })\n\nexport const matrixSchema = v.object({\n m00: finiteNumberSchema,\n m01: finiteNumberSchema,\n m02: finiteNumberSchema,\n m10: finiteNumberSchema,\n m11: finiteNumberSchema,\n m12: finiteNumberSchema\n})\n"],"mappings":";;AAEA,MAAa,qBAAqB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAE/D,MAAa,eAAe,EAAE,OAAO;CAAE,GAAG;CAAoB,GAAG;AAAmB,CAAC;AAErF,MAAa,eAAe,EAAE,OAAO;CACnC,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP,CAAC"}
|
package/dist/random.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/random.ts
|
|
2
|
+
function randomHex(bytes = 16) {
|
|
3
|
+
if (!Number.isInteger(bytes) || bytes < 0) throw new RangeError("bytes must be a non-negative integer");
|
|
4
|
+
const buf = crypto.getRandomValues(new Uint8Array(bytes));
|
|
5
|
+
let hex = "";
|
|
6
|
+
for (const b of buf) hex += b.toString(16).padStart(2, "0");
|
|
7
|
+
return hex;
|
|
8
|
+
}
|
|
9
|
+
function randomInt() {
|
|
10
|
+
return crypto.getRandomValues(/* @__PURE__ */ new Int32Array(1))[0];
|
|
11
|
+
}
|
|
12
|
+
function randomIndex(length) {
|
|
13
|
+
if (!Number.isInteger(length) || length <= 0) throw new RangeError("length must be a positive integer");
|
|
14
|
+
const max = 4294967296;
|
|
15
|
+
const limit = max - max % length;
|
|
16
|
+
const buffer = /* @__PURE__ */ new Uint32Array(1);
|
|
17
|
+
do
|
|
18
|
+
crypto.getRandomValues(buffer);
|
|
19
|
+
while (buffer[0] >= limit);
|
|
20
|
+
return buffer[0] % length;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
2
23
|
export { randomHex, randomIndex, randomInt };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.js","names":[],"sources":["../src/random.ts"],"sourcesContent":["export function randomHex(bytes = 16): string {\n if (!Number.isInteger(bytes) || bytes < 0) {\n throw new RangeError('bytes must be a non-negative integer')\n }\n const buf = crypto.getRandomValues(new Uint8Array(bytes))\n let hex = ''\n for (const b of buf) hex += b.toString(16).padStart(2, '0')\n return hex\n}\n\nexport function randomInt(): number {\n return crypto.getRandomValues(new Int32Array(1))[0]\n}\n\nexport function randomIndex(length: number): number {\n if (!Number.isInteger(length) || length <= 0) {\n throw new RangeError('length must be a positive integer')\n }\n const max = 0x1_0000_0000\n const limit = max - (max % length)\n const buffer = new Uint32Array(1)\n\n do {\n crypto.getRandomValues(buffer)\n } while (buffer[0] >= limit)\n\n return buffer[0] % length\n}\n"],"mappings":";AAAA,SAAgB,UAAU,QAAQ,IAAY;CAC5C,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GACtC,MAAM,IAAI,WAAW,sCAAsC;CAE7D,MAAM,MAAM,OAAO,gBAAgB,IAAI,WAAW,KAAK,CAAC;CACxD,IAAI,MAAM;CACV,KAAK,MAAM,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CAC1D,OAAO;AACT;AAEA,SAAgB,YAAoB;CAClC,OAAO,OAAO,gCAAgB,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AACnD;AAEA,SAAgB,YAAY,QAAwB;CAClD,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GACzC,MAAM,IAAI,WAAW,mCAAmC;CAE1D,MAAM,MAAM;CACZ,MAAM,QAAQ,MAAO,MAAM;CAC3B,MAAM,yBAAS,IAAI,YAAY,CAAC;CAEhC;EACE,OAAO,gBAAgB,MAAM;QACtB,OAAO,MAAM;CAEtB,OAAO,OAAO,KAAK;AACrB"}
|
package/dist/resize.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rect } from "./
|
|
1
|
+
import { Rect } from "./primitives/index.js";
|
|
2
2
|
import { ConstraintType, SceneNode, VectorNetwork } from "./types.js";
|
|
3
3
|
//#region src/resize.d.ts
|
|
4
4
|
/**
|
|
@@ -7,10 +7,12 @@ import { ConstraintType, SceneNode, VectorNetwork } from "./types.js";
|
|
|
7
7
|
* geometry that must scale with the node, and textPathBox is the layout box the
|
|
8
8
|
* glyphs were reflowed against.
|
|
9
9
|
*/
|
|
10
|
-
type ResizeSnapshot = Pick<SceneNode, 'x' | 'y' | 'width' | 'height' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>;
|
|
10
|
+
type ResizeSnapshot = Pick<SceneNode, 'type' | 'x' | 'y' | 'width' | 'height' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>;
|
|
11
11
|
interface ResizeGraph {
|
|
12
12
|
getNode(id: string): SceneNode | undefined;
|
|
13
13
|
}
|
|
14
|
+
/** Keep a placed box's constrained edges or center when its content determines its size. */
|
|
15
|
+
declare function resizedChildRect(placed: Rect, size: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType): Rect;
|
|
14
16
|
/** A child's box after its parent resizes, keeping a locked aspect ratio as Figma does. */
|
|
15
17
|
declare function constrainedChildRect(child: Rect, parentBefore: Pick<Rect, 'width' | 'height'>, parentAfter: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType, aspectRatio?: number | null): Rect;
|
|
16
18
|
/**
|
|
@@ -31,9 +33,9 @@ declare function createResizeSnapshot(node: SceneNode): ResizeSnapshot;
|
|
|
31
33
|
* glyphs stayed at the pre-resize size, so shrinking a sticker made the white
|
|
32
34
|
* OUTSIDE outlines look massively thick (DomeSticker resize bug).
|
|
33
35
|
*/
|
|
34
|
-
declare function scaledGeometryChanges(orig: Pick<ResizeSnapshot, 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>, origWidth: number, origHeight: number, width: number, height: number): Partial<SceneNode>;
|
|
36
|
+
declare function scaledGeometryChanges(orig: Pick<ResizeSnapshot, 'type' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>, origWidth: number, origHeight: number, width: number, height: number): Partial<SceneNode>;
|
|
35
37
|
declare function collectResizeDescendants(graph: ResizeGraph, rootId: string): Map<string, ResizeSnapshot> | null;
|
|
36
38
|
declare function computeConstrainedResizeChanges(graph: ResizeGraph, rootId: string, rootBefore: Pick<Rect, 'width' | 'height'>, rootAfter: Pick<Rect, 'width' | 'height'>, originals: ReadonlyMap<string, ResizeSnapshot>): Map<string, Partial<SceneNode>>;
|
|
37
39
|
//#endregion
|
|
38
|
-
export { ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, layoutConstrainedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
|
|
40
|
+
export { ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, layoutConstrainedChildRect, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
|
|
39
41
|
//# sourceMappingURL=resize.d.ts.map
|
package/dist/resize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;KAkBY,iBAAiB,KAC3B;
|
|
1
|
+
{"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;KAkBY,iBAAiB,KAC3B;UAeQ;EACR,QAAQ,aAAa;;;iBA8CP,iBACd,QAAQ,MACR,MAAM,KAAK,2BACX,YAAY,gBACZ,UAAU,iBACT;;iBAyBa,qBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;;;;;;;;iBAuCa,2BACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;iBAgBa,gBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,4BACjB;iBAIa,4BACd,eAAe,sBACf,uBACA,wBACA,eACA,iBACC;;iBA8Ba,qBAAqB,MAAM,YAAY;;;;;;;iBAkDvC,sBACd,MAAM,KACJ,kJAUF,mBACA,oBACA,eACA,iBACC,QAAQ;iBAqDK,yBACd,OAAO,aACP,iBACC,YAAY;iBAoBC,gCACd,OAAO,aACP,gBACA,YAAY,KAAK,2BACjB,WAAW,KAAK,2BAChB,WAAW,oBAAoB,kBAC9B,YAAY,QAAQ"}
|
package/dist/resize.js
CHANGED
|
@@ -1,2 +1,287 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { cloneVectorNetwork, copyDerivedGlyphs, copyGeometryPaths, copyStroke, copyStrokes, scaleGeometryPaths } from "./copy.js";
|
|
2
|
+
import { enforcedAspectRatio } from "./layout/aspect-ratio.js";
|
|
3
|
+
//#region src/resize.ts
|
|
4
|
+
const CONSTRAINT_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
5
|
+
"FRAME",
|
|
6
|
+
"COMPONENT",
|
|
7
|
+
"COMPONENT_SET",
|
|
8
|
+
"INSTANCE",
|
|
9
|
+
"GROUP",
|
|
10
|
+
"BOOLEAN_OPERATION"
|
|
11
|
+
]);
|
|
12
|
+
function constrainedAxis(position, size, parentBefore, parentAfter, constraint) {
|
|
13
|
+
const delta = parentAfter - parentBefore;
|
|
14
|
+
if (constraint === "MAX") return {
|
|
15
|
+
position: position + delta,
|
|
16
|
+
size
|
|
17
|
+
};
|
|
18
|
+
if (constraint === "CENTER") return {
|
|
19
|
+
position: position + delta / 2,
|
|
20
|
+
size
|
|
21
|
+
};
|
|
22
|
+
if (constraint === "STRETCH") return {
|
|
23
|
+
position,
|
|
24
|
+
size: Math.max(1, size + delta)
|
|
25
|
+
};
|
|
26
|
+
if (constraint === "SCALE" && parentBefore > 0) {
|
|
27
|
+
const scale = parentAfter / parentBefore;
|
|
28
|
+
return {
|
|
29
|
+
position: position * scale,
|
|
30
|
+
size: Math.max(1, size * scale)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
position,
|
|
35
|
+
size
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const FLEXIBLE_CONSTRAINTS = /* @__PURE__ */ new Set(["STRETCH", "SCALE"]);
|
|
39
|
+
/** The axis at `size`, keeping the edge or centre its constraint pins where it was placed. */
|
|
40
|
+
function resizedInPlace(placed, size, constraint) {
|
|
41
|
+
if (constraint === "MAX") return {
|
|
42
|
+
position: placed.position + placed.size - size,
|
|
43
|
+
size
|
|
44
|
+
};
|
|
45
|
+
if (constraint === "CENTER") return {
|
|
46
|
+
position: placed.position + (placed.size - size) / 2,
|
|
47
|
+
size
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
position: placed.position,
|
|
51
|
+
size
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Keep a placed box's constrained edges or center when its content determines its size. */
|
|
55
|
+
function resizedChildRect(placed, size, horizontal, vertical) {
|
|
56
|
+
const x = resizedInPlace({
|
|
57
|
+
position: placed.x,
|
|
58
|
+
size: placed.width
|
|
59
|
+
}, size.width, horizontal);
|
|
60
|
+
const y = resizedInPlace({
|
|
61
|
+
position: placed.y,
|
|
62
|
+
size: placed.height
|
|
63
|
+
}, size.height, vertical);
|
|
64
|
+
return {
|
|
65
|
+
x: x.position,
|
|
66
|
+
y: y.position,
|
|
67
|
+
width: x.size,
|
|
68
|
+
height: y.size
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A locked aspect ratio holds when exactly one axis follows the parent, as in Figma: that axis
|
|
73
|
+
* sizes the other. With both axes following the parent, or neither, the ratio gives way.
|
|
74
|
+
*/
|
|
75
|
+
function keepLockedRatio(x, y, horizontal, vertical, aspectRatio) {
|
|
76
|
+
const flexibleX = FLEXIBLE_CONSTRAINTS.has(horizontal);
|
|
77
|
+
if (aspectRatio === null || flexibleX === FLEXIBLE_CONSTRAINTS.has(vertical)) return {
|
|
78
|
+
x,
|
|
79
|
+
y
|
|
80
|
+
};
|
|
81
|
+
return flexibleX ? {
|
|
82
|
+
x,
|
|
83
|
+
y: resizedInPlace(y, x.size / aspectRatio, vertical)
|
|
84
|
+
} : {
|
|
85
|
+
x: resizedInPlace(x, y.size * aspectRatio, horizontal),
|
|
86
|
+
y
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** A child's box after its parent resizes, keeping a locked aspect ratio as Figma does. */
|
|
90
|
+
function constrainedChildRect(child, parentBefore, parentAfter, horizontal, vertical, aspectRatio = null) {
|
|
91
|
+
let x = constrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal);
|
|
92
|
+
let y = constrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical);
|
|
93
|
+
({x, y} = keepLockedRatio(x, y, horizontal, vertical, aspectRatio));
|
|
94
|
+
return {
|
|
95
|
+
x: Math.round(x.position),
|
|
96
|
+
y: Math.round(y.position),
|
|
97
|
+
width: Math.round(x.size),
|
|
98
|
+
height: Math.round(y.size)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function layoutConstrainedAxis(position, size, parentBefore, parentAfter, constraint) {
|
|
102
|
+
const delta = Math.round(parentAfter) - Math.round(parentBefore);
|
|
103
|
+
if (constraint === "MAX") return {
|
|
104
|
+
position: position + delta,
|
|
105
|
+
size
|
|
106
|
+
};
|
|
107
|
+
if (constraint === "CENTER") return {
|
|
108
|
+
position: position + Math.round(parentAfter / 2) - Math.round(parentBefore / 2),
|
|
109
|
+
size
|
|
110
|
+
};
|
|
111
|
+
if (constraint === "STRETCH") return {
|
|
112
|
+
position,
|
|
113
|
+
size: Math.abs(size + delta)
|
|
114
|
+
};
|
|
115
|
+
if (constraint === "SCALE" && parentBefore > 0) {
|
|
116
|
+
const scale = parentAfter / parentBefore;
|
|
117
|
+
return {
|
|
118
|
+
position: Math.round(position * scale * 128) / 128,
|
|
119
|
+
size: size * scale
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
position,
|
|
124
|
+
size
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Where a child goes when layout resizes its parent, as Figma places a layer that ignores auto
|
|
129
|
+
* layout when its Hug frame grows (measured on desktop 126): Right and Left & right move or grow
|
|
130
|
+
* it by the change in the parent's size rounded to whole pixels, Center by the change in its
|
|
131
|
+
* rounded half, and Scale by the exact ratio, its position to 1/128 of a pixel. Sizes are not
|
|
132
|
+
* rounded, so applying a run of changes one at a time lands where applying them at once does.
|
|
133
|
+
*/
|
|
134
|
+
function layoutConstrainedChildRect(child, parentBefore, parentAfter, horizontal, vertical, aspectRatio = null) {
|
|
135
|
+
const placed = keepLockedRatio(layoutConstrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal), layoutConstrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical), horizontal, vertical, aspectRatio);
|
|
136
|
+
return {
|
|
137
|
+
x: placed.x.position,
|
|
138
|
+
y: placed.y.position,
|
|
139
|
+
width: placed.x.size,
|
|
140
|
+
height: placed.y.size
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function scaledChildRect(child, parentBefore, parentAfter) {
|
|
144
|
+
return constrainedChildRect(child, parentBefore, parentAfter, "SCALE", "SCALE");
|
|
145
|
+
}
|
|
146
|
+
function scaleVectorNetworkForResize(vectorNetwork, originalWidth, originalHeight, width, height) {
|
|
147
|
+
if (!vectorNetwork || originalWidth <= 0 && originalHeight <= 0) return null;
|
|
148
|
+
const scaleX = originalWidth > 0 ? width / originalWidth : 1;
|
|
149
|
+
const scaleY = originalHeight > 0 ? height / originalHeight : 1;
|
|
150
|
+
if (scaleX === 1 && scaleY === 1) return null;
|
|
151
|
+
return {
|
|
152
|
+
vertices: vectorNetwork.vertices.map((vertex) => ({
|
|
153
|
+
...vertex,
|
|
154
|
+
x: vertex.x * scaleX,
|
|
155
|
+
y: vertex.y * scaleY
|
|
156
|
+
})),
|
|
157
|
+
segments: vectorNetwork.segments.map((segment) => ({
|
|
158
|
+
...segment,
|
|
159
|
+
tangentStart: {
|
|
160
|
+
x: segment.tangentStart.x * scaleX,
|
|
161
|
+
y: segment.tangentStart.y * scaleY
|
|
162
|
+
},
|
|
163
|
+
tangentEnd: {
|
|
164
|
+
x: segment.tangentEnd.x * scaleX,
|
|
165
|
+
y: segment.tangentEnd.y * scaleY
|
|
166
|
+
}
|
|
167
|
+
})),
|
|
168
|
+
regions: vectorNetwork.regions
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */
|
|
172
|
+
function createResizeSnapshot(node) {
|
|
173
|
+
return {
|
|
174
|
+
type: node.type,
|
|
175
|
+
x: node.x,
|
|
176
|
+
y: node.y,
|
|
177
|
+
width: node.width,
|
|
178
|
+
height: node.height,
|
|
179
|
+
vectorNetwork: node.vectorNetwork ? cloneVectorNetwork(node.vectorNetwork) : null,
|
|
180
|
+
fillGeometry: copyGeometryPaths(node.fillGeometry),
|
|
181
|
+
strokeGeometry: copyGeometryPaths(node.strokeGeometry),
|
|
182
|
+
derivedTextGlyphs: copyDerivedGlyphs(node.derivedTextGlyphs),
|
|
183
|
+
strokes: copyStrokes(node.strokes),
|
|
184
|
+
textPathData: node.textPathData ? structuredClone(node.textPathData) : null,
|
|
185
|
+
textPathBox: node.textPathBox ? { ...node.textPathBox } : null
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function scaleDerivedGlyphs(glyphs, sx, sy) {
|
|
189
|
+
if (!glyphs?.length) return glyphs;
|
|
190
|
+
return glyphs.map((g) => ({
|
|
191
|
+
...g,
|
|
192
|
+
x: g.x * sx,
|
|
193
|
+
y: g.y * sy,
|
|
194
|
+
scaleX: (g.scaleX ?? 1) * sx,
|
|
195
|
+
scaleY: (g.scaleY ?? 1) * sy,
|
|
196
|
+
commandsBlob: new Uint8Array(g.commandsBlob)
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
function hasPath(orig) {
|
|
200
|
+
return (orig.vectorNetwork?.segments.length ?? 0) > 0;
|
|
201
|
+
}
|
|
202
|
+
function scaleStrokes(strokes, sx, sy) {
|
|
203
|
+
if (strokes.length === 0) return strokes;
|
|
204
|
+
const weightScale = (Math.abs(sx) + Math.abs(sy)) / 2;
|
|
205
|
+
return strokes.map((s) => ({
|
|
206
|
+
...copyStroke(s),
|
|
207
|
+
weight: s.weight * weightScale
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* All geometry that must track a width/height change. Historically only
|
|
212
|
+
* vectorNetwork + fillGeometry were updated — path-text strokeGeometry and
|
|
213
|
+
* glyphs stayed at the pre-resize size, so shrinking a sticker made the white
|
|
214
|
+
* OUTSIDE outlines look massively thick (DomeSticker resize bug).
|
|
215
|
+
*/
|
|
216
|
+
function scaledGeometryChanges(orig, origWidth, origHeight, width, height) {
|
|
217
|
+
if (origWidth <= 0 || origHeight <= 0) return {};
|
|
218
|
+
const sx = width / origWidth;
|
|
219
|
+
const sy = height / origHeight;
|
|
220
|
+
if (sx === 1 && sy === 1) return {};
|
|
221
|
+
const changes = {};
|
|
222
|
+
const resizedVN = scaleVectorNetworkForResize(orig.vectorNetwork, origWidth, origHeight, width, height);
|
|
223
|
+
if (resizedVN) changes.vectorNetwork = resizedVN;
|
|
224
|
+
if (orig.fillGeometry.length > 0) changes.fillGeometry = scaleGeometryPaths(orig.fillGeometry, sx, sy);
|
|
225
|
+
const outlineOnly = orig.type === "TEXT" || orig.type === "VECTOR" && !hasPath(orig);
|
|
226
|
+
if (orig.strokeGeometry.length > 0) changes.strokeGeometry = outlineOnly ? scaleGeometryPaths(orig.strokeGeometry, sx, sy) : [];
|
|
227
|
+
const glyphs = orig.derivedTextGlyphs ?? [];
|
|
228
|
+
const pathText = !!orig.textPathData || !!orig.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0);
|
|
229
|
+
if (glyphs.length > 0 && pathText) {
|
|
230
|
+
changes.derivedTextGlyphs = scaleDerivedGlyphs(glyphs, sx, sy);
|
|
231
|
+
if (orig.textPathBox) changes.textPathBox = {
|
|
232
|
+
x: orig.textPathBox.x * sx,
|
|
233
|
+
y: orig.textPathBox.y * sy,
|
|
234
|
+
width: orig.textPathBox.width * sx,
|
|
235
|
+
height: orig.textPathBox.height * sy
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (orig.strokes.length > 0 && glyphs.length > 0 && pathText) changes.strokes = scaleStrokes(orig.strokes, sx, sy);
|
|
239
|
+
return changes;
|
|
240
|
+
}
|
|
241
|
+
function collectResizeDescendants(graph, rootId) {
|
|
242
|
+
const root = graph.getNode(rootId);
|
|
243
|
+
if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null;
|
|
244
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
245
|
+
const collect = (parentId) => {
|
|
246
|
+
const parent = graph.getNode(parentId);
|
|
247
|
+
if (!parent) return;
|
|
248
|
+
for (const childId of parent.childIds) {
|
|
249
|
+
const child = graph.getNode(childId);
|
|
250
|
+
if (!child) continue;
|
|
251
|
+
snapshots.set(childId, createResizeSnapshot(child));
|
|
252
|
+
collect(childId);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
collect(rootId);
|
|
256
|
+
return snapshots.size > 0 ? snapshots : null;
|
|
257
|
+
}
|
|
258
|
+
function computeConstrainedResizeChanges(graph, rootId, rootBefore, rootAfter, originals) {
|
|
259
|
+
const changes = /* @__PURE__ */ new Map();
|
|
260
|
+
const compute = (parentId, parentBefore, parentAfter) => {
|
|
261
|
+
const parent = graph.getNode(parentId);
|
|
262
|
+
if (!parent) return;
|
|
263
|
+
const scalesChildren = parent.type === "GROUP" || parent.type === "BOOLEAN_OPERATION";
|
|
264
|
+
for (const childId of parent.childIds) {
|
|
265
|
+
const original = originals.get(childId);
|
|
266
|
+
const child = graph.getNode(childId);
|
|
267
|
+
if (!original || !child) continue;
|
|
268
|
+
if (parent.layoutMode !== "NONE" && child.layoutPositioning !== "ABSOLUTE") {
|
|
269
|
+
compute(childId, original, child);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const rect = scalesChildren ? scaledChildRect(original, parentBefore, parentAfter) : constrainedChildRect(original, parentBefore, parentAfter, child.horizontalConstraint, child.verticalConstraint, enforcedAspectRatio(child));
|
|
273
|
+
const childChanges = {
|
|
274
|
+
...rect,
|
|
275
|
+
...scaledGeometryChanges(original, original.width, original.height, rect.width, rect.height)
|
|
276
|
+
};
|
|
277
|
+
changes.set(childId, childChanges);
|
|
278
|
+
compute(childId, original, child.layoutMode === "NONE" ? rect : child);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
compute(rootId, rootBefore, rootAfter);
|
|
282
|
+
return changes;
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, layoutConstrainedChildRect, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=resize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize.js","names":[],"sources":["../src/resize.ts"],"sourcesContent":["import {\n cloneVectorNetwork,\n copyDerivedGlyphs,\n copyGeometryPaths,\n copyStroke,\n copyStrokes,\n scaleGeometryPaths\n} from './copy'\nimport { enforcedAspectRatio } from './layout/aspect-ratio'\nimport type { Rect } from './primitives'\nimport type { ConstraintType, DerivedTextGlyph, SceneNode, Stroke, VectorNetwork } from './types'\n\n/**\n * Drag-start state a live resize re-scales from. Path text needs more than the\n * layout rect: its OUTSIDE stroke silhouettes and glyph outlines are baked\n * geometry that must scale with the node, and textPathBox is the layout box the\n * glyphs were reflowed against.\n */\nexport type ResizeSnapshot = Pick<\n SceneNode,\n | 'type'\n | 'x'\n | 'y'\n | 'width'\n | 'height'\n | 'vectorNetwork'\n | 'fillGeometry'\n | 'strokeGeometry'\n | 'derivedTextGlyphs'\n | 'strokes'\n | 'textPathData'\n | 'textPathBox'\n>\n\ninterface ResizeGraph {\n getNode(id: string): SceneNode | undefined\n}\n\nconst CONSTRAINT_CONTAINER_TYPES = new Set([\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE',\n 'GROUP',\n 'BOOLEAN_OPERATION'\n])\n\nfunction constrainedAxis(\n position: number,\n size: number,\n parentBefore: number,\n parentAfter: number,\n constraint: ConstraintType\n): { position: number; size: number } {\n const delta = parentAfter - parentBefore\n if (constraint === 'MAX') return { position: position + delta, size }\n if (constraint === 'CENTER') return { position: position + delta / 2, size }\n if (constraint === 'STRETCH') return { position, size: Math.max(1, size + delta) }\n if (constraint === 'SCALE' && parentBefore > 0) {\n const scale = parentAfter / parentBefore\n return { position: position * scale, size: Math.max(1, size * scale) }\n }\n return { position, size }\n}\n\ntype AxisPlacement = { position: number; size: number }\n\nconst FLEXIBLE_CONSTRAINTS: ReadonlySet<ConstraintType> = new Set(['STRETCH', 'SCALE'])\n\n/** The axis at `size`, keeping the edge or centre its constraint pins where it was placed. */\nfunction resizedInPlace(\n placed: AxisPlacement,\n size: number,\n constraint: ConstraintType\n): AxisPlacement {\n if (constraint === 'MAX') return { position: placed.position + placed.size - size, size }\n if (constraint === 'CENTER') return { position: placed.position + (placed.size - size) / 2, size }\n return { position: placed.position, size }\n}\n\n/** Keep a placed box's constrained edges or center when its content determines its size. */\nexport function resizedChildRect(\n placed: Rect,\n size: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType\n): Rect {\n const x = resizedInPlace({ position: placed.x, size: placed.width }, size.width, horizontal)\n const y = resizedInPlace({ position: placed.y, size: placed.height }, size.height, vertical)\n return { x: x.position, y: y.position, width: x.size, height: y.size }\n}\n\n/**\n * A locked aspect ratio holds when exactly one axis follows the parent, as in Figma: that axis\n * sizes the other. With both axes following the parent, or neither, the ratio gives way.\n */\nfunction keepLockedRatio(\n x: AxisPlacement,\n y: AxisPlacement,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null\n): { x: AxisPlacement; y: AxisPlacement } {\n const flexibleX = FLEXIBLE_CONSTRAINTS.has(horizontal)\n if (aspectRatio === null || flexibleX === FLEXIBLE_CONSTRAINTS.has(vertical)) return { x, y }\n return flexibleX\n ? { x, y: resizedInPlace(y, x.size / aspectRatio, vertical) }\n : { x: resizedInPlace(x, y.size * aspectRatio, horizontal), y }\n}\n\n/** A child's box after its parent resizes, keeping a locked aspect ratio as Figma does. */\nexport function constrainedChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null = null\n): Rect {\n let x = constrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal)\n let y = constrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical)\n ;({ x, y } = keepLockedRatio(x, y, horizontal, vertical, aspectRatio))\n return {\n x: Math.round(x.position),\n y: Math.round(y.position),\n width: Math.round(x.size),\n height: Math.round(y.size)\n }\n}\n\nfunction layoutConstrainedAxis(\n position: number,\n size: number,\n parentBefore: number,\n parentAfter: number,\n constraint: ConstraintType\n): { position: number; size: number } {\n const delta = Math.round(parentAfter) - Math.round(parentBefore)\n if (constraint === 'MAX') return { position: position + delta, size }\n if (constraint === 'CENTER') {\n return { position: position + Math.round(parentAfter / 2) - Math.round(parentBefore / 2), size }\n }\n if (constraint === 'STRETCH') return { position, size: Math.abs(size + delta) }\n if (constraint === 'SCALE' && parentBefore > 0) {\n const scale = parentAfter / parentBefore\n return { position: Math.round(position * scale * 128) / 128, size: size * scale }\n }\n return { position, size }\n}\n\n/**\n * Where a child goes when layout resizes its parent, as Figma places a layer that ignores auto\n * layout when its Hug frame grows (measured on desktop 126): Right and Left & right move or grow\n * it by the change in the parent's size rounded to whole pixels, Center by the change in its\n * rounded half, and Scale by the exact ratio, its position to 1/128 of a pixel. Sizes are not\n * rounded, so applying a run of changes one at a time lands where applying them at once does.\n */\nexport function layoutConstrainedChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>,\n horizontal: ConstraintType,\n vertical: ConstraintType,\n aspectRatio: number | null = null\n): Rect {\n const placed = keepLockedRatio(\n layoutConstrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal),\n layoutConstrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical),\n horizontal,\n vertical,\n aspectRatio\n )\n return {\n x: placed.x.position,\n y: placed.y.position,\n width: placed.x.size,\n height: placed.y.size\n }\n}\n\nexport function scaledChildRect(\n child: Rect,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>\n): Rect {\n return constrainedChildRect(child, parentBefore, parentAfter, 'SCALE', 'SCALE')\n}\n\nexport function scaleVectorNetworkForResize(\n vectorNetwork: VectorNetwork | null,\n originalWidth: number,\n originalHeight: number,\n width: number,\n height: number\n): VectorNetwork | null {\n if (!vectorNetwork || (originalWidth <= 0 && originalHeight <= 0)) return null\n\n // A flat side, as a straight line's, has nothing to scale along it.\n const scaleX = originalWidth > 0 ? width / originalWidth : 1\n const scaleY = originalHeight > 0 ? height / originalHeight : 1\n if (scaleX === 1 && scaleY === 1) return null\n\n return {\n vertices: vectorNetwork.vertices.map((vertex) => ({\n ...vertex,\n x: vertex.x * scaleX,\n y: vertex.y * scaleY\n })),\n segments: vectorNetwork.segments.map((segment) => ({\n ...segment,\n tangentStart: {\n x: segment.tangentStart.x * scaleX,\n y: segment.tangentStart.y * scaleY\n },\n tangentEnd: {\n x: segment.tangentEnd.x * scaleX,\n y: segment.tangentEnd.y * scaleY\n }\n })),\n regions: vectorNetwork.regions\n }\n}\n\n/** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */\nexport function createResizeSnapshot(node: SceneNode): ResizeSnapshot {\n return {\n type: node.type,\n x: node.x,\n y: node.y,\n width: node.width,\n height: node.height,\n vectorNetwork: node.vectorNetwork ? cloneVectorNetwork(node.vectorNetwork) : null,\n fillGeometry: copyGeometryPaths(node.fillGeometry),\n strokeGeometry: copyGeometryPaths(node.strokeGeometry),\n derivedTextGlyphs: copyDerivedGlyphs(node.derivedTextGlyphs),\n strokes: copyStrokes(node.strokes),\n textPathData: node.textPathData ? structuredClone(node.textPathData) : null,\n textPathBox: node.textPathBox ? { ...node.textPathBox } : null\n }\n}\n\nfunction scaleDerivedGlyphs(\n glyphs: DerivedTextGlyph[] | null,\n sx: number,\n sy: number\n): DerivedTextGlyph[] | null {\n if (!glyphs?.length) return glyphs\n return glyphs.map((g) => ({\n ...g,\n x: g.x * sx,\n y: g.y * sy,\n scaleX: (g.scaleX ?? 1) * sx,\n scaleY: (g.scaleY ?? 1) * sy,\n commandsBlob: new Uint8Array(g.commandsBlob)\n }))\n}\n\nfunction hasPath(orig: Pick<ResizeSnapshot, 'vectorNetwork'>): boolean {\n return (orig.vectorNetwork?.segments.length ?? 0) > 0\n}\n\nfunction scaleStrokes(strokes: Stroke[], sx: number, sy: number): Stroke[] {\n if (strokes.length === 0) return strokes\n // Weight is a scalar; average scale is the usual 2D → 1D compromise.\n const weightScale = (Math.abs(sx) + Math.abs(sy)) / 2\n return strokes.map((s) => ({ ...copyStroke(s), weight: s.weight * weightScale }))\n}\n\n/**\n * All geometry that must track a width/height change. Historically only\n * vectorNetwork + fillGeometry were updated — path-text strokeGeometry and\n * glyphs stayed at the pre-resize size, so shrinking a sticker made the white\n * OUTSIDE outlines look massively thick (DomeSticker resize bug).\n */\nexport function scaledGeometryChanges(\n orig: Pick<\n ResizeSnapshot,\n | 'type'\n | 'vectorNetwork'\n | 'fillGeometry'\n | 'strokeGeometry'\n | 'derivedTextGlyphs'\n | 'strokes'\n | 'textPathData'\n | 'textPathBox'\n >,\n origWidth: number,\n origHeight: number,\n width: number,\n height: number\n): Partial<SceneNode> {\n if (origWidth <= 0 || origHeight <= 0) return {}\n const sx = width / origWidth\n const sy = height / origHeight\n if (sx === 1 && sy === 1) return {}\n\n const changes: Partial<SceneNode> = {}\n const resizedVN = scaleVectorNetworkForResize(\n orig.vectorNetwork,\n origWidth,\n origHeight,\n width,\n height\n )\n if (resizedVN) changes.vectorNetwork = resizedVN\n\n if (orig.fillGeometry.length > 0) {\n changes.fillGeometry = scaleGeometryPaths(orig.fillGeometry, sx, sy)\n }\n // A stroke keeps its weight through a resize, as in Figma, so a saved stroke outline goes where\n // the stroke can be drawn again at its weight: from a path, or from a shape's own outline.\n // Text and a vector with only its outline keep scaling the outline, which is all they have.\n const outlineOnly = orig.type === 'TEXT' || (orig.type === 'VECTOR' && !hasPath(orig))\n if (orig.strokeGeometry.length > 0) {\n changes.strokeGeometry = outlineOnly ? scaleGeometryPaths(orig.strokeGeometry, sx, sy) : []\n }\n // Path text scales with its path, including baked path text that kept only rotated glyphs;\n // other text reflows in the new box, so its glyphs are dropped.\n const glyphs = orig.derivedTextGlyphs ?? []\n const pathText =\n !!orig.textPathData || !!orig.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0)\n if (glyphs.length > 0 && pathText) {\n changes.derivedTextGlyphs = scaleDerivedGlyphs(glyphs, sx, sy)\n // Keep the layout/selection box in sync with the scaled glyphs. reflow\n // overrides this when it applies; this covers the fallback where reflow\n // returns null (no path data) so the box doesn't carry a stale size.\n if (orig.textPathBox) {\n changes.textPathBox = {\n x: orig.textPathBox.x * sx,\n y: orig.textPathBox.y * sy,\n width: orig.textPathBox.width * sx,\n height: orig.textPathBox.height * sy\n }\n }\n }\n // Glyphs scaled as a picture take their strokes along; any other stroke keeps its weight, as\n // Figma reports it, even where only a scaled outline can draw it.\n if (orig.strokes.length > 0 && glyphs.length > 0 && pathText) {\n changes.strokes = scaleStrokes(orig.strokes, sx, sy)\n }\n return changes\n}\n\nexport function collectResizeDescendants(\n graph: ResizeGraph,\n rootId: string\n): Map<string, ResizeSnapshot> | null {\n const root = graph.getNode(rootId)\n if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null\n const snapshots = new Map<string, ResizeSnapshot>()\n\n const collect = (parentId: string) => {\n const parent = graph.getNode(parentId)\n if (!parent) return\n for (const childId of parent.childIds) {\n const child = graph.getNode(childId)\n if (!child) continue\n snapshots.set(childId, createResizeSnapshot(child))\n collect(childId)\n }\n }\n\n collect(rootId)\n return snapshots.size > 0 ? snapshots : null\n}\n\nexport function computeConstrainedResizeChanges(\n graph: ResizeGraph,\n rootId: string,\n rootBefore: Pick<Rect, 'width' | 'height'>,\n rootAfter: Pick<Rect, 'width' | 'height'>,\n originals: ReadonlyMap<string, ResizeSnapshot>\n): Map<string, Partial<SceneNode>> {\n const changes = new Map<string, Partial<SceneNode>>()\n\n const compute = (\n parentId: string,\n parentBefore: Pick<Rect, 'width' | 'height'>,\n parentAfter: Pick<Rect, 'width' | 'height'>\n ) => {\n const parent = graph.getNode(parentId)\n if (!parent) return\n const scalesChildren = parent.type === 'GROUP' || parent.type === 'BOOLEAN_OPERATION'\n for (const childId of parent.childIds) {\n const original = originals.get(childId)\n const child = graph.getNode(childId)\n if (!original || !child) continue\n const isInFlow = parent.layoutMode !== 'NONE' && child.layoutPositioning !== 'ABSOLUTE'\n if (isInFlow) {\n compute(childId, original, child)\n continue\n }\n const rect = scalesChildren\n ? scaledChildRect(original, parentBefore, parentAfter)\n : constrainedChildRect(\n original,\n parentBefore,\n parentAfter,\n child.horizontalConstraint,\n child.verticalConstraint,\n enforcedAspectRatio(child)\n )\n const childChanges: Partial<SceneNode> = {\n ...rect,\n ...scaledGeometryChanges(original, original.width, original.height, rect.width, rect.height)\n }\n changes.set(childId, childChanges)\n // The final pass sees layout containers after Yoga has resolved HUG/FILL sizing.\n compute(childId, original, child.layoutMode === 'NONE' ? rect : child)\n }\n }\n\n compute(rootId, rootBefore, rootAfter)\n return changes\n}\n"],"mappings":";;;AAsCA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,gBACP,UACA,MACA,cACA,aACA,YACoC;CACpC,MAAM,QAAQ,cAAc;CAC5B,IAAI,eAAe,OAAO,OAAO;EAAE,UAAU,WAAW;EAAO;CAAK;CACpE,IAAI,eAAe,UAAU,OAAO;EAAE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OAAO,SAAS,WAAW,OAAO,SAAS;EAClE,KAAK,MAAM,WAAW,OAAO,UAAU;GACrC,MAAM,WAAW,UAAU,IAAI,OAAO;GACtC,MAAM,QAAQ,MAAM,QAAQ,OAAO;GACnC,IAAI,CAAC,YAAY,CAAC,OAAO;GAEzB,IADiB,OAAO,eAAe,UAAU,MAAM,sBAAsB,YAC/D;IACZ,QAAQ,SAAS,UAAU,KAAK;IAChC;GACF;GACA,MAAM,OAAO,iBACT,gBAAgB,UAAU,cAAc,WAAW,IACnD,qBACE,UACA,cACA,aACA,MAAM,sBACN,MAAM,oBACN,oBAAoB,KAAK,CAC3B;GACJ,MAAM,eAAmC;IACvC,GAAG;IACH,GAAG,sBAAsB,UAAU,SAAS,OAAO,SAAS,QAAQ,KAAK,OAAO,KAAK,MAAM;GAC7F;GACA,QAAQ,IAAI,SAAS,YAAY;GAEjC,QAAQ,SAAS,UAAU,MAAM,eAAe,SAAS,OAAO,KAAK;EACvE;CACF;CAEA,QAAQ,QAAQ,YAAY,SAAS;CACrC,OAAO;AACT"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SceneNode } from "../types.js";
|
|
2
|
+
//#region src/scaling/node.d.ts
|
|
3
|
+
declare function scaleNodeChanges(node: SceneNode, scale: number, scalePosition: boolean): Partial<SceneNode>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { scaleNodeChanges };
|
|
6
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","names":[],"sources":["../../src/scaling/node.ts"],"mappings":";;iBAiHgB,iBACd,MAAM,WACN,eACA,yBACC,QAAQ"}
|