@twip/web 0.1.0-alpha.1 → 0.1.0-pre.2

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 (179) hide show
  1. package/README.md +35 -0
  2. package/dist/THIRD-PARTY-NOTICES.md +1013 -225
  3. package/dist/commands.d.ts +637 -0
  4. package/dist/commands.js +188 -0
  5. package/dist/editor.d.ts +218 -0
  6. package/dist/editor.js +460 -0
  7. package/dist/errors.d.ts +21 -0
  8. package/dist/errors.js +26 -0
  9. package/dist/events.d.ts +126 -0
  10. package/dist/events.js +1 -0
  11. package/dist/fonts/google.d.ts +3 -0
  12. package/dist/fonts/google.js +39 -0
  13. package/dist/fonts/library.d.ts +65 -0
  14. package/dist/fonts/library.js +130 -0
  15. package/dist/host/a11y.d.ts +3 -0
  16. package/dist/host/a11y.js +62 -0
  17. package/dist/host/chrome.d.ts +28 -0
  18. package/dist/host/chrome.js +144 -0
  19. package/dist/host/clipboard.d.ts +16 -0
  20. package/dist/host/clipboard.js +128 -0
  21. package/dist/host/dom.d.ts +45 -0
  22. package/dist/host/dom.js +122 -0
  23. package/dist/host/frames.d.ts +14 -0
  24. package/dist/host/frames.js +87 -0
  25. package/dist/host/gpu.d.ts +58 -0
  26. package/dist/host/gpu.js +79 -0
  27. package/dist/host/ime.d.ts +3 -0
  28. package/dist/host/ime.js +11 -0
  29. package/dist/host/input.d.ts +12 -0
  30. package/dist/host/input.js +86 -0
  31. package/dist/host/keys.d.ts +16 -0
  32. package/dist/host/keys.js +27 -0
  33. package/dist/host/mount.d.ts +11 -0
  34. package/dist/host/mount.js +72 -0
  35. package/dist/host/pointer.d.ts +4 -0
  36. package/dist/host/pointer.js +171 -0
  37. package/dist/host/scroll.d.ts +14 -0
  38. package/dist/host/scroll.js +95 -0
  39. package/dist/index.d.ts +27 -98
  40. package/dist/index.js +10 -0
  41. package/dist/review.d.ts +156 -0
  42. package/dist/review.js +38 -0
  43. package/dist/services/accessibility.d.ts +52 -0
  44. package/dist/services/accessibility.js +71 -0
  45. package/dist/services/dialogs.d.ts +181 -0
  46. package/dist/services/dialogs.js +18 -0
  47. package/dist/services/elements.d.ts +146 -0
  48. package/dist/services/elements.js +18 -0
  49. package/dist/services/find.d.ts +50 -0
  50. package/dist/services/find.js +12 -0
  51. package/dist/services/menus.d.ts +82 -0
  52. package/dist/services/menus.js +8 -0
  53. package/dist/services/navigation.d.ts +58 -0
  54. package/dist/services/navigation.js +12 -0
  55. package/dist/services/ruler.d.ts +95 -0
  56. package/dist/services/ruler.js +16 -0
  57. package/dist/services/spelling.d.ts +34 -0
  58. package/dist/services/spelling.js +14 -0
  59. package/dist/services/view.d.ts +70 -0
  60. package/dist/services/view.js +19 -0
  61. package/dist/state.d.ts +483 -0
  62. package/dist/state.js +1 -0
  63. package/dist/transport/direct.d.ts +31 -0
  64. package/dist/transport/direct.js +405 -0
  65. package/dist/transport/module.d.ts +51 -0
  66. package/dist/transport/module.js +17 -0
  67. package/dist/transport/protocol.d.ts +265 -0
  68. package/dist/transport/protocol.js +132 -0
  69. package/dist/transport/worker.d.ts +54 -0
  70. package/dist/transport/worker.js +203 -0
  71. package/dist/twip-wasm.js +1 -1
  72. package/dist/twip_wasm.wasm +0 -0
  73. package/dist/types.d.ts +134 -0
  74. package/dist/types.js +16 -0
  75. package/dist/worker/entry.d.ts +1 -0
  76. package/dist/worker/entry.js +53 -0
  77. package/dist/worker.d.ts +1 -0
  78. package/dist/worker.js +2 -0
  79. package/package.json +17 -7
  80. package/dist/AccessibleNode.d.ts +0 -51
  81. package/dist/AccessibleNode.mjs +0 -177
  82. package/dist/Alignment.d.ts +0 -38
  83. package/dist/Alignment.mjs +0 -90
  84. package/dist/BorderEdges.d.ts +0 -50
  85. package/dist/BorderEdges.mjs +0 -114
  86. package/dist/BorderStyle.d.ts +0 -27
  87. package/dist/BorderStyle.mjs +0 -81
  88. package/dist/Bytes.d.ts +0 -19
  89. package/dist/Bytes.mjs +0 -76
  90. package/dist/CaretPosition.d.ts +0 -34
  91. package/dist/CaretPosition.mjs +0 -148
  92. package/dist/CellAlignment.d.ts +0 -25
  93. package/dist/CellAlignment.mjs +0 -75
  94. package/dist/CellShift.d.ts +0 -30
  95. package/dist/CellShift.mjs +0 -78
  96. package/dist/Clipboard.d.ts +0 -22
  97. package/dist/Clipboard.mjs +0 -90
  98. package/dist/ColumnSide.d.ts +0 -24
  99. package/dist/ColumnSide.mjs +0 -72
  100. package/dist/ControlKind.d.ts +0 -28
  101. package/dist/ControlKind.mjs +0 -84
  102. package/dist/ControlLock.d.ts +0 -42
  103. package/dist/ControlLock.mjs +0 -96
  104. package/dist/DocumentStatus.d.ts +0 -34
  105. package/dist/DocumentStatus.mjs +0 -148
  106. package/dist/Editor.d.ts +0 -773
  107. package/dist/Editor.mjs +0 -2269
  108. package/dist/EditorMode.d.ts +0 -34
  109. package/dist/EditorMode.mjs +0 -84
  110. package/dist/Element.d.ts +0 -57
  111. package/dist/Element.mjs +0 -201
  112. package/dist/ElementKind.d.ts +0 -28
  113. package/dist/ElementKind.mjs +0 -78
  114. package/dist/ElementList.d.ts +0 -20
  115. package/dist/ElementList.mjs +0 -71
  116. package/dist/ElementText.d.ts +0 -34
  117. package/dist/ElementText.mjs +0 -84
  118. package/dist/Event.d.ts +0 -45
  119. package/dist/Event.mjs +0 -159
  120. package/dist/EventKind.d.ts +0 -39
  121. package/dist/EventKind.mjs +0 -93
  122. package/dist/EventList.d.ts +0 -20
  123. package/dist/EventList.mjs +0 -71
  124. package/dist/Fonts.d.ts +0 -29
  125. package/dist/Fonts.mjs +0 -107
  126. package/dist/Highlight.d.ts +0 -41
  127. package/dist/Highlight.mjs +0 -117
  128. package/dist/MarginPreset.d.ts +0 -38
  129. package/dist/MarginPreset.mjs +0 -90
  130. package/dist/MarkSeverity.d.ts +0 -25
  131. package/dist/MarkSeverity.mjs +0 -75
  132. package/dist/Modifiers.d.ts +0 -34
  133. package/dist/Modifiers.mjs +0 -148
  134. package/dist/OpenError.d.ts +0 -30
  135. package/dist/OpenError.mjs +0 -78
  136. package/dist/Orientation.d.ts +0 -30
  137. package/dist/Orientation.mjs +0 -78
  138. package/dist/PageNumber.d.ts +0 -34
  139. package/dist/PageNumber.mjs +0 -84
  140. package/dist/PaperSize.d.ts +0 -50
  141. package/dist/PaperSize.mjs +0 -108
  142. package/dist/ParagraphBorders.d.ts +0 -34
  143. package/dist/ParagraphBorders.mjs +0 -84
  144. package/dist/PictureWrap.d.ts +0 -34
  145. package/dist/PictureWrap.mjs +0 -90
  146. package/dist/PointerKind.d.ts +0 -23
  147. package/dist/PointerKind.mjs +0 -75
  148. package/dist/Rect.d.ts +0 -34
  149. package/dist/Rect.mjs +0 -148
  150. package/dist/Request.d.ts +0 -55
  151. package/dist/Request.mjs +0 -207
  152. package/dist/RequestKind.d.ts +0 -45
  153. package/dist/RequestKind.mjs +0 -105
  154. package/dist/RequestList.d.ts +0 -20
  155. package/dist/RequestList.mjs +0 -71
  156. package/dist/RowHeightRule.d.ts +0 -34
  157. package/dist/RowHeightRule.mjs +0 -84
  158. package/dist/RowSide.d.ts +0 -24
  159. package/dist/RowSide.mjs +0 -72
  160. package/dist/SaveError.d.ts +0 -24
  161. package/dist/SaveError.mjs +0 -72
  162. package/dist/SelectionInfo.d.ts +0 -39
  163. package/dist/SelectionInfo.mjs +0 -166
  164. package/dist/SelectionKind.d.ts +0 -37
  165. package/dist/SelectionKind.mjs +0 -93
  166. package/dist/TableAlignment.d.ts +0 -25
  167. package/dist/TableAlignment.mjs +0 -75
  168. package/dist/TableSelection.d.ts +0 -38
  169. package/dist/TableSelection.mjs +0 -90
  170. package/dist/TableWidthUnit.d.ts +0 -31
  171. package/dist/TableWidthUnit.mjs +0 -81
  172. package/dist/TextUnit.d.ts +0 -25
  173. package/dist/TextUnit.mjs +0 -75
  174. package/dist/diplomat-runtime.d.ts +0 -15
  175. package/dist/diplomat-runtime.mjs +0 -786
  176. package/dist/diplomat-wasm.mjs +0 -18
  177. package/dist/gpu.d.ts +0 -15
  178. package/dist/gpu.mjs +0 -42
  179. package/dist/index.mjs +0 -101
