@pairdraw/core 0.21.0 → 0.22.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/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/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/canvas/shaders/compile.d.ts +3 -1
- package/dist/canvas/shaders/compile.d.ts.map +1 -1
- package/dist/canvas/shaders/compile.js +12 -3
- package/dist/canvas/shaders/compile.js.map +1 -1
- package/dist/canvas/shaders/draw.d.ts.map +1 -1
- package/dist/canvas/shaders/draw.js +10 -3
- package/dist/canvas/shaders/draw.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +6 -16
- package/dist/canvas/shaders/effect.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/export.js +2 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- 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 +61 -5
- 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/drawio/warnings.d.ts +17 -2
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
- package/dist/io/formats/drawio/warnings.js +14 -7
- package/dist/io/formats/drawio/warnings.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/index.d.ts +1 -0
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +5 -3
- package/dist/io/formats/html/index.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/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +13 -4
- package/dist/io/formats/pen/index.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 +30 -17
- package/dist/io/formats.js.map +1 -1
- package/dist/io/index.d.ts +2 -2
- package/dist/io/types.d.ts +11 -2
- package/dist/io/types.d.ts.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/index.d.ts +2 -2
- package/dist/text/index.js +2 -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/canvas/shaders/compile.ts +14 -3
- package/src/canvas/shaders/draw.ts +11 -4
- package/src/canvas/shaders/effect.ts +6 -18
- 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/export.ts +2 -2
- 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/drawio/warnings.ts +27 -8
- 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/index.ts +9 -3
- 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/pen/index.ts +14 -6
- 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 +45 -19
- package/src/io/index.ts +1 -0
- package/src/io/types.ts +10 -0
- 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/index.ts +1 -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
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeTooLargeError,
|
|
3
|
+
MAX_CODE_ELEMENTS,
|
|
4
|
+
createHeadlessCSSRuntime,
|
|
5
|
+
jsxSourceToTree,
|
|
6
|
+
tailwindCandidates,
|
|
7
|
+
tailwindHTMLToSceneGraph,
|
|
8
|
+
tailwindJSXToSceneGraph,
|
|
9
|
+
tailwindUtilities,
|
|
10
|
+
type CodeReport,
|
|
11
|
+
type CSSRuntime
|
|
12
|
+
} from '@pairdraw/dom-css'
|
|
13
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
14
|
+
|
|
15
|
+
import { htmlClassNames, htmlElementCount } from '#core/io/formats/html/layers'
|
|
16
|
+
|
|
17
|
+
import { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, type PasteCodeKind } from './detect'
|
|
18
|
+
import { codeStylesheet } from './stylesheet'
|
|
19
|
+
|
|
20
|
+
/** What a paste could not keep, counted for the toast, plus what only the paste knows. */
|
|
21
|
+
export interface ReadCodeReport extends CodeReport {
|
|
22
|
+
/** Top-level layers the paste drew. */
|
|
23
|
+
layers: number
|
|
24
|
+
/** Variant-prefixed utilities left out, such as `md:flex-row`'s `md:`. */
|
|
25
|
+
variantsStripped: number
|
|
26
|
+
/** Colour and number properties bound to the target document's variables. */
|
|
27
|
+
tokensBound: number
|
|
28
|
+
/** Values two variables share, which a paste binds nothing to. */
|
|
29
|
+
tokensAmbiguous: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ReadCodeOptions {
|
|
33
|
+
/** The paste's own CSS: a `globals.css` or a `<style>` block it came with. */
|
|
34
|
+
css?: string
|
|
35
|
+
/** The target document's tokens as a stylesheet, so `bg-primary` resolves before binding. */
|
|
36
|
+
tokensCSS?: string
|
|
37
|
+
/** The CSS runtime a host supplies; the headless one by default. */
|
|
38
|
+
runtime?: CSSRuntime
|
|
39
|
+
pageName?: string
|
|
40
|
+
/** The language the caller names, instead of what detection reads. */
|
|
41
|
+
kind?: PasteCodeKind
|
|
42
|
+
/** Whether Tailwind utilities compile; false reads only inline styles and the paste's CSS. */
|
|
43
|
+
tailwind?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReadCodeResult {
|
|
47
|
+
graph: SceneGraph
|
|
48
|
+
report: ReadCodeReport
|
|
49
|
+
kind: PasteCodeKind
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The layers a pasted JSX, TSX, or HTML source draws, styled as a browser would style it with its
|
|
54
|
+
* own CSS and the Tailwind classes it names. Nothing in the source runs. Token binding needs the
|
|
55
|
+
* target document and happens in `bindCodeTokens`. Source past the size a paste reads is refused
|
|
56
|
+
* before it is parsed.
|
|
57
|
+
*/
|
|
58
|
+
export async function readCodeDocument(
|
|
59
|
+
code: string,
|
|
60
|
+
options: ReadCodeOptions = {}
|
|
61
|
+
): Promise<ReadCodeResult> {
|
|
62
|
+
const detection = detectCode(code)
|
|
63
|
+
if (detection === CODE_TOO_LARGE) {
|
|
64
|
+
throw new CodeTooLargeError(
|
|
65
|
+
`The paste is longer than ${MAX_CODE_LENGTH} characters; paste a smaller part of it.`
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
const kind = options.kind ?? detection
|
|
69
|
+
if (!kind) throw new Error('This text does not draw a layout: paste JSX, TSX, or HTML markup.')
|
|
70
|
+
if (kind === 'html' && htmlElementCount(code) > MAX_CODE_ELEMENTS) {
|
|
71
|
+
throw new CodeTooLargeError(
|
|
72
|
+
`The paste draws more than ${MAX_CODE_ELEMENTS} layers; paste a smaller part of it.`
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
const stylesheet = codeStylesheet([options.tokensCSS, options.css])
|
|
76
|
+
const runtime = options.runtime ?? createHeadlessCSSRuntime()
|
|
77
|
+
const build = kind === 'jsx' ? jsxLayers : htmlLayers
|
|
78
|
+
const { graph, report } = await build(code, {
|
|
79
|
+
...options,
|
|
80
|
+
runtime,
|
|
81
|
+
css: stylesheet.css,
|
|
82
|
+
tailwind: options.tailwind !== false
|
|
83
|
+
})
|
|
84
|
+
report.layers = codeLayerCount(graph)
|
|
85
|
+
report.approximations += stylesheet.importsDropped
|
|
86
|
+
return { graph, report, kind }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface StyleSource {
|
|
90
|
+
runtime: CSSRuntime
|
|
91
|
+
css: string
|
|
92
|
+
pageName?: string
|
|
93
|
+
tailwind: boolean
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function jsxLayers(
|
|
97
|
+
code: string,
|
|
98
|
+
source: StyleSource
|
|
99
|
+
): Promise<{ graph: SceneGraph; report: ReadCodeReport }> {
|
|
100
|
+
const { children, report } = jsxSourceToTree(code)
|
|
101
|
+
const { candidates, variantsStripped } = source.tailwind
|
|
102
|
+
? tailwindCandidates(children)
|
|
103
|
+
: { candidates: [], variantsStripped: 0 }
|
|
104
|
+
const graph = await tailwindJSXToSceneGraph(children, candidates, {
|
|
105
|
+
runtime: source.runtime,
|
|
106
|
+
css: source.css,
|
|
107
|
+
pageName: source.pageName
|
|
108
|
+
})
|
|
109
|
+
return { graph, report: withCounts(report, variantsStripped) }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function htmlLayers(
|
|
113
|
+
code: string,
|
|
114
|
+
source: StyleSource
|
|
115
|
+
): Promise<{ graph: SceneGraph; report: ReadCodeReport }> {
|
|
116
|
+
const { candidates, variantsStripped } = source.tailwind
|
|
117
|
+
? tailwindUtilities(htmlClassNames(code))
|
|
118
|
+
: { candidates: [], variantsStripped: 0 }
|
|
119
|
+
const graph = await tailwindHTMLToSceneGraph(code, candidates, {
|
|
120
|
+
runtime: source.runtime,
|
|
121
|
+
css: source.css,
|
|
122
|
+
pageName: source.pageName
|
|
123
|
+
})
|
|
124
|
+
const report: CodeReport = {
|
|
125
|
+
placeholders: 0,
|
|
126
|
+
componentsAsFrames: 0,
|
|
127
|
+
droppedProps: 0,
|
|
128
|
+
approximations: 0,
|
|
129
|
+
imagesAsPlaceholders: 0
|
|
130
|
+
}
|
|
131
|
+
return { graph, report: withCounts(report, variantsStripped) }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Every layer the paste drew, without the document node or its pages. */
|
|
135
|
+
export function codeLayerCount(graph: SceneGraph): number {
|
|
136
|
+
const pages = new Set(graph.getPages().map((page) => page.id))
|
|
137
|
+
return [...graph.getAllNodes()].filter((node) => node.id !== graph.rootId && !pages.has(node.id))
|
|
138
|
+
.length
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function withCounts(report: CodeReport, variantsStripped: number): ReadCodeReport {
|
|
142
|
+
return { ...report, layers: 0, variantsStripped, tokensBound: 0, tokensAmbiguous: 0 }
|
|
143
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The declarations a stylesheet keeps: one import names a file the paste does not carry. */
|
|
2
|
+
const IMPORT = /^\s*@import\b.*$/gm
|
|
3
|
+
|
|
4
|
+
export interface CodeStylesheet {
|
|
5
|
+
css: string
|
|
6
|
+
importsDropped: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The stylesheet a paste styles with: the document's tokens first, then the paste's own CSS, with
|
|
11
|
+
* `@import` rules left out because they name files the paste does not bring with it.
|
|
12
|
+
*/
|
|
13
|
+
export function codeStylesheet(parts: Array<string | undefined>): CodeStylesheet {
|
|
14
|
+
let importsDropped = 0
|
|
15
|
+
const kept = parts
|
|
16
|
+
.filter((part): part is string => Boolean(part?.trim()))
|
|
17
|
+
.map((part) =>
|
|
18
|
+
part.replace(IMPORT, () => {
|
|
19
|
+
importsDropped += 1
|
|
20
|
+
return ''
|
|
21
|
+
})
|
|
22
|
+
)
|
|
23
|
+
return { css: kept.join('\n'), importsDropped }
|
|
24
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { SceneGraph, SceneNode, Variable, VariableValue } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
import { variableValueInMode } from '@pairdraw/scene-graph/variables'
|
|
4
|
+
|
|
5
|
+
/** Tailwind namespace a document variable belongs to, which decides what it may bind. */
|
|
6
|
+
type TokenNamespace = 'color' | 'radius' | 'spacing' | 'text' | 'leading' | 'tracking'
|
|
7
|
+
|
|
8
|
+
/** The namespaces a layer property can take, in the vocabulary its tokens are named in. */
|
|
9
|
+
const PROPERTY_NAMESPACES: Partial<Record<string, TokenNamespace>> = {
|
|
10
|
+
cornerRadius: 'radius',
|
|
11
|
+
topLeftRadius: 'radius',
|
|
12
|
+
topRightRadius: 'radius',
|
|
13
|
+
bottomLeftRadius: 'radius',
|
|
14
|
+
bottomRightRadius: 'radius',
|
|
15
|
+
fontSize: 'text',
|
|
16
|
+
lineHeight: 'leading',
|
|
17
|
+
letterSpacing: 'tracking',
|
|
18
|
+
itemSpacing: 'spacing',
|
|
19
|
+
counterAxisSpacing: 'spacing',
|
|
20
|
+
gridColumnGap: 'spacing',
|
|
21
|
+
gridRowGap: 'spacing',
|
|
22
|
+
paddingLeft: 'spacing',
|
|
23
|
+
paddingRight: 'spacing',
|
|
24
|
+
paddingTop: 'spacing',
|
|
25
|
+
paddingBottom: 'spacing'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The numeric properties a pasted layer binds to a matching variable. */
|
|
29
|
+
const BOUND_NUMERIC_FIELDS = Object.keys(PROPERTY_NAMESPACES)
|
|
30
|
+
|
|
31
|
+
export interface TokenBindingReport {
|
|
32
|
+
tokensBound: number
|
|
33
|
+
tokensAmbiguous: number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Binds a pasted layer's colours and numbers to the target document's variables, one property at
|
|
38
|
+
* a time, only when exactly one variable of the matching namespace holds that exact value. A value
|
|
39
|
+
* two variables share binds nothing: guessing would change the design. The layers are the inserted
|
|
40
|
+
* ones, so a binding names a variable the document already has.
|
|
41
|
+
*/
|
|
42
|
+
export function bindCodeTokens(
|
|
43
|
+
nodes: Iterable<SceneNode>,
|
|
44
|
+
target: SceneGraph,
|
|
45
|
+
report: TokenBindingReport
|
|
46
|
+
): void {
|
|
47
|
+
const index = variableIndex(target)
|
|
48
|
+
if (index.size === 0) return
|
|
49
|
+
for (const node of nodes) bindNode(node, index, report)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Every layer a paste created, from its roots down, as a transfer inserted them. */
|
|
53
|
+
export function codeLayerNodes(graph: SceneGraph, rootIds: readonly string[]): SceneNode[] {
|
|
54
|
+
const nodes: SceneNode[] = []
|
|
55
|
+
const visit = (id: string): void => {
|
|
56
|
+
const node = graph.getNode(id)
|
|
57
|
+
if (!node) return
|
|
58
|
+
nodes.push(node)
|
|
59
|
+
for (const child of node.childIds) visit(child)
|
|
60
|
+
}
|
|
61
|
+
for (const id of rootIds) visit(id)
|
|
62
|
+
return nodes
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type ValueIndex = Map<string, Variable[]>
|
|
66
|
+
|
|
67
|
+
function variableIndex(target: SceneGraph): ValueIndex {
|
|
68
|
+
const index: ValueIndex = new Map()
|
|
69
|
+
for (const variable of target.variables.values()) {
|
|
70
|
+
if (variable.deleted) continue
|
|
71
|
+
const namespace = namespaceOf(variable)
|
|
72
|
+
if (!namespace) continue
|
|
73
|
+
const value = variableValueInMode(target, variable, defaultModeOf(target, variable))
|
|
74
|
+
const key = indexKey(namespace, value)
|
|
75
|
+
if (!key) continue
|
|
76
|
+
const found = index.get(key)
|
|
77
|
+
if (found) found.push(variable)
|
|
78
|
+
else index.set(key, [variable])
|
|
79
|
+
}
|
|
80
|
+
return index
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function defaultModeOf(target: SceneGraph, variable: Variable): string {
|
|
84
|
+
return target.variableCollections.get(variable.collectionId)?.defaultModeId ?? ''
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The namespace a variable's scopes name, or none when it names something a layer cannot take. */
|
|
88
|
+
function namespaceOf(variable: Variable): TokenNamespace | null {
|
|
89
|
+
if (variable.type === 'COLOR') return 'color'
|
|
90
|
+
if (variable.type !== 'FLOAT') return null
|
|
91
|
+
for (const scope of variable.scopes ?? []) {
|
|
92
|
+
if (scope === 'CORNER_RADIUS') return 'radius'
|
|
93
|
+
if (scope === 'GAP' || scope === 'WIDTH_HEIGHT') return 'spacing'
|
|
94
|
+
if (scope === 'FONT_SIZE') return 'text'
|
|
95
|
+
if (scope === 'LINE_HEIGHT') return 'leading'
|
|
96
|
+
if (scope === 'LETTER_SPACING') return 'tracking'
|
|
97
|
+
}
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function indexKey(namespace: TokenNamespace, value: VariableValue | undefined): string | null {
|
|
102
|
+
if (typeof value === 'number') return `${namespace}:${value.toFixed(3)}`
|
|
103
|
+
if (!isColor(value)) return null
|
|
104
|
+
return `${namespace}:${colorKey(value)}`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isColor(value: unknown): value is Color {
|
|
108
|
+
return typeof value === 'object' && value !== null && 'r' in value && 'g' in value && 'b' in value
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function colorKey(color: Color): string {
|
|
112
|
+
return [color.r, color.g, color.b, color.a].map((channel) => channel.toFixed(4)).join(',')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function bindNode(node: SceneNode, index: ValueIndex, report: TokenBindingReport): void {
|
|
116
|
+
bindPaints(node, 'fills', index, report)
|
|
117
|
+
bindPaints(node, 'strokes', index, report)
|
|
118
|
+
for (const field of BOUND_NUMERIC_FIELDS) {
|
|
119
|
+
const value = node[field as keyof SceneNode]
|
|
120
|
+
if (typeof value !== 'number' || value === 0) continue
|
|
121
|
+
const namespace = PROPERTY_NAMESPACES[field]
|
|
122
|
+
if (!namespace) continue
|
|
123
|
+
bindField(node, field, indexKey(namespace, value), index, report)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function bindPaints(
|
|
128
|
+
node: SceneNode,
|
|
129
|
+
list: 'fills' | 'strokes',
|
|
130
|
+
index: ValueIndex,
|
|
131
|
+
report: TokenBindingReport
|
|
132
|
+
): void {
|
|
133
|
+
const paints = node[list]
|
|
134
|
+
paints.forEach((paint, paintIndex) => {
|
|
135
|
+
if (paint.type !== 'SOLID') return
|
|
136
|
+
const { r, g, b, a } = paint.color
|
|
137
|
+
bindField(node, `${list}/${paintIndex}/color`, indexKey('color', { r, g, b, a }), index, report)
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function bindField(
|
|
142
|
+
node: SceneNode,
|
|
143
|
+
field: string,
|
|
144
|
+
key: string | null,
|
|
145
|
+
index: ValueIndex,
|
|
146
|
+
report: TokenBindingReport
|
|
147
|
+
): void {
|
|
148
|
+
if (!key || node.boundVariables[field]) return
|
|
149
|
+
const candidates = index.get(key)
|
|
150
|
+
if (!candidates || candidates.length === 0) return
|
|
151
|
+
if (candidates.length > 1) {
|
|
152
|
+
report.tokensAmbiguous += 1
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
const variable = candidates.at(0)
|
|
156
|
+
if (!variable) return
|
|
157
|
+
node.boundVariables = { ...node.boundVariables, [field]: variable.id }
|
|
158
|
+
report.tokensBound += 1
|
|
159
|
+
}
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
CodeSyntaxPlatform,
|
|
7
7
|
SceneGraph,
|
|
8
8
|
SceneNode,
|
|
9
|
+
SharedStyleType,
|
|
9
10
|
TokenExpression,
|
|
10
11
|
TokenUnit,
|
|
11
12
|
Variable,
|
|
@@ -245,13 +246,13 @@ export function applyTokenImport(
|
|
|
245
246
|
|
|
246
247
|
/** A style node: hidden from the layer list, found by its style id, as `.fig` styles are. */
|
|
247
248
|
export function styleNodeProps(
|
|
248
|
-
style: PlannedStyle,
|
|
249
|
+
style: Pick<PlannedStyle, 'kind'> | { kind: SharedStyleType },
|
|
249
250
|
fields: Partial<SceneNode>
|
|
250
251
|
): Partial<SceneNode> {
|
|
251
252
|
return { ...fields, sharedStyleType: style.kind, internalOnly: true }
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
export function styleNodeType(style: PlannedStyle) {
|
|
255
|
+
export function styleNodeType(style: Pick<PlannedStyle, 'kind'> | { kind: SharedStyleType }) {
|
|
255
256
|
return style.kind === 'TEXT' ? ('TEXT' as const) : ('RECTANGLE' as const)
|
|
256
257
|
}
|
|
257
258
|
|
|
@@ -5,23 +5,42 @@ function counted(count: number, one: string, many: string): string {
|
|
|
5
5
|
return `${count} ${count === 1 ? one : many}`
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* What a draw.io file could not hold, as facts rather than a sentence: the app shows these in the
|
|
10
|
+
* reader's language, while the CLI and MCP print `drawioWriteWarningText` of each.
|
|
11
|
+
*/
|
|
12
|
+
export interface DrawioWriteWarning {
|
|
13
|
+
kind: 'unbound-variables'
|
|
14
|
+
/** Variables the graph holds, none of which draw.io can carry. */
|
|
15
|
+
variables: number
|
|
16
|
+
/** The collections those variables belong to, by name. */
|
|
17
|
+
collections: string[]
|
|
18
|
+
/** Layers painted through a binding, which open without it. */
|
|
19
|
+
layers: number
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
/**
|
|
9
23
|
* What a draw.io file cannot hold. draw.io has no variable model and no style that reads one, so
|
|
10
24
|
* a document that paints with variables arrives in draw.io as plain colours and comes back
|
|
11
25
|
* unbound. The writer names that loss instead of writing a file that looks complete.
|
|
12
26
|
*/
|
|
13
|
-
export function
|
|
27
|
+
export function drawioWriteWarnings(graph: SceneGraph): DrawioWriteWarning[] {
|
|
14
28
|
const variables = graph.getLiveVariables().length
|
|
15
29
|
if (variables === 0) return []
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const bound = [...graph.nodes.values()].filter(
|
|
30
|
+
const collections = graph.getLiveCollections().map((collection) => collection.name)
|
|
31
|
+
const layers = [...graph.nodes.values()].filter(
|
|
19
32
|
(node) => Object.keys(node.boundVariables).length > 0
|
|
20
33
|
).length
|
|
21
|
-
|
|
34
|
+
return [{ kind: 'unbound-variables', variables, collections, layers }]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The English sentence a write warning has always been reported as. */
|
|
38
|
+
export function drawioWriteWarningText(warning: DrawioWriteWarning): string {
|
|
39
|
+
const dropped = `draw.io has no variables: ${counted(warning.variables, 'variable', 'variables')} in ${counted(warning.collections.length, 'collection', 'collections')} (${warning.collections.join(', ')}) not written`
|
|
40
|
+
if (warning.layers === 0) return dropped
|
|
22
41
|
const users =
|
|
23
|
-
|
|
42
|
+
warning.layers === 1
|
|
24
43
|
? '1 layer that uses one lost the binding'
|
|
25
|
-
: `${counted(
|
|
26
|
-
return
|
|
44
|
+
: `${counted(warning.layers, 'layer', 'layers')} that use them lost the binding`
|
|
45
|
+
return `${dropped}, and ${users}`
|
|
27
46
|
}
|
|
@@ -203,6 +203,17 @@ export async function narrowToChangedFields(
|
|
|
203
203
|
const fields: FigRecordFieldPatch[] = []
|
|
204
204
|
for (const record of written) {
|
|
205
205
|
const id = record.guid ? guidToString(record.guid) : null
|
|
206
|
+
// A layer whose slot assignment changed is written whole: the baseline a patch compares with
|
|
207
|
+
// carries no assignment, so the comparison cannot see one being added or dropped, and the
|
|
208
|
+
// archive's record would keep naming content this save releases.
|
|
209
|
+
const owner = id ? recordOwners.get(id) : undefined
|
|
210
|
+
if (
|
|
211
|
+
owner &&
|
|
212
|
+
source.getNode(owner)?.source.editedFields.includes('componentPropertyAssignments')
|
|
213
|
+
) {
|
|
214
|
+
records.push(record)
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
206
217
|
const saved = id ? baseline?.get(id) : undefined
|
|
207
218
|
if (!saved || !record.guid) {
|
|
208
219
|
records.push(record)
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@pairdraw/fig'
|
|
8
8
|
import {
|
|
9
9
|
nameImagesForFigma,
|
|
10
|
+
placeSlotContent,
|
|
10
11
|
type FigNodeChangeExportRuntime,
|
|
11
12
|
sceneNodeToKiwi
|
|
12
13
|
} from '@pairdraw/fig/node-change'
|
|
@@ -14,9 +15,8 @@ import { stringToGuid } from '@pairdraw/kiwi/fig/guid'
|
|
|
14
15
|
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
15
16
|
import { isGeneratedFrame } from '@pairdraw/scene-graph/generated'
|
|
16
17
|
import { computeImageHash } from '@pairdraw/scene-graph/images'
|
|
17
|
-
import { siblingOrderKeys } from '@pairdraw/scene-graph/order-keys'
|
|
18
|
+
import { fractionalPosition, siblingOrderKeys } from '@pairdraw/scene-graph/order-keys'
|
|
18
19
|
import type { GUID } from '@pairdraw/scene-graph/primitives'
|
|
19
|
-
import { ownsSlotContent } from '@pairdraw/scene-graph/slots'
|
|
20
20
|
import { layersUsingVariables } from '@pairdraw/scene-graph/variables'
|
|
21
21
|
|
|
22
22
|
import { figCompressionLevel } from '#core/io/formats/fig/compression'
|
|
@@ -40,21 +40,16 @@ import { mergeArchiveFonts } from '#core/text/font/document'
|
|
|
40
40
|
|
|
41
41
|
import { narrowToChangedFields, type RecordWriter } from './fields'
|
|
42
42
|
|
|
43
|
-
/** Slot content an instance writes as records of its own, which this path leaves alone. */
|
|
44
|
-
class UnpatchableChangeError extends Error {
|
|
45
|
-
override name = 'UnpatchableChangeError'
|
|
46
|
-
}
|
|
47
|
-
|
|
48
43
|
/**
|
|
49
44
|
* The layer whose record holds a layer: itself, or the outermost instance or generated frame it
|
|
50
45
|
* sits in, since both write their contents as overrides and derived data on their own record.
|
|
46
|
+
* Slot content is written by the instance assigning it, so it belongs to that instance too.
|
|
51
47
|
*/
|
|
52
48
|
function recordOwner(graph: SceneGraph, id: string): string | null {
|
|
53
49
|
const start = graph.getNode(id)
|
|
54
50
|
if (!start) return null
|
|
55
51
|
let owner: SceneNode = start
|
|
56
52
|
for (let node: SceneNode | undefined = start; node;) {
|
|
57
|
-
if (ownsSlotContent(graph, node)) throw new UnpatchableChangeError()
|
|
58
53
|
if (node.type === 'INSTANCE' || isGeneratedFrame(node)) owner = node
|
|
59
54
|
if (node.type === 'CANVAS') return owner.id
|
|
60
55
|
node = node.parentId ? graph.getNode(node.parentId) : undefined
|
|
@@ -236,13 +231,24 @@ async function loadComponentUsePages(
|
|
|
236
231
|
return loaded
|
|
237
232
|
}
|
|
238
233
|
|
|
239
|
-
|
|
234
|
+
/**
|
|
235
|
+
* Writes the plan's records. With `slotContent`, an instance's slot content is written as new
|
|
236
|
+
* frames on the internal canvas, as the whole-document export writes it; the archive's merge
|
|
237
|
+
* drops the frames the instance assigned before and places the new ones after the canvas's
|
|
238
|
+
* last record. Without, the instances write no slot assignment, so the archived document a
|
|
239
|
+
* patch is compared with never names a frame the patch adds.
|
|
240
|
+
*/
|
|
241
|
+
function writeRecords(
|
|
242
|
+
setup: FigExportSetup,
|
|
243
|
+
plan: RecordPlan,
|
|
244
|
+
slotContent = true
|
|
245
|
+
): KiwiNodeChange[] | null {
|
|
240
246
|
const { graph } = setup
|
|
241
247
|
const canvasGuids = new Map(setup.canvasEntries.map((entry) => [entry.page.id, entry]))
|
|
242
248
|
const slotContentRecords: KiwiNodeChange[] = []
|
|
243
249
|
const options = {
|
|
244
250
|
...figExportRecordOptions(setup),
|
|
245
|
-
slotContentRecords,
|
|
251
|
+
slotContentRecords: slotContent ? slotContentRecords : undefined,
|
|
246
252
|
orderKeys: plan.orderKeys,
|
|
247
253
|
writeChildren: false
|
|
248
254
|
}
|
|
@@ -294,8 +300,12 @@ function writeRecords(setup: FigExportSetup, plan: RecordPlan): KiwiNodeChange[]
|
|
|
294
300
|
...sceneNodeToKiwi(node, parentGuid, index, setup.localIdCounter, graph, setup.blobs, options)
|
|
295
301
|
)
|
|
296
302
|
}
|
|
303
|
+
if (slotContentRecords.length === 0) return written
|
|
297
304
|
// Instance slot content is written as records of its own on the internal canvas.
|
|
298
|
-
|
|
305
|
+
if (!internal) return null
|
|
306
|
+
if (!internal.page.id && !internalWritten) written.push(internal.canvasNc)
|
|
307
|
+
placeSlotContent(slotContentRecords, internal.canvasGuid, 0, fractionalPosition)
|
|
308
|
+
return [...written, ...slotContentRecords]
|
|
299
309
|
}
|
|
300
310
|
|
|
301
311
|
function variableRecords(setup: FigExportSetup, archiveInternalCanvas: boolean): KiwiNodeChange[] {
|
|
@@ -330,7 +340,7 @@ function baselineWriter(info: FigArchiveRecordInfo): RecordWriter {
|
|
|
330
340
|
if (orderKey) orderKeys.set(id, orderKey)
|
|
331
341
|
}
|
|
332
342
|
const plan = { records: new Set(records), orderKeys, removed: [], replaceVariables: false }
|
|
333
|
-
const written = writeRecords(setup, plan)
|
|
343
|
+
const written = writeRecords(setup, plan, false)
|
|
334
344
|
if (!written) return null
|
|
335
345
|
const internalPage = graph.getPages(true).find((page) => page.internalOnly)
|
|
336
346
|
// The baseline holds the document's own records; an unread one is not in the graph.
|
|
@@ -444,13 +454,7 @@ export async function writePatchedFigFile(
|
|
|
444
454
|
: loaded
|
|
445
455
|
if (!archived) return null
|
|
446
456
|
const info = await archive.info()
|
|
447
|
-
|
|
448
|
-
try {
|
|
449
|
-
built = await buildPatch(source, runtime, info, changes, archived)
|
|
450
|
-
} catch (error) {
|
|
451
|
-
if (error instanceof UnpatchableChangeError) return null
|
|
452
|
-
throw error
|
|
453
|
-
}
|
|
457
|
+
const built = await buildPatch(source, runtime, info, changes, archived)
|
|
454
458
|
if (!built) return null
|
|
455
459
|
const imageNames = nameImagesForFigma(built.patch.records, built.graph.images)
|
|
456
460
|
const extras = await figFileExtras(built.graph, imageNames, options)
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
parseGuidOrNull,
|
|
17
17
|
type FigNodeChangeExportRuntime,
|
|
18
18
|
makeCanvasNodeChange,
|
|
19
|
-
makeDocumentNodeChange
|
|
19
|
+
makeDocumentNodeChange,
|
|
20
|
+
categoryToChange
|
|
20
21
|
} from '@pairdraw/fig/node-change'
|
|
21
22
|
import { getCompiledSchema, getSchemaBytes, type NodeChange } from '@pairdraw/kiwi/fig/codec'
|
|
22
23
|
import { stringToGuid } from '@pairdraw/kiwi/fig/guid'
|
|
@@ -424,6 +425,12 @@ export async function prepareFigExport(
|
|
|
424
425
|
const documentNc = makeDocumentNodeChange(docGuid, graph.documentColorSpace)
|
|
425
426
|
const rootNode = graph.getNode(graph.rootId)
|
|
426
427
|
if (rootNode) Object.assign(documentNc, rootNode.source.fig.rawNodeFields)
|
|
428
|
+
if (graph.annotationCategories.size > 0) {
|
|
429
|
+
documentNc.annotationCategories = {
|
|
430
|
+
version: 3,
|
|
431
|
+
items: [...graph.annotationCategories.values()].map(categoryToChange)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
427
434
|
applyDocumentPluginData(documentNc, graph)
|
|
428
435
|
|
|
429
436
|
const pages = graph.getPages(true)
|
|
@@ -6,6 +6,12 @@ export {
|
|
|
6
6
|
pendingReaderPageOfNode as pendingFigPageOfNode,
|
|
7
7
|
populateFigPage,
|
|
8
8
|
populateAllFigPages,
|
|
9
|
+
readerDiagnosticComponents,
|
|
10
|
+
readerDiagnosticCounts,
|
|
11
|
+
type ReaderDiagnosticComponent,
|
|
12
|
+
type ReaderDiagnosticCount,
|
|
13
|
+
type ReaderDiagnosticReason,
|
|
9
14
|
readerDiagnostics
|
|
10
15
|
} from '#core/kiwi/fig/session/document-state'
|
|
16
|
+
export type { FigReaderDiagnostic } from '#core/kiwi/fig/session/options'
|
|
11
17
|
export { buildFontDigestMap } from '#core/kiwi/fig/node-change/font/digests'
|
|
@@ -15,8 +15,10 @@ import {
|
|
|
15
15
|
} from '#core/kiwi/fig/session/archive/access'
|
|
16
16
|
import { createFigSessionWorker } from '#core/kiwi/fig/session/client'
|
|
17
17
|
import {
|
|
18
|
+
normalizeSlotContentOwners,
|
|
18
19
|
registerReaderRecovery,
|
|
19
|
-
registerReaderSession
|
|
20
|
+
registerReaderSession,
|
|
21
|
+
releaseReaderRecords
|
|
20
22
|
} from '#core/kiwi/fig/session/document-state'
|
|
21
23
|
import type { FigSessionOpenRequest, FigSessionResponse } from '#core/kiwi/fig/session/protocol'
|
|
22
24
|
import { openReaderSession } from '#core/kiwi/fig/session/reader'
|
|
@@ -43,12 +45,18 @@ async function parseFigFileMainThread(
|
|
|
43
45
|
await reader.registerDocumentFonts()
|
|
44
46
|
options.signal?.throwIfAborted()
|
|
45
47
|
const bytes = buffer.slice(0)
|
|
46
|
-
registerReaderSession(bytes, reader.session, reader.diagnostics)
|
|
47
48
|
// Taken now, while the records are decoded: the archive outlives the reader's session.
|
|
48
49
|
const archiveInfo = reader.session.archiveRecordInfo()
|
|
49
50
|
const archive = localFigArchive(bytes, () => archiveInfo)
|
|
50
51
|
registerFigArchive(reader.graph, archive)
|
|
51
52
|
registerOriginalArchiveRequest(reader.graph, () => archive.original())
|
|
53
|
+
registerReaderSession(bytes, reader.session, reader.diagnostics)
|
|
54
|
+
normalizeSlotContentOwners(reader.graph)
|
|
55
|
+
if ((options.populate ?? 'all') === 'all') {
|
|
56
|
+
// Every visible page is in the graph. Keep the compressed bytes and the checkpoint, and drop
|
|
57
|
+
// the decoded records: a save or an explicit page population opens a fresh session from them.
|
|
58
|
+
releaseReaderRecords(reader.graph)
|
|
59
|
+
}
|
|
52
60
|
return reader.graph
|
|
53
61
|
}
|
|
54
62
|
|
|
@@ -90,6 +98,7 @@ export async function parseFigFileViaWorker(
|
|
|
90
98
|
const graph = deserializeSceneGraph(e.data.graph)
|
|
91
99
|
const fonts = e.data.graph.documentFonts ?? []
|
|
92
100
|
const register = fonts.length > 0 ? registerDocumentFonts(graph, fonts) : null
|
|
101
|
+
normalizeSlotContentOwners(graph)
|
|
93
102
|
if (options.populate === 'first-page' || options.populate === 'none') {
|
|
94
103
|
cleanupAbort()
|
|
95
104
|
const { checkpoint, archiveInfo, archive: bytes } = e.data
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { filename } from 'pathe/utils'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
designNodeDraws,
|
|
4
5
|
exportHTMLBundle,
|
|
5
6
|
sceneNodesToDesignDocument,
|
|
6
7
|
type DesignDocument
|
|
@@ -44,8 +45,9 @@ export async function renderNodesToHTML(
|
|
|
44
45
|
options: HTMLExportOptions = {},
|
|
45
46
|
fileName?: string,
|
|
46
47
|
context?: IOContext
|
|
47
|
-
): Promise<{ html: string; assets: ExportAsset[] }> {
|
|
48
|
-
const
|
|
48
|
+
): Promise<{ html: string; assets: ExportAsset[]; draws: boolean }> {
|
|
49
|
+
const projected = await designDocument(graph, nodeIds, options, context)
|
|
50
|
+
const bundle = await exportHTMLBundle(projected, {
|
|
49
51
|
html: options.html,
|
|
50
52
|
style: options.style,
|
|
51
53
|
assets: options.assets,
|
|
@@ -59,5 +61,9 @@ export async function renderNodesToHTML(
|
|
|
59
61
|
})
|
|
60
62
|
const page = bundle.files.find((file) => file.path === bundle.entrypoint)
|
|
61
63
|
if (typeof page?.content !== 'string') throw new Error('HTML export produced no page')
|
|
62
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
html: page.content,
|
|
66
|
+
assets: bundle.files.filter((file) => file !== page),
|
|
67
|
+
draws: projected.children.some(designNodeDraws)
|
|
68
|
+
}
|
|
63
69
|
}
|
|
@@ -43,6 +43,13 @@ export function htmlClassNames(html: string): string[] {
|
|
|
43
43
|
return [...names]
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const OPENING_ELEMENT = /<[A-Za-z][\w.:-]*/g
|
|
47
|
+
|
|
48
|
+
/** Every opening tag in markup, for the element ceiling a paste refuses before styling it. */
|
|
49
|
+
export function htmlElementCount(html: string): number {
|
|
50
|
+
return html.match(OPENING_ELEMENT)?.length ?? 0
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
/**
|
|
47
54
|
* The layers a styled DOM describes, with the sizes and positions its layout implies. Styling
|
|
48
55
|
* belongs to whoever has a CSS runtime, such as a browser or the headless runtime; building and
|