rocx-docx 0.0.0-stage → 0.5.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.
@@ -0,0 +1,457 @@
1
+ import type { ReadLimits, ResolvedHandle } from "./boundary.js";
2
+ import type { TableLayout } from "./tables.js";
3
+ import type { ResolvedParagraphFormat, ResolvedRunFormat } from "./text-layout.js";
4
+
5
+ declare const anchor: unique symbol;
6
+ export type MetadataField = "title" | "subject" | "creator" | "description" | "comments" | "category" | "keywords" | "version"
7
+ | "created" | "modified" | "lastPrinted" | "lastModifiedBy" | "revision"
8
+ | "identifier" | "language" | "contentStatus" | "company" | "manager";
9
+
10
+ export interface ControlAnchor { readonly [anchor]: "control" }
11
+ export interface ControlSiteAnchor { readonly [anchor]: "controlSite" }
12
+ export interface ControlSite {
13
+ readonly anchor: ControlSiteAnchor;
14
+ readonly context: ImportedControl["context"];
15
+ readonly text: string;
16
+ }
17
+ export interface ImportedControl {
18
+ readonly ownerPart?: string;
19
+ readonly entryId?: string;
20
+ readonly entryIndex?: number;
21
+ readonly anchor: ControlAnchor;
22
+ readonly context: "block" | "inline" | "row" | "cell";
23
+ readonly id?: string;
24
+ readonly tag?: string;
25
+ readonly alias?: string;
26
+ readonly lock?: string;
27
+ readonly bound: boolean;
28
+ readonly kind: string;
29
+ readonly choices: readonly { readonly displayText: string; readonly value: string }[];
30
+ readonly selected?: string;
31
+ readonly multiLine?: string;
32
+ }
33
+
34
+ /** Direct body paragraph target, valid only in the snapshot that issued it. */
35
+ export interface ParagraphAnchor { readonly [anchor]: "paragraph" }
36
+ export interface SectionAnchor { readonly [anchor]: "section" }
37
+ export interface LayoutTab {
38
+ readonly position: number;
39
+ readonly alignment: "left" | "center" | "right" | "decimal" | "bar" | "clear" | "start" | "end";
40
+ readonly leader?: "none" | "dot" | "hyphen" | "underscore" | "heavy" | "middleDot";
41
+ }
42
+ export interface DirectParagraphLayout {
43
+ readonly heading?: number;
44
+ readonly keepWithNext?: boolean;
45
+ readonly keepTogether?: boolean;
46
+ readonly pageBreakBefore?: boolean;
47
+ readonly widowControl?: boolean;
48
+ readonly suppressLineNumbers?: boolean;
49
+ readonly paragraphBidi?: boolean;
50
+ readonly snapToGrid?: boolean;
51
+ readonly contextualSpacing?: boolean;
52
+ readonly mirrorIndents?: boolean;
53
+ readonly styleId?: string;
54
+ readonly alignment?: "left" | "start" | "center" | "right" | "end" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute";
55
+ readonly outlineLevel?: number;
56
+ readonly spaceBefore?: number;
57
+ readonly spaceAfter?: number;
58
+ readonly lineHeight?: number;
59
+ readonly lineRule?: "auto" | "exact" | "atLeast";
60
+ readonly leftIndent?: number;
61
+ readonly rightIndent?: number;
62
+ readonly firstLineIndent?: number;
63
+ readonly tabStops?: readonly LayoutTab[];
64
+ }
65
+ export interface DirectSectionLayout {
66
+ readonly margins?: true;
67
+ readonly lineNumbering?: true;
68
+ readonly borderTop?: LayoutBorder;
69
+ readonly borderLeft?: LayoutBorder;
70
+ readonly borderBottom?: LayoutBorder;
71
+ readonly borderRight?: LayoutBorder;
72
+ readonly pageWidth?: number;
73
+ readonly pageHeight?: number;
74
+ readonly orientation?: "portrait" | "landscape";
75
+ readonly marginTop?: number;
76
+ readonly marginBottom?: number;
77
+ readonly marginLeft?: number;
78
+ readonly marginRight?: number;
79
+ readonly marginHeader?: number;
80
+ readonly marginFooter?: number;
81
+ readonly marginGutter?: number;
82
+ readonly columnCount?: number;
83
+ readonly columnSpace?: number;
84
+ readonly columnSeparator?: boolean;
85
+ readonly gridMode?: "default" | "lines" | "linesAndChars" | "snapToChars";
86
+ readonly gridPitch?: number;
87
+ readonly gridCharSpace?: number;
88
+ readonly pageStart?: number;
89
+ readonly pageFormat?: "decimal" | "upperRoman" | "lowerRoman" | "upperLetter" | "lowerLetter" | "ordinal" | "cardinalText" | "ordinalText" | "decimalZero" | "none";
90
+ readonly lineStart?: number;
91
+ readonly lineCountBy?: number;
92
+ readonly lineDistance?: number;
93
+ readonly lineRestart?: "newPage" | "newSection" | "continuous";
94
+ readonly verticalAlign?: "top" | "center" | "bottom" | "both";
95
+ readonly sectionType?: ImportedSectionType;
96
+ readonly titlePage?: boolean;
97
+ readonly bidi?: boolean;
98
+ readonly rtlGutter?: boolean;
99
+ readonly borderOffset?: "page" | "text";
100
+ readonly borderDisplay?: "allPages" | "firstPage" | "notFirstPage";
101
+ readonly borderZOrder?: "front" | "back";
102
+ }
103
+ export interface LayoutBorder { readonly size?: number; readonly space?: number; readonly color?: string }
104
+ export interface StoryParagraphAnchor { readonly [anchor]: "storyParagraph" }
105
+ /** Snapshot-scoped address; physical-owner and ordinary body anchors are not interchangeable. */
106
+ export interface TableAnchor { readonly [anchor]: "table" }
107
+ /** Snapshot-local run, hyperlink or revision address; eligible direct body runs support text replacement or removal. */
108
+ export interface InlineAnchor { readonly [anchor]: "inline" }
109
+ /** Section-scoped target for a header/footer image edit. */
110
+ export interface HeaderAnchor { readonly [anchor]: "header" }
111
+
112
+ export type ImportedAlignment =
113
+ | "left" | "center" | "right" | "justify" | "distribute"
114
+ | "justifyMedium" | "justifyHigh" | "justifyLow" | "thaiJustify";
115
+ export type ImportedBreakType = "line" | "page" | "column" | "textWrapping";
116
+ export type ImportedSectionType = "nextPage" | "nextColumn" | "continuous" | "evenPage" | "oddPage";
117
+
118
+ export interface DefaultTab {
119
+ readonly positionTwips: number;
120
+ readonly alignment: "left" | "right" | "center" | "decimal" | "bar" | "clear" | "start" | "end" | "num";
121
+ readonly leader?: "none" | "dot" | "hyphen" | "underscore" | "heavy" | "middleDot";
122
+ }
123
+ type DefaultToggle = "bold" | "italic" | "boldCs" | "italicCs" | "runRtl" | "complexScript"
124
+ | "caps" | "smallCaps" | "strike" | "runSnapToGrid" | "paragraphBidi" | "keepTogether"
125
+ | "keepWithNext" | "pageBreakBefore" | "widowControl" | "suppressLineNumbers" | "contextualSpacing"
126
+ | "mirrorIndents" | "paragraphSnapToGrid" | "mirrorMargins" | "gutterAtTop" | "trackRevisions"
127
+ | "beforeAutoSpacing" | "afterAutoSpacing";
128
+ type DefaultInteger = "sizeHalfPoints" | "sizeCsHalfPoints" | "beforeTwips" | "afterTwips" | "line"
129
+ | "leftTwips" | "rightTwips" | "firstLineTwips" | "hangingTwips" | "leftChars" | "rightChars"
130
+ | "firstLineChars" | "hangingChars" | "footnoteStart" | "endnoteStart" | "startTwips" | "endTwips"
131
+ | "startChars" | "endChars" | "beforeLines" | "afterLines";
132
+ type DefaultText = "fontAscii" | "fontHAnsi" | "fontEastAsia" | "fontCs" | "fontAsciiTheme"
133
+ | "fontHAnsiTheme" | "fontEastAsiaTheme" | "fontCsTheme" | "language" | "languageEastAsia"
134
+ | "languageBidi" | "underline" | "verticalAlign" | "runColor" | "colorTheme" | "colorTint"
135
+ | "colorShade" | "lineRule" | "footnotePosition" | "endnotePosition" | "footnoteFormat"
136
+ | "endnoteFormat" | "footnoteRestart" | "endnoteRestart" | "justification";
137
+ export type DefaultValues = Readonly<Record<DefaultToggle, boolean> & Record<DefaultInteger, number>
138
+ & Record<DefaultText, string> & {tabStops: readonly DefaultTab[]}>;
139
+
140
+ export interface ImportedOpaque {
141
+ readonly kind: "opaque";
142
+ /** Expanded XML name (usual OOXML names use their canonical prefix). */
143
+ readonly name: string;
144
+ }
145
+
146
+ export type ImportedInline =
147
+ | { readonly kind: "text"; readonly text: string }
148
+ | { readonly kind: "footnoteReference" | "endnoteReference"; readonly id: string }
149
+ | { readonly kind: "tab" }
150
+ | { readonly kind: "break"; readonly breakType: ImportedBreakType }
151
+ | ImportedOpaque;
152
+
153
+ export interface ImportedRun {
154
+ readonly drawing?: DrawingOccurrence;
155
+ readonly format: import("./text-layout.js").ResolvedRunFormat;
156
+ /** Direct toggle properties; absent when unset or ambiguous. */
157
+ readonly bold?: boolean;
158
+ readonly italic?: boolean;
159
+ readonly strike?: boolean;
160
+ readonly hidden?: boolean;
161
+ readonly hasOpaqueFormatting: boolean;
162
+ readonly propertyRevision?: ImportedPropertyRevision<"runProperties">;
163
+ readonly kind: "run";
164
+ readonly anchor: InlineAnchor;
165
+ readonly items: readonly ImportedInline[];
166
+ }
167
+
168
+ export interface ImportedHyperlink {
169
+ readonly kind: "hyperlink";
170
+ readonly anchor: InlineAnchor;
171
+ /** Source relationship ID local to the owning part, not a URL. */
172
+ readonly relationshipId?: string;
173
+ readonly bookmark?: string;
174
+ readonly tooltip?: string;
175
+ readonly historyXml?: string;
176
+ readonly children: readonly ImportedInlineNode[];
177
+ }
178
+
179
+ export interface ImportedRevision {
180
+ readonly kind: "revision";
181
+ readonly revisionKind: "insertion" | "deletion" | "moveSource" | "moveDestination";
182
+ readonly anchor: InlineAnchor;
183
+ readonly id?: string;
184
+ readonly author?: string;
185
+ readonly date?: string;
186
+ readonly children: readonly ImportedInlineNode[];
187
+ }
188
+
189
+ export interface DrawingOccurrence {
190
+ readonly title?: string;
191
+ readonly name?: string;
192
+ readonly geometry?: string;
193
+ readonly shapeText?: string;
194
+ /** DrawingML units: crop in thousandths of a percent, rotation in 1/60000 degrees. */
195
+ readonly crop?: readonly [number, number, number, number];
196
+ readonly rotation?: number;
197
+ readonly flipHorizontal?: boolean;
198
+ readonly flipVertical?: boolean;
199
+ readonly kind: "image" | "shape" | "chart";
200
+ readonly placement: "inline" | "floating";
201
+ readonly relationshipId?: string;
202
+ readonly description?: string;
203
+ readonly widthEmu?: number;
204
+ readonly heightEmu?: number;
205
+ }
206
+ export interface ImportedFraction {
207
+ readonly kind: "fraction";
208
+ readonly anchor: InlineAnchor;
209
+ readonly numerator: string;
210
+ readonly denominator: string;
211
+ }
212
+ export type ImportedInlineNode = ImportedRun | ImportedHyperlink | ImportedRevision | ImportedOpaque | ImportedFraction;
213
+
214
+ export interface ImportedFlatParagraph {
215
+ readonly kind: "paragraph";
216
+ readonly inlineItems: readonly ImportedInline[];
217
+ }
218
+
219
+ export interface ImportedParagraph extends ImportedFlatParagraph {
220
+ readonly layout: DirectParagraphLayout;
221
+ readonly markRevision?: ImportedPropertyRevision<"insertion" | "deletion">;
222
+ readonly flags: Readonly<Partial<Record<ParagraphFlag, boolean>>>;
223
+ readonly anchor: ParagraphAnchor;
224
+ /** Projection of ordinary runs and links, not rendered text. */
225
+ readonly text: string;
226
+ readonly alignment?: ImportedAlignment;
227
+ readonly alignmentXml?: string;
228
+ readonly hasOpaqueContent: boolean;
229
+ readonly inlineStructure: readonly ImportedInlineNode[];
230
+ }
231
+
232
+ export interface ImportedPropertyRevision<K extends "runProperties" | "insertion" | "deletion"> {
233
+ readonly kind: K; readonly id?: string; readonly author?: string; readonly date?: string;
234
+ }
235
+
236
+ /** Direct cell paragraph; only runs and hyperlinks have anchors. */
237
+ export interface ImportedCellParagraph extends ImportedFlatParagraph {
238
+ readonly inlineStructure: readonly ImportedInlineNode[];
239
+ }
240
+
241
+ /** Nested tables and unsupported blocks remain opaque. */
242
+ export type ImportedCellBlock = ImportedCellParagraph | ImportedOpaque;
243
+
244
+ export interface ImportedTableCell {
245
+ readonly properties: Readonly<Record<string, Readonly<Record<string, string>>>>;
246
+ readonly gridSpan?: number;
247
+ readonly verticalMerge?: string;
248
+ readonly kind: "cell";
249
+ readonly blocks: readonly ImportedCellBlock[];
250
+ }
251
+
252
+ export type ImportedRowChild = ImportedTableCell | ImportedOpaque;
253
+
254
+ export interface ImportedTableRow {
255
+ readonly properties: Readonly<Record<string, Readonly<Record<string, string>>>>;
256
+ readonly kind: "row";
257
+ readonly children: readonly ImportedRowChild[];
258
+ }
259
+
260
+ export type ImportedTableChild = ImportedTableRow | ImportedOpaque;
261
+
262
+ export interface ImportedTable {
263
+ readonly properties: Readonly<Record<string, Readonly<Record<string, string>>>>;
264
+ readonly layout?: TableLayout;
265
+ readonly gridWidths: readonly (number | null)[];
266
+ readonly kind: "table";
267
+ readonly anchor: TableAnchor;
268
+ /** Physical rows; merged cells are not expanded. */
269
+ readonly children: readonly ImportedTableChild[];
270
+ }
271
+ export interface LocatedTable {
272
+ readonly anchor: TableAnchor; readonly partName: string; readonly path: readonly number[];
273
+ readonly depth: number; readonly entryId?: string;
274
+ readonly properties: ImportedTable["properties"]; readonly gridWidths: ImportedTable["gridWidths"];
275
+ readonly rowProperties: readonly ImportedTable["properties"][];
276
+ readonly cellProperties: readonly (readonly ImportedTable["properties"][])[];
277
+ }
278
+
279
+ /** Direct body control metadata; its content is opaque and has no edit anchor.
280
+ * Values are source XML strings, including unrecognized lock values. */
281
+ export interface ImportedContentControl {
282
+ readonly kind: "contentControl";
283
+ readonly tag?: string;
284
+ readonly alias?: string;
285
+ readonly lock?: string;
286
+ }
287
+
288
+ export type BodyBlock = ImportedParagraph | ImportedTable | ImportedContentControl | ImportedOpaque;
289
+
290
+ /** Half-open body range with explicit section type only. */
291
+ export type ParagraphFlag = "keepWithNext" | "keepTogether" | "pageBreakBefore" | "widowControl" | "suppressLineNumbers" | "bidi" | "snapToGrid" | "contextualSpacing" | "mirrorIndents";
292
+ export type SectionFlag = "titlePage" | "bidi" | "rtlGutter";
293
+ export interface ImportedSection {
294
+ readonly anchor: SectionAnchor;
295
+ readonly layout: DirectSectionLayout;
296
+ readonly flags: Readonly<Partial<Record<SectionFlag, boolean>>>;
297
+ readonly bodyStart: number;
298
+ readonly bodyEnd: number;
299
+ readonly sectionType?: ImportedSectionType;
300
+ readonly sectionTypeXml?: string;
301
+ }
302
+
303
+ export type ImportedHeaderBlock = ImportedFlatParagraph | ImportedOpaque;
304
+
305
+ export interface ImportedHeaderView {
306
+ readonly anchor: HeaderAnchor;
307
+ readonly sectionIndex: number;
308
+ readonly partName: string;
309
+ readonly inherited: boolean;
310
+ readonly blocks: readonly ImportedHeaderBlock[];
311
+ }
312
+
313
+ export interface ImportedHeader extends ResolvedHandle<"importedHeader", ImportedHeaderView> {
314
+ /** Empty paragraphs return `[]`; opaque and out-of-range blocks return `undefined`. */
315
+ inlineStructure(blockIndex: number): readonly ImportedInlineNode[] | undefined;
316
+ }
317
+
318
+ export type SectionStoryKind = "header" | "footer";
319
+ export type ImportedStoryVariant = "default" | "first" | "even";
320
+ export type ImportedStoryBlock = ImportedHeaderBlock;
321
+
322
+ /** A section's effective reference to a physical header or footer part. */
323
+ export interface ImportedStoryView {
324
+ /** Image-edit target for this section, story kind and variant. */
325
+ readonly anchor: HeaderAnchor;
326
+ readonly sectionIndex: number;
327
+ readonly kind: SectionStoryKind;
328
+ /** The section reference slot, not a pagination result. */
329
+ readonly variant: ImportedStoryVariant;
330
+ /** Physical package part name; aliases share inline anchors. */
331
+ readonly partName: string;
332
+ readonly inherited: boolean;
333
+ readonly blocks: readonly ImportedStoryBlock[];
334
+ }
335
+
336
+ export interface ImportedStory extends ResolvedHandle<"importedStory", ImportedStoryView> {
337
+ /** Empty paragraphs return `[]`; opaque and out-of-range blocks return `undefined`. */
338
+ inlineStructure(blockIndex: number): readonly ImportedInlineNode[] | undefined;
339
+ }
340
+
341
+ declare const importedDocument: unique symbol;
342
+
343
+ export interface ImportedEntry {
344
+ readonly kind: "footnote" | "endnote" | "comment";
345
+ readonly partName: string;
346
+ readonly id: string;
347
+ readonly noteType?: string;
348
+ readonly author?: string;
349
+ readonly date?: string;
350
+ readonly initials?: string;
351
+ readonly blocks: readonly (ImportedOpaque | (ImportedFlatParagraph & {
352
+ readonly inlineStructure: readonly ImportedInlineNode[];
353
+ }))[];
354
+ }
355
+
356
+ /** Source metadata only; absent fields were not present in the source. */
357
+ export interface ImportedStyle {
358
+ readonly id?: string;
359
+ readonly kind: "paragraph" | "character" | "table" | "numbering" | "missing" | "unsupported";
360
+ readonly kindXml?: string;
361
+ readonly name?: string;
362
+ readonly basedOn?: string;
363
+ readonly nextStyle?: string;
364
+ readonly linkedStyle?: string;
365
+ readonly propertyXml: readonly string[];
366
+ }
367
+ export interface ImportedStyles {
368
+ readonly partName: string;
369
+ readonly styles: readonly ImportedStyle[];
370
+ }
371
+ export interface ImportedDocument {
372
+ chartSeries(anchor: InlineAnchor): { readonly categories: readonly string[]; readonly values: readonly number[] };
373
+ controls(): readonly ImportedControl[];
374
+ storyControls(): readonly ImportedControl[];
375
+ controlSites(): readonly ControlSite[];
376
+ readonly [importedDocument]: true;
377
+ body(): readonly BodyBlock[];
378
+ sections(): readonly ImportedSection[];
379
+ /** Rejects anchors issued by any other snapshot, including reopening identical bytes. */
380
+ inlineAt(anchor: InlineAnchor): ImportedRun | ImportedHyperlink | ImportedRevision | ImportedFraction;
381
+ /** Lazily inspect effective default headers; sections without one are omitted. */
382
+ defaultHeaders(): readonly ImportedHeader[];
383
+ /**
384
+ * Lazily inspect effective header/footer slots in section order, headers
385
+ * before footers and default, first, then even within each kind. Unset slots
386
+ * are omitted, and page selection settings do not filter the result.
387
+ */
388
+ stories(): readonly ImportedStory[];
389
+ entryStories(): readonly ImportedEntry[];
390
+ partTables(ownerPart?: string): readonly LocatedTable[];
391
+ /** Undefined when the document has no styles relationship. */
392
+ styles(): ImportedStyles | undefined;
393
+ coreTitle(): string | undefined;
394
+ coreSubject(): string | undefined;
395
+ metadataField(field: MetadataField): string | undefined;
396
+ customProperty(name: string): string | boolean | undefined;
397
+ defaultAlignment(): ImportedAlignment | undefined;
398
+ documentDefaults(): Partial<DefaultValues>;
399
+ abstractStarts(): readonly AbstractStart[];
400
+ numberingInstances(): readonly ImportedNumberingInstance[];
401
+ numberingCatalog(): ImportedNumberingCatalog;
402
+ storyParagraphAnchor(site: { readonly ownerPart: string; readonly blockIndex: number; readonly entryId?: string }): StoryParagraphAnchor;
403
+ cellParagraphAnchor(site: { readonly target: TableAnchor; readonly rowIndex: number; readonly cellIndex: number; readonly blockIndex: number }): StoryParagraphAnchor;
404
+ storyParagraphNumbering(target: StoryParagraphAnchor): { readonly id: number; readonly level: number } | undefined;
405
+ paragraphNumbering(target: ParagraphAnchor): { readonly id: number; readonly level: number } | undefined;
406
+ }
407
+
408
+ export interface AbstractStart {
409
+ readonly abstractId: number;
410
+ readonly level: number;
411
+ readonly start?: number;
412
+ }
413
+
414
+ export interface ImportedNumberingInstance {
415
+ readonly replacementLevels: readonly number[];
416
+ readonly numId: number;
417
+ readonly abstractId: number;
418
+ readonly startOverrides: readonly { readonly level: number; readonly start: number }[];
419
+ }
420
+
421
+ export interface ImportedNumberingLevel {
422
+ readonly level: number;
423
+ readonly start?: number;
424
+ readonly format?: string;
425
+ readonly text?: string;
426
+ readonly isLegal?: boolean;
427
+ readonly restart?: number;
428
+ readonly suffix?: "tab" | "space" | "nothing";
429
+ readonly alignment?: "left" | "center" | "right" | "start" | "end";
430
+ readonly paragraphStyle?: string;
431
+ readonly labelFormat?: ResolvedRunFormat;
432
+ readonly paragraphFormat?: ResolvedParagraphFormat;
433
+ readonly hasOpaqueContent: boolean;
434
+ }
435
+
436
+ export interface ImportedNumberingCatalog {
437
+ readonly abstracts: readonly {
438
+ readonly abstractId: number;
439
+ readonly styleLink?: string;
440
+ readonly numStyleLink?: string;
441
+ readonly levels: readonly ImportedNumberingLevel[];
442
+ }[];
443
+ readonly instances: readonly {
444
+ readonly numId: number;
445
+ readonly abstractId: number;
446
+ readonly styleIds: readonly string[];
447
+ readonly startOverrides: ImportedNumberingInstance["startOverrides"];
448
+ readonly levelOverrides: readonly ImportedNumberingLevel[];
449
+ }[];
450
+ }
451
+
452
+ export interface OpenDocxOptions {
453
+ readonly readLimits?: ReadLimits;
454
+ }
455
+
456
+ /** Open an immutable Transitional DOCX snapshot from the exact supplied byte view. */
457
+ export function openDocx(bytes: Uint8Array, options?: OpenDocxOptions): Promise<ImportedDocument>;
@@ -0,0 +1,73 @@
1
+ import type { Condition, ResolveOptions } from "./boundary.js";
2
+ import type { DrawingResolvedInlineInput, DrawingValidationInput } from "./drawings.js";
3
+ import type { ResolvedComment, StructuredResolvedInlineArms, TextRevision } from "./structured.js";
4
+ import type { ResolvedDocument, ResolvedInline, ResolvedParagraph, RunFormat } from "./text-layout.js";
5
+
6
+ declare const valueType: unique symbol;
7
+ declare const propertyId: unique symbol;
8
+ export type PropertyId = { readonly [propertyId]: true };
9
+
10
+ /** A single-use resolution stage. Use a Deferred or Property to share its outcome. */
11
+ export interface Value<T> {
12
+ readonly [valueType]: readonly ["value", T];
13
+ map<U>(transform: (value: T, context: ProducerContext) => SyncV<U>): Value<U>;
14
+ }
15
+ export interface Deferred<T> {
16
+ readonly [valueType]: readonly ["deferred", T];
17
+ }
18
+ export interface Property<T> {
19
+ readonly [valueType]: readonly ["property", T];
20
+ reference(): PropertyRef<T>;
21
+ }
22
+ export interface PropertyRef<T> {
23
+ readonly [valueType]: readonly ["ref", T];
24
+ readonly id: PropertyId;
25
+ }
26
+ export type V<T> = T | Value<T> | Deferred<T> | Property<T> | PropertyRef<T>;
27
+ // Only future assimilates thenables returned directly from its producer.
28
+ type SyncV<T> = (T & (T extends PromiseLike<unknown> ? never : unknown)) |
29
+ Value<T> | Deferred<T> | Property<T> | PropertyRef<T>;
30
+ export interface ProducerContext {
31
+ /** Aborts owned producer work. Cancelling a waiter does not abort shared work. */
32
+ readonly signal: AbortSignal;
33
+ get<T>(value: PropertyRef<T> | Deferred<T>): Promise<T>;
34
+ }
35
+ export function ready<T>(value: T): Value<T>;
36
+ export function lazy<T>(producer: (context: ProducerContext) => SyncV<T>): Value<T>;
37
+ export function future<T>(producer: (context: ProducerContext) => V<T> | PromiseLike<V<T>>): Value<T>;
38
+ export function deferred<T>(value: V<T>): Deferred<T>;
39
+ export function property<T>(name: string, value: V<T>, options?: { readonly condition?: Condition }): Property<T>;
40
+ export function resolveValue<T>(value: V<T>, options?: ResolveOptions): Promise<T>;
41
+
42
+ type TextInlineInput = {
43
+ readonly kind: "text";
44
+ readonly text: string;
45
+ readonly format?: RunFormat;
46
+ readonly comment?: ResolvedComment;
47
+ readonly revision?: TextRevision;
48
+ };
49
+ type StructuredInlineInput = {
50
+ [K in keyof StructuredResolvedInlineArms]: { readonly kind: K } & StructuredResolvedInlineArms[K];
51
+ }[keyof StructuredResolvedInlineArms];
52
+ export type CreateResolvedInlineInput = TextInlineInput | DrawingResolvedInlineInput | StructuredInlineInput;
53
+ export type ResolvedInlineView = ResolvedInline["view"];
54
+
55
+ /** Rust's display projection, not a concatenation of the raw text fields. */
56
+ export function inlineText(handles: readonly ResolvedInline[]): Promise<string>;
57
+ /** Construct a Rust enum arm from ready data; contextual checks are separate. */
58
+ export function createResolvedInline<K extends CreateResolvedInlineInput["kind"]>(
59
+ input: { readonly kind: K } & Extract<CreateResolvedInlineInput, { readonly kind: K }>,
60
+ ): Promise<Extract<ResolvedInline, { readonly view: { readonly kind: K } }>>;
61
+
62
+ export interface ValidationValues {
63
+ readonly resolvedInline: ResolvedInline;
64
+ readonly resolvedParagraph: ResolvedParagraph;
65
+ readonly resolvedDocument: ResolvedDocument;
66
+ }
67
+ export type ValidateValueInput = {
68
+ [K in keyof ValidationValues]: { readonly kind: K; readonly value: ValidationValues[K] };
69
+ }[keyof ValidationValues] | DrawingValidationInput;
70
+ export function validateValue(input: ValidateValueInput): Promise<void>;
71
+
72
+ export type AuthoringIdKind = "bookmarkName" | "rangeId" | "styleId";
73
+ export function validateAuthoringId(kind: AuthoringIdKind, value: string): Promise<void>;