@popcraft/kit 0.1.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.
Files changed (171) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +74 -0
  4. package/dist/index.js +160558 -0
  5. package/package.json +40 -0
  6. package/types/design-script.d.ts +39 -0
  7. package/types/lib/agent/design-script/build.d.ts +35 -0
  8. package/types/lib/agent/design-script/check.d.ts +11 -0
  9. package/types/lib/agent/design-script/helper-names.d.ts +1 -0
  10. package/types/lib/agent/design-script/kit-modules.d.ts +43 -0
  11. package/types/lib/agent/design-script/recorder.d.ts +52 -0
  12. package/types/lib/agent/design-script/replay.d.ts +13 -0
  13. package/types/lib/agent/design-script/run-node.d.ts +2 -0
  14. package/types/lib/ai/audio-models.d.ts +66 -0
  15. package/types/lib/ai/content.d.ts +27 -0
  16. package/types/lib/ai/limits.d.ts +42 -0
  17. package/types/lib/audio/presentation/loudness.d.ts +80 -0
  18. package/types/lib/audio/presentation/types.d.ts +112 -0
  19. package/types/lib/brand/apply.d.ts +25 -0
  20. package/types/lib/brand/review-kits.d.ts +10 -0
  21. package/types/lib/brand/types.d.ts +20 -0
  22. package/types/lib/code/hash.d.ts +2 -0
  23. package/types/lib/document/auto-layout.d.ts +10 -0
  24. package/types/lib/document/breakpoints.d.ts +45 -0
  25. package/types/lib/document/clone.d.ts +6 -0
  26. package/types/lib/document/color.d.ts +52 -0
  27. package/types/lib/document/detach.d.ts +12 -0
  28. package/types/lib/document/effects.d.ts +60 -0
  29. package/types/lib/document/expressions.d.ts +78 -0
  30. package/types/lib/document/instance-layout.d.ts +94 -0
  31. package/types/lib/document/instances.d.ts +63 -0
  32. package/types/lib/document/libraries.d.ts +97 -0
  33. package/types/lib/document/node-delta.d.ts +21 -0
  34. package/types/lib/document/page-tokens.d.ts +16 -0
  35. package/types/lib/document/photo-frames.d.ts +14 -0
  36. package/types/lib/document/print-pages.d.ts +85 -0
  37. package/types/lib/document/scene-graph.d.ts +194 -0
  38. package/types/lib/document/scene3d.d.ts +76 -0
  39. package/types/lib/document/shader-graph-effects.d.ts +8 -0
  40. package/types/lib/document/shader-graph.d.ts +134 -0
  41. package/types/lib/document/shader-params.d.ts +65 -0
  42. package/types/lib/document/shape-to-path.d.ts +20 -0
  43. package/types/lib/document/text-styles.d.ts +28 -0
  44. package/types/lib/document/text-tokens.d.ts +6 -0
  45. package/types/lib/document/transform.d.ts +79 -0
  46. package/types/lib/document/transform3d.d.ts +99 -0
  47. package/types/lib/document/trim.d.ts +35 -0
  48. package/types/lib/document/types.d.ts +2560 -0
  49. package/types/lib/document/variables.d.ts +14 -0
  50. package/types/lib/editor/easing.d.ts +46 -0
  51. package/types/lib/editor/modes/types.d.ts +131 -0
  52. package/types/lib/editor/prototype-connect.d.ts +49 -0
  53. package/types/lib/editor/smart-animate.d.ts +37 -0
  54. package/types/lib/engine/geometry/flatten.d.ts +2 -0
  55. package/types/lib/engine/geometry/shape-outline.d.ts +24 -0
  56. package/types/lib/engine/pixel/cells.d.ts +12 -0
  57. package/types/lib/engine/pixel/palettes.d.ts +25 -0
  58. package/types/lib/engine/readiness.d.ts +20 -0
  59. package/types/lib/engine/routing.d.ts +41 -0
  60. package/types/lib/engine/shader-graph-presets.d.ts +22 -0
  61. package/types/lib/engine/shader-presets-legacy.d.ts +7 -0
  62. package/types/lib/engine/shader-presets.d.ts +43 -0
  63. package/types/lib/engine/text/atlas.d.ts +120 -0
  64. package/types/lib/engine/text/emoji/segment.d.ts +15 -0
  65. package/types/lib/engine/text/fallback-fonts.d.ts +47 -0
  66. package/types/lib/engine/text/fontkit-lazy.d.ts +8 -0
  67. package/types/lib/engine/text/fonts.d.ts +33 -0
  68. package/types/lib/engine/text/glyph-linear.d.ts +22 -0
  69. package/types/lib/engine/text/google-fonts.d.ts +17 -0
  70. package/types/lib/engine/text/hyphenate/en-us.d.ts +6 -0
  71. package/types/lib/engine/text/hyphenate/liang.d.ts +21 -0
  72. package/types/lib/engine/text/layout-access.d.ts +16 -0
  73. package/types/lib/engine/text/layout.d.ts +168 -0
  74. package/types/lib/engine/text/lists.d.ts +16 -0
  75. package/types/lib/engine/text/measure.d.ts +58 -0
  76. package/types/lib/engine/text/outline-sdf.d.ts +34 -0
  77. package/types/lib/engine/text/shaper.d.ts +88 -0
  78. package/types/lib/engine/text/text-area.d.ts +16 -0
  79. package/types/lib/engine/text/text-fit.d.ts +51 -0
  80. package/types/lib/engine/text/text-path.d.ts +134 -0
  81. package/types/lib/engine/text/text-rings.d.ts +17 -0
  82. package/types/lib/engine/text/wrap-obstacles.d.ts +20 -0
  83. package/types/lib/i18n/catalogs.d.ts +10 -0
  84. package/types/lib/i18n/format.d.ts +27 -0
  85. package/types/lib/i18n/locales.d.ts +25 -0
  86. package/types/lib/i18n/pseudo.d.ts +10 -0
  87. package/types/lib/i18n/runtime.d.ts +27 -0
  88. package/types/lib/io/codecs/wav.d.ts +7 -0
  89. package/types/lib/io/codecs/webp.d.ts +7 -0
  90. package/types/lib/io/export-ir/children.d.ts +2 -0
  91. package/types/lib/io/json-export.d.ts +11 -0
  92. package/types/lib/media-library/types.d.ts +39 -0
  93. package/types/lib/motion/audio-analysis.d.ts +44 -0
  94. package/types/lib/motion/audio-clips.d.ts +92 -0
  95. package/types/lib/motion/audio-onsets.d.ts +13 -0
  96. package/types/lib/motion/audio-signals.d.ts +59 -0
  97. package/types/lib/motion/author.d.ts +80 -0
  98. package/types/lib/motion/composition.d.ts +99 -0
  99. package/types/lib/motion/instances.d.ts +95 -0
  100. package/types/lib/motion/key-selection.d.ts +100 -0
  101. package/types/lib/motion/keys.d.ts +41 -0
  102. package/types/lib/motion/layer-time-edit.d.ts +40 -0
  103. package/types/lib/motion/markers.d.ts +31 -0
  104. package/types/lib/motion/modifier-edit.d.ts +84 -0
  105. package/types/lib/motion/modifiers.d.ts +44 -0
  106. package/types/lib/motion/morph.d.ts +14 -0
  107. package/types/lib/motion/pose-layout.d.ts +6 -0
  108. package/types/lib/motion/pose.d.ts +115 -0
  109. package/types/lib/motion/presets.d.ts +148 -0
  110. package/types/lib/motion/properties.d.ts +74 -0
  111. package/types/lib/motion/sample-keys.d.ts +8 -0
  112. package/types/lib/motion/sample.d.ts +51 -0
  113. package/types/lib/motion/sound.d.ts +25 -0
  114. package/types/lib/motion/spatial-curve.d.ts +15 -0
  115. package/types/lib/motion/spatial.d.ts +38 -0
  116. package/types/lib/motion/text-animators.d.ts +79 -0
  117. package/types/lib/motion/text-units.d.ts +47 -0
  118. package/types/lib/motion/time.d.ts +58 -0
  119. package/types/lib/motion/transitions.d.ts +99 -0
  120. package/types/lib/motion/values.d.ts +12 -0
  121. package/types/lib/motion/video-clip.d.ts +63 -0
  122. package/types/lib/presets/page-presets.d.ts +50 -0
  123. package/types/lib/storage/media-hash.d.ts +4 -0
  124. package/types/lib/storage/media-refs.d.ts +2 -0
  125. package/types/lib/storage/media-store.d.ts +70 -0
  126. package/types/lib/templates/apply.d.ts +38 -0
  127. package/types/lib/templates/capture.d.ts +25 -0
  128. package/types/lib/templates/groups.d.ts +82 -0
  129. package/types/lib/templates/layout.d.ts +20 -0
  130. package/types/lib/templates/quality.d.ts +59 -0
  131. package/types/lib/templates/resize.d.ts +34 -0
  132. package/types/lib/templates/safe-areas.d.ts +42 -0
  133. package/types/lib/templates/text-measurer.d.ts +10 -0
  134. package/types/lib/templates/thumbnail.d.ts +134 -0
  135. package/types/lib/templates/types.d.ts +95 -0
  136. package/types/lib/templates/vocabulary.d.ts +50 -0
  137. package/types/lib/units/units.d.ts +23 -0
  138. package/types/packages/kit/src/index.d.ts +59 -0
  139. package/types/packages/runtime/src/expressions.d.ts +41 -0
  140. package/types/templates/src/app/shared.d.ts +29 -0
  141. package/types/templates/src/audio/beat-loop.d.ts +9 -0
  142. package/types/templates/src/audio/media.d.ts +42 -0
  143. package/types/templates/src/audio/music-synth.d.ts +57 -0
  144. package/types/templates/src/audio/music-worlds.d.ts +8 -0
  145. package/types/templates/src/audio/music.d.ts +19 -0
  146. package/types/templates/src/audio/studio/deck.d.ts +340 -0
  147. package/types/templates/src/audio/studio/dsp.d.ts +151 -0
  148. package/types/templates/src/audio/studio/fx.d.ts +96 -0
  149. package/types/templates/src/audio/studio/mix.d.ts +84 -0
  150. package/types/templates/src/audio/studio/voices.d.ts +120 -0
  151. package/types/templates/src/data/geometry.d.ts +16 -0
  152. package/types/templates/src/effects/shared.d.ts +17 -0
  153. package/types/templates/src/kit.d.ts +582 -0
  154. package/types/templates/src/motion3d/devices.d.ts +42 -0
  155. package/types/templates/src/motion3d/ui.d.ts +48 -0
  156. package/types/templates/src/saas/video-shared.d.ts +114 -0
  157. package/types/templates/src/saas/web-shared.d.ts +74 -0
  158. package/types/templates/src/shared/beat.d.ts +24 -0
  159. package/types/templates/src/shared/captions.d.ts +24 -0
  160. package/types/templates/src/shared/devices.d.ts +188 -0
  161. package/types/templates/src/shared/draw.d.ts +43 -0
  162. package/types/templates/src/shared/fit.d.ts +73 -0
  163. package/types/templates/src/shared/marks.d.ts +51 -0
  164. package/types/templates/src/shared/motion.d.ts +15 -0
  165. package/types/templates/src/shared/overlays.d.ts +80 -0
  166. package/types/templates/src/shared/pointer.d.ts +46 -0
  167. package/types/templates/src/shared/texture.d.ts +41 -0
  168. package/types/templates/src/shared/type.d.ts +6 -0
  169. package/types/templates/src/shared/window.d.ts +50 -0
  170. package/types/templates/src/social/shared.d.ts +66 -0
  171. package/types/templates/src/web/shared.d.ts +64 -0
