@pairdraw/core 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +73 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +0 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -4
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +22 -3
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +168 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +6 -0
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +6 -3
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -1
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +31 -3
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +4 -54
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +224 -50
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +6 -3
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.js +3 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +26 -5
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +2 -1
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -3
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +22 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/tools/vector/vectorize.js +1 -0
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
- package/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -3
- package/src/canvas/renderer.ts +40 -4
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +17 -1
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +5 -1
- package/src/io/formats/fig/export/patch/index.ts +8 -0
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +12 -1
- package/src/io/formats/svg/defs.ts +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/layout.ts +5 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/nodes.ts +0 -1
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +34 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/path.ts +30 -6
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
- package/src/xpath.ts +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.js","names":[],"sources":["../../src/prototype/timeline.ts"],"sourcesContent":["import type {\n PrototypeAction,\n PrototypeEasingType,\n PrototypeOverlayPositionType,\n PrototypeTransitionType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\n\nimport { easingAt } from './easing'\nimport {\n primaryAction,\n shownFrame,\n startSession,\n step,\n timeoutReactions,\n topFrameOf,\n type PlaySession\n} from './session'\n\n/** A scripted click: the layer clicked, and when, in milliseconds from the start of play. */\nexport interface TimelineClick {\n atMs: number\n nodeId: string\n}\n\nexport interface TimelineOptions {\n /** The top-level frame play starts from. */\n startFrameId: string\n /** Clicks to run as play goes, in time order. */\n clicks?: readonly TimelineClick[]\n /** Where the timeline stops when the flow goes on longer. */\n maxMs: number\n /** How long the last frame stays once nothing else happens. */\n tailMs: number\n}\n\n/** A stretch of play that moves from one screen to the next over a transition's own length. */\ninterface TimelineTransition {\n from: PlaySession\n to: PlaySession\n startMs: number\n endMs: number\n /** The transition's own length, which keeps its pace when a later step cuts it short. */\n fadeMs: number\n easing?: PrototypeEasingType\n}\n\n/**\n * A stretch of play: one screen held still, a crossfade from one screen to the next, or a Smart\n * animate between them.\n */\nexport type TimelineSegment =\n | { kind: 'hold'; session: PlaySession; startMs: number; endMs: number }\n | ({ kind: 'dissolve' } & TimelineTransition)\n | ({ kind: 'smart' } & TimelineTransition)\n\n/** A Smart animate stretch of a timeline. */\nexport type TimelineSmartSegment = Extract<TimelineSegment, { kind: 'smart' }>\n\n/** One step play took: when, the frame it shows afterwards, what started it, and how it moved. */\nexport interface TimelineStep {\n atMs: number\n frameId: string\n trigger: 'AFTER_TIMEOUT' | 'ON_CLICK'\n transition: PrototypeTransitionType\n}\n\nexport interface Timeline {\n segments: TimelineSegment[]\n durationMs: number\n /** Clicks the walk never ran: past the cap, or on a layer whose hit runs no reaction. */\n skippedClicks: TimelineClick[]\n /** Play came back to the screen it started on, so the clip repeats seamlessly. */\n loops: boolean\n /** The flow went on past `maxMs`, where the timeline stops. */\n truncated: boolean\n steps: TimelineStep[]\n /** Where each overlay frame play opened sits over the screen, from the action that opened it. */\n overlayPositions: Record<string, PrototypeOverlayPositionType>\n}\n\n/**\n * What a timeline shows at a moment: one screen, two mid-crossfade with `mix` of the second, or a\n * Smart animate `progress` of the way through its time, which its animation eases.\n */\nexport type TimelineFrame =\n | { session: PlaySession }\n | { from: PlaySession; to: PlaySession; mix: number }\n | { smart: TimelineSmartSegment; progress: number }\n\n/** Why a flow cannot be played: the start frame has nothing to follow, or anything else. */\nexport type TimelineErrorReason = 'nothing-to-follow' | 'invalid'\n\n/** A flow that cannot be played as asked, with a message naming the frame or click at fault. */\nexport class TimelineError extends Error {\n override name = 'TimelineError'\n constructor(\n message: string,\n readonly reason: TimelineErrorReason = 'invalid'\n ) {\n super(message)\n }\n}\n\n/** Steps a timeline may take before it is refused, which stops cycles that take no time. */\nconst MAX_TIMELINE_STEPS = 10_000\n\n/** How long an action's transition runs, in milliseconds; a cut takes none. */\nexport function transitionMs(action: PrototypeAction): number {\n if (action.type !== 'NODE' || action.transition.type === 'INSTANT') return 0\n return Math.max(0, action.transition.duration * 1000)\n}\n\n/** How play shows a step: a cut, a crossfade, or Smart animate. */\nexport type PlayAnimation = 'cut' | 'dissolve' | 'smart'\n\n/**\n * How play animates `action` from `session`: a cut when it takes no time; Smart animate for a\n * Smart animate Change to, or a navigation between screens while no overlay is open, as Figma\n * has no Smart animate for overlays; a crossfade otherwise.\n */\nexport function animationFor(session: PlaySession, action: PrototypeAction): PlayAnimation {\n if (transitionMs(action) === 0 || action.type !== 'NODE') return 'cut'\n if (action.transition.type !== 'SMART_ANIMATE') return 'dissolve'\n if (action.navigation === 'CHANGE_TO') return 'smart'\n return action.navigation === 'NAVIGATE' && session.overlays.length === 0 ? 'smart' : 'dissolve'\n}\n\n/**\n * The curve a dissolve fades along, CSS `ease-out`, which Figma's dissolve uses by default: the\n * x and y of its two cubic Bézier control points. The player draws its crossfade with\n * `DISSOLVE_EASING_CSS` and a recording samples `dissolveEasing`, so both fade alike.\n */\nexport const DISSOLVE_EASING = { x1: 0, y1: 0, x2: 0.58, y2: 1 } as const\n\n/** `DISSOLVE_EASING` as a CSS timing function. */\nexport const DISSOLVE_EASING_CSS = `cubic-bezier(${DISSOLVE_EASING.x1}, ${DISSOLVE_EASING.y1}, ${DISSOLVE_EASING.x2}, ${DISSOLVE_EASING.y2})`\n\n/** The share of the new screen a dissolve shows at `progress` of the way, along `DISSOLVE_EASING`. */\nexport function dissolveEasing(progress: number): number {\n return easingAt('EASE_OUT', progress)\n}\n\n/**\n * What play draws, as a key two sessions share when they look alike: the base frame and its\n * overlays. History only matters to Back. State that changes what a frame shows extends it here,\n * and the recorder's screen cache follows.\n */\nexport function sessionDrawKey(session: PlaySession): string {\n return [session.frameId, ...session.overlays].join(' ')\n}\n\nfunction nameOf(graph: SceneGraph, id: string): string {\n return graph.getNode(id)?.name ?? id\n}\n\nfunction seconds(ms: number): string {\n return `${(ms / 1000).toFixed(2)} s`\n}\n\n/** Whether `node` sits in `frameId`, or is that frame. */\nfunction isInside(graph: SceneGraph, node: SceneNode, frameId: string): boolean {\n let current: SceneNode | undefined = node\n while (current) {\n if (current.id === frameId) return true\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return false\n}\n\n/**\n * The action a click on `nodeId` runs, as a click on the canvas resolves one: the layer or its\n * nearest ancestor inside the shown frame with an `ON_CLICK` reaction. Throws when the layer is not\n * on the shown frame; null when nothing there reacts to a click.\n */\nfunction clickAction(\n graph: SceneGraph,\n session: PlaySession,\n click: TimelineClick,\n index: number\n): PrototypeAction | null {\n const shown = shownFrame(session)\n const node = graph.getNode(click.nodeId)\n if (!node || !isInside(graph, node, shown)) {\n throw new TimelineError(\n `click ${index + 1}: '${node?.name ?? click.nodeId}' is not on the shown frame '${nameOf(graph, shown)}' at ${seconds(click.atMs)}`\n )\n }\n let current: SceneNode | undefined = node\n while (current) {\n const reaction = current.prototypeReactions.find(\n (candidate) => candidate.trigger.type === 'ON_CLICK'\n )\n const action = reaction ? primaryAction(reaction) : null\n if (action) return action\n if (current.id === shown) return null\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return null\n}\n\ninterface ArmedTimer {\n atMs: number\n action: PrototypeAction\n}\n\n/** The shown frame's After delay reactions, each due `delay` after the frame finished entering. */\nfunction armTimers(graph: SceneGraph, session: PlaySession, readyMs: number): ArmedTimer[] {\n return timeoutReactions(graph, session)\n .map(({ action, delayMs }) => ({ atMs: readyMs + delayMs, action }))\n .toSorted((a, b) => a.atMs - b.atMs)\n}\n\n/** Play at its start frame, which must be a top-level frame with something to follow. */\nfunction startWalk(graph: SceneGraph, options: TimelineOptions): { walk: Walk; start: SceneNode } {\n const start = graph.getNode(options.startFrameId)\n if (!start || topFrameOf(graph, start)?.id !== start.id) {\n throw new TimelineError(`'${start?.name ?? options.startFrameId}' is not a top-level frame`)\n }\n const session = startSession(start.id)\n const walk: Walk = {\n graph,\n session,\n readyMs: 0,\n timers: armTimers(graph, session, 0),\n clicks: (options.clicks ?? []).toSorted((a, b) => a.atMs - b.atMs),\n clickIndex: 0,\n skippedClicks: [],\n segments: [],\n steps: [],\n overlayPositions: {}\n }\n if (walk.timers.length === 0 && walk.clicks.length === 0) {\n throw new TimelineError(\n `'${start.name}' has no After delay interaction to follow`,\n 'nothing-to-follow'\n )\n }\n return { walk, start }\n}\n\n/** Play in progress on the virtual clock: what is shown, since when, and what is due next. */\ninterface Walk {\n graph: SceneGraph\n session: PlaySession\n /** When the shown screen finished entering; its After delays count from here. */\n readyMs: number\n timers: ArmedTimer[]\n clicks: TimelineClick[]\n clickIndex: number\n skippedClicks: TimelineClick[]\n segments: TimelineSegment[]\n steps: TimelineStep[]\n overlayPositions: Record<string, PrototypeOverlayPositionType>\n}\n\ninterface WalkEvent {\n atMs: number\n action: PrototypeAction | null\n trigger: TimelineStep['trigger']\n}\n\n/** Holds the shown screen from when it finished entering until `endMs`. */\nfunction hold(walk: Walk, endMs: number): void {\n if (endMs > walk.readyMs) {\n walk.segments.push({ kind: 'hold', session: walk.session, startMs: walk.readyMs, endMs })\n }\n}\n\n/** The earliest due timer or click, taken off its queue; null when nothing else will happen. */\nfunction takeNextEvent(walk: Walk): WalkEvent | null {\n const timer = walk.timers.at(0)\n const click = walk.clicks.at(walk.clickIndex)\n if (timer && (!click || timer.atMs <= click.atMs)) {\n walk.timers = walk.timers.slice(1)\n return { atMs: timer.atMs, action: timer.action, trigger: 'AFTER_TIMEOUT' }\n }\n if (!click) return null\n const action = clickAction(walk.graph, walk.session, click, walk.clickIndex)\n walk.clickIndex += 1\n if (!action) walk.skippedClicks.push(click)\n return { atMs: click.atMs, action, trigger: 'ON_CLICK' }\n}\n\n/** The earliest event's time without taking it, or infinity when nothing else will happen. */\nfunction nextEventAt(walk: Walk): number {\n const timerAt = walk.timers.at(0)?.atMs ?? Number.POSITIVE_INFINITY\n const clickAt = walk.clicks.at(walk.clickIndex)?.atMs ?? Number.POSITIVE_INFINITY\n return Math.min(timerAt, clickAt)\n}\n\n/** Runs `action` at `atMs`, recording the hold before it, its crossfade, and the step. */\nfunction advance(walk: Walk, event: WalkEvent & { action: PrototypeAction }, next: PlaySession) {\n const { atMs, action } = event\n // A step while a transition still runs cuts it short where it is.\n const running = walk.segments.at(-1)\n if (running && running.kind !== 'hold' && running.endMs > atMs) running.endMs = atMs\n hold(walk, atMs)\n const durationMs = transitionMs(action)\n const animation = animationFor(walk.session, action)\n if (animation !== 'cut') {\n walk.segments.push({\n kind: animation === 'smart' ? 'smart' : 'dissolve',\n from: walk.session,\n to: next,\n startMs: atMs,\n endMs: atMs + durationMs,\n fadeMs: durationMs,\n ...(action.type === 'NODE' && action.transition.easing\n ? { easing: action.transition.easing }\n : {})\n })\n }\n walk.steps.push({\n atMs,\n frameId: shownFrame(next),\n trigger: event.trigger,\n transition: durationMs > 0 && action.type === 'NODE' ? action.transition.type : 'INSTANT'\n })\n if (action.type === 'NODE' && action.navigation === 'OVERLAY' && action.nodeId) {\n walk.overlayPositions[action.nodeId] = action.overlayPosition\n }\n walk.session = next\n walk.readyMs = atMs + durationMs\n walk.timers = armTimers(walk.graph, next, walk.readyMs)\n}\n\nfunction finish(walk: Walk, durationMs: number, end: 'ends' | 'loops' | 'truncated'): Timeline {\n return {\n segments: walk.segments,\n durationMs,\n loops: end === 'loops',\n truncated: end === 'truncated',\n steps: walk.steps,\n overlayPositions: walk.overlayPositions,\n skippedClicks: [...walk.skippedClicks, ...walk.clicks.slice(walk.clickIndex)]\n }\n}\n\n/**\n * Plays a prototype on a virtual clock, from `startFrameId`, following its After delay\n * reactions and the scripted clicks as the player would, without waiting for real time. Each delay\n * counts from when the transition into its frame ends, as in Figma. The walk stops when play\n * returns to the screen it started on (`loops`), when nothing else will happen (the last screen is\n * held `tailMs`), or at `maxMs` (`truncated`).\n */\nexport function planTimeline(graph: SceneGraph, options: TimelineOptions): Timeline {\n const { walk, start } = startWalk(graph, options)\n const startKey = sessionDrawKey(walk.session)\n\n for (let taken = 0; taken <= MAX_TIMELINE_STEPS; taken++) {\n const dueAt = nextEventAt(walk)\n if (dueAt >= options.maxMs) {\n const endMs = Math.min(walk.readyMs + options.tailMs, options.maxMs)\n // More is due past the cap, or the cap falls before the last transition has ended.\n const truncated = dueAt !== Number.POSITIVE_INFINITY || walk.readyMs > options.maxMs\n hold(walk, truncated ? options.maxMs : endMs)\n // With no time left to hold it, the last screen still ends the timeline.\n if (!truncated && endMs <= walk.readyMs) {\n walk.segments.push({\n kind: 'hold',\n session: walk.session,\n startMs: walk.readyMs,\n endMs: walk.readyMs\n })\n }\n return truncated ? finish(walk, options.maxMs, 'truncated') : finish(walk, endMs, 'ends')\n }\n const event = takeNextEvent(walk)\n const action = event?.action\n if (!event || !action) continue\n const next = step(graph, walk.session, action)\n if (next === walk.session) continue\n advance(walk, { ...event, action }, next)\n\n if (sessionDrawKey(next) === startKey && walk.clickIndex >= walk.clicks.length) {\n if (walk.readyMs === 0) {\n throw new TimelineError(`The flow loops back to '${start.name}' at once`)\n }\n if (walk.readyMs > options.maxMs) return finish(walk, options.maxMs, 'truncated')\n return finish(walk, walk.readyMs, 'loops')\n }\n }\n throw new TimelineError(`The flow takes more than ${MAX_TIMELINE_STEPS} steps`)\n}\n\n/** What the timeline shows at `atMs`; past its end, the last screen it shows. */\nexport function frameAt(timeline: Timeline, atMs: number): TimelineFrame {\n for (const segment of timeline.segments) {\n if (atMs >= segment.endMs) continue\n if (segment.kind === 'hold') return { session: segment.session }\n const progress = (atMs - segment.startMs) / segment.fadeMs\n if (segment.kind === 'smart') return { smart: segment, progress }\n return { from: segment.from, to: segment.to, mix: easingAt(segment.easing, progress) }\n }\n const last = timeline.segments.at(-1)\n if (!last) throw new TimelineError('The timeline is empty')\n return { session: last.kind === 'hold' ? last.session : last.to }\n}\n"],"mappings":";;;;AA+FA,IAAa,gBAAb,cAAmC,MAAM;CAI5B;CAHX,OAAgB;CAChB,YACE,SACA,SAAuC,WACvC;EACA,MAAM,OAAO;EAFJ,KAAA,SAAA;CAGX;AACF;;AAGA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QAAQ,QAAQ;EAAE;CACvF;CACA,MAAM,OAAO,SAAS,SAAS,GAAG,EAAE;CACpC,IAAI,CAAC,MAAM,MAAM,IAAI,cAAc,uBAAuB;CAC1D,OAAO,EAAE,SAAS,KAAK,SAAS,SAAS,KAAK,UAAU,KAAK,GAAG;AAClE"}
|
package/dist/rpc/commands.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnalyzeOverlapsArgs, AnalyzeOverlapsResult } from "../tools/analyze/overlaps/index.js";
|
|
2
2
|
import { RPCCommand } from "./types.js";
|
|
3
3
|
import { AnalyzeClustersArgs, AnalyzeClustersResult, AnalyzeColorsArgs, AnalyzeColorsResult, AnalyzeSpacingResult, AnalyzeTypographyArgs, AnalyzeTypographyResult, SpacingValue, TypographyStyle, analyzeClustersCommand, analyzeColorsCommand, analyzeOverlapsCommand, analyzeSpacingCommand, analyzeTypographyCommand } from "./analyze-commands.js";
|
|
4
|
-
import { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, treeCommand } from "./read-commands.js";
|
|
4
|
+
import { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageArgs, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, treeCommand } from "./read-commands.js";
|
|
5
5
|
import { TokensArgs, TokensResult, VariablesArgs, VariablesResult, tokensCommand, variablesCommand } from "./variables-command.js";
|
|
6
6
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
7
7
|
//#region src/rpc/commands.d.ts
|
|
@@ -20,5 +20,5 @@ type AutomationDocumentSummary = {
|
|
|
20
20
|
declare const ALL_RPC_COMMANDS: RPCCommand[];
|
|
21
21
|
declare function executeRPCCommand(graph: SceneGraph, name: string, args: unknown): unknown;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { ALL_RPC_COMMANDS, AnalyzeClustersArgs, AnalyzeClustersResult, AnalyzeColorsArgs, AnalyzeColorsResult, type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, AnalyzeSpacingResult, AnalyzeTypographyArgs, AnalyzeTypographyResult, AutomationDocumentSummary, FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageItem, QueryArgs, QueryNodeResult, type RPCCommand, SpacingValue, TokensArgs, TokensResult, TreeArgs, TreeNodeResult, TreeResult, TypographyStyle, VariablesArgs, VariablesResult, analyzeClustersCommand, analyzeColorsCommand, analyzeOverlapsCommand, analyzeSpacingCommand, analyzeTypographyCommand, executeRPCCommand, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, tokensCommand, treeCommand, variablesCommand };
|
|
23
|
+
export { ALL_RPC_COMMANDS, AnalyzeClustersArgs, AnalyzeClustersResult, AnalyzeColorsArgs, AnalyzeColorsResult, type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, AnalyzeSpacingResult, AnalyzeTypographyArgs, AnalyzeTypographyResult, AutomationDocumentSummary, FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageArgs, PageItem, QueryArgs, QueryNodeResult, type RPCCommand, SpacingValue, TokensArgs, TokensResult, TreeArgs, TreeNodeResult, TreeResult, TypographyStyle, VariablesArgs, VariablesResult, analyzeClustersCommand, analyzeColorsCommand, analyzeOverlapsCommand, analyzeSpacingCommand, analyzeTypographyCommand, executeRPCCommand, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, tokensCommand, treeCommand, variablesCommand };
|
|
24
24
|
//# sourceMappingURL=commands.d.ts.map
|
package/dist/rpc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalyzeOverlapsArgs, AnalyzeOverlapsResult } from "../tools/analyze/overlaps/index.js";
|
|
2
2
|
import { AnalyzeClustersArgs, AnalyzeClustersResult, AnalyzeColorsArgs, AnalyzeColorsResult, AnalyzeSpacingResult, AnalyzeTypographyArgs, AnalyzeTypographyResult, SpacingValue, TypographyStyle } from "./analyze-commands.js";
|
|
3
|
-
import { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult } from "./read-commands.js";
|
|
3
|
+
import { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageArgs, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult } from "./read-commands.js";
|
|
4
4
|
import { TokensArgs, TokensResult, VariablesArgs, VariablesResult } from "./variables-command.js";
|
|
5
5
|
import { ALL_RPC_COMMANDS, AutomationDocumentSummary, executeRPCCommand } from "./commands.js";
|
|
6
|
-
export { ALL_RPC_COMMANDS, type AnalyzeClustersArgs, type AnalyzeClustersResult, type AnalyzeColorsArgs, type AnalyzeColorsResult, type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, type AnalyzeSpacingResult, type AnalyzeTypographyArgs, type AnalyzeTypographyResult, type AutomationDocumentSummary, type FindArgs, type FindNodeResult, type InfoResult, type NodeArgs, type NodeResult, type PageItem, type QueryArgs, type QueryNodeResult, type SpacingValue, type TokensArgs, type TokensResult, type TreeArgs, type TreeNodeResult, type TreeResult, type TypographyStyle, type VariablesArgs, type VariablesResult, executeRPCCommand };
|
|
6
|
+
export { ALL_RPC_COMMANDS, type AnalyzeClustersArgs, type AnalyzeClustersResult, type AnalyzeColorsArgs, type AnalyzeColorsResult, type AnalyzeOverlapsArgs, type AnalyzeOverlapsResult, type AnalyzeSpacingResult, type AnalyzeTypographyArgs, type AnalyzeTypographyResult, type AutomationDocumentSummary, type FindArgs, type FindNodeResult, type InfoResult, type NodeArgs, type NodeResult, type PageArgs, type PageItem, type QueryArgs, type QueryNodeResult, type SpacingValue, type TokensArgs, type TokensResult, type TreeArgs, type TreeNodeResult, type TreeResult, type TypographyStyle, type VariablesArgs, type VariablesResult, executeRPCCommand };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { DocumentFontStatus } from "../text/font/status.js";
|
|
2
2
|
import { RPCCommand } from "./types.js";
|
|
3
|
+
import { BooleanOperation, MaskType } from "@pairdraw/scene-graph";
|
|
3
4
|
//#region src/rpc/read-commands.d.ts
|
|
5
|
+
/** A page picked by its ID, `page_id`, or by its name, `page`; the ID wins when both are given. */
|
|
6
|
+
interface PageArgs {
|
|
7
|
+
page?: string;
|
|
8
|
+
page_id?: string;
|
|
9
|
+
}
|
|
4
10
|
interface InfoResult {
|
|
5
11
|
pages: number;
|
|
6
12
|
totalNodes: number;
|
|
@@ -16,8 +22,7 @@ interface PageItem {
|
|
|
16
22
|
nodes: number;
|
|
17
23
|
}
|
|
18
24
|
declare const pagesCommand: RPCCommand<void, PageItem[]>;
|
|
19
|
-
interface TreeArgs {
|
|
20
|
-
page?: string;
|
|
25
|
+
interface TreeArgs extends PageArgs {
|
|
21
26
|
depth?: number;
|
|
22
27
|
}
|
|
23
28
|
interface TreeNodeResult {
|
|
@@ -41,10 +46,9 @@ interface TreeResult {
|
|
|
41
46
|
declare const treeCommand: RPCCommand<TreeArgs, TreeResult | {
|
|
42
47
|
error: string;
|
|
43
48
|
}>;
|
|
44
|
-
interface FindArgs {
|
|
49
|
+
interface FindArgs extends PageArgs {
|
|
45
50
|
name?: string;
|
|
46
51
|
type?: string;
|
|
47
|
-
page?: string;
|
|
48
52
|
limit?: number;
|
|
49
53
|
}
|
|
50
54
|
interface FindNodeResult {
|
|
@@ -55,9 +59,8 @@ interface FindNodeResult {
|
|
|
55
59
|
height: number;
|
|
56
60
|
}
|
|
57
61
|
declare const findCommand: RPCCommand<FindArgs, FindNodeResult[]>;
|
|
58
|
-
interface QueryArgs {
|
|
62
|
+
interface QueryArgs extends PageArgs {
|
|
59
63
|
selector: string;
|
|
60
|
-
page?: string;
|
|
61
64
|
limit?: number;
|
|
62
65
|
}
|
|
63
66
|
interface QueryNodeResult {
|
|
@@ -90,7 +93,14 @@ interface NodeResult {
|
|
|
90
93
|
fills: unknown[];
|
|
91
94
|
strokes: unknown[];
|
|
92
95
|
effects: unknown[];
|
|
93
|
-
cornerRadius
|
|
96
|
+
cornerRadius?: number;
|
|
97
|
+
topLeftRadius?: number;
|
|
98
|
+
topRightRadius?: number;
|
|
99
|
+
bottomRightRadius?: number;
|
|
100
|
+
bottomLeftRadius?: number;
|
|
101
|
+
isMask?: boolean;
|
|
102
|
+
maskType?: MaskType;
|
|
103
|
+
booleanOperation?: BooleanOperation;
|
|
94
104
|
blendMode: string;
|
|
95
105
|
layoutMode: string;
|
|
96
106
|
layoutDirection: string;
|
|
@@ -111,5 +121,5 @@ declare const nodeCommand: RPCCommand<NodeArgs, NodeResult | {
|
|
|
111
121
|
error: string;
|
|
112
122
|
}>;
|
|
113
123
|
//#endregion
|
|
114
|
-
export { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, treeCommand };
|
|
124
|
+
export { FindArgs, FindNodeResult, InfoResult, NodeArgs, NodeResult, PageArgs, PageItem, QueryArgs, QueryNodeResult, TreeArgs, TreeNodeResult, TreeResult, findCommand, fontStatusCommand, infoCommand, nodeCommand, pagesCommand, queryCommand, treeCommand };
|
|
115
125
|
//# sourceMappingURL=read-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-commands.d.ts","names":[],"sources":["../../src/rpc/read-commands.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-commands.d.ts","names":[],"sources":["../../src/rpc/read-commands.ts"],"mappings":";;;;;UAwBiB;EACf;EACA;;UA4Ce;EACf;EACA;EACA,OAAO;EACP;EACA,YAAY;;cAGD,aAAa,iBAAiB;cA4B9B,mBAAmB,iBAAiB;UAUhC;EACf;EACA;EACA;;cAGW,cAAc,iBAAiB;UAS3B,iBAAiB;EAChC;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;;UAyBI;EACf;IAAQ;IAAY;IAAc;;EAClC,UAAU;;cAGC,aAAa,WAAW,UAAU;EAAe;;UAkB7C,iBAAiB;EAChC;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;cAGW,aAAa,WAAW,UAAU;UAqC9B,kBAAkB;EACjC;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;cAGW,cAAc,WAAW,WAAW;EAAsB;;UA0BtD;EACf;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX,mBAAmB;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAY;IAAc;;EACpC;EACA,gBAAgB;;cAGL,aAAa,WAAW,UAAU;EAAe"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../text/ellipsis.js";
|
|
2
2
|
import { prepareGraphFonts } from "../text/prepare.js";
|
|
3
|
+
import { shapeDetailFields } from "../figma-api/shape-details.js";
|
|
3
4
|
import { queryByXPath } from "../xpath.js";
|
|
4
5
|
import { sumBy } from "es-toolkit";
|
|
5
6
|
//#region src/rpc/read-commands.ts
|
|
@@ -11,6 +12,18 @@ function walkNodes(graph, rootId, fn) {
|
|
|
11
12
|
for (const childId of node.childIds) if (!walkNodes(graph, childId, fn)) return false;
|
|
12
13
|
return true;
|
|
13
14
|
}
|
|
15
|
+
/** The pages `args` picks: the one it names, none when it names a missing page, else `fallback`. */
|
|
16
|
+
function pickedPages(graph, args, fallback) {
|
|
17
|
+
const pages = graph.getPages();
|
|
18
|
+
if (args.page_id) return pages.filter((page) => page.id === args.page_id);
|
|
19
|
+
if (args.page) return pages.filter((page) => page.name === args.page).slice(0, 1);
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
function missingPageError(graph, args) {
|
|
23
|
+
const pages = graph.getPages();
|
|
24
|
+
const [label, available] = args.page_id ? [args.page_id, pages.map((page) => page.id)] : [args.page ?? "", pages.map((page) => page.name)];
|
|
25
|
+
return `Page "${label}" not found. Available: ${available.join(", ")}`;
|
|
26
|
+
}
|
|
14
27
|
function countDescendants(graph, rootId) {
|
|
15
28
|
let count = 0;
|
|
16
29
|
walkNodes(graph, rootId, () => {
|
|
@@ -91,10 +104,9 @@ function buildTreeNode(graph, id, depth, maxDepth) {
|
|
|
91
104
|
const treeCommand = {
|
|
92
105
|
name: "tree",
|
|
93
106
|
execute: (graph, args) => {
|
|
94
|
-
const pages = graph.getPages();
|
|
95
107
|
const maxDepth = args.depth ?? Infinity;
|
|
96
|
-
const page = args
|
|
97
|
-
if (!page) return { error:
|
|
108
|
+
const page = pickedPages(graph, args, graph.getPages().slice(0, 1)).at(0);
|
|
109
|
+
if (!page) return { error: missingPageError(graph, args) };
|
|
98
110
|
return {
|
|
99
111
|
page: {
|
|
100
112
|
id: page.id,
|
|
@@ -108,7 +120,6 @@ const treeCommand = {
|
|
|
108
120
|
const findCommand = {
|
|
109
121
|
name: "find",
|
|
110
122
|
execute: (graph, args) => {
|
|
111
|
-
const pages = graph.getPages();
|
|
112
123
|
const max = args.limit ?? 100;
|
|
113
124
|
const namePattern = args.name?.toLowerCase();
|
|
114
125
|
const typeFilter = args.type?.toUpperCase();
|
|
@@ -128,10 +139,7 @@ const findCommand = {
|
|
|
128
139
|
return true;
|
|
129
140
|
})) break;
|
|
130
141
|
};
|
|
131
|
-
|
|
132
|
-
const page = pages.find((p) => p.name === args.page);
|
|
133
|
-
if (page) searchPage(page);
|
|
134
|
-
} else for (const page of pages) searchPage(page);
|
|
142
|
+
for (const page of pickedPages(graph, args, graph.getPages())) searchPage(page);
|
|
135
143
|
return results;
|
|
136
144
|
}
|
|
137
145
|
};
|
|
@@ -141,6 +149,7 @@ const queryCommand = {
|
|
|
141
149
|
try {
|
|
142
150
|
return (await queryByXPath(graph, args.selector, {
|
|
143
151
|
page: args.page,
|
|
152
|
+
pageId: args.page_id,
|
|
144
153
|
limit: args.limit
|
|
145
154
|
})).map((n) => ({
|
|
146
155
|
id: n.id,
|
|
@@ -176,7 +185,7 @@ const nodeCommand = {
|
|
|
176
185
|
fills: node.fills,
|
|
177
186
|
strokes: node.strokes,
|
|
178
187
|
effects: node.effects,
|
|
179
|
-
|
|
188
|
+
...shapeDetailFields(node),
|
|
180
189
|
blendMode: node.blendMode,
|
|
181
190
|
layoutMode: node.layoutMode,
|
|
182
191
|
layoutDirection: node.layoutDirection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-commands.js","names":[],"sources":["../../src/rpc/read-commands.ts"],"sourcesContent":["import { sumBy } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { ELLIPSIS } from '#core/text/ellipsis'\nimport type { DocumentFontStatus } from '#core/text/font/status'\nimport { prepareGraphFonts } from '#core/text/prepare'\nimport { queryByXPath } from '#core/xpath'\n\nimport type { RPCCommand } from './types'\n\n/** Walk descendants. Callback returns `false` to stop traversal. */\nfunction walkNodes(graph: SceneGraph, rootId: string, fn: (node: SceneNode) => boolean): boolean {\n const node = graph.getNode(rootId)\n if (!node) return true\n if (!fn(node)) return false\n for (const childId of node.childIds) {\n if (!walkNodes(graph, childId, fn)) return false\n }\n return true\n}\n\nfunction countDescendants(graph: SceneGraph, rootId: string): number {\n let count = 0\n walkNodes(graph, rootId, () => {\n count++\n return true\n })\n return count\n}\n\nfunction countNodes(graph: SceneGraph, pageId: string): number {\n const page = graph.getNode(pageId)\n return page ? sumBy(page.childIds, (id) => countDescendants(graph, id)) : 0\n}\n\nfunction nodeFrame(node: SceneNode) {\n return {\n x: Math.round(node.x),\n y: Math.round(node.y),\n width: Math.round(node.width),\n height: Math.round(node.height)\n }\n}\n\n// ── info ──\n\nexport interface InfoResult {\n pages: number\n totalNodes: number\n types: Record<string, number>\n fonts: string[]\n pageCounts: Record<string, number>\n}\n\nexport const infoCommand: RPCCommand<void, InfoResult> = {\n name: 'info',\n execute: (graph) => {\n const pages = graph.getPages()\n let totalNodes = 0\n const types: Record<string, number> = {}\n const fonts = new Set<string>()\n const pageCounts: Record<string, number> = {}\n\n const countNode = (node: SceneNode) => {\n totalNodes++\n types[node.type] = (types[node.type] ?? 0) + 1\n if (node.fontFamily) fonts.add(node.fontFamily)\n return true\n }\n\n for (const page of pages) {\n const beforePage = totalNodes\n for (const cid of page.childIds) {\n walkNodes(graph, cid, countNode)\n }\n pageCounts[page.name] = totalNodes - beforePage\n }\n\n return { pages: pages.length, totalNodes, types, fonts: [...fonts].sort(), pageCounts }\n }\n}\n\nexport const fontStatusCommand: RPCCommand<void, DocumentFontStatus> = {\n name: 'font-status',\n execute: async (graph) => {\n const pageIds = graph.getPages().map((page) => page.id)\n return prepareGraphFonts(graph, pageIds.length > 0 ? pageIds : [graph.rootId])\n }\n}\n\n// ── pages ──\n\nexport interface PageItem {\n id: string\n name: string\n nodes: number\n}\n\nexport const pagesCommand: RPCCommand<void, PageItem[]> = {\n name: 'pages',\n execute: (graph) => {\n return graph.getPages().map((p) => ({ id: p.id, name: p.name, nodes: countNodes(graph, p.id) }))\n }\n}\n\n// ── tree ──\n\nexport interface TreeArgs {\n page?: string\n depth?: number\n}\n\nexport interface TreeNodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n children?: TreeNodeResult[]\n}\n\nfunction buildTreeNode(\n graph: SceneGraph,\n id: string,\n depth: number,\n maxDepth: number\n): TreeNodeResult | null {\n const node = graph.getNode(id)\n if (!node) return null\n const result: TreeNodeResult = {\n id: node.id,\n name: node.name,\n type: node.type,\n ...nodeFrame(node)\n }\n if (node.childIds.length > 0 && depth < maxDepth) {\n result.children = node.childIds\n .map((cid) => buildTreeNode(graph, cid, depth + 1, maxDepth))\n .filter((n): n is TreeNodeResult => n !== null)\n }\n return result\n}\n\nexport interface TreeResult {\n page: { id: string; name: string; type: string }\n children: TreeNodeResult[]\n}\n\nexport const treeCommand: RPCCommand<TreeArgs, TreeResult | { error: string }> = {\n name: 'tree',\n execute: (graph, args) => {\n const pages = graph.getPages()\n const maxDepth = args.depth ?? Infinity\n const page = args.page ? pages.find((p) => p.name === args.page) : pages[0]\n if (!page)\n return {\n error: `Page \"${args.page}\" not found. Available: ${pages.map((p) => p.name).join(', ')}`\n }\n\n return {\n page: { id: page.id, name: page.name, type: page.type },\n children: page.childIds\n .map((cid) => buildTreeNode(graph, cid, 0, maxDepth))\n .filter((n): n is TreeNodeResult => n !== null)\n }\n }\n}\n\n// ── find ──\n\nexport interface FindArgs {\n name?: string\n type?: string\n page?: string\n limit?: number\n}\n\nexport interface FindNodeResult {\n id: string\n name: string\n type: string\n width: number\n height: number\n}\n\nexport const findCommand: RPCCommand<FindArgs, FindNodeResult[]> = {\n name: 'find',\n execute: (graph, args) => {\n const pages = graph.getPages()\n const max = args.limit ?? 100\n const namePattern = args.name?.toLowerCase()\n const typeFilter = args.type?.toUpperCase()\n const results: FindNodeResult[] = []\n\n const searchPage = (page: SceneNode) => {\n for (const cid of page.childIds) {\n const cont = walkNodes(graph, cid, (node) => {\n if (results.length >= max) return false\n const matchesName = !namePattern || node.name.toLowerCase().includes(namePattern)\n const matchesType = !typeFilter || node.type === typeFilter\n if (matchesName && matchesType) {\n results.push({\n id: node.id,\n name: node.name,\n type: node.type,\n width: Math.round(node.width),\n height: Math.round(node.height)\n })\n }\n return true\n })\n if (!cont) break\n }\n }\n\n if (args.page) {\n const page = pages.find((p) => p.name === args.page)\n if (page) searchPage(page)\n } else {\n for (const page of pages) searchPage(page)\n }\n\n return results\n }\n}\n\n// ── query (xpath) ──\n\nexport interface QueryArgs {\n selector: string\n page?: string\n limit?: number\n}\n\nexport interface QueryNodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n}\n\nexport const queryCommand: RPCCommand<QueryArgs, QueryNodeResult[] | { error: string }> = {\n name: 'query',\n execute: async (graph, args) => {\n try {\n const nodes = await queryByXPath(graph, args.selector, {\n page: args.page,\n limit: args.limit\n })\n return nodes.map((n) => ({\n id: n.id,\n name: n.name,\n type: n.type,\n x: Math.round(n.x),\n y: Math.round(n.y),\n width: Math.round(n.width),\n height: Math.round(n.height)\n }))\n } catch (err) {\n return { error: `XPath error: ${err instanceof Error ? err.message : String(err)}` }\n }\n }\n}\n\n// ── node ──\n\nexport interface NodeArgs {\n id: string\n}\n\nexport interface NodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n visible: boolean\n locked: boolean\n opacity: number\n rotation: number\n fills: unknown[]\n strokes: unknown[]\n effects: unknown[]\n cornerRadius: number\n blendMode: string\n layoutMode: string\n layoutDirection: string\n fontFamily: string\n fontSize: number\n fontWeight: number\n textDirection: string\n text: string | null\n parent: { id: string; name: string; type: string } | null\n children: number\n boundVariables: Record<string, string>\n}\n\nexport const nodeCommand: RPCCommand<NodeArgs, NodeResult | { error: string }> = {\n name: 'node',\n execute: (graph, args) => {\n const node = graph.getNode(args.id)\n if (!node) return { error: `Node \"${args.id}\" not found` }\n\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const boundVars: Record<string, string> = {}\n for (const [field, varId] of Object.entries(node.boundVariables)) {\n const variable = graph.variables.get(varId)\n boundVars[field] = variable?.name ?? varId\n }\n\n return {\n id: node.id,\n name: node.name,\n type: node.type,\n ...nodeFrame(node),\n visible: node.visible,\n locked: node.locked,\n opacity: node.opacity,\n rotation: node.rotation,\n fills: node.fills,\n strokes: node.strokes,\n effects: node.effects,\n cornerRadius: node.cornerRadius,\n blendMode: node.blendMode,\n layoutMode: node.layoutMode,\n layoutDirection: node.layoutDirection,\n fontFamily: node.fontFamily,\n fontSize: node.fontSize,\n fontWeight: node.fontWeight,\n textDirection: node.textDirection,\n text: (() => {\n if (!node.text.length) return null\n if (node.text.length > 200) return node.text.slice(0, 200) + ELLIPSIS\n return node.text\n })(),\n parent: parent ? { id: parent.id, name: parent.name, type: parent.type } : null,\n children: node.childIds.length,\n boundVariables: boundVars\n }\n }\n}\n"],"mappings":";;;;;;AAYA,SAAS,UAAU,OAAmB,QAAgB,IAA2C;CAC/F,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO;CACtB,KAAK,MAAM,WAAW,KAAK,UACzB,IAAI,CAAC,UAAU,OAAO,SAAS,EAAE,GAAG,OAAO;CAE7C,OAAO;AACT;AAEA,SAAS,iBAAiB,OAAmB,QAAwB;CACnE,IAAI,QAAQ;CACZ,UAAU,OAAO,cAAc;EAC7B;EACA,OAAO;CACT,CAAC;CACD,OAAO;AACT;AAEA,SAAS,WAAW,OAAmB,QAAwB;CAC7D,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,OAAO,OAAO,MAAM,KAAK,WAAW,OAAO,iBAAiB,OAAO,EAAE,CAAC,IAAI;AAC5E;AAEA,SAAS,UAAU,MAAiB;CAClC,OAAO;EACL,GAAG,KAAK,MAAM,KAAK,CAAC;EACpB,GAAG,KAAK,MAAM,KAAK,CAAC;EACpB,OAAO,KAAK,MAAM,KAAK,KAAK;EAC5B,QAAQ,KAAK,MAAM,KAAK,MAAM;CAChC;AACF;AAYA,MAAa,cAA4C;CACvD,MAAM;CACN,UAAU,UAAU;EAClB,MAAM,QAAQ,MAAM,SAAS;EAC7B,IAAI,aAAa;EACjB,MAAM,QAAgC,CAAC;EACvC,MAAM,wBAAQ,IAAI,IAAY;EAC9B,MAAM,aAAqC,CAAC;EAE5C,MAAM,aAAa,SAAoB;GACrC;GACA,MAAM,KAAK,SAAS,MAAM,KAAK,SAAS,KAAK;GAC7C,IAAI,KAAK,YAAY,MAAM,IAAI,KAAK,UAAU;GAC9C,OAAO;EACT;EAEA,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,aAAa;GACnB,KAAK,MAAM,OAAO,KAAK,UACrB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KAAK,SAAS,KAAK,OAAO,KAAK,KAAK,MAAM,GAAG,GAAG,IAAA;IACzD,OAAO,KAAK;GACd,EAAA,CAAG;GACH,QAAQ,SAAS;IAAE,IAAI,OAAO;IAAI,MAAM,OAAO;IAAM,MAAM,OAAO;GAAK,IAAI;GAC3E,UAAU,KAAK,SAAS;GACxB,gBAAgB;EAClB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"read-commands.js","names":[],"sources":["../../src/rpc/read-commands.ts"],"sourcesContent":["import { sumBy } from 'es-toolkit'\n\nimport type { BooleanOperation, MaskType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { shapeDetailFields } from '#core/figma-api/shape-details'\nimport { ELLIPSIS } from '#core/text/ellipsis'\nimport type { DocumentFontStatus } from '#core/text/font/status'\nimport { prepareGraphFonts } from '#core/text/prepare'\nimport { queryByXPath } from '#core/xpath'\n\nimport type { RPCCommand } from './types'\n\n/** Walk descendants. Callback returns `false` to stop traversal. */\nfunction walkNodes(graph: SceneGraph, rootId: string, fn: (node: SceneNode) => boolean): boolean {\n const node = graph.getNode(rootId)\n if (!node) return true\n if (!fn(node)) return false\n for (const childId of node.childIds) {\n if (!walkNodes(graph, childId, fn)) return false\n }\n return true\n}\n\n/** A page picked by its ID, `page_id`, or by its name, `page`; the ID wins when both are given. */\nexport interface PageArgs {\n page?: string\n page_id?: string\n}\n\n/** The pages `args` picks: the one it names, none when it names a missing page, else `fallback`. */\nfunction pickedPages(graph: SceneGraph, args: PageArgs, fallback: SceneNode[]): SceneNode[] {\n const pages = graph.getPages()\n if (args.page_id) return pages.filter((page) => page.id === args.page_id)\n if (args.page) return pages.filter((page) => page.name === args.page).slice(0, 1)\n return fallback\n}\n\nfunction missingPageError(graph: SceneGraph, args: PageArgs): string {\n const pages = graph.getPages()\n const [label, available] = args.page_id\n ? [args.page_id, pages.map((page) => page.id)]\n : [args.page ?? '', pages.map((page) => page.name)]\n return `Page \"${label}\" not found. Available: ${available.join(', ')}`\n}\n\nfunction countDescendants(graph: SceneGraph, rootId: string): number {\n let count = 0\n walkNodes(graph, rootId, () => {\n count++\n return true\n })\n return count\n}\n\nfunction countNodes(graph: SceneGraph, pageId: string): number {\n const page = graph.getNode(pageId)\n return page ? sumBy(page.childIds, (id) => countDescendants(graph, id)) : 0\n}\n\nfunction nodeFrame(node: SceneNode) {\n return {\n x: Math.round(node.x),\n y: Math.round(node.y),\n width: Math.round(node.width),\n height: Math.round(node.height)\n }\n}\n\n// ── info ──\n\nexport interface InfoResult {\n pages: number\n totalNodes: number\n types: Record<string, number>\n fonts: string[]\n pageCounts: Record<string, number>\n}\n\nexport const infoCommand: RPCCommand<void, InfoResult> = {\n name: 'info',\n execute: (graph) => {\n const pages = graph.getPages()\n let totalNodes = 0\n const types: Record<string, number> = {}\n const fonts = new Set<string>()\n const pageCounts: Record<string, number> = {}\n\n const countNode = (node: SceneNode) => {\n totalNodes++\n types[node.type] = (types[node.type] ?? 0) + 1\n if (node.fontFamily) fonts.add(node.fontFamily)\n return true\n }\n\n for (const page of pages) {\n const beforePage = totalNodes\n for (const cid of page.childIds) {\n walkNodes(graph, cid, countNode)\n }\n pageCounts[page.name] = totalNodes - beforePage\n }\n\n return { pages: pages.length, totalNodes, types, fonts: [...fonts].sort(), pageCounts }\n }\n}\n\nexport const fontStatusCommand: RPCCommand<void, DocumentFontStatus> = {\n name: 'font-status',\n execute: async (graph) => {\n const pageIds = graph.getPages().map((page) => page.id)\n return prepareGraphFonts(graph, pageIds.length > 0 ? pageIds : [graph.rootId])\n }\n}\n\n// ── pages ──\n\nexport interface PageItem {\n id: string\n name: string\n nodes: number\n}\n\nexport const pagesCommand: RPCCommand<void, PageItem[]> = {\n name: 'pages',\n execute: (graph) => {\n return graph.getPages().map((p) => ({ id: p.id, name: p.name, nodes: countNodes(graph, p.id) }))\n }\n}\n\n// ── tree ──\n\nexport interface TreeArgs extends PageArgs {\n depth?: number\n}\n\nexport interface TreeNodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n children?: TreeNodeResult[]\n}\n\nfunction buildTreeNode(\n graph: SceneGraph,\n id: string,\n depth: number,\n maxDepth: number\n): TreeNodeResult | null {\n const node = graph.getNode(id)\n if (!node) return null\n const result: TreeNodeResult = {\n id: node.id,\n name: node.name,\n type: node.type,\n ...nodeFrame(node)\n }\n if (node.childIds.length > 0 && depth < maxDepth) {\n result.children = node.childIds\n .map((cid) => buildTreeNode(graph, cid, depth + 1, maxDepth))\n .filter((n): n is TreeNodeResult => n !== null)\n }\n return result\n}\n\nexport interface TreeResult {\n page: { id: string; name: string; type: string }\n children: TreeNodeResult[]\n}\n\nexport const treeCommand: RPCCommand<TreeArgs, TreeResult | { error: string }> = {\n name: 'tree',\n execute: (graph, args) => {\n const maxDepth = args.depth ?? Infinity\n const page = pickedPages(graph, args, graph.getPages().slice(0, 1)).at(0)\n if (!page) return { error: missingPageError(graph, args) }\n\n return {\n page: { id: page.id, name: page.name, type: page.type },\n children: page.childIds\n .map((cid) => buildTreeNode(graph, cid, 0, maxDepth))\n .filter((n): n is TreeNodeResult => n !== null)\n }\n }\n}\n\n// ── find ──\n\nexport interface FindArgs extends PageArgs {\n name?: string\n type?: string\n limit?: number\n}\n\nexport interface FindNodeResult {\n id: string\n name: string\n type: string\n width: number\n height: number\n}\n\nexport const findCommand: RPCCommand<FindArgs, FindNodeResult[]> = {\n name: 'find',\n execute: (graph, args) => {\n const max = args.limit ?? 100\n const namePattern = args.name?.toLowerCase()\n const typeFilter = args.type?.toUpperCase()\n const results: FindNodeResult[] = []\n\n const searchPage = (page: SceneNode) => {\n for (const cid of page.childIds) {\n const cont = walkNodes(graph, cid, (node) => {\n if (results.length >= max) return false\n const matchesName = !namePattern || node.name.toLowerCase().includes(namePattern)\n const matchesType = !typeFilter || node.type === typeFilter\n if (matchesName && matchesType) {\n results.push({\n id: node.id,\n name: node.name,\n type: node.type,\n width: Math.round(node.width),\n height: Math.round(node.height)\n })\n }\n return true\n })\n if (!cont) break\n }\n }\n\n for (const page of pickedPages(graph, args, graph.getPages())) searchPage(page)\n\n return results\n }\n}\n\n// ── query (xpath) ──\n\nexport interface QueryArgs extends PageArgs {\n selector: string\n limit?: number\n}\n\nexport interface QueryNodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n}\n\nexport const queryCommand: RPCCommand<QueryArgs, QueryNodeResult[] | { error: string }> = {\n name: 'query',\n execute: async (graph, args) => {\n try {\n const nodes = await queryByXPath(graph, args.selector, {\n page: args.page,\n pageId: args.page_id,\n limit: args.limit\n })\n return nodes.map((n) => ({\n id: n.id,\n name: n.name,\n type: n.type,\n x: Math.round(n.x),\n y: Math.round(n.y),\n width: Math.round(n.width),\n height: Math.round(n.height)\n }))\n } catch (err) {\n return { error: `XPath error: ${err instanceof Error ? err.message : String(err)}` }\n }\n }\n}\n\n// ── node ──\n\nexport interface NodeArgs {\n id: string\n}\n\nexport interface NodeResult {\n id: string\n name: string\n type: string\n x: number\n y: number\n width: number\n height: number\n visible: boolean\n locked: boolean\n opacity: number\n rotation: number\n fills: unknown[]\n strokes: unknown[]\n effects: unknown[]\n cornerRadius?: number\n topLeftRadius?: number\n topRightRadius?: number\n bottomRightRadius?: number\n bottomLeftRadius?: number\n isMask?: boolean\n maskType?: MaskType\n booleanOperation?: BooleanOperation\n blendMode: string\n layoutMode: string\n layoutDirection: string\n fontFamily: string\n fontSize: number\n fontWeight: number\n textDirection: string\n text: string | null\n parent: { id: string; name: string; type: string } | null\n children: number\n boundVariables: Record<string, string>\n}\n\nexport const nodeCommand: RPCCommand<NodeArgs, NodeResult | { error: string }> = {\n name: 'node',\n execute: (graph, args) => {\n const node = graph.getNode(args.id)\n if (!node) return { error: `Node \"${args.id}\" not found` }\n\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const boundVars: Record<string, string> = {}\n for (const [field, varId] of Object.entries(node.boundVariables)) {\n const variable = graph.variables.get(varId)\n boundVars[field] = variable?.name ?? varId\n }\n return {\n id: node.id,\n name: node.name,\n type: node.type,\n ...nodeFrame(node),\n visible: node.visible,\n locked: node.locked,\n opacity: node.opacity,\n rotation: node.rotation,\n fills: node.fills,\n strokes: node.strokes,\n effects: node.effects,\n ...shapeDetailFields(node),\n blendMode: node.blendMode,\n layoutMode: node.layoutMode,\n layoutDirection: node.layoutDirection,\n fontFamily: node.fontFamily,\n fontSize: node.fontSize,\n fontWeight: node.fontWeight,\n textDirection: node.textDirection,\n text: (() => {\n if (!node.text.length) return null\n if (node.text.length > 200) return node.text.slice(0, 200) + ELLIPSIS\n return node.text\n })(),\n parent: parent ? { id: parent.id, name: parent.name, type: parent.type } : null,\n children: node.childIds.length,\n boundVariables: boundVars\n }\n }\n}\n"],"mappings":";;;;;;;AAaA,SAAS,UAAU,OAAmB,QAAgB,IAA2C;CAC/F,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO;CACtB,KAAK,MAAM,WAAW,KAAK,UACzB,IAAI,CAAC,UAAU,OAAO,SAAS,EAAE,GAAG,OAAO;CAE7C,OAAO;AACT;;AASA,SAAS,YAAY,OAAmB,MAAgB,UAAoC;CAC1F,MAAM,QAAQ,MAAM,SAAS;CAC7B,IAAI,KAAK,SAAS,OAAO,MAAM,QAAQ,SAAS,KAAK,OAAO,KAAK,OAAO;CACxE,IAAI,KAAK,MAAM,OAAO,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;CAChF,OAAO;AACT;AAEA,SAAS,iBAAiB,OAAmB,MAAwB;CACnE,MAAM,QAAQ,MAAM,SAAS;CAC7B,MAAM,CAAC,OAAO,aAAa,KAAK,UAC5B,CAAC,KAAK,SAAS,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC,IAC3C,CAAC,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC;CACpD,OAAO,SAAS,MAAM,0BAA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AAM,OAAO,MAAM,QAAQ,KAAK,EAAE;EAClC,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,SAAS,KAAK,GAAG,aAAa;EAEzD,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAA;EAC9D,MAAM,YAAoC,CAAC;EAC3C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,cAAc,GAE7D,UAAU,SADO,MAAM,UAAU,IAAI,KACX,CAAC,EAAE,QAAQ;EAEvC,OAAO;GACL,IAAI,KAAK;GACT,MAAM,KAAK;GACX,MAAM,KAAK;GACX,GAAG,UAAU,IAAI;GACjB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,UAAU,KAAK;GACf,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,SAAS,KAAK;GACd,GAAG,kBAAkB,IAAI;GACzB,WAAW,KAAK;GAChB,YAAY,KAAK;GACjB,iBAAiB,KAAK;GACtB,YAAY,KAAK;GACjB,UAAU,KAAK;GACf,YAAY,KAAK;GACjB,eAAe,KAAK;GACpB,aAAa;IACX,IAAI,CAAC,KAAK,KAAK,QAAQ,OAAO;IAC9B,IAAI,KAAK,KAAK,SAAS,KAAK,OAAO,KAAK,KAAK,MAAM,GAAG,GAAG,IAAA;IACzD,OAAO,KAAK;GACd,EAAA,CAAG;GACH,QAAQ,SAAS;IAAE,IAAI,OAAO;IAAI,MAAM,OAAO;IAAM,MAAM,OAAO;GAAK,IAAI;GAC3E,UAAU,KAAK,SAAS;GACxB,gBAAgB;EAClB;CACF;AACF"}
|
|
@@ -38,6 +38,17 @@ declare function fontFaceFromFigmaFontName(fontName: {
|
|
|
38
38
|
postscript?: string;
|
|
39
39
|
}): FontFaceRef;
|
|
40
40
|
declare function fontFaceRenderFamily(family: string, style: string): string;
|
|
41
|
+
/** What a font file is registered with in the page's `document.fonts`. */
|
|
42
|
+
interface BrowserFaceDescriptors {
|
|
43
|
+
weight: string;
|
|
44
|
+
style: 'normal' | 'italic';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The page face for a font file loaded as `style`. A variable font covers its whole `wght` range,
|
|
48
|
+
* so text at any weight draws from the font's own instance; registered at the one weight `style`
|
|
49
|
+
* names, every other weight would fall back to that instance, synthesized bold or not at all.
|
|
50
|
+
*/
|
|
51
|
+
declare function browserFaceDescriptors(style: string, data: ArrayBuffer): BrowserFaceDescriptors;
|
|
41
52
|
//#endregion
|
|
42
|
-
export { FaceWeight, FamilyFace, FontFaceRef, facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces };
|
|
53
|
+
export { BrowserFaceDescriptors, FaceWeight, FamilyFace, FontFaceRef, browserFaceDescriptors, facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces };
|
|
43
54
|
//# sourceMappingURL=faces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faces.d.ts","names":[],"sources":["../../../src/text/font/faces.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"faces.d.ts","names":[],"sources":["../../../src/text/font/faces.ts"],"mappings":";;;UAYiB;EACf;EACA;;;UAIe,mBAAmB;EAClC;;;;;;;iBAQc,gBAAgB,4BAA4B;;iBAU5C,aAAa,gBAAgB,kBAAkB;;iBAK/C,cAAc,4BAA4B;iBAI1C,cAAc,gBAAgB,cAAc,gBAAgB;;;;;;iBAS5D,kBACd,gBAAgB,cAChB,gBACA,kBACC;;UAcc,oBAAoB;EACnC;EACA;EACA;;iBAGc,0BAA0B;EACxC;EACA;EACA;IACE;iBAUY,qBAAqB,gBAAgB;;UAKpC;EACf;EACA;;;;;;;iBAQc,uBAAuB,eAAe,MAAM,cAAc"}
|
package/dist/text/font/faces.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fontAxes } from "./variation.js";
|
|
1
2
|
import { namesWidth, parseFontStyle, standardStyleName } from "@pairdraw/scene-graph/font-style";
|
|
2
3
|
import { partition, uniqBy } from "es-toolkit";
|
|
3
4
|
//#region src/text/font/faces.ts
|
|
@@ -58,7 +59,20 @@ function fontFaceFromFigmaFontName(fontName) {
|
|
|
58
59
|
function fontFaceRenderFamily(family, style) {
|
|
59
60
|
return `__pairdraw_font__${family.replace(/[^a-z0-9_-]+/giu, "_")}__${style.replace(/[^a-z0-9_-]+/giu, "_")}`;
|
|
60
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* The page face for a font file loaded as `style`. A variable font covers its whole `wght` range,
|
|
64
|
+
* so text at any weight draws from the font's own instance; registered at the one weight `style`
|
|
65
|
+
* names, every other weight would fall back to that instance, synthesized bold or not at all.
|
|
66
|
+
*/
|
|
67
|
+
function browserFaceDescriptors(style, data) {
|
|
68
|
+
const { weight, italic } = parseFontStyle(style);
|
|
69
|
+
const wght = fontAxes(data)?.find((axis) => axis.tag === "wght");
|
|
70
|
+
return {
|
|
71
|
+
weight: wght ? `${wght.min} ${wght.max}` : String(weight),
|
|
72
|
+
style: italic ? "italic" : "normal"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
61
75
|
//#endregion
|
|
62
|
-
export { facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces };
|
|
76
|
+
export { browserFaceDescriptors, facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces };
|
|
63
77
|
|
|
64
78
|
//# sourceMappingURL=faces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faces.js","names":[],"sources":["../../../src/text/font/faces.ts"],"sourcesContent":["import { partition, uniqBy } from 'es-toolkit'\n\nimport {\n namesWidth,\n parseFontStyle,\n standardStyleName,\n type ParsedFontStyle\n} from '@pairdraw/scene-graph/font-style'\n\n/** A weight, upright or italic. */\nexport interface FaceWeight {\n weight: number\n italic: boolean\n}\n\n/** One face a font family has: a weight, upright or italic, and the name its font gives it. */\nexport interface FamilyFace extends FaceWeight {\n style: string\n}\n\n/**\n * The faces named by a family's style names, such as \"Bold Italic\" or \"Semi Bold\", each keeping\n * its name, in the order listed. Of two names for one weight and slant, the first listed is the\n * face's, and a normal-width name (\"Medium\") goes before a width name (\"Compressed Medium\").\n */\nexport function facesFromStyles(styles: readonly string[]): FamilyFace[] {\n const faces = styles.map((style) => ({ ...parseFontStyle(style), style }))\n const [normalWidth, otherWidth] = partition(faces, (face) => !namesWidth(face.style))\n const slotFaces = new Set(\n uniqBy([...normalWidth, ...otherWidth], (face) => `${face.weight}${face.italic ? 'i' : ''}`)\n )\n return faces.filter((face) => slotFaces.has(face))\n}\n\n/** A face named as Google Fonts names it, for a source that gives weights but no names. */\nexport function standardFace(weight: number, italic: boolean): FamilyFace {\n return { weight, italic, style: standardStyleName(weight, italic) }\n}\n\n/** The faces style keys stand for, named as Google Fonts names them. */\nexport function standardFaces(styles: readonly string[]): FamilyFace[] {\n return facesFromStyles(styles).map((face) => standardFace(face.weight, face.italic))\n}\n\nexport function hasFamilyFace(faces: readonly FaceWeight[], weight: number, italic: boolean) {\n return faces.some((face) => face.weight === weight && face.italic === italic)\n}\n\n/**\n * The face a text takes in a family, as Figma picks it when the family changes: the same weight\n * and slant where the family has it, otherwise the nearest weight with the same slant, or the\n * nearest weight at all in a family without that slant. Equally near weights take the lighter.\n */\nexport function nearestFamilyFace(\n faces: readonly FamilyFace[],\n weight: number,\n italic: boolean\n): FamilyFace | null {\n const sameSlant = faces.filter((face) => face.italic === italic)\n const candidates = sameSlant.length > 0 ? sameSlant : faces\n let nearest: FamilyFace | null = null\n for (const face of candidates) {\n const distance = Math.abs(face.weight - weight)\n const best = nearest ? Math.abs(nearest.weight - weight) : Infinity\n if (distance < best || (distance === best && nearest && face.weight < nearest.weight))\n nearest = face\n }\n return nearest\n}\n\n/** A face text asks the font manager for: its family, its style key, and its weight and slant. */\nexport interface FontFaceRef extends ParsedFontStyle {\n family: string\n style: string\n postscriptName?: string\n}\n\nexport function fontFaceFromFigmaFontName(fontName: {\n family?: string\n style?: string\n postscript?: string\n}): FontFaceRef {\n const style = fontName.style ?? 'Regular'\n return {\n family: fontName.family ?? 'Inter',\n style,\n postscriptName: fontName.postscript,\n ...parseFontStyle(style)\n }\n}\n\nexport function fontFaceRenderFamily(family: string, style: string): string {\n return `__pairdraw_font__${family.replace(/[^a-z0-9_-]+/giu, '_')}__${style.replace(/[^a-z0-9_-]+/giu, '_')}`\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"faces.js","names":[],"sources":["../../../src/text/font/faces.ts"],"sourcesContent":["import { partition, uniqBy } from 'es-toolkit'\n\nimport {\n namesWidth,\n parseFontStyle,\n standardStyleName,\n type ParsedFontStyle\n} from '@pairdraw/scene-graph/font-style'\n\nimport { fontAxes } from './variation'\n\n/** A weight, upright or italic. */\nexport interface FaceWeight {\n weight: number\n italic: boolean\n}\n\n/** One face a font family has: a weight, upright or italic, and the name its font gives it. */\nexport interface FamilyFace extends FaceWeight {\n style: string\n}\n\n/**\n * The faces named by a family's style names, such as \"Bold Italic\" or \"Semi Bold\", each keeping\n * its name, in the order listed. Of two names for one weight and slant, the first listed is the\n * face's, and a normal-width name (\"Medium\") goes before a width name (\"Compressed Medium\").\n */\nexport function facesFromStyles(styles: readonly string[]): FamilyFace[] {\n const faces = styles.map((style) => ({ ...parseFontStyle(style), style }))\n const [normalWidth, otherWidth] = partition(faces, (face) => !namesWidth(face.style))\n const slotFaces = new Set(\n uniqBy([...normalWidth, ...otherWidth], (face) => `${face.weight}${face.italic ? 'i' : ''}`)\n )\n return faces.filter((face) => slotFaces.has(face))\n}\n\n/** A face named as Google Fonts names it, for a source that gives weights but no names. */\nexport function standardFace(weight: number, italic: boolean): FamilyFace {\n return { weight, italic, style: standardStyleName(weight, italic) }\n}\n\n/** The faces style keys stand for, named as Google Fonts names them. */\nexport function standardFaces(styles: readonly string[]): FamilyFace[] {\n return facesFromStyles(styles).map((face) => standardFace(face.weight, face.italic))\n}\n\nexport function hasFamilyFace(faces: readonly FaceWeight[], weight: number, italic: boolean) {\n return faces.some((face) => face.weight === weight && face.italic === italic)\n}\n\n/**\n * The face a text takes in a family, as Figma picks it when the family changes: the same weight\n * and slant where the family has it, otherwise the nearest weight with the same slant, or the\n * nearest weight at all in a family without that slant. Equally near weights take the lighter.\n */\nexport function nearestFamilyFace(\n faces: readonly FamilyFace[],\n weight: number,\n italic: boolean\n): FamilyFace | null {\n const sameSlant = faces.filter((face) => face.italic === italic)\n const candidates = sameSlant.length > 0 ? sameSlant : faces\n let nearest: FamilyFace | null = null\n for (const face of candidates) {\n const distance = Math.abs(face.weight - weight)\n const best = nearest ? Math.abs(nearest.weight - weight) : Infinity\n if (distance < best || (distance === best && nearest && face.weight < nearest.weight))\n nearest = face\n }\n return nearest\n}\n\n/** A face text asks the font manager for: its family, its style key, and its weight and slant. */\nexport interface FontFaceRef extends ParsedFontStyle {\n family: string\n style: string\n postscriptName?: string\n}\n\nexport function fontFaceFromFigmaFontName(fontName: {\n family?: string\n style?: string\n postscript?: string\n}): FontFaceRef {\n const style = fontName.style ?? 'Regular'\n return {\n family: fontName.family ?? 'Inter',\n style,\n postscriptName: fontName.postscript,\n ...parseFontStyle(style)\n }\n}\n\nexport function fontFaceRenderFamily(family: string, style: string): string {\n return `__pairdraw_font__${family.replace(/[^a-z0-9_-]+/giu, '_')}__${style.replace(/[^a-z0-9_-]+/giu, '_')}`\n}\n\n/** What a font file is registered with in the page's `document.fonts`. */\nexport interface BrowserFaceDescriptors {\n weight: string\n style: 'normal' | 'italic'\n}\n\n/**\n * The page face for a font file loaded as `style`. A variable font covers its whole `wght` range,\n * so text at any weight draws from the font's own instance; registered at the one weight `style`\n * names, every other weight would fall back to that instance, synthesized bold or not at all.\n */\nexport function browserFaceDescriptors(style: string, data: ArrayBuffer): BrowserFaceDescriptors {\n const { weight, italic } = parseFontStyle(style)\n const wght = fontAxes(data)?.find((axis) => axis.tag === 'wght')\n return {\n weight: wght ? `${wght.min} ${wght.max}` : String(weight),\n style: italic ? 'italic' : 'normal'\n }\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,gBAAgB,QAAyC;CACvE,MAAM,QAAQ,OAAO,KAAK,WAAW;EAAE,GAAG,eAAe,KAAK;EAAG;CAAM,EAAE;CACzE,MAAM,CAAC,aAAa,cAAc,UAAU,QAAQ,SAAS,CAAC,WAAW,KAAK,KAAK,CAAC;CACpF,MAAM,YAAY,IAAI,IACpB,OAAO,CAAC,GAAG,aAAa,GAAG,UAAU,IAAI,SAAS,GAAG,KAAK,SAAS,KAAK,SAAS,MAAM,IAAI,CAC7F;CACA,OAAO,MAAM,QAAQ,SAAS,UAAU,IAAI,IAAI,CAAC;AACnD;;AAGA,SAAgB,aAAa,QAAgB,QAA6B;CACxE,OAAO;EAAE;EAAQ;EAAQ,OAAO,kBAAkB,QAAQ,MAAM;CAAE;AACpE;;AAGA,SAAgB,cAAc,QAAyC;CACrE,OAAO,gBAAgB,MAAM,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,QAAQ,KAAK,MAAM,CAAC;AACrF;AAEA,SAAgB,cAAc,OAA8B,QAAgB,QAAiB;CAC3F,OAAO,MAAM,MAAM,SAAS,KAAK,WAAW,UAAU,KAAK,WAAW,MAAM;AAC9E;;;;;;AAOA,SAAgB,kBACd,OACA,QACA,QACmB;CACnB,MAAM,YAAY,MAAM,QAAQ,SAAS,KAAK,WAAW,MAAM;CAC/D,MAAM,aAAa,UAAU,SAAS,IAAI,YAAY;CACtD,IAAI,UAA6B;CACjC,KAAK,MAAM,QAAQ,YAAY;EAC7B,MAAM,WAAW,KAAK,IAAI,KAAK,SAAS,MAAM;EAC9C,MAAM,OAAO,UAAU,KAAK,IAAI,QAAQ,SAAS,MAAM,IAAI;EAC3D,IAAI,WAAW,QAAS,aAAa,QAAQ,WAAW,KAAK,SAAS,QAAQ,QAC5E,UAAU;CACd;CACA,OAAO;AACT;AASA,SAAgB,0BAA0B,UAI1B;CACd,MAAM,QAAQ,SAAS,SAAS;CAChC,OAAO;EACL,QAAQ,SAAS,UAAU;EAC3B;EACA,gBAAgB,SAAS;EACzB,GAAG,eAAe,KAAK;CACzB;AACF;AAEA,SAAgB,qBAAqB,QAAgB,OAAuB;CAC1E,OAAO,oBAAoB,OAAO,QAAQ,mBAAmB,GAAG,EAAE,IAAI,MAAM,QAAQ,mBAAmB,GAAG;AAC5G;;;;;;AAaA,SAAgB,uBAAuB,OAAe,MAA2C;CAC/F,MAAM,EAAE,QAAQ,WAAW,eAAe,KAAK;CAC/C,MAAM,OAAO,SAAS,IAAI,CAAC,EAAE,MAAM,SAAS,KAAK,QAAQ,MAAM;CAC/D,OAAO;EACL,QAAQ,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,QAAQ,OAAO,MAAM;EACxD,OAAO,SAAS,WAAW;CAC7B;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/text/font/features.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a
|
|
4
|
+
* font without one. The panel offers a feature only when the font actually has it, as Figma does.
|
|
5
|
+
*/
|
|
6
|
+
declare function fontFeatureTags(data: ArrayBuffer): string[] | null;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { fontFeatureTags };
|
|
9
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","names":[],"sources":["../../../src/text/font/features.ts"],"mappings":";;;;;iBAQgB,gBAAgB,MAAM"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { fontTableView } from "./variation.js";
|
|
2
|
+
import { uniq } from "es-toolkit/array";
|
|
3
|
+
//#region src/text/font/features.ts
|
|
4
|
+
/**
|
|
5
|
+
* The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a
|
|
6
|
+
* font without one. The panel offers a feature only when the font actually has it, as Figma does.
|
|
7
|
+
*/
|
|
8
|
+
function fontFeatureTags(data) {
|
|
9
|
+
const gsub = fontTableView(data, "GSUB");
|
|
10
|
+
if (!gsub || gsub.byteLength < 14) return null;
|
|
11
|
+
const featureListOffset = gsub.getUint16(6);
|
|
12
|
+
if (featureListOffset + 2 > gsub.byteLength) return null;
|
|
13
|
+
const count = gsub.getUint16(featureListOffset);
|
|
14
|
+
const tags = [];
|
|
15
|
+
for (let index = 0; index < count; index++) {
|
|
16
|
+
const record = featureListOffset + 2 + index * 6;
|
|
17
|
+
if (record + 4 > gsub.byteLength) break;
|
|
18
|
+
let tag = "";
|
|
19
|
+
for (let c = 0; c < 4; c++) tag += String.fromCharCode(gsub.getUint8(record + c));
|
|
20
|
+
tags.push(tag.toUpperCase());
|
|
21
|
+
}
|
|
22
|
+
return uniq(tags);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { fontFeatureTags };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","names":[],"sources":["../../../src/text/font/features.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\n\nimport { fontTableView } from './variation'\n\n/**\n * The OpenType feature tags a font's GSUB table lists, in the table's own order, or `null` for a\n * font without one. The panel offers a feature only when the font actually has it, as Figma does.\n */\nexport function fontFeatureTags(data: ArrayBuffer): string[] | null {\n const gsub = fontTableView(data, 'GSUB')\n if (!gsub || gsub.byteLength < 14) return null\n // GSUB header: version (4), ScriptList offset (2), FeatureList offset (2), LookupList offset (2);\n // version 1.1 adds a FeatureVariations offset (4). The FeatureList offset is at byte 6 either way.\n const featureListOffset = gsub.getUint16(6)\n if (featureListOffset + 2 > gsub.byteLength) return null\n const count = gsub.getUint16(featureListOffset)\n const tags: string[] = []\n for (let index = 0; index < count; index++) {\n // Each FeatureRecord: a 4-byte tag and a 2-byte offset to its feature table.\n const record = featureListOffset + 2 + index * 6\n if (record + 4 > gsub.byteLength) break\n let tag = ''\n for (let c = 0; c < 4; c++) tag += String.fromCharCode(gsub.getUint8(record + c))\n tags.push(tag.toUpperCase())\n }\n return uniq(tags)\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,gBAAgB,MAAoC;CAClE,MAAM,OAAO,cAAc,MAAM,MAAM;CACvC,IAAI,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO;CAG1C,MAAM,oBAAoB,KAAK,UAAU,CAAC;CAC1C,IAAI,oBAAoB,IAAI,KAAK,YAAY,OAAO;CACpD,MAAM,QAAQ,KAAK,UAAU,iBAAiB;CAC9C,MAAM,OAAiB,CAAC;CACxB,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,SAAS;EAE1C,MAAM,SAAS,oBAAoB,IAAI,QAAQ;EAC/C,IAAI,SAAS,IAAI,KAAK,YAAY;EAClC,IAAI,MAAM;EACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,OAAO,OAAO,aAAa,KAAK,SAAS,SAAS,CAAC,CAAC;EAChF,KAAK,KAAK,IAAI,YAAY,CAAC;CAC7B;CACA,OAAO,KAAK,IAAI;AAClB"}
|
|
@@ -32,6 +32,7 @@ declare class FontManager {
|
|
|
32
32
|
private remoteCoverage;
|
|
33
33
|
private instanceVariations;
|
|
34
34
|
private variations;
|
|
35
|
+
private featureTags;
|
|
35
36
|
private blockedNodeIds;
|
|
36
37
|
private fontProvider;
|
|
37
38
|
private fontProviders;
|
|
@@ -129,6 +130,11 @@ declare class FontManager {
|
|
|
129
130
|
private downloadFont;
|
|
130
131
|
loadFont(family: string, style?: string, characters?: string, signal?: AbortSignal): Promise<ArrayBuffer | null>;
|
|
131
132
|
private findFont;
|
|
133
|
+
/**
|
|
134
|
+
* A CSS generic keyword draws a face of the class it names: the first concrete family the host
|
|
135
|
+
* has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.
|
|
136
|
+
*/
|
|
137
|
+
private loadGenericFont;
|
|
132
138
|
/**
|
|
133
139
|
* `data`, or a web font fetched again with `characters` when it came from the web without them,
|
|
134
140
|
* as a provider cuts a font down to the text it is asked for.
|
|
@@ -159,6 +165,12 @@ declare class FontManager {
|
|
|
159
165
|
axes: FontAxis[];
|
|
160
166
|
instances: NamedInstance[];
|
|
161
167
|
} | null | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`
|
|
170
|
+
* when no face of the family is loaded, `null` when its font has no GSUB table, else the tags
|
|
171
|
+
* (empty when the table lists none). The panel offers a feature only when the font has it.
|
|
172
|
+
*/
|
|
173
|
+
familyFeatures(family: string): string[] | null | undefined;
|
|
162
174
|
/** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */
|
|
163
175
|
namedInstanceVariations(family: string, style: string): FontVariation[] | null;
|
|
164
176
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","names":[],"sources":["../../../src/text/font/manager.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","names":[],"sources":["../../../src/text/font/manager.ts"],"mappings":";;;;;;;;;;cA0Fa;UACH;;UAEA;UACA;UACA;UACA;;UAEA;;;;;;UAMA;;;;;;UAMA;UACA;UACA;UACA;UAIA;UACA;UACA;UACA;UACA;UACA;UACA;mBACS;UAIT;UACA;UACA;mBACS;UACT;mBACS;mBACA;mBACA;mBACA;mBACA;UAKT;UACA;;mBAES;mBAGA;;;;;;;;;EAUjB,gBAAgB,WAAW,YAAY;EAiBvC,gBAAgB,UAAU;EAY1B,eAAe,WAAW,WAAW,UAAU;EAgB/C,eAAe,UAAU;EASzB,YAAY;;EAKZ,YAAY,WAAW,YAAY;EAQnC;EAIA,4BAA4B;EAI5B,aAAa;;;;;EAUb,iBAAiB,WAAW;EAK5B,cAAc;EAId,oBAAoB;EAIpB,uBAAuB,OAAO;EAI9B,qBAAqB;EAIrB,kBAAk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IR,mBACE,UAAS,sBACT,qBACA,SAAS,cACR,QAAQ,QAAQ,OAAO;UAIZ;;;;;EA8Bd;EAIA,wBAAwB,QAAQ,sBAAsB;;;;;;;;UAYxC;;UAwCA;;;;;;UA0BN;UAyBA;UAQM;UAwBA;UAcA;;UAeN;UAiBA;;;;;EAoCR,aAAa,WAAW,gBAAgB;UAKhC;UAQA;;EAwBR,sBAAsB,gBAAgB,eAAe,MAAM;;cAsBhD,aAAW"}
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
import { DEFAULT_FONT_FAMILY, IS_BROWSER } from "../../constants.js";
|
|
2
2
|
import { LETTER_FALLBACK_SCRIPTS, fallbackDrawsCharacter, fontFallbackEntry } from "../fallbacks.js";
|
|
3
3
|
import { BundledFonts } from "./bundled.js";
|
|
4
|
-
import { fontFaceRenderFamily } from "./faces.js";
|
|
5
|
-
import { FamilyFaceCatalog } from "./catalog.js";
|
|
6
|
-
import { resetFontCollection } from "./collection.js";
|
|
7
4
|
import { fontAxes, hasNamedInstance, namedInstanceVariations, namedInstances } from "./variation.js";
|
|
5
|
+
import { browserFaceDescriptors, fontFaceRenderFamily } from "./faces.js";
|
|
6
|
+
import { FamilyFaceCatalog } from "./catalog.js";
|
|
7
|
+
import { makeParagraphBuilder, resetFontCollection } from "./collection.js";
|
|
8
|
+
import { fontFeatureTags } from "./features.js";
|
|
8
9
|
import { loadHarfBuzz } from "./harfbuzz.js";
|
|
9
10
|
import { SharedReads, sameFontFile, withHarfBuzz } from "./reads.js";
|
|
10
11
|
import { LocalFonts } from "./local.js";
|
|
11
12
|
import { UnsupportedFontFormatError } from "./sources.js";
|
|
12
13
|
import { collectGraphFontKeys } from "../requirements/collect.js";
|
|
13
14
|
import { WebFontResolver, normalizedCoverageText } from "../web-font/resolver.js";
|
|
14
|
-
import { faceLoadKey, namesWeight, normalizeFontFamily, parseFontStyle
|
|
15
|
+
import { faceLoadKey, namesWeight, normalizeFontFamily, parseFontStyle } from "@pairdraw/scene-graph/font-style";
|
|
15
16
|
import { uniq } from "es-toolkit";
|
|
17
|
+
import { GENERIC_FONT_FAMILIES_BY_CLASS, genericFontFamilyClass, isGenericFontFamily } from "@pairdraw/scene-graph/css";
|
|
16
18
|
//#region src/text/font/manager.ts
|
|
19
|
+
/**
|
|
20
|
+
* How long a web-font fetch may run before the page falls back to an installed or bundled face.
|
|
21
|
+
* A provider that never answers must not block page preparation.
|
|
22
|
+
*/
|
|
23
|
+
const WEB_FONT_FETCH_TIMEOUT_MS = 1e4;
|
|
24
|
+
/**
|
|
25
|
+
* `load`, bounded by `ms` and cancelled as soon as `signal` aborts, so a provider that never
|
|
26
|
+
* answers cannot block page preparation. The timer clears when the load settles.
|
|
27
|
+
*/
|
|
28
|
+
async function fetchWithin(load, signal, ms) {
|
|
29
|
+
const bounded = new AbortController();
|
|
30
|
+
const forward = () => bounded.abort(signal?.reason);
|
|
31
|
+
signal?.addEventListener("abort", forward, { once: true });
|
|
32
|
+
const timer = setTimeout(() => bounded.abort(/* @__PURE__ */ new Error("Web font fetch timed out")), ms);
|
|
33
|
+
try {
|
|
34
|
+
return await load(bounded.signal);
|
|
35
|
+
} finally {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
signal?.removeEventListener("abort", forward);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
17
40
|
var FontManager = class {
|
|
18
41
|
loadedFamilies = /* @__PURE__ */ new Map();
|
|
19
42
|
/** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */
|
|
@@ -38,6 +61,7 @@ var FontManager = class {
|
|
|
38
61
|
remoteCoverage = /* @__PURE__ */ new Map();
|
|
39
62
|
instanceVariations = /* @__PURE__ */ new WeakMap();
|
|
40
63
|
variations = /* @__PURE__ */ new WeakMap();
|
|
64
|
+
featureTags = /* @__PURE__ */ new WeakMap();
|
|
41
65
|
blockedNodeIds = /* @__PURE__ */ new Set();
|
|
42
66
|
fontProvider = null;
|
|
43
67
|
fontProviders = /* @__PURE__ */ new Set();
|
|
@@ -324,7 +348,7 @@ var FontManager = class {
|
|
|
324
348
|
const requestedCharacters = normalizedCoverageText(`${coverage ? Array.from(coverage).join("") : ""}${characters}`);
|
|
325
349
|
const normalized = normalizeFontFamily(family);
|
|
326
350
|
const families = normalized === family ? [family] : [family, normalized];
|
|
327
|
-
const resolved = await this.webFonts.fetchFont(families, style, requestedCharacters, signal);
|
|
351
|
+
const resolved = await fetchWithin((boundedSignal) => this.webFonts.fetchFont(families, style, requestedCharacters, boundedSignal), signal, WEB_FONT_FETCH_TIMEOUT_MS);
|
|
328
352
|
if (!resolved || resolved.buffers.length === 0) return null;
|
|
329
353
|
const primary = resolved.buffers[0];
|
|
330
354
|
if (!namesWeight(style) && !hasNamedInstance(primary, style)) return null;
|
|
@@ -346,6 +370,7 @@ var FontManager = class {
|
|
|
346
370
|
}
|
|
347
371
|
async findFont(family, style = "Regular", characters = "", signal) {
|
|
348
372
|
signal?.throwIfAborted();
|
|
373
|
+
if (isGenericFontFamily(family)) return this.loadGenericFont(family, style);
|
|
349
374
|
const loaded = this.loadedData(family, style);
|
|
350
375
|
if (loaded) {
|
|
351
376
|
this.registerFontInCanvasKit(family, loaded);
|
|
@@ -358,6 +383,21 @@ var FontManager = class {
|
|
|
358
383
|
return await this.loadBundledFont(family, style) ?? await this.loadCachedFont(family, style, characters) ?? await this.loadRemoteFont(family, style, characters, signal);
|
|
359
384
|
}
|
|
360
385
|
/**
|
|
386
|
+
* A CSS generic keyword draws a face of the class it names: the first concrete family the host
|
|
387
|
+
* has, else a bundled one. Its bytes register under the keyword, so the text keeps its name.
|
|
388
|
+
*/
|
|
389
|
+
async loadGenericFont(keyword, style) {
|
|
390
|
+
const kind = genericFontFamilyClass(keyword);
|
|
391
|
+
if (!kind) return null;
|
|
392
|
+
for (const candidate of GENERIC_FONT_FAMILIES_BY_CLASS[kind]) {
|
|
393
|
+
const installed = await this.loadInstalledFont(candidate, style);
|
|
394
|
+
if (installed) return this.registerAndCache(keyword, style, installed, "local");
|
|
395
|
+
const bundled = await this.loadBundledFont(candidate, style);
|
|
396
|
+
if (bundled) return this.registerAndCache(keyword, style, bundled, "bundled");
|
|
397
|
+
}
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
361
401
|
* `data`, or a web font fetched again with `characters` when it came from the web without them,
|
|
362
402
|
* as a provider cuts a font down to the text it is asked for.
|
|
363
403
|
*/
|
|
@@ -445,6 +485,25 @@ var FontManager = class {
|
|
|
445
485
|
}
|
|
446
486
|
return loaded ? other : void 0;
|
|
447
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* The OpenType feature tags a family's loaded font has, from its GSUB feature list: `undefined`
|
|
490
|
+
* when no face of the family is loaded, `null` when its font has no GSUB table, else the tags
|
|
491
|
+
* (empty when the table lists none). The panel offers a feature only when the font has it.
|
|
492
|
+
*/
|
|
493
|
+
familyFeatures(family) {
|
|
494
|
+
let loaded = false;
|
|
495
|
+
for (const [key, data] of this.loadedFamilies) {
|
|
496
|
+
if (!key.startsWith(`${family}|`)) continue;
|
|
497
|
+
loaded = true;
|
|
498
|
+
let tags = this.featureTags.get(data);
|
|
499
|
+
if (tags === void 0) {
|
|
500
|
+
tags = fontFeatureTags(data);
|
|
501
|
+
this.featureTags.set(data, tags);
|
|
502
|
+
}
|
|
503
|
+
if (tags !== null) return tags;
|
|
504
|
+
}
|
|
505
|
+
return loaded ? null : void 0;
|
|
506
|
+
}
|
|
448
507
|
/** Axis coordinates for `style` when the loaded face is a variable font, otherwise `null`. */
|
|
449
508
|
namedInstanceVariations(family, style) {
|
|
450
509
|
const data = this.loadedData(family, style);
|
|
@@ -623,7 +682,7 @@ var FontManager = class {
|
|
|
623
682
|
fontFamilies: [...families],
|
|
624
683
|
fontSize: 16
|
|
625
684
|
} });
|
|
626
|
-
const builder = canvasKit
|
|
685
|
+
const builder = makeParagraphBuilder(canvasKit, style, provider);
|
|
627
686
|
try {
|
|
628
687
|
builder.addText(characters.join(""));
|
|
629
688
|
const paragraph = builder.build();
|
|
@@ -745,12 +804,7 @@ var FontManager = class {
|
|
|
745
804
|
/** Makes a face available to the page's own text, such as fields over canvas labels. */
|
|
746
805
|
registerFontInBrowser(family, style, data) {
|
|
747
806
|
if (!IS_BROWSER) return;
|
|
748
|
-
const
|
|
749
|
-
const italic = style.toLowerCase().includes("italic") ? "italic" : "normal";
|
|
750
|
-
const face = new FontFace(family, data, {
|
|
751
|
-
weight: String(weight),
|
|
752
|
-
style: italic
|
|
753
|
-
});
|
|
807
|
+
const face = new FontFace(family, data, browserFaceDescriptors(style, data));
|
|
754
808
|
face.load().then(() => document.fonts.add(face)).catch(() => {
|
|
755
809
|
console.warn(`Failed to load font "${family}" (${style})`);
|
|
756
810
|
});
|