@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
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { issuePath } from "./effects.js";
|
|
2
|
+
import { asInstanceEdit, sameReaction } from "../prototype/reactions.js";
|
|
3
|
+
import { PROTOTYPE_EASINGS } from "@pairdraw/scene-graph/constants";
|
|
2
4
|
import { generateId } from "@pairdraw/scene-graph";
|
|
3
5
|
import * as v from "valibot";
|
|
6
|
+
import { variantSetsAround } from "@pairdraw/scene-graph/components";
|
|
4
7
|
//#region src/figma-api/reactions.ts
|
|
5
8
|
/**
|
|
6
9
|
* Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the
|
|
7
|
-
* message it gets instead.
|
|
10
|
+
* message it gets instead.
|
|
8
11
|
*/
|
|
9
12
|
const UNSUPPORTED_TRIGGERS = {
|
|
10
13
|
ON_DRAG: true,
|
|
11
|
-
ON_HOVER: true,
|
|
12
|
-
ON_PRESS: true,
|
|
13
|
-
MOUSE_ENTER: true,
|
|
14
|
-
MOUSE_LEAVE: true,
|
|
15
14
|
MOUSE_UP: true,
|
|
16
15
|
MOUSE_DOWN: true,
|
|
17
16
|
ON_KEY_DOWN: true
|
|
@@ -33,14 +32,26 @@ const overlayPositionSchema = v.picklist([
|
|
|
33
32
|
"BOTTOM_CENTER",
|
|
34
33
|
"BOTTOM_RIGHT"
|
|
35
34
|
]);
|
|
35
|
+
/** Figma's easing presets, which play has; a spring or a custom curve is refused. */
|
|
36
|
+
const easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) });
|
|
36
37
|
const transitionSchema = v.strictObject({
|
|
37
|
-
type: v.picklist([
|
|
38
|
-
|
|
38
|
+
type: v.picklist([
|
|
39
|
+
"INSTANT",
|
|
40
|
+
"DISSOLVE",
|
|
41
|
+
"SMART_ANIMATE"
|
|
42
|
+
]),
|
|
43
|
+
duration: secondsSchema,
|
|
44
|
+
easing: v.optional(easingSchema)
|
|
39
45
|
});
|
|
40
46
|
const nodeActionSchema = v.strictObject({
|
|
41
47
|
type: v.literal("NODE"),
|
|
42
|
-
destinationId: v.pipe(v.string(), v.minLength(1), v.description("
|
|
43
|
-
navigation: v.picklist([
|
|
48
|
+
destinationId: v.pipe(v.string(), v.minLength(1), v.description("NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's top-level frame.")),
|
|
49
|
+
navigation: v.picklist([
|
|
50
|
+
"NAVIGATE",
|
|
51
|
+
"OVERLAY",
|
|
52
|
+
"CHANGE_TO",
|
|
53
|
+
"SCROLL_TO"
|
|
54
|
+
]),
|
|
44
55
|
transition: v.optional(transitionSchema, {
|
|
45
56
|
type: "INSTANT",
|
|
46
57
|
duration: 0
|
|
@@ -52,10 +63,22 @@ const actionSchema = v.variant("type", [
|
|
|
52
63
|
v.strictObject({ type: v.literal("BACK") }),
|
|
53
64
|
v.strictObject({ type: v.literal("CLOSE") })
|
|
54
65
|
]);
|
|
55
|
-
const triggerSchema = v.variant("type", [
|
|
56
|
-
type: v.
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
const triggerSchema = v.variant("type", [
|
|
67
|
+
v.strictObject({ type: v.picklist([
|
|
68
|
+
"ON_CLICK",
|
|
69
|
+
"ON_HOVER",
|
|
70
|
+
"ON_PRESS"
|
|
71
|
+
]) }),
|
|
72
|
+
v.strictObject({
|
|
73
|
+
type: v.literal("AFTER_TIMEOUT"),
|
|
74
|
+
timeout: secondsSchema
|
|
75
|
+
}),
|
|
76
|
+
v.strictObject({
|
|
77
|
+
type: v.picklist(["MOUSE_ENTER", "MOUSE_LEAVE"]),
|
|
78
|
+
delay: v.optional(secondsSchema, 0),
|
|
79
|
+
deprecatedVersion: v.optional(v.boolean())
|
|
80
|
+
})
|
|
81
|
+
]);
|
|
59
82
|
const reactionSchema = v.strictObject({
|
|
60
83
|
trigger: triggerSchema,
|
|
61
84
|
actions: v.pipe(v.array(actionSchema), v.minLength(1))
|
|
@@ -66,26 +89,51 @@ const figmaReactionsSchema = reactionsSchema;
|
|
|
66
89
|
/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */
|
|
67
90
|
function toFigmaReaction(reaction) {
|
|
68
91
|
return {
|
|
69
|
-
trigger: reaction.trigger
|
|
70
|
-
type: "AFTER_TIMEOUT",
|
|
71
|
-
timeout: reaction.trigger.delay
|
|
72
|
-
} : { type: "ON_CLICK" },
|
|
92
|
+
trigger: toFigmaTrigger(reaction.trigger),
|
|
73
93
|
actions: reaction.actions.map(toFigmaAction)
|
|
74
94
|
};
|
|
75
95
|
}
|
|
96
|
+
function toFigmaTrigger({ type, delay }) {
|
|
97
|
+
if (type === "AFTER_TIMEOUT") return {
|
|
98
|
+
type,
|
|
99
|
+
timeout: delay
|
|
100
|
+
};
|
|
101
|
+
if (type === "MOUSE_ENTER" || type === "MOUSE_LEAVE") return {
|
|
102
|
+
type,
|
|
103
|
+
delay
|
|
104
|
+
};
|
|
105
|
+
return { type };
|
|
106
|
+
}
|
|
76
107
|
function toFigmaAction(action) {
|
|
77
108
|
if (action.type !== "NODE") return { type: action.type };
|
|
78
109
|
return {
|
|
79
110
|
type: "NODE",
|
|
80
111
|
destinationId: action.nodeId ?? "",
|
|
81
112
|
navigation: action.navigation,
|
|
82
|
-
transition:
|
|
83
|
-
type: action.transition.type,
|
|
84
|
-
duration: action.transition.duration
|
|
85
|
-
},
|
|
113
|
+
transition: toFigmaTransition(action.transition),
|
|
86
114
|
overlayRelativePosition: action.overlayPosition
|
|
87
115
|
};
|
|
88
116
|
}
|
|
117
|
+
function toFigmaTransition({ type, duration, easing }) {
|
|
118
|
+
return easing ? {
|
|
119
|
+
type,
|
|
120
|
+
duration,
|
|
121
|
+
easing: { type: easing }
|
|
122
|
+
} : {
|
|
123
|
+
type,
|
|
124
|
+
duration
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function fromFigmaTransition({ type, duration, easing }) {
|
|
128
|
+
return easing ? {
|
|
129
|
+
type,
|
|
130
|
+
duration,
|
|
131
|
+
easing: easing.type
|
|
132
|
+
} : {
|
|
133
|
+
type,
|
|
134
|
+
duration
|
|
135
|
+
};
|
|
136
|
+
}
|
|
89
137
|
/**
|
|
90
138
|
* `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.
|
|
91
139
|
* Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,
|
|
@@ -101,36 +149,70 @@ function parseFigmaReactions(value, context) {
|
|
|
101
149
|
throw new Error(`Property "reactions" failed validation: ${issue.message} at ${issuePath(issue.path) || "reactions"}`);
|
|
102
150
|
}
|
|
103
151
|
return result.output.map((reaction, index) => {
|
|
104
|
-
|
|
152
|
+
const parsed = {
|
|
105
153
|
id: context.previous?.[index]?.id ?? generateId(),
|
|
106
154
|
trigger: toTrigger(reaction.trigger),
|
|
107
155
|
actions: reaction.actions.map((action) => toAction(action, context, index))
|
|
108
156
|
};
|
|
157
|
+
const held = context.previous?.[index];
|
|
158
|
+
if (held && sameReaction(held, parsed)) return parsed;
|
|
159
|
+
return asInstanceEdit(parsed, context.inherited ?? []);
|
|
109
160
|
});
|
|
110
161
|
}
|
|
111
162
|
function toTrigger(trigger) {
|
|
163
|
+
const type = trigger.type;
|
|
164
|
+
if (trigger.type === "AFTER_TIMEOUT") return {
|
|
165
|
+
type,
|
|
166
|
+
delay: trigger.timeout
|
|
167
|
+
};
|
|
112
168
|
return {
|
|
113
|
-
type
|
|
114
|
-
delay:
|
|
169
|
+
type,
|
|
170
|
+
delay: "delay" in trigger ? trigger.delay : 0
|
|
115
171
|
};
|
|
116
172
|
}
|
|
117
173
|
function toAction(action, context, reactionIndex) {
|
|
118
174
|
if (action.type !== "NODE") return { type: action.type };
|
|
119
|
-
assertDestination(action
|
|
175
|
+
assertDestination(action, context, reactionIndex);
|
|
120
176
|
return {
|
|
121
177
|
type: "NODE",
|
|
122
178
|
nodeId: action.destinationId,
|
|
123
179
|
navigation: action.navigation,
|
|
124
|
-
transition: action.transition,
|
|
180
|
+
transition: fromFigmaTransition(action.transition),
|
|
125
181
|
overlayPosition: action.navigation === "OVERLAY" ? action.overlayRelativePosition : "CENTER"
|
|
126
182
|
};
|
|
127
183
|
}
|
|
128
|
-
|
|
129
|
-
|
|
184
|
+
function failure(message) {
|
|
185
|
+
return /* @__PURE__ */ new Error(`Property "reactions" failed validation: ${message}`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A destination play can show: a navigation's is a frame at the top of the layer's page, a Change
|
|
189
|
+
* to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's
|
|
190
|
+
* top-level frame.
|
|
191
|
+
*/
|
|
192
|
+
function assertDestination(action, context, index) {
|
|
193
|
+
const { destinationId, navigation } = action;
|
|
130
194
|
const destination = context.graph.getNode(destinationId);
|
|
131
195
|
const at = `reactions[${index}]`;
|
|
132
|
-
if (!destination) throw
|
|
133
|
-
if (
|
|
196
|
+
if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`);
|
|
197
|
+
if (navigation === "CHANGE_TO") return assertVariant(destination, context, at);
|
|
198
|
+
if (navigation === "SCROLL_TO") return assertScrollTarget(destination, context, at);
|
|
199
|
+
if (destination.type !== "FRAME" || destination.parentId !== context.pageId) throw failure(`${at} must navigate to a top-level frame on the same page, not ${destination.type} "${destination.name}"`);
|
|
200
|
+
}
|
|
201
|
+
function assertVariant(destination, context, at) {
|
|
202
|
+
const sets = variantSetsAround(context.graph, context.nodeId);
|
|
203
|
+
const nearest = sets.at(0);
|
|
204
|
+
if (!nearest) throw failure(`${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`);
|
|
205
|
+
const inSet = sets.some((set) => set.id === destination.parentId);
|
|
206
|
+
if (destination.type !== "COMPONENT" || !inSet) throw failure(`${at} must Change to a variant of ${nearest.name}, not ${destination.type} "${destination.name}"`);
|
|
207
|
+
}
|
|
208
|
+
/** The page's direct child a layer sits in, which play shows as one screen. */
|
|
209
|
+
function topLevelOf(graph, nodeId, pageId) {
|
|
210
|
+
return graph.closest(nodeId, (node) => node.parentId === pageId);
|
|
211
|
+
}
|
|
212
|
+
function assertScrollTarget(destination, context, at) {
|
|
213
|
+
const { graph, nodeId, pageId } = context;
|
|
214
|
+
const top = topLevelOf(graph, nodeId, pageId);
|
|
215
|
+
if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) throw failure(`${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} "${destination.name}"`);
|
|
134
216
|
}
|
|
135
217
|
/** Figma's first unsupported trigger or action kind in `value`, if it has one. */
|
|
136
218
|
function unsupportedKind(value) {
|
|
@@ -140,7 +222,7 @@ function unsupportedKind(value) {
|
|
|
140
222
|
const trigger = reaction.trigger;
|
|
141
223
|
if (trigger && typeof trigger === "object" && "type" in trigger) {
|
|
142
224
|
const type = trigger.type;
|
|
143
|
-
if (typeof type === "string" && type in UNSUPPORTED_TRIGGERS) return `a prototype starts from ON_CLICK or AFTER_TIMEOUT, not ${type}`;
|
|
225
|
+
if (typeof type === "string" && type in UNSUPPORTED_TRIGGERS) return `a prototype starts from ON_CLICK, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE or AFTER_TIMEOUT, not ${type}`;
|
|
144
226
|
}
|
|
145
227
|
const actions = reaction.actions;
|
|
146
228
|
if (!Array.isArray(actions)) continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.js","names":[],"sources":["../../src/figma-api/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { generateId } from '@pairdraw/scene-graph'\nimport type {\n PrototypeAction,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph\n} from '@pairdraw/scene-graph'\n\nimport { issuePath } from '#core/figma-api/effects'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead. Only a click and a timeout play.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: true,\n ON_HOVER: true,\n ON_PRESS: true,\n MOUSE_ENTER: true,\n MOUSE_LEAVE: true,\n MOUSE_UP: true,\n MOUSE_DOWN: true,\n ON_KEY_DOWN: true\n}\n\n/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */\nconst UNSUPPORTED_ACTIONS: Record<string, true> = {\n URL: true,\n SET_VARIABLE: true,\n CONDITIONAL: true,\n SET_VARIABLE_MODE: true\n}\n\n// No `v.finite()` action: the MCP tool contract turns this schema into JSON Schema, which\n// has no notion of infinities, and JSON numbers are always finite anyway.\nconst secondsSchema = v.pipe(v.number(), v.minValue(0))\n\nconst overlayPositionSchema = v.picklist([\n 'CENTER',\n 'TOP_LEFT',\n 'TOP_CENTER',\n 'TOP_RIGHT',\n 'BOTTOM_LEFT',\n 'BOTTOM_CENTER',\n 'BOTTOM_RIGHT'\n] satisfies PrototypeOverlayPositionType[])\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema\n})\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.pipe(v.string(), v.minLength(1), v.description('Top-level frame on the page.')),\n navigation: v.picklist(['NAVIGATE', 'OVERLAY'] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.literal('ON_CLICK') }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema })\n])\n\nconst reactionSchema = v.strictObject({\n trigger: triggerSchema,\n actions: v.pipe(v.array(actionSchema), v.minLength(1))\n})\n\nconst reactionsSchema = v.array(reactionSchema)\n\n/** The plugin shape as a contract, for a tool that takes connections as arguments. */\nexport const figmaReactionsSchema = reactionsSchema\n\n/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */\nexport type FigmaReaction = v.InferOutput<typeof reactionSchema>\nexport type FigmaReactionTrigger = FigmaReaction['trigger']\nexport type FigmaReactionAction = FigmaReaction['actions'][number]\n\n/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */\nexport function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction {\n const trigger: FigmaReactionTrigger =\n reaction.trigger.type === 'AFTER_TIMEOUT'\n ? { type: 'AFTER_TIMEOUT', timeout: reaction.trigger.delay }\n : { type: 'ON_CLICK' }\n return { trigger, actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: { type: action.transition.type, duration: action.transition.duration },\n overlayRelativePosition: action.overlayPosition\n }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The page the layer is on; a destination must be a top-level frame on it. */\n pageId: string\n /** The reactions the layer has now, whose ids this keeps by position. */\n previous?: readonly PrototypeReaction[]\n}\n\n/**\n * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.\n * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,\n * an action, transition, navigation or overlay spot outside the model, and a destination that\n * is not a top-level frame on the layer's page are refused rather than kept unplayable.\n */\nexport function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[] {\n const unsupported = unsupportedKind(value)\n if (unsupported) throw new Error(`Property \"reactions\" failed validation: ${unsupported}`)\n const result = v.safeParse(reactionsSchema, value)\n if (!result.success) {\n const [issue] = result.issues\n throw new Error(\n `Property \"reactions\" failed validation: ${issue.message} at ${issuePath(issue.path) || 'reactions'}`\n )\n }\n return result.output.map((reaction, index) => {\n const id = context.previous?.[index]?.id ?? generateId()\n return {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n return { type, delay: trigger.type === 'AFTER_TIMEOUT' ? trigger.timeout : 0 }\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type !== 'NODE') return { type: action.type }\n assertDestination(action.destinationId, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: action.destinationId,\n navigation: action.navigation,\n transition: action.transition,\n // Only an overlay uses the spot; Figma keeps CENTER on a navigation.\n overlayPosition: action.navigation === 'OVERLAY' ? action.overlayRelativePosition : 'CENTER'\n }\n}\n\n/** A destination must be a frame at the top of the layer's page, as the play can only show one. */\nfunction assertDestination(destinationId: string, context: ReactionContext, index: number): void {\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) {\n throw new Error(\n `Property \"reactions\" failed validation: no layer ${destinationId} at ${at}.actions[0].destinationId`\n )\n }\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw new Error(\n `Property \"reactions\" failed validation: ${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** Figma's first unsupported trigger or action kind in `value`, if it has one. */\nfunction unsupportedKind(value: unknown): string | null {\n if (!Array.isArray(value)) return null\n const reactions = value.filter(\n (reaction): reaction is Record<string, unknown> =>\n Boolean(reaction) && typeof reaction === 'object'\n )\n for (const reaction of reactions) {\n const trigger = reaction.trigger\n if (trigger && typeof trigger === 'object' && 'type' in trigger) {\n const type = trigger.type\n if (typeof type === 'string' && type in UNSUPPORTED_TRIGGERS) {\n return `a prototype starts from ON_CLICK or AFTER_TIMEOUT, not ${type}`\n }\n }\n const actions = reaction.actions\n if (!Array.isArray(actions)) continue\n for (const action of actions) {\n if (action && typeof action === 'object' && 'type' in action) {\n const type = action.type\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n }\n }\n }\n return null\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../src/figma-api/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { generateId } from '@pairdraw/scene-graph'\nimport type {\n PrototypeAction,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransition,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { variantSetsAround } from '@pairdraw/scene-graph/components'\nimport { PROTOTYPE_EASINGS } from '@pairdraw/scene-graph/constants'\n\nimport { issuePath } from '#core/figma-api/effects'\nimport { asInstanceEdit, sameReaction } from '#core/prototype/reactions'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: true,\n MOUSE_UP: true,\n MOUSE_DOWN: true,\n ON_KEY_DOWN: true\n}\n\n/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */\nconst UNSUPPORTED_ACTIONS: Record<string, true> = {\n URL: true,\n SET_VARIABLE: true,\n CONDITIONAL: true,\n SET_VARIABLE_MODE: true\n}\n\n// No `v.finite()` action: the MCP tool contract turns this schema into JSON Schema, which\n// has no notion of infinities, and JSON numbers are always finite anyway.\nconst secondsSchema = v.pipe(v.number(), v.minValue(0))\n\nconst overlayPositionSchema = v.picklist([\n 'CENTER',\n 'TOP_LEFT',\n 'TOP_CENTER',\n 'TOP_RIGHT',\n 'BOTTOM_LEFT',\n 'BOTTOM_CENTER',\n 'BOTTOM_RIGHT'\n] satisfies PrototypeOverlayPositionType[])\n\n/** Figma's easing presets, which play has; a spring or a custom curve is refused. */\nconst easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) })\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE', 'SMART_ANIMATE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema,\n easing: v.optional(easingSchema)\n})\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.pipe(\n v.string(),\n v.minLength(1),\n v.description(\n 'NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the ' +\n \"layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's \" +\n 'top-level frame.'\n )\n ),\n navigation: v.picklist([\n 'NAVIGATE',\n 'OVERLAY',\n 'CHANGE_TO',\n 'SCROLL_TO'\n ] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.picklist(['ON_CLICK', 'ON_HOVER', 'ON_PRESS']) }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema }),\n v.strictObject({\n type: v.picklist(['MOUSE_ENTER', 'MOUSE_LEAVE']),\n delay: v.optional(secondsSchema, 0),\n // Figma's plugin API reads it; play treats both versions alike.\n deprecatedVersion: v.optional(v.boolean())\n })\n])\n\nconst reactionSchema = v.strictObject({\n trigger: triggerSchema,\n actions: v.pipe(v.array(actionSchema), v.minLength(1))\n})\n\nconst reactionsSchema = v.array(reactionSchema)\n\n/** The plugin shape as a contract, for a tool that takes connections as arguments. */\nexport const figmaReactionsSchema = reactionsSchema\n\n/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */\nexport type FigmaReaction = v.InferOutput<typeof reactionSchema>\nexport type FigmaReactionTrigger = FigmaReaction['trigger']\nexport type FigmaReactionAction = FigmaReaction['actions'][number]\n\n/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */\nexport function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction {\n return { trigger: toFigmaTrigger(reaction.trigger), actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaTrigger({ type, delay }: PrototypeReaction['trigger']): FigmaReactionTrigger {\n if (type === 'AFTER_TIMEOUT') return { type, timeout: delay }\n if (type === 'MOUSE_ENTER' || type === 'MOUSE_LEAVE') return { type, delay }\n return { type }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: toFigmaTransition(action.transition),\n overlayRelativePosition: action.overlayPosition\n }\n}\n\nfunction toFigmaTransition({\n type,\n duration,\n easing\n}: PrototypeTransition): v.InferOutput<typeof transitionSchema> {\n return easing ? { type, duration, easing: { type: easing } } : { type, duration }\n}\n\nfunction fromFigmaTransition({\n type,\n duration,\n easing\n}: v.InferOutput<typeof transitionSchema>): PrototypeTransition {\n return easing ? { type, duration, easing: easing.type } : { type, duration }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The layer the reactions are on, which a Change to or Scroll to destination must suit. */\n nodeId: string\n /** The page the layer is on; a navigation's destination must be a top-level frame on it. */\n pageId: string\n /** The reactions the layer has now, whose ids this keeps by position. */\n previous?: readonly PrototypeReaction[]\n /**\n * An instance's main component's reactions: a reaction kept under one of their ids that an\n * edit changed, from what the layer held at its place and from the main's, becomes the\n * instance's own, with an id of its own.\n */\n inherited?: readonly PrototypeReaction[]\n}\n\n/**\n * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.\n * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,\n * an action, transition, navigation or overlay spot outside the model, and a destination that\n * is not a top-level frame on the layer's page are refused rather than kept unplayable.\n */\nexport function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[] {\n const unsupported = unsupportedKind(value)\n if (unsupported) throw new Error(`Property \"reactions\" failed validation: ${unsupported}`)\n const result = v.safeParse(reactionsSchema, value)\n if (!result.success) {\n const [issue] = result.issues\n throw new Error(\n `Property \"reactions\" failed validation: ${issue.message} at ${issuePath(issue.path) || 'reactions'}`\n )\n }\n return result.output.map((reaction, index) => {\n const id = context.previous?.[index]?.id ?? generateId()\n const parsed: PrototypeReaction = {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n // One the layer already held unchanged stays as it was, a copy of the main's included, so\n // writing reactions back as read never re-ids a copy whose main was edited since.\n const held = context.previous?.[index]\n if (held && sameReaction(held, parsed)) return parsed\n return asInstanceEdit(parsed, context.inherited ?? [])\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n if (trigger.type === 'AFTER_TIMEOUT') return { type, delay: trigger.timeout }\n return { type, delay: 'delay' in trigger ? trigger.delay : 0 }\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type !== 'NODE') return { type: action.type }\n assertDestination(action, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: action.destinationId,\n navigation: action.navigation,\n transition: fromFigmaTransition(action.transition),\n // Only an overlay uses the spot; Figma keeps CENTER on a navigation.\n overlayPosition: action.navigation === 'OVERLAY' ? action.overlayRelativePosition : 'CENTER'\n }\n}\n\nfunction failure(message: string): Error {\n return new Error(`Property \"reactions\" failed validation: ${message}`)\n}\n\n/**\n * A destination play can show: a navigation's is a frame at the top of the layer's page, a Change\n * to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's\n * top-level frame.\n */\nfunction assertDestination(\n action: v.InferOutput<typeof nodeActionSchema>,\n context: ReactionContext,\n index: number\n): void {\n const { destinationId, navigation } = action\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`)\n if (navigation === 'CHANGE_TO') return assertVariant(destination, context, at)\n if (navigation === 'SCROLL_TO') return assertScrollTarget(destination, context, at)\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw failure(\n `${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction assertVariant(destination: SceneNode, context: ReactionContext, at: string): void {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const inSet = sets.some((set) => set.id === destination.parentId)\n if (destination.type !== 'COMPONENT' || !inSet) {\n throw failure(\n `${at} must Change to a variant of ${nearest.name}, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** The page's direct child a layer sits in, which play shows as one screen. */\nfunction topLevelOf(graph: SceneGraph, nodeId: string, pageId: string): SceneNode | undefined {\n return graph.closest(nodeId, (node) => node.parentId === pageId)\n}\n\nfunction assertScrollTarget(destination: SceneNode, context: ReactionContext, at: string): void {\n const { graph, nodeId, pageId } = context\n const top = topLevelOf(graph, nodeId, pageId)\n if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) {\n throw failure(\n `${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** Figma's first unsupported trigger or action kind in `value`, if it has one. */\nfunction unsupportedKind(value: unknown): string | null {\n if (!Array.isArray(value)) return null\n const reactions = value.filter(\n (reaction): reaction is Record<string, unknown> =>\n Boolean(reaction) && typeof reaction === 'object'\n )\n for (const reaction of reactions) {\n const trigger = reaction.trigger\n if (trigger && typeof trigger === 'object' && 'type' in trigger) {\n const type = trigger.type\n if (typeof type === 'string' && type in UNSUPPORTED_TRIGGERS) {\n return `a prototype starts from ON_CLICK, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE or AFTER_TIMEOUT, not ${type}`\n }\n }\n const actions = reaction.actions\n if (!Array.isArray(actions)) continue\n for (const action of actions) {\n if (action && typeof action === 'object' && 'type' in action) {\n const type = action.type\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n }\n }\n }\n return null\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getWorldMatrix } from "@pairdraw/scene-graph/coordinate";
|
|
2
2
|
import { geometryBlobBounds, intersectVisualBounds, strokeOverflow, unionVisualBounds } from "@pairdraw/scene-graph/geometry";
|
|
3
|
-
import { textLinesReach } from "@pairdraw/scene-graph/text";
|
|
4
3
|
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
4
|
+
import { textLinesReach } from "@pairdraw/scene-graph/text";
|
|
5
5
|
//#region src/figma-api/render-bounds.ts
|
|
6
6
|
const INTRINSIC_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
7
7
|
"FRAME",
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
* A feature Figma has no API for goes on `pairdraw`, never on these lists; entries only leave.
|
|
6
6
|
*/
|
|
7
7
|
/** Members a host or tool wires up on `figma`, which scripts do not write against. */
|
|
8
|
-
declare const FIGMA_API_HOST_MEMBERS: readonly ["graph", "wrapNode", "currentPageId", "groupFitOptions", "setRenderer", "theme", "exportImage", "icons", "rasterCodec", "changeBaseline"];
|
|
8
|
+
declare const FIGMA_API_HOST_MEMBERS: readonly ["graph", "wrapNode", "currentPageId", "groupFitOptions", "setRenderer", "theme", "exportImage", "exportGraphImage", "icons", "rasterCodec", "changeBaseline"];
|
|
9
9
|
/**
|
|
10
10
|
* Members named as in Figma whose types do not match Figma's yet, mostly because node proxies do
|
|
11
11
|
* not implement every Figma node type; remove one when it matches.
|
|
12
12
|
*/
|
|
13
13
|
declare const FIGMA_API_INCOMPLETE_MEMBERS: readonly ["createComponentFromNode", "createPage", "currentPage", "getNodeById", "getNodeByIdAsync", "mixed", "root", "ui", "variables", "viewport"];
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Members hosts read or write beyond Figma's Plugin API: the `JSON.stringify` hook, and node
|
|
16
|
+
* fields stored in `.fig` that the installed typings do not name.
|
|
17
|
+
*/
|
|
18
|
+
declare const SERIALIZATION_MEMBERS: readonly ["toJSON", "scrollBehavior"];
|
|
16
19
|
//#endregion
|
|
17
20
|
export { FIGMA_API_HOST_MEMBERS, FIGMA_API_INCOMPLETE_MEMBERS, SERIALIZATION_MEMBERS };
|
|
18
21
|
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","names":[],"sources":["../../src/figma-api/surface.ts"],"mappings":";;;;;;;cAOa;;;;;cAiBA
|
|
1
|
+
{"version":3,"file":"surface.d.ts","names":[],"sources":["../../src/figma-api/surface.ts"],"mappings":";;;;;;;cAOa;;;;;cAkBA;;;;;cAiBA"}
|
|
@@ -13,6 +13,7 @@ const FIGMA_API_HOST_MEMBERS = [
|
|
|
13
13
|
"setRenderer",
|
|
14
14
|
"theme",
|
|
15
15
|
"exportImage",
|
|
16
|
+
"exportGraphImage",
|
|
16
17
|
"icons",
|
|
17
18
|
"rasterCodec",
|
|
18
19
|
"changeBaseline"
|
|
@@ -33,8 +34,11 @@ const FIGMA_API_INCOMPLETE_MEMBERS = [
|
|
|
33
34
|
"variables",
|
|
34
35
|
"viewport"
|
|
35
36
|
];
|
|
36
|
-
/**
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Members hosts read or write beyond Figma's Plugin API: the `JSON.stringify` hook, and node
|
|
39
|
+
* fields stored in `.fig` that the installed typings do not name.
|
|
40
|
+
*/
|
|
41
|
+
const SERIALIZATION_MEMBERS = ["toJSON", "scrollBehavior"];
|
|
38
42
|
//#endregion
|
|
39
43
|
export { FIGMA_API_HOST_MEMBERS, FIGMA_API_INCOMPLETE_MEMBERS, SERIALIZATION_MEMBERS };
|
|
40
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.js","names":[],"sources":["../../src/figma-api/surface.ts"],"sourcesContent":["/**\n * What `figma` and its objects have beyond Figma's Plugin API. `compatibility.ts` checks the\n * types against these lists and `tests/figma-api/surface.test.ts` checks what scripts can reach.\n * A feature Figma has no API for goes on `pairdraw`, never on these lists; entries only leave.\n */\n\n/** Members a host or tool wires up on `figma`, which scripts do not write against. */\nexport const FIGMA_API_HOST_MEMBERS = [\n 'graph',\n 'wrapNode',\n 'currentPageId',\n 'groupFitOptions',\n 'setRenderer',\n 'theme',\n 'exportImage',\n 'icons',\n 'rasterCodec',\n 'changeBaseline'\n] as const\n\n/**\n * Members named as in Figma whose types do not match Figma's yet, mostly because node proxies do\n * not implement every Figma node type; remove one when it matches.\n */\nexport const FIGMA_API_INCOMPLETE_MEMBERS = [\n 'createComponentFromNode',\n 'createPage',\n 'currentPage',\n 'getNodeById',\n 'getNodeByIdAsync',\n 'mixed',\n 'root',\n 'ui',\n 'variables',\n 'viewport'\n] as const\n\n
|
|
1
|
+
{"version":3,"file":"surface.js","names":[],"sources":["../../src/figma-api/surface.ts"],"sourcesContent":["/**\n * What `figma` and its objects have beyond Figma's Plugin API. `compatibility.ts` checks the\n * types against these lists and `tests/figma-api/surface.test.ts` checks what scripts can reach.\n * A feature Figma has no API for goes on `pairdraw`, never on these lists; entries only leave.\n */\n\n/** Members a host or tool wires up on `figma`, which scripts do not write against. */\nexport const FIGMA_API_HOST_MEMBERS = [\n 'graph',\n 'wrapNode',\n 'currentPageId',\n 'groupFitOptions',\n 'setRenderer',\n 'theme',\n 'exportImage',\n 'exportGraphImage',\n 'icons',\n 'rasterCodec',\n 'changeBaseline'\n] as const\n\n/**\n * Members named as in Figma whose types do not match Figma's yet, mostly because node proxies do\n * not implement every Figma node type; remove one when it matches.\n */\nexport const FIGMA_API_INCOMPLETE_MEMBERS = [\n 'createComponentFromNode',\n 'createPage',\n 'currentPage',\n 'getNodeById',\n 'getNodeByIdAsync',\n 'mixed',\n 'root',\n 'ui',\n 'variables',\n 'viewport'\n] as const\n\n/**\n * Members hosts read or write beyond Figma's Plugin API: the `JSON.stringify` hook, and node\n * fields stored in `.fig` that the installed typings do not name.\n */\nexport const SERIALIZATION_MEMBERS = ['toJSON', 'scrollBehavior'] as const\n"],"mappings":";;;;;;;AAOA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAa,wBAAwB,CAAC,UAAU,gBAAgB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
1
|
import { Mat3 } from "@pairdraw/scene-graph/matrix";
|
|
2
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/figma-api/transform.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* A node's transform into its container's space, which Figma's plugin API reports as
|
package/dist/geometry/figma.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
1
|
import { Mat3 } from "@pairdraw/scene-graph/matrix";
|
|
2
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
3
3
|
import { Vector } from "@pairdraw/scene-graph/primitives";
|
|
4
4
|
//#region src/geometry/figma.d.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HandlePosition } from "./transform-zones.js";
|
|
2
|
-
import { GradientTransform } from "@pairdraw/scene-graph";
|
|
3
2
|
import { Mat3 } from "@pairdraw/scene-graph/matrix";
|
|
3
|
+
import { GradientTransform } from "@pairdraw/scene-graph";
|
|
4
4
|
import { Rect, Vector } from "@pairdraw/scene-graph/primitives";
|
|
5
5
|
//#region src/geometry/image-crop.d.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computeBounds } from "@pairdraw/scene-graph/geometry";
|
|
2
|
-
import { clamp } from "es-toolkit";
|
|
3
2
|
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
3
|
+
import { clamp } from "es-toolkit";
|
|
4
4
|
//#region src/geometry/image-crop.ts
|
|
5
5
|
/** Screen-pixel sizes of the crop handles. */
|
|
6
6
|
const IMAGE_CROP_HANDLE = {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents,
|
|
|
6
6
|
import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
7
7
|
import { ClipboardSnapshot } from "./editor/clipboard/snapshot.js";
|
|
8
8
|
import { ClipboardPayload, CopyOptions } from "./editor/clipboard/copy.js";
|
|
9
|
+
import { DocumentChange, applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
9
10
|
import { SelectionSpacing } from "./editor/alignment.js";
|
|
10
11
|
import { NodeEditCapability, ReadOnlyLibraryDefinitionError, assertNodeEditable, getNodeEditCapability } from "./editor/capabilities.js";
|
|
11
12
|
import { ReadOnlyDocumentError } from "./editor/read-only/index.js";
|
|
@@ -13,11 +14,11 @@ import { createDocumentGraph } from "./editor/document-settings.js";
|
|
|
13
14
|
import { createDefaultEditorSharedState } from "./editor/state/shared.js";
|
|
14
15
|
import { editedGradient, editedGradientLayout } from "./editor/gradient-edit.js";
|
|
15
16
|
import { EditedImage, ImageEditModifiers, editableImageFillIndex, editedImage, editedImageLayout, imageEditChanges, imageEditCrops } from "./editor/image-edit.js";
|
|
16
|
-
import { DocumentChange, isEmptyDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
17
|
import { RecordEditOptions } from "./editor/history/edit.js";
|
|
18
18
|
import { PageSnapshot } from "./editor/history/snapshot/page.js";
|
|
19
19
|
import { MovePlace } from "./editor/undo.js";
|
|
20
20
|
import { SelectionColor, replaceSelectionColor, selectionColors, selectionColorsShown } from "./editor/selection/colors.js";
|
|
21
|
+
import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./editor/document-colors.js";
|
|
21
22
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
22
23
|
import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./editor/components/variants/model.js";
|
|
23
24
|
import { VariableTokenFields } from "./editor/variables.js";
|
|
@@ -49,7 +50,8 @@ import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
|
|
|
49
50
|
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
50
51
|
import { LayerType, layerTypeOptions } from "./editor/structure/layer-type.js";
|
|
51
52
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./editor/tool-registry.js";
|
|
53
|
+
import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
52
54
|
import { newLayerDefaults } from "./editor/shapes/defaults.js";
|
|
53
55
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./editor/structure/rename.js";
|
|
54
56
|
import "./editor/index.js";
|
|
55
|
-
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, type DocumentChange, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
57
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,9 @@ import { DEFAULT_SNAPPING_PREFERENCES } from "./editor/preferences.js";
|
|
|
12
12
|
import { createDocumentGraph } from "./editor/document-settings.js";
|
|
13
13
|
import { createDefaultEditorSharedState } from "./editor/state/shared.js";
|
|
14
14
|
import { replaceSelectionColor, selectionColors, selectionColorsShown } from "./editor/selection/colors.js";
|
|
15
|
+
import { DOCUMENT_COLOR_LIMIT, documentColors } from "./editor/document-colors.js";
|
|
15
16
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
16
|
-
import { isEmptyDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
|
+
import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
18
|
import { resolvePasteTarget } from "./editor/clipboard/paste/target.js";
|
|
18
19
|
import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
19
20
|
import { reapplyInstanceComponentProperties } from "./editor/components/properties.js";
|
|
@@ -32,4 +33,5 @@ import { createEditor } from "./editor/create.js";
|
|
|
32
33
|
import { executeAtomicTool } from "./editor/history/atomic-tool.js";
|
|
33
34
|
import { graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange } from "./editor/history/snapshot/graph.js";
|
|
34
35
|
import { resolvePlayState } from "./editor/play/states.js";
|
|
35
|
-
|
|
36
|
+
import { applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
37
|
+
export { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, EDITOR_TOOLS, EDIT_VIEW, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, SCALE_ANCHORS, TOOL_SHORTCUTS, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../../canvas/index.js";
|
|
2
|
+
import { SkiaRenderer } from "../../canvas/renderer.js";
|
|
3
|
+
import { CanvasKit } from "canvaskit-wasm";
|
|
4
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
5
|
+
//#region src/io/formats/boolean-path.d.ts
|
|
6
|
+
/** Writes a boolean operation's live result path as SVG path data, or null when it has none. */
|
|
7
|
+
type BooleanPathResolver = (graph: SceneGraph, node: SceneNode) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* A resolver that recomputes boolean geometry from the graph, through the same path operation the
|
|
10
|
+
* canvas draws, so an export follows edits to the operands instead of a stored copy. A host that
|
|
11
|
+
* already draws the document passes its CanvasKit and renderer, so the export never loads a
|
|
12
|
+
* second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.
|
|
13
|
+
*/
|
|
14
|
+
declare function booleanPathResolver(canvasKit?: CanvasKit, renderer?: SkiaRenderer): Promise<BooleanPathResolver>;
|
|
15
|
+
/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */
|
|
16
|
+
declare function needsBooleanPaths(graph: SceneGraph): boolean;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { BooleanPathResolver, booleanPathResolver, needsBooleanPaths };
|
|
19
|
+
//# sourceMappingURL=boolean-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-path.d.ts","names":[],"sources":["../../../src/io/formats/boolean-path.ts"],"mappings":";;;;;;KAUY,uBAAuB,OAAO,YAAY,MAAM;;;;;;;iBA2B5C,oBACd,YAAY,WACZ,WAAW,eACV,QAAQ;;iBAeK,kBAAkB,OAAO"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { makeBooleanOperationPath } from "../../canvas/boolean.js";
|
|
2
|
+
import { headlessRenderer } from "./raster/headless.js";
|
|
3
|
+
//#region src/io/formats/boolean-path.ts
|
|
4
|
+
/** One resolver per renderer: a host's live one, or the offscreen renderer built for a CanvasKit. */
|
|
5
|
+
const resolvers = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const pendingByCanvasKit = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
let pending = null;
|
|
8
|
+
function resolverFor(renderer) {
|
|
9
|
+
const cached = resolvers.get(renderer);
|
|
10
|
+
if (cached) return cached;
|
|
11
|
+
const resolver = (graph, node) => {
|
|
12
|
+
const path = makeBooleanOperationPath(renderer, node, graph);
|
|
13
|
+
if (!path) return null;
|
|
14
|
+
const data = path.toSVGString();
|
|
15
|
+
path.delete();
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
resolvers.set(renderer, resolver);
|
|
19
|
+
return resolver;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A resolver that recomputes boolean geometry from the graph, through the same path operation the
|
|
23
|
+
* canvas draws, so an export follows edits to the operands instead of a stored copy. A host that
|
|
24
|
+
* already draws the document passes its CanvasKit and renderer, so the export never loads a
|
|
25
|
+
* second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.
|
|
26
|
+
*/
|
|
27
|
+
function booleanPathResolver(canvasKit, renderer) {
|
|
28
|
+
if (renderer) return Promise.resolve(resolverFor(renderer));
|
|
29
|
+
if (canvasKit) {
|
|
30
|
+
let forKit = pendingByCanvasKit.get(canvasKit);
|
|
31
|
+
if (!forKit) {
|
|
32
|
+
forKit = headlessRenderer(canvasKit).then(({ renderer }) => resolverFor(renderer));
|
|
33
|
+
pendingByCanvasKit.set(canvasKit, forKit);
|
|
34
|
+
}
|
|
35
|
+
return forKit;
|
|
36
|
+
}
|
|
37
|
+
pending ??= headlessRenderer().then(({ renderer }) => resolverFor(renderer));
|
|
38
|
+
return pending;
|
|
39
|
+
}
|
|
40
|
+
/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */
|
|
41
|
+
function needsBooleanPaths(graph) {
|
|
42
|
+
return [...graph.getAllNodes()].some((node) => node.type === "BOOLEAN_OPERATION" && node.fillGeometry.length === 0);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { booleanPathResolver, needsBooleanPaths };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=boolean-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-path.js","names":[],"sources":["../../../src/io/formats/boolean-path.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas'\nimport { makeBooleanOperationPath } from '#core/canvas/boolean'\n\nimport { headlessRenderer } from './raster/headless'\n\n/** Writes a boolean operation's live result path as SVG path data, or null when it has none. */\nexport type BooleanPathResolver = (graph: SceneGraph, node: SceneNode) => string | null\n\n/** One resolver per renderer: a host's live one, or the offscreen renderer built for a CanvasKit. */\nconst resolvers = new WeakMap<SkiaRenderer, BooleanPathResolver>()\nconst pendingByCanvasKit = new WeakMap<CanvasKit, Promise<BooleanPathResolver>>()\nlet pending: Promise<BooleanPathResolver> | null = null\n\nfunction resolverFor(renderer: SkiaRenderer): BooleanPathResolver {\n const cached = resolvers.get(renderer)\n if (cached) return cached\n const resolver: BooleanPathResolver = (graph, node) => {\n const path = makeBooleanOperationPath(renderer, node, graph)\n if (!path) return null\n const data = path.toSVGString()\n path.delete()\n return data\n }\n resolvers.set(renderer, resolver)\n return resolver\n}\n\n/**\n * A resolver that recomputes boolean geometry from the graph, through the same path operation the\n * canvas draws, so an export follows edits to the operands instead of a stored copy. A host that\n * already draws the document passes its CanvasKit and renderer, so the export never loads a\n * second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.\n */\nexport function booleanPathResolver(\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<BooleanPathResolver> {\n if (renderer) return Promise.resolve(resolverFor(renderer))\n if (canvasKit) {\n let forKit = pendingByCanvasKit.get(canvasKit)\n if (!forKit) {\n forKit = headlessRenderer(canvasKit).then(({ renderer }) => resolverFor(renderer))\n pendingByCanvasKit.set(canvasKit, forKit)\n }\n return forKit\n }\n pending ??= headlessRenderer().then(({ renderer }) => resolverFor(renderer))\n return pending\n}\n\n/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */\nexport function needsBooleanPaths(graph: SceneGraph): boolean {\n return [...graph.getAllNodes()].some(\n (node) => node.type === 'BOOLEAN_OPERATION' && node.fillGeometry.length === 0\n )\n}\n"],"mappings":";;;;AAaA,MAAM,4BAAY,IAAI,QAA2C;AACjE,MAAM,qCAAqB,IAAI,QAAiD;AAChF,IAAI,UAA+C;AAEnD,SAAS,YAAY,UAA6C;CAChE,MAAM,SAAS,UAAU,IAAI,QAAQ;CACrC,IAAI,QAAQ,OAAO;CACnB,MAAM,YAAiC,OAAO,SAAS;EACrD,MAAM,OAAO,yBAAyB,UAAU,MAAM,KAAK;EAC3D,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,OAAO,KAAK,YAAY;EAC9B,KAAK,OAAO;EACZ,OAAO;CACT;CACA,UAAU,IAAI,UAAU,QAAQ;CAChC,OAAO;AACT;;;;;;;AAQA,SAAgB,oBACd,WACA,UAC8B;CAC9B,IAAI,UAAU,OAAO,QAAQ,QAAQ,YAAY,QAAQ,CAAC;CAC1D,IAAI,WAAW;EACb,IAAI,SAAS,mBAAmB,IAAI,SAAS;EAC7C,IAAI,CAAC,QAAQ;GACX,SAAS,iBAAiB,SAAS,CAAC,CAAC,MAAM,EAAE,eAAe,YAAY,QAAQ,CAAC;GACjF,mBAAmB,IAAI,WAAW,MAAM;EAC1C;EACA,OAAO;CACT;CACA,YAAY,iBAAiB,CAAC,CAAC,MAAM,EAAE,eAAe,YAAY,QAAQ,CAAC;CAC3E,OAAO;AACT;;AAGA,SAAgB,kBAAkB,OAA4B;CAC5D,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,CAAC,MAC7B,SAAS,KAAK,SAAS,uBAAuB,KAAK,aAAa,WAAW,CAC9E;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PAIRDRAW_EXTENSION } from "./types.js";
|
|
2
2
|
import { ROOT_FONT_SIZE_PX } from "@pairdraw/scene-graph/variables";
|
|
3
3
|
import { CODE_SYNTAX_PLATFORMS, TOKEN_UNITS, VARIABLE_SCOPES } from "@pairdraw/scene-graph";
|
|
4
|
+
import { parseCSSNumber } from "@pairdraw/scene-graph/css";
|
|
4
5
|
import { parseDisplayableColor } from "@pairdraw/scene-graph/color";
|
|
5
6
|
import * as v from "valibot";
|
|
6
|
-
import { parseCSSNumber } from "@pairdraw/scene-graph/css";
|
|
7
7
|
//#region src/io/formats/design-tokens/decode.ts
|
|
8
8
|
/** A `{group.token}` reference, as its path segments. */
|
|
9
9
|
function referencePath(value) {
|
|
@@ -7,5 +7,8 @@ import { countTokenImportChanges } from "./plan/changes.js";
|
|
|
7
7
|
import { CSSTokenReadOptions, readCSSDesignTokens } from "./css/read.js";
|
|
8
8
|
import { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, DesignSystemFolder, DesignSystemImportResult, DesignSystemIssue, DesignSystemSourceFile, confinedDesignSystemPath, importDesignSystemFiles } from "./project.js";
|
|
9
9
|
import { TokenStylesheetSync, patchTokenStylesheet, syncTokenStylesheet } from "./css/sync.js";
|
|
10
|
+
import { TokenDrift, TokenDriftKind, TokenSync, TokenSyncBase, TokenSyncChoice, TokenSyncResolution, driftNeedsChoice, planTokenSync, tokenSnapshot, trackTokenDrift } from "./sync/drift.js";
|
|
11
|
+
import { readTokenSourceFiles } from "./sync/files.js";
|
|
12
|
+
import { TokenFilesSync, TokenSourceLink, syncTokenFiles, syncTokensIntoGraph, syncedTokenSources, tokenSourceForFiles } from "./sync/apply.js";
|
|
10
13
|
import { ImportedTokenFields, TokenImportResult, TokenImportTarget, applyTokenImport, importTokensIntoGraph, styleNodeProps, styleNodeType } from "./apply.js";
|
|
11
|
-
export { type AliasTarget, type CSSTokenReadOptions, type CollectionImportChoice, type CollectionTarget, DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, type DesignSystemFolder, type DesignSystemImportResult, type DesignSystemIssue, type DesignSystemSourceFile, type DesignToken, type DesignTokenBundle, type DesignTokenExport, type DesignTokenFile, type DesignTokenGroup, type DesignTokenIssue, type DesignTokenReadIssue, type DesignTokenSourceFile, type DesignTokenType, type ImportSkip, type ImportSkipReason, type ImportedTokenFields, type ModeTarget, PAIRDRAW_EXTENSION, type PlannedCollection, type PlannedMode, type PlannedStyle, type PlannedValue, type PlannedVariable, RESOLVER_FILE, RESOLVER_VERSION, type ReadCollection, type ReadMode, type ReadToken, STYLES_FILE, type TokenImportOptions, type TokenImportPlan, type TokenImportResult, type TokenImportTarget, type TokenStylesheetSync, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, readCSSDesignTokens, readDesignTokens, styleNodeProps, styleNodeType, syncTokenStylesheet };
|
|
14
|
+
export { type AliasTarget, type CSSTokenReadOptions, type CollectionImportChoice, type CollectionTarget, DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, type DesignSystemFolder, type DesignSystemImportResult, type DesignSystemIssue, type DesignSystemSourceFile, type DesignToken, type DesignTokenBundle, type DesignTokenExport, type DesignTokenFile, type DesignTokenGroup, type DesignTokenIssue, type DesignTokenReadIssue, type DesignTokenSourceFile, type DesignTokenType, type ImportSkip, type ImportSkipReason, type ImportedTokenFields, type ModeTarget, PAIRDRAW_EXTENSION, type PlannedCollection, type PlannedMode, type PlannedStyle, type PlannedValue, type PlannedVariable, RESOLVER_FILE, RESOLVER_VERSION, type ReadCollection, type ReadMode, type ReadToken, STYLES_FILE, type TokenDrift, type TokenDriftKind, type TokenFilesSync, type TokenImportOptions, type TokenImportPlan, type TokenImportResult, type TokenImportTarget, type TokenSourceLink, type TokenStylesheetSync, type TokenSync, type TokenSyncBase, type TokenSyncChoice, type TokenSyncResolution, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, driftNeedsChoice, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, planTokenSync, readCSSDesignTokens, readDesignTokens, readTokenSourceFiles, styleNodeProps, styleNodeType, syncTokenFiles, syncTokenStylesheet, syncTokensIntoGraph, syncedTokenSources, tokenSnapshot, tokenSourceForFiles, trackTokenDrift };
|
|
@@ -7,4 +7,7 @@ import { RESOLVER_FILE, STYLES_FILE, exportDesignTokens } from "./export.js";
|
|
|
7
7
|
import { readDesignTokens } from "./read.js";
|
|
8
8
|
import { countTokenImportChanges } from "./plan/changes.js";
|
|
9
9
|
import { patchTokenStylesheet, syncTokenStylesheet } from "./css/sync.js";
|
|
10
|
-
|
|
10
|
+
import { driftNeedsChoice, planTokenSync, tokenSnapshot, trackTokenDrift } from "./sync/drift.js";
|
|
11
|
+
import { readTokenSourceFiles } from "./sync/files.js";
|
|
12
|
+
import { syncTokenFiles, syncTokensIntoGraph, syncedTokenSources, tokenSourceForFiles } from "./sync/apply.js";
|
|
13
|
+
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, PAIRDRAW_EXTENSION, RESOLVER_FILE, RESOLVER_VERSION, STYLES_FILE, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, driftNeedsChoice, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, planTokenSync, readCSSDesignTokens, readDesignTokens, readTokenSourceFiles, styleNodeProps, styleNodeType, syncTokenFiles, syncTokenStylesheet, syncTokensIntoGraph, syncedTokenSources, tokenSnapshot, tokenSourceForFiles, trackTokenDrift };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { TokenImportPlan } from "./index.js";
|
|
2
|
-
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
1
|
+
import { PlannedValue, TokenImportPlan } from "./index.js";
|
|
2
|
+
import { SceneGraph, VariableValue } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/io/formats/design-tokens/plan/changes.d.ts
|
|
4
|
+
/** The value a planned one sets, or undefined where it points at a variable the import adds. */
|
|
5
|
+
declare function plannedValue(plan: TokenImportPlan, value: PlannedValue): VariableValue | undefined;
|
|
4
6
|
/**
|
|
5
7
|
* How many things an import would change: collections and modes it adds, variables it adds, and
|
|
6
8
|
* variables whose values it changes, so an import that would only write what the document already
|
|
@@ -8,5 +10,5 @@ import { SceneGraph } from "@pairdraw/scene-graph";
|
|
|
8
10
|
*/
|
|
9
11
|
declare function countTokenImportChanges(graph: SceneGraph, plan: TokenImportPlan): number;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { countTokenImportChanges };
|
|
13
|
+
export { countTokenImportChanges, plannedValue };
|
|
12
14
|
//# sourceMappingURL=changes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"mappings":";;;;iBAOgB,aACd,MAAM,iBACN,OAAO,eACN;;;;;;iBA0Ca,wBAAwB,OAAO,YAAY,MAAM"}
|