@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,116 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import { variantInstanceFor } from '@pairdraw/scene-graph/components'
|
|
3
|
+
import { instanceMainComponent } from '@pairdraw/scene-graph/instances'
|
|
4
|
+
|
|
5
|
+
import type { RenderedPlayScene } from '#core/canvas/renderer/types'
|
|
6
|
+
import { reflow } from '#core/editor/play/states'
|
|
7
|
+
import { extractPageContext, findPageId } from '#core/io/subgraph'
|
|
8
|
+
import { computeAllLayouts, computeLayout } from '#core/layout'
|
|
9
|
+
|
|
10
|
+
import { withoutInheritedCopies } from './reactions'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* What the canvas draws in place of a top-level frame while play changed it: the frame's private
|
|
14
|
+
* copy, a count that grows with every change, and the layers the changes touched, whose cached
|
|
15
|
+
* drawings are stale. The renderer's own name for the same view.
|
|
16
|
+
*/
|
|
17
|
+
export type PlaySceneView = RenderedPlayScene
|
|
18
|
+
|
|
19
|
+
/** One Change to: the instance it switched, in the frame it sits in, and the two variants. */
|
|
20
|
+
export interface PlayChange {
|
|
21
|
+
rootId: string
|
|
22
|
+
instanceId: string
|
|
23
|
+
from: string
|
|
24
|
+
to: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PlayScene extends PlaySceneView {
|
|
28
|
+
/**
|
|
29
|
+
* Shows `variantId` on the instance a Change to from `sourceId` switches: the source or its
|
|
30
|
+
* nearest instance ancestor that shows a variant of that set. Null when there is none, or it
|
|
31
|
+
* already shows the variant.
|
|
32
|
+
*/
|
|
33
|
+
changeTo(sourceId: string, variantId: string): PlayChange | null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */
|
|
37
|
+
export function changeTarget(
|
|
38
|
+
graph: SceneGraph,
|
|
39
|
+
rootId: string,
|
|
40
|
+
sourceId: string,
|
|
41
|
+
variantId: string
|
|
42
|
+
): string | null {
|
|
43
|
+
const variant = graph.getNode(variantId)
|
|
44
|
+
if (variant?.type !== 'COMPONENT' || !variant.parentId) return null
|
|
45
|
+
const instance = variantInstanceFor(graph, sourceId, variant.parentId)
|
|
46
|
+
if (!instance || !graph.isDescendant(instance.id, rootId)) return null
|
|
47
|
+
return instanceMainComponent(graph, instance)?.id === variantId ? null : instance.id
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Lays out a switched instance, then each auto layout around it up to the frame, as an edit lays
|
|
52
|
+
* out the layer it changed and the auto layouts that hug it; the rest of the frame keeps its
|
|
53
|
+
* layout.
|
|
54
|
+
*/
|
|
55
|
+
function layOutAround(graph: SceneGraph, instanceId: string, rootId: string): void {
|
|
56
|
+
reflow(graph, instanceId)
|
|
57
|
+
computeAllLayouts(graph, instanceId)
|
|
58
|
+
let current = graph.getNode(instanceId)
|
|
59
|
+
while (current && current.id !== rootId && current.parentId) {
|
|
60
|
+
current = graph.getNode(current.parentId)
|
|
61
|
+
if (current && current.layoutMode !== 'NONE') computeLayout(graph, current.id)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A top-level frame as play shows it once an interaction changed it: a private copy of the frame,
|
|
67
|
+
* with every variant its instances can switch to, that the document, undo, autosave, and
|
|
68
|
+
* collaborators never see.
|
|
69
|
+
*/
|
|
70
|
+
export function createPlayScene(design: SceneGraph, rootId: string): PlayScene {
|
|
71
|
+
const pageId = findPageId(design, rootId) ?? design.rootId
|
|
72
|
+
const graph = extractPageContext(design, pageId, [rootId], {
|
|
73
|
+
componentSets: true,
|
|
74
|
+
shareTables: true
|
|
75
|
+
})
|
|
76
|
+
const touched = new Set<string>()
|
|
77
|
+
let revision = 0
|
|
78
|
+
|
|
79
|
+
function touch(id: string): void {
|
|
80
|
+
touched.add(id)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
graph,
|
|
85
|
+
touched,
|
|
86
|
+
get revision() {
|
|
87
|
+
return revision
|
|
88
|
+
},
|
|
89
|
+
changeTo(sourceId, variantId) {
|
|
90
|
+
const instanceId = changeTarget(graph, rootId, sourceId, variantId)
|
|
91
|
+
const instance = instanceId ? graph.getNode(instanceId) : undefined
|
|
92
|
+
const previous = instance && instanceMainComponent(graph, instance)
|
|
93
|
+
if (!instance || !previous) return null
|
|
94
|
+
const stop = graph.onNodeEvents({
|
|
95
|
+
created: (node) => touch(node.id),
|
|
96
|
+
updated: touch,
|
|
97
|
+
deleted: touch
|
|
98
|
+
})
|
|
99
|
+
try {
|
|
100
|
+
graph.swapInstanceComponent(instance.id, variantId, { keepName: true })
|
|
101
|
+
graph.updateNode(instance.id, {
|
|
102
|
+
prototypeReactions: withoutInheritedCopies(instance.prototypeReactions, previous)
|
|
103
|
+
})
|
|
104
|
+
layOutAround(graph, instance.id, rootId)
|
|
105
|
+
} finally {
|
|
106
|
+
stop()
|
|
107
|
+
}
|
|
108
|
+
graph.closest(instance.id, (node) => {
|
|
109
|
+
touch(node.id)
|
|
110
|
+
return node.id === rootId
|
|
111
|
+
})
|
|
112
|
+
revision += 1
|
|
113
|
+
return { rootId, instanceId: instance.id, from: previous.id, to: variantId }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PrototypeAction,
|
|
3
|
+
PrototypeReaction,
|
|
4
|
+
PrototypeTransition,
|
|
5
|
+
SceneGraph,
|
|
6
|
+
SceneNode
|
|
7
|
+
} from '@pairdraw/scene-graph'
|
|
8
|
+
import { instanceMainComponent } from '@pairdraw/scene-graph/instances'
|
|
9
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
10
|
+
|
|
11
|
+
import { extractPageContext, findPageId } from '#core/io/subgraph'
|
|
12
|
+
|
|
13
|
+
import type { PlayRevert } from './pointer'
|
|
14
|
+
import { componentLayerResolver, reactionsWithInherited } from './reactions'
|
|
15
|
+
import {
|
|
16
|
+
changeTarget,
|
|
17
|
+
createPlayScene,
|
|
18
|
+
type PlayChange,
|
|
19
|
+
type PlayScene,
|
|
20
|
+
type PlaySceneView
|
|
21
|
+
} from './scene'
|
|
22
|
+
import { clampScroll, scrollAlong, scrollIntoView, type ScrollChange } from './scroll'
|
|
23
|
+
import { primaryAction, shownFrame, step, type PlayClick, type PlaySession } from './session'
|
|
24
|
+
import {
|
|
25
|
+
createSmartAnimation,
|
|
26
|
+
type PlayFrame,
|
|
27
|
+
type SmartAnimation
|
|
28
|
+
} from './smart-animate/animation'
|
|
29
|
+
|
|
30
|
+
/** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */
|
|
31
|
+
export const PLAY_SCENE_LIMIT = 4
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An After delay reaction the layers a frame shows add: the layer it runs from, which is an
|
|
35
|
+
* instance or a copy inside one, the main component or layer it stands for, whose reaction it is,
|
|
36
|
+
* the reaction, its action, and the delay in milliseconds.
|
|
37
|
+
*/
|
|
38
|
+
export interface PlayTimeout {
|
|
39
|
+
sourceId: string
|
|
40
|
+
/** The main component an instance shows, or the main layer a copy stands for. */
|
|
41
|
+
variantId: string
|
|
42
|
+
reactionId: string
|
|
43
|
+
action: PrototypeAction
|
|
44
|
+
delayMs: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* What a reaction did: the session after it, and the Change to it made, if it made one. A Scroll
|
|
49
|
+
* to also says which frames it scrolled, for an animation to step between, and where the layer it
|
|
50
|
+
* scrolled to is drawn now, for a screen that scrolls by panning to bring into view.
|
|
51
|
+
*/
|
|
52
|
+
export interface PlayStep {
|
|
53
|
+
session: PlaySession
|
|
54
|
+
changed: PlayChange | null
|
|
55
|
+
scrolled?: ScrollChange[]
|
|
56
|
+
reveal?: Vector | null
|
|
57
|
+
/**
|
|
58
|
+
* A Smart animate Change to's animation from the frame as it was to its copy as it is now, for
|
|
59
|
+
* the player to run over the transition's duration; the copy shows the change at once.
|
|
60
|
+
*/
|
|
61
|
+
animation?: SmartAnimation
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The frames play changed, each kept as a private copy so the document never changes. Frames move
|
|
66
|
+
* through the session as before; a Change to switches an instance on its frame's copy, which is
|
|
67
|
+
* made at the first change, so a prototype without one copies nothing.
|
|
68
|
+
*/
|
|
69
|
+
export interface PlayScenes {
|
|
70
|
+
/** The graph play reads a top-level frame from: its copy once changed, else the document. */
|
|
71
|
+
graphFor(rootId: string): SceneGraph
|
|
72
|
+
/** The changed frames the canvas draws from their copies, by frame id. */
|
|
73
|
+
readonly views: ReadonlyMap<string, PlaySceneView>
|
|
74
|
+
/** How far play scrolled each frame that scrolls, by frame id. */
|
|
75
|
+
readonly scroll: ReadonlyMap<string, Vector>
|
|
76
|
+
/**
|
|
77
|
+
* Scrolls the frames along `path`, a pointer's path in `rootId`, innermost first, and returns
|
|
78
|
+
* what none of them could take, for the canvas to pan by.
|
|
79
|
+
*/
|
|
80
|
+
scrollBy(rootId: string, path: readonly string[], dx: number, dy: number): Vector
|
|
81
|
+
/** Sets one frame's offset, as an animated Scroll to steps it toward where it ends. */
|
|
82
|
+
setScroll(id: string, offset: Vector): void
|
|
83
|
+
/** Runs a reaction of a layer in `rootId`, the shown frame unless a timer names another. */
|
|
84
|
+
run(session: PlaySession, click: PlayClick, rootId?: string): PlayStep
|
|
85
|
+
/**
|
|
86
|
+
* Undoes a While hovering or While pressing reaction, unless play moved on from what it did: an
|
|
87
|
+
* instance that shows another variant by now, or an overlay or frame no longer shown.
|
|
88
|
+
*/
|
|
89
|
+
revert(session: PlaySession, revert: PlayRevert): PlayStep
|
|
90
|
+
/**
|
|
91
|
+
* The After delay reactions of the instances `rootId` shows and of the copies inside them, by
|
|
92
|
+
* the variants and main layers they stand for now.
|
|
93
|
+
*/
|
|
94
|
+
instanceTimeouts(rootId: string): PlayTimeout[]
|
|
95
|
+
/**
|
|
96
|
+
* Drops the copies of frames that hold any of these document layers, after an edit to them:
|
|
97
|
+
* the frame's own layers and the variants its copy holds.
|
|
98
|
+
*/
|
|
99
|
+
forget(nodeIds: Iterable<string>): void
|
|
100
|
+
clear(): void
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function createPlayScenes(
|
|
104
|
+
getDocument: () => SceneGraph,
|
|
105
|
+
limit = PLAY_SCENE_LIMIT
|
|
106
|
+
): PlayScenes {
|
|
107
|
+
// Insertion order is use order: a frame changed again moves to the end, and the first goes.
|
|
108
|
+
const scenes = new Map<string, PlayScene>()
|
|
109
|
+
const scroll = new Map<string, Vector>()
|
|
110
|
+
|
|
111
|
+
function graphFor(rootId: string): SceneGraph {
|
|
112
|
+
return scenes.get(rootId)?.graph ?? getDocument()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The frame as play shows it before a change: the document while play has not changed it, else
|
|
117
|
+
* a copy of play's copy, which the change is about to edit in place.
|
|
118
|
+
*/
|
|
119
|
+
function frameBefore(rootId: string): PlayFrame {
|
|
120
|
+
const scene = scenes.get(rootId)
|
|
121
|
+
if (!scene) return { graph: getDocument(), rootId }
|
|
122
|
+
const pageId = findPageId(scene.graph, rootId) ?? scene.graph.rootId
|
|
123
|
+
return {
|
|
124
|
+
graph: extractPageContext(scene.graph, pageId, [rootId], { shareTables: true }),
|
|
125
|
+
rootId
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Runs a Change to on `rootId`'s copy, and with a Smart animate transition the animation from the
|
|
131
|
+
* frame as it was.
|
|
132
|
+
*/
|
|
133
|
+
function changeWith(
|
|
134
|
+
rootId: string,
|
|
135
|
+
sourceId: string,
|
|
136
|
+
variantId: string,
|
|
137
|
+
transition: PrototypeTransition | null
|
|
138
|
+
): Pick<PlayStep, 'changed' | 'animation'> {
|
|
139
|
+
const smart = transition?.type === 'SMART_ANIMATE' && transition.duration > 0
|
|
140
|
+
const before = smart && changeTarget(graphFor(rootId), rootId, sourceId, variantId)
|
|
141
|
+
const from = before ? frameBefore(rootId) : null
|
|
142
|
+
const changed = changeIn(rootId, sourceId, variantId)
|
|
143
|
+
if (!changed || !from) return { changed }
|
|
144
|
+
const to = { graph: graphFor(rootId), rootId }
|
|
145
|
+
return { changed, animation: createSmartAnimation(from, to, transition?.easing) }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function changeIn(rootId: string, sourceId: string, variantId: string): PlayChange | null {
|
|
149
|
+
// Checked on what play shows now, so a Change to that cannot run copies nothing.
|
|
150
|
+
if (!changeTarget(graphFor(rootId), rootId, sourceId, variantId)) return null
|
|
151
|
+
const scene = scenes.get(rootId) ?? createPlayScene(getDocument(), rootId)
|
|
152
|
+
const change = scene.changeTo(sourceId, variantId)
|
|
153
|
+
scenes.delete(rootId)
|
|
154
|
+
scenes.set(rootId, scene)
|
|
155
|
+
for (const oldest of scenes.keys()) {
|
|
156
|
+
if (scenes.size <= limit) break
|
|
157
|
+
scenes.delete(oldest)
|
|
158
|
+
}
|
|
159
|
+
// What the switched instance holds may be shorter now than a frame scrolled past.
|
|
160
|
+
if (change) clampScroll(scene.graph, scroll)
|
|
161
|
+
return change
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
graphFor,
|
|
166
|
+
views: scenes,
|
|
167
|
+
scroll,
|
|
168
|
+
scrollBy(rootId, path, dx, dy) {
|
|
169
|
+
return scrollAlong(graphFor(rootId), scroll, path, dx, dy)
|
|
170
|
+
},
|
|
171
|
+
setScroll(id, offset) {
|
|
172
|
+
scroll.set(id, offset)
|
|
173
|
+
},
|
|
174
|
+
run(session, { sourceId, action }, rootId = shownFrame(session)) {
|
|
175
|
+
if (action.type === 'NODE' && action.navigation === 'CHANGE_TO') {
|
|
176
|
+
if (!action.nodeId) return { session, changed: null }
|
|
177
|
+
return { session, ...changeWith(rootId, sourceId, action.nodeId, action.transition) }
|
|
178
|
+
}
|
|
179
|
+
if (action.type === 'NODE' && action.navigation === 'SCROLL_TO') {
|
|
180
|
+
if (!action.nodeId) return { session, changed: null, scrolled: [], reveal: null }
|
|
181
|
+
const moved = scrollIntoView(graphFor(rootId), scroll, rootId, action.nodeId)
|
|
182
|
+
return { session, changed: null, ...moved }
|
|
183
|
+
}
|
|
184
|
+
return { session: step(getDocument(), session, action), changed: null }
|
|
185
|
+
},
|
|
186
|
+
revert(session, revert) {
|
|
187
|
+
if (revert.kind === 'change') {
|
|
188
|
+
const graph = graphFor(revert.rootId)
|
|
189
|
+
const instance = graph.getNode(revert.instanceId)
|
|
190
|
+
if (!instance || instanceMainComponent(graph, instance)?.id !== revert.to) {
|
|
191
|
+
return { session, changed: null }
|
|
192
|
+
}
|
|
193
|
+
const { rootId, instanceId, from, transition } = revert
|
|
194
|
+
return { session, ...changeWith(rootId, instanceId, from, transition) }
|
|
195
|
+
}
|
|
196
|
+
const shown =
|
|
197
|
+
revert.kind === 'overlay'
|
|
198
|
+
? session.overlays.at(-1) === revert.frameId
|
|
199
|
+
: session.frameId === revert.frameId
|
|
200
|
+
if (!shown) return { session, changed: null }
|
|
201
|
+
const action = { type: revert.kind === 'overlay' ? 'CLOSE' : 'BACK' } as const
|
|
202
|
+
return { session: step(getDocument(), session, action), changed: null }
|
|
203
|
+
},
|
|
204
|
+
instanceTimeouts(rootId) {
|
|
205
|
+
const graph = graphFor(rootId)
|
|
206
|
+
const timeouts: PlayTimeout[] = []
|
|
207
|
+
const sourceOf = componentLayerResolver(graph)
|
|
208
|
+
const collect = (node: SceneNode, variantId: string, inherited: PrototypeReaction[]) => {
|
|
209
|
+
for (const reaction of reactionsWithInherited(node, inherited)) {
|
|
210
|
+
const action = reaction.trigger.type === 'AFTER_TIMEOUT' && primaryAction(reaction)
|
|
211
|
+
if (!action) continue
|
|
212
|
+
timeouts.push({
|
|
213
|
+
sourceId: node.id,
|
|
214
|
+
variantId,
|
|
215
|
+
reactionId: reaction.id,
|
|
216
|
+
action,
|
|
217
|
+
delayMs: reaction.trigger.delay * 1000
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const visit = (id: string) => {
|
|
222
|
+
for (const child of graph.getChildren(id)) {
|
|
223
|
+
if (child.type === 'INSTANCE') {
|
|
224
|
+
const main = instanceMainComponent(graph, child)
|
|
225
|
+
if (main) collect(child, main.id, main.prototypeReactions)
|
|
226
|
+
} else {
|
|
227
|
+
// A plain copy inherits its main layer's After delay; the resolver reads each
|
|
228
|
+
// instance's copy map once, so arming costs one search per instance, not per copy.
|
|
229
|
+
const source = sourceOf(child)
|
|
230
|
+
if (source && source.id !== child.id)
|
|
231
|
+
collect(child, source.id, source.prototypeReactions)
|
|
232
|
+
}
|
|
233
|
+
visit(child.id)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
visit(rootId)
|
|
237
|
+
return timeouts
|
|
238
|
+
},
|
|
239
|
+
forget(nodeIds) {
|
|
240
|
+
const design = getDocument()
|
|
241
|
+
for (const id of nodeIds) {
|
|
242
|
+
for (const [rootId, scene] of scenes) {
|
|
243
|
+
// The copy holds the frame and every variant its instances switch to, wherever they
|
|
244
|
+
// are, under the page and document it copied, which an edit elsewhere touches too.
|
|
245
|
+
const copied = scene.graph.getNode(id)
|
|
246
|
+
const held = copied !== undefined && copied.type !== 'CANVAS' && id !== scene.graph.rootId
|
|
247
|
+
if (design.isDescendant(id, rootId) || held) scenes.delete(rootId)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
clear() {
|
|
252
|
+
scenes.clear()
|
|
253
|
+
scroll.clear()
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { clamp } from 'es-toolkit'
|
|
2
|
+
|
|
3
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
4
|
+
import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'
|
|
5
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
6
|
+
|
|
7
|
+
const NO_SCROLL: Vector = { x: 0, y: 0 }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Whether play scrolls a frame's content inside it: a frame, component, or instance with overflow
|
|
11
|
+
* scrolling that clips, as Figma needs for a frame inside another. A rotated one does not scroll.
|
|
12
|
+
*/
|
|
13
|
+
export function scrollsInPlay(node: SceneNode): boolean {
|
|
14
|
+
return (
|
|
15
|
+
(node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE') &&
|
|
16
|
+
node.overflowDirection !== 'NONE' &&
|
|
17
|
+
node.clipsContent &&
|
|
18
|
+
node.rotation === 0
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* How far play may scroll a frame's content, along the axes it scrolls: how far its visible
|
|
24
|
+
* layers reach past its edge, with an auto layout's trailing padding, as Figma scrolls to it.
|
|
25
|
+
*/
|
|
26
|
+
export function scrollRange(graph: SceneGraph, nodeId: string): Vector {
|
|
27
|
+
const node = graph.getNode(nodeId)
|
|
28
|
+
if (!node || !scrollsInPlay(node)) return NO_SCROLL
|
|
29
|
+
const frame = getAxisAlignedWorldBounds(node, graph)
|
|
30
|
+
let right = 0
|
|
31
|
+
let bottom = 0
|
|
32
|
+
for (const child of graph.getChildren(nodeId)) {
|
|
33
|
+
if (!child.visible) continue
|
|
34
|
+
const bounds = getAxisAlignedWorldBounds(child, graph)
|
|
35
|
+
right = Math.max(right, bounds.x + bounds.width - frame.x)
|
|
36
|
+
bottom = Math.max(bottom, bounds.y + bounds.height - frame.y)
|
|
37
|
+
}
|
|
38
|
+
const flows = node.layoutMode !== 'NONE'
|
|
39
|
+
const horizontal = node.overflowDirection === 'HORIZONTAL' || node.overflowDirection === 'BOTH'
|
|
40
|
+
const vertical = node.overflowDirection === 'VERTICAL' || node.overflowDirection === 'BOTH'
|
|
41
|
+
return {
|
|
42
|
+
x: horizontal ? Math.max(0, right + (flows ? node.paddingRight : 0) - frame.width) : 0,
|
|
43
|
+
y: vertical ? Math.max(0, bottom + (flows ? node.paddingBottom : 0) - frame.height) : 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Scrolls the frames along `path`, innermost first, by as much as each can move, and passes the
|
|
49
|
+
* rest outward, as a browser chains a scroll. Returns what none of them could take.
|
|
50
|
+
*/
|
|
51
|
+
export function scrollAlong(
|
|
52
|
+
graph: SceneGraph,
|
|
53
|
+
scroll: Map<string, Vector>,
|
|
54
|
+
path: readonly string[],
|
|
55
|
+
dx: number,
|
|
56
|
+
dy: number
|
|
57
|
+
): Vector {
|
|
58
|
+
let restX = dx
|
|
59
|
+
let restY = dy
|
|
60
|
+
for (const id of [...path].reverse()) {
|
|
61
|
+
if (restX === 0 && restY === 0) break
|
|
62
|
+
const range = scrollRange(graph, id)
|
|
63
|
+
if (range.x === 0 && range.y === 0) continue
|
|
64
|
+
const current = scroll.get(id) ?? NO_SCROLL
|
|
65
|
+
const next = {
|
|
66
|
+
x: clamp(current.x + restX, 0, range.x),
|
|
67
|
+
y: clamp(current.y + restY, 0, range.y)
|
|
68
|
+
}
|
|
69
|
+
restX -= next.x - current.x
|
|
70
|
+
restY -= next.y - current.y
|
|
71
|
+
scroll.set(id, next)
|
|
72
|
+
}
|
|
73
|
+
return { x: restX, y: restY }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Keeps every offset within its frame's range, after a change resized what the frame holds. */
|
|
77
|
+
export function clampScroll(graph: SceneGraph, scroll: Map<string, Vector>): void {
|
|
78
|
+
for (const [id, offset] of scroll) {
|
|
79
|
+
if (!graph.getNode(id)) continue
|
|
80
|
+
const range = scrollRange(graph, id)
|
|
81
|
+
scroll.set(id, { x: Math.min(offset.x, range.x), y: Math.min(offset.y, range.y) })
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** One frame a Scroll to moved, from and to its offsets, for an animation to step between. */
|
|
86
|
+
export interface ScrollChange {
|
|
87
|
+
id: string
|
|
88
|
+
from: Vector
|
|
89
|
+
to: Vector
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Scrolls every frame around `targetId` inside `rootId`, innermost first, so the layer meets each
|
|
94
|
+
* one's top left as far as it can scroll, as Figma's Scroll to does. Returns the frames it moved,
|
|
95
|
+
* and where the layer is now drawn, for a screen that scrolls by panning to bring into view.
|
|
96
|
+
*/
|
|
97
|
+
export function scrollIntoView(
|
|
98
|
+
graph: SceneGraph,
|
|
99
|
+
scroll: Map<string, Vector>,
|
|
100
|
+
rootId: string,
|
|
101
|
+
targetId: string
|
|
102
|
+
): { scrolled: ScrollChange[]; reveal: Vector | null } {
|
|
103
|
+
const target = graph.getNode(targetId)
|
|
104
|
+
if (!target || target.id === rootId || !graph.isDescendant(targetId, rootId)) {
|
|
105
|
+
return { scrolled: [], reveal: null }
|
|
106
|
+
}
|
|
107
|
+
const place = getAxisAlignedWorldBounds(target, graph)
|
|
108
|
+
const scrolled: ScrollChange[] = []
|
|
109
|
+
let shiftX = 0
|
|
110
|
+
let shiftY = 0
|
|
111
|
+
graph.closest(target.parentId ?? rootId, (frame) => {
|
|
112
|
+
const range = scrollRange(graph, frame.id)
|
|
113
|
+
if (range.x > 0 || range.y > 0) {
|
|
114
|
+
const box = getAxisAlignedWorldBounds(frame, graph)
|
|
115
|
+
const from = scroll.get(frame.id) ?? NO_SCROLL
|
|
116
|
+
const to = {
|
|
117
|
+
x: clamp(place.x - shiftX - box.x, 0, range.x),
|
|
118
|
+
y: clamp(place.y - shiftY - box.y, 0, range.y)
|
|
119
|
+
}
|
|
120
|
+
scroll.set(frame.id, to)
|
|
121
|
+
scrolled.push({ id: frame.id, from, to })
|
|
122
|
+
shiftX += to.x
|
|
123
|
+
shiftY += to.y
|
|
124
|
+
}
|
|
125
|
+
return frame.id === rootId
|
|
126
|
+
})
|
|
127
|
+
return { scrolled, reveal: { x: place.x - shiftX, y: place.y - shiftY } }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* How far a layer is counter-shifted when it opts out of its frame's scroll: all of the offset
|
|
132
|
+
* for a fixed layer, and only the part past its own start for a sticky one, so it scrolls until
|
|
133
|
+
* it reaches the frame's top or left edge and then stays there.
|
|
134
|
+
*/
|
|
135
|
+
function scrollShift(
|
|
136
|
+
node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,
|
|
137
|
+
scroll: Vector | undefined,
|
|
138
|
+
axis: 'x' | 'y'
|
|
139
|
+
): number {
|
|
140
|
+
if (!scroll || node.scrollBehavior === 'SCROLLS') return 0
|
|
141
|
+
if (node.scrollBehavior === 'FIXED') return scroll[axis]
|
|
142
|
+
return Math.max(0, scroll[axis] - node[axis])
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function scrollShiftX(
|
|
146
|
+
node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,
|
|
147
|
+
scroll: Vector | undefined
|
|
148
|
+
): number {
|
|
149
|
+
return scrollShift(node, scroll, 'x')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function scrollShiftY(
|
|
153
|
+
node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>,
|
|
154
|
+
scroll: Vector | undefined
|
|
155
|
+
): number {
|
|
156
|
+
return scrollShift(node, scroll, 'y')
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The children of a frame play scrolled, in the order they draw: the layers that scroll with the
|
|
161
|
+
* content first, then the fixed and sticky ones above them, as Figma lifts fixed children over the
|
|
162
|
+
* scrolling content. Each group keeps its layer order. A mask and the layers it masks are never
|
|
163
|
+
* lifted, so a mask run stays together; without an offset, or with nothing to lift, the order is
|
|
164
|
+
* the one given.
|
|
165
|
+
*/
|
|
166
|
+
export function liftedChildIds(
|
|
167
|
+
graph: SceneGraph,
|
|
168
|
+
childIds: readonly string[],
|
|
169
|
+
scroll: Vector | undefined
|
|
170
|
+
): readonly string[] {
|
|
171
|
+
if (!scroll) return childIds
|
|
172
|
+
const nodes = childIds.map((id) => graph.getNode(id))
|
|
173
|
+
const lifts = nodes.map(
|
|
174
|
+
(node) => node !== undefined && !node.isMask && node.scrollBehavior !== 'SCROLLS'
|
|
175
|
+
)
|
|
176
|
+
if (!lifts.some(Boolean)) return childIds
|
|
177
|
+
// A mask belongs to the layers after it until the next mask; a lifted layer inside a mask run
|
|
178
|
+
// stays in the run so the mask still clips it.
|
|
179
|
+
let masked = false
|
|
180
|
+
const lift = nodes.map((node, index) => {
|
|
181
|
+
if (node?.isMask) masked = true
|
|
182
|
+
return lifts[index] && !masked
|
|
183
|
+
})
|
|
184
|
+
const scrolling: string[] = []
|
|
185
|
+
const staying: string[] = []
|
|
186
|
+
for (let index = 0; index < childIds.length; index++) {
|
|
187
|
+
;(lift[index] ? staying : scrolling).push(childIds[index])
|
|
188
|
+
}
|
|
189
|
+
return [...scrolling, ...staying]
|
|
190
|
+
}
|