@open-pencil/scene-graph 0.16.0 → 0.17.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-caps.d.ts +35 -14
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +286 -55
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +17 -0
- package/dist/asset-keys.d.ts.map +1 -0
- package/dist/asset-keys.js.map +1 -0
- package/dist/behaviours/index.d.ts +6 -0
- package/dist/behaviours/index.js +6 -0
- package/dist/behaviours/kinds.d.ts +62 -0
- package/dist/behaviours/kinds.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
- package/dist/behaviours/kinds.js.map +1 -0
- package/dist/behaviours/layers.d.ts +16 -0
- package/dist/behaviours/layers.d.ts.map +1 -0
- package/dist/behaviours/layers.js +43 -0
- package/dist/behaviours/layers.js.map +1 -0
- package/dist/behaviours/model.d.ts +48 -0
- package/dist/behaviours/model.d.ts.map +1 -0
- package/dist/behaviours/model.js +156 -0
- package/dist/behaviours/model.js.map +1 -0
- package/dist/behaviours/schema.d.ts +228 -0
- package/dist/behaviours/schema.d.ts.map +1 -0
- package/dist/behaviours/schema.js +86 -0
- package/dist/behaviours/schema.js.map +1 -0
- package/dist/behaviours/spec.d.ts +26 -0
- package/dist/behaviours/spec.d.ts.map +1 -0
- package/dist/{chunks/behaviours → behaviours}/spec.js +6 -29
- package/dist/behaviours/spec.js.map +1 -0
- package/dist/bindings.js +26 -0
- package/dist/bindings.js.map +1 -0
- package/dist/buffered-events.d.ts +21 -0
- package/dist/buffered-events.d.ts.map +1 -0
- package/dist/buffered-events.js.map +1 -0
- package/dist/checkpoint.d.ts +42 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +249 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/clipping.d.ts +31 -0
- package/dist/clipping.d.ts.map +1 -0
- package/dist/clipping.js +125 -0
- package/dist/clipping.js.map +1 -0
- package/dist/color/contrast.d.ts +17 -0
- package/dist/color/contrast.d.ts.map +1 -0
- package/dist/{chunks/color → color}/contrast.js +2 -24
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +38 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +110 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/management.d.ts +32 -0
- package/dist/color/management.d.ts.map +1 -0
- package/dist/color/management.js +187 -0
- package/dist/color/management.js.map +1 -0
- package/dist/color/normalize.d.ts +6 -0
- package/dist/color/normalize.d.ts.map +1 -0
- package/dist/color/normalize.js +15 -0
- package/dist/color/normalize.js.map +1 -0
- package/dist/color/okhcl.d.ts +33 -0
- package/dist/color/okhcl.d.ts.map +1 -0
- package/dist/color/okhcl.js +146 -0
- package/dist/color/okhcl.js.map +1 -0
- package/dist/color/schema.d.ts +11 -0
- package/dist/color/schema.d.ts.map +1 -0
- package/dist/color/schema.js +13 -0
- package/dist/color/schema.js.map +1 -0
- package/dist/comments/document.d.ts +23 -0
- package/dist/comments/document.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/document.js +2 -1
- package/dist/comments/document.js.map +1 -0
- package/dist/comments/index.d.ts +6 -0
- package/dist/comments/index.js +6 -0
- package/dist/comments/list.d.ts +25 -0
- package/dist/comments/list.d.ts.map +1 -0
- package/dist/comments/list.js +33 -0
- package/dist/comments/list.js.map +1 -0
- package/dist/comments/merge.d.ts +16 -0
- package/dist/comments/merge.d.ts.map +1 -0
- package/dist/{chunks/comments → comments}/merge.js +1 -1
- package/dist/comments/merge.js.map +1 -0
- package/dist/comments/schema.d.ts +8 -0
- package/dist/comments/schema.d.ts.map +1 -0
- package/dist/comments/schema.js +50 -0
- package/dist/comments/schema.js.map +1 -0
- package/dist/comments/threads.d.ts +59 -0
- package/dist/comments/threads.d.ts.map +1 -0
- package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
- package/dist/comments/threads.js.map +1 -0
- package/dist/components/exposure.d.ts +24 -0
- package/dist/components/exposure.d.ts.map +1 -0
- package/dist/components/exposure.js +51 -0
- package/dist/components/exposure.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/properties.d.ts +32 -0
- package/dist/components/properties.d.ts.map +1 -0
- package/dist/components/properties.js +180 -0
- package/dist/components/properties.js.map +1 -0
- package/dist/components/variants.d.ts +33 -0
- package/dist/components/variants.d.ts.map +1 -0
- package/dist/components/variants.js +58 -0
- package/dist/components/variants.js.map +1 -0
- package/dist/connectors/controls.d.ts +34 -0
- package/dist/connectors/controls.d.ts.map +1 -0
- package/dist/connectors/controls.js +196 -0
- package/dist/connectors/controls.js.map +1 -0
- package/dist/connectors/create.d.ts +23 -0
- package/dist/connectors/create.d.ts.map +1 -0
- package/dist/connectors/create.js +33 -0
- package/dist/connectors/create.js.map +1 -0
- package/dist/connectors/elbow.js +191 -0
- package/dist/connectors/elbow.js.map +1 -0
- package/dist/connectors/gaps.d.ts +10 -0
- package/dist/connectors/gaps.d.ts.map +1 -0
- package/dist/connectors/gaps.js +86 -0
- package/dist/connectors/gaps.js.map +1 -0
- package/dist/connectors/hit.d.ts +11 -0
- package/dist/connectors/hit.d.ts.map +1 -0
- package/dist/connectors/hit.js +47 -0
- package/dist/connectors/hit.js.map +1 -0
- package/dist/connectors/index.d.ts +11 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/label.d.ts +32 -0
- package/dist/connectors/label.d.ts.map +1 -0
- package/dist/connectors/label.js +213 -0
- package/dist/connectors/label.js.map +1 -0
- package/dist/connectors/layout.d.ts +46 -0
- package/dist/connectors/layout.d.ts.map +1 -0
- package/dist/connectors/layout.js +234 -0
- package/dist/connectors/layout.js.map +1 -0
- package/dist/connectors/pieces.d.ts +22 -0
- package/dist/connectors/pieces.d.ts.map +1 -0
- package/dist/connectors/pieces.js +156 -0
- package/dist/connectors/pieces.js.map +1 -0
- package/dist/connectors/route.d.ts +23 -0
- package/dist/connectors/route.d.ts.map +1 -0
- package/dist/connectors/route.js +107 -0
- package/dist/connectors/route.js.map +1 -0
- package/dist/connectors/sides.d.ts +23 -0
- package/dist/connectors/sides.d.ts.map +1 -0
- package/dist/connectors/sides.js +98 -0
- package/dist/connectors/sides.js.map +1 -0
- package/dist/connectors/sublayers.d.ts +76 -0
- package/dist/connectors/sublayers.d.ts.map +1 -0
- package/dist/connectors/sublayers.js +208 -0
- package/dist/connectors/sublayers.js.map +1 -0
- package/dist/constants.d.ts +11 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -1
- package/dist/constants.js.map +1 -0
- package/dist/coordinate.d.ts +94 -2
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +268 -1
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +49 -2
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +264 -2
- package/dist/copy.js.map +1 -0
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.js.map +1 -0
- package/dist/css/grid.d.ts +7 -0
- package/dist/css/grid.d.ts.map +1 -0
- package/dist/{chunks/css → css}/grid.js +2 -33
- package/dist/css/grid.js.map +1 -0
- package/dist/css/index.d.ts +7 -0
- package/dist/css/index.js +7 -0
- package/dist/css/layout.d.ts +17 -0
- package/dist/css/layout.d.ts.map +1 -0
- package/dist/css/layout.js +45 -0
- package/dist/css/layout.js.map +1 -0
- package/dist/css/shadows.d.ts +10 -0
- package/dist/css/shadows.d.ts.map +1 -0
- package/dist/css/shadows.js +64 -0
- package/dist/css/shadows.js.map +1 -0
- package/dist/css/text.d.ts +22 -0
- package/dist/css/text.d.ts.map +1 -0
- package/dist/css/text.js +76 -0
- package/dist/css/text.js.map +1 -0
- package/dist/css/values.d.ts +14 -0
- package/dist/css/values.d.ts.map +1 -0
- package/dist/css/values.js +36 -0
- package/dist/css/values.js.map +1 -0
- package/dist/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/events.js.map +1 -0
- package/dist/export-format.d.ts +25 -0
- package/dist/export-format.d.ts.map +1 -0
- package/dist/export-format.js +47 -0
- package/dist/export-format.js.map +1 -0
- package/dist/export-scale.d.ts +14 -0
- package/dist/export-scale.d.ts.map +1 -0
- package/dist/export-scale.js +19 -0
- package/dist/export-scale.js.map +1 -0
- package/dist/fields/appearance.d.ts +9 -0
- package/dist/fields/appearance.d.ts.map +1 -0
- package/dist/fields/appearance.js +36 -0
- package/dist/fields/appearance.js.map +1 -0
- package/dist/fields/geometry.d.ts +7 -0
- package/dist/fields/geometry.d.ts.map +1 -0
- package/dist/fields/geometry.js.map +1 -0
- package/dist/fields/index.d.ts +5 -0
- package/dist/fields/index.js +5 -0
- package/dist/fields/layout.d.ts +10 -0
- package/dist/fields/layout.d.ts.map +1 -0
- package/dist/fields/layout.js +49 -0
- package/dist/fields/layout.js.map +1 -0
- package/dist/fields/text.d.ts +11 -0
- package/dist/fields/text.d.ts.map +1 -0
- package/dist/fields/text.js +64 -0
- package/dist/fields/text.js.map +1 -0
- package/dist/fig-compression.d.ts +11 -0
- package/dist/fig-compression.d.ts.map +1 -0
- package/dist/fig-compression.js +15 -0
- package/dist/fig-compression.js.map +1 -0
- package/dist/figjam/index.d.ts +3 -0
- package/dist/figjam/index.js +3 -0
- package/dist/figjam/palette.d.ts +270 -0
- package/dist/figjam/palette.d.ts.map +1 -0
- package/dist/figjam/palette.js +439 -0
- package/dist/figjam/palette.js.map +1 -0
- package/dist/figjam/text.d.ts +70 -0
- package/dist/figjam/text.d.ts.map +1 -0
- package/dist/figjam/text.js +95 -0
- package/dist/figjam/text.js.map +1 -0
- package/dist/font-style.d.ts +46 -0
- package/dist/font-style.d.ts.map +1 -0
- package/dist/font-style.js +127 -0
- package/dist/font-style.js.map +1 -0
- package/dist/generated/index.d.ts +44 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/kind.d.ts +27 -0
- package/dist/generated/kind.d.ts.map +1 -0
- package/dist/generated/shape-with-text.d.ts +43 -0
- package/dist/generated/shape-with-text.d.ts.map +1 -0
- package/dist/generated/shape-with-text.js +135 -0
- package/dist/generated/shape-with-text.js.map +1 -0
- package/dist/generated/sticky.d.ts +128 -0
- package/dist/generated/sticky.d.ts.map +1 -0
- package/dist/generated/sticky.js +233 -0
- package/dist/generated/sticky.js.map +1 -0
- package/dist/geometry.d.ts +89 -2
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +306 -2
- package/dist/geometry.js.map +1 -0
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +13 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +178 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +625 -0
- package/dist/graph.js.map +1 -0
- package/dist/group-bounds.d.ts +42 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
- package/dist/group-bounds.js.map +1 -0
- package/dist/guides.d.ts +21 -2
- package/dist/guides.d.ts.map +1 -0
- package/dist/guides.js +5 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +48 -2
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +75 -57
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/glyph.d.ts +22 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/{chunks/icons → icons}/glyph.js +2 -40
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/model.d.ts +29 -0
- package/dist/icons/model.d.ts.map +1 -0
- package/dist/icons/model.js +51 -0
- package/dist/icons/model.js.map +1 -0
- package/dist/icons/schema.d.ts +31 -0
- package/dist/icons/schema.d.ts.map +1 -0
- package/dist/icons/schema.js +28 -0
- package/dist/icons/schema.js.map +1 -0
- package/dist/ids.d.ts +12 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +31 -0
- package/dist/ids.js.map +1 -0
- package/dist/images.d.ts +39 -2
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +67 -9
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -23
- package/dist/instances/assignments.js +89 -0
- package/dist/instances/assignments.js.map +1 -0
- package/dist/instances/content-size.js +60 -0
- package/dist/instances/content-size.js.map +1 -0
- package/dist/instances/copies.js +161 -0
- package/dist/instances/copies.js.map +1 -0
- package/dist/instances/cycles.d.ts +20 -0
- package/dist/instances/cycles.d.ts.map +1 -0
- package/dist/instances/cycles.js +53 -0
- package/dist/instances/cycles.js.map +1 -0
- package/dist/instances/fields.d.ts +18 -0
- package/dist/instances/fields.d.ts.map +1 -0
- package/dist/instances/fields.js +90 -0
- package/dist/instances/fields.js.map +1 -0
- package/dist/instances/index.d.ts +38 -0
- package/dist/instances/index.d.ts.map +1 -0
- package/dist/instances/index.js +180 -0
- package/dist/instances/index.js.map +1 -0
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +13 -0
- package/dist/instances/main-component.d.ts.map +1 -0
- package/dist/instances/main-component.js +50 -0
- package/dist/instances/main-component.js.map +1 -0
- package/dist/instances/overrides.d.ts +51 -0
- package/dist/instances/overrides.d.ts.map +1 -0
- package/dist/instances/overrides.js +158 -0
- package/dist/instances/overrides.js.map +1 -0
- package/dist/instances/placement.js +30 -0
- package/dist/instances/placement.js.map +1 -0
- package/dist/instances/source-walk.js +31 -0
- package/dist/instances/source-walk.js.map +1 -0
- package/dist/instances/swap.js +288 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +327 -0
- package/dist/instances/sync.js.map +1 -0
- package/dist/instances/vector-geometry.js +70 -0
- package/dist/instances/vector-geometry.js.map +1 -0
- package/dist/layout/aspect-ratio.d.ts +27 -0
- package/dist/layout/aspect-ratio.d.ts.map +1 -0
- package/dist/layout/aspect-ratio.js +45 -0
- package/dist/layout/aspect-ratio.js.map +1 -0
- package/dist/layout/guides.d.ts +25 -0
- package/dist/layout/guides.d.ts.map +1 -0
- package/dist/layout/guides.js +105 -0
- package/dist/layout/guides.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/{layout.js → layout/index.js} +4 -3
- package/dist/layout/keywords.d.ts +26 -0
- package/dist/layout/keywords.d.ts.map +1 -0
- package/dist/layout/keywords.js +59 -0
- package/dist/layout/keywords.js.map +1 -0
- package/dist/layout/sizing.d.ts +40 -0
- package/dist/layout/sizing.d.ts.map +1 -0
- package/dist/layout/sizing.js +122 -0
- package/dist/layout/sizing.js.map +1 -0
- package/dist/layout/writes.js +55 -0
- package/dist/layout/writes.js.map +1 -0
- package/dist/matrix.d.ts +16 -2
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +119 -1
- package/dist/matrix.js.map +1 -0
- package/dist/mutation-impact.d.ts +23 -0
- package/dist/mutation-impact.d.ts.map +1 -0
- package/dist/mutation-impact.js +67 -0
- package/dist/mutation-impact.js.map +1 -0
- package/dist/node-defaults.d.ts +22 -2
- package/dist/node-defaults.d.ts.map +1 -0
- package/dist/node-defaults.js +254 -2
- package/dist/node-defaults.js.map +1 -0
- package/dist/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.js.map +1 -0
- package/dist/paints/index.d.ts +2 -0
- package/dist/paints/index.js +2 -0
- package/dist/paints/schema.d.ts +77 -0
- package/dist/paints/schema.d.ts.map +1 -0
- package/dist/paints/schema.js +56 -0
- package/dist/paints/schema.js.map +1 -0
- package/dist/parse-path.d.ts +9 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +39 -2
- package/dist/parse-path.js.map +1 -1
- package/dist/plugin-data/field.d.ts +47 -0
- package/dist/plugin-data/field.d.ts.map +1 -0
- package/dist/plugin-data/field.js +73 -0
- package/dist/plugin-data/field.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +143 -0
- package/dist/plugin-data/fields.d.ts.map +1 -0
- package/dist/plugin-data/fields.js +168 -0
- package/dist/plugin-data/fields.js.map +1 -0
- package/dist/plugin-data/index.d.ts +3 -0
- package/dist/plugin-data/index.js +3 -0
- package/dist/polygon.d.ts +4 -2
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +17 -2
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +12 -2
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +62 -1
- package/dist/preview.js.map +1 -0
- package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/schema.d.ts +18 -0
- package/dist/primitives/schema.d.ts.map +1 -0
- package/dist/primitives/schema.js +19 -0
- package/dist/primitives/schema.js.map +1 -0
- package/dist/random.js +24 -1
- package/dist/random.js.map +1 -0
- package/dist/resize.d.ts +6 -4
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +287 -2
- package/dist/resize.js.map +1 -0
- package/dist/scaling/index.d.ts +3 -0
- package/dist/scaling/index.js +3 -0
- package/dist/scaling/node.d.ts +6 -0
- package/dist/scaling/node.d.ts.map +1 -0
- package/dist/scaling/node.js +148 -0
- package/dist/scaling/node.js.map +1 -0
- package/dist/scaling/tree.d.ts +7 -0
- package/dist/scaling/tree.d.ts.map +1 -0
- package/dist/scaling/tree.js +47 -0
- package/dist/scaling/tree.js.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.js +4 -0
- package/dist/shaders/model.d.ts +41 -0
- package/dist/shaders/model.d.ts.map +1 -0
- package/dist/shaders/model.js +71 -0
- package/dist/shaders/model.js.map +1 -0
- package/dist/shaders/schema.d.ts +41 -0
- package/dist/shaders/schema.d.ts.map +1 -0
- package/dist/shaders/schema.js +36 -0
- package/dist/shaders/schema.js.map +1 -0
- package/dist/shaders/still.d.ts +18 -0
- package/dist/shaders/still.d.ts.map +1 -0
- package/dist/shaders/still.js +36 -0
- package/dist/shaders/still.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +28 -0
- package/dist/shape-with-text/fit.d.ts.map +1 -0
- package/dist/shape-with-text/fit.js +271 -0
- package/dist/shape-with-text/fit.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +20 -0
- package/dist/shape-with-text/geometry.d.ts.map +1 -0
- package/dist/shape-with-text/geometry.js +539 -0
- package/dist/shape-with-text/geometry.js.map +1 -0
- package/dist/shape-with-text/index.d.ts +4 -0
- package/dist/shape-with-text/index.js +4 -0
- package/dist/shape-with-text/kinds.d.ts +20 -0
- package/dist/shape-with-text/kinds.d.ts.map +1 -0
- package/dist/shape-with-text/kinds.js +86 -0
- package/dist/shape-with-text/kinds.js.map +1 -0
- package/dist/shared-styles.d.ts +51 -0
- package/dist/shared-styles.d.ts.map +1 -0
- package/dist/shared-styles.js +186 -0
- package/dist/shared-styles.js.map +1 -0
- package/dist/slots/authoring.d.ts +27 -0
- package/dist/slots/authoring.d.ts.map +1 -0
- package/dist/slots/authoring.js +77 -0
- package/dist/slots/authoring.js.map +1 -0
- package/dist/slots/content.d.ts +41 -0
- package/dist/slots/content.d.ts.map +1 -0
- package/dist/slots/content.js +105 -0
- package/dist/slots/content.js.map +1 -0
- package/dist/slots/frames.d.ts +40 -0
- package/dist/slots/frames.d.ts.map +1 -0
- package/dist/slots/frames.js +118 -0
- package/dist/slots/frames.js.map +1 -0
- package/dist/slots/index.d.ts +5 -0
- package/dist/slots/index.js +5 -0
- package/dist/slots/limits.d.ts +14 -0
- package/dist/slots/limits.d.ts.map +1 -0
- package/dist/slots/limits.js +28 -0
- package/dist/slots/limits.js.map +1 -0
- package/dist/snap.d.ts +21 -2
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +109 -1
- package/dist/snap.js.map +1 -0
- package/dist/source-metadata.js +10 -1
- package/dist/source-metadata.js.map +1 -0
- package/dist/statuses/impact.d.ts +18 -0
- package/dist/statuses/impact.d.ts.map +1 -0
- package/dist/statuses/impact.js +33 -0
- package/dist/statuses/impact.js.map +1 -0
- package/dist/statuses/index.d.ts +5 -0
- package/dist/statuses/index.js +5 -0
- package/dist/statuses/node.d.ts +22 -0
- package/dist/statuses/node.d.ts.map +1 -0
- package/dist/statuses/node.js +47 -0
- package/dist/statuses/node.js.map +1 -0
- package/dist/statuses/schema.d.ts +59 -0
- package/dist/statuses/schema.d.ts.map +1 -0
- package/dist/statuses/schema.js +27 -0
- package/dist/statuses/schema.js.map +1 -0
- package/dist/statuses/workflow.d.ts +120 -0
- package/dist/statuses/workflow.d.ts.map +1 -0
- package/dist/statuses/workflow.js +135 -0
- package/dist/statuses/workflow.js.map +1 -0
- package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
- package/dist/text/direction.d.ts.map +1 -0
- package/dist/{text-direction.js → text/direction.js} +1 -1
- package/dist/text/direction.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.js +7 -0
- package/dist/text/lengths.d.ts +24 -0
- package/dist/text/lengths.d.ts.map +1 -0
- package/dist/text/lengths.js +49 -0
- package/dist/text/lengths.js.map +1 -0
- package/dist/text/lists.d.ts +44 -0
- package/dist/text/lists.d.ts.map +1 -0
- package/dist/text/lists.js +100 -0
- package/dist/text/lists.js.map +1 -0
- package/dist/text/overflow.d.ts +11 -0
- package/dist/text/overflow.d.ts.map +1 -0
- package/dist/text/overflow.js +13 -0
- package/dist/text/overflow.js.map +1 -0
- package/dist/text/paragraphs.d.ts +62 -0
- package/dist/text/paragraphs.d.ts.map +1 -0
- package/dist/text/paragraphs.js +166 -0
- package/dist/text/paragraphs.js.map +1 -0
- package/dist/{text-picture.d.ts → text/picture.d.ts} +3 -4
- package/dist/text/picture.d.ts.map +1 -0
- package/dist/text/picture.js +38 -0
- package/dist/text/picture.js.map +1 -0
- package/dist/text/references.d.ts +21 -0
- package/dist/text/references.d.ts.map +1 -0
- package/dist/text/references.js +43 -0
- package/dist/text/references.js.map +1 -0
- package/dist/text/schema.d.ts +10 -0
- package/dist/text/schema.d.ts.map +1 -0
- package/dist/text/schema.js +11 -0
- package/dist/text/schema.js.map +1 -0
- package/dist/transfer/apply.d.ts +9 -0
- package/dist/transfer/apply.d.ts.map +1 -0
- package/dist/transfer/apply.js +65 -0
- package/dist/transfer/apply.js.map +1 -0
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/history.d.ts +8 -0
- package/dist/transfer/history.d.ts.map +1 -0
- package/dist/transfer/history.js +32 -0
- package/dist/transfer/history.js.map +1 -0
- package/dist/transfer/identity.js +12 -0
- package/dist/transfer/identity.js.map +1 -0
- package/dist/transfer/index.d.ts +8 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/nodes.d.ts +14 -0
- package/dist/transfer/nodes.d.ts.map +1 -0
- package/dist/transfer/nodes.js +78 -0
- package/dist/transfer/nodes.js.map +1 -0
- package/dist/transfer/plan.d.ts +29 -0
- package/dist/transfer/plan.d.ts.map +1 -0
- package/dist/transfer/plan.js +106 -0
- package/dist/transfer/plan.js.map +1 -0
- package/dist/transfer/references.js +10 -0
- package/dist/transfer/references.js.map +1 -0
- package/dist/transfer/remove.d.ts +8 -0
- package/dist/transfer/remove.d.ts.map +1 -0
- package/dist/transfer/remove.js +34 -0
- package/dist/transfer/remove.js.map +1 -0
- package/dist/transfer/validation.js +39 -0
- package/dist/transfer/validation.js.map +1 -0
- package/dist/transfer/variables.d.ts +15 -0
- package/dist/transfer/variables.d.ts.map +1 -0
- package/dist/transfer/variables.js +52 -0
- package/dist/transfer/variables.js.map +1 -0
- package/dist/types.d.ts +195 -2007
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +89 -2
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +93 -2
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +235 -1
- package/dist/undo.js.map +1 -0
- package/dist/variables/bindings.d.ts +83 -0
- package/dist/variables/bindings.d.ts.map +1 -0
- package/dist/variables/bindings.js +314 -0
- package/dist/variables/bindings.js.map +1 -0
- package/dist/variables/corners.d.ts +12 -0
- package/dist/variables/corners.d.ts.map +1 -0
- package/dist/variables/corners.js +38 -0
- package/dist/variables/corners.js.map +1 -0
- package/dist/variables/fields.d.ts +43 -0
- package/dist/variables/fields.d.ts.map +1 -0
- package/dist/variables/fields.js +104 -0
- package/dist/variables/fields.js.map +1 -0
- package/dist/variables/formula/check.d.ts +14 -0
- package/dist/variables/formula/check.d.ts.map +1 -0
- package/dist/variables/formula/check.js +73 -0
- package/dist/variables/formula/check.js.map +1 -0
- package/dist/variables/formula/evaluate.d.ts +7 -0
- package/dist/variables/formula/evaluate.d.ts.map +1 -0
- package/dist/variables/formula/evaluate.js +30 -0
- package/dist/variables/formula/evaluate.js.map +1 -0
- package/dist/variables/formula/index.d.ts +21 -0
- package/dist/variables/formula/index.d.ts.map +1 -0
- package/dist/variables/formula/index.js +77 -0
- package/dist/variables/formula/index.js.map +1 -0
- package/dist/variables/formula/parse.js +141 -0
- package/dist/variables/formula/parse.js.map +1 -0
- package/dist/variables/formula/print.d.ts +25 -0
- package/dist/variables/formula/print.d.ts.map +1 -0
- package/dist/variables/formula/print.js +105 -0
- package/dist/variables/formula/print.js.map +1 -0
- package/dist/variables/formula/schema.d.ts +7 -0
- package/dist/variables/formula/schema.d.ts.map +1 -0
- package/dist/variables/formula/schema.js +62 -0
- package/dist/variables/formula/schema.js.map +1 -0
- package/dist/variables/formula/signatures.d.ts +9 -0
- package/dist/variables/formula/signatures.d.ts.map +1 -0
- package/dist/variables/formula/signatures.js +238 -0
- package/dist/variables/formula/signatures.js.map +1 -0
- package/dist/variables/formula/tokens.d.ts +26 -0
- package/dist/variables/formula/tokens.d.ts.map +1 -0
- package/dist/variables/formula/tokens.js +82 -0
- package/dist/variables/formula/tokens.js.map +1 -0
- package/dist/variables/formula/tree.d.ts +22 -0
- package/dist/variables/formula/tree.d.ts.map +1 -0
- package/dist/variables/formula/tree.js +35 -0
- package/dist/variables/formula/tree.js.map +1 -0
- package/dist/variables/index.d.ts +41 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +238 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/resolution.d.ts +39 -0
- package/dist/variables/resolution.d.ts.map +1 -0
- package/dist/variables/resolution.js +154 -0
- package/dist/variables/resolution.js.map +1 -0
- package/dist/variables/schema.d.ts +40 -0
- package/dist/variables/schema.d.ts.map +1 -0
- package/dist/variables/schema.js +32 -0
- package/dist/variables/schema.js.map +1 -0
- package/dist/variables/text.d.ts +16 -0
- package/dist/variables/text.d.ts.map +1 -0
- package/dist/variables/text.js +49 -0
- package/dist/variables/text.js.map +1 -0
- package/dist/variables/token.d.ts +18 -0
- package/dist/variables/token.d.ts.map +1 -0
- package/dist/variables/token.js +39 -0
- package/dist/variables/token.js.map +1 -0
- package/dist/variables/units.js +19 -0
- package/dist/variables/units.js.map +1 -0
- package/dist/variables/value.d.ts +12 -0
- package/dist/variables/value.d.ts.map +1 -0
- package/dist/variables/value.js +70 -0
- package/dist/variables/value.js.map +1 -0
- package/dist/vector-network.d.ts +65 -2
- package/dist/vector-network.d.ts.map +1 -0
- package/dist/vector-network.js +375 -2
- package/dist/vector-network.js.map +1 -0
- package/package.json +303 -137
- package/src/arrow-caps.ts +279 -62
- package/src/behaviours/index.ts +5 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +5 -3
- package/src/behaviours/model.ts +25 -22
- package/src/behaviours/schema.ts +64 -13
- package/src/behaviours/spec.ts +11 -50
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +252 -5
- package/src/clipping.ts +112 -0
- package/src/color/index.ts +1 -0
- package/src/color/schema.ts +10 -0
- package/src/comments/document.ts +1 -1
- package/src/comments/index.ts +5 -0
- package/src/comments/schema.ts +51 -0
- package/src/comments/threads.ts +1 -1
- package/src/components/exposure.ts +1 -1
- package/src/components/index.ts +8 -0
- package/src/components/properties.ts +94 -4
- package/src/components/variants.ts +52 -31
- package/src/connectors/controls.ts +229 -0
- package/src/connectors/create.ts +48 -0
- package/src/connectors/elbow.ts +235 -0
- package/src/connectors/gaps.ts +72 -0
- package/src/connectors/hit.ts +49 -0
- package/src/connectors/index.ts +28 -0
- package/src/connectors/label.ts +238 -0
- package/src/connectors/layout.ts +280 -0
- package/src/connectors/pieces.ts +141 -0
- package/src/connectors/route.ts +148 -0
- package/src/connectors/sides.ts +94 -0
- package/src/connectors/sublayers.ts +203 -0
- package/src/coordinate.ts +10 -3
- package/src/copy.ts +71 -31
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +2 -0
- package/src/css/text.ts +84 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +30 -1
- package/src/fields/appearance.ts +35 -0
- package/src/fields/index.ts +4 -0
- package/src/fields/layout.ts +48 -0
- package/src/fields/text.ts +32 -1
- package/src/fig-compression.ts +9 -0
- package/src/figjam/index.ts +2 -0
- package/src/figjam/palette.ts +473 -0
- package/src/figjam/text.ts +83 -0
- package/src/font-style.ts +58 -14
- package/src/generated/index.ts +76 -0
- package/src/generated/kind.ts +24 -0
- package/src/generated/shape-with-text.ts +157 -0
- package/src/generated/sticky.ts +213 -0
- package/src/geometry.ts +102 -312
- package/src/gradient.ts +14 -0
- package/src/graph.ts +849 -0
- package/src/group-bounds.ts +59 -12
- package/src/guides.ts +6 -1
- package/src/hit-test.ts +118 -74
- package/src/icons/index.ts +3 -0
- package/src/icons/model.ts +9 -0
- package/src/icons/schema.ts +19 -3
- package/src/ids.ts +34 -0
- package/src/images.ts +71 -8
- package/src/index.ts +2 -976
- package/src/instances/assignments.ts +116 -0
- package/src/instances/content-size.ts +23 -2
- package/src/instances/copies.ts +7 -10
- package/src/instances/cycles.ts +1 -1
- package/src/instances/fields.ts +47 -92
- package/src/{instances.ts → instances/index.ts} +69 -44
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +55 -1
- package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
- package/src/instances/placement.ts +1 -1
- package/src/instances/source-walk.ts +3 -9
- package/src/instances/swap.ts +451 -0
- package/src/instances/sync.ts +166 -177
- package/src/instances/vector-geometry.ts +3 -3
- package/src/layout/aspect-ratio.ts +1 -1
- package/src/layout/sizing.ts +1 -1
- package/src/layout/writes.ts +59 -0
- package/src/matrix.ts +1 -1
- package/src/mutation-impact.ts +1 -1
- package/src/node-defaults.ts +43 -3
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- package/src/paints/index.ts +1 -0
- package/src/paints/schema.ts +67 -0
- package/src/parse-path.ts +49 -4
- package/src/plugin-data/fields.ts +69 -77
- package/src/plugin-data/index.ts +2 -0
- package/src/polygon.ts +17 -0
- package/src/preview.ts +1 -1
- package/src/{primitives.ts → primitives/index.ts} +2 -0
- package/src/primitives/schema.ts +14 -0
- package/src/resize.ts +32 -6
- package/src/scaling/node.ts +10 -6
- package/src/scaling/tree.ts +2 -1
- package/src/shaders/index.ts +3 -0
- package/src/shaders/schema.ts +3 -3
- package/src/shape-with-text/fit.ts +154 -0
- package/src/shape-with-text/geometry.ts +496 -0
- package/src/shape-with-text/index.ts +10 -0
- package/src/shape-with-text/kinds.ts +86 -0
- package/src/shared-styles.ts +169 -17
- package/src/slots/authoring.ts +1 -1
- package/src/slots/content.ts +10 -5
- package/src/slots/frames.ts +12 -10
- package/src/slots/index.ts +4 -0
- package/src/slots/limits.ts +1 -1
- package/src/snap.ts +3 -1
- package/src/statuses/impact.ts +38 -0
- package/src/statuses/index.ts +4 -0
- package/src/statuses/node.ts +63 -0
- package/src/statuses/schema.ts +39 -0
- package/src/statuses/workflow.ts +121 -0
- package/src/text/index.ts +3 -0
- package/src/text/lengths.ts +44 -0
- package/src/text/overflow.ts +12 -0
- package/src/text/picture.ts +0 -4
- package/src/text/schema.ts +7 -0
- package/src/transfer/apply.ts +1 -1
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/history.ts +1 -1
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +18 -19
- package/src/transfer/plan.ts +1 -1
- package/src/transfer/remove.ts +1 -1
- package/src/transfer/validation.ts +1 -1
- package/src/transfer/variables.ts +7 -6
- package/src/types.ts +246 -13
- package/src/undo.ts +64 -2
- package/src/variables/bindings.ts +166 -66
- package/src/variables/corners.ts +39 -0
- package/src/variables/fields.ts +83 -0
- package/src/variables/formula/check.ts +99 -0
- package/src/variables/formula/evaluate.ts +33 -0
- package/src/variables/formula/index.ts +129 -0
- package/src/variables/formula/parse.ts +160 -0
- package/src/variables/formula/print.ts +167 -0
- package/src/variables/formula/schema.ts +77 -0
- package/src/variables/formula/signatures.ts +266 -0
- package/src/variables/formula/tokens.ts +114 -0
- package/src/variables/formula/tree.ts +53 -0
- package/src/{variables.ts → variables/index.ts} +86 -146
- package/src/variables/resolution.ts +293 -0
- package/src/variables/schema.ts +31 -0
- package/src/variables/text.ts +51 -0
- package/src/variables/token.ts +27 -1
- package/src/variables/value.ts +92 -0
- package/src/vector-network.ts +263 -22
- package/dist/chunks/asset-keys.js.map +0 -1
- package/dist/chunks/behaviours/kinds.js.map +0 -1
- package/dist/chunks/behaviours/layers.js +0 -611
- package/dist/chunks/behaviours/layers.js.map +0 -1
- package/dist/chunks/behaviours/spec.js.map +0 -1
- package/dist/chunks/bindings.js +0 -18
- package/dist/chunks/bindings.js.map +0 -1
- package/dist/chunks/buffered-events.js.map +0 -1
- package/dist/chunks/checkpoint.js +0 -78
- package/dist/chunks/checkpoint.js.map +0 -1
- package/dist/chunks/color/contrast.js.map +0 -1
- package/dist/chunks/color/index.js +0 -1662
- package/dist/chunks/color/index.js.map +0 -1
- package/dist/chunks/comments/document.js.map +0 -1
- package/dist/chunks/comments/list.js.map +0 -1
- package/dist/chunks/comments/merge.js.map +0 -1
- package/dist/chunks/components/exposure.js +0 -2291
- package/dist/chunks/components/exposure.js.map +0 -1
- package/dist/chunks/components/variants.js +0 -32
- package/dist/chunks/components/variants.js.map +0 -1
- package/dist/chunks/coordinate.js +0 -385
- package/dist/chunks/coordinate.js.map +0 -1
- package/dist/chunks/css/grid.js.map +0 -1
- package/dist/chunks/css/index.js +0 -160
- package/dist/chunks/css/index.js.map +0 -1
- package/dist/chunks/events.js.map +0 -1
- package/dist/chunks/fields/geometry.js.map +0 -1
- package/dist/chunks/font-style.js +0 -96
- package/dist/chunks/font-style.js.map +0 -1
- package/dist/chunks/group-bounds.js.map +0 -1
- package/dist/chunks/icons/glyph.js.map +0 -1
- package/dist/chunks/index.js +0 -2430
- package/dist/chunks/index.js.map +0 -1
- package/dist/color.d.ts +0 -78
- package/dist/color.d.ts.map +0 -1
- package/dist/color.js +0 -3
- package/dist/constants2.d.ts +0 -11
- package/dist/constants2.d.ts.map +0 -1
- package/dist/css.d.ts +0 -39
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -3
- package/dist/images2.d.ts +0 -16
- package/dist/images2.d.ts.map +0 -1
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +0 -2
- package/dist/layout.d.ts +0 -2
- package/dist/matrix2.d.ts +0 -16
- package/dist/matrix2.d.ts.map +0 -1
- package/dist/primitives.d.ts +0 -2
- package/dist/primitives.js +0 -0
- package/dist/primitives2.d.ts.map +0 -1
- package/dist/text-direction.d.ts.map +0 -1
- package/dist/text-direction.js.map +0 -1
- package/dist/text-picture.d.ts.map +0 -1
- package/dist/text-picture.js +0 -2
- package/dist/text.d.ts +0 -2
- package/dist/text.js +0 -3
- package/dist/types2.d.ts +0 -2
- package/dist/undo2.d.ts +0 -73
- package/dist/undo2.d.ts.map +0 -1
- package/dist/variables.d.ts +0 -2
- package/dist/variables.js +0 -2
- /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
- /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
- /package/dist/{chunks/events.js → events.js} +0 -0
- /package/dist/{chunks/fields → fields}/geometry.js +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { BLACK } from '../constants'
|
|
2
|
+
import type { GeneratedFrameKind } from '../generated/kind'
|
|
3
|
+
import type { SceneGraph } from '../graph'
|
|
4
|
+
import type { Color, Vector } from '../primitives'
|
|
5
|
+
import { pixelLength } from '../text/lengths'
|
|
6
|
+
import type { ConnectorEndpoint, Fill, SceneNode, Stroke, VectorNetwork } from '../types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A FigJam connector as Figma draws it by default: a grey line 4 px wide with rounded elbows, a
|
|
10
|
+
* round start, and an arrow at the end. Measured in FigJam.
|
|
11
|
+
*/
|
|
12
|
+
export const CONNECTOR_COLOR: Color = { r: 117 / 255, g: 117 / 255, b: 117 / 255, a: 1 }
|
|
13
|
+
export const CONNECTOR_STROKE_WEIGHT = 4
|
|
14
|
+
/** FigJam's line menu draws a connector Thin, at its default weight, or Thick, at twice it. */
|
|
15
|
+
export const CONNECTOR_THICK_STROKE_WEIGHT = 8
|
|
16
|
+
export const CONNECTOR_CORNER_RADIUS = 24
|
|
17
|
+
/** The face a connector's label starts in, as FigJam's: Inter Medium. */
|
|
18
|
+
export const CONNECTOR_LABEL_FONT = { family: 'Inter', weight: 500 } as const
|
|
19
|
+
|
|
20
|
+
/** The dash FigJam's line menu draws a connector with, longer for a thick line. Measured in FigJam. */
|
|
21
|
+
export function connectorDash(weight: number): number[] {
|
|
22
|
+
return weight >= CONNECTOR_THICK_STROKE_WEIGHT ? [40, 24] : [16, 10]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** How a connector's line is drawn: its colour, weight, and whether it is dashed. */
|
|
26
|
+
export interface ConnectorLineStyle {
|
|
27
|
+
color: Color
|
|
28
|
+
weight: number
|
|
29
|
+
dashed: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The style a connector's line is drawn in. */
|
|
33
|
+
export function connectorLineStyle(line: Pick<SceneNode, 'strokes'>): ConnectorLineStyle {
|
|
34
|
+
const stroke = line.strokes.at(0) ?? connectorStroke()
|
|
35
|
+
return {
|
|
36
|
+
color: { ...stroke.color },
|
|
37
|
+
weight: stroke.weight,
|
|
38
|
+
dashed: (stroke.dashPattern?.length ?? 0) > 0
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A connector's line restyled by `style`, each part left out kept, as FigJam's colour and line
|
|
44
|
+
* menus set it. A new weight or dash takes FigJam's dash for the weight, while a new colour alone
|
|
45
|
+
* keeps the dash the line has, even one of its own. The dash goes on the stroke, which draws with
|
|
46
|
+
* it, and on the line, which files keep.
|
|
47
|
+
*/
|
|
48
|
+
export function connectorLineStyleFields(
|
|
49
|
+
line: Pick<SceneNode, 'strokes'>,
|
|
50
|
+
style: Partial<ConnectorLineStyle>
|
|
51
|
+
): Partial<SceneNode> {
|
|
52
|
+
const current = connectorLineStyle(line)
|
|
53
|
+
const color = style.color ?? current.color
|
|
54
|
+
const weight = style.weight ?? current.weight
|
|
55
|
+
const dashed = style.dashed ?? current.dashed
|
|
56
|
+
const [stroke = connectorStroke()] = line.strokes
|
|
57
|
+
const restyled = style.weight !== undefined || style.dashed !== undefined
|
|
58
|
+
const kept = stroke.dashPattern?.length ? [...stroke.dashPattern] : connectorDash(weight)
|
|
59
|
+
const dashPattern = dashed ? (restyled ? connectorDash(weight) : kept) : []
|
|
60
|
+
return {
|
|
61
|
+
strokes: [{ ...stroke, color: { ...color }, weight, dashPattern: [...dashPattern] }],
|
|
62
|
+
strokeWeight: weight,
|
|
63
|
+
dashPattern
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function connectorStroke(color: Color = CONNECTOR_COLOR): Stroke {
|
|
68
|
+
return {
|
|
69
|
+
type: 'SOLID',
|
|
70
|
+
color: { ...color },
|
|
71
|
+
opacity: 1,
|
|
72
|
+
visible: true,
|
|
73
|
+
weight: CONNECTOR_STROKE_WEIGHT,
|
|
74
|
+
align: 'CENTER',
|
|
75
|
+
cap: 'ROUND',
|
|
76
|
+
join: 'ROUND'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ConnectorSublayers {
|
|
81
|
+
/** The routed line, a vector whose ends carry the connector's caps. */
|
|
82
|
+
line: SceneNode
|
|
83
|
+
/** The plate behind the label, which the line breaks around. */
|
|
84
|
+
labelBackground: SceneNode
|
|
85
|
+
label: SceneNode
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A connector's line, label plate, and label, in drawing order. */
|
|
89
|
+
export function connectorSublayers(
|
|
90
|
+
graph: SceneGraph,
|
|
91
|
+
connector: SceneNode
|
|
92
|
+
): ConnectorSublayers | null {
|
|
93
|
+
const children = graph.getChildren(connector.id)
|
|
94
|
+
if (children.length !== 3) return null
|
|
95
|
+
const [line, labelBackground, label] = children
|
|
96
|
+
if (line.type !== 'VECTOR' || label.type !== 'TEXT') return null
|
|
97
|
+
return { line, labelBackground, label }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* FigJam keeps a connector's box to its route, so it never turns or resizes on its own; typing
|
|
102
|
+
* into it edits its label.
|
|
103
|
+
*/
|
|
104
|
+
export const CONNECTOR_KIND: GeneratedFrameKind = {
|
|
105
|
+
complete: (graph, frame) => connectorSublayers(graph, frame) !== null,
|
|
106
|
+
text: (graph, frame) => connectorSublayers(graph, frame)?.label,
|
|
107
|
+
rotates: false,
|
|
108
|
+
resizes: false,
|
|
109
|
+
namedByText: false
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function solid(color: Color, opacity = 1): Fill {
|
|
113
|
+
return { type: 'SOLID', color: { ...color }, opacity, visible: true }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Adds a connector's sublayers to a CONNECTOR the caller created; its route comes later. */
|
|
117
|
+
export function buildConnectorSublayers(
|
|
118
|
+
graph: SceneGraph,
|
|
119
|
+
connector: SceneNode,
|
|
120
|
+
overrides: Partial<Record<keyof ConnectorSublayers, Partial<SceneNode>>> = {}
|
|
121
|
+
): ConnectorSublayers {
|
|
122
|
+
const empty: VectorNetwork = { vertices: [], segments: [], regions: [] }
|
|
123
|
+
const line = graph.createNode('VECTOR', connector.id, {
|
|
124
|
+
name: 'Line',
|
|
125
|
+
vectorNetwork: empty,
|
|
126
|
+
fills: [],
|
|
127
|
+
strokes: [connectorStroke()],
|
|
128
|
+
strokeWeight: CONNECTOR_STROKE_WEIGHT,
|
|
129
|
+
cornerRadius: CONNECTOR_CORNER_RADIUS,
|
|
130
|
+
...overrides.line
|
|
131
|
+
})
|
|
132
|
+
const labelBackground = graph.createNode('RECTANGLE', connector.id, {
|
|
133
|
+
name: 'Label background',
|
|
134
|
+
fills: [solid({ r: 1, g: 1, b: 1, a: 1 })],
|
|
135
|
+
cornerRadius: 3,
|
|
136
|
+
visible: false,
|
|
137
|
+
...overrides.labelBackground
|
|
138
|
+
})
|
|
139
|
+
const label = graph.createNode('TEXT', connector.id, {
|
|
140
|
+
name: 'Label',
|
|
141
|
+
text: '',
|
|
142
|
+
fontFamily: CONNECTOR_LABEL_FONT.family,
|
|
143
|
+
fontWeight: CONNECTOR_LABEL_FONT.weight,
|
|
144
|
+
fontSize: 16,
|
|
145
|
+
lineHeight: pixelLength(24),
|
|
146
|
+
textAlignHorizontal: 'CENTER',
|
|
147
|
+
textAutoResize: 'WIDTH_AND_HEIGHT',
|
|
148
|
+
fills: [solid(BLACK)],
|
|
149
|
+
visible: false,
|
|
150
|
+
...overrides.label
|
|
151
|
+
})
|
|
152
|
+
return { line, labelBackground, label }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Where a connector's line starts and ends, in its parent's axes: the ends a connector keeps when
|
|
157
|
+
* the layers it was attached to are gone.
|
|
158
|
+
*/
|
|
159
|
+
export function connectorRouteEnds(
|
|
160
|
+
graph: SceneGraph,
|
|
161
|
+
connector: SceneNode
|
|
162
|
+
): { start: Vector; end: Vector } | null {
|
|
163
|
+
const ends = connectorLineEnds(graph, connector)
|
|
164
|
+
if (!ends) return null
|
|
165
|
+
const at = (vertex: Vector) => ({
|
|
166
|
+
x: connector.x + ends.line.x + vertex.x,
|
|
167
|
+
y: connector.y + ends.line.y + vertex.y
|
|
168
|
+
})
|
|
169
|
+
return { start: at(ends.start), end: at(ends.end) }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** A connector's line and where it starts and ends, in the line's own axes. */
|
|
173
|
+
export function connectorLineEnds(
|
|
174
|
+
graph: SceneGraph,
|
|
175
|
+
connector: SceneNode
|
|
176
|
+
): { line: SceneNode; start: Vector; end: Vector } | null {
|
|
177
|
+
const line = connectorSublayers(graph, connector)?.line
|
|
178
|
+
const vertices = line?.vectorNetwork?.vertices ?? []
|
|
179
|
+
const start = vertices.at(0)
|
|
180
|
+
const end = vertices.at(-1)
|
|
181
|
+
return line && start && end ? { line, start, end } : null
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A free connector end at a point in the connector's parent's axes. */
|
|
185
|
+
export function freeEndpoint(x: number, y: number): ConnectorEndpoint {
|
|
186
|
+
return { nodeId: null, magnet: 'NONE', position: { x, y } }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** A connector end bound to a layer, following it by `magnet`. */
|
|
190
|
+
export function boundEndpoint(
|
|
191
|
+
nodeId: string,
|
|
192
|
+
magnet: ConnectorEndpoint['magnet'] = 'AUTO'
|
|
193
|
+
): ConnectorEndpoint {
|
|
194
|
+
return { nodeId, magnet, position: { x: 0, y: 0 } }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The connector whose label `node` is, if it is one. */
|
|
198
|
+
export function labelledConnector(graph: SceneGraph, node: SceneNode): SceneNode | null {
|
|
199
|
+
if (node.type !== 'TEXT' || !node.parentId) return null
|
|
200
|
+
const owner = graph.getNode(node.parentId)
|
|
201
|
+
if (owner?.type !== 'CONNECTOR') return null
|
|
202
|
+
return connectorSublayers(graph, owner)?.label.id === node.id ? owner : null
|
|
203
|
+
}
|
package/src/coordinate.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { SceneGraph
|
|
1
|
+
import type { SceneGraph } from './graph'
|
|
2
2
|
import Matrix, { type Mat3 } from './matrix'
|
|
3
3
|
import { FITTED_CONTAINER_TYPES } from './node-defaults'
|
|
4
4
|
import type { Rect, Vector } from './primitives'
|
|
5
|
+
import type { SceneNode } from './types'
|
|
5
6
|
|
|
6
7
|
export function getWorldMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3 {
|
|
7
8
|
const chain: SceneNode[] = []
|
|
@@ -154,12 +155,18 @@ export function getAbsolutePositionFull(node: SceneNode, graph: SceneGraph) {
|
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
/** Lines retain their origin pivot; other shapes rotate around their center. */
|
|
157
|
-
export function getNodeRotationOrigin(node: SceneNode): Vector {
|
|
158
|
+
export function getNodeRotationOrigin(node: Pick<SceneNode, 'type' | 'width' | 'height'>): Vector {
|
|
158
159
|
return node.type === 'LINE' ? { x: 0, y: 0 } : { x: node.width / 2, y: node.height / 2 }
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
/** What places a layer in its parent: its position, size, reflection, turn, and pivot. */
|
|
163
|
+
export type NodePlacement = Pick<
|
|
164
|
+
SceneNode,
|
|
165
|
+
'type' | 'x' | 'y' | 'width' | 'height' | 'rotation' | 'flipX' | 'flipY'
|
|
166
|
+
>
|
|
167
|
+
|
|
161
168
|
/** Position can be applied separately by renderers before setting up local opacity layers. */
|
|
162
|
-
export function getNodeLocalMatrix(n:
|
|
169
|
+
export function getNodeLocalMatrix(n: NodePlacement, position: Vector = n) {
|
|
163
170
|
let matrix = Matrix.translated(position.x, position.y)
|
|
164
171
|
if (n.flipX || n.flipY) {
|
|
165
172
|
matrix = Matrix.multiply(
|
package/src/copy.ts
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* no shared references between source and copy.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { readGeometryBlob } from './geometry'
|
|
12
|
+
import { cloneInstanceOverrideState } from './instances/overrides'
|
|
13
|
+
import { createDefaultSourceMetadata } from './node-defaults'
|
|
11
14
|
import type {
|
|
12
15
|
ArcData,
|
|
13
16
|
ComponentPropertyDefinition,
|
|
17
|
+
ConnectorEndpoint,
|
|
14
18
|
Effect,
|
|
15
19
|
DerivedTextGlyph,
|
|
16
20
|
Fill,
|
|
@@ -19,12 +23,10 @@ import type {
|
|
|
19
23
|
LayoutGrid,
|
|
20
24
|
SceneNode,
|
|
21
25
|
Stroke,
|
|
22
|
-
StyleRun
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import { createDefaultSourceMetadata } from './node-defaults'
|
|
27
|
-
import { cloneVectorNetwork } from './vector-network'
|
|
26
|
+
StyleRun,
|
|
27
|
+
VectorNetwork,
|
|
28
|
+
VectorRegion
|
|
29
|
+
} from './types'
|
|
28
30
|
|
|
29
31
|
// --- Individual copy functions ---
|
|
30
32
|
|
|
@@ -71,6 +73,8 @@ export function copyStyleRun(r: StyleRun): StyleRun {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink }
|
|
76
|
+
if (r.style.lineHeight) copy.style.lineHeight = { ...r.style.lineHeight }
|
|
77
|
+
if (r.style.letterSpacing) copy.style.letterSpacing = { ...r.style.letterSpacing }
|
|
74
78
|
if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables }
|
|
75
79
|
return copy
|
|
76
80
|
}
|
|
@@ -111,17 +115,32 @@ export function copyStyleRuns(runs: StyleRun[]): StyleRun[] {
|
|
|
111
115
|
return runs.map(copyStyleRun)
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
/**
|
|
115
|
-
function
|
|
118
|
+
/** A region, with new loops when given, keeping its own paints and fill style. */
|
|
119
|
+
export function copyVectorRegion(
|
|
120
|
+
region: VectorRegion,
|
|
121
|
+
loops = region.loops.map((loop) => [...loop])
|
|
122
|
+
): VectorRegion {
|
|
123
|
+
const copy: VectorRegion = { windingRule: region.windingRule, loops }
|
|
124
|
+
if (region.fills) copy.fills = copyFills(region.fills)
|
|
125
|
+
if (region.fillStyleId) copy.fillStyleId = region.fillStyleId
|
|
126
|
+
return copy
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
|
|
130
|
+
export function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork {
|
|
116
131
|
return {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
vertices: vn.vertices.map((v) => ({ ...v })),
|
|
133
|
+
segments: vn.segments.map((s) => ({
|
|
134
|
+
...s,
|
|
135
|
+
tangentStart: { ...s.tangentStart },
|
|
136
|
+
tangentEnd: { ...s.tangentEnd }
|
|
137
|
+
})),
|
|
138
|
+
regions: vn.regions.map((r) => copyVectorRegion(r))
|
|
120
139
|
}
|
|
121
140
|
}
|
|
122
141
|
|
|
123
142
|
export function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {
|
|
124
|
-
return paths.map((p) =>
|
|
143
|
+
return paths.map((p) => ({ windingRule: p.windingRule, commandsBlob: p.commandsBlob.slice() }))
|
|
125
144
|
}
|
|
126
145
|
|
|
127
146
|
/**
|
|
@@ -140,21 +159,15 @@ export function transformGeometryBlob(
|
|
|
140
159
|
ty = 0
|
|
141
160
|
): Uint8Array {
|
|
142
161
|
const out = blob.slice()
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (offset + 8 > out.length) break
|
|
151
|
-
const x = dv.getFloat32(offset, true)
|
|
152
|
-
const y = dv.getFloat32(offset + 4, true)
|
|
153
|
-
dv.setFloat32(offset, m00 * x + m01 * y + tx, true)
|
|
154
|
-
dv.setFloat32(offset + 4, m10 * x + m11 * y + ty, true)
|
|
155
|
-
offset += 8
|
|
162
|
+
const view = new DataView(out.buffer, out.byteOffset, out.byteLength)
|
|
163
|
+
readGeometryBlob(out, (_, coords, offset) => {
|
|
164
|
+
for (let i = 0; i < coords.length; i += 2) {
|
|
165
|
+
const x = coords[i]
|
|
166
|
+
const y = coords[i + 1]
|
|
167
|
+
view.setFloat32(offset + i * 4, m00 * x + m01 * y + tx, true)
|
|
168
|
+
view.setFloat32(offset + i * 4 + 4, m10 * x + m11 * y + ty, true)
|
|
156
169
|
}
|
|
157
|
-
}
|
|
170
|
+
})
|
|
158
171
|
return out
|
|
159
172
|
}
|
|
160
173
|
|
|
@@ -167,9 +180,10 @@ export function transformGeometryPaths(
|
|
|
167
180
|
tx = 0,
|
|
168
181
|
ty = 0
|
|
169
182
|
): GeometryPath[] {
|
|
170
|
-
return paths.map((g) =>
|
|
171
|
-
|
|
172
|
-
|
|
183
|
+
return paths.map((g) => ({
|
|
184
|
+
windingRule: g.windingRule,
|
|
185
|
+
commandsBlob: transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)
|
|
186
|
+
}))
|
|
173
187
|
}
|
|
174
188
|
|
|
175
189
|
/**
|
|
@@ -212,12 +226,22 @@ function copyPropertyDefs(
|
|
|
212
226
|
|
|
213
227
|
/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */
|
|
214
228
|
export function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null {
|
|
215
|
-
return glyphs
|
|
229
|
+
return glyphs
|
|
230
|
+
? glyphs.map((g) => ({
|
|
231
|
+
...g,
|
|
232
|
+
commandsBlob: new Uint8Array(g.commandsBlob),
|
|
233
|
+
...(g.emojiCodePoints ? { emojiCodePoints: [...g.emojiCodePoints] } : {})
|
|
234
|
+
}))
|
|
235
|
+
: null
|
|
216
236
|
}
|
|
217
237
|
|
|
218
238
|
// --- Complex structure copy functions ---
|
|
219
239
|
// These replace structuredClone for known types, avoiding its ~24× overhead.
|
|
220
240
|
|
|
241
|
+
export function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint {
|
|
242
|
+
return { ...endpoint, position: { ...endpoint.position } }
|
|
243
|
+
}
|
|
244
|
+
|
|
221
245
|
function copyArcData(a: ArcData): ArcData {
|
|
222
246
|
return { startingAngle: a.startingAngle, endingAngle: a.endingAngle, innerRadius: a.innerRadius }
|
|
223
247
|
}
|
|
@@ -233,6 +257,14 @@ function copyArcData(a: ArcData): ArcData {
|
|
|
233
257
|
*/
|
|
234
258
|
export type NodeCloneMode = 'deep' | 'fig-import'
|
|
235
259
|
|
|
260
|
+
/** A text's line height and letter spacing, copied so a clone never shares them. */
|
|
261
|
+
function copyTextLengths(src: SceneNode): Pick<SceneNode, 'lineHeight' | 'letterSpacing'> {
|
|
262
|
+
return {
|
|
263
|
+
lineHeight: src.lineHeight && { ...src.lineHeight },
|
|
264
|
+
letterSpacing: { ...src.letterSpacing }
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
236
268
|
export function cloneNodeProps(
|
|
237
269
|
src: SceneNode,
|
|
238
270
|
componentId: string | null,
|
|
@@ -274,6 +306,7 @@ export function cloneNodeProps(
|
|
|
274
306
|
source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),
|
|
275
307
|
dashPattern: copyOpt(src.dashPattern, (a) => [...a]),
|
|
276
308
|
fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),
|
|
309
|
+
...copyTextLengths(src),
|
|
277
310
|
fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),
|
|
278
311
|
textParagraphs: copyOpt(src.textParagraphs, (a) => a.map((v) => ({ ...v }))),
|
|
279
312
|
textDecorationFills: copyOpt(src.textDecorationFills, copyFills),
|
|
@@ -289,6 +322,8 @@ export function cloneNodeProps(
|
|
|
289
322
|
pluginData: copySpread(src.pluginData),
|
|
290
323
|
pluginRelaunchData: copySpread(src.pluginRelaunchData),
|
|
291
324
|
exportSettings: copySpread(src.exportSettings),
|
|
325
|
+
// Generated instance descendants have no status of their own.
|
|
326
|
+
status: componentId === null ? src.status : null,
|
|
292
327
|
componentPropertyValues: { ...src.componentPropertyValues },
|
|
293
328
|
derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : null,
|
|
294
329
|
arcData: src.arcData ? copyArcData(src.arcData) : null,
|
|
@@ -300,6 +335,11 @@ export function cloneNodeProps(
|
|
|
300
335
|
textPathData: src.textPathData ? structuredClone(src.textPathData) : null,
|
|
301
336
|
textPathBox: src.textPathBox ? { ...src.textPathBox } : null,
|
|
302
337
|
gridPosition: src.gridPosition ? { ...src.gridPosition } : null,
|
|
303
|
-
targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null
|
|
338
|
+
targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,
|
|
339
|
+
connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,
|
|
340
|
+
connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,
|
|
341
|
+
connectorControlPoints: structuredClone(src.connectorControlPoints),
|
|
342
|
+
connectorCurveHandles: structuredClone(src.connectorCurveHandles),
|
|
343
|
+
connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null
|
|
304
344
|
}
|
|
305
345
|
}
|
package/src/css/blend.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BlendMode } from '../types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Each blend mode as CSS names it, for `mix-blend-mode` and `background-blend-mode`. Linear
|
|
5
|
+
* burn and linear dodge are the `plus-` modes, which `mix-blend-mode` takes and
|
|
6
|
+
* `background-blend-mode` does not.
|
|
7
|
+
*/
|
|
8
|
+
export const CSS_BLEND_MODE: Partial<Record<BlendMode, string>> = {
|
|
9
|
+
NORMAL: 'normal',
|
|
10
|
+
DARKEN: 'darken',
|
|
11
|
+
MULTIPLY: 'multiply',
|
|
12
|
+
COLOR_BURN: 'color-burn',
|
|
13
|
+
LIGHTEN: 'lighten',
|
|
14
|
+
LINEAR_BURN: 'plus-darker',
|
|
15
|
+
SCREEN: 'screen',
|
|
16
|
+
LINEAR_DODGE: 'plus-lighter',
|
|
17
|
+
COLOR_DODGE: 'color-dodge',
|
|
18
|
+
OVERLAY: 'overlay',
|
|
19
|
+
SOFT_LIGHT: 'soft-light',
|
|
20
|
+
HARD_LIGHT: 'hard-light',
|
|
21
|
+
DIFFERENCE: 'difference',
|
|
22
|
+
EXCLUSION: 'exclusion',
|
|
23
|
+
HUE: 'hue',
|
|
24
|
+
SATURATION: 'saturation',
|
|
25
|
+
COLOR: 'color',
|
|
26
|
+
LUMINOSITY: 'luminosity'
|
|
27
|
+
}
|
package/src/css/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { CSS_BLEND_MODE } from './blend'
|
|
1
2
|
export { parseCSSGridTracks } from './grid'
|
|
2
3
|
export {
|
|
3
4
|
parseCSSAlignItems,
|
|
@@ -6,4 +7,5 @@ export {
|
|
|
6
7
|
parseCSSJustifyContent
|
|
7
8
|
} from './layout'
|
|
8
9
|
export { parseCSSShadows } from './shadows'
|
|
10
|
+
export { parseCSSFontFamily, parseCSSLetterSpacing, parseCSSLineHeight } from './text'
|
|
9
11
|
export { parseCSSColor, parseCSSNumber, splitCSSValue } from './values'
|
package/src/css/text.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import valueParser from 'postcss-value-parser'
|
|
2
|
+
|
|
3
|
+
import { percentLength, pixelLength } from '../text/lengths'
|
|
4
|
+
import type { TextLength } from '../types'
|
|
5
|
+
import { parseCSSNumber } from './values'
|
|
6
|
+
|
|
7
|
+
/** A CSS escape: hex digits and one optional whitespace, an escaped line break, or any one character. */
|
|
8
|
+
const CSS_ESCAPE = /\\(?:([0-9a-fA-F]{1,6})(?:\r\n|[ \t\n\r\f])?|(?:\r\n|[\n\r\f])|([\s\S]))?/gu
|
|
9
|
+
|
|
10
|
+
/** The largest Unicode code point. */
|
|
11
|
+
const MAX_CODE_POINT = 0x10ffff
|
|
12
|
+
|
|
13
|
+
/** Text with its CSS escapes decoded; an escaped line break continues the line. */
|
|
14
|
+
function decodeCSSEscapes(text: string): string {
|
|
15
|
+
return text.replace(CSS_ESCAPE, (_escape, hex: string | undefined, char: string | undefined) => {
|
|
16
|
+
if (hex === undefined) return char ?? ''
|
|
17
|
+
const codePoint = Number.parseInt(hex, 16)
|
|
18
|
+
const surrogate = codePoint >= 0xd800 && codePoint <= 0xdfff
|
|
19
|
+
return codePoint === 0 || surrogate || codePoint > MAX_CODE_POINT
|
|
20
|
+
? '\uFFFD'
|
|
21
|
+
: String.fromCodePoint(codePoint)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The index of the first unescaped `stop` character from `from`, or the text's length. */
|
|
26
|
+
function unescapedIndexOf(text: string, stop: string, from: number): number {
|
|
27
|
+
let index = from
|
|
28
|
+
while (index < text.length && text[index] !== stop) index += text[index] === '\\' ? 2 : 1
|
|
29
|
+
return index
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The first family of a CSS `font-family` list, without its quotes and escapes. A family is a quoted
|
|
34
|
+
* string or unquoted words, which join with single spaces; a quote opens a string only at the start
|
|
35
|
+
* of the family, so a name list such as draw.io's keeps `O'Reilly`. Null for an empty list.
|
|
36
|
+
*/
|
|
37
|
+
export function parseCSSFontFamily(value: string | undefined): string | null {
|
|
38
|
+
const text = value?.trimStart()
|
|
39
|
+
if (!text) return null
|
|
40
|
+
const quote = text[0]
|
|
41
|
+
if (quote === '"' || quote === "'") {
|
|
42
|
+
return decodeCSSEscapes(text.slice(1, unescapedIndexOf(text, quote, 1))) || null
|
|
43
|
+
}
|
|
44
|
+
const words = decodeCSSEscapes(text.slice(0, unescapedIndexOf(text, ',', 0)))
|
|
45
|
+
return words.trim().replace(/\s+/gu, ' ') || null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A CSS dimension's number and lowercase unit, or null. */
|
|
49
|
+
function dimension(value: string): { number: number; unit: string } | null {
|
|
50
|
+
const parsed = valueParser.unit(value)
|
|
51
|
+
if (!parsed) return null
|
|
52
|
+
const number = Number(parsed.number)
|
|
53
|
+
return Number.isFinite(number) ? { number, unit: parsed.unit.toLowerCase() } : null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A CSS `line-height` as a text length: a unitless multiple, `em`, or a percent follows the font size,
|
|
58
|
+
* as a percent does in Figma; pixels stay pixels; `normal` is automatic, a null. Undefined for a
|
|
59
|
+
* value it cannot read.
|
|
60
|
+
*/
|
|
61
|
+
export function parseCSSLineHeight(value: string | undefined): TextLength | null | undefined {
|
|
62
|
+
const trimmed = value?.trim()
|
|
63
|
+
if (!trimmed) return undefined
|
|
64
|
+
if (trimmed === 'normal') return null
|
|
65
|
+
const parsed = dimension(trimmed)
|
|
66
|
+
if (parsed?.unit === '' || parsed?.unit === 'em') return percentLength(parsed.number * 100)
|
|
67
|
+
if (parsed?.unit === '%') return percentLength(parsed.number)
|
|
68
|
+
const pixels = parseCSSNumber(trimmed)
|
|
69
|
+
return pixels === null ? undefined : pixelLength(pixels)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A CSS `letter-spacing` as a text length: `em` is a percent of the font size, pixels stay pixels,
|
|
74
|
+
* and `normal` is none. Undefined for a value it cannot read.
|
|
75
|
+
*/
|
|
76
|
+
export function parseCSSLetterSpacing(value: string | undefined): TextLength | undefined {
|
|
77
|
+
const trimmed = value?.trim()
|
|
78
|
+
if (!trimmed) return undefined
|
|
79
|
+
if (trimmed === 'normal') return pixelLength(0)
|
|
80
|
+
const parsed = dimension(trimmed)
|
|
81
|
+
if (parsed?.unit === 'em') return percentLength(parsed.number * 100)
|
|
82
|
+
const pixels = parseCSSNumber(trimmed)
|
|
83
|
+
return pixels === null ? undefined : pixelLength(pixels)
|
|
84
|
+
}
|
package/src/cubic.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Vector } from './primitives'
|
|
2
|
+
|
|
3
|
+
/** The point at `t` along the cubic from `p0` to `p3` with control points `p1` and `p2`. */
|
|
4
|
+
export function cubicPoint(p0: Vector, p1: Vector, p2: Vector, p3: Vector, t: number): Vector {
|
|
5
|
+
const u = 1 - t
|
|
6
|
+
const a = u * u * u
|
|
7
|
+
const b = 3 * u * u * t
|
|
8
|
+
const c = 3 * u * t * t
|
|
9
|
+
const d = t * t * t
|
|
10
|
+
return {
|
|
11
|
+
x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
|
|
12
|
+
y: a * p0.y + b * p1.y + c * p2.y + d * p3.y
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/export-format.ts
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
|
+
import { omitBy } from 'es-toolkit/object'
|
|
2
|
+
|
|
3
|
+
import type { ExportSetting } from './types'
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Formats a node's export settings may persist. Each id must name a Core IO
|
|
3
7
|
* export adapter that supports node export; labels and options come from that
|
|
4
8
|
* adapter, so this list only decides what the Export panel offers.
|
|
5
9
|
*/
|
|
6
|
-
export const EXPORT_FORMAT_IDS = ['png', 'jpg', 'webp', 'svg', 'pdf', 'pptx'] as const
|
|
10
|
+
export const EXPORT_FORMAT_IDS = ['png', 'jpg', 'webp', 'svg', 'pdf', 'pptx', 'drawio'] as const
|
|
7
11
|
|
|
8
12
|
export type ExportFormatId = (typeof EXPORT_FORMAT_IDS)[number]
|
|
9
13
|
|
|
10
14
|
export function isExportFormatId(value: unknown): value is ExportFormatId {
|
|
11
15
|
return EXPORT_FORMAT_IDS.some((id) => id === value)
|
|
12
16
|
}
|
|
17
|
+
|
|
18
|
+
/** What each of Figma's export options reads as when an export leaves it out. */
|
|
19
|
+
export const EXPORT_OPTION_DEFAULTS = {
|
|
20
|
+
suffix: '',
|
|
21
|
+
contentsOnly: true,
|
|
22
|
+
useAbsoluteBounds: false,
|
|
23
|
+
colorProfile: 'DOCUMENT',
|
|
24
|
+
svgOutlineText: true,
|
|
25
|
+
svgIdAttribute: false,
|
|
26
|
+
svgSimplifyStroke: true
|
|
27
|
+
} as const satisfies Required<Omit<ExportSetting, 'scale' | 'format' | 'size'>>
|
|
28
|
+
|
|
29
|
+
/** An export as the model keeps it: options that are unset or at Figma's default left out. */
|
|
30
|
+
export function compactExportSetting({
|
|
31
|
+
scale,
|
|
32
|
+
format,
|
|
33
|
+
size,
|
|
34
|
+
...options
|
|
35
|
+
}: ExportSetting): ExportSetting {
|
|
36
|
+
const changed = omitBy(
|
|
37
|
+
options,
|
|
38
|
+
(value, key) => value === undefined || value === EXPORT_OPTION_DEFAULTS[key]
|
|
39
|
+
)
|
|
40
|
+
return size ? { scale, format, size, ...changed } : { scale, format, ...changed }
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SceneNode } from '../types'
|
|
2
|
+
|
|
3
|
+
/** What a layer is painted with, and how it blends. */
|
|
4
|
+
export const PAINT_FIELDS = [
|
|
5
|
+
'fills',
|
|
6
|
+
'strokes',
|
|
7
|
+
'effects',
|
|
8
|
+
'opacity',
|
|
9
|
+
'blendMode'
|
|
10
|
+
] as const satisfies readonly (keyof SceneNode)[]
|
|
11
|
+
|
|
12
|
+
/** How strokes are drawn, beside their paints. */
|
|
13
|
+
export const STROKE_FIELDS = [
|
|
14
|
+
'strokeWeight',
|
|
15
|
+
'strokeAlign',
|
|
16
|
+
'strokeCap',
|
|
17
|
+
'strokeJoin',
|
|
18
|
+
'strokeMiterLimit',
|
|
19
|
+
'dashPattern',
|
|
20
|
+
'independentStrokeWeights',
|
|
21
|
+
'borderTopWeight',
|
|
22
|
+
'borderRightWeight',
|
|
23
|
+
'borderBottomWeight',
|
|
24
|
+
'borderLeftWeight'
|
|
25
|
+
] as const satisfies readonly (keyof SceneNode)[]
|
|
26
|
+
|
|
27
|
+
export const CORNER_FIELDS = [
|
|
28
|
+
'cornerRadius',
|
|
29
|
+
'topLeftRadius',
|
|
30
|
+
'topRightRadius',
|
|
31
|
+
'bottomRightRadius',
|
|
32
|
+
'bottomLeftRadius',
|
|
33
|
+
'independentCorners',
|
|
34
|
+
'cornerSmoothing'
|
|
35
|
+
] as const satisfies readonly (keyof SceneNode)[]
|