@pairdraw/scene-graph 0.0.0-stage → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/agent-notes/index.d.ts +3 -0
- package/dist/agent-notes/index.js +3 -0
- package/dist/agent-notes/model.d.ts +23 -0
- package/dist/agent-notes/model.d.ts.map +1 -0
- package/dist/agent-notes/model.js +36 -0
- package/dist/agent-notes/model.js.map +1 -0
- package/dist/agent-notes/schema.d.ts +19 -0
- package/dist/agent-notes/schema.d.ts.map +1 -0
- package/dist/agent-notes/schema.js +17 -0
- package/dist/agent-notes/schema.js.map +1 -0
- package/dist/arrow-caps.d.ts +65 -0
- package/dist/arrow-caps.d.ts.map +1 -0
- package/dist/arrow-caps.js +365 -0
- package/dist/arrow-caps.js.map +1 -0
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js +27 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +56 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/behaviours/kinds.js +273 -0
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +42 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +45 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +149 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +114 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +71 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/behaviours/spec.js +157 -0
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +18 -0
- package/dist/bindings.js.map +1 -0
- package/dist/browser-node/index.d.ts +3 -0
- package/dist/browser-node/index.js +3 -0
- package/dist/browser-node/model.d.ts +18 -0
- package/dist/browser-node/model.d.ts.map +1 -0
- package/dist/browser-node/model.js +31 -0
- package/dist/browser-node/model.js.map +1 -0
- package/dist/browser-node/schema.d.ts +23 -0
- package/dist/browser-node/schema.d.ts.map +1 -0
- package/dist/browser-node/schema.js +44 -0
- package/dist/browser-node/schema.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js +57 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +28 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +246 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +20 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/color/contrast.js +69 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/comments/document.js +33 -0
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/comments/merge.js +58 -0
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/comments/threads.js +132 -0
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/library-page.d.ts +11 -0
- package/dist/components/library-page.d.ts.map +1 -0
- package/dist/components/library-page.js +21 -0
- package/dist/components/library-page.js.map +1 -0
- package/dist/components/properties.d.ts +20 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +125 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +27 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +32 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +53 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +159 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +209 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +99 -0
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +276 -0
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +45 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +256 -0
- package/dist/copy.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/css/grid.js +63 -0
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +6 -0
- package/dist/css/index.js +6 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/events.js +18 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +19 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +33 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js +14 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +63 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +199 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +277 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +68 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +89 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +46 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +62 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +29 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +38 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +119 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +234 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +105 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +374 -0
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +74 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +211 -0
- package/dist/gradient.js.map +1 -0
- package/dist/graph.d.ts +186 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +630 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/group-bounds.js +146 -0
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +19 -0
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +39 -0
- package/dist/guides.js.map +1 -0
- package/dist/hit-test.d.ts +49 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +315 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/icons/glyph.js +109 -0
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +85 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +162 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +82 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +63 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +305 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/main-component.d.ts +11 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +42 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/modes.js +26 -0
- package/dist/instances/modes.js.map +1 -0
- package/dist/instances/overrides.d.ts +63 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +164 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/replacements.d.ts +19 -0
- package/dist/instances/replacements.d.ts.map +1 -0
- package/dist/instances/replacements.js +67 -0
- package/dist/instances/replacements.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/sync.js +305 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +60 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +120 -0
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/naming.d.ts +9 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +16 -0
- package/dist/naming.js.map +1 -0
- package/dist/node-defaults.d.ts +19 -0
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +243 -0
- package/dist/node-defaults.js.map +1 -0
- package/dist/order-keys.d.ts +39 -0
- package/dist/order-keys.d.ts.map +1 -0
- package/dist/order-keys.js +136 -0
- package/dist/order-keys.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +103 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +64 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +36 -0
- package/dist/parse-path.d.ts.map +1 -0
- package/dist/parse-path.js +200 -0
- package/dist/parse-path.js.map +1 -0
- package/dist/plugin-data/citation.d.ts +13 -0
- package/dist/plugin-data/citation.d.ts.map +1 -0
- package/dist/plugin-data/citation.js +23 -0
- package/dist/plugin-data/citation.js.map +1 -0
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +79 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +220 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +214 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +5 -0
- package/dist/plugin-data/index.js +5 -0
- package/dist/plugin-data/schema.d.ts +18 -0
- package/dist/plugin-data/schema.d.ts.map +1 -0
- package/dist/plugin-data/schema.js +29 -0
- package/dist/plugin-data/schema.js.map +1 -0
- package/dist/polygon.d.ts +55 -0
- package/dist/polygon.d.ts.map +1 -0
- package/dist/polygon.js +220 -0
- package/dist/polygon.js.map +1 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +63 -0
- package/dist/preview.js.map +1 -0
- package/dist/primitives/index.d.ts +43 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.d.ts +7 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +25 -0
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +41 -0
- package/dist/resize.d.ts.map +1 -0
- package/dist/resize.js +288 -0
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +150 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +22 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +71 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/script/index.d.ts +2 -0
- package/dist/script/index.js +2 -0
- package/dist/script/schema.d.ts +29 -0
- package/dist/script/schema.d.ts.map +1 -0
- package/dist/script/schema.js +51 -0
- package/dist/script/schema.js.map +1 -0
- package/dist/shaders/directives.d.ts +43 -0
- package/dist/shaders/directives.d.ts.map +1 -0
- package/dist/shaders/directives.js +293 -0
- package/dist/shaders/directives.js.map +1 -0
- package/dist/shaders/index.d.ts +5 -0
- package/dist/shaders/index.js +5 -0
- package/dist/shaders/model.d.ts +58 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +109 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +86 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +65 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +36 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +116 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +74 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +103 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +38 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +113 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +61 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +264 -0
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.d.ts +6 -0
- package/dist/source-metadata.d.ts.map +1 -0
- package/dist/source-metadata.js +11 -0
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/text/direction.d.ts +13 -0
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/text/direction.js +31 -0
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +19 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +40 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/text/picture.d.ts +18 -0
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +41 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +7 -0
- package/dist/transfer/index.js +7 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +82 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +910 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +89 -0
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +236 -0
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +66 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +251 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +30 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +89 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +246 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +21 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +58 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/variant-name.d.ts +6 -0
- package/dist/variant-name.d.ts.map +1 -0
- package/dist/variant-name.js +17 -0
- package/dist/variant-name.js.map +1 -0
- package/dist/variant-properties.d.ts +18 -0
- package/dist/variant-properties.d.ts.map +1 -0
- package/dist/variant-properties.js +74 -0
- package/dist/variant-properties.js.map +1 -0
- package/dist/vector-network.d.ts +48 -0
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +352 -0
- package/dist/vector-network.js.map +1 -0
- package/package.json +364 -4
- package/src/agent-notes/index.ts +2 -0
- package/src/agent-notes/model.ts +46 -0
- package/src/agent-notes/schema.ts +28 -0
- package/src/arrow-caps.ts +364 -0
- package/src/asset-keys.ts +25 -0
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +185 -0
- package/src/behaviours/layers.ts +51 -0
- package/src/behaviours/model.ts +184 -0
- package/src/behaviours/schema.ts +93 -0
- package/src/behaviours/spec.ts +178 -0
- package/src/bindings.ts +20 -0
- package/src/browser-node/index.ts +2 -0
- package/src/browser-node/model.ts +35 -0
- package/src/browser-node/schema.ts +62 -0
- package/src/buffered-events.ts +64 -0
- package/src/checkpoint.ts +325 -0
- package/src/clipping.ts +112 -0
- package/src/color/contrast.ts +71 -0
- package/src/color/index.ts +89 -0
- package/src/color/management.ts +210 -0
- package/src/color/normalize.ts +7 -0
- package/src/color/okhcl.ts +201 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +51 -0
- package/src/comments/index.ts +5 -0
- package/src/comments/list.ts +52 -0
- package/src/comments/merge.ts +63 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +156 -0
- package/src/components/exposure.ts +61 -0
- package/src/components/index.ts +9 -0
- package/src/components/library-page.ts +17 -0
- package/src/components/properties.ts +241 -0
- package/src/components/variants.ts +53 -0
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +60 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +144 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +204 -0
- package/src/constants.ts +13 -0
- package/src/coordinate.ts +298 -0
- package/src/copy.ts +341 -0
- package/src/css/grid.ts +70 -0
- package/src/css/index.ts +10 -0
- package/src/css/layout.ts +53 -0
- package/src/css/shadows.ts +68 -0
- package/src/css/text.ts +84 -0
- package/src/css/values.ts +42 -0
- package/src/events.ts +21 -0
- package/src/export-format.ts +33 -0
- package/src/export-scale.ts +16 -0
- package/src/fields/appearance.ts +35 -0
- package/src/fields/geometry.ts +11 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +64 -0
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +308 -0
- package/src/figjam/text.ts +78 -0
- package/src/font-style.ts +121 -0
- package/src/generated/index.ts +81 -0
- package/src/generated/kind.ts +26 -0
- package/src/generated/shape-with-text.ts +132 -0
- package/src/generated/sticky.ts +214 -0
- package/src/geometry.ts +490 -0
- package/src/gradient.ts +275 -0
- package/src/graph.ts +842 -0
- package/src/group-bounds.ts +178 -0
- package/src/guides.ts +47 -0
- package/src/hit-test.ts +501 -0
- package/src/icons/glyph.ts +128 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +63 -0
- package/src/icons/schema.ts +34 -0
- package/src/ids.ts +34 -0
- package/src/images.ts +89 -0
- package/src/index.ts +4 -0
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +84 -0
- package/src/instances/copies.ts +244 -0
- package/src/instances/cycles.ts +73 -0
- package/src/instances/fields.ts +90 -0
- package/src/instances/index.ts +467 -0
- package/src/instances/main-component.ts +61 -0
- package/src/instances/modes.ts +39 -0
- package/src/instances/overrides.ts +240 -0
- package/src/instances/placement.ts +29 -0
- package/src/instances/replacements.ts +80 -0
- package/src/instances/source-walk.ts +35 -0
- package/src/instances/sync.ts +556 -0
- package/src/instances/vector-geometry.ts +81 -0
- package/src/layout/aspect-ratio.ts +51 -0
- package/src/layout/guides.ts +132 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/keywords.ts +74 -0
- package/src/layout/sizing.ts +196 -0
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +116 -0
- package/src/mutation-impact.ts +85 -0
- package/src/naming.ts +11 -0
- package/src/node-defaults.ts +260 -0
- package/src/order-keys.ts +162 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +72 -0
- package/src/parse-path.ts +244 -0
- package/src/plugin-data/citation.ts +27 -0
- package/src/plugin-data/field.ts +140 -0
- package/src/plugin-data/fields.ts +306 -0
- package/src/plugin-data/index.ts +3 -0
- package/src/plugin-data/schema.ts +35 -0
- package/src/polygon.ts +228 -0
- package/src/preview.ts +80 -0
- package/src/primitives/index.ts +44 -0
- package/src/primitives/schema.ts +14 -0
- package/src/random.ts +28 -0
- package/src/resize.ts +415 -0
- package/src/scaling/index.ts +9 -0
- package/src/scaling/node.ts +168 -0
- package/src/scaling/tree.ts +85 -0
- package/src/script/index.ts +1 -0
- package/src/script/schema.ts +65 -0
- package/src/shaders/directives.ts +366 -0
- package/src/shaders/index.ts +4 -0
- package/src/shaders/model.ts +147 -0
- package/src/shaders/schema.ts +84 -0
- package/src/shaders/still.ts +41 -0
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +137 -0
- package/src/slots/authoring.ts +101 -0
- package/src/slots/content.ts +127 -0
- package/src/slots/frames.ts +160 -0
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +49 -0
- package/src/snap.ts +349 -0
- package/src/source-metadata.ts +8 -0
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/direction.ts +55 -0
- package/src/text/index.ts +6 -0
- package/src/text/lengths.ts +34 -0
- package/src/text/lists.ts +138 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/paragraphs.ts +241 -0
- package/src/text/picture.ts +57 -0
- package/src/text/references.ts +50 -0
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +84 -0
- package/src/transfer/history.ts +49 -0
- package/src/transfer/identity.ts +16 -0
- package/src/transfer/index.ts +6 -0
- package/src/transfer/nodes.ts +128 -0
- package/src/transfer/plan.ts +130 -0
- package/src/transfer/references.ts +9 -0
- package/src/transfer/remove.ts +39 -0
- package/src/transfer/validation.ts +59 -0
- package/src/transfer/variables.ts +83 -0
- package/src/types.ts +1205 -0
- package/src/undo.ts +285 -0
- package/src/variables/bindings.ts +310 -0
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +109 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/variables/index.ts +400 -0
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +61 -0
- package/src/variables/token.ts +40 -0
- package/src/variables/units.ts +15 -0
- package/src/variables/value.ts +92 -0
- package/src/variant-name.ts +15 -0
- package/src/variant-properties.ts +98 -0
- package/src/vector-network.ts +489 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface GUID {
|
|
2
|
+
sessionID: number
|
|
3
|
+
localID: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Color {
|
|
7
|
+
r: number
|
|
8
|
+
g: number
|
|
9
|
+
b: number
|
|
10
|
+
a: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Vector {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Matrix {
|
|
19
|
+
m00: number
|
|
20
|
+
m01: number
|
|
21
|
+
m02: number
|
|
22
|
+
m10: number
|
|
23
|
+
m11: number
|
|
24
|
+
m12: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Size {
|
|
28
|
+
width: number
|
|
29
|
+
height: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Rect {
|
|
33
|
+
x: number
|
|
34
|
+
y: number
|
|
35
|
+
width: number
|
|
36
|
+
height: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type JSONPrimitive = string | number | boolean | null
|
|
40
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONArray
|
|
41
|
+
export type JSONObject = { [key: string]: unknown }
|
|
42
|
+
export type JSONArray = unknown[]
|
|
43
|
+
|
|
44
|
+
export * from './schema'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
export const finiteNumberSchema = v.pipe(v.number(), v.finite())
|
|
4
|
+
|
|
5
|
+
export const vectorSchema = v.object({ x: finiteNumberSchema, y: finiteNumberSchema })
|
|
6
|
+
|
|
7
|
+
export const matrixSchema = v.object({
|
|
8
|
+
m00: finiteNumberSchema,
|
|
9
|
+
m01: finiteNumberSchema,
|
|
10
|
+
m02: finiteNumberSchema,
|
|
11
|
+
m10: finiteNumberSchema,
|
|
12
|
+
m11: finiteNumberSchema,
|
|
13
|
+
m12: finiteNumberSchema
|
|
14
|
+
})
|
package/src/random.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function randomHex(bytes = 16): string {
|
|
2
|
+
if (!Number.isInteger(bytes) || bytes < 0) {
|
|
3
|
+
throw new RangeError('bytes must be a non-negative integer')
|
|
4
|
+
}
|
|
5
|
+
const buf = crypto.getRandomValues(new Uint8Array(bytes))
|
|
6
|
+
let hex = ''
|
|
7
|
+
for (const b of buf) hex += b.toString(16).padStart(2, '0')
|
|
8
|
+
return hex
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function randomInt(): number {
|
|
12
|
+
return crypto.getRandomValues(new Int32Array(1))[0]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function randomIndex(length: number): number {
|
|
16
|
+
if (!Number.isInteger(length) || length <= 0) {
|
|
17
|
+
throw new RangeError('length must be a positive integer')
|
|
18
|
+
}
|
|
19
|
+
const max = 0x1_0000_0000
|
|
20
|
+
const limit = max - (max % length)
|
|
21
|
+
const buffer = new Uint32Array(1)
|
|
22
|
+
|
|
23
|
+
do {
|
|
24
|
+
crypto.getRandomValues(buffer)
|
|
25
|
+
} while (buffer[0] >= limit)
|
|
26
|
+
|
|
27
|
+
return buffer[0] % length
|
|
28
|
+
}
|
package/src/resize.ts
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copyDerivedGlyphs,
|
|
3
|
+
copyGeometryPaths,
|
|
4
|
+
copyStroke,
|
|
5
|
+
copyStrokes,
|
|
6
|
+
scaleGeometryPaths
|
|
7
|
+
} from './copy'
|
|
8
|
+
import { enforcedAspectRatio } from './layout/aspect-ratio'
|
|
9
|
+
import type { Rect } from './primitives'
|
|
10
|
+
import type { ConstraintType, DerivedTextGlyph, SceneNode, Stroke, VectorNetwork } from './types'
|
|
11
|
+
import { cloneVectorNetwork } from './vector-network'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Drag-start state a live resize re-scales from. Path text needs more than the
|
|
15
|
+
* layout rect: its OUTSIDE stroke silhouettes and glyph outlines are baked
|
|
16
|
+
* geometry that must scale with the node, and textPathBox is the layout box the
|
|
17
|
+
* glyphs were reflowed against.
|
|
18
|
+
*/
|
|
19
|
+
export type ResizeSnapshot = Pick<
|
|
20
|
+
SceneNode,
|
|
21
|
+
| 'type'
|
|
22
|
+
| 'x'
|
|
23
|
+
| 'y'
|
|
24
|
+
| 'width'
|
|
25
|
+
| 'height'
|
|
26
|
+
| 'vectorNetwork'
|
|
27
|
+
| 'fillGeometry'
|
|
28
|
+
| 'strokeGeometry'
|
|
29
|
+
| 'derivedTextGlyphs'
|
|
30
|
+
| 'strokes'
|
|
31
|
+
| 'textPathData'
|
|
32
|
+
| 'textPathBox'
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
interface ResizeGraph {
|
|
36
|
+
getNode(id: string): SceneNode | undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const CONSTRAINT_CONTAINER_TYPES = new Set([
|
|
40
|
+
'FRAME',
|
|
41
|
+
'COMPONENT',
|
|
42
|
+
'COMPONENT_SET',
|
|
43
|
+
'INSTANCE',
|
|
44
|
+
'GROUP',
|
|
45
|
+
'BOOLEAN_OPERATION'
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
function constrainedAxis(
|
|
49
|
+
position: number,
|
|
50
|
+
size: number,
|
|
51
|
+
parentBefore: number,
|
|
52
|
+
parentAfter: number,
|
|
53
|
+
constraint: ConstraintType
|
|
54
|
+
): { position: number; size: number } {
|
|
55
|
+
const delta = parentAfter - parentBefore
|
|
56
|
+
if (constraint === 'MAX') return { position: position + delta, size }
|
|
57
|
+
if (constraint === 'CENTER') return { position: position + delta / 2, size }
|
|
58
|
+
if (constraint === 'STRETCH') return { position, size: Math.max(1, size + delta) }
|
|
59
|
+
if (constraint === 'SCALE' && parentBefore > 0) {
|
|
60
|
+
const scale = parentAfter / parentBefore
|
|
61
|
+
return { position: position * scale, size: Math.max(1, size * scale) }
|
|
62
|
+
}
|
|
63
|
+
return { position, size }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type AxisPlacement = { position: number; size: number }
|
|
67
|
+
|
|
68
|
+
const FLEXIBLE_CONSTRAINTS: ReadonlySet<ConstraintType> = new Set(['STRETCH', 'SCALE'])
|
|
69
|
+
|
|
70
|
+
/** The axis at `size`, keeping the edge or centre its constraint pins where it was placed. */
|
|
71
|
+
function resizedInPlace(
|
|
72
|
+
placed: AxisPlacement,
|
|
73
|
+
size: number,
|
|
74
|
+
constraint: ConstraintType
|
|
75
|
+
): AxisPlacement {
|
|
76
|
+
if (constraint === 'MAX') return { position: placed.position + placed.size - size, size }
|
|
77
|
+
if (constraint === 'CENTER') return { position: placed.position + (placed.size - size) / 2, size }
|
|
78
|
+
return { position: placed.position, size }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Keep a placed box's constrained edges or center when its content determines its size. */
|
|
82
|
+
export function resizedChildRect(
|
|
83
|
+
placed: Rect,
|
|
84
|
+
size: Pick<Rect, 'width' | 'height'>,
|
|
85
|
+
horizontal: ConstraintType,
|
|
86
|
+
vertical: ConstraintType
|
|
87
|
+
): Rect {
|
|
88
|
+
const x = resizedInPlace({ position: placed.x, size: placed.width }, size.width, horizontal)
|
|
89
|
+
const y = resizedInPlace({ position: placed.y, size: placed.height }, size.height, vertical)
|
|
90
|
+
return { x: x.position, y: y.position, width: x.size, height: y.size }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A locked aspect ratio holds when exactly one axis follows the parent, as in Figma: that axis
|
|
95
|
+
* sizes the other. With both axes following the parent, or neither, the ratio gives way.
|
|
96
|
+
*/
|
|
97
|
+
function keepLockedRatio(
|
|
98
|
+
x: AxisPlacement,
|
|
99
|
+
y: AxisPlacement,
|
|
100
|
+
horizontal: ConstraintType,
|
|
101
|
+
vertical: ConstraintType,
|
|
102
|
+
aspectRatio: number | null
|
|
103
|
+
): { x: AxisPlacement; y: AxisPlacement } {
|
|
104
|
+
const flexibleX = FLEXIBLE_CONSTRAINTS.has(horizontal)
|
|
105
|
+
if (aspectRatio === null || flexibleX === FLEXIBLE_CONSTRAINTS.has(vertical)) return { x, y }
|
|
106
|
+
return flexibleX
|
|
107
|
+
? { x, y: resizedInPlace(y, x.size / aspectRatio, vertical) }
|
|
108
|
+
: { x: resizedInPlace(x, y.size * aspectRatio, horizontal), y }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A child's box after its parent resizes, keeping a locked aspect ratio as Figma does. */
|
|
112
|
+
export function constrainedChildRect(
|
|
113
|
+
child: Rect,
|
|
114
|
+
parentBefore: Pick<Rect, 'width' | 'height'>,
|
|
115
|
+
parentAfter: Pick<Rect, 'width' | 'height'>,
|
|
116
|
+
horizontal: ConstraintType,
|
|
117
|
+
vertical: ConstraintType,
|
|
118
|
+
aspectRatio: number | null = null
|
|
119
|
+
): Rect {
|
|
120
|
+
let x = constrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal)
|
|
121
|
+
let y = constrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical)
|
|
122
|
+
;({ x, y } = keepLockedRatio(x, y, horizontal, vertical, aspectRatio))
|
|
123
|
+
return {
|
|
124
|
+
x: Math.round(x.position),
|
|
125
|
+
y: Math.round(y.position),
|
|
126
|
+
width: Math.round(x.size),
|
|
127
|
+
height: Math.round(y.size)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function layoutConstrainedAxis(
|
|
132
|
+
position: number,
|
|
133
|
+
size: number,
|
|
134
|
+
parentBefore: number,
|
|
135
|
+
parentAfter: number,
|
|
136
|
+
constraint: ConstraintType
|
|
137
|
+
): { position: number; size: number } {
|
|
138
|
+
const delta = Math.round(parentAfter) - Math.round(parentBefore)
|
|
139
|
+
if (constraint === 'MAX') return { position: position + delta, size }
|
|
140
|
+
if (constraint === 'CENTER') {
|
|
141
|
+
return { position: position + Math.round(parentAfter / 2) - Math.round(parentBefore / 2), size }
|
|
142
|
+
}
|
|
143
|
+
if (constraint === 'STRETCH') return { position, size: Math.abs(size + delta) }
|
|
144
|
+
if (constraint === 'SCALE' && parentBefore > 0) {
|
|
145
|
+
const scale = parentAfter / parentBefore
|
|
146
|
+
return { position: Math.round(position * scale * 128) / 128, size: size * scale }
|
|
147
|
+
}
|
|
148
|
+
return { position, size }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Where a child goes when layout resizes its parent, as Figma places a layer that ignores auto
|
|
153
|
+
* layout when its Hug frame grows (measured on desktop 126): Right and Left & right move or grow
|
|
154
|
+
* it by the change in the parent's size rounded to whole pixels, Center by the change in its
|
|
155
|
+
* rounded half, and Scale by the exact ratio, its position to 1/128 of a pixel. Sizes are not
|
|
156
|
+
* rounded, so applying a run of changes one at a time lands where applying them at once does.
|
|
157
|
+
*/
|
|
158
|
+
export function layoutConstrainedChildRect(
|
|
159
|
+
child: Rect,
|
|
160
|
+
parentBefore: Pick<Rect, 'width' | 'height'>,
|
|
161
|
+
parentAfter: Pick<Rect, 'width' | 'height'>,
|
|
162
|
+
horizontal: ConstraintType,
|
|
163
|
+
vertical: ConstraintType,
|
|
164
|
+
aspectRatio: number | null = null
|
|
165
|
+
): Rect {
|
|
166
|
+
const placed = keepLockedRatio(
|
|
167
|
+
layoutConstrainedAxis(child.x, child.width, parentBefore.width, parentAfter.width, horizontal),
|
|
168
|
+
layoutConstrainedAxis(child.y, child.height, parentBefore.height, parentAfter.height, vertical),
|
|
169
|
+
horizontal,
|
|
170
|
+
vertical,
|
|
171
|
+
aspectRatio
|
|
172
|
+
)
|
|
173
|
+
return {
|
|
174
|
+
x: placed.x.position,
|
|
175
|
+
y: placed.y.position,
|
|
176
|
+
width: placed.x.size,
|
|
177
|
+
height: placed.y.size
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function scaledChildRect(
|
|
182
|
+
child: Rect,
|
|
183
|
+
parentBefore: Pick<Rect, 'width' | 'height'>,
|
|
184
|
+
parentAfter: Pick<Rect, 'width' | 'height'>
|
|
185
|
+
): Rect {
|
|
186
|
+
return constrainedChildRect(child, parentBefore, parentAfter, 'SCALE', 'SCALE')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function scaleVectorNetworkForResize(
|
|
190
|
+
vectorNetwork: VectorNetwork | null,
|
|
191
|
+
originalWidth: number,
|
|
192
|
+
originalHeight: number,
|
|
193
|
+
width: number,
|
|
194
|
+
height: number
|
|
195
|
+
): VectorNetwork | null {
|
|
196
|
+
if (!vectorNetwork || (originalWidth <= 0 && originalHeight <= 0)) return null
|
|
197
|
+
|
|
198
|
+
// A flat side, as a straight line's, has nothing to scale along it.
|
|
199
|
+
const scaleX = originalWidth > 0 ? width / originalWidth : 1
|
|
200
|
+
const scaleY = originalHeight > 0 ? height / originalHeight : 1
|
|
201
|
+
if (scaleX === 1 && scaleY === 1) return null
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
vertices: vectorNetwork.vertices.map((vertex) => ({
|
|
205
|
+
...vertex,
|
|
206
|
+
x: vertex.x * scaleX,
|
|
207
|
+
y: vertex.y * scaleY
|
|
208
|
+
})),
|
|
209
|
+
segments: vectorNetwork.segments.map((segment) => ({
|
|
210
|
+
...segment,
|
|
211
|
+
tangentStart: {
|
|
212
|
+
x: segment.tangentStart.x * scaleX,
|
|
213
|
+
y: segment.tangentStart.y * scaleY
|
|
214
|
+
},
|
|
215
|
+
tangentEnd: {
|
|
216
|
+
x: segment.tangentEnd.x * scaleX,
|
|
217
|
+
y: segment.tangentEnd.y * scaleY
|
|
218
|
+
}
|
|
219
|
+
})),
|
|
220
|
+
regions: vectorNetwork.regions
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */
|
|
225
|
+
export function createResizeSnapshot(node: SceneNode): ResizeSnapshot {
|
|
226
|
+
return {
|
|
227
|
+
type: node.type,
|
|
228
|
+
x: node.x,
|
|
229
|
+
y: node.y,
|
|
230
|
+
width: node.width,
|
|
231
|
+
height: node.height,
|
|
232
|
+
vectorNetwork: node.vectorNetwork ? cloneVectorNetwork(node.vectorNetwork) : null,
|
|
233
|
+
fillGeometry: copyGeometryPaths(node.fillGeometry),
|
|
234
|
+
strokeGeometry: copyGeometryPaths(node.strokeGeometry),
|
|
235
|
+
derivedTextGlyphs: copyDerivedGlyphs(node.derivedTextGlyphs),
|
|
236
|
+
strokes: copyStrokes(node.strokes),
|
|
237
|
+
textPathData: node.textPathData ? structuredClone(node.textPathData) : null,
|
|
238
|
+
textPathBox: node.textPathBox ? { ...node.textPathBox } : null
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function scaleDerivedGlyphs(
|
|
243
|
+
glyphs: DerivedTextGlyph[] | null,
|
|
244
|
+
sx: number,
|
|
245
|
+
sy: number
|
|
246
|
+
): DerivedTextGlyph[] | null {
|
|
247
|
+
if (!glyphs?.length) return glyphs
|
|
248
|
+
return glyphs.map((g) => ({
|
|
249
|
+
...g,
|
|
250
|
+
x: g.x * sx,
|
|
251
|
+
y: g.y * sy,
|
|
252
|
+
scaleX: (g.scaleX ?? 1) * sx,
|
|
253
|
+
scaleY: (g.scaleY ?? 1) * sy,
|
|
254
|
+
commandsBlob: new Uint8Array(g.commandsBlob)
|
|
255
|
+
}))
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function hasPath(orig: Pick<ResizeSnapshot, 'vectorNetwork'>): boolean {
|
|
259
|
+
return (orig.vectorNetwork?.segments.length ?? 0) > 0
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function scaleStrokes(strokes: Stroke[], sx: number, sy: number): Stroke[] {
|
|
263
|
+
if (strokes.length === 0) return strokes
|
|
264
|
+
// Weight is a scalar; average scale is the usual 2D → 1D compromise.
|
|
265
|
+
const weightScale = (Math.abs(sx) + Math.abs(sy)) / 2
|
|
266
|
+
return strokes.map((s) => ({ ...copyStroke(s), weight: s.weight * weightScale }))
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* All geometry that must track a width/height change. Historically only
|
|
271
|
+
* vectorNetwork + fillGeometry were updated — path-text strokeGeometry and
|
|
272
|
+
* glyphs stayed at the pre-resize size, so shrinking a sticker made the white
|
|
273
|
+
* OUTSIDE outlines look massively thick (DomeSticker resize bug).
|
|
274
|
+
*/
|
|
275
|
+
export function scaledGeometryChanges(
|
|
276
|
+
orig: Pick<
|
|
277
|
+
ResizeSnapshot,
|
|
278
|
+
| 'type'
|
|
279
|
+
| 'vectorNetwork'
|
|
280
|
+
| 'fillGeometry'
|
|
281
|
+
| 'strokeGeometry'
|
|
282
|
+
| 'derivedTextGlyphs'
|
|
283
|
+
| 'strokes'
|
|
284
|
+
| 'textPathData'
|
|
285
|
+
| 'textPathBox'
|
|
286
|
+
>,
|
|
287
|
+
origWidth: number,
|
|
288
|
+
origHeight: number,
|
|
289
|
+
width: number,
|
|
290
|
+
height: number
|
|
291
|
+
): Partial<SceneNode> {
|
|
292
|
+
if (origWidth <= 0 || origHeight <= 0) return {}
|
|
293
|
+
const sx = width / origWidth
|
|
294
|
+
const sy = height / origHeight
|
|
295
|
+
if (sx === 1 && sy === 1) return {}
|
|
296
|
+
|
|
297
|
+
const changes: Partial<SceneNode> = {}
|
|
298
|
+
const resizedVN = scaleVectorNetworkForResize(
|
|
299
|
+
orig.vectorNetwork,
|
|
300
|
+
origWidth,
|
|
301
|
+
origHeight,
|
|
302
|
+
width,
|
|
303
|
+
height
|
|
304
|
+
)
|
|
305
|
+
if (resizedVN) changes.vectorNetwork = resizedVN
|
|
306
|
+
|
|
307
|
+
if (orig.fillGeometry.length > 0) {
|
|
308
|
+
changes.fillGeometry = scaleGeometryPaths(orig.fillGeometry, sx, sy)
|
|
309
|
+
}
|
|
310
|
+
// A stroke keeps its weight through a resize, as in Figma, so a saved stroke outline goes where
|
|
311
|
+
// the stroke can be drawn again at its weight: from a path, or from a shape's own outline.
|
|
312
|
+
// Text and a vector with only its outline keep scaling the outline, which is all they have.
|
|
313
|
+
const outlineOnly = orig.type === 'TEXT' || (orig.type === 'VECTOR' && !hasPath(orig))
|
|
314
|
+
if (orig.strokeGeometry.length > 0) {
|
|
315
|
+
changes.strokeGeometry = outlineOnly ? scaleGeometryPaths(orig.strokeGeometry, sx, sy) : []
|
|
316
|
+
}
|
|
317
|
+
// Path text scales with its path, including baked path text that kept only rotated glyphs;
|
|
318
|
+
// other text reflows in the new box, so its glyphs are dropped.
|
|
319
|
+
const glyphs = orig.derivedTextGlyphs ?? []
|
|
320
|
+
const pathText =
|
|
321
|
+
!!orig.textPathData || !!orig.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0)
|
|
322
|
+
if (glyphs.length > 0 && pathText) {
|
|
323
|
+
changes.derivedTextGlyphs = scaleDerivedGlyphs(glyphs, sx, sy)
|
|
324
|
+
// Keep the layout/selection box in sync with the scaled glyphs. reflow
|
|
325
|
+
// overrides this when it applies; this covers the fallback where reflow
|
|
326
|
+
// returns null (no path data) so the box doesn't carry a stale size.
|
|
327
|
+
if (orig.textPathBox) {
|
|
328
|
+
changes.textPathBox = {
|
|
329
|
+
x: orig.textPathBox.x * sx,
|
|
330
|
+
y: orig.textPathBox.y * sy,
|
|
331
|
+
width: orig.textPathBox.width * sx,
|
|
332
|
+
height: orig.textPathBox.height * sy
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
// Glyphs scaled as a picture take their strokes along; any other stroke keeps its weight, as
|
|
337
|
+
// Figma reports it, even where only a scaled outline can draw it.
|
|
338
|
+
if (orig.strokes.length > 0 && glyphs.length > 0 && pathText) {
|
|
339
|
+
changes.strokes = scaleStrokes(orig.strokes, sx, sy)
|
|
340
|
+
}
|
|
341
|
+
return changes
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function collectResizeDescendants(
|
|
345
|
+
graph: ResizeGraph,
|
|
346
|
+
rootId: string
|
|
347
|
+
): Map<string, ResizeSnapshot> | null {
|
|
348
|
+
const root = graph.getNode(rootId)
|
|
349
|
+
if (!root || !CONSTRAINT_CONTAINER_TYPES.has(root.type)) return null
|
|
350
|
+
const snapshots = new Map<string, ResizeSnapshot>()
|
|
351
|
+
|
|
352
|
+
const collect = (parentId: string) => {
|
|
353
|
+
const parent = graph.getNode(parentId)
|
|
354
|
+
if (!parent) return
|
|
355
|
+
for (const childId of parent.childIds) {
|
|
356
|
+
const child = graph.getNode(childId)
|
|
357
|
+
if (!child) continue
|
|
358
|
+
snapshots.set(childId, createResizeSnapshot(child))
|
|
359
|
+
collect(childId)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
collect(rootId)
|
|
364
|
+
return snapshots.size > 0 ? snapshots : null
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function computeConstrainedResizeChanges(
|
|
368
|
+
graph: ResizeGraph,
|
|
369
|
+
rootId: string,
|
|
370
|
+
rootBefore: Pick<Rect, 'width' | 'height'>,
|
|
371
|
+
rootAfter: Pick<Rect, 'width' | 'height'>,
|
|
372
|
+
originals: ReadonlyMap<string, ResizeSnapshot>
|
|
373
|
+
): Map<string, Partial<SceneNode>> {
|
|
374
|
+
const changes = new Map<string, Partial<SceneNode>>()
|
|
375
|
+
|
|
376
|
+
const compute = (
|
|
377
|
+
parentId: string,
|
|
378
|
+
parentBefore: Pick<Rect, 'width' | 'height'>,
|
|
379
|
+
parentAfter: Pick<Rect, 'width' | 'height'>
|
|
380
|
+
) => {
|
|
381
|
+
const parent = graph.getNode(parentId)
|
|
382
|
+
if (!parent) return
|
|
383
|
+
const scalesChildren = parent.type === 'GROUP' || parent.type === 'BOOLEAN_OPERATION'
|
|
384
|
+
for (const childId of parent.childIds) {
|
|
385
|
+
const original = originals.get(childId)
|
|
386
|
+
const child = graph.getNode(childId)
|
|
387
|
+
if (!original || !child) continue
|
|
388
|
+
const isInFlow = parent.layoutMode !== 'NONE' && child.layoutPositioning !== 'ABSOLUTE'
|
|
389
|
+
if (isInFlow) {
|
|
390
|
+
compute(childId, original, child)
|
|
391
|
+
continue
|
|
392
|
+
}
|
|
393
|
+
const rect = scalesChildren
|
|
394
|
+
? scaledChildRect(original, parentBefore, parentAfter)
|
|
395
|
+
: constrainedChildRect(
|
|
396
|
+
original,
|
|
397
|
+
parentBefore,
|
|
398
|
+
parentAfter,
|
|
399
|
+
child.horizontalConstraint,
|
|
400
|
+
child.verticalConstraint,
|
|
401
|
+
enforcedAspectRatio(child)
|
|
402
|
+
)
|
|
403
|
+
const childChanges: Partial<SceneNode> = {
|
|
404
|
+
...rect,
|
|
405
|
+
...scaledGeometryChanges(original, original.width, original.height, rect.width, rect.height)
|
|
406
|
+
}
|
|
407
|
+
changes.set(childId, childChanges)
|
|
408
|
+
// The final pass sees layout containers after Yoga has resolved HUG/FILL sizing.
|
|
409
|
+
compute(childId, original, child.layoutMode === 'NONE' ? rect : child)
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
compute(rootId, rootBefore, rootAfter)
|
|
414
|
+
return changes
|
|
415
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { scaleGeometryPaths } from '../copy'
|
|
2
|
+
import { scaledTextLength } from '../text/lengths'
|
|
3
|
+
import { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'
|
|
4
|
+
import {
|
|
5
|
+
type Effect,
|
|
6
|
+
type Fill,
|
|
7
|
+
type GridTrack,
|
|
8
|
+
type LayoutGrid,
|
|
9
|
+
type SceneNode,
|
|
10
|
+
type Stroke,
|
|
11
|
+
type StyleRun,
|
|
12
|
+
type TextParagraphStyle
|
|
13
|
+
} from '../types'
|
|
14
|
+
import { cloneVectorNetwork } from '../vector-network'
|
|
15
|
+
|
|
16
|
+
function scaledOptional(value: number | null, scale: number): number | null {
|
|
17
|
+
return value == null ? null : value * scale
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {
|
|
21
|
+
return strokes.map((stroke) => ({
|
|
22
|
+
...structuredClone(stroke),
|
|
23
|
+
weight: stroke.weight * scale,
|
|
24
|
+
dashPattern: stroke.dashPattern?.map((value) => value * scale)
|
|
25
|
+
}))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function scaledEffects(effects: readonly Effect[], scale: number): Effect[] {
|
|
29
|
+
return effects.map((effect) => {
|
|
30
|
+
const copy = structuredClone(effect)
|
|
31
|
+
// A shader effect has no geometry of its own; only a shadow's measures follow the layer.
|
|
32
|
+
if (copy.type === 'SHADER') return copy
|
|
33
|
+
copy.offset = { x: copy.offset.x * scale, y: copy.offset.y * scale }
|
|
34
|
+
copy.radius *= scale
|
|
35
|
+
copy.spread *= scale
|
|
36
|
+
return copy
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function scaledFills(fills: readonly Fill[], scale: number): Fill[] {
|
|
41
|
+
return fills.map((fill) => ({
|
|
42
|
+
...structuredClone(fill),
|
|
43
|
+
scale: fill.scale == null ? undefined : fill.scale * scale,
|
|
44
|
+
spacing: fill.spacing == null ? undefined : fill.spacing * scale,
|
|
45
|
+
patternSpacing: fill.patternSpacing
|
|
46
|
+
? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }
|
|
47
|
+
: undefined,
|
|
48
|
+
noiseSize: fill.noiseSize
|
|
49
|
+
? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }
|
|
50
|
+
: undefined
|
|
51
|
+
}))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {
|
|
55
|
+
return styleRuns.map((run) => ({
|
|
56
|
+
...structuredClone(run),
|
|
57
|
+
style: {
|
|
58
|
+
...structuredClone(run.style),
|
|
59
|
+
fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,
|
|
60
|
+
letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),
|
|
61
|
+
lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),
|
|
62
|
+
textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),
|
|
63
|
+
textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)
|
|
64
|
+
}
|
|
65
|
+
}))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function scaledParagraphStyles(
|
|
69
|
+
paragraphs: readonly TextParagraphStyle[],
|
|
70
|
+
scale: number
|
|
71
|
+
): TextParagraphStyle[] {
|
|
72
|
+
return paragraphs.map((style) => {
|
|
73
|
+
const scaled = { ...style }
|
|
74
|
+
for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {
|
|
75
|
+
const value = style[field]
|
|
76
|
+
if (value !== undefined) scaled[field] = value * scale
|
|
77
|
+
}
|
|
78
|
+
return scaled
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {
|
|
83
|
+
return grids.map((grid) => ({
|
|
84
|
+
...structuredClone(grid),
|
|
85
|
+
offset: grid.offset == null ? undefined : grid.offset * scale,
|
|
86
|
+
sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,
|
|
87
|
+
gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale
|
|
88
|
+
}))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {
|
|
92
|
+
return tracks.map((track) => ({
|
|
93
|
+
...track,
|
|
94
|
+
value: track.sizing === 'FIXED' ? track.value * scale : track.value
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {
|
|
99
|
+
if (!node.vectorNetwork) return null
|
|
100
|
+
const network = cloneVectorNetwork(node.vectorNetwork)
|
|
101
|
+
for (const vertex of network.vertices) {
|
|
102
|
+
vertex.x *= scale
|
|
103
|
+
vertex.y *= scale
|
|
104
|
+
}
|
|
105
|
+
for (const segment of network.segments) {
|
|
106
|
+
segment.tangentStart.x *= scale
|
|
107
|
+
segment.tangentStart.y *= scale
|
|
108
|
+
segment.tangentEnd.x *= scale
|
|
109
|
+
segment.tangentEnd.y *= scale
|
|
110
|
+
}
|
|
111
|
+
return network
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function scaleNodeChanges(
|
|
115
|
+
node: SceneNode,
|
|
116
|
+
scale: number,
|
|
117
|
+
scalePosition: boolean
|
|
118
|
+
): Partial<SceneNode> {
|
|
119
|
+
return {
|
|
120
|
+
x: scalePosition ? node.x * scale : node.x,
|
|
121
|
+
y: scalePosition ? node.y * scale : node.y,
|
|
122
|
+
width: node.width * scale,
|
|
123
|
+
height: node.height * scale,
|
|
124
|
+
minWidth: scaledOptional(node.minWidth, scale),
|
|
125
|
+
maxWidth: scaledOptional(node.maxWidth, scale),
|
|
126
|
+
minHeight: scaledOptional(node.minHeight, scale),
|
|
127
|
+
maxHeight: scaledOptional(node.maxHeight, scale),
|
|
128
|
+
cornerRadius: node.cornerRadius * scale,
|
|
129
|
+
topLeftRadius: node.topLeftRadius * scale,
|
|
130
|
+
topRightRadius: node.topRightRadius * scale,
|
|
131
|
+
bottomRightRadius: node.bottomRightRadius * scale,
|
|
132
|
+
bottomLeftRadius: node.bottomLeftRadius * scale,
|
|
133
|
+
fontSize: node.fontSize * scale,
|
|
134
|
+
letterSpacing: scaledTextLength(node.letterSpacing, scale),
|
|
135
|
+
lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),
|
|
136
|
+
textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),
|
|
137
|
+
textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),
|
|
138
|
+
styleRuns: scaledStyleRuns(node.styleRuns, scale),
|
|
139
|
+
listSpacing: node.listSpacing * scale,
|
|
140
|
+
paragraphSpacing: node.paragraphSpacing * scale,
|
|
141
|
+
paragraphIndent: node.paragraphIndent * scale,
|
|
142
|
+
textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),
|
|
143
|
+
itemSpacing: node.itemSpacing * scale,
|
|
144
|
+
counterAxisSpacing: node.counterAxisSpacing * scale,
|
|
145
|
+
paddingTop: node.paddingTop * scale,
|
|
146
|
+
paddingRight: node.paddingRight * scale,
|
|
147
|
+
paddingBottom: node.paddingBottom * scale,
|
|
148
|
+
paddingLeft: node.paddingLeft * scale,
|
|
149
|
+
gridColumnGap: node.gridColumnGap * scale,
|
|
150
|
+
gridRowGap: node.gridRowGap * scale,
|
|
151
|
+
gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),
|
|
152
|
+
gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),
|
|
153
|
+
strokes: scaledStrokes(node.strokes, scale),
|
|
154
|
+
strokeWeight: node.strokeWeight * scale,
|
|
155
|
+
dashPattern: node.dashPattern.map((value) => value * scale),
|
|
156
|
+
borderTopWeight: node.borderTopWeight * scale,
|
|
157
|
+
borderRightWeight: node.borderRightWeight * scale,
|
|
158
|
+
borderBottomWeight: node.borderBottomWeight * scale,
|
|
159
|
+
borderLeftWeight: node.borderLeftWeight * scale,
|
|
160
|
+
strokeMiterLimit: node.strokeMiterLimit,
|
|
161
|
+
effects: scaledEffects(node.effects, scale),
|
|
162
|
+
fills: scaledFills(node.fills, scale),
|
|
163
|
+
layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),
|
|
164
|
+
vectorNetwork: scaledVectorNetwork(node, scale),
|
|
165
|
+
fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),
|
|
166
|
+
strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale)
|
|
167
|
+
}
|
|
168
|
+
}
|