@pairdraw/core 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +74 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/colors.d.ts +20 -5
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +48 -42
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +25 -0
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
- package/dist/canvas/renderer/document-surface.js +46 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +6 -4
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -3
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -0
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +36 -3
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +2 -1
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +4 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/decorations.d.ts +2 -2
- package/dist/canvas/text/decorations.d.ts.map +1 -1
- package/dist/canvas/text/decorations.js +5 -5
- package/dist/canvas/text/decorations.js.map +1 -1
- package/dist/canvas/text/index.js +1 -1
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +2 -2
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -5
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -1
- package/dist/canvas/text/renderer.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +4 -4
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- package/dist/editor/clipboard/assets.js.map +1 -1
- package/dist/editor/clipboard/component-matches.d.ts +13 -0
- package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
- package/dist/editor/clipboard/component-matches.js +50 -0
- package/dist/editor/clipboard/component-matches.js.map +1 -0
- package/dist/editor/clipboard/dependencies.d.ts +7 -0
- package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
- package/dist/editor/clipboard/dependencies.js +5 -0
- package/dist/editor/clipboard/dependencies.js.map +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +48 -19
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -3
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +26 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +171 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +9 -2
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pencil.js +1 -1
- package/dist/editor/structure/state.d.ts.map +1 -1
- package/dist/editor/structure/state.js +2 -2
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +2 -2
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.js +3 -3
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fresh-read.d.ts +15 -0
- package/dist/figma-api/fresh-read.d.ts.map +1 -0
- package/dist/figma-api/fresh-read.js +54 -0
- package/dist/figma-api/fresh-read.js.map +1 -0
- package/dist/figma-api/graph-ref.d.ts +9 -0
- package/dist/figma-api/graph-ref.d.ts.map +1 -0
- package/dist/figma-api/graph-ref.js +14 -0
- package/dist/figma-api/graph-ref.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +3 -3
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +7 -3
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +1 -1
- package/dist/figma-api/pending-sync.d.ts.map +1 -1
- package/dist/figma-api/pending-sync.js +3 -1
- package/dist/figma-api/pending-sync.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/figma-api/variables/index.d.ts.map +1 -1
- package/dist/figma-api/variables/index.js +2 -2
- package/dist/figma-api/variables/index.js.map +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/css/known.js +1 -1
- package/dist/io/formats/design-tokens/css/known.js.map +1 -1
- package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
- package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/read.js +11 -5
- package/dist/io/formats/design-tokens/css/read.js.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.js +17 -4
- package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
- package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
- package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/values.js +24 -8
- package/dist/io/formats/design-tokens/css/values.js.map +1 -1
- package/dist/io/formats/design-tokens/decode.d.ts +7 -6
- package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/decode.js +14 -13
- package/dist/io/formats/design-tokens/decode.js.map +1 -1
- package/dist/io/formats/design-tokens/export.js +3 -3
- package/dist/io/formats/design-tokens/export.js.map +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -3
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +9 -9
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +4 -4
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +7 -7
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/design-tokens/values.d.ts +10 -5
- package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/values.js +13 -7
- package/dist/io/formats/design-tokens/values.js.map +1 -1
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -1
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts +7 -2
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +12 -13
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +9 -7
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +4 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/layers.js +2 -2
- package/dist/io/formats/mermaid/layers.js.map +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -0
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +4 -4
- package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
- package/dist/io/formats/pdf/prepare.js +2 -2
- package/dist/io/formats/pdf/prepare.js.map +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +35 -5
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/pptx/style.js +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/import.d.ts +4 -2
- package/dist/io/formats/svg/import.d.ts.map +1 -1
- package/dist/io/formats/svg/import.js +2 -1
- package/dist/io/formats/svg/import.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +8 -8
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +8 -5
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/yoga-helpers.d.ts +2 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +7 -1
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +112 -10
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/comments.d.ts +4 -1
- package/dist/pairdraw-api/comments.d.ts.map +1 -1
- package/dist/pairdraw-api/comments.js +5 -0
- package/dist/pairdraw-api/comments.js.map +1 -1
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/rpc/variables-command.js +2 -2
- package/dist/rpc/variables-command.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/provider.d.ts +15 -0
- package/dist/text/font/provider.d.ts.map +1 -0
- package/dist/text/font/provider.js +18 -0
- package/dist/text/font/provider.js.map +1 -0
- package/dist/text/font/readiness.d.ts +32 -0
- package/dist/text/font/readiness.d.ts.map +1 -0
- package/dist/text/font/{status.js → readiness.js} +8 -4
- package/dist/text/font/readiness.js.map +1 -0
- package/dist/text/index.d.ts +12 -9
- package/dist/text/index.js +6 -3
- package/dist/text/prepare.d.ts +9 -4
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +9 -4
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze/responsive/widths.d.ts +27 -0
- package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/widths.js +49 -0
- package/dist/tools/analyze/responsive/widths.js.map +1 -0
- package/dist/tools/analyze.d.ts +3 -1
- package/dist/tools/analyze.js +3 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen/tokens.d.ts.map +1 -1
- package/dist/tools/codegen/tokens.js +2 -2
- package/dist/tools/codegen/tokens.js.map +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -2
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/component-catalog.d.ts.map +1 -1
- package/dist/tools/component-catalog.js +5 -3
- package/dist/tools/component-catalog.js.map +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/css/shorthand.d.ts +20 -0
- package/dist/tools/css/shorthand.d.ts.map +1 -0
- package/dist/tools/css/shorthand.js +54 -0
- package/dist/tools/css/shorthand.js.map +1 -0
- package/dist/tools/describe/index.js +2 -2
- package/dist/tools/describe/index.js.map +1 -1
- package/dist/tools/describe/issues.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/html-host.d.ts.map +1 -1
- package/dist/tools/html-host.js +5 -3
- package/dist/tools/html-host.js.map +1 -1
- package/dist/tools/image-ai/apply.d.ts.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -3
- package/dist/tools/image-ai/apply.js.map +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/image-ai/service.d.ts.map +1 -1
- package/dist/tools/image-ai/service.js +5 -3
- package/dist/tools/image-ai/service.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/geometry.d.ts.map +1 -1
- package/dist/tools/modify/geometry.js +14 -3
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +35 -8
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +10 -10
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +56 -4
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +2 -2
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +29 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/prompts/codegen.js +1 -1
- package/dist/tools/prompts/codegen.js.map +1 -1
- package/dist/tools/read/css.d.ts +14 -0
- package/dist/tools/read/css.d.ts.map +1 -0
- package/dist/tools/read/css.js +306 -0
- package/dist/tools/read/css.js.map +1 -0
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/reactions.js +1 -1
- package/dist/tools/read/reactions.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -5
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +5 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script/host.d.ts.map +1 -1
- package/dist/tools/script/host.js +5 -3
- package/dist/tools/script/host.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/variables/collections.js +1 -1
- package/dist/tools/variables/collections.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -4
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
- package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/gradients.js +5 -5
- package/dist/vector/vectorize/svg/gradients.js.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.js +13 -12
- package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/colors.ts +76 -50
- package/src/canvas/renderer/document-surface.ts +53 -0
- package/src/canvas/renderer/fonts.ts +6 -4
- package/src/canvas/renderer/lifecycle.ts +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/assets.ts +6 -2
- package/src/editor/clipboard/component-matches.ts +65 -0
- package/src/editor/clipboard/dependencies.ts +22 -1
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/css/known.ts +1 -1
- package/src/io/formats/design-tokens/css/read.ts +20 -7
- package/src/io/formats/design-tokens/css/sync.ts +9 -4
- package/src/io/formats/design-tokens/css/values.ts +37 -9
- package/src/io/formats/design-tokens/decode.ts +17 -12
- package/src/io/formats/design-tokens/export.ts +3 -3
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -1
- package/src/io/formats/fig/export/setup.ts +25 -15
- package/src/io/formats/fig/export/variables.ts +17 -6
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -1
- package/src/tools/create/vector.ts +2 -2
- package/src/tools/css/shorthand.ts +64 -0
- package/src/tools/describe/index.ts +2 -8
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/geometry.ts +16 -3
- package/src/tools/modify/layout.ts +47 -13
- package/src/tools/modify/matching.ts +14 -11
- package/src/tools/modify/paint.ts +85 -5
- package/src/tools/modify/reactions.ts +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/canvas/text/shape.ts"],"sourcesContent":["import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport {\n EMPTY_EXPORT_RUNTIME,\n type FigNodeChangeExportRuntime,\n type PlacedTextGlyph,\n type ShapedText,\n type ShapedTextGlyph,\n type TextDecorationRecord\n} from '@pairdraw/fig/node-change'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { textVerticalOffset } from '@pairdraw/scene-graph/text'\n\nimport { buildParagraph } from '#core/canvas/text'\nimport { textDecorationRects, type DecoratedGlyph } from '#core/canvas/text/decorations'\nimport { outlineInk, savedGlyphInk } from '#core/canvas/text/ink'\nimport { COMBINING_KEYCAP, keycapFrame } from '#core/canvas/text/keycap'\nimport { characterFamily, laidOutGlyphs, type LaidOutGlyph } from '#core/canvas/text/placed'\nimport { getCanvasKit } from '#core/canvaskit'\nimport { shownText } from '#core/text/case'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { OutlineCommand } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { faceStyleName } from '#core/text/font/names'\nimport { nextGraphemeBoundary } from '#core/text/graphemes'\n\n/**\n * Whether saved glyphs could stand for this text: case changes that alter its length move\n * glyphs off the characters they came from, and path text is placed along its path. Truncated\n * text saves the characters it shows and the ellipsis after them.\n */\nfunction canShape(node: SceneNode, text: string): boolean {\n return node.text.length > 0 && text.length === node.text.length && !node.textPathData\n}\n\n/** Characters inside a glyph cluster or without a glyph take the offset of the one before. */\nfunction completeCharacterOffsets(offsets: Array<number | undefined>): number[] {\n let previous = 0\n return offsets.map((offset) => {\n previous = offset ?? previous\n return previous\n })\n}\n\n/**\n * The square Figma saves for an emoji, in pixels at `size` with y down: 1 em wide, from 0.07 em\n * below the baseline, closed with a line back to its start as Figma writes it.\n */\nfunction emojiPlaceholder(size: number): OutlineCommand[] {\n const bottom = 0.07 * size\n const top = -0.93 * size\n return [\n { type: 'M', x: 0, y: bottom },\n { type: 'L', x: size, y: bottom },\n { type: 'L', x: size, y: top },\n { type: 'L', x: 0, y: top },\n { type: 'L', x: 0, y: bottom },\n { type: 'Z' }\n ]\n}\n\ninterface SavedEmoji {\n codePoints: number[]\n /** Where the emoji's characters end in the text. */\n end: number\n}\n\n/**\n * The emoji a glyph starts, as Figma saves it, when the layout gave it to the emoji metrics font:\n * its code points, an emoji that shows as text by default with the selector that asks for its\n * emoji form, as Figma saves ☺ as ☺️.\n */\nfunction savedEmoji(node: SceneNode, text: string, glyph: LaidOutGlyph): SavedEmoji | undefined {\n const start = glyph.firstCharacter\n if (start === undefined || characterFamily(node, text, start) !== EMOJI_METRICS_FAMILY)\n return undefined\n const end = nextGraphemeBoundary(text, start)\n const emoji = text.slice(start, end)\n const codePoints = Array.from(emoji, (character) => character.codePointAt(0) ?? 0)\n if (codePoints.length === 1 && !/\\p{Emoji_Presentation}/u.test(emoji)) codePoints.push(0xfe0f)\n return { codePoints, end }\n}\n\n/**\n * A glyph's saved outline: an emoji's placeholder, nothing inside one, a keycap's frame, or its\n * font's outline.\n */\nfunction savedOutline(\n glyph: LaidOutGlyph,\n text: string,\n emoji: SavedEmoji | undefined,\n insideEmoji: boolean\n): OutlineCommand[] | null {\n if (insideEmoji) return []\n if (emoji) return emojiPlaceholder(glyph.fontSize)\n const character = glyph.firstCharacter\n if (character !== undefined && text[character] === COMBINING_KEYCAP)\n return keycapFrame(glyph.fontSize)\n return glyph.source?.outline(glyph.id, glyph.fontSize) ?? null\n}\n\n/**\n * Lay a text node out as the renderer draws it and pair each shaped glyph with the outline of\n * the glyph ID CanvasKit chose, so ligatures and contextual forms keep their shapes. An emoji the\n * layout gives the emoji metrics font is saved as Figma saves one: a placeholder square with its\n * code points. When a run's font cannot be told, no glyph gets an outline: the layout still\n * stands and Pairdraw lays the text out again on reading, but Figma draws it blank.\n * Returns `null` for text saved glyphs cannot represent at all.\n */\nexport function shapeText(\n ck: CanvasKit,\n fontProvider: TypefaceFontProvider,\n node: SceneNode\n): ShapedText | null {\n const text = shownText(node)\n if (!canShape(node, text)) return null\n\n const paragraph = buildParagraph({ ck, fontProvider, fontsLoaded: true }, node, undefined, {\n halfLeading: true\n })\n try {\n const offsetY = textVerticalOffset(node, paragraph.getHeight())\n const placed = laidOutGlyphs(node, paragraph, text, offsetY)\n if (!placed) return null\n const metrics = paragraph.getLineMetrics()\n const characterOffsets: Array<number | undefined> = Array.from({ length: text.length })\n // A sequence the font does not join is several glyphs: the first stands for the emoji, and\n // the rest keep their place and draw nothing. Glyphs come in visual order, so in\n // right-to-left text a character before the emoji can follow it: the whole range counts.\n let emojiRange = { start: 0, end: 0 }\n const glyphs: ShapedTextGlyph[] = placed.map((glyph) => {\n const start = glyph.firstCharacter\n if (start !== undefined) characterOffsets[start] ??= glyph.x - glyph.lineLeft\n const insideEmoji = start !== undefined && start > emojiRange.start && start < emojiRange.end\n const emoji = insideEmoji ? undefined : savedEmoji(node, text, glyph)\n if (emoji && start !== undefined) emojiRange = { start, end: emoji.end }\n return {\n commands: savedOutline(glyph, text, emoji, insideEmoji),\n x: glyph.x,\n y: glyph.y,\n fontSize: glyph.fontSize,\n firstCharacter: start,\n advance: glyph.advance,\n emojiCodePoints: emoji?.codePoints\n }\n })\n // Outlines from some runs only would draw the text with characters missing.\n const outlined = glyphs.every((glyph) => glyph.commands)\n return {\n glyphs: outlined ? glyphs : glyphs.map((glyph) => ({ ...glyph, commands: null })),\n // Figma saves no baseline for the empty line after a closing line break.\n baselines: metrics\n .filter((line, index) => index === 0 || line.startIndex < text.length)\n .map((line) => ({\n firstCharacter: line.startIndex,\n endCharacter: Math.min(line.endIncludingNewline, text.length),\n position: { x: line.left, y: line.baseline + offsetY },\n width: line.width,\n lineY: line.baseline - line.ascent + offsetY,\n lineHeight: line.height,\n lineAscent: line.ascent\n })),\n logicalIndexToCharacterOffsetMap: completeCharacterOffsets(characterOffsets)\n }\n } finally {\n paragraph.delete()\n }\n}\n\nfunction decoratedGlyph(glyph: PlacedTextGlyph): DecoratedGlyph {\n const { commandsBlob, commands } = glyph\n return {\n ...glyph,\n ink: (top, bottom) => {\n if (commandsBlob) return savedGlyphInk(commandsBlob, glyph, top, bottom)\n return commands ? outlineInk(commands, glyph.x, glyph.y, top, bottom) : null\n }\n }\n}\n\n/** Decorations as Figma saves them, over glyphs saved or just shaped. */\nfunction textDecorations(\n node: SceneNode,\n glyphs: readonly PlacedTextGlyph[]\n): TextDecorationRecord[] {\n return textDecorationRects(node, glyphs.map(decoratedGlyph)).map(\n ({ firstCharacter, x, y, width, height }) => ({ firstCharacter, x, y, width, height })\n )\n}\n\nfunction needsShaping(graph: SceneGraph): boolean {\n for (const node of graph.nodes.values()) {\n if (node.type === 'TEXT' && node.text && !node.derivedTextGlyphs?.length) return true\n }\n return false\n}\n\n/**\n * Run `use` with text shaped as the canvas lays it out, from the font provider the canvas of\n * `canvasKit` draws from, or one a caller attached and registered faces on for layout alone.\n * Each call holds a share of that provider, so overlapping calls shape from the same one and the\n * last to finish releases it; a provider with no share left is deleted.\n */\nexport async function withTextShaper<T>(\n canvasKit: CanvasKit,\n use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>\n): Promise<T> {\n const provider = fontManager.acquireProvider(canvasKit)\n try {\n return await use((node) => shapeText(canvasKit, provider, node))\n } finally {\n fontManager.releaseProvider(provider)\n }\n}\n\n/** Run a `.fig` or Figma clipboard write with text shaping. */\nexport async function withFigExportRuntime<T>(\n graph: SceneGraph,\n ck: CanvasKit | undefined,\n write: (runtime: FigNodeChangeExportRuntime) => Promise<T>\n): Promise<T> {\n const named = { textDecorations, fontStyleName: faceStyleName }\n if (!needsShaping(graph)) return write({ ...EMPTY_EXPORT_RUNTIME, ...named })\n return withTextShaper(ck ?? (await getCanvasKit()), (shapeText) => write({ shapeText, ...named }))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,SAAS,SAAS,MAAiB,MAAuB;CACxD,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,KAAK,UAAU,CAAC,KAAK;AAC3E;;AAGA,SAAS,yBAAyB,SAA8C;CAC9E,IAAI,WAAW;CACf,OAAO,QAAQ,KAAK,WAAW;EAC7B,WAAW,UAAU;EACrB,OAAO;CACT,CAAC;AACH;;;;;AAMA,SAAS,iBAAiB,MAAgC;CACxD,MAAM,SAAS,MAAO;CACtB,MAAM,MAAM,OAAQ;CACpB,OAAO;EACL;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAO;EAChC;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAI;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAI;EAC1B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B,EAAE,MAAM,IAAI;CACd;AACF;;;;;;AAaA,SAAS,WAAW,MAAiB,MAAc,OAA6C;CAC9F,MAAM,QAAQ,MAAM;CACpB,IAAI,UAAU,KAAA,KAAa,gBAAgB,MAAM,MAAM,KAAK,MAAA,0BAC1D,OAAO,KAAA;CACT,MAAM,MAAM,qBAAqB,MAAM,KAAK;CAC5C,MAAM,QAAQ,KAAK,MAAM,OAAO,GAAG;CACnC,MAAM,aAAa,MAAM,KAAK,QAAQ,cAAc,UAAU,YAAY,CAAC,KAAK,CAAC;CACjF,IAAI,WAAW,WAAW,KAAK,CAAC,0BAA0B,KAAK,KAAK,GAAG,WAAW,KAAK,KAAM;CAC7F,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A,eAAsB,eACpB,WACA,KACY;CACZ,MAAM,WAAW,YAAY,gBAAgB,SAAS;CACtD,IAAI;EACF,OAAO,MAAM,KAAK,SAAS,UAAU,WAAW,UAAU,IAAI,CAAC;CACjE,UAAU;EACR,YAAY,gBAAgB,QAAQ;CACtC;AACF;;AAGA,eAAsB,qBACpB,OACA,IACA,OACY;CACZ,MAAM,QAAQ;EAAE;EAAiB,eAAe;CAAc;CAC9D,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO,MAAM;EAAE,GAAG;EAAsB,GAAG;CAAM,CAAC;CAC5E,OAAO,eAAe,MAAO,MAAM,aAAa,IAAK,cAAc,MAAM;EAAE;EAAW,GAAG;CAAM,CAAC,CAAC;AACnG"}
|
|
1
|
+
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/canvas/text/shape.ts"],"sourcesContent":["import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport {\n EMPTY_EXPORT_RUNTIME,\n type FigNodeChangeExportRuntime,\n type PlacedTextGlyph,\n type ShapedText,\n type ShapedTextGlyph,\n type TextDecorationRecord\n} from '@pairdraw/fig/node-change'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { textVerticalOffset } from '@pairdraw/scene-graph/text'\n\nimport { buildParagraph } from '#core/canvas/text'\nimport { textDecorationRects, type DecoratedGlyph } from '#core/canvas/text/decorations'\nimport { outlineInk, savedGlyphInk } from '#core/canvas/text/ink'\nimport { COMBINING_KEYCAP, keycapFrame } from '#core/canvas/text/keycap'\nimport { characterFamily, laidOutGlyphs, type LaidOutGlyph } from '#core/canvas/text/placed'\nimport { getCanvasKit } from '#core/canvaskit'\nimport { shownText } from '#core/text/case'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { OutlineCommand } from '#core/text/font/glyphs'\nimport { faceStyleName } from '#core/text/font/names'\nimport { leaseFontProvider } from '#core/text/font/provider'\nimport { nextGraphemeBoundary } from '#core/text/graphemes'\n\n/**\n * Whether saved glyphs could stand for this text: case changes that alter its length move\n * glyphs off the characters they came from, and path text is placed along its path. Truncated\n * text saves the characters it shows and the ellipsis after them.\n */\nfunction canShape(node: SceneNode, text: string): boolean {\n return node.text.length > 0 && text.length === node.text.length && !node.textPathData\n}\n\n/** Characters inside a glyph cluster or without a glyph take the offset of the one before. */\nfunction completeCharacterOffsets(offsets: Array<number | undefined>): number[] {\n let previous = 0\n return offsets.map((offset) => {\n previous = offset ?? previous\n return previous\n })\n}\n\n/**\n * The square Figma saves for an emoji, in pixels at `size` with y down: 1 em wide, from 0.07 em\n * below the baseline, closed with a line back to its start as Figma writes it.\n */\nfunction emojiPlaceholder(size: number): OutlineCommand[] {\n const bottom = 0.07 * size\n const top = -0.93 * size\n return [\n { type: 'M', x: 0, y: bottom },\n { type: 'L', x: size, y: bottom },\n { type: 'L', x: size, y: top },\n { type: 'L', x: 0, y: top },\n { type: 'L', x: 0, y: bottom },\n { type: 'Z' }\n ]\n}\n\ninterface SavedEmoji {\n codePoints: number[]\n /** Where the emoji's characters end in the text. */\n end: number\n}\n\n/**\n * The emoji a glyph starts, as Figma saves it, when the layout gave it to the emoji metrics font:\n * its code points, an emoji that shows as text by default with the selector that asks for its\n * emoji form, as Figma saves ☺ as ☺️.\n */\nfunction savedEmoji(node: SceneNode, text: string, glyph: LaidOutGlyph): SavedEmoji | undefined {\n const start = glyph.firstCharacter\n if (start === undefined || characterFamily(node, text, start) !== EMOJI_METRICS_FAMILY)\n return undefined\n const end = nextGraphemeBoundary(text, start)\n const emoji = text.slice(start, end)\n const codePoints = Array.from(emoji, (character) => character.codePointAt(0) ?? 0)\n if (codePoints.length === 1 && !/\\p{Emoji_Presentation}/u.test(emoji)) codePoints.push(0xfe0f)\n return { codePoints, end }\n}\n\n/**\n * A glyph's saved outline: an emoji's placeholder, nothing inside one, a keycap's frame, or its\n * font's outline.\n */\nfunction savedOutline(\n glyph: LaidOutGlyph,\n text: string,\n emoji: SavedEmoji | undefined,\n insideEmoji: boolean\n): OutlineCommand[] | null {\n if (insideEmoji) return []\n if (emoji) return emojiPlaceholder(glyph.fontSize)\n const character = glyph.firstCharacter\n if (character !== undefined && text[character] === COMBINING_KEYCAP)\n return keycapFrame(glyph.fontSize)\n return glyph.source?.outline(glyph.id, glyph.fontSize) ?? null\n}\n\n/**\n * Lay a text node out as the renderer draws it and pair each shaped glyph with the outline of\n * the glyph ID CanvasKit chose, so ligatures and contextual forms keep their shapes. An emoji the\n * layout gives the emoji metrics font is saved as Figma saves one: a placeholder square with its\n * code points. When a run's font cannot be told, no glyph gets an outline: the layout still\n * stands and Pairdraw lays the text out again on reading, but Figma draws it blank.\n * Returns `null` for text saved glyphs cannot represent at all.\n */\nexport function shapeText(\n ck: CanvasKit,\n fontProvider: TypefaceFontProvider,\n node: SceneNode\n): ShapedText | null {\n const text = shownText(node)\n if (!canShape(node, text)) return null\n\n const paragraph = buildParagraph({ ck, fontProvider, fontsLoaded: true }, node, undefined, {\n halfLeading: true\n })\n try {\n const offsetY = textVerticalOffset(node, paragraph.getHeight())\n const placed = laidOutGlyphs(node, paragraph, text, offsetY)\n if (!placed) return null\n const metrics = paragraph.getLineMetrics()\n const characterOffsets: Array<number | undefined> = Array.from({ length: text.length })\n // A sequence the font does not join is several glyphs: the first stands for the emoji, and\n // the rest keep their place and draw nothing. Glyphs come in visual order, so in\n // right-to-left text a character before the emoji can follow it: the whole range counts.\n let emojiRange = { start: 0, end: 0 }\n const glyphs: ShapedTextGlyph[] = placed.map((glyph) => {\n const start = glyph.firstCharacter\n if (start !== undefined) characterOffsets[start] ??= glyph.x - glyph.lineLeft\n const insideEmoji = start !== undefined && start > emojiRange.start && start < emojiRange.end\n const emoji = insideEmoji ? undefined : savedEmoji(node, text, glyph)\n if (emoji && start !== undefined) emojiRange = { start, end: emoji.end }\n return {\n commands: savedOutline(glyph, text, emoji, insideEmoji),\n x: glyph.x,\n y: glyph.y,\n fontSize: glyph.fontSize,\n firstCharacter: start,\n advance: glyph.advance,\n emojiCodePoints: emoji?.codePoints\n }\n })\n // Outlines from some runs only would draw the text with characters missing.\n const outlined = glyphs.every((glyph) => glyph.commands)\n return {\n glyphs: outlined ? glyphs : glyphs.map((glyph) => ({ ...glyph, commands: null })),\n // Figma saves no baseline for the empty line after a closing line break.\n baselines: metrics\n .filter((line, index) => index === 0 || line.startIndex < text.length)\n .map((line) => ({\n firstCharacter: line.startIndex,\n endCharacter: Math.min(line.endIncludingNewline, text.length),\n position: { x: line.left, y: line.baseline + offsetY },\n width: line.width,\n lineY: line.baseline - line.ascent + offsetY,\n lineHeight: line.height,\n lineAscent: line.ascent\n })),\n logicalIndexToCharacterOffsetMap: completeCharacterOffsets(characterOffsets)\n }\n } finally {\n paragraph.delete()\n }\n}\n\nfunction decoratedGlyph(glyph: PlacedTextGlyph): DecoratedGlyph {\n const { commandsBlob, commands } = glyph\n return {\n ...glyph,\n ink: (top, bottom) => {\n if (commandsBlob) return savedGlyphInk(commandsBlob, glyph, top, bottom)\n return commands ? outlineInk(commands, glyph.x, glyph.y, top, bottom) : null\n }\n }\n}\n\n/** Decorations as Figma saves them, over glyphs saved or just shaped. */\nfunction textDecorations(\n node: SceneNode,\n glyphs: readonly PlacedTextGlyph[]\n): TextDecorationRecord[] {\n return textDecorationRects(node, glyphs.map(decoratedGlyph)).map(\n ({ firstCharacter, x, y, width, height }) => ({ firstCharacter, x, y, width, height })\n )\n}\n\nfunction needsShaping(graph: SceneGraph): boolean {\n for (const node of graph.nodes.values()) {\n if (node.type === 'TEXT' && node.text && !node.derivedTextGlyphs?.length) return true\n }\n return false\n}\n\n/**\n * Run `use` with text shaped as the canvas lays it out, from the font provider the canvas of\n * `canvasKit` draws from, or one a caller attached and registered faces on for layout alone.\n * Each call holds a share of that provider, so overlapping calls shape from the same one and the\n * last to finish releases it; a provider with no share left is deleted.\n */\nexport async function withTextShaper<T>(\n canvasKit: CanvasKit,\n use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>\n): Promise<T> {\n const lease = leaseFontProvider(canvasKit)\n try {\n return await use((node) => shapeText(canvasKit, lease.provider, node))\n } finally {\n lease.release()\n }\n}\n\n/** Run a `.fig` or Figma clipboard write with text shaping. */\nexport async function withFigExportRuntime<T>(\n graph: SceneGraph,\n ck: CanvasKit | undefined,\n write: (runtime: FigNodeChangeExportRuntime) => Promise<T>\n): Promise<T> {\n const named = { textDecorations, fontStyleName: faceStyleName }\n if (!needsShaping(graph)) return write({ ...EMPTY_EXPORT_RUNTIME, ...named })\n return withTextShaper(ck ?? (await getCanvasKit()), (shapeText) => write({ shapeText, ...named }))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,SAAS,SAAS,MAAiB,MAAuB;CACxD,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,KAAK,UAAU,CAAC,KAAK;AAC3E;;AAGA,SAAS,yBAAyB,SAA8C;CAC9E,IAAI,WAAW;CACf,OAAO,QAAQ,KAAK,WAAW;EAC7B,WAAW,UAAU;EACrB,OAAO;CACT,CAAC;AACH;;;;;AAMA,SAAS,iBAAiB,MAAgC;CACxD,MAAM,SAAS,MAAO;CACtB,MAAM,MAAM,OAAQ;CACpB,OAAO;EACL;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAO;EAChC;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAI;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAI;EAC1B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B,EAAE,MAAM,IAAI;CACd;AACF;;;;;;AAaA,SAAS,WAAW,MAAiB,MAAc,OAA6C;CAC9F,MAAM,QAAQ,MAAM;CACpB,IAAI,UAAU,KAAA,KAAa,gBAAgB,MAAM,MAAM,KAAK,MAAA,0BAC1D,OAAO,KAAA;CACT,MAAM,MAAM,qBAAqB,MAAM,KAAK;CAC5C,MAAM,QAAQ,KAAK,MAAM,OAAO,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AAS,aAAa,OAA4B;CAChD,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,GACpC,IAAI,KAAK,SAAS,UAAU,KAAK,QAAQ,CAAC,KAAK,mBAAmB,QAAQ,OAAO;CAEnF,OAAO;AACT;;;;;;;AAQA,eAAsB,eACpB,WACA,KACY;CACZ,MAAM,QAAQ,kBAAkB,SAAS;CACzC,IAAI;EACF,OAAO,MAAM,KAAK,SAAS,UAAU,WAAW,MAAM,UAAU,IAAI,CAAC;CACvE,UAAU;EACR,MAAM,QAAQ;CAChB;AACF;;AAGA,eAAsB,qBACpB,OACA,IACA,OACY;CACZ,MAAM,QAAQ;EAAE;EAAiB,eAAe;CAAc;CAC9D,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO,MAAM;EAAE,GAAG;EAAsB,GAAG;CAAM,CAAC;CAC5E,OAAO,eAAe,MAAO,MAAM,aAAa,IAAK,cAAc,MAAM;EAAE;EAAW,GAAG;CAAM,CAAC,CAAC;AACnG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SkiaRenderer } from "./renderer.js";
|
|
2
|
+
import { Canvas, Image } from "canvaskit-wasm";
|
|
3
|
+
import { SceneNode, TextureEffect } from "@pairdraw/scene-graph";
|
|
4
|
+
//#region src/canvas/texture.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The displacement tile for a texture: red and green as independent smooth noise one grain to a
|
|
7
|
+
* cycle, as `feTurbulence` writes them, cached by grain size and seed.
|
|
8
|
+
*/
|
|
9
|
+
declare function textureDisplacementTile(r: SkiaRenderer, texture: TextureEffect, seed: number): Image | null;
|
|
10
|
+
/** The first visible texture effect on a layer, which roughens its edges. */
|
|
11
|
+
declare function textureEffectOf(node: SceneNode): TextureEffect | null;
|
|
12
|
+
/**
|
|
13
|
+
* Draws a layer's content through the displacement of its texture effect: the noise moves each
|
|
14
|
+
* pixel by up to `radius`, as Figma's filter does, and `clipToShape` keeps the moved pixels inside
|
|
15
|
+
* the layer's box. Returns false when there is no texture to draw, so a caller draws as usual.
|
|
16
|
+
*/
|
|
17
|
+
declare function withTextureEffect(r: SkiaRenderer, canvas: Canvas, node: SceneNode, draw: () => void): boolean;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { textureDisplacementTile, textureEffectOf, withTextureEffect };
|
|
20
|
+
//# sourceMappingURL=texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.d.ts","names":[],"sources":["../../src/canvas/texture.ts"],"mappings":";;;;;;;;iBA2CgB,wBACd,GAAG,cACH,SAAS,eACT,eACC;;iBAkCa,gBAAgB,MAAM,YAAY;;;;;;iBAYlC,kBACd,GAAG,cACH,QAAQ,QACR,MAAM,WACN"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { skColorSpace } from "./renderer/colors.js";
|
|
2
|
+
import { cellValue } from "./noise/tile.js";
|
|
3
|
+
//#region src/canvas/texture.ts
|
|
4
|
+
/** Cells on each side of a texture's displacement tile; it repeats beyond them. */
|
|
5
|
+
const TEXTURE_TILE_CELLS = 256;
|
|
6
|
+
function smooth(t) {
|
|
7
|
+
return t * t * (3 - 2 * t);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A cell's red or green displacement as smooth noise over `frequency` cells, sampled where the
|
|
11
|
+
* layer's pixels are: one cycle per grain, and tileable because the corners wrap.
|
|
12
|
+
*/
|
|
13
|
+
function displacement(x, y, frequency, seed, salt) {
|
|
14
|
+
const gx = x * frequency;
|
|
15
|
+
const gy = y * frequency;
|
|
16
|
+
const x0 = Math.floor(gx);
|
|
17
|
+
const y0 = Math.floor(gy);
|
|
18
|
+
const x1 = (x0 + 1) % TEXTURE_TILE_CELLS;
|
|
19
|
+
const y1 = (y0 + 1) % TEXTURE_TILE_CELLS;
|
|
20
|
+
const tx = smooth(gx - x0);
|
|
21
|
+
const ty = smooth(gy - y0);
|
|
22
|
+
const wrap = (value) => (value % TEXTURE_TILE_CELLS + TEXTURE_TILE_CELLS) % TEXTURE_TILE_CELLS;
|
|
23
|
+
const v00 = cellValue(wrap(x0), wrap(y0), seed, salt);
|
|
24
|
+
const v10 = cellValue(x1, wrap(y0), seed, salt);
|
|
25
|
+
const v01 = cellValue(wrap(x0), y1, seed, salt);
|
|
26
|
+
const v11 = cellValue(x1, y1, seed, salt);
|
|
27
|
+
const top = v00 + (v10 - v00) * tx;
|
|
28
|
+
return top + (v01 + (v11 - v01) * tx - top) * ty;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The displacement tile for a texture: red and green as independent smooth noise one grain to a
|
|
32
|
+
* cycle, as `feTurbulence` writes them, cached by grain size and seed.
|
|
33
|
+
*/
|
|
34
|
+
function textureDisplacementTile(r, texture, seed) {
|
|
35
|
+
const frequency = (size) => size > 0 ? 1 / size : 0;
|
|
36
|
+
const fx = frequency(texture.texture.noiseSize.x);
|
|
37
|
+
const fy = frequency(texture.texture.noiseSize.y);
|
|
38
|
+
const key = `texture:${fx}:${fy}:${seed}`;
|
|
39
|
+
const kept = r.textureNoiseCache.get(key);
|
|
40
|
+
if (kept) return kept;
|
|
41
|
+
const pixels = new Uint8Array(TEXTURE_TILE_CELLS * TEXTURE_TILE_CELLS * 4);
|
|
42
|
+
for (let y = 0; y < TEXTURE_TILE_CELLS; y++) for (let x = 0; x < TEXTURE_TILE_CELLS; x++) {
|
|
43
|
+
const at = (y * TEXTURE_TILE_CELLS + x) * 4;
|
|
44
|
+
pixels[at] = Math.floor(displacement(x, y, fx, seed, 1) * 256);
|
|
45
|
+
pixels[at + 1] = Math.floor(displacement(x, y, fy, seed, 2) * 256);
|
|
46
|
+
pixels[at + 2] = 0;
|
|
47
|
+
pixels[at + 3] = 255;
|
|
48
|
+
}
|
|
49
|
+
const image = r.ck.MakeImage({
|
|
50
|
+
width: TEXTURE_TILE_CELLS,
|
|
51
|
+
height: TEXTURE_TILE_CELLS,
|
|
52
|
+
alphaType: r.ck.AlphaType.Unpremul,
|
|
53
|
+
colorType: r.ck.ColorType.RGBA_8888,
|
|
54
|
+
colorSpace: skColorSpace(r.ck, r.documentColorSpace)
|
|
55
|
+
}, pixels, TEXTURE_TILE_CELLS * 4);
|
|
56
|
+
if (!image) return null;
|
|
57
|
+
r.textureNoiseCache.set(key, image);
|
|
58
|
+
return image;
|
|
59
|
+
}
|
|
60
|
+
/** The first visible texture effect on a layer, which roughens its edges. */
|
|
61
|
+
function textureEffectOf(node) {
|
|
62
|
+
for (const effect of node.effects) if (effect.visible && effect.type === "TEXTURE" && effect.radius > 0) return effect;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Draws a layer's content through the displacement of its texture effect: the noise moves each
|
|
67
|
+
* pixel by up to `radius`, as Figma's filter does, and `clipToShape` keeps the moved pixels inside
|
|
68
|
+
* the layer's box. Returns false when there is no texture to draw, so a caller draws as usual.
|
|
69
|
+
*/
|
|
70
|
+
function withTextureEffect(r, canvas, node, draw) {
|
|
71
|
+
const texture = textureEffectOf(node);
|
|
72
|
+
if (!texture) return false;
|
|
73
|
+
const tile = textureDisplacementTile(r, texture, texture.texture.seed ?? 0);
|
|
74
|
+
if (!tile) return false;
|
|
75
|
+
const repeat = r.ck.TileMode.Repeat;
|
|
76
|
+
const shader = tile.makeShaderOptions(repeat, repeat, r.ck.FilterMode.Linear, r.ck.MipmapMode.None);
|
|
77
|
+
const displacement = r.ck.ImageFilter.MakeShader(shader);
|
|
78
|
+
const filter = r.ck.ImageFilter.MakeDisplacementMap(r.ck.ColorChannel.Red, r.ck.ColorChannel.Green, texture.radius * 2, displacement, null);
|
|
79
|
+
const paint = new r.ck.Paint();
|
|
80
|
+
try {
|
|
81
|
+
paint.setImageFilter(filter);
|
|
82
|
+
const rect = r.ck.LTRBRect(0, 0, node.width, node.height);
|
|
83
|
+
if (texture.texture.clipToShape) r.clipNodeShape(canvas, node);
|
|
84
|
+
canvas.saveLayer(paint, rect);
|
|
85
|
+
try {
|
|
86
|
+
draw();
|
|
87
|
+
} finally {
|
|
88
|
+
canvas.restore();
|
|
89
|
+
}
|
|
90
|
+
} finally {
|
|
91
|
+
paint.delete();
|
|
92
|
+
filter.delete();
|
|
93
|
+
displacement.delete();
|
|
94
|
+
shader.delete();
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { textureDisplacementTile, textureEffectOf, withTextureEffect };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.js","names":[],"sources":["../../src/canvas/texture.ts"],"sourcesContent":["import type { Canvas, Image, ImageFilter, Shader } from 'canvaskit-wasm'\n\nimport type { SceneNode, TextureEffect } from '@pairdraw/scene-graph'\n\nimport { cellValue } from './noise/tile'\nimport type { SkiaRenderer } from './renderer'\nimport { skColorSpace } from './renderer/colors'\n\n/** Cells on each side of a texture's displacement tile; it repeats beyond them. */\nconst TEXTURE_TILE_CELLS = 256\n\nfunction smooth(t: number): number {\n return t * t * (3 - 2 * t)\n}\n\n/**\n * A cell's red or green displacement as smooth noise over `frequency` cells, sampled where the\n * layer's pixels are: one cycle per grain, and tileable because the corners wrap.\n */\nfunction displacement(x: number, y: number, frequency: number, seed: number, salt: number): number {\n const gx = x * frequency\n const gy = y * frequency\n const x0 = Math.floor(gx)\n const y0 = Math.floor(gy)\n const x1 = (x0 + 1) % TEXTURE_TILE_CELLS\n const y1 = (y0 + 1) % TEXTURE_TILE_CELLS\n const tx = smooth(gx - x0)\n const ty = smooth(gy - y0)\n const wrap = (value: number) =>\n ((value % TEXTURE_TILE_CELLS) + TEXTURE_TILE_CELLS) % TEXTURE_TILE_CELLS\n const v00 = cellValue(wrap(x0), wrap(y0), seed, salt)\n const v10 = cellValue(x1, wrap(y0), seed, salt)\n const v01 = cellValue(wrap(x0), y1, seed, salt)\n const v11 = cellValue(x1, y1, seed, salt)\n const top = v00 + (v10 - v00) * tx\n const bottom = v01 + (v11 - v01) * tx\n return top + (bottom - top) * ty\n}\n\n/**\n * The displacement tile for a texture: red and green as independent smooth noise one grain to a\n * cycle, as `feTurbulence` writes them, cached by grain size and seed.\n */\nexport function textureDisplacementTile(\n r: SkiaRenderer,\n texture: TextureEffect,\n seed: number\n): Image | null {\n const frequency = (size: number) => (size > 0 ? 1 / size : 0)\n const fx = frequency(texture.texture.noiseSize.x)\n const fy = frequency(texture.texture.noiseSize.y)\n const key = `texture:${fx}:${fy}:${seed}`\n const kept = r.textureNoiseCache.get(key)\n if (kept) return kept\n const pixels = new Uint8Array(TEXTURE_TILE_CELLS * TEXTURE_TILE_CELLS * 4)\n for (let y = 0; y < TEXTURE_TILE_CELLS; y++) {\n for (let x = 0; x < TEXTURE_TILE_CELLS; x++) {\n const at = (y * TEXTURE_TILE_CELLS + x) * 4\n pixels[at] = Math.floor(displacement(x, y, fx, seed, 1) * 256)\n pixels[at + 1] = Math.floor(displacement(x, y, fy, seed, 2) * 256)\n pixels[at + 2] = 0\n pixels[at + 3] = 255\n }\n }\n const image = r.ck.MakeImage(\n {\n width: TEXTURE_TILE_CELLS,\n height: TEXTURE_TILE_CELLS,\n alphaType: r.ck.AlphaType.Unpremul,\n colorType: r.ck.ColorType.RGBA_8888,\n colorSpace: skColorSpace(r.ck, r.documentColorSpace)\n },\n pixels,\n TEXTURE_TILE_CELLS * 4\n )\n if (!image) return null\n r.textureNoiseCache.set(key, image)\n return image\n}\n\n/** The first visible texture effect on a layer, which roughens its edges. */\nexport function textureEffectOf(node: SceneNode): TextureEffect | null {\n for (const effect of node.effects) {\n if (effect.visible && effect.type === 'TEXTURE' && effect.radius > 0) return effect\n }\n return null\n}\n\n/**\n * Draws a layer's content through the displacement of its texture effect: the noise moves each\n * pixel by up to `radius`, as Figma's filter does, and `clipToShape` keeps the moved pixels inside\n * the layer's box. Returns false when there is no texture to draw, so a caller draws as usual.\n */\nexport function withTextureEffect(\n r: SkiaRenderer,\n canvas: Canvas,\n node: SceneNode,\n draw: () => void\n): boolean {\n const texture = textureEffectOf(node)\n if (!texture) return false\n const tile = textureDisplacementTile(r, texture, texture.texture.seed ?? 0)\n if (!tile) return false\n const repeat = r.ck.TileMode.Repeat\n const shader: Shader = tile.makeShaderOptions(\n repeat,\n repeat,\n r.ck.FilterMode.Linear,\n r.ck.MipmapMode.None\n )\n const displacement: ImageFilter = r.ck.ImageFilter.MakeShader(shader)\n const filter: ImageFilter = r.ck.ImageFilter.MakeDisplacementMap(\n r.ck.ColorChannel.Red,\n r.ck.ColorChannel.Green,\n texture.radius * 2,\n displacement,\n null\n )\n const paint = new r.ck.Paint()\n try {\n paint.setImageFilter(filter)\n const rect = r.ck.LTRBRect(0, 0, node.width, node.height)\n if (texture.texture.clipToShape) r.clipNodeShape(canvas, node)\n canvas.saveLayer(paint, rect)\n try {\n draw()\n } finally {\n canvas.restore()\n }\n } finally {\n paint.delete()\n filter.delete()\n displacement.delete()\n shader.delete()\n }\n return true\n}\n"],"mappings":";;;;AASA,MAAM,qBAAqB;AAE3B,SAAS,OAAO,GAAmB;CACjC,OAAO,IAAI,KAAK,IAAI,IAAI;AAC1B;;;;;AAMA,SAAS,aAAa,GAAW,GAAW,WAAmB,MAAc,MAAsB;CACjG,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,IAAI;CACf,MAAM,KAAK,KAAK,MAAM,EAAE;CACxB,MAAM,KAAK,KAAK,MAAM,EAAE;CACxB,MAAM,MAAM,KAAK,KAAK;CACtB,MAAM,MAAM,KAAK,KAAK;CACtB,MAAM,KAAK,OAAO,KAAK,EAAE;CACzB,MAAM,KAAK,OAAO,KAAK,EAAE;CACzB,MAAM,QAAQ,WACV,QAAQ,qBAAsB,sBAAsB;CACxD,MAAM,MAAM,UAAU,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,IAAI;CACpD,MAAM,MAAM,UAAU,IAAI,KAAK,EAAE,GAAG,MAAM,IAAI;CAC9C,MAAM,MAAM,UAAU,KAAK,EAAE,GAAG,IAAI,MAAM,IAAI;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Aa,OAAO,SAAS,GAAG,OAAO;CAE/E,OAAO;AACT;;;;;;AAOA,SAAgB,kBACd,GACA,QACA,MACA,MACS;CACT,MAAM,UAAU,gBAAgB,IAAI;CACpC,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,OAAO,wBAAwB,GAAG,SAAS,QAAQ,QAAQ,QAAQ,CAAC;CAC1E,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,SAAS,EAAE,GAAG,SAAS;CAC7B,MAAM,SAAiB,KAAK,kBAC1B,QACA,QACA,EAAE,GAAG,WAAW,QAChB,EAAE,GAAG,WAAW,IAClB;CACA,MAAM,eAA4B,EAAE,GAAG,YAAY,WAAW,MAAM;CACpE,MAAM,SAAsB,EAAE,GAAG,YAAY,oBAC3C,EAAE,GAAG,aAAa,KAClB,EAAE,GAAG,aAAa,OAClB,QAAQ,SAAS,GACjB,cACA,IACF;CACA,MAAM,QAAQ,IAAI,EAAE,GAAG,MAAM;CAC7B,IAAI;EACF,MAAM,eAAe,MAAM;EAC3B,MAAM,OAAO,EAAE,GAAG,SAAS,GAAG,GAAG,KAAK,OAAO,KAAK,MAAM;EACxD,IAAI,QAAQ,QAAQ,aAAa,EAAE,cAAc,QAAQ,IAAI;EAC7D,OAAO,UAAU,OAAO,IAAI;EAC5B,IAAI;GACF,KAAK;EACP,UAAU;GACR,OAAO,QAAQ;EACjB;CACF,UAAU;EACR,MAAM,OAAO;EACb,OAAO,OAAO;EACd,aAAa,OAAO;EACpB,OAAO,OAAO;CAChB;CACA,OAAO;AACT"}
|
package/dist/clipboard.js
CHANGED
|
@@ -72,6 +72,7 @@ async function writeFigmaClipboardHTML(nodes, graph, runtime, assetType) {
|
|
|
72
72
|
const blobs = [];
|
|
73
73
|
const variableIds = /* @__PURE__ */ new Map();
|
|
74
74
|
const modeIds = /* @__PURE__ */ new Map();
|
|
75
|
+
const propertyIdToGuid = /* @__PURE__ */ new Map();
|
|
75
76
|
assignVariableGuids(graph, localIdCounter, variableIds, modeIds, assignedGuidValues, layerSourceGuids(graph));
|
|
76
77
|
assignSharedStyleGuids([...graph.nodes.values()].filter((node) => node.sharedStyleType !== null), localIdCounter, nodeIdToGuid, assignedGuidValues);
|
|
77
78
|
const slotContentRecords = [];
|
|
@@ -83,6 +84,7 @@ async function writeFigmaClipboardHTML(nodes, graph, runtime, assetType) {
|
|
|
83
84
|
varIdToGuid: variableIds,
|
|
84
85
|
assignedGuidValues,
|
|
85
86
|
modeIdToGuid: modeIds,
|
|
87
|
+
propertyIdToGuid,
|
|
86
88
|
slotContentRecords,
|
|
87
89
|
runtime
|
|
88
90
|
}));
|
|
@@ -95,11 +97,19 @@ async function writeFigmaClipboardHTML(nodes, graph, runtime, assetType) {
|
|
|
95
97
|
};
|
|
96
98
|
for (const node of nodes) mark(node);
|
|
97
99
|
const visitDependencies = (node) => {
|
|
98
|
-
if (node.type === "INSTANCE" && node.componentId
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
if (node.type === "INSTANCE" && node.componentId) {
|
|
101
|
+
let componentId = node.componentId;
|
|
102
|
+
const seen = /* @__PURE__ */ new Set();
|
|
103
|
+
let component = graph.getNode(componentId);
|
|
104
|
+
while (component?.type === "INSTANCE" && component.componentId && !seen.has(component.id)) {
|
|
105
|
+
seen.add(component.id);
|
|
106
|
+
componentId = component.componentId;
|
|
107
|
+
component = graph.getNode(componentId);
|
|
108
|
+
}
|
|
109
|
+
if (component && (component.type === "COMPONENT" || component.type === "COMPONENT_SET") && !selected.has(component.id) && !dependencies.has(component.id)) {
|
|
110
|
+
dependencies.set(component.id, component);
|
|
111
|
+
visitDependencies(component);
|
|
112
|
+
}
|
|
103
113
|
}
|
|
104
114
|
for (const child of graph.getChildren(node.id)) visitDependencies(child);
|
|
105
115
|
};
|
|
@@ -125,6 +135,7 @@ async function writeFigmaClipboardHTML(nodes, graph, runtime, assetType) {
|
|
|
125
135
|
varIdToGuid: variableIds,
|
|
126
136
|
assignedGuidValues,
|
|
127
137
|
modeIdToGuid: modeIds,
|
|
138
|
+
propertyIdToGuid,
|
|
128
139
|
slotContentRecords,
|
|
129
140
|
runtime
|
|
130
141
|
}));
|
package/dist/clipboard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":[],"sources":["../src/clipboard.ts"],"sourcesContent":["import {\n embedClipboardImages,\n encodeFigmaClipboard,\n type FigmaClipboardAssetType\n} from '@pairdraw/fig/clipboard'\nimport {\n figmaLineHeight,\n placeSlotContent,\n relinkConnectorEnds,\n type FigNodeChangeExportRuntime,\n sceneNodeToKiwi,\n makeDocumentNodeChange,\n makeCanvasNodeChange\n} from '@pairdraw/fig/node-change'\nimport type { GUID } from '@pairdraw/kiwi/fig'\nimport { initCodec, type NodeChange as KiwiNodeChange } from '@pairdraw/kiwi/fig/codec'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { derivedAssetKey, derivedAssetVersion } from '@pairdraw/scene-graph/asset-keys'\nimport { fractionalPosition } from '@pairdraw/scene-graph/order-keys'\nimport { randomInt } from '@pairdraw/scene-graph/random'\nimport { ownsSlotContent } from '@pairdraw/scene-graph/slots'\n\nimport {\n collectComponentPropertyIds,\n firstUnclaimedLocalId,\n layerSourceGuids\n} from '#core/io/formats/fig/export/setup'\nimport {\n appendVariableNodeChanges,\n assignSharedStyleGuids,\n assignVariableGuids\n} from '#core/io/formats/fig/export/variables'\n\nimport { withFigExportRuntime } from './canvas/text/shape'\nimport { prepareClipboardImport } from './clipboard/fig-import'\nimport { buildFontDigestMap } from './kiwi/fig/node-change/serialize'\nimport { cloneSceneGraphForFigExport } from './kiwi/fig/parse/transfer'\n\nexport async function prefetchFigmaSchema(): Promise<void> {\n await initCodec()\n}\n\nexport function importClipboardNodes(\n nodeChanges: KiwiNodeChange[],\n graph: SceneGraph,\n targetParentId: string,\n offsetX = 0,\n offsetY = 0,\n blobs: Uint8Array[] = []\n): string[] {\n const operation = prepareClipboardImport(\n nodeChanges,\n graph,\n targetParentId,\n blobs,\n offsetX,\n offsetY\n )\n operation.commit()\n return operation.plan.rootIds\n}\n\n/**\n * The document as the clipboard writes it. Figma names the variables and collections a paste\n * uses by key, and keeps a binding to one it knows only by key as a remote variable, as it does\n * for its own clipboard; variables made in Pairdraw have no key, so they take one derived from\n * their ID here, for this copy only. Figma keeps the first value it pasted for a key and version,\n * so the version follows their content and an edited variable pastes with its new value.\n */\nfunction clipboardGraph(graph: SceneGraph): SceneGraph {\n const unkeyed =\n [...graph.variables.values()].some((variable) => !variable.key) ||\n [...graph.variableCollections.values()].some((collection) => !collection.key)\n if (!unkeyed) return graph\n const copy = cloneSceneGraphForFigExport(graph)\n copy.variableCollections = new Map(\n [...graph.variableCollections].map(([id, collection]) => [\n id,\n collection.key\n ? collection\n : {\n ...collection,\n key: derivedAssetKey(`collection:${id}`),\n version: derivedAssetVersion(JSON.stringify(collection))\n }\n ])\n )\n copy.variables = new Map(\n [...graph.variables].map(([id, variable]) => [\n id,\n variable.key\n ? variable\n : {\n ...variable,\n key: derivedAssetKey(`variable:${id}`),\n version: derivedAssetVersion(JSON.stringify(variable))\n }\n ])\n )\n return copy\n}\n\nexport function buildFigmaClipboardHTML(\n nodes: SceneNode[],\n graph: SceneGraph,\n assetType: FigmaClipboardAssetType = 'UNKNOWN'\n): Promise<string | null> {\n const written = clipboardGraph(graph)\n return withFigExportRuntime(written, undefined, (runtime) =>\n writeFigmaClipboardHTML(nodes, written, runtime, assetType)\n )\n}\n\nasync function writeFigmaClipboardHTML(\n nodes: SceneNode[],\n graph: SceneGraph,\n runtime: FigNodeChangeExportRuntime,\n assetType: FigmaClipboardAssetType\n): Promise<string | null> {\n const fontDigestMap = await buildFontDigestMap(graph)\n\n const docGuid = { sessionID: 0, localID: 0 }\n const canvasGuid = { sessionID: 0, localID: 1 }\n // Above every GUID the graph claims, as the document exporter starts, so no record collides.\n const localIdCounter = {\n value: Math.max(100, firstUnclaimedLocalId(graph, collectComponentPropertyIds(graph)))\n }\n\n const nodeChanges: KiwiNodeChange[] = [\n makeDocumentNodeChange(docGuid, graph.documentColorSpace),\n makeCanvasNodeChange(canvasGuid, docGuid, '!', 'Page 1')\n ]\n\n const exportedTextNodes: SceneNode[] = []\n const collectTextNodes = (node: SceneNode) => {\n if (node.type === 'TEXT') exportedTextNodes.push(node)\n for (const childId of node.childIds) {\n const child = graph.getNode(childId)\n if (child) collectTextNodes(child)\n }\n }\n\n const nodeIdToGuid = new Map<string, GUID>()\n const assignedGuidValues = new Set<string>()\n const blobs: Uint8Array[] = []\n const variableIds = new Map<string, GUID>()\n const modeIds = new Map<string, GUID>()\n assignVariableGuids(\n graph,\n localIdCounter,\n variableIds,\n modeIds,\n assignedGuidValues,\n layerSourceGuids(graph)\n )\n assignSharedStyleGuids(\n [...graph.nodes.values()].filter((node) => node.sharedStyleType !== null),\n localIdCounter,\n nodeIdToGuid,\n assignedGuidValues\n )\n const slotContentRecords: KiwiNodeChange[] = []\n for (let i = 0; i < nodes.length; i++) {\n collectTextNodes(nodes[i])\n nodeChanges.push(\n ...sceneNodeToKiwi(nodes[i], canvasGuid, i, localIdCounter, graph, blobs, {\n nodeIdToGuid,\n fontDigestMap,\n varIdToGuid: variableIds,\n assignedGuidValues,\n modeIdToGuid: modeIds,\n slotContentRecords,\n runtime\n })\n )\n }\n\n const dependencies = new Map<string, SceneNode>()\n const selected = new Set<string>()\n const mark = (node: SceneNode): void => {\n selected.add(node.id)\n for (const child of graph.getChildren(node.id)) mark(child)\n }\n for (const node of nodes) mark(node)\n const visitDependencies = (node: SceneNode): void => {\n if (\n node.type === 'INSTANCE' &&\n node.componentId &&\n !selected.has(node.componentId) &&\n !dependencies.has(node.componentId)\n ) {\n const component = graph.getNode(node.componentId)\n if (!component) throw new Error(`Missing clipboard component ${node.componentId}`)\n dependencies.set(component.id, component)\n visitDependencies(component)\n }\n for (const child of graph.getChildren(node.id)) visitDependencies(child)\n }\n for (const node of nodes) visitDependencies(node)\n for (const node of graph.getAllNodes())\n if (node.sharedStyleType && !selected.has(node.id)) dependencies.set(node.id, node)\n const dependencyCanvas = { sessionID: 0, localID: 2 }\n const hasSlotContent = [...selected].some((id) => {\n const node = graph.getNode(id)\n return !!node && ownsSlotContent(graph, node)\n })\n if (dependencies.size || graph.variableCollections.size || hasSlotContent)\n nodeChanges.push({\n ...makeCanvasNodeChange(dependencyCanvas, docGuid, '\"', 'Clipboard dependencies'),\n internalOnly: true\n })\n for (const component of dependencies.values()) {\n collectTextNodes(component)\n nodeChanges.push(\n ...sceneNodeToKiwi(component, dependencyCanvas, 0, localIdCounter, graph, blobs, {\n nodeIdToGuid,\n fontDigestMap,\n varIdToGuid: variableIds,\n assignedGuidValues,\n modeIdToGuid: modeIds,\n slotContentRecords,\n runtime\n })\n )\n }\n appendVariableNodeChanges(graph, nodeChanges, dependencyCanvas, variableIds, modeIds)\n // Slot content is collected while instances serialize; it follows the canvas's other records.\n const written = nodeChanges.filter(\n (change) =>\n change.parentIndex?.guid.sessionID === dependencyCanvas.sessionID &&\n change.parentIndex.guid.localID === dependencyCanvas.localID\n ).length\n placeSlotContent(slotContentRecords, dependencyCanvas, written, fractionalPosition)\n nodeChanges.push(...slotContentRecords)\n // A connector copied before a layer its end joins is joined to it now that both have GUIDs.\n relinkConnectorEnds(nodeChanges, graph, nodeIdToGuid)\n // Pair each text record with the node it was written from; instance content and slot\n // content are not emitted in traversal order.\n const textById = new Map(exportedTextNodes.map((node) => [node.id, node]))\n const sourceByGuid = new Map<string, SceneNode>()\n for (const [id, guid] of nodeIdToGuid) {\n const node = textById.get(id)\n if (node) sourceByGuid.set(`${guid.sessionID}:${guid.localID}`, node)\n }\n for (const change of nodeChanges) {\n if (change.type !== 'TEXT' || !change.guid) continue\n const source = sourceByGuid.get(`${change.guid.sessionID}:${change.guid.localID}`)\n if (!source) continue\n change.lineHeight = figmaLineHeight(source.lineHeight)\n }\n embedClipboardImages(nodeChanges, blobs, graph.images)\n return encodeFigmaClipboard(nodeChanges, blobs, randomInt(), assetType)\n}\n\nexport {\n buildPairdrawClipboardHTML,\n parsePairdrawClipboard,\n type PairdrawClipboardData,\n type TextPictureBuilder\n} from './clipboard/pairdraw'\n"],"mappings":";;;;;;;;;;;;;;;AAsCA,eAAsB,sBAAqC;CACzD,MAAM,UAAU;AAClB;AAEA,SAAgB,qBACd,aACA,OACA,gBACA,UAAU,GACV,UAAU,GACV,QAAsB,CAAC,GACb;CACV,MAAM,YAAY,uBAChB,aACA,OACA,gBACA,OACA,SACA,OACF;CACA,UAAU,OAAO;CACjB,OAAO,UAAU,KAAK;AACxB;;;;;;;;AASA,SAAS,eAAe,OAA+B;CAIrD,IAAI,EAFF,CAAC,GAAG,MAAM,UAAU,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,SAAS,GAAG,KAC9D,CAAC,GAAG,MAAM,oBAAoB,OAAO,CAAC,CAAC,CAAC,MAAM,eAAe,CAAC,WAAW,GAAG,IAChE,OAAO;CACrB,MAAM,OAAO,4BAA4B,KAAK;CAC9C,KAAK,sBAAsB,IAAI,IAC7B,CAAC,GAAG,MAAM,mBAAmB,CAAC,CAAC,KAAK,CAAC,IAAI,gBAAgB,CACvD,IACA,WAAW,MACP,aACA;EACE,GAAG;EACH,KAAK,gBAAgB,cAAc,IAAI;EACvC,SAAS,oBAAoB,KAAK,UAAU,UAAU,CAAC;CACzD,CACN,CAAC,CACH;CACA,KAAK,YAAY,IAAI,IACnB,CAAC,GAAG,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,cAAc,CAC3C,IACA,SAAS,MACL,WACA;EACE,GAAG;EACH,KAAK,gBAAgB,YAAY,IAAI;EACrC,SAAS,oBAAoB,KAAK,UAAU,QAAQ,CAAC;CACvD,CACN,CAAC,CACH;CACA,OAAO;AACT;AAEA,SAAgB,wBACd,OACA,OACA,YAAqC,WACb;CACxB,MAAM,UAAU,eAAe,KAAK;CACpC,OAAO,qBAAqB,SAAS,KAAA,IAAY,YAC/C,wBAAwB,OAAO,SAAS,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kB,GAAG,gBAAgB,OAAO,OAAO;GAC/E;GACA;GACA,aAAa;GACb;GACA,cAAc;GACd;GACA;EACF,CAAC,CACH;CACF;CACA,0BAA0B,OAAO,aAAa,kBAAkB,aAAa,OAAO;CAEpF,MAAM,UAAU,YAAY,QACzB,WACC,OAAO,aAAa,KAAK,cAAc,iBAAiB,aACxD,OAAO,YAAY,KAAK,YAAY,iBAAiB,OACzD,CAAC,CAAC;CACF,iBAAiB,oBAAoB,kBAAkB,SAAS,kBAAkB;CAClF,YAAY,KAAK,GAAG,kBAAkB;CAEtC,oBAAoB,aAAa,OAAO,YAAY;CAGpD,MAAM,WAAW,IAAI,IAAI,kBAAkB,KAAK,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;CACzE,MAAM,+BAAe,IAAI,IAAuB;CAChD,KAAK,MAAM,CAAC,IAAI,SAAS,cAAc;EACrC,MAAM,OAAO,SAAS,IAAI,EAAE;EAC5B,IAAI,MAAM,aAAa,IAAI,GAAG,KAAK,UAAU,GAAG,KAAK,WAAW,IAAI;CACtE;CACA,KAAK,MAAM,UAAU,aAAa;EAChC,IAAI,OAAO,SAAS,UAAU,CAAC,OAAO,MAAM;EAC5C,MAAM,SAAS,aAAa,IAAI,GAAG,OAAO,KAAK,UAAU,GAAG,OAAO,KAAK,SAAS;EACjF,IAAI,CAAC,QAAQ;EACb,OAAO,aAAa,gBAAgB,OAAO,UAAU;CACvD;CACA,qBAAqB,aAAa,OAAO,MAAM,MAAM;CACrD,OAAO,qBAAqB,aAAa,OAAO,UAAU,GAAG,SAAS;AACxE"}
|
|
1
|
+
{"version":3,"file":"clipboard.js","names":[],"sources":["../src/clipboard.ts"],"sourcesContent":["import {\n embedClipboardImages,\n encodeFigmaClipboard,\n type FigmaClipboardAssetType\n} from '@pairdraw/fig/clipboard'\nimport {\n figmaLineHeight,\n placeSlotContent,\n relinkConnectorEnds,\n type FigNodeChangeExportRuntime,\n sceneNodeToKiwi,\n makeDocumentNodeChange,\n makeCanvasNodeChange\n} from '@pairdraw/fig/node-change'\nimport type { GUID } from '@pairdraw/kiwi/fig'\nimport { initCodec, type NodeChange as KiwiNodeChange } from '@pairdraw/kiwi/fig/codec'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { derivedAssetKey, derivedAssetVersion } from '@pairdraw/scene-graph/asset-keys'\nimport { fractionalPosition } from '@pairdraw/scene-graph/order-keys'\nimport { randomInt } from '@pairdraw/scene-graph/random'\nimport { ownsSlotContent } from '@pairdraw/scene-graph/slots'\n\nimport {\n collectComponentPropertyIds,\n firstUnclaimedLocalId,\n layerSourceGuids\n} from '#core/io/formats/fig/export/setup'\nimport {\n appendVariableNodeChanges,\n assignSharedStyleGuids,\n assignVariableGuids\n} from '#core/io/formats/fig/export/variables'\n\nimport { withFigExportRuntime } from './canvas/text/shape'\nimport { prepareClipboardImport } from './clipboard/fig-import'\nimport { buildFontDigestMap } from './kiwi/fig/node-change/serialize'\nimport { cloneSceneGraphForFigExport } from './kiwi/fig/parse/transfer'\n\nexport async function prefetchFigmaSchema(): Promise<void> {\n await initCodec()\n}\n\nexport function importClipboardNodes(\n nodeChanges: KiwiNodeChange[],\n graph: SceneGraph,\n targetParentId: string,\n offsetX = 0,\n offsetY = 0,\n blobs: Uint8Array[] = []\n): string[] {\n const operation = prepareClipboardImport(\n nodeChanges,\n graph,\n targetParentId,\n blobs,\n offsetX,\n offsetY\n )\n operation.commit()\n return operation.plan.rootIds\n}\n\n/**\n * The document as the clipboard writes it. Figma names the variables and collections a paste\n * uses by key, and keeps a binding to one it knows only by key as a remote variable, as it does\n * for its own clipboard; variables made in Pairdraw have no key, so they take one derived from\n * their ID here, for this copy only. Figma keeps the first value it pasted for a key and version,\n * so the version follows their content and an edited variable pastes with its new value.\n */\nfunction clipboardGraph(graph: SceneGraph): SceneGraph {\n const unkeyed =\n [...graph.variables.values()].some((variable) => !variable.key) ||\n [...graph.variableCollections.values()].some((collection) => !collection.key)\n if (!unkeyed) return graph\n const copy = cloneSceneGraphForFigExport(graph)\n copy.variableCollections = new Map(\n [...graph.variableCollections].map(([id, collection]) => [\n id,\n collection.key\n ? collection\n : {\n ...collection,\n key: derivedAssetKey(`collection:${id}`),\n version: derivedAssetVersion(JSON.stringify(collection))\n }\n ])\n )\n copy.variables = new Map(\n [...graph.variables].map(([id, variable]) => [\n id,\n variable.key\n ? variable\n : {\n ...variable,\n key: derivedAssetKey(`variable:${id}`),\n version: derivedAssetVersion(JSON.stringify(variable))\n }\n ])\n )\n return copy\n}\n\nexport function buildFigmaClipboardHTML(\n nodes: SceneNode[],\n graph: SceneGraph,\n assetType: FigmaClipboardAssetType = 'UNKNOWN'\n): Promise<string | null> {\n const written = clipboardGraph(graph)\n return withFigExportRuntime(written, undefined, (runtime) =>\n writeFigmaClipboardHTML(nodes, written, runtime, assetType)\n )\n}\n\nasync function writeFigmaClipboardHTML(\n nodes: SceneNode[],\n graph: SceneGraph,\n runtime: FigNodeChangeExportRuntime,\n assetType: FigmaClipboardAssetType\n): Promise<string | null> {\n const fontDigestMap = await buildFontDigestMap(graph)\n\n const docGuid = { sessionID: 0, localID: 0 }\n const canvasGuid = { sessionID: 0, localID: 1 }\n // Above every GUID the graph claims, as the document exporter starts, so no record collides.\n const localIdCounter = {\n value: Math.max(100, firstUnclaimedLocalId(graph, collectComponentPropertyIds(graph)))\n }\n\n const nodeChanges: KiwiNodeChange[] = [\n makeDocumentNodeChange(docGuid, graph.documentColorSpace),\n makeCanvasNodeChange(canvasGuid, docGuid, '!', 'Page 1')\n ]\n\n const exportedTextNodes: SceneNode[] = []\n const collectTextNodes = (node: SceneNode) => {\n if (node.type === 'TEXT') exportedTextNodes.push(node)\n for (const childId of node.childIds) {\n const child = graph.getNode(childId)\n if (child) collectTextNodes(child)\n }\n }\n\n const nodeIdToGuid = new Map<string, GUID>()\n const assignedGuidValues = new Set<string>()\n const blobs: Uint8Array[] = []\n const variableIds = new Map<string, GUID>()\n const modeIds = new Map<string, GUID>()\n const propertyIdToGuid = new Map<string, GUID>()\n assignVariableGuids(\n graph,\n localIdCounter,\n variableIds,\n modeIds,\n assignedGuidValues,\n layerSourceGuids(graph)\n )\n assignSharedStyleGuids(\n [...graph.nodes.values()].filter((node) => node.sharedStyleType !== null),\n localIdCounter,\n nodeIdToGuid,\n assignedGuidValues\n )\n const slotContentRecords: KiwiNodeChange[] = []\n for (let i = 0; i < nodes.length; i++) {\n collectTextNodes(nodes[i])\n nodeChanges.push(\n ...sceneNodeToKiwi(nodes[i], canvasGuid, i, localIdCounter, graph, blobs, {\n nodeIdToGuid,\n fontDigestMap,\n varIdToGuid: variableIds,\n assignedGuidValues,\n modeIdToGuid: modeIds,\n propertyIdToGuid,\n slotContentRecords,\n runtime\n })\n )\n }\n\n const dependencies = new Map<string, SceneNode>()\n const selected = new Set<string>()\n const mark = (node: SceneNode): void => {\n selected.add(node.id)\n for (const child of graph.getChildren(node.id)) mark(child)\n }\n for (const node of nodes) mark(node)\n const visitDependencies = (node: SceneNode): void => {\n if (node.type === 'INSTANCE' && node.componentId) {\n // A nested instance's copy points at the component's own nested instance, not at a main\n // component; follow the chain to the component it draws, as the export's symbolID does.\n let componentId = node.componentId\n const seen = new Set<string>()\n let component = graph.getNode(componentId)\n while (component?.type === 'INSTANCE' && component.componentId && !seen.has(component.id)) {\n seen.add(component.id)\n componentId = component.componentId\n component = graph.getNode(componentId)\n }\n if (\n component &&\n (component.type === 'COMPONENT' || component.type === 'COMPONENT_SET') &&\n !selected.has(component.id) &&\n !dependencies.has(component.id)\n ) {\n dependencies.set(component.id, component)\n visitDependencies(component)\n }\n }\n for (const child of graph.getChildren(node.id)) visitDependencies(child)\n }\n for (const node of nodes) visitDependencies(node)\n for (const node of graph.getAllNodes())\n if (node.sharedStyleType && !selected.has(node.id)) dependencies.set(node.id, node)\n const dependencyCanvas = { sessionID: 0, localID: 2 }\n const hasSlotContent = [...selected].some((id) => {\n const node = graph.getNode(id)\n return !!node && ownsSlotContent(graph, node)\n })\n if (dependencies.size || graph.variableCollections.size || hasSlotContent)\n nodeChanges.push({\n ...makeCanvasNodeChange(dependencyCanvas, docGuid, '\"', 'Clipboard dependencies'),\n internalOnly: true\n })\n for (const component of dependencies.values()) {\n collectTextNodes(component)\n nodeChanges.push(\n ...sceneNodeToKiwi(component, dependencyCanvas, 0, localIdCounter, graph, blobs, {\n nodeIdToGuid,\n fontDigestMap,\n varIdToGuid: variableIds,\n assignedGuidValues,\n modeIdToGuid: modeIds,\n propertyIdToGuid,\n slotContentRecords,\n runtime\n })\n )\n }\n appendVariableNodeChanges(graph, nodeChanges, dependencyCanvas, variableIds, modeIds)\n // Slot content is collected while instances serialize; it follows the canvas's other records.\n const written = nodeChanges.filter(\n (change) =>\n change.parentIndex?.guid.sessionID === dependencyCanvas.sessionID &&\n change.parentIndex.guid.localID === dependencyCanvas.localID\n ).length\n placeSlotContent(slotContentRecords, dependencyCanvas, written, fractionalPosition)\n nodeChanges.push(...slotContentRecords)\n // A connector copied before a layer its end joins is joined to it now that both have GUIDs.\n relinkConnectorEnds(nodeChanges, graph, nodeIdToGuid)\n // Pair each text record with the node it was written from; instance content and slot\n // content are not emitted in traversal order.\n const textById = new Map(exportedTextNodes.map((node) => [node.id, node]))\n const sourceByGuid = new Map<string, SceneNode>()\n for (const [id, guid] of nodeIdToGuid) {\n const node = textById.get(id)\n if (node) sourceByGuid.set(`${guid.sessionID}:${guid.localID}`, node)\n }\n for (const change of nodeChanges) {\n if (change.type !== 'TEXT' || !change.guid) continue\n const source = sourceByGuid.get(`${change.guid.sessionID}:${change.guid.localID}`)\n if (!source) continue\n change.lineHeight = figmaLineHeight(source.lineHeight)\n }\n embedClipboardImages(nodeChanges, blobs, graph.images)\n return encodeFigmaClipboard(nodeChanges, blobs, randomInt(), assetType)\n}\n\nexport {\n buildPairdrawClipboardHTML,\n parsePairdrawClipboard,\n type PairdrawClipboardData,\n type TextPictureBuilder\n} from './clipboard/pairdraw'\n"],"mappings":";;;;;;;;;;;;;;;AAsCA,eAAsB,sBAA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KAAK,MAAM,aAAa,aAAa,OAAO,GAAG;EAC7C,iBAAiB,SAAS;EAC1B,YAAY,KACV,GAAG,gBAAgB,WAAW,kBAAkB,GAAG,gBAAgB,OAAO,OAAO;GAC/E;GACA;GACA,aAAa;GACb;GACA,cAAc;GACd;GACA;GACA;EACF,CAAC,CACH;CACF;CACA,0BAA0B,OAAO,aAAa,kBAAkB,aAAa,OAAO;CAEpF,MAAM,UAAU,YAAY,QACzB,WACC,OAAO,aAAa,KAAK,cAAc,iBAAiB,aACxD,OAAO,YAAY,KAAK,YAAY,iBAAiB,OACzD,CAAC,CAAC;CACF,iBAAiB,oBAAoB,kBAAkB,SAAS,kBAAkB;CAClF,YAAY,KAAK,GAAG,kBAAkB;CAEtC,oBAAoB,aAAa,OAAO,YAAY;CAGpD,MAAM,WAAW,IAAI,IAAI,kBAAkB,KAAK,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;CACzE,MAAM,+BAAe,IAAI,IAAuB;CAChD,KAAK,MAAM,CAAC,IAAI,SAAS,cAAc;EACrC,MAAM,OAAO,SAAS,IAAI,EAAE;EAC5B,IAAI,MAAM,aAAa,IAAI,GAAG,KAAK,UAAU,GAAG,KAAK,WAAW,IAAI;CACtE;CACA,KAAK,MAAM,UAAU,aAAa;EAChC,IAAI,OAAO,SAAS,UAAU,CAAC,OAAO,MAAM;EAC5C,MAAM,SAAS,aAAa,IAAI,GAAG,OAAO,KAAK,UAAU,GAAG,OAAO,KAAK,SAAS;EACjF,IAAI,CAAC,QAAQ;EACb,OAAO,aAAa,gBAAgB,OAAO,UAAU;CACvD;CACA,qBAAqB,aAAa,OAAO,MAAM,MAAM;CACrD,OAAO,qBAAqB,aAAa,OAAO,UAAU,GAAG,SAAS;AACxE"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -289,6 +289,10 @@ declare const SECTION_DEFAULT_STROKE: Stroke;
|
|
|
289
289
|
declare const SECTION_CORNER_RADIUS = 2;
|
|
290
290
|
/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */
|
|
291
291
|
declare const EFFECT_FILTER_CACHE_ENTRIES = 64;
|
|
292
|
+
/** Noise tiles a renderer keeps, each about 4 MB: a density or seed drag walks through many. */
|
|
293
|
+
declare const NOISE_TILE_CACHE_ENTRIES = 8;
|
|
294
|
+
/** Texture displacement tiles a renderer keeps, each 256 KB. */
|
|
295
|
+
declare const TEXTURE_NOISE_CACHE_ENTRIES = 16;
|
|
292
296
|
declare const ZOOM_DIVISOR = 50;
|
|
293
297
|
declare const ZOOM_SCALE_MIN = 0.75;
|
|
294
298
|
declare const ZOOM_SCALE_MAX = 1.25;
|
|
@@ -312,5 +316,5 @@ declare const DEFAULT_TEXT_HEIGHT = 24;
|
|
|
312
316
|
/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
|
|
313
317
|
declare const DUPLICATE_FRAME_GAP = 40;
|
|
314
318
|
//#endregion
|
|
315
|
-
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, InterfaceTheme, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, ModelOption, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, ReasoningEffort, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
319
|
+
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, InterfaceTheme, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, ModelOption, NOISE_TILE_CACHE_ENTRIES, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, ReasoningEffort, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXTURE_NOISE_CACHE_ENTRIES, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
316
320
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;;;;;;cAEA;;;;;;cACA;;;;;;cAEA;cACA;cACA;cACA;;;;;;cAMA;cACA;cACA;cACA;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cAEA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;;cAGA;;;;;cACA;;;;;cACA;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;cAGA;;cAEA,kBAAgB;cAChB;cAEA;;;;;cAKA;;cAGA;;;;;cAMA;cAEA;cAEA;cASA;cAUA;cASA;;cAGA,oBAAoB;cAOpB,oBAAoB;;KAQrB;;cAGC,0BAA0B,OAAO,gBAAgB;;cAMjD;;;;;;;cAQA,uBAAuB,OAAO,gBAAgB;cAU9C,wBAAwB;cASxB;;cAGA;cAEA;cACA;cACA;cAEA;;cAEA;;;;;cAKA;;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;;cAEA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;;;;;;cAEA;;;;;;cACA;;;;;;cAEA;cACA;cACA;cACA;;;;;;cAMA;cACA;cACA;cACA;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cAEA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;;cAGA;;;;;cACA;;;;;cACA;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;cAGA;;cAEA,kBAAgB;cAChB;cAEA;;;;;cAKA;;cAGA;;;;;cAMA;cAEA;cAEA;cASA;cAUA;cASA;;cAGA,oBAAoB;cAOpB,oBAAoB;;KAQrB;;cAGC,0BAA0B,OAAO,gBAAgB;;cAMjD;;;;;;;cAQA,uBAAuB,OAAO,gBAAgB;cAU9C,wBAAwB;cASxB;;cAGA;;cAGA;;cAGA;cAEA;cACA;cACA;cAEA;;cAEA;;;;;cAKA;;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;;cAEA"}
|
package/dist/constants.js
CHANGED
|
@@ -393,6 +393,10 @@ const SECTION_DEFAULT_STROKE = {
|
|
|
393
393
|
const SECTION_CORNER_RADIUS = 2;
|
|
394
394
|
/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */
|
|
395
395
|
const EFFECT_FILTER_CACHE_ENTRIES = 64;
|
|
396
|
+
/** Noise tiles a renderer keeps, each about 4 MB: a density or seed drag walks through many. */
|
|
397
|
+
const NOISE_TILE_CACHE_ENTRIES = 8;
|
|
398
|
+
/** Texture displacement tiles a renderer keeps, each 256 KB. */
|
|
399
|
+
const TEXTURE_NOISE_CACHE_ENTRIES = 16;
|
|
396
400
|
const ZOOM_DIVISOR = 50;
|
|
397
401
|
const ZOOM_SCALE_MIN = .75;
|
|
398
402
|
const ZOOM_SCALE_MAX = 1.25;
|
|
@@ -416,6 +420,6 @@ const DEFAULT_TEXT_HEIGHT = 24;
|
|
|
416
420
|
/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
|
|
417
421
|
const DUPLICATE_FRAME_GAP = 40;
|
|
418
422
|
//#endregion
|
|
419
|
-
export { ACP_AGENTS, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
423
|
+
export { ACP_AGENTS, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, NOISE_TILE_CACHE_ENTRIES, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXTURE_NOISE_CACHE_ENTRIES, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
420
424
|
|
|
421
425
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const HUD_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\n/** The violet AI agents show in everywhere, the app's `--color-agent`. */\nexport const AI_AGENT_COLOR = { r: 0.486, g: 0.361, b: 1 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_DONE_DURATION_MS = 800\n/** How long a layer an agent adds takes to trace in, once its turn comes. */\nexport const AI_ENTER_DURATION_MS = 480\n/** The pause between the layers of one edit, so they appear one after another. */\nexport const AI_ENTER_STAGGER_MS = 45\n/** The last layer of an edit starts within this, however many layers the edit adds. */\nexport const AI_ENTER_MAX_DELAY_MS = 900\n/** One sweep of the light over an area an agent is working in. */\nexport const AI_SHIMMER_PERIOD_MS = 1600\n/** Width of the sweeping light, in screen pixels. */\nexport const AI_SHIMMER_BAND = 120\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\n/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */\nexport const EFFECT_FILTER_CACHE_ENTRIES = 64\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/** Points a pen path needs before a press on its first point closes it: two make a closed shape, as in Figma. */\nexport const PEN_CLOSE_MIN_POINTS = 2\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAAa,OAAO,WAAW;AAC5C,MAAa,WAAW,cAAc,yBAAyB;AAE/D,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,uBAA8B;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAK;AACvE,MAAa,kBAAkB;CAAE,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;AAAE;;AAEjE,MAAa,0BAAoD;CAC/D,OAAO;CACP,YAAY;AACd;AACA,MAAa,kBAAkB;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAG,GAAG;AAAE;;AAEhE,MAAa,aAAa;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAO,GAAG;AAAE;AAC/D,MAAa,wBAAwB;AACrC,MAAa,aAAa;CAAE,GAAG;CAAK,GAAG;CAAK,GAAG;CAAM,GAAG;AAAE;;AAE1D,MAAa,oBAAoB;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E;CACxD,SAAS;CACT,SAAS;AACX;AAEA,MAAa,qBAA2B;CACtC,MAAM;CACN,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,SAAS;CACT,SAAS;AACX;;AAMA,MAAa,2BAA0D;CACrE,OAAO;CACP,MAAM;EAAE,GAAG,KAAO;EAAK,GAAG,KAAO;EAAK,GAAG,KAAO;EAAK,GAAG;CAAE;AAC5D;;AAGA,MAAa,wBAAwB;CACnC,GAAG,MAAM;CACT,GAAG,MAAM;CACT,GAAG,MAAM;CACT,GAAG;AACL;;AAGA,MAAa,wBAAsD;CACjE,OAAO;EAAE,MAAM;EAAS,OAAO;GAAE,GAAG;GAAG,GAAG;GAAG,GAAG;GAAG,GAAG;EAAE;EAAG,SAAS;EAAG,SAAS;CAAK;CACrF,MAAM;EACJ,MAAM;EACN,OAAO;GAAE,GAAG,KAAO;GAAK,GAAG,KAAO;GAAK,GAAG,KAAO;GAAK,GAAG;EAAE;EAC3D,SAAS;EACT,SAAS;CACX;AACF;AAEA,MAAa,yBAAiC;CAC5C,MAAM;CACN,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAa,wBAAwB;;AAGrC,MAAa,8BAA8B;AAE3C,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;AAEnC,MAAa,uBAAuB;;;;;AAKpC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const HUD_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\n/** The violet AI agents show in everywhere, the app's `--color-agent`. */\nexport const AI_AGENT_COLOR = { r: 0.486, g: 0.361, b: 1 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_DONE_DURATION_MS = 800\n/** How long a layer an agent adds takes to trace in, once its turn comes. */\nexport const AI_ENTER_DURATION_MS = 480\n/** The pause between the layers of one edit, so they appear one after another. */\nexport const AI_ENTER_STAGGER_MS = 45\n/** The last layer of an edit starts within this, however many layers the edit adds. */\nexport const AI_ENTER_MAX_DELAY_MS = 900\n/** One sweep of the light over an area an agent is working in. */\nexport const AI_SHIMMER_PERIOD_MS = 1600\n/** Width of the sweeping light, in screen pixels. */\nexport const AI_SHIMMER_BAND = 120\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\n/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */\nexport const EFFECT_FILTER_CACHE_ENTRIES = 64\n\n/** Noise tiles a renderer keeps, each about 4 MB: a density or seed drag walks through many. */\nexport const NOISE_TILE_CACHE_ENTRIES = 8\n\n/** Texture displacement tiles a renderer keeps, each 256 KB. */\nexport const TEXTURE_NOISE_CACHE_ENTRIES = 16\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/** Points a pen path needs before a press on its first point closes it: two make a closed shape, as in Figma. */\nexport const PEN_CLOSE_MIN_POINTS = 2\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAAa,OAAO,WAAW;AAC5C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G,KAAO;GAAK,GAAG;EAAE;EAC3D,SAAS;EACT,SAAS;CACX;AACF;AAEA,MAAa,yBAAiC;CAC5C,MAAM;CACN,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAa,wBAAwB;;AAGrC,MAAa,8BAA8B;;AAG3C,MAAa,2BAA2B;;AAGxC,MAAa,8BAA8B;AAE3C,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;AAEnC,MAAa,uBAAuB;;;;;AAKpC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","names":[],"sources":["../../src/design-jsx/renderer.ts"],"mappings":";;;;;;;iBAkEgB,kBAAkB,QAAO;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","names":[],"sources":["../../src/design-jsx/renderer.ts"],"mappings":";;;;;;;iBAkEgB,kBAAkB,QAAO;EAWk6T,YAAA,uCAAA,YAAA,mBAAA,yCAAC,kBAAA,uCAAA;EAA8K,aAAA,uCAAA,YAAA,qCAAA,UAAA,yCAAC,kBAAA,uCAAA;EAAqL,cAAA,uCAAA,YAAA,qCAAA,UAAA,yCAAC,kBAAA,uCAAA;;;cADlyU,YAAS,uCAAA,YAAA,mBAAA,yCAAA,kBAAA,uCAAA,iBAAE,cAAW,uCAAA,YAAA,qCAAA,UAAA,yCAAA,kBAAA,uCAAA,iBAAE,aAAU,uCAAA,YAAA,qCAAA,UAAA,yCAAA,kBAAA,uCAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { AllowedValue, DesignRules } from "./rules.js";
|
|
2
|
+
import { SceneGraph, SceneNode, Variable } from "@pairdraw/scene-graph";
|
|
3
|
+
import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
|
|
4
|
+
//#region src/design-memory/check.d.ts
|
|
5
|
+
/** A value that breaks the memory, with the closest one it allows. */
|
|
6
|
+
interface DesignViolation {
|
|
7
|
+
group: DesignMemoryGroup;
|
|
8
|
+
severity: 'refuse' | 'warn';
|
|
9
|
+
/** The layer, or the variable, that holds the value. */
|
|
10
|
+
nodeId: string;
|
|
11
|
+
nodeName: string;
|
|
12
|
+
path: string;
|
|
13
|
+
value: string | number;
|
|
14
|
+
nearest: AllowedValue<string | number> | null;
|
|
15
|
+
}
|
|
16
|
+
interface DesignFindings {
|
|
17
|
+
refused: DesignViolation[];
|
|
18
|
+
warnings: DesignViolation[];
|
|
19
|
+
/** The rules the edit was judged by; null when it brought no values to judge. */
|
|
20
|
+
rules: DesignRules | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* What an edit did: the layers it created, the fields it changed on others with their values
|
|
24
|
+
* before, the layers it deleted as they were, and the variables it created or changed.
|
|
25
|
+
*/
|
|
26
|
+
interface DesignEdit {
|
|
27
|
+
created: readonly Pick<SceneNode, 'id'>[];
|
|
28
|
+
updated: readonly {
|
|
29
|
+
id: string;
|
|
30
|
+
before: Partial<SceneNode>;
|
|
31
|
+
after: Partial<SceneNode>;
|
|
32
|
+
}[];
|
|
33
|
+
deleted?: readonly SceneNode[];
|
|
34
|
+
/** Each variable created (`before` null) or changed, with what it held before. */
|
|
35
|
+
variables?: readonly {
|
|
36
|
+
id: string;
|
|
37
|
+
before: Partial<Variable> | null;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
interface DesignCheckOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Report what the memory would refuse as warnings: for outside content, such as an imported
|
|
43
|
+
* web page, SVG or photo, whose values are its own, and for a call a person made.
|
|
44
|
+
*/
|
|
45
|
+
warnOnly?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The rules as they were before the edit, so nothing the edit itself did, such as a variable
|
|
48
|
+
* it created, widens what it is judged by. Resolved from the document now when absent.
|
|
49
|
+
*/
|
|
50
|
+
rules?: DesignRules;
|
|
51
|
+
/**
|
|
52
|
+
* The layers a call copies or converts with their values, such as a clone's original or the
|
|
53
|
+
* layers a boolean joins: a value they already had is not new on what the call made of them.
|
|
54
|
+
* Any other call is judged only against what the memory allows, wherever else a value is used.
|
|
55
|
+
*/
|
|
56
|
+
copiedFrom?: readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* The call joins the named layers into one and may take a paint from any of them, as flatten
|
|
59
|
+
* and boolean operations do: only a value every named layer had in the same field is theirs.
|
|
60
|
+
*/
|
|
61
|
+
merged?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** The values on a layer that break the memory, as lint lists them. */
|
|
64
|
+
declare function designViolations(rules: DesignRules, node: SceneNode): DesignViolation[];
|
|
65
|
+
/**
|
|
66
|
+
* Judges what an edit did against the document's design memory; null when the document has
|
|
67
|
+
* none. Only values the edit brought in are judged, against the rules as they were before it:
|
|
68
|
+
* - a value written onto a layer is judged against what the memory allows, wherever else the
|
|
69
|
+
* document uses it, unless the call copied or converted layers that already had it
|
|
70
|
+
* (`copiedFrom`);
|
|
71
|
+
* - Pairdraw's own defaults for a new layer warn at most: the agent did not choose them;
|
|
72
|
+
* - variables and shared styles are judged on every value they now give the system, under their
|
|
73
|
+
* scopes as they are now, so creating, changing or rescoping one cannot widen the rules;
|
|
74
|
+
* binding layers to the existing system stays free.
|
|
75
|
+
* People's edits are never judged here, only agents' and automation's.
|
|
76
|
+
*/
|
|
77
|
+
declare function checkDesignEdit(graph: SceneGraph, edit: DesignEdit, options?: DesignCheckOptions): DesignFindings | null;
|
|
78
|
+
/** A value proposed for a design, judged before it is used. */
|
|
79
|
+
interface DesignValueVerdict {
|
|
80
|
+
group: DesignMemoryGroup;
|
|
81
|
+
value: string | number;
|
|
82
|
+
/** `invalid` for a value the group cannot read, such as a color that is not CSS. */
|
|
83
|
+
verdict: 'ok' | 'warn' | 'refuse' | 'invalid';
|
|
84
|
+
nearest: AllowedValue<string | number> | null;
|
|
85
|
+
}
|
|
86
|
+
/** Judges values an agent means to use, so it can pick allowed ones before it edits. */
|
|
87
|
+
declare function checkDesignValues(rules: DesignRules, proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>): DesignValueVerdict[];
|
|
88
|
+
//#endregion
|
|
89
|
+
export { DesignCheckOptions, DesignEdit, DesignFindings, DesignValueVerdict, DesignViolation, checkDesignEdit, checkDesignValues, designViolations };
|
|
90
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","names":[],"sources":["../../src/design-memory/check.ts"],"mappings":";;;;;UA6BiB;EACf,OAAO;EACP;;EAEA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf,SAAS;EACT,UAAU;;EAEV,OAAO;;;;;;UAOQ;EACf,kBAAkB,KAAK;EACvB;IAAoB;IAAY,QAAQ,QAAQ;IAAY,OAAO,QAAQ;;EAC3E,mBAAmB;;EAEnB;IAAuB;IAAY,QAAQ,QAAQ;;;UAGpC;;;;;EAKf;;;;;EAKA,QAAQ;;;;;;EAMR;;;;;EAKA;;;iBAqDc,iBAAiB,OAAO,aAAa,MAAM,YAAY;;;;;;;;;;;;;iBAkLvD,gBACd,OAAO,YACP,MAAM,YACN,UAAS,qBACR;;UA0Bc;EACf,OAAO;EACP;;EAEA;EACA,SAAS;;;iBAIK,kBACd,OAAO,aACP,UAAU,QAAQ,OAAO,oDACxB"}
|