@@ -0,0 +1,85 @@
1
+ import type { AnyNode, Document, DocumentKind, DocumentSettings, FrameNode, Guide } from './types.js';
2
+ import { type PagePreset } from '../presets/page-presets.js';
3
+ /** Kinds whose pages are ordered, same-size sheets rather than a free canvas. */
4
+ export declare const isFixedPageKind: (kind: DocumentKind | undefined) => boolean;
5
+ export declare const isPrintPage: (n: AnyNode | undefined) => n is FrameNode;
6
+ export declare const isMasterPage: (n: AnyNode | undefined) => n is FrameNode;
7
+ /** The print pages of a canvas page, in reading order: explicit `print.index`, then top-to-bottom, left-to-right. */
8
+ export declare function listPrintPages(doc: Document, pageId: string): FrameNode[];
9
+ /** The masters of a canvas page, in creation order (A, B, …). */
10
+ export declare function listMasterPages(doc: Document, pageId: string): FrameNode[];
11
+ /** The print page (or master) a node sits on, or null for nodes on the free canvas. Virtual ids resolve to their host. */
12
+ export declare function printPageOf(nodes: Record<string, AnyNode>, nodeId: string): FrameNode | null;
13
+ /**
14
+ * The page someone means by "this page".
15
+ *
16
+ * In order: the page holding the selection (a panel counts — it is the page it sits on), then the page
17
+ * under the middle of the viewport, then the nearest one to it. Asking for the SELECTED page alone is not
18
+ * enough: nobody selects a sheet frame before printing it, so "this page" used to print page 1.
19
+ */
20
+ export declare function currentPrintPage(doc: Document, pageId: string, o?: {
21
+ selection?: readonly string[];
22
+ centre?: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ }): FrameNode | null;
27
+ /**
28
+ * The size ONE page of this document is, which is not always the size of its sheets.
29
+ *
30
+ * A file made from the spread preset has 13.25×10.25in sheets, each carrying two 6.625in pages; a printer
31
+ * wants those as single pages. The preset says so (`sheetOf`), so the export knows what to cut to.
32
+ */
33
+ export declare function jobPageSize(doc: Document): {
34
+ width: number;
35
+ height: number;
36
+ } | undefined;
37
+ /** Document settings a preset implies (kind, units, page size, bleed, margins, dpi). */
38
+ export declare function settingsFromPreset(preset: PagePreset): DocumentSettings;
39
+ /**
40
+ * Canvas position of the page at `index`. Single pages run in one row; facing pages stack spreads — page 1
41
+ * alone on the right, then left/right pairs below — the way a bound document reads.
42
+ */
43
+ export declare function pagePosition(index: number, size: {
44
+ width: number;
45
+ height: number;
46
+ }, facing: boolean | undefined): {
47
+ x: number;
48
+ y: number;
49
+ };
50
+ /** Node patches that put every page (and master) of `pageId` at its canonical position for the document's facing mode. */
51
+ export declare function placePrintPages(doc: Document, pageId: string): Record<string, Partial<FrameNode>>;
52
+ /** Fold guides for a preset, in the frame's local space, tagged so chrome can draw them as folds. */
53
+ export declare function foldGuides(preset: PagePreset, width: number, height: number): Guide[];
54
+ /** A preset's fold lines positioned on a frame that is already placed — what a new brochure page needs. */
55
+ export declare function foldGuidesAt(preset: PagePreset | undefined, frame: FrameNode): Guide[];
56
+ /** Fold lines that fall inside a frame — the ones that belong to it, when a page is resized or removed. */
57
+ export declare const foldsOn: (guides: Guide[] | undefined, frame: FrameNode) => Guide[];
58
+ /**
59
+ * A new print page after the last one on `pageId`, sized from the document (or an explicit preset).
60
+ * Returns the frame; the caller adds it to the document.
61
+ */
62
+ export declare function createPrintPage(doc: Document, pageId: string, opts?: {
63
+ preset?: PagePreset;
64
+ name?: string;
65
+ }): FrameNode;
66
+ /** A new master after the existing ones ("A-Master", "B-Master", …), sized like the document's pages. */
67
+ export declare function createMasterPage(doc: Document, pageId: string, opts?: {
68
+ name?: string;
69
+ }): FrameNode;
70
+ /** Patches that point `pageIds` at `masterId` (undefined detaches); masters and unknown ids are skipped. */
71
+ export declare function assignMaster(doc: Document, pageIds: string[], masterId: string | undefined): Record<string, Partial<FrameNode>>;
72
+ /**
73
+ * Which master a print page should draw: first / left / right variants when set, else the default `masterId`.
74
+ * Left/right follow 1-based page numbers (odd = right in LTR facing layouts).
75
+ */
76
+ export declare function effectiveMasterId(doc: Document, frame: FrameNode): string | undefined;
77
+ /** Place header / footer text with `{{page}}` on a master (top or bottom). Returns the new TEXT id. */
78
+ export declare function addHeaderFooterToMaster(doc: Document, masterId: string, kind: 'header' | 'footer'): {
79
+ doc: Document;
80
+ textId: string;
81
+ } | null;
82
+ /** Node patches that renumber pages to `orderedIds` (ids not listed keep their relative order after). */
83
+ export declare function reorderPrintPages(doc: Document, pageId: string, orderedIds: string[]): Record<string, Partial<FrameNode>>;
84
+ /** A new document started from a preset: settings applied and, for fixed-page kinds, the first page created. */
85
+ export declare function documentFromPreset(name: string, preset: PagePreset): Document;
@@ -0,0 +1,194 @@
1
+ import { type Affine, type Bounds } from './transform.js';
2
+ import { Document, PageNode, FrameNode, SectionNode, SliceNode, RectangleNode, EllipseNode, PolygonNode, StarNode, LineNode, ArrowNode, TextNode, GroupNode, VectorNode, BooleanNode, ImageNode, RasterNode, ComponentNode, ComponentSetNode, InstanceNode, StickyNode, PixelGridNode, AnyNode, BooleanOperation, DocumentSettings } from './types.js';
3
+ /**
4
+ * The subtree a host shows that is not its own: an INSTANCE's main component, or a print page's master
5
+ * (`print.masterId`). Children of that root become virtual nodes `${hostId}::${childId}` under the host.
6
+ */
7
+ export declare function virtualRootOf(host: AnyNode | undefined, doc?: Document): string | undefined;
8
+ /**
9
+ * The virtual id of `childId` drawn under `parent`. Expanding an instance (or a master's page) nests the
10
+ * child under the parent's full id; a child of a virtual frame shares that frame's owner prefix. Nested
11
+ * instances therefore address their children as `host::nested::child`.
12
+ */
13
+ export declare function virtualChildId(parent: AnyNode, childId: string): string;
14
+ /** Overrides in force along a virtual chain: the host's win over a nested instance's own. */
15
+ export declare function chainOverrides(nodes: Record<string, AnyNode>, parts: string[]): Record<string, Partial<AnyNode>>;
16
+ /**
17
+ * The node drawn at a virtual id: the component's child with the host's overrides, the values of any
18
+ * properties it is bound to, and — unless `layout: false` — the box the instance's own reflow puts it in
19
+ * (`instance-layout.ts` asks for the node without that, to avoid re-entering the layout it is computing).
20
+ */
21
+ export declare function resolveVirtualNode(nodes: Record<string, AnyNode>, id: string, opts?: {
22
+ layout?: boolean;
23
+ }): AnyNode | null;
24
+ export declare function createDocument(name?: string, settings?: DocumentSettings): Document;
25
+ export declare function createPage(name?: string): PageNode;
26
+ export declare function createRectangle(props?: Partial<RectangleNode>): RectangleNode;
27
+ export declare function createEllipse(props?: Partial<EllipseNode>): EllipseNode;
28
+ export declare function createSticky(props?: Partial<StickyNode>): StickyNode;
29
+ export declare function createLine(props?: Partial<LineNode>): LineNode;
30
+ export declare function createArrow(props?: Partial<ArrowNode>): ArrowNode;
31
+ export declare function createPolygon(props?: Partial<PolygonNode>): PolygonNode;
32
+ export declare function createStar(props?: Partial<StarNode>): StarNode;
33
+ export declare function createSection(props?: Partial<SectionNode>): SectionNode;
34
+ export declare function createSlice(props?: Partial<SliceNode>): SliceNode;
35
+ export declare function createFrame(props?: Partial<FrameNode>): FrameNode;
36
+ export declare function createText(props?: Partial<TextNode>): TextNode;
37
+ export declare function createGroup(childIds?: string[]): GroupNode;
38
+ export declare function createVector(props?: Partial<VectorNode>): VectorNode;
39
+ export declare function createBoolean(operation: BooleanOperation, childIds?: string[], props?: Partial<BooleanNode>): BooleanNode;
40
+ /** A blank pixel canvas: `pixelWidth × pixelHeight` cells shown at `cellSize` world px per cell. */
41
+ export declare function createPixelGrid(props?: Partial<PixelGridNode> & {
42
+ cellSize?: number;
43
+ }): PixelGridNode;
44
+ export declare function createImage(imageUrl: string, props?: Partial<ImageNode>): ImageNode;
45
+ export declare function createRaster(props?: Partial<RasterNode>): RasterNode;
46
+ export declare function createComponent(props?: Partial<ComponentNode>): ComponentNode;
47
+ export declare function createComponentSet(props?: Partial<ComponentSetNode>): ComponentSetNode;
48
+ export declare function createInstance(mainComponentId: string, props?: Partial<InstanceNode>): InstanceNode;
49
+ /**
50
+ * A new instance of `main` that draws its box the way the component does: its size, fills, strokes, effects and
51
+ * corners (an instance draws its own box, so without these it showed the default grey fill behind a component that
52
+ * has none — every motion component's root is see-through). Every place that inserts an instance makes it here.
53
+ */
54
+ export declare function createInstanceOf(main: AnyNode, props?: Partial<InstanceNode>): InstanceNode;
55
+ export declare function addNode(document: Document, node: AnyNode, parentId: string): Document;
56
+ export declare function removeNode(document: Document, nodeId: string): Document;
57
+ export declare function updateNode<T extends AnyNode>(document: Document, nodeId: string, updates: Partial<T>): Document;
58
+ export declare function getDescendants(document: Document, nodeId: string): AnyNode[];
59
+ export declare function getAncestors(document: Document, nodeId: string): AnyNode[];
60
+ export declare function applyConstraints(document: Document, parentId: string, oldW: number, oldH: number, newW: number, newH: number): Document;
61
+ export declare function getRenderableNodes(document: Document, pageId: string): AnyNode[];
62
+ export declare function moveNodeInZOrder(document: Document, nodeId: string, direction: 'up' | 'down' | 'top' | 'bottom'): Document;
63
+ /** Scroll offsets of scrollable frames, by frame id: children are drawn shifted by −offset. */
64
+ export type ScrollState = Record<string, {
65
+ x: number;
66
+ y: number;
67
+ }>;
68
+ /**
69
+ * A node's world placement, decomposed for callers that think in centre + rotation. `matrix` is the whole
70
+ * story (box → world, lib/document/transform.ts); the rest is read off it:
71
+ * - `cx, cy`: the world image of the box centre;
72
+ * - `flipX, flipY`: the mirror each axis accumulates down the chain (a flip flag or a negative scale on the node
73
+ * or any ancestor). Their XOR is `det(matrix) < 0`;
74
+ * - `scaleX, scaleY`: the axis scales of `matrix` with those flips taken out (1 for documents that never set
75
+ * `scaleX`/`scaleY`);
76
+ * - `rotationRad`: the accumulated rotation, each mirror reversing the sense of the rotations below it — so a
77
+ * layer at 350° reads 350°, not −10°, and rest documents get exactly the angles they always did. When a
78
+ * non-uniform scale somewhere up the chain skews the box, it is the angle of the box's x axis instead.
79
+ * For any unskewed chain, `matrix = T(cx, cy) · R(rotationRad) · S(±scaleX, ±scaleY) · T(−w/2, −h/2)`.
80
+ */
81
+ export interface WorldTransform {
82
+ readonly cx: number;
83
+ readonly cy: number;
84
+ readonly rotationRad: number;
85
+ readonly flipX: boolean;
86
+ readonly flipY: boolean;
87
+ readonly scaleX: number;
88
+ readonly scaleY: number;
89
+ readonly matrix: Affine;
90
+ }
91
+ /**
92
+ * The node's box at its world size about its world centre, rotation ignored: how snapping, measuring and
93
+ * componentising have always treated a layer (upright). Scale is honoured, so a scaled layer measures its size.
94
+ */
95
+ export declare function uprightBounds(t: WorldTransform, width: number, height: number): Bounds;
96
+ /**
97
+ * The placement with every mirror down the chain taken out about the box centre. For the callers that have always
98
+ * read node space unmirrored: hit-testing (a box is symmetric), text (the GPU never mirrors glyphs) and geometry
99
+ * extraction for vector operations.
100
+ */
101
+ export declare function unmirroredMatrix(t: WorldTransform, width: number, height: number): Affine;
102
+ /**
103
+ * A straight (unrouted) LINE/ARROW's two ends in world space: its box's x axis through the centre, at its world
104
+ * length. Mirroring does not swap them, as it never has on the canvas.
105
+ */
106
+ export declare function lineShaftEnds(t: WorldTransform, width: number): [{
107
+ x: number;
108
+ y: number;
109
+ }, {
110
+ x: number;
111
+ y: number;
112
+ }];
113
+ /** Anything with a node map: a Document, or a `{ nodes }` view of one (a render pass's resolved map). */
114
+ export type NodesLike = {
115
+ nodes: Record<string, AnyNode>;
116
+ };
117
+ /** The world placement of a box that belongs to no tree (canvas chrome, previews): its own fields, in world space. */
118
+ export declare function detachedTransform(node: AnyNode): WorldTransform;
119
+ /**
120
+ * World matrices for many nodes of one document state (a render pass, a hit-test sweep). Each container's frame is
121
+ * `world(parent) · localMatrix(container) · T(−scroll)`, computed once and shared by every descendant; virtual
122
+ * `host::child` ids resolve through their instance. Unknown ids get the identity. `roots` places render roots (a
123
+ * transition's or a composition's frames, lib/motion/transitions.ts) by a matrix of their own instead of their parent:
124
+ * everything under a root follows it.
125
+ */
126
+ export declare function createWorldMatrixResolver(nodes: Record<string, AnyNode>, scrollState?: ScrollState): (nodeId: string) => Affine;
127
+ /** The same resolver, decomposed (`WorldTransform`), for callers that place by centre and rotation. */
128
+ export declare function createWorldTransformResolver(nodes: Record<string, AnyNode>, scrollState?: ScrollState, roots?: ReadonlyMap<string, Affine>): (nodeId: string) => WorldTransform;
129
+ /** A node's world placement (see `WorldTransform`), memoised per node map. Unknown ids get the zero transform. */
130
+ export declare function getWorldTransform(document: NodesLike, nodeId: string, scrollState?: ScrollState): WorldTransform;
131
+ /** A node's box → world matrix, memoised per node map. Unknown ids get the identity. */
132
+ export declare function getWorldMatrix(document: NodesLike, nodeId: string, scrollState?: ScrollState): Affine;
133
+ /**
134
+ * The rest fields that keep `nodeId` exactly where it is on screen once it lives under `newParentId`: position,
135
+ * rotation, scale and — when the move crosses a mirror — the horizontal flip. Its anchor and translate stay as they
136
+ * are. Null when the new parent is collapsed to zero scale (nothing can be placed inside it). A skew the parents
137
+ * would impose cannot be expressed on one node and is dropped.
138
+ */
139
+ export declare function placementUnder(document: NodesLike, nodeId: string, newParentId: string): Partial<AnyNode> | null;
140
+ /**
141
+ * Every component the subtree under `rootId` draws, following instances into their main components. Used to
142
+ * refuse moves that would make a component contain an instance of itself, which the renderer would expand for ever.
143
+ */
144
+ export declare function componentsDrawnBy(document: Document, rootId: string): Set<string>;
145
+ /** Would putting `nodeId` under `newParentId` make a component (transitively) contain an instance of itself, or put a node inside itself? */
146
+ export declare function wouldCreateCycle(document: Document, nodeId: string, newParentId: string): boolean;
147
+ /**
148
+ * `ids` wrapped in a new component where they are (Figma's Create component on a selection): the component sits in
149
+ * the first top-level layer's parent (else `fallbackParentId`), sized to their world bounds, and each layer keeps
150
+ * its place on screen. Null when none of the ids exists.
151
+ */
152
+ export declare function wrapInComponent(document: Document, ids: readonly string[], fallbackParentId: string, name?: string): {
153
+ document: Document;
154
+ componentId: string;
155
+ } | null;
156
+ export declare function reparentNode(document: Document, nodeId: string, newParentId: string, index?: number): Document;
157
+ export declare function duplicateNode(document: Document, nodeId: string, offset?: {
158
+ x: number;
159
+ y: number;
160
+ }): {
161
+ document: Document;
162
+ newNodeId: string;
163
+ };
164
+ export declare function getNodeBounds(document: Document, nodeId: string): {
165
+ x: number;
166
+ y: number;
167
+ width: number;
168
+ height: number;
169
+ } | null;
170
+ export declare function getWorldRenderBounds(document: Document, nodeId: string): {
171
+ minX: number;
172
+ minY: number;
173
+ maxX: number;
174
+ maxY: number;
175
+ } | null;
176
+ import { Rect } from "../engine/routing.js";
177
+ /**
178
+ * World-space rectangles a connector should avoid: every visible shape/frame
179
+ * except the connector itself, the two nodes it attaches to, and those nodes'
180
+ * ancestors/descendants (you never route around your own endpoints or their
181
+ * containers). Pruned to the region around the endpoints and capped so a live
182
+ * drag stays responsive.
183
+ */
184
+ export declare function gatherLineObstacles(document: Document, line: AnyNode, startAbs: {
185
+ x: number;
186
+ y: number;
187
+ }, endAbs: {
188
+ x: number;
189
+ y: number;
190
+ }): Rect[];
191
+ export declare function connectorIdsOf(nodes: Document['nodes']): string[];
192
+ /** `to` has exactly the nodes of `from`, with the same types: its connectors are the same. */
193
+ export declare function carryConnectorIds(from: Document['nodes'], to: Document['nodes']): void;
194
+ export declare function updateConnectors(document: Document, movedNodeIds: string[]): Document;
@@ -0,0 +1,76 @@
1
+ import type { AnyNode, Light3D, Light3DType, Scene3D } from './types.js';
2
+ import { type Mat4, type SceneFrame } from './transform3d.js';
3
+ /** The context a node defines, if it is one. */
4
+ export declare function scene3dOf(n: AnyNode | undefined): Scene3D | undefined;
5
+ export declare const is3DContext: (n: AnyNode | undefined) => boolean;
6
+ /**
7
+ * Whether the render passes draw `node` as a 3D context (its cards at its slot, its subtree not walked in 2D). A
8
+ * context reached through an instance (a virtual `host::child` id) is drawn flat: its cards are not document nodes.
9
+ */
10
+ export declare const drawsIn3D: (node: AnyNode, nodes: Record<string, AnyNode>) => boolean;
11
+ /** A new context's scene: the default lens, no lights (so its layers draw unlit, exactly as flat). */
12
+ export declare const defaultScene3D: () => Scene3D;
13
+ /** A fresh light for a `w × h` scene: in front of its centre, aimed at it, with the next free id (`l1`, `l2` …). */
14
+ export declare function newLight(type: Light3DType, scene: Scene3D, w: number, h: number): Light3D;
15
+ export declare function setVirtualResolver(fn: (nodes: Record<string, AnyNode>, id: string) => AnyNode | null): void;
16
+ /**
17
+ * A layer that lets its children be 3D layers of the context above it, instead of one flattened card: a plain
18
+ * group, or an instance of a `preserve3d` component that draws nothing of its own (`nodes` is needed to see its
19
+ * component; without it an instance never passes through).
20
+ */
21
+ export declare function passesThrough(n: AnyNode, nodes?: Record<string, AnyNode>): boolean;
22
+ /**
23
+ * The layers a pass-through layer holds, resolved: a real group's children; a pass-through instance's are its shown
24
+ * component's children as virtual `host::child` nodes (posed when the pose resolved them); a virtual group's are
25
+ * addressed with its host prefix.
26
+ */
27
+ export declare function passThroughChildren(nodes: Record<string, AnyNode>, n: AnyNode): AnyNode[];
28
+ export interface Layer3D {
29
+ id: string;
30
+ node: AnyNode;
31
+ /** The card's box (top-left origin, unscaled) → the context's 3D space. */
32
+ model: Mat4;
33
+ /** Its own opacity times that of the pass-through groups above it (the context's is the 2D pass's). */
34
+ opacity: number;
35
+ /** Position in tree order (paint order before sorting, and the tiebreak after). */
36
+ order: number;
37
+ }
38
+ /**
39
+ * The flattened cards of the context `contextId` in tree order, each with its model matrix composed down the chain
40
+ * of pass-through groups. Hidden layers (and everything under a hidden group) are left out.
41
+ */
42
+ export declare function sceneLayers(nodes: Record<string, AnyNode>, contextId: string): Layer3D[];
43
+ /** Camera-space depth of a card's centre (negative is in front of the eye; more negative is farther). */
44
+ export declare const centreDepth: (view: Mat4, l: Layer3D) => number;
45
+ /** `layers` back to front: farthest centre first, tree order on ties (stable). */
46
+ export declare function depthSort<L extends Layer3D>(layers: readonly L[], view: Mat4): L[];
47
+ /** The context's camera for its box. */
48
+ export declare const contextFrame: (ctx: AnyNode) => SceneFrame | null;
49
+ export interface Placement3D {
50
+ /** The context the node is placed in. */
51
+ contextId: string;
52
+ /** The flattened card the node is (or is inside). Undefined for a pass-through group: it is not drawn itself. */
53
+ layerId?: string;
54
+ }
55
+ /**
56
+ * Where `id` sits in 3D: the nearest context above it reached through pass-through groups, and the card that
57
+ * carries it. Undefined when the node is not inside a context (or is a context itself, which is placed in 2D).
58
+ */
59
+ export declare function placement3D(nodes: Record<string, AnyNode>, id: string): Placement3D | undefined;
60
+ /**
61
+ * The node's 3D fields repaired to what the renderer relies on, the same node when nothing needs it: a context's
62
+ * camera has a positive finite focal length and finite numbers; each light a known type, a unique safe id (tracks
63
+ * address it by id), a colour, a finite intensity and position, a cone in (0°, 180°) and a feather in [0, 1]; a
64
+ * material finite, non-negative numbers. A `scene3d` on a node that cannot be a context, or that is not an
65
+ * object, is removed.
66
+ */
67
+ export declare function repairScene3D(node: AnyNode): AnyNode;
68
+ /**
69
+ * A node's box → its context's 3D space, for a card or a pass-through group: the product of the model matrices from
70
+ * the context's child down to it. Undefined when the node is not placed in 3D itself (it is inside a card, or not
71
+ * in a context).
72
+ */
73
+ export declare function boxModel(nodes: Record<string, AnyNode>, id: string): {
74
+ contextId: string;
75
+ model: Mat4;
76
+ } | undefined;
@@ -0,0 +1,8 @@
1
+ import type { ShaderNodeDef } from './shader-graph.js';
2
+ /** The particle kinds: how one particle is drawn, and the cell it needs (a multiple of its size). */
3
+ export declare const PARTICLE_KINDS: readonly ["petals", "rain", "snow", "sparkles", "confetti", "embers", "dust"];
4
+ export type ParticleKind = (typeof PARTICLE_KINDS)[number];
5
+ /** The helpers the effect nodes call, merged into the graph's own (lib/document/shader-graph.ts `LIB`). */
6
+ export declare const EFFECT_LIB: Record<string, string>;
7
+ export declare const EFFECT_LIB_DEPS: Record<string, string[]>;
8
+ export declare const EFFECT_NODES: readonly ShaderNodeDef[];
@@ -0,0 +1,134 @@
1
+ import type { AudioSignalName, ShaderGraph, ShaderParamValue } from './types.js';
2
+ export type PortType = 'f32' | 'vec2f' | 'vec3f' | 'vec4f';
3
+ export interface PortDef {
4
+ name: string;
5
+ type: PortType;
6
+ /** Its knob's starting value (and the `@default` of its field). */
7
+ default?: ShaderParamValue;
8
+ range?: [number, number];
9
+ /** Unconnected, it reads the pixel's coordinate instead of a knob (a pattern's `uv`). */
10
+ coord?: boolean;
11
+ }
12
+ export interface OptionDef {
13
+ name: string;
14
+ values: readonly string[];
15
+ default: string;
16
+ }
17
+ export type ShaderNodeCategory = 'input' | 'math' | 'color' | 'pattern' | 'effect' | 'warp' | 'output';
18
+ /** What a node's WGSL is written with. */
19
+ export interface EmitContext {
20
+ /** Input `port`'s value at coordinate expression `uv` (default: the node's own `uv`), in the port's type. */
21
+ in(port: string, uv?: string): string;
22
+ /** A compile-time option's value. */
23
+ opt(name: string): string;
24
+ /** The node's id. */
25
+ id: string;
26
+ }
27
+ export interface ShaderNodeDef {
28
+ kind: string;
29
+ label: string;
30
+ category: ShaderNodeCategory;
31
+ inputs: readonly PortDef[];
32
+ options?: readonly OptionDef[];
33
+ /** What its function returns. */
34
+ output: PortType;
35
+ /** Reads time (the fill re-renders as the playhead moves). */
36
+ time?: boolean;
37
+ /** Helper functions it calls (`LIB`), or which, by its options (a particle emitter's kind). */
38
+ lib?: readonly string[] | ((options: Record<string, string>) => readonly string[]);
39
+ /** The function's body: statements ending in a `return`. */
40
+ emit(c: EmitContext): string;
41
+ /** An audio input's annotation for its `value` knob. */
42
+ audio?: (options: Record<string, string>) => {
43
+ signal: AudioSignalName;
44
+ bin?: number;
45
+ };
46
+ }
47
+ /** A number as a WGSL f32 literal (always with a decimal point). */
48
+ export declare const lit: (n: number) => string;
49
+ /** `expr` of type `from` as type `to`. */
50
+ export declare function coerce(expr: string, from: PortType, to: PortType): string;
51
+ export declare const AUDIO_NODE_SIGNALS: readonly AudioSignalName[];
52
+ /** Every node kind, by kind. */
53
+ export declare const SHADER_NODES: ReadonlyMap<string, ShaderNodeDef>;
54
+ export declare const shaderNodeKinds: () => string[];
55
+ export interface CompiledShaderGraph {
56
+ /** WGSL for a SHADER fill (a transparent shader when there are errors). */
57
+ code: string;
58
+ /** The knobs' starting values (the nodes' `inputs`), by field name. */
59
+ params: Record<string, ShaderParamValue>;
60
+ /** Why the graph could not compile (an empty list when it did). */
61
+ errors: string[];
62
+ /** The same problems, each with the node, port or edge it is about (for the node editor to mark). */
63
+ issues: ShaderGraphIssue[];
64
+ /** The knobs: field name → node, port. */
65
+ knobs: {
66
+ field: string;
67
+ node: string;
68
+ port: string;
69
+ type: PortType;
70
+ }[];
71
+ }
72
+ export interface ShaderGraphIssue {
73
+ message: string;
74
+ node?: string;
75
+ port?: string;
76
+ edge?: string;
77
+ }
78
+ export interface CompileOptions {
79
+ /**
80
+ * Compile up to this node instead of the output: its value drawn as a colour (a number as grey, a coordinate as
81
+ * red-green), for the node editor's previews. The knobs' field names are the same, so the fill's values apply.
82
+ */
83
+ preview?: string;
84
+ }
85
+ /** The Params field a knob is: `<node>_<port>`. */
86
+ export declare const knobField: (node: string, port: string) => string;
87
+ /**
88
+ * `graph` compiled: its code and its knobs' starting values. Pure and deterministic: the same graph gives the same
89
+ * code (nodes are emitted in id order). A graph that cannot compile gives a transparent shader and says why:
90
+ * an unknown kind, a bad id, an edge to a port that is not there, a cycle, no output.
91
+ */
92
+ export declare function compileShaderGraph(graph: ShaderGraph, opts?: CompileOptions): CompiledShaderGraph;
93
+ /**
94
+ * A stored graph made well-formed: each map keyed by its entries' ids, nodes of a known kind at a finite place, and
95
+ * only edges between nodes that are there into an input their kind has. Its shape only: a graph that does not compile
96
+ * (a cycle, no output) is kept as it is, so it can be fixed in the editor. The same object when nothing was wrong;
97
+ * undefined when it is not a graph at all.
98
+ */
99
+ export declare function repairShaderGraph(raw: unknown): ShaderGraph | undefined;
100
+ /** Where the node editor draws a node: columns by distance from the output (the output on the right), rows within. */
101
+ export declare const LAYOUT_COLUMN = 240, LAYOUT_ROW = 170;
102
+ /**
103
+ * Places for a graph whose nodes were never placed (written as code: every node at y 0), worked out as it is shown: the
104
+ * output on the right and each node a column left of the furthest node it feeds. Nodes that reach nothing stack in a
105
+ * column of their own on the far left. A graph someone has arranged keeps its places (null). Never stored until a node
106
+ * is moved.
107
+ */
108
+ export declare function layoutShaderGraph(graph: ShaderGraph): Record<string, {
109
+ x: number;
110
+ y: number;
111
+ }> | null;
112
+ /**
113
+ * A SHADER paint for `graph`: its compiled code, and its knobs at their starting values under any the paint already
114
+ * sets. A knob keeps its value across a recompile while its input is unwired, even while its node is cut off from the
115
+ * output (a copy not wired in yet, a wire pulled out and put back), so it is still set when the node is wired in.
116
+ */
117
+ export declare function graphPaint<P extends {
118
+ shaderParams?: Record<string, ShaderParamValue>;
119
+ }>(paint: P, graph: ShaderGraph, name?: string): P & {
120
+ type: 'SHADER';
121
+ shaderGraph: ShaderGraph;
122
+ shaderCode: string;
123
+ };
124
+ /** A graph written as code: `g.node('fb', 'feedback', { zoom: 0.9 })`, `g.wire('pl', 'fb.input')`. */
125
+ export declare class GraphBuilder {
126
+ private nodes;
127
+ private edges;
128
+ private x;
129
+ /** A node; `inputs` are knob values (or, for a string, an option). */
130
+ node(id: string, kind: string, inputs?: Record<string, ShaderParamValue | string>): string;
131
+ /** An edge from node `from`'s output into `to` (`node.port`). */
132
+ wire(from: string, to: string): this;
133
+ build(): ShaderGraph;
134
+ }
@@ -0,0 +1,65 @@
1
+ import type { AudioSignalName, ShaderParamValue } from './types.js';
2
+ export type ShaderParamType = 'f32' | 'vec2f' | 'vec3f' | 'vec4f';
3
+ export interface ShaderParam {
4
+ name: string;
5
+ type: ShaderParamType;
6
+ /** A colour (vec4f, or vec3f marked `@color`): shown as a swatch, stored as {r, g, b, a}. */
7
+ color: boolean;
8
+ /** What it draws with when `Paint.shaderParams` has no value: `// @default`, else 0 (numbers) or white (colours). */
9
+ default: ShaderParamValue;
10
+ /** `// @range min max`: the control's bounds (values are not clamped — an overshooting ease may pass them). */
11
+ min?: number;
12
+ max?: number;
13
+ /** Byte offset in the Params uniform. */
14
+ offset: number;
15
+ /** `// @audio <signal> [band]`: the field is an audio input, fed by that signal (0…1) when the shader is applied. */
16
+ audio?: {
17
+ signal: AudioSignalName;
18
+ bin?: number;
19
+ };
20
+ }
21
+ export interface ShaderReflection {
22
+ params: ShaderParam[];
23
+ /** Bytes of the Params uniform: 0 when the code declares no `struct Params`. */
24
+ size: number;
25
+ /** `shade` reads its time argument (or the harness's `u.time`): the fill re-renders as time passes. */
26
+ animated: boolean;
27
+ /** Fields the harness cannot bind (their types, duplicates, attributes). A shader with any is not drawn. */
28
+ errors: string[];
29
+ }
30
+ /** The keyable components of a param, in path order: none for f32 (the path is the name). */
31
+ export declare function paramComponents(p: Pick<ShaderParam, 'type' | 'color'>): readonly string[];
32
+ /** The fields of `struct Params` (none when the code declares no such struct). Pure; see `reflectShader` for the cached form. */
33
+ export declare function parseShaderParams(code: string): {
34
+ params: ShaderParam[];
35
+ size: number;
36
+ errors: string[];
37
+ };
38
+ /** Whether `shade` reads its time argument (its third parameter, whatever it is called), or the harness's `u.time`. */
39
+ export declare function shaderReadsTime(code: string): boolean;
40
+ /** The longest shader fill code anything accepts: the fill command, a pack, the CLI. */
41
+ export declare const MAX_SHADER_CHARS = 20000;
42
+ /**
43
+ * A shader must be a `shade()` body and nothing that could reach outside the harness: the harness owns the entry
44
+ * points and bindings (lib/engine/shader-fill.ts), so code that declares its own is refused rather than left to
45
+ * fail to compile on someone else's machine. Null when it passes.
46
+ */
47
+ export declare function checkShaderCode(code: string): string | null;
48
+ /** The shader's params and whether it animates, cached by code (a drag never re-parses). */
49
+ export declare function reflectShader(code: string): ShaderReflection;
50
+ /** A param's value from `values`, when it is one of its type; else its default. */
51
+ export declare function paramValue(p: ShaderParam, values: Record<string, ShaderParamValue> | undefined): ShaderParamValue;
52
+ /** One component (or the whole f32) of a param's value. */
53
+ export declare function paramComponent(p: ShaderParam, values: Record<string, ShaderParamValue> | undefined, component?: string): number | undefined;
54
+ /** `values` with one component (or an f32) set: the param's other components keep what it draws with. */
55
+ export declare function withParamComponent(p: ShaderParam, values: Record<string, ShaderParamValue> | undefined, component: string | undefined, n: number): Record<string, ShaderParamValue>;
56
+ export interface PackedParams {
57
+ /** The Params uniform's bytes, laid out as WGSL lays the struct out. */
58
+ data: Float32Array;
59
+ /** Exact identity of the values (not the code): part of the shader-fill cache key. */
60
+ hash: string;
61
+ }
62
+ /** The Params uniform for `values` under `code`'s struct, cached by the values object's identity (idle frames reuse it). */
63
+ export declare function packShaderParams(code: string, values: Record<string, ShaderParamValue> | undefined): PackedParams;
64
+ /** "center" → "Center", "glowColor" → "Glow color", "ring_width" → "Ring width". */
65
+ export declare function paramLabel(name: string): string;
@@ -0,0 +1,20 @@
1
+ import { AnyNode, VectorPath } from './types.js';
2
+ /** A regular polygon's corners on the unit circle, from 12 o'clock clockwise (screen, y down). */
3
+ export declare function polygonCorners(count: number): [number, number][];
4
+ /** A star's outer and inner corners (inner at `inner` × the radius), from 12 o'clock clockwise. */
5
+ export declare function starCorners(count: number, inner: number): [number, number][];
6
+ /**
7
+ * Corners stretched so their bounds fill the w×h box — how the GPU draws a polygon or star (a triangle's base sits
8
+ * on the box's bottom edge, not three quarters of the way down), and so how its outline must be traced.
9
+ */
10
+ export declare function fitCornersToBox(pts: [number, number][], w: number, h: number): [number, number][];
11
+ /**
12
+ * Convert a primitive shape (rectangle, ellipse, polygon, star, line/arrow) into an
13
+ * editable vector path in the node's LOCAL space (top-left origin, 0..width × 0..height).
14
+ * Returns both `points` (anchors, with bezier handles for ellipses) and `data` (the flat
15
+ * SVG command array the renderer flattens for the fill) so the two stay consistent.
16
+ * Returns null for node types that shouldn't be path-edited.
17
+ */
18
+ export declare function shapeToVectorPath(node: AnyNode): VectorPath | null;
19
+ /** Node types that can be converted to an editable vector path. */
20
+ export declare function canEditAsVector(type: string): boolean;
@@ -0,0 +1,28 @@
1
+ import type { AnyNode, ParagraphFormat, TextNode, TextStyle } from './types.js';
2
+ type StyleMap = Record<string, {
3
+ type?: string;
4
+ } & Record<string, unknown>> | undefined;
5
+ /**
6
+ * A text style: Inter 400 at 16 px with nothing else set, under `props`. What the style commands and the template
7
+ * kit make a style from, so both write the same defaults.
8
+ */
9
+ export declare function createTextStyle(id: string, name: string, props?: Partial<Omit<TextStyle, 'id' | 'name' | 'type'>>): TextStyle;
10
+ /** The paragraph-level keys a text style can set. */
11
+ export declare const PARAGRAPH_STYLE_KEYS: readonly ["textAlign", "paragraphSpacing", "spaceBefore", "paragraphIndent", "list", "tabStops", "hyphenate"];
12
+ /**
13
+ * A text node with its styles applied: the whole-node style spread over it (as the renderer always did), and
14
+ * every paragraph format's `styleId` expanded into the paragraph properties of that style, under the format's
15
+ * own overrides. Returns the node itself when there is nothing to resolve.
16
+ */
17
+ export declare function resolveTextNodeStyles<T extends AnyNode>(node: T, styles: StyleMap): T;
18
+ /**
19
+ * `node.paragraphs` with `patch` merged into every paragraph that intersects [start, end) (the whole text when
20
+ * the range is empty). `undefined` values in the patch clear that key. Entries are keyed by paragraph start.
21
+ */
22
+ export declare function withParagraphFormat(node: TextNode, range: {
23
+ start: number;
24
+ end: number;
25
+ } | null, patch: Partial<Omit<ParagraphFormat, 'start'>>): ParagraphFormat[];
26
+ /** The format (resolved) that governs the paragraph containing character `index`. */
27
+ export declare function paragraphFormatAt(node: TextNode, index: number): ParagraphFormat | undefined;
28
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { AnyNode } from './types.js';
2
+ /**
3
+ * `node` with every `{{name}}` that `resolve` answers replaced (unanswered tokens stay); character-indexed
4
+ * formatting shifts to match. The same object comes back when nothing changed.
5
+ */
6
+ export declare function substituteTokens<T extends AnyNode>(node: T, pattern: RegExp, resolve: (name: string) => string | undefined): T;