@pairdraw/core 0.20.0 → 0.21.1
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/canvas/noise/render.js +1 -1
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +6 -3
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +12 -7
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/noise/tile.d.ts.map +1 -1
- package/dist/canvas/noise/tile.js +2 -1
- package/dist/canvas/noise/tile.js.map +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.js +4 -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 +23 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- 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/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.d.ts +20 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +28 -4
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +4 -3
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/compile.d.ts +3 -1
- package/dist/canvas/shaders/compile.d.ts.map +1 -1
- package/dist/canvas/shaders/compile.js +12 -3
- package/dist/canvas/shaders/compile.js.map +1 -1
- package/dist/canvas/shaders/draw.d.ts.map +1 -1
- package/dist/canvas/shaders/draw.js +10 -3
- package/dist/canvas/shaders/draw.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +8 -17
- 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.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.map +1 -1
- package/dist/canvas/texture.js +2 -1
- package/dist/canvas/texture.js.map +1 -1
- package/dist/design-memory/rules.js +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +2 -2
- 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.js +2 -2
- package/dist/editor/clipboard/export.js.map +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/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/eyedropper.d.ts +1 -1
- package/dist/editor/eyedropper.d.ts.map +1 -1
- package/dist/editor/eyedropper.js +6 -3
- package/dist/editor/eyedropper.js.map +1 -1
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +3 -2
- package/dist/editor/history/atomic-tool.js.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/variables.js +3 -3
- package/dist/editor/variables.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 +6 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +12 -5
- package/dist/figma-api/index.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.map +1 -1
- package/dist/figma-api/proxy.js +3 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +20 -4
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +49 -3
- package/dist/figma-api/reactions.js.map +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/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 +13 -12
- 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/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/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/drift.js +2 -2
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -1
- 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/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/warnings.d.ts +17 -2
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
- package/dist/io/formats/drawio/warnings.js +15 -8
- 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 +2 -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/html/index.d.ts +1 -0
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +5 -3
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.js +1 -0
- 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/mermaid/styles.js +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/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +13 -2
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/style.js +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 +9 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +6 -3
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +12 -11
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.js +2 -2
- package/dist/io/formats/svg/effects.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +4 -2
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +4 -1
- package/dist/io/formats/svg/filter.d.ts.map +1 -1
- package/dist/io/formats/svg/filter.js +6 -2
- package/dist/io/formats/svg/filter.js.map +1 -1
- package/dist/io/formats/svg/grain.js +1 -1
- package/dist/io/formats/svg/grain.js.map +1 -1
- 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/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/layout.js +2 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +11 -4
- package/dist/io/formats.js.map +1 -1
- package/dist/io/index.d.ts +2 -2
- 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 +12 -3
- package/dist/io/types.d.ts.map +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/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.js +24 -1
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.js +1 -1
- package/dist/lint/linter.js +2 -2
- package/dist/lint/linter.js.map +1 -1
- 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/index.d.ts +3 -3
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +5 -5
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +1 -1
- package/dist/prototype/scene.js +1 -1
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +3 -3
- 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/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 +4 -3
- package/dist/text/index.js +4 -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/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.js +7 -18
- package/dist/tools/analyze/responsive/index.js.map +1 -1
- 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 +2 -1
- package/dist/tools/analyze.js +2 -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/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/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +1 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +2 -2
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +5 -2
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +3 -3
- 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/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.js +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 +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- 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 +57 -5
- 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 +3 -3
- package/dist/tools/modify/text.js.map +1 -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/libraries.js +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.map +1 -1
- package/dist/tools/read/space.js +0 -2
- 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.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/schema.d.ts +6 -4
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +9 -5
- 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/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/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +6 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/video-host.d.ts.map +1 -1
- package/dist/tools/video-host.js +5 -3
- package/dist/tools/video-host.js.map +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 +9 -9
- package/src/canvas/noise/render.ts +1 -1
- package/src/canvas/noise/shader.ts +13 -5
- package/src/canvas/noise/tile.ts +2 -1
- 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 +4 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +21 -3
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer.ts +36 -11
- package/src/canvas/scene.ts +4 -3
- package/src/canvas/shaders/compile.ts +14 -3
- package/src/canvas/shaders/draw.ts +11 -4
- package/src/canvas/shaders/effect.ts +8 -19
- 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 +2 -1
- 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 +2 -2
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/eyedropper.ts +14 -4
- package/src/editor/history/atomic-tool.ts +3 -2
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/variables.ts +3 -3
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +12 -4
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +2 -1
- package/src/figma-api/reactions.ts +91 -10
- package/src/figma-api/variables/index.ts +5 -4
- 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/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/styles.ts +10 -7
- package/src/io/formats/design-tokens/sync/drift.ts +6 -4
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/warnings.ts +28 -9
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +4 -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/html/index.ts +9 -3
- package/src/io/formats/html/vectors.ts +1 -0
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/index.ts +15 -4
- package/src/io/formats/raster/render.ts +12 -4
- package/src/io/formats/svg/defs.ts +26 -14
- package/src/io/formats/svg/effects.ts +2 -2
- package/src/io/formats/svg/export.ts +17 -3
- package/src/io/formats/svg/filter.ts +12 -2
- package/src/io/formats/svg/grain.ts +1 -1
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +2 -2
- package/src/io/formats.ts +18 -5
- package/src/io/index.ts +1 -0
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +10 -0
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +47 -1
- package/src/lint/linter.ts +1 -1
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/index.ts +7 -9
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +2 -1
- package/src/text/prepare.ts +9 -4
- package/src/tools/analyze/responsive/index.ts +8 -15
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/html.ts +0 -3
- package/src/tools/create/icons.ts +1 -1
- package/src/tools/create/svg.ts +4 -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/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +2 -0
- package/src/tools/modify/effects.ts +1 -1
- 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 +3 -2
- package/src/tools/modify/text.ts +15 -11
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +0 -2
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +3 -2
- package/src/tools/schema.ts +14 -5
- package/src/tools/script/host.ts +6 -3
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/vectorize.ts +10 -4
- package/src/tools/video-host.ts +5 -3
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
package/src/tools/schema.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import * as v from 'valibot'
|
|
9
9
|
|
|
10
|
-
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
10
|
+
import type { DocumentColorSpace, SceneNode } from '@pairdraw/scene-graph'
|
|
11
11
|
import { tryParseColor } from '@pairdraw/scene-graph/color'
|
|
12
12
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
13
13
|
|
|
@@ -328,9 +328,12 @@ export function nodeSummary(node: FigmaNodeProxy): { id: string; name: string; t
|
|
|
328
328
|
* used to paint black and report success. Read through `tryParseColor`, since a published schema
|
|
329
329
|
* cannot express what the parser accepts.
|
|
330
330
|
*/
|
|
331
|
-
export function parseToolColor(
|
|
331
|
+
export function parseToolColor(
|
|
332
|
+
value: string,
|
|
333
|
+
profile: DocumentColorSpace = 'srgb'
|
|
334
|
+
): Color | { error: string } {
|
|
332
335
|
return (
|
|
333
|
-
tryParseColor(value) ?? {
|
|
336
|
+
tryParseColor(value, profile) ?? {
|
|
334
337
|
error: `"${value}" is not a color; use a hex value, a color name, or a color function`
|
|
335
338
|
}
|
|
336
339
|
)
|
|
@@ -341,10 +344,11 @@ export function parseToolColor(value: string): Color | { error: string } {
|
|
|
341
344
|
* same refusal `parseToolColor` gives, so each tool does not repeat that check.
|
|
342
345
|
*/
|
|
343
346
|
export function parseOptionalToolColor(
|
|
344
|
-
value: string | undefined
|
|
347
|
+
value: string | undefined,
|
|
348
|
+
profile: DocumentColorSpace = 'srgb'
|
|
345
349
|
): { color: Color | undefined } | { error: string } {
|
|
346
350
|
if (value === undefined) return { color: undefined }
|
|
347
|
-
const parsed = parseToolColor(value)
|
|
351
|
+
const parsed = parseToolColor(value, profile)
|
|
348
352
|
if ('error' in parsed) return parsed
|
|
349
353
|
return { color: parsed }
|
|
350
354
|
}
|
|
@@ -382,3 +386,8 @@ export function toolNumber(schema: v.GenericSchema<number, number> = v.number())
|
|
|
382
386
|
)
|
|
383
387
|
])
|
|
384
388
|
}
|
|
389
|
+
|
|
390
|
+
/** `ids`: several node IDs in one call; the description names what they point at. */
|
|
391
|
+
export function nodeIdsField(description: string) {
|
|
392
|
+
return v.optional(v.pipe(v.array(v.string()), v.minLength(1), v.description(description)))
|
|
393
|
+
}
|
package/src/tools/script/host.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { underlyingGraph } from '#core/figma-api/graph-ref'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* What the `script` tool needs from the host: the sandbox and the node that carries its program
|
|
3
5
|
* live in the app, so the app registers the runner for the documents it shows. A headless host
|
|
@@ -21,12 +23,13 @@ const hosts = new WeakMap<object, ScriptToolHost>()
|
|
|
21
23
|
|
|
22
24
|
/** Lets the `script` tool run for the documents of `owner`, a document's graph. */
|
|
23
25
|
export function registerScriptToolHost(owner: object, host: ScriptToolHost): () => void {
|
|
24
|
-
|
|
26
|
+
const target = underlyingGraph(owner)
|
|
27
|
+
hosts.set(target, host)
|
|
25
28
|
return () => {
|
|
26
|
-
if (hosts.get(
|
|
29
|
+
if (hosts.get(target) === host) hosts.delete(target)
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export function getScriptToolHost(owner: object): ScriptToolHost | undefined {
|
|
31
|
-
return hosts.get(owner)
|
|
34
|
+
return hosts.get(underlyingGraph(owner))
|
|
32
35
|
}
|
|
@@ -8,7 +8,7 @@ export const listCollections = defineTool({
|
|
|
8
8
|
execution: { kind: 'sync', mutation: 'none' },
|
|
9
9
|
input: v.strictObject({}),
|
|
10
10
|
execute: (figma) => {
|
|
11
|
-
const collections =
|
|
11
|
+
const collections = figma.graph.getLiveCollections()
|
|
12
12
|
return { count: collections.length, collections }
|
|
13
13
|
}
|
|
14
14
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot'
|
|
2
2
|
|
|
3
|
-
import type { VariableType } from '@pairdraw/scene-graph'
|
|
3
|
+
import type { DocumentColorSpace, VariableType } from '@pairdraw/scene-graph'
|
|
4
4
|
import { tryParseColor } from '@pairdraw/scene-graph/color'
|
|
5
5
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
6
6
|
|
|
@@ -14,8 +14,12 @@ function figmaValue(value: ToolValue): FigmaVariableValue {
|
|
|
14
14
|
|
|
15
15
|
type ToolValue = Color | number | string | boolean
|
|
16
16
|
|
|
17
|
-
function parseVariableValue(
|
|
18
|
-
|
|
17
|
+
function parseVariableValue(
|
|
18
|
+
type: VariableType,
|
|
19
|
+
value: string,
|
|
20
|
+
profile: DocumentColorSpace
|
|
21
|
+
): ToolValue | null {
|
|
22
|
+
if (type === 'COLOR') return tryParseColor(value, profile)
|
|
19
23
|
if (type === 'FLOAT') return Number(value)
|
|
20
24
|
if (type === 'BOOLEAN') return value === 'true'
|
|
21
25
|
return value
|
|
@@ -40,7 +44,10 @@ export const createVariable = defineTool({
|
|
|
40
44
|
execute: (figma, args) => {
|
|
41
45
|
const type = args.type
|
|
42
46
|
// The value is checked first, so a value the variable cannot hold creates nothing.
|
|
43
|
-
const value =
|
|
47
|
+
const value =
|
|
48
|
+
args.value === undefined
|
|
49
|
+
? undefined
|
|
50
|
+
: parseVariableValue(type, args.value, figma.graph.documentColorSpace)
|
|
44
51
|
if (value === null) return { error: `"${args.value}" is not a ${type} value` }
|
|
45
52
|
if (typeof value === 'number' && !Number.isFinite(value))
|
|
46
53
|
return { error: `"${args.value}" is not a number` }
|
|
@@ -66,7 +73,11 @@ export const setVariable = defineTool({
|
|
|
66
73
|
execute: (figma, args) => {
|
|
67
74
|
const variable = figma.variables.getVariableById(args.id)
|
|
68
75
|
if (!variable) return { error: `Variable "${args.id}" not found` }
|
|
69
|
-
const parsedValue = parseVariableValue(
|
|
76
|
+
const parsedValue = parseVariableValue(
|
|
77
|
+
variable.resolvedType,
|
|
78
|
+
args.value,
|
|
79
|
+
figma.graph.documentColorSpace
|
|
80
|
+
)
|
|
70
81
|
if (parsedValue === null)
|
|
71
82
|
return { error: `"${args.value}" is not a ${variable.resolvedType} value` }
|
|
72
83
|
variable.setValueForMode(args.mode, figmaValue(parsedValue))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot'
|
|
2
2
|
|
|
3
|
+
import { underlyingGraph } from '#core/figma-api/graph-ref'
|
|
3
4
|
import { defineTool, nodeIdInputSchema, nodeNotFound, toolFailure } from '#core/tools/schema'
|
|
4
5
|
import {
|
|
5
6
|
createVectorFrameBeside,
|
|
@@ -25,14 +26,15 @@ const vectorizers = new WeakMap<object, ImageVectorizer>()
|
|
|
25
26
|
|
|
26
27
|
/** Lets `vectorize_image` run for the documents of `owner`, a document's graph. */
|
|
27
28
|
export function registerImageVectorizer(owner: object, vectorizer: ImageVectorizer): () => void {
|
|
28
|
-
|
|
29
|
+
const target = underlyingGraph(owner)
|
|
30
|
+
vectorizers.set(target, vectorizer)
|
|
29
31
|
return () => {
|
|
30
|
-
if (vectorizers.get(
|
|
32
|
+
if (vectorizers.get(target) === vectorizer) vectorizers.delete(target)
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export function getImageVectorizer(owner: object): ImageVectorizer | undefined {
|
|
35
|
-
return vectorizers.get(owner)
|
|
37
|
+
return vectorizers.get(underlyingGraph(owner))
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export const vectorizeImage = defineTool({
|
|
@@ -73,7 +75,11 @@ export const vectorizeImage = defineTool({
|
|
|
73
75
|
if (!current || vectorizableImageFill(current)?.imageHash !== fill.imageHash) {
|
|
74
76
|
return { error: `The image of "${node.name}" changed before vectorizing finished` }
|
|
75
77
|
}
|
|
76
|
-
const vectorized = svgToVectorPaths(
|
|
78
|
+
const vectorized = svgToVectorPaths(
|
|
79
|
+
svg,
|
|
80
|
+
{ width: current.width, height: current.height },
|
|
81
|
+
{ profile: graph.documentColorSpace }
|
|
82
|
+
)
|
|
77
83
|
if (!vectorized?.paths.length) return { error: 'The vectorize service returned no paths' }
|
|
78
84
|
const frameId = createVectorFrameBeside(graph, id, vectorized)
|
|
79
85
|
const frame = frameId ? graph.getNode(frameId) : undefined
|
package/src/tools/video-host.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { underlyingGraph } from '#core/figma-api/graph-ref'
|
|
1
2
|
import type { VideoHostEncoder } from '#core/io/formats/video'
|
|
2
3
|
|
|
3
4
|
const encoders = new WeakMap<object, VideoHostEncoder>()
|
|
@@ -7,12 +8,13 @@ const encoders = new WeakMap<object, VideoHostEncoder>()
|
|
|
7
8
|
* WebCodecs cannot encode in that host, as the CLI does with ffmpeg. The app needs none.
|
|
8
9
|
*/
|
|
9
10
|
export function registerVideoEncoder(owner: object, encoder: VideoHostEncoder): () => void {
|
|
10
|
-
|
|
11
|
+
const target = underlyingGraph(owner)
|
|
12
|
+
encoders.set(target, encoder)
|
|
11
13
|
return () => {
|
|
12
|
-
if (encoders.get(
|
|
14
|
+
if (encoders.get(target) === encoder) encoders.delete(target)
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export function getVideoEncoder(owner: object): VideoHostEncoder | undefined {
|
|
17
|
-
return encoders.get(owner)
|
|
19
|
+
return encoders.get(underlyingGraph(owner))
|
|
18
20
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* normalize into each node's bounding box and build the transform in Figma's convention
|
|
10
10
|
* (see geometry/gradient).
|
|
11
11
|
*/
|
|
12
|
-
import type { Fill, GradientStop } from '@pairdraw/scene-graph'
|
|
12
|
+
import type { DocumentColorSpace, Fill, GradientStop } from '@pairdraw/scene-graph'
|
|
13
13
|
import { parseColor } from '@pairdraw/scene-graph/color'
|
|
14
14
|
import {
|
|
15
15
|
ellipticalGradientTransform,
|
|
@@ -59,12 +59,12 @@ function coord(value: string | null, fallback: number): number {
|
|
|
59
59
|
return Number.isFinite(n) ? n : fallback
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function readStops(gradient: SVGElementLike): RawStop[] {
|
|
62
|
+
function readStops(gradient: SVGElementLike, profile: DocumentColorSpace): RawStop[] {
|
|
63
63
|
const stops: RawStop[] = []
|
|
64
64
|
const stopEls = Array.from(gradient.getElementsByTagName('stop'))
|
|
65
65
|
for (const [i, stop] of stopEls.entries()) {
|
|
66
66
|
const offset = coord(stop.getAttribute('offset'), i === 0 ? 0 : 1)
|
|
67
|
-
const color = parseColor(stop.getAttribute('stop-color') ?? '#000000')
|
|
67
|
+
const color = parseColor(stop.getAttribute('stop-color') ?? '#000000', profile)
|
|
68
68
|
const opacity = stop.getAttribute('stop-opacity')
|
|
69
69
|
if (opacity != null) {
|
|
70
70
|
const a = Number.parseFloat(opacity)
|
|
@@ -80,7 +80,10 @@ function readStops(gradient: SVGElementLike): RawStop[] {
|
|
|
80
80
|
* (no hand-rolled markup parsing). Returns an empty map on parse failure so a
|
|
81
81
|
* malformed SVG simply falls back to solid fills.
|
|
82
82
|
*/
|
|
83
|
-
export function parseSVGGradients(
|
|
83
|
+
export function parseSVGGradients(
|
|
84
|
+
svg: string,
|
|
85
|
+
profile: DocumentColorSpace = 'srgb'
|
|
86
|
+
): Map<string, ParsedGradient> {
|
|
84
87
|
const map = new Map<string, ParsedGradient>()
|
|
85
88
|
const doc: SVGQueryable | null = parseSVGDocument(svg)
|
|
86
89
|
if (!doc) return map
|
|
@@ -100,7 +103,7 @@ export function parseSVGGradients(svg: string): Map<string, ParsedGradient> {
|
|
|
100
103
|
kind,
|
|
101
104
|
units,
|
|
102
105
|
transform: el.getAttribute('gradientTransform'),
|
|
103
|
-
stops: readStops(el),
|
|
106
|
+
stops: readStops(el, profile),
|
|
104
107
|
x1: coord(el.getAttribute('x1'), 0),
|
|
105
108
|
y1: coord(el.getAttribute('y1'), 0),
|
|
106
109
|
x2: coord(el.getAttribute('x2'), units === 'objectBoundingBox' ? 1 : 0),
|
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import svgpath from 'svgpath'
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
DocumentColorSpace,
|
|
12
|
+
Fill,
|
|
13
|
+
Stroke,
|
|
14
|
+
VectorNetwork,
|
|
15
|
+
WindingRule
|
|
16
|
+
} from '@pairdraw/scene-graph'
|
|
11
17
|
import { parseColor } from '@pairdraw/scene-graph/color'
|
|
12
18
|
import { computeBounds } from '@pairdraw/scene-graph/geometry'
|
|
13
19
|
import type { Mat3 } from '@pairdraw/scene-graph/matrix'
|
|
@@ -49,20 +55,35 @@ function unionPathBounds(paths: VectorizedPath[]): Rect {
|
|
|
49
55
|
return computeBounds(rects)
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
function resolveFill(
|
|
58
|
+
function resolveFill(
|
|
59
|
+
path: IconPathInfo,
|
|
60
|
+
defaultColor: string,
|
|
61
|
+
profile: DocumentColorSpace
|
|
62
|
+
): Fill[] {
|
|
53
63
|
if (path.fill && path.fill !== 'none') {
|
|
54
|
-
const color =
|
|
64
|
+
const color =
|
|
65
|
+
path.fill === 'currentColor'
|
|
66
|
+
? parseColor(defaultColor, profile)
|
|
67
|
+
: parseColor(path.fill, profile)
|
|
55
68
|
return [{ type: 'SOLID', color, opacity: path.fillOpacity, visible: true }]
|
|
56
69
|
}
|
|
57
70
|
if (path.fill === null && !path.stroke) {
|
|
58
|
-
return [{ type: 'SOLID', color: parseColor(defaultColor), opacity: 1, visible: true }]
|
|
71
|
+
return [{ type: 'SOLID', color: parseColor(defaultColor, profile), opacity: 1, visible: true }]
|
|
59
72
|
}
|
|
60
73
|
return []
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
function resolveStrokes(
|
|
76
|
+
function resolveStrokes(
|
|
77
|
+
path: IconPathInfo,
|
|
78
|
+
defaultColor: string,
|
|
79
|
+
strokeScale = 1,
|
|
80
|
+
profile: DocumentColorSpace = 'srgb'
|
|
81
|
+
): Stroke[] {
|
|
64
82
|
if (!path.stroke || path.stroke === 'none') return []
|
|
65
|
-
const color =
|
|
83
|
+
const color =
|
|
84
|
+
path.stroke === 'currentColor'
|
|
85
|
+
? parseColor(defaultColor, profile)
|
|
86
|
+
: parseColor(path.stroke, profile)
|
|
66
87
|
const stroke = createPathStroke(
|
|
67
88
|
color,
|
|
68
89
|
path.strokeWidth * strokeScale,
|
|
@@ -114,7 +135,12 @@ export interface SVGVectorizeResult {
|
|
|
114
135
|
export function svgToVectorPaths(
|
|
115
136
|
svgText: string,
|
|
116
137
|
bounds: Size,
|
|
117
|
-
options?: {
|
|
138
|
+
options?: {
|
|
139
|
+
defaultColor?: string
|
|
140
|
+
preserveAspectRatio?: boolean
|
|
141
|
+
/** The profile a color that names its own space is read into. */
|
|
142
|
+
profile?: DocumentColorSpace
|
|
143
|
+
}
|
|
118
144
|
): SVGVectorizeResult | null {
|
|
119
145
|
const { paths, texts } = extractSVGContent(svgText)
|
|
120
146
|
if (paths.length === 0 && texts.length === 0) return null
|
|
@@ -123,7 +149,8 @@ export function svgToVectorPaths(
|
|
|
123
149
|
if (space.width <= 0 || space.height <= 0) return null
|
|
124
150
|
|
|
125
151
|
const defaultColor = options?.defaultColor ?? '#000000'
|
|
126
|
-
const
|
|
152
|
+
const profile = options?.profile ?? 'srgb'
|
|
153
|
+
const gradients = parseSVGGradients(svgText, profile)
|
|
127
154
|
const viewport = resolveSVGViewportMapping(
|
|
128
155
|
svgText,
|
|
129
156
|
space,
|
|
@@ -139,8 +166,8 @@ export function svgToVectorPaths(
|
|
|
139
166
|
const transform = path.transform ?? null
|
|
140
167
|
const pathData = applySVGTransformToPath(path.d, transform)
|
|
141
168
|
const scaledD = mapSVGPathToViewport(pathData, viewport)
|
|
142
|
-
const solidFills = resolveFill(path, defaultColor)
|
|
143
|
-
const strokes = resolveStrokes(path, defaultColor, strokeScale)
|
|
169
|
+
const solidFills = resolveFill(path, defaultColor, profile)
|
|
170
|
+
const strokes = resolveStrokes(path, defaultColor, strokeScale, profile)
|
|
144
171
|
// A stroke would also trace the closing edge of an open subpath in the fill region.
|
|
145
172
|
const network = parseSVGPath(scaledD, fillRule, {
|
|
146
173
|
includeOpenRegions: solidFills.length > 0 && strokes.length === 0
|
|
@@ -171,7 +198,10 @@ export function svgToVectorPaths(
|
|
|
171
198
|
texts: texts.map((text) => ({
|
|
172
199
|
pieces: text.pieces.map((piece) => ({
|
|
173
200
|
...piece,
|
|
174
|
-
runs: piece.runs.map((run) => ({
|
|
201
|
+
runs: piece.runs.map((run) => ({
|
|
202
|
+
...run,
|
|
203
|
+
fills: resolveTextFill(run, defaultColor, profile)
|
|
204
|
+
}))
|
|
175
205
|
})),
|
|
176
206
|
matrix: transformMatrix(text.transform, viewport),
|
|
177
207
|
clips: text.clipPaths && vectorizeClips(text.clipPaths, viewport, null, clipCache),
|
|
@@ -253,10 +283,14 @@ function transformMatrix(transform: string | null, viewport: SVGViewportMapping)
|
|
|
253
283
|
]
|
|
254
284
|
}
|
|
255
285
|
|
|
256
|
-
function resolveTextFill(
|
|
286
|
+
function resolveTextFill(
|
|
287
|
+
run: SVGTextRun,
|
|
288
|
+
defaultColor: string,
|
|
289
|
+
profile: DocumentColorSpace
|
|
290
|
+
): Fill[] {
|
|
257
291
|
const color =
|
|
258
292
|
run.fill === null || run.fill === 'currentColor'
|
|
259
|
-
? parseColor(defaultColor)
|
|
260
|
-
: parseColor(run.fill)
|
|
293
|
+
? parseColor(defaultColor, profile)
|
|
294
|
+
: parseColor(run.fill, profile)
|
|
261
295
|
return [{ type: 'SOLID', color, opacity: run.fillOpacity, visible: true }]
|
|
262
296
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FontLoadedSource, FontUnavailableReason } from "./sources.js";
|
|
2
|
-
import { FontManager } from "./manager.js";
|
|
3
|
-
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
4
|
-
//#region src/text/font/status.d.ts
|
|
5
|
-
type FontFaceStatus = 'available' | 'substituted' | 'unresolved';
|
|
6
|
-
interface DocumentFontFaceStatus {
|
|
7
|
-
family: string;
|
|
8
|
-
/** The style the font manager loads the face as. */
|
|
9
|
-
style: string;
|
|
10
|
-
/** The face's name, as its text names it ("Book", "Semi Bold"). */
|
|
11
|
-
name: string;
|
|
12
|
-
status: FontFaceStatus;
|
|
13
|
-
source: FontLoadedSource | null;
|
|
14
|
-
substituteFamily: string | null;
|
|
15
|
-
/** Why the requested face could not be loaded, when the host reported a reason. */
|
|
16
|
-
reason: FontUnavailableReason | null;
|
|
17
|
-
nodeIds: string[];
|
|
18
|
-
nodeNames: string[];
|
|
19
|
-
}
|
|
20
|
-
interface DocumentFontStatus {
|
|
21
|
-
faithful: boolean;
|
|
22
|
-
faces: DocumentFontFaceStatus[];
|
|
23
|
-
issues: DocumentFontFaceStatus[];
|
|
24
|
-
}
|
|
25
|
-
declare function documentFontStatus(graph: SceneGraph, rootIds: string | readonly string[], manager?: FontManager): DocumentFontStatus;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { DocumentFontFaceStatus, DocumentFontStatus, FontFaceStatus, documentFontStatus };
|
|
28
|
-
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","names":[],"sources":["../../../src/text/font/status.ts"],"mappings":";;;;KAOY;UAEK;EACf;;EAEA;;EAEA;EACA,QAAQ;EACR,QAAQ;EACR;;EAEA,QAAQ;EACR;EACA;;UAGe;EACf;EACA,OAAO;EACP,QAAQ;;iBA2FM,mBACd,OAAO,YACP,qCACA,UAAS,cACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","names":[],"sources":["../../../src/text/font/status.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { fontManager, type FontManager } from '#core/text/font/manager'\nimport { collectNamedNodeFontFaces } from '#core/text/font/names'\nimport type { FontLoadedSource, FontUnavailableReason } from '#core/text/font/sources'\n\nexport type FontFaceStatus = 'available' | 'substituted' | 'unresolved'\n\nexport interface DocumentFontFaceStatus {\n family: string\n /** The style the font manager loads the face as. */\n style: string\n /** The face's name, as its text names it (\"Book\", \"Semi Bold\"). */\n name: string\n status: FontFaceStatus\n source: FontLoadedSource | null\n substituteFamily: string | null\n /** Why the requested face could not be loaded, when the host reported a reason. */\n reason: FontUnavailableReason | null\n nodeIds: string[]\n nodeNames: string[]\n}\n\nexport interface DocumentFontStatus {\n faithful: boolean\n faces: DocumentFontFaceStatus[]\n issues: DocumentFontFaceStatus[]\n}\n\ninterface MutableFontFaceUse {\n family: string\n style: string\n name: string\n nodeIds: Set<string>\n nodeNames: Set<string>\n}\n\n/** A face by its name and the style it loads as; one name may load as two styles. */\nfunction faceKey(family: string, style: string, name: string): string {\n return `${family}\\0${style}\\0${name}`\n}\n\n/** The text nodes under each root, and each root that is itself text. */\nfunction rootTextNodes(graph: SceneGraph, rootIds: readonly string[]): SceneNode[] {\n return rootIds.flatMap((rootId) => {\n const root = graph.getNode(rootId)\n if (!root) return []\n const nodes = [root, ...graph.flattenTree(rootId).map(({ node }) => node)]\n return nodes.filter((node) => node.type === 'TEXT')\n })\n}\n\nfunction collectFaceUses(graph: SceneGraph, rootIds: readonly string[]): MutableFontFaceUse[] {\n const uses = new Map<string, MutableFontFaceUse>()\n for (const node of rootTextNodes(graph, rootIds)) {\n // Faces that load as one style (\"Book\" and \"Roman\" at 400) are still faces of their own.\n for (const { family, style, name } of collectNamedNodeFontFaces(node)) {\n const key = faceKey(family, style, name)\n const use = uses.get(key) ?? {\n family,\n style,\n name,\n nodeIds: new Set<string>(),\n nodeNames: new Set<string>()\n }\n use.nodeIds.add(node.id)\n use.nodeNames.add(node.name)\n uses.set(key, use)\n }\n }\n return [...uses.values()]\n}\n\nfunction faceStatus(use: MutableFontFaceUse, manager: FontManager): DocumentFontFaceStatus {\n const exactSource = manager.loadedFontSource(use.family, use.style)\n if (exactSource) {\n return {\n family: use.family,\n style: use.style,\n name: use.name,\n status: 'available',\n source: exactSource,\n substituteFamily: null,\n reason: null,\n nodeIds: [...use.nodeIds],\n nodeNames: [...use.nodeNames]\n }\n }\n\n if (manager.isLoaded(use.family)) {\n return {\n family: use.family,\n style: use.style,\n name: use.name,\n status: 'substituted',\n source: null,\n substituteFamily: use.family,\n reason: manager.unavailableReason(use.family, use.style),\n nodeIds: [...use.nodeIds],\n nodeNames: [...use.nodeNames]\n }\n }\n\n const defaultSource = manager.loadedFontSource(DEFAULT_FONT_FAMILY, 'Regular')\n return {\n family: use.family,\n style: use.style,\n name: use.name,\n status: defaultSource ? 'substituted' : 'unresolved',\n source: null,\n substituteFamily: defaultSource ? DEFAULT_FONT_FAMILY : null,\n reason: manager.unavailableReason(use.family, use.style),\n nodeIds: [...use.nodeIds],\n nodeNames: [...use.nodeNames]\n }\n}\n\nexport function documentFontStatus(\n graph: SceneGraph,\n rootIds: string | readonly string[],\n manager: FontManager = fontManager\n): DocumentFontStatus {\n const roots = typeof rootIds === 'string' ? [rootIds] : rootIds\n const faces = collectFaceUses(graph, roots)\n .map((use) => faceStatus(use, manager))\n .sort((a, b) => a.family.localeCompare(b.family) || a.name.localeCompare(b.name))\n const issues = faces.filter((face) => face.status !== 'available')\n return { faithful: issues.length === 0, faces, issues }\n}\n"],"mappings":";;;;;AAuCA,SAAS,QAAQ,QAAgB,OAAe,MAAsB;CACpE,OAAO,GAAG,OAAO,IAAI,MAAM,IAAI;AACjC;;AAGA,SAAS,cAAc,OAAmB,SAAyC;CACjF,OAAO,QAAQ,SAAS,WAAW;EACjC,MAAM,OAAO,MAAM,QAAQ,MAAM;EACjC,IAAI,CAAC,MAAM,OAAO,CAAC;EAEnB,OAAO,CADQ,MAAM,GAAG,MAAM,YAAY,MAAM,CAAC,CAAC,KAAK,EAAE,WAAW,IAAI,CAC7D,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,MAAM;CACpD,CAAC;AACH;AAEA,SAAS,gBAAgB,OAAmB,SAAkD;CAC5F,MAAM,uBAAO,IAAI,IAAgC;CACjD,KAAK,MAAM,QAAQ,cAAc,OAAO,OAAO,GAE7C,KAAK,MAAM,EAAE,QAAQ,OAAO,UAAU,0BAA0B,IAAI,GAAG;EACrE,MAAM,MAAM,QAAQ,QAAQ,OAAO,IAAI;EACvC,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK;GAC3B;GACA;GACA;GACA,yBAAS,IAAI,IAAY;GACzB,2BAAW,IAAI,IAAY;EAC7B;EACA,IAAI,QAAQ,IAAI,KAAK,EAAE;EACvB,IAAI,UAAU,IAAI,KAAK,IAAI;EAC3B,KAAK,IAAI,KAAK,GAAG;CACnB;CAEF,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC;AAC1B;AAEA,SAAS,WAAW,KAAyB,SAA8C;CACzF,MAAM,cAAc,QAAQ,iBAAiB,IAAI,QAAQ,IAAI,KAAK;CAClE,IAAI,aACF,OAAO;EACL,QAAQ,IAAI;EACZ,OAAO,IAAI;EACX,MAAM,IAAI;EACV,QAAQ;EACR,QAAQ;EACR,kBAAkB;EAClB,QAAQ;EACR,SAAS,CAAC,GAAG,IAAI,OAAO;EACxB,WAAW,CAAC,GAAG,IAAI,SAAS;CAC9B;CAGF,IAAI,QAAQ,SAAS,IAAI,MAAM,GAC7B,OAAO;EACL,QAAQ,IAAI;EACZ,OAAO,IAAI;EACX,MAAM,IAAI;EACV,QAAQ;EACR,QAAQ;EACR,kBAAkB,IAAI;EACtB,QAAQ,QAAQ,kBAAkB,IAAI,QAAQ,IAAI,KAAK;EACvD,SAAS,CAAC,GAAG,IAAI,OAAO;EACxB,WAAW,CAAC,GAAG,IAAI,SAAS;CAC9B;CAGF,MAAM,gBAAgB,QAAQ,iBAAiB,qBAAqB,SAAS;CAC7E,OAAO;EACL,QAAQ,IAAI;EACZ,OAAO,IAAI;EACX,MAAM,IAAI;EACV,QAAQ,gBAAgB,gBAAgB;EACxC,QAAQ;EACR,kBAAkB,gBAAgB,sBAAsB;EACxD,QAAQ,QAAQ,kBAAkB,IAAI,QAAQ,IAAI,KAAK;EACvD,SAAS,CAAC,GAAG,IAAI,OAAO;EACxB,WAAW,CAAC,GAAG,IAAI,SAAS;CAC9B;AACF;AAEA,SAAgB,mBACd,OACA,SACA,UAAuB,aACH;CAEpB,MAAM,QAAQ,gBAAgB,OADhB,OAAO,YAAY,WAAW,CAAC,OAAO,IAAI,OACd,CAAC,CACxC,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,CAAC,CACtC,MAAM,GAAG,MAAM,EAAE,OAAO,cAAc,EAAE,MAAM,KAAK,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;CAClF,MAAM,SAAS,MAAM,QAAQ,SAAS,KAAK,WAAW,WAAW;CACjE,OAAO;EAAE,UAAU,OAAO,WAAW;EAAG;EAAO;CAAO;AACxD"}
|