@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,7 +1,13 @@
|
|
|
1
1
|
import { isEqual, isPlainObject } from 'es-toolkit/predicate'
|
|
2
2
|
import * as v from 'valibot'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
DocumentColorSpace,
|
|
6
|
+
Effect,
|
|
7
|
+
SceneGraph,
|
|
8
|
+
SceneNode,
|
|
9
|
+
TextLength
|
|
10
|
+
} from '@pairdraw/scene-graph'
|
|
5
11
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
6
12
|
import { getSharedStyles } from '@pairdraw/scene-graph/shared-styles'
|
|
7
13
|
import { percentLength, pixelLength, textLengthSchema } from '@pairdraw/scene-graph/text'
|
|
@@ -178,15 +184,24 @@ function recordedTarget(
|
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
/** One shadow of a shadow token, or the shadows a referenced shadow token holds. */
|
|
181
|
-
function shadowEffects(
|
|
187
|
+
function shadowEffects(
|
|
188
|
+
raw: unknown,
|
|
189
|
+
resolve: Resolve,
|
|
190
|
+
profile: DocumentColorSpace,
|
|
191
|
+
depth = 0
|
|
192
|
+
): Effect[] | null {
|
|
182
193
|
const path = referencePath(raw)
|
|
183
194
|
if (path) {
|
|
184
195
|
const resolved = depth < 16 ? resolve(path) : undefined
|
|
185
|
-
return resolved?.kind === 'token'
|
|
196
|
+
return resolved?.kind === 'token'
|
|
197
|
+
? shadowList(resolved.token.value, resolve, profile, depth + 1)
|
|
198
|
+
: null
|
|
186
199
|
}
|
|
187
200
|
if (!isPlainObject(raw)) return null
|
|
188
201
|
const color = fieldValue<Color>(raw.color, resolve, (value) =>
|
|
189
|
-
isPlainObject(value) && typeof value.r === 'number'
|
|
202
|
+
isPlainObject(value) && typeof value.r === 'number'
|
|
203
|
+
? (value as Color)
|
|
204
|
+
: decodeColor(value, profile)
|
|
190
205
|
)
|
|
191
206
|
const length = (key: string) => fieldValue(raw[key], resolve, pixels) ?? 0
|
|
192
207
|
if (!color) return null
|
|
@@ -203,11 +218,16 @@ function shadowEffects(raw: unknown, resolve: Resolve, depth = 0): Effect[] | nu
|
|
|
203
218
|
]
|
|
204
219
|
}
|
|
205
220
|
|
|
206
|
-
function shadowList(
|
|
221
|
+
function shadowList(
|
|
222
|
+
value: unknown,
|
|
223
|
+
resolve: Resolve,
|
|
224
|
+
profile: DocumentColorSpace,
|
|
225
|
+
depth = 0
|
|
226
|
+
): Effect[] | null {
|
|
207
227
|
const entries = Array.isArray(value) ? value : [value]
|
|
208
228
|
const effects: Effect[] = []
|
|
209
229
|
for (const entry of entries) {
|
|
210
|
-
const shadows = shadowEffects(entry, resolve, depth)
|
|
230
|
+
const shadows = shadowEffects(entry, resolve, profile, depth)
|
|
211
231
|
if (!shadows) return null
|
|
212
232
|
effects.push(...shadows)
|
|
213
233
|
}
|
|
@@ -229,12 +249,16 @@ function replaceShadows(exact: readonly Effect[], shadows: readonly Effect[]): E
|
|
|
229
249
|
}
|
|
230
250
|
|
|
231
251
|
/** A shadow token as effects, preferring the exact effects Pairdraw wrote. */
|
|
232
|
-
function effectFields(
|
|
252
|
+
function effectFields(
|
|
253
|
+
token: ReadToken,
|
|
254
|
+
resolve: Resolve,
|
|
255
|
+
profile: DocumentColorSpace
|
|
256
|
+
): Partial<SceneNode> | null {
|
|
233
257
|
const own = v.safeParse(ownEffectsSchema, token.extensions[PAIRDRAW_EXTENSION])
|
|
234
258
|
// Extension effects that do not read fall back to the token's own shadows.
|
|
235
259
|
const exact = own.success ? tryParseFigmaEffects(own.output.effects) : null
|
|
236
|
-
if (exact && isEqual(token.value, shadowTokenValue(exact))) return { effects: exact }
|
|
237
|
-
const shadows = shadowList(token.value, resolve)
|
|
260
|
+
if (exact && isEqual(token.value, shadowTokenValue(exact, profile))) return { effects: exact }
|
|
261
|
+
const shadows = shadowList(token.value, resolve, profile)
|
|
238
262
|
if (!shadows) return null
|
|
239
263
|
return { effects: exact ? replaceShadows(exact, shadows) : shadows }
|
|
240
264
|
}
|
|
@@ -256,7 +280,10 @@ export function planStyles(
|
|
|
256
280
|
skipped.push({ name: token.name, collection: undefined, reason: 'unsupported-type' })
|
|
257
281
|
continue
|
|
258
282
|
}
|
|
259
|
-
const fields =
|
|
283
|
+
const fields =
|
|
284
|
+
kind === 'TEXT'
|
|
285
|
+
? textFields(token, resolve)
|
|
286
|
+
: effectFields(token, resolve, graph.documentColorSpace)
|
|
260
287
|
if (!fields) {
|
|
261
288
|
skipped.push({ name: token.name, collection: undefined, reason: 'invalid-value' })
|
|
262
289
|
continue
|
|
@@ -2,6 +2,7 @@ import { countBy } from 'es-toolkit/array'
|
|
|
2
2
|
import { isEmptyObject, isPlainObject } from 'es-toolkit/predicate'
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
|
+
ColorProfile,
|
|
5
6
|
Effect,
|
|
6
7
|
SceneGraph,
|
|
7
8
|
SceneNode,
|
|
@@ -129,9 +130,9 @@ export function isShadow(effect: Effect): effect is ShadowEffect {
|
|
|
129
130
|
return effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW'
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
function shadowValue(effect: ShadowEffect) {
|
|
133
|
+
function shadowValue(effect: ShadowEffect, profile: ColorProfile) {
|
|
133
134
|
return {
|
|
134
|
-
color: colorTokenValue(effect.color),
|
|
135
|
+
color: colorTokenValue(effect.color, profile),
|
|
135
136
|
offsetX: dimensionTokenValue(effect.offset.x),
|
|
136
137
|
offsetY: dimensionTokenValue(effect.offset.y),
|
|
137
138
|
blur: dimensionTokenValue(effect.radius),
|
|
@@ -141,10 +142,10 @@ function shadowValue(effect: ShadowEffect) {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
/** A shadow token's `$value`: the visible shadows of `effects`, or undefined when there are none. */
|
|
144
|
-
export function shadowTokenValue(effects: readonly Effect[]) {
|
|
145
|
+
export function shadowTokenValue(effects: readonly Effect[], profile: ColorProfile = 'srgb') {
|
|
145
146
|
const values = effects
|
|
146
147
|
.filter((effect): effect is ShadowEffect => isShadow(effect) && effect.visible)
|
|
147
|
-
.map(shadowValue)
|
|
148
|
+
.map((effect) => shadowValue(effect, profile))
|
|
148
149
|
if (values.length === 0) return undefined
|
|
149
150
|
return values.length === 1 ? values[0] : values
|
|
150
151
|
}
|
|
@@ -154,8 +155,8 @@ export function shadowTokenValue(effects: readonly Effect[]) {
|
|
|
154
155
|
* blurs or hidden shadows, ride along whole in Pairdraw's extension, in the plugin API's shape;
|
|
155
156
|
* a style with no visible shadow has no token.
|
|
156
157
|
*/
|
|
157
|
-
function shadowToken(node: SceneNode): DesignToken | undefined {
|
|
158
|
-
const $value = shadowTokenValue(node.effects)
|
|
158
|
+
function shadowToken(node: SceneNode, profile: ColorProfile): DesignToken | undefined {
|
|
159
|
+
const $value = shadowTokenValue(node.effects, profile)
|
|
159
160
|
if ($value === undefined) return undefined
|
|
160
161
|
const exact = node.effects.every(
|
|
161
162
|
(effect) =>
|
|
@@ -207,7 +208,9 @@ export function styleTokens(
|
|
|
207
208
|
)
|
|
208
209
|
const candidates = styles.flatMap((node) => {
|
|
209
210
|
const token =
|
|
210
|
-
node.sharedStyleType === 'TEXT'
|
|
211
|
+
node.sharedStyleType === 'TEXT'
|
|
212
|
+
? typographyToken(graph, node, references)
|
|
213
|
+
: shadowToken(node, graph.documentColorSpace)
|
|
211
214
|
if (!token) {
|
|
212
215
|
issues.push({ kind: 'unsupported-effect', style: node.name })
|
|
213
216
|
return []
|
|
@@ -579,9 +579,11 @@ export function tokenSnapshot(
|
|
|
579
579
|
/** Every collection's modes by id and name, to find them again when a format reassigns ids. */
|
|
580
580
|
function modeNames(graph: SceneGraph): Record<string, Record<string, string>> {
|
|
581
581
|
return Object.fromEntries(
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
582
|
+
graph
|
|
583
|
+
.getLiveCollections()
|
|
584
|
+
.map((collection) => [
|
|
585
|
+
collection.name,
|
|
586
|
+
Object.fromEntries(collection.modes.map((mode) => [mode.modeId, mode.name]))
|
|
587
|
+
])
|
|
586
588
|
)
|
|
587
589
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { variableUnit } from '@pairdraw/dom-css/export'
|
|
2
|
-
import type { TokenUnit, Variable } from '@pairdraw/scene-graph'
|
|
3
|
-
import { colorToHex } from '@pairdraw/scene-graph/color'
|
|
2
|
+
import type { ColorProfile, TokenUnit, Variable } from '@pairdraw/scene-graph'
|
|
3
|
+
import { colorToHex, convertColor } from '@pairdraw/scene-graph/color'
|
|
4
4
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
5
5
|
|
|
6
6
|
import type { DesignTokenType } from './types'
|
|
@@ -31,13 +31,19 @@ export function variableTokenType(variable: Variable): DesignTokenType {
|
|
|
31
31
|
return 'number'
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A color as DTCG 2025.10 writes it: components in the document's profile, alpha, and the hex
|
|
36
|
+
* code tools display. The hex is the sRGB code of those components clamped to sRGB, which is the
|
|
37
|
+
* stored color in an sRGB document and an approximation in Display P3, where components can
|
|
38
|
+
* pass 1.
|
|
39
|
+
*/
|
|
40
|
+
export function colorTokenValue(color: Color, profile: ColorProfile = 'srgb') {
|
|
41
|
+
const shown = profile === 'srgb' ? color : convertColor(color, profile, 'srgb')
|
|
36
42
|
return {
|
|
37
|
-
colorSpace:
|
|
43
|
+
colorSpace: profile,
|
|
38
44
|
components: [trimNumber(color.r), trimNumber(color.g), trimNumber(color.b)],
|
|
39
45
|
alpha: trimNumber(color.a),
|
|
40
|
-
hex: colorToHex(
|
|
46
|
+
hex: colorToHex(shown).toLowerCase()
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -54,9 +60,10 @@ function durationTokenValue(value: number, unit: TokenUnit) {
|
|
|
54
60
|
/** A variable's own value in the shape its token type takes. */
|
|
55
61
|
export function literalTokenValue(
|
|
56
62
|
variable: Variable,
|
|
57
|
-
value: Color | number | string | boolean
|
|
63
|
+
value: Color | number | string | boolean,
|
|
64
|
+
profile: ColorProfile = 'srgb'
|
|
58
65
|
): unknown {
|
|
59
|
-
if (typeof value === 'object') return colorTokenValue(value)
|
|
66
|
+
if (typeof value === 'object') return colorTokenValue(value, profile)
|
|
60
67
|
if (typeof value === 'boolean') return value ? 1 : 0
|
|
61
68
|
if (typeof value === 'string') return value
|
|
62
69
|
const type = variableTokenType(variable)
|
|
@@ -11,9 +11,9 @@ function counted(count: number, one: string, many: string): string {
|
|
|
11
11
|
* unbound. The writer names that loss instead of writing a file that looks complete.
|
|
12
12
|
*/
|
|
13
13
|
export function drawioDroppedWarnings(graph: SceneGraph): string[] {
|
|
14
|
-
const variables = graph.
|
|
14
|
+
const variables = graph.getLiveVariables().length
|
|
15
15
|
if (variables === 0) return []
|
|
16
|
-
const names =
|
|
16
|
+
const names = graph.getLiveCollections().map((collection) => collection.name)
|
|
17
17
|
const dropped = `draw.io has no variables: ${counted(variables, 'variable', 'variables')} in ${counted(names.length, 'collection', 'collections')} (${names.join(', ')}) not written`
|
|
18
18
|
const bound = [...graph.nodes.values()].filter(
|
|
19
19
|
(node) => Object.keys(node.boundVariables).length > 0
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
appendFigRecordBytes,
|
|
3
|
+
compressFigDataSync,
|
|
4
|
+
figRecordBytes,
|
|
5
|
+
readFigArchiveParts,
|
|
6
|
+
renameFigArchive
|
|
7
|
+
} from '@pairdraw/fig'
|
|
2
8
|
import {
|
|
3
9
|
nameImagesForFigma,
|
|
4
10
|
placeSlotContent,
|
|
@@ -8,6 +14,7 @@ import {
|
|
|
8
14
|
import { initCodec } from '@pairdraw/kiwi/fig/codec'
|
|
9
15
|
import type { NodeChange } from '@pairdraw/kiwi/fig/codec'
|
|
10
16
|
import { loadFigDataCompressor, type FigFileKind } from '@pairdraw/kiwi/fig/container'
|
|
17
|
+
import { guidToString } from '@pairdraw/kiwi/fig/guid'
|
|
11
18
|
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
12
19
|
import { fractionalPosition } from '@pairdraw/scene-graph/order-keys'
|
|
13
20
|
import type { GUID } from '@pairdraw/scene-graph/primitives'
|
|
@@ -16,6 +23,7 @@ import { withFigExportRuntime } from '#core/canvas/text/shape'
|
|
|
16
23
|
import { IS_BROWSER, IS_TAURI } from '#core/constants'
|
|
17
24
|
import { figCompressionLevel } from '#core/io/formats/fig/compression'
|
|
18
25
|
import { cloneSceneGraphForFigExport } from '#core/kiwi/fig/parse/transfer'
|
|
26
|
+
import { figArchive } from '#core/kiwi/fig/session/archive/access'
|
|
19
27
|
import {
|
|
20
28
|
hasPendingReaderPages,
|
|
21
29
|
populateFigInternalPages,
|
|
@@ -139,7 +147,12 @@ async function writeFigFile(
|
|
|
139
147
|
graph = cloneSceneGraphForFigExport(sourceGraph)
|
|
140
148
|
populateReaderExport(sourceGraph, graph)
|
|
141
149
|
}
|
|
142
|
-
|
|
150
|
+
// The archive's records the document never read go back as the file saved them; a source
|
|
151
|
+
// without an archive was never saved, so it has none.
|
|
152
|
+
const archived = await figArchive(sourceGraph)?.info()
|
|
153
|
+
const setup = await prepareFigExport(graph, runtime, {
|
|
154
|
+
unreadVariables: archived?.unreadVariables
|
|
155
|
+
})
|
|
143
156
|
const { compiled, schemaDeflated } = exportSchema(graph)
|
|
144
157
|
const { canvasEntries, internalCanvasGuid, localIdCounter, blobs } = setup
|
|
145
158
|
const nodeChanges: KiwiNodeChange[] = [setup.documentNc]
|
|
@@ -190,7 +203,27 @@ async function writeFigFile(
|
|
|
190
203
|
}
|
|
191
204
|
|
|
192
205
|
const imageNames = nameImagesForFigma(nodeChanges, graph.images)
|
|
193
|
-
|
|
206
|
+
let kiwiData = compiled.encodeMessage(msg)
|
|
207
|
+
// A record of a type the pinned schema does not model cannot be encoded again, so its bytes
|
|
208
|
+
// come from the archive as the file saved them.
|
|
209
|
+
const unread = archived?.unreadVariables ?? []
|
|
210
|
+
if (unread.length > 0) {
|
|
211
|
+
const original = await figArchive(sourceGraph)?.original()
|
|
212
|
+
if (original) {
|
|
213
|
+
const parts = readFigArchiveParts(
|
|
214
|
+
original.buffer.slice(
|
|
215
|
+
original.byteOffset,
|
|
216
|
+
original.byteOffset + original.byteLength
|
|
217
|
+
) as ArrayBuffer
|
|
218
|
+
)
|
|
219
|
+
const ids = unread.flatMap(({ record }) => (record.guid ? [guidToString(record.guid)] : []))
|
|
220
|
+
kiwiData = appendFigRecordBytes(
|
|
221
|
+
parts.schemaDeflated,
|
|
222
|
+
kiwiData,
|
|
223
|
+
figRecordBytes(parts.schemaDeflated, parts.dataRaw, ids)
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
194
227
|
const extras = await figFileExtras(graph, imageNames, options)
|
|
195
228
|
|
|
196
229
|
const version = graph.figKiwiVersion ?? undefined
|
|
@@ -333,6 +333,7 @@ function baselineWriter(info: FigArchiveRecordInfo): RecordWriter {
|
|
|
333
333
|
const written = writeRecords(setup, plan)
|
|
334
334
|
if (!written) return null
|
|
335
335
|
const internalPage = graph.getPages(true).find((page) => page.internalOnly)
|
|
336
|
+
// The baseline holds the document's own records; an unread one is not in the graph.
|
|
336
337
|
return [documentRecord(setup, info), ...written, ...variableRecords(setup, !!internalPage)]
|
|
337
338
|
}
|
|
338
339
|
}
|
|
@@ -352,7 +353,8 @@ async function buildPatch(
|
|
|
352
353
|
blobs: Array.from({ length: info.blobCount }, () => new Uint8Array(0)),
|
|
353
354
|
recordOwners: archived.byGuid,
|
|
354
355
|
archiveRecordIds: info.recordIds,
|
|
355
|
-
archiveResourceIds: changes.resourceIds
|
|
356
|
+
archiveResourceIds: changes.resourceIds,
|
|
357
|
+
unreadVariables: info.unreadVariables
|
|
356
358
|
})
|
|
357
359
|
const records = writeRecords(setup, plan)
|
|
358
360
|
if (!records) return null
|
|
@@ -363,6 +365,7 @@ async function buildPatch(
|
|
|
363
365
|
const internalPage = graph.getPages(true).find((page) => page.internalOnly)
|
|
364
366
|
const internal = setup.canvasEntries.find((entry) => entry.page.internalOnly)
|
|
365
367
|
const canvasWritten = records.some((record) => record === internal?.canvasNc)
|
|
368
|
+
// Unread records stay in the archive's bytes, so the patch never encodes them.
|
|
366
369
|
for (const record of variableRecords(setup, !!internalPage || canvasWritten))
|
|
367
370
|
records.push(record)
|
|
368
371
|
}
|
|
@@ -2,7 +2,12 @@ import type { CanvasKit } from 'canvaskit-wasm'
|
|
|
2
2
|
import { deflateSync, inflateSync } from 'fflate'
|
|
3
3
|
import { toUint8Array } from 'js-base64'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
figArchiveMetaJSON,
|
|
7
|
+
figFontEntries,
|
|
8
|
+
figFontsManifest,
|
|
9
|
+
type FigUnreadVariable
|
|
10
|
+
} from '@pairdraw/fig'
|
|
6
11
|
import {
|
|
7
12
|
buildComponentPropIndex,
|
|
8
13
|
exportCanvasGuides,
|
|
@@ -155,15 +160,14 @@ function assignOwnLayerGuids(
|
|
|
155
160
|
|
|
156
161
|
/**
|
|
157
162
|
* The first local ID the counter can mint in sessions 0 and 1: past every saved GUID and every
|
|
158
|
-
* ID that layers, collections, modes, variables and component properties are
|
|
163
|
+
* ID that layers, collections, modes, variables (deleted ones too) and component properties are
|
|
164
|
+
* saved under.
|
|
159
165
|
*/
|
|
160
|
-
/** The first local ID above every GUID the graph's layers, variables, and properties claim. */
|
|
161
166
|
export function firstUnclaimedLocalId(graph: SceneGraph, propertyIds: readonly string[]): number {
|
|
162
|
-
const ids = [...propertyIds]
|
|
167
|
+
const ids = [...propertyIds, ...graph.variables.keys()]
|
|
163
168
|
for (const node of graph.nodes.values()) ids.push(node.source.id || node.id)
|
|
164
169
|
for (const [collectionId, collection] of graph.variableCollections) {
|
|
165
170
|
ids.push(collectionId, ...collection.modes.map((mode) => mode.modeId))
|
|
166
|
-
ids.push(...collection.variableIds)
|
|
167
171
|
}
|
|
168
172
|
let last = 0
|
|
169
173
|
for (const id of ids) {
|
|
@@ -272,7 +276,7 @@ function buildCanvasEntries(
|
|
|
272
276
|
nodeIdToGuid: Map<string, GUID>,
|
|
273
277
|
assignedGuidValues: Set<string>,
|
|
274
278
|
sourceOwners: ReadonlyMap<string, string>,
|
|
275
|
-
|
|
279
|
+
keepsUnreadRecords: boolean
|
|
276
280
|
): { canvasEntries: CanvasExportEntry[]; internalCanvasGuid: GUID | null } {
|
|
277
281
|
const canvasEntries: CanvasExportEntry[] = []
|
|
278
282
|
let internalCanvasGuid: GUID | null = null
|
|
@@ -284,7 +288,7 @@ function buildCanvasEntries(
|
|
|
284
288
|
const canvasGuid = (() => {
|
|
285
289
|
if (!page.source.id) {
|
|
286
290
|
return (
|
|
287
|
-
|
|
291
|
+
ownGuid(page.id, sourceOwners, assignedGuidValues) ?? {
|
|
288
292
|
sessionID: 0,
|
|
289
293
|
localID: localIdCounter.value++
|
|
290
294
|
}
|
|
@@ -319,10 +323,8 @@ function buildCanvasEntries(
|
|
|
319
323
|
|
|
320
324
|
const hasSharedStyles = [...graph.nodes.values()].some((node) => node.sharedStyleType !== null)
|
|
321
325
|
const hasSlotContent = [...graph.nodes.values()].some((node) => ownsSlotContent(graph, node))
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
internalCanvasGuid === null
|
|
325
|
-
) {
|
|
326
|
+
const hasVariables = graph.variableCollections.size > 0 || keepsUnreadRecords
|
|
327
|
+
if ((hasVariables || hasSharedStyles || hasSlotContent) && internalCanvasGuid === null) {
|
|
326
328
|
internalCanvasGuid = { sessionID: 0, localID: localIdCounter.value++ }
|
|
327
329
|
assignedGuidValues.add(`${internalCanvasGuid.sessionID}:${internalCanvasGuid.localID}`)
|
|
328
330
|
canvasEntries.push({
|
|
@@ -383,6 +385,8 @@ export interface FigExportSetup {
|
|
|
383
385
|
componentPropertyDefinitionsById: ReturnType<typeof buildComponentPropIndex>
|
|
384
386
|
pluginDataOverrides: ReadonlyMap<string, PluginDataEntry[]>
|
|
385
387
|
recordOwners?: ReadonlyMap<string, string>
|
|
388
|
+
/** Variable records the document never read, written back as the archive saved them. */
|
|
389
|
+
unreadVariables: readonly FigUnreadVariable[]
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
export interface FigExportSetupOptions {
|
|
@@ -400,6 +404,8 @@ export interface FigExportSetupOptions {
|
|
|
400
404
|
recordOwners?: ReadonlyMap<string, string>
|
|
401
405
|
/** Writing into an archive: the variables, collections and modes it holds keep their GUIDs. */
|
|
402
406
|
archiveResourceIds?: ReadonlySet<string>
|
|
407
|
+
/** Records the document never read, which the write keeps, so nothing new takes their GUIDs. */
|
|
408
|
+
unreadVariables?: readonly FigUnreadVariable[]
|
|
403
409
|
}
|
|
404
410
|
|
|
405
411
|
/**
|
|
@@ -426,6 +432,9 @@ export async function prepareFigExport(
|
|
|
426
432
|
// Reserve the document GUID to prevent imported nodes with source.id "0:0"
|
|
427
433
|
// from reusing the document's own GUID slot.
|
|
428
434
|
assignedGuidValues.add(`${docGuid.sessionID}:${docGuid.localID}`)
|
|
435
|
+
// No layer takes an unread record's GUID either: the save writes that record back.
|
|
436
|
+
for (const { record } of options.unreadVariables ?? [])
|
|
437
|
+
if (record.guid) assignedGuidValues.add(`${record.guid.sessionID}:${record.guid.localID}`)
|
|
429
438
|
const varIdToGuid = new Map<string, GUID>()
|
|
430
439
|
const modeIdToGuid = new Map<string, GUID>()
|
|
431
440
|
const propertyIdToGuid = new Map<string, GUID>()
|
|
@@ -434,10 +443,10 @@ export async function prepareFigExport(
|
|
|
434
443
|
const sourceOwners = layerSourceOwners(graph)
|
|
435
444
|
const archiveRecordIds = new Set(options.archiveRecordIds)
|
|
436
445
|
const propertyIds = collectComponentPropertyIds(graph)
|
|
437
|
-
// Before any canvas, variable or layer takes a counter GUID, so none collides.
|
|
446
|
+
// Before any canvas, variable or layer takes a counter GUID, so none collides with a reserved one.
|
|
438
447
|
localIdCounter.value = Math.max(
|
|
439
448
|
localIdCounter.value,
|
|
440
|
-
firstUnclaimedLocalId(graph, propertyIds),
|
|
449
|
+
firstUnclaimedLocalId(graph, [...propertyIds, ...assignedGuidValues]),
|
|
441
450
|
options.nextLocalId ?? 0
|
|
442
451
|
)
|
|
443
452
|
|
|
@@ -449,7 +458,7 @@ export async function prepareFigExport(
|
|
|
449
458
|
nodeIdToGuid,
|
|
450
459
|
assignedGuidValues,
|
|
451
460
|
sourceOwners,
|
|
452
|
-
|
|
461
|
+
(options.unreadVariables?.length ?? 0) > 0
|
|
453
462
|
)
|
|
454
463
|
// Archive records keep their GUIDs: claim them before any copy that kept one can.
|
|
455
464
|
for (const [guid, nodeId] of options.recordOwners ?? []) {
|
|
@@ -505,7 +514,8 @@ export async function prepareFigExport(
|
|
|
505
514
|
blobIndexByHex: new Map(),
|
|
506
515
|
componentPropertyDefinitionsById: buildComponentPropIndex(graph),
|
|
507
516
|
pluginDataOverrides,
|
|
508
|
-
recordOwners: options.recordOwners
|
|
517
|
+
recordOwners: options.recordOwners,
|
|
518
|
+
unreadVariables: options.unreadVariables ?? []
|
|
509
519
|
}
|
|
510
520
|
}
|
|
511
521
|
|
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
} from '@pairdraw/scene-graph'
|
|
23
23
|
import { fractionalPosition, orderKeyBetween } from '@pairdraw/scene-graph/order-keys'
|
|
24
24
|
import {
|
|
25
|
+
deletedVariablesOf,
|
|
25
26
|
isUnsupportedVariableValue,
|
|
26
27
|
foldFormula,
|
|
27
28
|
formulaValueType,
|
|
@@ -80,7 +81,11 @@ export function assignVariableGuids(
|
|
|
80
81
|
)
|
|
81
82
|
modeIdToGuid.set(mode.modeId, modeGuid)
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
// Deleted variables are written too, so they keep their GUIDs like the listed ones.
|
|
85
|
+
for (const varId of [
|
|
86
|
+
...col.variableIds,
|
|
87
|
+
...deletedVariablesOf(graph, colId).map((item) => item.id)
|
|
88
|
+
]) {
|
|
84
89
|
const varGuid = assignVariableGuid(
|
|
85
90
|
varId,
|
|
86
91
|
localIdCounter,
|
|
@@ -265,11 +270,16 @@ export function appendVariableNodeChanges(
|
|
|
265
270
|
})),
|
|
266
271
|
pluginData: collectionPluginDataNodeChange(collection, modeKey),
|
|
267
272
|
key: collection.key,
|
|
268
|
-
version: collection.version
|
|
273
|
+
version: collection.version,
|
|
274
|
+
...(collection.deleted ? { isSoftDeleted: true } : {})
|
|
269
275
|
})
|
|
270
|
-
for
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
// Deleted variables follow the listed ones: the file keeps them for the layers bound to them.
|
|
277
|
+
const variables = [
|
|
278
|
+
...collection.variableIds.flatMap((id) => graph.variables.get(id) ?? []),
|
|
279
|
+
...deletedVariablesOf(graph, collection.id)
|
|
280
|
+
]
|
|
281
|
+
for (const variable of variables) {
|
|
282
|
+
const id = variable.id
|
|
273
283
|
changes.push({
|
|
274
284
|
guid: ids.get(id) ?? stringToGuid(id),
|
|
275
285
|
parentIndex: { guid: parent, position: nextPosition() },
|
|
@@ -291,7 +301,8 @@ export function appendVariableNodeChanges(
|
|
|
291
301
|
},
|
|
292
302
|
...variableMetadataNodeChange(variable, modeKey),
|
|
293
303
|
key: variable.key,
|
|
294
|
-
version: variable.version
|
|
304
|
+
version: variable.version,
|
|
305
|
+
...(variable.deleted ? { isSoftDeleted: true } : {})
|
|
295
306
|
})
|
|
296
307
|
}
|
|
297
308
|
}
|
|
@@ -42,6 +42,7 @@ export const vectorElement = (
|
|
|
42
42
|
const idPrefix = `${idPart(node.id)}-`
|
|
43
43
|
const icon = readIcon(node)
|
|
44
44
|
const drawn = renderNodeSVGElement(graph, node, {
|
|
45
|
+
documentColorSpace: graph.documentColorSpace,
|
|
45
46
|
idPrefix,
|
|
46
47
|
colorSpace: graph.documentColorSpace,
|
|
47
48
|
tint: icon ? readIconTint : undefined,
|
|
@@ -18,7 +18,7 @@ import { applyArrangement, type ArrangePlacement } from '#core/layout/arrange/ap
|
|
|
18
18
|
import { arrangeBoxes, type ArrangeInput } from '#core/layout/arrange/boxes'
|
|
19
19
|
import { connectorLabelSize } from '#core/layout/arrange/routes'
|
|
20
20
|
import { shapeWithTextWidthFor } from '#core/layout/shape-with-text'
|
|
21
|
-
import {
|
|
21
|
+
import { resolveFontReadiness } from '#core/text/prepare'
|
|
22
22
|
|
|
23
23
|
import { figJamShape } from './shapes'
|
|
24
24
|
import { declarationsFor, readStyle, type FlowStyle } from './styles'
|
|
@@ -247,7 +247,7 @@ export async function addFlowchart(
|
|
|
247
247
|
created = added
|
|
248
248
|
// Shapes grow to their labels, and connector labels take their size, before the layout reads
|
|
249
249
|
// them, measured in the fonts they are drawn in.
|
|
250
|
-
await
|
|
250
|
+
await resolveFontReadiness(graph, added)
|
|
251
251
|
for (const node of chart.nodes) builder.fitWidth(node)
|
|
252
252
|
layoutAuthoredNodes(graph, added)
|
|
253
253
|
const enclosing = enclosingSubgraphs(chart)
|
|
@@ -13,8 +13,8 @@ import { shownText } from '#core/text/case'
|
|
|
13
13
|
import { EMOJI_METRICS_FAMILY } from '#core/text/emoji'
|
|
14
14
|
import { ARABIC_CHARACTER } from '#core/text/fallbacks'
|
|
15
15
|
import { fontManager } from '#core/text/font/manager'
|
|
16
|
-
import type {
|
|
17
|
-
import {
|
|
16
|
+
import type { FontReadiness } from '#core/text/font/readiness'
|
|
17
|
+
import { resolveFontReadiness } from '#core/text/prepare'
|
|
18
18
|
import { collectGraphFontRequirements } from '#core/text/requirements/collect'
|
|
19
19
|
|
|
20
20
|
import type { PDFFontFace } from './fonts'
|
|
@@ -28,9 +28,9 @@ import type { PDFPageSpec } from './plan'
|
|
|
28
28
|
export async function preparePDFFonts(
|
|
29
29
|
graph: SceneGraph,
|
|
30
30
|
specs: readonly PDFPageSpec[]
|
|
31
|
-
): Promise<
|
|
31
|
+
): Promise<FontReadiness> {
|
|
32
32
|
const nodeIds = specs.flatMap((spec) => spec.nodeIds)
|
|
33
|
-
return
|
|
33
|
+
return resolveFontReadiness(graph, nodeIds, await pdfWrittenCharacters(graph, nodeIds))
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -71,7 +71,7 @@ export function readPDFPages(graph: SceneGraph, pageIds?: readonly string[]): vo
|
|
|
71
71
|
export async function preparePagesForPDF(
|
|
72
72
|
graph: SceneGraph,
|
|
73
73
|
specs: readonly PDFPageSpec[]
|
|
74
|
-
): Promise<
|
|
74
|
+
): Promise<FontReadiness> {
|
|
75
75
|
const status = await preparePDFFonts(graph, specs)
|
|
76
76
|
graph.applyDerivedLayoutDuring(() => {
|
|
77
77
|
for (const spec of specs) computeAllLayouts(graph, spec.pageId)
|
|
@@ -80,7 +80,7 @@ export async function preparePagesForPDF(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/** The faces the pages' text uses, with the files the canvas draws them from. */
|
|
83
|
-
export function pdfFontFaces(status:
|
|
83
|
+
export function pdfFontFaces(status: FontReadiness): PDFFontFace[] {
|
|
84
84
|
return status.faces.map((face) => {
|
|
85
85
|
const data =
|
|
86
86
|
face.status === 'available' ? fontManager.loadedData(face.family, face.style) : null
|
|
@@ -208,12 +208,15 @@ export const penFormat: IOFormatAdapter<'pen'> = {
|
|
|
208
208
|
: { graph, sourceFormat: 'pen' }
|
|
209
209
|
},
|
|
210
210
|
async writeDocument(graph) {
|
|
211
|
+
const warnings: string[] = []
|
|
212
|
+
const data = writePenDocument(graph, { warnings })
|
|
211
213
|
return {
|
|
212
214
|
format: 'pen',
|
|
213
215
|
mimeType: 'application/json',
|
|
214
216
|
extension: 'pen',
|
|
215
|
-
data
|
|
216
|
-
encoding: 'utf8'
|
|
217
|
+
data,
|
|
218
|
+
encoding: 'utf8',
|
|
219
|
+
...(warnings.length > 0 ? { warnings } : {})
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
}
|
|
@@ -8,6 +8,7 @@ import Matrix, { type Mat3 } from '@pairdraw/scene-graph/matrix'
|
|
|
8
8
|
import { resolvedVariableModes } from '@pairdraw/scene-graph/variables'
|
|
9
9
|
|
|
10
10
|
import type { SkiaRenderer } from '#core/canvas'
|
|
11
|
+
import { skColorSpace } from '#core/canvas/renderer/colors'
|
|
11
12
|
import { getPageColor } from '#core/figma-api/page-backgrounds'
|
|
12
13
|
import { extractExportGraph, findPageId } from '#core/io/subgraph'
|
|
13
14
|
|
|
@@ -148,6 +149,8 @@ function renderToSurface(
|
|
|
148
149
|
setup: (canvas: Canvas) => void,
|
|
149
150
|
trimTransparent = false
|
|
150
151
|
): Uint8Array<ArrayBuffer> | null {
|
|
152
|
+
renderer.useDocumentColorSpace(renderGraph.documentColorSpace)
|
|
153
|
+
const documentSpace = skColorSpace(ck, renderGraph.documentColorSpace)
|
|
151
154
|
const renderScale = exportRenderScale(width, height)
|
|
152
155
|
const renderWidth = width * renderScale
|
|
153
156
|
const renderHeight = height * renderScale
|
|
@@ -156,7 +159,7 @@ function renderToSurface(
|
|
|
156
159
|
{
|
|
157
160
|
alphaType: ck.AlphaType.Premul,
|
|
158
161
|
colorType: ck.ColorType.RGBA_8888,
|
|
159
|
-
colorSpace:
|
|
162
|
+
colorSpace: documentSpace,
|
|
160
163
|
width: renderWidth,
|
|
161
164
|
height: renderHeight
|
|
162
165
|
},
|
|
@@ -198,7 +201,7 @@ function renderToSurface(
|
|
|
198
201
|
{
|
|
199
202
|
alphaType: ck.AlphaType.Premul,
|
|
200
203
|
colorType: ck.ColorType.RGBA_8888,
|
|
201
|
-
colorSpace:
|
|
204
|
+
colorSpace: documentSpace,
|
|
202
205
|
width,
|
|
203
206
|
height
|
|
204
207
|
},
|
|
@@ -441,9 +444,12 @@ export function renderThumbnail(
|
|
|
441
444
|
if (!frame) return null
|
|
442
445
|
const { bounds, scale, width: pixelW, height: pixelH } = frame
|
|
443
446
|
// The page's own background, which the editor's page colour matches only while it is open.
|
|
444
|
-
const
|
|
447
|
+
const stored = getPageColor(graph.getNode(pageId))
|
|
445
448
|
|
|
446
449
|
return renderToSurface(ck, renderer, graph, pageId, pixelW, pixelH, format, quality, (canvas) => {
|
|
450
|
+
// The page's color is stored in the document's profile, and `renderToSurface` has just told
|
|
451
|
+
// the renderer which that is; converting before that call would use the previous document's.
|
|
452
|
+
const background = renderer.renderColor(stored)
|
|
447
453
|
canvas.clear(ck.Color4f(background.r, background.g, background.b, 1))
|
|
448
454
|
canvas.translate(-bounds.minX * scale, -bounds.minY * scale)
|
|
449
455
|
canvas.scale(scale, scale)
|
|
@@ -463,7 +469,9 @@ export function drawRegionToImage(
|
|
|
463
469
|
const pixelH = Math.max(1, Math.round((bounds.maxY - bounds.minY) * scale))
|
|
464
470
|
if (!graph.getNode(pageId) || !Number.isFinite(pixelW * pixelH)) return null
|
|
465
471
|
return renderToSurface(ck, renderer, graph, pageId, pixelW, pixelH, 'PNG', 100, (canvas) => {
|
|
466
|
-
|
|
472
|
+
// `renderToSurface` has just set the renderer's profile, so the page color converts in it.
|
|
473
|
+
const pageBackground = renderer.renderColor(renderer.pageColor)
|
|
474
|
+
canvas.clear(ck.Color4f(pageBackground.r, pageBackground.g, pageBackground.b, 1))
|
|
467
475
|
canvas.scale(scale, scale)
|
|
468
476
|
canvas.translate(-bounds.minX, -bounds.minY)
|
|
469
477
|
})
|