rtf-codec 0.0.0 → 1.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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -0
  3. package/dist/base64.cjs +66 -0
  4. package/dist/base64.d.cts +7 -0
  5. package/dist/base64.d.ts +7 -0
  6. package/dist/base64.js +62 -0
  7. package/dist/bytes.cjs +25 -0
  8. package/dist/bytes.d.cts +6 -0
  9. package/dist/bytes.d.ts +6 -0
  10. package/dist/bytes.js +22 -0
  11. package/dist/cell-format.cjs +142 -0
  12. package/dist/cell-format.d.cts +25 -0
  13. package/dist/cell-format.d.ts +25 -0
  14. package/dist/cell-format.js +137 -0
  15. package/dist/codec.cjs +29 -0
  16. package/dist/codec.d.cts +2344 -0
  17. package/dist/codec.d.ts +2344 -0
  18. package/dist/codec.js +26 -0
  19. package/dist/codepage.cjs +98 -0
  20. package/dist/codepage.d.cts +10 -0
  21. package/dist/codepage.d.ts +10 -0
  22. package/dist/codepage.js +92 -0
  23. package/dist/constructs.cjs +131 -0
  24. package/dist/constructs.d.cts +31 -0
  25. package/dist/constructs.d.ts +31 -0
  26. package/dist/constructs.js +121 -0
  27. package/dist/diagnostics-BgG_KAiN.d.cts +52 -0
  28. package/dist/diagnostics-BgG_KAiN.d.ts +52 -0
  29. package/dist/diagnostics.cjs +76 -0
  30. package/dist/diagnostics.d.cts +2 -0
  31. package/dist/diagnostics.d.ts +2 -0
  32. package/dist/diagnostics.js +68 -0
  33. package/dist/group.cjs +40 -0
  34. package/dist/group.d.cts +11 -0
  35. package/dist/group.d.ts +11 -0
  36. package/dist/group.js +38 -0
  37. package/dist/header.cjs +433 -0
  38. package/dist/header.d.cts +44 -0
  39. package/dist/header.d.ts +44 -0
  40. package/dist/header.js +431 -0
  41. package/dist/index.cjs +28 -0
  42. package/dist/index.d.cts +8 -0
  43. package/dist/index.d.ts +8 -0
  44. package/dist/index.js +8 -0
  45. package/dist/list-id.cjs +30 -0
  46. package/dist/list-id.d.cts +16 -0
  47. package/dist/list-id.d.ts +16 -0
  48. package/dist/list-id.js +27 -0
  49. package/dist/options.cjs +7 -0
  50. package/dist/options.d.cts +18 -0
  51. package/dist/options.d.ts +18 -0
  52. package/dist/options.js +5 -0
  53. package/dist/read.cjs +1211 -0
  54. package/dist/read.d.cts +16 -0
  55. package/dist/read.d.ts +16 -0
  56. package/dist/read.js +1209 -0
  57. package/dist/tokenize.cjs +155 -0
  58. package/dist/tokenize.d.cts +25 -0
  59. package/dist/tokenize.d.ts +25 -0
  60. package/dist/tokenize.js +154 -0
  61. package/dist/units.cjs +43 -0
  62. package/dist/units.d.cts +17 -0
  63. package/dist/units.d.ts +17 -0
  64. package/dist/units.js +29 -0
  65. package/dist/write.cjs +532 -0
  66. package/dist/write.d.cts +7 -0
  67. package/dist/write.d.ts +7 -0
  68. package/dist/write.js +530 -0
  69. package/package.json +95 -2
