@pairdraw/core 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +74 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +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.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -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 +36 -3
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- 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/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +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/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +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 +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- 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.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +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/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.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/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +26 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +171 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +9 -2
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.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/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.js +3 -3
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.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 +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.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 +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +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/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- 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 +14 -13
- 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/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.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/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.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/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- 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/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -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/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +4 -2
- 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/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +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/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +35 -5
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/pptx/style.js +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +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 +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- 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/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.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/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +8 -5
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- 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.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +112 -10
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- 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/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- 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/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.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 +12 -9
- package/dist/text/index.js +6 -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/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- 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 +3 -1
- package/dist/tools/analyze.js +3 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -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/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -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/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- 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/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +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 +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- 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 +56 -4
- 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 +29 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -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/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -0
- package/dist/tools/read/libraries.js.map +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 +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -5
- 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.d.ts.map +1 -1
- package/dist/tools/registry/core.js +5 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- 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/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.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/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +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 +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- 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 +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- 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 +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- 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/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- 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/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -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/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -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/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- 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 +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
package/dist/layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Direction,\n Display,\n Gutter,\n MeasureMode,\n Overflow,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'\nimport { buildGridTree, createGridChildNode, gridTracksForAxis } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport {\n applyContentInsets,\n applyStrokeMargins,\n contentInsetsSize,\n strokeRoom\n} from './layout/strokes'\nimport {\n autoWidthWrapWidth,\n estimateTextSize,\n getTextMeasurer,\n measureAutoWidthText,\n measureTextForLayout\n} from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlignSelf,\n mapGridTrack,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\n/**\n * The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by\n * recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws\n * an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later\n * layout. Refusing the pass before the call keeps the editor working.\n */\nconst MAX_LAYOUT_DEPTH = 128\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n // The tree is freed on every path, a refused pass included: Yoga's nodes are WebAssembly memory\n // the caller owns, so a throw must not leave them behind.\n let yogaRoot: YogaNode | null = null\n try {\n yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n } finally {\n if (yogaRoot) freeYogaTree(yogaRoot)\n }\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n const insets = keepsSavedFrameSize(graph, frame) ? null : contentInsetsSize(frame)\n const width = insets ? Math.max(frame.width, insets.width) : frame.width\n const height = insets ? Math.max(frame.height, insets.height) : frame.height\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(width)\n else root.setHeight(height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(height)\n else root.setWidth(width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(width)\n if (stretchedAxis === 'height') root.setHeight(height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(width)\n if (heldAxis === 'height') root.setHeight(height)\n\n configureFlexContainer(root, frame, direction)\n\n try {\n insertFlexChildren(root, frame, graph, direction, 1)\n } catch (error) {\n // The depth check refuses a chain while the tree is half built; every node made so far hangs\n // from the root, which has no other holder.\n freeYogaTree(root)\n throw error\n }\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n setFlexFlow(yogaNode, node)\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n applyContentInsets(yogaNode, node)\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\n/**\n * A grid child's box in its flex parent: grow takes the free space, a fixed size is stored, and\n * an axis the grid hugs takes its tracks' size there, as configureAsGrid lays it out.\n */\nfunction applyGridChildBox(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n const hugWidth = ownAxisSizing(child, 'width') === 'HUG'\n const hugHeight = ownAxisSizing(child, 'height') === 'HUG'\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (stretchCross) return\n if (isParentRow) {\n if (!hugHeight) yogaChild.setHeight(child.height)\n } else if (!hugWidth) {\n yogaChild.setWidth(child.width)\n }\n return\n }\n if (isParentRow) {\n if (!hugWidth) yogaChild.setWidth(child.width)\n if (!stretchCross && !hugHeight) yogaChild.setHeight(child.height)\n return\n }\n if (child.gridTemplateRows.length > 0 && !hugHeight) yogaChild.setHeight(child.height)\n if (!stretchCross && !hugWidth) yogaChild.setWidth(child.width)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(gridTracksForAxis(child, 'width').map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(gridTracksForAxis(child, 'height').map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n applyGridChildBox(yogaChild, child, parent)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id)\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL',\n depth: number\n): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n insertFlexChildren(yogaChild, child, graph, direction, depth + 1)\n}\n\n/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */\nfunction insertFlexChildren(\n yogaParent: YogaNode,\n parent: SceneNode,\n graph: SceneGraph,\n direction: 'LTR' | 'RTL',\n depth: number\n): void {\n const box = insertFlowBox(yogaParent, parent)\n const flow: YogaNode[] = []\n for (const child of graph\n .getChildren(parent.id)\n .map((node) => asLaidOutIn(graph, node, parent))) {\n const yogaChild = createYogaNode()\n // Attached before it is configured, so a child the depth check refuses still hangs from the\n // root and is freed with it rather than left in WebAssembly memory.\n box.insertChild(yogaChild, box.getChildCount())\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else {\n if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, parent, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth)\n } else {\n configureChildAsLeaf(yogaChild, child, parent, graph)\n }\n flow.push(yogaChild)\n }\n applyStrokeMargins(yogaChild, child, parent)\n }\n setFlowEdges(yogaParent, box, parent, flow, direction)\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') {\n // A truncating text keeps the box it has, as Figma clips it to that box.\n if (child.width > 0 && child.height > 0) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n }\n return\n }\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n // A truncating or fixed text keeps its box, so Yoga measures only text that grows.\n const needsMeasureFunc = isText && textMeasurer && growsText(child)\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\n/** Whether layout measures a text to size it, which only the two growing modes need. */\nfunction growsText(node: SceneNode): boolean {\n return node.textAutoResize === 'WIDTH_AND_HEIGHT' || node.textAutoResize === 'HEIGHT'\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child))\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgEA,SAAgB,cAAc,OAAmB,SAAuB;CACtE,MAAM,0BAA0B,sBAAsB,OAAO,OAAO,CAAC;AACvE;;;;;;;AAQA,MAAM,mBAAmB;AAEzB,SAAS,sBAAsB,OAAmB,SAAuB;CACvE,MAAM,QAAQ,MAAM,QAAQ,OAAO;CACnC,IAAI,CAAC,SAAS,MAAM,eAAe,QAAQ;CAE3C,sBAAsB,OAAO,KAAK;CAElC,MAAM,gBAAgB,+BAA+B,OAAO,KAAK;CACjE,MAAM,gBAAgB,kBAAkB,QAAQ,UAAU,MAAM,UAAU;CAG1E,IAAI,WAA4B;CAChC,IAAI;EACF,WACE,MAAM,eAAe,SACjB,cAAc,OAAO,OAAO,aAAa,IACzC,cAAc,OAAO,OAAO,aAAa;EAC/C,SAAS,gBAAgB,KAAA,GAAW,KAAA,GAAW,aAAa;EAC5D,gBAAgB,OAAO,OAAO,UAAU,qBAAqB;CAC/D,UAAU;EACR,IAAI,UAAU,aAAa,QAAQ;CACrC;AACF;AACA,SAAS,+BACP,OACA,MACe;CACf,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,MAAM,qBAAqB,SAAS,+BAA+B,OAAO,MAAM,IAAI;CACpF,OAAO,2BAA2B,MAAM,kBAAkB;AAC5D;AAEA,SAA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,MAAM;GAC1B,OAAO;EACT,CAAC;CACH,OAAO,IAAI,eAAe,UAAU;EAClC,MAAM,aAAa,uBACd,MAAM,eAAe,SAAS,MAAM,QACrC,MAAM;EAEV,IAAI,MAAM,cAAc,KAAK,CAAC,YAC5B,UAAU,SAAS,UAAU;EAE/B,UAAU,gBAAgB,OAAO,WAAW,SAAS,gBAAgB;GACnE,IAAI,cAAc;GAClB,IAAI,YACE;QAAA,cAAc,YAAY,WAAW,cAAc;GAAA,OAClD,IAAI,cAAc,YAAY,WACnC,cAAc,KAAK,IAAI,OAAO,cAAc,KAAK;GAEnD,MAAM,WAAW,KAAK,MAAM,WAAW;GACvC,MAAM,SAAS,MAAM,IAAI,QAAQ;GACjC,IAAI,QAAQ,OAAO;GAEnB,IAAI,gBAAgB,MAAM,UAAU,MAAM,mBAAmB,UAAU,KAAK,GAC1E,OAAO;IAAE,OAAO;IAAa,QAAQ,MAAM;GAAO;GAEpD,MAAM,SAAS;IAAE,OAAO;IAAa,QAAQ,qBAAqB,OAAO,WAAW,CAAC,CAAC;GAAO;GAC7F,MAAM,IAAI,UAAU,MAAM;GAC1B,OAAO;EACT,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Direction,\n Display,\n Gutter,\n MeasureMode,\n Overflow,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'\nimport { buildGridTree, createGridChildNode, gridTracksForAxis } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport * from './layout/auto-layout-handles'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n measureTextForLayout,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { enforcedAspectRatio, layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport {\n applyContentInsets,\n applyStrokeMargins,\n contentInsetsSize,\n strokeRoom\n} from './layout/strokes'\nimport {\n autoWidthWrapWidth,\n estimateTextSize,\n getTextMeasurer,\n measureAutoWidthText,\n measureTextForLayout\n} from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlignSelf,\n mapGridTrack,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\n/**\n * The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by\n * recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws\n * an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later\n * layout. Refusing the pass before the call keeps the editor working.\n */\nconst MAX_LAYOUT_DEPTH = 128\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n // The tree is freed on every path, a refused pass included: Yoga's nodes are WebAssembly memory\n // the caller owns, so a throw must not leave them behind.\n let yogaRoot: YogaNode | null = null\n try {\n yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n } finally {\n if (yogaRoot) freeYogaTree(yogaRoot)\n }\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n const insets = keepsSavedFrameSize(graph, frame) ? null : contentInsetsSize(frame)\n const width = insets ? Math.max(frame.width, insets.width) : frame.width\n const height = insets ? Math.max(frame.height, insets.height) : frame.height\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(width)\n else root.setHeight(height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(height)\n else root.setWidth(width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(width)\n if (stretchedAxis === 'height') root.setHeight(height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(width)\n if (heldAxis === 'height') root.setHeight(height)\n\n configureFlexContainer(root, frame, direction)\n\n try {\n insertFlexChildren(root, frame, graph, direction, 1)\n } catch (error) {\n // The depth check refuses a chain while the tree is half built; every node made so far hangs\n // from the root, which has no other holder.\n freeYogaTree(root)\n throw error\n }\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n setFlexFlow(yogaNode, node)\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n applyContentInsets(yogaNode, node)\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\n/**\n * A grid child's box in its flex parent: grow takes the free space, a fixed size is stored, and\n * an axis the grid hugs takes its tracks' size there, as configureAsGrid lays it out.\n */\nfunction applyGridChildBox(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n const hugWidth = ownAxisSizing(child, 'width') === 'HUG'\n const hugHeight = ownAxisSizing(child, 'height') === 'HUG'\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (stretchCross) return\n if (isParentRow) {\n if (!hugHeight) yogaChild.setHeight(child.height)\n } else if (!hugWidth) {\n yogaChild.setWidth(child.width)\n }\n return\n }\n if (isParentRow) {\n if (!hugWidth) yogaChild.setWidth(child.width)\n if (!stretchCross && !hugHeight) yogaChild.setHeight(child.height)\n return\n }\n if (child.gridTemplateRows.length > 0 && !hugHeight) yogaChild.setHeight(child.height)\n if (!stretchCross && !hugWidth) yogaChild.setWidth(child.width)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(gridTracksForAxis(child, 'width').map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(gridTracksForAxis(child, 'height').map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n applyGridChildBox(yogaChild, child, parent)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id)\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\n/**\n * Whether the parent's pass places this child from the size it holds: neither its content nor the\n * parent decides its size, so its own cells keep their places while the parent moves it.\n */\nfunction placesFromSize(\n child: SceneNode,\n parent: SceneNode,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): boolean {\n return (\n widthSizing === 'FIXED' &&\n heightSizing === 'FIXED' &&\n child.layoutGrow === 0 &&\n parent.counterAxisAlign !== 'BASELINE' &&\n child.layoutAlignSelf !== 'BASELINE' &&\n enforcedAspectRatio(child) === null &&\n child.minWidth === null &&\n child.maxWidth === null &&\n child.minHeight === null &&\n child.maxHeight === null\n )\n}\n\n/**\n * Refuses a chain deeper than Yoga can lay out, for the subtrees a pass places from their size and\n * does not build: the same refusal, without the Yoga nodes.\n */\nfunction assertLayoutDepth(graph: SceneGraph, frame: SceneNode, depth: number): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n for (const child of graph.getChildren(frame.id)) {\n if (child.layoutMode === 'NONE' || !child.visible) continue\n if (child.layoutPositioning === 'ABSOLUTE') continue\n assertLayoutDepth(graph, child, depth + 1)\n }\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL',\n depth: number\n): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n if (placesFromSize(child, parent, widthSizing, heightSizing)) {\n assertLayoutDepth(graph, child, depth + 1)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n insertFlexChildren(yogaChild, child, graph, direction, depth + 1)\n}\n\n/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */\nfunction insertFlexChildren(\n yogaParent: YogaNode,\n parent: SceneNode,\n graph: SceneGraph,\n direction: 'LTR' | 'RTL',\n depth: number\n): void {\n const box = insertFlowBox(yogaParent, parent)\n const flow: YogaNode[] = []\n for (const child of graph\n .getChildren(parent.id)\n .map((node) => asLaidOutIn(graph, node, parent))) {\n const yogaChild = createYogaNode()\n // Attached before it is configured, so a child the depth check refuses still hangs from the\n // root and is freed with it rather than left in WebAssembly memory.\n box.insertChild(yogaChild, box.getChildCount())\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else {\n if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, parent, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth)\n } else {\n configureChildAsLeaf(yogaChild, child, parent, graph)\n }\n flow.push(yogaChild)\n }\n applyStrokeMargins(yogaChild, child, parent)\n }\n setFlowEdges(yogaParent, box, parent, flow, direction)\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') {\n // A truncating text keeps the box it has, as Figma clips it to that box.\n if (child.width > 0 && child.height > 0) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n }\n return\n }\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n // A truncating or fixed text keeps its box, so Yoga measures only text that grows.\n const needsMeasureFunc = isText && textMeasurer && growsText(child)\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\n/** Whether layout measures a text to size it, which only the two growing modes need. */\nfunction growsText(node: SceneNode): boolean {\n return node.textAutoResize === 'WIDTH_AND_HEIGHT' || node.textAutoResize === 'HEIGHT'\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child))\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,SAAgB,cAAc,OAAmB,SAAuB;CACtE,MAAM,0BAA0B,sBAAsB,OAAO,OAAO,CAAC;AACvE;;;;;;;AAQA,MAAM,mBAAmB;AAEzB,SAAS,sBAAsB,OAAmB,SAAuB;CACvE,MAAM,QAAQ,MAAM,QAAQ,OAAO;CACnC,IAAI,CAAC,SAAS,MAAM,eAAe,QAAQ;CAE3C,sBAAsB,OAAO,KAAK;CAElC,MAAM,gBAAgB,+BAA+B,OAAO,KAAK;CACjE,MAAM,gBAAgB,kBAAkB,QAAQ,UAAU,MAAM,UAAU;CAG1E,IAAI,WAA4B;CAChC,IAAI;EACF,WACE,MAAM,eAAe,SACjB,cAAc,OAAO,OAAO,aAAa,IACzC,cAAc,OAAO,OAAO,aAAa;EAC/C,SAAS,gBAAgB,KAAA,GAAW,KAAA,GAAW,aAAa;EAC5D,gBAAgB,OAAO,OAAO,UAAU,qBAAqB;CAC/D,UAAU;EACR,IAAI,UAAU,aAAa,QAAQ;CACrC;AACF;AACA,SAAS,+BACP,OACA,MACe;CACf,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,MAAM,qBAAqB,SAAS,+BAA+B,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AU,KAAK,GAC1E,OAAO;IAAE,OAAO;IAAa,QAAQ,MAAM;GAAO;GAEpD,MAAM,SAAS;IAAE,OAAO;IAAa,QAAQ,qBAAqB,OAAO,WAAW,CAAC,CAAC;GAAO;GAC7F,MAAM,IAAI,UAAU,MAAM;GAC1B,OAAO;EACT,CAAC;CACH;AACF"}
|
package/dist/lint/fixes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixes.d.ts","names":[],"sources":["../../src/lint/fixes.ts"],"mappings":";;;;UAUiB;EACf;EACA,KAAK;;;;;;UAOU;WACN,OAAO;EAChB,WAAW,gBAAgB,SAAS,QAAQ;EAC5C,aAAa,gBAAgB,cAAc;EAC3C,eAAe;;EAEf,YAAY;;iBAGE,eAAe,OAAO,aAAa;;iBAanC,UAAU,mBAAmB,gBAAgB;;;;;;
|
|
1
|
+
{"version":3,"file":"fixes.d.ts","names":[],"sources":["../../src/lint/fixes.ts"],"mappings":";;;;UAUiB;EACf;EACA,KAAK;;;;;;UAOU;WACN,OAAO;EAChB,WAAW,gBAAgB,SAAS,QAAQ;EAC5C,aAAa,gBAAgB,cAAc;EAC3C,eAAe;;EAEf,YAAY;;iBAGE,eAAe,OAAO,aAAa;;iBAanC,UAAU,mBAAmB,gBAAgB;;;;;;iBAwD7C,eAAe,QAAQ,eAAe,mBAAmB"}
|
package/dist/lint/fixes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ownsComponentTree } from "./utils.js";
|
|
2
|
-
import { paintBindingTarget } from "@pairdraw/scene-graph/variables";
|
|
3
|
-
import { isEmptyObject } from "es-toolkit";
|
|
2
|
+
import { isNumericVariableBindingField, paintBindingTarget } from "@pairdraw/scene-graph/variables";
|
|
4
3
|
import { colorToHex } from "@pairdraw/scene-graph/color";
|
|
4
|
+
import { isEmptyObject } from "es-toolkit";
|
|
5
5
|
//#region src/lint/fixes.ts
|
|
6
6
|
function graphFixTarget(graph) {
|
|
7
7
|
return {
|
|
@@ -22,11 +22,17 @@ function safeFixes(messages) {
|
|
|
22
22
|
}] : []);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Binding is safe only while the paint still shows the variable's color
|
|
26
|
-
* the lint run would change appearance, so its fix is
|
|
25
|
+
* Binding is safe only while the paint still shows the variable's color, or the field still holds
|
|
26
|
+
* the variable's number: one edited since the lint run would change appearance, so its fix is
|
|
27
|
+
* skipped.
|
|
27
28
|
*/
|
|
28
29
|
function canBind(graph, node, path, variableId) {
|
|
29
30
|
if (node.boundVariables[path] === variableId) return false;
|
|
31
|
+
if (isNumericVariableBindingField(path)) {
|
|
32
|
+
if (path === "fontSize" && node.textStyleId) return false;
|
|
33
|
+
const value = Reflect.get(node, path);
|
|
34
|
+
return typeof value === "number" && value === graph.resolveNumberVariableForNode(node.id, variableId);
|
|
35
|
+
}
|
|
30
36
|
const target = paintBindingTarget(path);
|
|
31
37
|
if (!target) return false;
|
|
32
38
|
const paint = node[target.list].at(target.index);
|
package/dist/lint/fixes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixes.js","names":[],"sources":["../../src/lint/fixes.ts"],"sourcesContent":["import { isEmptyObject } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { paintBindingTarget } from '@pairdraw/scene-graph/variables'\n\nimport type { LintFix, LintMessage } from './types'\nimport { ownsComponentTree } from './utils'\n\n/** A fix for the layer it was reported on. A `LintMessage` with a `fix` is one. */\nexport interface LintFixRequest {\n nodeId: string\n fix: LintFix\n}\n\n/**\n * Where fixes are written. The editor supplies undoable actions; headless callers write the\n * graph directly with {@link graphFixTarget}.\n */\nexport interface LintFixTarget {\n readonly graph: SceneGraph\n updateNode(nodeId: string, changes: Partial<SceneNode>): void\n bindVariable(nodeId: string, path: string, variableId: string): void\n convertToFrame(nodeId: string): void\n /** Deletes layers with their children; none of them is inside another. */\n deleteNodes(nodeIds: readonly string[]): void\n}\n\nexport function graphFixTarget(graph: SceneGraph): LintFixTarget {\n return {\n graph,\n updateNode: (nodeId, changes) => graph.updateNode(nodeId, changes),\n bindVariable: (nodeId, path, variableId) => graph.bindVariable(nodeId, path, variableId),\n convertToFrame: (nodeId) => graph.updateNode(nodeId, { type: 'FRAME' }),\n deleteNodes: (nodeIds) => {\n for (const nodeId of nodeIds) graph.deleteNode(nodeId)\n }\n }\n}\n\n/** The safe fixes of a lint run, which apply together without review. */\nexport function safeFixes(messages: readonly LintMessage[]): LintFixRequest[] {\n return messages.flatMap(({ nodeId, fix }) => (fix ? [{ nodeId, fix }] : []))\n}\n\n/**\n * Binding is safe only while the paint still shows the variable's color
|
|
1
|
+
{"version":3,"file":"fixes.js","names":[],"sources":["../../src/lint/fixes.ts"],"sourcesContent":["import { isEmptyObject } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { isNumericVariableBindingField, paintBindingTarget } from '@pairdraw/scene-graph/variables'\n\nimport type { LintFix, LintMessage } from './types'\nimport { ownsComponentTree } from './utils'\n\n/** A fix for the layer it was reported on. A `LintMessage` with a `fix` is one. */\nexport interface LintFixRequest {\n nodeId: string\n fix: LintFix\n}\n\n/**\n * Where fixes are written. The editor supplies undoable actions; headless callers write the\n * graph directly with {@link graphFixTarget}.\n */\nexport interface LintFixTarget {\n readonly graph: SceneGraph\n updateNode(nodeId: string, changes: Partial<SceneNode>): void\n bindVariable(nodeId: string, path: string, variableId: string): void\n convertToFrame(nodeId: string): void\n /** Deletes layers with their children; none of them is inside another. */\n deleteNodes(nodeIds: readonly string[]): void\n}\n\nexport function graphFixTarget(graph: SceneGraph): LintFixTarget {\n return {\n graph,\n updateNode: (nodeId, changes) => graph.updateNode(nodeId, changes),\n bindVariable: (nodeId, path, variableId) => graph.bindVariable(nodeId, path, variableId),\n convertToFrame: (nodeId) => graph.updateNode(nodeId, { type: 'FRAME' }),\n deleteNodes: (nodeIds) => {\n for (const nodeId of nodeIds) graph.deleteNode(nodeId)\n }\n }\n}\n\n/** The safe fixes of a lint run, which apply together without review. */\nexport function safeFixes(messages: readonly LintMessage[]): LintFixRequest[] {\n return messages.flatMap(({ nodeId, fix }) => (fix ? [{ nodeId, fix }] : []))\n}\n\n/**\n * Binding is safe only while the paint still shows the variable's color, or the field still holds\n * the variable's number: one edited since the lint run would change appearance, so its fix is\n * skipped.\n */\nfunction canBind(graph: SceneGraph, node: SceneNode, path: string, variableId: string): boolean {\n if (node.boundVariables[path] === variableId) return false\n if (isNumericVariableBindingField(path)) {\n // A text style supplies the layer's type values; the binding belongs on the style.\n if (path === 'fontSize' && node.textStyleId) return false\n const value: unknown = Reflect.get(node, path)\n return (\n typeof value === 'number' && value === graph.resolveNumberVariableForNode(node.id, variableId)\n )\n }\n const target = paintBindingTarget(path)\n if (!target) return false\n const paint = node[target.list].at(target.index)\n const color = graph.resolveColorVariableForNode(node.id, variableId)\n if (!paint || !color || ('type' in paint && paint.type !== 'SOLID')) return false\n return colorToHex({ ...paint.color, a: 1 }) === colorToHex({ ...color, a: 1 })\n}\n\nfunction* ancestors(graph: SceneGraph, node: SceneNode): Generator<SceneNode> {\n for (let id = node.parentId; id;) {\n const parent = graph.getNode(id)\n if (!parent) return\n yield parent\n id = parent.parentId\n }\n}\n\n/**\n * Structural fixes apply only where the layer's structure is the user's to change: not locked,\n * and not inside a component or an instance.\n */\nfunction canRestructure(graph: SceneGraph, node: SceneNode): boolean {\n if (node.locked) return false\n for (const parent of ancestors(graph, node)) if (ownsComponentTree(parent.type)) return false\n return true\n}\n\nfunction hasAncestorIn(graph: SceneGraph, node: SceneNode, ids: ReadonlySet<string>): boolean {\n for (const parent of ancestors(graph, node)) if (ids.has(parent.id)) return true\n return false\n}\n\n/**\n * Applies fixes that still hold against the current graph. Changes to one layer merge into a\n * single update, and deletions run last so other fixes still find their layers. Returns the\n * number of fixes applied.\n */\nexport function applyLintFixes(target: LintFixTarget, requests: readonly LintFixRequest[]): number {\n const { graph } = target\n const updates = new Map<string, Partial<SceneNode>>()\n const conversions = new Set<string>()\n const deletions = new Set<string>()\n let applied = 0\n for (const { nodeId, fix } of requests) {\n const node = graph.getNode(nodeId)\n if (!node) continue\n switch (fix.kind) {\n case 'bind-variable':\n if (!canBind(graph, node, fix.path, fix.variableId)) continue\n target.bindVariable(nodeId, fix.path, fix.variableId)\n break\n case 'set': {\n const changes = Object.fromEntries(\n Object.entries(fix.changes).filter(([key, value]) => Reflect.get(node, key) !== value)\n )\n if (isEmptyObject(changes)) continue\n updates.set(nodeId, { ...updates.get(nodeId), ...changes })\n break\n }\n case 'convert-to-frame':\n if (node.type !== 'GROUP' || conversions.has(nodeId) || !canRestructure(graph, node))\n continue\n conversions.add(nodeId)\n break\n case 'delete':\n // Only a layer that is still hidden: one shown since the check is in use.\n if (node.visible || deletions.has(nodeId) || !canRestructure(graph, node)) continue\n deletions.add(nodeId)\n break\n }\n applied++\n }\n for (const [nodeId, changes] of updates) target.updateNode(nodeId, changes)\n for (const nodeId of conversions) target.convertToFrame(nodeId)\n const roots = [...deletions].filter((nodeId) => {\n const node = graph.getNode(nodeId)\n return node ? !hasAncestorIn(graph, node, deletions) : false\n })\n if (roots.length > 0) target.deleteNodes(roots)\n return applied\n}\n"],"mappings":";;;;;AA4BA,SAAgB,eAAe,OAAkC;CAC/D,OAAO;EACL;EACA,aAAa,QAAQ,YAAY,MAAM,WAAW,QAAQ,OAAO;EACjE,eAAe,QAAQ,MAAM,eAAe,MAAM,aAAa,QAAQ,MAAM,UAAU;EACvF,iBAAiB,WAAW,MAAM,WAAW,QAAQ,EAAE,MAAM,QAAQ,CAAC;EACtE,cAAc,YAAY;GACxB,KAAK,MAAM,UAAU,SAAS,MAAM,WAAW,MAAM;EACvD;CACF;AACF;;AAGA,SAAgB,UAAU,UAAoD;CAC5E,OAAO,SAAS,SAAS,EAAE,QAAQ,UAAW,MAAM,CAAC;EA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AI,MAAM,SAAS,GAAG,OAAO,YAAY,KAAK;CAC9C,OAAO;AACT"}
|
package/dist/lint/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Category, LintConfig, LintFix, LintFixProperty, LintMessage, LintMessageData, LintNode, LintResult, Rule, RuleContext, RuleMeta, Severity } from "./types.js";
|
|
1
|
+
import { Category, LintConfig, LintDesignMemory, LintFix, LintFixProperty, LintMessage, LintMessageData, LintNode, LintResult, Rule, RuleContext, RuleMeta, Severity } from "./types.js";
|
|
2
2
|
import { Linter, createLinter } from "./linter.js";
|
|
3
3
|
import { defineRule } from "./rule.js";
|
|
4
4
|
import { LintFixRequest, LintFixTarget, applyLintFixes, graphFixTarget, safeFixes } from "./fixes.js";
|
|
5
5
|
import { allRules } from "./rules/index.js";
|
|
6
|
+
import { DESIGN_MEMORY_RULE_IDS } from "./rules/design-memory.js";
|
|
6
7
|
import { accessibility, presets, recommended, strict } from "./presets.js";
|
|
7
|
-
export { type Category, type LintConfig, type LintFix, type LintFixProperty, type LintFixRequest, type LintFixTarget, type LintMessage, type LintMessageData, type LintNode, type LintResult, Linter, type Rule, type RuleContext, type RuleMeta, type Severity, accessibility, allRules, applyLintFixes, createLinter, defineRule, graphFixTarget, presets, recommended, safeFixes, strict };
|
|
8
|
+
export { type Category, DESIGN_MEMORY_RULE_IDS, type LintConfig, type LintDesignMemory, type LintFix, type LintFixProperty, type LintFixRequest, type LintFixTarget, type LintMessage, type LintMessageData, type LintNode, type LintResult, Linter, type Rule, type RuleContext, type RuleMeta, type Severity, accessibility, allRules, applyLintFixes, createLinter, defineRule, graphFixTarget, presets, recommended, safeFixes, strict };
|
package/dist/lint/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { applyLintFixes, graphFixTarget, safeFixes } from "./fixes.js";
|
|
2
2
|
import { accessibility, presets, recommended, strict } from "./presets.js";
|
|
3
3
|
import { defineRule } from "./rule.js";
|
|
4
|
+
import { DESIGN_MEMORY_RULE_IDS } from "./rules/design-memory.js";
|
|
4
5
|
import { allRules } from "./rules/index.js";
|
|
5
6
|
import { Linter, createLinter } from "./linter.js";
|
|
6
|
-
export { Linter, accessibility, allRules, applyLintFixes, createLinter, defineRule, graphFixTarget, presets, recommended, safeFixes, strict };
|
|
7
|
+
export { DESIGN_MEMORY_RULE_IDS, Linter, accessibility, allRules, applyLintFixes, createLinter, defineRule, graphFixTarget, presets, recommended, safeFixes, strict };
|
package/dist/lint/linter.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ declare class Linter {
|
|
|
11
11
|
private nodes;
|
|
12
12
|
private variables;
|
|
13
13
|
private sharedStyleTypes;
|
|
14
|
+
private design;
|
|
15
|
+
/** Rules the configuration names, which a document's design memory does not override. */
|
|
16
|
+
private configured;
|
|
17
|
+
/** The only rules to run, when the caller named them. */
|
|
18
|
+
private only;
|
|
14
19
|
constructor(options?: {
|
|
15
20
|
config?: LintConfig;
|
|
16
21
|
preset?: string;
|
|
@@ -23,6 +28,13 @@ declare class Linter {
|
|
|
23
28
|
*/
|
|
24
29
|
private nodeFor;
|
|
25
30
|
private toLintNode;
|
|
31
|
+
/**
|
|
32
|
+
* The document's design memory, which its own rules check layers against. A memory's group
|
|
33
|
+
* replaces the generic scale rule for the same values.
|
|
34
|
+
*/
|
|
35
|
+
private describeDesign;
|
|
36
|
+
/** The rules this run checks with their settings: the configured ones and the memory's. */
|
|
37
|
+
private activeRules;
|
|
26
38
|
private ruleChecks;
|
|
27
39
|
private lintNode;
|
|
28
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","names":[],"sources":["../../src/lint/linter.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"linter.d.ts","names":[],"sources":["../../src/lint/linter.ts"],"mappings":";;;cAoDa;UACH;UACA;UACA;UACA;;UAEA;UACA;UACA;UAKA;UACA;;UAEA;;UAEA;EAEI,YAAA;IAAW,SAAS;IAAY;IAAiB;;EA2B7D,UAAU,OAAO,YAAY,qBAAqB;;;;;UAyB1C;UAWA;;;;;UAmEA;;UAmBA;UA4BA;UAuCA;;iBA0EM,aAAa;EAAY,SAAS;EAAY;EAAiB;IAAkB"}
|
package/dist/lint/linter.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { getNodePath } from "./utils.js";
|
|
2
|
+
import { currentDesignRules } from "../design-memory/document.js";
|
|
3
|
+
import { designViolations } from "../design-memory/check.js";
|
|
2
4
|
import { presets } from "./presets.js";
|
|
5
|
+
import { DESIGN_MEMORY_RULE_IDS, designMemoryRules } from "./rules/design-memory.js";
|
|
3
6
|
import { allRules } from "./rules/index.js";
|
|
7
|
+
import { colorToHex } from "@pairdraw/scene-graph/color";
|
|
4
8
|
import { sharedStyleLayers, sharedStyleTypeForKind } from "@pairdraw/scene-graph/shared-styles";
|
|
5
9
|
import { uniq } from "es-toolkit";
|
|
6
|
-
import {
|
|
10
|
+
import { variableNamespace } from "@pairdraw/dom-css/export";
|
|
11
|
+
import { DESIGN_MEMORY_GROUPS, cachedDesignMemory } from "@pairdraw/scene-graph/design-memory";
|
|
7
12
|
//#region src/lint/linter.ts
|
|
8
13
|
/** The size and weight of each stretch of a text layer's characters, as the canvas draws them. */
|
|
9
14
|
function effectiveTextStyles(node) {
|
|
@@ -17,6 +22,12 @@ function effectiveTextStyles(node) {
|
|
|
17
22
|
}));
|
|
18
23
|
return node.styleRuns.reduce((total, run) => total + run.length, 0) < node.text.length || runs.length === 0 ? [base, ...runs] : runs;
|
|
19
24
|
}
|
|
25
|
+
/** How mild each reported severity is, so a finding can only soften its rule's. */
|
|
26
|
+
const SEVERITY_RANK = {
|
|
27
|
+
error: 0,
|
|
28
|
+
warning: 1,
|
|
29
|
+
info: 2
|
|
30
|
+
};
|
|
20
31
|
/** A preset's rules, refusing a name no preset has so a typo cannot silently disable linting. */
|
|
21
32
|
function presetRules(id) {
|
|
22
33
|
if (!Object.hasOwn(presets, id)) {
|
|
@@ -40,9 +51,15 @@ var Linter = class {
|
|
|
40
51
|
STRING: 0,
|
|
41
52
|
BOOLEAN: 0
|
|
42
53
|
},
|
|
43
|
-
colorsByHex: /* @__PURE__ */ new Map()
|
|
54
|
+
colorsByHex: /* @__PURE__ */ new Map(),
|
|
55
|
+
numbersByField: /* @__PURE__ */ new Map()
|
|
44
56
|
};
|
|
45
57
|
sharedStyleTypes = /* @__PURE__ */ new Map();
|
|
58
|
+
design = null;
|
|
59
|
+
/** Rules the configuration names, which a document's design memory does not override. */
|
|
60
|
+
configured = /* @__PURE__ */ new Set();
|
|
61
|
+
/** The only rules to run, when the caller named them. */
|
|
62
|
+
only = null;
|
|
46
63
|
constructor(options = {}) {
|
|
47
64
|
let baseConfig = {};
|
|
48
65
|
if (options.preset) baseConfig = { ...presetRules(options.preset) };
|
|
@@ -57,6 +74,8 @@ var Linter = class {
|
|
|
57
74
|
...baseConfig,
|
|
58
75
|
...options.config.rules
|
|
59
76
|
};
|
|
77
|
+
this.configured = new Set(Object.keys(options.config?.rules ?? {}));
|
|
78
|
+
this.only = options.rules ? new Set(options.rules) : null;
|
|
60
79
|
const rulesToLoad = options.rules ?? Object.keys(baseConfig);
|
|
61
80
|
for (const ruleId of rulesToLoad) {
|
|
62
81
|
if (!Object.hasOwn(allRules, ruleId)) throw new Error(`Unknown lint rule "${ruleId}"`);
|
|
@@ -74,11 +93,13 @@ var Linter = class {
|
|
|
74
93
|
this.graph = graph;
|
|
75
94
|
this.variables = describeVariables(graph);
|
|
76
95
|
this.sharedStyleTypes = sharedStyleTypes(graph);
|
|
96
|
+
this.design = this.describeDesign(graph);
|
|
77
97
|
this.checks = this.ruleChecks();
|
|
78
98
|
const roots = rootIds && rootIds.length > 0 ? rootIds : graph.getPages().map((p) => p.id);
|
|
79
99
|
for (const id of outermostRoots(graph, roots)) this.lintNode(id, void 0);
|
|
80
100
|
this.graph = null;
|
|
81
101
|
this.checks = [];
|
|
102
|
+
this.design = null;
|
|
82
103
|
return {
|
|
83
104
|
messages: this.messages,
|
|
84
105
|
errorCount: this.messages.filter((m) => m.severity === "error").length,
|
|
@@ -151,27 +172,80 @@ var Linter = class {
|
|
|
151
172
|
effects: raw.effects.map((effect) => ({
|
|
152
173
|
type: effect.type,
|
|
153
174
|
visible: effect.visible,
|
|
154
|
-
radius: effect.type === "SHADER" ? 0 : effect.radius
|
|
175
|
+
radius: effect.type === "SHADER" || effect.type === "NOISE" ? 0 : effect.radius
|
|
155
176
|
})),
|
|
156
177
|
textStyleId: raw.textStyleId,
|
|
157
178
|
effectStyleId: raw.effectStyleId
|
|
158
179
|
};
|
|
159
180
|
}
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
/**
|
|
182
|
+
* The document's design memory, which its own rules check layers against. A memory's group
|
|
183
|
+
* replaces the generic scale rule for the same values.
|
|
184
|
+
*/
|
|
185
|
+
describeDesign(graph) {
|
|
186
|
+
const memory = cachedDesignMemory(graph);
|
|
187
|
+
if (!memory) return null;
|
|
188
|
+
const rules = currentDesignRules(graph, memory);
|
|
189
|
+
const found = /* @__PURE__ */ new Map();
|
|
190
|
+
return {
|
|
191
|
+
rules,
|
|
192
|
+
violations: (node) => {
|
|
193
|
+
const cached = found.get(node.id);
|
|
194
|
+
if (cached) return cached;
|
|
195
|
+
const raw = graph.getNode(node.id);
|
|
196
|
+
const violations = raw ? designViolations(rules, raw) : [];
|
|
197
|
+
found.set(node.id, violations);
|
|
198
|
+
return violations;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/** The rules this run checks with their settings: the configured ones and the memory's. */
|
|
203
|
+
activeRules() {
|
|
204
|
+
const active = [];
|
|
205
|
+
const rules = this.design?.rules;
|
|
206
|
+
const superseded = /* @__PURE__ */ new Set();
|
|
207
|
+
if (rules && rules.spacing.enforce !== "off") superseded.add("consistent-spacing");
|
|
208
|
+
if (rules && rules.radius.enforce !== "off") superseded.add("consistent-radius");
|
|
162
209
|
for (const [ruleId, rule] of this.rules) {
|
|
210
|
+
if (ruleId in designMemoryRules && !rules) continue;
|
|
211
|
+
if (superseded.has(ruleId) && !this.configured.has(ruleId)) continue;
|
|
163
212
|
const config = this.ruleConfigs.get(ruleId);
|
|
164
|
-
if (
|
|
213
|
+
if (config) active.push([
|
|
214
|
+
ruleId,
|
|
215
|
+
rule,
|
|
216
|
+
config
|
|
217
|
+
]);
|
|
218
|
+
}
|
|
219
|
+
if (!rules) return active;
|
|
220
|
+
for (const group of DESIGN_MEMORY_GROUPS) {
|
|
221
|
+
const ruleId = DESIGN_MEMORY_RULE_IDS[group];
|
|
222
|
+
if (this.ruleConfigs.get(ruleId) || this.configured.has(ruleId)) continue;
|
|
223
|
+
if (this.only && !this.only.has(ruleId)) continue;
|
|
224
|
+
const enforce = rules[group].enforce;
|
|
225
|
+
if (enforce === "off") continue;
|
|
226
|
+
active.push([
|
|
227
|
+
ruleId,
|
|
228
|
+
designMemoryRules[ruleId],
|
|
229
|
+
{ severity: enforce === "refuse" ? "error" : "warning" }
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
return active;
|
|
233
|
+
}
|
|
234
|
+
ruleChecks() {
|
|
235
|
+
const checks = [];
|
|
236
|
+
for (const [ruleId, rule, config] of this.activeRules()) {
|
|
237
|
+
if (config.severity === "off") continue;
|
|
165
238
|
const severity = config.severity;
|
|
166
239
|
checks.push({
|
|
167
240
|
rule,
|
|
168
241
|
context: {
|
|
169
242
|
variables: this.variables,
|
|
170
243
|
isSharedStyle: (kind, id) => id !== null && this.sharedStyleTypes.get(id) === sharedStyleTypeForKind(kind),
|
|
171
|
-
|
|
244
|
+
design: this.design,
|
|
245
|
+
report: ({ node, message, suggest, data, fix, suggestions, severity: milder }) => {
|
|
172
246
|
this.messages.push({
|
|
173
247
|
ruleId,
|
|
174
|
-
severity,
|
|
248
|
+
severity: milder && SEVERITY_RANK[milder] > SEVERITY_RANK[severity] ? milder : severity,
|
|
175
249
|
message,
|
|
176
250
|
nodeId: node.id,
|
|
177
251
|
nodeName: node.name,
|
|
@@ -221,6 +295,18 @@ function sharedStyleTypes(graph) {
|
|
|
221
295
|
for (const [id, style] of sharedStyleLayers(graph)) if (style.sharedStyleType) types.set(id, style.sharedStyleType);
|
|
222
296
|
return types;
|
|
223
297
|
}
|
|
298
|
+
/** The layer fields each Tailwind namespace of number tokens sets. */
|
|
299
|
+
const NAMESPACE_FIELDS = {
|
|
300
|
+
radius: ["cornerRadius"],
|
|
301
|
+
spacing: [
|
|
302
|
+
"itemSpacing",
|
|
303
|
+
"paddingTop",
|
|
304
|
+
"paddingRight",
|
|
305
|
+
"paddingBottom",
|
|
306
|
+
"paddingLeft"
|
|
307
|
+
],
|
|
308
|
+
text: ["fontSize"]
|
|
309
|
+
};
|
|
224
310
|
function describeVariables(graph) {
|
|
225
311
|
const counts = {
|
|
226
312
|
COLOR: 0,
|
|
@@ -229,8 +315,23 @@ function describeVariables(graph) {
|
|
|
229
315
|
BOOLEAN: 0
|
|
230
316
|
};
|
|
231
317
|
const colorsByHex = /* @__PURE__ */ new Map();
|
|
232
|
-
|
|
318
|
+
const numbersByField = /* @__PURE__ */ new Map();
|
|
319
|
+
for (const variable of graph.getLiveVariables()) {
|
|
233
320
|
counts[variable.type]++;
|
|
321
|
+
if (variable.type === "FLOAT") {
|
|
322
|
+
const namespace = variableNamespace(variable);
|
|
323
|
+
const value = graph.resolveNumberVariable(variable.id);
|
|
324
|
+
if (!namespace || value === void 0) continue;
|
|
325
|
+
for (const field of NAMESPACE_FIELDS[namespace] ?? []) {
|
|
326
|
+
const byValue = numbersByField.get(field) ?? /* @__PURE__ */ new Map();
|
|
327
|
+
byValue.set(value, [...byValue.get(value) ?? [], {
|
|
328
|
+
id: variable.id,
|
|
329
|
+
name: variable.name
|
|
330
|
+
}]);
|
|
331
|
+
numbersByField.set(field, byValue);
|
|
332
|
+
}
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
234
335
|
if (variable.type !== "COLOR") continue;
|
|
235
336
|
const color = graph.resolveColorVariable(variable.id);
|
|
236
337
|
if (!color || color.a < 1) continue;
|
|
@@ -242,7 +343,8 @@ function describeVariables(graph) {
|
|
|
242
343
|
}
|
|
243
344
|
return {
|
|
244
345
|
counts,
|
|
245
|
-
colorsByHex
|
|
346
|
+
colorsByHex,
|
|
347
|
+
numbersByField
|
|
246
348
|
};
|
|
247
349
|
}
|
|
248
350
|
function createLinter(options) {
|
package/dist/lint/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","names":[],"sources":["../../src/lint/linter.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode, SharedStyleType } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { sharedStyleLayers, sharedStyleTypeForKind } from '@pairdraw/scene-graph/shared-styles'\n\nimport { presets } from './presets'\nimport { allRules } from './rules'\nimport type {\n LintConfig,\n LintVariables,\n LintMessage,\n LintNode,\n LintResult,\n Rule,\n RuleContext,\n Severity\n} from './types'\nimport { getNodePath } from './utils'\n\n/** The size and weight of each stretch of a text layer's characters, as the canvas draws them. */\nfunction effectiveTextStyles(node: SceneNode): { fontSize: number; fontWeight: number }[] {\n const base = { fontSize: node.fontSize, fontWeight: node.fontWeight }\n const runs = node.styleRuns.map((run) => ({\n fontSize: run.style.fontSize ?? base.fontSize,\n fontWeight: run.style.fontWeight ?? base.fontWeight\n }))\n const covered = node.styleRuns.reduce((total, run) => total + run.length, 0)\n return covered < node.text.length || runs.length === 0 ? [base, ...runs] : runs\n}\n\n/** A preset's rules, refusing a name no preset has so a typo cannot silently disable linting. */\nfunction presetRules(id: string) {\n if (!Object.hasOwn(presets, id)) {\n const known = Object.keys(presets).sort().join(', ')\n throw new Error(`Unknown lint preset \"${id}\". Known presets: ${known}`)\n }\n return presets[id].rules\n}\n\nexport class Linter {\n private rules = new Map<string, Rule>()\n private ruleConfigs = new Map<string, { severity: Severity; options?: Record<string, unknown> }>()\n private messages: LintMessage[] = []\n private graph: SceneGraph | null = null\n /** The enabled rules with their contexts, made once per run rather than once per layer. */\n private checks: { rule: Rule; context: RuleContext }[] = []\n private nodes = new Map<string, LintNode>()\n private variables: LintVariables = {\n counts: { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 },\n colorsByHex: new Map()\n }\n private sharedStyleTypes: ReadonlyMap<string, SharedStyleType> = new Map()\n\n constructor(options: { config?: LintConfig; preset?: string; rules?: string[] } = {}) {\n let baseConfig: Record<\n string,\n Severity | { severity: Severity; options?: Record<string, unknown> }\n > = {}\n if (options.preset) baseConfig = { ...presetRules(options.preset) }\n if (options.config?.extends) {\n const ids = Array.isArray(options.config.extends)\n ? options.config.extends\n : [options.config.extends]\n for (const id of ids) baseConfig = { ...baseConfig, ...presetRules(id) }\n }\n if (options.config?.rules) baseConfig = { ...baseConfig, ...options.config.rules }\n const rulesToLoad = options.rules ?? Object.keys(baseConfig)\n for (const ruleId of rulesToLoad) {\n if (!Object.hasOwn(allRules, ruleId)) throw new Error(`Unknown lint rule \"${ruleId}\"`)\n const rule = allRules[ruleId]\n const config = baseConfig[ruleId]\n if (config === 'off') continue\n this.rules.set(ruleId, rule)\n if (typeof config === 'string') this.ruleConfigs.set(ruleId, { severity: config })\n else this.ruleConfigs.set(ruleId, config)\n }\n }\n\n lintGraph(graph: SceneGraph, rootIds?: string[]): LintResult {\n this.messages = []\n this.nodes.clear()\n this.graph = graph\n this.variables = describeVariables(graph)\n this.sharedStyleTypes = sharedStyleTypes(graph)\n this.checks = this.ruleChecks()\n const roots = rootIds && rootIds.length > 0 ? rootIds : graph.getPages().map((p) => p.id)\n for (const id of outermostRoots(graph, roots)) this.lintNode(id, undefined)\n this.graph = null\n this.checks = []\n return {\n messages: this.messages,\n errorCount: this.messages.filter((m) => m.severity === 'error').length,\n warningCount: this.messages.filter((m) => m.severity === 'warning').length,\n infoCount: this.messages.filter((m) => m.severity === 'info').length\n }\n }\n\n /**\n * The rules' view of `id`, made the first time the walk or a rule reaches it. Instance sublayers\n * are never linted, so on a page made of instances most layers are never converted at all.\n */\n private nodeFor(id: string, parent: LintNode | undefined): LintNode | undefined {\n const cached = this.nodes.get(id)\n if (cached) return cached\n const raw = this.graph?.getNode(id)\n if (!this.graph || !raw) return undefined\n const node = this.toLintNode(this.graph, raw)\n node.parent = parent\n this.nodes.set(id, node)\n return node\n }\n\n private toLintNode(graph: SceneGraph, raw: SceneNode): LintNode {\n // Rules see the color a paint renders with, including a bound variable in this node's mode.\n const paintColor = (\n field: 'fills' | 'strokes',\n index: number,\n color: SceneNode['fills'][number]['color']\n ) => {\n const variableId = raw.boundVariables[`${field}/${index}/color`]\n return (variableId && graph.resolveColorVariableForNode(raw.id, variableId)) || color\n }\n return {\n id: raw.id,\n name: raw.name,\n type: raw.type,\n width: raw.width,\n height: raw.height,\n x: raw.x,\n y: raw.y,\n rotation: raw.rotation,\n visible: raw.visible,\n locked: raw.locked,\n opacity: raw.opacity,\n layoutMode: raw.layoutMode,\n layoutPositioning: raw.layoutPositioning,\n layoutGrow: raw.layoutGrow,\n layoutAlignSelf: raw.layoutAlignSelf,\n primaryAxisSizing: raw.primaryAxisSizing,\n counterAxisSizing: raw.counterAxisSizing,\n textAutoResize: raw.textAutoResize,\n itemSpacing: raw.itemSpacing,\n paddingTop: raw.paddingTop,\n paddingRight: raw.paddingRight,\n paddingBottom: raw.paddingBottom,\n paddingLeft: raw.paddingLeft,\n cornerRadius: raw.cornerRadius,\n childIds: raw.childIds.slice(),\n componentId: raw.componentId || undefined,\n text: raw.text,\n fontSize: raw.fontSize,\n textStyles: raw.type === 'TEXT' ? effectiveTextStyles(raw) : undefined,\n styleRunCount: raw.styleRuns.length,\n boundVariables: raw.boundVariables,\n fills: raw.fills.map((f, index) => ({\n type: f.type,\n visible: f.visible,\n opacity: f.opacity,\n color: f.type === 'SOLID' ? paintColor('fills', index, f.color) : undefined\n })),\n strokes: raw.strokes.map((stroke, index) => ({\n visible: stroke.visible,\n opacity: stroke.opacity,\n color: paintColor('strokes', index, stroke.color)\n })),\n effects: raw.effects.map((effect) => ({\n type: effect.type,\n visible: effect.visible,\n radius: effect.type === 'SHADER' ? 0 : effect.radius\n })),\n textStyleId: raw.textStyleId,\n effectStyleId: raw.effectStyleId\n }\n }\n\n private ruleChecks(): { rule: Rule; context: RuleContext }[] {\n const checks: { rule: Rule; context: RuleContext }[] = []\n for (const [ruleId, rule] of this.rules) {\n const config = this.ruleConfigs.get(ruleId)\n if (!config || config.severity === 'off') continue\n const severity = config.severity\n checks.push({\n rule,\n context: {\n variables: this.variables,\n isSharedStyle: (kind, id) =>\n id !== null && this.sharedStyleTypes.get(id) === sharedStyleTypeForKind(kind),\n report: ({ node, message, suggest, data, fix, suggestions }) => {\n this.messages.push({\n ruleId,\n severity,\n message,\n nodeId: node.id,\n nodeName: node.name,\n nodePath: getNodePath(this.nodes.get(node.id) ?? node),\n suggest,\n data,\n fix,\n suggestions\n })\n },\n getConfig: () => config.options,\n getParent: (node) => this.nodes.get(node.id)?.parent ?? null,\n getChildren: (node) =>\n node.childIds\n .map((childId) => this.nodeFor(childId, this.nodes.get(node.id)))\n .filter((child): child is LintNode => !!child)\n }\n })\n }\n return checks\n }\n\n private lintNode(id: string, parent: LintNode | undefined) {\n const node = this.nodeFor(id, parent)\n if (!node) return\n for (const { rule, context } of this.checks) {\n if (rule.match && !rule.match.includes(node.type)) continue\n rule.check(node, context)\n }\n // Instance sublayers mirror their main component: issues there are fixed once in the\n // component, so reporting every placed copy only multiplies the same finding.\n if (node.type === 'INSTANCE') return\n for (const childId of node.childIds) this.lintNode(childId, node)\n }\n}\n\n/**\n * The roots no other root contains, each once. A layer inside another root is linted with it,\n * so it has its real parents and reports once.\n */\nfunction outermostRoots(graph: SceneGraph, ids: readonly string[]): string[] {\n const requested = new Set(ids)\n return uniq(ids).filter((id) => {\n for (let parentId = graph.getNode(id)?.parentId; parentId;) {\n if (requested.has(parentId)) return false\n parentId = graph.getNode(parentId)?.parentId\n }\n return true\n })\n}\n\n/** The type of each shared style in the document, by the source id layers link it by. */\nfunction sharedStyleTypes(graph: SceneGraph): ReadonlyMap<string, SharedStyleType> {\n const types = new Map<string, SharedStyleType>()\n for (const [id, style] of sharedStyleLayers(graph))\n if (style.sharedStyleType) types.set(id, style.sharedStyleType)\n return types\n}\n\nfunction describeVariables(graph: SceneGraph): LintVariables {\n const counts = { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 }\n const colorsByHex = new Map<string, { id: string; name: string }>()\n for (const variable of graph.variables.values()) {\n counts[variable.type]++\n if (variable.type !== 'COLOR') continue\n const color = graph.resolveColorVariable(variable.id)\n if (!color || color.a < 1) continue\n const hex = colorToHex(color)\n if (!colorsByHex.has(hex)) colorsByHex.set(hex, { id: variable.id, name: variable.name })\n }\n return { counts, colorsByHex }\n}\n\nexport function createLinter(options?: { config?: LintConfig; preset?: string; rules?: string[] }) {\n return new Linter(options)\n}\n"],"mappings":";;;;;;;;AAqBA,SAAS,oBAAoB,MAA6D;CACxF,MAAM,OAAO;EAAE,UAAU,KAAK;EAAU,YAAY,KAAK;CAAW;CACpE,MAAM,OAAO,KAAK,UAAU,KAAK,SAAS;EACxC,UAAU,IAAI,MAAM,YAAY,KAAK;EACrC,YAAY,IAAI,MAAM,cAAc,KAAK;CAC3C,EAAE;CAEF,OADgB,KAAK,UAAU,QAAQ,OAAO,QAAQ,QAAQ,IAAI,QAAQ,CAC7D,IAAI,KAAK,KAAK,UAAU,KAAK,WAAW,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI;AAC7E;;AAGA,SAAS,YAAY,IAAY;CAC/B,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,GAAG;EAC/B,MAAM,QAAQ,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;EACnD,MAAM,IAAI,MAAM,wBAAwB,GAAG,oBAAoB,OAAO;CACxE;CACA,OAAO,QAAQ,GAAG,CAAC;AACrB;AAEA,IAAa,SAAb,MAAoB;CAClB,wBAAgB,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,IAA6B;CAC/C,KAAK,MAAM,CAAC,IAAI,UAAU,kBAAkB,KAAK,GAC/C,IAAI,MAAM,iBAAiB,MAAM,IAAI,IAAI,MAAM,eAAe;CAChE,OAAO;AACT;AAEA,SAAS,kBAAkB,OAAkC;CAC3D,MAAM,SAAS;EAAE,OAAO;EAAG,OAAO;EAAG,QAAQ;EAAG,SAAS;CAAE;CAC3D,MAAM,8BAAc,IAAI,IAA0C;CAClE,KAAK,MAAM,YAAY,MAAM,UAAU,OAAO,GAAG;EAC/C,OAAO,SAAS,KAAK;EACrB,IAAI,SAAS,SAAS,SAAS;EAC/B,MAAM,QAAQ,MAAM,qBAAqB,SAAS,EAAE;EACpD,IAAI,CAAC,SAAS,MAAM,IAAI,GAAG;EAC3B,MAAM,MAAM,WAAW,KAAK;EAC5B,IAAI,CAAC,YAAY,IAAI,GAAG,GAAG,YAAY,IAAI,KAAK;GAAE,IAAI,SAAS;GAAI,MAAM,SAAS;EAAK,CAAC;CAC1F;CACA,OAAO;EAAE;EAAQ;CAAY;AAC/B;AAEA,SAAgB,aAAa,SAAsE;CACjG,OAAO,IAAI,OAAO,OAAO;AAC3B"}
|
|
1
|
+
{"version":3,"file":"linter.js","names":[],"sources":["../../src/lint/linter.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport { variableNamespace } from '@pairdraw/dom-css/export'\nimport type { SceneGraph, SceneNode, SharedStyleType } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport { cachedDesignMemory, DESIGN_MEMORY_GROUPS } from '@pairdraw/scene-graph/design-memory'\nimport { sharedStyleLayers, sharedStyleTypeForKind } from '@pairdraw/scene-graph/shared-styles'\n\nimport { currentDesignRules, designViolations, type DesignViolation } from '#core/design-memory'\n\nimport { presets } from './presets'\nimport { allRules } from './rules'\nimport { DESIGN_MEMORY_RULE_IDS, designMemoryRules } from './rules/design-memory'\nimport type {\n LintConfig,\n LintDesignMemory,\n LintVariables,\n LintMessage,\n LintNode,\n LintResult,\n Rule,\n RuleContext,\n Severity,\n TokenNumberField\n} from './types'\nimport { getNodePath } from './utils'\n\n/** The size and weight of each stretch of a text layer's characters, as the canvas draws them. */\nfunction effectiveTextStyles(node: SceneNode): { fontSize: number; fontWeight: number }[] {\n const base = { fontSize: node.fontSize, fontWeight: node.fontWeight }\n const runs = node.styleRuns.map((run) => ({\n fontSize: run.style.fontSize ?? base.fontSize,\n fontWeight: run.style.fontWeight ?? base.fontWeight\n }))\n const covered = node.styleRuns.reduce((total, run) => total + run.length, 0)\n return covered < node.text.length || runs.length === 0 ? [base, ...runs] : runs\n}\n\ntype RuleSettings = { severity: Severity; options?: Record<string, unknown> }\n\n/** How mild each reported severity is, so a finding can only soften its rule's. */\nconst SEVERITY_RANK: Record<Exclude<Severity, 'off'>, number> = { error: 0, warning: 1, info: 2 }\n\n/** A preset's rules, refusing a name no preset has so a typo cannot silently disable linting. */\nfunction presetRules(id: string) {\n if (!Object.hasOwn(presets, id)) {\n const known = Object.keys(presets).sort().join(', ')\n throw new Error(`Unknown lint preset \"${id}\". Known presets: ${known}`)\n }\n return presets[id].rules\n}\n\nexport class Linter {\n private rules = new Map<string, Rule>()\n private ruleConfigs = new Map<string, RuleSettings | undefined>()\n private messages: LintMessage[] = []\n private graph: SceneGraph | null = null\n /** The enabled rules with their contexts, made once per run rather than once per layer. */\n private checks: { rule: Rule; context: RuleContext }[] = []\n private nodes = new Map<string, LintNode>()\n private variables: LintVariables = {\n counts: { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 },\n colorsByHex: new Map(),\n numbersByField: new Map()\n }\n private sharedStyleTypes: ReadonlyMap<string, SharedStyleType> = new Map()\n private design: LintDesignMemory | null = null\n /** Rules the configuration names, which a document's design memory does not override. */\n private configured = new Set<string>()\n /** The only rules to run, when the caller named them. */\n private only: ReadonlySet<string> | null = null\n\n constructor(options: { config?: LintConfig; preset?: string; rules?: string[] } = {}) {\n let baseConfig: Record<\n string,\n Severity | { severity: Severity; options?: Record<string, unknown> }\n > = {}\n if (options.preset) baseConfig = { ...presetRules(options.preset) }\n if (options.config?.extends) {\n const ids = Array.isArray(options.config.extends)\n ? options.config.extends\n : [options.config.extends]\n for (const id of ids) baseConfig = { ...baseConfig, ...presetRules(id) }\n }\n if (options.config?.rules) baseConfig = { ...baseConfig, ...options.config.rules }\n this.configured = new Set(Object.keys(options.config?.rules ?? {}))\n this.only = options.rules ? new Set(options.rules) : null\n const rulesToLoad = options.rules ?? Object.keys(baseConfig)\n for (const ruleId of rulesToLoad) {\n if (!Object.hasOwn(allRules, ruleId)) throw new Error(`Unknown lint rule \"${ruleId}\"`)\n const rule = allRules[ruleId]\n const config = baseConfig[ruleId]\n if (config === 'off') continue\n this.rules.set(ruleId, rule)\n if (typeof config === 'string') this.ruleConfigs.set(ruleId, { severity: config })\n else this.ruleConfigs.set(ruleId, config)\n }\n }\n\n lintGraph(graph: SceneGraph, rootIds?: string[]): LintResult {\n this.messages = []\n this.nodes.clear()\n this.graph = graph\n this.variables = describeVariables(graph)\n this.sharedStyleTypes = sharedStyleTypes(graph)\n this.design = this.describeDesign(graph)\n this.checks = this.ruleChecks()\n const roots = rootIds && rootIds.length > 0 ? rootIds : graph.getPages().map((p) => p.id)\n for (const id of outermostRoots(graph, roots)) this.lintNode(id, undefined)\n this.graph = null\n this.checks = []\n this.design = null\n return {\n messages: this.messages,\n errorCount: this.messages.filter((m) => m.severity === 'error').length,\n warningCount: this.messages.filter((m) => m.severity === 'warning').length,\n infoCount: this.messages.filter((m) => m.severity === 'info').length\n }\n }\n\n /**\n * The rules' view of `id`, made the first time the walk or a rule reaches it. Instance sublayers\n * are never linted, so on a page made of instances most layers are never converted at all.\n */\n private nodeFor(id: string, parent: LintNode | undefined): LintNode | undefined {\n const cached = this.nodes.get(id)\n if (cached) return cached\n const raw = this.graph?.getNode(id)\n if (!this.graph || !raw) return undefined\n const node = this.toLintNode(this.graph, raw)\n node.parent = parent\n this.nodes.set(id, node)\n return node\n }\n\n private toLintNode(graph: SceneGraph, raw: SceneNode): LintNode {\n // Rules see the color a paint renders with, including a bound variable in this node's mode.\n const paintColor = (\n field: 'fills' | 'strokes',\n index: number,\n color: SceneNode['fills'][number]['color']\n ) => {\n const variableId = raw.boundVariables[`${field}/${index}/color`]\n return (variableId && graph.resolveColorVariableForNode(raw.id, variableId)) || color\n }\n return {\n id: raw.id,\n name: raw.name,\n type: raw.type,\n width: raw.width,\n height: raw.height,\n x: raw.x,\n y: raw.y,\n rotation: raw.rotation,\n visible: raw.visible,\n locked: raw.locked,\n opacity: raw.opacity,\n layoutMode: raw.layoutMode,\n layoutPositioning: raw.layoutPositioning,\n layoutGrow: raw.layoutGrow,\n layoutAlignSelf: raw.layoutAlignSelf,\n primaryAxisSizing: raw.primaryAxisSizing,\n counterAxisSizing: raw.counterAxisSizing,\n textAutoResize: raw.textAutoResize,\n itemSpacing: raw.itemSpacing,\n paddingTop: raw.paddingTop,\n paddingRight: raw.paddingRight,\n paddingBottom: raw.paddingBottom,\n paddingLeft: raw.paddingLeft,\n cornerRadius: raw.cornerRadius,\n childIds: raw.childIds.slice(),\n componentId: raw.componentId || undefined,\n text: raw.text,\n fontSize: raw.fontSize,\n textStyles: raw.type === 'TEXT' ? effectiveTextStyles(raw) : undefined,\n styleRunCount: raw.styleRuns.length,\n boundVariables: raw.boundVariables,\n fills: raw.fills.map((f, index) => ({\n type: f.type,\n visible: f.visible,\n opacity: f.opacity,\n color: f.type === 'SOLID' ? paintColor('fills', index, f.color) : undefined\n })),\n strokes: raw.strokes.map((stroke, index) => ({\n visible: stroke.visible,\n opacity: stroke.opacity,\n color: paintColor('strokes', index, stroke.color)\n })),\n effects: raw.effects.map((effect) => ({\n type: effect.type,\n visible: effect.visible,\n radius: effect.type === 'SHADER' || effect.type === 'NOISE' ? 0 : effect.radius\n })),\n textStyleId: raw.textStyleId,\n effectStyleId: raw.effectStyleId\n }\n }\n\n /**\n * The document's design memory, which its own rules check layers against. A memory's group\n * replaces the generic scale rule for the same values.\n */\n private describeDesign(graph: SceneGraph): LintDesignMemory | null {\n const memory = cachedDesignMemory(graph)\n if (!memory) return null\n const rules = currentDesignRules(graph, memory)\n const found = new Map<string, readonly DesignViolation[]>()\n return {\n rules,\n violations: (node) => {\n const cached = found.get(node.id)\n if (cached) return cached\n const raw = graph.getNode(node.id)\n const violations = raw ? designViolations(rules, raw) : []\n found.set(node.id, violations)\n return violations\n }\n }\n }\n\n /** The rules this run checks with their settings: the configured ones and the memory's. */\n private activeRules(): [string, Rule, RuleSettings][] {\n const active: [string, Rule, RuleSettings][] = []\n const rules = this.design?.rules\n const superseded = new Set<string>()\n if (rules && rules.spacing.enforce !== 'off') superseded.add('consistent-spacing')\n if (rules && rules.radius.enforce !== 'off') superseded.add('consistent-radius')\n for (const [ruleId, rule] of this.rules) {\n if (ruleId in designMemoryRules && !rules) continue\n if (superseded.has(ruleId) && !this.configured.has(ruleId)) continue\n const config = this.ruleConfigs.get(ruleId)\n if (config) active.push([ruleId, rule, config])\n }\n if (!rules) return active\n for (const group of DESIGN_MEMORY_GROUPS) {\n const ruleId = DESIGN_MEMORY_RULE_IDS[group]\n if (this.ruleConfigs.get(ruleId) || this.configured.has(ruleId)) continue\n if (this.only && !this.only.has(ruleId)) continue\n const enforce = rules[group].enforce\n if (enforce === 'off') continue\n active.push([\n ruleId,\n designMemoryRules[ruleId],\n { severity: enforce === 'refuse' ? 'error' : 'warning' }\n ])\n }\n return active\n }\n\n private ruleChecks(): { rule: Rule; context: RuleContext }[] {\n const checks: { rule: Rule; context: RuleContext }[] = []\n for (const [ruleId, rule, config] of this.activeRules()) {\n if (config.severity === 'off') continue\n const severity = config.severity\n checks.push({\n rule,\n context: {\n variables: this.variables,\n isSharedStyle: (kind, id) =>\n id !== null && this.sharedStyleTypes.get(id) === sharedStyleTypeForKind(kind),\n design: this.design,\n report: ({ node, message, suggest, data, fix, suggestions, severity: milder }) => {\n this.messages.push({\n ruleId,\n severity:\n milder && SEVERITY_RANK[milder] > SEVERITY_RANK[severity] ? milder : severity,\n message,\n nodeId: node.id,\n nodeName: node.name,\n nodePath: getNodePath(this.nodes.get(node.id) ?? node),\n suggest,\n data,\n fix,\n suggestions\n })\n },\n getConfig: () => config.options,\n getParent: (node) => this.nodes.get(node.id)?.parent ?? null,\n getChildren: (node) =>\n node.childIds\n .map((childId) => this.nodeFor(childId, this.nodes.get(node.id)))\n .filter((child): child is LintNode => !!child)\n }\n })\n }\n return checks\n }\n\n private lintNode(id: string, parent: LintNode | undefined) {\n const node = this.nodeFor(id, parent)\n if (!node) return\n for (const { rule, context } of this.checks) {\n if (rule.match && !rule.match.includes(node.type)) continue\n rule.check(node, context)\n }\n // Instance sublayers mirror their main component: issues there are fixed once in the\n // component, so reporting every placed copy only multiplies the same finding.\n if (node.type === 'INSTANCE') return\n for (const childId of node.childIds) this.lintNode(childId, node)\n }\n}\n\n/**\n * The roots no other root contains, each once. A layer inside another root is linted with it,\n * so it has its real parents and reports once.\n */\nfunction outermostRoots(graph: SceneGraph, ids: readonly string[]): string[] {\n const requested = new Set(ids)\n return uniq(ids).filter((id) => {\n for (let parentId = graph.getNode(id)?.parentId; parentId;) {\n if (requested.has(parentId)) return false\n parentId = graph.getNode(parentId)?.parentId\n }\n return true\n })\n}\n\n/** The type of each shared style in the document, by the source id layers link it by. */\nfunction sharedStyleTypes(graph: SceneGraph): ReadonlyMap<string, SharedStyleType> {\n const types = new Map<string, SharedStyleType>()\n for (const [id, style] of sharedStyleLayers(graph))\n if (style.sharedStyleType) types.set(id, style.sharedStyleType)\n return types\n}\n\n/** The layer fields each Tailwind namespace of number tokens sets. */\nconst NAMESPACE_FIELDS: Readonly<Record<string, readonly TokenNumberField[]>> = {\n radius: ['cornerRadius'],\n spacing: ['itemSpacing', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n text: ['fontSize']\n}\n\nfunction describeVariables(graph: SceneGraph): LintVariables {\n const counts = { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 }\n const colorsByHex = new Map<string, { id: string; name: string }>()\n const numbersByField = new Map<TokenNumberField, Map<number, { id: string; name: string }[]>>()\n for (const variable of graph.getLiveVariables()) {\n counts[variable.type]++\n if (variable.type === 'FLOAT') {\n const namespace = variableNamespace(variable)\n const value = graph.resolveNumberVariable(variable.id)\n if (!namespace || value === undefined) continue\n for (const field of NAMESPACE_FIELDS[namespace] ?? []) {\n const byValue =\n numbersByField.get(field) ?? new Map<number, { id: string; name: string }[]>()\n byValue.set(value, [\n ...(byValue.get(value) ?? []),\n { id: variable.id, name: variable.name }\n ])\n numbersByField.set(field, byValue)\n }\n continue\n }\n if (variable.type !== 'COLOR') continue\n const color = graph.resolveColorVariable(variable.id)\n if (!color || color.a < 1) continue\n const hex = colorToHex(color)\n if (!colorsByHex.has(hex)) colorsByHex.set(hex, { id: variable.id, name: variable.name })\n }\n return { counts, colorsByHex, numbersByField }\n}\n\nexport function createLinter(options?: { config?: LintConfig; preset?: string; rules?: string[] }) {\n return new Linter(options)\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,SAAS,oBAAoB,MAA6D;CACxF,MAAM,OAAO;EAAE,UAAU,KAAK;EAAU,YAAY,KAAK;CAAW;CACpE,MAAM,OAAO,KAAK,UAAU,KAAK,SAAS;EACxC,UAAU,IAAI,MAAM,YAAY,KAAK;EACrC,YAAY,IAAI,MAAM,cAAc,KAAK;CAC3C,EAAE;CAEF,OADgB,KAAK,UAAU,QAAQ,OAAO,QAAQ,QAAQ,IAAI,QAAQ,CAC7D,IAAI,KAAK,KAAK,UAAU,KAAK,WAAW,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI;AAC7E;;AAKA,MAAM,gBAA0D;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE;;AAGhG,SAAS,YAAY,IAAY;CAC/B,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,GAAG;EAC/B,MAAM,QAAQ,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI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AM,SAAS,iBAAiB,cAAc,CAAC,GAAG;IACrD,MAAM,UACJ,eAAe,IAAI,KAAK,qBAAK,IAAI,IAA4C;IAC/E,QAAQ,IAAI,OAAO,CACjB,GAAI,QAAQ,IAAI,KAAK,KAAK,CAAC,GAC3B;KAAE,IAAI,SAAS;KAAI,MAAM,SAAS;IAAK,CACzC,CAAC;IACD,eAAe,IAAI,OAAO,OAAO;GACnC;GACA;EACF;EACA,IAAI,SAAS,SAAS,SAAS;EAC/B,MAAM,QAAQ,MAAM,qBAAqB,SAAS,EAAE;EACpD,IAAI,CAAC,SAAS,MAAM,IAAI,GAAG;EAC3B,MAAM,MAAM,WAAW,KAAK;EAC5B,IAAI,CAAC,YAAY,IAAI,GAAG,GAAG,YAAY,IAAI,KAAK;GAAE,IAAI,SAAS;GAAI,MAAM,SAAS;EAAK,CAAC;CAC1F;CACA,OAAO;EAAE;EAAQ;EAAa;CAAe;AAC/C;AAEA,SAAgB,aAAa,SAAsE;CACjG,OAAO,IAAI,OAAO,OAAO;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","names":[],"sources":["../../src/lint/presets.ts"],"mappings":";;KAEK,aAAa;EAAa,UAAU;EAAU,UAAU;;UAC5C;EACf,OAAO,eAAe;;;;;;;cAQX,aAAa;
|
|
1
|
+
{"version":3,"file":"presets.d.ts","names":[],"sources":["../../src/lint/presets.ts"],"mappings":";;KAEK,aAAa;EAAa,UAAU;EAAU,UAAU;;UAC5C;EACf,OAAO,eAAe;;;;;;;cAQX,aAAa;cAwBb,QAAQ;cAKR,eAAe;cAsBf,SAAS,eAAe"}
|