@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,26 @@
|
|
|
1
|
+
import { FilterBuilder } from "./filter.js";
|
|
2
|
+
import { NoiseEffect, TextureEffect } from "@pairdraw/scene-graph";
|
|
3
|
+
//#region src/io/formats/svg/grain.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes
|
|
6
|
+
* it: a band of ones over the noise's middle tones, one step wide at no density and half the
|
|
7
|
+
* steps at full. Figma works it out in 32-bit floats, as it stores the density.
|
|
8
|
+
*/
|
|
9
|
+
declare function noiseDensityTable(density: number, mirrored?: boolean): string;
|
|
10
|
+
/**
|
|
11
|
+
* A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a
|
|
12
|
+
* cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its
|
|
13
|
+
* second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the
|
|
14
|
+
* result's name.
|
|
15
|
+
*/
|
|
16
|
+
declare function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal
|
|
19
|
+
* noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to
|
|
20
|
+
* its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.
|
|
21
|
+
* Returns the result's name.
|
|
22
|
+
*/
|
|
23
|
+
declare function textureFilter(filter: FilterBuilder, effect: TextureEffect, input: string): string;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { noiseDensityTable, noiseFilter, textureFilter };
|
|
26
|
+
//# sourceMappingURL=grain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grain.d.ts","names":[],"sources":["../../../../src/io/formats/svg/grain.ts"],"mappings":";;;;;;;;iBA6BgB,kBAAkB,iBAAiB;;;;;;;iBAgBnC,YAAY,QAAQ,eAAe,QAAQ,aAAa;;;;;;;iBA0ExD,cAAc,QAAQ,eAAe,QAAQ,eAAe"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { svg } from "./node.js";
|
|
2
|
+
import { round } from "./paths.js";
|
|
3
|
+
import { floodColor } from "./filter.js";
|
|
4
|
+
//#region src/io/formats/svg/grain.ts
|
|
5
|
+
/** How many steps the discrete alpha table of a noise has, as Figma writes it. */
|
|
6
|
+
const NOISE_TABLE_STEPS = 100;
|
|
7
|
+
/** Keeps a channel's alpha alone, as each of Figma's grain matrices does somewhere. */
|
|
8
|
+
const ALPHA_ONLY = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0";
|
|
9
|
+
const ALPHA_TO_RED = "0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
|
|
10
|
+
const ALPHA_TO_GREEN = "0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1";
|
|
11
|
+
const OPAQUE = "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 127 0";
|
|
12
|
+
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";
|
|
13
|
+
const RED_TO_ALPHA = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
|
|
14
|
+
/** A grain size as `feTurbulence` frequency, one cycle per grain on each axis. */
|
|
15
|
+
function grainFrequency(size) {
|
|
16
|
+
const frequency = (length) => length > 0 ? round(1 / length, 4) : 0;
|
|
17
|
+
return `${frequency(size.x)} ${frequency(size.y)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes
|
|
21
|
+
* it: a band of ones over the noise's middle tones, one step wide at no density and half the
|
|
22
|
+
* steps at full. Figma works it out in 32-bit floats, as it stores the density.
|
|
23
|
+
*/
|
|
24
|
+
function noiseDensityTable(density, mirrored = false) {
|
|
25
|
+
const stored = Math.fround(density);
|
|
26
|
+
const start = Math.floor(25 - 25 * stored);
|
|
27
|
+
const count = Math.floor(50 * stored) + 1;
|
|
28
|
+
const steps = Array.from({ length: NOISE_TABLE_STEPS }, (_, step) => step >= start && step < start + count ? 1 : 0);
|
|
29
|
+
return (mirrored ? steps.reverse() : steps).join(" ");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a
|
|
33
|
+
* cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its
|
|
34
|
+
* second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the
|
|
35
|
+
* result's name.
|
|
36
|
+
*/
|
|
37
|
+
function noiseFilter(filter, effect, input) {
|
|
38
|
+
const grain = effect.noise;
|
|
39
|
+
const noise = filter.result("noise");
|
|
40
|
+
filter.push("feTurbulence", {
|
|
41
|
+
type: "fractalNoise",
|
|
42
|
+
baseFrequency: grainFrequency(grain.noiseSize),
|
|
43
|
+
stitchTiles: "stitch",
|
|
44
|
+
numOctaves: 3,
|
|
45
|
+
seed: grain.seed ?? 0,
|
|
46
|
+
result: noise
|
|
47
|
+
});
|
|
48
|
+
const merged = filter.result("noiseMerge");
|
|
49
|
+
if (grain.noiseType === "MULTITONE") {
|
|
50
|
+
const colored = filter.result("multitone");
|
|
51
|
+
const linear = {
|
|
52
|
+
type: "linear",
|
|
53
|
+
slope: 2,
|
|
54
|
+
intercept: -.5
|
|
55
|
+
};
|
|
56
|
+
filter.push("feComponentTransfer", {
|
|
57
|
+
in: noise,
|
|
58
|
+
result: colored
|
|
59
|
+
}, svg("feFuncR", linear), svg("feFuncG", linear), svg("feFuncB", linear), svg("feFuncA", {
|
|
60
|
+
type: "discrete",
|
|
61
|
+
tableValues: noiseDensityTable(grain.density)
|
|
62
|
+
}));
|
|
63
|
+
const clipped = filter.result("noiseClipped");
|
|
64
|
+
filter.push("feComposite", {
|
|
65
|
+
in: colored,
|
|
66
|
+
in2: input,
|
|
67
|
+
operator: "in",
|
|
68
|
+
result: clipped
|
|
69
|
+
});
|
|
70
|
+
const faded = filter.result("noiseColor");
|
|
71
|
+
filter.push("feComponentTransfer", {
|
|
72
|
+
in: clipped,
|
|
73
|
+
result: faded
|
|
74
|
+
}, svg("feFuncA", {
|
|
75
|
+
type: "table",
|
|
76
|
+
tableValues: `0 ${round(grain.opacity ?? 1)}`
|
|
77
|
+
}));
|
|
78
|
+
filter.pushElement("feMerge", { result: merged }, mergeNodes([input, faded]));
|
|
79
|
+
return merged;
|
|
80
|
+
}
|
|
81
|
+
const alpha = filter.result("alphaNoise");
|
|
82
|
+
filter.push("feColorMatrix", {
|
|
83
|
+
in: noise,
|
|
84
|
+
type: "luminanceToAlpha",
|
|
85
|
+
result: alpha
|
|
86
|
+
});
|
|
87
|
+
const tones = [{
|
|
88
|
+
color: effect.color,
|
|
89
|
+
mirrored: false
|
|
90
|
+
}];
|
|
91
|
+
if (grain.noiseType === "DUOTONE") tones.push({
|
|
92
|
+
color: grain.secondaryColor ?? effect.color,
|
|
93
|
+
mirrored: true
|
|
94
|
+
});
|
|
95
|
+
const colors = tones.map(({ color, mirrored }) => {
|
|
96
|
+
const band = filter.result("noiseBand");
|
|
97
|
+
filter.push("feComponentTransfer", {
|
|
98
|
+
in: alpha,
|
|
99
|
+
result: band
|
|
100
|
+
}, svg("feFuncA", {
|
|
101
|
+
type: "discrete",
|
|
102
|
+
tableValues: noiseDensityTable(grain.density, mirrored)
|
|
103
|
+
}));
|
|
104
|
+
const clipped = filter.result("noiseClipped");
|
|
105
|
+
filter.push("feComposite", {
|
|
106
|
+
in: band,
|
|
107
|
+
in2: input,
|
|
108
|
+
operator: "in",
|
|
109
|
+
result: clipped
|
|
110
|
+
});
|
|
111
|
+
const flood = filter.result("noiseFlood");
|
|
112
|
+
filter.push("feFlood", {
|
|
113
|
+
"flood-color": floodColor(color, filter.colorSpace),
|
|
114
|
+
"flood-opacity": round(color.a),
|
|
115
|
+
result: flood
|
|
116
|
+
});
|
|
117
|
+
const colored = filter.result("noiseColor");
|
|
118
|
+
filter.push("feComposite", {
|
|
119
|
+
in: flood,
|
|
120
|
+
in2: clipped,
|
|
121
|
+
operator: "in",
|
|
122
|
+
result: colored
|
|
123
|
+
});
|
|
124
|
+
return colored;
|
|
125
|
+
});
|
|
126
|
+
filter.pushElement("feMerge", { result: merged }, mergeNodes([input, ...colors]));
|
|
127
|
+
return merged;
|
|
128
|
+
}
|
|
129
|
+
function mergeNodes(inputs) {
|
|
130
|
+
return inputs.map((input) => svg("feMergeNode", { in: input }));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal
|
|
134
|
+
* noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to
|
|
135
|
+
* its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.
|
|
136
|
+
* Returns the result's name.
|
|
137
|
+
*/
|
|
138
|
+
function textureFilter(filter, effect, input) {
|
|
139
|
+
const grain = effect.texture;
|
|
140
|
+
const frequency = grainFrequency(grain.noiseSize);
|
|
141
|
+
const scale = round(effect.radius * 2);
|
|
142
|
+
const name = (label) => filter.result(label);
|
|
143
|
+
const displace = (into, by, result) => filter.push("feDisplacementMap", {
|
|
144
|
+
in: into,
|
|
145
|
+
in2: by,
|
|
146
|
+
scale,
|
|
147
|
+
xChannelSelector: "R",
|
|
148
|
+
yChannelSelector: "G",
|
|
149
|
+
width: "100%",
|
|
150
|
+
height: "100%",
|
|
151
|
+
result
|
|
152
|
+
});
|
|
153
|
+
const turbulence = (seed, result) => filter.push("feTurbulence", {
|
|
154
|
+
type: "fractalNoise",
|
|
155
|
+
baseFrequency: frequency,
|
|
156
|
+
numOctaves: 3,
|
|
157
|
+
seed: (grain.seed ?? 0) + seed,
|
|
158
|
+
result
|
|
159
|
+
});
|
|
160
|
+
const matrix = (into, values, result) => filter.push("feColorMatrix", {
|
|
161
|
+
in: into,
|
|
162
|
+
type: "matrix",
|
|
163
|
+
values,
|
|
164
|
+
result
|
|
165
|
+
});
|
|
166
|
+
const arithmetic = (into, by, k, result) => filter.push("feComposite", {
|
|
167
|
+
in: into,
|
|
168
|
+
in2: by,
|
|
169
|
+
operator: "arithmetic",
|
|
170
|
+
k1: k[0],
|
|
171
|
+
k2: k[1],
|
|
172
|
+
k3: k[2],
|
|
173
|
+
k4: k[3],
|
|
174
|
+
result
|
|
175
|
+
});
|
|
176
|
+
const composite = (into, by, operator, result) => filter.push("feComposite", {
|
|
177
|
+
in: into,
|
|
178
|
+
in2: by,
|
|
179
|
+
operator,
|
|
180
|
+
result
|
|
181
|
+
});
|
|
182
|
+
const gamma = (into, result) => filter.push("feComponentTransfer", {
|
|
183
|
+
in: into,
|
|
184
|
+
result
|
|
185
|
+
}, svg("feFuncA", {
|
|
186
|
+
type: "gamma",
|
|
187
|
+
exponent: .2
|
|
188
|
+
}));
|
|
189
|
+
if (!grain.clipToShape) {
|
|
190
|
+
const noise = name("textureNoise");
|
|
191
|
+
turbulence(0, noise);
|
|
192
|
+
const displaced = name("texture");
|
|
193
|
+
displace(input, noise, displaced);
|
|
194
|
+
return displaced;
|
|
195
|
+
}
|
|
196
|
+
const noiseX = name("displacementX");
|
|
197
|
+
const noiseY = name("displacementY");
|
|
198
|
+
turbulence(0, noiseX);
|
|
199
|
+
turbulence(1, noiseY);
|
|
200
|
+
const xRed = name("displacementXRed");
|
|
201
|
+
matrix(noiseX, ALPHA_TO_RED, xRed);
|
|
202
|
+
const yGreen = name("displacementYGreen");
|
|
203
|
+
matrix(noiseY, ALPHA_TO_GREEN, yGreen);
|
|
204
|
+
const xy = name("displacementXY");
|
|
205
|
+
arithmetic(xRed, yGreen, [
|
|
206
|
+
0,
|
|
207
|
+
1,
|
|
208
|
+
1,
|
|
209
|
+
0
|
|
210
|
+
], xy);
|
|
211
|
+
const firstPass = name("firstPass");
|
|
212
|
+
displace(input, xy, firstPass);
|
|
213
|
+
const firstAlpha = name("firstPassAlpha");
|
|
214
|
+
matrix(firstPass, ALPHA_ONLY, firstAlpha);
|
|
215
|
+
const displacedAlpha = name("sourceDisplacedAlpha");
|
|
216
|
+
gamma(firstAlpha, displacedAlpha);
|
|
217
|
+
const inputAlphaOnly = name("inputAlphaOnly");
|
|
218
|
+
matrix(input, ALPHA_ONLY, inputAlphaOnly);
|
|
219
|
+
const inputAlpha = name("inputSourceAlpha");
|
|
220
|
+
gamma(inputAlphaOnly, inputAlpha);
|
|
221
|
+
const alphas = name("displacementAlphasMultiplied");
|
|
222
|
+
arithmetic(displacedAlpha, inputAlpha, [
|
|
223
|
+
1,
|
|
224
|
+
0,
|
|
225
|
+
0,
|
|
226
|
+
0
|
|
227
|
+
], alphas);
|
|
228
|
+
const centering = name("centeringAdjustment");
|
|
229
|
+
arithmetic(alphas, alphas, [
|
|
230
|
+
0,
|
|
231
|
+
0,
|
|
232
|
+
-.5,
|
|
233
|
+
.5
|
|
234
|
+
], centering);
|
|
235
|
+
const finalChannel = (noise, values, label) => {
|
|
236
|
+
const weighted = name(`${label}Weighted`);
|
|
237
|
+
arithmetic(noise, alphas, [
|
|
238
|
+
1,
|
|
239
|
+
0,
|
|
240
|
+
0,
|
|
241
|
+
0
|
|
242
|
+
], weighted);
|
|
243
|
+
const centered = name(`${label}Centered`);
|
|
244
|
+
arithmetic(centering, weighted, [
|
|
245
|
+
0,
|
|
246
|
+
1,
|
|
247
|
+
1,
|
|
248
|
+
0
|
|
249
|
+
], centered);
|
|
250
|
+
const final = name(`${label}Final`);
|
|
251
|
+
matrix(centered, values, final);
|
|
252
|
+
return final;
|
|
253
|
+
};
|
|
254
|
+
const xFinal = finalChannel(noiseX, ALPHA_TO_RED, "displacementX");
|
|
255
|
+
const yFinal = finalChannel(noiseY, ALPHA_TO_GREEN, "displacementY");
|
|
256
|
+
const combined = name("displacementCombined");
|
|
257
|
+
arithmetic(xFinal, yFinal, [
|
|
258
|
+
0,
|
|
259
|
+
1,
|
|
260
|
+
1,
|
|
261
|
+
0
|
|
262
|
+
], combined);
|
|
263
|
+
const map = name("displacementMap");
|
|
264
|
+
composite(combined, alphas, "in", map);
|
|
265
|
+
const neutral = name("neutral");
|
|
266
|
+
filter.push("feFlood", {
|
|
267
|
+
"flood-color": "rgb(127, 127, 127)",
|
|
268
|
+
"flood-opacity": 1,
|
|
269
|
+
result: neutral
|
|
270
|
+
});
|
|
271
|
+
const outside = name("neutralOutside");
|
|
272
|
+
composite(neutral, alphas, "out", outside);
|
|
273
|
+
const mapWithBackground = name("displacementMapWithBg");
|
|
274
|
+
composite(outside, map, "over", mapWithBackground);
|
|
275
|
+
const displaced = name("displacedImage");
|
|
276
|
+
displace(input, mapWithBackground, displaced);
|
|
277
|
+
const opaque = name("imageOpaque");
|
|
278
|
+
matrix(input, OPAQUE, opaque);
|
|
279
|
+
const displacedOpaque = name("displacedImageOpaque");
|
|
280
|
+
displace(opaque, mapWithBackground, displacedOpaque);
|
|
281
|
+
const displacedRed = name("displacedImageRed");
|
|
282
|
+
matrix(displaced, ALPHA_TO_RED_OPAQUE, displacedRed);
|
|
283
|
+
const inputRed = name("inputRed");
|
|
284
|
+
matrix(input, ALPHA_TO_RED_OPAQUE, inputRed);
|
|
285
|
+
const transparencyRed = name("transparencyRedMap");
|
|
286
|
+
composite(displacedRed, inputRed, "atop", transparencyRed);
|
|
287
|
+
const transparency = name("transparencyAlphaMap");
|
|
288
|
+
matrix(transparencyRed, RED_TO_ALPHA, transparency);
|
|
289
|
+
const layered = name("textureLayered");
|
|
290
|
+
composite(displacedOpaque, opaque, "over", layered);
|
|
291
|
+
const textured = name("texture");
|
|
292
|
+
composite(layered, transparency, "in", textured);
|
|
293
|
+
return textured;
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { noiseDensityTable, noiseFilter, textureFilter };
|
|
297
|
+
|
|
298
|
+
//# sourceMappingURL=grain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grain.js","names":[],"sources":["../../../../src/io/formats/svg/grain.ts"],"sourcesContent":["import type { NoiseEffect, TextureEffect } from '@pairdraw/scene-graph'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { floodColor, type FilterBuilder } from './filter'\nimport { svg } from './node'\nimport { round } from './paths'\n\n/** How many steps the discrete alpha table of a noise has, as Figma writes it. */\nconst NOISE_TABLE_STEPS = 100\n\n/** Keeps a channel's alpha alone, as each of Figma's grain matrices does somewhere. */\nconst ALPHA_ONLY = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'\nconst ALPHA_TO_RED = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1'\nconst ALPHA_TO_GREEN = '0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1'\nconst OPAQUE = '1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 127 0'\nconst ALPHA_TO_RED_OPAQUE = '0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'\nconst RED_TO_ALPHA = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'\n\n/** A grain size as `feTurbulence` frequency, one cycle per grain on each axis. */\nfunction grainFrequency(size: Vector): string {\n const frequency = (length: number) => (length > 0 ? round(1 / length, 4) : 0)\n return `${frequency(size.x)} ${frequency(size.y)}`\n}\n\n/**\n * The discrete alpha table that shows a noise's grains at `density`, as Figma's SVG export writes\n * it: a band of ones over the noise's middle tones, one step wide at no density and half the\n * steps at full. Figma works it out in 32-bit floats, as it stores the density.\n */\nexport function noiseDensityTable(density: number, mirrored = false): string {\n const stored = Math.fround(density)\n const start = Math.floor(25 - 25 * stored)\n const count = Math.floor(50 * stored) + 1\n const steps = Array.from({ length: NOISE_TABLE_STEPS }, (_, step) =>\n step >= start && step < start + count ? 1 : 0\n )\n return (mirrored ? steps.reverse() : steps).join(' ')\n}\n\n/**\n * A noise effect over `input` as Figma's SVG export draws it: fractal noise one grain to a\n * cycle, its middle tones shown in the effect's colour, a duotone's opposite tones in its\n * second colour, and a multitone's own colours at its opacity, all inside the layer. Returns the\n * result's name.\n */\nexport function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: string): string {\n const grain = effect.noise\n const noise = filter.result('noise')\n filter.push('feTurbulence', {\n type: 'fractalNoise',\n baseFrequency: grainFrequency(grain.noiseSize),\n stitchTiles: 'stitch',\n numOctaves: 3,\n seed: grain.seed ?? 0,\n result: noise\n })\n const merged = filter.result('noiseMerge')\n if (grain.noiseType === 'MULTITONE') {\n const colored = filter.result('multitone')\n const linear = { type: 'linear', slope: 2, intercept: -0.5 }\n filter.push(\n 'feComponentTransfer',\n { in: noise, result: colored },\n svg('feFuncR', linear),\n svg('feFuncG', linear),\n svg('feFuncB', linear),\n svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density) })\n )\n const clipped = filter.result('noiseClipped')\n filter.push('feComposite', { in: colored, in2: input, operator: 'in', result: clipped })\n const faded = filter.result('noiseColor')\n filter.push(\n 'feComponentTransfer',\n { in: clipped, result: faded },\n svg('feFuncA', { type: 'table', tableValues: `0 ${round(grain.opacity ?? 1)}` })\n )\n filter.pushElement('feMerge', { result: merged }, mergeNodes([input, faded]))\n return merged\n }\n\n const alpha = filter.result('alphaNoise')\n filter.push('feColorMatrix', { in: noise, type: 'luminanceToAlpha', result: alpha })\n const tones = [{ color: effect.color, mirrored: false }]\n if (grain.noiseType === 'DUOTONE') {\n tones.push({ color: grain.secondaryColor ?? effect.color, mirrored: true })\n }\n const colors = tones.map(({ color, mirrored }) => {\n const band = filter.result('noiseBand')\n filter.push(\n 'feComponentTransfer',\n { in: alpha, result: band },\n svg('feFuncA', { type: 'discrete', tableValues: noiseDensityTable(grain.density, mirrored) })\n )\n const clipped = filter.result('noiseClipped')\n filter.push('feComposite', { in: band, in2: input, operator: 'in', result: clipped })\n const flood = filter.result('noiseFlood')\n filter.push('feFlood', {\n 'flood-color': floodColor(color, filter.colorSpace),\n 'flood-opacity': round(color.a),\n result: flood\n })\n const colored = filter.result('noiseColor')\n filter.push('feComposite', { in: flood, in2: clipped, operator: 'in', result: colored })\n return colored\n })\n filter.pushElement('feMerge', { result: merged }, mergeNodes([input, ...colors]))\n return merged\n}\n\nfunction mergeNodes(inputs: readonly string[]) {\n return inputs.map((input) => svg('feMergeNode', { in: input }))\n}\n\n/**\n * A texture effect over `input` as Figma's SVG export draws it: the layer displaced by fractal\n * noise one grain to a cycle, twice the radius at most. Without clipping that is all; clipped to\n * its shape, Figma's chain moves only the layer's inside and keeps it within its own outline.\n * Returns the result's name.\n */\nexport function textureFilter(filter: FilterBuilder, effect: TextureEffect, input: string): string {\n const grain = effect.texture\n const frequency = grainFrequency(grain.noiseSize)\n const scale = round(effect.radius * 2)\n const name = (label: string) => filter.result(label)\n const displace = (into: string, by: string, result: string) =>\n filter.push('feDisplacementMap', {\n in: into,\n in2: by,\n scale,\n xChannelSelector: 'R',\n yChannelSelector: 'G',\n width: '100%',\n height: '100%',\n result\n })\n const turbulence = (seed: number, result: string) =>\n filter.push('feTurbulence', {\n type: 'fractalNoise',\n baseFrequency: frequency,\n numOctaves: 3,\n seed: (grain.seed ?? 0) + seed,\n result\n })\n const matrix = (into: string, values: string, result: string) =>\n filter.push('feColorMatrix', { in: into, type: 'matrix', values, result })\n const arithmetic = (\n into: string,\n by: string,\n k: [number, number, number, number],\n result: string\n ) =>\n filter.push('feComposite', {\n in: into,\n in2: by,\n operator: 'arithmetic',\n k1: k[0],\n k2: k[1],\n k3: k[2],\n k4: k[3],\n result\n })\n const composite = (into: string, by: string, operator: string, result: string) =>\n filter.push('feComposite', { in: into, in2: by, operator, result })\n const gamma = (into: string, result: string) =>\n filter.push(\n 'feComponentTransfer',\n { in: into, result },\n svg('feFuncA', { type: 'gamma', exponent: 0.2 })\n )\n\n if (!grain.clipToShape) {\n const noise = name('textureNoise')\n turbulence(0, noise)\n const displaced = name('texture')\n displace(input, noise, displaced)\n return displaced\n }\n\n const noiseX = name('displacementX')\n const noiseY = name('displacementY')\n turbulence(0, noiseX)\n turbulence(1, noiseY)\n const xRed = name('displacementXRed')\n matrix(noiseX, ALPHA_TO_RED, xRed)\n const yGreen = name('displacementYGreen')\n matrix(noiseY, ALPHA_TO_GREEN, yGreen)\n const xy = name('displacementXY')\n arithmetic(xRed, yGreen, [0, 1, 1, 0], xy)\n const firstPass = name('firstPass')\n displace(input, xy, firstPass)\n const firstAlpha = name('firstPassAlpha')\n matrix(firstPass, ALPHA_ONLY, firstAlpha)\n const displacedAlpha = name('sourceDisplacedAlpha')\n gamma(firstAlpha, displacedAlpha)\n const inputAlphaOnly = name('inputAlphaOnly')\n matrix(input, ALPHA_ONLY, inputAlphaOnly)\n const inputAlpha = name('inputSourceAlpha')\n gamma(inputAlphaOnly, inputAlpha)\n const alphas = name('displacementAlphasMultiplied')\n arithmetic(displacedAlpha, inputAlpha, [1, 0, 0, 0], alphas)\n const centering = name('centeringAdjustment')\n arithmetic(alphas, alphas, [0, 0, -0.5, 0.5], centering)\n\n const finalChannel = (noise: string, values: string, label: string) => {\n const weighted = name(`${label}Weighted`)\n arithmetic(noise, alphas, [1, 0, 0, 0], weighted)\n const centered = name(`${label}Centered`)\n arithmetic(centering, weighted, [0, 1, 1, 0], centered)\n const final = name(`${label}Final`)\n matrix(centered, values, final)\n return final\n }\n const xFinal = finalChannel(noiseX, ALPHA_TO_RED, 'displacementX')\n const yFinal = finalChannel(noiseY, ALPHA_TO_GREEN, 'displacementY')\n const combined = name('displacementCombined')\n arithmetic(xFinal, yFinal, [0, 1, 1, 0], combined)\n const map = name('displacementMap')\n composite(combined, alphas, 'in', map)\n const neutral = name('neutral')\n filter.push('feFlood', {\n 'flood-color': 'rgb(127, 127, 127)',\n 'flood-opacity': 1,\n result: neutral\n })\n const outside = name('neutralOutside')\n composite(neutral, alphas, 'out', outside)\n const mapWithBackground = name('displacementMapWithBg')\n composite(outside, map, 'over', mapWithBackground)\n\n const displaced = name('displacedImage')\n displace(input, mapWithBackground, displaced)\n const opaque = name('imageOpaque')\n matrix(input, OPAQUE, opaque)\n const displacedOpaque = name('displacedImageOpaque')\n displace(opaque, mapWithBackground, displacedOpaque)\n const displacedRed = name('displacedImageRed')\n matrix(displaced, ALPHA_TO_RED_OPAQUE, displacedRed)\n const inputRed = name('inputRed')\n matrix(input, ALPHA_TO_RED_OPAQUE, inputRed)\n const transparencyRed = name('transparencyRedMap')\n composite(displacedRed, inputRed, 'atop', transparencyRed)\n const transparency = name('transparencyAlphaMap')\n matrix(transparencyRed, RED_TO_ALPHA, transparency)\n const layered = name('textureLayered')\n composite(displacedOpaque, opaque, 'over', layered)\n const textured = name('texture')\n composite(layered, transparency, 'in', textured)\n return textured\n}\n"],"mappings":"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"}
|
|
@@ -9,7 +9,7 @@ declare function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Str
|
|
|
9
9
|
* A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its
|
|
10
10
|
* weight and clipped to the outline, or to everything around it.
|
|
11
11
|
*/
|
|
12
|
-
declare function alignedStrokeElement(node: SceneNode, stroke: Stroke, strokeAttrs: Attrs, ctx: SVGExportContext): SVGNode[];
|
|
12
|
+
declare function alignedStrokeElement(node: SceneNode, stroke: Stroke, strokeAttrs: Attrs, ctx: SVGExportContext, outline?: string | null): SVGNode[];
|
|
13
13
|
/**
|
|
14
14
|
* A FigJam shape's inner lines, such as a database's front rim, stroked as the canvas strokes
|
|
15
15
|
* them: at the stroke's own weight whatever its alignment, ending where the outline does.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;KAaK,QAAQ;;iBA0BG,cAAc,MAAM,WAAW,QAAQ,qBAAqB;;;;;iBAS5D,qBACd,MAAM,WACN,QAAQ,QACR,aAAa,OACb,KAAK,
|
|
1
|
+
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;KAaK,QAAQ;;iBA0BG,cAAc,MAAM,WAAW,QAAQ,qBAAqB;;;;;iBAS5D,qBACd,MAAM,WACN,QAAQ,QACR,aAAa,OACb,KAAK,kBACL,0BACC;;;;;iBAiCa,4BACd,MAAM,WACN,aAAa,OACb,KAAK,mBACJ"}
|
|
@@ -28,8 +28,7 @@ function alignedStroke(node, stroke) {
|
|
|
28
28
|
* A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its
|
|
29
29
|
* weight and clipped to the outline, or to everything around it.
|
|
30
30
|
*/
|
|
31
|
-
function alignedStrokeElement(node, stroke, strokeAttrs, ctx) {
|
|
32
|
-
const outline = closedOutlinePath(node);
|
|
31
|
+
function alignedStrokeElement(node, stroke, strokeAttrs, ctx, outline = closedOutlinePath(node)) {
|
|
33
32
|
if (outline === null) return [];
|
|
34
33
|
const clipId = nextDefId(ctx, "clip");
|
|
35
34
|
if (stroke.align === "INSIDE") ctx.defs.push(svg("clipPath", { id: clipId }, svg("path", { d: outline })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {\n boxOutlinePath,\n nodeOutlinePath,\n round,\n shapeWithTextDetailsPath,\n shapeWithTextOutlinePath\n} from './paths'\n\ntype Attrs = Record<string, string | number | undefined>\n\n/**\n * The closed outline an aligned stroke follows, as path data in the layer's box: a FigJam shape's,\n * an ellipse, polygon or star, or a box with its corners for any other layer. Null for lines,\n * arcs, and vectors, whose strokes the canvas centres on their paths.\n */\nfunction closedOutlinePath(node: SceneNode): string | null {\n switch (node.type) {\n case 'LINE':\n case 'VECTOR':\n case 'BOOLEAN_OPERATION':\n return null\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextOutlinePath(node)\n case 'ELLIPSE':\n return node.arcData ? null : nodeOutlinePath(node)\n case 'POLYGON':\n case 'STAR':\n return nodeOutlinePath(node)\n default:\n return boxOutlinePath(node)\n }\n}\n\n/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */\nexport function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Stroke | null {\n if (!stroke || stroke.align === 'CENTER') return null\n return closedOutlinePath(node) === null ? null : stroke\n}\n\n/**\n * A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its\n * weight and clipped to the outline, or to everything around it.\n */\nexport function alignedStrokeElement(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n
|
|
1
|
+
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {\n boxOutlinePath,\n nodeOutlinePath,\n round,\n shapeWithTextDetailsPath,\n shapeWithTextOutlinePath\n} from './paths'\n\ntype Attrs = Record<string, string | number | undefined>\n\n/**\n * The closed outline an aligned stroke follows, as path data in the layer's box: a FigJam shape's,\n * an ellipse, polygon or star, or a box with its corners for any other layer. Null for lines,\n * arcs, and vectors, whose strokes the canvas centres on their paths.\n */\nfunction closedOutlinePath(node: SceneNode): string | null {\n switch (node.type) {\n case 'LINE':\n case 'VECTOR':\n case 'BOOLEAN_OPERATION':\n return null\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextOutlinePath(node)\n case 'ELLIPSE':\n return node.arcData ? null : nodeOutlinePath(node)\n case 'POLYGON':\n case 'STAR':\n return nodeOutlinePath(node)\n default:\n return boxOutlinePath(node)\n }\n}\n\n/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */\nexport function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Stroke | null {\n if (!stroke || stroke.align === 'CENTER') return null\n return closedOutlinePath(node) === null ? null : stroke\n}\n\n/**\n * A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its\n * weight and clipped to the outline, or to everything around it.\n */\nexport function alignedStrokeElement(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Attrs,\n ctx: SVGExportContext,\n outline = closedOutlinePath(node)\n): SVGNode[] {\n if (outline === null) return []\n const clipId = nextDefId(ctx, 'clip')\n if (stroke.align === 'INSIDE') {\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: outline })))\n } else {\n // A box wide enough for the stroke, its mitred tips included, with the outline cut out of it.\n // The doubled stroke mitres out to its weight times the miter limit.\n const margin = stroke.weight * Math.max(2, node.strokeMiterLimit)\n const left = round(-margin)\n const top = round(-margin)\n const right = round(node.width + margin)\n const bottom = round(node.height + margin)\n const around = `M${left} ${top}H${right}V${bottom}H${left}Z`\n ctx.defs.push(\n svg('clipPath', { id: clipId }, svg('path', { d: around + outline, 'clip-rule': 'evenodd' }))\n )\n }\n return [\n svg('path', {\n d: outline,\n fill: 'none',\n ...strokeAttrs,\n 'stroke-width': round(stroke.weight * 2),\n 'clip-path': `url(#${clipId})`\n })\n ]\n}\n\n/**\n * A FigJam shape's inner lines, such as a database's front rim, stroked as the canvas strokes\n * them: at the stroke's own weight whatever its alignment, ending where the outline does.\n */\nexport function shapeWithTextDetailElements(\n node: SceneNode,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n const details = strokeAttrs.stroke ? shapeWithTextDetailsPath(node) : null\n if (!details) return []\n const clipId = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: shapeWithTextOutlinePath(node) })))\n return [svg('path', { d: details, fill: 'none', ...strokeAttrs, 'clip-path': `url(#${clipId})` })]\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAS,kBAAkB,MAAgC;CACzD,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK,qBACH,OAAO;EACT,KAAK,mBACH,OAAO,yBAAyB,IAAI;EACtC,KAAK,WACH,OAAO,KAAK,UAAU,OAAO,gBAAgB,IAAI;EACnD,KAAK;EACL,KAAK,QACH,OAAO,gBAAgB,IAAI;EAC7B,SACE,OAAO,eAAe,IAAI;CAC9B;AACF;;AAGA,SAAgB,cAAc,MAAiB,QAA2C;CACxF,IAAI,CAAC,UAAU,OAAO,UAAU,UAAU,OAAO;CACjD,OAAO,kBAAkB,IAAI,MAAM,OAAO,OAAO;AACnD;;;;;AAMA,SAAgB,qBACd,MACA,QACA,aACA,KACA,UAAU,kBAAkB,IAAI,GACrB;CACX,IAAI,YAAY,MAAM,OAAO,CAAC;CAC9B,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,OAAO,UAAU,UACnB,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;MACrE;EAGL,MAAM,SAAS,OAAO,SAAS,KAAK,IAAI,GAAG,KAAK,gBAAgB;EAChE,MAAM,OAAO,MAAM,CAAC,MAAM;EAI1B,MAAM,SAAS,IAAI,KAAK,GAHZ,MAAM,CAAC,MAGU,EAAE,GAFjB,MAAM,KAAK,QAAQ,MAEK,EAAE,GADzB,MAAM,KAAK,SAAS,MACa,EAAE,GAAG,KAAK;EAC1D,IAAI,KAAK,KACP,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ;GAAE,GAAG,SAAS;GAAS,aAAa;EAAU,CAAC,CAAC,CAC9F;CACF;CACA,OAAO,CACL,IAAI,QAAQ;EACV,GAAG;EACH,MAAM;EACN,GAAG;EACH,gBAAgB,MAAM,OAAO,SAAS,CAAC;EACvC,aAAa,QAAQ,OAAO;CAC9B,CAAC,CACH;AACF;;;;;AAMA,SAAgB,4BACd,MACA,aACA,KACW;CACX,MAAM,UAAU,YAAY,SAAS,yBAAyB,IAAI,IAAI;CACtE,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,yBAAyB,IAAI,EAAE,CAAC,CAAC,CAAC;CACjG,OAAO,CAAC,IAAI,QAAQ;EAAE,GAAG;EAAS,MAAM;EAAQ,GAAG;EAAa,aAAa,QAAQ,OAAO;CAAG,CAAC,CAAC;AACnG"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { measureTextForLayout } from "../../../../layout/text-measurement.js";
|
|
2
2
|
import { localTransformFromWorld } from "@pairdraw/scene-graph/coordinate";
|
|
3
|
+
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
3
4
|
import { pixelLength } from "@pairdraw/scene-graph/text";
|
|
4
5
|
import { faceLoadKey } from "@pairdraw/scene-graph/font-style";
|
|
5
|
-
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
6
6
|
import { textLayerName } from "@pairdraw/scene-graph/node-defaults";
|
|
7
7
|
import { isEqual } from "es-toolkit/predicate";
|
|
8
8
|
//#region src/io/formats/svg/text/import.ts
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { SkiaRenderer } from "../../../../canvas/renderer.js";
|
|
1
2
|
import { SVGExportOptions } from "../export.js";
|
|
3
|
+
import { CanvasKit } from "canvaskit-wasm";
|
|
2
4
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
3
5
|
//#region src/io/formats/svg/text/layout.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each
|
|
6
8
|
* line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export
|
|
7
|
-
* sets them.
|
|
9
|
+
* sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so
|
|
10
|
+
* the pattern embeds the adjusted pixels.
|
|
8
11
|
*/
|
|
9
|
-
declare function renderNodesToLaidOutSVG(graph: SceneGraph, pageId: string, nodeIds: string[], options?: SVGExportOptions): Promise<string | null>;
|
|
12
|
+
declare function renderNodesToLaidOutSVG(graph: SceneGraph, pageId: string, nodeIds: string[], options?: SVGExportOptions, canvasKit?: CanvasKit, renderer?: SkiaRenderer): Promise<string | null>;
|
|
10
13
|
//#endregion
|
|
11
14
|
export { renderNodesToLaidOutSVG };
|
|
12
15
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"layout.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"mappings":";;;;;;;;;;;iBAgBsB,wBACpB,OAAO,YACP,gBACA,mBACA,UAAS,kBACT,YAAY,WACZ,WAAW,eACV"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { prepareGraphFonts } from "../../../../text/prepare.js";
|
|
2
2
|
import { renderNodesToSVG } from "../export.js";
|
|
3
3
|
import { withPDFTextLayout } from "../../pdf/prepare.js";
|
|
4
|
+
import { bakeAdjustedImages, hasAdjustedImagePaints } from "../../raster/adjusted-images.js";
|
|
4
5
|
//#region src/io/formats/svg/text/layout.ts
|
|
5
6
|
/**
|
|
6
7
|
* Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each
|
|
7
8
|
* line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export
|
|
8
|
-
* sets them.
|
|
9
|
+
* sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so
|
|
10
|
+
* the pattern embeds the adjusted pixels.
|
|
9
11
|
*/
|
|
10
|
-
async function renderNodesToLaidOutSVG(graph, pageId, nodeIds, options = {}) {
|
|
12
|
+
async function renderNodesToLaidOutSVG(graph, pageId, nodeIds, options = {}, canvasKit, renderer) {
|
|
11
13
|
await prepareGraphFonts(graph, nodeIds);
|
|
12
|
-
|
|
14
|
+
const baked = hasAdjustedImagePaints(graph, nodeIds) ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer) : graph;
|
|
15
|
+
return withPDFTextLayout(async (textLayout) => renderNodesToSVG(baked, pageId, nodeIds, {
|
|
13
16
|
textLayout,
|
|
14
17
|
...options
|
|
15
18
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { withPDFTextLayout } from '#core/io/formats/pdf/prepare'\nimport { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'\nimport { prepareGraphFonts } from '#core/text/prepare'\n\n/**\n * Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each\n * line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export\n * sets them.\n */\nexport async function renderNodesToLaidOutSVG(\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {}\n): Promise<string | null> {\n await prepareGraphFonts(graph, nodeIds)\n return withPDFTextLayout(async (textLayout) =>\n renderNodesToSVG(
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../../../../src/io/formats/svg/text/layout.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { withPDFTextLayout } from '#core/io/formats/pdf/prepare'\nimport { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'\nimport { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'\nimport { prepareGraphFonts } from '#core/text/prepare'\n\n/**\n * Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each\n * line on the baseline the canvas gives it, and wrapped paragraphs kept wrapped, as PDF export\n * sets them. An image paint with adjustments is baked to the PNG the raster pipeline draws, so\n * the pattern embeds the adjusted pixels.\n */\nexport async function renderNodesToLaidOutSVG(\n graph: SceneGraph,\n pageId: string,\n nodeIds: string[],\n options: SVGExportOptions = {},\n canvasKit?: CanvasKit,\n renderer?: SkiaRenderer\n): Promise<string | null> {\n await prepareGraphFonts(graph, nodeIds)\n const baked = hasAdjustedImagePaints(graph, nodeIds)\n ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)\n : graph\n return withPDFTextLayout(async (textLayout) =>\n renderNodesToSVG(baked, pageId, nodeIds, { textLayout, ...options })\n )\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAsB,wBACpB,OACA,QACA,SACA,UAA4B,CAAC,GAC7B,WACA,UACwB;CACxB,MAAM,kBAAkB,OAAO,OAAO;CACtC,MAAM,QAAQ,uBAAuB,OAAO,OAAO,IAC/C,MAAM,mBAAmB,OAAO,SAAS,WAAW,QAAQ,IAC5D;CACJ,OAAO,kBAAkB,OAAO,eAC9B,iBAAiB,OAAO,QAAQ,SAAS;EAAE;EAAY,GAAG;CAAQ,CAAC,CACrE;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RGBAImage } from "../raster/pixels.js";
|
|
2
|
+
import "../raster/index.js";
|
|
3
|
+
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
4
|
+
//#region src/io/formats/video/composite.d.ts
|
|
5
|
+
/** A frame of one opaque color, such as the page behind the played frame. */
|
|
6
|
+
declare function filledImage(width: number, height: number, color: Color): RGBAImage;
|
|
7
|
+
/**
|
|
8
|
+
* Draws `source` over `target` with its top-left corner at `x`, `y` in whole pixels, as a layer
|
|
9
|
+
* paints over what is under it; what falls outside `target` is clipped.
|
|
10
|
+
*/
|
|
11
|
+
declare function drawOver(target: RGBAImage, source: RGBAImage, x: number, y: number): void;
|
|
12
|
+
/** Darkens `target` toward black by `amount`, as the scrim under an overlay does. */
|
|
13
|
+
declare function dim(target: RGBAImage, amount: number): void;
|
|
14
|
+
/** A frame `mix` of the way from `from` to `to`, as a crossfade's opacity draws it. */
|
|
15
|
+
declare function crossfade(from: RGBAImage, to: RGBAImage, mix: number): RGBAImage;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { crossfade, dim, drawOver, filledImage };
|
|
18
|
+
//# sourceMappingURL=composite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite.d.ts","names":[],"sources":["../../../../src/io/formats/video/composite.ts"],"mappings":";;;;;iBAKgB,YAAY,eAAe,gBAAgB,OAAO,QAAQ;;;;;iBAkB1D,SAAS,QAAQ,WAAW,QAAQ,WAAW,WAAW;;iBAkC1D,IAAI,QAAQ,WAAW;;iBAWvB,UAAU,MAAM,WAAW,IAAI,WAAW,cAAc"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//#region src/io/formats/video/composite.ts
|
|
2
|
+
/** A frame of one opaque color, such as the page behind the played frame. */
|
|
3
|
+
function filledImage(width, height, color) {
|
|
4
|
+
const data = new Uint8Array(width * height * 4);
|
|
5
|
+
const r = Math.round(color.r * 255);
|
|
6
|
+
const g = Math.round(color.g * 255);
|
|
7
|
+
const b = Math.round(color.b * 255);
|
|
8
|
+
for (let index = 0; index < data.length; index += 4) {
|
|
9
|
+
data[index] = r;
|
|
10
|
+
data[index + 1] = g;
|
|
11
|
+
data[index + 2] = b;
|
|
12
|
+
data[index + 3] = 255;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
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
|
+
function drawOver(target, source, x, y) {
|
|
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++) out[to + channel] = Math.round((src[from + channel] * alpha + out[to + channel] * under) / total);
|
|
48
|
+
out[to + 3] = Math.round(total);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Darkens `target` toward black by `amount`, as the scrim under an overlay does. */
|
|
53
|
+
function dim(target, amount) {
|
|
54
|
+
const keep = 1 - amount;
|
|
55
|
+
const data = target.data;
|
|
56
|
+
for (let index = 0; index < data.length; index += 4) {
|
|
57
|
+
data[index] = Math.round(data[index] * keep);
|
|
58
|
+
data[index + 1] = Math.round(data[index + 1] * keep);
|
|
59
|
+
data[index + 2] = Math.round(data[index + 2] * keep);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** A frame `mix` of the way from `from` to `to`, as a crossfade's opacity draws it. */
|
|
63
|
+
function crossfade(from, to, mix) {
|
|
64
|
+
if (mix <= 0) return from;
|
|
65
|
+
if (mix >= 1) return to;
|
|
66
|
+
const data = new Uint8Array(from.data.length);
|
|
67
|
+
const a = from.data;
|
|
68
|
+
const b = to.data;
|
|
69
|
+
for (let index = 0; index < data.length; index++) data[index] = Math.round(a[index] + (b[index] - a[index]) * mix);
|
|
70
|
+
return {
|
|
71
|
+
width: from.width,
|
|
72
|
+
height: from.height,
|
|
73
|
+
data
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { crossfade, dim, drawOver, filledImage };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=composite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite.js","names":[],"sources":["../../../../src/io/formats/video/composite.ts"],"sourcesContent":["import type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { RGBAImage } from '#core/io/formats/raster'\n\n/** A frame of one opaque color, such as the page behind the played frame. */\nexport function filledImage(width: number, height: number, color: Color): RGBAImage {\n const data = new Uint8Array(width * height * 4)\n const r = Math.round(color.r * 255)\n const g = Math.round(color.g * 255)\n const b = Math.round(color.b * 255)\n for (let index = 0; index < data.length; index += 4) {\n data[index] = r\n data[index + 1] = g\n data[index + 2] = b\n data[index + 3] = 255\n }\n return { width, height, data }\n}\n\n/**\n * Draws `source` over `target` with its top-left corner at `x`, `y` in whole pixels, as a layer\n * paints over what is under it; what falls outside `target` is clipped.\n */\nexport function drawOver(target: RGBAImage, source: RGBAImage, x: number, y: number): void {\n const left = Math.max(0, x)\n const top = Math.max(0, y)\n const right = Math.min(target.width, x + source.width)\n const bottom = Math.min(target.height, y + source.height)\n const out = target.data\n const src = source.data\n for (let row = top; row < bottom; row++) {\n let to = (row * target.width + left) * 4\n let from = ((row - y) * source.width + (left - x)) * 4\n for (let column = left; column < right; column++, to += 4, from += 4) {\n const alpha = src[from + 3]\n if (alpha === 0) continue\n if (alpha === 255) {\n out[to] = src[from]\n out[to + 1] = src[from + 1]\n out[to + 2] = src[from + 2]\n out[to + 3] = 255\n continue\n }\n const rest = 255 - alpha\n const under = (out[to + 3] * rest) / 255\n const total = alpha + under\n for (let channel = 0; channel < 3; channel++) {\n out[to + channel] = Math.round(\n (src[from + channel] * alpha + out[to + channel] * under) / total\n )\n }\n out[to + 3] = Math.round(total)\n }\n }\n}\n\n/** Darkens `target` toward black by `amount`, as the scrim under an overlay does. */\nexport function dim(target: RGBAImage, amount: number): void {\n const keep = 1 - amount\n const data = target.data\n for (let index = 0; index < data.length; index += 4) {\n data[index] = Math.round(data[index] * keep)\n data[index + 1] = Math.round(data[index + 1] * keep)\n data[index + 2] = Math.round(data[index + 2] * keep)\n }\n}\n\n/** A frame `mix` of the way from `from` to `to`, as a crossfade's opacity draws it. */\nexport function crossfade(from: RGBAImage, to: RGBAImage, mix: number): RGBAImage {\n if (mix <= 0) return from\n if (mix >= 1) return to\n const data = new Uint8Array(from.data.length)\n const a = from.data\n const b = to.data\n for (let index = 0; index < data.length; index++) {\n data[index] = Math.round(a[index] + (b[index] - a[index]) * mix)\n }\n return { width: from.width, height: from.height, data }\n}\n"],"mappings":";;AAKA,SAAgB,YAAY,OAAe,QAAgB,OAAyB;CAClF,MAAM,OAAO,IAAI,WAAW,QAAQ,SAAS,CAAC;CAC9C,MAAM,IAAI,KAAK,MAAM,MAAM,IAAI,GAAG;CAClC,MAAM,IAAI,KAAK,MAAM,MAAM,IAAI,GAAG;CAClC,MAAM,IAAI,KAAK,MAAM,MAAM,IAAI,GAAG;CAClC,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,KAAK,SAAS;EACd,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK;EAClB,KAAK,QAAQ,KAAK;CACpB;CACA,OAAO;EAAE;EAAO;EAAQ;CAAK;AAC/B;;;;;AAMA,SAAgB,SAAS,QAAmB,QAAmB,GAAW,GAAiB;CACzF,MAAM,OAAO,KAAK,IAAI,GAAG,CAAC;CAC1B,MAAM,MAAM,KAAK,IAAI,GAAG,CAAC;CACzB,MAAM,QAAQ,KAAK,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK;CACrD,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,IAAI,OAAO,MAAM;CACxD,MAAM,MAAM,OAAO;CACnB,MAAM,MAAM,OAAO;CACnB,KAAK,IAAI,MAAM,KAAK,MAAM,QAAQ,OAAO;EACvC,IAAI,MAAM,MAAM,OAAO,QAAQ,QAAQ;EACvC,IAAI,SAAS,MAAM,KAAK,OAAO,SAAS,OAAO,MAAM;EACrD,KAAK,IAAI,SAAS,MAAM,SAAS,OAAO,UAAU,MAAM,GAAG,QAAQ,GAAG;GACpE,MAAM,QAAQ,IAAI,OAAO;GACzB,IAAI,UAAU,GAAG;GACjB,IAAI,UAAU,KAAK;IACjB,IAAI,MAAM,IAAI;IACd,IAAI,KAAK,KAAK,IAAI,OAAO;IACzB,IAAI,KAAK,KAAK,IAAI,OAAO;IACzB,IAAI,KAAK,KAAK;IACd;GACF;GACA,MAAM,OAAO,MAAM;GACnB,MAAM,QAAS,IAAI,KAAK,KAAK,OAAQ;GACrC,MAAM,QAAQ,QAAQ;GACtB,KAAK,IAAI,UAAU,GAAG,UAAU,GAAG,WACjC,IAAI,KAAK,WAAW,KAAK,OACtB,IAAI,OAAO,WAAW,QAAQ,IAAI,KAAK,WAAW,SAAS,KAC9D;GAEF,IAAI,KAAK,KAAK,KAAK,MAAM,KAAK;EAChC;CACF;AACF;;AAGA,SAAgB,IAAI,QAAmB,QAAsB;CAC3D,MAAM,OAAO,IAAI;CACjB,MAAM,OAAO,OAAO;CACpB,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,KAAK,SAAS,KAAK,MAAM,KAAK,SAAS,IAAI;EAC3C,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI;EACnD,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI;CACrD;AACF;;AAGA,SAAgB,UAAU,MAAiB,IAAe,KAAwB;CAChF,IAAI,OAAO,GAAG,OAAO;CACrB,IAAI,OAAO,GAAG,OAAO;CACrB,MAAM,OAAO,IAAI,WAAW,KAAK,KAAK,MAAM;CAC5C,MAAM,IAAI,KAAK;CACf,MAAM,IAAI,GAAG;CACb,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SACvC,KAAK,SAAS,KAAK,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG;CAEjE,OAAO;EAAE,OAAO,KAAK;EAAO,QAAQ,KAAK;EAAQ;CAAK;AACxD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { VideoFormat, VideoSink, VideoSinkOptions } from "./sink.js";
|
|
2
|
+
//#region src/io/formats/video/formats.d.ts
|
|
3
|
+
/** Each format's name as people know it. */
|
|
4
|
+
declare const VIDEO_FORMAT_LABELS: Record<VideoFormat, string>;
|
|
5
|
+
/**
|
|
6
|
+
* An encoder a host passes for the formats WebCodecs cannot encode there, such as the CLI's
|
|
7
|
+
* ffmpeg. It is asked only for MP4 and WebM, after WebCodecs.
|
|
8
|
+
*/
|
|
9
|
+
interface VideoHostEncoder {
|
|
10
|
+
supports(format: VideoFormat): boolean | Promise<boolean>;
|
|
11
|
+
create(format: VideoFormat, options: VideoSinkOptions): Promise<VideoSink>;
|
|
12
|
+
}
|
|
13
|
+
/** A format this engine cannot record at the size and frame rate asked for, and why. */
|
|
14
|
+
declare class VideoFormatError extends Error {
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
/** Whether this engine, or the host's encoder, can record `format` at `width`×`height` and `fps`. */
|
|
18
|
+
declare function canRecordFormat(format: VideoFormat, width: number, height: number, fps: number, host?: VideoHostEncoder | null): Promise<boolean>;
|
|
19
|
+
/** The formats this engine can record at `width`×`height` and `fps`, MP4 first. */
|
|
20
|
+
declare function recordableFormats(width: number, height: number, fps: number, host?: VideoHostEncoder | null): Promise<VideoFormat[]>;
|
|
21
|
+
/**
|
|
22
|
+
* The encoder for `format`: GIF everywhere, MP4 and WebM where WebCodecs (or an encoder registered
|
|
23
|
+
* with mediabunny) can encode them, else through `host`. Throws a `VideoFormatError` naming the
|
|
24
|
+
* formats that do work here.
|
|
25
|
+
*/
|
|
26
|
+
declare function openVideoSink(format: VideoFormat, options: VideoSinkOptions, host?: VideoHostEncoder | null): Promise<VideoSink>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { VIDEO_FORMAT_LABELS, VideoFormatError, VideoHostEncoder, canRecordFormat, openVideoSink, recordableFormats };
|
|
29
|
+
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","names":[],"sources":["../../../../src/io/formats/video/formats.ts"],"mappings":";;;cAKa,qBAAqB,OAAO;;;;;UAUxB;EACf,SAAS,QAAQ,wBAAwB;EACzC,OAAO,QAAQ,aAAa,SAAS,mBAAmB,QAAQ;;;cAIrD,yBAAyB;EAC3B;;;iBAIW,gBACpB,QAAQ,aACR,eACA,gBACA,aACA,OAAO,0BACN;;iBAOmB,kBACpB,eACA,gBACA,aACA,OAAO,0BACN,QAAQ;;;;;;iBAYW,cACpB,QAAQ,aACR,SAAS,kBACT,OAAO,0BACN,QAAQ"}
|