@@ -0,0 +1,433 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_bytes = require("./bytes.cjs");
3
+ const require_units = require("./units.cjs");
4
+ const require_codepage = require("./codepage.cjs");
5
+ const require_group = require("./group.cjs");
6
+ //#region src/header.ts
7
+ const RGB_MAX = 255;
8
+ const FONT_FAMILIES = /* @__PURE__ */ new Set([
9
+ "fnil",
10
+ "froman",
11
+ "fswiss",
12
+ "fmodern",
13
+ "fscript",
14
+ "fdecor",
15
+ "ftech",
16
+ "fbidi"
17
+ ]);
18
+ const HEADING_STYLE_NAME = /^heading[ -]?([1-9])$/i;
19
+ const DEFAULT_LIST_LEVEL = {
20
+ numberFormat: 0,
21
+ startAt: 1
22
+ };
23
+ const HEADER_DESTINATIONS = /* @__PURE__ */ new Set([
24
+ "fonttbl",
25
+ "colortbl",
26
+ "stylesheet",
27
+ "listtable",
28
+ "listoverridetable",
29
+ "info",
30
+ "filetbl",
31
+ "revtbl",
32
+ "rsidtbl",
33
+ "generator",
34
+ "pgptbl",
35
+ "themedata",
36
+ "colorschememapping",
37
+ "latentstyles",
38
+ "listtextoverride",
39
+ "xmlnstbl",
40
+ "wgrffmtfilter",
41
+ "datastore",
42
+ "protusertbl",
43
+ "mmathPr",
44
+ "stylerestrictions",
45
+ "userprops"
46
+ ]);
47
+ function collectPlainText(tokens, start, end, codepage, sink) {
48
+ const pending = [];
49
+ let out = "";
50
+ const flush = () => {
51
+ if (pending.length === 0) return;
52
+ out += require_codepage.decodeCodepageBytes(Uint8Array.from(pending), codepage, sink);
53
+ pending.length = 0;
54
+ };
55
+ for (let index = start; index < end; index += 1) {
56
+ const token = tokens[index];
57
+ if (token === void 0) break;
58
+ if (token.kind === "groupStart") {
59
+ flush();
60
+ index = require_group.matchingGroupEnd(tokens, index);
61
+ continue;
62
+ }
63
+ if (token.kind === "text") {
64
+ require_bytes.appendBytes(pending, token.bytes);
65
+ continue;
66
+ }
67
+ if (token.kind === "hex") {
68
+ pending.push(token.byte);
69
+ continue;
70
+ }
71
+ if (token.kind === "controlWord" && token.name === "u") {
72
+ flush();
73
+ const code = token.param;
74
+ if (code !== void 0) out += String.fromCodePoint(code < 0 ? code + 65536 : code);
75
+ }
76
+ }
77
+ flush();
78
+ return out.replace(/;\s*$/, "").trim();
79
+ }
80
+ function parseFontTable(tokens, contentStart, end, documentCodepage, fonts, sink) {
81
+ let index = contentStart;
82
+ let sawBracedEntry = false;
83
+ while (index < end) {
84
+ if (tokens[index]?.kind !== "groupStart") {
85
+ index += 1;
86
+ continue;
87
+ }
88
+ sawBracedEntry = true;
89
+ const entryEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
90
+ readFontInfo(tokens, index + 1, entryEnd, documentCodepage, fonts, sink);
91
+ index = entryEnd + 1;
92
+ }
93
+ if (!sawBracedEntry) readFontInfo(tokens, contentStart, end, documentCodepage, fonts, sink);
94
+ }
95
+ function readFontInfo(tokens, start, end, documentCodepage, fonts, sink) {
96
+ let number;
97
+ let family;
98
+ let charsetPage;
99
+ let explicitPage;
100
+ let nameStart = start;
101
+ for (let index = start; index < end; index += 1) {
102
+ const token = tokens[index];
103
+ if (token === void 0) break;
104
+ if (token.kind !== "controlWord") continue;
105
+ if (token.name === "f" && token.param !== void 0) {
106
+ number = token.param;
107
+ nameStart = index + 1;
108
+ continue;
109
+ }
110
+ if (FONT_FAMILIES.has(token.name)) {
111
+ family = token.name.slice(1);
112
+ nameStart = index + 1;
113
+ continue;
114
+ }
115
+ if (token.name === "fcharset" && token.param !== void 0) {
116
+ charsetPage = require_codepage.codepageForFontCharset(token.param);
117
+ nameStart = index + 1;
118
+ continue;
119
+ }
120
+ if (token.name === "cpg" && token.param !== void 0) {
121
+ explicitPage = token.param;
122
+ nameStart = index + 1;
123
+ continue;
124
+ }
125
+ if (token.name === "fprq" || token.name === "fbias") nameStart = index + 1;
126
+ }
127
+ if (number === void 0) return;
128
+ const name = collectPlainText(tokens, nameStart, end, explicitPage ?? charsetPage ?? documentCodepage, sink);
129
+ fonts.set(number, {
130
+ name,
131
+ family,
132
+ codepage: explicitPage ?? charsetPage
133
+ });
134
+ }
135
+ function parseColorTable(tokens, contentStart, end, colors) {
136
+ let red;
137
+ let green;
138
+ let blue;
139
+ const finishEntry = () => {
140
+ colors.push(red === void 0 && green === void 0 && blue === void 0 ? void 0 : {
141
+ r: (red ?? 0) / RGB_MAX,
142
+ g: (green ?? 0) / RGB_MAX,
143
+ b: (blue ?? 0) / RGB_MAX
144
+ });
145
+ red = void 0;
146
+ green = void 0;
147
+ blue = void 0;
148
+ };
149
+ for (let index = contentStart; index < end; index += 1) {
150
+ const token = tokens[index];
151
+ if (token === void 0) break;
152
+ if (token.kind === "controlWord") {
153
+ if (token.name === "red") red = token.param ?? 0;
154
+ else if (token.name === "green") green = token.param ?? 0;
155
+ else if (token.name === "blue") blue = token.param ?? 0;
156
+ continue;
157
+ }
158
+ if (token.kind === "text") {
159
+ for (const byte of token.bytes) if (byte === 59) finishEntry();
160
+ }
161
+ }
162
+ }
163
+ function parseStyleSheet(tokens, contentStart, end, documentCodepage, styles, sink) {
164
+ for (let index = contentStart; index < end; index += 1) {
165
+ if (tokens[index]?.kind !== "groupStart") continue;
166
+ const entryEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
167
+ readStyle(tokens, index, entryEnd, documentCodepage, styles, sink);
168
+ index = entryEnd;
169
+ }
170
+ }
171
+ function readStyle(tokens, start, end, documentCodepage, styles, sink) {
172
+ const head = require_group.groupHead(tokens, start);
173
+ if (head.ignorable) return;
174
+ let handle = 0;
175
+ let outlineLevel;
176
+ let nameStart = head.contentStart;
177
+ for (let index = start + 1; index < end; index += 1) {
178
+ const token = tokens[index];
179
+ if (token === void 0) break;
180
+ if (token.kind === "groupStart") {
181
+ index = Math.min(require_group.matchingGroupEnd(tokens, index), end);
182
+ nameStart = index + 1;
183
+ continue;
184
+ }
185
+ if (token.kind !== "controlWord") continue;
186
+ if (token.name === "s" && token.param !== void 0) handle = token.param;
187
+ else if (token.name === "outlinelevel" && token.param !== void 0) outlineLevel = token.param;
188
+ nameStart = index + 1;
189
+ }
190
+ const name = collectPlainText(tokens, nameStart, end, documentCodepage, sink);
191
+ const fromName = HEADING_STYLE_NAME.exec(name)?.[1];
192
+ const headingLevel = outlineLevel === void 0 ? fromName === void 0 ? void 0 : Number(fromName) : outlineLevel + 1;
193
+ styles.set(handle, {
194
+ name,
195
+ headingLevel
196
+ });
197
+ }
198
+ function parseListTable(tokens, contentStart, end, listsById) {
199
+ for (let index = contentStart; index < end; index += 1) {
200
+ if (tokens[index]?.kind !== "groupStart") continue;
201
+ const entryEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
202
+ if (require_group.groupHead(tokens, index).destination === "list") readListDefinition(tokens, index, entryEnd, listsById);
203
+ index = entryEnd;
204
+ }
205
+ }
206
+ function readListDefinition(tokens, start, end, listsById) {
207
+ const levels = [];
208
+ let listId;
209
+ for (let index = start + 1; index < end; index += 1) {
210
+ const token = tokens[index];
211
+ if (token === void 0) break;
212
+ if (token.kind === "groupStart") {
213
+ const inner = Math.min(require_group.matchingGroupEnd(tokens, index), end);
214
+ if (require_group.groupHead(tokens, index).destination === "listlevel") levels.push(readListLevel(tokens, index, inner));
215
+ index = inner;
216
+ continue;
217
+ }
218
+ if (token.kind === "controlWord" && token.name === "listid" && token.param !== void 0) listId = token.param;
219
+ }
220
+ if (listId === void 0) return;
221
+ listsById.set(listId, { levels });
222
+ return listId;
223
+ }
224
+ function readListLevel(tokens, start, end) {
225
+ let numberFormat = 0;
226
+ let startAt = 1;
227
+ for (let index = start + 1; index < end; index += 1) {
228
+ const token = tokens[index];
229
+ if (token === void 0) break;
230
+ if (token.kind === "groupStart") {
231
+ index = Math.min(require_group.matchingGroupEnd(tokens, index), end);
232
+ continue;
233
+ }
234
+ if (token.kind !== "controlWord") continue;
235
+ if (token.name === "levelnfc" && token.param !== void 0) numberFormat = token.param;
236
+ else if (token.name === "levelstartat" && token.param !== void 0) startAt = token.param;
237
+ }
238
+ return {
239
+ numberFormat,
240
+ startAt
241
+ };
242
+ }
243
+ function parseListOverrideTable(tokens, contentStart, end, overrides) {
244
+ for (let index = contentStart; index < end; index += 1) {
245
+ if (tokens[index]?.kind !== "groupStart") continue;
246
+ const entryEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
247
+ let listId;
248
+ let overrideIndex;
249
+ const levelOverrides = [];
250
+ for (let inner = index + 1; inner < entryEnd; inner += 1) {
251
+ const child = tokens[inner];
252
+ if (child?.kind === "groupStart") {
253
+ const childEnd = Math.min(require_group.matchingGroupEnd(tokens, inner), entryEnd);
254
+ if (require_group.groupHead(tokens, inner).destination === "lfolevel") levelOverrides.push(readLevelOverride(tokens, inner, childEnd));
255
+ inner = childEnd;
256
+ continue;
257
+ }
258
+ if (child?.kind !== "controlWord" || child.param === void 0) continue;
259
+ if (child.name === "listid") listId = child.param;
260
+ else if (child.name === "ls") overrideIndex = child.param;
261
+ }
262
+ if (listId !== void 0 && overrideIndex !== void 0) overrides.set(overrideIndex, {
263
+ listId,
264
+ levelOverrides
265
+ });
266
+ index = entryEnd;
267
+ }
268
+ }
269
+ function readLevelOverride(tokens, start, end) {
270
+ let level;
271
+ let startAt;
272
+ for (let index = start + 1; index < end; index += 1) {
273
+ const token = tokens[index];
274
+ if (token === void 0) break;
275
+ if (token.kind === "groupStart") {
276
+ const inner = Math.min(require_group.matchingGroupEnd(tokens, index), end);
277
+ if (require_group.groupHead(tokens, index).destination === "listlevel") level = readListLevel(tokens, index, inner);
278
+ index = inner;
279
+ continue;
280
+ }
281
+ if (token.kind === "controlWord" && token.name === "levelstartat" && token.param !== void 0) startAt = token.param;
282
+ }
283
+ return {
284
+ ...level === void 0 ? {} : { level },
285
+ ...startAt === void 0 ? {} : { startAt }
286
+ };
287
+ }
288
+ function applyListOverride(list, levelOverrides) {
289
+ if (levelOverrides.length === 0) return list;
290
+ const levels = [...list.levels];
291
+ for (const [index, override] of levelOverrides.entries()) {
292
+ const base = override.level ?? levels[index] ?? DEFAULT_LIST_LEVEL;
293
+ levels[index] = override.level === void 0 && override.startAt !== void 0 ? {
294
+ ...base,
295
+ startAt: override.startAt
296
+ } : base;
297
+ }
298
+ return { levels };
299
+ }
300
+ function parseRevisionTable(tokens, contentStart, end, codepage, authors, sink) {
301
+ for (let index = contentStart; index < end; index += 1) {
302
+ if (tokens[index]?.kind !== "groupStart") continue;
303
+ const entryEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
304
+ const value = collectPlainText(tokens, index + 1, entryEnd, codepage, sink);
305
+ authors.push(value.split("\0")[0]?.trim() ?? "");
306
+ index = entryEnd;
307
+ }
308
+ }
309
+ function parseInfoGroup(tokens, contentStart, end, codepage, sink) {
310
+ const metadata = {};
311
+ for (let index = contentStart; index < end; index += 1) {
312
+ if (tokens[index]?.kind !== "groupStart") continue;
313
+ const fieldEnd = Math.min(require_group.matchingGroupEnd(tokens, index), end);
314
+ const head = require_group.groupHead(tokens, index);
315
+ const value = collectPlainText(tokens, head.contentStart, fieldEnd, codepage, sink);
316
+ if (value.length > 0) {
317
+ if (head.destination === "title") metadata.title = value;
318
+ else if (head.destination === "author") metadata.author = value;
319
+ else if (head.destination === "subject") metadata.subject = value;
320
+ else if (head.destination === "keywords") metadata.keywords = value.split(/[;,]\s*/).filter((k) => k.length > 0);
321
+ else if (head.destination === "operator") metadata.creator = value;
322
+ }
323
+ index = fieldEnd;
324
+ }
325
+ return metadata;
326
+ }
327
+ function readRtfHeader(tokens, sink) {
328
+ const fonts = /* @__PURE__ */ new Map();
329
+ const colors = [];
330
+ const styles = /* @__PURE__ */ new Map();
331
+ const listsById = /* @__PURE__ */ new Map();
332
+ const overrides = /* @__PURE__ */ new Map();
333
+ const revisionAuthors = [];
334
+ const page = {
335
+ paperWidthTwips: require_units.DEFAULT_PAPER_WIDTH_TWIPS,
336
+ paperHeightTwips: require_units.DEFAULT_PAPER_HEIGHT_TWIPS,
337
+ marginLeftTwips: require_units.DEFAULT_MARGIN_LEFT_TWIPS,
338
+ marginRightTwips: require_units.DEFAULT_MARGIN_RIGHT_TWIPS,
339
+ marginTopTwips: require_units.DEFAULT_MARGIN_TOP_TWIPS,
340
+ marginBottomTwips: require_units.DEFAULT_MARGIN_BOTTOM_TWIPS
341
+ };
342
+ let metadata = {};
343
+ let codepage = require_codepage.DEFAULT_CODEPAGE;
344
+ let defaultFontIndex;
345
+ let bodyStartIndex = 0;
346
+ const fileGroupEnd = require_group.matchingGroupEnd(tokens, 0);
347
+ for (let index = 0; index < fileGroupEnd; index += 1) {
348
+ const token = tokens[index];
349
+ if (token?.kind === "groupStart" && index > 0) {
350
+ index = Math.min(require_group.matchingGroupEnd(tokens, index), fileGroupEnd);
351
+ continue;
352
+ }
353
+ if (token?.kind !== "controlWord") continue;
354
+ const charsetPage = require_codepage.DOCUMENT_CHARSET_CODEPAGES.get(token.name);
355
+ if (charsetPage !== void 0) {
356
+ codepage = charsetPage;
357
+ continue;
358
+ }
359
+ if (token.param === void 0) continue;
360
+ switch (token.name) {
361
+ case "ansicpg":
362
+ codepage = token.param;
363
+ break;
364
+ case "deff":
365
+ defaultFontIndex = token.param;
366
+ break;
367
+ case "paperw":
368
+ page.paperWidthTwips = token.param;
369
+ break;
370
+ case "paperh":
371
+ page.paperHeightTwips = token.param;
372
+ break;
373
+ case "margl":
374
+ page.marginLeftTwips = token.param;
375
+ break;
376
+ case "margr":
377
+ page.marginRightTwips = token.param;
378
+ break;
379
+ case "margt":
380
+ page.marginTopTwips = token.param;
381
+ break;
382
+ case "margb": page.marginBottomTwips = token.param;
383
+ }
384
+ }
385
+ for (let index = 1; index < fileGroupEnd; index += 1) {
386
+ if (tokens[index]?.kind !== "groupStart") continue;
387
+ const groupEnd = Math.min(require_group.matchingGroupEnd(tokens, index), fileGroupEnd);
388
+ const head = require_group.groupHead(tokens, index);
389
+ switch (head.destination) {
390
+ case "fonttbl":
391
+ parseFontTable(tokens, head.contentStart, groupEnd, codepage, fonts, sink);
392
+ break;
393
+ case "colortbl":
394
+ parseColorTable(tokens, head.contentStart, groupEnd, colors);
395
+ break;
396
+ case "stylesheet":
397
+ parseStyleSheet(tokens, head.contentStart, groupEnd, codepage, styles, sink);
398
+ break;
399
+ case "listtable":
400
+ parseListTable(tokens, head.contentStart, groupEnd, listsById);
401
+ break;
402
+ case "listoverridetable":
403
+ parseListOverrideTable(tokens, head.contentStart, groupEnd, overrides);
404
+ break;
405
+ case "revtbl":
406
+ parseRevisionTable(tokens, head.contentStart, groupEnd, codepage, revisionAuthors, sink);
407
+ break;
408
+ case "info": metadata = parseInfoGroup(tokens, head.contentStart, groupEnd, codepage, sink);
409
+ }
410
+ if (head.destination !== void 0 && HEADER_DESTINATIONS.has(head.destination)) bodyStartIndex = Math.max(bodyStartIndex, groupEnd + 1);
411
+ index = groupEnd;
412
+ }
413
+ const lists = /* @__PURE__ */ new Map();
414
+ for (const [overrideIndex, override] of overrides) {
415
+ const list = listsById.get(override.listId);
416
+ if (list !== void 0) lists.set(overrideIndex, applyListOverride(list, override.levelOverrides));
417
+ }
418
+ return {
419
+ codepage,
420
+ defaultFontIndex,
421
+ fonts,
422
+ colors,
423
+ styles,
424
+ lists,
425
+ revisionAuthors,
426
+ page,
427
+ metadata,
428
+ bodyStartIndex
429
+ };
430
+ }
431
+ //#endregion
432
+ exports.HEADER_DESTINATIONS = HEADER_DESTINATIONS;
433
+ exports.readRtfHeader = readRtfHeader;
@@ -0,0 +1,44 @@
1
+ import { a as RtfDiagnosticSink } from "./diagnostics-BgG_KAiN.cjs";
2
+ import { RtfToken } from "./tokenize.cjs";
3
+ import { Color, LayoutMetadata } from "document-schema.js";
4
+ //#region src/header.d.ts
5
+ interface RtfFontEntry {
6
+ readonly name: string;
7
+ readonly family: string | undefined;
8
+ readonly codepage: number | undefined;
9
+ }
10
+ interface RtfStyleEntry {
11
+ readonly name: string;
12
+ readonly headingLevel: number | undefined;
13
+ }
14
+ interface RtfListLevel {
15
+ readonly numberFormat: number;
16
+ readonly startAt: number;
17
+ }
18
+ interface RtfListEntry {
19
+ readonly levels: readonly RtfListLevel[];
20
+ }
21
+ interface RtfPageGeometry {
22
+ readonly paperWidthTwips: number;
23
+ readonly paperHeightTwips: number;
24
+ readonly marginLeftTwips: number;
25
+ readonly marginRightTwips: number;
26
+ readonly marginTopTwips: number;
27
+ readonly marginBottomTwips: number;
28
+ }
29
+ interface RtfHeader {
30
+ readonly codepage: number;
31
+ readonly defaultFontIndex: number | undefined;
32
+ readonly fonts: ReadonlyMap<number, RtfFontEntry>;
33
+ readonly colors: readonly (Color | undefined)[];
34
+ readonly styles: ReadonlyMap<number, RtfStyleEntry>;
35
+ readonly lists: ReadonlyMap<number, RtfListEntry>;
36
+ readonly revisionAuthors: readonly string[];
37
+ readonly page: RtfPageGeometry;
38
+ readonly metadata: LayoutMetadata;
39
+ readonly bodyStartIndex: number;
40
+ }
41
+ declare const HEADER_DESTINATIONS: ReadonlySet<string>;
42
+ declare function readRtfHeader(tokens: readonly RtfToken[], sink: RtfDiagnosticSink): RtfHeader;
43
+ //#endregion
44
+ export { HEADER_DESTINATIONS, RtfFontEntry, RtfHeader, RtfListEntry, RtfListLevel, RtfPageGeometry, RtfStyleEntry, readRtfHeader };
@@ -0,0 +1,44 @@
1
+ import { a as RtfDiagnosticSink } from "./diagnostics-BgG_KAiN.js";
2
+ import { RtfToken } from "./tokenize.js";
3
+ import { Color, LayoutMetadata } from "document-schema.js";
4
+ //#region src/header.d.ts
5
+ interface RtfFontEntry {
6
+ readonly name: string;
7
+ readonly family: string | undefined;
8
+ readonly codepage: number | undefined;
9
+ }
10
+ interface RtfStyleEntry {
11
+ readonly name: string;
12
+ readonly headingLevel: number | undefined;
13
+ }
14
+ interface RtfListLevel {
15
+ readonly numberFormat: number;
16
+ readonly startAt: number;
17
+ }
18
+ interface RtfListEntry {
19
+ readonly levels: readonly RtfListLevel[];
20
+ }
21
+ interface RtfPageGeometry {
22
+ readonly paperWidthTwips: number;
23
+ readonly paperHeightTwips: number;
24
+ readonly marginLeftTwips: number;
25
+ readonly marginRightTwips: number;
26
+ readonly marginTopTwips: number;
27
+ readonly marginBottomTwips: number;
28
+ }
29
+ interface RtfHeader {
30
+ readonly codepage: number;
31
+ readonly defaultFontIndex: number | undefined;
32
+ readonly fonts: ReadonlyMap<number, RtfFontEntry>;
33
+ readonly colors: readonly (Color | undefined)[];
34
+ readonly styles: ReadonlyMap<number, RtfStyleEntry>;
35
+ readonly lists: ReadonlyMap<number, RtfListEntry>;
36
+ readonly revisionAuthors: readonly string[];
37
+ readonly page: RtfPageGeometry;
38
+ readonly metadata: LayoutMetadata;
39
+ readonly bodyStartIndex: number;
40
+ }
41
+ declare const HEADER_DESTINATIONS: ReadonlySet<string>;
42
+ declare function readRtfHeader(tokens: readonly RtfToken[], sink: RtfDiagnosticSink): RtfHeader;
43
+ //#endregion
44
+ export { HEADER_DESTINATIONS, RtfFontEntry, RtfHeader, RtfListEntry, RtfListLevel, RtfPageGeometry, RtfStyleEntry, readRtfHeader };