doc-codec 1.0.2 → 1.1.1

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 (112) hide show
  1. package/README.md +192 -50
  2. package/dist/color.cjs +166 -0
  3. package/dist/color.d.cts +20 -0
  4. package/dist/color.d.ts +20 -0
  5. package/dist/color.js +160 -0
  6. package/dist/detect.cjs +3 -0
  7. package/dist/detect.d.cts +3 -1
  8. package/dist/detect.d.ts +3 -1
  9. package/dist/detect.js +3 -1
  10. package/dist/fib/fib.cjs +9 -1
  11. package/dist/fib/fib.d.cts +1 -28
  12. package/dist/fib/fib.d.ts +1 -28
  13. package/dist/fib/fib.js +9 -1
  14. package/dist/fib/offsets.cjs +9 -1
  15. package/dist/fib/offsets.d.cts +8 -0
  16. package/dist/fib/offsets.d.ts +8 -0
  17. package/dist/fib/offsets.js +9 -1
  18. package/dist/fib/write.cjs +43 -0
  19. package/dist/fib/write.d.cts +21 -0
  20. package/dist/fib/write.d.ts +21 -0
  21. package/dist/fib/write.js +42 -0
  22. package/dist/fib-CtsLtF96.d.cts +37 -0
  23. package/dist/fib-CtsLtF96.d.ts +37 -0
  24. package/dist/index.cjs +31 -0
  25. package/dist/index.d.cts +18 -7
  26. package/dist/index.d.ts +18 -7
  27. package/dist/index.js +14 -3
  28. package/dist/list/numbering.cjs +206 -0
  29. package/dist/list/numbering.d.cts +2 -0
  30. package/dist/list/numbering.d.ts +2 -0
  31. package/dist/list/numbering.js +205 -0
  32. package/dist/metadata.cjs +14 -0
  33. package/dist/metadata.d.cts +6 -0
  34. package/dist/metadata.d.ts +6 -0
  35. package/dist/metadata.js +13 -0
  36. package/dist/numbering-Cir-uGdc.d.cts +22 -0
  37. package/dist/numbering-DF1z1PyG.d.ts +22 -0
  38. package/dist/pap-BkFo8dZO.d.ts +29 -0
  39. package/dist/pap-BmelEYEP.d.cts +29 -0
  40. package/dist/prop/chp-write.cjs +47 -0
  41. package/dist/prop/chp-write.d.cts +5 -0
  42. package/dist/prop/chp-write.d.ts +5 -0
  43. package/dist/prop/chp-write.js +46 -0
  44. package/dist/prop/chp.cjs +15 -107
  45. package/dist/prop/chp.d.cts +3 -2
  46. package/dist/prop/chp.d.ts +3 -2
  47. package/dist/prop/chp.js +15 -107
  48. package/dist/prop/fkp-write.cjs +139 -0
  49. package/dist/prop/fkp-write.d.cts +21 -0
  50. package/dist/prop/fkp-write.d.ts +21 -0
  51. package/dist/prop/fkp-write.js +135 -0
  52. package/dist/prop/pap-write.cjs +67 -0
  53. package/dist/prop/pap-write.d.cts +5 -0
  54. package/dist/prop/pap-write.d.ts +5 -0
  55. package/dist/prop/pap-write.js +66 -0
  56. package/dist/prop/pap.cjs +10 -0
  57. package/dist/prop/pap.d.cts +1 -24
  58. package/dist/prop/pap.d.ts +1 -24
  59. package/dist/prop/pap.js +11 -1
  60. package/dist/prop/sep-write.cjs +63 -0
  61. package/dist/prop/sep-write.d.cts +9 -0
  62. package/dist/prop/sep-write.d.ts +9 -0
  63. package/dist/prop/sep-write.js +60 -0
  64. package/dist/prop/sep.cjs +63 -0
  65. package/dist/prop/sep.d.cts +16 -0
  66. package/dist/prop/sep.d.ts +16 -0
  67. package/dist/prop/sep.js +61 -0
  68. package/dist/prop/sprm.d.cts +1 -25
  69. package/dist/prop/sprm.d.ts +1 -25
  70. package/dist/read.cjs +44 -18
  71. package/dist/read.d.cts +21 -4
  72. package/dist/read.d.ts +21 -4
  73. package/dist/read.js +46 -20
  74. package/dist/sprm-Djg5RNiq.d.cts +26 -0
  75. package/dist/sprm-Djg5RNiq.d.ts +26 -0
  76. package/dist/style/fonts.cjs +68 -0
  77. package/dist/style/fonts.d.cts +5 -0
  78. package/dist/style/fonts.d.ts +5 -0
  79. package/dist/style/fonts.js +66 -0
  80. package/dist/style/stsh.cjs +23 -0
  81. package/dist/style/stsh.d.cts +2 -1
  82. package/dist/style/stsh.d.ts +2 -1
  83. package/dist/style/stsh.js +23 -1
  84. package/dist/table/decoration.cjs +220 -0
  85. package/dist/table/decoration.d.cts +41 -0
  86. package/dist/table/decoration.d.ts +41 -0
  87. package/dist/table/decoration.js +205 -0
  88. package/dist/table/read.cjs +192 -0
  89. package/dist/table/read.d.cts +6 -0
  90. package/dist/table/read.d.ts +6 -0
  91. package/dist/table/read.js +191 -0
  92. package/dist/table/tap-write.cjs +125 -0
  93. package/dist/table/tap-write.d.cts +13 -0
  94. package/dist/table/tap-write.d.ts +13 -0
  95. package/dist/table/tap-write.js +124 -0
  96. package/dist/table/tap.cjs +217 -0
  97. package/dist/table/tap.d.cts +29 -0
  98. package/dist/table/tap.d.ts +29 -0
  99. package/dist/table/tap.js +213 -0
  100. package/dist/table/write.cjs +136 -0
  101. package/dist/table/write.d.cts +13 -0
  102. package/dist/table/write.d.ts +13 -0
  103. package/dist/table/write.js +135 -0
  104. package/dist/text/piece-table-write.cjs +24 -0
  105. package/dist/text/piece-table-write.d.cts +4 -0
  106. package/dist/text/piece-table-write.d.ts +4 -0
  107. package/dist/text/piece-table-write.js +23 -0
  108. package/dist/write.cjs +175 -0
  109. package/dist/write.d.cts +5 -0
  110. package/dist/write.d.ts +5 -0
  111. package/dist/write.js +174 -0
  112. package/package.json +3 -3
