@pairdraw/core 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +73 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +0 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -4
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +22 -3
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +168 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +6 -0
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +6 -3
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -1
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +31 -3
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +4 -54
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +224 -50
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +6 -3
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.js +3 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +26 -5
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +2 -1
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -3
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +22 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/tools/vector/vectorize.js +1 -0
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
- package/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -3
- package/src/canvas/renderer.ts +40 -4
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +17 -1
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +5 -1
- package/src/io/formats/fig/export/patch/index.ts +8 -0
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +12 -1
- package/src/io/formats/svg/defs.ts +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/layout.ts +5 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/nodes.ts +0 -1
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +34 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/path.ts +30 -6
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
- package/src/xpath.ts +6 -1
package/dist/icons/svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","names":[],"sources":["../../src/icons/svg.ts"],"sourcesContent":["import { iconToSVG, type IconifyIcon } from '@iconify/utils'\nimport { DOMImplementation, type Document as XMLDocument, type Element } from '@xmldom/xmldom'\nimport svgpath from 'svgpath'\n\nimport { parseSVGPath } from '@pairdraw/scene-graph/parse-path'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { parseSVGFragment } from '#core/io/formats/svg/document'\n\nimport {\n combinedTransform,\n DEFAULT_PRESENTATION,\n isElement,\n normalizeSVGPaint,\n num,\n opacityValue,\n presentationFor,\n presentationVisible\n} from './svg/presentation'\nimport { elementLayer, type Scope, type Traversal } from './svg/scope'\nimport { textInfo } from './svg/text'\nimport type {\n IconData,\n IconPathInfo,\n SVGClipPathRegion,\n SVGElementLayer,\n SVGTextInfo\n} from './types'\n\ninterface SVGElementInput {\n type: string\n props: Readonly<Record<string, unknown>>\n children: readonly (SVGElementInput | string)[]\n}\n\nconst SVG_NAMESPACE = 'http://www.w3.org/2000/svg'\nconst JSX_ATTRIBUTE_NAMES: Readonly<Record<string, string>> = {\n className: 'class',\n fillRule: 'fill-rule',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeWidth: 'stroke-width',\n xlinkHref: 'xlink:href'\n}\n\nconst SHAPE_NAMES = new Set(['path', 'circle', 'ellipse', 'rect', 'line', 'polygon', 'polyline'])\nconst NON_RENDERED_CONTAINERS = new Set(['defs', 'clipPath', 'mask', 'symbol'])\n\nfunction circleToD(element: Element): string | null {\n const cx = num(element, 'cx')\n const cy = num(element, 'cy')\n const r = num(element, 'r')\n return r > 0\n ? `M${cx - r},${cy}A${r},${r},0,1,0,${cx + r},${cy}A${r},${r},0,1,0,${cx - r},${cy}Z`\n : null\n}\n\nfunction ellipseToD(element: Element): string | null {\n const cx = num(element, 'cx')\n const cy = num(element, 'cy')\n const rx = num(element, 'rx')\n const ry = num(element, 'ry')\n return rx > 0 && ry > 0\n ? `M${cx - rx},${cy}A${rx},${ry},0,1,0,${cx + rx},${cy}A${rx},${ry},0,1,0,${cx - rx},${cy}Z`\n : null\n}\n\nfunction rectToD(element: Element): string | null {\n const x = num(element, 'x')\n const y = num(element, 'y')\n const width = num(element, 'width')\n const height = num(element, 'height')\n if (width <= 0 || height <= 0) return null\n const rx = Math.min(num(element, 'rx'), width / 2)\n const ry = Math.min(num(element, 'ry', rx), height / 2)\n if (rx > 0 || ry > 0) {\n const arcX = rx || ry\n const arcY = ry || rx\n return `M${x + arcX},${y}H${x + width - arcX}A${arcX},${arcY},0,0,1,${x + width},${y + arcY}V${y + height - arcY}A${arcX},${arcY},0,0,1,${x + width - arcX},${y + height}H${x + arcX}A${arcX},${arcY},0,0,1,${x},${y + height - arcY}V${y + arcY}A${arcX},${arcY},0,0,1,${x + arcX},${y}Z`\n }\n return `M${x},${y}H${x + width}V${y + height}H${x}Z`\n}\n\nfunction pointsToD(element: Element, close: boolean): string | null {\n const points = element.getAttribute('points')\n if (!points) return null\n const values = points\n .trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (values.length < 4 || values.length % 2 !== 0) return null\n let path = `M${values[0]},${values[1]}`\n for (let index = 2; index < values.length; index += 2) {\n path += `L${values[index]},${values[index + 1]}`\n }\n return close ? `${path}Z` : path\n}\n\nfunction shapeToD(tagName: string, element: Element): string | null {\n switch (tagName) {\n case 'circle':\n return circleToD(element)\n case 'ellipse':\n return ellipseToD(element)\n case 'rect':\n return rectToD(element)\n case 'line':\n return `M${num(element, 'x1')},${num(element, 'y1')}L${num(element, 'x2')},${num(element, 'y2')}`\n case 'polygon':\n return pointsToD(element, true)\n case 'polyline':\n return pointsToD(element, false)\n default:\n return null\n }\n}\n\nfunction appendShapePath(\n tagName: string,\n element: Element,\n scope: Scope,\n layer: SVGElementLayer,\n result: IconPathInfo[]\n): void {\n const pathData = tagName === 'path' ? element.getAttribute('d') : shapeToD(tagName, element)\n if (!pathData) return\n const { presentation } = scope\n const strokeWidth = Number.parseFloat(presentation.strokeWidth)\n result.push({\n d: pathData,\n fill: normalizeSVGPaint(presentation.fill, presentation.color),\n stroke: normalizeSVGPaint(presentation.stroke, presentation.color),\n strokeWidth: Number.isFinite(strokeWidth) ? strokeWidth : 1,\n strokeCap: presentation.strokeCap,\n strokeJoin: presentation.strokeJoin,\n fillRule: presentation.fillRule === 'evenodd' ? 'EVENODD' : 'NONZERO',\n fillOpacity: opacityValue(presentation.fillOpacity),\n strokeOpacity: opacityValue(presentation.strokeOpacity),\n transform: scope.transform,\n clipPaths: scope.clipPaths.length > 0 ? scope.clipPaths : undefined,\n elements: [...scope.elements, layer]\n })\n}\n\nfunction collectUsePaths(\n element: Element,\n scope: Scope,\n traversal: Traversal,\n result: IconPathInfo[]\n): void {\n const x = num(element, 'x')\n const y = num(element, 'y')\n const transform =\n x !== 0 || y !== 0 ? `${scope.transform ?? ''} translate(${x} ${y})`.trim() : scope.transform\n const href = element.getAttribute('href') ?? element.getAttribute('xlink:href')\n const target = href?.startsWith('#') ? traversal.elementsById.get(href.slice(1)) : null\n if (target && !scope.useStack.has(target)) {\n collectPaths(\n target,\n { ...scope, transform, useStack: new Set([...scope.useStack, target]), referenced: true },\n traversal,\n result\n )\n }\n}\n\nfunction collectClipPath(\n value: string | null,\n parentTransform: string | null,\n traversal: Traversal\n): SVGClipPathRegion | null {\n const match = value?.trim().match(/^url\\(\\s*['\"]?#([^'\")\\s]+)['\"]?\\s*\\)$/)\n const target = match ? traversal.elementsById.get(match[1]) : null\n if (!match || !target || (target.localName || target.tagName) !== 'clipPath') return null\n\n const units =\n target.getAttribute('clipPathUnits') === 'objectBoundingBox'\n ? 'objectBoundingBox'\n : 'userSpaceOnUse'\n const paths: IconPathInfo[] = []\n collectPaths(\n target,\n {\n presentation: { ...DEFAULT_PRESENTATION, fill: '#000000' },\n transform: units === 'objectBoundingBox' ? null : parentTransform,\n clipPaths: [],\n elements: [],\n useStack: new Set([target]),\n referenced: true\n },\n traversal,\n paths\n )\n return {\n id: match[1],\n paths: paths.map((path) => ({\n d: path.d,\n fillRule: path.fillRule,\n transform: path.transform,\n visible: isSVGPathShown(path)\n })),\n units,\n visible: presentationVisible(presentationFor(target, DEFAULT_PRESENTATION))\n }\n}\n\nfunction collectPaths(\n element: Element,\n inherited: Scope,\n traversal: Traversal,\n result: IconPathInfo[]\n): void {\n const tagName = element.localName || element.tagName\n if (NON_RENDERED_CONTAINERS.has(tagName) && !inherited.referenced) return\n\n const transform = combinedTransform(inherited.transform, element)\n const ownClipPath = collectClipPath(element.getAttribute('clip-path'), transform, traversal)\n const clipPaths = ownClipPath ? [...inherited.clipPaths, ownClipPath] : inherited.clipPaths\n const clip = ownClipPath ? clipPaths.length - 1 : null\n const scope: Scope = {\n ...inherited,\n presentation: presentationFor(element, inherited.presentation),\n transform,\n clipPaths\n }\n\n if (tagName === 'text') {\n const text = textInfo(element, scope, result.length)\n if (text) {\n const layer = elementLayer(traversal, element, 'shape', scope, clip)\n traversal.texts.push({ ...text, elements: [...scope.elements, layer] })\n }\n return\n }\n if (SHAPE_NAMES.has(tagName)) {\n appendShapePath(\n tagName,\n element,\n scope,\n elementLayer(traversal, element, 'shape', scope, clip),\n result\n )\n return\n }\n // A group is a layer; another container only becomes one to keep its clip or opacity.\n const layer = elementLayer(traversal, element, 'group', scope, clip)\n const isLayer =\n tagName === 'g' || clip !== null || (layer.opacity !== 1 && element !== traversal.root)\n const childScope = isLayer ? { ...scope, elements: [...scope.elements, layer] } : scope\n if (tagName === 'use') {\n collectUsePaths(element, childScope, traversal, result)\n return\n }\n for (const child of Array.from(element.childNodes)) {\n if (isElement(child)) collectPaths(child, childScope, traversal, result)\n }\n}\n\nfunction appendSVGElement(svgDocument: XMLDocument, parent: Element, input: SVGElementInput): void {\n if (!/^[A-Za-z][\\w:.-]*$/.test(input.type)) return\n const element = svgDocument.createElementNS(SVG_NAMESPACE, input.type)\n for (const [propName, value] of Object.entries(input.props)) {\n if (typeof value !== 'string' && typeof value !== 'number') continue\n const attributeName = JSX_ATTRIBUTE_NAMES[propName] ?? propName\n element.setAttribute(attributeName, String(value))\n }\n if (input.type === 'path' && !element.hasAttribute('d') && typeof input.props.body === 'string') {\n element.setAttribute('d', input.props.body)\n }\n for (const child of input.children) {\n if (typeof child !== 'string') appendSVGElement(svgDocument, element, child)\n }\n parent.appendChild(element)\n}\n\n/** The shapes and text an SVG draws, in drawing order. */\nexport interface SVGContent {\n paths: IconPathInfo[]\n texts: SVGTextInfo[]\n}\n\nfunction collectDocument(root: Element): SVGContent {\n const elementsById = new Map<string, Element>()\n for (const element of Array.from(root.getElementsByTagName('*'))) {\n const id = element.getAttribute('id')\n if (id) elementsById.set(id, element)\n }\n const paths: IconPathInfo[] = []\n const traversal: Traversal = { root, elementsById, nextKey: 0, texts: [] }\n collectPaths(\n root,\n {\n presentation: DEFAULT_PRESENTATION,\n transform: null,\n clipPaths: [],\n elements: [],\n useStack: new Set(),\n referenced: false\n },\n traversal,\n paths\n )\n return { paths, texts: traversal.texts }\n}\n\nexport function extractPathsFromElements(\n elements: readonly SVGElementInput[],\n rootProps: Readonly<Record<string, unknown>> = {}\n): IconPathInfo[] {\n const svgDocument = new DOMImplementation().createDocument(SVG_NAMESPACE, 'svg')\n const root = svgDocument.documentElement\n if (!root) return []\n appendSVGElement(svgDocument, root, { type: 'svg', props: rootProps, children: elements })\n return collectDocument(root).paths.filter(isSVGPathShown)\n}\n\nexport function extractSVGContent(svgBody: string): SVGContent {\n const root = parseSVGFragment(svgBody)?.documentElement\n return root ? collectDocument(root) : { paths: [], texts: [] }\n}\n\n/** Whether a shape shows: a hidden element hides everything in it, as a hidden layer does. */\nexport function isSVGPathShown(path: Pick<IconPathInfo, 'elements'>): boolean {\n return path.elements.every((element) => element.visible)\n}\n\n/** The shapes an SVG shows, for drawing it as one icon rather than importing its layers. */\nexport function extractPaths(svgBody: string): IconPathInfo[] {\n return extractSVGContent(svgBody).paths.filter(isSVGPathShown)\n}\n\n/**\n * An Iconify icon at `size`. Iconify's own rendering applies its box, defaulting to 16, and any\n * turn or flip, before the shapes are placed in the icon box as SVG import places them.\n */\nexport function buildIconData(\n icon: IconifyIcon,\n prefix: string,\n iconName: string,\n size: number\n): IconData {\n const rendered = iconToSVG(icon)\n const [x, y, width, height] = rendered.viewBox\n // As a browser draws the SVG: one scale for both axes, centered in the icon box, and the box's\n // own origin moved to the box's top-left.\n const scale = Math.min(size / width, size / height)\n const offsetX = -x * scale + (size - width * scale) / 2\n const offsetY = -y * scale + (size - height * scale) / 2\n\n return {\n prefix,\n name: iconName,\n width: size,\n height: size,\n paths: scalePathInfos(extractPaths(rendered.body), scale, scale, offsetX, offsetY)\n }\n}\n\nfunction transformStrokeScale(transform: string | null | undefined): number {\n if (!transform || transform === 'none') return 1\n\n const points: Vector[] = []\n svgpath('M0 0 L1 0 M0 0 L0 1')\n .transform(transform)\n .abs()\n .iterate((segment) => {\n if (segment[0] === 'M' || segment[0] === 'L') {\n points.push({ x: segment[1], y: segment[2] })\n }\n })\n if (points.length < 4) return 1\n\n const xScale = Math.hypot(points[1].x - points[0].x, points[1].y - points[0].y)\n const yScale = Math.hypot(points[3].x - points[2].x, points[3].y - points[2].y)\n return Math.min(xScale, yScale)\n}\n\n/** Scale extracted SVG path info into IconData paths (shared by buildIconData and design-jsx <svg>). */\nexport function scalePathInfos(\n pathInfos: IconPathInfo[],\n scaleX: number,\n scaleY: number,\n offsetX = 0,\n offsetY = 0\n): IconData['paths'] {\n return pathInfos.map((path) => {\n let transformedPath = svgpath(path.d)\n if (path.transform && path.transform !== 'none') {\n transformedPath = transformedPath.transform(path.transform)\n }\n if (scaleX !== 1 || scaleY !== 1) transformedPath = transformedPath.scale(scaleX, scaleY)\n if (offsetX !== 0 || offsetY !== 0)\n transformedPath = transformedPath.translate(offsetX, offsetY)\n const scaledD = transformedPath.round(2).toString()\n const fill = normalizeSVGPaint(path.fill)\n const stroke = normalizeSVGPaint(path.stroke)\n return {\n // A stroke would also trace the closing edge of an open subpath in the fill region.\n vectorNetwork: parseSVGPath(scaledD, path.fillRule, {\n includeOpenRegions: fill !== null && stroke === null\n }),\n fill,\n stroke,\n strokeWidth:\n path.strokeWidth * transformStrokeScale(path.transform) * Math.min(scaleX, scaleY),\n strokeCap: path.strokeCap,\n strokeJoin: path.strokeJoin\n }\n })\n}\n"],"mappings":";;;;;;;;;AAmCA,MAAM,gBAAgB;AACtB,MAAM,sBAAwD;CAC5D,WAAW;CACX,UAAU;CACV,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,WAAW;AACb;AAEA,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAW;CAAQ;CAAQ;CAAW;AAAU,CAAC;AAChG,MAAM,0CAA0B,IAAI,IAAI;CAAC;CAAQ;CAAY;CAAQ;AAAQ,CAAC;AAE9E,SAAS,UAAU,SAAiC;CAClD,MAAM,KAAK,IAAI,SAAS,IAAI;CAC5B,MAAM,KAAK,IAAI,SAAS,IAAI;CAC5B,MAAM,IAAI,IAAI,SAAS,GAAG;CAC1B,O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AI;EACxC,MAAM,SAAS,kBAAkB,KAAK,MAAM;EAC5C,OAAO;GAEL,eAAe,aAAa,SAAS,KAAK,UAAU,EAClD,oBAAoB,SAAS,QAAQ,WAAW,KAClD,CAAC;GACD;GACA;GACA,aACE,KAAK,cAAc,qBAAqB,KAAK,SAAS,IAAI,KAAK,IAAI,QAAQ,MAAM;GACnF,WAAW,KAAK;GAChB,YAAY,KAAK;EACnB;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"svg.js","names":[],"sources":["../../src/icons/svg.ts"],"sourcesContent":["import { iconToSVG, type IconifyIcon } from '@iconify/utils'\nimport { DOMImplementation, type Document as XMLDocument, type Element } from '@xmldom/xmldom'\nimport svgpath from 'svgpath'\n\nimport { parseSVGPath } from '@pairdraw/scene-graph/parse-path'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { parseSVGFragment } from '#core/io/formats/svg/document'\n\nimport {\n combinedTransform,\n DEFAULT_PRESENTATION,\n isElement,\n normalizeSVGPaint,\n num,\n opacityValue,\n presentationFor,\n presentationVisible\n} from './svg/presentation'\nimport { elementLayer, type Scope, type Traversal } from './svg/scope'\nimport { textInfo } from './svg/text'\nimport type {\n IconData,\n IconPathInfo,\n SVGClipPathRegion,\n SVGElementLayer,\n SVGTextInfo\n} from './types'\n\ninterface SVGElementInput {\n type: string\n props: Readonly<Record<string, unknown>>\n children: readonly (SVGElementInput | string)[]\n}\n\nconst SVG_NAMESPACE = 'http://www.w3.org/2000/svg'\nconst JSX_ATTRIBUTE_NAMES: Readonly<Record<string, string>> = {\n className: 'class',\n fillRule: 'fill-rule',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeWidth: 'stroke-width',\n xlinkHref: 'xlink:href'\n}\n\nconst SHAPE_NAMES = new Set(['path', 'circle', 'ellipse', 'rect', 'line', 'polygon', 'polyline'])\nconst NON_RENDERED_CONTAINERS = new Set(['defs', 'clipPath', 'mask', 'symbol'])\n\nfunction circleToD(element: Element): string | null {\n const cx = num(element, 'cx')\n const cy = num(element, 'cy')\n const r = num(element, 'r')\n return r > 0\n ? `M${cx - r},${cy}A${r},${r},0,1,0,${cx + r},${cy}A${r},${r},0,1,0,${cx - r},${cy}Z`\n : null\n}\n\nfunction ellipseToD(element: Element): string | null {\n const cx = num(element, 'cx')\n const cy = num(element, 'cy')\n const rx = num(element, 'rx')\n const ry = num(element, 'ry')\n return rx > 0 && ry > 0\n ? `M${cx - rx},${cy}A${rx},${ry},0,1,0,${cx + rx},${cy}A${rx},${ry},0,1,0,${cx - rx},${cy}Z`\n : null\n}\n\nfunction rectToD(element: Element): string | null {\n const x = num(element, 'x')\n const y = num(element, 'y')\n const width = num(element, 'width')\n const height = num(element, 'height')\n if (width <= 0 || height <= 0) return null\n const rx = Math.min(num(element, 'rx'), width / 2)\n const ry = Math.min(num(element, 'ry', rx), height / 2)\n if (rx > 0 || ry > 0) {\n const arcX = rx || ry\n const arcY = ry || rx\n return `M${x + arcX},${y}H${x + width - arcX}A${arcX},${arcY},0,0,1,${x + width},${y + arcY}V${y + height - arcY}A${arcX},${arcY},0,0,1,${x + width - arcX},${y + height}H${x + arcX}A${arcX},${arcY},0,0,1,${x},${y + height - arcY}V${y + arcY}A${arcX},${arcY},0,0,1,${x + arcX},${y}Z`\n }\n return `M${x},${y}H${x + width}V${y + height}H${x}Z`\n}\n\nfunction pointsToD(element: Element, close: boolean): string | null {\n const points = element.getAttribute('points')\n if (!points) return null\n const values = points\n .trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (values.length < 4 || values.length % 2 !== 0) return null\n let path = `M${values[0]},${values[1]}`\n for (let index = 2; index < values.length; index += 2) {\n path += `L${values[index]},${values[index + 1]}`\n }\n return close ? `${path}Z` : path\n}\n\nfunction shapeToD(tagName: string, element: Element): string | null {\n switch (tagName) {\n case 'circle':\n return circleToD(element)\n case 'ellipse':\n return ellipseToD(element)\n case 'rect':\n return rectToD(element)\n case 'line':\n return `M${num(element, 'x1')},${num(element, 'y1')}L${num(element, 'x2')},${num(element, 'y2')}`\n case 'polygon':\n return pointsToD(element, true)\n case 'polyline':\n return pointsToD(element, false)\n default:\n return null\n }\n}\n\nfunction appendShapePath(\n tagName: string,\n element: Element,\n scope: Scope,\n layer: SVGElementLayer,\n result: IconPathInfo[]\n): void {\n const pathData = tagName === 'path' ? element.getAttribute('d') : shapeToD(tagName, element)\n if (!pathData) return\n const { presentation } = scope\n const strokeWidth = Number.parseFloat(presentation.strokeWidth)\n result.push({\n d: pathData,\n fill: normalizeSVGPaint(presentation.fill, presentation.color),\n stroke: normalizeSVGPaint(presentation.stroke, presentation.color),\n strokeWidth: Number.isFinite(strokeWidth) ? strokeWidth : 1,\n strokeCap: presentation.strokeCap,\n strokeJoin: presentation.strokeJoin,\n fillRule: presentation.fillRule === 'evenodd' ? 'EVENODD' : 'NONZERO',\n fillOpacity: opacityValue(presentation.fillOpacity),\n strokeOpacity: opacityValue(presentation.strokeOpacity),\n transform: scope.transform,\n clipPaths: scope.clipPaths.length > 0 ? scope.clipPaths : undefined,\n elements: [...scope.elements, layer]\n })\n}\n\nfunction collectUsePaths(\n element: Element,\n scope: Scope,\n traversal: Traversal,\n result: IconPathInfo[]\n): void {\n const x = num(element, 'x')\n const y = num(element, 'y')\n const transform =\n x !== 0 || y !== 0 ? `${scope.transform ?? ''} translate(${x} ${y})`.trim() : scope.transform\n const href = element.getAttribute('href') ?? element.getAttribute('xlink:href')\n const target = href?.startsWith('#') ? traversal.elementsById.get(href.slice(1)) : null\n if (target && !scope.useStack.has(target)) {\n collectPaths(\n target,\n { ...scope, transform, useStack: new Set([...scope.useStack, target]), referenced: true },\n traversal,\n result\n )\n }\n}\n\nfunction collectClipPath(\n value: string | null,\n parentTransform: string | null,\n traversal: Traversal\n): SVGClipPathRegion | null {\n const match = value?.trim().match(/^url\\(\\s*['\"]?#([^'\")\\s]+)['\"]?\\s*\\)$/)\n const target = match ? traversal.elementsById.get(match[1]) : null\n if (!match || !target || (target.localName || target.tagName) !== 'clipPath') return null\n\n const units =\n target.getAttribute('clipPathUnits') === 'objectBoundingBox'\n ? 'objectBoundingBox'\n : 'userSpaceOnUse'\n const paths: IconPathInfo[] = []\n collectPaths(\n target,\n {\n presentation: { ...DEFAULT_PRESENTATION, fill: '#000000' },\n transform: units === 'objectBoundingBox' ? null : parentTransform,\n clipPaths: [],\n elements: [],\n useStack: new Set([target]),\n referenced: true\n },\n traversal,\n paths\n )\n return {\n id: match[1],\n paths: paths.map((path) => ({\n d: path.d,\n fillRule: path.fillRule,\n transform: path.transform,\n visible: isSVGPathShown(path)\n })),\n units,\n visible: presentationVisible(presentationFor(target, DEFAULT_PRESENTATION))\n }\n}\n\nfunction collectPaths(\n element: Element,\n inherited: Scope,\n traversal: Traversal,\n result: IconPathInfo[]\n): void {\n const tagName = element.localName || element.tagName\n if (NON_RENDERED_CONTAINERS.has(tagName) && !inherited.referenced) return\n\n const transform = combinedTransform(inherited.transform, element)\n const ownClipPath = collectClipPath(element.getAttribute('clip-path'), transform, traversal)\n const clipPaths = ownClipPath ? [...inherited.clipPaths, ownClipPath] : inherited.clipPaths\n const clip = ownClipPath ? clipPaths.length - 1 : null\n const scope: Scope = {\n ...inherited,\n presentation: presentationFor(element, inherited.presentation),\n transform,\n clipPaths\n }\n\n if (tagName === 'text') {\n const text = textInfo(element, scope, result.length)\n if (text) {\n const layer = elementLayer(traversal, element, 'shape', scope, clip)\n traversal.texts.push({ ...text, elements: [...scope.elements, layer] })\n }\n return\n }\n if (SHAPE_NAMES.has(tagName)) {\n appendShapePath(\n tagName,\n element,\n scope,\n elementLayer(traversal, element, 'shape', scope, clip),\n result\n )\n return\n }\n // A group is a layer; another container only becomes one to keep its clip or opacity.\n const layer = elementLayer(traversal, element, 'group', scope, clip)\n const isLayer =\n tagName === 'g' || clip !== null || (layer.opacity !== 1 && element !== traversal.root)\n const childScope = isLayer ? { ...scope, elements: [...scope.elements, layer] } : scope\n if (tagName === 'use') {\n collectUsePaths(element, childScope, traversal, result)\n return\n }\n for (const child of Array.from(element.childNodes)) {\n if (isElement(child)) collectPaths(child, childScope, traversal, result)\n }\n}\n\nfunction appendSVGElement(svgDocument: XMLDocument, parent: Element, input: SVGElementInput): void {\n if (!/^[A-Za-z][\\w:.-]*$/.test(input.type)) return\n const element = svgDocument.createElementNS(SVG_NAMESPACE, input.type)\n for (const [propName, value] of Object.entries(input.props)) {\n if (typeof value !== 'string' && typeof value !== 'number') continue\n const attributeName = JSX_ATTRIBUTE_NAMES[propName] ?? propName\n element.setAttribute(attributeName, String(value))\n }\n if (input.type === 'path' && !element.hasAttribute('d') && typeof input.props.body === 'string') {\n element.setAttribute('d', input.props.body)\n }\n for (const child of input.children) {\n if (typeof child !== 'string') appendSVGElement(svgDocument, element, child)\n }\n parent.appendChild(element)\n}\n\n/** The shapes and text an SVG draws, in drawing order. */\nexport interface SVGContent {\n paths: IconPathInfo[]\n texts: SVGTextInfo[]\n}\n\nfunction collectDocument(root: Element): SVGContent {\n const elementsById = new Map<string, Element>()\n for (const element of Array.from(root.getElementsByTagName('*'))) {\n const id = element.getAttribute('id')\n if (id) elementsById.set(id, element)\n }\n const paths: IconPathInfo[] = []\n const traversal: Traversal = { root, elementsById, nextKey: 0, texts: [] }\n collectPaths(\n root,\n {\n presentation: DEFAULT_PRESENTATION,\n transform: null,\n clipPaths: [],\n elements: [],\n useStack: new Set(),\n referenced: false\n },\n traversal,\n paths\n )\n return { paths, texts: traversal.texts }\n}\n\nexport function extractPathsFromElements(\n elements: readonly SVGElementInput[],\n rootProps: Readonly<Record<string, unknown>> = {}\n): IconPathInfo[] {\n const svgDocument = new DOMImplementation().createDocument(SVG_NAMESPACE, 'svg')\n const root = svgDocument.documentElement\n if (!root) return []\n appendSVGElement(svgDocument, root, { type: 'svg', props: rootProps, children: elements })\n return collectDocument(root).paths.filter(isSVGPathShown)\n}\n\nexport function extractSVGContent(svgBody: string): SVGContent {\n const root = parseSVGFragment(svgBody)?.documentElement\n return root ? collectDocument(root) : { paths: [], texts: [] }\n}\n\n/** Whether a shape shows: a hidden element hides everything in it, as a hidden layer does. */\nexport function isSVGPathShown(path: Pick<IconPathInfo, 'elements'>): boolean {\n return path.elements.every((element) => element.visible)\n}\n\n/** The shapes an SVG shows, for drawing it as one icon rather than importing its layers. */\nexport function extractPaths(svgBody: string): IconPathInfo[] {\n return extractSVGContent(svgBody).paths.filter(isSVGPathShown)\n}\n\n/**\n * An Iconify icon at `size`. Iconify's own rendering applies its box, defaulting to 16, and any\n * turn or flip, before the shapes are placed in the icon box as SVG import places them.\n */\nexport function buildIconData(\n icon: IconifyIcon,\n prefix: string,\n iconName: string,\n size: number\n): IconData {\n const rendered = iconToSVG(icon)\n const [x, y, width, height] = rendered.viewBox\n // As a browser draws the SVG: one scale for both axes, centered in the icon box, and the box's\n // own origin moved to the box's top-left.\n const scale = Math.min(size / width, size / height)\n const offsetX = -x * scale + (size - width * scale) / 2\n const offsetY = -y * scale + (size - height * scale) / 2\n\n return {\n prefix,\n name: iconName,\n width: size,\n height: size,\n paths: scalePathInfos(extractPaths(rendered.body), scale, scale, offsetX, offsetY)\n }\n}\n\nfunction transformStrokeScale(transform: string | null | undefined): number {\n if (!transform || transform === 'none') return 1\n\n const points: Vector[] = []\n svgpath('M0 0 L1 0 M0 0 L0 1')\n .transform(transform)\n .abs()\n .iterate((segment) => {\n if (segment[0] === 'M' || segment[0] === 'L') {\n points.push({ x: segment[1], y: segment[2] })\n }\n })\n if (points.length < 4) return 1\n\n const xScale = Math.hypot(points[1].x - points[0].x, points[1].y - points[0].y)\n const yScale = Math.hypot(points[3].x - points[2].x, points[3].y - points[2].y)\n return Math.min(xScale, yScale)\n}\n\n/** Scale extracted SVG path info into IconData paths (shared by buildIconData and design-jsx <svg>). */\nexport function scalePathInfos(\n pathInfos: IconPathInfo[],\n scaleX: number,\n scaleY: number,\n offsetX = 0,\n offsetY = 0\n): IconData['paths'] {\n return pathInfos.map((path) => {\n let transformedPath = svgpath(path.d)\n if (path.transform && path.transform !== 'none') {\n transformedPath = transformedPath.transform(path.transform)\n }\n if (scaleX !== 1 || scaleY !== 1) transformedPath = transformedPath.scale(scaleX, scaleY)\n if (offsetX !== 0 || offsetY !== 0)\n transformedPath = transformedPath.translate(offsetX, offsetY)\n // Arcs become curves before rounding, as the path parser would turn them anyway: rounding an\n // arc's own end can put it on its start, and a degenerate arc draws nothing.\n const scaledD = transformedPath.abs().unshort().unarc().round(2).toString()\n const fill = normalizeSVGPaint(path.fill)\n const stroke = normalizeSVGPaint(path.stroke)\n return {\n // A stroke would also trace the closing edge of an open subpath in the fill region.\n vectorNetwork: parseSVGPath(scaledD, path.fillRule, {\n includeOpenRegions: fill !== null && stroke === null\n }),\n fill,\n stroke,\n strokeWidth:\n path.strokeWidth * transformStrokeScale(path.transform) * Math.min(scaleX, scaleY),\n strokeCap: path.strokeCap,\n strokeJoin: path.strokeJoin\n }\n })\n}\n"],"mappings":";;;;;;;;;AAmCA,MAAM,gBAAgB;AACtB,MAAM,sBAAwD;CAC5D,WAAW;CACX,UAAU;CACV,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,WAAW;AACb;AAEA,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAW;CAAQ;CAAQ;CAAW;AAAU,CAAC;AAChG,MAAM,0CAA0B,IAAI,IAAI;CAAC;CAAQ;CAAY;CAAQ;AAAQ,CAAC;AAE9E,SAAS,UAAU,SAAiC;CAClD,MAAM,KAAK,IAAI,SAAS,IAAI;CAC5B,MAAM,KAAK,IAAI,SAAS,IAAI;CAC5B,MAAM,IAAI,IAAI,SAAS,GAAG;CAC1B,OAAO,IAAI,IACP,IAAI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,SAAS,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,SAAS,KAAK,EAAE,GAAG,GAAG,KACjF;AACN;AAEA,SAAS,WAAW,SAAiC;CACnD,MAAM,KAAK,IAAI,SAAS,IAAI;CAC5B,MA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AK,SAAS,IAAI,KAAK,IAAI,QAAQ,MAAM;GACnF,WAAW,KAAK;GAChB,YAAY,KAAK;EACnB;CACF,CAAC;AACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents,
|
|
|
6
6
|
import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
7
7
|
import { ClipboardSnapshot } from "./editor/clipboard/snapshot.js";
|
|
8
8
|
import { ClipboardPayload, CopyOptions } from "./editor/clipboard/copy.js";
|
|
9
|
+
import { DocumentChange, applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
9
10
|
import { SelectionSpacing } from "./editor/alignment.js";
|
|
10
11
|
import { NodeEditCapability, ReadOnlyLibraryDefinitionError, assertNodeEditable, getNodeEditCapability } from "./editor/capabilities.js";
|
|
11
12
|
import { ReadOnlyDocumentError } from "./editor/read-only/index.js";
|
|
@@ -13,11 +14,11 @@ import { createDocumentGraph } from "./editor/document-settings.js";
|
|
|
13
14
|
import { createDefaultEditorSharedState } from "./editor/state/shared.js";
|
|
14
15
|
import { editedGradient, editedGradientLayout } from "./editor/gradient-edit.js";
|
|
15
16
|
import { EditedImage, ImageEditModifiers, editableImageFillIndex, editedImage, editedImageLayout, imageEditChanges, imageEditCrops } from "./editor/image-edit.js";
|
|
16
|
-
import { DocumentChange, isEmptyDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
17
|
import { RecordEditOptions } from "./editor/history/edit.js";
|
|
18
18
|
import { PageSnapshot } from "./editor/history/snapshot/page.js";
|
|
19
19
|
import { MovePlace } from "./editor/undo.js";
|
|
20
20
|
import { SelectionColor, replaceSelectionColor, selectionColors, selectionColorsShown } from "./editor/selection/colors.js";
|
|
21
|
+
import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./editor/document-colors.js";
|
|
21
22
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
22
23
|
import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./editor/components/variants/model.js";
|
|
23
24
|
import { VariableTokenFields } from "./editor/variables.js";
|
|
@@ -49,7 +50,8 @@ import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
|
|
|
49
50
|
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
50
51
|
import { LayerType, layerTypeOptions } from "./editor/structure/layer-type.js";
|
|
51
52
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./editor/tool-registry.js";
|
|
53
|
+
import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
52
54
|
import { newLayerDefaults } from "./editor/shapes/defaults.js";
|
|
53
55
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./editor/structure/rename.js";
|
|
54
56
|
import "./editor/index.js";
|
|
55
|
-
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, type DocumentChange, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
57
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,9 @@ import { DEFAULT_SNAPPING_PREFERENCES } from "./editor/preferences.js";
|
|
|
12
12
|
import { createDocumentGraph } from "./editor/document-settings.js";
|
|
13
13
|
import { createDefaultEditorSharedState } from "./editor/state/shared.js";
|
|
14
14
|
import { replaceSelectionColor, selectionColors, selectionColorsShown } from "./editor/selection/colors.js";
|
|
15
|
+
import { DOCUMENT_COLOR_LIMIT, documentColors } from "./editor/document-colors.js";
|
|
15
16
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
16
|
-
import { isEmptyDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
|
+
import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
17
18
|
import { resolvePasteTarget } from "./editor/clipboard/paste/target.js";
|
|
18
19
|
import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
19
20
|
import { reapplyInstanceComponentProperties } from "./editor/components/properties.js";
|
|
@@ -32,4 +33,5 @@ import { createEditor } from "./editor/create.js";
|
|
|
32
33
|
import { executeAtomicTool } from "./editor/history/atomic-tool.js";
|
|
33
34
|
import { graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange } from "./editor/history/snapshot/graph.js";
|
|
34
35
|
import { resolvePlayState } from "./editor/play/states.js";
|
|
35
|
-
|
|
36
|
+
import { applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
37
|
+
export { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, EDITOR_TOOLS, EDIT_VIEW, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, SCALE_ANCHORS, TOOL_SHORTCUTS, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../../canvas/index.js";
|
|
2
|
+
import { SkiaRenderer } from "../../canvas/renderer.js";
|
|
3
|
+
import { CanvasKit } from "canvaskit-wasm";
|
|
4
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
5
|
+
//#region src/io/formats/boolean-path.d.ts
|
|
6
|
+
/** Writes a boolean operation's live result path as SVG path data, or null when it has none. */
|
|
7
|
+
type BooleanPathResolver = (graph: SceneGraph, node: SceneNode) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* A resolver that recomputes boolean geometry from the graph, through the same path operation the
|
|
10
|
+
* canvas draws, so an export follows edits to the operands instead of a stored copy. A host that
|
|
11
|
+
* already draws the document passes its CanvasKit and renderer, so the export never loads a
|
|
12
|
+
* second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.
|
|
13
|
+
*/
|
|
14
|
+
declare function booleanPathResolver(canvasKit?: CanvasKit, renderer?: SkiaRenderer): Promise<BooleanPathResolver>;
|
|
15
|
+
/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */
|
|
16
|
+
declare function needsBooleanPaths(graph: SceneGraph): boolean;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { BooleanPathResolver, booleanPathResolver, needsBooleanPaths };
|
|
19
|
+
//# sourceMappingURL=boolean-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-path.d.ts","names":[],"sources":["../../../src/io/formats/boolean-path.ts"],"mappings":";;;;;;KAUY,uBAAuB,OAAO,YAAY,MAAM;;;;;;;iBA2B5C,oBACd,YAAY,WACZ,WAAW,eACV,QAAQ;;iBAeK,kBAAkB,OAAO"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { makeBooleanOperationPath } from "../../canvas/boolean.js";
|
|
2
|
+
import { headlessRenderer } from "./raster/headless.js";
|
|
3
|
+
//#region src/io/formats/boolean-path.ts
|
|
4
|
+
/** One resolver per renderer: a host's live one, or the offscreen renderer built for a CanvasKit. */
|
|
5
|
+
const resolvers = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const pendingByCanvasKit = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
let pending = null;
|
|
8
|
+
function resolverFor(renderer) {
|
|
9
|
+
const cached = resolvers.get(renderer);
|
|
10
|
+
if (cached) return cached;
|
|
11
|
+
const resolver = (graph, node) => {
|
|
12
|
+
const path = makeBooleanOperationPath(renderer, node, graph);
|
|
13
|
+
if (!path) return null;
|
|
14
|
+
const data = path.toSVGString();
|
|
15
|
+
path.delete();
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
resolvers.set(renderer, resolver);
|
|
19
|
+
return resolver;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A resolver that recomputes boolean geometry from the graph, through the same path operation the
|
|
23
|
+
* canvas draws, so an export follows edits to the operands instead of a stored copy. A host that
|
|
24
|
+
* already draws the document passes its CanvasKit and renderer, so the export never loads a
|
|
25
|
+
* second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.
|
|
26
|
+
*/
|
|
27
|
+
function booleanPathResolver(canvasKit, renderer) {
|
|
28
|
+
if (renderer) return Promise.resolve(resolverFor(renderer));
|
|
29
|
+
if (canvasKit) {
|
|
30
|
+
let forKit = pendingByCanvasKit.get(canvasKit);
|
|
31
|
+
if (!forKit) {
|
|
32
|
+
forKit = headlessRenderer(canvasKit).then(({ renderer }) => resolverFor(renderer));
|
|
33
|
+
pendingByCanvasKit.set(canvasKit, forKit);
|
|
34
|
+
}
|
|
35
|
+
return forKit;
|
|
36
|
+
}
|
|
37
|
+
pending ??= headlessRenderer().then(({ renderer }) => resolverFor(renderer));
|
|
38
|
+
return pending;
|
|
39
|
+
}
|
|
40
|
+
/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */
|
|
41
|
+
function needsBooleanPaths(graph) {
|
|
42
|
+
return [...graph.getAllNodes()].some((node) => node.type === "BOOLEAN_OPERATION" && node.fillGeometry.length === 0);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { booleanPathResolver, needsBooleanPaths };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=boolean-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-path.js","names":[],"sources":["../../../src/io/formats/boolean-path.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas'\nimport { makeBooleanOperationPath } from '#core/canvas/boolean'\n\nimport { headlessRenderer } from './raster/headless'\n\n/** Writes a boolean operation's live result path as SVG path data, or null when it has none. */\nexport type BooleanPathResolver = (graph: SceneGraph, node: SceneNode) => string | null\n\n/** One resolver per renderer: a host's live one, or the offscreen renderer built for a CanvasKit. */\nconst resolvers = new WeakMap<SkiaRenderer, BooleanPathResolver>()\nconst pendingByCanvasKit = new WeakMap<CanvasKit, Promise<BooleanPathResolver>>()\nlet pending: Promise<BooleanPathResolver> | null = null\n\nfunction resolverFor(renderer: SkiaRenderer): BooleanPathResolver {\n const cached = resolvers.get(renderer)\n if (cached) return cached\n const resolver: BooleanPathResolver = (graph, node) => {\n const path = makeBooleanOperationPath(renderer, node, graph)\n if (!path) return null\n const data = path.toSVGString()\n path.delete()\n return data\n }\n resolvers.set(renderer, resolver)\n return resolver\n}\n\n/**\n * A resolver that recomputes boolean geometry from the graph, through the same path operation the\n * canvas draws, so an export follows edits to the operands instead of a stored copy. A host that\n * already draws the document passes its CanvasKit and renderer, so the export never loads a\n * second CanvasKit; without them the offscreen renderer loads its own, as the CLI and MCP do.\n */\nexport function booleanPathResolver(\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<BooleanPathResolver> {\n if (renderer) return Promise.resolve(resolverFor(renderer))\n if (canvasKit) {\n let forKit = pendingByCanvasKit.get(canvasKit)\n if (!forKit) {\n forKit = headlessRenderer(canvasKit).then(({ renderer }) => resolverFor(renderer))\n pendingByCanvasKit.set(canvasKit, forKit)\n }\n return forKit\n }\n pending ??= headlessRenderer().then(({ renderer }) => resolverFor(renderer))\n return pending\n}\n\n/** Whether an export has to compute boolean geometry: a boolean contains no stored result path. */\nexport function needsBooleanPaths(graph: SceneGraph): boolean {\n return [...graph.getAllNodes()].some(\n (node) => node.type === 'BOOLEAN_OPERATION' && node.fillGeometry.length === 0\n )\n}\n"],"mappings":";;;;AAaA,MAAM,4BAAY,IAAI,QAA2C;AACjE,MAAM,qCAAqB,IAAI,QAAiD;AAChF,IAAI,UAA+C;AAEnD,SAAS,YAAY,UAA6C;CAChE,MAAM,SAAS,UAAU,IAAI,QAAQ;CACrC,IAAI,QAAQ,OAAO;CACnB,MAAM,YAAiC,OAAO,SAAS;EACrD,MAAM,OAAO,yBAAyB,UAAU,MAAM,KAAK;EAC3D,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,OAAO,KAAK,YAAY;EAC9B,KAAK,OAAO;EACZ,OAAO;CACT;CACA,UAAU,IAAI,UAAU,QAAQ;CAChC,OAAO;AACT;;;;;;;AAQA,SAAgB,oBACd,WACA,UAC8B;CAC9B,IAAI,UAAU,OAAO,QAAQ,QAAQ,YAAY,QAAQ,CAAC;CAC1D,IAAI,WAAW;EACb,IAAI,SAAS,mBAAmB,IAAI,SAAS;EAC7C,IAAI,CAAC,QAAQ;GACX,SAAS,iBAAiB,SAAS,CAAC,CAAC,MAAM,EAAE,eAAe,YAAY,QAAQ,CAAC;GACjF,mBAAmB,IAAI,WAAW,MAAM;EAC1C;EACA,OAAO;CACT;CACA,YAAY,iBAAiB,CAAC,CAAC,MAAM,EAAE,eAAe,YAAY,QAAQ,CAAC;CAC3E,OAAO;AACT;;AAGA,SAAgB,kBAAkB,OAA4B;CAC5D,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,CAAC,MAC7B,SAAS,KAAK,SAAS,uBAAuB,KAAK,aAAa,WAAW,CAC9E;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PAIRDRAW_EXTENSION } from "./types.js";
|
|
2
2
|
import { ROOT_FONT_SIZE_PX } from "@pairdraw/scene-graph/variables";
|
|
3
3
|
import { CODE_SYNTAX_PLATFORMS, TOKEN_UNITS, VARIABLE_SCOPES } from "@pairdraw/scene-graph";
|
|
4
|
+
import { parseCSSNumber } from "@pairdraw/scene-graph/css";
|
|
4
5
|
import { parseDisplayableColor } from "@pairdraw/scene-graph/color";
|
|
5
6
|
import * as v from "valibot";
|
|
6
|
-
import { parseCSSNumber } from "@pairdraw/scene-graph/css";
|
|
7
7
|
//#region src/io/formats/design-tokens/decode.ts
|
|
8
8
|
/** A `{group.token}` reference, as its path segments. */
|
|
9
9
|
function referencePath(value) {
|
|
@@ -7,5 +7,8 @@ import { countTokenImportChanges } from "./plan/changes.js";
|
|
|
7
7
|
import { CSSTokenReadOptions, readCSSDesignTokens } from "./css/read.js";
|
|
8
8
|
import { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, DesignSystemFolder, DesignSystemImportResult, DesignSystemIssue, DesignSystemSourceFile, confinedDesignSystemPath, importDesignSystemFiles } from "./project.js";
|
|
9
9
|
import { TokenStylesheetSync, patchTokenStylesheet, syncTokenStylesheet } from "./css/sync.js";
|
|
10
|
+
import { TokenDrift, TokenDriftKind, TokenSync, TokenSyncBase, TokenSyncChoice, TokenSyncResolution, driftNeedsChoice, planTokenSync, tokenSnapshot, trackTokenDrift } from "./sync/drift.js";
|
|
11
|
+
import { readTokenSourceFiles } from "./sync/files.js";
|
|
12
|
+
import { TokenFilesSync, TokenSourceLink, syncTokenFiles, syncTokensIntoGraph, syncedTokenSources, tokenSourceForFiles } from "./sync/apply.js";
|
|
10
13
|
import { ImportedTokenFields, TokenImportResult, TokenImportTarget, applyTokenImport, importTokensIntoGraph, styleNodeProps, styleNodeType } from "./apply.js";
|
|
11
|
-
export { type AliasTarget, type CSSTokenReadOptions, type CollectionImportChoice, type CollectionTarget, DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, type DesignSystemFolder, type DesignSystemImportResult, type DesignSystemIssue, type DesignSystemSourceFile, type DesignToken, type DesignTokenBundle, type DesignTokenExport, type DesignTokenFile, type DesignTokenGroup, type DesignTokenIssue, type DesignTokenReadIssue, type DesignTokenSourceFile, type DesignTokenType, type ImportSkip, type ImportSkipReason, type ImportedTokenFields, type ModeTarget, PAIRDRAW_EXTENSION, type PlannedCollection, type PlannedMode, type PlannedStyle, type PlannedValue, type PlannedVariable, RESOLVER_FILE, RESOLVER_VERSION, type ReadCollection, type ReadMode, type ReadToken, STYLES_FILE, type TokenImportOptions, type TokenImportPlan, type TokenImportResult, type TokenImportTarget, type TokenStylesheetSync, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, readCSSDesignTokens, readDesignTokens, styleNodeProps, styleNodeType, syncTokenStylesheet };
|
|
14
|
+
export { type AliasTarget, type CSSTokenReadOptions, type CollectionImportChoice, type CollectionTarget, DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, type DesignSystemFolder, type DesignSystemImportResult, type DesignSystemIssue, type DesignSystemSourceFile, type DesignToken, type DesignTokenBundle, type DesignTokenExport, type DesignTokenFile, type DesignTokenGroup, type DesignTokenIssue, type DesignTokenReadIssue, type DesignTokenSourceFile, type DesignTokenType, type ImportSkip, type ImportSkipReason, type ImportedTokenFields, type ModeTarget, PAIRDRAW_EXTENSION, type PlannedCollection, type PlannedMode, type PlannedStyle, type PlannedValue, type PlannedVariable, RESOLVER_FILE, RESOLVER_VERSION, type ReadCollection, type ReadMode, type ReadToken, STYLES_FILE, type TokenDrift, type TokenDriftKind, type TokenFilesSync, type TokenImportOptions, type TokenImportPlan, type TokenImportResult, type TokenImportTarget, type TokenSourceLink, type TokenStylesheetSync, type TokenSync, type TokenSyncBase, type TokenSyncChoice, type TokenSyncResolution, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, driftNeedsChoice, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, planTokenSync, readCSSDesignTokens, readDesignTokens, readTokenSourceFiles, styleNodeProps, styleNodeType, syncTokenFiles, syncTokenStylesheet, syncTokensIntoGraph, syncedTokenSources, tokenSnapshot, tokenSourceForFiles, trackTokenDrift };
|
|
@@ -7,4 +7,7 @@ import { RESOLVER_FILE, STYLES_FILE, exportDesignTokens } from "./export.js";
|
|
|
7
7
|
import { readDesignTokens } from "./read.js";
|
|
8
8
|
import { countTokenImportChanges } from "./plan/changes.js";
|
|
9
9
|
import { patchTokenStylesheet, syncTokenStylesheet } from "./css/sync.js";
|
|
10
|
-
|
|
10
|
+
import { driftNeedsChoice, planTokenSync, tokenSnapshot, trackTokenDrift } from "./sync/drift.js";
|
|
11
|
+
import { readTokenSourceFiles } from "./sync/files.js";
|
|
12
|
+
import { syncTokenFiles, syncTokensIntoGraph, syncedTokenSources, tokenSourceForFiles } from "./sync/apply.js";
|
|
13
|
+
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, PAIRDRAW_EXTENSION, RESOLVER_FILE, RESOLVER_VERSION, STYLES_FILE, applyTokenImport, confinedDesignSystemPath, countTokenImportChanges, defaultTokenImportOptions, designTokenIssueMessage, driftNeedsChoice, exportDesignTokens, importDesignSystemFiles, importTokensIntoGraph, patchTokenStylesheet, planTokenImport, planTokenSync, readCSSDesignTokens, readDesignTokens, readTokenSourceFiles, styleNodeProps, styleNodeType, syncTokenFiles, syncTokenStylesheet, syncTokensIntoGraph, syncedTokenSources, tokenSnapshot, tokenSourceForFiles, trackTokenDrift };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { TokenImportPlan } from "./index.js";
|
|
2
|
-
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
1
|
+
import { PlannedValue, TokenImportPlan } from "./index.js";
|
|
2
|
+
import { SceneGraph, VariableValue } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/io/formats/design-tokens/plan/changes.d.ts
|
|
4
|
+
/** The value a planned one sets, or undefined where it points at a variable the import adds. */
|
|
5
|
+
declare function plannedValue(plan: TokenImportPlan, value: PlannedValue): VariableValue | undefined;
|
|
4
6
|
/**
|
|
5
7
|
* How many things an import would change: collections and modes it adds, variables it adds, and
|
|
6
8
|
* variables whose values it changes, so an import that would only write what the document already
|
|
@@ -8,5 +10,5 @@ import { SceneGraph } from "@pairdraw/scene-graph";
|
|
|
8
10
|
*/
|
|
9
11
|
declare function countTokenImportChanges(graph: SceneGraph, plan: TokenImportPlan): number;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { countTokenImportChanges };
|
|
13
|
+
export { countTokenImportChanges, plannedValue };
|
|
12
14
|
//# sourceMappingURL=changes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"changes.d.ts","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"mappings":";;;;iBAOgB,aACd,MAAM,iBACN,OAAO,eACN;;;;;;iBA0Ca,wBAAwB,OAAO,YAAY,MAAM"}
|
|
@@ -39,6 +39,6 @@ function countTokenImportChanges(graph, plan) {
|
|
|
39
39
|
return plan.collections.reduce((count, collection) => count + collectionChanges(graph, plan, collection), plan.styles.length);
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
-
export { countTokenImportChanges };
|
|
42
|
+
export { countTokenImportChanges, plannedValue };
|
|
43
43
|
|
|
44
44
|
//# sourceMappingURL=changes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changes.js","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph, VariableValue } from '@pairdraw/scene-graph'\n\nimport type { PlannedCollection, PlannedValue, TokenImportPlan } from './index'\n\n/** The value a planned one sets, or undefined where it points at a variable the import adds. */\
|
|
1
|
+
{"version":3,"file":"changes.js","names":[],"sources":["../../../../../src/io/formats/design-tokens/plan/changes.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph, VariableValue } from '@pairdraw/scene-graph'\n\nimport type { PlannedCollection, PlannedValue, TokenImportPlan } from './index'\n\n/** The value a planned one sets, or undefined where it points at a variable the import adds. */\nexport function plannedValue(\n plan: TokenImportPlan,\n value: PlannedValue\n): VariableValue | undefined {\n if (value.kind === 'literal') return value.value\n const { target } = value\n if (target.kind === 'variable') return { aliasId: target.variableId }\n const existingId = plan.collections[target.collection]?.variables[target.variable]?.existingId\n return existingId ? { aliasId: existingId } : undefined\n}\n\nfunction collectionChanges(\n graph: SceneGraph,\n plan: TokenImportPlan,\n collection: PlannedCollection\n): number {\n if (collection.target.kind === 'new') return collection.variables.length + 1\n const newModes = collection.modes.filter((mode) => mode.target.kind === 'new').length\n let changed = newModes\n for (const variable of collection.variables) {\n const current = variable.existingId ? graph.variables.get(variable.existingId) : undefined\n if (!current) {\n changed++\n continue\n }\n // A changed unit or CSS expression counts even where the number it comes to is the same.\n const unitChanged = variable.unit !== undefined && variable.unit !== current.unit\n const differs = variable.values.some((value, index) => {\n const target = collection.modes.at(index)?.target\n if (!value || !target) return false\n if (target.kind !== 'existing') return true\n const next = plannedValue(plan, value)\n if (next === undefined || !isEqual(current.valuesByMode[target.modeId], next)) return true\n return variable.expressions[index] !== current.expressions?.[target.modeId]?.css\n })\n if (unitChanged || differs) changed++\n }\n return changed\n}\n\n/**\n * How many things an import would change: collections and modes it adds, variables it adds, and\n * variables whose values it changes, so an import that would only write what the document already\n * has can be left out. Styles count whenever they are planned.\n */\nexport function countTokenImportChanges(graph: SceneGraph, plan: TokenImportPlan): number {\n return plan.collections.reduce(\n (count, collection) => count + collectionChanges(graph, plan, collection),\n plan.styles.length\n )\n}\n"],"mappings":";;;AAOA,SAAgB,aACd,MACA,OAC2B;CAC3B,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|
|
|
1
|
-
import { DesignTokenReadIssue, DesignTokenSourceFile } from "./read.js";
|
|
1
|
+
import { DesignTokenBundle, DesignTokenReadIssue, DesignTokenSourceFile } from "./read.js";
|
|
2
2
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/io/formats/design-tokens/project.d.ts
|
|
4
4
|
/** A stylesheet or manifest the folder reader already loaded. Paths stay inside the folder. */
|
|
@@ -53,6 +53,21 @@ declare const DESIGN_SYSTEM_MAX_FILES = 200;
|
|
|
53
53
|
declare const DESIGN_SYSTEM_MAX_TOTAL_BYTES: number;
|
|
54
54
|
/** A relative path that cannot climb out of the folder it was given against. */
|
|
55
55
|
declare function confinedDesignSystemPath(path: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The stylesheets a project folder's tokens come from: the one `components.json` names, or every
|
|
58
|
+
* stylesheet that declares custom properties. Paths that leave the folder and JavaScript config
|
|
59
|
+
* are reported, not read.
|
|
60
|
+
*/
|
|
61
|
+
declare function designSystemStylesheets(folder: DesignSystemFolder): {
|
|
62
|
+
stylesheets: DesignSystemSourceFile[];
|
|
63
|
+
issues: DesignSystemIssue[];
|
|
64
|
+
manifestPath?: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* One stylesheet of a project as a token bundle, read against the document as it is now. A
|
|
68
|
+
* shadcn/ui `:root` and `.dark` pair becomes Light and Dark modes; the bundle's issues are noted.
|
|
69
|
+
*/
|
|
70
|
+
declare function readDesignSystemStylesheet(graph: SceneGraph, file: DesignSystemSourceFile, issues: DesignSystemIssue[]): DesignTokenBundle;
|
|
56
71
|
/**
|
|
57
72
|
* Imports CSS variables from files already read inside one project folder.
|
|
58
73
|
* A shadcn/ui `:root` and `.dark` pair becomes one collection with Light and Dark modes.
|
|
@@ -60,5 +75,5 @@ declare function confinedDesignSystemPath(path: string): boolean;
|
|
|
60
75
|
*/
|
|
61
76
|
declare function importDesignSystemFiles(graph: SceneGraph, folder: DesignSystemFolder): DesignSystemImportResult;
|
|
62
77
|
//#endregion
|
|
63
|
-
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, DesignSystemFolder, DesignSystemImportResult, DesignSystemIssue, DesignSystemSourceFile, confinedDesignSystemPath, importDesignSystemFiles };
|
|
78
|
+
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, DesignSystemFolder, DesignSystemImportResult, DesignSystemIssue, DesignSystemSourceFile, confinedDesignSystemPath, designSystemStylesheets, importDesignSystemFiles, readDesignSystemStylesheet };
|
|
64
79
|
//# sourceMappingURL=project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/project.ts"],"mappings":";;;;KAeY,yBAAyB;KAEzB,oBACR;EACE;EAA0B;;EAC1B;EAA4B;;EAC5B;EAAsB;;EACtB;EAAwB;;EACxB;EAAwB;;EACxB;EAAyB;;EACzB;EAAoB;;EACpB;EAAiC;;EACjC;EAA2B;EAAc;EAAc;;;UAG5C;EACf,OAAO;EACP,QAAQ;;EAER;;UAGe;EACf;EACA;EACA,QAAQ;;;cAIG;;cAGA;;cAGA;;iBAsBG,yBAAyB;;;;;;iBA+
|
|
1
|
+
{"version":3,"file":"project.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/project.ts"],"mappings":";;;;KAeY,yBAAyB;KAEzB,oBACR;EACE;EAA0B;;EAC1B;EAA4B;;EAC5B;EAAsB;;EACtB;EAAwB;;EACxB;EAAwB;;EACxB;EAAyB;;EACzB;EAAoB;;EACpB;EAAiC;;EACjC;EAA2B;EAAc;EAAc;;;UAG5C;EACf,OAAO;EACP,QAAQ;;EAER;;UAGe;EACf;EACA;EACA,QAAQ;;;cAIG;;cAGA;;cAGA;;iBAsBG,yBAAyB;;;;;;iBA0GzB,wBAAwB,QAAQ;EAC9C,aAAa;EACb,QAAQ;EACR;;;;;;iBAgBc,2BACd,OAAO,YACP,MAAM,wBACN,QAAQ,sBACP;;;;;;iBA+Ba,wBACd,OAAO,YACP,QAAQ,qBACP"}
|
|
@@ -124,10 +124,33 @@ function manifestChoice(files, issues) {
|
|
|
124
124
|
path: manifest.path
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The stylesheets a project folder's tokens come from: the one `components.json` names, or every
|
|
129
|
+
* stylesheet that declares custom properties. Paths that leave the folder and JavaScript config
|
|
130
|
+
* are reported, not read.
|
|
131
|
+
*/
|
|
132
|
+
function designSystemStylesheets(folder) {
|
|
133
|
+
const issues = [...folder.issues];
|
|
134
|
+
const files = confineFiles(folder, issues);
|
|
135
|
+
const manifest = manifestChoice(files, issues);
|
|
136
|
+
return {
|
|
137
|
+
stylesheets: stylesheets(files, manifest.stylesheet, issues),
|
|
138
|
+
issues,
|
|
139
|
+
manifestPath: manifest.path
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* One stylesheet of a project as a token bundle, read against the document as it is now. A
|
|
144
|
+
* shadcn/ui `:root` and `.dark` pair becomes Light and Dark modes; the bundle's issues are noted.
|
|
145
|
+
*/
|
|
146
|
+
function readDesignSystemStylesheet(graph, file, issues) {
|
|
128
147
|
const bundle = readCSSDesignTokens(graph, file.text, { file: file.path });
|
|
129
148
|
renameShadcnModes(bundle);
|
|
130
149
|
for (const issue of bundle.issues) addIssue(issues, issue);
|
|
150
|
+
return bundle;
|
|
151
|
+
}
|
|
152
|
+
function importStylesheetFile(graph, pageId, file, issues) {
|
|
153
|
+
const bundle = readDesignSystemStylesheet(graph, file, issues);
|
|
131
154
|
const plan = planTokenImport(graph, bundle, defaultTokenImportOptions(graph, bundle));
|
|
132
155
|
for (const skip of plan.skipped) addIssue(issues, {
|
|
133
156
|
kind: "unsupported-value",
|
|
@@ -143,17 +166,15 @@ function importStylesheetFile(graph, pageId, file, issues) {
|
|
|
143
166
|
* JavaScript config is reported and ignored. Component source is recorded and not imported.
|
|
144
167
|
*/
|
|
145
168
|
function importDesignSystemFiles(graph, folder) {
|
|
146
|
-
const issues =
|
|
147
|
-
|
|
148
|
-
const manifest = manifestChoice(files, issues);
|
|
149
|
-
if (manifest.path || folder.componentsPath) addIssue(issues, {
|
|
169
|
+
const { stylesheets: files, issues, manifestPath } = designSystemStylesheets(folder);
|
|
170
|
+
if (manifestPath || folder.componentsPath) addIssue(issues, {
|
|
150
171
|
kind: "components-not-imported",
|
|
151
|
-
path:
|
|
172
|
+
path: manifestPath ?? folder.componentsPath ?? "components.json"
|
|
152
173
|
});
|
|
153
174
|
const pageId = graph.getPages()[0]?.id ?? graph.rootId;
|
|
154
175
|
const collectionIds = [];
|
|
155
176
|
const variableIds = [];
|
|
156
|
-
for (const file of
|
|
177
|
+
for (const file of files) {
|
|
157
178
|
const imported = importStylesheetFile(graph, pageId, file, issues);
|
|
158
179
|
collectionIds.push(...imported.collectionIds);
|
|
159
180
|
variableIds.push(...imported.variableIds);
|
|
@@ -165,6 +186,6 @@ function importDesignSystemFiles(graph, folder) {
|
|
|
165
186
|
};
|
|
166
187
|
}
|
|
167
188
|
//#endregion
|
|
168
|
-
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, confinedDesignSystemPath, importDesignSystemFiles };
|
|
189
|
+
export { DESIGN_SYSTEM_MAX_FILES, DESIGN_SYSTEM_MAX_FILE_BYTES, DESIGN_SYSTEM_MAX_TOTAL_BYTES, confinedDesignSystemPath, designSystemStylesheets, importDesignSystemFiles, readDesignSystemStylesheet };
|
|
169
190
|
|
|
170
191
|
//# sourceMappingURL=project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","names":[],"sources":["../../../../src/io/formats/design-tokens/project.ts"],"sourcesContent":["import { isAbsolute, normalize, posix } from 'pathe'\nimport * as v from 'valibot'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { importTokensIntoGraph } from '#core/io/formats/design-tokens/apply'\nimport { readCSSDesignTokens } from '#core/io/formats/design-tokens/css/read'\nimport { defaultTokenImportOptions, planTokenImport } from '#core/io/formats/design-tokens/plan'\nimport type {\n DesignTokenBundle,\n DesignTokenReadIssue,\n DesignTokenSourceFile\n} from '#core/io/formats/design-tokens/read'\n\n/** A stylesheet or manifest the folder reader already loaded. Paths stay inside the folder. */\nexport type DesignSystemSourceFile = DesignTokenSourceFile\n\nexport type DesignSystemIssue =\n | DesignTokenReadIssue\n | { kind: 'invalid-manifest'; path: string }\n | { kind: 'unsupported-config'; path: string }\n | { kind: 'escaped-path'; path: string }\n | { kind: 'file-too-large'; path: string }\n | { kind: 'too-many-files'; path: string }\n | { kind: 'total-too-large'; path: string }\n | { kind: 'unreadable'; path: string }\n | { kind: 'components-not-imported'; path: string }\n | { kind: 'unsupported-value'; path: string; name: string; reason: string }\n\n/** Files and notes a folder walk hands to the importer. The walk itself stays in Node. */\nexport interface DesignSystemFolder {\n files: DesignSystemSourceFile[]\n issues: DesignSystemIssue[]\n /** Set when the folder has component source, which this import does not read. */\n componentsPath?: string\n}\n\nexport interface DesignSystemImportResult {\n collectionIds: string[]\n variableIds: string[]\n issues: DesignSystemIssue[]\n}\n\n/** Files larger than this are reported and not read. */\nexport const DESIGN_SYSTEM_MAX_FILE_BYTES = 1_048_576\n\n/** How many stylesheets and manifests a folder read keeps. The next one is reported and the walk stops. */\nexport const DESIGN_SYSTEM_MAX_FILES = 200\n\n/** Total bytes of files a folder read keeps. The file that would pass this is reported and the walk stops. */\nexport const DESIGN_SYSTEM_MAX_TOTAL_BYTES = 8 * DESIGN_SYSTEM_MAX_FILE_BYTES\n\nconst CONFIG_FILE = /^tailwind\\.config\\.(?:js|ts|mjs|cjs|cts|mts)$/\n\nconst manifestSchema = v.looseObject({\n tailwind: v.optional(\n v.looseObject({\n css: v.optional(v.string()),\n config: v.optional(v.string())\n })\n )\n})\n\nfunction sameIssue(left: DesignSystemIssue, right: DesignSystemIssue): boolean {\n return JSON.stringify(left) === JSON.stringify(right)\n}\n\nfunction addIssue(issues: DesignSystemIssue[], issue: DesignSystemIssue): void {\n if (!issues.some((existing) => sameIssue(existing, issue))) issues.push(issue)\n}\n\n/** A relative path that cannot climb out of the folder it was given against. */\nexport function confinedDesignSystemPath(path: string): boolean {\n if (path.trim() === '') return false\n const normalized = normalize(path)\n if (normalized === '.' || isAbsolute(normalized)) return false\n return !normalized.split('/').includes('..')\n}\n\nfunction isConfigFile(path: string): boolean {\n return CONFIG_FILE.test(posix.basename(normalize(path)))\n}\n\nfunction declaresCustomProperties(text: string): boolean {\n return /@theme\\b/.test(text) || /(?:^|[^\\w-])--[\\w-]+\\s*:/.test(text)\n}\n\n/** shadcn/ui writes the light values on `:root` and the dark values on `.dark`. */\nfunction renameShadcnModes(bundle: DesignTokenBundle): void {\n for (const collection of bundle.collections) {\n const base = collection.modes.find(\n (mode) => mode.isDefault && mode.name === 'Default' && mode.condition === undefined\n )\n const dark = collection.modes.find((mode) => mode.name === 'dark' && mode.condition === '.dark')\n if (!base || !dark) continue\n const taken = new Set(collection.modes.map((mode) => mode.name))\n if (taken.has('Light') || taken.has('Dark')) continue\n base.name = 'Light'\n dark.name = 'Dark'\n }\n}\n\nfunction stylesheets(\n files: readonly DesignSystemSourceFile[],\n named: string | null | undefined,\n issues: DesignSystemIssue[]\n): DesignSystemSourceFile[] {\n if (named === null) return []\n const css = files.filter((file) => posix.basename(file.path).endsWith('.css'))\n if (named === undefined) return css.filter((file) => declaresCustomProperties(file.text))\n const match = css.find((file) => posix.normalize(file.path) === named)\n if (!match) addIssue(issues, { kind: 'missing-file', file: named, from: 'components.json' })\n return match ? [match] : []\n}\n\nfunction confineFiles(\n folder: DesignSystemFolder,\n issues: DesignSystemIssue[]\n): DesignSystemSourceFile[] {\n const files: DesignSystemSourceFile[] = []\n for (const file of folder.files) {\n if (!confinedDesignSystemPath(file.path)) {\n addIssue(issues, { kind: 'escaped-path', path: file.path })\n continue\n }\n files.push(file)\n if (isConfigFile(file.path)) addIssue(issues, { kind: 'unsupported-config', path: file.path })\n }\n return files\n}\n\nfunction noteTailwindConfig(config: string | undefined, issues: DesignSystemIssue[]): void {\n const path = config?.trim()\n if (!path) return\n if (!confinedDesignSystemPath(path)) {\n addIssue(issues, { kind: 'escaped-path', path })\n return\n }\n if (isConfigFile(path)) addIssue(issues, { kind: 'unsupported-config', path })\n}\n\n/** `undefined` scans stylesheets that declare variables. `null` imports none. */\nfunction stylesheetNamedByManifest(\n css: string | undefined,\n issues: DesignSystemIssue[]\n): string | null | undefined {\n const path = css?.trim()\n if (!path) return undefined\n if (!confinedDesignSystemPath(path)) {\n addIssue(issues, { kind: 'escaped-path', path })\n return null\n }\n return posix.normalize(path)\n}\n\nfunction manifestChoice(\n files: readonly DesignSystemSourceFile[],\n issues: DesignSystemIssue[]\n): { stylesheet: string | null | undefined; path?: string } {\n const manifest = files.find((file) => posix.normalize(file.path) === 'components.json')\n if (!manifest) return { stylesheet: undefined }\n const parsed = v.safeParse(v.pipe(v.string(), v.parseJson(), manifestSchema), manifest.text)\n if (!parsed.success) {\n addIssue(issues, { kind: 'invalid-manifest', path: manifest.path })\n return { stylesheet: undefined, path: manifest.path }\n }\n noteTailwindConfig(parsed.output.tailwind?.config, issues)\n return {\n stylesheet: stylesheetNamedByManifest(parsed.output.tailwind?.css, issues),\n path: manifest.path\n }\n}\n\nfunction importStylesheetFile(\n graph: SceneGraph,\n pageId: string,\n file: DesignSystemSourceFile,\n issues: DesignSystemIssue[]\n): { collectionIds: string[]; variableIds: string[] } {\n const bundle = readCSSDesignTokens(graph, file.text, { file: file.path })\n renameShadcnModes(bundle)\n for (const issue of bundle.issues) addIssue(issues, issue)\n const plan = planTokenImport(graph, bundle, defaultTokenImportOptions(graph, bundle))\n for (const skip of plan.skipped) {\n addIssue(issues, {\n kind: 'unsupported-value',\n path: file.path,\n name: skip.name,\n reason: skip.reason\n })\n }\n return importTokensIntoGraph(graph, pageId, plan)\n}\n\n/**\n * Imports CSS variables from files already read inside one project folder.\n * A shadcn/ui `:root` and `.dark` pair becomes one collection with Light and Dark modes.\n * JavaScript config is reported and ignored. Component source is recorded and not imported.\n */\nexport function importDesignSystemFiles(\n graph: SceneGraph,\n folder: DesignSystemFolder\n): DesignSystemImportResult {\n const issues = [...folder.issues]\n const files = confineFiles(folder, issues)\n const manifest = manifestChoice(files, issues)\n if (manifest.path || folder.componentsPath) {\n addIssue(issues, {\n kind: 'components-not-imported',\n path: manifest.path ?? folder.componentsPath ?? 'components.json'\n })\n }\n\n const pageId = graph.getPages()[0]?.id ?? graph.rootId\n const collectionIds: string[] = []\n const variableIds: string[] = []\n for (const file of stylesheets(files, manifest.stylesheet, issues)) {\n const imported = importStylesheetFile(graph, pageId, file, issues)\n collectionIds.push(...imported.collectionIds)\n variableIds.push(...imported.variableIds)\n }\n return { collectionIds, variableIds, issues }\n}\n"],"mappings":";;;;;;;AA4CA,MAAa,+BAA+B;;AAG5C,MAAa,0BAA0B;;AAGvC,MAAa,gCAAgC,IAAI;AAEjD,MAAM,cAAc;AAEpB,MAAM,iBAAiB,EAAE,YAAY,EACnC,UAAU,EAAE,SACV,EAAE,YAAY;CACZ,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;CAC1B,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;AAC/B,CAAC,CACH,EACF,CAAC;AAED,SAAS,UAAU,MAAyB,OAAmC;CAC7E,OAAO,KAAK,UAAU,IAAI,MAAM,KAAK,UAAU,KAAK;AACtD;AAEA,SAAS,SAAS,QAA6B,OAAgC;CAC7E,IAAI,CAAC,OAAO,MAAM,aAAa,UAAU,UAAU,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK;AAC/E;;AAGA,SAAgB,yBAAyB,MAAuB;CAC9D,IAAI,KAAK,KAAK,MAAM,IAAI,OAAO;CAC/B,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a;CAAO;AAC9C"}
|
|
1
|
+
{"version":3,"file":"project.js","names":[],"sources":["../../../../src/io/formats/design-tokens/project.ts"],"sourcesContent":["import { isAbsolute, normalize, posix } from 'pathe'\nimport * as v from 'valibot'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { importTokensIntoGraph } from '#core/io/formats/design-tokens/apply'\nimport { readCSSDesignTokens } from '#core/io/formats/design-tokens/css/read'\nimport { defaultTokenImportOptions, planTokenImport } from '#core/io/formats/design-tokens/plan'\nimport type {\n DesignTokenBundle,\n DesignTokenReadIssue,\n DesignTokenSourceFile\n} from '#core/io/formats/design-tokens/read'\n\n/** A stylesheet or manifest the folder reader already loaded. Paths stay inside the folder. */\nexport type DesignSystemSourceFile = DesignTokenSourceFile\n\nexport type DesignSystemIssue =\n | DesignTokenReadIssue\n | { kind: 'invalid-manifest'; path: string }\n | { kind: 'unsupported-config'; path: string }\n | { kind: 'escaped-path'; path: string }\n | { kind: 'file-too-large'; path: string }\n | { kind: 'too-many-files'; path: string }\n | { kind: 'total-too-large'; path: string }\n | { kind: 'unreadable'; path: string }\n | { kind: 'components-not-imported'; path: string }\n | { kind: 'unsupported-value'; path: string; name: string; reason: string }\n\n/** Files and notes a folder walk hands to the importer. The walk itself stays in Node. */\nexport interface DesignSystemFolder {\n files: DesignSystemSourceFile[]\n issues: DesignSystemIssue[]\n /** Set when the folder has component source, which this import does not read. */\n componentsPath?: string\n}\n\nexport interface DesignSystemImportResult {\n collectionIds: string[]\n variableIds: string[]\n issues: DesignSystemIssue[]\n}\n\n/** Files larger than this are reported and not read. */\nexport const DESIGN_SYSTEM_MAX_FILE_BYTES = 1_048_576\n\n/** How many stylesheets and manifests a folder read keeps. The next one is reported and the walk stops. */\nexport const DESIGN_SYSTEM_MAX_FILES = 200\n\n/** Total bytes of files a folder read keeps. The file that would pass this is reported and the walk stops. */\nexport const DESIGN_SYSTEM_MAX_TOTAL_BYTES = 8 * DESIGN_SYSTEM_MAX_FILE_BYTES\n\nconst CONFIG_FILE = /^tailwind\\.config\\.(?:js|ts|mjs|cjs|cts|mts)$/\n\nconst manifestSchema = v.looseObject({\n tailwind: v.optional(\n v.looseObject({\n css: v.optional(v.string()),\n config: v.optional(v.string())\n })\n )\n})\n\nfunction sameIssue(left: DesignSystemIssue, right: DesignSystemIssue): boolean {\n return JSON.stringify(left) === JSON.stringify(right)\n}\n\nfunction addIssue(issues: DesignSystemIssue[], issue: DesignSystemIssue): void {\n if (!issues.some((existing) => sameIssue(existing, issue))) issues.push(issue)\n}\n\n/** A relative path that cannot climb out of the folder it was given against. */\nexport function confinedDesignSystemPath(path: string): boolean {\n if (path.trim() === '') return false\n const normalized = normalize(path)\n if (normalized === '.' || isAbsolute(normalized)) return false\n return !normalized.split('/').includes('..')\n}\n\nfunction isConfigFile(path: string): boolean {\n return CONFIG_FILE.test(posix.basename(normalize(path)))\n}\n\nfunction declaresCustomProperties(text: string): boolean {\n return /@theme\\b/.test(text) || /(?:^|[^\\w-])--[\\w-]+\\s*:/.test(text)\n}\n\n/** shadcn/ui writes the light values on `:root` and the dark values on `.dark`. */\nfunction renameShadcnModes(bundle: DesignTokenBundle): void {\n for (const collection of bundle.collections) {\n const base = collection.modes.find(\n (mode) => mode.isDefault && mode.name === 'Default' && mode.condition === undefined\n )\n const dark = collection.modes.find((mode) => mode.name === 'dark' && mode.condition === '.dark')\n if (!base || !dark) continue\n const taken = new Set(collection.modes.map((mode) => mode.name))\n if (taken.has('Light') || taken.has('Dark')) continue\n base.name = 'Light'\n dark.name = 'Dark'\n }\n}\n\nfunction stylesheets(\n files: readonly DesignSystemSourceFile[],\n named: string | null | undefined,\n issues: DesignSystemIssue[]\n): DesignSystemSourceFile[] {\n if (named === null) return []\n const css = files.filter((file) => posix.basename(file.path).endsWith('.css'))\n if (named === undefined) return css.filter((file) => declaresCustomProperties(file.text))\n const match = css.find((file) => posix.normalize(file.path) === named)\n if (!match) addIssue(issues, { kind: 'missing-file', file: named, from: 'components.json' })\n return match ? [match] : []\n}\n\nfunction confineFiles(\n folder: DesignSystemFolder,\n issues: DesignSystemIssue[]\n): DesignSystemSourceFile[] {\n const files: DesignSystemSourceFile[] = []\n for (const file of folder.files) {\n if (!confinedDesignSystemPath(file.path)) {\n addIssue(issues, { kind: 'escaped-path', path: file.path })\n continue\n }\n files.push(file)\n if (isConfigFile(file.path)) addIssue(issues, { kind: 'unsupported-config', path: file.path })\n }\n return files\n}\n\nfunction noteTailwindConfig(config: string | undefined, issues: DesignSystemIssue[]): void {\n const path = config?.trim()\n if (!path) return\n if (!confinedDesignSystemPath(path)) {\n addIssue(issues, { kind: 'escaped-path', path })\n return\n }\n if (isConfigFile(path)) addIssue(issues, { kind: 'unsupported-config', path })\n}\n\n/** `undefined` scans stylesheets that declare variables. `null` imports none. */\nfunction stylesheetNamedByManifest(\n css: string | undefined,\n issues: DesignSystemIssue[]\n): string | null | undefined {\n const path = css?.trim()\n if (!path) return undefined\n if (!confinedDesignSystemPath(path)) {\n addIssue(issues, { kind: 'escaped-path', path })\n return null\n }\n return posix.normalize(path)\n}\n\nfunction manifestChoice(\n files: readonly DesignSystemSourceFile[],\n issues: DesignSystemIssue[]\n): { stylesheet: string | null | undefined; path?: string } {\n const manifest = files.find((file) => posix.normalize(file.path) === 'components.json')\n if (!manifest) return { stylesheet: undefined }\n const parsed = v.safeParse(v.pipe(v.string(), v.parseJson(), manifestSchema), manifest.text)\n if (!parsed.success) {\n addIssue(issues, { kind: 'invalid-manifest', path: manifest.path })\n return { stylesheet: undefined, path: manifest.path }\n }\n noteTailwindConfig(parsed.output.tailwind?.config, issues)\n return {\n stylesheet: stylesheetNamedByManifest(parsed.output.tailwind?.css, issues),\n path: manifest.path\n }\n}\n\n/**\n * The stylesheets a project folder's tokens come from: the one `components.json` names, or every\n * stylesheet that declares custom properties. Paths that leave the folder and JavaScript config\n * are reported, not read.\n */\nexport function designSystemStylesheets(folder: DesignSystemFolder): {\n stylesheets: DesignSystemSourceFile[]\n issues: DesignSystemIssue[]\n manifestPath?: string\n} {\n const issues = [...folder.issues]\n const files = confineFiles(folder, issues)\n const manifest = manifestChoice(files, issues)\n return {\n stylesheets: stylesheets(files, manifest.stylesheet, issues),\n issues,\n manifestPath: manifest.path\n }\n}\n\n/**\n * One stylesheet of a project as a token bundle, read against the document as it is now. A\n * shadcn/ui `:root` and `.dark` pair becomes Light and Dark modes; the bundle's issues are noted.\n */\nexport function readDesignSystemStylesheet(\n graph: SceneGraph,\n file: DesignSystemSourceFile,\n issues: DesignSystemIssue[]\n): DesignTokenBundle {\n const bundle = readCSSDesignTokens(graph, file.text, { file: file.path })\n renameShadcnModes(bundle)\n for (const issue of bundle.issues) addIssue(issues, issue)\n return bundle\n}\n\nfunction importStylesheetFile(\n graph: SceneGraph,\n pageId: string,\n file: DesignSystemSourceFile,\n issues: DesignSystemIssue[]\n): { collectionIds: string[]; variableIds: string[] } {\n const bundle = readDesignSystemStylesheet(graph, file, issues)\n const plan = planTokenImport(graph, bundle, defaultTokenImportOptions(graph, bundle))\n for (const skip of plan.skipped) {\n addIssue(issues, {\n kind: 'unsupported-value',\n path: file.path,\n name: skip.name,\n reason: skip.reason\n })\n }\n return importTokensIntoGraph(graph, pageId, plan)\n}\n\n/**\n * Imports CSS variables from files already read inside one project folder.\n * A shadcn/ui `:root` and `.dark` pair becomes one collection with Light and Dark modes.\n * JavaScript config is reported and ignored. Component source is recorded and not imported.\n */\nexport function importDesignSystemFiles(\n graph: SceneGraph,\n folder: DesignSystemFolder\n): DesignSystemImportResult {\n const { stylesheets: files, issues, manifestPath } = designSystemStylesheets(folder)\n if (manifestPath || folder.componentsPath) {\n addIssue(issues, {\n kind: 'components-not-imported',\n path: manifestPath ?? folder.componentsPath ?? 'components.json'\n })\n }\n\n const pageId = graph.getPages()[0]?.id ?? graph.rootId\n const collectionIds: string[] = []\n const variableIds: string[] = []\n for (const file of files) {\n const imported = importStylesheetFile(graph, pageId, file, issues)\n collectionIds.push(...imported.collectionIds)\n variableIds.push(...imported.variableIds)\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S,QAAQ,KAAK;CACzD,OAAO;AACT;AAEA,SAAS,qBACP,OACA,QACA,MACA,QACoD;CACpD,MAAM,SAAS,2BAA2B,OAAO,MAAM,MAAM;CAC7D,MAAM,OAAO,gBAAgB,OAAO,QAAQ,0BAA0B,OAAO,MAAM,CAAC;CACpF,KAAK,MAAM,QAAQ,KAAK,SACtB,SAAS,QAAQ;EACf,MAAM;EACN,MAAM,KAAK;EACX,MAAM,KAAK;EACX,QAAQ,KAAK;CACf,CAAC;CAEH,OAAO,sBAAsB,OAAO,QAAQ,IAAI;AAClD;;;;;;AAOA,SAAgB,wBACd,OACA,QAC0B;CAC1B,MAAM,EAAE,aAAa,OAAO,QAAQ,iBAAiB,wBAAwB,MAAM;CACnF,IAAI,gBAAgB,OAAO,gBACzB,SAAS,QAAQ;EACf,MAAM;EACN,MAAM,gBAAgB,OAAO,kBAAkB;CACjD,CAAC;CAGH,MAAM,SAAS,MAAM,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,MAAM;CAChD,MAAM,gBAA0B,CAAC;CACjC,MAAM,cAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,qBAAqB,OAAO,QAAQ,MAAM,MAAM;EACjE,cAAc,KAAK,GAAG,SAAS,aAAa;EAC5C,YAAY,KAAK,GAAG,SAAS,WAAW;CAC1C;CACA,OAAO;EAAE;EAAe;EAAa;CAAO;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/styles.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/styles.ts"],"mappings":";;;;KAmBY,kBAAkB;;;;;UAMb;EACf;EACA;;cA+BI;KAcM,mBAAmB,KAC7B;;iBAKc,gBACd,MAAM,kBACN,OAAO,QAAQ,eAAe;;;;;;;;;;;;;iBA+ChB,SAAS,QAAQ,SAAS,UAAU;;iBAgBpC,iBAAiB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDnC,YACd,OAAO,YACP,YAAY;EACT,QAAQ;IAAQ;IAAgB,OAAO;;EAAgB,QAAQ;;;iBAwCpD,iBACd,OAAO,aACP,cACA,0BACC"}
|