@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
package/src/variables/token.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { omit } from 'es-toolkit/object'
|
|
2
|
+
import { isEmptyObject } from 'es-toolkit/predicate'
|
|
3
|
+
|
|
4
|
+
import type { TokenExpression, TokenUnit, Variable, VariableValue } from '../types'
|
|
2
5
|
|
|
3
6
|
/** `rem` tokens are stored in canvas pixels and shown against this root font size. */
|
|
4
7
|
export const ROOT_FONT_SIZE_PX = 16
|
|
@@ -12,3 +15,26 @@ export function tokenNumberFromUnit(value: number, unit: TokenUnit): number {
|
|
|
12
15
|
export function tokenNumberInUnit(value: number, unit: TokenUnit): number {
|
|
13
16
|
return unit === 'rem' ? value / ROOT_FONT_SIZE_PX : value
|
|
14
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A CSS expression outlives edits to its mode's value, whatever the value becomes; it records the
|
|
21
|
+
* value only while that is a plain number.
|
|
22
|
+
*/
|
|
23
|
+
export function tokenExpressionForValue(
|
|
24
|
+
expression: TokenExpression | undefined,
|
|
25
|
+
value: VariableValue
|
|
26
|
+
): TokenExpression | undefined {
|
|
27
|
+
if (!expression) return undefined
|
|
28
|
+
return typeof value === 'number'
|
|
29
|
+
? { css: expression.css, resolved: value }
|
|
30
|
+
: { css: expression.css }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Keep a variable's CSS expression for one mode in step with that mode's new value. */
|
|
34
|
+
export function updateTokenExpression(variable: Variable, modeId: string, value: VariableValue) {
|
|
35
|
+
const expression = tokenExpressionForValue(variable.expressions?.[modeId], value)
|
|
36
|
+
const others = omit(variable.expressions ?? {}, [modeId])
|
|
37
|
+
const expressions = expression ? { ...others, [modeId]: expression } : others
|
|
38
|
+
if (isEmptyObject(expressions)) delete variable.expressions
|
|
39
|
+
else variable.expressions = expressions
|
|
40
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { compact } from 'es-toolkit/array'
|
|
2
|
+
import * as v from 'valibot'
|
|
3
|
+
|
|
4
|
+
import type { VariableLiteral, VariableValue, VariableUnsupportedExpression } from '../types'
|
|
5
|
+
import { formulaValueType } from './formula/check'
|
|
6
|
+
import { evaluateVariableFormula } from './formula/evaluate'
|
|
7
|
+
import { mapFormulaReferences, VariableFormulaError } from './formula/tree'
|
|
8
|
+
import { variableColorExpressionSchema } from './schema'
|
|
9
|
+
|
|
10
|
+
export function isUnsupportedVariableValue(
|
|
11
|
+
value: VariableValue | undefined
|
|
12
|
+
): value is VariableUnsupportedExpression {
|
|
13
|
+
return typeof value === 'object' && 'expression' in value && value.expression === 'UNSUPPORTED'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** All references in one definition, including color and opacity operands. */
|
|
17
|
+
export function variableValueReferences(value: VariableValue): string[] {
|
|
18
|
+
if (isUnsupportedVariableValue(value)) return compact(value.references)
|
|
19
|
+
if (typeof value !== 'object') return []
|
|
20
|
+
if ('aliasId' in value) return [value.aliasId]
|
|
21
|
+
if ('expression' in value && value.expression === 'FORMULA') {
|
|
22
|
+
const references: string[] = []
|
|
23
|
+
mapFormulaReferences(value.value, (id) => {
|
|
24
|
+
references.push(id)
|
|
25
|
+
return id
|
|
26
|
+
})
|
|
27
|
+
return references
|
|
28
|
+
}
|
|
29
|
+
if ('expression' in value)
|
|
30
|
+
return [...variableValueReferences(value.color), ...variableValueReferences(value.opacity)]
|
|
31
|
+
return []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Clone a value while remapping its references for transfer to another document. */
|
|
35
|
+
export function mapVariableValueReferences(
|
|
36
|
+
value: VariableValue,
|
|
37
|
+
map: (id: string) => string,
|
|
38
|
+
mapMode: (id: string) => string = (id) => id
|
|
39
|
+
): VariableValue {
|
|
40
|
+
if (isUnsupportedVariableValue(value))
|
|
41
|
+
return {
|
|
42
|
+
...structuredClone(value),
|
|
43
|
+
references: value.references.map((id) => (id === null ? null : map(id))),
|
|
44
|
+
modes: value.modes.map(mapMode)
|
|
45
|
+
}
|
|
46
|
+
if (typeof value !== 'object') return value
|
|
47
|
+
if ('aliasId' in value) return { aliasId: map(value.aliasId) }
|
|
48
|
+
if ('expression' in value && value.expression === 'FORMULA')
|
|
49
|
+
return { ...value, value: mapFormulaReferences(value.value, map) }
|
|
50
|
+
if ('expression' in value)
|
|
51
|
+
return {
|
|
52
|
+
expression: value.expression,
|
|
53
|
+
color: 'aliasId' in value.color ? { aliasId: map(value.color.aliasId) } : { ...value.color },
|
|
54
|
+
opacity:
|
|
55
|
+
typeof value.opacity === 'object' ? { aliasId: map(value.opacity.aliasId) } : value.opacity
|
|
56
|
+
}
|
|
57
|
+
return { ...value }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Resolve operands through the caller's mode context; formula failures retain their diagnostics for the caller. */
|
|
61
|
+
export function resolveVariableValue(
|
|
62
|
+
value: VariableValue,
|
|
63
|
+
resolve: (id: string) => VariableLiteral | undefined
|
|
64
|
+
): VariableLiteral | undefined {
|
|
65
|
+
if (isUnsupportedVariableValue(value)) return undefined
|
|
66
|
+
if (typeof value !== 'object') return value
|
|
67
|
+
if ('aliasId' in value) return resolve(value.aliasId)
|
|
68
|
+
if (!('expression' in value)) return value
|
|
69
|
+
if (value.expression === 'FORMULA') {
|
|
70
|
+
// Evaluation checks every node it visits, so drawing never walks the tree twice; files are
|
|
71
|
+
// checked against the full schema where they are read.
|
|
72
|
+
const result = evaluateVariableFormula(value.value, resolve)
|
|
73
|
+
if (formulaValueType(result) !== value.type)
|
|
74
|
+
throw new VariableFormulaError('Wrong formula result type')
|
|
75
|
+
return result
|
|
76
|
+
}
|
|
77
|
+
const expression = v.parse(variableColorExpressionSchema, value)
|
|
78
|
+
const color = 'aliasId' in expression.color ? resolve(expression.color.aliasId) : expression.color
|
|
79
|
+
const opacity =
|
|
80
|
+
typeof expression.opacity === 'object'
|
|
81
|
+
? resolve(expression.opacity.aliasId)
|
|
82
|
+
: expression.opacity
|
|
83
|
+
if (
|
|
84
|
+
!color ||
|
|
85
|
+
typeof color !== 'object' ||
|
|
86
|
+
!Object.values(color).every(Number.isFinite) ||
|
|
87
|
+
typeof opacity !== 'number' ||
|
|
88
|
+
!Number.isFinite(opacity)
|
|
89
|
+
)
|
|
90
|
+
return undefined
|
|
91
|
+
return { ...color, a: Math.min(1, Math.max(0, opacity / 100)) }
|
|
92
|
+
}
|
package/src/vector-network.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { isEqual } from 'es-toolkit/predicate'
|
|
2
2
|
|
|
3
|
+
import { cloneVectorNetwork, copyVectorRegion } from './copy'
|
|
3
4
|
import type { Mat3 } from './matrix'
|
|
5
|
+
import type { VectorPathWindingRule } from './parse-path'
|
|
4
6
|
import type { Vector } from './primitives'
|
|
5
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
Fill,
|
|
9
|
+
GeometryPath,
|
|
10
|
+
SceneNode,
|
|
11
|
+
VectorNetwork,
|
|
12
|
+
VectorSegment,
|
|
13
|
+
VectorVertex
|
|
14
|
+
} from './types'
|
|
6
15
|
|
|
7
16
|
/** Concatenate vector networks while preserving independent geometry. */
|
|
8
17
|
export function mergeVectorNetworks(networks: readonly VectorNetwork[]): VectorNetwork {
|
|
@@ -30,7 +39,7 @@ export function mergeVectorNetworks(networks: readonly VectorNetwork[]): VectorN
|
|
|
30
39
|
for (const segmentIndex of loop) shifted.push(segmentIndex + segmentOffset)
|
|
31
40
|
loops.push(shifted)
|
|
32
41
|
}
|
|
33
|
-
regions.push(
|
|
42
|
+
regions.push(copyVectorRegion(region, loops))
|
|
34
43
|
}
|
|
35
44
|
vertexOffset += network.vertices.length
|
|
36
45
|
segmentOffset += network.segments.length
|
|
@@ -60,13 +69,66 @@ export function transformVectorNetwork(m: Mat3, vn: VectorNetwork): VectorNetwor
|
|
|
60
69
|
tangentStart: mapVector(s.tangentStart),
|
|
61
70
|
tangentEnd: mapVector(s.tangentEnd)
|
|
62
71
|
})),
|
|
63
|
-
regions: vn.regions.map((r) => (
|
|
64
|
-
windingRule: r.windingRule,
|
|
65
|
-
loops: r.loops.map((l) => [...l])
|
|
66
|
-
}))
|
|
72
|
+
regions: vn.regions.map((r) => copyVectorRegion(r))
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
/** Whether any region has paints of its own, which it draws instead of the layer's fills. */
|
|
77
|
+
export function hasRegionFills(network: VectorNetwork | null): boolean {
|
|
78
|
+
return network?.regions.some((region) => region.fills !== undefined) ?? false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether fill geometry is the regions' outlines, one each, as a file or an edit writes it. A
|
|
83
|
+
* pasted vector has none, and an import skips empty outlines; their regions draw traced.
|
|
84
|
+
*/
|
|
85
|
+
export function fillGeometryMatchesRegions(
|
|
86
|
+
fillGeometry: readonly GeometryPath[],
|
|
87
|
+
network: VectorNetwork
|
|
88
|
+
): boolean {
|
|
89
|
+
return fillGeometry.length === network.regions.length
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether a vector's regions draw different fills, each its own or else the layer's, which Figma
|
|
94
|
+
* reads as mixed (live-verified: regions with equal fills of their own read the layer's).
|
|
95
|
+
*/
|
|
96
|
+
export function regionFillsDiffer(
|
|
97
|
+
network: VectorNetwork | null,
|
|
98
|
+
layerFills: readonly Fill[]
|
|
99
|
+
): boolean {
|
|
100
|
+
const [first, ...rest] = (network?.regions ?? []).map((region) => region.fills ?? layerFills)
|
|
101
|
+
return rest.some((fills) => !isEqual(fills, first))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The network with every region drawing the layer's fills. */
|
|
105
|
+
function withoutRegionFills(network: VectorNetwork): VectorNetwork {
|
|
106
|
+
const copy = cloneVectorNetwork(network)
|
|
107
|
+
return {
|
|
108
|
+
...copy,
|
|
109
|
+
regions: copy.regions.map(({ windingRule, loops }) => ({ windingRule, loops }))
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* What else an edit that sets a vector's fills changes: every region draws them, its own paints
|
|
115
|
+
* and style dropped, as setting fills does in Figma (live-verified). Edit entry points apply it.
|
|
116
|
+
*/
|
|
117
|
+
export function regionFillChanges(
|
|
118
|
+
node: SceneNode,
|
|
119
|
+
changes: Partial<SceneNode>
|
|
120
|
+
): Pick<Partial<SceneNode>, 'vectorNetwork'> {
|
|
121
|
+
const network = node.type === 'VECTOR' ? node.vectorNetwork : null
|
|
122
|
+
if (!('fills' in changes) || 'vectorNetwork' in changes || !network) return {}
|
|
123
|
+
const ownFills = network.regions.some((region) => region.fills || region.fillStyleId)
|
|
124
|
+
return ownFills ? { vectorNetwork: withoutRegionFills(network) } : {}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The paints regions carry of their own. */
|
|
128
|
+
export function regionFills(network: VectorNetwork | null): Fill[] {
|
|
129
|
+
return network?.regions.flatMap((region) => region.fills ?? []) ?? []
|
|
130
|
+
}
|
|
131
|
+
|
|
70
132
|
/** Structural equality of two VectorNetworks (order-sensitive, exact values). */
|
|
71
133
|
export function vectorNetworksEqual(a: VectorNetwork, b: VectorNetwork): boolean {
|
|
72
134
|
return (
|
|
@@ -76,22 +138,6 @@ export function vectorNetworksEqual(a: VectorNetwork, b: VectorNetwork): boolean
|
|
|
76
138
|
)
|
|
77
139
|
}
|
|
78
140
|
|
|
79
|
-
/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
|
|
80
|
-
export function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork {
|
|
81
|
-
return {
|
|
82
|
-
vertices: vn.vertices.map((v) => ({ ...v })),
|
|
83
|
-
segments: vn.segments.map((s) => ({
|
|
84
|
-
...s,
|
|
85
|
-
tangentStart: { ...s.tangentStart },
|
|
86
|
-
tangentEnd: { ...s.tangentEnd }
|
|
87
|
-
})),
|
|
88
|
-
regions: vn.regions.map((r) => ({
|
|
89
|
-
windingRule: r.windingRule,
|
|
90
|
-
loops: r.loops.map((l) => [...l])
|
|
91
|
-
}))
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
141
|
/**
|
|
96
142
|
* Validate a VectorNetwork structure, returning an array of error messages.
|
|
97
143
|
* Empty array means the network is valid.
|
|
@@ -291,3 +337,198 @@ export function normalizeVectorNetwork(vn: NormalizableVectorNetwork): VectorNet
|
|
|
291
337
|
regions: vn.regions ?? []
|
|
292
338
|
}
|
|
293
339
|
}
|
|
340
|
+
|
|
341
|
+
function coordinate(value: number, decimals: number | null): number {
|
|
342
|
+
if (decimals === null) return value
|
|
343
|
+
const factor = 10 ** decimals
|
|
344
|
+
return Math.round(value * factor) / factor
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function segmentToSVG(
|
|
348
|
+
seg: VectorSegment,
|
|
349
|
+
vertices: VectorVertex[],
|
|
350
|
+
forward: boolean,
|
|
351
|
+
decimals: number | null
|
|
352
|
+
): string {
|
|
353
|
+
const start = forward ? vertices[seg.start] : vertices[seg.end]
|
|
354
|
+
const end = forward ? vertices[seg.end] : vertices[seg.start]
|
|
355
|
+
const ts = forward ? seg.tangentStart : { x: -seg.tangentEnd.x, y: -seg.tangentEnd.y }
|
|
356
|
+
const te = forward ? seg.tangentEnd : { x: -seg.tangentStart.x, y: -seg.tangentStart.y }
|
|
357
|
+
|
|
358
|
+
const isStraight =
|
|
359
|
+
Math.abs(ts.x) < 0.001 &&
|
|
360
|
+
Math.abs(ts.y) < 0.001 &&
|
|
361
|
+
Math.abs(te.x) < 0.001 &&
|
|
362
|
+
Math.abs(te.y) < 0.001
|
|
363
|
+
|
|
364
|
+
if (isStraight) {
|
|
365
|
+
return `L${coordinate(end.x, decimals)} ${coordinate(end.y, decimals)}`
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const cp1x = coordinate(start.x + ts.x, decimals)
|
|
369
|
+
const cp1y = coordinate(start.y + ts.y, decimals)
|
|
370
|
+
const cp2x = coordinate(end.x + te.x, decimals)
|
|
371
|
+
const cp2y = coordinate(end.y + te.y, decimals)
|
|
372
|
+
return `C${cp1x} ${cp1y} ${cp2x} ${cp2y} ${coordinate(end.x, decimals)} ${coordinate(end.y, decimals)}`
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function traceOrderedSegments(
|
|
376
|
+
segmentIndices: readonly number[],
|
|
377
|
+
segments: VectorSegment[],
|
|
378
|
+
vertices: VectorVertex[],
|
|
379
|
+
decimals: number | null
|
|
380
|
+
): string {
|
|
381
|
+
if (segmentIndices.length === 0) return ''
|
|
382
|
+
const first = segments[segmentIndices[0]]
|
|
383
|
+
const second = segmentIndices.length > 1 ? segments[segmentIndices[1]] : null
|
|
384
|
+
// Start at the first segment endpoint that does not connect to the second segment.
|
|
385
|
+
const secondConnectsStart = second?.start === first.start || second?.end === first.start
|
|
386
|
+
const secondConnectsEnd = second?.start === first.end || second?.end === first.end
|
|
387
|
+
const firstForward = !second || secondConnectsEnd || !secondConnectsStart
|
|
388
|
+
const startIndex = firstForward ? first.start : first.end
|
|
389
|
+
let currentIndex = startIndex
|
|
390
|
+
const parts = [
|
|
391
|
+
`M${coordinate(vertices[startIndex].x, decimals)} ${coordinate(vertices[startIndex].y, decimals)}`
|
|
392
|
+
]
|
|
393
|
+
|
|
394
|
+
for (const segmentIndex of segmentIndices) {
|
|
395
|
+
const segment = segments[segmentIndex]
|
|
396
|
+
const isConnected = segment.start === currentIndex || segment.end === currentIndex
|
|
397
|
+
const forward = segment.start === currentIndex || !isConnected
|
|
398
|
+
if (!isConnected) {
|
|
399
|
+
const segmentStart = forward ? segment.start : segment.end
|
|
400
|
+
parts.push(
|
|
401
|
+
`M${coordinate(vertices[segmentStart].x, decimals)} ${coordinate(vertices[segmentStart].y, decimals)}`
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
parts.push(segmentToSVG(segment, vertices, forward, decimals))
|
|
405
|
+
currentIndex = forward ? segment.end : segment.start
|
|
406
|
+
}
|
|
407
|
+
if (parts.length === segmentIndices.length + 1 && currentIndex === startIndex) parts.push('Z')
|
|
408
|
+
return parts.join('')
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
type SegmentAdjacency = ReadonlyMap<number, readonly number[]>
|
|
412
|
+
|
|
413
|
+
function buildSegmentAdjacency(segments: VectorSegment[]): SegmentAdjacency {
|
|
414
|
+
const adjacency = new Map<number, number[]>()
|
|
415
|
+
for (let index = 0; index < segments.length; index++) {
|
|
416
|
+
const segment = segments[index]
|
|
417
|
+
for (const vertexIndex of [segment.start, segment.end]) {
|
|
418
|
+
const incidentSegments = adjacency.get(vertexIndex)
|
|
419
|
+
if (incidentSegments) incidentSegments.push(index)
|
|
420
|
+
else adjacency.set(vertexIndex, [index])
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return adjacency
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function findConnectedSegment(
|
|
427
|
+
remaining: ReadonlySet<number>,
|
|
428
|
+
adjacency: SegmentAdjacency,
|
|
429
|
+
vertexIndex: number
|
|
430
|
+
): number | undefined {
|
|
431
|
+
return adjacency.get(vertexIndex)?.find((index) => remaining.has(index))
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function extendSegmentChain(
|
|
435
|
+
chain: number[],
|
|
436
|
+
startVertex: number,
|
|
437
|
+
remaining: Set<number>,
|
|
438
|
+
segments: VectorSegment[],
|
|
439
|
+
adjacency: SegmentAdjacency
|
|
440
|
+
): void {
|
|
441
|
+
let currentIndex = startVertex
|
|
442
|
+
let nextIndex = findConnectedSegment(remaining, adjacency, currentIndex)
|
|
443
|
+
while (nextIndex !== undefined) {
|
|
444
|
+
chain.push(nextIndex)
|
|
445
|
+
remaining.delete(nextIndex)
|
|
446
|
+
const segment = segments[nextIndex]
|
|
447
|
+
currentIndex = segment.start === currentIndex ? segment.end : segment.start
|
|
448
|
+
nextIndex = findConnectedSegment(remaining, adjacency, currentIndex)
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function unfilledSegmentsToPath(network: VectorNetwork, decimals: number | null): string {
|
|
453
|
+
const { vertices, segments } = network
|
|
454
|
+
const remaining = new Set(segments.map((_, index) => index))
|
|
455
|
+
const adjacency = buildSegmentAdjacency(segments)
|
|
456
|
+
const parts: string[] = []
|
|
457
|
+
|
|
458
|
+
while (remaining.size > 0) {
|
|
459
|
+
const firstIndex = remaining.values().next().value
|
|
460
|
+
if (firstIndex === undefined) break
|
|
461
|
+
remaining.delete(firstIndex)
|
|
462
|
+
const first = segments[firstIndex]
|
|
463
|
+
|
|
464
|
+
const backward: number[] = []
|
|
465
|
+
extendSegmentChain(backward, first.start, remaining, segments, adjacency)
|
|
466
|
+
backward.reverse()
|
|
467
|
+
|
|
468
|
+
const forward: number[] = []
|
|
469
|
+
extendSegmentChain(forward, first.end, remaining, segments, adjacency)
|
|
470
|
+
|
|
471
|
+
parts.push(
|
|
472
|
+
traceOrderedSegments([...backward, firstIndex, ...forward], segments, vertices, decimals)
|
|
473
|
+
)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return parts.join('')
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export function vectorNetworkToSVGPaths(
|
|
480
|
+
network: VectorNetwork,
|
|
481
|
+
decimals: number | null = 2
|
|
482
|
+
): string[] {
|
|
483
|
+
const { vertices, regions } = network
|
|
484
|
+
|
|
485
|
+
if (regions.length === 0) {
|
|
486
|
+
const path = unfilledSegmentsToPath(network, decimals)
|
|
487
|
+
return path ? [path] : []
|
|
488
|
+
}
|
|
489
|
+
const paths = regionSVGPaths(network, decimals)
|
|
490
|
+
// Segments no region encloses, such as an icon's open strokes beside its filled shapes,
|
|
491
|
+
// draw as open paths after the regions.
|
|
492
|
+
const open = looseSegments(network)
|
|
493
|
+
const loose =
|
|
494
|
+
open.length > 0 && unfilledSegmentsToPath({ vertices, segments: open, regions: [] }, decimals)
|
|
495
|
+
return loose ? [...paths, loose] : paths
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** Each region of a vector network as path data, its loops traced in turn. */
|
|
499
|
+
export function regionSVGPaths(network: VectorNetwork, decimals: number | null = 2): string[] {
|
|
500
|
+
const { vertices, segments, regions } = network
|
|
501
|
+
return regions.map((region) =>
|
|
502
|
+
region.loops.map((loop) => traceOrderedSegments(loop, segments, vertices, decimals)).join('')
|
|
503
|
+
)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** The segments of a vector network that no region encloses. */
|
|
507
|
+
export function looseSegments({ segments, regions }: VectorNetwork): VectorNetwork['segments'] {
|
|
508
|
+
const enclosed = new Set(regions.flatMap((region) => region.loops.flat()))
|
|
509
|
+
return segments.filter((_, index) => !enclosed.has(index))
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** A path of a vector network as Figma's `vectorPaths` gives it. */
|
|
513
|
+
export interface VectorPath {
|
|
514
|
+
windingRule: VectorPathWindingRule
|
|
515
|
+
data: string
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* A vector network as Figma's `vectorPaths`: each region as a path with its winding rule, then
|
|
520
|
+
* the segments no region encloses as one open path, at full precision.
|
|
521
|
+
*/
|
|
522
|
+
export function vectorNetworkPaths(network: VectorNetwork): VectorPath[] {
|
|
523
|
+
if (network.segments.length === 0) return []
|
|
524
|
+
const paths: VectorPath[] = regionSVGPaths(network, null).flatMap((data, index) =>
|
|
525
|
+
data ? [{ windingRule: network.regions[index].windingRule, data }] : []
|
|
526
|
+
)
|
|
527
|
+
const open = looseSegments(network)
|
|
528
|
+
if (open.length === 0) return paths
|
|
529
|
+
const data = vectorNetworkToSVGPaths(
|
|
530
|
+
{ vertices: network.vertices, segments: open, regions: [] },
|
|
531
|
+
null
|
|
532
|
+
).join('')
|
|
533
|
+
return data ? [...paths, { windingRule: 'NONE', data }] : paths
|
|
534
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asset-keys.js","names":[],"sources":["../../src/asset-keys.ts"],"sourcesContent":["import { sha1 } from '@noble/hashes/legacy.js'\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js'\n\n/**\n * A key shaped as Figma's asset keys, 40 hex digits, derived from `seed` so the same seed always\n * gives the same key. The Figma clipboard names variables and collections by key; one made in\n * OpenPencil has none, so copying it gives it this one, and copying it again gives the same.\n */\nexport function derivedAssetKey(seed: string): string {\n return bytesToHex(sha1(utf8ToBytes(seed)))\n}\n\n/** Largest part of a Figma GUID, which Figma reads as a signed 32-bit integer. */\nconst MAX_GUID_PART = 0x7fffffff\n\n/**\n * A version shaped as Figma's asset versions, `session:local`, derived from `content` so that\n * copying an unchanged asset again gives the same version and copying a changed one gives another.\n * Figma keeps the first value it pasted for a key and version, so a version that stayed the same\n * across an edit would bring the old value back.\n */\nexport function derivedAssetVersion(content: string): string {\n const view = new DataView(sha1(utf8ToBytes(content)).buffer)\n return `${view.getUint32(0) & MAX_GUID_PART}:${view.getUint32(4) & MAX_GUID_PART}`\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,gBAAgB,MAAsB;CACpD,OAAO,WAAW,KAAK,YAAY,IAAI,CAAC,CAAC;AAC3C;;AAGA,MAAM,gBAAgB;;;;;;;AAQtB,SAAgB,oBAAoB,SAAyB;CAC3D,MAAM,OAAO,IAAI,SAAS,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM;CAC3D,OAAO,GAAG,KAAK,UAAU,CAAC,IAAI,cAAc,GAAG,KAAK,UAAU,CAAC,IAAI;AACrE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.js","names":[],"sources":["../../../src/behaviours/kinds.ts"],"sourcesContent":["/** The controls a main component can behave as, in the order the picker lists them. */\nexport const BEHAVIOUR_KINDS = [\n 'button',\n 'textField',\n 'textarea',\n 'numberField',\n 'toggle',\n 'switch',\n 'checkbox',\n 'radio',\n 'radioGroup',\n 'toggleGroup',\n 'slider',\n 'progress',\n 'tabs',\n 'collapsible',\n 'accordion'\n] as const\n\nexport type BehaviourKind = (typeof BEHAVIOUR_KINDS)[number]\n\n/**\n * The interaction states a control can show, each drawn as a value of one variant property:\n * at rest, under the pointer, while pressed, focused from the keyboard, and disabled.\n */\nexport const INTERACTION_STATES = ['rest', 'hover', 'pressed', 'focus', 'disabled'] as const\n\nexport type InteractionState = (typeof INTERACTION_STATES)[number]\n\n/**\n * How a behaviour value is held. A boolean is a variant or boolean property of the component,\n * and text is a text property. Figma has no number property, so a number is the behaviour's\n * own (min, max, step, default); a choice is which item of a slot is active, the first by\n * default.\n */\nexport type BehaviourValueType = 'boolean' | 'text' | 'number' | 'choice'\n\n/** A value of the control: its state, which preview reads and changes. */\nexport interface BehaviourValueContract {\n id: string\n type: BehaviourValueType\n /** Whether a boolean or text value must be bound before the behaviour is complete. */\n required: boolean\n}\n\n/**\n * A Reka UI subcomponent of the control, which is a slot of the component: the behaviour binds\n * it to one of the component's slot properties, never to a layer found by name.\n */\nexport interface BehaviourPartContract {\n id: string\n required: boolean\n /**\n * Whether the slot holds the control's items, each an instance with its own behaviour (a\n * radio, a toggle, a collapsible), which the control turns on and off.\n */\n items?: boolean\n /**\n * The Reka UI part each child of the slot is, when the slot holds repeated parts: a tab list's\n * triggers, the tabs' content panels, or a group's items.\n */\n children?: string\n}\n\nexport interface BehaviourContract {\n values: BehaviourValueContract[]\n parts: BehaviourPartContract[]\n}\n\n/**\n * A text field or textarea: its text is a text property, and `filled`, when bound, draws the\n * empty field with its placeholder.\n */\nconst TEXT_INPUT: BehaviourContract = {\n values: [\n { id: 'value', type: 'text', required: true },\n { id: 'filled', type: 'boolean', required: false },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: []\n}\n\n/**\n * The behaviours OpenPencil knows, after Reka UI's primitives. Their states are drawn as the\n * component's variants and properties; their subcomponents (thumb, range, trigger, …) are the\n * component's slots, and the component itself is the control's root.\n */\nexport const BEHAVIOUR_CONTRACTS: Readonly<Record<BehaviourKind, BehaviourContract>> = {\n button: {\n values: [{ id: 'disabled', type: 'boolean', required: false }],\n parts: []\n },\n textField: TEXT_INPUT,\n textarea: TEXT_INPUT,\n numberField: {\n values: [\n { id: 'value', type: 'number', required: false },\n { id: 'text', type: 'text', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [\n { id: 'increment', required: false },\n { id: 'decrement', required: false }\n ]\n },\n toggle: {\n values: [\n { id: 'value', type: 'boolean', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: []\n },\n switch: {\n values: [\n { id: 'value', type: 'boolean', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [{ id: 'thumb', required: false }]\n },\n checkbox: {\n values: [\n { id: 'value', type: 'boolean', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [{ id: 'indicator', required: false }]\n },\n radio: {\n values: [\n { id: 'value', type: 'boolean', required: true },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [{ id: 'indicator', required: false }]\n },\n radioGroup: {\n values: [{ id: 'disabled', type: 'boolean', required: false }],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n },\n toggleGroup: {\n values: [{ id: 'disabled', type: 'boolean', required: false }],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n },\n slider: {\n values: [\n { id: 'value', type: 'number', required: false },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [\n { id: 'track', required: true },\n { id: 'range', required: false },\n { id: 'thumb', required: true }\n ]\n },\n tabs: {\n values: [{ id: 'value', type: 'choice', required: false }],\n parts: [\n { id: 'list', required: true, children: 'trigger' },\n { id: 'panels', required: false, children: 'content' }\n ]\n },\n progress: {\n values: [{ id: 'value', type: 'number', required: false }],\n parts: [\n { id: 'track', required: true },\n { id: 'indicator', required: true }\n ]\n },\n collapsible: {\n values: [\n { id: 'open', type: 'boolean', required: false },\n { id: 'disabled', type: 'boolean', required: false }\n ],\n parts: [\n { id: 'trigger', required: true },\n { id: 'content', required: true }\n ]\n },\n accordion: {\n values: [{ id: 'disabled', type: 'boolean', required: false }],\n parts: [{ id: 'items', required: true, items: true, children: 'item' }]\n }\n}\n\nexport function behaviourContract(kind: BehaviourKind): BehaviourContract {\n return BEHAVIOUR_CONTRACTS[kind]\n}\n"],"mappings":";;AACA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAQA,MAAa,qBAAqB;CAAC;CAAQ;CAAS;CAAW;CAAS;AAAU;;;;;AAgDlF,MAAM,aAAgC;CACpC,QAAQ;EACN;GAAE,IAAI;GAAS,MAAM;GAAQ,UAAU;EAAK;EAC5C;GAAE,IAAI;GAAU,MAAM;GAAW,UAAU;EAAM;EACjD;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM;CACrD;CACA,OAAO,CAAC;AACV;;;;;;AAOA,MAAa,sBAA0E;CACrF,QAAQ;EACN,QAAQ,CAAC;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CAAC;EAC7D,OAAO,CAAC;CACV;CACA,WAAW;CACX,UAAU;CACV,aAAa;EACX,QAAQ;GACN;IAAE,IAAI;IAAS,MAAM;IAAU,UAAU;GAAM;GAC/C;IAAE,IAAI;IAAQ,MAAM;IAAQ,UAAU;GAAK;GAC3C;IAAE,IAAI;IAAY,MAAM;IAAW,UAAU;GAAM;EACrD;EACA,OAAO,CACL;GAAE,IAAI;GAAa,UAAU;EAAM,GACnC;GAAE,IAAI;GAAa,UAAU;EAAM,CACrC;CACF;CACA,QAAQ;EACN,QAAQ,CACN;GAAE,IAAI;GAAS,MAAM;GAAW,UAAU;EAAK,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO,CAAC;CACV;CACA,QAAQ;EACN,QAAQ,CACN;GAAE,IAAI;GAAS,MAAM;GAAW,UAAU;EAAK,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO,CAAC;GAAE,IAAI;GAAS,UAAU;EAAM,CAAC;CAC1C;CACA,UAAU;EACR,QAAQ,CACN;GAAE,IAAI;GAAS,MAAM;GAAW,UAAU;EAAK,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO,CAAC;GAAE,IAAI;GAAa,UAAU;EAAM,CAAC;CAC9C;CACA,OAAO;EACL,QAAQ,CACN;GAAE,IAAI;GAAS,MAAM;GAAW,UAAU;EAAK,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO,CAAC;GAAE,IAAI;GAAa,UAAU;EAAM,CAAC;CAC9C;CACA,YAAY;EACV,QAAQ,CAAC;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CAAC;EAC7D,OAAO,CAAC;GAAE,IAAI;GAAS,UAAU;GAAM,OAAO;GAAM,UAAU;EAAO,CAAC;CACxE;CACA,aAAa;EACX,QAAQ,CAAC;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CAAC;EAC7D,OAAO,CAAC;GAAE,IAAI;GAAS,UAAU;GAAM,OAAO;GAAM,UAAU;EAAO,CAAC;CACxE;CACA,QAAQ;EACN,QAAQ,CACN;GAAE,IAAI;GAAS,MAAM;GAAU,UAAU;EAAM,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO;GACL;IAAE,IAAI;IAAS,UAAU;GAAK;GAC9B;IAAE,IAAI;IAAS,UAAU;GAAM;GAC/B;IAAE,IAAI;IAAS,UAAU;GAAK;EAChC;CACF;CACA,MAAM;EACJ,QAAQ,CAAC;GAAE,IAAI;GAAS,MAAM;GAAU,UAAU;EAAM,CAAC;EACzD,OAAO,CACL;GAAE,IAAI;GAAQ,UAAU;GAAM,UAAU;EAAU,GAClD;GAAE,IAAI;GAAU,UAAU;GAAO,UAAU;EAAU,CACvD;CACF;CACA,UAAU;EACR,QAAQ,CAAC;GAAE,IAAI;GAAS,MAAM;GAAU,UAAU;EAAM,CAAC;EACzD,OAAO,CACL;GAAE,IAAI;GAAS,UAAU;EAAK,GAC9B;GAAE,IAAI;GAAa,UAAU;EAAK,CACpC;CACF;CACA,aAAa;EACX,QAAQ,CACN;GAAE,IAAI;GAAQ,MAAM;GAAW,UAAU;EAAM,GAC/C;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CACrD;EACA,OAAO,CACL;GAAE,IAAI;GAAW,UAAU;EAAK,GAChC;GAAE,IAAI;GAAW,UAAU;EAAK,CAClC;CACF;CACA,WAAW;EACT,QAAQ,CAAC;GAAE,IAAI;GAAY,MAAM;GAAW,UAAU;EAAM,CAAC;EAC7D,OAAO,CAAC;GAAE,IAAI;GAAS,UAAU;GAAM,OAAO;GAAM,UAAU;EAAO,CAAC;CACxE;AACF;AAEA,SAAgB,kBAAkB,MAAwC;CACxE,OAAO,oBAAoB;AAC7B"}
|