@pairdraw/core 0.19.1 → 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/previews.d.ts +1 -1
- 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/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +0 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -2
- 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 -4
- 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 -3
- 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/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.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/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.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 +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- 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 +6 -3
- 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/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- 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 +6 -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/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +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 +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- 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/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -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/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -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/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +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.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- 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/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.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/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.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 +4 -54
- 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 +224 -50
- 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/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- 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 +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- 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/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- 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/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -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/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- 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/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- 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/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.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 +22 -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/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.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/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +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/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- 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 -3
- package/src/canvas/renderer.ts +40 -4
- 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-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- 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/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- 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 +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- 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 +17 -1
- 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/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -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/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- 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 +5 -1
- 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/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- 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 +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- 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/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -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/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- 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/layout.ts +5 -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/nodes.ts +0 -1
- 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 +34 -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/path.ts +30 -6
- 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
- package/src/xpath.ts +6 -1
|
@@ -13,7 +13,20 @@ import { enforcedAspectRatio, layoutSizingInParent } from '@pairdraw/scene-graph
|
|
|
13
13
|
const yogaConfig = Yoga.Config.create()
|
|
14
14
|
yogaConfig.setPointScaleFactor(0)
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Yoga nodes built and not freed yet. Yoga's nodes live in WebAssembly memory the caller owns, so a
|
|
18
|
+
* pass that leaves its tree behind holds that memory and the nodes it holds; a test reads this to
|
|
19
|
+
* see one freed on every path.
|
|
20
|
+
*/
|
|
21
|
+
let liveYogaNodes = 0
|
|
22
|
+
|
|
23
|
+
/** Yoga nodes created and not yet freed by `freeYogaTree`. */
|
|
24
|
+
export function liveYogaNodeCount(): number {
|
|
25
|
+
return liveYogaNodes
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
export function createYogaNode(): YogaNode {
|
|
29
|
+
liveYogaNodes += 1
|
|
17
30
|
return Yoga.Node.create(yogaConfig)
|
|
18
31
|
}
|
|
19
32
|
|
|
@@ -100,7 +113,11 @@ export function freeYogaTree(node: YogaNode): void {
|
|
|
100
113
|
for (let i = node.getChildCount() - 1; i >= 0; i--) {
|
|
101
114
|
freeYogaTree(node.getChild(i))
|
|
102
115
|
}
|
|
103
|
-
|
|
116
|
+
// Wasm-backed nodes carry `free`, which `yoga-layout`'s type leaves out.
|
|
117
|
+
if ('free' in node && typeof node.free === 'function') {
|
|
118
|
+
node.free()
|
|
119
|
+
liveYogaNodes -= 1
|
|
120
|
+
}
|
|
104
121
|
}
|
|
105
122
|
|
|
106
123
|
export function mapJustify(align: string): Justify {
|
package/src/layout.ts
CHANGED
|
@@ -19,16 +19,18 @@ import {
|
|
|
19
19
|
setCrossAxisSizing,
|
|
20
20
|
setMainAxisSizing
|
|
21
21
|
} from './layout/axis-sizing'
|
|
22
|
-
import { keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'
|
|
22
|
+
import { keepsSavedFrameSize, keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'
|
|
23
23
|
import { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'
|
|
24
24
|
import { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'
|
|
25
|
-
import { buildGridTree, createGridChildNode } from './layout/grid'
|
|
25
|
+
import { buildGridTree, createGridChildNode, gridTracksForAxis } from './layout/grid'
|
|
26
26
|
import { sizeAutoResizingText } from './layout/text-auto-resize'
|
|
27
27
|
export { sizeAutoResizingText } from './layout/text-auto-resize'
|
|
28
|
+
export * from './layout/auto-layout-handles'
|
|
28
29
|
export {
|
|
29
30
|
estimateTextSize,
|
|
30
31
|
getTextMeasurer,
|
|
31
32
|
installTextMeasurer,
|
|
33
|
+
measureTextForLayout,
|
|
32
34
|
setTextMeasurer,
|
|
33
35
|
type TextMeasurer
|
|
34
36
|
} from './layout/text-measurement'
|
|
@@ -37,7 +39,12 @@ import { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/conne
|
|
|
37
39
|
import { layoutSizing } from '@pairdraw/scene-graph/layout'
|
|
38
40
|
|
|
39
41
|
import { fitShapeWithTextFrame } from './layout/shape-with-text'
|
|
40
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
applyContentInsets,
|
|
44
|
+
applyStrokeMargins,
|
|
45
|
+
contentInsetsSize,
|
|
46
|
+
strokeRoom
|
|
47
|
+
} from './layout/strokes'
|
|
41
48
|
import {
|
|
42
49
|
autoWidthWrapWidth,
|
|
43
50
|
estimateTextSize,
|
|
@@ -77,13 +84,19 @@ function computeLayoutInternal(graph: SceneGraph, frameId: string): void {
|
|
|
77
84
|
|
|
78
85
|
const rootDirection = resolveComputedLayoutDirection(graph, frame)
|
|
79
86
|
const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
// The tree is freed on every path, a refused pass included: Yoga's nodes are WebAssembly memory
|
|
88
|
+
// the caller owns, so a throw must not leave them behind.
|
|
89
|
+
let yogaRoot: YogaNode | null = null
|
|
90
|
+
try {
|
|
91
|
+
yogaRoot =
|
|
92
|
+
frame.layoutMode === 'GRID'
|
|
93
|
+
? buildGridTree(graph, frame, rootDirection)
|
|
94
|
+
: buildYogaTree(graph, frame, rootDirection)
|
|
95
|
+
yogaRoot.calculateLayout(undefined, undefined, yogaDirection)
|
|
96
|
+
applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)
|
|
97
|
+
} finally {
|
|
98
|
+
if (yogaRoot) freeYogaTree(yogaRoot)
|
|
99
|
+
}
|
|
87
100
|
}
|
|
88
101
|
function resolveComputedLayoutDirection(
|
|
89
102
|
graph: SceneGraph,
|
|
@@ -175,27 +188,37 @@ function buildYogaTree(
|
|
|
175
188
|
): YogaNode {
|
|
176
189
|
const root = createYogaNode()
|
|
177
190
|
const direction = resolveNodeLayoutDirection(frame, inheritedDirection)
|
|
191
|
+
const insets = keepsSavedFrameSize(graph, frame) ? null : contentInsetsSize(frame)
|
|
192
|
+
const width = insets ? Math.max(frame.width, insets.width) : frame.width
|
|
193
|
+
const height = insets ? Math.max(frame.height, insets.height) : frame.height
|
|
178
194
|
|
|
179
195
|
if (frame.primaryAxisSizing === 'FIXED') {
|
|
180
|
-
if (frame.layoutMode === 'HORIZONTAL') root.setWidth(
|
|
181
|
-
else root.setHeight(
|
|
196
|
+
if (frame.layoutMode === 'HORIZONTAL') root.setWidth(width)
|
|
197
|
+
else root.setHeight(height)
|
|
182
198
|
}
|
|
183
199
|
if (frame.counterAxisSizing === 'FIXED') {
|
|
184
|
-
if (frame.layoutMode === 'HORIZONTAL') root.setHeight(
|
|
185
|
-
else root.setWidth(
|
|
200
|
+
if (frame.layoutMode === 'HORIZONTAL') root.setHeight(height)
|
|
201
|
+
else root.setWidth(width)
|
|
186
202
|
}
|
|
187
203
|
// Laid out on its own, a frame its parent stretches keeps the size the parent gave it on
|
|
188
204
|
// that axis, so its content aligns within that size rather than within a hug.
|
|
189
205
|
const stretchedAxis = parentStretchedAxis(graph, frame)
|
|
190
|
-
if (stretchedAxis === 'width') root.setWidth(
|
|
191
|
-
if (stretchedAxis === 'height') root.setHeight(
|
|
206
|
+
if (stretchedAxis === 'width') root.setWidth(width)
|
|
207
|
+
if (stretchedAxis === 'height') root.setHeight(height)
|
|
192
208
|
const heldAxis = heldHugAxis(graph, frame)
|
|
193
|
-
if (heldAxis === 'width') root.setWidth(
|
|
194
|
-
if (heldAxis === 'height') root.setHeight(
|
|
209
|
+
if (heldAxis === 'width') root.setWidth(width)
|
|
210
|
+
if (heldAxis === 'height') root.setHeight(height)
|
|
195
211
|
|
|
196
212
|
configureFlexContainer(root, frame, direction)
|
|
197
213
|
|
|
198
|
-
|
|
214
|
+
try {
|
|
215
|
+
insertFlexChildren(root, frame, graph, direction, 1)
|
|
216
|
+
} catch (error) {
|
|
217
|
+
// The depth check refuses a chain while the tree is half built; every node made so far hangs
|
|
218
|
+
// from the root, which has no other holder.
|
|
219
|
+
freeYogaTree(root)
|
|
220
|
+
throw error
|
|
221
|
+
}
|
|
199
222
|
|
|
200
223
|
return root
|
|
201
224
|
}
|
|
@@ -213,6 +236,39 @@ function configureFlexContainer(
|
|
|
213
236
|
applyMinMaxConstraints(yogaNode, node)
|
|
214
237
|
}
|
|
215
238
|
|
|
239
|
+
/**
|
|
240
|
+
* A grid child's box in its flex parent: grow takes the free space, a fixed size is stored, and
|
|
241
|
+
* an axis the grid hugs takes its tracks' size there, as configureAsGrid lays it out.
|
|
242
|
+
*/
|
|
243
|
+
function applyGridChildBox(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {
|
|
244
|
+
const isParentRow = parent.layoutMode === 'HORIZONTAL'
|
|
245
|
+
const selfOverride = child.layoutAlignSelf !== 'AUTO'
|
|
246
|
+
const stretchCross = selfOverride
|
|
247
|
+
? child.layoutAlignSelf === 'STRETCH'
|
|
248
|
+
: parent.counterAxisAlign === 'STRETCH'
|
|
249
|
+
const hugWidth = ownAxisSizing(child, 'width') === 'HUG'
|
|
250
|
+
const hugHeight = ownAxisSizing(child, 'height') === 'HUG'
|
|
251
|
+
if (child.layoutGrow > 0) {
|
|
252
|
+
yogaChild.setFlexGrow(child.layoutGrow)
|
|
253
|
+
yogaChild.setFlexShrink(1)
|
|
254
|
+
yogaChild.setFlexBasis(0)
|
|
255
|
+
if (stretchCross) return
|
|
256
|
+
if (isParentRow) {
|
|
257
|
+
if (!hugHeight) yogaChild.setHeight(child.height)
|
|
258
|
+
} else if (!hugWidth) {
|
|
259
|
+
yogaChild.setWidth(child.width)
|
|
260
|
+
}
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
if (isParentRow) {
|
|
264
|
+
if (!hugWidth) yogaChild.setWidth(child.width)
|
|
265
|
+
if (!stretchCross && !hugHeight) yogaChild.setHeight(child.height)
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
if (child.gridTemplateRows.length > 0 && !hugHeight) yogaChild.setHeight(child.height)
|
|
269
|
+
if (!stretchCross && !hugWidth) yogaChild.setWidth(child.width)
|
|
270
|
+
}
|
|
271
|
+
|
|
216
272
|
function configureChildAsGrid(
|
|
217
273
|
yogaChild: YogaNode,
|
|
218
274
|
child: SceneNode,
|
|
@@ -225,40 +281,17 @@ function configureChildAsGrid(
|
|
|
225
281
|
yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)
|
|
226
282
|
|
|
227
283
|
if (child.gridTemplateColumns.length > 0) {
|
|
228
|
-
yogaChild.setGridTemplateColumns(child.
|
|
284
|
+
yogaChild.setGridTemplateColumns(gridTracksForAxis(child, 'width').map(mapGridTrack))
|
|
229
285
|
}
|
|
230
286
|
if (child.gridTemplateRows.length > 0) {
|
|
231
|
-
yogaChild.setGridTemplateRows(child.
|
|
287
|
+
yogaChild.setGridTemplateRows(gridTracksForAxis(child, 'height').map(mapGridTrack))
|
|
232
288
|
}
|
|
233
289
|
|
|
234
290
|
yogaChild.setGap(Gutter.Column, child.gridColumnGap)
|
|
235
291
|
yogaChild.setGap(Gutter.Row, child.gridRowGap)
|
|
236
292
|
|
|
237
293
|
applyContentInsets(yogaChild, child)
|
|
238
|
-
|
|
239
|
-
const isParentRow = parent.layoutMode === 'HORIZONTAL'
|
|
240
|
-
const selfOverride = child.layoutAlignSelf !== 'AUTO'
|
|
241
|
-
const stretchCross = selfOverride
|
|
242
|
-
? child.layoutAlignSelf === 'STRETCH'
|
|
243
|
-
: parent.counterAxisAlign === 'STRETCH'
|
|
244
|
-
|
|
245
|
-
if (child.layoutGrow > 0) {
|
|
246
|
-
yogaChild.setFlexGrow(child.layoutGrow)
|
|
247
|
-
yogaChild.setFlexShrink(1)
|
|
248
|
-
yogaChild.setFlexBasis(0)
|
|
249
|
-
if (!stretchCross) {
|
|
250
|
-
if (isParentRow) yogaChild.setHeight(child.height)
|
|
251
|
-
else yogaChild.setWidth(child.width)
|
|
252
|
-
}
|
|
253
|
-
} else {
|
|
254
|
-
if (isParentRow) {
|
|
255
|
-
yogaChild.setWidth(child.width)
|
|
256
|
-
if (!stretchCross) yogaChild.setHeight(child.height)
|
|
257
|
-
} else {
|
|
258
|
-
if (child.gridTemplateRows.length > 0) yogaChild.setHeight(child.height)
|
|
259
|
-
if (!stretchCross) yogaChild.setWidth(child.width)
|
|
260
|
-
}
|
|
261
|
-
}
|
|
294
|
+
applyGridChildBox(yogaChild, child, parent)
|
|
262
295
|
|
|
263
296
|
const selfAlign = mapAlignSelf(child.layoutAlignSelf)
|
|
264
297
|
if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)
|
|
@@ -399,6 +432,9 @@ function insertFlexChildren(
|
|
|
399
432
|
.getChildren(parent.id)
|
|
400
433
|
.map((node) => asLaidOutIn(graph, node, parent))) {
|
|
401
434
|
const yogaChild = createYogaNode()
|
|
435
|
+
// Attached before it is configured, so a child the depth check refuses still hangs from the
|
|
436
|
+
// root and is freed with it rather than left in WebAssembly memory.
|
|
437
|
+
box.insertChild(yogaChild, box.getChildCount())
|
|
402
438
|
|
|
403
439
|
if (child.layoutPositioning === 'ABSOLUTE') {
|
|
404
440
|
configureAbsoluteChild(yogaChild, child)
|
|
@@ -415,8 +451,6 @@ function insertFlexChildren(
|
|
|
415
451
|
flow.push(yogaChild)
|
|
416
452
|
}
|
|
417
453
|
applyStrokeMargins(yogaChild, child, parent)
|
|
418
|
-
|
|
419
|
-
box.insertChild(yogaChild, box.getChildCount())
|
|
420
454
|
}
|
|
421
455
|
setFlowEdges(yogaParent, box, parent, flow, direction)
|
|
422
456
|
}
|
|
@@ -478,7 +512,14 @@ function configureTextLeafWithoutMeasurer(
|
|
|
478
512
|
}
|
|
479
513
|
return
|
|
480
514
|
}
|
|
481
|
-
if (child.textAutoResize !== 'HEIGHT')
|
|
515
|
+
if (child.textAutoResize !== 'HEIGHT') {
|
|
516
|
+
// A truncating text keeps the box it has, as Figma clips it to that box.
|
|
517
|
+
if (child.width > 0 && child.height > 0) {
|
|
518
|
+
yogaChild.setWidth(child.width)
|
|
519
|
+
yogaChild.setHeight(child.height)
|
|
520
|
+
}
|
|
521
|
+
return
|
|
522
|
+
}
|
|
482
523
|
|
|
483
524
|
const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)
|
|
484
525
|
const isRow = parent.layoutMode === 'HORIZONTAL'
|
|
@@ -510,7 +551,8 @@ function configureChildAsLeaf(
|
|
|
510
551
|
|
|
511
552
|
const isText = child.type === 'TEXT'
|
|
512
553
|
const textMeasurer = getTextMeasurer()
|
|
513
|
-
|
|
554
|
+
// A truncating or fixed text keeps its box, so Yoga measures only text that grows.
|
|
555
|
+
const needsMeasureFunc = isText && textMeasurer && growsText(child)
|
|
514
556
|
|
|
515
557
|
const fixedDerivedMainAxis = isRow
|
|
516
558
|
? derivedGrowingLeafFitsParent(graph, parent, child, 'width')
|
|
@@ -542,6 +584,11 @@ function configureChildAsLeaf(
|
|
|
542
584
|
applyMinMaxConstraints(yogaChild, child)
|
|
543
585
|
}
|
|
544
586
|
|
|
587
|
+
/** Whether layout measures a text to size it, which only the two growing modes need. */
|
|
588
|
+
function growsText(node: SceneNode): boolean {
|
|
589
|
+
return node.textAutoResize === 'WIDTH_AND_HEIGHT' || node.textAutoResize === 'HEIGHT'
|
|
590
|
+
}
|
|
591
|
+
|
|
545
592
|
function configureTextLeaf(
|
|
546
593
|
yogaChild: YogaNode,
|
|
547
594
|
child: SceneNode,
|
package/src/lint/fixes.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { isEmptyObject } from 'es-toolkit'
|
|
|
2
2
|
|
|
3
3
|
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
4
4
|
import { colorToHex } from '@pairdraw/scene-graph/color'
|
|
5
|
-
import { paintBindingTarget } from '@pairdraw/scene-graph/variables'
|
|
5
|
+
import { isNumericVariableBindingField, paintBindingTarget } from '@pairdraw/scene-graph/variables'
|
|
6
6
|
|
|
7
7
|
import type { LintFix, LintMessage } from './types'
|
|
8
8
|
import { ownsComponentTree } from './utils'
|
|
@@ -44,11 +44,20 @@ export function safeFixes(messages: readonly LintMessage[]): LintFixRequest[] {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Binding is safe only while the paint still shows the variable's color
|
|
48
|
-
* the lint run would change appearance, so its fix is
|
|
47
|
+
* Binding is safe only while the paint still shows the variable's color, or the field still holds
|
|
48
|
+
* the variable's number: one edited since the lint run would change appearance, so its fix is
|
|
49
|
+
* skipped.
|
|
49
50
|
*/
|
|
50
51
|
function canBind(graph: SceneGraph, node: SceneNode, path: string, variableId: string): boolean {
|
|
51
52
|
if (node.boundVariables[path] === variableId) return false
|
|
53
|
+
if (isNumericVariableBindingField(path)) {
|
|
54
|
+
// A text style supplies the layer's type values; the binding belongs on the style.
|
|
55
|
+
if (path === 'fontSize' && node.textStyleId) return false
|
|
56
|
+
const value: unknown = Reflect.get(node, path)
|
|
57
|
+
return (
|
|
58
|
+
typeof value === 'number' && value === graph.resolveNumberVariableForNode(node.id, variableId)
|
|
59
|
+
)
|
|
60
|
+
}
|
|
52
61
|
const target = paintBindingTarget(path)
|
|
53
62
|
if (!target) return false
|
|
54
63
|
const paint = node[target.list].at(target.index)
|
package/src/lint/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { defineRule } from './rule'
|
|
|
3
3
|
export { applyLintFixes, graphFixTarget, safeFixes } from './fixes'
|
|
4
4
|
export type { LintFixRequest, LintFixTarget } from './fixes'
|
|
5
5
|
export { allRules } from './rules'
|
|
6
|
+
export { DESIGN_MEMORY_RULE_IDS } from './rules/design-memory'
|
|
6
7
|
export { presets, recommended, strict, accessibility } from './presets'
|
|
7
8
|
export type {
|
|
8
9
|
Rule,
|
|
@@ -16,5 +17,6 @@ export type {
|
|
|
16
17
|
LintResult,
|
|
17
18
|
LintConfig,
|
|
18
19
|
Severity,
|
|
19
|
-
Category
|
|
20
|
+
Category,
|
|
21
|
+
LintDesignMemory
|
|
20
22
|
} from './types'
|
package/src/lint/linter.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { uniq } from 'es-toolkit'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { variableNamespace } from '@pairdraw/dom-css/export'
|
|
4
|
+
import type { SceneGraph, SceneNode, SharedStyleType } from '@pairdraw/scene-graph'
|
|
4
5
|
import { colorToHex } from '@pairdraw/scene-graph/color'
|
|
6
|
+
import { cachedDesignMemory, DESIGN_MEMORY_GROUPS } from '@pairdraw/scene-graph/design-memory'
|
|
7
|
+
import { sharedStyleLayers, sharedStyleTypeForKind } from '@pairdraw/scene-graph/shared-styles'
|
|
8
|
+
|
|
9
|
+
import { currentDesignRules, designViolations, type DesignViolation } from '#core/design-memory'
|
|
5
10
|
|
|
6
11
|
import { presets } from './presets'
|
|
7
12
|
import { allRules } from './rules'
|
|
13
|
+
import { DESIGN_MEMORY_RULE_IDS, designMemoryRules } from './rules/design-memory'
|
|
8
14
|
import type {
|
|
9
15
|
LintConfig,
|
|
16
|
+
LintDesignMemory,
|
|
10
17
|
LintVariables,
|
|
11
18
|
LintMessage,
|
|
12
19
|
LintNode,
|
|
13
20
|
LintResult,
|
|
14
21
|
Rule,
|
|
15
22
|
RuleContext,
|
|
16
|
-
Severity
|
|
23
|
+
Severity,
|
|
24
|
+
TokenNumberField
|
|
17
25
|
} from './types'
|
|
18
26
|
import { getNodePath } from './utils'
|
|
19
27
|
|
|
@@ -28,6 +36,11 @@ function effectiveTextStyles(node: SceneNode): { fontSize: number; fontWeight: n
|
|
|
28
36
|
return covered < node.text.length || runs.length === 0 ? [base, ...runs] : runs
|
|
29
37
|
}
|
|
30
38
|
|
|
39
|
+
type RuleSettings = { severity: Severity; options?: Record<string, unknown> }
|
|
40
|
+
|
|
41
|
+
/** How mild each reported severity is, so a finding can only soften its rule's. */
|
|
42
|
+
const SEVERITY_RANK: Record<Exclude<Severity, 'off'>, number> = { error: 0, warning: 1, info: 2 }
|
|
43
|
+
|
|
31
44
|
/** A preset's rules, refusing a name no preset has so a typo cannot silently disable linting. */
|
|
32
45
|
function presetRules(id: string) {
|
|
33
46
|
if (!Object.hasOwn(presets, id)) {
|
|
@@ -39,7 +52,7 @@ function presetRules(id: string) {
|
|
|
39
52
|
|
|
40
53
|
export class Linter {
|
|
41
54
|
private rules = new Map<string, Rule>()
|
|
42
|
-
private ruleConfigs = new Map<string,
|
|
55
|
+
private ruleConfigs = new Map<string, RuleSettings | undefined>()
|
|
43
56
|
private messages: LintMessage[] = []
|
|
44
57
|
private graph: SceneGraph | null = null
|
|
45
58
|
/** The enabled rules with their contexts, made once per run rather than once per layer. */
|
|
@@ -47,8 +60,15 @@ export class Linter {
|
|
|
47
60
|
private nodes = new Map<string, LintNode>()
|
|
48
61
|
private variables: LintVariables = {
|
|
49
62
|
counts: { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 },
|
|
50
|
-
colorsByHex: new Map()
|
|
63
|
+
colorsByHex: new Map(),
|
|
64
|
+
numbersByField: new Map()
|
|
51
65
|
}
|
|
66
|
+
private sharedStyleTypes: ReadonlyMap<string, SharedStyleType> = new Map()
|
|
67
|
+
private design: LintDesignMemory | null = null
|
|
68
|
+
/** Rules the configuration names, which a document's design memory does not override. */
|
|
69
|
+
private configured = new Set<string>()
|
|
70
|
+
/** The only rules to run, when the caller named them. */
|
|
71
|
+
private only: ReadonlySet<string> | null = null
|
|
52
72
|
|
|
53
73
|
constructor(options: { config?: LintConfig; preset?: string; rules?: string[] } = {}) {
|
|
54
74
|
let baseConfig: Record<
|
|
@@ -63,6 +83,8 @@ export class Linter {
|
|
|
63
83
|
for (const id of ids) baseConfig = { ...baseConfig, ...presetRules(id) }
|
|
64
84
|
}
|
|
65
85
|
if (options.config?.rules) baseConfig = { ...baseConfig, ...options.config.rules }
|
|
86
|
+
this.configured = new Set(Object.keys(options.config?.rules ?? {}))
|
|
87
|
+
this.only = options.rules ? new Set(options.rules) : null
|
|
66
88
|
const rulesToLoad = options.rules ?? Object.keys(baseConfig)
|
|
67
89
|
for (const ruleId of rulesToLoad) {
|
|
68
90
|
if (!Object.hasOwn(allRules, ruleId)) throw new Error(`Unknown lint rule "${ruleId}"`)
|
|
@@ -80,11 +102,14 @@ export class Linter {
|
|
|
80
102
|
this.nodes.clear()
|
|
81
103
|
this.graph = graph
|
|
82
104
|
this.variables = describeVariables(graph)
|
|
105
|
+
this.sharedStyleTypes = sharedStyleTypes(graph)
|
|
106
|
+
this.design = this.describeDesign(graph)
|
|
83
107
|
this.checks = this.ruleChecks()
|
|
84
108
|
const roots = rootIds && rootIds.length > 0 ? rootIds : graph.getPages().map((p) => p.id)
|
|
85
109
|
for (const id of outermostRoots(graph, roots)) this.lintNode(id, undefined)
|
|
86
110
|
this.graph = null
|
|
87
111
|
this.checks = []
|
|
112
|
+
this.design = null
|
|
88
113
|
return {
|
|
89
114
|
messages: this.messages,
|
|
90
115
|
errorCount: this.messages.filter((m) => m.severity === 'error').length,
|
|
@@ -164,25 +189,81 @@ export class Linter {
|
|
|
164
189
|
effects: raw.effects.map((effect) => ({
|
|
165
190
|
type: effect.type,
|
|
166
191
|
visible: effect.visible,
|
|
167
|
-
radius: effect.type === 'SHADER' ? 0 : effect.radius
|
|
168
|
-
}))
|
|
192
|
+
radius: effect.type === 'SHADER' || effect.type === 'NOISE' ? 0 : effect.radius
|
|
193
|
+
})),
|
|
194
|
+
textStyleId: raw.textStyleId,
|
|
195
|
+
effectStyleId: raw.effectStyleId
|
|
169
196
|
}
|
|
170
197
|
}
|
|
171
198
|
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The document's design memory, which its own rules check layers against. A memory's group
|
|
201
|
+
* replaces the generic scale rule for the same values.
|
|
202
|
+
*/
|
|
203
|
+
private describeDesign(graph: SceneGraph): LintDesignMemory | null {
|
|
204
|
+
const memory = cachedDesignMemory(graph)
|
|
205
|
+
if (!memory) return null
|
|
206
|
+
const rules = currentDesignRules(graph, memory)
|
|
207
|
+
const found = new Map<string, readonly DesignViolation[]>()
|
|
208
|
+
return {
|
|
209
|
+
rules,
|
|
210
|
+
violations: (node) => {
|
|
211
|
+
const cached = found.get(node.id)
|
|
212
|
+
if (cached) return cached
|
|
213
|
+
const raw = graph.getNode(node.id)
|
|
214
|
+
const violations = raw ? designViolations(rules, raw) : []
|
|
215
|
+
found.set(node.id, violations)
|
|
216
|
+
return violations
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The rules this run checks with their settings: the configured ones and the memory's. */
|
|
222
|
+
private activeRules(): [string, Rule, RuleSettings][] {
|
|
223
|
+
const active: [string, Rule, RuleSettings][] = []
|
|
224
|
+
const rules = this.design?.rules
|
|
225
|
+
const superseded = new Set<string>()
|
|
226
|
+
if (rules && rules.spacing.enforce !== 'off') superseded.add('consistent-spacing')
|
|
227
|
+
if (rules && rules.radius.enforce !== 'off') superseded.add('consistent-radius')
|
|
174
228
|
for (const [ruleId, rule] of this.rules) {
|
|
229
|
+
if (ruleId in designMemoryRules && !rules) continue
|
|
230
|
+
if (superseded.has(ruleId) && !this.configured.has(ruleId)) continue
|
|
175
231
|
const config = this.ruleConfigs.get(ruleId)
|
|
176
|
-
if (
|
|
232
|
+
if (config) active.push([ruleId, rule, config])
|
|
233
|
+
}
|
|
234
|
+
if (!rules) return active
|
|
235
|
+
for (const group of DESIGN_MEMORY_GROUPS) {
|
|
236
|
+
const ruleId = DESIGN_MEMORY_RULE_IDS[group]
|
|
237
|
+
if (this.ruleConfigs.get(ruleId) || this.configured.has(ruleId)) continue
|
|
238
|
+
if (this.only && !this.only.has(ruleId)) continue
|
|
239
|
+
const enforce = rules[group].enforce
|
|
240
|
+
if (enforce === 'off') continue
|
|
241
|
+
active.push([
|
|
242
|
+
ruleId,
|
|
243
|
+
designMemoryRules[ruleId],
|
|
244
|
+
{ severity: enforce === 'refuse' ? 'error' : 'warning' }
|
|
245
|
+
])
|
|
246
|
+
}
|
|
247
|
+
return active
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private ruleChecks(): { rule: Rule; context: RuleContext }[] {
|
|
251
|
+
const checks: { rule: Rule; context: RuleContext }[] = []
|
|
252
|
+
for (const [ruleId, rule, config] of this.activeRules()) {
|
|
253
|
+
if (config.severity === 'off') continue
|
|
177
254
|
const severity = config.severity
|
|
178
255
|
checks.push({
|
|
179
256
|
rule,
|
|
180
257
|
context: {
|
|
181
258
|
variables: this.variables,
|
|
182
|
-
|
|
259
|
+
isSharedStyle: (kind, id) =>
|
|
260
|
+
id !== null && this.sharedStyleTypes.get(id) === sharedStyleTypeForKind(kind),
|
|
261
|
+
design: this.design,
|
|
262
|
+
report: ({ node, message, suggest, data, fix, suggestions, severity: milder }) => {
|
|
183
263
|
this.messages.push({
|
|
184
264
|
ruleId,
|
|
185
|
-
severity
|
|
265
|
+
severity:
|
|
266
|
+
milder && SEVERITY_RANK[milder] > SEVERITY_RANK[severity] ? milder : severity,
|
|
186
267
|
message,
|
|
187
268
|
nodeId: node.id,
|
|
188
269
|
nodeName: node.name,
|
|
@@ -234,18 +315,49 @@ function outermostRoots(graph: SceneGraph, ids: readonly string[]): string[] {
|
|
|
234
315
|
})
|
|
235
316
|
}
|
|
236
317
|
|
|
318
|
+
/** The type of each shared style in the document, by the source id layers link it by. */
|
|
319
|
+
function sharedStyleTypes(graph: SceneGraph): ReadonlyMap<string, SharedStyleType> {
|
|
320
|
+
const types = new Map<string, SharedStyleType>()
|
|
321
|
+
for (const [id, style] of sharedStyleLayers(graph))
|
|
322
|
+
if (style.sharedStyleType) types.set(id, style.sharedStyleType)
|
|
323
|
+
return types
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The layer fields each Tailwind namespace of number tokens sets. */
|
|
327
|
+
const NAMESPACE_FIELDS: Readonly<Record<string, readonly TokenNumberField[]>> = {
|
|
328
|
+
radius: ['cornerRadius'],
|
|
329
|
+
spacing: ['itemSpacing', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],
|
|
330
|
+
text: ['fontSize']
|
|
331
|
+
}
|
|
332
|
+
|
|
237
333
|
function describeVariables(graph: SceneGraph): LintVariables {
|
|
238
334
|
const counts = { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 }
|
|
239
335
|
const colorsByHex = new Map<string, { id: string; name: string }>()
|
|
336
|
+
const numbersByField = new Map<TokenNumberField, Map<number, { id: string; name: string }[]>>()
|
|
240
337
|
for (const variable of graph.variables.values()) {
|
|
241
338
|
counts[variable.type]++
|
|
339
|
+
if (variable.type === 'FLOAT') {
|
|
340
|
+
const namespace = variableNamespace(variable)
|
|
341
|
+
const value = graph.resolveNumberVariable(variable.id)
|
|
342
|
+
if (!namespace || value === undefined) continue
|
|
343
|
+
for (const field of NAMESPACE_FIELDS[namespace] ?? []) {
|
|
344
|
+
const byValue =
|
|
345
|
+
numbersByField.get(field) ?? new Map<number, { id: string; name: string }[]>()
|
|
346
|
+
byValue.set(value, [
|
|
347
|
+
...(byValue.get(value) ?? []),
|
|
348
|
+
{ id: variable.id, name: variable.name }
|
|
349
|
+
])
|
|
350
|
+
numbersByField.set(field, byValue)
|
|
351
|
+
}
|
|
352
|
+
continue
|
|
353
|
+
}
|
|
242
354
|
if (variable.type !== 'COLOR') continue
|
|
243
355
|
const color = graph.resolveColorVariable(variable.id)
|
|
244
356
|
if (!color || color.a < 1) continue
|
|
245
357
|
const hex = colorToHex(color)
|
|
246
358
|
if (!colorsByHex.has(hex)) colorsByHex.set(hex, { id: variable.id, name: variable.name })
|
|
247
359
|
}
|
|
248
|
-
return { counts, colorsByHex }
|
|
360
|
+
return { counts, colorsByHex, numbersByField }
|
|
249
361
|
}
|
|
250
362
|
|
|
251
363
|
export function createLinter(options?: { config?: LintConfig; preset?: string; rules?: string[] }) {
|
package/src/lint/presets.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface Preset {
|
|
|
13
13
|
export const recommended: Preset = {
|
|
14
14
|
rules: {
|
|
15
15
|
'no-hardcoded-colors': 'info',
|
|
16
|
+
'no-unbound-token-values': 'info',
|
|
16
17
|
'no-default-names': 'info',
|
|
17
18
|
'prefer-auto-layout': 'info',
|
|
18
19
|
'consistent-spacing': 'info',
|
|
@@ -44,6 +45,7 @@ export const accessibility: Preset = {
|
|
|
44
45
|
'touch-target-size': 'error',
|
|
45
46
|
'min-text-size': 'error',
|
|
46
47
|
'no-hardcoded-colors': 'off',
|
|
48
|
+
'no-unbound-token-values': 'off',
|
|
47
49
|
'no-default-names': 'off',
|
|
48
50
|
'prefer-auto-layout': 'off',
|
|
49
51
|
'consistent-spacing': 'off',
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DESIGN_MEMORY_GROUPS, type DesignMemoryGroup } from '@pairdraw/scene-graph/design-memory'
|
|
2
|
+
|
|
3
|
+
import { DESIGN_VALUE_NOUNS, type DesignViolation } from '#core/design-memory'
|
|
4
|
+
import { defineRule } from '#core/lint/rule'
|
|
5
|
+
import type { LintFix, LintFixProperty, LintMessageData, Rule } from '#core/lint/types'
|
|
6
|
+
|
|
7
|
+
/** The rule that checks each group of the document's design memory. */
|
|
8
|
+
export const DESIGN_MEMORY_RULE_IDS = {
|
|
9
|
+
colors: 'design-memory-colors',
|
|
10
|
+
fonts: 'design-memory-fonts',
|
|
11
|
+
fontSizes: 'design-memory-font-sizes',
|
|
12
|
+
spacing: 'design-memory-spacing',
|
|
13
|
+
radius: 'design-memory-radius'
|
|
14
|
+
} as const satisfies Record<DesignMemoryGroup, string>
|
|
15
|
+
|
|
16
|
+
const DESCRIPTIONS: Record<DesignMemoryGroup, string> = {
|
|
17
|
+
colors: "Colors should be ones the document's design memory allows",
|
|
18
|
+
fonts: "Fonts should be ones the document's design memory allows",
|
|
19
|
+
fontSizes: "Font sizes should follow the document's design memory",
|
|
20
|
+
spacing: "Spacing should follow the document's design memory",
|
|
21
|
+
radius: "Corner radii should follow the document's design memory"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The numeric fields a lint fix may set that the memory's groups judge. */
|
|
25
|
+
const SETTABLE: ReadonlySet<string> = new Set<LintFixProperty>([
|
|
26
|
+
'fontSize',
|
|
27
|
+
'itemSpacing',
|
|
28
|
+
'paddingTop',
|
|
29
|
+
'paddingRight',
|
|
30
|
+
'paddingBottom',
|
|
31
|
+
'paddingLeft',
|
|
32
|
+
'cornerRadius'
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
const BINDABLE_PAINT = /^(?:fills|strokes)\/\d+\/color$/
|
|
36
|
+
|
|
37
|
+
/** The change that puts the nearest allowed value in place, when one can. */
|
|
38
|
+
function suggestion(violation: DesignViolation): LintFix | null {
|
|
39
|
+
const { nearest, path } = violation
|
|
40
|
+
if (!nearest) return null
|
|
41
|
+
if (violation.group === 'colors') {
|
|
42
|
+
if (!nearest.variableId || !BINDABLE_PAINT.test(path)) return null
|
|
43
|
+
return {
|
|
44
|
+
kind: 'bind-variable',
|
|
45
|
+
path,
|
|
46
|
+
variableId: nearest.variableId,
|
|
47
|
+
variableName: nearest.name ?? String(nearest.value)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (typeof nearest.value !== 'number' || !SETTABLE.has(path)) return null
|
|
51
|
+
return { kind: 'set', changes: { [path]: nearest.value } }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** What a finding carries for interfaces: the value, and the nearest allowed one when there is one. */
|
|
55
|
+
function findingData(violation: DesignViolation): LintMessageData {
|
|
56
|
+
const data: Record<string, string | number> = {
|
|
57
|
+
group: violation.group,
|
|
58
|
+
path: violation.path,
|
|
59
|
+
value: violation.value
|
|
60
|
+
}
|
|
61
|
+
if (violation.nearest) data.nearest = violation.nearest.value
|
|
62
|
+
if (violation.nearest?.name) data.nearestName = violation.nearest.name
|
|
63
|
+
return data
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function memoryRule(group: DesignMemoryGroup): Rule {
|
|
67
|
+
return defineRule({
|
|
68
|
+
meta: {
|
|
69
|
+
id: DESIGN_MEMORY_RULE_IDS[group],
|
|
70
|
+
category: 'design-memory',
|
|
71
|
+
description: DESCRIPTIONS[group]
|
|
72
|
+
},
|
|
73
|
+
check(node, context) {
|
|
74
|
+
for (const violation of context.design?.violations(node) ?? []) {
|
|
75
|
+
if (violation.group !== group) continue
|
|
76
|
+
const nearest = violation.nearest
|
|
77
|
+
const fix = suggestion(violation)
|
|
78
|
+
context.report({
|
|
79
|
+
node,
|
|
80
|
+
message: `${violation.path} ${violation.value} is not an allowed ${DESIGN_VALUE_NOUNS[group]}`,
|
|
81
|
+
suggest: nearest
|
|
82
|
+
? `Use ${nearest.name ? `"${nearest.name}" ` : ''}${nearest.value}`
|
|
83
|
+
: 'Use an allowed value, or allow this one in the design memory',
|
|
84
|
+
data: findingData(violation),
|
|
85
|
+
suggestions: fix ? [fix] : undefined,
|
|
86
|
+
// Gradient stops and shadow colors only ever warn.
|
|
87
|
+
severity: violation.severity === 'warn' ? 'warning' : undefined
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The design memory's rules, by id; they run only in a document that has a memory. */
|
|
95
|
+
export const designMemoryRules: Record<string, Rule> = Object.fromEntries(
|
|
96
|
+
DESIGN_MEMORY_GROUPS.map((group) => [DESIGN_MEMORY_RULE_IDS[group], memoryRule(group)])
|
|
97
|
+
)
|