@pairdraw/core 0.19.2 → 0.20.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 +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -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 +73 -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/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -1
- 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/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/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 +22 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- 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 +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -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/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +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/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.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 +27 -3
- 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 +168 -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 +6 -0
- 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/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/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/index.d.ts +5 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +6 -1
- 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/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- 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/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/decode.js +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/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.map +1 -1
- 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/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/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.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 +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +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/prepare.d.ts +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 +31 -3
- 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/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.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +1 -53
- 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 +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +174 -36
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -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/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/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 +6 -3
- 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 +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +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.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -1
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- 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 +110 -8
- 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/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 +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- 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/read-commands.js +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/index.d.ts +10 -8
- package/dist/text/index.js +3 -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/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -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.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +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.js +3 -2
- 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 +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.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/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -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/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- 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 +26 -5
- 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/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 +2 -1
- package/dist/tools/read/libraries.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 -3
- package/dist/tools/read/space.js.map +1 -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 +3 -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 +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.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/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.js +1 -0
- 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 +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +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 +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/pipeline.ts +19 -1
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +40 -3
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -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/export.ts +24 -7
- package/src/editor/components/instances.ts +31 -0
- 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 +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- 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/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- 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/index.ts +10 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/surface.ts +6 -2
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- 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/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- 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/fig/export/patch/index.ts +8 -0
- 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 +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- 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 +12 -1
- package/src/io/formats/svg/defs.ts +4 -72
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +278 -46
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- 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 +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout.ts +2 -0
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +107 -10
- 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/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- 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/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- 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/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
|
|
2
|
+
//#region src/layout/auto-layout-handles.ts
|
|
3
|
+
/** The gap between two neighbouring children, in the frame's coordinates. */
|
|
4
|
+
function primaryGapRects(node, children) {
|
|
5
|
+
if (children.length < 2 || node.itemSpacing <= 0 || node.primaryAxisAlign === "SPACE_BETWEEN") return [];
|
|
6
|
+
const isRow = node.layoutMode === "HORIZONTAL";
|
|
7
|
+
const rects = [];
|
|
8
|
+
for (let index = 0; index < children.length - 1; index++) {
|
|
9
|
+
const prev = children[index];
|
|
10
|
+
const next = children[index + 1];
|
|
11
|
+
const prevStart = isRow ? prev.x : prev.y;
|
|
12
|
+
const prevEnd = isRow ? prev.x + prev.width : prev.y + prev.height;
|
|
13
|
+
const nextStart = isRow ? next.x : next.y;
|
|
14
|
+
const nextEnd = isRow ? next.x + next.width : next.y + next.height;
|
|
15
|
+
const start = nextStart >= prevStart ? prevEnd : nextEnd;
|
|
16
|
+
const end = nextStart >= prevStart ? nextStart : prevStart;
|
|
17
|
+
if (end <= start) continue;
|
|
18
|
+
rects.push(isRow ? {
|
|
19
|
+
index,
|
|
20
|
+
rect: {
|
|
21
|
+
x: start,
|
|
22
|
+
y: node.paddingTop,
|
|
23
|
+
width: end - start,
|
|
24
|
+
height: node.height - node.paddingTop - node.paddingBottom
|
|
25
|
+
}
|
|
26
|
+
} : {
|
|
27
|
+
index,
|
|
28
|
+
rect: {
|
|
29
|
+
x: node.paddingLeft,
|
|
30
|
+
y: start,
|
|
31
|
+
width: node.width - node.paddingLeft - node.paddingRight,
|
|
32
|
+
height: end - start
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return rects;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The gap between wrapped lines, which a wrapping flow lays out with counterAxisSpacing. Lines are
|
|
40
|
+
* grouped by their position so a line with different item sizes still yields one gap.
|
|
41
|
+
*/
|
|
42
|
+
function counterGapRects(node, children) {
|
|
43
|
+
if (node.layoutWrap !== "WRAP" || node.counterAxisSpacing <= 0 || children.length < 2) return [];
|
|
44
|
+
const isRow = node.layoutMode === "HORIZONTAL";
|
|
45
|
+
const lines = [];
|
|
46
|
+
for (const child of children) {
|
|
47
|
+
const start = isRow ? child.y : child.x;
|
|
48
|
+
const end = isRow ? child.y + child.height : child.x + child.width;
|
|
49
|
+
const line = lines.find((candidate) => start <= candidate.end && end >= candidate.start);
|
|
50
|
+
if (line) {
|
|
51
|
+
line.start = Math.min(line.start, start);
|
|
52
|
+
line.end = Math.max(line.end, end);
|
|
53
|
+
} else lines.push({
|
|
54
|
+
start,
|
|
55
|
+
end
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const sorted = lines.sort((left, right) => left.start - right.start);
|
|
59
|
+
const rects = [];
|
|
60
|
+
for (let index = 0; index < sorted.length - 1; index++) {
|
|
61
|
+
const previous = sorted[index];
|
|
62
|
+
const next = sorted[index + 1];
|
|
63
|
+
if (next.start <= previous.end) continue;
|
|
64
|
+
rects.push(isRow ? {
|
|
65
|
+
index,
|
|
66
|
+
rect: {
|
|
67
|
+
x: node.paddingLeft,
|
|
68
|
+
y: previous.end,
|
|
69
|
+
width: node.width - node.paddingLeft - node.paddingRight,
|
|
70
|
+
height: next.start - previous.end
|
|
71
|
+
}
|
|
72
|
+
} : {
|
|
73
|
+
index,
|
|
74
|
+
rect: {
|
|
75
|
+
x: previous.end,
|
|
76
|
+
y: node.paddingTop,
|
|
77
|
+
width: next.start - previous.end,
|
|
78
|
+
height: node.height - node.paddingTop - node.paddingBottom
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return rects;
|
|
83
|
+
}
|
|
84
|
+
/** The padding and gap zones of an auto-layout frame, in its own coordinates. */
|
|
85
|
+
const PADDING_FIELD = {
|
|
86
|
+
top: "paddingTop",
|
|
87
|
+
right: "paddingRight",
|
|
88
|
+
bottom: "paddingBottom",
|
|
89
|
+
left: "paddingLeft"
|
|
90
|
+
};
|
|
91
|
+
function paddingValue(node, side) {
|
|
92
|
+
return node[PADDING_FIELD[side]];
|
|
93
|
+
}
|
|
94
|
+
/** The band a padding side occupies, in the frame's coordinates. */
|
|
95
|
+
function paddingBand(node, side, value) {
|
|
96
|
+
switch (side) {
|
|
97
|
+
case "top": return {
|
|
98
|
+
x: 0,
|
|
99
|
+
y: 0,
|
|
100
|
+
width: node.width,
|
|
101
|
+
height: value
|
|
102
|
+
};
|
|
103
|
+
case "right": return {
|
|
104
|
+
x: node.width - value,
|
|
105
|
+
y: 0,
|
|
106
|
+
width: value,
|
|
107
|
+
height: node.height
|
|
108
|
+
};
|
|
109
|
+
case "bottom": return {
|
|
110
|
+
x: 0,
|
|
111
|
+
y: node.height - value,
|
|
112
|
+
width: node.width,
|
|
113
|
+
height: value
|
|
114
|
+
};
|
|
115
|
+
case "left": return {
|
|
116
|
+
x: 0,
|
|
117
|
+
y: 0,
|
|
118
|
+
width: value,
|
|
119
|
+
height: node.height
|
|
120
|
+
};
|
|
121
|
+
default: throw new Error("Unknown padding side");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** The frame edge a padding handle hugs, so the nearest of two meeting bands wins. */
|
|
125
|
+
function edgeDistance(handle, x, y) {
|
|
126
|
+
switch (handle.side) {
|
|
127
|
+
case "top": return y;
|
|
128
|
+
case "bottom": return handle.rect.y + handle.rect.height - y;
|
|
129
|
+
case "left": return x;
|
|
130
|
+
case "right": return handle.rect.x + handle.rect.width - x;
|
|
131
|
+
default: throw new Error("Unknown padding side");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function measureAutoLayoutHandles(node, children) {
|
|
135
|
+
if (!node || node.layoutMode !== "HORIZONTAL" && node.layoutMode !== "VERTICAL") return null;
|
|
136
|
+
const laidOut = children.filter((child) => child.visible && child.layoutPositioning !== "ABSOLUTE");
|
|
137
|
+
const padding = [];
|
|
138
|
+
for (const side of [
|
|
139
|
+
"top",
|
|
140
|
+
"right",
|
|
141
|
+
"bottom",
|
|
142
|
+
"left"
|
|
143
|
+
]) {
|
|
144
|
+
const value = paddingValue(node, side);
|
|
145
|
+
if (value <= 0) continue;
|
|
146
|
+
padding.push({
|
|
147
|
+
kind: "padding",
|
|
148
|
+
side,
|
|
149
|
+
rect: paddingBand(node, side, value),
|
|
150
|
+
value
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const gaps = [...primaryGapRects(node, laidOut).map(({ index, rect }) => ({
|
|
154
|
+
kind: "gap",
|
|
155
|
+
axis: "primary",
|
|
156
|
+
index,
|
|
157
|
+
rect,
|
|
158
|
+
value: node.itemSpacing
|
|
159
|
+
})), ...counterGapRects(node, laidOut).map(({ index, rect }) => ({
|
|
160
|
+
kind: "gap",
|
|
161
|
+
axis: "counter",
|
|
162
|
+
index,
|
|
163
|
+
rect,
|
|
164
|
+
value: node.counterAxisSpacing
|
|
165
|
+
}))];
|
|
166
|
+
return {
|
|
167
|
+
nodeId: node.id,
|
|
168
|
+
layoutMode: node.layoutMode,
|
|
169
|
+
editable: !isGeneratedFrame(node),
|
|
170
|
+
padding,
|
|
171
|
+
gaps
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function contains(rect, x, y, grow = 0) {
|
|
175
|
+
return x >= rect.x - grow && x <= rect.x + rect.width + grow && y >= rect.y - grow && y <= rect.y + rect.height + grow;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The padding or gap handle under a point in the frame's coordinates. Padding wins where it meets a
|
|
179
|
+
* gap, and the nearest frame edge wins in a corner where two padding bands meet.
|
|
180
|
+
*/
|
|
181
|
+
function hitAutoLayoutHandle(layout, x, y) {
|
|
182
|
+
if (!layout) return null;
|
|
183
|
+
let nearest = null;
|
|
184
|
+
for (const handle of layout.padding) {
|
|
185
|
+
if (!contains(handle.rect, x, y)) continue;
|
|
186
|
+
if (!nearest || edgeDistance(handle, x, y) <= edgeDistance(nearest, x, y)) nearest = handle;
|
|
187
|
+
}
|
|
188
|
+
if (nearest) return {
|
|
189
|
+
kind: "padding",
|
|
190
|
+
side: nearest.side
|
|
191
|
+
};
|
|
192
|
+
for (const handle of layout.gaps) if (contains(handle.rect, x, y)) return {
|
|
193
|
+
kind: "gap",
|
|
194
|
+
axis: handle.axis,
|
|
195
|
+
index: handle.index
|
|
196
|
+
};
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
function handleFor(layout, hit) {
|
|
200
|
+
if (hit.kind === "padding") return layout.padding.find((handle) => handle.side === hit.side) ?? null;
|
|
201
|
+
return layout.gaps.find((handle) => handle.axis === hit.axis && handle.index === hit.index) ?? null;
|
|
202
|
+
}
|
|
203
|
+
/** Movement along the axis a padding side grows in. */
|
|
204
|
+
function paddingDelta(side, dx, dy) {
|
|
205
|
+
switch (side) {
|
|
206
|
+
case "top": return dy;
|
|
207
|
+
case "bottom": return -dy;
|
|
208
|
+
case "left": return dx;
|
|
209
|
+
case "right": return -dx;
|
|
210
|
+
default: throw new Error("Unknown padding side");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** Movement across the gaps of a flow: primary along it, counter across it. */
|
|
214
|
+
function gapDelta(layoutMode, axis, dx, dy) {
|
|
215
|
+
const horizontal = layoutMode === "HORIZONTAL";
|
|
216
|
+
if (axis === "counter") return horizontal ? dy : dx;
|
|
217
|
+
return horizontal ? dx : dy;
|
|
218
|
+
}
|
|
219
|
+
/** The rounded, non-negative value a drag would set for the grabbed handle. */
|
|
220
|
+
function autoLayoutDragValue(layout, hit, input) {
|
|
221
|
+
const handle = handleFor(layout, hit);
|
|
222
|
+
if (!handle) return 0;
|
|
223
|
+
const zoom = input.zoom > 0 ? input.zoom : 1;
|
|
224
|
+
const delta = handle.kind === "padding" ? paddingDelta(handle.side, input.dx, input.dy) : gapDelta(layout.layoutMode, handle.axis, input.dx, input.dy);
|
|
225
|
+
const raw = handle.value + delta / zoom;
|
|
226
|
+
const step = input.bigNudge && input.bigNudge > 0 ? input.bigNudge : 10;
|
|
227
|
+
return Math.max(0, input.shift ? Math.round(raw / step) * step : Math.round(raw));
|
|
228
|
+
}
|
|
229
|
+
/** The properties a drag writes for the grabbed handle, with Alt and Shift expanding padding. */
|
|
230
|
+
function autoLayoutDragChanges(layout, hit, input) {
|
|
231
|
+
const value = autoLayoutDragValue(layout, hit, input);
|
|
232
|
+
if (hit.kind === "padding") {
|
|
233
|
+
if (input.alt && input.shift) return {
|
|
234
|
+
value,
|
|
235
|
+
changes: {
|
|
236
|
+
paddingTop: value,
|
|
237
|
+
paddingRight: value,
|
|
238
|
+
paddingBottom: value,
|
|
239
|
+
paddingLeft: value
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
if (input.alt) switch (hit.side) {
|
|
243
|
+
case "top":
|
|
244
|
+
case "bottom": return {
|
|
245
|
+
value,
|
|
246
|
+
changes: {
|
|
247
|
+
paddingTop: value,
|
|
248
|
+
paddingBottom: value
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
case "left":
|
|
252
|
+
case "right": return {
|
|
253
|
+
value,
|
|
254
|
+
changes: {
|
|
255
|
+
paddingLeft: value,
|
|
256
|
+
paddingRight: value
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
switch (hit.side) {
|
|
261
|
+
case "top": return {
|
|
262
|
+
value,
|
|
263
|
+
changes: { paddingTop: value }
|
|
264
|
+
};
|
|
265
|
+
case "right": return {
|
|
266
|
+
value,
|
|
267
|
+
changes: { paddingRight: value }
|
|
268
|
+
};
|
|
269
|
+
case "bottom": return {
|
|
270
|
+
value,
|
|
271
|
+
changes: { paddingBottom: value }
|
|
272
|
+
};
|
|
273
|
+
case "left": return {
|
|
274
|
+
value,
|
|
275
|
+
changes: { paddingLeft: value }
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (hit.axis === "counter") return {
|
|
280
|
+
value,
|
|
281
|
+
changes: { counterAxisSpacing: value }
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
value,
|
|
285
|
+
changes: { itemSpacing: value }
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
export { autoLayoutDragChanges, autoLayoutDragValue, hitAutoLayoutHandle, measureAutoLayoutHandles };
|
|
290
|
+
|
|
291
|
+
//# sourceMappingURL=auto-layout-handles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-layout-handles.js","names":[],"sources":["../../src/layout/auto-layout-handles.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\n\n/** The side of a frame a padding handle edits. */\nexport type AutoLayoutPaddingSide = 'top' | 'right' | 'bottom' | 'left'\n\n/** A rectangle in the frame's own coordinates, the space a handle occupies. */\nexport interface AutoLayoutHandleRect {\n x: number\n y: number\n width: number\n height: number\n}\n\nexport interface AutoLayoutPaddingHandle {\n kind: 'padding'\n side: AutoLayoutPaddingSide\n rect: AutoLayoutHandleRect\n value: number\n}\n\nexport interface AutoLayoutGapHandle {\n kind: 'gap'\n /** The gap the flow lays out, or the gap between wrapped lines. */\n axis: 'primary' | 'counter'\n /** The child the gap starts after, on the primary axis. */\n index: number\n rect: AutoLayoutHandleRect\n value: number\n}\n\nexport type AutoLayoutHandle = AutoLayoutPaddingHandle | AutoLayoutGapHandle\nexport type AutoLayoutHandleHit =\n | Pick<AutoLayoutPaddingHandle, 'kind' | 'side'>\n | Pick<AutoLayoutGapHandle, 'kind' | 'axis' | 'index'>\n\nexport interface AutoLayoutHandleLayout {\n nodeId: string\n layoutMode: 'HORIZONTAL' | 'VERTICAL'\n /** False where no edit can land, such as a generated frame's own layout. */\n editable: boolean\n padding: AutoLayoutPaddingHandle[]\n gaps: AutoLayoutGapHandle[]\n}\n\nexport interface AutoLayoutDragInput {\n /** Pointer movement on screen, in pixels. */\n dx: number\n dy: number\n zoom: number\n /** Alt edits the opposite side on the dragged axis; with Shift, every side. */\n alt: boolean\n /** Shift moves padding or spacing by the large nudge. */\n shift: boolean\n /** The large nudge distance, as Settings → Editor sets it. */\n bigNudge?: number\n}\n\nexport interface AutoLayoutDragChanges {\n /** The new value of the dragged property, clamped to zero. */\n value: number\n changes: Partial<\n Pick<\n SceneNode,\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'itemSpacing'\n | 'counterAxisSpacing'\n >\n >\n}\n\n/** The gap between two neighbouring children, in the frame's coordinates. */\nfunction primaryGapRects(\n node: SceneNode,\n children: readonly SceneNode[]\n): Array<{ index: number; rect: AutoLayoutHandleRect }> {\n if (children.length < 2 || node.itemSpacing <= 0 || node.primaryAxisAlign === 'SPACE_BETWEEN')\n return []\n const isRow = node.layoutMode === 'HORIZONTAL'\n const rects: Array<{ index: number; rect: AutoLayoutHandleRect }> = []\n for (let index = 0; index < children.length - 1; index++) {\n const prev = children[index]\n const next = children[index + 1]\n const prevStart = isRow ? prev.x : prev.y\n const prevEnd = isRow ? prev.x + prev.width : prev.y + prev.height\n const nextStart = isRow ? next.x : next.y\n const nextEnd = isRow ? next.x + next.width : next.y + next.height\n // A reversed flow (RTL rows, for one) lays the next child before the previous one.\n const start = nextStart >= prevStart ? prevEnd : nextEnd\n const end = nextStart >= prevStart ? nextStart : prevStart\n if (end <= start) continue\n rects.push(\n isRow\n ? {\n index,\n rect: {\n x: start,\n y: node.paddingTop,\n width: end - start,\n height: node.height - node.paddingTop - node.paddingBottom\n }\n }\n : {\n index,\n rect: {\n x: node.paddingLeft,\n y: start,\n width: node.width - node.paddingLeft - node.paddingRight,\n height: end - start\n }\n }\n )\n }\n return rects\n}\n\n/**\n * The gap between wrapped lines, which a wrapping flow lays out with counterAxisSpacing. Lines are\n * grouped by their position so a line with different item sizes still yields one gap.\n */\nfunction counterGapRects(\n node: SceneNode,\n children: readonly SceneNode[]\n): Array<{ index: number; rect: AutoLayoutHandleRect }> {\n if (node.layoutWrap !== 'WRAP' || node.counterAxisSpacing <= 0 || children.length < 2) return []\n const isRow = node.layoutMode === 'HORIZONTAL'\n const lines: Array<{ start: number; end: number }> = []\n for (const child of children) {\n const start = isRow ? child.y : child.x\n const end = isRow ? child.y + child.height : child.x + child.width\n // A centered or baseline line aligns children with different sizes at different starts.\n const line = lines.find((candidate) => start <= candidate.end && end >= candidate.start)\n if (line) {\n line.start = Math.min(line.start, start)\n line.end = Math.max(line.end, end)\n } else {\n lines.push({ start, end })\n }\n }\n const sorted = lines.sort((left, right) => left.start - right.start)\n const rects: Array<{ index: number; rect: AutoLayoutHandleRect }> = []\n for (let index = 0; index < sorted.length - 1; index++) {\n const previous = sorted[index]\n const next = sorted[index + 1]\n if (next.start <= previous.end) continue\n rects.push(\n isRow\n ? {\n index,\n rect: {\n x: node.paddingLeft,\n y: previous.end,\n width: node.width - node.paddingLeft - node.paddingRight,\n height: next.start - previous.end\n }\n }\n : {\n index,\n rect: {\n x: previous.end,\n y: node.paddingTop,\n width: next.start - previous.end,\n height: node.height - node.paddingTop - node.paddingBottom\n }\n }\n )\n }\n return rects\n}\n\n/** The padding and gap zones of an auto-layout frame, in its own coordinates. */\nconst PADDING_FIELD = {\n top: 'paddingTop',\n right: 'paddingRight',\n bottom: 'paddingBottom',\n left: 'paddingLeft'\n} as const\n\nfunction paddingValue(node: SceneNode, side: AutoLayoutPaddingSide): number {\n return node[PADDING_FIELD[side]]\n}\n\n/** The band a padding side occupies, in the frame's coordinates. */\nfunction paddingBand(\n node: SceneNode,\n side: AutoLayoutPaddingSide,\n value: number\n): AutoLayoutHandleRect {\n switch (side) {\n case 'top':\n return { x: 0, y: 0, width: node.width, height: value }\n case 'right':\n return { x: node.width - value, y: 0, width: value, height: node.height }\n case 'bottom':\n return { x: 0, y: node.height - value, width: node.width, height: value }\n case 'left':\n return { x: 0, y: 0, width: value, height: node.height }\n default:\n throw new Error('Unknown padding side')\n }\n}\n\n/** The frame edge a padding handle hugs, so the nearest of two meeting bands wins. */\nfunction edgeDistance(handle: AutoLayoutPaddingHandle, x: number, y: number): number {\n switch (handle.side) {\n case 'top':\n return y\n case 'bottom':\n return handle.rect.y + handle.rect.height - y\n case 'left':\n return x\n case 'right':\n return handle.rect.x + handle.rect.width - x\n default:\n throw new Error('Unknown padding side')\n }\n}\n\nexport function measureAutoLayoutHandles(\n node: SceneNode | undefined,\n children: readonly SceneNode[]\n): AutoLayoutHandleLayout | null {\n if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return null\n const laidOut = children.filter(\n (child) => child.visible && child.layoutPositioning !== 'ABSOLUTE'\n )\n const padding: AutoLayoutPaddingHandle[] = []\n const sides: AutoLayoutPaddingSide[] = ['top', 'right', 'bottom', 'left']\n for (const side of sides) {\n const value = paddingValue(node, side)\n if (value <= 0) continue\n padding.push({ kind: 'padding', side, rect: paddingBand(node, side, value), value })\n }\n const gaps: AutoLayoutGapHandle[] = [\n ...primaryGapRects(node, laidOut).map(({ index, rect }) => ({\n kind: 'gap' as const,\n axis: 'primary' as const,\n index,\n rect,\n value: node.itemSpacing\n })),\n ...counterGapRects(node, laidOut).map(({ index, rect }) => ({\n kind: 'gap' as const,\n axis: 'counter' as const,\n index,\n rect,\n value: node.counterAxisSpacing\n }))\n ]\n return {\n nodeId: node.id,\n layoutMode: node.layoutMode,\n editable: !isGeneratedFrame(node),\n padding,\n gaps\n }\n}\n\nfunction contains(rect: AutoLayoutHandleRect, x: number, y: number, grow = 0): boolean {\n return (\n x >= rect.x - grow &&\n x <= rect.x + rect.width + grow &&\n y >= rect.y - grow &&\n y <= rect.y + rect.height + grow\n )\n}\n\n/**\n * The padding or gap handle under a point in the frame's coordinates. Padding wins where it meets a\n * gap, and the nearest frame edge wins in a corner where two padding bands meet.\n */\nexport function hitAutoLayoutHandle(\n layout: AutoLayoutHandleLayout | null,\n x: number,\n y: number\n): AutoLayoutHandleHit | null {\n if (!layout) return null\n let nearest: AutoLayoutPaddingHandle | null = null\n for (const handle of layout.padding) {\n if (!contains(handle.rect, x, y)) continue\n if (!nearest || edgeDistance(handle, x, y) <= edgeDistance(nearest, x, y)) nearest = handle\n }\n if (nearest) return { kind: 'padding', side: nearest.side }\n for (const handle of layout.gaps) {\n if (contains(handle.rect, x, y)) {\n return { kind: 'gap', axis: handle.axis, index: handle.index }\n }\n }\n return null\n}\n\nfunction handleFor(\n layout: AutoLayoutHandleLayout,\n hit: AutoLayoutHandleHit\n): AutoLayoutHandle | null {\n if (hit.kind === 'padding') {\n return layout.padding.find((handle) => handle.side === hit.side) ?? null\n }\n return (\n layout.gaps.find((handle) => handle.axis === hit.axis && handle.index === hit.index) ?? null\n )\n}\n\n/** Movement along the axis a padding side grows in. */\nfunction paddingDelta(side: AutoLayoutPaddingSide, dx: number, dy: number): number {\n switch (side) {\n case 'top':\n return dy\n case 'bottom':\n return -dy\n case 'left':\n return dx\n case 'right':\n return -dx\n default:\n throw new Error('Unknown padding side')\n }\n}\n\n/** Movement across the gaps of a flow: primary along it, counter across it. */\nfunction gapDelta(\n layoutMode: 'HORIZONTAL' | 'VERTICAL',\n axis: AutoLayoutGapHandle['axis'],\n dx: number,\n dy: number\n): number {\n const horizontal = layoutMode === 'HORIZONTAL'\n if (axis === 'counter') return horizontal ? dy : dx\n return horizontal ? dx : dy\n}\n\n/** The rounded, non-negative value a drag would set for the grabbed handle. */\nexport function autoLayoutDragValue(\n layout: AutoLayoutHandleLayout,\n hit: AutoLayoutHandleHit,\n input: AutoLayoutDragInput\n): number {\n const handle = handleFor(layout, hit)\n if (!handle) return 0\n const zoom = input.zoom > 0 ? input.zoom : 1\n const delta =\n handle.kind === 'padding'\n ? paddingDelta(handle.side, input.dx, input.dy)\n : gapDelta(layout.layoutMode, handle.axis, input.dx, input.dy)\n const raw = handle.value + delta / zoom\n // Shift moves padding and spacing by the large nudge, as Settings → Editor sets it.\n const step = input.bigNudge && input.bigNudge > 0 ? input.bigNudge : 10\n return Math.max(0, input.shift ? Math.round(raw / step) * step : Math.round(raw))\n}\n\n/** The properties a drag writes for the grabbed handle, with Alt and Shift expanding padding. */\nexport function autoLayoutDragChanges(\n layout: AutoLayoutHandleLayout,\n hit: AutoLayoutHandleHit,\n input: AutoLayoutDragInput\n): AutoLayoutDragChanges {\n const value = autoLayoutDragValue(layout, hit, input)\n if (hit.kind === 'padding') {\n if (input.alt && input.shift) {\n return {\n value,\n changes: {\n paddingTop: value,\n paddingRight: value,\n paddingBottom: value,\n paddingLeft: value\n }\n }\n }\n if (input.alt) {\n switch (hit.side) {\n case 'top':\n case 'bottom':\n return { value, changes: { paddingTop: value, paddingBottom: value } }\n case 'left':\n case 'right':\n return { value, changes: { paddingLeft: value, paddingRight: value } }\n }\n }\n switch (hit.side) {\n case 'top':\n return { value, changes: { paddingTop: value } }\n case 'right':\n return { value, changes: { paddingRight: value } }\n case 'bottom':\n return { value, changes: { paddingBottom: value } }\n case 'left':\n return { value, changes: { paddingLeft: value } }\n }\n }\n if (hit.axis === 'counter') return { value, changes: { counterAxisSpacing: value } }\n return { value, changes: { itemSpacing: value } }\n}\n"],"mappings":";;;AA2EA,SAAS,gBACP,MACA,UACsD;CACtD,IAAI,SAAS,SAAS,KAAK,KAAK,eAAe,KAAK,KAAK,qBAAqB,iBAC5E,OAAO,CAAC;CACV,MAAM,QAAQ,KAAK,eAAe;CAClC,MAAM,QAA8D,CAAC;CACrE,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,SAAS,GAAG,SAAS;EACxD,MAAM,OAAO,SAAS;EACtB,MAAM,OAAO,SAAS,QAAQ;EAC9B,MAAM,YAAY,QAAQ,KAAK,IAAI,KAAK;EACxC,MAAM,UAAU,QAAQ,KAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,KAAK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IAAI,MAAM,WAAW;CACrE,OAAO,KAAK,IAAI,GAAG,MAAM,QAAQ,KAAK,MAAM,MAAM,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,CAAC;AAClF;;AAGA,SAAgB,sBACd,QACA,KACA,OACuB;CACvB,MAAM,QAAQ,oBAAoB,QAAQ,KAAK,KAAK;CACpD,IAAI,IAAI,SAAS,WAAW;EAC1B,IAAI,MAAM,OAAO,MAAM,OACrB,OAAO;GACL;GACA,SAAS;IACP,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;GACf;EACF;EAEF,IAAI,MAAM,KACR,QAAQ,IAAI,MAAZ;GACE,KAAK;GACL,KAAK,UACH,OAAO;IAAE;IAAO,SAAS;KAAE,YAAY;KAAO,eAAe;IAAM;GAAE;GACvE,KAAK;GACL,KAAK,SACH,OAAO;IAAE;IAAO,SAAS;KAAE,aAAa;KAAO,cAAc;IAAM;GAAE;EACzE;EAEF,QAAQ,IAAI,MAAZ;GACE,KAAK,OACH,OAAO;IAAE;IAAO,SAAS,EAAE,YAAY,MAAM;GAAE;GACjD,KAAK,SACH,OAAO;IAAE;IAAO,SAAS,EAAE,cAAc,MAAM;GAAE;GACnD,KAAK,UACH,OAAO;IAAE;IAAO,SAAS,EAAE,eAAe,MAAM;GAAE;GACpD,KAAK,QACH,OAAO;IAAE;IAAO,SAAS,EAAE,aAAa,MAAM;GAAE;EACpD;CACF;CACA,IAAI,IAAI,SAAS,WAAW,OAAO;EAAE;EAAO,SAAS,EAAE,oBAAoB,MAAM;CAAE;CACnF,OAAO;EAAE;EAAO,SAAS,EAAE,aAAa,MAAM;CAAE;AAClD"}
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sizeAutoResizingText } from "./layout/text-auto-resize.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AutoLayoutDragChanges, AutoLayoutDragInput, AutoLayoutGapHandle, AutoLayoutHandle, AutoLayoutHandleHit, AutoLayoutHandleLayout, AutoLayoutHandleRect, AutoLayoutPaddingHandle, AutoLayoutPaddingSide, autoLayoutDragChanges, autoLayoutDragValue, hitAutoLayoutHandle, measureAutoLayoutHandles } from "./layout/auto-layout-handles.js";
|
|
3
|
+
import { TextMeasurer, estimateTextSize, getTextMeasurer, installTextMeasurer, measureTextForLayout, setTextMeasurer } from "./layout/text-measurement.js";
|
|
3
4
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
4
5
|
//#region src/layout.d.ts
|
|
5
6
|
declare function computeLayout(graph: SceneGraph, frameId: string): void;
|
|
@@ -16,5 +17,5 @@ declare function routeUnroutedConnectors(graph: SceneGraph, rootId: string): voi
|
|
|
16
17
|
*/
|
|
17
18
|
declare function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { type TextMeasurer, computeAllLayouts, computeLayout, estimateTextSize, getTextMeasurer, installTextMeasurer, layoutAuthoredNodes, routeUnroutedConnectors, setTextMeasurer, sizeAutoResizingText };
|
|
20
|
+
export { AutoLayoutDragChanges, AutoLayoutDragInput, AutoLayoutGapHandle, AutoLayoutHandle, AutoLayoutHandleHit, AutoLayoutHandleLayout, AutoLayoutHandleRect, AutoLayoutPaddingHandle, AutoLayoutPaddingSide, type TextMeasurer, autoLayoutDragChanges, autoLayoutDragValue, computeAllLayouts, computeLayout, estimateTextSize, getTextMeasurer, hitAutoLayoutHandle, installTextMeasurer, layoutAuthoredNodes, measureAutoLayoutHandles, measureTextForLayout, routeUnroutedConnectors, setTextMeasurer, sizeAutoResizingText };
|
|
20
21
|
//# sourceMappingURL=layout.d.ts.map
|
package/dist/layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","names":[],"sources":["../src/layout.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"layout.d.ts","names":[],"sources":["../src/layout.ts"],"mappings":";;;;;iBAkEgB,cAAc,OAAO,YAAY;iBA2CjC,kBAAkB,OAAO,YAAY;;;;;iBAgBrC,wBAAwB,OAAO,YAAY;;;;;;iBAe3C,oBAAoB,OAAO,YAAY,SAAS"}
|
package/dist/layout.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { autoWidthWrapWidth, estimateTextSize, getTextMeasurer, installTextMeasurer, measureAutoWidthText, measureTextForLayout, setTextMeasurer } from "./layout/text-measurement.js";
|
|
2
|
+
import { autoLayoutDragChanges, autoLayoutDragValue, hitAutoLayoutHandle, measureAutoLayoutHandles } from "./layout/auto-layout-handles.js";
|
|
2
3
|
import { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from "./layout/derived.js";
|
|
3
4
|
import { applyLockedAspectRatio, applyMinMaxConstraints, configureAbsoluteChild, configureNonTextLeaf, createYogaNode, freeYogaTree, mapAlignSelf, mapGridTrack, parentStretchedAxis } from "./layout/yoga-helpers.js";
|
|
4
5
|
import { insertFlowBox, setFlexFlow, setFlowEdges } from "./layout/flow-edges.js";
|
|
@@ -384,6 +385,6 @@ function configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis = fals
|
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
387
|
//#endregion
|
|
387
|
-
export { computeAllLayouts, computeLayout, estimateTextSize, getTextMeasurer, installTextMeasurer, layoutAuthoredNodes, routeUnroutedConnectors, setTextMeasurer, sizeAutoResizingText };
|
|
388
|
+
export { autoLayoutDragChanges, autoLayoutDragValue, computeAllLayouts, computeLayout, estimateTextSize, getTextMeasurer, hitAutoLayoutHandle, installTextMeasurer, layoutAuthoredNodes, measureAutoLayoutHandles, measureTextForLayout, routeUnroutedConnectors, setTextMeasurer, sizeAutoResizingText };
|
|
388
389
|
|
|
389
390
|
//# sourceMappingURL=layout.js.map
|
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}\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,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 { 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":";;;;;;;;;;;;;;;;;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,+B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AM,SAAS,qBAAqB,OAAO,QAAQ,mBAAmB,KAAK,CAAC;GAC5E,MAAM,IAAI,UAAU,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"}
|
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,5 +1,5 @@
|
|
|
1
1
|
import { ownsComponentTree } from "./utils.js";
|
|
2
|
-
import { paintBindingTarget } from "@pairdraw/scene-graph/variables";
|
|
2
|
+
import { isNumericVariableBindingField, paintBindingTarget } from "@pairdraw/scene-graph/variables";
|
|
3
3
|
import { isEmptyObject } from "es-toolkit";
|
|
4
4
|
import { colorToHex } from "@pairdraw/scene-graph/color";
|
|
5
5
|
//#region src/lint/fixes.ts
|
|
@@ -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;EAAE;EAAQ;CAAI,CAAC,IAAI,CAAC,CAAE;AAC7E;;;;;;AAOA,SAAS,QAAQ,OAAmB,MAAiB,MAAc,YAA6B;CAC9F,IAAI,KAAK,eAAe,UAAU,YAAY,OAAO;CACrD,IAAI,8BAA8B,IAAI,GAAG;EAEvC,IAAI,SAAS,cAAc,KAAK,aAAa,OAAO;EACpD,MAAM,QAAiB,QAAQ,IAAI,MAAM,IAAI;EAC7C,OACE,OAAO,UAAU,YAAY,UAAU,MAAM,6BAA6B,KAAK,IAAI,UAAU;CAEjG;CACA,MAAM,SAAS,mBAAmB,IAAI;CACtC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAQ,KAAK,OAAO,KAAK,CAAC,GAAG,OAAO,KAAK;CAC/C,MAAM,QAAQ,MAAM,4BAA4B,KAAK,IAAI,UAAU;CACnE,IAAI,CAAC,SAAS,CAAC,SAAU,UAAU,SAAS,MAAM,SAAS,SAAU,OAAO;CAC5E,OAAO,WAAW;EAAE,GAAG,MAAM;EAAO,GAAG;CAAE,CAAC,MAAM,WAAW;EAAE,GAAG;EAAO,GAAG;CAAE,CAAC;AAC/E;AAEA,UAAU,U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,WAAW,YAAY,IAAI,MAAM,KAAK,CAAC,eAAe,OAAO,IAAI,GACjF;IACF,YAAY,IAAI,MAAM;IACtB;GACF,KAAK;IAEH,IAAI,KAAK,WAAW,UAAU,IAAI,MAAM,KAAK,CAAC,eAAe,OAAO,IAAI,GAAG;IAC3E,UAAU,IAAI,MAAM;EAExB;EACA;CACF;CACA,KAAK,MAAM,CAAC,QAAQ,YAAY,SAAS,OAAO,WAAW,QAAQ,OAAO;CAC1E,KAAK,MAAM,UAAU,aAAa,OAAO,eAAe,MAAM;CAC9D,MAAM,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC,QAAQ,WAAW;EAC9C,MAAM,OAAO,MAAM,QAAQ,MAAM;EACjC,OAAO,OAAO,CAAC,cAAc,OAAO,MAAM,SAAS,IAAI;CACzD,CAAC;CACD,IAAI,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 };
|