@pairdraw/core 0.19.2 → 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/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/renderer/chunks/index.d.ts +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/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -1
- 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 -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 +22 -2
- 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/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/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/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 +27 -3
- 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 +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 +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/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/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/index.d.ts +5 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +6 -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/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/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/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.js +1 -0
- 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/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/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 +1 -53
- 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 +174 -36
- 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/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.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -1
- 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 +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +110 -8
- 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/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/read-commands.js +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/index.d.ts +10 -8
- package/dist/text/index.js +3 -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/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/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/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 +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/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.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/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/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/pipeline.ts +19 -1
- 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 -2
- package/src/canvas/renderer.ts +40 -3
- 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-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/components/instances.ts +31 -0
- 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 +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 +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/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- 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/index.ts +10 -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/surface.ts +6 -2
- package/src/global.d.ts +26 -0
- 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 +2 -0
- 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/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- 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 +4 -72
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +278 -46
- 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/auto-layout-handles.ts +396 -0
- package/src/layout.ts +2 -0
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +107 -10
- 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/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/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- 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/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/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 +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/vector/boolean.ts +4 -0
- 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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
2
|
+
|
|
3
|
+
import { formatColor, type SVGExportContext } from './defs'
|
|
4
|
+
import { svg, type SVGNode } from './node'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A flood's colour, opaque: its alpha goes in `flood-opacity`, which a Display P3 colour would
|
|
8
|
+
* otherwise carry a second time.
|
|
9
|
+
*/
|
|
10
|
+
export function floodColor(color: Color, colorSpace: SVGExportContext['colorSpace']): string {
|
|
11
|
+
return formatColor({ ...color, a: 1 }, 1, colorSpace)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** An SVG filter's primitives as they are added, each naming its result uniquely. */
|
|
15
|
+
export class FilterBuilder {
|
|
16
|
+
readonly primitives: SVGNode[] = []
|
|
17
|
+
private count = 0
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
private readonly id: string,
|
|
21
|
+
private readonly ctx: SVGExportContext
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
/** A primitive with as many children as `children` holds. */
|
|
25
|
+
pushElement(
|
|
26
|
+
tag: string,
|
|
27
|
+
attrs: Record<string, string | number | undefined>,
|
|
28
|
+
children: SVGNode[]
|
|
29
|
+
) {
|
|
30
|
+
this.primitives.push(svg(tag, attrs, ...children))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The colour space the export writes colours in. */
|
|
34
|
+
get colorSpace(): SVGExportContext['colorSpace'] {
|
|
35
|
+
return this.ctx.colorSpace
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A new result name, unique in this filter. */
|
|
39
|
+
result(name: string): string {
|
|
40
|
+
this.count += 1
|
|
41
|
+
return `${this.id}_${name}${this.count}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
push(tag: string, attrs: Record<string, string | number | undefined>, ...children: SVGNode[]) {
|
|
45
|
+
this.primitives.push(svg(tag, attrs, ...children))
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type { NoiseEffect, TextureEffect } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Vector } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
|
|
4
|
+
import { floodColor, type FilterBuilder } from './filter'
|
|
5
|
+
import { svg } from './node'
|
|
6
|
+
import { round } from './paths'
|
|
7
|
+
|
|
8
|
+
/** How many steps the discrete alpha table of a noise has, as Figma writes it. */
|
|
9
|
+
const NOISE_TABLE_STEPS = 100
|
|
10
|
+
|
|
11
|
+
/** Keeps a channel's alpha alone, as each of Figma's grain matrices does somewhere. */
|
|
12
|
+
const ALPHA_ONLY = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'
|
|
13
|
+
const ALPHA_TO_RED = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1'
|
|
14
|
+
const ALPHA_TO_GREEN = '0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1'
|
|
15
|
+
const OPAQUE = '1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 127 0'
|
|
16
|
+
const ALPHA_TO_RED_OPAQUE = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'
|
|
17
|
+
const RED_TO_ALPHA = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'
|
|
18
|
+
|
|
19
|
+
/** A grain size as `feTurbulence` frequency, one cycle per grain on each axis. */
|
|
20
|
+
function grainFrequency(size: Vector): string {
|
|
21
|
+
const frequency = (length: number) => (length > 0 ? round(1 / length, 4) : 0)
|
|
22
|
+
return `${frequency(size.x)} ${frequency(size.y)}`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes
|
|
27
|
+
* it: a band of ones over the noise's middle tones, one step wide at no density and half the
|
|
28
|
+
* steps at full. Figma works it out in 32-bit floats, as it stores the density.
|
|
29
|
+
*/
|
|
30
|
+
export function noiseDensityTable(density: number, mirrored = false): string {
|
|
31
|
+
const stored = Math.fround(density)
|
|
32
|
+
const start = Math.floor(25 - 25 * stored)
|
|
33
|
+
const count = Math.floor(50 * stored) + 1
|
|
34
|
+
const steps = Array.from({ length: NOISE_TABLE_STEPS }, (_, step) =>
|
|
35
|
+
step >= start && step < start + count ? 1 : 0
|
|
36
|
+
)
|
|
37
|
+
return (mirrored ? steps.reverse() : steps).join(' ')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a
|
|
42
|
+
* cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its
|
|
43
|
+
* second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the
|
|
44
|
+
* result's name.
|
|
45
|
+
*/
|
|
46
|
+
export function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: string): string {
|
|
47
|
+
const grain = effect.noise
|
|
48
|
+
const noise = filter.result('noise')
|
|
49
|
+
filter.push('feTurbulence', {
|
|
50
|
+
type: 'fractalNoise',
|
|
51
|
+
baseFrequency: grainFrequency(grain.noiseSize),
|
|
52
|
+
stitchTiles: 'stitch',
|
|
53
|
+
numOctaves: 3,
|
|
54
|
+
seed: grain.seed ?? 0,
|
|
55
|
+
result: noise
|
|
56
|
+
})
|
|
57
|
+
const merged = filter.result('noiseMerge')
|
|
58
|
+
if (grain.noiseType === 'MULTITONE') {
|
|
59
|
+
const colored = filter.result('multitone')
|
|
60
|
+
const linear = { type: 'linear', slope: 2, intercept: -0.5 }
|
|
61
|
+
filter.push(
|
|
62
|
+
'feComponentTransfer',
|
|
63
|
+
{ in: noise, result: colored },
|
|
64
|
+
svg('feFuncR', linear),
|
|
65
|
+
svg('feFuncG', linear),
|
|
66
|
+
svg('feFuncB', linear),
|
|
67
|
+
svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density) })
|
|
68
|
+
)
|
|
69
|
+
const clipped = filter.result('noiseClipped')
|
|
70
|
+
filter.push('feComposite', { in: colored, in2: input, operator: 'in', result: clipped })
|
|
71
|
+
const faded = filter.result('noiseColor')
|
|
72
|
+
filter.push(
|
|
73
|
+
'feComponentTransfer',
|
|
74
|
+
{ in: clipped, result: faded },
|
|
75
|
+
svg('feFuncA', { type: 'table', tableValues: `0 ${round(grain.opacity ?? 1)}` })
|
|
76
|
+
)
|
|
77
|
+
filter.pushElement('feMerge', { result: merged }, mergeNodes([input, faded]))
|
|
78
|
+
return merged
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const alpha = filter.result('alphaNoise')
|
|
82
|
+
filter.push('feColorMatrix', { in: noise, type: 'luminanceToAlpha', result: alpha })
|
|
83
|
+
const tones = [{ color: effect.color, mirrored: false }]
|
|
84
|
+
if (grain.noiseType === 'DUOTONE') {
|
|
85
|
+
tones.push({ color: grain.secondaryColor ?? effect.color, mirrored: true })
|
|
86
|
+
}
|
|
87
|
+
const colors = tones.map(({ color, mirrored }) => {
|
|
88
|
+
const band = filter.result('noiseBand')
|
|
89
|
+
filter.push(
|
|
90
|
+
'feComponentTransfer',
|
|
91
|
+
{ in: alpha, result: band },
|
|
92
|
+
svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density, mirrored) })
|
|
93
|
+
)
|
|
94
|
+
const clipped = filter.result('noiseClipped')
|
|
95
|
+
filter.push('feComposite', { in: band, in2: input, operator: 'in', result: clipped })
|
|
96
|
+
const flood = filter.result('noiseFlood')
|
|
97
|
+
filter.push('feFlood', {
|
|
98
|
+
'flood-color': floodColor(color, filter.colorSpace),
|
|
99
|
+
'flood-opacity': round(color.a),
|
|
100
|
+
result: flood
|
|
101
|
+
})
|
|
102
|
+
const colored = filter.result('noiseColor')
|
|
103
|
+
filter.push('feComposite', { in: flood, in2: clipped, operator: 'in', result: colored })
|
|
104
|
+
return colored
|
|
105
|
+
})
|
|
106
|
+
filter.pushElement('feMerge', { result: merged }, mergeNodes([input, ...colors]))
|
|
107
|
+
return merged
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function mergeNodes(inputs: readonly string[]) {
|
|
111
|
+
return inputs.map((input) => svg('feMergeNode', { in: input }))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal
|
|
116
|
+
* noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to
|
|
117
|
+
* its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.
|
|
118
|
+
* Returns the result's name.
|
|
119
|
+
*/
|
|
120
|
+
export function textureFilter(filter: FilterBuilder, effect: TextureEffect, input: string): string {
|
|
121
|
+
const grain = effect.texture
|
|
122
|
+
const frequency = grainFrequency(grain.noiseSize)
|
|
123
|
+
const scale = round(effect.radius * 2)
|
|
124
|
+
const name = (label: string) => filter.result(label)
|
|
125
|
+
const displace = (into: string, by: string, result: string) =>
|
|
126
|
+
filter.push('feDisplacementMap', {
|
|
127
|
+
in: into,
|
|
128
|
+
in2: by,
|
|
129
|
+
scale,
|
|
130
|
+
xChannelSelector: 'R',
|
|
131
|
+
yChannelSelector: 'G',
|
|
132
|
+
width: '100%',
|
|
133
|
+
height: '100%',
|
|
134
|
+
result
|
|
135
|
+
})
|
|
136
|
+
const turbulence = (seed: number, result: string) =>
|
|
137
|
+
filter.push('feTurbulence', {
|
|
138
|
+
type: 'fractalNoise',
|
|
139
|
+
baseFrequency: frequency,
|
|
140
|
+
numOctaves: 3,
|
|
141
|
+
seed: (grain.seed ?? 0) + seed,
|
|
142
|
+
result
|
|
143
|
+
})
|
|
144
|
+
const matrix = (into: string, values: string, result: string) =>
|
|
145
|
+
filter.push('feColorMatrix', { in: into, type: 'matrix', values, result })
|
|
146
|
+
const arithmetic = (
|
|
147
|
+
into: string,
|
|
148
|
+
by: string,
|
|
149
|
+
k: [number, number, number, number],
|
|
150
|
+
result: string
|
|
151
|
+
) =>
|
|
152
|
+
filter.push('feComposite', {
|
|
153
|
+
in: into,
|
|
154
|
+
in2: by,
|
|
155
|
+
operator: 'arithmetic',
|
|
156
|
+
k1: k[0],
|
|
157
|
+
k2: k[1],
|
|
158
|
+
k3: k[2],
|
|
159
|
+
k4: k[3],
|
|
160
|
+
result
|
|
161
|
+
})
|
|
162
|
+
const composite = (into: string, by: string, operator: string, result: string) =>
|
|
163
|
+
filter.push('feComposite', { in: into, in2: by, operator, result })
|
|
164
|
+
const gamma = (into: string, result: string) =>
|
|
165
|
+
filter.push(
|
|
166
|
+
'feComponentTransfer',
|
|
167
|
+
{ in: into, result },
|
|
168
|
+
svg('feFuncA', { type: 'gamma', exponent: 0.2 })
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if (!grain.clipToShape) {
|
|
172
|
+
const noise = name('textureNoise')
|
|
173
|
+
turbulence(0, noise)
|
|
174
|
+
const displaced = name('texture')
|
|
175
|
+
displace(input, noise, displaced)
|
|
176
|
+
return displaced
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const noiseX = name('displacementX')
|
|
180
|
+
const noiseY = name('displacementY')
|
|
181
|
+
turbulence(0, noiseX)
|
|
182
|
+
turbulence(1, noiseY)
|
|
183
|
+
const xRed = name('displacementXRed')
|
|
184
|
+
matrix(noiseX, ALPHA_TO_RED, xRed)
|
|
185
|
+
const yGreen = name('displacementYGreen')
|
|
186
|
+
matrix(noiseY, ALPHA_TO_GREEN, yGreen)
|
|
187
|
+
const xy = name('displacementXY')
|
|
188
|
+
arithmetic(xRed, yGreen, [0, 1, 1, 0], xy)
|
|
189
|
+
const firstPass = name('firstPass')
|
|
190
|
+
displace(input, xy, firstPass)
|
|
191
|
+
const firstAlpha = name('firstPassAlpha')
|
|
192
|
+
matrix(firstPass, ALPHA_ONLY, firstAlpha)
|
|
193
|
+
const displacedAlpha = name('sourceDisplacedAlpha')
|
|
194
|
+
gamma(firstAlpha, displacedAlpha)
|
|
195
|
+
const inputAlphaOnly = name('inputAlphaOnly')
|
|
196
|
+
matrix(input, ALPHA_ONLY, inputAlphaOnly)
|
|
197
|
+
const inputAlpha = name('inputSourceAlpha')
|
|
198
|
+
gamma(inputAlphaOnly, inputAlpha)
|
|
199
|
+
const alphas = name('displacementAlphasMultiplied')
|
|
200
|
+
arithmetic(displacedAlpha, inputAlpha, [1, 0, 0, 0], alphas)
|
|
201
|
+
const centering = name('centeringAdjustment')
|
|
202
|
+
arithmetic(alphas, alphas, [0, 0, -0.5, 0.5], centering)
|
|
203
|
+
|
|
204
|
+
const finalChannel = (noise: string, values: string, label: string) => {
|
|
205
|
+
const weighted = name(`${label}Weighted`)
|
|
206
|
+
arithmetic(noise, alphas, [1, 0, 0, 0], weighted)
|
|
207
|
+
const centered = name(`${label}Centered`)
|
|
208
|
+
arithmetic(centering, weighted, [0, 1, 1, 0], centered)
|
|
209
|
+
const final = name(`${label}Final`)
|
|
210
|
+
matrix(centered, values, final)
|
|
211
|
+
return final
|
|
212
|
+
}
|
|
213
|
+
const xFinal = finalChannel(noiseX, ALPHA_TO_RED, 'displacementX')
|
|
214
|
+
const yFinal = finalChannel(noiseY, ALPHA_TO_GREEN, 'displacementY')
|
|
215
|
+
const combined = name('displacementCombined')
|
|
216
|
+
arithmetic(xFinal, yFinal, [0, 1, 1, 0], combined)
|
|
217
|
+
const map = name('displacementMap')
|
|
218
|
+
composite(combined, alphas, 'in', map)
|
|
219
|
+
const neutral = name('neutral')
|
|
220
|
+
filter.push('feFlood', {
|
|
221
|
+
'flood-color': 'rgb(127, 127, 127)',
|
|
222
|
+
'flood-opacity': 1,
|
|
223
|
+
result: neutral
|
|
224
|
+
})
|
|
225
|
+
const outside = name('neutralOutside')
|
|
226
|
+
composite(neutral, alphas, 'out', outside)
|
|
227
|
+
const mapWithBackground = name('displacementMapWithBg')
|
|
228
|
+
composite(outside, map, 'over', mapWithBackground)
|
|
229
|
+
|
|
230
|
+
const displaced = name('displacedImage')
|
|
231
|
+
displace(input, mapWithBackground, displaced)
|
|
232
|
+
const opaque = name('imageOpaque')
|
|
233
|
+
matrix(input, OPAQUE, opaque)
|
|
234
|
+
const displacedOpaque = name('displacedImageOpaque')
|
|
235
|
+
displace(opaque, mapWithBackground, displacedOpaque)
|
|
236
|
+
const displacedRed = name('displacedImageRed')
|
|
237
|
+
matrix(displaced, ALPHA_TO_RED_OPAQUE, displacedRed)
|
|
238
|
+
const inputRed = name('inputRed')
|
|
239
|
+
matrix(input, ALPHA_TO_RED_OPAQUE, inputRed)
|
|
240
|
+
const transparencyRed = name('transparencyRedMap')
|
|
241
|
+
composite(displacedRed, inputRed, 'atop', transparencyRed)
|
|
242
|
+
const transparency = name('transparencyAlphaMap')
|
|
243
|
+
matrix(transparencyRed, RED_TO_ALPHA, transparency)
|
|
244
|
+
const layered = name('textureLayered')
|
|
245
|
+
composite(displacedOpaque, opaque, 'over', layered)
|
|
246
|
+
const textured = name('texture')
|
|
247
|
+
composite(layered, transparency, 'in', textured)
|
|
248
|
+
return textured
|
|
249
|
+
}
|
|
@@ -50,9 +50,9 @@ export function alignedStrokeElement(
|
|
|
50
50
|
node: SceneNode,
|
|
51
51
|
stroke: Stroke,
|
|
52
52
|
strokeAttrs: Attrs,
|
|
53
|
-
ctx: SVGExportContext
|
|
53
|
+
ctx: SVGExportContext,
|
|
54
|
+
outline = closedOutlinePath(node)
|
|
54
55
|
): SVGNode[] {
|
|
55
|
-
const outline = closedOutlinePath(node)
|
|
56
56
|
if (outline === null) return []
|
|
57
57
|
const clipId = nextDefId(ctx, 'clip')
|
|
58
58
|
if (stroke.align === 'INSIDE') {
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
+
import type { CanvasKit } from 'canvaskit-wasm'
|
|
2
|
+
|
|
1
3
|
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
4
|
|
|
5
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
3
6
|
import { withPDFTextLayout } from '#core/io/formats/pdf/prepare'
|
|
7
|
+
import { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'
|
|
4
8
|
import { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'
|
|
5
9
|
import { prepareGraphFonts } from '#core/text/prepare'
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each
|
|
9
13
|
* line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export
|
|
10
|
-
* sets them.
|
|
14
|
+
* sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so
|
|
15
|
+
* the pattern embeds the adjusted pixels.
|
|
11
16
|
*/
|
|
12
17
|
export async function renderNodesToLaidOutSVG(
|
|
13
18
|
graph: SceneGraph,
|
|
14
19
|
pageId: string,
|
|
15
20
|
nodeIds: string[],
|
|
16
|
-
options: SVGExportOptions = {}
|
|
21
|
+
options: SVGExportOptions = {},
|
|
22
|
+
canvasKit?: CanvasKit,
|
|
23
|
+
renderer?: SkiaRenderer
|
|
17
24
|
): Promise<string | null> {
|
|
18
25
|
await prepareGraphFonts(graph, nodeIds)
|
|
26
|
+
const baked = hasAdjustedImagePaints(graph, nodeIds)
|
|
27
|
+
? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)
|
|
28
|
+
: graph
|
|
19
29
|
return withPDFTextLayout(async (textLayout) =>
|
|
20
|
-
renderNodesToSVG(
|
|
30
|
+
renderNodesToSVG(baked, pageId, nodeIds, { textLayout, ...options })
|
|
21
31
|
)
|
|
22
32
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
2
|
+
|
|
3
|
+
import type { RGBAImage } from '#core/io/formats/raster'
|
|
4
|
+
|
|
5
|
+
/** A frame of one opaque color, such as the page behind the played frame. */
|
|
6
|
+
export function filledImage(width: number, height: number, color: Color): RGBAImage {
|
|
7
|
+
const data = new Uint8Array(width * height * 4)
|
|
8
|
+
const r = Math.round(color.r * 255)
|
|
9
|
+
const g = Math.round(color.g * 255)
|
|
10
|
+
const b = Math.round(color.b * 255)
|
|
11
|
+
for (let index = 0; index < data.length; index += 4) {
|
|
12
|
+
data[index] = r
|
|
13
|
+
data[index + 1] = g
|
|
14
|
+
data[index + 2] = b
|
|
15
|
+
data[index + 3] = 255
|
|
16
|
+
}
|
|
17
|
+
return { width, height, data }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Draws `source` over `target` with its top-left corner at `x`, `y` in whole pixels, as a layer
|
|
22
|
+
* paints over what is under it; what falls outside `target` is clipped.
|
|
23
|
+
*/
|
|
24
|
+
export function drawOver(target: RGBAImage, source: RGBAImage, x: number, y: number): void {
|
|
25
|
+
const left = Math.max(0, x)
|
|
26
|
+
const top = Math.max(0, y)
|
|
27
|
+
const right = Math.min(target.width, x + source.width)
|
|
28
|
+
const bottom = Math.min(target.height, y + source.height)
|
|
29
|
+
const out = target.data
|
|
30
|
+
const src = source.data
|
|
31
|
+
for (let row = top; row < bottom; row++) {
|
|
32
|
+
let to = (row * target.width + left) * 4
|
|
33
|
+
let from = ((row - y) * source.width + (left - x)) * 4
|
|
34
|
+
for (let column = left; column < right; column++, to += 4, from += 4) {
|
|
35
|
+
const alpha = src[from + 3]
|
|
36
|
+
if (alpha === 0) continue
|
|
37
|
+
if (alpha === 255) {
|
|
38
|
+
out[to] = src[from]
|
|
39
|
+
out[to + 1] = src[from + 1]
|
|
40
|
+
out[to + 2] = src[from + 2]
|
|
41
|
+
out[to + 3] = 255
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
const rest = 255 - alpha
|
|
45
|
+
const under = (out[to + 3] * rest) / 255
|
|
46
|
+
const total = alpha + under
|
|
47
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
48
|
+
out[to + channel] = Math.round(
|
|
49
|
+
(src[from + channel] * alpha + out[to + channel] * under) / total
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
out[to + 3] = Math.round(total)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Darkens `target` toward black by `amount`, as the scrim under an overlay does. */
|
|
58
|
+
export function dim(target: RGBAImage, amount: number): void {
|
|
59
|
+
const keep = 1 - amount
|
|
60
|
+
const data = target.data
|
|
61
|
+
for (let index = 0; index < data.length; index += 4) {
|
|
62
|
+
data[index] = Math.round(data[index] * keep)
|
|
63
|
+
data[index + 1] = Math.round(data[index + 1] * keep)
|
|
64
|
+
data[index + 2] = Math.round(data[index + 2] * keep)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A frame `mix` of the way from `from` to `to`, as a crossfade's opacity draws it. */
|
|
69
|
+
export function crossfade(from: RGBAImage, to: RGBAImage, mix: number): RGBAImage {
|
|
70
|
+
if (mix <= 0) return from
|
|
71
|
+
if (mix >= 1) return to
|
|
72
|
+
const data = new Uint8Array(from.data.length)
|
|
73
|
+
const a = from.data
|
|
74
|
+
const b = to.data
|
|
75
|
+
for (let index = 0; index < data.length; index++) {
|
|
76
|
+
data[index] = Math.round(a[index] + (b[index] - a[index]) * mix)
|
|
77
|
+
}
|
|
78
|
+
return { width: from.width, height: from.height, data }
|
|
79
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createGIFSink, MAX_GIF_FPS } from './gif'
|
|
2
|
+
import { VIDEO_FORMATS, type VideoFormat, type VideoSink, type VideoSinkOptions } from './sink'
|
|
3
|
+
import { canRecordVideo, createWebCodecsSink } from './webcodecs'
|
|
4
|
+
|
|
5
|
+
/** Each format's name as people know it. */
|
|
6
|
+
export const VIDEO_FORMAT_LABELS: Record<VideoFormat, string> = {
|
|
7
|
+
mp4: 'MP4',
|
|
8
|
+
gif: 'GIF',
|
|
9
|
+
webm: 'WebM'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An encoder a host passes for the formats WebCodecs cannot encode there, such as the CLI's
|
|
14
|
+
* ffmpeg. It is asked only for MP4 and WebM, after WebCodecs.
|
|
15
|
+
*/
|
|
16
|
+
export interface VideoHostEncoder {
|
|
17
|
+
supports(format: VideoFormat): boolean | Promise<boolean>
|
|
18
|
+
create(format: VideoFormat, options: VideoSinkOptions): Promise<VideoSink>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A format this engine cannot record at the size and frame rate asked for, and why. */
|
|
22
|
+
export class VideoFormatError extends Error {
|
|
23
|
+
override name = 'VideoFormatError'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Whether this engine, or the host's encoder, can record `format` at `width`×`height` and `fps`. */
|
|
27
|
+
export async function canRecordFormat(
|
|
28
|
+
format: VideoFormat,
|
|
29
|
+
width: number,
|
|
30
|
+
height: number,
|
|
31
|
+
fps: number,
|
|
32
|
+
host?: VideoHostEncoder | null
|
|
33
|
+
): Promise<boolean> {
|
|
34
|
+
if (format === 'gif') return fps <= MAX_GIF_FPS
|
|
35
|
+
if (await canRecordVideo(format, width, height, fps)) return true
|
|
36
|
+
return (await host?.supports(format)) ?? false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The formats this engine can record at `width`×`height` and `fps`, MP4 first. */
|
|
40
|
+
export async function recordableFormats(
|
|
41
|
+
width: number,
|
|
42
|
+
height: number,
|
|
43
|
+
fps: number,
|
|
44
|
+
host?: VideoHostEncoder | null
|
|
45
|
+
): Promise<VideoFormat[]> {
|
|
46
|
+
const supported = await Promise.all(
|
|
47
|
+
VIDEO_FORMATS.map((format) => canRecordFormat(format, width, height, fps, host))
|
|
48
|
+
)
|
|
49
|
+
return VIDEO_FORMATS.filter((_, index) => supported[index])
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The encoder for `format`: GIF everywhere, MP4 and WebM where WebCodecs (or an encoder registered
|
|
54
|
+
* with mediabunny) can encode them, else through `host`. Throws a `VideoFormatError` naming the
|
|
55
|
+
* formats that do work here.
|
|
56
|
+
*/
|
|
57
|
+
export async function openVideoSink(
|
|
58
|
+
format: VideoFormat,
|
|
59
|
+
options: VideoSinkOptions,
|
|
60
|
+
host?: VideoHostEncoder | null
|
|
61
|
+
): Promise<VideoSink> {
|
|
62
|
+
const { width, height, fps } = options
|
|
63
|
+
if (format === 'gif' && fps <= MAX_GIF_FPS) return createGIFSink(options)
|
|
64
|
+
if (format !== 'gif' && (await canRecordVideo(format, width, height, fps))) {
|
|
65
|
+
return createWebCodecsSink(format, options)
|
|
66
|
+
}
|
|
67
|
+
if (format !== 'gif' && host && (await host.supports(format))) {
|
|
68
|
+
return host.create(format, options)
|
|
69
|
+
}
|
|
70
|
+
if (format === 'gif') {
|
|
71
|
+
throw new VideoFormatError(`GIF plays at most ${MAX_GIF_FPS} frames per second`)
|
|
72
|
+
}
|
|
73
|
+
const working = await recordableFormats(width, height, fps, host)
|
|
74
|
+
throw new VideoFormatError(
|
|
75
|
+
`${VIDEO_FORMAT_LABELS[format]} can’t be encoded here at ${width}×${height}. Formats that work here: ${working.map((entry) => VIDEO_FORMAT_LABELS[entry]).join(', ')}.`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// gifenc's package root resolves to its CJS build under Node, whose named exports Node ESM cannot
|
|
2
|
+
// see; the ES build it ships for bundlers has them, and every runtime loads that same file.
|
|
3
|
+
import { applyPalette, GIFEncoder, quantize } from 'gifenc/dist/gifenc.esm.js'
|
|
4
|
+
|
|
5
|
+
import type { RGBAImage } from '#core/io/formats/raster'
|
|
6
|
+
|
|
7
|
+
import type { VideoSink, VideoSinkOptions } from './sink'
|
|
8
|
+
|
|
9
|
+
/** Browsers stretch delays under two hundredths of a second, so faster GIFs play slower. */
|
|
10
|
+
export const MAX_GIF_FPS = 50
|
|
11
|
+
|
|
12
|
+
interface PendingFrame {
|
|
13
|
+
image: RGBAImage
|
|
14
|
+
startMs: number
|
|
15
|
+
endMs: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A GIF encoder for recorded frames. A frame passed again as the same image extends the one before
|
|
20
|
+
* it, so a held screen is stored once with its whole delay. Delays are kept in hundredths of a
|
|
21
|
+
* second measured from the start, so rounding never drifts the clip's length.
|
|
22
|
+
*/
|
|
23
|
+
export function createGIFSink(options: VideoSinkOptions): VideoSink {
|
|
24
|
+
if (options.fps > MAX_GIF_FPS) {
|
|
25
|
+
throw new Error(`GIF plays at most ${MAX_GIF_FPS} frames per second`)
|
|
26
|
+
}
|
|
27
|
+
const encoder = GIFEncoder()
|
|
28
|
+
let pending: PendingFrame | null = null
|
|
29
|
+
|
|
30
|
+
function write(frame: PendingFrame) {
|
|
31
|
+
const { data, width, height } = frame.image
|
|
32
|
+
const palette = quantize(data, 256)
|
|
33
|
+
const delayCs = Math.round(frame.endMs / 10) - Math.round(frame.startMs / 10)
|
|
34
|
+
encoder.writeFrame(applyPalette(data, palette), width, height, {
|
|
35
|
+
palette,
|
|
36
|
+
delay: delayCs * 10,
|
|
37
|
+
repeat: options.loops ? 0 : -1
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
add(image, timestampMs, durationMs) {
|
|
43
|
+
const endMs = timestampMs + durationMs
|
|
44
|
+
if (pending?.image === image) pending.endMs = endMs
|
|
45
|
+
else {
|
|
46
|
+
if (pending) write(pending)
|
|
47
|
+
pending = { image, startMs: timestampMs, endMs }
|
|
48
|
+
}
|
|
49
|
+
return Promise.resolve()
|
|
50
|
+
},
|
|
51
|
+
finish() {
|
|
52
|
+
if (pending) write(pending)
|
|
53
|
+
pending = null
|
|
54
|
+
encoder.finish()
|
|
55
|
+
return Promise.resolve(encoder.bytes())
|
|
56
|
+
},
|
|
57
|
+
cancel() {
|
|
58
|
+
pending = null
|
|
59
|
+
return Promise.resolve()
|
|
60
|
+
},
|
|
61
|
+
get byteLength() {
|
|
62
|
+
return encoder.bytesView().length
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { crossfade, dim, drawOver, filledImage } from './composite'
|
|
2
|
+
export { createGIFSink, MAX_GIF_FPS } from './gif'
|
|
3
|
+
export {
|
|
4
|
+
VIDEO_FORMATS,
|
|
5
|
+
VIDEO_MIME_TYPES,
|
|
6
|
+
type VideoFormat,
|
|
7
|
+
type VideoSink,
|
|
8
|
+
type VideoSinkOptions
|
|
9
|
+
} from './sink'
|
|
10
|
+
export { recordPrototype, type RecordOptions, type RecordResult, type RenderFrame } from './record'
|
|
11
|
+
export { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from './size'
|
|
12
|
+
export { canRecordVideo, createWebCodecsSink, type EncodedVideoFormat } from './webcodecs'
|
|
13
|
+
export {
|
|
14
|
+
canRecordFormat,
|
|
15
|
+
openVideoSink,
|
|
16
|
+
recordableFormats,
|
|
17
|
+
type VideoHostEncoder,
|
|
18
|
+
VIDEO_FORMAT_LABELS,
|
|
19
|
+
VideoFormatError
|
|
20
|
+
} from './formats'
|
|
21
|
+
export {
|
|
22
|
+
DEFAULT_VIDEO_TAIL_MS,
|
|
23
|
+
exportedFrameRenderer,
|
|
24
|
+
MAX_GIF_EDGE,
|
|
25
|
+
planPrototypeVideo,
|
|
26
|
+
recordPrototypeVideo,
|
|
27
|
+
VIDEO_DEFAULTS,
|
|
28
|
+
type PrototypeVideoOptions,
|
|
29
|
+
type PrototypeVideoPlan
|
|
30
|
+
} from './plan'
|