@pairdraw/core 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +73 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +0 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -4
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +22 -3
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +168 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +6 -0
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +6 -3
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -1
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +31 -3
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +4 -54
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +224 -50
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +6 -3
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.js +3 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +26 -5
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +2 -1
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -3
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +22 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/tools/vector/vectorize.js +1 -0
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
- package/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -3
- package/src/canvas/renderer.ts +40 -4
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +17 -1
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +5 -1
- package/src/io/formats/fig/export/patch/index.ts +8 -0
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +12 -1
- package/src/io/formats/svg/defs.ts +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/layout.ts +5 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/nodes.ts +0 -1
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +34 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/path.ts +30 -6
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
- package/src/xpath.ts +6 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Figma's noise effect spreads its grains over 17 alpha levels, measured from Figma 126 PNG
|
|
3
|
+
* exports of a black monotone noise of size 1 on white at every density from 0 to 1 in steps of
|
|
4
|
+
* 0.05 (65,536 pixels each). Row `d` holds, for levels 0 to 15, the share of pixels at that level
|
|
5
|
+
* or below; the rest are at level 16.
|
|
6
|
+
*/
|
|
7
|
+
const LEVEL_SHARES: readonly (readonly number[])[] = [
|
|
8
|
+
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
9
|
+
[0.9662, 0.994, 0.9991, 0.9999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
10
|
+
[0.9382, 0.9814, 0.9948, 0.9989, 0.9998, 0.9999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
11
|
+
[0.9092, 0.9652, 0.9865, 0.9959, 0.9987, 0.9996, 0.9999, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
12
|
+
[0.8743, 0.9446, 0.9752, 0.9902, 0.9961, 0.9987, 0.9995, 0.9999, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
13
|
+
[0.8302, 0.9196, 0.9601, 0.9811, 0.9919, 0.9965, 0.9987, 0.9996, 0.9999, 1, 1, 1, 1, 1, 1, 1],
|
|
14
|
+
[0.7797, 0.8868, 0.9386, 0.9682, 0.984, 0.9925, 0.9966, 0.9988, 0.9995, 0.9999, 1, 1, 1, 1, 1, 1],
|
|
15
|
+
[
|
|
16
|
+
0.721, 0.8476, 0.9097, 0.9503, 0.9725, 0.9856, 0.9927, 0.9967, 0.9988, 0.9996, 0.9999, 1, 1, 1,
|
|
17
|
+
1, 1
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
0.656, 0.7984, 0.8746, 0.9255, 0.956, 0.9752, 0.9862, 0.9932, 0.997, 0.9987, 0.9997, 0.9999, 1,
|
|
21
|
+
1, 1, 1
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
0.5862, 0.7429, 0.8315, 0.8925, 0.9324, 0.9591, 0.9761, 0.9861, 0.9932, 0.9969, 0.9989, 0.9997,
|
|
25
|
+
0.9999, 1, 1, 1
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
0.5137, 0.6797, 0.7769, 0.8498, 0.9001, 0.9352, 0.961, 0.9756, 0.9862, 0.9932, 0.9973, 0.9992,
|
|
29
|
+
0.9998, 1, 1, 1
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
0.4375, 0.611, 0.716, 0.7998, 0.8601, 0.9045, 0.9381, 0.9601, 0.9751, 0.9862, 0.9934, 0.9976,
|
|
33
|
+
0.9993, 0.9998, 1, 1
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
0.3658, 0.5383, 0.649, 0.7411, 0.811, 0.8648, 0.9068, 0.9383, 0.9595, 0.9748, 0.9865, 0.9938,
|
|
37
|
+
0.9979, 0.9994, 0.9999, 1
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
0.2958, 0.4651, 0.5781, 0.6728, 0.7521, 0.8151, 0.8667, 0.9066, 0.9365, 0.9581, 0.9748, 0.9873,
|
|
41
|
+
0.9948, 0.9984, 0.9997, 1
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
0.2323, 0.392, 0.5021, 0.6009, 0.6872, 0.7571, 0.817, 0.8661, 0.9055, 0.935, 0.9583, 0.9758,
|
|
45
|
+
0.9884, 0.9956, 0.9991, 0.9999
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
0.1742, 0.3205, 0.4286, 0.5257, 0.614, 0.6912, 0.759, 0.8168, 0.8648, 0.9032, 0.9341, 0.9584,
|
|
49
|
+
0.9772, 0.9903, 0.9972, 0.9997
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
0.1252, 0.2539, 0.3552, 0.4494, 0.5371, 0.618, 0.6934, 0.7586, 0.8153, 0.8635, 0.9024, 0.935,
|
|
53
|
+
0.9612, 0.9809, 0.9933, 0.999
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
0.087, 0.1921, 0.2882, 0.3744, 0.4601, 0.541, 0.6183, 0.6924, 0.7556, 0.8132, 0.8616, 0.903,
|
|
57
|
+
0.9373, 0.9656, 0.9862, 0.9974
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
0.0572, 0.14, 0.2235, 0.3052, 0.3844, 0.463, 0.5412, 0.6179, 0.6903, 0.7536, 0.8115, 0.8615,
|
|
61
|
+
0.907, 0.9452, 0.975, 0.9939
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
0.036, 0.0981, 0.1676, 0.2397, 0.3136, 0.3878, 0.4624, 0.5414, 0.6173, 0.6872, 0.7538, 0.8112,
|
|
65
|
+
0.8669, 0.9159, 0.9582, 0.9878
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
0.0205, 0.0651, 0.1202, 0.1818, 0.2461, 0.3163, 0.3857, 0.4628, 0.5406, 0.6151, 0.6875, 0.7535,
|
|
69
|
+
0.818, 0.8776, 0.9331, 0.9783
|
|
70
|
+
]
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
/** Levels a noise effect's alpha takes, 0 to 16 sixteenths. */
|
|
74
|
+
export const NOISE_LEVELS = 16
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The shares of pixels at each level or below for `density`, between the two measured rows
|
|
78
|
+
* around it: a uniform value under the first share is level 0, under the second level 1, and so on.
|
|
79
|
+
*/
|
|
80
|
+
export function noiseLevelShares(density: number): number[] {
|
|
81
|
+
const at = Math.min(Math.max(density, 0), 1) * (LEVEL_SHARES.length - 1)
|
|
82
|
+
const below = Math.floor(at)
|
|
83
|
+
const above = Math.min(below + 1, LEVEL_SHARES.length - 1)
|
|
84
|
+
const t = at - below
|
|
85
|
+
return LEVEL_SHARES[below].map((share, level) => share + (LEVEL_SHARES[above][level] - share) * t)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The mean level, 0 to 1, of a noise whose shares are `shares`. */
|
|
89
|
+
export function noiseMeanLevel(shares: readonly number[]): number {
|
|
90
|
+
return shares.reduce((sum, share) => sum + (1 - share), 0) / NOISE_LEVELS
|
|
91
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Image } from 'canvaskit-wasm'
|
|
2
|
+
|
|
3
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cells on each side of a noise tile, which repeats beyond them: wide enough that the repeat lies
|
|
7
|
+
* past a thousand grains, small enough to build in a few milliseconds and keep in 4 MB.
|
|
8
|
+
*/
|
|
9
|
+
export const NOISE_TILE_CELLS = 1024
|
|
10
|
+
|
|
11
|
+
/** What a level byte holds: 15 per level, so the 17 levels stay exact through 8 bits. */
|
|
12
|
+
export const LEVEL_STEP = 15
|
|
13
|
+
|
|
14
|
+
/** The step between a cell's possible values, the hash's 32 bits. */
|
|
15
|
+
const CELL_VALUE_STEP = 2 ** -32
|
|
16
|
+
|
|
17
|
+
/** A cell's uniform value from its index and the seed: a 32-bit integer hash. */
|
|
18
|
+
export function cellValue(x: number, y: number, seed: number, salt: number): number {
|
|
19
|
+
let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1) ^ Math.imul(seed + salt, 0x9e3779b9)
|
|
20
|
+
h ^= h >>> 16
|
|
21
|
+
h = Math.imul(h, 0x7feb352d)
|
|
22
|
+
h ^= h >>> 15
|
|
23
|
+
h = Math.imul(h, 0x846ca68b)
|
|
24
|
+
h ^= h >>> 16
|
|
25
|
+
return (h >>> 0) * CELL_VALUE_STEP
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The level a uniform value takes under `shares`, the share of pixels at each level or below. */
|
|
29
|
+
function level(u: number, shares: readonly number[]): number {
|
|
30
|
+
let at = 0
|
|
31
|
+
while (at < shares.length && u >= shares[at]) at += 1
|
|
32
|
+
return at
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function cached(r: SkiaRenderer, key: string, build: () => Uint8Array): Image | null {
|
|
36
|
+
const kept = r.noiseTileCache.get(key)
|
|
37
|
+
if (kept) return kept
|
|
38
|
+
const image = r.ck.MakeImage(
|
|
39
|
+
{
|
|
40
|
+
width: NOISE_TILE_CELLS,
|
|
41
|
+
height: NOISE_TILE_CELLS,
|
|
42
|
+
alphaType: r.ck.AlphaType.Unpremul,
|
|
43
|
+
colorType: r.ck.ColorType.RGBA_8888,
|
|
44
|
+
colorSpace: r.ck.ColorSpace.SRGB
|
|
45
|
+
},
|
|
46
|
+
build(),
|
|
47
|
+
NOISE_TILE_CELLS * 4
|
|
48
|
+
)
|
|
49
|
+
if (!image) return null
|
|
50
|
+
r.noiseTileCache.set(key, image)
|
|
51
|
+
return image
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Each cell's level under `shares` in red, and the level of its opposite value, which a duotone's
|
|
56
|
+
* second colour shows, in green, as multiples of `LEVEL_STEP`.
|
|
57
|
+
*/
|
|
58
|
+
export function noiseLevelTile(
|
|
59
|
+
r: SkiaRenderer,
|
|
60
|
+
shares: readonly number[],
|
|
61
|
+
seed: number
|
|
62
|
+
): Image | null {
|
|
63
|
+
return cached(r, `levels:${seed}:${shares.join(',')}`, () => {
|
|
64
|
+
const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4)
|
|
65
|
+
for (let y = 0; y < NOISE_TILE_CELLS; y++) {
|
|
66
|
+
for (let x = 0; x < NOISE_TILE_CELLS; x++) {
|
|
67
|
+
const u = cellValue(x, y, seed, 0)
|
|
68
|
+
const at = (y * NOISE_TILE_CELLS + x) * 4
|
|
69
|
+
pixels[at] = level(u, shares) * LEVEL_STEP
|
|
70
|
+
// The opposite value, reflected within [0, 1) as the hash is, so no cell reaches 1.
|
|
71
|
+
pixels[at + 1] = level(1 - u - CELL_VALUE_STEP, shares) * LEVEL_STEP
|
|
72
|
+
pixels[at + 3] = 255
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return pixels
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A random colour for each cell of a multitone noise. */
|
|
80
|
+
export function noiseColorTile(r: SkiaRenderer, seed: number): Image | null {
|
|
81
|
+
return cached(r, `colors:${seed}`, () => {
|
|
82
|
+
const pixels = new Uint8Array(NOISE_TILE_CELLS * NOISE_TILE_CELLS * 4)
|
|
83
|
+
for (let y = 0; y < NOISE_TILE_CELLS; y++) {
|
|
84
|
+
for (let x = 0; x < NOISE_TILE_CELLS; x++) {
|
|
85
|
+
const at = (y * NOISE_TILE_CELLS + x) * 4
|
|
86
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
87
|
+
pixels[at + channel] = Math.floor(cellValue(x, y, seed, channel + 1) * 256)
|
|
88
|
+
}
|
|
89
|
+
pixels[at + 3] = 255
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return pixels
|
|
93
|
+
})
|
|
94
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Canvas } from 'canvaskit-wasm'
|
|
2
2
|
|
|
3
3
|
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
4
|
-
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
4
|
+
import type { Color, Rect } from '@pairdraw/scene-graph/primitives'
|
|
5
5
|
|
|
6
6
|
import { strokeLayoutChildren } from '#core/canvas/overlays/layout-outlines'
|
|
7
7
|
import type { RenderOverlays, SkiaRenderer } from '#core/canvas/renderer'
|
|
8
8
|
import {
|
|
9
|
-
AUTO_LAYOUT_HOVER_BLUE,
|
|
10
|
-
AUTO_LAYOUT_HOVER_BLUE_FILL,
|
|
11
9
|
AUTO_LAYOUT_HOVER_MAGENTA,
|
|
12
10
|
AUTO_LAYOUT_HOVER_MAGENTA_FILL,
|
|
13
11
|
AUTO_LAYOUT_HOVER_STRIPE_GAP,
|
|
@@ -16,11 +14,14 @@ import {
|
|
|
16
14
|
AUTO_LAYOUT_HOVER_TICK_LENGTH,
|
|
17
15
|
AUTO_LAYOUT_HOVER_VALUE_OFFSET,
|
|
18
16
|
AUTO_LAYOUT_HOVER_GAP_PILL,
|
|
19
|
-
AUTO_LAYOUT_HOVER_PADDING_PILL,
|
|
20
17
|
AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT,
|
|
21
18
|
AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X,
|
|
22
19
|
AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS
|
|
23
20
|
} from '#core/constants'
|
|
21
|
+
import {
|
|
22
|
+
measureAutoLayoutHandles,
|
|
23
|
+
type AutoLayoutHandleLayout
|
|
24
|
+
} from '#core/layout/auto-layout-handles'
|
|
24
25
|
|
|
25
26
|
type Hover = NonNullable<RenderOverlays['autoLayoutHover']>
|
|
26
27
|
type RectTuple = [x: number, y: number, width: number, height: number]
|
|
@@ -141,55 +142,23 @@ function drawValuePill(
|
|
|
141
142
|
canvas.drawText(text, x - advance / 2, y - (top + bottom) / 2, r.auxFill, font)
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
function
|
|
145
|
-
const children = visibleLayoutChildren(node, graph)
|
|
146
|
-
if (children.length < 2 || node.itemSpacing <= 0) return []
|
|
145
|
+
function absoluteRect(graph: SceneGraph, node: SceneNode, rect: Rect): RectTuple {
|
|
147
146
|
const abs = graph.getAbsolutePosition(node.id)
|
|
148
|
-
|
|
149
|
-
const rects: RectTuple[] = []
|
|
150
|
-
|
|
151
|
-
for (let i = 0; i < children.length - 1; i++) {
|
|
152
|
-
const prev = children[i]
|
|
153
|
-
const next = children[i + 1]
|
|
154
|
-
const gapStart = isRow ? prev.x + prev.width : prev.y + prev.height
|
|
155
|
-
const gapEnd = isRow ? next.x : next.y
|
|
156
|
-
if (gapEnd <= gapStart) continue
|
|
157
|
-
rects.push(
|
|
158
|
-
isRow
|
|
159
|
-
? [
|
|
160
|
-
abs.x + gapStart,
|
|
161
|
-
abs.y + node.paddingTop,
|
|
162
|
-
gapEnd - gapStart,
|
|
163
|
-
node.height - node.paddingTop - node.paddingBottom
|
|
164
|
-
]
|
|
165
|
-
: [
|
|
166
|
-
abs.x + node.paddingLeft,
|
|
167
|
-
abs.y + gapStart,
|
|
168
|
-
node.width - node.paddingLeft - node.paddingRight,
|
|
169
|
-
gapEnd - gapStart
|
|
170
|
-
]
|
|
171
|
-
)
|
|
172
|
-
}
|
|
173
|
-
return rects
|
|
147
|
+
return [abs.x + rect.x, abs.y + rect.y, rect.width, rect.height]
|
|
174
148
|
}
|
|
175
149
|
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (side === 'left') return [abs.x, abs.y, node.paddingLeft, node.height]
|
|
184
|
-
return [abs.x + node.width - node.paddingRight, abs.y, node.paddingRight, node.height]
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function drawBaselineTicks(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph, node: SceneNode) {
|
|
150
|
+
function drawBaselineTicks(
|
|
151
|
+
r: SkiaRenderer,
|
|
152
|
+
canvas: Canvas,
|
|
153
|
+
graph: SceneGraph,
|
|
154
|
+
node: SceneNode,
|
|
155
|
+
layout: AutoLayoutHandleLayout
|
|
156
|
+
) {
|
|
188
157
|
const abs = graph.getAbsolutePosition(node.id)
|
|
189
158
|
const xCenter = (abs.x + node.width / 2) * r.zoom + r.panX
|
|
190
159
|
const yCenter = (abs.y + node.height / 2) * r.zoom + r.panY
|
|
191
160
|
|
|
192
|
-
setStroke(r,
|
|
161
|
+
setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA)
|
|
193
162
|
if (node.paddingTop > 0) {
|
|
194
163
|
drawHorizontalTick(r, canvas, xCenter, (abs.y + node.paddingTop / 2) * r.zoom + r.panY)
|
|
195
164
|
}
|
|
@@ -214,9 +183,9 @@ function drawBaselineTicks(r: SkiaRenderer, canvas: Canvas, graph: SceneGraph, n
|
|
|
214
183
|
}
|
|
215
184
|
|
|
216
185
|
setStroke(r, AUTO_LAYOUT_HOVER_MAGENTA)
|
|
217
|
-
for (const
|
|
218
|
-
const [x, y, width, height] = rect
|
|
219
|
-
if (
|
|
186
|
+
for (const gap of layout.gaps) {
|
|
187
|
+
const [x, y, width, height] = absoluteRect(graph, node, gap.rect)
|
|
188
|
+
if (width <= height) {
|
|
220
189
|
drawVerticalTick(r, canvas, (x + width / 2) * r.zoom + r.panX, yCenter)
|
|
221
190
|
} else {
|
|
222
191
|
drawHorizontalTick(r, canvas, xCenter, (y + height / 2) * r.zoom + r.panY)
|
|
@@ -229,18 +198,28 @@ function drawSpacingHover(
|
|
|
229
198
|
canvas: Canvas,
|
|
230
199
|
graph: SceneGraph,
|
|
231
200
|
node: SceneNode,
|
|
201
|
+
layout: AutoLayoutHandleLayout,
|
|
202
|
+
hover: Hover,
|
|
232
203
|
showValue: boolean
|
|
233
204
|
) {
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!
|
|
239
|
-
|
|
205
|
+
const handles = layout.gaps
|
|
206
|
+
const shown =
|
|
207
|
+
handles.find((gap) => gap.axis === (hover.axis ?? 'primary') && gap.index === hover.index) ??
|
|
208
|
+
handles.at(0)
|
|
209
|
+
if (!shown) return
|
|
210
|
+
drawStripedRect(
|
|
211
|
+
r,
|
|
212
|
+
canvas,
|
|
213
|
+
absoluteRect(graph, node, shown.rect),
|
|
214
|
+
AUTO_LAYOUT_HOVER_MAGENTA,
|
|
215
|
+
AUTO_LAYOUT_HOVER_MAGENTA_FILL
|
|
216
|
+
)
|
|
217
|
+
if (!showValue) return
|
|
218
|
+
const [x, y, width, height] = absoluteRect(graph, node, shown.rect)
|
|
240
219
|
drawValuePill(
|
|
241
220
|
r,
|
|
242
221
|
canvas,
|
|
243
|
-
String(Math.round(
|
|
222
|
+
String(Math.round(shown.value)),
|
|
244
223
|
(x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,
|
|
245
224
|
(y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,
|
|
246
225
|
AUTO_LAYOUT_HOVER_GAP_PILL
|
|
@@ -252,22 +231,23 @@ function drawPaddingHover(
|
|
|
252
231
|
canvas: Canvas,
|
|
253
232
|
graph: SceneGraph,
|
|
254
233
|
node: SceneNode,
|
|
234
|
+
layout: AutoLayoutHandleLayout,
|
|
255
235
|
hover: Hover,
|
|
256
236
|
showValue: boolean
|
|
257
237
|
) {
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
260
|
-
|
|
238
|
+
const handle = layout.padding.find((padding) => padding.side === hover.side)
|
|
239
|
+
if (!handle) return
|
|
240
|
+
const rect = absoluteRect(graph, node, handle.rect)
|
|
241
|
+
drawStripedRect(r, canvas, rect, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL)
|
|
261
242
|
if (!showValue) return
|
|
262
243
|
const [x, y, width, height] = rect
|
|
263
|
-
const value = hover.side === 'left' || hover.side === 'right' ? width : height
|
|
264
244
|
drawValuePill(
|
|
265
245
|
r,
|
|
266
246
|
canvas,
|
|
267
|
-
String(Math.round(value)),
|
|
247
|
+
String(Math.round(handle.value)),
|
|
268
248
|
(x + width / 2) * r.zoom + r.panX + AUTO_LAYOUT_HOVER_VALUE_OFFSET,
|
|
269
249
|
(y + height / 2) * r.zoom + r.panY - AUTO_LAYOUT_HOVER_VALUE_OFFSET,
|
|
270
|
-
|
|
250
|
+
AUTO_LAYOUT_HOVER_GAP_PILL
|
|
271
251
|
)
|
|
272
252
|
}
|
|
273
253
|
|
|
@@ -280,13 +260,15 @@ export function drawAutoLayoutHover(
|
|
|
280
260
|
if (!hover) return
|
|
281
261
|
const node = graph.getNode(hover.nodeId)
|
|
282
262
|
if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return
|
|
263
|
+
const layout = measureAutoLayoutHandles(node, visibleLayoutChildren(node, graph))
|
|
264
|
+
if (!layout) return
|
|
283
265
|
|
|
284
266
|
if (hover.kind === 'children') strokeLayoutChildren(r, canvas, graph, node)
|
|
285
267
|
if (hover.kind === 'spacing' || hover.kind === 'spacing-value') {
|
|
286
|
-
drawSpacingHover(r, canvas, graph, node, hover.kind === 'spacing-value')
|
|
268
|
+
drawSpacingHover(r, canvas, graph, node, layout, hover, hover.kind === 'spacing-value')
|
|
287
269
|
}
|
|
288
270
|
if (hover.kind === 'padding' || hover.kind === 'padding-value') {
|
|
289
|
-
drawPaddingHover(r, canvas, graph, node, hover, hover.kind === 'padding-value')
|
|
271
|
+
drawPaddingHover(r, canvas, graph, node, layout, hover, hover.kind === 'padding-value')
|
|
290
272
|
}
|
|
291
|
-
drawBaselineTicks(r, canvas, graph, node)
|
|
273
|
+
drawBaselineTicks(r, canvas, graph, node, layout)
|
|
292
274
|
}
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from '#core/geometry'
|
|
29
29
|
import { pointAtArc, textPathStartArc } from '#core/text/path'
|
|
30
30
|
|
|
31
|
-
import { inNodeSpace,
|
|
31
|
+
import { inNodeSpace, withScreenStroke } from './outline'
|
|
32
32
|
|
|
33
33
|
/** The dash of faint selection bounds, in screen pixels. */
|
|
34
34
|
const SELECTION_DASH = [4, 4] as const
|
|
@@ -79,17 +79,6 @@ export function drawCodeFocus(
|
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function drawEnteredContainer(
|
|
83
|
-
r: SkiaRenderer,
|
|
84
|
-
canvas: Canvas,
|
|
85
|
-
graph: SceneGraph,
|
|
86
|
-
enteredContainerId?: string | null,
|
|
87
|
-
preview?: RotationPreview | null
|
|
88
|
-
): void {
|
|
89
|
-
const stroke = { color: r.selColor(SELECTION_DASH_ALPHA), dash: SELECTION_DASH }
|
|
90
|
-
outlineNode(r, canvas, graph, enteredContainerId, stroke, preview)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
82
|
/** Single-node selection overlay: path-text curve/band for imported TEXT_PATH,
|
|
94
83
|
* the standard rect+handles otherwise. */
|
|
95
84
|
function drawSingleSelection(
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '#core/constants'
|
|
22
22
|
import { withTextMeasurer } from '#core/layout/text-measurement'
|
|
23
23
|
import { EMOJI_METRICS_FAMILY } from '#core/text/emoji'
|
|
24
|
+
import { resetFontCollection } from '#core/text/font/collection'
|
|
24
25
|
import { fontManager } from '#core/text/font/manager'
|
|
25
26
|
import { prepareGraphFonts } from '#core/text/prepare'
|
|
26
27
|
import {
|
|
@@ -112,6 +113,7 @@ function registerSectionTitleFont(r: SkiaRenderer, data: ArrayBuffer) {
|
|
|
112
113
|
if (provider && !sectionTitleProviders.has(provider)) {
|
|
113
114
|
sectionTitleProviders.add(provider)
|
|
114
115
|
provider.registerFont(data, SECTION_TITLE_FONT_FAMILY)
|
|
116
|
+
resetFontCollection(provider)
|
|
115
117
|
fontManager.registerFontInBrowser(SECTION_TITLE_FONT_FAMILY, 'SemiBold', data)
|
|
116
118
|
}
|
|
117
119
|
const typeface = r.ck.Typeface.MakeFreeTypeFaceFromData(data)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { releaseImageAdjustments } from '#core/canvas/images/adjustments'
|
|
1
2
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
2
3
|
import { clearSubtreePictureCache } from '#core/canvas/renderer/state'
|
|
3
4
|
import { fontManager } from '#core/text/font/manager'
|
|
@@ -36,6 +37,7 @@ function releaseRuntimeEffects(r: SkiaRenderer): void {
|
|
|
36
37
|
r.linearBurnBlender = null
|
|
37
38
|
r.linearDodgeBlender?.delete()
|
|
38
39
|
r.linearDodgeBlender = null
|
|
40
|
+
releaseImageAdjustments(r.ck)
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export function destroyRenderer(r: SkiaRenderer): void {
|
|
@@ -85,6 +87,10 @@ export function destroyRenderer(r: SkiaRenderer): void {
|
|
|
85
87
|
r.effectLayerPaint.delete()
|
|
86
88
|
r.imageFilterCache.clear()
|
|
87
89
|
r.maskFilterCache.clear()
|
|
90
|
+
r.noiseTileCache.clear()
|
|
91
|
+
r.textureNoiseCache.clear()
|
|
92
|
+
r.noiseGrainEffect?.delete()
|
|
93
|
+
r.noiseGrainEffect = null
|
|
88
94
|
for (const pic of r.nodePictureCache.values()) pic?.delete()
|
|
89
95
|
r.nodePictureCache.clear()
|
|
90
96
|
r.labelParagraphCache.clear()
|
|
@@ -40,15 +40,6 @@ const rendererMethods = {
|
|
|
40
40
|
Overlays.drawMeasurements(this, canvas, graph, selectedIds, targetId)
|
|
41
41
|
},
|
|
42
42
|
|
|
43
|
-
drawEnteredContainer(
|
|
44
|
-
canvas: Canvas,
|
|
45
|
-
graph: SceneGraph,
|
|
46
|
-
enteredContainerId?: string | null,
|
|
47
|
-
preview?: RenderOverlays['rotationPreview']
|
|
48
|
-
): void {
|
|
49
|
-
Overlays.drawEnteredContainer(this, canvas, graph, enteredContainerId, preview)
|
|
50
|
-
},
|
|
51
|
-
|
|
52
43
|
drawSelection(
|
|
53
44
|
canvas: Canvas,
|
|
54
45
|
graph: SceneGraph,
|
|
@@ -93,7 +93,6 @@ export function drawOverlayPass(
|
|
|
93
93
|
if (!measuring) drawPrototypeConnections(r, canvas, graph, selectedIds, overlays.rotationPreview)
|
|
94
94
|
r.drawHoverHighlight(canvas, graph, hoveredNodeId, overlays.rotationPreview)
|
|
95
95
|
drawIssueHighlight(r, canvas, graph, overlays.designIssueHighlight, overlays.rotationPreview)
|
|
96
|
-
r.drawEnteredContainer(canvas, graph, overlays.enteredContainerId, overlays.rotationPreview)
|
|
97
96
|
drawDropTarget(r, canvas, graph, overlays.dropTargetId, overlays.rotationPreview)
|
|
98
97
|
drawConnectorTarget(r, canvas, graph, overlays.connectorTarget, overlays.rotationPreview)
|
|
99
98
|
drawEditingText(r, canvas, graph, overlays)
|
|
@@ -47,6 +47,24 @@ export function renderSceneToCanvas(
|
|
|
47
47
|
|
|
48
48
|
export type RenderLayer = 'full' | 'scene' | 'overlays'
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* What a canvas that runs play leaves to its live islands, and the frames a playing prototype
|
|
52
|
+
* draws from its play scenes or scrolled; an editing canvas has none of them.
|
|
53
|
+
*/
|
|
54
|
+
function playOverlays(
|
|
55
|
+
r: SkiaRenderer,
|
|
56
|
+
graph: SceneGraph,
|
|
57
|
+
pageId: string,
|
|
58
|
+
live: boolean
|
|
59
|
+
): Pick<RenderOverlays, 'playIslands' | 'playScenes' | 'playScroll'> {
|
|
60
|
+
if (!live) return {}
|
|
61
|
+
return {
|
|
62
|
+
playIslands: new Set(playIslandRoots(graph, pageId)),
|
|
63
|
+
playScenes: r.playScenes ?? undefined,
|
|
64
|
+
playScroll: r.playScroll ?? undefined
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
50
68
|
export function renderFromEditorState(
|
|
51
69
|
r: SkiaRenderer,
|
|
52
70
|
state: EditorState,
|
|
@@ -95,14 +113,13 @@ export function renderFromEditorState(
|
|
|
95
113
|
editChrome ? state.selectedIds : new Set<string>(),
|
|
96
114
|
{
|
|
97
115
|
playing: !editChrome,
|
|
98
|
-
|
|
116
|
+
...playOverlays(r, graph, state.currentPageId, live !== null),
|
|
99
117
|
hoveredNodeId: editChrome ? state.hoveredNodeId : null,
|
|
100
118
|
showPixelGrid: editChrome && state.showPixelGrid !== false,
|
|
101
119
|
gradientEdit: state.gradientEdit,
|
|
102
120
|
imageEdit: state.imageEdit,
|
|
103
121
|
transforming: state.transforming,
|
|
104
122
|
measurementMode: state.measurementMode,
|
|
105
|
-
enteredContainerId: state.enteredContainerId,
|
|
106
123
|
editingTextId: state.editingTextId,
|
|
107
124
|
renamingLabelId: state.renamingLabelId,
|
|
108
125
|
textEditor: textEditor as RenderOverlays['textEditor'],
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
3
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
4
|
+
|
|
5
|
+
import type { RenderOverlays, RenderedPlayScene } from './types'
|
|
6
|
+
|
|
7
|
+
/** The play scene a canvas last drew a frame from, and the change it showed then. */
|
|
8
|
+
interface DrawnPlayScene {
|
|
9
|
+
scene: RenderedPlayScene
|
|
10
|
+
revision: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** By canvas, the play scene each frame was last drawn from. */
|
|
14
|
+
const drawnByRenderer = new WeakMap<SkiaRenderer, Map<string, DrawnPlayScene>>()
|
|
15
|
+
|
|
16
|
+
function forgetTouched(r: SkiaRenderer, scene: RenderedPlayScene): void {
|
|
17
|
+
for (const id of scene.touched) r.invalidateNodePicture(id)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The graph a top-level frame is drawn from: its play scene's copy while play changed it, else
|
|
22
|
+
* null for the document. The copy keeps the document's ids, so the drawings the canvas keeps by
|
|
23
|
+
* id for the layers a change touched are dropped whenever the scene moves on or goes away.
|
|
24
|
+
*/
|
|
25
|
+
export function playSceneGraph(
|
|
26
|
+
r: SkiaRenderer,
|
|
27
|
+
nodeId: string,
|
|
28
|
+
overlays: RenderOverlays
|
|
29
|
+
): SceneGraph | null {
|
|
30
|
+
const scene = overlays.playScenes?.get(nodeId) ?? null
|
|
31
|
+
let drawnScenes = drawnByRenderer.get(r)
|
|
32
|
+
if (!scene && !drawnScenes) return null
|
|
33
|
+
const drawn = drawnScenes?.get(nodeId)
|
|
34
|
+
if (drawn && (drawn.scene !== scene || drawn.revision !== scene.revision)) {
|
|
35
|
+
forgetTouched(r, drawn.scene)
|
|
36
|
+
drawnScenes?.delete(nodeId)
|
|
37
|
+
// A canvas with no changed frame left skips this lookup for every layer it draws.
|
|
38
|
+
if (drawnScenes?.size === 0) drawnByRenderer.delete(r)
|
|
39
|
+
drawnScenes = drawnByRenderer.get(r)
|
|
40
|
+
}
|
|
41
|
+
if (!scene) return null
|
|
42
|
+
if (!drawnScenes) {
|
|
43
|
+
drawnScenes = new Map()
|
|
44
|
+
drawnByRenderer.set(r, drawnScenes)
|
|
45
|
+
}
|
|
46
|
+
if (!drawnScenes.has(nodeId)) {
|
|
47
|
+
forgetTouched(r, scene)
|
|
48
|
+
drawnScenes.set(nodeId, { scene, revision: scene.revision })
|
|
49
|
+
}
|
|
50
|
+
return scene.graph
|
|
51
|
+
}
|
|
@@ -2,7 +2,13 @@ import type { Image as CKImage } from 'canvaskit-wasm'
|
|
|
2
2
|
|
|
3
3
|
import { ResourceCache } from '#core/cache/resource'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
TILE_DEVICE_SIZE,
|
|
7
|
+
tileKeyString,
|
|
8
|
+
tileWorldSize,
|
|
9
|
+
type TileKey,
|
|
10
|
+
type TileWorldBounds
|
|
11
|
+
} from './geometry'
|
|
6
12
|
import type { RenderedTile } from './render'
|
|
7
13
|
|
|
8
14
|
export interface CachedTile {
|
|
@@ -14,6 +20,44 @@ export interface CachedTile {
|
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
const DEFAULT_MAX_TILE_BYTES = 128 * 1024 * 1024
|
|
23
|
+
const MAXIMUM_TILE_CACHE_BYTES = 768 * 1024 * 1024
|
|
24
|
+
/**
|
|
25
|
+
* The cache keeps as many viewports of tiles as the background stages work through, so one frame's
|
|
26
|
+
* work never evicts what the next frame draws.
|
|
27
|
+
*/
|
|
28
|
+
const TILE_CACHE_VIEWPORTS = 5
|
|
29
|
+
/** The share of a device's memory the tiles may hold, on a device that reports its memory. */
|
|
30
|
+
const DEVICE_MEMORY_SHARE = 1 / 16
|
|
31
|
+
|
|
32
|
+
const TILE_BYTES = TILE_DEVICE_SIZE * TILE_DEVICE_SIZE * 4
|
|
33
|
+
|
|
34
|
+
/** What the host knows about the memory the tiles share. */
|
|
35
|
+
export interface TileMemory {
|
|
36
|
+
/** The device's memory in bytes, where the host can tell. */
|
|
37
|
+
deviceBytes?: number
|
|
38
|
+
/** The canvas is not on screen: only the tiles it showed last are kept, to show it again. */
|
|
39
|
+
hidden?: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The bytes of the tiles a viewport of this many device pixels can touch. */
|
|
43
|
+
export function viewportTileBytes(widthPx: number, heightPx: number): number {
|
|
44
|
+
return Math.ceil(widthPx / TILE_DEVICE_SIZE) * Math.ceil(heightPx / TILE_DEVICE_SIZE) * TILE_BYTES
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The cache's byte budget for a viewport whose tiles weigh `viewportBytes`: as many viewports as
|
|
49
|
+
* the background stages use, within a share of the device's memory where it is known. The
|
|
50
|
+
* visible tiles always fit, or the view could never finish drawing.
|
|
51
|
+
*/
|
|
52
|
+
export function viewportTileCacheBudget(viewportBytes: number, memory: TileMemory = {}): number {
|
|
53
|
+
if (memory.hidden) return viewportBytes
|
|
54
|
+
const ceiling =
|
|
55
|
+
memory.deviceBytes === undefined
|
|
56
|
+
? MAXIMUM_TILE_CACHE_BYTES
|
|
57
|
+
: Math.min(MAXIMUM_TILE_CACHE_BYTES, memory.deviceBytes * DEVICE_MEMORY_SHARE)
|
|
58
|
+
const wanted = Math.max(DEFAULT_MAX_TILE_BYTES, viewportBytes * TILE_CACHE_VIEWPORTS)
|
|
59
|
+
return Math.max(viewportBytes, Math.min(ceiling, wanted))
|
|
60
|
+
}
|
|
17
61
|
|
|
18
62
|
export class TileImageCache {
|
|
19
63
|
private readonly entries: ResourceCache<string, CachedTile>
|
|
@@ -99,4 +143,13 @@ export class TileImageCache {
|
|
|
99
143
|
byteSize(): number {
|
|
100
144
|
return this.entries.weight
|
|
101
145
|
}
|
|
146
|
+
|
|
147
|
+
/** The cache's byte budget, as `viewportTileCacheBudget` gives it for the current viewport. */
|
|
148
|
+
budget(): number {
|
|
149
|
+
return this.entries.maxBytes
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setBudget(bytes: number): void {
|
|
153
|
+
this.entries.setMaxWeight(bytes)
|
|
154
|
+
}
|
|
102
155
|
}
|