@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE3C;EAAE,KAAK;EAAU,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,UAAU,OAAO;CAAE;CAC3E;EAAE,KAAK;EAAS,OAAO;EAAS,UAAU;EAAK,QAAQ,CAAC,SAAS,SAAS;CAAE;CAC5E;EACE,KAAK;EACL,OAAO;EACP,UAAU;EACV,QAAQ;GAAC;GAAa;GAAQ;GAAW;GAAW;EAAM;CAC5D;CACA;EAAE,KAAK;EAAO,OAAO;EAAO,UAAU;EAAK,QAAQ,CAAC,OAAO,QAAQ;CAAE;CACrE;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;CAAI;CAE5C;EAAE,KAAK;EAAU,OAAO;EAAe,UAAU;CAAG;CAEpD;EAAE,KAAK;EAAmB,OAAO;EAAS,UAAU;CAAG;CAEvD;EAAE,KAAK;EAAa,OAAO;EAAa,UAAU;CAAG;CAErD;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,QAAQ,MAAM;CAAE;CACtE;EAAE,KAAK;EAAW,OAAO;EAAW,UAAU;CAAI;AACpD;AAEA,MAAa,iBAAgD;CAC3D,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;;;;AAMA,MAAa,8BAAiC,IAAI,IAAU;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAsD;CACjE,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR"}
|
|
1
|
+
{"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM',\n KeyI: 'EYEDROPPER'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE3C;EAAE,KAAK;EAAU,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,UAAU,OAAO;CAAE;CAC3E;EAAE,KAAK;EAAS,OAAO;EAAS,UAAU;EAAK,QAAQ,CAAC,SAAS,SAAS;CAAE;CAC5E;EACE,KAAK;EACL,OAAO;EACP,UAAU;EACV,QAAQ;GAAC;GAAa;GAAQ;GAAW;GAAW;EAAM;CAC5D;CACA;EAAE,KAAK;EAAO,OAAO;EAAO,UAAU;EAAK,QAAQ,CAAC,OAAO,QAAQ;CAAE;CACrE;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;CAAI;CAE5C;EAAE,KAAK;EAAU,OAAO;EAAe,UAAU;CAAG;CAEpD;EAAE,KAAK;EAAmB,OAAO;EAAS,UAAU;CAAG;CAEvD;EAAE,KAAK;EAAa,OAAO;EAAa,UAAU;CAAG;CAErD;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,QAAQ,MAAM;CAAE;CACtE;EAAE,KAAK;EAAW,OAAO;EAAW,UAAU;CAAI;AACpD;AAEA,MAAa,iBAAgD;CAC3D,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;;;;AAMA,MAAa,8BAAiC,IAAI,IAAU;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAsD;CACjE,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR"}
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -26,7 +26,9 @@ type Tool = 'SELECT' | 'FRAME' | 'SECTION' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' |
|
|
|
26
26
|
/** Figma's Z: a click zooms in, ⌥ and a click out, and a drag zooms to the dragged area. */
|
|
27
27
|
'ZOOM' |
|
|
28
28
|
/** Figma's K: handles scale layers with their text, strokes, effects, and spacing. */
|
|
29
|
-
'SCALE'
|
|
29
|
+
'SCALE' |
|
|
30
|
+
/** Figma's I: samples the colour the document shows at the pointer into the selection. */
|
|
31
|
+
'EYEDROPPER';
|
|
30
32
|
/** The gradient whose handles the canvas shows while its paint picker is open. */
|
|
31
33
|
interface GradientEdit {
|
|
32
34
|
nodeId: string;
|
|
@@ -156,6 +158,8 @@ interface EditorViewState {
|
|
|
156
158
|
autoLayoutHover: {
|
|
157
159
|
nodeId: string;
|
|
158
160
|
kind: 'frame' | 'children' | 'spacing' | 'spacing-value' | 'padding' | 'padding-value';
|
|
161
|
+
/** For a gap: the flow axis whose spacing it edits. */
|
|
162
|
+
axis?: 'primary' | 'counter';
|
|
159
163
|
index?: number;
|
|
160
164
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
161
165
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/editor/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAsCY
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/editor/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAsCY;;;;;;;;UAyBK;EACf;EACA;EACA;;EAEA;;;UAIe;EACf;;EAEA;;;UAIe;EACf;;EAEA;;EAEA,QAAQ;;EAER;;EAEA,SAAS;;UAGM;EACf,YAAY;;EAEZ,mBAAmB;;;;;;EAMnB,cAAc;EACd,kBAAkB;EAClB,qBAAqB;;EAErB;;EAEA,eAAe;;EAEf,YAAY;EACZ,iBAAiB;EACjB;;EAEA,sBAAsB;;EAEtB;EACA,aAAa;;EAEb,iBAAiB;;EAEjB,QAAQ;;EAER;;;;;EAKA;;;;;;UAOe;EACf,SAAS;;EAET;;EAEA,UAAU;IAAQ;IAAe;;;UAGlB;EACf,QAAQ;;EAER;;EAEA;IAAW,OAAO;IAAO;;;UAGV;EACf;EACA,aAAa;EACb,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,iBAAiB;EACjB;EACA;IACE;IAC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B;;UAGe;MACX,SAAS;MACT,MAAM,GAAG;EACb,MAAM;;EAEN,WAAW,OAAO,YAAY,OAAO;EACrC,OAAO;EACP,WACE,gBACA,eACA,qBACA,SAAS,gBACN,QAAQ;EACb,6BAA6B;EAC7B;IAAyB;IAAe;;EACxC,yBAAyB;EACzB;EACA,OAAO;EACP,aAAa;EACb,mBAAmB;;EAEnB,oBAAoB,SAAS;EAC7B,qBAAqB;EACrB;;EAEA;EACA;EACA;EACA,gBAAgB,UAAU,iBAAiB,OAAO,GAAG,SAAS,aAAa;EAC3E,kBAAkB,UAAU,iBAC1B,OAAO,MACJ,MAAM,WAAW,aAAa;EAEnC,iBAAiB,KAAK;EACtB,gBAAgB,MAAM;EACtB,qBAAqB,OAAO,iBAAiB;EAC7C,mBAAmB;EACnB,sBAAsB,WAAW;EACjC,wBAAwB,GACtB,iBAAiB,IAAI,QAAQ,IAC7B,qBAEA;;EAAA,gBAAgB,QAAQ,GAAG,QAAQ,wBAAwB,yBACxD,QAAQ;EACb"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/editor/variations/create.d.ts
|
|
3
|
+
/** Room around the versions inside their section, and between them. */
|
|
4
|
+
declare const VARIATION_SECTION_PADDING = 80;
|
|
5
|
+
declare const VARIATION_GAP = 80;
|
|
6
|
+
interface VariationRequest {
|
|
7
|
+
/** How many versions to make, 1 to {@link VARIATION_MAX_COUNT}. */
|
|
8
|
+
count: number;
|
|
9
|
+
/** What each version tries, named in its layer: `V2 · Calmer palette`. */
|
|
10
|
+
labels?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
interface CreatedVariations {
|
|
13
|
+
sectionId: string;
|
|
14
|
+
originalId: string;
|
|
15
|
+
/** The versions this request made, in order. */
|
|
16
|
+
versions: SceneNode[];
|
|
17
|
+
}
|
|
18
|
+
/** Why `nodeId` cannot be varied, or null when it can. */
|
|
19
|
+
declare function variationRefusal(graph: SceneGraph, nodeId: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Copies a layer `request.count` times into the section of variations beside it, made the first
|
|
22
|
+
* time, in a row after the versions already there. On a version, it copies that version into
|
|
23
|
+
* its own set. The original is not changed. The caller records the edit as one step.
|
|
24
|
+
*/
|
|
25
|
+
declare function createVariations(graph: SceneGraph, nodeId: string, request: VariationRequest): CreatedVariations;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { CreatedVariations, VARIATION_GAP, VARIATION_SECTION_PADDING, VariationRequest, createVariations, variationRefusal };
|
|
28
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","names":[],"sources":["../../../src/editor/variations/create.ts"],"mappings":";;;cAsBa;cACA;UAEI;;EAEf;;EAEA;;UAGe;EACf;EACA;;EAEA,UAAU;;;iBA2CI,iBAAiB,OAAO,YAAY;;;;;;iBA0GpC,iBACd,OAAO,YACP,gBACA,SAAS,mBACR"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { getNodeEditCapability } from "../capabilities.js";
|
|
2
|
+
import { findEmptySpace, rectsOverlap } from "../../tools/read/space.js";
|
|
3
|
+
import { getAxisAlignedBoundsInParent } from "@pairdraw/scene-graph/coordinate";
|
|
4
|
+
import { resolvedVariableModes } from "@pairdraw/scene-graph/variables";
|
|
5
|
+
import { findInstanceAncestor } from "@pairdraw/scene-graph/instances";
|
|
6
|
+
import { VARIATION_LABEL_MAX_LENGTH, VARIATION_MAX_COUNT, VARIATION_MAX_LAYERS, copyVersion, readVariationSet, variationFingerprint, variationSetForOriginal, variationSetOf, versionOf, withVariationSet } from "@pairdraw/scene-graph/variations";
|
|
7
|
+
//#region src/editor/variations/create.ts
|
|
8
|
+
/** Room around the versions inside their section, and between them. */
|
|
9
|
+
const VARIATION_SECTION_PADDING = 80;
|
|
10
|
+
const VARIATION_GAP = 80;
|
|
11
|
+
const SECTION_REFUSAL = "A section cannot be varied; select a frame inside it";
|
|
12
|
+
const UNVARIED_TYPES = {
|
|
13
|
+
CANVAS: "A page cannot be varied; select a layer on it",
|
|
14
|
+
SECTION: SECTION_REFUSAL,
|
|
15
|
+
COMPONENT_SET: "A component set cannot be varied; select one of its variants"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* What a request on `node` copies: the version holding it, or the layer itself; or why it
|
|
19
|
+
* cannot be varied.
|
|
20
|
+
*/
|
|
21
|
+
function variationSource(graph, node) {
|
|
22
|
+
const view = variationSetOf(graph, node.id);
|
|
23
|
+
if (view) {
|
|
24
|
+
const version = versionOf(graph, view, node.id);
|
|
25
|
+
if (!version) return SECTION_REFUSAL;
|
|
26
|
+
if (!view.original) return "The layer these are variations of is gone";
|
|
27
|
+
return {
|
|
28
|
+
source: version,
|
|
29
|
+
original: view.original,
|
|
30
|
+
section: view.section
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const refusal = UNVARIED_TYPES[node.type];
|
|
34
|
+
if (refusal) return refusal;
|
|
35
|
+
if (node.parentId && findInstanceAncestor(graph, node.parentId)) return "A layer inside an instance cannot be varied; vary the instance or its main component";
|
|
36
|
+
if (!getNodeEditCapability(graph, node.id).editable) return `"${node.name}" belongs to a library and cannot be changed here`;
|
|
37
|
+
return {
|
|
38
|
+
source: node,
|
|
39
|
+
original: node,
|
|
40
|
+
section: variationSetForOriginal(graph, node.id)?.section
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Why `nodeId` cannot be varied, or null when it can. */
|
|
44
|
+
function variationRefusal(graph, nodeId) {
|
|
45
|
+
const node = graph.getNode(nodeId);
|
|
46
|
+
if (!node) return `Node "${nodeId}" not found`;
|
|
47
|
+
const found = variationSource(graph, node);
|
|
48
|
+
return typeof found === "string" ? found : null;
|
|
49
|
+
}
|
|
50
|
+
function checkRequest(graph, source, request) {
|
|
51
|
+
const { count, labels = [] } = request;
|
|
52
|
+
if (!Number.isInteger(count) || count < 1 || count > VARIATION_MAX_COUNT) throw new Error(`Ask for 1 to ${VARIATION_MAX_COUNT} versions, not ${count}`);
|
|
53
|
+
if (labels.length > count) throw new Error(`${labels.length} labels for ${count} versions`);
|
|
54
|
+
const long = labels.find((label) => label.trim().length > VARIATION_LABEL_MAX_LENGTH);
|
|
55
|
+
if (long !== void 0) throw new Error(`Label "${long}" is longer than ${VARIATION_LABEL_MAX_LENGTH} characters`);
|
|
56
|
+
const layers = graph.countDescendants(source.id) + 1;
|
|
57
|
+
if (layers * count > VARIATION_MAX_LAYERS) throw new Error(`${count} copies of ${layers} layers make ${layers * count} layers, more than the ${VARIATION_MAX_LAYERS} one request may copy; ask for fewer versions or vary a smaller layer`);
|
|
58
|
+
}
|
|
59
|
+
function rowSize(width, height, count) {
|
|
60
|
+
return {
|
|
61
|
+
width: 160 + count * width + (count - 1) * 80,
|
|
62
|
+
height: 160 + height
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The page's top-level layers but `sectionId`, as boxes a section must stay clear of. */
|
|
66
|
+
function pageObstacles(graph, pageId, sectionId) {
|
|
67
|
+
return graph.getChildren(pageId).filter((node) => node.id !== sectionId).map((node) => getAxisAlignedBoundsInParent([node], pageId, graph));
|
|
68
|
+
}
|
|
69
|
+
/** The free spot of `size` nearest the original's top-level layer, right of it or below it. */
|
|
70
|
+
function spaceBeside(graph, pageId, original, size, sectionId) {
|
|
71
|
+
const topLevel = graph.closest(original.id, (node) => node.parentId === pageId) ?? original;
|
|
72
|
+
return findEmptySpace({
|
|
73
|
+
obstacles: pageObstacles(graph, pageId, sectionId),
|
|
74
|
+
...size,
|
|
75
|
+
anchor: getAxisAlignedBoundsInParent([topLevel], pageId, graph),
|
|
76
|
+
gap: 80,
|
|
77
|
+
directions: ["right", "below"]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gives the section `size`. It grows where it is while that covers no other layer on the page,
|
|
82
|
+
* and otherwise moves to the free spot nearest the original, where a new set would go.
|
|
83
|
+
*/
|
|
84
|
+
function fitSection(graph, section, original, size) {
|
|
85
|
+
const pageId = section.parentId;
|
|
86
|
+
if (!pageId) return;
|
|
87
|
+
const grown = {
|
|
88
|
+
x: section.x,
|
|
89
|
+
y: section.y,
|
|
90
|
+
...size
|
|
91
|
+
};
|
|
92
|
+
const space = pageObstacles(graph, pageId, section.id).some((box) => rectsOverlap(grown, box, 0)) ? spaceBeside(graph, pageId, original, size, section.id) : grown;
|
|
93
|
+
graph.updateNode(section.id, {
|
|
94
|
+
x: space.x,
|
|
95
|
+
y: space.y,
|
|
96
|
+
...size
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** A new marked section beside the original's top-level layer, sized for `count` copies. */
|
|
100
|
+
function createSection(graph, original, source, count) {
|
|
101
|
+
const pageId = graph.pageOf(original.id);
|
|
102
|
+
if (!pageId) throw new Error(`"${original.name}" is on no page`);
|
|
103
|
+
const size = rowSize(source.width, source.height, count);
|
|
104
|
+
const space = spaceBeside(graph, pageId, original, size);
|
|
105
|
+
const section = graph.createNode("SECTION", pageId, {
|
|
106
|
+
name: `Variations · ${original.name}`,
|
|
107
|
+
x: space.x,
|
|
108
|
+
y: space.y,
|
|
109
|
+
...size,
|
|
110
|
+
variableModes: original.parentId ? resolvedVariableModes(graph, original.parentId) : {}
|
|
111
|
+
});
|
|
112
|
+
graph.updateNode(section.id, { pluginData: withVariationSet(section, {
|
|
113
|
+
version: 1,
|
|
114
|
+
originalId: original.id,
|
|
115
|
+
originalFingerprint: variationFingerprint(graph, original.id)
|
|
116
|
+
}) });
|
|
117
|
+
return section;
|
|
118
|
+
}
|
|
119
|
+
function versionName(index, label) {
|
|
120
|
+
const text = label?.trim();
|
|
121
|
+
return text ? `V${index} · ${text}` : `V${index}`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Copies a layer `request.count` times into the section of variations beside it, made the first
|
|
125
|
+
* time, in a row after the versions already there. On a version, it copies that version into
|
|
126
|
+
* its own set. The original is not changed. The caller records the edit as one step.
|
|
127
|
+
*/
|
|
128
|
+
function createVariations(graph, nodeId, request) {
|
|
129
|
+
const node = graph.getNode(nodeId);
|
|
130
|
+
if (!node) throw new Error(`Node "${nodeId}" not found`);
|
|
131
|
+
const found = variationSource(graph, node);
|
|
132
|
+
if (typeof found === "string") throw new Error(found);
|
|
133
|
+
const { source, original } = found;
|
|
134
|
+
checkRequest(graph, source, request);
|
|
135
|
+
const section = found.section ?? createSection(graph, original, source, request.count);
|
|
136
|
+
const set = found.section ? readVariationSet(found.section) : null;
|
|
137
|
+
if (set) {
|
|
138
|
+
const originalFingerprint = variationFingerprint(graph, original.id);
|
|
139
|
+
graph.updateNode(section.id, { pluginData: withVariationSet(section, {
|
|
140
|
+
...set,
|
|
141
|
+
originalFingerprint
|
|
142
|
+
}) });
|
|
143
|
+
}
|
|
144
|
+
const existing = graph.getChildren(section.id);
|
|
145
|
+
const right = Math.max(0, ...existing.map((version) => version.x + version.width));
|
|
146
|
+
const versions = [];
|
|
147
|
+
for (let index = 0; index < request.count; index++) {
|
|
148
|
+
const copy = copyVersion(graph, source.id, section.id, {
|
|
149
|
+
name: versionName(existing.length + index + 1, request.labels?.[index]),
|
|
150
|
+
x: right + 80 + index * (source.width + 80),
|
|
151
|
+
y: 80,
|
|
152
|
+
rotation: 0,
|
|
153
|
+
visible: true,
|
|
154
|
+
locked: false
|
|
155
|
+
});
|
|
156
|
+
if (!copy) continue;
|
|
157
|
+
versions.push(copy);
|
|
158
|
+
}
|
|
159
|
+
const last = versions.at(-1);
|
|
160
|
+
if (last) {
|
|
161
|
+
const bottom = Math.max(...graph.getChildren(section.id).map((v) => v.y + v.height));
|
|
162
|
+
fitSection(graph, section, original, {
|
|
163
|
+
width: Math.max(section.width, last.x + last.width + 80),
|
|
164
|
+
height: Math.max(section.height, bottom + 80)
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
sectionId: section.id,
|
|
169
|
+
originalId: original.id,
|
|
170
|
+
versions
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
export { VARIATION_GAP, VARIATION_SECTION_PADDING, createVariations, variationRefusal };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","names":[],"sources":["../../../src/editor/variations/create.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { getAxisAlignedBoundsInParent } from '@pairdraw/scene-graph/coordinate'\nimport { findInstanceAncestor } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Size } from '@pairdraw/scene-graph/primitives'\nimport { resolvedVariableModes } from '@pairdraw/scene-graph/variables'\nimport {\n VARIATION_LABEL_MAX_LENGTH,\n VARIATION_MAX_COUNT,\n VARIATION_MAX_LAYERS,\n copyVersion,\n readVariationSet,\n variationFingerprint,\n variationSetForOriginal,\n variationSetOf,\n versionOf,\n withVariationSet\n} from '@pairdraw/scene-graph/variations'\n\nimport { getNodeEditCapability } from '#core/editor/capabilities'\nimport { findEmptySpace, rectsOverlap } from '#core/tools/read/space'\n\n/** Room around the versions inside their section, and between them. */\nexport const VARIATION_SECTION_PADDING = 80\nexport const VARIATION_GAP = 80\n\nexport interface VariationRequest {\n /** How many versions to make, 1 to {@link VARIATION_MAX_COUNT}. */\n count: number\n /** What each version tries, named in its layer: `V2 · Calmer palette`. */\n labels?: readonly string[]\n}\n\nexport interface CreatedVariations {\n sectionId: string\n originalId: string\n /** The versions this request made, in order. */\n versions: SceneNode[]\n}\n\nconst SECTION_REFUSAL = 'A section cannot be varied; select a frame inside it'\n\nconst UNVARIED_TYPES: Partial<Record<SceneNode['type'], string>> = {\n CANVAS: 'A page cannot be varied; select a layer on it',\n SECTION: SECTION_REFUSAL,\n COMPONENT_SET: 'A component set cannot be varied; select one of its variants'\n}\n\ninterface VariationSource {\n /** The layer the versions copy: the original, or one of its versions. */\n source: SceneNode\n original: SceneNode\n /** The set the versions join, or undefined when the request makes it. */\n section: SceneNode | undefined\n}\n\n/**\n * What a request on `node` copies: the version holding it, or the layer itself; or why it\n * cannot be varied.\n */\nfunction variationSource(graph: SceneGraph, node: SceneNode): VariationSource | string {\n const view = variationSetOf(graph, node.id)\n if (view) {\n const version = versionOf(graph, view, node.id)\n if (!version) return SECTION_REFUSAL\n if (!view.original) return 'The layer these are variations of is gone'\n return { source: version, original: view.original, section: view.section }\n }\n const refusal = UNVARIED_TYPES[node.type]\n if (refusal) return refusal\n if (node.parentId && findInstanceAncestor(graph, node.parentId)) {\n return 'A layer inside an instance cannot be varied; vary the instance or its main component'\n }\n if (!getNodeEditCapability(graph, node.id).editable) {\n return `\"${node.name}\" belongs to a library and cannot be changed here`\n }\n return { source: node, original: node, section: variationSetForOriginal(graph, node.id)?.section }\n}\n\n/** Why `nodeId` cannot be varied, or null when it can. */\nexport function variationRefusal(graph: SceneGraph, nodeId: string): string | null {\n const node = graph.getNode(nodeId)\n if (!node) return `Node \"${nodeId}\" not found`\n const found = variationSource(graph, node)\n return typeof found === 'string' ? found : null\n}\n\nfunction checkRequest(graph: SceneGraph, source: SceneNode, request: VariationRequest) {\n const { count, labels = [] } = request\n if (!Number.isInteger(count) || count < 1 || count > VARIATION_MAX_COUNT) {\n throw new Error(`Ask for 1 to ${VARIATION_MAX_COUNT} versions, not ${count}`)\n }\n if (labels.length > count) throw new Error(`${labels.length} labels for ${count} versions`)\n const long = labels.find((label) => label.trim().length > VARIATION_LABEL_MAX_LENGTH)\n if (long !== undefined) {\n throw new Error(`Label \"${long}\" is longer than ${VARIATION_LABEL_MAX_LENGTH} characters`)\n }\n const layers = graph.countDescendants(source.id) + 1\n if (layers * count > VARIATION_MAX_LAYERS) {\n throw new Error(\n `${count} copies of ${layers} layers make ${layers * count} layers, more than the ` +\n `${VARIATION_MAX_LAYERS} one request may copy; ask for fewer versions or vary a smaller layer`\n )\n }\n}\n\nfunction rowSize(width: number, height: number, count: number) {\n return {\n width: VARIATION_SECTION_PADDING * 2 + count * width + (count - 1) * VARIATION_GAP,\n height: VARIATION_SECTION_PADDING * 2 + height\n }\n}\n\n/** The page's top-level layers but `sectionId`, as boxes a section must stay clear of. */\nfunction pageObstacles(graph: SceneGraph, pageId: string, sectionId?: string): Rect[] {\n return graph\n .getChildren(pageId)\n .filter((node) => node.id !== sectionId)\n .map((node) => getAxisAlignedBoundsInParent([node], pageId, graph))\n}\n\n/** The free spot of `size` nearest the original's top-level layer, right of it or below it. */\nfunction spaceBeside(\n graph: SceneGraph,\n pageId: string,\n original: SceneNode,\n size: Size,\n sectionId?: string\n) {\n const topLevel = graph.closest(original.id, (node) => node.parentId === pageId) ?? original\n return findEmptySpace({\n obstacles: pageObstacles(graph, pageId, sectionId),\n ...size,\n anchor: getAxisAlignedBoundsInParent([topLevel], pageId, graph),\n gap: VARIATION_GAP,\n directions: ['right', 'below']\n })\n}\n\n/**\n * Gives the section `size`. It grows where it is while that covers no other layer on the page,\n * and otherwise moves to the free spot nearest the original, where a new set would go.\n */\nfunction fitSection(graph: SceneGraph, section: SceneNode, original: SceneNode, size: Size) {\n const pageId = section.parentId\n if (!pageId) return\n const grown = { x: section.x, y: section.y, ...size }\n const covers = pageObstacles(graph, pageId, section.id).some((box) => rectsOverlap(grown, box, 0))\n const space = covers ? spaceBeside(graph, pageId, original, size, section.id) : grown\n graph.updateNode(section.id, { x: space.x, y: space.y, ...size })\n}\n\n/** A new marked section beside the original's top-level layer, sized for `count` copies. */\nfunction createSection(graph: SceneGraph, original: SceneNode, source: SceneNode, count: number) {\n const pageId = graph.pageOf(original.id)\n if (!pageId) throw new Error(`\"${original.name}\" is on no page`)\n const size = rowSize(source.width, source.height, count)\n const space = spaceBeside(graph, pageId, original, size)\n const section = graph.createNode('SECTION', pageId, {\n name: `Variations · ${original.name}`,\n x: space.x,\n y: space.y,\n ...size,\n // The copies show in the modes the original shows in from its ancestors.\n variableModes: original.parentId ? resolvedVariableModes(graph, original.parentId) : {}\n })\n graph.updateNode(section.id, {\n pluginData: withVariationSet(section, {\n version: 1,\n originalId: original.id,\n originalFingerprint: variationFingerprint(graph, original.id)\n })\n })\n return section\n}\n\nfunction versionName(index: number, label: string | undefined): string {\n const text = label?.trim()\n return text ? `V${index} · ${text}` : `V${index}`\n}\n\n/**\n * Copies a layer `request.count` times into the section of variations beside it, made the first\n * time, in a row after the versions already there. On a version, it copies that version into\n * its own set. The original is not changed. The caller records the edit as one step.\n */\nexport function createVariations(\n graph: SceneGraph,\n nodeId: string,\n request: VariationRequest\n): CreatedVariations {\n const node = graph.getNode(nodeId)\n if (!node) throw new Error(`Node \"${nodeId}\" not found`)\n const found = variationSource(graph, node)\n if (typeof found === 'string') throw new Error(found)\n const { source, original } = found\n checkRequest(graph, source, request)\n const section = found.section ?? createSection(graph, original, source, request.count)\n const set = found.section ? readVariationSet(found.section) : null\n if (set) {\n // The newest versions start from the original as it is now.\n const originalFingerprint = variationFingerprint(graph, original.id)\n graph.updateNode(section.id, {\n pluginData: withVariationSet(section, { ...set, originalFingerprint })\n })\n }\n\n const existing = graph.getChildren(section.id)\n const right = Math.max(\n VARIATION_SECTION_PADDING - VARIATION_GAP,\n ...existing.map((version) => version.x + version.width)\n )\n const versions: SceneNode[] = []\n for (let index = 0; index < request.count; index++) {\n const copy = copyVersion(graph, source.id, section.id, {\n name: versionName(existing.length + index + 1, request.labels?.[index]),\n x: right + VARIATION_GAP + index * (source.width + VARIATION_GAP),\n y: VARIATION_SECTION_PADDING,\n rotation: 0,\n visible: true,\n locked: false\n })\n if (!copy) continue\n versions.push(copy)\n }\n\n const last = versions.at(-1)\n if (last) {\n const bottom = Math.max(...graph.getChildren(section.id).map((v) => v.y + v.height))\n fitSection(graph, section, original, {\n width: Math.max(section.width, last.x + last.width + VARIATION_SECTION_PADDING),\n height: Math.max(section.height, bottom + VARIATION_SECTION_PADDING)\n })\n }\n return { sectionId: section.id, originalId: original.id, versions }\n}\n"],"mappings":";;;;;;;;AAsBA,MAAa,4BAA4B;AACz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/variations";
|
|
3
|
+
//#region src/editor/variations/pick.d.ts
|
|
4
|
+
/** Why a version cannot replace its original, including an original a library owns. */
|
|
5
|
+
type PickProblem = VariationPickProblem | 'original-not-editable';
|
|
6
|
+
/** Why `versionId` cannot replace the original of `view`, or null when it can. */
|
|
7
|
+
declare function pickProblemOf(graph: SceneGraph, view: VariationSetView, versionId: string): PickProblem | null;
|
|
8
|
+
/**
|
|
9
|
+
* Throws the reason `versionId` cannot replace its original, before anything changes: a layer
|
|
10
|
+
* outside a set, the section itself, or an original that is gone, locked, inside an instance,
|
|
11
|
+
* of another type than the version, or owned by a library.
|
|
12
|
+
*/
|
|
13
|
+
declare function assertVariationPickable(graph: SceneGraph, versionId: string): void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PickProblem, assertVariationPickable, pickProblemOf };
|
|
16
|
+
//# sourceMappingURL=pick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.d.ts","names":[],"sources":["../../../src/editor/variations/pick.ts"],"mappings":";;;;KAYY,cAAc;;iBAGV,cACd,OAAO,YACP,MAAM,kBACN,oBACC;;;;;;iBAWa,wBAAwB,OAAO,YAAY"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { assertNodeEditable, getNodeEditCapability } from "../capabilities.js";
|
|
2
|
+
import { VariationError, variationPickProblem, variationToPick } from "@pairdraw/scene-graph/variations";
|
|
3
|
+
//#region src/editor/variations/pick.ts
|
|
4
|
+
/** Why `versionId` cannot replace the original of `view`, or null when it can. */
|
|
5
|
+
function pickProblemOf(graph, view, versionId) {
|
|
6
|
+
const problem = variationPickProblem(graph, view, versionId);
|
|
7
|
+
if (problem || !view.original) return problem;
|
|
8
|
+
return getNodeEditCapability(graph, view.original.id).editable ? null : "original-not-editable";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Throws the reason `versionId` cannot replace its original, before anything changes: a layer
|
|
12
|
+
* outside a set, the section itself, or an original that is gone, locked, inside an instance,
|
|
13
|
+
* of another type than the version, or owned by a library.
|
|
14
|
+
*/
|
|
15
|
+
function assertVariationPickable(graph, versionId) {
|
|
16
|
+
const { view, problem } = variationToPick(graph, versionId);
|
|
17
|
+
if (problem) throw new VariationError(problem, versionId);
|
|
18
|
+
if (view.original) assertNodeEditable(graph, view.original.id);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { assertVariationPickable, pickProblemOf };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=pick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.js","names":[],"sources":["../../../src/editor/variations/pick.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n VariationError,\n variationPickProblem,\n variationToPick,\n type VariationPickProblem,\n type VariationSetView\n} from '@pairdraw/scene-graph/variations'\n\nimport { assertNodeEditable, getNodeEditCapability } from '#core/editor/capabilities'\n\n/** Why a version cannot replace its original, including an original a library owns. */\nexport type PickProblem = VariationPickProblem | 'original-not-editable'\n\n/** Why `versionId` cannot replace the original of `view`, or null when it can. */\nexport function pickProblemOf(\n graph: SceneGraph,\n view: VariationSetView,\n versionId: string\n): PickProblem | null {\n const problem = variationPickProblem(graph, view, versionId)\n if (problem || !view.original) return problem\n return getNodeEditCapability(graph, view.original.id).editable ? null : 'original-not-editable'\n}\n\n/**\n * Throws the reason `versionId` cannot replace its original, before anything changes: a layer\n * outside a set, the section itself, or an original that is gone, locked, inside an instance,\n * of another type than the version, or owned by a library.\n */\nexport function assertVariationPickable(graph: SceneGraph, versionId: string): void {\n const { view, problem } = variationToPick(graph, versionId)\n if (problem) throw new VariationError(problem, versionId)\n if (view.original) assertNodeEditable(graph, view.original.id)\n}\n"],"mappings":";;;;AAeA,SAAgB,cACd,OACA,MACA,WACoB;CACpB,MAAM,UAAU,qBAAqB,OAAO,MAAM,SAAS;CAC3D,IAAI,WAAW,CAAC,KAAK,UAAU,OAAO;CACtC,OAAO,sBAAsB,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,WAAW,OAAO;AAC1E;;;;;;AAOA,SAAgB,wBAAwB,OAAmB,WAAyB;CAClF,MAAM,EAAE,MAAM,YAAY,gBAAgB,OAAO,SAAS;CAC1D,IAAI,SAAS,MAAM,IAAI,eAAe,SAAS,SAAS;CACxD,IAAI,KAAK,UAAU,mBAAmB,OAAO,KAAK,SAAS,EAAE;AAC/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EditorContext } from "./types.js";
|
|
2
|
+
import { CreatedVariations, VariationRequest } from "./variations/create.js";
|
|
3
|
+
import { PickProblem } from "./variations/pick.js";
|
|
4
|
+
import { VariationSetView } from "@pairdraw/scene-graph/variations";
|
|
5
|
+
//#region src/editor/variations.d.ts
|
|
6
|
+
/** A set of variations as panels show it, from wherever in it the selection is. */
|
|
7
|
+
interface VariationSetState extends VariationSetView {
|
|
8
|
+
/** The version holding the layer asked about, or null for the section itself. */
|
|
9
|
+
version: VariationSetView['versions'][number] | null;
|
|
10
|
+
/** Why that version cannot replace the original, or null when it can. */
|
|
11
|
+
pickProblem: PickProblem | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sets of variations: copies of a layer side by side in a section beside it, one of which can
|
|
15
|
+
* replace it. Each command is one undo step.
|
|
16
|
+
*/
|
|
17
|
+
declare function createVariationActions(ctx: EditorContext): {
|
|
18
|
+
getVariationSet: (nodeId: string) => VariationSetState | null;
|
|
19
|
+
isVariationOriginalChanged: (nodeId: string) => boolean;
|
|
20
|
+
canCreateVariations: (nodeId: string) => boolean;
|
|
21
|
+
createVariations: (nodeId: string, request: VariationRequest) => CreatedVariations;
|
|
22
|
+
duplicateAsVariation: (nodeId: string) => CreatedVariations;
|
|
23
|
+
pickVariation: (versionId: string) => string;
|
|
24
|
+
discardVariations: (nodeId: string) => string | null;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { VariationSetState, createVariationActions };
|
|
28
|
+
//# sourceMappingURL=variations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variations.d.ts","names":[],"sources":["../../src/editor/variations.ts"],"mappings":";;;;;;UAoBiB,0BAA0B;;EAEzC,SAAS;;EAET,aAAa;;;;;;iBAOC,uBAAuB,KAAK;EAET,kBAAA,mBAAS;EAgBE,6BAAA;EAMP,sBAAA;EAKD,mBAAA,gBAAM,SAAW,qBAAmB;EASlC,uBAAA,mBAAS;EAOb,gBAAA;EAaC,oBAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { recordEdit } from "./history/edit.js";
|
|
2
|
+
import { createVariations, variationRefusal } from "./variations/create.js";
|
|
3
|
+
import { assertVariationPickable, pickProblemOf } from "./variations/pick.js";
|
|
4
|
+
import { applyVariation, discardVariations, originalChangedSince, variationSetOf, versionOf } from "@pairdraw/scene-graph/variations";
|
|
5
|
+
//#region src/editor/variations.ts
|
|
6
|
+
/**
|
|
7
|
+
* Sets of variations: copies of a layer side by side in a section beside it, one of which can
|
|
8
|
+
* replace it. Each command is one undo step.
|
|
9
|
+
*/
|
|
10
|
+
function createVariationActions(ctx) {
|
|
11
|
+
/** The set `nodeId` belongs to, with the version holding it, or null outside every set. */
|
|
12
|
+
function getVariationSet(nodeId) {
|
|
13
|
+
const view = variationSetOf(ctx.graph, nodeId);
|
|
14
|
+
if (!view) return null;
|
|
15
|
+
const version = versionOf(ctx.graph, view, nodeId);
|
|
16
|
+
return {
|
|
17
|
+
...view,
|
|
18
|
+
version,
|
|
19
|
+
pickProblem: version ? pickProblemOf(ctx.graph, view, version.id) : "not-a-version"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the original of the set holding `nodeId` looks different from when its newest
|
|
24
|
+
* versions were made. It walks the original's layers, so panels ask when they show a set
|
|
25
|
+
* rather than on every edit.
|
|
26
|
+
*/
|
|
27
|
+
function isVariationOriginalChanged(nodeId) {
|
|
28
|
+
const view = variationSetOf(ctx.graph, nodeId);
|
|
29
|
+
return view ? originalChangedSince(ctx.graph, view) : false;
|
|
30
|
+
}
|
|
31
|
+
/** Whether `nodeId` can be varied: copied into a set of variations beside it. */
|
|
32
|
+
function canCreateVariations(nodeId) {
|
|
33
|
+
return variationRefusal(ctx.graph, nodeId) === null;
|
|
34
|
+
}
|
|
35
|
+
/** Copies `nodeId` into its set of variations, as `create_variations` does. */
|
|
36
|
+
function createVariationsOf(nodeId, request) {
|
|
37
|
+
const created = recordEdit(ctx, {
|
|
38
|
+
label: "Create variations",
|
|
39
|
+
rollbackOnThrow: true
|
|
40
|
+
}, () => createVariations(ctx.graph, nodeId, request));
|
|
41
|
+
ctx.requestRender();
|
|
42
|
+
return created;
|
|
43
|
+
}
|
|
44
|
+
/** One plain copy of `nodeId` in its set, selected, for a person to change by hand. */
|
|
45
|
+
function duplicateAsVariation(nodeId) {
|
|
46
|
+
const created = createVariationsOf(nodeId, { count: 1 });
|
|
47
|
+
ctx.setSelectedIds(new Set(created.versions.map((version) => version.id)));
|
|
48
|
+
return created;
|
|
49
|
+
}
|
|
50
|
+
/** Makes the original look like the version holding `versionId` and removes the set. */
|
|
51
|
+
function pickVariation(versionId) {
|
|
52
|
+
assertVariationPickable(ctx.graph, versionId);
|
|
53
|
+
const originalId = recordEdit(ctx, {
|
|
54
|
+
label: "Use variation",
|
|
55
|
+
rollbackOnThrow: true
|
|
56
|
+
}, () => {
|
|
57
|
+
const picked = applyVariation(ctx.graph, versionId);
|
|
58
|
+
ctx.runLayoutForNode(picked.originalId);
|
|
59
|
+
return picked.originalId;
|
|
60
|
+
});
|
|
61
|
+
ctx.setSelectedIds(/* @__PURE__ */ new Set([originalId]));
|
|
62
|
+
ctx.requestRender();
|
|
63
|
+
return originalId;
|
|
64
|
+
}
|
|
65
|
+
/** Removes the set holding `nodeId` and selects its original, when it is still there. */
|
|
66
|
+
function discardVariations$1(nodeId) {
|
|
67
|
+
const { originalId } = recordEdit(ctx, {
|
|
68
|
+
label: "Discard variations",
|
|
69
|
+
rollbackOnThrow: true
|
|
70
|
+
}, () => discardVariations(ctx.graph, nodeId));
|
|
71
|
+
ctx.setSelectedIds(new Set(originalId ? [originalId] : []));
|
|
72
|
+
ctx.requestRender();
|
|
73
|
+
return originalId;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
getVariationSet,
|
|
77
|
+
isVariationOriginalChanged,
|
|
78
|
+
canCreateVariations,
|
|
79
|
+
createVariations: createVariationsOf,
|
|
80
|
+
duplicateAsVariation,
|
|
81
|
+
pickVariation,
|
|
82
|
+
discardVariations: discardVariations$1
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createVariationActions };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variations.js","names":["discardVariations","discardVariationSet"],"sources":["../../src/editor/variations.ts"],"sourcesContent":["import {\n applyVariation,\n discardVariations as discardVariationSet,\n originalChangedSince,\n variationSetOf,\n versionOf,\n type VariationSetView\n} from '@pairdraw/scene-graph/variations'\n\nimport { recordEdit } from './history/edit'\nimport type { EditorContext } from './types'\nimport {\n createVariations,\n variationRefusal,\n type CreatedVariations,\n type VariationRequest\n} from './variations/create'\nimport { assertVariationPickable, pickProblemOf, type PickProblem } from './variations/pick'\n\n/** A set of variations as panels show it, from wherever in it the selection is. */\nexport interface VariationSetState extends VariationSetView {\n /** The version holding the layer asked about, or null for the section itself. */\n version: VariationSetView['versions'][number] | null\n /** Why that version cannot replace the original, or null when it can. */\n pickProblem: PickProblem | null\n}\n\n/**\n * Sets of variations: copies of a layer side by side in a section beside it, one of which can\n * replace it. Each command is one undo step.\n */\nexport function createVariationActions(ctx: EditorContext) {\n /** The set `nodeId` belongs to, with the version holding it, or null outside every set. */\n function getVariationSet(nodeId: string): VariationSetState | null {\n const view = variationSetOf(ctx.graph, nodeId)\n if (!view) return null\n const version = versionOf(ctx.graph, view, nodeId)\n return {\n ...view,\n version,\n pickProblem: version ? pickProblemOf(ctx.graph, view, version.id) : 'not-a-version'\n }\n }\n\n /**\n * Whether the original of the set holding `nodeId` looks different from when its newest\n * versions were made. It walks the original's layers, so panels ask when they show a set\n * rather than on every edit.\n */\n function isVariationOriginalChanged(nodeId: string): boolean {\n const view = variationSetOf(ctx.graph, nodeId)\n return view ? originalChangedSince(ctx.graph, view) : false\n }\n\n /** Whether `nodeId` can be varied: copied into a set of variations beside it. */\n function canCreateVariations(nodeId: string): boolean {\n return variationRefusal(ctx.graph, nodeId) === null\n }\n\n /** Copies `nodeId` into its set of variations, as `create_variations` does. */\n function createVariationsOf(nodeId: string, request: VariationRequest): CreatedVariations {\n const created = recordEdit(ctx, { label: 'Create variations', rollbackOnThrow: true }, () =>\n createVariations(ctx.graph, nodeId, request)\n )\n ctx.requestRender()\n return created\n }\n\n /** One plain copy of `nodeId` in its set, selected, for a person to change by hand. */\n function duplicateAsVariation(nodeId: string): CreatedVariations {\n const created = createVariationsOf(nodeId, { count: 1 })\n ctx.setSelectedIds(new Set(created.versions.map((version) => version.id)))\n return created\n }\n\n /** Makes the original look like the version holding `versionId` and removes the set. */\n function pickVariation(versionId: string): string {\n assertVariationPickable(ctx.graph, versionId)\n const originalId = recordEdit(ctx, { label: 'Use variation', rollbackOnThrow: true }, () => {\n const picked = applyVariation(ctx.graph, versionId)\n ctx.runLayoutForNode(picked.originalId)\n return picked.originalId\n })\n ctx.setSelectedIds(new Set([originalId]))\n ctx.requestRender()\n return originalId\n }\n\n /** Removes the set holding `nodeId` and selects its original, when it is still there. */\n function discardVariations(nodeId: string): string | null {\n const { originalId } = recordEdit(\n ctx,\n { label: 'Discard variations', rollbackOnThrow: true },\n () => discardVariationSet(ctx.graph, nodeId)\n )\n ctx.setSelectedIds(new Set(originalId ? [originalId] : []))\n ctx.requestRender()\n return originalId\n }\n\n return {\n getVariationSet,\n isVariationOriginalChanged,\n canCreateVariations,\n createVariations: createVariation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c;EAClB,OAAO;CACT;;CAGA,SAASA,oBAAkB,QAA+B;EACxD,MAAM,EAAE,eAAe,WACrB,KACA;GAAE,OAAO;GAAsB,iBAAiB;EAAK,SAC/CC,kBAAoB,IAAI,OAAO,MAAM,CAC7C;EACA,IAAI,eAAe,IAAI,IAAI,aAAa,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;EAC1D,IAAI,cAAc;EAClB,OAAO;CACT;CAEA,OAAO;EACL;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA,mBAAA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"mappings":";;;;;;;iBAYgB,yBAAyB,mBAAmB,WAAW"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { graph, raw, updateNode } from "../accessor-utils.js";
|
|
2
2
|
import { parseFigmaReactions, toFigmaReaction } from "../reactions.js";
|
|
3
|
+
import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
|
|
3
4
|
//#region src/figma-api/accessors/reactions.ts
|
|
4
5
|
/**
|
|
5
6
|
* `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's
|
|
@@ -18,8 +19,10 @@ function installReactionAccessors(prototype, internals) {
|
|
|
18
19
|
const previous = node.prototypeReactions;
|
|
19
20
|
updateNode(this, internals, { prototypeReactions: parseFigmaReactions(value, {
|
|
20
21
|
graph: sceneGraph,
|
|
22
|
+
nodeId: node.id,
|
|
21
23
|
pageId,
|
|
22
|
-
previous
|
|
24
|
+
previous,
|
|
25
|
+
inherited: node.type === "INSTANCE" ? instanceMainComponent(sceneGraph, node)?.prototypeReactions : void 0
|
|
23
26
|
}) });
|
|
24
27
|
}
|
|
25
28
|
} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"sourcesContent":["import type { PrototypeReaction } from '@pairdraw/scene-graph'\n\nimport type { NodeProxyInternals, ProxyThis } from '#core/figma-api/accessor-utils'\nimport { graph, raw, updateNode } from '#core/figma-api/accessor-utils'\nimport { parseFigmaReactions, toFigmaReaction, type FigmaReaction } from '#core/figma-api/reactions'\n\n/**\n * `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's\n * `prototypeReactions`; a write goes through the same validation as the tool, so a trigger,\n * action, transition, navigation or destination the play cannot show is refused.\n */\nexport function installReactionAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n reactions: {\n get(this: ProxyThis): readonly FigmaReaction[] {\n return Object.freeze(raw(this, internals).prototypeReactions.map(toFigmaReaction))\n },\n set(this: ProxyThis, value: readonly FigmaReaction[]) {\n const node = raw(this, internals)\n const sceneGraph = graph(this, internals)\n const pageId = sceneGraph.pageOf(node.id) ?? ''\n const previous: readonly PrototypeReaction[] = node.prototypeReactions\n updateNode(this, internals, {\n prototypeReactions: parseFigmaReactions(value, {
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/figma-api/accessors/reactions.ts"],"sourcesContent":["import type { PrototypeReaction } from '@pairdraw/scene-graph'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\n\nimport type { NodeProxyInternals, ProxyThis } from '#core/figma-api/accessor-utils'\nimport { graph, raw, updateNode } from '#core/figma-api/accessor-utils'\nimport { parseFigmaReactions, toFigmaReaction, type FigmaReaction } from '#core/figma-api/reactions'\n\n/**\n * `reactions` on every layer, in Figma's plugin shape. Pairdraw keeps them on the layer's\n * `prototypeReactions`; a write goes through the same validation as the tool, so a trigger,\n * action, transition, navigation or destination the play cannot show is refused.\n */\nexport function installReactionAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n reactions: {\n get(this: ProxyThis): readonly FigmaReaction[] {\n return Object.freeze(raw(this, internals).prototypeReactions.map(toFigmaReaction))\n },\n set(this: ProxyThis, value: readonly FigmaReaction[]) {\n const node = raw(this, internals)\n const sceneGraph = graph(this, internals)\n const pageId = sceneGraph.pageOf(node.id) ?? ''\n const previous: readonly PrototypeReaction[] = node.prototypeReactions\n updateNode(this, internals, {\n prototypeReactions: parseFigmaReactions(value, {\n graph: sceneGraph,\n nodeId: node.id,\n pageId,\n previous,\n inherited:\n node.type === 'INSTANCE'\n ? instanceMainComponent(sceneGraph, node)?.prototypeReactions\n : undefined\n })\n })\n }\n }\n })\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,yBAAyB,WAAmB,WAAqC;CAC/F,OAAO,iBAAiB,WAAW,EACjC,WAAW;EACT,MAA+C;GAC7C,OAAO,OAAO,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC,mBAAmB,IAAI,eAAe,CAAC;EACnF;EACA,IAAqB,OAAiC;GACpD,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,aAAa,MAAM,MAAM,SAAS;GACxC,MAAM,SAAS,WAAW,OAAO,KAAK,EAAE,KAAK;GAC7C,MAAM,WAAyC,KAAK;GACpD,WAAW,MAAM,WAAW,EAC1B,oBAAoB,oBAAoB,OAAO;IAC7C,OAAO;IACP,QAAQ,KAAK;IACb;IACA;IACA,WACE,KAAK,SAAS,aACV,sBAAsB,YAAY,IAAI,CAAC,EAAE,qBACzC,KAAA;GACR,CAAC,EACH,CAAC;EACH;CACF,EACF,CAAC;AACH"}
|
|
@@ -111,6 +111,9 @@ function installTextNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
textDecoration: characterStyle(internals, "textDecoration", mixed, (_node, textDecoration) => ({ textDecoration })),
|
|
114
|
+
openTypeFeatures: { get() {
|
|
115
|
+
return getTextStyle(raw(this, internals), "openTypeFeatures", mixed);
|
|
116
|
+
} },
|
|
114
117
|
maxLines: field(internals, "maxLines"),
|
|
115
118
|
listSpacing: spacing(internals, "listSpacing", mixed),
|
|
116
119
|
paragraphSpacing: spacing(internals, "paragraphSpacing", mixed),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport { renameTextLayer } from '#core/editor/text/name'\nimport {\n graph,\n nodeId,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport {\n assertFontLoaded,\n assertTextFontsLoaded,\n textHasMissingFont\n} from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n // A text layer that was never renamed follows its characters, as in Figma.\n renameTextLayer(graph(this, internals), nodeId(this, internals), value)\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n hasMissingFont: {\n get(this: ProxyThis): boolean {\n return textHasMissingFont(raw(this, internals))\n }\n },\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":";;;;;;;;;;;;;AA0CA,SAAS,QAAQ,WAA+B,MAAiC,OAAe;CAC9F,OAAO;EACL,MAAsC;GACpC,OAAO,oBAAoB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;EAC9D;EACA,IAAqB,OAAe;GAClC,MAAM,UAAU,eAAe,KAAK;GACpC,IAAI,SACF,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,KAAK,uBAAuB,SAAS;GAEpF,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzD,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AACF;;;;;;AAOA,SAAS,eACP,WACA,OACA,OACA,SACA,aAAa,MACb;CACA,OAAO;EACL,MAA8B;GAC5B,OAAO,aAAa,IAAI,MAAM,SAAS,GAAG,OAAO,KAAK;EACxD;EACA,IAAqB,OAAU;GAC7B,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,QAAQ,QAAQ,MAAM,KAAK;GACjC,IAAI,YAAY,sBAAsB,OAAO,SAAS,IAAI;GAC1D,WAAW,MAAM,WAAW,iBAAiB,MAAM,KAAK,CAAC;EAC3D;CACF;AACF;;;;;AAMA,SAAS,MACP,WACA,MACA,aAAa,MACb;CACA,OAAO;EACL,MAAuC;GACrC,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAyB;GAC5C,IAAI,YAAY,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzE,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AACF;AAEA,SAAgB,8BACd,WACA,WACA,OACM;CACN,OAAO,iBAAiB,WAAW;EACjC,YAAY;GACV,MAA6B;IAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;GAC9B;GACA,IAAqB,OAAe;IAClC,sBAAsB,kB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Aa,KAAK;GAC9D;GACA,IAAqB,OAA+B;IAClD,MAAM,OAAO,IAAI,MAAM,SAAS;IAChC,MAAM,YAAY,gBAAgB,iBAAiB,OAAO,MAAM,MAAM,SAAS,CAAC;IAChF,MAAM,YAAY,mBAAmB,MAAM,GAAG,KAAK,KAAK,QAAQ,EAAE,UAAU,CAAC;IAC7E,WAAW,MAAM,WAAW,EAAE,UAAU,CAAC;GAC3C;EACF;EACA,gBAAgB,eACd,WACA,kBACA,QACC,OAAO,oBAAoB,EAAE,eAAe,EAC/C;EACA,UAAU,MAAM,WAAW,UAAU;EACrC,aAAa,QAAQ,WAAW,eAAe,KAAK;EACpD,kBAAkB,QAAQ,WAAW,oBAAoB,KAAK;EAC9D,iBAAiB,QAAQ,WAAW,mBAAmB,KAAK;EAC5D,aAAa,MAAM,WAAW,aAAa;EAC3C,gBAAgB,MAAM,WAAW,gBAAgB;EACjD,YAAY,MAAM,WAAW,cAAc,KAAK;CAClD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport { renameTextLayer } from '#core/editor/text/name'\nimport {\n graph,\n nodeId,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport {\n assertFontLoaded,\n assertTextFontsLoaded,\n textHasMissingFont\n} from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n // A text layer that was never renamed follows its characters, as in Figma.\n renameTextLayer(graph(this, internals), nodeId(this, internals), value)\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n hasMissingFont: {\n get(this: ProxyThis): boolean {\n return textHasMissingFont(raw(this, internals))\n }\n },\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n // Figma reads a text's explicitly set OpenType features; it has no setter for them, so\n // this one is read-only and `pairdraw.setFontFeatures` writes them.\n openTypeFeatures: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'openTypeFeatures', mixed)\n }\n },\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":";;;;;;;;;;;;;AA0CA,SAAS,QAAQ,WAA+B,MAAiC,OAAe;CAC9F,OAAO;EACL,MAAsC;GACpC,OAAO,oBAAoB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;EAC9D;EACA,IAAqB,OAAe;GAClC,MAAM,UAAU,eAAe,KAAK;GACpC,IAAI,SACF,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,KAAK,uBAAuB,SAAS;GAEpF,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACzD,WAAW,MAAM,WAAW,GAAG,OAAO,MAAM,CAAC;EAC/C;CACF;AACF;;;;;;AAOA,SAAS,eACP,WACA,OACA,OACA,SACA,aAAa,MACb;CACA,OAAO;EACL,MAA8B;GAC5B,OAAO,aAAa,IAAI,MAAM,SAAS,GAAG,OAAO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AK;EAC5D,aAAa,MAAM,WAAW,aAAa;EAC3C,gBAAgB,MAAM,WAAW,gBAAgB;EACjD,YAAY,MAAM,WAAW,cAAc,KAAK;CAClD,CAAC;AACH"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/figma-api/accessors/text/opentype.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The style patch a range's OpenType features take: the features its characters already had,
|
|
5
|
+
* with the given tags replacing their own entries, as setRangeFontName keeps the axes it does
|
|
6
|
+
* not name. A non-boolean value is refused before anything changes. Figma's plugin API has no
|
|
7
|
+
* range feature setter, so `pairdraw.setRangeFontFeatures` applies this patch.
|
|
8
|
+
*/
|
|
9
|
+
declare function openTypeFeaturesPatch(method: string, node: SceneNode, start: number, value: unknown): {
|
|
10
|
+
fontFeatures: Array<{
|
|
11
|
+
tag: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { openTypeFeaturesPatch };
|
|
17
|
+
//# sourceMappingURL=opentype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentype.d.ts","names":[],"sources":["../../../../src/figma-api/accessors/text/opentype.ts"],"mappings":";;;;;;;;iBAYgB,sBACd,gBACA,MAAM,WACN,eACA;EACG,cAAc;IAAQ;IAAa"}
|