@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,79 @@
|
|
|
1
|
+
import { defineRule } from "../rule.js";
|
|
2
|
+
//#region src/lint/rules/no-unbound-token-values.ts
|
|
3
|
+
const SPACING_FIELDS = [
|
|
4
|
+
"itemSpacing",
|
|
5
|
+
"paddingTop",
|
|
6
|
+
"paddingRight",
|
|
7
|
+
"paddingBottom",
|
|
8
|
+
"paddingLeft"
|
|
9
|
+
];
|
|
10
|
+
const FIELD_LABELS = {
|
|
11
|
+
cornerRadius: "Corner radius",
|
|
12
|
+
itemSpacing: "Gap",
|
|
13
|
+
paddingTop: "Top padding",
|
|
14
|
+
paddingRight: "Right padding",
|
|
15
|
+
paddingBottom: "Bottom padding",
|
|
16
|
+
paddingLeft: "Left padding",
|
|
17
|
+
fontSize: "Font size"
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The fields a layer of this kind sets for itself: spacing only in auto layout, and no font size
|
|
21
|
+
* where a text style supplies it, since the style is where a binding belongs.
|
|
22
|
+
*/
|
|
23
|
+
function fieldsOf(node) {
|
|
24
|
+
if (node.type === "TEXT") return node.textStyleId ? [] : ["fontSize"];
|
|
25
|
+
const fields = ["cornerRadius"];
|
|
26
|
+
if (node.layoutMode !== "NONE") fields.push(...SPACING_FIELDS);
|
|
27
|
+
return fields;
|
|
28
|
+
}
|
|
29
|
+
function bindTo(field, variable) {
|
|
30
|
+
return {
|
|
31
|
+
kind: "bind-variable",
|
|
32
|
+
path: field,
|
|
33
|
+
variableId: variable.id,
|
|
34
|
+
variableName: variable.name
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var no_unbound_token_values_default = defineRule({
|
|
38
|
+
meta: {
|
|
39
|
+
id: "no-unbound-token-values",
|
|
40
|
+
category: "design-tokens",
|
|
41
|
+
description: "Radii, spacing, and font sizes that equal a token should be bound to it"
|
|
42
|
+
},
|
|
43
|
+
match: [
|
|
44
|
+
"RECTANGLE",
|
|
45
|
+
"FRAME",
|
|
46
|
+
"COMPONENT",
|
|
47
|
+
"INSTANCE",
|
|
48
|
+
"TEXT"
|
|
49
|
+
],
|
|
50
|
+
check(node, context) {
|
|
51
|
+
const { numbersByField } = context.variables;
|
|
52
|
+
if (numbersByField.size === 0) return;
|
|
53
|
+
for (const field of fieldsOf(node)) {
|
|
54
|
+
const value = node[field];
|
|
55
|
+
if (value <= 0 || node.boundVariables[field]) continue;
|
|
56
|
+
const matches = numbersByField.get(field)?.get(value) ?? [];
|
|
57
|
+
const only = matches.at(0);
|
|
58
|
+
if (!only) continue;
|
|
59
|
+
const label = FIELD_LABELS[field];
|
|
60
|
+
const names = matches.map((variable) => `"${variable.name}"`).join(", ");
|
|
61
|
+
context.report({
|
|
62
|
+
node,
|
|
63
|
+
message: `${label} ${value} matches token ${names}`,
|
|
64
|
+
suggest: matches.length === 1 ? `Bind ${label.toLowerCase()} to "${only.name}"` : "Bind one token",
|
|
65
|
+
data: {
|
|
66
|
+
field,
|
|
67
|
+
value,
|
|
68
|
+
variableId: only.id,
|
|
69
|
+
variableName: only.name
|
|
70
|
+
},
|
|
71
|
+
...matches.length === 1 ? { fix: bindTo(field, only) } : { suggestions: matches.map((variable) => bindTo(field, variable)) }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//#endregion
|
|
77
|
+
export { no_unbound_token_values_default as default };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=no-unbound-token-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-unbound-token-values.js","names":[],"sources":["../../../src/lint/rules/no-unbound-token-values.ts"],"sourcesContent":["import { defineRule } from '#core/lint/rule'\nimport type { LintFix, LintNode, TokenNumberField } from '#core/lint/types'\n\nconst SPACING_FIELDS = [\n 'itemSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft'\n] as const satisfies readonly TokenNumberField[]\n\nconst FIELD_LABELS: Record<TokenNumberField, string> = {\n cornerRadius: 'Corner radius',\n itemSpacing: 'Gap',\n paddingTop: 'Top padding',\n paddingRight: 'Right padding',\n paddingBottom: 'Bottom padding',\n paddingLeft: 'Left padding',\n fontSize: 'Font size'\n}\n\n/**\n * The fields a layer of this kind sets for itself: spacing only in auto layout, and no font size\n * where a text style supplies it, since the style is where a binding belongs.\n */\nfunction fieldsOf(node: LintNode): TokenNumberField[] {\n if (node.type === 'TEXT') return node.textStyleId ? [] : ['fontSize']\n const fields: TokenNumberField[] = ['cornerRadius']\n if (node.layoutMode !== 'NONE') fields.push(...SPACING_FIELDS)\n return fields\n}\n\nfunction bindTo(field: TokenNumberField, variable: { id: string; name: string }): LintFix {\n return {\n kind: 'bind-variable',\n path: field,\n variableId: variable.id,\n variableName: variable.name\n }\n}\n\nexport default defineRule({\n meta: {\n id: 'no-unbound-token-values',\n category: 'design-tokens',\n description: 'Radii, spacing, and font sizes that equal a token should be bound to it'\n },\n match: ['RECTANGLE', 'FRAME', 'COMPONENT', 'INSTANCE', 'TEXT'],\n check(node, context) {\n const { numbersByField } = context.variables\n if (numbersByField.size === 0) return\n for (const field of fieldsOf(node)) {\n const value = node[field]\n // Zero means \"none\" far more often than it means a token.\n if (value <= 0 || node.boundVariables[field]) continue\n const matches = numbersByField.get(field)?.get(value) ?? []\n const only = matches.at(0)\n if (!only) continue\n const label = FIELD_LABELS[field]\n const names = matches.map((variable) => `\"${variable.name}\"`).join(', ')\n context.report({\n node,\n message: `${label} ${value} matches token ${names}`,\n suggest:\n matches.length === 1 ? `Bind ${label.toLowerCase()} to \"${only.name}\"` : 'Bind one token',\n data: { field, value, variableId: only.id, variableName: only.name },\n ...(matches.length === 1\n ? { fix: bindTo(field, only) }\n : { suggestions: matches.map((variable) => bindTo(field, variable)) })\n })\n }\n }\n})\n"],"mappings":";;AAGA,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,eAAiD;CACrD,cAAc;CACd,aAAa;CACb,YAAY;CACZ,cAAc;CACd,eAAe;CACf,aAAa;CACb,UAAU;AACZ;;;;;AAMA,SAAS,SAAS,MAAoC;CACpD,IAAI,KAAK,SAAS,QAAQ,OAAO,KAAK,cAAc,CAAC,IAAI,CAAC,UAAU;CACpE,MAAM,SAA6B,CAAC,cAAc;CAClD,IAAI,KAAK,eAAe,QAAQ,OAAO,KAAK,GAAG,cAAc;CAC7D,OAAO;AACT;AAEA,SAAS,OAAO,OAAyB,UAAiD;CACxF,OAAO;EACL,MAAM;EACN,MAAM;EACN,YAAY,SAAS;EACrB,cAAc,SAAS;CACzB;AACF;AAEA,IAAA,kCAAe,WAAW;CACxB,MAAM;EACJ,IAAI;EACJ,UAAU;EACV,aAAa;CACf;CACA,OAAO;EAAC;EAAa;EAAS;EAAa;EAAY;CAAM;CAC7D,MAAM,MAAM,SAAS;EACnB,MAAM,EAAE,mBAAmB,QAAQ;EACnC,IAAI,eAAe,SAAS,GAAG;EAC/B,KAAK,MAAM,SAAS,SAAS,IAAI,GAAG;GAClC,MAAM,QAAQ,KAAK;GAEnB,IAAI,SAAS,KAAK,KAAK,eAAe,QAAQ;GAC9C,MAAM,UAAU,eAAe,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,KAAK,CAAC;GAC1D,MAAM,OAAO,QAAQ,GAAG,CAAC;GACzB,IAAI,CAAC,MAAM;GACX,MAAM,QAAQ,aAAa;GAC3B,MAAM,QAAQ,QAAQ,KAAK,aAAa,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI;GACvE,QAAQ,OAAO;IACb;IACA,SAAS,GAAG,MAAM,GAAG,MAAM,iBAAiB;IAC5C,SACE,QAAQ,WAAW,IAAI,QAAQ,MAAM,YAAY,EAAE,OAAO,KAAK,KAAK,KAAK;IAC3E,MAAM;KAAE;KAAO;KAAO,YAAY,KAAK;KAAI,cAAc,KAAK;IAAK;IACnE,GAAI,QAAQ,WAAW,IACnB,EAAE,KAAK,OAAO,OAAO,IAAI,EAAE,IAC3B,EAAE,aAAa,QAAQ,KAAK,aAAa,OAAO,OAAO,QAAQ,CAAC,EAAE;GACxE,CAAC;EACH;CACF;AACF,CAAC"}
|
package/dist/lint/types.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { DesignRules } from "../design-memory/rules.js";
|
|
2
|
+
import { DesignViolation } from "../design-memory/check.js";
|
|
3
|
+
import "../design-memory/index.js";
|
|
1
4
|
import { SharedStyleKind } from "@pairdraw/scene-graph";
|
|
2
5
|
//#region src/lint/types.d.ts
|
|
3
6
|
type Severity = 'error' | 'warning' | 'info' | 'off';
|
|
4
|
-
type Category = 'layout' | 'accessibility' | 'naming' | 'structure' | 'components' | 'design-tokens' | 'typography';
|
|
7
|
+
type Category = 'layout' | 'accessibility' | 'naming' | 'structure' | 'components' | 'design-tokens' | 'typography' | 'design-memory';
|
|
5
8
|
interface RuleMeta {
|
|
6
9
|
id: string;
|
|
7
10
|
severity: Severity;
|
|
@@ -138,11 +141,29 @@ interface LintVariables {
|
|
|
138
141
|
id: string;
|
|
139
142
|
name: string;
|
|
140
143
|
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Number variables by the layer field their kind of token sets (`cornerRadius` for a radius,
|
|
146
|
+
* the gap and padding for spacing, `fontSize` for text) and then by their resolved value.
|
|
147
|
+
*/
|
|
148
|
+
numbersByField: ReadonlyMap<TokenNumberField, ReadonlyMap<number, ReadonlyArray<{
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
}>>>;
|
|
152
|
+
}
|
|
153
|
+
/** Layer fields a number token can stand for. */
|
|
154
|
+
type TokenNumberField = 'cornerRadius' | 'itemSpacing' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'fontSize';
|
|
155
|
+
/** The document's design memory, for the rules that check layers against it. */
|
|
156
|
+
interface LintDesignMemory {
|
|
157
|
+
rules: DesignRules;
|
|
158
|
+
/** The values on the layer that break the memory. */
|
|
159
|
+
violations(node: LintNode): readonly DesignViolation[];
|
|
141
160
|
}
|
|
142
161
|
interface RuleContext {
|
|
143
162
|
variables: LintVariables;
|
|
144
163
|
/** Whether `id`, a layer's style link, names a shared style of that kind in the document. */
|
|
145
164
|
isSharedStyle(kind: SharedStyleKind, id: string | null): boolean;
|
|
165
|
+
/** Absent or null when the document has no design memory. */
|
|
166
|
+
design?: LintDesignMemory | null;
|
|
146
167
|
report(issue: {
|
|
147
168
|
node: LintNode;
|
|
148
169
|
message: string;
|
|
@@ -150,6 +171,8 @@ interface RuleContext {
|
|
|
150
171
|
data?: LintMessageData;
|
|
151
172
|
fix?: LintFix;
|
|
152
173
|
suggestions?: LintFix[];
|
|
174
|
+
/** A milder severity for this finding than the rule's, never a harsher one. */
|
|
175
|
+
severity?: Exclude<Severity, 'off' | 'error'>;
|
|
153
176
|
}): void;
|
|
154
177
|
getConfig(): unknown;
|
|
155
178
|
getParent(node: LintNode): LintNode | null;
|
|
@@ -161,5 +184,5 @@ interface Rule {
|
|
|
161
184
|
check(node: LintNode, context: RuleContext): void;
|
|
162
185
|
}
|
|
163
186
|
//#endregion
|
|
164
|
-
export { Category, LintConfig, LintFix, LintFixProperty, LintMessage, LintMessageData, LintNode, LintResult, LintVariables, Rule, RuleContext, RuleMeta, Severity };
|
|
187
|
+
export { Category, LintConfig, LintDesignMemory, LintFix, LintFixProperty, LintMessage, LintMessageData, LintNode, LintResult, LintVariables, Rule, RuleContext, RuleMeta, Severity, TokenNumberField };
|
|
165
188
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lint/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/lint/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/lint/types.ts"],"mappings":";;;;;KAIY;KAEA;UAUK;EACf;EACA,UAAU;EACV,UAAU;EACV;;;KAIU,kBAAkB,SAAS;;KAG3B;;;;;KAiBA;EACN;EAAuB;EAAc;EAAoB;;EACzD;EAAa,SAAS,SAAS,QAAQ,OAAO;;;;EAE9C;;;;EAEA;;UAEW;EACf;EACA,UAAU,QAAQ;EAClB;EACA;EACA;EACA;EACA;EACA,OAAO;;EAEP,MAAM;;EAEN,cAAc;;UAGC;EACf,UAAU;EACV;EACA;EACA;;UAGe;EACf;EACA,OAAO,eAAe;IAAa,UAAU;IAAU,UAAU;;;UAGlD;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;EAKA;IAAe;IAAkB;;EACjC;EACA,gBAAgB;EAChB,OAAO;IACL;IACA;IACA;IACA;MAAU;MAAW;MAAW;;;EAElC,SAAS;IACP;IACA;IACA;MAAU;MAAW;MAAW;;;EAElC,SAAS;IACP;IACA;IACA;;;EAGF;;EAEA;EACA,SAAS;;;UAIM;;EAEf,QAAQ,SAAS;;EAEjB,aAAa;IAAsB;IAAY;;;;;;EAK/C,gBAAgB,YACd,kBACA,oBAAoB;IAAgB;IAAY;;;;KAKxC;;UAUK;EACf,OAAO;;EAEP,WAAW,MAAM,oBAAoB;;UAGtB;EACf,WAAW;;EAEX,cAAc,MAAM,iBAAiB;;EAErC,SAAS;EACT,OAAO;IACL,MAAM;IACN;IACA;IACA,OAAO;IACP,MAAM;IACN,cAAc;;IAEd,WAAW,QAAQ;;EAErB;EACA,UAAU,MAAM,WAAW;EAC3B,YAAY,MAAM,WAAW;;UAGd;EACf,MAAM;EACN;EACA,MAAM,MAAM,UAAU,SAAS"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VideoHostEncoder } from "../io/formats/video/formats.js";
|
|
2
|
+
import "../io/formats/video/index.js";
|
|
3
|
+
//#region src/node/video.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Encodes recorded frames with an ffmpeg on the machine, for hosts without WebCodecs such as the
|
|
6
|
+
* CLI: raw RGBA frames go to its input as they come, and the file is read back when it ends.
|
|
7
|
+
* A missing `command`, or one without libx264 or libvpx-vp9, supports nothing.
|
|
8
|
+
*/
|
|
9
|
+
declare function createFFmpegEncoder(command?: string): VideoHostEncoder;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createFFmpegEncoder };
|
|
12
|
+
//# sourceMappingURL=video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.d.ts","names":[],"sources":["../../src/node/video.ts"],"mappings":";;;;;;;;iBAuFgB,oBAAoB,mBAAqB"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { mkdtemp, readFile, rm, stat } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { once } from "node:events";
|
|
5
|
+
import { rmSync } from "node:fs";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
//#region src/node/video.ts
|
|
8
|
+
/** The encoder and settings ffmpeg records each format with: H.264 and VP9 in 4:2:0. */
|
|
9
|
+
const ENCODERS = {
|
|
10
|
+
mp4: {
|
|
11
|
+
encoder: "libx264",
|
|
12
|
+
args: [
|
|
13
|
+
"-c:v",
|
|
14
|
+
"libx264",
|
|
15
|
+
"-preset",
|
|
16
|
+
"medium",
|
|
17
|
+
"-crf",
|
|
18
|
+
"20",
|
|
19
|
+
"-movflags",
|
|
20
|
+
"+faststart"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
webm: {
|
|
24
|
+
encoder: "libvpx-vp9",
|
|
25
|
+
args: [
|
|
26
|
+
"-c:v",
|
|
27
|
+
"libvpx-vp9",
|
|
28
|
+
"-b:v",
|
|
29
|
+
"0",
|
|
30
|
+
"-crf",
|
|
31
|
+
"32"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** Folders of ffmpeg sinks still running in this process, removed when it is interrupted. */
|
|
36
|
+
const temporaryDirs = /* @__PURE__ */ new Set();
|
|
37
|
+
let cleanupInstalled = false;
|
|
38
|
+
function cleanupTemporaryDirs() {
|
|
39
|
+
for (const dir of temporaryDirs) rmSync(dir, {
|
|
40
|
+
recursive: true,
|
|
41
|
+
force: true
|
|
42
|
+
});
|
|
43
|
+
temporaryDirs.clear();
|
|
44
|
+
removeCleanupListeners();
|
|
45
|
+
}
|
|
46
|
+
function interrupted(signal) {
|
|
47
|
+
cleanupTemporaryDirs();
|
|
48
|
+
process.kill(process.pid, signal);
|
|
49
|
+
}
|
|
50
|
+
const onInterrupt = () => interrupted("SIGINT");
|
|
51
|
+
const onTerminate = () => interrupted("SIGTERM");
|
|
52
|
+
function installCleanupListeners() {
|
|
53
|
+
if (cleanupInstalled) return;
|
|
54
|
+
cleanupInstalled = true;
|
|
55
|
+
process.once("exit", cleanupTemporaryDirs);
|
|
56
|
+
process.once("SIGINT", onInterrupt);
|
|
57
|
+
process.once("SIGTERM", onTerminate);
|
|
58
|
+
}
|
|
59
|
+
function removeCleanupListeners() {
|
|
60
|
+
if (!cleanupInstalled) return;
|
|
61
|
+
cleanupInstalled = false;
|
|
62
|
+
process.off("exit", cleanupTemporaryDirs);
|
|
63
|
+
process.off("SIGINT", onInterrupt);
|
|
64
|
+
process.off("SIGTERM", onTerminate);
|
|
65
|
+
}
|
|
66
|
+
function trackTemporaryDir(dir) {
|
|
67
|
+
temporaryDirs.add(dir);
|
|
68
|
+
installCleanupListeners();
|
|
69
|
+
}
|
|
70
|
+
function releaseTemporaryDir(dir) {
|
|
71
|
+
temporaryDirs.delete(dir);
|
|
72
|
+
if (temporaryDirs.size === 0) removeCleanupListeners();
|
|
73
|
+
}
|
|
74
|
+
/** The encoders `command` lists, or none when it cannot run. */
|
|
75
|
+
function listEncoders(command) {
|
|
76
|
+
return new Promise((resolve) => {
|
|
77
|
+
const child = spawn(command, ["-hide_banner", "-encoders"], { stdio: [
|
|
78
|
+
"ignore",
|
|
79
|
+
"pipe",
|
|
80
|
+
"ignore"
|
|
81
|
+
] });
|
|
82
|
+
let output = "";
|
|
83
|
+
child.stdout.setEncoding("utf8");
|
|
84
|
+
child.stdout.on("data", (chunk) => {
|
|
85
|
+
output += chunk;
|
|
86
|
+
});
|
|
87
|
+
child.on("error", () => resolve(""));
|
|
88
|
+
child.on("close", (code) => resolve(code === 0 ? output : ""));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Encodes recorded frames with an ffmpeg on the machine, for hosts without WebCodecs such as the
|
|
93
|
+
* CLI: raw RGBA frames go to its input as they come, and the file is read back when it ends.
|
|
94
|
+
* A missing `command`, or one without libx264 or libvpx-vp9, supports nothing.
|
|
95
|
+
*/
|
|
96
|
+
function createFFmpegEncoder(command = "ffmpeg") {
|
|
97
|
+
let encoders = null;
|
|
98
|
+
return {
|
|
99
|
+
async supports(format) {
|
|
100
|
+
if (format === "gif") return false;
|
|
101
|
+
encoders ??= listEncoders(command);
|
|
102
|
+
return (await encoders).includes(ENCODERS[format].encoder);
|
|
103
|
+
},
|
|
104
|
+
async create(format, options) {
|
|
105
|
+
if (format === "gif") throw new Error("ffmpeg records MP4 and WebM, not GIF");
|
|
106
|
+
const dir = await mkdtemp(join(tmpdir(), "pairdraw-ffmpeg-"));
|
|
107
|
+
trackTemporaryDir(dir);
|
|
108
|
+
const output = join(dir, `video.${format}`);
|
|
109
|
+
let byteLength = 0;
|
|
110
|
+
const state = {
|
|
111
|
+
/** finish or cancel ran, so no frame may follow. */
|
|
112
|
+
ended: false,
|
|
113
|
+
/** ffmpeg stopped reading, which a dying ffmpeg does before it exits. */
|
|
114
|
+
inputClosed: false
|
|
115
|
+
};
|
|
116
|
+
const child = spawn(command, [
|
|
117
|
+
"-hide_banner",
|
|
118
|
+
"-loglevel",
|
|
119
|
+
"error",
|
|
120
|
+
"-f",
|
|
121
|
+
"rawvideo",
|
|
122
|
+
"-pix_fmt",
|
|
123
|
+
"rgba",
|
|
124
|
+
"-s",
|
|
125
|
+
`${options.width}x${options.height}`,
|
|
126
|
+
"-r",
|
|
127
|
+
String(options.fps),
|
|
128
|
+
"-i",
|
|
129
|
+
"pipe:0",
|
|
130
|
+
...ENCODERS[format].args,
|
|
131
|
+
"-pix_fmt",
|
|
132
|
+
"yuv420p",
|
|
133
|
+
"-y",
|
|
134
|
+
output
|
|
135
|
+
], { stdio: [
|
|
136
|
+
"pipe",
|
|
137
|
+
"ignore",
|
|
138
|
+
"pipe"
|
|
139
|
+
] });
|
|
140
|
+
let stderr = "";
|
|
141
|
+
child.stdin.on("error", () => {
|
|
142
|
+
state.inputClosed = true;
|
|
143
|
+
});
|
|
144
|
+
child.stderr.setEncoding("utf8");
|
|
145
|
+
child.stderr.on("data", (chunk) => {
|
|
146
|
+
stderr = (stderr + chunk).slice(-2e3);
|
|
147
|
+
});
|
|
148
|
+
const exited = new Promise((resolve) => {
|
|
149
|
+
child.on("error", () => resolve(-1));
|
|
150
|
+
child.on("close", (code) => resolve(code));
|
|
151
|
+
});
|
|
152
|
+
const failure = () => /* @__PURE__ */ new Error(`ffmpeg could not encode the video: ${stderr.trim() || "it stopped"}`);
|
|
153
|
+
/** Waits for ffmpeg to exit, so its error output is complete, then reports it. */
|
|
154
|
+
const failed = async () => {
|
|
155
|
+
await exited;
|
|
156
|
+
throw failure();
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
async add(image) {
|
|
160
|
+
if (state.ended) throw new Error("The recording has ended");
|
|
161
|
+
if (state.inputClosed) await failed();
|
|
162
|
+
if (!child.stdin.write(image.data)) {
|
|
163
|
+
const drained = once(child.stdin, "drain").then(() => true);
|
|
164
|
+
if (!await Promise.race([drained, exited.then(() => false)]).catch(() => false) || state.inputClosed) await failed();
|
|
165
|
+
}
|
|
166
|
+
byteLength = (await stat(output).catch(() => null))?.size ?? byteLength;
|
|
167
|
+
},
|
|
168
|
+
async finish() {
|
|
169
|
+
if (state.ended) throw new Error("The recording has ended");
|
|
170
|
+
state.ended = true;
|
|
171
|
+
child.stdin.end();
|
|
172
|
+
const code = await exited;
|
|
173
|
+
try {
|
|
174
|
+
if (code !== 0) throw failure();
|
|
175
|
+
return new Uint8Array(await readFile(output));
|
|
176
|
+
} finally {
|
|
177
|
+
await rm(dir, {
|
|
178
|
+
recursive: true,
|
|
179
|
+
force: true
|
|
180
|
+
});
|
|
181
|
+
releaseTemporaryDir(dir);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async cancel() {
|
|
185
|
+
if (!state.ended) {
|
|
186
|
+
state.ended = true;
|
|
187
|
+
child.kill("SIGKILL");
|
|
188
|
+
}
|
|
189
|
+
await exited;
|
|
190
|
+
await rm(dir, {
|
|
191
|
+
recursive: true,
|
|
192
|
+
force: true
|
|
193
|
+
});
|
|
194
|
+
releaseTemporaryDir(dir);
|
|
195
|
+
},
|
|
196
|
+
get byteLength() {
|
|
197
|
+
return byteLength;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
export { createFFmpegEncoder };
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.js","names":[],"sources":["../../src/node/video.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { once } from 'node:events'\nimport { rmSync } from 'node:fs'\nimport { mkdtemp, readFile, rm, stat } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\n\nimport type { VideoFormat, VideoHostEncoder, VideoSink } from '#core/io/formats/video'\n\n/** The encoder and settings ffmpeg records each format with: H.264 and VP9 in 4:2:0. */\nconst ENCODERS = {\n mp4: {\n encoder: 'libx264',\n args: ['-c:v', 'libx264', '-preset', 'medium', '-crf', '20', '-movflags', '+faststart']\n },\n webm: { encoder: 'libvpx-vp9', args: ['-c:v', 'libvpx-vp9', '-b:v', '0', '-crf', '32'] }\n} as const\n\n/** The tail of ffmpeg's error output a failure reports. */\nconst STDERR_TAIL = 2000\n\n/** Folders of ffmpeg sinks still running in this process, removed when it is interrupted. */\nconst temporaryDirs = new Set<string>()\nlet cleanupInstalled = false\n\nfunction cleanupTemporaryDirs(): void {\n for (const dir of temporaryDirs) rmSync(dir, { recursive: true, force: true })\n temporaryDirs.clear()\n removeCleanupListeners()\n}\n\nfunction interrupted(signal: 'SIGINT' | 'SIGTERM'): void {\n cleanupTemporaryDirs()\n // With our listener gone, the same signal takes its default path, so the exit code stays.\n process.kill(process.pid, signal)\n}\n\nconst onInterrupt = () => interrupted('SIGINT')\nconst onTerminate = () => interrupted('SIGTERM')\n\nfunction installCleanupListeners(): void {\n if (cleanupInstalled) return\n cleanupInstalled = true\n process.once('exit', cleanupTemporaryDirs)\n process.once('SIGINT', onInterrupt)\n process.once('SIGTERM', onTerminate)\n}\n\nfunction removeCleanupListeners(): void {\n if (!cleanupInstalled) return\n cleanupInstalled = false\n process.off('exit', cleanupTemporaryDirs)\n process.off('SIGINT', onInterrupt)\n process.off('SIGTERM', onTerminate)\n}\n\nfunction trackTemporaryDir(dir: string): void {\n temporaryDirs.add(dir)\n installCleanupListeners()\n}\n\nfunction releaseTemporaryDir(dir: string): void {\n temporaryDirs.delete(dir)\n if (temporaryDirs.size === 0) removeCleanupListeners()\n}\n\n/** The encoders `command` lists, or none when it cannot run. */\nfunction listEncoders(command: string): Promise<string> {\n return new Promise((resolve) => {\n const child = spawn(command, ['-hide_banner', '-encoders'], {\n stdio: ['ignore', 'pipe', 'ignore']\n })\n let output = ''\n child.stdout.setEncoding('utf8')\n child.stdout.on('data', (chunk: string) => {\n output += chunk\n })\n child.on('error', () => resolve(''))\n child.on('close', (code) => resolve(code === 0 ? output : ''))\n })\n}\n\n/**\n * Encodes recorded frames with an ffmpeg on the machine, for hosts without WebCodecs such as the\n * CLI: raw RGBA frames go to its input as they come, and the file is read back when it ends.\n * A missing `command`, or one without libx264 or libvpx-vp9, supports nothing.\n */\nexport function createFFmpegEncoder(command = 'ffmpeg'): VideoHostEncoder {\n let encoders: Promise<string> | null = null\n\n return {\n async supports(format: VideoFormat) {\n if (format === 'gif') return false\n encoders ??= listEncoders(command)\n return (await encoders).includes(ENCODERS[format].encoder)\n },\n async create(format, options): Promise<VideoSink> {\n if (format === 'gif') throw new Error('ffmpeg records MP4 and WebM, not GIF')\n const dir = await mkdtemp(join(tmpdir(), 'pairdraw-ffmpeg-'))\n trackTemporaryDir(dir)\n const output = join(dir, `video.${format}`)\n let byteLength = 0\n const state = {\n /** finish or cancel ran, so no frame may follow. */\n ended: false,\n /** ffmpeg stopped reading, which a dying ffmpeg does before it exits. */\n inputClosed: false\n }\n const child = spawn(\n command,\n [\n '-hide_banner',\n '-loglevel',\n 'error',\n '-f',\n 'rawvideo',\n '-pix_fmt',\n 'rgba',\n '-s',\n `${options.width}x${options.height}`,\n '-r',\n String(options.fps),\n '-i',\n 'pipe:0',\n ...ENCODERS[format].args,\n '-pix_fmt',\n 'yuv420p',\n '-y',\n output\n ],\n { stdio: ['pipe', 'ignore', 'pipe'] }\n )\n let stderr = ''\n // ffmpeg stopping early closes its input; the frame that finds it closed reports why.\n child.stdin.on('error', () => {\n state.inputClosed = true\n })\n child.stderr.setEncoding('utf8')\n child.stderr.on('data', (chunk: string) => {\n stderr = (stderr + chunk).slice(-STDERR_TAIL)\n })\n const exited = new Promise<number | null>((resolve) => {\n child.on('error', () => resolve(-1))\n child.on('close', (code) => resolve(code))\n })\n\n const failure = () =>\n new Error(`ffmpeg could not encode the video: ${stderr.trim() || 'it stopped'}`)\n /** Waits for ffmpeg to exit, so its error output is complete, then reports it. */\n const failed = async (): Promise<never> => {\n await exited\n throw failure()\n }\n\n return {\n async add(image) {\n if (state.ended) throw new Error('The recording has ended')\n if (state.inputClosed) await failed()\n if (!child.stdin.write(image.data)) {\n // `once` drops its listeners whichever way the wait ends; ffmpeg exiting ends it too.\n const drained = once(child.stdin, 'drain').then(() => true)\n const ok = await Promise.race([drained, exited.then(() => false)]).catch(() => false)\n if (!ok || state.inputClosed) await failed()\n }\n byteLength = (await stat(output).catch(() => null))?.size ?? byteLength\n },\n async finish() {\n if (state.ended) throw new Error('The recording has ended')\n state.ended = true\n child.stdin.end()\n const code = await exited\n try {\n if (code !== 0) throw failure()\n return new Uint8Array(await readFile(output))\n } finally {\n await rm(dir, { recursive: true, force: true })\n releaseTemporaryDir(dir)\n }\n },\n async cancel() {\n if (!state.ended) {\n state.ended = true\n child.kill('SIGKILL')\n }\n await exited\n // Whatever ended the recording, its folder goes with it.\n await rm(dir, { recursive: true, force: true })\n releaseTemporaryDir(dir)\n },\n get byteLength() {\n return byteLength\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,WAAW;CACf,KAAK;EACH,SAAS;EACT,MAAM;GAAC;GAAQ;GAAW;GAAW;GAAU;GAAQ;GAAM;GAAa;EAAY;CACxF;CACA,MAAM;EAAE,SAAS;EAAc,MAAM;GAAC;GAAQ;GAAc;GAAQ;GAAK;GAAQ;EAAI;CAAE;AACzF;;AAMA,MAAM,gCAAgB,IAAI,IAAY;AACtC,IAAI,mBAAmB;AAEvB,SAAS,uBAA6B;CACpC,KAAK,MAAM,OAAO,eAAe,OAAO,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAC7E,cAAc,MAAM;CACpB,uBAAuB;AACzB;AAEA,SAAS,YAAY,QAAoC;CACvD,qBAAqB;CAErB,QAAQ,KAAK,QAAQ,KAAK,MAAM;AAClC;AAEA,MAAM,oBAAoB,YAAY,QAAQ;AAC9C,MAAM,oBAAoB,YAAY,SAAS;AAE/C,SAAS,0BAAgC;CACvC,IAAI,kBAAkB;CACtB,mBAAmB;CACnB,QAAQ,KAAK,QAAQ,oBAAoB;CACzC,QAAQ,KAAK,UAAU,WAAW;CAClC,QAAQ,KAAK,WAAW,WAAW;AACrC;AAEA,SAAS,yBAA+B;CACtC,IAAI,CAAC,kBAAkB;CACvB,mBAAmB;CACnB,QAAQ,IAAI,QAAQ,oBAAoB;CACxC,QAAQ,IAAI,UAAU,WAAW;CACjC,QAAQ,IAAI,WAAW,WAAW;AACpC;AAEA,SAAS,kBAAkB,KAAmB;CAC5C,cAAc,IAAI,GAAG;CACrB,wBAAwB;AAC1B;AAEA,SAAS,oBAAoB,KAAmB;CAC9C,cAAc,OAAO,GAAG;CACxB,IAAI,cAAc,SAAS,GAAG,uBAAuB;AACvD;;AAGA,SAAS,aAAa,SAAkC;CACtD,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,SAAS,CAAC,gBAAgB,WAAW,GAAG,EAC1D,OAAO;GAAC;GAAU;GAAQ;EAAQ,EACpC,CAAC;EACD,IAAI,SAAS;EACb,MAAM,OAAO,YAAY,MAAM;EAC/B,MAAM,OAAO,GAAG,SAAS,UAAkB;GACzC,UAAU;EACZ,CAAC;EACD,MAAM,GAAG,eAAe,QAAQ,EAAE,CAAC;EACnC,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,IAAI,SAAS,EAAE,CAAC;CAC/D,CAAC;AACH;;;;;;AAOA,SAAgB,oBAAoB,UAAU,UAA4B;CACxE,IAAI,WAAmC;CAEvC,OAAO;EACL,MAAM,SAAS,QAAqB;GAClC,IAAI,WAAW,OAAO,OAAO;GAC7B,aAAa,aAAa,OAAO;GACjC,QAAQ,MAAM,SAAA,CAAU,SAAS,SAAS,OAAO,CAAC,OAAO;EAC3D;EACA,MAAM,OAAO,QAAQ,SAA6B;GAChD,IAAI,WAAW,OAAO,MAAM,IAAI,MAAM,sCAAsC;GAC5E,MAAM,MAAM,MAAM,QAAQ,KAAK,OAAO,GAAG,kBAAkB,CAAC;GAC5D,kBAAkB,GAAG;GACrB,MAAM,SAAS,KAAK,KAAK,SAAS,QAAQ;GAC1C,IAAI,aAAa;GACjB,MAAM,QAAQ;;IAEZ,OAAO;;IAEP,aAAa;GACf;GACA,MAAM,QAAQ,MACZ,SACA;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,GAAG,QAAQ,MAAM,GAAG,QAAQ;IAC5B;IACA,OAAO,QAAQ,GAAG;IAClB;IACA;IACA,GAAG,SAAS,OAAO,CAAC;IACpB;IACA;IACA;IACA;GACF,GACA,EAAE,OAAO;IAAC;IAAQ;IAAU;GAAM,EAAE,CACtC;GACA,IAAI,SAAS;GAEb,MAAM,MAAM,GAAG,eAAe;IAC5B,MAAM,cAAc;GACtB,CAAC;GACD,MAAM,OAAO,YAAY,MAAM;GAC/B,MAAM,OAAO,GAAG,SAAS,UAAkB;IACzC,UAAU,SAAS,MAAA,CAAO,MAAM,IAAY;GAC9C,CAAC;GACD,MAAM,SAAS,IAAI,SAAwB,YAAY;IACrD,MAAM,GAAG,eAAe,QAAQ,EAAE,CAAC;IACnC,MAAM,GAAG,UAAU,SAAS,QAAQ,IAAI,CAAC;GAC3C,CAAC;GAED,MAAM,gCACJ,IAAI,MAAM,sCAAsC,OAAO,KAAK,KAAK,cAAc;;GAEjF,MAAM,SAAS,YAA4B;IACzC,MAAM;IACN,MAAM,QAAQ;GAChB;GAEA,OAAO;IACL,MAAM,IAAI,OAAO;KACf,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,yBAAyB;KAC1D,IAAI,MAAM,aAAa,MAAM,OAAO;KACpC,IAAI,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI,GAAG;MAElC,MAAM,UAAU,KAAK,MAAM,OAAO,OAAO,CAAC,CAAC,WAAW,IAAI;MAE1D,IAAI,CAAC,MADY,QAAQ,KAAK,CAAC,SAAS,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,KACzE,MAAM,aAAa,MAAM,OAAO;KAC7C;KACA,cAAc,MAAM,KAAK,MAAM,CAAC,CAAC,YAAY,IAAI,EAAA,EAAI,QAAQ;IAC/D;IACA,MAAM,SAAS;KACb,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,yBAAyB;KAC1D,MAAM,QAAQ;KACd,MAAM,MAAM,IAAI;KAChB,MAAM,OAAO,MAAM;KACnB,IAAI;MACF,IAAI,SAAS,GAAG,MAAM,QAAQ;MAC9B,OAAO,IAAI,WAAW,MAAM,SAAS,MAAM,CAAC;KAC9C,UAAU;MACR,MAAM,GAAG,KAAK;OAAE,WAAW;OAAM,OAAO;MAAK,CAAC;MAC9C,oBAAoB,GAAG;KACzB;IACF;IACA,MAAM,SAAS;KACb,IAAI,CAAC,MAAM,OAAO;MAChB,MAAM,QAAQ;MACd,MAAM,KAAK,SAAS;KACtB;KACA,MAAM;KAEN,MAAM,GAAG,KAAK;MAAE,WAAW;MAAM,OAAO;KAAK,CAAC;KAC9C,oBAAoB,GAAG;IACzB;IACA,IAAI,aAAa;KACf,OAAO;IACT;GACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DesignValueVerdict } from "../design-memory/check.js";
|
|
2
|
+
import "../design-memory/index.js";
|
|
3
|
+
import { NodeRef } from "./behaviours.js";
|
|
4
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
5
|
+
import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
|
|
6
|
+
//#region src/pairdraw-api/design-memory.d.ts
|
|
7
|
+
/** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */
|
|
8
|
+
declare function checkProposedDesignValues(graph: SceneGraph, proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>): DesignValueVerdict[];
|
|
9
|
+
/**
|
|
10
|
+
* Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add
|
|
11
|
+
* to the memory but never change what it allows: only the person does that.
|
|
12
|
+
*/
|
|
13
|
+
declare function recordDesignDecision(graph: SceneGraph, text: string, example?: NodeRef): {
|
|
14
|
+
decisions: number;
|
|
15
|
+
examples: number;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { checkProposedDesignValues, recordDesignDecision };
|
|
19
|
+
//# sourceMappingURL=design-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-memory.d.ts","names":[],"sources":["../../src/pairdraw-api/design-memory.ts"],"mappings":";;;;;;;iBAwBgB,0BACd,OAAO,YACP,UAAU,QAAQ,OAAO,oDACxB;;;;;iBAQa,qBACd,OAAO,YACP,cACA,UAAU;EACP;EAAmB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { currentDesignRules } from "../design-memory/document.js";
|
|
2
|
+
import { checkDesignValues } from "../design-memory/check.js";
|
|
3
|
+
import { nodeOf } from "./behaviours.js";
|
|
4
|
+
import { addDesignDecision, cachedDesignMemory, pinDesignExample, writeDesignMemory } from "@pairdraw/scene-graph/design-memory";
|
|
5
|
+
//#region src/pairdraw-api/design-memory.ts
|
|
6
|
+
const NO_MEMORY = "This document has no design memory; the person creates one in the Design panel with nothing selected.";
|
|
7
|
+
function memoryOf(graph) {
|
|
8
|
+
const memory = cachedDesignMemory(graph);
|
|
9
|
+
if (!memory) throw new Error(NO_MEMORY);
|
|
10
|
+
return memory;
|
|
11
|
+
}
|
|
12
|
+
/** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */
|
|
13
|
+
function checkProposedDesignValues(graph, proposal) {
|
|
14
|
+
return checkDesignValues(currentDesignRules(graph, memoryOf(graph)), proposal);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add
|
|
18
|
+
* to the memory but never change what it allows: only the person does that.
|
|
19
|
+
*/
|
|
20
|
+
function recordDesignDecision(graph, text, example) {
|
|
21
|
+
let memory = memoryOf(graph);
|
|
22
|
+
const decisions = memory.decisions.length;
|
|
23
|
+
memory = addDesignDecision(memory, text, "agent");
|
|
24
|
+
if (memory.decisions.length === decisions) throw new Error(text.trim() ? "The design memory holds as many decisions as it can; ask the person to remove some." : "A decision needs text.");
|
|
25
|
+
if (example !== void 0) {
|
|
26
|
+
const nodeId = nodeOf(graph, example).id;
|
|
27
|
+
memory = pinDesignExample(memory, nodeId);
|
|
28
|
+
if (!memory.examples.some((pinned) => pinned.nodeId === nodeId)) throw new Error("The design memory holds as many examples as it can; ask the person to unpin some.");
|
|
29
|
+
}
|
|
30
|
+
writeDesignMemory(graph, memory);
|
|
31
|
+
return {
|
|
32
|
+
decisions: memory.decisions.length,
|
|
33
|
+
examples: memory.examples.length
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { checkProposedDesignValues, recordDesignDecision };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=design-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-memory.js","names":[],"sources":["../../src/pairdraw-api/design-memory.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n addDesignDecision,\n cachedDesignMemory,\n pinDesignExample,\n writeDesignMemory,\n type DesignMemory,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { checkDesignValues, currentDesignRules, type DesignValueVerdict } from '#core/design-memory'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\nconst NO_MEMORY =\n 'This document has no design memory; the person creates one in the Design panel with nothing selected.'\n\nfunction memoryOf(graph: SceneGraph): DesignMemory {\n const memory = cachedDesignMemory(graph)\n if (!memory) throw new Error(NO_MEMORY)\n return memory\n}\n\n/** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */\nexport function checkProposedDesignValues(\n graph: SceneGraph,\n proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>\n): DesignValueVerdict[] {\n return checkDesignValues(currentDesignRules(graph, memoryOf(graph)), proposal)\n}\n\n/**\n * Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add\n * to the memory but never change what it allows: only the person does that.\n */\nexport function recordDesignDecision(\n graph: SceneGraph,\n text: string,\n example?: NodeRef\n): { decisions: number; examples: number } {\n let memory = memoryOf(graph)\n const decisions = memory.decisions.length\n memory = addDesignDecision(memory, text, 'agent')\n if (memory.decisions.length === decisions) {\n throw new Error(\n text.trim()\n ? 'The design memory holds as many decisions as it can; ask the person to remove some.'\n : 'A decision needs text.'\n )\n }\n if (example !== undefined) {\n const nodeId = nodeOf(graph, example).id\n memory = pinDesignExample(memory, nodeId)\n if (!memory.examples.some((pinned) => pinned.nodeId === nodeId))\n throw new Error(\n 'The design memory holds as many examples as it can; ask the person to unpin some.'\n )\n }\n writeDesignMemory(graph, memory)\n return { decisions: memory.decisions.length, examples: memory.examples.length }\n}\n"],"mappings":";;;;;AAcA,MAAM,YACJ;AAEF,SAAS,SAAS,OAAiC;CACjD,MAAM,SAAS,mBAAmB,KAAK;CACvC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,SAAS;CACtC,OAAO;AACT;;AAGA,SAAgB,0BACd,OACA,UACsB;CACtB,OAAO,kBAAkB,mBAAmB,OAAO,SAAS,KAAK,CAAC,GAAG,QAAQ;AAC/E;;;;;AAMA,SAAgB,qBACd,OACA,MACA,SACyC;CACzC,IAAI,SAAS,SAAS,KAAK;CAC3B,MAAM,YAAY,OAAO,UAAU;CACnC,SAAS,kBAAkB,QAAQ,MAAM,OAAO;CAChD,IAAI,OAAO,UAAU,WAAW,WAC9B,MAAM,IAAI,MACR,KAAK,KAAK,IACN,wFACA,wBACN;CAEF,IAAI,YAAY,KAAA,GAAW;EACzB,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC,CAAC;EACtC,SAAS,iBAAiB,QAAQ,MAAM;EACxC,IAAI,CAAC,OAAO,SAAS,MAAM,WAAW,OAAO,WAAW,MAAM,GAC5D,MAAM,IAAI,MACR,mFACF;CACJ;CACA,kBAAkB,OAAO,MAAM;CAC/B,OAAO;EAAE,WAAW,OAAO,UAAU;EAAQ,UAAU,OAAO,SAAS;CAAO;AAChF"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { DesignValueVerdict } from "../design-memory/check.js";
|
|
2
|
+
import { DesignMemoryReport } from "../design-memory/describe.js";
|
|
1
3
|
import { FigmaNodeProxy } from "../figma-api/proxy.js";
|
|
2
4
|
import { FigmaAPI } from "../figma-api/index.js";
|
|
5
|
+
import "../design-memory/index.js";
|
|
3
6
|
import { DocumentFontStatus } from "../text/font/status.js";
|
|
4
7
|
import { BehaviourHandle, NodeRef } from "./behaviours.js";
|
|
5
8
|
import { CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, NewComment } from "./comments.js";
|
|
6
9
|
import { StatusInfo } from "./statuses.js";
|
|
7
10
|
import { VariableRef } from "./variables.js";
|
|
11
|
+
import { VariationSetHandle, VariationSetInfo } from "./variations.js";
|
|
8
12
|
import { BehaviourKind, BehaviourSpec } from "@pairdraw/scene-graph/behaviours";
|
|
9
13
|
import { VariableLiteral } from "@pairdraw/scene-graph";
|
|
10
14
|
import { OkHCLColor, OkHCLPayload } from "@pairdraw/scene-graph/color";
|
|
15
|
+
import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
|
|
11
16
|
//#region src/pairdraw-api/index.d.ts
|
|
12
17
|
/**
|
|
13
18
|
* What Pairdraw adds to the Figma Plugin API for scripts, as the `pairdraw` global next to
|
|
@@ -73,6 +78,41 @@ declare class PairdrawAPI {
|
|
|
73
78
|
* frames, components, sets and instances directly on a page or in a section take one.
|
|
74
79
|
*/
|
|
75
80
|
setStatus(node: NodeRef, status: string | null): void;
|
|
81
|
+
/**
|
|
82
|
+
* The document's design memory: the colors, fonts, sizes, spacing and radii agents may use,
|
|
83
|
+
* whether an off-system value is refused or warned about, the decisions written down, and the
|
|
84
|
+
* layers pinned as examples. Null when the document has none.
|
|
85
|
+
*/
|
|
86
|
+
get designMemory(): DesignMemoryReport | null;
|
|
87
|
+
/**
|
|
88
|
+
* Judge values before using them, such as `{ colors: ['#FF00AA'], spacing: [13] }`: each comes
|
|
89
|
+
* back `ok`, `warn`, `refuse` or `invalid`, with the nearest allowed value.
|
|
90
|
+
*/
|
|
91
|
+
checkDesignValues(proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>): DesignValueVerdict[];
|
|
92
|
+
/**
|
|
93
|
+
* Write a decision down in the design memory, optionally pinning a layer that shows it as an
|
|
94
|
+
* example. The memory's allowed values stay as the person set them.
|
|
95
|
+
*/
|
|
96
|
+
recordDesignDecision(text: string, example?: NodeRef): {
|
|
97
|
+
decisions: number;
|
|
98
|
+
examples: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Copy a layer `count` times (1 to 8) into a section of variations beside it, made the first
|
|
102
|
+
* time; `labels` name what each version tries, as in `V2 · Calmer palette`. On a version, it
|
|
103
|
+
* copies that version into its set. The original does not change.
|
|
104
|
+
*/
|
|
105
|
+
createVariations(node: NodeRef, options: {
|
|
106
|
+
count: number;
|
|
107
|
+
labels?: readonly string[];
|
|
108
|
+
}): {
|
|
109
|
+
set: VariationSetHandle;
|
|
110
|
+
versions: FigmaNodeProxy[];
|
|
111
|
+
};
|
|
112
|
+
/** The set of variations a layer belongs to, from its section, a version or a layer inside one. */
|
|
113
|
+
getVariations(node: NodeRef): VariationSetHandle | null;
|
|
114
|
+
/** The sets of variations on the current page. */
|
|
115
|
+
get variations(): VariationSetHandle[];
|
|
76
116
|
/**
|
|
77
117
|
* Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;
|
|
78
118
|
* returns the layer that holds the property.
|
|
@@ -95,7 +135,11 @@ declare class PairdrawAPI {
|
|
|
95
135
|
/** Which way a text runs: `AUTO`, `LTR` or `RTL`. */
|
|
96
136
|
getTextDirection(node: NodeRef): string;
|
|
97
137
|
setTextDirection(node: NodeRef, direction: string): void;
|
|
138
|
+
/** Merges OpenType feature toggles into the text's own, keeping the tags it does not name. */
|
|
139
|
+
setFontFeatures(node: NodeRef, features: Record<string, boolean>): void;
|
|
140
|
+
/** Merges OpenType feature toggles into a text range's own, keeping its other features. */
|
|
141
|
+
setRangeFontFeatures(node: NodeRef, start: number, end: number, features: Record<string, boolean>): void;
|
|
98
142
|
}
|
|
99
143
|
//#endregion
|
|
100
|
-
export { BehaviourHandle, type CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, type NewComment, type NodeRef, PairdrawAPI, type StatusInfo, type VariableRef };
|
|
144
|
+
export { BehaviourHandle, type CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, type NewComment, type NodeRef, PairdrawAPI, type StatusInfo, type VariableRef, VariationSetHandle, type VariationSetInfo };
|
|
101
145
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/pairdraw-api/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/pairdraw-api/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cA2Ea;mBACkB;EAAA,YAAA,OAAO;;;;;;;;EASpC,mBACE,wBACA,sBACA,gBACA,oBACC;;;;;;;EA8BH,aAAa,MAAM,SAAS,eAAe,UAAU;;EAKrD,eAAe,MAAM,SAAS;;MAK1B;;;;;;EAKJ,aAAa,MAAM,UAAU;;;;;;EAS7B,aAAa,MAAM,SAAS,MAAM,gBAAgB,gBAAgB;;EAKlE,WAAW,OAAO;;;;;EAQlB,YAAY,SAAS,gBAAgB;EAIrC,WAAW,aAAa;;;;;EAQxB,WAAW,cAAc,UAAU,aAAa;;;;;MAQ5C,YAAY;;EAKhB,UAAU,MAAM;;;;;EAQhB,UAAU,MAAM,SAAS;;;;;;MASrB,gBAAgB;;;;;EAQpB,kBACE,UAAU,QAAQ,OAAO,oDACxB;;;;;EAQH,qBAAqB,cAAc,UAAU;IAAY;IAAmB;;;;;;;EAS5E,iBACE,MAAM,SACN;IAAW;IAAe;;IACvB,KAAK;IAAoB,UAAU;;;EAMxC,cAAc,MAAM,UAAU;;MAK1B,cAAc;;;;;EAQlB,mBACE,oBAAoB,WACpB,qBAAqB,WACrB,wBACC;;;;;EAgBH,iBAAiB;;EAKjB,aAAa,MAAM,SAAS,iBAAY;;EAKxC,aAAa,MAAM,SAAS,OAAO,YAAY;EAI/C,eAAe,MAAM,SAAS,iBAAY;EAI1C,eAAe,MAAM,SAAS,OAAO,YAAY;;EAKjD,mBAAmB,MAAM;EAIzB,mBAAmB,MAAM,SAAS;;EAKlC,iBAAiB,MAAM;EAIvB,iBAAiB,MAAM,SAAS;;EAKhC,gBAAgB,MAAM,SAAS,UAAU;;EAKzC,qBACE,MAAM,SACN,eACA,aACA,UAAU"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { documentFontStatus } from "../text/font/status.js";
|
|
2
2
|
import { exposeInstanceSwap } from "../figma-api/components.js";
|
|
3
3
|
import { writeVariableValue } from "../figma-api/variables/variable.js";
|
|
4
|
+
import { describeDesignMemory } from "../design-memory/describe.js";
|
|
4
5
|
import { BehaviourHandle, getBehaviour, makeSlot, nodeOf, setBehaviour } from "./behaviours.js";
|
|
5
6
|
import { CommentHandle, DEFAULT_COMMENT_AUTHOR, addComment, getComment, getComments } from "./comments.js";
|
|
6
|
-
import {
|
|
7
|
+
import { checkProposedDesignValues, recordDesignDecision } from "./design-memory.js";
|
|
8
|
+
import { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeFontFeatures, writeLayoutDirection, writeRangeFontFeatures, writeStrokeOkHCL, writeTextDirection } from "./nodes.js";
|
|
7
9
|
import { getStatus, listStatuses, setStatus } from "./statuses.js";
|
|
8
10
|
import { bindVariable, unbindVariable } from "./variables.js";
|
|
11
|
+
import { VariationSetHandle, createVariationSet, getVariationSet, listVariationSets } from "./variations.js";
|
|
9
12
|
import { BEHAVIOUR_CONTRACTS, BEHAVIOUR_KINDS } from "@pairdraw/scene-graph/behaviours";
|
|
10
13
|
import { parseVariableFormula } from "@pairdraw/scene-graph/variables";
|
|
11
14
|
//#region src/pairdraw-api/index.ts
|
|
@@ -113,6 +116,48 @@ var PairdrawAPI = class {
|
|
|
113
116
|
setStatus(this.figma.graph, node, status);
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
119
|
+
* The document's design memory: the colors, fonts, sizes, spacing and radii agents may use,
|
|
120
|
+
* whether an off-system value is refused or warned about, the decisions written down, and the
|
|
121
|
+
* layers pinned as examples. Null when the document has none.
|
|
122
|
+
*/
|
|
123
|
+
get designMemory() {
|
|
124
|
+
return describeDesignMemory(this.figma.graph);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Judge values before using them, such as `{ colors: ['#FF00AA'], spacing: [13] }`: each comes
|
|
128
|
+
* back `ok`, `warn`, `refuse` or `invalid`, with the nearest allowed value.
|
|
129
|
+
*/
|
|
130
|
+
checkDesignValues(proposal) {
|
|
131
|
+
return checkProposedDesignValues(this.figma.graph, proposal);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Write a decision down in the design memory, optionally pinning a layer that shows it as an
|
|
135
|
+
* example. The memory's allowed values stay as the person set them.
|
|
136
|
+
*/
|
|
137
|
+
recordDesignDecision(text, example) {
|
|
138
|
+
return recordDesignDecision(this.figma.graph, text, example);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Copy a layer `count` times (1 to 8) into a section of variations beside it, made the first
|
|
142
|
+
* time; `labels` name what each version tries, as in `V2 · Calmer palette`. On a version, it
|
|
143
|
+
* copies that version into its set. The original does not change.
|
|
144
|
+
*/
|
|
145
|
+
createVariations(node, options) {
|
|
146
|
+
const { set, created } = createVariationSet(this.figma, node, options);
|
|
147
|
+
return {
|
|
148
|
+
set,
|
|
149
|
+
versions: created
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** The set of variations a layer belongs to, from its section, a version or a layer inside one. */
|
|
153
|
+
getVariations(node) {
|
|
154
|
+
return getVariationSet(this.figma, node);
|
|
155
|
+
}
|
|
156
|
+
/** The sets of variations on the current page. */
|
|
157
|
+
get variations() {
|
|
158
|
+
return listVariationSets(this.figma, this.figma.currentPageId);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
116
161
|
* Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;
|
|
117
162
|
* returns the layer that holds the property.
|
|
118
163
|
*/
|
|
@@ -156,8 +201,16 @@ var PairdrawAPI = class {
|
|
|
156
201
|
setTextDirection(node, direction) {
|
|
157
202
|
writeTextDirection(this.figma.graph, node, direction);
|
|
158
203
|
}
|
|
204
|
+
/** Merges OpenType feature toggles into the text's own, keeping the tags it does not name. */
|
|
205
|
+
setFontFeatures(node, features) {
|
|
206
|
+
writeFontFeatures(this.figma.graph, node, features);
|
|
207
|
+
}
|
|
208
|
+
/** Merges OpenType feature toggles into a text range's own, keeping its other features. */
|
|
209
|
+
setRangeFontFeatures(node, start, end, features) {
|
|
210
|
+
writeRangeFontFeatures(this.figma.graph, node, start, end, features);
|
|
211
|
+
}
|
|
159
212
|
};
|
|
160
213
|
//#endregion
|
|
161
|
-
export { BehaviourHandle, CommentHandle, DEFAULT_COMMENT_AUTHOR, PairdrawAPI };
|
|
214
|
+
export { BehaviourHandle, CommentHandle, DEFAULT_COMMENT_AUTHOR, PairdrawAPI, VariationSetHandle };
|
|
162
215
|
|
|
163
216
|
//# sourceMappingURL=index.js.map
|