@open-pencil/scene-graph 0.18.0-beta.1 → 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 +4 -3
- package/dist/behaviours/index.js +6 -5
- package/dist/behaviours/kinds.d.ts +38 -15
- package/dist/behaviours/kinds.d.ts.map +1 -1
- package/dist/behaviours/kinds.js +119 -4
- 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 +16 -18
- package/dist/behaviours/schema.d.ts.map +1 -1
- package/dist/behaviours/schema.js +2 -3
- package/dist/behaviours/spec.d.ts +3 -6
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +4 -5
- package/dist/behaviours/transition.d.ts +6 -9
- package/dist/behaviours/transition.d.ts.map +1 -1
- package/dist/behaviours/transition.js +1 -2
- 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 +2 -3
- 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 +13 -15
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +3 -4
- package/dist/color/management.d.ts +11 -14
- package/dist/color/management.d.ts.map +1 -1
- package/dist/color/management.js +2 -3
- 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 +16 -19
- package/dist/color/okhcl.d.ts.map +1 -1
- package/dist/color/okhcl.js +3 -4
- package/dist/color/schema.d.ts +4 -7
- package/dist/color/schema.d.ts.map +1 -1
- package/dist/color/schema.js +2 -3
- 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 +1 -2
- 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 +31 -25
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +13 -5
- package/dist/copy.js.map +1 -1
- package/dist/corners.d.ts +8 -10
- package/dist/corners.d.ts.map +1 -1
- package/dist/corners.js +1 -2
- 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 +4 -5
- package/dist/css/index.js +2 -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 +2 -5
- package/dist/css/motion.d.ts.map +1 -1
- package/dist/css/motion.js +2 -3
- package/dist/css/shadows.d.ts +1 -4
- package/dist/css/shadows.d.ts.map +1 -1
- package/dist/css/shadows.js +3 -4
- 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 +9 -12
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +2 -3
- 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.js +1 -1
- package/dist/fields/layout.d.ts +4 -7
- package/dist/fields/layout.d.ts.map +1 -1
- package/dist/fields/layout.js +1 -2
- 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 +5 -5
- package/dist/font-style.js.map +1 -1
- package/dist/generated/index.d.ts +32 -16
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +37 -9
- 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 +43 -69
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +44 -76
- 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 +4 -7
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +26 -19
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +10 -12
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +5 -6
- 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 +51 -31
- 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 +3 -4
- 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 +9 -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 +69 -12
- 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 +27 -14
- 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 +3 -6
- package/dist/layout/flow.d.ts.map +1 -1
- package/dist/layout/flow.js +6 -5
- package/dist/layout/flow.js.map +1 -1
- 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 +3 -2
- package/dist/layout/index.js +6 -5
- package/dist/layout/keywords.d.ts +7 -9
- package/dist/layout/keywords.d.ts.map +1 -1
- package/dist/layout/keywords.js +1 -2
- 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 +11 -13
- package/dist/layout/sizing.d.ts.map +1 -1
- package/dist/layout/sizing.js +1 -2
- package/dist/layout/spacing.d.ts +2 -5
- package/dist/layout/spacing.d.ts.map +1 -1
- package/dist/layout/spacing.js +1 -2
- 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 +21 -24
- package/dist/mesh/geometry.d.ts.map +1 -1
- package/dist/mesh/geometry.js +3 -14
- package/dist/mesh/geometry.js.map +1 -1
- package/dist/mesh/index.d.ts +1 -1
- package/dist/mesh/index.js +1 -1
- package/dist/mesh/model.d.ts +5 -8
- package/dist/mesh/model.d.ts.map +1 -1
- package/dist/mesh/model.js +2 -3
- package/dist/mesh/schema.d.ts +10 -13
- package/dist/mesh/schema.d.ts.map +1 -1
- package/dist/mesh/schema.js +3 -4
- 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 +7 -10
- package/dist/mutation-impact.d.ts.map +1 -1
- package/dist/mutation-impact.js +2 -3
- package/dist/node-defaults.d.ts +14 -15
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +133 -51
- 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 +2 -2
- package/dist/paints/index.js +4 -4
- package/dist/paints/pattern.d.ts +6 -9
- package/dist/paints/pattern.d.ts.map +1 -1
- package/dist/paints/pattern.js +1 -2
- 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 +3 -6
- package/dist/paints/shows.d.ts.map +1 -1
- package/dist/paints/shows.js +1 -2
- package/dist/paints/solid.d.ts +1 -4
- package/dist/paints/solid.d.ts.map +1 -1
- package/dist/paints/solid.js +1 -2
- package/dist/paints/stills.d.ts +17 -17
- package/dist/paints/stills.d.ts.map +1 -1
- package/dist/paints/stills.js +22 -18
- package/dist/paints/stills.js.map +1 -1
- 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 +1 -2
- package/dist/plugin-data/fields.d.ts +37 -11
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +35 -10
- 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 +13 -15
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +5 -6
- package/dist/scaling/node.d.ts +2 -5
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +4 -5
- 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 -2
- package/dist/shaders/index.js +2 -2
- package/dist/shaders/model.d.ts +54 -13
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +98 -7
- package/dist/shaders/model.js.map +1 -1
- package/dist/shaders/schema.d.ts +15 -8
- package/dist/shaders/schema.d.ts.map +1 -1
- package/dist/shaders/schema.js +11 -2
- package/dist/shaders/schema.js.map +1 -1
- package/dist/shape-with-text/document.js +9 -21
- package/dist/shape-with-text/document.js.map +1 -1
- 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 +7 -10
- package/dist/shape-with-text/geometry.d.ts.map +1 -1
- package/dist/shape-with-text/geometry.js +4 -7
- package/dist/shape-with-text/geometry.js.map +1 -1
- package/dist/shape-with-text/index.js +1 -1
- 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 +2 -4
- package/dist/shared-style-index.d.ts.map +1 -1
- package/dist/shared-style-index.js +1 -2
- package/dist/shared-style-index.js.map +1 -1
- package/dist/shared-styles.d.ts +17 -19
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +5 -6
- package/dist/slides/drop.d.ts +5 -8
- package/dist/slides/drop.d.ts.map +1 -1
- package/dist/slides/drop.js +1 -2
- package/dist/slides/index.d.ts +19 -19
- package/dist/slides/index.d.ts.map +1 -1
- package/dist/slides/index.js +8 -5
- package/dist/slides/index.js.map +1 -1
- package/dist/slides/motion.d.ts +32 -16
- package/dist/slides/motion.d.ts.map +1 -1
- package/dist/slides/motion.js +30 -5
- package/dist/slides/motion.js.map +1 -1
- package/dist/slides/playback.d.ts +24 -21
- package/dist/slides/playback.d.ts.map +1 -1
- package/dist/slides/playback.js +45 -13
- package/dist/slides/playback.js.map +1 -1
- package/dist/slides/types.d.ts +8 -11
- package/dist/slides/types.d.ts.map +1 -1
- package/dist/slides/types.js +1 -2
- 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 +1 -2
- 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 +5 -8
- package/dist/text/direction.d.ts.map +1 -1
- package/dist/text/direction.js +1 -2
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +5 -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 +4 -7
- package/dist/text/name.d.ts.map +1 -1
- package/dist/text/name.js +1 -2
- 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 +1 -2
- 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 +4 -7
- package/dist/thumbnail.d.ts.map +1 -1
- package/dist/thumbnail.js +1 -2
- package/dist/transfer/apply.d.ts +2 -5
- package/dist/transfer/apply.d.ts.map +1 -1
- package/dist/transfer/apply.js +2 -3
- package/dist/transfer/copied.d.ts +5 -8
- package/dist/transfer/copied.d.ts.map +1 -1
- package/dist/transfer/copied.js +3 -4
- package/dist/transfer/dependencies.d.ts +6 -9
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +13 -11
- 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 +1 -2
- package/dist/transfer/identity.js +1 -2
- package/dist/transfer/index.d.ts +3 -3
- package/dist/transfer/index.js +6 -6
- package/dist/transfer/library.d.ts +5 -7
- package/dist/transfer/library.d.ts.map +1 -1
- package/dist/transfer/library.js +32 -12
- package/dist/transfer/library.js.map +1 -1
- package/dist/transfer/nodes.d.ts +2 -5
- package/dist/transfer/nodes.d.ts.map +1 -1
- package/dist/transfer/nodes.js +8 -6
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/transfer/plan.d.ts +2 -5
- package/dist/transfer/plan.d.ts.map +1 -1
- package/dist/transfer/plan.js +2 -3
- 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 +2 -3
- 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 +1 -2
- package/dist/transfer/variables.d.ts +3 -6
- package/dist/transfer/variables.d.ts.map +1 -1
- package/dist/transfer/variables.js +2 -3
- package/dist/types.d.ts +191 -142
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +15 -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 +24 -25
- package/dist/variables/bindings.d.ts.map +1 -1
- package/dist/variables/bindings.js +28 -23
- 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 +24 -19
- package/dist/variables/easing.d.ts.map +1 -1
- package/dist/variables/easing.js +17 -17
- package/dist/variables/easing.js.map +1 -1
- 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 +6 -8
- package/dist/variables/formula/index.d.ts.map +1 -1
- package/dist/variables/formula/index.js +4 -5
- 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 +5 -6
- package/dist/variables/formula/signatures.d.ts +3 -6
- package/dist/variables/formula/signatures.d.ts.map +1 -1
- package/dist/variables/formula/signatures.js +1 -2
- 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 +6 -9
- 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 +30 -32
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +17 -18
- package/dist/variables/lookup.d.ts +11 -7
- package/dist/variables/lookup.d.ts.map +1 -1
- package/dist/variables/lookup.js +24 -3
- package/dist/variables/lookup.js.map +1 -1
- package/dist/variables/motion.d.ts +9 -12
- package/dist/variables/motion.d.ts.map +1 -1
- package/dist/variables/motion.js +3 -4
- package/dist/variables/paints.d.ts +18 -20
- package/dist/variables/paints.d.ts.map +1 -1
- package/dist/variables/paints.js +4 -5
- package/dist/variables/resolution.d.ts +22 -19
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +13 -5
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/schema.d.ts +9 -12
- package/dist/variables/schema.d.ts.map +1 -1
- package/dist/variables/schema.js +3 -4
- package/dist/variables/style-bindings.d.ts +11 -13
- package/dist/variables/style-bindings.d.ts.map +1 -1
- package/dist/variables/style-bindings.js +2 -3
- 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 +23 -5
- package/src/behaviours/index.ts +1 -0
- package/src/behaviours/kinds.ts +103 -1
- package/src/behaviours/listing.ts +142 -0
- package/src/behaviours/model.ts +21 -0
- package/src/blur.ts +88 -0
- package/src/clipping.ts +3 -4
- package/src/comments/threads.ts +8 -1
- package/src/connectors/layout.ts +10 -3
- package/src/connectors/sublayers.ts +2 -1
- package/src/coordinate.ts +17 -25
- package/src/copy.ts +15 -6
- package/src/cubic.ts +57 -1
- package/src/export-format.ts +11 -1
- package/src/font-style.ts +12 -4
- package/src/generated/index.ts +43 -6
- 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 +39 -88
- package/src/graph.ts +21 -6
- package/src/hit-test.ts +66 -26
- 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 +7 -3
- package/src/instances/index.ts +94 -5
- package/src/instances/lookup.ts +61 -0
- package/src/instances/sync.ts +15 -0
- package/src/layout/flow.ts +5 -3
- package/src/layout/index.ts +1 -0
- package/src/layout/stacking.ts +14 -0
- package/src/matrix.ts +11 -1
- package/src/mesh/geometry.ts +2 -13
- 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/node-defaults.ts +131 -49
- package/src/order-keys.ts +16 -2
- package/src/paints/stills.ts +16 -12
- package/src/parse-path.ts +15 -0
- package/src/plugin-data/fields.ts +40 -3
- package/src/polygon.ts +6 -4
- package/src/shaders/model.ts +124 -6
- package/src/shaders/schema.ts +12 -0
- package/src/shape-with-text/document.ts +7 -12
- package/src/shape-with-text/geometry.ts +1 -4
- package/src/slides/index.ts +8 -0
- package/src/slides/motion.ts +35 -1
- package/src/slides/playback.ts +51 -9
- 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/lists.ts +20 -7
- package/src/text/paragraphs.ts +10 -3
- package/src/transfer/dependencies.ts +17 -11
- package/src/transfer/library.ts +36 -12
- package/src/transfer/nodes.ts +8 -0
- package/src/types.ts +71 -8
- package/src/undo.ts +10 -1
- package/src/variables/bindings.ts +33 -16
- package/src/variables/easing.ts +16 -17
- package/src/variables/fields.ts +30 -3
- package/src/variables/lookup.ts +24 -1
- package/src/variables/resolution.ts +15 -1
- package/src/variables/units.ts +2 -3
package/dist/slides/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { SceneGraph } from "../graph.js";
|
|
2
|
-
import { LAYER_ANIMATION_STYLES, LayerAnimation, LayerAnimationStyle, SLIDE_TRANSITION_STYLES, SlideSettings, SlideTransition, SlideTransitionStyle, SlideTransitionTiming } from "./types.js";
|
|
3
2
|
import { SceneNode } from "../types.js";
|
|
3
|
+
import { LAYER_ANIMATION_STYLES, LayerAnimation, LayerAnimationStyle, SLIDE_TRANSITION_STYLES, SlideSettings, SlideTransition, SlideTransitionStyle, SlideTransitionTiming } from "./types.js";
|
|
4
4
|
import { SlideDrop, SlideDropLine, SlidePlacement, slideDropAt } from "./drop.js";
|
|
5
|
-
import { AnimatedLayer, BuildStep, ResolvedSlideTransition, animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, mapSlideVariables, resolveSlideTransition, slideBuild, slideVariableIds } from "./motion.js";
|
|
6
|
-
import { LAYER_SLIDE_DISTANCE, LayerFrame, MOTION_DIRECTIONS, MotionDirection, SLIDE_TRANSITION_KINDS, SlideFrame, SlideTransitionKind, TransitionFrames, layerAnimationDirection, layerAnimationStyle, layerAtRest,
|
|
7
|
-
//#region src/slides/index.d.ts
|
|
5
|
+
import { AnimatedLayer, BuildStep, ResolvedSlideTransition, TimedLayer, TimedStep, animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, mapSlideVariables, resolveSlideTransition, slideBuild, slideVariableIds, timedBuild } from "./motion.js";
|
|
6
|
+
import { LAYER_SLIDE_DISTANCE, LayerFrame, MOTION_DIRECTIONS, MotionDirection, SLIDE_TRANSITION_KINDS, SlideFrame, SlideTransitionKind, TransitionFrames, layerAnimationDirection, layerAnimationStyle, layerAnimationTracks, layerAtRest, layerFrameAt, transitionDirection, transitionFrames, transitionKind, transitionStyle } from "./playback.js";
|
|
8
7
|
/** Figma's slide: 1920 by 1080, with 240 between slides and 600 between the rows of a grid. */
|
|
9
|
-
declare const DEFAULT_SLIDE_SIZE: {
|
|
8
|
+
export declare const DEFAULT_SLIDE_SIZE: {
|
|
10
9
|
readonly width: 1920;
|
|
11
10
|
readonly height: 1080;
|
|
12
11
|
};
|
|
13
12
|
/** The sizes a deck offers its slides, by shape; any other size is a custom one. */
|
|
14
|
-
declare const SLIDE_SIZE_PRESETS: readonly [{
|
|
13
|
+
export declare const SLIDE_SIZE_PRESETS: readonly [{
|
|
15
14
|
readonly id: "wide";
|
|
16
15
|
readonly width: 1920;
|
|
17
16
|
readonly height: 1080;
|
|
@@ -28,29 +27,30 @@ declare const SLIDE_SIZE_PRESETS: readonly [{
|
|
|
28
27
|
readonly width: 1080;
|
|
29
28
|
readonly height: 1920;
|
|
30
29
|
}];
|
|
31
|
-
type SlideSizePreset = (typeof SLIDE_SIZE_PRESETS)[number];
|
|
32
|
-
declare function defaultSlideSettings(): SlideSettings;
|
|
30
|
+
export type SlideSizePreset = (typeof SLIDE_SIZE_PRESETS)[number];
|
|
31
|
+
export declare function defaultSlideSettings(): SlideSettings;
|
|
33
32
|
/** What a slide keeps, whether or not it was ever set; null for any other layer. */
|
|
34
|
-
declare function slideSettings(node: Pick<SceneNode, 'type' | 'slide'>): SlideSettings | null;
|
|
33
|
+
export declare function slideSettings(node: Pick<SceneNode, 'type' | 'slide'>): SlideSettings | null;
|
|
35
34
|
/** The grid that holds a deck's slides on a page, if the page has one. */
|
|
36
|
-
declare function slideGrid(graph: SceneGraph, pageId: string): SceneNode | undefined;
|
|
35
|
+
export declare function slideGrid(graph: SceneGraph, pageId: string): SceneNode | undefined;
|
|
37
36
|
/** A page's slides by row, in the order a deck presents them. */
|
|
38
|
-
declare function slideRows(graph: SceneGraph, pageId: string): SceneNode[][];
|
|
37
|
+
export declare function slideRows(graph: SceneGraph, pageId: string): SceneNode[][];
|
|
39
38
|
/** The slide the deck moves on to from `slide`, passing by skipped slides, or undefined at the end. */
|
|
40
|
-
declare function nextSlide(graph: SceneGraph, slide: SceneNode): SceneNode | undefined;
|
|
39
|
+
export declare function nextSlide(graph: SceneGraph, slide: SceneNode): SceneNode | undefined;
|
|
41
40
|
/**
|
|
42
41
|
* Each slide's number, by ID, in the order a deck presents them: skipped slides have none and are
|
|
43
42
|
* not counted, as in Figma.
|
|
44
43
|
*/
|
|
45
|
-
declare function slideNumbers(graph: SceneGraph, pageId: string): Map<string, number | null>;
|
|
44
|
+
export declare function slideNumbers(graph: SceneGraph, pageId: string): Map<string, number | null>;
|
|
46
45
|
/** Names a page's slides by their numbers, and a skipped one `-`, as Figma does. */
|
|
47
|
-
declare function renumberSlides(graph: SceneGraph, pageId: string): void;
|
|
46
|
+
export declare function renumberSlides(graph: SceneGraph, pageId: string): void;
|
|
48
47
|
/** Adds the grid a deck's slides sit in to a page. */
|
|
49
|
-
declare function createSlideGrid(graph: SceneGraph, pageId: string): SceneNode;
|
|
48
|
+
export declare function createSlideGrid(graph: SceneGraph, pageId: string): SceneNode;
|
|
50
49
|
/** Adds a row, which Figma calls a section, to the end of a grid. */
|
|
51
|
-
declare function createSlideRow(graph: SceneGraph, gridId: string): SceneNode;
|
|
50
|
+
export declare function createSlideRow(graph: SceneGraph, gridId: string): SceneNode;
|
|
52
51
|
/** Adds an empty slide to the end of a row, at the size of the slide before it. */
|
|
53
|
-
declare function createSlide(graph: SceneGraph, rowId: string): SceneNode;
|
|
54
|
-
|
|
55
|
-
export
|
|
52
|
+
export declare function createSlide(graph: SceneGraph, rowId: string): SceneNode;
|
|
53
|
+
/** The slides a deck on `pageId` presents, in order: skipped ones are passed by. */
|
|
54
|
+
export declare function presentedSlides(graph: SceneGraph, pageId: string): string[];
|
|
55
|
+
export { AnimatedLayer, BuildStep, LAYER_ANIMATION_STYLES, LAYER_SLIDE_DISTANCE, LayerAnimation, LayerAnimationStyle, LayerFrame, MOTION_DIRECTIONS, MotionDirection, ResolvedSlideTransition, SLIDE_TRANSITION_KINDS, SLIDE_TRANSITION_STYLES, SlideDrop, SlideDropLine, SlideFrame, SlidePlacement, SlideSettings, SlideTransition, SlideTransitionKind, SlideTransitionStyle, SlideTransitionTiming, TimedLayer, TimedStep, TransitionFrames, animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, layerAnimationDirection, layerAnimationStyle, layerAnimationTracks, layerAtRest, layerFrameAt, mapSlideVariables, resolveSlideTransition, slideBuild, slideDropAt, slideVariableIds, timedBuild, transitionDirection, transitionFrames, transitionKind, transitionStyle };
|
|
56
56
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/slides/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/slides/index.ts"],"mappings":";;;;;;;qBAUa;;;;;qBAGA;;;;;;;;;;;;;;;;;YAMD,0BAA0B;wBAOtB,wBAAwB;;wBAKxB,cAAc,MAAM,KAAK,+BAA+B;;wBAKxD,UAAU,OAAO,YAAY,iBAAiB;;wBAK9C,UAAU,OAAO,YAAY,iBAAiB;;wBAU9C,UAAU,OAAO,YAAY,OAAO,YAAY;;;;;wBAehD,aAAa,OAAO,YAAY,iBAAiB;;wBAUjD,eAAe,OAAO,YAAY;;wBAQlC,gBAAgB,OAAO,YAAY,iBAAiB;;wBAcpD,eAAe,OAAO,YAAY,iBAAiB;;wBAenD,YAAY,OAAO,YAAY,gBAAgB;;wBAc/C,gBAAgB,OAAO,YAAY"}
|
package/dist/slides/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { slideDropAt } from "./drop.js";
|
|
2
|
-
import { animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, mapSlideVariables, resolveSlideTransition, slideBuild, slideVariableIds } from "./motion.js";
|
|
3
|
-
import { LAYER_SLIDE_DISTANCE, MOTION_DIRECTIONS, SLIDE_TRANSITION_KINDS, layerAnimationDirection, layerAnimationStyle, layerAtRest,
|
|
2
|
+
import { animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, mapSlideVariables, resolveSlideTransition, slideBuild, slideVariableIds, timedBuild } from "./motion.js";
|
|
3
|
+
import { LAYER_SLIDE_DISTANCE, MOTION_DIRECTIONS, SLIDE_TRANSITION_KINDS, layerAnimationDirection, layerAnimationStyle, layerAnimationTracks, layerAtRest, layerFrameAt, transitionDirection, transitionFrames, transitionKind, transitionStyle } from "./playback.js";
|
|
4
4
|
import { LAYER_ANIMATION_STYLES, SLIDE_TRANSITION_STYLES } from "./types.js";
|
|
5
|
-
|
|
5
|
+
// src/slides/index.ts
|
|
6
6
|
/** Figma's slide: 1920 by 1080, with 240 between slides and 600 between the rows of a grid. */
|
|
7
7
|
const DEFAULT_SLIDE_SIZE = {
|
|
8
8
|
width: 1920,
|
|
@@ -128,7 +128,10 @@ function createSlide(graph, rowId) {
|
|
|
128
128
|
slide: defaultSlideSettings()
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
/** The slides a deck on `pageId` presents, in order: skipped ones are passed by. */
|
|
132
|
+
function presentedSlides(graph, pageId) {
|
|
133
|
+
return slideRows(graph, pageId).flat().filter((slide) => !slideSettings(slide)?.skipped).map((slide) => slide.id);
|
|
134
|
+
}
|
|
135
|
+
export { DEFAULT_SLIDE_SIZE, LAYER_ANIMATION_STYLES, LAYER_SLIDE_DISTANCE, MOTION_DIRECTIONS, SLIDE_SIZE_PRESETS, SLIDE_TRANSITION_KINDS, SLIDE_TRANSITION_STYLES, animatedLayers, animationSlide, animationTarget, createSlide, createSlideGrid, createSlideRow, defaultLayerAnimation, defaultSlideSettings, defaultSlideTransition, layerAnimationDirection, layerAnimationStyle, layerAnimationTracks, layerAtRest, layerFrameAt, mapSlideVariables, nextSlide, presentedSlides, renumberSlides, resolveSlideTransition, slideBuild, slideDropAt, slideGrid, slideNumbers, slideRows, slideSettings, slideVariableIds, timedBuild, transitionDirection, transitionFrames, transitionKind, transitionStyle };
|
|
133
136
|
|
|
134
137
|
//# sourceMappingURL=index.js.map
|
package/dist/slides/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/slides/index.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { SceneNode } from '../types'\nimport type { SlideSettings } from './types'\n\nexport * from './drop'\nexport * from './motion'\nexport * from './playback'\nexport * from './types'\n\n/** Figma's slide: 1920 by 1080, with 240 between slides and 600 between the rows of a grid. */\nexport const DEFAULT_SLIDE_SIZE = { width: 1920, height: 1080 } as const\n\n/** The sizes a deck offers its slides, by shape; any other size is a custom one. */\nexport const SLIDE_SIZE_PRESETS = [\n { id: 'wide', width: 1920, height: 1080 },\n { id: 'standard', width: 1440, height: 1080 },\n { id: 'square', width: 1080, height: 1080 },\n { id: 'portrait', width: 1080, height: 1920 }\n] as const\nexport type SlideSizePreset = (typeof SLIDE_SIZE_PRESETS)[number]\nconst SLIDE_GAP = 240\nconst ROW_GAP = 600\nconst SLIDES_PER_LINE = 20\n\nconst WHITE = { r: 1, g: 1, b: 1, a: 1 } as const\n\nexport function defaultSlideSettings(): SlideSettings {\n return { skipped: false, notes: '', transition: null }\n}\n\n/** What a slide keeps, whether or not it was ever set; null for any other layer. */\nexport function slideSettings(node: Pick<SceneNode, 'type' | 'slide'>): SlideSettings | null {\n return node.type === 'SLIDE' ? (node.slide ?? defaultSlideSettings()) : null\n}\n\n/** The grid that holds a deck's slides on a page, if the page has one. */\nexport function slideGrid(graph: SceneGraph, pageId: string): SceneNode | undefined {\n return graph.getChildren(pageId).find((node) => node.type === 'SLIDE_GRID')\n}\n\n/** A page's slides by row, in the order a deck presents them. */\nexport function slideRows(graph: SceneGraph, pageId: string): SceneNode[][] {\n const grid = slideGrid(graph, pageId)\n if (!grid) return []\n return graph\n .getChildren(grid.id)\n .filter((row) => row.type === 'SLIDE_ROW')\n .map((row) => graph.getChildren(row.id).filter((node) => node.type === 'SLIDE'))\n}\n\n/** The slide the deck moves on to from `slide`, passing by skipped slides, or undefined at the end. */\nexport function nextSlide(graph: SceneGraph, slide: SceneNode): SceneNode | undefined {\n const page = slide.parentId\n ? graph.closest(slide.parentId, (node) => node.type === 'CANVAS')\n : undefined\n if (!page) return undefined\n const slides = slideRows(graph, page.id).flat()\n const index = slides.findIndex((node) => node.id === slide.id)\n if (index === -1) return undefined\n return slides.slice(index + 1).find((node) => !slideSettings(node)?.skipped)\n}\n\n/**\n * Each slide's number, by ID, in the order a deck presents them: skipped slides have none and are\n * not counted, as in Figma.\n */\nexport function slideNumbers(graph: SceneGraph, pageId: string): Map<string, number | null> {\n let shown = 0\n return new Map(\n slideRows(graph, pageId)\n .flat()\n .map((slide) => [slide.id, slideSettings(slide)?.skipped ? null : ++shown])\n )\n}\n\n/** Names a page's slides by their numbers, and a skipped one `-`, as Figma does. */\nexport function renumberSlides(graph: SceneGraph, pageId: string): void {\n for (const [id, number] of slideNumbers(graph, pageId)) {\n const name = number === null ? '-' : String(number)\n if (graph.getNode(id)?.name !== name) graph.updateNode(id, { name })\n }\n}\n\n/** Adds the grid a deck's slides sit in to a page. */\nexport function createSlideGrid(graph: SceneGraph, pageId: string): SceneNode {\n return graph.createNode('SLIDE_GRID', pageId, {\n name: 'Presentation',\n layoutMode: 'VERTICAL',\n itemSpacing: ROW_GAP,\n // Figma pads a grid before its slides only.\n paddingTop: SLIDE_GAP,\n paddingLeft: SLIDE_GAP,\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'HUG'\n })\n}\n\n/** Adds a row, which Figma calls a section, to the end of a grid. */\nexport function createSlideRow(graph: SceneGraph, gridId: string): SceneNode {\n return graph.createNode('SLIDE_ROW', gridId, {\n name: 'Section',\n layoutMode: 'HORIZONTAL',\n layoutWrap: 'WRAP',\n layoutAlignSelf: 'STRETCH',\n itemSpacing: SLIDE_GAP,\n counterAxisSpacing: SLIDE_GAP,\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'HUG',\n maxWidth: SLIDES_PER_LINE * (DEFAULT_SLIDE_SIZE.width + SLIDE_GAP) + SLIDE_GAP\n })\n}\n\n/** Adds an empty slide to the end of a row, at the size of the slide before it. */\nexport function createSlide(graph: SceneGraph, rowId: string): SceneNode {\n const before = graph.getChildren(rowId).findLast((node) => node.type === 'SLIDE')\n const { width, height } = before ?? DEFAULT_SLIDE_SIZE\n return graph.createNode('SLIDE', rowId, {\n name: 'Slide',\n width,\n height,\n clipsContent: true,\n fills: [{ type: 'SOLID', color: { ...WHITE }, opacity: 1, visible: true }],\n slide: defaultSlideSettings()\n })\n}\n"],"mappings":";;;;;;AAUA,MAAa,qBAAqB;CAAE,OAAO;CAAM,QAAQ;AAAK;;AAG9D,MAAa,qBAAqB;CAChC;EAAE,IAAI;EAAQ,OAAO;EAAM,QAAQ;CAAK;CACxC;EAAE,IAAI;EAAY,OAAO;EAAM,QAAQ;CAAK;CAC5C;EAAE,IAAI;EAAU,OAAO;EAAM,QAAQ;CAAK;CAC1C;EAAE,IAAI;EAAY,OAAO;EAAM,QAAQ;CAAK;AAC9C;AAEA,MAAM,YAAY;AAClB,MAAM,UAAU;AAChB,MAAM,kBAAkB;AAExB,MAAM,QAAQ;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAEvC,SAAgB,uBAAsC;CACpD,OAAO;EAAE,SAAS;EAAO,OAAO;EAAI,YAAY;CAAK;AACvD;;AAGA,SAAgB,cAAc,MAA+D;CAC3F,OAAO,KAAK,SAAS,UAAW,KAAK,SAAS,qBAAqB,I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M,QAAQ,EAAE,CAAC,EAAE,SAAS,MAAM,MAAM,WAAW,IAAI,EAAE,KAAK,CAAC;CACrE;AACF;;AAGA,SAAgB,gBAAgB,OAAmB,QAA2B;CAC5E,OAAO,MAAM,WAAW,cAAc,QAAQ;EAC5C,MAAM;EACN,YAAY;EACZ,aAAa;EAEb,YAAY;EACZ,aAAa;EACb,mBAAmB;EACnB,mBAAmB;CACrB,CAAC;AACH;;AAGA,SAAgB,eAAe,OAAmB,QAA2B;CAC3E,OAAO,MAAM,WAAW,aAAa,QAAQ;EAC3C,MAAM;EACN,YAAY;EACZ,YAAY;EACZ,iBAAiB;EACjB,aAAa;EACb,oBAAoB;EACpB,mBAAmB;EACnB,mBAAmB;EACnB,UAAU,mBAAmB,mBAAmB,QAAQ,aAAa;CACvE,CAAC;AACH;;AAGA,SAAgB,YAAY,OAAmB,OAA0B;CAEvE,MAAM,EAAE,OAAO,WADA,MAAM,YAAY,KAAK,CAAC,CAAC,UAAU,SAAS,KAAK,SAAS,OAC1C,KAAK;CACpC,OAAO,MAAM,WAAW,SAAS,OAAO;EACtC,MAAM;EACN;EACA;EACA,cAAc;EACd,OAAO,CAAC;GAAE,MAAM;GAAS,OAAO,EAAE,GAAG,MAAM;GAAG,SAAS;GAAG,SAAS;EAAK,CAAC;EACzE,OAAO,qBAAqB;CAC9B,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/slides/index.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { SceneNode } from '../types'\nimport type { SlideSettings } from './types'\n\nexport * from './drop'\nexport * from './motion'\nexport * from './playback'\nexport * from './types'\n\n/** Figma's slide: 1920 by 1080, with 240 between slides and 600 between the rows of a grid. */\nexport const DEFAULT_SLIDE_SIZE = { width: 1920, height: 1080 } as const\n\n/** The sizes a deck offers its slides, by shape; any other size is a custom one. */\nexport const SLIDE_SIZE_PRESETS = [\n { id: 'wide', width: 1920, height: 1080 },\n { id: 'standard', width: 1440, height: 1080 },\n { id: 'square', width: 1080, height: 1080 },\n { id: 'portrait', width: 1080, height: 1920 }\n] as const\nexport type SlideSizePreset = (typeof SLIDE_SIZE_PRESETS)[number]\nconst SLIDE_GAP = 240\nconst ROW_GAP = 600\nconst SLIDES_PER_LINE = 20\n\nconst WHITE = { r: 1, g: 1, b: 1, a: 1 } as const\n\nexport function defaultSlideSettings(): SlideSettings {\n return { skipped: false, notes: '', transition: null }\n}\n\n/** What a slide keeps, whether or not it was ever set; null for any other layer. */\nexport function slideSettings(node: Pick<SceneNode, 'type' | 'slide'>): SlideSettings | null {\n return node.type === 'SLIDE' ? (node.slide ?? defaultSlideSettings()) : null\n}\n\n/** The grid that holds a deck's slides on a page, if the page has one. */\nexport function slideGrid(graph: SceneGraph, pageId: string): SceneNode | undefined {\n return graph.getChildren(pageId).find((node) => node.type === 'SLIDE_GRID')\n}\n\n/** A page's slides by row, in the order a deck presents them. */\nexport function slideRows(graph: SceneGraph, pageId: string): SceneNode[][] {\n const grid = slideGrid(graph, pageId)\n if (!grid) return []\n return graph\n .getChildren(grid.id)\n .filter((row) => row.type === 'SLIDE_ROW')\n .map((row) => graph.getChildren(row.id).filter((node) => node.type === 'SLIDE'))\n}\n\n/** The slide the deck moves on to from `slide`, passing by skipped slides, or undefined at the end. */\nexport function nextSlide(graph: SceneGraph, slide: SceneNode): SceneNode | undefined {\n const page = slide.parentId\n ? graph.closest(slide.parentId, (node) => node.type === 'CANVAS')\n : undefined\n if (!page) return undefined\n const slides = slideRows(graph, page.id).flat()\n const index = slides.findIndex((node) => node.id === slide.id)\n if (index === -1) return undefined\n return slides.slice(index + 1).find((node) => !slideSettings(node)?.skipped)\n}\n\n/**\n * Each slide's number, by ID, in the order a deck presents them: skipped slides have none and are\n * not counted, as in Figma.\n */\nexport function slideNumbers(graph: SceneGraph, pageId: string): Map<string, number | null> {\n let shown = 0\n return new Map(\n slideRows(graph, pageId)\n .flat()\n .map((slide) => [slide.id, slideSettings(slide)?.skipped ? null : ++shown])\n )\n}\n\n/** Names a page's slides by their numbers, and a skipped one `-`, as Figma does. */\nexport function renumberSlides(graph: SceneGraph, pageId: string): void {\n for (const [id, number] of slideNumbers(graph, pageId)) {\n const name = number === null ? '-' : String(number)\n if (graph.getNode(id)?.name !== name) graph.updateNode(id, { name })\n }\n}\n\n/** Adds the grid a deck's slides sit in to a page. */\nexport function createSlideGrid(graph: SceneGraph, pageId: string): SceneNode {\n return graph.createNode('SLIDE_GRID', pageId, {\n name: 'Presentation',\n layoutMode: 'VERTICAL',\n itemSpacing: ROW_GAP,\n // Figma pads a grid before its slides only.\n paddingTop: SLIDE_GAP,\n paddingLeft: SLIDE_GAP,\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'HUG'\n })\n}\n\n/** Adds a row, which Figma calls a section, to the end of a grid. */\nexport function createSlideRow(graph: SceneGraph, gridId: string): SceneNode {\n return graph.createNode('SLIDE_ROW', gridId, {\n name: 'Section',\n layoutMode: 'HORIZONTAL',\n layoutWrap: 'WRAP',\n layoutAlignSelf: 'STRETCH',\n itemSpacing: SLIDE_GAP,\n counterAxisSpacing: SLIDE_GAP,\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'HUG',\n maxWidth: SLIDES_PER_LINE * (DEFAULT_SLIDE_SIZE.width + SLIDE_GAP) + SLIDE_GAP\n })\n}\n\n/** Adds an empty slide to the end of a row, at the size of the slide before it. */\nexport function createSlide(graph: SceneGraph, rowId: string): SceneNode {\n const before = graph.getChildren(rowId).findLast((node) => node.type === 'SLIDE')\n const { width, height } = before ?? DEFAULT_SLIDE_SIZE\n return graph.createNode('SLIDE', rowId, {\n name: 'Slide',\n width,\n height,\n clipsContent: true,\n fills: [{ type: 'SOLID', color: { ...WHITE }, opacity: 1, visible: true }],\n slide: defaultSlideSettings()\n })\n}\n\n/** The slides a deck on `pageId` presents, in order: skipped ones are passed by. */\nexport function presentedSlides(graph: SceneGraph, pageId: string): string[] {\n return slideRows(graph, pageId)\n .flat()\n .filter((slide) => !slideS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U,SAAS,KAAK,SAAS,OAC1C,KAAK;CACpC,OAAO,MAAM,WAAW,SAAS,OAAO;EACtC,MAAM;EACN;EACA;EACA,cAAc;EACd,OAAO,CAAC;GAAE,MAAM;GAAS,OAAO,EAAE,GAAG,MAAM;GAAG,SAAS;GAAG,SAAS;EAAK,CAAC;EACzE,OAAO,qBAAqB;CAC9B,CAAC;AACH;;AAGA,SAAgB,gBAAgB,OAAmB,QAA0B;CAC3E,OAAO,UAAU,OAAO,MAAM,CAAC,CAC5B,KAAK,CAAC,CACN,QAAQ,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,OAAO,CAAC,CACjD,KAAK,UAAU,MAAM,EAAE;AAC5B"}
|
package/dist/slides/motion.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { SceneGraph } from "../graph.js";
|
|
2
|
-
import { LayerAnimation, SlideTransition, SlideTransitionStyle } from "./types.js";
|
|
3
2
|
import { SceneNode } from "../types.js";
|
|
4
3
|
import { ResolvedMotion } from "../variables/motion.js";
|
|
5
|
-
|
|
4
|
+
import { LayerAnimation, SlideTransition, SlideTransitionStyle } from "./types.js";
|
|
6
5
|
/** The transition a slide starts with when one is added. */
|
|
7
|
-
declare function defaultSlideTransition(): SlideTransition;
|
|
6
|
+
export declare function defaultSlideTransition(): SlideTransition;
|
|
8
7
|
/** The animation a layer starts with when one is added, as in Figma: it slides in from the left. */
|
|
9
|
-
declare function defaultLayerAnimation(order: number): LayerAnimation;
|
|
8
|
+
export declare function defaultLayerAnimation(order: number): LayerAnimation;
|
|
10
9
|
/** A slide's transition as it plays, with its variables read for the slide. */
|
|
11
|
-
interface ResolvedSlideTransition extends ResolvedMotion {
|
|
10
|
+
export interface ResolvedSlideTransition extends ResolvedMotion {
|
|
12
11
|
style: SlideTransitionStyle;
|
|
13
12
|
/** Seconds before the deck moves on by itself, or null when it waits for the presenter. */
|
|
14
13
|
delay: number | null;
|
|
15
14
|
}
|
|
16
|
-
declare function resolveSlideTransition(graph: SceneGraph, slide: SceneNode): ResolvedSlideTransition | null;
|
|
15
|
+
export declare function resolveSlideTransition(graph: SceneGraph, slide: SceneNode): ResolvedSlideTransition | null;
|
|
17
16
|
/** The variables a layer's slide transition and animation follow. */
|
|
18
|
-
declare function slideVariableIds(node: Pick<SceneNode, 'slide' | 'animation'>): string[];
|
|
17
|
+
export declare function slideVariableIds(node: Pick<SceneNode, 'slide' | 'animation'>): string[];
|
|
19
18
|
/**
|
|
20
19
|
* A layer's slide transition and animation following other variables, as a copy into another
|
|
21
20
|
* document names them; a variable `map` gives nothing for is let go, keeping the value.
|
|
22
21
|
*/
|
|
23
|
-
declare function mapSlideVariables(node: Pick<SceneNode, 'slide' | 'animation'>, map: (variableId: string) => string | undefined): Pick<SceneNode, 'slide' | 'animation'>;
|
|
22
|
+
export declare function mapSlideVariables(node: Pick<SceneNode, 'slide' | 'animation'>, map: (variableId: string) => string | undefined): Pick<SceneNode, 'slide' | 'animation'>;
|
|
24
23
|
/** A layer's animation, with the layer it moves. */
|
|
25
|
-
interface AnimatedLayer {
|
|
24
|
+
export interface AnimatedLayer {
|
|
26
25
|
id: string;
|
|
27
26
|
animation: LayerAnimation;
|
|
28
27
|
}
|
|
@@ -31,25 +30,42 @@ interface AnimatedLayer {
|
|
|
31
30
|
* presenter, except a first one made only of `AFTER_PREVIOUS` animations, which plays as the slide
|
|
32
31
|
* appears.
|
|
33
32
|
*/
|
|
34
|
-
interface BuildStep {
|
|
33
|
+
export interface BuildStep {
|
|
35
34
|
onClick: boolean;
|
|
36
35
|
layers: AnimatedLayer[];
|
|
37
36
|
}
|
|
38
37
|
/** The animated layers of a slide, in the order they play: by `order`, then by layer order. */
|
|
39
|
-
declare function animatedLayers(graph: SceneGraph, slideId: string): AnimatedLayer[];
|
|
38
|
+
export declare function animatedLayers(graph: SceneGraph, slideId: string): AnimatedLayer[];
|
|
40
39
|
/** A slide's build: its animations grouped into the steps a presenter clicks through. */
|
|
41
|
-
declare function slideBuild(graph: SceneGraph, slideId: string): BuildStep[];
|
|
40
|
+
export declare function slideBuild(graph: SceneGraph, slideId: string): BuildStep[];
|
|
42
41
|
/**
|
|
43
42
|
* The slide a layer animates on, or undefined for a layer that cannot have an animation: one on no
|
|
44
43
|
* slide, a slide itself, or a layer inside an instance, whose component gives it its fields.
|
|
45
44
|
*/
|
|
46
|
-
declare function animationSlide(graph: SceneGraph, layerId: string): SceneNode | undefined;
|
|
45
|
+
export declare function animationSlide(graph: SceneGraph, layerId: string): SceneNode | undefined;
|
|
47
46
|
/**
|
|
48
47
|
* The layer an animation for `layerId` goes on, as Figma's Animate panel picks it: the layer
|
|
49
48
|
* itself, or for a layer inside an instance the outermost instance on the slide, which Figma
|
|
50
49
|
* animates instead. Undefined for a layer on no slide, or a slide.
|
|
51
50
|
*/
|
|
52
|
-
declare function animationTarget(graph: SceneGraph, layerId: string): string | undefined;
|
|
53
|
-
|
|
54
|
-
export
|
|
51
|
+
export declare function animationTarget(graph: SceneGraph, layerId: string): string | undefined;
|
|
52
|
+
/** A layer's step in a slide's build, timed: when it starts within its step, and how long it plays. */
|
|
53
|
+
export interface TimedLayer {
|
|
54
|
+
id: string;
|
|
55
|
+
step: AnimatedLayer;
|
|
56
|
+
/** Seconds after its step starts. */
|
|
57
|
+
start: number;
|
|
58
|
+
seconds: number;
|
|
59
|
+
}
|
|
60
|
+
/** A step of a slide's build with its layers timed one after another, and how long it plays. */
|
|
61
|
+
export interface TimedStep {
|
|
62
|
+
onClick: boolean;
|
|
63
|
+
layers: TimedLayer[];
|
|
64
|
+
seconds: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A slide's build with each step's layers timed as presenting plays them: one after another, each
|
|
68
|
+
* for its duration, or, eased by a spring, for as long as the spring takes to settle.
|
|
69
|
+
*/
|
|
70
|
+
export declare function timedBuild(graph: SceneGraph, slideId: string): TimedStep[];
|
|
55
71
|
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.d.ts","names":[],"sources":["../../src/slides/motion.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"motion.d.ts","names":[],"sources":["../../src/slides/motion.ts"],"mappings":";;;;;wBAegB,0BAA0B;;wBAa1B,sBAAsB,gBAAgB;;iBAYrC,gCAAgC;EAC/C,OAAO;;EAEP;;wBAGc,uBACd,OAAO,YACP,OAAO,YACN;;wBAea,iBAAiB,MAAM,KAAK;;;;;wBAa5B,kBACd,MAAM,KAAK,mCACX,MAAM,4CACL,KAAK;;iBAgBS;EACf;EACA,WAAW;;;;;;;iBAQI;EACf;EACA,QAAQ;;;wBAIM,eAAe,OAAO,YAAY,kBAAkB;;wBAcpD,WAAW,OAAO,YAAY,kBAAkB;;;;;wBAchD,eAAe,OAAO,YAAY,kBAAkB;;;;;;wBAYpD,gBAAgB,OAAO,YAAY;;iBAmBlC;EACf;EACA,MAAM;;EAEN;EACA;;;iBAIe;EACf;EACA,QAAQ;EACR;;;;;;wBAOc,WAAW,OAAO,YAAY,kBAAkB"}
|
package/dist/slides/motion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { easingPreset } from "../variables/easing.js";
|
|
2
|
-
import { mapMotionVariables, motionVariableIds, resolveMotion, resolveTiming } from "../variables/motion.js";
|
|
3
1
|
import { compact } from "es-toolkit/array";
|
|
4
|
-
|
|
2
|
+
import { easingPreset, easingSeconds } from "../variables/easing.js";
|
|
3
|
+
import { mapMotionVariables, motionVariableIds, resolveMotion, resolveTiming } from "../variables/motion.js";
|
|
4
|
+
// src/slides/motion.ts
|
|
5
5
|
/** The transition a slide starts with when one is added. */
|
|
6
6
|
function defaultSlideTransition() {
|
|
7
7
|
return {
|
|
@@ -136,7 +136,32 @@ function animationTarget(graph, layerId) {
|
|
|
136
136
|
id = parent.parentId;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
/**
|
|
140
|
+
* A slide's build with each step's layers timed as presenting plays them: one after another, each
|
|
141
|
+
* for its duration, or, eased by a spring, for as long as the spring takes to settle.
|
|
142
|
+
*/
|
|
143
|
+
function timedBuild(graph, slideId) {
|
|
144
|
+
return slideBuild(graph, slideId).map((step) => {
|
|
145
|
+
let start = 0;
|
|
146
|
+
const layers = step.layers.map((layer) => {
|
|
147
|
+
const motion = resolveMotion(graph, layer.animation, layer.id);
|
|
148
|
+
const seconds = easingSeconds(motion.easing, motion.duration);
|
|
149
|
+
const timed = {
|
|
150
|
+
id: layer.id,
|
|
151
|
+
step: layer,
|
|
152
|
+
start,
|
|
153
|
+
seconds
|
|
154
|
+
};
|
|
155
|
+
start += seconds;
|
|
156
|
+
return timed;
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
onClick: step.onClick,
|
|
160
|
+
layers,
|
|
161
|
+
seconds: start
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export { animatedLayers, animationSlide, animationTarget, defaultLayerAnimation, defaultSlideTransition, mapSlideVariables, resolveSlideTransition, slideBuild, slideVariableIds, timedBuild };
|
|
141
166
|
|
|
142
167
|
//# sourceMappingURL=motion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.js","names":[],"sources":["../../src/slides/motion.ts"],"sourcesContent":["import { compact } from 'es-toolkit/array'\n\nimport type { SceneGraph } from '../graph'\nimport type { SceneNode } from '../types'\nimport { easingPreset } from '../variables/easing'\nimport {\n mapMotionVariables,\n motionVariableIds,\n resolveMotion,\n resolveTiming,\n type ResolvedMotion\n} from '../variables/motion'\nimport type { LayerAnimation, SlideTransition, SlideTransitionStyle } from './types'\n\n/** The transition a slide starts with when one is added. */\nexport function defaultSlideTransition(): SlideTransition {\n return {\n style: 'DISSOLVE',\n duration: 0.3,\n easing: easingPreset('OUT_CUBIC'),\n timing: { type: 'ON_CLICK' }\n }\n}\n\n/** Figma's curve for layer animations, which its panel does not offer to change. */\nconst LAYER_ANIMATION_BEZIER = { x1: 0.17, y1: 0, x2: 0.2, y2: 1 }\n\n/** The animation a layer starts with when one is added, as in Figma: it slides in from the left. */\nexport function defaultLayerAnimation(order: number): LayerAnimation {\n return {\n style: 'SLIDE_FROM_LEFT',\n phase: 'IN',\n trigger: 'ON_CLICK',\n duration: 0.6,\n easing: { easing: 'CUSTOM_CUBIC', bezier: { ...LAYER_ANIMATION_BEZIER } },\n order\n }\n}\n\n/** A slide's transition as it plays, with its variables read for the slide. */\nexport interface ResolvedSlideTransition extends ResolvedMotion {\n style: SlideTransitionStyle\n /** Seconds before the deck moves on by itself, or null when it waits for the presenter. */\n delay: number | null\n}\n\nexport function resolveSlideTransition(\n graph: SceneGraph,\n slide: SceneNode\n): ResolvedSlideTransition | null {\n const transition = slide.slide?.transition\n if (!transition) return null\n const { timing } = transition\n return {\n style: transition.style,\n ...resolveMotion(graph, transition, slide.id),\n delay:\n timing.type === 'AFTER_DELAY'\n ? resolveTiming(graph, timing.delayVariableId, slide.id, timing.delay)\n : null\n }\n}\n\n/** The variables a layer's slide transition and animation follow. */\nexport function slideVariableIds(node: Pick<SceneNode, 'slide' | 'animation'>): string[] {\n const transition = node.slide?.transition\n return [\n ...(transition ? motionVariableIds(transition) : []),\n ...compact([transition?.timing.type === 'AFTER_DELAY' && transition.timing.delayVariableId]),\n ...(node.animation ? motionVariableIds(node.animation) : [])\n ]\n}\n\n/**\n * A layer's slide transition and animation following other variables, as a copy into another\n * document names them; a variable `map` gives nothing for is let go, keeping the value.\n */\nexport function mapSlideVariables(\n node: Pick<SceneNode, 'slide' | 'animation'>,\n map: (variableId: string) => string | undefined\n): Pick<SceneNode, 'slide' | 'animation'> {\n const transition = node.slide?.transition\n let slide = node.slide && structuredClone(node.slide)\n if (slide && transition) {\n const mapped = mapMotionVariables(transition, map)\n if (transition.timing.type === 'AFTER_DELAY') {\n const { delayVariableId, ...timing } = transition.timing\n const delay = delayVariableId === undefined ? undefined : map(delayVariableId)\n mapped.timing = delay === undefined ? timing : { ...timing, delayVariableId: delay }\n }\n slide = { ...slide, transition: mapped }\n }\n return { slide, animation: node.animation && mapMotionVariables(node.animation, map) }\n}\n\n/** A layer's animation, with the layer it moves. */\nexport interface AnimatedLayer {\n id: string\n animation: LayerAnimation\n}\n\n/**\n * A step of a slide's build: its layers' animations, one after another. A step waits for the\n * presenter, except a first one made only of `AFTER_PREVIOUS` animations, which plays as the slide\n * appears.\n */\nexport interface BuildStep {\n onClick: boolean\n layers: AnimatedLayer[]\n}\n\n/** The animated layers of a slide, in the order they play: by `order`, then by layer order. */\nexport function animatedLayers(graph: SceneGraph, slideId: string): AnimatedLayer[] {\n const layers: AnimatedLayer[] = []\n const visit = (id: string) => {\n for (const child of graph.getChildren(id)) {\n if (child.animation) layers.push({ id: child.id, animation: child.animation })\n visit(child.id)\n }\n }\n visit(slideId)\n // Array sort is stable, so equal orders keep layer order.\n return layers.sort((a, b) => a.animation.order - b.animation.order)\n}\n\n/** A slide's build: its animations grouped into the steps a presenter clicks through. */\nexport function slideBuild(graph: SceneGraph, slideId: string): BuildStep[] {\n const steps: BuildStep[] = []\n for (const layer of animatedLayers(graph, slideId)) {\n const last = steps.at(-1)\n if (layer.animation.trigger === 'AFTER_PREVIOUS' && last) last.layers.push(layer)\n else steps.push({ onClick: layer.animation.trigger === 'ON_CLICK', layers: [layer] })\n }\n return steps\n}\n\n/**\n * The slide a layer animates on, or undefined for a layer that cannot have an animation: one on no\n * slide, a slide itself, or a layer inside an instance, whose component gives it its fields.\n */\nexport function animationSlide(graph: SceneGraph, layerId: string): SceneNode | undefined {\n const node = graph.getNode(layerId)\n if (!node?.parentId || node.type === 'SLIDE') return undefined\n if (graph.closest(node.parentId, (item) => item.type === 'INSTANCE')) return undefined\n return graph.closest(node.parentId, (item) => item.type === 'SLIDE') ?? undefined\n}\n\n/**\n * The layer an animation for `layerId` goes on, as Figma's Animate panel picks it: the layer\n * itself, or for a layer inside an instance the outermost instance on the slide, which Figma\n * animates instead. Undefined for a layer on no slide, or a slide.\n */\nexport function animationTarget(graph: SceneGraph, layerId: string): string | undefined {\n const node = graph.getNode(layerId)\n if (!node || node.type === 'SLIDE') return undefined\n let target = layerId\n let id = node.parentId\n // A parent cycle in bad data ends the walk.\n const seen = new Set<string>()\n while (id && !seen.has(id)) {\n seen.add(id)\n const parent = graph.getNode(id)\n if (!parent) return undefined\n if (parent.type === 'SLIDE') return target\n if (parent.type === 'INSTANCE') target = parent.id\n id = parent.parentId\n }\n return undefined\n}\n"],"mappings":";;;;;AAeA,SAAgB,yBAA0C;CACxD,OAAO;EACL,OAAO;EACP,UAAU;EACV,QAAQ,aAAa,WAAW;EAChC,QAAQ,EAAE,MAAM,WAAW;CAC7B;AACF;;AAGA,MAAM,yBAAyB;CAAE,IAAI;CAAM,IAAI;CAAG,IAAI;CAAK,IAAI;AAAE;;AAGjE,SAAgB,sBAAsB,OAA+B;CACnE,OAAO;EACL,OAAO;EACP,OAAO;EACP,SAAS;EACT,UAAU;EACV,QAAQ;GAAE,QAAQ;GAAgB,QAAQ,EAAE,GAAG,uBAAuB;EAAE;EACxE;CACF;AACF;AASA,SAAgB,uBACd,OACA,OACgC;CAChC,MAAM,aAAa,MAAM,OAAO;CAChC,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,EAAE,WAAW;CACnB,OAAO;EACL,OAAO,WAAW;EAClB,GAAG,cAAc,OAAO,YAAY,MAAM,EAAE;EAC5C,OACE,OAAO,SAAS,gBACZ,cAAc,OAAO,OAAO,iBAAiB,MAAM,IAAI,OAAO,KAAK,IACnE;CACR;AACF;;AAGA,SAAgB,iBAAiB,MAAwD;CACvF,MAAM,aAAa,KAAK,OAAO;CAC/B,OAAO;EACL,GAAI,aAAa,kBAAkB,UAAU,IAAI,CAAC;EAClD,GAAG,QAAQ,CAAC,YAAY,OAAO,SAAS,iBAAiB,WAAW,OAAO,eAAe,CAAC;EAC3F,GAAI,KAAK,YAAY,kBAAkB,KAAK,SAAS,IAAI,CAAC;CAC5D;AACF;;;;;AAMA,SAAgB,kBACd,MACA,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,OAAO,MAAM,QAAQ,OAAO;CAClC,IAAI,CAAC,MAAM,YAAY,KAAK,SAAS,SAAS,OAAO,KAAA;CACrD,IAAI,MAAM,QAAQ,KAAK,WAAW,SAAS,KAAK,SAAS,UAAU,GAAG,OAAO,KAAA;CAC7E,OAAO,MAAM,QAAQ,KAAK,WAAW,SAAS,KAAK,SAAS,OAAO,KAAK,KAAA;AAC1E;;;;;;AAOA,SAAgB,gBAAgB,OAAmB,SAAqC;CACtF,MAAM,OAAO,MAAM,QAAQ,OAAO;CAClC,IAAI,CAAC,QAAQ,KAAK,SAAS,SAAS,OAAO,KAAA;CAC3C,IAAI,SAAS;CACb,IAAI,KAAK,KAAK;CAEd,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG;EAC1B,KAAK,IAAI,EAAE;EACX,MAAM,SAAS,MAAM,QAAQ,EAAE;EAC/B,IAAI,CAAC,QAAQ,OAAO,KAAA;EACpB,IAAI,OAAO,SAAS,SAAS,OAAO;EACpC,IAAI,OAAO,SAAS,YAAY,SAAS,OAAO;EAChD,KAAK,OAAO;CACd;AAEF"}
|
|
1
|
+
{"version":3,"file":"motion.js","names":[],"sources":["../../src/slides/motion.ts"],"sourcesContent":["import { compact } from 'es-toolkit/array'\n\nimport type { SceneGraph } from '../graph'\nimport type { SceneNode } from '../types'\nimport { easingPreset, easingSeconds } from '../variables/easing'\nimport {\n mapMotionVariables,\n motionVariableIds,\n resolveMotion,\n resolveTiming,\n type ResolvedMotion\n} from '../variables/motion'\nimport type { LayerAnimation, SlideTransition, SlideTransitionStyle } from './types'\n\n/** The transition a slide starts with when one is added. */\nexport function defaultSlideTransition(): SlideTransition {\n return {\n style: 'DISSOLVE',\n duration: 0.3,\n easing: easingPreset('OUT_CUBIC'),\n timing: { type: 'ON_CLICK' }\n }\n}\n\n/** Figma's curve for layer animations, which its panel does not offer to change. */\nconst LAYER_ANIMATION_BEZIER = { x1: 0.17, y1: 0, x2: 0.2, y2: 1 }\n\n/** The animation a layer starts with when one is added, as in Figma: it slides in from the left. */\nexport function defaultLayerAnimation(order: number): LayerAnimation {\n return {\n style: 'SLIDE_FROM_LEFT',\n phase: 'IN',\n trigger: 'ON_CLICK',\n duration: 0.6,\n easing: { easing: 'CUSTOM_CUBIC', bezier: { ...LAYER_ANIMATION_BEZIER } },\n order\n }\n}\n\n/** A slide's transition as it plays, with its variables read for the slide. */\nexport interface ResolvedSlideTransition extends ResolvedMotion {\n style: SlideTransitionStyle\n /** Seconds before the deck moves on by itself, or null when it waits for the presenter. */\n delay: number | null\n}\n\nexport function resolveSlideTransition(\n graph: SceneGraph,\n slide: SceneNode\n): ResolvedSlideTransition | null {\n const transition = slide.slide?.transition\n if (!transition) return null\n const { timing } = transition\n return {\n style: transition.style,\n ...resolveMotion(graph, transition, slide.id),\n delay:\n timing.type === 'AFTER_DELAY'\n ? resolveTiming(graph, timing.delayVariableId, slide.id, timing.delay)\n : null\n }\n}\n\n/** The variables a layer's slide transition and animation follow. */\nexport function slideVariableIds(node: Pick<SceneNode, 'slide' | 'animation'>): string[] {\n const transition = node.slide?.transition\n return [\n ...(transition ? motionVariableIds(transition) : []),\n ...compact([transition?.timing.type === 'AFTER_DELAY' && transition.timing.delayVariableId]),\n ...(node.animation ? motionVariableIds(node.animation) : [])\n ]\n}\n\n/**\n * A layer's slide transition and animation following other variables, as a copy into another\n * document names them; a variable `map` gives nothing for is let go, keeping the value.\n */\nexport function mapSlideVariables(\n node: Pick<SceneNode, 'slide' | 'animation'>,\n map: (variableId: string) => string | undefined\n): Pick<SceneNode, 'slide' | 'animation'> {\n const transition = node.slide?.transition\n let slide = node.slide && structuredClone(node.slide)\n if (slide && transition) {\n const mapped = mapMotionVariables(transition, map)\n if (transition.timing.type === 'AFTER_DELAY') {\n const { delayVariableId, ...timing } = transition.timing\n const delay = delayVariableId === undefined ? undefined : map(delayVariableId)\n mapped.timing = delay === undefined ? timing : { ...timing, delayVariableId: delay }\n }\n slide = { ...slide, transition: mapped }\n }\n return { slide, animation: node.animation && mapMotionVariables(node.animation, map) }\n}\n\n/** A layer's animation, with the layer it moves. */\nexport interface AnimatedLayer {\n id: string\n animation: LayerAnimation\n}\n\n/**\n * A step of a slide's build: its layers' animations, one after another. A step waits for the\n * presenter, except a first one made only of `AFTER_PREVIOUS` animations, which plays as the slide\n * appears.\n */\nexport interface BuildStep {\n onClick: boolean\n layers: AnimatedLayer[]\n}\n\n/** The animated layers of a slide, in the order they play: by `order`, then by layer order. */\nexport function animatedLayers(graph: SceneGraph, slideId: string): AnimatedLayer[] {\n const layers: AnimatedLayer[] = []\n const visit = (id: string) => {\n for (const child of graph.getChildren(id)) {\n if (child.animation) layers.push({ id: child.id, animation: child.animation })\n visit(child.id)\n }\n }\n visit(slideId)\n // Array sort is stable, so equal orders keep layer order.\n return layers.sort((a, b) => a.animation.order - b.animation.order)\n}\n\n/** A slide's build: its animations grouped into the steps a presenter clicks through. */\nexport function slideBuild(graph: SceneGraph, slideId: string): BuildStep[] {\n const steps: BuildStep[] = []\n for (const layer of animatedLayers(graph, slideId)) {\n const last = steps.at(-1)\n if (layer.animation.trigger === 'AFTER_PREVIOUS' && last) last.layers.push(layer)\n else steps.push({ onClick: layer.animation.trigger === 'ON_CLICK', layers: [layer] })\n }\n return steps\n}\n\n/**\n * The slide a layer animates on, or undefined for a layer that cannot have an animation: one on no\n * slide, a slide itself, or a layer inside an instance, whose component gives it its fields.\n */\nexport function animationSlide(graph: SceneGraph, layerId: string): SceneNode | undefined {\n const node = graph.getNode(layerId)\n if (!node?.parentId || node.type === 'SLIDE') return undefined\n if (graph.closest(node.parentId, (item) => item.type === 'INSTANCE')) return undefined\n return graph.closest(node.parentId, (item) => item.type === 'SLIDE') ?? undefined\n}\n\n/**\n * The layer an animation for `layerId` goes on, as Figma's Animate panel picks it: the layer\n * itself, or for a layer inside an instance the outermost instance on the slide, which Figma\n * animates instead. Undefined for a layer on no slide, or a slide.\n */\nexport function animationTarget(graph: SceneGraph, layerId: string): string | undefined {\n const node = graph.getNode(layerId)\n if (!node || node.type === 'SLIDE') return undefined\n let target = layerId\n let id = node.parentId\n // A parent cycle in bad data ends the walk.\n const seen = new Set<string>()\n while (id && !seen.has(id)) {\n seen.add(id)\n const parent = graph.getNode(id)\n if (!parent) return undefined\n if (parent.type === 'SLIDE') return target\n if (parent.type === 'INSTANCE') target = parent.id\n id = parent.parentId\n }\n return undefined\n}\n\n/** A layer's step in a slide's build, timed: when it starts within its step, and how long it plays. */\nexport interface TimedLayer {\n id: string\n step: AnimatedLayer\n /** Seconds after its step starts. */\n start: number\n seconds: number\n}\n\n/** A step of a slide's build with its layers timed one after another, and how long it plays. */\nexport interface TimedStep {\n onClick: boolean\n layers: TimedLayer[]\n seconds: number\n}\n\n/**\n * A slide's build with each step's layers timed as presenting plays them: one after another, each\n * for its duration, or, eased by a spring, for as long as the spring takes to settle.\n */\nexport function timedBuild(graph: SceneGraph, slideId: string): TimedStep[] {\n return slideBuild(graph, slideId).map((step) => {\n let start = 0\n const layers = step.layers.map((layer) => {\n const motion = resolveMotion(graph, layer.animation, layer.id)\n const seconds = easingSeconds(motion.easing, motion.duration)\n const timed = { id: layer.id, step: layer, start, seconds }\n start += seconds\n return timed\n })\n return { onClick: step.onClick, layers, seconds: start }\n })\n}\n"],"mappings":";;;;;AAeA,SAAgB,yBAA0C;CACxD,OAAO;EACL,OAAO;EACP,UAAU;EACV,QAAQ,aAAa,WAAW;EAChC,QAAQ,EAAE,MAAM,WAAW;CAC7B;AACF;;AAGA,MAAM,yBAAyB;CAAE,IAAI;CAAM,IAAI;CAAG,IAAI;CAAK,IAAI;AAAE;;AAGjE,SAAgB,sBAAsB,OAA+B;CACnE,OAAO;EACL,OAAO;EACP,OAAO;EACP,SAAS;EACT,UAAU;EACV,QAAQ;GAAE,QAAQ;GAAgB,QAAQ,EAAE,GAAG,uBAAuB;EAAE;EACxE;CACF;AACF;AASA,SAAgB,uBACd,OACA,OACgC;CAChC,MAAM,aAAa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;AAEF;;;;;AAsBA,SAAgB,WAAW,OAAmB,SAA8B;CAC1E,OAAO,WAAW,OAAO,OAAO,CAAC,CAAC,KAAK,SAAS;EAC9C,IAAI,QAAQ;EACZ,MAAM,SAAS,KAAK,OAAO,KAAK,UAAU;GACxC,MAAM,SAAS,cAAc,OAAO,MAAM,WAAW,MAAM,EAAE;GAC7D,MAAM,UAAU,cAAc,OAAO,QAAQ,OAAO,QAAQ;GAC5D,MAAM,QAAQ;IAAE,IAAI,MAAM;IAAI,MAAM;IAAO;IAAO;GAAQ;GAC1D,SAAS;GACT,OAAO;EACT,CAAC;EACD,OAAO;GAAE,SAAS,KAAK;GAAS;GAAQ,SAAS;EAAM;CACzD,CAAC;AACH"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { KeyframeTrack } from "../motion/types.js";
|
|
2
|
+
import { Easing } from "../types.js";
|
|
1
3
|
import { LayerAnimation, SlideTransitionStyle } from "./types.js";
|
|
2
|
-
//#region src/slides/playback.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* How a slide is drawn at a moment of a transition: moved by fractions of its own width and
|
|
5
6
|
* height, faded, and darkened towards black.
|
|
6
7
|
*/
|
|
7
|
-
interface SlideFrame {
|
|
8
|
+
export interface SlideFrame {
|
|
8
9
|
x: number;
|
|
9
10
|
y: number;
|
|
10
11
|
opacity: number;
|
|
@@ -12,7 +13,7 @@ interface SlideFrame {
|
|
|
12
13
|
dim: number;
|
|
13
14
|
}
|
|
14
15
|
/** The two slides of a transition, the one drawn first below the other. */
|
|
15
|
-
interface TransitionFrames {
|
|
16
|
+
export interface TransitionFrames {
|
|
16
17
|
from: SlideFrame;
|
|
17
18
|
to: SlideFrame;
|
|
18
19
|
/** Which slide is drawn on top. */
|
|
@@ -22,38 +23,40 @@ interface TransitionFrames {
|
|
|
22
23
|
* Where the slides of a transition are when its easing is at `position`: 0 at the start, 1 at the
|
|
23
24
|
* end, past 1 while a spring overshoots. Smart animate plays as Dissolve for now.
|
|
24
25
|
*/
|
|
25
|
-
declare function transitionFrames(style: SlideTransitionStyle, position: number): TransitionFrames;
|
|
26
|
+
export declare function transitionFrames(style: SlideTransitionStyle, position: number): TransitionFrames;
|
|
26
27
|
/** How far, in slide pixels, a layer slides on or off, whatever its size, as in Figma. */
|
|
27
|
-
declare const LAYER_SLIDE_DISTANCE = 300;
|
|
28
|
+
export declare const LAYER_SLIDE_DISTANCE = 300;
|
|
28
29
|
/** Where a layer animating onto or off its slide is drawn, relative to where it is. */
|
|
29
|
-
interface LayerFrame {
|
|
30
|
+
export interface LayerFrame {
|
|
30
31
|
x: number;
|
|
31
32
|
y: number;
|
|
32
33
|
opacity: number;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
-
* slides the last stretch to its place; one going out keeps
|
|
36
|
+
* A layer's animation as keyframe tracks over the `seconds` its step plays, eased by `easing`: a
|
|
37
|
+
* layer coming in fades in as it slides the last stretch to its place; one going out keeps
|
|
38
|
+
* moving the same way as it fades. A spring's step lasts as long as the spring takes to settle,
|
|
39
|
+
* so fitted into it the spring keeps its own pace.
|
|
37
40
|
*/
|
|
38
|
-
declare function
|
|
41
|
+
export declare function layerAnimationTracks(animation: Pick<LayerAnimation, 'style' | 'phase'>, easing: Easing, seconds: number): Record<string, KeyframeTrack>;
|
|
42
|
+
/** Where an animating layer is `elapsed` seconds into the `seconds` its step plays. */
|
|
43
|
+
export declare function layerFrameAt(animation: Pick<LayerAnimation, 'style' | 'phase'>, easing: Easing, elapsed: number, seconds: number): LayerFrame;
|
|
39
44
|
/** Where a layer is drawn before its step has played, or after. */
|
|
40
|
-
declare function layerAtRest(animation: Pick<LayerAnimation, 'phase'>, played: boolean): LayerFrame;
|
|
45
|
+
export declare function layerAtRest(animation: Pick<LayerAnimation, 'phase'>, played: boolean): LayerFrame;
|
|
41
46
|
/** The transitions Figma's panel offers, each but the first three in four directions. */
|
|
42
|
-
declare const SLIDE_TRANSITION_KINDS: readonly ["NONE", "SMART_ANIMATE", "DISSOLVE", "PUSH", "SLIDE_IN", "SLIDE_OUT", "MOVE_IN", "MOVE_OUT"];
|
|
43
|
-
type SlideTransitionKind = (typeof SLIDE_TRANSITION_KINDS)[number];
|
|
47
|
+
export declare const SLIDE_TRANSITION_KINDS: readonly ["NONE", "SMART_ANIMATE", "DISSOLVE", "PUSH", "SLIDE_IN", "SLIDE_OUT", "MOVE_IN", "MOVE_OUT"];
|
|
48
|
+
export type SlideTransitionKind = (typeof SLIDE_TRANSITION_KINDS)[number];
|
|
44
49
|
/** Which way a transition or a layer moves, as Figma's arrows show it. */
|
|
45
|
-
declare const MOTION_DIRECTIONS: readonly ["LEFT", "RIGHT", "DOWN", "UP"];
|
|
46
|
-
type MotionDirection = (typeof MOTION_DIRECTIONS)[number];
|
|
50
|
+
export declare const MOTION_DIRECTIONS: readonly ["LEFT", "RIGHT", "DOWN", "UP"];
|
|
51
|
+
export type MotionDirection = (typeof MOTION_DIRECTIONS)[number];
|
|
47
52
|
/** A style's kind, as Figma's panel lists it. */
|
|
48
|
-
declare function transitionKind(style: SlideTransitionStyle): SlideTransitionKind;
|
|
53
|
+
export declare function transitionKind(style: SlideTransitionStyle): SlideTransitionKind;
|
|
49
54
|
/** Which way a style moves its slides, or null for one that does not move them. */
|
|
50
|
-
declare function transitionDirection(style: SlideTransitionStyle): MotionDirection | null;
|
|
55
|
+
export declare function transitionDirection(style: SlideTransitionStyle): MotionDirection | null;
|
|
51
56
|
/** The style of a kind moving `direction`; a kind that does not move ignores it. */
|
|
52
|
-
declare function transitionStyle(kind: SlideTransitionKind, direction: MotionDirection): SlideTransitionStyle;
|
|
57
|
+
export declare function transitionStyle(kind: SlideTransitionKind, direction: MotionDirection): SlideTransitionStyle;
|
|
53
58
|
/** Which way a layer animation moves its layer, or null for a fade. */
|
|
54
|
-
declare function layerAnimationDirection(style: LayerAnimation['style']): MotionDirection | null;
|
|
59
|
+
export declare function layerAnimationDirection(style: LayerAnimation['style']): MotionDirection | null;
|
|
55
60
|
/** The layer animation that slides its layer `direction`, or fades it with null. */
|
|
56
|
-
declare function layerAnimationStyle(direction: MotionDirection | null): LayerAnimation['style'];
|
|
57
|
-
//#endregion
|
|
58
|
-
export { LAYER_SLIDE_DISTANCE, LayerFrame, MOTION_DIRECTIONS, MotionDirection, SLIDE_TRANSITION_KINDS, SlideFrame, SlideTransitionKind, TransitionFrames, layerAnimationDirection, layerAnimationStyle, layerAtRest, layerFrame, transitionDirection, transitionFrames, transitionKind, transitionStyle };
|
|
61
|
+
export declare function layerAnimationStyle(direction: MotionDirection | null): LayerAnimation['style'];
|
|
59
62
|
//# sourceMappingURL=playback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playback.d.ts","names":[],"sources":["../../src/slides/playback.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"playback.d.ts","names":[],"sources":["../../src/slides/playback.ts"],"mappings":";;;;;;;iBAUiB;EACf;EACA;EACA;;EAEA;;;iBAIe;EACf,MAAM;EACN,IAAI;;EAEJ;;;;;;wBA4Cc,iBAAiB,OAAO,sBAAsB,mBAAmB;;qBA0BpE;;iBAGI;EACf;EACA;EACA;;;;;;;;wBAgBc,qBACd,WAAW,KAAK,oCAChB,QAAQ,QACR,kBACC,eAAe;;wBA0BF,aACd,WAAW,KAAK,oCAChB,QAAQ,QACR,iBACA,kBACC;;wBAca,YAAY,WAAW,KAAK,0BAA0B,kBAAkB;;qBAM3E;YAUD,8BAA8B;;qBAG7B;YACD,0BAA0B;;wBA6BtB,eAAe,OAAO,uBAAuB;;wBAO7C,oBAAoB,OAAO,uBAAuB;;wBAKlD,gBACd,MAAM,qBACN,WAAW,kBACV;;wBAMa,wBAAwB,OAAO,0BAA0B;;wBAKzD,oBAAoB,WAAW,yBAAyB"}
|
package/dist/slides/playback.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { trackValueAt } from "../motion/evaluate.js";
|
|
2
|
+
// src/slides/playback.ts
|
|
2
3
|
/** How far the slide underneath moves in Slide in and Slide out, as Figma moves it. */
|
|
3
4
|
const PARALLAX = .25;
|
|
4
5
|
/** How dark the slide underneath gets in Slide in and Slide out. */
|
|
@@ -95,20 +96,52 @@ const LAYER_DIRECTIONS = {
|
|
|
95
96
|
SLIDE_FROM_BOTTOM: UPWARDS
|
|
96
97
|
};
|
|
97
98
|
/**
|
|
98
|
-
*
|
|
99
|
-
* slides the last stretch to its place; one going out keeps
|
|
99
|
+
* A layer's animation as keyframe tracks over the `seconds` its step plays, eased by `easing`: a
|
|
100
|
+
* layer coming in fades in as it slides the last stretch to its place; one going out keeps
|
|
101
|
+
* moving the same way as it fades. A spring's step lasts as long as the spring takes to settle,
|
|
102
|
+
* so fitted into it the spring keeps its own pace.
|
|
100
103
|
*/
|
|
101
|
-
function
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
+
function layerAnimationTracks(animation, easing, seconds) {
|
|
105
|
+
const coming = animation.phase === "IN";
|
|
106
|
+
const track = (from, to) => ({
|
|
107
|
+
operation: "SET",
|
|
108
|
+
keyframes: [{
|
|
109
|
+
time: 0,
|
|
110
|
+
value: from,
|
|
111
|
+
easing
|
|
112
|
+
}, {
|
|
113
|
+
time: seconds,
|
|
114
|
+
value: to,
|
|
115
|
+
easing
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
const shown = (value) => ({
|
|
119
|
+
type: "FLOAT",
|
|
120
|
+
value
|
|
121
|
+
});
|
|
122
|
+
const tracks = { opacity: coming ? track(shown(0), shown(1)) : track(shown(1), shown(0)) };
|
|
123
|
+
if (animation.style === "FADE") return tracks;
|
|
124
|
+
const direction = LAYER_DIRECTIONS[animation.style];
|
|
125
|
+
const at = (offset) => ({
|
|
126
|
+
type: "VECTOR",
|
|
127
|
+
value: along(direction, offset)
|
|
128
|
+
});
|
|
129
|
+
tracks["motion/translation"] = coming ? track(at(-300), at(0)) : track(at(0), at(300));
|
|
130
|
+
return tracks;
|
|
131
|
+
}
|
|
132
|
+
/** Where an animating layer is `elapsed` seconds into the `seconds` its step plays. */
|
|
133
|
+
function layerFrameAt(animation, easing, elapsed, seconds) {
|
|
134
|
+
const tracks = layerAnimationTracks(animation, easing, seconds);
|
|
135
|
+
const opacity = trackValueAt(tracks.opacity, elapsed);
|
|
136
|
+
const move = animation.style === "FADE" ? null : trackValueAt(tracks["motion/translation"], elapsed);
|
|
137
|
+
const offset = move?.type === "VECTOR" ? move.value : {
|
|
104
138
|
x: 0,
|
|
105
|
-
y: 0
|
|
106
|
-
opacity
|
|
139
|
+
y: 0
|
|
107
140
|
};
|
|
108
|
-
const offset = 300 * (animation.phase === "IN" ? position - 1 : position);
|
|
109
141
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
142
|
+
x: offset.x,
|
|
143
|
+
y: offset.y,
|
|
144
|
+
opacity: clamp01(opacity?.type === "FLOAT" ? opacity.value : 1)
|
|
112
145
|
};
|
|
113
146
|
}
|
|
114
147
|
/** Where a layer is drawn before its step has played, or after. */
|
|
@@ -182,7 +215,6 @@ function layerAnimationDirection(style) {
|
|
|
182
215
|
function layerAnimationStyle(direction) {
|
|
183
216
|
return direction ? `SLIDE_FROM_${SIDES[direction]}` : "FADE";
|
|
184
217
|
}
|
|
185
|
-
|
|
186
|
-
export { LAYER_SLIDE_DISTANCE, MOTION_DIRECTIONS, SLIDE_TRANSITION_KINDS, layerAnimationDirection, layerAnimationStyle, layerAtRest, layerFrame, transitionDirection, transitionFrames, transitionKind, transitionStyle };
|
|
218
|
+
export { LAYER_SLIDE_DISTANCE, MOTION_DIRECTIONS, SLIDE_TRANSITION_KINDS, layerAnimationDirection, layerAnimationStyle, layerAnimationTracks, layerAtRest, layerFrameAt, transitionDirection, transitionFrames, transitionKind, transitionStyle };
|
|
187
219
|
|
|
188
220
|
//# sourceMappingURL=playback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playback.js","names":[],"sources":["../../src/slides/playback.ts"],"sourcesContent":["import type { Vector } from '../primitives'\nimport type { LayerAnimation, SlideTransitionStyle } from './types'\n\n/**\n * How a slide is drawn at a moment of a transition: moved by fractions of its own width and\n * height, faded, and darkened towards black.\n */\nexport interface SlideFrame {\n x: number\n y: number\n opacity: number\n /** How dark: 0 is the slide as it is, 1 black. */\n dim: number\n}\n\n/** The two slides of a transition, the one drawn first below the other. */\nexport interface TransitionFrames {\n from: SlideFrame\n to: SlideFrame\n /** Which slide is drawn on top. */\n above: 'from' | 'to'\n}\n\n/** How far the slide underneath moves in Slide in and Slide out, as Figma moves it. */\nconst PARALLAX = 0.25\n/** How dark the slide underneath gets in Slide in and Slide out. */\nconst UNDERNEATH_DIM = 0.5\n\ntype Direction = readonly [number, number]\nconst RIGHTWARDS: Direction = [1, 0]\nconst LEFTWARDS: Direction = [-1, 0]\nconst DOWNWARDS: Direction = [0, 1]\nconst UPWARDS: Direction = [0, -1]\n\n/**\n * The way a style moves its slides. A `FROM` side is the side the slide comes from. Figma's `OUT_TO`\n * names are mirrored: its panel shows SLIDE_OUT_TO_LEFT as → and plays it moving right.\n */\nfunction directionOf(style: SlideTransitionStyle): Direction {\n if (style.endsWith('FROM_LEFT') || style.endsWith('OUT_TO_LEFT')) return RIGHTWARDS\n if (style.endsWith('FROM_RIGHT') || style.endsWith('OUT_TO_RIGHT')) return LEFTWARDS\n if (style.endsWith('FROM_TOP') || style.endsWith('OUT_TO_TOP')) return DOWNWARDS\n return UPWARDS\n}\n\nfunction clamp01(value: number): number {\n return Math.min(1, Math.max(0, value))\n}\n\n/** A direction scaled by `amount`, with no negative zero where the direction has no part. */\nfunction along(direction: Direction, amount: number): Vector {\n return { x: direction[0] * amount || 0, y: direction[1] * amount || 0 }\n}\n\nfunction frame(direction: Direction, offset: number, dim = 0, opacity = 1): SlideFrame {\n return { ...along(direction, offset), opacity, dim: clamp01(dim) }\n}\n\nconst STILL: SlideFrame = { x: 0, y: 0, opacity: 1, dim: 0 }\n\n/**\n * Where the slides of a transition are when its easing is at `position`: 0 at the start, 1 at the\n * end, past 1 while a spring overshoots. Smart animate plays as Dissolve for now.\n */\nexport function transitionFrames(style: SlideTransitionStyle, position: number): TransitionFrames {\n const p = position\n if (style === 'NONE') return { from: STILL, to: STILL, above: 'to' }\n if (style === 'DISSOLVE' || style === 'SMART_ANIMATE')\n return { from: STILL, to: { ...STILL, opacity: clamp01(p) }, above: 'to' }\n const direction = directionOf(style)\n if (style.startsWith('PUSH_'))\n return { from: frame(direction, p), to: frame(direction, p - 1), above: 'to' }\n if (style.startsWith('MOVE_FROM_'))\n return { from: STILL, to: frame(direction, p - 1), above: 'to' }\n if (style.startsWith('MOVE_OUT_')) return { from: frame(direction, p), to: STILL, above: 'from' }\n if (style.startsWith('SLIDE_FROM_')) {\n return {\n from: frame(direction, PARALLAX * p, UNDERNEATH_DIM * p),\n to: frame(direction, p - 1),\n above: 'to'\n }\n }\n return {\n from: frame(direction, p),\n to: frame(direction, PARALLAX * (p - 1), UNDERNEATH_DIM * (1 - p)),\n above: 'from'\n }\n}\n\n/** How far, in slide pixels, a layer slides on or off, whatever its size, as in Figma. */\nexport const LAYER_SLIDE_DISTANCE = 300\n\n/** Where a layer animating onto or off its slide is drawn, relative to where it is. */\nexport interface LayerFrame {\n x: number\n y: number\n opacity: number\n}\n\nconst LAYER_DIRECTIONS: Record<Exclude<LayerAnimation['style'], 'FADE'>, Direction> = {\n SLIDE_FROM_LEFT: RIGHTWARDS,\n SLIDE_FROM_RIGHT: LEFTWARDS,\n SLIDE_FROM_TOP: DOWNWARDS,\n SLIDE_FROM_BOTTOM: UPWARDS\n}\n\n/**\n * Where an animating layer is when its easing is at `position`. A layer coming in fades in as it\n * slides the last stretch to its place; one going out keeps moving the same way as it fades.\n */\nexport function layerFrame(\n animation: Pick<LayerAnimation, 'style' | 'phase'>,\n position: number\n): LayerFrame {\n const shown = animation.phase === 'IN' ? position : 1 - position\n const opacity = clamp01(shown)\n if (animation.style === 'FADE') return { x: 0, y: 0, opacity }\n const offset = LAYER_SLIDE_DISTANCE * (animation.phase === 'IN' ? position - 1 : position)\n return { ...along(LAYER_DIRECTIONS[animation.style], offset), opacity }\n}\n\n/** Where a layer is drawn before its step has played, or after. */\nexport function layerAtRest(animation: Pick<LayerAnimation, 'phase'>, played: boolean): LayerFrame {\n const shown = animation.phase === 'IN' ? played : !played\n return { x: 0, y: 0, opacity: shown ? 1 : 0 }\n}\n\n/** The transitions Figma's panel offers, each but the first three in four directions. */\nexport const SLIDE_TRANSITION_KINDS = [\n 'NONE',\n 'SMART_ANIMATE',\n 'DISSOLVE',\n 'PUSH',\n 'SLIDE_IN',\n 'SLIDE_OUT',\n 'MOVE_IN',\n 'MOVE_OUT'\n] as const\nexport type SlideTransitionKind = (typeof SLIDE_TRANSITION_KINDS)[number]\n\n/** Which way a transition or a layer moves, as Figma's arrows show it. */\nexport const MOTION_DIRECTIONS = ['LEFT', 'RIGHT', 'DOWN', 'UP'] as const\nexport type MotionDirection = (typeof MOTION_DIRECTIONS)[number]\n\n/** The record names' prefix for each kind that moves. */\nconst KIND_PREFIXES = {\n PUSH: 'PUSH_FROM_',\n SLIDE_IN: 'SLIDE_FROM_',\n SLIDE_OUT: 'SLIDE_OUT_TO_',\n MOVE_IN: 'MOVE_FROM_',\n MOVE_OUT: 'MOVE_OUT_TO_'\n} as const\n\n/**\n * The side a record names for a way of moving: what moves rightwards comes from the left, and,\n * as Figma names them, an `OUT_TO_LEFT` moves rightwards too.\n */\nconst SIDES: Record<MotionDirection, 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'> = {\n RIGHT: 'LEFT',\n LEFT: 'RIGHT',\n DOWN: 'TOP',\n UP: 'BOTTOM'\n}\n\nfunction directionName(direction: Direction): MotionDirection {\n if (direction[0] > 0) return 'RIGHT'\n if (direction[0] < 0) return 'LEFT'\n return direction[1] > 0 ? 'DOWN' : 'UP'\n}\n\n/** A style's kind, as Figma's panel lists it. */\nexport function transitionKind(style: SlideTransitionStyle): SlideTransitionKind {\n for (const [kind, prefix] of Object.entries(KIND_PREFIXES))\n if (style.startsWith(prefix)) return kind as SlideTransitionKind\n return style === 'NONE' || style === 'SMART_ANIMATE' ? style : 'DISSOLVE'\n}\n\n/** Which way a style moves its slides, or null for one that does not move them. */\nexport function transitionDirection(style: SlideTransitionStyle): MotionDirection | null {\n return transitionKind(style) in KIND_PREFIXES ? directionName(directionOf(style)) : null\n}\n\n/** The style of a kind moving `direction`; a kind that does not move ignores it. */\nexport function transitionStyle(\n kind: SlideTransitionKind,\n direction: MotionDirection\n): SlideTransitionStyle {\n if (kind === 'NONE' || kind === 'SMART_ANIMATE' || kind === 'DISSOLVE') return kind\n return `${KIND_PREFIXES[kind]}${SIDES[direction]}` as SlideTransitionStyle\n}\n\n/** Which way a layer animation moves its layer, or null for a fade. */\nexport function layerAnimationDirection(style: LayerAnimation['style']): MotionDirection | null {\n return style === 'FADE' ? null : directionName(LAYER_DIRECTIONS[style])\n}\n\n/** The layer animation that slides its layer `direction`, or fades it with null. */\nexport function layerAnimationStyle(direction: MotionDirection | null): LayerAnimation['style'] {\n return direction ? `SLIDE_FROM_${SIDES[direction]}` : 'FADE'\n}\n"],"mappings":";;AAwBA,MAAM,WAAW;;AAEjB,MAAM,iBAAiB;AAGvB,MAAM,aAAwB,CAAC,GAAG,CAAC;AACnC,MAAM,YAAuB,CAAC,IAAI,CAAC;AACnC,MAAM,YAAuB,CAAC,GAAG,CAAC;AAClC,MAAM,UAAqB,CAAC,GAAG,EAAE;;;;;AAMjC,SAAS,YAAY,OAAwC;CAC3D,IAAI,MAAM,SAAS,WAAW,KAAK,MAAM,SAAS,aAAa,GAAG,OAAO;CACzE,IAAI,MAAM,SAAS,YAAY,KAAK,MAAM,SAAS,cAAc,GAAG,OAAO;CAC3E,IAAI,MAAM,SAAS,UAAU,KAAK,MAAM,SAAS,YAAY,GAAG,OAAO;CACvE,OAAO;AACT;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AACvC;;AA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AK,CAAC,IAAI;AACtF;;AAGA,SAAgB,gBACd,MACA,WACsB;CACtB,IAAI,SAAS,UAAU,SAAS,mBAAmB,SAAS,YAAY,OAAO;CAC/E,OAAO,GAAG,cAAc,QAAQ,MAAM;AACxC;;AAGA,SAAgB,wBAAwB,OAAwD;CAC9F,OAAO,UAAU,SAAS,OAAO,cAAc,iBAAiB,MAAM;AACxE;;AAGA,SAAgB,oBAAoB,WAA4D;CAC9F,OAAO,YAAY,cAAc,MAAM,eAAe;AACxD"}
|
|
1
|
+
{"version":3,"file":"playback.js","names":[],"sources":["../../src/slides/playback.ts"],"sourcesContent":["import { trackValueAt } from '../motion/evaluate'\nimport type { KeyframeTrack, KeyframeValue } from '../motion/types'\nimport type { Vector } from '../primitives'\nimport type { Easing } from '../types'\nimport type { LayerAnimation, SlideTransitionStyle } from './types'\n\n/**\n * How a slide is drawn at a moment of a transition: moved by fractions of its own width and\n * height, faded, and darkened towards black.\n */\nexport interface SlideFrame {\n x: number\n y: number\n opacity: number\n /** How dark: 0 is the slide as it is, 1 black. */\n dim: number\n}\n\n/** The two slides of a transition, the one drawn first below the other. */\nexport interface TransitionFrames {\n from: SlideFrame\n to: SlideFrame\n /** Which slide is drawn on top. */\n above: 'from' | 'to'\n}\n\n/** How far the slide underneath moves in Slide in and Slide out, as Figma moves it. */\nconst PARALLAX = 0.25\n/** How dark the slide underneath gets in Slide in and Slide out. */\nconst UNDERNEATH_DIM = 0.5\n\ntype Direction = readonly [number, number]\nconst RIGHTWARDS: Direction = [1, 0]\nconst LEFTWARDS: Direction = [-1, 0]\nconst DOWNWARDS: Direction = [0, 1]\nconst UPWARDS: Direction = [0, -1]\n\n/**\n * The way a style moves its slides. A `FROM` side is the side the slide comes from. Figma's `OUT_TO`\n * names are mirrored: its panel shows SLIDE_OUT_TO_LEFT as → and plays it moving right.\n */\nfunction directionOf(style: SlideTransitionStyle): Direction {\n if (style.endsWith('FROM_LEFT') || style.endsWith('OUT_TO_LEFT')) return RIGHTWARDS\n if (style.endsWith('FROM_RIGHT') || style.endsWith('OUT_TO_RIGHT')) return LEFTWARDS\n if (style.endsWith('FROM_TOP') || style.endsWith('OUT_TO_TOP')) return DOWNWARDS\n return UPWARDS\n}\n\nfunction clamp01(value: number): number {\n return Math.min(1, Math.max(0, value))\n}\n\n/** A direction scaled by `amount`, with no negative zero where the direction has no part. */\nfunction along(direction: Direction, amount: number): Vector {\n return { x: direction[0] * amount || 0, y: direction[1] * amount || 0 }\n}\n\nfunction frame(direction: Direction, offset: number, dim = 0, opacity = 1): SlideFrame {\n return { ...along(direction, offset), opacity, dim: clamp01(dim) }\n}\n\nconst STILL: SlideFrame = { x: 0, y: 0, opacity: 1, dim: 0 }\n\n/**\n * Where the slides of a transition are when its easing is at `position`: 0 at the start, 1 at the\n * end, past 1 while a spring overshoots. Smart animate plays as Dissolve for now.\n */\nexport function transitionFrames(style: SlideTransitionStyle, position: number): TransitionFrames {\n const p = position\n if (style === 'NONE') return { from: STILL, to: STILL, above: 'to' }\n if (style === 'DISSOLVE' || style === 'SMART_ANIMATE')\n return { from: STILL, to: { ...STILL, opacity: clamp01(p) }, above: 'to' }\n const direction = directionOf(style)\n if (style.startsWith('PUSH_'))\n return { from: frame(direction, p), to: frame(direction, p - 1), above: 'to' }\n if (style.startsWith('MOVE_FROM_'))\n return { from: STILL, to: frame(direction, p - 1), above: 'to' }\n if (style.startsWith('MOVE_OUT_')) return { from: frame(direction, p), to: STILL, above: 'from' }\n if (style.startsWith('SLIDE_FROM_')) {\n return {\n from: frame(direction, PARALLAX * p, UNDERNEATH_DIM * p),\n to: frame(direction, p - 1),\n above: 'to'\n }\n }\n return {\n from: frame(direction, p),\n to: frame(direction, PARALLAX * (p - 1), UNDERNEATH_DIM * (1 - p)),\n above: 'from'\n }\n}\n\n/** How far, in slide pixels, a layer slides on or off, whatever its size, as in Figma. */\nexport const LAYER_SLIDE_DISTANCE = 300\n\n/** Where a layer animating onto or off its slide is drawn, relative to where it is. */\nexport interface LayerFrame {\n x: number\n y: number\n opacity: number\n}\n\nconst LAYER_DIRECTIONS: Record<Exclude<LayerAnimation['style'], 'FADE'>, Direction> = {\n SLIDE_FROM_LEFT: RIGHTWARDS,\n SLIDE_FROM_RIGHT: LEFTWARDS,\n SLIDE_FROM_TOP: DOWNWARDS,\n SLIDE_FROM_BOTTOM: UPWARDS\n}\n\n/**\n * A layer's animation as keyframe tracks over the `seconds` its step plays, eased by `easing`: a\n * layer coming in fades in as it slides the last stretch to its place; one going out keeps\n * moving the same way as it fades. A spring's step lasts as long as the spring takes to settle,\n * so fitted into it the spring keeps its own pace.\n */\nexport function layerAnimationTracks(\n animation: Pick<LayerAnimation, 'style' | 'phase'>,\n easing: Easing,\n seconds: number\n): Record<string, KeyframeTrack> {\n const coming = animation.phase === 'IN'\n const track = (from: KeyframeValue, to: KeyframeValue): KeyframeTrack => ({\n operation: 'SET',\n keyframes: [\n { time: 0, value: from, easing },\n { time: seconds, value: to, easing }\n ]\n })\n const shown = (value: number): KeyframeValue => ({ type: 'FLOAT', value })\n const tracks: Record<string, KeyframeTrack> = {\n opacity: coming ? track(shown(0), shown(1)) : track(shown(1), shown(0))\n }\n if (animation.style === 'FADE') return tracks\n const direction = LAYER_DIRECTIONS[animation.style]\n const at = (offset: number): KeyframeValue => ({\n type: 'VECTOR',\n value: along(direction, offset)\n })\n tracks['motion/translation'] = coming\n ? track(at(-LAYER_SLIDE_DISTANCE), at(0))\n : track(at(0), at(LAYER_SLIDE_DISTANCE))\n return tracks\n}\n\n/** Where an animating layer is `elapsed` seconds into the `seconds` its step plays. */\nexport function layerFrameAt(\n animation: Pick<LayerAnimation, 'style' | 'phase'>,\n easing: Easing,\n elapsed: number,\n seconds: number\n): LayerFrame {\n const tracks = layerAnimationTracks(animation, easing, seconds)\n const opacity = trackValueAt(tracks.opacity, elapsed)\n const move =\n animation.style === 'FADE' ? null : trackValueAt(tracks['motion/translation'], elapsed)\n const offset = move?.type === 'VECTOR' ? move.value : { x: 0, y: 0 }\n return {\n x: offset.x,\n y: offset.y,\n opacity: clamp01(opacity?.type === 'FLOAT' ? opacity.value : 1)\n }\n}\n\n/** Where a layer is drawn before its step has played, or after. */\nexport function layerAtRest(animation: Pick<LayerAnimation, 'phase'>, played: boolean): LayerFrame {\n const shown = animation.phase === 'IN' ? played : !played\n return { x: 0, y: 0, opacity: shown ? 1 : 0 }\n}\n\n/** The transitions Figma's panel offers, each but the first three in four directions. */\nexport const SLIDE_TRANSITION_KINDS = [\n 'NONE',\n 'SMART_ANIMATE',\n 'DISSOLVE',\n 'PUSH',\n 'SLIDE_IN',\n 'SLIDE_OUT',\n 'MOVE_IN',\n 'MOVE_OUT'\n] as const\nexport type SlideTransitionKind = (typeof SLIDE_TRANSITION_KINDS)[number]\n\n/** Which way a transition or a layer moves, as Figma's arrows show it. */\nexport const MOTION_DIRECTIONS = ['LEFT', 'RIGHT', 'DOWN', 'UP'] as const\nexport type MotionDirection = (typeof MOTION_DIRECTIONS)[number]\n\n/** The record names' prefix for each kind that moves. */\nconst KIND_PREFIXES = {\n PUSH: 'PUSH_FROM_',\n SLIDE_IN: 'SLIDE_FROM_',\n SLIDE_OUT: 'SLIDE_OUT_TO_',\n MOVE_IN: 'MOVE_FROM_',\n MOVE_OUT: 'MOVE_OUT_TO_'\n} as const\n\n/**\n * The side a record names for a way of moving: what moves rightwards comes from the left, and,\n * as Figma names them, an `OUT_TO_LEFT` moves rightwards too.\n */\nconst SIDES: Record<MotionDirection, 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'> = {\n RIGHT: 'LEFT',\n LEFT: 'RIGHT',\n DOWN: 'TOP',\n UP: 'BOTTOM'\n}\n\nfunction directionName(direction: Direction): MotionDirection {\n if (direction[0] > 0) return 'RIGHT'\n if (direction[0] < 0) return 'LEFT'\n return direction[1] > 0 ? 'DOWN' : 'UP'\n}\n\n/** A style's kind, as Figma's panel lists it. */\nexport function transitionKind(style: SlideTransitionStyle): SlideTransitionKind {\n for (const [kind, prefix] of Object.entries(KIND_PREFIXES))\n if (style.startsWith(prefix)) return kind as SlideTransitionKind\n return style === 'NONE' || style === 'SMART_ANIMATE' ? style : 'DISSOLVE'\n}\n\n/** Which way a style moves its slides, or null for one that does not move them. */\nexport function transitionDirection(style: SlideTransitionStyle): MotionDirection | null {\n return transitionKind(style) in KIND_PREFIXES ? directionName(directionOf(style)) : null\n}\n\n/** The style of a kind moving `direction`; a kind that does not move ignores it. */\nexport function transitionStyle(\n kind: SlideTransitionKind,\n direction: MotionDirection\n): SlideTransitionStyle {\n if (kind === 'NONE' || kind === 'SMART_ANIMATE' || kind === 'DISSOLVE') return kind\n return `${KIND_PREFIXES[kind]}${SIDES[direction]}` as SlideTransitionStyle\n}\n\n/** Which way a layer animation moves its layer, or null for a fade. */\nexport function layerAnimationDirection(style: LayerAnimation['style']): MotionDirection | null {\n return style === 'FADE' ? null : directionName(LAYER_DIRECTIONS[style])\n}\n\n/** The layer animation that slides its layer `direction`, or fades it with null. */\nexport function layerAnimationStyle(direction: MotionDirection | null): LayerAnimation['style'] {\n return direction ? `SLIDE_FROM_${SIDES[direction]}` : 'FADE'\n}\n"],"mappings":";;;AA2BA,MAAM,WAAW;;AAEjB,MAAM,iBAAiB;AAGvB,MAAM,aAAwB,CAAC,GAAG,CAAC;AACnC,MAAM,YAAuB,CAAC,IAAI,CAAC;AACnC,MAAM,YAAuB,CAAC,GAAG,CAAC;AAClC,MAAM,UAAqB,CAAC,GAAG,EAAE;;;;;AAMjC,SAAS,YAAY,OAAwC;CAC3D,IAAI,MAAM,SAAS,WAAW,KAAK,MAAM,SAAS,aAAa,GAAG,OAAO;CACzE,IAAI,MAAM,SAAS,YAAY,KAAK,MAAM,SAAS,cAAc,GAAG,OAAO;CAC3E,IAAI,MAAM,SAAS,UAAU,KAAK,MAAM,SAAS,YAAY,GAAG,OAAO;CACvE,OAAO;AACT;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAC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