@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","names":[],"sources":["../../src/shape-with-text/geometry.ts"],"sourcesContent":["import type { PolygonOutlineCommand } from '../polygon'\nimport { databaseCap } from './fit'\nimport type { ShapeWithTextType } from './kinds'\n\nexport interface ShapeWithTextGeometry {\n /** The closed outline that is filled and stroked, and that connectors attach to. */\n outline: PolygonOutlineCommand[]\n /** Inner lines that are stroked only, such as a database's front rim. */\n details: PolygonOutlineCommand[]\n}\n\n/** Bezier handle length for a quarter ellipse. */\nconst KAPPA = 0.5522847498\n\ntype Point = readonly [number, number]\n\nfunction polygon(points: Point[]): PolygonOutlineCommand[] {\n const commands: PolygonOutlineCommand[] = points.map(([x, y], index) => ({\n type: index === 0 ? 'M' : 'L',\n x,\n y\n }))\n commands.push({ type: 'Z' })\n return commands\n}\n\nfunction line(from: Point, to: Point): PolygonOutlineCommand[] {\n return [\n { type: 'M', x: from[0], y: from[1] },\n { type: 'L', x: to[0], y: to[1] }\n ]\n}\n\nfunction curve(x1: number, y1: number, x2: number, y2: number, x: number, y: number) {\n return { type: 'C', x1, y1, x2, y2, x, y } as const\n}\n\nfunction ellipse(x: number, y: number, w: number, h: number): PolygonOutlineCommand[] {\n const rx = w / 2\n const ry = h / 2\n const cx = x + rx\n const cy = y + ry\n const kx = rx * KAPPA\n const ky = ry * KAPPA\n return [\n { type: 'M', x: cx, y },\n curve(cx + kx, y, x + w, cy - ky, x + w, cy),\n curve(x + w, cy + ky, cx + kx, y + h, cx, y + h),\n curve(cx - kx, y + h, x, cy + ky, x, cy),\n curve(x, cy - ky, cx - kx, y, cx, y),\n { type: 'Z' }\n ]\n}\n\nfunction roundedRect(w: number, h: number, radius: number): PolygonOutlineCommand[] {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2))\n const k = r * (1 - KAPPA)\n return [\n { type: 'M', x: r, y: 0 },\n { type: 'L', x: w - r, y: 0 },\n curve(w - k, 0, w, k, w, r),\n { type: 'L', x: w, y: h - r },\n curve(w, h - k, w - k, h, w - r, h),\n { type: 'L', x: r, y: h },\n curve(k, h, 0, h - k, 0, h - r),\n { type: 'L', x: 0, y: r },\n curve(0, k, k, 0, r, 0),\n { type: 'Z' }\n ]\n}\n\n/** A page with a wavy bottom edge, the flowchart \"document\" symbol. */\nfunction documentPage(x: number, y: number, w: number, h: number): PolygonOutlineCommand[] {\n const wave = h * 0.1\n const base = y + h - wave\n return [\n { type: 'M', x, y },\n { type: 'L', x: x + w, y },\n { type: 'L', x: x + w, y: base },\n curve(x + w * 0.8, base - wave * 1.2, x + w * 0.7, base - wave * 1.2, x + w * 0.5, base),\n curve(x + w * 0.3, base + wave, x + w * 0.2, base + wave, x, base),\n { type: 'Z' }\n ]\n}\n\nfunction star(w: number, h: number): Point[] {\n const points: Point[] = []\n for (let i = 0; i < 10; i++) {\n const angle = -Math.PI / 2 + (i * Math.PI) / 5\n const radius = i % 2 === 0 ? 1 : 0.382\n points.push([\n w / 2 + (Math.cos(angle) * radius * w) / 2,\n h / 2 + (Math.sin(angle) * radius * h) / 2 + h * 0.05\n ])\n }\n return points\n}\n\n/** A point on the ellipse filling the box, at `angle` radians clockwise from the right. */\nfunction onEllipse(w: number, h: number, angle: number): Point {\n return [w / 2 + (Math.cos(angle) * w) / 2, h / 2 + (Math.sin(angle) * h) / 2]\n}\n\n/** A plain box with stroke-only inner lines. */\nfunction boxWithLines(\n w: number,\n h: number,\n details: PolygonOutlineCommand[]\n): ShapeWithTextGeometry {\n return {\n outline: polygon([\n [0, 0],\n [w, 0],\n [w, h],\n [0, h]\n ]),\n details\n }\n}\n\n/** A rounded box with a tail below its left side; the tail joins the bottom edge. */\nfunction speechBubble(w: number, h: number): PolygonOutlineCommand[] {\n const body = h * 0.8\n const box = roundedRect(w, body, Math.min(w, body) * 0.2)\n // The fifth command draws the bottom edge leftwards; the tail goes just before it.\n const tail: PolygonOutlineCommand[] = [\n { type: 'L', x: w * 0.38, y: body },\n { type: 'L', x: w * 0.18, y: h },\n { type: 'L', x: w * 0.22, y: body }\n ]\n return [...box.slice(0, 5), ...tail, ...box.slice(5)]\n}\n\nconst plain = (outline: PolygonOutlineCommand[]): ShapeWithTextGeometry => ({\n outline,\n details: []\n})\n\ntype Builder = (w: number, h: number, min: number) => ShapeWithTextGeometry\n\n/** How far a parallelogram's sides lean: FigJam leans them with the height, not the width. */\nexport function parallelogramSlant(w: number, h: number): number {\n return Math.min(h * 0.43, w * 0.45)\n}\n\n/** Each kind's outline and inner lines for a `w` × `h` box, `min` being its shorter side. */\nconst BUILDERS: Record<ShapeWithTextType, Builder> = {\n SQUARE: (w, h) =>\n plain(\n polygon([\n [0, 0],\n [w, 0],\n [w, h],\n [0, h]\n ])\n ),\n ELLIPSE: (w, h) => plain(ellipse(0, 0, w, h)),\n DIAMOND: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h / 2],\n [w / 2, h],\n [0, h / 2]\n ])\n ),\n TRIANGLE_UP: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h],\n [0, h]\n ])\n ),\n TRIANGLE_DOWN: (w, h) =>\n plain(\n polygon([\n [0, 0],\n [w, 0],\n [w / 2, h]\n ])\n ),\n // FigJam rounds the ends to 0.4 of the shorter side, as its saved outlines show.\n ROUNDED_RECTANGLE: (w, h, min) => plain(roundedRect(w, h, min * 0.4)),\n PARALLELOGRAM_RIGHT: (w, h) => {\n const s = parallelogramSlant(w, h)\n return plain(\n polygon([\n [s, 0],\n [w, 0],\n [w - s, h],\n [0, h]\n ])\n )\n },\n PARALLELOGRAM_LEFT: (w, h) => {\n const s = parallelogramSlant(w, h)\n return plain(\n polygon([\n [0, 0],\n [w - s, 0],\n [w, h],\n [s, h]\n ])\n )\n },\n ENG_DATABASE: (w, h) => {\n const ry = databaseCap(w, h)\n const kx = (w / 2) * KAPPA\n const ky = ry * KAPPA\n return {\n outline: [\n { type: 'M', x: 0, y: ry },\n curve(0, ry - ky, w / 2 - kx, 0, w / 2, 0),\n curve(w / 2 + kx, 0, w, ry - ky, w, ry),\n { type: 'L', x: w, y: h - ry },\n curve(w, h - ry + ky, w / 2 + kx, h, w / 2, h),\n curve(w / 2 - kx, h, 0, h - ry + ky, 0, h - ry),\n { type: 'Z' }\n ],\n details: [\n { type: 'M', x: 0, y: ry },\n curve(0, ry + ky, w / 2 - kx, ry * 2, w / 2, ry * 2),\n curve(w / 2 + kx, ry * 2, w, ry + ky, w, ry)\n ]\n }\n },\n ENG_QUEUE: (w, h) => {\n const rx = Math.min(w * 0.15, h * 0.25)\n const kx = rx * KAPPA\n const ky = (h / 2) * KAPPA\n return {\n outline: [\n { type: 'M', x: rx, y: 0 },\n { type: 'L', x: w - rx, y: 0 },\n curve(w - rx + kx, 0, w, h / 2 - ky, w, h / 2),\n curve(w, h / 2 + ky, w - rx + kx, h, w - rx, h),\n { type: 'L', x: rx, y: h },\n curve(rx - kx, h, 0, h / 2 + ky, 0, h / 2),\n curve(0, h / 2 - ky, rx - kx, 0, rx, 0),\n { type: 'Z' }\n ],\n details: [\n { type: 'M', x: w - rx, y: 0 },\n curve(w - rx - kx, 0, w - rx * 2, h / 2 - ky, w - rx * 2, h / 2),\n curve(w - rx * 2, h / 2 + ky, w - rx - kx, h, w - rx, h)\n ]\n }\n },\n ENG_FILE: (w, h, min) => {\n const f = min * 0.25\n return {\n outline: polygon([\n [0, 0],\n [w - f, 0],\n [w, f],\n [w, h],\n [0, h]\n ]),\n details: [...line([w - f, 0], [w - f, f]), { type: 'L', x: w, y: f }]\n }\n },\n ENG_FOLDER: (w, h) => {\n const tab = Math.min(h * 0.18, w * 0.2)\n return plain(\n polygon([\n [0, 0],\n [w * 0.4, 0],\n [w * 0.4 + tab, tab],\n [w, tab],\n [w, h],\n [0, h]\n ])\n )\n },\n TRAPEZOID: (w, h) => {\n const s = Math.min(w * 0.2, h)\n return plain(\n polygon([\n [s, 0],\n [w - s, 0],\n [w, h],\n [0, h]\n ])\n )\n },\n PREDEFINED_PROCESS: (w, h) => {\n const e = Math.min(w * 0.1, h * 0.5)\n return boxWithLines(w, h, [...line([e, 0], [e, h]), ...line([w - e, 0], [w - e, h])])\n },\n SHIELD: (w, h) =>\n plain([\n { type: 'M', x: 0, y: 0 },\n { type: 'L', x: w, y: 0 },\n { type: 'L', x: w, y: h * 0.45 },\n curve(w, h * 0.75, w * 0.75, h * 0.9, w / 2, h),\n curve(w * 0.25, h * 0.9, 0, h * 0.75, 0, h * 0.45),\n { type: 'Z' }\n ]),\n DOCUMENT_SINGLE: (w, h) => plain(documentPage(0, 0, w, h)),\n DOCUMENT_MULTIPLE: (w, h, min) => {\n const o = min * 0.06\n return {\n outline: documentPage(0, o * 2, w - o * 2, h - o * 2),\n details: [\n ...line([o, o * 2], [o, o]),\n { type: 'L', x: w - o, y: o },\n { type: 'L', x: w - o, y: h - o * 2 },\n ...line([o * 2, o], [o * 2, 0]),\n { type: 'L', x: w, y: 0 },\n { type: 'L', x: w, y: h - o * 3 }\n ]\n }\n },\n MANUAL_INPUT: (w, h) =>\n plain(\n polygon([\n [0, h * 0.25],\n [w, 0],\n [w, h],\n [0, h]\n ])\n ),\n HEXAGON: (w, h) => {\n const s = Math.min(w * 0.25, h * 0.5)\n return plain(\n polygon([\n [s, 0],\n [w - s, 0],\n [w, h / 2],\n [w - s, h],\n [s, h],\n [0, h / 2]\n ])\n )\n },\n CHEVRON: (w, h) => {\n const p = Math.min(w * 0.25, h * 0.5)\n return plain(\n polygon([\n [0, 0],\n [w - p, 0],\n [w, h / 2],\n [w - p, h],\n [0, h],\n [p, h / 2]\n ])\n )\n },\n PENTAGON: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h * 0.38],\n [w * 0.81, h],\n [w * 0.19, h],\n [0, h * 0.38]\n ])\n ),\n OCTAGON: (w, h, min) => {\n const c = min * 0.29\n return plain(\n polygon([\n [c, 0],\n [w - c, 0],\n [w, c],\n [w, h - c],\n [w - c, h],\n [c, h],\n [0, h - c],\n [0, c]\n ])\n )\n },\n STAR: (w, h) => plain(polygon(star(w, h))),\n PLUS: (w, h) => {\n const a = w / 3\n const b = h / 3\n return plain(\n polygon([\n [a, 0],\n [a * 2, 0],\n [a * 2, b],\n [w, b],\n [w, b * 2],\n [a * 2, b * 2],\n [a * 2, h],\n [a, h],\n [a, b * 2],\n [0, b * 2],\n [0, b],\n [a, b]\n ])\n )\n },\n ARROW_RIGHT: (w, h) => {\n const head = Math.min(w * 0.4, h * 0.5)\n return plain(\n polygon([\n [0, h * 0.25],\n [w - head, h * 0.25],\n [w - head, 0],\n [w, h / 2],\n [w - head, h],\n [w - head, h * 0.75],\n [0, h * 0.75]\n ])\n )\n },\n ARROW_LEFT: (w, h) => {\n const head = Math.min(w * 0.4, h * 0.5)\n return plain(\n polygon([\n [w, h * 0.25],\n [head, h * 0.25],\n [head, 0],\n [0, h / 2],\n [head, h],\n [head, h * 0.75],\n [w, h * 0.75]\n ])\n )\n },\n SUMMING_JUNCTION: (w, h) => {\n const q = Math.PI / 4\n return {\n outline: ellipse(0, 0, w, h),\n details: [\n ...line(onEllipse(w, h, -q), onEllipse(w, h, Math.PI - q)),\n ...line(onEllipse(w, h, q), onEllipse(w, h, Math.PI + q))\n ]\n }\n },\n OR: (w, h) => ({\n outline: ellipse(0, 0, w, h),\n details: [...line([w / 2, 0], [w / 2, h]), ...line([0, h / 2], [w, h / 2])]\n }),\n SPEECH_BUBBLE: (w, h) => plain(speechBubble(w, h)),\n INTERNAL_STORAGE: (w, h, min) => {\n const e = min * 0.15\n return boxWithLines(w, h, [...line([e, 0], [e, h]), ...line([0, e], [w, e])])\n }\n}\n\n/**\n * The outline with each straight corner rounded to `radius` (FigJam rounds them all to its corner\n * radius), shortened where an edge is too short for it. Outlines with curves keep their shape.\n */\nfunction roundCorners(commands: PolygonOutlineCommand[], radius: number): PolygonOutlineCommand[] {\n if (radius <= 0 || commands.some((command) => command.type === 'C')) return commands\n const points: Point[] = []\n for (const command of commands) if (command.type !== 'Z') points.push([command.x, command.y])\n if (points.length < 3) return commands\n const rounded: PolygonOutlineCommand[] = []\n points.forEach((vertex, index) => {\n const before = points[(index + points.length - 1) % points.length]\n const after = points[(index + 1) % points.length]\n const toward = (to: Point): Point => {\n const length = Math.hypot(to[0] - vertex[0], to[1] - vertex[1])\n const t = length > 0 ? Math.min(radius, length / 2) / length : 0\n return [vertex[0] + (to[0] - vertex[0]) * t, vertex[1] + (to[1] - vertex[1]) * t]\n }\n const [inX, inY] = toward(before)\n const [outX, outY] = toward(after)\n rounded.push({ type: index === 0 ? 'M' : 'L', x: inX, y: inY })\n rounded.push(\n curve(\n inX + (vertex[0] - inX) * KAPPA,\n inY + (vertex[1] - inY) * KAPPA,\n outX + (vertex[0] - outX) * KAPPA,\n outY + (vertex[1] - outY) * KAPPA,\n outX,\n outY\n )\n )\n })\n rounded.push({ type: 'Z' })\n return rounded\n}\n\n/**\n * The outline and inner lines of a shape of `type` filling a `width` × `height` box. Outlines\n * made only of straight segments have their corners rounded to `cornerRadius`; outlines with\n * curves, such as a rounded rectangle, keep their own shape.\n */\nexport function shapeWithTextGeometry(\n type: ShapeWithTextType,\n width: number,\n height: number,\n cornerRadius = 0\n): ShapeWithTextGeometry {\n const w = Math.max(0, width)\n const h = Math.max(0, height)\n const geometry = BUILDERS[type](w, h, Math.min(w, h))\n return { ...geometry, outline: roundCorners(geometry.outline, cornerRadius) }\n}\n"],"mappings":";;;AAYA,MAAM,QAAQ;AAId,SAAS,QAAQ,QAA0C;CACzD,MAAM,WAAoC,OAAO,KAAK,CAAC,GAAG,IAAI,WAAW;EACvE,MAAM,UAAU,IAAI,MAAM;EAC1B;EACA;CACF,EAAE;CACF,SAAS,KAAK,EAAE,MAAM,IAAI,CAAC;CAC3B,OAAO;AACT;AAEA,SAAS,KAAK,MAAa,IAAoC;CAC7D,OAAO,CACL;EAAE,MAAM;EAAK,GAAG,KAAK;EAAI,GAAG,KAAK;CAAG,GACpC;EAAE,MAAM;EAAK,GAAG,GAAG;EAAI,GAAG,GAAG;CAAG,CAClC;AACF;AAEA,SAAS,MAAM,IAAY,IAAY,IAAY,IAAY,GAAW,GAAW;CACnF,OAAO;EAAE,MAAM;EAAK;EAAI;EAAI;EAAI;EAAI;EAAG;CAAE;AAC3C;AAEA,SAAS,QAAQ,GAAW,GAAW,GAAW,GAAoC;CACpF,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,KAAK;CAChB,MAAM,KAAK,KAAK;CAChB,OAAO;EACL;GAAE,MAAM;GAAK,GAAG;GAAI;EAAE;EACtB,MAAM,KAAK,IAAI,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,EAAE;EAC3C,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC;EAC/C,MAAM,KAAK,IAAI,IAAI,GAAG,GAAG,KAAK,IAAI,GAAG,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AM,SAAS,QAAQ,QAAQ,OAAO,SAAS,KAAK,OAAO;EAC3D,MAAM,QAAQ,QAAQ,QAAQ,KAAK,OAAO;EAC1C,MAAM,UAAU,OAAqB;GACnC,MAAM,SAAS,KAAK,MAAM,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO,EAAE;GAC9D,MAAM,IAAI,SAAS,IAAI,KAAK,IAAI,QAAQ,SAAS,CAAC,IAAI,SAAS;GAC/D,OAAO,CAAC,OAAO,MAAM,GAAG,KAAK,OAAO,MAAM,GAAG,OAAO,MAAM,GAAG,KAAK,OAAO,MAAM,CAAC;EAClF;EACA,MAAM,CAAC,KAAK,OAAO,OAAO,MAAM;EAChC,MAAM,CAAC,MAAM,QAAQ,OAAO,KAAK;EACjC,QAAQ,KAAK;GAAE,MAAM,UAAU,IAAI,MAAM;GAAK,GAAG;GAAK,GAAG;EAAI,CAAC;EAC9D,QAAQ,KACN,MACE,OAAO,OAAO,KAAK,OAAO,OAC1B,OAAO,OAAO,KAAK,OAAO,OAC1B,QAAQ,OAAO,KAAK,QAAQ,OAC5B,QAAQ,OAAO,KAAK,QAAQ,OAC5B,MACA,IACF,CACF;CACF,CAAC;CACD,QAAQ,KAAK,EAAE,MAAM,IAAI,CAAC;CAC1B,OAAO;AACT;;;;;;AAOA,SAAgB,sBACd,MACA,OACA,QACA,eAAe,GACQ;CACvB,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK;CAC3B,MAAM,IAAI,KAAK,IAAI,GAAG,MAAM;CAC5B,MAAM,WAAW,SAAS,KAAK,CAAC,GAAG,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;CACpD,OAAO;EAAE,GAAG;EAAU,SAAS,aAAa,SAAS,SAAS,YAAY;CAAE;AAC9E"}
|
|
1
|
+
{"version":3,"file":"geometry.js","names":[],"sources":["../../src/shape-with-text/geometry.ts"],"sourcesContent":["import { drawsStroke, KAPPA } from '../geometry'\nimport type { PolygonOutlineCommand } from '../polygon'\nimport type { SceneNode } from '../types'\nimport { documentOutline } from './document'\nimport { databaseCap } from './fit'\nimport type { ShapeWithTextType } from './kinds'\n\nexport interface ShapeWithTextGeometry {\n /** The closed outline that is filled and stroked, and that connectors attach to. */\n outline: PolygonOutlineCommand[]\n /** Inner lines that are stroked only, such as a database's front rim. */\n details: PolygonOutlineCommand[]\n}\n\n/**\n * The band FigJam cuts out of a shape's fill along its outline and inner lines when no stroke\n * draws them, so a database still shows its rim: half of it insets the outline.\n */\nexport const SHAPE_WITH_TEXT_LINE_GAP = 3\n\n/** A folder's tab: its height, and how far its base reaches past the middle of the box. */\nconst FOLDER_TAB_HEIGHT = 44\nconst FOLDER_TAB_OVERHANG = 13\n/** How far the tab's sides lean in over its full height. */\nconst FOLDER_TAB_SLANT = 18\n/** How far a multiple document's front page sits right of and below its back page. */\nconst DOCUMENT_OFFSET = 16\n\ntype Point = readonly [number, number]\n\nfunction polygon(points: Point[]): PolygonOutlineCommand[] {\n const commands: PolygonOutlineCommand[] = points.map(([x, y], index) => ({\n type: index === 0 ? 'M' : 'L',\n x,\n y\n }))\n commands.push({ type: 'Z' })\n return commands\n}\n\nfunction line(from: Point, to: Point): PolygonOutlineCommand[] {\n return [\n { type: 'M', x: from[0], y: from[1] },\n { type: 'L', x: to[0], y: to[1] }\n ]\n}\n\nfunction curve(x1: number, y1: number, x2: number, y2: number, x: number, y: number) {\n return { type: 'C', x1, y1, x2, y2, x, y } as const\n}\n\nfunction ellipse(x: number, y: number, w: number, h: number): PolygonOutlineCommand[] {\n const rx = w / 2\n const ry = h / 2\n const cx = x + rx\n const cy = y + ry\n const kx = rx * KAPPA\n const ky = ry * KAPPA\n return [\n { type: 'M', x: cx, y },\n curve(cx + kx, y, x + w, cy - ky, x + w, cy),\n curve(x + w, cy + ky, cx + kx, y + h, cx, y + h),\n curve(cx - kx, y + h, x, cy + ky, x, cy),\n curve(x, cy - ky, cx - kx, y, cx, y),\n { type: 'Z' }\n ]\n}\n\nfunction roundedRect(w: number, h: number, radius: number): PolygonOutlineCommand[] {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2))\n const k = r * (1 - KAPPA)\n return [\n { type: 'M', x: r, y: 0 },\n { type: 'L', x: w - r, y: 0 },\n curve(w - k, 0, w, k, w, r),\n { type: 'L', x: w, y: h - r },\n curve(w, h - k, w - k, h, w - r, h),\n { type: 'L', x: r, y: h },\n curve(k, h, 0, h - k, 0, h - r),\n { type: 'L', x: 0, y: r },\n curve(0, k, k, 0, r, 0),\n { type: 'Z' }\n ]\n}\n\n/** A page with a wavy bottom edge, the flowchart \"document\" symbol. */\nfunction documentPage(x: number, y: number, w: number, h: number): PolygonOutlineCommand[] {\n const wave = h * 0.1\n const base = y + h - wave\n return [\n { type: 'M', x, y },\n { type: 'L', x: x + w, y },\n { type: 'L', x: x + w, y: base },\n curve(x + w * 0.8, base - wave * 1.2, x + w * 0.7, base - wave * 1.2, x + w * 0.5, base),\n curve(x + w * 0.3, base + wave, x + w * 0.2, base + wave, x, base),\n { type: 'Z' }\n ]\n}\n\nfunction star(w: number, h: number): Point[] {\n const points: Point[] = []\n for (let i = 0; i < 10; i++) {\n const angle = -Math.PI / 2 + (i * Math.PI) / 5\n const radius = i % 2 === 0 ? 1 : 0.382\n points.push([\n w / 2 + (Math.cos(angle) * radius * w) / 2,\n h / 2 + (Math.sin(angle) * radius * h) / 2 + h * 0.05\n ])\n }\n return points\n}\n\n/** A point on the ellipse filling the box, at `angle` radians clockwise from the right. */\nfunction onEllipse(w: number, h: number, angle: number): Point {\n return [w / 2 + (Math.cos(angle) * w) / 2, h / 2 + (Math.sin(angle) * h) / 2]\n}\n\n/** A plain box with stroke-only inner lines. */\nfunction boxWithLines(\n w: number,\n h: number,\n details: PolygonOutlineCommand[]\n): ShapeWithTextGeometry {\n return {\n outline: polygon([\n [0, 0],\n [w, 0],\n [w, h],\n [0, h]\n ]),\n details\n }\n}\n\n/** A rounded box with a tail below its left side; the tail joins the bottom edge. */\nfunction speechBubble(w: number, h: number): PolygonOutlineCommand[] {\n const body = h * 0.8\n const box = roundedRect(w, body, Math.min(w, body) * 0.2)\n // The fifth command draws the bottom edge leftwards; the tail goes just before it.\n const tail: PolygonOutlineCommand[] = [\n { type: 'L', x: w * 0.38, y: body },\n { type: 'L', x: w * 0.18, y: h },\n { type: 'L', x: w * 0.22, y: body }\n ]\n return [...box.slice(0, 5), ...tail, ...box.slice(5)]\n}\n\nconst plain = (outline: PolygonOutlineCommand[]): ShapeWithTextGeometry => ({\n outline,\n details: []\n})\n\ntype Builder = (w: number, h: number, min: number, radius: number) => ShapeWithTextGeometry\n\n/** How far a parallelogram's sides lean: FigJam leans them with the height, not the width. */\nexport function parallelogramSlant(w: number, h: number): number {\n return Math.min(h * 0.43, w * 0.45)\n}\n\n/** Each kind's outline and inner lines for a `w` × `h` box, `min` being its shorter side. */\nconst BUILDERS: Record<ShapeWithTextType, Builder> = {\n SQUARE: (w, h) =>\n plain(\n polygon([\n [0, 0],\n [w, 0],\n [w, h],\n [0, h]\n ])\n ),\n ELLIPSE: (w, h) => plain(ellipse(0, 0, w, h)),\n DIAMOND: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h / 2],\n [w / 2, h],\n [0, h / 2]\n ])\n ),\n TRIANGLE_UP: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h],\n [0, h]\n ])\n ),\n TRIANGLE_DOWN: (w, h) =>\n plain(\n polygon([\n [0, 0],\n [w, 0],\n [w / 2, h]\n ])\n ),\n // FigJam rounds the ends to 0.4 of the shorter side, as its saved outlines show.\n ROUNDED_RECTANGLE: (w, h, min) => plain(roundedRect(w, h, min * 0.4)),\n PARALLELOGRAM_RIGHT: (w, h) => {\n const s = parallelogramSlant(w, h)\n return plain(\n polygon([\n [s, 0],\n [w, 0],\n [w - s, h],\n [0, h]\n ])\n )\n },\n PARALLELOGRAM_LEFT: (w, h) => {\n const s = parallelogramSlant(w, h)\n return plain(\n polygon([\n [0, 0],\n [w - s, 0],\n [w, h],\n [s, h]\n ])\n )\n },\n ENG_DATABASE: (w, h) => {\n const ry = databaseCap(w, h)\n const kx = (w / 2) * KAPPA\n const ky = ry * KAPPA\n return {\n outline: [\n { type: 'M', x: 0, y: ry },\n curve(0, ry - ky, w / 2 - kx, 0, w / 2, 0),\n curve(w / 2 + kx, 0, w, ry - ky, w, ry),\n { type: 'L', x: w, y: h - ry },\n curve(w, h - ry + ky, w / 2 + kx, h, w / 2, h),\n curve(w / 2 - kx, h, 0, h - ry + ky, 0, h - ry),\n { type: 'Z' }\n ],\n details: [\n { type: 'M', x: 0, y: ry },\n curve(0, ry + ky, w / 2 - kx, ry * 2, w / 2, ry * 2),\n curve(w / 2 + kx, ry * 2, w, ry + ky, w, ry)\n ]\n }\n },\n ENG_QUEUE: (w, h) => {\n const rx = Math.min(w * 0.15, h * 0.25)\n const kx = rx * KAPPA\n const ky = (h / 2) * KAPPA\n return {\n outline: [\n { type: 'M', x: rx, y: 0 },\n { type: 'L', x: w - rx, y: 0 },\n curve(w - rx + kx, 0, w, h / 2 - ky, w, h / 2),\n curve(w, h / 2 + ky, w - rx + kx, h, w - rx, h),\n { type: 'L', x: rx, y: h },\n curve(rx - kx, h, 0, h / 2 + ky, 0, h / 2),\n curve(0, h / 2 - ky, rx - kx, 0, rx, 0),\n { type: 'Z' }\n ],\n details: [\n { type: 'M', x: w - rx, y: 0 },\n curve(w - rx - kx, 0, w - rx * 2, h / 2 - ky, w - rx * 2, h / 2),\n curve(w - rx * 2, h / 2 + ky, w - rx - kx, h, w - rx, h)\n ]\n }\n },\n ENG_FILE: (w, h, min) => {\n const f = min * 0.25\n return {\n outline: polygon([\n [0, 0],\n [w - f, 0],\n [w, f],\n [w, h],\n [0, h]\n ]),\n details: [...line([w - f, 0], [w - f, f]), { type: 'L', x: w, y: f }]\n }\n },\n // A tab on the left of the box above a body; the line between them is the body's top edge.\n // The corners where tab and body meet stay sharp.\n ENG_FOLDER: (w, h, _min, radius) => {\n const tab = Math.min(FOLDER_TAB_HEIGHT, h)\n const base = Math.min(w / 2 + FOLDER_TAB_OVERHANG, w)\n const slant = Math.min((FOLDER_TAB_SLANT * tab) / FOLDER_TAB_HEIGHT, base / 2)\n return {\n outline: roundedPolygon(\n [\n [0, h],\n [0, tab],\n [slant, 0],\n [base - slant, 0],\n [base, tab],\n [w, tab],\n [w, h]\n ],\n [radius, 0, radius, radius, 0, radius, radius]\n ),\n details: line([0, tab], [base, tab])\n }\n },\n TRAPEZOID: (w, h) => {\n const s = Math.min(w * 0.2, h)\n return plain(\n polygon([\n [s, 0],\n [w - s, 0],\n [w, h],\n [0, h]\n ])\n )\n },\n PREDEFINED_PROCESS: (w, h) => {\n const e = Math.min(w * 0.1, h * 0.5)\n return boxWithLines(w, h, [...line([e, 0], [e, h]), ...line([w - e, 0], [w - e, h])])\n },\n SHIELD: (w, h) =>\n plain([\n { type: 'M', x: 0, y: 0 },\n { type: 'L', x: w, y: 0 },\n { type: 'L', x: w, y: h * 0.45 },\n curve(w, h * 0.75, w * 0.75, h * 0.9, w / 2, h),\n curve(w * 0.25, h * 0.9, 0, h * 0.75, 0, h * 0.45),\n { type: 'Z' }\n ]),\n DOCUMENT_SINGLE: (w, h, _min, radius) => plain(documentOutline(w, h, radius)),\n // A back page with a front page over its lower right; the front page's top and left edges,\n // where it lies over the back one, are the inner lines.\n DOCUMENT_MULTIPLE: (w, h, _min, radius) => {\n const o = Math.min(DOCUMENT_OFFSET, w / 4, h / 4)\n const front = documentPage(o, o, w - o, h - o)\n const wave = front.filter((command) => command.type === 'C')\n const base = wave.at(-1)?.y ?? h\n // The back page ends on the front page's left side, sloping down to it.\n const join = Math.min(h - 2 * o, base)\n const outline = roundedPolygon(\n [\n [0, 0],\n [w - o, 0],\n [w - o, o],\n [w, o],\n [w, base],\n [o, base],\n [o, join],\n [0, join - o / 4]\n ],\n [radius, radius, 0, radius, 0, 0, 0, radius]\n )\n // The straight edge along the bottom becomes the front page's wave.\n const bottom = outline.findIndex(\n (command) => command.type === 'L' && command.x === o && command.y === base\n )\n return {\n outline: [...outline.slice(0, bottom), ...wave, ...outline.slice(bottom + 1)],\n details: [...line([w - o, o], [o, o]), { type: 'L', x: o, y: join }]\n }\n },\n MANUAL_INPUT: (w, h) =>\n plain(\n polygon([\n [0, h * 0.25],\n [w, 0],\n [w, h],\n [0, h]\n ])\n ),\n HEXAGON: (w, h) => {\n const s = Math.min(w * 0.25, h * 0.5)\n return plain(\n polygon([\n [s, 0],\n [w - s, 0],\n [w, h / 2],\n [w - s, h],\n [s, h],\n [0, h / 2]\n ])\n )\n },\n CHEVRON: (w, h) => {\n const p = Math.min(w * 0.25, h * 0.5)\n return plain(\n polygon([\n [0, 0],\n [w - p, 0],\n [w, h / 2],\n [w - p, h],\n [0, h],\n [p, h / 2]\n ])\n )\n },\n PENTAGON: (w, h) =>\n plain(\n polygon([\n [w / 2, 0],\n [w, h * 0.38],\n [w * 0.81, h],\n [w * 0.19, h],\n [0, h * 0.38]\n ])\n ),\n OCTAGON: (w, h, min) => {\n const c = min * 0.29\n return plain(\n polygon([\n [c, 0],\n [w - c, 0],\n [w, c],\n [w, h - c],\n [w - c, h],\n [c, h],\n [0, h - c],\n [0, c]\n ])\n )\n },\n STAR: (w, h) => plain(polygon(star(w, h))),\n PLUS: (w, h) => {\n const a = w / 3\n const b = h / 3\n return plain(\n polygon([\n [a, 0],\n [a * 2, 0],\n [a * 2, b],\n [w, b],\n [w, b * 2],\n [a * 2, b * 2],\n [a * 2, h],\n [a, h],\n [a, b * 2],\n [0, b * 2],\n [0, b],\n [a, b]\n ])\n )\n },\n ARROW_RIGHT: (w, h) => {\n const head = Math.min(w * 0.4, h * 0.5)\n return plain(\n polygon([\n [0, h * 0.25],\n [w - head, h * 0.25],\n [w - head, 0],\n [w, h / 2],\n [w - head, h],\n [w - head, h * 0.75],\n [0, h * 0.75]\n ])\n )\n },\n ARROW_LEFT: (w, h) => {\n const head = Math.min(w * 0.4, h * 0.5)\n return plain(\n polygon([\n [w, h * 0.25],\n [head, h * 0.25],\n [head, 0],\n [0, h / 2],\n [head, h],\n [head, h * 0.75],\n [w, h * 0.75]\n ])\n )\n },\n SUMMING_JUNCTION: (w, h) => {\n const q = Math.PI / 4\n return {\n outline: ellipse(0, 0, w, h),\n details: [\n ...line(onEllipse(w, h, -q), onEllipse(w, h, Math.PI - q)),\n ...line(onEllipse(w, h, q), onEllipse(w, h, Math.PI + q))\n ]\n }\n },\n OR: (w, h) => ({\n outline: ellipse(0, 0, w, h),\n details: [...line([w / 2, 0], [w / 2, h]), ...line([0, h / 2], [w, h / 2])]\n }),\n SPEECH_BUBBLE: (w, h) => plain(speechBubble(w, h)),\n INTERNAL_STORAGE: (w, h, min) => {\n const e = min * 0.15\n return boxWithLines(w, h, [...line([e, 0], [e, h]), ...line([0, e], [w, e])])\n }\n}\n\n/**\n * The outline with each straight corner rounded to `radius` (FigJam rounds them all to its corner\n * radius), shortened where an edge is too short for it. Outlines with curves keep their shape.\n */\nfunction roundCorners(commands: PolygonOutlineCommand[], radius: number): PolygonOutlineCommand[] {\n if (radius <= 0 || commands.some((command) => command.type === 'C')) return commands\n const points: Point[] = []\n for (const command of commands) if (command.type !== 'Z') points.push([command.x, command.y])\n if (points.length < 3) return commands\n return roundedPolygon(\n points,\n points.map(() => radius)\n )\n}\n\n/**\n * The closed polygon through `points` with the corner at each rounded to its own radius in\n * `radii`, shortened where an edge is too short for it; a corner with radius 0 stays sharp.\n */\nfunction roundedPolygon(points: Point[], radii: number[]): PolygonOutlineCommand[] {\n const rounded: PolygonOutlineCommand[] = []\n points.forEach((vertex, index) => {\n const radius = radii[index] ?? 0\n const type = index === 0 ? 'M' : 'L'\n if (radius <= 0) {\n rounded.push({ type, x: vertex[0], y: vertex[1] })\n return\n }\n const before = points[(index + points.length - 1) % points.length]\n const after = points[(index + 1) % points.length]\n const toward = (to: Point): Point => {\n const length = Math.hypot(to[0] - vertex[0], to[1] - vertex[1])\n const t = length > 0 ? Math.min(radius, length / 2) / length : 0\n return [vertex[0] + (to[0] - vertex[0]) * t, vertex[1] + (to[1] - vertex[1]) * t]\n }\n const [inX, inY] = toward(before)\n const [outX, outY] = toward(after)\n rounded.push({ type, x: inX, y: inY })\n rounded.push(\n curve(\n inX + (vertex[0] - inX) * KAPPA,\n inY + (vertex[1] - inY) * KAPPA,\n outX + (vertex[0] - outX) * KAPPA,\n outY + (vertex[1] - outY) * KAPPA,\n outX,\n outY\n )\n )\n })\n rounded.push({ type: 'Z' })\n return rounded\n}\n\n/**\n * The outline and inner lines of a shape of `type` filling a `width` × `height` box. Outlines\n * made only of straight segments have their corners rounded to `cornerRadius`; outlines with\n * curves, such as a rounded rectangle, keep their own shape.\n */\nexport function shapeWithTextGeometry(\n type: ShapeWithTextType,\n width: number,\n height: number,\n cornerRadius = 0\n): ShapeWithTextGeometry {\n const w = Math.max(0, width)\n const h = Math.max(0, height)\n const geometry = BUILDERS[type](w, h, Math.min(w, h), cornerRadius)\n return { ...geometry, outline: roundCorners(geometry.outline, cornerRadius) }\n}\n\n/**\n * Whether the shape's fill has its outline and inner lines cut out of it, as FigJam draws a shape\n * with inner lines, such as a database, when no stroke draws them: it has inner lines and no\n * visible stroke.\n */\nexport function shapeWithTextCutsFill(\n node: Pick<SceneNode, 'type' | 'shapeWithTextType' | 'width' | 'height' | 'strokes'>\n): boolean {\n if (node.strokes.some((stroke) => stroke.opacity > 0 && drawsStroke(node, stroke))) return false\n return shapeWithTextGeometry(node.shapeWithTextType, node.width, node.height).details.length > 0\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,2BAA2B;;AAGxC,MAAM,oBAAoB;AAC1B,MAAM,sBAAsB;;AAE5B,MAAM,mBAAmB;;AAEzB,MAAM,kBAAkB;AAIxB,SAAS,QAAQ,QAA0C;CACzD,MAAM,WAAoC,OAAO,KAAK,CAAC,GAAG,IAAI,WAAW;EACvE,MAAM,UAAU,IAAI,MAAM;EAC1B;EACA;CACF,EAAE;CACF,SAAS,KAAK,EAAE,MAAM,IAAI,CAAC;CAC3B,OAAO;AACT;AAEA,S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AI,CAAC;CAC1B,OAAO;AACT;;;;;;AAOA,SAAgB,sBACd,MACA,OACA,QACA,eAAe,GACQ;CACvB,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK;CAC3B,MAAM,IAAI,KAAK,IAAI,GAAG,MAAM;CAC5B,MAAM,WAAW,SAAS,KAAK,CAAC,GAAG,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,YAAY;CAClE,OAAO;EAAE,GAAG;EAAU,SAAS,aAAa,SAAS,SAAS,YAAY;CAAE;AAC9E;;;;;;AAOA,SAAgB,sBACd,MACS;CACT,IAAI,KAAK,QAAQ,MAAM,WAAW,OAAO,UAAU,KAAK,YAAY,MAAM,MAAM,CAAC,GAAG,OAAO;CAC3F,OAAO,sBAAsB,KAAK,mBAAmB,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,QAAQ,SAAS;AACjG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_TYPES, ShapeWithTextType, isShapeWithTextType } from "./kinds.js";
|
|
2
|
-
import { ShapeWithTextGeometry, parallelogramSlant, shapeWithTextGeometry } from "./geometry.js";
|
|
2
|
+
import { SHAPE_WITH_TEXT_LINE_GAP, ShapeWithTextGeometry, parallelogramSlant, shapeWithTextCutsFill, shapeWithTextGeometry } from "./geometry.js";
|
|
3
3
|
import { LabelBox, LabelMeasure, databaseCap, fitShapeWithTextHeight, shapeWithTextGrows, shapeWithTextLabelBox } from "./fit.js";
|
|
4
|
-
export { type LabelBox, type LabelMeasure, SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_TYPES, ShapeWithTextGeometry, ShapeWithTextType, databaseCap, fitShapeWithTextHeight, isShapeWithTextType, parallelogramSlant, shapeWithTextGeometry, shapeWithTextGrows, shapeWithTextLabelBox };
|
|
4
|
+
export { type LabelBox, type LabelMeasure, SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_LINE_GAP, SHAPE_WITH_TEXT_TYPES, ShapeWithTextGeometry, ShapeWithTextType, databaseCap, fitShapeWithTextHeight, isShapeWithTextType, parallelogramSlant, shapeWithTextCutsFill, shapeWithTextGeometry, shapeWithTextGrows, shapeWithTextLabelBox };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { databaseCap, fitShapeWithTextHeight, shapeWithTextGrows, shapeWithTextLabelBox } from "./fit.js";
|
|
2
1
|
import { SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_TYPES, isShapeWithTextType } from "./kinds.js";
|
|
3
|
-
import { parallelogramSlant, shapeWithTextGeometry } from "./geometry.js";
|
|
4
|
-
|
|
2
|
+
import { SHAPE_WITH_TEXT_LINE_GAP, parallelogramSlant, shapeWithTextCutsFill, shapeWithTextGeometry } from "./geometry.js";
|
|
3
|
+
import { databaseCap, fitShapeWithTextHeight, shapeWithTextGrows, shapeWithTextLabelBox } from "./fit.js";
|
|
4
|
+
export { SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_LINE_GAP, SHAPE_WITH_TEXT_TYPES, databaseCap, fitShapeWithTextHeight, isShapeWithTextType, parallelogramSlant, shapeWithTextCutsFill, shapeWithTextGeometry, shapeWithTextGrows, shapeWithTextLabelBox };
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
//#region src/shape-with-text/kinds.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* FigJam's shape-with-text kinds, as Figma names them in `.fig` files and in its plugin API
|
|
4
3
|
* (`ShapeWithTextNode.shapeType`). Each kind is drawn from its size here, so rendering, hit
|
|
5
4
|
* testing, export and connectors share one outline.
|
|
6
5
|
*/
|
|
7
|
-
declare const SHAPE_WITH_TEXT_TYPES: readonly ["SQUARE", "ELLIPSE", "DIAMOND", "TRIANGLE_UP", "TRIANGLE_DOWN", "ROUNDED_RECTANGLE", "PARALLELOGRAM_RIGHT", "PARALLELOGRAM_LEFT", "ENG_DATABASE", "ENG_QUEUE", "ENG_FILE", "ENG_FOLDER", "TRAPEZOID", "PREDEFINED_PROCESS", "SHIELD", "DOCUMENT_SINGLE", "DOCUMENT_MULTIPLE", "MANUAL_INPUT", "HEXAGON", "CHEVRON", "PENTAGON", "OCTAGON", "STAR", "PLUS", "ARROW_LEFT", "ARROW_RIGHT", "SUMMING_JUNCTION", "OR", "SPEECH_BUBBLE", "INTERNAL_STORAGE"];
|
|
8
|
-
type ShapeWithTextType = (typeof SHAPE_WITH_TEXT_TYPES)[number];
|
|
9
|
-
declare function isShapeWithTextType(value: unknown): value is ShapeWithTextType;
|
|
6
|
+
export declare const SHAPE_WITH_TEXT_TYPES: readonly ["SQUARE", "ELLIPSE", "DIAMOND", "TRIANGLE_UP", "TRIANGLE_DOWN", "ROUNDED_RECTANGLE", "PARALLELOGRAM_RIGHT", "PARALLELOGRAM_LEFT", "ENG_DATABASE", "ENG_QUEUE", "ENG_FILE", "ENG_FOLDER", "TRAPEZOID", "PREDEFINED_PROCESS", "SHIELD", "DOCUMENT_SINGLE", "DOCUMENT_MULTIPLE", "MANUAL_INPUT", "HEXAGON", "CHEVRON", "PENTAGON", "OCTAGON", "STAR", "PLUS", "ARROW_LEFT", "ARROW_RIGHT", "SUMMING_JUNCTION", "OR", "SPEECH_BUBBLE", "INTERNAL_STORAGE"];
|
|
7
|
+
export type ShapeWithTextType = (typeof SHAPE_WITH_TEXT_TYPES)[number];
|
|
8
|
+
export declare function isShapeWithTextType(value: unknown): value is ShapeWithTextType;
|
|
10
9
|
/**
|
|
11
10
|
* The kinds as FigJam's Shapes panel offers them, in its order: Basic, then Flowchart. Together
|
|
12
11
|
* they are every kind.
|
|
13
12
|
*/
|
|
14
|
-
declare const SHAPE_WITH_TEXT_GROUPS: {
|
|
13
|
+
export declare const SHAPE_WITH_TEXT_GROUPS: {
|
|
15
14
|
readonly basic: readonly ["SQUARE", "ELLIPSE", "DIAMOND", "TRIANGLE_UP", "TRIANGLE_DOWN", "ROUNDED_RECTANGLE", "PENTAGON", "OCTAGON", "PLUS", "ARROW_LEFT", "ARROW_RIGHT", "CHEVRON", "STAR", "SPEECH_BUBBLE"];
|
|
16
15
|
readonly flowchart: readonly ["PARALLELOGRAM_RIGHT", "PARALLELOGRAM_LEFT", "ENG_DATABASE", "ENG_QUEUE", "ENG_FILE", "ENG_FOLDER", "DOCUMENT_SINGLE", "DOCUMENT_MULTIPLE", "PREDEFINED_PROCESS", "SHIELD", "TRAPEZOID", "MANUAL_INPUT", "HEXAGON", "INTERNAL_STORAGE", "OR", "SUMMING_JUNCTION"];
|
|
17
16
|
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_TYPES, ShapeWithTextType, isShapeWithTextType };
|
|
20
17
|
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","names":[],"sources":["../../src/shape-with-text/kinds.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","names":[],"sources":["../../src/shape-with-text/kinds.ts"],"mappings":";;;;;qBAKa;YAiCD,4BAA4B;wBAIxB,oBAAoB,iBAAiB,SAAS;;;;;qBAQjD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/shape-with-text/kinds.ts
|
|
2
2
|
/**
|
|
3
3
|
* FigJam's shape-with-text kinds, as Figma names them in `.fig` files and in its plugin API
|
|
4
4
|
* (`ShapeWithTextNode.shapeType`). Each kind is drawn from its size here, so rendering, hit
|
|
@@ -80,7 +80,6 @@ const SHAPE_WITH_TEXT_GROUPS = {
|
|
|
80
80
|
"SUMMING_JUNCTION"
|
|
81
81
|
]
|
|
82
82
|
};
|
|
83
|
-
//#endregion
|
|
84
83
|
export { SHAPE_WITH_TEXT_GROUPS, SHAPE_WITH_TEXT_TYPES, isShapeWithTextType };
|
|
85
84
|
|
|
86
85
|
//# sourceMappingURL=kinds.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SceneNode, SharedStyleType } from "./types.js";
|
|
2
|
+
type NodeMap = ReadonlyMap<string, SceneNode>;
|
|
3
|
+
export declare class SharedStyleIndex {
|
|
4
|
+
private readonly nodes;
|
|
5
|
+
private readonly nodeIdsByStyleId;
|
|
6
|
+
private indexed;
|
|
7
|
+
constructor(nodes: () => NodeMap);
|
|
8
|
+
styleNode(styleId: string, type: SharedStyleType): SceneNode | undefined;
|
|
9
|
+
added(node: SceneNode): void;
|
|
10
|
+
removed(node: SceneNode): void;
|
|
11
|
+
willChange(node: SceneNode, changes: Partial<SceneNode>): boolean;
|
|
12
|
+
didChange(node: SceneNode, restyled: boolean): void;
|
|
13
|
+
invalidate(): void;
|
|
14
|
+
private current;
|
|
15
|
+
private add;
|
|
16
|
+
private remove;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=shared-style-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-style-index.d.ts","names":[],"sources":["../src/shared-style-index.ts"],"mappings":";KAEK,UAAU,oBAAoB;qBAiBtB;mBAIkB;mBAHZ;UACT;EAEqB,YAAA,aAAa;EAE1C,UAAU,iBAAiB,MAAM,kBAAkB;EAcnD,MAAM,MAAM;EAMZ,QAAQ,MAAM;EAMd,WAAW,MAAM,WAAW,SAAS,QAAQ;EAQ7C,UAAU,MAAM,WAAW;EAM3B;UAIQ;UAYA;UAaA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/shared-style-index.ts
|
|
2
|
+
const INDEX_KEYS = /* @__PURE__ */ new Set(["source", "sharedStyleType"]);
|
|
3
|
+
function restyles(changes) {
|
|
4
|
+
for (const key of INDEX_KEYS) if (key in changes) return true;
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
function styleKey(node) {
|
|
8
|
+
return node.sharedStyleType && node.source.id ? node.source.id : null;
|
|
9
|
+
}
|
|
10
|
+
var SharedStyleIndex = class {
|
|
11
|
+
nodes;
|
|
12
|
+
nodeIdsByStyleId = /* @__PURE__ */ new Map();
|
|
13
|
+
indexed = null;
|
|
14
|
+
constructor(nodes) {
|
|
15
|
+
this.nodes = nodes;
|
|
16
|
+
}
|
|
17
|
+
styleNode(styleId, type) {
|
|
18
|
+
if (!styleId) return;
|
|
19
|
+
const nodes = this.current();
|
|
20
|
+
for (const id of this.nodeIdsByStyleId.get(styleId) ?? []) {
|
|
21
|
+
const node = nodes.get(id);
|
|
22
|
+
if (node?.sharedStyleType === type && node.source.id === styleId) return node;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
added(node) {
|
|
26
|
+
if (this.indexed) this.add(node);
|
|
27
|
+
}
|
|
28
|
+
removed(node) {
|
|
29
|
+
if (this.indexed) this.remove(node);
|
|
30
|
+
}
|
|
31
|
+
willChange(node, changes) {
|
|
32
|
+
const restyled = restyles(changes);
|
|
33
|
+
if (restyled) this.removed(node);
|
|
34
|
+
return restyled;
|
|
35
|
+
}
|
|
36
|
+
didChange(node, restyled) {
|
|
37
|
+
if (restyled) this.added(node);
|
|
38
|
+
}
|
|
39
|
+
invalidate() {
|
|
40
|
+
this.indexed = null;
|
|
41
|
+
}
|
|
42
|
+
current() {
|
|
43
|
+
const nodes = this.nodes();
|
|
44
|
+
if (this.indexed !== nodes) {
|
|
45
|
+
this.nodeIdsByStyleId.clear();
|
|
46
|
+
for (const node of nodes.values()) this.add(node);
|
|
47
|
+
this.indexed = nodes;
|
|
48
|
+
}
|
|
49
|
+
return nodes;
|
|
50
|
+
}
|
|
51
|
+
add(node) {
|
|
52
|
+
const key = styleKey(node);
|
|
53
|
+
if (!key) return;
|
|
54
|
+
let ids = this.nodeIdsByStyleId.get(key);
|
|
55
|
+
if (!ids) {
|
|
56
|
+
ids = /* @__PURE__ */ new Set();
|
|
57
|
+
this.nodeIdsByStyleId.set(key, ids);
|
|
58
|
+
}
|
|
59
|
+
ids.add(node.id);
|
|
60
|
+
}
|
|
61
|
+
remove(node) {
|
|
62
|
+
const key = styleKey(node);
|
|
63
|
+
const ids = key ? this.nodeIdsByStyleId.get(key) : void 0;
|
|
64
|
+
if (!key || !ids) return;
|
|
65
|
+
ids.delete(node.id);
|
|
66
|
+
if (ids.size === 0) this.nodeIdsByStyleId.delete(key);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export { SharedStyleIndex };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=shared-style-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-style-index.js","names":[],"sources":["../src/shared-style-index.ts"],"sourcesContent":["import type { SceneNode, SharedStyleType } from './types'\n\ntype NodeMap = ReadonlyMap<string, SceneNode>\n\nconst INDEX_KEYS: ReadonlySet<string> = new Set(['source', 'sharedStyleType'])\n\nfunction restyles(changes: Partial<SceneNode>): boolean {\n for (const key of INDEX_KEYS) {\n if (key in changes) {\n return true\n }\n }\n return false\n}\n\nfunction styleKey(node: SceneNode): string | null {\n return node.sharedStyleType && node.source.id ? node.source.id : null\n}\n\nexport class SharedStyleIndex {\n private readonly nodeIdsByStyleId = new Map<string, Set<string>>()\n private indexed: NodeMap | null = null\n\n constructor(private readonly nodes: () => NodeMap) {}\n\n styleNode(styleId: string, type: SharedStyleType): SceneNode | undefined {\n if (!styleId) {\n return undefined\n }\n const nodes = this.current()\n for (const id of this.nodeIdsByStyleId.get(styleId) ?? []) {\n const node = nodes.get(id)\n if (node?.sharedStyleType === type && node.source.id === styleId) {\n return node\n }\n }\n return undefined\n }\n\n added(node: SceneNode): void {\n if (this.indexed) {\n this.add(node)\n }\n }\n\n removed(node: SceneNode): void {\n if (this.indexed) {\n this.remove(node)\n }\n }\n\n willChange(node: SceneNode, changes: Partial<SceneNode>): boolean {\n const restyled = restyles(changes)\n if (restyled) {\n this.removed(node)\n }\n return restyled\n }\n\n didChange(node: SceneNode, restyled: boolean): void {\n if (restyled) {\n this.added(node)\n }\n }\n\n invalidate(): void {\n this.indexed = null\n }\n\n private current(): NodeMap {\n const nodes = this.nodes()\n if (this.indexed !== nodes) {\n this.nodeIdsByStyleId.clear()\n for (const node of nodes.values()) {\n this.add(node)\n }\n this.indexed = nodes\n }\n return nodes\n }\n\n private add(node: SceneNode): void {\n const key = styleKey(node)\n if (!key) {\n return\n }\n let ids = this.nodeIdsByStyleId.get(key)\n if (!ids) {\n ids = new Set()\n this.nodeIdsByStyleId.set(key, ids)\n }\n ids.add(node.id)\n }\n\n private remove(node: SceneNode): void {\n const key = styleKey(node)\n const ids = key ? this.nodeIdsByStyleId.get(key) : undefined\n if (!key || !ids) {\n return\n }\n ids.delete(node.id)\n if (ids.size === 0) {\n this.nodeIdsByStyleId.delete(key)\n }\n }\n}\n"],"mappings":";AAIA,MAAM,6BAAkC,IAAI,IAAI,CAAC,UAAU,iBAAiB,CAAC;AAE7E,SAAS,SAAS,SAAsC;CACtD,KAAK,MAAM,OAAO,YAChB,IAAI,OAAO,SACT,OAAO;CAGX,OAAO;AACT;AAEA,SAAS,SAAS,MAAgC;CAChD,OAAO,KAAK,mBAAmB,KAAK,OAAO,KAAK,KAAK,OAAO,KAAK;AACnE;AAEA,IAAa,mBAAb,MAA8B;CAIC;CAHZ,mCAAmB,IAAI,IAAyB;CACzD,UAA0B;CAElC,YAA6B,OAAsB;EAAtB,KAAA,QAAA;CAAuB;CAEpD,UAAU,SAAiB,MAA8C;EACvE,IAAI,CAAC,SACH;EAEF,MAAM,QAAQ,KAAK,QAAQ;EAC3B,KAAK,MAAM,MAAM,KAAK,iBAAiB,IAAI,OAAO,KAAK,CAAC,GAAG;GACzD,MAAM,OAAO,MAAM,IAAI,EAAE;GACzB,IAAI,MAAM,oBAAoB,QAAQ,KAAK,OAAO,OAAO,SACvD,OAAO;EAEX;CAEF;CAEA,MAAM,MAAuB;EAC3B,IAAI,KAAK,SACP,KAAK,IAAI,IAAI;CAEjB;CAEA,QAAQ,MAAuB;EAC7B,IAAI,KAAK,SACP,KAAK,OAAO,IAAI;CAEpB;CAEA,WAAW,MAAiB,SAAsC;EAChE,MAAM,WAAW,SAAS,OAAO;EACjC,IAAI,UACF,KAAK,QAAQ,IAAI;EAEnB,OAAO;CACT;CAEA,UAAU,MAAiB,UAAyB;EAClD,IAAI,UACF,KAAK,MAAM,IAAI;CAEnB;CAEA,aAAmB;EACjB,KAAK,UAAU;CACjB;CAEQ,UAAmB;EACzB,MAAM,QAAQ,KAAK,MAAM;EACzB,IAAI,KAAK,YAAY,OAAO;GAC1B,KAAK,iBAAiB,MAAM;GAC5B,KAAK,MAAM,QAAQ,MAAM,OAAO,GAC9B,KAAK,IAAI,IAAI;GAEf,KAAK,UAAU;EACjB;EACA,OAAO;CACT;CAEQ,IAAI,MAAuB;EACjC,MAAM,MAAM,SAAS,IAAI;EACzB,IAAI,CAAC,KACH;EAEF,IAAI,MAAM,KAAK,iBAAiB,IAAI,GAAG;EACvC,IAAI,CAAC,KAAK;GACR,sBAAM,IAAI,IAAI;GACd,KAAK,iBAAiB,IAAI,KAAK,GAAG;EACpC;EACA,IAAI,IAAI,KAAK,EAAE;CACjB;CAEQ,OAAO,MAAuB;EACpC,MAAM,MAAM,SAAS,IAAI;EACzB,MAAM,MAAM,MAAM,KAAK,iBAAiB,IAAI,GAAG,IAAI,KAAA;EACnD,IAAI,CAAC,OAAO,CAAC,KACX;EAEF,IAAI,OAAO,KAAK,EAAE;EAClB,IAAI,IAAI,SAAS,GACf,KAAK,iBAAiB,OAAO,GAAG;CAEpC;AACF"}
|
package/dist/shared-styles.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SceneGraph } from "./graph.js";
|
|
2
2
|
import { CharacterStyleOverride, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType } from "./types.js";
|
|
3
|
-
//#region src/shared-styles.d.ts
|
|
4
3
|
declare const STYLE_REF_KEYS: {
|
|
5
4
|
readonly fill: "fillStyleId";
|
|
6
5
|
readonly stroke: "strokeStyleId";
|
|
@@ -9,13 +8,13 @@ declare const STYLE_REF_KEYS: {
|
|
|
9
8
|
readonly grid: "gridStyleId";
|
|
10
9
|
};
|
|
11
10
|
/** The fields that link a layer to its shared styles. */
|
|
12
|
-
declare const STYLE_LINK_FIELDS: ("fillStyleId" | "strokeStyleId" | "textStyleId" | "effectStyleId" | "gridStyleId")[];
|
|
11
|
+
export declare const STYLE_LINK_FIELDS: ("fillStyleId" | "strokeStyleId" | "textStyleId" | "effectStyleId" | "gridStyleId")[];
|
|
13
12
|
/** The shared styles a layer uses: its own, its text ranges', and its vector regions'. */
|
|
14
|
-
declare function referencedStyleIds(node: SceneNode): string[];
|
|
13
|
+
export declare function referencedStyleIds(node: SceneNode): string[];
|
|
15
14
|
/** The fields a text style gives what uses it; changing one leaves the style. */
|
|
16
|
-
declare const SHARED_TEXT_STYLE_FIELDS: readonly ["fontFamily", "fontWeight", "italic", "fontStyle", "fontSize", "lineHeight", "letterSpacing", "textDecoration", "textCase", "fontFeatures"];
|
|
15
|
+
export declare const SHARED_TEXT_STYLE_FIELDS: readonly ["fontFamily", "fontWeight", "italic", "fontStyle", "fontSize", "lineHeight", "letterSpacing", "textDecoration", "textCase", "fontFeatures"];
|
|
17
16
|
/** The fields each kind of shared style gives what uses it; changing one leaves the style. */
|
|
18
|
-
declare const SHARED_STYLE_FIELDS: {
|
|
17
|
+
export declare const SHARED_STYLE_FIELDS: {
|
|
19
18
|
readonly fill: readonly ["fills"];
|
|
20
19
|
readonly stroke: readonly ["strokes"];
|
|
21
20
|
readonly text: readonly ["fontFamily", "fontWeight", "italic", "fontStyle", "fontSize", "lineHeight", "letterSpacing", "textDecoration", "textCase", "fontFeatures", "paragraphSpacing", "paragraphIndent", "listSpacing"];
|
|
@@ -23,31 +22,30 @@ declare const SHARED_STYLE_FIELDS: {
|
|
|
23
22
|
readonly grid: readonly ["layoutGrids"];
|
|
24
23
|
};
|
|
25
24
|
/** The fields that pick a text's face, which its style name names. */
|
|
26
|
-
declare const FACE_KEYS: readonly ["fontFamily", "fontWeight", "italic"];
|
|
25
|
+
export declare const FACE_KEYS: readonly ["fontFamily", "fontWeight", "italic"];
|
|
27
26
|
/**
|
|
28
27
|
* The face name of characters with `style` over the text: their own, none where they set another
|
|
29
28
|
* face without one (as ranges from HTML or `.pen` do), else the text's.
|
|
30
29
|
*/
|
|
31
|
-
declare function rangeFontStyle(node: Pick<SceneNode, 'fontStyle'>, style: CharacterStyleOverride): string | null;
|
|
32
|
-
declare function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind];
|
|
33
|
-
declare function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType;
|
|
30
|
+
export declare function rangeFontStyle(node: Pick<SceneNode, 'fontStyle'>, style: CharacterStyleOverride): string | null;
|
|
31
|
+
export declare function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind];
|
|
32
|
+
export declare function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType;
|
|
34
33
|
/** The document's shared style layers, by the source ID layers link them by. */
|
|
35
|
-
declare function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode>;
|
|
36
|
-
declare function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[];
|
|
37
|
-
declare function styleDetachmentChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
38
|
-
/** The node of the shared style with `id`, when the document holds one of `type`. */
|
|
39
|
-
declare function findSharedStyle(graph: SceneGraph, id: string, type: SharedStyleType): SceneNode | undefined;
|
|
34
|
+
export declare function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode>;
|
|
35
|
+
export declare function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[];
|
|
36
|
+
export declare function styleDetachmentChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
40
37
|
/** A new local style's ID, in the shape Figma gives one: `S:` and a 40-digit hex key. */
|
|
41
|
-
declare function newSharedStyleId(): string;
|
|
38
|
+
export declare function newSharedStyleId(): string;
|
|
42
39
|
/** The page that holds the document's styles out of view, as a `.fig` file keeps them; made once. */
|
|
43
|
-
declare function internalCanvas(graph: SceneGraph): SceneNode;
|
|
40
|
+
export declare function internalCanvas(graph: SceneGraph): SceneNode;
|
|
44
41
|
/**
|
|
45
42
|
* What a layer takes from a shared style it starts using: the style's fields and the reference
|
|
46
43
|
* that keeps it attached. Without the style's node, the reference alone.
|
|
47
44
|
*/
|
|
48
|
-
declare function sharedStylePatch(kind: SharedStyleKind, target: SceneNode, styleId: string, style: SceneNode | null): Partial<SceneNode>;
|
|
45
|
+
export declare function sharedStylePatch(kind: SharedStyleKind, target: SceneNode, styleId: string, style: SceneNode | null): Partial<SceneNode>;
|
|
46
|
+
/** Whether a text style sets `field`, so a text or range starting to use it lets its binding go. */
|
|
47
|
+
export declare function isTextStyleField(field: string): boolean;
|
|
49
48
|
/** A layer leaving a shared style: it keeps the style's values, without the reference. */
|
|
50
|
-
declare function sharedStyleDetachPatch(kind: SharedStyleKind): Partial<SceneNode>;
|
|
51
|
-
|
|
52
|
-
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, findSharedStyle, getSharedStyles, internalCanvas, newSharedStyleId, rangeFontStyle, referencedStyleIds, sharedStyleDetachPatch, sharedStyleLayers, sharedStylePatch, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
49
|
+
export declare function sharedStyleDetachPatch(kind: SharedStyleKind): Partial<SceneNode>;
|
|
50
|
+
export {};
|
|
53
51
|
//# sourceMappingURL=shared-styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-styles.d.ts","names":[],"sources":["../src/shared-styles.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared-styles.d.ts","names":[],"sources":["../src/shared-styles.ts"],"mappings":";;cAoBM;;;;;;;;qBASO;;wBAGG,mBAAmB,MAAM;;qBAiB5B;;qBAwBA;;;;;;;;qBASA;;;;;wBAUG,eACd,MAAM,KAAK,yBACX,OAAO;wBAMO,kBAAkB,MAAM,0BAA0B,gBAAgB;wBAIlE,uBAAuB,MAAM,kBAAkB;;wBAK/C,kBAAkB,OAAO,aAAa,YAAY;wBAOlD,gBAAgB,OAAO,YAAY,MAAM,kBAAkB;wBAuB3D,uBACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ;;wBAmBK;;wBAOA,eAAe,OAAO,aAAa;;;;;wBAmCnC,iBACd,MAAM,iBACN,QAAQ,WACR,iBACA,OAAO,mBACN,QAAQ;;wBA0BK,iBAAiB;;wBAKjB,uBAAuB,MAAM,kBAAkB,QAAQ"}
|
package/dist/shared-styles.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { compact, isEqual, omit, pick } from "es-toolkit";
|
|
2
|
+
import { randomHex } from "@open-pencil/std/random";
|
|
1
3
|
import { BLACK } from "./constants.js";
|
|
2
|
-
import { newStrokeGeometry } from "./node-defaults.js";
|
|
3
4
|
import { copyEffects, copyFills, copyLayoutGrids } from "./copy.js";
|
|
5
|
+
import { newStrokeGeometry } from "./node-defaults.js";
|
|
6
|
+
import { scaledTextStyleLengths } from "./scaling/node.js";
|
|
4
7
|
import { STROKE_LINE_KEYS } from "./strokes.js";
|
|
5
8
|
import { styleRunReferences } from "./text/references.js";
|
|
6
|
-
|
|
7
|
-
import { randomHex } from "@open-pencil/std/random";
|
|
8
|
-
//#region src/shared-styles.ts
|
|
9
|
+
// src/shared-styles.ts
|
|
9
10
|
const STYLE_REF_KEYS = {
|
|
10
11
|
fill: "fillStyleId",
|
|
11
12
|
stroke: "strokeStyleId",
|
|
@@ -122,11 +123,6 @@ function styleDetachmentChanges(node, changes) {
|
|
|
122
123
|
if (FACE_KEYS.some((key) => key in changes && changes[key] !== node[key]) && !("fontStyle" in changes) && node.fontStyle) next.fontStyle = null;
|
|
123
124
|
return next;
|
|
124
125
|
}
|
|
125
|
-
/** The node of the shared style with `id`, when the document holds one of `type`. */
|
|
126
|
-
function findSharedStyle(graph, id, type) {
|
|
127
|
-
if (!id) return void 0;
|
|
128
|
-
for (const node of graph.getAllNodes()) if (node.sharedStyleType === type && node.source.id === id) return node;
|
|
129
|
-
}
|
|
130
126
|
/** A new local style's ID, in the shape Figma gives one: `S:` and a 40-digit hex key. */
|
|
131
127
|
function newSharedStyleId() {
|
|
132
128
|
return `S:${randomHex(20)},`;
|
|
@@ -172,14 +168,26 @@ function sharedStylePatch(kind, target, styleId, style) {
|
|
|
172
168
|
else if (kind === "stroke") patch.strokes = strokesFromStyle(target, style);
|
|
173
169
|
else if (kind === "effect") patch.effects = copyEffects(style.effects);
|
|
174
170
|
else if (kind === "grid") patch.layoutGrids = copyLayoutGrids(style.layoutGrids);
|
|
175
|
-
else
|
|
171
|
+
else {
|
|
172
|
+
const fields = structuredClone(pick(style, SHARED_STYLE_FIELDS.text));
|
|
173
|
+
Object.assign(patch, scaledTextStyleLengths(fields, target.componentScale));
|
|
174
|
+
const dropped = target.textStyleId === styleId ? [] : Object.keys(target.boundVariables).filter(isTextStyleField);
|
|
175
|
+
if (dropped.length > 0) {
|
|
176
|
+
patch.boundVariables = omit(target.boundVariables, dropped);
|
|
177
|
+
patch.variableBindingScales = omit(target.variableBindingScales, dropped);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
176
180
|
return patch;
|
|
177
181
|
}
|
|
182
|
+
const TEXT_STYLE_FIELD_SET = new Set(SHARED_STYLE_FIELDS.text);
|
|
183
|
+
/** Whether a text style sets `field`, so a text or range starting to use it lets its binding go. */
|
|
184
|
+
function isTextStyleField(field) {
|
|
185
|
+
return TEXT_STYLE_FIELD_SET.has(field);
|
|
186
|
+
}
|
|
178
187
|
/** A layer leaving a shared style: it keeps the style's values, without the reference. */
|
|
179
188
|
function sharedStyleDetachPatch(kind) {
|
|
180
189
|
return { [STYLE_REF_KEYS[kind]]: null };
|
|
181
190
|
}
|
|
182
|
-
|
|
183
|
-
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, findSharedStyle, getSharedStyles, internalCanvas, newSharedStyleId, rangeFontStyle, referencedStyleIds, sharedStyleDetachPatch, sharedStyleLayers, sharedStylePatch, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
191
|
+
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, getSharedStyles, internalCanvas, isTextStyleField, newSharedStyleId, rangeFontStyle, referencedStyleIds, sharedStyleDetachPatch, sharedStyleLayers, sharedStylePatch, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
184
192
|
|
|
185
193
|
//# sourceMappingURL=shared-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-styles.js","names":[],"sources":["../src/shared-styles.ts"],"sourcesContent":["import { compact, isEqual, omit, pick } from 'es-toolkit'\n\nimport { randomHex } from '@open-pencil/std/random'\n\nimport { BLACK } from './constants'\nimport { copyEffects, copyFills, copyLayoutGrids } from './copy'\nimport type { SceneGraph } from './graph'\nimport { newStrokeGeometry } from './node-defaults'\nimport { STROKE_LINE_KEYS } from './strokes'\nimport { styleRunReferences } from './text/references'\nimport type {\n CharacterStyleOverride,\n SceneNode,\n SharedStyle,\n SharedStyleKind,\n SharedStyleType,\n Stroke\n} from './types'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\n/** The fields that link a layer to its shared styles. */\nexport const STYLE_LINK_FIELDS = Object.values(STYLE_REF_KEYS)\n\n/** The shared styles a layer uses: its own, its text ranges', and its vector regions'. */\nexport function referencedStyleIds(node: SceneNode): string[] {\n return compact([\n ...STYLE_LINK_FIELDS.map((field) => node[field]),\n ...styleRunReferences(node.styleRuns).styles,\n ...(node.vectorNetwork?.regions ?? []).map((region) => region.fillStyleId)\n ])\n}\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\n/** The fields a text style gives what uses it; changing one leaves the style. */\nexport const SHARED_TEXT_STYLE_FIELDS = [\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The paragraph fields a text style also gives the whole text; a range takes only the character\n * ones. Changing one leaves the style, and a cleared style resets them (live-verified).\n */\nconst TEXT_STYLE_PARAGRAPH_FIELDS = [\n 'paragraphSpacing',\n 'paragraphIndent',\n 'listSpacing'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** The fields each kind of shared style gives what uses it; changing one leaves the style. */\nexport const SHARED_STYLE_FIELDS = {\n fill: ['fills'],\n stroke: ['strokes'],\n text: [...SHARED_TEXT_STYLE_FIELDS, ...TEXT_STYLE_PARAGRAPH_FIELDS],\n effect: ['effects'],\n grid: ['layoutGrids']\n} as const satisfies Record<SharedStyleKind, readonly (keyof SceneNode)[]>\n\n/** The fields that pick a text's face, which its style name names. */\nexport const FACE_KEYS = [\n 'fontFamily',\n 'fontWeight',\n 'italic'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The face name of characters with `style` over the text: their own, none where they set another\n * face without one (as ranges from HTML or `.pen` do), else the text's.\n */\nexport function rangeFontStyle(\n node: Pick<SceneNode, 'fontStyle'>,\n style: CharacterStyleOverride\n): string | null {\n if (style.fontStyle !== undefined) return style.fontStyle\n return FACE_KEYS.some((key) => style[key] !== undefined) ? null : node.fontStyle\n}\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\n/** The document's shared style layers, by the source ID layers link them by. */\nexport function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode> {\n const styles = new Map<string, SceneNode>()\n for (const node of graph.getAllNodes())\n if (node.sharedStyleType !== null && node.source.id) styles.set(node.source.id, node)\n return styles\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\n/**\n * Whether new strokes only change how their lines run, keeping every paint. A stroke style gives\n * paints only, so such a write keeps it; any other strokes write leaves it, as setting even the\n * same paints does in Figma (live-verified).\n */\nfunction restylesStrokeLines(current: readonly Stroke[], next: readonly Stroke[]): boolean {\n const paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, STROKE_LINE_KEYS))\n const lines = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => STROKE_LINE_KEYS.map((key) => stroke[key]))\n return isEqual(paints(current), paints(next)) && !isEqual(lines(current), lines(next))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n for (const [kind, fields] of Object.entries(SHARED_STYLE_FIELDS)) {\n const reference = STYLE_REF_KEYS[kind as SharedStyleKind]\n if (reference in changes || !node[reference]) continue\n if (!fields.some((field) => field in changes)) continue\n if (kind === 'stroke' && changes.strokes && restylesStrokeLines(node.strokes, changes.strokes))\n continue\n next[reference] = null\n }\n // A face named for another family, weight, or slant names none; the new one takes its own name.\n const changesFace = FACE_KEYS.some((key) => key in changes && changes[key] !== node[key])\n if (changesFace && !('fontStyle' in changes) && node.fontStyle) {\n next.fontStyle = null\n }\n return next\n}\n\n/** The node of the shared style with `id`, when the document holds one of `type`. */\nexport function findSharedStyle(\n graph: SceneGraph,\n id: string,\n type: SharedStyleType\n): SceneNode | undefined {\n if (!id) return undefined\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType === type && node.source.id === id) return node\n }\n return undefined\n}\n\n/** A new local style's ID, in the shape Figma gives one: `S:` and a 40-digit hex key. */\nexport function newSharedStyleId(): string {\n return `S:${randomHex(20)},`\n}\n\nconst INTERNAL_CANVAS_NAME = 'Internal Only Canvas'\n\n/** The page that holds the document's styles out of view, as a `.fig` file keeps them; made once. */\nexport function internalCanvas(graph: SceneGraph): SceneNode {\n const existing = graph.getPages(true).find((page) => page.internalOnly)\n if (existing) return existing\n return graph.createNode('CANVAS', graph.rootId, {\n name: INTERNAL_CANVAS_NAME,\n width: 0,\n height: 0,\n internalOnly: true\n })\n}\n\n/**\n * A paint style's paints as a layer's strokes: every paint, each keeping the weight, alignment,\n * and line style of the stroke it replaces, or of the layer's first; no paints clear the strokes\n * (Figma desktop 126).\n */\nfunction strokesFromStyle(target: SceneNode, style: SceneNode): SceneNode['strokes'] {\n // Without strokes, the layer keeps the weight and alignment a new stroke takes.\n const fallback: Stroke = target.strokes[0] ?? {\n type: 'SOLID',\n color: BLACK,\n opacity: 1,\n visible: true,\n ...newStrokeGeometry(target)\n }\n return copyFills(style.fills).map((paint, index) => ({\n ...paint,\n ...pick(target.strokes[index] ?? fallback, STROKE_LINE_KEYS)\n }))\n}\n\n/**\n * What a layer takes from a shared style it starts using: the style's fields and the reference\n * that keeps it attached. Without the style's node, the reference alone.\n */\nexport function sharedStylePatch(\n kind: SharedStyleKind,\n target: SceneNode,\n styleId: string,\n style: SceneNode | null\n): Partial<SceneNode> {\n const patch: Partial<SceneNode> = { [STYLE_REF_KEYS[kind]]: styleId }\n if (!style) return patch\n if (kind === 'fill') patch.fills = copyFills(style.fills)\n else if (kind === 'stroke') patch.strokes = strokesFromStyle(target, style)\n else if (kind === 'effect') patch.effects = copyEffects(style.effects)\n else if (kind === 'grid') patch.layoutGrids = copyLayoutGrids(style.layoutGrids)\n else Object.assign(patch, structuredClone(pick(style, SHARED_STYLE_FIELDS.text)))\n return patch\n}\n\n/** A layer leaving a shared style: it keeps the style's values, without the reference. */\nexport function sharedStyleDetachPatch(kind: SharedStyleKind): Partial<SceneNode> {\n return { [STYLE_REF_KEYS[kind]]: null }\n}\n"],"mappings":";;;;;;;;AAmBA,MAAM,iBAAiB;CACrB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,oBAAoB,OAAO,OAAO,cAAc;;AAG7D,SAAgB,mBAAmB,MAA2B;CAC5D,OAAO,QAAQ;EACb,GAAG,kBAAkB,KAAK,UAAU,KAAK,MAAM;EAC/C,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;EACtC,IAAI,KAAK,eAAe,WAAW,CAAC,EAAA,CAAG,KAAK,WAAW,OAAO,WAAW;CAC3E,CAAC;AACH;AAEA,MAAM,cAAc;CAClB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,8BAA8B;CAClC;CACA;CACA;AACF;;AAGA,MAAa,sBAAsB;CACjC,MAAM,CAAC,OAAO;CACd,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,GAAG,0BAA0B,GAAG,2BAA2B;CAClE,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,aAAa;AACtB;;AAGA,MAAa,YAAY;CACvB;CACA;CACA;AACF;;;;;AAMA,SAAgB,eACd,MACA,OACe;CACf,IAAI,MAAM,cAAc,KAAA,GAAW,OAAO,MAAM;CAChD,OAAO,UAAU,MAAM,QAAQ,MAAM,SAAS,KAAA,CAAS,IAAI,OAAO,KAAK;AACzE;AAEA,SAAgB,kBAA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AAS,UAAU,MAAM,UAAU,iBAAiB,QAAQ,KAAK;MACrE,IAAI,SAAS,UAAU,MAAM,UAAU,YAAY,MAAM,OAAO;MAChE,IAAI,SAAS,QAAQ,MAAM,cAAc,gBAAgB,MAAM,WAAW;MAC1E,OAAO,OAAO,OAAO,gBAAgB,KAAK,OAAO,oBAAoB,IAAI,CAAC,CAAC;CAChF,OAAO;AACT;;AAGA,SAAgB,uBAAuB,MAA2C;CAChF,OAAO,GAAG,eAAe,QAAQ,KAAK;AACxC"}
|
|
1
|
+
{"version":3,"file":"shared-styles.js","names":[],"sources":["../src/shared-styles.ts"],"sourcesContent":["import { compact, isEqual, omit, pick } from 'es-toolkit'\n\nimport { randomHex } from '@open-pencil/std/random'\n\nimport { BLACK } from './constants'\nimport { copyEffects, copyFills, copyLayoutGrids } from './copy'\nimport type { SceneGraph } from './graph'\nimport { newStrokeGeometry } from './node-defaults'\nimport { scaledTextStyleLengths } from './scaling/node'\nimport { STROKE_LINE_KEYS } from './strokes'\nimport { styleRunReferences } from './text/references'\nimport type {\n CharacterStyleOverride,\n SceneNode,\n SharedStyle,\n SharedStyleKind,\n SharedStyleType,\n Stroke\n} from './types'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\n/** The fields that link a layer to its shared styles. */\nexport const STYLE_LINK_FIELDS = Object.values(STYLE_REF_KEYS)\n\n/** The shared styles a layer uses: its own, its text ranges', and its vector regions'. */\nexport function referencedStyleIds(node: SceneNode): string[] {\n return compact([\n ...STYLE_LINK_FIELDS.map((field) => node[field]),\n ...styleRunReferences(node.styleRuns).styles,\n ...(node.vectorNetwork?.regions ?? []).map((region) => region.fillStyleId)\n ])\n}\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\n/** The fields a text style gives what uses it; changing one leaves the style. */\nexport const SHARED_TEXT_STYLE_FIELDS = [\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The paragraph fields a text style also gives the whole text; a range takes only the character\n * ones. Changing one leaves the style, and a cleared style resets them (live-verified).\n */\nconst TEXT_STYLE_PARAGRAPH_FIELDS = [\n 'paragraphSpacing',\n 'paragraphIndent',\n 'listSpacing'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** The fields each kind of shared style gives what uses it; changing one leaves the style. */\nexport const SHARED_STYLE_FIELDS = {\n fill: ['fills'],\n stroke: ['strokes'],\n text: [...SHARED_TEXT_STYLE_FIELDS, ...TEXT_STYLE_PARAGRAPH_FIELDS],\n effect: ['effects'],\n grid: ['layoutGrids']\n} as const satisfies Record<SharedStyleKind, readonly (keyof SceneNode)[]>\n\n/** The fields that pick a text's face, which its style name names. */\nexport const FACE_KEYS = [\n 'fontFamily',\n 'fontWeight',\n 'italic'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The face name of characters with `style` over the text: their own, none where they set another\n * face without one (as ranges from HTML or `.pen` do), else the text's.\n */\nexport function rangeFontStyle(\n node: Pick<SceneNode, 'fontStyle'>,\n style: CharacterStyleOverride\n): string | null {\n if (style.fontStyle !== undefined) return style.fontStyle\n return FACE_KEYS.some((key) => style[key] !== undefined) ? null : node.fontStyle\n}\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\n/** The document's shared style layers, by the source ID layers link them by. */\nexport function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode> {\n const styles = new Map<string, SceneNode>()\n for (const node of graph.getAllNodes())\n if (node.sharedStyleType !== null && node.source.id) styles.set(node.source.id, node)\n return styles\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\n/**\n * Whether new strokes only change how their lines run, keeping every paint. A stroke style gives\n * paints only, so such a write keeps it; any other strokes write leaves it, as setting even the\n * same paints does in Figma (live-verified).\n */\nfunction restylesStrokeLines(current: readonly Stroke[], next: readonly Stroke[]): boolean {\n const paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, STROKE_LINE_KEYS))\n const lines = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => STROKE_LINE_KEYS.map((key) => stroke[key]))\n return isEqual(paints(current), paints(next)) && !isEqual(lines(current), lines(next))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n for (const [kind, fields] of Object.entries(SHARED_STYLE_FIELDS)) {\n const reference = STYLE_REF_KEYS[kind as SharedStyleKind]\n if (reference in changes || !node[reference]) continue\n if (!fields.some((field) => field in changes)) continue\n if (kind === 'stroke' && changes.strokes && restylesStrokeLines(node.strokes, changes.strokes))\n continue\n next[reference] = null\n }\n // A face named for another family, weight, or slant names none; the new one takes its own name.\n const changesFace = FACE_KEYS.some((key) => key in changes && changes[key] !== node[key])\n if (changesFace && !('fontStyle' in changes) && node.fontStyle) {\n next.fontStyle = null\n }\n return next\n}\n\n/** A new local style's ID, in the shape Figma gives one: `S:` and a 40-digit hex key. */\nexport function newSharedStyleId(): string {\n return `S:${randomHex(20)},`\n}\n\nconst INTERNAL_CANVAS_NAME = 'Internal Only Canvas'\n\n/** The page that holds the document's styles out of view, as a `.fig` file keeps them; made once. */\nexport function internalCanvas(graph: SceneGraph): SceneNode {\n const existing = graph.getPages(true).find((page) => page.internalOnly)\n if (existing) return existing\n return graph.createNode('CANVAS', graph.rootId, {\n name: INTERNAL_CANVAS_NAME,\n width: 0,\n height: 0,\n internalOnly: true\n })\n}\n\n/**\n * A paint style's paints as a layer's strokes: every paint, each keeping the weight, alignment,\n * and line style of the stroke it replaces, or of the layer's first; no paints clear the strokes\n * (Figma desktop 126).\n */\nfunction strokesFromStyle(target: SceneNode, style: SceneNode): SceneNode['strokes'] {\n // Without strokes, the layer keeps the weight and alignment a new stroke takes.\n const fallback: Stroke = target.strokes[0] ?? {\n type: 'SOLID',\n color: BLACK,\n opacity: 1,\n visible: true,\n ...newStrokeGeometry(target)\n }\n return copyFills(style.fills).map((paint, index) => ({\n ...paint,\n ...pick(target.strokes[index] ?? fallback, STROKE_LINE_KEYS)\n }))\n}\n\n/**\n * What a layer takes from a shared style it starts using: the style's fields and the reference\n * that keeps it attached. Without the style's node, the reference alone.\n */\nexport function sharedStylePatch(\n kind: SharedStyleKind,\n target: SceneNode,\n styleId: string,\n style: SceneNode | null\n): Partial<SceneNode> {\n const patch: Partial<SceneNode> = { [STYLE_REF_KEYS[kind]]: styleId }\n if (!style) return patch\n if (kind === 'fill') patch.fills = copyFills(style.fills)\n else if (kind === 'stroke') patch.strokes = strokesFromStyle(target, style)\n else if (kind === 'effect') patch.effects = copyEffects(style.effects)\n else if (kind === 'grid') patch.layoutGrids = copyLayoutGrids(style.layoutGrids)\n else {\n const fields = structuredClone(pick(style, SHARED_STYLE_FIELDS.text))\n Object.assign(patch, scaledTextStyleLengths(fields, target.componentScale))\n // A text starting to use a text style lets go of its own bindings of the style's fields.\n const dropped =\n target.textStyleId === styleId\n ? []\n : Object.keys(target.boundVariables).filter(isTextStyleField)\n if (dropped.length > 0) {\n patch.boundVariables = omit(target.boundVariables, dropped)\n patch.variableBindingScales = omit(target.variableBindingScales, dropped)\n }\n }\n return patch\n}\n\nconst TEXT_STYLE_FIELD_SET: ReadonlySet<string> = new Set(SHARED_STYLE_FIELDS.text)\n\n/** Whether a text style sets `field`, so a text or range starting to use it lets its binding go. */\nexport function isTextStyleField(field: string): boolean {\n return TEXT_STYLE_FIELD_SET.has(field)\n}\n\n/** A layer leaving a shared style: it keeps the style's values, without the reference. */\nexport function sharedStyleDetachPatch(kind: SharedStyleKind): Partial<SceneNode> {\n return { [STYLE_REF_KEYS[kind]]: null }\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAM,iBAAiB;CACrB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,oBAAoB,OAAO,OAAO,cAAc;;AAG7D,SAAgB,mBAAmB,MAA2B;CAC5D,OAAO,QAAQ;EACb,GAAG,kBAAkB,KAAK,UAAU,KAAK,MAAM;EAC/C,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;EACtC,IAAI,KAAK,eAAe,WAAW,CAAC,EAAA,CAAG,KAAK,WAAW,OAAO,WAAW;CAC3E,CAAC;AACH;AAEA,MAAM,cAAc;CAClB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,8BAA8B;CAClC;CACA;CACA;AACF;;AAGA,MAAa,sBAAsB;CACjC,MAAM,CAAC,OAAO;CACd,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,GAAG,0BAA0B,GAAG,2BAA2B;CAClE,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,aAAa;AACtB;;AAGA,MAAa,YAAY;CACvB;CACA;CACA;AACF;;;;;AAMA,SAAgB,eACd,MACA,OACe;CACf,IAAI,MAAM,cAAc,KAAA,GAAW,OAAO,MAAM;CAChD,OAAO,UAAU,MAA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IAAI,SAAS,QAAQ,MAAM,cAAc,gBAAgB,MAAM,WAAW;MAC1E;EACH,MAAM,SAAS,gBAAgB,KAAK,OAAO,oBAAoB,IAAI,CAAC;EACpE,OAAO,OAAO,OAAO,uBAAuB,QAAQ,OAAO,cAAc,CAAC;EAE1E,MAAM,UACJ,OAAO,gBAAgB,UACnB,CAAC,IACD,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,OAAO,gBAAgB;EAChE,IAAI,QAAQ,SAAS,GAAG;GACtB,MAAM,iBAAiB,KAAK,OAAO,gBAAgB,OAAO;GAC1D,MAAM,wBAAwB,KAAK,OAAO,uBAAuB,OAAO;EAC1E;CACF;CACA,OAAO;AACT;AAEA,MAAM,uBAA4C,IAAI,IAAI,oBAAoB,IAAI;;AAGlF,SAAgB,iBAAiB,OAAwB;CACvD,OAAO,qBAAqB,IAAI,KAAK;AACvC;;AAGA,SAAgB,uBAAuB,MAA2C;CAChF,OAAO,GAAG,eAAe,QAAQ,KAAK;AACxC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { Vector } from "../primitives/index.js";
|
|
3
|
+
/** Where moved slides go: beside a slide, or as a new section before another one or at the end. */
|
|
4
|
+
export type SlidePlacement = {
|
|
5
|
+
type: 'beside';
|
|
6
|
+
slideId: string;
|
|
7
|
+
side: 'before' | 'after';
|
|
8
|
+
} | {
|
|
9
|
+
type: 'section';
|
|
10
|
+
before: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** The line that shows where a drop lands, in canvas units. */
|
|
13
|
+
export interface SlideDropLine {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
length: number;
|
|
17
|
+
direction: 'HORIZONTAL' | 'VERTICAL';
|
|
18
|
+
}
|
|
19
|
+
export interface SlideDrop {
|
|
20
|
+
placement: SlidePlacement;
|
|
21
|
+
line: SlideDropLine;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Where slides dragged to a point on the page's deck land, as in Figma's grid: in a section's band,
|
|
25
|
+
* beside its nearest slide; between sections, above the first, or below the last, as a new section
|
|
26
|
+
* there. Null on a page without a deck.
|
|
27
|
+
*/
|
|
28
|
+
export declare function slideDropAt(graph: SceneGraph, pageId: string, point: Vector): SlideDrop | null;
|
|
29
|
+
//# sourceMappingURL=drop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop.d.ts","names":[],"sources":["../../src/slides/drop.ts"],"mappings":";;;YAKY;EACN;EAAgB;EAAiB;;EACjC;EAAiB;;;iBAGN;EACf;EACA;EACA;EACA;;iBAGe;EACf,WAAW;EACX,MAAM;;;;;;;wBA8CQ,YAAY,OAAO,YAAY,gBAAgB,OAAO,SAAS"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/slides/drop.ts
|
|
2
|
+
function boxOf(graph, node) {
|
|
3
|
+
const { x, y } = graph.getAbsolutePosition(node.id);
|
|
4
|
+
return {
|
|
5
|
+
x,
|
|
6
|
+
y,
|
|
7
|
+
width: node.width,
|
|
8
|
+
height: node.height
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function distanceTo(box, point) {
|
|
12
|
+
const dx = Math.max(box.x - point.x, 0, point.x - box.x - box.width);
|
|
13
|
+
const dy = Math.max(box.y - point.y, 0, point.y - box.y - box.height);
|
|
14
|
+
return Math.hypot(dx, dy);
|
|
15
|
+
}
|
|
16
|
+
/** Beside the slide of `row` nearest the point, on the side of its middle the point is on. */
|
|
17
|
+
function besideNearest(graph, row, point) {
|
|
18
|
+
const slides = graph.getChildren(row.id).filter((node) => node.type === "SLIDE").map((slide) => ({
|
|
19
|
+
slide,
|
|
20
|
+
box: boxOf(graph, slide)
|
|
21
|
+
}));
|
|
22
|
+
let nearest = slides.at(0);
|
|
23
|
+
for (const candidate of slides) if (nearest && distanceTo(candidate.box, point) < distanceTo(nearest.box, point)) nearest = candidate;
|
|
24
|
+
if (!nearest) return null;
|
|
25
|
+
const { slide, box } = nearest;
|
|
26
|
+
const side = point.x < box.x + box.width / 2 ? "before" : "after";
|
|
27
|
+
const half = row.itemSpacing / 2;
|
|
28
|
+
return {
|
|
29
|
+
placement: {
|
|
30
|
+
type: "beside",
|
|
31
|
+
slideId: slide.id,
|
|
32
|
+
side
|
|
33
|
+
},
|
|
34
|
+
line: {
|
|
35
|
+
x: side === "before" ? box.x - half : box.x + box.width + half,
|
|
36
|
+
y: box.y,
|
|
37
|
+
length: box.height,
|
|
38
|
+
direction: "VERTICAL"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Where slides dragged to a point on the page's deck land, as in Figma's grid: in a section's band,
|
|
44
|
+
* beside its nearest slide; between sections, above the first, or below the last, as a new section
|
|
45
|
+
* there. Null on a page without a deck.
|
|
46
|
+
*/
|
|
47
|
+
function slideDropAt(graph, pageId, point) {
|
|
48
|
+
const grid = graph.getChildren(pageId).find((node) => node.type === "SLIDE_GRID");
|
|
49
|
+
if (!grid) return null;
|
|
50
|
+
const rows = graph.getChildren(grid.id).filter((node) => node.type === "SLIDE_ROW").map((row) => ({
|
|
51
|
+
row,
|
|
52
|
+
box: boxOf(graph, row)
|
|
53
|
+
}));
|
|
54
|
+
const within = rows.find(({ box }) => point.y >= box.y && point.y <= box.y + box.height);
|
|
55
|
+
if (within) return besideNearest(graph, within.row, point);
|
|
56
|
+
const index = rows.findIndex(({ box }) => point.y < box.y);
|
|
57
|
+
const next = index === -1 ? void 0 : rows[index];
|
|
58
|
+
const previous = index === -1 ? rows.at(-1) : rows[index - 1];
|
|
59
|
+
const half = grid.itemSpacing / 2;
|
|
60
|
+
const gridBox = boxOf(graph, grid);
|
|
61
|
+
let y = gridBox.y + grid.paddingTop - half;
|
|
62
|
+
if (previous && next) y = (previous.box.y + previous.box.height + next.box.y) / 2;
|
|
63
|
+
else if (previous) y = previous.box.y + previous.box.height + half;
|
|
64
|
+
else if (next) y = next.box.y - half;
|
|
65
|
+
return {
|
|
66
|
+
placement: {
|
|
67
|
+
type: "section",
|
|
68
|
+
before: next?.row.id ?? null
|
|
69
|
+
},
|
|
70
|
+
line: {
|
|
71
|
+
x: gridBox.x + grid.paddingLeft,
|
|
72
|
+
y,
|
|
73
|
+
length: gridBox.width - grid.paddingLeft - grid.paddingRight,
|
|
74
|
+
direction: "HORIZONTAL"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export { slideDropAt };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=drop.js.map
|