@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,266 @@
|
|
|
1
|
+
import type { VariableFormulaOperator, VariableLiteral, VariableType } from '#scene-graph/types'
|
|
2
|
+
|
|
3
|
+
import { variableText, variableTruthy } from '../text'
|
|
4
|
+
import { VariableFormulaError } from './tree'
|
|
5
|
+
|
|
6
|
+
export type FormulaValueType = VariableType
|
|
7
|
+
|
|
8
|
+
/** One set of operand types an operator takes, and the type it then gives. */
|
|
9
|
+
export interface FormulaOverload {
|
|
10
|
+
operands: readonly FormulaValueType[]
|
|
11
|
+
result: FormulaValueType
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Everything about one operator: how it is written and binds, which operand types it takes as
|
|
16
|
+
* Figma's expression signatures list them, and what it computes. The parser, printer, tokenizer,
|
|
17
|
+
* type checker and evaluator all read this table.
|
|
18
|
+
*/
|
|
19
|
+
interface OperatorSignature {
|
|
20
|
+
/** How the operator is written; the parser reads every spelling, the printer the first. */
|
|
21
|
+
spellings: readonly [string, ...string[]]
|
|
22
|
+
/** Written as a function call, `name(operands)`, rather than around its operands. */
|
|
23
|
+
call?: boolean
|
|
24
|
+
arity: 1 | 2 | 3
|
|
25
|
+
/** How tightly an operator written around its operands binds; calls need none. */
|
|
26
|
+
precedence?: number
|
|
27
|
+
/** Grouping it differently gives the same value, so `a + (b + c)` may print as `a + b + c`. */
|
|
28
|
+
associative?: boolean
|
|
29
|
+
/** Its operations do not chain: `a < b < c` reads as a mistake, not as `(a < b) < c`. */
|
|
30
|
+
nonAssociative?: boolean
|
|
31
|
+
overloads: readonly FormulaOverload[]
|
|
32
|
+
/** What the error says when no overload takes the operands. */
|
|
33
|
+
needs: string
|
|
34
|
+
/** Operands are checked against `overloads` before this runs. */
|
|
35
|
+
apply: (operands: VariableLiteral[]) => VariableLiteral
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Prefix operators bind tighter than every operator written between two operands. */
|
|
39
|
+
export const FORMULA_PREFIX_PRECEDENCE = 7
|
|
40
|
+
|
|
41
|
+
const FLOAT_FLOAT = ['FLOAT', 'FLOAT'] as const
|
|
42
|
+
const TEXT_TYPES = ['FLOAT', 'BOOLEAN', 'STRING'] as const
|
|
43
|
+
|
|
44
|
+
const SIGNATURES: Record<VariableFormulaOperator, OperatorSignature> = {
|
|
45
|
+
add: {
|
|
46
|
+
spellings: ['+'],
|
|
47
|
+
arity: 2,
|
|
48
|
+
precedence: 5,
|
|
49
|
+
associative: true,
|
|
50
|
+
overloads: [
|
|
51
|
+
{ operands: FLOAT_FLOAT, result: 'FLOAT' },
|
|
52
|
+
{ operands: ['STRING', 'STRING'], result: 'STRING' },
|
|
53
|
+
...(['FLOAT', 'BOOLEAN'] as const).flatMap((other) => [
|
|
54
|
+
{ operands: ['STRING', other], result: 'STRING' } as const,
|
|
55
|
+
{ operands: [other, 'STRING'], result: 'STRING' } as const
|
|
56
|
+
])
|
|
57
|
+
],
|
|
58
|
+
needs: 'adds numbers or joins text',
|
|
59
|
+
apply: ([a, b]) =>
|
|
60
|
+
typeof a === 'number' && typeof b === 'number'
|
|
61
|
+
? a + b
|
|
62
|
+
: `${variableText(a) ?? ''}${variableText(b) ?? ''}`
|
|
63
|
+
},
|
|
64
|
+
subtract: arithmetic('-', 5, (a, b) => a - b),
|
|
65
|
+
multiply: { ...arithmetic('*', 6, (a, b) => a * b), associative: true },
|
|
66
|
+
divide: arithmetic('/', 6, (a, b) => {
|
|
67
|
+
if (b === 0) throw new VariableFormulaError('Cannot divide by zero')
|
|
68
|
+
return a / b
|
|
69
|
+
}),
|
|
70
|
+
negate: {
|
|
71
|
+
spellings: ['-'],
|
|
72
|
+
arity: 1,
|
|
73
|
+
precedence: FORMULA_PREFIX_PRECEDENCE,
|
|
74
|
+
overloads: [{ operands: ['FLOAT'], result: 'FLOAT' }],
|
|
75
|
+
needs: 'needs numbers',
|
|
76
|
+
apply: ([a]) => -Number(a)
|
|
77
|
+
},
|
|
78
|
+
equal: equality('==', (a, b) => a === b),
|
|
79
|
+
notEqual: equality('!=', (a, b) => a !== b),
|
|
80
|
+
less: comparison('<', (a, b) => a < b),
|
|
81
|
+
lessOrEqual: comparison('<=', (a, b) => a <= b),
|
|
82
|
+
greater: comparison('>', (a, b) => a > b),
|
|
83
|
+
greaterOrEqual: comparison('>=', (a, b) => a >= b),
|
|
84
|
+
and: logic(['and', '&&'], 2, (a, b) => a && b),
|
|
85
|
+
or: logic(['or', '||'], 1, (a, b) => a || b),
|
|
86
|
+
not: {
|
|
87
|
+
spellings: ['not', '!'],
|
|
88
|
+
arity: 1,
|
|
89
|
+
precedence: FORMULA_PREFIX_PRECEDENCE,
|
|
90
|
+
overloads: [{ operands: ['BOOLEAN'], result: 'BOOLEAN' }],
|
|
91
|
+
needs: 'needs true or false',
|
|
92
|
+
apply: ([a]) => a !== true
|
|
93
|
+
},
|
|
94
|
+
text: {
|
|
95
|
+
spellings: ['text'],
|
|
96
|
+
call: true,
|
|
97
|
+
arity: 1,
|
|
98
|
+
overloads: TEXT_TYPES.map((type) => ({ operands: [type], result: 'STRING' })),
|
|
99
|
+
needs: 'needs a number, text, or true or false',
|
|
100
|
+
apply: ([a]) => variableText(a) ?? ''
|
|
101
|
+
},
|
|
102
|
+
truthy: {
|
|
103
|
+
spellings: ['truthy'],
|
|
104
|
+
call: true,
|
|
105
|
+
arity: 1,
|
|
106
|
+
overloads: TEXT_TYPES.map((type) => ({ operands: [type], result: 'BOOLEAN' })),
|
|
107
|
+
needs: 'needs a number, text, or true or false',
|
|
108
|
+
apply: ([a]) => variableTruthy(a) ?? false
|
|
109
|
+
},
|
|
110
|
+
if: {
|
|
111
|
+
spellings: ['if'],
|
|
112
|
+
call: true,
|
|
113
|
+
arity: 3,
|
|
114
|
+
overloads: (['FLOAT', 'BOOLEAN', 'STRING', 'COLOR'] as const).map((type) => ({
|
|
115
|
+
operands: ['BOOLEAN', type, type],
|
|
116
|
+
result: type
|
|
117
|
+
})),
|
|
118
|
+
needs: 'needs true or false, then two values of the same type',
|
|
119
|
+
apply: ([condition, then, otherwise]) => (condition === true ? then : otherwise)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function arithmetic(
|
|
124
|
+
symbol: string,
|
|
125
|
+
precedence: number,
|
|
126
|
+
apply: (a: number, b: number) => number
|
|
127
|
+
): OperatorSignature {
|
|
128
|
+
return {
|
|
129
|
+
spellings: [symbol],
|
|
130
|
+
arity: 2,
|
|
131
|
+
precedence,
|
|
132
|
+
overloads: [{ operands: FLOAT_FLOAT, result: 'FLOAT' }],
|
|
133
|
+
needs: 'needs numbers',
|
|
134
|
+
apply: ([a, b]) => apply(Number(a), Number(b))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function comparison(symbol: string, apply: (a: number, b: number) => boolean): OperatorSignature {
|
|
139
|
+
return {
|
|
140
|
+
spellings: [symbol],
|
|
141
|
+
arity: 2,
|
|
142
|
+
precedence: 4,
|
|
143
|
+
nonAssociative: true,
|
|
144
|
+
overloads: [{ operands: FLOAT_FLOAT, result: 'BOOLEAN' }],
|
|
145
|
+
needs: 'needs numbers',
|
|
146
|
+
apply: ([a, b]) => apply(Number(a), Number(b))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function equality(
|
|
151
|
+
symbol: string,
|
|
152
|
+
apply: (a: VariableLiteral, b: VariableLiteral) => boolean
|
|
153
|
+
): OperatorSignature {
|
|
154
|
+
return {
|
|
155
|
+
spellings: [symbol],
|
|
156
|
+
arity: 2,
|
|
157
|
+
precedence: 3,
|
|
158
|
+
nonAssociative: true,
|
|
159
|
+
overloads: TEXT_TYPES.map((type) => ({ operands: [type, type], result: 'BOOLEAN' })),
|
|
160
|
+
needs: 'compares two numbers, two texts, or two true or false values',
|
|
161
|
+
apply: ([a, b]) => apply(a, b)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function logic(
|
|
166
|
+
spellings: readonly [string, ...string[]],
|
|
167
|
+
precedence: number,
|
|
168
|
+
apply: (a: boolean, b: boolean) => boolean
|
|
169
|
+
): OperatorSignature {
|
|
170
|
+
return {
|
|
171
|
+
spellings,
|
|
172
|
+
arity: 2,
|
|
173
|
+
precedence,
|
|
174
|
+
associative: true,
|
|
175
|
+
overloads: [{ operands: ['BOOLEAN', 'BOOLEAN'], result: 'BOOLEAN' }],
|
|
176
|
+
needs: 'needs true or false',
|
|
177
|
+
apply: ([a, b]) => apply(a === true, b === true)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const OPERATORS = Object.keys(SIGNATURES) as VariableFormulaOperator[]
|
|
182
|
+
|
|
183
|
+
/** Each spelling written between operands, or before one, and the operator it reads as. */
|
|
184
|
+
function spellingIndex(written: (signature: OperatorSignature) => boolean) {
|
|
185
|
+
return new Map(
|
|
186
|
+
OPERATORS.filter((operator) => written(SIGNATURES[operator])).flatMap((operator) =>
|
|
187
|
+
SIGNATURES[operator].spellings.map((spelling) => [spelling, operator] as const)
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
const BINARY = spellingIndex(({ arity, call }) => arity === 2 && !call)
|
|
192
|
+
const PREFIX = spellingIndex(({ arity, call }) => arity === 1 && !call)
|
|
193
|
+
const CALLS = spellingIndex(({ call }) => call === true)
|
|
194
|
+
|
|
195
|
+
/** Operators spelled as words, such as `and` and `not`, which read as keywords, not names. */
|
|
196
|
+
export const FORMULA_KEYWORDS: ReadonlySet<string> = new Set(
|
|
197
|
+
[...BINARY.keys(), ...PREFIX.keys()].filter((spelling) => /^\p{L}+$/u.test(spelling))
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
export function isFormulaOperator(name: string): name is VariableFormulaOperator {
|
|
201
|
+
return Object.hasOwn(SIGNATURES, name)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function formulaArity(operator: VariableFormulaOperator): number {
|
|
205
|
+
return SIGNATURES[operator].arity
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** How the operator is printed: its first spelling. */
|
|
209
|
+
export function formulaSymbol(operator: VariableFormulaOperator): string {
|
|
210
|
+
return SIGNATURES[operator].spellings[0]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function formulaPrecedence(operator: VariableFormulaOperator): number | undefined {
|
|
214
|
+
return SIGNATURES[operator].precedence
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Written as a function call, such as `if(a, b, c)`, rather than around its operands. */
|
|
218
|
+
export function isFormulaCall(operator: VariableFormulaOperator): boolean {
|
|
219
|
+
return SIGNATURES[operator].call === true
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function isFormulaAssociative(operator: VariableFormulaOperator): boolean {
|
|
223
|
+
return SIGNATURES[operator].associative === true
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Precedence levels whose operations do not chain, such as the comparisons. */
|
|
227
|
+
export const FORMULA_NON_ASSOCIATIVE: ReadonlySet<number> = new Set(
|
|
228
|
+
OPERATORS.flatMap((operator) => {
|
|
229
|
+
const { nonAssociative, precedence } = SIGNATURES[operator]
|
|
230
|
+
return nonAssociative && precedence !== undefined ? [precedence] : []
|
|
231
|
+
})
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
/** The operator written between operands as `spelling`, such as `AND` for `&&`. */
|
|
235
|
+
export function binaryFormulaOperator(spelling: string): VariableFormulaOperator | undefined {
|
|
236
|
+
return BINARY.get(spelling.toLowerCase())
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** The operator written before an operand as `spelling`, such as `NOT` for `!`. */
|
|
240
|
+
export function prefixFormulaOperator(spelling: string): VariableFormulaOperator | undefined {
|
|
241
|
+
return PREFIX.get(spelling.toLowerCase())
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** The operator a function call names, such as `TERNARY` for `if`. */
|
|
245
|
+
export function formulaCallOperator(name: string): VariableFormulaOperator | undefined {
|
|
246
|
+
return CALLS.get(name.toLowerCase())
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function formulaOverloads(operator: VariableFormulaOperator): readonly FormulaOverload[] {
|
|
250
|
+
return SIGNATURES[operator].overloads
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The name an error gives the operator, `if()` for a call, and what it needs. */
|
|
254
|
+
export function formulaNeeds(operator: VariableFormulaOperator): { name: string; needs: string } {
|
|
255
|
+
const { call, needs } = SIGNATURES[operator]
|
|
256
|
+
const symbol = formulaSymbol(operator)
|
|
257
|
+
return { name: call ? `${symbol}()` : symbol, needs }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Compute an operation whose operands have been checked against its overloads. */
|
|
261
|
+
export function applyFormulaOperator(
|
|
262
|
+
operator: VariableFormulaOperator,
|
|
263
|
+
operands: VariableLiteral[]
|
|
264
|
+
): VariableLiteral {
|
|
265
|
+
return SIGNATURES[operator].apply(operands)
|
|
266
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { formulaCallOperator, FORMULA_KEYWORDS } from './signatures'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a piece of formula text is. `reference` is a braced `{name}` and `string` a quoted
|
|
5
|
+
* `"text"`, either of which may still be open while it is typed; `name` is a bare word that
|
|
6
|
+
* names a variable; `function` is a call's name, such as `if`; `invalid` is any character the
|
|
7
|
+
* syntax has no place for.
|
|
8
|
+
*/
|
|
9
|
+
export type FormulaTokenKind =
|
|
10
|
+
| 'number'
|
|
11
|
+
| 'string'
|
|
12
|
+
| 'color'
|
|
13
|
+
| 'reference'
|
|
14
|
+
| 'name'
|
|
15
|
+
| 'function'
|
|
16
|
+
| 'keyword'
|
|
17
|
+
| 'bool'
|
|
18
|
+
| 'operator'
|
|
19
|
+
| 'paren'
|
|
20
|
+
| 'comma'
|
|
21
|
+
| 'invalid'
|
|
22
|
+
|
|
23
|
+
export interface FormulaToken {
|
|
24
|
+
kind: FormulaTokenKind
|
|
25
|
+
text: string
|
|
26
|
+
from: number
|
|
27
|
+
to: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const NUMBER = /(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/y
|
|
31
|
+
const WORD = /[\p{L}_$][\p{L}\p{N}_$]*/uy
|
|
32
|
+
const OPERATOR = /<=|>=|==|!=|&&|\|\||[-+*/<>!]/y
|
|
33
|
+
const SPACE = /\s+/y
|
|
34
|
+
const COLOR = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6})(?![\p{L}\p{N}_$])/uy
|
|
35
|
+
const BOOLEANS = new Set(['true', 'false'])
|
|
36
|
+
|
|
37
|
+
function matchAt(pattern: RegExp, source: string, at: number) {
|
|
38
|
+
pattern.lastIndex = at
|
|
39
|
+
return pattern.exec(source)?.[0]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A string runs to its unescaped closing quote, or, while it is still being typed, to the end. */
|
|
43
|
+
function stringEnd(source: string, at: number) {
|
|
44
|
+
for (let index = at + 1; index < source.length; index++) {
|
|
45
|
+
if (source[index] === '\\') index++
|
|
46
|
+
else if (source[index] === '"') return index + 1
|
|
47
|
+
}
|
|
48
|
+
return source.length
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A reference runs to its `}`, or, while it is still being typed, to the next `{` or the end. */
|
|
52
|
+
function referenceEnd(source: string, at: number) {
|
|
53
|
+
for (let index = at + 1; index < source.length; index++) {
|
|
54
|
+
if (source[index] === '}') return index + 1
|
|
55
|
+
if (source[index] === '{') return index
|
|
56
|
+
}
|
|
57
|
+
return source.length
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function wordKind(word: string): FormulaTokenKind {
|
|
61
|
+
const lower = word.toLowerCase()
|
|
62
|
+
if (FORMULA_KEYWORDS.has(lower)) return 'keyword'
|
|
63
|
+
if (formulaCallOperator(lower)) return 'function'
|
|
64
|
+
return BOOLEANS.has(lower) ? 'bool' : 'name'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The token that starts at `at`, which must not be whitespace. Reading never fails: text the
|
|
69
|
+
* syntax has no place for is an `invalid` token, so an editor can highlight what a parser rejects.
|
|
70
|
+
*/
|
|
71
|
+
export function readFormulaToken(source: string, at: number): FormulaToken {
|
|
72
|
+
const token = (kind: FormulaTokenKind, length: number): FormulaToken => ({
|
|
73
|
+
kind,
|
|
74
|
+
text: source.slice(at, at + length),
|
|
75
|
+
from: at,
|
|
76
|
+
to: at + length
|
|
77
|
+
})
|
|
78
|
+
const char = source[at] ?? ''
|
|
79
|
+
if (char === '{') return token('reference', referenceEnd(source, at) - at)
|
|
80
|
+
if (char === '"') return token('string', stringEnd(source, at) - at)
|
|
81
|
+
if (char === '(' || char === ')') return token('paren', 1)
|
|
82
|
+
if (char === ',') return token('comma', 1)
|
|
83
|
+
const color = matchAt(COLOR, source, at)
|
|
84
|
+
if (color) return token('color', color.length)
|
|
85
|
+
const number = matchAt(NUMBER, source, at)
|
|
86
|
+
if (number) return token('number', number.length)
|
|
87
|
+
const word = matchAt(WORD, source, at)
|
|
88
|
+
if (word) return token(wordKind(word), word.length)
|
|
89
|
+
const operator = matchAt(OPERATOR, source, at)
|
|
90
|
+
return operator ? token('operator', operator.length) : token('invalid', 1)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Every token of a formula, in order, without the whitespace between them. */
|
|
94
|
+
export function formulaTokens(source: string): FormulaToken[] {
|
|
95
|
+
const tokens: FormulaToken[] = []
|
|
96
|
+
let at = 0
|
|
97
|
+
while (at < source.length) {
|
|
98
|
+
const space = matchAt(SPACE, source, at)
|
|
99
|
+
if (space) {
|
|
100
|
+
at += space.length
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
const token = readFormulaToken(source, at)
|
|
104
|
+
tokens.push(token)
|
|
105
|
+
at = token.to
|
|
106
|
+
}
|
|
107
|
+
return tokens
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The variable a reference or bare name gives, without braces or surrounding spaces. */
|
|
111
|
+
export function formulaTokenName(token: FormulaToken) {
|
|
112
|
+
if (token.kind !== 'reference') return token.text
|
|
113
|
+
return token.text.slice(1, token.text.endsWith('}') ? -1 : undefined).trim()
|
|
114
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
VariableAlias,
|
|
3
|
+
VariableFormulaNode,
|
|
4
|
+
VariableFormulaOperation,
|
|
5
|
+
VariableLiteral
|
|
6
|
+
} from '#scene-graph/types'
|
|
7
|
+
|
|
8
|
+
export const MAX_FORMULA_DEPTH = 64
|
|
9
|
+
export const MAX_FORMULA_LENGTH = 4096
|
|
10
|
+
|
|
11
|
+
export class VariableFormulaError extends Error {
|
|
12
|
+
override name = 'VariableFormulaError'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function isFormulaOperation(node: VariableFormulaNode): node is VariableFormulaOperation {
|
|
16
|
+
return typeof node === 'object' && 'operator' in node
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isFormulaReference(node: VariableFormulaNode): node is VariableAlias {
|
|
20
|
+
return typeof node === 'object' && 'aliasId' in node
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What a fold makes of each kind of node; an operation gets its operands' results. */
|
|
24
|
+
export interface FormulaFold<T> {
|
|
25
|
+
literal: (value: VariableLiteral) => T
|
|
26
|
+
reference: (id: string) => T
|
|
27
|
+
operation: (node: VariableFormulaOperation, operands: T[]) => T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Walk a formula bottom-up, as evaluating, type checking, remapping and writing it to another
|
|
32
|
+
* format all do. A tree deeper than `MAX_FORMULA_DEPTH` is refused rather than walked.
|
|
33
|
+
*/
|
|
34
|
+
export function foldFormula<T>(node: VariableFormulaNode, fold: FormulaFold<T>, depth = 0): T {
|
|
35
|
+
if (depth > MAX_FORMULA_DEPTH) throw new VariableFormulaError('Formula is too deeply nested')
|
|
36
|
+
if (isFormulaOperation(node))
|
|
37
|
+
return fold.operation(
|
|
38
|
+
node,
|
|
39
|
+
node.operands.map((operand) => foldFormula(operand, fold, depth + 1))
|
|
40
|
+
)
|
|
41
|
+
return isFormulaReference(node) ? fold.reference(node.aliasId) : fold.literal(node)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function mapFormulaReferences(
|
|
45
|
+
node: VariableFormulaNode,
|
|
46
|
+
map: (id: string) => string
|
|
47
|
+
): VariableFormulaNode {
|
|
48
|
+
return foldFormula<VariableFormulaNode>(node, {
|
|
49
|
+
literal: (value) => (typeof value === 'object' ? { ...value } : value),
|
|
50
|
+
reference: (id) => ({ aliasId: map(id) }),
|
|
51
|
+
operation: ({ operator }, operands) => ({ operator, operands })
|
|
52
|
+
})
|
|
53
|
+
}
|