@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { assertNodeEditable, getNodeEditCapability } from "../capabilities.js";
|
|
2
|
+
import { VariationError, variationPickProblem, variationToPick } from "@pairdraw/scene-graph/variations";
|
|
3
|
+
//#region src/editor/variations/pick.ts
|
|
4
|
+
/** Why `versionId` cannot replace the original of `view`, or null when it can. */
|
|
5
|
+
function pickProblemOf(graph, view, versionId) {
|
|
6
|
+
const problem = variationPickProblem(graph, view, versionId);
|
|
7
|
+
if (problem || !view.original) return problem;
|
|
8
|
+
return getNodeEditCapability(graph, view.original.id).editable ? null : "original-not-editable";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Throws the reason `versionId` cannot replace its original, before anything changes: a layer
|
|
12
|
+
* outside a set, the section itself, or an original that is gone, locked, inside an instance,
|
|
13
|
+
* of another type than the version, or owned by a library.
|
|
14
|
+
*/
|
|
15
|
+
function assertVariationPickable(graph, versionId) {
|
|
16
|
+
const { view, problem } = variationToPick(graph, versionId);
|
|
17
|
+
if (problem) throw new VariationError(problem, versionId);
|
|
18
|
+
if (view.original) assertNodeEditable(graph, view.original.id);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { assertVariationPickable, pickProblemOf };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=pick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.js","names":[],"sources":["../../../src/editor/variations/pick.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n VariationError,\n variationPickProblem,\n variationToPick,\n type VariationPickProblem,\n type VariationSetView\n} from '@pairdraw/scene-graph/variations'\n\nimport { assertNodeEditable, getNodeEditCapability } from '#core/editor/capabilities'\n\n/** Why a version cannot replace its original, including an original a library owns. */\nexport type PickProblem = VariationPickProblem | 'original-not-editable'\n\n/** Why `versionId` cannot replace the original of `view`, or null when it can. */\nexport function pickProblemOf(\n graph: SceneGraph,\n view: VariationSetView,\n versionId: string\n): PickProblem | null {\n const problem = variationPickProblem(graph, view, versionId)\n if (problem || !view.original) return problem\n return getNodeEditCapability(graph, view.original.id).editable ? null : 'original-not-editable'\n}\n\n/**\n * Throws the reason `versionId` cannot replace its original, before anything changes: a layer\n * outside a set, the section itself, or an original that is gone, locked, inside an instance,\n * of another type than the version, or owned by a library.\n */\nexport function assertVariationPickable(graph: SceneGraph, versionId: string): void {\n const { view, problem } = variationToPick(graph, versionId)\n if (problem) throw new VariationError(problem, versionId)\n if (view.original) assertNodeEditable(graph, view.original.id)\n}\n"],"mappings":";;;;AAeA,SAAgB,cACd,OACA,MACA,WACoB;CACpB,MAAM,UAAU,qBAAqB,OAAO,MAAM,SAAS;CAC3D,IAAI,WAAW,CAAC,KAAK,UAAU,OAAO;CACtC,OAAO,sBAAsB,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,WAAW,OAAO;AAC1E;;;;;;AAOA,SAAgB,wBAAwB,OAAmB,WAAyB;CAClF,MAAM,EAAE,MAAM,YAAY,gBAAgB,OAAO,SAAS;CAC1D,IAAI,SAAS,MAAM,IAAI,eAAe,SAAS,SAAS;CACxD,IAAI,KAAK,UAAU,mBAAmB,OAAO,KAAK,SAAS,EAAE;AAC/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EditorContext } from "./types.js";
|
|
2
|
+
import { CreatedVariations, VariationRequest } from "./variations/create.js";
|
|
3
|
+
import { PickProblem } from "./variations/pick.js";
|
|
4
|
+
import { VariationSetView } from "@pairdraw/scene-graph/variations";
|
|
5
|
+
//#region src/editor/variations.d.ts
|
|
6
|
+
/** A set of variations as panels show it, from wherever in it the selection is. */
|
|
7
|
+
interface VariationSetState extends VariationSetView {
|
|
8
|
+
/** The version holding the layer asked about, or null for the section itself. */
|
|
9
|
+
version: VariationSetView['versions'][number] | null;
|
|
10
|
+
/** Why that version cannot replace the original, or null when it can. */
|
|
11
|
+
pickProblem: PickProblem | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sets of variations: copies of a layer side by side in a section beside it, one of which can
|
|
15
|
+
* replace it. Each command is one undo step.
|
|
16
|
+
*/
|
|
17
|
+
declare function createVariationActions(ctx: EditorContext): {
|
|
18
|
+
getVariationSet: (nodeId: string) => VariationSetState | null;
|
|
19
|
+
isVariationOriginalChanged: (nodeId: string) => boolean;
|
|
20
|
+
canCreateVariations: (nodeId: string) => boolean;
|
|
21
|
+
createVariations: (nodeId: string, request: VariationRequest) => CreatedVariations;
|
|
22
|
+
duplicateAsVariation: (nodeId: string) => CreatedVariations;
|
|
23
|
+
pickVariation: (versionId: string) => string;
|
|
24
|
+
discardVariations: (nodeId: string) => string | null;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { VariationSetState, createVariationActions };
|
|
28
|
+
//# sourceMappingURL=variations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variations.d.ts","names":[],"sources":["../../src/editor/variations.ts"],"mappings":";;;;;;UAoBiB,0BAA0B;;EAEzC,SAAS;;EAET,aAAa;;;;;;iBAOC,uBAAuB,KAAK;EAET,kBAAA,mBAAS;EAgBE,6BAAA;EAMP,sBAAA;EAKD,mBAAA,gBAAM,SAAW,qBAAmB;EASlC,uBAAA,mBAAS;EAOb,gBAAA;EAaC,oBAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { recordEdit } from "./history/edit.js";
|
|
2
|
+
import { createVariations, variationRefusal } from "./variations/create.js";
|
|
3
|
+
import { assertVariationPickable, pickProblemOf } from "./variations/pick.js";
|
|
4
|
+
import { applyVariation, discardVariations, originalChangedSince, variationSetOf, versionOf } from "@pairdraw/scene-graph/variations";
|
|
5
|
+
//#region src/editor/variations.ts
|
|
6
|
+
/**
|
|
7
|
+
* Sets of variations: copies of a layer side by side in a section beside it, one of which can
|
|
8
|
+
* replace it. Each command is one undo step.
|
|
9
|
+
*/
|
|
10
|
+
function createVariationActions(ctx) {
|
|
11
|
+
/** The set `nodeId` belongs to, with the version holding it, or null outside every set. */
|
|
12
|
+
function getVariationSet(nodeId) {
|
|
13
|
+
const view = variationSetOf(ctx.graph, nodeId);
|
|
14
|
+
if (!view) return null;
|
|
15
|
+
const version = versionOf(ctx.graph, view, nodeId);
|
|
16
|
+
return {
|
|
17
|
+
...view,
|
|
18
|
+
version,
|
|
19
|
+
pickProblem: version ? pickProblemOf(ctx.graph, view, version.id) : "not-a-version"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the original of the set holding `nodeId` looks different from when its newest
|
|
24
|
+
* versions were made. It walks the original's layers, so panels ask when they show a set
|
|
25
|
+
* rather than on every edit.
|
|
26
|
+
*/
|
|
27
|
+
function isVariationOriginalChanged(nodeId) {
|
|
28
|
+
const view = variationSetOf(ctx.graph, nodeId);
|
|
29
|
+
return view ? originalChangedSince(ctx.graph, view) : false;
|
|
30
|
+
}
|
|
31
|
+
/** Whether `nodeId` can be varied: copied into a set of variations beside it. */
|
|
32
|
+
function canCreateVariations(nodeId) {
|
|
33
|
+
return variationRefusal(ctx.graph, nodeId) === null;
|
|
34
|
+
}
|
|
35
|
+
/** Copies `nodeId` into its set of variations, as `create_variations` does. */
|
|
36
|
+
function createVariationsOf(nodeId, request) {
|
|
37
|
+
const created = recordEdit(ctx, {
|
|
38
|
+
label: "Create variations",
|
|
39
|
+
rollbackOnThrow: true
|
|
40
|
+
}, () => createVariations(ctx.graph, nodeId, request));
|
|
41
|
+
ctx.requestRender();
|
|
42
|
+
return created;
|
|
43
|
+
}
|
|
44
|
+
/** One plain copy of `nodeId` in its set, selected, for a person to change by hand. */
|
|
45
|
+
function duplicateAsVariation(nodeId) {
|
|
46
|
+
const created = createVariationsOf(nodeId, { count: 1 });
|
|
47
|
+
ctx.setSelectedIds(new Set(created.versions.map((version) => version.id)));
|
|
48
|
+
return created;
|
|
49
|
+
}
|
|
50
|
+
/** Makes the original look like the version holding `versionId` and removes the set. */
|
|
51
|
+
function pickVariation(versionId) {
|
|
52
|
+
assertVariationPickable(ctx.graph, versionId);
|
|
53
|
+
const originalId = recordEdit(ctx, {
|
|
54
|
+
label: "Use variation",
|
|
55
|
+
rollbackOnThrow: true
|
|
56
|
+
}, () => {
|
|
57
|
+
const picked = applyVariation(ctx.graph, versionId);
|
|
58
|
+
ctx.runLayoutForNode(picked.originalId);
|
|
59
|
+
return picked.originalId;
|
|
60
|
+
});
|
|
61
|
+
ctx.setSelectedIds(/* @__PURE__ */ new Set([originalId]));
|
|
62
|
+
ctx.requestRender();
|
|
63
|
+
return originalId;
|
|
64
|
+
}
|
|
65
|
+
/** Removes the set holding `nodeId` and selects its original, when it is still there. */
|
|
66
|
+
function discardVariations$1(nodeId) {
|
|
67
|
+
const { originalId } = recordEdit(ctx, {
|
|
68
|
+
label: "Discard variations",
|
|
69
|
+
rollbackOnThrow: true
|
|
70
|
+
}, () => discardVariations(ctx.graph, nodeId));
|
|
71
|
+
ctx.setSelectedIds(new Set(originalId ? [originalId] : []));
|
|
72
|
+
ctx.requestRender();
|
|
73
|
+
return originalId;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
getVariationSet,
|
|
77
|
+
isVariationOriginalChanged,
|
|
78
|
+
canCreateVariations,
|
|
79
|
+
createVariations: createVariationsOf,
|
|
80
|
+
duplicateAsVariation,
|
|
81
|
+
pickVariation,
|
|
82
|
+
discardVariations: discardVariations$1
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createVariationActions };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variations.js","names":["discardVariations","discardVariationSet"],"sources":["../../src/editor/variations.ts"],"sourcesContent":["import {\n applyVariation,\n discardVariations as discardVariationSet,\n originalChangedSince,\n variationSetOf,\n versionOf,\n type VariationSetView\n} from '@pairdraw/scene-graph/variations'\n\nimport { recordEdit } from './history/edit'\nimport type { EditorContext } from './types'\nimport {\n createVariations,\n variationRefusal,\n type CreatedVariations,\n type VariationRequest\n} from './variations/create'\nimport { assertVariationPickable, pickProblemOf, type PickProblem } from './variations/pick'\n\n/** A set of variations as panels show it, from wherever in it the selection is. */\nexport interface VariationSetState extends VariationSetView {\n /** The version holding the layer asked about, or null for the section itself. */\n version: VariationSetView['versions'][number] | null\n /** Why that version cannot replace the original, or null when it can. */\n pickProblem: PickProblem | null\n}\n\n/**\n * Sets of variations: copies of a layer side by side in a section beside it, one of which can\n * replace it. Each command is one undo step.\n */\nexport function createVariationActions(ctx: EditorContext) {\n /** The set `nodeId` belongs to, with the version holding it, or null outside every set. */\n function getVariationSet(nodeId: string): VariationSetState | null {\n const view = variationSetOf(ctx.graph, nodeId)\n if (!view) return null\n const version = versionOf(ctx.graph, view, nodeId)\n return {\n ...view,\n version,\n pickProblem: version ? pickProblemOf(ctx.graph, view, version.id) : 'not-a-version'\n }\n }\n\n /**\n * Whether the original of the set holding `nodeId` looks different from when its newest\n * versions were made. It walks the original's layers, so panels ask when they show a set\n * rather than on every edit.\n */\n function isVariationOriginalChanged(nodeId: string): boolean {\n const view = variationSetOf(ctx.graph, nodeId)\n return view ? originalChangedSince(ctx.graph, view) : false\n }\n\n /** Whether `nodeId` can be varied: copied into a set of variations beside it. */\n function canCreateVariations(nodeId: string): boolean {\n return variationRefusal(ctx.graph, nodeId) === null\n }\n\n /** Copies `nodeId` into its set of variations, as `create_variations` does. */\n function createVariationsOf(nodeId: string, request: VariationRequest): CreatedVariations {\n const created = recordEdit(ctx, { label: 'Create variations', rollbackOnThrow: true }, () =>\n createVariations(ctx.graph, nodeId, request)\n )\n ctx.requestRender()\n return created\n }\n\n /** One plain copy of `nodeId` in its set, selected, for a person to change by hand. */\n function duplicateAsVariation(nodeId: string): CreatedVariations {\n const created = createVariationsOf(nodeId, { count: 1 })\n ctx.setSelectedIds(new Set(created.versions.map((version) => version.id)))\n return created\n }\n\n /** Makes the original look like the version holding `versionId` and removes the set. */\n function pickVariation(versionId: string): string {\n assertVariationPickable(ctx.graph, versionId)\n const originalId = recordEdit(ctx, { label: 'Use variation', rollbackOnThrow: true }, () => {\n const picked = applyVariation(ctx.graph, versionId)\n ctx.runLayoutForNode(picked.originalId)\n return picked.originalId\n })\n ctx.setSelectedIds(new Set([originalId]))\n ctx.requestRender()\n return originalId\n }\n\n /** Removes the set holding `nodeId` and selects its original, when it is still there. */\n function discardVariations(nodeId: string): string | null {\n const { originalId } = recordEdit(\n ctx,\n { label: 'Discard variations', rollbackOnThrow: true },\n () => discardVariationSet(ctx.graph, nodeId)\n )\n ctx.setSelectedIds(new Set(originalId ? [originalId] : []))\n ctx.requestRender()\n return originalId\n }\n\n return {\n getVariationSet,\n isVariationOriginalChanged,\n canCreateVariations,\n createVariations: createVariationsOf,\n duplicateAsVariation,\n pickVariation,\n discardVariations\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,uBAAuB,KAAoB;;CAEzD,SAAS,gBAAgB,QAA0C;EACjE,MAAM,OAAO,eAAe,IAAI,OAAO,MAAM;EAC7C,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,UAAU,UAAU,IAAI,OAAO,MAAM,MAAM;EACjD,OAAO;GACL,GAAG;GACH;GACA,aAAa,UAAU,cAAc,IAAI,OAAO,MAAM,QAAQ,EAAE,IAAI;EACtE;CACF;;;;;;CAOA,SAAS,2BAA2B,QAAyB;EAC3D,MAAM,OAAO,eAAe,IAAI,OAAO,MAAM;EAC7C,OAAO,OAAO,qBAAqB,IAAI,OAAO,IAAI,IAAI;CACxD;;CAGA,SAAS,oBAAoB,QAAyB;EACpD,OAAO,iBAAiB,IAAI,OAAO,MAAM,MAAM;CACjD;;CAGA,SAAS,mBAAmB,QAAgB,SAA8C;EACxF,MAAM,UAAU,WAAW,KAAK;GAAE,OAAO;GAAqB,iBAAiB;EAAK,SAClF,iBAAiB,IAAI,OAAO,QAAQ,OAAO,CAC7C;EACA,IAAI,cAAc;EAClB,OAAO;CACT;;CAGA,SAAS,qBAAqB,QAAmC;EAC/D,MAAM,UAAU,mBAAmB,QAAQ,EAAE,OAAO,EAAE,CAAC;EACvD,IAAI,eAAe,IAAI,IAAI,QAAQ,SAAS,KAAK,YAAY,QAAQ,EAAE,CAAC,CAAC;EACzE,OAAO;CACT;;CAGA,SAAS,cAAc,WAA2B;EAChD,wBAAwB,IAAI,OAAO,SAAS;EAC5C,MAAM,aAAa,WAAW,KAAK;GAAE,OAAO;GAAiB,iBAAiB;EAAK,SAAS;GAC1F,MAAM,SAAS,eAAe,IAAI,OAAO,SAAS;GAClD,IAAI,iBAAiB,OAAO,UAAU;GACtC,OAAO,OAAO;EAChB,CAAC;EACD,IAAI,+BAAe,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;EACxC,IAAI,cAAc;EAClB,OAAO;CACT;;CAGA,SAASA,oBAAkB,QAA+B;EACxD,MAAM,EAAE,eAAe,WACrB,KACA;GAAE,OAAO;GAAsB,iBAAiB;EAAK,SAC/CC,kBAAoB,IAAI,OAAO,MAAM,CAC7C;EACA,IAAI,eAAe,IAAI,IAAI,aAAa,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;EAC1D,IAAI,cAAc;EAClB,OAAO;CACT;CAEA,OAAO;EACL;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA,mBAAA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"mappings":";;;;;;;iBAYgB,yBAAyB,mBAAmB,WAAW"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { graph, raw, updateNode } from "../accessor-utils.js";
|
|
2
2
|
import { parseFigmaReactions, toFigmaReaction } from "../reactions.js";
|
|
3
|
+
import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
|
|
3
4
|
//#region src/figma-api/accessors/reactions.ts
|
|
4
5
|
/**
|
|
5
6
|
* `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's
|
|
@@ -18,8 +19,10 @@ function installReactionAccessors(prototype, internals) {
|
|
|
18
19
|
const previous = node.prototypeReactions;
|
|
19
20
|
updateNode(this, internals, { prototypeReactions: parseFigmaReactions(value, {
|
|
20
21
|
graph: sceneGraph,
|
|
22
|
+
nodeId: node.id,
|
|
21
23
|
pageId,
|
|
22
|
-
previous
|
|
24
|
+
previous,
|
|
25
|
+
inherited: node.type === "INSTANCE" ? instanceMainComponent(sceneGraph, node)?.prototypeReactions : void 0
|
|
23
26
|
}) });
|
|
24
27
|
}
|
|
25
28
|
} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"sourcesContent":["import type { PrototypeReaction } from '@pairdraw/scene-graph'\n\nimport type { NodeProxyInternals, ProxyThis } from '#core/figma-api/accessor-utils'\nimport { graph, raw, updateNode } from '#core/figma-api/accessor-utils'\nimport { parseFigmaReactions, toFigmaReaction, type FigmaReaction } from '#core/figma-api/reactions'\n\n/**\n * `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's\n * `prototypeReactions`; a write goes through the same validation as the tool, so a trigger,\n * action, transition, navigation or destination the play cannot show is refused.\n */\nexport function installReactionAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n reactions: {\n get(this: ProxyThis): readonly FigmaReaction[] {\n return Object.freeze(raw(this, internals).prototypeReactions.map(toFigmaReaction))\n },\n set(this: ProxyThis, value: readonly FigmaReaction[]) {\n const node = raw(this, internals)\n const sceneGraph = graph(this, internals)\n const pageId = sceneGraph.pageOf(node.id) ?? ''\n const previous: readonly PrototypeReaction[] = node.prototypeReactions\n updateNode(this, internals, {\n prototypeReactions: parseFigmaReactions(value, {
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"sourcesContent":["import type { PrototypeReaction } from '@pairdraw/scene-graph'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\n\nimport type { NodeProxyInternals, ProxyThis } from '#core/figma-api/accessor-utils'\nimport { graph, raw, updateNode } from '#core/figma-api/accessor-utils'\nimport { parseFigmaReactions, toFigmaReaction, type FigmaReaction } from '#core/figma-api/reactions'\n\n/**\n * `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's\n * `prototypeReactions`; a write goes through the same validation as the tool, so a trigger,\n * action, transition, navigation or destination the play cannot show is refused.\n */\nexport function installReactionAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n reactions: {\n get(this: ProxyThis): readonly FigmaReaction[] {\n return Object.freeze(raw(this, internals).prototypeReactions.map(toFigmaReaction))\n },\n set(this: ProxyThis, value: readonly FigmaReaction[]) {\n const node = raw(this, internals)\n const sceneGraph = graph(this, internals)\n const pageId = sceneGraph.pageOf(node.id) ?? ''\n const previous: readonly PrototypeReaction[] = node.prototypeReactions\n updateNode(this, internals, {\n prototypeReactions: parseFigmaReactions(value, {\n graph: sceneGraph,\n nodeId: node.id,\n pageId,\n previous,\n inherited:\n node.type === 'INSTANCE'\n ? instanceMainComponent(sceneGraph, node)?.prototypeReactions\n : undefined\n })\n })\n }\n }\n })\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,yBAAyB,WAAmB,WAAqC;CAC/F,OAAO,iBAAiB,WAAW,EACjC,WAAW;EACT,MAA+C;GAC7C,OAAO,OAAO,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC,mBAAmB,IAAI,eAAe,CAAC;EACnF;EACA,IAAqB,OAAiC;GACpD,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,aAAa,MAAM,MAAM,SAAS;GACxC,MAAM,SAAS,WAAW,OAAO,KAAK,EAAE,KAAK;GAC7C,MAAM,WAAyC,KAAK;GACpD,WAAW,MAAM,WAAW,EAC1B,oBAAoB,oBAAoB,OAAO;IAC7C,OAAO;IACP,QAAQ,KAAK;IACb;IACA;IACA,WACE,KAAK,SAAS,aACV,sBAAsB,YAAY,IAAI,CAAC,EAAE,qBACzC,KAAA;GACR,CAAC,EACH,CAAC;EACH;CACF,EACF,CAAC;AACH"}
|
|
@@ -111,6 +111,9 @@ function installTextNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
textDecoration: characterStyle(internals, "textDecoration", mixed, (_node, textDecoration) => ({ textDecoration })),
|
|
114
|
+
openTypeFeatures: { get() {
|
|
115
|
+
return getTextStyle(raw(this, internals), "openTypeFeatures", mixed);
|
|
116
|
+
} },
|
|
114
117
|
maxLines: field(internals, "maxLines"),
|
|
115
118
|
listSpacing: spacing(internals, "listSpacing", mixed),
|
|
116
119
|
paragraphSpacing: spacing(internals, "paragraphSpacing", mixed),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport { renameTextLayer } from '#core/editor/text/name'\nimport {\n graph,\n nodeId,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport {\n assertFontLoaded,\n assertTextFontsLoaded,\n textHasMissingFont\n} from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n // A text layer that was never renamed follows its characters, as in Figma.\n renameTextLayer(graph(this, internals), nodeId(this, internals), value)\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n hasMissingFont: {\n get(this: ProxyThis): boolean {\n return textHasMissingFont(raw(this, internals))\n }\n },\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":";;;;;;;;;;;;;AA0CA,SAAS,QAAQ,WAA+B,MAAiC,OAAe;CAC9F,OAAO;EACL,MAAsC;GACpC,OAAO,oBAAoB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;EAC9D;EACA,IAAqB,OAAe;GAClC,MAAM,UAAU,eAAe,KAAK;GACpC,IAAI,SACF,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,KAAK,uBAAuB,SAAS;GAEpF,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzD,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AACF;;;;;;AAOA,SAAS,eACP,WAC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KAAK;EAC5D,aAAa,MAAM,WAAW,aAAa;EAC3C,gBAAgB,MAAM,WAAW,gBAAgB;EACjD,YAAY,MAAM,WAAW,cAAc,KAAK;CAClD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport { renameTextLayer } from '#core/editor/text/name'\nimport {\n graph,\n nodeId,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport {\n assertFontLoaded,\n assertTextFontsLoaded,\n textHasMissingFont\n} from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n // A text layer that was never renamed follows its characters, as in Figma.\n renameTextLayer(graph(this, internals), nodeId(this, internals), value)\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n hasMissingFont: {\n get(this: ProxyThis): boolean {\n return textHasMissingFont(raw(this, internals))\n }\n },\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n // Figma reads a text's explicitly set OpenType features; it has no setter for them, so\n // this one is read-only and `pairdraw.setFontFeatures` writes them.\n openTypeFeatures: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'openTypeFeatures', mixed)\n }\n },\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":";;;;;;;;;;;;;AA0CA,SAAS,QAAQ,WAA+B,MAAiC,OAAe;CAC9F,OAAO;EACL,MAAsC;GACpC,OAAO,oBAAoB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;EAC9D;EACA,IAAqB,OAAe;GAClC,MAAM,UAAU,eAAe,KAAK;GACpC,IAAI,SACF,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,KAAK,uBAAuB,SAAS;GAEpF,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzD,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AACF;;;;;;AAOA,SAAS,eACP,WACA,OACA,OACA,SACA,aAAa,MACb;CACA,OAAO;EACL,MAA8B;GAC5B,OAAO,aAAa,IAAI,MAAM,SAAS,GAAG,OAAO,KAAK;EACxD;EACA,IAAqB,OAAU;GAC7B,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,QAAQ,QAAQ,MAAM,KAAK;GACjC,IAAI,YAAY,sBAAsB,OAAO,SAAS,IAAI;GAC1D,WAAW,MAAM,WAAW,iBAAiB,MAAM,KAAK,CAAC;EAC3D;CACF;AACF;;;;;AAMA,SAAS,MACP,WACA,MACA,aAAa,MACb;CACA,OAAO;EACL,MAAuC;GACrC,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAyB;GAC5C,IAAI,YAAY,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzE,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AAC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E,YAAY,gBAAgB,KAAK,EAAE,EAC1D;EACA,UAAU,eAAyB,WAAW,YAAY,QAAQ,OAAO,cAAc,EACrF,SACF,EAAE;EACF,WAAW;GACT,MAA8B;IAC5B,OAAO,aAAa,IAAI,MAAM,SAAS,GAAG,aAAa,KAAK;GAC9D;GACA,IAAqB,OAA+B;IAClD,MAAM,OAAO,IAAI,MAAM,SAAS;IAChC,MAAM,YAAY,gBAAgB,iBAAiB,OAAO,MAAM,MAAM,SAAS,CAAC;IAChF,MAAM,YAAY,mBAAmB,MAAM,GAAG,KAAK,KAAK,QAAQ,EAAE,UAAU,CAAC;IAC7E,WAAW,MAAM,WAAW,EAAE,UAAU,CAAC;GAC3C;EACF;EACA,gBAAgB,eACd,WACA,kBACA,QACC,OAAO,oBAAoB,EAAE,eAAe,EAC/C;EAGA,kBAAkB,EAChB,MAA8B;GAC5B,OAAO,aAAa,IAAI,MAAM,SAAS,GAAG,oBAAoB,KAAK;EACrE,EACF;EACA,UAAU,MAAM,WAAW,UAAU;EACrC,aAAa,QAAQ,WAAW,eAAe,KAAK;EACpD,kBAAkB,QAAQ,WAAW,oBAAoB,KAAK;EAC9D,iBAAiB,QAAQ,WAAW,mBAAmB,KAAK;EAC5D,aAAa,MAAM,WAAW,aAAa;EAC3C,gBAAgB,MAAM,WAAW,gBAAgB;EACjD,YAAY,MAAM,WAAW,cAAc,KAAK;CAClD,CAAC;AACH"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/figma-api/accessors/text/opentype.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The style patch a range's OpenType features take: the features its characters already had,
|
|
5
|
+
* with the given tags replacing their own entries, as setRangeFontName keeps the axes it does
|
|
6
|
+
* not name. A non-boolean value is refused before anything changes. Figma's plugin API has no
|
|
7
|
+
* range feature setter, so `pairdraw.setRangeFontFeatures` applies this patch.
|
|
8
|
+
*/
|
|
9
|
+
declare function openTypeFeaturesPatch(method: string, node: SceneNode, start: number, value: unknown): {
|
|
10
|
+
fontFeatures: Array<{
|
|
11
|
+
tag: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { openTypeFeaturesPatch };
|
|
17
|
+
//# sourceMappingURL=opentype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentype.d.ts","names":[],"sources":["../../../../src/figma-api/accessors/text/opentype.ts"],"mappings":";;;;;;;;iBAYgB,sBACd,gBACA,MAAM,WACN,eACA;EACG,cAAc;IAAQ;IAAa"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { characterStyles } from "../../../text/character-style.js";
|
|
2
|
+
import { invalid, received } from "./messages.js";
|
|
3
|
+
//#region src/figma-api/accessors/text/opentype.ts
|
|
4
|
+
/**
|
|
5
|
+
* The style patch a range's OpenType features take: the features its characters already had,
|
|
6
|
+
* with the given tags replacing their own entries, as setRangeFontName keeps the axes it does
|
|
7
|
+
* not name. A non-boolean value is refused before anything changes. Figma's plugin API has no
|
|
8
|
+
* range feature setter, so `pairdraw.setRangeFontFeatures` applies this patch.
|
|
9
|
+
*/
|
|
10
|
+
function openTypeFeaturesPatch(method, node, start, value) {
|
|
11
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw invalid(method, `Expected object, received ${received(value)}`);
|
|
12
|
+
const features = {};
|
|
13
|
+
for (const [tag, enabled] of Object.entries(value)) {
|
|
14
|
+
if (typeof enabled !== "boolean") throw invalid(method, `Expected boolean at .${tag}, received ${received(enabled)}`);
|
|
15
|
+
features[tag.toUpperCase()] = enabled;
|
|
16
|
+
}
|
|
17
|
+
const [first] = characterStyles(node, start, start + 1);
|
|
18
|
+
const merged = new Map(first.fontFeatures.map((feature) => [feature.tag, feature.enabled]));
|
|
19
|
+
for (const [tag, enabled] of Object.entries(features)) merged.set(tag, enabled);
|
|
20
|
+
return { fontFeatures: [...merged].map(([tag, enabled]) => ({
|
|
21
|
+
tag,
|
|
22
|
+
enabled
|
|
23
|
+
})) };
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { openTypeFeaturesPatch };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=opentype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentype.js","names":[],"sources":["../../../../src/figma-api/accessors/text/opentype.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { characterStyles } from '#core/text/character-style'\n\nimport { invalid, received } from './messages'\n\n/**\n * The style patch a range's OpenType features take: the features its characters already had,\n * with the given tags replacing their own entries, as setRangeFontName keeps the axes it does\n * not name. A non-boolean value is refused before anything changes. Figma's plugin API has no\n * range feature setter, so `pairdraw.setRangeFontFeatures` applies this patch.\n */\nexport function openTypeFeaturesPatch(\n method: string,\n node: SceneNode,\n start: number,\n value: unknown\n): { fontFeatures: Array<{ tag: string; enabled: boolean }> } {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n throw invalid(method, `Expected object, received ${received(value)}`)\n }\n const features: Record<string, boolean> = {}\n for (const [tag, enabled] of Object.entries(value)) {\n if (typeof enabled !== 'boolean') {\n throw invalid(method, `Expected boolean at .${tag}, received ${received(enabled)}`)\n }\n features[tag.toUpperCase()] = enabled\n }\n const [first] = characterStyles(node, start, start + 1)\n const merged = new Map(first.fontFeatures.map((feature) => [feature.tag, feature.enabled]))\n for (const [tag, enabled] of Object.entries(features)) merged.set(tag, enabled)\n return { fontFeatures: [...merged].map(([tag, enabled]) => ({ tag, enabled })) }\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,sBACd,QACA,MACA,OACA,OAC4D;CAC5D,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GACpE,MAAM,QAAQ,QAAQ,6BAA6B,SAAS,KAAK,GAAG;CAEtE,MAAM,WAAoC,CAAC;CAC3C,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,KAAK,GAAG;EAClD,IAAI,OAAO,YAAY,WACrB,MAAM,QAAQ,QAAQ,wBAAwB,IAAI,aAAa,SAAS,OAAO,GAAG;EAEpF,SAAS,IAAI,YAAY,KAAK;CAChC;CACA,MAAM,CAAC,SAAS,gBAAgB,MAAM,OAAO,QAAQ,CAAC;CACtD,MAAM,SAAS,IAAI,IAAI,MAAM,aAAa,KAAK,YAAY,CAAC,QAAQ,KAAK,QAAQ,OAAO,CAAC,CAAC;CAC1F,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,QAAQ,GAAG,OAAO,IAAI,KAAK,OAAO;CAC9E,OAAO,EAAE,cAAc,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,cAAc;EAAE;EAAK;CAAQ,EAAE,EAAE;AACjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.d.ts","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"visual.d.ts","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"mappings":";;;;;;;;;iBA8EgB,WAAW,MAAM,YAAY;;iBAM7B,aAAa,MAAM,YAAY;iBAK/B,gCACd,mBACA,WAAW,oBACX"}
|
|
@@ -5,9 +5,24 @@ import { getTextStyle } from "../text/style.js";
|
|
|
5
5
|
import { graph, raw, strokeOwner, updateNode } from "../accessor-utils.js";
|
|
6
6
|
import { finiteNumber } from "../finite.js";
|
|
7
7
|
import { paintBindings, setPaintBindings } from "../variables/bindings.js";
|
|
8
|
+
import { OVERFLOW_DIRECTIONS, SCROLL_BEHAVIORS } from "@pairdraw/scene-graph/constants";
|
|
8
9
|
import { independentCornerChanges } from "@pairdraw/scene-graph/variables";
|
|
9
10
|
import { newStrokeGeometry } from "@pairdraw/scene-graph/node-defaults";
|
|
10
11
|
//#region src/figma-api/accessors/visual.ts
|
|
12
|
+
/** `value` as a frame's overflow scrolling, refused in the words Figma's plugin API uses. */
|
|
13
|
+
function checkedOverflowDirection(value) {
|
|
14
|
+
const direction = OVERFLOW_DIRECTIONS.find((candidate) => candidate === value);
|
|
15
|
+
if (direction) return direction;
|
|
16
|
+
const expected = OVERFLOW_DIRECTIONS.map((candidate) => `'${candidate}'`).join(" | ");
|
|
17
|
+
throw new Error(`in set_overflowDirection: Property "overflowDirection" failed validation: Invalid enum value. Expected ${expected}, received '${String(value)}'`);
|
|
18
|
+
}
|
|
19
|
+
/** `value` as a layer's scroll behavior, refused in the words Figma's plugin API uses. */
|
|
20
|
+
function checkedScrollBehavior(value) {
|
|
21
|
+
const behavior = SCROLL_BEHAVIORS.find((candidate) => candidate === value);
|
|
22
|
+
if (behavior) return behavior;
|
|
23
|
+
const expected = SCROLL_BEHAVIORS.map((candidate) => `'${candidate}'`).join(" | ");
|
|
24
|
+
throw new Error(`in set_scrollBehavior: Property "scrollBehavior" failed validation: Invalid enum value. Expected ${expected}, received '${String(value)}'`);
|
|
25
|
+
}
|
|
11
26
|
function styleReference(internals, field, mixed) {
|
|
12
27
|
return {
|
|
13
28
|
get() {
|
|
@@ -130,6 +145,24 @@ function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
130
145
|
updateNode(this, internals, { clipsContent: value });
|
|
131
146
|
}
|
|
132
147
|
},
|
|
148
|
+
overflowDirection: {
|
|
149
|
+
get() {
|
|
150
|
+
return raw(this, internals).overflowDirection;
|
|
151
|
+
},
|
|
152
|
+
set(value) {
|
|
153
|
+
const node = raw(this, internals);
|
|
154
|
+
if (node.type !== "FRAME" && node.type !== "COMPONENT" && node.type !== "INSTANCE") throw new Error(`in set_overflowDirection: Only a frame, component or instance scrolls; ${node.type} "${node.name}" cannot`);
|
|
155
|
+
updateNode(this, internals, { overflowDirection: checkedOverflowDirection(value) });
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
scrollBehavior: {
|
|
159
|
+
get() {
|
|
160
|
+
return raw(this, internals).scrollBehavior;
|
|
161
|
+
},
|
|
162
|
+
set(value) {
|
|
163
|
+
updateNode(this, internals, { scrollBehavior: checkedScrollBehavior(value) });
|
|
164
|
+
}
|
|
165
|
+
},
|
|
133
166
|
cornerRadius: {
|
|
134
167
|
get() {
|
|
135
168
|
const node = raw(this, internals);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.js","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"sourcesContent":["import type { SceneNode, ShadowEffect, Stroke } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\nimport { independentCornerChanges } from '@pairdraw/scene-graph/variables'\n\nimport {\n graph,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaEffects, toFigmaEffect, type FigmaEffect } from '#core/figma-api/effects'\nimport { finiteNumber } from '#core/figma-api/finite'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { getTextStyle } from '#core/figma-api/text/style'\nimport { paintBindings, setPaintBindings } from '#core/figma-api/variables/bindings'\nimport { textStyleChanges } from '#core/text/character-style'\n\nfunction styleReference(\n internals: NodeProxyInternals,\n field: 'fillStyleId' | 'strokeStyleId' | 'effectStyleId' | 'gridStyleId',\n mixed: symbol\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): string | symbol {\n const node = raw(this, internals)\n // Characters of a text can each use a fill style of their own.\n if (field === 'fillStyleId' && node.type === 'TEXT') {\n return getTextStyle(node, 'fillStyleId', mixed) as string | symbol\n }\n return node[field] ?? ''\n },\n set(this: ProxyThis, value: string) {\n const node = raw(this, internals)\n const changes = { [field]: value || null }\n updateNode(\n this,\n internals,\n field === 'fillStyleId' && node.type === 'TEXT' ? textStyleChanges(node, changes) : changes\n )\n }\n }\n}\n\n/**\n * `node`'s fills as Figma's plugin API reads them, each carrying the variable it is bound to. A\n * bound paint reads as it stores its color and opacity, which its variable writes into it when it\n * binds and whenever the color it gives the layer changes, as in Figma.\n */\nexport function figmaFills(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'fills')\n return node.fills.map((fill, index) => toFigmaPaint(fill, bound.get(index)))\n}\n\n/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */\nexport function figmaStrokes(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'strokes')\n return node.strokes.map((stroke, index) => toFigmaPaint(stroke, bound.get(index)))\n}\n\nexport function installVisualNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n fills: {\n // Text reads mixed while its characters are filled differently, and setting it fills them all.\n get(this: ProxyThis): readonly FigmaPaint[] | symbol {\n const node = raw(this, internals)\n if (node.type !== 'TEXT') return Object.freeze(figmaFills(node))\n const fills = getTextStyle(node, 'fills', mixed)\n // Text styles read for scripts already give Figma's paints.\n return typeof fills === 'symbol' ? fills : Object.freeze(fills as FigmaPaint[])\n },\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const node = raw(this, internals)\n const fills = parseFigmaPaints(value)\n updateNode(\n this,\n internals,\n node.type === 'TEXT' ? textStyleChanges(node, { fills }) : { fills }\n )\n setPaintBindings(graph(this, internals), raw(this, internals), 'fills', value)\n }\n },\n strokes: {\n get(this: ProxyThis): readonly FigmaPaint[] {\n const owner = raw(strokeOwner(this, internals), internals)\n return Object.freeze(figmaStrokes(owner))\n },\n // Figma paints carry no geometry; a stroke takes the node's weight and alignment, which\n // outlast its strokes.\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const owner = strokeOwner(this, internals)\n const geometry = newStrokeGeometry(raw(owner, internals))\n const strokes = parseFigmaPaints(value, 'set_strokes', 'strokes').map((paint): Stroke => ({\n ...paint,\n weight: geometry.weight,\n align: geometry.align\n }))\n const kept = newStrokeGeometry({\n strokes,\n strokeWeight: geometry.weight,\n strokeAlign: geometry.align\n })\n updateNode(owner, internals, {\n strokes,\n strokeWeight: kept.weight,\n strokeAlign: kept.align\n })\n setPaintBindings(graph(this, internals), raw(owner, internals), 'strokes', value)\n }\n },\n effects: {\n get(this: ProxyThis): readonly FigmaEffect[] {\n // A shader effect has no Figma plugin-API form yet (`UNSUPPORTED_EFFECT_TYPES`).\n return Object.freeze(\n raw(this, internals)\n .effects.filter((effect): effect is ShadowEffect => effect.type !== 'SHADER')\n .map(toFigmaEffect)\n )\n },\n set(this: ProxyThis, value: readonly FigmaEffect[]) {\n updateNode(this, internals, { effects: parseFigmaEffects(value) })\n }\n },\n // Applied shared styles, as Figma exposes them; an assignment inside an instance is an override.\n fillStyleId: styleReference(internals, 'fillStyleId', mixed),\n strokeStyleId: styleReference(internals, 'strokeStyleId', mixed),\n effectStyleId: styleReference(internals, 'effectStyleId', mixed),\n gridStyleId: styleReference(internals, 'gridStyleId', mixed),\n opacity: {\n get(this: ProxyThis): number {\n return raw(this, internals).opacity\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { opacity: finiteNumber(value, 'opacity') })\n }\n },\n visible: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).visible\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { visible: value })\n }\n },\n locked: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).locked\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { locked: value })\n }\n },\n blendMode: {\n get(this: ProxyThis): string {\n return raw(this, internals).blendMode\n },\n set(this: ProxyThis, value: string) {\n updateNode(this, internals, { blendMode: value as SceneNode['blendMode'] })\n }\n },\n clipsContent: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).clipsContent\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { clipsContent: value })\n }\n },\n cornerRadius: {\n get(this: ProxyThis): number | symbol {\n const node = raw(this, internals)\n if (!node.independentCorners) return node.cornerRadius\n // Corners set or bound one by one read as one radius while they agree, as in Figma.\n const { topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius } = node\n const agree = [topRightRadius, bottomLeftRadius, bottomRightRadius].every(\n (radius) => radius === topLeftRadius\n )\n return agree ? topLeftRadius : mixed\n },\n set(this: ProxyThis, value: unknown) {\n if (value === mixed) return\n const radius = finiteNumber(value, 'cornerRadius')\n updateNode(this, internals, {\n cornerRadius: radius,\n topLeftRadius: radius,\n topRightRadius: radius,\n bottomRightRadius: radius,\n bottomLeftRadius: radius,\n independentCorners: false\n })\n }\n },\n topLeftRadius: cornerAccessor(internals, 'topLeftRadius'),\n topRightRadius: cornerAccessor(internals, 'topRightRadius'),\n bottomLeftRadius: cornerAccessor(internals, 'bottomLeftRadius'),\n bottomRightRadius: cornerAccessor(internals, 'bottomRightRadius'),\n cornerSmoothing: {\n get(this: ProxyThis): number {\n return raw(this, internals).cornerSmoothing\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { cornerSmoothing: finiteNumber(value, 'cornerSmoothing') })\n }\n }\n })\n}\n\nfunction cornerAccessor(\n internals: NodeProxyInternals,\n field: 'topLeftRadius' | 'topRightRadius' | 'bottomLeftRadius' | 'bottomRightRadius'\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, {\n ...independentCornerChanges(raw(this, internals)),\n [field]: finiteNumber(value, field)\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,eACP,WACA,OACA,OACoB;CACpB,OAAO;EACL,MAAsC;GACpC,MAAM,OAAO,IAAI,MAAM,SAAS;GAEhC,IAAI,UAAU,iBAAiB,KAAK,SAAS,QAC3C,OAAO,aAAa,MAAM,eAAe,KAAK;GAEhD,OAAO,KAAK,UAAU;EACxB;EACA,IAAqB,OAAe;GAClC,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,UAAU,GAAG,QAAQ,SAAS,KAAK;GACzC,WACE,MACA,WACA,UAAU,iBAAiB,K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yB,IAAI,MAAM,SAAS,CAAC;KAC/C,QAAQ,aAAa,OAAO,KAAK;GACpC,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"visual.js","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"sourcesContent":["import type {\n Effect,\n OverflowDirection,\n SceneNode,\n ScrollBehavior,\n ShaderEffect,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { OVERFLOW_DIRECTIONS, SCROLL_BEHAVIORS } from '@pairdraw/scene-graph/constants'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\nimport { independentCornerChanges } from '@pairdraw/scene-graph/variables'\n\nimport {\n graph,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaEffects, toFigmaEffect, type FigmaEffect } from '#core/figma-api/effects'\nimport { finiteNumber } from '#core/figma-api/finite'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { getTextStyle } from '#core/figma-api/text/style'\nimport { paintBindings, setPaintBindings } from '#core/figma-api/variables/bindings'\nimport { textStyleChanges } from '#core/text/character-style'\n\n/** `value` as a frame's overflow scrolling, refused in the words Figma's plugin API uses. */\nfunction checkedOverflowDirection(value: unknown): OverflowDirection {\n const direction = OVERFLOW_DIRECTIONS.find((candidate) => candidate === value)\n if (direction) return direction\n const expected = OVERFLOW_DIRECTIONS.map((candidate) => `'${candidate}'`).join(' | ')\n throw new Error(\n `in set_overflowDirection: Property \"overflowDirection\" failed validation: Invalid enum value. Expected ${expected}, received '${String(value)}'`\n )\n}\n\n/** `value` as a layer's scroll behavior, refused in the words Figma's plugin API uses. */\nfunction checkedScrollBehavior(value: unknown): ScrollBehavior {\n const behavior = SCROLL_BEHAVIORS.find((candidate) => candidate === value)\n if (behavior) return behavior\n const expected = SCROLL_BEHAVIORS.map((candidate) => `'${candidate}'`).join(' | ')\n throw new Error(\n `in set_scrollBehavior: Property \"scrollBehavior\" failed validation: Invalid enum value. Expected ${expected}, received '${String(value)}'`\n )\n}\n\nfunction styleReference(\n internals: NodeProxyInternals,\n field: 'fillStyleId' | 'strokeStyleId' | 'effectStyleId' | 'gridStyleId',\n mixed: symbol\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): string | symbol {\n const node = raw(this, internals)\n // Characters of a text can each use a fill style of their own.\n if (field === 'fillStyleId' && node.type === 'TEXT') {\n return getTextStyle(node, 'fillStyleId', mixed) as string | symbol\n }\n return node[field] ?? ''\n },\n set(this: ProxyThis, value: string) {\n const node = raw(this, internals)\n const changes = { [field]: value || null }\n updateNode(\n this,\n internals,\n field === 'fillStyleId' && node.type === 'TEXT' ? textStyleChanges(node, changes) : changes\n )\n }\n }\n}\n\n/**\n * `node`'s fills as Figma's plugin API reads them, each carrying the variable it is bound to. A\n * bound paint reads as it stores its color and opacity, which its variable writes into it when it\n * binds and whenever the color it gives the layer changes, as in Figma.\n */\nexport function figmaFills(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'fills')\n return node.fills.map((fill, index) => toFigmaPaint(fill, bound.get(index)))\n}\n\n/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */\nexport function figmaStrokes(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'strokes')\n return node.strokes.map((stroke, index) => toFigmaPaint(stroke, bound.get(index)))\n}\n\nexport function installVisualNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n fills: {\n // Text reads mixed while its characters are filled differently, and setting it fills them all.\n get(this: ProxyThis): readonly FigmaPaint[] | symbol {\n const node = raw(this, internals)\n if (node.type !== 'TEXT') return Object.freeze(figmaFills(node))\n const fills = getTextStyle(node, 'fills', mixed)\n // Text styles read for scripts already give Figma's paints.\n return typeof fills === 'symbol' ? fills : Object.freeze(fills as FigmaPaint[])\n },\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const node = raw(this, internals)\n const fills = parseFigmaPaints(value)\n updateNode(\n this,\n internals,\n node.type === 'TEXT' ? textStyleChanges(node, { fills }) : { fills }\n )\n setPaintBindings(graph(this, internals), raw(this, internals), 'fills', value)\n }\n },\n strokes: {\n get(this: ProxyThis): readonly FigmaPaint[] {\n const owner = raw(strokeOwner(this, internals), internals)\n return Object.freeze(figmaStrokes(owner))\n },\n // Figma paints carry no geometry; a stroke takes the node's weight and alignment, which\n // outlast its strokes.\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const owner = strokeOwner(this, internals)\n const geometry = newStrokeGeometry(raw(owner, internals))\n const strokes = parseFigmaPaints(value, 'set_strokes', 'strokes').map((paint): Stroke => ({\n ...paint,\n weight: geometry.weight,\n align: geometry.align\n }))\n const kept = newStrokeGeometry({\n strokes,\n strokeWeight: geometry.weight,\n strokeAlign: geometry.align\n })\n updateNode(owner, internals, {\n strokes,\n strokeWeight: kept.weight,\n strokeAlign: kept.align\n })\n setPaintBindings(graph(this, internals), raw(owner, internals), 'strokes', value)\n }\n },\n effects: {\n get(this: ProxyThis): readonly FigmaEffect[] {\n // A shader effect has no Figma plugin-API form yet (`UNSUPPORTED_EFFECT_TYPES`).\n return Object.freeze(\n raw(this, internals)\n .effects.filter(\n (effect): effect is Exclude<Effect, ShaderEffect> => effect.type !== 'SHADER'\n )\n .map(toFigmaEffect)\n )\n },\n set(this: ProxyThis, value: readonly FigmaEffect[]) {\n updateNode(this, internals, { effects: parseFigmaEffects(value) })\n }\n },\n // Applied shared styles, as Figma exposes them; an assignment inside an instance is an override.\n fillStyleId: styleReference(internals, 'fillStyleId', mixed),\n strokeStyleId: styleReference(internals, 'strokeStyleId', mixed),\n effectStyleId: styleReference(internals, 'effectStyleId', mixed),\n gridStyleId: styleReference(internals, 'gridStyleId', mixed),\n opacity: {\n get(this: ProxyThis): number {\n return raw(this, internals).opacity\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { opacity: finiteNumber(value, 'opacity') })\n }\n },\n visible: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).visible\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { visible: value })\n }\n },\n locked: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).locked\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { locked: value })\n }\n },\n blendMode: {\n get(this: ProxyThis): string {\n return raw(this, internals).blendMode\n },\n set(this: ProxyThis, value: string) {\n updateNode(this, internals, { blendMode: value as SceneNode['blendMode'] })\n }\n },\n clipsContent: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).clipsContent\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { clipsContent: value })\n }\n },\n overflowDirection: {\n get(this: ProxyThis): OverflowDirection {\n return raw(this, internals).overflowDirection\n },\n set(this: ProxyThis, value: unknown) {\n const node = raw(this, internals)\n // Only a frame-like layer scrolls in play, and only its record carries the field.\n if (node.type !== 'FRAME' && node.type !== 'COMPONENT' && node.type !== 'INSTANCE') {\n throw new Error(\n `in set_overflowDirection: Only a frame, component or instance scrolls; ${node.type} \"${node.name}\" cannot`\n )\n }\n updateNode(this, internals, { overflowDirection: checkedOverflowDirection(value) })\n }\n },\n scrollBehavior: {\n get(this: ProxyThis): ScrollBehavior {\n return raw(this, internals).scrollBehavior\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { scrollBehavior: checkedScrollBehavior(value) })\n }\n },\n cornerRadius: {\n get(this: ProxyThis): number | symbol {\n const node = raw(this, internals)\n if (!node.independentCorners) return node.cornerRadius\n // Corners set or bound one by one read as one radius while they agree, as in Figma.\n const { topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius } = node\n const agree = [topRightRadius, bottomLeftRadius, bottomRightRadius].every(\n (radius) => radius === topLeftRadius\n )\n return agree ? topLeftRadius : mixed\n },\n set(this: ProxyThis, value: unknown) {\n if (value === mixed) return\n const radius = finiteNumber(value, 'cornerRadius')\n updateNode(this, internals, {\n cornerRadius: radius,\n topLeftRadius: radius,\n topRightRadius: radius,\n bottomRightRadius: radius,\n bottomLeftRadius: radius,\n independentCorners: false\n })\n }\n },\n topLeftRadius: cornerAccessor(internals, 'topLeftRadius'),\n topRightRadius: cornerAccessor(internals, 'topRightRadius'),\n bottomLeftRadius: cornerAccessor(internals, 'bottomLeftRadius'),\n bottomRightRadius: cornerAccessor(internals, 'bottomRightRadius'),\n cornerSmoothing: {\n get(this: ProxyThis): number {\n return raw(this, internals).cornerSmoothing\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { cornerSmoothing: finiteNumber(value, 'cornerSmoothing') })\n }\n }\n })\n}\n\nfunction cornerAccessor(\n internals: NodeProxyInternals,\n field: 'topLeftRadius' | 'topRightRadius' | 'bottomLeftRadius' | 'bottomRightRadius'\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, {\n ...independentCornerChanges(raw(this, internals)),\n [field]: finiteNumber(value, field)\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,SAAS,yBAAyB,OAAmC;CACnE,MAAM,YAAY,oBAAoB,MAAM,cAAc,cAAc,KAAK;CAC7E,IAAI,WAAW,OAAO;CACtB,MAAM,WAAW,oBAAoB,KAAK,cAAc,IAAI,UAAU,EAAE,CAAC,CAAC,KAAK,KAAK;CACpF,MAAM,IAAI,MACR,0GAA0G,SAAS,cAAc,OAAO,KAAK,EAAE,EACjJ;AACF;;AAGA,SAAS,sBAAsB,OAAgC;CAC7D,MAAM,WAAW,iBAAiB,MAAM,cAAc,cAAc,KAAK;CACzE,IAAI,UAAU,OAAO;CACrB,MAAM,WAAW,iBAAiB,KAAK,cAAc,IAAI,UAAU,EAAE,CAAC,CAAC,KAAK,KAAK;CACjF,MAAM,IAAI,MACR,oGAAoG,SAAS,cAAc,OAAO,KAAK,EAAE,EAC3I;AACF;AAEA,SAAS,eACP,WACA,OACA,OACoB;CACpB,O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AI/E,OAHc;KAAC;KAAgB;KAAkB;IAAiB,CAAC,CAAC,OACjE,WAAW,WAAW,aAEd,IAAI,gBAAgB;GACjC;GACA,IAAqB,OAAgB;IACnC,IAAI,UAAU,OAAO;IACrB,MAAM,SAAS,aAAa,OAAO,cAAc;IACjD,WAAW,MAAM,WAAW;KAC1B,cAAc;KACd,eAAe;KACf,gBAAgB;KAChB,mBAAmB;KACnB,kBAAkB;KAClB,oBAAoB;IACtB,CAAC;GACH;EACF;EACA,eAAe,eAAe,WAAW,eAAe;EACxD,gBAAgB,eAAe,WAAW,gBAAgB;EAC1D,kBAAkB,eAAe,WAAW,kBAAkB;EAC9D,mBAAmB,eAAe,WAAW,mBAAmB;EAChE,iBAAiB;GACf,MAA6B;IAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;GAC9B;GACA,IAAqB,OAAgB;IACnC,WAAW,MAAM,WAAW,EAAE,iBAAiB,aAAa,OAAO,iBAAiB,EAAE,CAAC;GACzF;EACF;CACF,CAAC;AACH;AAEA,SAAS,eACP,WACA,OACoB;CACpB,OAAO;EACL,MAA6B;GAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAgB;GACnC,WAAW,MAAM,WAAW;IAC1B,GAAG,yBAAyB,IAAI,MAAM,SAAS,CAAC;KAC/C,QAAQ,aAAa,OAAO,KAAK;GACpC,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlendMode, Effect,
|
|
1
|
+
import { BlendMode, Effect, ShaderEffect } from "@pairdraw/scene-graph";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/figma-api/effects.d.ts
|
|
4
4
|
declare const BLEND_MODES: BlendMode[];
|
|
@@ -43,11 +43,87 @@ declare const effectSchema: v.VariantSchema<"type", [v.StrictObjectSchema<{
|
|
|
43
43
|
readonly visible: v.BooleanSchema<undefined>;
|
|
44
44
|
readonly blurType: v.OptionalSchema<v.LiteralSchema<"NORMAL", undefined>, "NORMAL">;
|
|
45
45
|
readonly boundVariables: v.OptionalSchema<v.StrictObjectSchema<{}, undefined>, undefined>;
|
|
46
|
+
}, undefined>, v.VariantSchema<"noiseType", [v.StrictObjectSchema<{
|
|
47
|
+
readonly noiseType: v.LiteralSchema<"MONOTONE", undefined>;
|
|
48
|
+
readonly type: v.LiteralSchema<"NOISE", undefined>;
|
|
49
|
+
readonly visible: v.BooleanSchema<undefined>;
|
|
50
|
+
readonly boundVariables: v.OptionalSchema<v.StrictObjectSchema<{}, undefined>, undefined>;
|
|
51
|
+
readonly noiseSize: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
52
|
+
readonly noiseSizeVector: v.OptionalSchema<v.StrictObjectSchema<{
|
|
53
|
+
readonly x: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
54
|
+
readonly y: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
55
|
+
}, undefined>, undefined>;
|
|
56
|
+
readonly color: v.StrictObjectSchema<{
|
|
57
|
+
readonly r: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
58
|
+
readonly g: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
59
|
+
readonly b: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
60
|
+
readonly a: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
61
|
+
}, undefined>;
|
|
62
|
+
readonly density: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
63
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
64
|
+
readonly noiseType: v.LiteralSchema<"DUOTONE", undefined>;
|
|
65
|
+
readonly secondaryColor: v.StrictObjectSchema<{
|
|
66
|
+
readonly r: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
67
|
+
readonly g: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
68
|
+
readonly b: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
69
|
+
readonly a: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
70
|
+
}, undefined>;
|
|
71
|
+
readonly type: v.LiteralSchema<"NOISE", undefined>;
|
|
72
|
+
readonly visible: v.BooleanSchema<undefined>;
|
|
73
|
+
readonly boundVariables: v.OptionalSchema<v.StrictObjectSchema<{}, undefined>, undefined>;
|
|
74
|
+
readonly noiseSize: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
75
|
+
readonly noiseSizeVector: v.OptionalSchema<v.StrictObjectSchema<{
|
|
76
|
+
readonly x: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
77
|
+
readonly y: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
78
|
+
}, undefined>, undefined>;
|
|
79
|
+
readonly color: v.StrictObjectSchema<{
|
|
80
|
+
readonly r: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
81
|
+
readonly g: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
82
|
+
readonly b: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
83
|
+
readonly a: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
84
|
+
}, undefined>;
|
|
85
|
+
readonly density: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
86
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
87
|
+
readonly noiseType: v.LiteralSchema<"MULTITONE", undefined>;
|
|
88
|
+
readonly opacity: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
89
|
+
readonly type: v.LiteralSchema<"NOISE", undefined>;
|
|
90
|
+
readonly visible: v.BooleanSchema<undefined>;
|
|
91
|
+
readonly boundVariables: v.OptionalSchema<v.StrictObjectSchema<{}, undefined>, undefined>;
|
|
92
|
+
readonly noiseSize: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
93
|
+
readonly noiseSizeVector: v.OptionalSchema<v.StrictObjectSchema<{
|
|
94
|
+
readonly x: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
95
|
+
readonly y: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
96
|
+
}, undefined>, undefined>;
|
|
97
|
+
readonly color: v.StrictObjectSchema<{
|
|
98
|
+
readonly r: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
99
|
+
readonly g: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
100
|
+
readonly b: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
101
|
+
readonly a: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
102
|
+
}, undefined>;
|
|
103
|
+
readonly density: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>;
|
|
104
|
+
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
105
|
+
readonly type: v.LiteralSchema<"TEXTURE", undefined>;
|
|
106
|
+
readonly visible: v.BooleanSchema<undefined>;
|
|
107
|
+
readonly radius: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
108
|
+
readonly boundVariables: v.OptionalSchema<v.StrictObjectSchema<{}, undefined>, undefined>;
|
|
109
|
+
readonly noiseSize: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
110
|
+
readonly noiseSizeVector: v.OptionalSchema<v.StrictObjectSchema<{
|
|
111
|
+
readonly x: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
112
|
+
readonly y: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>, v.MinValueAction<number, 0, undefined>]>, v.TransformAction<number, number>]>;
|
|
113
|
+
}, undefined>, undefined>;
|
|
114
|
+
readonly clipToShape: v.BooleanSchema<undefined>;
|
|
46
115
|
}, undefined>], undefined>;
|
|
47
116
|
/** An effect as Figma's plugin API reads and writes it (`Effect` in `@figma/plugin-typings`). */
|
|
48
117
|
type FigmaEffect = v.InferOutput<typeof effectSchema>;
|
|
49
118
|
/** Figma's spelling of a path into a value: `[0].color.r`. */
|
|
50
119
|
declare function issuePath(path: readonly v.IssuePathItem[] | undefined): string;
|
|
120
|
+
/**
|
|
121
|
+
* `effects` with every texture after the first left out, as Figma silently keeps one. The effects
|
|
122
|
+
* setter reads bindings from the same list, so their indexes match the effects it keeps.
|
|
123
|
+
*/
|
|
124
|
+
declare function firstTextureOnly<T extends {
|
|
125
|
+
readonly type: string;
|
|
126
|
+
}>(effects: readonly T[]): T[];
|
|
51
127
|
/**
|
|
52
128
|
* Check `value` against Figma's effect shapes and convert it to scene effects.
|
|
53
129
|
* Throws with the first problem, as Figma's `effects` setter does.
|
|
@@ -56,7 +132,7 @@ declare function parseFigmaEffects(value: unknown): Effect[];
|
|
|
56
132
|
/** `value` as scene effects when it holds valid Figma effects, or null. */
|
|
57
133
|
declare function tryParseFigmaEffects(value: unknown): Effect[] | null;
|
|
58
134
|
/** A scene effect in the shape Figma's `effects` getter returns. */
|
|
59
|
-
declare function toFigmaEffect(effect:
|
|
135
|
+
declare function toFigmaEffect(effect: Exclude<Effect, ShaderEffect>): FigmaEffect;
|
|
60
136
|
//#endregion
|
|
61
|
-
export { BLEND_MODES, FigmaEffect, issuePath, parseFigmaEffects, toFigmaEffect, tryParseFigmaEffects };
|
|
137
|
+
export { BLEND_MODES, FigmaEffect, firstTextureOnly, issuePath, parseFigmaEffects, toFigmaEffect, tryParseFigmaEffects };
|
|
62
138
|
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","names":[],"sources":["../../src/figma-api/effects.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"effects.d.ts","names":[],"sources":["../../src/figma-api/effects.ts"],"mappings":";;;cAqCa,aAA8C;cA4CrD,cAAY,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCN,cAAc,EAAE,mBAAmB;;iBAG/B,UAAU,eAAe,EAAE;;;;;iBAsC3B,iBAAiB;WAAqB;GAAgB,kBAAkB,MAAM;;;;;iBAS9E,kBAAkB,iBAAiB;;iBAgBnC,qBAAqB,iBAAiB;;iBA8DtC,cAAc,QAAQ,QAAQ,QAAQ,gBAAgB"}
|