@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,198 @@
|
|
|
1
|
+
import type { CanvasKit } from 'canvaskit-wasm'
|
|
2
|
+
import { isEqual } from 'es-toolkit'
|
|
3
|
+
|
|
4
|
+
import type { Fill, SceneGraph, SceneNode, Stroke } from '@pairdraw/scene-graph'
|
|
5
|
+
import { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'
|
|
6
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
7
|
+
import type { UndoManager } from '@pairdraw/scene-graph/undo'
|
|
8
|
+
|
|
9
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
10
|
+
import { getPageColor } from '#core/figma-api/page-backgrounds'
|
|
11
|
+
|
|
12
|
+
/** Which paint of the selection a sampled colour replaces. Alt samples into the stroke. */
|
|
13
|
+
export type EyedropperTarget = 'fill' | 'stroke'
|
|
14
|
+
|
|
15
|
+
type SampleRenderer = Pick<
|
|
16
|
+
SkiaRenderer,
|
|
17
|
+
'worldViewport' | 'viewportImageRendering' | 'presentationColorSpace' | 'renderNode'
|
|
18
|
+
>
|
|
19
|
+
|
|
20
|
+
/** A square of the document's pixels: RGBA rows, `size` pixels a side, the centre one sampled. */
|
|
21
|
+
export interface ScenePixels {
|
|
22
|
+
size: number
|
|
23
|
+
data: Uint8Array
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The document's pixels in a square of `size` (odd) pixels centred on a world point, each
|
|
28
|
+
* `1 / scale` world units wide, composited over the page background, so at the view's zoom they
|
|
29
|
+
* are the pixels the screen shows there.
|
|
30
|
+
*
|
|
31
|
+
* Renders only what intersects the square into a raster surface, so selection chrome, rulers and
|
|
32
|
+
* the screen's colour profile never leak into the result, unlike `window.EyeDropper`, which
|
|
33
|
+
* samples the screen. Components come back in the document's own colour space: the renderer
|
|
34
|
+
* presents in that space and the surface is not converted.
|
|
35
|
+
*/
|
|
36
|
+
export function sampleScenePixels(
|
|
37
|
+
ck: CanvasKit,
|
|
38
|
+
renderer: SampleRenderer,
|
|
39
|
+
graph: SceneGraph,
|
|
40
|
+
pageId: string,
|
|
41
|
+
x: number,
|
|
42
|
+
y: number,
|
|
43
|
+
size = 1,
|
|
44
|
+
scale = 1
|
|
45
|
+
): ScenePixels | null {
|
|
46
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null
|
|
47
|
+
if (!Number.isInteger(size) || size < 1 || size % 2 === 0 || !(scale > 0)) return null
|
|
48
|
+
const page = graph.getNode(pageId)
|
|
49
|
+
if (!page) return null
|
|
50
|
+
const surface = ck.MakeSurface(size, size)
|
|
51
|
+
if (!surface) return null
|
|
52
|
+
const previousViewport = renderer.worldViewport
|
|
53
|
+
const previousImageRendering = renderer.viewportImageRendering
|
|
54
|
+
const previousColorSpace = renderer.presentationColorSpace
|
|
55
|
+
try {
|
|
56
|
+
const canvas = surface.getCanvas()
|
|
57
|
+
const background = getPageColor(page)
|
|
58
|
+
canvas.clear(ck.Color4f(background.r, background.g, background.b, 1))
|
|
59
|
+
// Pixel (i, j) covers [i, i + 1); put the sampled point at the centre pixel's centre.
|
|
60
|
+
const half = (size - 1) / 2
|
|
61
|
+
canvas.translate(half + 0.5, half + 0.5)
|
|
62
|
+
canvas.scale(scale, scale)
|
|
63
|
+
canvas.translate(-x, -y)
|
|
64
|
+
const reach = (half + 1) / scale
|
|
65
|
+
renderer.worldViewport = { x: x - reach, y: y - reach, w: reach * 2, h: reach * 2 }
|
|
66
|
+
renderer.viewportImageRendering = false
|
|
67
|
+
renderer.presentationColorSpace = graph.documentColorSpace
|
|
68
|
+
for (const childId of page.childIds) renderer.renderNode(canvas, graph, childId, {})
|
|
69
|
+
surface.flush()
|
|
70
|
+
const data = canvas.readPixels(0, 0, {
|
|
71
|
+
width: size,
|
|
72
|
+
height: size,
|
|
73
|
+
alphaType: ck.AlphaType.Unpremul,
|
|
74
|
+
colorType: ck.ColorType.RGBA_8888,
|
|
75
|
+
colorSpace: ck.ColorSpace.SRGB
|
|
76
|
+
})
|
|
77
|
+
if (!(data instanceof Uint8Array) || data.length < size * size * 4) return null
|
|
78
|
+
return { size, data }
|
|
79
|
+
} finally {
|
|
80
|
+
renderer.worldViewport = previousViewport
|
|
81
|
+
renderer.viewportImageRendering = previousImageRendering
|
|
82
|
+
renderer.presentationColorSpace = previousColorSpace
|
|
83
|
+
surface.dispose()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The opaque colour of one pixel of a sample, by column and row. */
|
|
88
|
+
export function scenePixelColor(pixels: ScenePixels, column: number, row: number): Color {
|
|
89
|
+
const at = (row * pixels.size + column) * 4
|
|
90
|
+
const { data } = pixels
|
|
91
|
+
return { r: data[at] / 255, g: data[at + 1] / 255, b: data[at + 2] / 255, a: 1 }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The colour the document shows at a world point, one `1 / scale`-wide pixel of it. */
|
|
95
|
+
export function sampleSceneColor(
|
|
96
|
+
ck: CanvasKit,
|
|
97
|
+
renderer: SampleRenderer,
|
|
98
|
+
graph: SceneGraph,
|
|
99
|
+
pageId: string,
|
|
100
|
+
x: number,
|
|
101
|
+
y: number,
|
|
102
|
+
scale = 1
|
|
103
|
+
): Color | null {
|
|
104
|
+
const pixels = sampleScenePixels(ck, renderer, graph, pageId, x, y, 1, scale)
|
|
105
|
+
return pixels ? scenePixelColor(pixels, 0, 0) : null
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function solidPaint(color: Color): Fill {
|
|
109
|
+
return { type: 'SOLID', color: { ...color, a: 1 }, opacity: 1, visible: true }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Replaces the top solid paint's colour, keeping its opacity, or adds an opaque solid paint. A
|
|
114
|
+
* solid paint's alpha is its opacity, as the colour picker writes them, so the alpha stays too.
|
|
115
|
+
*/
|
|
116
|
+
function withSampledPaint<T extends Fill>(
|
|
117
|
+
paints: readonly T[],
|
|
118
|
+
color: Color,
|
|
119
|
+
create: (paint: Fill) => T
|
|
120
|
+
): { paints: T[]; index: number } {
|
|
121
|
+
const next = paints.map((paint) => ({ ...paint }))
|
|
122
|
+
for (let index = next.length - 1; index >= 0; index--) {
|
|
123
|
+
if (next[index].type !== 'SOLID') continue
|
|
124
|
+
next[index] = { ...next[index], color: { ...color, a: next[index].color.a } }
|
|
125
|
+
return { paints: next, index }
|
|
126
|
+
}
|
|
127
|
+
next.push(create(solidPaint(color)))
|
|
128
|
+
return { paints: next, index: next.length - 1 }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function eyedropperChanges(
|
|
132
|
+
node: SceneNode,
|
|
133
|
+
color: Color,
|
|
134
|
+
target: EyedropperTarget
|
|
135
|
+
): Partial<SceneNode> {
|
|
136
|
+
const boundVariables = { ...node.boundVariables }
|
|
137
|
+
if (target === 'stroke') {
|
|
138
|
+
// A first stroke takes the weight and alignment the node keeps for its strokes.
|
|
139
|
+
const { paints, index } = withSampledPaint<Stroke>(node.strokes, color, (paint) => ({
|
|
140
|
+
...paint,
|
|
141
|
+
...newStrokeGeometry(node)
|
|
142
|
+
}))
|
|
143
|
+
delete boundVariables[`strokes/${index}/color`]
|
|
144
|
+
return { strokes: paints, boundVariables }
|
|
145
|
+
}
|
|
146
|
+
const { paints, index } = withSampledPaint<Fill>(node.fills, color, (paint) => paint)
|
|
147
|
+
delete boundVariables[`fills/${index}/color`]
|
|
148
|
+
const changes: Partial<SceneNode> = { fills: paints, boundVariables }
|
|
149
|
+
// Text colour lives in the node fills; per-character fills would hide the sample.
|
|
150
|
+
if (node.type === 'TEXT' && node.styleRuns.some((run) => run.style.fills)) {
|
|
151
|
+
changes.styleRuns = node.styleRuns.map((run) => {
|
|
152
|
+
const style = { ...run.style }
|
|
153
|
+
delete style.fills
|
|
154
|
+
return { ...run, style }
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
return changes
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface EyedropperEditor {
|
|
161
|
+
graph: SceneGraph
|
|
162
|
+
undo: UndoManager
|
|
163
|
+
state: { selectedIds: ReadonlySet<string> }
|
|
164
|
+
updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Whether the changes would leave the layer as it is, as when it already has the colour. */
|
|
168
|
+
function changesNothing(node: SceneNode, changes: Partial<SceneNode>): boolean {
|
|
169
|
+
return Object.entries(changes).every(([key, value]) =>
|
|
170
|
+
isEqual(node[key as keyof SceneNode], value)
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Applies a sampled colour to every selected layer that can take a paint, as one undo step.
|
|
176
|
+
* Layers that already show it are left alone, so a sample that changes nothing records nothing.
|
|
177
|
+
* Returns how many layers changed.
|
|
178
|
+
*/
|
|
179
|
+
export function applySampledColor(
|
|
180
|
+
editor: EyedropperEditor,
|
|
181
|
+
color: Color,
|
|
182
|
+
target: EyedropperTarget = 'fill'
|
|
183
|
+
): number {
|
|
184
|
+
const nodes = [...editor.state.selectedIds]
|
|
185
|
+
.map((id) => editor.graph.getNode(id))
|
|
186
|
+
.filter((node): node is SceneNode => node !== undefined && !node.locked)
|
|
187
|
+
.filter((node) => node.type !== 'GROUP')
|
|
188
|
+
const edits = nodes
|
|
189
|
+
.map((node) => ({ node, changes: eyedropperChanges(node, color, target) }))
|
|
190
|
+
.filter(({ node, changes }) => !changesNothing(node, changes))
|
|
191
|
+
if (edits.length === 0) return 0
|
|
192
|
+
editor.undo.runBatch('Eyedropper', () => {
|
|
193
|
+
for (const { node, changes } of edits) {
|
|
194
|
+
editor.updateNodeWithUndo(node.id, changes, 'Eyedropper')
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
return edits.length
|
|
198
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceDocumentFonts,
|
|
3
|
+
type FontReplacement,
|
|
4
|
+
type FontReplacementCounts
|
|
5
|
+
} from '#core/text/replace-fonts'
|
|
6
|
+
|
|
7
|
+
import { recordEdit } from './history/edit'
|
|
8
|
+
import type { EditorContext } from './types'
|
|
9
|
+
|
|
10
|
+
export function createFontActions(ctx: EditorContext) {
|
|
11
|
+
/** Replaces font faces across the document as one undoable step. */
|
|
12
|
+
function replaceFonts(replacements: readonly FontReplacement[]): FontReplacementCounts {
|
|
13
|
+
return recordEdit(ctx, { label: 'Replace fonts' }, () =>
|
|
14
|
+
replaceDocumentFonts(ctx.graph, replacements)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return { replaceFonts }
|
|
19
|
+
}
|
|
@@ -46,7 +46,19 @@ export function executeAtomicTool(
|
|
|
46
46
|
figma: FigmaAPI,
|
|
47
47
|
def: ToolDef,
|
|
48
48
|
args: Record<string, unknown>,
|
|
49
|
-
options: {
|
|
49
|
+
options: {
|
|
50
|
+
signal?: AbortSignal
|
|
51
|
+
isLive?: () => boolean
|
|
52
|
+
label?: string
|
|
53
|
+
/**
|
|
54
|
+
* Judges the layer fields the call changed once it ran; an error it returns undoes the call
|
|
55
|
+
* and is thrown, as the document's design memory refuses an agent's off-system values.
|
|
56
|
+
*/
|
|
57
|
+
verify?: (
|
|
58
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
59
|
+
variables: readonly FieldChanges<Variable>[]
|
|
60
|
+
) => Error | null
|
|
61
|
+
} = {}
|
|
50
62
|
): unknown {
|
|
51
63
|
if (!isAtomicTool(def)) throw new Error(`Not an atomic tool: ${def.name}`)
|
|
52
64
|
if (!resolveEditorProfile(editor.state).edits) throw new ReadOnlyDocumentError()
|
|
@@ -112,6 +124,7 @@ export function executeAtomicTool(
|
|
|
112
124
|
)
|
|
113
125
|
// Layout may change other layers too.
|
|
114
126
|
const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount)
|
|
127
|
+
rejectRefused(options.verify, nodeChanges, variableChanges)
|
|
115
128
|
const contentChanged =
|
|
116
129
|
variableChanges.length > 0 ||
|
|
117
130
|
nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== 'source'))
|
|
@@ -134,6 +147,21 @@ export function executeAtomicTool(
|
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
|
|
150
|
+
/** Throws the error `verify` judges the changes with, which undoes the call. */
|
|
151
|
+
function rejectRefused(
|
|
152
|
+
verify:
|
|
153
|
+
| ((
|
|
154
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
155
|
+
variables: readonly FieldChanges<Variable>[]
|
|
156
|
+
) => Error | null)
|
|
157
|
+
| undefined,
|
|
158
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
159
|
+
variables: readonly FieldChanges<Variable>[]
|
|
160
|
+
): void {
|
|
161
|
+
const refusal = verify ? verify(nodes, variables) : null
|
|
162
|
+
if (refusal) throw refusal
|
|
163
|
+
}
|
|
164
|
+
|
|
137
165
|
function layout(
|
|
138
166
|
graph: SceneGraph,
|
|
139
167
|
editor: MutationEditor,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A copy that keeps the layer's values as they are now. Values are replaced, never written into
|
|
6
|
+
* (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits
|
|
7
|
+
* child lists, source metadata, and override maps in place, so those are copied. It costs a few
|
|
8
|
+
* object spreads where a deep clone of the layer costs its whole value tree, which is what lets
|
|
9
|
+
* undo record thousands of layers.
|
|
10
|
+
*/
|
|
11
|
+
export function captureNode(node: SceneNode): SceneNode {
|
|
12
|
+
const { source, instanceOverrides } = node
|
|
13
|
+
return {
|
|
14
|
+
...node,
|
|
15
|
+
childIds: [...node.childIds],
|
|
16
|
+
source: { ...source, fig: { ...source.fig, rawNodeFields: { ...source.fig.rawNodeFields } } },
|
|
17
|
+
instanceOverrides: cloneInstanceOverrideState(instanceOverrides)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
VariableCollection
|
|
10
10
|
} from '@pairdraw/scene-graph'
|
|
11
11
|
import { withLiveComments } from '@pairdraw/scene-graph/comments'
|
|
12
|
-
import { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'
|
|
13
12
|
import {
|
|
14
13
|
createSceneMutationImpact,
|
|
15
14
|
recordSceneMutations
|
|
@@ -18,6 +17,7 @@ import {
|
|
|
18
17
|
import type { EditorContext } from '#core/editor/types'
|
|
19
18
|
import { computeAllLayouts } from '#core/layout'
|
|
20
19
|
|
|
20
|
+
import { captureNode } from './capture'
|
|
21
21
|
import { diffFields, type FieldChanges } from './diff'
|
|
22
22
|
|
|
23
23
|
type Side = 'before' | 'after'
|
|
@@ -134,21 +134,6 @@ function restoreLayer(graph: SceneGraph, update: LayerUpdate, side: Side): void
|
|
|
134
134
|
graph.restoreNodeProperties(update.id, changes, update.fields?.absent[side] ?? [])
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
/**
|
|
138
|
-
* A copy that keeps the layer's values as they are now. Values are replaced, never written into
|
|
139
|
-
* (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits
|
|
140
|
-
* child lists, source metadata, and override maps in place, so those are copied.
|
|
141
|
-
*/
|
|
142
|
-
function captureNode(node: SceneNode): SceneNode {
|
|
143
|
-
const { source, instanceOverrides } = node
|
|
144
|
-
return {
|
|
145
|
-
...node,
|
|
146
|
-
childIds: [...node.childIds],
|
|
147
|
-
source: { ...source, fig: { ...source.fig, rawNodeFields: { ...source.fig.rawNodeFields } } },
|
|
148
|
-
instanceOverrides: cloneInstanceOverrideState(instanceOverrides)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
137
|
/** Copies a page's layers not copied yet; a layer moved in from another page keeps its copy. */
|
|
153
138
|
function capturePage(graph: SceneGraph, pageId: string, captured: Map<string, SceneNode>): void {
|
|
154
139
|
const stack = [pageId]
|
|
@@ -199,7 +184,10 @@ function recordLayer(
|
|
|
199
184
|
if (!previous) {
|
|
200
185
|
if (current) change.created.push(structuredClone(current))
|
|
201
186
|
} else if (!current) {
|
|
202
|
-
|
|
187
|
+
// `previous` is this edit's own copy, made before the layer changed (`captureNode`), and the
|
|
188
|
+
// layer it copies is gone; restoring it copies it again, so the record stays as it is.
|
|
189
|
+
// Copying it here too cost a deep clone per layer, which made deleting thousands slow.
|
|
190
|
+
change.deleted.push(previous)
|
|
203
191
|
} else {
|
|
204
192
|
const update = diffLayer(id, previous, current)
|
|
205
193
|
if (update) change.updated.push(update)
|
|
@@ -42,6 +42,13 @@ export interface RecordEditOptions {
|
|
|
42
42
|
* back after it threw changed nothing.
|
|
43
43
|
*/
|
|
44
44
|
onRecorded?: (change: DocumentChange) => void
|
|
45
|
+
/**
|
|
46
|
+
* Judges what the edit changed once it finished without throwing. An error it returns fails
|
|
47
|
+
* the edit: with `rollbackOnThrow` the edit is put back and the error thrown, as the design
|
|
48
|
+
* memory refuses an agent's off-system values. When the edit cannot be put back, its step is
|
|
49
|
+
* recorded and nothing is thrown, so the caller reports the error some other way.
|
|
50
|
+
*/
|
|
51
|
+
verify?: (change: DocumentChange) => Error | null
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
function unchanged(pageId: string): DocumentChange {
|
|
@@ -157,11 +164,13 @@ function begin(ctx: EditorContext, options: RecordEditOptions, awaits = false) {
|
|
|
157
164
|
if (awaits) keepOpenRecorder(ctx, recorder)
|
|
158
165
|
// A synchronous edit runs alone; one that awaits shares the document while it waits.
|
|
159
166
|
const othersWrote = awaits ? watchOtherWrites(ctx) : () => false
|
|
160
|
-
const finish = (
|
|
167
|
+
const finish = (threw: boolean) => {
|
|
161
168
|
if (awaits) releaseOpenRecorder(ctx, recorder)
|
|
162
169
|
const others = othersWrote()
|
|
163
170
|
const change = recorder.finish()
|
|
164
171
|
const empty = isEmptyDocumentChange(change)
|
|
172
|
+
const refusal = !threw && !empty && options.verify ? options.verify(change) : null
|
|
173
|
+
const failed = threw || refusal !== null
|
|
165
174
|
if (
|
|
166
175
|
failed &&
|
|
167
176
|
options.rollbackOnThrow &&
|
|
@@ -171,6 +180,7 @@ function begin(ctx: EditorContext, options: RecordEditOptions, awaits = false) {
|
|
|
171
180
|
rollBack(ctx, graph, change)
|
|
172
181
|
) {
|
|
173
182
|
options.onRecorded?.(unchanged(pageId))
|
|
183
|
+
if (refusal) throw refusal
|
|
174
184
|
return
|
|
175
185
|
}
|
|
176
186
|
// An edit that changed nothing, such as a read-only script, leaves no empty step behind.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
2
|
|
|
3
|
+
import { captureNode } from './capture'
|
|
4
|
+
|
|
3
5
|
export function collectSubtrees(graph: SceneGraph, rootIds: string[]): SceneNode[] {
|
|
4
6
|
const result: SceneNode[] = []
|
|
5
7
|
function walk(id: string) {
|
|
@@ -12,25 +14,34 @@ export function collectSubtrees(graph: SceneGraph, rootIds: string[]): SceneNode
|
|
|
12
14
|
return result
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Copies of a layer and its layers by id, for undo to put back. Each is a `captureNode` copy,
|
|
19
|
+
* not a deep clone, so deleting thousands of layers stays quick.
|
|
20
|
+
*/
|
|
15
21
|
export function snapshotSubtree(graph: SceneGraph, rootId: string): Map<string, SceneNode> {
|
|
16
22
|
const index = new Map<string, SceneNode>()
|
|
17
23
|
const walk = (id: string) => {
|
|
18
24
|
const node = graph.getNode(id)
|
|
19
25
|
if (!node) return
|
|
20
|
-
index.set(id,
|
|
26
|
+
index.set(id, captureNode(node))
|
|
21
27
|
for (const childId of node.childIds) walk(childId)
|
|
22
28
|
}
|
|
23
29
|
walk(rootId)
|
|
24
30
|
return index
|
|
25
31
|
}
|
|
26
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Puts a snapshot back under `parentId`, its layers in order. The layer it makes gets a copy of
|
|
35
|
+
* the snapshot's child list, source metadata and override maps, which the graph edits in place,
|
|
36
|
+
* so the snapshot stays as it is for the next undo or redo.
|
|
37
|
+
*/
|
|
27
38
|
export function restoreSubtree(
|
|
28
39
|
graph: SceneGraph,
|
|
29
40
|
snapshot: SceneNode,
|
|
30
41
|
parentId: string,
|
|
31
42
|
index: Map<string, SceneNode>
|
|
32
43
|
): void {
|
|
33
|
-
const { parentId: _parentId, childIds, ...rest } = snapshot
|
|
44
|
+
const { parentId: _parentId, childIds, ...rest } = captureNode(snapshot)
|
|
34
45
|
graph.createNode(snapshot.type, parentId, { ...rest, id: snapshot.id })
|
|
35
46
|
for (const childId of childIds) {
|
|
36
47
|
const child = index.get(childId)
|
package/src/editor/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ export {
|
|
|
28
28
|
selectionColorsShown,
|
|
29
29
|
type SelectionColor
|
|
30
30
|
} from './selection/colors'
|
|
31
|
+
export { DOCUMENT_COLOR_LIMIT, documentColors, type DocumentColor } from './document-colors'
|
|
31
32
|
export {
|
|
32
33
|
copyEditorViewState,
|
|
33
34
|
createDefaultEditorViewState,
|
|
@@ -37,7 +38,9 @@ export { createDefaultEditorState, createEditor } from './create'
|
|
|
37
38
|
export { syncEditedComponents } from './component-sync'
|
|
38
39
|
export { executeAtomicTool } from './history/atomic-tool'
|
|
39
40
|
export {
|
|
41
|
+
applyDocumentChange,
|
|
40
42
|
isEmptyDocumentChange,
|
|
43
|
+
recordDocumentChange,
|
|
41
44
|
touchedTopLevelIds,
|
|
42
45
|
type DocumentChange
|
|
43
46
|
} from './history/document-change'
|
|
@@ -89,6 +92,14 @@ export { opacityFromBuffer } from './nodes'
|
|
|
89
92
|
export { layerTypeOptions, type LayerType } from './structure/layer-type'
|
|
90
93
|
export type { NodePreview } from './node-preview'
|
|
91
94
|
export { BOARD_TOOL_SHORTCUTS, BOARD_TOOLS, EDITOR_TOOLS, TOOL_SHORTCUTS } from './tool-registry'
|
|
95
|
+
export {
|
|
96
|
+
applySampledColor,
|
|
97
|
+
eyedropperChanges,
|
|
98
|
+
sampleSceneColor,
|
|
99
|
+
sampleScenePixels,
|
|
100
|
+
scenePixelColor
|
|
101
|
+
} from './eyedropper'
|
|
102
|
+
export type { EyedropperTarget, ScenePixels } from './eyedropper'
|
|
92
103
|
export {
|
|
93
104
|
DEFAULT_SCALE_ANCHOR,
|
|
94
105
|
isScaleAnchor,
|
package/src/editor/pages.ts
CHANGED
|
@@ -67,26 +67,29 @@ interface PageDrawing {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* The other pages that
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* The component sets on other pages that instances on `pageId` show a variant of, nested
|
|
71
|
+
* instances included, and the sets those sets' variants use in turn. Reading a page brings in
|
|
72
|
+
* each such set whole, so its variants can be switched to; they get fonts and layout here
|
|
73
|
+
* rather than their pages, whose other layers the page does not use.
|
|
73
74
|
*/
|
|
74
|
-
export function
|
|
75
|
-
const
|
|
75
|
+
export function componentSetsUsed(graph: SceneGraph, pageId: string): string[] {
|
|
76
|
+
const sets = new Set<string>()
|
|
77
|
+
const pending = [pageId]
|
|
76
78
|
const visit = (id: string): void => {
|
|
77
79
|
for (const node of graph.getChildren(id)) {
|
|
78
80
|
if (node.type === 'INSTANCE') {
|
|
79
81
|
const component = instanceMainComponent(graph, node)
|
|
80
82
|
const set = component?.parentId ? graph.getNode(component.parentId) : undefined
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
if (set?.type === 'COMPONENT_SET' && graph.pageOf(set.id) !== pageId && !sets.has(set.id)) {
|
|
84
|
+
sets.add(set.id)
|
|
85
|
+
pending.push(set.id)
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
visit(node.id)
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
visit(
|
|
89
|
-
return [...
|
|
91
|
+
for (let id = pending.pop(); id !== undefined; id = pending.pop()) visit(id)
|
|
92
|
+
return [...sets]
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
@@ -141,12 +144,13 @@ export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
|
141
144
|
return false
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
/** Loads the fonts the layers under `rootIds` use, with fallbacks for their scripts. */
|
|
148
|
+
async function resolveFonts(
|
|
149
|
+
rootIds: readonly string[],
|
|
146
150
|
pageName: string,
|
|
147
151
|
options: PreparePageOptions
|
|
148
152
|
): Promise<void> {
|
|
149
|
-
const childIds = ctx.graph.getChildren(
|
|
153
|
+
const childIds = rootIds.flatMap((id) => ctx.graph.getChildren(id).map((node) => node.id))
|
|
150
154
|
const toLoad = fontManager.collectFontKeys(ctx.graph, childIds)
|
|
151
155
|
const requirements = collectGraphFontRequirements(ctx.graph, childIds)
|
|
152
156
|
options.onProgress?.({
|
|
@@ -217,23 +221,17 @@ export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
|
217
221
|
options.onProgress?.({ phase: 'populating-page', detail: page.name })
|
|
218
222
|
const populated = await populatePage(pageId, generation, options.signal)
|
|
219
223
|
if (populated === null || generation !== pageSwitchGeneration) return null
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
for (let setPageId = pending.shift(); setPageId !== undefined; setPageId = pending.shift()) {
|
|
226
|
-
if (seen.has(setPageId)) continue
|
|
227
|
-
seen.add(setPageId)
|
|
228
|
-
const ready = await preparePageNodes(setPageId)
|
|
229
|
-
throwIfAborted(options.signal)
|
|
230
|
-
if (!ready || generation !== pageSwitchGeneration) return null
|
|
231
|
-
pending.push(...componentSetPages(ctx.graph, setPageId))
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
await resolvePageFonts(pageId, page.name, options)
|
|
224
|
+
// Switching a variant, in the panel or in preview, needs the rest of its set laid out with
|
|
225
|
+
// its fonts. Reading the page brought each set it uses in whole; those on other pages are
|
|
226
|
+
// laid out here, without the rest of their pages.
|
|
227
|
+
const sets = componentSetsUsed(ctx.graph, pageId)
|
|
228
|
+
await resolveFonts([pageId, ...sets], page.name, options)
|
|
235
229
|
throwIfAborted(options.signal)
|
|
236
230
|
if (generation !== pageSwitchGeneration) return null
|
|
231
|
+
if (sets.length > 0)
|
|
232
|
+
ctx.graph.applyDerivedLayoutDuring(() => {
|
|
233
|
+
for (const setId of sets) computeAllLayouts(ctx.graph, setId)
|
|
234
|
+
})
|
|
237
235
|
// A page visited before keeps the layout it got then, unless something it depends on changed.
|
|
238
236
|
if ((ctx.getRenderer() || populated) && !pageLayouts.isCurrent(pageId)) {
|
|
239
237
|
options.onProgress?.({ phase: 'layout', detail: page.name })
|
|
@@ -248,6 +246,18 @@ export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
|
248
246
|
return generation === pageSwitchGeneration ? { pageId, generation } : null
|
|
249
247
|
}
|
|
250
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Lays out the page on screen again when what sized its text has changed since, as for a page
|
|
251
|
+
* shown before any canvas could measure text, which preparing it leaves to the canvas.
|
|
252
|
+
*/
|
|
253
|
+
function layOutStaleCurrentPage(): void {
|
|
254
|
+
const pageId = ctx.state.currentPageId
|
|
255
|
+
if (ctx.graph.getNode(pageId)?.type !== 'CANVAS' || pageLayouts.isCurrent(pageId)) return
|
|
256
|
+
ctx.graph.applyDerivedLayoutDuring(() => computeAllLayouts(ctx.graph, pageId))
|
|
257
|
+
pageLayouts.record(pageId)
|
|
258
|
+
ctx.requestRender()
|
|
259
|
+
}
|
|
260
|
+
|
|
251
261
|
function commitPageSwitch(prepared: PreparedPage): boolean {
|
|
252
262
|
if (prepared.generation !== pageSwitchGeneration) return false
|
|
253
263
|
const page = ctx.graph.getNode(prepared.pageId)
|
|
@@ -292,7 +302,7 @@ export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
|
292
302
|
async function prepareOffscreenPage(graph: SceneGraph, page: SceneNode): Promise<boolean> {
|
|
293
303
|
const populated = await populatePage(page.id, null)
|
|
294
304
|
if (populated === null || graph !== ctx.graph) return false
|
|
295
|
-
await
|
|
305
|
+
await resolveFonts([page.id], page.name, {})
|
|
296
306
|
if (graph !== ctx.graph) return false
|
|
297
307
|
graph.applyDerivedLayoutDuring(() => computeAllLayouts(graph, page.id))
|
|
298
308
|
return true
|
|
@@ -475,6 +485,7 @@ export function createPageActions(ctx: EditorContext, drawing?: PageDrawing) {
|
|
|
475
485
|
preparePage,
|
|
476
486
|
commitPageSwitch,
|
|
477
487
|
switchPage,
|
|
488
|
+
layOutStaleCurrentPage,
|
|
478
489
|
switchToNextPage: () => switchToAdjacentPage(1),
|
|
479
490
|
switchToPreviousPage: () => switchToAdjacentPage(-1),
|
|
480
491
|
addPage,
|
|
@@ -57,7 +57,7 @@ function variantFor(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** Let auto layout size a changed layer's ancestors again, not as a `.fig` file recorded them. */
|
|
60
|
-
function reflow(graph: SceneGraph, nodeId: string): void {
|
|
60
|
+
export function reflow(graph: SceneGraph, nodeId: string): void {
|
|
61
61
|
let current = graph.getNode(nodeId)
|
|
62
62
|
while (current) {
|
|
63
63
|
if (current.derivedLayout) graph.updateNode(current.id, { derivedLayout: null })
|
|
@@ -12,9 +12,11 @@ export const READ_ONLY_ACTIONS: ReadonlySet<string> = new Set([
|
|
|
12
12
|
'canArrangeNodes',
|
|
13
13
|
'canAutoArrangeNodes',
|
|
14
14
|
'canConvertToFrame',
|
|
15
|
+
'canCreateVariations',
|
|
15
16
|
'canDistributeNodes',
|
|
16
17
|
'canEditImage',
|
|
17
18
|
'collectVariantOptions',
|
|
19
|
+
'designMemory',
|
|
18
20
|
'componentInstanceCount',
|
|
19
21
|
'figCompression',
|
|
20
22
|
'findVariantByValues',
|
|
@@ -45,6 +47,8 @@ export const READ_ONLY_ACTIONS: ReadonlySet<string> = new Set([
|
|
|
45
47
|
'getVariableCount',
|
|
46
48
|
'getVariablesByType',
|
|
47
49
|
'getVariablesForCollection',
|
|
50
|
+
'getVariationSet',
|
|
51
|
+
'isVariationOriginalChanged',
|
|
48
52
|
'getVariantOptionAvailability',
|
|
49
53
|
'getVariantOptions',
|
|
50
54
|
'hitTestAtPoint',
|