@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":"shape-with-text.js","names":[],"sources":["../../src/generated/shape-with-text.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport { FIGJAM_TYPEFACES, figJamTextSizeFields } from '../figjam/text'\nimport type { SceneGraph } from '../index'\nimport { shapeWithTextLabelBox } from '../shape-with-text/fit'\nimport type { ShapeWithTextType } from '../shape-with-text/kinds'\nimport { lineHeightPixels } from '../text/lengths'\nimport type { Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */\nexport const SHAPE_WITH_TEXT_SIZE = 176\n/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\n\n/**\n * FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,\n * measured in FigJam; Figma draws the shape from that radius.\n */\nconst ROUNDED_RECTANGLE_RADIUS = 0.4\n\nconst LABEL_FILL: Fill = { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }\n\n/** How the label sits in its shape: as wide as the label box, as tall as its text. */\nexport const SHAPE_WITH_TEXT_LABEL_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/**\n * The shape's own layout: a vertical auto layout that centres the label in the label box of its\n * kind, which the padding leaves free. The padding follows the kind and size, so it is set again\n * whenever either changes.\n */\nexport function shapeWithTextFrameFields(\n kind: ShapeWithTextType,\n width: number,\n height: number\n): Partial<SceneNode> {\n const box = shapeWithTextLabelBox(kind, width, height)\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'CENTER',\n counterAxisAlign: 'CENTER',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n paddingTop: box.y,\n paddingRight: Math.max(0, width - box.x - box.width),\n paddingBottom: Math.max(0, height - box.y - box.height),\n paddingLeft: box.x,\n clipsContent: false,\n ...(kind === 'ROUNDED_RECTANGLE'\n ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) }\n : {})\n }\n}\n\n/**\n * What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the\n * label area, and the corners a rounded rectangle leaves go back to FigJam's 6.\n */\nexport function shapeWithTextKindFields(\n shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>,\n kind: ShapeWithTextType\n): Partial<SceneNode> {\n const leavesRounded =\n shape.shapeWithTextType === 'ROUNDED_RECTANGLE' && kind !== shape.shapeWithTextType\n return {\n shapeWithTextType: kind,\n ...(leavesRounded ? { cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS } : {}),\n ...shapeWithTextFrameFields(kind, shape.width, shape.height)\n }\n}\n\n/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */\nexport function shapeWithTextLabelFields(): Partial<SceneNode> {\n return {\n name: 'Text',\n fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,\n fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,\n ...figJamTextSizeFields('small'),\n textAlignHorizontal: 'CENTER',\n textAlignVertical: 'TOP',\n fills: [{ ...LABEL_FILL, color: { ...LABEL_FILL.color } }],\n ...SHAPE_WITH_TEXT_LABEL_LAYOUT\n }\n}\n\n/** A shape's label: its one text sublayer. */\nexport function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null {\n if (shape.type !== 'SHAPE_WITH_TEXT') return null\n const children = graph.getChildren(shape.id)\n if (children.length !== 1) return null\n const [label] = children\n return label.type === 'TEXT' ? label : null\n}\n\n/**\n * A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes\n * its name from its label until it is named. A height set on it by a resize, a field or a script\n * is the height it was given, which layout grows it from when its label needs more room; once\n * that height changes, FigJam keeps it and truncates the label instead.\n */\nexport const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,\n text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? undefined,\n rotates: true,\n resizes: true,\n namedByText: true,\n sized: ({ height }, shape) =>\n height === undefined || height === shape.height\n ? {}\n : { shapeUserHeight: height, shapeTruncates: true }\n}\n\n/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */\nexport function buildShapeWithTextLabel(\n graph: SceneGraph,\n shape: SceneNode,\n props: Partial<SceneNode> = {}\n): SceneNode {\n const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height)\n const fields = shapeWithTextLabelFields()\n return graph.createNode('TEXT', shape.id, {\n ...fields,\n x: box.x,\n y: box.y,\n width: box.width,\n height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? undefined,\n text: '',\n ...props\n })\n}\n\n/** A new shape with text and its label; the caller lays it out to grow it to its text. */\nexport function createShapeWithText(\n graph: SceneGraph,\n parentId: string,\n props: Partial<SceneNode> = {},\n label: Partial<SceneNode> = {}\n): SceneNode {\n const kind = props.shapeWithTextType ?? 'SQUARE'\n const width = props.width ?? SHAPE_WITH_TEXT_SIZE\n const height = props.height ?? SHAPE_WITH_TEXT_SIZE\n const shape = graph.createNode('SHAPE_WITH_TEXT', parentId, {\n name: 'Shape with text',\n cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS,\n ...props,\n shapeWithTextType: kind,\n width,\n height,\n shapeUserHeight: props.shapeUserHeight ?? height,\n ...shapeWithTextFrameFields(kind, width, height)\n })\n buildShapeWithTextLabel(graph, shape, label)\n return shape\n}\n"],"mappings":";;;;;;AAUA,MAAa,uBAAuB;;AAEpC,MAAa,gCAAgC;;;;;AAM7C,MAAM,2BAA2B;AAEjC,MAAM,aAAmB;CAAE,MAAM;CAAS,OAAO,EAAE,GAAG,MAAM;CAAG,SAAS;CAAK,SAAS;AAAK;;AAG3F,MAAa,+BAA+B;CAC1C,gBAAgB;CAChB,iBAAiB;AACnB;;;;;;AAOA,SAAgB,yBACd,MACA,OACA,QACoB;CACpB,MAAM,MAAM,sBAAsB,MAAM,OAAO,MAAM;CACrD,OAAO;EACL,YAAY;EACZ,kBAAkB;EAClB,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;EACb,YAAY,IAAI;EAChB,cAAc,KAAK,IAAI,GAAG,QAAQ,IAAI,IAAI,IAAI,KAAK;EACnD,eAAe,KAAK,IAAI,GAAG,SAAS,IAAI,IAAI,IAAI,MAAM;EACtD,aAAa,IAAI;EACjB,cAAc;EACd,GAAI,SAAS,sBACT,EAAE,cAAc,2BAA2B,KAAK,IAAI,OAAO,MAAM,EAAE,IACnE,CAAC;CACP;AACF;;;;;AAMA,SAAgB,wBACd,OACA,MACoB;CAGpB,OAAO;EACL,mBAAmB;EACnB,GAHA,MAAM,sBAAsB,uBAAuB,SAAS,MAAM,oBAG9C,EAAE,cAAA,EAA4C,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,CAAC,GAC7B,QAA4B,CAAC,GAClB;CACX,MAAM,OAAO,MAAM,qBAAqB;CACxC,MAAM,QAAQ,MAAM,SAAA;CACpB,MAAM,SAAS,MAAM,UAAA;CACrB,MAAM,QAAQ,MAAM,WAAW,mBAAmB,UAAU;EAC1D,MAAM;EACN,cAAA;EACA,GAAG;EACH,mBAAmB;EACnB;EACA;EACA,iBAAiB,MAAM,mBAAmB;EAC1C,GAAG,yBAAyB,MAAM,OAAO,MAAM;CACjD,CAAC;CACD,wBAAwB,OAAO,OAAO,KAAK;CAC3C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"shape-with-text.js","names":[],"sources":["../../src/generated/shape-with-text.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport { FIGJAM_TYPEFACES, figJamTextSizeFields } from '../figjam/text'\nimport type { SceneGraph } from '../index'\nimport { shapeWithTextLabelBox } from '../shape-with-text/fit'\nimport type { ShapeWithTextType } from '../shape-with-text/kinds'\nimport { lineHeightPixels } from '../text/lengths'\nimport type { Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */\nexport const SHAPE_WITH_TEXT_SIZE = 176\n/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\n\n/**\n * FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,\n * measured in FigJam; Figma draws the shape from that radius.\n */\nconst ROUNDED_RECTANGLE_RADIUS = 0.4\n\nconst LABEL_FILL: Fill = { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }\n\n/** How the label sits in its shape: as wide as the label box, as tall as its text. */\nexport const SHAPE_WITH_TEXT_LABEL_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/**\n * The shape's own layout: a vertical auto layout that centres the label in the label box of its\n * kind, which the padding leaves free. The padding follows the kind and size, so it is set again\n * whenever either changes.\n */\nexport function shapeWithTextFrameFields(\n kind: ShapeWithTextType,\n width: number,\n height: number\n): Partial<SceneNode> {\n const box = shapeWithTextLabelBox(kind, width, height)\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'CENTER',\n counterAxisAlign: 'CENTER',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n paddingTop: box.y,\n paddingRight: Math.max(0, width - box.x - box.width),\n paddingBottom: Math.max(0, height - box.y - box.height),\n paddingLeft: box.x,\n clipsContent: false,\n ...(kind === 'ROUNDED_RECTANGLE'\n ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) }\n : {})\n }\n}\n\n/**\n * What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the\n * label area, and the corners a rounded rectangle leaves go back to FigJam's 6.\n */\nexport function shapeWithTextKindFields(\n shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>,\n kind: ShapeWithTextType\n): Partial<SceneNode> {\n const leavesRounded =\n shape.shapeWithTextType === 'ROUNDED_RECTANGLE' && kind !== shape.shapeWithTextType\n return {\n shapeWithTextType: kind,\n ...(leavesRounded ? { cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS } : {}),\n ...shapeWithTextFrameFields(kind, shape.width, shape.height)\n }\n}\n\n/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */\nexport function shapeWithTextLabelFields(): Partial<SceneNode> {\n return {\n name: 'Text',\n fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,\n fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,\n ...figJamTextSizeFields('small'),\n textAlignHorizontal: 'CENTER',\n textAlignVertical: 'TOP',\n fills: [{ ...LABEL_FILL, color: { ...LABEL_FILL.color } }],\n ...SHAPE_WITH_TEXT_LABEL_LAYOUT\n }\n}\n\n/** A shape's label: its one text sublayer. */\nexport function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null {\n if (shape.type !== 'SHAPE_WITH_TEXT') return null\n const children = graph.getChildren(shape.id)\n if (children.length !== 1) return null\n const [label] = children\n return label.type === 'TEXT' ? label : null\n}\n\n/**\n * A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes\n * its name from its label until it is named. A height set on it by a resize, a field or a script\n * is the height it was given, which layout grows it from when its label needs more room; once\n * that height changes, FigJam keeps it and truncates the label instead.\n */\nexport const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,\n text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? undefined,\n rotates: true,\n resizes: true,\n namedByText: true,\n textSelection: 'all',\n sized: ({ height }, shape) =>\n height === undefined || height === shape.height\n ? {}\n : { shapeUserHeight: height, shapeTruncates: true }\n}\n\n/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */\nexport function buildShapeWithTextLabel(\n graph: SceneGraph,\n shape: SceneNode,\n props: Partial<SceneNode> = {}\n): SceneNode {\n const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height)\n const fields = shapeWithTextLabelFields()\n return graph.createNode('TEXT', shape.id, {\n ...fields,\n x: box.x,\n y: box.y,\n width: box.width,\n height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? undefined,\n text: '',\n ...props\n })\n}\n\n/** A new shape with text and its label; the caller lays it out to grow it to its text. */\nexport function createShapeWithText(\n graph: SceneGraph,\n parentId: string,\n props: Partial<SceneNode> = {},\n label: Partial<SceneNode> = {}\n): SceneNode {\n const kind = props.shapeWithTextType ?? 'SQUARE'\n const width = props.width ?? SHAPE_WITH_TEXT_SIZE\n const height = props.height ?? SHAPE_WITH_TEXT_SIZE\n const shape = graph.createNode('SHAPE_WITH_TEXT', parentId, {\n name: 'Shape with text',\n cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS,\n ...props,\n shapeWithTextType: kind,\n width,\n height,\n shapeUserHeight: props.shapeUserHeight ?? height,\n ...shapeWithTextFrameFields(kind, width, height)\n })\n buildShapeWithTextLabel(graph, shape, label)\n return shape\n}\n"],"mappings":";;;;;;AAUA,MAAa,uBAAuB;;AAEpC,MAAa,gCAAgC;;;;;AAM7C,MAAM,2BAA2B;AAEjC,MAAM,aAAmB;CAAE,MAAM;CAAS,OAAO,EAAE,GAAG,MAAM;CAAG,SAAS;CAAK,SAAS;AAAK;;AAG3F,MAAa,+BAA+B;CAC1C,gBAAgB;CAChB,iBAAiB;AACnB;;;;;;AAOA,SAAgB,yBACd,MACA,OACA,QACoB;CACpB,MAAM,MAAM,sBAAsB,MAAM,OAAO,MAAM;CACrD,OAAO;EACL,YAAY;EACZ,kBAAkB;EAClB,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa;EACb,YAAY,IAAI;EAChB,cAAc,KAAK,IAAI,GAAG,QAAQ,IAAI,IAAI,IAAI,KAAK;EACnD,eAAe,KAAK,IAAI,GAAG,SAAS,IAAI,IAAI,IAAI,MAAM;EACtD,aAAa,IAAI;EACjB,cAAc;EACd,GAAI,SAAS,sBACT,EAAE,cAAc,2BAA2B,KAAK,IAAI,OAAO,MAAM,EAAE,IACnE,CAAC;CACP;AACF;;;;;AAMA,SAAgB,wBACd,OACA,MACoB;CAGpB,OAAO;EACL,mBAAmB;EACnB,GAHA,MAAM,sBAAsB,uBAAuB,SAAS,MAAM,oBAG9C,EAAE,cAAA,EAA4C,IAAI,CAAC;EACvE,GAAG,yBAAyB,MAAM,MAAM,OAAO,MAAM,MAAM;CAC7D;AACF;;AAGA,SAAgB,2BAA+C;CAC7D,OAAO;EACL,MAAM;EACN,YAAY,iBAAiB,OAAO;EACpC,YAAY,iBAAiB,OAAO;EACpC,GAAG,qBAAqB,OAAO;EAC/B,qBAAqB;EACrB,mBAAmB;EACnB,OAAO,CAAC;GAAE,GAAG;GAAY,OAAO,EAAE,GAAG,WAAW,MAAM;EAAE,CAAC;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;CACjD,CAAC;CACD,wBAAwB,OAAO,OAAO,KAAK;CAC3C,OAAO;AACT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { Color } from "../primitives/index.js";
|
|
3
|
+
import { SpecBlockKind } from "../specs/schema.js";
|
|
4
|
+
import { SceneNode } from "../types.js";
|
|
5
|
+
import { GeneratedFrameKind } from "./kind.js";
|
|
6
|
+
/**
|
|
7
|
+
* A spec as OpenPencil draws it: a white page of fixed width that grows to fit its blocks, one
|
|
8
|
+
* sublayer per block of its Markdown, stacked by a vertical auto layout.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SPEC_WIDTH = 720;
|
|
11
|
+
export declare const SPEC_FONT_FAMILY = "Inter";
|
|
12
|
+
export declare const SPEC_FONT_SIZE = 16;
|
|
13
|
+
export declare const SPEC_FONT_WEIGHT = 400;
|
|
14
|
+
export declare const SPEC_CODE_FONT_FAMILY = "Roboto Mono";
|
|
15
|
+
export declare const SPEC_CODE_FONT_SIZE = 14;
|
|
16
|
+
/** The spec's own fields: the page, its padding, and the auto layout that stacks its blocks. */
|
|
17
|
+
export declare function specFrameFields(): Partial<SceneNode>;
|
|
18
|
+
/** A prose block's text: as wide as the page allows and as tall as its text. */
|
|
19
|
+
export declare function specTextFields(kind: SpecBlockKind): Partial<SceneNode>;
|
|
20
|
+
/** A heading's own style, which its text is set in and its Markdown is written relative to. */
|
|
21
|
+
export declare function specHeadingFields(level: number): Pick<SceneNode, 'fontSize' | 'fontWeight' | 'lineHeight'>;
|
|
22
|
+
/** The frame a code block's text sits in. */
|
|
23
|
+
export declare function specCodeFrameFields(): Partial<SceneNode>;
|
|
24
|
+
/** A `::tokens` table: rows stacked as wide as the page, in a rounded outline. */
|
|
25
|
+
export declare function specTableFields(): Partial<SceneNode>;
|
|
26
|
+
/** A row of a table, its cells side by side; the header row is shaded as code is. */
|
|
27
|
+
export declare function specTableRowFields(header: boolean): Partial<SceneNode>;
|
|
28
|
+
/** A cell of a table: an equal share of its row, its contents side by side. */
|
|
29
|
+
export declare function specTableCellFields(): Partial<SceneNode>;
|
|
30
|
+
/** A cell's words; a header's are muted and a value's set in the code face. */
|
|
31
|
+
export declare function specTableTextFields(cell: 'header' | 'name' | 'value'): Partial<SceneNode>;
|
|
32
|
+
/** The swatch before a colour's value in a table. */
|
|
33
|
+
export declare function specTableSwatchFields(color: Color): Partial<SceneNode>;
|
|
34
|
+
/** A horizontal rule: a hairline as wide as the page. */
|
|
35
|
+
export declare function specRuleFields(): Partial<SceneNode>;
|
|
36
|
+
/** The spec's sublayer that `node` is or sits in. */
|
|
37
|
+
export declare function specBlockLayer(graph: SceneGraph, spec: SceneNode, node: SceneNode): SceneNode | undefined;
|
|
38
|
+
/** The text of a spec's block typed into in place, or none for blocks drawn otherwise. */
|
|
39
|
+
export declare function specBlockText(graph: SceneGraph, layer: SceneNode): SceneNode | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* A spec is edited block by block, in the text of the block a double-click lands on; it resizes
|
|
42
|
+
* only in width, its height following its blocks.
|
|
43
|
+
*/
|
|
44
|
+
export declare const SPEC_KIND: GeneratedFrameKind;
|
|
45
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","names":[],"sources":["../../src/generated/spec.ts"],"mappings":";;;;;;;;;qBAYa;qBAMA;qBACA;qBACA;qBACA;qBACA;;wBAgCG,mBAAmB,QAAQ;;wBAoB3B,eAAe,MAAM,gBAAgB,QAAQ;;wBAoB7C,kBACd,gBACC,KAAK;;wBAMQ,uBAAuB,QAAQ;;wBAsB/B,mBAAmB,QAAQ;;wBAe3B,mBAAmB,kBAAkB,QAAQ;;wBAa7C,uBAAuB,QAAQ;;wBAiB/B,oBAAoB,oCAAoC,QAAQ;;wBAYhE,sBAAsB,OAAO,QAAQ,QAAQ;;wBAW7C,kBAAkB,QAAQ;;wBAa1B,eACd,OAAO,YACP,MAAM,WACN,MAAM,YACL;;wBAKa,cAAc,OAAO,YAAY,OAAO,YAAY;;;;;qBASvD,WAAW"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { readSpecBlock } from "../specs/model.js";
|
|
2
|
+
import { percentLength } from "../text/lengths.js";
|
|
3
|
+
// src/generated/spec.ts
|
|
4
|
+
/**
|
|
5
|
+
* A spec as OpenPencil draws it: a white page of fixed width that grows to fit its blocks, one
|
|
6
|
+
* sublayer per block of its Markdown, stacked by a vertical auto layout.
|
|
7
|
+
*/
|
|
8
|
+
const SPEC_WIDTH = 720;
|
|
9
|
+
const SPEC_PADDING_X = 56;
|
|
10
|
+
const SPEC_PADDING_Y = 48;
|
|
11
|
+
const SPEC_BLOCK_GAP = 16;
|
|
12
|
+
const SPEC_RADIUS = 16;
|
|
13
|
+
const SPEC_FONT_FAMILY = "Inter";
|
|
14
|
+
const SPEC_FONT_SIZE = 16;
|
|
15
|
+
const SPEC_FONT_WEIGHT = 400;
|
|
16
|
+
const SPEC_CODE_FONT_FAMILY = "Roboto Mono";
|
|
17
|
+
const SPEC_CODE_FONT_SIZE = 14;
|
|
18
|
+
const SPEC_CODE_PADDING = 16;
|
|
19
|
+
const SPEC_CODE_RADIUS = 8;
|
|
20
|
+
const INK = {
|
|
21
|
+
r: .118,
|
|
22
|
+
g: .118,
|
|
23
|
+
b: .118,
|
|
24
|
+
a: 1
|
|
25
|
+
};
|
|
26
|
+
const MUTED_INK = {
|
|
27
|
+
r: .459,
|
|
28
|
+
g: .459,
|
|
29
|
+
b: .459,
|
|
30
|
+
a: 1
|
|
31
|
+
};
|
|
32
|
+
const CODE_BACKGROUND = {
|
|
33
|
+
r: .96,
|
|
34
|
+
g: .96,
|
|
35
|
+
b: .96,
|
|
36
|
+
a: 1
|
|
37
|
+
};
|
|
38
|
+
const RULE = {
|
|
39
|
+
r: .9,
|
|
40
|
+
g: .9,
|
|
41
|
+
b: .9,
|
|
42
|
+
a: 1
|
|
43
|
+
};
|
|
44
|
+
const WHITE = {
|
|
45
|
+
r: 1,
|
|
46
|
+
g: 1,
|
|
47
|
+
b: 1,
|
|
48
|
+
a: 1
|
|
49
|
+
};
|
|
50
|
+
function solid(color) {
|
|
51
|
+
return {
|
|
52
|
+
type: "SOLID",
|
|
53
|
+
color: { ...color },
|
|
54
|
+
opacity: 1,
|
|
55
|
+
visible: true
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function hairline() {
|
|
59
|
+
return {
|
|
60
|
+
...solid(RULE),
|
|
61
|
+
weight: 1,
|
|
62
|
+
align: "INSIDE"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function shadow(y, radius, alpha) {
|
|
66
|
+
return {
|
|
67
|
+
type: "DROP_SHADOW",
|
|
68
|
+
color: {
|
|
69
|
+
r: 0,
|
|
70
|
+
g: 0,
|
|
71
|
+
b: 0,
|
|
72
|
+
a: alpha
|
|
73
|
+
},
|
|
74
|
+
offset: {
|
|
75
|
+
x: 0,
|
|
76
|
+
y
|
|
77
|
+
},
|
|
78
|
+
radius,
|
|
79
|
+
spread: 0,
|
|
80
|
+
visible: true,
|
|
81
|
+
blendMode: "NORMAL",
|
|
82
|
+
showShadowBehindNode: false
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** The spec's own fields: the page, its padding, and the auto layout that stacks its blocks. */
|
|
86
|
+
function specFrameFields() {
|
|
87
|
+
return {
|
|
88
|
+
layoutMode: "VERTICAL",
|
|
89
|
+
primaryAxisAlign: "MIN",
|
|
90
|
+
counterAxisAlign: "MIN",
|
|
91
|
+
primaryAxisSizing: "HUG",
|
|
92
|
+
counterAxisSizing: "FIXED",
|
|
93
|
+
itemSpacing: SPEC_BLOCK_GAP,
|
|
94
|
+
paddingTop: SPEC_PADDING_Y,
|
|
95
|
+
paddingBottom: SPEC_PADDING_Y,
|
|
96
|
+
paddingLeft: SPEC_PADDING_X,
|
|
97
|
+
paddingRight: SPEC_PADDING_X,
|
|
98
|
+
cornerRadius: SPEC_RADIUS,
|
|
99
|
+
clipsContent: false,
|
|
100
|
+
fills: [solid(WHITE)],
|
|
101
|
+
effects: [shadow(1, 3, .08), shadow(4, 12, .06)]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** A prose block's text: as wide as the page allows and as tall as its text. */
|
|
105
|
+
function specTextFields(kind) {
|
|
106
|
+
const code = kind === "code" || kind === "raw";
|
|
107
|
+
return {
|
|
108
|
+
fontFamily: code ? SPEC_CODE_FONT_FAMILY : SPEC_FONT_FAMILY,
|
|
109
|
+
fontWeight: 400,
|
|
110
|
+
fontSize: code ? 14 : 16,
|
|
111
|
+
lineHeight: percentLength(150),
|
|
112
|
+
textAlignHorizontal: "LEFT",
|
|
113
|
+
textAlignVertical: "TOP",
|
|
114
|
+
textAutoResize: "HEIGHT",
|
|
115
|
+
layoutAlignSelf: "STRETCH",
|
|
116
|
+
fills: [solid(kind === "raw" || kind === "quote" ? MUTED_INK : INK)],
|
|
117
|
+
italic: kind === "quote"
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** Heading sizes by level, 1 to 6; levels past the list take the last. */
|
|
121
|
+
const HEADING_SIZES = [
|
|
122
|
+
32,
|
|
123
|
+
24,
|
|
124
|
+
20,
|
|
125
|
+
17,
|
|
126
|
+
16,
|
|
127
|
+
16
|
|
128
|
+
];
|
|
129
|
+
/** A heading's own style, which its text is set in and its Markdown is written relative to. */
|
|
130
|
+
function specHeadingFields(level) {
|
|
131
|
+
return {
|
|
132
|
+
fontSize: HEADING_SIZES[Math.min(Math.max(level, 1), HEADING_SIZES.length) - 1],
|
|
133
|
+
fontWeight: level <= 2 ? 700 : 600,
|
|
134
|
+
lineHeight: percentLength(130)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The frame a code block's text sits in. */
|
|
138
|
+
function specCodeFrameFields() {
|
|
139
|
+
return {
|
|
140
|
+
layoutMode: "VERTICAL",
|
|
141
|
+
primaryAxisSizing: "HUG",
|
|
142
|
+
counterAxisSizing: "FIXED",
|
|
143
|
+
layoutAlignSelf: "STRETCH",
|
|
144
|
+
paddingTop: SPEC_CODE_PADDING,
|
|
145
|
+
paddingBottom: SPEC_CODE_PADDING,
|
|
146
|
+
paddingLeft: SPEC_CODE_PADDING,
|
|
147
|
+
paddingRight: SPEC_CODE_PADDING,
|
|
148
|
+
cornerRadius: SPEC_CODE_RADIUS,
|
|
149
|
+
clipsContent: true,
|
|
150
|
+
fills: [solid(CODE_BACKGROUND)]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const SPEC_TABLE_CELL_PADDING_X = 12;
|
|
154
|
+
const SPEC_TABLE_CELL_PADDING_Y = 8;
|
|
155
|
+
const SPEC_TABLE_FONT_SIZE = 14;
|
|
156
|
+
const SPEC_TABLE_SWATCH = 14;
|
|
157
|
+
/** A `::tokens` table: rows stacked as wide as the page, in a rounded outline. */
|
|
158
|
+
function specTableFields() {
|
|
159
|
+
return {
|
|
160
|
+
layoutMode: "VERTICAL",
|
|
161
|
+
primaryAxisSizing: "HUG",
|
|
162
|
+
counterAxisSizing: "FIXED",
|
|
163
|
+
layoutAlignSelf: "STRETCH",
|
|
164
|
+
itemSpacing: 0,
|
|
165
|
+
cornerRadius: SPEC_CODE_RADIUS,
|
|
166
|
+
clipsContent: true,
|
|
167
|
+
fills: [],
|
|
168
|
+
strokes: [hairline()]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** A row of a table, its cells side by side; the header row is shaded as code is. */
|
|
172
|
+
function specTableRowFields(header) {
|
|
173
|
+
return {
|
|
174
|
+
layoutMode: "HORIZONTAL",
|
|
175
|
+
primaryAxisSizing: "FIXED",
|
|
176
|
+
counterAxisSizing: "HUG",
|
|
177
|
+
counterAxisAlign: "CENTER",
|
|
178
|
+
layoutAlignSelf: "STRETCH",
|
|
179
|
+
itemSpacing: 0,
|
|
180
|
+
fills: header ? [solid(CODE_BACKGROUND)] : []
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/** A cell of a table: an equal share of its row, its contents side by side. */
|
|
184
|
+
function specTableCellFields() {
|
|
185
|
+
return {
|
|
186
|
+
layoutMode: "HORIZONTAL",
|
|
187
|
+
primaryAxisSizing: "FIXED",
|
|
188
|
+
counterAxisSizing: "HUG",
|
|
189
|
+
counterAxisAlign: "CENTER",
|
|
190
|
+
layoutGrow: 1,
|
|
191
|
+
itemSpacing: 8,
|
|
192
|
+
paddingTop: SPEC_TABLE_CELL_PADDING_Y,
|
|
193
|
+
paddingBottom: SPEC_TABLE_CELL_PADDING_Y,
|
|
194
|
+
paddingLeft: SPEC_TABLE_CELL_PADDING_X,
|
|
195
|
+
paddingRight: SPEC_TABLE_CELL_PADDING_X,
|
|
196
|
+
fills: []
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** A cell's words; a header's are muted and a value's set in the code face. */
|
|
200
|
+
function specTableTextFields(cell) {
|
|
201
|
+
return {
|
|
202
|
+
fontFamily: cell === "value" ? SPEC_CODE_FONT_FAMILY : SPEC_FONT_FAMILY,
|
|
203
|
+
fontWeight: cell === "header" ? 600 : 400,
|
|
204
|
+
fontSize: SPEC_TABLE_FONT_SIZE,
|
|
205
|
+
lineHeight: percentLength(150),
|
|
206
|
+
textAutoResize: "WIDTH_AND_HEIGHT",
|
|
207
|
+
fills: [solid(cell === "header" ? MUTED_INK : INK)]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/** The swatch before a colour's value in a table. */
|
|
211
|
+
function specTableSwatchFields(color) {
|
|
212
|
+
return {
|
|
213
|
+
width: SPEC_TABLE_SWATCH,
|
|
214
|
+
height: SPEC_TABLE_SWATCH,
|
|
215
|
+
cornerRadius: 3,
|
|
216
|
+
fills: [{
|
|
217
|
+
type: "SOLID",
|
|
218
|
+
color: {
|
|
219
|
+
...color,
|
|
220
|
+
a: 1
|
|
221
|
+
},
|
|
222
|
+
opacity: color.a,
|
|
223
|
+
visible: true
|
|
224
|
+
}],
|
|
225
|
+
strokes: [hairline()]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/** A horizontal rule: a hairline as wide as the page. */
|
|
229
|
+
function specRuleFields() {
|
|
230
|
+
return {
|
|
231
|
+
height: 1,
|
|
232
|
+
layoutAlignSelf: "STRETCH",
|
|
233
|
+
fills: [solid(RULE)]
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** The text a block's sublayer is edited through: the sublayer itself or the text inside it. */
|
|
237
|
+
function blockText(graph, layer) {
|
|
238
|
+
if (layer.type === "TEXT") return layer;
|
|
239
|
+
return graph.getChildren(layer.id).find((child) => child.type === "TEXT");
|
|
240
|
+
}
|
|
241
|
+
const PROSE = /* @__PURE__ */ new Set([
|
|
242
|
+
"heading",
|
|
243
|
+
"paragraph",
|
|
244
|
+
"list",
|
|
245
|
+
"quote",
|
|
246
|
+
"code"
|
|
247
|
+
]);
|
|
248
|
+
/** The spec's sublayer that `node` is or sits in. */
|
|
249
|
+
function specBlockLayer(graph, spec, node) {
|
|
250
|
+
return graph.closest(node.id, (candidate) => candidate.parentId === spec.id);
|
|
251
|
+
}
|
|
252
|
+
/** The text of a spec's block typed into in place, or none for blocks drawn otherwise. */
|
|
253
|
+
function specBlockText(graph, layer) {
|
|
254
|
+
const block = readSpecBlock(layer);
|
|
255
|
+
return block && PROSE.has(block.kind) ? blockText(graph, layer) : void 0;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* A spec is edited block by block, in the text of the block a double-click lands on; it resizes
|
|
259
|
+
* only in width, its height following its blocks.
|
|
260
|
+
*/
|
|
261
|
+
const SPEC_KIND = {
|
|
262
|
+
complete: () => true,
|
|
263
|
+
text: (graph, frame, sublayer) => {
|
|
264
|
+
if (sublayer) {
|
|
265
|
+
const layer = specBlockLayer(graph, frame, sublayer);
|
|
266
|
+
return layer ? specBlockText(graph, layer) : void 0;
|
|
267
|
+
}
|
|
268
|
+
for (const layer of graph.getChildren(frame.id)) {
|
|
269
|
+
const text = specBlockText(graph, layer);
|
|
270
|
+
if (text) return text;
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
embeds: (child) => readSpecBlock(child)?.kind === "instance",
|
|
274
|
+
rotates: true,
|
|
275
|
+
resizes: true,
|
|
276
|
+
namedByText: false,
|
|
277
|
+
textSelection: "caret"
|
|
278
|
+
};
|
|
279
|
+
export { SPEC_CODE_FONT_FAMILY, SPEC_CODE_FONT_SIZE, SPEC_FONT_FAMILY, SPEC_FONT_SIZE, SPEC_FONT_WEIGHT, SPEC_KIND, SPEC_WIDTH, specBlockLayer, specBlockText, specCodeFrameFields, specFrameFields, specHeadingFields, specRuleFields, specTableCellFields, specTableFields, specTableRowFields, specTableSwatchFields, specTableTextFields, specTextFields };
|
|
280
|
+
|
|
281
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","names":[],"sources":["../../src/generated/spec.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { Color } from '../primitives'\nimport { readSpecBlock } from '../specs/model'\nimport type { SpecBlockKind } from '../specs/schema'\nimport { percentLength } from '../text/lengths'\nimport type { Effect, Fill, SceneNode, Stroke } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/**\n * A spec as OpenPencil draws it: a white page of fixed width that grows to fit its blocks, one\n * sublayer per block of its Markdown, stacked by a vertical auto layout.\n */\nexport const SPEC_WIDTH = 720\nconst SPEC_PADDING_X = 56\nconst SPEC_PADDING_Y = 48\nconst SPEC_BLOCK_GAP = 16\nconst SPEC_RADIUS = 16\n\nexport const SPEC_FONT_FAMILY = 'Inter'\nexport const SPEC_FONT_SIZE = 16\nexport const SPEC_FONT_WEIGHT = 400\nexport const SPEC_CODE_FONT_FAMILY = 'Roboto Mono'\nexport const SPEC_CODE_FONT_SIZE = 14\nconst SPEC_CODE_PADDING = 16\nconst SPEC_CODE_RADIUS = 8\n\nconst INK: Color = { r: 0.118, g: 0.118, b: 0.118, a: 1 }\nconst MUTED_INK: Color = { r: 0.459, g: 0.459, b: 0.459, a: 1 }\nconst CODE_BACKGROUND: Color = { r: 0.96, g: 0.96, b: 0.96, a: 1 }\nconst RULE: Color = { r: 0.9, g: 0.9, b: 0.9, a: 1 }\nconst WHITE: Color = { r: 1, g: 1, b: 1, a: 1 }\n\nfunction solid(color: Color): Fill {\n return { type: 'SOLID', color: { ...color }, opacity: 1, visible: true }\n}\n\nfunction hairline(): Stroke {\n return { ...solid(RULE), weight: 1, align: 'INSIDE' }\n}\n\nfunction shadow(y: number, radius: number, alpha: number): Effect {\n return {\n type: 'DROP_SHADOW',\n color: { r: 0, g: 0, b: 0, a: alpha },\n offset: { x: 0, y },\n radius,\n spread: 0,\n visible: true,\n blendMode: 'NORMAL',\n showShadowBehindNode: false\n }\n}\n\n/** The spec's own fields: the page, its padding, and the auto layout that stacks its blocks. */\nexport function specFrameFields(): Partial<SceneNode> {\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n itemSpacing: SPEC_BLOCK_GAP,\n paddingTop: SPEC_PADDING_Y,\n paddingBottom: SPEC_PADDING_Y,\n paddingLeft: SPEC_PADDING_X,\n paddingRight: SPEC_PADDING_X,\n cornerRadius: SPEC_RADIUS,\n clipsContent: false,\n fills: [solid(WHITE)],\n effects: [shadow(1, 3, 0.08), shadow(4, 12, 0.06)]\n }\n}\n\n/** A prose block's text: as wide as the page allows and as tall as its text. */\nexport function specTextFields(kind: SpecBlockKind): Partial<SceneNode> {\n const code = kind === 'code' || kind === 'raw'\n return {\n fontFamily: code ? SPEC_CODE_FONT_FAMILY : SPEC_FONT_FAMILY,\n fontWeight: SPEC_FONT_WEIGHT,\n fontSize: code ? SPEC_CODE_FONT_SIZE : SPEC_FONT_SIZE,\n lineHeight: percentLength(150),\n textAlignHorizontal: 'LEFT',\n textAlignVertical: 'TOP',\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH',\n fills: [solid(kind === 'raw' || kind === 'quote' ? MUTED_INK : INK)],\n italic: kind === 'quote'\n }\n}\n\n/** Heading sizes by level, 1 to 6; levels past the list take the last. */\nconst HEADING_SIZES = [32, 24, 20, 17, 16, 16] as const\n\n/** A heading's own style, which its text is set in and its Markdown is written relative to. */\nexport function specHeadingFields(\n level: number\n): Pick<SceneNode, 'fontSize' | 'fontWeight' | 'lineHeight'> {\n const size = HEADING_SIZES[Math.min(Math.max(level, 1), HEADING_SIZES.length) - 1]\n return { fontSize: size, fontWeight: level <= 2 ? 700 : 600, lineHeight: percentLength(130) }\n}\n\n/** The frame a code block's text sits in. */\nexport function specCodeFrameFields(): Partial<SceneNode> {\n return {\n layoutMode: 'VERTICAL',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n layoutAlignSelf: 'STRETCH',\n paddingTop: SPEC_CODE_PADDING,\n paddingBottom: SPEC_CODE_PADDING,\n paddingLeft: SPEC_CODE_PADDING,\n paddingRight: SPEC_CODE_PADDING,\n cornerRadius: SPEC_CODE_RADIUS,\n clipsContent: true,\n fills: [solid(CODE_BACKGROUND)]\n }\n}\n\nconst SPEC_TABLE_CELL_PADDING_X = 12\nconst SPEC_TABLE_CELL_PADDING_Y = 8\nconst SPEC_TABLE_FONT_SIZE = 14\nconst SPEC_TABLE_SWATCH = 14\n\n/** A `::tokens` table: rows stacked as wide as the page, in a rounded outline. */\nexport function specTableFields(): Partial<SceneNode> {\n return {\n layoutMode: 'VERTICAL',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n layoutAlignSelf: 'STRETCH',\n itemSpacing: 0,\n cornerRadius: SPEC_CODE_RADIUS,\n clipsContent: true,\n fills: [],\n strokes: [hairline()]\n }\n}\n\n/** A row of a table, its cells side by side; the header row is shaded as code is. */\nexport function specTableRowFields(header: boolean): Partial<SceneNode> {\n return {\n layoutMode: 'HORIZONTAL',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'HUG',\n counterAxisAlign: 'CENTER',\n layoutAlignSelf: 'STRETCH',\n itemSpacing: 0,\n fills: header ? [solid(CODE_BACKGROUND)] : []\n }\n}\n\n/** A cell of a table: an equal share of its row, its contents side by side. */\nexport function specTableCellFields(): Partial<SceneNode> {\n return {\n layoutMode: 'HORIZONTAL',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'HUG',\n counterAxisAlign: 'CENTER',\n layoutGrow: 1,\n itemSpacing: 8,\n paddingTop: SPEC_TABLE_CELL_PADDING_Y,\n paddingBottom: SPEC_TABLE_CELL_PADDING_Y,\n paddingLeft: SPEC_TABLE_CELL_PADDING_X,\n paddingRight: SPEC_TABLE_CELL_PADDING_X,\n fills: []\n }\n}\n\n/** A cell's words; a header's are muted and a value's set in the code face. */\nexport function specTableTextFields(cell: 'header' | 'name' | 'value'): Partial<SceneNode> {\n return {\n fontFamily: cell === 'value' ? SPEC_CODE_FONT_FAMILY : SPEC_FONT_FAMILY,\n fontWeight: cell === 'header' ? 600 : SPEC_FONT_WEIGHT,\n fontSize: SPEC_TABLE_FONT_SIZE,\n lineHeight: percentLength(150),\n textAutoResize: 'WIDTH_AND_HEIGHT',\n fills: [solid(cell === 'header' ? MUTED_INK : INK)]\n }\n}\n\n/** The swatch before a colour's value in a table. */\nexport function specTableSwatchFields(color: Color): Partial<SceneNode> {\n return {\n width: SPEC_TABLE_SWATCH,\n height: SPEC_TABLE_SWATCH,\n cornerRadius: 3,\n fills: [{ type: 'SOLID', color: { ...color, a: 1 }, opacity: color.a, visible: true }],\n strokes: [hairline()]\n }\n}\n\n/** A horizontal rule: a hairline as wide as the page. */\nexport function specRuleFields(): Partial<SceneNode> {\n return { height: 1, layoutAlignSelf: 'STRETCH', fills: [solid(RULE)] }\n}\n\n/** The text a block's sublayer is edited through: the sublayer itself or the text inside it. */\nfunction blockText(graph: SceneGraph, layer: SceneNode): SceneNode | undefined {\n if (layer.type === 'TEXT') return layer\n return graph.getChildren(layer.id).find((child) => child.type === 'TEXT')\n}\n\nconst PROSE: ReadonlySet<SpecBlockKind> = new Set(['heading', 'paragraph', 'list', 'quote', 'code'])\n\n/** The spec's sublayer that `node` is or sits in. */\nexport function specBlockLayer(\n graph: SceneGraph,\n spec: SceneNode,\n node: SceneNode\n): SceneNode | undefined {\n return graph.closest(node.id, (candidate) => candidate.parentId === spec.id)\n}\n\n/** The text of a spec's block typed into in place, or none for blocks drawn otherwise. */\nexport function specBlockText(graph: SceneGraph, layer: SceneNode): SceneNode | undefined {\n const block = readSpecBlock(layer)\n return block && PROSE.has(block.kind) ? blockText(graph, layer) : undefined\n}\n\n/**\n * A spec is edited block by block, in the text of the block a double-click lands on; it resizes\n * only in width, its height following its blocks.\n */\nexport const SPEC_KIND: GeneratedFrameKind = {\n complete: () => true,\n text: (graph, frame, sublayer) => {\n if (sublayer) {\n const layer = specBlockLayer(graph, frame, sublayer)\n return layer ? specBlockText(graph, layer) : undefined\n }\n for (const layer of graph.getChildren(frame.id)) {\n const text = specBlockText(graph, layer)\n if (text) return text\n }\n return undefined\n },\n // An instance block is an instance as anywhere else; Markdown records what is done to it.\n embeds: (child) => readSpecBlock(child)?.kind === 'instance',\n rotates: true,\n resizes: true,\n namedByText: false,\n textSelection: 'caret'\n}\n"],"mappings":";;;;;;;AAYA,MAAa,aAAa;AAC1B,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AACvB,MAAM,cAAc;AAEpB,MAAa,mBAAmB;AAChC,MAAa,iBAAiB;AAC9B,MAAa,mBAAmB;AAChC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;AACnC,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AAEzB,MAAM,MAAa;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAO,GAAG;AAAE;AACxD,MAAM,YAAmB;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAO,GAAG;AAAE;AAC9D,MAAM,kBAAyB;CAAE,GAAG;CAAM,GAAG;CAAM,GA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AU,cAAc,KAAK,CAAC,EAAE,SAAS;CAClD,SAAS;CACT,SAAS;CACT,aAAa;CACb,eAAe;AACjB"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { Color } from "../primitives/index.js";
|
|
2
1
|
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { Color } from "../primitives/index.js";
|
|
3
3
|
import { Effect, SceneNode } from "../types.js";
|
|
4
4
|
import { GeneratedFrameKind } from "./kind.js";
|
|
5
|
-
//#region src/generated/sticky.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with
|
|
8
7
|
* the author pinned to the bottom. Every length scales with the note, which `rescale` changes;
|
|
9
8
|
* the values here are those of a note at scale 1, measured in Figma.
|
|
10
9
|
*/
|
|
11
|
-
declare const STICKY_SIZE = 240;
|
|
12
|
-
declare const STICKY_WIDE_WIDTH = 416;
|
|
13
|
-
declare const STICKY_FONT_FAMILY = "Inter";
|
|
14
|
-
declare const STICKY_FONT_WEIGHT = 500;
|
|
15
|
-
declare const STICKY_BODY_FONT_SIZE = 16;
|
|
16
|
-
declare const STICKY_AUTHOR_FONT_SIZE = 12;
|
|
10
|
+
export declare const STICKY_SIZE = 240;
|
|
11
|
+
export declare const STICKY_WIDE_WIDTH = 416;
|
|
12
|
+
export declare const STICKY_FONT_FAMILY = "Inter";
|
|
13
|
+
export declare const STICKY_FONT_WEIGHT = 500;
|
|
14
|
+
export declare const STICKY_BODY_FONT_SIZE = 16;
|
|
15
|
+
export declare const STICKY_AUTHOR_FONT_SIZE = 12;
|
|
17
16
|
/** FigJam's sticky palette, in its picker's order. */
|
|
18
|
-
declare const STICKY_COLORS: {
|
|
17
|
+
export declare const STICKY_COLORS: {
|
|
19
18
|
readonly white: {
|
|
20
19
|
readonly r: 1;
|
|
21
20
|
readonly g: 1;
|
|
@@ -77,38 +76,38 @@ declare const STICKY_COLORS: {
|
|
|
77
76
|
readonly a: 1;
|
|
78
77
|
};
|
|
79
78
|
};
|
|
80
|
-
declare const DEFAULT_STICKY_COLOR: Color;
|
|
79
|
+
export declare const DEFAULT_STICKY_COLOR: Color;
|
|
81
80
|
/** The three soft shadows Figma gives every sticky. */
|
|
82
|
-
declare function stickyShadows(): Effect[];
|
|
81
|
+
export declare function stickyShadows(): Effect[];
|
|
83
82
|
/**
|
|
84
83
|
* The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,
|
|
85
84
|
* spreading them apart so the author sits at the bottom. A generated frame keeps its gap with
|
|
86
85
|
* space between, which keeps the author clear of a long body.
|
|
87
86
|
*/
|
|
88
|
-
declare function stickyFrameFields(scale?: number): Partial<SceneNode>;
|
|
89
|
-
type StickyTextRole = 'body' | 'author';
|
|
87
|
+
export declare function stickyFrameFields(scale?: number): Partial<SceneNode>;
|
|
88
|
+
export type StickyTextRole = 'body' | 'author';
|
|
90
89
|
/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */
|
|
91
|
-
declare const STICKY_SUBLAYER_LAYOUT: {
|
|
90
|
+
export declare const STICKY_SUBLAYER_LAYOUT: {
|
|
92
91
|
readonly textAutoResize: "HEIGHT";
|
|
93
92
|
readonly layoutAlignSelf: "STRETCH";
|
|
94
93
|
};
|
|
95
94
|
/** A sublayer's text style; the body follows the size preset, the author only the scale. */
|
|
96
|
-
declare function stickyTextFields(role: StickyTextRole, scale?: number, fontSize?: number): Partial<SceneNode>;
|
|
95
|
+
export declare function stickyTextFields(role: StickyTextRole, scale?: number, fontSize?: number): Partial<SceneNode>;
|
|
97
96
|
/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */
|
|
98
|
-
declare function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number;
|
|
97
|
+
export declare function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number;
|
|
99
98
|
/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */
|
|
100
|
-
declare function stickyWidth(scale: number, wide: boolean): number;
|
|
99
|
+
export declare function stickyWidth(scale: number, wide: boolean): number;
|
|
101
100
|
/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */
|
|
102
|
-
declare function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean;
|
|
103
|
-
interface StickySublayers {
|
|
101
|
+
export declare function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean;
|
|
102
|
+
export interface StickySublayers {
|
|
104
103
|
body: SceneNode;
|
|
105
104
|
author: SceneNode;
|
|
106
105
|
}
|
|
107
106
|
/** A note's body and author, in the order Figma generates them. */
|
|
108
|
-
declare function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null;
|
|
107
|
+
export declare function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null;
|
|
109
108
|
/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */
|
|
110
|
-
declare const STICKY_KIND: GeneratedFrameKind;
|
|
111
|
-
interface StickyContent {
|
|
109
|
+
export declare const STICKY_KIND: GeneratedFrameKind;
|
|
110
|
+
export interface StickyContent {
|
|
112
111
|
text?: string;
|
|
113
112
|
author?: string;
|
|
114
113
|
authorVisible?: boolean;
|
|
@@ -117,12 +116,10 @@ interface StickyContent {
|
|
|
117
116
|
scale?: number;
|
|
118
117
|
}
|
|
119
118
|
/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */
|
|
120
|
-
declare function buildStickySublayers(graph: SceneGraph, sticky: SceneNode, content?: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'>, overrides?: {
|
|
119
|
+
export declare function buildStickySublayers(graph: SceneGraph, sticky: SceneNode, content?: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'>, overrides?: {
|
|
121
120
|
body?: Partial<SceneNode>;
|
|
122
121
|
author?: Partial<SceneNode>;
|
|
123
122
|
}): StickySublayers;
|
|
124
123
|
/** A new note with its sublayers; the caller lays it out to grow it to its text. */
|
|
125
|
-
declare function createSticky(graph: SceneGraph, parentId: string, content?: StickyContent, props?: Partial<SceneNode>): SceneNode;
|
|
126
|
-
//#endregion
|
|
127
|
-
export { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth };
|
|
124
|
+
export declare function createSticky(graph: SceneGraph, parentId: string, content?: StickyContent, props?: Partial<SceneNode>): SceneNode;
|
|
128
125
|
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky.d.ts","names":[],"sources":["../../src/generated/sticky.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sticky.d.ts","names":[],"sources":["../../src/generated/sticky.ts"],"mappings":";;;;;;;;;qBAYa;qBACA;qBAIA;qBACA;qBACA;qBACA;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAaA,sBAAsB;;wBAoBnB,iBAAiB;;;;;;wBASjB,kBAAkB,iBAAY,QAAQ;YAmB1C;;qBAGC;;;;;wBAMG,iBACd,MAAM,gBACN,gBACA,oBACC,QAAQ;;wBAiBK,YAAY,QAAQ,KAAK;;wBAKzB,YAAY,eAAe;;wBAK3B,aAAa,OAAO,YAAY,QAAQ;iBAKvC;EACf,MAAM;EACN,QAAQ;;;wBAIM,gBAAgB,OAAO,YAAY,QAAQ,YAAY;;qBAS1D,aAAa;iBAST;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA;;;wBAIc,qBACd,OAAO,YACP,QAAQ,WACR,UAAS,KAAK,+DACd;EAAa,OAAO,QAAQ;EAAY,SAAS,QAAQ;IACxD;;wBA0Ba,aACd,OAAO,YACP,kBACA,UAAS,eACT,QAAO,QAAQ,aACd"}
|
package/dist/generated/sticky.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BLACK } from "../constants.js";
|
|
2
2
|
import { lineHeightPixels, percentLength, pixelLength } from "../text/lengths.js";
|
|
3
|
-
|
|
3
|
+
// src/generated/sticky.ts
|
|
4
4
|
/**
|
|
5
5
|
* A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with
|
|
6
6
|
* the author pinned to the bottom. Every length scales with the note, which `rescale` changes;
|
|
@@ -43,7 +43,7 @@ const STICKY_COLORS = {
|
|
|
43
43
|
yellow: {
|
|
44
44
|
r: 1,
|
|
45
45
|
g: 226 / 255,
|
|
46
|
-
b:
|
|
46
|
+
b: .6,
|
|
47
47
|
a: 1
|
|
48
48
|
},
|
|
49
49
|
green: {
|
|
@@ -185,7 +185,8 @@ const STICKY_KIND = {
|
|
|
185
185
|
text: (graph, frame) => stickySublayers(graph, frame)?.body,
|
|
186
186
|
rotates: false,
|
|
187
187
|
resizes: false,
|
|
188
|
-
namedByText: true
|
|
188
|
+
namedByText: true,
|
|
189
|
+
textSelection: "all"
|
|
189
190
|
};
|
|
190
191
|
/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */
|
|
191
192
|
function buildStickySublayers(graph, sticky, content = {}, overrides = {}) {
|
|
@@ -227,7 +228,6 @@ function createSticky(graph, parentId, content = {}, props = {}) {
|
|
|
227
228
|
buildStickySublayers(graph, sticky, content);
|
|
228
229
|
return sticky;
|
|
229
230
|
}
|
|
230
|
-
//#endregion
|
|
231
231
|
export { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth };
|
|
232
232
|
|
|
233
233
|
//# sourceMappingURL=sticky.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky.js","names":[],"sources":["../../src/generated/sticky.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport type { SceneGraph } from '../graph'\nimport type { Color } from '../primitives'\nimport { lineHeightPixels, percentLength, pixelLength } from '../text/lengths'\nimport type { Effect, Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/**\n * A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with\n * the author pinned to the bottom. Every length scales with the note, which `rescale` changes;\n * the values here are those of a note at scale 1, measured in Figma.\n */\nexport const STICKY_SIZE = 240\nexport const STICKY_WIDE_WIDTH = 416\nconst STICKY_PADDING = 20\nconst STICKY_GAP = 16\n\nexport const STICKY_FONT_FAMILY = 'Inter'\nexport const STICKY_FONT_WEIGHT = 500\nexport const STICKY_BODY_FONT_SIZE = 16\nexport const STICKY_AUTHOR_FONT_SIZE = 12\n\n/** FigJam's sticky palette, in its picker's order. */\nexport const STICKY_COLORS = {\n white: { r: 1, g: 1, b: 1, a: 1 },\n gray: { r: 230 / 255, g: 230 / 255, b: 230 / 255, a: 1 },\n red: { r: 1, g: 175 / 255, b: 163 / 255, a: 1 },\n orange: { r: 1, g: 211 / 255, b: 168 / 255, a: 1 },\n yellow: { r: 1, g: 226 / 255, b: 153 / 255, a: 1 },\n green: { r: 179 / 255, g: 239 / 255, b: 189 / 255, a: 1 },\n teal: { r: 179 / 255, g: 244 / 255, b: 239 / 255, a: 1 },\n blue: { r: 168 / 255, g: 218 / 255, b: 1, a: 1 },\n violet: { r: 211 / 255, g: 189 / 255, b: 1, a: 1 },\n pink: { r: 1, g: 168 / 255, b: 219 / 255, a: 1 }\n} as const satisfies Record<string, Color>\n\nexport const DEFAULT_STICKY_COLOR: Color = STICKY_COLORS.blue\n\nfunction solid(color: Color, opacity = 1): Fill {\n return { type: 'SOLID', color: { ...color }, opacity, visible: true }\n}\n\nfunction dropShadow(y: number, radius: number, alpha: number): Effect {\n return {\n type: 'DROP_SHADOW',\n color: { ...BLACK, a: alpha },\n offset: { x: 0, y },\n radius,\n spread: 0,\n visible: true,\n blendMode: 'NORMAL',\n showShadowBehindNode: true\n }\n}\n\n/** The three soft shadows Figma gives every sticky. */\nexport function stickyShadows(): Effect[] {\n return [dropShadow(2.5, 2, 0.02), dropShadow(3, 5, 0.04), dropShadow(8, 10, 0.08)]\n}\n\n/**\n * The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,\n * spreading them apart so the author sits at the bottom. A generated frame keeps its gap with\n * space between, which keeps the author clear of a long body.\n */\nexport function stickyFrameFields(scale = 1): Partial<SceneNode> {\n const padding = STICKY_PADDING * scale\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'SPACE_BETWEEN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n itemSpacing: STICKY_GAP * scale,\n paddingTop: padding,\n paddingRight: padding,\n paddingBottom: padding,\n paddingLeft: padding,\n minHeight: STICKY_SIZE * scale,\n cornerRadius: 0,\n clipsContent: false\n }\n}\n\nexport type StickyTextRole = 'body' | 'author'\n\n/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */\nexport const STICKY_SUBLAYER_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/** A sublayer's text style; the body follows the size preset, the author only the scale. */\nexport function stickyTextFields(\n role: StickyTextRole,\n scale = 1,\n fontSize = role === 'body' ? STICKY_BODY_FONT_SIZE * scale : STICKY_AUTHOR_FONT_SIZE * scale\n): Partial<SceneNode> {\n return {\n name: role === 'body' ? 'Text' : 'Author',\n fontFamily: STICKY_FONT_FAMILY,\n fontWeight: STICKY_FONT_WEIGHT,\n fontSize,\n // As Figma writes a note: the body at 150% and the author at 16 px a scale, tracked -1.1%.\n lineHeight: role === 'body' ? percentLength(150) : pixelLength(16 * scale),\n letterSpacing: percentLength(-1.1),\n textAlignHorizontal: 'LEFT',\n textAlignVertical: 'TOP',\n ...STICKY_SUBLAYER_LAYOUT,\n fills: [solid(BLACK, role === 'body' ? 0.8 : 128 / 255)]\n }\n}\n\n/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */\nexport function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number {\n return author ? author.fontSize / STICKY_AUTHOR_FONT_SIZE : 1\n}\n\n/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */\nexport function stickyWidth(scale: number, wide: boolean): number {\n return (wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale\n}\n\n/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */\nexport function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean {\n const scale = stickyScale(stickySublayers(graph, sticky)?.author)\n return sticky.width > ((STICKY_SIZE + STICKY_WIDE_WIDTH) / 2) * scale\n}\n\nexport interface StickySublayers {\n body: SceneNode\n author: SceneNode\n}\n\n/** A note's body and author, in the order Figma generates them. */\nexport function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null {\n const children = graph.getChildren(sticky.id)\n if (children.length !== 2) return null\n const [body, author] = children\n if (body.type !== 'TEXT' || author.type !== 'TEXT') return null\n return { body, author }\n}\n\n/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */\nexport const STICKY_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => stickySublayers(graph, frame) !== null,\n text: (graph, frame) => stickySublayers(graph, frame)?.body,\n rotates: false,\n resizes: false,\n namedByText: true\n}\n\nexport interface StickyContent {\n text?: string\n author?: string\n authorVisible?: boolean\n color?: Color\n wide?: boolean\n scale?: number\n}\n\n/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */\nexport function buildStickySublayers(\n graph: SceneGraph,\n sticky: SceneNode,\n content: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'> = {},\n overrides: { body?: Partial<SceneNode>; author?: Partial<SceneNode> } = {}\n): StickySublayers {\n const scale = content.scale ?? 1\n const inner = sticky.width - 2 * STICKY_PADDING * scale\n // One line tall until text is measured, so a note laid out without fonts keeps Figma's square.\n const bodyFields = stickyTextFields('body', scale)\n const authorFields = stickyTextFields('author', scale)\n const body = graph.createNode('TEXT', sticky.id, {\n ...bodyFields,\n width: inner,\n height: lineHeightPixels(bodyFields.lineHeight ?? null, bodyFields.fontSize ?? 0) ?? undefined,\n text: content.text ?? '',\n ...overrides.body\n })\n const author = graph.createNode('TEXT', sticky.id, {\n ...authorFields,\n width: inner,\n height:\n lineHeightPixels(authorFields.lineHeight ?? null, authorFields.fontSize ?? 0) ?? undefined,\n text: content.author ?? '',\n visible: content.authorVisible ?? true,\n ...overrides.author\n })\n return { body, author }\n}\n\n/** A new note with its sublayers; the caller lays it out to grow it to its text. */\nexport function createSticky(\n graph: SceneGraph,\n parentId: string,\n content: StickyContent = {},\n props: Partial<SceneNode> = {}\n): SceneNode {\n const scale = content.scale ?? 1\n const size = STICKY_SIZE * scale\n const sticky = graph.createNode('STICKY', parentId, {\n name: 'Sticky',\n width: (content.wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale,\n height: size,\n fills: [solid(content.color ?? DEFAULT_STICKY_COLOR)],\n effects: stickyShadows(),\n ...stickyFrameFields(scale),\n ...props\n })\n buildStickySublayers(graph, sticky, content)\n return sticky\n}\n"],"mappings":";;;;;;;;AAYA,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAM,iBAAiB;AACvB,MAAM,aAAa;AAEnB,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;;AAGvC,MAAa,gBAAgB;CAC3B,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,MAAM;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAA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,CAAC,EAAE;CACvD,SAAS;CACT,SAAS;CACT,aAAa;AACf;;AAYA,SAAgB,qBACd,OACA,QACA,UAA8E,CAAC,GAC/E,YAAwE,CAAC,GACxD;CACjB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,QAAQ,OAAO,QAAQ,KAAqB;CAElD,MAAM,aAAa,iBAAiB,QAAQ,KAAK;CACjD,MAAM,eAAe,iBAAiB,UAAU,KAAK;CAiBrD,OAAO;EAAE,MAhBI,MAAM,WAAW,QAAQ,OAAO,IAAI;GAC/C,GAAG;GACH,OAAO;GACP,QAAQ,iBAAiB,WAAW,cAAc,MAAM,WAAW,YAAY,CAAC,KAAK,KAAA;GACrF,MAAM,QAAQ,QAAQ;GACtB,GAAG,UAAU;EACf,CAUY;EAAG,QATA,MAAM,WAAW,QAAQ,OAAO,IAAI;GACjD,GAAG;GACH,OAAO;GACP,QACE,iBAAiB,aAAa,cAAc,MAAM,aAAa,YAAY,CAAC,KAAK,KAAA;GACnF,MAAM,QAAQ,UAAU;GACxB,SAAS,QAAQ,iBAAiB;GAClC,GAAG,UAAU;EACf,CACoB;CAAE;AACxB;;AAGA,SAAgB,aACd,OACA,UACA,UAAyB,CAAC,GAC1B,QAA4B,CAAC,GAClB;CACX,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,OAAA,MAAqB;CAC3B,MAAM,SAAS,MAAM,WAAW,UAAU,UAAU;EAClD,MAAM;EACN,QAAQ,QAAQ,OAAA,MAAA,OAA0C;EAC1D,QAAQ;EACR,OAAO,CAAC,MAAM,QAAQ,SAAS,oBAAoB,CAAC;EACpD,SAAS,cAAc;EACvB,GAAG,kBAAkB,KAAK;EAC1B,GAAG;CACL,CAAC;CACD,qBAAqB,OAAO,QAAQ,OAAO;CAC3C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"sticky.js","names":[],"sources":["../../src/generated/sticky.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport type { SceneGraph } from '../graph'\nimport type { Color } from '../primitives'\nimport { lineHeightPixels, percentLength, pixelLength } from '../text/lengths'\nimport type { Effect, Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/**\n * A FigJam sticky note as Figma lays it out: a fixed-width card that grows to fit its body, with\n * the author pinned to the bottom. Every length scales with the note, which `rescale` changes;\n * the values here are those of a note at scale 1, measured in Figma.\n */\nexport const STICKY_SIZE = 240\nexport const STICKY_WIDE_WIDTH = 416\nconst STICKY_PADDING = 20\nconst STICKY_GAP = 16\n\nexport const STICKY_FONT_FAMILY = 'Inter'\nexport const STICKY_FONT_WEIGHT = 500\nexport const STICKY_BODY_FONT_SIZE = 16\nexport const STICKY_AUTHOR_FONT_SIZE = 12\n\n/** FigJam's sticky palette, in its picker's order. */\nexport const STICKY_COLORS = {\n white: { r: 1, g: 1, b: 1, a: 1 },\n gray: { r: 230 / 255, g: 230 / 255, b: 230 / 255, a: 1 },\n red: { r: 1, g: 175 / 255, b: 163 / 255, a: 1 },\n orange: { r: 1, g: 211 / 255, b: 168 / 255, a: 1 },\n yellow: { r: 1, g: 226 / 255, b: 153 / 255, a: 1 },\n green: { r: 179 / 255, g: 239 / 255, b: 189 / 255, a: 1 },\n teal: { r: 179 / 255, g: 244 / 255, b: 239 / 255, a: 1 },\n blue: { r: 168 / 255, g: 218 / 255, b: 1, a: 1 },\n violet: { r: 211 / 255, g: 189 / 255, b: 1, a: 1 },\n pink: { r: 1, g: 168 / 255, b: 219 / 255, a: 1 }\n} as const satisfies Record<string, Color>\n\nexport const DEFAULT_STICKY_COLOR: Color = STICKY_COLORS.blue\n\nfunction solid(color: Color, opacity = 1): Fill {\n return { type: 'SOLID', color: { ...color }, opacity, visible: true }\n}\n\nfunction dropShadow(y: number, radius: number, alpha: number): Effect {\n return {\n type: 'DROP_SHADOW',\n color: { ...BLACK, a: alpha },\n offset: { x: 0, y },\n radius,\n spread: 0,\n visible: true,\n blendMode: 'NORMAL',\n showShadowBehindNode: true\n }\n}\n\n/** The three soft shadows Figma gives every sticky. */\nexport function stickyShadows(): Effect[] {\n return [dropShadow(2.5, 2, 0.02), dropShadow(3, 5, 0.04), dropShadow(8, 10, 0.08)]\n}\n\n/**\n * The note's own fields: a vertical auto layout that hugs its sublayers above a minimum height,\n * spreading them apart so the author sits at the bottom. A generated frame keeps its gap with\n * space between, which keeps the author clear of a long body.\n */\nexport function stickyFrameFields(scale = 1): Partial<SceneNode> {\n const padding = STICKY_PADDING * scale\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'SPACE_BETWEEN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'FIXED',\n itemSpacing: STICKY_GAP * scale,\n paddingTop: padding,\n paddingRight: padding,\n paddingBottom: padding,\n paddingLeft: padding,\n minHeight: STICKY_SIZE * scale,\n cornerRadius: 0,\n clipsContent: false\n }\n}\n\nexport type StickyTextRole = 'body' | 'author'\n\n/** How a sublayer sits in the note: as wide as the padding allows, as tall as its text. */\nexport const STICKY_SUBLAYER_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/** A sublayer's text style; the body follows the size preset, the author only the scale. */\nexport function stickyTextFields(\n role: StickyTextRole,\n scale = 1,\n fontSize = role === 'body' ? STICKY_BODY_FONT_SIZE * scale : STICKY_AUTHOR_FONT_SIZE * scale\n): Partial<SceneNode> {\n return {\n name: role === 'body' ? 'Text' : 'Author',\n fontFamily: STICKY_FONT_FAMILY,\n fontWeight: STICKY_FONT_WEIGHT,\n fontSize,\n // As Figma writes a note: the body at 150% and the author at 16 px a scale, tracked -1.1%.\n lineHeight: role === 'body' ? percentLength(150) : pixelLength(16 * scale),\n letterSpacing: percentLength(-1.1),\n textAlignHorizontal: 'LEFT',\n textAlignVertical: 'TOP',\n ...STICKY_SUBLAYER_LAYOUT,\n fills: [solid(BLACK, role === 'body' ? 0.8 : 128 / 255)]\n }\n}\n\n/** The scale a note was drawn at, read from its author line, whose size only the scale sets. */\nexport function stickyScale(author: Pick<SceneNode, 'fontSize'> | undefined): number {\n return author ? author.fontSize / STICKY_AUTHOR_FONT_SIZE : 1\n}\n\n/** A note's width at a scale, square or wide, as FigJam's side handles switch between them. */\nexport function stickyWidth(scale: number, wide: boolean): number {\n return (wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale\n}\n\n/** Whether a note is wide: nearer FigJam's wide width than its square one at its scale. */\nexport function isWideSticky(graph: SceneGraph, sticky: SceneNode): boolean {\n const scale = stickyScale(stickySublayers(graph, sticky)?.author)\n return sticky.width > ((STICKY_SIZE + STICKY_WIDE_WIDTH) / 2) * scale\n}\n\nexport interface StickySublayers {\n body: SceneNode\n author: SceneNode\n}\n\n/** A note's body and author, in the order Figma generates them. */\nexport function stickySublayers(graph: SceneGraph, sticky: SceneNode): StickySublayers | null {\n const children = graph.getChildren(sticky.id)\n if (children.length !== 2) return null\n const [body, author] = children\n if (body.type !== 'TEXT' || author.type !== 'TEXT') return null\n return { body, author }\n}\n\n/** A sticky note scales as a whole from its own handles and stays upright, as in FigJam. */\nexport const STICKY_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => stickySublayers(graph, frame) !== null,\n text: (graph, frame) => stickySublayers(graph, frame)?.body,\n rotates: false,\n resizes: false,\n namedByText: true,\n textSelection: 'all'\n}\n\nexport interface StickyContent {\n text?: string\n author?: string\n authorVisible?: boolean\n color?: Color\n wide?: boolean\n scale?: number\n}\n\n/** Adds a note's sublayers to a STICKY the caller created, styled as Figma generates them. */\nexport function buildStickySublayers(\n graph: SceneGraph,\n sticky: SceneNode,\n content: Pick<StickyContent, 'text' | 'author' | 'authorVisible' | 'scale'> = {},\n overrides: { body?: Partial<SceneNode>; author?: Partial<SceneNode> } = {}\n): StickySublayers {\n const scale = content.scale ?? 1\n const inner = sticky.width - 2 * STICKY_PADDING * scale\n // One line tall until text is measured, so a note laid out without fonts keeps Figma's square.\n const bodyFields = stickyTextFields('body', scale)\n const authorFields = stickyTextFields('author', scale)\n const body = graph.createNode('TEXT', sticky.id, {\n ...bodyFields,\n width: inner,\n height: lineHeightPixels(bodyFields.lineHeight ?? null, bodyFields.fontSize ?? 0) ?? undefined,\n text: content.text ?? '',\n ...overrides.body\n })\n const author = graph.createNode('TEXT', sticky.id, {\n ...authorFields,\n width: inner,\n height:\n lineHeightPixels(authorFields.lineHeight ?? null, authorFields.fontSize ?? 0) ?? undefined,\n text: content.author ?? '',\n visible: content.authorVisible ?? true,\n ...overrides.author\n })\n return { body, author }\n}\n\n/** A new note with its sublayers; the caller lays it out to grow it to its text. */\nexport function createSticky(\n graph: SceneGraph,\n parentId: string,\n content: StickyContent = {},\n props: Partial<SceneNode> = {}\n): SceneNode {\n const scale = content.scale ?? 1\n const size = STICKY_SIZE * scale\n const sticky = graph.createNode('STICKY', parentId, {\n name: 'Sticky',\n width: (content.wide ? STICKY_WIDE_WIDTH : STICKY_SIZE) * scale,\n height: size,\n fills: [solid(content.color ?? DEFAULT_STICKY_COLOR)],\n effects: stickyShadows(),\n ...stickyFrameFields(scale),\n ...props\n })\n buildStickySublayers(graph, sticky, content)\n return sticky\n}\n"],"mappings":";;;;;;;;AAYA,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAM,iBAAiB;AACvB,MAAM,aAAa;AAEnB,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;;AAGvC,MAAa,gBAAgB;CAC3B,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,MAAM;EAAE,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACvD,KAAK;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CAC9C,QAAQ;EAAE,GAAG;EAAG,GAAG,MAAM;EAAK,GAAG,MAAM;EAAK,GAAG;CAAE;CACjD,QAAQ;EA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