@@ -0,0 +1,483 @@
1
+ import type { CommandId } from './commands.js';
2
+ import type { DialogKind } from './services/dialogs.js';
3
+ import type { ControlKind } from './services/elements.js';
4
+ import type { RulerModel, RulerUnit, TabSelector } from './services/ruler.js';
5
+ import type { Color, CommentId, ElementId, Points, RevisionId, StyleId } from './types.js';
6
+ /** An on/off value over the selection: `'mixed'` where it differs, `null` where it doesn't apply. */
7
+ export type Tri = boolean | 'mixed' | null;
8
+ /** A value over the selection: `'mixed'` where it differs, `null` where it doesn't apply. */
9
+ export type Mixed<T> = T | 'mixed' | null;
10
+ /** The editor's UI snapshot: small, immutable, and cached on the calling side. */
11
+ export interface EditorState {
12
+ /** Rises by one per committed transaction. */
13
+ revision: number;
14
+ /** Rises by one per observable change, selection included. */
15
+ sequence: number;
16
+ /** Whether a document is opening, ready, or still being laid out. */
17
+ load: 'opening' | 'ready' | 'layingOut';
18
+ /** Editing or the merge designer's design mode. */
19
+ mode: 'editing' | 'design';
20
+ /** Whether edits are refused. */
21
+ readOnly: boolean;
22
+ /** Changed since the last open or DOCX export; undoing back clears it. */
23
+ modified: boolean;
24
+ /** What is selected. */
25
+ selection: SelectionSummary;
26
+ /** The selection's character formatting. */
27
+ formatting: CharacterFormatting;
28
+ /** The selection's paragraph formatting. */
29
+ paragraph: ParagraphFormatting;
30
+ /** The selection's section. */
31
+ page: PageFormatting;
32
+ /** Each command's availability and value, keyed by command id. */
33
+ commands: {
34
+ readonly [K in CommandId]: CommandState<K>;
35
+ };
36
+ /** Each dialog's availability: whether `dialogs.open` opens it now. */
37
+ dialogs: {
38
+ readonly [K in DialogKind]: boolean;
39
+ };
40
+ /** Undo and redo. */
41
+ history: {
42
+ canUndo: boolean;
43
+ canRedo: boolean;
44
+ undoLabel: string | null;
45
+ redoLabel: string | null;
46
+ };
47
+ /**
48
+ * The pages laid out so far and the caret's page. Background layout adds pages until `complete`; each change is a
49
+ * new state with the same revision.
50
+ */
51
+ pages: {
52
+ count: number;
53
+ current: number;
54
+ complete: boolean;
55
+ };
56
+ /** View settings. */
57
+ view: ViewState;
58
+ /** Track changes and comments. */
59
+ review: ReviewState;
60
+ /** Spell checking. */
61
+ spelling: {
62
+ enabled: boolean;
63
+ language: string;
64
+ misspellings: number;
65
+ };
66
+ /** Fonts being fetched and fonts that could not be found. */
67
+ fonts: {
68
+ pending: string[];
69
+ unresolved: string[];
70
+ };
71
+ /** The ruler model for the selection, in points, with no viewport mapping. */
72
+ ruler: RulerModel;
73
+ /** Whether formatting is held for `pasteFormatting`. */
74
+ formatPainter: boolean;
75
+ }
76
+ /** The value each command reports in state, for the commands that report one. */
77
+ export interface CommandValues {
78
+ /** The undo label. */
79
+ undo: string | null;
80
+ /** The redo label. */
81
+ redo: string | null;
82
+ /** The selection mode. */
83
+ setSelectionMode: SelectionSummary['mode'];
84
+ /** Bold. */
85
+ setBold: Tri;
86
+ /** Italic. */
87
+ setItalic: Tri;
88
+ /** The underline style. */
89
+ setUnderline: Mixed<UnderlineStyle>;
90
+ /** Strikethrough. */
91
+ setStrikethrough: Tri;
92
+ /** Double strikethrough. */
93
+ setDoubleStrikethrough: Tri;
94
+ /** Subscript. */
95
+ setSubscript: Tri;
96
+ /** Superscript. */
97
+ setSuperscript: Tri;
98
+ /** Small caps. */
99
+ setSmallCaps: Tri;
100
+ /** All caps. */
101
+ setAllCaps: Tri;
102
+ /** Hidden text. */
103
+ setHidden: Tri;
104
+ /** The document's font family. */
105
+ setFont: Mixed<string>;
106
+ /** The font size. */
107
+ setFontSize: Mixed<Points>;
108
+ /** The font colour. */
109
+ setFontColor: Mixed<Color | 'auto'>;
110
+ /** The highlight. */
111
+ setHighlight: Mixed<HighlightColor | 'none'>;
112
+ /** The character spacing. */
113
+ setCharacterSpacing: Mixed<Points>;
114
+ /** The raised or lowered position. */
115
+ setCharacterPosition: Mixed<Points>;
116
+ /** Whether formatting is held. */
117
+ copyFormatting: boolean;
118
+ /** Whether formatting is held. */
119
+ pasteFormatting: boolean;
120
+ /** The alignment. */
121
+ setAlignment: ParagraphFormatting['alignment'];
122
+ /** The line spacing. */
123
+ setLineSpacing: Mixed<LineSpacing>;
124
+ /** The space before and after. */
125
+ setParagraphSpacing: {
126
+ before: Mixed<Points | 'auto'>;
127
+ after: Mixed<Points | 'auto'>;
128
+ };
129
+ /** The indents. */
130
+ setIndents: ParagraphFormatting['indents'];
131
+ /** The paragraph style. */
132
+ setParagraphStyle: Mixed<StyleId>;
133
+ /** The list kind. */
134
+ setList: ParagraphFormatting['list'];
135
+ /** The list level. */
136
+ setListLevel: Mixed<number>;
137
+ /** The pagination flags. */
138
+ setParagraphFlow: ParagraphFormatting['flow'];
139
+ /** The paragraph borders. */
140
+ setParagraphBorders: ParagraphFormatting['borders'];
141
+ /** The paragraph shading. */
142
+ setParagraphShading: Mixed<Color | 'none'>;
143
+ /** The margins. */
144
+ setMargins: PageFormatting['margins'];
145
+ /** The orientation. */
146
+ setOrientation: PageFormatting['orientation'];
147
+ /** The paper size. */
148
+ setPaperSize: PageFormatting['size'];
149
+ /** The text columns. */
150
+ setColumns: PageFormatting['columns'];
151
+ /** The header and footer distances. */
152
+ setHeaderFooterDistance: {
153
+ header: Points;
154
+ footer: Points;
155
+ };
156
+ /** A different first page. */
157
+ setDifferentFirstPage: boolean;
158
+ /** Different odd and even pages. */
159
+ setDifferentOddEvenPages: boolean;
160
+ /** Whether changes are tracked. */
161
+ setTrackChanges: boolean;
162
+ /** The markup view. */
163
+ setMarkupView: MarkupView;
164
+ /** The active comment. */
165
+ setActiveComment: CommentId | null;
166
+ /** The zoom, in percent. */
167
+ setZoom: number;
168
+ /** The view options. */
169
+ setViewOptions: {
170
+ formattingMarks: boolean;
171
+ gridlines: boolean;
172
+ textBoundaries: boolean;
173
+ };
174
+ /** The mode. */
175
+ setMode: EditorState['mode'];
176
+ }
177
+ /** A command's entry in {@link EditorState.commands}. */
178
+ export interface CommandState<K extends CommandId = CommandId> {
179
+ /** Whether running it now would succeed. */
180
+ enabled: boolean;
181
+ /** For on/off commands: whether it is on. */
182
+ checked?: boolean;
183
+ /** The command's state value, where it has one. */
184
+ value?: K extends keyof CommandValues ? CommandValues[K] : never;
185
+ }
186
+ /** What is selected. No document position is public. */
187
+ export interface SelectionSummary {
188
+ /** A caret, text, table cells, an object, or an element. */
189
+ kind: 'caret' | 'text' | 'cells' | 'object' | 'element';
190
+ /** The story the selection is in. */
191
+ story: 'body' | 'header' | 'footer' | 'footnote' | 'endnote' | 'textBox';
192
+ /** The page of the caret. */
193
+ page: number;
194
+ /** The selection mode. */
195
+ mode: 'normal' | 'extend' | 'block';
196
+ /** Nothing is selected (a caret). */
197
+ empty: boolean;
198
+ /**
199
+ * The selection as plain text, paragraphs separated by `\n` (`''` for a caret), or `null` when it is longer than
200
+ * 10,000 characters.
201
+ */
202
+ text: string | null;
203
+ /** The table around the selection, if any. */
204
+ table: TableSelection | null;
205
+ /** The selected object, if any. */
206
+ object: ObjectSelection | null;
207
+ /** Innermost first: the element the selection is in or covers, then its parents. */
208
+ context: ElementContext[];
209
+ /** The link at the selection, if any. */
210
+ link: {
211
+ address: string;
212
+ text: string;
213
+ } | null;
214
+ /** The comment thread at the caret. */
215
+ comment: CommentId | null;
216
+ /** The revision at the caret. */
217
+ revision: RevisionId | null;
218
+ /** Set while a header or footer is being edited. */
219
+ headerFooter: {
220
+ kind: 'header' | 'footer';
221
+ type: 'default' | 'first' | 'even';
222
+ section: number;
223
+ page: number;
224
+ /** For example `'First Page Header -Section 2-'`. */
225
+ label: string;
226
+ } | null;
227
+ }
228
+ /** The table around the selection. */
229
+ export interface TableSelection {
230
+ /** The row count. */
231
+ rows: number;
232
+ /** The column count. */
233
+ columns: number;
234
+ /** The current cell's row, 0-based. */
235
+ row: number;
236
+ /** The current cell's column, 0-based. */
237
+ column: number;
238
+ /** Whether the selected cells can merge. */
239
+ canMerge: boolean;
240
+ /** Repeat as header row. */
241
+ headerRow: Tri;
242
+ /** Rows can break across pages. */
243
+ rowCanBreak: Tri;
244
+ /** The vertical cell alignment. */
245
+ cellAlignment: Mixed<'top' | 'center' | 'bottom'>;
246
+ /** The cell shading. */
247
+ cellShading: Mixed<Color | 'none'>;
248
+ /** The row height. */
249
+ rowHeight: Mixed<RowHeight>;
250
+ /** The column width. */
251
+ columnWidth: Mixed<Points>;
252
+ /** The table style. */
253
+ style: StyleId | null;
254
+ /** The table style options. */
255
+ styleOptions: TableStyleOptions;
256
+ /** The table width. */
257
+ width: TableWidth;
258
+ /** The table alignment. */
259
+ alignment: 'left' | 'center' | 'right';
260
+ /** The table indent. */
261
+ indent: Points;
262
+ }
263
+ /** A row height. */
264
+ export type RowHeight = {
265
+ height: Points;
266
+ rule: 'atLeast' | 'exact';
267
+ } | 'auto';
268
+ /** Which parts of a table style apply. */
269
+ export interface TableStyleOptions {
270
+ /** The header row. */
271
+ headerRow: boolean;
272
+ /** The total row. */
273
+ totalRow: boolean;
274
+ /** The first column. */
275
+ firstColumn: boolean;
276
+ /** The last column. */
277
+ lastColumn: boolean;
278
+ /** Banded rows. */
279
+ bandedRows: boolean;
280
+ /** Banded columns. */
281
+ bandedColumns: boolean;
282
+ }
283
+ /** A table width. */
284
+ export type TableWidth = {
285
+ kind: 'auto';
286
+ } | {
287
+ kind: 'points';
288
+ value: Points;
289
+ } | {
290
+ kind: 'percent';
291
+ value: number;
292
+ };
293
+ /** The selected picture or text box. */
294
+ export interface ObjectSelection {
295
+ /** A picture or a text box. */
296
+ kind: 'picture' | 'textBox';
297
+ /** How text wraps around it. */
298
+ wrap: ObjectWrap;
299
+ /** The width. */
300
+ width: Points;
301
+ /** The height. */
302
+ height: Points;
303
+ /** The alternative text. */
304
+ altText: string;
305
+ /** Marked decorative. */
306
+ decorative: boolean;
307
+ /** Whether a floating object's anchor is locked; `null` when inline. */
308
+ anchorLocked: boolean | null;
309
+ }
310
+ /** How text wraps around an object. */
311
+ export type ObjectWrap = 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behindText' | 'inFrontOfText';
312
+ /** An element the selection is in or covers. */
313
+ export interface ElementContext {
314
+ /** The element. */
315
+ id: ElementId;
316
+ /** Its kind. */
317
+ kind: 'field' | ControlKind | 'repeatingItem';
318
+ /** The selection covers exactly this element. */
319
+ exact: boolean;
320
+ /** A field's code. */
321
+ code?: string;
322
+ /** A control's tag. */
323
+ tag?: string;
324
+ /** A control's title. */
325
+ title?: string;
326
+ }
327
+ /** The selection's character formatting. */
328
+ export interface CharacterFormatting {
329
+ /** The document's family, never the substituted one. */
330
+ font: Mixed<string>;
331
+ /** The size. */
332
+ size: Mixed<Points>;
333
+ /** Bold. */
334
+ bold: Tri;
335
+ /** Italic. */
336
+ italic: Tri;
337
+ /** The underline style. */
338
+ underline: Mixed<UnderlineStyle>;
339
+ /** Strikethrough. */
340
+ strikethrough: Tri;
341
+ /** Double strikethrough. */
342
+ doubleStrikethrough: Tri;
343
+ /** Subscript. */
344
+ subscript: Tri;
345
+ /** Superscript. */
346
+ superscript: Tri;
347
+ /** Small caps. */
348
+ smallCaps: Tri;
349
+ /** All caps. */
350
+ allCaps: Tri;
351
+ /** Hidden. */
352
+ hidden: Tri;
353
+ /** The colour. */
354
+ color: Mixed<Color | 'auto'>;
355
+ /** The highlight. */
356
+ highlight: Mixed<HighlightColor | 'none'>;
357
+ /** The character spacing. */
358
+ characterSpacing: Mixed<Points>;
359
+ /** The raised (positive) or lowered position. */
360
+ position: Mixed<Points>;
361
+ }
362
+ /** The selection's paragraph formatting. */
363
+ export interface ParagraphFormatting {
364
+ /** The paragraph style. */
365
+ style: Mixed<StyleId>;
366
+ /** The alignment. */
367
+ alignment: Mixed<'left' | 'center' | 'right' | 'justify'>;
368
+ /** The line spacing. */
369
+ lineSpacing: Mixed<LineSpacing>;
370
+ /** The space before. */
371
+ spaceBefore: Mixed<Points | 'auto'>;
372
+ /** The space after. */
373
+ spaceAfter: Mixed<Points | 'auto'>;
374
+ /** The indents. */
375
+ indents: {
376
+ left: Mixed<Points>;
377
+ right: Mixed<Points>;
378
+ firstLine: Mixed<Points>;
379
+ hanging: Mixed<Points>;
380
+ };
381
+ /** The list kind. */
382
+ list: Mixed<'bullet' | 'numbered' | 'none'>;
383
+ /** The list level. */
384
+ listLevel: Mixed<number>;
385
+ /** The pagination flags. */
386
+ flow: {
387
+ keepWithNext: Tri;
388
+ keepLinesTogether: Tri;
389
+ pageBreakBefore: Tri;
390
+ widowControl: Tri;
391
+ };
392
+ /** The borders. */
393
+ borders: Mixed<'box' | 'bottom' | 'none' | 'other'>;
394
+ /** The shading. */
395
+ shading: Mixed<Color | 'none'>;
396
+ }
397
+ /** The selection's section. */
398
+ export interface PageFormatting {
399
+ /** The paper size. */
400
+ size: {
401
+ width: Points;
402
+ height: Points;
403
+ };
404
+ /** The orientation. */
405
+ orientation: 'portrait' | 'landscape';
406
+ /** The margins. */
407
+ margins: {
408
+ top: Points;
409
+ bottom: Points;
410
+ left: Points;
411
+ right: Points;
412
+ gutter: Points;
413
+ };
414
+ /** The text columns. */
415
+ columns: {
416
+ count: number;
417
+ spacing: Points;
418
+ separator: boolean;
419
+ };
420
+ /** The header distance from the page edge. */
421
+ headerDistance: Points;
422
+ /** The footer distance from the page edge. */
423
+ footerDistance: Points;
424
+ /** A different first page. */
425
+ differentFirstPage: boolean;
426
+ /** Different odd and even pages. */
427
+ differentOddEven: boolean;
428
+ }
429
+ /** View settings. */
430
+ export interface ViewState {
431
+ /** Percent, after any fit. */
432
+ zoom: number;
433
+ /** Formatting marks are shown. */
434
+ formattingMarks: boolean;
435
+ /** Table gridlines are shown. */
436
+ gridlines: boolean;
437
+ /** Text boundaries are shown. */
438
+ textBoundaries: boolean;
439
+ /** Field codes are shown. */
440
+ fieldCodes: boolean;
441
+ /** Which built-in rulers are shown. */
442
+ rulers: {
443
+ horizontal: boolean;
444
+ vertical: boolean;
445
+ };
446
+ /** The ruler unit. */
447
+ rulerUnit: RulerUnit;
448
+ /** What a click on the ruler adds. */
449
+ tabSelector: TabSelector;
450
+ /** The room beside the pages for balloons, CSS px. */
451
+ markupPaneWidth: number;
452
+ /** The editor background around the pages. */
453
+ background: Color;
454
+ }
455
+ /** Track changes and comments. */
456
+ export interface ReviewState {
457
+ /** Changes are tracked. */
458
+ tracking: boolean;
459
+ /** Document protection keeps tracking on. */
460
+ trackingLocked: boolean;
461
+ /** The markup view. */
462
+ markupView: MarkupView;
463
+ /** The revision count. */
464
+ revisions: number;
465
+ /** The comment count. */
466
+ comments: number;
467
+ /** The active comment thread. */
468
+ activeComment: CommentId | null;
469
+ }
470
+ /** How tracked changes are shown. */
471
+ export type MarkupView = 'all' | 'simple' | 'noMarkup' | 'original';
472
+ /** A line spacing. */
473
+ export type LineSpacing = {
474
+ rule: 'multiple';
475
+ lines: number;
476
+ } | {
477
+ rule: 'exact' | 'atLeast';
478
+ size: Points;
479
+ };
480
+ /** An underline style. */
481
+ export type UnderlineStyle = 'none' | 'single' | 'words' | 'double' | 'thick' | 'dotted' | 'dash' | 'dotDash' | 'wave';
482
+ /** A highlight colour. */
483
+ export type HighlightColor = 'yellow' | 'brightGreen' | 'turquoise' | 'pink' | 'blue' | 'red' | 'darkBlue' | 'teal' | 'green' | 'violet' | 'darkRed' | 'darkYellow' | 'gray50' | 'gray25' | 'black';
package/dist/state.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { FaceInfo } from '../fonts/library.js';
2
+ import type { Warning } from '../types.js';
3
+ import { type Backend, type FrameInfo, type Input, type Message, Method, type Transport } from './protocol.js';
4
+ /** The page's one direct transport, loading the engine module on first use. */
5
+ export declare function directTransport(): Promise<DirectTransport>;
6
+ /** The {@link Transport} that calls the engine module on this thread. */
7
+ export declare class DirectTransport implements Transport {
8
+ #private;
9
+ private constructor();
10
+ /** Loads the module and creates the page's engine. */
11
+ static load(): Promise<DirectTransport>;
12
+ createSession(options: object): Promise<number>;
13
+ closeSession(session: number): Promise<void>;
14
+ call(session: number, method: Method, request?: unknown): Promise<unknown>;
15
+ open(session: number, bytes: Uint8Array, signal?: AbortSignal): Promise<Warning[]>;
16
+ openPrepare(session: number, bytes: Uint8Array): Promise<number>;
17
+ openCommit(session: number, token: number): Promise<Warning[]>;
18
+ openDiscard(session: number, token: number): Promise<void>;
19
+ export(session: number, options: {
20
+ format: 'docx' | 'pdf';
21
+ }, signal?: AbortSignal): Promise<{
22
+ bytes: Uint8Array<ArrayBufferLike>;
23
+ revision: number;
24
+ warnings: Warning[];
25
+ }>;
26
+ addFont(bytes: Uint8Array): Promise<FaceInfo[]>;
27
+ input(session: number, input: Input): Promise<number>;
28
+ attachCanvas(session: number, canvas: HTMLCanvasElement): Promise<Backend>;
29
+ frame(session: number, width: number, height: number): Promise<FrameInfo | null>;
30
+ listen(session: number, listener: (message: Message) => void): () => void;
31
+ }