@open-pencil/scene-graph 0.17.0 → 0.18.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 +14 -17
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +1 -2
- package/dist/asset-keys.d.ts +5 -8
- package/dist/asset-keys.d.ts.map +1 -1
- package/dist/asset-keys.js +2 -3
- package/dist/behaviours/index.d.ts +6 -4
- package/dist/behaviours/index.js +6 -4
- package/dist/behaviours/kinds.d.ts +38 -15
- package/dist/behaviours/kinds.d.ts.map +1 -1
- package/dist/behaviours/kinds.js +134 -12
- package/dist/behaviours/kinds.js.map +1 -1
- package/dist/behaviours/layers.d.ts +3 -6
- package/dist/behaviours/layers.d.ts.map +1 -1
- package/dist/behaviours/layers.js +1 -2
- package/dist/behaviours/listing.d.ts +58 -0
- package/dist/behaviours/listing.d.ts.map +1 -0
- package/dist/behaviours/listing.js +98 -0
- package/dist/behaviours/listing.js.map +1 -0
- package/dist/behaviours/model.d.ts +19 -16
- package/dist/behaviours/model.d.ts.map +1 -1
- package/dist/behaviours/model.js +14 -6
- package/dist/behaviours/model.js.map +1 -1
- package/dist/behaviours/schema.d.ts +150 -17
- package/dist/behaviours/schema.d.ts.map +1 -1
- package/dist/behaviours/schema.js +19 -5
- package/dist/behaviours/schema.js.map +1 -1
- package/dist/behaviours/spec.d.ts +3 -6
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +7 -4
- package/dist/behaviours/spec.js.map +1 -1
- package/dist/behaviours/transition.d.ts +20 -0
- package/dist/behaviours/transition.d.ts.map +1 -0
- package/dist/behaviours/transition.js +35 -0
- package/dist/behaviours/transition.js.map +1 -0
- package/dist/bindings.js +2 -3
- package/dist/blur.d.ts +35 -0
- package/dist/blur.d.ts.map +1 -0
- package/dist/blur.js +69 -0
- package/dist/blur.js.map +1 -0
- package/dist/buffered-events.d.ts +3 -6
- package/dist/buffered-events.d.ts.map +1 -1
- package/dist/buffered-events.js +1 -2
- package/dist/buffered-events.js.map +1 -1
- package/dist/checkpoint.d.ts +3 -6
- package/dist/checkpoint.d.ts.map +1 -1
- package/dist/checkpoint.js +4 -3
- package/dist/checkpoint.js.map +1 -1
- package/dist/clipping.d.ts +4 -7
- package/dist/clipping.d.ts.map +1 -1
- package/dist/clipping.js +4 -16
- package/dist/clipping.js.map +1 -1
- package/dist/color/contrast.d.ts +4 -7
- package/dist/color/contrast.d.ts.map +1 -1
- package/dist/color/contrast.js +2 -3
- package/dist/color/index.d.ts +21 -20
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +16 -27
- package/dist/color/index.js.map +1 -1
- package/dist/color/management.d.ts +50 -25
- package/dist/color/management.d.ts.map +1 -1
- package/dist/color/management.js +155 -151
- package/dist/color/management.js.map +1 -1
- package/dist/color/normalize.d.ts +1 -4
- package/dist/color/normalize.d.ts.map +1 -1
- package/dist/color/normalize.js +1 -2
- package/dist/color/okhcl.d.ts +36 -21
- package/dist/color/okhcl.d.ts.map +1 -1
- package/dist/color/okhcl.js +57 -42
- package/dist/color/okhcl.js.map +1 -1
- package/dist/color/schema.d.ts +6 -4
- package/dist/color/schema.d.ts.map +1 -1
- package/dist/color/schema.js +12 -4
- package/dist/color/schema.js.map +1 -1
- package/dist/comments/document.d.ts +3 -6
- package/dist/comments/document.d.ts.map +1 -1
- package/dist/comments/document.js +1 -2
- package/dist/comments/index.js +2 -2
- package/dist/comments/list.d.ts +5 -8
- package/dist/comments/list.d.ts.map +1 -1
- package/dist/comments/list.js +1 -2
- package/dist/comments/merge.d.ts +2 -5
- package/dist/comments/merge.d.ts.map +1 -1
- package/dist/comments/merge.js +1 -2
- package/dist/comments/schema.d.ts +2 -5
- package/dist/comments/schema.d.ts.map +1 -1
- package/dist/comments/schema.js +1 -2
- package/dist/comments/threads.d.ts +16 -19
- package/dist/comments/threads.d.ts.map +1 -1
- package/dist/comments/threads.js +8 -3
- package/dist/comments/threads.js.map +1 -1
- package/dist/components/exposure.d.ts +4 -7
- package/dist/components/exposure.d.ts.map +1 -1
- package/dist/components/exposure.js +1 -2
- package/dist/components/properties.d.ts +13 -16
- package/dist/components/properties.d.ts.map +1 -1
- package/dist/components/properties.js +3 -4
- package/dist/components/variants.d.ts +5 -8
- package/dist/components/variants.d.ts.map +1 -1
- package/dist/components/variants.js +1 -2
- package/dist/connectors/controls.d.ts +6 -9
- package/dist/connectors/controls.d.ts.map +1 -1
- package/dist/connectors/controls.js +2 -3
- package/dist/connectors/create.d.ts +3 -6
- package/dist/connectors/create.d.ts.map +1 -1
- package/dist/connectors/create.js +2 -3
- package/dist/connectors/elbow.js +0 -1
- package/dist/connectors/gaps.d.ts +1 -4
- package/dist/connectors/gaps.d.ts.map +1 -1
- package/dist/connectors/gaps.js +1 -2
- package/dist/connectors/hit.d.ts +1 -4
- package/dist/connectors/hit.d.ts.map +1 -1
- package/dist/connectors/hit.js +3 -4
- package/dist/connectors/index.d.ts +3 -3
- package/dist/connectors/index.js +6 -6
- package/dist/connectors/label.d.ts +4 -7
- package/dist/connectors/label.d.ts.map +1 -1
- package/dist/connectors/label.js +1 -2
- package/dist/connectors/layout.d.ts +8 -10
- package/dist/connectors/layout.d.ts.map +1 -1
- package/dist/connectors/layout.js +12 -10
- package/dist/connectors/layout.js.map +1 -1
- package/dist/connectors/pieces.d.ts +2 -5
- package/dist/connectors/pieces.d.ts.map +1 -1
- package/dist/connectors/pieces.js +3 -4
- package/dist/connectors/pieces.js.map +1 -1
- package/dist/connectors/route.d.ts +2 -5
- package/dist/connectors/route.d.ts.map +1 -1
- package/dist/connectors/route.js +4 -5
- package/dist/connectors/sides.d.ts +3 -6
- package/dist/connectors/sides.d.ts.map +1 -1
- package/dist/connectors/sides.js +2 -3
- package/dist/connectors/sublayers.d.ts +21 -24
- package/dist/connectors/sublayers.d.ts.map +1 -1
- package/dist/connectors/sublayers.js +3 -3
- package/dist/connectors/sublayers.js.map +1 -1
- package/dist/constants.d.ts +13 -16
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/constraints.d.ts +6 -8
- package/dist/constraints.d.ts.map +1 -1
- package/dist/constraints.js +3 -3
- package/dist/constraints.js.map +1 -1
- package/dist/coordinate.d.ts +27 -29
- package/dist/coordinate.d.ts.map +1 -1
- package/dist/coordinate.js +19 -38
- package/dist/coordinate.js.map +1 -1
- package/dist/copy.d.ts +36 -24
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +33 -4
- package/dist/copy.js.map +1 -1
- package/dist/corners.d.ts +9 -9
- package/dist/corners.d.ts.map +1 -1
- package/dist/corners.js +4 -3
- package/dist/corners.js.map +1 -1
- package/dist/css/blend.d.ts +1 -4
- package/dist/css/blend.d.ts.map +1 -1
- package/dist/css/blend.js +1 -2
- package/dist/css/grid.d.ts +1 -4
- package/dist/css/grid.d.ts.map +1 -1
- package/dist/css/grid.js +3 -4
- package/dist/css/index.d.ts +2 -1
- package/dist/css/index.js +3 -2
- package/dist/css/layout.d.ts +7 -10
- package/dist/css/layout.d.ts.map +1 -1
- package/dist/css/layout.js +2 -3
- package/dist/css/motion.d.ts +9 -0
- package/dist/css/motion.d.ts.map +1 -0
- package/dist/css/motion.js +59 -0
- package/dist/css/motion.js.map +1 -0
- package/dist/css/shadows.d.ts +4 -6
- package/dist/css/shadows.d.ts.map +1 -1
- package/dist/css/shadows.js +9 -9
- package/dist/css/shadows.js.map +1 -1
- package/dist/css/text.d.ts +8 -11
- package/dist/css/text.d.ts.map +1 -1
- package/dist/css/text.js +1 -2
- package/dist/css/transform.d.ts +6 -9
- package/dist/css/transform.d.ts.map +1 -1
- package/dist/css/transform.js +2 -3
- package/dist/css/values.d.ts +11 -13
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +5 -6
- package/dist/css/values.js.map +1 -1
- package/dist/cubic.d.ts +11 -5
- package/dist/cubic.d.ts.map +1 -1
- package/dist/cubic.js +71 -3
- package/dist/cubic.js.map +1 -1
- package/dist/events.js +1 -2
- package/dist/export-format.d.ts +5 -8
- package/dist/export-format.d.ts.map +1 -1
- package/dist/export-format.js +4 -3
- package/dist/export-format.js.map +1 -1
- package/dist/export-scale.d.ts +4 -7
- package/dist/export-scale.d.ts.map +1 -1
- package/dist/export-scale.js +1 -2
- package/dist/fields/appearance.d.ts +3 -6
- package/dist/fields/appearance.d.ts.map +1 -1
- package/dist/fields/appearance.js +1 -2
- package/dist/fields/geometry.d.ts +2 -5
- package/dist/fields/geometry.d.ts.map +1 -1
- package/dist/fields/geometry.js +1 -2
- package/dist/fields/index.d.ts +2 -2
- package/dist/fields/index.js +3 -3
- package/dist/fields/layout.d.ts +5 -6
- package/dist/fields/layout.d.ts.map +1 -1
- package/dist/fields/layout.js +10 -3
- package/dist/fields/layout.js.map +1 -1
- package/dist/fields/text.d.ts +5 -8
- package/dist/fields/text.d.ts.map +1 -1
- package/dist/fields/text.js +1 -2
- package/dist/fig-compression.d.ts +3 -6
- package/dist/fig-compression.d.ts.map +1 -1
- package/dist/fig-compression.js +1 -2
- package/dist/figjam/index.js +1 -1
- package/dist/figjam/palette.d.ts +21 -23
- package/dist/figjam/palette.d.ts.map +1 -1
- package/dist/figjam/palette.js +3 -4
- package/dist/figjam/text.d.ts +10 -13
- package/dist/figjam/text.d.ts.map +1 -1
- package/dist/figjam/text.js +1 -2
- package/dist/font-style.d.ts +18 -18
- package/dist/font-style.d.ts.map +1 -1
- package/dist/font-style.js +12 -8
- package/dist/font-style.js.map +1 -1
- package/dist/generated/index.d.ts +35 -15
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +50 -12
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/kind.d.ts +17 -6
- package/dist/generated/kind.d.ts.map +1 -1
- package/dist/generated/shape-with-text.d.ts +10 -13
- package/dist/generated/shape-with-text.d.ts.map +1 -1
- package/dist/generated/shape-with-text.js +3 -3
- package/dist/generated/shape-with-text.js.map +1 -1
- package/dist/generated/spec.d.ts +45 -0
- package/dist/generated/spec.d.ts.map +1 -0
- package/dist/generated/spec.js +281 -0
- package/dist/generated/spec.js.map +1 -0
- package/dist/generated/sticky.d.ts +23 -26
- package/dist/generated/sticky.d.ts.map +1 -1
- package/dist/generated/sticky.js +4 -4
- package/dist/generated/sticky.js.map +1 -1
- package/dist/geometry.d.ts +47 -68
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +53 -77
- package/dist/geometry.js.map +1 -1
- package/dist/gradient.d.ts +15 -18
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +1 -2
- package/dist/graph.d.ts +33 -11
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +85 -28
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +15 -14
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +41 -12
- package/dist/group-bounds.js.map +1 -1
- package/dist/guides.d.ts +5 -8
- package/dist/guides.d.ts.map +1 -1
- package/dist/guides.js +2 -3
- package/dist/hit-test.d.ts +20 -12
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +69 -38
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/fit.d.ts +2 -4
- package/dist/icons/fit.d.ts.map +1 -1
- package/dist/icons/fit.js +1 -2
- package/dist/icons/glyph.d.ts +3 -5
- package/dist/icons/glyph.d.ts.map +1 -1
- package/dist/icons/glyph.js +3 -4
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +2 -2
- package/dist/icons/model.d.ts +8 -11
- package/dist/icons/model.d.ts.map +1 -1
- package/dist/icons/model.js +1 -2
- package/dist/icons/schema.d.ts +8 -11
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +1 -2
- package/dist/ids.d.ts +2 -5
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +3 -4
- package/dist/images.d.ts +20 -21
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +7 -6
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/instances/assignments.js +1 -2
- package/dist/instances/content-marks.js +98 -0
- package/dist/instances/content-marks.js.map +1 -0
- package/dist/instances/content-size.js +2 -3
- package/dist/instances/copies.js +2 -3
- package/dist/instances/cycles.d.ts +3 -6
- package/dist/instances/cycles.d.ts.map +1 -1
- package/dist/instances/cycles.js +1 -2
- package/dist/instances/deleted.d.ts +23 -0
- package/dist/instances/deleted.d.ts.map +1 -0
- package/dist/instances/deleted.js +82 -0
- package/dist/instances/deleted.js.map +1 -0
- package/dist/instances/fields.d.ts +5 -8
- package/dist/instances/fields.d.ts.map +1 -1
- package/dist/instances/fields.js +11 -7
- package/dist/instances/fields.js.map +1 -1
- package/dist/instances/index.d.ts +21 -20
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +116 -20
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/kept-overrides.js +4 -5
- package/dist/instances/lookup.d.ts +17 -0
- package/dist/instances/lookup.d.ts.map +1 -0
- package/dist/instances/lookup.js +48 -0
- package/dist/instances/lookup.js.map +1 -0
- package/dist/instances/main-component.d.ts +2 -5
- package/dist/instances/main-component.d.ts.map +1 -1
- package/dist/instances/main-component.js +1 -2
- package/dist/instances/matching.js +1 -2
- package/dist/instances/overrides.d.ts +23 -26
- package/dist/instances/overrides.d.ts.map +1 -1
- package/dist/instances/overrides.js +1 -2
- package/dist/instances/placement.js +3 -4
- package/dist/instances/protection.js +3 -4
- package/dist/instances/source-walk.js +1 -2
- package/dist/instances/swap.js +7 -8
- package/dist/instances/sync.js +91 -18
- package/dist/instances/sync.js.map +1 -1
- package/dist/instances/vector-geometry.js +2 -3
- package/dist/layout/aspect-ratio.d.ts +7 -9
- package/dist/layout/aspect-ratio.d.ts.map +1 -1
- package/dist/layout/aspect-ratio.js +1 -2
- package/dist/layout/flow.d.ts +13 -0
- package/dist/layout/flow.d.ts.map +1 -0
- package/dist/layout/flow.js +35 -0
- package/dist/layout/flow.js.map +1 -0
- package/dist/layout/guides.d.ts +13 -16
- package/dist/layout/guides.d.ts.map +1 -1
- package/dist/layout/guides.js +4 -5
- package/dist/layout/guides.js.map +1 -1
- package/dist/layout/index.d.ts +6 -4
- package/dist/layout/index.js +7 -5
- package/dist/layout/keywords.d.ts +7 -9
- package/dist/layout/keywords.d.ts.map +1 -1
- package/dist/layout/keywords.js +8 -3
- package/dist/layout/keywords.js.map +1 -1
- package/dist/layout/limits.d.ts +13 -16
- package/dist/layout/limits.d.ts.map +1 -1
- package/dist/layout/limits.js +1 -2
- package/dist/layout/sizing.d.ts +18 -12
- package/dist/layout/sizing.d.ts.map +1 -1
- package/dist/layout/sizing.js +18 -3
- package/dist/layout/sizing.js.map +1 -1
- package/dist/layout/spacing.d.ts +7 -4
- package/dist/layout/spacing.d.ts.map +1 -1
- package/dist/layout/spacing.js +11 -3
- package/dist/layout/spacing.js.map +1 -1
- package/dist/layout/stacking.d.ts +8 -0
- package/dist/layout/stacking.d.ts.map +1 -0
- package/dist/layout/stacking.js +12 -0
- package/dist/layout/stacking.js.map +1 -0
- package/dist/layout/strokes.d.ts +1 -4
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +1 -2
- package/dist/layout/writes.js +1 -2
- package/dist/layout/writes.js.map +1 -1
- package/dist/masks.d.ts +4 -7
- package/dist/masks.d.ts.map +1 -1
- package/dist/masks.js +1 -2
- package/dist/matrix.d.ts +3 -4
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +11 -3
- package/dist/matrix.js.map +1 -1
- package/dist/mesh/geometry.d.ts +80 -0
- package/dist/mesh/geometry.d.ts.map +1 -0
- package/dist/mesh/geometry.js +430 -0
- package/dist/mesh/geometry.js.map +1 -0
- package/dist/mesh/index.d.ts +4 -0
- package/dist/mesh/index.js +4 -0
- package/dist/mesh/model.d.ts +25 -0
- package/dist/mesh/model.d.ts.map +1 -0
- package/dist/mesh/model.js +39 -0
- package/dist/mesh/model.js.map +1 -0
- package/dist/mesh/schema.d.ts +188 -0
- package/dist/mesh/schema.d.ts.map +1 -0
- package/dist/mesh/schema.js +55 -0
- package/dist/mesh/schema.js.map +1 -0
- package/dist/motion/apply.d.ts +42 -0
- package/dist/motion/apply.d.ts.map +1 -0
- package/dist/motion/apply.js +98 -0
- package/dist/motion/apply.js.map +1 -0
- package/dist/motion/edit.d.ts +53 -0
- package/dist/motion/edit.d.ts.map +1 -0
- package/dist/motion/edit.js +125 -0
- package/dist/motion/edit.js.map +1 -0
- package/dist/motion/effects.js +86 -0
- package/dist/motion/effects.js.map +1 -0
- package/dist/motion/evaluate.d.ts +33 -0
- package/dist/motion/evaluate.d.ts.map +1 -0
- package/dist/motion/evaluate.js +160 -0
- package/dist/motion/evaluate.js.map +1 -0
- package/dist/motion/fields.d.ts +69 -0
- package/dist/motion/fields.d.ts.map +1 -0
- package/dist/motion/fields.js +132 -0
- package/dist/motion/fields.js.map +1 -0
- package/dist/motion/index.d.ts +16 -0
- package/dist/motion/index.js +15 -0
- package/dist/motion/keyable.d.ts +32 -0
- package/dist/motion/keyable.d.ts.map +1 -0
- package/dist/motion/keyable.js +120 -0
- package/dist/motion/keyable.js.map +1 -0
- package/dist/motion/outline.d.ts +35 -0
- package/dist/motion/outline.d.ts.map +1 -0
- package/dist/motion/outline.js +59 -0
- package/dist/motion/outline.js.map +1 -0
- package/dist/motion/presets/index.d.ts +20 -0
- package/dist/motion/presets/index.d.ts.map +1 -0
- package/dist/motion/presets/index.js +166 -0
- package/dist/motion/presets/index.js.map +1 -0
- package/dist/motion/presets/settings.d.ts +43 -0
- package/dist/motion/presets/settings.d.ts.map +1 -0
- package/dist/motion/presets/settings.js +254 -0
- package/dist/motion/presets/settings.js.map +1 -0
- package/dist/motion/presets/stagger.d.ts +69 -0
- package/dist/motion/presets/stagger.d.ts.map +1 -0
- package/dist/motion/presets/stagger.js +185 -0
- package/dist/motion/presets/stagger.js.map +1 -0
- package/dist/motion/schema.d.ts +185 -0
- package/dist/motion/schema.d.ts.map +1 -0
- package/dist/motion/schema.js +62 -0
- package/dist/motion/schema.js.map +1 -0
- package/dist/motion/segment.d.ts +25 -0
- package/dist/motion/segment.d.ts.map +1 -0
- package/dist/motion/segment.js +73 -0
- package/dist/motion/segment.js.map +1 -0
- package/dist/motion/spec.d.ts +26 -0
- package/dist/motion/spec.d.ts.map +1 -0
- package/dist/motion/spec.js +175 -0
- package/dist/motion/spec.js.map +1 -0
- package/dist/motion/timeline.d.ts +16 -0
- package/dist/motion/timeline.d.ts.map +1 -0
- package/dist/motion/timeline.js +53 -0
- package/dist/motion/timeline.js.map +1 -0
- package/dist/motion/types.d.ts +49 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion/variables.d.ts +9 -0
- package/dist/motion/variables.d.ts.map +1 -0
- package/dist/motion/variables.js +25 -0
- package/dist/motion/variables.js.map +1 -0
- package/dist/mutation-impact.d.ts +9 -10
- package/dist/mutation-impact.d.ts.map +1 -1
- package/dist/mutation-impact.js +19 -9
- package/dist/mutation-impact.js.map +1 -1
- package/dist/node-defaults.d.ts +15 -14
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +153 -55
- package/dist/node-defaults.js.map +1 -1
- package/dist/order-keys.d.ts +8 -9
- package/dist/order-keys.d.ts.map +1 -1
- package/dist/order-keys.js +10 -2
- package/dist/order-keys.js.map +1 -1
- package/dist/outline/flatten.d.ts +3 -6
- package/dist/outline/flatten.d.ts.map +1 -1
- package/dist/outline/flatten.js +3 -4
- package/dist/outline/heads.js +1 -2
- package/dist/outline/hit.d.ts +2 -5
- package/dist/outline/hit.d.ts.map +1 -1
- package/dist/outline/hit.js +5 -6
- package/dist/outline/index.js +3 -3
- package/dist/outline/point.d.ts +4 -7
- package/dist/outline/point.d.ts.map +1 -1
- package/dist/outline/point.js +2 -3
- package/dist/outline/shapes.d.ts +4 -7
- package/dist/outline/shapes.d.ts.map +1 -1
- package/dist/outline/shapes.js +2 -3
- package/dist/paints/index.d.ts +5 -3
- package/dist/paints/index.js +5 -3
- package/dist/paints/pattern.d.ts +6 -5
- package/dist/paints/pattern.d.ts.map +1 -1
- package/dist/paints/pattern.js +34 -3
- package/dist/paints/pattern.js.map +1 -1
- package/dist/paints/schema.d.ts +4 -7
- package/dist/paints/schema.d.ts.map +1 -1
- package/dist/paints/schema.js +3 -4
- package/dist/paints/shows.d.ts +4 -4
- package/dist/paints/shows.d.ts.map +1 -1
- package/dist/paints/shows.js +9 -3
- package/dist/paints/shows.js.map +1 -1
- package/dist/paints/solid.d.ts +8 -0
- package/dist/paints/solid.d.ts.map +1 -0
- package/dist/paints/solid.js +17 -0
- package/dist/paints/solid.js.map +1 -0
- package/dist/paints/stills.d.ts +74 -0
- package/dist/paints/stills.d.ts.map +1 -0
- package/dist/paints/stills.js +117 -0
- package/dist/paints/stills.js.map +1 -0
- package/dist/parse-path.d.ts +12 -9
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +13 -3
- package/dist/parse-path.js.map +1 -1
- package/dist/paths/arc.d.ts +6 -9
- package/dist/paths/arc.d.ts.map +1 -1
- package/dist/paths/arc.js +1 -2
- package/dist/paths/index.d.ts +1 -1
- package/dist/paths/index.js +1 -1
- package/dist/paths/network.d.ts +13 -16
- package/dist/paths/network.d.ts.map +1 -1
- package/dist/paths/network.js +1 -2
- package/dist/paths/sink.d.ts +5 -8
- package/dist/paths/sink.d.ts.map +1 -1
- package/dist/paths/sink.js +1 -2
- package/dist/paths/smooth-corners.d.ts +3 -6
- package/dist/paths/smooth-corners.d.ts.map +1 -1
- package/dist/paths/smooth-corners.js +1 -2
- package/dist/plugin-data/field.d.ts +15 -18
- package/dist/plugin-data/field.d.ts.map +1 -1
- package/dist/plugin-data/field.js +3 -2
- package/dist/plugin-data/field.js.map +1 -1
- package/dist/plugin-data/fields.d.ts +104 -11
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +43 -13
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/plugin-data/index.d.ts +2 -2
- package/dist/plugin-data/index.js +2 -2
- package/dist/polygon.d.ts +8 -8
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +7 -7
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +3 -5
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +2 -3
- package/dist/primitives/index.d.ts +7 -9
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -2
- package/dist/primitives/schema.d.ts +3 -6
- package/dist/primitives/schema.d.ts.map +1 -1
- package/dist/primitives/schema.js +1 -2
- package/dist/resize.d.ts +19 -14
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +38 -8
- package/dist/resize.js.map +1 -1
- package/dist/scaling/index.d.ts +2 -2
- package/dist/scaling/index.js +2 -2
- package/dist/scaling/node.d.ts +2 -4
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +30 -11
- package/dist/scaling/node.js.map +1 -1
- package/dist/scaling/snapshot.d.ts +5 -8
- package/dist/scaling/snapshot.d.ts.map +1 -1
- package/dist/scaling/snapshot.js +1 -2
- package/dist/scaling/tree.d.ts +6 -9
- package/dist/scaling/tree.d.ts.map +1 -1
- package/dist/scaling/tree.js +2 -3
- package/dist/shaders/index.d.ts +2 -3
- package/dist/shaders/index.js +2 -3
- package/dist/shaders/model.d.ts +54 -21
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +103 -35
- package/dist/shaders/model.js.map +1 -1
- package/dist/shaders/schema.d.ts +16 -9
- package/dist/shaders/schema.d.ts.map +1 -1
- package/dist/shaders/schema.js +12 -3
- package/dist/shaders/schema.js.map +1 -1
- package/dist/shape-with-text/document.js +264 -0
- package/dist/shape-with-text/document.js.map +1 -0
- package/dist/shape-with-text/fit.d.ts +6 -9
- package/dist/shape-with-text/fit.d.ts.map +1 -1
- package/dist/shape-with-text/fit.js +1 -2
- package/dist/shape-with-text/geometry.d.ts +16 -7
- package/dist/shape-with-text/geometry.d.ts.map +1 -1
- package/dist/shape-with-text/geometry.js +105 -46
- package/dist/shape-with-text/geometry.js.map +1 -1
- package/dist/shape-with-text/index.d.ts +2 -2
- package/dist/shape-with-text/index.js +3 -3
- package/dist/shape-with-text/kinds.d.ts +4 -7
- package/dist/shape-with-text/kinds.d.ts.map +1 -1
- package/dist/shape-with-text/kinds.js +1 -2
- package/dist/shared-style-index.d.ts +19 -0
- package/dist/shared-style-index.d.ts.map +1 -0
- package/dist/shared-style-index.js +71 -0
- package/dist/shared-style-index.js.map +1 -0
- package/dist/shared-styles.d.ts +18 -20
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +20 -12
- package/dist/shared-styles.js.map +1 -1
- package/dist/slides/drop.d.ts +29 -0
- package/dist/slides/drop.d.ts.map +1 -0
- package/dist/slides/drop.js +80 -0
- package/dist/slides/drop.js.map +1 -0
- package/dist/slides/index.d.ts +56 -0
- package/dist/slides/index.d.ts.map +1 -0
- package/dist/slides/index.js +137 -0
- package/dist/slides/index.js.map +1 -0
- package/dist/slides/motion.d.ts +71 -0
- package/dist/slides/motion.d.ts.map +1 -0
- package/dist/slides/motion.js +167 -0
- package/dist/slides/motion.js.map +1 -0
- package/dist/slides/playback.d.ts +62 -0
- package/dist/slides/playback.d.ts.map +1 -0
- package/dist/slides/playback.js +220 -0
- package/dist/slides/playback.js.map +1 -0
- package/dist/slides/types.d.ts +59 -0
- package/dist/slides/types.d.ts.map +1 -0
- package/dist/slides/types.js +38 -0
- package/dist/slides/types.js.map +1 -0
- package/dist/slots/authoring.d.ts +6 -9
- package/dist/slots/authoring.d.ts.map +1 -1
- package/dist/slots/authoring.js +2 -3
- package/dist/slots/content.d.ts +5 -8
- package/dist/slots/content.d.ts.map +1 -1
- package/dist/slots/content.js +4 -5
- package/dist/slots/frames.d.ts +7 -9
- package/dist/slots/frames.d.ts.map +1 -1
- package/dist/slots/frames.js +3 -4
- package/dist/slots/frames.js.map +1 -1
- package/dist/slots/index.js +1 -1
- package/dist/slots/limits.d.ts +4 -7
- package/dist/slots/limits.d.ts.map +1 -1
- package/dist/slots/limits.js +1 -2
- package/dist/snap.d.ts +4 -7
- package/dist/snap.d.ts.map +1 -1
- package/dist/snap.js +7 -8
- package/dist/source-metadata.d.ts +1 -4
- package/dist/source-metadata.d.ts.map +1 -1
- package/dist/source-metadata.js +1 -2
- package/dist/specs/index.d.ts +3 -0
- package/dist/specs/index.js +3 -0
- package/dist/specs/model.d.ts +20 -0
- package/dist/specs/model.d.ts.map +1 -0
- package/dist/specs/model.js +32 -0
- package/dist/specs/model.js.map +1 -0
- package/dist/specs/schema.d.ts +24 -0
- package/dist/specs/schema.d.ts.map +1 -0
- package/dist/specs/schema.js +32 -0
- package/dist/specs/schema.js.map +1 -0
- package/dist/statuses/impact.d.ts +2 -5
- package/dist/statuses/impact.d.ts.map +1 -1
- package/dist/statuses/impact.js +2 -3
- package/dist/statuses/index.d.ts +1 -1
- package/dist/statuses/index.js +2 -2
- package/dist/statuses/node.d.ts +4 -7
- package/dist/statuses/node.d.ts.map +1 -1
- package/dist/statuses/node.js +1 -2
- package/dist/statuses/schema.d.ts +7 -9
- package/dist/statuses/schema.d.ts.map +1 -1
- package/dist/statuses/schema.js +1 -2
- package/dist/statuses/workflow.d.ts +9 -12
- package/dist/statuses/workflow.d.ts.map +1 -1
- package/dist/statuses/workflow.js +2 -3
- package/dist/strokes.d.ts +8 -10
- package/dist/strokes.d.ts.map +1 -1
- package/dist/strokes.js +2 -3
- package/dist/text/auto-resize.d.ts +4 -6
- package/dist/text/auto-resize.d.ts.map +1 -1
- package/dist/text/auto-resize.js +1 -2
- package/dist/text/direction.d.ts +10 -10
- package/dist/text/direction.d.ts.map +1 -1
- package/dist/text/direction.js +13 -14
- package/dist/text/direction.js.map +1 -1
- package/dist/text/index.d.ts +3 -2
- package/dist/text/index.js +6 -5
- package/dist/text/lengths.d.ts +9 -12
- package/dist/text/lengths.d.ts.map +1 -1
- package/dist/text/lengths.js +1 -2
- package/dist/text/lists.d.ts +17 -13
- package/dist/text/lists.d.ts.map +1 -1
- package/dist/text/lists.js +15 -4
- package/dist/text/lists.js.map +1 -1
- package/dist/text/name.d.ts +19 -0
- package/dist/text/name.d.ts.map +1 -0
- package/dist/text/name.js +37 -0
- package/dist/text/name.js.map +1 -0
- package/dist/text/overflow.d.ts +5 -7
- package/dist/text/overflow.d.ts.map +1 -1
- package/dist/text/overflow.js +1 -2
- package/dist/text/paragraphs.d.ts +20 -23
- package/dist/text/paragraphs.d.ts.map +1 -1
- package/dist/text/paragraphs.js +8 -5
- package/dist/text/paragraphs.js.map +1 -1
- package/dist/text/path.js +1 -2
- package/dist/text/picture.d.ts +3 -6
- package/dist/text/picture.d.ts.map +1 -1
- package/dist/text/picture.js +2 -3
- package/dist/text/references.d.ts +3 -6
- package/dist/text/references.d.ts.map +1 -1
- package/dist/text/references.js +2 -4
- package/dist/text/references.js.map +1 -1
- package/dist/text/runs.d.ts +6 -9
- package/dist/text/runs.d.ts.map +1 -1
- package/dist/text/runs.js +1 -2
- package/dist/text/schema.d.ts +1 -4
- package/dist/text/schema.d.ts.map +1 -1
- package/dist/text/schema.js +1 -2
- package/dist/thumbnail.d.ts +20 -0
- package/dist/thumbnail.d.ts.map +1 -0
- package/dist/thumbnail.js +46 -0
- package/dist/thumbnail.js.map +1 -0
- package/dist/transfer/apply.d.ts +2 -5
- package/dist/transfer/apply.d.ts.map +1 -1
- package/dist/transfer/apply.js +16 -6
- package/dist/transfer/apply.js.map +1 -1
- package/dist/transfer/copied.d.ts +11 -9
- package/dist/transfer/copied.d.ts.map +1 -1
- package/dist/transfer/copied.js +5 -6
- package/dist/transfer/copied.js.map +1 -1
- package/dist/transfer/dependencies.d.ts +10 -10
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +21 -10
- package/dist/transfer/dependencies.js.map +1 -1
- package/dist/transfer/history.d.ts +1 -4
- package/dist/transfer/history.d.ts.map +1 -1
- package/dist/transfer/history.js +3 -2
- package/dist/transfer/history.js.map +1 -1
- package/dist/transfer/identity.js +19 -5
- package/dist/transfer/identity.js.map +1 -1
- package/dist/transfer/index.d.ts +5 -4
- package/dist/transfer/index.js +6 -5
- package/dist/transfer/library.d.ts +43 -0
- package/dist/transfer/library.d.ts.map +1 -0
- package/dist/transfer/library.js +122 -0
- package/dist/transfer/library.js.map +1 -0
- package/dist/transfer/nodes.d.ts +2 -5
- package/dist/transfer/nodes.d.ts.map +1 -1
- package/dist/transfer/nodes.js +15 -4
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/transfer/plan.d.ts +11 -5
- package/dist/transfer/plan.d.ts.map +1 -1
- package/dist/transfer/plan.js +52 -8
- package/dist/transfer/plan.js.map +1 -1
- package/dist/transfer/references.js +1 -2
- package/dist/transfer/remove.d.ts +1 -4
- package/dist/transfer/remove.d.ts.map +1 -1
- package/dist/transfer/remove.js +8 -3
- package/dist/transfer/remove.js.map +1 -1
- package/dist/transfer/resources.d.ts +2 -5
- package/dist/transfer/resources.d.ts.map +1 -1
- package/dist/transfer/resources.js +3 -4
- package/dist/transfer/validation.js +9 -6
- package/dist/transfer/validation.js.map +1 -1
- package/dist/transfer/variables.d.ts +3 -6
- package/dist/transfer/variables.d.ts.map +1 -1
- package/dist/transfer/variables.js +4 -4
- package/dist/transfer/variables.js.map +1 -1
- package/dist/types.d.ts +261 -134
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +47 -3
- package/dist/types.js.map +1 -1
- package/dist/undo.d.ts +5 -8
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +9 -3
- package/dist/undo.js.map +1 -1
- package/dist/variables/bindings.d.ts +29 -25
- package/dist/variables/bindings.d.ts.map +1 -1
- package/dist/variables/bindings.js +184 -55
- package/dist/variables/bindings.js.map +1 -1
- package/dist/variables/corners.d.ts +1 -4
- package/dist/variables/corners.d.ts.map +1 -1
- package/dist/variables/corners.js +1 -2
- package/dist/variables/easing.d.ts +53 -0
- package/dist/variables/easing.d.ts.map +1 -0
- package/dist/variables/easing.js +321 -0
- package/dist/variables/easing.js.map +1 -0
- package/dist/variables/fields.d.ts +21 -14
- package/dist/variables/fields.d.ts.map +1 -1
- package/dist/variables/fields.js +24 -6
- package/dist/variables/fields.js.map +1 -1
- package/dist/variables/formula/check.d.ts +2 -5
- package/dist/variables/formula/check.d.ts.map +1 -1
- package/dist/variables/formula/check.js +2 -3
- package/dist/variables/formula/evaluate.d.ts +1 -4
- package/dist/variables/formula/evaluate.d.ts.map +1 -1
- package/dist/variables/formula/evaluate.js +3 -4
- package/dist/variables/formula/index.d.ts +8 -8
- package/dist/variables/formula/index.d.ts.map +1 -1
- package/dist/variables/formula/index.js +29 -13
- package/dist/variables/formula/index.js.map +1 -1
- package/dist/variables/formula/parse.js +5 -6
- package/dist/variables/formula/print.d.ts +2 -5
- package/dist/variables/formula/print.d.ts.map +1 -1
- package/dist/variables/formula/print.js +4 -5
- package/dist/variables/formula/schema.d.ts +2 -5
- package/dist/variables/formula/schema.d.ts.map +1 -1
- package/dist/variables/formula/schema.js +6 -7
- package/dist/variables/formula/signatures.d.ts +4 -7
- package/dist/variables/formula/signatures.d.ts.map +1 -1
- package/dist/variables/formula/signatures.js +1 -2
- package/dist/variables/formula/signatures.js.map +1 -1
- package/dist/variables/formula/tokens.d.ts +5 -8
- package/dist/variables/formula/tokens.d.ts.map +1 -1
- package/dist/variables/formula/tokens.js +1 -2
- package/dist/variables/formula/tree.d.ts +8 -11
- package/dist/variables/formula/tree.d.ts.map +1 -1
- package/dist/variables/formula/tree.js +1 -2
- package/dist/variables/formula/tree.js.map +1 -1
- package/dist/variables/index.d.ts +42 -27
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +78 -29
- package/dist/variables/index.js.map +1 -1
- package/dist/variables/lookup.d.ts +11 -7
- package/dist/variables/lookup.d.ts.map +1 -1
- package/dist/variables/lookup.js +25 -4
- package/dist/variables/lookup.js.map +1 -1
- package/dist/variables/motion.d.ts +43 -0
- package/dist/variables/motion.d.ts.map +1 -0
- package/dist/variables/motion.js +106 -0
- package/dist/variables/motion.js.map +1 -0
- package/dist/variables/paints.d.ts +25 -19
- package/dist/variables/paints.d.ts.map +1 -1
- package/dist/variables/paints.js +28 -15
- package/dist/variables/paints.js.map +1 -1
- package/dist/variables/resolution.d.ts +22 -19
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +23 -14
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/schema.d.ts +62 -7
- package/dist/variables/schema.d.ts.map +1 -1
- package/dist/variables/schema.js +39 -5
- package/dist/variables/schema.js.map +1 -1
- package/dist/variables/style-bindings.d.ts +21 -0
- package/dist/variables/style-bindings.d.ts.map +1 -0
- package/dist/variables/style-bindings.js +82 -0
- package/dist/variables/style-bindings.js.map +1 -0
- package/dist/variables/subtree.js +1 -2
- package/dist/variables/text.d.ts +2 -5
- package/dist/variables/text.d.ts.map +1 -1
- package/dist/variables/text.js +3 -4
- package/dist/variables/token.d.ts +5 -8
- package/dist/variables/token.d.ts.map +1 -1
- package/dist/variables/token.js +1 -2
- package/dist/variables/units.js +3 -5
- package/dist/variables/units.js.map +1 -1
- package/dist/variables/value.d.ts +4 -7
- package/dist/variables/value.d.ts.map +1 -1
- package/dist/variables/value.js +4 -5
- package/dist/variant-name.d.ts +2 -5
- package/dist/variant-name.d.ts.map +1 -1
- package/dist/variant-name.js +1 -2
- package/dist/variant-properties.d.ts +4 -7
- package/dist/variant-properties.d.ts.map +1 -1
- package/dist/variant-properties.js +2 -3
- package/dist/vector-network.d.ts +17 -20
- package/dist/vector-network.d.ts.map +1 -1
- package/dist/vector-network.js +4 -5
- package/package.json +42 -5
- package/src/behaviours/index.ts +2 -0
- package/src/behaviours/kinds.ts +108 -2
- package/src/behaviours/listing.ts +142 -0
- package/src/behaviours/model.ts +23 -2
- package/src/behaviours/schema.ts +19 -2
- package/src/behaviours/spec.ts +5 -0
- package/src/behaviours/transition.ts +46 -0
- package/src/blur.ts +88 -0
- package/src/checkpoint.ts +2 -0
- package/src/clipping.ts +3 -4
- package/src/color/index.ts +15 -24
- package/src/color/management.ts +144 -168
- package/src/color/okhcl.ts +62 -43
- package/src/color/schema.ts +13 -0
- package/src/comments/threads.ts +8 -1
- package/src/connectors/layout.ts +10 -3
- package/src/connectors/sublayers.ts +2 -1
- package/src/constraints.ts +2 -1
- package/src/coordinate.ts +17 -25
- package/src/copy.ts +38 -0
- package/src/corners.ts +3 -0
- package/src/css/index.ts +1 -0
- package/src/css/motion.ts +51 -0
- package/src/css/shadows.ts +7 -6
- package/src/css/values.ts +7 -3
- package/src/cubic.ts +57 -1
- package/src/export-format.ts +11 -1
- package/src/fields/layout.ts +9 -0
- package/src/font-style.ts +20 -7
- package/src/generated/index.ts +58 -9
- package/src/generated/kind.ts +16 -2
- package/src/generated/shape-with-text.ts +1 -0
- package/src/generated/spec.ts +243 -0
- package/src/generated/sticky.ts +2 -1
- package/src/geometry.ts +52 -89
- package/src/graph.ts +93 -15
- package/src/group-bounds.ts +54 -13
- package/src/hit-test.ts +78 -33
- package/src/images.ts +4 -1
- package/src/instances/content-marks.ts +124 -0
- package/src/instances/deleted.ts +115 -0
- package/src/instances/fields.ts +9 -3
- package/src/instances/index.ts +165 -17
- package/src/instances/lookup.ts +61 -0
- package/src/instances/sync.ts +108 -11
- package/src/layout/flow.ts +36 -0
- package/src/layout/index.ts +2 -0
- package/src/layout/keywords.ts +7 -1
- package/src/layout/sizing.ts +30 -0
- package/src/layout/spacing.ts +12 -0
- package/src/layout/stacking.ts +14 -0
- package/src/matrix.ts +11 -1
- package/src/mesh/geometry.ts +422 -0
- package/src/mesh/index.ts +3 -0
- package/src/mesh/model.ts +50 -0
- package/src/mesh/schema.ts +81 -0
- package/src/motion/apply.ts +156 -0
- package/src/motion/edit.ts +148 -0
- package/src/motion/effects.ts +166 -0
- package/src/motion/evaluate.ts +181 -0
- package/src/motion/fields.ts +136 -0
- package/src/motion/index.ts +13 -0
- package/src/motion/keyable.ts +141 -0
- package/src/motion/outline.ts +72 -0
- package/src/motion/presets/index.ts +257 -0
- package/src/motion/presets/settings.ts +221 -0
- package/src/motion/presets/stagger.ts +242 -0
- package/src/motion/schema.ts +66 -0
- package/src/motion/segment.ts +83 -0
- package/src/motion/spec.ts +225 -0
- package/src/motion/timeline.ts +48 -0
- package/src/motion/types.ts +45 -0
- package/src/motion/variables.ts +33 -0
- package/src/mutation-impact.ts +23 -7
- package/src/node-defaults.ts +152 -53
- package/src/order-keys.ts +16 -2
- package/src/paints/index.ts +2 -0
- package/src/paints/pattern.ts +55 -0
- package/src/paints/shows.ts +9 -0
- package/src/paints/solid.ts +10 -0
- package/src/paints/stills.ts +186 -0
- package/src/parse-path.ts +15 -0
- package/src/plugin-data/field.ts +3 -0
- package/src/plugin-data/fields.ts +54 -4
- package/src/polygon.ts +6 -4
- package/src/resize.ts +32 -20
- package/src/scaling/index.ts +1 -1
- package/src/scaling/node.ts +43 -6
- package/src/shaders/index.ts +0 -1
- package/src/shaders/model.ts +133 -45
- package/src/shaders/schema.ts +13 -1
- package/src/shape-with-text/document.ts +170 -0
- package/src/shape-with-text/geometry.ts +98 -29
- package/src/shared-style-index.ts +106 -0
- package/src/shared-styles.ts +21 -14
- package/src/slides/drop.ts +94 -0
- package/src/slides/index.ts +133 -0
- package/src/slides/motion.ts +203 -0
- package/src/slides/playback.ts +242 -0
- package/src/slides/types.ts +94 -0
- package/src/slots/frames.ts +2 -3
- package/src/specs/index.ts +2 -0
- package/src/specs/model.ts +40 -0
- package/src/specs/schema.ts +43 -0
- package/src/text/direction.ts +13 -23
- package/src/text/index.ts +1 -0
- package/src/text/lists.ts +20 -7
- package/src/text/name.ts +39 -0
- package/src/text/paragraphs.ts +10 -3
- package/src/text/references.ts +3 -3
- package/src/thumbnail.ts +52 -0
- package/src/transfer/apply.ts +16 -3
- package/src/transfer/copied.ts +7 -2
- package/src/transfer/dependencies.ts +27 -12
- package/src/transfer/history.ts +2 -0
- package/src/transfer/identity.ts +34 -2
- package/src/transfer/index.ts +6 -0
- package/src/transfer/library.ts +177 -0
- package/src/transfer/nodes.ts +28 -0
- package/src/transfer/plan.ts +96 -10
- package/src/transfer/remove.ts +6 -2
- package/src/transfer/validation.ts +15 -7
- package/src/transfer/variables.ts +8 -2
- package/src/types.ts +182 -15
- package/src/undo.ts +10 -1
- package/src/variables/bindings.ts +292 -51
- package/src/variables/easing.ts +281 -0
- package/src/variables/fields.ts +30 -3
- package/src/variables/formula/index.ts +33 -14
- package/src/variables/formula/signatures.ts +6 -2
- package/src/variables/formula/tree.ts +3 -3
- package/src/variables/index.ts +90 -37
- package/src/variables/lookup.ts +25 -2
- package/src/variables/motion.ts +151 -0
- package/src/variables/paints.ts +29 -7
- package/src/variables/resolution.ts +26 -6
- package/src/variables/schema.ts +41 -0
- package/src/variables/style-bindings.ts +137 -0
- package/src/variables/units.ts +2 -3
- package/dist/shaders/still.d.ts +0 -18
- package/dist/shaders/still.d.ts.map +0 -1
- package/dist/shaders/still.js +0 -36
- package/dist/shaders/still.js.map +0 -1
- package/src/shaders/still.ts +0 -41
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { PluginDataField, PluginDataKey } from "./field.js";
|
|
2
|
+
import { OkHCLPayload } from "../color/okhcl.js";
|
|
1
3
|
import { Rect } from "../primitives/index.js";
|
|
4
|
+
import { SpecBlock } from "../specs/schema.js";
|
|
2
5
|
import { CommentThread, EnabledLibraryBinding, ExportSetting, LibraryAssetSource, PluginDataEntry, SourceLibraryPublication, TokenUnit } from "../types.js";
|
|
3
|
-
import { OkHCLPayload } from "../color/okhcl.js";
|
|
4
|
-
import { PluginDataField } from "./field.js";
|
|
5
6
|
import { ShaderComponent } from "../shaders/schema.js";
|
|
6
|
-
//#region src/plugin-data/fields.d.ts
|
|
7
7
|
/** Token fields Figma has no slot for, with mode ids as the file spells them. */
|
|
8
|
-
interface StoredToken {
|
|
8
|
+
export interface StoredToken {
|
|
9
9
|
unit?: TokenUnit;
|
|
10
10
|
expressions?: Record<string, {
|
|
11
11
|
css: string;
|
|
@@ -17,17 +17,26 @@ interface StoredToken {
|
|
|
17
17
|
* format has no field for. Add a key here, never as a string elsewhere, so reading and writing
|
|
18
18
|
* it share one schema.
|
|
19
19
|
*/
|
|
20
|
-
declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
20
|
+
export declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
21
21
|
/** A text node's direction, on TEXT nodes. */
|
|
22
22
|
textDirection: PluginDataField<"AUTO" | "LTR" | "RTL">;
|
|
23
23
|
/** An auto-layout frame's direction. */
|
|
24
24
|
layoutDirection: PluginDataField<"AUTO" | "LTR" | "RTL">;
|
|
25
|
-
/** Marks a component set Figma would read as a plain frame. */
|
|
26
|
-
nodeType: PluginDataField<"COMPONENT_SET">;
|
|
25
|
+
/** Marks a component set or a spec, which Figma would read as a plain frame. */
|
|
26
|
+
nodeType: PluginDataField<"COMPONENT_SET" | "SPEC">;
|
|
27
27
|
/** Variable bindings by field path, including those Figma cannot store natively. */
|
|
28
28
|
boundVariables: PluginDataField<{
|
|
29
29
|
[k: string]: string;
|
|
30
30
|
}>;
|
|
31
|
+
/**
|
|
32
|
+
* On a TEXT node, the bindings of its ranges Figma cannot store, such as the characters a
|
|
33
|
+
* spec's token shows, by the style ID its record gives each range.
|
|
34
|
+
*/
|
|
35
|
+
textRunBindings: PluginDataField<{
|
|
36
|
+
[k: string]: {
|
|
37
|
+
[k: string]: string;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
31
40
|
exportSettings: PluginDataField<ExportSetting[]>;
|
|
32
41
|
/** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */
|
|
33
42
|
textPathBox: PluginDataField<Rect>;
|
|
@@ -44,6 +53,11 @@ declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
|
44
53
|
enabledLibraries: PluginDataField<EnabledLibraryBinding[]>;
|
|
45
54
|
/** The library this document publishes as, on the DOCUMENT node. */
|
|
46
55
|
sourceLibraryPublication: PluginDataField<SourceLibraryPublication>;
|
|
56
|
+
/**
|
|
57
|
+
* The layer chosen as the document's thumbnail, on the DOCUMENT node. Figma keeps its own
|
|
58
|
+
* choice outside the file, so a `.fig` carries only this one.
|
|
59
|
+
*/
|
|
60
|
+
thumbnail: PluginDataField<string>;
|
|
47
61
|
/** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
|
|
48
62
|
comments: PluginDataField<CommentThread[]>;
|
|
49
63
|
/** The statuses layers can be in, on the DOCUMENT node. */
|
|
@@ -80,7 +94,7 @@ declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
|
80
94
|
okhcl: PluginDataField<OkHCLPayload>;
|
|
81
95
|
/** How a main component or component set behaves as a control in preview. */
|
|
82
96
|
behaviour: PluginDataField<{
|
|
83
|
-
kind: "button" | "textField" | "textarea" | "numberField" | "toggle" | "switch" | "checkbox" | "radio" | "radioGroup" | "toggleGroup" | "slider" | "progress" | "tabs" | "tab" | "collapsible" | "accordion";
|
|
97
|
+
kind: "button" | "textField" | "textarea" | "numberField" | "toggle" | "switch" | "checkbox" | "radio" | "radioGroup" | "toggleGroup" | "slider" | "progress" | "tabs" | "tab" | "collapsible" | "accordion" | "popover" | "tooltip" | "hoverCard" | "dropdownMenu" | "select" | "dialog";
|
|
84
98
|
booleans: {
|
|
85
99
|
[x: string]: {
|
|
86
100
|
propertyId: string;
|
|
@@ -113,7 +127,33 @@ declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
|
113
127
|
invalid?: string | undefined;
|
|
114
128
|
propertyId: string;
|
|
115
129
|
} | undefined;
|
|
130
|
+
transition?: {
|
|
131
|
+
duration: number;
|
|
132
|
+
easing: {
|
|
133
|
+
easing: "IN_CUBIC" | "OUT_CUBIC" | "INOUT_CUBIC" | "LINEAR" | "IN_BACK_CUBIC" | "OUT_BACK_CUBIC" | "INOUT_BACK_CUBIC" | "CUSTOM_CUBIC" | "SPRING" | "GENTLE_SPRING" | "CUSTOM_SPRING" | "SPRING_PRESET_ONE" | "SPRING_PRESET_TWO" | "SPRING_PRESET_THREE" | "HOLD" | "EASE_IN";
|
|
134
|
+
bezier?: {
|
|
135
|
+
x1: number;
|
|
136
|
+
y1: number;
|
|
137
|
+
x2: number;
|
|
138
|
+
y2: number;
|
|
139
|
+
} | undefined;
|
|
140
|
+
spring?: {
|
|
141
|
+
stiffness: number;
|
|
142
|
+
damping: number;
|
|
143
|
+
mass: number;
|
|
144
|
+
type?: "NORMALIZED" | "PHYSICAL" | undefined;
|
|
145
|
+
platform?: "ANDROID" | "IOS_WEB" | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
};
|
|
148
|
+
durationVariableId?: string | undefined;
|
|
149
|
+
easingVariableId?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
116
151
|
}>;
|
|
152
|
+
/**
|
|
153
|
+
* What a child of a menu's or a select's listing is other than an item: a group, a label, or a
|
|
154
|
+
* separator, on that layer.
|
|
155
|
+
*/
|
|
156
|
+
listingPart: PluginDataField<"group" | "label" | "separator">;
|
|
117
157
|
/** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */
|
|
118
158
|
icon: PluginDataField<{
|
|
119
159
|
name: string;
|
|
@@ -136,14 +176,67 @@ declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
|
136
176
|
height: number;
|
|
137
177
|
preset: string;
|
|
138
178
|
} | undefined;
|
|
179
|
+
baked?: {
|
|
180
|
+
index: number;
|
|
181
|
+
visible: boolean;
|
|
182
|
+
opacity: number;
|
|
183
|
+
} | undefined;
|
|
139
184
|
}>;
|
|
185
|
+
/** One entry per paint that draws a mesh gradient, matched to its image paint by the frame's hash. */
|
|
186
|
+
mesh: PluginDataField<{
|
|
187
|
+
image: string;
|
|
188
|
+
mesh: {
|
|
189
|
+
columns: number;
|
|
190
|
+
rows: number;
|
|
191
|
+
points: {
|
|
192
|
+
position: {
|
|
193
|
+
x: number;
|
|
194
|
+
y: number;
|
|
195
|
+
};
|
|
196
|
+
left?: {
|
|
197
|
+
x: number;
|
|
198
|
+
y: number;
|
|
199
|
+
} | undefined;
|
|
200
|
+
right?: {
|
|
201
|
+
x: number;
|
|
202
|
+
y: number;
|
|
203
|
+
} | undefined;
|
|
204
|
+
top?: {
|
|
205
|
+
x: number;
|
|
206
|
+
y: number;
|
|
207
|
+
} | undefined;
|
|
208
|
+
bottom?: {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
} | undefined;
|
|
212
|
+
}[];
|
|
213
|
+
colors: {
|
|
214
|
+
r: number;
|
|
215
|
+
g: number;
|
|
216
|
+
b: number;
|
|
217
|
+
a: number;
|
|
218
|
+
}[];
|
|
219
|
+
};
|
|
220
|
+
frame?: {
|
|
221
|
+
width: number;
|
|
222
|
+
height: number;
|
|
223
|
+
key: string;
|
|
224
|
+
} | undefined;
|
|
225
|
+
}>;
|
|
226
|
+
/** The block a spec's sublayer draws, on each sublayer of a spec. */
|
|
227
|
+
specBlock: PluginDataField<SpecBlock>;
|
|
228
|
+
/**
|
|
229
|
+
* Marks the layer a `.fig` writes for Figma to stand in for one a Shader effect draws, showing
|
|
230
|
+
* its frame; reading the file back removes it.
|
|
231
|
+
*/
|
|
232
|
+
shaderFrame: PluginDataField<true>;
|
|
140
233
|
};
|
|
234
|
+
/** OpenPencil's `content` fields: what a layer is or draws, which only plugin data keeps. */
|
|
235
|
+
export declare const CONTENT_PLUGIN_DATA: readonly PluginDataKey[];
|
|
141
236
|
/**
|
|
142
237
|
* A node's plugin data that is part of its content, in a stable order: OpenPencil's content
|
|
143
238
|
* fields and every other plugin's entries, which the node carries wherever it goes. Format
|
|
144
239
|
* copies of node fields and bookkeeping are left out.
|
|
145
240
|
*/
|
|
146
|
-
declare function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[];
|
|
147
|
-
//#endregion
|
|
148
|
-
export { OPEN_PENCIL_PLUGIN_DATA, StoredToken, contentPluginData };
|
|
241
|
+
export declare function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[];
|
|
149
242
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"fields.d.ts","names":["_$__field0.PluginDataField"],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;iBAuIiB;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;;;;;qBAuCjC;;E,eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAsGA,8BAA8B;;;;;;wBAa3B,kBAAkB,kBAAkB,oBAAoB"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { LISTING_PARTS } from "../behaviours/kinds.js";
|
|
2
3
|
import { behaviourSchema } from "../behaviours/schema.js";
|
|
4
|
+
import { exportColorProfileSchema } from "../color/schema.js";
|
|
3
5
|
import { commentThreadsSchema } from "../comments/schema.js";
|
|
4
6
|
import { isExportFormatId } from "../export-format.js";
|
|
5
7
|
import { clampExportScale } from "../export-scale.js";
|
|
6
8
|
import { FIG_COMPRESSIONS } from "../fig-compression.js";
|
|
7
9
|
import { iconSchema, iconTintSchema } from "../icons/schema.js";
|
|
10
|
+
import { meshPaintSchema } from "../mesh/schema.js";
|
|
8
11
|
import { shaderPaintSchema } from "../shaders/schema.js";
|
|
12
|
+
import { specBlockSchema } from "../specs/schema.js";
|
|
9
13
|
import { nodeStatusSchema, statusWorkflowSchema } from "../statuses/schema.js";
|
|
10
14
|
import { MODE_ATTRIBUTE_PATTERN, TOKEN_UNITS } from "../types.js";
|
|
11
|
-
import
|
|
12
|
-
|
|
15
|
+
import { jsonPluginDataField, textPluginDataField, withoutPluginData } from "./field.js";
|
|
16
|
+
// src/plugin-data/fields.ts
|
|
13
17
|
const DIRECTIONS = [
|
|
14
18
|
"AUTO",
|
|
15
19
|
"LTR",
|
|
@@ -23,6 +27,11 @@ const textPathBoxSchema = v.pipe(v.object({
|
|
|
23
27
|
}), v.check(({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0));
|
|
24
28
|
/** String-valued entries of a JSON object; other entries are dropped, not rejected. */
|
|
25
29
|
const boundVariablesSchema = v.pipe(v.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value)), v.transform((value) => Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"))));
|
|
30
|
+
/** Bindings by the style ID of the range that has them; a malformed entry is dropped. */
|
|
31
|
+
const textRunBindingsSchema = v.pipe(v.record(v.string(), v.unknown()), v.transform((value) => Object.fromEntries(Object.entries(value).flatMap(([styleID, bound]) => {
|
|
32
|
+
const read = v.safeParse(boundVariablesSchema, bound);
|
|
33
|
+
return /^\d+$/.test(styleID) && read.success ? [[styleID, read.output]] : [];
|
|
34
|
+
}))));
|
|
26
35
|
/** Every entry must be valid, or the whole value is ignored in favour of native settings. */
|
|
27
36
|
const exportSettingsSchema = v.array(v.pipe(v.object({
|
|
28
37
|
scale: v.pipe(v.number(), v.finite()),
|
|
@@ -34,11 +43,7 @@ const exportSettingsSchema = v.array(v.pipe(v.object({
|
|
|
34
43
|
})),
|
|
35
44
|
contentsOnly: v.optional(v.boolean()),
|
|
36
45
|
useAbsoluteBounds: v.optional(v.boolean()),
|
|
37
|
-
colorProfile: v.optional(
|
|
38
|
-
"DOCUMENT",
|
|
39
|
-
"SRGB",
|
|
40
|
-
"DISPLAY_P3_V4"
|
|
41
|
-
])),
|
|
46
|
+
colorProfile: v.optional(exportColorProfileSchema),
|
|
42
47
|
svgOutlineText: v.optional(v.boolean()),
|
|
43
48
|
svgIdAttribute: v.optional(v.boolean()),
|
|
44
49
|
svgSimplifyStroke: v.optional(v.boolean())
|
|
@@ -110,10 +115,15 @@ const OPEN_PENCIL_PLUGIN_DATA = {
|
|
|
110
115
|
textDirection: textPluginDataField("textDirection", "format", DIRECTIONS),
|
|
111
116
|
/** An auto-layout frame's direction. */
|
|
112
117
|
layoutDirection: textPluginDataField("layoutDirection", "format", DIRECTIONS),
|
|
113
|
-
/** Marks a component set Figma would read as a plain frame. */
|
|
114
|
-
nodeType: textPluginDataField("nodeType", "format", ["COMPONENT_SET"]),
|
|
118
|
+
/** Marks a component set or a spec, which Figma would read as a plain frame. */
|
|
119
|
+
nodeType: textPluginDataField("nodeType", "format", ["COMPONENT_SET", "SPEC"]),
|
|
115
120
|
/** Variable bindings by field path, including those Figma cannot store natively. */
|
|
116
121
|
boundVariables: jsonPluginDataField("boundVariables", "format", boundVariablesSchema),
|
|
122
|
+
/**
|
|
123
|
+
* On a TEXT node, the bindings of its ranges Figma cannot store, such as the characters a
|
|
124
|
+
* spec's token shows, by the style ID its record gives each range.
|
|
125
|
+
*/
|
|
126
|
+
textRunBindings: jsonPluginDataField("textRunBindings", "format", textRunBindingsSchema),
|
|
117
127
|
exportSettings: jsonPluginDataField("exportSettings", "format", exportSettingsSchema),
|
|
118
128
|
/** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */
|
|
119
129
|
textPathBox: jsonPluginDataField("textPathBox", "format", textPathBoxSchema),
|
|
@@ -130,6 +140,11 @@ const OPEN_PENCIL_PLUGIN_DATA = {
|
|
|
130
140
|
enabledLibraries: jsonPluginDataField("enabledLibraries", "bookkeeping", enabledLibrariesSchema),
|
|
131
141
|
/** The library this document publishes as, on the DOCUMENT node. */
|
|
132
142
|
sourceLibraryPublication: jsonPluginDataField("sourceLibraryPublication", "bookkeeping", sourceLibraryPublicationSchema),
|
|
143
|
+
/**
|
|
144
|
+
* The layer chosen as the document's thumbnail, on the DOCUMENT node. Figma keeps its own
|
|
145
|
+
* choice outside the file, so a `.fig` carries only this one.
|
|
146
|
+
*/
|
|
147
|
+
thumbnail: jsonPluginDataField("thumbnail", "bookkeeping", v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))),
|
|
133
148
|
/** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
|
|
134
149
|
comments: jsonPluginDataField("comments", "bookkeeping", commentThreadsSchema),
|
|
135
150
|
/** The statuses layers can be in, on the DOCUMENT node. */
|
|
@@ -150,13 +165,29 @@ const OPEN_PENCIL_PLUGIN_DATA = {
|
|
|
150
165
|
okhcl: jsonPluginDataField("okhcl", "content", okhclSchema),
|
|
151
166
|
/** How a main component or component set behaves as a control in preview. */
|
|
152
167
|
behaviour: jsonPluginDataField("behaviour", "content", behaviourSchema),
|
|
168
|
+
/**
|
|
169
|
+
* What a child of a menu's or a select's listing is other than an item: a group, a label, or a
|
|
170
|
+
* separator, on that layer.
|
|
171
|
+
*/
|
|
172
|
+
listingPart: textPluginDataField("listingPart", "content", LISTING_PARTS),
|
|
153
173
|
/** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */
|
|
154
174
|
icon: jsonPluginDataField("icon", "content", iconSchema),
|
|
155
175
|
/** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */
|
|
156
176
|
iconTint: jsonPluginDataField("iconTint", "content", iconTintSchema),
|
|
157
177
|
/** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */
|
|
158
|
-
shader: jsonPluginDataField("shader", "content", shaderPaintSchema)
|
|
178
|
+
shader: jsonPluginDataField("shader", "content", shaderPaintSchema),
|
|
179
|
+
/** One entry per paint that draws a mesh gradient, matched to its image paint by the frame's hash. */
|
|
180
|
+
mesh: jsonPluginDataField("mesh", "content", meshPaintSchema),
|
|
181
|
+
/** The block a spec's sublayer draws, on each sublayer of a spec. */
|
|
182
|
+
specBlock: jsonPluginDataField("specBlock", "content", specBlockSchema),
|
|
183
|
+
/**
|
|
184
|
+
* Marks the layer a `.fig` writes for Figma to stand in for one a Shader effect draws, showing
|
|
185
|
+
* its frame; reading the file back removes it.
|
|
186
|
+
*/
|
|
187
|
+
shaderFrame: jsonPluginDataField("shaderFrame", "format", v.literal(true))
|
|
159
188
|
};
|
|
189
|
+
/** OpenPencil's `content` fields: what a layer is or draws, which only plugin data keeps. */
|
|
190
|
+
const CONTENT_PLUGIN_DATA = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter((field) => field.role === "content");
|
|
160
191
|
const NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter((field) => field.role !== "content");
|
|
161
192
|
/**
|
|
162
193
|
* A node's plugin data that is part of its content, in a stable order: OpenPencil's content
|
|
@@ -166,7 +197,6 @@ const NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter((field) => fie
|
|
|
166
197
|
function contentPluginData(entries) {
|
|
167
198
|
return withoutPluginData(entries, NOT_CONTENT).sort((a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key));
|
|
168
199
|
}
|
|
169
|
-
|
|
170
|
-
export { OPEN_PENCIL_PLUGIN_DATA, contentPluginData };
|
|
200
|
+
export { CONTENT_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_DATA, contentPluginData };
|
|
171
201
|
|
|
172
202
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(v.picklist(['DOCUMENT', 'SRGB', 'DISPLAY_P3_V4'])),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /** The library source layer a library definition's layer copies, on every definition layer. */\n libraryLayer: jsonPluginDataField(\n 'libraryLayer',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))\n ),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** The library mode each mode of a copied collection came from, by the file's mode id. */\n libraryModes: jsonPluginDataField('libraryModes', 'format', v.record(v.string(), v.string())),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;AAAE,CAAC,GAChF,EAAE,OACC,EAAE,GAAG,GAAG,OAAO,aAAa,OAAO,SAAS,IAAI,IAAI,QAAQ,MAAM,KAAK,QAAQ,KAAK,SAAS,CAChG,CACF;;AAGA,MAAM,uBAAuB,EAAE,KAC7B,EAAE,QACC,UAAU,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,CAChF,GACA,EAAE,WAAW,UACX,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,QACnB,UAAqC,OAAO,MAAM,OAAO,QAC5D,CACF,CACF,CACF;;AAGA,MAAM,uBAAkE,EAAE,MACxE,EAAE,KACA,EAAE,OAAO;CACP,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;CACpC,QAAQ,EAAE,OAAuB,gBAAgB;CACjD,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;CAC7B,MAAM,EAAE,SACN,EAAE,OAAO;EACP,MAAM,EAAE,SAAS,CAAC,SAAS,QAAQ,CAAC;EACpC,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;CACtC,CAAC,CACH;CACA,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC;CACpC,mBAAmB,EAAE,SAAS,EAAE,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fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { LISTING_PARTS } from '../behaviours/kinds'\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { exportColorProfileSchema } from '../color/schema'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport { meshPaintSchema } from '../mesh/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { specBlockSchema } from '../specs/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Bindings by the style ID of the range that has them; a malformed entry is dropped. */\nconst textRunBindingsSchema = v.pipe(\n v.record(v.string(), v.unknown()),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).flatMap(([styleID, bound]) => {\n const read = v.safeParse(boundVariablesSchema, bound)\n return /^\\d+$/.test(styleID) && read.success ? [[styleID, read.output]] : []\n })\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(exportColorProfileSchema),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set or a spec, which Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET', 'SPEC']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n /**\n * On a TEXT node, the bindings of its ranges Figma cannot store, such as the characters a\n * spec's token shows, by the style ID its record gives each range.\n */\n textRunBindings: jsonPluginDataField('textRunBindings', 'format', textRunBindingsSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /** The library source layer a library definition's layer copies, on every definition layer. */\n libraryLayer: jsonPluginDataField(\n 'libraryLayer',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))\n ),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /**\n * The layer chosen as the document's thumbnail, on the DOCUMENT node. Figma keeps its own\n * choice outside the file, so a `.fig` carries only this one.\n */\n thumbnail: jsonPluginDataField(\n 'thumbnail',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** The library mode each mode of a copied collection came from, by the file's mode id. */\n libraryModes: jsonPluginDataField('libraryModes', 'format', v.record(v.string(), v.string())),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /**\n * What a child of a menu's or a select's listing is other than an item: a group, a label, or a\n * separator, on that layer.\n */\n listingPart: textPluginDataField('listingPart', 'content', LISTING_PARTS),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema),\n /** One entry per paint that draws a mesh gradient, matched to its image paint by the frame's hash. */\n mesh: jsonPluginDataField('mesh', 'content', meshPaintSchema),\n /** The block a spec's sublayer draws, on each sublayer of a spec. */\n specBlock: jsonPluginDataField('specBlock', 'content', specBlockSchema),\n /**\n * Marks the layer a `.fig` writes for Figma to stand in for one a Shader effect draws, showing\n * its frame; reading the file back removes it.\n */\n shaderFrame: jsonPluginDataField('shaderFrame', 'format', v.literal(true))\n} satisfies Record<string, PluginDataKey>\n\n/** OpenPencil's `content` fields: what a layer is or draws, which only plugin data keeps. */\nexport const CONTENT_PLUGIN_DATA: readonly PluginDataKey[] = Object.values(\n OPEN_PENCIL_PLUGIN_DATA\n).filter((field) => field.role === 'content')\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;AAAE,CAAC,GAChF,EAAE,OACC,EAAE,GAAG,GAAG,OAAO,aAAa,OAAO,SAAS,IAAI,IAAI,QAAQ,MAAM,KAAK,QAAQ,KAAK,SAAS,CAChG,CACF;;AAGA,MAAM,uBAAuB,EAAE,KAC7B,EAAE,QACC,UAAU,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,CAChF,GACA,EAAE,WAAW,UACX,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,QACnB,UAAqC,OAAO,MAAM,OAAO,QAC5D,CACF,CACF,CACF;;AAGA,MAAM,wBAAwB,EAAE,KAC9B,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,GAChC,EAAE,WAAW,UACX,OAAO,YACL,OAAO,QAAQ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ACA,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CACpC;;CAEA,eAAe,oBACb,iBACA,UACA,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,GAAG,GAAG,EAAE,MAAM,sBAAsB,CAAC,CAChF;;CAEA,cAAc,oBAAoB,gBAAgB,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;;CAE5F,OAAO,oBAAoB,SAAS,WAAW,WAAW;;CAE1D,WAAW,oBAAoB,aAAa,WAAW,eAAe;;;;;CAKtE,aAAa,oBAAoB,eAAe,WAAW,aAAa;;CAExE,MAAM,oBAAoB,QAAQ,WAAW,UAAU;;CAEvD,UAAU,oBAAoB,YAAY,WAAW,cAAc;;CAEnE,QAAQ,oBAAoB,UAAU,WAAW,iBAAiB;;CAElE,MAAM,oBAAoB,QAAQ,WAAW,eAAe;;CAE5D,WAAW,oBAAoB,aAAa,WAAW,eAAe;;;;;CAKtE,aAAa,oBAAoB,eAAe,UAAU,EAAE,QAAQ,IAAI,CAAC;AAC3E;;AAGA,MAAa,sBAAgD,OAAO,OAClE,uBACF,CAAC,CAAC,QAAQ,UAAU,MAAM,SAAS,SAAS;AAE5C,MAAM,cAAc,OAAO,OAAO,uBAAuB,CAAC,CAAC,QACxD,UAAU,MAAM,SAAS,SAC5B;;;;;;AAOA,SAAgB,kBAAkB,SAAwD;CACxF,OAAO,kBAAkB,SAAS,WAAW,CAAC,CAAC,MAC5C,GAAG,MAAM,EAAE,SAAS,cAAc,EAAE,QAAQ,KAAK,EAAE,IAAI,cAAc,EAAE,GAAG,CAC7E;AACF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OPEN_PENCIL_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData } from "./field.js";
|
|
2
|
-
import { OPEN_PENCIL_PLUGIN_DATA, StoredToken, contentPluginData } from "./fields.js";
|
|
3
|
-
export { OPEN_PENCIL_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, StoredToken, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData };
|
|
2
|
+
import { CONTENT_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_DATA, StoredToken, contentPluginData } from "./fields.js";
|
|
3
|
+
export { CONTENT_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, StoredToken, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OPEN_PENCIL_PLUGIN_ID, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData } from "./field.js";
|
|
2
|
-
import { OPEN_PENCIL_PLUGIN_DATA, contentPluginData } from "./fields.js";
|
|
3
|
-
export { OPEN_PENCIL_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_ID, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData };
|
|
2
|
+
import { CONTENT_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_DATA, contentPluginData } from "./fields.js";
|
|
3
|
+
export { CONTENT_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_ID, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData };
|
package/dist/polygon.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Vector } from "./primitives/index.js";
|
|
2
2
|
import { SceneNode } from "./types.js";
|
|
3
|
-
//#region src/polygon.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Rounded polygon and star outlines, as Figma draws them. Each corner, convex or not, is rounded by
|
|
6
5
|
* a circular arc tangent to both edges, capped so that it and its neighbours fit along every edge;
|
|
7
6
|
* corner smoothing replaces the arc's ends with curves that ease into the edges, as on rectangles.
|
|
8
7
|
*/
|
|
9
8
|
/** Figma keeps a polygon's sides or a star's points within this range, and its plugin API clamps to it. */
|
|
10
|
-
declare const POINT_COUNT_RANGE: {
|
|
9
|
+
export declare const POINT_COUNT_RANGE: {
|
|
11
10
|
readonly min: 3;
|
|
12
11
|
readonly max: 60;
|
|
13
12
|
};
|
|
14
|
-
type PolygonOutlineCommand = {
|
|
13
|
+
export type PolygonOutlineCommand = {
|
|
15
14
|
type: 'M' | 'L';
|
|
16
15
|
x: number;
|
|
17
16
|
y: number;
|
|
@@ -27,7 +26,7 @@ type PolygonOutlineCommand = {
|
|
|
27
26
|
type: 'Z';
|
|
28
27
|
};
|
|
29
28
|
type PolygonNode = Pick<SceneNode, 'type' | 'width' | 'height' | 'pointCount' | 'starInnerRadius' | 'cornerRadius' | 'cornerSmoothing'>;
|
|
30
|
-
interface PolygonCorner {
|
|
29
|
+
export interface PolygonCorner {
|
|
31
30
|
vertex: Vector;
|
|
32
31
|
/** The unit direction of the edge arriving at the vertex. */
|
|
33
32
|
incoming: Vector;
|
|
@@ -45,9 +44,10 @@ interface PolygonCorner {
|
|
|
45
44
|
* r·tan(α/2) of each edge, so on an edge of length L between corners turning by α and β the radius
|
|
46
45
|
* is at most L / (tan(α/2) + tan(β/2)); each corner takes the least of its two edges' limits.
|
|
47
46
|
*/
|
|
48
|
-
declare function polygonCorners(node: PolygonNode): PolygonCorner[];
|
|
47
|
+
export declare function polygonCorners(node: PolygonNode): PolygonCorner[];
|
|
48
|
+
/** A cubic Bézier to `to` with control points `c1` and `c2`. */
|
|
49
|
+
export declare function cubicTo(c1: Vector, c2: Vector, to: Vector): PolygonOutlineCommand;
|
|
49
50
|
/** The outline of a polygon or star with its corner radius and smoothing, in its own pixels. */
|
|
50
|
-
declare function polygonOutline(node: PolygonNode): PolygonOutlineCommand[];
|
|
51
|
-
|
|
52
|
-
export { POINT_COUNT_RANGE, PolygonCorner, PolygonOutlineCommand, polygonCorners, polygonOutline };
|
|
51
|
+
export declare function polygonOutline(node: PolygonNode): PolygonOutlineCommand[];
|
|
52
|
+
export {};
|
|
53
53
|
//# sourceMappingURL=polygon.d.ts.map
|
package/dist/polygon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.d.ts","names":[],"sources":["../src/polygon.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","names":[],"sources":["../src/polygon.ts"],"mappings":";;;;;;;;qBAWa;;;;YAED;EACN;EAAiB;EAAW;;EAC5B;EAAW;EAAY;EAAY;EAAY;EAAY;EAAW;;EACtE;;KAED,cAAc,KACjB;iBAUe;EACf,QAAQ;;EAER,UAAU;;EAEV,UAAU;;EAEV;;EAEA;;EAEA;;;;;;;wBA2Bc,eAAe,MAAM,cAAc;;wBA8DnC,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,SAAS;;wBA0D7C,eAAe,MAAM,cAAc"}
|
package/dist/polygon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { polygonVertices } from "./geometry.js";
|
|
2
|
-
|
|
2
|
+
// src/polygon.ts
|
|
3
3
|
/**
|
|
4
4
|
* Rounded polygon and star outlines, as Figma draws them. Each corner, convex or not, is rounded by
|
|
5
5
|
* a circular arc tangent to both edges, capped so that it and its neighbours fit along every edge;
|
|
@@ -107,7 +107,8 @@ function rotate(direction, towards, angle) {
|
|
|
107
107
|
y: direction.y * Math.cos(angle) + normal.y * Math.sin(angle)
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
/** A cubic Bézier to `to` with control points `c1` and `c2`. */
|
|
111
|
+
function cubicTo(c1, c2, to) {
|
|
111
112
|
return {
|
|
112
113
|
type: "C",
|
|
113
114
|
x1: c1.x,
|
|
@@ -133,15 +134,15 @@ function cornerCommands(corner, smooth) {
|
|
|
133
134
|
const arcFrom = along(along(start, incoming, a + b + c), normalIn, d);
|
|
134
135
|
const arcTo = along(along(end, outgoing, -(a + b + c)), normalOut, d);
|
|
135
136
|
const commands = [];
|
|
136
|
-
if (ease > 0) commands.push(
|
|
137
|
+
if (ease > 0) commands.push(cubicTo(along(start, incoming, a), along(start, incoming, a + b), arcFrom));
|
|
137
138
|
const sweep = turn - 2 * ease;
|
|
138
139
|
if (sweep > 0) {
|
|
139
140
|
const handle = 4 / 3 * Math.tan(sweep / 4) * radius;
|
|
140
141
|
const leaving = rotate(incoming, outgoing, ease);
|
|
141
142
|
const arriving = rotate(outgoing, incoming, ease);
|
|
142
|
-
commands.push(
|
|
143
|
+
commands.push(cubicTo(along(arcFrom, leaving, handle), along(arcTo, arriving, -handle), arcTo));
|
|
143
144
|
}
|
|
144
|
-
if (ease > 0) commands.push(
|
|
145
|
+
if (ease > 0) commands.push(cubicTo(along(end, outgoing, -(a + b)), along(end, outgoing, -a), end));
|
|
145
146
|
return commands;
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
@@ -199,7 +200,6 @@ function polygonOutline(node) {
|
|
|
199
200
|
commands.push({ type: "Z" });
|
|
200
201
|
return commands;
|
|
201
202
|
}
|
|
202
|
-
|
|
203
|
-
export { POINT_COUNT_RANGE, polygonCorners, polygonOutline };
|
|
203
|
+
export { POINT_COUNT_RANGE, cubicTo, polygonCorners, polygonOutline };
|
|
204
204
|
|
|
205
205
|
//# sourceMappingURL=polygon.js.map
|
package/dist/polygon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.js","names":[],"sources":["../src/polygon.ts"],"sourcesContent":["import { polygonVertices } from './geometry'\nimport type { Vector } from './primitives'\nimport type { SceneNode } from './types'\n\n/**\n * Rounded polygon and star outlines, as Figma draws them. Each corner, convex or not, is rounded by\n * a circular arc tangent to both edges, capped so that it and its neighbours fit along every edge;\n * corner smoothing replaces the arc's ends with curves that ease into the edges, as on rectangles.\n */\n\n/** Figma keeps a polygon's sides or a star's points within this range, and its plugin API clamps to it. */\nexport const POINT_COUNT_RANGE = { min: 3, max: 60 } as const\n\nexport type PolygonOutlineCommand =\n | { type: 'M' | 'L'; x: number; y: number }\n | { type: 'C'; x1: number; y1: number; x2: number; y2: number; x: number; y: number }\n | { type: 'Z' }\n\ntype PolygonNode = Pick<\n SceneNode,\n | 'type'\n | 'width'\n | 'height'\n | 'pointCount'\n | 'starInnerRadius'\n | 'cornerRadius'\n | 'cornerSmoothing'\n>\n\nexport interface PolygonCorner {\n vertex: Vector\n /** The unit direction of the edge arriving at the vertex. */\n incoming: Vector\n /** The unit direction of the edge leaving the vertex. */\n outgoing: Vector\n /** How far the outline turns at the vertex, in radians: 0 for a straight line. */\n turn: number\n /** The radius the corner is drawn with, after fitting it along its edges. */\n radius: number\n /** How far along each edge from the vertex the rounding starts. */\n extent: number\n}\n\nconst sub = (a: Vector, b: Vector): Vector => ({ x: a.x - b.x, y: a.y - b.y })\nconst along = (point: Vector, direction: Vector, distance: number): Vector => ({\n x: point.x + direction.x * distance,\n y: point.y + direction.y * distance\n})\n\nfunction unit(vector: Vector): Vector {\n const length = Math.hypot(vector.x, vector.y)\n return length > 0 ? { x: vector.x / length, y: vector.y / length } : { x: 0, y: 0 }\n}\n\n/** The perpendicular of `direction` on the side the outline turns towards. */\nfunction inward(direction: Vector, towards: Vector): Vector {\n const normal = { x: -direction.y, y: direction.x }\n return normal.x * towards.x + normal.y * towards.y < 0\n ? { x: direction.y, y: -direction.x }\n : normal\n}\n\n/**\n * The polygon's or star's corners with the radius each is drawn with. A corner turning by α keeps\n * r·tan(α/2) of each edge, so on an edge of length L between corners turning by α and β the radius\n * is at most L / (tan(α/2) + tan(β/2)); each corner takes the least of its two edges' limits.\n */\nexport function polygonCorners(node: PolygonNode): PolygonCorner[] {\n const vertices = polygonVertices(node)\n const count = vertices.length\n const at = (index: number) => vertices[(index + count) % count]\n const shape = vertices.map((vertex, index) => {\n const incoming = unit(sub(vertex, at(index - 1)))\n const outgoing = unit(sub(at(index + 1), vertex))\n const cos = Math.min(1, Math.max(-1, incoming.x * outgoing.x + incoming.y * outgoing.y))\n const turn = Math.acos(cos)\n return { vertex, incoming, outgoing, turn, factor: Math.tan(turn / 2) }\n })\n const edgeLimit = (index: number) => {\n const from = shape[(index + count) % count]\n const to = shape[(index + 1 + count) % count]\n const length = Math.hypot(to.vertex.x - from.vertex.x, to.vertex.y - from.vertex.y)\n const factors = from.factor + to.factor\n return factors > 0 ? length / factors : Number.POSITIVE_INFINITY\n }\n const requested = Math.max(0, node.cornerRadius)\n return shape.map(({ factor, ...corner }, index) => {\n const radius = Math.min(requested, edgeLimit(index - 1), edgeLimit(index))\n return { ...corner, radius, extent: radius * factor }\n })\n}\n\ninterface SmoothCorner {\n /** Where the rounding starts, along each edge from the vertex. */\n p: number\n a: number\n b: number\n c: number\n d: number\n /** The angle each eased end takes from the arc, in radians. */\n ease: number\n}\n\n/**\n * Figma's smoothing for a corner turning by any angle: the rectangle construction with the\n * tangent length r·tan(α/2) in place of r and α/2 in place of 45°. Smoothing grows the rounded\n * part of each edge by up to its tangent length again.\n */\nfunction smoothCorner(corner: PolygonCorner, smoothing: number): SmoothCorner {\n const { radius, extent } = corner\n const p = (1 + smoothing) * extent\n const ease = (corner.turn * smoothing) / 2\n const toEase = radius * Math.tan(ease / 2)\n const c = toEase * Math.cos(ease)\n const d = toEase * Math.sin(ease)\n const arcStart = extent - radius * Math.sin(ease) - d\n const b = (p - arcStart - c - d) / 3\n return { p, a: 2 * b, b, c, d, ease }\n}\n\nfunction rotate(direction: Vector, towards: Vector, angle: number): Vector {\n const normal = inward(direction, towards)\n return {\n x: direction.x * Math.cos(angle) + normal.x * Math.sin(angle),\n y: direction.y * Math.cos(angle) + normal.y * Math.sin(angle)\n }\n}\n\nfunction cubic(c1: Vector, c2: Vector, to: Vector): PolygonOutlineCommand {\n return { type: 'C', x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: to.x, y: to.y }\n}\n\n/** The rounded corner from where it leaves the incoming edge to where it joins the outgoing one. */\nfunction cornerCommands(corner: PolygonCorner, smooth: SmoothCorner): PolygonOutlineCommand[] {\n const { vertex, incoming, outgoing, radius, turn } = corner\n const { p, a, b, c, d, ease } = smooth\n const back = { x: -incoming.x, y: -incoming.y }\n const start = along(vertex, back, p)\n const end = along(vertex, outgoing, p)\n const normalIn = inward(incoming, outgoing)\n const normalOut = inward(outgoing, back)\n const arcFrom = along(along(start, incoming, a + b + c), normalIn, d)\n const arcTo = along(along(end, outgoing, -(a + b + c)), normalOut, d)\n const commands: PolygonOutlineCommand[] = []\n if (ease > 0)\n commands.push(cubic(along(start, incoming, a), along(start, incoming, a + b), arcFrom))\n const sweep = turn - 2 * ease\n if (sweep > 0) {\n const handle = (4 / 3) * Math.tan(sweep / 4) * radius\n const leaving = rotate(incoming, outgoing, ease)\n const arriving = rotate(outgoing, incoming, ease)\n commands.push(cubic(along(arcFrom, leaving, handle), along(arcTo, arriving, -handle), arcTo))\n }\n if (ease > 0) commands.push(cubic(along(end, outgoing, -(a + b)), along(end, outgoing, -a), end))\n return commands\n}\n\n/**\n * The smoothing every corner can take: on each edge a corner may use the part its tangent length\n * takes of both corners' tangent lengths, and Figma lowers smoothing for the whole shape to what\n * its tightest corner allows rather than corner by corner.\n */\nfunction fittedSmoothing(corners: readonly PolygonCorner[], smoothing: number): number {\n const count = corners.length\n const share = (corner: PolygonCorner, neighbour: PolygonCorner) => {\n const length = Math.hypot(\n neighbour.vertex.x - corner.vertex.x,\n neighbour.vertex.y - corner.vertex.y\n )\n return (length * corner.extent) / (corner.extent + neighbour.extent)\n }\n return corners.reduce(\n (fitted, corner, index) => {\n if (!(corner.extent > 0)) return fitted\n const budget = Math.min(\n share(corner, corners[(index - 1 + count) % count]),\n share(corner, corners[(index + 1) % count])\n )\n return Math.min(fitted, budget / corner.extent - 1)\n },\n Math.min(Math.max(smoothing, 0), 1)\n )\n}\n\n/** The outline of a polygon or star with its corner radius and smoothing, in its own pixels. */\nexport function polygonOutline(node: PolygonNode): PolygonOutlineCommand[] {\n const corners = polygonCorners(node)\n const smoothing = Math.max(0, fittedSmoothing(corners, node.cornerSmoothing))\n const commands: PolygonOutlineCommand[] = []\n let current: Vector | null = null\n // Corners whose rounding meets along an edge leave no line between them.\n const lineTo = ({ x, y }: Vector) => {\n if (current && Math.hypot(x - current.x, y - current.y) < 1e-6) return\n commands.push({ type: current ? 'L' : 'M', x, y })\n current = { x, y }\n }\n for (const corner of corners) {\n if (!(corner.radius > 0) || !(corner.turn > 0)) {\n lineTo(corner.vertex)\n continue\n }\n const smooth = smoothCorner(corner, smoothing)\n lineTo(along(corner.vertex, { x: -corner.incoming.x, y: -corner.incoming.y }, smooth.p))\n for (const command of cornerCommands(corner, smooth)) {\n commands.push(command)\n if (command.type === 'C') current = { x: command.x, y: command.y }\n }\n }\n commands.push({ type: 'Z' })\n return commands\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,oBAAoB;CAAE,KAAK;CAAG,KAAK;AAAG;AAgCnD,MAAM,OAAO,GAAW,OAAuB;CAAE,GAAG,EAAE,IAAI,EAAE;CAAG,GAAG,EAAE,IAAI,EAAE;AAAE;AAC5E,MAAM,SAAS,OAAe,WAAmB,cAA8B;CAC7E,GAAG,MAAM,IAAI,UAAU,IAAI;CAC3B,GAAG,MAAM,IAAI,UAAU,IAAI;AAC7B;AAEA,SAAS,KAAK,QAAwB;CACpC,MAAM,SAAS,KAAK,MAAM,OAAO,GAAG,OAAO,CAAC;CAC5C,OAAO,SAAS,IAAI;EAAE,GAAG,OAA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"file":"polygon.js","names":[],"sources":["../src/polygon.ts"],"sourcesContent":["import { polygonVertices } from './geometry'\nimport type { Vector } from './primitives'\nimport type { SceneNode } from './types'\n\n/**\n * Rounded polygon and star outlines, as Figma draws them. Each corner, convex or not, is rounded by\n * a circular arc tangent to both edges, capped so that it and its neighbours fit along every edge;\n * corner smoothing replaces the arc's ends with curves that ease into the edges, as on rectangles.\n */\n\n/** Figma keeps a polygon's sides or a star's points within this range, and its plugin API clamps to it. */\nexport const POINT_COUNT_RANGE = { min: 3, max: 60 } as const\n\nexport type PolygonOutlineCommand =\n | { type: 'M' | 'L'; x: number; y: number }\n | { type: 'C'; x1: number; y1: number; x2: number; y2: number; x: number; y: number }\n | { type: 'Z' }\n\ntype PolygonNode = Pick<\n SceneNode,\n | 'type'\n | 'width'\n | 'height'\n | 'pointCount'\n | 'starInnerRadius'\n | 'cornerRadius'\n | 'cornerSmoothing'\n>\n\nexport interface PolygonCorner {\n vertex: Vector\n /** The unit direction of the edge arriving at the vertex. */\n incoming: Vector\n /** The unit direction of the edge leaving the vertex. */\n outgoing: Vector\n /** How far the outline turns at the vertex, in radians: 0 for a straight line. */\n turn: number\n /** The radius the corner is drawn with, after fitting it along its edges. */\n radius: number\n /** How far along each edge from the vertex the rounding starts. */\n extent: number\n}\n\nconst sub = (a: Vector, b: Vector): Vector => ({ x: a.x - b.x, y: a.y - b.y })\nconst along = (point: Vector, direction: Vector, distance: number): Vector => ({\n x: point.x + direction.x * distance,\n y: point.y + direction.y * distance\n})\n\nfunction unit(vector: Vector): Vector {\n const length = Math.hypot(vector.x, vector.y)\n return length > 0 ? { x: vector.x / length, y: vector.y / length } : { x: 0, y: 0 }\n}\n\n/** The perpendicular of `direction` on the side the outline turns towards. */\nfunction inward(direction: Vector, towards: Vector): Vector {\n const normal = { x: -direction.y, y: direction.x }\n return normal.x * towards.x + normal.y * towards.y < 0\n ? { x: direction.y, y: -direction.x }\n : normal\n}\n\n/**\n * The polygon's or star's corners with the radius each is drawn with. A corner turning by α keeps\n * r·tan(α/2) of each edge, so on an edge of length L between corners turning by α and β the radius\n * is at most L / (tan(α/2) + tan(β/2)); each corner takes the least of its two edges' limits.\n */\nexport function polygonCorners(node: PolygonNode): PolygonCorner[] {\n const vertices = polygonVertices(node)\n const count = vertices.length\n const at = (index: number) => vertices[(index + count) % count]\n const shape = vertices.map((vertex, index) => {\n const incoming = unit(sub(vertex, at(index - 1)))\n const outgoing = unit(sub(at(index + 1), vertex))\n const cos = Math.min(1, Math.max(-1, incoming.x * outgoing.x + incoming.y * outgoing.y))\n const turn = Math.acos(cos)\n return { vertex, incoming, outgoing, turn, factor: Math.tan(turn / 2) }\n })\n const edgeLimit = (index: number) => {\n const from = shape[(index + count) % count]\n const to = shape[(index + 1 + count) % count]\n const length = Math.hypot(to.vertex.x - from.vertex.x, to.vertex.y - from.vertex.y)\n const factors = from.factor + to.factor\n return factors > 0 ? length / factors : Number.POSITIVE_INFINITY\n }\n const requested = Math.max(0, node.cornerRadius)\n return shape.map(({ factor, ...corner }, index) => {\n const radius = Math.min(requested, edgeLimit(index - 1), edgeLimit(index))\n return { ...corner, radius, extent: radius * factor }\n })\n}\n\ninterface SmoothCorner {\n /** Where the rounding starts, along each edge from the vertex. */\n p: number\n a: number\n b: number\n c: number\n d: number\n /** The angle each eased end takes from the arc, in radians. */\n ease: number\n}\n\n/**\n * Figma's smoothing for a corner turning by any angle: the rectangle construction with the\n * tangent length r·tan(α/2) in place of r and α/2 in place of 45°. Smoothing grows the rounded\n * part of each edge by up to its tangent length again.\n */\nfunction smoothCorner(corner: PolygonCorner, smoothing: number): SmoothCorner {\n const { radius, extent } = corner\n const p = (1 + smoothing) * extent\n const ease = (corner.turn * smoothing) / 2\n const toEase = radius * Math.tan(ease / 2)\n const c = toEase * Math.cos(ease)\n const d = toEase * Math.sin(ease)\n const arcStart = extent - radius * Math.sin(ease) - d\n const b = (p - arcStart - c - d) / 3\n return { p, a: 2 * b, b, c, d, ease }\n}\n\nfunction rotate(direction: Vector, towards: Vector, angle: number): Vector {\n const normal = inward(direction, towards)\n return {\n x: direction.x * Math.cos(angle) + normal.x * Math.sin(angle),\n y: direction.y * Math.cos(angle) + normal.y * Math.sin(angle)\n }\n}\n\n/** A cubic Bézier to `to` with control points `c1` and `c2`. */\nexport function cubicTo(c1: Vector, c2: Vector, to: Vector): PolygonOutlineCommand {\n return { type: 'C', x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: to.x, y: to.y }\n}\n\n/** The rounded corner from where it leaves the incoming edge to where it joins the outgoing one. */\nfunction cornerCommands(corner: PolygonCorner, smooth: SmoothCorner): PolygonOutlineCommand[] {\n const { vertex, incoming, outgoing, radius, turn } = corner\n const { p, a, b, c, d, ease } = smooth\n const back = { x: -incoming.x, y: -incoming.y }\n const start = along(vertex, back, p)\n const end = along(vertex, outgoing, p)\n const normalIn = inward(incoming, outgoing)\n const normalOut = inward(outgoing, back)\n const arcFrom = along(along(start, incoming, a + b + c), normalIn, d)\n const arcTo = along(along(end, outgoing, -(a + b + c)), normalOut, d)\n const commands: PolygonOutlineCommand[] = []\n if (ease > 0)\n commands.push(cubicTo(along(start, incoming, a), along(start, incoming, a + b), arcFrom))\n const sweep = turn - 2 * ease\n if (sweep > 0) {\n const handle = (4 / 3) * Math.tan(sweep / 4) * radius\n const leaving = rotate(incoming, outgoing, ease)\n const arriving = rotate(outgoing, incoming, ease)\n commands.push(cubicTo(along(arcFrom, leaving, handle), along(arcTo, arriving, -handle), arcTo))\n }\n if (ease > 0)\n commands.push(cubicTo(along(end, outgoing, -(a + b)), along(end, outgoing, -a), end))\n return commands\n}\n\n/**\n * The smoothing every corner can take: on each edge a corner may use the part its tangent length\n * takes of both corners' tangent lengths, and Figma lowers smoothing for the whole shape to what\n * its tightest corner allows rather than corner by corner.\n */\nfunction fittedSmoothing(corners: readonly PolygonCorner[], smoothing: number): number {\n const count = corners.length\n const share = (corner: PolygonCorner, neighbour: PolygonCorner) => {\n const length = Math.hypot(\n neighbour.vertex.x - corner.vertex.x,\n neighbour.vertex.y - corner.vertex.y\n )\n return (length * corner.extent) / (corner.extent + neighbour.extent)\n }\n return corners.reduce(\n (fitted, corner, index) => {\n if (!(corner.extent > 0)) return fitted\n const budget = Math.min(\n share(corner, corners[(index - 1 + count) % count]),\n share(corner, corners[(index + 1) % count])\n )\n return Math.min(fitted, budget / corner.extent - 1)\n },\n Math.min(Math.max(smoothing, 0), 1)\n )\n}\n\n/** The outline of a polygon or star with its corner radius and smoothing, in its own pixels. */\nexport function polygonOutline(node: PolygonNode): PolygonOutlineCommand[] {\n const corners = polygonCorners(node)\n const smoothing = Math.max(0, fittedSmoothing(corners, node.cornerSmoothing))\n const commands: PolygonOutlineCommand[] = []\n let current: Vector | null = null\n // Corners whose rounding meets along an edge leave no line between them.\n const lineTo = ({ x, y }: Vector) => {\n if (current && Math.hypot(x - current.x, y - current.y) < 1e-6) return\n commands.push({ type: current ? 'L' : 'M', x, y })\n current = { x, y }\n }\n for (const corner of corners) {\n if (!(corner.radius > 0) || !(corner.turn > 0)) {\n lineTo(corner.vertex)\n continue\n }\n const smooth = smoothCorner(corner, smoothing)\n lineTo(along(corner.vertex, { x: -corner.incoming.x, y: -corner.incoming.y }, smooth.p))\n for (const command of cornerCommands(corner, smooth)) {\n commands.push(command)\n if (command.type === 'C') current = { x: command.x, y: command.y }\n }\n }\n commands.push({ type: 'Z' })\n return commands\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,oBAAoB;CAAE,KAAK;CAAG,KAAK;AAAG;AAgCnD,MAAM,OAAO,GAAW,OAAuB;CAAE,GAAG,EAAE,IAAI,EAAE;CAAG,GAAG,EAAE,IAAI,EAAE;AAAE;AAC5E,MAAM,SAAS,OAAe,WAAmB,cAA8B;CAC7E,GAAG,MAAM,IAAI,UAAU,IAAI;CAC3B,GAAG,MAAM,IAAI,UAAU,IAAI;AAC7B;AAEA,SAAS,KAAK,QAAwB;CACpC,MAAM,SAAS,KAAK,MAAM,OAAO,GAAG,OAAO,CAAC;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,CAAC;CAC3B,OAAO;AACT"}
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { SceneNode } from "./types.js";
|
|
2
|
-
|
|
3
|
-
type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void;
|
|
2
|
+
export type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void;
|
|
4
3
|
type PreviewGraph = {
|
|
5
4
|
nodes: Map<string, SceneNode>;
|
|
6
5
|
positionPreviewVersion: number;
|
|
7
6
|
clearAbsPosCache: () => void;
|
|
8
7
|
};
|
|
9
|
-
declare function updateNodePreview(graph: PreviewGraph, id: string, changes: Partial<SceneNode>, beforeUpdate?: NodePreviewObserver): Partial<SceneNode> | null;
|
|
10
|
-
|
|
11
|
-
export { NodePreviewObserver, updateNodePreview };
|
|
8
|
+
export declare function updateNodePreview(graph: PreviewGraph, id: string, changes: Partial<SceneNode>, beforeUpdate?: NodePreviewObserver): Partial<SceneNode> | null;
|
|
9
|
+
export {};
|
|
12
10
|
//# sourceMappingURL=preview.d.ts.map
|
package/dist/preview.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","names":[],"sources":["../src/preview.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"preview.d.ts","names":[],"sources":["../src/preview.ts"],"mappings":";YAIY,uBAAuB,MAAM,WAAW,SAAS,QAAQ;KAEhE;EACH,OAAO,YAAY;EACnB;EACA;;wBAwCc,kBACd,OAAO,cACP,YACA,SAAS,QAAQ,YACjB,eAAe,sBACd,QAAQ"}
|
package/dist/preview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { normalizeVectorNetwork } from "./vector-network.js";
|
|
2
1
|
import { textCacheInvalidationChanges } from "./text/picture.js";
|
|
3
|
-
|
|
2
|
+
import { normalizeVectorNetwork } from "./vector-network.js";
|
|
3
|
+
// src/preview.ts
|
|
4
4
|
const LAYOUT_AFFECTING_KEYS = /* @__PURE__ */ new Set([
|
|
5
5
|
"x",
|
|
6
6
|
"y",
|
|
@@ -57,7 +57,6 @@ function updateNodePreview(graph, id, changes, beforeUpdate) {
|
|
|
57
57
|
Object.assign(node, normalizedChanges);
|
|
58
58
|
return normalizedChanges;
|
|
59
59
|
}
|
|
60
|
-
//#endregion
|
|
61
60
|
export { updateNodePreview };
|
|
62
61
|
|
|
63
62
|
//# sourceMappingURL=preview.js.map
|