@pairdraw/scene-graph 0.0.0-stage → 0.16.0
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 +13 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +78 -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 +352 -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 +123 -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,209 @@
|
|
|
1
|
+
import { BLACK } from "../constants.js";
|
|
2
|
+
import { pixelLength } from "../text/lengths.js";
|
|
3
|
+
//#region src/connectors/sublayers.ts
|
|
4
|
+
/**
|
|
5
|
+
* A FigJam connector as Figma draws it by default: a grey line 4 px wide with rounded elbows, a
|
|
6
|
+
* round start, and an arrow at the end. Measured in FigJam.
|
|
7
|
+
*/
|
|
8
|
+
const CONNECTOR_COLOR = {
|
|
9
|
+
r: 117 / 255,
|
|
10
|
+
g: 117 / 255,
|
|
11
|
+
b: 117 / 255,
|
|
12
|
+
a: 1
|
|
13
|
+
};
|
|
14
|
+
const CONNECTOR_STROKE_WEIGHT = 4;
|
|
15
|
+
/** FigJam's line menu draws a connector Thin, at its default weight, or Thick, at twice it. */
|
|
16
|
+
const CONNECTOR_THICK_STROKE_WEIGHT = 8;
|
|
17
|
+
const CONNECTOR_CORNER_RADIUS = 24;
|
|
18
|
+
/** The face a connector's label starts in, as FigJam's: Inter Medium. */
|
|
19
|
+
const CONNECTOR_LABEL_FONT = {
|
|
20
|
+
family: "Inter",
|
|
21
|
+
weight: 500
|
|
22
|
+
};
|
|
23
|
+
/** The dash FigJam's line menu draws a connector with, longer for a thick line. Measured in FigJam. */
|
|
24
|
+
function connectorDash(weight) {
|
|
25
|
+
return weight >= 8 ? [40, 24] : [16, 10];
|
|
26
|
+
}
|
|
27
|
+
/** The style a connector's line is drawn in. */
|
|
28
|
+
function connectorLineStyle(line) {
|
|
29
|
+
const stroke = line.strokes.at(0) ?? connectorStroke();
|
|
30
|
+
return {
|
|
31
|
+
color: { ...stroke.color },
|
|
32
|
+
weight: stroke.weight,
|
|
33
|
+
dashed: (stroke.dashPattern?.length ?? 0) > 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A connector's line restyled by `style`, each part left out kept, as FigJam's colour and line
|
|
38
|
+
* menus set it. A new weight or dash takes FigJam's dash for the weight, while a new colour alone
|
|
39
|
+
* keeps the dash the line has, even one of its own. The dash goes on the stroke, which draws with
|
|
40
|
+
* it, and on the line, which files keep.
|
|
41
|
+
*/
|
|
42
|
+
function connectorLineStyleFields(line, style) {
|
|
43
|
+
const current = connectorLineStyle(line);
|
|
44
|
+
const color = style.color ?? current.color;
|
|
45
|
+
const weight = style.weight ?? current.weight;
|
|
46
|
+
const dashed = style.dashed ?? current.dashed;
|
|
47
|
+
const [stroke = connectorStroke()] = line.strokes;
|
|
48
|
+
const restyled = style.weight !== void 0 || style.dashed !== void 0;
|
|
49
|
+
const kept = stroke.dashPattern?.length ? [...stroke.dashPattern] : connectorDash(weight);
|
|
50
|
+
const dashPattern = dashed ? restyled ? connectorDash(weight) : kept : [];
|
|
51
|
+
return {
|
|
52
|
+
strokes: [{
|
|
53
|
+
...stroke,
|
|
54
|
+
color: { ...color },
|
|
55
|
+
weight,
|
|
56
|
+
dashPattern: [...dashPattern]
|
|
57
|
+
}],
|
|
58
|
+
strokeWeight: weight,
|
|
59
|
+
dashPattern
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function connectorStroke(color = CONNECTOR_COLOR) {
|
|
63
|
+
return {
|
|
64
|
+
type: "SOLID",
|
|
65
|
+
color: { ...color },
|
|
66
|
+
opacity: 1,
|
|
67
|
+
visible: true,
|
|
68
|
+
weight: 4,
|
|
69
|
+
align: "CENTER",
|
|
70
|
+
cap: "ROUND",
|
|
71
|
+
join: "ROUND"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** A connector's line, label plate, and label, in drawing order. */
|
|
75
|
+
function connectorSublayers(graph, connector) {
|
|
76
|
+
const children = graph.getChildren(connector.id);
|
|
77
|
+
if (children.length !== 3) return null;
|
|
78
|
+
const [line, labelBackground, label] = children;
|
|
79
|
+
if (line.type !== "VECTOR" || label.type !== "TEXT") return null;
|
|
80
|
+
return {
|
|
81
|
+
line,
|
|
82
|
+
labelBackground,
|
|
83
|
+
label
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* FigJam keeps a connector's box to its route, so it never turns or resizes on its own; typing
|
|
88
|
+
* into it edits its label.
|
|
89
|
+
*/
|
|
90
|
+
const CONNECTOR_KIND = {
|
|
91
|
+
complete: (graph, frame) => connectorSublayers(graph, frame) !== null,
|
|
92
|
+
text: (graph, frame) => connectorSublayers(graph, frame)?.label,
|
|
93
|
+
rotates: false,
|
|
94
|
+
resizes: false,
|
|
95
|
+
strokesAndEffects: true,
|
|
96
|
+
namedByText: false
|
|
97
|
+
};
|
|
98
|
+
function solid(color, opacity = 1) {
|
|
99
|
+
return {
|
|
100
|
+
type: "SOLID",
|
|
101
|
+
color: { ...color },
|
|
102
|
+
opacity,
|
|
103
|
+
visible: true
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Adds a connector's sublayers to a CONNECTOR the caller created; its route comes later. */
|
|
107
|
+
function buildConnectorSublayers(graph, connector, overrides = {}) {
|
|
108
|
+
return {
|
|
109
|
+
line: graph.createNode("VECTOR", connector.id, {
|
|
110
|
+
name: "Line",
|
|
111
|
+
vectorNetwork: {
|
|
112
|
+
vertices: [],
|
|
113
|
+
segments: [],
|
|
114
|
+
regions: []
|
|
115
|
+
},
|
|
116
|
+
fills: [],
|
|
117
|
+
strokes: [connectorStroke()],
|
|
118
|
+
strokeWeight: 4,
|
|
119
|
+
cornerRadius: 24,
|
|
120
|
+
...overrides.line
|
|
121
|
+
}),
|
|
122
|
+
labelBackground: graph.createNode("RECTANGLE", connector.id, {
|
|
123
|
+
name: "Label background",
|
|
124
|
+
fills: [solid({
|
|
125
|
+
r: 1,
|
|
126
|
+
g: 1,
|
|
127
|
+
b: 1,
|
|
128
|
+
a: 1
|
|
129
|
+
})],
|
|
130
|
+
cornerRadius: 3,
|
|
131
|
+
visible: false,
|
|
132
|
+
...overrides.labelBackground
|
|
133
|
+
}),
|
|
134
|
+
label: graph.createNode("TEXT", connector.id, {
|
|
135
|
+
name: "Label",
|
|
136
|
+
text: "",
|
|
137
|
+
fontFamily: CONNECTOR_LABEL_FONT.family,
|
|
138
|
+
fontWeight: CONNECTOR_LABEL_FONT.weight,
|
|
139
|
+
fontSize: 16,
|
|
140
|
+
lineHeight: pixelLength(24),
|
|
141
|
+
textAlignHorizontal: "CENTER",
|
|
142
|
+
textAutoResize: "WIDTH_AND_HEIGHT",
|
|
143
|
+
fills: [solid(BLACK)],
|
|
144
|
+
visible: false,
|
|
145
|
+
...overrides.label
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Where a connector's line starts and ends, in its parent's axes: the ends a connector keeps when
|
|
151
|
+
* the layers it was attached to are gone.
|
|
152
|
+
*/
|
|
153
|
+
function connectorRouteEnds(graph, connector) {
|
|
154
|
+
const ends = connectorLineEnds(graph, connector);
|
|
155
|
+
if (!ends) return null;
|
|
156
|
+
const at = (vertex) => ({
|
|
157
|
+
x: connector.x + ends.line.x + vertex.x,
|
|
158
|
+
y: connector.y + ends.line.y + vertex.y
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
start: at(ends.start),
|
|
162
|
+
end: at(ends.end)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** A connector's line and where it starts and ends, in the line's own axes. */
|
|
166
|
+
function connectorLineEnds(graph, connector) {
|
|
167
|
+
const line = connectorSublayers(graph, connector)?.line;
|
|
168
|
+
const vertices = line?.vectorNetwork?.vertices ?? [];
|
|
169
|
+
const start = vertices.at(0);
|
|
170
|
+
const end = vertices.at(-1);
|
|
171
|
+
return line && start && end ? {
|
|
172
|
+
line,
|
|
173
|
+
start,
|
|
174
|
+
end
|
|
175
|
+
} : null;
|
|
176
|
+
}
|
|
177
|
+
/** A free connector end at a point in the connector's parent's axes. */
|
|
178
|
+
function freeEndpoint(x, y) {
|
|
179
|
+
return {
|
|
180
|
+
nodeId: null,
|
|
181
|
+
magnet: "NONE",
|
|
182
|
+
position: {
|
|
183
|
+
x,
|
|
184
|
+
y
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** A connector end bound to a layer, following it by `magnet`. */
|
|
189
|
+
function boundEndpoint(nodeId, magnet = "AUTO") {
|
|
190
|
+
return {
|
|
191
|
+
nodeId,
|
|
192
|
+
magnet,
|
|
193
|
+
position: {
|
|
194
|
+
x: 0,
|
|
195
|
+
y: 0
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** The connector whose label `node` is, if it is one. */
|
|
200
|
+
function labelledConnector(graph, node) {
|
|
201
|
+
if (node.type !== "TEXT" || !node.parentId) return null;
|
|
202
|
+
const owner = graph.getNode(node.parentId);
|
|
203
|
+
if (owner?.type !== "CONNECTOR") return null;
|
|
204
|
+
return connectorSublayers(graph, owner)?.label.id === node.id ? owner : null;
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
export { CONNECTOR_COLOR, CONNECTOR_CORNER_RADIUS, CONNECTOR_KIND, CONNECTOR_LABEL_FONT, CONNECTOR_STROKE_WEIGHT, CONNECTOR_THICK_STROKE_WEIGHT, boundEndpoint, buildConnectorSublayers, connectorDash, connectorLineEnds, connectorLineStyle, connectorLineStyleFields, connectorRouteEnds, connectorStroke, connectorSublayers, freeEndpoint, labelledConnector };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=sublayers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sublayers.js","names":[],"sources":["../../src/connectors/sublayers.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport type { GeneratedFrameKind } from '../generated/kind'\nimport type { SceneGraph } from '../graph'\nimport type { Color, Vector } from '../primitives'\nimport { pixelLength } from '../text/lengths'\nimport type { ConnectorEndpoint, Fill, SceneNode, Stroke, VectorNetwork } from '../types'\n\n/**\n * A FigJam connector as Figma draws it by default: a grey line 4 px wide with rounded elbows, a\n * round start, and an arrow at the end. Measured in FigJam.\n */\nexport const CONNECTOR_COLOR: Color = { r: 117 / 255, g: 117 / 255, b: 117 / 255, a: 1 }\nexport const CONNECTOR_STROKE_WEIGHT = 4\n/** FigJam's line menu draws a connector Thin, at its default weight, or Thick, at twice it. */\nexport const CONNECTOR_THICK_STROKE_WEIGHT = 8\nexport const CONNECTOR_CORNER_RADIUS = 24\n/** The face a connector's label starts in, as FigJam's: Inter Medium. */\nexport const CONNECTOR_LABEL_FONT = { family: 'Inter', weight: 500 } as const\n\n/** The dash FigJam's line menu draws a connector with, longer for a thick line. Measured in FigJam. */\nexport function connectorDash(weight: number): number[] {\n return weight >= CONNECTOR_THICK_STROKE_WEIGHT ? [40, 24] : [16, 10]\n}\n\n/** How a connector's line is drawn: its colour, weight, and whether it is dashed. */\nexport interface ConnectorLineStyle {\n color: Color\n weight: number\n dashed: boolean\n}\n\n/** The style a connector's line is drawn in. */\nexport function connectorLineStyle(line: Pick<SceneNode, 'strokes'>): ConnectorLineStyle {\n const stroke = line.strokes.at(0) ?? connectorStroke()\n return {\n color: { ...stroke.color },\n weight: stroke.weight,\n dashed: (stroke.dashPattern?.length ?? 0) > 0\n }\n}\n\n/**\n * A connector's line restyled by `style`, each part left out kept, as FigJam's colour and line\n * menus set it. A new weight or dash takes FigJam's dash for the weight, while a new colour alone\n * keeps the dash the line has, even one of its own. The dash goes on the stroke, which draws with\n * it, and on the line, which files keep.\n */\nexport function connectorLineStyleFields(\n line: Pick<SceneNode, 'strokes'>,\n style: Partial<ConnectorLineStyle>\n): Partial<SceneNode> {\n const current = connectorLineStyle(line)\n const color = style.color ?? current.color\n const weight = style.weight ?? current.weight\n const dashed = style.dashed ?? current.dashed\n const [stroke = connectorStroke()] = line.strokes\n const restyled = style.weight !== undefined || style.dashed !== undefined\n const kept = stroke.dashPattern?.length ? [...stroke.dashPattern] : connectorDash(weight)\n const dashPattern = dashed ? (restyled ? connectorDash(weight) : kept) : []\n return {\n strokes: [{ ...stroke, color: { ...color }, weight, dashPattern: [...dashPattern] }],\n strokeWeight: weight,\n dashPattern\n }\n}\n\nexport function connectorStroke(color: Color = CONNECTOR_COLOR): Stroke {\n return {\n type: 'SOLID',\n color: { ...color },\n opacity: 1,\n visible: true,\n weight: CONNECTOR_STROKE_WEIGHT,\n align: 'CENTER',\n cap: 'ROUND',\n join: 'ROUND'\n }\n}\n\nexport interface ConnectorSublayers {\n /** The routed line, a vector whose ends carry the connector's caps. */\n line: SceneNode\n /** The plate behind the label, which the line breaks around. */\n labelBackground: SceneNode\n label: SceneNode\n}\n\n/** A connector's line, label plate, and label, in drawing order. */\nexport function connectorSublayers(\n graph: SceneGraph,\n connector: SceneNode\n): ConnectorSublayers | null {\n const children = graph.getChildren(connector.id)\n if (children.length !== 3) return null\n const [line, labelBackground, label] = children\n if (line.type !== 'VECTOR' || label.type !== 'TEXT') return null\n return { line, labelBackground, label }\n}\n\n/**\n * FigJam keeps a connector's box to its route, so it never turns or resizes on its own; typing\n * into it edits its label.\n */\nexport const CONNECTOR_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => connectorSublayers(graph, frame) !== null,\n text: (graph, frame) => connectorSublayers(graph, frame)?.label,\n rotates: false,\n resizes: false,\n strokesAndEffects: true,\n namedByText: false\n}\n\nfunction solid(color: Color, opacity = 1): Fill {\n return { type: 'SOLID', color: { ...color }, opacity, visible: true }\n}\n\n/** Adds a connector's sublayers to a CONNECTOR the caller created; its route comes later. */\nexport function buildConnectorSublayers(\n graph: SceneGraph,\n connector: SceneNode,\n overrides: Partial<Record<keyof ConnectorSublayers, Partial<SceneNode>>> = {}\n): ConnectorSublayers {\n const empty: VectorNetwork = { vertices: [], segments: [], regions: [] }\n const line = graph.createNode('VECTOR', connector.id, {\n name: 'Line',\n vectorNetwork: empty,\n fills: [],\n strokes: [connectorStroke()],\n strokeWeight: CONNECTOR_STROKE_WEIGHT,\n cornerRadius: CONNECTOR_CORNER_RADIUS,\n ...overrides.line\n })\n const labelBackground = graph.createNode('RECTANGLE', connector.id, {\n name: 'Label background',\n fills: [solid({ r: 1, g: 1, b: 1, a: 1 })],\n cornerRadius: 3,\n visible: false,\n ...overrides.labelBackground\n })\n const label = graph.createNode('TEXT', connector.id, {\n name: 'Label',\n text: '',\n fontFamily: CONNECTOR_LABEL_FONT.family,\n fontWeight: CONNECTOR_LABEL_FONT.weight,\n fontSize: 16,\n lineHeight: pixelLength(24),\n textAlignHorizontal: 'CENTER',\n textAutoResize: 'WIDTH_AND_HEIGHT',\n fills: [solid(BLACK)],\n visible: false,\n ...overrides.label\n })\n return { line, labelBackground, label }\n}\n\n/**\n * Where a connector's line starts and ends, in its parent's axes: the ends a connector keeps when\n * the layers it was attached to are gone.\n */\nexport function connectorRouteEnds(\n graph: SceneGraph,\n connector: SceneNode\n): { start: Vector; end: Vector } | null {\n const ends = connectorLineEnds(graph, connector)\n if (!ends) return null\n const at = (vertex: Vector) => ({\n x: connector.x + ends.line.x + vertex.x,\n y: connector.y + ends.line.y + vertex.y\n })\n return { start: at(ends.start), end: at(ends.end) }\n}\n\n/** A connector's line and where it starts and ends, in the line's own axes. */\nexport function connectorLineEnds(\n graph: SceneGraph,\n connector: SceneNode\n): { line: SceneNode; start: Vector; end: Vector } | null {\n const line = connectorSublayers(graph, connector)?.line\n const vertices = line?.vectorNetwork?.vertices ?? []\n const start = vertices.at(0)\n const end = vertices.at(-1)\n return line && start && end ? { line, start, end } : null\n}\n\n/** A free connector end at a point in the connector's parent's axes. */\nexport function freeEndpoint(x: number, y: number): ConnectorEndpoint {\n return { nodeId: null, magnet: 'NONE', position: { x, y } }\n}\n\n/** A connector end bound to a layer, following it by `magnet`. */\nexport function boundEndpoint(\n nodeId: string,\n magnet: ConnectorEndpoint['magnet'] = 'AUTO'\n): ConnectorEndpoint {\n return { nodeId, magnet, position: { x: 0, y: 0 } }\n}\n\n/** The connector whose label `node` is, if it is one. */\nexport function labelledConnector(graph: SceneGraph, node: SceneNode): SceneNode | null {\n if (node.type !== 'TEXT' || !node.parentId) return null\n const owner = graph.getNode(node.parentId)\n if (owner?.type !== 'CONNECTOR') return null\n return connectorSublayers(graph, owner)?.label.id === node.id ? owner : null\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Color } from "./primitives/index.js";
|
|
2
|
+
//#region src/constants.d.ts
|
|
3
|
+
declare const BLACK: Color;
|
|
4
|
+
declare const WHITE: Color;
|
|
5
|
+
declare const TRANSPARENT: Color;
|
|
6
|
+
declare const DEFAULT_FONT_FAMILY = "Inter";
|
|
7
|
+
declare const DEFAULT_STROKE_MITER_LIMIT = 4;
|
|
8
|
+
declare const DEFAULT_STROKE_WEIGHT = 1;
|
|
9
|
+
/**
|
|
10
|
+
* The hidden page a document keeps the components of libraries it uses on, which it shows
|
|
11
|
+
* instances of but never edits: a component library's definitions, and a `.pen` library's.
|
|
12
|
+
*/
|
|
13
|
+
declare const LIBRARY_DEFINITIONS_PAGE_NAME = "Pairdraw library definitions";
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BLACK, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_STROKE_WEIGHT, LIBRARY_DEFINITIONS_PAGE_NAME, TRANSPARENT, WHITE };
|
|
16
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;cAEa,OAAO;cACP,OAAO;cACP,aAAa;cACb;cACA;cACA;;;;;cAKA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const BLACK = {
|
|
3
|
+
r: 0,
|
|
4
|
+
g: 0,
|
|
5
|
+
b: 0,
|
|
6
|
+
a: 1
|
|
7
|
+
};
|
|
8
|
+
const WHITE = {
|
|
9
|
+
r: 1,
|
|
10
|
+
g: 1,
|
|
11
|
+
b: 1,
|
|
12
|
+
a: 1
|
|
13
|
+
};
|
|
14
|
+
const TRANSPARENT = {
|
|
15
|
+
r: 0,
|
|
16
|
+
g: 0,
|
|
17
|
+
b: 0,
|
|
18
|
+
a: 0
|
|
19
|
+
};
|
|
20
|
+
const DEFAULT_FONT_FAMILY = "Inter";
|
|
21
|
+
const DEFAULT_STROKE_MITER_LIMIT = 4;
|
|
22
|
+
const DEFAULT_STROKE_WEIGHT = 1;
|
|
23
|
+
/**
|
|
24
|
+
* The hidden page a document keeps the components of libraries it uses on, which it shows
|
|
25
|
+
* instances of but never edits: a component library's definitions, and a `.pen` library's.
|
|
26
|
+
*/
|
|
27
|
+
const LIBRARY_DEFINITIONS_PAGE_NAME = "Pairdraw library definitions";
|
|
28
|
+
//#endregion
|
|
29
|
+
export { BLACK, DEFAULT_FONT_FAMILY, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_STROKE_WEIGHT, LIBRARY_DEFINITIONS_PAGE_NAME, TRANSPARENT, WHITE };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Color } from './primitives'\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const WHITE: Color = { r: 1, g: 1, b: 1, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\nexport const DEFAULT_STROKE_WEIGHT = 1\n/**\n * The hidden page a document keeps the components of libraries it uses on, which it shows\n * instances of but never edits: a component library's definitions, and a `.pen` library's.\n */\nexport const LIBRARY_DEFINITIONS_PAGE_NAME = 'Pairdraw library definitions'\n"],"mappings":";AAEA,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,sBAAsB;AACnC,MAAa,6BAA6B;AAC1C,MAAa,wBAAwB;;;;;AAKrC,MAAa,gCAAgC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Rect, Vector } from "./primitives/index.js";
|
|
2
|
+
import { SceneGraph } from "./graph.js";
|
|
3
|
+
import { SceneNode } from "./types.js";
|
|
4
|
+
import { Mat3 } from "./matrix.js";
|
|
5
|
+
//#region src/coordinate.d.ts
|
|
6
|
+
declare function getWorldMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3;
|
|
7
|
+
declare function getAxisAlignedWorldBounds(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Rect;
|
|
8
|
+
/**
|
|
9
|
+
* Axis-aligned canvas box of a node drawn with the world matrix `world`, for walks down the tree
|
|
10
|
+
* that compose each child's matrix from its parent's instead of climbing the ancestors again.
|
|
11
|
+
*/
|
|
12
|
+
declare function getAxisAlignedBoundsAt(node: Pick<SceneNode, 'width' | 'height'>, world: Mat3): Rect;
|
|
13
|
+
/** World matrix of a parent; the document root and a missing parent are the identity. */
|
|
14
|
+
declare function getParentWorldMatrix(parent: SceneNode | undefined, graph: Pick<SceneGraph, 'getNode' | 'rootId'>): Mat3;
|
|
15
|
+
/**
|
|
16
|
+
* Axis-aligned box of `nodes` in `parentId`'s own axes: where a group, frame, or boolean operation
|
|
17
|
+
* made from them sits. Each node's corners are mapped through the parent's inverse world matrix,
|
|
18
|
+
* so a rotated or flipped parent gets a box in its own axes and the nodes keep their drawn places
|
|
19
|
+
* once they move into the container.
|
|
20
|
+
*/
|
|
21
|
+
declare function getAxisAlignedBoundsInParent(nodes: readonly SceneNode[], parentId: string, graph: Pick<SceneGraph, 'getNode' | 'rootId'>): Rect;
|
|
22
|
+
declare function getAbsolutePosition(node: SceneNode, graph: SceneGraph): Vector;
|
|
23
|
+
declare function getAbsoluteRotation(node: SceneNode, graph: SceneGraph): number;
|
|
24
|
+
declare function getAbsolutePositionFull(node: SceneNode, graph: SceneGraph): {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
boundX: number;
|
|
28
|
+
boundY: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
rotation: number;
|
|
32
|
+
centerX: number;
|
|
33
|
+
centerY: number;
|
|
34
|
+
};
|
|
35
|
+
/** Lines retain their origin pivot; other shapes rotate around their center. */
|
|
36
|
+
declare function getNodeRotationOrigin(node: Pick<SceneNode, 'type' | 'width' | 'height'>): Vector;
|
|
37
|
+
/** What places a layer in its parent: its position, size, reflection, turn, and pivot. */
|
|
38
|
+
type NodePlacement = Pick<SceneNode, 'type' | 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'>;
|
|
39
|
+
/** Position can be applied separately by renderers before setting up local opacity layers. */
|
|
40
|
+
declare function getNodeLocalMatrix(n: NodePlacement, position?: Vector): Mat3;
|
|
41
|
+
declare function getNodeWorldBounds(node: SceneNode): Rect;
|
|
42
|
+
/**
|
|
43
|
+
* World-space positions of the 8 selection handles. `localRect` overrides the
|
|
44
|
+
* node-local box the handles sit on — text-on-path draws its handles on the
|
|
45
|
+
* glyph-fitted path box, not node bounds, so its hit-test must pass that box
|
|
46
|
+
* or the visible handles are ~25px off and unclickable. Defaults to full node
|
|
47
|
+
* bounds.
|
|
48
|
+
*/
|
|
49
|
+
declare function getWorldHandles(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>, localRect?: Rect): {
|
|
50
|
+
nw: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
};
|
|
54
|
+
n: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
58
|
+
ne: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
};
|
|
62
|
+
e: {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
};
|
|
66
|
+
se: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
70
|
+
s: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
};
|
|
74
|
+
sw: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
w: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
type LocalTransform = Pick<SceneNode, 'x' | 'y' | 'rotation' | 'flipX' | 'flipY'>;
|
|
84
|
+
/**
|
|
85
|
+
* Local transform that draws `node` with the given world matrix once it sits under a parent
|
|
86
|
+
* whose world matrix is `parentWorld`. Keeps the node's own `flipX` when the matrix allows it.
|
|
87
|
+
*/
|
|
88
|
+
declare function localTransformFromWorld(node: SceneNode, world: Mat3, parentWorld: Mat3): LocalTransform | null;
|
|
89
|
+
declare function isTranslationOnly(matrix: Mat3): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Maps a node's parent space into its container's: through the groups and booleans around it,
|
|
92
|
+
* which set no coordinate space of their own. Figma's plugin API reports `x`, `y`, and
|
|
93
|
+
* `relativeTransform` of their children in the container's space. The identity when the parent is
|
|
94
|
+
* not a group.
|
|
95
|
+
*/
|
|
96
|
+
declare function getParentToContainerMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { NodePlacement, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsAt, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld };
|
|
99
|
+
//# sourceMappingURL=coordinate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinate.d.ts","names":[],"sources":["../src/coordinate.ts"],"mappings":";;;;;iBAMgB,eAAe,MAAM,WAAW,OAAO,KAAK,yBAAyB;iBAwCrE,0BAA0B,MAAM,WAAW,OAAO,KAAK,yBAAsB;;;;;iBAQ7E,uBAAuB,MAAM,KAAK,gCAAgC,OAAO,OAAI;;iBAK7E,qBACd,QAAQ,uBACR,OAAO,KAAK,oCACX;;;;;;;iBAWa,6BACd,gBAAgB,aAChB,kBACA,OAAO,KAAK,oCACX;iBASa,oBAAoB,MAAM,WAAW,OAAO,aAAa;iBASzD,oBAAoB,MAAM,WAAW,OAAO;iBAW5C,wBAAwB,MAAM,WAAW,OAAO;;;;;;;;;;;;iBA2DhD,sBAAsB,MAAM,KAAK,0CAA0C;;KAK/E,gBAAgB,KAC1B;;iBAKc,mBAAmB,GAAG,eAAe,WAAU,SAAU;iBAczD,mBAAmB,MAAM,YAAS;;;;;;;;iBAWlC,gBACd,MAAM,WACN,OAAO,KAAK,wBACZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8CT,iBAAiB,KAAK;;;;;iBAMX,wBACd,MAAM,WACN,OAAO,MACP,aAAa,OACZ;iBAca,kBAAkB,QAAQ;;;;;;;iBAU1B,2BACd,MAAM,WACN,OAAO,KAAK,yBACX"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import Matrix from "./matrix.js";
|
|
2
|
+
import { FITTED_CONTAINER_TYPES } from "./node-defaults.js";
|
|
3
|
+
//#region src/coordinate.ts
|
|
4
|
+
function getWorldMatrix(node, graph) {
|
|
5
|
+
const chain = [];
|
|
6
|
+
let current = node;
|
|
7
|
+
while (current) {
|
|
8
|
+
chain.unshift(current);
|
|
9
|
+
if (!current.parentId) break;
|
|
10
|
+
current = graph.getNode(current.parentId);
|
|
11
|
+
}
|
|
12
|
+
let matrix = Matrix.identity();
|
|
13
|
+
for (const n of chain) {
|
|
14
|
+
const local = getNodeLocalMatrix(n);
|
|
15
|
+
matrix = Matrix.multiply(matrix, local);
|
|
16
|
+
}
|
|
17
|
+
return matrix;
|
|
18
|
+
}
|
|
19
|
+
/** Axis-aligned box around interleaved `x, y` points; empty input gives an empty box at the origin. */
|
|
20
|
+
function boundsOfPoints(points) {
|
|
21
|
+
if (points.length === 0) return {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 0
|
|
26
|
+
};
|
|
27
|
+
let minX = Infinity;
|
|
28
|
+
let minY = Infinity;
|
|
29
|
+
let maxX = -Infinity;
|
|
30
|
+
let maxY = -Infinity;
|
|
31
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
32
|
+
minX = Math.min(minX, points[i]);
|
|
33
|
+
minY = Math.min(minY, points[i + 1]);
|
|
34
|
+
maxX = Math.max(maxX, points[i]);
|
|
35
|
+
maxY = Math.max(maxY, points[i + 1]);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
x: minX,
|
|
39
|
+
y: minY,
|
|
40
|
+
width: maxX - minX,
|
|
41
|
+
height: maxY - minY
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function cornersOf(node) {
|
|
45
|
+
return [
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
node.width,
|
|
49
|
+
0,
|
|
50
|
+
node.width,
|
|
51
|
+
node.height,
|
|
52
|
+
0,
|
|
53
|
+
node.height
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
function getAxisAlignedWorldBounds(node, graph) {
|
|
57
|
+
return getAxisAlignedBoundsAt(node, getWorldMatrix(node, graph));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Axis-aligned canvas box of a node drawn with the world matrix `world`, for walks down the tree
|
|
61
|
+
* that compose each child's matrix from its parent's instead of climbing the ancestors again.
|
|
62
|
+
*/
|
|
63
|
+
function getAxisAlignedBoundsAt(node, world) {
|
|
64
|
+
return boundsOfPoints(Matrix.mapPoints(world, cornersOf(node)));
|
|
65
|
+
}
|
|
66
|
+
/** World matrix of a parent; the document root and a missing parent are the identity. */
|
|
67
|
+
function getParentWorldMatrix(parent, graph) {
|
|
68
|
+
if (!parent || parent.id === graph.rootId) return Matrix.identity();
|
|
69
|
+
return getWorldMatrix(parent, graph);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Axis-aligned box of `nodes` in `parentId`'s own axes: where a group, frame, or boolean operation
|
|
73
|
+
* made from them sits. Each node's corners are mapped through the parent's inverse world matrix,
|
|
74
|
+
* so a rotated or flipped parent gets a box in its own axes and the nodes keep their drawn places
|
|
75
|
+
* once they move into the container.
|
|
76
|
+
*/
|
|
77
|
+
function getAxisAlignedBoundsInParent(nodes, parentId, graph) {
|
|
78
|
+
const toParent = Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity();
|
|
79
|
+
return boundsOfPoints(nodes.flatMap((node) => Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), cornersOf(node))));
|
|
80
|
+
}
|
|
81
|
+
function getAbsolutePosition(node, graph) {
|
|
82
|
+
const matrix = getWorldMatrix(node, graph);
|
|
83
|
+
const p = Matrix.mapPoints(matrix, [0, 0]);
|
|
84
|
+
return {
|
|
85
|
+
x: p[0],
|
|
86
|
+
y: p[1]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function getAbsoluteRotation(node, graph) {
|
|
90
|
+
const matrix = getWorldMatrix(node, graph);
|
|
91
|
+
const a = matrix[0];
|
|
92
|
+
const b = matrix[1];
|
|
93
|
+
let deg = Math.atan2(b, a) * 180 / Math.PI;
|
|
94
|
+
deg = (deg + 360) % 360;
|
|
95
|
+
return deg;
|
|
96
|
+
}
|
|
97
|
+
function getAbsolutePositionFull(node, graph) {
|
|
98
|
+
const matrix = getWorldMatrix(node, graph);
|
|
99
|
+
const origin = Matrix.mapPoints(matrix, [0, 0]);
|
|
100
|
+
const x = origin[0];
|
|
101
|
+
const y = origin[1];
|
|
102
|
+
const [x1, y1, x2, y2, x3, y3, x4, y4] = Matrix.mapPoints(matrix, [
|
|
103
|
+
0,
|
|
104
|
+
0,
|
|
105
|
+
node.width,
|
|
106
|
+
0,
|
|
107
|
+
node.width,
|
|
108
|
+
node.height,
|
|
109
|
+
0,
|
|
110
|
+
node.height
|
|
111
|
+
]);
|
|
112
|
+
const minX = Math.min(x1, x2, x3, x4);
|
|
113
|
+
const maxX = Math.max(x1, x2, x3, x4);
|
|
114
|
+
const minY = Math.min(y1, y2, y3, y4);
|
|
115
|
+
const maxY = Math.max(y1, y2, y3, y4);
|
|
116
|
+
const width = maxX - minX;
|
|
117
|
+
const height = maxY - minY;
|
|
118
|
+
let angle = Math.atan2(matrix[3], matrix[0]);
|
|
119
|
+
if (matrix[0] * matrix[4] - matrix[1] * matrix[3] < 0) angle = -angle;
|
|
120
|
+
const rotation = angle * (180 / Math.PI);
|
|
121
|
+
const center = Matrix.mapPoints(matrix, [node.width / 2, node.height / 2]);
|
|
122
|
+
return {
|
|
123
|
+
x,
|
|
124
|
+
y,
|
|
125
|
+
boundX: minX,
|
|
126
|
+
boundY: minY,
|
|
127
|
+
width,
|
|
128
|
+
height,
|
|
129
|
+
rotation,
|
|
130
|
+
centerX: center[0],
|
|
131
|
+
centerY: center[1]
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Lines retain their origin pivot; other shapes rotate around their center. */
|
|
135
|
+
function getNodeRotationOrigin(node) {
|
|
136
|
+
return node.type === "LINE" ? {
|
|
137
|
+
x: 0,
|
|
138
|
+
y: 0
|
|
139
|
+
} : {
|
|
140
|
+
x: node.width / 2,
|
|
141
|
+
y: node.height / 2
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Position can be applied separately by renderers before setting up local opacity layers. */
|
|
145
|
+
function getNodeLocalMatrix(n, position = n) {
|
|
146
|
+
let matrix = Matrix.translated(position.x, position.y);
|
|
147
|
+
if (n.flipX || n.flipY) matrix = Matrix.multiply(matrix, Matrix.scaled(n.flipX ? -1 : 1, n.flipY ? -1 : 1, n.width / 2, n.height / 2));
|
|
148
|
+
if (n.rotation) {
|
|
149
|
+
const pivot = getNodeRotationOrigin(n);
|
|
150
|
+
matrix = Matrix.multiply(matrix, Matrix.rotated(n.rotation * Math.PI / 180, pivot.x, pivot.y));
|
|
151
|
+
}
|
|
152
|
+
return matrix;
|
|
153
|
+
}
|
|
154
|
+
function getNodeWorldBounds(node) {
|
|
155
|
+
return boundsOfPoints(Matrix.mapPoints(getNodeLocalMatrix(node), cornersOf(node)));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* World-space positions of the 8 selection handles. `localRect` overrides the
|
|
159
|
+
* node-local box the handles sit on — text-on-path draws its handles on the
|
|
160
|
+
* glyph-fitted path box, not node bounds, so its hit-test must pass that box
|
|
161
|
+
* or the visible handles are ~25px off and unclickable. Defaults to full node
|
|
162
|
+
* bounds.
|
|
163
|
+
*/
|
|
164
|
+
function getWorldHandles(node, graph, localRect) {
|
|
165
|
+
const matrix = getWorldMatrix(node, graph);
|
|
166
|
+
const x0 = localRect?.x ?? 0;
|
|
167
|
+
const y0 = localRect?.y ?? 0;
|
|
168
|
+
const w = localRect?.width ?? node.width;
|
|
169
|
+
const h = localRect?.height ?? node.height;
|
|
170
|
+
const mx = x0 + w / 2;
|
|
171
|
+
const my = y0 + h / 2;
|
|
172
|
+
const x1 = x0 + w;
|
|
173
|
+
const y1 = y0 + h;
|
|
174
|
+
const localPts = [
|
|
175
|
+
x0,
|
|
176
|
+
y0,
|
|
177
|
+
mx,
|
|
178
|
+
y0,
|
|
179
|
+
x1,
|
|
180
|
+
y0,
|
|
181
|
+
x1,
|
|
182
|
+
my,
|
|
183
|
+
x1,
|
|
184
|
+
y1,
|
|
185
|
+
mx,
|
|
186
|
+
y1,
|
|
187
|
+
x0,
|
|
188
|
+
y1,
|
|
189
|
+
x0,
|
|
190
|
+
my
|
|
191
|
+
];
|
|
192
|
+
const pts = Matrix.mapPoints(matrix, localPts);
|
|
193
|
+
return {
|
|
194
|
+
nw: {
|
|
195
|
+
x: pts[0],
|
|
196
|
+
y: pts[1]
|
|
197
|
+
},
|
|
198
|
+
n: {
|
|
199
|
+
x: pts[2],
|
|
200
|
+
y: pts[3]
|
|
201
|
+
},
|
|
202
|
+
ne: {
|
|
203
|
+
x: pts[4],
|
|
204
|
+
y: pts[5]
|
|
205
|
+
},
|
|
206
|
+
e: {
|
|
207
|
+
x: pts[6],
|
|
208
|
+
y: pts[7]
|
|
209
|
+
},
|
|
210
|
+
se: {
|
|
211
|
+
x: pts[8],
|
|
212
|
+
y: pts[9]
|
|
213
|
+
},
|
|
214
|
+
s: {
|
|
215
|
+
x: pts[10],
|
|
216
|
+
y: pts[11]
|
|
217
|
+
},
|
|
218
|
+
sw: {
|
|
219
|
+
x: pts[12],
|
|
220
|
+
y: pts[13]
|
|
221
|
+
},
|
|
222
|
+
w: {
|
|
223
|
+
x: pts[14],
|
|
224
|
+
y: pts[15]
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Local transform that draws `node` with the given world matrix once it sits under a parent
|
|
230
|
+
* whose world matrix is `parentWorld`. Keeps the node's own `flipX` when the matrix allows it.
|
|
231
|
+
*/
|
|
232
|
+
function localTransformFromWorld(node, world, parentWorld) {
|
|
233
|
+
const parentInverse = Matrix.invert(parentWorld);
|
|
234
|
+
if (!parentInverse) return null;
|
|
235
|
+
const local = Matrix.multiply(parentInverse, world);
|
|
236
|
+
const [a, b, , c, d] = local;
|
|
237
|
+
const sx = node.flipX ? -1 : 1;
|
|
238
|
+
const sy = a * d - b * c < 0 ? -sx : sx;
|
|
239
|
+
let rotation = Math.atan2(sy * c, sx * a) * 180 / Math.PI;
|
|
240
|
+
if (Math.abs(rotation) < 1e-9) rotation = 0;
|
|
241
|
+
const transform = {
|
|
242
|
+
rotation,
|
|
243
|
+
flipX: sx < 0,
|
|
244
|
+
flipY: sy < 0
|
|
245
|
+
};
|
|
246
|
+
const origin = getNodeLocalMatrix({
|
|
247
|
+
...node,
|
|
248
|
+
...transform
|
|
249
|
+
}, {
|
|
250
|
+
x: 0,
|
|
251
|
+
y: 0
|
|
252
|
+
});
|
|
253
|
+
return {
|
|
254
|
+
...transform,
|
|
255
|
+
x: local[2] - origin[2],
|
|
256
|
+
y: local[5] - origin[5]
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function isTranslationOnly(matrix) {
|
|
260
|
+
return matrix[0] === 1 && matrix[1] === 0 && matrix[3] === 0 && matrix[4] === 1;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Maps a node's parent space into its container's: through the groups and booleans around it,
|
|
264
|
+
* which set no coordinate space of their own. Figma's plugin API reports `x`, `y`, and
|
|
265
|
+
* `relativeTransform` of their children in the container's space. The identity when the parent is
|
|
266
|
+
* not a group.
|
|
267
|
+
*/
|
|
268
|
+
function getParentToContainerMatrix(node, graph) {
|
|
269
|
+
let matrix = Matrix.identity();
|
|
270
|
+
for (let parent = node.parentId ? graph.getNode(node.parentId) : void 0; parent && FITTED_CONTAINER_TYPES.has(parent.type); parent = parent.parentId ? graph.getNode(parent.parentId) : void 0) matrix = Matrix.multiply(getNodeLocalMatrix(parent), matrix);
|
|
271
|
+
return matrix;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
export { getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getAxisAlignedBoundsAt, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getNodeLocalMatrix, getNodeRotationOrigin, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getWorldHandles, getWorldMatrix, isTranslationOnly, localTransformFromWorld };
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=coordinate.js.map
|