@pairdraw/core 0.19.2 → 0.21.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 +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -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 +74 -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/colors.d.ts +20 -5
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +48 -42
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +25 -0
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
- package/dist/canvas/renderer/document-surface.js +46 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +6 -4
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -3
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -0
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +36 -3
- 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/retained-backing.d.ts.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +2 -1
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- 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/tiles/surface-pool.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
- package/dist/canvas/renderer/tiles/surface-pool.js.map +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 +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- 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 +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +4 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/decorations.d.ts +2 -2
- package/dist/canvas/text/decorations.d.ts.map +1 -1
- package/dist/canvas/text/decorations.js +5 -5
- package/dist/canvas/text/decorations.js.map +1 -1
- package/dist/canvas/text/index.js +1 -1
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +2 -2
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -5
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -1
- package/dist/canvas/text/renderer.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +4 -4
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -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/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- package/dist/editor/clipboard/assets.js.map +1 -1
- package/dist/editor/clipboard/component-matches.d.ts +13 -0
- package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
- package/dist/editor/clipboard/component-matches.js +50 -0
- package/dist/editor/clipboard/component-matches.js.map +1 -0
- package/dist/editor/clipboard/dependencies.d.ts +7 -0
- package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
- package/dist/editor/clipboard/dependencies.js +5 -0
- package/dist/editor/clipboard/dependencies.js.map +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/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +48 -19
- package/dist/editor/clipboard.js.map +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/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -3
- package/dist/editor/components/properties.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 +26 -2
- 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 +171 -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 +9 -2
- 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/shapes/pencil.js +1 -1
- package/dist/editor/structure/state.d.ts.map +1 -1
- package/dist/editor/structure/state.js +2 -2
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +2 -2
- package/dist/editor/text.js.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/variables.js +3 -3
- package/dist/editor/variables.js.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/fresh-read.d.ts +15 -0
- package/dist/figma-api/fresh-read.d.ts.map +1 -0
- package/dist/figma-api/fresh-read.js +54 -0
- package/dist/figma-api/fresh-read.js.map +1 -0
- package/dist/figma-api/graph-ref.d.ts +9 -0
- package/dist/figma-api/graph-ref.d.ts.map +1 -0
- package/dist/figma-api/graph-ref.js +14 -0
- package/dist/figma-api/graph-ref.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- 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/pending-layout.d.ts +3 -3
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +7 -3
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +1 -1
- package/dist/figma-api/pending-sync.d.ts.map +1 -1
- package/dist/figma-api/pending-sync.js +3 -1
- package/dist/figma-api/pending-sync.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 +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- 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/figma-api/variables/index.d.ts.map +1 -1
- package/dist/figma-api/variables/index.js +2 -2
- package/dist/figma-api/variables/index.js.map +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/css/known.js +1 -1
- package/dist/io/formats/design-tokens/css/known.js.map +1 -1
- package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
- package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/read.js +11 -5
- package/dist/io/formats/design-tokens/css/read.js.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.js +17 -4
- package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
- package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
- package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/values.js +24 -8
- package/dist/io/formats/design-tokens/css/values.js.map +1 -1
- package/dist/io/formats/design-tokens/decode.d.ts +7 -6
- package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/decode.js +14 -13
- package/dist/io/formats/design-tokens/decode.js.map +1 -1
- package/dist/io/formats/design-tokens/export.js +3 -3
- package/dist/io/formats/design-tokens/export.js.map +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/plan/index.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -3
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +9 -9
- package/dist/io/formats/design-tokens/plan/styles.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 +4 -4
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +7 -7
- 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/design-tokens/values.d.ts +10 -5
- package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/values.js +13 -7
- package/dist/io/formats/design-tokens/values.js.map +1 -1
- 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/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -1
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts +7 -2
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +12 -13
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +9 -7
- package/dist/io/formats/fig/export/variables.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 +4 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/layers.js +2 -2
- package/dist/io/formats/mermaid/layers.js.map +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/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -0
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +4 -4
- package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
- package/dist/io/formats/pdf/prepare.js +2 -2
- package/dist/io/formats/pdf/prepare.js.map +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 +35 -5
- 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/pptx/style.js +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 +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- 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 +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -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/import.d.ts +4 -2
- package/dist/io/formats/svg/import.d.ts.map +1 -1
- package/dist/io/formats/svg/import.js +2 -1
- package/dist/io/formats/svg/import.js.map +1 -1
- 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/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +8 -8
- package/dist/io/formats/svg/text/export.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 +8 -5
- 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 +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +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/yoga-helpers.d.ts +2 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +7 -1
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- 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 +112 -10
- 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/comments.d.ts +4 -1
- package/dist/pairdraw-api/comments.d.ts.map +1 -1
- package/dist/pairdraw-api/comments.js +5 -0
- package/dist/pairdraw-api/comments.js.map +1 -1
- 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 +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- 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/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/rpc/variables-command.js +2 -2
- package/dist/rpc/variables-command.js.map +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/font/provider.d.ts +15 -0
- package/dist/text/font/provider.d.ts.map +1 -0
- package/dist/text/font/provider.js +18 -0
- package/dist/text/font/provider.js.map +1 -0
- package/dist/text/font/readiness.d.ts +32 -0
- package/dist/text/font/readiness.d.ts.map +1 -0
- package/dist/text/font/{status.js → readiness.js} +8 -4
- package/dist/text/font/readiness.js.map +1 -0
- package/dist/text/index.d.ts +12 -9
- package/dist/text/index.js +6 -3
- package/dist/text/prepare.d.ts +9 -4
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +9 -4
- package/dist/text/prepare.js.map +1 -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/colors.js +1 -1
- 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 +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze/responsive/widths.d.ts +27 -0
- package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/widths.js +49 -0
- package/dist/tools/analyze/responsive/widths.js.map +1 -0
- package/dist/tools/analyze.d.ts +3 -1
- package/dist/tools/analyze.js +3 -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/tokens.d.ts.map +1 -1
- package/dist/tools/codegen/tokens.js +2 -2
- package/dist/tools/codegen/tokens.js.map +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -2
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/component-catalog.d.ts.map +1 -1
- package/dist/tools/component-catalog.js +5 -3
- package/dist/tools/component-catalog.js.map +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.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- 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 +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/css/shorthand.d.ts +20 -0
- package/dist/tools/css/shorthand.d.ts.map +1 -0
- package/dist/tools/css/shorthand.js +54 -0
- package/dist/tools/css/shorthand.js.map +1 -0
- package/dist/tools/describe/index.js +2 -2
- package/dist/tools/describe/index.js.map +1 -1
- package/dist/tools/describe/issues.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/html-host.d.ts.map +1 -1
- package/dist/tools/html-host.js +5 -3
- package/dist/tools/html-host.js.map +1 -1
- package/dist/tools/image-ai/apply.d.ts.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -3
- package/dist/tools/image-ai/apply.js.map +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/image-ai/service.d.ts.map +1 -1
- package/dist/tools/image-ai/service.js +5 -3
- package/dist/tools/image-ai/service.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -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/geometry.d.ts.map +1 -1
- package/dist/tools/modify/geometry.js +14 -3
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +35 -8
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +10 -10
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +56 -4
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +2 -2
- 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 +29 -8
- 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/prompts/codegen.js +1 -1
- package/dist/tools/prompts/codegen.js.map +1 -1
- package/dist/tools/read/css.d.ts +14 -0
- package/dist/tools/read/css.d.ts.map +1 -0
- package/dist/tools/read/css.js +306 -0
- package/dist/tools/read/css.js.map +1 -0
- 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 +1 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/reactions.js +1 -1
- package/dist/tools/read/reactions.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 -5
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -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 +5 -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 +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script/host.d.ts.map +1 -1
- package/dist/tools/script/host.js +5 -3
- package/dist/tools/script/host.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/variables/collections.js +1 -1
- package/dist/tools/variables/collections.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -4
- package/dist/tools/variables/values.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.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- 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 +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
- package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/gradients.js +5 -5
- package/dist/vector/vectorize/svg/gradients.js.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.js +13 -12
- package/dist/vector/vectorize/svg/to-vectors.js.map +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 +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/colors.ts +76 -50
- package/src/canvas/renderer/document-surface.ts +53 -0
- package/src/canvas/renderer/fonts.ts +6 -4
- package/src/canvas/renderer/lifecycle.ts +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -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/assets.ts +6 -2
- package/src/editor/clipboard/component-matches.ts +65 -0
- package/src/editor/clipboard/dependencies.ts +22 -1
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- 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 +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- 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/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- 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/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/css/known.ts +1 -1
- package/src/io/formats/design-tokens/css/read.ts +20 -7
- package/src/io/formats/design-tokens/css/sync.ts +9 -4
- package/src/io/formats/design-tokens/css/values.ts +37 -9
- package/src/io/formats/design-tokens/decode.ts +17 -12
- package/src/io/formats/design-tokens/export.ts +3 -3
- 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/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- 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/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -1
- package/src/io/formats/fig/export/setup.ts +25 -15
- package/src/io/formats/fig/export/variables.ts +17 -6
- 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 +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- 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 +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- 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 +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- 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/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- 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/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -1
- package/src/tools/create/vector.ts +2 -2
- package/src/tools/css/shorthand.ts +64 -0
- package/src/tools/describe/index.ts +2 -8
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/geometry.ts +16 -3
- package/src/tools/modify/layout.ts +47 -13
- package/src/tools/modify/matching.ts +14 -11
- package/src/tools/modify/paint.ts +85 -5
- package/src/tools/modify/reactions.ts +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- 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/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
package/src/figma-api/effects.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as v from 'valibot'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
BlendMode,
|
|
5
|
+
Effect,
|
|
6
|
+
NoiseEffect,
|
|
7
|
+
NoiseEffectParams,
|
|
8
|
+
ShaderEffect,
|
|
9
|
+
TextureEffect
|
|
10
|
+
} from '@pairdraw/scene-graph'
|
|
11
|
+
import { BLACK } from '@pairdraw/scene-graph/constants'
|
|
12
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
4
13
|
|
|
5
14
|
import { TRANSPARENT } from '#core/constants'
|
|
6
15
|
|
|
@@ -29,13 +38,21 @@ const BLEND_MODE_KEYS = {
|
|
|
29
38
|
export const BLEND_MODES = Object.keys(BLEND_MODE_KEYS) as BlendMode[]
|
|
30
39
|
|
|
31
40
|
/** Effect kinds Figma's plugin API accepts that Pairdraw does not model yet. */
|
|
32
|
-
const UNSUPPORTED_EFFECT_TYPES = new Set(['
|
|
41
|
+
const UNSUPPORTED_EFFECT_TYPES = new Set(['GLASS', 'SHADER'])
|
|
33
42
|
|
|
34
43
|
// Figma rejects Infinity as well as NaN ("Number must be finite").
|
|
35
44
|
const finiteSchema = v.pipe(v.number(), v.finite())
|
|
36
45
|
const unitSchema = v.pipe(finiteSchema, v.minValue(0), v.maxValue(1))
|
|
37
46
|
const nonNegativeSchema = v.pipe(finiteSchema, v.minValue(0))
|
|
38
47
|
|
|
48
|
+
// Figma keeps a grain size, and a texture's radius, above 100 at 100 rather than refusing it.
|
|
49
|
+
const GRAIN_MAX = 100
|
|
50
|
+
const grainSchema = v.pipe(
|
|
51
|
+
nonNegativeSchema,
|
|
52
|
+
v.transform((size) => Math.min(size, GRAIN_MAX))
|
|
53
|
+
)
|
|
54
|
+
const grainVectorSchema = v.optional(v.strictObject({ x: grainSchema, y: grainSchema }))
|
|
55
|
+
|
|
39
56
|
const colorSchema = v.strictObject({ r: unitSchema, g: unitSchema, b: unitSchema, a: unitSchema })
|
|
40
57
|
const vectorSchema = v.strictObject({ x: finiteSchema, y: finiteSchema })
|
|
41
58
|
// Variable bindings on effects are not supported; Figma reports an empty object.
|
|
@@ -51,6 +68,17 @@ const shadowEntries = {
|
|
|
51
68
|
boundVariables: boundVariablesSchema
|
|
52
69
|
}
|
|
53
70
|
|
|
71
|
+
// A noise has no visible radius, yet only its radius binds, as on a blur (Figma 126).
|
|
72
|
+
const noiseEntries = {
|
|
73
|
+
type: v.literal('NOISE'),
|
|
74
|
+
visible: v.boolean(),
|
|
75
|
+
boundVariables: boundVariablesSchema,
|
|
76
|
+
noiseSize: grainSchema,
|
|
77
|
+
noiseSizeVector: grainVectorSchema,
|
|
78
|
+
color: colorSchema,
|
|
79
|
+
density: unitSchema
|
|
80
|
+
}
|
|
81
|
+
|
|
54
82
|
const effectSchema = v.variant('type', [
|
|
55
83
|
v.strictObject({
|
|
56
84
|
type: v.literal('DROP_SHADOW'),
|
|
@@ -64,6 +92,24 @@ const effectSchema = v.variant('type', [
|
|
|
64
92
|
visible: v.boolean(),
|
|
65
93
|
blurType: v.optional(v.literal('NORMAL'), 'NORMAL'),
|
|
66
94
|
boundVariables: boundVariablesSchema
|
|
95
|
+
}),
|
|
96
|
+
v.variant('noiseType', [
|
|
97
|
+
v.strictObject({ ...noiseEntries, noiseType: v.literal('MONOTONE') }),
|
|
98
|
+
v.strictObject({
|
|
99
|
+
...noiseEntries,
|
|
100
|
+
noiseType: v.literal('DUOTONE'),
|
|
101
|
+
secondaryColor: colorSchema
|
|
102
|
+
}),
|
|
103
|
+
v.strictObject({ ...noiseEntries, noiseType: v.literal('MULTITONE'), opacity: unitSchema })
|
|
104
|
+
]),
|
|
105
|
+
v.strictObject({
|
|
106
|
+
type: v.literal('TEXTURE'),
|
|
107
|
+
visible: v.boolean(),
|
|
108
|
+
radius: grainSchema,
|
|
109
|
+
boundVariables: boundVariablesSchema,
|
|
110
|
+
noiseSize: grainSchema,
|
|
111
|
+
noiseSizeVector: grainVectorSchema,
|
|
112
|
+
clipToShape: v.boolean()
|
|
67
113
|
})
|
|
68
114
|
])
|
|
69
115
|
|
|
@@ -93,6 +139,29 @@ function unsupportedEffect(value: unknown): string | null {
|
|
|
93
139
|
return null
|
|
94
140
|
}
|
|
95
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Figma's complaint about an effect whose `noiseSize` is not its `noiseSizeVector.x`, read from
|
|
144
|
+
* the values it was given, or null. The vector's `y` may differ: that is how a grain is not square.
|
|
145
|
+
*/
|
|
146
|
+
function grainSizeMismatch(value: unknown): string | null {
|
|
147
|
+
const grain = v.object({ noiseSize: v.number(), noiseSizeVector: v.object({ x: v.number() }) })
|
|
148
|
+
if (!Array.isArray(value)) return null
|
|
149
|
+
for (const effect of value) {
|
|
150
|
+
if (!v.is(grain, effect) || effect.noiseSize === effect.noiseSizeVector.x) continue
|
|
151
|
+
return `Effect noiseSize (${effect.noiseSize}) does not match noiseSizeVector.x (${effect.noiseSizeVector.x}). Ensure these values are consistent.`
|
|
152
|
+
}
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* `effects` with every texture after the first left out, as Figma silently keeps one. The effects
|
|
158
|
+
* setter reads bindings from the same list, so their indexes match the effects it keeps.
|
|
159
|
+
*/
|
|
160
|
+
export function firstTextureOnly<T extends { readonly type: string }>(effects: readonly T[]): T[] {
|
|
161
|
+
const first = effects.findIndex((effect) => effect.type === 'TEXTURE')
|
|
162
|
+
return effects.filter((effect, index) => effect.type !== 'TEXTURE' || index === first)
|
|
163
|
+
}
|
|
164
|
+
|
|
96
165
|
/**
|
|
97
166
|
* Check `value` against Figma's effect shapes and convert it to scene effects.
|
|
98
167
|
* Throws with the first problem, as Figma's `effects` setter does.
|
|
@@ -107,17 +176,48 @@ export function parseFigmaEffects(value: unknown): Effect[] {
|
|
|
107
176
|
`Property "effects" failed validation: ${issue.message} at ${issuePath(issue.path) || 'effects'}`
|
|
108
177
|
)
|
|
109
178
|
}
|
|
110
|
-
|
|
179
|
+
const mismatch = grainSizeMismatch(value)
|
|
180
|
+
if (mismatch) throw new Error(`Property "effects" failed validation: ${mismatch}`)
|
|
181
|
+
return firstTextureOnly(result.output).map(toSceneEffect)
|
|
111
182
|
}
|
|
112
183
|
|
|
113
184
|
/** `value` as scene effects when it holds valid Figma effects, or null. */
|
|
114
185
|
export function tryParseFigmaEffects(value: unknown): Effect[] | null {
|
|
115
186
|
if (unsupportedEffect(value)) return null
|
|
116
187
|
const result = v.safeParse(effectsSchema, value)
|
|
117
|
-
|
|
188
|
+
if (!result.success) return null
|
|
189
|
+
if (grainSizeMismatch(value)) return null
|
|
190
|
+
return firstTextureOnly(result.output).map(toSceneEffect)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** A grain size as both axes, from the vector when given, else the one number. */
|
|
194
|
+
function grainSize(effect: { noiseSize: number; noiseSizeVector?: Vector }): Vector {
|
|
195
|
+
return effect.noiseSizeVector
|
|
196
|
+
? { ...effect.noiseSizeVector }
|
|
197
|
+
: { x: effect.noiseSize, y: effect.noiseSize }
|
|
118
198
|
}
|
|
119
199
|
|
|
120
200
|
function toSceneEffect(effect: FigmaEffect): Effect {
|
|
201
|
+
if (effect.type === 'NOISE') {
|
|
202
|
+
const noise: NoiseEffectParams = {
|
|
203
|
+
noiseType: effect.noiseType,
|
|
204
|
+
noiseSize: grainSize(effect),
|
|
205
|
+
density: effect.density
|
|
206
|
+
}
|
|
207
|
+
if (effect.noiseType === 'DUOTONE') noise.secondaryColor = { ...effect.secondaryColor }
|
|
208
|
+
if (effect.noiseType === 'MULTITONE') noise.opacity = effect.opacity
|
|
209
|
+
return { type: 'NOISE', color: { ...effect.color }, visible: effect.visible, noise }
|
|
210
|
+
}
|
|
211
|
+
if (effect.type === 'TEXTURE') {
|
|
212
|
+
return {
|
|
213
|
+
type: 'TEXTURE',
|
|
214
|
+
// A `.fig` texture carries an opaque black colour it does not use.
|
|
215
|
+
color: { ...BLACK },
|
|
216
|
+
radius: effect.radius,
|
|
217
|
+
visible: effect.visible,
|
|
218
|
+
texture: { noiseSize: grainSize(effect), clipToShape: effect.clipToShape }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
121
221
|
if (effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW') {
|
|
122
222
|
return {
|
|
123
223
|
type: effect.type,
|
|
@@ -144,7 +244,9 @@ function toSceneEffect(effect: FigmaEffect): Effect {
|
|
|
144
244
|
}
|
|
145
245
|
|
|
146
246
|
/** A scene effect in the shape Figma's `effects` getter returns. */
|
|
147
|
-
export function toFigmaEffect(effect:
|
|
247
|
+
export function toFigmaEffect(effect: Exclude<Effect, ShaderEffect>): FigmaEffect {
|
|
248
|
+
if (effect.type === 'NOISE') return figmaNoiseEffect(effect)
|
|
249
|
+
if (effect.type === 'TEXTURE') return figmaTextureEffect(effect)
|
|
148
250
|
if (
|
|
149
251
|
effect.type === 'LAYER_BLUR' ||
|
|
150
252
|
effect.type === 'FOREGROUND_BLUR' ||
|
|
@@ -177,3 +279,39 @@ export function toFigmaEffect(effect: ShadowEffect): FigmaEffect {
|
|
|
177
279
|
}
|
|
178
280
|
: { type: 'INNER_SHADOW', ...shadow }
|
|
179
281
|
}
|
|
282
|
+
|
|
283
|
+
/** A scene noise effect as Figma's `effects` getter returns it, each noise type with its field. */
|
|
284
|
+
function figmaNoiseEffect(effect: NoiseEffect): FigmaEffect {
|
|
285
|
+
const noise = effect.noise
|
|
286
|
+
const base = {
|
|
287
|
+
type: 'NOISE' as const,
|
|
288
|
+
visible: effect.visible,
|
|
289
|
+
boundVariables: {},
|
|
290
|
+
noiseSize: noise.noiseSize.x,
|
|
291
|
+
noiseSizeVector: { ...noise.noiseSize },
|
|
292
|
+
color: { ...effect.color },
|
|
293
|
+
density: noise.density
|
|
294
|
+
}
|
|
295
|
+
if (noise.noiseType === 'DUOTONE') {
|
|
296
|
+
const secondaryColor = { ...(noise.secondaryColor ?? effect.color) }
|
|
297
|
+
return { ...base, noiseType: 'DUOTONE', secondaryColor }
|
|
298
|
+
}
|
|
299
|
+
if (noise.noiseType === 'MULTITONE') {
|
|
300
|
+
return { ...base, noiseType: 'MULTITONE', opacity: noise.opacity ?? 1 }
|
|
301
|
+
}
|
|
302
|
+
return { ...base, noiseType: 'MONOTONE' }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** A scene texture effect as Figma's `effects` getter returns it. */
|
|
306
|
+
function figmaTextureEffect(effect: TextureEffect): FigmaEffect {
|
|
307
|
+
const texture = effect.texture
|
|
308
|
+
return {
|
|
309
|
+
type: 'TEXTURE',
|
|
310
|
+
visible: effect.visible,
|
|
311
|
+
radius: effect.radius,
|
|
312
|
+
boundVariables: {},
|
|
313
|
+
noiseSize: texture.noiseSize.x,
|
|
314
|
+
noiseSizeVector: { ...texture.noiseSize },
|
|
315
|
+
clipToShape: texture.clipToShape
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
3
|
+
import { registerFreshGraph, underlyingGraph } from './graph-ref'
|
|
4
|
+
import { flushPendingLayout } from './pending-layout'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The graph reads that must see every edit recorded before them. A read added to SceneGraph and not
|
|
8
|
+
* to this list stays stale, so add it here; `satisfies` catches a rename.
|
|
9
|
+
* `getChildren` pays a flush plus an array per call, so a tool looping parents over children should
|
|
10
|
+
* take the raw graph once and read that.
|
|
11
|
+
*/
|
|
12
|
+
const FRESH_READS = new Set<PropertyKey>([
|
|
13
|
+
'getNode',
|
|
14
|
+
'getChildren',
|
|
15
|
+
'getPages',
|
|
16
|
+
'getAllNodes',
|
|
17
|
+
'flattenTree',
|
|
18
|
+
'closest',
|
|
19
|
+
'getAbsolutePosition',
|
|
20
|
+
'pageOf'
|
|
21
|
+
] satisfies (keyof SceneGraph)[])
|
|
22
|
+
|
|
23
|
+
const freshGraphs = new WeakMap<SceneGraph, SceneGraph>()
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Lays out and syncs the edits recorded since the last read, then runs `read`. One seam for every
|
|
27
|
+
* surface that reads the graph, so no caller has to flush first.
|
|
28
|
+
*/
|
|
29
|
+
export function freshRead<T>(graph: SceneGraph, read: () => T): T {
|
|
30
|
+
flushPendingLayout(underlyingGraph(graph))
|
|
31
|
+
return read()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The graph as read surfaces see it. A read lays out pending edits first; a write goes straight
|
|
36
|
+
* through, and the writer decides whether an edit depends on a fresh layout.
|
|
37
|
+
*/
|
|
38
|
+
export function freshReadGraph(graph: SceneGraph): SceneGraph {
|
|
39
|
+
const cached = freshGraphs.get(graph)
|
|
40
|
+
if (cached) return cached
|
|
41
|
+
const methods = new Map<PropertyKey, (...args: never[]) => unknown>()
|
|
42
|
+
const proxy = new Proxy(graph, {
|
|
43
|
+
get(target, property, receiver) {
|
|
44
|
+
const value = Reflect.get(target, property, receiver)
|
|
45
|
+
if (!FRESH_READS.has(property) || typeof value !== 'function') return value
|
|
46
|
+
let method = methods.get(property)
|
|
47
|
+
if (!method) {
|
|
48
|
+
method = (...args: never[]) => freshRead(target, () => value.apply(target, args))
|
|
49
|
+
methods.set(property, method)
|
|
50
|
+
}
|
|
51
|
+
return method
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
freshGraphs.set(graph, proxy)
|
|
55
|
+
registerFreshGraph(proxy, graph)
|
|
56
|
+
return proxy
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
3
|
+
const rawByProxy = new WeakMap<object, SceneGraph>()
|
|
4
|
+
|
|
5
|
+
/** Remembers the raw graph behind a read-freshening proxy, so pending work keyed by the raw graph is found. */
|
|
6
|
+
export function registerFreshGraph(proxy: SceneGraph, graph: SceneGraph): void {
|
|
7
|
+
rawByProxy.set(proxy, graph)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The graph pending layout and instance sync are recorded on. */
|
|
11
|
+
export function underlyingGraph<T extends object>(graph: T): T {
|
|
12
|
+
return (rawByProxy.get(graph) as T | undefined) ?? graph
|
|
13
|
+
}
|
package/src/figma-api/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { listFigmaFonts } from './fonts/list'
|
|
|
26
26
|
import { loadFigmaFont } from './fonts/load'
|
|
27
27
|
import type { FigmaFontNameInput } from './fonts/names'
|
|
28
28
|
import { variationAxisTags } from './fonts/variations'
|
|
29
|
+
import { freshReadGraph } from './fresh-read'
|
|
29
30
|
import * as images from './images'
|
|
30
31
|
import type {
|
|
31
32
|
FigmaBooleanOperationNode,
|
|
@@ -45,7 +46,7 @@ import type {
|
|
|
45
46
|
FigmaVectorNode
|
|
46
47
|
} from './node-types'
|
|
47
48
|
import { startPendingLayout } from './pending-layout'
|
|
48
|
-
import {
|
|
49
|
+
import { startPendingComponentSync } from './pending-sync'
|
|
49
50
|
import {
|
|
50
51
|
FigmaNodeProxy,
|
|
51
52
|
INTERNAL_ID,
|
|
@@ -122,6 +123,7 @@ export interface FigmaAPIOptions {
|
|
|
122
123
|
|
|
123
124
|
export { FigmaNodeProxy } from './proxy'
|
|
124
125
|
export { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'
|
|
126
|
+
export { freshRead, freshReadGraph } from './fresh-read'
|
|
125
127
|
export { flushPendingLayout } from './pending-layout'
|
|
126
128
|
export { flushPendingComponentSync } from './pending-sync'
|
|
127
129
|
export type { FigmaEffect } from './effects'
|
|
@@ -185,6 +187,10 @@ const clientStorage: ClientStorageAPI = {
|
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
export class FigmaAPI implements NodeProxyHost {
|
|
190
|
+
/**
|
|
191
|
+
* The read-freshening proxy. It is not the raw graph, so an identity check against an editor's
|
|
192
|
+
* graph goes through `underlyingGraph`; node internals already hold the raw graph.
|
|
193
|
+
*/
|
|
188
194
|
readonly graph: SceneGraph
|
|
189
195
|
private _currentPageId: string
|
|
190
196
|
private _selection: FigmaNodeProxy[] = []
|
|
@@ -213,7 +219,7 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
213
219
|
#pageSwitch = 0
|
|
214
220
|
|
|
215
221
|
constructor(graph: SceneGraph, options: FigmaAPIOptions = {}) {
|
|
216
|
-
this.graph = graph
|
|
222
|
+
this.graph = freshReadGraph(graph)
|
|
217
223
|
this.#fetch = options.fetch ?? ((input, init) => fetch(input, init))
|
|
218
224
|
if (options.loadPage)
|
|
219
225
|
setPageHost(this, { load: options.loadPage, pageOfNode: options.pageOfNode })
|
|
@@ -298,7 +304,6 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
298
304
|
}
|
|
299
305
|
|
|
300
306
|
getNodeById(id: string): FigmaNodeProxy | null {
|
|
301
|
-
flushPendingComponentSync(this.graph)
|
|
302
307
|
const node = this.graph.getNode(id)
|
|
303
308
|
return node ? this.wrapNode(id) : null
|
|
304
309
|
}
|
|
@@ -400,7 +405,10 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
400
405
|
/** The layers Figma makes from SVG markup, on the current page at its origin. */
|
|
401
406
|
// eslint-disable-next-line pairdraw/no-mixed-case-acronym-identifiers -- Figma Plugin API name.
|
|
402
407
|
createNodeFromSvg(svg: string): FigmaFrameNode {
|
|
403
|
-
const node = createSVGNodes(this.graph, this._currentPageId, svg, {
|
|
408
|
+
const node = createSVGNodes(this.graph, this._currentPageId, svg, {
|
|
409
|
+
keepEmpty: true,
|
|
410
|
+
profile: this.graph.documentColorSpace
|
|
411
|
+
})
|
|
404
412
|
if (!node) throw new Error('in createNodeFromSvg: Failed to convert SVG file')
|
|
405
413
|
return this.wrapNode(node.id) as FigmaFrameNode
|
|
406
414
|
}
|
|
@@ -771,6 +779,16 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
771
779
|
}
|
|
772
780
|
|
|
773
781
|
exportImage?: (nodeIds: string[], options: ExportImageOptions) => Promise<Uint8Array | null>
|
|
782
|
+
/**
|
|
783
|
+
* Renders nodes of a graph other than the open document's, such as a copy a tool resized, so
|
|
784
|
+
* checking a variant leaves the document and its undo history untouched.
|
|
785
|
+
*/
|
|
786
|
+
exportGraphImage?: (
|
|
787
|
+
graph: SceneGraph,
|
|
788
|
+
pageId: string,
|
|
789
|
+
nodeIds: string[],
|
|
790
|
+
options: ExportImageOptions
|
|
791
|
+
) => Promise<Uint8Array | null>
|
|
774
792
|
/** Where icon tools search and fetch icons; hosts may pass a self-hosted or bundled set. */
|
|
775
793
|
icons: IconProvider = defaultIcons
|
|
776
794
|
rasterCodec?: RasterCodec
|
|
@@ -9,7 +9,10 @@ import type {
|
|
|
9
9
|
} from '@pairdraw/scene-graph'
|
|
10
10
|
import { findInstanceAncestor, isReplacedLayer } from '@pairdraw/scene-graph/instances'
|
|
11
11
|
import {
|
|
12
|
+
overriddenAssignmentId,
|
|
13
|
+
overriddenBindingField,
|
|
12
14
|
overriddenVariableModeCollection,
|
|
15
|
+
REPLACED_LAYER_OVERRIDE,
|
|
13
16
|
type InstanceOverrideState
|
|
14
17
|
} from '@pairdraw/scene-graph/instances/overrides'
|
|
15
18
|
|
|
@@ -150,11 +153,79 @@ function figmaFields(fields: Iterable<string>, skipped: Set<string>): string[] {
|
|
|
150
153
|
* instance links to the component's instance it copies, until a swap points it at a component;
|
|
151
154
|
* the enclosing instance then keeps the layer it copied.
|
|
152
155
|
*/
|
|
153
|
-
function componentLayer(
|
|
156
|
+
function componentLayer(
|
|
157
|
+
graph: SceneGraph,
|
|
158
|
+
node: SceneNode,
|
|
159
|
+
owner: SceneNode | undefined
|
|
160
|
+
): SceneNode | undefined {
|
|
154
161
|
const linked = node.componentId ? graph.getNode(node.componentId) : undefined
|
|
155
|
-
if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE')
|
|
162
|
+
if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE') {
|
|
163
|
+
return linked ? resolveCopiedLayer(graph, linked) : linked
|
|
164
|
+
}
|
|
156
165
|
const source = owner?.instanceOverrides.descendants.get(node.id)?.get('sourceComponentId')
|
|
157
|
-
|
|
166
|
+
if (typeof source === 'string') return graph.getNode(source)
|
|
167
|
+
return componentLayerByName(graph, node, owner)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* A copy inside a nested instance links to the enclosing component's copy, which in turn links
|
|
172
|
+
* to the nested component's layer. Follow that chain to the layer an edit belongs to.
|
|
173
|
+
*/
|
|
174
|
+
function resolveCopiedLayer(graph: SceneGraph, linked: SceneNode): SceneNode {
|
|
175
|
+
let target = linked
|
|
176
|
+
for (let depth = 0; depth < 32 && target.componentId; depth++) {
|
|
177
|
+
const parent = target.parentId ? graph.getNode(target.parentId) : undefined
|
|
178
|
+
if (parent?.type !== 'INSTANCE') break
|
|
179
|
+
const next = graph.getNode(target.componentId)
|
|
180
|
+
if (!next) break
|
|
181
|
+
target = next
|
|
182
|
+
}
|
|
183
|
+
return target
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A copy made by cloning carries no link to its source, so match the path from its instance to
|
|
188
|
+
* the instance's component by sibling position and name.
|
|
189
|
+
*/
|
|
190
|
+
function componentLayerByName(
|
|
191
|
+
graph: SceneGraph,
|
|
192
|
+
node: SceneNode,
|
|
193
|
+
owner: SceneNode | undefined
|
|
194
|
+
): SceneNode | undefined {
|
|
195
|
+
if (owner?.type !== 'INSTANCE' || !owner.componentId) return undefined
|
|
196
|
+
const path: SceneNode[] = []
|
|
197
|
+
let current: SceneNode | undefined = node
|
|
198
|
+
while (current && current.id !== owner.id) {
|
|
199
|
+
path.unshift(current)
|
|
200
|
+
current = current.parentId ? graph.getNode(current.parentId) : undefined
|
|
201
|
+
}
|
|
202
|
+
if (!current) return undefined
|
|
203
|
+
let source = graph.getNode(owner.componentId)
|
|
204
|
+
// A nested instance copies the enclosing component's nested instance, so follow its link to
|
|
205
|
+
// the component that instance actually shows.
|
|
206
|
+
while (source?.type === 'INSTANCE' && source.componentId)
|
|
207
|
+
source = graph.getNode(source.componentId)
|
|
208
|
+
for (const step of path) {
|
|
209
|
+
if (!source) return undefined
|
|
210
|
+
source = matchingComponentChild(graph, source, step)
|
|
211
|
+
}
|
|
212
|
+
return source
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The component child a copy at the same place shows, preferring its sibling position. */
|
|
216
|
+
function matchingComponentChild(
|
|
217
|
+
graph: SceneGraph,
|
|
218
|
+
source: SceneNode,
|
|
219
|
+
step: SceneNode
|
|
220
|
+
): SceneNode | undefined {
|
|
221
|
+
const siblings = graph.getChildren(source.id)
|
|
222
|
+
const index = step.parentId ? graph.getNode(step.parentId)?.childIds.indexOf(step.id) : -1
|
|
223
|
+
const atIndex = index !== undefined && index >= 0 ? siblings[index] : undefined
|
|
224
|
+
if (atIndex?.type === step.type) return atIndex
|
|
225
|
+
return (
|
|
226
|
+
siblings.find((sibling) => sibling.type === step.type && sibling.name === step.name) ??
|
|
227
|
+
siblings.find((sibling) => sibling.type === step.type)
|
|
228
|
+
)
|
|
158
229
|
}
|
|
159
230
|
|
|
160
231
|
/** Figma keeps stroke weight and alignment on the layer, so a paint differs by its colour alone. */
|
|
@@ -222,6 +293,227 @@ function withoutEdits(graph: SceneGraph, state: InstanceOverrideState): Instance
|
|
|
222
293
|
return { self: new Map(), descendants }
|
|
223
294
|
}
|
|
224
295
|
|
|
296
|
+
/** Every instance at or below `root`, deepest first, as pushing each one's edits needs them. */
|
|
297
|
+
function instancesDeepestFirst(graph: SceneGraph, root: SceneNode): SceneNode[] {
|
|
298
|
+
const result: SceneNode[] = []
|
|
299
|
+
const visit = (node: SceneNode): void => {
|
|
300
|
+
for (const child of graph.getChildren(node.id)) visit(child)
|
|
301
|
+
if (node.type === 'INSTANCE') result.push(node)
|
|
302
|
+
}
|
|
303
|
+
visit(root)
|
|
304
|
+
return result
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** The main component an instance's own edits belong to, if it can take them. */
|
|
308
|
+
function pushableMainComponent(
|
|
309
|
+
graph: SceneGraph,
|
|
310
|
+
instance: SceneNode,
|
|
311
|
+
canEditMain: ((componentId: string) => boolean) | undefined
|
|
312
|
+
): SceneNode | null {
|
|
313
|
+
let component = instance.componentId ? graph.getNode(instance.componentId) : undefined
|
|
314
|
+
// A nested copy's link points at the enclosing component's nested instance, not at the
|
|
315
|
+
// component that instance shows, so follow it to the main component the edits belong to.
|
|
316
|
+
while (component?.type === 'INSTANCE' && component.componentId) {
|
|
317
|
+
component = graph.getNode(component.componentId)
|
|
318
|
+
}
|
|
319
|
+
if (component?.type !== 'COMPONENT') return null
|
|
320
|
+
if (canEditMain && !canEditMain(component.id)) return null
|
|
321
|
+
return component
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Applies one recorded override field from an instance layer to the component layer it copies.
|
|
326
|
+
* Returns whether the field was a text pushed into a component property's default.
|
|
327
|
+
*/
|
|
328
|
+
function pushOverrideField(
|
|
329
|
+
graph: SceneGraph,
|
|
330
|
+
target: SceneNode,
|
|
331
|
+
source: SceneNode,
|
|
332
|
+
field: string
|
|
333
|
+
): boolean {
|
|
334
|
+
// A source link is bookkeeping for sync; a replaced layer is a structural edit, not a field.
|
|
335
|
+
if (field === 'sourceComponentId' || field === REPLACED_LAYER_OVERRIDE) return false
|
|
336
|
+
// Assigning a component property belongs to the instance, not to the main component.
|
|
337
|
+
if (overriddenAssignmentId(field) !== null) return false
|
|
338
|
+
const collection = overriddenVariableModeCollection(field)
|
|
339
|
+
if (collection !== null) {
|
|
340
|
+
const modes = Object.hasOwn(source.variableModes, collection)
|
|
341
|
+
? { ...target.variableModes, [collection]: source.variableModes[collection] }
|
|
342
|
+
: omit(target.variableModes, [collection])
|
|
343
|
+
graph.updateNode(target.id, { variableModes: modes })
|
|
344
|
+
return false
|
|
345
|
+
}
|
|
346
|
+
const binding = overriddenBindingField(field)
|
|
347
|
+
if (binding !== null) {
|
|
348
|
+
const bindings = Object.hasOwn(source.boundVariables, binding)
|
|
349
|
+
? {
|
|
350
|
+
...target.boundVariables,
|
|
351
|
+
[binding]: structuredClone(source.boundVariables[binding])
|
|
352
|
+
}
|
|
353
|
+
: omit(target.boundVariables, [binding])
|
|
354
|
+
graph.updateNode(target.id, { boundVariables: bindings })
|
|
355
|
+
return false
|
|
356
|
+
}
|
|
357
|
+
const value = Reflect.get(source, field)
|
|
358
|
+
if (value === undefined) return false
|
|
359
|
+
const defaulted =
|
|
360
|
+
field === 'text' && typeof value === 'string'
|
|
361
|
+
? pushBoundTextDefault(graph, target, value)
|
|
362
|
+
: false
|
|
363
|
+
graph.updateNode(target.id, { [field]: structuredClone(value) })
|
|
364
|
+
return defaulted
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The override state after a push: property values stay, but a text pushed as a default goes. */
|
|
368
|
+
function clearedAfterPush(
|
|
369
|
+
graph: SceneGraph,
|
|
370
|
+
state: InstanceOverrideState,
|
|
371
|
+
defaulted: Set<string>
|
|
372
|
+
): InstanceOverrideState {
|
|
373
|
+
const cleared = withoutEdits(graph, state)
|
|
374
|
+
const descendants = new Map(cleared.descendants)
|
|
375
|
+
for (const nodeId of defaulted) {
|
|
376
|
+
const fields = descendants.get(nodeId)
|
|
377
|
+
if (!fields) continue
|
|
378
|
+
fields.delete('text')
|
|
379
|
+
if (fields.size === 0) descendants.delete(nodeId)
|
|
380
|
+
}
|
|
381
|
+
return { self: cleared.self, descendants }
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* A text layer bound to a text property shows the property's default on the main component.
|
|
386
|
+
* Pushing the edit moves that default with it, so the canvas and the property panel agree.
|
|
387
|
+
* Returns whether the field was pushed as a default.
|
|
388
|
+
*/
|
|
389
|
+
function pushBoundTextDefault(graph: SceneGraph, target: SceneNode, text: string): boolean {
|
|
390
|
+
const propertyId = target.componentPropertyReferences.find(
|
|
391
|
+
(reference) => reference.field === 'TEXT'
|
|
392
|
+
)?.propertyId
|
|
393
|
+
if (!propertyId) return false
|
|
394
|
+
const owner = graph.closest(
|
|
395
|
+
target.parentId ?? target.id,
|
|
396
|
+
(node) =>
|
|
397
|
+
(node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') &&
|
|
398
|
+
node.componentPropertyDefinitions.some((definition) => definition.id === propertyId)
|
|
399
|
+
)
|
|
400
|
+
const definition = owner?.componentPropertyDefinitions.find((item) => item.id === propertyId)
|
|
401
|
+
if (!owner || !definition) return false
|
|
402
|
+
if (definition.defaultValue !== text)
|
|
403
|
+
graph.updateNode(owner.id, {
|
|
404
|
+
componentPropertyDefinitions: owner.componentPropertyDefinitions.map((item) =>
|
|
405
|
+
item.id === propertyId ? { ...item, defaultValue: text } : item
|
|
406
|
+
)
|
|
407
|
+
})
|
|
408
|
+
// Every other definition layer the property drives follows the new default, as editing the
|
|
409
|
+
// default does. A nested instance's copies belong to their own component and are left to sync.
|
|
410
|
+
const visit = (node: SceneNode): void => {
|
|
411
|
+
for (const child of graph.getChildren(node.id)) {
|
|
412
|
+
if (child.type === 'INSTANCE') continue
|
|
413
|
+
if (
|
|
414
|
+
child.type === 'TEXT' &&
|
|
415
|
+
child.componentPropertyReferences.some(
|
|
416
|
+
(reference) => reference.propertyId === propertyId && reference.field === 'TEXT'
|
|
417
|
+
)
|
|
418
|
+
)
|
|
419
|
+
graph.updateNode(child.id, { text })
|
|
420
|
+
visit(child)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
visit(owner)
|
|
424
|
+
return true
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Whether pushing `root`'s changes can reach every main component they belong to. Pushing is
|
|
429
|
+
* refused for a library component, whose main is read-only.
|
|
430
|
+
*/
|
|
431
|
+
export function canPushInstanceOverrides(
|
|
432
|
+
graph: SceneGraph,
|
|
433
|
+
root: SceneNode,
|
|
434
|
+
canEditMain?: (componentId: string) => boolean
|
|
435
|
+
): boolean {
|
|
436
|
+
if (root.type !== 'INSTANCE') return false
|
|
437
|
+
let found = false
|
|
438
|
+
for (const instance of instancesDeepestFirst(graph, root)) {
|
|
439
|
+
if (
|
|
440
|
+
instance.instanceOverrides.self.size === 0 &&
|
|
441
|
+
instance.instanceOverrides.descendants.size === 0
|
|
442
|
+
)
|
|
443
|
+
continue
|
|
444
|
+
if (!pushableMainComponent(graph, instance, canEditMain)) return false
|
|
445
|
+
found = true
|
|
446
|
+
}
|
|
447
|
+
return found
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Figma's Push changes to main component: writes the edits of `root` and the instances inside
|
|
452
|
+
* it to their own main components, then clears those edits so every instance follows. A
|
|
453
|
+
* nested instance's edits go to its nested main; the outer main then picks them up by sync.
|
|
454
|
+
* Returns false, changing nothing, when a main component is missing or read-only.
|
|
455
|
+
*/
|
|
456
|
+
export function pushInstanceOverrides(
|
|
457
|
+
graph: SceneGraph,
|
|
458
|
+
root: SceneNode,
|
|
459
|
+
canEditMain?: (componentId: string) => boolean
|
|
460
|
+
): boolean {
|
|
461
|
+
if (!canPushInstanceOverrides(graph, root, canEditMain)) return false
|
|
462
|
+
const instances = instancesDeepestFirst(graph, root).filter(
|
|
463
|
+
(instance) =>
|
|
464
|
+
instance.instanceOverrides.self.size > 0 || instance.instanceOverrides.descendants.size > 0
|
|
465
|
+
)
|
|
466
|
+
const components: string[] = []
|
|
467
|
+
const defaulted = new Set<string>()
|
|
468
|
+
for (const instance of instances) {
|
|
469
|
+
const main = pushableMainComponent(graph, instance, canEditMain)
|
|
470
|
+
if (!main) return false
|
|
471
|
+
if (!components.includes(main.id)) components.push(main.id)
|
|
472
|
+
const state = instance.instanceOverrides
|
|
473
|
+
for (const [field] of state.self) {
|
|
474
|
+
pushOverrideField(graph, main, instance, field)
|
|
475
|
+
}
|
|
476
|
+
for (const [nodeId, fields] of state.descendants) {
|
|
477
|
+
const node = graph.getNode(nodeId)
|
|
478
|
+
if (!node) continue
|
|
479
|
+
const owner = node.parentId ? findInstanceAncestor(graph, node.parentId) : undefined
|
|
480
|
+
const target = componentLayer(graph, node, owner)
|
|
481
|
+
if (!target) continue
|
|
482
|
+
for (const [field] of fields) {
|
|
483
|
+
if (pushOverrideField(graph, target, node, field)) defaulted.add(nodeId)
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
for (const instance of instances) {
|
|
488
|
+
graph.updateNode(instance.id, {
|
|
489
|
+
instanceOverrides: clearedAfterPush(graph, instance.instanceOverrides, defaulted)
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
// Deepest main first, then every component holding an instance of one: an outer main syncs
|
|
493
|
+
// the nested instance the inner main changed, and so on up to the page.
|
|
494
|
+
graph.syncInstancesTogether(followingComponents(graph, components))
|
|
495
|
+
return true
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** The pushed mains and every component whose instances show one of them, deepest first. */
|
|
499
|
+
function followingComponents(graph: SceneGraph, components: string[]): string[] {
|
|
500
|
+
const order: string[] = []
|
|
501
|
+
const seen = new Set<string>()
|
|
502
|
+
const visit = (id: string): void => {
|
|
503
|
+
if (seen.has(id)) return
|
|
504
|
+
seen.add(id)
|
|
505
|
+
order.push(id)
|
|
506
|
+
for (const instance of graph.getInstances(id)) {
|
|
507
|
+
const holder = instance.parentId
|
|
508
|
+
? graph.closest(instance.parentId, (node) => node.type === 'COMPONENT')
|
|
509
|
+
: undefined
|
|
510
|
+
if (holder) visit(holder.id)
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
for (const id of components) visit(id)
|
|
514
|
+
return order
|
|
515
|
+
}
|
|
516
|
+
|
|
225
517
|
/**
|
|
226
518
|
* Figma's `resetOverrides`: the instance and every instance inside it go back to their
|
|
227
519
|
* components, keeping the values their component properties set.
|