@@ -0,0 +1,21 @@
1
+ //#region src/fib/write.d.ts
2
+ interface FibWriteSpec {
3
+ readonly ccpText: number;
4
+ readonly cbMac: number;
5
+ readonly fcClx: number;
6
+ readonly lcbClx: number;
7
+ readonly fcPlcfSed: number;
8
+ readonly lcbPlcfSed: number;
9
+ readonly fcPlcfBteChpx: number;
10
+ readonly lcbPlcfBteChpx: number;
11
+ readonly fcPlcfBtePapx: number;
12
+ readonly lcbPlcfBtePapx: number;
13
+ readonly fcStshf: number;
14
+ readonly lcbStshf: number;
15
+ /** 0/0 when the document uses no font table (see write.ts). */
16
+ readonly fcSttbfFfn: number;
17
+ readonly lcbSttbfFfn: number;
18
+ }
19
+ declare function buildFib(spec: FibWriteSpec): Uint8Array<ArrayBuffer>;
20
+ //#endregion
21
+ export { FibWriteSpec, buildFib };
@@ -0,0 +1,21 @@
1
+ //#region src/fib/write.d.ts
2
+ interface FibWriteSpec {
3
+ readonly ccpText: number;
4
+ readonly cbMac: number;
5
+ readonly fcClx: number;
6
+ readonly lcbClx: number;
7
+ readonly fcPlcfSed: number;
8
+ readonly lcbPlcfSed: number;
9
+ readonly fcPlcfBteChpx: number;
10
+ readonly lcbPlcfBteChpx: number;
11
+ readonly fcPlcfBtePapx: number;
12
+ readonly lcbPlcfBtePapx: number;
13
+ readonly fcStshf: number;
14
+ readonly lcbStshf: number;
15
+ /** 0/0 when the document uses no font table (see write.ts). */
16
+ readonly fcSttbfFfn: number;
17
+ readonly lcbSttbfFfn: number;
18
+ }
19
+ declare function buildFib(spec: FibWriteSpec): Uint8Array<ArrayBuffer>;
20
+ //#endregion
21
+ export { FibWriteSpec, buildFib };
@@ -0,0 +1,42 @@
1
+ import { DocFormatError } from "../errors.js";
2
+ import { readUint16LE } from "../bytes.js";
3
+ import { FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_W_IDENT, LW_OFFSET } from "./offsets.js";
4
+ //#region src/fib/write.ts
5
+ /** [MS-DOC]'s own Fib page: nFib 0x00C1 mandates cbRgFcLcb 0x005D and cswNew 0. */
6
+ const NFIB_WORD_97 = 193;
7
+ const CB_RG_FC_LCB_WORD_97 = 93;
8
+ /** FibBase.nFibBack: "this value SHOULD be 0x00BF" for a document written by an application that does not need older-version compatibility beyond it -- carried verbatim from test-support/fib.ts, which cites the same field. */
9
+ const N_FIB_BACK = 191;
10
+ /** FibBase's own flags word at offset 10: fExtChar "MUST be 1" ([MS-DOC] 2.5.2), independent of fComplex/fWhichTblStm/fEncrypted/fObfuscated (see offsets.ts's own FIB_BASE_FLAG). */
11
+ const FLAG_F_EXT_CHAR = 4096;
12
+ function buildFib(spec) {
13
+ const bytes = /* @__PURE__ */ new Uint8Array(900);
14
+ const view = new DataView(bytes.buffer);
15
+ view.setUint16(0, FIB_W_IDENT, true);
16
+ view.setUint16(2, NFIB_WORD_97, true);
17
+ view.setUint16(10, FLAG_F_EXT_CHAR | FIB_BASE_FLAG.fWhichTblStm, true);
18
+ view.setUint16(12, N_FIB_BACK, true);
19
+ view.setUint16(32, 14, true);
20
+ view.setUint16(62, 22, true);
21
+ const lw = (offset, value) => {
22
+ view.setInt32(64 + offset, value, true);
23
+ };
24
+ lw(LW_OFFSET.cbMac, spec.cbMac);
25
+ lw(LW_OFFSET.ccpText, spec.ccpText);
26
+ view.setUint16(152, CB_RG_FC_LCB_WORD_97, true);
27
+ const pair = (index, fc, lcb) => {
28
+ const offset = 154 + index * 4;
29
+ view.setUint32(offset, fc, true);
30
+ view.setUint32(offset + 4, lcb, true);
31
+ };
32
+ pair(FC_LCB_VALUE_INDEX.fcStshf, spec.fcStshf, spec.lcbStshf);
33
+ pair(FC_LCB_VALUE_INDEX.fcPlcfBteChpx, spec.fcPlcfBteChpx, spec.lcbPlcfBteChpx);
34
+ pair(FC_LCB_VALUE_INDEX.fcPlcfBtePapx, spec.fcPlcfBtePapx, spec.lcbPlcfBtePapx);
35
+ pair(FC_LCB_VALUE_INDEX.fcSttbfFfn, spec.fcSttbfFfn, spec.lcbSttbfFfn);
36
+ pair(FC_LCB_VALUE_INDEX.fcClx, spec.fcClx, spec.lcbClx);
37
+ pair(FC_LCB_VALUE_INDEX.fcPlcfSed, spec.fcPlcfSed, spec.lcbPlcfSed);
38
+ if (readUint16LE(bytes, 0) !== 42476) throw new DocFormatError("buildFib produced a Fib whose own wIdent does not read back as 0xA5EC; this is an internal defect, not an input error");
39
+ return bytes;
40
+ }
41
+ //#endregion
42
+ export { buildFib };
@@ -0,0 +1,37 @@
1
+ //#region src/fib/fib.d.ts
2
+ interface Fib {
3
+ readonly nFib: number;
4
+ /** Set when the last save was an incremental ("fast") save. The piece table is what makes such a document readable at all, so this is informational rather than a refusal. */
5
+ readonly fComplex: boolean;
6
+ /** 1 selects the "1Table" stream, 0 the "0Table" stream, as the Table stream every fc offset below is relative to. */
7
+ readonly fWhichTblStm: 0 | 1;
8
+ readonly cbMac: number;
9
+ readonly ccpText: number;
10
+ readonly ccpFtn: number;
11
+ readonly ccpHdd: number;
12
+ readonly ccpAtn: number;
13
+ readonly ccpEdn: number;
14
+ readonly ccpTxbx: number;
15
+ readonly ccpHdrTxbx: number;
16
+ readonly fcStshf: number;
17
+ readonly lcbStshf: number;
18
+ readonly fcPlcfBteChpx: number;
19
+ readonly lcbPlcfBteChpx: number;
20
+ readonly fcPlcfBtePapx: number;
21
+ readonly lcbPlcfBtePapx: number;
22
+ readonly fcClx: number;
23
+ readonly lcbClx: number;
24
+ readonly fcPlcfSed: number;
25
+ readonly lcbPlcfSed: number;
26
+ readonly fcSttbfFfn: number;
27
+ readonly lcbSttbfFfn: number;
28
+ readonly fcPlfLst: number;
29
+ readonly lcbPlfLst: number;
30
+ readonly fcPlfLfo: number;
31
+ readonly lcbPlfLfo: number;
32
+ }
33
+ declare function parseFib(wordDocument: Uint8Array): Fib;
34
+ /** The name of the compound-file stream every `fc` offset in the Fib is relative to, selected by FibBase.fWhichTblStm. */
35
+ declare function tableStreamName(fib: Fib): "0Table" | "1Table";
36
+ //#endregion
37
+ export { parseFib as n, tableStreamName as r, Fib as t };
@@ -0,0 +1,37 @@
1
+ //#region src/fib/fib.d.ts
2
+ interface Fib {
3
+ readonly nFib: number;
4
+ /** Set when the last save was an incremental ("fast") save. The piece table is what makes such a document readable at all, so this is informational rather than a refusal. */
5
+ readonly fComplex: boolean;
6
+ /** 1 selects the "1Table" stream, 0 the "0Table" stream, as the Table stream every fc offset below is relative to. */
7
+ readonly fWhichTblStm: 0 | 1;
8
+ readonly cbMac: number;
9
+ readonly ccpText: number;
10
+ readonly ccpFtn: number;
11
+ readonly ccpHdd: number;
12
+ readonly ccpAtn: number;
13
+ readonly ccpEdn: number;
14
+ readonly ccpTxbx: number;
15
+ readonly ccpHdrTxbx: number;
16
+ readonly fcStshf: number;
17
+ readonly lcbStshf: number;
18
+ readonly fcPlcfBteChpx: number;
19
+ readonly lcbPlcfBteChpx: number;
20
+ readonly fcPlcfBtePapx: number;
21
+ readonly lcbPlcfBtePapx: number;
22
+ readonly fcClx: number;
23
+ readonly lcbClx: number;
24
+ readonly fcPlcfSed: number;
25
+ readonly lcbPlcfSed: number;
26
+ readonly fcSttbfFfn: number;
27
+ readonly lcbSttbfFfn: number;
28
+ readonly fcPlfLst: number;
29
+ readonly lcbPlfLst: number;
30
+ readonly fcPlfLfo: number;
31
+ readonly lcbPlfLfo: number;
32
+ }
33
+ declare function parseFib(wordDocument: Uint8Array): Fib;
34
+ /** The name of the compound-file stream every `fc` offset in the Fib is relative to, selected by FibBase.fWhichTblStm. */
35
+ declare function tableStreamName(fib: Fib): "0Table" | "1Table";
36
+ //#endregion
37
+ export { parseFib as n, tableStreamName as r, Fib as t };
package/dist/index.cjs CHANGED
@@ -5,15 +5,26 @@ const require_fib_offsets = require("./fib/offsets.cjs");
5
5
  const require_detect = require("./detect.cjs");
