@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,298 @@
|
|
|
1
|
+
import { svg } from "./node.js";
|
|
2
|
+
import { round } from "./paths.js";
|
|
3
|
+
import { floodColor } from "./filter.js";
|
|
4
|
+
//#region src/io/formats/svg/grain.ts
|
|
5
|
+
/** How many steps the discrete alpha table of a noise has, as Figma writes it. */
|
|
6
|
+
const NOISE_TABLE_STEPS = 100;
|
|
7
|
+
/** Keeps a channel's alpha alone, as each of Figma's grain matrices does somewhere. */
|
|
8
|
+
const ALPHA_ONLY = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0";
|
|
9
|
+
const ALPHA_TO_RED = "0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
|
|
10
|
+
const ALPHA_TO_GREEN = "0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1";
|
|
11
|
+
const OPAQUE = "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 127 0";
|
|
12
|
+
const ALPHA_TO_RED_OPAQUE = "0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0";
|
|
13
|
+
const RED_TO_ALPHA = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
|
|
14
|
+
/** A grain size as `feTurbulence` frequency, one cycle per grain on each axis. */
|
|
15
|
+
function grainFrequency(size) {
|
|
16
|
+
const frequency = (length) => length > 0 ? round(1 / length, 4) : 0;
|
|
17
|
+
return `${frequency(size.x)} ${frequency(size.y)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes
|
|
21
|
+
* it: a band of ones over the noise's middle tones, one step wide at no density and half the
|
|
22
|
+
* steps at full. Figma works it out in 32-bit floats, as it stores the density.
|
|
23
|
+
*/
|
|
24
|
+
function noiseDensityTable(density, mirrored = false) {
|
|
25
|
+
const stored = Math.fround(density);
|
|
26
|
+
const start = Math.floor(25 - 25 * stored);
|
|
27
|
+
const count = Math.floor(50 * stored) + 1;
|
|
28
|
+
const steps = Array.from({ length: NOISE_TABLE_STEPS }, (_, step) => step >= start && step < start + count ? 1 : 0);
|
|
29
|
+
return (mirrored ? steps.reverse() : steps).join(" ");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a
|
|
33
|
+
* cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its
|
|
34
|
+
* second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the
|
|
35
|
+
* result's name.
|
|
36
|
+
*/
|
|
37
|
+
function noiseFilter(filter, effect, input) {
|
|
38
|
+
const grain = effect.noise;
|
|
39
|
+
const noise = filter.result("noise");
|
|
40
|
+
filter.push("feTurbulence", {
|
|
41
|
+
type: "fractalNoise",
|
|
42
|
+
baseFrequency: grainFrequency(grain.noiseSize),
|
|
43
|
+
stitchTiles: "stitch",
|
|
44
|
+
numOctaves: 3,
|
|
45
|
+
seed: grain.seed ?? 0,
|
|
46
|
+
result: noise
|
|
47
|
+
});
|
|
48
|
+
const merged = filter.result("noiseMerge");
|
|
49
|
+
if (grain.noiseType === "MULTITONE") {
|
|
50
|
+
const colored = filter.result("multitone");
|
|
51
|
+
const linear = {
|
|
52
|
+
type: "linear",
|
|
53
|
+
slope: 2,
|
|
54
|
+
intercept: -.5
|
|
55
|
+
};
|
|
56
|
+
filter.push("feComponentTransfer", {
|
|
57
|
+
in: noise,
|
|
58
|
+
result: colored
|
|
59
|
+
}, svg("feFuncR", linear), svg("feFuncG", linear), svg("feFuncB", linear), svg("feFuncA", {
|
|
60
|
+
type: "discrete",
|
|
61
|
+
tableValues: noiseDensityTable(grain.density)
|
|
62
|
+
}));
|
|
63
|
+
const clipped = filter.result("noiseClipped");
|
|
64
|
+
filter.push("feComposite", {
|
|
65
|
+
in: colored,
|
|
66
|
+
in2: input,
|
|
67
|
+
operator: "in",
|
|
68
|
+
result: clipped
|
|
69
|
+
});
|
|
70
|
+
const faded = filter.result("noiseColor");
|
|
71
|
+
filter.push("feComponentTransfer", {
|
|
72
|
+
in: clipped,
|
|
73
|
+
result: faded
|
|
74
|
+
}, svg("feFuncA", {
|
|
75
|
+
type: "table",
|
|
76
|
+
tableValues: `0 ${round(grain.opacity ?? 1)}`
|
|
77
|
+
}));
|
|
78
|
+
filter.pushElement("feMerge", { result: merged }, mergeNodes([input, faded]));
|
|
79
|
+
return merged;
|
|
80
|
+
}
|
|
81
|
+
const alpha = filter.result("alphaNoise");
|
|
82
|
+
filter.push("feColorMatrix", {
|
|
83
|
+
in: noise,
|
|
84
|
+
type: "luminanceToAlpha",
|
|
85
|
+
result: alpha
|
|
86
|
+
});
|
|
87
|
+
const tones = [{
|
|
88
|
+
color: effect.color,
|
|
89
|
+
mirrored: false
|
|
90
|
+
}];
|
|
91
|
+
if (grain.noiseType === "DUOTONE") tones.push({
|
|
92
|
+
color: grain.secondaryColor ?? effect.color,
|
|
93
|
+
mirrored: true
|
|
94
|
+
});
|
|
95
|
+
const colors = tones.map(({ color, mirrored }) => {
|
|
96
|
+
const band = filter.result("noiseBand");
|
|
97
|
+
filter.push("feComponentTransfer", {
|
|
98
|
+
in: alpha,
|
|
99
|
+
result: band
|
|
100
|
+
}, svg("feFuncA", {
|
|
101
|
+
type: "discrete",
|
|
102
|
+
tableValues: noiseDensityTable(grain.density, mirrored)
|
|
103
|
+
}));
|
|
104
|
+
const clipped = filter.result("noiseClipped");
|
|
105
|
+
filter.push("feComposite", {
|
|
106
|
+
in: band,
|
|
107
|
+
in2: input,
|
|
108
|
+
operator: "in",
|
|
109
|
+
result: clipped
|
|
110
|
+
});
|
|
111
|
+
const flood = filter.result("noiseFlood");
|
|
112
|
+
filter.push("feFlood", {
|
|
113
|
+
"flood-color": floodColor(color, filter.colorSpace, filter.documentColorSpace),
|
|
114
|
+
"flood-opacity": round(color.a),
|
|
115
|
+
result: flood
|
|
116
|
+
});
|
|
117
|
+
const colored = filter.result("noiseColor");
|
|
118
|
+
filter.push("feComposite", {
|
|
119
|
+
in: flood,
|
|
120
|
+
in2: clipped,
|
|
121
|
+
operator: "in",
|
|
122
|
+
result: colored
|
|
123
|
+
});
|
|
124
|
+
return colored;
|
|
125
|
+
});
|
|
126
|
+
filter.pushElement("feMerge", { result: merged }, mergeNodes([input, ...colors]));
|
|
127
|
+
return merged;
|
|
128
|
+
}
|
|
129
|
+
function mergeNodes(inputs) {
|
|
130
|
+
return inputs.map((input) => svg("feMergeNode", { in: input }));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal
|
|
134
|
+
* noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to
|
|
135
|
+
* its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.
|
|
136
|
+
* Returns the result's name.
|
|
137
|
+
*/
|
|
138
|
+
function textureFilter(filter, effect, input) {
|
|
139
|
+
const grain = effect.texture;
|
|
140
|
+
const frequency = grainFrequency(grain.noiseSize);
|
|
141
|
+
const scale = round(effect.radius * 2);
|
|
142
|
+
const name = (label) => filter.result(label);
|
|
143
|
+
const displace = (into, by, result) => filter.push("feDisplacementMap", {
|
|
144
|
+
in: into,
|
|
145
|
+
in2: by,
|
|
146
|
+
scale,
|
|
147
|
+
xChannelSelector: "R",
|
|
148
|
+
yChannelSelector: "G",
|
|
149
|
+
width: "100%",
|
|
150
|
+
height: "100%",
|
|
151
|
+
result
|
|
152
|
+
});
|
|
153
|
+
const turbulence = (seed, result) => filter.push("feTurbulence", {
|
|
154
|
+
type: "fractalNoise",
|
|
155
|
+
baseFrequency: frequency,
|
|
156
|
+
numOctaves: 3,
|
|
157
|
+
seed: (grain.seed ?? 0) + seed,
|
|
158
|
+
result
|
|
159
|
+
});
|
|
160
|
+
const matrix = (into, values, result) => filter.push("feColorMatrix", {
|
|
161
|
+
in: into,
|
|
162
|
+
type: "matrix",
|
|
163
|
+
values,
|
|
164
|
+
result
|
|
165
|
+
});
|
|
166
|
+
const arithmetic = (into, by, k, result) => filter.push("feComposite", {
|
|
167
|
+
in: into,
|
|
168
|
+
in2: by,
|
|
169
|
+
operator: "arithmetic",
|
|
170
|
+
k1: k[0],
|
|
171
|
+
k2: k[1],
|
|
172
|
+
k3: k[2],
|
|
173
|
+
k4: k[3],
|
|
174
|
+
result
|
|
175
|
+
});
|
|
176
|
+
const composite = (into, by, operator, result) => filter.push("feComposite", {
|
|
177
|
+
in: into,
|
|
178
|
+
in2: by,
|
|
179
|
+
operator,
|
|
180
|
+
result
|
|
181
|
+
});
|
|
182
|
+
const gamma = (into, result) => filter.push("feComponentTransfer", {
|
|
183
|
+
in: into,
|
|
184
|
+
result
|
|
185
|
+
}, svg("feFuncA", {
|
|
186
|
+
type: "gamma",
|
|
187
|
+
exponent: .2
|
|
188
|
+
}));
|
|
189
|
+
if (!grain.clipToShape) {
|
|
190
|
+
const noise = name("textureNoise");
|
|
191
|
+
turbulence(0, noise);
|
|
192
|
+
const displaced = name("texture");
|
|
193
|
+
displace(input, noise, displaced);
|
|
194
|
+
return displaced;
|
|
195
|
+
}
|
|
196
|
+
const noiseX = name("displacementX");
|
|
197
|
+
const noiseY = name("displacementY");
|
|
198
|
+
turbulence(0, noiseX);
|
|
199
|
+
turbulence(1, noiseY);
|
|
200
|
+
const xRed = name("displacementXRed");
|
|
201
|
+
matrix(noiseX, ALPHA_TO_RED, xRed);
|
|
202
|
+
const yGreen = name("displacementYGreen");
|
|
203
|
+
matrix(noiseY, ALPHA_TO_GREEN, yGreen);
|
|
204
|
+
const xy = name("displacementXY");
|
|
205
|
+
arithmetic(xRed, yGreen, [
|
|
206
|
+
0,
|
|
207
|
+
1,
|
|
208
|
+
1,
|
|
209
|
+
0
|
|
210
|
+
], xy);
|
|
211
|
+
const firstPass = name("firstPass");
|
|
212
|
+
displace(input, xy, firstPass);
|
|
213
|
+
const firstAlpha = name("firstPassAlpha");
|
|
214
|
+
matrix(firstPass, ALPHA_ONLY, firstAlpha);
|
|
215
|
+
const displacedAlpha = name("sourceDisplacedAlpha");
|
|
216
|
+
gamma(firstAlpha, displacedAlpha);
|
|
217
|
+
const inputAlphaOnly = name("inputAlphaOnly");
|
|
218
|
+
matrix(input, ALPHA_ONLY, inputAlphaOnly);
|
|
219
|
+
const inputAlpha = name("inputSourceAlpha");
|
|
220
|
+
gamma(inputAlphaOnly, inputAlpha);
|
|
221
|
+
const alphas = name("displacementAlphasMultiplied");
|
|
222
|
+
arithmetic(displacedAlpha, inputAlpha, [
|
|
223
|
+
1,
|
|
224
|
+
0,
|
|
225
|
+
0,
|
|
226
|
+
0
|
|
227
|
+
], alphas);
|
|
228
|
+
const centering = name("centeringAdjustment");
|
|
229
|
+
arithmetic(alphas, alphas, [
|
|
230
|
+
0,
|
|
231
|
+
0,
|
|
232
|
+
-.5,
|
|
233
|
+
.5
|
|
234
|
+
], centering);
|
|
235
|
+
const finalChannel = (noise, values, label) => {
|
|
236
|
+
const weighted = name(`${label}Weighted`);
|
|
237
|
+
arithmetic(noise, alphas, [
|
|
238
|
+
1,
|
|
239
|
+
0,
|
|
240
|
+
0,
|
|
241
|
+
0
|
|
242
|
+
], weighted);
|
|
243
|
+
const centered = name(`${label}Centered`);
|
|
244
|
+
arithmetic(centering, weighted, [
|
|
245
|
+
0,
|
|
246
|
+
1,
|
|
247
|
+
1,
|
|
248
|
+
0
|
|
249
|
+
], centered);
|
|
250
|
+
const final = name(`${label}Final`);
|
|
251
|
+
matrix(centered, values, final);
|
|
252
|
+
return final;
|
|
253
|
+
};
|
|
254
|
+
const xFinal = finalChannel(noiseX, ALPHA_TO_RED, "displacementX");
|
|
255
|
+
const yFinal = finalChannel(noiseY, ALPHA_TO_GREEN, "displacementY");
|
|
256
|
+
const combined = name("displacementCombined");
|
|
257
|
+
arithmetic(xFinal, yFinal, [
|
|
258
|
+
0,
|
|
259
|
+
1,
|
|
260
|
+
1,
|
|
261
|
+
0
|
|
262
|
+
], combined);
|
|
263
|
+
const map = name("displacementMap");
|
|
264
|
+
composite(combined, alphas, "in", map);
|
|
265
|
+
const neutral = name("neutral");
|
|
266
|
+
filter.push("feFlood", {
|
|
267
|
+
"flood-color": "rgb(127, 127, 127)",
|
|
268
|
+
"flood-opacity": 1,
|
|
269
|
+
result: neutral
|
|
270
|
+
});
|
|
271
|
+
const outside = name("neutralOutside");
|
|
272
|
+
composite(neutral, alphas, "out", outside);
|
|
273
|
+
const mapWithBackground = name("displacementMapWithBg");
|
|
274
|
+
composite(outside, map, "over", mapWithBackground);
|
|
275
|
+
const displaced = name("displacedImage");
|
|
276
|
+
displace(input, mapWithBackground, displaced);
|
|
277
|
+
const opaque = name("imageOpaque");
|
|
278
|
+
matrix(input, OPAQUE, opaque);
|
|
279
|
+
const displacedOpaque = name("displacedImageOpaque");
|
|
280
|
+
displace(opaque, mapWithBackground, displacedOpaque);
|
|
281
|
+
const displacedRed = name("displacedImageRed");
|
|
282
|
+
matrix(displaced, ALPHA_TO_RED_OPAQUE, displacedRed);
|
|
283
|
+
const inputRed = name("inputRed");
|
|
284
|
+
matrix(input, ALPHA_TO_RED_OPAQUE, inputRed);
|
|
285
|
+
const transparencyRed = name("transparencyRedMap");
|
|
286
|
+
composite(displacedRed, inputRed, "atop", transparencyRed);
|
|
287
|
+
const transparency = name("transparencyAlphaMap");
|
|
288
|
+
matrix(transparencyRed, RED_TO_ALPHA, transparency);
|
|
289
|
+
const layered = name("textureLayered");
|
|
290
|
+
composite(displacedOpaque, opaque, "over", layered);
|
|
291
|
+
const textured = name("texture");
|
|
292
|
+
composite(layered, transparency, "in", textured);
|
|
293
|
+
return textured;
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { noiseDensityTable, noiseFilter, textureFilter };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=grain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grain.js","names":[],"sources":["../../../../src/io/formats/svg/grain.ts"],"sourcesContent":["import type { NoiseEffect, TextureEffect } from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { floodColor, type FilterBuilder } from './filter'\nimport { svg } from './node'\nimport { round } from './paths'\n\n/** How many steps the discrete alpha table of a noise has, as Figma writes it. */\nconst NOISE_TABLE_STEPS = 100\n\n/** Keeps a channel's alpha alone, as each of Figma's grain matrices does somewhere. */\nconst ALPHA_ONLY = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'\nconst ALPHA_TO_RED = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1'\nconst ALPHA_TO_GREEN = '0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1'\nconst OPAQUE = '1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 127 0'\nconst ALPHA_TO_RED_OPAQUE = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'\nconst RED_TO_ALPHA = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'\n\n/** A grain size as `feTurbulence` frequency, one cycle per grain on each axis. */\nfunction grainFrequency(size: Vector): string {\n const frequency = (length: number) => (length > 0 ? round(1 / length, 4) : 0)\n return `${frequency(size.x)} ${frequency(size.y)}`\n}\n\n/**\n * The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes\n * it: a band of ones over the noise's middle tones, one step wide at no density and half the\n * steps at full. Figma works it out in 32-bit floats, as it stores the density.\n */\nexport function noiseDensityTable(density: number, mirrored = false): string {\n const stored = Math.fround(density)\n const start = Math.floor(25 - 25 * stored)\n const count = Math.floor(50 * stored) + 1\n const steps = Array.from({ length: NOISE_TABLE_STEPS }, (_, step) =>\n step >= start && step < start + count ? 1 : 0\n )\n return (mirrored ? steps.reverse() : steps).join(' ')\n}\n\n/**\n * A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a\n * cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its\n * second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the\n * result's name.\n */\nexport function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: string): string {\n const grain = effect.noise\n const noise = filter.result('noise')\n filter.push('feTurbulence', {\n type: 'fractalNoise',\n baseFrequency: grainFrequency(grain.noiseSize),\n stitchTiles: 'stitch',\n numOctaves: 3,\n seed: grain.seed ?? 0,\n result: noise\n })\n const merged = filter.result('noiseMerge')\n if (grain.noiseType === 'MULTITONE') {\n const colored = filter.result('multitone')\n const linear = { type: 'linear', slope: 2, intercept: -0.5 }\n filter.push(\n 'feComponentTransfer',\n { in: noise, result: colored },\n svg('feFuncR', linear),\n svg('feFuncG', linear),\n svg('feFuncB', linear),\n svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density) })\n )\n const clipped = filter.result('noiseClipped')\n filter.push('feComposite', { in: colored, in2: input, operator: 'in', result: clipped })\n const faded = filter.result('noiseColor')\n filter.push(\n 'feComponentTransfer',\n { in: clipped, result: faded },\n svg('feFuncA', { type: 'table', tableValues: `0 ${round(grain.opacity ?? 1)}` })\n )\n filter.pushElement('feMerge', { result: merged }, mergeNodes([input, faded]))\n return merged\n }\n\n const alpha = filter.result('alphaNoise')\n filter.push('feColorMatrix', { in: noise, type: 'luminanceToAlpha', result: alpha })\n const tones = [{ color: effect.color, mirrored: false }]\n if (grain.noiseType === 'DUOTONE') {\n tones.push({ color: grain.secondaryColor ?? effect.color, mirrored: true })\n }\n const colors = tones.map(({ color, mirrored }) => {\n const band = filter.result('noiseBand')\n filter.push(\n 'feComponentTransfer',\n { in: alpha, result: band },\n svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density, mirrored) })\n )\n const clipped = filter.result('noiseClipped')\n filter.push('feComposite', { in: band, in2: input, operator: 'in', result: clipped })\n const flood = filter.result('noiseFlood')\n filter.push('feFlood', {\n 'flood-color': floodColor(color, filter.colorSpace, filter.documentColorSpace),\n 'flood-opacity': round(color.a),\n result: flood\n })\n const colored = filter.result('noiseColor')\n filter.push('feComposite', { in: flood, in2: clipped, operator: 'in', result: colored })\n return colored\n })\n filter.pushElement('feMerge', { result: merged }, mergeNodes([input, ...colors]))\n return merged\n}\n\nfunction mergeNodes(inputs: readonly string[]) {\n return inputs.map((input) => svg('feMergeNode', { in: input }))\n}\n\n/**\n * A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal\n * noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to\n * its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.\n * Returns the result's name.\n */\nexport function textureFilter(filter: FilterBuilder, effect: TextureEffect, input: string): string {\n const grain = effect.texture\n const frequency = grainFrequency(grain.noiseSize)\n const scale = round(effect.radius * 2)\n const name = (label: string) => filter.result(label)\n const displace = (into: string, by: string, result: string) =>\n filter.push('feDisplacementMap', {\n in: into,\n in2: by,\n scale,\n xChannelSelector: 'R',\n yChannelSelector: 'G',\n width: '100%',\n height: '100%',\n result\n })\n const turbulence = (seed: number, result: string) =>\n filter.push('feTurbulence', {\n type: 'fractalNoise',\n baseFrequency: frequency,\n numOctaves: 3,\n seed: (grain.seed ?? 0) + seed,\n result\n })\n const matrix = (into: string, values: string, result: string) =>\n filter.push('feColorMatrix', { in: into, type: 'matrix', values, result })\n const arithmetic = (\n into: string,\n by: string,\n k: [number, number, number, number],\n result: string\n ) =>\n filter.push('feComposite', {\n in: into,\n in2: by,\n operator: 'arithmetic',\n k1: k[0],\n k2: k[1],\n k3: k[2],\n k4: k[3],\n result\n })\n const composite = (into: string, by: string, operator: string, result: string) =>\n filter.push('feComposite', { in: into, in2: by, operator, result })\n const gamma = (into: string, result: string) =>\n filter.push(\n 'feComponentTransfer',\n { in: into, result },\n svg('feFuncA', { type: 'gamma', exponent: 0.2 })\n )\n\n if (!grain.clipToShape) {\n const noise = name('textureNoise')\n turbulence(0, noise)\n const displaced = name('texture')\n displace(input, noise, displaced)\n return displaced\n }\n\n const noiseX = name('displacementX')\n const noiseY = name('displacementY')\n turbulence(0, noiseX)\n turbulence(1, noiseY)\n const xRed = name('displacementXRed')\n matrix(noiseX, ALPHA_TO_RED, xRed)\n const yGreen = name('displacementYGreen')\n matrix(noiseY, ALPHA_TO_GREEN, yGreen)\n const xy = name('displacementXY')\n arithmetic(xRed, yGreen, [0, 1, 1, 0], xy)\n const firstPass = name('firstPass')\n displace(input, xy, firstPass)\n const firstAlpha = name('firstPassAlpha')\n matrix(firstPass, ALPHA_ONLY, firstAlpha)\n const displacedAlpha = name('sourceDisplacedAlpha')\n gamma(firstAlpha, displacedAlpha)\n const inputAlphaOnly = name('inputAlphaOnly')\n matrix(input, ALPHA_ONLY, inputAlphaOnly)\n const inputAlpha = name('inputSourceAlpha')\n gamma(inputAlphaOnly, inputAlpha)\n const alphas = name('displacementAlphasMultiplied')\n arithmetic(displacedAlpha, inputAlpha, [1, 0, 0, 0], alphas)\n const centering = name('centeringAdjustment')\n arithmetic(alphas, alphas, [0, 0, -0.5, 0.5], centering)\n\n const finalChannel = (noise: string, values: string, label: string) => {\n const weighted = name(`${label}Weighted`)\n arithmetic(noise, alphas, [1, 0, 0, 0], weighted)\n const centered = name(`${label}Centered`)\n arithmetic(centering, weighted, [0, 1, 1, 0], centered)\n const final = name(`${label}Final`)\n matrix(centered, values, final)\n return final\n }\n const xFinal = finalChannel(noiseX, ALPHA_TO_RED, 'displacementX')\n const yFinal = finalChannel(noiseY, ALPHA_TO_GREEN, 'displacementY')\n const combined = name('displacementCombined')\n arithmetic(xFinal, yFinal, [0, 1, 1, 0], combined)\n const map = name('displacementMap')\n composite(combined, alphas, 'in', map)\n const neutral = name('neutral')\n filter.push('feFlood', {\n 'flood-color': 'rgb(127, 127, 127)',\n 'flood-opacity': 1,\n result: neutral\n })\n const outside = name('neutralOutside')\n composite(neutral, alphas, 'out', outside)\n const mapWithBackground = name('displacementMapWithBg')\n composite(outside, map, 'over', mapWithBackground)\n\n const displaced = name('displacedImage')\n displace(input, mapWithBackground, displaced)\n const opaque = name('imageOpaque')\n matrix(input, OPAQUE, opaque)\n const displacedOpaque = name('displacedImageOpaque')\n displace(opaque, mapWithBackground, displacedOpaque)\n const displacedRed = name('displacedImageRed')\n matrix(displaced, ALPHA_TO_RED_OPAQUE, displacedRed)\n const inputRed = name('inputRed')\n matrix(input, ALPHA_TO_RED_OPAQUE, inputRed)\n const transparencyRed = name('transparencyRedMap')\n composite(displacedRed, inputRed, 'atop', transparencyRed)\n const transparency = name('transparencyAlphaMap')\n matrix(transparencyRed, RED_TO_ALPHA, transparency)\n const layered = name('textureLayered')\n composite(displacedOpaque, opaque, 'over', layered)\n const textured = name('texture')\n composite(layered, transparency, 'in', textured)\n return textured\n}\n"],"mappings":";;;;;AAQA,MAAM,oBAAoB;;AAG1B,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAM,SAAS;AACf,MAAM,sBAAsB;AAC5B,MAAM,eAAe;;AAGrB,SAAS,eAAe,MAAsB;CAC5C,MAAM,aAAa,WAAoB,SAAS,IAAI,MAAM,IAAI,QAAQ,CAAC,IAAI;CAC3E,OAAO,GAAG,UAAU,KAAK,CAAC,EAAE,GAAG,UAAU,KAAK,CAAC;AACjD;;;;;;AAOA,SAAgB,kBAAkB,SAAiB,WAAW,OAAe;CAC3E,MAAM,SAAS,KAAK,OAAO,OAAO;CAClC,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,MAAM;CACzC,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,IAAI;CACxC,MAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,kBAAkB,IAAI,GAAG,SAC1D,QAAQ,SAAS,OAAO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AG;CACrC,MAAM,UAAU,KAAK,SAAS;CAC9B,OAAO,KAAK,WAAW;EACrB,eAAe;EACf,iBAAiB;EACjB,QAAQ;CACV,CAAC;CACD,MAAM,UAAU,KAAK,gBAAgB;CACrC,UAAU,SAAS,QAAQ,OAAO,OAAO;CACzC,MAAM,oBAAoB,KAAK,uBAAuB;CACtD,UAAU,SAAS,KAAK,QAAQ,iBAAiB;CAEjD,MAAM,YAAY,KAAK,gBAAgB;CACvC,SAAS,OAAO,mBAAmB,SAAS;CAC5C,MAAM,SAAS,KAAK,aAAa;CACjC,OAAO,OAAO,QAAQ,MAAM;CAC5B,MAAM,kBAAkB,KAAK,sBAAsB;CACnD,SAAS,QAAQ,mBAAmB,eAAe;CACnD,MAAM,eAAe,KAAK,mBAAmB;CAC7C,OAAO,WAAW,qBAAqB,YAAY;CACnD,MAAM,WAAW,KAAK,UAAU;CAChC,OAAO,OAAO,qBAAqB,QAAQ;CAC3C,MAAM,kBAAkB,KAAK,oBAAoB;CACjD,UAAU,cAAc,UAAU,QAAQ,eAAe;CACzD,MAAM,eAAe,KAAK,sBAAsB;CAChD,OAAO,iBAAiB,cAAc,YAAY;CAClD,MAAM,UAAU,KAAK,gBAAgB;CACrC,UAAU,iBAAiB,QAAQ,QAAQ,OAAO;CAClD,MAAM,WAAW,KAAK,SAAS;CAC/B,UAAU,SAAS,cAAc,MAAM,QAAQ;CAC/C,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SVGVectorizeResult } from "../../../vector/vectorize/svg/to-vectors.js";
|
|
2
|
-
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
import { DocumentColorSpace, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
3
3
|
import { Size } from "@pairdraw/scene-graph/primitives";
|
|
4
4
|
//#region src/io/formats/svg/import.d.ts
|
|
5
5
|
type SVGImportData = SVGVectorizeResult & Size & {
|
|
@@ -11,13 +11,15 @@ type SVGImportData = SVGVectorizeResult & Size & {
|
|
|
11
11
|
interface SVGImportOptions {
|
|
12
12
|
name?: string;
|
|
13
13
|
defaultColor?: string;
|
|
14
|
+
/** The profile a color that names its own space is read into. */
|
|
15
|
+
profile?: DocumentColorSpace;
|
|
14
16
|
x?: number;
|
|
15
17
|
y?: number;
|
|
16
18
|
/** Keep the frame of an SVG that draws nothing, as `figma.createNodeFromSvg` does. */
|
|
17
19
|
keepEmpty?: boolean;
|
|
18
20
|
}
|
|
19
21
|
/** The layers SVG markup draws, or null when it does not parse as SVG. */
|
|
20
|
-
declare function prepareSVGImport(source: string, options?: Pick<SVGImportOptions, 'defaultColor'>): SVGImportData | null;
|
|
22
|
+
declare function prepareSVGImport(source: string, options?: Pick<SVGImportOptions, 'defaultColor' | 'profile'>): SVGImportData | null;
|
|
21
23
|
declare function createSVGNodesFromImport(graph: SceneGraph, parentId: string, data: SVGImportData, options?: SVGImportOptions): SceneNode | null;
|
|
22
24
|
declare function createSVGNodes(graph: SceneGraph, parentId: string, source: string, options?: SVGImportOptions): SceneNode | null;
|
|
23
25
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","names":[],"sources":["../../../../src/io/formats/svg/import.ts"],"mappings":";;;;KAsBY,gBAAgB,qBAC1B;;EAEE;;EAEA;;UAGa;EACf;EACA;
|
|
1
|
+
{"version":3,"file":"import.d.ts","names":[],"sources":["../../../../src/io/formats/svg/import.ts"],"mappings":";;;;KAsBY,gBAAgB,qBAC1B;;EAEE;;EAEA;;UAGa;EACf;EACA;;EAEA,UAAU;EACV;EACA;;EAEA;;;iBAIc,iBACd,gBACA,UAAS,KAAK,gDACb;iBAiIa,yBACd,OAAO,YACP,kBACA,MAAM,eACN,UAAS,mBACR;iBA4Ba,eACd,OAAO,YACP,kBACA,gBACA,UAAS,mBACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","names":["BLACK"],"sources":["../../../../src/io/formats/svg/import.ts"],"sourcesContent":["import { groupBy } from 'es-toolkit/array'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport { fitEnclosingGroups } from '@pairdraw/scene-graph/group-bounds'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { BLACK } from '#core/constants'\nimport type { SVGElementLayer } from '#core/icons/types'\nimport { createPlacedVector, vectorizedPathPaints } from '#core/vector/vectorize/placement'\nimport {\n svgToVectorPaths,\n type SVGVectorizeResult,\n type VectorizedClip,\n type VectorizedPath,\n type VectorizedText\n} from '#core/vector/vectorize/svg/to-vectors'\n\nimport { parseSVGDocument } from './document'\nimport { parseSVGSize, svgRootId } from './metadata'\nimport { createSVGText } from './text/import'\n\nexport type SVGImportData = SVGVectorizeResult &\n Size & {\n /** The root `<svg>` element's `id`, which names the imported layer. */\n name: string | null\n /** Without a width, height, or viewBox the SVG has no frame, only a group of its layers. */\n sized: boolean\n }\n\nexport interface SVGImportOptions {\n name?: string\n defaultColor?: string\n x?: number\n y?: number\n /** Keep the frame of an SVG that draws nothing, as `figma.createNodeFromSvg` does. */\n keepEmpty?: boolean\n}\n\n/** The layers SVG markup draws, or null when it does not parse as SVG. */\nexport function prepareSVGImport(\n source: string,\n options: Pick<SVGImportOptions, 'defaultColor'> = {}\n): SVGImportData | null {\n if (!parseSVGDocument(source)) return null\n const sized = parseSVGSize(source, { width: 0, height: 0 }).width > 0\n const { width, height } = parseSVGSize(source)\n const vectorized = svgToVectorPaths(\n source,\n { width, height },\n {\n defaultColor: options.defaultColor,\n preserveAspectRatio: true\n }\n ) ?? { paths: [], texts: [], contentBounds: { x: 0, y: 0, width: 0, height: 0 } }\n return { width, height, name: svgRootId(source), sized, ...vectorized }\n}\n\nfunction createGroup(graph: SceneGraph, parentId: string, props: Partial<SceneNode>): string {\n return graph.createNode('GROUP', parentId, { x: 0, y: 0, ...props }).id\n}\n\n/** Figma's clip wrapper: a mask group drawn from the clip's shapes, then the clipped content. */\nfunction createClipGroup(\n graph: SceneGraph,\n parentId: string,\n clip: VectorizedClip,\n parentIds: Set<string>\n): string {\n const groupId = createGroup(graph, parentId, { name: 'Clip path group' })\n const maskId = createGroup(graph, groupId, {\n name: clip.id,\n isMask: true,\n maskType: 'VECTOR',\n visible: clip.visible\n })\n for (const shape of clip.shapes) {\n createPlacedVector(graph, maskId, shape.network, {\n name: 'Vector',\n visible: shape.visible,\n fills: [{ type: 'SOLID', color: BLACK, opacity: 1, visible: true }]\n })\n }\n parentIds.add(maskId)\n return groupId\n}\n\nfunction clipFor(\n clips: VectorizedClip[] | undefined,\n element: SVGElementLayer\n): VectorizedClip | null {\n const clip = element.clip === null ? null : clips?.[element.clip]\n return clip && clip.shapes.length > 0 ? clip : null\n}\n\n/** A path or a text, with the elements it was drawn in. */\ninterface Drawable {\n elements: SVGElementLayer[]\n clips?: VectorizedClip[]\n create: (parentId: string, element: SVGElementLayer) => void\n}\n\n/** Paths and texts in drawing order: each text goes before the path it preceded. */\nfunction drawables(graph: SceneGraph, data: SVGImportData, parentIds: Set<string>): Drawable[] {\n const pathDrawable = (path: VectorizedPath): Drawable => ({\n elements: path.elements,\n clips: path.clips,\n create: (parentId, element) => {\n const vector = createPlacedVector(graph, parentId, path.vectorNetwork, {\n name: element.name ?? 'Vector',\n opacity: element.opacity,\n visible: element.visible,\n ...vectorizedPathPaints(path)\n })\n if (vector) parentIds.add(parentId)\n }\n })\n const textDrawable = (text: VectorizedText): Drawable => ({\n elements: text.elements,\n clips: text.clips,\n create: (parentId, element) => {\n createSVGText(graph, parentId, text, element, (groupParentId, props) => {\n const groupId = createGroup(graph, groupParentId, props)\n parentIds.add(groupId)\n return groupId\n })\n parentIds.add(parentId)\n }\n })\n const textsByPath = groupBy(data.texts, (text) => text.pathIndex)\n const textsAt = (index: number) => (textsByPath[index] ?? []).map(textDrawable)\n return [\n ...data.paths.flatMap((path, index) => [...textsAt(index), pathDrawable(path)]),\n ...textsAt(data.paths.length)\n ]\n}\n\n/**\n * Builds the layers Figma makes from SVG: a group per `<g>`, a vector per shape and a text layer\n * per text, each named by its `id`, and a clip group around anything clipped. Groups are fitted\n * to their layers last.\n */\nfunction createSVGLayers(graph: SceneGraph, rootId: string, data: SVGImportData): void {\n const open: Array<{ key: number; parentId: string }> = []\n const parentIds = new Set<string>()\n for (const drawable of drawables(graph, data, parentIds)) {\n const groups = drawable.elements.slice(0, -1)\n const shape = drawable.elements.at(-1)\n if (!shape) continue\n let depth = 0\n while (depth < open.length && depth < groups.length && open[depth].key === groups[depth].key) {\n depth++\n }\n open.length = depth\n let parentId = open.at(-1)?.parentId ?? rootId\n for (const element of groups.slice(depth)) {\n const clip = clipFor(drawable.clips, element)\n if (clip) parentId = createClipGroup(graph, parentId, clip, parentIds)\n parentId = createGroup(graph, parentId, {\n name: element.name ?? 'Group',\n opacity: element.opacity,\n visible: element.visible\n })\n open.push({ key: element.key, parentId })\n }\n const clip = clipFor(drawable.clips, shape)\n drawable.create(clip ? createClipGroup(graph, parentId, clip, parentIds) : parentId, shape)\n }\n fitEnclosingGroups(graph, [...parentIds])\n}\n\nexport function createSVGNodesFromImport(\n graph: SceneGraph,\n parentId: string,\n data: SVGImportData,\n options: SVGImportOptions = {}\n): SceneNode | null {\n const position = { x: options.x ?? 0, y: options.y ?? 0 }\n const root = data.sized\n ? graph.createNode('FRAME', parentId, {\n name: options.name ?? data.name ?? 'Frame',\n ...position,\n width: data.width,\n height: data.height,\n fills: [{ type: 'SOLID', color: WHITE, opacity: 1, visible: true }],\n clipsContent: true\n })\n : graph.createNode('GROUP', parentId, {\n name: options.name ?? data.name ?? 'Group',\n ...position\n })\n\n try {\n createSVGLayers(graph, root.id, data)\n const created = graph.getNode(root.id)\n if (created && (options.keepEmpty || graph.getChildren(root.id).length > 0)) return created\n if (created) graph.deleteNode(root.id)\n return null\n } catch (error) {\n graph.deleteNode(root.id)\n throw error\n }\n}\n\nexport function createSVGNodes(\n graph: SceneGraph,\n parentId: string,\n source: string,\n options: SVGImportOptions = {}\n): SceneNode | null {\n const data = prepareSVGImport(source, options)\n return data ? createSVGNodesFromImport(graph, parentId, data, options) : null\n}\n"],"mappings":";;;;;;;;;;;AAwCA,SAAgB,iBACd,QACA,UAAkD,CAAC,GAC7B;CACtB,IAAI,CAAC,iBAAiB,MAAM,GAAG,OAAO;CACtC,MAAM,QAAQ,aAAa,QAAQ;EAAE,OAAO;EAAG,QAAQ;CAAE,CAAC,CAAC,CAAC,QAAQ;CACpE,MAAM,EAAE,OAAO,WAAW,aAAa,MAAM;CAC7C,MAAM,aAAa,iBACjB,QACA;EAAE;EAAO;CAAO,GAChB;EACE,cAAc,QAAQ;EACtB,qBAAqB;CACvB,CACF,KAAK;EAAE,OAAO,CAAC;EAAG,OAAO,CAAC;EAAG,eAAe;GAAE,GAAG;GAAG,GAAG;GAAG,OAAO;GAAG,QAAQ;EAAE;CAAE;CAChF,OAAO;EAAE;EAAO;EAAQ,MAAM,UAAU,MAAM;EAAG;EAAO,GAAG;CAAW;AACxE;AAEA,SAAS,YAAY,OAAmB,UAAkB,OAAmC;CAC3F,OAAO,MAAM,WAAW,SAAS,UAAU;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;CAAM,CAAC,CAAC,CAAC;AACvE;;AAGA,SAAS,gBACP,OACA,UACA,MACA,WACQ;CACR,MAAM,UAAU,YAAY,OAAO,UAAU,EAAE,MAAM,kBAAkB,CAAC;CACxE,MAAM,SAAS,YAAY,OAAO,SAAS;EACzC,MAAM,KAAK;EACX,QAAQ;EACR,UAAU;EACV,SAAS,KAAK;CAChB,CAAC;CACD,KAAK,MAAM,SAAS,KAAK,QACvB,mBAAmB,OAAO,QAAQ,MAAM,SAAS;EAC/C,MAAM;EACN,SAAS,MAAM;EACf,OAAO,CAAC;GAAE,MAAM;GAAS,OAAOA;GAAO,SAAS;GAAG,SAAS;EAAK,CAAC;CACpE,CAAC;CAEH,UAAU,IAAI,MAAM;CACpB,OAAO;AACT;AAEA,SAAS,QACP,OACA,SAC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QAAQ,KAAK,EAAE;EACrC,IAAI,YAAY,QAAQ,aAAa,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC,SAAS,IAAI,OAAO;EACpF,IAAI,SAAS,MAAM,WAAW,KAAK,EAAE;EACrC,OAAO;CACT,SAAS,OAAO;EACd,MAAM,WAAW,KAAK,EAAE;EACxB,MAAM;CACR;AACF;AAEA,SAAgB,eACd,OACA,UACA,QACA,UAA4B,CAAC,GACX;CAClB,MAAM,OAAO,iBAAiB,QAAQ,OAAO;CAC7C,OAAO,OAAO,yBAAyB,OAAO,UAAU,MAAM,OAAO,IAAI;AAC3E"}
|
|
1
|
+
{"version":3,"file":"import.js","names":["BLACK"],"sources":["../../../../src/io/formats/svg/import.ts"],"sourcesContent":["import { groupBy } from 'es-toolkit/array'\n\nimport type { DocumentColorSpace, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport { fitEnclosingGroups } from '@pairdraw/scene-graph/group-bounds'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { BLACK } from '#core/constants'\nimport type { SVGElementLayer } from '#core/icons/types'\nimport { createPlacedVector, vectorizedPathPaints } from '#core/vector/vectorize/placement'\nimport {\n svgToVectorPaths,\n type SVGVectorizeResult,\n type VectorizedClip,\n type VectorizedPath,\n type VectorizedText\n} from '#core/vector/vectorize/svg/to-vectors'\n\nimport { parseSVGDocument } from './document'\nimport { parseSVGSize, svgRootId } from './metadata'\nimport { createSVGText } from './text/import'\n\nexport type SVGImportData = SVGVectorizeResult &\n Size & {\n /** The root `<svg>` element's `id`, which names the imported layer. */\n name: string | null\n /** Without a width, height, or viewBox the SVG has no frame, only a group of its layers. */\n sized: boolean\n }\n\nexport interface SVGImportOptions {\n name?: string\n defaultColor?: string\n /** The profile a color that names its own space is read into. */\n profile?: DocumentColorSpace\n x?: number\n y?: number\n /** Keep the frame of an SVG that draws nothing, as `figma.createNodeFromSvg` does. */\n keepEmpty?: boolean\n}\n\n/** The layers SVG markup draws, or null when it does not parse as SVG. */\nexport function prepareSVGImport(\n source: string,\n options: Pick<SVGImportOptions, 'defaultColor' | 'profile'> = {}\n): SVGImportData | null {\n if (!parseSVGDocument(source)) return null\n const sized = parseSVGSize(source, { width: 0, height: 0 }).width > 0\n const { width, height } = parseSVGSize(source)\n const vectorized = svgToVectorPaths(\n source,\n { width, height },\n {\n defaultColor: options.defaultColor,\n preserveAspectRatio: true,\n profile: options.profile\n }\n ) ?? { paths: [], texts: [], contentBounds: { x: 0, y: 0, width: 0, height: 0 } }\n return { width, height, name: svgRootId(source), sized, ...vectorized }\n}\n\nfunction createGroup(graph: SceneGraph, parentId: string, props: Partial<SceneNode>): string {\n return graph.createNode('GROUP', parentId, { x: 0, y: 0, ...props }).id\n}\n\n/** Figma's clip wrapper: a mask group drawn from the clip's shapes, then the clipped content. */\nfunction createClipGroup(\n graph: SceneGraph,\n parentId: string,\n clip: VectorizedClip,\n parentIds: Set<string>\n): string {\n const groupId = createGroup(graph, parentId, { name: 'Clip path group' })\n const maskId = createGroup(graph, groupId, {\n name: clip.id,\n isMask: true,\n maskType: 'VECTOR',\n visible: clip.visible\n })\n for (const shape of clip.shapes) {\n createPlacedVector(graph, maskId, shape.network, {\n name: 'Vector',\n visible: shape.visible,\n fills: [{ type: 'SOLID', color: BLACK, opacity: 1, visible: true }]\n })\n }\n parentIds.add(maskId)\n return groupId\n}\n\nfunction clipFor(\n clips: VectorizedClip[] | undefined,\n element: SVGElementLayer\n): VectorizedClip | null {\n const clip = element.clip === null ? null : clips?.[element.clip]\n return clip && clip.shapes.length > 0 ? clip : null\n}\n\n/** A path or a text, with the elements it was drawn in. */\ninterface Drawable {\n elements: SVGElementLayer[]\n clips?: VectorizedClip[]\n create: (parentId: string, element: SVGElementLayer) => void\n}\n\n/** Paths and texts in drawing order: each text goes before the path it preceded. */\nfunction drawables(graph: SceneGraph, data: SVGImportData, parentIds: Set<string>): Drawable[] {\n const pathDrawable = (path: VectorizedPath): Drawable => ({\n elements: path.elements,\n clips: path.clips,\n create: (parentId, element) => {\n const vector = createPlacedVector(graph, parentId, path.vectorNetwork, {\n name: element.name ?? 'Vector',\n opacity: element.opacity,\n visible: element.visible,\n ...vectorizedPathPaints(path)\n })\n if (vector) parentIds.add(parentId)\n }\n })\n const textDrawable = (text: VectorizedText): Drawable => ({\n elements: text.elements,\n clips: text.clips,\n create: (parentId, element) => {\n createSVGText(graph, parentId, text, element, (groupParentId, props) => {\n const groupId = createGroup(graph, groupParentId, props)\n parentIds.add(groupId)\n return groupId\n })\n parentIds.add(parentId)\n }\n })\n const textsByPath = groupBy(data.texts, (text) => text.pathIndex)\n const textsAt = (index: number) => (textsByPath[index] ?? []).map(textDrawable)\n return [\n ...data.paths.flatMap((path, index) => [...textsAt(index), pathDrawable(path)]),\n ...textsAt(data.paths.length)\n ]\n}\n\n/**\n * Builds the layers Figma makes from SVG: a group per `<g>`, a vector per shape and a text layer\n * per text, each named by its `id`, and a clip group around anything clipped. Groups are fitted\n * to their layers last.\n */\nfunction createSVGLayers(graph: SceneGraph, rootId: string, data: SVGImportData): void {\n const open: Array<{ key: number; parentId: string }> = []\n const parentIds = new Set<string>()\n for (const drawable of drawables(graph, data, parentIds)) {\n const groups = drawable.elements.slice(0, -1)\n const shape = drawable.elements.at(-1)\n if (!shape) continue\n let depth = 0\n while (depth < open.length && depth < groups.length && open[depth].key === groups[depth].key) {\n depth++\n }\n open.length = depth\n let parentId = open.at(-1)?.parentId ?? rootId\n for (const element of groups.slice(depth)) {\n const clip = clipFor(drawable.clips, element)\n if (clip) parentId = createClipGroup(graph, parentId, clip, parentIds)\n parentId = createGroup(graph, parentId, {\n name: element.name ?? 'Group',\n opacity: element.opacity,\n visible: element.visible\n })\n open.push({ key: element.key, parentId })\n }\n const clip = clipFor(drawable.clips, shape)\n drawable.create(clip ? createClipGroup(graph, parentId, clip, parentIds) : parentId, shape)\n }\n fitEnclosingGroups(graph, [...parentIds])\n}\n\nexport function createSVGNodesFromImport(\n graph: SceneGraph,\n parentId: string,\n data: SVGImportData,\n options: SVGImportOptions = {}\n): SceneNode | null {\n const position = { x: options.x ?? 0, y: options.y ?? 0 }\n const root = data.sized\n ? graph.createNode('FRAME', parentId, {\n name: options.name ?? data.name ?? 'Frame',\n ...position,\n width: data.width,\n height: data.height,\n fills: [{ type: 'SOLID', color: WHITE, opacity: 1, visible: true }],\n clipsContent: true\n })\n : graph.createNode('GROUP', parentId, {\n name: options.name ?? data.name ?? 'Group',\n ...position\n })\n\n try {\n createSVGLayers(graph, root.id, data)\n const created = graph.getNode(root.id)\n if (created && (options.keepEmpty || graph.getChildren(root.id).length > 0)) return created\n if (created) graph.deleteNode(root.id)\n return null\n } catch (error) {\n graph.deleteNode(root.id)\n throw error\n }\n}\n\nexport function createSVGNodes(\n graph: SceneGraph,\n parentId: string,\n source: string,\n options: SVGImportOptions = {}\n): SceneNode | null {\n const data = prepareSVGImport(source, options)\n return data ? createSVGNodesFromImport(graph, parentId, data, options) : null\n}\n"],"mappings":";;;;;;;;;;;AA0CA,SAAgB,iBACd,QACA,UAA8D,CAAC,GACzC;CACtB,IAAI,CAAC,iBAAiB,MAAM,GAAG,OAAO;CACtC,MAAM,QAAQ,aAAa,QAAQ;EAAE,OAAO;EAAG,QAAQ;CAAE,CAAC,CAAC,CAAC,QAAQ;CACpE,MAAM,EAAE,OAAO,WAAW,aAAa,MAAM;CAC7C,MAAM,aAAa,iBACjB,QACA;EAAE;EAAO;CAAO,GAChB;EACE,cAAc,QAAQ;EACtB,qBAAqB;EACrB,SAAS,QAAQ;CACnB,CACF,KAAK;EAAE,OAAO,CAAC;EAAG,OAAO,CAAC;EAAG,eAAe;GAAE,GAAG;GAAG,GAAG;GAAG,OAAO;GAAG,QAAQ;EAAE;CAAE;CAChF,OAAO;EAAE;EAAO;EAAQ,MAAM,UAAU,MAAM;EAAG;EAAO,GAAG;CAAW;AACxE;AAEA,SAAS,YAAY,OAAmB,UAAkB,OAAmC;CAC3F,OAAO,MAAM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CAAC;AAC1C;AAEA,SAAgB,yBACd,OACA,UACA,MACA,UAA4B,CAAC,GACX;CAClB,MAAM,WAAW;EAAE,GAAG,QAAQ,KAAK;EAAG,GAAG,QAAQ,KAAK;CAAE;CACxD,MAAM,OAAO,KAAK,QACd,MAAM,WAAW,SAAS,UAAU;EAClC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;EACnC,GAAG;EACH,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,OAAO,CAAC;GAAE,MAAM;GAAS,OAAO;GAAO,SAAS;GAAG,SAAS;EAAK,CAAC;EAClE,cAAc;CAChB,CAAC,IACD,MAAM,WAAW,SAAS,UAAU;EAClC,MAAM,QAAQ,QAAQ,KAAK,QAAQ;EACnC,GAAG;CACL,CAAC;CAEL,IAAI;EACF,gBAAgB,OAAO,KAAK,IAAI,IAAI;EACpC,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE;EACrC,IAAI,YAAY,QAAQ,aAAa,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC,SAAS,IAAI,OAAO;EACpF,IAAI,SAAS,MAAM,WAAW,KAAK,EAAE;EACrC,OAAO;CACT,SAAS,OAAO;EACd,MAAM,WAAW,KAAK,EAAE;EACxB,MAAM;CACR;AACF;AAEA,SAAgB,eACd,OACA,UACA,QACA,UAA4B,CAAC,GACX;CAClB,MAAM,OAAO,iBAAiB,QAAQ,OAAO;CAC7C,OAAO,OAAO,yBAAyB,OAAO,UAAU,MAAM,OAAO,IAAI;AAC3E"}
|
|
@@ -9,7 +9,7 @@ declare function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Str
|
|
|
9
9
|
* A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its
|
|
10
10
|
* weight and clipped to the outline, or to everything around it.
|
|
11
11
|
*/
|
|
12
|
-
declare function alignedStrokeElement(node: SceneNode, stroke: Stroke, strokeAttrs: Attrs, ctx: SVGExportContext): SVGNode[];
|
|
12
|
+
declare function alignedStrokeElement(node: SceneNode, stroke: Stroke, strokeAttrs: Attrs, ctx: SVGExportContext, outline?: string | null): SVGNode[];
|
|
13
13
|
/**
|
|
14
14
|
* A FigJam shape's inner lines, such as a database's front rim, stroked as the canvas strokes
|
|
15
15
|
* them: at the stroke's own weight whatever its alignment, ending where the outline does.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;KAaK,QAAQ;;iBA0BG,cAAc,MAAM,WAAW,QAAQ,qBAAqB;;;;;iBAS5D,qBACd,MAAM,WACN,QAAQ,QACR,aAAa,OACb,KAAK,
|
|
1
|
+
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;KAaK,QAAQ;;iBA0BG,cAAc,MAAM,WAAW,QAAQ,qBAAqB;;;;;iBAS5D,qBACd,MAAM,WACN,QAAQ,QACR,aAAa,OACb,KAAK,kBACL,0BACC;;;;;iBAiCa,4BACd,MAAM,WACN,aAAa,OACb,KAAK,mBACJ"}
|
|
@@ -28,8 +28,7 @@ function alignedStroke(node, stroke) {
|
|
|
28
28
|
* A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its
|
|
29
29
|
* weight and clipped to the outline, or to everything around it.
|
|
30
30
|
*/
|
|
31
|
-
function alignedStrokeElement(node, stroke, strokeAttrs, ctx) {
|
|
32
|
-
const outline = closedOutlinePath(node);
|
|
31
|
+
function alignedStrokeElement(node, stroke, strokeAttrs, ctx, outline = closedOutlinePath(node)) {
|
|
33
32
|
if (outline === null) return [];
|
|
34
33
|
const clipId = nextDefId(ctx, "clip");
|
|
35
34
|
if (stroke.align === "INSIDE") ctx.defs.push(svg("clipPath", { id: clipId }, svg("path", { d: outline })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {\n boxOutlinePath,\n nodeOutlinePath,\n round,\n shapeWithTextDetailsPath,\n shapeWithTextOutlinePath\n} from './paths'\n\ntype Attrs = Record<string, string | number | undefined>\n\n/**\n * The closed outline an aligned stroke follows, as path data in the layer's box: a FigJam shape's,\n * an ellipse, polygon or star, or a box with its corners for any other layer. Null for lines,\n * arcs, and vectors, whose strokes the canvas centres on their paths.\n */\nfunction closedOutlinePath(node: SceneNode): string | null {\n switch (node.type) {\n case 'LINE':\n case 'VECTOR':\n case 'BOOLEAN_OPERATION':\n return null\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextOutlinePath(node)\n case 'ELLIPSE':\n return node.arcData ? null : nodeOutlinePath(node)\n case 'POLYGON':\n case 'STAR':\n return nodeOutlinePath(node)\n default:\n return boxOutlinePath(node)\n }\n}\n\n/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */\nexport function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Stroke | null {\n if (!stroke || stroke.align === 'CENTER') return null\n return closedOutlinePath(node) === null ? null : stroke\n}\n\n/**\n * A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its\n * weight and clipped to the outline, or to everything around it.\n */\nexport function alignedStrokeElement(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n
|
|
1
|
+
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {\n boxOutlinePath,\n nodeOutlinePath,\n round,\n shapeWithTextDetailsPath,\n shapeWithTextOutlinePath\n} from './paths'\n\ntype Attrs = Record<string, string | number | undefined>\n\n/**\n * The closed outline an aligned stroke follows, as path data in the layer's box: a FigJam shape's,\n * an ellipse, polygon or star, or a box with its corners for any other layer. Null for lines,\n * arcs, and vectors, whose strokes the canvas centres on their paths.\n */\nfunction closedOutlinePath(node: SceneNode): string | null {\n switch (node.type) {\n case 'LINE':\n case 'VECTOR':\n case 'BOOLEAN_OPERATION':\n return null\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextOutlinePath(node)\n case 'ELLIPSE':\n return node.arcData ? null : nodeOutlinePath(node)\n case 'POLYGON':\n case 'STAR':\n return nodeOutlinePath(node)\n default:\n return boxOutlinePath(node)\n }\n}\n\n/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */\nexport function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Stroke | null {\n if (!stroke || stroke.align === 'CENTER') return null\n return closedOutlinePath(node) === null ? null : stroke\n}\n\n/**\n * A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its\n * weight and clipped to the outline, or to everything around it.\n */\nexport function alignedStrokeElement(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Attrs,\n ctx: SVGExportContext,\n outline = closedOutlinePath(node)\n): SVGNode[] {\n if (outline === null) return []\n const clipId = nextDefId(ctx, 'clip')\n if (stroke.align === 'INSIDE') {\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: outline })))\n } else {\n // A box wide enough for the stroke, its mitred tips included, with the outline cut out of it.\n // The doubled stroke mitres out to its weight times the miter limit.\n const margin = stroke.weight * Math.max(2, node.strokeMiterLimit)\n const left = round(-margin)\n const top = round(-margin)\n const right = round(node.width + margin)\n const bottom = round(node.height + margin)\n const around = `M${left} ${top}H${right}V${bottom}H${left}Z`\n ctx.defs.push(\n svg('clipPath', { id: clipId }, svg('path', { d: around + outline, 'clip-rule': 'evenodd' }))\n )\n }\n return [\n svg('path', {\n d: outline,\n fill: 'none',\n ...strokeAttrs,\n 'stroke-width': round(stroke.weight * 2),\n 'clip-path': `url(#${clipId})`\n })\n ]\n}\n\n/**\n * A FigJam shape's inner lines, such as a database's front rim, stroked as the canvas strokes\n * them: at the stroke's own weight whatever its alignment, ending where the outline does.\n */\nexport function shapeWithTextDetailElements(\n node: SceneNode,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n const details = strokeAttrs.stroke ? shapeWithTextDetailsPath(node) : null\n if (!details) return []\n const clipId = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: shapeWithTextOutlinePath(node) })))\n return [svg('path', { d: details, fill: 'none', ...strokeAttrs, 'clip-path': `url(#${clipId})` })]\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAS,kBAAkB,MAAgC;CACzD,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK,qBACH,OAAO;EACT,KAAK,mBACH,OAAO,yBAAyB,IAAI;EACtC,KAAK,WACH,OAAO,KAAK,UAAU,OAAO,gBAAgB,IAAI;EACnD,KAAK;EACL,KAAK,QACH,OAAO,gBAAgB,IAAI;EAC7B,SACE,OAAO,eAAe,IAAI;CAC9B;AACF;;AAGA,SAAgB,cAAc,MAAiB,QAA2C;CACxF,IAAI,CAAC,UAAU,OAAO,UAAU,UAAU,OAAO;CACjD,OAAO,kBAAkB,IAAI,MAAM,OAAO,OAAO;AACnD;;;;;AAMA,SAAgB,qBACd,MACA,QACA,aACA,KACA,UAAU,kBAAkB,IAAI,GACrB;CACX,IAAI,YAAY,MAAM,OAAO,CAAC;CAC9B,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,OAAO,UAAU,UACnB,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;MACrE;EAGL,MAAM,SAAS,OAAO,SAAS,KAAK,IAAI,GAAG,KAAK,gBAAgB;EAChE,MAAM,OAAO,MAAM,CAAC,MAAM;EAI1B,MAAM,SAAS,IAAI,KAAK,GAHZ,MAAM,CAAC,MAGU,EAAE,GAFjB,MAAM,KAAK,QAAQ,MAEK,EAAE,GADzB,MAAM,KAAK,SAAS,MACa,EAAE,GAAG,KAAK;EAC1D,IAAI,KAAK,KACP,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ;GAAE,GAAG,SAAS;GAAS,aAAa;EAAU,CAAC,CAAC,CAC9F;CACF;CACA,OAAO,CACL,IAAI,QAAQ;EACV,GAAG;EACH,MAAM;EACN,GAAG;EACH,gBAAgB,MAAM,OAAO,SAAS,CAAC;EACvC,aAAa,QAAQ,OAAO;CAC9B,CAAC,CACH;AACF;;;;;AAMA,SAAgB,4BACd,MACA,aACA,KACW;CACX,MAAM,UAAU,YAAY,SAAS,yBAAyB,IAAI,IAAI;CACtE,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,yBAAyB,IAAI,EAAE,CAAC,CAAC,CAAC;CACjG,OAAO,CAAC,IAAI,QAAQ;EAAE,GAAG;EAAS,MAAM;EAAQ,GAAG;EAAa,aAAa,QAAQ,OAAO;CAAG,CAAC,CAAC;AACnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"export.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"mappings":";;;;iBAwMgB,eACd,MAAM,WACN,yBACA,KAAK,kBACL,uBACC"}
|
|
@@ -9,7 +9,7 @@ import { textLengthPixels } from "@pairdraw/scene-graph/text";
|
|
|
9
9
|
import { parseFontStyle } from "@pairdraw/scene-graph/font-style";
|
|
10
10
|
import { resolveNodeTextDirection } from "@pairdraw/scene-graph/text/direction";
|
|
11
11
|
//#region src/io/formats/svg/text/export.ts
|
|
12
|
-
function styleOverrideToTspanAttrs(style, colorSpace, parentFillOpacity, node) {
|
|
12
|
+
function styleOverrideToTspanAttrs(style, colorSpace, documentSpace, parentFillOpacity, node) {
|
|
13
13
|
const attrs = {};
|
|
14
14
|
if (style.fontFamily) attrs["font-family"] = style.fontFamily;
|
|
15
15
|
if (style.fontSize) attrs["font-size"] = style.fontSize;
|
|
@@ -27,9 +27,9 @@ function styleOverrideToTspanAttrs(style, colorSpace, parentFillOpacity, node) {
|
|
|
27
27
|
if (colorSpace === "display-p3") attrs.fill = formatColor({
|
|
28
28
|
...visibleFill.color,
|
|
29
29
|
a: 1
|
|
30
|
-
}, alpha, colorSpace);
|
|
30
|
+
}, alpha, colorSpace, documentSpace);
|
|
31
31
|
else {
|
|
32
|
-
attrs.fill = formatColor(visibleFill.color, 1, colorSpace);
|
|
32
|
+
attrs.fill = formatColor(visibleFill.color, 1, colorSpace, documentSpace);
|
|
33
33
|
if (alpha < 1) attrs["fill-opacity"] = alpha;
|
|
34
34
|
}
|
|
35
35
|
if (alpha >= 1 && parentFillOpacity !== void 0) attrs["fill-opacity"] = 1;
|
|
@@ -68,11 +68,11 @@ function spanFontAttrs(node, style, fallback, fontAlias) {
|
|
|
68
68
|
* so the same band is painted behind the fill at twice the weight, which hides the inner half. An
|
|
69
69
|
* inside or centred stroke keeps its own weight over the fill.
|
|
70
70
|
*/
|
|
71
|
-
function textStrokeAttrs(node, colorSpace) {
|
|
71
|
+
function textStrokeAttrs(node, colorSpace, documentSpace = "srgb") {
|
|
72
72
|
const stroke = node.strokes.find((candidate) => candidate.visible);
|
|
73
73
|
if (!stroke) return {};
|
|
74
74
|
const attrs = {
|
|
75
|
-
stroke: formatSolidColor(stroke.color, 1, colorSpace),
|
|
75
|
+
stroke: formatSolidColor(stroke.color, 1, colorSpace, documentSpace),
|
|
76
76
|
"stroke-width": round(stroke.weight * (stroke.align === "OUTSIDE" ? 2 : 1))
|
|
77
77
|
};
|
|
78
78
|
if (stroke.opacity < 1) attrs["stroke-opacity"] = round(stroke.opacity);
|
|
@@ -134,7 +134,7 @@ function renderUnmeasuredText(node, attrs, spanAttrs, direction) {
|
|
|
134
134
|
}, shownText(node));
|
|
135
135
|
}
|
|
136
136
|
function renderTextNode(node, fillAttr, ctx, fillOpacity) {
|
|
137
|
-
const { colorSpace, textLayout, fontAlias } = ctx;
|
|
137
|
+
const { colorSpace, documentColorSpace: documentSpace, textLayout, fontAlias } = ctx;
|
|
138
138
|
const direction = resolveNodeTextDirection(node);
|
|
139
139
|
const lines = textLayout ? textLayout(node) : null;
|
|
140
140
|
const laidOut = lines && lines.length > 0 ? lines : null;
|
|
@@ -153,11 +153,11 @@ function renderTextNode(node, fillAttr, ctx, fillOpacity) {
|
|
|
153
153
|
"text-anchor": laidOut ? void 0 : textAnchorForNode(node, direction),
|
|
154
154
|
"text-decoration": textDecoration,
|
|
155
155
|
"letter-spacing": letterSpacing ? round(letterSpacing) : void 0,
|
|
156
|
-
...textStrokeAttrs(node, colorSpace),
|
|
156
|
+
...textStrokeAttrs(node, colorSpace, documentSpace),
|
|
157
157
|
...fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {}
|
|
158
158
|
};
|
|
159
159
|
const spanAttrs = (style, fallback) => ({
|
|
160
|
-
...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),
|
|
160
|
+
...styleOverrideToTspanAttrs(style, colorSpace, documentSpace, fillOpacity, node),
|
|
161
161
|
...spanFontAttrs(node, style, fallback, fontAlias)
|
|
162
162
|
});
|
|
163
163
|
if (laidOut) return svg("text", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"sourcesContent":["import type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'\nimport { parseFontStyle } from '@pairdraw/scene-graph/font-style'\nimport { textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { drawnFontVariations } from '#core/canvas/text/font-families'\nimport {\n formatColor,\n formatSolidColor,\n type SVGExportContext,\n type SVGFontAlias,\n type SVGFontRequest\n} from '#core/io/formats/svg/defs'\nimport { svg, type SVGNode } from '#core/io/formats/svg/node'\nimport { round } from '#core/io/formats/svg/paths'\nimport {\n explicitNewlineLines,\n laidOutTextSpans,\n textStyleSpans,\n type SpanAttrs,\n type SVGFallbackFace\n} from '#core/io/formats/svg/text/lines'\nimport { shownText } from '#core/text/case'\nimport { textFontFace } from '#core/text/requirements/collect'\n\nfunction styleOverrideToTspanAttrs(\n style: CharacterStyleOverride,\n colorSpace: 'srgb' | 'display-p3',\n parentFillOpacity: number | undefined,\n node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>\n): Record<string, string | number | undefined> {\n const attrs: Record<string, string | number | undefined> = {}\n if (style.fontFamily) attrs['font-family'] = style.fontFamily\n if (style.fontSize) attrs['font-size'] = style.fontSize\n if (style.fontWeight) attrs['font-weight'] = style.fontWeight\n if (style.italic) attrs['font-style'] = 'italic'\n // A run's own spacing is written even at zero, or it would inherit the layer's. A percent the\n // run inherits follows its own font size, so a larger or smaller run writes it again.\n const inherited =\n style.fontSize !== undefined &&\n node.letterSpacing.unit === 'PERCENT' &&\n node.letterSpacing.value !== 0\n ? node.letterSpacing\n : undefined\n const spacing = style.letterSpacing ?? inherited\n if (spacing) {\n attrs['letter-spacing'] = round(textLengthPixels(spacing, style.fontSize ?? node.fontSize))\n }\n if (style.textDecoration === 'UNDERLINE') attrs['text-decoration'] = 'underline'\n if (style.textDecoration === 'STRIKETHROUGH') attrs['text-decoration'] = 'line-through'\n if (style.fills) {\n const visibleFill = style.fills.find((f) => f.visible && f.type === 'SOLID')\n if (visibleFill) {\n // Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.\n const alpha = round(visibleFill.color.a * visibleFill.opacity)\n if (colorSpace === 'display-p3') {\n attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace)\n } else {\n attrs.fill = formatColor(visibleFill.color, 1, colorSpace)\n if (alpha < 1) attrs['fill-opacity'] = alpha\n }\n // `fill-opacity` inherits, so an opaque run has to cover a translucent parent.\n if (alpha >= 1 && parentFillOpacity !== undefined) attrs['fill-opacity'] = 1\n }\n }\n return attrs\n}\n\n/**\n * Font attributes naming a face's alias, such as the family a PDF embeds its file under, or else\n * the face itself, so text inside an aliased parent does not inherit the alias.\n */\nfunction aliasedFontAttrs(\n face: SVGFontRequest,\n fontAlias: SVGFontAlias\n): Record<string, string | number> {\n const alias = fontAlias(face)\n if (alias) return { 'font-family': alias, 'font-weight': 'normal', 'font-style': 'normal' }\n return {\n 'font-family': face.family,\n 'font-weight': face.weight,\n 'font-style': face.italic ? 'italic' : 'normal'\n }\n}\n\n/**\n * The font attributes of a span: its face's alias where there is one, otherwise the family of the\n * fallback face that draws it, if any.\n */\nfunction spanFontAttrs(\n node: SceneNode,\n style: CharacterStyleOverride,\n fallback: SVGFallbackFace | undefined,\n fontAlias: SVGFontAlias | undefined\n): Record<string, string | number> {\n if (fontAlias) return aliasedFontAttrs(fontRequest(node, style, fallback), fontAlias)\n return fallback ? { 'font-family': fallback.family } : {}\n}\n\n/**\n * A text layer's stroke, painted on the glyphs themselves. The canvas strokes an outside stroke at\n * twice its weight and clips it to the outside of the glyphs; live text cannot be clipped in SVG,\n * so the same band is painted behind the fill at twice the weight, which hides the inner half. An\n * inside or centred stroke keeps its own weight over the fill.\n */\nfunction textStrokeAttrs(\n node: SceneNode,\n colorSpace: 'srgb' | 'display-p3'\n): Record<string, string | number | undefined> {\n const stroke = node.strokes.find((candidate) => candidate.visible)\n if (!stroke) return {}\n const attrs: Record<string, string | number | undefined> = {\n stroke: formatSolidColor(stroke.color, 1, colorSpace),\n 'stroke-width': round(stroke.weight * (stroke.align === 'OUTSIDE' ? 2 : 1))\n }\n if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)\n if (stroke.align === 'OUTSIDE') attrs['paint-order'] = 'stroke'\n return attrs\n}\n\n/**\n * The face a run of `node` is drawn in, or the fallback face that draws its characters instead,\n * with the size and axes its instance follows. A fallback is drawn at the axes the run's own font\n * is drawn at, as the paragraph draws every font it falls back to.\n */\nfunction fontRequest(\n node: SceneNode,\n style: CharacterStyleOverride = {},\n fallback?: SVGFallbackFace\n): SVGFontRequest {\n const own: SVGFontRequest = {\n ...textFontFace(node, style),\n fontSize: style.fontSize ?? node.fontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n }\n if (!fallback) return own\n return {\n ...own,\n ...fallback,\n ...parseFontStyle(fallback.style),\n variations: drawnFontVariations(own),\n opticalSizeFromFontSize: false\n }\n}\n\nfunction isLogicalTextEnd(node: SceneNode, direction: 'LTR' | 'RTL'): boolean {\n return (\n (direction === 'LTR' && node.textAlignHorizontal === 'RIGHT') ||\n (direction === 'RTL' && node.textAlignHorizontal === 'LEFT')\n )\n}\n\nfunction textAnchorForNode(\n node: SceneNode,\n direction: 'LTR' | 'RTL'\n): 'middle' | 'end' | undefined {\n if (node.textAlignHorizontal === 'CENTER') return 'middle'\n if (isLogicalTextEnd(node, direction)) return 'end'\n return undefined\n}\n\nfunction textXForNode(node: SceneNode, direction: 'LTR' | 'RTL'): number {\n if (node.textAlignHorizontal === 'CENTER') return round(node.width / 2)\n if (isLogicalTextEnd(node, direction)) return round(node.width)\n return 0\n}\n\n/** Text with no measured layout: explicit newlines on their own baselines, otherwise one line. */\nfunction renderUnmeasuredText(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>,\n spanAttrs: SpanAttrs,\n direction: 'LTR' | 'RTL'\n): SVGNode {\n const x = textXForNode(node, direction)\n const y = node.fontSize || 14\n // No measured wraps: an explicit newline still starts a line, on the same anchor as one line.\n const newlineLines = explicitNewlineLines(node, x, y)\n if (newlineLines) {\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, newlineLines, spanAttrs)\n )\n }\n\n if (node.styleRuns.length > 0) {\n return svg(\n 'text',\n { x, y, ...attrs, 'xml:space': 'preserve' },\n ...textStyleSpans(node, spanAttrs)\n )\n }\n\n return svg('text', { x, y, ...attrs }, shownText(node))\n}\n\nexport function renderTextNode(\n node: SceneNode,\n fillAttr: string | null,\n ctx: SVGExportContext,\n fillOpacity?: number\n): SVGNode {\n const { colorSpace, textLayout, fontAlias } = ctx\n const direction = resolveNodeTextDirection(node)\n const lines = textLayout ? textLayout(node) : null\n const laidOut = lines && lines.length > 0 ? lines : null\n\n let textDecoration: 'underline' | 'line-through' | undefined\n if (node.textDecoration === 'UNDERLINE') textDecoration = 'underline'\n else if (node.textDecoration === 'STRIKETHROUGH') textDecoration = 'line-through'\n const letterSpacing = textLengthPixels(node.letterSpacing, node.fontSize)\n\n const attrs: Record<string, string | number | undefined> = {\n 'font-family': node.fontFamily || undefined,\n 'font-size': node.fontSize || undefined,\n 'font-weight': node.fontWeight !== 400 ? node.fontWeight : undefined,\n 'font-style': node.italic ? 'italic' : undefined,\n fill: fillAttr ?? undefined,\n 'fill-opacity': fillOpacity,\n // Laid-out spans each start at their own left edge, so they take no direction or anchor.\n direction: direction === 'RTL' && !laidOut ? 'rtl' : undefined,\n 'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),\n 'text-decoration': textDecoration,\n 'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,\n ...textStrokeAttrs(node, colorSpace),\n ...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})\n }\n const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({\n ...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),\n ...spanFontAttrs(node, style, fallback, fontAlias)\n })\n\n if (laidOut) {\n // Laid-out spans sit where the editor draws them, which keeps every space it draws.\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, laidOut, spanAttrs)\n )\n }\n\n return renderUnmeasuredText(node, attrs, spanAttrs, direction)\n}\n"],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BAAkB,MAAM,SAAS;EACtE,mBAAmB;EACnB,kBAAkB,gBAAgB,MAAM,aAAa,IAAI,KAAA;EACzD,GAAG,gBAAgB,MAAM,UAAU;EACnC,GAAI,YAAY,iBAAiB,YAAY,IAAI,GAAG,SAAS,IAAI,CAAC;CACpE;CACA,MAAM,aAAa,OAA+B,cAAgC;EAChF,GAAG,0BAA0B,OAAO,YAAY,aAAa,IAAI;EACjE,GAAG,cAAc,MAAM,OAAO,UAAU,SAAS;CACnD;CAEA,IAAI,SAEF,OAAO,IACL,QACA;EAAE,GAAG;EAAO,aAAa;CAAW,GACpC,GAAG,iBAAiB,MAAM,SAAS,SAAS,CAC9C;CAGF,OAAO,qBAAqB,MAAM,OAAO,WAAW,SAAS;AAC/D"}
|
|
1
|
+
{"version":3,"file":"export.js","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"sourcesContent":["import type { CharacterStyleOverride, ColorProfile, SceneNode } from '@pairdraw/scene-graph'\nimport { parseFontStyle } from '@pairdraw/scene-graph/font-style'\nimport { textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { drawnFontVariations } from '#core/canvas/text/font-families'\nimport {\n formatColor,\n formatSolidColor,\n type SVGExportContext,\n type SVGFontAlias,\n type SVGFontRequest\n} from '#core/io/formats/svg/defs'\nimport { svg, type SVGNode } from '#core/io/formats/svg/node'\nimport { round } from '#core/io/formats/svg/paths'\nimport {\n explicitNewlineLines,\n laidOutTextSpans,\n textStyleSpans,\n type SpanAttrs,\n type SVGFallbackFace\n} from '#core/io/formats/svg/text/lines'\nimport { shownText } from '#core/text/case'\nimport { textFontFace } from '#core/text/requirements/collect'\n\nfunction styleOverrideToTspanAttrs(\n style: CharacterStyleOverride,\n colorSpace: 'srgb' | 'display-p3',\n documentSpace: ColorProfile,\n parentFillOpacity: number | undefined,\n node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>\n): Record<string, string | number | undefined> {\n const attrs: Record<string, string | number | undefined> = {}\n if (style.fontFamily) attrs['font-family'] = style.fontFamily\n if (style.fontSize) attrs['font-size'] = style.fontSize\n if (style.fontWeight) attrs['font-weight'] = style.fontWeight\n if (style.italic) attrs['font-style'] = 'italic'\n // A run's own spacing is written even at zero, or it would inherit the layer's. A percent the\n // run inherits follows its own font size, so a larger or smaller run writes it again.\n const inherited =\n style.fontSize !== undefined &&\n node.letterSpacing.unit === 'PERCENT' &&\n node.letterSpacing.value !== 0\n ? node.letterSpacing\n : undefined\n const spacing = style.letterSpacing ?? inherited\n if (spacing) {\n attrs['letter-spacing'] = round(textLengthPixels(spacing, style.fontSize ?? node.fontSize))\n }\n if (style.textDecoration === 'UNDERLINE') attrs['text-decoration'] = 'underline'\n if (style.textDecoration === 'STRIKETHROUGH') attrs['text-decoration'] = 'line-through'\n if (style.fills) {\n const visibleFill = style.fills.find((f) => f.visible && f.type === 'SOLID')\n if (visibleFill) {\n // Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.\n const alpha = round(visibleFill.color.a * visibleFill.opacity)\n if (colorSpace === 'display-p3') {\n attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace, documentSpace)\n } else {\n attrs.fill = formatColor(visibleFill.color, 1, colorSpace, documentSpace)\n if (alpha < 1) attrs['fill-opacity'] = alpha\n }\n // `fill-opacity` inherits, so an opaque run has to cover a translucent parent.\n if (alpha >= 1 && parentFillOpacity !== undefined) attrs['fill-opacity'] = 1\n }\n }\n return attrs\n}\n\n/**\n * Font attributes naming a face's alias, such as the family a PDF embeds its file under, or else\n * the face itself, so text inside an aliased parent does not inherit the alias.\n */\nfunction aliasedFontAttrs(\n face: SVGFontRequest,\n fontAlias: SVGFontAlias\n): Record<string, string | number> {\n const alias = fontAlias(face)\n if (alias) return { 'font-family': alias, 'font-weight': 'normal', 'font-style': 'normal' }\n return {\n 'font-family': face.family,\n 'font-weight': face.weight,\n 'font-style': face.italic ? 'italic' : 'normal'\n }\n}\n\n/**\n * The font attributes of a span: its face's alias where there is one, otherwise the family of the\n * fallback face that draws it, if any.\n */\nfunction spanFontAttrs(\n node: SceneNode,\n style: CharacterStyleOverride,\n fallback: SVGFallbackFace | undefined,\n fontAlias: SVGFontAlias | undefined\n): Record<string, string | number> {\n if (fontAlias) return aliasedFontAttrs(fontRequest(node, style, fallback), fontAlias)\n return fallback ? { 'font-family': fallback.family } : {}\n}\n\n/**\n * A text layer's stroke, painted on the glyphs themselves. The canvas strokes an outside stroke at\n * twice its weight and clips it to the outside of the glyphs; live text cannot be clipped in SVG,\n * so the same band is painted behind the fill at twice the weight, which hides the inner half. An\n * inside or centred stroke keeps its own weight over the fill.\n */\nfunction textStrokeAttrs(\n node: SceneNode,\n colorSpace: 'srgb' | 'display-p3',\n documentSpace: ColorProfile = 'srgb'\n): Record<string, string | number | undefined> {\n const stroke = node.strokes.find((candidate) => candidate.visible)\n if (!stroke) return {}\n const attrs: Record<string, string | number | undefined> = {\n stroke: formatSolidColor(stroke.color, 1, colorSpace, documentSpace),\n 'stroke-width': round(stroke.weight * (stroke.align === 'OUTSIDE' ? 2 : 1))\n }\n if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)\n if (stroke.align === 'OUTSIDE') attrs['paint-order'] = 'stroke'\n return attrs\n}\n\n/**\n * The face a run of `node` is drawn in, or the fallback face that draws its characters instead,\n * with the size and axes its instance follows. A fallback is drawn at the axes the run's own font\n * is drawn at, as the paragraph draws every font it falls back to.\n */\nfunction fontRequest(\n node: SceneNode,\n style: CharacterStyleOverride = {},\n fallback?: SVGFallbackFace\n): SVGFontRequest {\n const own: SVGFontRequest = {\n ...textFontFace(node, style),\n fontSize: style.fontSize ?? node.fontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n }\n if (!fallback) return own\n return {\n ...own,\n ...fallback,\n ...parseFontStyle(fallback.style),\n variations: drawnFontVariations(own),\n opticalSizeFromFontSize: false\n }\n}\n\nfunction isLogicalTextEnd(node: SceneNode, direction: 'LTR' | 'RTL'): boolean {\n return (\n (direction === 'LTR' && node.textAlignHorizontal === 'RIGHT') ||\n (direction === 'RTL' && node.textAlignHorizontal === 'LEFT')\n )\n}\n\nfunction textAnchorForNode(\n node: SceneNode,\n direction: 'LTR' | 'RTL'\n): 'middle' | 'end' | undefined {\n if (node.textAlignHorizontal === 'CENTER') return 'middle'\n if (isLogicalTextEnd(node, direction)) return 'end'\n return undefined\n}\n\nfunction textXForNode(node: SceneNode, direction: 'LTR' | 'RTL'): number {\n if (node.textAlignHorizontal === 'CENTER') return round(node.width / 2)\n if (isLogicalTextEnd(node, direction)) return round(node.width)\n return 0\n}\n\n/** Text with no measured layout: explicit newlines on their own baselines, otherwise one line. */\nfunction renderUnmeasuredText(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>,\n spanAttrs: SpanAttrs,\n direction: 'LTR' | 'RTL'\n): SVGNode {\n const x = textXForNode(node, direction)\n const y = node.fontSize || 14\n // No measured wraps: an explicit newline still starts a line, on the same anchor as one line.\n const newlineLines = explicitNewlineLines(node, x, y)\n if (newlineLines) {\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, newlineLines, spanAttrs)\n )\n }\n\n if (node.styleRuns.length > 0) {\n return svg(\n 'text',\n { x, y, ...attrs, 'xml:space': 'preserve' },\n ...textStyleSpans(node, spanAttrs)\n )\n }\n\n return svg('text', { x, y, ...attrs }, shownText(node))\n}\n\nexport function renderTextNode(\n node: SceneNode,\n fillAttr: string | null,\n ctx: SVGExportContext,\n fillOpacity?: number\n): SVGNode {\n const { colorSpace, documentColorSpace: documentSpace, textLayout, fontAlias } = ctx\n const direction = resolveNodeTextDirection(node)\n const lines = textLayout ? textLayout(node) : null\n const laidOut = lines && lines.length > 0 ? lines : null\n\n let textDecoration: 'underline' | 'line-through' | undefined\n if (node.textDecoration === 'UNDERLINE') textDecoration = 'underline'\n else if (node.textDecoration === 'STRIKETHROUGH') textDecoration = 'line-through'\n const letterSpacing = textLengthPixels(node.letterSpacing, node.fontSize)\n\n const attrs: Record<string, string | number | undefined> = {\n 'font-family': node.fontFamily || undefined,\n 'font-size': node.fontSize || undefined,\n 'font-weight': node.fontWeight !== 400 ? node.fontWeight : undefined,\n 'font-style': node.italic ? 'italic' : undefined,\n fill: fillAttr ?? undefined,\n 'fill-opacity': fillOpacity,\n // Laid-out spans each start at their own left edge, so they take no direction or anchor.\n direction: direction === 'RTL' && !laidOut ? 'rtl' : undefined,\n 'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),\n 'text-decoration': textDecoration,\n 'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,\n ...textStrokeAttrs(node, colorSpace, documentSpace),\n ...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})\n }\n const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({\n ...styleOverrideToTspanAttrs(style, colorSpace, documentSpace, fillOpacity, node),\n ...spanFontAttrs(node, style, fallback, fontAlias)\n })\n\n if (laidOut) {\n // Laid-out spans sit where the editor draws them, which keeps every space it draws.\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, laidOut, spanAttrs)\n )\n }\n\n return renderUnmeasuredText(node, attrs, spanAttrs, direction)\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,0BACP,OACA,YACA,eACA,mBACA,MAC6C;CAC7C,MAAM,QAAqD,CAAC;CAC5D,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,UAAU,MAAM,eAAe,MAAM;CAC/C,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,QAAQ,MAAM,gBAAgB;CAGxC,MAAM,YACJ,MAAM,aAAa,KAAA,KACnB,KAAK,cAAc,SAAS,aAC5B,KAAK,cAAc,UAAU,IACzB,KAAK,gBACL,KAAA;C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AEF,OAAO,IACL,QACA;EAAE,GAAG;EAAO,aAAa;CAAW,GACpC,GAAG,iBAAiB,MAAM,SAAS,SAAS,CAC9C;CAGF,OAAO,qBAAqB,MAAM,OAAO,WAAW,SAAS;AAC/D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { measureTextForLayout } from "../../../../layout/text-measurement.js";
|
|
2
2
|
import { localTransformFromWorld } from "@pairdraw/scene-graph/coordinate";
|
|
3
|
+
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
3
4
|
import { pixelLength } from "@pairdraw/scene-graph/text";
|
|
4
5
|
import { faceLoadKey } from "@pairdraw/scene-graph/font-style";
|
|
5
|
-
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
6
6
|
import { textLayerName } from "@pairdraw/scene-graph/node-defaults";
|
|
7
7
|
import { isEqual } from "es-toolkit/predicate";
|
|
8
8
|
//#region src/io/formats/svg/text/import.ts
|