@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/canvas/renderer.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { isEqual } from 'es-toolkit'
|
|
2
2
|
import { toUint8Array } from 'js-base64'
|
|
3
3
|
|
|
4
|
-
import type { SceneNode, SceneGraph, Fill, Stroke } from '@pairdraw/scene-graph'
|
|
5
|
-
import
|
|
4
|
+
import type { ColorProfile, SceneNode, SceneGraph, Fill, Stroke } from '@pairdraw/scene-graph'
|
|
5
|
+
import {
|
|
6
|
+
normalizeColor,
|
|
7
|
+
toExtendedSRGB,
|
|
8
|
+
type RenderColorSpace,
|
|
9
|
+
type ResolvedRenderColor
|
|
10
|
+
} from '@pairdraw/scene-graph/color'
|
|
6
11
|
import type { Color, Vector } from '@pairdraw/scene-graph/primitives'
|
|
7
12
|
import { slotPropertyId } from '@pairdraw/scene-graph/slots'
|
|
8
13
|
|
|
@@ -24,6 +29,7 @@ import {
|
|
|
24
29
|
} from '#core/constants'
|
|
25
30
|
import type { EditorState } from '#core/editor/types'
|
|
26
31
|
import { RenderProfiler } from '#core/profiler'
|
|
32
|
+
import type { FontProviderLease } from '#core/text/font/provider'
|
|
27
33
|
import type { FontResolutionSnapshot } from '#core/text/resolver'
|
|
28
34
|
|
|
29
35
|
import { createImageCache } from './images/cache'
|
|
@@ -34,6 +40,7 @@ import { LabelParagraphCache } from './labels/paragraph-cache'
|
|
|
34
40
|
import { labelHitOptions } from './labels/style'
|
|
35
41
|
import { NodePathCaches } from './paths/cache'
|
|
36
42
|
import * as RenderColors from './renderer/colors'
|
|
43
|
+
import { releaseDocumentSurface, type DocumentSurface } from './renderer/document-surface'
|
|
37
44
|
import * as RendererFonts from './renderer/fonts'
|
|
38
45
|
import { destroyRenderer, releaseLiveImages } from './renderer/lifecycle'
|
|
39
46
|
import { installRendererDomainMethods, type RendererDomainMethods } from './renderer/methods'
|
|
@@ -161,6 +168,8 @@ export class SkiaRenderer {
|
|
|
161
168
|
hudFont: Font | null = null
|
|
162
169
|
fontMgr: FontMgr | null = null
|
|
163
170
|
fontProvider: TypefaceFontProvider | null = null
|
|
171
|
+
/** The renderer's share of the shared provider; released on dispose and before a reload. */
|
|
172
|
+
fontLease: FontProviderLease | null = null
|
|
164
173
|
fontsLoaded = false
|
|
165
174
|
/** Set once fonts are prepared for a one-shot export, so a pending face stops holding text back. */
|
|
166
175
|
exportFontsSettled = false
|
|
@@ -223,8 +232,15 @@ export class SkiaRenderer {
|
|
|
223
232
|
/** What an empty connector label shows while it is typed into; null draws nothing. */
|
|
224
233
|
connectorLabelPlaceholder: string | null = null
|
|
225
234
|
tracksSceneSettlement = true
|
|
226
|
-
/** Colour space this renderer's surface presents; colours convert into it when
|
|
235
|
+
/** Colour space this renderer's surface presents; colours convert into it when panting chrome. */
|
|
227
236
|
presentationColorSpace: RenderColorSpace = 'srgb'
|
|
237
|
+
/**
|
|
238
|
+
* The color profile of the document being drawn: surfaces it is drawn on hold its colors in it,
|
|
239
|
+
* and its blend modes work in it.
|
|
240
|
+
*/
|
|
241
|
+
documentColorSpace: ColorProfile = 'srgb'
|
|
242
|
+
/** A surface in the document's profile the size of the screen's, while the two differ. */
|
|
243
|
+
documentSurface: DocumentSurface | null = null
|
|
228
244
|
tiledScenePending = false
|
|
229
245
|
tiledSceneCovered = false
|
|
230
246
|
lastSceneViewport: { panX: number; panY: number; zoom: number } | null = null
|
|
@@ -511,6 +527,7 @@ export class SkiaRenderer {
|
|
|
511
527
|
}
|
|
512
528
|
|
|
513
529
|
replaceSurface(surface: Surface): void {
|
|
530
|
+
releaseDocumentSurface(this)
|
|
514
531
|
this.tiledScene.destroy()
|
|
515
532
|
// Live textures belong to the old surface's context, so they go before it does.
|
|
516
533
|
releaseLiveImages(this)
|
|
@@ -750,7 +767,7 @@ export class SkiaRenderer {
|
|
|
750
767
|
}
|
|
751
768
|
|
|
752
769
|
resolveFillColor(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph): Color {
|
|
753
|
-
return RenderColors.resolveFillColor(fill, fillIndex, node, graph
|
|
770
|
+
return RenderColors.resolveFillColor(fill, fillIndex, node, graph)
|
|
754
771
|
}
|
|
755
772
|
|
|
756
773
|
resolveStrokeColorInfo(
|
|
@@ -774,13 +791,21 @@ export class SkiaRenderer {
|
|
|
774
791
|
node: SceneNode,
|
|
775
792
|
graph: SceneGraph
|
|
776
793
|
): Color {
|
|
777
|
-
return RenderColors.resolveStrokeColor(
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
794
|
+
return RenderColors.resolveStrokeColor(stroke, strokeIndex, node, graph)
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* A color stored in the document, such as an effect's, as Skia is given it: in extended sRGB,
|
|
799
|
+
* which Skia converts into the document's space of the surfaces the document is drawn on.
|
|
800
|
+
*/
|
|
801
|
+
renderColor(color: Color): Color {
|
|
802
|
+
return toExtendedSRGB(normalizeColor(color), this.documentColorSpace)
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** Draws on surfaces in `space` from now on. */
|
|
806
|
+
useDocumentColorSpace(space: ColorProfile): void {
|
|
807
|
+
if (this.documentColorSpace === space) return
|
|
808
|
+
this.documentColorSpace = space
|
|
784
809
|
}
|
|
785
810
|
|
|
786
811
|
screenToCanvas(sx: number, sy: number): Vector {
|
package/src/canvas/scene.ts
CHANGED
|
@@ -20,6 +20,7 @@ import Matrix from '@pairdraw/scene-graph/matrix'
|
|
|
20
20
|
import type { Color, Vector } from '@pairdraw/scene-graph/primitives'
|
|
21
21
|
import { textLinesReach, textVerticalOffset } from '@pairdraw/scene-graph/text'
|
|
22
22
|
|
|
23
|
+
import { skColorSpace } from '#core/canvas/renderer/colors'
|
|
23
24
|
import { createSceneGeometry, nodeOrientationMatrix, projectedNode } from '#core/geometry'
|
|
24
25
|
import { liftedChildIds, scrollShiftX, scrollShiftY } from '#core/prototype/scroll'
|
|
25
26
|
import { shownText } from '#core/text/case'
|
|
@@ -709,7 +710,7 @@ export function renderShape(
|
|
|
709
710
|
height: Math.ceil(height * scale),
|
|
710
711
|
colorType: r.ck.ColorType.RGBA_8888,
|
|
711
712
|
alphaType: r.ck.AlphaType.Premul,
|
|
712
|
-
colorSpace: r.ck.
|
|
713
|
+
colorSpace: skColorSpace(r.ck, r.documentColorSpace)
|
|
713
714
|
})
|
|
714
715
|
const rasterCanvas = surface.getCanvas()
|
|
715
716
|
try {
|
|
@@ -1202,7 +1203,7 @@ function drawPaintedText(r: SkiaRenderer, canvas: Canvas, node: SceneNode): bool
|
|
|
1202
1203
|
},
|
|
1203
1204
|
(paragraph, prepared) => {
|
|
1204
1205
|
const y = textVerticalOffset(node, paragraph.getHeight())
|
|
1205
|
-
drawTextLayout(r.ck, canvas, node, prepared, y, r.fillPaint)
|
|
1206
|
+
drawTextLayout(r.ck, canvas, node, prepared, y, r.fillPaint, r.documentColorSpace)
|
|
1206
1207
|
return true
|
|
1207
1208
|
}
|
|
1208
1209
|
)
|
|
@@ -1299,7 +1300,7 @@ export function renderText(r: SkiaRenderer, canvas: Canvas, node: SceneNode, fil
|
|
|
1299
1300
|
{ halfLeading: true },
|
|
1300
1301
|
(paragraph, prepared) => {
|
|
1301
1302
|
const paragraphY = textVerticalOffset(node, paragraph.getHeight())
|
|
1302
|
-
drawTextLayout(r.ck, canvas, node, prepared, paragraphY, r.fillPaint)
|
|
1303
|
+
drawTextLayout(r.ck, canvas, node, prepared, paragraphY, r.fillPaint, r.documentColorSpace)
|
|
1303
1304
|
}
|
|
1304
1305
|
)
|
|
1305
1306
|
} else if (r.textFont) {
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
type ShaderUniformValue
|
|
15
15
|
} from '@pairdraw/scene-graph/shaders'
|
|
16
16
|
|
|
17
|
+
import { ResourceCache } from '#core/cache/resource'
|
|
18
|
+
|
|
17
19
|
import { FRAME_HEIGHT_UNIFORM, OBJECT_SIZE_UNIFORM, translateShader } from './translate'
|
|
18
20
|
|
|
19
21
|
/** A shader source with its compiled effect, or why it could not compile. */
|
|
@@ -24,8 +26,14 @@ export interface CompiledShader {
|
|
|
24
26
|
error: string | null
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
const
|
|
29
|
+
/** Sources compiled per CanvasKit instance; the shader library and edits share this budget. */
|
|
30
|
+
export const SHADER_CACHE_ENTRIES = 64
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* One owning cache per CanvasKit instance, so a reload gets fresh effects. Effects are native
|
|
34
|
+
* handles: the cache is their only owner, and disposing a slot is what frees one.
|
|
35
|
+
*/
|
|
36
|
+
const caches = new WeakMap<CanvasKit, ResourceCache<string, CompiledShader>>()
|
|
29
37
|
|
|
30
38
|
/** The frame values the renderer supplies instead of the document. */
|
|
31
39
|
export interface ShaderFrame {
|
|
@@ -109,7 +117,10 @@ export function shaderSamplers(compiled: CompiledShader): string[] {
|
|
|
109
117
|
export function compileShader(ck: CanvasKit, source: string): CompiledShader {
|
|
110
118
|
let cache = caches.get(ck)
|
|
111
119
|
if (!cache) {
|
|
112
|
-
cache = new
|
|
120
|
+
cache = new ResourceCache<string, CompiledShader>({
|
|
121
|
+
maxEntries: SHADER_CACHE_ENTRIES,
|
|
122
|
+
dispose: (compiled) => compiled.effect?.delete()
|
|
123
|
+
})
|
|
113
124
|
caches.set(ck, cache)
|
|
114
125
|
}
|
|
115
126
|
const cached = cache.get(source)
|
|
@@ -23,8 +23,12 @@ import { sdfShader } from './sdf'
|
|
|
23
23
|
/** When the page started drawing shaders, which is what `@time` counts from. */
|
|
24
24
|
const startedAt = Date.now()
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The source each paint last compiled from, by frame image, so a broken edit keeps drawing. A source
|
|
28
|
+
* is stored rather than the compiled object: the compile cache owns the handle, and a remembered
|
|
29
|
+
* object could be disposed by an eviction between the edit and the draw.
|
|
30
|
+
*/
|
|
31
|
+
const lastGood = new Map<string, string>()
|
|
28
32
|
|
|
29
33
|
/** How many paints keep a last good effect, so a long session does not hold every one forever. */
|
|
30
34
|
const KEEP_LAST_GOOD = 32
|
|
@@ -42,7 +46,7 @@ function effectFor(r: SkiaRenderer, shader: ShaderSourcePaint): CompiledShader |
|
|
|
42
46
|
const compiled = compileShader(r.ck, shader.source)
|
|
43
47
|
if (compiled.effect) {
|
|
44
48
|
lastGood.delete(shader.image)
|
|
45
|
-
lastGood.set(shader.image,
|
|
49
|
+
lastGood.set(shader.image, shader.source)
|
|
46
50
|
while (lastGood.size > KEEP_LAST_GOOD) {
|
|
47
51
|
const oldest = lastGood.keys().next().value
|
|
48
52
|
if (oldest === undefined) break
|
|
@@ -50,7 +54,10 @@ function effectFor(r: SkiaRenderer, shader: ShaderSourcePaint): CompiledShader |
|
|
|
50
54
|
}
|
|
51
55
|
return compiled
|
|
52
56
|
}
|
|
53
|
-
|
|
57
|
+
const goodSource = lastGood.get(shader.image)
|
|
58
|
+
if (goodSource === undefined) return null
|
|
59
|
+
const good = compileShader(r.ck, goodSource)
|
|
60
|
+
return good.effect ? good : null
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
@@ -11,6 +11,7 @@ import type { SceneGraph, SceneNode, ShaderEffect } from '@pairdraw/scene-graph'
|
|
|
11
11
|
|
|
12
12
|
import { setPaintBlendMode } from '#core/canvas/blend'
|
|
13
13
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
14
|
+
import { skColorSpace } from '#core/canvas/renderer/colors'
|
|
14
15
|
|
|
15
16
|
import { boundUniformValues } from './bindings'
|
|
16
17
|
import { compileShader, packShaderUniforms, type CompiledShader, type ShaderFrame } from './compile'
|
|
@@ -22,26 +23,14 @@ const MAX_SIDE = 4096
|
|
|
22
23
|
/** When the page started drawing shaders, which is what `@time` counts from. */
|
|
23
24
|
const startedAt = Date.now()
|
|
24
25
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/** The effect to draw `effect` with: its own compile, or the one it last compiled with. */
|
|
26
|
+
/**
|
|
27
|
+
* The effect to draw `effect` with. A failed compile has nothing to fall back to here: the last
|
|
28
|
+
* good compile of a source is that same source's entry, which `compileShader` memoizes, so its
|
|
29
|
+
* effect is already returned by a successful compile. The compile cache owns the handle.
|
|
30
|
+
*/
|
|
32
31
|
function effectFor(r: SkiaRenderer, effect: ShaderEffect): CompiledShader | null {
|
|
33
32
|
const compiled = compileShader(r.ck, effect.source)
|
|
34
|
-
|
|
35
|
-
lastGood.delete(effect.source)
|
|
36
|
-
lastGood.set(effect.source, compiled)
|
|
37
|
-
while (lastGood.size > KEEP_LAST_GOOD) {
|
|
38
|
-
const oldest = lastGood.keys().next().value
|
|
39
|
-
if (oldest === undefined) break
|
|
40
|
-
lastGood.delete(oldest)
|
|
41
|
-
}
|
|
42
|
-
return compiled
|
|
43
|
-
}
|
|
44
|
-
return lastGood.get(effect.source) ?? null
|
|
33
|
+
return compiled.effect ? compiled : null
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
/** The device pixels one layer coordinate spans, so the snapshot draws at the canvas's own rate. */
|
|
@@ -119,7 +108,7 @@ export function drawShaderEffectLayer(
|
|
|
119
108
|
height,
|
|
120
109
|
colorType: r.ck.ColorType.RGBA_8888,
|
|
121
110
|
alphaType: r.ck.AlphaType.Premul,
|
|
122
|
-
colorSpace: r.ck.
|
|
111
|
+
colorSpace: skColorSpace(r.ck, r.documentColorSpace)
|
|
123
112
|
})
|
|
124
113
|
const offscreen = surface.getCanvas()
|
|
125
114
|
offscreen.clear(r.ck.TRANSPARENT)
|
|
@@ -128,7 +128,8 @@ function drawMaskShadow(
|
|
|
128
128
|
blendMode: BlendMode | undefined,
|
|
129
129
|
draw: () => void
|
|
130
130
|
): void {
|
|
131
|
-
|
|
131
|
+
const color = r.renderColor(effect.color)
|
|
132
|
+
r.auxFill.setColor(r.color4f(color.r, color.g, color.b, color.a))
|
|
132
133
|
r.auxFill.setMaskFilter(r.getCachedMaskBlur(blurSigma(effect.radius)))
|
|
133
134
|
r.auxFill.setImageFilter(null)
|
|
134
135
|
setPaintBlendMode(r, r.auxFill, blendMode)
|
|
@@ -241,7 +242,8 @@ export function drawShapeInnerShadow(
|
|
|
241
242
|
isolated = false
|
|
242
243
|
): void {
|
|
243
244
|
const sp = spread
|
|
244
|
-
|
|
245
|
+
const color = r.renderColor(effect.color)
|
|
246
|
+
r.auxFill.setColor(r.ck.Color4f(color.r, color.g, color.b, color.a))
|
|
245
247
|
r.auxFill.setImageFilter(r.getCachedDecalBlur(blurSigma(effect.radius)))
|
|
246
248
|
|
|
247
249
|
canvas.save()
|
package/src/canvas/shadows.ts
CHANGED
|
@@ -106,7 +106,9 @@ function drawSilhouetteDropShadow(
|
|
|
106
106
|
draw: () => void
|
|
107
107
|
): void {
|
|
108
108
|
const ck = r.ck
|
|
109
|
-
|
|
109
|
+
// Stored in the document's profile, as every paint is; Skia converts it to its surface.
|
|
110
|
+
const drawn = r.renderColor(effect.color)
|
|
111
|
+
const color = ck.Color4f(drawn.r, drawn.g, drawn.b, drawn.a)
|
|
110
112
|
const sigma = blurSigma(effect.radius)
|
|
111
113
|
const morphology = spreadFilter(r, spread)
|
|
112
114
|
const filter = morphology
|
|
@@ -298,8 +300,9 @@ function drawSilhouetteInnerShadow(
|
|
|
298
300
|
draw()
|
|
299
301
|
|
|
300
302
|
r.effectLayerPaint.setBlendMode(ck.BlendMode.SrcIn)
|
|
303
|
+
const drawn = r.renderColor(effect.color)
|
|
301
304
|
tintFilter = ck.ColorFilter.MakeBlend(
|
|
302
|
-
ck.Color4f(
|
|
305
|
+
ck.Color4f(drawn.r, drawn.g, drawn.b, drawn.a),
|
|
303
306
|
ck.BlendMode.SrcIn
|
|
304
307
|
)
|
|
305
308
|
r.effectLayerPaint.setColorFilter(tintFilter)
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Canvas, CanvasKit, Paint } from 'canvaskit-wasm'
|
|
2
2
|
import { isEqual } from 'es-toolkit/predicate'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
ColorProfile,
|
|
6
|
+
DerivedTextGlyph,
|
|
7
|
+
Fill,
|
|
8
|
+
SceneNode,
|
|
9
|
+
TextDecorationStyle
|
|
10
|
+
} from '@pairdraw/scene-graph'
|
|
5
11
|
import { resolveRGBAForPreview } from '@pairdraw/scene-graph/color'
|
|
6
12
|
import { faceStyleKey } from '@pairdraw/scene-graph/font-style'
|
|
7
13
|
|
|
@@ -351,7 +357,8 @@ function drawKeycapFrames(
|
|
|
351
357
|
node: SceneNode,
|
|
352
358
|
layout: TextLayout,
|
|
353
359
|
y: number,
|
|
354
|
-
paint: Paint
|
|
360
|
+
paint: Paint,
|
|
361
|
+
space: ColorProfile
|
|
355
362
|
): void {
|
|
356
363
|
const text = shownText(node)
|
|
357
364
|
if (!text.includes(COMBINING_KEYCAP)) return
|
|
@@ -372,7 +379,9 @@ function drawKeycapFrames(
|
|
|
372
379
|
const run = node.styleRuns.find(
|
|
373
380
|
(item) => source >= item.start && source < item.start + item.length
|
|
374
381
|
)
|
|
375
|
-
runPaint.setColor(
|
|
382
|
+
runPaint.setColor(
|
|
383
|
+
run ? styleRunColor(ck, run.style, paint.getColor(), space) : paint.getColor()
|
|
384
|
+
)
|
|
376
385
|
drawKeycapFrame(ck, canvas, glyph.x, glyph.y, glyph.fontSize, runPaint)
|
|
377
386
|
}
|
|
378
387
|
} finally {
|
|
@@ -386,11 +395,12 @@ export function drawTextLayout(
|
|
|
386
395
|
node: SceneNode,
|
|
387
396
|
prepared: PreparedText,
|
|
388
397
|
y: number,
|
|
389
|
-
textPaint: Paint
|
|
398
|
+
textPaint: Paint,
|
|
399
|
+
space: ColorProfile = 'srgb'
|
|
390
400
|
): void {
|
|
391
401
|
const layout = prepared.paragraph
|
|
392
402
|
layout.draw(canvas, 0, y)
|
|
393
|
-
drawKeycapFrames(ck, canvas, node, layout, y, textPaint)
|
|
403
|
+
drawKeycapFrames(ck, canvas, node, layout, y, textPaint, space)
|
|
394
404
|
if (!hasDecoration(node)) return
|
|
395
405
|
if (prepared.decorations?.y !== y) {
|
|
396
406
|
const glyphs = laidOutGlyphs(node, layout, shownText(node), y)
|
package/src/canvas/text/index.ts
CHANGED
|
@@ -228,7 +228,15 @@ export function buildTextPicture(r: TextRenderer, node: SceneNode): Uint8Array |
|
|
|
228
228
|
const layout = buildParagraph(r, node)
|
|
229
229
|
const paint = new ck.Paint()
|
|
230
230
|
try {
|
|
231
|
-
drawTextLayout(
|
|
231
|
+
drawTextLayout(
|
|
232
|
+
ck,
|
|
233
|
+
recCanvas,
|
|
234
|
+
node,
|
|
235
|
+
{ paragraph: layout },
|
|
236
|
+
0,
|
|
237
|
+
paint,
|
|
238
|
+
r.documentColorSpace ?? 'srgb'
|
|
239
|
+
)
|
|
232
240
|
} finally {
|
|
233
241
|
paint.delete()
|
|
234
242
|
layout.delete()
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
TextHeightBehavior
|
|
10
10
|
} from 'canvaskit-wasm'
|
|
11
11
|
|
|
12
|
-
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
13
|
-
import {
|
|
12
|
+
import type { ColorProfile, SceneNode } from '@pairdraw/scene-graph'
|
|
13
|
+
import { normalizeColor, toExtendedSRGB } from '@pairdraw/scene-graph/color'
|
|
14
14
|
import { faceStyleKey, type NamedFace } from '@pairdraw/scene-graph/font-style'
|
|
15
15
|
import { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'
|
|
16
16
|
import { lineHeightPixels, textLengthPixels } from '@pairdraw/scene-graph/text'
|
|
@@ -152,14 +152,24 @@ function drawnFontStyle(
|
|
|
152
152
|
export function styleRunColor(
|
|
153
153
|
ck: CanvasKit,
|
|
154
154
|
style: SceneNode['styleRuns'][number]['style'],
|
|
155
|
-
baseColor: Float32Array
|
|
155
|
+
baseColor: Float32Array,
|
|
156
|
+
space: ColorProfile
|
|
156
157
|
): Float32Array {
|
|
157
158
|
const visibleFill = style.fills?.find((fill) => fill.visible && fill.type === 'SOLID')
|
|
158
159
|
if (!visibleFill) return baseColor
|
|
159
|
-
const color =
|
|
160
|
+
const color = toExtendedSRGB(normalizeColor(visibleFill.color), space)
|
|
160
161
|
return ck.Color4f(color.r, color.g, color.b, color.a * visibleFill.opacity)
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
/**
|
|
165
|
+
* A text style's color. CanvasKit keeps `color` in 8-bit sRGB, which clips a wide-gamut color, and
|
|
166
|
+
* draws `foregroundColor` with float components, so both carry it; a pushed foreground paint, as a
|
|
167
|
+
* gradient fill draws with, still takes their place.
|
|
168
|
+
*/
|
|
169
|
+
function textColor(color: Float32Array) {
|
|
170
|
+
return { color, foregroundColor: color }
|
|
171
|
+
}
|
|
172
|
+
|
|
163
173
|
function styleRunLanguage(
|
|
164
174
|
style: SceneNode['styleRuns'][number]['style'],
|
|
165
175
|
node: Pick<ParagraphNode, 'textLanguage'>
|
|
@@ -197,7 +207,7 @@ function pushStyleRun(
|
|
|
197
207
|
const runKey = faceStyleKey(runFace)
|
|
198
208
|
|
|
199
209
|
const textStyle = new ck.TextStyle({
|
|
200
|
-
|
|
210
|
+
...textColor(styleRunColor(ck, style, baseColor, r.documentColorSpace ?? 'srgb')),
|
|
201
211
|
fontFamilies: fontFamilies(runFamily, runFace),
|
|
202
212
|
fontSize: runFontSize,
|
|
203
213
|
locale: styleRunLanguage(style, node),
|
|
@@ -310,7 +320,7 @@ export function buildSkParagraph(
|
|
|
310
320
|
const nodeKey = faceStyleKey(node)
|
|
311
321
|
|
|
312
322
|
const baseTextStyle = {
|
|
313
|
-
|
|
323
|
+
...textColor(baseColor),
|
|
314
324
|
fontFamilies: fontFamilies(node.fontFamily || DEFAULT_FONT_FAMILY, node),
|
|
315
325
|
fontSize: baseFontSize,
|
|
316
326
|
locale: node.textLanguage ?? undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'
|
|
2
2
|
|
|
3
|
-
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
3
|
+
import type { ColorProfile, SceneNode } from '@pairdraw/scene-graph'
|
|
4
4
|
|
|
5
5
|
import type { FontResolutionSettled } from '#core/text/resolver'
|
|
6
6
|
|
|
@@ -19,6 +19,7 @@ export interface FontReadinessRenderer {
|
|
|
19
19
|
|
|
20
20
|
export interface TextRenderer extends FontReadinessRenderer {
|
|
21
21
|
ck: CanvasKit
|
|
22
|
+
documentColorSpace?: ColorProfile
|
|
22
23
|
fontProvider: TypefaceFontProvider | null
|
|
23
24
|
fontsLoaded: boolean
|
|
24
25
|
}
|
package/src/canvas/text/shape.ts
CHANGED
|
@@ -20,8 +20,8 @@ import { getCanvasKit } from '#core/canvaskit'
|
|
|
20
20
|
import { shownText } from '#core/text/case'
|
|
21
21
|
import { EMOJI_METRICS_FAMILY } from '#core/text/emoji'
|
|
22
22
|
import type { OutlineCommand } from '#core/text/font/glyphs'
|
|
23
|
-
import { fontManager } from '#core/text/font/manager'
|
|
24
23
|
import { faceStyleName } from '#core/text/font/names'
|
|
24
|
+
import { leaseFontProvider } from '#core/text/font/provider'
|
|
25
25
|
import { nextGraphemeBoundary } from '#core/text/graphemes'
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -205,11 +205,11 @@ export async function withTextShaper<T>(
|
|
|
205
205
|
canvasKit: CanvasKit,
|
|
206
206
|
use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>
|
|
207
207
|
): Promise<T> {
|
|
208
|
-
const
|
|
208
|
+
const lease = leaseFontProvider(canvasKit)
|
|
209
209
|
try {
|
|
210
|
-
return await use((node) => shapeText(canvasKit, provider, node))
|
|
210
|
+
return await use((node) => shapeText(canvasKit, lease.provider, node))
|
|
211
211
|
} finally {
|
|
212
|
-
|
|
212
|
+
lease.release()
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
package/src/canvas/texture.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SceneNode, TextureEffect } from '@pairdraw/scene-graph'
|
|
|
4
4
|
|
|
5
5
|
import { cellValue } from './noise/tile'
|
|
6
6
|
import type { SkiaRenderer } from './renderer'
|
|
7
|
+
import { skColorSpace } from './renderer/colors'
|
|
7
8
|
|
|
8
9
|
/** Cells on each side of a texture's displacement tile; it repeats beyond them. */
|
|
9
10
|
const TEXTURE_TILE_CELLS = 256
|
|
@@ -67,7 +68,7 @@ export function textureDisplacementTile(
|
|
|
67
68
|
height: TEXTURE_TILE_CELLS,
|
|
68
69
|
alphaType: r.ck.AlphaType.Unpremul,
|
|
69
70
|
colorType: r.ck.ColorType.RGBA_8888,
|
|
70
|
-
colorSpace: r.ck.
|
|
71
|
+
colorSpace: skColorSpace(r.ck, r.documentColorSpace)
|
|
71
72
|
},
|
|
72
73
|
pixels,
|
|
73
74
|
TEXTURE_TILE_CELLS * 4
|
|
@@ -74,7 +74,9 @@ export function createClipboardAssetActions(
|
|
|
74
74
|
|
|
75
75
|
async function prepareAsset(file: File): Promise<PreparedAsset | null> {
|
|
76
76
|
if (isSVGFile(file)) {
|
|
77
|
-
const data = prepareSVGImport(await file.text()
|
|
77
|
+
const data = prepareSVGImport(await file.text(), {
|
|
78
|
+
profile: ctx.graph.documentColorSpace
|
|
79
|
+
})
|
|
78
80
|
return data
|
|
79
81
|
? {
|
|
80
82
|
kind: 'svg',
|
|
@@ -181,7 +183,9 @@ export function createClipboardAssetActions(
|
|
|
181
183
|
|
|
182
184
|
/** Paste SVG markup as layers, as Figma does; false when the text is not SVG. */
|
|
183
185
|
async function pasteSVG(markup: string, cx: number, cy: number): Promise<boolean> {
|
|
184
|
-
const data = isSVGMarkup(markup)
|
|
186
|
+
const data = isSVGMarkup(markup)
|
|
187
|
+
? prepareSVGImport(markup, { profile: ctx.graph.documentColorSpace })
|
|
188
|
+
: null
|
|
185
189
|
if (!data) return false
|
|
186
190
|
const asset: PreparedAsset = { kind: 'svg', data, width: data.width, height: data.height }
|
|
187
191
|
await loadSVGFonts([asset])
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import { PAIRDRAW_PLUGIN_DATA, readPluginData } from '@pairdraw/scene-graph/plugin-data'
|
|
3
|
+
|
|
4
|
+
import { collectSubtrees } from '#core/editor/history/subtree'
|
|
5
|
+
|
|
6
|
+
import type { ClipboardNodeTree } from './snapshot'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The component or set already in this document that a snapshot's dependency becomes, when the
|
|
10
|
+
* dependency came from here before. A node a paste created carries its clipboard origin, and a
|
|
11
|
+
* component read from a `.fig` carries the source identity Figma stores; names are never compared,
|
|
12
|
+
* so an unrelated same-named component is never reused.
|
|
13
|
+
*/
|
|
14
|
+
export function matchClipboardComponents(
|
|
15
|
+
graph: SceneGraph,
|
|
16
|
+
sourceRootId: string,
|
|
17
|
+
dependencies: ClipboardNodeTree[]
|
|
18
|
+
): Map<string, string> {
|
|
19
|
+
const roots = [...graph.getAllNodes()].filter(
|
|
20
|
+
(node) => node.type === 'COMPONENT' || node.type === 'COMPONENT_SET'
|
|
21
|
+
)
|
|
22
|
+
const byOrigin = new Map<string, string>()
|
|
23
|
+
const bySource = new Map<string, string>()
|
|
24
|
+
const byKey = new Map<string, string>()
|
|
25
|
+
for (const root of roots) {
|
|
26
|
+
const origin = readPluginData(root.pluginData, PAIRDRAW_PLUGIN_DATA.clipboardOrigin)
|
|
27
|
+
if (origin?.documentId === sourceRootId) byOrigin.set(origin.nodeId, root.id)
|
|
28
|
+
if (root.source.id) bySource.set(root.source.id, root.id)
|
|
29
|
+
for (const key of [root.sourceLibraryKey, root.componentKey])
|
|
30
|
+
if (key && !byKey.has(key)) byKey.set(key, root.id)
|
|
31
|
+
}
|
|
32
|
+
const matches = new Map<string, string>()
|
|
33
|
+
const matchedRoots = new Set<string>()
|
|
34
|
+
|
|
35
|
+
const mapExistingChildren = (dependency: ClipboardNodeTree, existingRootId: string) => {
|
|
36
|
+
const byChildOrigin = new Map<string, string>()
|
|
37
|
+
const byChildSource = new Map<string, string>()
|
|
38
|
+
for (const node of collectSubtrees(graph, [existingRootId])) {
|
|
39
|
+
const origin = readPluginData(node.pluginData, PAIRDRAW_PLUGIN_DATA.clipboardOrigin)
|
|
40
|
+
if (origin?.documentId === sourceRootId) byChildOrigin.set(origin.nodeId, node.id)
|
|
41
|
+
if (node.source.id) byChildSource.set(node.source.id, node.id)
|
|
42
|
+
}
|
|
43
|
+
const visit = (node: ClipboardNodeTree) => {
|
|
44
|
+
const existing =
|
|
45
|
+
byChildOrigin.get(node.id) ??
|
|
46
|
+
(node.source.id ? byChildSource.get(node.source.id) : undefined)
|
|
47
|
+
if (existing) matches.set(node.id, existing)
|
|
48
|
+
for (const child of node.children ?? []) visit(child)
|
|
49
|
+
}
|
|
50
|
+
for (const child of dependency.children ?? []) visit(child)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const dependency of dependencies) {
|
|
54
|
+
const existing =
|
|
55
|
+
byOrigin.get(dependency.id) ??
|
|
56
|
+
(dependency.sourceLibraryKey ? byKey.get(dependency.sourceLibraryKey) : undefined) ??
|
|
57
|
+
(dependency.componentKey ? byKey.get(dependency.componentKey) : undefined) ??
|
|
58
|
+
(dependency.source.id ? bySource.get(dependency.source.id) : undefined)
|
|
59
|
+
if (!existing || matchedRoots.has(existing)) continue
|
|
60
|
+
matchedRoots.add(existing)
|
|
61
|
+
matches.set(dependency.id, existing)
|
|
62
|
+
mapExistingChildren(dependency, existing)
|
|
63
|
+
}
|
|
64
|
+
return matches
|
|
65
|
+
}
|
|
@@ -3,6 +3,7 @@ import { numberedName } from '@pairdraw/scene-graph/naming'
|
|
|
3
3
|
|
|
4
4
|
import type { EditorContext } from '#core/editor/types'
|
|
5
5
|
|
|
6
|
+
import { matchClipboardComponents } from './component-matches'
|
|
6
7
|
import {
|
|
7
8
|
addsRenamed,
|
|
8
9
|
matchClipboardCollections,
|
|
@@ -18,6 +19,13 @@ import { importClipboardVariables, remapClipboardVariableBindings } from './vari
|
|
|
18
19
|
export interface ClipboardDependencyImport {
|
|
19
20
|
nodes: ClipboardSnapshot['nodes']
|
|
20
21
|
componentDependencies: ClipboardSnapshot['componentDependencies']
|
|
22
|
+
/**
|
|
23
|
+
* By a dependency's id here, the component or set already in this document it becomes, when the
|
|
24
|
+
* same snapshot was pasted before. A reuse keeps the local main, as in Figma.
|
|
25
|
+
*/
|
|
26
|
+
componentMatches: Map<string, string>
|
|
27
|
+
/** The copying document's root id, for a foreign paste that creates dependencies here. */
|
|
28
|
+
clipboardOrigin?: string
|
|
21
29
|
styleSnapshots: SceneNode[]
|
|
22
30
|
/**
|
|
23
31
|
* Whether the layers bind variables of this document now, whose values may differ from the
|
|
@@ -77,6 +85,7 @@ export function importClipboardDependencies(
|
|
|
77
85
|
return {
|
|
78
86
|
nodes,
|
|
79
87
|
componentDependencies: componentDependencies.filter((node) => !ctx.graph.getNode(node.id)),
|
|
88
|
+
componentMatches: new Map(),
|
|
80
89
|
styleSnapshots: [],
|
|
81
90
|
resolveBindings: false
|
|
82
91
|
}
|
|
@@ -87,7 +96,13 @@ export function importClipboardDependencies(
|
|
|
87
96
|
for (const child of node.children ?? []) detach(child)
|
|
88
97
|
}
|
|
89
98
|
for (const node of [...nodes, ...componentDependencies]) detach(node)
|
|
90
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
nodes,
|
|
101
|
+
componentDependencies,
|
|
102
|
+
componentMatches: new Map(),
|
|
103
|
+
styleSnapshots: [],
|
|
104
|
+
resolveBindings: false
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
const styleIds = new Map<string, string>()
|
|
93
108
|
/** This document's styles the layers use in place of copied ones, by id. */
|
|
@@ -154,6 +169,12 @@ export function importClipboardDependencies(
|
|
|
154
169
|
return {
|
|
155
170
|
nodes,
|
|
156
171
|
componentDependencies,
|
|
172
|
+
componentMatches: matchClipboardComponents(
|
|
173
|
+
ctx.graph,
|
|
174
|
+
snapshot.sourceRootId,
|
|
175
|
+
componentDependencies
|
|
176
|
+
),
|
|
177
|
+
clipboardOrigin: snapshot.sourceRootId,
|
|
157
178
|
styleSnapshots,
|
|
158
179
|
resolveBindings: snapshot.variableDependencies.variables.length > 0,
|
|
159
180
|
applyVariables: variables.apply,
|
|
@@ -41,14 +41,14 @@ export function createClipboardExportActions(ctx: EditorContext) {
|
|
|
41
41
|
async function copySelectionAsHTML(ids: string[]): Promise<string | null> {
|
|
42
42
|
if (ids.length === 0) return null
|
|
43
43
|
const { renderNodesToHTML } = await import('#core/io/formats/html')
|
|
44
|
-
const { html } = await renderNodesToHTML(
|
|
44
|
+
const { html, draws } = await renderNodesToHTML(
|
|
45
45
|
ctx.graph,
|
|
46
46
|
ids,
|
|
47
47
|
{ html: 'fragment', style: 'inline', assets: 'inline' },
|
|
48
48
|
undefined,
|
|
49
49
|
{ canvasKit: ctx.getCk() ?? undefined, renderer: ctx.getRenderer() ?? undefined }
|
|
50
50
|
)
|
|
51
|
-
return html || null
|
|
51
|
+
return draws ? html || null : null
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return { copySelectionAsText, copySelectionAsSVG, copySelectionAsJSX, copySelectionAsHTML }
|