6
6
  const require_plc = require("./plc.cjs");
7
7
  const require_fib_fib = require("./fib/fib.cjs");
8
+ const require_fib_write = require("./fib/write.cjs");
9
+ const require_metadata = require("./metadata.cjs");
8
10
  const require_text_piece_table = require("./text/piece-table.cjs");
11
+ const require_text_piece_table_write = require("./text/piece-table-write.cjs");
9
12
  const require_text_characters = require("./text/characters.cjs");
10
13
  const require_text_special = require("./text/special.cjs");
11
14
  const require_prop_sprm = require("./prop/sprm.cjs");
12
15
  const require_prop_fkp = require("./prop/fkp.cjs");
16
+ const require_prop_fkp_write = require("./prop/fkp-write.cjs");
13
17
  const require_prop_chp = require("./prop/chp.cjs");
18
+ const require_prop_chp_write = require("./prop/chp-write.cjs");
14
19
  const require_prop_pap = require("./prop/pap.cjs");
20
+ const require_prop_pap_write = require("./prop/pap-write.cjs");
21
+ const require_prop_sep = require("./prop/sep.cjs");
22
+ const require_prop_sep_write = require("./prop/sep-write.cjs");
15
23
  const require_style_stsh = require("./style/stsh.cjs");
24
+ const require_style_fonts = require("./style/fonts.cjs");
25
+ const require_list_numbering = require("./list/numbering.cjs");
16
26
  const require_read = require("./read.cjs");
27
+ const require_write = require("./write.cjs");
17
28
  exports.ANNOTATION_REFERENCE = require_text_special.ANNOTATION_REFERENCE;
18
29
  exports.CELL_MARK = require_text_special.CELL_MARK;
19
30
  exports.COMPRESSED_CHARACTER_MAP = require_text_characters.COMPRESSED_CHARACTER_MAP;
@@ -47,22 +58,39 @@ exports.SECTION_MARK = require_text_special.SECTION_MARK;
47
58
  exports.SGC = require_prop_sprm.SGC;
48
59
  exports.STI_USER_DEFINED = require_style_stsh.STI_USER_DEFINED;
49
60
  exports.STK = require_style_stsh.STK;
61
+ exports.SUMMARY_INFORMATION_STREAM = require_detect.SUMMARY_INFORMATION_STREAM;
50
62
  exports.SYMBOL_ANCHOR = require_text_special.SYMBOL_ANCHOR;
51
63
  exports.WORD_DOCUMENT_STREAM = require_detect.WORD_DOCUMENT_STREAM;
52
64
  exports.applyCharacterSprms = require_prop_chp.applyCharacterSprms;
53
65
  exports.applyParagraphSprms = require_prop_pap.applyParagraphSprms;
66
+ exports.applySectionSprms = require_prop_sep.applySectionSprms;
67
+ exports.buildChpxPages = require_prop_fkp_write.buildChpxPages;
68
+ exports.buildEmptyStsh = require_style_stsh.buildEmptyStsh;
69
+ exports.buildFib = require_fib_write.buildFib;
70
+ exports.buildFontTable = require_style_fonts.buildFontTable;
71
+ exports.buildPapxPages = require_prop_fkp_write.buildPapxPages;
72
+ exports.buildPlcfSed = require_prop_sep_write.buildPlcfSed;
73
+ exports.buildPropertyBinTable = require_prop_fkp_write.buildPropertyBinTable;
74
+ exports.buildSepx = require_prop_sep_write.buildSepx;
75
+ exports.buildTextClx = require_text_piece_table_write.buildTextClx;
54
76
  exports.characterOffset = require_text_piece_table.characterOffset;
55
77
  exports.characterSize = require_text_piece_table.characterSize;
56
78
  exports.decodeSprm = require_prop_sprm.decodeSprm;
79
+ exports.encodeCharacterGrpprl = require_prop_chp_write.encodeCharacterGrpprl;
80
+ exports.encodeParagraphGrpprl = require_prop_pap_write.encodeParagraphGrpprl;
81
+ exports.encodeSectionGrpprl = require_prop_sep_write.encodeSectionGrpprl;
57
82
  exports.endsParagraph = require_text_special.endsParagraph;
58
83
  exports.findLargestAtMost = require_plc.findLargestAtMost;
