@pairdraw/core 0.21.1 → 0.22.1
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/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.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/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- 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 +6 -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 +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +30 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.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/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +65 -9
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- 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/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/font/batch.d.ts +26 -0
- package/dist/text/font/batch.d.ts.map +1 -0
- package/dist/text/font/batch.js +31 -0
- package/dist/text/font/batch.js.map +1 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +14 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +3 -2
- package/dist/text/index.js +3 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/font/batch.ts +58 -0
- package/src/text/font/manager.ts +17 -1
- package/src/text/index.ts +2 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AttachModifiers } from "./editor/connectors/attach.js";
|
|
|
2
2
|
import { DEFAULT_SNAPPING_PREFERENCES, SnappingPreferences } from "./editor/preferences.js";
|
|
3
3
|
import { ShaderRasterizer } from "./editor/shaders/types.js";
|
|
4
4
|
import { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentationScale, ShaderView } from "./editor/views/types.js";
|
|
5
|
-
import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
|
|
5
|
+
import { ClipboardImageResolution, ClipboardPatternSources, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
|
|
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";
|
|
@@ -21,8 +21,9 @@ import { SelectionColor, replaceSelectionColor, selectionColors, selectionColors
|
|
|
21
21
|
import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./editor/document-colors.js";
|
|
22
22
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
23
23
|
import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./editor/components/variants/model.js";
|
|
24
|
-
import { VariableTokenFields } from "./editor/variables.js";
|
|
25
24
|
import { NodePreview } from "./editor/node-preview.js";
|
|
25
|
+
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
26
|
+
import { VariableTokenFields } from "./editor/variables.js";
|
|
26
27
|
import { DEFAULT_SCALE_ANCHOR, SCALE_ANCHORS, ScaleAnchor, isScaleAnchor, parseScaleFactor, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds } from "./editor/scale/anchor.js";
|
|
27
28
|
import { ScaleSession } from "./editor/scale/actions.js";
|
|
28
29
|
import { RescaleSnapshot, rescaleNodes } from "./editor/scale/rescale.js";
|
|
@@ -47,11 +48,10 @@ import { reapplyInstanceComponentProperties } from "./editor/components/properti
|
|
|
47
48
|
import { createGuideActions } from "./editor/guides.js";
|
|
48
49
|
import { createTextActions } from "./editor/text.js";
|
|
49
50
|
import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
|
|
50
|
-
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
51
51
|
import { LayerType, layerTypeOptions } from "./editor/structure/layer-type.js";
|
|
52
52
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./editor/tool-registry.js";
|
|
53
53
|
import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
54
54
|
import { newLayerDefaults } from "./editor/shapes/defaults.js";
|
|
55
55
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./editor/structure/rename.js";
|
|
56
56
|
import "./editor/index.js";
|
|
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 };
|
|
57
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPatternSources, 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
|
@@ -15,12 +15,12 @@ import { replaceSelectionColor, selectionColors, selectionColorsShown } from "./
|
|
|
15
15
|
import { DOCUMENT_COLOR_LIMIT, documentColors } from "./editor/document-colors.js";
|
|
16
16
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
17
17
|
import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
|
|
18
|
+
import { syncEditedComponents } from "./editor/component-sync.js";
|
|
18
19
|
import { resolvePasteTarget } from "./editor/clipboard/paste/target.js";
|
|
19
20
|
import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
20
21
|
import { reapplyInstanceComponentProperties } from "./editor/components/properties.js";
|
|
21
22
|
import { newLayerDefaults } from "./editor/shapes/defaults.js";
|
|
22
23
|
import { pastedPropertyChanges } from "./editor/clipboard/paste/properties.js";
|
|
23
|
-
import { syncEditedComponents } from "./editor/component-sync.js";
|
|
24
24
|
import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
|
|
25
25
|
import { createGuideActions } from "./editor/guides.js";
|
|
26
26
|
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/io/formats/code/detect.d.ts
|
|
2
|
+
/** The most source a paste reads: 200 000 characters of JSX or HTML. */
|
|
3
|
+
declare const MAX_CODE_LENGTH = 200000;
|
|
4
|
+
/** What a pasted source is written in, which decides how its layers are built. */
|
|
5
|
+
type PasteCodeKind = 'jsx' | 'html';
|
|
6
|
+
/** Detection's answer for source longer than a paste reads. */
|
|
7
|
+
declare const CODE_TOO_LARGE = "too-large";
|
|
8
|
+
/** What detection says about a text: the code it holds, or that it is past the size a paste reads. */
|
|
9
|
+
type CodeDetection = PasteCodeKind | typeof CODE_TOO_LARGE;
|
|
10
|
+
/**
|
|
11
|
+
* What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is
|
|
12
|
+
* markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it
|
|
13
|
+
* draws no element, so ordinary text keeps pasting as text.
|
|
14
|
+
*/
|
|
15
|
+
declare function detectCode(text: string): CodeDetection | null;
|
|
16
|
+
/**
|
|
17
|
+
* The code a pasted text holds, or null when it is not code or is past the size a paste reads;
|
|
18
|
+
* `detectCode` says which of the two refused it.
|
|
19
|
+
*/
|
|
20
|
+
declare function detectCodeText(text: string): PasteCodeKind | null;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CODE_TOO_LARGE, CodeDetection, MAX_CODE_LENGTH, PasteCodeKind, detectCode, detectCodeText };
|
|
23
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","names":[],"sources":["../../../../src/io/formats/code/detect.ts"],"mappings":";;cACa;;KAGD;;cAGC;;KAGD,gBAAgB,uBAAuB;;;;;;iBAqCnC,WAAW,eAAe;;;;;iBAgB1B,eAAe,eAAe"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/io/formats/code/detect.ts
|
|
2
|
+
/** The most source a paste reads: 200 000 characters of JSX or HTML. */
|
|
3
|
+
const MAX_CODE_LENGTH = 2e5;
|
|
4
|
+
/** Detection's answer for source longer than a paste reads. */
|
|
5
|
+
const CODE_TOO_LARGE = "too-large";
|
|
6
|
+
const ELEMENT = /<([A-Za-z][\w.:-]*)(?:\s[^<>]*)?\/?>/;
|
|
7
|
+
const CLOSING = /<\/([A-Za-z][\w.:-]*)\s*>/;
|
|
8
|
+
const SELF_CLOSING = /<([A-Za-z][\w.:-]*)(?:\s[^<>]*)?\/>/;
|
|
9
|
+
const FRAGMENT = /<>[\s\S]*<\/>/;
|
|
10
|
+
/** A source that names a component, an export, or an arrow body, rather than plain markup. */
|
|
11
|
+
const JSX_SOURCE = /\b(?:className\s*=|export\s+(?:default|function|const)\b|=>|function\s+[A-Z_a-z]\w*\s*\()/;
|
|
12
|
+
/** The kind of code a trimmed text draws, or null when it draws no element. */
|
|
13
|
+
function looksLikeCode(trimmed, tail) {
|
|
14
|
+
if (!ELEMENT.test(trimmed)) return null;
|
|
15
|
+
if (!CLOSING.test(trimmed) && !SELF_CLOSING.test(trimmed) && !FRAGMENT.test(trimmed) && !CLOSING.test(tail)) return null;
|
|
16
|
+
if (!trimmed.startsWith("<")) {
|
|
17
|
+
if (!/\breturn\b|\bimport\b|\bexport\b/.test(trimmed)) return null;
|
|
18
|
+
return "jsx";
|
|
19
|
+
}
|
|
20
|
+
return JSX_SOURCE.test(trimmed) ? "jsx" : "html";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is
|
|
24
|
+
* markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it
|
|
25
|
+
* draws no element, so ordinary text keeps pasting as text.
|
|
26
|
+
*/
|
|
27
|
+
function detectCode(text) {
|
|
28
|
+
const tooLarge = text.length > MAX_CODE_LENGTH;
|
|
29
|
+
const trimmed = (tooLarge ? text.slice(0, MAX_CODE_LENGTH) : text).trim();
|
|
30
|
+
const tail = tooLarge ? text.slice(-4096) : "";
|
|
31
|
+
const kind = trimmed.length > 0 ? looksLikeCode(trimmed, tail) : null;
|
|
32
|
+
if (!kind) return null;
|
|
33
|
+
return tooLarge ? CODE_TOO_LARGE : kind;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The code a pasted text holds, or null when it is not code or is past the size a paste reads;
|
|
37
|
+
* `detectCode` says which of the two refused it.
|
|
38
|
+
*/
|
|
39
|
+
function detectCodeText(text) {
|
|
40
|
+
const detection = detectCode(text);
|
|
41
|
+
return detection === "too-large" ? null : detection;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, detectCodeText };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","names":[],"sources":["../../../../src/io/formats/code/detect.ts"],"sourcesContent":["/** The most source a paste reads: 200 000 characters of JSX or HTML. */\nexport const MAX_CODE_LENGTH = 200_000\n\n/** What a pasted source is written in, which decides how its layers are built. */\nexport type PasteCodeKind = 'jsx' | 'html'\n\n/** Detection's answer for source longer than a paste reads. */\nexport const CODE_TOO_LARGE = 'too-large'\n\n/** What detection says about a text: the code it holds, or that it is past the size a paste reads. */\nexport type CodeDetection = PasteCodeKind | typeof CODE_TOO_LARGE\n\nconst ELEMENT = /<([A-Za-z][\\w.:-]*)(?:\\s[^<>]*)?\\/?>/\nconst CLOSING = /<\\/([A-Za-z][\\w.:-]*)\\s*>/\nconst SELF_CLOSING = /<([A-Za-z][\\w.:-]*)(?:\\s[^<>]*)?\\/>/\nconst FRAGMENT = /<>[\\s\\S]*<\\/>/\n/** A source that names a component, an export, or an arrow body, rather than plain markup. */\nconst JSX_SOURCE =\n /\\b(?:className\\s*=|export\\s+(?:default|function|const)\\b|=>|function\\s+[A-Z_a-z]\\w*\\s*\\()/\n\n/** The end of a paste too long to read whole, where its closing markup still is. */\nconst STRUCTURE_TAIL = 4096\n\n/** The kind of code a trimmed text draws, or null when it draws no element. */\nfunction looksLikeCode(trimmed: string, tail: string): PasteCodeKind | null {\n if (!ELEMENT.test(trimmed)) return null\n if (\n !CLOSING.test(trimmed) &&\n !SELF_CLOSING.test(trimmed) &&\n !FRAGMENT.test(trimmed) &&\n !CLOSING.test(tail)\n ) {\n return null\n }\n if (!trimmed.startsWith('<')) {\n // Markup with code around it is a component; anything else without a return is markup.\n if (!/\\breturn\\b|\\bimport\\b|\\bexport\\b/.test(trimmed)) return null\n return 'jsx'\n }\n return JSX_SOURCE.test(trimmed) ? 'jsx' : 'html'\n}\n\n/**\n * What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is\n * markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it\n * draws no element, so ordinary text keeps pasting as text.\n */\nexport function detectCode(text: string): CodeDetection | null {\n // A paste past the size a paste reads is only scanned up to that size, so its length bounds work;\n // the tail still decides whether markup is closed, since the cut can land inside an element.\n const tooLarge = text.length > MAX_CODE_LENGTH\n const limited = tooLarge ? text.slice(0, MAX_CODE_LENGTH) : text\n const trimmed = limited.trim()\n const tail = tooLarge ? text.slice(-STRUCTURE_TAIL) : ''\n const kind = trimmed.length > 0 ? looksLikeCode(trimmed, tail) : null\n if (!kind) return null\n return tooLarge ? CODE_TOO_LARGE : kind\n}\n\n/**\n * The code a pasted text holds, or null when it is not code or is past the size a paste reads;\n * `detectCode` says which of the two refused it.\n */\nexport function detectCodeText(text: string): PasteCodeKind | null {\n const detection = detectCode(text)\n return detection === CODE_TOO_LARGE ? null : detection\n}\n"],"mappings":";;AACA,MAAa,kBAAkB;;AAM/B,MAAa,iBAAiB;AAK9B,MAAM,UAAU;AAChB,MAAM,UAAU;AAChB,MAAM,eAAe;AACrB,MAAM,WAAW;;AAEjB,MAAM,aACJ;;AAMF,SAAS,cAAc,SAAiB,MAAoC;CAC1E,IAAI,CAAC,QAAQ,KAAK,OAAO,GAAG,OAAO;CACnC,IACE,CAAC,QAAQ,KAAK,OAAO,KACrB,CAAC,aAAa,KAAK,OAAO,KAC1B,CAAC,SAAS,KAAK,OAAO,KACtB,CAAC,QAAQ,KAAK,IAAI,GAElB,OAAO;CAET,IAAI,CAAC,QAAQ,WAAW,GAAG,GAAG;EAE5B,IAAI,CAAC,mCAAmC,KAAK,OAAO,GAAG,OAAO;EAC9D,OAAO;CACT;CACA,OAAO,WAAW,KAAK,OAAO,IAAI,QAAQ;AAC5C;;;;;;AAOA,SAAgB,WAAW,MAAoC;CAG7D,MAAM,WAAW,KAAK,SAAS;CAE/B,MAAM,WADU,WAAW,KAAK,MAAM,GAAG,eAAe,IAAI,KAAA,CACpC,KAAK;CAC7B,MAAM,OAAO,WAAW,KAAK,MAAM,KAAe,IAAI;CACtD,MAAM,OAAO,QAAQ,SAAS,IAAI,cAAc,SAAS,IAAI,IAAI;CACjE,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,WAAW,iBAAiB;AACrC;;;;;AAMA,SAAgB,eAAe,MAAoC;CACjE,MAAM,YAAY,WAAW,IAAI;CACjC,OAAO,cAAA,cAA+B,OAAO;AAC/C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CODE_TOO_LARGE, CodeDetection, MAX_CODE_LENGTH, PasteCodeKind, detectCode, detectCodeText } from "./detect.js";
|
|
2
|
+
import { CodeStylesheet, codeStylesheet } from "./stylesheet.js";
|
|
3
|
+
import { ReadCodeOptions, ReadCodeReport, ReadCodeResult, codeLayerCount, readCodeDocument } from "./read.js";
|
|
4
|
+
import { TokenBindingReport, bindCodeTokens, codeLayerNodes } from "./tokens.js";
|
|
5
|
+
export { CODE_TOO_LARGE, type CodeDetection, type CodeStylesheet, MAX_CODE_LENGTH, type PasteCodeKind, type ReadCodeOptions, type ReadCodeReport, type ReadCodeResult, type TokenBindingReport, bindCodeTokens, codeLayerCount, codeLayerNodes, codeStylesheet, detectCode, detectCodeText, readCodeDocument };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, detectCodeText } from "./detect.js";
|
|
2
|
+
import { codeStylesheet } from "./stylesheet.js";
|
|
3
|
+
import { codeLayerCount, readCodeDocument } from "./read.js";
|
|
4
|
+
import { bindCodeTokens, codeLayerNodes } from "./tokens.js";
|
|
5
|
+
export { CODE_TOO_LARGE, MAX_CODE_LENGTH, bindCodeTokens, codeLayerCount, codeLayerNodes, codeStylesheet, detectCode, detectCodeText, readCodeDocument };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PasteCodeKind } from "./detect.js";
|
|
2
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
3
|
+
import { CSSRuntime, CodeReport } from "@pairdraw/dom-css";
|
|
4
|
+
//#region src/io/formats/code/read.d.ts
|
|
5
|
+
/** What a paste could not keep, counted for the toast, plus what only the paste knows. */
|
|
6
|
+
interface ReadCodeReport extends CodeReport {
|
|
7
|
+
/** Top-level layers the paste drew. */
|
|
8
|
+
layers: number;
|
|
9
|
+
/** Variant-prefixed utilities left out, such as `md:flex-row`'s `md:`. */
|
|
10
|
+
variantsStripped: number;
|
|
11
|
+
/** Colour and number properties bound to the target document's variables. */
|
|
12
|
+
tokensBound: number;
|
|
13
|
+
/** Values two variables share, which a paste binds nothing to. */
|
|
14
|
+
tokensAmbiguous: number;
|
|
15
|
+
}
|
|
16
|
+
interface ReadCodeOptions {
|
|
17
|
+
/** The paste's own CSS: a `globals.css` or a `<style>` block it came with. */
|
|
18
|
+
css?: string;
|
|
19
|
+
/** The target document's tokens as a stylesheet, so `bg-primary` resolves before binding. */
|
|
20
|
+
tokensCSS?: string;
|
|
21
|
+
/** The CSS runtime a host supplies; the headless one by default. */
|
|
22
|
+
runtime?: CSSRuntime;
|
|
23
|
+
pageName?: string;
|
|
24
|
+
/** The language the caller names, instead of what detection reads. */
|
|
25
|
+
kind?: PasteCodeKind;
|
|
26
|
+
/** Whether Tailwind utilities compile; false reads only inline styles and the paste's CSS. */
|
|
27
|
+
tailwind?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface ReadCodeResult {
|
|
30
|
+
graph: SceneGraph;
|
|
31
|
+
report: ReadCodeReport;
|
|
32
|
+
kind: PasteCodeKind;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The layers a pasted JSX, TSX, or HTML source draws, styled as a browser would style it with its
|
|
36
|
+
* own CSS and the Tailwind classes it names. Nothing in the source runs. Token binding needs the
|
|
37
|
+
* target document and happens in `bindCodeTokens`. Source past the size a paste reads is refused
|
|
38
|
+
* before it is parsed.
|
|
39
|
+
*/
|
|
40
|
+
declare function readCodeDocument(code: string, options?: ReadCodeOptions): Promise<ReadCodeResult>;
|
|
41
|
+
/** Every layer the paste drew, without the document node or its pages. */
|
|
42
|
+
declare function codeLayerCount(graph: SceneGraph): number;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { ReadCodeOptions, ReadCodeReport, ReadCodeResult, codeLayerCount, readCodeDocument };
|
|
45
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","names":[],"sources":["../../../../src/io/formats/code/read.ts"],"mappings":";;;;;UAoBiB,uBAAuB;;EAEtC;;EAEA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA;;EAEA,UAAU;EACV;;EAEA,OAAO;;EAEP;;UAGe;EACf,OAAO;EACP,QAAQ;EACR,MAAM;;;;;;;;iBASc,iBACpB,cACA,UAAS,kBACR,QAAQ;;iBA0EK,eAAe,OAAO"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { MAX_CODE_LENGTH, detectCode } from "./detect.js";
|
|
2
|
+
import { codeStylesheet } from "./stylesheet.js";
|
|
3
|
+
import { htmlClassNames, htmlElementCount } from "../html/layers.js";
|
|
4
|
+
import { CodeTooLargeError, MAX_CODE_ELEMENTS, createHeadlessCSSRuntime, jsxSourceToTree, tailwindCandidates, tailwindHTMLToSceneGraph, tailwindJSXToSceneGraph, tailwindUtilities } from "@pairdraw/dom-css";
|
|
5
|
+
//#region src/io/formats/code/read.ts
|
|
6
|
+
/**
|
|
7
|
+
* The layers a pasted JSX, TSX, or HTML source draws, styled as a browser would style it with its
|
|
8
|
+
* own CSS and the Tailwind classes it names. Nothing in the source runs. Token binding needs the
|
|
9
|
+
* target document and happens in `bindCodeTokens`. Source past the size a paste reads is refused
|
|
10
|
+
* before it is parsed.
|
|
11
|
+
*/
|
|
12
|
+
async function readCodeDocument(code, options = {}) {
|
|
13
|
+
const detection = detectCode(code);
|
|
14
|
+
if (detection === "too-large") throw new CodeTooLargeError(`The paste is longer than ${MAX_CODE_LENGTH} characters; paste a smaller part of it.`);
|
|
15
|
+
const kind = options.kind ?? detection;
|
|
16
|
+
if (!kind) throw new Error("This text does not draw a layout: paste JSX, TSX, or HTML markup.");
|
|
17
|
+
if (kind === "html" && htmlElementCount(code) > MAX_CODE_ELEMENTS) throw new CodeTooLargeError(`The paste draws more than ${MAX_CODE_ELEMENTS} layers; paste a smaller part of it.`);
|
|
18
|
+
const stylesheet = codeStylesheet([options.tokensCSS, options.css]);
|
|
19
|
+
const runtime = options.runtime ?? createHeadlessCSSRuntime();
|
|
20
|
+
const { graph, report } = await (kind === "jsx" ? jsxLayers : htmlLayers)(code, {
|
|
21
|
+
...options,
|
|
22
|
+
runtime,
|
|
23
|
+
css: stylesheet.css,
|
|
24
|
+
tailwind: options.tailwind !== false
|
|
25
|
+
});
|
|
26
|
+
report.layers = codeLayerCount(graph);
|
|
27
|
+
report.approximations += stylesheet.importsDropped;
|
|
28
|
+
return {
|
|
29
|
+
graph,
|
|
30
|
+
report,
|
|
31
|
+
kind
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function jsxLayers(code, source) {
|
|
35
|
+
const { children, report } = jsxSourceToTree(code);
|
|
36
|
+
const { candidates, variantsStripped } = source.tailwind ? tailwindCandidates(children) : {
|
|
37
|
+
candidates: [],
|
|
38
|
+
variantsStripped: 0
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
graph: await tailwindJSXToSceneGraph(children, candidates, {
|
|
42
|
+
runtime: source.runtime,
|
|
43
|
+
css: source.css,
|
|
44
|
+
pageName: source.pageName
|
|
45
|
+
}),
|
|
46
|
+
report: withCounts(report, variantsStripped)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function htmlLayers(code, source) {
|
|
50
|
+
const { candidates, variantsStripped } = source.tailwind ? tailwindUtilities(htmlClassNames(code)) : {
|
|
51
|
+
candidates: [],
|
|
52
|
+
variantsStripped: 0
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
graph: await tailwindHTMLToSceneGraph(code, candidates, {
|
|
56
|
+
runtime: source.runtime,
|
|
57
|
+
css: source.css,
|
|
58
|
+
pageName: source.pageName
|
|
59
|
+
}),
|
|
60
|
+
report: withCounts({
|
|
61
|
+
placeholders: 0,
|
|
62
|
+
componentsAsFrames: 0,
|
|
63
|
+
droppedProps: 0,
|
|
64
|
+
approximations: 0,
|
|
65
|
+
imagesAsPlaceholders: 0
|
|
66
|
+
}, variantsStripped)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Every layer the paste drew, without the document node or its pages. */
|
|
70
|
+
function codeLayerCount(graph) {
|
|
71
|
+
const pages = new Set(graph.getPages().map((page) => page.id));
|
|
72
|
+
return [...graph.getAllNodes()].filter((node) => node.id !== graph.rootId && !pages.has(node.id)).length;
|
|
73
|
+
}
|
|
74
|
+
function withCounts(report, variantsStripped) {
|
|
75
|
+
return {
|
|
76
|
+
...report,
|
|
77
|
+
layers: 0,
|
|
78
|
+
variantsStripped,
|
|
79
|
+
tokensBound: 0,
|
|
80
|
+
tokensAmbiguous: 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { codeLayerCount, readCodeDocument };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","names":[],"sources":["../../../../src/io/formats/code/read.ts"],"sourcesContent":["import {\n CodeTooLargeError,\n MAX_CODE_ELEMENTS,\n createHeadlessCSSRuntime,\n jsxSourceToTree,\n tailwindCandidates,\n tailwindHTMLToSceneGraph,\n tailwindJSXToSceneGraph,\n tailwindUtilities,\n type CodeReport,\n type CSSRuntime\n} from '@pairdraw/dom-css'\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { htmlClassNames, htmlElementCount } from '#core/io/formats/html/layers'\n\nimport { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, type PasteCodeKind } from './detect'\nimport { codeStylesheet } from './stylesheet'\n\n/** What a paste could not keep, counted for the toast, plus what only the paste knows. */\nexport interface ReadCodeReport extends CodeReport {\n /** Top-level layers the paste drew. */\n layers: number\n /** Variant-prefixed utilities left out, such as `md:flex-row`'s `md:`. */\n variantsStripped: number\n /** Colour and number properties bound to the target document's variables. */\n tokensBound: number\n /** Values two variables share, which a paste binds nothing to. */\n tokensAmbiguous: number\n}\n\nexport interface ReadCodeOptions {\n /** The paste's own CSS: a `globals.css` or a `<style>` block it came with. */\n css?: string\n /** The target document's tokens as a stylesheet, so `bg-primary` resolves before binding. */\n tokensCSS?: string\n /** The CSS runtime a host supplies; the headless one by default. */\n runtime?: CSSRuntime\n pageName?: string\n /** The language the caller names, instead of what detection reads. */\n kind?: PasteCodeKind\n /** Whether Tailwind utilities compile; false reads only inline styles and the paste's CSS. */\n tailwind?: boolean\n}\n\nexport interface ReadCodeResult {\n graph: SceneGraph\n report: ReadCodeReport\n kind: PasteCodeKind\n}\n\n/**\n * The layers a pasted JSX, TSX, or HTML source draws, styled as a browser would style it with its\n * own CSS and the Tailwind classes it names. Nothing in the source runs. Token binding needs the\n * target document and happens in `bindCodeTokens`. Source past the size a paste reads is refused\n * before it is parsed.\n */\nexport async function readCodeDocument(\n code: string,\n options: ReadCodeOptions = {}\n): Promise<ReadCodeResult> {\n const detection = detectCode(code)\n if (detection === CODE_TOO_LARGE) {\n throw new CodeTooLargeError(\n `The paste is longer than ${MAX_CODE_LENGTH} characters; paste a smaller part of it.`\n )\n }\n const kind = options.kind ?? detection\n if (!kind) throw new Error('This text does not draw a layout: paste JSX, TSX, or HTML markup.')\n if (kind === 'html' && htmlElementCount(code) > MAX_CODE_ELEMENTS) {\n throw new CodeTooLargeError(\n `The paste draws more than ${MAX_CODE_ELEMENTS} layers; paste a smaller part of it.`\n )\n }\n const stylesheet = codeStylesheet([options.tokensCSS, options.css])\n const runtime = options.runtime ?? createHeadlessCSSRuntime()\n const build = kind === 'jsx' ? jsxLayers : htmlLayers\n const { graph, report } = await build(code, {\n ...options,\n runtime,\n css: stylesheet.css,\n tailwind: options.tailwind !== false\n })\n report.layers = codeLayerCount(graph)\n report.approximations += stylesheet.importsDropped\n return { graph, report, kind }\n}\n\ninterface StyleSource {\n runtime: CSSRuntime\n css: string\n pageName?: string\n tailwind: boolean\n}\n\nasync function jsxLayers(\n code: string,\n source: StyleSource\n): Promise<{ graph: SceneGraph; report: ReadCodeReport }> {\n const { children, report } = jsxSourceToTree(code)\n const { candidates, variantsStripped } = source.tailwind\n ? tailwindCandidates(children)\n : { candidates: [], variantsStripped: 0 }\n const graph = await tailwindJSXToSceneGraph(children, candidates, {\n runtime: source.runtime,\n css: source.css,\n pageName: source.pageName\n })\n return { graph, report: withCounts(report, variantsStripped) }\n}\n\nasync function htmlLayers(\n code: string,\n source: StyleSource\n): Promise<{ graph: SceneGraph; report: ReadCodeReport }> {\n const { candidates, variantsStripped } = source.tailwind\n ? tailwindUtilities(htmlClassNames(code))\n : { candidates: [], variantsStripped: 0 }\n const graph = await tailwindHTMLToSceneGraph(code, candidates, {\n runtime: source.runtime,\n css: source.css,\n pageName: source.pageName\n })\n const report: CodeReport = {\n placeholders: 0,\n componentsAsFrames: 0,\n droppedProps: 0,\n approximations: 0,\n imagesAsPlaceholders: 0\n }\n return { graph, report: withCounts(report, variantsStripped) }\n}\n\n/** Every layer the paste drew, without the document node or its pages. */\nexport function codeLayerCount(graph: SceneGraph): number {\n const pages = new Set(graph.getPages().map((page) => page.id))\n return [...graph.getAllNodes()].filter((node) => node.id !== graph.rootId && !pages.has(node.id))\n .length\n}\n\nfunction withCounts(report: CodeReport, variantsStripped: number): ReadCodeReport {\n return { ...report, layers: 0, variantsStripped, tokensBound: 0, tokensAmbiguous: 0 }\n}\n"],"mappings":";;;;;;;;;;;AAyDA,eAAsB,iBACpB,MACA,UAA2B,CAAC,GACH;CACzB,MAAM,YAAY,WAAW,IAAI;CACjC,IAAI,cAAA,aACF,MAAM,IAAI,kBACR,4BAA4B,gBAAgB,yCAC9C;CAEF,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,mEAAmE;CAC9F,IAAI,SAAS,UAAU,iBAAiB,IAAI,IAAI,mBAC9C,MAAM,IAAI,kBACR,6BAA6B,kBAAkB,qCACjD;CAEF,MAAM,aAAa,eAAe,CAAC,QAAQ,WAAW,QAAQ,GAAG,CAAC;CAClE,MAAM,UAAU,QAAQ,WAAW,yBAAyB;CAE5D,MAAM,EAAE,OAAO,WAAW,OADZ,SAAS,QAAQ,YAAY,WAAA,CACL,MAAM;EAC1C,GAAG;EACH;EACA,KAAK,WAAW;EAChB,UAAU,QAAQ,aAAa;CACjC,CAAC;CACD,OAAO,SAAS,eAAe,KAAK;CACpC,OAAO,kBAAkB,WAAW;CACpC,OAAO;EAAE;EAAO;EAAQ;CAAK;AAC/B;AASA,eAAe,UACb,MACA,QACwD;CACxD,MAAM,EAAE,UAAU,WAAW,gBAAgB,IAAI;CACjD,MAAM,EAAE,YAAY,qBAAqB,OAAO,WAC5C,mBAAmB,QAAQ,IAC3B;EAAE,YAAY,CAAC;EAAG,kBAAkB;CAAE;CAM1C,OAAO;EAAE,OAAA,MALW,wBAAwB,UAAU,YAAY;GAChE,SAAS,OAAO;GAChB,KAAK,OAAO;GACZ,UAAU,OAAO;EACnB,CAAC;EACe,QAAQ,WAAW,QAAQ,gBAAgB;CAAE;AAC/D;AAEA,eAAe,WACb,MACA,QACwD;CACxD,MAAM,EAAE,YAAY,qBAAqB,OAAO,WAC5C,kBAAkB,eAAe,IAAI,CAAC,IACtC;EAAE,YAAY,CAAC;EAAG,kBAAkB;CAAE;CAa1C,OAAO;EAAE,OAAA,MAZW,yBAAyB,MAAM,YAAY;GAC7D,SAAS,OAAO;GAChB,KAAK,OAAO;GACZ,UAAU,OAAO;EACnB,CAAC;EAQe,QAAQ,WAAW;GANjC,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,gBAAgB;GAChB,sBAAsB;EAEgB,GAAG,gBAAgB;CAAE;AAC/D;;AAGA,SAAgB,eAAe,OAA2B;CACxD,MAAM,QAAQ,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,CAAC;CAC7D,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,CAAC,QAAQ,SAAS,KAAK,OAAO,MAAM,UAAU,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAC9F;AACL;AAEA,SAAS,WAAW,QAAoB,kBAA0C;CAChF,OAAO;EAAE,GAAG;EAAQ,QAAQ;EAAG;EAAkB,aAAa;EAAG,iBAAiB;CAAE;AACtF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/io/formats/code/stylesheet.d.ts
|
|
2
|
+
interface CodeStylesheet {
|
|
3
|
+
css: string;
|
|
4
|
+
importsDropped: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The stylesheet a paste styles with: the document's tokens first, then the paste's own CSS, with
|
|
8
|
+
* `@import` rules left out because they name files the paste does not bring with it.
|
|
9
|
+
*/
|
|
10
|
+
declare function codeStylesheet(parts: Array<string | undefined>): CodeStylesheet;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { CodeStylesheet, codeStylesheet };
|
|
13
|
+
//# sourceMappingURL=stylesheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet.d.ts","names":[],"sources":["../../../../src/io/formats/code/stylesheet.ts"],"mappings":";UAGiB;EACf;EACA;;;;;;iBAOc,eAAe,OAAO,4BAA4B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/io/formats/code/stylesheet.ts
|
|
2
|
+
/** The declarations a stylesheet keeps: one import names a file the paste does not carry. */
|
|
3
|
+
const IMPORT = /^\s*@import\b.*$/gm;
|
|
4
|
+
/**
|
|
5
|
+
* The stylesheet a paste styles with: the document's tokens first, then the paste's own CSS, with
|
|
6
|
+
* `@import` rules left out because they name files the paste does not bring with it.
|
|
7
|
+
*/
|
|
8
|
+
function codeStylesheet(parts) {
|
|
9
|
+
let importsDropped = 0;
|
|
10
|
+
return {
|
|
11
|
+
css: parts.filter((part) => Boolean(part?.trim())).map((part) => part.replace(IMPORT, () => {
|
|
12
|
+
importsDropped += 1;
|
|
13
|
+
return "";
|
|
14
|
+
})).join("\n"),
|
|
15
|
+
importsDropped
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { codeStylesheet };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=stylesheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet.js","names":[],"sources":["../../../../src/io/formats/code/stylesheet.ts"],"sourcesContent":["/** The declarations a stylesheet keeps: one import names a file the paste does not carry. */\nconst IMPORT = /^\\s*@import\\b.*$/gm\n\nexport interface CodeStylesheet {\n css: string\n importsDropped: number\n}\n\n/**\n * The stylesheet a paste styles with: the document's tokens first, then the paste's own CSS, with\n * `@import` rules left out because they name files the paste does not bring with it.\n */\nexport function codeStylesheet(parts: Array<string | undefined>): CodeStylesheet {\n let importsDropped = 0\n const kept = parts\n .filter((part): part is string => Boolean(part?.trim()))\n .map((part) =>\n part.replace(IMPORT, () => {\n importsDropped += 1\n return ''\n })\n )\n return { css: kept.join('\\n'), importsDropped }\n}\n"],"mappings":";;AACA,MAAM,SAAS;;;;;AAWf,SAAgB,eAAe,OAAkD;CAC/E,IAAI,iBAAiB;CASrB,OAAO;EAAE,KARI,MACV,QAAQ,SAAyB,QAAQ,MAAM,KAAK,CAAC,CAAC,CAAC,CACvD,KAAK,SACJ,KAAK,QAAQ,cAAc;GACzB,kBAAkB;GAClB,OAAO;EACT,CAAC,CAEY,CAAC,CAAC,KAAK,IAAI;EAAG;CAAe;AAChD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/io/formats/code/tokens.d.ts
|
|
3
|
+
interface TokenBindingReport {
|
|
4
|
+
tokensBound: number;
|
|
5
|
+
tokensAmbiguous: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Binds a pasted layer's colours and numbers to the target document's variables, one property at
|
|
9
|
+
* a time, only when exactly one variable of the matching namespace holds that exact value. A value
|
|
10
|
+
* two variables share binds nothing: guessing would change the design. The layers are the inserted
|
|
11
|
+
* ones, so a binding names a variable the document already has.
|
|
12
|
+
*/
|
|
13
|
+
declare function bindCodeTokens(nodes: Iterable<SceneNode>, target: SceneGraph, report: TokenBindingReport): void;
|
|
14
|
+
/** Every layer a paste created, from its roots down, as a transfer inserted them. */
|
|
15
|
+
declare function codeLayerNodes(graph: SceneGraph, rootIds: readonly string[]): SceneNode[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { TokenBindingReport, bindCodeTokens, codeLayerNodes };
|
|
18
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","names":[],"sources":["../../../../src/io/formats/code/tokens.ts"],"mappings":";;UA8BiB;EACf;EACA;;;;;;;;iBASc,eACd,OAAO,SAAS,YAChB,QAAQ,YACR,QAAQ;;iBAQM,eAAe,OAAO,YAAY,6BAA6B"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { variableValueInMode } from "@pairdraw/scene-graph/variables";
|
|
2
|
+
//#region src/io/formats/code/tokens.ts
|
|
3
|
+
/** The namespaces a layer property can take, in the vocabulary its tokens are named in. */
|
|
4
|
+
const PROPERTY_NAMESPACES = {
|
|
5
|
+
cornerRadius: "radius",
|
|
6
|
+
topLeftRadius: "radius",
|
|
7
|
+
topRightRadius: "radius",
|
|
8
|
+
bottomLeftRadius: "radius",
|
|
9
|
+
bottomRightRadius: "radius",
|
|
10
|
+
fontSize: "text",
|
|
11
|
+
lineHeight: "leading",
|
|
12
|
+
letterSpacing: "tracking",
|
|
13
|
+
itemSpacing: "spacing",
|
|
14
|
+
counterAxisSpacing: "spacing",
|
|
15
|
+
gridColumnGap: "spacing",
|
|
16
|
+
gridRowGap: "spacing",
|
|
17
|
+
paddingLeft: "spacing",
|
|
18
|
+
paddingRight: "spacing",
|
|
19
|
+
paddingTop: "spacing",
|
|
20
|
+
paddingBottom: "spacing"
|
|
21
|
+
};
|
|
22
|
+
/** The numeric properties a pasted layer binds to a matching variable. */
|
|
23
|
+
const BOUND_NUMERIC_FIELDS = Object.keys(PROPERTY_NAMESPACES);
|
|
24
|
+
/**
|
|
25
|
+
* Binds a pasted layer's colours and numbers to the target document's variables, one property at
|
|
26
|
+
* a time, only when exactly one variable of the matching namespace holds that exact value. A value
|
|
27
|
+
* two variables share binds nothing: guessing would change the design. The layers are the inserted
|
|
28
|
+
* ones, so a binding names a variable the document already has.
|
|
29
|
+
*/
|
|
30
|
+
function bindCodeTokens(nodes, target, report) {
|
|
31
|
+
const index = variableIndex(target);
|
|
32
|
+
if (index.size === 0) return;
|
|
33
|
+
for (const node of nodes) bindNode(node, index, report);
|
|
34
|
+
}
|
|
35
|
+
/** Every layer a paste created, from its roots down, as a transfer inserted them. */
|
|
36
|
+
function codeLayerNodes(graph, rootIds) {
|
|
37
|
+
const nodes = [];
|
|
38
|
+
const visit = (id) => {
|
|
39
|
+
const node = graph.getNode(id);
|
|
40
|
+
if (!node) return;
|
|
41
|
+
nodes.push(node);
|
|
42
|
+
for (const child of node.childIds) visit(child);
|
|
43
|
+
};
|
|
44
|
+
for (const id of rootIds) visit(id);
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
function variableIndex(target) {
|
|
48
|
+
const index = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const variable of target.variables.values()) {
|
|
50
|
+
if (variable.deleted) continue;
|
|
51
|
+
const namespace = namespaceOf(variable);
|
|
52
|
+
if (!namespace) continue;
|
|
53
|
+
const key = indexKey(namespace, variableValueInMode(target, variable, defaultModeOf(target, variable)));
|
|
54
|
+
if (!key) continue;
|
|
55
|
+
const found = index.get(key);
|
|
56
|
+
if (found) found.push(variable);
|
|
57
|
+
else index.set(key, [variable]);
|
|
58
|
+
}
|
|
59
|
+
return index;
|
|
60
|
+
}
|
|
61
|
+
function defaultModeOf(target, variable) {
|
|
62
|
+
return target.variableCollections.get(variable.collectionId)?.defaultModeId ?? "";
|
|
63
|
+
}
|
|
64
|
+
/** The namespace a variable's scopes name, or none when it names something a layer cannot take. */
|
|
65
|
+
function namespaceOf(variable) {
|
|
66
|
+
if (variable.type === "COLOR") return "color";
|
|
67
|
+
if (variable.type !== "FLOAT") return null;
|
|
68
|
+
for (const scope of variable.scopes ?? []) {
|
|
69
|
+
if (scope === "CORNER_RADIUS") return "radius";
|
|
70
|
+
if (scope === "GAP" || scope === "WIDTH_HEIGHT") return "spacing";
|
|
71
|
+
if (scope === "FONT_SIZE") return "text";
|
|
72
|
+
if (scope === "LINE_HEIGHT") return "leading";
|
|
73
|
+
if (scope === "LETTER_SPACING") return "tracking";
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function indexKey(namespace, value) {
|
|
78
|
+
if (typeof value === "number") return `${namespace}:${value.toFixed(3)}`;
|
|
79
|
+
if (!isColor(value)) return null;
|
|
80
|
+
return `${namespace}:${colorKey(value)}`;
|
|
81
|
+
}
|
|
82
|
+
function isColor(value) {
|
|
83
|
+
return typeof value === "object" && value !== null && "r" in value && "g" in value && "b" in value;
|
|
84
|
+
}
|
|
85
|
+
function colorKey(color) {
|
|
86
|
+
return [
|
|
87
|
+
color.r,
|
|
88
|
+
color.g,
|
|
89
|
+
color.b,
|
|
90
|
+
color.a
|
|
91
|
+
].map((channel) => channel.toFixed(4)).join(",");
|
|
92
|
+
}
|
|
93
|
+
function bindNode(node, index, report) {
|
|
94
|
+
bindPaints(node, "fills", index, report);
|
|
95
|
+
bindPaints(node, "strokes", index, report);
|
|
96
|
+
for (const field of BOUND_NUMERIC_FIELDS) {
|
|
97
|
+
const value = node[field];
|
|
98
|
+
if (typeof value !== "number" || value === 0) continue;
|
|
99
|
+
const namespace = PROPERTY_NAMESPACES[field];
|
|
100
|
+
if (!namespace) continue;
|
|
101
|
+
bindField(node, field, indexKey(namespace, value), index, report);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function bindPaints(node, list, index, report) {
|
|
105
|
+
node[list].forEach((paint, paintIndex) => {
|
|
106
|
+
if (paint.type !== "SOLID") return;
|
|
107
|
+
const { r, g, b, a } = paint.color;
|
|
108
|
+
bindField(node, `${list}/${paintIndex}/color`, indexKey("color", {
|
|
109
|
+
r,
|
|
110
|
+
g,
|
|
111
|
+
b,
|
|
112
|
+
a
|
|
113
|
+
}), index, report);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function bindField(node, field, key, index, report) {
|
|
117
|
+
if (!key || node.boundVariables[field]) return;
|
|
118
|
+
const candidates = index.get(key);
|
|
119
|
+
if (!candidates || candidates.length === 0) return;
|
|
120
|
+
if (candidates.length > 1) {
|
|
121
|
+
report.tokensAmbiguous += 1;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const variable = candidates.at(0);
|
|
125
|
+
if (!variable) return;
|
|
126
|
+
node.boundVariables = {
|
|
127
|
+
...node.boundVariables,
|
|
128
|
+
[field]: variable.id
|
|
129
|
+
};
|
|
130
|
+
report.tokensBound += 1;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { bindCodeTokens, codeLayerNodes };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","names":[],"sources":["../../../../src/io/formats/code/tokens.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable, VariableValue } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\nimport { variableValueInMode } from '@pairdraw/scene-graph/variables'\n\n/** Tailwind namespace a document variable belongs to, which decides what it may bind. */\ntype TokenNamespace = 'color' | 'radius' | 'spacing' | 'text' | 'leading' | 'tracking'\n\n/** The namespaces a layer property can take, in the vocabulary its tokens are named in. */\nconst PROPERTY_NAMESPACES: Partial<Record<string, TokenNamespace>> = {\n cornerRadius: 'radius',\n topLeftRadius: 'radius',\n topRightRadius: 'radius',\n bottomLeftRadius: 'radius',\n bottomRightRadius: 'radius',\n fontSize: 'text',\n lineHeight: 'leading',\n letterSpacing: 'tracking',\n itemSpacing: 'spacing',\n counterAxisSpacing: 'spacing',\n gridColumnGap: 'spacing',\n gridRowGap: 'spacing',\n paddingLeft: 'spacing',\n paddingRight: 'spacing',\n paddingTop: 'spacing',\n paddingBottom: 'spacing'\n}\n\n/** The numeric properties a pasted layer binds to a matching variable. */\nconst BOUND_NUMERIC_FIELDS = Object.keys(PROPERTY_NAMESPACES)\n\nexport interface TokenBindingReport {\n tokensBound: number\n tokensAmbiguous: number\n}\n\n/**\n * Binds a pasted layer's colours and numbers to the target document's variables, one property at\n * a time, only when exactly one variable of the matching namespace holds that exact value. A value\n * two variables share binds nothing: guessing would change the design. The layers are the inserted\n * ones, so a binding names a variable the document already has.\n */\nexport function bindCodeTokens(\n nodes: Iterable<SceneNode>,\n target: SceneGraph,\n report: TokenBindingReport\n): void {\n const index = variableIndex(target)\n if (index.size === 0) return\n for (const node of nodes) bindNode(node, index, report)\n}\n\n/** Every layer a paste created, from its roots down, as a transfer inserted them. */\nexport function codeLayerNodes(graph: SceneGraph, rootIds: readonly string[]): SceneNode[] {\n const nodes: SceneNode[] = []\n const visit = (id: string): void => {\n const node = graph.getNode(id)\n if (!node) return\n nodes.push(node)\n for (const child of node.childIds) visit(child)\n }\n for (const id of rootIds) visit(id)\n return nodes\n}\n\ntype ValueIndex = Map<string, Variable[]>\n\nfunction variableIndex(target: SceneGraph): ValueIndex {\n const index: ValueIndex = new Map()\n for (const variable of target.variables.values()) {\n if (variable.deleted) continue\n const namespace = namespaceOf(variable)\n if (!namespace) continue\n const value = variableValueInMode(target, variable, defaultModeOf(target, variable))\n const key = indexKey(namespace, value)\n if (!key) continue\n const found = index.get(key)\n if (found) found.push(variable)\n else index.set(key, [variable])\n }\n return index\n}\n\nfunction defaultModeOf(target: SceneGraph, variable: Variable): string {\n return target.variableCollections.get(variable.collectionId)?.defaultModeId ?? ''\n}\n\n/** The namespace a variable's scopes name, or none when it names something a layer cannot take. */\nfunction namespaceOf(variable: Variable): TokenNamespace | null {\n if (variable.type === 'COLOR') return 'color'\n if (variable.type !== 'FLOAT') return null\n for (const scope of variable.scopes ?? []) {\n if (scope === 'CORNER_RADIUS') return 'radius'\n if (scope === 'GAP' || scope === 'WIDTH_HEIGHT') return 'spacing'\n if (scope === 'FONT_SIZE') return 'text'\n if (scope === 'LINE_HEIGHT') return 'leading'\n if (scope === 'LETTER_SPACING') return 'tracking'\n }\n return null\n}\n\nfunction indexKey(namespace: TokenNamespace, value: VariableValue | undefined): string | null {\n if (typeof value === 'number') return `${namespace}:${value.toFixed(3)}`\n if (!isColor(value)) return null\n return `${namespace}:${colorKey(value)}`\n}\n\nfunction isColor(value: unknown): value is Color {\n return typeof value === 'object' && value !== null && 'r' in value && 'g' in value && 'b' in value\n}\n\nfunction colorKey(color: Color): string {\n return [color.r, color.g, color.b, color.a].map((channel) => channel.toFixed(4)).join(',')\n}\n\nfunction bindNode(node: SceneNode, index: ValueIndex, report: TokenBindingReport): void {\n bindPaints(node, 'fills', index, report)\n bindPaints(node, 'strokes', index, report)\n for (const field of BOUND_NUMERIC_FIELDS) {\n const value = node[field as keyof SceneNode]\n if (typeof value !== 'number' || value === 0) continue\n const namespace = PROPERTY_NAMESPACES[field]\n if (!namespace) continue\n bindField(node, field, indexKey(namespace, value), index, report)\n }\n}\n\nfunction bindPaints(\n node: SceneNode,\n list: 'fills' | 'strokes',\n index: ValueIndex,\n report: TokenBindingReport\n): void {\n const paints = node[list]\n paints.forEach((paint, paintIndex) => {\n if (paint.type !== 'SOLID') return\n const { r, g, b, a } = paint.color\n bindField(node, `${list}/${paintIndex}/color`, indexKey('color', { r, g, b, a }), index, report)\n })\n}\n\nfunction bindField(\n node: SceneNode,\n field: string,\n key: string | null,\n index: ValueIndex,\n report: TokenBindingReport\n): void {\n if (!key || node.boundVariables[field]) return\n const candidates = index.get(key)\n if (!candidates || candidates.length === 0) return\n if (candidates.length > 1) {\n report.tokensAmbiguous += 1\n return\n }\n const variable = candidates.at(0)\n if (!variable) return\n node.boundVariables = { ...node.boundVariables, [field]: variable.id }\n report.tokensBound += 1\n}\n"],"mappings":";;;AAQA,MAAM,sBAA+D;CACnE,cAAc;CACd,eAAe;CACf,gBAAgB;CAChB,kBAAkB;CAClB,mBAAmB;CACnB,UAAU;CACV,YAAY;CACZ,eAAe;CACf,aAAa;CACb,oBAAoB;CACpB,eAAe;CACf,YAAY;CACZ,aAAa;CACb,cAAc;CACd,YAAY;CACZ,eAAe;AACjB;;AAGA,MAAM,uBAAuB,OAAO,KAAK,mBAAmB;;;;;;;AAa5D,SAAgB,eACd,OACA,QACA,QACM;CACN,MAAM,QAAQ,cAAc,MAAM;CAClC,IAAI,MAAM,SAAS,GAAG;CACtB,KAAK,MAAM,QAAQ,OAAO,SAAS,MAAM,OAAO,MAAM;AACxD;;AAGA,SAAgB,eAAe,OAAmB,SAAyC;CACzF,MAAM,QAAqB,CAAC;CAC5B,MAAM,SAAS,OAAqB;EAClC,MAAM,OAAO,MAAM,QAAQ,EAAE;EAC7B,IAAI,CAAC,MAAM;EACX,MAAM,KAAK,IAAI;EACf,KAAK,MAAM,SAAS,KAAK,UAAU,MAAM,KAAK;CAChD;CACA,KAAK,MAAM,MAAM,SAAS,MAAM,EAAE;CAClC,OAAO;AACT;AAIA,SAAS,cAAc,QAAgC;CACrD,MAAM,wBAAoB,IAAI,IAAI;CAClC,KAAK,MAAM,YAAY,OAAO,UAAU,OAAO,GAAG;EAChD,IAAI,SAAS,SAAS;EACtB,MAAM,YAAY,YAAY,QAAQ;EACtC,IAAI,CAAC,WAAW;EAEhB,MAAM,MAAM,SAAS,WADP,oBAAoB,QAAQ,UAAU,cAAc,QAAQ,QAAQ,CAC9C,CAAC;EACrC,IAAI,CAAC,KAAK;EACV,MAAM,QAAQ,MAAM,IAAI,GAAG;EAC3B,IAAI,OAAO,MAAM,KAAK,QAAQ;OACzB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC;CAChC;CACA,OAAO;AACT;AAEA,SAAS,cAAc,QAAoB,UAA4B;CACrE,OAAO,OAAO,oBAAoB,IAAI,SAAS,YAAY,CAAC,EAAE,iBAAiB;AACjF;;AAGA,SAAS,YAAY,UAA2C;CAC9D,IAAI,SAAS,SAAS,SAAS,OAAO;CACtC,IAAI,SAAS,SAAS,SAAS,OAAO;CACtC,KAAK,MAAM,SAAS,SAAS,UAAU,CAAC,GAAG;EACzC,IAAI,UAAU,iBAAiB,OAAO;EACtC,IAAI,UAAU,SAAS,UAAU,gBAAgB,OAAO;EACxD,IAAI,UAAU,aAAa,OAAO;EAClC,IAAI,UAAU,eAAe,OAAO;EACpC,IAAI,UAAU,kBAAkB,OAAO;CACzC;CACA,OAAO;AACT;AAEA,SAAS,SAAS,WAA2B,OAAiD;CAC5F,IAAI,OAAO,UAAU,UAAU,OAAO,GAAG,UAAU,GAAG,MAAM,QAAQ,CAAC;CACrE,IAAI,CAAC,QAAQ,KAAK,GAAG,OAAO;CAC5B,OAAO,GAAG,UAAU,GAAG,SAAS,KAAK;AACvC;AAEA,SAAS,QAAQ,OAAgC;CAC/C,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,SAAS,OAAO,SAAS,OAAO;AAC/F;AAEA,SAAS,SAAS,OAAsB;CACtC,OAAO;EAAC,MAAM;EAAG,MAAM;EAAG,MAAM;EAAG,MAAM;CAAC,CAAC,CAAC,KAAK,YAAY,QAAQ,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;AAC3F;AAEA,SAAS,SAAS,MAAiB,OAAmB,QAAkC;CACtF,WAAW,MAAM,SAAS,OAAO,MAAM;CACvC,WAAW,MAAM,WAAW,OAAO,MAAM;CACzC,KAAK,MAAM,SAAS,sBAAsB;EACxC,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,UAAU,YAAY,UAAU,GAAG;EAC9C,MAAM,YAAY,oBAAoB;EACtC,IAAI,CAAC,WAAW;EAChB,UAAU,MAAM,OAAO,SAAS,WAAW,KAAK,GAAG,OAAO,MAAM;CAClE;AACF;AAEA,SAAS,WACP,MACA,MACA,OACA,QACM;CAEN,KADoB,KACd,CAAC,SAAS,OAAO,eAAe;EACpC,IAAI,MAAM,SAAS,SAAS;EAC5B,MAAM,EAAE,GAAG,GAAG,GAAG,MAAM,MAAM;EAC7B,UAAU,MAAM,GAAG,KAAK,GAAG,WAAW,SAAS,SAAS,SAAS;GAAE;GAAG;GAAG;GAAG;EAAE,CAAC,GAAG,OAAO,MAAM;CACjG,CAAC;AACH;AAEA,SAAS,UACP,MACA,OACA,KACA,OACA,QACM;CACN,IAAI,CAAC,OAAO,KAAK,eAAe,QAAQ;CACxC,MAAM,aAAa,MAAM,IAAI,GAAG;CAChC,IAAI,CAAC,cAAc,WAAW,WAAW,GAAG;CAC5C,IAAI,WAAW,SAAS,GAAG;EACzB,OAAO,mBAAmB;EAC1B;CACF;CACA,MAAM,WAAW,WAAW,GAAG,CAAC;CAChC,IAAI,CAAC,UAAU;CACf,KAAK,iBAAiB;EAAE,GAAG,KAAK;GAAiB,QAAQ,SAAS;CAAG;CACrE,OAAO,eAAe;AACxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PlannedStyle } from "./plan/styles.js";
|
|
2
2
|
import { PlannedVariable, TokenImportPlan } from "./plan/index.js";
|
|
3
|
-
import { CodeSyntaxPlatform, SceneGraph, SceneNode, TokenExpression, TokenUnit, Variable, VariableCollection, VariableScope, VariableValue } from "@pairdraw/scene-graph";
|
|
3
|
+
import { CodeSyntaxPlatform, SceneGraph, SceneNode, SharedStyleType, TokenExpression, TokenUnit, Variable, VariableCollection, VariableScope, VariableValue } from "@pairdraw/scene-graph";
|
|
4
4
|
//#region src/io/formats/design-tokens/apply.d.ts
|
|
5
5
|
/** Token fields an import sets; `undefined` clears one. */
|
|
6
6
|
interface ImportedTokenFields {
|
|
@@ -42,8 +42,12 @@ interface TokenImportResult {
|
|
|
42
42
|
*/
|
|
43
43
|
declare function applyTokenImport(target: TokenImportTarget, plan: TokenImportPlan): TokenImportResult;
|
|
44
44
|
/** A style node: hidden from the layer list, found by its style id, as `.fig` styles are. */
|
|
45
|
-
declare function styleNodeProps(style: PlannedStyle,
|
|
46
|
-
|
|
45
|
+
declare function styleNodeProps(style: Pick<PlannedStyle, 'kind'> | {
|
|
46
|
+
kind: SharedStyleType;
|
|
47
|
+
}, fields: Partial<SceneNode>): Partial<SceneNode>;
|
|
48
|
+
declare function styleNodeType(style: Pick<PlannedStyle, 'kind'> | {
|
|
49
|
+
kind: SharedStyleType;
|
|
50
|
+
}): "RECTANGLE" | "TEXT";
|
|
47
51
|
/**
|
|
48
52
|
* Imports straight into a graph, for scripts, tools, and the CLI working on a document without
|
|
49
53
|
* an editor; the layers bound to variables whose values changed are resolved and laid out
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/apply.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"apply.d.ts","names":[],"sources":["../../../../src/io/formats/design-tokens/apply.ts"],"mappings":";;;;;UA0BiB;EACf,OAAO;EACP,SAAS;EACT,aAAa,QAAQ,OAAO;EAC5B;EACA;EACA,cAAc,eAAe;;;;;;UAOd;EACf,OAAO;EACP,cAAc,eAAe;EAC7B,QAAQ,sBAAsB;EAC9B,WAAW,sBAAsB,gBAAgB;EACjD,eAAe,sBAAsB;EACrC,iBAAiB,sBAAsB,gBAAgB;EACvD,iBAAiB,sBAAsB;EACvC,YAAY,SAAS,iBAAiB,uBAAuB;EAC7D,SAAS,oBAAoB,gBAAgB,OAAO;EACpD,eAAe,oBAAoB,QAAQ;EAC3C,SAAS,OAAO,cAAc,QAAQ,QAAQ,aAAa;EAC3D,WAAW,gBAAgB,SAAS,QAAQ;EAC5C,aAAa,gBAAgB,eAAe;;UAG7B;EACf;EACA;EACA;;;;;;;iBA+Kc,iBACd,QAAQ,mBACR,MAAM,kBACL;;iBAWa,eACd,OAAO,KAAK;EAA0B,MAAM;GAC5C,QAAQ,QAAQ,aACf,QAAQ;iBAIK,cAAc,OAAO,KAAK;EAA0B,MAAM;;;;;;;iBAuD1D,sBACd,OAAO,YACP,gBACA,MAAM,kBACL"}
|