@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,249 @@
|
|
|
1
|
+
import { createSceneMutationImpact, recordSceneMutations } from "./mutation-impact.js";
|
|
2
|
+
import { isEqual } from "es-toolkit";
|
|
3
|
+
//#region src/checkpoint.ts
|
|
4
|
+
const NODE_COUNT_ERROR = "Atomic tools must not create or remove nodes or variables";
|
|
5
|
+
const NODE_IDENTITY_ERROR = "Atomic tools must not change node hierarchy or identity";
|
|
6
|
+
const VARIABLE_IDENTITY_ERROR = "Atomic tools must not change variable identity";
|
|
7
|
+
const DOCUMENT_ERROR = "Atomic tools must not change collections, assets or document metadata";
|
|
8
|
+
/** Capture rollback state without changing graph or surviving object identities. */
|
|
9
|
+
function captureGraphCheckpoint(graph) {
|
|
10
|
+
const nodeRefs = new Map(graph.nodes);
|
|
11
|
+
const variableRefs = new Map(graph.variables);
|
|
12
|
+
const collectionRefs = new Map(graph.variableCollections);
|
|
13
|
+
const snapshot = structuredClone({
|
|
14
|
+
nodes: graph.nodes,
|
|
15
|
+
variables: graph.variables,
|
|
16
|
+
variableCollections: graph.variableCollections,
|
|
17
|
+
activeMode: graph.activeMode,
|
|
18
|
+
instanceIndex: graph.instanceIndex,
|
|
19
|
+
enabledLibraries: graph.enabledLibraries,
|
|
20
|
+
rootId: graph.rootId,
|
|
21
|
+
figKiwiVersion: graph.figKiwiVersion,
|
|
22
|
+
figSchemaDeflated: graph.figSchemaDeflated,
|
|
23
|
+
documentColorSpace: graph.documentColorSpace
|
|
24
|
+
});
|
|
25
|
+
const images = new Map(graph.images);
|
|
26
|
+
function assertPropertiesOnly() {
|
|
27
|
+
if (snapshot.nodes.size !== graph.nodes.size || snapshot.variables.size !== graph.variables.size) throw new Error(NODE_COUNT_ERROR);
|
|
28
|
+
for (const [id, before] of snapshot.nodes) {
|
|
29
|
+
const after = graph.nodes.get(id);
|
|
30
|
+
if (!after || after !== nodeRefs.get(id) || before.id !== after.id || before.type !== after.type || before.parentId !== after.parentId || before.componentId !== after.componentId || !isEqual(before.childIds, after.childIds)) throw new Error(NODE_IDENTITY_ERROR);
|
|
31
|
+
}
|
|
32
|
+
for (const [id, before] of snapshot.variables) {
|
|
33
|
+
const after = graph.variables.get(id);
|
|
34
|
+
if (!after || after !== variableRefs.get(id) || before.id !== after.id || before.collectionId !== after.collectionId || before.type !== after.type) throw new Error(VARIABLE_IDENTITY_ERROR);
|
|
35
|
+
}
|
|
36
|
+
assertDocumentUnchanged();
|
|
37
|
+
}
|
|
38
|
+
function assertDocumentUnchanged() {
|
|
39
|
+
if (!isEqual(snapshot.variableCollections, graph.variableCollections) || !isEqual(snapshot.activeMode, graph.activeMode) || !isEqual(snapshot.instanceIndex, graph.instanceIndex) || !isEqual(snapshot.enabledLibraries, graph.enabledLibraries) || images.size !== graph.images.size || [...images].some(([id, bytes]) => graph.images.get(id) !== bytes) || graph.rootId !== snapshot.rootId || graph.documentColorSpace !== snapshot.documentColorSpace || graph.figKiwiVersion !== snapshot.figKiwiVersion || !isEqual(graph.figSchemaDeflated, snapshot.figSchemaDeflated)) throw new Error(DOCUMENT_ERROR);
|
|
40
|
+
}
|
|
41
|
+
function restore() {
|
|
42
|
+
const failedNodes = new Map(graph.nodes);
|
|
43
|
+
restoreObjects(graph.nodes, snapshot.nodes, nodeRefs);
|
|
44
|
+
restoreObjects(graph.variables, snapshot.variables, variableRefs);
|
|
45
|
+
restoreObjects(graph.variableCollections, snapshot.variableCollections, collectionRefs);
|
|
46
|
+
restoreMap(graph.activeMode, structuredClone(snapshot.activeMode));
|
|
47
|
+
restoreMap(graph.instanceIndex, structuredClone(snapshot.instanceIndex));
|
|
48
|
+
restoreMap(graph.enabledLibraries, structuredClone(snapshot.enabledLibraries));
|
|
49
|
+
restoreMap(graph.images, images);
|
|
50
|
+
graph.rootId = snapshot.rootId;
|
|
51
|
+
graph.figKiwiVersion = snapshot.figKiwiVersion;
|
|
52
|
+
graph.figSchemaDeflated = structuredClone(snapshot.figSchemaDeflated);
|
|
53
|
+
graph.documentColorSpace = snapshot.documentColorSpace;
|
|
54
|
+
graph.clearAbsPosCache();
|
|
55
|
+
for (const [id, node] of failedNodes) if (!graph.nodes.has(id)) graph.emitter.emit("node:deleted", id, node.parentId);
|
|
56
|
+
for (const [id, node] of graph.nodes) if (failedNodes.has(id)) graph.emitter.emit("node:updated", id, node);
|
|
57
|
+
else graph.emitter.emit("node:created", node);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
nodes: snapshot.nodes,
|
|
61
|
+
variables: snapshot.variables,
|
|
62
|
+
assertPropertiesOnly,
|
|
63
|
+
restore
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function restoreObjects(target, snapshot, refs) {
|
|
67
|
+
target.clear();
|
|
68
|
+
for (const [id, saved] of snapshot) {
|
|
69
|
+
const original = refs.get(id);
|
|
70
|
+
if (!original) throw new Error(`Missing checkpoint reference: ${id}`);
|
|
71
|
+
for (const key of Object.keys(original)) if (!(key in saved)) Reflect.deleteProperty(original, key);
|
|
72
|
+
Object.assign(original, structuredClone(saved));
|
|
73
|
+
target.set(id, original);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function restoreMap(target, saved) {
|
|
77
|
+
target.clear();
|
|
78
|
+
for (const [key, value] of saved) target.set(key, value);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Starts observing `graph` for an edit that may only change properties. Node identities are
|
|
82
|
+
* kept as pointers, so replacing, adding, or removing a node anywhere is found; a node's fields
|
|
83
|
+
* are compared and restored only where the graph reported it, so code that writes into a node
|
|
84
|
+
* directly calls `SceneGraph.willChangeNode` first, and a node event without such a report fails
|
|
85
|
+
* the edit.
|
|
86
|
+
*/
|
|
87
|
+
function captureTouchedCheckpoint(graph) {
|
|
88
|
+
const nodeRefs = new Map(graph.nodes);
|
|
89
|
+
const variableRefs = new Map(graph.variables);
|
|
90
|
+
const collectionRefs = new Map(graph.variableCollections);
|
|
91
|
+
const saved = structuredClone({
|
|
92
|
+
variables: graph.variables,
|
|
93
|
+
variableCollections: graph.variableCollections,
|
|
94
|
+
activeMode: graph.activeMode,
|
|
95
|
+
instanceIndex: graph.instanceIndex,
|
|
96
|
+
enabledLibraries: graph.enabledLibraries
|
|
97
|
+
});
|
|
98
|
+
const images = new Map(graph.images);
|
|
99
|
+
const { rootId, figKiwiVersion, figSchemaDeflated, documentColorSpace } = graph;
|
|
100
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
101
|
+
const reported = /* @__PURE__ */ new Set();
|
|
102
|
+
const created = /* @__PURE__ */ new Set();
|
|
103
|
+
const impact = createSceneMutationImpact();
|
|
104
|
+
/** Copies a node as the edit found it: the original object, should the edit have replaced it. */
|
|
105
|
+
function copy(node) {
|
|
106
|
+
nodes.set(node.id, structuredClone(nodeRefs.get(node.id) ?? node));
|
|
107
|
+
}
|
|
108
|
+
const skipped = (node) => nodes.has(node.id) || created.has(node.id);
|
|
109
|
+
/**
|
|
110
|
+
* Copies `node` and each ancestor not copied yet, up to but excluding its page. An ancestor
|
|
111
|
+
* copied already had its own ancestors copied with it, so the walk stops there.
|
|
112
|
+
*/
|
|
113
|
+
function copyLineage(node) {
|
|
114
|
+
if (skipped(node)) return;
|
|
115
|
+
copy(node);
|
|
116
|
+
if (!node.parentId) return;
|
|
117
|
+
graph.closest(node.parentId, (ancestor) => {
|
|
118
|
+
if (ancestor.type === "CANVAS" || ancestor.id === rootId || skipped(ancestor)) return true;
|
|
119
|
+
copy(ancestor);
|
|
120
|
+
return false;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const unobserve = graph.observeNodeChanges({
|
|
124
|
+
created: (node) => {
|
|
125
|
+
created.add(node.id);
|
|
126
|
+
reported.add(node.id);
|
|
127
|
+
},
|
|
128
|
+
before: (node) => {
|
|
129
|
+
reported.add(node.id);
|
|
130
|
+
copyLineage(node);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const unbindEvents = recordSceneMutations(graph, impact);
|
|
134
|
+
let observing = true;
|
|
135
|
+
function stop() {
|
|
136
|
+
if (!observing) return;
|
|
137
|
+
observing = false;
|
|
138
|
+
unobserve();
|
|
139
|
+
unbindEvents();
|
|
140
|
+
}
|
|
141
|
+
function assertNodes() {
|
|
142
|
+
if (created.size > 0 || impact.deletedNodeIds.size > 0 || graph.nodes.size !== nodeRefs.size || graph.variables.size !== variableRefs.size) throw new Error(NODE_COUNT_ERROR);
|
|
143
|
+
for (const [id, node] of graph.nodes) {
|
|
144
|
+
const original = nodeRefs.get(id);
|
|
145
|
+
if (!original) throw new Error(NODE_COUNT_ERROR);
|
|
146
|
+
if (original !== node) throw new Error(NODE_IDENTITY_ERROR);
|
|
147
|
+
}
|
|
148
|
+
for (const [id, before] of nodes) {
|
|
149
|
+
const after = graph.nodes.get(id);
|
|
150
|
+
if (!after || before.id !== after.id || before.type !== after.type || before.parentId !== after.parentId || before.componentId !== after.componentId || !isEqual(before.childIds, after.childIds)) throw new Error(NODE_IDENTITY_ERROR);
|
|
151
|
+
}
|
|
152
|
+
for (const id of [
|
|
153
|
+
...impact.changedNodeIds,
|
|
154
|
+
...impact.previousParentIds,
|
|
155
|
+
...impact.currentParentIds
|
|
156
|
+
]) if (!nodes.has(id) && !created.has(id)) throw new Error(`Atomic tools must report layer changes to the scene graph (SceneGraph.willChangeNode): ${id}`);
|
|
157
|
+
}
|
|
158
|
+
function assertPropertiesOnly() {
|
|
159
|
+
assertNodes();
|
|
160
|
+
for (const [id, before] of saved.variables) {
|
|
161
|
+
const after = graph.variables.get(id);
|
|
162
|
+
if (!after || after !== variableRefs.get(id) || before.id !== after.id || before.collectionId !== after.collectionId || before.type !== after.type) throw new Error(VARIABLE_IDENTITY_ERROR);
|
|
163
|
+
}
|
|
164
|
+
if (!isEqual(saved.variableCollections, graph.variableCollections) || !isEqual(saved.activeMode, graph.activeMode) || !isEqual(saved.instanceIndex, graph.instanceIndex) || !isEqual(saved.enabledLibraries, graph.enabledLibraries) || images.size !== graph.images.size || [...images].some(([id, bytes]) => graph.images.get(id) !== bytes) || graph.rootId !== rootId || graph.documentColorSpace !== documentColorSpace || graph.figKiwiVersion !== figKiwiVersion || graph.figSchemaDeflated !== figSchemaDeflated) throw new Error(DOCUMENT_ERROR);
|
|
165
|
+
}
|
|
166
|
+
/** Puts the node map back as it was, in its order, if the edit changed its entries. */
|
|
167
|
+
function restoreNodeMap() {
|
|
168
|
+
const removed = /* @__PURE__ */ new Map();
|
|
169
|
+
const readded = /* @__PURE__ */ new Set();
|
|
170
|
+
let changed = graph.nodes.size !== nodeRefs.size;
|
|
171
|
+
if (!changed) {
|
|
172
|
+
const live = graph.nodes.entries();
|
|
173
|
+
for (const [id, node] of nodeRefs) {
|
|
174
|
+
const next = live.next();
|
|
175
|
+
if (next.done || next.value[0] !== id || next.value[1] !== node) {
|
|
176
|
+
changed = true;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (!changed) return {
|
|
182
|
+
removed,
|
|
183
|
+
readded
|
|
184
|
+
};
|
|
185
|
+
const failed = new Map(graph.nodes);
|
|
186
|
+
graph.nodes.clear();
|
|
187
|
+
for (const [id, node] of nodeRefs) {
|
|
188
|
+
graph.nodes.set(id, node);
|
|
189
|
+
if (!failed.has(id)) readded.add(id);
|
|
190
|
+
}
|
|
191
|
+
for (const [id, node] of failed) if (!nodeRefs.has(id)) removed.set(id, node);
|
|
192
|
+
return {
|
|
193
|
+
removed,
|
|
194
|
+
readded
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function restore() {
|
|
198
|
+
stop();
|
|
199
|
+
const { removed, readded } = restoreNodeMap();
|
|
200
|
+
for (const [id, copy] of nodes) {
|
|
201
|
+
const original = nodeRefs.get(id);
|
|
202
|
+
if (!original) continue;
|
|
203
|
+
for (const key of Object.keys(original)) if (!Object.hasOwn(copy, key)) Reflect.deleteProperty(original, key);
|
|
204
|
+
Object.assign(original, structuredClone(copy));
|
|
205
|
+
}
|
|
206
|
+
restoreObjects(graph.variables, saved.variables, variableRefs);
|
|
207
|
+
restoreObjects(graph.variableCollections, saved.variableCollections, collectionRefs);
|
|
208
|
+
restoreMap(graph.activeMode, structuredClone(saved.activeMode));
|
|
209
|
+
restoreMap(graph.instanceIndex, structuredClone(saved.instanceIndex));
|
|
210
|
+
restoreMap(graph.enabledLibraries, structuredClone(saved.enabledLibraries));
|
|
211
|
+
restoreMap(graph.images, images);
|
|
212
|
+
graph.rootId = rootId;
|
|
213
|
+
graph.figKiwiVersion = figKiwiVersion;
|
|
214
|
+
graph.figSchemaDeflated = figSchemaDeflated;
|
|
215
|
+
graph.documentColorSpace = documentColorSpace;
|
|
216
|
+
graph.clearAbsPosCache();
|
|
217
|
+
const touched = /* @__PURE__ */ new Set([
|
|
218
|
+
...nodes.keys(),
|
|
219
|
+
...created,
|
|
220
|
+
...readded,
|
|
221
|
+
...removed.keys(),
|
|
222
|
+
...impact.changedNodeIds,
|
|
223
|
+
...impact.previousParentIds,
|
|
224
|
+
...impact.currentParentIds
|
|
225
|
+
]);
|
|
226
|
+
for (const id of touched) if (graph.nodes.get(id)?.type === "CONNECTOR") graph.connectorIds.add(id);
|
|
227
|
+
else graph.connectorIds.delete(id);
|
|
228
|
+
for (const [id, node] of removed) graph.emitter.emit("node:deleted", id, node.parentId);
|
|
229
|
+
for (const id of touched) {
|
|
230
|
+
const node = graph.nodes.get(id);
|
|
231
|
+
if (!node) continue;
|
|
232
|
+
if (readded.has(id)) graph.emitter.emit("node:created", node);
|
|
233
|
+
else graph.emitter.emit("node:updated", id, node);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
nodes,
|
|
238
|
+
reported,
|
|
239
|
+
variables: saved.variables,
|
|
240
|
+
variableCollections: saved.variableCollections,
|
|
241
|
+
assertPropertiesOnly,
|
|
242
|
+
restore,
|
|
243
|
+
stop
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
export { captureGraphCheckpoint, captureTouchedCheckpoint };
|
|
248
|
+
|
|
249
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","names":[],"sources":["../src/checkpoint.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\n\nimport type { SceneGraph } from './graph'\nimport { createSceneMutationImpact, recordSceneMutations } from './mutation-impact'\nimport type { SceneNode, Variable, VariableCollection } from './types'\n\nconst NODE_COUNT_ERROR = 'Atomic tools must not create or remove nodes or variables'\nconst NODE_IDENTITY_ERROR = 'Atomic tools must not change node hierarchy or identity'\nconst VARIABLE_IDENTITY_ERROR = 'Atomic tools must not change variable identity'\nconst DOCUMENT_ERROR = 'Atomic tools must not change collections, assets or document metadata'\n\n/** Capture rollback state without changing graph or surviving object identities. */\nexport function captureGraphCheckpoint(graph: SceneGraph) {\n const nodeRefs = new Map(graph.nodes)\n const variableRefs = new Map(graph.variables)\n const collectionRefs = new Map(graph.variableCollections)\n const snapshot = structuredClone({\n nodes: graph.nodes,\n variables: graph.variables,\n variableCollections: graph.variableCollections,\n activeMode: graph.activeMode,\n instanceIndex: graph.instanceIndex,\n enabledLibraries: graph.enabledLibraries,\n rootId: graph.rootId,\n figKiwiVersion: graph.figKiwiVersion,\n figSchemaDeflated: graph.figSchemaDeflated,\n documentColorSpace: graph.documentColorSpace\n })\n // Atomic property tools cannot edit assets. Retain existing buffers, not copies of every bitmap.\n const images = new Map(graph.images)\n\n function assertPropertiesOnly() {\n if (\n snapshot.nodes.size !== graph.nodes.size ||\n snapshot.variables.size !== graph.variables.size\n )\n throw new Error(NODE_COUNT_ERROR)\n for (const [id, before] of snapshot.nodes) {\n const after = graph.nodes.get(id)\n if (\n !after ||\n after !== nodeRefs.get(id) ||\n before.id !== after.id ||\n before.type !== after.type ||\n before.parentId !== after.parentId ||\n before.componentId !== after.componentId ||\n !isEqual(before.childIds, after.childIds)\n ) {\n throw new Error(NODE_IDENTITY_ERROR)\n }\n }\n for (const [id, before] of snapshot.variables) {\n const after = graph.variables.get(id)\n if (\n !after ||\n after !== variableRefs.get(id) ||\n before.id !== after.id ||\n before.collectionId !== after.collectionId ||\n before.type !== after.type\n )\n throw new Error(VARIABLE_IDENTITY_ERROR)\n }\n assertDocumentUnchanged()\n }\n\n function assertDocumentUnchanged() {\n if (\n !isEqual(snapshot.variableCollections, graph.variableCollections) ||\n !isEqual(snapshot.activeMode, graph.activeMode) ||\n !isEqual(snapshot.instanceIndex, graph.instanceIndex) ||\n !isEqual(snapshot.enabledLibraries, graph.enabledLibraries) ||\n images.size !== graph.images.size ||\n [...images].some(([id, bytes]) => graph.images.get(id) !== bytes) ||\n graph.rootId !== snapshot.rootId ||\n graph.documentColorSpace !== snapshot.documentColorSpace ||\n graph.figKiwiVersion !== snapshot.figKiwiVersion ||\n !isEqual(graph.figSchemaDeflated, snapshot.figSchemaDeflated)\n ) {\n throw new Error(DOCUMENT_ERROR)\n }\n }\n\n function restore() {\n const failedNodes = new Map(graph.nodes)\n restoreObjects(graph.nodes, snapshot.nodes, nodeRefs)\n restoreObjects(graph.variables, snapshot.variables, variableRefs)\n restoreObjects(graph.variableCollections, snapshot.variableCollections, collectionRefs)\n restoreMap(graph.activeMode, structuredClone(snapshot.activeMode))\n restoreMap(graph.instanceIndex, structuredClone(snapshot.instanceIndex))\n restoreMap(graph.enabledLibraries, structuredClone(snapshot.enabledLibraries))\n restoreMap(graph.images, images)\n graph.rootId = snapshot.rootId\n graph.figKiwiVersion = snapshot.figKiwiVersion\n graph.figSchemaDeflated = structuredClone(snapshot.figSchemaDeflated)\n graph.documentColorSpace = snapshot.documentColorSpace\n graph.clearAbsPosCache()\n // Notify consumers only after the complete hierarchy and indexes have been restored.\n for (const [id, node] of failedNodes) {\n if (!graph.nodes.has(id)) graph.emitter.emit('node:deleted', id, node.parentId)\n }\n for (const [id, node] of graph.nodes) {\n if (failedNodes.has(id)) graph.emitter.emit('node:updated', id, node)\n else graph.emitter.emit('node:created', node)\n }\n }\n\n return { nodes: snapshot.nodes, variables: snapshot.variables, assertPropertiesOnly, restore }\n}\n\nfunction restoreObjects<T extends object>(\n target: Map<string, T>,\n snapshot: Map<string, T>,\n refs: Map<string, T>\n) {\n target.clear()\n for (const [id, saved] of snapshot) {\n const original = refs.get(id)\n if (!original) throw new Error(`Missing checkpoint reference: ${id}`)\n for (const key of Object.keys(original) as (keyof T)[]) {\n if (!(key in saved)) Reflect.deleteProperty(original, key)\n }\n Object.assign(original, structuredClone(saved))\n target.set(id, original)\n }\n}\n\nfunction restoreMap<K, V>(target: Map<K, V>, saved: Map<K, V>) {\n target.clear()\n for (const [key, value] of saved) target.set(key, value)\n}\n\n/**\n * Rollback state for an edit that may only change properties, which costs what the edit touches\n * rather than a copy of the document: a node is copied the first time the graph reports it about\n * to change (`SceneGraph.observeNodeChanges`), together with its ancestors below the page, which\n * keep instance override maps the graph writes into in place.\n */\nexport interface TouchedCheckpoint {\n /** Copies of the reported nodes and their ancestors below the page, as they were before. */\n readonly nodes: ReadonlyMap<string, SceneNode>\n /** Nodes the graph reported changing or creating. */\n readonly reported: ReadonlySet<string>\n /** Copies of every variable, as variables have no change report. */\n readonly variables: ReadonlyMap<string, Variable>\n readonly variableCollections: ReadonlyMap<string, VariableCollection>\n /** Throws unless the edit only changed properties of existing nodes and variables. */\n assertPropertiesOnly(): void\n /** Stops observing and puts back everything the edit changed, keeping object identities. */\n restore(): void\n /** Stops observing the graph. */\n stop(): void\n}\n\n/**\n * Starts observing `graph` for an edit that may only change properties. Node identities are\n * kept as pointers, so replacing, adding, or removing a node anywhere is found; a node's fields\n * are compared and restored only where the graph reported it, so code that writes into a node\n * directly calls `SceneGraph.willChangeNode` first, and a node event without such a report fails\n * the edit.\n */\nexport function captureTouchedCheckpoint(graph: SceneGraph): TouchedCheckpoint {\n const nodeRefs = new Map(graph.nodes)\n const variableRefs = new Map(graph.variables)\n const collectionRefs = new Map(graph.variableCollections)\n const saved = structuredClone({\n variables: graph.variables,\n variableCollections: graph.variableCollections,\n activeMode: graph.activeMode,\n instanceIndex: graph.instanceIndex,\n enabledLibraries: graph.enabledLibraries\n })\n // Property edits cannot edit assets. Retain existing buffers, not copies of every bitmap.\n const images = new Map(graph.images)\n const { rootId, figKiwiVersion, figSchemaDeflated, documentColorSpace } = graph\n const nodes = new Map<string, SceneNode>()\n const reported = new Set<string>()\n const created = new Set<string>()\n const impact = createSceneMutationImpact()\n\n /** Copies a node as the edit found it: the original object, should the edit have replaced it. */\n function copy(node: SceneNode) {\n nodes.set(node.id, structuredClone(nodeRefs.get(node.id) ?? node))\n }\n\n const skipped = (node: SceneNode) => nodes.has(node.id) || created.has(node.id)\n\n /**\n * Copies `node` and each ancestor not copied yet, up to but excluding its page. An ancestor\n * copied already had its own ancestors copied with it, so the walk stops there.\n */\n function copyLineage(node: SceneNode) {\n if (skipped(node)) return\n copy(node)\n if (!node.parentId) return\n graph.closest(node.parentId, (ancestor) => {\n if (ancestor.type === 'CANVAS' || ancestor.id === rootId || skipped(ancestor)) return true\n copy(ancestor)\n return false\n })\n }\n\n const unobserve = graph.observeNodeChanges({\n created: (node) => {\n created.add(node.id)\n reported.add(node.id)\n },\n before: (node) => {\n reported.add(node.id)\n copyLineage(node)\n }\n })\n const unbindEvents = recordSceneMutations(graph, impact)\n let observing = true\n\n function stop() {\n if (!observing) return\n observing = false\n unobserve()\n unbindEvents()\n }\n\n function assertNodes() {\n if (\n created.size > 0 ||\n impact.deletedNodeIds.size > 0 ||\n graph.nodes.size !== nodeRefs.size ||\n graph.variables.size !== variableRefs.size\n )\n throw new Error(NODE_COUNT_ERROR)\n for (const [id, node] of graph.nodes) {\n const original = nodeRefs.get(id)\n if (!original) throw new Error(NODE_COUNT_ERROR)\n if (original !== node) throw new Error(NODE_IDENTITY_ERROR)\n }\n for (const [id, before] of nodes) {\n const after = graph.nodes.get(id)\n if (\n !after ||\n before.id !== after.id ||\n before.type !== after.type ||\n before.parentId !== after.parentId ||\n before.componentId !== after.componentId ||\n !isEqual(before.childIds, after.childIds)\n )\n throw new Error(NODE_IDENTITY_ERROR)\n }\n for (const id of [\n ...impact.changedNodeIds,\n ...impact.previousParentIds,\n ...impact.currentParentIds\n ]) {\n if (!nodes.has(id) && !created.has(id)) {\n throw new Error(\n `Atomic tools must report layer changes to the scene graph (SceneGraph.willChangeNode): ${id}`\n )\n }\n }\n }\n\n function assertPropertiesOnly() {\n assertNodes()\n for (const [id, before] of saved.variables) {\n const after = graph.variables.get(id)\n if (\n !after ||\n after !== variableRefs.get(id) ||\n before.id !== after.id ||\n before.collectionId !== after.collectionId ||\n before.type !== after.type\n )\n throw new Error(VARIABLE_IDENTITY_ERROR)\n }\n if (\n !isEqual(saved.variableCollections, graph.variableCollections) ||\n !isEqual(saved.activeMode, graph.activeMode) ||\n !isEqual(saved.instanceIndex, graph.instanceIndex) ||\n !isEqual(saved.enabledLibraries, graph.enabledLibraries) ||\n images.size !== graph.images.size ||\n [...images].some(([id, bytes]) => graph.images.get(id) !== bytes) ||\n graph.rootId !== rootId ||\n graph.documentColorSpace !== documentColorSpace ||\n graph.figKiwiVersion !== figKiwiVersion ||\n // Every writer assigns a new schema rather than writing into it.\n graph.figSchemaDeflated !== figSchemaDeflated\n )\n throw new Error(DOCUMENT_ERROR)\n }\n\n /** Puts the node map back as it was, in its order, if the edit changed its entries. */\n function restoreNodeMap(): { removed: Map<string, SceneNode>; readded: Set<string> } {\n const removed = new Map<string, SceneNode>()\n const readded = new Set<string>()\n let changed = graph.nodes.size !== nodeRefs.size\n if (!changed) {\n // In lockstep, so a node removed and set again, which moves to the end, is put back too.\n const live = graph.nodes.entries()\n for (const [id, node] of nodeRefs) {\n const next = live.next()\n if (next.done || next.value[0] !== id || next.value[1] !== node) {\n changed = true\n break\n }\n }\n }\n if (!changed) return { removed, readded }\n const failed = new Map(graph.nodes)\n graph.nodes.clear()\n for (const [id, node] of nodeRefs) {\n graph.nodes.set(id, node)\n if (!failed.has(id)) readded.add(id)\n }\n for (const [id, node] of failed) if (!nodeRefs.has(id)) removed.set(id, node)\n return { removed, readded }\n }\n\n function restore() {\n stop()\n const { removed, readded } = restoreNodeMap()\n for (const [id, copy] of nodes) {\n const original = nodeRefs.get(id)\n if (!original) continue\n for (const key of Object.keys(original)) {\n if (!Object.hasOwn(copy, key)) Reflect.deleteProperty(original, key)\n }\n Object.assign(original, structuredClone(copy))\n }\n restoreObjects(graph.variables, saved.variables, variableRefs)\n restoreObjects(graph.variableCollections, saved.variableCollections, collectionRefs)\n restoreMap(graph.activeMode, structuredClone(saved.activeMode))\n restoreMap(graph.instanceIndex, structuredClone(saved.instanceIndex))\n restoreMap(graph.enabledLibraries, structuredClone(saved.enabledLibraries))\n restoreMap(graph.images, images)\n graph.rootId = rootId\n graph.figKiwiVersion = figKiwiVersion\n graph.figSchemaDeflated = figSchemaDeflated\n graph.documentColorSpace = documentColorSpace\n graph.clearAbsPosCache()\n const touched = new Set([\n ...nodes.keys(),\n ...created,\n ...readded,\n ...removed.keys(),\n ...impact.changedNodeIds,\n ...impact.previousParentIds,\n ...impact.currentParentIds\n ])\n for (const id of touched) {\n if (graph.nodes.get(id)?.type === 'CONNECTOR') graph.connectorIds.add(id)\n else graph.connectorIds.delete(id)\n }\n // Notify consumers only after the complete hierarchy and indexes have been restored.\n for (const [id, node] of removed) graph.emitter.emit('node:deleted', id, node.parentId)\n for (const id of touched) {\n const node = graph.nodes.get(id)\n if (!node) continue\n if (readded.has(id)) graph.emitter.emit('node:created', node)\n else graph.emitter.emit('node:updated', id, node)\n }\n }\n\n return {\n nodes,\n reported,\n variables: saved.variables,\n variableCollections: saved.variableCollections,\n assertPropertiesOnly,\n restore,\n stop\n }\n}\n"],"mappings":";;;AAMA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,iBAAiB;;AAGvB,SAAgB,uBAAuB,OAAmB;CACxD,MAAM,WAAW,IAAI,IAAI,MAAM,KAAK;CACpC,MAAM,eAAe,IAAI,IAAI,MAAM,SAAS;CAC5C,MAAM,iBAAiB,IAAI,IAAI,MAAM,mBAAmB;CACxD,MAAM,WAAW,gBAAgB;EAC/B,OAAO,MAAM;EACb,WAAW,MAAM;EACjB,qBAAqB,MAAM;EAC3B,YAAY,MAAM;EAClB,eAAe,MAAM;EACrB,kBAAkB,MAAM;EACxB,QAAQ,MAAM;EACd,gBAAgB,MAAM;EACtB,mBAAmB,MAAM;EACzB,oBAAoB,MAAM;CAC5B,CAAC;CAED,MAAM,SAAS,IAAI,IAAI,MAAM,MAAM;CAEnC,SAAS,uBAAuB;EAC9B,IACE,SAAS,MAAM,SAAS,MAAM,MAAM,QACpC,SAAS,UAAU,SAAS,MAAM,UAAU,MAE5C,MAAM,IAAI,MAAM,gBAAgB;EAClC,KAAK,MAAM,CAAC,IAAI,WAAW,SAAS,OAAO;GACzC,MAAM,QAAQ,MAAM,MAAM,IAAI,EAAE;GAChC,IACE,CAAC,SACD,UAAU,SAAS,IAAI,EAAE,KACzB,OAAO,O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,MAAM;EAC3B;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Vector } from "./primitives/index.js";
|
|
2
|
+
import { VisualBounds } from "./geometry.js";
|
|
3
|
+
//#region src/clipping.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Clip a subject polygon against a convex polygon (e.g. the 4 canvas-space
|
|
6
|
+
* corners of a rotated clipping ancestor).
|
|
7
|
+
*
|
|
8
|
+
* Uses Sutherland–Hodgman polygon clipping with centroid-based interior
|
|
9
|
+
* detection, making it robust to either winding order of the clip polygon.
|
|
10
|
+
* Returns the clipped polygon, or null if the subject is fully outside the
|
|
11
|
+
* clip polygon. When `clipCorners` has fewer than 3 points the subject is
|
|
12
|
+
* returned unchanged (no clipping).
|
|
13
|
+
*
|
|
14
|
+
* Preserving the polygon (rather than collapsing to an AABB) lets callers
|
|
15
|
+
* chain multiple clips without reintroducing corners removed by an inner clip.
|
|
16
|
+
*/
|
|
17
|
+
declare function clipPolygon(subject: Vector[], clipCorners: Vector[]): Vector[] | null;
|
|
18
|
+
/**
|
|
19
|
+
* Clip an axis-aligned VisualBounds rectangle against a convex polygon
|
|
20
|
+
* (e.g. the 4 canvas-space corners of a rotated clipping ancestor).
|
|
21
|
+
*
|
|
22
|
+
* Returns the AABB of the intersection, or null if the bounds are fully
|
|
23
|
+
* outside the clip polygon. Delegates to {@link clipPolygon}.
|
|
24
|
+
*
|
|
25
|
+
* For a non-rotated clip (axis-aligned corners) the result is identical
|
|
26
|
+
* to `intersectVisualBounds`.
|
|
27
|
+
*/
|
|
28
|
+
declare function clipBoundsToPolygon(bounds: VisualBounds, clipCorners: Vector[]): VisualBounds | null;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { clipBoundsToPolygon, clipPolygon };
|
|
31
|
+
//# sourceMappingURL=clipping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipping.d.ts","names":[],"sources":["../src/clipping.ts"],"mappings":";;;;;;;;;;;;;;;;iBAyDgB,YAAY,SAAS,UAAU,aAAa,WAAW;;;;;;;;;;;iBAmCvD,oBACd,QAAQ,cACR,aAAa,WACZ"}
|
package/dist/clipping.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { computeBounds } from "./geometry.js";
|
|
2
|
+
//#region src/clipping.ts
|
|
3
|
+
/**
|
|
4
|
+
* Rotated-rectangle clipping: a polygon or an axis-aligned box cut by a convex polygon, such as
|
|
5
|
+
* the canvas corners of a rotated frame that clips its content.
|
|
6
|
+
*/
|
|
7
|
+
function crossProduct(a, b, p) {
|
|
8
|
+
return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x);
|
|
9
|
+
}
|
|
10
|
+
function lineSegmentIntersect(p1, p2, p3, p4) {
|
|
11
|
+
const dx1 = p2.x - p1.x;
|
|
12
|
+
const dy1 = p2.y - p1.y;
|
|
13
|
+
const dx2 = p4.x - p3.x;
|
|
14
|
+
const dy2 = p4.y - p3.y;
|
|
15
|
+
const denom = dx1 * dy2 - dy1 * dx2;
|
|
16
|
+
if (denom === 0) return p1;
|
|
17
|
+
const t = ((p3.x - p1.x) * dy2 - (p3.y - p1.y) * dx2) / denom;
|
|
18
|
+
return {
|
|
19
|
+
x: p1.x + t * dx1,
|
|
20
|
+
y: p1.y + t * dy1
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function clipHalfPlane(polygon, a, b, wantPositive) {
|
|
24
|
+
const output = [];
|
|
25
|
+
const isInside = (p) => {
|
|
26
|
+
const cross = crossProduct(a, b, p);
|
|
27
|
+
return wantPositive ? cross >= 0 : cross <= 0;
|
|
28
|
+
};
|
|
29
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
30
|
+
const curr = polygon[i];
|
|
31
|
+
const prev = polygon[i === 0 ? polygon.length - 1 : i - 1];
|
|
32
|
+
const currInside = isInside(curr);
|
|
33
|
+
const prevInside = isInside(prev);
|
|
34
|
+
if (currInside) {
|
|
35
|
+
if (!prevInside) output.push(lineSegmentIntersect(prev, curr, a, b));
|
|
36
|
+
output.push(curr);
|
|
37
|
+
} else if (prevInside) output.push(lineSegmentIntersect(prev, curr, a, b));
|
|
38
|
+
}
|
|
39
|
+
return output;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Clip a subject polygon against a convex polygon (e.g. the 4 canvas-space
|
|
43
|
+
* corners of a rotated clipping ancestor).
|
|
44
|
+
*
|
|
45
|
+
* Uses Sutherland–Hodgman polygon clipping with centroid-based interior
|
|
46
|
+
* detection, making it robust to either winding order of the clip polygon.
|
|
47
|
+
* Returns the clipped polygon, or null if the subject is fully outside the
|
|
48
|
+
* clip polygon. When `clipCorners` has fewer than 3 points the subject is
|
|
49
|
+
* returned unchanged (no clipping).
|
|
50
|
+
*
|
|
51
|
+
* Preserving the polygon (rather than collapsing to an AABB) lets callers
|
|
52
|
+
* chain multiple clips without reintroducing corners removed by an inner clip.
|
|
53
|
+
*/
|
|
54
|
+
function clipPolygon(subject, clipCorners) {
|
|
55
|
+
if (clipCorners.length < 3) return subject;
|
|
56
|
+
let cx = 0;
|
|
57
|
+
let cy = 0;
|
|
58
|
+
for (const c of clipCorners) {
|
|
59
|
+
cx += c.x;
|
|
60
|
+
cy += c.y;
|
|
61
|
+
}
|
|
62
|
+
cx /= clipCorners.length;
|
|
63
|
+
cy /= clipCorners.length;
|
|
64
|
+
let polygon = subject;
|
|
65
|
+
for (let i = 0; i < clipCorners.length; i++) {
|
|
66
|
+
if (polygon.length === 0) return null;
|
|
67
|
+
const a = clipCorners[i];
|
|
68
|
+
const b = clipCorners[(i + 1) % clipCorners.length];
|
|
69
|
+
const centroidCross = crossProduct(a, b, {
|
|
70
|
+
x: cx,
|
|
71
|
+
y: cy
|
|
72
|
+
});
|
|
73
|
+
polygon = clipHalfPlane(polygon, a, b, centroidCross >= 0);
|
|
74
|
+
}
|
|
75
|
+
return polygon.length === 0 ? null : polygon;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Clip an axis-aligned VisualBounds rectangle against a convex polygon
|
|
79
|
+
* (e.g. the 4 canvas-space corners of a rotated clipping ancestor).
|
|
80
|
+
*
|
|
81
|
+
* Returns the AABB of the intersection, or null if the bounds are fully
|
|
82
|
+
* outside the clip polygon. Delegates to {@link clipPolygon}.
|
|
83
|
+
*
|
|
84
|
+
* For a non-rotated clip (axis-aligned corners) the result is identical
|
|
85
|
+
* to `intersectVisualBounds`.
|
|
86
|
+
*/
|
|
87
|
+
function clipBoundsToPolygon(bounds, clipCorners) {
|
|
88
|
+
if (clipCorners.length < 3) return bounds;
|
|
89
|
+
const polygon = clipPolygon([
|
|
90
|
+
{
|
|
91
|
+
x: bounds.minX,
|
|
92
|
+
y: bounds.minY
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
x: bounds.maxX,
|
|
96
|
+
y: bounds.minY
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
x: bounds.maxX,
|
|
100
|
+
y: bounds.maxY
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
x: bounds.minX,
|
|
104
|
+
y: bounds.maxY
|
|
105
|
+
}
|
|
106
|
+
], clipCorners);
|
|
107
|
+
if (!polygon) return null;
|
|
108
|
+
const box = computeBounds(polygon.map(({ x, y }) => ({
|
|
109
|
+
x,
|
|
110
|
+
y,
|
|
111
|
+
width: 0,
|
|
112
|
+
height: 0
|
|
113
|
+
})));
|
|
114
|
+
if (box.width <= 0 || box.height <= 0) return null;
|
|
115
|
+
return {
|
|
116
|
+
minX: box.x,
|
|
117
|
+
minY: box.y,
|
|
118
|
+
maxX: box.x + box.width,
|
|
119
|
+
maxY: box.y + box.height
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { clipBoundsToPolygon, clipPolygon };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=clipping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipping.js","names":[],"sources":["../src/clipping.ts"],"sourcesContent":["import { computeBounds, type VisualBounds } from './geometry'\nimport type { Vector } from './primitives'\n\n/**\n * Rotated-rectangle clipping: a polygon or an axis-aligned box cut by a convex polygon, such as\n * the canvas corners of a rotated frame that clips its content.\n */\n\nfunction crossProduct(a: Vector, b: Vector, p: Vector): number {\n return (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x)\n}\n\nfunction lineSegmentIntersect(p1: Vector, p2: Vector, p3: Vector, p4: Vector): Vector {\n const dx1 = p2.x - p1.x\n const dy1 = p2.y - p1.y\n const dx2 = p4.x - p3.x\n const dy2 = p4.y - p3.y\n const denom = dx1 * dy2 - dy1 * dx2\n if (denom === 0) return p1\n const t = ((p3.x - p1.x) * dy2 - (p3.y - p1.y) * dx2) / denom\n return { x: p1.x + t * dx1, y: p1.y + t * dy1 }\n}\n\nfunction clipHalfPlane(polygon: Vector[], a: Vector, b: Vector, wantPositive: boolean): Vector[] {\n const output: Vector[] = []\n const isInside = (p: Vector): boolean => {\n const cross = crossProduct(a, b, p)\n return wantPositive ? cross >= 0 : cross <= 0\n }\n for (let i = 0; i < polygon.length; i++) {\n const curr = polygon[i]\n const prev = polygon[i === 0 ? polygon.length - 1 : i - 1]\n const currInside = isInside(curr)\n const prevInside = isInside(prev)\n if (currInside) {\n if (!prevInside) output.push(lineSegmentIntersect(prev, curr, a, b))\n output.push(curr)\n } else if (prevInside) {\n output.push(lineSegmentIntersect(prev, curr, a, b))\n }\n }\n return output\n}\n\n/**\n * Clip a subject polygon against a convex polygon (e.g. the 4 canvas-space\n * corners of a rotated clipping ancestor).\n *\n * Uses Sutherland–Hodgman polygon clipping with centroid-based interior\n * detection, making it robust to either winding order of the clip polygon.\n * Returns the clipped polygon, or null if the subject is fully outside the\n * clip polygon. When `clipCorners` has fewer than 3 points the subject is\n * returned unchanged (no clipping).\n *\n * Preserving the polygon (rather than collapsing to an AABB) lets callers\n * chain multiple clips without reintroducing corners removed by an inner clip.\n */\nexport function clipPolygon(subject: Vector[], clipCorners: Vector[]): Vector[] | null {\n if (clipCorners.length < 3) return subject\n\n let cx = 0\n let cy = 0\n for (const c of clipCorners) {\n cx += c.x\n cy += c.y\n }\n cx /= clipCorners.length\n cy /= clipCorners.length\n\n let polygon: Vector[] = subject\n\n for (let i = 0; i < clipCorners.length; i++) {\n if (polygon.length === 0) return null\n const a = clipCorners[i]\n const b = clipCorners[(i + 1) % clipCorners.length]\n const centroidCross = crossProduct(a, b, { x: cx, y: cy })\n polygon = clipHalfPlane(polygon, a, b, centroidCross >= 0)\n }\n\n return polygon.length === 0 ? null : polygon\n}\n\n/**\n * Clip an axis-aligned VisualBounds rectangle against a convex polygon\n * (e.g. the 4 canvas-space corners of a rotated clipping ancestor).\n *\n * Returns the AABB of the intersection, or null if the bounds are fully\n * outside the clip polygon. Delegates to {@link clipPolygon}.\n *\n * For a non-rotated clip (axis-aligned corners) the result is identical\n * to `intersectVisualBounds`.\n */\nexport function clipBoundsToPolygon(\n bounds: VisualBounds,\n clipCorners: Vector[]\n): VisualBounds | null {\n if (clipCorners.length < 3) return bounds\n\n const subject: Vector[] = [\n { x: bounds.minX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.maxY },\n { x: bounds.minX, y: bounds.maxY }\n ]\n\n const polygon = clipPolygon(subject, clipCorners)\n if (!polygon) return null\n\n const box = computeBounds(polygon.map(({ x, y }) => ({ x, y, width: 0, height: 0 })))\n if (box.width <= 0 || box.height <= 0) return null\n return { minX: box.x, minY: box.y, maxX: box.x + box.width, maxY: box.y + box.height }\n}\n"],"mappings":";;;;;;AAQA,SAAS,aAAa,GAAW,GAAW,GAAmB;CAC7D,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;AAC5D;AAEA,SAAS,qBAAqB,IAAY,IAAY,IAAY,IAAoB;CACpF,MAAM,MAAM,GAAG,IAAI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QAAQ,KAAK;EAC3C,IAAI,QAAQ,WAAW,GAAG,OAAO;EACjC,MAAM,IAAI,YAAY;EACtB,MAAM,IAAI,aAAa,IAAI,KAAK,YAAY;EAC5C,MAAM,gBAAgB,aAAa,GAAG,GAAG;GAAE,GAAG;GAAI,GAAG;EAAG,CAAC;EACzD,UAAU,cAAc,SAAS,GAAG,GAAG,iBAAiB,CAAC;CAC3D;CAEA,OAAO,QAAQ,WAAW,IAAI,OAAO;AACvC;;;;;;;;;;;AAYA,SAAgB,oBACd,QACA,aACqB;CACrB,IAAI,YAAY,SAAS,GAAG,OAAO;CASnC,MAAM,UAAU,YAAY;EAN1B;GAAE,GAAG,OAAO;GAAM,GAAG,OAAO;EAAK;EACjC;GAAE,GAAG,OAAO;GAAM,GAAG,OAAO;EAAK;EACjC;GAAE,GAAG,OAAO;GAAM,GAAG,OAAO;EAAK;EACjC;GAAE,GAAG,OAAO;GAAM,GAAG,OAAO;EAAK;CAGD,GAAG,WAAW;CAChD,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,MAAM,cAAc,QAAQ,KAAK,EAAE,GAAG,SAAS;EAAE;EAAG;EAAG,OAAO;EAAG,QAAQ;CAAE,EAAE,CAAC;CACpF,IAAI,IAAI,SAAS,KAAK,IAAI,UAAU,GAAG,OAAO;CAC9C,OAAO;EAAE,MAAM,IAAI;EAAG,MAAM,IAAI;EAAG,MAAM,IAAI,IAAI,IAAI;EAAO,MAAM,IAAI,IAAI,IAAI;CAAO;AACvF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Color } from "../primitives/index.js";
|
|
2
|
+
//#region src/color/contrast.d.ts
|
|
3
|
+
/** Opaque color seen when `foreground` at `alpha` is drawn over an opaque `background`. */
|
|
4
|
+
declare function compositeOver(foreground: Color, background: Color, alpha?: number): Color;
|
|
5
|
+
/** WCAG 2 contrast ratio of two colors, from 1 to 21; alpha is ignored, so composite first. */
|
|
6
|
+
declare function contrastRatio(a: Pick<Color, 'r' | 'g' | 'b'>, b: Pick<Color, 'r' | 'g' | 'b'>): number;
|
|
7
|
+
/**
|
|
8
|
+
* `background` darkened just enough for light `text` to reach `ratio` on it, by scaling its
|
|
9
|
+
* channels toward black, which keeps its hue; returned as it is when the text already does.
|
|
10
|
+
* The default is white text at WCAG AA's 4.5:1 for normal text.
|
|
11
|
+
*/
|
|
12
|
+
declare function darkenForContrast(background: Color, text?: Pick<Color, 'r' | 'g' | 'b'>, ratio?: number): Color;
|
|
13
|
+
/** Black or white, whichever reads better on an opaque `background`. */
|
|
14
|
+
declare function readableForeground(background: Pick<Color, 'r' | 'g' | 'b'>): Color;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { compositeOver, contrastRatio, darkenForContrast, readableForeground };
|
|
17
|
+
//# sourceMappingURL=contrast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.d.ts","names":[],"sources":["../../src/color/contrast.ts"],"mappings":";;;iBAMgB,cAAc,YAAY,OAAO,YAAY,OAAO,iBAAuB;;iBAW3E,cACd,GAAG,KAAK,yBACR,GAAG,KAAK;;;;;;iBAaM,kBACd,YAAY,OACZ,OAAM,KAAK,yBACX,iBACC;;iBAoBa,mBAAmB,YAAY,KAAK,0BAA0B"}
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
+
import { BLACK, WHITE } from "../constants.js";
|
|
1
2
|
import { wcagContrast } from "culori";
|
|
2
|
-
//#region src/constants.ts
|
|
3
|
-
const BLACK = {
|
|
4
|
-
r: 0,
|
|
5
|
-
g: 0,
|
|
6
|
-
b: 0,
|
|
7
|
-
a: 1
|
|
8
|
-
};
|
|
9
|
-
const WHITE = {
|
|
10
|
-
r: 1,
|
|
11
|
-
g: 1,
|
|
12
|
-
b: 1,
|
|
13
|
-
a: 1
|
|
14
|
-
};
|
|
15
|
-
const TRANSPARENT = {
|
|
16
|
-
r: 0,
|
|
17
|
-
g: 0,
|
|
18
|
-
b: 0,
|
|
19
|
-
a: 0
|
|
20
|
-
};
|
|
21
|
-
const DEFAULT_FONT_FAMILY = "Inter";
|
|
22
|
-
const DEFAULT_STROKE_MITER_LIMIT = 4;
|
|
23
|
-
const DEFAULT_STROKE_WEIGHT = 1;
|
|
24
|
-
//#endregion
|
|
25
3
|
//#region src/color/contrast.ts
|
|
26
4
|
/** Opaque color seen when `foreground` at `alpha` is drawn over an opaque `background`. */
|
|
27
5
|
function compositeOver(foreground, background, alpha = foreground.a) {
|
|
@@ -74,6 +52,6 @@ function readableForeground(background) {
|
|
|
74
52
|
return contrastRatio(background, BLACK) >= contrastRatio(background, WHITE) ? BLACK : WHITE;
|
|
75
53
|
}
|
|
76
54
|
//#endregion
|
|
77
|
-
export {
|
|
55
|
+
export { compositeOver, contrastRatio, darkenForContrast, readableForeground };
|
|
78
56
|
|
|
79
57
|
//# sourceMappingURL=contrast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.js","names":[],"sources":["../../src/color/contrast.ts"],"sourcesContent":["import { wcagContrast } from 'culori'\n\nimport { BLACK, WHITE } from '../constants'\nimport type { Color } from '../primitives'\n\n/** Opaque color seen when `foreground` at `alpha` is drawn over an opaque `background`. */\nexport function compositeOver(foreground: Color, background: Color, alpha = foreground.a): Color {\n const mix = (top: number, bottom: number) => top * alpha + bottom * (1 - alpha)\n return {\n r: mix(foreground.r, background.r),\n g: mix(foreground.g, background.g),\n b: mix(foreground.b, background.b),\n a: 1\n }\n}\n\n/** WCAG 2 contrast ratio of two colors, from 1 to 21; alpha is ignored, so composite first. */\nexport function contrastRatio(\n a: Pick<Color, 'r' | 'g' | 'b'>,\n b: Pick<Color, 'r' | 'g' | 'b'>\n): number {\n return wcagContrast(\n { mode: 'rgb', r: a.r, g: a.g, b: a.b },\n { mode: 'rgb', r: b.r, g: b.g, b: b.b }\n )\n}\n\n/**\n * `background` darkened just enough for light `text` to reach `ratio` on it, by scaling its\n * channels toward black, which keeps its hue; returned as it is when the text already does.\n * The default is white text at WCAG AA's 4.5:1 for normal text.\n */\nexport function darkenForContrast(\n background: Color,\n text: Pick<Color, 'r' | 'g' | 'b'> = WHITE,\n ratio = 4.5\n): Color {\n if (contrastRatio(background, text) >= ratio) return background\n const scaled = (factor: number): Color => ({\n ...background,\n r: background.r * factor,\n g: background.g * factor,\n b: background.b * factor\n })\n // Darker always contrasts more with light text, so the smallest darkening is found by halving.\n let enough = 0\n let short = 1\n for (let step = 0; step < 20; step++) {\n const middle = (enough + short) / 2\n if (contrastRatio(scaled(middle), text) >= ratio) enough = middle\n else short = middle\n }\n return scaled(enough)\n}\n\n/** Black or white, whichever reads better on an opaque `background`. */\nexport function readableForeground(background: Pick<Color, 'r' | 'g' | 'b'>): Color {\n return contrastRatio(background, BLACK) >= contrastRatio(background, WHITE) ? BLACK : WHITE\n}\n"],"mappings":";;;;AAMA,SAAgB,cAAc,YAAmB,YAAmB,QAAQ,WAAW,GAAU;CAC/F,MAAM,OAAO,KAAa,WAAmB,MAAM,QAAQ,UAAU,IAAI;CACzE,OAAO;EACL,GAAG,IAAI,WAAW,GAAG,WAAW,CAAC;EACjC,GAAG,IAAI,WAAW,GAAG,WAAW,CAAC;EACjC,GAAG,IAAI,WAAW,GAAG,WAAW,CAAC;EACjC,GAAG;CACL;AACF;;AAGA,SAAgB,cACd,GACA,GACQ;CACR,OAAO,aACL;EAAE,MAAM;EAAO,GAAG,EAAE;EAAG,GAAG,EAAE;EAAG,GAAG,EAAE;CAAE,GACtC;EAAE,MAAM;EAAO,GAAG,EAAE;EAAG,GAAG,EAAE;EAAG,GAAG,EAAE;CAAE,CACxC;AACF;;;;;;AAOA,SAAgB,kBACd,YACA,OAAqC,OACrC,QAAQ,KACD;CACP,IAAI,cAAc,YAAY,IAAI,KAAK,OAAO,OAAO;CACrD,MAAM,UAAU,YAA2B;EACzC,GAAG;EACH,GAAG,WAAW,IAAI;EAClB,GAAG,WAAW,IAAI;EAClB,GAAG,WAAW,IAAI;CACpB;CAEA,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,KAAK,IAAI,OAAO,GAAG,OAAO,IAAI,QAAQ;EACpC,MAAM,UAAU,SAAS,SAAS;EAClC,IAAI,cAAc,OAAO,MAAM,GAAG,IAAI,KAAK,OAAO,SAAS;OACtD,QAAQ;CACf;CACA,OAAO,OAAO,MAAM;AACtB;;AAGA,SAAgB,mBAAmB,YAAiD;CAClF,OAAO,cAAc,YAAY,KAAK,KAAK,cAAc,YAAY,KAAK,IAAI,QAAQ;AACxF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Color } from "../primitives/index.js";
|
|
2
|
+
import { compositeOver, contrastRatio, darkenForContrast, readableForeground } from "./contrast.js";
|
|
3
|
+
import { OkHCLColor, OkHCLColorSpace, OkHCLPayload, clearNodeFillOkHCL, clearNodeStrokeOkHCL, getFillOkHCL, getNodeOkHCLPayloads, getStrokeOkHCL, okhclToRGBA, parseOkHCLPayload, rgbaToOkHCL, serializeOkHCLPayload, setNodeFillOkHCL, setNodeStrokeOkHCL } from "./okhcl.js";
|
|
4
|
+
import { ColorIntentSpace, ColorPreviewOptions, RenderColorSpace, ResolvedRenderColor, colorToDisplayCSS, getDefaultRenderColorSpace, parseDisplayableColor, resolveNodeFillColor, resolveNodeStrokeColor, resolveOkHCLForPreview, resolveRGBAForPreview } from "./management.js";
|
|
5
|
+
import { normalizeColor } from "./normalize.js";
|
|
6
|
+
import { colorSchema } from "./schema.js";
|
|
7
|
+
//#region src/color/index.d.ts
|
|
8
|
+
/** A CSS color, or null when `input` is not one. */
|
|
9
|
+
declare function tryParseColor(input: string): Color | null;
|
|
10
|
+
/** A CSS color, or black when `input` is not one. */
|
|
11
|
+
declare function parseColor(input: string): Color;
|
|
12
|
+
declare function colorToHex(color: Color): string;
|
|
13
|
+
declare function colorToHex8(color: Color, alpha?: number): string;
|
|
14
|
+
declare function colorToHexRaw(color: Color): string;
|
|
15
|
+
declare function colorToRgba255(color: Color): {
|
|
16
|
+
r: number;
|
|
17
|
+
g: number;
|
|
18
|
+
b: number;
|
|
19
|
+
a: number;
|
|
20
|
+
};
|
|
21
|
+
declare function colorToCSS(color: Color): string;
|
|
22
|
+
declare function colorToCSSCompact(color: Color): string;
|
|
23
|
+
declare function rgba255ToColor(r: number, g: number, b: number, a?: number): Color;
|
|
24
|
+
declare function colorToFill(color: string | Color): {
|
|
25
|
+
type: "SOLID";
|
|
26
|
+
color: {
|
|
27
|
+
r: number;
|
|
28
|
+
g: number;
|
|
29
|
+
b: number;
|
|
30
|
+
a: number;
|
|
31
|
+
};
|
|
32
|
+
opacity: number;
|
|
33
|
+
visible: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare function colorDistance(c1: Color, c2: Color): number;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ColorIntentSpace, ColorPreviewOptions, OkHCLColor, OkHCLColorSpace, OkHCLPayload, RenderColorSpace, ResolvedRenderColor, clearNodeFillOkHCL, clearNodeStrokeOkHCL, colorDistance, colorSchema, colorToCSS, colorToCSSCompact, colorToDisplayCSS, colorToFill, colorToHex, colorToHex8, colorToHexRaw, colorToRgba255, compositeOver, contrastRatio, darkenForContrast, getDefaultRenderColorSpace, getFillOkHCL, getNodeOkHCLPayloads, getStrokeOkHCL, normalizeColor, okhclToRGBA, parseColor, parseDisplayableColor, parseOkHCLPayload, readableForeground, resolveNodeFillColor, resolveNodeStrokeColor, resolveOkHCLForPreview, resolveRGBAForPreview, rgba255ToColor, rgbaToOkHCL, serializeOkHCLPayload, setNodeFillOkHCL, setNodeStrokeOkHCL, tryParseColor };
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/color/index.ts"],"mappings":";;;;;;;;iBAagB,cAAc,gBAAgB;;iBAa9B,WAAW,gBAAgB;iBAI3B,WAAW,OAAO;iBAIlB,YAAY,OAAO,OAAO;iBAM1B,cAAc,OAAO;iBAIrB,eAAe,OAAO;;;;;;iBAStB,WAAW,OAAO;iBAIlB,kBAAkB,OAAO;iBAOzB,eAAe,WAAW,WAAW,WAAW,aAAQ;iBAIxD,YAAY,gBAAgB;;;;;;;;;;;iBAY5B,cAAc,IAAI,OAAO,IAAI"}
|