84
+ exports.firstFcOfPage = require_prop_fkp_write.firstFcOfPage;
59
85
  exports.headingLevelFromIstd = require_style_stsh.headingLevelFromIstd;
60
86
  exports.isAnchorOnly = require_text_special.isAnchorOnly;
61
87
  exports.isDocBytes = require_detect.isDocBytes;
88
+ exports.layoutMetadataToSummaryInformation = require_metadata.layoutMetadataToSummaryInformation;
62
89
  exports.operandSize = require_prop_sprm.operandSize;
63
90
  exports.parseChpxFkp = require_prop_fkp.parseChpxFkp;
64
91
  exports.parseClx = require_text_piece_table.parseClx;
65
92
  exports.parseFib = require_fib_fib.parseFib;
93
+ exports.parseFontTable = require_style_fonts.parseFontTable;
66
94
  exports.parsePapxFkp = require_prop_fkp.parsePapxFkp;
67
95
  exports.parsePlc = require_plc.parsePlc;
68
96
  exports.parseStsh = require_style_stsh.parseStsh;
@@ -71,9 +99,12 @@ exports.readDocStreams = require_read.readDocStreams;
71
99
  exports.readGrpprl = require_prop_sprm.readGrpprl;
72
100
  exports.readInt16LE = require_bytes.readInt16LE;
73
101
  exports.readInt32LE = require_bytes.readInt32LE;
102
+ exports.readNumberingDefinitions = require_list_numbering.readNumberingDefinitions;
103
+ exports.readSectionProperties = require_prop_sep.readSectionProperties;
74
104
  exports.readTextRange = require_text_characters.readTextRange;
75
105
  exports.readUint16LE = require_bytes.readUint16LE;
76
106
  exports.readUint32LE = require_bytes.readUint32LE;
77
107
  exports.readUint8 = require_bytes.readUint8;
78
108
  exports.slice = require_bytes.slice;
79
109
  exports.tableStreamName = require_fib_fib.tableStreamName;
110
+ exports.writeDocContent = require_write.writeDocContent;
package/dist/index.d.cts CHANGED
@@ -1,16 +1,27 @@
1
1
  import { readInt16LE, readInt32LE, readUint16LE, readUint32LE, readUint8, slice } from "./bytes.cjs";
2
- import { WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.cjs";
2
+ import { SUMMARY_INFORMATION_STREAM, WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.cjs";
3
3
  import { DocFormatError, DocUnsupportedError } from "./errors.cjs";
4
- import { Fib, parseFib, tableStreamName } from "./fib/fib.cjs";
4
+ import { n as parseFib, r as tableStreamName, t as Fib } from "./fib-CtsLtF96.cjs";
5
5
  import { FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, LW_OFFSET } from "./fib/offsets.cjs";
6
+ import { FibWriteSpec, buildFib } from "./fib/write.cjs";
6
7
  import { Plc, findLargestAtMost, parsePlc } from "./plc.cjs";
8
+ import { layoutMetadataToSummaryInformation } from "./metadata.cjs";
7
9
  import { Piece, PieceTable, characterOffset, characterSize, parseClx } from "./text/piece-table.cjs";
10
+ import { buildTextClx } from "./text/piece-table-write.cjs";
8
11
  import { COMPRESSED_CHARACTER_MAP, TextRange, readTextRange } from "./text/characters.cjs";
9
12
  import { ANNOTATION_REFERENCE, CELL_MARK, DRAWN_OBJECT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FOOTNOTE_REFERENCE, INLINE_PICTURE, LINE_BREAK, PARAGRAPH_MARK, SECTION_MARK, SYMBOL_ANCHOR, endsParagraph, isAnchorOnly } from "./text/special.cjs";
10
- import { Prl, SGC, Sprm, decodeSprm, operandSize, readGrpprl } from "./prop/sprm.cjs";
13
+ import { a as operandSize, i as decodeSprm, n as SGC, o as readGrpprl, r as Sprm, t as Prl } from "./sprm-Djg5RNiq.cjs";
11
14
  import { ChpxFkp, FKP_PAGE_SIZE, PapxFkp, PapxLookup, PapxRecord, PropertyBinTable, parseChpxFkp, parsePapxFkp } from "./prop/fkp.cjs";
15
+ import { ChpxRunToWrite, PapxParagraphToWrite, buildChpxPages, buildPapxPages, buildPropertyBinTable, firstFcOfPage } from "./prop/fkp-write.cjs";
12
16
  import { CharacterProperties, applyCharacterSprms } from "./prop/chp.cjs";
13
- import { ParagraphProperties, applyParagraphSprms } from "./prop/pap.cjs";
14
- import { STI_USER_DEFINED, STK, Style, StyleSheet, headingLevelFromIstd, parseStsh } from "./style/stsh.cjs";
15
- import { DocStreams, readDocContent, readDocStreams } from "./read.cjs";
16
- export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, CharacterProperties, ChpxFkp, DRAWN_OBJECT, DocFormatError, DocStreams, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, Fib, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, PARAGRAPH_MARK, PapxFkp, PapxLookup, PapxRecord, ParagraphProperties, Piece, PieceTable, Plc, Prl, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SYMBOL_ANCHOR, Sprm, Style, StyleSheet, TextRange, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, characterOffset, characterSize, decodeSprm, endsParagraph, findLargestAtMost, headingLevelFromIstd, isAnchorOnly, isDocBytes, operandSize, parseChpxFkp, parseClx, parseFib, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName };
17
+ import { encodeCharacterGrpprl } from "./prop/chp-write.cjs";
18
+ import { n as applyParagraphSprms, t as ParagraphProperties } from "./pap-BmelEYEP.cjs";
19
+ import { encodeParagraphGrpprl } from "./prop/pap-write.cjs";
20
+ import { SectionProperties, applySectionSprms, readSectionProperties } from "./prop/sep.cjs";
21
+ import { buildPlcfSed, buildSepx, encodeSectionGrpprl } from "./prop/sep-write.cjs";
22
+ import { STI_USER_DEFINED, STK, Style, StyleSheet, buildEmptyStsh, headingLevelFromIstd, parseStsh } from "./style/stsh.cjs";
23
+ import { buildFontTable, parseFontTable } from "./style/fonts.cjs";
24
+ import { i as readNumberingDefinitions, n as NumberingDefinitions, r as NumberingLevel, t as NumberingDefinition } from "./numbering-Cir-uGdc.cjs";
25
+ import { DocContent, DocStreams, ParagraphEntry, readDocContent, readDocStreams } from "./read.cjs";
26
+ import { writeDocContent } from "./write.cjs";
27
+ export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, CharacterProperties, ChpxFkp, ChpxRunToWrite, DRAWN_OBJECT, DocContent, DocFormatError, DocStreams, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, Fib, FibWriteSpec, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, NumberingDefinition, NumberingDefinitions, NumberingLevel, PARAGRAPH_MARK, PapxFkp, PapxLookup, PapxParagraphToWrite, PapxRecord, ParagraphEntry, ParagraphProperties, Piece, PieceTable, Plc, Prl, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SUMMARY_INFORMATION_STREAM, SYMBOL_ANCHOR, SectionProperties, Sprm, Style, StyleSheet, TextRange, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, applySectionSprms, buildChpxPages, buildEmptyStsh, buildFib, buildFontTable, buildPapxPages, buildPlcfSed, buildPropertyBinTable, buildSepx, buildTextClx, characterOffset, characterSize, decodeSprm, encodeCharacterGrpprl, encodeParagraphGrpprl, encodeSectionGrpprl, endsParagraph, findLargestAtMost, firstFcOfPage, headingLevelFromIstd, isAnchorOnly, isDocBytes, layoutMetadataToSummaryInformation, operandSize, parseChpxFkp, parseClx, parseFib, parseFontTable, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readNumberingDefinitions, readSectionProperties, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName, writeDocContent };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,27 @@
1
1
  import { readInt16LE, readInt32LE, readUint16LE, readUint32LE, readUint8, slice } from "./bytes.js";
