@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#fetch","#onPageChange","#onViewportChange","#onSelectionChange","#pageSwitch","#pageChange","images.createImage","images.imageByHash","images.fetchImage"],"sources":["../../src/figma-api/index.ts"],"sourcesContent":["import { fromUint8Array, isValid, toUint8Array } from 'js-base64'\n\nimport type { SceneGraph, SceneNode as CoreSceneNode, NodeType } from '@pairdraw/scene-graph'\nimport { createConnector, freeEndpoint } from '@pairdraw/scene-graph/connectors'\nimport { computeBounds } from '@pairdraw/scene-graph/geometry'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport type { SkiaRenderer } from '#core/canvas'\nimport { groupFitOptions } from '#core/canvas/boolean'\nimport { IS_BROWSER, type InterfaceTheme } from '#core/constants'\nimport { newLayerDefaults } from '#core/editor/shapes/defaults'\nimport { booleanOperationPaints, createBooleanOperation } from '#core/editor/structure/boolean'\nimport { wrapNodes } from '#core/editor/structure/container-wrap'\nimport { ungroupNode } from '#core/editor/structure/group/ungroup'\nimport { setDefaultPageBackground } from '#core/figma-api/page-backgrounds'\nimport { defaultIcons, type IconProvider } from '#core/icons'\nimport type { RasterCodec } from '#core/io/formats/raster'\nimport { createSVGNodes } from '#core/io/formats/svg'\nimport { textAutoResizeChanges } from '#core/layout/text-auto-resize'\nimport { fontManager } from '#core/text/font/manager'\n\nimport { componentFromNode } from './components'\nimport { flattenSceneNodes } from './flatten'\nimport { listFigmaFonts } from './fonts/list'\nimport { loadFigmaFont } from './fonts/load'\nimport type { FigmaFontNameInput } from './fonts/names'\nimport { variationAxisTags } from './fonts/variations'\nimport * as images from './images'\nimport type {\n FigmaBooleanOperationNode,\n FigmaComponentNode,\n FigmaComponentSetNode,\n FigmaConnectorNode,\n FigmaEllipseNode,\n FigmaFrameNode,\n FigmaGroupNode,\n FigmaLineNode,\n FigmaPolygonNode,\n FigmaRectangleNode,\n FigmaSectionNode,\n FigmaShapeWithTextNode,\n FigmaStarNode,\n FigmaTextNode,\n FigmaVectorNode\n} from './node-types'\nimport { startPendingLayout } from './pending-layout'\nimport { flushPendingComponentSync, startPendingComponentSync } from './pending-sync'\nimport {\n FigmaNodeProxy,\n INTERNAL_ID,\n loadPage,\n MIXED,\n pageOfNode,\n setPageHost,\n type FigmaFont,\n type NodeProxyHost\n} from './proxy'\nimport { newShapeWithText } from './shape-with-text'\nimport type { ExportImageOptions } from './types'\nimport { figmaUtil } from './util'\nimport { FigmaVariablesAPI } from './variables'\nimport { combineComponentsAsVariants } from './variants'\n\nconst noop = () => undefined\n\n/** A view of the document: its centre point and its zoom. */\nexport interface FigmaViewport {\n center: Vector\n zoom: number\n}\n\n/** What a host passes to `FigmaAPI` beyond the document. */\nexport interface FigmaAPIOptions {\n /** Fetches the HTTP(S) URLs `figma.createImageAsync` loads; the global `fetch` by default. */\n fetch?: images.ImageFetch\n /**\n * Loads a page's layers, for a host that loads pages as they are visited, as the editor does a\n * file it opens: `page.loadAsync`, `figma.loadAllPagesAsync`, and `setCurrentPageAsync` call\n * it, as they load pages in Figma's dynamic-page mode. Without one every page is in memory.\n */\n loadPage?: (pageId: string) => Promise<void>\n /** The page holding a layer not loaded yet, which `getNodeByIdAsync` loads to find it. */\n pageOfNode?: (nodeId: string) => Promise<string | null>\n /**\n * Runs when a script puts the API on another page, so a host can show that page too. The host\n * owns which page is on screen, and a plugin that switches page expects to see it switched.\n */\n onPageChange?: (pageId: string) => void | Promise<void>\n /**\n * Runs when a script moves the viewport, so a host can show the same view. A host owns the\n * viewport on screen, and a plugin that pans or zooms expects to see the result.\n */\n onViewportChange?: (viewport: FigmaViewport) => void\n /**\n * The page the host already shows. Seeded here rather than assigned after construction, so a\n * plain tool call does not ask the host to switch to the page it is already on.\n */\n pageId?: string\n /**\n * The view the host already shows, seeded for the same reason: a tool that only reads or draws\n * must not move the viewport of whoever is looking at the document.\n */\n viewport?: FigmaViewport\n /**\n * Runs when a script sets the page selection, so a host can select those layers too. The host\n * owns which layers are selected on screen, and a plugin that selects expects to see them selected.\n */\n onSelectionChange?: (ids: readonly string[], pageId: string) => void\n /**\n * The selection the host already shows, seeded for the same reason as the page and the viewport:\n * a tool that only reads must not reselect what is already selected.\n */\n selection?: readonly string[]\n /**\n * Brings instances in line with the component edits made so far, for a host that syncs them\n * after edits itself, as the editor does; reading a layer calls it first. Without one the API\n * records edits and syncs their instances itself.\n */\n flushComponentSync?: () => void\n}\n\nexport { FigmaNodeProxy } from './proxy'\nexport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nexport { flushPendingLayout } from './pending-layout'\nexport { flushPendingComponentSync } from './pending-sync'\nexport type { FigmaEffect } from './effects'\nexport type { ExportImageOptions } from './types'\nexport {\n ImageTooLargeError,\n MAX_IMAGE_FETCH_BYTES,\n readBoundedImage,\n type ImageFetch\n} from './images'\nexport {\n FigmaVariable,\n FigmaVariableCollection,\n FigmaVariablesAPI,\n type FigmaComposedColor,\n type FigmaVariableAlias,\n type FigmaVariableValue\n} from './variables'\nexport type {\n FigmaBooleanOperationNode,\n FigmaComponentNode,\n FigmaComponentSetNode,\n FigmaConnectorNode,\n FigmaEllipseNode,\n FigmaFrameNode,\n FigmaGroupNode,\n FigmaInstanceNode,\n FigmaLineNode,\n FigmaPolygonNode,\n FigmaRectangleNode,\n FigmaSectionNode,\n FigmaShapeWithTextNode,\n FigmaSlotNode,\n FigmaStarNode,\n FigmaTextNode,\n FigmaVectorNode\n} from './node-types'\nexport type { FigmaFont, FigmaFontName } from './proxy'\nexport type { FigmaFontNameInput } from './fonts/names'\nexport type { FigmaVariationSettings } from './fonts/variations'\n\n// TODO(figma-api): Implement the full official PluginAPI interface once our compatibility\n// layer covers all required node-specific return types and unsupported APIs are modeled explicitly.\n/** What a plugin keeps in `figma.clientStorage`: JSON values, copied in and out. */\nconst clientStorageValues = new Map<string, unknown>()\n\nconst clientStorage: ClientStorageAPI = {\n async getAsync(key: string): Promise<unknown> {\n const value = clientStorageValues.get(key)\n return value === undefined ? undefined : structuredClone(value)\n },\n async setAsync(key: string, value: unknown): Promise<void> {\n clientStorageValues.set(key, structuredClone(value))\n },\n async deleteAsync(key: string): Promise<void> {\n clientStorageValues.delete(key)\n },\n async keysAsync(): Promise<string[]> {\n return [...clientStorageValues.keys()]\n }\n}\n\nexport class FigmaAPI implements NodeProxyHost {\n readonly graph: SceneGraph\n private _currentPageId: string\n private _selection: FigmaNodeProxy[] = []\n private _nodeCache = new Map<string, FigmaNodeProxy>()\n private _pageProxies = new WeakSet<FigmaNodeProxy>()\n private _renderer: SkiaRenderer | null = null\n /** The interface theme new sections take their fill from, as in Figma. */\n theme: InterfaceTheme = 'light'\n\n readonly mixed = MIXED\n /** Figma's color and Markdown helpers, as `figma.util`. */\n readonly util: UtilAPI = figmaUtil\n /** The document's variables and collections, as Figma's `figma.variables`. */\n readonly variables: FigmaVariablesAPI\n /** Values a plugin keeps for its next run, as Figma's `figma.clientStorage`. */\n readonly clientStorage: ClientStorageAPI = clientStorage\n\n /** How `createImageAsync` fetches HTTP(S) URLs; a host passes one that gets past CORS. */\n readonly #fetch: images.ImageFetch\n readonly #onPageChange: ((pageId: string) => void | Promise<void>) | undefined\n readonly #onViewportChange: ((viewport: FigmaViewport) => void) | undefined\n readonly #onSelectionChange: ((ids: readonly string[], pageId: string) => void) | undefined\n /** The last host page switch, so `setCurrentPageAsync` can wait for it. */\n #pageChange: Promise<void> = Promise.resolve()\n /** Counts page switches, so a switch whose page loads after a later one does not undo it. */\n #pageSwitch = 0\n\n constructor(graph: SceneGraph, options: FigmaAPIOptions = {}) {\n this.graph = graph\n this.#fetch = options.fetch ?? ((input, init) => fetch(input, init))\n if (options.loadPage)\n setPageHost(this, { load: options.loadPage, pageOfNode: options.pageOfNode })\n this.#onPageChange = options.onPageChange\n this.#onViewportChange = options.onViewportChange\n this.#onSelectionChange = options.onSelectionChange\n this.variables = new FigmaVariablesAPI(graph)\n startPendingLayout(graph)\n startPendingComponentSync(graph, options.flushComponentSync)\n this._currentPageId = pageIdToStart(graph, options.pageId)\n if (options.viewport) {\n this._viewport = {\n x: options.viewport.center.x,\n y: options.viewport.center.y,\n zoom: options.viewport.zoom\n }\n }\n // Seeded here, not assigned through the setter, so a tool that only reads does not ask the\n // host to select the layers it is already showing.\n this._selection = (options.selection ?? []).flatMap((id) =>\n this.graph.getNode(id) ? [this.wrapNode(id)] : []\n )\n }\n\n setRenderer(renderer: SkiaRenderer | null): void {\n this._renderer = renderer\n }\n\n get groupFitOptions(): GroupFitOptions {\n return groupFitOptions(this._renderer, this.graph)\n }\n\n get currentPageId(): string {\n return this._currentPageId\n }\n\n wrapNode(id: string): FigmaNodeProxy {\n let proxy = this._nodeCache.get(id)\n if (!proxy) {\n proxy = new FigmaNodeProxy(id, this.graph, this)\n this._nodeCache.set(id, proxy)\n }\n return proxy\n }\n\n private _ensurePageProxy(\n proxy: FigmaNodeProxy\n ): FigmaNodeProxy & { selection: FigmaNodeProxy[] } {\n if (!this._pageProxies.has(proxy)) {\n Object.defineProperty(proxy, 'selection', {\n get: () => this._selection,\n set: (nodes: FigmaNodeProxy[]) => {\n const next = nodes.map((node) => node[INTERNAL_ID])\n const current = this._selection.map((node) => node[INTERNAL_ID])\n this._selection = nodes\n if (next.length === current.length && next.every((id, index) => id === current[index]))\n return\n this.#onSelectionChange?.(next, this._currentPageId)\n },\n enumerable: true,\n configurable: true\n })\n this._pageProxies.add(proxy)\n }\n return proxy as FigmaNodeProxy & { selection: FigmaNodeProxy[] }\n }\n\n get root(): FigmaNodeProxy {\n return this.wrapNode(this.graph.rootId)\n }\n\n get currentPage(): FigmaNodeProxy & { selection: FigmaNodeProxy[] } {\n return this._ensurePageProxy(this.wrapNode(this._currentPageId))\n }\n\n set currentPage(page: FigmaNodeProxy) {\n const pageId = page[INTERNAL_ID]\n this.#pageSwitch++\n if (pageId === this._currentPageId) return\n this._currentPageId = pageId\n this.#pageChange = Promise.resolve(this.#onPageChange?.(pageId))\n }\n\n getNodeById(id: string): FigmaNodeProxy | null {\n flushPendingComponentSync(this.graph)\n const node = this.graph.getNode(id)\n return node ? this.wrapNode(id) : null\n }\n\n /** As in Figma's dynamic-page mode, a layer on a page not loaded yet loads that page. */\n async getNodeByIdAsync(id: string): Promise<FigmaNodeProxy | null> {\n const node = this.getNodeById(id)\n // A page asked for by id is its own holder, and one whose layers are not in yet loads first.\n const unloadedPage = node?.type === 'CANVAS' && this.graph.getChildren(id).length === 0\n if (node && !unloadedPage) return node\n const pageId = node\n ? id\n : ((await pageOfNode(this, id)) ??\n (this.graph.getPages().some((page) => page.id === id) ? id : null))\n if (!pageId) return null\n await loadPage(this, pageId)\n return this.getNodeById(id) ?? node\n }\n\n /**\n * The page switch Figma requires in dynamic-page mode, which sets `currentPage`. As in Figma, a\n * missing node throws at once and a node that is no page rejects.\n */\n setCurrentPageAsync(page: FigmaNodeProxy): Promise<void>\n setCurrentPageAsync(page: PageNode): Promise<void>\n // Scripts are not type-checked, so the call checks for a missing node as Figma does.\n setCurrentPageAsync(page: PageNode | FigmaNodeProxy | null | undefined): Promise<void> {\n if (page == null) throw new Error(`in setCurrentPageAsync: Expected node, got ${String(page)}`)\n if (this._rawNode(page).type !== 'CANVAS') {\n return Promise.reject(new Error('figma.setCurrentPageAsync expects a PageNode'))\n }\n const pageId = this._nodeId(page)\n const pageSwitch = ++this.#pageSwitch\n return loadPage(this, pageId).then(() => {\n if (pageSwitch !== this.#pageSwitch) return undefined\n if (this.graph.getNode(pageId)?.type !== 'CANVAS')\n throw new Error('in setCurrentPageAsync: The page was removed while it loaded')\n this._currentPageId = pageId\n this.#pageChange = Promise.resolve(this.#onPageChange?.(pageId))\n return this.#pageChange\n })\n }\n\n // --- Node Creation ---\n\n /** New layers start as the editor's tools make them, which is how Figma's plugin API makes them. */\n private _createNode(type: NodeType): FigmaNodeProxy {\n const defaults = newLayerDefaults(type, this.theme)\n // Figma's plugin API makes a line with no height, a 496 px section, and a hugging frame.\n if (type === 'LINE') defaults.height = 0\n if (type === 'SECTION') Object.assign(defaults, { width: 496, height: 496 })\n if (type === 'FRAME' || type === 'COMPONENT') defaults.primaryAxisSizing = 'HUG'\n const node = this.graph.createNode(type, this._currentPageId, defaults)\n return this.wrapNode(node.id)\n }\n\n createFrame(): FigmaFrameNode {\n return this._createNode('FRAME') as FigmaFrameNode\n }\n\n createRectangle(): FigmaRectangleNode {\n return this._createNode('RECTANGLE') as FigmaRectangleNode\n }\n\n createEllipse(): FigmaEllipseNode {\n return this._createNode('ELLIPSE') as FigmaEllipseNode\n }\n\n createText(): FigmaTextNode {\n const text = this._createNode('TEXT') as FigmaTextNode\n // Figma's plugin text starts empty at 12px and sizes itself to its content: no width, one\n // line tall.\n const node = this.graph.getNode(text.id)\n const defaults = { fontSize: 12, textAutoResize: 'WIDTH_AND_HEIGHT' as const, width: 0 }\n this.graph.updateNode(text.id, { ...defaults, ...textAutoResizeChanges(node, defaults) })\n return text\n }\n\n createLine(): FigmaLineNode {\n return this._createNode('LINE') as FigmaLineNode\n }\n\n createPolygon(): FigmaPolygonNode {\n return this._createNode('POLYGON') as FigmaPolygonNode\n }\n\n createStar(): FigmaStarNode {\n return this._createNode('STAR') as FigmaStarNode\n }\n\n createShapeWithText(): FigmaShapeWithTextNode {\n return this.wrapNode(newShapeWithText(this).id) as FigmaShapeWithTextNode\n }\n\n createVector(): FigmaVectorNode {\n return this._createNode('VECTOR') as FigmaVectorNode\n }\n\n /** The layers Figma makes from SVG markup, on the current page at its origin. */\n // eslint-disable-next-line pairdraw/no-mixed-case-acronym-identifiers -- Figma Plugin API name.\n createNodeFromSvg(svg: string): FigmaFrameNode {\n const node = createSVGNodes(this.graph, this._currentPageId, svg, { keepEmpty: true })\n if (!node) throw new Error('in createNodeFromSvg: Failed to convert SVG file')\n return this.wrapNode(node.id) as FigmaFrameNode\n }\n\n /**\n * A connector as Figma's plugin API makes one: \"Connector line\", free from the page origin to\n * 200 px right of it, with no start cap and an arrow at the end.\n */\n createConnector(): FigmaConnectorNode {\n const node = createConnector(this.graph, this._currentPageId, {\n start: freeEndpoint(0, 0),\n end: freeEndpoint(200, 0),\n startCap: 'NONE',\n endCap: 'ARROW_LINES'\n })\n return this.wrapNode(node.id) as FigmaConnectorNode\n }\n\n createComponent(): FigmaComponentNode {\n return this._createNode('COMPONENT') as FigmaComponentNode\n }\n\n createSection(): FigmaSectionNode {\n return this._createNode('SECTION') as FigmaSectionNode\n }\n\n createPage(): FigmaNodeProxy {\n const page = this.graph.addPage('Page')\n setDefaultPageBackground(this.graph, page, this.theme)\n return this.wrapNode(page.id)\n }\n\n // --- Grouping ---\n\n private _nodeId(node: BaseNode | FigmaNodeProxy): string {\n return (node as BaseNode & { [INTERNAL_ID]: string })[INTERNAL_ID]\n }\n\n private _rawNode(node: BaseNode | FigmaNodeProxy): CoreSceneNode {\n const id = this._nodeId(node)\n const raw = this.graph.getNode(id)\n if (!raw) throw new Error(`Node ${id} not found`)\n return raw\n }\n\n group(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaGroupNode\n group(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): GroupNode\n group(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaGroupNode {\n const parentId = this._nodeId(parent)\n const members = nodes.map((node) => this._rawNode(node))\n const groupNode = wrapNodes(this.graph, 'GROUP', members, parentId, index)\n return this.wrapNode(groupNode.id) as FigmaGroupNode\n }\n\n ungroup(node: FigmaNodeProxy): FigmaNodeProxy[]\n ungroup(node: SceneNode & ChildrenMixin): Array<SceneNode>\n ungroup(node: (SceneNode & ChildrenMixin) | FigmaNodeProxy): Array<SceneNode> | FigmaNodeProxy[] {\n const children = ungroupNode(this.graph, this._nodeId(node)) ?? []\n return children.map((id) => this.wrapNode(id))\n }\n\n createComponentFromNode(node: FigmaNodeProxy): FigmaNodeProxy {\n const raw = this.graph.getNode(node[INTERNAL_ID])\n if (!raw) throw new Error('Node not found')\n return this.wrapNode(componentFromNode(this.graph, raw, raw.parentId ?? this._currentPageId).id)\n }\n\n combineAsVariants(\n nodes: ReadonlyArray<FigmaComponentNode>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaComponentSetNode\n combineAsVariants(\n nodes: ReadonlyArray<ComponentNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): ComponentSetNode\n combineAsVariants(\n nodes: ReadonlyArray<ComponentNode | FigmaComponentNode>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaComponentSetNode {\n const componentSet = combineComponentsAsVariants(\n this.graph,\n nodes.map((node) => this._nodeId(node)),\n this._nodeId(parent),\n index\n )\n return this.wrapNode(componentSet.id) as FigmaComponentSetNode\n }\n\n // --- Boolean Operations ---\n\n private _booleanOperation(\n operation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE',\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n if (nodes.length < 2) throw new Error('Need at least 2 nodes for boolean operation')\n const parentId = this._nodeId(parent)\n const members = nodes.map((node) => this._rawNode(node))\n const { node: group } = createBooleanOperation(\n this.graph,\n members,\n parentId,\n operation,\n index,\n booleanOperationPaints(operation, members, 'script'),\n this.groupFitOptions\n )\n return this.wrapNode(group.id) as FigmaBooleanOperationNode\n }\n\n union(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n union(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n union(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('UNION', nodes, parent, index)\n }\n\n subtract(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n subtract(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n subtract(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('SUBTRACT', nodes, parent, index)\n }\n\n intersect(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n intersect(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n intersect(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('INTERSECT', nodes, parent, index)\n }\n\n exclude(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n exclude(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n exclude(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('EXCLUDE', nodes, parent, index)\n }\n\n // --- Flatten ---\n\n flatten(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent?: FigmaNodeProxy,\n index?: number\n ): FigmaVectorNode\n flatten(\n nodes: ReadonlyArray<BaseNode>,\n parent?: BaseNode & ChildrenMixin,\n index?: number\n ): VectorNode\n flatten(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent?: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaVectorNode {\n if (nodes.length === 0) throw new Error('Need at least 1 node to flatten')\n const parentId = this._nodeId(parent ?? this.currentPage)\n const sourceNodes: CoreSceneNode[] = []\n for (const node of nodes) {\n const raw = this.graph.getNode(this._nodeId(node))\n if (!raw) throw new Error('Node not found')\n sourceNodes.push(raw)\n }\n const vector = flattenSceneNodes(this.graph, this._renderer, sourceNodes, parentId)\n if (index != null) this.graph.insertChildAt(vector.id, parentId, index)\n for (const node of nodes) {\n this.graph.deleteNode(this._nodeId(node))\n }\n return this.wrapNode(vector.id) as FigmaVectorNode\n }\n\n // --- Viewport ---\n\n private _viewport = { x: 0, y: 0, zoom: 1 }\n\n get viewport(): FigmaViewport & {\n scrollAndZoomIntoView: (nodes: readonly { absoluteBoundingBox: Rect }[]) => void\n } {\n return {\n center: { x: this._viewport.x, y: this._viewport.y },\n zoom: this._viewport.zoom,\n scrollAndZoomIntoView: (nodes) => {\n const b = computeBounds(nodes.map((n) => n.absoluteBoundingBox))\n if (b.width === 0 && b.height === 0 && nodes.length === 0) return\n\n const padding = 80\n const contentW = b.width + padding * 2\n const contentH = b.height + padding * 2\n const viewW = IS_BROWSER ? window.innerWidth : 1280\n const viewH = IS_BROWSER ? window.innerHeight : 720\n const zoom = Math.min(viewW / contentW, viewH / contentH, 1)\n // A script scrolling to its own result must not move the view someone else is looking at:\n // only `viewport` and a page switch do that.\n this._viewport = { x: b.x + b.width / 2, y: b.y + b.height / 2, zoom }\n }\n }\n }\n\n set viewport(v: FigmaViewport) {\n this._showViewport({ x: v.center.x, y: v.center.y, zoom: v.zoom })\n }\n\n /**\n * Moves the viewport and puts the host on the same view. A tool that scrolls nodes into view\n * does not call this: only a viewport a writer asks for moves the view of whoever is looking.\n */\n private _showViewport(next: { x: number; y: number; zoom: number }): void {\n const current = this._viewport\n this._viewport = next\n if (current.x === next.x && current.y === next.y && current.zoom === next.zoom) return\n this.#onViewportChange?.({ center: { x: next.x, y: next.y }, zoom: next.zoom })\n }\n\n createImage(data: Uint8Array): Image {\n return images.createImage(this.graph, data)\n }\n\n getImageByHash(hash: string): Image | null {\n return images.imageByHash(this.graph, hash)\n }\n\n /** Fetches the image at `src` through the host's `fetch` and stores it as `createImage` does. */\n createImageAsync(src: string): Promise<Image> {\n return images.fetchImage(this.graph, src, this.#fetch)\n }\n\n // --- Stubs ---\n\n /** Loads the font so text measures and draws with it from then on; rejects as Figma does. */\n async loadFontAsync(fontName: FigmaFontNameInput): Promise<void> {\n await loadFigmaFont(fontName)\n }\n\n /**\n * The axis tags a variable family takes in `variationSettings`, or `null` for a static family.\n * Figma answers for any family it lists; Pairdraw reads the axes from a file the family has\n * loaded, so a family has to be loaded first.\n */\n getFontFamilyVariationAxes(family: string): string[] | null {\n const variation = fontManager.familyVariation(family)\n if (variation === undefined) {\n throw new Error(\n `in getFontFamilyVariationAxes: Font family \"${family}\" is not available. Load it with figma.loadFontAsync({ family: \"${family}\" }) first.`\n )\n }\n return variation ? variationAxisTags(variation.axes) : null\n }\n\n /** Every face a script can set, by family; see {@link listFigmaFonts}. */\n listAvailableFontsAsync(): Promise<FigmaFont[]> {\n return listFigmaFonts()\n }\n\n base64Encode(data: Uint8Array): string {\n return fromUint8Array(data)\n }\n\n base64Decode(data: string): Uint8Array {\n if (!isValid(data)) throw new TypeError('Invalid Base64 string')\n return toUint8Array(data)\n }\n\n /**\n * A script run in the editor has no UI to talk to, and Figma still gives every plugin a UI\n * object, so scripts that guard on `figma.ui` keep working here: the calls do nothing.\n */\n readonly ui: {\n onmessage: ((message: unknown, props: unknown) => void) | undefined\n postMessage(message: unknown): void\n resize(width: number, height: number): void\n close(): void\n show(): void\n hide(): void\n } = {\n onmessage: undefined,\n postMessage: noop,\n resize: noop,\n close: noop,\n show: noop,\n hide: noop\n }\n\n showUI(html?: string, options?: unknown): void {\n void html\n void options\n }\n\n notify(message: string): { cancel: () => void } {\n if (typeof console !== 'undefined') console.warn(`[figma.notify] ${message}`)\n return { cancel: noop }\n }\n\n /**\n * A script is one call rather than a plugin with a lifetime, so nothing closes; the message is\n * shown as Figma shows it, through `notify`.\n */\n closePlugin(message?: string): void {\n if (message) this.notify(message)\n }\n\n /** Loads every page's layers, one after another, for a host that loads them as visited. */\n async loadAllPagesAsync(): Promise<void> {\n for (const page of this.graph.getPages()) await loadPage(this, page.id)\n }\n\n commitUndo(): void {\n return undefined\n }\n\n triggerUndo(): void {\n return undefined\n }\n\n exportImage?: (nodeIds: string[], options: ExportImageOptions) => Promise<Uint8Array | null>\n /**\n * Renders nodes of a graph other than the open document's, such as a copy a tool resized, so\n * checking a variant leaves the document and its undo history untouched.\n */\n exportGraphImage?: (\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: ExportImageOptions\n ) => Promise<Uint8Array | null>\n /** Where icon tools search and fetch icons; hosts may pass a self-hosted or bundled set. */\n icons: IconProvider = defaultIcons\n rasterCodec?: RasterCodec\n /** The document as it was before the current AI run first edited `pageId`, or null if unedited. */\n changeBaseline?: (pageId: string) => SceneGraph | null\n}\n\n/** The page an API starts on: the one the host shows, else the document's first page. */\nfunction pageIdToStart(graph: SceneGraph, pageId?: string): string {\n const pages = graph.getPages()\n return pageId ?? (pages.length > 0 ? pages[0].id : graph.rootId)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAM,aAAa,KAAA;;AAwGnB,MAAM,sCAAsB,IAAI,IAAqB;AAErD,MAAM,gBAAkC;CACtC,MAAM,SAAS,KAA+B;EAC5C,MAAM,QAAQ,oBAAoB,IAAI,GAAG;EACzC,OAAO,UAAU,KAAA,IAAY,K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version":3,"file":"index.js","names":["#fetch","#onPageChange","#onViewportChange","#onSelectionChange","#pageSwitch","#pageChange","images.createImage","images.imageByHash","images.fetchImage"],"sources":["../../src/figma-api/index.ts"],"sourcesContent":["import { fromUint8Array, isValid, toUint8Array } from 'js-base64'\n\nimport type { SceneGraph, SceneNode as CoreSceneNode, NodeType } from '@pairdraw/scene-graph'\nimport { createConnector, freeEndpoint } from '@pairdraw/scene-graph/connectors'\nimport { computeBounds } from '@pairdraw/scene-graph/geometry'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport type { SkiaRenderer } from '#core/canvas'\nimport { groupFitOptions } from '#core/canvas/boolean'\nimport { IS_BROWSER, type InterfaceTheme } from '#core/constants'\nimport { newLayerDefaults } from '#core/editor/shapes/defaults'\nimport { booleanOperationPaints, createBooleanOperation } from '#core/editor/structure/boolean'\nimport { wrapNodes } from '#core/editor/structure/container-wrap'\nimport { ungroupNode } from '#core/editor/structure/group/ungroup'\nimport { setDefaultPageBackground } from '#core/figma-api/page-backgrounds'\nimport { defaultIcons, type IconProvider } from '#core/icons'\nimport type { RasterCodec } from '#core/io/formats/raster'\nimport { createSVGNodes } from '#core/io/formats/svg'\nimport { textAutoResizeChanges } from '#core/layout/text-auto-resize'\nimport { fontManager } from '#core/text/font/manager'\n\nimport { componentFromNode } from './components'\nimport { flattenSceneNodes } from './flatten'\nimport { listFigmaFonts } from './fonts/list'\nimport { loadFigmaFont } from './fonts/load'\nimport type { FigmaFontNameInput } from './fonts/names'\nimport { variationAxisTags } from './fonts/variations'\nimport { freshReadGraph } from './fresh-read'\nimport * as images from './images'\nimport type {\n FigmaBooleanOperationNode,\n FigmaComponentNode,\n FigmaComponentSetNode,\n FigmaConnectorNode,\n FigmaEllipseNode,\n FigmaFrameNode,\n FigmaGroupNode,\n FigmaLineNode,\n FigmaPolygonNode,\n FigmaRectangleNode,\n FigmaSectionNode,\n FigmaShapeWithTextNode,\n FigmaStarNode,\n FigmaTextNode,\n FigmaVectorNode\n} from './node-types'\nimport { startPendingLayout } from './pending-layout'\nimport { startPendingComponentSync } from './pending-sync'\nimport {\n FigmaNodeProxy,\n INTERNAL_ID,\n loadPage,\n MIXED,\n pageOfNode,\n setPageHost,\n type FigmaFont,\n type NodeProxyHost\n} from './proxy'\nimport { newShapeWithText } from './shape-with-text'\nimport type { ExportImageOptions } from './types'\nimport { figmaUtil } from './util'\nimport { FigmaVariablesAPI } from './variables'\nimport { combineComponentsAsVariants } from './variants'\n\nconst noop = () => undefined\n\n/** A view of the document: its centre point and its zoom. */\nexport interface FigmaViewport {\n center: Vector\n zoom: number\n}\n\n/** What a host passes to `FigmaAPI` beyond the document. */\nexport interface FigmaAPIOptions {\n /** Fetches the HTTP(S) URLs `figma.createImageAsync` loads; the global `fetch` by default. */\n fetch?: images.ImageFetch\n /**\n * Loads a page's layers, for a host that loads pages as they are visited, as the editor does a\n * file it opens: `page.loadAsync`, `figma.loadAllPagesAsync`, and `setCurrentPageAsync` call\n * it, as they load pages in Figma's dynamic-page mode. Without one every page is in memory.\n */\n loadPage?: (pageId: string) => Promise<void>\n /** The page holding a layer not loaded yet, which `getNodeByIdAsync` loads to find it. */\n pageOfNode?: (nodeId: string) => Promise<string | null>\n /**\n * Runs when a script puts the API on another page, so a host can show that page too. The host\n * owns which page is on screen, and a plugin that switches page expects to see it switched.\n */\n onPageChange?: (pageId: string) => void | Promise<void>\n /**\n * Runs when a script moves the viewport, so a host can show the same view. A host owns the\n * viewport on screen, and a plugin that pans or zooms expects to see the result.\n */\n onViewportChange?: (viewport: FigmaViewport) => void\n /**\n * The page the host already shows. Seeded here rather than assigned after construction, so a\n * plain tool call does not ask the host to switch to the page it is already on.\n */\n pageId?: string\n /**\n * The view the host already shows, seeded for the same reason: a tool that only reads or draws\n * must not move the viewport of whoever is looking at the document.\n */\n viewport?: FigmaViewport\n /**\n * Runs when a script sets the page selection, so a host can select those layers too. The host\n * owns which layers are selected on screen, and a plugin that selects expects to see them selected.\n */\n onSelectionChange?: (ids: readonly string[], pageId: string) => void\n /**\n * The selection the host already shows, seeded for the same reason as the page and the viewport:\n * a tool that only reads must not reselect what is already selected.\n */\n selection?: readonly string[]\n /**\n * Brings instances in line with the component edits made so far, for a host that syncs them\n * after edits itself, as the editor does; reading a layer calls it first. Without one the API\n * records edits and syncs their instances itself.\n */\n flushComponentSync?: () => void\n}\n\nexport { FigmaNodeProxy } from './proxy'\nexport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nexport { freshRead, freshReadGraph } from './fresh-read'\nexport { flushPendingLayout } from './pending-layout'\nexport { flushPendingComponentSync } from './pending-sync'\nexport type { FigmaEffect } from './effects'\nexport type { ExportImageOptions } from './types'\nexport {\n ImageTooLargeError,\n MAX_IMAGE_FETCH_BYTES,\n readBoundedImage,\n type ImageFetch\n} from './images'\nexport {\n FigmaVariable,\n FigmaVariableCollection,\n FigmaVariablesAPI,\n type FigmaComposedColor,\n type FigmaVariableAlias,\n type FigmaVariableValue\n} from './variables'\nexport type {\n FigmaBooleanOperationNode,\n FigmaComponentNode,\n FigmaComponentSetNode,\n FigmaConnectorNode,\n FigmaEllipseNode,\n FigmaFrameNode,\n FigmaGroupNode,\n FigmaInstanceNode,\n FigmaLineNode,\n FigmaPolygonNode,\n FigmaRectangleNode,\n FigmaSectionNode,\n FigmaShapeWithTextNode,\n FigmaSlotNode,\n FigmaStarNode,\n FigmaTextNode,\n FigmaVectorNode\n} from './node-types'\nexport type { FigmaFont, FigmaFontName } from './proxy'\nexport type { FigmaFontNameInput } from './fonts/names'\nexport type { FigmaVariationSettings } from './fonts/variations'\n\n// TODO(figma-api): Implement the full official PluginAPI interface once our compatibility\n// layer covers all required node-specific return types and unsupported APIs are modeled explicitly.\n/** What a plugin keeps in `figma.clientStorage`: JSON values, copied in and out. */\nconst clientStorageValues = new Map<string, unknown>()\n\nconst clientStorage: ClientStorageAPI = {\n async getAsync(key: string): Promise<unknown> {\n const value = clientStorageValues.get(key)\n return value === undefined ? undefined : structuredClone(value)\n },\n async setAsync(key: string, value: unknown): Promise<void> {\n clientStorageValues.set(key, structuredClone(value))\n },\n async deleteAsync(key: string): Promise<void> {\n clientStorageValues.delete(key)\n },\n async keysAsync(): Promise<string[]> {\n return [...clientStorageValues.keys()]\n }\n}\n\nexport class FigmaAPI implements NodeProxyHost {\n /**\n * The read-freshening proxy. It is not the raw graph, so an identity check against an editor's\n * graph goes through `underlyingGraph`; node internals already hold the raw graph.\n */\n readonly graph: SceneGraph\n private _currentPageId: string\n private _selection: FigmaNodeProxy[] = []\n private _nodeCache = new Map<string, FigmaNodeProxy>()\n private _pageProxies = new WeakSet<FigmaNodeProxy>()\n private _renderer: SkiaRenderer | null = null\n /** The interface theme new sections take their fill from, as in Figma. */\n theme: InterfaceTheme = 'light'\n\n readonly mixed = MIXED\n /** Figma's color and Markdown helpers, as `figma.util`. */\n readonly util: UtilAPI = figmaUtil\n /** The document's variables and collections, as Figma's `figma.variables`. */\n readonly variables: FigmaVariablesAPI\n /** Values a plugin keeps for its next run, as Figma's `figma.clientStorage`. */\n readonly clientStorage: ClientStorageAPI = clientStorage\n\n /** How `createImageAsync` fetches HTTP(S) URLs; a host passes one that gets past CORS. */\n readonly #fetch: images.ImageFetch\n readonly #onPageChange: ((pageId: string) => void | Promise<void>) | undefined\n readonly #onViewportChange: ((viewport: FigmaViewport) => void) | undefined\n readonly #onSelectionChange: ((ids: readonly string[], pageId: string) => void) | undefined\n /** The last host page switch, so `setCurrentPageAsync` can wait for it. */\n #pageChange: Promise<void> = Promise.resolve()\n /** Counts page switches, so a switch whose page loads after a later one does not undo it. */\n #pageSwitch = 0\n\n constructor(graph: SceneGraph, options: FigmaAPIOptions = {}) {\n this.graph = freshReadGraph(graph)\n this.#fetch = options.fetch ?? ((input, init) => fetch(input, init))\n if (options.loadPage)\n setPageHost(this, { load: options.loadPage, pageOfNode: options.pageOfNode })\n this.#onPageChange = options.onPageChange\n this.#onViewportChange = options.onViewportChange\n this.#onSelectionChange = options.onSelectionChange\n this.variables = new FigmaVariablesAPI(graph)\n startPendingLayout(graph)\n startPendingComponentSync(graph, options.flushComponentSync)\n this._currentPageId = pageIdToStart(graph, options.pageId)\n if (options.viewport) {\n this._viewport = {\n x: options.viewport.center.x,\n y: options.viewport.center.y,\n zoom: options.viewport.zoom\n }\n }\n // Seeded here, not assigned through the setter, so a tool that only reads does not ask the\n // host to select the layers it is already showing.\n this._selection = (options.selection ?? []).flatMap((id) =>\n this.graph.getNode(id) ? [this.wrapNode(id)] : []\n )\n }\n\n setRenderer(renderer: SkiaRenderer | null): void {\n this._renderer = renderer\n }\n\n get groupFitOptions(): GroupFitOptions {\n return groupFitOptions(this._renderer, this.graph)\n }\n\n get currentPageId(): string {\n return this._currentPageId\n }\n\n wrapNode(id: string): FigmaNodeProxy {\n let proxy = this._nodeCache.get(id)\n if (!proxy) {\n proxy = new FigmaNodeProxy(id, this.graph, this)\n this._nodeCache.set(id, proxy)\n }\n return proxy\n }\n\n private _ensurePageProxy(\n proxy: FigmaNodeProxy\n ): FigmaNodeProxy & { selection: FigmaNodeProxy[] } {\n if (!this._pageProxies.has(proxy)) {\n Object.defineProperty(proxy, 'selection', {\n get: () => this._selection,\n set: (nodes: FigmaNodeProxy[]) => {\n const next = nodes.map((node) => node[INTERNAL_ID])\n const current = this._selection.map((node) => node[INTERNAL_ID])\n this._selection = nodes\n if (next.length === current.length && next.every((id, index) => id === current[index]))\n return\n this.#onSelectionChange?.(next, this._currentPageId)\n },\n enumerable: true,\n configurable: true\n })\n this._pageProxies.add(proxy)\n }\n return proxy as FigmaNodeProxy & { selection: FigmaNodeProxy[] }\n }\n\n get root(): FigmaNodeProxy {\n return this.wrapNode(this.graph.rootId)\n }\n\n get currentPage(): FigmaNodeProxy & { selection: FigmaNodeProxy[] } {\n return this._ensurePageProxy(this.wrapNode(this._currentPageId))\n }\n\n set currentPage(page: FigmaNodeProxy) {\n const pageId = page[INTERNAL_ID]\n this.#pageSwitch++\n if (pageId === this._currentPageId) return\n this._currentPageId = pageId\n this.#pageChange = Promise.resolve(this.#onPageChange?.(pageId))\n }\n\n getNodeById(id: string): FigmaNodeProxy | null {\n const node = this.graph.getNode(id)\n return node ? this.wrapNode(id) : null\n }\n\n /** As in Figma's dynamic-page mode, a layer on a page not loaded yet loads that page. */\n async getNodeByIdAsync(id: string): Promise<FigmaNodeProxy | null> {\n const node = this.getNodeById(id)\n // A page asked for by id is its own holder, and one whose layers are not in yet loads first.\n const unloadedPage = node?.type === 'CANVAS' && this.graph.getChildren(id).length === 0\n if (node && !unloadedPage) return node\n const pageId = node\n ? id\n : ((await pageOfNode(this, id)) ??\n (this.graph.getPages().some((page) => page.id === id) ? id : null))\n if (!pageId) return null\n await loadPage(this, pageId)\n return this.getNodeById(id) ?? node\n }\n\n /**\n * The page switch Figma requires in dynamic-page mode, which sets `currentPage`. As in Figma, a\n * missing node throws at once and a node that is no page rejects.\n */\n setCurrentPageAsync(page: FigmaNodeProxy): Promise<void>\n setCurrentPageAsync(page: PageNode): Promise<void>\n // Scripts are not type-checked, so the call checks for a missing node as Figma does.\n setCurrentPageAsync(page: PageNode | FigmaNodeProxy | null | undefined): Promise<void> {\n if (page == null) throw new Error(`in setCurrentPageAsync: Expected node, got ${String(page)}`)\n if (this._rawNode(page).type !== 'CANVAS') {\n return Promise.reject(new Error('figma.setCurrentPageAsync expects a PageNode'))\n }\n const pageId = this._nodeId(page)\n const pageSwitch = ++this.#pageSwitch\n return loadPage(this, pageId).then(() => {\n if (pageSwitch !== this.#pageSwitch) return undefined\n if (this.graph.getNode(pageId)?.type !== 'CANVAS')\n throw new Error('in setCurrentPageAsync: The page was removed while it loaded')\n this._currentPageId = pageId\n this.#pageChange = Promise.resolve(this.#onPageChange?.(pageId))\n return this.#pageChange\n })\n }\n\n // --- Node Creation ---\n\n /** New layers start as the editor's tools make them, which is how Figma's plugin API makes them. */\n private _createNode(type: NodeType): FigmaNodeProxy {\n const defaults = newLayerDefaults(type, this.theme)\n // Figma's plugin API makes a line with no height, a 496 px section, and a hugging frame.\n if (type === 'LINE') defaults.height = 0\n if (type === 'SECTION') Object.assign(defaults, { width: 496, height: 496 })\n if (type === 'FRAME' || type === 'COMPONENT') defaults.primaryAxisSizing = 'HUG'\n const node = this.graph.createNode(type, this._currentPageId, defaults)\n return this.wrapNode(node.id)\n }\n\n createFrame(): FigmaFrameNode {\n return this._createNode('FRAME') as FigmaFrameNode\n }\n\n createRectangle(): FigmaRectangleNode {\n return this._createNode('RECTANGLE') as FigmaRectangleNode\n }\n\n createEllipse(): FigmaEllipseNode {\n return this._createNode('ELLIPSE') as FigmaEllipseNode\n }\n\n createText(): FigmaTextNode {\n const text = this._createNode('TEXT') as FigmaTextNode\n // Figma's plugin text starts empty at 12px and sizes itself to its content: no width, one\n // line tall.\n const node = this.graph.getNode(text.id)\n const defaults = { fontSize: 12, textAutoResize: 'WIDTH_AND_HEIGHT' as const, width: 0 }\n this.graph.updateNode(text.id, { ...defaults, ...textAutoResizeChanges(node, defaults) })\n return text\n }\n\n createLine(): FigmaLineNode {\n return this._createNode('LINE') as FigmaLineNode\n }\n\n createPolygon(): FigmaPolygonNode {\n return this._createNode('POLYGON') as FigmaPolygonNode\n }\n\n createStar(): FigmaStarNode {\n return this._createNode('STAR') as FigmaStarNode\n }\n\n createShapeWithText(): FigmaShapeWithTextNode {\n return this.wrapNode(newShapeWithText(this).id) as FigmaShapeWithTextNode\n }\n\n createVector(): FigmaVectorNode {\n return this._createNode('VECTOR') as FigmaVectorNode\n }\n\n /** The layers Figma makes from SVG markup, on the current page at its origin. */\n // eslint-disable-next-line pairdraw/no-mixed-case-acronym-identifiers -- Figma Plugin API name.\n createNodeFromSvg(svg: string): FigmaFrameNode {\n const node = createSVGNodes(this.graph, this._currentPageId, svg, {\n keepEmpty: true,\n profile: this.graph.documentColorSpace\n })\n if (!node) throw new Error('in createNodeFromSvg: Failed to convert SVG file')\n return this.wrapNode(node.id) as FigmaFrameNode\n }\n\n /**\n * A connector as Figma's plugin API makes one: \"Connector line\", free from the page origin to\n * 200 px right of it, with no start cap and an arrow at the end.\n */\n createConnector(): FigmaConnectorNode {\n const node = createConnector(this.graph, this._currentPageId, {\n start: freeEndpoint(0, 0),\n end: freeEndpoint(200, 0),\n startCap: 'NONE',\n endCap: 'ARROW_LINES'\n })\n return this.wrapNode(node.id) as FigmaConnectorNode\n }\n\n createComponent(): FigmaComponentNode {\n return this._createNode('COMPONENT') as FigmaComponentNode\n }\n\n createSection(): FigmaSectionNode {\n return this._createNode('SECTION') as FigmaSectionNode\n }\n\n createPage(): FigmaNodeProxy {\n const page = this.graph.addPage('Page')\n setDefaultPageBackground(this.graph, page, this.theme)\n return this.wrapNode(page.id)\n }\n\n // --- Grouping ---\n\n private _nodeId(node: BaseNode | FigmaNodeProxy): string {\n return (node as BaseNode & { [INTERNAL_ID]: string })[INTERNAL_ID]\n }\n\n private _rawNode(node: BaseNode | FigmaNodeProxy): CoreSceneNode {\n const id = this._nodeId(node)\n const raw = this.graph.getNode(id)\n if (!raw) throw new Error(`Node ${id} not found`)\n return raw\n }\n\n group(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaGroupNode\n group(nodes: ReadonlyArray<BaseNode>, parent: BaseNode & ChildrenMixin, index?: number): GroupNode\n group(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaGroupNode {\n const parentId = this._nodeId(parent)\n const members = nodes.map((node) => this._rawNode(node))\n const groupNode = wrapNodes(this.graph, 'GROUP', members, parentId, index)\n return this.wrapNode(groupNode.id) as FigmaGroupNode\n }\n\n ungroup(node: FigmaNodeProxy): FigmaNodeProxy[]\n ungroup(node: SceneNode & ChildrenMixin): Array<SceneNode>\n ungroup(node: (SceneNode & ChildrenMixin) | FigmaNodeProxy): Array<SceneNode> | FigmaNodeProxy[] {\n const children = ungroupNode(this.graph, this._nodeId(node)) ?? []\n return children.map((id) => this.wrapNode(id))\n }\n\n createComponentFromNode(node: FigmaNodeProxy): FigmaNodeProxy {\n const raw = this.graph.getNode(node[INTERNAL_ID])\n if (!raw) throw new Error('Node not found')\n return this.wrapNode(componentFromNode(this.graph, raw, raw.parentId ?? this._currentPageId).id)\n }\n\n combineAsVariants(\n nodes: ReadonlyArray<FigmaComponentNode>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaComponentSetNode\n combineAsVariants(\n nodes: ReadonlyArray<ComponentNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): ComponentSetNode\n combineAsVariants(\n nodes: ReadonlyArray<ComponentNode | FigmaComponentNode>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaComponentSetNode {\n const componentSet = combineComponentsAsVariants(\n this.graph,\n nodes.map((node) => this._nodeId(node)),\n this._nodeId(parent),\n index\n )\n return this.wrapNode(componentSet.id) as FigmaComponentSetNode\n }\n\n // --- Boolean Operations ---\n\n private _booleanOperation(\n operation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE',\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n if (nodes.length < 2) throw new Error('Need at least 2 nodes for boolean operation')\n const parentId = this._nodeId(parent)\n const members = nodes.map((node) => this._rawNode(node))\n const { node: group } = createBooleanOperation(\n this.graph,\n members,\n parentId,\n operation,\n index,\n booleanOperationPaints(operation, members, 'script'),\n this.groupFitOptions\n )\n return this.wrapNode(group.id) as FigmaBooleanOperationNode\n }\n\n union(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n union(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n union(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('UNION', nodes, parent, index)\n }\n\n subtract(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n subtract(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n subtract(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('SUBTRACT', nodes, parent, index)\n }\n\n intersect(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n intersect(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n intersect(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('INTERSECT', nodes, parent, index)\n }\n\n exclude(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent: FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode\n exclude(\n nodes: ReadonlyArray<BaseNode>,\n parent: BaseNode & ChildrenMixin,\n index?: number\n ): BooleanOperationNode\n exclude(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaBooleanOperationNode {\n return this._booleanOperation('EXCLUDE', nodes, parent, index)\n }\n\n // --- Flatten ---\n\n flatten(\n nodes: ReadonlyArray<FigmaNodeProxy>,\n parent?: FigmaNodeProxy,\n index?: number\n ): FigmaVectorNode\n flatten(\n nodes: ReadonlyArray<BaseNode>,\n parent?: BaseNode & ChildrenMixin,\n index?: number\n ): VectorNode\n flatten(\n nodes: ReadonlyArray<BaseNode | FigmaNodeProxy>,\n parent?: (BaseNode & ChildrenMixin) | FigmaNodeProxy,\n index?: number\n ): FigmaVectorNode {\n if (nodes.length === 0) throw new Error('Need at least 1 node to flatten')\n const parentId = this._nodeId(parent ?? this.currentPage)\n const sourceNodes: CoreSceneNode[] = []\n for (const node of nodes) {\n const raw = this.graph.getNode(this._nodeId(node))\n if (!raw) throw new Error('Node not found')\n sourceNodes.push(raw)\n }\n const vector = flattenSceneNodes(this.graph, this._renderer, sourceNodes, parentId)\n if (index != null) this.graph.insertChildAt(vector.id, parentId, index)\n for (const node of nodes) {\n this.graph.deleteNode(this._nodeId(node))\n }\n return this.wrapNode(vector.id) as FigmaVectorNode\n }\n\n // --- Viewport ---\n\n private _viewport = { x: 0, y: 0, zoom: 1 }\n\n get viewport(): FigmaViewport & {\n scrollAndZoomIntoView: (nodes: readonly { absoluteBoundingBox: Rect }[]) => void\n } {\n return {\n center: { x: this._viewport.x, y: this._viewport.y },\n zoom: this._viewport.zoom,\n scrollAndZoomIntoView: (nodes) => {\n const b = computeBounds(nodes.map((n) => n.absoluteBoundingBox))\n if (b.width === 0 && b.height === 0 && nodes.length === 0) return\n\n const padding = 80\n const contentW = b.width + padding * 2\n const contentH = b.height + padding * 2\n const viewW = IS_BROWSER ? window.innerWidth : 1280\n const viewH = IS_BROWSER ? window.innerHeight : 720\n const zoom = Math.min(viewW / contentW, viewH / contentH, 1)\n // A script scrolling to its own result must not move the view someone else is looking at:\n // only `viewport` and a page switch do that.\n this._viewport = { x: b.x + b.width / 2, y: b.y + b.height / 2, zoom }\n }\n }\n }\n\n set viewport(v: FigmaViewport) {\n this._showViewport({ x: v.center.x, y: v.center.y, zoom: v.zoom })\n }\n\n /**\n * Moves the viewport and puts the host on the same view. A tool that scrolls nodes into view\n * does not call this: only a viewport a writer asks for moves the view of whoever is looking.\n */\n private _showViewport(next: { x: number; y: number; zoom: number }): void {\n const current = this._viewport\n this._viewport = next\n if (current.x === next.x && current.y === next.y && current.zoom === next.zoom) return\n this.#onViewportChange?.({ center: { x: next.x, y: next.y }, zoom: next.zoom })\n }\n\n createImage(data: Uint8Array): Image {\n return images.createImage(this.graph, data)\n }\n\n getImageByHash(hash: string): Image | null {\n return images.imageByHash(this.graph, hash)\n }\n\n /** Fetches the image at `src` through the host's `fetch` and stores it as `createImage` does. */\n createImageAsync(src: string): Promise<Image> {\n return images.fetchImage(this.graph, src, this.#fetch)\n }\n\n // --- Stubs ---\n\n /** Loads the font so text measures and draws with it from then on; rejects as Figma does. */\n async loadFontAsync(fontName: FigmaFontNameInput): Promise<void> {\n await loadFigmaFont(fontName)\n }\n\n /**\n * The axis tags a variable family takes in `variationSettings`, or `null` for a static family.\n * Figma answers for any family it lists; Pairdraw reads the axes from a file the family has\n * loaded, so a family has to be loaded first.\n */\n getFontFamilyVariationAxes(family: string): string[] | null {\n const variation = fontManager.familyVariation(family)\n if (variation === undefined) {\n throw new Error(\n `in getFontFamilyVariationAxes: Font family \"${family}\" is not available. Load it with figma.loadFontAsync({ family: \"${family}\" }) first.`\n )\n }\n return variation ? variationAxisTags(variation.axes) : null\n }\n\n /** Every face a script can set, by family; see {@link listFigmaFonts}. */\n listAvailableFontsAsync(): Promise<FigmaFont[]> {\n return listFigmaFonts()\n }\n\n base64Encode(data: Uint8Array): string {\n return fromUint8Array(data)\n }\n\n base64Decode(data: string): Uint8Array {\n if (!isValid(data)) throw new TypeError('Invalid Base64 string')\n return toUint8Array(data)\n }\n\n /**\n * A script run in the editor has no UI to talk to, and Figma still gives every plugin a UI\n * object, so scripts that guard on `figma.ui` keep working here: the calls do nothing.\n */\n readonly ui: {\n onmessage: ((message: unknown, props: unknown) => void) | undefined\n postMessage(message: unknown): void\n resize(width: number, height: number): void\n close(): void\n show(): void\n hide(): void\n } = {\n onmessage: undefined,\n postMessage: noop,\n resize: noop,\n close: noop,\n show: noop,\n hide: noop\n }\n\n showUI(html?: string, options?: unknown): void {\n void html\n void options\n }\n\n notify(message: string): { cancel: () => void } {\n if (typeof console !== 'undefined') console.warn(`[figma.notify] ${message}`)\n return { cancel: noop }\n }\n\n /**\n * A script is one call rather than a plugin with a lifetime, so nothing closes; the message is\n * shown as Figma shows it, through `notify`.\n */\n closePlugin(message?: string): void {\n if (message) this.notify(message)\n }\n\n /** Loads every page's layers, one after another, for a host that loads them as visited. */\n async loadAllPagesAsync(): Promise<void> {\n for (const page of this.graph.getPages()) await loadPage(this, page.id)\n }\n\n commitUndo(): void {\n return undefined\n }\n\n triggerUndo(): void {\n return undefined\n }\n\n exportImage?: (nodeIds: string[], options: ExportImageOptions) => Promise<Uint8Array | null>\n /**\n * Renders nodes of a graph other than the open document's, such as a copy a tool resized, so\n * checking a variant leaves the document and its undo history untouched.\n */\n exportGraphImage?: (\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: ExportImageOptions\n ) => Promise<Uint8Array | null>\n /** Where icon tools search and fetch icons; hosts may pass a self-hosted or bundled set. */\n icons: IconProvider = defaultIcons\n rasterCodec?: RasterCodec\n /** The document as it was before the current AI run first edited `pageId`, or null if unedited. */\n changeBaseline?: (pageId: string) => SceneGraph | null\n}\n\n/** The page an API starts on: the one the host shows, else the document's first page. */\nfunction pageIdToStart(graph: SceneGraph, pageId?: string): string {\n const pages = graph.getPages()\n return pageId ?? (pages.length > 0 ? pages[0].id : graph.rootId)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAM,aAAa,KAAA;;AAyGnB,MAAM,sCAAsB,IAAI,IAAqB;AAErD,MAAM,gBAAkC;CACtC,MAAM,SAAS,KAA+B;EAC5C,MAAM,QAAQ,oBAAoB,IAAI,GAAG;EACzC,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,gBAAgB,KAAK;CAChE;CACA,MAAM,SAAS,KAAa,OAA+B;EACzD,oBAAoB,IAAI,KAAK,gBAAgB,KAAK,CAAC;CACrD;CACA,MA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MAAM,cAAc,UAA6C;EAC/D,MAAM,cAAc,QAAQ;CAC9B;;;;;;CAOA,2BAA2B,QAAiC;EAC1D,MAAM,YAAY,YAAY,gBAAgB,MAAM;EACpD,IAAI,cAAc,KAAA,GAChB,MAAM,IAAI,MACR,+CAA+C,OAAO,kEAAkE,OAAO,YACjI;EAEF,OAAO,YAAY,kBAAkB,UAAU,IAAI,IAAI;CACzD;;CAGA,0BAAgD;EAC9C,OAAO,eAAe;CACxB;CAEA,aAAa,MAA0B;EACrC,OAAO,eAAe,IAAI;CAC5B;CAEA,aAAa,MAA0B;EACrC,IAAI,CAAC,QAAQ,IAAI,GAAG,MAAM,IAAI,UAAU,uBAAuB;EAC/D,OAAO,aAAa,IAAI;CAC1B;;;;;CAMA,KAOI;EACF,WAAW,KAAA;EACX,aAAa;EACb,QAAQ;EACR,OAAO;EACP,MAAM;EACN,MAAM;CACR;CAEA,OAAO,MAAe,SAAyB,CAG/C;CAEA,OAAO,SAAyC;EAC9C,IAAI,OAAO,YAAY,aAAa,QAAQ,KAAK,kBAAkB,SAAS;EAC5E,OAAO,EAAE,QAAQ,KAAK;CACxB;;;;;CAMA,YAAY,SAAwB;EAClC,IAAI,SAAS,KAAK,OAAO,OAAO;CAClC;;CAGA,MAAM,oBAAmC;EACvC,KAAK,MAAM,QAAQ,KAAK,MAAM,SAAS,GAAG,MAAM,SAAS,MAAM,KAAK,EAAE;CACxE;CAEA,aAAmB,CAEnB;CAEA,cAAoB,CAEpB;CAEA;;;;;CAKA;;CAOA,QAAsB;CACtB;;CAEA;AACF;;AAGA,SAAS,cAAc,OAAmB,QAAyB;CACjE,MAAM,QAAQ,MAAM,SAAS;CAC7B,OAAO,WAAW,MAAM,SAAS,IAAI,MAAM,EAAE,CAAC,KAAK,MAAM;AAC3D"}
|
|
@@ -6,9 +6,9 @@ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
|
6
6
|
* one recorder for its lifetime, kept across APIs: a script that failed before its tool laid
|
|
7
7
|
* out its edits leaves them for the next read to lay out.
|
|
8
8
|
*/
|
|
9
|
-
declare function startPendingLayout(
|
|
9
|
+
declare function startPendingLayout(source: SceneGraph): void;
|
|
10
10
|
/** Lays out the edits recorded since the last geometry read. */
|
|
11
|
-
declare function flushPendingLayout(
|
|
11
|
+
declare function flushPendingLayout(source: SceneGraph): void;
|
|
12
12
|
/**
|
|
13
13
|
* Lays out the recorded edits before a script moves or sizes `node`, when that layout could change
|
|
14
14
|
* where it lands, as Figma lays out a script's edits while it runs: the layer follows its frame's
|
|
@@ -16,7 +16,7 @@ declare function flushPendingLayout(graph: SceneGraph): void;
|
|
|
16
16
|
* an auto layout places, lands the same either way, so its edits wait for the next read: a script
|
|
17
17
|
* that builds many layers lays out once rather than once per layer.
|
|
18
18
|
*/
|
|
19
|
-
declare function flushPendingLayoutBefore(
|
|
19
|
+
declare function flushPendingLayoutBefore(source: SceneGraph, node: SceneNode, { placesChildren }?: {
|
|
20
20
|
placesChildren?: boolean;
|
|
21
21
|
}): void;
|
|
22
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-layout.d.ts","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"pending-layout.d.ts","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"mappings":";;;;;;;;iBAmCgB,mBAAmB,QAAQ;;iBAU3B,mBAAmB,QAAQ;;;;;;;;iBAqD3B,yBACd,QAAQ,YACR,MAAM,aACJ;EAA4B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLayoutRunner } from "../layout/mutations.js";
|
|
2
|
+
import { underlyingGraph } from "./graph-ref.js";
|
|
2
3
|
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
3
4
|
import { createSceneMutationImpact, recordSceneMutations } from "@pairdraw/scene-graph/mutation-impact";
|
|
4
5
|
//#region src/figma-api/pending-layout.ts
|
|
@@ -15,7 +16,8 @@ function mergeImpact(into, from) {
|
|
|
15
16
|
* one recorder for its lifetime, kept across APIs: a script that failed before its tool laid
|
|
16
17
|
* out its edits leaves them for the next read to lay out.
|
|
17
18
|
*/
|
|
18
|
-
function startPendingLayout(
|
|
19
|
+
function startPendingLayout(source) {
|
|
20
|
+
const graph = underlyingGraph(source);
|
|
19
21
|
if (pendingByGraph.has(graph)) return;
|
|
20
22
|
const pending = {
|
|
21
23
|
impact: createSceneMutationImpact(),
|
|
@@ -25,7 +27,8 @@ function startPendingLayout(graph) {
|
|
|
25
27
|
recordSceneMutations(graph, pending.impact, () => !pending.flushing && !graph.isApplyingLayout);
|
|
26
28
|
}
|
|
27
29
|
/** Lays out the edits recorded since the last geometry read. */
|
|
28
|
-
function flushPendingLayout(
|
|
30
|
+
function flushPendingLayout(source) {
|
|
31
|
+
const graph = underlyingGraph(source);
|
|
29
32
|
flushPendingComponentSync(graph);
|
|
30
33
|
const pending = pendingByGraph.get(graph);
|
|
31
34
|
if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return;
|
|
@@ -74,7 +77,8 @@ function editsReach(graph, impact, node) {
|
|
|
74
77
|
* an auto layout places, lands the same either way, so its edits wait for the next read: a script
|
|
75
78
|
* that builds many layers lays out once rather than once per layer.
|
|
76
79
|
*/
|
|
77
|
-
function flushPendingLayoutBefore(
|
|
80
|
+
function flushPendingLayoutBefore(source, node, { placesChildren = false } = {}) {
|
|
81
|
+
const graph = underlyingGraph(source);
|
|
78
82
|
const pending = pendingByGraph.get(graph);
|
|
79
83
|
if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return;
|
|
80
84
|
if ((followsFrameSize(node) || placesChildren && graph.getChildren(node.id).some(followsFrameSize)) && editsReach(graph, pending.impact, node)) flushPendingLayout(graph);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-layout.js","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations,\n type SceneMutationImpact\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { createLayoutRunner } from '#core/layout/mutations'\n\nimport { flushPendingComponentSync } from './pending-sync'\n\ninterface PendingLayout {\n impact: SceneMutationImpact\n flushing: boolean\n}\n\nconst pendingByGraph = new WeakMap<SceneGraph, PendingLayout>()\n\nfunction clearImpact(impact: SceneMutationImpact): void {\n for (const ids of Object.values(impact)) ids.clear()\n}\n\nfunction mergeImpact(into: SceneMutationImpact, from: SceneMutationImpact): void {\n for (const key of Object.keys(into) as (keyof SceneMutationImpact)[]) {\n for (const id of from[key]) into[key].add(id)\n }\n}\n\n/**\n * Records the graph's edits so that reading geometry lays out what they touched first, as Figma\n * does: a script that fills a child and then reads its width sees the filled width. A graph has\n * one recorder for its lifetime, kept across APIs: a script that failed before its tool laid\n * out its edits leaves them for the next read to lay out.\n */\nexport function startPendingLayout(
|
|
1
|
+
{"version":3,"file":"pending-layout.js","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations,\n type SceneMutationImpact\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { createLayoutRunner } from '#core/layout/mutations'\n\nimport { underlyingGraph } from './graph-ref'\nimport { flushPendingComponentSync } from './pending-sync'\n\ninterface PendingLayout {\n impact: SceneMutationImpact\n flushing: boolean\n}\n\nconst pendingByGraph = new WeakMap<SceneGraph, PendingLayout>()\n\nfunction clearImpact(impact: SceneMutationImpact): void {\n for (const ids of Object.values(impact)) ids.clear()\n}\n\nfunction mergeImpact(into: SceneMutationImpact, from: SceneMutationImpact): void {\n for (const key of Object.keys(into) as (keyof SceneMutationImpact)[]) {\n for (const id of from[key]) into[key].add(id)\n }\n}\n\n/**\n * Records the graph's edits so that reading geometry lays out what they touched first, as Figma\n * does: a script that fills a child and then reads its width sees the filled width. A graph has\n * one recorder for its lifetime, kept across APIs: a script that failed before its tool laid\n * out its edits leaves them for the next read to lay out.\n */\nexport function startPendingLayout(source: SceneGraph): void {\n const graph = underlyingGraph(source)\n if (pendingByGraph.has(graph)) return\n const pending: PendingLayout = { impact: createSceneMutationImpact(), flushing: false }\n pendingByGraph.set(graph, pending)\n // Layout's own writes are its result, not new edits.\n recordSceneMutations(graph, pending.impact, () => !pending.flushing && !graph.isApplyingLayout)\n}\n\n/** Lays out the edits recorded since the last geometry read. */\nexport function flushPendingLayout(source: SceneGraph): void {\n const graph = underlyingGraph(source)\n // Instances lay out what their components hold now.\n flushPendingComponentSync(graph)\n const pending = pendingByGraph.get(graph)\n if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return\n const impact = structuredClone(pending.impact)\n clearImpact(pending.impact)\n pending.flushing = true\n try {\n createLayoutRunner(() => graph).runLayoutForImpact(impact)\n } catch (error) {\n // The edits are still unlaid out, so the next read tries again.\n mergeImpact(pending.impact, impact)\n throw error\n } finally {\n pending.flushing = false\n }\n}\n\n/** Whether a frame resizing would move or stretch the layer: a constraint other than left or top. */\nfunction followsFrameSize(node: SceneNode): boolean {\n return node.horizontalConstraint !== 'MIN' || node.verticalConstraint !== 'MIN'\n}\n\n/** The layer and the layers above it, up to but not including its page. */\nfunction layoutChain(graph: SceneGraph, id: string): string[] {\n const chain: string[] = []\n for (let node = graph.getNode(id); node && node.type !== 'CANVAS';) {\n chain.push(node.id)\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n }\n return chain\n}\n\n/**\n * Whether laying out the recorded edits could reach the layer: an edit sits in the same frame as\n * the layer, at any depth, since a layer that grows makes every Hug frame around it grow. Edits\n * in another top-level frame share only the page with it, and leave it where it is.\n */\nfunction editsReach(graph: SceneGraph, impact: SceneMutationImpact, node: SceneNode): boolean {\n const above = new Set(layoutChain(graph, node.id))\n const edited = [...impact.changedNodeIds, ...impact.currentParentIds, ...impact.previousParentIds]\n return edited.some((id) => layoutChain(graph, id).some((current) => above.has(current)))\n}\n\n/**\n * Lays out the recorded edits before a script moves or sizes `node`, when that layout could change\n * where it lands, as Figma lays out a script's edits while it runs: the layer follows its frame's\n * size, or a resize places its children from its own size. A layer pinned left and top, or one\n * an auto layout places, lands the same either way, so its edits wait for the next read: a script\n * that builds many layers lays out once rather than once per layer.\n */\nexport function flushPendingLayoutBefore(\n source: SceneGraph,\n node: SceneNode,\n { placesChildren = false }: { placesChildren?: boolean } = {}\n): void {\n const graph = underlyingGraph(source)\n const pending = pendingByGraph.get(graph)\n if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return\n const depends =\n followsFrameSize(node) || (placesChildren && graph.getChildren(node.id).some(followsFrameSize))\n if (depends && editsReach(graph, pending.impact, node)) flushPendingLayout(graph)\n}\n"],"mappings":";;;;;AAiBA,MAAM,iCAAiB,IAAI,QAAmC;AAE9D,SAAS,YAAY,QAAmC;CACtD,KAAK,MAAM,OAAO,OAAO,OAAO,MAAM,GAAG,IAAI,MAAM;AACrD;AAEA,SAAS,YAAY,MAA2B,MAAiC;CAC/E,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAChC,KAAK,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE;AAEhD;;;;;;;AAQA,SAAgB,mBAAmB,QAA0B;CAC3D,MAAM,QAAQ,gBAAgB,MAAM;CACpC,IAAI,eAAe,IAAI,KAAK,GAAG;CAC/B,MAAM,UAAyB;EAAE,QAAQ,0BAA0B;EAAG,UAAU;CAAM;CACtF,eAAe,IAAI,OAAO,OAAO;CAEjC,qBAAqB,OAAO,QAAQ,cAAc,CAAC,QAAQ,YAAY,CAAC,MAAM,gBAAgB;AAChG;;AAGA,SAAgB,mBAAmB,QAA0B;CAC3D,MAAM,QAAQ,gBAAgB,MAAM;CAEpC,0BAA0B,KAAK;CAC/B,MAAM,UAAU,eAAe,IAAI,KAAK;CACxC,IAAI,CAAC,WAAW,QAAQ,YAAY,QAAQ,OAAO,eAAe,SAAS,GAAG;CAC9E,MAAM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7 +13,7 @@ declare function startPendingComponentSync(graph: SceneGraph, flush?: () => void
|
|
|
13
13
|
* read or written, only when it is in an instance, as only those layers change. Edits inside a
|
|
14
14
|
* component then sync once, when an instance is next read, not once per edit.
|
|
15
15
|
*/
|
|
16
|
-
declare function flushPendingComponentSync(
|
|
16
|
+
declare function flushPendingComponentSync(source: SceneGraph, layerId?: string): void;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { flushPendingComponentSync, startPendingComponentSync };
|
|
19
19
|
//# sourceMappingURL=pending-sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-sync.d.ts","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"pending-sync.d.ts","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"mappings":";;;;;;;;;iBAmBgB,0BAA0B,OAAO,YAAY;;;;;;iBAsC7C,0BAA0B,QAAQ,YAAY"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { syncComponentsHolding } from "../editor/component-sync.js";
|
|
2
|
+
import { underlyingGraph } from "./graph-ref.js";
|
|
2
3
|
import { createSceneMutationImpact, recordSceneMutations } from "@pairdraw/scene-graph/mutation-impact";
|
|
3
4
|
//#region src/figma-api/pending-sync.ts
|
|
4
5
|
const syncByGraph = /* @__PURE__ */ new WeakMap();
|
|
@@ -40,7 +41,8 @@ function startPendingComponentSync(graph, flush) {
|
|
|
40
41
|
* read or written, only when it is in an instance, as only those layers change. Edits inside a
|
|
41
42
|
* component then sync once, when an instance is next read, not once per edit.
|
|
42
43
|
*/
|
|
43
|
-
function flushPendingComponentSync(
|
|
44
|
+
function flushPendingComponentSync(source, layerId) {
|
|
45
|
+
const graph = underlyingGraph(source);
|
|
44
46
|
const flush = syncByGraph.get(graph);
|
|
45
47
|
if (!flush) return;
|
|
46
48
|
if (layerId !== void 0 && !graph.closest(layerId, (node) => node.type === "INSTANCE")) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-sync.js","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { syncComponentsHolding } from '#core/editor/component-sync'\n\nconst syncByGraph = new WeakMap<SceneGraph, () => void>()\n\n/**\n * Makes reading a layer bring instances in line with the component edits made before it, as Figma\n * does at once: a script that recolors a component and then reads an instance sees the new color.\n * A host that already syncs instances after edits, such as the editor, passes its own `flush`,\n * which also lays out and redraws what it synced. Without one the graph records its edits itself,\n * for its lifetime, as `startPendingLayout` does.\n */\nexport function startPendingComponentSync(graph: SceneGraph, flush?: () => void): void {\n if (flush) {\n syncByGraph.set(graph, flush)\n return\n }\n if (syncByGraph.has(graph)) return\n const impact = createSceneMutationImpact()\n let syncing = false\n // Syncing writes the instances it updates, which are results, not edits; so do loading and layout.\n recordSceneMutations(\n graph,\n impact,\n () => !syncing && !graph.isApplyingImportedState && !graph.isApplyingLayout\n )\n syncByGraph.set(graph, () => {\n if (syncing || impact.changedNodeIds.size === 0) return\n const changed = [...impact.changedNodeIds]\n const leftParents = [...impact.previousParentIds]\n for (const recorded of Object.values(impact)) recorded.clear()\n syncing = true\n try {\n syncComponentsHolding(graph, [...changed, ...leftParents])\n } catch (error) {\n // The edits are still unsynced, so the next read tries again, as pending layout does.\n for (const id of changed) impact.changedNodeIds.add(id)\n for (const id of leftParents) impact.previousParentIds.add(id)\n throw error\n } finally {\n syncing = false\n }\n })\n}\n\n/**\n * Syncs the instances of the components edited since, before a read; given the layer about to be\n * read or written, only when it is in an instance, as only those layers change. Edits inside a\n * component then sync once, when an instance is next read, not once per edit.\n */\nexport function flushPendingComponentSync(
|
|
1
|
+
{"version":3,"file":"pending-sync.js","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { syncComponentsHolding } from '#core/editor/component-sync'\n\nimport { underlyingGraph } from './graph-ref'\n\nconst syncByGraph = new WeakMap<SceneGraph, () => void>()\n\n/**\n * Makes reading a layer bring instances in line with the component edits made before it, as Figma\n * does at once: a script that recolors a component and then reads an instance sees the new color.\n * A host that already syncs instances after edits, such as the editor, passes its own `flush`,\n * which also lays out and redraws what it synced. Without one the graph records its edits itself,\n * for its lifetime, as `startPendingLayout` does.\n */\nexport function startPendingComponentSync(graph: SceneGraph, flush?: () => void): void {\n if (flush) {\n syncByGraph.set(graph, flush)\n return\n }\n if (syncByGraph.has(graph)) return\n const impact = createSceneMutationImpact()\n let syncing = false\n // Syncing writes the instances it updates, which are results, not edits; so do loading and layout.\n recordSceneMutations(\n graph,\n impact,\n () => !syncing && !graph.isApplyingImportedState && !graph.isApplyingLayout\n )\n syncByGraph.set(graph, () => {\n if (syncing || impact.changedNodeIds.size === 0) return\n const changed = [...impact.changedNodeIds]\n const leftParents = [...impact.previousParentIds]\n for (const recorded of Object.values(impact)) recorded.clear()\n syncing = true\n try {\n syncComponentsHolding(graph, [...changed, ...leftParents])\n } catch (error) {\n // The edits are still unsynced, so the next read tries again, as pending layout does.\n for (const id of changed) impact.changedNodeIds.add(id)\n for (const id of leftParents) impact.previousParentIds.add(id)\n throw error\n } finally {\n syncing = false\n }\n })\n}\n\n/**\n * Syncs the instances of the components edited since, before a read; given the layer about to be\n * read or written, only when it is in an instance, as only those layers change. Edits inside a\n * component then sync once, when an instance is next read, not once per edit.\n */\nexport function flushPendingComponentSync(source: SceneGraph, layerId?: string): void {\n const graph = underlyingGraph(source)\n const flush = syncByGraph.get(graph)\n if (!flush) return\n if (layerId !== undefined && !graph.closest(layerId, (node) => node.type === 'INSTANCE')) return\n flush()\n}\n"],"mappings":";;;;AAUA,MAAM,8BAAc,IAAI,QAAgC;;;;;;;;AASxD,SAAgB,0BAA0B,OAAmB,OAA0B;CACrF,IAAI,OAAO;EACT,YAAY,IAAI,OAAO,KAAK;EAC5B;CACF;CACA,IAAI,YAAY,IAAI,KAAK,GAAG;CAC5B,MAAM,SAAS,0BAA0B;CACzC,IAAI,UAAU;CAEd,qBACE,OACA,cACM,CAAC,WAAW,CAAC,MAAM,2BAA2B,CAAC,MAAM,gBAC7D;CACA,YAAY,IAAI,aAAa;EAC3B,IAAI,WAAW,OAAO,eAAe,SAAS,GAAG;EACjD,MAAM,UAAU,CAAC,GAAG,OAAO,cAAc;EACzC,MAAM,cAAc,CAAC,GAAG,OAAO,iBAAiB;EAChD,KAAK,MAAM,YAAY,OAAO,OAAO,MAAM,GAAG,SAAS,MAAM;EAC7D,UAAU;EACV,IAAI;GACF,sBAAsB,OAAO,CAAC,GAAG,SAAS,GAAG,WAAW,CAAC;EAC3D,SAAS,OAAO;GAEd,KAAK,MAAM,MAAM,SAAS,OAAO,eAAe,IAAI,EAAE;GACtD,KAAK,MAAM,MAAM,aAAa,OAAO,kBAAkB,IAAI,EAAE;GAC7D,MAAM;EACR,UAAU;GACR,UAAU;EACZ;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,0BAA0B,QAAoB,SAAwB;CACpF,MAAM,QAAQ,gBAAgB,MAAM;CACpC,MAAM,QAAQ,YAAY,IAAI,KAAK;CACnC,IAAI,CAAC,OAAO;CACZ,IAAI,YAAY,KAAA,KAAa,CAAC,MAAM,QAAQ,UAAU,SAAS,KAAK,SAAS,UAAU,GAAG;CAC1F,MAAM;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cA6DM;cAIO;cACA;cACA;;UAGI;EACf,OAAO,mBAAmB;EAC1B,cAAc,mBAAmB;;iBASnB,YAAY,KAAK,eAAe,MAAM;iBAItC,SAAS,KAAK,eAAe,iBAAiB;;iBAK9C,WAAW,KAAK,eAAe,iBAAiB;UAI/C;EACf,SAAS,aAAa;WACb;;WAEA,iBAAiB;;cAgBf;GACV;GACA,iBAAiB;GACjB,eAAe;WAEC;;WAEA,MAAM;EACf;WACS;EACT;EACA;WACS;WACA;EACT;EACA,mBAAmB;EACnB,SAAS,eAAe;EACxB,2BAA2B,eAAe;EAC1C,UAAU;WACD,mBAAmB;WACnB,qBAAqB;WACrB,sBAAsB;EAE/B,gBAAgB;EAChB,kBAAkB;EAClB,kBAAkB;EAClB;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,mBAAmB;EACnB,gBAAgB;EAChB,8BAA8B;EAC9B;EACA;EACA;EACA;EACA;EAEA,YAAY;EACZ,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAe;IAAoB;;EACnC;EACA;EACA;EACA;WACS,mBAAmB;;EAE5B;EACA;EACA;EACA;EACA;EACA,SAAS,SAAS;EAClB,sBAAsB;EACtB,eAAe;EACf,wBAAwB,eAAe,uBAAuB;EAC9D,iBAAiB,sCAAsC;EACvD,eAAe;EACf,eAAe;EACf,mBAAmB;EACnB,qBAAqB;EACrB,qBAAqB;EACrB,yBAAyB;WAChB,uBAAuB;WACvB,uBAAuB;EAChC,sCAAsC;EACtC,wCAAwC;WAC/B,gBAAgB;EACzB,kBAAkB;WACT,WAAW;;EAEpB,oBAAoB;;WAEX,MAAM;WACN;EACT;EACA;EACA,WAAW;;EAEX,iBAAiB;EACjB;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,eAAe;EACf,YAAY;EACZ,UAAU;EACV,WAAW;EACX;EACA;EACA,gBAAgB;WACP,kBAAkB;EAC3B;EACA;EACA;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AA6B;EAS5D,oBAAoB;IAAY;MAAqB;EAWrD,OAAO,mBAAmB,wBAAmB;EAU7C"}
|
package/dist/figma-api/proxy.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getPageBackgrounds, setPageBackgrounds } from "./page-backgrounds.js";
|
|
2
2
|
import { assertNodeEditable } from "../editor/capabilities.js";
|
|
3
3
|
import { parseFigmaPaints, toFigmaPaint } from "./paints.js";
|
|
4
|
+
import { underlyingGraph } from "./graph-ref.js";
|
|
4
5
|
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
5
6
|
import { fitGroupsAround, prepareFollowedFieldEdit } from "./accessor-utils.js";
|
|
6
7
|
import { installInstanceOverrideAccessors } from "./overrides.js";
|
|
7
8
|
import { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from "./slots.js";
|
|
8
9
|
import { installComponentPropertyAccessors } from "./components.js";
|
|
10
|
+
import { installDevStatusAccessors } from "./dev-status.js";
|
|
9
11
|
import { containerTransform, setContainerTransform } from "./transform.js";
|
|
10
12
|
import { installBasicNodeProxyAccessors } from "./accessors/basic.js";
|
|
11
13
|
import { installConnectorNodeProxyAccessors } from "./accessors/connector.js";
|
|
@@ -20,7 +22,6 @@ import { installTextNodeProxyAccessors } from "./accessors/text/index.js";
|
|
|
20
22
|
import { installVariableModeNodeProxyAccessors } from "./accessors/variables.js";
|
|
21
23
|
import { installVectorNodeProxyAccessors } from "./accessors/vector.js";
|
|
22
24
|
import { installVisualNodeProxyAccessors } from "./accessors/visual.js";
|
|
23
|
-
import { installDevStatusAccessors } from "./dev-status.js";
|
|
24
25
|
import { installPluginDataMethods } from "./plugin-data.js";
|
|
25
26
|
import { nodeProxyToJSON } from "./serialization.js";
|
|
26
27
|
import { installShapeWithTextAccessors } from "./shape-with-text.js";
|
|
@@ -58,7 +59,7 @@ var FigmaNodeProxy = class {
|
|
|
58
59
|
[INTERNAL_API];
|
|
59
60
|
constructor(id, graph, api) {
|
|
60
61
|
this[INTERNAL_ID] = id;
|
|
61
|
-
this[INTERNAL_GRAPH] = graph;
|
|
62
|
+
this[INTERNAL_GRAPH] = underlyingGraph(graph);
|
|
62
63
|
this[INTERNAL_API] = api;
|
|
63
64
|
const type = graph.getNode(id)?.type;
|
|
64
65
|
const internals = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode,\n OverflowDirection,\n ScrollBehavior\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installReactionAccessors } from './accessors/reactions'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { flushPendingComponentSync } from './pending-sync'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport type { FigmaReaction } from './reactions'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\n/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */\nexport interface PageHost {\n load: (pageId: string) => Promise<void>\n pageOfNode?: (nodeId: string) => Promise<string | null>\n}\n\n/**\n * How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's\n * members. Without one every page is in memory.\n */\nconst pageHosts = new WeakMap<NodeProxyHost, PageHost>()\n\nexport function setPageHost(api: NodeProxyHost, host: PageHost): void {\n pageHosts.set(api, host)\n}\n\nexport function loadPage(api: NodeProxyHost, pageId: string): Promise<void> {\n return pageHosts.get(api)?.load(pageId) ?? Promise.resolve()\n}\n\n/** The page holding a layer not loaded yet, which loading that page brings in. */\nexport function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null> {\n return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null)\n}\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare overflowDirection: OverflowDirection\n declare scrollBehavior: ScrollBehavior\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */\n declare reactions: readonly FigmaReaction[]\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare readonly openTypeFeatures: Record<string, boolean> | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = graph\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone, as the editor loads a page's layers when it is first visited.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => loadPage(api, id) })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallReactionAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,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nE,OAAO,gBACL,KAAK,iBACL,KAAK,eACL,KAAK,cACL,UACA,YACF;CACF;CAEA,WAAmB;EACjB,MAAM,IAAI,KAAK,KAAK;EACpB,OAAO,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,GAAG;CACxC;CAEA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;AACF;AAEA,+BAA+B,eAAe,WAAW;CACvD,IAAI;CACJ,OAAO;CACP,KAAK;AACP,CAAC;AAED,gCACE,eAAe,WACf;CAAE,IAAI;CAAa,OAAO;CAAgB,KAAK;AAAa,GAC5D,KACF;AAEA,MAAM,iBAAiB;CACrB,IAAI;CACJ,OAAO;CACP,KAAK;AACP;AAEA,gCAAgC,eAAe,WAAW,cAAc;AACxE,gCAAgC,eAAe,WAAW,cAAc;AACxE,mCAAmC,eAAe,WAAW,cAAc;AAC3E,8BAA8B,eAAe,WAAW,gBAAgB,KAAK;AAC7E,wBAAwB,eAAe,WAAW,gBAAgB,KAAK;AACvE,gCAAgC,eAAe,WAAW,cAAc;AACxE,sCAAsC,eAAe,WAAW,cAAc;AAC9E,yBAAyB,eAAe,WAAW,cAAc;AACjE,yBAAyB,eAAe,WAAW,cAAc;AACjE,kCAAkC,eAAe,WAAW,cAAc;AAC1E,iCAAiC,eAAe,WAAW,cAAc;AACzE,qBAAqB,eAAe,WAAW,cAAc;AAC7D,0BAA0B,eAAe,WAAW,cAAc;AAClE,8BAA8B,eAAe,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode,\n OverflowDirection,\n ScrollBehavior\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installReactionAccessors } from './accessors/reactions'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport { underlyingGraph } from './graph-ref'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { flushPendingComponentSync } from './pending-sync'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport type { FigmaReaction } from './reactions'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\n/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */\nexport interface PageHost {\n load: (pageId: string) => Promise<void>\n pageOfNode?: (nodeId: string) => Promise<string | null>\n}\n\n/**\n * How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's\n * members. Without one every page is in memory.\n */\nconst pageHosts = new WeakMap<NodeProxyHost, PageHost>()\n\nexport function setPageHost(api: NodeProxyHost, host: PageHost): void {\n pageHosts.set(api, host)\n}\n\nexport function loadPage(api: NodeProxyHost, pageId: string): Promise<void> {\n return pageHosts.get(api)?.load(pageId) ?? Promise.resolve()\n}\n\n/** The page holding a layer not loaded yet, which loading that page brings in. */\nexport function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null> {\n return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null)\n}\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare overflowDirection: OverflowDirection\n declare scrollBehavior: ScrollBehavior\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */\n declare reactions: readonly FigmaReaction[]\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare readonly openTypeFeatures: Record<string, boolean> | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = underlyingGraph(graph)\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone, as the editor loads a page's layers when it is first visited.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => loadPage(api, id) })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallReactionAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,OAAO,KAAK;;;;;AAYxC,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,YAAY,KAAoB,MAAsB;CACpE,UAAU,IAAI,KAAK,IAAI;AACzB;AAEA,SAAgB,SAAS,KAAoB,QAA+B;CAC1E,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,KAAK,QAAQ,QAAQ;AAC7D;;AAGA,SAAgB,WAAW,KAAoB,QAAwC;CACrF,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,aAAa,MAAM,KAAK,QAAQ,QAAQ,IAAI;AACzE;;AAYA,SAAS,uBACP,OACA,UACA,SACA,QACM;CACN,IAAI,sBAAsB,OAAO,SAAS,QAAQ,GAChD,MAA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