@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
package/dist/geometry.js
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { arrowCapOverflow } from "./arrow-caps.js";
|
|
2
|
+
import { textLinesOverflow } from "./text/overflow.js";
|
|
3
|
+
//#region src/geometry.ts
|
|
4
|
+
function degToRad(degrees) {
|
|
5
|
+
return degrees * Math.PI / 180;
|
|
6
|
+
}
|
|
7
|
+
function radToDeg(radians) {
|
|
8
|
+
return radians * 180 / Math.PI;
|
|
9
|
+
}
|
|
10
|
+
function rotatePoint(px, py, cx, cy, rad) {
|
|
11
|
+
const cos = Math.cos(rad);
|
|
12
|
+
const sin = Math.sin(rad);
|
|
13
|
+
return {
|
|
14
|
+
x: cx + (px - cx) * cos - (py - cy) * sin,
|
|
15
|
+
y: cy + (px - cx) * sin + (py - cy) * cos
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function rotatedCorners(cx, cy, hw, hh, rotationDeg) {
|
|
19
|
+
const rad = degToRad(rotationDeg);
|
|
20
|
+
const cos = Math.cos(rad);
|
|
21
|
+
const sin = Math.sin(rad);
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
x: cx + -hw * cos - -hh * sin,
|
|
25
|
+
y: cy + -hw * sin + -hh * cos
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
x: cx + hw * cos - -hh * sin,
|
|
29
|
+
y: cy + hw * sin + -hh * cos
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
x: cx + hw * cos - hh * sin,
|
|
33
|
+
y: cy + hw * sin + hh * cos
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
x: cx + -hw * cos - hh * sin,
|
|
37
|
+
y: cy + -hw * sin + hh * cos
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
function rotatedBBox(x, y, w, h, rotationDeg) {
|
|
42
|
+
if (rotationDeg === 0) return {
|
|
43
|
+
left: x,
|
|
44
|
+
right: x + w,
|
|
45
|
+
top: y,
|
|
46
|
+
bottom: y + h,
|
|
47
|
+
centerX: x + w / 2,
|
|
48
|
+
centerY: y + h / 2
|
|
49
|
+
};
|
|
50
|
+
const corners = rotatedCorners(x + w / 2, y + h / 2, w / 2, h / 2, rotationDeg);
|
|
51
|
+
let left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity;
|
|
52
|
+
for (const c of corners) {
|
|
53
|
+
left = Math.min(left, c.x);
|
|
54
|
+
right = Math.max(right, c.x);
|
|
55
|
+
top = Math.min(top, c.y);
|
|
56
|
+
bottom = Math.max(bottom, c.y);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
left,
|
|
60
|
+
right,
|
|
61
|
+
top,
|
|
62
|
+
bottom,
|
|
63
|
+
centerX: (left + right) / 2,
|
|
64
|
+
centerY: (top + bottom) / 2
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function createBoundsAccumulator() {
|
|
68
|
+
return {
|
|
69
|
+
minX: Infinity,
|
|
70
|
+
minY: Infinity,
|
|
71
|
+
maxX: -Infinity,
|
|
72
|
+
maxY: -Infinity
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function includePoint(bounds, x, y) {
|
|
76
|
+
bounds.minX = Math.min(bounds.minX, x);
|
|
77
|
+
bounds.minY = Math.min(bounds.minY, y);
|
|
78
|
+
bounds.maxX = Math.max(bounds.maxX, x);
|
|
79
|
+
bounds.maxY = Math.max(bounds.maxY, y);
|
|
80
|
+
}
|
|
81
|
+
function includeRect(bounds, rect) {
|
|
82
|
+
includePoint(bounds, rect.x, rect.y);
|
|
83
|
+
includePoint(bounds, rect.x + rect.width, rect.y + rect.height);
|
|
84
|
+
}
|
|
85
|
+
function boundsToRect(bounds) {
|
|
86
|
+
return bounds.minX === Infinity ? {
|
|
87
|
+
x: 0,
|
|
88
|
+
y: 0,
|
|
89
|
+
width: 0,
|
|
90
|
+
height: 0
|
|
91
|
+
} : {
|
|
92
|
+
x: bounds.minX,
|
|
93
|
+
y: bounds.minY,
|
|
94
|
+
width: bounds.maxX - bounds.minX,
|
|
95
|
+
height: bounds.maxY - bounds.minY
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function computeBounds(items) {
|
|
99
|
+
const bounds = createBoundsAccumulator();
|
|
100
|
+
for (const item of items) includeRect(bounds, item);
|
|
101
|
+
return boundsToRect(bounds);
|
|
102
|
+
}
|
|
103
|
+
function polygonVertices(node) {
|
|
104
|
+
const cx = node.width / 2;
|
|
105
|
+
const cy = node.height / 2;
|
|
106
|
+
const rx = node.width / 2;
|
|
107
|
+
const ry = node.height / 2;
|
|
108
|
+
const pointCount = Math.max(3, node.pointCount);
|
|
109
|
+
const isStar = node.type === "STAR";
|
|
110
|
+
const innerRatio = isStar ? node.starInnerRadius : 1;
|
|
111
|
+
const totalPoints = isStar ? pointCount * 2 : pointCount;
|
|
112
|
+
const angleOffset = -Math.PI / 2;
|
|
113
|
+
return Array.from({ length: totalPoints }, (_, index) => {
|
|
114
|
+
const angle = angleOffset + 2 * Math.PI * index / totalPoints;
|
|
115
|
+
const radius = isStar && index % 2 === 1 ? innerRatio : 1;
|
|
116
|
+
return {
|
|
117
|
+
x: cx + rx * radius * Math.cos(angle),
|
|
118
|
+
y: cy + ry * radius * Math.sin(angle)
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function strokeOverflow(strokes, fallbackCap, network, shape) {
|
|
123
|
+
const line = shape?.type === "LINE";
|
|
124
|
+
const enclosed = new Set(network?.regions.flatMap((region) => region.loops.flat()));
|
|
125
|
+
const open = network?.segments.some((_, index) => !enclosed.has(index)) ?? false;
|
|
126
|
+
const sided = !network || network.regions.length > 0;
|
|
127
|
+
let overflow = 0;
|
|
128
|
+
for (const stroke of strokes ?? []) {
|
|
129
|
+
if (!stroke.visible) continue;
|
|
130
|
+
const align = sided ? stroke.align : "CENTER";
|
|
131
|
+
let extra = open ? stroke.weight / 2 : 0;
|
|
132
|
+
if (line || align === "OUTSIDE") extra = stroke.weight;
|
|
133
|
+
else if (align === "CENTER") extra = stroke.weight / 2;
|
|
134
|
+
const miter = network ? miterRatio(network, stroke.join ?? shape?.strokeJoin, shape?.strokeMiterLimit) : 1;
|
|
135
|
+
overflow = Math.max(overflow, extra * miter);
|
|
136
|
+
}
|
|
137
|
+
const heads = arrowCapOverflow(strokes, fallbackCap, network);
|
|
138
|
+
return Math.max(overflow, heads > 0 && line ? heads + overflow / 2 : heads);
|
|
139
|
+
}
|
|
140
|
+
/** The direction a segment leaves `vertex` in, along its handle when it has one. */
|
|
141
|
+
function leaving(network, index, vertex) {
|
|
142
|
+
const segment = network.segments[index];
|
|
143
|
+
const atStart = segment.start === vertex;
|
|
144
|
+
const handle = atStart ? segment.tangentStart : segment.tangentEnd;
|
|
145
|
+
if (handle.x !== 0 || handle.y !== 0) return handle;
|
|
146
|
+
const from = network.vertices[vertex];
|
|
147
|
+
const to = network.vertices[atStart ? segment.end : segment.start];
|
|
148
|
+
return {
|
|
149
|
+
x: to.x - from.x,
|
|
150
|
+
y: to.y - from.y
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* How far past half the stroke the sharpest mitered corner reaches, as a multiple: a corner of
|
|
155
|
+
* angle θ mitres out to 1/sin(θ/2), unless that passes the miter limit and it bevels instead.
|
|
156
|
+
* Corners are the vertices exactly two segments meet at, as the stroke joins them.
|
|
157
|
+
*/
|
|
158
|
+
function miterRatio(network, join, limit = 4) {
|
|
159
|
+
const meeting = /* @__PURE__ */ new Map();
|
|
160
|
+
for (const [index, segment] of network.segments.entries()) for (const vertex of /* @__PURE__ */ new Set([segment.start, segment.end])) meeting.set(vertex, [...meeting.get(vertex) ?? [], index]);
|
|
161
|
+
let ratio = 1;
|
|
162
|
+
for (const [vertex, indices] of meeting) {
|
|
163
|
+
if (indices.length !== 2) continue;
|
|
164
|
+
if ((network.vertices[vertex].strokeJoin ?? join ?? "MITER") !== "MITER") continue;
|
|
165
|
+
const a = leaving(network, indices[0], vertex);
|
|
166
|
+
const b = leaving(network, indices[1], vertex);
|
|
167
|
+
const lengths = Math.hypot(a.x, a.y) * Math.hypot(b.x, b.y);
|
|
168
|
+
if (lengths === 0) continue;
|
|
169
|
+
const angle = Math.acos(Math.max(-1, Math.min(1, (a.x * b.x + a.y * b.y) / lengths)));
|
|
170
|
+
const miter = 1 / Math.sin(angle / 2);
|
|
171
|
+
if (miter <= limit) ratio = Math.max(ratio, miter);
|
|
172
|
+
}
|
|
173
|
+
return ratio;
|
|
174
|
+
}
|
|
175
|
+
function effectOverflow(effects) {
|
|
176
|
+
let left = 0;
|
|
177
|
+
let right = 0;
|
|
178
|
+
let top = 0;
|
|
179
|
+
let bottom = 0;
|
|
180
|
+
for (const effect of effects ?? []) {
|
|
181
|
+
if (!effect.visible) continue;
|
|
182
|
+
if (effect.type !== "DROP_SHADOW" && effect.type !== "LAYER_BLUR" && effect.type !== "FOREGROUND_BLUR") continue;
|
|
183
|
+
const blurSpread = effect.radius + effect.spread;
|
|
184
|
+
left = Math.max(left, blurSpread + Math.max(0, -effect.offset.x));
|
|
185
|
+
right = Math.max(right, blurSpread + Math.max(0, effect.offset.x));
|
|
186
|
+
top = Math.max(top, blurSpread + Math.max(0, -effect.offset.y));
|
|
187
|
+
bottom = Math.max(bottom, blurSpread + Math.max(0, effect.offset.y));
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
left,
|
|
191
|
+
right,
|
|
192
|
+
top,
|
|
193
|
+
bottom
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function computeAbsoluteBounds(nodes, getAbsolutePosition) {
|
|
197
|
+
const bounds = createBoundsAccumulator();
|
|
198
|
+
for (const n of nodes) {
|
|
199
|
+
const abs = getAbsolutePosition(n.id);
|
|
200
|
+
includeRect(bounds, {
|
|
201
|
+
x: abs.x,
|
|
202
|
+
y: abs.y,
|
|
203
|
+
width: n.width,
|
|
204
|
+
height: n.height
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return boundsToRect(bounds);
|
|
208
|
+
}
|
|
209
|
+
function computeVisualBounds(nodes, getAbsolutePosition) {
|
|
210
|
+
const bounds = createBoundsAccumulator();
|
|
211
|
+
for (const n of nodes) {
|
|
212
|
+
const abs = getAbsolutePosition(n.id);
|
|
213
|
+
const bbox = rotatedBBox(abs.x, abs.y, n.width, n.height, n.rotation ?? 0);
|
|
214
|
+
const stroke = strokeOverflow(n.strokes, n.strokeCap, n.vectorNetwork, n);
|
|
215
|
+
const effects = effectOverflow(n.effects);
|
|
216
|
+
includePoint(bounds, bbox.left - stroke - effects.left, bbox.top - stroke - effects.top);
|
|
217
|
+
includePoint(bounds, bbox.right + stroke + effects.right, bbox.bottom + stroke + effects.bottom);
|
|
218
|
+
}
|
|
219
|
+
return boundsToRect(bounds);
|
|
220
|
+
}
|
|
221
|
+
function unionVisualBounds(a, b) {
|
|
222
|
+
if (!a) return b;
|
|
223
|
+
if (!b) return a;
|
|
224
|
+
return {
|
|
225
|
+
minX: Math.min(a.minX, b.minX),
|
|
226
|
+
minY: Math.min(a.minY, b.minY),
|
|
227
|
+
maxX: Math.max(a.maxX, b.maxX),
|
|
228
|
+
maxY: Math.max(a.maxY, b.maxY)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function intersectVisualBounds(a, b) {
|
|
232
|
+
const minX = Math.max(a.minX, b.minX);
|
|
233
|
+
const minY = Math.max(a.minY, b.minY);
|
|
234
|
+
const maxX = Math.min(a.maxX, b.maxX);
|
|
235
|
+
const maxY = Math.min(a.maxY, b.maxY);
|
|
236
|
+
return minX < maxX && minY < maxY ? {
|
|
237
|
+
minX,
|
|
238
|
+
minY,
|
|
239
|
+
maxX,
|
|
240
|
+
maxY
|
|
241
|
+
} : null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Coordinate pairs per path blob command: 0=close, 1=move, 2=line,
|
|
245
|
+
* 3=quad (glyph-derived blobs are quad-heavy), 4=cubic. Unknown → null so
|
|
246
|
+
* walkers stop instead of desyncing into coordinate bytes.
|
|
247
|
+
*/
|
|
248
|
+
function geometryCommandCoordCount(command) {
|
|
249
|
+
if (command === 0) return 0;
|
|
250
|
+
if (command === 1 || command === 2) return 1;
|
|
251
|
+
if (command === 3) return 2;
|
|
252
|
+
if (command === 4) return 3;
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
function geometryBlobBounds(paths) {
|
|
256
|
+
const bounds = createBoundsAccumulator();
|
|
257
|
+
for (const path of paths) {
|
|
258
|
+
const blob = path.commandsBlob;
|
|
259
|
+
const dv = new DataView(blob.buffer, blob.byteOffset, blob.byteLength);
|
|
260
|
+
let offset = 0;
|
|
261
|
+
while (offset < blob.length) {
|
|
262
|
+
const command = blob[offset++];
|
|
263
|
+
const coords = geometryCommandCoordCount(command);
|
|
264
|
+
if (coords == null) break;
|
|
265
|
+
for (let i = 0; i < coords; i++) {
|
|
266
|
+
if (offset + 8 > blob.length) break;
|
|
267
|
+
includePoint(bounds, dv.getFloat32(offset, true), dv.getFloat32(offset + 4, true));
|
|
268
|
+
offset += 8;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return bounds.minX === Infinity ? null : boundsToRect(bounds);
|
|
273
|
+
}
|
|
274
|
+
function transformLocalPoint(node, point) {
|
|
275
|
+
let x = node.flipX ? node.width - point.x : point.x;
|
|
276
|
+
let y = node.flipY ? node.height - point.y : point.y;
|
|
277
|
+
const rotation = node.rotation ?? 0;
|
|
278
|
+
if (rotation !== 0) {
|
|
279
|
+
const rotated = rotatePoint(x, y, node.width / 2, node.height / 2, degToRad(rotation));
|
|
280
|
+
x = rotated.x;
|
|
281
|
+
y = rotated.y;
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
x,
|
|
285
|
+
y
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function transformedLocalBounds(node, local, abs) {
|
|
289
|
+
const points = [
|
|
290
|
+
{
|
|
291
|
+
x: local.x,
|
|
292
|
+
y: local.y
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
x: local.x + local.width,
|
|
296
|
+
y: local.y
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
x: local.x + local.width,
|
|
300
|
+
y: local.y + local.height
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
x: local.x,
|
|
304
|
+
y: local.y + local.height
|
|
305
|
+
}
|
|
306
|
+
].map((point) => transformLocalPoint(node, point));
|
|
307
|
+
return {
|
|
308
|
+
minX: abs.x + Math.min(...points.map((point) => point.x)),
|
|
309
|
+
minY: abs.y + Math.min(...points.map((point) => point.y)),
|
|
310
|
+
maxX: abs.x + Math.max(...points.map((point) => point.x)),
|
|
311
|
+
maxY: abs.y + Math.max(...points.map((point) => point.y))
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function nodeVisualBounds(node, getAbsolutePosition) {
|
|
315
|
+
const abs = getAbsolutePosition(node.id);
|
|
316
|
+
const base = computeVisualBounds([node], getAbsolutePosition);
|
|
317
|
+
let bounds = {
|
|
318
|
+
minX: base.x,
|
|
319
|
+
minY: base.y,
|
|
320
|
+
maxX: base.x + base.width,
|
|
321
|
+
maxY: base.y + base.height
|
|
322
|
+
};
|
|
323
|
+
const hasNonInsideStroke = node.strokes?.some((stroke) => stroke.visible && stroke.align !== "INSIDE");
|
|
324
|
+
const localGeometry = geometryBlobBounds([...node.fillGeometry ?? [], ...hasNonInsideStroke ? node.strokeGeometry ?? [] : []]);
|
|
325
|
+
if (localGeometry) bounds = unionVisualBounds(bounds, transformedLocalBounds(node, localGeometry, abs)) ?? bounds;
|
|
326
|
+
const linesOverflow = textLinesOverflow(node);
|
|
327
|
+
if (linesOverflow > 0) {
|
|
328
|
+
const lines = {
|
|
329
|
+
x: 0,
|
|
330
|
+
y: 0,
|
|
331
|
+
width: node.width,
|
|
332
|
+
height: node.height + linesOverflow
|
|
333
|
+
};
|
|
334
|
+
bounds = unionVisualBounds(bounds, transformedLocalBounds(node, lines, abs)) ?? bounds;
|
|
335
|
+
}
|
|
336
|
+
bounds.maxY += textDecorationOverflow(node);
|
|
337
|
+
return bounds;
|
|
338
|
+
}
|
|
339
|
+
/** How far a text node's underline or strikethrough reaches below its box. */
|
|
340
|
+
function textDecorationOverflow(node) {
|
|
341
|
+
if (node.type !== "TEXT" || !node.textDecoration || node.textDecoration === "NONE") return 0;
|
|
342
|
+
const fontSize = node.fontSize ?? 14;
|
|
343
|
+
return (node.textUnderlineOffset ?? fontSize * .18) + (node.textDecorationThickness ?? Math.max(1, fontSize / 16)) + fontSize * .35;
|
|
344
|
+
}
|
|
345
|
+
function collectDescendantVisualBounds(nodeId, getNode, getAbsolutePosition, clip = null) {
|
|
346
|
+
const node = getNode(nodeId);
|
|
347
|
+
if (!node?.visible) return null;
|
|
348
|
+
const own = nodeVisualBounds(node, getAbsolutePosition);
|
|
349
|
+
let bounds = clip ? intersectVisualBounds(own, clip) : own;
|
|
350
|
+
const isClippableContainer = node.type === "FRAME" || node.type === "COMPONENT" || node.type === "INSTANCE";
|
|
351
|
+
let childClip = clip;
|
|
352
|
+
if (isClippableContainer && node.clipsContent) {
|
|
353
|
+
const abs = getAbsolutePosition(node.id);
|
|
354
|
+
const nodeClip = {
|
|
355
|
+
minX: abs.x,
|
|
356
|
+
minY: abs.y,
|
|
357
|
+
maxX: abs.x + node.width,
|
|
358
|
+
maxY: abs.y + node.height
|
|
359
|
+
};
|
|
360
|
+
childClip = childClip ? intersectVisualBounds(childClip, nodeClip) : nodeClip;
|
|
361
|
+
if (!childClip) return bounds;
|
|
362
|
+
}
|
|
363
|
+
for (const childId of node.childIds ?? []) bounds = unionVisualBounds(bounds, collectDescendantVisualBounds(childId, getNode, getAbsolutePosition, childClip));
|
|
364
|
+
return bounds;
|
|
365
|
+
}
|
|
366
|
+
function computeDescendantVisualBounds(nodeIds, getNode, getAbsolutePosition) {
|
|
367
|
+
let bounds = null;
|
|
368
|
+
for (const nodeId of nodeIds) bounds = unionVisualBounds(bounds, collectDescendantVisualBounds(nodeId, getNode, getAbsolutePosition));
|
|
369
|
+
return bounds;
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
export { computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeVisualBounds, degToRad, effectOverflow, geometryBlobBounds, geometryCommandCoordCount, intersectVisualBounds, nodeVisualBounds, polygonVertices, radToDeg, rotatePoint, rotatedBBox, rotatedCorners, strokeOverflow, textDecorationOverflow, unionVisualBounds };
|
|
373
|
+
|
|
374
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","names":[],"sources":["../src/geometry.ts"],"sourcesContent":["import { arrowCapOverflow } from './arrow-caps'\nimport type { Rect, Vector } from './primitives'\nimport { textLinesOverflow } from './text/overflow'\nimport type { Effect, Stroke, StrokeCap, StrokeJoin, VectorNetwork } from './types'\n\nexport function degToRad(degrees: number): number {\n return (degrees * Math.PI) / 180\n}\n\nexport function radToDeg(radians: number): number {\n return (radians * 180) / Math.PI\n}\n\nexport function rotatePoint(px: number, py: number, cx: number, cy: number, rad: number): Vector {\n const cos = Math.cos(rad)\n const sin = Math.sin(rad)\n return {\n x: cx + (px - cx) * cos - (py - cy) * sin,\n y: cy + (px - cx) * sin + (py - cy) * cos\n }\n}\n\nexport function rotatedCorners(\n cx: number,\n cy: number,\n hw: number,\n hh: number,\n rotationDeg: number\n): [Vector, Vector, Vector, Vector] {\n const rad = degToRad(rotationDeg)\n const cos = Math.cos(rad)\n const sin = Math.sin(rad)\n return [\n { x: cx + -hw * cos - -hh * sin, y: cy + -hw * sin + -hh * cos },\n { x: cx + hw * cos - -hh * sin, y: cy + hw * sin + -hh * cos },\n { x: cx + hw * cos - hh * sin, y: cy + hw * sin + hh * cos },\n { x: cx + -hw * cos - hh * sin, y: cy + -hw * sin + hh * cos }\n ]\n}\n\nexport function rotatedBBox(\n x: number,\n y: number,\n w: number,\n h: number,\n rotationDeg: number\n): { left: number; right: number; top: number; bottom: number; centerX: number; centerY: number } {\n if (rotationDeg === 0) {\n return {\n left: x,\n right: x + w,\n top: y,\n bottom: y + h,\n centerX: x + w / 2,\n centerY: y + h / 2\n }\n }\n const corners = rotatedCorners(x + w / 2, y + h / 2, w / 2, h / 2, rotationDeg)\n let left = Infinity,\n right = -Infinity,\n top = Infinity,\n bottom = -Infinity\n for (const c of corners) {\n left = Math.min(left, c.x)\n right = Math.max(right, c.x)\n top = Math.min(top, c.y)\n bottom = Math.max(bottom, c.y)\n }\n return { left, right, top, bottom, centerX: (left + right) / 2, centerY: (top + bottom) / 2 }\n}\n\nexport interface VisualBounds {\n minX: number\n minY: number\n maxX: number\n maxY: number\n}\n\ntype BoundsAccumulator = VisualBounds\n\nfunction createBoundsAccumulator(): BoundsAccumulator {\n return { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }\n}\n\nfunction includePoint(bounds: BoundsAccumulator, x: number, y: number): void {\n bounds.minX = Math.min(bounds.minX, x)\n bounds.minY = Math.min(bounds.minY, y)\n bounds.maxX = Math.max(bounds.maxX, x)\n bounds.maxY = Math.max(bounds.maxY, y)\n}\n\nfunction includeRect(bounds: BoundsAccumulator, rect: Rect): void {\n includePoint(bounds, rect.x, rect.y)\n includePoint(bounds, rect.x + rect.width, rect.y + rect.height)\n}\n\nfunction boundsToRect(bounds: BoundsAccumulator): Rect {\n return bounds.minX === Infinity\n ? { x: 0, y: 0, width: 0, height: 0 }\n : {\n x: bounds.minX,\n y: bounds.minY,\n width: bounds.maxX - bounds.minX,\n height: bounds.maxY - bounds.minY\n }\n}\n\nexport function computeBounds(items: Iterable<Rect>): Rect {\n const bounds = createBoundsAccumulator()\n for (const item of items) includeRect(bounds, item)\n return boundsToRect(bounds)\n}\n\nexport function polygonVertices(node: {\n width: number\n height: number\n pointCount: number\n type: string\n starInnerRadius: number\n}): Vector[] {\n const cx = node.width / 2\n const cy = node.height / 2\n const rx = node.width / 2\n const ry = node.height / 2\n const pointCount = Math.max(3, node.pointCount)\n const isStar = node.type === 'STAR'\n const innerRatio = isStar ? node.starInnerRadius : 1\n const totalPoints = isStar ? pointCount * 2 : pointCount\n const angleOffset = -Math.PI / 2\n\n return Array.from({ length: totalPoints }, (_, index) => {\n const angle = angleOffset + (2 * Math.PI * index) / totalPoints\n const isInner = isStar && index % 2 === 1\n const radius = isInner ? innerRatio : 1\n return {\n x: cx + rx * radius * Math.cos(angle),\n y: cy + ry * radius * Math.sin(angle)\n }\n })\n}\n\n/**\n * What shapes how far a layer's stroke reaches past its box: its type, since a line is stroked to\n * one side, and its join and miter limit, for the tips mitered path corners reach.\n */\nexport interface StrokeShape {\n type?: string\n strokeJoin?: StrokeJoin\n strokeMiterLimit?: number\n}\n\nexport function strokeOverflow(\n strokes?: Stroke[],\n fallbackCap?: StrokeCap,\n network?: VectorNetwork | null,\n shape?: StrokeShape\n): number {\n const line = shape?.type === 'LINE'\n // Open segments enclose nothing to take a side of, so their strokes draw centred; a network\n // with closed regions still strokes those on their side.\n const enclosed = new Set(network?.regions.flatMap((region) => region.loops.flat()))\n const open = network?.segments.some((_, index) => !enclosed.has(index)) ?? false\n const sided = !network || network.regions.length > 0\n let overflow = 0\n for (const stroke of strokes ?? []) {\n if (!stroke.visible) continue\n const align = sided ? stroke.align : 'CENTER'\n let extra = open ? stroke.weight / 2 : 0\n if (line || align === 'OUTSIDE') extra = stroke.weight\n else if (align === 'CENTER') extra = stroke.weight / 2\n const miter = network\n ? miterRatio(network, stroke.join ?? shape?.strokeJoin, shape?.strokeMiterLimit)\n : 1\n overflow = Math.max(overflow, extra * miter)\n }\n // A line's heads sit on its stroke's middle, half a weight off the line.\n const heads = arrowCapOverflow(strokes, fallbackCap, network)\n return Math.max(overflow, heads > 0 && line ? heads + overflow / 2 : heads)\n}\n\n/** The direction a segment leaves `vertex` in, along its handle when it has one. */\nfunction leaving(network: VectorNetwork, index: number, vertex: number): Vector {\n const segment = network.segments[index]\n const atStart = segment.start === vertex\n const handle = atStart ? segment.tangentStart : segment.tangentEnd\n if (handle.x !== 0 || handle.y !== 0) return handle\n const from = network.vertices[vertex]\n const to = network.vertices[atStart ? segment.end : segment.start]\n return { x: to.x - from.x, y: to.y - from.y }\n}\n\n/**\n * How far past half the stroke the sharpest mitered corner reaches, as a multiple: a corner of\n * angle θ mitres out to 1/sin(θ/2), unless that passes the miter limit and it bevels instead.\n * Corners are the vertices exactly two segments meet at, as the stroke joins them.\n */\nfunction miterRatio(network: VectorNetwork, join: StrokeJoin | undefined, limit = 4): number {\n const meeting = new Map<number, number[]>()\n for (const [index, segment] of network.segments.entries()) {\n for (const vertex of new Set([segment.start, segment.end])) {\n meeting.set(vertex, [...(meeting.get(vertex) ?? []), index])\n }\n }\n let ratio = 1\n for (const [vertex, indices] of meeting) {\n if (indices.length !== 2) continue\n if ((network.vertices[vertex].strokeJoin ?? join ?? 'MITER') !== 'MITER') continue\n const a = leaving(network, indices[0], vertex)\n const b = leaving(network, indices[1], vertex)\n const lengths = Math.hypot(a.x, a.y) * Math.hypot(b.x, b.y)\n if (lengths === 0) continue\n const angle = Math.acos(Math.max(-1, Math.min(1, (a.x * b.x + a.y * b.y) / lengths)))\n const miter = 1 / Math.sin(angle / 2)\n if (miter <= limit) ratio = Math.max(ratio, miter)\n }\n return ratio\n}\n\nexport function effectOverflow(effects?: Effect[]) {\n let left = 0\n let right = 0\n let top = 0\n let bottom = 0\n\n for (const effect of effects ?? []) {\n if (!effect.visible) continue\n if (\n effect.type !== 'DROP_SHADOW' &&\n effect.type !== 'LAYER_BLUR' &&\n effect.type !== 'FOREGROUND_BLUR'\n ) {\n continue\n }\n const blurSpread = effect.radius + effect.spread\n left = Math.max(left, blurSpread + Math.max(0, -effect.offset.x))\n right = Math.max(right, blurSpread + Math.max(0, effect.offset.x))\n top = Math.max(top, blurSpread + Math.max(0, -effect.offset.y))\n bottom = Math.max(bottom, blurSpread + Math.max(0, effect.offset.y))\n }\n\n return { left, right, top, bottom }\n}\n\nexport function computeAbsoluteBounds(\n nodes: Iterable<{ id: string; width: number; height: number }>,\n getAbsolutePosition: (id: string) => Vector\n): Rect {\n const bounds = createBoundsAccumulator()\n for (const n of nodes) {\n const abs = getAbsolutePosition(n.id)\n includeRect(bounds, { x: abs.x, y: abs.y, width: n.width, height: n.height })\n }\n return boundsToRect(bounds)\n}\n\nexport function computeVisualBounds(\n nodes: Iterable<\n {\n id: string\n width: number\n height: number\n rotation?: number\n strokes?: Stroke[]\n strokeCap?: StrokeCap\n vectorNetwork?: VectorNetwork | null\n effects?: Effect[]\n } & StrokeShape\n >,\n getAbsolutePosition: (id: string) => Vector\n): Rect {\n const bounds = createBoundsAccumulator()\n\n for (const n of nodes) {\n const abs = getAbsolutePosition(n.id)\n const bbox = rotatedBBox(abs.x, abs.y, n.width, n.height, n.rotation ?? 0)\n const stroke = strokeOverflow(n.strokes, n.strokeCap, n.vectorNetwork, n)\n const effects = effectOverflow(n.effects)\n includePoint(bounds, bbox.left - stroke - effects.left, bbox.top - stroke - effects.top)\n includePoint(bounds, bbox.right + stroke + effects.right, bbox.bottom + stroke + effects.bottom)\n }\n\n return boundsToRect(bounds)\n}\n\nexport interface VisualBoundsNode {\n id: string\n width: number\n height: number\n rotation?: number\n flipX?: boolean\n flipY?: boolean\n strokes?: Stroke[]\n strokeCap?: StrokeCap\n vectorNetwork?: VectorNetwork | null\n effects?: Effect[]\n fillGeometry?: Array<{ commandsBlob: Uint8Array }>\n strokeGeometry?: Array<{ commandsBlob: Uint8Array }>\n childIds?: string[]\n visible?: boolean\n type?: string\n clipsContent?: boolean\n fontSize?: number\n textDecoration?: string\n textUnderlineOffset?: number | null\n textDecorationThickness?: number | null\n derivedTextHeight?: number | null\n}\n\nexport function unionVisualBounds(\n a: VisualBounds | null,\n b: VisualBounds | null\n): VisualBounds | null {\n if (!a) return b\n if (!b) return a\n return {\n minX: Math.min(a.minX, b.minX),\n minY: Math.min(a.minY, b.minY),\n maxX: Math.max(a.maxX, b.maxX),\n maxY: Math.max(a.maxY, b.maxY)\n }\n}\n\nexport function intersectVisualBounds(a: VisualBounds, b: VisualBounds): VisualBounds | null {\n const minX = Math.max(a.minX, b.minX)\n const minY = Math.max(a.minY, b.minY)\n const maxX = Math.min(a.maxX, b.maxX)\n const maxY = Math.min(a.maxY, b.maxY)\n return minX < maxX && minY < maxY ? { minX, minY, maxX, maxY } : null\n}\n\n/**\n * Coordinate pairs per path blob command: 0=close, 1=move, 2=line,\n * 3=quad (glyph-derived blobs are quad-heavy), 4=cubic. Unknown → null so\n * walkers stop instead of desyncing into coordinate bytes.\n */\nexport function geometryCommandCoordCount(command: number): number | null {\n if (command === 0) return 0\n if (command === 1 || command === 2) return 1\n if (command === 3) return 2\n if (command === 4) return 3\n return null\n}\n\nexport function geometryBlobBounds(paths: Array<{ commandsBlob: Uint8Array }>): Rect | null {\n const bounds = createBoundsAccumulator()\n\n for (const path of paths) {\n const blob = path.commandsBlob\n const dv = new DataView(blob.buffer, blob.byteOffset, blob.byteLength)\n let offset = 0\n while (offset < blob.length) {\n const command = blob[offset++]\n const coords = geometryCommandCoordCount(command)\n if (coords == null) break\n for (let i = 0; i < coords; i++) {\n if (offset + 8 > blob.length) break\n const x = dv.getFloat32(offset, true)\n const y = dv.getFloat32(offset + 4, true)\n includePoint(bounds, x, y)\n offset += 8\n }\n }\n }\n\n return bounds.minX === Infinity ? null : boundsToRect(bounds)\n}\n\nfunction transformLocalPoint(node: VisualBoundsNode, point: Vector): Vector {\n let x = node.flipX ? node.width - point.x : point.x\n let y = node.flipY ? node.height - point.y : point.y\n const rotation = node.rotation ?? 0\n if (rotation !== 0) {\n const rotated = rotatePoint(x, y, node.width / 2, node.height / 2, degToRad(rotation))\n x = rotated.x\n y = rotated.y\n }\n return { x, y }\n}\n\nfunction transformedLocalBounds(node: VisualBoundsNode, local: Rect, abs: Vector): VisualBounds {\n const points = [\n { x: local.x, y: local.y },\n { x: local.x + local.width, y: local.y },\n { x: local.x + local.width, y: local.y + local.height },\n { x: local.x, y: local.y + local.height }\n ].map((point) => transformLocalPoint(node, point))\n\n return {\n minX: abs.x + Math.min(...points.map((point) => point.x)),\n minY: abs.y + Math.min(...points.map((point) => point.y)),\n maxX: abs.x + Math.max(...points.map((point) => point.x)),\n maxY: abs.y + Math.max(...points.map((point) => point.y))\n }\n}\n\nexport function nodeVisualBounds(\n node: VisualBoundsNode,\n getAbsolutePosition: (id: string) => Vector\n): VisualBounds {\n const abs = getAbsolutePosition(node.id)\n const base = computeVisualBounds([node], getAbsolutePosition)\n let bounds: VisualBounds = {\n minX: base.x,\n minY: base.y,\n maxX: base.x + base.width,\n maxY: base.y + base.height\n }\n\n const hasNonInsideStroke = node.strokes?.some(\n (stroke) => stroke.visible && stroke.align !== 'INSIDE'\n )\n const localGeometry = geometryBlobBounds([\n ...(node.fillGeometry ?? []),\n ...(hasNonInsideStroke ? (node.strokeGeometry ?? []) : [])\n ])\n if (localGeometry) {\n bounds = unionVisualBounds(bounds, transformedLocalBounds(node, localGeometry, abs)) ?? bounds\n }\n\n const linesOverflow = textLinesOverflow(node)\n if (linesOverflow > 0) {\n const lines = { x: 0, y: 0, width: node.width, height: node.height + linesOverflow }\n bounds = unionVisualBounds(bounds, transformedLocalBounds(node, lines, abs)) ?? bounds\n }\n\n bounds.maxY += textDecorationOverflow(node)\n\n return bounds\n}\n\n/** How far a text node's underline or strikethrough reaches below its box. */\nexport function textDecorationOverflow(node: VisualBoundsNode): number {\n if (node.type !== 'TEXT' || !node.textDecoration || node.textDecoration === 'NONE') return 0\n const fontSize = node.fontSize ?? 14\n const underlineOffset = node.textUnderlineOffset ?? fontSize * 0.18\n const thickness = node.textDecorationThickness ?? Math.max(1, fontSize / 16)\n return underlineOffset + thickness + fontSize * 0.35\n}\n\nfunction collectDescendantVisualBounds(\n nodeId: string,\n getNode: (id: string) => VisualBoundsNode | undefined,\n getAbsolutePosition: (id: string) => Vector,\n clip: VisualBounds | null = null\n): VisualBounds | null {\n const node = getNode(nodeId)\n if (!node?.visible) return null\n\n const own = nodeVisualBounds(node, getAbsolutePosition)\n let bounds = clip ? intersectVisualBounds(own, clip) : own\n\n const isClippableContainer =\n node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE'\n let childClip = clip\n if (isClippableContainer && node.clipsContent) {\n const abs = getAbsolutePosition(node.id)\n const nodeClip = {\n minX: abs.x,\n minY: abs.y,\n maxX: abs.x + node.width,\n maxY: abs.y + node.height\n }\n childClip = childClip ? intersectVisualBounds(childClip, nodeClip) : nodeClip\n if (!childClip) return bounds\n }\n\n for (const childId of node.childIds ?? []) {\n bounds = unionVisualBounds(\n bounds,\n collectDescendantVisualBounds(childId, getNode, getAbsolutePosition, childClip)\n )\n }\n\n return bounds\n}\n\nexport function computeDescendantVisualBounds(\n nodeIds: string[],\n getNode: (id: string) => VisualBoundsNode | undefined,\n getAbsolutePosition: (id: string) => Vector\n): VisualBounds | null {\n let bounds: VisualBounds | null = null\n for (const nodeId of nodeIds) {\n bounds = unionVisualBounds(\n bounds,\n collectDescendantVisualBounds(nodeId, getNode, getAbsolutePosition)\n )\n }\n return bounds\n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fill, GradientStop, GradientTransform, MeshGradientPoint } from "./types.js";
|
|
3
|
+
//#region src/gradient.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gradient paints in Figma's convention. A paint's `gradientTransform` maps the layer's unit
|
|
6
|
+
* square to gradient space, as Figma's plugin API, `.fig` files, and the clipboard store it. In
|
|
7
|
+
* gradient space a linear gradient runs from (0, 0.5) to (1, 0.5); radial, angular, and diamond
|
|
8
|
+
* gradients are centred on (0.5, 0.5) with radius 0.5, and an angular one starts at +x and turns
|
|
9
|
+
* clockwise. Every reader and writer of gradients goes through this module.
|
|
10
|
+
*/
|
|
11
|
+
type GradientFillType = Extract<Fill['type'], 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR' | 'GRADIENT_DIAMOND'>;
|
|
12
|
+
/** A mesh's point count for its grid: one more point than cells each way, row-major. */
|
|
13
|
+
declare function meshPointCount(columns: number, rows: number): number;
|
|
14
|
+
/** Whether a fill draws as a mesh: type `MESH` with a complete grid of points. */
|
|
15
|
+
declare function isMeshFill(fill: Fill): boolean;
|
|
16
|
+
/** A new 1x1 mesh over the layer's unit square, tinted with the fill color. */
|
|
17
|
+
declare function defaultMeshPoints(color: Color): MeshGradientPoint[];
|
|
18
|
+
/**
|
|
19
|
+
* A new mesh grid over the layer's unit square: points evenly spaced, all tinted with the fill
|
|
20
|
+
* color. Columns and rows count cells, so the grid holds one more point each way.
|
|
21
|
+
*/
|
|
22
|
+
declare function defaultMeshGrid(color: Color, columns: number, rows: number): MeshGradientPoint[];
|
|
23
|
+
/**
|
|
24
|
+
* A grid of a new size sampled from an old one: positions evenly spaced, colors blended from the
|
|
25
|
+
* old grid, so resizing keeps the look. Gaps where the old grid is short read as transparent.
|
|
26
|
+
*/
|
|
27
|
+
declare function resampleMeshPoints(points: readonly MeshGradientPoint[], fromColumns: number, fromRows: number, toColumns: number, toRows: number): MeshGradientPoint[];
|
|
28
|
+
declare function isGradientFill(type: Fill['type']): type is GradientFillType;
|
|
29
|
+
/** Left to right for a linear gradient; centred and filling the layer for the others. */
|
|
30
|
+
declare const IDENTITY_GRADIENT_TRANSFORM: GradientTransform;
|
|
31
|
+
/**
|
|
32
|
+
* Figma's transform when a fill becomes a gradient: top to bottom, and centred when switched to
|
|
33
|
+
* another kind (Figma desktop 126).
|
|
34
|
+
*/
|
|
35
|
+
declare const DEFAULT_GRADIENT_TRANSFORM: GradientTransform;
|
|
36
|
+
/**
|
|
37
|
+
* A paint transform as Figma's plugin API gives and takes it, and as authors write it: two rows of
|
|
38
|
+
* three, `[[m00, m01, m02], [m10, m11, m12]]`.
|
|
39
|
+
*/
|
|
40
|
+
type GradientTransformRows = [[number, number, number], [number, number, number]];
|
|
41
|
+
/** `t` as Figma's plugin API gives a paint transform: two rows of three. */
|
|
42
|
+
declare function gradientTransformRows(t: GradientTransform): GradientTransformRows;
|
|
43
|
+
/** Figma's stops for a new gradient: the fill colour, then a 60% shade of it. */
|
|
44
|
+
declare function defaultGradientStops(color: Color): GradientStop[];
|
|
45
|
+
declare function isIdentityGradientTransform(t: GradientTransform): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The inverse affine map; a singular one falls back to the identity. Inverting a
|
|
48
|
+
* `gradientTransform` gives the map from gradient space to the layer's unit square.
|
|
49
|
+
*/
|
|
50
|
+
declare function invertGradientTransform(t: GradientTransform): GradientTransform;
|
|
51
|
+
/** A point through an affine map. */
|
|
52
|
+
declare function applyGradientTransform(t: GradientTransform, point: Vector): Vector;
|
|
53
|
+
/** Where a point of gradient space falls in the layer's unit square. */
|
|
54
|
+
declare function gradientPoint(t: GradientTransform, point: Vector): Vector;
|
|
55
|
+
/**
|
|
56
|
+
* The transform of a linear gradient from `start` to `end` whose bands run along `across`, all in
|
|
57
|
+
* the layer's unit square, such as an SVG gradient mapped through its own transform.
|
|
58
|
+
*/
|
|
59
|
+
declare function linearGradientTransformFromAxes(start: Vector, end: Vector, across: Vector): GradientTransform;
|
|
60
|
+
/**
|
|
61
|
+
* The transform of a linear gradient from `start` to `end`, both in the layer's unit square, in a
|
|
62
|
+
* `width` × `height` layer. Its second axis is square to the line on screen and `ratio` times as
|
|
63
|
+
* long; Figma keeps that ratio when a handle is dragged (measured on desktop 126), and it starts
|
|
64
|
+
* as the layer's height over its width.
|
|
65
|
+
*/
|
|
66
|
+
declare function linearGradientTransform(start: Vector, end: Vector, width?: number, height?: number, ratio?: number): GradientTransform;
|
|
67
|
+
/**
|
|
68
|
+
* The transform of a radial, angular, or diamond gradient from its centre and the ends of its two
|
|
69
|
+
* radii, all in the layer's unit square.
|
|
70
|
+
*/
|
|
71
|
+
declare function ellipticalGradientTransform(center: Vector, radiusX: Vector, radiusY: Vector): GradientTransform;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { DEFAULT_GRADIENT_TRANSFORM, GradientFillType, GradientTransformRows, IDENTITY_GRADIENT_TRANSFORM, applyGradientTransform, defaultGradientStops, defaultMeshGrid, defaultMeshPoints, ellipticalGradientTransform, gradientPoint, gradientTransformRows, invertGradientTransform, isGradientFill, isIdentityGradientTransform, isMeshFill, linearGradientTransform, linearGradientTransformFromAxes, meshPointCount, resampleMeshPoints };
|
|
74
|
+
//# sourceMappingURL=gradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","names":[],"sources":["../src/gradient.ts"],"mappings":";;;;;;;;;;KAWY,mBAAmB,QAC7B;;iBAKc,eAAe,iBAAiB;;iBAKhC,WAAW,MAAM;;iBASjB,kBAAkB,OAAO,QAAQ;;;;;iBAQjC,gBAAgB,OAAO,OAAO,iBAAiB,eAAe;;;;;iBA8C9D,mBACd,iBAAiB,qBACjB,qBACA,kBACA,mBACA,iBACC;iBAoBa,eAAe,MAAM,eAAe,QAAQ;;cAU/C,6BAA6B;;;;;cAa7B,4BAA4B;;;;;KAa7B;;iBAGI,sBAAsB,GAAG,oBAAoB;;iBAW7C,qBAAqB,OAAO,QAAQ;iBAepC,4BAA4B,GAAG;;;;;iBAU/B,wBAAwB,GAAG,oBAAoB;;iBAkB/C,uBAAuB,GAAG,mBAAmB,OAAO,SAAS;;iBAQ7D,cAAc,GAAG,mBAAmB,OAAO,SAAS;;;;;iBAQpD,gCACd,OAAO,QACP,KAAK,QACL,QAAQ,SACP;;;;;;;iBAiBa,wBACd,OAAO,QACP,KAAK,QACL,gBACA,iBACA,iBACC;;;;;iBAYa,4BACd,QAAQ,QACR,SAAS,QACT,SAAS,SACR"}
|