2
- import { WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.js";
2
+ import { SUMMARY_INFORMATION_STREAM, WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.js";
3
3
  import { DocFormatError, DocUnsupportedError } from "./errors.js";
4
- import { Fib, parseFib, tableStreamName } from "./fib/fib.js";
4
+ import { n as parseFib, r as tableStreamName, t as Fib } from "./fib-CtsLtF96.js";
5
5
  import { FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, LW_OFFSET } from "./fib/offsets.js";
6
+ import { FibWriteSpec, buildFib } from "./fib/write.js";
6
7
  import { Plc, findLargestAtMost, parsePlc } from "./plc.js";
8
+ import { layoutMetadataToSummaryInformation } from "./metadata.js";
7
9
  import { Piece, PieceTable, characterOffset, characterSize, parseClx } from "./text/piece-table.js";
10
+ import { buildTextClx } from "./text/piece-table-write.js";
8
11
  import { COMPRESSED_CHARACTER_MAP, TextRange, readTextRange } from "./text/characters.js";
9
12
  import { ANNOTATION_REFERENCE, CELL_MARK, DRAWN_OBJECT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FOOTNOTE_REFERENCE, INLINE_PICTURE, LINE_BREAK, PARAGRAPH_MARK, SECTION_MARK, SYMBOL_ANCHOR, endsParagraph, isAnchorOnly } from "./text/special.js";
10
- import { Prl, SGC, Sprm, decodeSprm, operandSize, readGrpprl } from "./prop/sprm.js";
13
+ import { a as operandSize, i as decodeSprm, n as SGC, o as readGrpprl, r as Sprm, t as Prl } from "./sprm-Djg5RNiq.js";
11
14
  import { ChpxFkp, FKP_PAGE_SIZE, PapxFkp, PapxLookup, PapxRecord, PropertyBinTable, parseChpxFkp, parsePapxFkp } from "./prop/fkp.js";
15
+ import { ChpxRunToWrite, PapxParagraphToWrite, buildChpxPages, buildPapxPages, buildPropertyBinTable, firstFcOfPage } from "./prop/fkp-write.js";
12
16
  import { CharacterProperties, applyCharacterSprms } from "./prop/chp.js";
13
- import { ParagraphProperties, applyParagraphSprms } from "./prop/pap.js";
14
- import { STI_USER_DEFINED, STK, Style, StyleSheet, headingLevelFromIstd, parseStsh } from "./style/stsh.js";
15
- import { DocStreams, readDocContent, readDocStreams } from "./read.js";
16
- export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, CharacterProperties, ChpxFkp, DRAWN_OBJECT, DocFormatError, DocStreams, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, Fib, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, PARAGRAPH_MARK, PapxFkp, PapxLookup, PapxRecord, ParagraphProperties, Piece, PieceTable, Plc, Prl, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SYMBOL_ANCHOR, Sprm, Style, StyleSheet, TextRange, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, characterOffset, characterSize, decodeSprm, endsParagraph, findLargestAtMost, headingLevelFromIstd, isAnchorOnly, isDocBytes, operandSize, parseChpxFkp, parseClx, parseFib, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName };
17
+ import { encodeCharacterGrpprl } from "./prop/chp-write.js";
18
+ import { n as applyParagraphSprms, t as ParagraphProperties } from "./pap-BkFo8dZO.js";
19
+ import { encodeParagraphGrpprl } from "./prop/pap-write.js";
20
+ import { SectionProperties, applySectionSprms, readSectionProperties } from "./prop/sep.js";
21
+ import { buildPlcfSed, buildSepx, encodeSectionGrpprl } from "./prop/sep-write.js";
22
+ import { STI_USER_DEFINED, STK, Style, StyleSheet, buildEmptyStsh, headingLevelFromIstd, parseStsh } from "./style/stsh.js";
23
+ import { buildFontTable, parseFontTable } from "./style/fonts.js";
24
+ import { i as readNumberingDefinitions, n as NumberingDefinitions, r as NumberingLevel, t as NumberingDefinition } from "./numbering-DF1z1PyG.js";
25
+ import { DocContent, DocStreams, ParagraphEntry, readDocContent, readDocStreams } from "./read.js";
26
+ import { writeDocContent } from "./write.js";
27
+ export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, CharacterProperties, ChpxFkp, ChpxRunToWrite, DRAWN_OBJECT, DocContent, DocFormatError, DocStreams, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, Fib, FibWriteSpec, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, NumberingDefinition, NumberingDefinitions, NumberingLevel, PARAGRAPH_MARK, PapxFkp, PapxLookup, PapxParagraphToWrite, PapxRecord, ParagraphEntry, ParagraphProperties, Piece, PieceTable, Plc, Prl, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SUMMARY_INFORMATION_STREAM, SYMBOL_ANCHOR, SectionProperties, Sprm, Style, StyleSheet, TextRange, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, applySectionSprms, buildChpxPages, buildEmptyStsh, buildFib, buildFontTable, buildPapxPages, buildPlcfSed, buildPropertyBinTable, buildSepx, buildTextClx, characterOffset, characterSize, decodeSprm, encodeCharacterGrpprl, encodeParagraphGrpprl, encodeSectionGrpprl, endsParagraph, findLargestAtMost, firstFcOfPage, headingLevelFromIstd, isAnchorOnly, isDocBytes, layoutMetadataToSummaryInformation, operandSize, parseChpxFkp, parseClx, parseFib, parseFontTable, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readNumberingDefinitions, readSectionProperties, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName, writeDocContent };
package/dist/index.js CHANGED
@@ -1,16 +1,27 @@
1
1
  import { DocFormatError, DocUnsupportedError } from "./errors.js";
