@pairdraw/core 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +74 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/colors.d.ts +20 -5
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +48 -42
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +25 -0
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
- package/dist/canvas/renderer/document-surface.js +46 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +6 -4
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -3
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -0
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +36 -3
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +2 -1
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +4 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/decorations.d.ts +2 -2
- package/dist/canvas/text/decorations.d.ts.map +1 -1
- package/dist/canvas/text/decorations.js +5 -5
- package/dist/canvas/text/decorations.js.map +1 -1
- package/dist/canvas/text/index.js +1 -1
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +2 -2
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -5
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -1
- package/dist/canvas/text/renderer.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +4 -4
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- package/dist/editor/clipboard/assets.js.map +1 -1
- package/dist/editor/clipboard/component-matches.d.ts +13 -0
- package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
- package/dist/editor/clipboard/component-matches.js +50 -0
- package/dist/editor/clipboard/component-matches.js.map +1 -0
- package/dist/editor/clipboard/dependencies.d.ts +7 -0
- package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
- package/dist/editor/clipboard/dependencies.js +5 -0
- package/dist/editor/clipboard/dependencies.js.map +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +48 -19
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -3
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +26 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +171 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +9 -2
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pencil.js +1 -1
- package/dist/editor/structure/state.d.ts.map +1 -1
- package/dist/editor/structure/state.js +2 -2
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +2 -2
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.js +3 -3
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fresh-read.d.ts +15 -0
- package/dist/figma-api/fresh-read.d.ts.map +1 -0
- package/dist/figma-api/fresh-read.js +54 -0
- package/dist/figma-api/fresh-read.js.map +1 -0
- package/dist/figma-api/graph-ref.d.ts +9 -0
- package/dist/figma-api/graph-ref.d.ts.map +1 -0
- package/dist/figma-api/graph-ref.js +14 -0
- package/dist/figma-api/graph-ref.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +3 -3
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +7 -3
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +1 -1
- package/dist/figma-api/pending-sync.d.ts.map +1 -1
- package/dist/figma-api/pending-sync.js +3 -1
- package/dist/figma-api/pending-sync.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/figma-api/variables/index.d.ts.map +1 -1
- package/dist/figma-api/variables/index.js +2 -2
- package/dist/figma-api/variables/index.js.map +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/css/known.js +1 -1
- package/dist/io/formats/design-tokens/css/known.js.map +1 -1
- package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
- package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/read.js +11 -5
- package/dist/io/formats/design-tokens/css/read.js.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.js +17 -4
- package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
- package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
- package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/values.js +24 -8
- package/dist/io/formats/design-tokens/css/values.js.map +1 -1
- package/dist/io/formats/design-tokens/decode.d.ts +7 -6
- package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/decode.js +14 -13
- package/dist/io/formats/design-tokens/decode.js.map +1 -1
- package/dist/io/formats/design-tokens/export.js +3 -3
- package/dist/io/formats/design-tokens/export.js.map +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -3
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +9 -9
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +4 -4
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +7 -7
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/design-tokens/values.d.ts +10 -5
- package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/values.js +13 -7
- package/dist/io/formats/design-tokens/values.js.map +1 -1
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -1
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts +7 -2
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +12 -13
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +9 -7
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +4 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/layers.js +2 -2
- package/dist/io/formats/mermaid/layers.js.map +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -0
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +4 -4
- package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
- package/dist/io/formats/pdf/prepare.js +2 -2
- package/dist/io/formats/pdf/prepare.js.map +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +35 -5
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/pptx/style.js +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/import.d.ts +4 -2
- package/dist/io/formats/svg/import.d.ts.map +1 -1
- package/dist/io/formats/svg/import.js +2 -1
- package/dist/io/formats/svg/import.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +8 -8
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +8 -5
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/yoga-helpers.d.ts +2 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +7 -1
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +112 -10
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/comments.d.ts +4 -1
- package/dist/pairdraw-api/comments.d.ts.map +1 -1
- package/dist/pairdraw-api/comments.js +5 -0
- package/dist/pairdraw-api/comments.js.map +1 -1
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/rpc/variables-command.js +2 -2
- package/dist/rpc/variables-command.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/provider.d.ts +15 -0
- package/dist/text/font/provider.d.ts.map +1 -0
- package/dist/text/font/provider.js +18 -0
- package/dist/text/font/provider.js.map +1 -0
- package/dist/text/font/readiness.d.ts +32 -0
- package/dist/text/font/readiness.d.ts.map +1 -0
- package/dist/text/font/{status.js → readiness.js} +8 -4
- package/dist/text/font/readiness.js.map +1 -0
- package/dist/text/index.d.ts +12 -9
- package/dist/text/index.js +6 -3
- package/dist/text/prepare.d.ts +9 -4
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +9 -4
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze/responsive/widths.d.ts +27 -0
- package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/widths.js +49 -0
- package/dist/tools/analyze/responsive/widths.js.map +1 -0
- package/dist/tools/analyze.d.ts +3 -1
- package/dist/tools/analyze.js +3 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen/tokens.d.ts.map +1 -1
- package/dist/tools/codegen/tokens.js +2 -2
- package/dist/tools/codegen/tokens.js.map +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -2
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/component-catalog.d.ts.map +1 -1
- package/dist/tools/component-catalog.js +5 -3
- package/dist/tools/component-catalog.js.map +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/css/shorthand.d.ts +20 -0
- package/dist/tools/css/shorthand.d.ts.map +1 -0
- package/dist/tools/css/shorthand.js +54 -0
- package/dist/tools/css/shorthand.js.map +1 -0
- package/dist/tools/describe/index.js +2 -2
- package/dist/tools/describe/index.js.map +1 -1
- package/dist/tools/describe/issues.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/html-host.d.ts.map +1 -1
- package/dist/tools/html-host.js +5 -3
- package/dist/tools/html-host.js.map +1 -1
- package/dist/tools/image-ai/apply.d.ts.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -3
- package/dist/tools/image-ai/apply.js.map +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/image-ai/service.d.ts.map +1 -1
- package/dist/tools/image-ai/service.js +5 -3
- package/dist/tools/image-ai/service.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/geometry.d.ts.map +1 -1
- package/dist/tools/modify/geometry.js +14 -3
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +35 -8
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +10 -10
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +56 -4
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +2 -2
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +29 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/prompts/codegen.js +1 -1
- package/dist/tools/prompts/codegen.js.map +1 -1
- package/dist/tools/read/css.d.ts +14 -0
- package/dist/tools/read/css.d.ts.map +1 -0
- package/dist/tools/read/css.js +306 -0
- package/dist/tools/read/css.js.map +1 -0
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/reactions.js +1 -1
- package/dist/tools/read/reactions.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -5
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +5 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script/host.d.ts.map +1 -1
- package/dist/tools/script/host.js +5 -3
- package/dist/tools/script/host.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/variables/collections.js +1 -1
- package/dist/tools/variables/collections.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -4
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
- package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/gradients.js +5 -5
- package/dist/vector/vectorize/svg/gradients.js.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.js +13 -12
- package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/colors.ts +76 -50
- package/src/canvas/renderer/document-surface.ts +53 -0
- package/src/canvas/renderer/fonts.ts +6 -4
- package/src/canvas/renderer/lifecycle.ts +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/assets.ts +6 -2
- package/src/editor/clipboard/component-matches.ts +65 -0
- package/src/editor/clipboard/dependencies.ts +22 -1
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/css/known.ts +1 -1
- package/src/io/formats/design-tokens/css/read.ts +20 -7
- package/src/io/formats/design-tokens/css/sync.ts +9 -4
- package/src/io/formats/design-tokens/css/values.ts +37 -9
- package/src/io/formats/design-tokens/decode.ts +17 -12
- package/src/io/formats/design-tokens/export.ts +3 -3
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -1
- package/src/io/formats/fig/export/setup.ts +25 -15
- package/src/io/formats/fig/export/variables.ts +17 -6
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -1
- package/src/tools/create/vector.ts +2 -2
- package/src/tools/css/shorthand.ts +64 -0
- package/src/tools/describe/index.ts +2 -8
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/geometry.ts +16 -3
- package/src/tools/modify/layout.ts +47 -13
- package/src/tools/modify/matching.ts +14 -11
- package/src/tools/modify/paint.ts +85 -5
- package/src/tools/modify/reactions.ts +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { skColorSpace } from "../renderer/colors.js";
|
|
2
|
+
//#region src/canvas/noise/tile.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cells on each side of a noise tile, which repeats beyond them: wide enough that the repeat lies
|
|
5
|
+
* past a thousand grains, small enough to build in a few milliseconds and keep in 4 MB.
|
|
6
|
+
*/
|
|
7
|
+
const NOISE_TILE_CELLS = 1024;
|
|
8
|
+
/** What a level byte holds: 15 per level, so the 17 levels stay exact through 8 bits. */
|
|
9
|
+
const LEVEL_STEP = 15;
|
|
10
|
+
/** The step between a cell's possible values, the hash's 32 bits. */
|
|
11
|
+
const CELL_VALUE_STEP = 2 ** -32;
|
|
12
|
+
/** A cell's uniform value from its index and the seed: a 32-bit integer hash. */
|
|
13
|
+
function cellValue(x, y, seed, salt) {
|
|
14
|
+
let h = Math.imul(x, 668265261) ^ Math.imul(y, 374761393) ^ Math.imul(seed + salt, 2654435769);
|
|
15
|
+
h ^= h >>> 16;
|
|
16
|
+
h = Math.imul(h, 2146121005);
|
|
17
|
+
h ^= h >>> 15;
|
|
18
|
+
h = Math.imul(h, 2221713035);
|
|
19
|
+
h ^= h >>> 16;
|
|
20
|
+
return (h >>> 0) * CELL_VALUE_STEP;
|
|
21
|
+
}
|
|
22
|
+
/** The level a uniform value takes under `shares`, the share of pixels at each level or below. */
|
|
23
|
+
function level(u, shares) {
|
|
24
|
+
let at = 0;
|
|
25
|
+
while (at < shares.length && u >= shares[at]) at += 1;
|
|
26
|
+
return at;
|
|
27
|
+
}
|
|
28
|
+
function cached(r, key, build) {
|
|
29
|
+
const kept = r.noiseTileCache.get(key);
|
|
30
|
+
if (kept) return kept;
|
|
31
|
+
const image = r.ck.MakeImage({
|
|
32
|
+
width: NOISE_TILE_CELLS,
|
|
33
|
+
height: NOISE_TILE_CELLS,
|
|
34
|
+
alphaType: r.ck.AlphaType.Unpremul,
|
|
35
|
+
colorType: r.ck.ColorType.RGBA_8888,
|
|
36
|
+
colorSpace: skColorSpace(r.ck, r.documentColorSpace)
|
|
37
|
+
}, build(), NOISE_TILE_CELLS * 4);
|
|
38
|
+
if (!image) return null;
|
|
39
|
+
r.noiseTileCache.set(key, image);
|
|
40
|
+
return image;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Each cell's level under `shares` in red, and the level of its opposite value, which a duotone's
|
|
44
|
+
* second colour shows, in green, as multiples of `LEVEL_STEP`.
|
|
45
|
+
*/
|
|
46
|
+
function noiseLevelTile(r, shares, seed) {
|
|
47
|
+
return cached(r, `levels:${seed}:${shares.join(",")}`, () => {
|
|
48
|
+
const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4);
|
|
49
|
+
for (let y = 0; y < NOISE_TILE_CELLS; y++) for (let x = 0; x < NOISE_TILE_CELLS; x++) {
|
|
50
|
+
const u = cellValue(x, y, seed, 0);
|
|
51
|
+
const at = (y * NOISE_TILE_CELLS + x) * 4;
|
|
52
|
+
pixels[at] = level(u, shares) * 15;
|
|
53
|
+
pixels[at + 1] = level(1 - u - CELL_VALUE_STEP, shares) * 15;
|
|
54
|
+
pixels[at + 3] = 255;
|
|
55
|
+
}
|
|
56
|
+
return pixels;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** A random colour for each cell of a multitone noise. */
|
|
60
|
+
function noiseColorTile(r, seed) {
|
|
61
|
+
return cached(r, `colors:${seed}`, () => {
|
|
62
|
+
const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4);
|
|
63
|
+
for (let y = 0; y < NOISE_TILE_CELLS; y++) for (let x = 0; x < NOISE_TILE_CELLS; x++) {
|
|
64
|
+
const at = (y * NOISE_TILE_CELLS + x) * 4;
|
|
65
|
+
for (let channel = 0; channel < 3; channel++) pixels[at + channel] = Math.floor(cellValue(x, y, seed, channel + 1) * 256);
|
|
66
|
+
pixels[at + 3] = 255;
|
|
67
|
+
}
|
|
68
|
+
return pixels;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { LEVEL_STEP, NOISE_TILE_CELLS, cellValue, noiseColorTile, noiseLevelTile };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=tile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile.js","names":[],"sources":["../../../src/canvas/noise/tile.ts"],"sourcesContent":["import type { Image } from 'canvaskit-wasm'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { skColorSpace } from '#core/canvas/renderer/colors'\n\n/**\n * Cells on each side of a noise tile, which repeats beyond them: wide enough that the repeat lies\n * past a thousand grains, small enough to build in a few milliseconds and keep in 4 MB.\n */\nexport const NOISE_TILE_CELLS = 1024\n\n/** What a level byte holds: 15 per level, so the 17 levels stay exact through 8 bits. */\nexport const LEVEL_STEP = 15\n\n/** The step between a cell's possible values, the hash's 32 bits. */\nconst CELL_VALUE_STEP = 2 ** -32\n\n/** A cell's uniform value from its index and the seed: a 32-bit integer hash. */\nexport function cellValue(x: number, y: number, seed: number, salt: number): number {\n let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1) ^ Math.imul(seed + salt, 0x9e3779b9)\n h ^= h >>> 16\n h = Math.imul(h, 0x7feb352d)\n h ^= h >>> 15\n h = Math.imul(h, 0x846ca68b)\n h ^= h >>> 16\n return (h >>> 0) * CELL_VALUE_STEP\n}\n\n/** The level a uniform value takes under `shares`, the share of pixels at each level or below. */\nfunction level(u: number, shares: readonly number[]): number {\n let at = 0\n while (at < shares.length && u >= shares[at]) at += 1\n return at\n}\n\nfunction cached(r: SkiaRenderer, key: string, build: () => Uint8Array): Image | null {\n const kept = r.noiseTileCache.get(key)\n if (kept) return kept\n const image = r.ck.MakeImage(\n {\n width: NOISE_TILE_CELLS,\n height: NOISE_TILE_CELLS,\n alphaType: r.ck.AlphaType.Unpremul,\n colorType: r.ck.ColorType.RGBA_8888,\n colorSpace: skColorSpace(r.ck, r.documentColorSpace)\n },\n build(),\n NOISE_TILE_CELLS * 4\n )\n if (!image) return null\n r.noiseTileCache.set(key, image)\n return image\n}\n\n/**\n * Each cell's level under `shares` in red, and the level of its opposite value, which a duotone's\n * second colour shows, in green, as multiples of `LEVEL_STEP`.\n */\nexport function noiseLevelTile(\n r: SkiaRenderer,\n shares: readonly number[],\n seed: number\n): Image | null {\n return cached(r, `levels:${seed}:${shares.join(',')}`, () => {\n const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4)\n for (let y = 0; y < NOISE_TILE_CELLS; y++) {\n for (let x = 0; x < NOISE_TILE_CELLS; x++) {\n const u = cellValue(x, y, seed, 0)\n const at = (y * NOISE_TILE_CELLS + x) * 4\n pixels[at] = level(u, shares) * LEVEL_STEP\n // The opposite value, reflected within [0, 1) as the hash is, so no cell reaches 1.\n pixels[at + 1] = level(1 - u - CELL_VALUE_STEP, shares) * LEVEL_STEP\n pixels[at + 3] = 255\n }\n }\n return pixels\n })\n}\n\n/** A random colour for each cell of a multitone noise. */\nexport function noiseColorTile(r: SkiaRenderer, seed: number): Image | null {\n return cached(r, `colors:${seed}`, () => {\n const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4)\n for (let y = 0; y < NOISE_TILE_CELLS; y++) {\n for (let x = 0; x < NOISE_TILE_CELLS; x++) {\n const at = (y * NOISE_TILE_CELLS + x) * 4\n for (let channel = 0; channel < 3; channel++) {\n pixels[at + channel] = Math.floor(cellValue(x, y, seed, channel + 1) * 256)\n }\n pixels[at + 3] = 255\n }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C,MAAM,MAAM,IAAI,mBAAmB,KAAK;GACxC,OAAO,MAAM,MAAM,GAAG,MAAM,IAAA;GAE5B,OAAO,KAAK,KAAK,MAAM,IAAI,IAAI,iBAAiB,MAAM,IAAA;GACtD,OAAO,KAAK,KAAK;EACnB;EAEF,OAAO;CACT,CAAC;AACH;;AAGA,SAAgB,eAAe,GAAiB,MAA4B;CAC1E,OAAO,OAAO,GAAG,UAAU,cAAc;EACvC,MAAM,SAAS,IAAI,WAAW,mBAAmB,mBAAmB,CAAC;EACrE,KAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,KACpC,KAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,KAAK;GACzC,MAAM,MAAM,IAAI,mBAAmB,KAAK;GACxC,KAAK,IAAI,UAAU,GAAG,UAAU,GAAG,WACjC,OAAO,KAAK,WAAW,KAAK,MAAM,UAAU,GAAG,GAAG,MAAM,UAAU,CAAC,IAAI,GAAG;GAE5E,OAAO,KAAK,KAAK;EACnB;EAEF,OAAO;CACT,CAAC;AACH"}
|
|
@@ -2,8 +2,8 @@ import { textGlyphPaths } from "./text/outlines.js";
|
|
|
2
2
|
import { baseShapePath, canContainFlattenableChildren, canMakeBooleanSourcePath, makeBooleanOperationPath, nodeHasVisibleFill, nodeHasVisibleStroke, placedPath, strokeAreaPath, windingRuleOf } from "./boolean.js";
|
|
3
3
|
import { copyFills } from "@pairdraw/scene-graph/copy";
|
|
4
4
|
import { getNodeLocalMatrix, localTransformFromWorld } from "@pairdraw/scene-graph/coordinate";
|
|
5
|
-
import { parseSVGPath } from "@pairdraw/scene-graph/parse-path";
|
|
6
5
|
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
6
|
+
import { parseSVGPath } from "@pairdraw/scene-graph/parse-path";
|
|
7
7
|
import { omit, pick } from "es-toolkit/object";
|
|
8
8
|
//#region src/canvas/outline-stroke.ts
|
|
9
9
|
/** What the outlines keep of the layer they replace, as Figma's do. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-layout-hover.d.ts","names":[],"sources":["../../../src/canvas/overlays/auto-layout-hover.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"auto-layout-hover.d.ts","names":[],"sources":["../../../src/canvas/overlays/auto-layout-hover.ts"],"mappings":";;;;;iBA6PgB,oBACd,GAAG,cACH,QAAQ,QACR,OAAO,YACP,QAAQ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS } from "../../constants.js";
|
|
2
2
|
import { strokeLayoutChildren } from "./layout-outlines.js";
|
|
3
|
+
import { measureAutoLayoutHandles } from "../../layout/auto-layout-handles.js";
|
|
3
4
|
//#region src/canvas/overlays/auto-layout-hover.ts
|
|
4
5
|
function visibleLayoutChildren(node, graph) {
|
|
5
6
|
return node.childIds.map((id) => graph.getNode(id)).filter((child) => !!child && child.visible && child.layoutPositioning !== "ABSOLUTE");
|
|
@@ -68,100 +69,59 @@ function drawValuePill(r, canvas, text, x, y, color) {
|
|
|
68
69
|
r.auxFill.setColor(r.ck.Color4f(1, 1, 1, 1));
|
|
69
70
|
canvas.drawText(text, x - advance / 2, y - (top + bottom) / 2, r.auxFill, font);
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
-
const children = visibleLayoutChildren(node, graph);
|
|
73
|
-
if (children.length < 2 || node.itemSpacing <= 0) return [];
|
|
72
|
+
function absoluteRect(graph, node, rect) {
|
|
74
73
|
const abs = graph.getAbsolutePosition(node.id);
|
|
75
|
-
const isRow = node.layoutMode === "HORIZONTAL";
|
|
76
|
-
const rects = [];
|
|
77
|
-
for (let i = 0; i < children.length - 1; i++) {
|
|
78
|
-
const prev = children[i];
|
|
79
|
-
const next = children[i + 1];
|
|
80
|
-
const gapStart = isRow ? prev.x + prev.width : prev.y + prev.height;
|
|
81
|
-
const gapEnd = isRow ? next.x : next.y;
|
|
82
|
-
if (gapEnd <= gapStart) continue;
|
|
83
|
-
rects.push(isRow ? [
|
|
84
|
-
abs.x + gapStart,
|
|
85
|
-
abs.y + node.paddingTop,
|
|
86
|
-
gapEnd - gapStart,
|
|
87
|
-
node.height - node.paddingTop - node.paddingBottom
|
|
88
|
-
] : [
|
|
89
|
-
abs.x + node.paddingLeft,
|
|
90
|
-
abs.y + gapStart,
|
|
91
|
-
node.width - node.paddingLeft - node.paddingRight,
|
|
92
|
-
gapEnd - gapStart
|
|
93
|
-
]);
|
|
94
|
-
}
|
|
95
|
-
return rects;
|
|
96
|
-
}
|
|
97
|
-
function paddingRect(node, graph, side) {
|
|
98
|
-
if (!side) return null;
|
|
99
|
-
const abs = graph.getAbsolutePosition(node.id);
|
|
100
|
-
if (side === "top") return [
|
|
101
|
-
abs.x,
|
|
102
|
-
abs.y,
|
|
103
|
-
node.width,
|
|
104
|
-
node.paddingTop
|
|
105
|
-
];
|
|
106
|
-
if (side === "bottom") return [
|
|
107
|
-
abs.x,
|
|
108
|
-
abs.y + node.height - node.paddingBottom,
|
|
109
|
-
node.width,
|
|
110
|
-
node.paddingBottom
|
|
111
|
-
];
|
|
112
|
-
if (side === "left") return [
|
|
113
|
-
abs.x,
|
|
114
|
-
abs.y,
|
|
115
|
-
node.paddingLeft,
|
|
116
|
-
node.height
|
|
117
|
-
];
|
|
118
74
|
return [
|
|
119
|
-
abs.x +
|
|
120
|
-
abs.y,
|
|
121
|
-
|
|
122
|
-
|
|
75
|
+
abs.x + rect.x,
|
|
76
|
+
abs.y + rect.y,
|
|
77
|
+
rect.width,
|
|
78
|
+
rect.height
|
|
123
79
|
];
|
|
124
80
|
}
|
|
125
|
-
function drawBaselineTicks(r, canvas, graph, node) {
|
|
81
|
+
function drawBaselineTicks(r, canvas, graph, node, layout) {
|
|
126
82
|
const abs = graph.getAbsolutePosition(node.id);
|
|
127
83
|
const xCenter = (abs.x + node.width / 2) * r.zoom + r.panX;
|
|
128
84
|
const yCenter = (abs.y + node.height / 2) * r.zoom + r.panY;
|
|
129
|
-
setStroke(r,
|
|
85
|
+
setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA);
|
|
130
86
|
if (node.paddingTop > 0) drawHorizontalTick(r, canvas, xCenter, (abs.y + node.paddingTop / 2) * r.zoom + r.panY);
|
|
131
87
|
if (node.paddingBottom > 0) drawHorizontalTick(r, canvas, xCenter, (abs.y + node.height - node.paddingBottom / 2) * r.zoom + r.panY);
|
|
132
88
|
if (node.paddingLeft > 0) drawVerticalTick(r, canvas, (abs.x + node.paddingLeft / 2) * r.zoom + r.panX, yCenter);
|
|
133
89
|
if (node.paddingRight > 0) drawVerticalTick(r, canvas, (abs.x + node.width - node.paddingRight / 2) * r.zoom + r.panX, yCenter);
|
|
134
90
|
setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA);
|
|
135
|
-
for (const
|
|
136
|
-
const [x, y, width, height] = rect;
|
|
137
|
-
if (
|
|
91
|
+
for (const gap of layout.gaps) {
|
|
92
|
+
const [x, y, width, height] = absoluteRect(graph, node, gap.rect);
|
|
93
|
+
if (width <= height) drawVerticalTick(r, canvas, (x + width / 2) * r.zoom + r.panX, yCenter);
|
|
138
94
|
else drawHorizontalTick(r, canvas, xCenter, (y + height / 2) * r.zoom + r.panY);
|
|
139
95
|
}
|
|
140
96
|
}
|
|
141
|
-
function drawSpacingHover(r, canvas, graph, node, showValue) {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
if (!
|
|
145
|
-
|
|
146
|
-
|
|
97
|
+
function drawSpacingHover(r, canvas, graph, node, layout, hover, showValue) {
|
|
98
|
+
const handles = layout.gaps;
|
|
99
|
+
const shown = handles.find((gap) => gap.axis === (hover.axis ?? "primary") && gap.index === hover.index) ?? handles.at(0);
|
|
100
|
+
if (!shown) return;
|
|
101
|
+
drawStripedRect(r, canvas, absoluteRect(graph, node, shown.rect), AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL);
|
|
102
|
+
if (!showValue) return;
|
|
103
|
+
const [x, y, width, height] = absoluteRect(graph, node, shown.rect);
|
|
104
|
+
drawValuePill(r, canvas, String(Math.round(shown.value)), (x + width / 2) * r.zoom + r.panX + 18, (y + height / 2) * r.zoom + r.panY - 18, AUTO_LAYOUT_HOVER_GAP_PILL);
|
|
147
105
|
}
|
|
148
|
-
function drawPaddingHover(r, canvas, graph, node, hover, showValue) {
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
151
|
-
|
|
106
|
+
function drawPaddingHover(r, canvas, graph, node, layout, hover, showValue) {
|
|
107
|
+
const handle = layout.padding.find((padding) => padding.side === hover.side);
|
|
108
|
+
if (!handle) return;
|
|
109
|
+
const rect = absoluteRect(graph, node, handle.rect);
|
|
110
|
+
drawStripedRect(r, canvas, rect, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL);
|
|
152
111
|
if (!showValue) return;
|
|
153
112
|
const [x, y, width, height] = rect;
|
|
154
|
-
|
|
155
|
-
drawValuePill(r, canvas, String(Math.round(value)), (x + width / 2) * r.zoom + r.panX + 18, (y + height / 2) * r.zoom + r.panY - 18, AUTO_LAYOUT_HOVER_PADDING_PILL);
|
|
113
|
+
drawValuePill(r, canvas, String(Math.round(handle.value)), (x + width / 2) * r.zoom + r.panX + 18, (y + height / 2) * r.zoom + r.panY - 18, AUTO_LAYOUT_HOVER_GAP_PILL);
|
|
156
114
|
}
|
|
157
115
|
function drawAutoLayoutHover(r, canvas, graph, hover) {
|
|
158
116
|
if (!hover) return;
|
|
159
117
|
const node = graph.getNode(hover.nodeId);
|
|
160
118
|
if (!node || node.layoutMode !== "HORIZONTAL" && node.layoutMode !== "VERTICAL") return;
|
|
119
|
+
const layout = measureAutoLayoutHandles(node, visibleLayoutChildren(node, graph));
|
|
120
|
+
if (!layout) return;
|
|
161
121
|
if (hover.kind === "children") strokeLayoutChildren(r, canvas, graph, node);
|
|
162
|
-
if (hover.kind === "spacing" || hover.kind === "spacing-value") drawSpacingHover(r, canvas, graph, node, hover.kind === "spacing-value");
|
|
163
|
-
if (hover.kind === "padding" || hover.kind === "padding-value") drawPaddingHover(r, canvas, graph, node, hover, hover.kind === "padding-value");
|
|
164
|
-
drawBaselineTicks(r, canvas, graph, node);
|
|
122
|
+
if (hover.kind === "spacing" || hover.kind === "spacing-value") drawSpacingHover(r, canvas, graph, node, layout, hover, hover.kind === "spacing-value");
|
|
123
|
+
if (hover.kind === "padding" || hover.kind === "padding-value") drawPaddingHover(r, canvas, graph, node, layout, hover, hover.kind === "padding-value");
|
|
124
|
+
drawBaselineTicks(r, canvas, graph, node, layout);
|
|
165
125
|
}
|
|
166
126
|
//#endregion
|
|
167
127
|
export { drawAutoLayoutHover };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-layout-hover.js","names":[],"sources":["../../../src/canvas/overlays/auto-layout-hover.ts"],"sourcesContent":["import type { Canvas } from 'canvaskit-wasm'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { strokeLayoutChildren } from '#core/canvas/overlays/layout-outlines'\nimport type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'\nimport {\n AUTO_LAYOUT_HOVER_BLUE,\n AUTO_LAYOUT_HOVER_BLUE_FILL,\n AUTO_LAYOUT_HOVER_MAGENTA,\n AUTO_LAYOUT_HOVER_MAGENTA_FILL,\n AUTO_LAYOUT_HOVER_STRIPE_GAP,\n AUTO_LAYOUT_HOVER_STRIPE_WIDTH,\n AUTO_LAYOUT_HOVER_STROKE_WIDTH,\n AUTO_LAYOUT_HOVER_TICK_LENGTH,\n AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_GAP_PILL,\n AUTO_LAYOUT_HOVER_PADDING_PILL,\n AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT,\n AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X,\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS\n} from '#core/constants'\n\ntype Hover = NonNullable<RenderOverlays['autoLayoutHover']>\ntype RectTuple = [x: number, y: number, width: number, height: number]\n\nfunction visibleLayoutChildren(node: SceneNode, graph: SceneGraph) {\n return node.childIds\n .map((id) => graph.getNode(id))\n .filter(\n (child): child is SceneNode =>\n !!child && child.visible && child.layoutPositioning !== 'ABSOLUTE'\n )\n}\n\nfunction canvasColor(r: SkiaRenderer, color: Color) {\n return r.ck.Color4f(color.r, color.g, color.b, color.a)\n}\n\nfunction setStroke(r: SkiaRenderer, color: Color) {\n r.auxStroke.setStrokeWidth(AUTO_LAYOUT_HOVER_STROKE_WIDTH)\n r.auxStroke.setColor(canvasColor(r, color))\n r.auxStroke.setPathEffect(null)\n}\n\nfunction drawHorizontalTick(r: SkiaRenderer, canvas: Canvas, x: number, y: number) {\n canvas.drawLine(\n x - AUTO_LAYOUT_HOVER_TICK_LENGTH,\n y,\n x + AUTO_LAYOUT_HOVER_TICK_LENGTH,\n y,\n r.auxStroke\n )\n}\n\nfunction drawVerticalTick(r: SkiaRenderer, canvas: Canvas, x: number, y: number) {\n canvas.drawLine(\n x,\n y - AUTO_LAYOUT_HOVER_TICK_LENGTH,\n x,\n y + AUTO_LAYOUT_HOVER_TICK_LENGTH,\n r.auxStroke\n )\n}\n\nfunction toScreenRect(r: SkiaRenderer, [x, y, width, height]: RectTuple) {\n return r.ck.LTRBRect(\n x * r.zoom + r.panX,\n y * r.zoom + r.panY,\n (x + width) * r.zoom + r.panX,\n (y + height) * r.zoom + r.panY\n )\n}\n\nfunction drawStripedRect(\n r: SkiaRenderer,\n canvas: Canvas,\n rectTuple: RectTuple,\n color: Color,\n fill: Color\n) {\n const [, , width, height] = rectTuple\n if (width <= 0 || height <= 0) return\n const rect = toScreenRect(r, rectTuple)\n r.auxFill.setColor(canvasColor(r, fill))\n canvas.drawRect(rect, r.auxFill)\n\n const path = new r.ck.PathBuilder()\n const left = rect[0]\n const top = rect[1]\n const right = rect[2]\n const bottom = rect[3]\n for (let sx = left - (bottom - top); sx < right; sx += AUTO_LAYOUT_HOVER_STRIPE_GAP) {\n path.moveTo(sx, bottom)\n path.lineTo(sx + (bottom - top), top)\n }\n r.auxStroke.setStrokeWidth(AUTO_LAYOUT_HOVER_STRIPE_WIDTH)\n r.auxStroke.setColor(canvasColor(r, color))\n r.auxStroke.setPathEffect(null)\n canvas.save()\n canvas.clipRect(rect, r.ck.ClipOp.Intersect, true)\n const immutablePath = path.detachAndDelete()\n canvas.drawPath(immutablePath, r.auxStroke)\n canvas.restore()\n immutablePath.delete()\n}\n\n/** A value in a pill as wide as its text, its digits centred, as Figma draws padding and gaps. */\nfunction drawValuePill(\n r: SkiaRenderer,\n canvas: Canvas,\n text: string,\n x: number,\n y: number,\n color: Color\n) {\n const font = r.valueFont ?? r.labelFont\n if (!font) return\n const glyphs = font.getGlyphIDs(text)\n let advance = 0\n for (const glyphWidth of font.getGlyphWidths(glyphs)) advance += glyphWidth\n // The ink's top and bottom, so the digits sit in the middle whatever the font's metrics.\n const bounds = font.getGlyphBounds(glyphs)\n let top = 0\n let bottom = 0\n for (let i = 0; i < bounds.length; i += 4) {\n top = Math.min(top, bounds[i + 1])\n bottom = Math.max(bottom, bounds[i + 3])\n }\n const width = advance + AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X * 2\n const height = AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT\n const rect = r.ck.RRectXY(\n r.ck.LTRBRect(x - width / 2, y - height / 2, x + width / 2, y + height / 2),\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS,\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS\n )\n r.auxFill.setColor(canvasColor(r, color))\n canvas.drawRRect(rect, r.auxFill)\n r.auxFill.setColor(r.ck.Color4f(1, 1, 1, 1))\n canvas.drawText(text, x - advance / 2, y - (top + bottom) / 2, r.auxFill, font)\n}\n\nfunction gapRects(node: SceneNode, graph: SceneGraph): RectTuple[] {\n const children = visibleLayoutChildren(node, graph)\n if (children.length < 2 || node.itemSpacing <= 0) return []\n const abs = graph.getAbsolutePosition(node.id)\n const isRow = node.layoutMode === 'HORIZONTAL'\n const rects: RectTuple[] = []\n\n for (let i = 0; i < children.length - 1; i++) {\n const prev = children[i]\n const next = children[i + 1]\n const gapStart = isRow ? prev.x + prev.width : prev.y + prev.height\n const gapEnd = isRow ? next.x : next.y\n if (gapEnd <= gapStart) continue\n rects.push(\n isRow\n ? [\n abs.x + gapStart,\n abs.y + node.paddingTop,\n gapEnd - gapStart,\n node.height - node.paddingTop - node.paddingBottom\n ]\n : [\n abs.x + node.paddingLeft,\n abs.y + gapStart,\n node.width - node.paddingLeft - node.paddingRight,\n gapEnd - gapStart\n ]\n )\n }\n return rects\n}\n\nfunction paddingRect(node: SceneNode, graph: SceneGraph, side: Hover['side']): RectTuple | null {\n if (!side) return null\n const abs = graph.getAbsolutePosition(node.id)\n if (side === 'top') return [abs.x, abs.y, node.width, node.paddingTop]\n if (side === 'bottom') {\n return [abs.x, abs.y + node.height - node.paddingBottom, node.width, node.paddingBottom]\n }\n if (side === 'left') return [abs.x, abs.y, node.paddingLeft, node.height]\n return [abs.x + node.width - node.paddingRight, abs.y, node.paddingRight, node.height]\n}\n\nfunction drawBaselineTicks(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph, node: SceneNode) {\n const abs = graph.getAbsolutePosition(node.id)\n const xCenter = (abs.x + node.width / 2) * r.zoom + r.panX\n const yCenter = (abs.y + node.height / 2) * r.zoom + r.panY\n\n setStroke(r, AUTO_LAYOUT_HOVER_BLUE)\n if (node.paddingTop > 0) {\n drawHorizontalTick(r, canvas, xCenter, (abs.y + node.paddingTop / 2) * r.zoom + r.panY)\n }\n if (node.paddingBottom > 0) {\n drawHorizontalTick(\n r,\n canvas,\n xCenter,\n (abs.y + node.height - node.paddingBottom / 2) * r.zoom + r.panY\n )\n }\n if (node.paddingLeft > 0) {\n drawVerticalTick(r, canvas, (abs.x + node.paddingLeft / 2) * r.zoom + r.panX, yCenter)\n }\n if (node.paddingRight > 0) {\n drawVerticalTick(\n r,\n canvas,\n (abs.x + node.width - node.paddingRight / 2) * r.zoom + r.panX,\n yCenter\n )\n }\n\n setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA)\n for (const rect of gapRects(node, graph)) {\n const [x, y, width, height] = rect\n if (node.layoutMode === 'HORIZONTAL') {\n drawVerticalTick(r, canvas, (x + width / 2) * r.zoom + r.panX, yCenter)\n } else {\n drawHorizontalTick(r, canvas, xCenter, (y + height / 2) * r.zoom + r.panY)\n }\n }\n}\n\nfunction drawSpacingHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n node: SceneNode,\n showValue: boolean\n) {\n const rects = gapRects(node, graph)\n for (const rect of rects) {\n drawStripedRect(r, canvas, rect, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL)\n }\n if (!showValue || rects.length === 0) return\n const [x, y, width, height] = rects[0]\n drawValuePill(\n r,\n canvas,\n String(Math.round(node.itemSpacing)),\n (x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n (y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_GAP_PILL\n )\n}\n\nfunction drawPaddingHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n node: SceneNode,\n hover: Hover,\n showValue: boolean\n) {\n const rect = paddingRect(node, graph, hover.side)\n if (!rect) return\n drawStripedRect(r, canvas, rect, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL)\n if (!showValue) return\n const [x, y, width, height] = rect\n const value = hover.side === 'left' || hover.side === 'right' ? width : height\n drawValuePill(\n r,\n canvas,\n String(Math.round(value)),\n (x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n (y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_PADDING_PILL\n )\n}\n\nexport function drawAutoLayoutHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n hover?: RenderOverlays['autoLayoutHover']\n): void {\n if (!hover) return\n const node = graph.getNode(hover.nodeId)\n if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return\n\n if (hover.kind === 'children') strokeLayoutChildren(r, canvas, graph, node)\n if (hover.kind === 'spacing' || hover.kind === 'spacing-value') {\n drawSpacingHover(r, canvas, graph, node, hover.kind === 'spacing-value')\n }\n if (hover.kind === 'padding' || hover.kind === 'padding-value') {\n drawPaddingHover(r, canvas, graph, node, hover, hover.kind === 'padding-value')\n }\n drawBaselineTicks(r, canvas, graph, node)\n}\n"],"mappings":";;;AA2BA,SAAS,sBAAsB,MAAiB,OAAmB;CACjE,OAAO,KAAK,SACT,KAAK,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CAC9B,QACE,UACC,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,sBAAsB,UAC5D;AACJ;AAEA,SAAS,YAAY,GAAiB,OAAc;CAClD,OAAO,EAAE,GAAG,QAAQ,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACxD;AAEA,SAAS,UAAU,GAAiB,OAAc;CAChD,EAAE,UAAU,eAAe,8BAA8B;CACzD,EAAE,UAAU,SAAS,YAAY,GAAG,KAAK,CAAC;CAC1C,EAAE,UAAU,cAAc,IAAI;AAChC;AAEA,SAAS,mBAAmB,GAAiB,QAAgB,GAAW,GAAW;CACjF,OAAO,SACL,IAAA,IACA,GACA,IAAA,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WAAW;CAChB,MAAM,CAAC,GAAG,GAAG,OAAO,UAAU;CAC9B,MAAM,QAAQ,MAAM,SAAS,UAAU,MAAM,SAAS,UAAU,QAAQ;CACxE,cACE,GACA,QACA,OAAO,KAAK,MAAM,KAAK,CAAC,IACvB,IAAI,QAAQ,KAAK,EAAE,OAAO,EAAE,OAAA,KAC5B,IAAI,SAAS,KAAK,EAAE,OAAO,EAAE,OAAA,IAC9B,8BACF;AACF;AAEA,SAAgB,oBACd,GACA,QACA,OACA,OACM;CACN,IAAI,CAAC,OAAO;CACZ,MAAM,OAAO,MAAM,QAAQ,MAAM,MAAM;CACvC,IAAI,CAAC,QAAS,KAAK,eAAe,gBAAgB,KAAK,eAAe,YAAa;CAEnF,IAAI,MAAM,SAAS,YAAY,qBAAqB,GAAG,QAAQ,OAAO,IAAI;CAC1E,IAAI,MAAM,SAAS,aAAa,MAAM,SAAS,iBAC7C,iBAAiB,GAAG,QAAQ,OAAO,MAAM,MAAM,SAAS,eAAe;CAEzE,IAAI,MAAM,SAAS,aAAa,MAAM,SAAS,iBAC7C,iBAAiB,GAAG,QAAQ,OAAO,MAAM,OAAO,MAAM,SAAS,eAAe;CAEhF,kBAAkB,GAAG,QAAQ,OAAO,IAAI;AAC1C"}
|
|
1
|
+
{"version":3,"file":"auto-layout-hover.js","names":[],"sources":["../../../src/canvas/overlays/auto-layout-hover.ts"],"sourcesContent":["import type { Canvas } from 'canvaskit-wasm'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport type { Color, Rect } from '@pairdraw/scene-graph/primitives'\n\nimport { strokeLayoutChildren } from '#core/canvas/overlays/layout-outlines'\nimport type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'\nimport {\n AUTO_LAYOUT_HOVER_MAGENTA,\n AUTO_LAYOUT_HOVER_MAGENTA_FILL,\n AUTO_LAYOUT_HOVER_STRIPE_GAP,\n AUTO_LAYOUT_HOVER_STRIPE_WIDTH,\n AUTO_LAYOUT_HOVER_STROKE_WIDTH,\n AUTO_LAYOUT_HOVER_TICK_LENGTH,\n AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_GAP_PILL,\n AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT,\n AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X,\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS\n} from '#core/constants'\nimport {\n measureAutoLayoutHandles,\n type AutoLayoutHandleLayout\n} from '#core/layout/auto-layout-handles'\n\ntype Hover = NonNullable<RenderOverlays['autoLayoutHover']>\ntype RectTuple = [x: number, y: number, width: number, height: number]\n\nfunction visibleLayoutChildren(node: SceneNode, graph: SceneGraph) {\n return node.childIds\n .map((id) => graph.getNode(id))\n .filter(\n (child): child is SceneNode =>\n !!child && child.visible && child.layoutPositioning !== 'ABSOLUTE'\n )\n}\n\nfunction canvasColor(r: SkiaRenderer, color: Color) {\n return r.ck.Color4f(color.r, color.g, color.b, color.a)\n}\n\nfunction setStroke(r: SkiaRenderer, color: Color) {\n r.auxStroke.setStrokeWidth(AUTO_LAYOUT_HOVER_STROKE_WIDTH)\n r.auxStroke.setColor(canvasColor(r, color))\n r.auxStroke.setPathEffect(null)\n}\n\nfunction drawHorizontalTick(r: SkiaRenderer, canvas: Canvas, x: number, y: number) {\n canvas.drawLine(\n x - AUTO_LAYOUT_HOVER_TICK_LENGTH,\n y,\n x + AUTO_LAYOUT_HOVER_TICK_LENGTH,\n y,\n r.auxStroke\n )\n}\n\nfunction drawVerticalTick(r: SkiaRenderer, canvas: Canvas, x: number, y: number) {\n canvas.drawLine(\n x,\n y - AUTO_LAYOUT_HOVER_TICK_LENGTH,\n x,\n y + AUTO_LAYOUT_HOVER_TICK_LENGTH,\n r.auxStroke\n )\n}\n\nfunction toScreenRect(r: SkiaRenderer, [x, y, width, height]: RectTuple) {\n return r.ck.LTRBRect(\n x * r.zoom + r.panX,\n y * r.zoom + r.panY,\n (x + width) * r.zoom + r.panX,\n (y + height) * r.zoom + r.panY\n )\n}\n\nfunction drawStripedRect(\n r: SkiaRenderer,\n canvas: Canvas,\n rectTuple: RectTuple,\n color: Color,\n fill: Color\n) {\n const [, , width, height] = rectTuple\n if (width <= 0 || height <= 0) return\n const rect = toScreenRect(r, rectTuple)\n r.auxFill.setColor(canvasColor(r, fill))\n canvas.drawRect(rect, r.auxFill)\n\n const path = new r.ck.PathBuilder()\n const left = rect[0]\n const top = rect[1]\n const right = rect[2]\n const bottom = rect[3]\n for (let sx = left - (bottom - top); sx < right; sx += AUTO_LAYOUT_HOVER_STRIPE_GAP) {\n path.moveTo(sx, bottom)\n path.lineTo(sx + (bottom - top), top)\n }\n r.auxStroke.setStrokeWidth(AUTO_LAYOUT_HOVER_STRIPE_WIDTH)\n r.auxStroke.setColor(canvasColor(r, color))\n r.auxStroke.setPathEffect(null)\n canvas.save()\n canvas.clipRect(rect, r.ck.ClipOp.Intersect, true)\n const immutablePath = path.detachAndDelete()\n canvas.drawPath(immutablePath, r.auxStroke)\n canvas.restore()\n immutablePath.delete()\n}\n\n/** A value in a pill as wide as its text, its digits centred, as Figma draws padding and gaps. */\nfunction drawValuePill(\n r: SkiaRenderer,\n canvas: Canvas,\n text: string,\n x: number,\n y: number,\n color: Color\n) {\n const font = r.valueFont ?? r.labelFont\n if (!font) return\n const glyphs = font.getGlyphIDs(text)\n let advance = 0\n for (const glyphWidth of font.getGlyphWidths(glyphs)) advance += glyphWidth\n // The ink's top and bottom, so the digits sit in the middle whatever the font's metrics.\n const bounds = font.getGlyphBounds(glyphs)\n let top = 0\n let bottom = 0\n for (let i = 0; i < bounds.length; i += 4) {\n top = Math.min(top, bounds[i + 1])\n bottom = Math.max(bottom, bounds[i + 3])\n }\n const width = advance + AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X * 2\n const height = AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT\n const rect = r.ck.RRectXY(\n r.ck.LTRBRect(x - width / 2, y - height / 2, x + width / 2, y + height / 2),\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS,\n AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS\n )\n r.auxFill.setColor(canvasColor(r, color))\n canvas.drawRRect(rect, r.auxFill)\n r.auxFill.setColor(r.ck.Color4f(1, 1, 1, 1))\n canvas.drawText(text, x - advance / 2, y - (top + bottom) / 2, r.auxFill, font)\n}\n\nfunction absoluteRect(graph: SceneGraph, node: SceneNode, rect: Rect): RectTuple {\n const abs = graph.getAbsolutePosition(node.id)\n return [abs.x + rect.x, abs.y + rect.y, rect.width, rect.height]\n}\n\nfunction drawBaselineTicks(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n node: SceneNode,\n layout: AutoLayoutHandleLayout\n) {\n const abs = graph.getAbsolutePosition(node.id)\n const xCenter = (abs.x + node.width / 2) * r.zoom + r.panX\n const yCenter = (abs.y + node.height / 2) * r.zoom + r.panY\n\n setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA)\n if (node.paddingTop > 0) {\n drawHorizontalTick(r, canvas, xCenter, (abs.y + node.paddingTop / 2) * r.zoom + r.panY)\n }\n if (node.paddingBottom > 0) {\n drawHorizontalTick(\n r,\n canvas,\n xCenter,\n (abs.y + node.height - node.paddingBottom / 2) * r.zoom + r.panY\n )\n }\n if (node.paddingLeft > 0) {\n drawVerticalTick(r, canvas, (abs.x + node.paddingLeft / 2) * r.zoom + r.panX, yCenter)\n }\n if (node.paddingRight > 0) {\n drawVerticalTick(\n r,\n canvas,\n (abs.x + node.width - node.paddingRight / 2) * r.zoom + r.panX,\n yCenter\n )\n }\n\n setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA)\n for (const gap of layout.gaps) {\n const [x, y, width, height] = absoluteRect(graph, node, gap.rect)\n if (width <= height) {\n drawVerticalTick(r, canvas, (x + width / 2) * r.zoom + r.panX, yCenter)\n } else {\n drawHorizontalTick(r, canvas, xCenter, (y + height / 2) * r.zoom + r.panY)\n }\n }\n}\n\nfunction drawSpacingHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n node: SceneNode,\n layout: AutoLayoutHandleLayout,\n hover: Hover,\n showValue: boolean\n) {\n const handles = layout.gaps\n const shown =\n handles.find((gap) => gap.axis === (hover.axis ?? 'primary') && gap.index === hover.index) ??\n handles.at(0)\n if (!shown) return\n drawStripedRect(\n r,\n canvas,\n absoluteRect(graph, node, shown.rect),\n AUTO_LAYOUT_HOVER_MAGENTA,\n AUTO_LAYOUT_HOVER_MAGENTA_FILL\n )\n if (!showValue) return\n const [x, y, width, height] = absoluteRect(graph, node, shown.rect)\n drawValuePill(\n r,\n canvas,\n String(Math.round(shown.value)),\n (x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n (y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_GAP_PILL\n )\n}\n\nfunction drawPaddingHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n node: SceneNode,\n layout: AutoLayoutHandleLayout,\n hover: Hover,\n showValue: boolean\n) {\n const handle = layout.padding.find((padding) => padding.side === hover.side)\n if (!handle) return\n const rect = absoluteRect(graph, node, handle.rect)\n drawStripedRect(r, canvas, rect, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL)\n if (!showValue) return\n const [x, y, width, height] = rect\n drawValuePill(\n r,\n canvas,\n String(Math.round(handle.value)),\n (x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n (y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,\n AUTO_LAYOUT_HOVER_GAP_PILL\n )\n}\n\nexport function drawAutoLayoutHover(\n r: SkiaRenderer,\n canvas: Canvas,\n graph: SceneGraph,\n hover?: RenderOverlays['autoLayoutHover']\n): void {\n if (!hover) return\n const node = graph.getNode(hover.nodeId)\n if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return\n const layout = measureAutoLayoutHandles(node, visibleLayoutChildren(node, graph))\n if (!layout) return\n\n if (hover.kind === 'children') strokeLayoutChildren(r, canvas, graph, node)\n if (hover.kind === 'spacing' || hover.kind === 'spacing-value') {\n drawSpacingHover(r, canvas, graph, node, layout, hover, hover.kind === 'spacing-value')\n }\n if (hover.kind === 'padding' || hover.kind === 'padding-value') {\n drawPaddingHover(r, canvas, graph, node, layout, hover, hover.kind === 'padding-value')\n }\n drawBaselineTicks(r, canvas, graph, node, layout)\n}\n"],"mappings":";;;;AA4BA,SAAS,sBAAsB,MAAiB,OAAmB;CACjE,OAAO,KAAK,SACT,KAAK,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CAC9B,QACE,UACC,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,sBAAsB,UAC5D;AACJ;AAEA,SAAS,YAAY,GAAiB,OAAc;CAClD,OAAO,EAAE,GAAG,QAAQ,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACxD;AAEA,SAAS,UAAU,GAAiB,OAAc;CAChD,EAAE,UAAU,eAAe,8BAA8B;CACzD,EAAE,UAAU,SAAS,YAAY,GAAG,KAAK,CAAC;CAC1C,EAAE,UAAU,cAAc,IAAI;AAChC;AAEA,SAAS,mBAAmB,GAAiB,QAAgB,GAAW,GAAW;CACjF,OAAO,SACL,IAAA,IACA,GACA,IAAA,IACA,GACA,EAAE,SACJ;AACF;AAEA,SAAS,iBAAiB,GAAiB,QAAgB,GAAW,GAAW;CAC/E,OAAO,SACL,GACA,IAAA,IACA,GACA,IAAA,IACA,EAAE,SACJ;AACF;AAEA,SAAS,aAAa,GAAiB,CAAC,GAAG,GAAG,OAAO,SAAoB;CACvE,OAAO,EAAE,GAAG,SACV,IAAI,EAAE,OAAO,EAAE,MACf,IAAI,EAAE,OAAO,EAAE,OACd,IAAI,SAAS,EAAE,OAAO,EAAE,OACxB,IAAI,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AM,OAAO,IAAI;CAClD,gBAAgB,GAAG,QAAQ,MAAM,2BAA2B,8BAA8B;CAC1F,IAAI,CAAC,WAAW;CAChB,MAAM,CAAC,GAAG,GAAG,OAAO,UAAU;CAC9B,cACE,GACA,QACA,OAAO,KAAK,MAAM,OAAO,KAAK,CAAC,IAC9B,IAAI,QAAQ,KAAK,EAAE,OAAO,EAAE,OAAA,KAC5B,IAAI,SAAS,KAAK,EAAE,OAAO,EAAE,OAAA,IAC9B,0BACF;AACF;AAEA,SAAgB,oBACd,GACA,QACA,OACA,OACM;CACN,IAAI,CAAC,OAAO;CACZ,MAAM,OAAO,MAAM,QAAQ,MAAM,MAAM;CACvC,IAAI,CAAC,QAAS,KAAK,eAAe,gBAAgB,KAAK,eAAe,YAAa;CACnF,MAAM,SAAS,yBAAyB,MAAM,sBAAsB,MAAM,KAAK,CAAC;CAChF,IAAI,CAAC,QAAQ;CAEb,IAAI,MAAM,SAAS,YAAY,qBAAqB,GAAG,QAAQ,OAAO,IAAI;CAC1E,IAAI,MAAM,SAAS,aAAa,MAAM,SAAS,iBAC7C,iBAAiB,GAAG,QAAQ,OAAO,MAAM,QAAQ,OAAO,MAAM,SAAS,eAAe;CAExF,IAAI,MAAM,SAAS,aAAa,MAAM,SAAS,iBAC7C,iBAAiB,GAAG,QAAQ,OAAO,MAAM,QAAQ,OAAO,MAAM,SAAS,eAAe;CAExF,kBAAkB,GAAG,QAAQ,OAAO,MAAM,MAAM;AAClD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderChunkPictureCache } from "./cache.js";
|
|
2
2
|
import { RecordedRenderChunk, deleteRecordedRenderChunks, drawRecordedRenderChunks, drawRenderChunkDirect, recordRenderChunk } from "./record.js";
|
|
3
|
-
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
4
3
|
import { Mat3 } from "@pairdraw/scene-graph/matrix";
|
|
4
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
5
5
|
//#region src/canvas/renderer/chunks/index.d.ts
|
|
6
6
|
type RenderChunkKind = 'self' | 'subtree';
|
|
7
7
|
interface RenderChunkContext {
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasKit, ColorSpace, ColorType, ImageInfo } from "canvaskit-wasm";
|
|
2
2
|
import { RenderColorSpace, ResolvedRenderColor } from "@pairdraw/scene-graph/color";
|
|
3
|
-
import {
|
|
3
|
+
import { ColorProfile, Fill, SceneGraph, SceneNode, Stroke } from "@pairdraw/scene-graph";
|
|
4
|
+
import { Color as Color$1 } from "@pairdraw/scene-graph/primitives";
|
|
4
5
|
//#region src/canvas/renderer/colors.d.ts
|
|
6
|
+
/** Skia's color space for a document's. */
|
|
7
|
+
declare function skColorSpace(ck: CanvasKit, space: ColorProfile): ColorSpace;
|
|
8
|
+
/**
|
|
9
|
+
* A premultiplied surface `width` by `height` in `profile`, as a document is drawn on: its colors
|
|
10
|
+
* and blend modes work in its own profile there, as on the screen and in Figma's export.
|
|
11
|
+
*/
|
|
12
|
+
declare function documentImageInfo(ck: CanvasKit, profile: ColorProfile, width: number, height: number, colorType?: ColorType): ImageInfo;
|
|
13
|
+
/**
|
|
14
|
+
* A stored color, such as a paint's or a gradient stop's, as Skia is given it: its components, in
|
|
15
|
+
* the document's profile, as extended sRGB, which Skia converts into the document's space of the
|
|
16
|
+
* surfaces it draws on. The stored color is what draws, as in Figma; an OkHCL value kept for
|
|
17
|
+
* editing only describes it.
|
|
18
|
+
*/
|
|
19
|
+
declare function drawnColor(color: Color$1, graph: SceneGraph): Color$1;
|
|
5
20
|
declare function resolveFillColorInfo(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph, presentation: RenderColorSpace): ResolvedRenderColor;
|
|
6
|
-
declare function resolveFillColor(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph
|
|
21
|
+
declare function resolveFillColor(fill: Fill, fillIndex: number, node: SceneNode, graph: SceneGraph): Color$1;
|
|
7
22
|
declare function resolveStrokeColorInfo(stroke: Stroke, strokeIndex: number, node: SceneNode, graph: SceneGraph, presentation: RenderColorSpace): ResolvedRenderColor;
|
|
8
|
-
declare function resolveStrokeColor(stroke: Stroke, strokeIndex: number, node: SceneNode, graph: SceneGraph
|
|
23
|
+
declare function resolveStrokeColor(stroke: Stroke, strokeIndex: number, node: SceneNode, graph: SceneGraph): Color$1;
|
|
9
24
|
//#endregion
|
|
10
|
-
export { resolveFillColor, resolveFillColorInfo, resolveStrokeColor, resolveStrokeColorInfo };
|
|
25
|
+
export { documentImageInfo, drawnColor, resolveFillColor, resolveFillColorInfo, resolveStrokeColor, resolveStrokeColorInfo, skColorSpace };
|
|
11
26
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","names":[],"sources":["../../../src/canvas/renderer/colors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"colors.d.ts","names":[],"sources":["../../../src/canvas/renderer/colors.ts"],"mappings":";;;;;;iBAegB,aAAa,IAAI,WAAW,OAAO,eAAe;;;;;iBAQlD,kBACd,IAAI,WACJ,SAAS,cACT,eACA,gBACA,YAAW,YACV;;;;;;;iBAgBa,WAAW,OAAO,SAAO,OAAO,aAAa;iBAyC7C,qBACd,MAAM,MACN,mBACA,MAAM,WACN,OAAO,YACP,cAAc,mBACb;iBAIa,iBACd,MAAM,MACN,mBACA,MAAM,WACN,OAAO,aACN;iBAIa,uBACd,QAAQ,QACR,qBACA,MAAM,WACN,OAAO,YACP,cAAc,mBACb;iBAQa,mBACd,QAAQ,QACR,qBACA,MAAM,WACN,OAAO,aACN"}
|
|
@@ -1,63 +1,69 @@
|
|
|
1
1
|
import { paintColorApplied } from "@pairdraw/scene-graph/variables";
|
|
2
|
-
import {
|
|
2
|
+
import { colorToProfileCSS, normalizeColor, resolveRGBAForPreview, toExtendedSRGB } from "@pairdraw/scene-graph/color";
|
|
3
3
|
//#region src/canvas/renderer/colors.ts
|
|
4
|
+
/** Skia's color space for a document's. */
|
|
5
|
+
function skColorSpace(ck, space) {
|
|
6
|
+
return space === "display-p3" ? ck.ColorSpace.DISPLAY_P3 : ck.ColorSpace.SRGB;
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
|
-
* A
|
|
6
|
-
*
|
|
7
|
-
* binding with no applied color, as a layer just imported or built with its bindings has, draws
|
|
8
|
-
* its variable's color for the layer until a write or refresh records one.
|
|
9
|
+
* A premultiplied surface `width` by `height` in `profile`, as a document is drawn on: its colors
|
|
10
|
+
* and blend modes work in its own profile there, as on the screen and in Figma's export.
|
|
9
11
|
*/
|
|
10
|
-
function
|
|
12
|
+
function documentImageInfo(ck, profile, width, height, colorType = ck.ColorType.RGBA_8888) {
|
|
13
|
+
return {
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
colorType,
|
|
17
|
+
alphaType: ck.AlphaType.Premul,
|
|
18
|
+
colorSpace: skColorSpace(ck, profile)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A stored color, such as a paint's or a gradient stop's, as Skia is given it: its components, in
|
|
23
|
+
* the document's profile, as extended sRGB, which Skia converts into the document's space of the
|
|
24
|
+
* surfaces it draws on. The stored color is what draws, as in Figma; an OkHCL value kept for
|
|
25
|
+
* editing only describes it.
|
|
26
|
+
*/
|
|
27
|
+
function drawnColor(color, graph) {
|
|
28
|
+
return toExtendedSRGB(normalizeColor(color), graph.documentColorSpace);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The color a paint draws: the color it stores, or before a write or refresh records one, the
|
|
32
|
+
* variable color a binding resolves to for the layer. OkHCL data kept from before the paint was
|
|
33
|
+
* bound no longer describes it.
|
|
34
|
+
*/
|
|
35
|
+
function storedColor(node, list, index, graph, fallback) {
|
|
11
36
|
const field = `${list}/${index}/color`;
|
|
12
37
|
const variableId = node.boundVariables[field];
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
if (variableId && !paintColorApplied(node, field)) {
|
|
39
|
+
const resolved = graph.resolveColorVariableForNode(node.id, variableId);
|
|
40
|
+
if (resolved) return resolved;
|
|
41
|
+
}
|
|
42
|
+
return normalizeColor(fallback);
|
|
43
|
+
}
|
|
44
|
+
function colorInfo(color, graph, presentation) {
|
|
17
45
|
return {
|
|
18
|
-
...resolveRGBAForPreview(
|
|
46
|
+
...resolveRGBAForPreview(color, {
|
|
19
47
|
documentColorSpace: graph.documentColorSpace,
|
|
20
48
|
colorSpace: presentation
|
|
21
49
|
}),
|
|
22
|
-
|
|
50
|
+
color: drawnColor(color, graph),
|
|
51
|
+
cssColor: colorToProfileCSS(color, graph.documentColorSpace, presentation)
|
|
23
52
|
};
|
|
24
53
|
}
|
|
25
|
-
function isBound(node, list, index) {
|
|
26
|
-
return `${list}/${index}/color` in node.boundVariables;
|
|
27
|
-
}
|
|
28
54
|
function resolveFillColorInfo(fill, fillIndex, node, graph, presentation) {
|
|
29
|
-
|
|
30
|
-
documentColorSpace: graph.documentColorSpace,
|
|
31
|
-
colorSpace: presentation
|
|
32
|
-
};
|
|
33
|
-
const drawn = boundDrawnColor(node, "fills", fillIndex, graph, presentation);
|
|
34
|
-
if (drawn) return drawn;
|
|
35
|
-
if (isBound(node, "fills", fillIndex)) return resolveRGBAForPreview(fill.color, options);
|
|
36
|
-
return resolveNodeFillColor(fill, fillIndex, node, options);
|
|
55
|
+
return colorInfo(storedColor(node, "fills", fillIndex, graph, fill.color), graph, presentation);
|
|
37
56
|
}
|
|
38
|
-
function resolveFillColor(fill, fillIndex, node, graph
|
|
39
|
-
|
|
40
|
-
if (drawn) return drawn.color;
|
|
41
|
-
if (isBound(node, "fills", fillIndex) || !getFillOkHCL(node, fillIndex)) return normalizeColor(fill.color);
|
|
42
|
-
return resolveFillColorInfo(fill, fillIndex, node, graph, presentation).color;
|
|
57
|
+
function resolveFillColor(fill, fillIndex, node, graph) {
|
|
58
|
+
return drawnColor(storedColor(node, "fills", fillIndex, graph, fill.color), graph);
|
|
43
59
|
}
|
|
44
60
|
function resolveStrokeColorInfo(stroke, strokeIndex, node, graph, presentation) {
|
|
45
|
-
|
|
46
|
-
documentColorSpace: graph.documentColorSpace,
|
|
47
|
-
colorSpace: presentation
|
|
48
|
-
};
|
|
49
|
-
const drawn = boundDrawnColor(node, "strokes", strokeIndex, graph, presentation);
|
|
50
|
-
if (drawn) return drawn;
|
|
51
|
-
if (isBound(node, "strokes", strokeIndex)) return resolveRGBAForPreview(stroke.color, options);
|
|
52
|
-
return resolveNodeStrokeColor(stroke, strokeIndex, node, options);
|
|
61
|
+
return colorInfo(storedColor(node, "strokes", strokeIndex, graph, stroke.color), graph, presentation);
|
|
53
62
|
}
|
|
54
|
-
function resolveStrokeColor(stroke, strokeIndex, node, graph
|
|
55
|
-
|
|
56
|
-
if (drawn) return drawn.color;
|
|
57
|
-
if (isBound(node, "strokes", strokeIndex) || !getStrokeOkHCL(node, strokeIndex)) return normalizeColor(stroke.color);
|
|
58
|
-
return resolveStrokeColorInfo(stroke, strokeIndex, node, graph, presentation).color;
|
|
63
|
+
function resolveStrokeColor(stroke, strokeIndex, node, graph) {
|
|
64
|
+
return drawnColor(storedColor(node, "strokes", strokeIndex, graph, stroke.color), graph);
|
|
59
65
|
}
|
|
60
66
|
//#endregion
|
|
61
|
-
export { resolveFillColor, resolveFillColorInfo, resolveStrokeColor, resolveStrokeColorInfo };
|
|
67
|
+
export { documentImageInfo, drawnColor, resolveFillColor, resolveFillColorInfo, resolveStrokeColor, resolveStrokeColorInfo, skColorSpace };
|
|
62
68
|
|
|
63
69
|
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","names":[],"sources":["../../../src/canvas/renderer/colors.ts"],"sourcesContent":["import type { Fill, SceneGraph, SceneNode, Stroke } from '@pairdraw/scene-graph'\nimport {\n
|
|
1
|
+
{"version":3,"file":"colors.js","names":[],"sources":["../../../src/canvas/renderer/colors.ts"],"sourcesContent":["import type { CanvasKit, ColorSpace, ColorType, ImageInfo } from 'canvaskit-wasm'\n\nimport type { ColorProfile, Fill, SceneGraph, SceneNode, Stroke } from '@pairdraw/scene-graph'\nimport {\n colorToProfileCSS,\n normalizeColor,\n resolveRGBAForPreview,\n toExtendedSRGB,\n type RenderColorSpace,\n type ResolvedRenderColor\n} from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\nimport { paintColorApplied } from '@pairdraw/scene-graph/variables'\n\n/** Skia's color space for a document's. */\nexport function skColorSpace(ck: CanvasKit, space: ColorProfile): ColorSpace {\n return space === 'display-p3' ? ck.ColorSpace.DISPLAY_P3 : ck.ColorSpace.SRGB\n}\n\n/**\n * A premultiplied surface `width` by `height` in `profile`, as a document is drawn on: its colors\n * and blend modes work in its own profile there, as on the screen and in Figma's export.\n */\nexport function documentImageInfo(\n ck: CanvasKit,\n profile: ColorProfile,\n width: number,\n height: number,\n colorType: ColorType = ck.ColorType.RGBA_8888\n): ImageInfo {\n return {\n width,\n height,\n colorType,\n alphaType: ck.AlphaType.Premul,\n colorSpace: skColorSpace(ck, profile)\n }\n}\n\n/**\n * A stored color, such as a paint's or a gradient stop's, as Skia is given it: its components, in\n * the document's profile, as extended sRGB, which Skia converts into the document's space of the\n * surfaces it draws on. The stored color is what draws, as in Figma; an OkHCL value kept for\n * editing only describes it.\n */\nexport function drawnColor(color: Color, graph: SceneGraph): Color {\n return toExtendedSRGB(normalizeColor(color), graph.documentColorSpace)\n}\n\n/**\n * The color a paint draws: the color it stores, or before a write or refresh records one, the\n * variable color a binding resolves to for the layer. OkHCL data kept from before the paint was\n * bound no longer describes it.\n */\nfunction storedColor(\n node: SceneNode,\n list: 'fills' | 'strokes',\n index: number,\n graph: SceneGraph,\n fallback: Color\n): Color {\n const field = `${list}/${index}/color`\n const variableId = node.boundVariables[field]\n if (variableId && !paintColorApplied(node, field)) {\n const resolved = graph.resolveColorVariableForNode(node.id, variableId)\n if (resolved) return resolved\n }\n return normalizeColor(fallback)\n}\n\nfunction colorInfo(\n color: Color,\n graph: SceneGraph,\n presentation: RenderColorSpace\n): ResolvedRenderColor {\n const preview = resolveRGBAForPreview(color, {\n documentColorSpace: graph.documentColorSpace,\n colorSpace: presentation\n })\n return {\n ...preview,\n color: drawnColor(color, graph),\n cssColor: colorToProfileCSS(color, graph.documentColorSpace, presentation)\n }\n}\n\nexport function resolveFillColorInfo(\n fill: Fill,\n fillIndex: number,\n node: SceneNode,\n graph: SceneGraph,\n presentation: RenderColorSpace\n): ResolvedRenderColor {\n return colorInfo(storedColor(node, 'fills', fillIndex, graph, fill.color), graph, presentation)\n}\n\nexport function resolveFillColor(\n fill: Fill,\n fillIndex: number,\n node: SceneNode,\n graph: SceneGraph\n): Color {\n return drawnColor(storedColor(node, 'fills', fillIndex, graph, fill.color), graph)\n}\n\nexport function resolveStrokeColorInfo(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph,\n presentation: RenderColorSpace\n): ResolvedRenderColor {\n return colorInfo(\n storedColor(node, 'strokes', strokeIndex, graph, stroke.color),\n graph,\n presentation\n )\n}\n\nexport function resolveStrokeColor(\n stroke: Stroke,\n strokeIndex: number,\n node: SceneNode,\n graph: SceneGraph\n): Color {\n return drawnColor(storedColor(node, 'strokes', strokeIndex, graph, stroke.color), graph)\n}\n"],"mappings":";;;;AAeA,SAAgB,aAAa,IAAe,OAAiC;CAC3E,OAAO,UAAU,eAAe,GAAG,WAAW,aAAa,GAAG,WAAW;AAC3E;;;;;AAMA,SAAgB,kBACd,IACA,SACA,OACA,QACA,YAAuB,GAAG,UAAU,WACzB;CACX,OAAO;EACL;EACA;EACA;EACA,WAAW,GAAG,UAAU;EACxB,YAAY,aAAa,IAAI,OAAO;CACtC;AACF;;;;;;;AAQA,SAAgB,WAAW,OAAc,OAA0B;CACjE,OAAO,eAAe,eAAe,KAAK,GAAG,MAAM,kBAAkB;AACvE;;;;;;AAOA,SAAS,YACP,MACA,MACA,OACA,OACA,UACO;CACP,MAAM,QAAQ,GAAG,KAAK,GAAG,MAAM;CAC/B,MAAM,aAAa,KAAK,eAAe;CACvC,IAAI,cAAc,CAAC,kBAAkB,MAAM,KAAK,GAAG;EACjD,MAAM,WAAW,MAAM,4BAA4B,KAAK,IAAI,UAAU;EACtE,IAAI,UAAU,OAAO;CACvB;CACA,OAAO,eAAe,QAAQ;AAChC;AAEA,SAAS,UACP,OACA,OACA,cACqB;CAKrB,OAAO;EACL,GALc,sBAAsB,OAAO;GAC3C,oBAAoB,MAAM;GAC1B,YAAY;EACd,CAEW;EACT,OAAO,WAAW,OAAO,KAAK;EAC9B,UAAU,kBAAkB,OAAO,MAAM,oBAAoB,YAAY;CAC3E;AACF;AAEA,SAAgB,qBACd,MACA,WACA,MACA,OACA,cACqB;CACrB,OAAO,UAAU,YAAY,MAAM,SAAS,WAAW,OAAO,KAAK,KAAK,GAAG,OAAO,YAAY;AAChG;AAEA,SAAgB,iBACd,MACA,WACA,MACA,OACO;CACP,OAAO,WAAW,YAAY,MAAM,SAAS,WAAW,OAAO,KAAK,KAAK,GAAG,KAAK;AACnF;AAEA,SAAgB,uBACd,QACA,aACA,MACA,OACA,cACqB;CACrB,OAAO,UACL,YAAY,MAAM,WAAW,aAAa,OAAO,OAAO,KAAK,GAC7D,OACA,YACF;AACF;AAEA,SAAgB,mBACd,QACA,aACA,MACA,OACO;CACP,OAAO,WAAW,YAAY,MAAM,WAAW,aAAa,OAAO,OAAO,KAAK,GAAG,KAAK;AACzF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SkiaRenderer } from "../renderer.js";
|
|
2
|
+
import { Canvas, Surface } from "canvaskit-wasm";
|
|
3
|
+
import { ColorProfile } from "@pairdraw/scene-graph";
|
|
4
|
+
//#region src/canvas/renderer/document-surface.d.ts
|
|
5
|
+
/** A surface in the document's color space, the size of the screen surface it is shown on. */
|
|
6
|
+
interface DocumentSurface {
|
|
7
|
+
surface: Surface;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
space: ColorProfile;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Where the scene is drawn this frame: the screen surface when it is in the document's color space,
|
|
14
|
+
* or a surface in the document's space the size of the screen's, which {@link presentDocumentSurface}
|
|
15
|
+
* then draws onto the screen. Skia blends in the space of the surface it draws on, so a P3 document
|
|
16
|
+
* on an sRGB screen blends in P3, as Figma blends it, and is converted only to be shown. Null when
|
|
17
|
+
* the screen surface serves, or when no such surface can be made.
|
|
18
|
+
*/
|
|
19
|
+
declare function documentSurfaceFor(r: SkiaRenderer): Surface | null;
|
|
20
|
+
/** Draws what the document surface holds onto the screen, converted into the screen's space. */
|
|
21
|
+
declare function presentDocumentSurface(screen: Canvas, surface: Surface): void;
|
|
22
|
+
declare function releaseDocumentSurface(r: Pick<SkiaRenderer, 'documentSurface'>): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { DocumentSurface, documentSurfaceFor, presentDocumentSurface, releaseDocumentSurface };
|
|
25
|
+
//# sourceMappingURL=document-surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-surface.d.ts","names":[],"sources":["../../../src/canvas/renderer/document-surface.ts"],"mappings":";;;;;UASiB;EACf,SAAS;EACT;EACA;EACA,OAAO;;;;;;;;;iBAUO,mBAAmB,GAAG,eAAe;;iBAiBrC,uBAAuB,QAAQ,QAAQ,SAAS;iBAShD,uBAAuB,GAAG,KAAK"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { documentImageInfo } from "./colors.js";
|
|
2
|
+
//#region src/canvas/renderer/document-surface.ts
|
|
3
|
+
/**
|
|
4
|
+
* Where the scene is drawn this frame: the screen surface when it is in the document's color space,
|
|
5
|
+
* or a surface in the document's space the size of the screen's, which {@link presentDocumentSurface}
|
|
6
|
+
* then draws onto the screen. Skia blends in the space of the surface it draws on, so a P3 document
|
|
7
|
+
* on an sRGB screen blends in P3, as Figma blends it, and is converted only to be shown. Null when
|
|
8
|
+
* the screen surface serves, or when no such surface can be made.
|
|
9
|
+
*/
|
|
10
|
+
function documentSurfaceFor(r) {
|
|
11
|
+
const space = r.documentColorSpace;
|
|
12
|
+
if (space === r.presentationColorSpace) {
|
|
13
|
+
releaseDocumentSurface(r);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const width = r.surface.width();
|
|
17
|
+
const height = r.surface.height();
|
|
18
|
+
const kept = r.documentSurface;
|
|
19
|
+
if (kept?.space === space && kept.width === width && kept.height === height) return kept.surface;
|
|
20
|
+
releaseDocumentSurface(r);
|
|
21
|
+
const surface = r.surface.makeSurface(documentImageInfo(r.ck, space, width, height));
|
|
22
|
+
r.documentSurface = {
|
|
23
|
+
surface,
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
26
|
+
space
|
|
27
|
+
};
|
|
28
|
+
return surface;
|
|
29
|
+
}
|
|
30
|
+
/** Draws what the document surface holds onto the screen, converted into the screen's space. */
|
|
31
|
+
function presentDocumentSurface(screen, surface) {
|
|
32
|
+
const image = surface.makeImageSnapshot();
|
|
33
|
+
try {
|
|
34
|
+
screen.drawImage(image, 0, 0);
|
|
35
|
+
} finally {
|
|
36
|
+
image.delete();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function releaseDocumentSurface(r) {
|
|
40
|
+
r.documentSurface?.surface.dispose();
|
|
41
|
+
r.documentSurface = null;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { documentSurfaceFor, presentDocumentSurface, releaseDocumentSurface };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=document-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-surface.js","names":[],"sources":["../../../src/canvas/renderer/document-surface.ts"],"sourcesContent":["import type { Canvas, Surface } from 'canvaskit-wasm'\n\nimport type { ColorProfile } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\n\nimport { documentImageInfo } from './colors'\n\n/** A surface in the document's color space, the size of the screen surface it is shown on. */\nexport interface DocumentSurface {\n surface: Surface\n width: number\n height: number\n space: ColorProfile\n}\n\n/**\n * Where the scene is drawn this frame: the screen surface when it is in the document's color space,\n * or a surface in the document's space the size of the screen's, which {@link presentDocumentSurface}\n * then draws onto the screen. Skia blends in the space of the surface it draws on, so a P3 document\n * on an sRGB screen blends in P3, as Figma blends it, and is converted only to be shown. Null when\n * the screen surface serves, or when no such surface can be made.\n */\nexport function documentSurfaceFor(r: SkiaRenderer): Surface | null {\n const space = r.documentColorSpace\n if (space === r.presentationColorSpace) {\n releaseDocumentSurface(r)\n return null\n }\n const width = r.surface.width()\n const height = r.surface.height()\n const kept = r.documentSurface\n if (kept?.space === space && kept.width === width && kept.height === height) return kept.surface\n releaseDocumentSurface(r)\n const surface = r.surface.makeSurface(documentImageInfo(r.ck, space, width, height))\n r.documentSurface = { surface, width, height, space }\n return surface\n}\n\n/** Draws what the document surface holds onto the screen, converted into the screen's space. */\nexport function presentDocumentSurface(screen: Canvas, surface: Surface): void {\n const image = surface.makeImageSnapshot()\n try {\n screen.drawImage(image, 0, 0)\n } finally {\n image.delete()\n }\n}\n\nexport function releaseDocumentSurface(r: Pick<SkiaRenderer, 'documentSurface'>): void {\n r.documentSurface?.surface.dispose()\n r.documentSurface = null\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,mBAAmB,GAAiC;CAClE,MAAM,QAAQ,EAAE;CAChB,IAAI,UAAU,EAAE,wBAAwB;EACtC,uBAAuB,CAAC;EACxB,OAAO;CACT;CACA,MAAM,QAAQ,EAAE,QAAQ,MAAM;CAC9B,MAAM,SAAS,EAAE,QAAQ,OAAO;CAChC,MAAM,OAAO,EAAE;CACf,IAAI,MAAM,UAAU,SAAS,KAAK,UAAU,SAAS,KAAK,WAAW,QAAQ,OAAO,KAAK;CACzF,uBAAuB,CAAC;CACxB,MAAM,UAAU,EAAE,QAAQ,YAAY,kBAAkB,EAAE,IAAI,OAAO,OAAO,MAAM,CAAC;CACnF,EAAE,kBAAkB;EAAE;EAAS;EAAO;EAAQ;CAAM;CACpD,OAAO;AACT;;AAGA,SAAgB,uBAAuB,QAAgB,SAAwB;CAC7E,MAAM,QAAQ,QAAQ,kBAAkB;CACxC,IAAI;EACF,OAAO,UAAU,OAAO,GAAG,CAAC;CAC9B,UAAU;EACR,MAAM,OAAO;CACf;AACF;AAEA,SAAgB,uBAAuB,GAAgD;CACrF,EAAE,iBAAiB,QAAQ,QAAQ;CACnC,EAAE,kBAAkB;AACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../../src/canvas/renderer/fonts.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../../src/canvas/renderer/fonts.ts"],"mappings":";;;;;;;iBAmCgB,yBACd,GAAG,KAAK,0DACR,kBAAkB,0BAClB,WADkB;iBAeJ,mBAAmB,GAAG;iBAItB,gBAAgB,GAAG,cAAc,MAAM,WAAW;UAOxD;EACR;EACA,wBAAwB;IAAc,MAAM;IAAY;;;iBAG1C,qBAAqB,GAAG,4BAA4B,MAAM;iBAgC1D,gBAAgB,GAAG,eAAY;iBA8BzB,UACpB,GAAG,cACH,qCACC;iBAmDmB,iBACpB,GAAG,cACH,OAAO,YACP,gBACA,oBACC"}
|