@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/dist/text/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/text/prepare.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { faceLoadKey, parseFontStyle } from '@pairdraw/scene-graph/font-style'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport {\n canDrawPlatformEmoji,\n mayHoldEmoji,\n NOTO_COLOR_EMOJI_FAMILY,\n savedEmojiCharacters\n} from '#core/text/emoji'\nimport { fontGlyphCoverageSync } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { collectGraphFontRequirements, collectNodeFontFaces } from '#core/text/requirements/collect'\nimport { missingGraphFontScripts } from '#core/text/requirements/resolved'\nimport { fontFaceDemand, fontResolver } from '#core/text/resolver'\n\nimport {
|
|
1
|
+
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/text/prepare.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { faceLoadKey, parseFontStyle } from '@pairdraw/scene-graph/font-style'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport {\n canDrawPlatformEmoji,\n mayHoldEmoji,\n NOTO_COLOR_EMOJI_FAMILY,\n savedEmojiCharacters\n} from '#core/text/emoji'\nimport { fontGlyphCoverageSync } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { collectGraphFontRequirements, collectNodeFontFaces } from '#core/text/requirements/collect'\nimport { missingGraphFontScripts } from '#core/text/requirements/resolved'\nimport { fontFaceDemand, fontResolver } from '#core/text/resolver'\n\nimport { readFontReadiness, type FontReadiness } from './font/readiness'\n\n/**\n * The characters of a text its layout falls back to the emoji metrics font for: ones that may be\n * emoji and that none of the faces it draws in, nor the fallbacks after them, has. A face not\n * loaded cannot tell, and leaves the character to it.\n */\nfunction laidOutEmojiCharacters(node: SceneNode): string {\n if (node.type !== 'TEXT' || !mayHoldEmoji(node.text)) return ''\n const faces = [\n ...collectNodeFontFaces(node),\n { family: DEFAULT_FONT_FAMILY, style: 'Regular' },\n ...[...fontManager.getLetterFallbackFamilies(), ...fontManager.getCJKFallbackFamilies()].map(\n (family) => ({ family, style: 'Regular' })\n )\n ]\n let characters = ''\n for (const character of node.text) {\n if (!mayHoldEmoji(character)) continue\n const drawnByText = faces.some(\n ({ family, style }) => fontGlyphCoverageSync(family, style, character) !== 'missing'\n )\n if (!drawnByText) characters += character\n }\n return characters\n}\n\n/**\n * A one-shot output cannot wait for a face no source has. Loading the substitute face and settling\n * those demands is what lets the text draw in it instead of leaving the layer empty.\n */\nasync function settleUnavailableFonts(\n faces: readonly { family: string; style: string }[],\n characters: string\n): Promise<void> {\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length === 0) return\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', characters)\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, characters))\n }\n}\n\n/**\n * The one readiness read a caller needs: loads every face the document under `nodeIds` asks for,\n * then reports what it can draw with. {@link readFontReadiness} reports the loaded state without\n * loading, for a caller that only mirrors it in the UI.\n */\nexport async function resolveFontReadiness(\n graph: SceneGraph,\n nodeIds: readonly string[],\n /** Characters a writer draws besides the text's own, which the fonts must map too. */\n extraCharacters = '',\n /** An output that draws once and cannot wait for a face to arrive; see `settleUnavailableFonts`. */\n { settleUnavailable = false }: { settleUnavailable?: boolean } = {}\n): Promise<FontReadiness> {\n const collected = collectGraphFontRequirements(graph, nodeIds)\n const requirements = extraCharacters\n ? {\n ...collected,\n characters: uniq(Array.from(collected.characters + extraCharacters)).join('')\n }\n : collected\n const faces = requirements.nodes.flatMap(collectNodeFontFaces)\n await Promise.all(\n faces.map(({ family, style }) => fontManager.loadFont(family, style, requirements.characters))\n )\n // A family found nowhere draws in the default family, and CanvasKit slants the default family's\n // upright face for an italic it lacks. Its face of the same weight and slant is loaded instead,\n // so the canvas draws a real italic and the saved outlines read that face.\n const defaultStyles = uniq(\n faces.flatMap(({ family, style }) => {\n const { weight, italic } = parseFontStyle(style)\n return family === DEFAULT_FONT_FAMILY || fontManager.isLoaded(family)\n ? []\n : [faceLoadKey(weight, italic)]\n })\n )\n await Promise.all(\n defaultStyles.map((style) =>\n fontManager.loadFont(DEFAULT_FONT_FAMILY, style, requirements.characters)\n )\n )\n await fontManager.ensureFallbackPack(\n missingGraphFontScripts(requirements),\n requirements.characters\n )\n if (settleUnavailable) await settleUnavailableFonts(faces, requirements.characters)\n // A face the document asks for and no source has cannot draw; the text is drawn in the default\n // face and the script fallbacks after it, so that face has to be loaded to keep the text\n // visible instead of leaving the layer blank.\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length > 0) {\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', requirements.characters)\n // Nothing else will load these faces in this export, so the render must not wait for them:\n // settling them here is what turns the text into the substituted face it is drawn in.\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, requirements.characters))\n }\n }\n // Without a platform that draws emoji, emoji are drawn with Noto, loaded for just these: the\n // saved ones, and the ones the layout leaves to the emoji metrics font.\n const emoji =\n requirements.nodes.map(savedEmojiCharacters).join('') +\n requirements.nodes.map(laidOutEmojiCharacters).join('')\n if (emoji && !canDrawPlatformEmoji())\n await fontManager.loadRemoteFont(NOTO_COLOR_EMOJI_FAMILY, 'Regular', emoji)\n return readFontReadiness(graph, nodeI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AAO,aAAa,UAAU,CAAC,CAC/F;CAIA,MAAM,gBAAgB,KACpB,MAAM,SAAS,EAAE,QAAQ,YAAY;EACnC,MAAM,EAAE,QAAQ,WAAW,eAAe,KAAK;EAC/C,OAAO,WAAA,WAAkC,YAAY,SAAS,MAAM,IAChE,CAAC,IACD,CAAC,YAAY,QAAQ,MAAM,CAAC;CAClC,CAAC,CACH;CACA,MAAM,QAAQ,IACZ,cAAc,KAAK,UACjB,YAAY,SAAS,qBAAqB,OAAO,aAAa,UAAU,CAC1E,CACF;CACA,MAAM,YAAY,mBAChB,wBAAwB,YAAY,GACpC,aAAa,UACf;CACA,IAAI,mBAAmB,MAAM,uBAAuB,OAAO,aAAa,UAAU;CAIlF,MAAM,cAAc,MAAM,QAAQ,EAAE,QAAQ,YAAY,CAAC,YAAY,cAAc,QAAQ,KAAK,CAAC;CACjG,IAAI,YAAY,SAAS,GAAG;EAC1B,MAAM,YAAY,SAAS,qBAAqB,WAAW,aAAa,UAAU;EAGlF,KAAK,MAAM,EAAE,QAAQ,WAAW,aAC9B,aAAa,QAAQ,eAAe,QAAQ,OAAO,aAAa,UAAU,CAAC;CAE/E;CAGA,MAAM,QACJ,aAAa,MAAM,IAAI,oBAAoB,CAAC,CAAC,KAAK,EAAE,IACpD,aAAa,MAAM,IAAI,sBAAsB,CAAC,CAAC,KAAK,EAAE;CACxD,IAAI,SAAS,CAAC,qBAAqB,GACjC,MAAM,YAAY,eAAe,yBAAyB,WAAW,KAAK;CAC5E,OAAO,kBAAkB,OAAO,OAAO;AACzC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool, toolNumber } from "../schema.js";
|
|
2
2
|
import { analysisLimitInputSchema } from "./schema.js";
|
|
3
|
-
import { orderBy } from "es-toolkit/array";
|
|
4
3
|
import { colorDistance, colorToHex } from "@pairdraw/scene-graph/color";
|
|
4
|
+
import { orderBy } from "es-toolkit/array";
|
|
5
5
|
import * as v from "valibot";
|
|
6
6
|
import { sumBy } from "es-toolkit/math";
|
|
7
7
|
//#region src/tools/analyze/colors.ts
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { extractExportGraph } from "../../../io/subgraph.js";
|
|
2
1
|
import { collectNodeFontFaces } from "../../../text/requirements/collect.js";
|
|
3
2
|
import { measureTextForLayout } from "../../../layout/text-measurement.js";
|
|
4
|
-
import { sizeAutoResizingText } from "../../../layout/text-auto-resize.js";
|
|
5
|
-
import { computeLayout } from "../../../layout.js";
|
|
6
3
|
import { defineTool, nodeIdInputSchema, toolNumber } from "../../schema.js";
|
|
7
4
|
import { computeOverlaps } from "../overlaps/index.js";
|
|
8
5
|
import { boundedRasterScale, rasterScaleInputs } from "../../vector/export.js";
|
|
6
|
+
import { layoutFrameAtWidth } from "./widths.js";
|
|
9
7
|
import { fromUint8Array } from "js-base64";
|
|
10
8
|
import { computeAbsoluteBounds } from "@pairdraw/scene-graph/geometry";
|
|
11
9
|
import * as v from "valibot";
|
|
@@ -160,20 +158,11 @@ const checkResponsive = defineTool({
|
|
|
160
158
|
const maxWarnings = args.max_warnings;
|
|
161
159
|
const results = [];
|
|
162
160
|
for (const width of widths) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
167
|
-
const
|
|
168
|
-
const pageId = extracted.pageId ?? figma.currentPageId;
|
|
169
|
-
const target = copy.getNode(node.id);
|
|
170
|
-
if (!target) continue;
|
|
171
|
-
copy.updateNode(node.id, { width });
|
|
172
|
-
sizeAutoResizingText(copy, node.id);
|
|
173
|
-
computeLayout(copy, node.id);
|
|
174
|
-
const laid = copy.getNode(node.id) ?? target;
|
|
175
|
-
const { warnings, dropped } = collectWarnings(copy, laid, pageId, maxWarnings);
|
|
176
|
-
const scale = boundedRasterScale(laid.width, laid.height, args.scale, args.maxEdge);
|
|
161
|
+
const laid = layoutFrameAtWidth(figma.graph, figma.currentPageId, node.id, width);
|
|
162
|
+
if (!laid) continue;
|
|
163
|
+
const { graph: copy, pageId, frame: target } = laid;
|
|
164
|
+
const { warnings, dropped } = collectWarnings(copy, target, pageId, maxWarnings);
|
|
165
|
+
const scale = boundedRasterScale(target.width, target.height, args.scale, args.maxEdge);
|
|
177
166
|
const bytes = await figma.exportGraphImage(copy, pageId, [node.id], {
|
|
178
167
|
scale,
|
|
179
168
|
format: "PNG"
|
|
@@ -181,7 +170,7 @@ const checkResponsive = defineTool({
|
|
|
181
170
|
if (!bytes) return { error: `Width ${width} could not be rendered` };
|
|
182
171
|
results.push({
|
|
183
172
|
width,
|
|
184
|
-
height: Math.round(
|
|
173
|
+
height: Math.round(target.height),
|
|
185
174
|
mimeType: "image/png",
|
|
186
175
|
base64: fromUint8Array(bytes),
|
|
187
176
|
byteLength: bytes.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/tools/analyze/responsive/index.ts"],"sourcesContent":["import { fromUint8Array } from 'js-base64'\nimport * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { computeAbsoluteBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { extractExportGraph } from '#core/io/subgraph'\nimport { computeLayout, measureTextForLayout, sizeAutoResizingText } from '#core/layout'\nimport { collectNodeFontFaces } from '#core/text/requirements/collect'\nimport {\n computeOverlaps,\n type OverlapItem,\n type OverlapSeverity\n} from '#core/tools/analyze/overlaps'\nimport { defineTool, nodeIdInputSchema, toolNumber } from '#core/tools/schema'\nimport { boundedRasterScale, rasterScaleInputs } from '#core/tools/vector/export'\n\nconst DEFAULT_WIDTHS = [375, 768, 1280]\nconst DEFAULT_MAX_WARNINGS = 20\n/** A layer is outside its frame, or text overflows its box, only past this many pixels. */\nconst TOLERANCE = 1\n\nexport type ResponsiveWarningKind =\n | 'text-overflow'\n | 'text-truncated'\n | 'child-outside-frame'\n | 'sibling-overlap'\n\nexport interface ResponsiveWarning {\n kind: ResponsiveWarningKind\n severity: OverlapSeverity | 'warning'\n node_id: string\n node_name: string\n message: string\n}\n\ninterface Collected {\n warnings: ResponsiveWarning[]\n /** Warnings dropped for this width because `max_warnings` was reached. */\n dropped: number\n}\n\nfunction isContainer(node: SceneNode): boolean {\n return node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE'\n}\n\nfunction isVisible(node: SceneNode, graph: SceneGraph): boolean {\n let current: SceneNode | undefined = node\n while (current) {\n if (!current.visible) return false\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return true\n}\n\nfunction descendants(graph: SceneGraph, rootId: string): SceneNode[] {\n const nodes: SceneNode[] = []\n const stack = [...(graph.getNode(rootId)?.childIds ?? [])].reverse()\n while (stack.length > 0) {\n const node = graph.getNode(stack.pop() ?? '')\n if (!node) continue\n nodes.push(node)\n for (let index = node.childIds.length - 1; index >= 0; index--) {\n const childId = node.childIds[index]\n if (childId) stack.push(childId)\n }\n }\n return nodes\n}\n\n/** Text whose measured height no longer fits the box it was given. */\nfunction textWarnings(node: SceneNode): ResponsiveWarning[] {\n if (node.type !== 'TEXT' || !node.text) return []\n const truncates = node.textAutoResize === 'TRUNCATE' || node.textTruncation === 'ENDING'\n const fixed = node.textAutoResize === 'NONE' || node.textAutoResize === 'TRUNCATE'\n if (!fixed) return []\n const measured = measureTextForLayout(node, node.width).height\n if (measured <= node.height + TOLERANCE) return []\n return [\n truncates\n ? {\n kind: 'text-truncated',\n severity: 'info',\n node_id: node.id,\n node_name: node.name,\n message: `Text is truncated: ${Math.round(measured)}px of text in a ${Math.round(node.height)}px box`\n }\n : {\n kind: 'text-overflow',\n severity: 'warning',\n node_id: node.id,\n node_name: node.name,\n message: `Text overflows its box: ${Math.round(measured)}px of text in a ${Math.round(node.height)}px box`\n }\n ]\n}\n\n/** Direct children whose box reaches past the frame's own box. */\nfunction outsideWarnings(graph: SceneGraph, frame: SceneNode): ResponsiveWarning[] {\n const frameBounds = computeAbsoluteBounds([frame], graph)\n const warnings: ResponsiveWarning[] = []\n for (const childId of frame.childIds) {\n const child = graph.getNode(childId)\n if (!child || !isVisible(child, graph)) continue\n const bounds = computeAbsoluteBounds([child], graph)\n const outside =\n bounds.x < frameBounds.x - TOLERANCE ||\n bounds.y < frameBounds.y - TOLERANCE ||\n bounds.x + bounds.width > frameBounds.x + frameBounds.width + TOLERANCE ||\n bounds.y + bounds.height > frameBounds.y + frameBounds.height + TOLERANCE\n if (!outside) continue\n warnings.push({\n kind: 'child-outside-frame',\n severity: 'warning',\n node_id: child.id,\n node_name: child.name,\n message: `${child.name} reaches outside the ${Math.round(frame.width)}px frame`\n })\n }\n return warnings\n}\n\nfunction laterSibling(graph: SceneGraph, item: OverlapItem): { later: string; earlier: string } {\n const parentId = item.nodeA.parentId\n const order = parentId ? (graph.getNode(parentId)?.childIds ?? []) : []\n const a = order.indexOf(item.nodeA.id)\n const b = order.indexOf(item.nodeB.id)\n return b >= a\n ? { later: item.nodeB.id, earlier: item.nodeA.id }\n : { later: item.nodeA.id, earlier: item.nodeB.id }\n}\n\nfunction overlapWarnings(graph: SceneGraph, pageId: string, limit: number): ResponsiveWarning[] {\n if (limit <= 0) return []\n const result = computeOverlaps(graph, { scope: 'same-parent', page_id: pageId, limit })\n const warnings: ResponsiveWarning[] = []\n for (const item of result.overlaps) {\n if (item.category !== 'sibling-overlap') continue\n const { later, earlier } = laterSibling(graph, item)\n const node = graph.getNode(later)\n warnings.push({\n kind: 'sibling-overlap',\n severity: item.severity,\n node_id: later,\n node_name: node?.name ?? later,\n message: `${node?.name ?? later} overlaps ${graph.getNode(earlier)?.name ?? earlier}`\n })\n if (warnings.length >= limit) break\n }\n return warnings\n}\n\nfunction collectWarnings(\n graph: SceneGraph,\n frame: SceneNode,\n pageId: string,\n maxWarnings: number\n): Collected {\n const found: ResponsiveWarning[] = [\n ...outsideWarnings(graph, frame),\n ...descendants(graph, frame.id).flatMap((node) => textWarnings(node)),\n ...overlapWarnings(graph, pageId, maxWarnings)\n ]\n return {\n warnings: found.slice(0, maxWarnings),\n dropped: Math.max(0, found.length - maxWarnings)\n }\n}\n\n/** The width a copy is laid out at, never below one pixel. */\nfunction clampWidth(width: number): number {\n return Math.max(1, Math.round(width))\n}\n\nexport const checkResponsive = defineTool({\n name: 'check_responsive',\n\n description:\n 'Lay out and render a copy of a frame at several viewport widths without changing the document, and report text overflow, layers outside the frame, and overlapping siblings at each width. Auto-layout children reflow; children placed by free x/y keep their position, as constraints are not applied.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n id: nodeIdInputSchema,\n widths: v.optional(\n v.pipe(\n v.array(toolNumber(v.pipe(v.number(), v.minValue(1), v.maxValue(4096)))),\n v.minLength(1),\n v.maxLength(12),\n v.description(\n 'Viewport widths to test in the same units as the frame (default: 375, 768, 1280)'\n )\n )\n ),\n max_warnings: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(0),\n v.maxValue(200),\n v.description('Warnings reported per width (default: 20)')\n )\n ),\n DEFAULT_MAX_WARNINGS\n ),\n ...rasterScaleInputs\n }),\n // Every face the frame draws text with must load before the copy is measured.\n fonts: (figma, { id }) => {\n const node = figma.graph.getNode(id)\n return node ? descendants(figma.graph, node.id).flatMap(collectNodeFontFaces) : []\n },\n execute: async (figma, args) => {\n const node = figma.graph.getNode(args.id)\n if (!node) return { error: `Node \"${args.id}\" not found` }\n if (!isContainer(node)) {\n return { error: `Node \"${args.id}\" is a ${node.type}; check_responsive needs a frame` }\n }\n if (!figma.exportGraphImage) {\n return { error: 'Responsive rendering is not available in this environment' }\n }\n\n const widths = (args.widths ?? DEFAULT_WIDTHS).map(clampWidth)\n const maxWarnings = args.max_warnings\n const results = []\n\n for (const width of widths) {\n const extracted = extractExportGraph(figma.graph, { scope: 'node', nodeId: node.id })\n const copy = extracted.graph\n const pageId = extracted.pageId ?? figma.currentPageId\n const target = copy.getNode(node.id)\n if (!target) continue\n\n copy.updateNode(node.id, { width })\n sizeAutoResizingText(copy, node.id)\n computeLayout(copy, node.id)\n\n const laid = copy.getNode(node.id) ?? target\n const { warnings, dropped } = collectWarnings(copy, laid, pageId, maxWarnings)\n const scale = boundedRasterScale(laid.width, laid.height, args.scale, args.maxEdge)\n const bytes = await figma.exportGraphImage(copy, pageId, [node.id], {\n scale,\n format: 'PNG'\n })\n if (!bytes) return { error: `Width ${width} could not be rendered` }\n\n results.push({\n width,\n height: Math.round(laid.height),\n mimeType: 'image/png',\n base64: fromUint8Array(bytes),\n byteLength: bytes.length,\n warnings,\n ...(dropped > 0 ? { dropped_warnings: dropped } : {})\n })\n }\n\n return {\n id: node.id,\n name: node.name,\n widths: results,\n warningCount: results.reduce((total, entry) => total + entry.warnings.length, 0)\n }\n }\n})\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,iBAAiB;CAAC;CAAK;CAAK;AAAI;AACtC,MAAM,uBAAuB;;AAE7B,MAAM,YAAY;AAsBlB,SAAS,YAAY,MAA0B;CAC7C,OAAO,KAAK,SAAS,WAAW,KAAK,SAAS,eAAe,KAAK,SAAS;AAC7E;AAEA,SAAS,UAAU,MAAiB,OAA4B;CAC9D,IAAI,UAAiC;CACrC,OAAO,SAAS;EACd,IAAI,CAAC,QAAQ,SAAS,OAAO;EAC7B,UAAU,QAAQ,WAAW,MAAM,QAAQ,QAAQ,QAAQ,IAAI,KAAA;CACjE;CACA,OAAO;AACT;AAEA,SAAS,YAAY,OAAmB,QAA6B;CACnE,MAAM,QAAqB,CAAC;CAC5B,MAAM,QAAQ,CAAC,GAAI,MAAM,QAAQ,MAAM,CAAC,EAAE,YAAY,CAAC,CAAE,CAAC,CAAC,QAAQ;CACnE,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,KAAK,EAAE;EAC5C,IAAI,CAAC,MAAM;EACX,MAAM,KAAK,IAAI;EACf,KAAK,IAAI,QAAQ,KAAK,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS;GAC9D,MAAM,UAAU,KAAK,SAAS;GAC9B,IAAI,SAAS,MAAM,KAAK,OA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"sourcesContent":["import { fromUint8Array } from 'js-base64'\nimport * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { computeAbsoluteBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { measureTextForLayout } from '#core/layout'\nimport { collectNodeFontFaces } from '#core/text/requirements/collect'\nimport {\n computeOverlaps,\n type OverlapItem,\n type OverlapSeverity\n} from '#core/tools/analyze/overlaps'\nimport { layoutFrameAtWidth } from '#core/tools/analyze/responsive/widths'\nimport { defineTool, nodeIdInputSchema, toolNumber } from '#core/tools/schema'\nimport { boundedRasterScale, rasterScaleInputs } from '#core/tools/vector/export'\n\nconst DEFAULT_WIDTHS = [375, 768, 1280]\nconst DEFAULT_MAX_WARNINGS = 20\n/** A layer is outside its frame, or text overflows its box, only past this many pixels. */\nconst TOLERANCE = 1\n\nexport type ResponsiveWarningKind =\n | 'text-overflow'\n | 'text-truncated'\n | 'child-outside-frame'\n | 'sibling-overlap'\n\nexport interface ResponsiveWarning {\n kind: ResponsiveWarningKind\n severity: OverlapSeverity | 'warning'\n node_id: string\n node_name: string\n message: string\n}\n\ninterface Collected {\n warnings: ResponsiveWarning[]\n /** Warnings dropped for this width because `max_warnings` was reached. */\n dropped: number\n}\n\nfunction isContainer(node: SceneNode): boolean {\n return node.type === 'FRAME' || node.type === 'COMPONENT' || node.type === 'INSTANCE'\n}\n\nfunction isVisible(node: SceneNode, graph: SceneGraph): boolean {\n let current: SceneNode | undefined = node\n while (current) {\n if (!current.visible) return false\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return true\n}\n\nfunction descendants(graph: SceneGraph, rootId: string): SceneNode[] {\n const nodes: SceneNode[] = []\n const stack = [...(graph.getNode(rootId)?.childIds ?? [])].reverse()\n while (stack.length > 0) {\n const node = graph.getNode(stack.pop() ?? '')\n if (!node) continue\n nodes.push(node)\n for (let index = node.childIds.length - 1; index >= 0; index--) {\n const childId = node.childIds[index]\n if (childId) stack.push(childId)\n }\n }\n return nodes\n}\n\n/** Text whose measured height no longer fits the box it was given. */\nfunction textWarnings(node: SceneNode): ResponsiveWarning[] {\n if (node.type !== 'TEXT' || !node.text) return []\n const truncates = node.textAutoResize === 'TRUNCATE' || node.textTruncation === 'ENDING'\n const fixed = node.textAutoResize === 'NONE' || node.textAutoResize === 'TRUNCATE'\n if (!fixed) return []\n const measured = measureTextForLayout(node, node.width).height\n if (measured <= node.height + TOLERANCE) return []\n return [\n truncates\n ? {\n kind: 'text-truncated',\n severity: 'info',\n node_id: node.id,\n node_name: node.name,\n message: `Text is truncated: ${Math.round(measured)}px of text in a ${Math.round(node.height)}px box`\n }\n : {\n kind: 'text-overflow',\n severity: 'warning',\n node_id: node.id,\n node_name: node.name,\n message: `Text overflows its box: ${Math.round(measured)}px of text in a ${Math.round(node.height)}px box`\n }\n ]\n}\n\n/** Direct children whose box reaches past the frame's own box. */\nfunction outsideWarnings(graph: SceneGraph, frame: SceneNode): ResponsiveWarning[] {\n const frameBounds = computeAbsoluteBounds([frame], graph)\n const warnings: ResponsiveWarning[] = []\n for (const childId of frame.childIds) {\n const child = graph.getNode(childId)\n if (!child || !isVisible(child, graph)) continue\n const bounds = computeAbsoluteBounds([child], graph)\n const outside =\n bounds.x < frameBounds.x - TOLERANCE ||\n bounds.y < frameBounds.y - TOLERANCE ||\n bounds.x + bounds.width > frameBounds.x + frameBounds.width + TOLERANCE ||\n bounds.y + bounds.height > frameBounds.y + frameBounds.height + TOLERANCE\n if (!outside) continue\n warnings.push({\n kind: 'child-outside-frame',\n severity: 'warning',\n node_id: child.id,\n node_name: child.name,\n message: `${child.name} reaches outside the ${Math.round(frame.width)}px frame`\n })\n }\n return warnings\n}\n\nfunction laterSibling(graph: SceneGraph, item: OverlapItem): { later: string; earlier: string } {\n const parentId = item.nodeA.parentId\n const order = parentId ? (graph.getNode(parentId)?.childIds ?? []) : []\n const a = order.indexOf(item.nodeA.id)\n const b = order.indexOf(item.nodeB.id)\n return b >= a\n ? { later: item.nodeB.id, earlier: item.nodeA.id }\n : { later: item.nodeA.id, earlier: item.nodeB.id }\n}\n\nfunction overlapWarnings(graph: SceneGraph, pageId: string, limit: number): ResponsiveWarning[] {\n if (limit <= 0) return []\n const result = computeOverlaps(graph, { scope: 'same-parent', page_id: pageId, limit })\n const warnings: ResponsiveWarning[] = []\n for (const item of result.overlaps) {\n if (item.category !== 'sibling-overlap') continue\n const { later, earlier } = laterSibling(graph, item)\n const node = graph.getNode(later)\n warnings.push({\n kind: 'sibling-overlap',\n severity: item.severity,\n node_id: later,\n node_name: node?.name ?? later,\n message: `${node?.name ?? later} overlaps ${graph.getNode(earlier)?.name ?? earlier}`\n })\n if (warnings.length >= limit) break\n }\n return warnings\n}\n\nfunction collectWarnings(\n graph: SceneGraph,\n frame: SceneNode,\n pageId: string,\n maxWarnings: number\n): Collected {\n const found: ResponsiveWarning[] = [\n ...outsideWarnings(graph, frame),\n ...descendants(graph, frame.id).flatMap((node) => textWarnings(node)),\n ...overlapWarnings(graph, pageId, maxWarnings)\n ]\n return {\n warnings: found.slice(0, maxWarnings),\n dropped: Math.max(0, found.length - maxWarnings)\n }\n}\n\n/** The width a copy is laid out at, never below one pixel. */\nfunction clampWidth(width: number): number {\n return Math.max(1, Math.round(width))\n}\n\nexport const checkResponsive = defineTool({\n name: 'check_responsive',\n\n description:\n 'Lay out and render a copy of a frame at several viewport widths without changing the document, and report text overflow, layers outside the frame, and overlapping siblings at each width. Auto-layout children reflow; children placed by free x/y keep their position, as constraints are not applied.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n id: nodeIdInputSchema,\n widths: v.optional(\n v.pipe(\n v.array(toolNumber(v.pipe(v.number(), v.minValue(1), v.maxValue(4096)))),\n v.minLength(1),\n v.maxLength(12),\n v.description(\n 'Viewport widths to test in the same units as the frame (default: 375, 768, 1280)'\n )\n )\n ),\n max_warnings: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(0),\n v.maxValue(200),\n v.description('Warnings reported per width (default: 20)')\n )\n ),\n DEFAULT_MAX_WARNINGS\n ),\n ...rasterScaleInputs\n }),\n // Every face the frame draws text with must load before the copy is measured.\n fonts: (figma, { id }) => {\n const node = figma.graph.getNode(id)\n return node ? descendants(figma.graph, node.id).flatMap(collectNodeFontFaces) : []\n },\n execute: async (figma, args) => {\n const node = figma.graph.getNode(args.id)\n if (!node) return { error: `Node \"${args.id}\" not found` }\n if (!isContainer(node)) {\n return { error: `Node \"${args.id}\" is a ${node.type}; check_responsive needs a frame` }\n }\n if (!figma.exportGraphImage) {\n return { error: 'Responsive rendering is not available in this environment' }\n }\n\n const widths = (args.widths ?? DEFAULT_WIDTHS).map(clampWidth)\n const maxWarnings = args.max_warnings\n const results = []\n\n for (const width of widths) {\n const laid = layoutFrameAtWidth(figma.graph, figma.currentPageId, node.id, width)\n if (!laid) continue\n const { graph: copy, pageId, frame: target } = laid\n\n const { warnings, dropped } = collectWarnings(copy, target, pageId, maxWarnings)\n const scale = boundedRasterScale(target.width, target.height, args.scale, args.maxEdge)\n const bytes = await figma.exportGraphImage(copy, pageId, [node.id], {\n scale,\n format: 'PNG'\n })\n if (!bytes) return { error: `Width ${width} could not be rendered` }\n\n results.push({\n width,\n height: Math.round(target.height),\n mimeType: 'image/png',\n base64: fromUint8Array(bytes),\n byteLength: bytes.length,\n warnings,\n ...(dropped > 0 ? { dropped_warnings: dropped } : {})\n })\n }\n\n return {\n id: node.id,\n name: node.name,\n widths: results,\n warningCount: results.reduce((total, entry) => total + entry.warnings.length, 0)\n }\n }\n})\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,iBAAiB;CAAC;CAAK;CAAK;AAAI;AACtC,MAAM,uBAAuB;;AAE7B,MAAM,YAAY;AAsBlB,SAAS,YAAY,MAA0B;CAC7C,OAAO,KAAK,SAAS,WAAW,KAAK,SAAS,eAAe,KAAK,SAAS;AAC7E;AAEA,SAAS,UAAU,MAAiB,OAA4B;CAC9D,IAAI,UAAiC;CACrC,OAAO,SA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K;IAC5B,YAAY,MAAM;IAClB;IACA,GAAI,UAAU,IAAI,EAAE,kBAAkB,QAAQ,IAAI,CAAC;GACrD,CAAC;EACH;EAEA,OAAO;GACL,IAAI,KAAK;GACT,MAAM,KAAK;GACX,QAAQ;GACR,cAAc,QAAQ,QAAQ,OAAO,UAAU,QAAQ,MAAM,SAAS,QAAQ,CAAC;EACjF;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/tools/analyze/responsive/widths.d.ts
|
|
3
|
+
interface FrameAtWidth {
|
|
4
|
+
/** A copy holding only the frame's subtree, laid out at `requested`. */
|
|
5
|
+
graph: SceneGraph;
|
|
6
|
+
pageId: string;
|
|
7
|
+
frame: SceneNode;
|
|
8
|
+
/** The width the copy was asked for, rounded. */
|
|
9
|
+
requested: number;
|
|
10
|
+
/** Whether the frame's own min or max width moved it away from `requested`. */
|
|
11
|
+
clamped: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The narrower widths to render a frame at: 375 and 768, each kept only when it is narrower
|
|
15
|
+
* than the frame and wide enough to be worth a render. Rounded, so a fractional width compares
|
|
16
|
+
* as its whole pixels.
|
|
17
|
+
*/
|
|
18
|
+
declare function widthVariants(frameWidth: number): number[];
|
|
19
|
+
/**
|
|
20
|
+
* A copy of the frame and its subtree laid out at `width`, with auto-resizing text sized for it.
|
|
21
|
+
* The input graph is not touched. `clamped` reports that the frame's own min or max width held
|
|
22
|
+
* it away from the requested width, so a caller can drop a render it cannot label honestly.
|
|
23
|
+
*/
|
|
24
|
+
declare function layoutFrameAtWidth(graph: SceneGraph, pageId: string, frameId: string, width: number): FrameAtWidth | null;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { FrameAtWidth, layoutFrameAtWidth, widthVariants };
|
|
27
|
+
//# sourceMappingURL=widths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widths.d.ts","names":[],"sources":["../../../../src/tools/analyze/responsive/widths.ts"],"mappings":";;UAciB;;EAEf,OAAO;EACP;EACA,OAAO;;EAEP;;EAEA;;;;;;;iBAQc,cAAc;;;;;;iBAUd,mBACd,OAAO,YACP,gBACA,iBACA,gBACC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { extractExportGraph } from "../../../io/subgraph.js";
|
|
2
|
+
import { sizeAutoResizingText } from "../../../layout/text-auto-resize.js";
|
|
3
|
+
import { computeLayout } from "../../../layout.js";
|
|
4
|
+
//#region src/tools/analyze/responsive/widths.ts
|
|
5
|
+
/** The narrower widths a responsive frame is rendered at, when they fit under its own. */
|
|
6
|
+
const NARROW_WIDTHS = [375, 768];
|
|
7
|
+
/** Below this a narrow render says nothing a phone-sized frame has not already shown. */
|
|
8
|
+
const MIN_NARROW_WIDTH = 240;
|
|
9
|
+
/** A layout that misses the requested width by more than this was clamped, not reflowed. */
|
|
10
|
+
const CLAMP_TOLERANCE = 1;
|
|
11
|
+
/**
|
|
12
|
+
* The narrower widths to render a frame at: 375 and 768, each kept only when it is narrower
|
|
13
|
+
* than the frame and wide enough to be worth a render. Rounded, so a fractional width compares
|
|
14
|
+
* as its whole pixels.
|
|
15
|
+
*/
|
|
16
|
+
function widthVariants(frameWidth) {
|
|
17
|
+
const own = Math.round(frameWidth);
|
|
18
|
+
return NARROW_WIDTHS.filter((width) => width >= MIN_NARROW_WIDTH && width < own);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A copy of the frame and its subtree laid out at `width`, with auto-resizing text sized for it.
|
|
22
|
+
* The input graph is not touched. `clamped` reports that the frame's own min or max width held
|
|
23
|
+
* it away from the requested width, so a caller can drop a render it cannot label honestly.
|
|
24
|
+
*/
|
|
25
|
+
function layoutFrameAtWidth(graph, pageId, frameId, width) {
|
|
26
|
+
const extracted = extractExportGraph(graph, {
|
|
27
|
+
scope: "node",
|
|
28
|
+
nodeId: frameId
|
|
29
|
+
});
|
|
30
|
+
const copy = extracted.graph;
|
|
31
|
+
if (!copy.getNode(frameId)) return null;
|
|
32
|
+
const requested = Math.max(1, Math.round(width));
|
|
33
|
+
copy.updateNode(frameId, { width: requested });
|
|
34
|
+
sizeAutoResizingText(copy, frameId);
|
|
35
|
+
computeLayout(copy, frameId);
|
|
36
|
+
const frame = copy.getNode(frameId);
|
|
37
|
+
if (!frame) return null;
|
|
38
|
+
return {
|
|
39
|
+
graph: copy,
|
|
40
|
+
pageId: extracted.pageId ?? pageId,
|
|
41
|
+
frame,
|
|
42
|
+
requested,
|
|
43
|
+
clamped: Math.abs(frame.width - requested) > CLAMP_TOLERANCE
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { layoutFrameAtWidth, widthVariants };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=widths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widths.js","names":[],"sources":["../../../../src/tools/analyze/responsive/widths.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { extractExportGraph } from '#core/io/subgraph'\nimport { computeLayout, sizeAutoResizingText } from '#core/layout'\n\n/** The narrower widths a responsive frame is rendered at, when they fit under its own. */\nconst NARROW_WIDTHS = [375, 768] as const\n\n/** Below this a narrow render says nothing a phone-sized frame has not already shown. */\nconst MIN_NARROW_WIDTH = 240\n\n/** A layout that misses the requested width by more than this was clamped, not reflowed. */\nconst CLAMP_TOLERANCE = 1\n\nexport interface FrameAtWidth {\n /** A copy holding only the frame's subtree, laid out at `requested`. */\n graph: SceneGraph\n pageId: string\n frame: SceneNode\n /** The width the copy was asked for, rounded. */\n requested: number\n /** Whether the frame's own min or max width moved it away from `requested`. */\n clamped: boolean\n}\n\n/**\n * The narrower widths to render a frame at: 375 and 768, each kept only when it is narrower\n * than the frame and wide enough to be worth a render. Rounded, so a fractional width compares\n * as its whole pixels.\n */\nexport function widthVariants(frameWidth: number): number[] {\n const own = Math.round(frameWidth)\n return NARROW_WIDTHS.filter((width) => width >= MIN_NARROW_WIDTH && width < own)\n}\n\n/**\n * A copy of the frame and its subtree laid out at `width`, with auto-resizing text sized for it.\n * The input graph is not touched. `clamped` reports that the frame's own min or max width held\n * it away from the requested width, so a caller can drop a render it cannot label honestly.\n */\nexport function layoutFrameAtWidth(\n graph: SceneGraph,\n pageId: string,\n frameId: string,\n width: number\n): FrameAtWidth | null {\n const extracted = extractExportGraph(graph, { scope: 'node', nodeId: frameId })\n const copy = extracted.graph\n if (!copy.getNode(frameId)) return null\n const requested = Math.max(1, Math.round(width))\n copy.updateNode(frameId, { width: requested })\n sizeAutoResizingText(copy, frameId)\n computeLayout(copy, frameId)\n const frame = copy.getNode(frameId)\n if (!frame) return null\n return {\n graph: copy,\n pageId: extracted.pageId ?? pageId,\n frame,\n requested,\n clamped: Math.abs(frame.width - requested) > CLAMP_TOLERANCE\n }\n}\n"],"mappings":";;;;;AAMA,MAAM,gBAAgB,CAAC,KAAK,GAAG;;AAG/B,MAAM,mBAAmB;;AAGzB,MAAM,kBAAkB;;;;;;AAkBxB,SAAgB,cAAc,YAA8B;CAC1D,MAAM,MAAM,KAAK,MAAM,UAAU;CACjC,OAAO,cAAc,QAAQ,UAAU,SAAS,oBAAoB,QAAQ,GAAG;AACjF;;;;;;AAOA,SAAgB,mBACd,OACA,QACA,SACA,OACqB;CACrB,MAAM,YAAY,mBAAmB,OAAO;EAAE,OAAO;EAAQ,QAAQ;CAAQ,CAAC;CAC9E,MAAM,OAAO,UAAU;CACvB,IAAI,CAAC,KAAK,QAAQ,OAAO,GAAG,OAAO;CACnC,MAAM,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;CAC/C,KAAK,WAAW,SAAS,EAAE,OAAO,UAAU,CAAC;CAC7C,qBAAqB,MAAM,OAAO;CAClC,cAAc,MAAM,OAAO;CAC3B,MAAM,QAAQ,KAAK,QAAQ,OAAO;CAClC,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO;EACL,OAAO;EACP,QAAQ,UAAU,UAAU;EAC5B;EACA;EACA,SAAS,KAAK,IAAI,MAAM,QAAQ,SAAS,IAAI;CAC/C;AACF"}
|
package/dist/tools/analyze.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { evalCode } from "./analyze/eval/index.js";
|
|
|
11
11
|
import { lint, lintFix } from "./analyze/lint.js";
|
|
12
12
|
import { compileScript, wrapEvalCode } from "./analyze/eval/wrap.js";
|
|
13
13
|
import { ResponsiveWarning, ResponsiveWarningKind, checkResponsive } from "./analyze/responsive/index.js";
|
|
14
|
+
import { FrameAtWidth, layoutFrameAtWidth, widthVariants } from "./analyze/responsive/widths.js";
|
|
14
15
|
import { analyzeSpacing } from "./analyze/spacing.js";
|
|
15
16
|
import { analyzeTypography } from "./analyze/typography.js";
|
|
16
|
-
export { type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, type AnalyzeOverlapsSummary, type DocumentDiff, type DocumentDiffOptions, type LayerJSXChange, type OverlapCategory, type OverlapIntersection, type OverlapItem, type OverlapNodeSummary, type OverlapScope, type OverlapSeverity, type ResponsiveWarning, type ResponsiveWarningKind, analyzeClusters, analyzeColors, analyzeOverlaps, analyzeSpacing, analyzeTypography, calcClusterConfidence, checkResponsive, compileScript, computeOverlaps, diffApply, diffChanges, diffCreate, diffDocuments, diffPageLayersJSX, diffShow, diffVisual, evalCode, lint, lintFix, wrapEvalCode };
|
|
17
|
+
export { type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, type AnalyzeOverlapsSummary, type DocumentDiff, type DocumentDiffOptions, type FrameAtWidth, type LayerJSXChange, type OverlapCategory, type OverlapIntersection, type OverlapItem, type OverlapNodeSummary, type OverlapScope, type OverlapSeverity, type ResponsiveWarning, type ResponsiveWarningKind, analyzeClusters, analyzeColors, analyzeOverlaps, analyzeSpacing, analyzeTypography, calcClusterConfidence, checkResponsive, compileScript, computeOverlaps, diffApply, diffChanges, diffCreate, diffDocuments, diffPageLayersJSX, diffShow, diffVisual, evalCode, layoutFrameAtWidth, lint, lintFix, widthVariants, wrapEvalCode };
|
package/dist/tools/analyze.js
CHANGED
|
@@ -9,7 +9,8 @@ import { diffPageLayersJSX } from "./analyze/diff/jsx.js";
|
|
|
9
9
|
import { compileScript, wrapEvalCode } from "./analyze/eval/wrap.js";
|
|
10
10
|
import { evalCode } from "./analyze/eval/index.js";
|
|
11
11
|
import { lint, lintFix } from "./analyze/lint.js";
|
|
12
|
+
import { layoutFrameAtWidth, widthVariants } from "./analyze/responsive/widths.js";
|
|
12
13
|
import { checkResponsive } from "./analyze/responsive/index.js";
|
|
13
14
|
import { analyzeSpacing } from "./analyze/spacing.js";
|
|
14
15
|
import { analyzeTypography } from "./analyze/typography.js";
|
|
15
|
-
export { analyzeClusters, analyzeColors, analyzeOverlaps, analyzeSpacing, analyzeTypography, calcClusterConfidence, checkResponsive, compileScript, computeOverlaps, diffApply, diffChanges, diffCreate, diffDocuments, diffPageLayersJSX, diffShow, diffVisual, evalCode, lint, lintFix, wrapEvalCode };
|
|
16
|
+
export { analyzeClusters, analyzeColors, analyzeOverlaps, analyzeSpacing, analyzeTypography, calcClusterConfidence, checkResponsive, compileScript, computeOverlaps, diffApply, diffChanges, diffCreate, diffDocuments, diffPageLayersJSX, diffShow, diffVisual, evalCode, layoutFrameAtWidth, lint, lintFix, widthVariants, wrapEvalCode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","names":[],"sources":["../../../src/tools/codegen/tokens.ts"],"mappings":";;;;;KAOY;EACV;;EAEA;EACA,OAAO;;KAGG;EACV;EACA;EACA;;EAEA,QAAQ;;;iBAIY,sBACpB,OAAO,YACP,SAAS,qBACR,QAAQ;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","names":[],"sources":["../../../src/tools/codegen/tokens.ts"],"mappings":";;;;;KAOY;EACV;;EAEA;EACA,OAAO;;KAGG;EACV;EACA;EACA;;EAEA,QAAQ;;;iBAIY,sBACpB,OAAO,YACP,SAAS,qBACR,QAAQ;cAyBE,gBAAA;cAwCA,oBAAA"}
|
|
@@ -4,8 +4,8 @@ import * as v from "valibot";
|
|
|
4
4
|
/** The document's variables as a token stylesheet, shared by the tool, the CLI, and the app. */
|
|
5
5
|
async function exportTokenStylesheet(graph, options) {
|
|
6
6
|
const query = options.collection?.toLowerCase();
|
|
7
|
-
const collectionIds = new Set(
|
|
8
|
-
const ids = new Set(
|
|
7
|
+
const collectionIds = new Set(graph.getLiveCollections().filter((collection) => !query || collection.name.toLowerCase().includes(query)).map((collection) => collection.id));
|
|
8
|
+
const ids = new Set(graph.getLiveVariables().filter((variable) => collectionIds.has(variable.collectionId)).filter((variable) => !options.type || variable.type === options.type).map((variable) => variable.id));
|
|
9
9
|
if (ids.size === 0) return {
|
|
10
10
|
css: "",
|
|
11
11
|
tokenCount: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","names":[],"sources":["../../../src/tools/codegen/tokens.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph, VariableType } from '@pairdraw/scene-graph'\n\nimport type { DesignTokenFile } from '#core/io/formats/design-tokens'\nimport { defineTool } from '#core/tools/schema'\n\nexport type TokenExportOptions = {\n format: 'css' | 'tailwind'\n /** Collection name, matched as a case-insensitive substring. */\n collection?: string\n type?: VariableType\n}\n\nexport type TokenExport = {\n css: string\n tokenCount: number\n issues: string[]\n /** W3C design token files, for the `dtcg` format. */\n files?: DesignTokenFile[]\n}\n\n/** The document's variables as a token stylesheet, shared by the tool, the CLI, and the app. */\nexport async function exportTokenStylesheet(\n graph: SceneGraph,\n options: TokenExportOptions\n): Promise<TokenExport> {\n const query = options.collection?.toLowerCase()\n const collectionIds = new Set(\n
|
|
1
|
+
{"version":3,"file":"tokens.js","names":[],"sources":["../../../src/tools/codegen/tokens.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph, VariableType } from '@pairdraw/scene-graph'\n\nimport type { DesignTokenFile } from '#core/io/formats/design-tokens'\nimport { defineTool } from '#core/tools/schema'\n\nexport type TokenExportOptions = {\n format: 'css' | 'tailwind'\n /** Collection name, matched as a case-insensitive substring. */\n collection?: string\n type?: VariableType\n}\n\nexport type TokenExport = {\n css: string\n tokenCount: number\n issues: string[]\n /** W3C design token files, for the `dtcg` format. */\n files?: DesignTokenFile[]\n}\n\n/** The document's variables as a token stylesheet, shared by the tool, the CLI, and the app. */\nexport async function exportTokenStylesheet(\n graph: SceneGraph,\n options: TokenExportOptions\n): Promise<TokenExport> {\n const query = options.collection?.toLowerCase()\n const collectionIds = new Set(\n graph\n .getLiveCollections()\n .filter((collection) => !query || collection.name.toLowerCase().includes(query))\n .map((collection) => collection.id)\n )\n const ids = new Set(\n graph\n .getLiveVariables()\n .filter((variable) => collectionIds.has(variable.collectionId))\n .filter((variable) => !options.type || variable.type === options.type)\n .map((variable) => variable.id)\n )\n if (ids.size === 0) return { css: '', tokenCount: 0, issues: [] }\n\n const { tokenStylesheet } = await import('@pairdraw/dom-css/export')\n const { css, issues } = await tokenStylesheet(graph, {\n format: options.format,\n include: (variable) => ids.has(variable.id)\n })\n return { css, tokenCount: ids.size, issues: issues.map((issue) => issue.message) }\n}\n\nexport const designToTokens = defineTool({\n name: 'design_to_tokens',\n description:\n 'Write the document variables as a stylesheet of CSS custom properties: defaults in :root, every other mode under its condition (a selector such as [data-theme=\"dark\"] or an @media query), aliases as var() references. The tailwind format puts tokens with a Tailwind v4 namespace (--color-*, --spacing-*, --radius-*, --text-*, …) in @theme and adds a @custom-variant per mode. The dtcg format returns W3C design token files instead: one per collection mode, text and effect styles as typography and shadow tokens, and a resolver document; collection and type filters do not apply to it. Issues lists tokens or modes that could not be written.',\n execution: { kind: 'async', mutation: 'none' },\n input: v.strictObject({\n format: v.optional(\n v.pipe(\n v.picklist(['css', 'tailwind', 'dtcg']),\n v.description(\n 'css: :root and mode scopes; tailwind: @theme, mode scopes and variants; dtcg: W3C design token files'\n )\n ),\n 'css'\n ),\n collection: v.optional(\n v.pipe(v.string(), v.description('Filter by collection name (substring, case-insensitive)'))\n ),\n type: v.optional(\n v.pipe(\n v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']),\n v.description('Filter by variable type')\n )\n )\n }),\n execute: async (figma, args) => {\n if (args.format === 'dtcg') {\n const { designTokenIssueMessage, exportDesignTokens } =\n await import('#core/io/formats/design-tokens')\n const { files, issues } = exportDesignTokens(figma.graph)\n return { files, issues: issues.map(designTokenIssueMessage) }\n }\n const { css, tokenCount, issues } = await exportTokenStylesheet(figma.graph, {\n ...args,\n format: args.format\n })\n return { output: css, tokenCount, issues }\n }\n})\n\nexport const importDesignTokens = defineTool({\n name: 'import_design_tokens',\n description:\n 'Import W3C design token (DTCG) files into the document as variables, and typography and shadow tokens as text and effect styles. Pass each file with its path: a file per mode grouped by folder (as Figma exports modes), a .resolver.json with the files it refers to, or a Tokens Studio file with $themes. Collections and modes with the same names as existing ones are updated, variables are matched by name, and nothing is deleted. Returns what was added, updated, and skipped and why.',\n execution: { kind: 'async', mutation: 'document' },\n input: v.strictObject({\n files: v.pipe(\n v.array(v.object({ path: v.string(), text: v.string() })),\n v.minLength(1),\n v.description('Token files, each with its path (folders name collections) and JSON text')\n ),\n add_missing: v.optional(\n v.pipe(v.boolean(), v.description('Add tokens that match no variable (default true)')),\n true\n ),\n styles: v.optional(\n v.pipe(v.boolean(), v.description('Make text and effect styles (default true)')),\n true\n )\n }),\n execute: async (figma, args) => {\n const tokens = await import('#core/io/formats/design-tokens')\n const bundle = tokens.readDesignTokens(args.files)\n const options = {\n ...tokens.defaultTokenImportOptions(figma.graph, bundle),\n addMissing: args.add_missing,\n styles: args.styles\n }\n const plan = tokens.planTokenImport(figma.graph, bundle, options)\n tokens.importTokensIntoGraph(figma.graph, figma.currentPageId, plan)\n return {\n ...plan.counts,\n collections: plan.collections.map((collection) => collection.name),\n skipped: plan.skipped,\n issues: bundle.issues\n }\n }\n})\n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GACR,aAAa,KAAK,YAAY,KAAK,eAAe,WAAW,IAAI;GACjE,SAAS,KAAK;GACd,QAAQ,OAAO;EACjB;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.d.ts","names":[],"sources":["../../src/tools/comments.ts"],"mappings":";;cAca,aAAA;
|
|
1
|
+
{"version":3,"file":"comments.d.ts","names":[],"sources":["../../src/tools/comments.ts"],"mappings":";;cAca,aAAA;cA8BA,YAAA;cA+BA,gBAAA;cAsBA,gBAAA"}
|
package/dist/tools/comments.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as v from "valibot";
|
|
|
6
6
|
const authorSchema = v.optional(v.pipe(v.string(), v.description(`Name shown as the author, such as your agent's name; "${DEFAULT_COMMENT_AUTHOR}" if omitted`)));
|
|
7
7
|
const getComments = defineTool({
|
|
8
8
|
name: "get_comments",
|
|
9
|
-
description: "Read the comments people left on the canvas, oldest first: each thread with its text, author, page, the layer it is pinned to, its position, replies, and whether it is resolved. Open threads only unless includeResolved is set. Use it to find review feedback to act on, then reply_to_comment and resolve_comment.",
|
|
9
|
+
description: "Read the comments people left on the canvas, oldest first: each thread with its text, author, page, the layer it is pinned to, its position, the marked area it was drawn around when it has one, replies, and whether it is resolved. Open threads only unless includeResolved is set. Use it to find review feedback to act on, then reply_to_comment and resolve_comment.",
|
|
10
10
|
execution: {
|
|
11
11
|
kind: "sync",
|
|
12
12
|
mutation: "none"
|
|
@@ -30,7 +30,7 @@ const getComments = defineTool({
|
|
|
30
30
|
});
|
|
31
31
|
const addComment = defineTool({
|
|
32
32
|
name: "add_comment",
|
|
33
|
-
description: "Leave a comment on the canvas, as a person does with the Comment tool: pinned on a layer by ID, which it then follows, or at x, y on a page. Text may use Markdown: **bold**, *italic*, ~~strikethrough~~, [links](https://…), and - or 1. lists.",
|
|
33
|
+
description: "Leave a comment on the canvas, as a person does with the Comment tool: pinned on a layer by ID, which it then follows, or at x, y on a page. A comment may carry a stroke the person drew around the area to change. Text may use Markdown: **bold**, *italic*, ~~strikethrough~~, [links](https://…), and - or 1. lists.",
|
|
34
34
|
execution: {
|
|
35
35
|
kind: "sync",
|
|
36
36
|
mutation: "document"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.js","names":[],"sources":["../../src/tools/comments.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { DEFAULT_COMMENT_AUTHOR, PairdrawAPI } from '#core/pairdraw-api'\nimport { defineTool, toolFailure } from '#core/tools/schema'\n\nconst authorSchema = v.optional(\n v.pipe(\n v.string(),\n v.description(\n `Name shown as the author, such as your agent's name; \"${DEFAULT_COMMENT_AUTHOR}\" if omitted`\n )\n )\n)\n\nexport const getComments = defineTool({\n name: 'get_comments',\n description:\n 'Read the comments people left on the canvas, oldest first: each thread with its text, ' +\n 'author, page, the layer it is pinned to, its position,
|
|
1
|
+
{"version":3,"file":"comments.js","names":[],"sources":["../../src/tools/comments.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { DEFAULT_COMMENT_AUTHOR, PairdrawAPI } from '#core/pairdraw-api'\nimport { defineTool, toolFailure } from '#core/tools/schema'\n\nconst authorSchema = v.optional(\n v.pipe(\n v.string(),\n v.description(\n `Name shown as the author, such as your agent's name; \"${DEFAULT_COMMENT_AUTHOR}\" if omitted`\n )\n )\n)\n\nexport const getComments = defineTool({\n name: 'get_comments',\n description:\n 'Read the comments people left on the canvas, oldest first: each thread with its text, ' +\n 'author, page, the layer it is pinned to, its position, the marked area it was drawn ' +\n 'around when it has one, replies, and whether it is resolved. Open threads only unless ' +\n 'includeResolved is set. Use it to find review feedback to act on, then reply_to_comment ' +\n 'and resolve_comment.',\n execution: { kind: 'sync', mutation: 'none' },\n input: v.strictObject({\n includeResolved: v.optional(v.pipe(v.boolean(), v.description('Also list resolved threads'))),\n page: v.optional(v.pipe(v.string(), v.description('Only threads on this page ID'))),\n author: v.optional(\n v.pipe(v.string(), v.description('Only threads this person started or replied to'))\n )\n }),\n execute: (figma, { includeResolved, page, author }) => {\n try {\n const comments = new PairdrawAPI(figma).getComments({\n resolved: includeResolved ? undefined : false,\n page,\n author\n })\n return { comments: comments.map((comment) => comment.toJSON()) }\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n\nexport const addComment = defineTool({\n name: 'add_comment',\n description:\n 'Leave a comment on the canvas, as a person does with the Comment tool: pinned on a layer ' +\n 'by ID, which it then follows, or at x, y on a page. A comment may carry a stroke the person ' +\n 'drew around the area to change. Text may use Markdown: **bold**, ' +\n '*italic*, ~~strikethrough~~, [links](https://…), and - or 1. lists.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n text: v.pipe(v.string(), v.minLength(1), v.description('The comment, in Markdown')),\n node: v.optional(v.pipe(v.string(), v.description('Layer ID to pin the comment on'))),\n page: v.optional(\n v.pipe(v.string(), v.description('Page ID without a layer; the current page if omitted'))\n ),\n x: v.optional(\n v.pipe(v.number(), v.description('Canvas X, or offset from the layer’s left edge'))\n ),\n y: v.optional(\n v.pipe(v.number(), v.description('Canvas Y, or offset from the layer’s top edge'))\n ),\n author: authorSchema\n }),\n execute: (figma, { text, ...options }) => {\n try {\n return new PairdrawAPI(figma).addComment(text, options).toJSON()\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n\nexport const replyToComment = defineTool({\n name: 'reply_to_comment',\n description:\n 'Answer a comment thread by ID from get_comments, for example to say what you changed. A ' +\n 'reply reopens a resolved thread. Text may use Markdown, as in add_comment.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Comment thread ID')),\n text: v.pipe(v.string(), v.minLength(1), v.description('The reply, in Markdown')),\n author: authorSchema\n }),\n execute: (figma, { id, text, author }) => {\n try {\n const comment = new PairdrawAPI(figma).getComment(id)\n if (!comment) return { error: `No comment ${id}` }\n return comment.reply(text, { author }).toJSON()\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n\nexport const resolveComment = defineTool({\n name: 'resolve_comment',\n description:\n 'Mark a comment thread by ID as resolved once its feedback is addressed, which hides it ' +\n 'from the canvas and the open list; pass resolved: false to reopen it.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Comment thread ID')),\n resolved: v.optional(\n v.pipe(v.boolean(), v.description('false reopens the thread; true by default'))\n )\n }),\n execute: (figma, { id, resolved = true }) => {\n try {\n const comment = new PairdrawAPI(figma).getComment(id)\n if (!comment) return { error: `No comment ${id}` }\n return (resolved ? comment.resolve() : comment.reopen()).toJSON()\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n"],"mappings":";;;;;AAKA,MAAM,eAAe,EAAE,SACrB,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YACA,yDAAyD,uBAAuB,aAClF,CACF,CACF;AAEA,MAAa,cAAc,WAAW;CACpC,MAAM;CACN,aACE;CAKF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAO;CAC5C,OAAO,EAAE,aAAa;EACpB,iBAAiB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,GAAG,EAAE,YAAY,4BAA4B,CAAC,CAAC;EAC5F,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,8BAA8B,CAAC,CAAC;EAClF,QAAQ,EAAE,SACR,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gDAAgD,CAAC,CACpF;CACF,CAAC;CACD,UAAU,OAAO,EAAE,iBAAiB,MAAM,aAAa;EACrD,IAAI;GAMF,OAAO,EAAE,UALQ,IAAI,YAAY,KAAK,CAAC,CAAC,YAAY;IAClD,UAAU,kBAAkB,KAAA,IAAY;IACxC;IACA;GACF,CAC0B,CAAC,CAAC,KAAK,YAAY,QAAQ,OAAO,CAAC,EAAE;EACjE,SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;CACF;AACF,CAAC;AAED,MAAa,aAAa,WAAW;CACnC,MAAM;CACN,aACE;CAIF,WAAW;EAAE,MAAM;E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SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;CACF;AACF,CAAC;AAED,MAAa,iBAAiB,WAAW;CACvC,MAAM;CACN,aACE;CAEF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,mBAAmB,CAAC;EACzD,UAAU,EAAE,SACV,EAAE,KAAK,EAAE,QAAQ,GAAG,EAAE,YAAY,2CAA2C,CAAC,CAChF;CACF,CAAC;CACD,UAAU,OAAO,EAAE,IAAI,WAAW,WAAW;EAC3C,IAAI;GACF,MAAM,UAAU,IAAI,YAAY,KAAK,CAAC,CAAC,WAAW,EAAE;GACpD,IAAI,CAAC,SAAS,OAAO,EAAE,OAAO,cAAc,KAAK;GACjD,QAAQ,WAAW,QAAQ,QAAQ,IAAI,QAAQ,OAAO,EAAA,CAAG,OAAO;EAClE,SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-catalog.d.ts","names":[],"sources":["../../src/tools/component-catalog.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"component-catalog.d.ts","names":[],"sources":["../../src/tools/component-catalog.ts"],"mappings":";;;KAGY;UAEK;EACf;EACA;EACA;EACA;EACA;EACA,OAAO;;UAGQ;EACf;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB;;UAGD;EACf,iBAAiB,QAAQ;EACzB,eAAe;IACb;IACA;IACA;MACE,QAAQ;EACZ,gBAAgB,OAAO,8BAA8B;IAAU;IAAY;;;iBAK7D,yBAAyB,eAAe,SAAS;iBAQjD,oBAAoB,gBAAgB"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { underlyingGraph } from "../figma-api/graph-ref.js";
|
|
1
2
|
//#region src/tools/component-catalog.ts
|
|
2
3
|
const catalogs = /* @__PURE__ */ new WeakMap();
|
|
3
4
|
function registerComponentCatalog(owner, catalog) {
|
|
4
|
-
|
|
5
|
+
const target = underlyingGraph(owner);
|
|
6
|
+
catalogs.set(target, catalog);
|
|
5
7
|
return () => {
|
|
6
|
-
if (catalogs.get(
|
|
8
|
+
if (catalogs.get(target) === catalog) catalogs.delete(target);
|
|
7
9
|
};
|
|
8
10
|
}
|
|
9
11
|
function getComponentCatalog(owner) {
|
|
10
|
-
return catalogs.get(owner);
|
|
12
|
+
return catalogs.get(underlyingGraph(owner));
|
|
11
13
|
}
|
|
12
14
|
//#endregion
|
|
13
15
|
export { getComponentCatalog, registerComponentCatalog };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-catalog.js","names":[],"sources":["../../src/tools/component-catalog.ts"],"sourcesContent":["import type { LibraryAssetDescriptor, LibrarySummary } from '#core/library'\n\nexport type ComponentCatalogSource = 'document' | 'libraries' | 'all'\n\nexport interface ComponentCatalogLibraryAsset {\n libraryId: string\n libraryName: string\n revisionId: string\n enabled: boolean\n priority: number\n asset: LibraryAssetDescriptor\n}\n\nexport interface ComponentCatalogInsertInput {\n libraryId: string\n revisionId?: string\n assetKey: string\n parentId?: string\n x?: number\n y?: number\n variantValues?: Record<string, string>\n}\n\nexport interface ComponentCatalog {\n listLibraries(): Promise<LibrarySummary[]>\n listComponents(input: {\n name?: string\n libraryId?: string\n enabledOnly?: boolean\n }): Promise<ComponentCatalogLibraryAsset[]>\n insertComponent(input: ComponentCatalogInsertInput): Promise<{ id: string; componentId: string }>\n}\n\nconst catalogs = new WeakMap<object, ComponentCatalog>()\n\nexport function registerComponentCatalog(owner: object, catalog: ComponentCatalog): () => void {\n catalogs.set(
|
|
1
|
+
{"version":3,"file":"component-catalog.js","names":[],"sources":["../../src/tools/component-catalog.ts"],"sourcesContent":["import { underlyingGraph } from '#core/figma-api/graph-ref'\nimport type { LibraryAssetDescriptor, LibrarySummary } from '#core/library'\n\nexport type ComponentCatalogSource = 'document' | 'libraries' | 'all'\n\nexport interface ComponentCatalogLibraryAsset {\n libraryId: string\n libraryName: string\n revisionId: string\n enabled: boolean\n priority: number\n asset: LibraryAssetDescriptor\n}\n\nexport interface ComponentCatalogInsertInput {\n libraryId: string\n revisionId?: string\n assetKey: string\n parentId?: string\n x?: number\n y?: number\n variantValues?: Record<string, string>\n}\n\nexport interface ComponentCatalog {\n listLibraries(): Promise<LibrarySummary[]>\n listComponents(input: {\n name?: string\n libraryId?: string\n enabledOnly?: boolean\n }): Promise<ComponentCatalogLibraryAsset[]>\n insertComponent(input: ComponentCatalogInsertInput): Promise<{ id: string; componentId: string }>\n}\n\nconst catalogs = new WeakMap<object, ComponentCatalog>()\n\nexport function registerComponentCatalog(owner: object, catalog: ComponentCatalog): () => void {\n const target = underlyingGraph(owner)\n catalogs.set(target, catalog)\n return () => {\n if (catalogs.get(target) === catalog) catalogs.delete(target)\n }\n}\n\nexport function getComponentCatalog(owner: object): ComponentCatalog | undefined {\n return catalogs.get(underlyingGraph(owner))\n}\n"],"mappings":";;AAkCA,MAAM,2BAAW,IAAI,QAAkC;AAEvD,SAAgB,yBAAyB,OAAe,SAAuC;CAC7F,MAAM,SAAS,gBAAgB,KAAK;CACpC,SAAS,IAAI,QAAQ,OAAO;CAC5B,aAAa;EACX,IAAI,SAAS,IAAI,MAAM,MAAM,SAAS,SAAS,OAAO,MAAM;CAC9D;AACF;AAEA,SAAgB,oBAAoB,OAA6C;CAC/E,OAAO,SAAS,IAAI,gBAAgB,KAAK,CAAC;AAC5C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
2
1
|
import { defineTool, nodeSummary, positionInputs, toolNumber } from "../schema.js";
|
|
2
|
+
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
//#region src/tools/create/basic.ts
|
|
5
5
|
const createShape = defineTool({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeSlotSettings } from "../../figma-api/slots.js";
|
|
2
1
|
import { defineTool, toolFailure, toolNumber } from "../schema.js";
|
|
2
|
+
import { mergeSlotSettings } from "../../figma-api/slots.js";
|
|
3
3
|
import { PairdrawAPI } from "../../pairdraw-api/index.js";
|
|
4
4
|
import { slotOwner, slotPropertyId, updateSlotProperty } from "@pairdraw/scene-graph/slots";
|
|
5
5
|
import { behaviourSpecSchema } from "@pairdraw/scene-graph/behaviours";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/tools/create/html.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/tools/create/html.ts"],"mappings":";;cAca,YAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { findPageId } from "../../io/subgraph.js";
|
|
2
2
|
import { layoutAuthoredNodes } from "../../layout.js";
|
|
3
3
|
import { sceneGraphFromStyledHTML } from "../../io/formats/html/layers.js";
|
|
4
|
-
import { flushPendingLayout } from "../../figma-api/pending-layout.js";
|
|
5
|
-
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
6
4
|
import { defineTool, toolFailure, toolNumber } from "../schema.js";
|
|
7
5
|
import { spaceBesideContent } from "../read/space.js";
|
|
6
|
+
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
8
7
|
import { getHTMLToolHost } from "../html-host.js";
|
|
9
8
|
import { getAxisAlignedBoundsInParent } from "@pairdraw/scene-graph/coordinate";
|
|
10
9
|
import * as v from "valibot";
|
|
@@ -53,7 +52,6 @@ const importHTML = defineTool({
|
|
|
53
52
|
y: args.y ?? 0
|
|
54
53
|
};
|
|
55
54
|
if (args.x === void 0 || args.y === void 0) {
|
|
56
|
-
flushPendingLayout(graph);
|
|
57
55
|
const beside = spaceBesideContent(graph, parentId, bounds);
|
|
58
56
|
topLeft = {
|
|
59
57
|
x: args.x ?? beside.x,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":[],"sources":["../../../src/tools/create/html.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { getAxisAlignedBoundsInParent } from '@pairdraw/scene-graph/coordinate'\nimport { applyGraphTransfer, prepareGraphTransfer } from '@pairdraw/scene-graph/transfer'\n\nimport {
|
|
1
|
+
{"version":3,"file":"html.js","names":[],"sources":["../../../src/tools/create/html.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { getAxisAlignedBoundsInParent } from '@pairdraw/scene-graph/coordinate'\nimport { applyGraphTransfer, prepareGraphTransfer } from '@pairdraw/scene-graph/transfer'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { sceneGraphFromStyledHTML } from '#core/io/formats/html/layers'\nimport { findPageId } from '#core/io/subgraph'\nimport { layoutAuthoredNodes } from '#core/layout'\nimport { getHTMLToolHost } from '#core/tools/html-host'\nimport { spaceBesideContent } from '#core/tools/read/space'\nimport { defineTool, toolFailure, toolNumber } from '#core/tools/schema'\n\nexport const importHTML = defineTool({\n name: 'import_html',\n description:\n 'Import HTML and CSS as editable layers in the open document, styled as a browser styles them: flex and grid become auto layout, and text, fills, borders, radii, shadows, and images carry over. <style> blocks in the HTML apply; css adds a stylesheet; tailwind compiles the Tailwind classes the markup uses. Without x and y the layers go to the right of what the parent already holds. Returns the ids of the top-level layers.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n input: v.strictObject({\n html: v.pipe(\n v.string(),\n v.nonEmpty(),\n v.description('HTML markup: a fragment or a whole document with <style> blocks')\n ),\n css: v.optional(v.pipe(v.string(), v.description('Extra CSS applied after the HTML’s own'))),\n tailwind: v.optional(\n v.pipe(v.boolean(), v.description('Compile the Tailwind utility classes the markup uses')),\n false\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID (default: the page)'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X of the imported content')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y of the imported content'))))\n }),\n execute: async (figma, args) => {\n const graph = figma.graph\n const parentId = args.parent_id ?? figma.currentPage.id\n prepareSlotInsertion(graph, parentId, 'import_html')\n const host = getHTMLToolHost(graph)\n if (!host) {\n return { error: 'import_html needs a CSS runtime, which this environment does not provide' }\n }\n const parent = graph.getNode(parentId)\n if (!parent || (parent.type !== 'CANVAS' && !findPageId(graph, parentId))) {\n return { error: `Parent \"${parentId}\" not found` }\n }\n let source: SceneGraph\n try {\n const styled = await host.style(args.html, {\n cssText: args.css,\n tailwind: args.tailwind\n })\n source = sceneGraphFromStyledHTML(styled)\n } catch (error) {\n return toolFailure(error)\n }\n const page = source.getPages().at(0)\n const roots = page ? page.childIds.flatMap((id) => source.getNode(id) ?? []) : []\n if (!page || roots.length === 0) return { error: 'The HTML has no content to import' }\n const bounds = getAxisAlignedBoundsInParent(roots, page.id, source)\n let topLeft = { x: args.x ?? 0, y: args.y ?? 0 }\n if (args.x === undefined || args.y === undefined) {\n const beside = spaceBesideContent(graph, parentId, bounds)\n topLeft = { x: args.x ?? beside.x, y: args.y ?? beside.y }\n }\n const plan = prepareGraphTransfer({\n source,\n rootIds: roots.map((root) => root.id),\n dependencyPageIds: [],\n target: graph,\n parentId\n })\n const rootIds = new Set(plan.rootIds)\n for (const node of plan.nodes) {\n if (!rootIds.has(node.id)) continue\n node.props.x = (node.props.x ?? 0) - bounds.x + topLeft.x\n node.props.y = (node.props.y ?? 0) - bounds.y + topLeft.y\n }\n applyGraphTransfer(graph, plan)\n layoutAuthoredNodes(graph, plan.rootIds)\n const layers = plan.rootIds.flatMap((id) => {\n const node = graph.getNode(id)\n return node ? [{ id: node.id, name: node.name, type: node.type }] : []\n })\n return {\n ids: layers.map((layer) => layer.id),\n layers,\n x: topLeft.x,\n y: topLeft.y,\n width: bounds.width,\n height: bounds.height\n }\n }\n})\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,aAAa,WAAW;CACn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Q;GACX,GAAG,QAAQ;GACX,OAAO,OAAO;GACd,QAAQ,OAAO;EACjB;CACF;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { placeIcon } from "../../icons/render.js";
|
|
2
|
-
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
3
2
|
import { defineTool, parseToolColor, toolNumber } from "../schema.js";
|
|
3
|
+
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
4
4
|
import { iconOptionsSchema } from "@pairdraw/scene-graph/icons";
|
|
5
5
|
import * as v from "valibot";
|
|
6
6
|
//#region src/tools/create/icons.ts
|
|
@@ -77,7 +77,7 @@ const insertIcon = defineTool({
|
|
|
77
77
|
const names = args.names ?? (args.name ? [args.name] : []);
|
|
78
78
|
if (names.length === 0) return { error: "Provide \"names\" (array) or \"name\" (string)" };
|
|
79
79
|
const size = args.size ?? 24;
|
|
80
|
-
const parsedColor = parseToolColor(args.color ?? "#000000");
|
|
80
|
+
const parsedColor = parseToolColor(args.color ?? "#000000", figma.graph.documentColorSpace);
|
|
81
81
|
if ("error" in parsedColor) return parsedColor;
|
|
82
82
|
const options = iconOptions(args);
|
|
83
83
|
let icons;
|