@pairdraw/core 0.19.2 → 0.20.0
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/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +73 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -1
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +22 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +27 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +168 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +6 -0
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/index.d.ts +5 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +6 -1
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +31 -3
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +1 -53
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +174 -36
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +6 -3
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -1
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +110 -8
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/read-commands.js +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +10 -8
- package/dist/text/index.js +3 -1
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.js +3 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +26 -5
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +2 -1
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -3
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.js +1 -0
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/pipeline.ts +19 -1
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +40 -3
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/index.ts +10 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/surface.ts +6 -2
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/fig/export/patch/index.ts +8 -0
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +12 -1
- package/src/io/formats/svg/defs.ts +4 -72
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +278 -46
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout.ts +2 -0
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +107 -10
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PrototypeAction,
|
|
3
|
+
PrototypeReaction,
|
|
4
|
+
PrototypeTransition,
|
|
5
|
+
PrototypeTriggerType,
|
|
6
|
+
SceneGraph,
|
|
7
|
+
SceneNode
|
|
8
|
+
} from '@pairdraw/scene-graph'
|
|
9
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
10
|
+
|
|
11
|
+
import { framesOnPage } from './frames'
|
|
12
|
+
import { playHitTest } from './hit'
|
|
13
|
+
import { effectiveReactions } from './reactions'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The action a reaction runs: its first, which the prototype panel edits alone in this version, as
|
|
17
|
+
* Figma's first action row; `actions` keeps the array the `.fig` model and Figma's plugin API use.
|
|
18
|
+
*/
|
|
19
|
+
export function primaryAction(reaction: PrototypeReaction): PrototypeAction | null {
|
|
20
|
+
return reaction.actions[0] ?? null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Where play is: the frame it shows, the frame it started from, and the frames it came through. */
|
|
24
|
+
export interface PlaySession {
|
|
25
|
+
/** The base frame under any open overlays. */
|
|
26
|
+
frameId: string
|
|
27
|
+
/** The frame play started from, which Restart returns to. */
|
|
28
|
+
startFrameId: string
|
|
29
|
+
/** Frames shown before this one, oldest first; Back returns to the last. */
|
|
30
|
+
history: string[]
|
|
31
|
+
/** Overlay frames open over the base frame, bottom first; the last is the one shown. */
|
|
32
|
+
overlays: string[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One reaction a pointer or a timer runs: the layer it runs from, its action, and the transition
|
|
37
|
+
* that action asked for.
|
|
38
|
+
*/
|
|
39
|
+
export interface PlayClick {
|
|
40
|
+
/** The layer whose reaction runs, which a Change to switches the instance of. */
|
|
41
|
+
sourceId: string
|
|
42
|
+
action: PrototypeAction
|
|
43
|
+
transition: PrototypeTransition | null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The frame play starts from: the selected frame, or the frame holding the selection; otherwise
|
|
48
|
+
* the page's first frame. Null when the page has no frames, so there is nothing to play.
|
|
49
|
+
*/
|
|
50
|
+
export function startFrame(graph: SceneGraph, pageId: string, selectedIds: ReadonlySet<string>) {
|
|
51
|
+
const frames = framesOnPage(graph, pageId)
|
|
52
|
+
const ids = new Set(frames.map((frame) => frame.id))
|
|
53
|
+
for (const id of selectedIds) {
|
|
54
|
+
if (ids.has(id)) return id
|
|
55
|
+
const frame = topFrameOf(graph, graph.getNode(id))
|
|
56
|
+
if (frame && ids.has(frame.id)) return frame.id
|
|
57
|
+
}
|
|
58
|
+
return frames[0]?.id ?? null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The top-level frame a node sits in: the page's direct child above it, when that child is a
|
|
63
|
+
* frame. Play fits and hit-tests top-level frames, as Figma's presentation does.
|
|
64
|
+
*/
|
|
65
|
+
export function topFrameOf(
|
|
66
|
+
graph: SceneGraph,
|
|
67
|
+
node: SceneNode | null | undefined
|
|
68
|
+
): SceneNode | null {
|
|
69
|
+
let top = node ?? null
|
|
70
|
+
while (top?.parentId) {
|
|
71
|
+
const parent = graph.getNode(top.parentId)
|
|
72
|
+
if (!parent || parent.type === 'CANVAS') break
|
|
73
|
+
top = parent
|
|
74
|
+
}
|
|
75
|
+
return top?.type === 'FRAME' ? top : null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Starts playing the page from `frameId` with no history behind it. */
|
|
79
|
+
export function startSession(frameId: string): PlaySession {
|
|
80
|
+
return { frameId, startFrameId: frameId, history: [], overlays: [] }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The frame the stage shows: the top overlay when one is open, else the base frame. */
|
|
84
|
+
export function shownFrame(session: PlaySession): string {
|
|
85
|
+
return session.overlays.at(-1) ?? session.frameId
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Plays again from where the session started, as Restart does. */
|
|
89
|
+
export function restartSession(session: PlaySession): PlaySession {
|
|
90
|
+
return startSession(session.startFrameId)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The reaction a click at a document point runs: the topmost layer under the point inside the
|
|
95
|
+
* shown frame that has a reaction to `trigger`, over its whole box, or that shows a paint there,
|
|
96
|
+
* and then its nearest ancestor with one, up to the frame, with the reaction's first action. An
|
|
97
|
+
* unpainted layer without one lets the click through. An instance runs the reactions of the variant it shows, and a frame
|
|
98
|
+
* play scrolled finds its layers where they are drawn.
|
|
99
|
+
*/
|
|
100
|
+
export function reactionAt(
|
|
101
|
+
graph: SceneGraph,
|
|
102
|
+
session: PlaySession,
|
|
103
|
+
x: number,
|
|
104
|
+
y: number,
|
|
105
|
+
trigger: PrototypeTriggerType = 'ON_CLICK',
|
|
106
|
+
scroll?: ReadonlyMap<string, Vector>
|
|
107
|
+
): PlayClick | null {
|
|
108
|
+
// A click on the frame's own background is the frame's, not a layer's; one outside it hits
|
|
109
|
+
// nothing.
|
|
110
|
+
const reacts = (layer: SceneNode) =>
|
|
111
|
+
effectiveReactions(graph, layer).some((reaction) => reaction.trigger.type === trigger)
|
|
112
|
+
let node = playHitTest(graph, shownFrame(session), x, y, scroll, reacts)
|
|
113
|
+
while (node) {
|
|
114
|
+
const reaction = effectiveReactions(graph, node).find(
|
|
115
|
+
(candidate) => candidate.trigger.type === trigger
|
|
116
|
+
)
|
|
117
|
+
const action = reaction ? primaryAction(reaction) : null
|
|
118
|
+
if (action) {
|
|
119
|
+
return {
|
|
120
|
+
sourceId: node.id,
|
|
121
|
+
action,
|
|
122
|
+
transition: action.type === 'NODE' ? action.transition : null
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (node.id === shownFrame(session)) return null
|
|
126
|
+
node = node.parentId ? (graph.getNode(node.parentId) ?? null) : null
|
|
127
|
+
}
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The session after an action runs. `NAVIGATE` moves to its frame and remembers this one for
|
|
133
|
+
* Back; `OVERLAY` opens a frame over the screen and `CLOSE` takes the top one away; `BACK`
|
|
134
|
+
* returns to the previous screen and drops overlays, which are not history entries; an action
|
|
135
|
+
* this version cannot show leaves the session as it is.
|
|
136
|
+
*/
|
|
137
|
+
export function step(
|
|
138
|
+
graph: SceneGraph,
|
|
139
|
+
session: PlaySession,
|
|
140
|
+
action: PrototypeAction
|
|
141
|
+
): PlaySession {
|
|
142
|
+
if (action.type === 'BACK') {
|
|
143
|
+
const previous = session.history.at(-1)
|
|
144
|
+
if (!previous) return session
|
|
145
|
+
return {
|
|
146
|
+
...session,
|
|
147
|
+
frameId: previous,
|
|
148
|
+
history: session.history.slice(0, -1),
|
|
149
|
+
overlays: []
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (action.type === 'CLOSE') {
|
|
153
|
+
if (session.overlays.length === 0) return session
|
|
154
|
+
return { ...session, overlays: session.overlays.slice(0, -1) }
|
|
155
|
+
}
|
|
156
|
+
if (!action.nodeId) return session
|
|
157
|
+
if (topFrameOf(graph, graph.getNode(action.nodeId))?.id !== action.nodeId) return session
|
|
158
|
+
if (action.navigation === 'OVERLAY') {
|
|
159
|
+
if (action.nodeId === shownFrame(session)) return session
|
|
160
|
+
return { ...session, overlays: [...session.overlays, action.nodeId] }
|
|
161
|
+
}
|
|
162
|
+
if (action.nodeId === session.frameId) return session
|
|
163
|
+
return {
|
|
164
|
+
...session,
|
|
165
|
+
frameId: action.nodeId,
|
|
166
|
+
history: [...session.history, session.frameId],
|
|
167
|
+
overlays: []
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The `AFTER_TIMEOUT` reactions of the frame being shown, with their delays in milliseconds:
|
|
173
|
+
* what the stage schedules whenever the shown frame changes.
|
|
174
|
+
*/
|
|
175
|
+
export function timeoutReactions(
|
|
176
|
+
graph: SceneGraph,
|
|
177
|
+
session: PlaySession
|
|
178
|
+
): { action: PrototypeAction; delayMs: number }[] {
|
|
179
|
+
const node = graph.getNode(shownFrame(session))
|
|
180
|
+
if (!node) return []
|
|
181
|
+
return node.prototypeReactions
|
|
182
|
+
.filter((reaction) => reaction.trigger.type === 'AFTER_TIMEOUT')
|
|
183
|
+
.map((reaction) => ({
|
|
184
|
+
action: primaryAction(reaction),
|
|
185
|
+
delayMs: reaction.trigger.delay * 1000
|
|
186
|
+
}))
|
|
187
|
+
.filter((entry): entry is { action: PrototypeAction; delayMs: number } => entry.action !== null)
|
|
188
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { Fill, PrototypeEasingType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
|
|
4
|
+
import { extractPageContext, findPageId } from '#core/io/subgraph'
|
|
5
|
+
import { easingAt } from '#core/prototype/easing'
|
|
6
|
+
import type { PlaySceneView } from '#core/prototype/scene'
|
|
7
|
+
|
|
8
|
+
import { matchLayers } from './match'
|
|
9
|
+
|
|
10
|
+
/** A top-level frame and the graph play reads it from: the document, or play's copy of it. */
|
|
11
|
+
export interface PlayFrame {
|
|
12
|
+
graph: SceneGraph
|
|
13
|
+
rootId: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A Smart animate from one frame to another, drawn as a view of the destination frame: a private
|
|
18
|
+
* copy of it, which `seek` poses at a moment of the transition. The canvas draws `graph` in place
|
|
19
|
+
* of `rootId` and redraws `touched` whenever `revision` grows; a recording draws it the same way.
|
|
20
|
+
*/
|
|
21
|
+
export interface SmartAnimation extends PlaySceneView {
|
|
22
|
+
/** The destination frame, which the copy draws in its place. */
|
|
23
|
+
readonly rootId: string
|
|
24
|
+
/**
|
|
25
|
+
* Poses the copy `progress` of the way through the transition's time, from 0 to 1, eased as the
|
|
26
|
+
* transition asks. Writes only the layers that change.
|
|
27
|
+
*/
|
|
28
|
+
seek(progress: number): void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The numbers Smart animate moves from one layer's value to its match's. */
|
|
32
|
+
const ANIMATED_FIELDS = [
|
|
33
|
+
'x',
|
|
34
|
+
'y',
|
|
35
|
+
'width',
|
|
36
|
+
'height',
|
|
37
|
+
'rotation',
|
|
38
|
+
'opacity',
|
|
39
|
+
'cornerRadius',
|
|
40
|
+
'topLeftRadius',
|
|
41
|
+
'topRightRadius',
|
|
42
|
+
'bottomRightRadius',
|
|
43
|
+
'bottomLeftRadius'
|
|
44
|
+
] as const satisfies readonly (keyof SceneNode)[]
|
|
45
|
+
|
|
46
|
+
type AnimatedField = (typeof ANIMATED_FIELDS)[number]
|
|
47
|
+
|
|
48
|
+
/** One field moving from `from` to `to`. */
|
|
49
|
+
interface NumberTrack {
|
|
50
|
+
field: AnimatedField
|
|
51
|
+
from: number
|
|
52
|
+
to: number
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A layer of the copy and what moves on it: numbers, and solid fills whose colours blend. */
|
|
56
|
+
interface LayerTrack {
|
|
57
|
+
id: string
|
|
58
|
+
numbers: NumberTrack[]
|
|
59
|
+
fills: { from: readonly Fill[]; to: readonly Fill[] } | null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A copy's own id for a layer of the start frame that fades out, which never names a real one. */
|
|
63
|
+
function leavingId(id: string): string {
|
|
64
|
+
return `smart-animate:${id}`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function lerp(from: number, to: number, amount: number): number {
|
|
68
|
+
return from + (to - from) * amount
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Wraps an angle into (-180, 180], the range a layer's rotation keeps. */
|
|
72
|
+
function wrapAngle(degrees: number): number {
|
|
73
|
+
const wrapped = ((degrees % 360) + 360) % 360
|
|
74
|
+
return wrapped > 180 ? wrapped - 360 : wrapped
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function blend(from: Color, to: Color, amount: number): Color {
|
|
78
|
+
return {
|
|
79
|
+
r: lerp(from.r, to.r, amount),
|
|
80
|
+
g: lerp(from.g, to.g, amount),
|
|
81
|
+
b: lerp(from.b, to.b, amount),
|
|
82
|
+
a: lerp(from.a, to.a, amount)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The fills to blend between two layers: lists of the same length whose fills are solid at the
|
|
88
|
+
* same places. Others, and fills that do not differ, take the destination's at once.
|
|
89
|
+
*/
|
|
90
|
+
function fillTrack(from: readonly Fill[], to: readonly Fill[]): LayerTrack['fills'] {
|
|
91
|
+
if (from.length !== to.length || from.length === 0) return null
|
|
92
|
+
let differs = false
|
|
93
|
+
for (const [index, fill] of to.entries()) {
|
|
94
|
+
const start = from.at(index)
|
|
95
|
+
if (start?.type !== 'SOLID' || fill.type !== 'SOLID') return null
|
|
96
|
+
const { r, g, b, a } = start.color
|
|
97
|
+
const end = fill.color
|
|
98
|
+
if (
|
|
99
|
+
r !== end.r ||
|
|
100
|
+
g !== end.g ||
|
|
101
|
+
b !== end.b ||
|
|
102
|
+
a !== end.a ||
|
|
103
|
+
start.opacity !== fill.opacity
|
|
104
|
+
) {
|
|
105
|
+
differs = true
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return differs ? { from, to } : null
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function blendFills(track: NonNullable<LayerTrack['fills']>, amount: number): Fill[] {
|
|
112
|
+
return track.to.map((fill, index) => {
|
|
113
|
+
const start = track.from.at(index)
|
|
114
|
+
if (!start) return fill
|
|
115
|
+
return {
|
|
116
|
+
...fill,
|
|
117
|
+
color: blend(start.color, fill.color, amount),
|
|
118
|
+
opacity: lerp(start.opacity, fill.opacity, amount)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** What moves on a matched layer, or null when nothing does. Rotation turns the short way. */
|
|
124
|
+
function pairTrack(from: SceneNode, to: SceneNode, fields: readonly AnimatedField[]) {
|
|
125
|
+
const numbers = fields.flatMap((field) => {
|
|
126
|
+
const start = from[field]
|
|
127
|
+
const end = to[field]
|
|
128
|
+
if (start === end) return []
|
|
129
|
+
// Rotation lives in (-180, 180]; across ±180 the short way is under half a turn.
|
|
130
|
+
const delta = field === 'rotation' ? ((((end - start) % 360) + 540) % 360) - 180 : end - start
|
|
131
|
+
return [{ field, from: start, to: start + delta }]
|
|
132
|
+
})
|
|
133
|
+
const fills = fillTrack(from.fills, to.fills)
|
|
134
|
+
return numbers.length > 0 || fills ? { id: to.id, numbers, fills } : null
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Copies a start-frame layer that fades out, with all it holds, under `parentId` in the copy at
|
|
139
|
+
* `index`, under ids of its own so it never shares a cached drawing with a real layer.
|
|
140
|
+
*/
|
|
141
|
+
function carryLeaving(
|
|
142
|
+
from: SceneGraph,
|
|
143
|
+
graph: SceneGraph,
|
|
144
|
+
id: string,
|
|
145
|
+
parentId: string,
|
|
146
|
+
index: number
|
|
147
|
+
): string | null {
|
|
148
|
+
const parent = graph.getNode(parentId)
|
|
149
|
+
const source = from.getNode(id)
|
|
150
|
+
if (!parent || !source) return null
|
|
151
|
+
const copy = (node: SceneNode, copyParentId: string): string => {
|
|
152
|
+
const cloned = structuredClone(node)
|
|
153
|
+
cloned.id = leavingId(node.id)
|
|
154
|
+
cloned.parentId = copyParentId
|
|
155
|
+
cloned.childIds = node.childIds.flatMap((childId) => {
|
|
156
|
+
const child = from.getNode(childId)
|
|
157
|
+
return child ? [copy(child, cloned.id)] : []
|
|
158
|
+
})
|
|
159
|
+
graph.nodes.set(cloned.id, cloned)
|
|
160
|
+
return cloned.id
|
|
161
|
+
}
|
|
162
|
+
const copied = copy(source, parent.id)
|
|
163
|
+
const at = Math.min(index, parent.childIds.length)
|
|
164
|
+
parent.childIds = [...parent.childIds.slice(0, at), copied, ...parent.childIds.slice(at)]
|
|
165
|
+
return copied
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** A fade of one layer's opacity, or null for a layer already invisible. */
|
|
169
|
+
function fadeTrack(id: string, from: number, to: number): LayerTrack | null {
|
|
170
|
+
return from === to ? null : { id, numbers: [{ field: 'opacity', from, to }], fills: null }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* What moves in `graph`, the copy of the destination frame `rootId`: its fill, the layers that
|
|
175
|
+
* match the start frame's, the destination's layers that fade in, and the start frame's that fade
|
|
176
|
+
* out, which this carries into the copy under the match of their parent.
|
|
177
|
+
*/
|
|
178
|
+
function animationTracks(from: PlayFrame, graph: SceneGraph, rootId: string): LayerTrack[] {
|
|
179
|
+
const match = matchLayers(from.graph, from.rootId, graph, rootId)
|
|
180
|
+
const tracks: LayerTrack[] = []
|
|
181
|
+
const add = (track: LayerTrack | null) => {
|
|
182
|
+
if (track) tracks.push(track)
|
|
183
|
+
}
|
|
184
|
+
const fromRoot = from.graph.getNode(from.rootId)
|
|
185
|
+
const toRoot = graph.getNode(rootId)
|
|
186
|
+
if (fromRoot && toRoot) add(pairTrack(fromRoot, toRoot, []))
|
|
187
|
+
const matchOf = new Map<string, string>([[from.rootId, rootId]])
|
|
188
|
+
for (const pair of match.pairs) {
|
|
189
|
+
matchOf.set(pair.from, pair.to)
|
|
190
|
+
const start = from.graph.getNode(pair.from)
|
|
191
|
+
const end = graph.getNode(pair.to)
|
|
192
|
+
if (start && end) add(pairTrack(start, end, ANIMATED_FIELDS))
|
|
193
|
+
}
|
|
194
|
+
// A layer hidden at an end draws nothing there, so it needs no fade: one hidden in both frames
|
|
195
|
+
// costs nothing at all, and one hidden at the far end only fades at the end that shows it.
|
|
196
|
+
for (const id of match.entering) {
|
|
197
|
+
const node = graph.getNode(id)
|
|
198
|
+
if (node?.visible) add(fadeTrack(id, 0, node.opacity))
|
|
199
|
+
}
|
|
200
|
+
for (const id of match.leaving) {
|
|
201
|
+
const node = from.graph.getNode(id)
|
|
202
|
+
if (!node?.visible) continue
|
|
203
|
+
const parentId = node.parentId ? matchOf.get(node.parentId) : undefined
|
|
204
|
+
if (!node.parentId || !parentId) continue
|
|
205
|
+
const index = from.graph.getNode(node.parentId)?.childIds.indexOf(id) ?? 0
|
|
206
|
+
const copied = carryLeaving(from.graph, graph, id, parentId, index)
|
|
207
|
+
if (copied) add(fadeTrack(copied, node.opacity, 0))
|
|
208
|
+
}
|
|
209
|
+
graph.clearAbsPosCache()
|
|
210
|
+
return tracks
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A Smart animate from `from` to `to`: a copy of the destination frame in which each layer that
|
|
215
|
+
* matches one of the start frame (`matchLayers`) moves from the start layer's position, size,
|
|
216
|
+
* rotation, opacity, corner radius and solid fill colours to its own, the start frame's layers
|
|
217
|
+
* with no match fade out where they were, and the destination's fade in. The destination frame
|
|
218
|
+
* keeps its place and size and blends its fill. Neither frame changes. Matching and the copy cost
|
|
219
|
+
* one pass when it is made; a step writes only the layers that change.
|
|
220
|
+
*/
|
|
221
|
+
export function createSmartAnimation(
|
|
222
|
+
from: PlayFrame,
|
|
223
|
+
to: PlayFrame,
|
|
224
|
+
easing?: PrototypeEasingType
|
|
225
|
+
): SmartAnimation {
|
|
226
|
+
const pageId = findPageId(to.graph, to.rootId) ?? to.graph.rootId
|
|
227
|
+
const graph = extractPageContext(to.graph, pageId, [to.rootId], { shareTables: true })
|
|
228
|
+
const tracks = animationTracks(from, graph, to.rootId)
|
|
229
|
+
|
|
230
|
+
// A layer's cached drawing holds what it contains, so its frame and the layers between redraw.
|
|
231
|
+
const touched = new Set<string>()
|
|
232
|
+
for (const track of tracks) {
|
|
233
|
+
graph.closest(track.id, (node) => {
|
|
234
|
+
touched.add(node.id)
|
|
235
|
+
return node.id === to.rootId
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function pose(progress: number): void {
|
|
240
|
+
const amount = easingAt(easing, progress)
|
|
241
|
+
for (const track of tracks) {
|
|
242
|
+
const changes: Partial<SceneNode> = {}
|
|
243
|
+
for (const { field, from: start, to: end } of track.numbers) {
|
|
244
|
+
const value = lerp(start, end, amount)
|
|
245
|
+
changes[field] = field === 'rotation' ? wrapAngle(value) : value
|
|
246
|
+
}
|
|
247
|
+
if (track.fills) changes.fills = blendFills(track.fills, amount)
|
|
248
|
+
graph.updateNode(track.id, changes)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Made at its start, so the first drawing shows the start frame's layout.
|
|
253
|
+
pose(0)
|
|
254
|
+
let revision = 0
|
|
255
|
+
return {
|
|
256
|
+
graph,
|
|
257
|
+
rootId: to.rootId,
|
|
258
|
+
touched,
|
|
259
|
+
get revision() {
|
|
260
|
+
return revision
|
|
261
|
+
},
|
|
262
|
+
seek(progress) {
|
|
263
|
+
pose(progress)
|
|
264
|
+
revision += 1
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which layers of two frames Smart animate moves, and which it fades: pairs of a layer in the
|
|
5
|
+
* start frame and its match in the destination, then the start frame's layers with no match and
|
|
6
|
+
* the destination's, each the topmost of its unmatched branch, in layer order.
|
|
7
|
+
*/
|
|
8
|
+
export interface LayerMatch {
|
|
9
|
+
pairs: { from: string; to: string }[]
|
|
10
|
+
leaving: string[]
|
|
11
|
+
entering: string[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Layers that hold others; a frame matches an instance or a group of the same name. */
|
|
15
|
+
const CONTAINERS: ReadonlySet<NodeType> = new Set<NodeType>([
|
|
16
|
+
'FRAME',
|
|
17
|
+
'GROUP',
|
|
18
|
+
'SECTION',
|
|
19
|
+
'COMPONENT',
|
|
20
|
+
'COMPONENT_SET',
|
|
21
|
+
'INSTANCE'
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether two layers of the same name at the same place animate from one to the other. A layer
|
|
26
|
+
* hidden in either frame, a layer of another kind, or text that reads differently crossfades
|
|
27
|
+
* instead, as Figma dissolves what it cannot animate.
|
|
28
|
+
*/
|
|
29
|
+
function animates(from: SceneNode, to: SceneNode): boolean {
|
|
30
|
+
if (!from.visible || !to.visible) return false
|
|
31
|
+
if (from.type !== to.type && !(CONTAINERS.has(from.type) && CONTAINERS.has(to.type))) {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
return from.type !== 'TEXT' || from.text === to.text
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A key per child that names its place among its siblings: its name, and how many siblings before
|
|
39
|
+
* it share that name, so repeated names pair in the order they come.
|
|
40
|
+
*/
|
|
41
|
+
function siblingKeys(children: readonly SceneNode[]): string[] {
|
|
42
|
+
const seen = new Map<string, number>()
|
|
43
|
+
return children.map((child) => {
|
|
44
|
+
const count = seen.get(child.name) ?? 0
|
|
45
|
+
seen.set(child.name, count + 1)
|
|
46
|
+
return `${count}:${child.name}`
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Matches the layers of `fromRootId` to those of `toRootId` as Smart animate does: by name and by
|
|
52
|
+
* place in the hierarchy, so a layer matches the layer of its name under its parent's match, and
|
|
53
|
+
* the n-th of several siblings with one name matches the n-th there. One pass over both frames.
|
|
54
|
+
*/
|
|
55
|
+
export function matchLayers(
|
|
56
|
+
from: SceneGraph,
|
|
57
|
+
fromRootId: string,
|
|
58
|
+
to: SceneGraph,
|
|
59
|
+
toRootId: string
|
|
60
|
+
): LayerMatch {
|
|
61
|
+
const match: LayerMatch = { pairs: [], leaving: [], entering: [] }
|
|
62
|
+
const visit = (fromParentId: string, toParentId: string) => {
|
|
63
|
+
const fromChildren = from.getChildren(fromParentId)
|
|
64
|
+
const toChildren = to.getChildren(toParentId)
|
|
65
|
+
const toKeys = siblingKeys(toChildren)
|
|
66
|
+
const byKey = new Map(toKeys.map((key, index) => [key, toChildren[index]]))
|
|
67
|
+
const taken = new Set<string>()
|
|
68
|
+
const fromKeys = siblingKeys(fromChildren)
|
|
69
|
+
fromChildren.forEach((child, index) => {
|
|
70
|
+
const partner = byKey.get(fromKeys[index] ?? '')
|
|
71
|
+
if (!partner || !animates(child, partner)) {
|
|
72
|
+
match.leaving.push(child.id)
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
taken.add(partner.id)
|
|
76
|
+
match.pairs.push({ from: child.id, to: partner.id })
|
|
77
|
+
visit(child.id, partner.id)
|
|
78
|
+
})
|
|
79
|
+
for (const child of toChildren) {
|
|
80
|
+
if (!taken.has(child.id)) match.entering.push(child.id)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
visit(fromRootId, toRootId)
|
|
84
|
+
return match
|
|
85
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'
|
|
3
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
4
|
+
|
|
5
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
6
|
+
import { withWorldViewport } from '#core/canvas/renderer/picture'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A frame as play shows it, drawn to a PNG: from `graph`, play's copy of a frame it changed, with
|
|
10
|
+
* the offsets play scrolled its frames by. The canvas may be one another pane edits with, so the
|
|
11
|
+
* drawings it keeps by id for the layers play changed (`touched`) are dropped before and after,
|
|
12
|
+
* and neither the snapshot nor that canvas shows the other's version of them. Null when the frame
|
|
13
|
+
* cannot be drawn.
|
|
14
|
+
*/
|
|
15
|
+
export function snapshotPlayFrame(
|
|
16
|
+
renderer: SkiaRenderer,
|
|
17
|
+
graph: SceneGraph,
|
|
18
|
+
frameId: string,
|
|
19
|
+
options: { scale: number; scroll?: ReadonlyMap<string, Vector>; touched?: Iterable<string> }
|
|
20
|
+
): Uint8Array<ArrayBuffer> | null {
|
|
21
|
+
const frame = graph.getNode(frameId)
|
|
22
|
+
if (!frame) return null
|
|
23
|
+
const bounds = getAxisAlignedWorldBounds(frame, graph)
|
|
24
|
+
const width = Math.ceil(bounds.width * options.scale)
|
|
25
|
+
const height = Math.ceil(bounds.height * options.scale)
|
|
26
|
+
if (width <= 0 || height <= 0) return null
|
|
27
|
+
const surface = renderer.ck.MakeSurface(width, height)
|
|
28
|
+
if (!surface) return null
|
|
29
|
+
const touched = [...(options.touched ?? [])]
|
|
30
|
+
const forget = () => {
|
|
31
|
+
for (const id of touched) renderer.invalidateNodePicture(id)
|
|
32
|
+
}
|
|
33
|
+
forget()
|
|
34
|
+
try {
|
|
35
|
+
const canvas = surface.getCanvas()
|
|
36
|
+
canvas.clear(renderer.ck.TRANSPARENT)
|
|
37
|
+
canvas.scale(options.scale, options.scale)
|
|
38
|
+
canvas.translate(-bounds.x, -bounds.y)
|
|
39
|
+
const area = {
|
|
40
|
+
minX: bounds.x,
|
|
41
|
+
minY: bounds.y,
|
|
42
|
+
maxX: bounds.x + bounds.width,
|
|
43
|
+
maxY: bounds.y + bounds.height
|
|
44
|
+
}
|
|
45
|
+
withWorldViewport(renderer, area, () =>
|
|
46
|
+
renderer.renderNode(canvas, graph, frameId, { playing: true, playScroll: options.scroll })
|
|
47
|
+
)
|
|
48
|
+
surface.flush()
|
|
49
|
+
const image = surface.makeImageSnapshot()
|
|
50
|
+
try {
|
|
51
|
+
const bytes = image.encodeToBytes()
|
|
52
|
+
return bytes ? new Uint8Array(bytes) : null
|
|
53
|
+
} finally {
|
|
54
|
+
image.delete()
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
surface.delete()
|
|
58
|
+
forget()
|
|
59
|
+
}
|
|
60
|
+
}
|