@office-kit/xlsx 0.8.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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +319 -0
  3. package/THIRD_PARTY_NOTICES.md +56 -0
  4. package/dist/cell/cell.d.ts +234 -0
  5. package/dist/cell/index.d.ts +4 -0
  6. package/dist/cell/rich-text.d.ts +37 -0
  7. package/dist/cell-D9CaNKnU.mjs +320 -0
  8. package/dist/cell-D9CaNKnU.mjs.map +1 -0
  9. package/dist/cell-style-BEDjMX1y.mjs +1579 -0
  10. package/dist/cell-style-BEDjMX1y.mjs.map +1 -0
  11. package/dist/cell.mjs +2 -0
  12. package/dist/chart/chart-xml.d.ts +16 -0
  13. package/dist/chart/chart.d.ts +735 -0
  14. package/dist/chart/cx/chartex-xml.d.ts +6 -0
  15. package/dist/chart/cx/chartex.d.ts +279 -0
  16. package/dist/chart/index.d.ts +6 -0
  17. package/dist/chart/user-shapes-xml.d.ts +4 -0
  18. package/dist/chart/user-shapes.d.ts +61 -0
  19. package/dist/chart.mjs +232 -0
  20. package/dist/chart.mjs.map +1 -0
  21. package/dist/chartsheet/chartsheet-xml.d.ts +17 -0
  22. package/dist/chartsheet/chartsheet.d.ts +121 -0
  23. package/dist/chartsheet/index.d.ts +2 -0
  24. package/dist/chartsheet-C3-tqkPy.mjs +23 -0
  25. package/dist/chartsheet-C3-tqkPy.mjs.map +1 -0
  26. package/dist/chartsheet.mjs +2 -0
  27. package/dist/colors-ovWAwnZI.mjs +67 -0
  28. package/dist/colors-ovWAwnZI.mjs.map +1 -0
  29. package/dist/compat/numbers.d.ts +14 -0
  30. package/dist/coordinate-96Ecci4d.mjs +276 -0
  31. package/dist/coordinate-96Ecci4d.mjs.map +1 -0
  32. package/dist/datetime-B2ySVlXt.mjs +71 -0
  33. package/dist/datetime-B2ySVlXt.mjs.map +1 -0
  34. package/dist/defined-names-CviWmtQg.mjs +89 -0
  35. package/dist/defined-names-CviWmtQg.mjs.map +1 -0
  36. package/dist/differential-D4dg-qtZ.mjs +37 -0
  37. package/dist/differential-D4dg-qtZ.mjs.map +1 -0
  38. package/dist/drawing/anchor.d.ts +63 -0
  39. package/dist/drawing/dml/colors.d.ts +109 -0
  40. package/dist/drawing/dml/dml-xml.d.ts +35 -0
  41. package/dist/drawing/dml/effect.d.ts +92 -0
  42. package/dist/drawing/dml/fill.d.ts +115 -0
  43. package/dist/drawing/dml/geometry.d.ts +113 -0
  44. package/dist/drawing/dml/line.d.ts +41 -0
  45. package/dist/drawing/dml/shape-properties.d.ts +33 -0
  46. package/dist/drawing/dml/text.d.ts +218 -0
  47. package/dist/drawing/drawing-xml.d.ts +5 -0
  48. package/dist/drawing/drawing.d.ts +117 -0
  49. package/dist/drawing/image.d.ts +40 -0
  50. package/dist/drawing/index.d.ts +14 -0
  51. package/dist/drawing-BxzLuryn.mjs +415 -0
  52. package/dist/drawing-BxzLuryn.mjs.map +1 -0
  53. package/dist/drawing.mjs +119 -0
  54. package/dist/drawing.mjs.map +1 -0
  55. package/dist/escape-DFTE7ZJc.mjs +51 -0
  56. package/dist/escape-DFTE7ZJc.mjs.map +1 -0
  57. package/dist/exceptions-D-CFwxgm.mjs +37 -0
  58. package/dist/exceptions-D-CFwxgm.mjs.map +1 -0
  59. package/dist/formula/tokenizer.d.ts +61 -0
  60. package/dist/formula/translate.d.ts +67 -0
  61. package/dist/inference-B3ES3KEJ.mjs +42 -0
  62. package/dist/inference-B3ES3KEJ.mjs.map +1 -0
  63. package/dist/io/browser.d.ts +41 -0
  64. package/dist/io/index.d.ts +7 -0
  65. package/dist/io/load.d.ts +46 -0
  66. package/dist/io/node-fs.d.ts +62 -0
  67. package/dist/io/node-save.d.ts +3 -0
  68. package/dist/io/node.d.ts +17 -0
  69. package/dist/io/save.d.ts +14 -0
  70. package/dist/io/sink.d.ts +54 -0
  71. package/dist/io/source.d.ts +14 -0
  72. package/dist/io.mjs +212 -0
  73. package/dist/io.mjs.map +1 -0
  74. package/dist/load-D5cbhoGx.mjs +1069 -0
  75. package/dist/load-D5cbhoGx.mjs.map +1 -0
  76. package/dist/manifest-Dps1-OpP.mjs +801 -0
  77. package/dist/manifest-Dps1-OpP.mjs.map +1 -0
  78. package/dist/node.d.ts +3 -0
  79. package/dist/node.mjs +308 -0
  80. package/dist/node.mjs.map +1 -0
  81. package/dist/packaging/core.d.ts +45 -0
  82. package/dist/packaging/custom.d.ts +62 -0
  83. package/dist/packaging/extended.d.ts +45 -0
  84. package/dist/packaging/index.d.ts +10 -0
  85. package/dist/packaging/manifest.d.ts +24 -0
  86. package/dist/packaging/relationships.d.ts +30 -0
  87. package/dist/packaging.mjs +2 -0
  88. package/dist/parser-DuLejQy1.mjs +156 -0
  89. package/dist/parser-DuLejQy1.mjs.map +1 -0
  90. package/dist/reader-D1fNW9k1.mjs +534 -0
  91. package/dist/reader-D1fNW9k1.mjs.map +1 -0
  92. package/dist/save-RohQtgEZ.mjs +745 -0
  93. package/dist/save-RohQtgEZ.mjs.map +1 -0
  94. package/dist/schema/core.d.ts +133 -0
  95. package/dist/schema/index.d.ts +3 -0
  96. package/dist/schema/serialize.d.ts +6 -0
  97. package/dist/schema.mjs +2 -0
  98. package/dist/serialize-55EnT30e.mjs +254 -0
  99. package/dist/serialize-55EnT30e.mjs.map +1 -0
  100. package/dist/serializer-BwbgHYJV.mjs +116 -0
  101. package/dist/serializer-BwbgHYJV.mjs.map +1 -0
  102. package/dist/streaming/index.d.ts +2 -0
  103. package/dist/streaming/read-only.d.ts +38 -0
  104. package/dist/streaming/write-only.d.ts +47 -0
  105. package/dist/streaming.mjs +612 -0
  106. package/dist/streaming.mjs.map +1 -0
  107. package/dist/styles/alignment.d.ts +33 -0
  108. package/dist/styles/alignment.schema.d.ts +3 -0
  109. package/dist/styles/borders.d.ts +40 -0
  110. package/dist/styles/borders.schema.d.ts +4 -0
  111. package/dist/styles/cell-style.d.ts +270 -0
  112. package/dist/styles/colors.d.ts +128 -0
  113. package/dist/styles/colors.schema.d.ts +3 -0
  114. package/dist/styles/differential.d.ts +41 -0
  115. package/dist/styles/fills.d.ts +54 -0
  116. package/dist/styles/fills.schema.d.ts +6 -0
  117. package/dist/styles/fonts.d.ts +44 -0
  118. package/dist/styles/fonts.schema.d.ts +3 -0
  119. package/dist/styles/index.d.ts +21 -0
  120. package/dist/styles/named-styles.d.ts +52 -0
  121. package/dist/styles/numbers.d.ts +39 -0
  122. package/dist/styles/numbers.schema.d.ts +3 -0
  123. package/dist/styles/protection.d.ts +9 -0
  124. package/dist/styles/protection.schema.d.ts +3 -0
  125. package/dist/styles/stylesheet-reader.d.ts +7 -0
  126. package/dist/styles/stylesheet-writer.d.ts +3 -0
  127. package/dist/styles/stylesheet.d.ts +95 -0
  128. package/dist/styles.mjs +4 -0
  129. package/dist/stylesheet-writer-C2eRmn22.mjs +8624 -0
  130. package/dist/stylesheet-writer-C2eRmn22.mjs.map +1 -0
  131. package/dist/table-DkX6UniA.mjs +113 -0
  132. package/dist/table-DkX6UniA.mjs.map +1 -0
  133. package/dist/tree-Bbs1C8Rc.mjs +192 -0
  134. package/dist/tree-Bbs1C8Rc.mjs.map +1 -0
  135. package/dist/units-rOMQqXh2.mjs +41 -0
  136. package/dist/units-rOMQqXh2.mjs.map +1 -0
  137. package/dist/user-shapes-DfmCGKB0.mjs +252 -0
  138. package/dist/user-shapes-DfmCGKB0.mjs.map +1 -0
  139. package/dist/utf8-D91g1XTG.mjs +143 -0
  140. package/dist/utf8-D91g1XTG.mjs.map +1 -0
  141. package/dist/utils/coordinate.d.ts +103 -0
  142. package/dist/utils/css.d.ts +18 -0
  143. package/dist/utils/datetime.d.ts +38 -0
  144. package/dist/utils/escape.d.ts +34 -0
  145. package/dist/utils/exceptions.d.ts +34 -0
  146. package/dist/utils/index.d.ts +11 -0
  147. package/dist/utils/inference.d.ts +24 -0
  148. package/dist/utils/stable-stringify.d.ts +7 -0
  149. package/dist/utils/units.d.ts +14 -0
  150. package/dist/utils/utf8.d.ts +1 -0
  151. package/dist/utils.mjs +39 -0
  152. package/dist/utils.mjs.map +1 -0
  153. package/dist/workbook/calc-properties.d.ts +47 -0
  154. package/dist/workbook/defined-names.d.ts +121 -0
  155. package/dist/workbook/file-recovery.d.ts +11 -0
  156. package/dist/workbook/file-sharing.d.ts +14 -0
  157. package/dist/workbook/file-version.d.ts +13 -0
  158. package/dist/workbook/function-groups.d.ts +10 -0
  159. package/dist/workbook/index.d.ts +24 -0
  160. package/dist/workbook/protection.d.ts +35 -0
  161. package/dist/workbook/shared-strings.d.ts +57 -0
  162. package/dist/workbook/smart-tags.d.ts +13 -0
  163. package/dist/workbook/views.d.ts +89 -0
  164. package/dist/workbook/workbook-properties.d.ts +57 -0
  165. package/dist/workbook/workbook.d.ts +643 -0
  166. package/dist/workbook-HGYNRBlV.mjs +636 -0
  167. package/dist/workbook-HGYNRBlV.mjs.map +1 -0
  168. package/dist/workbook.mjs +58 -0
  169. package/dist/workbook.mjs.map +1 -0
  170. package/dist/worksheet/auto-filter.d.ts +34 -0
  171. package/dist/worksheet/cell-range.d.ts +121 -0
  172. package/dist/worksheet/comments-xml.d.ts +24 -0
  173. package/dist/worksheet/comments.d.ts +13 -0
  174. package/dist/worksheet/conditional-formatting.d.ts +150 -0
  175. package/dist/worksheet/custom-sheet-views.d.ts +43 -0
  176. package/dist/worksheet/data-consolidate.d.ts +29 -0
  177. package/dist/worksheet/data-validations.d.ts +72 -0
  178. package/dist/worksheet/dimensions.d.ts +40 -0
  179. package/dist/worksheet/errors.d.ts +40 -0
  180. package/dist/worksheet/hyperlinks.d.ts +42 -0
  181. package/dist/worksheet/index.d.ts +46 -0
  182. package/dist/worksheet/ole-objects.d.ts +37 -0
  183. package/dist/worksheet/page-setup.d.ts +173 -0
  184. package/dist/worksheet/phonetic.d.ts +11 -0
  185. package/dist/worksheet/properties.d.ts +34 -0
  186. package/dist/worksheet/protected-ranges.d.ts +19 -0
  187. package/dist/worksheet/protection.d.ts +44 -0
  188. package/dist/worksheet/reader.d.ts +38 -0
  189. package/dist/worksheet/scenarios.d.ts +36 -0
  190. package/dist/worksheet/smart-tags.d.ts +23 -0
  191. package/dist/worksheet/sort-state.d.ts +28 -0
  192. package/dist/worksheet/table-xml.d.ts +5 -0
  193. package/dist/worksheet/table.d.ts +80 -0
  194. package/dist/worksheet/views.d.ts +47 -0
  195. package/dist/worksheet/web-publish.d.ts +21 -0
  196. package/dist/worksheet/worksheet.d.ts +935 -0
  197. package/dist/worksheet/writer.d.ts +72 -0
  198. package/dist/worksheet-CmCNoIgD.mjs +1726 -0
  199. package/dist/worksheet-CmCNoIgD.mjs.map +1 -0
  200. package/dist/worksheet.mjs +247 -0
  201. package/dist/worksheet.mjs.map +1 -0
  202. package/dist/writer-DspzfkNA.mjs +221 -0
  203. package/dist/writer-DspzfkNA.mjs.map +1 -0
  204. package/dist/xml/index.d.ts +10 -0
  205. package/dist/xml/iterparse.d.ts +22 -0
  206. package/dist/xml/namespaces.d.ts +91 -0
  207. package/dist/xml/parser.d.ts +7 -0
  208. package/dist/xml/serializer.d.ts +14 -0
  209. package/dist/xml/stream-writer.d.ts +39 -0
  210. package/dist/xml/tree.d.ts +37 -0
  211. package/dist/xml.mjs +140 -0
  212. package/dist/xml.mjs.map +1 -0
  213. package/dist/zip/decompression-guard.d.ts +70 -0
  214. package/dist/zip/index.d.ts +6 -0
  215. package/dist/zip/random-access-reader.d.ts +16 -0
  216. package/dist/zip/reader.d.ts +45 -0
  217. package/dist/zip/writer.d.ts +65 -0
  218. package/dist/zip/zip64-patch.d.ts +12 -0
  219. package/dist/zip.mjs +3 -0
  220. package/package.json +147 -0