2
2
  import { readInt16LE, readInt32LE, readUint16LE, readUint32LE, readUint8, slice } from "./bytes.js";
3
3
  import { FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, LW_OFFSET } from "./fib/offsets.js";
4
- import { WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.js";
4
+ import { SUMMARY_INFORMATION_STREAM, WORD_DOCUMENT_STREAM, isDocBytes } from "./detect.js";
5
5
  import { findLargestAtMost, parsePlc } from "./plc.js";
6
6
  import { parseFib, tableStreamName } from "./fib/fib.js";
7
+ import { buildFib } from "./fib/write.js";
8
+ import { layoutMetadataToSummaryInformation } from "./metadata.js";
7
9
  import { characterOffset, characterSize, parseClx } from "./text/piece-table.js";
10
+ import { buildTextClx } from "./text/piece-table-write.js";
8
11
  import { COMPRESSED_CHARACTER_MAP, readTextRange } from "./text/characters.js";
9
12
  import { ANNOTATION_REFERENCE, CELL_MARK, DRAWN_OBJECT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FOOTNOTE_REFERENCE, INLINE_PICTURE, LINE_BREAK, PARAGRAPH_MARK, SECTION_MARK, SYMBOL_ANCHOR, endsParagraph, isAnchorOnly } from "./text/special.js";
10
13
  import { SGC, decodeSprm, operandSize, readGrpprl } from "./prop/sprm.js";
11
14
  import { FKP_PAGE_SIZE, PropertyBinTable, parseChpxFkp, parsePapxFkp } from "./prop/fkp.js";
15
+ import { buildChpxPages, buildPapxPages, buildPropertyBinTable, firstFcOfPage } from "./prop/fkp-write.js";
12
16
  import { applyCharacterSprms } from "./prop/chp.js";
17
+ import { encodeCharacterGrpprl } from "./prop/chp-write.js";
13
18
  import { applyParagraphSprms } from "./prop/pap.js";
14
- import { STI_USER_DEFINED, STK, headingLevelFromIstd, parseStsh } from "./style/stsh.js";
19
+ import { encodeParagraphGrpprl } from "./prop/pap-write.js";
20
+ import { applySectionSprms, readSectionProperties } from "./prop/sep.js";
21
+ import { buildPlcfSed, buildSepx, encodeSectionGrpprl } from "./prop/sep-write.js";
22
+ import { STI_USER_DEFINED, STK, buildEmptyStsh, headingLevelFromIstd, parseStsh } from "./style/stsh.js";
23
+ import { buildFontTable, parseFontTable } from "./style/fonts.js";
24
+ import { readNumberingDefinitions } from "./list/numbering.js";
15
25
  import { readDocContent, readDocStreams } from "./read.js";
16
- export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, DRAWN_OBJECT, DocFormatError, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, PARAGRAPH_MARK, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SYMBOL_ANCHOR, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, characterOffset, characterSize, decodeSprm, endsParagraph, findLargestAtMost, headingLevelFromIstd, isAnchorOnly, isDocBytes, operandSize, parseChpxFkp, parseClx, parseFib, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName };
26
+ import { writeDocContent } from "./write.js";
27
+ export { ANNOTATION_REFERENCE, CELL_MARK, COMPRESSED_CHARACTER_MAP, DRAWN_OBJECT, DocFormatError, DocUnsupportedError, FC_LCB_VALUE_INDEX, FIB_BASE_FLAG, FIB_BASE_SIZE, FIB_CB_RG_FC_LCB_OFFSET, FIB_CSLW_OFFSET, FIB_CSLW_REQUIRED, FIB_CSW_REQUIRED, FIB_FC_LCB_BLOB_OFFSET, FIB_RG_LW_OFFSET, FIB_RG_LW_SIZE, FIB_RG_W_OFFSET, FIB_RG_W_SIZE, FIB_W_IDENT, FIELD_BEGIN, FIELD_END, FIELD_SEPARATOR, FKP_PAGE_SIZE, FOOTNOTE_REFERENCE, INLINE_PICTURE, LINE_BREAK, LW_OFFSET, PARAGRAPH_MARK, PropertyBinTable, SECTION_MARK, SGC, STI_USER_DEFINED, STK, SUMMARY_INFORMATION_STREAM, SYMBOL_ANCHOR, WORD_DOCUMENT_STREAM, applyCharacterSprms, applyParagraphSprms, applySectionSprms, buildChpxPages, buildEmptyStsh, buildFib, buildFontTable, buildPapxPages, buildPlcfSed, buildPropertyBinTable, buildSepx, buildTextClx, characterOffset, characterSize, decodeSprm, encodeCharacterGrpprl, encodeParagraphGrpprl, encodeSectionGrpprl, endsParagraph, findLargestAtMost, firstFcOfPage, headingLevelFromIstd, isAnchorOnly, isDocBytes, layoutMetadataToSummaryInformation, operandSize, parseChpxFkp, parseClx, parseFib, parseFontTable, parsePapxFkp, parsePlc, parseStsh, readDocContent, readDocStreams, readGrpprl, readInt16LE, readInt32LE, readNumberingDefinitions, readSectionProperties, readTextRange, readUint16LE, readUint32LE, readUint8, slice, tableStreamName, writeDocContent };
@@ -0,0 +1,206 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_errors = require("../errors.cjs");
3
+ const require_bytes = require("../bytes.cjs");
4
+ //#region src/list/numbering.ts
5
+ const LSTF_SIZE = 28;
6
+ const LVLF_SIZE = 28;
7
+ const LFO_SIZE = 16;
8
+ /** LSTF's own flags byte ([MS-DOC] 2.9.191), bit 0: "this LSTF represents a simple (one-level) list that has one corresponding LVL. Otherwise... a multi-level list that has nine corresponding LVLs." */
9
+ const LSTF_FLAG_SIMPLE_LIST = 1;
10
+ /** MSONFC ([MS-OSHARED] 2.2.1.3), mapped to its own documented ST_NumberFormat equivalent -- the identical vocabulary ooxml.js's NumberingLevel.format carries verbatim from word/numbering.xml's own w:numFmt/@w:val. Every member through msonfcUCRus (0x3B) is a real numbered/lettered/ideograph format; 0x17 (msonfcBullet) is handled separately below since PlfLfo also treats it as the "no number sequence, but has bullets" case LVLF's own field text calls out by name. */
11
+ const NUMBER_FORMAT_BY_NFC = {
12
+ 0: "decimal",
13
+ 1: "upperRoman",
14
+ 2: "lowerRoman",
15
+ 3: "upperLetter",
16
+ 4: "lowerLetter",
17
+ 5: "ordinal",
18
+ 6: "cardinalText",
19
+ 7: "ordinalText",
20
+ 8: "hex",
21
+ 9: "chicago",
22
+ 10: "ideographDigital",
23
+ 11: "japaneseCounting",
24
+ 12: "Aiueo",
25
+ 13: "Iroha",
26
+ 14: "decimalFullWidth",
27
+ 15: "decimalHalfWidth",
28
+ 16: "japaneseLegal",
29
+ 17: "japaneseDigitalTenThousand",
30
+ 18: "decimalEnclosedCircle",
31
+ 19: "decimalFullWidth2",
32
+ 20: "aiueoFullWidth",
33
+ 21: "irohaFullWidth",
34
+ 22: "decimalZero",
35
+ 23: "bullet",
36
+ 24: "ganada",
37
+ 25: "chosung",
38
+ 26: "decimalEnclosedFullstop",
39
+ 27: "decimalEnclosedParen",
40
+ 28: "decimalEnclosedCircleChinese",
41
+ 29: "ideographEnclosedCircle",
42
+ 30: "ideographTraditional",
43
+ 31: "ideographZodiac",
44
+ 32: "ideographZodiacTraditional",
45
+ 33: "taiwaneseCounting",
46
+ 34: "ideographLegalTraditional",
47
+ 35: "taiwaneseCountingThousand",
48
+ 36: "taiwaneseDigital",
49
+ 37: "chineseCounting",
50
+ 38: "chineseLegalSimplified",
51
+ 39: "chineseCountingThousand",
52
+ 40: "decimal",
53
+ 41: "koreanDigital",
54
+ 42: "koreanCounting",
55
+ 43: "koreanLegal",
56
+ 44: "koreanDigital2",
57
+ 45: "hebrew1",
58
+ 46: "arabicAlpha",
59
+ 47: "hebrew2",
60
+ 48: "arabicAbjad",
61
+ 49: "hindiVowels",
62
+ 50: "hindiConsonants",
63
+ 51: "hindiNumbers",
64
+ 52: "hindiCounting",
65
+ 53: "thaiLetters",
66
+ 54: "thaiNumbers",
67
+ 55: "thaiCounting",
68
+ 56: "vietnameseCounting",
69
+ 57: "numberInDash",
70
+ 58: "russianLower",
71
+ 59: "russianUpper"
72
+ };
73
+ /** MSONFC's own "Specifies that the sequence will not display any numbering" sentinel -- not itself an ST_NumberFormat value, so this reader's own spelling for it ("none") is a deliberate literal rather than a value MSONFC's table states. */
74
+ const NFC_NONE = 255;
75
+ function numberFormatFor(nfc) {
76
+ if (nfc === NFC_NONE) return "none";
77
+ const format = NUMBER_FORMAT_BY_NFC[nfc];
78
+ if (format === void 0) throw new require_errors.DocFormatError(`LVLF.nfc is 0x${nfc.toString(16).padStart(2, "0")}, not a recognised MSONFC value ([MS-OSHARED] 2.2.1.3)`);
79
+ return format;
80
+ }
81
+ /** LSTF ([MS-DOC] 2.9.191): lsid(4) + tplc(4, ignored -- UI-only) + rgistdPara(18, ignored -- this reader has no per-level style cascade to link into) + a flags byte (only fSimpleList, bit 0, acted on) + grfhic(1, ignored -- HTML-export-only incompatibility flags). Fixed 28 bytes. */
82
+ function readLstf(bytes, offset) {
83
+ return {
84
+ lsid: require_bytes.readInt32LE(bytes, offset),
85
+ fSimpleList: (require_bytes.readUint8(bytes, offset + 26) & LSTF_FLAG_SIMPLE_LIST) !== 0
86
+ };
87
+ }
88
+ /** Xst ([MS-DOC] 2.9.343): cch(2 bytes) then that many raw 16-bit code units, prefixed-length and not null-terminated. Decoded as a plain UTF-16 string -- readLevelText below re-inspects specific character positions afterward for placeholders, which round-trips exactly through String.fromCharCode/charCodeAt since every placeholder value (0-8) sits well within one UTF-16 code unit and never needs a surrogate pair. Returns the decoded text and the byte length consumed, since the caller must advance past it to reach grpprlPapx/grpprlChpx or the next LVL. */
89
+ function readXst(bytes, offset) {
90
+ const cch = require_bytes.readUint16LE(bytes, offset);
91
+ let text = "";
92
+ for (let index = 0; index < cch; index += 1) text += String.fromCharCode(require_bytes.readUint16LE(bytes, offset + 2 + index * 2));
93
+ return {
94
+ text,
95
+ byteLength: 2 + cch * 2
96
+ };
97
+ }
98
+ /** rgbxchNums ([MS-DOC] 2.9.148's own LVLF field): nine 8-bit one-based character offsets into the LVL's own xst.rgtchar, zero-terminated (a 0 entry, or the end of the fixed 9-byte array, ends the list). Each offset it names is a POSITION in the string, not a value -- readLevelText is what turns a position into the placeholder it names. */
99
+ function readRgbxchNums(bytes, offset) {
100
+ const positions = [];
101
+ for (let index = 0; index < 9; index += 1) {
102
+ const value = require_bytes.readUint8(bytes, offset + index);
103
+ if (value === 0) break;
104
+ positions.push(value);
105
+ }
106
+ return positions;
107
+ }
108
+ /** Turns an Xst's own decoded text plus its rgbxchNums positions into the '%1.'-style placeholder text NumberingLevel.text states -- the mirror of readXst/readRgbxchNums together. [MS-DOC]'s own Xst field text: "Each placeholder is an unsigned 2-byte integer that specifies the zero-based level that the placeholder is for" -- so the character AT a named position is not a literal code point at all, but a raw level index (0-8) String.fromCharCode/charCodeAt round-trips losslessly; every other position is decoded as ordinary text. A one-based placeholder ('%1' for level 0) matches ooxml.js's own w:lvlText convention, so a consumer already resolving '%1.'/'%2)' style docx templates resolves this reader's templates identically. */
109
+ function readLevelText(xstText, placeholderPositions) {
110
+ const placeholders = new Set(placeholderPositions);
111
+ let result = "";
112
+ for (let index = 0; index < xstText.length; index += 1) {
113
+ const oneBasedPosition = index + 1;
114
+ if (placeholders.has(oneBasedPosition)) {
115
+ const levelIndex = xstText.charCodeAt(index);
116
+ result += `%${levelIndex + 1}`;
117
+ } else result += xstText.charAt(index);
118
+ }
119
+ return result;
120
+ }
121
+ /** LVL ([MS-DOC] 2.9.196): a 28-byte LVLF, then grpprlPapx (cbGrpprlPapx bytes, skipped -- see this module's own top comment), grpprlChpx (cbGrpprlChpx bytes, skipped), then the level's own Xst. Every LVL is variable-length, so the caller must use byteLength to advance to the next one in the array -- there is no outer length field to skip by instead. */
122
+ function readLvl(bytes, offset) {
123
+ if (offset + LVLF_SIZE > bytes.length) throw new require_errors.DocFormatError(`PlfLst's own appended LVL array runs past the end of its ${bytes.length}-byte buffer at offset ${offset}, ${LVLF_SIZE} bytes short of one LVLF`);
124
+ const iStartAt = require_bytes.readInt32LE(bytes, offset);
125
+ const nfc = require_bytes.readUint8(bytes, offset + 4);
126
+ const fNoRestart = (require_bytes.readUint8(bytes, offset + 5) & 2) !== 0;
127
+ const rgbxchNums = readRgbxchNums(bytes, offset + 6);
128
+ const cbGrpprlChpx = require_bytes.readUint8(bytes, offset + 24);
129
+ const cbGrpprlPapx = require_bytes.readUint8(bytes, offset + 25);
130
+ const ilvlRestartLim = require_bytes.readUint8(bytes, offset + 26);
131
+ const { text: xstText, byteLength: xstByteLength } = readXst(bytes, offset + LVLF_SIZE + cbGrpprlPapx + cbGrpprlChpx);
132
+ const level = {
133
+ format: numberFormatFor(nfc),
134
+ text: readLevelText(xstText, rgbxchNums),
135
+ startAt: iStartAt
136
+ };
137
+ return {
138
+ level: fNoRestart ? {
139
+ ...level,
140
+ restart: ilvlRestartLim
141
+ } : level,
142
+ byteLength: LVLF_SIZE + cbGrpprlPapx + cbGrpprlChpx + xstByteLength
143
+ };
144
+ }
145
+ /** PlfLst ([MS-DOC] 2.9.226): cLst(2 bytes, signed) then that many 28-byte LSTF entries -- followed IMMEDIATELY by the appended LVL array FibRgFcLcb97's own fcPlfLst field describes, which lcbPlfLst does not account for and which this function therefore reads past the declared PlfLst length to reach. */
146
+ function parsePlfLst(table, fc, lcb) {
147
+ const plfLst = require_bytes.slice(table, fc, lcb, "PlfLst");
148
+ const cLst = require_bytes.readInt16LE(plfLst, 0);
149
+ if (cLst < 0) throw new require_errors.DocFormatError(`PlfLst.cLst is ${cLst}, a negative LSTF count [MS-DOC] 2.9.226 never permits`);
150
+ const lstfs = [];
151
+ for (let index = 0; index < cLst; index += 1) lstfs.push(readLstf(plfLst, 2 + index * LSTF_SIZE));
152
+ let cursor = fc + lcb;
153
+ const levelsByLstf = [];
154
+ for (const lstf of lstfs) {
155
+ const count = lstf.fSimpleList ? 1 : 9;
156
+ const levels = [];
157
+ for (let index = 0; index < count; index += 1) {
158
+ const { level, byteLength } = readLvl(table, cursor);
159
+ levels.push(level);
160
+ cursor += byteLength;
161
+ }
162
+ levelsByLstf.push(levels);
163
+ }
164
+ return {
165
+ lstfs,
166
+ levelsByLstf
167
+ };
168
+ }
169
+ /** PlfLfo ([MS-DOC] 2.9.225): lfoMac(4 bytes) then that many 16-byte LFO entries (rgLfo), then rgLfoData -- this reader's own scope stops at rgLfo, since resolving ilfo to a list needs only each LFO's own lsid (rgLfoData carries LFOLVL overrides this reader deliberately does not apply; see this module's own top comment). rgLfo sits entirely before rgLfoData in the stream, so not reading rgLfoData at all is a real, not merely partial, saving -- no cursor needs to walk past it. */
170
+ function parseLfoLsids(table, fc, lcb) {
171
+ const plfLfo = require_bytes.slice(table, fc, lcb, "PlfLfo");
172
+ const lfoMac = require_bytes.readInt32LE(plfLfo, 0);
173
+ if (lfoMac < 0) throw new require_errors.DocFormatError(`PlfLfo.lfoMac is ${lfoMac}, a negative LFO count [MS-DOC] 2.9.225 never permits`);
174
+ const lsids = [];
175
+ for (let index = 0; index < lfoMac; index += 1) {
176
+ const offset = 4 + index * LFO_SIZE;
177
+ if (offset + LFO_SIZE > plfLfo.length) throw new require_errors.DocFormatError(`PlfLfo declares lfoMac=${lfoMac} LFO entries, but its own ${plfLfo.length}-byte buffer has room for only ${Math.floor((plfLfo.length - 4) / LFO_SIZE)}`);
178
+ lsids.push(require_bytes.readInt32LE(plfLfo, offset));
179
+ }
180
+ return lsids;
181
+ }
182
+ /** Resolves PlfLst and PlfLfo into NumberingDefinitions, keyed by the one-based ilfo every listId already is (prop/pap.ts's own Math.abs(ilfo)) -- absent entirely when the file carries neither (fcPlfLst/fcPlfLfo both 0, a document with no lists at all, the common case this reader must not fail on). */
183
+ function readNumberingDefinitions(table, fib) {
184
+ if (fib.lcbPlfLst === 0 || fib.lcbPlfLfo === 0) return {};
185
+ const { lstfs, levelsByLstf } = parsePlfLst(table, fib.fcPlfLst, fib.lcbPlfLst);
186
+ const lsids = parseLfoLsids(table, fib.fcPlfLfo, fib.lcbPlfLfo);
187
+ const levelsByLsid = /* @__PURE__ */ new Map();
188
+ lstfs.forEach((lstf, index) => {
189
+ const levels = levelsByLstf[index];
190
+ if (levels !== void 0) levelsByLsid.set(lstf.lsid, levels);
191
+ });
192
+ const definitions = {};
193
+ lsids.forEach((lsid, index) => {
194
+ const levels = levelsByLsid.get(lsid);
195
+ if (levels === void 0) return;
196
+ const ilfo = index + 1;
197
+ const byLevel = {};
198
+ levels.forEach((level, levelIndex) => {
199
+ byLevel[String(levelIndex)] = level;
200
+ });
201
+ definitions[String(ilfo)] = { levels: byLevel };
202
+ });
203
+ return definitions;
204
+ }
205
+ //#endregion
206
+ exports.readNumberingDefinitions = readNumberingDefinitions;
@@ -0,0 +1,2 @@
1
+ import { i as readNumberingDefinitions, n as NumberingDefinitions, r as NumberingLevel, t as NumberingDefinition } from "../numbering-Cir-uGdc.cjs";
2
+ export { NumberingDefinition, NumberingDefinitions, NumberingLevel, readNumberingDefinitions };
@@ -0,0 +1,2 @@
1
+ import { i as readNumberingDefinitions, n as NumberingDefinitions, r as NumberingLevel, t as NumberingDefinition } from "../numbering-DF1z1PyG.js";
2
+ export { NumberingDefinition, NumberingDefinitions, NumberingLevel, readNumberingDefinitions };