@pairdraw/scene-graph 0.0.0-stage → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/agent-notes/index.d.ts +3 -0
- package/dist/agent-notes/index.js +3 -0
- package/dist/agent-notes/model.d.ts +23 -0
- package/dist/agent-notes/model.d.ts.map +1 -0
- package/dist/agent-notes/model.js +36 -0
- package/dist/agent-notes/model.js.map +1 -0
- package/dist/agent-notes/schema.d.ts +19 -0
- package/dist/agent-notes/schema.d.ts.map +1 -0
- package/dist/agent-notes/schema.js +17 -0
- package/dist/agent-notes/schema.js.map +1 -0
- package/dist/arrow-caps.d.ts +65 -0
- package/dist/arrow-caps.d.ts.map +1 -0
- package/dist/arrow-caps.js +365 -0
- package/dist/arrow-caps.js.map +1 -0
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js +27 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +56 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/behaviours/kinds.js +273 -0
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +42 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +45 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +149 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +114 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +71 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/behaviours/spec.js +157 -0
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +18 -0
- package/dist/bindings.js.map +1 -0
- package/dist/browser-node/index.d.ts +3 -0
- package/dist/browser-node/index.js +3 -0
- package/dist/browser-node/model.d.ts +18 -0
- package/dist/browser-node/model.d.ts.map +1 -0
- package/dist/browser-node/model.js +31 -0
- package/dist/browser-node/model.js.map +1 -0
- package/dist/browser-node/schema.d.ts +23 -0
- package/dist/browser-node/schema.d.ts.map +1 -0
- package/dist/browser-node/schema.js +44 -0
- package/dist/browser-node/schema.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js +57 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +28 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +246 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +20 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/color/contrast.js +69 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/comments/document.js +33 -0
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/comments/merge.js +58 -0
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/comments/threads.js +132 -0
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/library-page.d.ts +11 -0
- package/dist/components/library-page.d.ts.map +1 -0
- package/dist/components/library-page.js +21 -0
- package/dist/components/library-page.js.map +1 -0
- package/dist/components/properties.d.ts +20 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +125 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +27 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +32 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +53 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +159 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +209 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +99 -0
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +276 -0
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +45 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +256 -0
- package/dist/copy.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/css/grid.js +63 -0
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +6 -0
- package/dist/css/index.js +6 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/events.js +18 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +19 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +33 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js +14 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +63 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +199 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +277 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +68 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +89 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +46 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +62 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +29 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +38 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +119 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +234 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +105 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +374 -0
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +74 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +211 -0
- package/dist/gradient.js.map +1 -0
- package/dist/graph.d.ts +186 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +630 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/group-bounds.js +146 -0
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +19 -0
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +39 -0
- package/dist/guides.js.map +1 -0
- package/dist/hit-test.d.ts +49 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +315 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/icons/glyph.js +109 -0
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +85 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +162 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +82 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +63 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +305 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/main-component.d.ts +11 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +42 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/modes.js +26 -0
- package/dist/instances/modes.js.map +1 -0
- package/dist/instances/overrides.d.ts +63 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +164 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/replacements.d.ts +19 -0
- package/dist/instances/replacements.d.ts.map +1 -0
- package/dist/instances/replacements.js +67 -0
- package/dist/instances/replacements.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/sync.js +305 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +60 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +120 -0
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/naming.d.ts +9 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +16 -0
- package/dist/naming.js.map +1 -0
- package/dist/node-defaults.d.ts +19 -0
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +243 -0
- package/dist/node-defaults.js.map +1 -0
- package/dist/order-keys.d.ts +39 -0
- package/dist/order-keys.d.ts.map +1 -0
- package/dist/order-keys.js +136 -0
- package/dist/order-keys.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +103 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +64 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +36 -0
- package/dist/parse-path.d.ts.map +1 -0
- package/dist/parse-path.js +200 -0
- package/dist/parse-path.js.map +1 -0
- package/dist/plugin-data/citation.d.ts +13 -0
- package/dist/plugin-data/citation.d.ts.map +1 -0
- package/dist/plugin-data/citation.js +23 -0
- package/dist/plugin-data/citation.js.map +1 -0
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +79 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +220 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +214 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +5 -0
- package/dist/plugin-data/index.js +5 -0
- package/dist/plugin-data/schema.d.ts +18 -0
- package/dist/plugin-data/schema.d.ts.map +1 -0
- package/dist/plugin-data/schema.js +29 -0
- package/dist/plugin-data/schema.js.map +1 -0
- package/dist/polygon.d.ts +55 -0
- package/dist/polygon.d.ts.map +1 -0
- package/dist/polygon.js +220 -0
- package/dist/polygon.js.map +1 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +63 -0
- package/dist/preview.js.map +1 -0
- package/dist/primitives/index.d.ts +43 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.d.ts +7 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +25 -0
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +41 -0
- package/dist/resize.d.ts.map +1 -0
- package/dist/resize.js +288 -0
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +150 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +22 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +71 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/script/index.d.ts +2 -0
- package/dist/script/index.js +2 -0
- package/dist/script/schema.d.ts +29 -0
- package/dist/script/schema.d.ts.map +1 -0
- package/dist/script/schema.js +51 -0
- package/dist/script/schema.js.map +1 -0
- package/dist/shaders/directives.d.ts +43 -0
- package/dist/shaders/directives.d.ts.map +1 -0
- package/dist/shaders/directives.js +293 -0
- package/dist/shaders/directives.js.map +1 -0
- package/dist/shaders/index.d.ts +5 -0
- package/dist/shaders/index.js +5 -0
- package/dist/shaders/model.d.ts +58 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +109 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +86 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +65 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +36 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +116 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +74 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +103 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +38 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +113 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +61 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +264 -0
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.d.ts +6 -0
- package/dist/source-metadata.d.ts.map +1 -0
- package/dist/source-metadata.js +11 -0
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/text/direction.d.ts +13 -0
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/text/direction.js +31 -0
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +19 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +40 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/text/picture.d.ts +18 -0
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +41 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +7 -0
- package/dist/transfer/index.js +7 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +82 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +910 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +89 -0
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +236 -0
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +66 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +251 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +30 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +89 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +246 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +21 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +58 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/variant-name.d.ts +6 -0
- package/dist/variant-name.d.ts.map +1 -0
- package/dist/variant-name.js +17 -0
- package/dist/variant-name.js.map +1 -0
- package/dist/variant-properties.d.ts +18 -0
- package/dist/variant-properties.d.ts.map +1 -0
- package/dist/variant-properties.js +74 -0
- package/dist/variant-properties.js.map +1 -0
- package/dist/vector-network.d.ts +48 -0
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +352 -0
- package/dist/vector-network.js.map +1 -0
- package/package.json +364 -4
- package/src/agent-notes/index.ts +2 -0
- package/src/agent-notes/model.ts +46 -0
- package/src/agent-notes/schema.ts +28 -0
- package/src/arrow-caps.ts +364 -0
- package/src/asset-keys.ts +25 -0
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +185 -0
- package/src/behaviours/layers.ts +51 -0
- package/src/behaviours/model.ts +184 -0
- package/src/behaviours/schema.ts +93 -0
- package/src/behaviours/spec.ts +178 -0
- package/src/bindings.ts +20 -0
- package/src/browser-node/index.ts +2 -0
- package/src/browser-node/model.ts +35 -0
- package/src/browser-node/schema.ts +62 -0
- package/src/buffered-events.ts +64 -0
- package/src/checkpoint.ts +325 -0
- package/src/clipping.ts +112 -0
- package/src/color/contrast.ts +71 -0
- package/src/color/index.ts +89 -0
- package/src/color/management.ts +210 -0
- package/src/color/normalize.ts +7 -0
- package/src/color/okhcl.ts +201 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +51 -0
- package/src/comments/index.ts +5 -0
- package/src/comments/list.ts +52 -0
- package/src/comments/merge.ts +63 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +156 -0
- package/src/components/exposure.ts +61 -0
- package/src/components/index.ts +9 -0
- package/src/components/library-page.ts +17 -0
- package/src/components/properties.ts +241 -0
- package/src/components/variants.ts +53 -0
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +60 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +144 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +204 -0
- package/src/constants.ts +13 -0
- package/src/coordinate.ts +298 -0
- package/src/copy.ts +341 -0
- package/src/css/grid.ts +70 -0
- package/src/css/index.ts +10 -0
- package/src/css/layout.ts +53 -0
- package/src/css/shadows.ts +68 -0
- package/src/css/text.ts +84 -0
- package/src/css/values.ts +42 -0
- package/src/events.ts +21 -0
- package/src/export-format.ts +33 -0
- package/src/export-scale.ts +16 -0
- package/src/fields/appearance.ts +35 -0
- package/src/fields/geometry.ts +11 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +64 -0
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +308 -0
- package/src/figjam/text.ts +78 -0
- package/src/font-style.ts +121 -0
- package/src/generated/index.ts +81 -0
- package/src/generated/kind.ts +26 -0
- package/src/generated/shape-with-text.ts +132 -0
- package/src/generated/sticky.ts +214 -0
- package/src/geometry.ts +490 -0
- package/src/gradient.ts +275 -0
- package/src/graph.ts +842 -0
- package/src/group-bounds.ts +178 -0
- package/src/guides.ts +47 -0
- package/src/hit-test.ts +501 -0
- package/src/icons/glyph.ts +128 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +63 -0
- package/src/icons/schema.ts +34 -0
- package/src/ids.ts +34 -0
- package/src/images.ts +89 -0
- package/src/index.ts +4 -0
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +84 -0
- package/src/instances/copies.ts +244 -0
- package/src/instances/cycles.ts +73 -0
- package/src/instances/fields.ts +90 -0
- package/src/instances/index.ts +467 -0
- package/src/instances/main-component.ts +61 -0
- package/src/instances/modes.ts +39 -0
- package/src/instances/overrides.ts +240 -0
- package/src/instances/placement.ts +29 -0
- package/src/instances/replacements.ts +80 -0
- package/src/instances/source-walk.ts +35 -0
- package/src/instances/sync.ts +556 -0
- package/src/instances/vector-geometry.ts +81 -0
- package/src/layout/aspect-ratio.ts +51 -0
- package/src/layout/guides.ts +132 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/keywords.ts +74 -0
- package/src/layout/sizing.ts +196 -0
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +116 -0
- package/src/mutation-impact.ts +85 -0
- package/src/naming.ts +11 -0
- package/src/node-defaults.ts +260 -0
- package/src/order-keys.ts +162 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +72 -0
- package/src/parse-path.ts +244 -0
- package/src/plugin-data/citation.ts +27 -0
- package/src/plugin-data/field.ts +140 -0
- package/src/plugin-data/fields.ts +306 -0
- package/src/plugin-data/index.ts +3 -0
- package/src/plugin-data/schema.ts +35 -0
- package/src/polygon.ts +228 -0
- package/src/preview.ts +80 -0
- package/src/primitives/index.ts +44 -0
- package/src/primitives/schema.ts +14 -0
- package/src/random.ts +28 -0
- package/src/resize.ts +415 -0
- package/src/scaling/index.ts +9 -0
- package/src/scaling/node.ts +168 -0
- package/src/scaling/tree.ts +85 -0
- package/src/script/index.ts +1 -0
- package/src/script/schema.ts +65 -0
- package/src/shaders/directives.ts +366 -0
- package/src/shaders/index.ts +4 -0
- package/src/shaders/model.ts +147 -0
- package/src/shaders/schema.ts +84 -0
- package/src/shaders/still.ts +41 -0
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +137 -0
- package/src/slots/authoring.ts +101 -0
- package/src/slots/content.ts +127 -0
- package/src/slots/frames.ts +160 -0
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +49 -0
- package/src/snap.ts +349 -0
- package/src/source-metadata.ts +8 -0
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/direction.ts +55 -0
- package/src/text/index.ts +6 -0
- package/src/text/lengths.ts +34 -0
- package/src/text/lists.ts +138 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/paragraphs.ts +241 -0
- package/src/text/picture.ts +57 -0
- package/src/text/references.ts +50 -0
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +84 -0
- package/src/transfer/history.ts +49 -0
- package/src/transfer/identity.ts +16 -0
- package/src/transfer/index.ts +6 -0
- package/src/transfer/nodes.ts +128 -0
- package/src/transfer/plan.ts +130 -0
- package/src/transfer/references.ts +9 -0
- package/src/transfer/remove.ts +39 -0
- package/src/transfer/validation.ts +59 -0
- package/src/transfer/variables.ts +83 -0
- package/src/types.ts +1205 -0
- package/src/undo.ts +285 -0
- package/src/variables/bindings.ts +310 -0
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +109 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/variables/index.ts +400 -0
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +61 -0
- package/src/variables/token.ts +40 -0
- package/src/variables/units.ts +15 -0
- package/src/variables/value.ts +92 -0
- package/src/variant-name.ts +15 -0
- package/src/variant-properties.ts +98 -0
- package/src/vector-network.ts +489 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import Matrix from "../matrix.js";
|
|
2
|
+
import { getAxisAlignedBoundsInParent, getParentWorldMatrix, getWorldMatrix } from "../coordinate.js";
|
|
3
|
+
import { computeBounds } from "../geometry.js";
|
|
4
|
+
import { connectorRouteEnds, connectorSublayers } from "./sublayers.js";
|
|
5
|
+
import { connectorNetwork, piecesBounds } from "./pieces.js";
|
|
6
|
+
import { connectorSides } from "./sides.js";
|
|
7
|
+
import { elbowControlPoints } from "./controls.js";
|
|
8
|
+
import { CONNECTOR_LABEL_PADDING, placeConnectorLabel } from "./label.js";
|
|
9
|
+
import { routeConnector } from "./route.js";
|
|
10
|
+
import { compact, isEqual, pick } from "es-toolkit";
|
|
11
|
+
//#region src/connectors/layout.ts
|
|
12
|
+
/**
|
|
13
|
+
* An end as the router sees it, in the connector's parent's axes: the box of the layer it follows
|
|
14
|
+
* by a magnet, or a point, which an end pinned to a point of its layer follows as the layer moves.
|
|
15
|
+
* An end whose layer is gone stays where its route last ended.
|
|
16
|
+
*/
|
|
17
|
+
function routeEnd(graph, connector, endpoint, cap, fallback) {
|
|
18
|
+
const parentId = connector.parentId;
|
|
19
|
+
if (!parentId) return null;
|
|
20
|
+
const node = endpoint.nodeId ? graph.getNode(endpoint.nodeId) : void 0;
|
|
21
|
+
if (!node) {
|
|
22
|
+
if (endpoint.nodeId && !fallback) return null;
|
|
23
|
+
return {
|
|
24
|
+
box: null,
|
|
25
|
+
point: endpoint.nodeId && fallback ? fallback : endpoint.position,
|
|
26
|
+
magnet: "NONE",
|
|
27
|
+
cap,
|
|
28
|
+
outline: 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const centred = endpoint.magnet === "CENTER" && connector.connectorLineType !== "STRAIGHT";
|
|
32
|
+
if (endpoint.magnet === "NONE" || endpoint.magnet === "ABSOLUTE" || centred) {
|
|
33
|
+
const toParent = Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity();
|
|
34
|
+
const local = centred ? {
|
|
35
|
+
x: node.width / 2,
|
|
36
|
+
y: node.height / 2
|
|
37
|
+
} : endpoint.position;
|
|
38
|
+
const [x, y] = Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), [local.x, local.y]);
|
|
39
|
+
return {
|
|
40
|
+
box: null,
|
|
41
|
+
point: {
|
|
42
|
+
x,
|
|
43
|
+
y
|
|
44
|
+
},
|
|
45
|
+
magnet: endpoint.magnet,
|
|
46
|
+
cap,
|
|
47
|
+
outline: 0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
box: getAxisAlignedBoundsInParent([node], parentId, graph),
|
|
52
|
+
point: {
|
|
53
|
+
x: 0,
|
|
54
|
+
y: 0
|
|
55
|
+
},
|
|
56
|
+
magnet: endpoint.magnet,
|
|
57
|
+
cap,
|
|
58
|
+
outline: node.type === "SHAPE_WITH_TEXT" && node.strokes.length > 0 ? node.strokeWeight / 2 : 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Writes only the fields that differ, so a route that did not move changes nothing. */
|
|
62
|
+
function changesFor(node, changes) {
|
|
63
|
+
const differing = Object.fromEntries(Object.entries(changes).filter(([key, value]) => !isEqual(node[key], value)));
|
|
64
|
+
return Object.keys(differing).length > 0 ? differing : null;
|
|
65
|
+
}
|
|
66
|
+
function shifted(point, by) {
|
|
67
|
+
return {
|
|
68
|
+
x: point.x + by.x,
|
|
69
|
+
y: point.y + by.y
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Control points carried between the connector's own axes and its parent's, by `by`. */
|
|
73
|
+
function shiftControls(points, curve, by) {
|
|
74
|
+
return {
|
|
75
|
+
points: points.map((point) => ({
|
|
76
|
+
...point,
|
|
77
|
+
position: shifted(point.position, by)
|
|
78
|
+
})),
|
|
79
|
+
curve: curve && [shifted(curve[0], by), shifted(curve[1], by)]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Routes a connector from the layers its ends follow and the control points it was dragged to,
|
|
84
|
+
* without laying anything out. Null when an end cannot be placed.
|
|
85
|
+
*/
|
|
86
|
+
function connectorRoute(graph, connector) {
|
|
87
|
+
const parts = connectorSublayers(graph, connector);
|
|
88
|
+
const { connectorStart, connectorEnd } = connector;
|
|
89
|
+
if (!parts || !connectorStart || !connectorEnd) return null;
|
|
90
|
+
const drawn = connectorRouteEnds(graph, connector);
|
|
91
|
+
const start = routeEnd(graph, connector, connectorStart, connector.connectorStartCap, drawn?.start);
|
|
92
|
+
const end = routeEnd(graph, connector, connectorEnd, connector.connectorEndCap, drawn?.end);
|
|
93
|
+
if (!start || !end) return null;
|
|
94
|
+
const weight = parts.line.strokes[0]?.weight ?? parts.line.strokeWeight;
|
|
95
|
+
const controls = shiftControls(connector.connectorControlPoints, connector.connectorCurveHandles, connector);
|
|
96
|
+
return {
|
|
97
|
+
start,
|
|
98
|
+
end,
|
|
99
|
+
sides: connectorSides(start, end),
|
|
100
|
+
pieces: routeConnector(connector.connectorLineType, start, end, weight, controls),
|
|
101
|
+
controls
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Where the connector, its line, and its label go for a route with the label placed on it. A
|
|
106
|
+
* connector that keeps its box places its line and label inside the box it has.
|
|
107
|
+
*/
|
|
108
|
+
function routeWrites(connector, { line, label, labelBackground }, pieces, placed, labelled, keepBox, controls) {
|
|
109
|
+
const lineBox = pieces.length > 0 ? piecesBounds(pieces) : null;
|
|
110
|
+
const boxes = compact([lineBox, labelled ? placed?.plate : null]);
|
|
111
|
+
if (boxes.length === 0) return null;
|
|
112
|
+
const bounds = computeBounds(boxes);
|
|
113
|
+
const frame = keepBox ? connector : bounds;
|
|
114
|
+
const lineOrigin = lineBox ?? bounds;
|
|
115
|
+
const local = shiftControls(controls.points, controls.curve, {
|
|
116
|
+
x: -frame.x,
|
|
117
|
+
y: -frame.y
|
|
118
|
+
});
|
|
119
|
+
const writes = [[connector, {
|
|
120
|
+
...keepBox ? {} : pick(frame, [
|
|
121
|
+
"x",
|
|
122
|
+
"y",
|
|
123
|
+
"width",
|
|
124
|
+
"height"
|
|
125
|
+
]),
|
|
126
|
+
connectorControlPoints: local.points,
|
|
127
|
+
connectorCurveHandles: local.curve
|
|
128
|
+
}], [line, {
|
|
129
|
+
x: lineOrigin.x - frame.x,
|
|
130
|
+
y: lineOrigin.y - frame.y,
|
|
131
|
+
width: lineOrigin.width,
|
|
132
|
+
height: lineOrigin.height,
|
|
133
|
+
vectorNetwork: connectorNetwork(pieces, lineOrigin, {
|
|
134
|
+
start: connector.connectorStartCap,
|
|
135
|
+
end: connector.connectorEndCap
|
|
136
|
+
})
|
|
137
|
+
}]];
|
|
138
|
+
if (!placed) return [...writes, [labelBackground, { visible: false }]];
|
|
139
|
+
const x = placed.plate.x - frame.x;
|
|
140
|
+
const y = placed.plate.y - frame.y;
|
|
141
|
+
const { width, height } = placed.plate;
|
|
142
|
+
return [
|
|
143
|
+
...writes,
|
|
144
|
+
[labelBackground, {
|
|
145
|
+
x,
|
|
146
|
+
y,
|
|
147
|
+
width,
|
|
148
|
+
height,
|
|
149
|
+
visible: labelled
|
|
150
|
+
}],
|
|
151
|
+
[label, {
|
|
152
|
+
x: x + CONNECTOR_LABEL_PADDING,
|
|
153
|
+
y: y + CONNECTOR_LABEL_PADDING,
|
|
154
|
+
visible: true
|
|
155
|
+
}]
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Routes a connector again from the layers its ends follow and lays out its line, label plate,
|
|
160
|
+
* and label to match, through `update` so the caller decides whether that is an edit or a
|
|
161
|
+
* preview. Returns whether anything moved. A connector with an end that cannot be placed keeps
|
|
162
|
+
* its route. With `keepBox`, the connector keeps its own position and size, as while a move
|
|
163
|
+
* previews. With `capture`, an elbow that was dragged keeps its new route's segments as its
|
|
164
|
+
* control points, as FigJam does after an edit reroutes one.
|
|
165
|
+
*/
|
|
166
|
+
function layoutConnector(graph, connector, update = (id, changes) => graph.updateNode(id, changes), { keepBox = false, capture = false } = {}) {
|
|
167
|
+
const parts = connectorSublayers(graph, connector);
|
|
168
|
+
const route = connectorRoute(graph, connector);
|
|
169
|
+
if (!parts || !route) return false;
|
|
170
|
+
const { label } = parts;
|
|
171
|
+
const { pieces } = route;
|
|
172
|
+
const controls = capture && connector.connectorLineType === "ELBOWED" && route.controls.points.length > 0 ? {
|
|
173
|
+
...route.controls,
|
|
174
|
+
points: elbowControlPoints(pieces)
|
|
175
|
+
} : route.controls;
|
|
176
|
+
const labelled = label.text !== "";
|
|
177
|
+
const placed = placeConnectorLabel(pieces, {
|
|
178
|
+
width: label.width + CONNECTOR_LABEL_PADDING * 2,
|
|
179
|
+
height: label.height + CONNECTOR_LABEL_PADDING * 2
|
|
180
|
+
}, connector.connectorLabelPosition);
|
|
181
|
+
const writes = routeWrites(connector, parts, labelled && placed ? placed.pieces : pieces, placed, labelled, keepBox, controls);
|
|
182
|
+
let moved = false;
|
|
183
|
+
graph.withLayoutMutations(() => {
|
|
184
|
+
for (const [node, changes] of writes ?? []) {
|
|
185
|
+
const differing = changesFor(node, changes);
|
|
186
|
+
if (!differing) continue;
|
|
187
|
+
update(node.id, differing);
|
|
188
|
+
moved = true;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return moved;
|
|
192
|
+
}
|
|
193
|
+
/** Whether `id` is one of `ids` or lies inside one of them. */
|
|
194
|
+
function withinAny(graph, id, ids) {
|
|
195
|
+
return graph.closest(id, (node) => ids.has(node.id)) !== void 0;
|
|
196
|
+
}
|
|
197
|
+
/** The graph's connectors, from its index rather than a scan of every layer. */
|
|
198
|
+
function* connectorsIn(graph) {
|
|
199
|
+
for (const id of graph.connectorIds) {
|
|
200
|
+
const node = graph.getNode(id);
|
|
201
|
+
if (node?.type === "CONNECTOR") yield node;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The connectors with an end on one of `ids` or a layer inside them, which go when those layers
|
|
206
|
+
* are deleted, as in FigJam. Connectors inside `ids` themselves are left out.
|
|
207
|
+
*/
|
|
208
|
+
function attachedConnectors(graph, ids) {
|
|
209
|
+
const roots = new Set(ids);
|
|
210
|
+
const attached = [];
|
|
211
|
+
for (const node of connectorsIn(graph)) {
|
|
212
|
+
if (withinAny(graph, node.id, roots)) continue;
|
|
213
|
+
if ([node.connectorStart?.nodeId, node.connectorEnd?.nodeId].some((id) => id && withinAny(graph, id, roots))) attached.push(node);
|
|
214
|
+
}
|
|
215
|
+
return attached;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The connectors an edit to `ids` moves: those with an end on one of them or on a layer inside
|
|
219
|
+
* them, those inside them, and those whose line or label is among them.
|
|
220
|
+
*/
|
|
221
|
+
function connectorsAffectedBy(graph, ids) {
|
|
222
|
+
if (ids.size === 0) return [];
|
|
223
|
+
const affected = [];
|
|
224
|
+
for (const node of connectorsIn(graph)) if ([
|
|
225
|
+
node.id,
|
|
226
|
+
node.connectorStart?.nodeId,
|
|
227
|
+
node.connectorEnd?.nodeId
|
|
228
|
+
].some((id) => id && withinAny(graph, id, ids)) || node.childIds.some((id) => ids.has(id))) affected.push(node);
|
|
229
|
+
return affected;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { attachedConnectors, connectorRoute, connectorsAffectedBy, layoutConnector };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../src/connectors/layout.ts"],"sourcesContent":["import { compact, isEqual, pick } from 'es-toolkit'\n\nimport { getAxisAlignedBoundsInParent, getParentWorldMatrix, getWorldMatrix } from '../coordinate'\nimport { computeBounds } from '../geometry'\nimport type { SceneGraph } from '../graph'\nimport Matrix from '../matrix'\nimport type { Vector } from '../primitives'\nimport type { ConnectorControlPoint, ConnectorEndpoint, SceneNode, StrokeCap } from '../types'\nimport { elbowControlPoints } from './controls'\nimport { CONNECTOR_LABEL_PADDING, placeConnectorLabel, type ConnectorLabelLayout } from './label'\nimport { connectorNetwork, piecesBounds, type ConnectorPiece } from './pieces'\nimport { routeConnector, type ConnectorRouteControls } from './route'\nimport { connectorSides, type ConnectorRouteEnd, type ConnectorSide } from './sides'\nimport { connectorRouteEnds, connectorSublayers, type ConnectorSublayers } from './sublayers'\n\n/**\n * An end as the router sees it, in the connector's parent's axes: the box of the layer it follows\n * by a magnet, or a point, which an end pinned to a point of its layer follows as the layer moves.\n * An end whose layer is gone stays where its route last ended.\n */\nfunction routeEnd(\n graph: SceneGraph,\n connector: SceneNode,\n endpoint: ConnectorEndpoint,\n cap: StrokeCap,\n fallback: Vector | undefined\n): ConnectorRouteEnd | null {\n const parentId = connector.parentId\n if (!parentId) return null\n const node = endpoint.nodeId ? graph.getNode(endpoint.nodeId) : undefined\n if (!node) {\n if (endpoint.nodeId && !fallback) return null\n const point = endpoint.nodeId && fallback ? fallback : endpoint.position\n return { box: null, point, magnet: 'NONE', cap, outline: 0 }\n }\n // An elbow or curve joined at the centre runs into the layer to its centre, as Figma Design\n // draws it; a straight line stops at the outline on its way there.\n const centred = endpoint.magnet === 'CENTER' && connector.connectorLineType !== 'STRAIGHT'\n if (endpoint.magnet === 'NONE' || endpoint.magnet === 'ABSOLUTE' || centred) {\n // A point in the layer's own axes, carried into the connector's parent's.\n const toParent =\n Matrix.invert(getParentWorldMatrix(graph.getNode(parentId), graph)) ?? Matrix.identity()\n const local = centred ? { x: node.width / 2, y: node.height / 2 } : endpoint.position\n const [x, y] = Matrix.mapPoints(Matrix.multiply(toParent, getWorldMatrix(node, graph)), [\n local.x,\n local.y\n ])\n return { box: null, point: { x, y }, magnet: endpoint.magnet, cap, outline: 0 }\n }\n return {\n box: getAxisAlignedBoundsInParent([node], parentId, graph),\n point: { x: 0, y: 0 },\n magnet: endpoint.magnet,\n cap,\n // FigJam keeps connectors clear of a shape's stroke, centred on its edge, hidden or not; a\n // shape with no stroke, or another layer's stroke, does not count.\n outline: node.type === 'SHAPE_WITH_TEXT' && node.strokes.length > 0 ? node.strokeWeight / 2 : 0\n }\n}\n\n/** Writes only the fields that differ, so a route that did not move changes nothing. */\nfunction changesFor(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode> | null {\n const differing = Object.fromEntries(\n Object.entries(changes).filter(([key, value]) => !isEqual(node[key as keyof SceneNode], value))\n ) as Partial<SceneNode>\n return Object.keys(differing).length > 0 ? differing : null\n}\n\ntype Write = [SceneNode, Partial<SceneNode>]\n\nfunction shifted(point: Vector, by: Vector): Vector {\n return { x: point.x + by.x, y: point.y + by.y }\n}\n\n/** Control points carried between the connector's own axes and its parent's, by `by`. */\nfunction shiftControls(\n points: ConnectorControlPoint[],\n curve: [Vector, Vector] | null,\n by: Vector\n): ConnectorRouteControls {\n return {\n points: points.map((point) => ({ ...point, position: shifted(point.position, by) })),\n curve: curve && [shifted(curve[0], by), shifted(curve[1], by)]\n }\n}\n\n/** A connector's route as its ends and control points give it, in its parent's axes. */\nexport interface ConnectorRoute {\n start: ConnectorRouteEnd\n end: ConnectorRouteEnd\n sides: [ConnectorSide, ConnectorSide]\n /** The line before its label cuts it. */\n pieces: ConnectorPiece[]\n /** Its control points in its parent's axes. */\n controls: ConnectorRouteControls\n}\n\n/**\n * Routes a connector from the layers its ends follow and the control points it was dragged to,\n * without laying anything out. Null when an end cannot be placed.\n */\nexport function connectorRoute(graph: SceneGraph, connector: SceneNode): ConnectorRoute | null {\n const parts = connectorSublayers(graph, connector)\n const { connectorStart, connectorEnd } = connector\n if (!parts || !connectorStart || !connectorEnd) return null\n // Where the line last ran, for an end whose layer is gone.\n const drawn = connectorRouteEnds(graph, connector)\n const start = routeEnd(\n graph,\n connector,\n connectorStart,\n connector.connectorStartCap,\n drawn?.start\n )\n const end = routeEnd(graph, connector, connectorEnd, connector.connectorEndCap, drawn?.end)\n if (!start || !end) return null\n const weight = parts.line.strokes[0]?.weight ?? parts.line.strokeWeight\n const controls = shiftControls(\n connector.connectorControlPoints,\n connector.connectorCurveHandles,\n connector\n )\n return {\n start,\n end,\n sides: connectorSides(start, end),\n pieces: routeConnector(connector.connectorLineType, start, end, weight, controls),\n controls\n }\n}\n\n/**\n * Where the connector, its line, and its label go for a route with the label placed on it. A\n * connector that keeps its box places its line and label inside the box it has.\n */\nfunction routeWrites(\n connector: SceneNode,\n { line, label, labelBackground }: ConnectorSublayers,\n pieces: ConnectorPiece[],\n placed: ConnectorLabelLayout | null,\n labelled: boolean,\n keepBox: boolean,\n controls: ConnectorRouteControls\n): Write[] | null {\n const lineBox = pieces.length > 0 ? piecesBounds(pieces) : null\n const boxes = compact([lineBox, labelled ? placed?.plate : null])\n if (boxes.length === 0) return null\n const bounds = computeBounds(boxes)\n const frame = keepBox ? connector : bounds\n const lineOrigin = lineBox ?? bounds\n // Control points stay where they are in the parent as the connector's box moves to fit.\n const local = shiftControls(controls.points, controls.curve, { x: -frame.x, y: -frame.y })\n const writes: Write[] = [\n [\n connector,\n {\n ...(keepBox ? {} : pick(frame, ['x', 'y', 'width', 'height'])),\n connectorControlPoints: local.points,\n connectorCurveHandles: local.curve\n }\n ],\n [\n line,\n {\n x: lineOrigin.x - frame.x,\n y: lineOrigin.y - frame.y,\n width: lineOrigin.width,\n height: lineOrigin.height,\n vectorNetwork: connectorNetwork(pieces, lineOrigin, {\n start: connector.connectorStartCap,\n end: connector.connectorEndCap\n })\n }\n ]\n ]\n if (!placed) return [...writes, [labelBackground, { visible: false }]]\n const x = placed.plate.x - frame.x\n const y = placed.plate.y - frame.y\n const { width, height } = placed.plate\n // An empty label still sits where its text goes, ready to be typed into.\n return [\n ...writes,\n [labelBackground, { x, y, width, height, visible: labelled }],\n [label, { x: x + CONNECTOR_LABEL_PADDING, y: y + CONNECTOR_LABEL_PADDING, visible: true }]\n ]\n}\n\n/**\n * Routes a connector again from the layers its ends follow and lays out its line, label plate,\n * and label to match, through `update` so the caller decides whether that is an edit or a\n * preview. Returns whether anything moved. A connector with an end that cannot be placed keeps\n * its route. With `keepBox`, the connector keeps its own position and size, as while a move\n * previews. With `capture`, an elbow that was dragged keeps its new route's segments as its\n * control points, as FigJam does after an edit reroutes one.\n */\nexport function layoutConnector(\n graph: SceneGraph,\n connector: SceneNode,\n update: (id: string, changes: Partial<SceneNode>) => void = (id, changes) =>\n graph.updateNode(id, changes),\n { keepBox = false, capture = false }: { keepBox?: boolean; capture?: boolean } = {}\n): boolean {\n const parts = connectorSublayers(graph, connector)\n const route = connectorRoute(graph, connector)\n if (!parts || !route) return false\n const { label } = parts\n const { pieces } = route\n const controls =\n capture && connector.connectorLineType === 'ELBOWED' && route.controls.points.length > 0\n ? { ...route.controls, points: elbowControlPoints(pieces) }\n : route.controls\n const labelled = label.text !== ''\n const placed = placeConnectorLabel(\n pieces,\n {\n width: label.width + CONNECTOR_LABEL_PADDING * 2,\n height: label.height + CONNECTOR_LABEL_PADDING * 2\n },\n connector.connectorLabelPosition\n )\n const routed = labelled && placed ? placed.pieces : pieces\n const writes = routeWrites(connector, parts, routed, placed, labelled, keepBox, controls)\n let moved = false\n // A route derives from its ends, so laying it out is layout rather than an edit, as moving the\n // connector it fits is not.\n graph.withLayoutMutations(() => {\n for (const [node, changes] of writes ?? []) {\n const differing = changesFor(node, changes)\n if (!differing) continue\n update(node.id, differing)\n moved = true\n }\n })\n return moved\n}\n\n/** Whether `id` is one of `ids` or lies inside one of them. */\nfunction withinAny(graph: SceneGraph, id: string, ids: ReadonlySet<string>): boolean {\n return graph.closest(id, (node) => ids.has(node.id)) !== undefined\n}\n\n/** The graph's connectors, from its index rather than a scan of every layer. */\nfunction* connectorsIn(graph: SceneGraph): Generator<SceneNode> {\n for (const id of graph.connectorIds) {\n const node = graph.getNode(id)\n if (node?.type === 'CONNECTOR') yield node\n }\n}\n\n/**\n * The connectors with an end on one of `ids` or a layer inside them, which go when those layers\n * are deleted, as in FigJam. Connectors inside `ids` themselves are left out.\n */\nexport function attachedConnectors(graph: SceneGraph, ids: Iterable<string>): SceneNode[] {\n const roots = new Set(ids)\n const attached: SceneNode[] = []\n for (const node of connectorsIn(graph)) {\n if (withinAny(graph, node.id, roots)) continue\n const ends = [node.connectorStart?.nodeId, node.connectorEnd?.nodeId]\n if (ends.some((id) => id && withinAny(graph, id, roots))) attached.push(node)\n }\n return attached\n}\n\n/**\n * The connectors an edit to `ids` moves: those with an end on one of them or on a layer inside\n * them, those inside them, and those whose line or label is among them.\n */\nexport function connectorsAffectedBy(graph: SceneGraph, ids: ReadonlySet<string>): SceneNode[] {\n if (ids.size === 0) return []\n const affected: SceneNode[] = []\n for (const node of connectorsIn(graph)) {\n const watched = [node.id, node.connectorStart?.nodeId, node.connectorEnd?.nodeId]\n const touched =\n watched.some((id) => id && withinAny(graph, id, ids)) ||\n node.childIds.some((id) => ids.has(id))\n if (touched) affected.push(node)\n }\n return affected\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,SAAS,SACP,OACA,WACA,UACA,KACA,UAC0B;CAC1B,MAAM,WAAW,UAAU;CAC3B,IAAI,CAAC,UAAU,O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AAS,KAAK,IAAI;CAC9E;CACA,OAAO;AACT;;;;;AAMA,SAAgB,qBAAqB,OAAmB,KAAuC;CAC7F,IAAI,IAAI,SAAS,GAAG,OAAO,CAAC;CAC5B,MAAM,WAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,aAAa,KAAK,GAKnC,IAFE;EAFe,KAAK;EAAI,KAAK,gBAAgB;EAAQ,KAAK,cAAc;CAElE,CAAC,CAAC,MAAM,OAAO,MAAM,UAAU,OAAO,IAAI,GAAG,CAAC,KACpD,KAAK,SAAS,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC,GAC3B,SAAS,KAAK,IAAI;CAEjC,OAAO;AACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Vector } from "../primitives/index.js";
|
|
2
|
+
import { StrokeCap, VectorNetwork } from "../types.js";
|
|
3
|
+
//#region src/connectors/pieces.d.ts
|
|
4
|
+
/** One piece of a route: a straight run when both handles are zero, else a cubic. */
|
|
5
|
+
interface ConnectorPiece {
|
|
6
|
+
from: Vector;
|
|
7
|
+
to: Vector;
|
|
8
|
+
handleFrom: Vector;
|
|
9
|
+
handleTo: Vector;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A route as a vector network: pieces that meet share a vertex, so elbows round their corners,
|
|
13
|
+
* and a cut leaves two runs. The first and last vertices carry the connector's caps, as Figma
|
|
14
|
+
* stores them.
|
|
15
|
+
*/
|
|
16
|
+
declare function connectorNetwork(pieces: ConnectorPiece[], origin: Vector, caps: {
|
|
17
|
+
start: StrokeCap;
|
|
18
|
+
end: StrokeCap;
|
|
19
|
+
}): VectorNetwork;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ConnectorPiece, connectorNetwork };
|
|
22
|
+
//# sourceMappingURL=pieces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieces.d.ts","names":[],"sources":["../../src/connectors/pieces.ts"],"mappings":";;;;UAKiB;EACf,MAAM;EACN,IAAI;EACJ,YAAY;EACZ,UAAU;;;;;;;iBAoGI,iBACd,QAAQ,kBACR,QAAQ,QACR;EAAQ,OAAO;EAAW,KAAK;IAC9B"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { computeBounds } from "../geometry.js";
|
|
2
|
+
//#region src/connectors/pieces.ts
|
|
3
|
+
const ZERO = {
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0
|
|
6
|
+
};
|
|
7
|
+
const EPSILON = 1e-6;
|
|
8
|
+
/** Points sampled along a curved piece to bound it. */
|
|
9
|
+
const CURVE_BOUND_SAMPLES = 16;
|
|
10
|
+
function along(point, direction, distance) {
|
|
11
|
+
return {
|
|
12
|
+
x: point.x + direction.x * distance,
|
|
13
|
+
y: point.y + direction.y * distance
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function isStraight(piece) {
|
|
17
|
+
const { handleFrom: h0, handleTo: h1 } = piece;
|
|
18
|
+
return h0.x === 0 && h0.y === 0 && h1.x === 0 && h1.y === 0;
|
|
19
|
+
}
|
|
20
|
+
function straightPieces(points) {
|
|
21
|
+
return points.slice(1).map((to, index) => ({
|
|
22
|
+
from: points[index],
|
|
23
|
+
to,
|
|
24
|
+
handleFrom: ZERO,
|
|
25
|
+
handleTo: ZERO
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
function pieceLength(piece) {
|
|
29
|
+
return Math.hypot(piece.to.x - piece.from.x, piece.to.y - piece.from.y);
|
|
30
|
+
}
|
|
31
|
+
function controls(piece) {
|
|
32
|
+
const { from: a, to: b } = piece;
|
|
33
|
+
return [{
|
|
34
|
+
x: a.x + piece.handleFrom.x,
|
|
35
|
+
y: a.y + piece.handleFrom.y
|
|
36
|
+
}, {
|
|
37
|
+
x: b.x + piece.handleTo.x,
|
|
38
|
+
y: b.y + piece.handleTo.y
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
/** The point at `t` along a piece; a straight run is parametrised by length. */
|
|
42
|
+
function pointAt(piece, t) {
|
|
43
|
+
const { from: a, to: b } = piece;
|
|
44
|
+
if (isStraight(piece)) return {
|
|
45
|
+
x: a.x + (b.x - a.x) * t,
|
|
46
|
+
y: a.y + (b.y - a.y) * t
|
|
47
|
+
};
|
|
48
|
+
const [c1, c2] = controls(piece);
|
|
49
|
+
const u = 1 - t;
|
|
50
|
+
return {
|
|
51
|
+
x: u * u * u * a.x + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * b.x,
|
|
52
|
+
y: u * u * u * a.y + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * b.y
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function derivativeAt(piece, t) {
|
|
56
|
+
const { from: a, to: b } = piece;
|
|
57
|
+
const [c1, c2] = controls(piece);
|
|
58
|
+
const u = 1 - t;
|
|
59
|
+
return {
|
|
60
|
+
x: 3 * u * u * (c1.x - a.x) + 6 * u * t * (c2.x - c1.x) + 3 * t * t * (b.x - c2.x),
|
|
61
|
+
y: 3 * u * u * (c1.y - a.y) + 6 * u * t * (c2.y - c1.y) + 3 * t * t * (b.y - c2.y)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The part of a piece from `t0` to `t1`, its handles as de Casteljau splits them. */
|
|
65
|
+
function subPiece(piece, t0, t1) {
|
|
66
|
+
const from = pointAt(piece, t0);
|
|
67
|
+
const to = pointAt(piece, t1);
|
|
68
|
+
if (isStraight(piece)) return {
|
|
69
|
+
from,
|
|
70
|
+
to,
|
|
71
|
+
handleFrom: ZERO,
|
|
72
|
+
handleTo: ZERO
|
|
73
|
+
};
|
|
74
|
+
const span = (t1 - t0) / 3;
|
|
75
|
+
const d0 = derivativeAt(piece, t0);
|
|
76
|
+
const d1 = derivativeAt(piece, t1);
|
|
77
|
+
return {
|
|
78
|
+
from,
|
|
79
|
+
to,
|
|
80
|
+
handleFrom: {
|
|
81
|
+
x: d0.x * span,
|
|
82
|
+
y: d0.y * span
|
|
83
|
+
},
|
|
84
|
+
handleTo: {
|
|
85
|
+
x: -d1.x * span,
|
|
86
|
+
y: -d1.y * span
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Where the ray from `from`, inside `box`, towards `toward` leaves it. */
|
|
91
|
+
function exitPoint(box, from, toward) {
|
|
92
|
+
const dx = toward.x - from.x;
|
|
93
|
+
const dy = toward.y - from.y;
|
|
94
|
+
const tx = dx === 0 ? Infinity : ((dx > 0 ? box.x + box.width : box.x) - from.x) / dx;
|
|
95
|
+
const ty = dy === 0 ? Infinity : ((dy > 0 ? box.y + box.height : box.y) - from.y) / dy;
|
|
96
|
+
const t = Math.max(0, Math.min(tx, ty, 1));
|
|
97
|
+
return {
|
|
98
|
+
x: from.x + dx * t,
|
|
99
|
+
y: from.y + dy * t
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** The box a route's pieces cover, curves sampled along their length. */
|
|
103
|
+
function piecesBounds(pieces) {
|
|
104
|
+
const points = [];
|
|
105
|
+
for (const piece of pieces) {
|
|
106
|
+
const samples = isStraight(piece) ? 1 : CURVE_BOUND_SAMPLES;
|
|
107
|
+
for (let step = 0; step <= samples; step++) points.push({
|
|
108
|
+
...pointAt(piece, step / samples),
|
|
109
|
+
width: 0,
|
|
110
|
+
height: 0
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return computeBounds(points);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A route as a vector network: pieces that meet share a vertex, so elbows round their corners,
|
|
117
|
+
* and a cut leaves two runs. The first and last vertices carry the connector's caps, as Figma
|
|
118
|
+
* stores them.
|
|
119
|
+
*/
|
|
120
|
+
function connectorNetwork(pieces, origin, caps) {
|
|
121
|
+
const network = {
|
|
122
|
+
vertices: [],
|
|
123
|
+
segments: [],
|
|
124
|
+
regions: []
|
|
125
|
+
};
|
|
126
|
+
const vertexAt = (point) => {
|
|
127
|
+
const last = network.vertices.at(-1);
|
|
128
|
+
const x = point.x - origin.x;
|
|
129
|
+
const y = point.y - origin.y;
|
|
130
|
+
if (last && Math.abs(last.x - x) < 1e-6 && Math.abs(last.y - y) < 1e-6) return network.vertices.length - 1;
|
|
131
|
+
network.vertices.push({
|
|
132
|
+
x,
|
|
133
|
+
y
|
|
134
|
+
});
|
|
135
|
+
return network.vertices.length - 1;
|
|
136
|
+
};
|
|
137
|
+
for (const piece of pieces) {
|
|
138
|
+
const start = vertexAt(piece.from);
|
|
139
|
+
const end = vertexAt(piece.to);
|
|
140
|
+
if (start === end) continue;
|
|
141
|
+
network.segments.push({
|
|
142
|
+
start,
|
|
143
|
+
end,
|
|
144
|
+
tangentStart: { ...piece.handleFrom },
|
|
145
|
+
tangentEnd: { ...piece.handleTo }
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const first = network.vertices.at(0);
|
|
149
|
+
const last = network.vertices.at(-1);
|
|
150
|
+
if (first && last && first !== last) {
|
|
151
|
+
first.strokeCap = caps.start;
|
|
152
|
+
last.strokeCap = caps.end;
|
|
153
|
+
}
|
|
154
|
+
return network;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { EPSILON, ZERO, along, connectorNetwork, exitPoint, isStraight, pieceLength, piecesBounds, pointAt, straightPieces, subPiece };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=pieces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieces.js","names":[],"sources":["../../src/connectors/pieces.ts"],"sourcesContent":["import { computeBounds } from '../geometry'\nimport type { Rect, Vector } from '../primitives'\nimport type { StrokeCap, VectorNetwork } from '../types'\n\n/** One piece of a route: a straight run when both handles are zero, else a cubic. */\nexport interface ConnectorPiece {\n from: Vector\n to: Vector\n handleFrom: Vector\n handleTo: Vector\n}\n\nexport const ZERO: Vector = { x: 0, y: 0 }\nexport const EPSILON = 1e-6\n/** Points sampled along a curved piece to bound it. */\nconst CURVE_BOUND_SAMPLES = 16\n\nexport function along(point: Vector, direction: Vector, distance: number): Vector {\n return { x: point.x + direction.x * distance, y: point.y + direction.y * distance }\n}\n\nexport function isStraight(piece: ConnectorPiece): boolean {\n const { handleFrom: h0, handleTo: h1 } = piece\n return h0.x === 0 && h0.y === 0 && h1.x === 0 && h1.y === 0\n}\n\nexport function straightPieces(points: Vector[]): ConnectorPiece[] {\n return points\n .slice(1)\n .map((to, index) => ({ from: points[index], to, handleFrom: ZERO, handleTo: ZERO }))\n}\n\nexport function pieceLength(piece: ConnectorPiece): number {\n return Math.hypot(piece.to.x - piece.from.x, piece.to.y - piece.from.y)\n}\n\nfunction controls(piece: ConnectorPiece): [Vector, Vector] {\n const { from: a, to: b } = piece\n return [\n { x: a.x + piece.handleFrom.x, y: a.y + piece.handleFrom.y },\n { x: b.x + piece.handleTo.x, y: b.y + piece.handleTo.y }\n ]\n}\n\n/** The point at `t` along a piece; a straight run is parametrised by length. */\nexport function pointAt(piece: ConnectorPiece, t: number): Vector {\n const { from: a, to: b } = piece\n if (isStraight(piece)) return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t }\n const [c1, c2] = controls(piece)\n const u = 1 - t\n return {\n x: u * u * u * a.x + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * b.x,\n y: u * u * u * a.y + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * b.y\n }\n}\n\nfunction derivativeAt(piece: ConnectorPiece, t: number): Vector {\n const { from: a, to: b } = piece\n const [c1, c2] = controls(piece)\n const u = 1 - t\n return {\n x: 3 * u * u * (c1.x - a.x) + 6 * u * t * (c2.x - c1.x) + 3 * t * t * (b.x - c2.x),\n y: 3 * u * u * (c1.y - a.y) + 6 * u * t * (c2.y - c1.y) + 3 * t * t * (b.y - c2.y)\n }\n}\n\n/** The part of a piece from `t0` to `t1`, its handles as de Casteljau splits them. */\nexport function subPiece(piece: ConnectorPiece, t0: number, t1: number): ConnectorPiece {\n const from = pointAt(piece, t0)\n const to = pointAt(piece, t1)\n if (isStraight(piece)) return { from, to, handleFrom: ZERO, handleTo: ZERO }\n const span = (t1 - t0) / 3\n const d0 = derivativeAt(piece, t0)\n const d1 = derivativeAt(piece, t1)\n return {\n from,\n to,\n handleFrom: { x: d0.x * span, y: d0.y * span },\n handleTo: { x: -d1.x * span, y: -d1.y * span }\n }\n}\n\n/** Where the ray from `from`, inside `box`, towards `toward` leaves it. */\nexport function exitPoint(box: Rect, from: Vector, toward: Vector): Vector {\n const dx = toward.x - from.x\n const dy = toward.y - from.y\n const tx = dx === 0 ? Infinity : ((dx > 0 ? box.x + box.width : box.x) - from.x) / dx\n const ty = dy === 0 ? Infinity : ((dy > 0 ? box.y + box.height : box.y) - from.y) / dy\n const t = Math.max(0, Math.min(tx, ty, 1))\n return { x: from.x + dx * t, y: from.y + dy * t }\n}\n\n/** The box a route's pieces cover, curves sampled along their length. */\nexport function piecesBounds(pieces: ConnectorPiece[]): Rect {\n const points: Rect[] = []\n for (const piece of pieces) {\n const samples = isStraight(piece) ? 1 : CURVE_BOUND_SAMPLES\n for (let step = 0; step <= samples; step++) {\n points.push({ ...pointAt(piece, step / samples), width: 0, height: 0 })\n }\n }\n return computeBounds(points)\n}\n\n/**\n * A route as a vector network: pieces that meet share a vertex, so elbows round their corners,\n * and a cut leaves two runs. The first and last vertices carry the connector's caps, as Figma\n * stores them.\n */\nexport function connectorNetwork(\n pieces: ConnectorPiece[],\n origin: Vector,\n caps: { start: StrokeCap; end: StrokeCap }\n): VectorNetwork {\n const network: VectorNetwork = { vertices: [], segments: [], regions: [] }\n const vertexAt = (point: Vector) => {\n const last = network.vertices.at(-1)\n const x = point.x - origin.x\n const y = point.y - origin.y\n if (last && Math.abs(last.x - x) < EPSILON && Math.abs(last.y - y) < EPSILON) {\n return network.vertices.length - 1\n }\n network.vertices.push({ x, y })\n return network.vertices.length - 1\n }\n for (const piece of pieces) {\n const start = vertexAt(piece.from)\n const end = vertexAt(piece.to)\n if (start === end) continue\n network.segments.push({\n start,\n end,\n tangentStart: { ...piece.handleFrom },\n tangentEnd: { ...piece.handleTo }\n })\n }\n const first = network.vertices.at(0)\n const last = network.vertices.at(-1)\n if (first && last && first !== last) {\n first.strokeCap = caps.start\n last.strokeCap = caps.end\n }\n return network\n}\n"],"mappings":";;AAYA,MAAa,OAAe;CAAE,GAAG;CAAG,GAAG;AAAE;AACzC,MAAa,UAAU;;AAEvB,MAAM,sBAAsB;AAE5B,SAAgB,MAAM,OAAe,WAAmB,UAA0B;CAChF,OAAO;EAAE,GAAG,MAAM,IAAI,UAAU,IAAI;EAAU,GAAG,MAAM,IAAI,UAAU,IAAI;CAAS;AACpF;AAEA,SAAgB,WAAW,OAAgC;CACzD,MAAM,EAAE,YAAY,IAAI,UAAU,OAAO;CACzC,OAAO,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM;AAC5D;AAEA,SAAgB,eAAe,QAAoC;CACjE,OAAO,OACJ,MAAM,CAAC,CAAC,CACR,KAAK,IAAI,WAAW;EAAE,MAAM,OAAO;EAAQ;EAAI,YAAY;EAAM,UAAU;CAAK,EAAE;AACvF;AAEA,SAAgB,YAAY,OAA+B;CACzD,OAAO,KAAK,MAAM,MAAM,GAAG,IAAI,MAAM,KAAK,GAAG,MAAM,GAAG,IAAI,MAAM,KAAK,CAAC;AACxE;AAEA,SAAS,SAAS,OAAyC;CACzD,MAAM,EAAE,MAAM,GAAG,IAAI,MAAM;CAC3B,OAAO,CACL;EAAE,GAAG,EAAE,IAAI,MAAM,WAAW;EAAG,GAAG,EAAE,IAAI,MAAM,WAAW;CAAE,GAC3D;EAAE,GAAG,EAAE,IAAI,MAAM,SAAS;EAAG,GAAG,EAAE,IAAI,MAAM,SAAS;CAAE,CACzD;AACF;;AAGA,SAAgB,QAAQ,OAAuB,GAAmB;CAChE,MAAM,EAAE,MAAM,GAAG,IAAI,MAAM;CAC3B,IAAI,WAAW,KAAK,GAAG,OAAO;EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,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MAC/D,OAAO,QAAQ,SAAS,SAAS;EAEnC,QAAQ,SAAS,KAAK;GAAE;GAAG;EAAE,CAAC;EAC9B,OAAO,QAAQ,SAAS,SAAS;CACnC;CACA,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAQ,SAAS,MAAM,IAAI;EACjC,MAAM,MAAM,SAAS,MAAM,EAAE;EAC7B,IAAI,UAAU,KAAK;EACnB,QAAQ,SAAS,KAAK;GACpB;GACA;GACA,cAAc,EAAE,GAAG,MAAM,WAAW;GACpC,YAAY,EAAE,GAAG,MAAM,SAAS;EAClC,CAAC;CACH;CACA,MAAM,QAAQ,QAAQ,SAAS,GAAG,CAAC;CACnC,MAAM,OAAO,QAAQ,SAAS,GAAG,EAAE;CACnC,IAAI,SAAS,QAAQ,UAAU,MAAM;EACnC,MAAM,YAAY,KAAK;EACvB,KAAK,YAAY,KAAK;CACxB;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Vector } from "../primitives/index.js";
|
|
2
|
+
import { ConnectorControlPoint, ConnectorLineType } from "../types.js";
|
|
3
|
+
import { ConnectorPiece } from "./pieces.js";
|
|
4
|
+
import { ConnectorRouteEnd } from "./sides.js";
|
|
5
|
+
//#region src/connectors/route.d.ts
|
|
6
|
+
/** Where a connector's line was dragged to, in the connector's parent's axes. */
|
|
7
|
+
interface ConnectorRouteControls {
|
|
8
|
+
/** An elbow's dragged segments, in order. */
|
|
9
|
+
points: ConnectorControlPoint[];
|
|
10
|
+
/** A curve's two control points. */
|
|
11
|
+
curve: [Vector, Vector] | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The pieces of a connector's line between its two ends, in the connector's parent's axes. Ends
|
|
15
|
+
* attached by a magnet stop short by their caps' gaps; free ends sit on their points. Layers that
|
|
16
|
+
* touch or overlap leave an elbow or a curve nothing to route but the start, as in Figma. An elbow
|
|
17
|
+
* runs along the segments it was dragged to and a curve bends to its dragged control points,
|
|
18
|
+
* leaving their ends by the sides they would take anyway.
|
|
19
|
+
*/
|
|
20
|
+
declare function routeConnector(lineType: ConnectorLineType, start: ConnectorRouteEnd, end: ConnectorRouteEnd, strokeWeight: number, controls?: ConnectorRouteControls): ConnectorPiece[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ConnectorRouteControls, routeConnector };
|
|
23
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","names":[],"sources":["../../src/connectors/route.ts"],"mappings":";;;;;;UAuGiB;;EAEf,QAAQ;;EAER,QAAQ,QAAQ;;;;;;;;;iBAUF,eACd,UAAU,mBACV,OAAO,mBACP,KAAK,mBACL,sBACA,WAAU,yBACT"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ZERO, along, exitPoint, straightPieces } from "./pieces.js";
|
|
2
|
+
import { OUTWARD, attachment, connectorSides, opposite, sideMidpoint, sidesFor } from "./sides.js";
|
|
3
|
+
import { elbowRoute } from "./elbow.js";
|
|
4
|
+
import { controlledCurveRoute, controlledElbowRoute } from "./controls.js";
|
|
5
|
+
import { connectorEndGap } from "./gaps.js";
|
|
6
|
+
//#region src/connectors/route.ts
|
|
7
|
+
/**
|
|
8
|
+
* Connector routing as FigJam routes, checked against routes Figma derived
|
|
9
|
+
* (`packages/scene-graph/tests/connectors/figma-routes.json`).
|
|
10
|
+
*/
|
|
11
|
+
/** Curve handles as a share of the distance between the two edge points. */
|
|
12
|
+
const CURVE_HANDLE_RATIO = .42667;
|
|
13
|
+
/** Whether two boxes share more than a corner: they overlap, or meet along an edge. */
|
|
14
|
+
function touches(a, b) {
|
|
15
|
+
const meetX = a.x <= b.x + b.width && b.x <= a.x + a.width;
|
|
16
|
+
const meetY = a.y <= b.y + b.height && b.y <= a.y + a.height;
|
|
17
|
+
const overlapX = a.x < b.x + b.width && b.x < a.x + a.width;
|
|
18
|
+
const overlapY = a.y < b.y + b.height && b.y < a.y + a.height;
|
|
19
|
+
return overlapX && meetY || meetX && overlapY;
|
|
20
|
+
}
|
|
21
|
+
function unit(from, to) {
|
|
22
|
+
const length = Math.hypot(to.x - from.x, to.y - from.y);
|
|
23
|
+
return length === 0 ? ZERO : {
|
|
24
|
+
x: (to.x - from.x) / length,
|
|
25
|
+
y: (to.y - from.y) / length
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Where a straight connector's end sits: its side midpoint, or the centre of its layer. */
|
|
29
|
+
function straightAnchor(end) {
|
|
30
|
+
const { box } = end;
|
|
31
|
+
if (!box) return end.point;
|
|
32
|
+
const sides = sidesFor(end.magnet);
|
|
33
|
+
if (sides.length === 1) return sideMidpoint(box, sides[0]);
|
|
34
|
+
return {
|
|
35
|
+
x: box.x + box.width / 2,
|
|
36
|
+
y: box.y + box.height / 2
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** A straight connector: centre to centre, cut where it leaves each layer, less the gaps. */
|
|
40
|
+
function straightRoute(start, end, [startGap, endGap]) {
|
|
41
|
+
const from = straightAnchor(start);
|
|
42
|
+
const to = straightAnchor(end);
|
|
43
|
+
const exit = start.box ? exitPoint(start.box, from, to) : from;
|
|
44
|
+
const entry = end.box ? exitPoint(end.box, to, from) : to;
|
|
45
|
+
const direction = unit(exit, entry);
|
|
46
|
+
return straightPieces([along(exit, direction, startGap), along(entry, direction, -endGap)]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A curved connector: one cubic between the elbow's ends, its handles along the sides it leaves
|
|
50
|
+
* and enters by. Each handle is a fixed share of the distance between the edge points, less the
|
|
51
|
+
* end's gap; ends that face each other in line draw straight.
|
|
52
|
+
*/
|
|
53
|
+
function curvedRoute(start, end, [startSide, endSide], [startGap, endGap]) {
|
|
54
|
+
const edgeFrom = attachment(start, startSide);
|
|
55
|
+
const edgeTo = attachment(end, endSide);
|
|
56
|
+
const from = along(edgeFrom, OUTWARD[startSide], startGap);
|
|
57
|
+
const to = along(edgeTo, OUTWARD[endSide], endGap);
|
|
58
|
+
const offset = startSide === "TOP" || startSide === "BOTTOM" ? from.x - to.x : from.y - to.y;
|
|
59
|
+
if (Math.abs(offset) < 1e-6 && endSide === opposite(startSide)) return straightPieces([from, to]);
|
|
60
|
+
const handle = CURVE_HANDLE_RATIO * Math.hypot(edgeTo.x - edgeFrom.x, edgeTo.y - edgeFrom.y);
|
|
61
|
+
return [{
|
|
62
|
+
from,
|
|
63
|
+
to,
|
|
64
|
+
handleFrom: along(ZERO, OUTWARD[startSide], Math.max(0, handle - startGap)),
|
|
65
|
+
handleTo: along(ZERO, OUTWARD[endSide], Math.max(0, handle - endGap))
|
|
66
|
+
}];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether an end stops short of where it attaches by its cap's gap: every end attached by a
|
|
70
|
+
* magnet does, including one FigJam pins to a point of a section (`ABSOLUTE`); a free end, or a
|
|
71
|
+
* point a script sets (`NONE`), is reached exactly.
|
|
72
|
+
*/
|
|
73
|
+
function gapped(end) {
|
|
74
|
+
return end.magnet !== "NONE";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The pieces of a connector's line between its two ends, in the connector's parent's axes. Ends
|
|
78
|
+
* attached by a magnet stop short by their caps' gaps; free ends sit on their points. Layers that
|
|
79
|
+
* touch or overlap leave an elbow or a curve nothing to route but the start, as in Figma. An elbow
|
|
80
|
+
* runs along the segments it was dragged to and a curve bends to its dragged control points,
|
|
81
|
+
* leaving their ends by the sides they would take anyway.
|
|
82
|
+
*/
|
|
83
|
+
function routeConnector(lineType, start, end, strokeWeight, controls = {
|
|
84
|
+
points: [],
|
|
85
|
+
curve: null
|
|
86
|
+
}) {
|
|
87
|
+
const gaps = [gapped(start) ? connectorEndGap(start, strokeWeight, "start") : 0, gapped(end) ? connectorEndGap(end, strokeWeight, "end") : 0];
|
|
88
|
+
if (lineType === "STRAIGHT") return straightRoute(start, end, gaps);
|
|
89
|
+
const [startSide, endSide] = connectorSides(start, end);
|
|
90
|
+
if (start.box && end.box && touches(start.box, end.box)) {
|
|
91
|
+
const at = sideMidpoint(start.box, startSide);
|
|
92
|
+
return [{
|
|
93
|
+
from: at,
|
|
94
|
+
to: at,
|
|
95
|
+
handleFrom: ZERO,
|
|
96
|
+
handleTo: ZERO
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
if (lineType === "CURVED" && controls.curve) return controlledCurveRoute(start, end, [startSide, endSide], gaps, controls.curve);
|
|
100
|
+
if (lineType === "CURVED") return curvedRoute(start, end, [startSide, end.box || !start.box ? endSide : opposite(startSide)], gaps);
|
|
101
|
+
if (controls.points.length > 0) return controlledElbowRoute(start, end, [startSide, endSide], gaps, controls.points);
|
|
102
|
+
return elbowRoute(start, end, [startSide, endSide], gaps) ?? [];
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { routeConnector };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","names":[],"sources":["../../src/connectors/route.ts"],"sourcesContent":["import type { Rect, Vector } from '../primitives'\nimport type { ConnectorControlPoint, ConnectorLineType } from '../types'\nimport { controlledCurveRoute, controlledElbowRoute } from './controls'\nimport { elbowRoute } from './elbow'\nimport { connectorEndGap } from './gaps'\nimport { along, EPSILON, exitPoint, straightPieces, ZERO, type ConnectorPiece } from './pieces'\nimport {\n attachment,\n connectorSides,\n opposite,\n OUTWARD,\n sideMidpoint,\n sidesFor,\n type ConnectorRouteEnd,\n type ConnectorSide\n} from './sides'\n\n/**\n * Connector routing as FigJam routes, checked against routes Figma derived\n * (`packages/scene-graph/tests/connectors/figma-routes.json`).\n */\n\n/** Curve handles as a share of the distance between the two edge points. */\nconst CURVE_HANDLE_RATIO = 0.42667\n\n/** Whether two boxes share more than a corner: they overlap, or meet along an edge. */\nfunction touches(a: Rect, b: Rect): boolean {\n const meetX = a.x <= b.x + b.width && b.x <= a.x + a.width\n const meetY = a.y <= b.y + b.height && b.y <= a.y + a.height\n const overlapX = a.x < b.x + b.width && b.x < a.x + a.width\n const overlapY = a.y < b.y + b.height && b.y < a.y + a.height\n return (overlapX && meetY) || (meetX && overlapY)\n}\n\nfunction unit(from: Vector, to: Vector): Vector {\n const length = Math.hypot(to.x - from.x, to.y - from.y)\n return length === 0 ? ZERO : { x: (to.x - from.x) / length, y: (to.y - from.y) / length }\n}\n\n/** Where a straight connector's end sits: its side midpoint, or the centre of its layer. */\nfunction straightAnchor(end: ConnectorRouteEnd): Vector {\n const { box } = end\n if (!box) return end.point\n const sides = sidesFor(end.magnet)\n if (sides.length === 1) return sideMidpoint(box, sides[0])\n return { x: box.x + box.width / 2, y: box.y + box.height / 2 }\n}\n\n/** A straight connector: centre to centre, cut where it leaves each layer, less the gaps. */\nfunction straightRoute(\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n [startGap, endGap]: [number, number]\n): ConnectorPiece[] {\n const from = straightAnchor(start)\n const to = straightAnchor(end)\n const exit = start.box ? exitPoint(start.box, from, to) : from\n const entry = end.box ? exitPoint(end.box, to, from) : to\n const direction = unit(exit, entry)\n return straightPieces([along(exit, direction, startGap), along(entry, direction, -endGap)])\n}\n\n/**\n * A curved connector: one cubic between the elbow's ends, its handles along the sides it leaves\n * and enters by. Each handle is a fixed share of the distance between the edge points, less the\n * end's gap; ends that face each other in line draw straight.\n */\nfunction curvedRoute(\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n [startSide, endSide]: [ConnectorSide, ConnectorSide],\n [startGap, endGap]: [number, number]\n): ConnectorPiece[] {\n const edgeFrom = attachment(start, startSide)\n const edgeTo = attachment(end, endSide)\n const from = along(edgeFrom, OUTWARD[startSide], startGap)\n const to = along(edgeTo, OUTWARD[endSide], endGap)\n const vertical = startSide === 'TOP' || startSide === 'BOTTOM'\n const offset = vertical ? from.x - to.x : from.y - to.y\n if (Math.abs(offset) < EPSILON && endSide === opposite(startSide)) {\n return straightPieces([from, to])\n }\n const handle = CURVE_HANDLE_RATIO * Math.hypot(edgeTo.x - edgeFrom.x, edgeTo.y - edgeFrom.y)\n return [\n {\n from,\n to,\n handleFrom: along(ZERO, OUTWARD[startSide], Math.max(0, handle - startGap)),\n handleTo: along(ZERO, OUTWARD[endSide], Math.max(0, handle - endGap))\n }\n ]\n}\n\n/**\n * Whether an end stops short of where it attaches by its cap's gap: every end attached by a\n * magnet does, including one FigJam pins to a point of a section (`ABSOLUTE`); a free end, or a\n * point a script sets (`NONE`), is reached exactly.\n */\nfunction gapped(end: ConnectorRouteEnd): boolean {\n return end.magnet !== 'NONE'\n}\n\n/** Where a connector's line was dragged to, in the connector's parent's axes. */\nexport interface ConnectorRouteControls {\n /** An elbow's dragged segments, in order. */\n points: ConnectorControlPoint[]\n /** A curve's two control points. */\n curve: [Vector, Vector] | null\n}\n\n/**\n * The pieces of a connector's line between its two ends, in the connector's parent's axes. Ends\n * attached by a magnet stop short by their caps' gaps; free ends sit on their points. Layers that\n * touch or overlap leave an elbow or a curve nothing to route but the start, as in Figma. An elbow\n * runs along the segments it was dragged to and a curve bends to its dragged control points,\n * leaving their ends by the sides they would take anyway.\n */\nexport function routeConnector(\n lineType: ConnectorLineType,\n start: ConnectorRouteEnd,\n end: ConnectorRouteEnd,\n strokeWeight: number,\n controls: ConnectorRouteControls = { points: [], curve: null }\n): ConnectorPiece[] {\n const gaps: [number, number] = [\n gapped(start) ? connectorEndGap(start, strokeWeight, 'start') : 0,\n gapped(end) ? connectorEndGap(end, strokeWeight, 'end') : 0\n ]\n if (lineType === 'STRAIGHT') return straightRoute(start, end, gaps)\n const [startSide, endSide] = connectorSides(start, end)\n if (start.box && end.box && touches(start.box, end.box)) {\n const at = sideMidpoint(start.box, startSide)\n return [{ from: at, to: at, handleFrom: ZERO, handleTo: ZERO }]\n }\n if (lineType === 'CURVED' && controls.curve) {\n return controlledCurveRoute(start, end, [startSide, endSide], gaps, controls.curve)\n }\n if (lineType === 'CURVED') {\n // A curve to a free point arrives facing the way it left, where an elbow arrives along the\n // longer axis.\n const curveEndSide = end.box || !start.box ? endSide : opposite(startSide)\n return curvedRoute(start, end, [startSide, curveEndSide], gaps)\n }\n if (controls.points.length > 0) {\n return controlledElbowRoute(start, end, [startSide, endSide], gaps, controls.points)\n }\n return elbowRoute(start, end, [startSide, endSide], gaps) ?? []\n}\n"],"mappings":";;;;;;;;;;;AAuBA,MAAM,qBAAqB;;AAG3B,SAAS,QAAQ,GAAS,GAAkB;CAC1C,MAAM,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;CACrD,MAAM,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;CACtD,MAAM,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;CACtD,MAAM,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE;CACvD,OAAQ,YAAY,SAAW,SAAS;AAC1C;AAEA,SAAS,KAAK,MAAc,IAAoB;CAC9C,MAAM,SAAS,KAAK,MAAM,GAAG,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC;CACtD,OAAO,WAAW,IAAI,OAAO;EAAE,IAAI,GAAG,IAAI,KAAK,KAAK;EAAQ,IAAI,GAAG,IAAI,KAAK,KAAK;CAAO;AAC1F;;AAGA,SAAS,eAAe,KAAgC;CACtD,MAAM,EAAE,QAAQ;CAChB,IAAI,CAAC,KAAK,OAAO,IAAI;CACrB,MAAM,QAAQ,SAAS,IAAI,MAAM;CACjC,IAAI,MAAM,WAAW,GAAG,OAAO,aAAa,KAAK,MAAM,EAAE;CACzD,OAAO;EAAE,GAAG,IAAI,IAAI,IAAI,QAAQ;EAAG,GAAG,IAAI,IAAI,IAAI,SAAS;CAAE;AAC/D;;AAGA,SAAS,cACP,OACA,KACA,CAAC,UAAU,SACO;CAClB,MAAM,OA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AAI,gBAAgB,OAAO,cAAc,OAAO,IAAI,GAChE,OAAO,GAAG,IAAI,gBAAgB,KAAK,cAAc,KAAK,IAAI,CAC5D;CACA,IAAI,aAAa,YAAY,OAAO,cAAc,OAAO,KAAK,IAAI;CAClE,MAAM,CAAC,WAAW,WAAW,eAAe,OAAO,GAAG;CACtD,IAAI,MAAM,OAAO,IAAI,OAAO,QAAQ,MAAM,KAAK,IAAI,GAAG,GAAG;EACvD,MAAM,KAAK,aAAa,MAAM,KAAK,SAAS;EAC5C,OAAO,CAAC;GAAE,MAAM;GAAI,IAAI;GAAI,YAAY;GAAM,UAAU;EAAK,CAAC;CAChE;CACA,IAAI,aAAa,YAAY,SAAS,OACpC,OAAO,qBAAqB,OAAO,KAAK,CAAC,WAAW,OAAO,GAAG,MAAM,SAAS,KAAK;CAEpF,IAAI,aAAa,UAIf,OAAO,YAAY,OAAO,KAAK,CAAC,WADX,IAAI,OAAO,CAAC,MAAM,MAAM,UAAU,SAAS,SAAS,CAClB,GAAG,IAAI;CAEhE,IAAI,SAAS,OAAO,SAAS,GAC3B,OAAO,qBAAqB,OAAO,KAAK,CAAC,WAAW,OAAO,GAAG,MAAM,SAAS,MAAM;CAErF,OAAO,WAAW,OAAO,KAAK,CAAC,WAAW,OAAO,GAAG,IAAI,KAAK,CAAC;AAChE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Rect, Vector } from "../primitives/index.js";
|
|
2
|
+
import { ConnectorMagnet, StrokeCap } from "../types.js";
|
|
3
|
+
//#region src/connectors/sides.d.ts
|
|
4
|
+
type ConnectorSide = 'TOP' | 'RIGHT' | 'BOTTOM' | 'LEFT';
|
|
5
|
+
/** One end of a connector as the router sees it: the box it follows, or a free point. */
|
|
6
|
+
interface ConnectorRouteEnd {
|
|
7
|
+
/** The bound layer's box in the connector's parent's axes; null for an end at a point. */
|
|
8
|
+
box: Rect | null;
|
|
9
|
+
/** Where an end at a point sits, in the connector's parent's axes. */
|
|
10
|
+
point: Vector;
|
|
11
|
+
magnet: ConnectorMagnet;
|
|
12
|
+
cap: StrokeCap;
|
|
13
|
+
/** How far the layer's outline reaches past its box: half a FigJam shape's stroke. */
|
|
14
|
+
outline: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The sides a connector leaves and enters by: of the side midpoints its magnets allow, the pair
|
|
18
|
+
* closest together. A free end faces its line along the longer axis.
|
|
19
|
+
*/
|
|
20
|
+
declare function connectorSides(start: ConnectorRouteEnd, end: ConnectorRouteEnd): [ConnectorSide, ConnectorSide];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ConnectorRouteEnd, ConnectorSide, connectorSides };
|
|
23
|
+
//# sourceMappingURL=sides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sides.d.ts","names":[],"sources":["../../src/connectors/sides.ts"],"mappings":";;;KAIY;;UAYK;;EAEf,KAAK;;EAEL,OAAO;EACP,QAAQ;EACR,KAAK;;EAEL;;;;;;iBA6Cc,eACd,OAAO,mBACP,KAAK,qBACH,eAAe"}
|