@pairdraw/core 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +74 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/colors.d.ts +20 -5
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +48 -42
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +25 -0
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
- package/dist/canvas/renderer/document-surface.js +46 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +6 -4
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -3
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -0
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +36 -3
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +2 -1
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +4 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/decorations.d.ts +2 -2
- package/dist/canvas/text/decorations.d.ts.map +1 -1
- package/dist/canvas/text/decorations.js +5 -5
- package/dist/canvas/text/decorations.js.map +1 -1
- package/dist/canvas/text/index.js +1 -1
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +2 -2
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -5
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -1
- package/dist/canvas/text/renderer.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +4 -4
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- package/dist/editor/clipboard/assets.js.map +1 -1
- package/dist/editor/clipboard/component-matches.d.ts +13 -0
- package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
- package/dist/editor/clipboard/component-matches.js +50 -0
- package/dist/editor/clipboard/component-matches.js.map +1 -0
- package/dist/editor/clipboard/dependencies.d.ts +7 -0
- package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
- package/dist/editor/clipboard/dependencies.js +5 -0
- package/dist/editor/clipboard/dependencies.js.map +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +48 -19
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -3
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +26 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +171 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +9 -2
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pencil.js +1 -1
- package/dist/editor/structure/state.d.ts.map +1 -1
- package/dist/editor/structure/state.js +2 -2
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +2 -2
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.js +3 -3
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fresh-read.d.ts +15 -0
- package/dist/figma-api/fresh-read.d.ts.map +1 -0
- package/dist/figma-api/fresh-read.js +54 -0
- package/dist/figma-api/fresh-read.js.map +1 -0
- package/dist/figma-api/graph-ref.d.ts +9 -0
- package/dist/figma-api/graph-ref.d.ts.map +1 -0
- package/dist/figma-api/graph-ref.js +14 -0
- package/dist/figma-api/graph-ref.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +3 -3
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +7 -3
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +1 -1
- package/dist/figma-api/pending-sync.d.ts.map +1 -1
- package/dist/figma-api/pending-sync.js +3 -1
- package/dist/figma-api/pending-sync.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/figma-api/variables/index.d.ts.map +1 -1
- package/dist/figma-api/variables/index.js +2 -2
- package/dist/figma-api/variables/index.js.map +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/css/known.js +1 -1
- package/dist/io/formats/design-tokens/css/known.js.map +1 -1
- package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
- package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/read.js +11 -5
- package/dist/io/formats/design-tokens/css/read.js.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.js +17 -4
- package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
- package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
- package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/values.js +24 -8
- package/dist/io/formats/design-tokens/css/values.js.map +1 -1
- package/dist/io/formats/design-tokens/decode.d.ts +7 -6
- package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/decode.js +14 -13
- package/dist/io/formats/design-tokens/decode.js.map +1 -1
- package/dist/io/formats/design-tokens/export.js +3 -3
- package/dist/io/formats/design-tokens/export.js.map +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -3
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +9 -9
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +4 -4
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +7 -7
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/design-tokens/values.d.ts +10 -5
- package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/values.js +13 -7
- package/dist/io/formats/design-tokens/values.js.map +1 -1
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -1
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts +7 -2
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +12 -13
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +9 -7
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +4 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/layers.js +2 -2
- package/dist/io/formats/mermaid/layers.js.map +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -0
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +4 -4
- package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
- package/dist/io/formats/pdf/prepare.js +2 -2
- package/dist/io/formats/pdf/prepare.js.map +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +35 -5
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/pptx/style.js +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/import.d.ts +4 -2
- package/dist/io/formats/svg/import.d.ts.map +1 -1
- package/dist/io/formats/svg/import.js +2 -1
- package/dist/io/formats/svg/import.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +8 -8
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +8 -5
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/yoga-helpers.d.ts +2 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +7 -1
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +112 -10
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/comments.d.ts +4 -1
- package/dist/pairdraw-api/comments.d.ts.map +1 -1
- package/dist/pairdraw-api/comments.js +5 -0
- package/dist/pairdraw-api/comments.js.map +1 -1
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/rpc/variables-command.js +2 -2
- package/dist/rpc/variables-command.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/provider.d.ts +15 -0
- package/dist/text/font/provider.d.ts.map +1 -0
- package/dist/text/font/provider.js +18 -0
- package/dist/text/font/provider.js.map +1 -0
- package/dist/text/font/readiness.d.ts +32 -0
- package/dist/text/font/readiness.d.ts.map +1 -0
- package/dist/text/font/{status.js → readiness.js} +8 -4
- package/dist/text/font/readiness.js.map +1 -0
- package/dist/text/index.d.ts +12 -9
- package/dist/text/index.js +6 -3
- package/dist/text/prepare.d.ts +9 -4
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +9 -4
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze/responsive/widths.d.ts +27 -0
- package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/widths.js +49 -0
- package/dist/tools/analyze/responsive/widths.js.map +1 -0
- package/dist/tools/analyze.d.ts +3 -1
- package/dist/tools/analyze.js +3 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen/tokens.d.ts.map +1 -1
- package/dist/tools/codegen/tokens.js +2 -2
- package/dist/tools/codegen/tokens.js.map +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -2
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/component-catalog.d.ts.map +1 -1
- package/dist/tools/component-catalog.js +5 -3
- package/dist/tools/component-catalog.js.map +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/css/shorthand.d.ts +20 -0
- package/dist/tools/css/shorthand.d.ts.map +1 -0
- package/dist/tools/css/shorthand.js +54 -0
- package/dist/tools/css/shorthand.js.map +1 -0
- package/dist/tools/describe/index.js +2 -2
- package/dist/tools/describe/index.js.map +1 -1
- package/dist/tools/describe/issues.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/html-host.d.ts.map +1 -1
- package/dist/tools/html-host.js +5 -3
- package/dist/tools/html-host.js.map +1 -1
- package/dist/tools/image-ai/apply.d.ts.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -3
- package/dist/tools/image-ai/apply.js.map +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/image-ai/service.d.ts.map +1 -1
- package/dist/tools/image-ai/service.js +5 -3
- package/dist/tools/image-ai/service.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/geometry.d.ts.map +1 -1
- package/dist/tools/modify/geometry.js +14 -3
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +35 -8
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +10 -10
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +56 -4
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +2 -2
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +29 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/prompts/codegen.js +1 -1
- package/dist/tools/prompts/codegen.js.map +1 -1
- package/dist/tools/read/css.d.ts +14 -0
- package/dist/tools/read/css.d.ts.map +1 -0
- package/dist/tools/read/css.js +306 -0
- package/dist/tools/read/css.js.map +1 -0
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/reactions.js +1 -1
- package/dist/tools/read/reactions.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -5
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +5 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script/host.d.ts.map +1 -1
- package/dist/tools/script/host.js +5 -3
- package/dist/tools/script/host.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/variables/collections.js +1 -1
- package/dist/tools/variables/collections.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -4
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
- package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/gradients.js +5 -5
- package/dist/vector/vectorize/svg/gradients.js.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.js +13 -12
- package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/colors.ts +76 -50
- package/src/canvas/renderer/document-surface.ts +53 -0
- package/src/canvas/renderer/fonts.ts +6 -4
- package/src/canvas/renderer/lifecycle.ts +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/assets.ts +6 -2
- package/src/editor/clipboard/component-matches.ts +65 -0
- package/src/editor/clipboard/dependencies.ts +22 -1
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/css/known.ts +1 -1
- package/src/io/formats/design-tokens/css/read.ts +20 -7
- package/src/io/formats/design-tokens/css/sync.ts +9 -4
- package/src/io/formats/design-tokens/css/values.ts +37 -9
- package/src/io/formats/design-tokens/decode.ts +17 -12
- package/src/io/formats/design-tokens/export.ts +3 -3
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -1
- package/src/io/formats/fig/export/setup.ts +25 -15
- package/src/io/formats/fig/export/variables.ts +17 -6
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -1
- package/src/tools/create/vector.ts +2 -2
- package/src/tools/css/shorthand.ts +64 -0
- package/src/tools/describe/index.ts +2 -8
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/geometry.ts +16 -3
- package/src/tools/modify/layout.ts +47 -13
- package/src/tools/modify/matching.ts +14 -11
- package/src/tools/modify/paint.ts +85 -5
- package/src/tools/modify/reactions.ts +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { DEFAULT_FONT_FAMILY } from "../constants.js";
|
|
2
|
+
import { newLayerDefaults } from "../editor/shapes/defaults.js";
|
|
3
|
+
import { isStyleNode, nearestColor, nearestNumber, styleValues, variableValues } from "./rules.js";
|
|
4
|
+
import { currentDesignRules } from "./document.js";
|
|
5
|
+
import { copiedValueKey, designValueKey, designValues } from "./values.js";
|
|
6
|
+
import { colorToHex } from "@pairdraw/scene-graph/color";
|
|
7
|
+
import { findInstanceAncestor, hasInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
8
|
+
import { DESIGN_MEMORY_GROUPS, cachedDesignMemory, normalizeDesignValue } from "@pairdraw/scene-graph/design-memory";
|
|
9
|
+
//#region src/design-memory/check.ts
|
|
10
|
+
/** The neutral colors and the font Pairdraw gives a new layer of every kind. */
|
|
11
|
+
const PAIRDRAW_DEFAULT_KEYS = /* @__PURE__ */ new Set([designValueKey("fonts", DEFAULT_FONT_FAMILY), ...[
|
|
12
|
+
"FRAME",
|
|
13
|
+
"COMPONENT",
|
|
14
|
+
"SECTION",
|
|
15
|
+
"RECTANGLE",
|
|
16
|
+
"LINE",
|
|
17
|
+
"TEXT"
|
|
18
|
+
].flatMap((type) => ["light", "dark"].flatMap((theme) => {
|
|
19
|
+
const { fills = [], strokes = [] } = newLayerDefaults(type, theme);
|
|
20
|
+
return [...fills, ...strokes].map((paint) => designValueKey("colors", colorToHex(paint.color)));
|
|
21
|
+
}))]);
|
|
22
|
+
/** Judges one value; null when the memory allows it or does not check its group. */
|
|
23
|
+
function judge(rules, node, value) {
|
|
24
|
+
const group = rules[value.group];
|
|
25
|
+
if (group.enforce === "off" || value.fromSystem && group.fromSystem) return null;
|
|
26
|
+
let nearest = null;
|
|
27
|
+
if (value.group === "colors" && typeof value.value === "string") {
|
|
28
|
+
const match = nearestColor(rules.colors, value.value);
|
|
29
|
+
if (match && match.distance <= .02) return null;
|
|
30
|
+
nearest = match?.allowed ?? null;
|
|
31
|
+
} else if (value.group === "fonts" && typeof value.value === "string") {
|
|
32
|
+
const family = value.value.toLowerCase();
|
|
33
|
+
if (rules.fonts.allowed.some((allowed) => allowed.value.toLowerCase() === family)) return null;
|
|
34
|
+
} else if (typeof value.value === "number" && value.group !== "colors" && value.group !== "fonts") {
|
|
35
|
+
const match = nearestNumber(rules[value.group], value.value);
|
|
36
|
+
if (match && Math.abs(match.value - value.value) <= .01) return null;
|
|
37
|
+
nearest = match;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
group: value.group,
|
|
41
|
+
severity: group.enforce === "refuse" && !value.soft ? "refuse" : "warn",
|
|
42
|
+
nodeId: node.id,
|
|
43
|
+
nodeName: node.name,
|
|
44
|
+
path: value.path,
|
|
45
|
+
value: value.value,
|
|
46
|
+
nearest
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The values on a layer that break the memory, as lint lists them. */
|
|
50
|
+
function designViolations(rules, node) {
|
|
51
|
+
const violations = [];
|
|
52
|
+
for (const value of designValues(node)) {
|
|
53
|
+
const violation = judge(rules, node, value);
|
|
54
|
+
if (violation) violations.push(violation);
|
|
55
|
+
}
|
|
56
|
+
return violations;
|
|
57
|
+
}
|
|
58
|
+
const keyOf = (value) => designValueKey(value.group, value.value);
|
|
59
|
+
/**
|
|
60
|
+
* The values an edit brought to a layer: on a layer it created, all of them; on one it changed,
|
|
61
|
+
* those in the fields it changed that the same field did not hold before, as a value that is
|
|
62
|
+
* judged in full, so moving or renaming an old layer judges nothing. A layer inside an instance shows its component's values, so only
|
|
63
|
+
* the fields it overrides are its own.
|
|
64
|
+
*/
|
|
65
|
+
function editedValues(graph, node, change) {
|
|
66
|
+
const inInstance = findInstanceAncestor(graph, node.id) !== void 0;
|
|
67
|
+
const own = (value) => !inInstance || hasInstanceOverride(graph, node.id, String(value.field));
|
|
68
|
+
let values = designValues(node).filter(own);
|
|
69
|
+
if (change) {
|
|
70
|
+
const changed = new Set(Object.keys(change.after));
|
|
71
|
+
values = values.filter((value) => changed.has(String(value.field)));
|
|
72
|
+
const heldKey = (value) => `${String(value.field)}|${copiedValueKey(value)}`;
|
|
73
|
+
const previous = new Set(designValues({
|
|
74
|
+
...node,
|
|
75
|
+
...change.before
|
|
76
|
+
}).map(heldKey));
|
|
77
|
+
values = values.filter((value) => !previous.has(heldKey(value)));
|
|
78
|
+
}
|
|
79
|
+
return values;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The values a variable an edit created or changed now gives the system, under its type and
|
|
83
|
+
* scopes as they are now, so a rescoped variable is judged on what it newly admits.
|
|
84
|
+
*/
|
|
85
|
+
function editedVariableValues(graph, change) {
|
|
86
|
+
const variable = graph.variables.get(change.id);
|
|
87
|
+
if (!variable) return null;
|
|
88
|
+
const values = variableValues(graph, variable);
|
|
89
|
+
return values.length > 0 ? {
|
|
90
|
+
variable,
|
|
91
|
+
values
|
|
92
|
+
} : null;
|
|
93
|
+
}
|
|
94
|
+
/** The values a style layer an edit created or changed now gives the system. */
|
|
95
|
+
function editedStyleValues(node) {
|
|
96
|
+
return isStyleNode(node) ? styleValues(node) : [];
|
|
97
|
+
}
|
|
98
|
+
function systemValue(value, path) {
|
|
99
|
+
return {
|
|
100
|
+
...value,
|
|
101
|
+
field: "name",
|
|
102
|
+
path,
|
|
103
|
+
fromSystem: false,
|
|
104
|
+
soft: false
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** Every value an edit brought in: on layers, in the styles they define, and in variables. */
|
|
108
|
+
function broughtValues(graph, edit) {
|
|
109
|
+
const brought = [];
|
|
110
|
+
const visit = (id, change) => {
|
|
111
|
+
const node = graph.getNode(id);
|
|
112
|
+
if (!node) return;
|
|
113
|
+
const values = editedValues(graph, node, change);
|
|
114
|
+
if (values.length > 0) brought.push({
|
|
115
|
+
owner: node,
|
|
116
|
+
values,
|
|
117
|
+
layer: true
|
|
118
|
+
});
|
|
119
|
+
const styles = editedStyleValues(node).map((value) => systemValue(value, "style"));
|
|
120
|
+
if (styles.length > 0) brought.push({
|
|
121
|
+
owner: node,
|
|
122
|
+
values: styles,
|
|
123
|
+
layer: false
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
for (const node of edit.created) visit(node.id, null);
|
|
127
|
+
for (const change of edit.updated) visit(change.id, change);
|
|
128
|
+
for (const change of edit.variables ?? []) {
|
|
129
|
+
const edited = editedVariableValues(graph, change);
|
|
130
|
+
if (!edited) continue;
|
|
131
|
+
brought.push({
|
|
132
|
+
owner: {
|
|
133
|
+
id: edited.variable.id,
|
|
134
|
+
name: edited.variable.name
|
|
135
|
+
},
|
|
136
|
+
values: edited.values.map((value) => systemValue(value, "variable")),
|
|
137
|
+
layer: false
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return brought;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A copied value's key with the field it sits in, so a fill never vouches for a stroke.
|
|
144
|
+
*/
|
|
145
|
+
function provenanceKey(value) {
|
|
146
|
+
return `${String(value.field)}|${copiedValueKey(value)}`;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The values on the layers a copying call names, as they were before it: their subtrees, read
|
|
150
|
+
* as they were where the call changed them, and the layers it deleted, such as a boolean's
|
|
151
|
+
* operands. Only the named layers are read, never the rest of the document. A merging call may
|
|
152
|
+
* take one operand's paint, so it vouches only for a value every named layer had in that field.
|
|
153
|
+
*/
|
|
154
|
+
function copiedValues(graph, edit, sourceIds, merged) {
|
|
155
|
+
const created = new Set(edit.created.map((node) => node.id));
|
|
156
|
+
const before = new Map(edit.updated.map((change) => [change.id, change.before]));
|
|
157
|
+
const deleted = new Map((edit.deleted ?? []).map((node) => [node.id, node]));
|
|
158
|
+
const snapshot = (id) => {
|
|
159
|
+
if (created.has(id)) return void 0;
|
|
160
|
+
const removed = deleted.get(id);
|
|
161
|
+
if (removed) return removed;
|
|
162
|
+
const node = graph.getNode(id);
|
|
163
|
+
if (!node) return void 0;
|
|
164
|
+
const previous = before.get(id);
|
|
165
|
+
return previous ? {
|
|
166
|
+
...node,
|
|
167
|
+
...previous
|
|
168
|
+
} : node;
|
|
169
|
+
};
|
|
170
|
+
const subtreeKeys = (id) => {
|
|
171
|
+
const keys = /* @__PURE__ */ new Set();
|
|
172
|
+
const pending = [id];
|
|
173
|
+
for (let current = pending.pop(); current !== void 0; current = pending.pop()) {
|
|
174
|
+
const node = snapshot(current);
|
|
175
|
+
if (!node) continue;
|
|
176
|
+
for (const value of designValues(node)) keys.add(provenanceKey(value));
|
|
177
|
+
pending.push(...node.childIds);
|
|
178
|
+
}
|
|
179
|
+
return keys;
|
|
180
|
+
};
|
|
181
|
+
const sources = sourceIds.map(subtreeKeys);
|
|
182
|
+
if (!merged) {
|
|
183
|
+
const keys = /* @__PURE__ */ new Set();
|
|
184
|
+
for (const node of edit.deleted ?? []) for (const value of designValues(node)) keys.add(provenanceKey(value));
|
|
185
|
+
for (const keysOfSource of sources) for (const key of keysOfSource) keys.add(key);
|
|
186
|
+
return keys;
|
|
187
|
+
}
|
|
188
|
+
if (sources.length === 0) return /* @__PURE__ */ new Set();
|
|
189
|
+
const [first, ...rest] = sources;
|
|
190
|
+
let keys = first;
|
|
191
|
+
for (const other of rest) keys = new Set([...keys].filter((key) => other.has(key)));
|
|
192
|
+
return keys;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A value written on a layer, as it is judged: none when a copied layer already had it in the
|
|
196
|
+
* same field, and only a warning for Pairdraw's own default for a new layer, which the agent did
|
|
197
|
+
* not choose.
|
|
198
|
+
*/
|
|
199
|
+
function layerValue(value, copied) {
|
|
200
|
+
if (copied?.has(provenanceKey(value))) return null;
|
|
201
|
+
return PAIRDRAW_DEFAULT_KEYS.has(keyOf(value)) ? {
|
|
202
|
+
...value,
|
|
203
|
+
soft: true
|
|
204
|
+
} : value;
|
|
205
|
+
}
|
|
206
|
+
/** A variable's or style's value, judged only where the group takes the system's values. */
|
|
207
|
+
function systemValueIn(rules, value) {
|
|
208
|
+
return rules[value.group].fromSystem ? value : null;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Judges what an edit did against the document's design memory; null when the document has
|
|
212
|
+
* none. Only values the edit brought in are judged, against the rules as they were before it:
|
|
213
|
+
* - a value written onto a layer is judged against what the memory allows, wherever else the
|
|
214
|
+
* document uses it, unless the call copied or converted layers that already had it
|
|
215
|
+
* (`copiedFrom`);
|
|
216
|
+
* - Pairdraw's own defaults for a new layer warn at most: the agent did not choose them;
|
|
217
|
+
* - variables and shared styles are judged on every value they now give the system, under their
|
|
218
|
+
* scopes as they are now, so creating, changing or rescoping one cannot widen the rules;
|
|
219
|
+
* binding layers to the existing system stays free.
|
|
220
|
+
* People's edits are never judged here, only agents' and automation's.
|
|
221
|
+
*/
|
|
222
|
+
function checkDesignEdit(graph, edit, options = {}) {
|
|
223
|
+
const memory = options.rules?.memory ?? cachedDesignMemory(graph);
|
|
224
|
+
if (!memory) return null;
|
|
225
|
+
const findings = {
|
|
226
|
+
refused: [],
|
|
227
|
+
warnings: [],
|
|
228
|
+
rules: null
|
|
229
|
+
};
|
|
230
|
+
const pending = broughtValues(graph, edit);
|
|
231
|
+
if (pending.length === 0) return findings;
|
|
232
|
+
const rules = options.rules ?? currentDesignRules(graph, memory);
|
|
233
|
+
findings.rules = rules;
|
|
234
|
+
const copied = options.copiedFrom?.length ? copiedValues(graph, edit, options.copiedFrom, options.merged === true) : null;
|
|
235
|
+
for (const { owner, values, layer } of pending) for (const value of values) {
|
|
236
|
+
const judged = layer ? layerValue(value, copied) : systemValueIn(rules, value);
|
|
237
|
+
if (!judged) continue;
|
|
238
|
+
const violation = judge(rules, owner, judged);
|
|
239
|
+
if (!violation) continue;
|
|
240
|
+
if (violation.severity === "refuse" && !options.warnOnly) findings.refused.push(violation);
|
|
241
|
+
else findings.warnings.push({
|
|
242
|
+
...violation,
|
|
243
|
+
severity: "warn"
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return findings;
|
|
247
|
+
}
|
|
248
|
+
/** Judges values an agent means to use, so it can pick allowed ones before it edits. */
|
|
249
|
+
function checkDesignValues(rules, proposal) {
|
|
250
|
+
const probe = {
|
|
251
|
+
id: "",
|
|
252
|
+
name: ""
|
|
253
|
+
};
|
|
254
|
+
return DESIGN_MEMORY_GROUPS.flatMap((group) => (proposal[group] ?? []).map((input) => {
|
|
255
|
+
const value = normalizeDesignValue(group, input);
|
|
256
|
+
if (value === null) return {
|
|
257
|
+
group,
|
|
258
|
+
value: input,
|
|
259
|
+
verdict: "invalid",
|
|
260
|
+
nearest: null
|
|
261
|
+
};
|
|
262
|
+
const violation = judge(rules, probe, {
|
|
263
|
+
group,
|
|
264
|
+
field: "name",
|
|
265
|
+
path: group,
|
|
266
|
+
value,
|
|
267
|
+
fromSystem: false,
|
|
268
|
+
soft: false
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
group,
|
|
272
|
+
value,
|
|
273
|
+
verdict: violation?.severity ?? "ok",
|
|
274
|
+
nearest: violation?.nearest ?? null
|
|
275
|
+
};
|
|
276
|
+
}));
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
export { checkDesignEdit, checkDesignValues, designViolations };
|
|
280
|
+
|
|
281
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","names":[],"sources":["../../src/design-memory/check.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport {\n cachedDesignMemory,\n DESIGN_MEMORY_GROUPS,\n normalizeDesignValue,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\nimport { findInstanceAncestor, hasInstanceOverride } from '@pairdraw/scene-graph/instances'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { newLayerDefaults } from '#core/editor/shapes/defaults'\n\nimport { currentDesignRules } from './document'\nimport {\n COLOR_TOLERANCE,\n isStyleNode,\n nearestColor,\n nearestNumber,\n NUMBER_TOLERANCE,\n styleValues,\n variableValues,\n type AllowedValue,\n type DesignRules,\n type SystemValue\n} from './rules'\nimport { copiedValueKey, designValueKey, designValues, type DesignValue } from './values'\n\n/** A value that breaks the memory, with the closest one it allows. */\nexport interface DesignViolation {\n group: DesignMemoryGroup\n severity: 'refuse' | 'warn'\n /** The layer, or the variable, that holds the value. */\n nodeId: string\n nodeName: string\n path: string\n value: string | number\n nearest: AllowedValue<string | number> | null\n}\n\nexport interface DesignFindings {\n refused: DesignViolation[]\n warnings: DesignViolation[]\n /** The rules the edit was judged by; null when it brought no values to judge. */\n rules: DesignRules | null\n}\n\n/**\n * What an edit did: the layers it created, the fields it changed on others with their values\n * before, the layers it deleted as they were, and the variables it created or changed.\n */\nexport interface DesignEdit {\n created: readonly Pick<SceneNode, 'id'>[]\n updated: readonly { id: string; before: Partial<SceneNode>; after: Partial<SceneNode> }[]\n deleted?: readonly SceneNode[]\n /** Each variable created (`before` null) or changed, with what it held before. */\n variables?: readonly { id: string; before: Partial<Variable> | null }[]\n}\n\nexport interface DesignCheckOptions {\n /**\n * Report what the memory would refuse as warnings: for outside content, such as an imported\n * web page, SVG or photo, whose values are its own, and for a call a person made.\n */\n warnOnly?: boolean\n /**\n * The rules as they were before the edit, so nothing the edit itself did, such as a variable\n * it created, widens what it is judged by. Resolved from the document now when absent.\n */\n rules?: DesignRules\n /**\n * The layers a call copies or converts with their values, such as a clone's original or the\n * layers a boolean joins: a value they already had is not new on what the call made of them.\n * Any other call is judged only against what the memory allows, wherever else a value is used.\n */\n copiedFrom?: readonly string[]\n /**\n * The call joins the named layers into one and may take a paint from any of them, as flatten\n * and boolean operations do: only a value every named layer had in the same field is theirs.\n */\n merged?: boolean\n}\n\n/** The neutral colors and the font Pairdraw gives a new layer of every kind. */\nconst PAIRDRAW_DEFAULT_KEYS: ReadonlySet<string> = new Set([\n designValueKey('fonts', DEFAULT_FONT_FAMILY),\n ...(['FRAME', 'COMPONENT', 'SECTION', 'RECTANGLE', 'LINE', 'TEXT'] as const).flatMap((type) =>\n (['light', 'dark'] as const).flatMap((theme) => {\n const { fills = [], strokes = [] } = newLayerDefaults(type, theme)\n return [...fills, ...strokes].map((paint) =>\n designValueKey('colors', colorToHex(paint.color))\n )\n })\n )\n])\n\n/** Judges one value; null when the memory allows it or does not check its group. */\nfunction judge(\n rules: DesignRules,\n node: Pick<SceneNode, 'id' | 'name'>,\n value: DesignValue\n): DesignViolation | null {\n const group = rules[value.group]\n if (group.enforce === 'off' || (value.fromSystem && group.fromSystem)) return null\n let nearest: AllowedValue<string | number> | null = null\n if (value.group === 'colors' && typeof value.value === 'string') {\n const match = nearestColor(rules.colors, value.value)\n if (match && match.distance <= COLOR_TOLERANCE) return null\n nearest = match?.allowed ?? null\n } else if (value.group === 'fonts' && typeof value.value === 'string') {\n const family = value.value.toLowerCase()\n if (rules.fonts.allowed.some((allowed) => allowed.value.toLowerCase() === family)) return null\n } else if (\n typeof value.value === 'number' &&\n value.group !== 'colors' &&\n value.group !== 'fonts'\n ) {\n const match = nearestNumber(rules[value.group], value.value)\n if (match && Math.abs(match.value - value.value) <= NUMBER_TOLERANCE) return null\n nearest = match\n }\n return {\n group: value.group,\n severity: group.enforce === 'refuse' && !value.soft ? 'refuse' : 'warn',\n nodeId: node.id,\n nodeName: node.name,\n path: value.path,\n value: value.value,\n nearest\n }\n}\n\n/** The values on a layer that break the memory, as lint lists them. */\nexport function designViolations(rules: DesignRules, node: SceneNode): DesignViolation[] {\n const violations: DesignViolation[] = []\n for (const value of designValues(node)) {\n const violation = judge(rules, node, value)\n if (violation) violations.push(violation)\n }\n return violations\n}\n\nconst keyOf = (value: DesignValue | SystemValue) => designValueKey(value.group, value.value)\n\n/**\n * The values an edit brought to a layer: on a layer it created, all of them; on one it changed,\n * those in the fields it changed that the same field did not hold before, as a value that is\n * judged in full, so moving or renaming an old layer judges nothing. A layer inside an instance shows its component's values, so only\n * the fields it overrides are its own.\n */\nfunction editedValues(\n graph: SceneGraph,\n node: SceneNode,\n change: DesignEdit['updated'][number] | null\n): DesignValue[] {\n const inInstance = findInstanceAncestor(graph, node.id) !== undefined\n const own = (value: DesignValue) =>\n !inInstance || hasInstanceOverride(graph, node.id, String(value.field))\n let values = designValues(node).filter(own)\n if (change) {\n const changed = new Set(Object.keys(change.after))\n values = values.filter((value) => changed.has(String(value.field)))\n // Held before means in the same field and as solid a value: a shadow or gradient stop that\n // only warned never vouches for a fill or stroke of the same color.\n const heldKey = (value: DesignValue) => `${String(value.field)}|${copiedValueKey(value)}`\n const previous = new Set(designValues({ ...node, ...change.before }).map(heldKey))\n values = values.filter((value) => !previous.has(heldKey(value)))\n }\n return values\n}\n\n/**\n * The values a variable an edit created or changed now gives the system, under its type and\n * scopes as they are now, so a rescoped variable is judged on what it newly admits.\n */\nfunction editedVariableValues(\n graph: SceneGraph,\n change: NonNullable<DesignEdit['variables']>[number]\n): { variable: Variable; values: SystemValue[] } | null {\n const variable = graph.variables.get(change.id)\n if (!variable) return null\n const values = variableValues(graph, variable)\n return values.length > 0 ? { variable, values } : null\n}\n\n/** The values a style layer an edit created or changed now gives the system. */\nfunction editedStyleValues(node: SceneNode): SystemValue[] {\n return isStyleNode(node) ? styleValues(node) : []\n}\n\nfunction systemValue(value: SystemValue, path: string): DesignValue {\n return { ...value, field: 'name', path, fromSystem: false, soft: false }\n}\n\n/** The values one layer, style or variable got from an edit, and whether a layer holds them. */\ninterface BroughtValues {\n owner: Pick<SceneNode, 'id' | 'name'>\n values: DesignValue[]\n layer: boolean\n}\n\n/** Every value an edit brought in: on layers, in the styles they define, and in variables. */\nfunction broughtValues(graph: SceneGraph, edit: DesignEdit): BroughtValues[] {\n const brought: BroughtValues[] = []\n const visit = (id: string, change: DesignEdit['updated'][number] | null) => {\n const node = graph.getNode(id)\n if (!node) return\n const values = editedValues(graph, node, change)\n if (values.length > 0) brought.push({ owner: node, values, layer: true })\n const styles = editedStyleValues(node).map((value) => systemValue(value, 'style'))\n if (styles.length > 0) brought.push({ owner: node, values: styles, layer: false })\n }\n for (const node of edit.created) visit(node.id, null)\n for (const change of edit.updated) visit(change.id, change)\n for (const change of edit.variables ?? []) {\n const edited = editedVariableValues(graph, change)\n if (!edited) continue\n brought.push({\n owner: { id: edited.variable.id, name: edited.variable.name },\n values: edited.values.map((value) => systemValue(value, 'variable')),\n layer: false\n })\n }\n return brought\n}\n\n/**\n * A copied value's key with the field it sits in, so a fill never vouches for a stroke.\n */\nfunction provenanceKey(value: DesignValue): string {\n return `${String(value.field)}|${copiedValueKey(value)}`\n}\n\n/**\n * The values on the layers a copying call names, as they were before it: their subtrees, read\n * as they were where the call changed them, and the layers it deleted, such as a boolean's\n * operands. Only the named layers are read, never the rest of the document. A merging call may\n * take one operand's paint, so it vouches only for a value every named layer had in that field.\n */\nfunction copiedValues(\n graph: SceneGraph,\n edit: DesignEdit,\n sourceIds: readonly string[],\n merged: boolean\n): Set<string> {\n const created = new Set(edit.created.map((node) => node.id))\n const before = new Map(edit.updated.map((change) => [change.id, change.before]))\n const deleted = new Map((edit.deleted ?? []).map((node) => [node.id, node]))\n const snapshot = (id: string): SceneNode | undefined => {\n if (created.has(id)) return undefined\n const removed = deleted.get(id)\n if (removed) return removed\n const node = graph.getNode(id)\n if (!node) return undefined\n const previous = before.get(id)\n return previous ? { ...node, ...previous } : node\n }\n const subtreeKeys = (id: string): Set<string> => {\n const keys = new Set<string>()\n const pending = [id]\n for (let current = pending.pop(); current !== undefined; current = pending.pop()) {\n const node = snapshot(current)\n if (!node) continue\n for (const value of designValues(node)) keys.add(provenanceKey(value))\n pending.push(...node.childIds)\n }\n return keys\n }\n const sources = sourceIds.map(subtreeKeys)\n if (!merged) {\n const keys = new Set<string>()\n for (const node of edit.deleted ?? []) {\n for (const value of designValues(node)) keys.add(provenanceKey(value))\n }\n for (const keysOfSource of sources) for (const key of keysOfSource) keys.add(key)\n return keys\n }\n if (sources.length === 0) return new Set()\n const [first, ...rest] = sources\n let keys = first\n for (const other of rest) keys = new Set([...keys].filter((key) => other.has(key)))\n return keys\n}\n\n/**\n * A value written on a layer, as it is judged: none when a copied layer already had it in the\n * same field, and only a warning for Pairdraw's own default for a new layer, which the agent did\n * not choose.\n */\nfunction layerValue(value: DesignValue, copied: Set<string> | null): DesignValue | null {\n if (copied?.has(provenanceKey(value))) return null\n return PAIRDRAW_DEFAULT_KEYS.has(keyOf(value)) ? { ...value, soft: true } : value\n}\n\n/** A variable's or style's value, judged only where the group takes the system's values. */\nfunction systemValueIn(rules: DesignRules, value: DesignValue): DesignValue | null {\n return rules[value.group].fromSystem ? value : null\n}\n\n/**\n * Judges what an edit did against the document's design memory; null when the document has\n * none. Only values the edit brought in are judged, against the rules as they were before it:\n * - a value written onto a layer is judged against what the memory allows, wherever else the\n * document uses it, unless the call copied or converted layers that already had it\n * (`copiedFrom`);\n * - Pairdraw's own defaults for a new layer warn at most: the agent did not choose them;\n * - variables and shared styles are judged on every value they now give the system, under their\n * scopes as they are now, so creating, changing or rescoping one cannot widen the rules;\n * binding layers to the existing system stays free.\n * People's edits are never judged here, only agents' and automation's.\n */\nexport function checkDesignEdit(\n graph: SceneGraph,\n edit: DesignEdit,\n options: DesignCheckOptions = {}\n): DesignFindings | null {\n const memory = options.rules?.memory ?? cachedDesignMemory(graph)\n if (!memory) return null\n const findings: DesignFindings = { refused: [], warnings: [], rules: null }\n const pending = broughtValues(graph, edit)\n // Resolving the rules costs more than the check, so only an edit that brought values pays.\n if (pending.length === 0) return findings\n const rules = options.rules ?? currentDesignRules(graph, memory)\n findings.rules = rules\n const copied = options.copiedFrom?.length\n ? copiedValues(graph, edit, options.copiedFrom, options.merged === true)\n : null\n for (const { owner, values, layer } of pending) {\n for (const value of values) {\n const judged = layer ? layerValue(value, copied) : systemValueIn(rules, value)\n if (!judged) continue\n const violation = judge(rules, owner, judged)\n if (!violation) continue\n if (violation.severity === 'refuse' && !options.warnOnly) findings.refused.push(violation)\n else findings.warnings.push({ ...violation, severity: 'warn' })\n }\n }\n return findings\n}\n\n/** A value proposed for a design, judged before it is used. */\nexport interface DesignValueVerdict {\n group: DesignMemoryGroup\n value: string | number\n /** `invalid` for a value the group cannot read, such as a color that is not CSS. */\n verdict: 'ok' | 'warn' | 'refuse' | 'invalid'\n nearest: AllowedValue<string | number> | null\n}\n\n/** Judges values an agent means to use, so it can pick allowed ones before it edits. */\nexport function checkDesignValues(\n rules: DesignRules,\n proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>\n): DesignValueVerdict[] {\n const probe = { id: '', name: '' }\n return DESIGN_MEMORY_GROUPS.flatMap((group) =>\n (proposal[group] ?? []).map((input): DesignValueVerdict => {\n const value = normalizeDesignValue(group, input)\n if (value === null) return { group, value: input, verdict: 'invalid', nearest: null }\n const violation = judge(rules, probe, {\n group,\n field: 'name',\n path: group,\n value,\n fromSystem: false,\n soft: false\n })\n return {\n group,\n value,\n verdict: violation?.severity ?? 'ok',\n nearest: violation?.nearest ?? null\n }\n })\n )\n}\n"],"mappings":";;;;;;;;;;AAoFA,MAAM,wCAA6C,IAAI,IAAI,CACzD,eAAe,SAAS,mBAAmB,GAC3C,GAAI;CAAC;CAAS;CAAa;CAAW;CAAa;CAAQ;AAAM,CAAC,CAAW,SAAS,SACnF,CAAC,SAAS,MAAM,CAAC,CAAW,SAAS,UAAU;CAC9C,MAAM,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,MAAM,iBAAiB,MAAM,KAAK;CACjE,OAAO,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,KAAK,UACjC,eAAe,UAAU,WAAW,MA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AU,MAAM,OAAO;GAAE;GAAO,OAAO;GAAO,SAAS;GAAW,SAAS;EAAK;EACpF,MAAM,YAAY,MAAM,OAAO,OAAO;GACpC;GACA,OAAO;GACP,MAAM;GACN;GACA,YAAY;GACZ,MAAM;EACR,CAAC;EACD,OAAO;GACL;GACA;GACA,SAAS,WAAW,YAAY;GAChC,SAAS,WAAW,WAAW;EACjC;CACF,CAAC,CACH;AACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
|
+
import { DesignDecisionAuthor, DesignMemoryEnforcement, DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
|
|
3
|
+
//#region src/design-memory/describe.d.ts
|
|
4
|
+
interface DesignGroupReport {
|
|
5
|
+
enforce: DesignMemoryEnforcement;
|
|
6
|
+
/** Whether the document's variables and styles count. */
|
|
7
|
+
fromSystem: boolean;
|
|
8
|
+
allowed: {
|
|
9
|
+
value: string | number;
|
|
10
|
+
name: string | null;
|
|
11
|
+
}[];
|
|
12
|
+
/** Allowed values past the listed ones. */
|
|
13
|
+
more: number;
|
|
14
|
+
}
|
|
15
|
+
interface DesignExampleReport {
|
|
16
|
+
id: string;
|
|
17
|
+
/** Null for a layer the document no longer has. */
|
|
18
|
+
name: string | null;
|
|
19
|
+
page: string | null;
|
|
20
|
+
width: number | null;
|
|
21
|
+
height: number | null;
|
|
22
|
+
}
|
|
23
|
+
/** A document's design memory as agents, the CLI and the chat read it. */
|
|
24
|
+
interface DesignMemoryReport {
|
|
25
|
+
groups: Record<DesignMemoryGroup, DesignGroupReport>;
|
|
26
|
+
decisions: {
|
|
27
|
+
id: string;
|
|
28
|
+
text: string;
|
|
29
|
+
author: DesignDecisionAuthor;
|
|
30
|
+
}[];
|
|
31
|
+
examples: DesignExampleReport[];
|
|
32
|
+
}
|
|
33
|
+
/** The document's memory with its allowed values resolved; null when it has none. */
|
|
34
|
+
declare function describeDesignMemory(graph: SceneGraph, limit?: number): DesignMemoryReport | null;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DesignExampleReport, DesignGroupReport, DesignMemoryReport, describeDesignMemory };
|
|
37
|
+
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.d.ts","names":[],"sources":["../../src/design-memory/describe.ts"],"mappings":";;;UAaiB;EACf,SAAS;;EAET;EACA;IAAW;IAAwB;;;EAEnC;;UAGe;EACf;;EAEA;EACA;EACA;EACA;;;UAIe;EACf,QAAQ,OAAO,mBAAmB;EAClC;IAAa;IAAY;IAAc,QAAQ;;EAC/C,UAAU;;;iBAII,qBACd,OAAO,YACP,iBACC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { currentDesignRules } from "./document.js";
|
|
2
|
+
import { cachedDesignMemory } from "@pairdraw/scene-graph/design-memory";
|
|
3
|
+
//#region src/design-memory/describe.ts
|
|
4
|
+
/** How many allowed values of a group a report lists by default. */
|
|
5
|
+
const LISTED_VALUES = 64;
|
|
6
|
+
/** The document's memory with its allowed values resolved; null when it has none. */
|
|
7
|
+
function describeDesignMemory(graph, limit = LISTED_VALUES) {
|
|
8
|
+
const memory = cachedDesignMemory(graph);
|
|
9
|
+
if (!memory) return null;
|
|
10
|
+
const rules = currentDesignRules(graph, memory);
|
|
11
|
+
const group = (name) => {
|
|
12
|
+
const { enforce, fromSystem, allowed } = rules[name];
|
|
13
|
+
return {
|
|
14
|
+
enforce,
|
|
15
|
+
fromSystem,
|
|
16
|
+
allowed: allowed.slice(0, limit).map(({ value, name: source }) => ({
|
|
17
|
+
value,
|
|
18
|
+
name: source
|
|
19
|
+
})),
|
|
20
|
+
more: Math.max(0, allowed.length - limit)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
groups: {
|
|
25
|
+
colors: group("colors"),
|
|
26
|
+
fonts: group("fonts"),
|
|
27
|
+
fontSizes: group("fontSizes"),
|
|
28
|
+
spacing: group("spacing"),
|
|
29
|
+
radius: group("radius")
|
|
30
|
+
},
|
|
31
|
+
decisions: memory.decisions.map(({ id, text, author }) => ({
|
|
32
|
+
id,
|
|
33
|
+
text,
|
|
34
|
+
author
|
|
35
|
+
})),
|
|
36
|
+
examples: memory.examples.map(({ nodeId }) => {
|
|
37
|
+
const node = graph.getNode(nodeId);
|
|
38
|
+
const page = node ? graph.getNode(graph.pageOf(node.id) ?? "") : void 0;
|
|
39
|
+
return {
|
|
40
|
+
id: nodeId,
|
|
41
|
+
name: node?.name ?? null,
|
|
42
|
+
page: page?.name ?? null,
|
|
43
|
+
width: node?.width ?? null,
|
|
44
|
+
height: node?.height ?? null
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { describeDesignMemory };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","names":[],"sources":["../../src/design-memory/describe.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n cachedDesignMemory,\n type DesignDecisionAuthor,\n type DesignMemoryEnforcement,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { currentDesignRules } from './document'\n\n/** How many allowed values of a group a report lists by default. */\nconst LISTED_VALUES = 64\n\nexport interface DesignGroupReport {\n enforce: DesignMemoryEnforcement\n /** Whether the document's variables and styles count. */\n fromSystem: boolean\n allowed: { value: string | number; name: string | null }[]\n /** Allowed values past the listed ones. */\n more: number\n}\n\nexport interface DesignExampleReport {\n id: string\n /** Null for a layer the document no longer has. */\n name: string | null\n page: string | null\n width: number | null\n height: number | null\n}\n\n/** A document's design memory as agents, the CLI and the chat read it. */\nexport interface DesignMemoryReport {\n groups: Record<DesignMemoryGroup, DesignGroupReport>\n decisions: { id: string; text: string; author: DesignDecisionAuthor }[]\n examples: DesignExampleReport[]\n}\n\n/** The document's memory with its allowed values resolved; null when it has none. */\nexport function describeDesignMemory(\n graph: SceneGraph,\n limit = LISTED_VALUES\n): DesignMemoryReport | null {\n const memory = cachedDesignMemory(graph)\n if (!memory) return null\n const rules = currentDesignRules(graph, memory)\n const group = (name: DesignMemoryGroup): DesignGroupReport => {\n const { enforce, fromSystem, allowed } = rules[name]\n return {\n enforce,\n fromSystem,\n allowed: allowed.slice(0, limit).map(({ value, name: source }) => ({ value, name: source })),\n more: Math.max(0, allowed.length - limit)\n }\n }\n return {\n groups: {\n colors: group('colors'),\n fonts: group('fonts'),\n fontSizes: group('fontSizes'),\n spacing: group('spacing'),\n radius: group('radius')\n },\n decisions: memory.decisions.map(({ id, text, author }) => ({ id, text, author })),\n examples: memory.examples.map(({ nodeId }) => {\n const node = graph.getNode(nodeId)\n const page = node ? graph.getNode(graph.pageOf(node.id) ?? '') : undefined\n return {\n id: nodeId,\n name: node?.name ?? null,\n page: page?.name ?? null,\n width: node?.width ?? null,\n height: node?.height ?? null\n }\n })\n }\n}\n"],"mappings":";;;;AAWA,MAAM,gBAAgB;;AA4BtB,SAAgB,qBACd,OACA,QAAQ,eACmB;CAC3B,MAAM,SAAS,mBAAmB,KAAK;CACvC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAQ,mBAAmB,OAAO,MAAM;CAC9C,MAAM,SAAS,SAA+C;EAC5D,MAAM,EAAE,SAAS,YAAY,YAAY,MAAM;EAC/C,OAAO;GACL;GACA;GACA,SAAS,QAAQ,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,MAAM,cAAc;IAAE;IAAO,MAAM;GAAO,EAAE;GAC3F,MAAM,KAAK,IAAI,GAAG,QAAQ,SAAS,KAAK;EAC1C;CACF;CACA,OAAO;EACL,QAAQ;GACN,QAAQ,MAAM,QAAQ;GACtB,OAAO,MAAM,OAAO;GACpB,WAAW,MAAM,WAAW;GAC5B,SAAS,MAAM,SAAS;GACxB,QAAQ,MAAM,QAAQ;EACxB;EACA,WAAW,OAAO,UAAU,KAAK,EAAE,IAAI,MAAM,cAAc;GAAE;GAAI;GAAM;EAAO,EAAE;EAChF,UAAU,OAAO,SAAS,KAAK,EAAE,aAAa;GAC5C,MAAM,OAAO,MAAM,QAAQ,MAAM;GACjC,MAAM,OAAO,OAAO,MAAM,QAAQ,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,KAAA;GACjE,OAAO;IACL,IAAI;IACJ,MAAM,MAAM,QAAQ;IACpB,MAAM,MAAM,QAAQ;IACpB,OAAO,MAAM,SAAS;IACtB,QAAQ,MAAM,UAAU;GAC1B;EACF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
|
+
import { DesignMemory, DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
|
|
3
|
+
//#region src/design-memory/distil.d.ts
|
|
4
|
+
/** A value the layers use, how often, and whether a variable or style already gives it. */
|
|
5
|
+
interface DistilledValue {
|
|
6
|
+
value: string | number;
|
|
7
|
+
count: number;
|
|
8
|
+
/** Given by a variable or a style, so the document's system already allows it. */
|
|
9
|
+
fromSystem: boolean;
|
|
10
|
+
}
|
|
11
|
+
type DistilledValues = Record<DesignMemoryGroup, DistilledValue[]>;
|
|
12
|
+
/**
|
|
13
|
+
* The values the layers under `rootIds` use, most used first, as rules to learn: colors,
|
|
14
|
+
* fonts, font sizes, spacing and radii, each once. Instances count as the component they show,
|
|
15
|
+
* so a component placed fifty times is not fifty votes.
|
|
16
|
+
*/
|
|
17
|
+
declare function distilDesignValues(graph: SceneGraph, rootIds: readonly string[]): DistilledValues;
|
|
18
|
+
/** Whether a distilled value is worth proposing: used more than once, and not already allowed. */
|
|
19
|
+
declare function proposesValue(memory: DesignMemory | null, group: DesignMemoryGroup, value: DistilledValue): boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { DistilledValue, DistilledValues, distilDesignValues, proposesValue };
|
|
22
|
+
//# sourceMappingURL=distil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distil.d.ts","names":[],"sources":["../../src/design-memory/distil.ts"],"mappings":";;;;UAUiB;EACf;EACA;;EAEA;;KAGU,kBAAkB,OAAO,mBAAmB;;;;;;iBAUxC,mBAAmB,OAAO,YAAY,6BAA6B;;iBAiCnE,cACd,QAAQ,qBACR,OAAO,mBACP,OAAO"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { designValues } from "./values.js";
|
|
2
|
+
import { DESIGN_MEMORY_GROUPS } from "@pairdraw/scene-graph/design-memory";
|
|
3
|
+
//#region src/design-memory/distil.ts
|
|
4
|
+
/** How many layers one distil reads, so learning from a whole document stays quick. */
|
|
5
|
+
const MAX_LAYERS = 2e4;
|
|
6
|
+
/**
|
|
7
|
+
* The values the layers under `rootIds` use, most used first, as rules to learn: colors,
|
|
8
|
+
* fonts, font sizes, spacing and radii, each once. Instances count as the component they show,
|
|
9
|
+
* so a component placed fifty times is not fifty votes.
|
|
10
|
+
*/
|
|
11
|
+
function distilDesignValues(graph, rootIds) {
|
|
12
|
+
const tallies = /* @__PURE__ */ new Map();
|
|
13
|
+
const pending = [...rootIds];
|
|
14
|
+
let visited = 0;
|
|
15
|
+
while (pending.length > 0 && visited < MAX_LAYERS) {
|
|
16
|
+
const id = pending.pop();
|
|
17
|
+
const node = id === void 0 ? void 0 : graph.getNode(id);
|
|
18
|
+
if (!node || !node.visible) continue;
|
|
19
|
+
visited++;
|
|
20
|
+
for (const value of designValues(node)) {
|
|
21
|
+
const key = `${value.group}:${typeof value.value === "string" ? value.value.toLowerCase() : value.value}`;
|
|
22
|
+
const tally = tallies.get(key);
|
|
23
|
+
if (tally) {
|
|
24
|
+
tally.count++;
|
|
25
|
+
tally.fromSystem ||= value.fromSystem;
|
|
26
|
+
} else tallies.set(key, {
|
|
27
|
+
group: value.group,
|
|
28
|
+
value: value.value,
|
|
29
|
+
count: 1,
|
|
30
|
+
fromSystem: value.fromSystem
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (node.type !== "INSTANCE") pending.push(...node.childIds);
|
|
34
|
+
}
|
|
35
|
+
const result = {
|
|
36
|
+
colors: [],
|
|
37
|
+
fonts: [],
|
|
38
|
+
fontSizes: [],
|
|
39
|
+
spacing: [],
|
|
40
|
+
radius: []
|
|
41
|
+
};
|
|
42
|
+
for (const { group, ...value } of tallies.values()) result[group].push(value);
|
|
43
|
+
for (const group of DESIGN_MEMORY_GROUPS) result[group].sort((a, b) => b.count - a.count);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/** Whether a distilled value is worth proposing: used more than once, and not already allowed. */
|
|
47
|
+
function proposesValue(memory, group, value) {
|
|
48
|
+
if (value.count < 2) return false;
|
|
49
|
+
return !(memory?.[group].values ?? []).includes(value.value);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { distilDesignValues, proposesValue };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=distil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distil.js","names":[],"sources":["../../src/design-memory/distil.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n DESIGN_MEMORY_GROUPS,\n type DesignMemory,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { designValues } from './values'\n\n/** A value the layers use, how often, and whether a variable or style already gives it. */\nexport interface DistilledValue {\n value: string | number\n count: number\n /** Given by a variable or a style, so the document's system already allows it. */\n fromSystem: boolean\n}\n\nexport type DistilledValues = Record<DesignMemoryGroup, DistilledValue[]>\n\n/** How many layers one distil reads, so learning from a whole document stays quick. */\nconst MAX_LAYERS = 20_000\n\n/**\n * The values the layers under `rootIds` use, most used first, as rules to learn: colors,\n * fonts, font sizes, spacing and radii, each once. Instances count as the component they show,\n * so a component placed fifty times is not fifty votes.\n */\nexport function distilDesignValues(graph: SceneGraph, rootIds: readonly string[]): DistilledValues {\n const tallies = new Map<string, DistilledValue & { group: DesignMemoryGroup }>()\n const pending = [...rootIds]\n let visited = 0\n while (pending.length > 0 && visited < MAX_LAYERS) {\n const id = pending.pop()\n const node = id === undefined ? undefined : graph.getNode(id)\n if (!node || !node.visible) continue\n visited++\n for (const value of designValues(node)) {\n const key = `${value.group}:${typeof value.value === 'string' ? value.value.toLowerCase() : value.value}`\n const tally = tallies.get(key)\n if (tally) {\n tally.count++\n tally.fromSystem ||= value.fromSystem\n } else {\n tallies.set(key, {\n group: value.group,\n value: value.value,\n count: 1,\n fromSystem: value.fromSystem\n })\n }\n }\n if (node.type !== 'INSTANCE') pending.push(...node.childIds)\n }\n const result: DistilledValues = { colors: [], fonts: [], fontSizes: [], spacing: [], radius: [] }\n for (const { group, ...value } of tallies.values()) result[group].push(value)\n for (const group of DESIGN_MEMORY_GROUPS) result[group].sort((a, b) => b.count - a.count)\n return result\n}\n\n/** Whether a distilled value is worth proposing: used more than once, and not already allowed. */\nexport function proposesValue(\n memory: DesignMemory | null,\n group: DesignMemoryGroup,\n value: DistilledValue\n): boolean {\n if (value.count < 2) return false\n const values: readonly (string | number)[] = memory?.[group].values ?? []\n return !values.includes(value.value)\n}\n"],"mappings":";;;;AAoBA,MAAM,aAAa;;;;;;AAOnB,SAAgB,mBAAmB,OAAmB,SAA6C;CACjG,MAAM,0BAAU,IAAI,IAA2D;CAC/E,MAAM,UAAU,CAAC,GAAG,OAAO;CAC3B,IAAI,UAAU;CACd,OAAO,QAAQ,SAAS,KAAK,UAAU,YAAY;EACjD,MAAM,KAAK,QAAQ,IAAI;EACvB,MAAM,OAAO,OAAO,KAAA,IAAY,KAAA,IAAY,MAAM,QAAQ,EAAE;EAC5D,IAAI,CAAC,QAAQ,CAAC,KAAK,SAAS;EAC5B;EACA,KAAK,MAAM,SAAS,aAAa,IAAI,GAAG;GACtC,MAAM,MAAM,GAAG,MAAM,MAAM,GAAG,OAAO,MAAM,UAAU,WAAW,MAAM,MAAM,YAAY,IAAI,MAAM;GAClG,MAAM,QAAQ,QAAQ,IAAI,GAAG;GAC7B,IAAI,OAAO;IACT,MAAM;IACN,MAAM,eAAe,MAAM;GAC7B,OACE,QAAQ,IAAI,KAAK;IACf,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO;IACP,YAAY,MAAM;GACpB,CAAC;EAEL;EACA,IAAI,KAAK,SAAS,YAAY,QAAQ,KAAK,GAAG,KAAK,QAAQ;CAC7D;CACA,MAAM,SAA0B;EAAE,QAAQ,CAAC;EAAG,OAAO,CAAC;EAAG,WAAW,CAAC;EAAG,SAAS,CAAC;EAAG,QAAQ,CAAC;CAAE;CAChG,KAAK,MAAM,EAAE,OAAO,GAAG,WAAW,QAAQ,OAAO,GAAG,OAAO,MAAM,CAAC,KAAK,KAAK;CAC5E,KAAK,MAAM,SAAS,sBAAsB,OAAO,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CACxF,OAAO;AACT;;AAGA,SAAgB,cACd,QACA,OACA,OACS;CACT,IAAI,MAAM,QAAQ,GAAG,OAAO;CAE5B,OAAO,EADsC,SAAS,MAAM,CAAC,UAAU,CAAC,EAAA,CACzD,SAAS,MAAM,KAAK;AACrC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DesignRules } from "./rules.js";
|
|
2
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
3
|
+
import { DesignMemory } from "@pairdraw/scene-graph/design-memory";
|
|
4
|
+
//#region src/design-memory/document.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The memory's rules resolved against the document as it is now, reused while the memory, the
|
|
7
|
+
* style layers and the variables have not changed since they were last resolved.
|
|
8
|
+
*/
|
|
9
|
+
declare function currentDesignRules(graph: SceneGraph, memory: DesignMemory): DesignRules;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { currentDesignRules };
|
|
12
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","names":[],"sources":["../../src/design-memory/document.ts"],"mappings":";;;;;;;;iBAiEgB,mBAAmB,OAAO,YAAY,QAAQ,eAAe"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isStyleNode, resolveDesignRules } from "./rules.js";
|
|
2
|
+
//#region src/design-memory/document.ts
|
|
3
|
+
const states = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function stateOf(graph) {
|
|
5
|
+
const known = states.get(graph);
|
|
6
|
+
if (known) return known;
|
|
7
|
+
const state = {
|
|
8
|
+
styleIds: /* @__PURE__ */ new Set(),
|
|
9
|
+
styleVersion: 0,
|
|
10
|
+
rules: null
|
|
11
|
+
};
|
|
12
|
+
for (const node of graph.getAllNodes()) if (isStyleNode(node)) state.styleIds.add(node.id);
|
|
13
|
+
const touched = (id) => {
|
|
14
|
+
const node = graph.getNode(id);
|
|
15
|
+
const isStyle = node !== void 0 && isStyleNode(node);
|
|
16
|
+
if (!isStyle && !state.styleIds.has(id)) return;
|
|
17
|
+
if (isStyle) state.styleIds.add(id);
|
|
18
|
+
else state.styleIds.delete(id);
|
|
19
|
+
state.styleVersion++;
|
|
20
|
+
};
|
|
21
|
+
graph.onNodeEvents({
|
|
22
|
+
created: (node) => touched(node.id),
|
|
23
|
+
updated: (id) => touched(id),
|
|
24
|
+
deleted: (id) => touched(id)
|
|
25
|
+
});
|
|
26
|
+
states.set(graph, state);
|
|
27
|
+
return state;
|
|
28
|
+
}
|
|
29
|
+
/** Every reference a variable's values could change through, in a fixed order. */
|
|
30
|
+
function variableFingerprint(graph) {
|
|
31
|
+
const refs = [];
|
|
32
|
+
for (const variable of graph.variables.values()) {
|
|
33
|
+
refs.push(variable, variable.type, variable.scopes?.join(","), variable.valuesByMode);
|
|
34
|
+
for (const value of Object.values(variable.valuesByMode)) refs.push(value);
|
|
35
|
+
}
|
|
36
|
+
for (const collection of graph.variableCollections.values()) refs.push(collection.modes);
|
|
37
|
+
return refs;
|
|
38
|
+
}
|
|
39
|
+
function sameRefs(left, right) {
|
|
40
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The memory's rules resolved against the document as it is now, reused while the memory, the
|
|
44
|
+
* style layers and the variables have not changed since they were last resolved.
|
|
45
|
+
*/
|
|
46
|
+
function currentDesignRules(graph, memory) {
|
|
47
|
+
const state = stateOf(graph);
|
|
48
|
+
const variables = variableFingerprint(graph);
|
|
49
|
+
const cached = state.rules;
|
|
50
|
+
if (cached?.memory === memory && cached.styleVersion === state.styleVersion && sameRefs(cached.variables, variables)) return cached.rules;
|
|
51
|
+
const styles = [...state.styleIds].flatMap((id) => graph.getNode(id) ?? []);
|
|
52
|
+
const rules = resolveDesignRules(graph, memory, styles);
|
|
53
|
+
state.rules = {
|
|
54
|
+
memory,
|
|
55
|
+
styleVersion: state.styleVersion,
|
|
56
|
+
variables,
|
|
57
|
+
rules
|
|
58
|
+
};
|
|
59
|
+
return rules;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { currentDesignRules };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","names":[],"sources":["../../src/design-memory/document.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport type { DesignMemory } from '@pairdraw/scene-graph/design-memory'\n\nimport { isStyleNode, resolveDesignRules, type DesignRules } from './rules'\n\n/**\n * What one document keeps for its design memory between checks, kept current by the graph's\n * node events, so a check never walks the whole document: the layers that define shared styles,\n * whose values join the system, and the rules last resolved, reused while the memory, those\n * styles and the variables are as they were.\n */\ninterface DocumentDesignState {\n styleIds: Set<string>\n styleVersion: number\n rules: {\n memory: DesignMemory\n styleVersion: number\n variables: unknown[]\n rules: DesignRules\n } | null\n}\n\nconst states = new WeakMap<SceneGraph, DocumentDesignState>()\n\nfunction stateOf(graph: SceneGraph): DocumentDesignState {\n const known = states.get(graph)\n if (known) return known\n const state: DocumentDesignState = { styleIds: new Set(), styleVersion: 0, rules: null }\n for (const node of graph.getAllNodes()) if (isStyleNode(node)) state.styleIds.add(node.id)\n const touched = (id: string) => {\n const node = graph.getNode(id)\n const isStyle = node !== undefined && isStyleNode(node)\n if (!isStyle && !state.styleIds.has(id)) return\n if (isStyle) state.styleIds.add(id)\n else state.styleIds.delete(id)\n state.styleVersion++\n }\n graph.onNodeEvents({\n created: (node) => touched(node.id),\n updated: (id) => touched(id),\n deleted: (id) => touched(id)\n })\n states.set(graph, state)\n return state\n}\n\n/** Every reference a variable's values could change through, in a fixed order. */\nfunction variableFingerprint(graph: SceneGraph): unknown[] {\n const refs: unknown[] = []\n for (const variable of graph.variables.values()) {\n refs.push(variable, variable.type, variable.scopes?.join(','), variable.valuesByMode)\n for (const value of Object.values(variable.valuesByMode)) refs.push(value)\n }\n for (const collection of graph.variableCollections.values()) refs.push(collection.modes)\n return refs\n}\n\nfunction sameRefs(left: readonly unknown[], right: readonly unknown[]): boolean {\n return left.length === right.length && left.every((value, index) => value === right[index])\n}\n\n/**\n * The memory's rules resolved against the document as it is now, reused while the memory, the\n * style layers and the variables have not changed since they were last resolved.\n */\nexport function currentDesignRules(graph: SceneGraph, memory: DesignMemory): DesignRules {\n const state = stateOf(graph)\n const variables = variableFingerprint(graph)\n const cached = state.rules\n if (\n cached?.memory === memory &&\n cached.styleVersion === state.styleVersion &&\n sameRefs(cached.variables, variables)\n )\n return cached.rules\n const styles = [...state.styleIds].flatMap((id) => graph.getNode(id) ?? [])\n const rules = resolveDesignRules(graph, memory, styles)\n state.rules = { memory, styleVersion: state.styleVersion, variables, rules }\n return rules\n}\n"],"mappings":";;AAsBA,MAAM,yBAAS,IAAI,QAAyC;AAE5D,SAAS,QAAQ,OAAwC;CACvD,MAAM,QAAQ,OAAO,IAAI,KAAK;CAC9B,IAAI,OAAO,OAAO;CAClB,MAAM,QAA6B;EAAE,0BAAU,IAAI,IAAI;E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