@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,104 @@
|
|
|
1
|
+
import { effectiveReactions } from "./reactions.js";
|
|
2
|
+
import { playHitTest } from "./hit.js";
|
|
3
|
+
import { primaryAction } from "./session.js";
|
|
4
|
+
//#region src/prototype/pointer.ts
|
|
5
|
+
/** The triggers the pointer runs by moving over a layer or pressing on it, rather than clicking. */
|
|
6
|
+
const POINTER_TRIGGERS = /* @__PURE__ */ new Set([
|
|
7
|
+
"ON_HOVER",
|
|
8
|
+
"ON_PRESS",
|
|
9
|
+
"MOUSE_ENTER",
|
|
10
|
+
"MOUSE_LEAVE"
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* The layers under a point inside `rootId`, from the frame down to the deepest one `takes` the
|
|
14
|
+
* pointer, any layer unless told otherwise; none outside.
|
|
15
|
+
*/
|
|
16
|
+
function pointerPath(graph, rootId, x, y, scroll, takes) {
|
|
17
|
+
const path = [];
|
|
18
|
+
const deepest = playHitTest(graph, rootId, x, y, scroll, takes);
|
|
19
|
+
if (!deepest) return path;
|
|
20
|
+
graph.closest(deepest.id, (node) => {
|
|
21
|
+
path.unshift(node.id);
|
|
22
|
+
return node.id === rootId;
|
|
23
|
+
});
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
/** The layers a pointer left, innermost first, and those it entered, outermost first. */
|
|
27
|
+
function pathChanges(before, after) {
|
|
28
|
+
let shared = 0;
|
|
29
|
+
while (shared < before.length && shared < after.length && before[shared] === after[shared]) shared += 1;
|
|
30
|
+
return {
|
|
31
|
+
left: before.slice(shared).reverse(),
|
|
32
|
+
entered: after.slice(shared)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether the pointer has left the layer a While hovering reaction ran from: its path in the
|
|
37
|
+
* frame the action opened a variant on, so an overlay covering the pointer does not count.
|
|
38
|
+
*/
|
|
39
|
+
function pointerLeftTrigger(basePath, triggerId) {
|
|
40
|
+
return !basePath.includes(triggerId);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether any layer of `rootId` reacts to the pointer moving over or pressing on it, an instance
|
|
44
|
+
* by its variant; a frame without one is not hit-tested as the pointer moves.
|
|
45
|
+
*/
|
|
46
|
+
function hasPointerTriggers(graph, rootId) {
|
|
47
|
+
const reacts = (id) => {
|
|
48
|
+
const node = graph.getNode(id);
|
|
49
|
+
if (!node) return false;
|
|
50
|
+
return effectiveReactions(graph, node).some((reaction) => POINTER_TRIGGERS.has(reaction.trigger.type)) || node.childIds.some(reacts);
|
|
51
|
+
};
|
|
52
|
+
return reacts(rootId);
|
|
53
|
+
}
|
|
54
|
+
/** A layer's reactions to `trigger`, an instance's from the variant it shows, first action each. */
|
|
55
|
+
function pointerReactions(graph, nodeId, trigger) {
|
|
56
|
+
const node = graph.getNode(nodeId);
|
|
57
|
+
if (!node) return [];
|
|
58
|
+
return effectiveReactions(graph, node).flatMap((reaction) => {
|
|
59
|
+
const action = reaction.trigger.type === trigger ? primaryAction(reaction) : null;
|
|
60
|
+
if (!action) return [];
|
|
61
|
+
return [{
|
|
62
|
+
sourceId: nodeId,
|
|
63
|
+
action,
|
|
64
|
+
transition: action.type === "NODE" ? action.transition : null,
|
|
65
|
+
delayMs: reaction.trigger.delay * 1e3
|
|
66
|
+
}];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* How to undo what a While hovering or While pressing reaction did: a Change to switches back, an
|
|
71
|
+
* overlay it opened closes, a navigation goes back. Null when it changed nothing. `shown` is the
|
|
72
|
+
* graph play shows the frame from after it ran.
|
|
73
|
+
*/
|
|
74
|
+
function revertFor(before, done, { sourceId, action, transition }, shown) {
|
|
75
|
+
if (done.changed) {
|
|
76
|
+
const { rootId, instanceId, from, to } = done.changed;
|
|
77
|
+
return {
|
|
78
|
+
kind: "change",
|
|
79
|
+
watchId: shown.getNode(sourceId) ? sourceId : instanceId,
|
|
80
|
+
rootId,
|
|
81
|
+
instanceId,
|
|
82
|
+
from,
|
|
83
|
+
to,
|
|
84
|
+
transition
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (action.type !== "NODE" || !action.nodeId) return null;
|
|
88
|
+
const after = done.session;
|
|
89
|
+
if (action.navigation === "OVERLAY" && after.overlays.length > before.overlays.length) return {
|
|
90
|
+
kind: "overlay",
|
|
91
|
+
watchId: sourceId,
|
|
92
|
+
frameId: action.nodeId
|
|
93
|
+
};
|
|
94
|
+
if (action.navigation === "NAVIGATE" && after.frameId !== before.frameId) return {
|
|
95
|
+
kind: "back",
|
|
96
|
+
watchId: sourceId,
|
|
97
|
+
frameId: action.nodeId
|
|
98
|
+
};
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { hasPointerTriggers, pathChanges, pointerLeftTrigger, pointerPath, pointerReactions, revertFor };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","names":[],"sources":["../../src/prototype/pointer.ts"],"sourcesContent":["import type {\n PrototypeTransition,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { playHitTest } from './hit'\nimport { effectiveReactions } from './reactions'\nimport type { PlayStep } from './scenes'\nimport { primaryAction, type PlayClick, type PlaySession } from './session'\n\n/** The triggers the pointer runs by moving over a layer or pressing on it, rather than clicking. */\nconst POINTER_TRIGGERS: ReadonlySet<PrototypeTriggerType> = new Set<PrototypeTriggerType>([\n 'ON_HOVER',\n 'ON_PRESS',\n 'MOUSE_ENTER',\n 'MOUSE_LEAVE'\n])\n\n/** A reaction the pointer runs, with the delay a Mouse enter or Mouse leave waits first. */\nexport interface PlayPointerReaction extends PlayClick {\n delayMs: number\n}\n\n/**\n * How to undo a While hovering or While pressing reaction once the pointer leaves or lifts, and\n * the layer whose leaving undoes it: the layer the reaction ran from, or the instance it\n * switched when that layer went with the switch. A Change to switches back with the transition\n * it switched with, as Figma's does.\n */\nexport type PlayRevert =\n | {\n kind: 'change'\n watchId: string\n rootId: string\n instanceId: string\n from: string\n to: string\n transition: PrototypeTransition | null\n }\n | { kind: 'overlay'; watchId: string; frameId: string }\n | { kind: 'back'; watchId: string; frameId: string }\n\n/**\n * The layers under a point inside `rootId`, from the frame down to the deepest one `takes` the\n * pointer, any layer unless told otherwise; none outside.\n */\nexport function pointerPath(\n graph: SceneGraph,\n rootId: string,\n x: number,\n y: number,\n scroll?: ReadonlyMap<string, Vector>,\n takes?: (node: SceneNode) => boolean\n): string[] {\n const path: string[] = []\n const deepest = playHitTest(graph, rootId, x, y, scroll, takes)\n if (!deepest) return path\n graph.closest(deepest.id, (node) => {\n path.unshift(node.id)\n return node.id === rootId\n })\n return path\n}\n\n/** The layers a pointer left, innermost first, and those it entered, outermost first. */\nexport function pathChanges(\n before: readonly string[],\n after: readonly string[]\n): { left: string[]; entered: string[] } {\n let shared = 0\n while (shared < before.length && shared < after.length && before[shared] === after[shared]) {\n shared += 1\n }\n return { left: before.slice(shared).reverse(), entered: after.slice(shared) }\n}\n\n/**\n * Whether the pointer has left the layer a While hovering reaction ran from: its path in the\n * frame the action opened a variant on, so an overlay covering the pointer does not count.\n */\nexport function pointerLeftTrigger(basePath: readonly string[], triggerId: string): boolean {\n return !basePath.includes(triggerId)\n}\n\n/**\n * Whether any layer of `rootId` reacts to the pointer moving over or pressing on it, an instance\n * by its variant; a frame without one is not hit-tested as the pointer moves.\n */\nexport function hasPointerTriggers(graph: SceneGraph, rootId: string): boolean {\n const reacts = (id: string): boolean => {\n const node = graph.getNode(id)\n if (!node) return false\n const own = effectiveReactions(graph, node).some((reaction) =>\n POINTER_TRIGGERS.has(reaction.trigger.type)\n )\n return own || node.childIds.some(reacts)\n }\n return reacts(rootId)\n}\n\n/** A layer's reactions to `trigger`, an instance's from the variant it shows, first action each. */\nexport function pointerReactions(\n graph: SceneGraph,\n nodeId: string,\n trigger: PrototypeTriggerType\n): PlayPointerReaction[] {\n const node = graph.getNode(nodeId)\n if (!node) return []\n return effectiveReactions(graph, node).flatMap((reaction) => {\n const action = reaction.trigger.type === trigger ? primaryAction(reaction) : null\n if (!action) return []\n const transition = action.type === 'NODE' ? action.transition : null\n return [{ sourceId: nodeId, action, transition, delayMs: reaction.trigger.delay * 1000 }]\n })\n}\n\n/**\n * How to undo what a While hovering or While pressing reaction did: a Change to switches back, an\n * overlay it opened closes, a navigation goes back. Null when it changed nothing. `shown` is the\n * graph play shows the frame from after it ran.\n */\nexport function revertFor(\n before: PlaySession,\n done: PlayStep,\n { sourceId, action, transition }: PlayClick,\n shown: SceneGraph\n): PlayRevert | null {\n if (done.changed) {\n const { rootId, instanceId, from, to } = done.changed\n // A layer inside the instance went with the switch; leaving the instance undoes it then.\n const watchId = shown.getNode(sourceId) ? sourceId : instanceId\n return { kind: 'change', watchId, rootId, instanceId, from, to, transition }\n }\n if (action.type !== 'NODE' || !action.nodeId) return null\n const after = done.session\n if (action.navigation === 'OVERLAY' && after.overlays.length > before.overlays.length) {\n return { kind: 'overlay', watchId: sourceId, frameId: action.nodeId }\n }\n if (action.navigation === 'NAVIGATE' && after.frameId !== before.frameId) {\n return { kind: 'back', watchId: sourceId, frameId: action.nodeId }\n }\n return null\n}\n"],"mappings":";;;;;AAcA,MAAM,mCAAsD,IAAI,IAA0B;CACxF;CACA;CACA;CACA;AACF,CAAC;;;;;AA8BD,SAAgB,YACd,OACA,QACA,GACA,GACA,QACA,OACU;CACV,MAAM,OAAiB,CAAC;CACxB,MAAM,UAAU,YAAY,OAAO,QAAQ,GAAG,GAAG,QAAQ,KAAK;CAC9D,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,QAAQ,QAAQ,KAAK,SAAS;EAClC,KAAK,QAAQ,KAAK,EAAE;EACpB,OAAO,KAAK,OAAO;CACrB,CAAC;CACD,OAAO;AACT;;AAGA,SAAgB,YACd,QACA,OACuC;CACvC,IAAI,SAAS;CACb,OAAO,SAAS,OAAO,UAAU,SAAS,MAAM,UAAU,OAAO,YAAY,MAAM,SACjF,UAAU;CAEZ,OAAO;EAAE,MAAM,OAAO,MAAM,MAAM,CAAC,CAAC,QAAQ;EAAG,SAAS,MAAM,MAAM,MAAM;CAAE;AAC9E;;;;;AAMA,SAAgB,mBAAmB,UAA6B,WAA4B;CAC1F,OAAO,CAAC,SAAS,SAAS,SAAS;AACrC;;;;;AAMA,SAAgB,mBAAmB,OAAmB,QAAyB;CAC7E,MAAM,UAAU,OAAwB;EACtC,MAAM,OAAO,MAAM,QAAQ,EAAE;EAC7B,IAAI,CAAC,MAAM,OAAO;EAIlB,OAHY,mBAAmB,OAAO,IAAI,CAAC,CAAC,MAAM,aAChD,iBAAiB,IAAI,SAAS,QAAQ,IAAI,CAEnC,KAAK,KAAK,SAAS,KAAK,MAAM;CACzC;CACA,OAAO,OAAO,MAAM;AACtB;;AAGA,SAAgB,iBACd,OACA,QACA,SACuB;CACvB,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,CAAC,MAAM,OAAO,CAAC;CACnB,OAAO,mBAAmB,OAAO,IAAI,CAAC,CAAC,SAAS,aAAa;EAC3D,MAAM,SAAS,SAAS,QAAQ,SAAS,UAAU,cAAc,QAAQ,IAAI;EAC7E,IAAI,CAAC,QAAQ,OAAO,CAAC;EAErB,OAAO,CAAC;GAAE,UAAU;GAAQ;GAAQ,YADjB,OAAO,SAAS,SAAS,OAAO,aAAa;GAChB,SAAS,SAAS,QAAQ,QAAQ;EAAK,CAAC;CAC1F,CAAC;AACH;;;;;;AAOA,SAAgB,UACd,QACA,MACA,EAAE,UAAU,QAAQ,cACpB,OACmB;CACnB,IAAI,KAAK,SAAS;EAChB,MAAM,EAAE,QAAQ,YAAY,MAAM,OAAO,KAAK;EAG9C,OAAO;GAAE,MAAM;GAAU,SADT,MAAM,QAAQ,QAAQ,IAAI,WAAW;GACnB;GAAQ;GAAY;GAAM;GAAI;EAAW;CAC7E;CACA,IAAI,OAAO,SAAS,UAAU,CAAC,OAAO,QAAQ,OAAO;CACrD,MAAM,QAAQ,KAAK;CACnB,IAAI,OAAO,eAAe,aAAa,MAAM,SAAS,SAAS,OAAO,SAAS,QAC7E,OAAO;EAAE,MAAM;EAAW,SAAS;EAAU,SAAS,OAAO;CAAO;CAEtE,IAAI,OAAO,eAAe,cAAc,MAAM,YAAY,OAAO,SAC/D,OAAO;EAAE,MAAM;EAAQ,SAAS;EAAU,SAAS,OAAO;CAAO;CAEnE,OAAO;AACT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PrototypeReaction, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/prototype/reactions.d.ts
|
|
3
|
+
/** Whether two reactions do the same thing, whatever their ids. */
|
|
4
|
+
declare function sameReaction(a: PrototypeReaction, b: PrototypeReaction): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The reactions play runs on a layer. An instance runs its main component's, so an interaction
|
|
7
|
+
* set once on a variant works on every instance of it, and the instance's own reactions replace
|
|
8
|
+
* the main's of the same trigger, as in Figma. A reaction an instance holds under one of its
|
|
9
|
+
* main's ids is Figma's copy of it, which gives way to the main's as edited. Any other layer runs
|
|
10
|
+
* its own.
|
|
11
|
+
*/
|
|
12
|
+
declare function effectiveReactions(graph: SceneGraph, node: SceneNode): PrototypeReaction[];
|
|
13
|
+
/**
|
|
14
|
+
* A layer's reactions with the ones it inherits: the inherited reactions run unless the layer
|
|
15
|
+
* overrides their trigger. Figma's copy of a main's interaction keeps the main's id; the main's
|
|
16
|
+
* own, as edited, runs.
|
|
17
|
+
*/
|
|
18
|
+
declare function reactionsWithInherited(node: SceneNode, inherited: readonly PrototypeReaction[]): PrototypeReaction[];
|
|
19
|
+
/**
|
|
20
|
+
* The component layer a copy stands for, followed through nested instances to the main that
|
|
21
|
+
* finally holds it. A nested copy points at the layer one level up, not at the main's layer.
|
|
22
|
+
*/
|
|
23
|
+
declare function componentLayer(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A resolver for the component layers copies stand for, which reads each instance's copy-to-main
|
|
26
|
+
* map once. Arm many layers of one frame with it instead of calling `componentLayer` per layer,
|
|
27
|
+
* which searches an instance for every copy.
|
|
28
|
+
*/
|
|
29
|
+
declare function componentLayerResolver(graph: SceneGraph): (node: SceneNode) => SceneNode | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The instance's own reactions without the copies of `previousMain`'s: those under one of its ids,
|
|
32
|
+
* or equal to one. Figma writes a main component's interactions onto each instance too; once play
|
|
33
|
+
* shows another variant, those copies would keep running the old variant's interactions over the
|
|
34
|
+
* new one's.
|
|
35
|
+
*/
|
|
36
|
+
declare function withoutInheritedCopies(own: readonly PrototypeReaction[], previousMain: SceneNode | undefined): PrototypeReaction[];
|
|
37
|
+
/**
|
|
38
|
+
* The reaction an instance keeps after an edit. Figma's copy of a main's interaction keeps the
|
|
39
|
+
* main's id, which play reads as the main's; edited to do something else, it takes an id of its
|
|
40
|
+
* own and becomes the instance's override, which play runs.
|
|
41
|
+
*/
|
|
42
|
+
declare function asInstanceEdit(reaction: PrototypeReaction, inherited: readonly PrototypeReaction[]): PrototypeReaction;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { asInstanceEdit, componentLayer, componentLayerResolver, effectiveReactions, reactionsWithInherited, sameReaction, withoutInheritedCopies };
|
|
45
|
+
//# sourceMappingURL=reactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../src/prototype/reactions.ts"],"mappings":";;;iBAegB,aAAa,GAAG,mBAAmB,GAAG;;;;;;;;iBAWtC,mBAAmB,OAAO,YAAY,MAAM,YAAY;;;;;;iBASxD,uBACd,MAAM,WACN,oBAAoB,sBACnB;;;;;iBA6Ba,eAAe,OAAO,YAAY,MAAM,YAAY;;;;;;iBAWpD,uBACd,OAAO,cACL,MAAM,cAAc;;;;;;;iBA2ER,uBACd,cAAc,qBACd,cAAc,wBACb;;;;;;iBAYa,eACd,UAAU,mBACV,oBAAoB,sBACnB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { generateId } from "@pairdraw/scene-graph";
|
|
2
|
+
import { isEqual, omit } from "es-toolkit";
|
|
3
|
+
import { findInstanceAncestor, instanceMainComponent, walkInstanceSources } from "@pairdraw/scene-graph/instances";
|
|
4
|
+
//#region src/prototype/reactions.ts
|
|
5
|
+
/** Whether two reactions do the same thing, whatever their ids. */
|
|
6
|
+
function sameReaction(a, b) {
|
|
7
|
+
return isEqual(omit(a, ["id"]), omit(b, ["id"]));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The reactions play runs on a layer. An instance runs its main component's, so an interaction
|
|
11
|
+
* set once on a variant works on every instance of it, and the instance's own reactions replace
|
|
12
|
+
* the main's of the same trigger, as in Figma. A reaction an instance holds under one of its
|
|
13
|
+
* main's ids is Figma's copy of it, which gives way to the main's as edited. Any other layer runs
|
|
14
|
+
* its own.
|
|
15
|
+
*/
|
|
16
|
+
function effectiveReactions(graph, node) {
|
|
17
|
+
return reactionsWithInherited(node, inheritedReactions(graph, node));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A layer's reactions with the ones it inherits: the inherited reactions run unless the layer
|
|
21
|
+
* overrides their trigger. Figma's copy of a main's interaction keeps the main's id; the main's
|
|
22
|
+
* own, as edited, runs.
|
|
23
|
+
*/
|
|
24
|
+
function reactionsWithInherited(node, inherited) {
|
|
25
|
+
if (inherited.length === 0) return node.prototypeReactions;
|
|
26
|
+
const own = node.prototypeReactions.filter((reaction) => !inherited.some((main) => main.id === reaction.id));
|
|
27
|
+
return [...own, ...inherited.filter((reaction) => !own.some((mine) => mine.trigger.type === reaction.trigger.type))];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The reactions a layer takes from its component: an instance root from the component it shows,
|
|
31
|
+
* a layer inside an instance from the component layer it was copied from.
|
|
32
|
+
*/
|
|
33
|
+
function inheritedReactions(graph, node) {
|
|
34
|
+
if (node.type === "INSTANCE") return instanceMainComponent(graph, node)?.prototypeReactions ?? [];
|
|
35
|
+
const source = componentLayer(graph, node);
|
|
36
|
+
return source && source.id !== node.id ? source.prototypeReactions : [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The component layer a copy stands for, followed through nested instances to the main that
|
|
40
|
+
* finally holds it. A nested copy points at the layer one level up, not at the main's layer.
|
|
41
|
+
*/
|
|
42
|
+
function componentLayer(graph, node) {
|
|
43
|
+
return followComponentLayer(graph, node, (instance, copyId) => copiedSource(graph, instance, copyId));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A resolver for the component layers copies stand for, which reads each instance's copy-to-main
|
|
47
|
+
* map once. Arm many layers of one frame with it instead of calling `componentLayer` per layer,
|
|
48
|
+
* which searches an instance for every copy.
|
|
49
|
+
*/
|
|
50
|
+
function componentLayerResolver(graph) {
|
|
51
|
+
const sourcesByInstance = /* @__PURE__ */ new Map();
|
|
52
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
53
|
+
const sourcesOf = (instance) => {
|
|
54
|
+
const cached = sourcesByInstance.get(instance.id);
|
|
55
|
+
if (cached) return cached;
|
|
56
|
+
const sources = /* @__PURE__ */ new Map();
|
|
57
|
+
walkInstanceSources(graph, instance, (source, copy) => {
|
|
58
|
+
sources.set(copy.id, source);
|
|
59
|
+
return true;
|
|
60
|
+
}, true);
|
|
61
|
+
sourcesByInstance.set(instance.id, sources);
|
|
62
|
+
return sources;
|
|
63
|
+
};
|
|
64
|
+
return (node) => {
|
|
65
|
+
if (resolved.has(node.id)) return resolved.get(node.id);
|
|
66
|
+
const layer = followComponentLayer(graph, node, (instance, copyId) => sourcesOf(instance).get(copyId));
|
|
67
|
+
resolved.set(node.id, layer);
|
|
68
|
+
return layer;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Walks a copy up to its main layer, one instance at a time, using `sourceOf` to map each step. */
|
|
72
|
+
function followComponentLayer(graph, node, sourceOf) {
|
|
73
|
+
const seen = /* @__PURE__ */ new Set();
|
|
74
|
+
let current = node;
|
|
75
|
+
for (;;) {
|
|
76
|
+
if (seen.has(current.id)) return void 0;
|
|
77
|
+
seen.add(current.id);
|
|
78
|
+
const owner = current.parentId ? findInstanceAncestor(graph, current.parentId) : void 0;
|
|
79
|
+
if (!owner) return current;
|
|
80
|
+
if (!instanceMainComponent(graph, owner)) return void 0;
|
|
81
|
+
const source = sourceOf(owner, current.id);
|
|
82
|
+
if (!source || source.id === current.id) return void 0;
|
|
83
|
+
current = source;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** The component layer that an instance's copy of `copyId` stands for. */
|
|
87
|
+
function copiedSource(graph, instance, copyId) {
|
|
88
|
+
let source;
|
|
89
|
+
walkInstanceSources(graph, instance, (candidate, copy) => {
|
|
90
|
+
if (copy.id !== copyId) return true;
|
|
91
|
+
source = candidate;
|
|
92
|
+
return false;
|
|
93
|
+
}, true);
|
|
94
|
+
return source;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The instance's own reactions without the copies of `previousMain`'s: those under one of its ids,
|
|
98
|
+
* or equal to one. Figma writes a main component's interactions onto each instance too; once play
|
|
99
|
+
* shows another variant, those copies would keep running the old variant's interactions over the
|
|
100
|
+
* new one's.
|
|
101
|
+
*/
|
|
102
|
+
function withoutInheritedCopies(own, previousMain) {
|
|
103
|
+
const inherited = previousMain?.prototypeReactions ?? [];
|
|
104
|
+
return own.filter((reaction) => !inherited.some((main) => main.id === reaction.id || sameReaction(main, reaction)));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The reaction an instance keeps after an edit. Figma's copy of a main's interaction keeps the
|
|
108
|
+
* main's id, which play reads as the main's; edited to do something else, it takes an id of its
|
|
109
|
+
* own and becomes the instance's override, which play runs.
|
|
110
|
+
*/
|
|
111
|
+
function asInstanceEdit(reaction, inherited) {
|
|
112
|
+
const main = inherited.find((candidate) => candidate.id === reaction.id);
|
|
113
|
+
if (!main || sameReaction(main, reaction)) return reaction;
|
|
114
|
+
return {
|
|
115
|
+
...reaction,
|
|
116
|
+
id: generateId()
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { asInstanceEdit, componentLayer, componentLayerResolver, effectiveReactions, reactionsWithInherited, sameReaction, withoutInheritedCopies };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=reactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../src/prototype/reactions.ts"],"sourcesContent":["import { isEqual, omit } from 'es-toolkit'\n\nimport {\n generateId,\n type PrototypeReaction,\n type SceneGraph,\n type SceneNode\n} from '@pairdraw/scene-graph'\nimport {\n findInstanceAncestor,\n instanceMainComponent,\n walkInstanceSources\n} from '@pairdraw/scene-graph/instances'\n\n/** Whether two reactions do the same thing, whatever their ids. */\nexport function sameReaction(a: PrototypeReaction, b: PrototypeReaction): boolean {\n return isEqual(omit(a, ['id']), omit(b, ['id']))\n}\n\n/**\n * The reactions play runs on a layer. An instance runs its main component's, so an interaction\n * set once on a variant works on every instance of it, and the instance's own reactions replace\n * the main's of the same trigger, as in Figma. A reaction an instance holds under one of its\n * main's ids is Figma's copy of it, which gives way to the main's as edited. Any other layer runs\n * its own.\n */\nexport function effectiveReactions(graph: SceneGraph, node: SceneNode): PrototypeReaction[] {\n return reactionsWithInherited(node, inheritedReactions(graph, node))\n}\n\n/**\n * A layer's reactions with the ones it inherits: the inherited reactions run unless the layer\n * overrides their trigger. Figma's copy of a main's interaction keeps the main's id; the main's\n * own, as edited, runs.\n */\nexport function reactionsWithInherited(\n node: SceneNode,\n inherited: readonly PrototypeReaction[]\n): PrototypeReaction[] {\n if (inherited.length === 0) return node.prototypeReactions\n const own = node.prototypeReactions.filter(\n (reaction) => !inherited.some((main) => main.id === reaction.id)\n )\n return [\n ...own,\n ...inherited.filter(\n (reaction) => !own.some((mine) => mine.trigger.type === reaction.trigger.type)\n )\n ]\n}\n\n/**\n * The reactions a layer takes from its component: an instance root from the component it shows,\n * a layer inside an instance from the component layer it was copied from.\n */\nfunction inheritedReactions(graph: SceneGraph, node: SceneNode): PrototypeReaction[] {\n if (node.type === 'INSTANCE') {\n return instanceMainComponent(graph, node)?.prototypeReactions ?? []\n }\n const source = componentLayer(graph, node)\n return source && source.id !== node.id ? source.prototypeReactions : []\n}\n\n/**\n * The component layer a copy stands for, followed through nested instances to the main that\n * finally holds it. A nested copy points at the layer one level up, not at the main's layer.\n */\nexport function componentLayer(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return followComponentLayer(graph, node, (instance, copyId) =>\n copiedSource(graph, instance, copyId)\n )\n}\n\n/**\n * A resolver for the component layers copies stand for, which reads each instance's copy-to-main\n * map once. Arm many layers of one frame with it instead of calling `componentLayer` per layer,\n * which searches an instance for every copy.\n */\nexport function componentLayerResolver(\n graph: SceneGraph\n): (node: SceneNode) => SceneNode | undefined {\n const sourcesByInstance = new Map<string, Map<string, SceneNode>>()\n const resolved = new Map<string, SceneNode | undefined>()\n const sourcesOf = (instance: SceneNode): Map<string, SceneNode> => {\n const cached = sourcesByInstance.get(instance.id)\n if (cached) return cached\n const sources = new Map<string, SceneNode>()\n walkInstanceSources(\n graph,\n instance,\n (source, copy) => {\n sources.set(copy.id, source)\n return true\n },\n true\n )\n sourcesByInstance.set(instance.id, sources)\n return sources\n }\n return (node) => {\n if (resolved.has(node.id)) return resolved.get(node.id)\n const layer = followComponentLayer(graph, node, (instance, copyId) =>\n sourcesOf(instance).get(copyId)\n )\n resolved.set(node.id, layer)\n return layer\n }\n}\n\n/** Walks a copy up to its main layer, one instance at a time, using `sourceOf` to map each step. */\nfunction followComponentLayer(\n graph: SceneGraph,\n node: SceneNode,\n sourceOf: (instance: SceneNode, copyId: string) => SceneNode | undefined\n): SceneNode | undefined {\n const seen = new Set<string>()\n let current = node\n for (;;) {\n if (seen.has(current.id)) return undefined\n seen.add(current.id)\n const owner = current.parentId ? findInstanceAncestor(graph, current.parentId) : undefined\n if (!owner) return current\n if (!instanceMainComponent(graph, owner)) return undefined\n const source = sourceOf(owner, current.id)\n if (!source || source.id === current.id) return undefined\n current = source\n }\n}\n\n/** The component layer that an instance's copy of `copyId` stands for. */\nfunction copiedSource(\n graph: SceneGraph,\n instance: SceneNode,\n copyId: string\n): SceneNode | undefined {\n let source: SceneNode | undefined\n walkInstanceSources(\n graph,\n instance,\n (candidate, copy) => {\n if (copy.id !== copyId) return true\n source = candidate\n return false\n },\n true\n )\n return source\n}\n\n/**\n * The instance's own reactions without the copies of `previousMain`'s: those under one of its ids,\n * or equal to one. Figma writes a main component's interactions onto each instance too; once play\n * shows another variant, those copies would keep running the old variant's interactions over the\n * new one's.\n */\nexport function withoutInheritedCopies(\n own: readonly PrototypeReaction[],\n previousMain: SceneNode | undefined\n): PrototypeReaction[] {\n const inherited = previousMain?.prototypeReactions ?? []\n return own.filter(\n (reaction) => !inherited.some((main) => main.id === reaction.id || sameReaction(main, reaction))\n )\n}\n\n/**\n * The reaction an instance keeps after an edit. Figma's copy of a main's interaction keeps the\n * main's id, which play reads as the main's; edited to do something else, it takes an id of its\n * own and becomes the instance's override, which play runs.\n */\nexport function asInstanceEdit(\n reaction: PrototypeReaction,\n inherited: readonly PrototypeReaction[]\n): PrototypeReaction {\n const main = inherited.find((candidate) => candidate.id === reaction.id)\n if (!main || sameReaction(main, reaction)) return reaction\n return { ...reaction, id: generateId() }\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,GAAsB,GAA+B;CAChF,OAAO,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;AACjD;;;;;;;;AASA,SAAgB,mBAAmB,OAAmB,MAAsC;CAC1F,OAAO,uBAAuB,MAAM,mBAAmB,OAAO,IAAI,CAAC;AACrE;;;;;;AAOA,SAAgB,uBACd,MACA,WACqB;CACrB,IAAI,UAAU,WAAW,GAAG,OAAO,KAAK;CACxC,MAAM,MAAM,KAAK,mBAAmB,QACjC,aAAa,CAAC,UAAU,MAAM,SAAS,KAAK,OAAO,SAAS,EAAE,CACjE;CACA,OAAO,CACL,GAAG,KACH,GAAG,UAAU,QACV,aAAa,CAAC,IAAI,MAAM,SAAS,KAAK,QAAQ,SAAS,SAAS,QAAQ,IAAI,CAC/E,CACF;AACF;;;;;AAMA,SAAS,mBAAmB,OAAmB,MAAsC;CACnF,IAAI,KAAK,SAAS,YAChB,OAAO,sBAAsB,OAAO,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAEpE,MAAM,SAAS,eAAe,OAAO,IAAI;CACzC,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK,OAAO,qBAAqB,CAAC;AACxE;;;;;AAMA,SAAgB,eAAe,OAAmB,MAAwC;CACxF,OAAO,qBAAqB,OAAO,OAAO,UAAU,WAClD,aAAa,OAAO,UAAU,MAAM,CACtC;AACF;;;;;;AAOA,SAAgB,uBACd,OAC4C;CAC5C,MAAM,oCAAoB,IAAI,IAAoC;CAClE,MAAM,2BAAW,IAAI,IAAmC;CACxD,MAAM,aAAa,aAAgD;EACjE,MAAM,SAAS,kBAAkB,IAAI,SAAS,EAAE;EAChD,IAAI,QAAQ,OAAO;EACnB,MAAM,0BAAU,IAAI,IAAuB;EAC3C,oBACE,OACA,WACC,QAAQ,SAAS;GAChB,QAAQ,IAAI,KAAK,IAAI,MAAM;GAC3B,OAAO;EACT,GACA,IACF;EACA,kBAAkB,IAAI,SAAS,IAAI,OAAO;EAC1C,OAAO;CACT;CACA,QAAQ,SAAS;EACf,IAAI,SAAS,IAAI,KAAK,EAAE,GAAG,OAAO,SAAS,IAAI,KAAK,EAAE;EACtD,MAAM,QAAQ,qBAAqB,OAAO,OAAO,UAAU,WACzD,UAAU,QAAQ,CAAC,CAAC,IAAI,MAAM,CAChC;EACA,SAAS,IAAI,KAAK,IAAI,KAAK;EAC3B,OAAO;CACT;AACF;;AAGA,SAAS,qBACP,OACA,MACA,UACuB;CACvB,MAAM,uBAAO,IAAI,IAAY;CAC7B,IAAI,UAAU;CACd,SAAS;EACP,IAAI,KAAK,IAAI,QAAQ,EAAE,GAAG,OAAO,KAAA;EACjC,KAAK,IAAI,QAAQ,EAAE;EACnB,MAAM,QAAQ,QAAQ,WAAW,qBAAqB,OAAO,QAAQ,QAAQ,IAAI,KAAA;EACjF,IAAI,CAAC,OAAO,OAAO;EACnB,IAAI,CAAC,sBAAsB,OAAO,KAAK,GAAG,OAAO,KAAA;EACjD,MAAM,SAAS,SAAS,OAAO,QAAQ,EAAE;EACzC,IAAI,CAAC,UAAU,OAAO,OAAO,QAAQ,IAAI,OAAO,KAAA;EAChD,UAAU;CACZ;AACF;;AAGA,SAAS,aACP,OACA,UACA,QACuB;CACvB,IAAI;CACJ,oBACE,OACA,WACC,WAAW,SAAS;EACnB,IAAI,KAAK,OAAO,QAAQ,OAAO;EAC/B,SAAS;EACT,OAAO;CACT,GACA,IACF;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,uBACd,KACA,cACqB;CACrB,MAAM,YAAY,cAAc,sBAAsB,CAAC;CACvD,OAAO,IAAI,QACR,aAAa,CAAC,UAAU,MAAM,SAAS,KAAK,OAAO,SAAS,MAAM,aAAa,MAAM,QAAQ,CAAC,CACjG;AACF;;;;;;AAOA,SAAgB,eACd,UACA,WACmB;CACnB,MAAM,OAAO,UAAU,MAAM,cAAc,UAAU,OAAO,SAAS,EAAE;CACvE,IAAI,CAAC,QAAQ,aAAa,MAAM,QAAQ,GAAG,OAAO;CAClD,OAAO;EAAE,GAAG;EAAU,IAAI,WAAW;CAAE;AACzC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RenderedPlayScene } from "../canvas/renderer/types.js";
|
|
2
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
3
|
+
//#region src/prototype/scene.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* What the canvas draws in place of a top-level frame while play changed it: the frame's private
|
|
6
|
+
* copy, a count that grows with every change, and the layers the changes touched, whose cached
|
|
7
|
+
* drawings are stale. The renderer's own name for the same view.
|
|
8
|
+
*/
|
|
9
|
+
type PlaySceneView = RenderedPlayScene;
|
|
10
|
+
/** One Change to: the instance it switched, in the frame it sits in, and the two variants. */
|
|
11
|
+
interface PlayChange {
|
|
12
|
+
rootId: string;
|
|
13
|
+
instanceId: string;
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
}
|
|
17
|
+
interface PlayScene extends PlaySceneView {
|
|
18
|
+
/**
|
|
19
|
+
* Shows `variantId` on the instance a Change to from `sourceId` switches: the source or its
|
|
20
|
+
* nearest instance ancestor that shows a variant of that set. Null when there is none, or it
|
|
21
|
+
* already shows the variant.
|
|
22
|
+
*/
|
|
23
|
+
changeTo(sourceId: string, variantId: string): PlayChange | null;
|
|
24
|
+
}
|
|
25
|
+
/** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */
|
|
26
|
+
declare function changeTarget(graph: SceneGraph, rootId: string, sourceId: string, variantId: string): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* A top-level frame as play shows it once an interaction changed it: a private copy of the frame,
|
|
29
|
+
* with every variant its instances can switch to, that the document, undo, autosave, and
|
|
30
|
+
* collaborators never see.
|
|
31
|
+
*/
|
|
32
|
+
declare function createPlayScene(design: SceneGraph, rootId: string): PlayScene;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { PlayChange, PlayScene, PlaySceneView, changeTarget, createPlayScene };
|
|
35
|
+
//# sourceMappingURL=scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.d.ts","names":[],"sources":["../../src/prototype/scene.ts"],"mappings":";;;;;;;;KAgBY,gBAAgB;;UAGX;EACf;EACA;EACA;EACA;;UAGe,kBAAkB;;;;;;EAMjC,SAAS,kBAAkB,oBAAoB;;;iBAIjC,aACd,OAAO,YACP,gBACA,kBACA;;;;;;iBA6Bc,gBAAgB,QAAQ,YAAY,iBAAiB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { extractPageContext, findPageId } from "../io/subgraph.js";
|
|
2
|
+
import { computeAllLayouts, computeLayout } from "../layout.js";
|
|
3
|
+
import { withoutInheritedCopies } from "./reactions.js";
|
|
4
|
+
import { reflow } from "../editor/play/states.js";
|
|
5
|
+
import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
|
|
6
|
+
import { variantInstanceFor } from "@pairdraw/scene-graph/components";
|
|
7
|
+
//#region src/prototype/scene.ts
|
|
8
|
+
/** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */
|
|
9
|
+
function changeTarget(graph, rootId, sourceId, variantId) {
|
|
10
|
+
const variant = graph.getNode(variantId);
|
|
11
|
+
if (variant?.type !== "COMPONENT" || !variant.parentId) return null;
|
|
12
|
+
const instance = variantInstanceFor(graph, sourceId, variant.parentId);
|
|
13
|
+
if (!instance || !graph.isDescendant(instance.id, rootId)) return null;
|
|
14
|
+
return instanceMainComponent(graph, instance)?.id === variantId ? null : instance.id;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Lays out a switched instance, then each auto layout around it up to the frame, as an edit lays
|
|
18
|
+
* out the layer it changed and the auto layouts that hug it; the rest of the frame keeps its
|
|
19
|
+
* layout.
|
|
20
|
+
*/
|
|
21
|
+
function layOutAround(graph, instanceId, rootId) {
|
|
22
|
+
reflow(graph, instanceId);
|
|
23
|
+
computeAllLayouts(graph, instanceId);
|
|
24
|
+
let current = graph.getNode(instanceId);
|
|
25
|
+
while (current && current.id !== rootId && current.parentId) {
|
|
26
|
+
current = graph.getNode(current.parentId);
|
|
27
|
+
if (current && current.layoutMode !== "NONE") computeLayout(graph, current.id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A top-level frame as play shows it once an interaction changed it: a private copy of the frame,
|
|
32
|
+
* with every variant its instances can switch to, that the document, undo, autosave, and
|
|
33
|
+
* collaborators never see.
|
|
34
|
+
*/
|
|
35
|
+
function createPlayScene(design, rootId) {
|
|
36
|
+
const pageId = findPageId(design, rootId) ?? design.rootId;
|
|
37
|
+
const graph = extractPageContext(design, pageId, [rootId], {
|
|
38
|
+
componentSets: true,
|
|
39
|
+
shareTables: true
|
|
40
|
+
});
|
|
41
|
+
const touched = /* @__PURE__ */ new Set();
|
|
42
|
+
let revision = 0;
|
|
43
|
+
function touch(id) {
|
|
44
|
+
touched.add(id);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
graph,
|
|
48
|
+
touched,
|
|
49
|
+
get revision() {
|
|
50
|
+
return revision;
|
|
51
|
+
},
|
|
52
|
+
changeTo(sourceId, variantId) {
|
|
53
|
+
const instanceId = changeTarget(graph, rootId, sourceId, variantId);
|
|
54
|
+
const instance = instanceId ? graph.getNode(instanceId) : void 0;
|
|
55
|
+
const previous = instance && instanceMainComponent(graph, instance);
|
|
56
|
+
if (!instance || !previous) return null;
|
|
57
|
+
const stop = graph.onNodeEvents({
|
|
58
|
+
created: (node) => touch(node.id),
|
|
59
|
+
updated: touch,
|
|
60
|
+
deleted: touch
|
|
61
|
+
});
|
|
62
|
+
try {
|
|
63
|
+
graph.swapInstanceComponent(instance.id, variantId, { keepName: true });
|
|
64
|
+
graph.updateNode(instance.id, { prototypeReactions: withoutInheritedCopies(instance.prototypeReactions, previous) });
|
|
65
|
+
layOutAround(graph, instance.id, rootId);
|
|
66
|
+
} finally {
|
|
67
|
+
stop();
|
|
68
|
+
}
|
|
69
|
+
graph.closest(instance.id, (node) => {
|
|
70
|
+
touch(node.id);
|
|
71
|
+
return node.id === rootId;
|
|
72
|
+
});
|
|
73
|
+
revision += 1;
|
|
74
|
+
return {
|
|
75
|
+
rootId,
|
|
76
|
+
instanceId: instance.id,
|
|
77
|
+
from: previous.id,
|
|
78
|
+
to: variantId
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { changeTarget, createPlayScene };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.js","names":[],"sources":["../../src/prototype/scene.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport { variantInstanceFor } from '@pairdraw/scene-graph/components'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\n\nimport type { RenderedPlayScene } from '#core/canvas/renderer/types'\nimport { reflow } from '#core/editor/play/states'\nimport { extractPageContext, findPageId } from '#core/io/subgraph'\nimport { computeAllLayouts, computeLayout } from '#core/layout'\n\nimport { withoutInheritedCopies } from './reactions'\n\n/**\n * What the canvas draws in place of a top-level frame while play changed it: the frame's private\n * copy, a count that grows with every change, and the layers the changes touched, whose cached\n * drawings are stale. The renderer's own name for the same view.\n */\nexport type PlaySceneView = RenderedPlayScene\n\n/** One Change to: the instance it switched, in the frame it sits in, and the two variants. */\nexport interface PlayChange {\n rootId: string\n instanceId: string\n from: string\n to: string\n}\n\nexport interface PlayScene extends PlaySceneView {\n /**\n * Shows `variantId` on the instance a Change to from `sourceId` switches: the source or its\n * nearest instance ancestor that shows a variant of that set. Null when there is none, or it\n * already shows the variant.\n */\n changeTo(sourceId: string, variantId: string): PlayChange | null\n}\n\n/** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */\nexport function changeTarget(\n graph: SceneGraph,\n rootId: string,\n sourceId: string,\n variantId: string\n): string | null {\n const variant = graph.getNode(variantId)\n if (variant?.type !== 'COMPONENT' || !variant.parentId) return null\n const instance = variantInstanceFor(graph, sourceId, variant.parentId)\n if (!instance || !graph.isDescendant(instance.id, rootId)) return null\n return instanceMainComponent(graph, instance)?.id === variantId ? null : instance.id\n}\n\n/**\n * Lays out a switched instance, then each auto layout around it up to the frame, as an edit lays\n * out the layer it changed and the auto layouts that hug it; the rest of the frame keeps its\n * layout.\n */\nfunction layOutAround(graph: SceneGraph, instanceId: string, rootId: string): void {\n reflow(graph, instanceId)\n computeAllLayouts(graph, instanceId)\n let current = graph.getNode(instanceId)\n while (current && current.id !== rootId && current.parentId) {\n current = graph.getNode(current.parentId)\n if (current && current.layoutMode !== 'NONE') computeLayout(graph, current.id)\n }\n}\n\n/**\n * A top-level frame as play shows it once an interaction changed it: a private copy of the frame,\n * with every variant its instances can switch to, that the document, undo, autosave, and\n * collaborators never see.\n */\nexport function createPlayScene(design: SceneGraph, rootId: string): PlayScene {\n const pageId = findPageId(design, rootId) ?? design.rootId\n const graph = extractPageContext(design, pageId, [rootId], {\n componentSets: true,\n shareTables: true\n })\n const touched = new Set<string>()\n let revision = 0\n\n function touch(id: string): void {\n touched.add(id)\n }\n\n return {\n graph,\n touched,\n get revision() {\n return revision\n },\n changeTo(sourceId, variantId) {\n const instanceId = changeTarget(graph, rootId, sourceId, variantId)\n const instance = instanceId ? graph.getNode(instanceId) : undefined\n const previous = instance && instanceMainComponent(graph, instance)\n if (!instance || !previous) return null\n const stop = graph.onNodeEvents({\n created: (node) => touch(node.id),\n updated: touch,\n deleted: touch\n })\n try {\n graph.swapInstanceComponent(instance.id, variantId, { keepName: true })\n graph.updateNode(instance.id, {\n prototypeReactions: withoutInheritedCopies(instance.prototypeReactions, previous)\n })\n layOutAround(graph, instance.id, rootId)\n } finally {\n stop()\n }\n graph.closest(instance.id, (node) => {\n touch(node.id)\n return node.id === rootId\n })\n revision += 1\n return { rootId, instanceId: instance.id, from: previous.id, to: variantId }\n }\n }\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,aACd,OACA,QACA,UACA,WACe;CACf,MAAM,UAAU,MAAM,QAAQ,SAAS;CACvC,IAAI,SAAS,SAAS,eAAe,CAAC,QAAQ,UAAU,OAAO;CAC/D,MAAM,WAAW,mBAAmB,OAAO,UAAU,QAAQ,QAAQ;CACrE,IAAI,CAAC,YAAY,CAAC,MAAM,aAAa,SAAS,IAAI,MAAM,GAAG,OAAO;CAClE,OAAO,sBAAsB,OAAO,QAAQ,CAAC,EAAE,OAAO,YAAY,OAAO,SAAS;AACpF;;;;;;AAOA,SAAS,aAAa,OAAmB,YAAoB,QAAsB;CACjF,OAAO,OAAO,UAAU;CACxB,kBAAkB,OAAO,UAAU;CACnC,IAAI,UAAU,MAAM,QAAQ,UAAU;CACtC,OAAO,WAAW,QAAQ,OAAO,UAAU,QAAQ,UAAU;EAC3D,UAAU,MAAM,QAAQ,QAAQ,QAAQ;EACxC,IAAI,WAAW,QAAQ,eAAe,QAAQ,cAAc,OAAO,QAAQ,EAAE;CAC/E;AACF;;;;;;AAOA,SAAgB,gBAAgB,QAAoB,QAA2B;CAC7E,MAAM,SAAS,WAAW,QAAQ,MAAM,KAAK,OAAO;CACpD,MAAM,QAAQ,mBAAmB,QAAQ,QAAQ,CAAC,MAAM,GAAG;EACzD,eAAe;EACf,aAAa;CACf,CAAC;CACD,MAAM,0BAAU,IAAI,IAAY;CAChC,IAAI,WAAW;CAEf,SAAS,MAAM,IAAkB;EAC/B,QAAQ,IAAI,EAAE;CAChB;CAEA,OAAO;EACL;EACA;EACA,IAAI,WAAW;GACb,OAAO;EACT;EACA,SAAS,UAAU,WAAW;GAC5B,MAAM,aAAa,aAAa,OAAO,QAAQ,UAAU,SAAS;GAClE,MAAM,WAAW,aAAa,MAAM,QAAQ,UAAU,IAAI,KAAA;GAC1D,MAAM,WAAW,YAAY,sBAAsB,OAAO,QAAQ;GAClE,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO;GACnC,MAAM,OAAO,MAAM,aAAa;IAC9B,UAAU,SAAS,MAAM,KAAK,EAAE;IAChC,SAAS;IACT,SAAS;GACX,CAAC;GACD,IAAI;IACF,MAAM,sBAAsB,SAAS,IAAI,WAAW,EAAE,UAAU,KAAK,CAAC;IACtE,MAAM,WAAW,SAAS,IAAI,EAC5B,oBAAoB,uBAAuB,SAAS,oBAAoB,QAAQ,EAClF,CAAC;IACD,aAAa,OAAO,SAAS,IAAI,MAAM;GACzC,UAAU;IACR,KAAK;GACP;GACA,MAAM,QAAQ,SAAS,KAAK,SAAS;IACnC,MAAM,KAAK,EAAE;IACb,OAAO,KAAK,OAAO;GACrB,CAAC;GACD,YAAY;GACZ,OAAO;IAAE;IAAQ,YAAY,SAAS;IAAI,MAAM,SAAS;IAAI,IAAI;GAAU;EAC7E;CACF;AACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PlayChange, PlaySceneView } from "./scene.js";
|
|
2
|
+
import { ScrollChange } from "./scroll.js";
|
|
3
|
+
import { PlayClick, PlaySession } from "./session.js";
|
|
4
|
+
import { SmartAnimation } from "./smart-animate/animation.js";
|
|
5
|
+
import { PlayRevert } from "./pointer.js";
|
|
6
|
+
import { PrototypeAction, SceneGraph } from "@pairdraw/scene-graph";
|
|
7
|
+
import { Vector } from "@pairdraw/scene-graph/primitives";
|
|
8
|
+
//#region src/prototype/scenes.d.ts
|
|
9
|
+
/** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */
|
|
10
|
+
declare const PLAY_SCENE_LIMIT = 4;
|
|
11
|
+
/**
|
|
12
|
+
* An After delay reaction the layers a frame shows add: the layer it runs from, which is an
|
|
13
|
+
* instance or a copy inside one, the main component or layer it stands for, whose reaction it is,
|
|
14
|
+
* the reaction, its action, and the delay in milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
interface PlayTimeout {
|
|
17
|
+
sourceId: string;
|
|
18
|
+
/** The main component an instance shows, or the main layer a copy stands for. */
|
|
19
|
+
variantId: string;
|
|
20
|
+
reactionId: string;
|
|
21
|
+
action: PrototypeAction;
|
|
22
|
+
delayMs: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What a reaction did: the session after it, and the Change to it made, if it made one. A Scroll
|
|
26
|
+
* to also says which frames it scrolled, for an animation to step between, and where the layer it
|
|
27
|
+
* scrolled to is drawn now, for a screen that scrolls by panning to bring into view.
|
|
28
|
+
*/
|
|
29
|
+
interface PlayStep {
|
|
30
|
+
session: PlaySession;
|
|
31
|
+
changed: PlayChange | null;
|
|
32
|
+
scrolled?: ScrollChange[];
|
|
33
|
+
reveal?: Vector | null;
|
|
34
|
+
/**
|
|
35
|
+
* A Smart animate Change to's animation from the frame as it was to its copy as it is now, for
|
|
36
|
+
* the player to run over the transition's duration; the copy shows the change at once.
|
|
37
|
+
*/
|
|
38
|
+
animation?: SmartAnimation;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The frames play changed, each kept as a private copy so the document never changes. Frames move
|
|
42
|
+
* through the session as before; a Change to switches an instance on its frame's copy, which is
|
|
43
|
+
* made at the first change, so a prototype without one copies nothing.
|
|
44
|
+
*/
|
|
45
|
+
interface PlayScenes {
|
|
46
|
+
/** The graph play reads a top-level frame from: its copy once changed, else the document. */
|
|
47
|
+
graphFor(rootId: string): SceneGraph;
|
|
48
|
+
/** The changed frames the canvas draws from their copies, by frame id. */
|
|
49
|
+
readonly views: ReadonlyMap<string, PlaySceneView>;
|
|
50
|
+
/** How far play scrolled each frame that scrolls, by frame id. */
|
|
51
|
+
readonly scroll: ReadonlyMap<string, Vector>;
|
|
52
|
+
/**
|
|
53
|
+
* Scrolls the frames along `path`, a pointer's path in `rootId`, innermost first, and returns
|
|
54
|
+
* what none of them could take, for the canvas to pan by.
|
|
55
|
+
*/
|
|
56
|
+
scrollBy(rootId: string, path: readonly string[], dx: number, dy: number): Vector;
|
|
57
|
+
/** Sets one frame's offset, as an animated Scroll to steps it toward where it ends. */
|
|
58
|
+
setScroll(id: string, offset: Vector): void;
|
|
59
|
+
/** Runs a reaction of a layer in `rootId`, the shown frame unless a timer names another. */
|
|
60
|
+
run(session: PlaySession, click: PlayClick, rootId?: string): PlayStep;
|
|
61
|
+
/**
|
|
62
|
+
* Undoes a While hovering or While pressing reaction, unless play moved on from what it did: an
|
|
63
|
+
* instance that shows another variant by now, or an overlay or frame no longer shown.
|
|
64
|
+
*/
|
|
65
|
+
revert(session: PlaySession, revert: PlayRevert): PlayStep;
|
|
66
|
+
/**
|
|
67
|
+
* The After delay reactions of the instances `rootId` shows and of the copies inside them, by
|
|
68
|
+
* the variants and main layers they stand for now.
|
|
69
|
+
*/
|
|
70
|
+
instanceTimeouts(rootId: string): PlayTimeout[];
|
|
71
|
+
/**
|
|
72
|
+
* Drops the copies of frames that hold any of these document layers, after an edit to them:
|
|
73
|
+
* the frame's own layers and the variants its copy holds.
|
|
74
|
+
*/
|
|
75
|
+
forget(nodeIds: Iterable<string>): void;
|
|
76
|
+
clear(): void;
|
|
77
|
+
}
|
|
78
|
+
declare function createPlayScenes(getDocument: () => SceneGraph, limit?: number): PlayScenes;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { PLAY_SCENE_LIMIT, PlayScenes, PlayStep, PlayTimeout, createPlayScenes };
|
|
81
|
+
//# sourceMappingURL=scenes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenes.d.ts","names":[],"sources":["../../src/prototype/scenes.ts"],"mappings":";;;;;;;;;cA8Ba;;;;;;UAOI;EACf;;EAEA;EACA;EACA,QAAQ;EACR;;;;;;;UAQe;EACf,SAAS;EACT,SAAS;EACT,WAAW;EACX,SAAS;;;;;EAKT,YAAY;;;;;;;UAQG;;EAEf,SAAS,iBAAiB;;WAEjB,OAAO,oBAAoB;;WAE3B,QAAQ,oBAAoB;;;;;EAKrC,SAAS,gBAAgB,yBAAyB,YAAY,aAAa;;EAE3E,UAAU,YAAY,QAAQ;;EAE9B,IAAI,SAAS,aAAa,OAAO,WAAW,kBAAkB;;;;;EAK9D,OAAO,SAAS,aAAa,QAAQ,aAAa;;;;;EAKlD,iBAAiB,iBAAiB;;;;;EAKlC,OAAO,SAAS;EAChB;;iBAGc,iBACd,mBAAmB,YACnB,iBACC"}
|