@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,175 @@
|
|
|
1
|
+
import { extractPageContext, findPageId } from "../io/subgraph.js";
|
|
2
|
+
import { clampScroll, scrollAlong, scrollIntoView } from "./scroll.js";
|
|
3
|
+
import { componentLayerResolver, reactionsWithInherited } from "./reactions.js";
|
|
4
|
+
import { primaryAction, shownFrame, step } from "./session.js";
|
|
5
|
+
import { changeTarget, createPlayScene } from "./scene.js";
|
|
6
|
+
import { createSmartAnimation } from "./smart-animate/animation.js";
|
|
7
|
+
import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
|
|
8
|
+
//#region src/prototype/scenes.ts
|
|
9
|
+
/** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */
|
|
10
|
+
const PLAY_SCENE_LIMIT = 4;
|
|
11
|
+
function createPlayScenes(getDocument, limit = 4) {
|
|
12
|
+
const scenes = /* @__PURE__ */ new Map();
|
|
13
|
+
const scroll = /* @__PURE__ */ new Map();
|
|
14
|
+
function graphFor(rootId) {
|
|
15
|
+
return scenes.get(rootId)?.graph ?? getDocument();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The frame as play shows it before a change: the document while play has not changed it, else
|
|
19
|
+
* a copy of play's copy, which the change is about to edit in place.
|
|
20
|
+
*/
|
|
21
|
+
function frameBefore(rootId) {
|
|
22
|
+
const scene = scenes.get(rootId);
|
|
23
|
+
if (!scene) return {
|
|
24
|
+
graph: getDocument(),
|
|
25
|
+
rootId
|
|
26
|
+
};
|
|
27
|
+
const pageId = findPageId(scene.graph, rootId) ?? scene.graph.rootId;
|
|
28
|
+
return {
|
|
29
|
+
graph: extractPageContext(scene.graph, pageId, [rootId], { shareTables: true }),
|
|
30
|
+
rootId
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs a Change to on `rootId`'s copy, and with a Smart animate transition the animation from the
|
|
35
|
+
* frame as it was.
|
|
36
|
+
*/
|
|
37
|
+
function changeWith(rootId, sourceId, variantId, transition) {
|
|
38
|
+
const from = transition?.type === "SMART_ANIMATE" && transition.duration > 0 && changeTarget(graphFor(rootId), rootId, sourceId, variantId) ? frameBefore(rootId) : null;
|
|
39
|
+
const changed = changeIn(rootId, sourceId, variantId);
|
|
40
|
+
if (!changed || !from) return { changed };
|
|
41
|
+
const to = {
|
|
42
|
+
graph: graphFor(rootId),
|
|
43
|
+
rootId
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
changed,
|
|
47
|
+
animation: createSmartAnimation(from, to, transition?.easing)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function changeIn(rootId, sourceId, variantId) {
|
|
51
|
+
if (!changeTarget(graphFor(rootId), rootId, sourceId, variantId)) return null;
|
|
52
|
+
const scene = scenes.get(rootId) ?? createPlayScene(getDocument(), rootId);
|
|
53
|
+
const change = scene.changeTo(sourceId, variantId);
|
|
54
|
+
scenes.delete(rootId);
|
|
55
|
+
scenes.set(rootId, scene);
|
|
56
|
+
for (const oldest of scenes.keys()) {
|
|
57
|
+
if (scenes.size <= limit) break;
|
|
58
|
+
scenes.delete(oldest);
|
|
59
|
+
}
|
|
60
|
+
if (change) clampScroll(scene.graph, scroll);
|
|
61
|
+
return change;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
graphFor,
|
|
65
|
+
views: scenes,
|
|
66
|
+
scroll,
|
|
67
|
+
scrollBy(rootId, path, dx, dy) {
|
|
68
|
+
return scrollAlong(graphFor(rootId), scroll, path, dx, dy);
|
|
69
|
+
},
|
|
70
|
+
setScroll(id, offset) {
|
|
71
|
+
scroll.set(id, offset);
|
|
72
|
+
},
|
|
73
|
+
run(session, { sourceId, action }, rootId = shownFrame(session)) {
|
|
74
|
+
if (action.type === "NODE" && action.navigation === "CHANGE_TO") {
|
|
75
|
+
if (!action.nodeId) return {
|
|
76
|
+
session,
|
|
77
|
+
changed: null
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
session,
|
|
81
|
+
...changeWith(rootId, sourceId, action.nodeId, action.transition)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (action.type === "NODE" && action.navigation === "SCROLL_TO") {
|
|
85
|
+
if (!action.nodeId) return {
|
|
86
|
+
session,
|
|
87
|
+
changed: null,
|
|
88
|
+
scrolled: [],
|
|
89
|
+
reveal: null
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
session,
|
|
93
|
+
changed: null,
|
|
94
|
+
...scrollIntoView(graphFor(rootId), scroll, rootId, action.nodeId)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
session: step(getDocument(), session, action),
|
|
99
|
+
changed: null
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
revert(session, revert) {
|
|
103
|
+
if (revert.kind === "change") {
|
|
104
|
+
const graph = graphFor(revert.rootId);
|
|
105
|
+
const instance = graph.getNode(revert.instanceId);
|
|
106
|
+
if (!instance || instanceMainComponent(graph, instance)?.id !== revert.to) return {
|
|
107
|
+
session,
|
|
108
|
+
changed: null
|
|
109
|
+
};
|
|
110
|
+
const { rootId, instanceId, from, transition } = revert;
|
|
111
|
+
return {
|
|
112
|
+
session,
|
|
113
|
+
...changeWith(rootId, instanceId, from, transition)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!(revert.kind === "overlay" ? session.overlays.at(-1) === revert.frameId : session.frameId === revert.frameId)) return {
|
|
117
|
+
session,
|
|
118
|
+
changed: null
|
|
119
|
+
};
|
|
120
|
+
const action = { type: revert.kind === "overlay" ? "CLOSE" : "BACK" };
|
|
121
|
+
return {
|
|
122
|
+
session: step(getDocument(), session, action),
|
|
123
|
+
changed: null
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
instanceTimeouts(rootId) {
|
|
127
|
+
const graph = graphFor(rootId);
|
|
128
|
+
const timeouts = [];
|
|
129
|
+
const sourceOf = componentLayerResolver(graph);
|
|
130
|
+
const collect = (node, variantId, inherited) => {
|
|
131
|
+
for (const reaction of reactionsWithInherited(node, inherited)) {
|
|
132
|
+
const action = reaction.trigger.type === "AFTER_TIMEOUT" && primaryAction(reaction);
|
|
133
|
+
if (!action) continue;
|
|
134
|
+
timeouts.push({
|
|
135
|
+
sourceId: node.id,
|
|
136
|
+
variantId,
|
|
137
|
+
reactionId: reaction.id,
|
|
138
|
+
action,
|
|
139
|
+
delayMs: reaction.trigger.delay * 1e3
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const visit = (id) => {
|
|
144
|
+
for (const child of graph.getChildren(id)) {
|
|
145
|
+
if (child.type === "INSTANCE") {
|
|
146
|
+
const main = instanceMainComponent(graph, child);
|
|
147
|
+
if (main) collect(child, main.id, main.prototypeReactions);
|
|
148
|
+
} else {
|
|
149
|
+
const source = sourceOf(child);
|
|
150
|
+
if (source && source.id !== child.id) collect(child, source.id, source.prototypeReactions);
|
|
151
|
+
}
|
|
152
|
+
visit(child.id);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
visit(rootId);
|
|
156
|
+
return timeouts;
|
|
157
|
+
},
|
|
158
|
+
forget(nodeIds) {
|
|
159
|
+
const design = getDocument();
|
|
160
|
+
for (const id of nodeIds) for (const [rootId, scene] of scenes) {
|
|
161
|
+
const copied = scene.graph.getNode(id);
|
|
162
|
+
const held = copied !== void 0 && copied.type !== "CANVAS" && id !== scene.graph.rootId;
|
|
163
|
+
if (design.isDescendant(id, rootId) || held) scenes.delete(rootId);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
clear() {
|
|
167
|
+
scenes.clear();
|
|
168
|
+
scroll.clear();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { PLAY_SCENE_LIMIT, createPlayScenes };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=scenes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenes.js","names":[],"sources":["../../src/prototype/scenes.ts"],"sourcesContent":["import type {\n PrototypeAction,\n PrototypeReaction,\n PrototypeTransition,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { extractPageContext, findPageId } from '#core/io/subgraph'\n\nimport type { PlayRevert } from './pointer'\nimport { componentLayerResolver, reactionsWithInherited } from './reactions'\nimport {\n changeTarget,\n createPlayScene,\n type PlayChange,\n type PlayScene,\n type PlaySceneView\n} from './scene'\nimport { clampScroll, scrollAlong, scrollIntoView, type ScrollChange } from './scroll'\nimport { primaryAction, shownFrame, step, type PlayClick, type PlaySession } from './session'\nimport {\n createSmartAnimation,\n type PlayFrame,\n type SmartAnimation\n} from './smart-animate/animation'\n\n/** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */\nexport const PLAY_SCENE_LIMIT = 4\n\n/**\n * An After delay reaction the layers a frame shows add: the layer it runs from, which is an\n * instance or a copy inside one, the main component or layer it stands for, whose reaction it is,\n * the reaction, its action, and the delay in milliseconds.\n */\nexport interface PlayTimeout {\n sourceId: string\n /** The main component an instance shows, or the main layer a copy stands for. */\n variantId: string\n reactionId: string\n action: PrototypeAction\n delayMs: number\n}\n\n/**\n * What a reaction did: the session after it, and the Change to it made, if it made one. A Scroll\n * to also says which frames it scrolled, for an animation to step between, and where the layer it\n * scrolled to is drawn now, for a screen that scrolls by panning to bring into view.\n */\nexport interface PlayStep {\n session: PlaySession\n changed: PlayChange | null\n scrolled?: ScrollChange[]\n reveal?: Vector | null\n /**\n * A Smart animate Change to's animation from the frame as it was to its copy as it is now, for\n * the player to run over the transition's duration; the copy shows the change at once.\n */\n animation?: SmartAnimation\n}\n\n/**\n * The frames play changed, each kept as a private copy so the document never changes. Frames move\n * through the session as before; a Change to switches an instance on its frame's copy, which is\n * made at the first change, so a prototype without one copies nothing.\n */\nexport interface PlayScenes {\n /** The graph play reads a top-level frame from: its copy once changed, else the document. */\n graphFor(rootId: string): SceneGraph\n /** The changed frames the canvas draws from their copies, by frame id. */\n readonly views: ReadonlyMap<string, PlaySceneView>\n /** How far play scrolled each frame that scrolls, by frame id. */\n readonly scroll: ReadonlyMap<string, Vector>\n /**\n * Scrolls the frames along `path`, a pointer's path in `rootId`, innermost first, and returns\n * what none of them could take, for the canvas to pan by.\n */\n scrollBy(rootId: string, path: readonly string[], dx: number, dy: number): Vector\n /** Sets one frame's offset, as an animated Scroll to steps it toward where it ends. */\n setScroll(id: string, offset: Vector): void\n /** Runs a reaction of a layer in `rootId`, the shown frame unless a timer names another. */\n run(session: PlaySession, click: PlayClick, rootId?: string): PlayStep\n /**\n * Undoes a While hovering or While pressing reaction, unless play moved on from what it did: an\n * instance that shows another variant by now, or an overlay or frame no longer shown.\n */\n revert(session: PlaySession, revert: PlayRevert): PlayStep\n /**\n * The After delay reactions of the instances `rootId` shows and of the copies inside them, by\n * the variants and main layers they stand for now.\n */\n instanceTimeouts(rootId: string): PlayTimeout[]\n /**\n * Drops the copies of frames that hold any of these document layers, after an edit to them:\n * the frame's own layers and the variants its copy holds.\n */\n forget(nodeIds: Iterable<string>): void\n clear(): void\n}\n\nexport function createPlayScenes(\n getDocument: () => SceneGraph,\n limit = PLAY_SCENE_LIMIT\n): PlayScenes {\n // Insertion order is use order: a frame changed again moves to the end, and the first goes.\n const scenes = new Map<string, PlayScene>()\n const scroll = new Map<string, Vector>()\n\n function graphFor(rootId: string): SceneGraph {\n return scenes.get(rootId)?.graph ?? getDocument()\n }\n\n /**\n * The frame as play shows it before a change: the document while play has not changed it, else\n * a copy of play's copy, which the change is about to edit in place.\n */\n function frameBefore(rootId: string): PlayFrame {\n const scene = scenes.get(rootId)\n if (!scene) return { graph: getDocument(), rootId }\n const pageId = findPageId(scene.graph, rootId) ?? scene.graph.rootId\n return {\n graph: extractPageContext(scene.graph, pageId, [rootId], { shareTables: true }),\n rootId\n }\n }\n\n /**\n * Runs a Change to on `rootId`'s copy, and with a Smart animate transition the animation from the\n * frame as it was.\n */\n function changeWith(\n rootId: string,\n sourceId: string,\n variantId: string,\n transition: PrototypeTransition | null\n ): Pick<PlayStep, 'changed' | 'animation'> {\n const smart = transition?.type === 'SMART_ANIMATE' && transition.duration > 0\n const before = smart && changeTarget(graphFor(rootId), rootId, sourceId, variantId)\n const from = before ? frameBefore(rootId) : null\n const changed = changeIn(rootId, sourceId, variantId)\n if (!changed || !from) return { changed }\n const to = { graph: graphFor(rootId), rootId }\n return { changed, animation: createSmartAnimation(from, to, transition?.easing) }\n }\n\n function changeIn(rootId: string, sourceId: string, variantId: string): PlayChange | null {\n // Checked on what play shows now, so a Change to that cannot run copies nothing.\n if (!changeTarget(graphFor(rootId), rootId, sourceId, variantId)) return null\n const scene = scenes.get(rootId) ?? createPlayScene(getDocument(), rootId)\n const change = scene.changeTo(sourceId, variantId)\n scenes.delete(rootId)\n scenes.set(rootId, scene)\n for (const oldest of scenes.keys()) {\n if (scenes.size <= limit) break\n scenes.delete(oldest)\n }\n // What the switched instance holds may be shorter now than a frame scrolled past.\n if (change) clampScroll(scene.graph, scroll)\n return change\n }\n\n return {\n graphFor,\n views: scenes,\n scroll,\n scrollBy(rootId, path, dx, dy) {\n return scrollAlong(graphFor(rootId), scroll, path, dx, dy)\n },\n setScroll(id, offset) {\n scroll.set(id, offset)\n },\n run(session, { sourceId, action }, rootId = shownFrame(session)) {\n if (action.type === 'NODE' && action.navigation === 'CHANGE_TO') {\n if (!action.nodeId) return { session, changed: null }\n return { session, ...changeWith(rootId, sourceId, action.nodeId, action.transition) }\n }\n if (action.type === 'NODE' && action.navigation === 'SCROLL_TO') {\n if (!action.nodeId) return { session, changed: null, scrolled: [], reveal: null }\n const moved = scrollIntoView(graphFor(rootId), scroll, rootId, action.nodeId)\n return { session, changed: null, ...moved }\n }\n return { session: step(getDocument(), session, action), changed: null }\n },\n revert(session, revert) {\n if (revert.kind === 'change') {\n const graph = graphFor(revert.rootId)\n const instance = graph.getNode(revert.instanceId)\n if (!instance || instanceMainComponent(graph, instance)?.id !== revert.to) {\n return { session, changed: null }\n }\n const { rootId, instanceId, from, transition } = revert\n return { session, ...changeWith(rootId, instanceId, from, transition) }\n }\n const shown =\n revert.kind === 'overlay'\n ? session.overlays.at(-1) === revert.frameId\n : session.frameId === revert.frameId\n if (!shown) return { session, changed: null }\n const action = { type: revert.kind === 'overlay' ? 'CLOSE' : 'BACK' } as const\n return { session: step(getDocument(), session, action), changed: null }\n },\n instanceTimeouts(rootId) {\n const graph = graphFor(rootId)\n const timeouts: PlayTimeout[] = []\n const sourceOf = componentLayerResolver(graph)\n const collect = (node: SceneNode, variantId: string, inherited: PrototypeReaction[]) => {\n for (const reaction of reactionsWithInherited(node, inherited)) {\n const action = reaction.trigger.type === 'AFTER_TIMEOUT' && primaryAction(reaction)\n if (!action) continue\n timeouts.push({\n sourceId: node.id,\n variantId,\n reactionId: reaction.id,\n action,\n delayMs: reaction.trigger.delay * 1000\n })\n }\n }\n const visit = (id: string) => {\n for (const child of graph.getChildren(id)) {\n if (child.type === 'INSTANCE') {\n const main = instanceMainComponent(graph, child)\n if (main) collect(child, main.id, main.prototypeReactions)\n } else {\n // A plain copy inherits its main layer's After delay; the resolver reads each\n // instance's copy map once, so arming costs one search per instance, not per copy.\n const source = sourceOf(child)\n if (source && source.id !== child.id)\n collect(child, source.id, source.prototypeReactions)\n }\n visit(child.id)\n }\n }\n visit(rootId)\n return timeouts\n },\n forget(nodeIds) {\n const design = getDocument()\n for (const id of nodeIds) {\n for (const [rootId, scene] of scenes) {\n // The copy holds the frame and every variant its instances switch to, wherever they\n // are, under the page and document it copied, which an edit elsewhere touches too.\n const copied = scene.graph.getNode(id)\n const held = copied !== undefined && copied.type !== 'CANVAS' && id !== scene.graph.rootId\n if (design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AAS;GACd,MAAM,SAAS,YAAY;GAC3B,KAAK,MAAM,MAAM,SACf,KAAK,MAAM,CAAC,QAAQ,UAAU,QAAQ;IAGpC,MAAM,SAAS,MAAM,MAAM,QAAQ,EAAE;IACrC,MAAM,OAAO,WAAW,KAAA,KAAa,OAAO,SAAS,YAAY,OAAO,MAAM,MAAM;IACpF,IAAI,OAAO,aAAa,IAAI,MAAM,KAAK,MAAM,OAAO,OAAO,MAAM;GACnE;EAEJ;EACA,QAAQ;GACN,OAAO,MAAM;GACb,OAAO,MAAM;EACf;CACF;AACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
import { Vector } from "@pairdraw/scene-graph/primitives";
|
|
3
|
+
//#region src/prototype/scroll.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether play scrolls a frame's content inside it: a frame, component, or instance with overflow
|
|
6
|
+
* scrolling that clips, as Figma needs for a frame inside another. A rotated one does not scroll.
|
|
7
|
+
*/
|
|
8
|
+
declare function scrollsInPlay(node: SceneNode): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* How far play may scroll a frame's content, along the axes it scrolls: how far its visible
|
|
11
|
+
* layers reach past its edge, with an auto layout's trailing padding, as Figma scrolls to it.
|
|
12
|
+
*/
|
|
13
|
+
declare function scrollRange(graph: SceneGraph, nodeId: string): Vector;
|
|
14
|
+
/**
|
|
15
|
+
* Scrolls the frames along `path`, innermost first, by as much as each can move, and passes the
|
|
16
|
+
* rest outward, as a browser chains a scroll. Returns what none of them could take.
|
|
17
|
+
*/
|
|
18
|
+
declare function scrollAlong(graph: SceneGraph, scroll: Map<string, Vector>, path: readonly string[], dx: number, dy: number): Vector;
|
|
19
|
+
/** Keeps every offset within its frame's range, after a change resized what the frame holds. */
|
|
20
|
+
declare function clampScroll(graph: SceneGraph, scroll: Map<string, Vector>): void;
|
|
21
|
+
/** One frame a Scroll to moved, from and to its offsets, for an animation to step between. */
|
|
22
|
+
interface ScrollChange {
|
|
23
|
+
id: string;
|
|
24
|
+
from: Vector;
|
|
25
|
+
to: Vector;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Scrolls every frame around `targetId` inside `rootId`, innermost first, so the layer meets each
|
|
29
|
+
* one's top left as far as it can scroll, as Figma's Scroll to does. Returns the frames it moved,
|
|
30
|
+
* and where the layer is now drawn, for a screen that scrolls by panning to bring into view.
|
|
31
|
+
*/
|
|
32
|
+
declare function scrollIntoView(graph: SceneGraph, scroll: Map<string, Vector>, rootId: string, targetId: string): {
|
|
33
|
+
scrolled: ScrollChange[];
|
|
34
|
+
reveal: Vector | null;
|
|
35
|
+
};
|
|
36
|
+
declare function scrollShiftX(node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>, scroll: Vector | undefined): number;
|
|
37
|
+
declare function scrollShiftY(node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>, scroll: Vector | undefined): number;
|
|
38
|
+
/**
|
|
39
|
+
* The children of a frame play scrolled, in the order they draw: the layers that scroll with the
|
|
40
|
+
* content first, then the fixed and sticky ones above them, as Figma lifts fixed children over the
|
|
41
|
+
* scrolling content. Each group keeps its layer order. A mask and the layers it masks are never
|
|
42
|
+
* lifted, so a mask run stays together; without an offset, or with nothing to lift, the order is
|
|
43
|
+
* the one given.
|
|
44
|
+
*/
|
|
45
|
+
declare function liftedChildIds(graph: SceneGraph, childIds: readonly string[], scroll: Vector | undefined): readonly string[];
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ScrollChange, clampScroll, liftedChildIds, scrollAlong, scrollIntoView, scrollRange, scrollShiftX, scrollShiftY, scrollsInPlay };
|
|
48
|
+
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.d.ts","names":[],"sources":["../../src/prototype/scroll.ts"],"mappings":";;;;;;;iBAYgB,cAAc,MAAM;;;;;iBAapB,YAAY,OAAO,YAAY,iBAAiB;;;;;iBAyBhD,YACd,OAAO,YACP,QAAQ,YAAY,SACpB,yBACA,YACA,aACC;;iBAoBa,YAAY,OAAO,YAAY,QAAQ,YAAY;;UASlD;EACf;EACA,MAAM;EACN,IAAI;;;;;;;iBAQU,eACd,OAAO,YACP,QAAQ,YAAY,SACpB,gBACA;EACG,UAAU;EAAgB,QAAQ;;iBA2CvB,aACd,MAAM,KAAK,0CACX,QAAQ;iBAKM,aACd,MAAM,KAAK,0CACX,QAAQ;;;;;;;;iBAYM,eACd,OAAO,YACP,6BACA,QAAQ"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { getAxisAlignedWorldBounds } from "@pairdraw/scene-graph/coordinate";
|
|
2
|
+
import { clamp } from "es-toolkit";
|
|
3
|
+
//#region src/prototype/scroll.ts
|
|
4
|
+
const NO_SCROLL = {
|
|
5
|
+
x: 0,
|
|
6
|
+
y: 0
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Whether play scrolls a frame's content inside it: a frame, component, or instance with overflow
|
|
10
|
+
* scrolling that clips, as Figma needs for a frame inside another. A rotated one does not scroll.
|
|
11
|
+
*/
|
|
12
|
+
function scrollsInPlay(node) {
|
|
13
|
+
return (node.type === "FRAME" || node.type === "COMPONENT" || node.type === "INSTANCE") && node.overflowDirection !== "NONE" && node.clipsContent && node.rotation === 0;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* How far play may scroll a frame's content, along the axes it scrolls: how far its visible
|
|
17
|
+
* layers reach past its edge, with an auto layout's trailing padding, as Figma scrolls to it.
|
|
18
|
+
*/
|
|
19
|
+
function scrollRange(graph, nodeId) {
|
|
20
|
+
const node = graph.getNode(nodeId);
|
|
21
|
+
if (!node || !scrollsInPlay(node)) return NO_SCROLL;
|
|
22
|
+
const frame = getAxisAlignedWorldBounds(node, graph);
|
|
23
|
+
let right = 0;
|
|
24
|
+
let bottom = 0;
|
|
25
|
+
for (const child of graph.getChildren(nodeId)) {
|
|
26
|
+
if (!child.visible) continue;
|
|
27
|
+
const bounds = getAxisAlignedWorldBounds(child, graph);
|
|
28
|
+
right = Math.max(right, bounds.x + bounds.width - frame.x);
|
|
29
|
+
bottom = Math.max(bottom, bounds.y + bounds.height - frame.y);
|
|
30
|
+
}
|
|
31
|
+
const flows = node.layoutMode !== "NONE";
|
|
32
|
+
const horizontal = node.overflowDirection === "HORIZONTAL" || node.overflowDirection === "BOTH";
|
|
33
|
+
const vertical = node.overflowDirection === "VERTICAL" || node.overflowDirection === "BOTH";
|
|
34
|
+
return {
|
|
35
|
+
x: horizontal ? Math.max(0, right + (flows ? node.paddingRight : 0) - frame.width) : 0,
|
|
36
|
+
y: vertical ? Math.max(0, bottom + (flows ? node.paddingBottom : 0) - frame.height) : 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Scrolls the frames along `path`, innermost first, by as much as each can move, and passes the
|
|
41
|
+
* rest outward, as a browser chains a scroll. Returns what none of them could take.
|
|
42
|
+
*/
|
|
43
|
+
function scrollAlong(graph, scroll, path, dx, dy) {
|
|
44
|
+
let restX = dx;
|
|
45
|
+
let restY = dy;
|
|
46
|
+
for (const id of [...path].reverse()) {
|
|
47
|
+
if (restX === 0 && restY === 0) break;
|
|
48
|
+
const range = scrollRange(graph, id);
|
|
49
|
+
if (range.x === 0 && range.y === 0) continue;
|
|
50
|
+
const current = scroll.get(id) ?? NO_SCROLL;
|
|
51
|
+
const next = {
|
|
52
|
+
x: clamp(current.x + restX, 0, range.x),
|
|
53
|
+
y: clamp(current.y + restY, 0, range.y)
|
|
54
|
+
};
|
|
55
|
+
restX -= next.x - current.x;
|
|
56
|
+
restY -= next.y - current.y;
|
|
57
|
+
scroll.set(id, next);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
x: restX,
|
|
61
|
+
y: restY
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Keeps every offset within its frame's range, after a change resized what the frame holds. */
|
|
65
|
+
function clampScroll(graph, scroll) {
|
|
66
|
+
for (const [id, offset] of scroll) {
|
|
67
|
+
if (!graph.getNode(id)) continue;
|
|
68
|
+
const range = scrollRange(graph, id);
|
|
69
|
+
scroll.set(id, {
|
|
70
|
+
x: Math.min(offset.x, range.x),
|
|
71
|
+
y: Math.min(offset.y, range.y)
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Scrolls every frame around `targetId` inside `rootId`, innermost first, so the layer meets each
|
|
77
|
+
* one's top left as far as it can scroll, as Figma's Scroll to does. Returns the frames it moved,
|
|
78
|
+
* and where the layer is now drawn, for a screen that scrolls by panning to bring into view.
|
|
79
|
+
*/
|
|
80
|
+
function scrollIntoView(graph, scroll, rootId, targetId) {
|
|
81
|
+
const target = graph.getNode(targetId);
|
|
82
|
+
if (!target || target.id === rootId || !graph.isDescendant(targetId, rootId)) return {
|
|
83
|
+
scrolled: [],
|
|
84
|
+
reveal: null
|
|
85
|
+
};
|
|
86
|
+
const place = getAxisAlignedWorldBounds(target, graph);
|
|
87
|
+
const scrolled = [];
|
|
88
|
+
let shiftX = 0;
|
|
89
|
+
let shiftY = 0;
|
|
90
|
+
graph.closest(target.parentId ?? rootId, (frame) => {
|
|
91
|
+
const range = scrollRange(graph, frame.id);
|
|
92
|
+
if (range.x > 0 || range.y > 0) {
|
|
93
|
+
const box = getAxisAlignedWorldBounds(frame, graph);
|
|
94
|
+
const from = scroll.get(frame.id) ?? NO_SCROLL;
|
|
95
|
+
const to = {
|
|
96
|
+
x: clamp(place.x - shiftX - box.x, 0, range.x),
|
|
97
|
+
y: clamp(place.y - shiftY - box.y, 0, range.y)
|
|
98
|
+
};
|
|
99
|
+
scroll.set(frame.id, to);
|
|
100
|
+
scrolled.push({
|
|
101
|
+
id: frame.id,
|
|
102
|
+
from,
|
|
103
|
+
to
|
|
104
|
+
});
|
|
105
|
+
shiftX += to.x;
|
|
106
|
+
shiftY += to.y;
|
|
107
|
+
}
|
|
108
|
+
return frame.id === rootId;
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
scrolled,
|
|
112
|
+
reveal: {
|
|
113
|
+
x: place.x - shiftX,
|
|
114
|
+
y: place.y - shiftY
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* How far a layer is counter-shifted when it opts out of its frame's scroll: all of the offset
|
|
120
|
+
* for a fixed layer, and only the part past its own start for a sticky one, so it scrolls until
|
|
121
|
+
* it reaches the frame's top or left edge and then stays there.
|
|
122
|
+
*/
|
|
123
|
+
function scrollShift(node, scroll, axis) {
|
|
124
|
+
if (!scroll || node.scrollBehavior === "SCROLLS") return 0;
|
|
125
|
+
if (node.scrollBehavior === "FIXED") return scroll[axis];
|
|
126
|
+
return Math.max(0, scroll[axis] - node[axis]);
|
|
127
|
+
}
|
|
128
|
+
function scrollShiftX(node, scroll) {
|
|
129
|
+
return scrollShift(node, scroll, "x");
|
|
130
|
+
}
|
|
131
|
+
function scrollShiftY(node, scroll) {
|
|
132
|
+
return scrollShift(node, scroll, "y");
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The children of a frame play scrolled, in the order they draw: the layers that scroll with the
|
|
136
|
+
* content first, then the fixed and sticky ones above them, as Figma lifts fixed children over the
|
|
137
|
+
* scrolling content. Each group keeps its layer order. A mask and the layers it masks are never
|
|
138
|
+
* lifted, so a mask run stays together; without an offset, or with nothing to lift, the order is
|
|
139
|
+
* the one given.
|
|
140
|
+
*/
|
|
141
|
+
function liftedChildIds(graph, childIds, scroll) {
|
|
142
|
+
if (!scroll) return childIds;
|
|
143
|
+
const nodes = childIds.map((id) => graph.getNode(id));
|
|
144
|
+
const lifts = nodes.map((node) => node !== void 0 && !node.isMask && node.scrollBehavior !== "SCROLLS");
|
|
145
|
+
if (!lifts.some(Boolean)) return childIds;
|
|
146
|
+
let masked = false;
|
|
147
|
+
const lift = nodes.map((node, index) => {
|
|
148
|
+
if (node?.isMask) masked = true;
|
|
149
|
+
return lifts[index] && !masked;
|
|
150
|
+
});
|
|
151
|
+
const scrolling = [];
|
|
152
|
+
const staying = [];
|
|
153
|
+
for (let index = 0; index < childIds.length; index++) (lift[index] ? staying : scrolling).push(childIds[index]);
|
|
154
|
+
return [...scrolling, ...staying];
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { clampScroll, liftedChildIds, scrollAlong, scrollIntoView, scrollRange, scrollShiftX, scrollShiftY, scrollsInPlay };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.js","names":[],"sources":["../../src/prototype/scroll.ts"],"sourcesContent":["import { clamp } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nconst NO_SCROLL: Vector = { x: 0, y: 0 }\n\n/**\n * Whether play scrolls a frame's content inside it: a frame, component, or instance with overflow\n * scrolling that clips, as Figma needs for a frame inside another. A rotated one does not scroll.\n */\nexport function scrollsInPlay(node: SceneNode): boolean {\n return (\n (node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE') &&\n node.overflowDirection !== 'NONE' &&\n node.clipsContent &&\n node.rotation === 0\n )\n}\n\n/**\n * How far play may scroll a frame's content, along the axes it scrolls: how far its visible\n * layers reach past its edge, with an auto layout's trailing padding, as Figma scrolls to it.\n */\nexport function scrollRange(graph: SceneGraph, nodeId: string): Vector {\n const node = graph.getNode(nodeId)\n if (!node || !scrollsInPlay(node)) return NO_SCROLL\n const frame = getAxisAlignedWorldBounds(node, graph)\n let right = 0\n let bottom = 0\n for (const child of graph.getChildren(nodeId)) {\n if (!child.visible) continue\n const bounds = getAxisAlignedWorldBounds(child, graph)\n right = Math.max(right, bounds.x + bounds.width - frame.x)\n bottom = Math.max(bottom, bounds.y + bounds.height - frame.y)\n }\n const flows = node.layoutMode !== 'NONE'\n const horizontal = node.overflowDirection === 'HORIZONTAL' || node.overflowDirection === 'BOTH'\n const vertical = node.overflowDirection === 'VERTICAL' || node.overflowDirection === 'BOTH'\n return {\n x: horizontal ? Math.max(0, right + (flows ? node.paddingRight : 0) - frame.width) : 0,\n y: vertical ? Math.max(0, bottom + (flows ? node.paddingBottom : 0) - frame.height) : 0\n }\n}\n\n/**\n * Scrolls the frames along `path`, innermost first, by as much as each can move, and passes the\n * rest outward, as a browser chains a scroll. Returns what none of them could take.\n */\nexport function scrollAlong(\n graph: SceneGraph,\n scroll: Map<string, Vector>,\n path: readonly string[],\n dx: number,\n dy: number\n): Vector {\n let restX = dx\n let restY = dy\n for (const id of [...path].reverse()) {\n if (restX === 0 && restY === 0) break\n const range = scrollRange(graph, id)\n if (range.x === 0 && range.y === 0) continue\n const current = scroll.get(id) ?? NO_SCROLL\n const next = {\n x: clamp(current.x + restX, 0, range.x),\n y: clamp(current.y + restY, 0, range.y)\n }\n restX -= next.x - current.x\n restY -= next.y - current.y\n scroll.set(id, next)\n }\n return { x: restX, y: restY }\n}\n\n/** Keeps every offset within its frame's range, after a change resized what the frame holds. */\nexport function clampScroll(graph: SceneGraph, scroll: Map<string, Vector>): void {\n for (const [id, offset] of scroll) {\n if (!graph.getNode(id)) continue\n const range = scrollRange(graph, id)\n scroll.set(id, { x: Math.min(offset.x, range.x), y: Math.min(offset.y, range.y) })\n }\n}\n\n/** One frame a Scroll to moved, from and to its offsets, for an animation to step between. */\nexport interface ScrollChange {\n id: string\n from: Vector\n to: Vector\n}\n\n/**\n * Scrolls every frame around `targetId` inside `rootId`, innermost first, so the layer meets each\n * one's top left as far as it can scroll, as Figma's Scroll to does. Returns the frames it moved,\n * and where the layer is now drawn, for a screen that scrolls by panning to bring into view.\n */\nexport function scrollIntoView(\n graph: SceneGraph,\n scroll: Map<string, Vector>,\n rootId: string,\n targetId: string\n): { scrolled: ScrollChange[]; reveal: Vector | null } {\n const target = graph.getNode(targetId)\n if (!target || target.id === rootId || !graph.isDescendant(targetId, rootId)) {\n return { scrolled: [], reveal: null }\n }\n const place = getAxisAlignedWorldBounds(target, graph)\n const scrolled: ScrollChange[] = []\n let shiftX = 0\n let shiftY = 0\n graph.closest(target.parentId ?? rootId, (frame) => {\n const range = scrollRange(graph, frame.id)\n if (range.x > 0 || range.y > 0) {\n const box = getAxisAlignedWorldBounds(frame, graph)\n const from = scroll.get(frame.id) ?? NO_SCROLL\n const to = {\n x: clamp(place.x - shiftX - box.x, 0, range.x),\n y: clamp(place.y - shiftY - box.y, 0, range.y)\n }\n scroll.set(frame.id, to)\n scrolled.push({ id: frame.id, from, to })\n shiftX += to.x\n shiftY += to.y\n }\n return frame.id === rootId\n })\n return { scrolled, reveal: { x: place.x - shiftX, y: place.y - shiftY } }\n}\n\n/**\n * How far a layer is counter-shifted when it opts out of its frame's scroll: all of the offset\n * for a fixed layer, and only the part past its own start for a sticky one, so it scrolls until\n * it reaches the frame's top or left edge and then stays there.\n */\nfunction scrollShift(\n node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,\n scroll: Vector | undefined,\n axis: 'x' | 'y'\n): number {\n if (!scroll || node.scrollBehavior === 'SCROLLS') return 0\n if (node.scrollBehavior === 'FIXED') return scroll[axis]\n return Math.max(0, scroll[axis] - node[axis])\n}\n\nexport function scrollShiftX(\n node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,\n scroll: Vector | undefined\n): number {\n return scrollShift(node, scroll, 'x')\n}\n\nexport function scrollShiftY(\n node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,\n scroll: Vector | undefined\n): number {\n return scrollShift(node, scroll, 'y')\n}\n\n/**\n * The children of a frame play scrolled, in the order they draw: the layers that scroll with the\n * content first, then the fixed and sticky ones above them, as Figma lifts fixed children over the\n * scrolling content. Each group keeps its layer order. A mask and the layers it masks are never\n * lifted, so a mask run stays together; without an offset, or with nothing to lift, the order is\n * the one given.\n */\nexport function liftedChildIds(\n graph: SceneGraph,\n childIds: readonly string[],\n scroll: Vector | undefined\n): readonly string[] {\n if (!scroll) return childIds\n const nodes = childIds.map((id) => graph.getNode(id))\n const lifts = nodes.map(\n (node) => node !== undefined && !node.isMask && node.scrollBehavior !== 'SCROLLS'\n )\n if (!lifts.some(Boolean)) return childIds\n // A mask belongs to the layers after it until the next mask; a lifted layer inside a mask run\n // stays in the run so the mask still clips it.\n let masked = false\n const lift = nodes.map((node, index) => {\n if (node?.isMask) masked = true\n return lifts[index] && !masked\n })\n const scrolling: string[] = []\n const staying: string[] = []\n for (let index = 0; index < childIds.length; index++) {\n ;(lift[index] ? staying : scrolling).push(childIds[index])\n }\n return [...scrolling, ...staying]\n}\n"],"mappings":";;;AAMA,MAAM,YAAoB;CAAE,GAAG;CAAG,GAAG;AAAE;;;;;AAMvC,SAAgB,cAAc,MAA0B;CACtD,QACG,KAAK,SAAS,WAAW,KAAK,SAAS,eAAe,KAAK,SAAS,eACrE,KAAK,sBAAsB,UAC3B,KAAK,gBACL,KAAK,aAAa;AAEtB;;;;;AAMA,SAAgB,YAAY,OAAmB,QAAwB;CACrE,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,CAAC,QAAQ,CAAC,cAAc,IAAI,GAAG,OAAO;CAC1C,MAAM,QAAQ,0BAA0B,MAAM,KAAK;CACnD,IAAI,QAAQ;CACZ,IAAI,SAAS;CACb,KAAK,MAAM,SAAS,MAAM,YAAY,MAAM,GAAG;EAC7C,IAAI,CAAC,MAAM,SAAS;EACpB,MAAM,SAAS,0BAA0B,OAAO,KAAK;EACrD,QAAQ,KAAK,IAAI,OAAO,OAAO,IAAI,OAAO,QAAQ,MAAM,CAAC;EACzD,SAAS,KAAK,IAAI,QAAQ,OAAO,IAAI,OAAO,SAAS,MAAM,CAAC;CAC9D;CACA,MAAM,QAAQ,KAAK,eAAe;CAClC,MAAM,aAAa,KAAK,sBAAsB,gBAAgB,KAAK,sBAAs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d,OACA,UACA,QACmB;CACnB,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAQ,SAAS,KAAK,OAAO,MAAM,QAAQ,EAAE,CAAC;CACpD,MAAM,QAAQ,MAAM,KACjB,SAAS,SAAS,KAAA,KAAa,CAAC,KAAK,UAAU,KAAK,mBAAmB,SAC1E;CACA,IAAI,CAAC,MAAM,KAAK,OAAO,GAAG,OAAO;CAGjC,IAAI,SAAS;CACb,MAAM,OAAO,MAAM,KAAK,MAAM,UAAU;EACtC,IAAI,MAAM,QAAQ,SAAS;EAC3B,OAAO,MAAM,UAAU,CAAC;CAC1B,CAAC;CACD,MAAM,YAAsB,CAAC;CAC7B,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAC1C,CAAC,KAAK,SAAS,UAAU,UAAA,CAAW,KAAK,SAAS,MAAM;CAE3D,OAAO,CAAC,GAAG,WAAW,GAAG,OAAO;AAClC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { PrototypeAction, PrototypeReaction, PrototypeTransition, PrototypeTriggerType, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
import { Vector } from "@pairdraw/scene-graph/primitives";
|
|
3
|
+
//#region src/prototype/session.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The action a reaction runs: its first, which the prototype panel edits alone in this version, as
|
|
6
|
+
* Figma's first action row; `actions` keeps the array the `.fig` model and Figma's plugin API use.
|
|
7
|
+
*/
|
|
8
|
+
declare function primaryAction(reaction: PrototypeReaction): PrototypeAction | null;
|
|
9
|
+
/** Where play is: the frame it shows, the frame it started from, and the frames it came through. */
|
|
10
|
+
interface PlaySession {
|
|
11
|
+
/** The base frame under any open overlays. */
|
|
12
|
+
frameId: string;
|
|
13
|
+
/** The frame play started from, which Restart returns to. */
|
|
14
|
+
startFrameId: string;
|
|
15
|
+
/** Frames shown before this one, oldest first; Back returns to the last. */
|
|
16
|
+
history: string[];
|
|
17
|
+
/** Overlay frames open over the base frame, bottom first; the last is the one shown. */
|
|
18
|
+
overlays: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One reaction a pointer or a timer runs: the layer it runs from, its action, and the transition
|
|
22
|
+
* that action asked for.
|
|
23
|
+
*/
|
|
24
|
+
interface PlayClick {
|
|
25
|
+
/** The layer whose reaction runs, which a Change to switches the instance of. */
|
|
26
|
+
sourceId: string;
|
|
27
|
+
action: PrototypeAction;
|
|
28
|
+
transition: PrototypeTransition | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The frame play starts from: the selected frame, or the frame holding the selection; otherwise
|
|
32
|
+
* the page's first frame. Null when the page has no frames, so there is nothing to play.
|
|
33
|
+
*/
|
|
34
|
+
declare function startFrame(graph: SceneGraph, pageId: string, selectedIds: ReadonlySet<string>): string;
|
|
35
|
+
/**
|
|
36
|
+
* The top-level frame a node sits in: the page's direct child above it, when that child is a
|
|
37
|
+
* frame. Play fits and hit-tests top-level frames, as Figma's presentation does.
|
|
38
|
+
*/
|
|
39
|
+
declare function topFrameOf(graph: SceneGraph, node: SceneNode | null | undefined): SceneNode | null;
|
|
40
|
+
/** Starts playing the page from `frameId` with no history behind it. */
|
|
41
|
+
declare function startSession(frameId: string): PlaySession;
|
|
42
|
+
/** The frame the stage shows: the top overlay when one is open, else the base frame. */
|
|
43
|
+
declare function shownFrame(session: PlaySession): string;
|
|
44
|
+
/** Plays again from where the session started, as Restart does. */
|
|
45
|
+
declare function restartSession(session: PlaySession): PlaySession;
|
|
46
|
+
/**
|
|
47
|
+
* The reaction a click at a document point runs: the topmost layer under the point inside the
|
|
48
|
+
* shown frame that has a reaction to `trigger`, over its whole box, or that shows a paint there,
|
|
49
|
+
* and then its nearest ancestor with one, up to the frame, with the reaction's first action. An
|
|
50
|
+
* unpainted layer without one lets the click through. An instance runs the reactions of the variant it shows, and a frame
|
|
51
|
+
* play scrolled finds its layers where they are drawn.
|
|
52
|
+
*/
|
|
53
|
+
declare function reactionAt(graph: SceneGraph, session: PlaySession, x: number, y: number, trigger?: PrototypeTriggerType, scroll?: ReadonlyMap<string, Vector>): PlayClick | null;
|
|
54
|
+
/**
|
|
55
|
+
* The session after an action runs. `NAVIGATE` moves to its frame and remembers this one for
|
|
56
|
+
* Back; `OVERLAY` opens a frame over the screen and `CLOSE` takes the top one away; `BACK`
|
|
57
|
+
* returns to the previous screen and drops overlays, which are not history entries; an action
|
|
58
|
+
* this version cannot show leaves the session as it is.
|
|
59
|
+
*/
|
|
60
|
+
declare function step(graph: SceneGraph, session: PlaySession, action: PrototypeAction): PlaySession;
|
|
61
|
+
/**
|
|
62
|
+
* The `AFTER_TIMEOUT` reactions of the frame being shown, with their delays in milliseconds:
|
|
63
|
+
* what the stage schedules whenever the shown frame changes.
|
|
64
|
+
*/
|
|
65
|
+
declare function timeoutReactions(graph: SceneGraph, session: PlaySession): {
|
|
66
|
+
action: PrototypeAction;
|
|
67
|
+
delayMs: number;
|
|
68
|
+
}[];
|
|
69
|
+
//#endregion
|
|
70
|
+
export { PlayClick, PlaySession, primaryAction, reactionAt, restartSession, shownFrame, startFrame, startSession, step, timeoutReactions, topFrameOf };
|
|
71
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","names":[],"sources":["../../src/prototype/session.ts"],"mappings":";;;;;;;iBAkBgB,cAAc,UAAU,oBAAoB;;UAK3C;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;UAOe;;EAEf;EACA,QAAQ;EACR,YAAY;;;;;;iBAOE,WAAW,OAAO,YAAY,gBAAgB,aAAa;;;;;iBAe3D,WACd,OAAO,YACP,MAAM,+BACL;;iBAWa,aAAa,kBAAkB;;iBAK/B,WAAW,SAAS;;iBAKpB,eAAe,SAAS,cAAc;;;;;;;;iBAWtC,WACd,OAAO,YACP,SAAS,aACT,WACA,WACA,UAAS,sBACT,SAAS,oBAAoB,UAC5B;;;;;;;iBA8Ba,KACd,OAAO,YACP,SAAS,aACT,QAAQ,kBACP;;;;;iBAkCa,iBACd,OAAO,YACP,SAAS;EACN,QAAQ;EAAiB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { effectiveReactions } from "./reactions.js";
|
|
2
|
+
import { framesOnPage } from "./frames.js";
|
|
3
|
+
import { playHitTest } from "./hit.js";
|
|
4
|
+
//#region src/prototype/session.ts
|
|
5
|
+
/**
|
|
6
|
+
* The action a reaction runs: its first, which the prototype panel edits alone in this version, as
|
|
7
|
+
* Figma's first action row; `actions` keeps the array the `.fig` model and Figma's plugin API use.
|
|
8
|
+
*/
|
|
9
|
+
function primaryAction(reaction) {
|
|
10
|
+
return reaction.actions[0] ?? null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The frame play starts from: the selected frame, or the frame holding the selection; otherwise
|
|
14
|
+
* the page's first frame. Null when the page has no frames, so there is nothing to play.
|
|
15
|
+
*/
|
|
16
|
+
function startFrame(graph, pageId, selectedIds) {
|
|
17
|
+
const frames = framesOnPage(graph, pageId);
|
|
18
|
+
const ids = new Set(frames.map((frame) => frame.id));
|
|
19
|
+
for (const id of selectedIds) {
|
|
20
|
+
if (ids.has(id)) return id;
|
|
21
|
+
const frame = topFrameOf(graph, graph.getNode(id));
|
|
22
|
+
if (frame && ids.has(frame.id)) return frame.id;
|
|
23
|
+
}
|
|
24
|
+
return frames[0]?.id ?? null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The top-level frame a node sits in: the page's direct child above it, when that child is a
|
|
28
|
+
* frame. Play fits and hit-tests top-level frames, as Figma's presentation does.
|
|
29
|
+
*/
|
|
30
|
+
function topFrameOf(graph, node) {
|
|
31
|
+
let top = node ?? null;
|
|
32
|
+
while (top?.parentId) {
|
|
33
|
+
const parent = graph.getNode(top.parentId);
|
|
34
|
+
if (!parent || parent.type === "CANVAS") break;
|
|
35
|
+
top = parent;
|
|
36
|
+
}
|
|
37
|
+
return top?.type === "FRAME" ? top : null;
|
|
38
|
+
}
|
|
39
|
+
/** Starts playing the page from `frameId` with no history behind it. */
|
|
40
|
+
function startSession(frameId) {
|
|
41
|
+
return {
|
|
42
|
+
frameId,
|
|
43
|
+
startFrameId: frameId,
|
|
44
|
+
history: [],
|
|
45
|
+
overlays: []
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The frame the stage shows: the top overlay when one is open, else the base frame. */
|
|
49
|
+
function shownFrame(session) {
|
|
50
|
+
return session.overlays.at(-1) ?? session.frameId;
|
|
51
|
+
}
|
|
52
|
+
/** Plays again from where the session started, as Restart does. */
|
|
53
|
+
function restartSession(session) {
|
|
54
|
+
return startSession(session.startFrameId);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The reaction a click at a document point runs: the topmost layer under the point inside the
|
|
58
|
+
* shown frame that has a reaction to `trigger`, over its whole box, or that shows a paint there,
|
|
59
|
+
* and then its nearest ancestor with one, up to the frame, with the reaction's first action. An
|
|
60
|
+
* unpainted layer without one lets the click through. An instance runs the reactions of the variant it shows, and a frame
|
|
61
|
+
* play scrolled finds its layers where they are drawn.
|
|
62
|
+
*/
|
|
63
|
+
function reactionAt(graph, session, x, y, trigger = "ON_CLICK", scroll) {
|
|
64
|
+
const reacts = (layer) => effectiveReactions(graph, layer).some((reaction) => reaction.trigger.type === trigger);
|
|
65
|
+
let node = playHitTest(graph, shownFrame(session), x, y, scroll, reacts);
|
|
66
|
+
while (node) {
|
|
67
|
+
const reaction = effectiveReactions(graph, node).find((candidate) => candidate.trigger.type === trigger);
|
|
68
|
+
const action = reaction ? primaryAction(reaction) : null;
|
|
69
|
+
if (action) return {
|
|
70
|
+
sourceId: node.id,
|
|
71
|
+
action,
|
|
72
|
+
transition: action.type === "NODE" ? action.transition : null
|
|
73
|
+
};
|
|
74
|
+
if (node.id === shownFrame(session)) return null;
|
|
75
|
+
node = node.parentId ? graph.getNode(node.parentId) ?? null : null;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The session after an action runs. `NAVIGATE` moves to its frame and remembers this one for
|
|
81
|
+
* Back; `OVERLAY` opens a frame over the screen and `CLOSE` takes the top one away; `BACK`
|
|
82
|
+
* returns to the previous screen and drops overlays, which are not history entries; an action
|
|
83
|
+
* this version cannot show leaves the session as it is.
|
|
84
|
+
*/
|
|
85
|
+
function step(graph, session, action) {
|
|
86
|
+
if (action.type === "BACK") {
|
|
87
|
+
const previous = session.history.at(-1);
|
|
88
|
+
if (!previous) return session;
|
|
89
|
+
return {
|
|
90
|
+
...session,
|
|
91
|
+
frameId: previous,
|
|
92
|
+
history: session.history.slice(0, -1),
|
|
93
|
+
overlays: []
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (action.type === "CLOSE") {
|
|
97
|
+
if (session.overlays.length === 0) return session;
|
|
98
|
+
return {
|
|
99
|
+
...session,
|
|
100
|
+
overlays: session.overlays.slice(0, -1)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (!action.nodeId) return session;
|
|
104
|
+
if (topFrameOf(graph, graph.getNode(action.nodeId))?.id !== action.nodeId) return session;
|
|
105
|
+
if (action.navigation === "OVERLAY") {
|
|
106
|
+
if (action.nodeId === shownFrame(session)) return session;
|
|
107
|
+
return {
|
|
108
|
+
...session,
|
|
109
|
+
overlays: [...session.overlays, action.nodeId]
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (action.nodeId === session.frameId) return session;
|
|
113
|
+
return {
|
|
114
|
+
...session,
|
|
115
|
+
frameId: action.nodeId,
|
|
116
|
+
history: [...session.history, session.frameId],
|
|
117
|
+
overlays: []
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The `AFTER_TIMEOUT` reactions of the frame being shown, with their delays in milliseconds:
|
|
122
|
+
* what the stage schedules whenever the shown frame changes.
|
|
123
|
+
*/
|
|
124
|
+
function timeoutReactions(graph, session) {
|
|
125
|
+
const node = graph.getNode(shownFrame(session));
|
|
126
|
+
if (!node) return [];
|
|
127
|
+
return node.prototypeReactions.filter((reaction) => reaction.trigger.type === "AFTER_TIMEOUT").map((reaction) => ({
|
|
128
|
+
action: primaryAction(reaction),
|
|
129
|
+
delayMs: reaction.trigger.delay * 1e3
|
|
130
|
+
})).filter((entry) => entry.action !== null);
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { primaryAction, reactionAt, restartSession, shownFrame, startFrame, startSession, step, timeoutReactions, topFrameOf };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=session.js.map
|