@@ -0,0 +1,247 @@
1
+ import { $ as iterRows, $t as makeRowDimension, A as getCellsInRow, An as unionRange, At as setRangeValues, B as getPopulatedRowIndices, Bt as unhideColumns, C as getAutoFilter, Ct as setColumnWidth, Dt as setDefaultRowHeight, En as rangeContainsRange, Et as setDefaultColumnWidth, F as getMaxRow, Ft as setSheetViewMode, G as groupRows, Gt as writeRange, H as getRowDimension, Ht as unhideRows, I as getMergedCells, It as setSheetZoom, J as hideRow, Jt as freezePaneRef, K as hideColumn, Kt as makeSheetProperties, L as getMergedRangeAt, Lt as ungroupColumns, M as getDataExtent, Mt as setRowHeight, N as getFreezePanes, Nt as setRowHeights, O as getCellsInColumn, On as rangesOverlap, Ot as setFreezePanes, P as getMaxCol, Pt as setSheetTabColor, Q as iterCells, Qt as makeColumnDimension, R as getNonEmptyCellCount, Rt as ungroupRows, S as freezePanes, St as setColumnDimension, T as getCellByCoord, Tn as rangeContainsCell, Tt as setComment, U as getTable, Ut as unmergeCells, V as getRangeValues, Vt as unhideRow, W as groupColumns, Wt as unmergeCellsAt, X as isMergedCell, Xt as makeSheetView, Y as hideRows, Yt as makeFreezePane, Z as isWorksheetEmpty, Zt as makeHyperlink, _ as countCellsByKind, _n as intersectionRange, _t as removeIgnoredErrors, a as addTable, at as makeWorksheet, b as expandRowGroup, bt as setCell, c as applyToRange, ct as removeAllComments, d as clearAllCells, dt as removeAllHyperlinks, et as iterValues, f as clearRange, ft as removeAllMergedRanges, g as countCells, gn as expandRangeStr, gt as removeHyperlink, h as copyRange, ht as removeDataValidations, i as addIgnoredError, it as listTables, j as getColumnDimension, jt as setRowDimension, k as getCellsInRange, kn as shiftRange, kt as setHyperlink, l as autofitColumns, lt as removeAllConditionalFormatting, m as collapseRowGroup, mt as removeCellWatches, n as addConditionalFormatting, nt as listDataValidations, o as appendRow, ot as mergeCells, p as collapseColumnGroup, pt as removeAllTables, q as hideColumns, qt as makeLegacyComment, r as addDataValidation, rt as listHyperlinks, s as appendRows, st as moveRange, t as addCellWatch, tt as listComments, ut as removeAllDataValidations, v as deleteCell, vn as isCellInRange, vt as removeTable, w as getCell, wn as rangeArea, wt as setColumnWidths, x as findCells, xt as setCellByCoord, y as expandColumnGroup, yn as isRangeInRange, yt as setAutoFilter, z as getPopulatedColumnIndices, zt as unhideColumn } from "./worksheet-CmCNoIgD.mjs";
2
+ import { a as makeCfRule, i as makeDataValidation, n as makeTableColumn, o as makeConditionalFormatting, r as makeTableDefinition, t as addExcelTable } from "./table-DkX6UniA.mjs";
3
+ //#region src/worksheet/auto-filter.ts
4
+ function makeAutoFilter(opts) {
5
+ return {
6
+ ref: opts.ref,
7
+ filterColumns: opts.filterColumns ?? []
8
+ };
9
+ }
10
+ function makeFilterColumn(opts) {
11
+ return {
12
+ kind: "filters",
13
+ colId: opts.colId,
14
+ values: [...opts.values],
15
+ ...opts.blank !== void 0 ? { blank: opts.blank } : {}
16
+ };
17
+ }
18
+ //#endregion
19
+ //#region src/worksheet/errors.ts
20
+ const makeCellWatch = (ref) => ({ ref });
21
+ function makeIgnoredError(opts) {
22
+ return {
23
+ sqref: opts.sqref,
24
+ ...opts.evalError !== void 0 ? { evalError: opts.evalError } : {},
25
+ ...opts.twoDigitTextYear !== void 0 ? { twoDigitTextYear: opts.twoDigitTextYear } : {},
26
+ ...opts.numberStoredAsText !== void 0 ? { numberStoredAsText: opts.numberStoredAsText } : {},
27
+ ...opts.formula !== void 0 ? { formula: opts.formula } : {},
28
+ ...opts.formulaRange !== void 0 ? { formulaRange: opts.formulaRange } : {},
29
+ ...opts.unlockedFormula !== void 0 ? { unlockedFormula: opts.unlockedFormula } : {},
30
+ ...opts.emptyCellReference !== void 0 ? { emptyCellReference: opts.emptyCellReference } : {},
31
+ ...opts.listDataValidation !== void 0 ? { listDataValidation: opts.listDataValidation } : {},
32
+ ...opts.calculatedColumn !== void 0 ? { calculatedColumn: opts.calculatedColumn } : {}
33
+ };
34
+ }
35
+ //#endregion
36
+ //#region src/worksheet/protection.ts
37
+ const makeSheetProtection = (opts = {}) => {
38
+ const out = {};
39
+ for (const k of [
40
+ "sheet",
41
+ "objects",
42
+ "scenarios",
43
+ "formatCells",
44
+ "formatColumns",
45
+ "formatRows",
46
+ "insertColumns",
47
+ "insertRows",
48
+ "insertHyperlinks",
49
+ "deleteColumns",
50
+ "deleteRows",
51
+ "selectLockedCells",
52
+ "selectUnlockedCells",
53
+ "sort",
54
+ "autoFilter",
55
+ "pivotTables"
56
+ ]) if (opts[k] !== void 0) out[k] = opts[k];
57
+ if (opts.saltValue !== void 0) out.saltValue = opts.saltValue;
58
+ if (opts.spinCount !== void 0) out.spinCount = opts.spinCount;
59
+ if (opts.algorithmName !== void 0) out.algorithmName = opts.algorithmName;
60
+ if (opts.hashValue !== void 0) out.hashValue = opts.hashValue;
61
+ return out;
62
+ };
63
+ Object.freeze({
64
+ sheet: true,
65
+ objects: true,
66
+ scenarios: true,
67
+ formatCells: false,
68
+ formatColumns: false,
69
+ formatRows: false,
70
+ insertColumns: false,
71
+ insertRows: false,
72
+ insertHyperlinks: false,
73
+ deleteColumns: false,
74
+ deleteRows: false,
75
+ selectLockedCells: false,
76
+ selectUnlockedCells: false,
77
+ sort: false,
78
+ autoFilter: false,
79
+ pivotTables: false
80
+ });
81
+ //#endregion
82
+ //#region src/worksheet/protected-ranges.ts
83
+ const makeProtectedRange = (opts) => ({
84
+ sqref: opts.sqref,
85
+ name: opts.name,
86
+ ...opts.password !== void 0 ? { password: opts.password } : {},
87
+ ...opts.securityDescriptor !== void 0 ? { securityDescriptor: opts.securityDescriptor } : {},
88
+ ...opts.algorithmName !== void 0 ? { algorithmName: opts.algorithmName } : {},
89
+ ...opts.hashValue !== void 0 ? { hashValue: opts.hashValue } : {},
90
+ ...opts.saltValue !== void 0 ? { saltValue: opts.saltValue } : {},
91
+ ...opts.spinCount !== void 0 ? { spinCount: opts.spinCount } : {}
92
+ });
93
+ //#endregion
94
+ //#region src/worksheet/sort-state.ts
95
+ const makeSortCondition = (opts) => ({ ...opts });
96
+ const makeSortState = (opts) => ({
97
+ ref: opts.ref,
98
+ conditions: opts.conditions?.slice() ?? [],
99
+ ...opts.columnSort !== void 0 ? { columnSort: opts.columnSort } : {},
100
+ ...opts.caseSensitive !== void 0 ? { caseSensitive: opts.caseSensitive } : {},
101
+ ...opts.sortMethod !== void 0 ? { sortMethod: opts.sortMethod } : {}
102
+ });
103
+ //#endregion
104
+ //#region src/worksheet/smart-tags.ts
105
+ const makeCellSmartTagProperty = (key, val) => ({
106
+ key,
107
+ val
108
+ });
109
+ const makeCellSmartTag = (opts) => ({
110
+ type: opts.type,
111
+ properties: opts.properties?.slice() ?? [],
112
+ ...opts.deleted !== void 0 ? { deleted: opts.deleted } : {},
113
+ ...opts.xmlBased !== void 0 ? { xmlBased: opts.xmlBased } : {}
114
+ });
115
+ const makeCellSmartTags = (opts) => ({
116
+ ref: opts.ref,
117
+ tags: opts.tags?.slice() ?? []
118
+ });
119
+ //#endregion
120
+ //#region src/worksheet/ole-objects.ts
121
+ const makeOleObject = (opts) => ({
122
+ shapeId: opts.shapeId,
123
+ ...opts.rId !== void 0 ? { rId: opts.rId } : {},
124
+ ...opts.progId !== void 0 ? { progId: opts.progId } : {},
125
+ ...opts.dvAspect !== void 0 ? { dvAspect: opts.dvAspect } : {},
126
+ ...opts.link !== void 0 ? { link: opts.link } : {},
127
+ ...opts.oleUpdate !== void 0 ? { oleUpdate: opts.oleUpdate } : {},
128
+ ...opts.autoLoad !== void 0 ? { autoLoad: opts.autoLoad } : {},
129
+ ...opts.objectPr !== void 0 ? { objectPr: opts.objectPr } : {}
130
+ });
131
+ const makeFormControl = (opts) => ({
132
+ shapeId: opts.shapeId,
133
+ ...opts.rId !== void 0 ? { rId: opts.rId } : {},
134
+ ...opts.name !== void 0 ? { name: opts.name } : {},
135
+ ...opts.controlPr !== void 0 ? { controlPr: opts.controlPr } : {}
136
+ });
137
+ //#endregion
138
+ //#region src/worksheet/custom-sheet-views.ts
139
+ const makeCustomSheetView = (opts) => ({ ...opts });
140
+ //#endregion
141
+ //#region src/worksheet/page-setup.ts
142
+ const makePageMargins = (opts = {}) => ({
143
+ left: opts.left ?? .75,
144
+ right: opts.right ?? .75,
145
+ top: opts.top ?? 1,
146
+ bottom: opts.bottom ?? 1,
147
+ header: opts.header ?? .5,
148
+ footer: opts.footer ?? .5
149
+ });
150
+ const makePrintOptions = (opts = {}) => ({ ...opts });
151
+ const makePageSetup = (opts = {}) => ({ ...opts });
152
+ const makeHeaderFooter = (opts = {}) => ({ ...opts });
153
+ const makePageBreak = (opts = {}) => ({ ...opts });
154
+ /**
155
+ * Excel's reserved header / footer code tokens. Drop these into the left /
156
+ * center / right text inputs of {@link buildHeaderFooterText} (or directly into
157
+ * a setHeader / setFooter string) to render dynamic values at print time.
158
+ */
159
+ const HEADER_FOOTER_CODES = Object.freeze({
160
+ /** Current page number. */
161
+ pageNumber: "&P",
162
+ /** Total number of pages. */
163
+ pageCount: "&N",
164
+ /** Print date. */
165
+ date: "&D",
166
+ /** Print time. */
167
+ time: "&T",
168
+ /** File path + name. */
169
+ filePath: "&Z&F",
170
+ /** File name only. */
171
+ fileName: "&F",
172
+ /** Sheet name. */
173
+ sheetName: "&A",
174
+ /** Embedded image (Excel inserts via "Insert Picture" — `&G` is the placeholder). */
175
+ picture: "&G"
176
+ });
177
+ /**
178
+ * Build a header / footer string from optional left / center / right fragments
179
+ * using Excel's `&L` / `&C` / `&R` markers. An empty fragment is omitted (no
180
+ * marker emitted) so a center-only header doesn't leave a stray `&L` prefix.
181
+ * Returns `''` when all three fragments are undefined.
182
+ */
183
+ const buildHeaderFooterText = (parts) => {
184
+ let out = "";
185
+ if (parts.left !== void 0) out += `&L${parts.left}`;
186
+ if (parts.center !== void 0) out += `&C${parts.center}`;
187
+ if (parts.right !== void 0) out += `&R${parts.right}`;
188
+ return out;
189
+ };
190
+ //#endregion
191
+ //#region src/worksheet/web-publish.ts
192
+ const makeWorksheetCustomProperty = (opts) => ({
193
+ name: opts.name,
194
+ ...opts.rId !== void 0 ? { rId: opts.rId } : {}
195
+ });
196
+ const makeWebPublishItem = (opts) => ({
197
+ id: opts.id,
198
+ divId: opts.divId,
199
+ sourceType: opts.sourceType,
200
+ destinationFile: opts.destinationFile,
201
+ ...opts.sourceRef !== void 0 ? { sourceRef: opts.sourceRef } : {},
202
+ ...opts.sourceObject !== void 0 ? { sourceObject: opts.sourceObject } : {},
203
+ ...opts.title !== void 0 ? { title: opts.title } : {},
204
+ ...opts.autoRepublish !== void 0 ? { autoRepublish: opts.autoRepublish } : {}
205
+ });
206
+ //#endregion
207
+ //#region src/worksheet/phonetic.ts
208
+ const makeWorksheetPhoneticProperties = (opts = {}) => ({ ...opts });
209
+ //#endregion
210
+ //#region src/worksheet/data-consolidate.ts
211
+ const makeDataConsolidate = (opts = {}) => {
212
+ const out = {};
213
+ if (opts.function !== void 0) out.function = opts.function;
214
+ if (opts.topLabels !== void 0) out.topLabels = opts.topLabels;
215
+ if (opts.leftLabels !== void 0) out.leftLabels = opts.leftLabels;
216
+ if (opts.link !== void 0) out.link = opts.link;
217
+ if (opts.dataRefs !== void 0) out.dataRefs = opts.dataRefs.map((r) => ({ ...r }));
218
+ if (opts.startLabels !== void 0) out.startLabels = opts.startLabels;
219
+ return out;
220
+ };
221
+ //#endregion
222
+ //#region src/worksheet/scenarios.ts
223
+ const makeScenarioInputCell = (opts) => ({
224
+ ref: opts.ref,
225
+ val: opts.val,
226
+ ...opts.deleted !== void 0 ? { deleted: opts.deleted } : {},
227
+ ...opts.undone !== void 0 ? { undone: opts.undone } : {},
228
+ ...opts.numFmtId !== void 0 ? { numFmtId: opts.numFmtId } : {}
229
+ });
230
+ const makeScenario = (opts) => ({
231
+ name: opts.name,
232
+ inputCells: opts.inputCells.slice(),
233
+ ...opts.locked !== void 0 ? { locked: opts.locked } : {},
234
+ ...opts.hidden !== void 0 ? { hidden: opts.hidden } : {},
235
+ ...opts.user !== void 0 ? { user: opts.user } : {},
236
+ ...opts.comment !== void 0 ? { comment: opts.comment } : {}
237
+ });
238
+ const makeScenarioList = (opts = {}) => ({
239
+ scenarios: opts.scenarios?.slice() ?? [],
240
+ ...opts.current !== void 0 ? { current: opts.current } : {},
241
+ ...opts.show !== void 0 ? { show: opts.show } : {},
242
+ ...opts.sqref !== void 0 ? { sqref: opts.sqref } : {}
243
+ });
244
+ //#endregion
245
+ export { HEADER_FOOTER_CODES, addCellWatch, addConditionalFormatting, addDataValidation, addExcelTable, addIgnoredError, addTable, appendRow, appendRows, applyToRange, autofitColumns, buildHeaderFooterText, clearAllCells, clearRange, collapseColumnGroup, collapseRowGroup, copyRange, countCells, countCellsByKind, deleteCell, expandColumnGroup, expandRangeStr, expandRowGroup, findCells, freezePaneRef, freezePanes, getAutoFilter, getCell, getCellByCoord, getCellsInColumn, getCellsInRange, getCellsInRow, getColumnDimension, getDataExtent, getFreezePanes, getMaxCol, getMaxRow, getMergedCells, getMergedRangeAt, getNonEmptyCellCount, getPopulatedColumnIndices, getPopulatedRowIndices, getRangeValues, getRowDimension, getTable, groupColumns, groupRows, hideColumn, hideColumns, hideRow, hideRows, intersectionRange, isCellInRange, isMergedCell, isRangeInRange, isWorksheetEmpty, iterCells, iterRows, iterValues, listComments, listDataValidations, listHyperlinks, listTables, makeAutoFilter, makeCellSmartTag, makeCellSmartTagProperty, makeCellSmartTags, makeCellWatch, makeCfRule, makeColumnDimension, makeConditionalFormatting, makeCustomSheetView, makeDataConsolidate, makeDataValidation, makeFilterColumn, makeFormControl, makeFreezePane, makeHeaderFooter, makeHyperlink, makeIgnoredError, makeLegacyComment, makeOleObject, makePageBreak, makePageMargins, makePageSetup, makePrintOptions, makeProtectedRange, makeRowDimension, makeScenario, makeScenarioInputCell, makeScenarioList, makeSheetProperties, makeSheetProtection, makeSheetView, makeSortCondition, makeSortState, makeTableColumn, makeTableDefinition, makeWebPublishItem, makeWorksheet, makeWorksheetCustomProperty, makeWorksheetPhoneticProperties, mergeCells, moveRange, rangeArea, rangeContainsCell, rangeContainsRange, rangesOverlap, removeAllComments, removeAllConditionalFormatting, removeAllDataValidations, removeAllHyperlinks, removeAllMergedRanges, removeAllTables, removeCellWatches, removeDataValidations, removeHyperlink, removeIgnoredErrors, removeTable, setAutoFilter, setCell, setCellByCoord, setColumnDimension, setColumnWidth, setColumnWidths, setComment, setDefaultColumnWidth, setDefaultRowHeight, setFreezePanes, setHyperlink, setRangeValues, setRowDimension, setRowHeight, setRowHeights, setSheetTabColor, setSheetViewMode, setSheetZoom, shiftRange, ungroupColumns, ungroupRows, unhideColumn, unhideColumns, unhideRow, unhideRows, unionRange, unmergeCells, unmergeCellsAt, writeRange };
246
+
247
+ //# sourceMappingURL=worksheet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worksheet.mjs","names":[],"sources":["../src/worksheet/auto-filter.ts","../src/worksheet/errors.ts","../src/worksheet/protection.ts","../src/worksheet/protected-ranges.ts","../src/worksheet/sort-state.ts","../src/worksheet/smart-tags.ts","../src/worksheet/ole-objects.ts","../src/worksheet/custom-sheet-views.ts","../src/worksheet/page-setup.ts","../src/worksheet/web-publish.ts","../src/worksheet/phonetic.ts","../src/worksheet/data-consolidate.ts","../src/worksheet/scenarios.ts"],"sourcesContent":["// AutoFilter.\n//\n// **Stage 1**: ref + filterColumns where each entry is the `kind: 'filters'`\n// variant — the value-list dropdown filter that covers >95% of real-world\n// spreadsheets. customFilters / top10 / dynamicFilter / colorFilter /\n// iconFilter / SortState are reserved for later iterations.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions';\n\nexport type FilterColumn = {\n kind: 'filters';\n colId: number;\n /** Discrete values that pass the filter. Stored as strings to match the wire format. */\n values: string[];\n /** Whether blanks are visible. */\n blank?: boolean;\n};\n\nexport interface AutoFilter {\n /** Excel range the filter covers (`\"A1:E100\"`). */\n ref: string;\n filterColumns: FilterColumn[];\n}\n\nexport function makeAutoFilter(opts: { ref: string; filterColumns?: FilterColumn[] }): AutoFilter {\n return { ref: opts.ref, filterColumns: opts.filterColumns ?? [] };\n}\n\nexport function makeFilterColumn(opts: {\n colId: number;\n values: ReadonlyArray<string>;\n blank?: boolean;\n}): FilterColumn {\n return {\n kind: 'filters',\n colId: opts.colId,\n values: [...opts.values],\n ...(opts.blank !== undefined ? { blank: opts.blank } : {}),\n };\n}\n\n// ---- Worksheet ergonomic builders ---------------------------------------\n\nimport type { Worksheet } from './worksheet';\n\n/** Add an AutoFilter dropdown header strip to the given range. */\nexport const addAutoFilter = (ws: Worksheet, ref: string): AutoFilter => {\n ws.autoFilter = makeAutoFilter({ ref });\n return ws.autoFilter;\n};\n\n/**\n * Add a value-list dropdown filter to a column inside the existing AutoFilter\n * range. `colId` is 0-based relative to the AutoFilter left edge.\n */\nexport const addAutoFilterColumn = (\n ws: Worksheet,\n colId: number,\n values: ReadonlyArray<string>,\n opts: { blank?: boolean } = {},\n): FilterColumn => {\n if (!ws.autoFilter) {\n throw new OpenXmlSchemaError('addAutoFilterColumn: call addAutoFilter(ws, ref) first');\n }\n const fc = makeFilterColumn({ colId, values, ...(opts.blank !== undefined ? { blank: opts.blank } : {}) });\n ws.autoFilter.filterColumns.push(fc);\n return fc;\n};\n\n/** Drop the worksheet's AutoFilter entirely. */\nexport const removeAutoFilter = (ws: Worksheet): void => {\n delete (ws as { autoFilter?: AutoFilter }).autoFilter;\n};\n","// Cell-level error / watch metadata. (cellWatches / ignoredErrors).\n//\n// `ignoredErrors` lets you tell Excel \"don't flag these cells with the little\n// green triangle for this class of validation\". `cellWatches` records which\n// cells the user has pinned in the Watch Window.\n//\n// Both round-trip via the worksheet `bodyExtras` passthrough already, but\n// promoting them to first-class arrays gives the editor a clean API and the\n// writer a stable position in the worksheet element order (between rowBreaks /\n// colBreaks and the drawing block per ECMA-376 §18.3.1.94 cellWatches /\n// §18.3.1.51 ignoredErrors).\n\nimport type { MultiCellRange } from './cell-range';\n\n/**\n * One Cell-Watch entry. The Watch Window in Excel (Formulas → Watch Window)\n * shows live values for the cells listed here.\n */\nexport interface CellWatch {\n /** Single-cell reference like \"Sheet1!$A$1\" — kept verbatim. */\n ref: string;\n}\n\n/**\n * One ignored-error entry. Each Boolean flag corresponds to a class of Excel's\n * background validation; setting any of them to `true` suppresses the green\n * triangle for cells in `sqref`.\n */\nexport interface IgnoredError {\n /** Cells to which the suppressions apply. */\n sqref: MultiCellRange;\n /** \"Formula evaluates to error\" warning. */\n evalError?: boolean;\n /** \"Date stored as 2-digit year\" warning. */\n twoDigitTextYear?: boolean;\n /** \"Number stored as text\" warning. */\n numberStoredAsText?: boolean;\n /** \"Inconsistent formula\" warning. */\n formula?: boolean;\n /** \"Formula omits cells\" warning. */\n formulaRange?: boolean;\n /** \"Unlocked cells containing formulas\" warning. */\n unlockedFormula?: boolean;\n /** \"Empty cells referenced\" warning. */\n emptyCellReference?: boolean;\n /** \"Data validation list error\" warning. */\n listDataValidation?: boolean;\n /** \"Inconsistent calculated column\" warning (Excel Tables). */\n calculatedColumn?: boolean;\n}\n\nexport const makeCellWatch = (ref: string): CellWatch => ({ ref });\n\nexport function makeIgnoredError(\n opts: Partial<IgnoredError> & { sqref: MultiCellRange },\n): IgnoredError {\n return {\n sqref: opts.sqref,\n ...(opts.evalError !== undefined ? { evalError: opts.evalError } : {}),\n ...(opts.twoDigitTextYear !== undefined ? { twoDigitTextYear: opts.twoDigitTextYear } : {}),\n ...(opts.numberStoredAsText !== undefined ? { numberStoredAsText: opts.numberStoredAsText } : {}),\n ...(opts.formula !== undefined ? { formula: opts.formula } : {}),\n ...(opts.formulaRange !== undefined ? { formulaRange: opts.formulaRange } : {}),\n ...(opts.unlockedFormula !== undefined ? { unlockedFormula: opts.unlockedFormula } : {}),\n ...(opts.emptyCellReference !== undefined ? { emptyCellReference: opts.emptyCellReference } : {}),\n ...(opts.listDataValidation !== undefined ? { listDataValidation: opts.listDataValidation } : {}),\n ...(opts.calculatedColumn !== undefined ? { calculatedColumn: opts.calculatedColumn } : {}),\n };\n}\n","// Sheet-protection model. (without password hashing — saltValue / spinCount /\n// algorithmName / hashValue round-trip verbatim, but no helper to compute them\n// yet).\n//\n// Excel uses the listed booleans inversely: `true` typically means \"users CAN\n// do this even when the sheet is locked\" (e.g. `formatCells: true` lets people\n// change cell formatting on a protected sheet). The only universally meaningful\n// field is `sheet: true`, which actually enables the lock.\n\nexport interface SheetProtection {\n /** Master toggle — when true the sheet is protected. */\n sheet?: boolean;\n /** Allow operations on drawing objects when sheet is protected. */\n objects?: boolean;\n /** Allow operations on scenarios when sheet is protected. */\n scenarios?: boolean;\n formatCells?: boolean;\n formatColumns?: boolean;\n formatRows?: boolean;\n insertColumns?: boolean;\n insertRows?: boolean;\n insertHyperlinks?: boolean;\n deleteColumns?: boolean;\n deleteRows?: boolean;\n selectLockedCells?: boolean;\n selectUnlockedCells?: boolean;\n sort?: boolean;\n autoFilter?: boolean;\n pivotTables?: boolean;\n\n // Password-protection fields. Round-trip only — computing a fresh hash from a\n // plaintext password lives behind a future helper.\n /** Base-64 salt for the password hash. */\n saltValue?: string;\n /** Number of hash iterations. */\n spinCount?: number;\n /** Hash algorithm name, e.g. \"SHA-512\". */\n algorithmName?: string;\n /** Base-64 hashed password. */\n hashValue?: string;\n}\n\nexport const makeSheetProtection = (opts: SheetProtection = {}): SheetProtection => {\n const out: SheetProtection = {};\n for (const k of [\n 'sheet',\n 'objects',\n 'scenarios',\n 'formatCells',\n 'formatColumns',\n 'formatRows',\n 'insertColumns',\n 'insertRows',\n 'insertHyperlinks',\n 'deleteColumns',\n 'deleteRows',\n 'selectLockedCells',\n 'selectUnlockedCells',\n 'sort',\n 'autoFilter',\n 'pivotTables',\n ] as const) {\n if (opts[k] !== undefined) out[k] = opts[k];\n }\n if (opts.saltValue !== undefined) out.saltValue = opts.saltValue;\n if (opts.spinCount !== undefined) out.spinCount = opts.spinCount;\n if (opts.algorithmName !== undefined) out.algorithmName = opts.algorithmName;\n if (opts.hashValue !== undefined) out.hashValue = opts.hashValue;\n return out;\n};\n\n// ---- Worksheet ergonomic helpers ----------------------------------------\n\nimport type { Worksheet } from './worksheet';\n\n/**\n * Excel's \"Protect Sheet\" defaults — when you click the dialog without changing\n * any checkbox, it locks structure but allows the listed actions. This matches\n * Excel's wire form (sheet=1 + the listed flags left at their defaults).\n */\nconst PROTECT_SHEET_DEFAULTS: SheetProtection = Object.freeze({\n sheet: true,\n objects: true,\n scenarios: true,\n formatCells: false,\n formatColumns: false,\n formatRows: false,\n insertColumns: false,\n insertRows: false,\n insertHyperlinks: false,\n deleteColumns: false,\n deleteRows: false,\n selectLockedCells: false,\n selectUnlockedCells: false,\n sort: false,\n autoFilter: false,\n pivotTables: false,\n});\n\n/**\n * Lock a worksheet with Excel's \"Protect Sheet\" defaults. Pass `overrides` to\n * allow specific actions while otherwise locked (e.g. `{ sort: true,\n * autoFilter: true }` for \"allow sort + filter on locked sheet\"). Password-hash\n * fields can be supplied as a quad (algorithmName / hashValue / saltValue /\n * spinCount); plaintext passwords are out of scope until the D-tier hashing\n * helper lands.\n */\nexport const protectSheet = (\n ws: Worksheet,\n overrides: Partial<SheetProtection> = {},\n): SheetProtection => {\n ws.sheetProtection = { ...PROTECT_SHEET_DEFAULTS, ...overrides };\n return ws.sheetProtection;\n};\n\n/** Drop the typed sheet-protection record. */\nexport const unprotectSheet = (ws: Worksheet): void => {\n delete (ws as { sheetProtection?: SheetProtection }).sheetProtection;\n};\n\n/** Quick-lock helper that mirrors Excel's \"Allow users to edit ranges → Protect Sheet\" defaults. */\nexport const isSheetProtected = (ws: Worksheet): boolean => ws.sheetProtection?.sheet === true;\n","// Worksheet-level <protectedRanges>. Per ECMA-376 §18.3.1.69.\n//\n// Excel's \"Allow Edit Ranges\" dialog (Review → Allow Edit Ranges).\n// Each entry whitelists a specific range to be editable while the\n// sheet is otherwise protected. Round-tripped verbatim — no password\n// hashing helper yet.\n\nimport type { MultiCellRange } from './cell-range';\n\nexport interface ProtectedRange {\n /** Range to expose for editing while the sheet is protected. */\n sqref: MultiCellRange;\n /** Display name shown in the dialog. */\n name: string;\n /** Legacy 16-bit hex password. */\n password?: string;\n /** Optional security descriptor (Windows ACL string). */\n securityDescriptor?: string;\n // Modern hash quad — round-tripped verbatim.\n algorithmName?: string;\n hashValue?: string;\n saltValue?: string;\n spinCount?: number;\n}\n\nexport const makeProtectedRange = (\n opts: Partial<ProtectedRange> & { sqref: MultiCellRange; name: string },\n): ProtectedRange => ({\n sqref: opts.sqref,\n name: opts.name,\n ...(opts.password !== undefined ? { password: opts.password } : {}),\n ...(opts.securityDescriptor !== undefined ? { securityDescriptor: opts.securityDescriptor } : {}),\n ...(opts.algorithmName !== undefined ? { algorithmName: opts.algorithmName } : {}),\n ...(opts.hashValue !== undefined ? { hashValue: opts.hashValue } : {}),\n ...(opts.saltValue !== undefined ? { saltValue: opts.saltValue } : {}),\n ...(opts.spinCount !== undefined ? { spinCount: opts.spinCount } : {}),\n});\n","// Worksheet-level <sortState>. Per ECMA-376 §18.3.1.92.\n//\n// Excel persists the last sort the user applied so re-opening the file\n// shows the rows in the same order. The element carries one or more\n// <sortCondition> entries describing the sort key columns (or rows).\n\nexport type SortBy = 'value' | 'cellColor' | 'fontColor' | 'icon';\nexport type SortMethod = 'stroke' | 'pinYin';\nexport type SortIconSet =\n | '3Arrows'\n | '3ArrowsGray'\n | '3Flags'\n | '3TrafficLights1'\n | '3TrafficLights2'\n | '3Signs'\n | '3Symbols'\n | '3Symbols2'\n | '4Arrows'\n | '4ArrowsGray'\n | '4RedToBlack'\n | '4Rating'\n | '4TrafficLights'\n | '5Arrows'\n | '5ArrowsGray'\n | '5Rating'\n | '5Quarters';\n\nexport interface SortCondition {\n /** Column or row that drives this sort key. */\n ref: string;\n descending?: boolean;\n sortBy?: SortBy;\n /** Reference to a custom-list defined name. */\n customList?: string;\n /** Differential-style index (`<dxf>` slot in the stylesheet). */\n dxfId?: number;\n iconSet?: SortIconSet;\n iconId?: number;\n}\n\nexport interface SortState {\n /** Range the sort applies to (`A1:D20`). */\n ref: string;\n conditions: SortCondition[];\n /** Sort columns instead of rows (rare). */\n columnSort?: boolean;\n caseSensitive?: boolean;\n sortMethod?: SortMethod;\n}\n\nexport const makeSortCondition = (opts: SortCondition): SortCondition => ({ ...opts });\n\nexport const makeSortState = (opts: Partial<SortState> & { ref: string }): SortState => ({\n ref: opts.ref,\n conditions: opts.conditions?.slice() ?? [],\n ...(opts.columnSort !== undefined ? { columnSort: opts.columnSort } : {}),\n ...(opts.caseSensitive !== undefined ? { caseSensitive: opts.caseSensitive } : {}),\n ...(opts.sortMethod !== undefined ? { sortMethod: opts.sortMethod } : {}),\n});\n","// Worksheet-level <smartTags>. Per ECMA-376 §18.3.1.93.\n//\n// Per-cell smart-tag annotations from Excel 2003. The element is\n// nested:\n// <smartTags>\n// <cellSmartTags r=\"A1\">\n// <cellSmartTag type=\"0\" deleted=\"0\" xmlBased=\"0\">\n// <cellSmartTagPr key=\"…\" val=\"…\"/>\n// </cellSmartTag>\n// </cellSmartTags>\n// </smartTags>\n// Almost never seen in modern files; the workbook-level smartTagTypes\n// list registers the schema, this element pins individual cells.\n\nexport interface CellSmartTagProperty {\n key: string;\n val: string;\n}\n\nexport interface CellSmartTag {\n /** 0-based index into the workbook's smartTagTypes list. */\n type: number;\n properties: CellSmartTagProperty[];\n deleted?: boolean;\n xmlBased?: boolean;\n}\n\nexport interface CellSmartTags {\n /** Single-cell ref (\"A1\"). */\n ref: string;\n tags: CellSmartTag[];\n}\n\nexport const makeCellSmartTagProperty = (key: string, val: string): CellSmartTagProperty => ({ key, val });\n\nexport const makeCellSmartTag = (opts: Partial<CellSmartTag> & { type: number }): CellSmartTag => ({\n type: opts.type,\n properties: opts.properties?.slice() ?? [],\n ...(opts.deleted !== undefined ? { deleted: opts.deleted } : {}),\n ...(opts.xmlBased !== undefined ? { xmlBased: opts.xmlBased } : {}),\n});\n\nexport const makeCellSmartTags = (opts: Partial<CellSmartTags> & { ref: string }): CellSmartTags => ({\n ref: opts.ref,\n tags: opts.tags?.slice() ?? [],\n});\n","// Worksheet-level <oleObjects> + <controls>. Per ECMA-376 §18.3.1.61\n// and §18.3.1.27.\n//\n// Both elements are lists of object references where each entry has a\n// `shapeId` + `r:id` plus a child `<objectPr>` / `<controlPr>` element\n// that holds the anchor / display properties. The objectPr/controlPr\n// children pull in the spreadsheet-drawing namespace, so we round-trip\n// them as opaque XmlNode payloads rather than fully modeling the\n// nested anchor schema. The top-level attrs are typed for editor access.\n\nimport type { XmlNode } from '../xml/tree';\n\nexport type OleDvAspect = 'DVASPECT_CONTENT' | 'DVASPECT_ICON';\nexport type OleUpdateMode = 'OLEUPDATE_ALWAYS' | 'OLEUPDATE_ONCALL';\n\nexport interface OleObject {\n /** Unique shape id assigned by Excel — required. */\n shapeId: number;\n /** rels link to the embedded OLE blob. */\n rId?: string;\n progId?: string;\n dvAspect?: OleDvAspect;\n link?: string;\n oleUpdate?: OleUpdateMode;\n autoLoad?: boolean;\n /**\n * Optional `<objectPr>` child preserved verbatim. Modeling its\n * `<anchor>` schema in detail is deferred — this preserves the\n * round-trip without re-deriving the anchor attrs.\n */\n objectPr?: XmlNode;\n}\n\nexport interface FormControl {\n shapeId: number;\n rId?: string;\n /** ECMA-376 §18.3.1.27 — name shown in the form-control name box. */\n name?: string;\n /**\n * Optional `<controlPr>` child preserved verbatim (similar to\n * `objectPr` for OLE objects).\n */\n controlPr?: XmlNode;\n}\n\nexport const makeOleObject = (opts: Partial<OleObject> & { shapeId: number }): OleObject => ({\n shapeId: opts.shapeId,\n ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n ...(opts.progId !== undefined ? { progId: opts.progId } : {}),\n ...(opts.dvAspect !== undefined ? { dvAspect: opts.dvAspect } : {}),\n ...(opts.link !== undefined ? { link: opts.link } : {}),\n ...(opts.oleUpdate !== undefined ? { oleUpdate: opts.oleUpdate } : {}),\n ...(opts.autoLoad !== undefined ? { autoLoad: opts.autoLoad } : {}),\n ...(opts.objectPr !== undefined ? { objectPr: opts.objectPr } : {}),\n});\n\nexport const makeFormControl = (opts: Partial<FormControl> & { shapeId: number }): FormControl => ({\n shapeId: opts.shapeId,\n ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n ...(opts.name !== undefined ? { name: opts.name } : {}),\n ...(opts.controlPr !== undefined ? { controlPr: opts.controlPr } : {}),\n});\n","// Worksheet-level <customSheetViews> — saved per-user view presets.\n// Per ECMA-376 §18.3.1.26 / §18.3.1.27.\n//\n// Each <customSheetView> snapshots a sheet's view state: zoom level,\n// gridline / formula / heading toggles, plus its own page-setup block\n// and break list. The chartsheet sibling (smaller) has been typed\n// separately in src/chartsheet/chartsheet.ts.\n\nimport type { HeaderFooter, PageBreak, PageMargins, PageSetup, PrintOptions } from './page-setup';\nimport type { Pane, Selection, SheetViewMode } from './views';\n\nexport type CustomSheetViewState = 'visible' | 'hidden' | 'veryHidden';\n\nexport interface CustomSheetView {\n guid: string;\n scale?: number;\n /** 0..64 (legacy palette index) */\n colorId?: number;\n showPageBreaks?: boolean;\n showFormulas?: boolean;\n showGridLines?: boolean;\n showRowCol?: boolean;\n outlineSymbols?: boolean;\n zeroValues?: boolean;\n fitToPage?: boolean;\n /** Print only the print-area selection on this saved view. */\n printArea?: boolean;\n /** AutoFilter is active in this saved view. */\n filter?: boolean;\n showAutoFilter?: boolean;\n /** Hidden rows persist for this saved view. */\n hiddenRows?: boolean;\n hiddenColumns?: boolean;\n state?: CustomSheetViewState;\n filterUnique?: boolean;\n view?: SheetViewMode;\n showRuler?: boolean;\n /** Top-left cell ref shown when this view is restored. */\n topLeftCell?: string;\n /** Inner pane split / freeze. */\n pane?: Pane;\n /** Selection state for this view (one entry per pane). */\n selections?: Selection[];\n rowBreaks?: PageBreak[];\n colBreaks?: PageBreak[];\n pageMargins?: PageMargins;\n printOptions?: PrintOptions;\n pageSetup?: PageSetup;\n headerFooter?: HeaderFooter;\n}\n\nexport const makeCustomSheetView = (\n opts: Partial<CustomSheetView> & { guid: string },\n): CustomSheetView => ({ ...opts });\n","// Page-setup typed model.\n//\n// Promotes <printOptions> / <pageMargins> / <pageSetup> / <headerFooter> from\n// the bodyExtras passthrough into typed Worksheet fields with round-trip\n// readers / writers. Mirrors openpyxl/openpyxl/worksheet/ page.py +\n// header_footer.py.\n\nexport interface PrintOptions {\n /** Center the printed sheet horizontally on the page. */\n horizontalCentered?: boolean;\n /** Center the printed sheet vertically on the page. */\n verticalCentered?: boolean;\n /** Print row + column headings (the A B C / 1 2 3 strips). */\n headings?: boolean;\n /** Print sheet gridlines. */\n gridLines?: boolean;\n /** Mirrors a quirky Excel companion flag for `gridLines`. */\n gridLinesSet?: boolean;\n}\n\n/** Page margins in inches. ECMA-376 §18.3.1.62. All six fields are required when the element is present. */\nexport interface PageMargins {\n left: number;\n right: number;\n top: number;\n bottom: number;\n header: number;\n footer: number;\n}\n\nexport type PageOrientation = 'default' | 'portrait' | 'landscape';\nexport type PageOrder = 'downThenOver' | 'overThenDown';\nexport type CellCommentMode = 'none' | 'asDisplayed' | 'atEnd';\nexport type PrintErrorMode = 'displayed' | 'blank' | 'dash' | 'NA';\n\nexport interface PageSetup {\n paperSize?: number;\n scale?: number;\n firstPageNumber?: number;\n fitToWidth?: number;\n fitToHeight?: number;\n pageOrder?: PageOrder;\n orientation?: PageOrientation;\n usePrinterDefaults?: boolean;\n blackAndWhite?: boolean;\n draft?: boolean;\n cellComments?: CellCommentMode;\n useFirstPageNumber?: boolean;\n errors?: PrintErrorMode;\n horizontalDpi?: number;\n verticalDpi?: number;\n copies?: number;\n /** Optional `r:id` referencing an external printerSettings part — round-tripped verbatim. */\n rId?: string;\n /** Paper height (UniversalMeasure, e.g. \"297mm\"). */\n paperHeight?: string;\n /** Paper width (UniversalMeasure). */\n paperWidth?: string;\n}\n\nexport interface HeaderFooter {\n differentFirst?: boolean;\n differentOddEven?: boolean;\n /** Mirror Excel's \"scale header/footer with document\" toggle. Default true. */\n scaleWithDoc?: boolean;\n /** Mirror Excel's \"align header/footer with margins\" toggle. Default true. */\n alignWithMargins?: boolean;\n /**\n * Mini-format string. Excel uses `&L` / `&C` / `&R` to split the three\n * sections, plus codes like `&P` (page number), `&N` (page count), `&F` (file\n * name), `&A` (sheet name), `&D` / `&T` (date / time). We round-trip the\n * literal text — no parsing into sections.\n */\n oddHeader?: string;\n oddFooter?: string;\n evenHeader?: string;\n evenFooter?: string;\n firstHeader?: string;\n firstFooter?: string;\n}\n\nexport const makePageMargins = (opts: Partial<PageMargins> = {}): PageMargins => ({\n left: opts.left ?? 0.75,\n right: opts.right ?? 0.75,\n top: opts.top ?? 1,\n bottom: opts.bottom ?? 1,\n header: opts.header ?? 0.5,\n footer: opts.footer ?? 0.5,\n});\n\nexport const makePrintOptions = (opts: PrintOptions = {}): PrintOptions => ({ ...opts });\n\nexport const makePageSetup = (opts: PageSetup = {}): PageSetup => ({ ...opts });\n\nexport const makeHeaderFooter = (opts: HeaderFooter = {}): HeaderFooter => ({ ...opts });\n\n/**\n * One manual page break. `id` is the row (for rowBreaks) or column (for\n * colBreaks) index where the break sits; `min`/`max` constrain the orthogonal\n * range Excel honours; `man=true` means a user-placed break (default true).\n * `pt` indicates a \"pivot table\" break — rare.\n */\nexport interface PageBreak {\n id?: number;\n min?: number;\n max?: number;\n man?: boolean;\n pt?: boolean;\n}\n\nexport const makePageBreak = (opts: PageBreak = {}): PageBreak => ({ ...opts });\n\n// ---- Worksheet ergonomic helpers ----------------------------------------\n// Operate on a Worksheet directly so callers don't have to allocate the\n// individual typed records up front.\n\nimport type { Worksheet } from './worksheet';\n\nconst ensurePageSetup = (ws: Worksheet): PageSetup => {\n if (!ws.pageSetup) ws.pageSetup = {};\n return ws.pageSetup;\n};\n\nconst ensureHeaderFooter = (ws: Worksheet): HeaderFooter => {\n if (!ws.headerFooter) ws.headerFooter = {};\n return ws.headerFooter;\n};\n\n/** Set page orientation on `ws.pageSetup` (allocates if missing). */\nexport const setPageOrientation = (ws: Worksheet, orientation: PageOrientation): void => {\n ensurePageSetup(ws).orientation = orientation;\n};\n\n/** Set paper size code (Excel uses ECMA-376 §3.3 paper-size enums; 1=Letter, 9=A4 etc.). */\nexport const setPaperSize = (ws: Worksheet, paperSize: number): void => {\n ensurePageSetup(ws).paperSize = paperSize;\n};\n\n/** Set the print scale percentage (10..400). */\nexport const setPrintScale = (ws: Worksheet, scale: number): void => {\n ensurePageSetup(ws).scale = scale;\n};\n\n/** Set fitToWidth + fitToHeight (Excel \"Fit to N pages wide × M tall\" UI). */\nexport const setFitToPage = (ws: Worksheet, opts: { width?: number; height?: number }): void => {\n const ps = ensurePageSetup(ws);\n if (opts.width !== undefined) ps.fitToWidth = opts.width;\n if (opts.height !== undefined) ps.fitToHeight = opts.height;\n};\n\n/** Replace ws.pageMargins with the provided values (uses Excel defaults for missing axes). */\nexport const setPageMargins = (ws: Worksheet, opts: Partial<PageMargins> = {}): void => {\n ws.pageMargins = {\n left: opts.left ?? 0.75,\n right: opts.right ?? 0.75,\n top: opts.top ?? 1,\n bottom: opts.bottom ?? 1,\n header: opts.header ?? 0.5,\n footer: opts.footer ?? 0.5,\n };\n};\n\nexport type HeaderFooterSection = 'odd' | 'even' | 'first';\n\n/** Set the header text for a given section. Excel uses `&L` / `&C` / `&R` codes inside the string. */\nexport const setHeader = (ws: Worksheet, section: HeaderFooterSection, text: string): void => {\n const hf = ensureHeaderFooter(ws);\n if (section === 'odd') hf.oddHeader = text;\n else if (section === 'even') {\n hf.evenHeader = text;\n hf.differentOddEven = true;\n } else {\n hf.firstHeader = text;\n hf.differentFirst = true;\n }\n};\n\n/** Set the footer text for a given section. */\nexport const setFooter = (ws: Worksheet, section: HeaderFooterSection, text: string): void => {\n const hf = ensureHeaderFooter(ws);\n if (section === 'odd') hf.oddFooter = text;\n else if (section === 'even') {\n hf.evenFooter = text;\n hf.differentOddEven = true;\n } else {\n hf.firstFooter = text;\n hf.differentFirst = true;\n }\n};\n\n/**\n * Excel's reserved header / footer code tokens. Drop these into the left /\n * center / right text inputs of {@link buildHeaderFooterText} (or directly into\n * a setHeader / setFooter string) to render dynamic values at print time.\n */\nexport const HEADER_FOOTER_CODES = Object.freeze({\n /** Current page number. */\n pageNumber: '&P',\n /** Total number of pages. */\n pageCount: '&N',\n /** Print date. */\n date: '&D',\n /** Print time. */\n time: '&T',\n /** File path + name. */\n filePath: '&Z&F',\n /** File name only. */\n fileName: '&F',\n /** Sheet name. */\n sheetName: '&A',\n /** Embedded image (Excel inserts via \"Insert Picture\" — `&G` is the placeholder). */\n picture: '&G',\n});\n\n/**\n * Build a header / footer string from optional left / center / right fragments\n * using Excel's `&L` / `&C` / `&R` markers. An empty fragment is omitted (no\n * marker emitted) so a center-only header doesn't leave a stray `&L` prefix.\n * Returns `''` when all three fragments are undefined.\n */\nexport const buildHeaderFooterText = (\n parts: { left?: string; center?: string; right?: string },\n): string => {\n let out = '';\n if (parts.left !== undefined) out += `&L${parts.left}`;\n if (parts.center !== undefined) out += `&C${parts.center}`;\n if (parts.right !== undefined) out += `&R${parts.right}`;\n return out;\n};\n\n/**\n * Set a header by left / center / right parts. `section` defaults to `'odd'`\n * (the standard pages); pass `'first'` or `'even'` to target the alternate\n * sections (Excel auto-flips the corresponding differentOddEven /\n * differentFirst flag).\n */\nexport const setHeaderText = (\n ws: Worksheet,\n parts: { left?: string; center?: string; right?: string },\n section: HeaderFooterSection = 'odd',\n): void => {\n setHeader(ws, section, buildHeaderFooterText(parts));\n};\n\n/** Same shape as {@link setHeaderText} but writes the corresponding footer slot. */\nexport const setFooterText = (\n ws: Worksheet,\n parts: { left?: string; center?: string; right?: string },\n section: HeaderFooterSection = 'odd',\n): void => {\n setFooter(ws, section, buildHeaderFooterText(parts));\n};\n\n/** Push a manual horizontal page break above the given row (1-based). Defaults to `man=true`. */\nexport const addRowBreak = (ws: Worksheet, row: number): PageBreak => {\n const brk: PageBreak = { id: row, man: true, max: 16383 };\n ws.rowBreaks.push(brk);\n return brk;\n};\n\n/** Push a manual vertical page break to the left of the given column (1-based). Defaults to `man=true`. */\nexport const addColBreak = (ws: Worksheet, col: number): PageBreak => {\n const brk: PageBreak = { id: col, man: true, max: 1048575 };\n ws.colBreaks.push(brk);\n return brk;\n};\n\nconst ensurePrintOptions = (ws: Worksheet): PrintOptions => {\n if (!ws.printOptions) ws.printOptions = {};\n return ws.printOptions;\n};\n\n/** Toggle \"Print gridlines\". Mirrors Excel's \"Page Layout → Sheet Options → Gridlines: Print\". */\nexport const setPrintGridLines = (ws: Worksheet, on: boolean): void => {\n const po = ensurePrintOptions(ws);\n po.gridLines = on;\n // Excel pairs gridLines with the gridLinesSet companion flag.\n po.gridLinesSet = on;\n};\n\n/** Toggle \"Print row and column headings\" (the A B C / 1 2 3 strips on the printed page). */\nexport const setPrintHeadings = (ws: Worksheet, on: boolean): void => {\n ensurePrintOptions(ws).headings = on;\n};\n\n/**\n * Toggle horizontal / vertical centering on the printed page. Pass either field\n * to leave the other untouched.\n */\nexport const setPrintCentered = (\n ws: Worksheet,\n opts: { horizontal?: boolean; vertical?: boolean },\n): void => {\n const po = ensurePrintOptions(ws);\n if (opts.horizontal !== undefined) po.horizontalCentered = opts.horizontal;\n if (opts.vertical !== undefined) po.verticalCentered = opts.vertical;\n};\n\n","// Worksheet-level <customProperties> and <webPublishItems>.\n//\n// Both elements live near the bottom of <worksheet> (after tableParts, before\n// extLst per ECMA-376 §18.3.1.43 / §18.3.1.97). Each is a thin shell over a\n// list of children. customProperty references a Custom XML part via `r:id` —\n// the underlying rel is already preserved by the worksheet's `relsExtras`\n// machinery, so we just have to keep the inline element from leaking.\n\n/**\n * One <customProperty>. The `rId` points at a Custom XML part registered in the\n * worksheet rels (e.g. for SharePoint sync metadata).\n */\nexport interface WorksheetCustomProperty {\n name: string;\n /** Worksheet-rels rId pointing at the Custom XML part backing this entry. */\n rId?: string;\n}\n\nexport interface WebPublishItem {\n id: number;\n divId: string;\n sourceType: 'sheet' | 'printArea' | 'autoFilter' | 'range' | 'chart' | 'pivotTable' | 'query' | 'label';\n sourceRef?: string;\n sourceObject?: string;\n destinationFile: string;\n title?: string;\n autoRepublish?: boolean;\n}\n\nexport const makeWorksheetCustomProperty = (\n opts: WorksheetCustomProperty,\n): WorksheetCustomProperty => ({\n name: opts.name,\n ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n});\n\nexport const makeWebPublishItem = (opts: WebPublishItem): WebPublishItem => ({\n id: opts.id,\n divId: opts.divId,\n sourceType: opts.sourceType,\n destinationFile: opts.destinationFile,\n ...(opts.sourceRef !== undefined ? { sourceRef: opts.sourceRef } : {}),\n ...(opts.sourceObject !== undefined ? { sourceObject: opts.sourceObject } : {}),\n ...(opts.title !== undefined ? { title: opts.title } : {}),\n ...(opts.autoRepublish !== undefined ? { autoRepublish: opts.autoRepublish } : {}),\n});\n","// Worksheet-level <phoneticPr> for East-Asian (mostly Japanese) furigana\n// rendering.\n//\n// Excel uses `<phoneticPr fontId=\"...\" type=\"...\" alignment=\"...\"/>` to drive\n// how it renders the small phonetic annotation strip above CJK characters in\n// cells. The per-cell `<rPh>` annotations live on shared-string entries and are\n// a separate concern (richer model).\n\nexport type PhoneticType = 'halfwidthKatakana' | 'fullwidthKatakana' | 'Hiragana' | 'noConversion';\nexport type PhoneticAlignment = 'noControl' | 'left' | 'center' | 'distributed';\n\nexport interface WorksheetPhoneticProperties {\n /** Font index in the workbook's stylesheet for the furigana glyphs. */\n fontId?: number;\n /** Conversion mode the IME should default to when adding furigana. */\n type?: PhoneticType;\n /** Horizontal alignment of the furigana strip relative to the base text. */\n alignment?: PhoneticAlignment;\n}\n\nexport const makeWorksheetPhoneticProperties = (\n opts: WorksheetPhoneticProperties = {},\n): WorksheetPhoneticProperties => ({ ...opts });\n","// Worksheet-level <dataConsolidate>. Used by Excel's\n// Data → Consolidate dialog to join multiple ranges into one summary\n// table. Per ECMA-376 §18.3.1.20, §18.3.1.22 (dataRef).\n\nexport type DataConsolidateFunction =\n | 'average'\n | 'count'\n | 'countNums'\n | 'max'\n | 'min'\n | 'product'\n | 'stdDev'\n | 'stdDevp'\n | 'sum'\n | 'var'\n | 'varp';\n\nexport interface DataReference {\n /** Optional name of the source range (defined-name reference). */\n name?: string;\n /** External range ref like \"Sheet1!$A$1:$B$10\" — required when no `rId`. */\n ref?: string;\n /** Optional friendly sheet name for display. */\n sheet?: string;\n /** rels rId pointing at an external workbook part — round-tripped verbatim. */\n rId?: string;\n}\n\nexport interface DataConsolidate {\n /** Aggregation function applied to overlapping cells. Default `sum`. */\n function?: DataConsolidateFunction;\n /** Use top-row labels as category keys. */\n topLabels?: boolean;\n /** Use left-column labels as category keys. */\n leftLabels?: boolean;\n /** \"Create links to source data\" (Excel's checkbox). */\n link?: boolean;\n /** Optional `<dataRefs>` list (one entry per source range). */\n dataRefs?: DataReference[];\n /**\n * `startLabels` was added in a later schema revision — round-tripped\n * verbatim when present.\n */\n startLabels?: string;\n}\n\nexport const makeDataConsolidate = (opts: DataConsolidate = {}): DataConsolidate => {\n const out: DataConsolidate = {};\n if (opts.function !== undefined) out.function = opts.function;\n if (opts.topLabels !== undefined) out.topLabels = opts.topLabels;\n if (opts.leftLabels !== undefined) out.leftLabels = opts.leftLabels;\n if (opts.link !== undefined) out.link = opts.link;\n if (opts.dataRefs !== undefined) out.dataRefs = opts.dataRefs.map((r) => ({ ...r }));\n if (opts.startLabels !== undefined) out.startLabels = opts.startLabels;\n return out;\n};\n","// Worksheet-level <scenarios> — Excel's Data → What-If Analysis →\n// Scenario Manager. Per ECMA-376 §18.3.1.74 / §18.3.1.41 (inputCells)\n// and openpyxl/openpyxl/worksheet/scenario.py.\n\nimport type { MultiCellRange } from './cell-range';\n\n/** One <inputCells> entry — a single (cell, override-value) pair. */\nexport interface ScenarioInputCell {\n /** Single-cell ref, e.g. \"B5\". */\n ref: string;\n /** Stored as a string on the wire (Excel uses int / float / text format codes via numFmtId). */\n val: string;\n /** Mark this entry as deleted in the scenario history. */\n deleted?: boolean;\n /** Marks an undone change in the scenario history. */\n undone?: boolean;\n /** Number-format index used to display the override. */\n numFmtId?: number;\n}\n\nexport interface Scenario {\n name: string;\n inputCells: ScenarioInputCell[];\n /** When true, Excel disables editing the scenario unless the workbook protection password is supplied. */\n locked?: boolean;\n /** Hide the scenario from the picker dialog. */\n hidden?: boolean;\n user?: string;\n comment?: string;\n}\n\nexport interface ScenarioList {\n scenarios: Scenario[];\n /** Index of the currently active scenario. */\n current?: number;\n /** Index of the scenario shown by default. */\n show?: number;\n /** Range that the scenarios change (output cells). */\n sqref?: MultiCellRange;\n}\n\nexport const makeScenarioInputCell = (opts: ScenarioInputCell): ScenarioInputCell => ({\n ref: opts.ref,\n val: opts.val,\n ...(opts.deleted !== undefined ? { deleted: opts.deleted } : {}),\n ...(opts.undone !== undefined ? { undone: opts.undone } : {}),\n ...(opts.numFmtId !== undefined ? { numFmtId: opts.numFmtId } : {}),\n});\n\nexport const makeScenario = (opts: Scenario): Scenario => ({\n name: opts.name,\n inputCells: opts.inputCells.slice(),\n ...(opts.locked !== undefined ? { locked: opts.locked } : {}),\n ...(opts.hidden !== undefined ? { hidden: opts.hidden } : {}),\n ...(opts.user !== undefined ? { user: opts.user } : {}),\n ...(opts.comment !== undefined ? { comment: opts.comment } : {}),\n});\n\nexport const makeScenarioList = (opts: Partial<ScenarioList> = {}): ScenarioList => ({\n scenarios: opts.scenarios?.slice() ?? [],\n ...(opts.current !== undefined ? { current: opts.current } : {}),\n ...(opts.show !== undefined ? { show: opts.show } : {}),\n ...(opts.sqref !== undefined ? { sqref: opts.sqref } : {}),\n});\n"],"mappings":";;;AAwBA,SAAgB,eAAe,MAAmE;CAChG,OAAO;EAAE,KAAK,KAAK;EAAK,eAAe,KAAK,iBAAiB,CAAC;CAAE;AAClE;AAEA,SAAgB,iBAAiB,MAIhB;CACf,OAAO;EACL,MAAM;EACN,OAAO,KAAK;EACZ,QAAQ,CAAC,GAAG,KAAK,MAAM;EACvB,GAAI,KAAK,UAAU,KAAA,IAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;CAC1D;AACF;;;ACYA,MAAa,iBAAiB,SAA4B,EAAE,IAAI;AAEhE,SAAgB,iBACd,MACc;CACd,OAAO;EACL,OAAO,KAAK;EACZ,GAAI,KAAK,cAAc,KAAA,IAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;EACpE,GAAI,KAAK,qBAAqB,KAAA,IAAY,EAAE,kBAAkB,KAAK,iBAAiB,IAAI,CAAC;EACzF,GAAI,KAAK,uBAAuB,KAAA,IAAY,EAAE,oBAAoB,KAAK,mBAAmB,IAAI,CAAC;EAC/F,G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 -0,0 +1,221 @@
1
+ import { a as OpenXmlNotImplementedError, i as OpenXmlIoError } from "./exceptions-D-CFwxgm.mjs";
2
+ import { Zip, ZipDeflate, ZipPassThrough } from "fflate";
3
+ //#region src/zip/zip64-patch.ts
4
+ const ZIP32_MAX_ENTRIES$1 = 65535;
5
+ const ZIP32_MAX_U32 = 4294967295;
6
+ const SIG_EOCD = 101010256;
7
+ const SIG_ZIP64_EOCD = 101075792;
8
+ const SIG_ZIP64_EOCD_LOCATOR = 117853008;
9
+ const ZIP64_EOCD_SIZE = 56;
10
+ const ZIP64_LOCATOR_SIZE = 20;
11
+ const u16 = (b, o) => (b[o] ?? 0) | (b[o + 1] ?? 0) << 8;
12
+ const u32 = (b, o) => {
13
+ const v0 = b[o] ?? 0;
14
+ const v1 = b[o + 1] ?? 0;
15
+ const v2 = b[o + 2] ?? 0;
16
+ const v3 = b[o + 3] ?? 0;
17
+ return (v0 | v1 << 8 | v2 << 16 | v3 << 24) >>> 0;
18
+ };
19
+ const writeU16 = (b, o, v) => {
20
+ b[o] = v & 255;
21
+ b[o + 1] = v >>> 8 & 255;
22
+ };
23
+ const writeU32 = (b, o, v) => {
24
+ b[o] = v & 255;
25
+ b[o + 1] = v >>> 8 & 255;
26
+ b[o + 2] = v >>> 16 & 255;
27
+ b[o + 3] = v >>> 24 & 255;
28
+ };
29
+ const writeU64 = (b, o, v) => {
30
+ const lo = v >>> 0;
31
+ const hi = Math.floor(v / 4294967296) >>> 0;
32
+ writeU32(b, o, lo);
33
+ writeU32(b, o + 4, hi);
34
+ };
35
+ const findEocdOffset = (bytes) => {
36
+ const minOffset = Math.max(0, bytes.length - 65557);
37
+ for (let p = bytes.length - 22; p >= minOffset; p--) if (u32(bytes, p) === SIG_EOCD) {
38
+ const commentLen = u16(bytes, p + 20);
39
+ if (p + 22 + commentLen === bytes.length) return p;
40
+ }
41
+ throw new OpenXmlIoError("zip64-patch: no End-of-Central-Directory signature found");
42
+ };
43
+ /**
44
+ * Splice ZIP64 EOCD record + locator into fflate's final chunk and
45
+ * patch the trailing EOCD entry-count fields with the 0xFFFF sentinel.
46
+ *
47
+ * `finalChunk` must be the [CD | EOCD] block fflate emits as its last
48
+ * ondata callback (everything before it is per-entry LFH/data/DD that
49
+ * we leave untouched). Returns a new chunk; the input is not mutated.
50
+ *
51
+ * Assumes per-entry sizes and central-directory offset fit in 32 bits;
52
+ * throws if not (xlsx archives never approach those limits).
53
+ */
54
+ function applyZip64EntryCountPatch(finalChunk, totalEntries) {
55
+ if (totalEntries <= ZIP32_MAX_ENTRIES$1) return finalChunk;
56
+ const eocdOffset = findEocdOffset(finalChunk);
57
+ const cdSize = u32(finalChunk, eocdOffset + 12);
58
+ const cdOffset = u32(finalChunk, eocdOffset + 16);
59
+ const commentLen = u16(finalChunk, eocdOffset + 20);
60
+ if (cdSize === ZIP32_MAX_U32 || cdOffset === ZIP32_MAX_U32) throw new OpenXmlNotImplementedError("zip64-patch: archive size or central-directory offset exceeds 4 GiB; full ZIP64 size support is not implemented (xlsx in practice stays well under 4 GiB).");
61
+ const globalEocdOffset = cdOffset + cdSize;
62
+ const eocdLen = 22 + commentLen;
63
+ const newChunkLen = eocdOffset + ZIP64_EOCD_SIZE + ZIP64_LOCATOR_SIZE + eocdLen;
64
+ const out = new Uint8Array(newChunkLen);
65
+ out.set(finalChunk.subarray(0, eocdOffset), 0);
66
+ const zip64Eocd = out.subarray(eocdOffset, eocdOffset + ZIP64_EOCD_SIZE);
67
+ writeU32(zip64Eocd, 0, SIG_ZIP64_EOCD);
68
+ writeU64(zip64Eocd, 4, ZIP64_EOCD_SIZE - 12);
69
+ writeU16(zip64Eocd, 12, 45);
70
+ writeU16(zip64Eocd, 14, 45);
71
+ writeU32(zip64Eocd, 16, 0);
72
+ writeU32(zip64Eocd, 20, 0);
73
+ writeU64(zip64Eocd, 24, totalEntries);
74
+ writeU64(zip64Eocd, 32, totalEntries);
75
+ writeU64(zip64Eocd, 40, cdSize);
76
+ writeU64(zip64Eocd, 48, cdOffset);
77
+ const locOffset = eocdOffset + ZIP64_EOCD_SIZE;
78
+ const locator = out.subarray(locOffset, locOffset + ZIP64_LOCATOR_SIZE);
79
+ writeU32(locator, 0, SIG_ZIP64_EOCD_LOCATOR);
80
+ writeU32(locator, 4, 0);
81
+ writeU64(locator, 8, globalEocdOffset);
82
+ writeU32(locator, 16, 1);
83
+ const newEocdOffset = locOffset + ZIP64_LOCATOR_SIZE;
84
+ out.set(finalChunk.subarray(eocdOffset, eocdOffset + eocdLen), newEocdOffset);
85
+ writeU16(out, newEocdOffset + 8, ZIP32_MAX_ENTRIES$1);
86
+ writeU16(out, newEocdOffset + 10, ZIP32_MAX_ENTRIES$1);
87
+ return out;
88
+ }
89
+ //#endregion
90
+ //#region src/zip/writer.ts
91
+ const ZIP32_MAX_ENTRIES = 65535;
92
+ /**
93
+ * ZIP writer backed by fflate's streaming `Zip` class. Entries are pushed
94
+ * through `ZipDeflate` / `ZipPassThrough` streams as they arrive, so peak
95
+ * memory stays at the size of the in-flight entry plus the output buffer rather
96
+ * than the full archive.
97
+ *
98
+ * The sink contract is `toBytes()`, but that name is historical: the sink is
99
+ * driven by a chunked `write(chunk)` API that fans bytes out as they arrive.
100
+ * The buffered Node/browser sinks (`toBuffer`, `toBlob`, `toArrayBuffer`)
101
+ * concatenate the chunks for a single-shot result; streaming sinks
102
+ * (`toFile`, `toWritable`) forward each chunk to disk / the wrapped writable
103
+ * without ever holding the full archive resident. Either kind plugs in here.
104
+ */
105
+ function createZipWriter(sink) {
106
+ const writer = sink.toBytes();
107
+ let finalised;
108
+ let endCalled = false;
109
+ const seen = /* @__PURE__ */ new Set();
110
+ const errors = [];
111
+ let finalChunk;
112
+ let zipFinishResolve;
113
+ const zipFinishPromise = new Promise((resolve) => {
114
+ zipFinishResolve = resolve;
115
+ });
116
+ const zip = new Zip((err, chunk, final) => {
117
+ if (err) {
118
+ errors.push(err instanceof Error ? err : new Error(String(err)));
119
+ return;
120
+ }
121
+ if (chunk && chunk.byteLength > 0) if (final) finalChunk = chunk;
122
+ else writer.write(chunk);
123
+ if (final && zipFinishResolve) {
124
+ zipFinishResolve();
125
+ zipFinishResolve = void 0;
126
+ }
127
+ });
128
+ let streamingOpen = false;
129
+ const guardAdd = (path) => {
130
+ if (finalised !== void 0) throw new OpenXmlIoError("createZipWriter: addEntry after finalize");
131
+ if (streamingOpen) throw new OpenXmlIoError("createZipWriter: a streaming entry is still open — call end() first");
132
+ if (seen.has(path)) throw new OpenXmlIoError(`createZipWriter: duplicate entry "${path}"`);
133
+ };
134
+ return {
135
+ async addEntry(path, bytes, opts) {
136
+ if (!(bytes instanceof Uint8Array)) throw new OpenXmlIoError("createZipWriter: ReadableStream entries are not yet supported (deferred to streaming writer)");
137
+ guardAdd(path);
138
+ seen.add(path);
139
+ const file = opts?.compress ?? true ? new ZipDeflate(path) : new ZipPassThrough(path);
140
+ try {
141
+ zip.add(file);
142
+ file.push(bytes, true);
143
+ } catch (cause) {
144
+ throw new OpenXmlIoError(`createZipWriter: failed to add entry "${path}"`, { cause });
145
+ }
146
+ if (errors.length > 0) throw new OpenXmlIoError("createZipWriter: stream error during addEntry", { cause: errors[0] });
147
+ },
148
+ addStreamingEntry(path, opts) {
149
+ guardAdd(path);
150
+ seen.add(path);
151
+ streamingOpen = true;
152
+ const file = opts?.compress ?? true ? new ZipDeflate(path) : new ZipPassThrough(path);
153
+ try {
154
+ zip.add(file);
155
+ } catch (cause) {
156
+ streamingOpen = false;
157
+ throw new OpenXmlIoError(`createZipWriter: failed to open streaming entry "${path}"`, { cause });
158
+ }
159
+ let ended = false;
160
+ return {
161
+ write(chunk) {
162
+ if (ended) throw new OpenXmlIoError(`createZipWriter: write after end on "${path}"`);
163
+ if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError(`createZipWriter: streaming entry "${path}" chunk is not a Uint8Array`);
164
+ if (chunk.byteLength === 0) return;
165
+ try {
166
+ file.push(chunk, false);
167
+ } catch (cause) {
168
+ throw new OpenXmlIoError(`createZipWriter: failed to push chunk on "${path}"`, { cause });
169
+ }
170
+ if (errors.length > 0) throw new OpenXmlIoError("createZipWriter: stream error during write", { cause: errors[0] });
171
+ },
172
+ async end() {
173
+ if (ended) return;
174
+ ended = true;
175
+ try {
176
+ file.push(new Uint8Array(0), true);
177
+ } catch (cause) {
178
+ throw new OpenXmlIoError(`createZipWriter: failed to end streaming entry "${path}"`, { cause });
179
+ }
180
+ streamingOpen = false;
181
+ if (errors.length > 0) throw new OpenXmlIoError("createZipWriter: stream error during end", { cause: errors[0] });
182
+ }
183
+ };
184
+ },
185
+ async finalize() {
186
+ if (finalised !== void 0) return finalised;
187
+ if (streamingOpen) throw new OpenXmlIoError("createZipWriter: cannot finalize while a streaming entry is open");
188
+ finalised = (async () => {
189
+ try {
190
+ if (!endCalled) {
191
+ zip.end();
192
+ endCalled = true;
193
+ }
194
+ } catch (cause) {
195
+ throw new OpenXmlIoError("createZipWriter: failed to finalize zip archive", { cause });
196
+ }
197
+ await zipFinishPromise;
198
+ if (errors.length > 0) throw new OpenXmlIoError("createZipWriter: stream error during finalize", { cause: errors[0] });
199
+ if (finalChunk) {
200
+ const patched = seen.size > ZIP32_MAX_ENTRIES ? applyZip64EntryCountPatch(finalChunk, seen.size) : finalChunk;
201
+ writer.write(patched);
202
+ }
203
+ return writer.finish();
204
+ })();
205
+ return finalised;
206
+ },
207
+ abort(cause) {
208
+ if (finalised !== void 0) return;
209
+ finalised = Promise.resolve(new Uint8Array(0));
210
+ if (zipFinishResolve) {
211
+ zipFinishResolve();
212
+ zipFinishResolve = void 0;
213
+ }
214
+ writer.abort?.(cause);
215
+ }
216
+ };
217
+ }
218
+ //#endregion
219
+ export { createZipWriter as t };
220
+
221
+ //# sourceMappingURL=writer-DspzfkNA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-DspzfkNA.mjs","names":["ZIP32_MAX_ENTRIES"],"sources":["../src/zip/zip64-patch.ts","../src/zip/writer.ts"],"sourcesContent":["// ZIP64 post-processing for archives whose entry count exceeds the\n// 16-bit ZIP32 cap (65535). fflate's `Zip` writer always emits a\n// plain ZIP32 EOCD; for archives with more entries we keep its\n// per-entry LFH/CDH layout (correct as long as no individual size or\n// offset overflows 32 bits) and splice in a ZIP64 End-of-Central-\n// Directory record + locator before the EOCD, then patch the EOCD's\n// entry-count fields with the 0xFFFF sentinel that signals \"consult\n// the ZIP64 record for the real values\".\n//\n// The input is fflate's *final* chunk — the trailing [CD | EOCD] block\n// it emits in one ondata callback when `Zip.end()` is called. The\n// preceding entry-data chunks have already been streamed to the sink,\n// so we operate on the final chunk in isolation. The global EOCD\n// offset (needed for the ZIP64 locator) is derivable from cd_offset +\n// cd_size carried in the EOCD itself, so no external bookkeeping is\n// required.\n//\n// Out of scope: per-entry sizes or central-directory offsets > 4 GiB.\n// xlsx archives don't approach those limits in practice; we throw a\n// clear error if we detect overflow there.\n\nimport { OpenXmlIoError, OpenXmlNotImplementedError } from '../utils/exceptions';\n\nconst ZIP32_MAX_ENTRIES = 0xffff;\nconst ZIP32_MAX_U32 = 0xffffffff;\nconst SIG_EOCD = 0x06054b50;\nconst SIG_ZIP64_EOCD = 0x06064b50;\nconst SIG_ZIP64_EOCD_LOCATOR = 0x07064b50;\n\nconst ZIP64_EOCD_SIZE = 56;\nconst ZIP64_LOCATOR_SIZE = 20;\n\nconst u16 = (b: Uint8Array, o: number): number => (b[o] ?? 0) | ((b[o + 1] ?? 0) << 8);\n\nconst u32 = (b: Uint8Array, o: number): number => {\n const v0 = b[o] ?? 0;\n const v1 = b[o + 1] ?? 0;\n const v2 = b[o + 2] ?? 0;\n const v3 = b[o + 3] ?? 0;\n return (v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)) >>> 0;\n};\n\nconst writeU16 = (b: Uint8Array, o: number, v: number): void => {\n b[o] = v & 0xff;\n b[o + 1] = (v >>> 8) & 0xff;\n};\n\nconst writeU32 = (b: Uint8Array, o: number, v: number): void => {\n b[o] = v & 0xff;\n b[o + 1] = (v >>> 8) & 0xff;\n b[o + 2] = (v >>> 16) & 0xff;\n b[o + 3] = (v >>> 24) & 0xff;\n};\n\nconst writeU64 = (b: Uint8Array, o: number, v: number): void => {\n // JS Number safely represents integers up to 2^53 - 1, well beyond\n // anything we'd ever emit here. Split via Math.floor + modulo to\n // avoid bit-shift truncation at 32 bits.\n const lo = v >>> 0;\n const hi = Math.floor(v / 0x100000000) >>> 0;\n writeU32(b, o, lo);\n writeU32(b, o + 4, hi);\n};\n\nconst findEocdOffset = (bytes: Uint8Array): number => {\n // EOCD is min 22 bytes and may be followed by up to 65535 bytes of\n // archive comment. Scan backwards from the latest possible position.\n const minOffset = Math.max(0, bytes.length - (22 + 0xffff));\n for (let p = bytes.length - 22; p >= minOffset; p--) {\n if (u32(bytes, p) === SIG_EOCD) {\n const commentLen = u16(bytes, p + 20);\n if (p + 22 + commentLen === bytes.length) return p;\n }\n }\n throw new OpenXmlIoError('zip64-patch: no End-of-Central-Directory signature found');\n};\n\n/**\n * Splice ZIP64 EOCD record + locator into fflate's final chunk and\n * patch the trailing EOCD entry-count fields with the 0xFFFF sentinel.\n *\n * `finalChunk` must be the [CD | EOCD] block fflate emits as its last\n * ondata callback (everything before it is per-entry LFH/data/DD that\n * we leave untouched). Returns a new chunk; the input is not mutated.\n *\n * Assumes per-entry sizes and central-directory offset fit in 32 bits;\n * throws if not (xlsx archives never approach those limits).\n */\nexport function applyZip64EntryCountPatch(finalChunk: Uint8Array, totalEntries: number): Uint8Array {\n if (totalEntries <= ZIP32_MAX_ENTRIES) return finalChunk;\n\n const eocdOffset = findEocdOffset(finalChunk);\n\n const cdSize = u32(finalChunk, eocdOffset + 12);\n const cdOffset = u32(finalChunk, eocdOffset + 16);\n const commentLen = u16(finalChunk, eocdOffset + 20);\n\n if (cdSize === ZIP32_MAX_U32 || cdOffset === ZIP32_MAX_U32) {\n throw new OpenXmlNotImplementedError(\n 'zip64-patch: archive size or central-directory offset exceeds 4 GiB; full ZIP64 size support is not implemented (xlsx in practice stays well under 4 GiB).',\n );\n }\n\n // Where the EOCD starts in the *global* archive (before our patch).\n // CD precedes EOCD with no gap, so global EOCD offset is just\n // cd_offset + cd_size — the locator points here.\n const globalEocdOffset = cdOffset + cdSize;\n\n const eocdLen = 22 + commentLen;\n const newChunkLen = eocdOffset + ZIP64_EOCD_SIZE + ZIP64_LOCATOR_SIZE + eocdLen;\n const out = new Uint8Array(newChunkLen);\n\n // Original CD bytes (everything before the EOCD).\n out.set(finalChunk.subarray(0, eocdOffset), 0);\n\n // ZIP64 EOCD record (56 bytes total).\n const zip64Eocd = out.subarray(eocdOffset, eocdOffset + ZIP64_EOCD_SIZE);\n writeU32(zip64Eocd, 0, SIG_ZIP64_EOCD);\n // size_of_zip64_eocd = total_size - 12 (size field excludes signature + this field itself)\n writeU64(zip64Eocd, 4, ZIP64_EOCD_SIZE - 12);\n writeU16(zip64Eocd, 12, 45); // version made by (4.5 — first ZIP64 spec)\n writeU16(zip64Eocd, 14, 45); // version needed\n writeU32(zip64Eocd, 16, 0); // disk_number\n writeU32(zip64Eocd, 20, 0); // disk_with_cd\n writeU64(zip64Eocd, 24, totalEntries); // entries_on_this_disk\n writeU64(zip64Eocd, 32, totalEntries); // total_entries\n writeU64(zip64Eocd, 40, cdSize); // cd_size\n writeU64(zip64Eocd, 48, cdOffset); // cd_offset\n\n // ZIP64 EOCD locator (20 bytes).\n const locOffset = eocdOffset + ZIP64_EOCD_SIZE;\n const locator = out.subarray(locOffset, locOffset + ZIP64_LOCATOR_SIZE);\n writeU32(locator, 0, SIG_ZIP64_EOCD_LOCATOR);\n writeU32(locator, 4, 0); // disk_with_zip64_eocd\n writeU64(locator, 8, globalEocdOffset);\n writeU32(locator, 16, 1); // total_disks\n\n // New EOCD: copy original then patch entry counts to the 0xFFFF\n // sentinel. (fflate writes the low 16 bits of the true count there,\n // which confuses readers that don't first look for the ZIP64 record.)\n const newEocdOffset = locOffset + ZIP64_LOCATOR_SIZE;\n out.set(finalChunk.subarray(eocdOffset, eocdOffset + eocdLen), newEocdOffset);\n writeU16(out, newEocdOffset + 8, ZIP32_MAX_ENTRIES);\n writeU16(out, newEocdOffset + 10, ZIP32_MAX_ENTRIES);\n\n return out;\n}\n","// ZIP write layer. Streaming-deflate via fflate's `Zip` + per-entry\n// `ZipDeflate` / `ZipPassThrough` so the writer never holds the whole archive\n// in memory. Each addEntry pushes its bytes through the deflate stream and the\n// resulting ZIP chunks land on the sink one at a time — the buffered\n// `toBytes()` sink concatenates them on finish, while a streaming sink can\n// flush them as they arrive.\n//\n// ZIP64 (entry count > 65535): fflate's `Zip` emits a plain ZIP32 EOCD in all\n// cases, so on finalize we splice in a ZIP64 EOCD record + locator when needed\n// via `applyZip64EntryCountPatch`. That keeps the per-entry LFH/CDH layout\n// fflate produces and only rewrites the trailing records.\n//\n// Scope: this covers the entry-count-overflow case (the limit xlsx archives\n// realistically hit — `tens of millions of cells` → tens of thousands of\n// worksheet entries via the streaming writer). Per-entry compressed/uncompressed\n// sizes and the central-directory offset must still fit in 32 bits (≤ 4 GiB\n// each); a single >4 GiB entry would need full ZIP64 size support and\n// `applyZip64EntryCountPatch` throws `OpenXmlNotImplementedError` if we ever\n// detect that. xlsx workbooks don't approach that limit in practice, but the\n// constraint is real — surface it in your own size estimates.\n\nimport { Zip, ZipDeflate, ZipPassThrough } from 'fflate';\nimport type { XlsxSink } from '../io/sink';\nimport { OpenXmlIoError } from '../utils/exceptions';\nimport { applyZip64EntryCountPatch } from './zip64-patch';\n\nconst ZIP32_MAX_ENTRIES = 0xffff;\n\nexport interface ZipWriter {\n /**\n * Stage an entry. Bytes are pushed through fflate's `ZipDeflate` /\n * `ZipPassThrough` stream synchronously, so the deflated chunks land on the\n * sink as the call runs (no per-entry buffering — see the streaming-behaviour\n * test in `tests/phase-1/zip/writer.test.ts`). Streams (`ReadableStream`)\n * are not accepted today; pass an already-materialised entry, or use\n * {@link addStreamingEntry} for chunked writes.\n *\n * `compress` defaults to `true`. Pass `false` for already-compressed payloads\n * (PNG/JPEG/zip-as-binary content like vbaProject.bin) so we don't pay\n * deflate costs for no gain.\n */\n addEntry(path: string, bytes: Uint8Array | ReadableStream<Uint8Array>, opts?: { compress?: boolean }): Promise<void>;\n\n /**\n * Open a streaming entry. Returns a writer the caller can `write()` chunks to\n * and `end()` to seal the entry. Each chunk pushes through the same fflate\n * `ZipDeflate` / `ZipPassThrough` machinery as `addEntry`, so peak memory\n * stays at one chunk + deflate scratch even for multi-GB worksheets.\n *\n * Sequencing: only one streaming entry may be open at a time — `addEntry` and\n * a second `addStreamingEntry` both throw until the current entry's `end()`\n * resolves.\n */\n addStreamingEntry(path: string, opts?: { compress?: boolean }): StreamingEntryWriter;\n\n /**\n * Build the central directory and flush all bytes through the sink.\n * Idempotent; subsequent calls resolve to the same payload.\n */\n finalize(): Promise<Uint8Array>;\n\n /**\n * Release the sink and underlying writer without producing a valid archive.\n * Use this from a surrounding catch block when serialization fails part-way\n * through — without it, streaming sinks (`toFile` / `toWritable`) keep their\n * file descriptors / writables open and the half-written xlsx looks valid on\n * disk. Idempotent; safe to call after `finalize()`.\n */\n abort(cause?: unknown): void;\n}\n\n/** Writer handle for a single streaming entry. */\nexport interface StreamingEntryWriter {\n /** Push a chunk of bytes (already-encoded). Throws after `end()`. */\n write(chunk: Uint8Array): void;\n /** Seal the entry. Subsequent `write()` throws. Idempotent. */\n end(): Promise<void>;\n}\n\n/**\n * ZIP writer backed by fflate's streaming `Zip` class. Entries are pushed\n * through `ZipDeflate` / `ZipPassThrough` streams as they arrive, so peak\n * memory stays at the size of the in-flight entry plus the output buffer rather\n * than the full archive.\n *\n * The sink contract is `toBytes()`, but that name is historical: the sink is\n * driven by a chunked `write(chunk)` API that fans bytes out as they arrive.\n * The buffered Node/browser sinks (`toBuffer`, `toBlob`, `toArrayBuffer`)\n * concatenate the chunks for a single-shot result; streaming sinks\n * (`toFile`, `toWritable`) forward each chunk to disk / the wrapped writable\n * without ever holding the full archive resident. Either kind plugs in here.\n */\nexport function createZipWriter(sink: XlsxSink): ZipWriter {\n const writer = sink.toBytes();\n let finalised: Promise<Uint8Array> | undefined;\n let endCalled = false;\n const seen = new Set<string>();\n const errors: Error[] = [];\n // fflate emits the [CD | EOCD] block in a single ondata call with\n // `final=true`. We capture only that chunk so we can apply the ZIP64 patch on\n // finalize; all preceding entry-data chunks stream straight to the sink to\n // preserve the writer's incremental flushing contract.\n let finalChunk: Uint8Array | undefined;\n let zipFinishResolve: (() => void) | undefined;\n const zipFinishPromise = new Promise<void>((resolve) => {\n zipFinishResolve = resolve;\n });\n\n const zip = new Zip((err, chunk, final) => {\n if (err) {\n errors.push(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n // ZipDeflate emits an empty trailer chunk on the final callback even when\n // there are no bytes; guard against pushing an undefined chunk.\n if (chunk && chunk.byteLength > 0) {\n if (final) {\n // Buffer the trailing CD + EOCD block; written after possible patch.\n finalChunk = chunk;\n } else {\n writer.write(chunk);\n }\n }\n if (final && zipFinishResolve) {\n zipFinishResolve();\n zipFinishResolve = undefined;\n }\n });\n\n let streamingOpen = false;\n\n const guardAdd = (path: string): void => {\n if (finalised !== undefined) {\n throw new OpenXmlIoError('createZipWriter: addEntry after finalize');\n }\n if (streamingOpen) {\n throw new OpenXmlIoError('createZipWriter: a streaming entry is still open — call end() first');\n }\n if (seen.has(path)) {\n throw new OpenXmlIoError(`createZipWriter: duplicate entry \"${path}\"`);\n }\n };\n\n return {\n async addEntry(path, bytes, opts) {\n if (!(bytes instanceof Uint8Array)) {\n throw new OpenXmlIoError(\n 'createZipWriter: ReadableStream entries are not yet supported (deferred to streaming writer)',\n );\n }\n guardAdd(path);\n seen.add(path);\n const compress = opts?.compress ?? true;\n const file = compress ? new ZipDeflate(path) : new ZipPassThrough(path);\n try {\n zip.add(file);\n file.push(bytes, /* final */ true);\n } catch (cause) {\n throw new OpenXmlIoError(`createZipWriter: failed to add entry \"${path}\"`, { cause });\n }\n if (errors.length > 0) {\n throw new OpenXmlIoError('createZipWriter: stream error during addEntry', { cause: errors[0] });\n }\n },\n\n addStreamingEntry(path, opts) {\n guardAdd(path);\n seen.add(path);\n streamingOpen = true;\n const compress = opts?.compress ?? true;\n const file = compress ? new ZipDeflate(path) : new ZipPassThrough(path);\n try {\n zip.add(file);\n } catch (cause) {\n streamingOpen = false;\n throw new OpenXmlIoError(`createZipWriter: failed to open streaming entry \"${path}\"`, { cause });\n }\n let ended = false;\n return {\n write(chunk: Uint8Array): void {\n if (ended) throw new OpenXmlIoError(`createZipWriter: write after end on \"${path}\"`);\n if (!(chunk instanceof Uint8Array)) {\n throw new OpenXmlIoError(`createZipWriter: streaming entry \"${path}\" chunk is not a Uint8Array`);\n }\n if (chunk.byteLength === 0) return;\n try {\n file.push(chunk, /* final */ false);\n } catch (cause) {\n throw new OpenXmlIoError(`createZipWriter: failed to push chunk on \"${path}\"`, { cause });\n }\n if (errors.length > 0) {\n throw new OpenXmlIoError('createZipWriter: stream error during write', { cause: errors[0] });\n }\n },\n async end(): Promise<void> {\n if (ended) return;\n ended = true;\n try {\n file.push(new Uint8Array(0), /* final */ true);\n } catch (cause) {\n throw new OpenXmlIoError(`createZipWriter: failed to end streaming entry \"${path}\"`, { cause });\n }\n streamingOpen = false;\n if (errors.length > 0) {\n throw new OpenXmlIoError('createZipWriter: stream error during end', { cause: errors[0] });\n }\n },\n };\n },\n\n async finalize() {\n if (finalised !== undefined) return finalised;\n if (streamingOpen) {\n throw new OpenXmlIoError('createZipWriter: cannot finalize while a streaming entry is open');\n }\n finalised = (async () => {\n try {\n if (!endCalled) {\n zip.end();\n endCalled = true;\n }\n } catch (cause) {\n throw new OpenXmlIoError('createZipWriter: failed to finalize zip archive', { cause });\n }\n await zipFinishPromise;\n if (errors.length > 0) {\n throw new OpenXmlIoError('createZipWriter: stream error during finalize', { cause: errors[0] });\n }\n\n // Apply the ZIP64 patch to fflate's [CD | EOCD] tail when the entry\n // count exceeds ZIP32's 16-bit cap, then flush the (possibly patched)\n // tail to the sink.\n if (finalChunk) {\n const patched =\n seen.size > ZIP32_MAX_ENTRIES\n ? applyZip64EntryCountPatch(finalChunk, seen.size)\n : finalChunk;\n writer.write(patched);\n }\n return writer.finish();\n })();\n return finalised;\n },\n\n abort(cause?: unknown): void {\n if (finalised !== undefined) return;\n // Mark finalised so any subsequent addEntry / finalize short-circuits.\n finalised = Promise.resolve(new Uint8Array(0));\n // Drop fflate's listener — we don't care about further `ondata` callbacks.\n if (zipFinishResolve) {\n zipFinishResolve();\n zipFinishResolve = undefined;\n }\n writer.abort?.(cause);\n },\n };\n}\n"],"mappings":";;;AAuBA,MAAMA,sBAAoB;AAC1B,MAAM,gBAAgB;AACtB,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAE3B,MAAM,OAAO,GAAe,OAAuB,EAAE,MAAM,MAAO,EAAE,IAAI,MAAM,MAAM;AAEpF,MAAM,OAAO,GAAe,MAAsB;CAChD,MAAM,KAAK,EAAE,MAAM;CACnB,MAAM,KAAK,EAAE,IAAI,MAAM;CACvB,MAAM,KAAK,EAAE,IAAI,MAAM;CACvB,MAAM,KAAK,EAAE,IAAI,MAAM;CACvB,QAAQ,KAAM,MAAM,IAAM,MAAM,KAAO,MAAM,QAAS;AACxD;AAEA,MAAM,YAAY,GAAe,GAAW,MAAoB;CAC9D,EAAE,KAAK,IAAI;CACX,EAAE,IAAI,KAAM,MAAM,IAAK;AACzB;AAEA,MAAM,YAAY,GAAe,GAAW,MAAoB;CAC9D,EAAE,KAAK,IAAI;CACX,EAAE,IAAI,KAAM,MAAM,IAAK;CACvB,EAAE,IAAI,KAAM,MAAM,KAAM;CACxB,EAAE,IAAI,KAAM,MAAM,KAAM;AAC1B;AAEA,MAAM,YAAY,GAAe,GAAW,MAAoB;CAI9D,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,KAAK,MAAM,IAAI,UAAW,MAAM;CAC3C,SAAS,GAAG,GAAG,EAAE;CACjB,SAAS,GAAG,IAAI,GA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I;KAC/C,SAAS,OAAO;MACd,MAAM,IAAI,eAAe,mDAAmD,KAAK,IAAI,EAAE,MAAM,CAAC;KAChG;KACA,gBAAgB;KAChB,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,eAAe,4CAA4C,EAAE,OAAO,OAAO,GAAG,CAAC;IAE7F;GACF;EACF;EAEA,MAAM,WAAW;GACf,IAAI,cAAc,KAAA,GAAW,OAAO;GACpC,IAAI,eACF,MAAM,IAAI,eAAe,kEAAkE;GAE7F,aAAa,YAAY;IACvB,IAAI;KACF,IAAI,CAAC,WAAW;MACd,IAAI,IAAI;MACR,YAAY;KACd;IACF,SAAS,OAAO;KACd,MAAM,IAAI,eAAe,mDAAmD,EAAE,MAAM,CAAC;IACvF;IACA,MAAM;IACN,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,eAAe,iDAAiD,EAAE,OAAO,OAAO,GAAG,CAAC;IAMhG,IAAI,YAAY;KACd,MAAM,UACJ,KAAK,OAAO,oBACR,0BAA0B,YAAY,KAAK,IAAI,IAC/C;KACN,OAAO,MAAM,OAAO;IACtB;IACA,OAAO,OAAO,OAAO;GACvB,GAAG;GACH,OAAO;EACT;EAEA,MAAM,OAAuB;GAC3B,IAAI,cAAc,KAAA,GAAW;GAE7B,YAAY,QAAQ,QAAQ,IAAI,WAAW,CAAC,CAAC;GAE7C,IAAI,kBAAkB;IACpB,iBAAiB;IACjB,mBAAmB,KAAA;GACrB;GACA,OAAO,QAAQ,KAAK;EACtB;CACF;AACF"}
@@ -0,0 +1,10 @@
1
+ export type { SaxEvent, SaxInput } from './iterparse';
2
+ export { iterParse } from './iterparse';
3
+ export { ACTIVEX_TYPE, ARC_APP, ARC_CONTENT_TYPES, ARC_CORE, ARC_CUSTOM, ARC_CUSTOM_UI, ARC_ROOT_RELS, ARC_SHARED_STRINGS, ARC_STYLE, ARC_THEME, ARC_WORKBOOK, ARC_WORKBOOK_RELS, C14_NS, C15_NS, C16_NS, CHART_DRAWING_NS, CHART_NS, CHART_TYPE, CHARTSHAPE_TYPE, CHARTSHEET_TYPE, COMMENTS_NS, COMMENTS_TYPE, CONTYPES_NS, COREPROPS_NS, CPROPS_FMTID, CPROPS_TYPE, CTRLPROPS_TYPE, CUSTOMUI_NS, CUSTPROPS_NS, CX_NS, DCMITYPE_NS, DCORE_NS, DCTERMS_NS, DCTERMS_PREFIX, DEFAULT_PREFIXES, DRAWING_NS, DRAWING_TYPE, EXTERNAL_LINK_NS, EXTERNAL_LINK_TYPE, IMAGE_NS, MARKUP_COMPAT_NS, PACKAGE_CHARTS, PACKAGE_CHARTSHEETS, PACKAGE_CHARTSHEETS_RELS, PACKAGE_DRAWINGS, PACKAGE_IMAGES, PACKAGE_PIVOT_CACHE, PACKAGE_PIVOT_TABLE, PACKAGE_PROPS, PACKAGE_RELS, PACKAGE_THEME, PACKAGE_WORKSHEET_RELS, PACKAGE_WORKSHEETS, PACKAGE_XL, PICTURE_NS, PKG_REL_NS, parseQName, qname, REL_NS, SHARED_STRINGS_TYPE, SHEET_DRAWING_NS, SHEET_MAIN_NS, STYLES_TYPE, THEME_TYPE, THREADED_COMMENTS_NS, VBA_TYPE, VML_NS, VTYPES_NS, WORKSHEET_TYPE, X14_NS, X15_NS, X16_NS, XLSM_TYPE, XLSX_TYPE, XLTM_TYPE, XLTX_TYPE, XML_NS, XPROPS_NS, XSI_NS, } from './namespaces';
4
+ export { parseXml } from './parser';
5
+ export type { SerializeOptions } from './serializer';
6
+ export { serializeXml } from './serializer';
7
+ export type { XmlStreamWriter, XmlStreamWriterOptions } from './stream-writer';
8
+ export { createXmlStreamWriter } from './stream-writer';
9
+ export type { XmlNode } from './tree';
10
+ export { appendChild, el, elNs, findChild, findChildren } from './tree';