@pairdraw/core 0.20.0 → 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/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/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.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/bridges/undo.d.ts +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.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/create.d.ts +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.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 +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/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.js +4 -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 +1 -0
- 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 +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/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 +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.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 +2 -2
- 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/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 +5 -2
- 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 +8 -1
- package/src/io/subgraph.ts +4 -1
- 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
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { fromUint8Array } from 'js-base64'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ColorProfile,
|
|
5
|
+
Fill,
|
|
6
|
+
FontVariation,
|
|
7
|
+
SceneGraph,
|
|
8
|
+
SceneNode
|
|
9
|
+
} from '@pairdraw/scene-graph'
|
|
4
10
|
import {
|
|
5
11
|
colorToHex,
|
|
6
|
-
|
|
12
|
+
colorToProfileCSS,
|
|
13
|
+
convertColor,
|
|
7
14
|
getDefaultRenderColorSpace,
|
|
8
15
|
type RenderColorSpace
|
|
9
16
|
} from '@pairdraw/scene-graph/color'
|
|
@@ -41,7 +48,10 @@ export interface SVGExportContext {
|
|
|
41
48
|
defs: SVGNode[]
|
|
42
49
|
defIdCounter: number
|
|
43
50
|
graph: SceneGraph
|
|
51
|
+
/** The space the export writes colors in. */
|
|
44
52
|
colorSpace: RenderColorSpace
|
|
53
|
+
/** The document's profile: the space its stored color components are in. */
|
|
54
|
+
documentColorSpace: ColorProfile
|
|
45
55
|
/** Starts every def id, so SVGs inlined on one page cannot reference each other's defs. */
|
|
46
56
|
idPrefix?: string
|
|
47
57
|
/** Paints drawn in `currentColor`, such as an icon's tinted paths, so CSS `color` sets them. */
|
|
@@ -60,12 +70,13 @@ export function nextDefId(ctx: SVGExportContext, prefix: string): string {
|
|
|
60
70
|
export function formatColor(
|
|
61
71
|
color: Color,
|
|
62
72
|
opacity = 1,
|
|
63
|
-
colorSpace: RenderColorSpace = getDefaultRenderColorSpace()
|
|
73
|
+
colorSpace: RenderColorSpace = getDefaultRenderColorSpace(),
|
|
74
|
+
documentSpace: ColorProfile = 'srgb'
|
|
64
75
|
): string {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
const painted = { ...color, a: color.a * opacity }
|
|
77
|
+
// Stored components sit in the document's profile; write the color in the profile it is shown in.
|
|
78
|
+
if (colorSpace === 'display-p3') return colorToProfileCSS(painted, documentSpace, 'display-p3')
|
|
79
|
+
const alphaColor = convertColor(painted, documentSpace, 'srgb')
|
|
69
80
|
// Hex has no alpha. Stops and shadows already emit theirs; solid fills use `solidFillOpacity`.
|
|
70
81
|
return colorToHex(alphaColor)
|
|
71
82
|
}
|
|
@@ -78,12 +89,13 @@ export function formatColor(
|
|
|
78
89
|
export function formatSolidColor(
|
|
79
90
|
color: Color,
|
|
80
91
|
opacity: number,
|
|
81
|
-
colorSpace: RenderColorSpace
|
|
92
|
+
colorSpace: RenderColorSpace,
|
|
93
|
+
documentSpace: ColorProfile = 'srgb'
|
|
82
94
|
): string {
|
|
83
95
|
if (colorSpace === 'display-p3') {
|
|
84
|
-
return formatColor({ ...color, a: 1 }, round(opacity), colorSpace)
|
|
96
|
+
return formatColor({ ...color, a: 1 }, round(opacity), colorSpace, documentSpace)
|
|
85
97
|
}
|
|
86
|
-
return formatColor(color, 1, colorSpace)
|
|
98
|
+
return formatColor(color, 1, colorSpace, documentSpace)
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
/**
|
|
@@ -113,7 +125,7 @@ function createGradientDef(
|
|
|
113
125
|
const stopNodes = stops.map((s) =>
|
|
114
126
|
svg('stop', {
|
|
115
127
|
offset: `${round(s.position * 100)}%`,
|
|
116
|
-
'stop-color': formatColor(s.color, 1, ctx.colorSpace),
|
|
128
|
+
'stop-color': formatColor(s.color, 1, ctx.colorSpace, ctx.documentColorSpace),
|
|
117
129
|
'stop-opacity': s.color.a < 1 ? round(s.color.a) : undefined
|
|
118
130
|
})
|
|
119
131
|
)
|
|
@@ -219,18 +231,18 @@ export function resolveFill(fill: Fill, node: SceneNode, ctx: SVGExportContext):
|
|
|
219
231
|
if (!fill.visible) return null
|
|
220
232
|
|
|
221
233
|
if (fill.type === 'SOLID') {
|
|
222
|
-
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace)
|
|
234
|
+
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace, ctx.documentColorSpace)
|
|
223
235
|
}
|
|
224
236
|
|
|
225
237
|
// SVG has no mesh element: a mesh exports its own color, as `.fig` records carry it.
|
|
226
238
|
if (fill.type === 'MESH') {
|
|
227
|
-
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace)
|
|
239
|
+
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace, ctx.documentColorSpace)
|
|
228
240
|
}
|
|
229
241
|
|
|
230
242
|
// The canvas draws a pattern, noise or custom paint as its own colour when the format has no
|
|
231
243
|
// element for it, so the export must not drop the layer.
|
|
232
244
|
if (fill.type === 'PATTERN' || fill.type === 'NOISE' || fill.type === 'CUSTOM') {
|
|
233
|
-
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace)
|
|
245
|
+
return formatSolidColor(fill.color, fill.opacity, ctx.colorSpace, ctx.documentColorSpace)
|
|
234
246
|
}
|
|
235
247
|
|
|
236
248
|
if (fill.type.startsWith('GRADIENT')) {
|
|
@@ -61,7 +61,7 @@ export function createFilterDef(
|
|
|
61
61
|
dx: round(effect.offset.x),
|
|
62
62
|
dy: round(effect.offset.y),
|
|
63
63
|
stdDeviation: round(effect.radius / 2),
|
|
64
|
-
'flood-color': floodColor(effect.color, ctx.colorSpace),
|
|
64
|
+
'flood-color': floodColor(effect.color, ctx.colorSpace, ctx.documentColorSpace),
|
|
65
65
|
'flood-opacity': round(effect.color.a),
|
|
66
66
|
result: dropped
|
|
67
67
|
})
|
|
@@ -87,7 +87,7 @@ export function createFilterDef(
|
|
|
87
87
|
})
|
|
88
88
|
filter.push('feComposite', { in: shape, in2: offset, operator: 'out', result: inverted })
|
|
89
89
|
filter.push('feFlood', {
|
|
90
|
-
'flood-color': floodColor(effect.color, ctx.colorSpace),
|
|
90
|
+
'flood-color': floodColor(effect.color, ctx.colorSpace, ctx.documentColorSpace),
|
|
91
91
|
'flood-opacity': round(effect.color.a),
|
|
92
92
|
result: shadow
|
|
93
93
|
})
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ColorProfile,
|
|
3
|
+
Fill,
|
|
4
|
+
SceneGraph,
|
|
5
|
+
SceneNode,
|
|
6
|
+
Stroke,
|
|
7
|
+
VectorNetwork
|
|
8
|
+
} from '@pairdraw/scene-graph'
|
|
1
9
|
import type { RenderColorSpace } from '@pairdraw/scene-graph/color'
|
|
2
10
|
|
|
3
11
|
import { normalizeDashPattern } from '#core/canvas/strokes'
|
|
@@ -29,7 +37,6 @@ import {
|
|
|
29
37
|
|
|
30
38
|
export { geometryBlobToSVGPath, nodeOutlinePath, type OutlineNode } from './paths'
|
|
31
39
|
|
|
32
|
-
import type { SceneGraph, SceneNode, Fill, Stroke, VectorNetwork } from '@pairdraw/scene-graph'
|
|
33
40
|
import { looseSegments, regionSVGPaths } from '@pairdraw/scene-graph/vector-network'
|
|
34
41
|
|
|
35
42
|
import type { BooleanPathResolver } from '#core/io/formats/boolean-path'
|
|
@@ -373,8 +380,9 @@ function buildSVGStrokeAttrs(
|
|
|
373
380
|
// viewer multiplies it by stroke-opacity; the canvas paints stroke.opacity alone.
|
|
374
381
|
stroke:
|
|
375
382
|
stroke.type === 'SOLID'
|
|
376
|
-
? formatSolidColor(stroke.color, 1, ctx.colorSpace)
|
|
377
|
-
: (resolveFill(stroke, node, ctx) ??
|
|
383
|
+
? formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)
|
|
384
|
+
: (resolveFill(stroke, node, ctx) ??
|
|
385
|
+
formatSolidColor(stroke.color, 1, ctx.colorSpace, ctx.documentColorSpace)),
|
|
378
386
|
'stroke-width': round(stroke.weight)
|
|
379
387
|
}
|
|
380
388
|
if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)
|
|
@@ -770,6 +778,8 @@ export interface SVGExportOptions {
|
|
|
770
778
|
xmlDeclaration?: boolean
|
|
771
779
|
/** Target export color space (default: srgb) */
|
|
772
780
|
colorSpace?: 'srgb' | 'display-p3'
|
|
781
|
+
/** The document's color profile; colors stored in it convert into `colorSpace`. */
|
|
782
|
+
documentColorSpace?: ColorProfile
|
|
773
783
|
/**
|
|
774
784
|
* Line breaks of text nodes as the editor laid them out, wraps included. Without them, only
|
|
775
785
|
* explicit newlines start a new baseline, which renderers that do not wrap SVG text keep.
|
|
@@ -805,6 +815,7 @@ export function renderNodesToSVG(
|
|
|
805
815
|
defIdCounter: 0,
|
|
806
816
|
graph,
|
|
807
817
|
colorSpace: options.colorSpace ?? 'srgb',
|
|
818
|
+
documentColorSpace: options.documentColorSpace ?? graph.documentColorSpace,
|
|
808
819
|
textLayout: options.textLayout,
|
|
809
820
|
fontAlias: options.fontAlias,
|
|
810
821
|
booleanPath: options.booleanPath
|
|
@@ -863,11 +874,13 @@ export function renderNodeSVGElement(
|
|
|
863
874
|
{
|
|
864
875
|
idPrefix,
|
|
865
876
|
colorSpace = 'srgb',
|
|
877
|
+
documentColorSpace,
|
|
866
878
|
tint,
|
|
867
879
|
booleanPath
|
|
868
880
|
}: Pick<SVGExportContext, 'tint' | 'booleanPath'> & {
|
|
869
881
|
idPrefix: string
|
|
870
882
|
colorSpace?: RenderColorSpace
|
|
883
|
+
documentColorSpace?: ColorProfile
|
|
871
884
|
}
|
|
872
885
|
): SVGNode | null {
|
|
873
886
|
const ctx: SVGExportContext = {
|
|
@@ -875,6 +888,7 @@ export function renderNodeSVGElement(
|
|
|
875
888
|
defIdCounter: 0,
|
|
876
889
|
graph,
|
|
877
890
|
colorSpace,
|
|
891
|
+
documentColorSpace: documentColorSpace ?? graph.documentColorSpace,
|
|
878
892
|
idPrefix,
|
|
879
893
|
tint,
|
|
880
894
|
booleanPath
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ColorProfile } from '@pairdraw/scene-graph'
|
|
1
2
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
2
3
|
|
|
3
4
|
import { formatColor, type SVGExportContext } from './defs'
|
|
@@ -7,8 +8,12 @@ import { svg, type SVGNode } from './node'
|
|
|
7
8
|
* A flood's colour, opaque: its alpha goes in `flood-opacity`, which a Display P3 colour would
|
|
8
9
|
* otherwise carry a second time.
|
|
9
10
|
*/
|
|
10
|
-
export function floodColor(
|
|
11
|
-
|
|
11
|
+
export function floodColor(
|
|
12
|
+
color: Color,
|
|
13
|
+
colorSpace: SVGExportContext['colorSpace'],
|
|
14
|
+
documentColorSpace: ColorProfile = 'srgb'
|
|
15
|
+
): string {
|
|
16
|
+
return formatColor({ ...color, a: 1 }, 1, colorSpace, documentColorSpace)
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
/** An SVG filter's primitives as they are added, each naming its result uniquely. */
|
|
@@ -35,6 +40,11 @@ export class FilterBuilder {
|
|
|
35
40
|
return this.ctx.colorSpace
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
/** The document's profile, where its stored colors are. */
|
|
44
|
+
get documentColorSpace(): ColorProfile {
|
|
45
|
+
return this.ctx.documentColorSpace
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
/** A new result name, unique in this filter. */
|
|
39
49
|
result(name: string): string {
|
|
40
50
|
this.count += 1
|
|
@@ -95,7 +95,7 @@ export function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: s
|
|
|
95
95
|
filter.push('feComposite', { in: band, in2: input, operator: 'in', result: clipped })
|
|
96
96
|
const flood = filter.result('noiseFlood')
|
|
97
97
|
filter.push('feFlood', {
|
|
98
|
-
'flood-color': floodColor(color, filter.colorSpace),
|
|
98
|
+
'flood-color': floodColor(color, filter.colorSpace, filter.documentColorSpace),
|
|
99
99
|
'flood-opacity': round(color.a),
|
|
100
100
|
result: flood
|
|
101
101
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { groupBy } from 'es-toolkit/array'
|
|
2
2
|
|
|
3
|
-
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
3
|
+
import type { DocumentColorSpace, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
4
4
|
import { WHITE } from '@pairdraw/scene-graph/constants'
|
|
5
5
|
import { fitEnclosingGroups } from '@pairdraw/scene-graph/group-bounds'
|
|
6
6
|
import type { Size } from '@pairdraw/scene-graph/primitives'
|
|
@@ -31,6 +31,8 @@ export type SVGImportData = SVGVectorizeResult &
|
|
|
31
31
|
export interface SVGImportOptions {
|
|
32
32
|
name?: string
|
|
33
33
|
defaultColor?: string
|
|
34
|
+
/** The profile a color that names its own space is read into. */
|
|
35
|
+
profile?: DocumentColorSpace
|
|
34
36
|
x?: number
|
|
35
37
|
y?: number
|
|
36
38
|
/** Keep the frame of an SVG that draws nothing, as `figma.createNodeFromSvg` does. */
|
|
@@ -40,7 +42,7 @@ export interface SVGImportOptions {
|
|
|
40
42
|
/** The layers SVG markup draws, or null when it does not parse as SVG. */
|
|
41
43
|
export function prepareSVGImport(
|
|
42
44
|
source: string,
|
|
43
|
-
options: Pick<SVGImportOptions, 'defaultColor'> = {}
|
|
45
|
+
options: Pick<SVGImportOptions, 'defaultColor' | 'profile'> = {}
|
|
44
46
|
): SVGImportData | null {
|
|
45
47
|
if (!parseSVGDocument(source)) return null
|
|
46
48
|
const sized = parseSVGSize(source, { width: 0, height: 0 }).width > 0
|
|
@@ -50,7 +52,8 @@ export function prepareSVGImport(
|
|
|
50
52
|
{ width, height },
|
|
51
53
|
{
|
|
52
54
|
defaultColor: options.defaultColor,
|
|
53
|
-
preserveAspectRatio: true
|
|
55
|
+
preserveAspectRatio: true,
|
|
56
|
+
profile: options.profile
|
|
54
57
|
}
|
|
55
58
|
) ?? { paths: [], texts: [], contentBounds: { x: 0, y: 0, width: 0, height: 0 } }
|
|
56
59
|
return { width, height, name: svgRootId(source), sized, ...vectorized }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'
|
|
1
|
+
import type { CharacterStyleOverride, ColorProfile, SceneNode } from '@pairdraw/scene-graph'
|
|
2
2
|
import { parseFontStyle } from '@pairdraw/scene-graph/font-style'
|
|
3
3
|
import { textLengthPixels } from '@pairdraw/scene-graph/text'
|
|
4
4
|
import { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'
|
|
@@ -26,6 +26,7 @@ import { textFontFace } from '#core/text/requirements/collect'
|
|
|
26
26
|
function styleOverrideToTspanAttrs(
|
|
27
27
|
style: CharacterStyleOverride,
|
|
28
28
|
colorSpace: 'srgb' | 'display-p3',
|
|
29
|
+
documentSpace: ColorProfile,
|
|
29
30
|
parentFillOpacity: number | undefined,
|
|
30
31
|
node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>
|
|
31
32
|
): Record<string, string | number | undefined> {
|
|
@@ -54,9 +55,9 @@ function styleOverrideToTspanAttrs(
|
|
|
54
55
|
// Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.
|
|
55
56
|
const alpha = round(visibleFill.color.a * visibleFill.opacity)
|
|
56
57
|
if (colorSpace === 'display-p3') {
|
|
57
|
-
attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace)
|
|
58
|
+
attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace, documentSpace)
|
|
58
59
|
} else {
|
|
59
|
-
attrs.fill = formatColor(visibleFill.color, 1, colorSpace)
|
|
60
|
+
attrs.fill = formatColor(visibleFill.color, 1, colorSpace, documentSpace)
|
|
60
61
|
if (alpha < 1) attrs['fill-opacity'] = alpha
|
|
61
62
|
}
|
|
62
63
|
// `fill-opacity` inherits, so an opaque run has to cover a translucent parent.
|
|
@@ -105,12 +106,13 @@ function spanFontAttrs(
|
|
|
105
106
|
*/
|
|
106
107
|
function textStrokeAttrs(
|
|
107
108
|
node: SceneNode,
|
|
108
|
-
colorSpace: 'srgb' | 'display-p3'
|
|
109
|
+
colorSpace: 'srgb' | 'display-p3',
|
|
110
|
+
documentSpace: ColorProfile = 'srgb'
|
|
109
111
|
): Record<string, string | number | undefined> {
|
|
110
112
|
const stroke = node.strokes.find((candidate) => candidate.visible)
|
|
111
113
|
if (!stroke) return {}
|
|
112
114
|
const attrs: Record<string, string | number | undefined> = {
|
|
113
|
-
stroke: formatSolidColor(stroke.color, 1, colorSpace),
|
|
115
|
+
stroke: formatSolidColor(stroke.color, 1, colorSpace, documentSpace),
|
|
114
116
|
'stroke-width': round(stroke.weight * (stroke.align === 'OUTSIDE' ? 2 : 1))
|
|
115
117
|
}
|
|
116
118
|
if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)
|
|
@@ -202,7 +204,7 @@ export function renderTextNode(
|
|
|
202
204
|
ctx: SVGExportContext,
|
|
203
205
|
fillOpacity?: number
|
|
204
206
|
): SVGNode {
|
|
205
|
-
const { colorSpace, textLayout, fontAlias } = ctx
|
|
207
|
+
const { colorSpace, documentColorSpace: documentSpace, textLayout, fontAlias } = ctx
|
|
206
208
|
const direction = resolveNodeTextDirection(node)
|
|
207
209
|
const lines = textLayout ? textLayout(node) : null
|
|
208
210
|
const laidOut = lines && lines.length > 0 ? lines : null
|
|
@@ -224,11 +226,11 @@ export function renderTextNode(
|
|
|
224
226
|
'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),
|
|
225
227
|
'text-decoration': textDecoration,
|
|
226
228
|
'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,
|
|
227
|
-
...textStrokeAttrs(node, colorSpace),
|
|
229
|
+
...textStrokeAttrs(node, colorSpace, documentSpace),
|
|
228
230
|
...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})
|
|
229
231
|
}
|
|
230
232
|
const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({
|
|
231
|
-
...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),
|
|
233
|
+
...styleOverrideToTspanAttrs(style, colorSpace, documentSpace, fillOpacity, node),
|
|
232
234
|
...spanFontAttrs(node, style, fallback, fontAlias)
|
|
233
235
|
})
|
|
234
236
|
|
|
@@ -6,7 +6,7 @@ import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
|
6
6
|
import { withPDFTextLayout } from '#core/io/formats/pdf/prepare'
|
|
7
7
|
import { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'
|
|
8
8
|
import { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'
|
|
9
|
-
import {
|
|
9
|
+
import { resolveFontReadiness } from '#core/text/prepare'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each
|
|
@@ -22,7 +22,7 @@ export async function renderNodesToLaidOutSVG(
|
|
|
22
22
|
canvasKit?: CanvasKit,
|
|
23
23
|
renderer?: SkiaRenderer
|
|
24
24
|
): Promise<string | null> {
|
|
25
|
-
await
|
|
25
|
+
await resolveFontReadiness(graph, nodeIds)
|
|
26
26
|
const baked = hasAdjustedImagePaints(graph, nodeIds)
|
|
27
27
|
? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)
|
|
28
28
|
: graph
|
package/src/io/formats.ts
CHANGED
|
@@ -351,7 +351,14 @@ export const svgFormat: IOFormatAdapter<'svg'> = {
|
|
|
351
351
|
request.graph,
|
|
352
352
|
target.pageId,
|
|
353
353
|
target.nodeIds,
|
|
354
|
-
{
|
|
354
|
+
{
|
|
355
|
+
...options,
|
|
356
|
+
// An export writes the profile the document is stored in, so a Display P3 color keeps its
|
|
357
|
+
// gamut; a caller may still ask for sRGB. PDF and thumbnails render SVG themselves and
|
|
358
|
+
// stay sRGB, as their formats expect.
|
|
359
|
+
colorSpace: options?.colorSpace ?? request.graph.documentColorSpace,
|
|
360
|
+
booleanPath
|
|
361
|
+
},
|
|
355
362
|
context?.canvasKit,
|
|
356
363
|
context?.renderer
|
|
357
364
|
)
|
package/src/io/subgraph.ts
CHANGED
|
@@ -138,7 +138,10 @@ function copyReferencedTables(source: SceneGraph, graph: SceneGraph): void {
|
|
|
138
138
|
variableIds: []
|
|
139
139
|
})
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
// A collection lists its live variables; a deleted one is copied out of the list (addVariable).
|
|
142
|
+
if (!variable.deleted) {
|
|
143
|
+
graph.variableCollections.get(collection.id)?.variableIds.push(variableId)
|
|
144
|
+
}
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -13,6 +13,7 @@ export type FigReaderDiagnostic =
|
|
|
13
13
|
}
|
|
14
14
|
| { kind: 'component'; diagnostic: Parameters<Handler<'onMissingComponent'>>[0] }
|
|
15
15
|
| { kind: 'slot-content'; diagnostic: Parameters<Handler<'onMissingSlotContent'>>[0] }
|
|
16
|
+
| { kind: 'variable-type'; diagnostic: Parameters<Handler<'onUnsupportedVariableType'>>[0] }
|
|
16
17
|
|
|
17
18
|
/** Each sink's entries, so a record reported again is not listed twice. */
|
|
18
19
|
const reported = new WeakMap<FigReaderDiagnostic[], Set<string>>()
|
|
@@ -50,6 +51,8 @@ export function readerSessionOptions(sink: FigReaderDiagnostic[]): DocumentAssem
|
|
|
50
51
|
onUnsupportedVariableExpression: (diagnostic) =>
|
|
51
52
|
report(sink, { kind: 'variable-expression', diagnostic }),
|
|
52
53
|
onMissingComponent: (diagnostic) => report(sink, { kind: 'component', diagnostic }),
|
|
53
|
-
onMissingSlotContent: (diagnostic) => report(sink, { kind: 'slot-content', diagnostic })
|
|
54
|
+
onMissingSlotContent: (diagnostic) => report(sink, { kind: 'slot-content', diagnostic }),
|
|
55
|
+
onUnsupportedVariableType: (resource) =>
|
|
56
|
+
report(sink, { kind: 'variable-type', diagnostic: resource })
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -25,8 +25,16 @@ export function liveYogaNodeCount(): number {
|
|
|
25
25
|
return liveYogaNodes
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** Yoga nodes created since the process started, which tests read to see a pass build what it places. */
|
|
29
|
+
let yogaNodeCreations = 0
|
|
30
|
+
|
|
31
|
+
export function yogaNodeCreationCount(): number {
|
|
32
|
+
return yogaNodeCreations
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
export function createYogaNode(): YogaNode {
|
|
29
36
|
liveYogaNodes += 1
|
|
37
|
+
yogaNodeCreations += 1
|
|
30
38
|
return Yoga.Node.create(yogaConfig)
|
|
31
39
|
}
|
|
32
40
|
|
package/src/layout.ts
CHANGED
|
@@ -36,7 +36,7 @@ export {
|
|
|
36
36
|
} from './layout/text-measurement'
|
|
37
37
|
import type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
38
38
|
import { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'
|
|
39
|
-
import { layoutSizing } from '@pairdraw/scene-graph/layout'
|
|
39
|
+
import { enforcedAspectRatio, layoutSizing } from '@pairdraw/scene-graph/layout'
|
|
40
40
|
|
|
41
41
|
import { fitShapeWithTextFrame } from './layout/shape-with-text'
|
|
42
42
|
import {
|
|
@@ -376,6 +376,47 @@ function configureAutoLayoutChildSizing(
|
|
|
376
376
|
else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Whether the parent's pass places this child from the size it holds: neither its content nor the
|
|
381
|
+
* parent decides its size, so its own cells keep their places while the parent moves it.
|
|
382
|
+
*/
|
|
383
|
+
function placesFromSize(
|
|
384
|
+
child: SceneNode,
|
|
385
|
+
parent: SceneNode,
|
|
386
|
+
widthSizing: LayoutSizing,
|
|
387
|
+
heightSizing: LayoutSizing
|
|
388
|
+
): boolean {
|
|
389
|
+
return (
|
|
390
|
+
widthSizing === 'FIXED' &&
|
|
391
|
+
heightSizing === 'FIXED' &&
|
|
392
|
+
child.layoutGrow === 0 &&
|
|
393
|
+
parent.counterAxisAlign !== 'BASELINE' &&
|
|
394
|
+
child.layoutAlignSelf !== 'BASELINE' &&
|
|
395
|
+
enforcedAspectRatio(child) === null &&
|
|
396
|
+
child.minWidth === null &&
|
|
397
|
+
child.maxWidth === null &&
|
|
398
|
+
child.minHeight === null &&
|
|
399
|
+
child.maxHeight === null
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Refuses a chain deeper than Yoga can lay out, for the subtrees a pass places from their size and
|
|
405
|
+
* does not build: the same refusal, without the Yoga nodes.
|
|
406
|
+
*/
|
|
407
|
+
function assertLayoutDepth(graph: SceneGraph, frame: SceneNode, depth: number): void {
|
|
408
|
+
if (depth > MAX_LAYOUT_DEPTH) {
|
|
409
|
+
throw new RangeError(
|
|
410
|
+
`Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
for (const child of graph.getChildren(frame.id)) {
|
|
414
|
+
if (child.layoutMode === 'NONE' || !child.visible) continue
|
|
415
|
+
if (child.layoutPositioning === 'ABSOLUTE') continue
|
|
416
|
+
assertLayoutDepth(graph, child, depth + 1)
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
379
420
|
function configureChildAsAutoLayout(
|
|
380
421
|
yogaChild: YogaNode,
|
|
381
422
|
child: SceneNode,
|
|
@@ -410,6 +451,11 @@ function configureChildAsAutoLayout(
|
|
|
410
451
|
return
|
|
411
452
|
}
|
|
412
453
|
|
|
454
|
+
if (placesFromSize(child, parent, widthSizing, heightSizing)) {
|
|
455
|
+
assertLayoutDepth(graph, child, depth + 1)
|
|
456
|
+
return
|
|
457
|
+
}
|
|
458
|
+
|
|
413
459
|
configureFlexContainer(yogaChild, child, direction)
|
|
414
460
|
const heldAxis = heldHugAxis(graph, child)
|
|
415
461
|
if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)
|
package/src/lint/linter.ts
CHANGED
|
@@ -334,7 +334,7 @@ function describeVariables(graph: SceneGraph): LintVariables {
|
|
|
334
334
|
const counts = { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 }
|
|
335
335
|
const colorsByHex = new Map<string, { id: string; name: string }>()
|
|
336
336
|
const numbersByField = new Map<TokenNumberField, Map<number, { id: string; name: string }[]>>()
|
|
337
|
-
for (const variable of graph.
|
|
337
|
+
for (const variable of graph.getLiveVariables()) {
|
|
338
338
|
counts[variable.type]++
|
|
339
339
|
if (variable.type === 'FLOAT') {
|
|
340
340
|
const namespace = variableNamespace(variable)
|
|
@@ -111,6 +111,11 @@ export class CommentHandle {
|
|
|
111
111
|
return commentPosition(this.graph, this.thread)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** The area the person circled, in canvas units relative to the pin; null for a clicked pin. */
|
|
115
|
+
get region(): CommentThread['region'] {
|
|
116
|
+
return this.thread.region ?? null
|
|
117
|
+
}
|
|
118
|
+
|
|
114
119
|
get replies(): { id: string; author: string; text: string; createdAt: string }[] {
|
|
115
120
|
return liveReplies(this.thread).map(({ id, author, text, createdAt }) => ({
|
|
116
121
|
id,
|
|
@@ -151,6 +156,7 @@ export class CommentHandle {
|
|
|
151
156
|
page: this.page,
|
|
152
157
|
node: this.node,
|
|
153
158
|
position: this.position,
|
|
159
|
+
region: this.region,
|
|
154
160
|
replies: this.replies
|
|
155
161
|
}
|
|
156
162
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { exposeInstanceSwap } from '#core/figma-api/components'
|
|
18
18
|
import type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api/index'
|
|
19
19
|
import { writeVariableValue } from '#core/figma-api/variables'
|
|
20
|
-
import {
|
|
20
|
+
import { readFontReadiness, type FontReadiness } from '#core/text/font/readiness'
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
23
|
getBehaviour,
|
|
@@ -90,15 +90,13 @@ export class PairdrawAPI {
|
|
|
90
90
|
modeName?: string
|
|
91
91
|
): VariableLiteral {
|
|
92
92
|
const graph = this.figma.graph
|
|
93
|
-
const collections =
|
|
94
|
-
(item) => item.name === collectionName
|
|
95
|
-
)
|
|
93
|
+
const collections = graph.getLiveCollections().filter((item) => item.name === collectionName)
|
|
96
94
|
const collection = collections.at(0)
|
|
97
95
|
if (!collection || collections.length !== 1)
|
|
98
96
|
throw new Error(`Unknown or ambiguous collection: ${collectionName}`)
|
|
99
|
-
const variables =
|
|
100
|
-
(
|
|
101
|
-
|
|
97
|
+
const variables = graph
|
|
98
|
+
.getLiveVariables()
|
|
99
|
+
.filter((item) => item.collectionId === collection.id && item.name === variableName)
|
|
102
100
|
const variable = variables.at(0)
|
|
103
101
|
if (!variable || variables.length !== 1)
|
|
104
102
|
throw new Error(`Unknown or ambiguous variable: ${variableName}`)
|
|
@@ -266,8 +264,8 @@ export class PairdrawAPI {
|
|
|
266
264
|
* Whether the current page's fonts are faithfully available: requested faces, where each
|
|
267
265
|
* loaded from, substitutions, why an installed face could not load, and the layers affected.
|
|
268
266
|
*/
|
|
269
|
-
getFontStatus():
|
|
270
|
-
return
|
|
267
|
+
getFontStatus(): FontReadiness {
|
|
268
|
+
return readFontReadiness(this.figma.graph, this.figma.currentPageId)
|
|
271
269
|
}
|
|
272
270
|
|
|
273
271
|
/** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */
|
package/src/rpc/read-commands.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type { BooleanOperation, MaskType, SceneGraph, SceneNode } from '@pairdra
|
|
|
4
4
|
|
|
5
5
|
import { shapeDetailFields } from '#core/figma-api/shape-details'
|
|
6
6
|
import { ELLIPSIS } from '#core/text/ellipsis'
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
7
|
+
import type { FontReadiness } from '#core/text/font/readiness'
|
|
8
|
+
import { resolveFontReadiness } from '#core/text/prepare'
|
|
9
9
|
import { queryByXPath } from '#core/xpath'
|
|
10
10
|
|
|
11
11
|
import type { RPCCommand } from './types'
|
|
@@ -104,11 +104,11 @@ export const infoCommand: RPCCommand<void, InfoResult> = {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
export const fontStatusCommand: RPCCommand<void,
|
|
107
|
+
export const fontStatusCommand: RPCCommand<void, FontReadiness> = {
|
|
108
108
|
name: 'font-status',
|
|
109
109
|
execute: async (graph) => {
|
|
110
110
|
const pageIds = graph.getPages().map((page) => page.id)
|
|
111
|
-
return
|
|
111
|
+
return resolveFontReadiness(graph, pageIds.length > 0 ? pageIds : [graph.rootId])
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -63,7 +63,7 @@ export const variablesCommand: RPCCommand<VariablesArgs, VariablesResult> = {
|
|
|
63
63
|
|
|
64
64
|
const result: VariablesResult = { collections: [], totalVariables: 0, totalCollections: 0 }
|
|
65
65
|
|
|
66
|
-
for (const coll of graph.
|
|
66
|
+
for (const coll of graph.getLiveCollections()) {
|
|
67
67
|
if (collFilter && !coll.name.toLowerCase().includes(collFilter)) continue
|
|
68
68
|
|
|
69
69
|
const collVars = graph
|
|
@@ -120,7 +120,7 @@ async function designTokenFiles(graph: SceneGraph): Promise<TokensResult> {
|
|
|
120
120
|
const { files, issues } = exportDesignTokens(graph)
|
|
121
121
|
return {
|
|
122
122
|
css: '',
|
|
123
|
-
tokenCount: graph.
|
|
123
|
+
tokenCount: graph.getLiveVariables().length,
|
|
124
124
|
issues: issues.map(designTokenIssueMessage),
|
|
125
125
|
files
|
|
126
126
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'
|
|
2
|
+
|
|
3
|
+
import { fontManager } from './manager'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A share of the font provider `canvasKit` draws from. Every renderer and shaper holds one for as
|
|
7
|
+
* long as it reads text, so a face registered by one is shaped by all of them, and the last share
|
|
8
|
+
* given back deletes the provider. Releasing twice is safe and does nothing the second time.
|
|
9
|
+
*/
|
|
10
|
+
export interface FontProviderLease {
|
|
11
|
+
readonly provider: TypefaceFontProvider
|
|
12
|
+
release(): void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function leaseFontProvider(canvasKit: CanvasKit): FontProviderLease {
|
|
16
|
+
const provider = fontManager.acquireProvider(canvasKit)
|
|
17
|
+
let held = true
|
|
18
|
+
return {
|
|
19
|
+
provider,
|
|
20
|
+
release() {
|
|
21
|
+
if (!held) return
|
|
22
|
+
held = false
|
|
23
|
+
fontManager.releaseProvider(provider)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|