@office-kit/xlsx 0.11.0 → 0.11.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 (155) hide show
  1. package/README.md +7 -0
  2. package/dist/cell/cell.d.ts +1 -1
  3. package/dist/cell/index.d.ts +4 -4
  4. package/dist/cell/rich-text.d.ts +1 -1
  5. package/dist/cell-BucgGwl3.mjs.map +1 -1
  6. package/dist/cell-style-DuvS_Lsg.mjs.map +1 -1
  7. package/dist/chart/chart-xml.d.ts +1 -1
  8. package/dist/chart/chart.d.ts +3 -3
  9. package/dist/chart/cx/chartex-xml.d.ts +1 -1
  10. package/dist/chart/cx/chartex.d.ts +2 -2
  11. package/dist/chart/index.d.ts +6 -6
  12. package/dist/chart/user-shapes-xml.d.ts +1 -1
  13. package/dist/chart/user-shapes.d.ts +2 -2
  14. package/dist/chart.mjs.map +1 -1
  15. package/dist/chartsheet/chartsheet-xml.d.ts +1 -1
  16. package/dist/chartsheet/chartsheet.d.ts +4 -4
  17. package/dist/chartsheet/index.d.ts +2 -2
  18. package/dist/chartsheet-C3-tqkPy.mjs.map +1 -1
  19. package/dist/coordinate-96Ecci4d.mjs.map +1 -1
  20. package/dist/datetime-B2ySVlXt.mjs.map +1 -1
  21. package/dist/defined-names-CviWmtQg.mjs.map +1 -1
  22. package/dist/differential-DvKU8fJt.mjs.map +1 -1
  23. package/dist/drawing/dml/dml-xml.d.ts +8 -8
  24. package/dist/drawing/dml/effect.d.ts +2 -2
  25. package/dist/drawing/dml/fill.d.ts +1 -1
  26. package/dist/drawing/dml/geometry.d.ts +1 -1
  27. package/dist/drawing/dml/line.d.ts +1 -1
  28. package/dist/drawing/dml/shape-properties.d.ts +5 -5
  29. package/dist/drawing/dml/text.d.ts +4 -4
  30. package/dist/drawing/drawing-xml.d.ts +1 -1
  31. package/dist/drawing/drawing.d.ts +9 -9
  32. package/dist/drawing/index.d.ts +14 -14
  33. package/dist/drawing-BxzLuryn.mjs.map +1 -1
  34. package/dist/drawing.mjs.map +1 -1
  35. package/dist/{escape-DFTE7ZJc.mjs → escape-rnWSPpWY.mjs} +4 -6
  36. package/dist/{escape-DFTE7ZJc.mjs.map → escape-rnWSPpWY.mjs.map} +1 -1
  37. package/dist/formula/tokenizer.d.ts +1 -1
  38. package/dist/formula/translate.d.ts +2 -2
  39. package/dist/io/browser.d.ts +2 -2
  40. package/dist/io/index.d.ts +7 -7
  41. package/dist/io/load.d.ts +4 -4
  42. package/dist/io/node-fs.d.ts +2 -2
  43. package/dist/io/node-save.d.ts +2 -2
  44. package/dist/io/node.d.ts +2 -2
  45. package/dist/io/save.d.ts +2 -2
  46. package/dist/io.mjs +2 -2
  47. package/dist/io.mjs.map +1 -1
  48. package/dist/{load-MyOIjtrU.mjs → load-Bghb1YHY.mjs} +5 -5
  49. package/dist/load-Bghb1YHY.mjs.map +1 -0
  50. package/dist/{manifest-Cm9K7D62.mjs → manifest-pLmx7KYh.mjs} +3 -3
  51. package/dist/manifest-pLmx7KYh.mjs.map +1 -0
  52. package/dist/node.d.ts +3 -3
  53. package/dist/node.mjs +1 -1
  54. package/dist/node.mjs.map +1 -1
  55. package/dist/packaging/core.d.ts +1 -1
  56. package/dist/packaging/custom.d.ts +2 -2
  57. package/dist/packaging/extended.d.ts +2 -2
  58. package/dist/packaging/index.d.ts +10 -10
  59. package/dist/packaging.mjs +1 -1
  60. package/dist/{parser-D3SLaOFe.mjs → parser-By6RWZVW.mjs} +39 -10
  61. package/dist/parser-By6RWZVW.mjs.map +1 -0
  62. package/dist/reader-BNaUTVCy.mjs.map +1 -1
  63. package/dist/{save-2moCT3Af.mjs → save-Bqcf8w3g.mjs} +6 -6
  64. package/dist/save-Bqcf8w3g.mjs.map +1 -0
  65. package/dist/schema/core.d.ts +1 -1
  66. package/dist/schema/index.d.ts +3 -3
  67. package/dist/schema/serialize.d.ts +2 -2
  68. package/dist/serialize-BC2Wu3bR.mjs.map +1 -1
  69. package/dist/{serializer-BtO2TrI7.mjs → serializer-C6nm0mRJ.mjs} +2 -2
  70. package/dist/serializer-C6nm0mRJ.mjs.map +1 -0
  71. package/dist/streaming/index.d.ts +2 -2
  72. package/dist/streaming/read-only.d.ts +4 -4
  73. package/dist/streaming/write-only.d.ts +7 -7
  74. package/dist/streaming.mjs +6 -6
  75. package/dist/streaming.mjs.map +1 -1
  76. package/dist/styles/alignment.schema.d.ts +2 -2
  77. package/dist/styles/borders.d.ts +1 -1
  78. package/dist/styles/borders.schema.d.ts +2 -2
  79. package/dist/styles/cell-style.d.ts +9 -9
  80. package/dist/styles/colors.schema.d.ts +2 -2
  81. package/dist/styles/differential.d.ts +7 -7
  82. package/dist/styles/fills.d.ts +1 -1
  83. package/dist/styles/fills.schema.d.ts +2 -2
  84. package/dist/styles/fonts.d.ts +1 -1
  85. package/dist/styles/fonts.schema.d.ts +2 -2
  86. package/dist/styles/index.d.ts +21 -21
  87. package/dist/styles/named-styles.d.ts +6 -6
  88. package/dist/styles/numbers.schema.d.ts +2 -2
  89. package/dist/styles/protection.schema.d.ts +2 -2
  90. package/dist/styles/stylesheet-reader.d.ts +1 -1
  91. package/dist/styles/stylesheet-writer.d.ts +1 -1
  92. package/dist/styles/stylesheet.d.ts +8 -8
  93. package/dist/{stylesheet-writer-BrOw4jMY.mjs → stylesheet-writer-HxaX7bGy.mjs} +6 -6
  94. package/dist/stylesheet-writer-HxaX7bGy.mjs.map +1 -0
  95. package/dist/table-1P8we2gS.mjs.map +1 -1
  96. package/dist/tree-BX-sRRVp.mjs.map +1 -1
  97. package/dist/user-shapes-DfmCGKB0.mjs.map +1 -1
  98. package/dist/utf8-Tn3nzyik.mjs.map +1 -1
  99. package/dist/utils/escape.d.ts +3 -5
  100. package/dist/utils/index.d.ts +11 -11
  101. package/dist/utils.mjs +1 -1
  102. package/dist/workbook/calc-properties.d.ts +1 -1
  103. package/dist/workbook/defined-names.d.ts +3 -3
  104. package/dist/workbook/index.d.ts +24 -24
  105. package/dist/workbook/protection.d.ts +1 -1
  106. package/dist/workbook/shared-strings.d.ts +2 -2
  107. package/dist/workbook/views.d.ts +1 -1
  108. package/dist/workbook/workbook-properties.d.ts +1 -1
  109. package/dist/workbook/workbook.d.ts +46 -46
  110. package/dist/{workbook-CARZS94U.mjs → workbook-BlZVXiyG.mjs} +3 -3
  111. package/dist/workbook-BlZVXiyG.mjs.map +1 -0
  112. package/dist/workbook.mjs +1 -1
  113. package/dist/workbook.mjs.map +1 -1
  114. package/dist/worksheet/auto-filter.d.ts +1 -1
  115. package/dist/worksheet/cell-range.d.ts +2 -2
  116. package/dist/worksheet/comments-xml.d.ts +1 -1
  117. package/dist/worksheet/conditional-formatting.d.ts +2 -2
  118. package/dist/worksheet/custom-sheet-views.d.ts +2 -2
  119. package/dist/worksheet/data-validations.d.ts +2 -2
  120. package/dist/worksheet/errors.d.ts +1 -1
  121. package/dist/worksheet/hyperlinks.d.ts +1 -1
  122. package/dist/worksheet/index.d.ts +46 -46
  123. package/dist/worksheet/ole-objects.d.ts +1 -1
  124. package/dist/worksheet/page-setup.d.ts +1 -1
  125. package/dist/worksheet/properties.d.ts +1 -1
  126. package/dist/worksheet/protected-ranges.d.ts +1 -1
  127. package/dist/worksheet/protection.d.ts +1 -1
  128. package/dist/worksheet/reader.d.ts +9 -9
  129. package/dist/worksheet/scenarios.d.ts +1 -1
  130. package/dist/worksheet/table-xml.d.ts +1 -1
  131. package/dist/worksheet/table.d.ts +3 -3
  132. package/dist/worksheet/worksheet.d.ts +31 -31
  133. package/dist/worksheet/writer.d.ts +9 -9
  134. package/dist/worksheet-C5Ensf_j.mjs.map +1 -1
  135. package/dist/worksheet.mjs.map +1 -1
  136. package/dist/writer-IyFccCRJ.mjs.map +1 -1
  137. package/dist/xml/index.d.ts +10 -10
  138. package/dist/xml/parser.d.ts +1 -1
  139. package/dist/xml/serializer.d.ts +1 -1
  140. package/dist/xml/stream-writer.d.ts +1 -1
  141. package/dist/xml.mjs +3 -3
  142. package/dist/xml.mjs.map +1 -1
  143. package/dist/zip/decompression-guard.d.ts +1 -1
  144. package/dist/zip/index.d.ts +6 -6
  145. package/dist/zip/random-access-reader.d.ts +2 -2
  146. package/dist/zip/reader.d.ts +2 -2
  147. package/dist/zip/writer.d.ts +1 -1
  148. package/package.json +4 -1
  149. package/dist/load-MyOIjtrU.mjs.map +0 -1
  150. package/dist/manifest-Cm9K7D62.mjs.map +0 -1
  151. package/dist/parser-D3SLaOFe.mjs.map +0 -1
  152. package/dist/save-2moCT3Af.mjs.map +0 -1
  153. package/dist/serializer-BtO2TrI7.mjs.map +0 -1
  154. package/dist/stylesheet-writer-BrOw4jMY.mjs.map +0 -1
  155. package/dist/workbook-CARZS94U.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-Bghb1YHY.mjs","names":[],"sources":["../src/styles/stylesheet-reader.ts","../src/io/load.ts"],"sourcesContent":["// xl/styles.xml → Stylesheet reader.\n//\n// The reader preserves slot ordering exactly — cellXfs[3] in the source xlsx\n// must come back as cellXfs[3] in the loaded Workbook because every `<c s=\"3\">`\n// reference depends on the index, not on the value's identity. That rules out\n// the `addFont` / `addCellXf` dedup helpers (which collapse equal values);\n// instead we push raw entries and rebuild the `_*IdByKey` maps at the end so\n// subsequent edits go back through dedup.\n\nimport { fromTree } from '../schema/serialize.js';\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { stableStringify } from '../utils/stable-stringify.js';\nimport { qname, SHEET_MAIN_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { findChild, findChildren, type XmlNode } from '../xml/tree.js';\nimport { AlignmentSchema } from './alignment.schema.js';\nimport type { Border } from './borders.js';\nimport { BorderSchema } from './borders.schema.js';\nimport type { DifferentialStyle, StylesheetWithDxfs } from './differential.js';\nimport type { Fill } from './fills.js';\nimport { fillFromTree } from './fills.schema.js';\nimport type { Font } from './fonts.js';\nimport { FontSchema } from './fonts.schema.js';\nimport type { StylesheetNamedStyle } from './named-styles.js';\nimport type { NumberFormat } from './numbers.js';\nimport { NumberFormatSchema } from './numbers.schema.js';\nimport { ProtectionSchema } from './protection.schema.js';\nimport { type CellXf, makeStylesheet, type Stylesheet } from './stylesheet.js';\n\nconst STYLESHEET_TAG = qname(SHEET_MAIN_NS, 'styleSheet');\nconst FONTS_TAG = qname(SHEET_MAIN_NS, 'fonts');\nconst FILLS_TAG = qname(SHEET_MAIN_NS, 'fills');\nconst BORDERS_TAG = qname(SHEET_MAIN_NS, 'borders');\nconst NUMFMTS_TAG = qname(SHEET_MAIN_NS, 'numFmts');\nconst NUMFMT_TAG = qname(SHEET_MAIN_NS, 'numFmt');\nconst CELLXFS_TAG = qname(SHEET_MAIN_NS, 'cellXfs');\nconst CELLSTYLEXFS_TAG = qname(SHEET_MAIN_NS, 'cellStyleXfs');\nconst CELLSTYLES_TAG = qname(SHEET_MAIN_NS, 'cellStyles');\nconst CELLSTYLE_TAG = qname(SHEET_MAIN_NS, 'cellStyle');\nconst DXFS_TAG = qname(SHEET_MAIN_NS, 'dxfs');\nconst DXF_TAG = qname(SHEET_MAIN_NS, 'dxf');\nconst XF_TAG = qname(SHEET_MAIN_NS, 'xf');\n// Every `<styleSheet>` child this reader turns into typed model state. Anything\n// else — `<tableStyles>`, `<colors>`, `<extLst>` — is kept verbatim instead.\nconst MODELED_SECTION_TAGS: ReadonlySet<string> = new Set([\n NUMFMTS_TAG,\n FONTS_TAG,\n FILLS_TAG,\n BORDERS_TAG,\n CELLSTYLEXFS_TAG,\n CELLXFS_TAG,\n CELLSTYLES_TAG,\n DXFS_TAG,\n]);\nconst FONT_TAG = qname(SHEET_MAIN_NS, 'font');\nconst FILL_TAG = qname(SHEET_MAIN_NS, 'fill');\nconst BORDER_TAG = qname(SHEET_MAIN_NS, 'border');\nconst NUMFMT_INNER_TAG = qname(SHEET_MAIN_NS, 'numFmt');\nconst ALIGNMENT_TAG = qname(SHEET_MAIN_NS, 'alignment');\nconst PROTECTION_TAG = qname(SHEET_MAIN_NS, 'protection');\n\n/**\n * Parse `xl/styles.xml` and return a fully-populated {@link Stylesheet}. Slot\n * ordering is preserved verbatim; the dedup index Maps are rebuilt after the\n * fact so future `addFont` / `addCellXf` calls keep working.\n */\nexport function parseStylesheetXml(bytes: Uint8Array | string): Stylesheet {\n const root = parseXml(bytes);\n if (root.name !== STYLESHEET_TAG) {\n throw new OpenXmlSchemaError(`parseStylesheetXml: root is \"${root.name}\", expected styleSheet`);\n }\n\n // Start from a Stylesheet whose default-pool entries we'll wholesale replace\n // with the XML's actual contents.\n const ss = makeStylesheet();\n ss.fonts.length = 0;\n ss.fills.length = 0;\n ss.borders.length = 0;\n\n for (const fontEl of findInSection(root, FONTS_TAG, FONT_TAG)) {\n ss.fonts.push(fromTree(fontEl, FontSchema));\n }\n for (const fillEl of findInSection(root, FILLS_TAG, FILL_TAG)) {\n ss.fills.push(fillFromTree(fillEl));\n }\n for (const borderEl of findInSection(root, BORDERS_TAG, BORDER_TAG)) {\n ss.borders.push(fromTree(borderEl, BorderSchema));\n }\n\n // numFmts is a Map<id, code>; id is on the element so a sparse Map works.\n for (const numFmtEl of findInSection(root, NUMFMTS_TAG, NUMFMT_TAG)) {\n const nf = parseNumFmt(numFmtEl);\n ss.numFmts.set(nf.numFmtId, nf.formatCode);\n }\n\n for (const xfEl of findInSection(root, CELLSTYLEXFS_TAG, XF_TAG)) {\n ss.cellStyleXfs.push(parseCellXf(xfEl));\n }\n for (const xfEl of findInSection(root, CELLXFS_TAG, XF_TAG)) {\n ss.cellXfs.push(parseCellXf(xfEl));\n }\n\n // cellStyles → ss.namedStyles\n const cellStylesEl = findChild(root, CELLSTYLES_TAG);\n if (cellStylesEl) {\n const named: StylesheetNamedStyle[] = [];\n for (const cs of findChildren(cellStylesEl, CELLSTYLE_TAG)) {\n const name = cs.attrs['name'];\n const xfId = parseIntAttr(cs.attrs['xfId'], 'xfId');\n if (name === undefined || xfId === undefined) continue;\n const entry: StylesheetNamedStyle = {\n name,\n xfId,\n ...(cs.attrs['builtinId'] !== undefined ? { builtinId: parseIntAttr(cs.attrs['builtinId'], 'builtinId') ?? 0 } : {}),\n ...(cs.attrs['iLevel'] !== undefined ? { iLevel: parseIntAttr(cs.attrs['iLevel'], 'iLevel') ?? 0 } : {}),\n ...(parseBoolAttr(cs.attrs['hidden']) === true ? { hidden: true } : {}),\n ...(parseBoolAttr(cs.attrs['customBuiltin']) === true ? { customBuiltin: true } : {}),\n };\n named.push(entry);\n }\n if (named.length > 0) {\n ss.namedStyles = named;\n ss._namedStyleByName = new Map(named.map((n) => [n.name, n]));\n }\n }\n\n // dxfs → ss.dxfs\n const dxfsEl = findChild(root, DXFS_TAG);\n if (dxfsEl) {\n const dxfs: DifferentialStyle[] = [];\n for (const dxfEl of findChildren(dxfsEl, DXF_TAG)) {\n const fontEl = findChild(dxfEl, FONT_TAG);\n const numFmtEl = findChild(dxfEl, NUMFMT_INNER_TAG);\n const fillEl = findChild(dxfEl, FILL_TAG);\n const alignmentEl = findChild(dxfEl, ALIGNMENT_TAG);\n const borderEl = findChild(dxfEl, BORDER_TAG);\n const protectionEl = findChild(dxfEl, PROTECTION_TAG);\n const dxf: DifferentialStyle = {\n ...(fontEl ? { font: fromTree(fontEl, FontSchema) } : {}),\n ...(numFmtEl ? { numFmt: fromTree(numFmtEl, NumberFormatSchema) } : {}),\n ...(fillEl ? { fill: fillFromTree(fillEl) } : {}),\n ...(alignmentEl ? { alignment: fromTree(alignmentEl, AlignmentSchema) } : {}),\n ...(borderEl ? { border: fromTree(borderEl, BorderSchema) } : {}),\n ...(protectionEl ? { protection: fromTree(protectionEl, ProtectionSchema) } : {}),\n };\n dxfs.push(Object.freeze(dxf));\n }\n if (dxfs.length > 0) {\n const w = ss as StylesheetWithDxfs;\n w.dxfs = dxfs;\n w._dxfIdByKey = new Map(dxfs.map((d, i) => [stableStringify(d), i]));\n }\n }\n\n const tail = root.children.filter((child) => !MODELED_SECTION_TAGS.has(child.name));\n if (tail.length > 0) ss.stylesXmlTail = tail;\n\n rebuildIndexes(ss);\n return ss;\n}\n\n/** Drill from `<styleSheet>` into a numbered section and yield every matching child. */\nfunction findInSection(root: XmlNode, sectionTag: string, itemTag: string): XmlNode[] {\n const section = findChild(root, sectionTag);\n if (!section) return [];\n return findChildren(section, itemTag);\n}\n\nconst parseNumFmt = (node: XmlNode): NumberFormat => {\n const idAttr = node.attrs['numFmtId'];\n const code = node.attrs['formatCode'];\n if (idAttr === undefined) {\n throw new OpenXmlSchemaError('styles: <numFmt> missing @numFmtId');\n }\n if (code === undefined) {\n throw new OpenXmlSchemaError(`styles: <numFmt numFmtId=\"${idAttr}\"> missing @formatCode`);\n }\n const numFmtId = Number.parseInt(idAttr, 10);\n if (!Number.isInteger(numFmtId) || numFmtId < 0) {\n throw new OpenXmlSchemaError(`styles: <numFmt numFmtId=\"${idAttr}\"> is not a non-negative integer`);\n }\n return { numFmtId, formatCode: code };\n};\n\nconst parseIntAttr = (raw: string | undefined, label: string): number | undefined => {\n if (raw === undefined) return undefined;\n const n = Number.parseInt(raw, 10);\n if (!Number.isInteger(n) || n < 0) {\n throw new OpenXmlSchemaError(`styles: <xf ${label}=\"${raw}\"> is not a non-negative integer`);\n }\n return n;\n};\n\nconst parseBoolAttr = (raw: string | undefined): boolean | undefined => {\n if (raw === undefined) return undefined;\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n};\n\nconst parseCellXf = (node: XmlNode): CellXf => {\n const fontId = parseIntAttr(node.attrs['fontId'], 'fontId') ?? 0;\n const fillId = parseIntAttr(node.attrs['fillId'], 'fillId') ?? 0;\n const borderId = parseIntAttr(node.attrs['borderId'], 'borderId') ?? 0;\n const numFmtId = parseIntAttr(node.attrs['numFmtId'], 'numFmtId') ?? 0;\n const xfId = parseIntAttr(node.attrs['xfId'], 'xfId');\n\n const applyFont = parseBoolAttr(node.attrs['applyFont']);\n const applyFill = parseBoolAttr(node.attrs['applyFill']);\n const applyBorder = parseBoolAttr(node.attrs['applyBorder']);\n const applyNumberFormat = parseBoolAttr(node.attrs['applyNumberFormat']);\n const applyAlignment = parseBoolAttr(node.attrs['applyAlignment']);\n const applyProtection = parseBoolAttr(node.attrs['applyProtection']);\n const pivotButton = parseBoolAttr(node.attrs['pivotButton']);\n const quotePrefix = parseBoolAttr(node.attrs['quotePrefix']);\n\n const alignmentEl = findChild(node, ALIGNMENT_TAG);\n const protectionEl = findChild(node, PROTECTION_TAG);\n\n return {\n fontId,\n fillId,\n borderId,\n numFmtId,\n ...(xfId !== undefined ? { xfId } : {}),\n ...(alignmentEl ? { alignment: fromTree(alignmentEl, AlignmentSchema) } : {}),\n ...(protectionEl ? { protection: fromTree(protectionEl, ProtectionSchema) } : {}),\n ...(applyFont !== undefined ? { applyFont } : {}),\n ...(applyFill !== undefined ? { applyFill } : {}),\n ...(applyBorder !== undefined ? { applyBorder } : {}),\n ...(applyNumberFormat !== undefined ? { applyNumberFormat } : {}),\n ...(applyAlignment !== undefined ? { applyAlignment } : {}),\n ...(applyProtection !== undefined ? { applyProtection } : {}),\n ...(pivotButton !== undefined ? { pivotButton } : {}),\n ...(quotePrefix !== undefined ? { quotePrefix } : {}),\n };\n};\n\n/** Repopulate the `_*IdByKey` maps from the freshly-loaded pool entries. */\nfunction rebuildIndexes(ss: Stylesheet): void {\n ss._fontIdByKey = buildKeyIndex<Font>(ss.fonts);\n ss._fillIdByKey = buildKeyIndex<Fill>(ss.fills);\n ss._borderIdByKey = buildKeyIndex<Border>(ss.borders);\n ss._xfIdByKey = buildKeyIndex<CellXf>(ss.cellXfs);\n ss._styleXfIdByKey = buildKeyIndex<CellXf>(ss.cellStyleXfs);\n ss._numFmtIdByCode = new Map();\n for (const [id, code] of ss.numFmts) ss._numFmtIdByCode.set(code, id);\n}\n\nconst buildKeyIndex = <T>(arr: ReadonlyArray<T>): Map<string, number> => {\n const m = new Map<string, number>();\n for (let i = 0; i < arr.length; i++) {\n const key = stableStringify(arr[i] as T);\n if (!m.has(key)) m.set(key, i);\n }\n return m;\n};\n","// Public `loadWorkbook` entry point.\n//\n// **This is the minimum-skeleton stage**: open zip → parse manifest → resolve\n// workbook part path → parse the `<sheets>` list → for each sheet, allocate an\n// empty Worksheet (title + sheetId + state). Reading the actual cell content /\n// styles / sharedStrings / theme / docProps happens in the next iterations of\n// the loop.\n//\n// The skeleton is enough to round-trip through openpyxl's `genuine/empty.xlsx`\n// fixture (3 empty sheets) and to give the rest of phase 3 a stable scaffolding\n// to layer onto.\n\nimport { findUserShapesRId, parseChartXml } from '../chart/chart-xml.js';\nimport { isChartExBytes, parseChartExXml } from '../chart/cx/chartex-xml.js';\nimport { parseUserShapesXml } from '../chart/user-shapes-xml.js';\nimport { parseChartsheetXml } from '../chartsheet/chartsheet-xml.js';\nimport { collectRawRelIds, parseDrawingXml } from '../drawing/drawing-xml.js';\nimport { loadImage } from '../drawing/image.js';\nimport type { XlsxSource } from '../io/source.js';\nimport { corePropsFromBytes } from '../packaging/core.js';\nimport { customPropsFromBytes } from '../packaging/custom.js';\nimport { extendedPropsFromBytes } from '../packaging/extended.js';\nimport { manifestFromBytes } from '../packaging/manifest.js';\nimport { findById, indexRelsById, makeRelationships, type Relationship, relsFromBytes } from '../packaging/relationships.js';\nimport { parseStylesheetXml } from '../styles/stylesheet-reader.js';\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport type { DefinedName } from '../workbook/defined-names.js';\nimport { makeDefinedName } from '../workbook/defined-names.js';\nimport { parseSharedStringsXml, type SharedStringsTable } from '../workbook/shared-strings.js';\nimport { createWorkbook, type SheetRef, type SheetState, type Workbook } from '../workbook/workbook.js';\nimport { parseCommentsXml } from '../worksheet/comments-xml.js';\nimport { parseWorksheetXml } from '../worksheet/reader.js';\nimport { parseTableXml } from '../worksheet/table-xml.js';\nimport {\n ARC_APP,\n ARC_CONTENT_TYPES,\n ARC_CORE,\n ARC_CUSTOM,\n ARC_ROOT_RELS,\n ARC_SHARED_STRINGS,\n ARC_STYLE,\n ARC_THEME,\n ARC_WORKBOOK,\n MARKUP_COMPAT_NS,\n parseQName,\n REL_NS,\n SHEET_MAIN_NS,\n} from '../xml/namespaces.js';\nimport { type ParsedDocument, parseXmlDocument } from '../xml/parser.js';\nimport { findChild, findChildren, type XmlNode } from '../xml/tree.js';\nimport type { DecompressionLimits } from '../zip/decompression-guard.js';\nimport { openZip, type ZipArchive } from '../zip/reader.js';\n\n/**\n * Options for {@link loadWorkbook}. Earlier drafts exposed `readOnly` /\n * `keepLinks` / `keepVba` / `dataOnly` / `richText` placeholders that the\n * loader silently ignored; those were removed to keep the surface honest.\n * Future toggles land here once their behavior is implemented.\n */\nexport interface LoadOptions {\n /**\n * Decompression-bomb safeguards applied while inflating zip entries.\n * Defaults to limits that fit any legitimate xlsx; pass `false` to disable\n * (only safe for fully trusted sources). See\n * {@link DecompressionLimits} for the individual knobs.\n */\n decompressionLimits?: DecompressionLimits | false;\n}\n\n/** Office Document relationship type — the package-root pointer to `xl/workbook.xml`. */\nconst OFFICE_DOC_REL_TYPE = `${REL_NS}/officeDocument`;\n\n/**\n * Resolve an OPC relationship target against its source part path.\n *\n * - Targets starting with `/` are package-absolute.\n * - Otherwise the target is relative to the source part's parent directory.\n * - `..` segments collapse normally.\n */\nexport function resolveRelTarget(sourcePartPath: string, target: string): string {\n if (target.startsWith('/')) return target.slice(1);\n const lastSlash = sourcePartPath.lastIndexOf('/');\n const parentDir = lastSlash >= 0 ? sourcePartPath.slice(0, lastSlash + 1) : '';\n const joined = parentDir + target;\n return normalizePath(joined);\n}\n\nfunction normalizePath(path: string): string {\n const segments = path.split('/');\n const out: string[] = [];\n for (const seg of segments) {\n if (seg === '' || seg === '.') continue;\n if (seg === '..') {\n // Pop the last accumulated segment when one exists; when `out` is\n // empty (a relative target with more `..` than ancestors) the pop is\n // a no-op so the climb is silently absorbed at the package root. The\n // archive.has() check on the resolved path catches any escape attempt\n // because the entry simply won't exist outside the package — there's\n // no filesystem traversal to worry about, only a missing-entry error.\n out.pop();\n continue;\n }\n out.push(seg);\n }\n return out.join('/');\n}\n\n/** Sibling rels-part path for a given part. `xl/workbook.xml` → `xl/_rels/workbook.xml.rels`. */\nfunction relsPathFor(partPath: string): string {\n const i = partPath.lastIndexOf('/');\n if (i < 0) return `_rels/${partPath}.rels`;\n return `${partPath.slice(0, i)}/_rels/${partPath.slice(i + 1)}.rels`;\n}\n\ninterface SheetEntry {\n /** Display name (`sheet/@name`). */\n name: string;\n /** Workbook-scope sheetId (`sheet/@sheetId`). */\n sheetId: number;\n /** Workbook rels Id (`sheet/@r:id`). */\n rId: string;\n /** Visibility state — defaults to `'visible'` when the attribute is absent. */\n state: SheetState;\n}\n\nconst SHEET_TAG = `{${SHEET_MAIN_NS}}sheet`;\nconst SHEETS_TAG = `{${SHEET_MAIN_NS}}sheets`;\nconst DEFINED_NAMES_TAG = `{${SHEET_MAIN_NS}}definedNames`;\nconst DEFINED_NAME_TAG = `{${SHEET_MAIN_NS}}definedName`;\nconst RID_ATTR = `{${REL_NS}}id`;\n\n/** Extract the `<definedNames>/<definedName>` entries from a parsed `xl/workbook.xml`. */\nfunction parseDefinedNames(workbookRoot: XmlNode): DefinedName[] {\n const wrapper = findChild(workbookRoot, DEFINED_NAMES_TAG);\n if (!wrapper) return [];\n const out: DefinedName[] = [];\n for (const node of findChildren(wrapper, DEFINED_NAME_TAG)) {\n const name = node.attrs['name'];\n if (!name) throw new OpenXmlSchemaError(\"workbook.xml: <definedName> is missing 'name'\");\n const value = node.text ?? '';\n const opts: Partial<DefinedName> & { name: string; value: string } = { name, value };\n const scopeAttr = node.attrs['localSheetId'];\n if (scopeAttr !== undefined) {\n const scope = Number.parseInt(scopeAttr, 10);\n if (Number.isInteger(scope) && scope >= 0) opts.scope = scope;\n }\n if (node.attrs['hidden'] === '1' || node.attrs['hidden'] === 'true') opts.hidden = true;\n if (node.attrs['comment'] !== undefined) opts.comment = node.attrs['comment'];\n out.push(makeDefinedName(opts));\n }\n return out;\n}\n\nconst WORKBOOK_PR_TAG = `{${SHEET_MAIN_NS}}workbookPr`;\nconst WORKBOOK_PROTECTION_TAG = `{${SHEET_MAIN_NS}}workbookProtection`;\nconst BOOK_VIEWS_TAG = `{${SHEET_MAIN_NS}}bookViews`;\nconst WORKBOOK_VIEW_TAG = `{${SHEET_MAIN_NS}}workbookView`;\nconst CUSTOM_WORKBOOK_VIEWS_TAG = `{${SHEET_MAIN_NS}}customWorkbookViews`;\nconst CUSTOM_WORKBOOK_VIEW_TAG = `{${SHEET_MAIN_NS}}customWorkbookView`;\nconst CALC_PR_TAG = `{${SHEET_MAIN_NS}}calcPr`;\nconst FILE_VERSION_TAG = `{${SHEET_MAIN_NS}}fileVersion`;\nconst FILE_SHARING_TAG = `{${SHEET_MAIN_NS}}fileSharing`;\nconst OLE_SIZE_TAG = `{${SHEET_MAIN_NS}}oleSize`;\nconst FILE_RECOVERY_PR_TAG = `{${SHEET_MAIN_NS}}fileRecoveryPr`;\nconst PIVOT_CACHES_TAG = `{${SHEET_MAIN_NS}}pivotCaches`;\nconst PIVOT_CACHE_TAG = `{${SHEET_MAIN_NS}}pivotCache`;\nconst EXTERNAL_REFERENCES_TAG = `{${SHEET_MAIN_NS}}externalReferences`;\nconst EXTERNAL_REFERENCE_TAG = `{${SHEET_MAIN_NS}}externalReference`;\nconst SMART_TAG_PR_TAG = `{${SHEET_MAIN_NS}}smartTagPr`;\nconst SMART_TAG_TYPES_TAG = `{${SHEET_MAIN_NS}}smartTagTypes`;\nconst SMART_TAG_TYPE_TAG = `{${SHEET_MAIN_NS}}smartTagType`;\nconst FUNCTION_GROUPS_TAG = `{${SHEET_MAIN_NS}}functionGroups`;\nconst FUNCTION_GROUP_TAG = `{${SHEET_MAIN_NS}}functionGroup`;\n\n/**\n * Parse the `<workbookPr date1904>` flag. Mac-origin workbooks set\n * `date1904=\"true\"`; everything else uses the Windows 1900 epoch. The value\n * drives Date serialization and lets readers select the epoch when converting\n * numeric date serials.\n */\nexport function parseDate1904(workbookRoot: XmlNode): boolean {\n const pr = findChild(workbookRoot, WORKBOOK_PR_TAG);\n if (!pr) return false;\n const v = pr.attrs['date1904'];\n return v === '1' || v === 'true';\n}\n\n/** Extract the `<sheets>/<sheet>` entries from a parsed `xl/workbook.xml`. */\nexport function parseSheetEntries(workbookRoot: XmlNode): SheetEntry[] {\n const sheets = findChild(workbookRoot, SHEETS_TAG);\n if (!sheets) return [];\n const out: SheetEntry[] = [];\n for (const node of findChildren(sheets, SHEET_TAG)) {\n const name = node.attrs['name'];\n const sheetIdAttr = node.attrs['sheetId'];\n const rId = node.attrs[RID_ATTR];\n if (!name) throw new OpenXmlSchemaError(\"workbook.xml: <sheet> is missing 'name'\");\n if (!sheetIdAttr) throw new OpenXmlSchemaError(`workbook.xml: <sheet name=\"${name}\"> is missing 'sheetId'`);\n if (!rId) throw new OpenXmlSchemaError(`workbook.xml: <sheet name=\"${name}\"> is missing 'r:id'`);\n const sheetId = Number.parseInt(sheetIdAttr, 10);\n if (!Number.isInteger(sheetId) || sheetId < 1) {\n throw new OpenXmlSchemaError(\n `workbook.xml: <sheet name=\"${name}\"> sheetId \"${sheetIdAttr}\" is not a positive integer`,\n );\n }\n const stateAttr = node.attrs['state'];\n let state: SheetState = 'visible';\n if (stateAttr === 'hidden' || stateAttr === 'veryHidden') state = stateAttr;\n out.push({ name, sheetId, rId, state });\n }\n return out;\n}\n\n/**\n * Load a workbook from any {@link XlsxSource}. Currently produces a scaffold\n * Workbook: each Worksheet is empty (no cells / styles / shared strings / theme\n * yet). The next phase-3 iterations layer those in atop the same skeleton.\n */\nexport async function loadWorkbook(source: XlsxSource, opts: LoadOptions = {}): Promise<Workbook> {\n const archive = await openZip(\n source,\n opts.decompressionLimits === undefined ? {} : { decompressionLimits: opts.decompressionLimits },\n );\n try {\n return loadWorkbookFromArchive(archive);\n } finally {\n archive.close();\n }\n}\n\n/** Internal: same as {@link loadWorkbook} but operating on an already-opened archive. */\nfunction loadWorkbookFromArchive(archive: ZipArchive): Workbook {\n // 1. Manifest — resolves which override entries the package declares.\n if (!archive.has(ARC_CONTENT_TYPES)) {\n throw new OpenXmlSchemaError(`loadWorkbook: missing \"${ARC_CONTENT_TYPES}\"`);\n }\n const manifest = manifestFromBytes(archive.read(ARC_CONTENT_TYPES));\n\n // 2. Root rels → resolve the office-document relationship to the workbook part path.\n if (!archive.has(ARC_ROOT_RELS)) {\n throw new OpenXmlSchemaError(`loadWorkbook: missing \"${ARC_ROOT_RELS}\"`);\n }\n const rootRels = relsFromBytes(archive.read(ARC_ROOT_RELS));\n const officeRel = rootRels.rels.find((r) => r.type === OFFICE_DOC_REL_TYPE);\n if (!officeRel) {\n throw new OpenXmlSchemaError('loadWorkbook: root rels missing officeDocument relationship');\n }\n const workbookPath = resolveRelTarget('', officeRel.target);\n if (workbookPath !== ARC_WORKBOOK) {\n // Most xlsx files put the workbook at xl/workbook.xml. We accept any path\n // the rels point at as long as the archive holds it.\n if (!archive.has(workbookPath)) {\n throw new OpenXmlSchemaError(`loadWorkbook: workbook part \"${workbookPath}\" not found in archive`);\n }\n }\n\n // 3. workbook.xml — parse to extract sheet metadata only.\n const wbDoc = parseXmlDocument(archive.read(workbookPath));\n const wbRoot = wbDoc.root;\n if (parseQName(wbRoot.name).local !== 'workbook') {\n throw new OpenXmlSchemaError(`loadWorkbook: ${workbookPath} root is \"${wbRoot.name}\", expected workbook`);\n }\n const sheetEntries = parseSheetEntries(wbRoot);\n const definedNamesFromXml = parseDefinedNames(wbRoot);\n\n // 4. workbook.xml.rels — needed to resolve each sheet's rId to a part path.\n const wbRelsPath = relsPathFor(workbookPath);\n // openpyxl tolerates a missing workbook.xml.rels (it implies no sheets); in\n // practice every Excel file has one. We require it so a malformed package\n // surfaces as an OpenXmlSchemaError, not a silently-empty workbook.\n if (sheetEntries.length > 0 && !archive.has(wbRelsPath)) {\n throw new OpenXmlSchemaError(`loadWorkbook: workbook has sheets but rels part \"${wbRelsPath}\" is missing`);\n }\n const wbRels = archive.has(wbRelsPath) ? relsFromBytes(archive.read(wbRelsPath)) : { rels: [] };\n\n // 4b. sharedStrings.xml — optional. The workbook rels can also point at a\n // non-default location; for the minimum-skeleton stage we look at the\n // canonical `xl/sharedStrings.xml` path first, then fall back to the rels\n // entry if present.\n let sharedStrings: SharedStringsTable | undefined;\n if (archive.has(ARC_SHARED_STRINGS)) {\n sharedStrings = parseSharedStringsXml(archive.read(ARC_SHARED_STRINGS));\n } else {\n const sstRel = wbRels.rels.find((r) => r.type === `${REL_NS}/sharedStrings`);\n if (sstRel) {\n const sstPath = resolveRelTarget(workbookPath, sstRel.target);\n if (archive.has(sstPath)) {\n sharedStrings = parseSharedStringsXml(archive.read(sstPath));\n }\n }\n }\n // Entries reach the worksheet reader as-is: a rich-text `<si>` becomes a\n // rich-text cell value, so the per-run formatting Excel stored survives the\n // round-trip instead of collapsing into the concatenated text body.\n const sst = sharedStrings?.entries ?? [];\n\n // 4c. styles.xml — optional. Same default-or-rels lookup as sst.\n let styles: ReturnType<typeof parseStylesheetXml> | undefined;\n if (archive.has(ARC_STYLE)) {\n styles = parseStylesheetXml(archive.read(ARC_STYLE));\n } else {\n const stylesRel = wbRels.rels.find((r) => r.type === `${REL_NS}/styles`);\n if (stylesRel) {\n const stylesPath = resolveRelTarget(workbookPath, stylesRel.target);\n if (archive.has(stylesPath)) {\n styles = parseStylesheetXml(archive.read(stylesPath));\n }\n }\n }\n\n // 4d. docProps/{core,app,custom}.xml — package-level metadata. Each part is\n // optional; absent ones leave the matching Workbook field undefined. We walk\n // both the canonical path and the root rels so non-default layouts (rare but\n // legal) still resolve.\n const properties = archive.has(ARC_CORE) ? corePropsFromBytes(archive.read(ARC_CORE)) : undefined;\n const appProperties = archive.has(ARC_APP) ? extendedPropsFromBytes(archive.read(ARC_APP)) : undefined;\n const customProperties = archive.has(ARC_CUSTOM) ? customPropsFromBytes(archive.read(ARC_CUSTOM)) : undefined;\n\n // 4e. xl/theme/theme1.xml — kept verbatim. Excel renders with this exact\n // payload; round-tripping the bytes avoids drift.\n const themeXml: Uint8Array | undefined = (() => {\n if (archive.has(ARC_THEME)) return archive.read(ARC_THEME);\n const themeRel = wbRels.rels.find((r) => r.type === `${REL_NS}/theme`);\n if (themeRel) {\n const themePath = resolveRelTarget(workbookPath, themeRel.target);\n if (archive.has(themePath)) return archive.read(themePath);\n }\n return undefined;\n })();\n\n // 5. Build the Workbook. We bypass `addWorksheet` because that allocates\n // sheetIds via `allocateSheetId`; load preserves the IDs from XML.\n const wb = createWorkbook({ date1904: parseDate1904(wbRoot) });\n if (styles) wb.styles = styles;\n if (properties) wb.properties = properties;\n if (appProperties) wb.appProperties = appProperties;\n if (customProperties) wb.customProperties = customProperties;\n if (themeXml) wb.themeXml = themeXml;\n if (definedNamesFromXml.length > 0) wb.definedNames = definedNamesFromXml;\n const seenTitles = new Set<string>();\n const passthroughRoots: string[] = [];\n const vml = makeVmlPartCache(archive);\n for (const entry of sheetEntries) {\n if (seenTitles.has(entry.name)) {\n throw new OpenXmlSchemaError(`loadWorkbook: duplicate sheet name \"${entry.name}\"`);\n }\n seenTitles.add(entry.name);\n const rel = findById(wbRels, entry.rId);\n if (!rel) {\n throw new OpenXmlSchemaError(`loadWorkbook: sheet \"${entry.name}\" rId \"${entry.rId}\" has no matching rels entry`);\n }\n const sheetPath = resolveRelTarget(workbookPath, rel.target);\n if (!archive.has(sheetPath)) {\n throw new OpenXmlSchemaError(`loadWorkbook: sheet part \"${sheetPath}\" not found in archive`);\n }\n const sheetRelsPath = relsPathFor(sheetPath);\n const sheetRels = archive.has(sheetRelsPath) ? relsFromBytes(archive.read(sheetRelsPath)) : undefined;\n // Build an id → rel index once; the loadTable / loadComments / loadDrawing\n // callbacks are invoked once per cross-reference in the worksheet body and\n // a linear find() inside each would be O(rels × refs). Sheets with many\n // hyperlinks / tables / drawings (e.g. dashboard workbooks) make that\n // accumulation visible.\n const sheetRelsById = sheetRels ? indexRelsById(sheetRels) : undefined;\n const loadTable = sheetRelsById\n ? (relId: string) => {\n const tRel = sheetRelsById.get(relId);\n if (!tRel) return undefined;\n const tablePath = resolveRelTarget(sheetPath, tRel.target);\n if (!archive.has(tablePath)) return undefined;\n return parseTableXml(archive.read(tablePath));\n }\n : undefined;\n const loadComments = sheetRelsById\n ? (relId: string) => {\n const cRel = sheetRelsById.get(relId);\n if (!cRel) return undefined;\n const cPath = resolveRelTarget(sheetPath, cRel.target);\n if (!archive.has(cPath)) return undefined;\n return parseCommentsXml(archive.read(cPath));\n }\n : undefined;\n const loadDrawing = sheetRelsById\n ? (relId: string) => {\n const dRel = sheetRelsById.get(relId);\n if (!dRel) return undefined;\n const dPath = resolveRelTarget(sheetPath, dRel.target);\n if (!archive.has(dPath)) return undefined;\n const drawing = parseDrawingXml(archive.read(dPath));\n // Phase-2: resolve drawing-rels to populate chart payloads.\n const dRelsPath = relsPathFor(dPath);\n if (archive.has(dRelsPath)) {\n const dRels = relsFromBytes(archive.read(dRelsPath));\n const dRelsById = indexRelsById(dRels);\n for (const item of drawing.items) {\n if (item.content.kind === 'chart') {\n const chartRId = item.content.chart.rId;\n if (!chartRId) continue;\n const chartRel = dRelsById.get(chartRId);\n if (!chartRel) continue;\n const chartPath = resolveRelTarget(dPath, chartRel.target);\n if (archive.has(chartPath)) {\n const chartBytes = archive.read(chartPath);\n if (isChartExBytes(chartBytes)) {\n item.content.chart.cxSpace = parseChartExXml(chartBytes);\n } else {\n const space = parseChartXml(chartBytes);\n // Resolve <c:userShapes r:id=\"...\"> via the chart's own\n // rels file (xl/charts/_rels/chartN.xml.rels).\n const userShapesRId = findUserShapesRId(chartBytes);\n if (userShapesRId) {\n const chartRelsPath = relsPathFor(chartPath);\n if (archive.has(chartRelsPath)) {\n const chartRelsObj = relsFromBytes(archive.read(chartRelsPath));\n const usRel = indexRelsById(chartRelsObj).get(userShapesRId);\n if (usRel) {\n const usPath = resolveRelTarget(chartPath, usRel.target);\n if (archive.has(usPath)) {\n try {\n space.userShapes = parseUserShapesXml(archive.read(usPath));\n } catch {\n // Tolerate parse failures (Excel sometimes emits\n // chartDrawing parts with namespaces / shapes\n // outside our model).\n }\n }\n }\n }\n }\n item.content.chart.space = space;\n }\n }\n } else if (item.content.kind === 'picture') {\n const picRId = item.content.picture.rId;\n if (!picRId) continue;\n const picRel = dRelsById.get(picRId);\n if (!picRel) continue;\n const imgPath = resolveRelTarget(dPath, picRel.target);\n if (archive.has(imgPath)) {\n try {\n item.content.picture.image = loadImage(archive.read(imgPath));\n } catch {\n // Unknown / unsupported format — leave bytes-less; callers\n // can read via the rId + archive directly if they need the\n // raw payload.\n }\n }\n }\n }\n // Anything kept verbatim (shapes, groups, mc:AlternateContent\n // wrappers) may still reference the drawing's rels. Carry those\n // entries under their original ids and hand their targets to the\n // passthrough sweep so the references still resolve on re-save.\n const rawRelIds = collectRawRelIds(drawing);\n if (rawRelIds.size > 0) {\n const carried = makeRelationships();\n for (const id of rawRelIds) {\n const rawRel = dRelsById.get(id);\n if (!rawRel) continue;\n carried.rels.push(rawRel);\n if (rawRel.targetMode !== 'External') {\n passthroughRoots.push(resolveRelTarget(dPath, rawRel.target));\n }\n }\n if (carried.rels.length > 0) drawing.rawRels = carried;\n }\n }\n return drawing;\n }\n : undefined;\n // Distinguish worksheet vs chartsheet by inspecting the workbook-rels\n // entry's relationship type.\n const isChartsheet = rel.type === `${REL_NS}/chartsheet`;\n if (isChartsheet) {\n const chartsheet = parseChartsheetXml(archive.read(sheetPath), entry.name);\n // Inline drawing reference from the chartsheet XML.\n if (sheetRels) {\n // Find the drawing rel and resolve it the same way worksheets do.\n const drawingRel = sheetRels.rels.find((r) => r.type === `${REL_NS}/drawing`);\n if (drawingRel && loadDrawing) {\n const d = loadDrawing(drawingRel.id);\n if (d) chartsheet.drawing = d;\n }\n }\n const ref: SheetRef = {\n kind: 'chartsheet',\n sheet: chartsheet,\n sheetId: entry.sheetId,\n state: entry.state,\n rId: entry.rId,\n };\n wb.sheets.push(ref);\n continue;\n }\n const ws = parseWorksheetXml(archive.read(sheetPath), entry.name, {\n sharedStrings: sst,\n ...(sheetRels ? { rels: sheetRels } : {}),\n ...(loadTable ? { loadTable } : {}),\n ...(loadComments ? { loadComments } : {}),\n ...(loadDrawing ? { loadDrawing } : {}),\n });\n if (sheetRels) {\n const extras = captureSheetRelsExtras(sheetRels, sheetPath, vml);\n if (extras.length > 0) {\n ws.relsExtras = extras;\n // The writer re-emits these rels verbatim, so whatever they point at\n // has to be carried over as passthrough or the output dangles.\n for (const e of extras) {\n if (e.targetMode !== 'External') passthroughRoots.push(resolveRelTarget(sheetPath, e.target));\n }\n }\n }\n // A <legacyDrawing> pointing at the comment VML (or at nothing) has no\n // surviving rel; the writer regenerates the comment link from\n // ws.legacyComments, so re-emitting this rId would dangle.\n if (ws.legacyDrawingRId !== undefined && !ws.relsExtras?.some((e) => e.id === ws.legacyDrawingRId)) {\n delete ws.legacyDrawingRId;\n }\n const ref: SheetRef = {\n kind: 'worksheet',\n sheet: ws,\n sheetId: entry.sheetId,\n state: entry.state,\n rId: entry.rId,\n };\n wb.sheets.push(ref);\n }\n\n captureWorkbookXmlExtras(wbRoot, wb);\n captureWorkbookXmlRoot(wbDoc, wb);\n captureWorkbookRelsExtras(wbRels, wb);\n\n // Pass-through: capture parts we don't model (VBA / pivot / activeX / OLE /\n // customUI / customXml / etc.) so re-saving doesn't drop them.\n capturePassthrough(archive, manifest, wb, passthroughRoots, vml);\n return wb;\n}\n\nconst SHEET_MODELED_REL_TYPES: ReadonlySet<string> = new Set([\n `${REL_NS}/hyperlink`,\n `${REL_NS}/table`,\n `${REL_NS}/comments`,\n `${REL_NS}/drawing`,\n]);\nconst VML_DRAWING_REL = `${REL_NS}/vmlDrawing`;\n\n/**\n * Capture per-sheet rels entries that don't match a modeled type. The writer\n * re-emits these verbatim alongside the freshly allocated modeled rels so\n * captured passthrough parts (pivotTable / queryTable / slicer /\n * printerSettings / oleObject / customProperty / threadedComment) remain\n * reachable from the worksheet after a round-trip.\n *\n * `vmlDrawing` rels are split by part content rather than by type: only the\n * comments VML is regenerated (from `ws.legacyComments`), so its rel is\n * dropped; header/footer and form-control VML is re-emitted by its original\n * r:id and rides along as an extra.\n */\nfunction captureSheetRelsExtras(\n sheetRels: import('../packaging/relationships.js').Relationships,\n sheetPath: string,\n vml: VmlPartCache,\n): Relationship[] {\n const extras: Relationship[] = [];\n for (const rel of sheetRels.rels) {\n if (SHEET_MODELED_REL_TYPES.has(rel.type)) continue;\n if (rel.type === VML_DRAWING_REL && vml.isCommentVml(resolveRelTarget(sheetPath, rel.target))) continue;\n extras.push(rel);\n }\n return extras;\n}\n\n/**\n * Walk top-level children of `<workbook>` and split anything that isn't\n * `<sheets>` or `<definedNames>` into the before/after halves the writer\n * inserts around the modeled elements. Order is preserved within each half so\n * things like `<fileVersion>`, `<workbookPr>`, `<bookViews>`, `<calcPr>`,\n * `<pivotCaches>`, `<extLst>` round-trip in document order.\n */\n/**\n * Keep the `<workbook>` root's namespace declarations and `mc:Ignorable`. Excel\n * writes `mc:Ignorable=\"x15 xr xr6 xr10 xr2\"` naming prefixes declared only\n * there; dropping either half — or renaming the prefixes — makes Excel report\n * the file as corrupt. The default namespace and `r` are re-emitted by the\n * writer itself, so they are not carried here.\n */\nfunction captureWorkbookXmlRoot(doc: ParsedDocument, wb: Workbook): void {\n const namespaces = doc.rootNamespaces.filter((d) => d.prefix !== '' && d.prefix !== 'r');\n const ignorable = doc.root.attrs[`{${MARKUP_COMPAT_NS}}Ignorable`];\n if (namespaces.length === 0 && ignorable === undefined) return;\n wb.workbookXmlRoot = {\n namespaces,\n ...(ignorable !== undefined ? { ignorable } : {}),\n };\n}\n\nfunction captureWorkbookXmlExtras(wbRoot: XmlNode, wb: Workbook): void {\n const beforeSheets: XmlNode[] = [];\n const afterSheets: XmlNode[] = [];\n let seenSheets = false;\n for (const child of wbRoot.children) {\n if (child.name === SHEETS_TAG) {\n seenSheets = true;\n continue;\n }\n if (child.name === DEFINED_NAMES_TAG) continue;\n // Lift <workbookProtection> into the typed workbook field instead of\n // stashing it as a passthrough XmlNode (B5 partial).\n if (child.name === WORKBOOK_PROTECTION_TAG) {\n wb.workbookProtection = parseWorkbookProtection(child);\n continue;\n }\n // Lift <workbookPr> into the typed workbook field. The date1904 attribute\n // is already mirrored onto wb.date1904; everything else stops leaking into\n // bodyExtras.\n if (child.name === WORKBOOK_PR_TAG) {\n const wp = parseWorkbookProperties(child);\n if (wp) wb.workbookProperties = wp;\n continue;\n }\n // Lift <fileSharing> into the typed workbook field.\n if (child.name === FILE_SHARING_TAG) {\n const fs: import('../workbook/file-sharing.js').FileSharing = {};\n const a = child.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const ror = flag(a['readOnlyRecommended']);\n if (ror !== undefined) fs.readOnlyRecommended = ror;\n if (a['userName'] !== undefined) fs.userName = a['userName'];\n if (a['reservationPassword'] !== undefined) fs.reservationPassword = a['reservationPassword'];\n if (a['algorithmName'] !== undefined) fs.algorithmName = a['algorithmName'];\n if (a['hashValue'] !== undefined) fs.hashValue = a['hashValue'];\n if (a['saltValue'] !== undefined) fs.saltValue = a['saltValue'];\n if (a['spinCount'] !== undefined) {\n const n = Number.parseInt(a['spinCount'], 10);\n if (Number.isInteger(n)) fs.spinCount = n;\n }\n if (Object.keys(fs).length > 0) wb.fileSharing = fs;\n continue;\n }\n // Lift <fileVersion> into the typed workbook field.\n if (child.name === FILE_VERSION_TAG) {\n const fv: import('../workbook/file-version.js').FileVersion = {};\n if (child.attrs['appName'] !== undefined) fv.appName = child.attrs['appName'];\n if (child.attrs['lastEdited'] !== undefined) fv.lastEdited = child.attrs['lastEdited'];\n if (child.attrs['lowestEdited'] !== undefined) fv.lowestEdited = child.attrs['lowestEdited'];\n if (child.attrs['rupBuild'] !== undefined) fv.rupBuild = child.attrs['rupBuild'];\n if (child.attrs['codeName'] !== undefined) fv.codeName = child.attrs['codeName'];\n if (Object.keys(fv).length > 0) wb.fileVersion = fv;\n continue;\n }\n // Lift <bookViews> into the typed workbook field.\n if (child.name === BOOK_VIEWS_TAG) {\n const views: import('../workbook/views.js').WorkbookView[] = [];\n for (const v of findChildren(child, WORKBOOK_VIEW_TAG)) views.push(parseWorkbookView(v));\n if (views.length > 0) wb.bookViews = views;\n continue;\n }\n // Lift <customWorkbookViews> into the typed workbook field.\n if (child.name === CUSTOM_WORKBOOK_VIEWS_TAG) {\n const cws: import('../workbook/views.js').CustomWorkbookView[] = [];\n for (const v of findChildren(child, CUSTOM_WORKBOOK_VIEW_TAG)) {\n const parsed = parseCustomWorkbookView(v);\n if (parsed) cws.push(parsed);\n }\n if (cws.length > 0) wb.customWorkbookViews = cws;\n continue;\n }\n // Lift <calcPr> into the typed workbook field.\n if (child.name === CALC_PR_TAG) {\n const cp = parseCalcProperties(child);\n if (cp) wb.calcProperties = cp;\n continue;\n }\n // Lift <oleSize ref=\"…\"/> as a single typed string attribute.\n if (child.name === OLE_SIZE_TAG) {\n const ref = child.attrs['ref'];\n if (ref) wb.oleSize = ref;\n continue;\n }\n // Lift <smartTagPr embed=\"1\" show=\"all\"/>.\n if (child.name === SMART_TAG_PR_TAG) {\n const out: import('../workbook/smart-tags.js').SmartTagProperties = {};\n const a = child.attrs;\n if (a['embed'] === '1' || a['embed'] === 'true') out.embed = true;\n else if (a['embed'] === '0' || a['embed'] === 'false') out.embed = false;\n if (a['show'] === 'all' || a['show'] === 'noIndicator') out.show = a['show'];\n if (Object.keys(out).length > 0) wb.smartTagPr = out;\n continue;\n }\n // Lift <smartTagTypes><smartTagType .../></smartTagTypes>.\n if (child.name === SMART_TAG_TYPES_TAG) {\n const tags: import('../workbook/smart-tags.js').SmartTagType[] = [];\n for (const t of findChildren(child, SMART_TAG_TYPE_TAG)) {\n const entry: import('../workbook/smart-tags.js').SmartTagType = {};\n if (t.attrs['namespaceUri'] !== undefined) entry.namespaceUri = t.attrs['namespaceUri'];\n if (t.attrs['name'] !== undefined) entry.name = t.attrs['name'];\n if (t.attrs['url'] !== undefined) entry.url = t.attrs['url'];\n if (Object.keys(entry).length > 0) tags.push(entry);\n }\n if (tags.length > 0) wb.smartTagTypes = tags;\n continue;\n }\n // Lift <functionGroups builtInGroupCount=…><functionGroup\n // name=…/></functionGroups>.\n if (child.name === FUNCTION_GROUPS_TAG) {\n const fg: import('../workbook/function-groups.js').FunctionGroups = { groups: [] };\n const bicgRaw = child.attrs['builtInGroupCount'];\n if (bicgRaw !== undefined) {\n const n = Number.parseInt(bicgRaw, 10);\n if (Number.isInteger(n)) fg.builtInGroupCount = n;\n }\n for (const g of findChildren(child, FUNCTION_GROUP_TAG)) {\n const name = g.attrs['name'];\n if (name) fg.groups.push({ name });\n }\n if (fg.groups.length > 0 || fg.builtInGroupCount !== undefined) wb.functionGroups = fg;\n continue;\n }\n // Lift <externalReferences><externalReference\n // r:id=…/></externalReferences>.\n if (child.name === EXTERNAL_REFERENCES_TAG) {\n const refs: Array<{ rId: string }> = [];\n for (const er of findChildren(child, EXTERNAL_REFERENCE_TAG)) {\n const rId = er.attrs[`{${REL_NS}}id`];\n if (rId) refs.push({ rId });\n }\n if (refs.length > 0) wb.externalReferences = refs;\n continue;\n }\n // Lift <pivotCaches><pivotCache cacheId=… r:id=…/></pivotCaches>.\n if (child.name === PIVOT_CACHES_TAG) {\n const caches: Array<{ cacheId: number; rId: string }> = [];\n for (const pc of findChildren(child, PIVOT_CACHE_TAG)) {\n const cacheIdAttr = pc.attrs['cacheId'];\n const rId = pc.attrs[`{${REL_NS}}id`];\n if (cacheIdAttr === undefined || !rId) continue;\n const cacheId = Number.parseInt(cacheIdAttr, 10);\n if (!Number.isInteger(cacheId)) continue;\n caches.push({ cacheId, rId });\n }\n if (caches.length > 0) wb.pivotCaches = caches;\n continue;\n }\n // Lift <fileRecoveryPr> into the typed workbook field.\n if (child.name === FILE_RECOVERY_PR_TAG) {\n const fp: import('../workbook/file-recovery.js').FileRecoveryProperties = {};\n const a = child.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const ar = flag(a['autoRecover']);\n if (ar !== undefined) fp.autoRecover = ar;\n const cs = flag(a['crashSave']);\n if (cs !== undefined) fp.crashSave = cs;\n const del = flag(a['dataExtractLoad']);\n if (del !== undefined) fp.dataExtractLoad = del;\n const rl = flag(a['repairLoad']);\n if (rl !== undefined) fp.repairLoad = rl;\n if (Object.keys(fp).length > 0) wb.fileRecoveryPr = fp;\n continue;\n }\n if (seenSheets) afterSheets.push(child);\n else beforeSheets.push(child);\n }\n if (beforeSheets.length > 0 || afterSheets.length > 0) {\n wb.workbookXmlExtras = { beforeSheets, afterSheets };\n }\n}\n\nconst SHOW_OBJECTS_MODES: ReadonlyArray<import('../workbook/workbook-properties.js').ShowObjectsMode> = [\n 'all',\n 'placeholders',\n 'none',\n];\nconst UPDATE_LINKS_MODES: ReadonlyArray<import('../workbook/workbook-properties.js').UpdateLinksMode> = [\n 'userSet',\n 'never',\n 'always',\n];\n\nconst parseWorkbookProperties = (\n node: XmlNode,\n): import('../workbook/workbook-properties.js').WorkbookProperties | undefined => {\n const out: import('../workbook/workbook-properties.js').WorkbookProperties = {};\n const a = node.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const intAttr = (k: string): number | undefined => {\n if (a[k] === undefined) return undefined;\n const n = Number.parseInt(a[k], 10);\n return Number.isInteger(n) ? n : undefined;\n };\n\n const bools = [\n 'date1904',\n 'dateCompatibility',\n 'showBorderUnselectedTables',\n 'filterPrivacy',\n 'promptedSolutions',\n 'showInkAnnotation',\n 'backupFile',\n 'saveExternalLinkValues',\n 'hidePivotFieldList',\n 'showPivotChartFilter',\n 'allowRefreshQuery',\n 'publishItems',\n 'checkCompatibility',\n 'autoCompressPictures',\n 'refreshAllConnections',\n ] as const satisfies ReadonlyArray<keyof import('../workbook/workbook-properties.js').WorkbookProperties>;\n for (const k of bools) {\n const v = flag(a[k]);\n if (v !== undefined) out[k] = v;\n }\n\n const showObjects = a['showObjects'];\n if (showObjects && SHOW_OBJECTS_MODES.includes(showObjects as import('../workbook/workbook-properties.js').ShowObjectsMode)) {\n out.showObjects = showObjects as import('../workbook/workbook-properties.js').ShowObjectsMode;\n }\n const updateLinks = a['updateLinks'];\n if (updateLinks && UPDATE_LINKS_MODES.includes(updateLinks as import('../workbook/workbook-properties.js').UpdateLinksMode)) {\n out.updateLinks = updateLinks as import('../workbook/workbook-properties.js').UpdateLinksMode;\n }\n if (a['codeName'] !== undefined) out.codeName = a['codeName'];\n const dtv = intAttr('defaultThemeVersion');\n if (dtv !== undefined) out.defaultThemeVersion = dtv;\n\n return Object.keys(out).length > 0 ? out : undefined;\n};\n\nconst CALC_MODES: ReadonlyArray<import('../workbook/calc-properties.js').CalcMode> = [\n 'manual',\n 'auto',\n 'autoNoTable',\n];\nconst REF_MODES: ReadonlyArray<import('../workbook/calc-properties.js').RefMode> = ['A1', 'R1C1'];\n\nconst parseCalcProperties = (\n node: XmlNode,\n): import('../workbook/calc-properties.js').CalcProperties | undefined => {\n const out: import('../workbook/calc-properties.js').CalcProperties = {};\n const a = node.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const intAttr = (k: string): number | undefined => {\n if (a[k] === undefined) return undefined;\n const n = Number.parseInt(a[k], 10);\n return Number.isInteger(n) ? n : undefined;\n };\n const floatAttr = (k: string): number | undefined => {\n if (a[k] === undefined) return undefined;\n const n = Number.parseFloat(a[k]);\n return Number.isFinite(n) ? n : undefined;\n };\n\n const calcId = intAttr('calcId');\n if (calcId !== undefined) out.calcId = calcId;\n const calcMode = a['calcMode'];\n if (calcMode && CALC_MODES.includes(calcMode as import('../workbook/calc-properties.js').CalcMode)) {\n out.calcMode = calcMode as import('../workbook/calc-properties.js').CalcMode;\n }\n const fcol = flag(a['fullCalcOnLoad']);\n if (fcol !== undefined) out.fullCalcOnLoad = fcol;\n const refMode = a['refMode'];\n if (refMode && REF_MODES.includes(refMode as import('../workbook/calc-properties.js').RefMode)) {\n out.refMode = refMode as import('../workbook/calc-properties.js').RefMode;\n }\n const iterate = flag(a['iterate']);\n if (iterate !== undefined) out.iterate = iterate;\n const iterateCount = intAttr('iterateCount');\n if (iterateCount !== undefined) out.iterateCount = iterateCount;\n const iterateDelta = floatAttr('iterateDelta');\n if (iterateDelta !== undefined) out.iterateDelta = iterateDelta;\n const fullPrecision = flag(a['fullPrecision']);\n if (fullPrecision !== undefined) out.fullPrecision = fullPrecision;\n const calcCompleted = flag(a['calcCompleted']);\n if (calcCompleted !== undefined) out.calcCompleted = calcCompleted;\n const calcOnSave = flag(a['calcOnSave']);\n if (calcOnSave !== undefined) out.calcOnSave = calcOnSave;\n const concurrentCalc = flag(a['concurrentCalc']);\n if (concurrentCalc !== undefined) out.concurrentCalc = concurrentCalc;\n const concurrentManualCount = intAttr('concurrentManualCount');\n if (concurrentManualCount !== undefined) out.concurrentManualCount = concurrentManualCount;\n const forceFullCalc = flag(a['forceFullCalc']);\n if (forceFullCalc !== undefined) out.forceFullCalc = forceFullCalc;\n\n return Object.keys(out).length > 0 ? out : undefined;\n};\n\nconst SHOW_COMMENTS_MODES: ReadonlyArray<import('../workbook/views.js').CustomViewShowComments> = [\n 'commNone',\n 'commIndicator',\n 'commIndAndComment',\n];\nconst SHOW_OBJECTS_CV_MODES: ReadonlyArray<import('../workbook/views.js').CustomViewShowObjects> = [\n 'all',\n 'placeholders',\n 'none',\n];\n\nconst parseCustomWorkbookView = (\n node: XmlNode,\n): import('../workbook/views.js').CustomWorkbookView | undefined => {\n const a = node.attrs;\n const name = a['name'];\n const guid = a['guid'];\n if (!name || !guid) return undefined;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const intAttr = (k: string): number | undefined => {\n if (a[k] === undefined) return undefined;\n const n = Number.parseInt(a[k], 10);\n return Number.isInteger(n) ? n : undefined;\n };\n const ww = intAttr('windowWidth') ?? 0;\n const wh = intAttr('windowHeight') ?? 0;\n const asid = intAttr('activeSheetId') ?? 0;\n const out: import('../workbook/views.js').CustomWorkbookView = {\n name,\n guid,\n windowWidth: ww,\n windowHeight: wh,\n activeSheetId: asid,\n };\n\n const boolKeys = [\n 'autoUpdate',\n 'changesSavedWin',\n 'onlySync',\n 'personalView',\n 'includePrintSettings',\n 'includeHiddenRowCol',\n 'maximized',\n 'minimized',\n 'showHorizontalScroll',\n 'showVerticalScroll',\n 'showSheetTabs',\n 'showFormulaBar',\n 'showStatusbar',\n ] as const satisfies ReadonlyArray<keyof import('../workbook/views.js').CustomWorkbookView>;\n for (const k of boolKeys) {\n const v = flag(a[k]);\n if (v !== undefined) out[k] = v;\n }\n const intKeys = [\n 'mergeInterval',\n 'xWindow',\n 'yWindow',\n 'tabRatio',\n ] as const satisfies ReadonlyArray<keyof import('../workbook/views.js').CustomWorkbookView>;\n for (const k of intKeys) {\n const v = intAttr(k);\n if (v !== undefined) out[k] = v;\n }\n\n const sc = a['showComments'];\n if (sc && SHOW_COMMENTS_MODES.includes(sc as import('../workbook/views.js').CustomViewShowComments)) {\n out.showComments = sc as import('../workbook/views.js').CustomViewShowComments;\n }\n const so = a['showObjects'];\n if (so && SHOW_OBJECTS_CV_MODES.includes(so as import('../workbook/views.js').CustomViewShowObjects)) {\n out.showObjects = so as import('../workbook/views.js').CustomViewShowObjects;\n }\n return out;\n};\n\nconst VISIBILITIES: ReadonlyArray<import('../workbook/views.js').WorkbookViewVisibility> = [\n 'visible',\n 'hidden',\n 'veryHidden',\n];\n\nconst parseWorkbookView = (node: XmlNode): import('../workbook/views.js').WorkbookView => {\n const out: import('../workbook/views.js').WorkbookView = {};\n const a = node.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n const intAttr = (k: string): number | undefined => {\n if (a[k] === undefined) return undefined;\n const n = Number.parseInt(a[k], 10);\n return Number.isInteger(n) ? n : undefined;\n };\n\n const visibility = a['visibility'];\n if (visibility && VISIBILITIES.includes(visibility as import('../workbook/views.js').WorkbookViewVisibility)) {\n out.visibility = visibility as import('../workbook/views.js').WorkbookViewVisibility;\n }\n const minimized = flag(a['minimized']);\n if (minimized !== undefined) out.minimized = minimized;\n const shScroll = flag(a['showHorizontalScroll']);\n if (shScroll !== undefined) out.showHorizontalScroll = shScroll;\n const svScroll = flag(a['showVerticalScroll']);\n if (svScroll !== undefined) out.showVerticalScroll = svScroll;\n const sst = flag(a['showSheetTabs']);\n if (sst !== undefined) out.showSheetTabs = sst;\n const xWindow = intAttr('xWindow');\n if (xWindow !== undefined) out.xWindow = xWindow;\n const yWindow = intAttr('yWindow');\n if (yWindow !== undefined) out.yWindow = yWindow;\n const ww = intAttr('windowWidth');\n if (ww !== undefined) out.windowWidth = ww;\n const wh = intAttr('windowHeight');\n if (wh !== undefined) out.windowHeight = wh;\n const tr = intAttr('tabRatio');\n if (tr !== undefined) out.tabRatio = tr;\n const fs = intAttr('firstSheet');\n if (fs !== undefined) out.firstSheet = fs;\n const at = intAttr('activeTab');\n if (at !== undefined) out.activeTab = at;\n // `xr2:uid` and friends: anything namespaced is outside CT_BookView, so keep\n // it verbatim rather than dropping it.\n const extAttrs: Record<string, string> = {};\n for (const [k, v] of Object.entries(a)) {\n if (k.startsWith('{')) extAttrs[k] = v;\n }\n if (Object.keys(extAttrs).length > 0) out.extAttrs = extAttrs;\n const adg = flag(a['autoFilterDateGrouping']);\n if (adg !== undefined) out.autoFilterDateGrouping = adg;\n return out;\n};\n\nconst parseWorkbookProtection = (node: XmlNode): import('../workbook/protection.js').WorkbookProtection => {\n const out: import('../workbook/protection.js').WorkbookProtection = {};\n const a = node.attrs;\n const flag = (raw: string | undefined): boolean | undefined => {\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return undefined;\n };\n if (a['workbookPassword'] !== undefined) out.workbookPassword = a['workbookPassword'];\n if (a['workbookPasswordCharacterSet'] !== undefined)\n out.workbookPasswordCharacterSet = a['workbookPasswordCharacterSet'];\n if (a['workbookAlgorithmName'] !== undefined) out.workbookAlgorithmName = a['workbookAlgorithmName'];\n if (a['workbookHashValue'] !== undefined) out.workbookHashValue = a['workbookHashValue'];\n if (a['workbookSaltValue'] !== undefined) out.workbookSaltValue = a['workbookSaltValue'];\n if (a['workbookSpinCount'] !== undefined) {\n const n = Number.parseInt(a['workbookSpinCount'], 10);\n if (Number.isInteger(n)) out.workbookSpinCount = n;\n }\n if (a['revisionsPassword'] !== undefined) out.revisionsPassword = a['revisionsPassword'];\n if (a['revisionsPasswordCharacterSet'] !== undefined)\n out.revisionsPasswordCharacterSet = a['revisionsPasswordCharacterSet'];\n if (a['revisionsAlgorithmName'] !== undefined) out.revisionsAlgorithmName = a['revisionsAlgorithmName'];\n if (a['revisionsHashValue'] !== undefined) out.revisionsHashValue = a['revisionsHashValue'];\n if (a['revisionsSaltValue'] !== undefined) out.revisionsSaltValue = a['revisionsSaltValue'];\n if (a['revisionsSpinCount'] !== undefined) {\n const n = Number.parseInt(a['revisionsSpinCount'], 10);\n if (Number.isInteger(n)) out.revisionsSpinCount = n;\n }\n const ls = flag(a['lockStructure']);\n if (ls !== undefined) out.lockStructure = ls;\n const lw = flag(a['lockWindows']);\n if (lw !== undefined) out.lockWindows = lw;\n const lr = flag(a['lockRevision']);\n if (lr !== undefined) out.lockRevision = lr;\n return out;\n};\n\n/**\n * Capture workbook-rels entries that don't match a modeled type so the writer\n * can re-emit them with their original Id (and any captured `<pivotCaches\n * r:id=\"…\"/>` etc. still resolves after a round-trip). Modeled non-sheet rels\n * (sst / styles / theme / vbaProject) keep their original Id via\n * `wb.workbookRelOriginalIds` so the writer can prefer those over freshly\n * allocated ones.\n */\nfunction captureWorkbookRelsExtras(\n wbRels: import('../packaging/relationships.js').Relationships,\n wb: Workbook,\n): void {\n const SHEET_RELS = new Set([`${REL_NS}/worksheet`, `${REL_NS}/chartsheet`]);\n const original: NonNullable<Workbook['workbookRelOriginalIds']> = {};\n const extras: Array<{ id: string; type: string; target: string }> = [];\n for (const rel of wbRels.rels) {\n if (SHEET_RELS.has(rel.type)) continue;\n if (rel.type === `${REL_NS}/sharedStrings`) {\n original.sharedStrings = rel.id;\n continue;\n }\n if (rel.type === `${REL_NS}/styles`) {\n original.styles = rel.id;\n continue;\n }\n if (rel.type === `${REL_NS}/theme`) {\n original.theme = rel.id;\n continue;\n }\n if (rel.type === `${REL_NS}/vbaProject`) {\n original.vbaProject = rel.id;\n continue;\n }\n extras.push({ id: rel.id, type: rel.type, target: rel.target });\n }\n if (Object.keys(original).length > 0) wb.workbookRelOriginalIds = original;\n if (extras.length > 0) wb.workbookRelsExtras = extras;\n}\n\nconst PASSTHROUGH_PREFIXES: ReadonlyArray<string> = [\n 'xl/activeX/',\n 'xl/ctrlProps/',\n 'xl/embeddings/',\n 'xl/externalLinks/',\n // xl/model/ — Power Pivot data model (`xl/model/item.data` etc.).\n 'xl/model/',\n 'xl/persons/',\n 'xl/pivotCache/',\n 'xl/pivotTables/',\n 'xl/printerSettings/',\n 'xl/queryTables/',\n 'xl/richData/',\n 'xl/slicerCaches/',\n 'xl/slicers/',\n 'xl/threadedComments/',\n 'xl/timelineCaches/',\n 'xl/timelines/',\n 'xl/workbookCache/',\n 'customUI/',\n 'customXml/',\n];\n\n/**\n * Excel emits both form-control VMLs and comment VMLs at\n * `xl/drawings/vmlDrawingN.vml`. Filename alone can't tell them apart, but\n * ECMA-376 §17.18.51 requires comment shapes to carry `<x:ClientData\n * ObjectType=\"Note\">`, so a byte-search for that marker decides which path the\n * file belongs on:\n *\n * - With marker → comment VML; the comments writer regenerates\n * these from `Worksheet.legacyComments`, so we must not capture them as\n * passthrough (would duplicate the entry on save).\n * - Without marker → control / OLE / shape VML; capture as\n * passthrough so form controls survive load → save → load.\n */\nconst COMMENT_VML_MARKER = 'ObjectType=\"Note\"';\n// Latin-1 is a 1-to-1 byte-to-character mapping for the 0–255 range, so a\n// String.indexOf scan on the decoded view returns the same answer as a byte\n// search but takes advantage of V8's native StringPrototypeIndexOf — orders\n// of magnitude faster than the JS loop the previous implementation used on\n// multi-megabyte VML drawings.\nconst LATIN1_DECODER = new TextDecoder('latin1');\n\nconst isVmlDrawing = (path: string): boolean =>\n path.startsWith('xl/drawings/') && path.endsWith('.vml');\n\nconst containsCommentMarker = (bytes: Uint8Array): boolean =>\n LATIN1_DECODER.decode(bytes).includes(COMMENT_VML_MARKER);\n\ninterface VmlPartCache {\n /** Inflated VML bytes, read once per part. */\n read(path: string): Uint8Array;\n /** True when the part at `path` exists and is a comment overlay. */\n isCommentVml(path: string): boolean;\n}\n\n/**\n * Both the per-sheet rels capture and the passthrough sweep need to classify\n * VML parts; share one inflate per part between them.\n */\nconst makeVmlPartCache = (archive: ZipArchive): VmlPartCache => {\n const bytesByPath = new Map<string, Uint8Array>();\n const read = (path: string): Uint8Array => {\n let bytes = bytesByPath.get(path);\n if (bytes === undefined) {\n bytes = archive.read(path);\n bytesByPath.set(path, bytes);\n }\n return bytes;\n };\n return {\n read,\n isCommentVml: (path) => archive.has(path) && containsCommentMarker(read(path)),\n };\n};\n\n/**\n * Top-level xl/*.xml files that aren't modeled but Excel relies on (or\n * harmlessly preserves). Captured by exact path; their content types come\n * through the manifest Override map.\n *\n * - `xl/calcChain.xml` — calculation order hint (Excel rebuilds\n * it on first open if missing, but losing it forces a full recalc).\n * - `xl/connections.xml` — external data connection metadata.\n * - `xl/persons/` — threaded-comment author registry\n * (Excel 365). Captured under the prefix list below.\n * - `xl/metadata.xml` — Excel 365 dynamic-array cell metadata.\n * - `xl/SheetMetadata.xml` — variant casing of the same.\n */\nconst PASSTHROUGH_EXACT_PATHS: ReadonlySet<string> = new Set([\n 'xl/calcChain.xml',\n 'xl/connections.xml',\n 'xl/metadata.xml',\n 'xl/SheetMetadata.xml',\n // docProps/thumbnail.jpeg — workbook preview image Excel renders in the OS\n // file browser. JPEG by default; some files use PNG.\n 'docProps/thumbnail.jpeg',\n 'docProps/thumbnail.jpg',\n 'docProps/thumbnail.png',\n 'docProps/thumbnail.wmf',\n 'docProps/thumbnail.emf',\n]);\n\nconst isPassthroughPath = (path: string, vml: VmlPartCache): boolean => {\n if (PASSTHROUGH_EXACT_PATHS.has(path)) return true;\n if (PASSTHROUGH_PREFIXES.some((p) => path.startsWith(p))) return true;\n // Comment VML is regenerated; control / shape / header-footer VML passes\n // through.\n if (isVmlDrawing(path)) return !vml.isCommentVml(path);\n return false;\n};\n\n/**\n * Walk the archive after the modeled parts are loaded and capture any remaining\n * content into `wb.passthrough`. The dedicated VBA project binaries land on\n * their own slots so the writer can promote the workbook content type to xlsm.\n *\n * `roots` are parts the worksheet writer will reference by their original\n * r:id (see `captureSheetRelsExtras`). Each root is captured together with\n * its own `.rels` file and, transitively, every internal target of those rels\n * — that is what keeps a header/footer VML's image (`vmlDrawingN.vml.rels` →\n * `xl/media/imageN.jpeg`) attached. Passthrough VML parts get the same\n * treatment because form-control VML references images the same way.\n */\nfunction capturePassthrough(\n archive: ZipArchive,\n manifest: import('../packaging/manifest.js').Manifest,\n wb: Workbook,\n roots: ReadonlyArray<string>,\n vml: VmlPartCache,\n): void {\n const overrides = new Map<string, string>();\n for (const o of manifest.overrides) {\n // Manifest paths are package-absolute (`/xl/...`); strip the leading slash.\n overrides.set(o.partName.replace(/^\\//, ''), o.contentType);\n }\n const defaults = new Map<string, string>();\n for (const d of manifest.defaults) defaults.set(d.ext.toLowerCase(), d.contentType);\n\n const capture = (path: string, bytes: Uint8Array): void => {\n if (!wb.passthrough) wb.passthrough = new Map();\n wb.passthrough.set(path, bytes);\n const ct = overrides.get(path);\n if (ct !== undefined) {\n if (!wb.passthroughContentTypes) wb.passthroughContentTypes = new Map();\n wb.passthroughContentTypes.set(path, ct);\n return;\n }\n // No Override → the part is typed by its extension's Default. Remember it\n // so the writer can re-emit that Default; it only knows the extensions of\n // parts it produces itself.\n const ext = path.slice(path.lastIndexOf('.') + 1).toLowerCase();\n const dct = defaults.get(ext);\n if (dct !== undefined) {\n if (!wb.passthroughDefaults) wb.passthroughDefaults = new Map();\n wb.passthroughDefaults.set(ext, dct);\n }\n };\n\n const closureRoots: string[] = [...roots];\n for (const path of archive.list()) {\n if (path === 'xl/vbaProject.bin') {\n wb.vbaProject = archive.read(path);\n continue;\n }\n if (path === 'xl/vbaProjectSignature.bin') {\n wb.vbaSignature = archive.read(path);\n continue;\n }\n if (!isPassthroughPath(path, vml)) continue;\n if (isVmlDrawing(path)) {\n capture(path, vml.read(path));\n closureRoots.push(path);\n } else {\n capture(path, archive.read(path));\n }\n }\n\n // Breadth-first over rels so a chain like sheet → VML → image is captured\n // whole. `visited` (not `wb.passthrough`) gates the walk because roots\n // captured by the prefix scan above still need their rels followed.\n const visited = new Set<string>();\n // for…of re-reads the array length each step, so targets pushed mid-walk\n // are visited too.\n for (const path of closureRoots) {\n if (visited.has(path) || !archive.has(path)) continue;\n visited.add(path);\n if (!wb.passthrough?.has(path)) capture(path, archive.read(path));\n const relsPath = relsPathFor(path);\n if (!archive.has(relsPath)) continue;\n const relsBytes = archive.read(relsPath);\n capture(relsPath, relsBytes);\n for (const r of relsFromBytes(relsBytes).rels) {\n if (r.targetMode !== 'External') closureRoots.push(resolveRelTarget(path, r.target));\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,iBAAiB,MAAM,eAAe,YAAY;AACxD,MAAM,YAAY,MAAM,eAAe,OAAO;AAC9C,MAAM,YAAY,MAAM,eAAe,OAAO;AAC9C,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,aAAa,MAAM,eAAe,QAAQ;AAChD,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,mBAAmB,MAAM,eAAe,cAAc;AAC5D,MAAM,iBAAiB,MAAM,eAAe,YAAY;AACxD,MAAM,gBAAgB,MAAM,eAAe,WAA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./exceptions-D-CFwxgm.mjs";
2
2
  import { A as COREPROPS_NS, At as parseQName, F as CUSTPROPS_NS, Ot as XPROPS_NS, R as DCORE_NS, ct as PKG_REL_NS, k as CONTYPES_NS, kt as XSI_NS, n as el, vt as VTYPES_NS, z as DCTERMS_NS } from "./tree-BX-sRRVp.mjs";
3
- import { t as parseXml } from "./parser-D3SLaOFe.mjs";
3
+ import { t as parseXml } from "./parser-By6RWZVW.mjs";
4
4
  import { n as toTree, r as defineSchema, t as fromTree } from "./serialize-BC2Wu3bR.mjs";
5
- import { t as serializeXml } from "./serializer-BtO2TrI7.mjs";
5
+ import { t as serializeXml } from "./serializer-C6nm0mRJ.mjs";
6
6
  //#region src/packaging/relationships.ts
7
7
  const RelationshipSchema = defineSchema({
8
8
  tagname: "Relationship",
@@ -800,4 +800,4 @@ function manifestFromBytes(bytes) {
800
800
  //#endregion
801
801
  export { findByType as $, readBoolValue as A, corePropsFromBytes as B, makeBoolValue as C, makeFiletimeValue as D, makeDoubleValue as E, removeCustomProperty as F, setWorkbookDescription as G, makeCoreProperties as H, setCustomBoolProperty as I, setWorkbookSubject as J, setWorkbookKeywords as K, setCustomDateProperty as L, readFiletimeValue as M, readIntValue as N, makeIntValue as O, readStringValue as P, findById as Q, setCustomNumberProperty as R, makeAsciiStringValue as S, makeDateValue as T, setWorkbookCategory as U, corePropsToBytes as V, setWorkbookCreator as W, appendRel as X, setWorkbookTitle as Y, findAllByType as Z, customPropsFromBytes as _, makeManifest as a, getCustomPropertyValue as b, extendedPropsFromBytes as c, setWorkbookAppVersion as d, indexRelsById as et, setWorkbookApplication as f, appendCustomProperty as g, setWorkbookManager as h, findOverrideByContentType as i, readDoubleValue as j, makeStringValue as k, extendedPropsToBytes as l, setWorkbookHyperlinkBase as m, addOverride as n, relsFromBytes as nt, manifestFromBytes as o, setWorkbookCompany as p, setWorkbookLastModifiedBy as q, findOverride as r, relsToBytes as rt, manifestToBytes as s, addDefault as t, makeRelationships as tt, makeExtendedProperties as u, customPropsToBytes as v, makeCustomProperties as w, listCustomProperties as x, findCustomPropertyByName as y, setCustomStringProperty as z };
802
802
 
803
- //# sourceMappingURL=manifest-Cm9K7D62.mjs.map
803
+ //# sourceMappingURL=manifest-pLmx7KYh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-pLmx7KYh.mjs","names":[],"sources":["../src/packaging/relationships.ts","../src/packaging/core.ts","../src/packaging/custom.ts","../src/packaging/extended.ts","../src/packaging/manifest.ts"],"sourcesContent":["// `*.rels` files — Open Packaging Conventions relationship lists.\n//\n// Mirrors openpyxl/openpyxl/packaging/relationship.py. Relationship Ids\n// (`rId{N}`) auto-increment using the smallest unused integer so the list stays\n// deterministic even when callers mix in pre-assigned ids.\n\nimport { defineSchema, type Schema } from '../schema/core.js';\nimport { fromTree, toTree } from '../schema/serialize.js';\nimport { PKG_REL_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { serializeXml } from '../xml/serializer.js';\n\nexport interface Relationship {\n /** rIdN identifier; unique within the parent .rels file. */\n id: string;\n /** Full relationship type URI. */\n type: string;\n /** Target — relative part path or absolute URL when targetMode === 'External'. */\n target: string;\n /** Defaults to internal. */\n targetMode?: 'External' | 'Internal';\n}\n\nexport interface Relationships {\n rels: Relationship[];\n}\n\nconst RelationshipSchema = defineSchema<Relationship>({\n tagname: 'Relationship',\n xmlNs: PKG_REL_NS,\n attrs: {\n id: { kind: 'string', xmlName: 'Id' },\n type: { kind: 'string', xmlName: 'Type' },\n target: { kind: 'string', xmlName: 'Target' },\n targetMode: {\n kind: 'enum',\n values: ['External', 'Internal'],\n xmlName: 'TargetMode',\n optional: true,\n },\n },\n elements: [],\n});\n\nconst RelationshipsSchema: Schema<Relationships> = defineSchema<Relationships>({\n tagname: 'Relationships',\n xmlNs: PKG_REL_NS,\n attrs: {},\n elements: [\n {\n kind: 'sequence',\n key: 'rels',\n itemName: 'Relationship',\n itemNs: PKG_REL_NS,\n itemSchema: () => RelationshipSchema,\n },\n ],\n});\n\nexport function makeRelationships(): Relationships {\n return { rels: [] };\n}\n\nconst RID_RE = /^rId(\\d+)$/;\n\nconst allocateNextId = (rels: Relationships): string => {\n // Smallest positive integer not yet used as `rId{N}`. Linear scan is fine\n // because rels lists are small (tens of entries in real workbooks).\n const used = new Set<number>();\n for (const r of rels.rels) {\n const m = RID_RE.exec(r.id);\n if (m !== null) {\n const n = Number.parseInt(m[1] ?? '0', 10);\n if (Number.isFinite(n) && n > 0) used.add(n);\n }\n }\n let n = 1;\n while (used.has(n)) n++;\n return `rId${n}`;\n};\n\n/**\n * Append a relationship and return the resulting object. Auto-assigns the next\n * free `rId{N}` Id.\n */\nexport function appendRel(rels: Relationships, type: string, target: string, targetMode?: 'External'): Relationship {\n const next: Relationship = { id: allocateNextId(rels), type, target };\n if (targetMode !== undefined) next.targetMode = targetMode;\n rels.rels.push(next);\n return next;\n}\n\nexport function findById(rels: Relationships, id: string): Relationship | undefined {\n for (const r of rels.rels) if (r.id === id) return r;\n return undefined;\n}\n\n/**\n * Build an id → relationship index for callers that look up the same .rels\n * file many times in a hot loop. Cheaper than repeated {@link findById} once\n * the rels count crosses a handful of entries.\n */\nexport function indexRelsById(rels: Relationships): Map<string, Relationship> {\n const out = new Map<string, Relationship>();\n for (const r of rels.rels) out.set(r.id, r);\n return out;\n}\n\nexport function findByType(rels: Relationships, type: string): Relationship | undefined {\n for (const r of rels.rels) if (r.type === type) return r;\n return undefined;\n}\n\nexport function findAllByType(rels: Relationships, type: string): Relationship[] {\n const out: Relationship[] = [];\n for (const r of rels.rels) if (r.type === type) out.push(r);\n return out;\n}\n\nexport function relsToBytes(rels: Relationships): Uint8Array {\n return serializeXml(toTree(rels, RelationshipsSchema));\n}\n\nexport function relsFromBytes(bytes: Uint8Array | string): Relationships {\n return fromTree(parseXml(bytes), RelationshipsSchema);\n}\n","// `docProps/core.xml` — Dublin Core / Office core document properties.\n//\n// Each property lives in its own namespace (cp / dc / dcterms). The dcterms\n// timestamps carry an `xsi:type=\"dcterms:W3CDTF\"` marker which we reproduce as\n// a fixed attr on those text elements via the schema layer's `text` element\n// kind.\n\nimport { defineSchema, type Schema } from '../schema/core.js';\nimport { fromTree, toTree } from '../schema/serialize.js';\nimport { COREPROPS_NS, DCORE_NS, DCTERMS_NS, XSI_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { serializeXml } from '../xml/serializer.js';\n\n/**\n * Set of properties exposed under `docProps/core.xml`. All fields are optional;\n * the workbook only emits those that are set. Timestamps are stored as ISO-8601\n * strings (the W3CDTF subset) — no Date conversion happens at this layer;\n * phase-3 saveWorkbook is responsible for stamping `modified` to `now()` on\n * each save.\n */\nexport interface CoreProperties {\n category?: string;\n contentStatus?: string;\n /** ISO-8601 W3CDTF; auto-stamped on save in phase 3. */\n created?: string;\n creator?: string;\n description?: string;\n identifier?: string;\n keywords?: string;\n language?: string;\n lastModifiedBy?: string;\n /** ISO-8601 W3CDTF. */\n lastPrinted?: string;\n /** ISO-8601 W3CDTF; auto-stamped on save in phase 3. */\n modified?: string;\n revision?: string;\n subject?: string;\n title?: string;\n version?: string;\n}\n\nconst W3CDTF_ATTRS: Record<string, string> = {\n [`{${XSI_NS}}type`]: 'dcterms:W3CDTF',\n};\n\nconst CorePropertiesSchema: Schema<CoreProperties> = defineSchema<CoreProperties>({\n tagname: 'coreProperties',\n xmlNs: COREPROPS_NS,\n attrs: {},\n elements: [\n // openpyxl's child-namespace assignment, mirrored exactly:\n { kind: 'text', key: 'category', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'contentStatus', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'keywords', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'lastModifiedBy', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n {\n kind: 'text',\n key: 'lastPrinted',\n xmlNs: DCTERMS_NS,\n primitive: 'string',\n optional: true,\n attrs: W3CDTF_ATTRS,\n },\n { kind: 'text', key: 'revision', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'version', xmlNs: COREPROPS_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'description', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'identifier', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'language', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'subject', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'title', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n { kind: 'text', key: 'creator', xmlNs: DCORE_NS, primitive: 'string', optional: true },\n {\n kind: 'text',\n key: 'created',\n xmlNs: DCTERMS_NS,\n primitive: 'string',\n optional: true,\n attrs: W3CDTF_ATTRS,\n },\n {\n kind: 'text',\n key: 'modified',\n xmlNs: DCTERMS_NS,\n primitive: 'string',\n optional: true,\n attrs: W3CDTF_ATTRS,\n },\n ],\n});\n\nexport function makeCoreProperties(): CoreProperties {\n return {};\n}\n\nexport function corePropsToBytes(p: CoreProperties): Uint8Array {\n return serializeXml(toTree(p, CorePropertiesSchema));\n}\n\nexport function corePropsFromBytes(bytes: Uint8Array | string): CoreProperties {\n return fromTree(parseXml(bytes), CorePropertiesSchema);\n}\n\n// ---- Workbook ergonomic helpers ----------------------------------------\n\nimport type { Workbook } from '../workbook/workbook.js';\n\nconst ensureCoreProperties = (wb: Workbook): CoreProperties => {\n if (!wb.properties) wb.properties = {};\n return wb.properties;\n};\n\n/** Set the document author (Excel \"File → Properties → Author\"). */\nexport const setWorkbookCreator = (wb: Workbook, creator: string): void => {\n ensureCoreProperties(wb).creator = creator;\n};\n\n/** Set the document title. */\nexport const setWorkbookTitle = (wb: Workbook, title: string): void => {\n ensureCoreProperties(wb).title = title;\n};\n\n/** Set the document subject. */\nexport const setWorkbookSubject = (wb: Workbook, subject: string): void => {\n ensureCoreProperties(wb).subject = subject;\n};\n\n/** Set the document description / abstract. */\nexport const setWorkbookDescription = (wb: Workbook, description: string): void => {\n ensureCoreProperties(wb).description = description;\n};\n\n/** Set comma- or semicolon-separated keywords. */\nexport const setWorkbookKeywords = (wb: Workbook, keywords: string): void => {\n ensureCoreProperties(wb).keywords = keywords;\n};\n\n/** Set the \"last modified by\" name (defaults to creator if absent). */\nexport const setWorkbookLastModifiedBy = (wb: Workbook, name: string): void => {\n ensureCoreProperties(wb).lastModifiedBy = name;\n};\n\n/** Set the document category (e.g. \"Reports\", \"Drafts\"). */\nexport const setWorkbookCategory = (wb: Workbook, category: string): void => {\n ensureCoreProperties(wb).category = category;\n};\n","// `docProps/custom.xml` — user-defined document properties. Each <property>\n// carries fmtid/pid/name attributes plus a single typed value child from the\n// vt: namespace (vt:lpwstr, vt:i4, vt:bool, …).\n//\n// The Schema layer drives the <property> element attribute set; the typed-value\n// child is stored as a raw XmlNode and the `make*Value` / `read*Value` helpers\n// below cover the most common conversions.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { CPROPS_FMTID, CUSTPROPS_NS, parseQName, VTYPES_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { serializeXml } from '../xml/serializer.js';\nimport { el, type XmlNode } from '../xml/tree.js';\n\nexport interface CustomProperty {\n /** User-visible property name (must be unique within the workbook). */\n name: string;\n /** OOXML \"Property Identifier\"; ≥ 2. Auto-allocated if absent on append. */\n pid: number;\n /** Format ID GUID. Defaults to the well-known {D5CDD505-…} on append. */\n fmtid?: string;\n /** Typed value as a raw vt: element. Use the `make*Value` helpers. */\n value: XmlNode;\n}\n\nexport interface CustomProperties {\n properties: CustomProperty[];\n}\n\nexport function makeCustomProperties(): CustomProperties {\n return { properties: [] };\n}\n\nconst PROPERTY_NAME = `{${CUSTPROPS_NS}}property`;\nconst PROPERTIES_NAME = `{${CUSTPROPS_NS}}Properties`;\n\n// ---- typed-value constructors ----------------------------------------------\n\nconst vt = (local: string, text: string): XmlNode => el(`{${VTYPES_NS}}${local}`, {}, [], text);\n\nexport function makeStringValue(s: string): XmlNode {\n return vt('lpwstr', s);\n}\nexport function makeAsciiStringValue(s: string): XmlNode {\n return vt('lpstr', s);\n}\nexport function makeIntValue(n: number): XmlNode {\n if (!Number.isInteger(n)) throw new OpenXmlSchemaError(`makeIntValue: ${n} is not an integer`);\n return vt('i4', String(n));\n}\nexport function makeDoubleValue(n: number): XmlNode {\n if (!Number.isFinite(n)) throw new OpenXmlSchemaError(`makeDoubleValue: ${n} is not finite`);\n return vt('r8', String(n));\n}\nexport function makeBoolValue(b: boolean): XmlNode {\n return vt('bool', b ? '1' : '0');\n}\nexport function makeFiletimeValue(iso: string): XmlNode {\n return vt('filetime', iso);\n}\nexport function makeDateValue(iso: string): XmlNode {\n return vt('date', iso);\n}\n\n// ---- typed-value readers ---------------------------------------------------\n\nconst localNameOf = (n: XmlNode): string => parseQName(n.name).local;\n\nexport function readStringValue(v: XmlNode): string | undefined {\n const ln = localNameOf(v);\n if (ln === 'lpwstr' || ln === 'lpstr' || ln === 'bstr') return v.text ?? '';\n return undefined;\n}\nexport function readIntValue(v: XmlNode): number | undefined {\n const ln = localNameOf(v);\n if (\n ln === 'i4' ||\n ln === 'i2' ||\n ln === 'i1' ||\n ln === 'int' ||\n ln === 'uint' ||\n ln === 'ui4' ||\n ln === 'ui2' ||\n ln === 'ui1'\n ) {\n const n = Number.parseInt(v.text ?? '', 10);\n return Number.isFinite(n) ? n : undefined;\n }\n return undefined;\n}\nexport function readDoubleValue(v: XmlNode): number | undefined {\n const ln = localNameOf(v);\n if (ln === 'r4' || ln === 'r8' || ln === 'decimal' || ln === 'cy') {\n const n = Number.parseFloat(v.text ?? '');\n return Number.isFinite(n) ? n : undefined;\n }\n return undefined;\n}\nexport function readBoolValue(v: XmlNode): boolean | undefined {\n if (localNameOf(v) !== 'bool') return undefined;\n const t = (v.text ?? '').toLowerCase();\n if (t === '1' || t === 'true' || t === 't') return true;\n if (t === '0' || t === 'false' || t === 'f') return false;\n return undefined;\n}\nexport function readFiletimeValue(v: XmlNode): string | undefined {\n if (localNameOf(v) === 'filetime') return v.text ?? '';\n return undefined;\n}\n\n// ---- collection ops --------------------------------------------------------\n\nconst allocatePid = (props: CustomProperties): number => {\n // pid 0 / 1 are reserved by the OPC spec; user pids start at 2.\n const used = new Set<number>();\n for (const p of props.properties) used.add(p.pid);\n let n = 2;\n while (used.has(n)) n++;\n return n;\n};\n\nexport function appendCustomProperty(\n props: CustomProperties,\n name: string,\n value: XmlNode,\n opts?: { pid?: number; fmtid?: string },\n): CustomProperty {\n const pid = opts?.pid ?? allocatePid(props);\n const out: CustomProperty = { name, pid, value };\n if (opts?.fmtid !== undefined) out.fmtid = opts.fmtid;\n props.properties.push(out);\n return out;\n}\n\nexport function findCustomPropertyByName(props: CustomProperties, name: string): CustomProperty | undefined {\n for (const p of props.properties) if (p.name === name) return p;\n return undefined;\n}\n\n// ---- bytes round-trip ------------------------------------------------------\n\nexport function customPropsToBytes(p: CustomProperties): Uint8Array {\n const root = el(PROPERTIES_NAME);\n for (const prop of p.properties) {\n const propEl = el(PROPERTY_NAME, {\n fmtid: prop.fmtid ?? CPROPS_FMTID,\n pid: String(prop.pid),\n name: prop.name,\n });\n propEl.children.push(prop.value);\n root.children.push(propEl);\n }\n return serializeXml(root);\n}\n\nexport function customPropsFromBytes(bytes: Uint8Array | string): CustomProperties {\n const root = parseXml(bytes);\n if (root.name !== PROPERTIES_NAME) {\n throw new OpenXmlSchemaError(`customPropsFromBytes: expected <Properties>, got \"${root.name}\"`);\n }\n const properties: CustomProperty[] = [];\n for (const propEl of root.children) {\n if (propEl.name !== PROPERTY_NAME) continue;\n const fmtid = propEl.attrs['fmtid'];\n const pidRaw = propEl.attrs['pid'];\n const name = propEl.attrs['name'];\n if (name === undefined || pidRaw === undefined) {\n throw new OpenXmlSchemaError('custom.xml: <property> requires name and pid attributes');\n }\n const pid = Number.parseInt(pidRaw, 10);\n if (!Number.isFinite(pid)) {\n throw new OpenXmlSchemaError(`custom.xml: <property> pid is not an integer (got \"${pidRaw}\")`);\n }\n const value = propEl.children[0];\n if (value === undefined) {\n throw new OpenXmlSchemaError(`custom.xml: <property name=\"${name}\"> has no typed-value child`);\n }\n const out: CustomProperty = { name, pid, value };\n if (fmtid !== undefined) out.fmtid = fmtid;\n properties.push(out);\n }\n return { properties };\n}\n\n// ---- Workbook ergonomic helpers ----------------------------------------\n\nimport type { Workbook } from '../workbook/workbook.js';\n\nconst ensureCustomProperties = (wb: Workbook): CustomProperties => {\n if (!wb.customProperties) wb.customProperties = makeCustomProperties();\n return wb.customProperties;\n};\n\nconst replaceOrAppend = (\n wb: Workbook,\n name: string,\n value: XmlNode,\n opts?: { fmtid?: string },\n): CustomProperty => {\n const props = ensureCustomProperties(wb);\n const existing = findCustomPropertyByName(props, name);\n if (existing) {\n existing.value = value;\n if (opts?.fmtid !== undefined) existing.fmtid = opts.fmtid;\n return existing;\n }\n return appendCustomProperty(props, name, value, opts);\n};\n\n/** Set (or replace) a custom string property. */\nexport const setCustomStringProperty = (wb: Workbook, name: string, value: string): CustomProperty =>\n replaceOrAppend(wb, name, makeStringValue(value));\n\n/**\n * Set (or replace) a custom numeric property. Integers (within Int32 range) are\n * stored as `vt:i4`; non-integer / out-of-range numbers as `vt:r8` doubles.\n */\nexport const setCustomNumberProperty = (wb: Workbook, name: string, value: number): CustomProperty => {\n if (!Number.isFinite(value)) {\n throw new OpenXmlSchemaError(`setCustomNumberProperty: value \"${value}\" is not finite`);\n }\n const isInt32 = Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;\n const node = isInt32 ? makeIntValue(value) : makeDoubleValue(value);\n return replaceOrAppend(wb, name, node);\n};\n\n/** Set (or replace) a custom boolean property. */\nexport const setCustomBoolProperty = (wb: Workbook, name: string, value: boolean): CustomProperty =>\n replaceOrAppend(wb, name, makeBoolValue(value));\n\n/**\n * Set (or replace) a custom date property. Accepts a `Date` (converted to ISO\n * via `toISOString()`) or a pre-formatted W3C-DTF string.\n */\nexport const setCustomDateProperty = (\n wb: Workbook,\n name: string,\n value: Date | string,\n): CustomProperty => {\n const iso = value instanceof Date ? value.toISOString() : value;\n return replaceOrAppend(wb, name, makeFiletimeValue(iso));\n};\n\n/**\n * Read the typed value of a custom property by name. Tries each decoder in turn\n * — string, int, double, bool, filetime — and returns the first hit. Returns\n * `undefined` for unknown names or unsupported types.\n */\nexport const getCustomPropertyValue = (\n wb: Workbook,\n name: string,\n): string | number | boolean | undefined => {\n if (!wb.customProperties) return undefined;\n const prop = findCustomPropertyByName(wb.customProperties, name);\n if (!prop) return undefined;\n const s = readStringValue(prop.value);\n if (s !== undefined) return s;\n const i = readIntValue(prop.value);\n if (i !== undefined) return i;\n const d = readDoubleValue(prop.value);\n if (d !== undefined) return d;\n const b = readBoolValue(prop.value);\n if (b !== undefined) return b;\n const ft = readFiletimeValue(prop.value);\n if (ft !== undefined) return ft;\n return undefined;\n};\n\n/**\n * Remove a custom property by name. Returns `true` when one was removed,\n * `false` when the name wasn't found.\n */\nexport const removeCustomProperty = (wb: Workbook, name: string): boolean => {\n if (!wb.customProperties) return false;\n const arr = wb.customProperties.properties;\n const i = arr.findIndex((p) => p.name === name);\n if (i < 0) return false;\n arr.splice(i, 1);\n return true;\n};\n\n/** Read-only snapshot of every custom property. */\nexport const listCustomProperties = (wb: Workbook): ReadonlyArray<CustomProperty> => {\n return wb.customProperties?.properties ?? [];\n};\n","// `docProps/app.xml` — Office \"extended\" document properties.\n//\n// Mirrors openpyxl/openpyxl/packaging/extended.py. Most fields are flat (text\n// or numeric). The four vector-shaped children — HeadingPairs, TitlesOfParts,\n// HLinks, DigSig — are kept as raw XmlNode subtrees and round-tripped verbatim;\n// modelling vt:vector explicitly is a phase-3 concern at the earliest. See row\n// for `packaging/extended.py`.\n\nimport { defineSchema, type Schema } from '../schema/core.js';\nimport { fromTree, toTree } from '../schema/serialize.js';\nimport { XPROPS_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { serializeXml } from '../xml/serializer.js';\nimport type { XmlNode } from '../xml/tree.js';\n\nexport interface ExtendedProperties {\n application?: string;\n appVersion?: string;\n characters?: number;\n charactersWithSpaces?: number;\n company?: string;\n digitalSignature?: XmlNode;\n docSecurity?: number;\n hLinks?: XmlNode;\n headingPairs?: XmlNode;\n hiddenSlides?: number;\n hyperlinkBase?: string;\n hyperlinks?: XmlNode;\n hyperlinksChanged?: boolean;\n lines?: number;\n linksUpToDate?: boolean;\n manager?: string;\n mmClips?: number;\n notes?: number;\n pages?: number;\n paragraphs?: number;\n presentationFormat?: string;\n scaleCrop?: boolean;\n sharedDoc?: boolean;\n slides?: number;\n template?: string;\n titlesOfParts?: XmlNode;\n totalTime?: number;\n words?: number;\n}\n\nconst ExtendedSchema: Schema<ExtendedProperties> = defineSchema<ExtendedProperties>({\n tagname: 'Properties',\n xmlNs: XPROPS_NS,\n attrs: {},\n // Element order chosen to match the Office output convention.\n elements: [\n { kind: 'text', key: 'template', xmlNs: XPROPS_NS, name: 'Template', primitive: 'string', optional: true },\n { kind: 'text', key: 'manager', xmlNs: XPROPS_NS, name: 'Manager', primitive: 'string', optional: true },\n { kind: 'text', key: 'company', xmlNs: XPROPS_NS, name: 'Company', primitive: 'string', optional: true },\n { kind: 'text', key: 'pages', xmlNs: XPROPS_NS, name: 'Pages', primitive: 'int', optional: true },\n { kind: 'text', key: 'words', xmlNs: XPROPS_NS, name: 'Words', primitive: 'int', optional: true },\n { kind: 'text', key: 'characters', xmlNs: XPROPS_NS, name: 'Characters', primitive: 'int', optional: true },\n {\n kind: 'text',\n key: 'presentationFormat',\n xmlNs: XPROPS_NS,\n name: 'PresentationFormat',\n primitive: 'string',\n optional: true,\n },\n { kind: 'text', key: 'lines', xmlNs: XPROPS_NS, name: 'Lines', primitive: 'int', optional: true },\n { kind: 'text', key: 'paragraphs', xmlNs: XPROPS_NS, name: 'Paragraphs', primitive: 'int', optional: true },\n { kind: 'text', key: 'slides', xmlNs: XPROPS_NS, name: 'Slides', primitive: 'int', optional: true },\n { kind: 'text', key: 'notes', xmlNs: XPROPS_NS, name: 'Notes', primitive: 'int', optional: true },\n { kind: 'text', key: 'totalTime', xmlNs: XPROPS_NS, name: 'TotalTime', primitive: 'int', optional: true },\n { kind: 'text', key: 'hiddenSlides', xmlNs: XPROPS_NS, name: 'HiddenSlides', primitive: 'int', optional: true },\n { kind: 'text', key: 'mmClips', xmlNs: XPROPS_NS, name: 'MMClips', primitive: 'int', optional: true },\n { kind: 'text', key: 'scaleCrop', xmlNs: XPROPS_NS, name: 'ScaleCrop', primitive: 'bool', optional: true },\n { kind: 'raw', key: 'headingPairs', xmlNs: XPROPS_NS, name: 'HeadingPairs', optional: true },\n { kind: 'raw', key: 'titlesOfParts', xmlNs: XPROPS_NS, name: 'TitlesOfParts', optional: true },\n { kind: 'raw', key: 'hLinks', xmlNs: XPROPS_NS, name: 'HLinks', optional: true },\n { kind: 'raw', key: 'hyperlinks', xmlNs: XPROPS_NS, name: 'Hyperlinks', optional: true },\n { kind: 'text', key: 'linksUpToDate', xmlNs: XPROPS_NS, name: 'LinksUpToDate', primitive: 'bool', optional: true },\n { kind: 'text', key: 'sharedDoc', xmlNs: XPROPS_NS, name: 'SharedDoc', primitive: 'bool', optional: true },\n {\n kind: 'text',\n key: 'hyperlinkBase',\n xmlNs: XPROPS_NS,\n name: 'HyperlinkBase',\n primitive: 'string',\n optional: true,\n },\n {\n kind: 'text',\n key: 'hyperlinksChanged',\n xmlNs: XPROPS_NS,\n name: 'HyperlinksChanged',\n primitive: 'bool',\n optional: true,\n },\n { kind: 'raw', key: 'digitalSignature', xmlNs: XPROPS_NS, name: 'DigSig', optional: true },\n { kind: 'text', key: 'application', xmlNs: XPROPS_NS, name: 'Application', primitive: 'string', optional: true },\n { kind: 'text', key: 'appVersion', xmlNs: XPROPS_NS, name: 'AppVersion', primitive: 'string', optional: true },\n { kind: 'text', key: 'docSecurity', xmlNs: XPROPS_NS, name: 'DocSecurity', primitive: 'int', optional: true },\n {\n kind: 'text',\n key: 'charactersWithSpaces',\n xmlNs: XPROPS_NS,\n name: 'CharactersWithSpaces',\n primitive: 'int',\n optional: true,\n },\n ],\n});\n\nexport function makeExtendedProperties(): ExtendedProperties {\n return {};\n}\n\nexport function extendedPropsToBytes(p: ExtendedProperties): Uint8Array {\n return serializeXml(toTree(p, ExtendedSchema));\n}\n\nexport function extendedPropsFromBytes(bytes: Uint8Array | string): ExtendedProperties {\n return fromTree(parseXml(bytes), ExtendedSchema);\n}\n\n// ---- Workbook ergonomic helpers ----------------------------------------\n\nimport type { Workbook } from '../workbook/workbook.js';\n\nconst ensureAppProperties = (wb: Workbook): ExtendedProperties => {\n if (!wb.appProperties) wb.appProperties = {};\n return wb.appProperties;\n};\n\n/** Set the company name on docProps/app.xml. */\nexport const setWorkbookCompany = (wb: Workbook, company: string): void => {\n ensureAppProperties(wb).company = company;\n};\n\n/** Set the manager / supervisor name on docProps/app.xml. */\nexport const setWorkbookManager = (wb: Workbook, manager: string): void => {\n ensureAppProperties(wb).manager = manager;\n};\n\n/** Set the application name (e.g. `\"Microsoft Excel\"`). */\nexport const setWorkbookApplication = (wb: Workbook, application: string): void => {\n ensureAppProperties(wb).application = application;\n};\n\n/** Set the application version (typically `\"16.0300\"` for Excel 365). */\nexport const setWorkbookAppVersion = (wb: Workbook, version: string): void => {\n ensureAppProperties(wb).appVersion = version;\n};\n\n/** Set the hyperlink base URL — Excel uses this as a prefix for relative `&F` codes. */\nexport const setWorkbookHyperlinkBase = (wb: Workbook, base: string): void => {\n ensureAppProperties(wb).hyperlinkBase = base;\n};\n","// [Content_Types].xml — the package manifest. Tracks default content types per\n// file extension and per-part Override entries.\n\nimport { defineSchema, type Schema } from '../schema/core.js';\nimport { fromTree, toTree } from '../schema/serialize.js';\nimport { CONTYPES_NS } from '../xml/namespaces.js';\nimport { parseXml } from '../xml/parser.js';\nimport { serializeXml } from '../xml/serializer.js';\n\nexport interface DefaultEntry {\n /** File extension without leading dot (e.g. \"rels\", \"xml\", \"png\"). */\n ext: string;\n contentType: string;\n}\n\nexport interface OverrideEntry {\n /** Part name path including leading slash (e.g. \"/xl/workbook.xml\"). */\n partName: string;\n contentType: string;\n}\n\nexport interface Manifest {\n defaults: DefaultEntry[];\n overrides: OverrideEntry[];\n}\n\nconst DefaultSchema = defineSchema<DefaultEntry>({\n tagname: 'Default',\n xmlNs: CONTYPES_NS,\n attrs: {\n ext: { kind: 'string', xmlName: 'Extension' },\n contentType: { kind: 'string', xmlName: 'ContentType' },\n },\n elements: [],\n});\n\nconst OverrideSchema = defineSchema<OverrideEntry>({\n tagname: 'Override',\n xmlNs: CONTYPES_NS,\n attrs: {\n partName: { kind: 'string', xmlName: 'PartName' },\n contentType: { kind: 'string', xmlName: 'ContentType' },\n },\n elements: [],\n});\n\nconst ManifestSchema: Schema<Manifest> = defineSchema<Manifest>({\n tagname: 'Types',\n xmlNs: CONTYPES_NS,\n attrs: {},\n elements: [\n {\n kind: 'sequence',\n key: 'defaults',\n itemName: 'Default',\n itemNs: CONTYPES_NS,\n itemSchema: () => DefaultSchema,\n },\n {\n kind: 'sequence',\n key: 'overrides',\n itemName: 'Override',\n itemNs: CONTYPES_NS,\n itemSchema: () => OverrideSchema,\n },\n ],\n});\n\nexport function makeManifest(): Manifest {\n return { defaults: [], overrides: [] };\n}\n\n/** Register a default content type for an extension. Idempotent. */\nexport function addDefault(m: Manifest, ext: string, contentType: string): void {\n for (const d of m.defaults) {\n if (d.ext === ext) {\n if (d.contentType !== contentType) {\n d.contentType = contentType; // newer wins; matches openpyxl behaviour\n }\n return;\n }\n }\n m.defaults.push({ ext, contentType });\n}\n\n/** Register an Override for a specific part. Idempotent. */\nexport function addOverride(m: Manifest, partName: string, contentType: string): void {\n for (const o of m.overrides) {\n if (o.partName === partName) {\n if (o.contentType !== contentType) o.contentType = contentType;\n return;\n }\n }\n m.overrides.push({ partName, contentType });\n}\n\nexport function findOverride(m: Manifest, partName: string): OverrideEntry | undefined {\n for (const o of m.overrides) if (o.partName === partName) return o;\n return undefined;\n}\n\n/** Find the first Override matching a content type. */\nexport function findOverrideByContentType(m: Manifest, contentType: string): OverrideEntry | undefined {\n for (const o of m.overrides) if (o.contentType === contentType) return o;\n return undefined;\n}\n\nexport function manifestToBytes(m: Manifest): Uint8Array {\n return serializeXml(toTree(m, ManifestSchema));\n}\n\nexport function manifestFromBytes(bytes: Uint8Array | string): Manifest {\n return fromTree(parseXml(bytes), ManifestSchema);\n}\n"],"mappings":";;;;;;AA2BA,MAAM,qBAAqB,aAA2B;CACpD,SAAS;CACT,OAAO;CACP,OAAO;EACL,IAAI;GAAE,MAAM;GAAU,SAAS;EAAK;EACpC,MAAM;GAAE,MAAM;GAAU,SAAS;EAAO;EACxC,QAAQ;GAAE,MAAM;GAAU,SAAS;EAAS;EAC5C,YAAY;GACV,MAAM;GACN,QAAQ,CAAC,YAAY,UAAU;GAC/B,SAAS;GACT,UAAU;EACZ;CACF;CACA,UAAU,CAAC;AACb,CAAC;AAED,MAAM,sBAA6C,aAA4B;CAC7E,SAAS;CACT,OAAO;CACP,OAAO,CAAC;CACR,UAAU,CACR;EACE,MAAM;EACN,KAAK;EACL,UAAU;EACV,QAAQ;EACR,kBAAkB;CACpB,CACF;AACF,CAAC;AAED,SAAgB,oBAAmC;CACjD,OAAO,EAAE,MAAM,CAAC,EAAE;AACpB;AAEA,MAAM,SAAS;AAEf,MAAM,kBAAkB,SAAgC;CAGtD,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,KAAK,KAAK,MAAM;EACzB,MAAM,IAAI,OAAO,KAAK,EAAE,EAAE;EAC1B,IAAI,MAAM,MAAM;GACd,MAAM,IAAI,OAAO,SAAS,EAAE,MAAM,KAAK,EAAE;GACzC,IAAI,OAAO,SAAS,CAAC,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC;EAC7C;CACF;CACA,IAAI,IAAI;CACR,OAAO,KAAK,IAAI,CAAC,GAAG;CACpB,OAAO,MAAM;AACf;;;;;AAMA,S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E;EAAK;CAAY,CAAC;AACtC;;AAGA,SAAgB,YAAY,GAAa,UAAkB,aAA2B;CACpF,KAAK,MAAM,KAAK,EAAE,WAChB,IAAI,EAAE,aAAa,UAAU;EAC3B,IAAI,EAAE,gBAAgB,aAAa,EAAE,cAAc;EACnD;CACF;CAEF,EAAE,UAAU,KAAK;EAAE;EAAU;CAAY,CAAC;AAC5C;AAEA,SAAgB,aAAa,GAAa,UAA6C;CACrF,KAAK,MAAM,KAAK,EAAE,WAAW,IAAI,EAAE,aAAa,UAAU,OAAO;AAEnE;;AAGA,SAAgB,0BAA0B,GAAa,aAAgD;CACrG,KAAK,MAAM,KAAK,EAAE,WAAW,IAAI,EAAE,gBAAgB,aAAa,OAAO;AAEzE;AAEA,SAAgB,gBAAgB,GAAyB;CACvD,OAAO,aAAa,OAAO,GAAG,cAAc,CAAC;AAC/C;AAEA,SAAgB,kBAAkB,OAAsC;CACtE,OAAO,SAAS,SAAS,KAAK,GAAG,cAAc;AACjD"}
package/dist/node.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { fromBuffer, toBuffer } from './io/node';
2
- export { fromFile, fromFileSync, fromReadable, toFile, toWritable } from './io/node-fs';
3
- export { workbookToBuffer } from './io/node-save';
1
+ export { fromBuffer, toBuffer } from './io/node.js';
2
+ export { fromFile, fromFileSync, fromReadable, toFile, toWritable } from './io/node-fs.js';
3
+ export { workbookToBuffer } from './io/node-save.js';
package/dist/node.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as OpenXmlIoError } from "./exceptions-D-CFwxgm.mjs";
2
- import { t as saveWorkbook } from "./save-2moCT3Af.mjs";
2
+ import { t as saveWorkbook } from "./save-Bqcf8w3g.mjs";
3
3
  import { createReadStream, createWriteStream, readFileSync } from "node:fs";
4
4
  import { readFile, unlink } from "node:fs/promises";
5
5
  import { once } from "node:events";
package/dist/node.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.mjs","names":[],"sources":["../src/io/node.ts","../src/io/node-fs.ts","../src/io/node-save.ts"],"sourcesContent":["// In-memory Node helpers.\n//\n// `fromBuffer` / `toBuffer` rely only on the global `Buffer` symbol — no\n// `node:*` imports — so they're safe to ship through the `@office-kit/xlsx/streaming`\n// browser-targeted entry too. Filesystem + Readable / Writable helpers live in\n// `./node-fs.ts` (re-exported via `@office-kit/xlsx/node`) where the `node:fs` /\n// `node:stream` imports stay out of the browser-safe surface.\n\nimport { OpenXmlIoError } from '../utils/exceptions';\nimport type { BufferedSinkWriter, XlsxSink } from './sink';\nimport type { XlsxSource } from './source';\n\n/**\n * Wrap a Buffer or Uint8Array as an XlsxSource. The underlying bytes are\n * referenced — no copy — so callers must not mutate them while the source is in\n * use.\n */\nexport function fromBuffer(buf: Buffer | Uint8Array): XlsxSource {\n if (!(buf instanceof Uint8Array)) {\n throw new OpenXmlIoError('fromBuffer expects a Buffer or Uint8Array');\n }\n // Buffer is a subclass of Uint8Array, so a single normalisation suffices.\n const bytes: Uint8Array = buf instanceof Buffer ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf;\n return {\n async toBytes() {\n return bytes;\n },\n toStream() {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n },\n };\n}\n\n/**\n * In-memory Buffer sink. The buffered path concatenates appended chunks into a\n * single allocation when {@link BufferedSinkWriter.finish} resolves; the\n * convenience `result()` returns it as a Node Buffer.\n */\nexport function toBuffer(): XlsxSink & { toBytes(): BufferedSinkWriter; result(): Buffer } {\n const chunks: Uint8Array[] = [];\n let finalised: Uint8Array | undefined;\n\n const finalise = (): Uint8Array => {\n if (finalised !== undefined) return finalised;\n let total = 0;\n for (const c of chunks) total += c.byteLength;\n const out = new Uint8Array(total);\n let off = 0;\n for (const c of chunks) {\n out.set(c, off);\n off += c.byteLength;\n }\n finalised = out;\n chunks.length = 0;\n return out;\n };\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) {\n throw new OpenXmlIoError('toBuffer sink: write after finish');\n }\n if (!(chunk instanceof Uint8Array)) {\n throw new OpenXmlIoError('toBuffer sink: chunk is not a Uint8Array');\n }\n chunks.push(chunk);\n },\n async finish(): Promise<Uint8Array> {\n return finalise();\n },\n abort(): void {\n if (finalised !== undefined) return;\n finalised = new Uint8Array(0);\n chunks.length = 0;\n },\n };\n },\n result(): Buffer {\n const bytes = finalise();\n return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n },\n };\n}\n","// Node filesystem + Readable / Writable I/O helpers.\n//\n// Kept separate from `./node.ts` so the buffer-only entry stays free of\n// `node:fs` / `node:stream` imports — important for the `@office-kit/xlsx/streaming`\n// browser-targeted bundle, which can re-export `fromBuffer` / `toBuffer`\n// without dragging Node-only modules into the browser surface. Users who want\n// filesystem I/O reach this module directly (or through `@office-kit/xlsx/node` once\n// that subpath lands).\n\nimport { createReadStream, createWriteStream, readFileSync } from 'node:fs';\nimport { readFile, unlink } from 'node:fs/promises';\nimport { once } from 'node:events';\nimport { Readable, Writable } from 'node:stream';\nimport { OpenXmlIoError } from '../utils/exceptions';\nimport type { BufferedSinkWriter, XlsxSink } from './sink';\nimport type { XlsxSource } from './source';\n\nconst EMPTY_BYTES = new Uint8Array(0);\n\n/**\n * Wrap a filesystem path as an XlsxSource. `toBytes` reads the whole file into\n * memory; `toStream` opens a `fs.createReadStream` and bridges it to a Web\n * {@link ReadableStream} via `Readable.toWeb` so the ZIP reader can iterate\n * without loading the entire xlsx up front.\n */\nexport function fromFile(path: string): XlsxSource {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('fromFile expects a non-empty path string');\n }\n return {\n async toBytes() {\n try {\n return new Uint8Array(await readFile(path));\n } catch (cause) {\n throw new OpenXmlIoError(`fromFile: failed to read \"${path}\"`, { cause });\n }\n },\n toStream() {\n const nodeStream = createReadStream(path);\n return Readable.toWeb(nodeStream) as unknown as ReadableStream<Uint8Array>;\n },\n };\n}\n\n/**\n * Synchronous variant of {@link fromFile}. Convenience for tooling / scripts\n * where the cost of `await fs.readFile` outweighs the ergonomic gain. The\n * returned source's `toBytes` resolves immediately with the bytes already in\n * memory.\n */\nexport function fromFileSync(path: string): XlsxSource {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('fromFileSync expects a non-empty path string');\n }\n let bytes: Uint8Array;\n try {\n bytes = new Uint8Array(readFileSync(path));\n } catch (cause) {\n throw new OpenXmlIoError(`fromFileSync: failed to read \"${path}\"`, { cause });\n }\n return {\n async toBytes() {\n return bytes;\n },\n toStream() {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n },\n };\n}\n\n/**\n * Filesystem sink. Each `write(chunk)` call streams the bytes to disk via\n * `fs.createWriteStream`, honouring backpressure: the actual `writable.write`\n * for each chunk is queued behind any pending `drain`, so the writable's\n * internal buffer never grows past its `highWaterMark` (default 16 KB) no\n * matter how fast the producer hands chunks over.\n *\n * Note on the producer-side memory budget: the sink contract is\n * intentionally synchronous (`write(chunk): void`), so a producer that races\n * ahead without yielding will let chunk references pile up in the queue.\n * That keeps `writable`'s buffer bounded but does not bound the queue\n * itself. Producers that need a hard ceiling should yield between writes\n * (`await new Promise(setImmediate)` is enough) or use a sink with an async\n * write contract.\n *\n * `result()` returns the destination path; `finish()` resolves with an empty\n * `Uint8Array` once the stream has flushed. Callers that need the on-disk\n * bytes should `readFile()` the returned path themselves — re-reading inside\n * `finish()` would defeat the \"streamed to disk, never resident\" guarantee.\n */\nexport function toFile(path: string): XlsxSink & { toBytes(): BufferedSinkWriter; result(): string } {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('toFile expects a non-empty path string');\n }\n let stream: ReturnType<typeof createWriteStream> | undefined;\n let streamCreated = false;\n let finalised: Promise<Uint8Array> | undefined;\n let pendingError: Error | undefined;\n // Backpressure queue: every chunk's actual `writable.write` call is staged\n // behind the previous chunk's completion. When a write returns `false` the\n // queue parks on `drain` before the next chunk goes out, so the writable's\n // internal buffer stays within its highWaterMark.\n let writeQueue: Promise<void> = Promise.resolve();\n\n const ensureStream = (): NonNullable<typeof stream> => {\n if (!stream) {\n stream = createWriteStream(path);\n streamCreated = true;\n stream.on('error', (err) => {\n pendingError = err instanceof Error ? err : new Error(String(err));\n });\n }\n return stream;\n };\n\n // Best-effort: remove a half-written file when finish() fails so callers\n // don't mistake a corrupt artefact for a successful save. Swallows unlink\n // errors because we're already in a failure path and the original cause\n // is what the caller needs to see.\n const cleanupOnFailure = async (): Promise<void> => {\n if (!streamCreated) return;\n try {\n await unlink(path);\n } catch {\n // ignore — file may be gone, path may be on a read-only fs, etc.\n }\n };\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) throw new OpenXmlIoError(`toFile sink: write after finish (\"${path}\")`);\n if (!(chunk instanceof Uint8Array)) {\n throw new OpenXmlIoError(`toFile sink: chunk is not a Uint8Array (\"${path}\")`);\n }\n if (pendingError) throw new OpenXmlIoError(`toFile sink: write error on \"${path}\"`, { cause: pendingError });\n const s = ensureStream();\n writeQueue = writeQueue.then(async () => {\n // Skip remaining work once the stream has errored — the error\n // surfaces from `finish()` so callers see one consistent failure.\n if (pendingError) return;\n const ok = s.write(chunk);\n if (!ok) {\n // Writable's internal buffer is over highWaterMark; wait for it\n // to flush before the next queued chunk runs.\n await once(s, 'drain');\n }\n });\n },\n async finish(): Promise<Uint8Array> {\n if (finalised) return finalised;\n finalised = (async () => {\n const s = ensureStream();\n try {\n await writeQueue;\n await new Promise<void>((resolve, reject) => {\n s.end((err?: Error | null) => (err ? reject(err) : resolve()));\n });\n if (pendingError) {\n throw new OpenXmlIoError(`toFile sink: write error on \"${path}\"`, { cause: pendingError });\n }\n } catch (err) {\n await cleanupOnFailure();\n throw err;\n }\n return EMPTY_BYTES;\n })();\n return finalised;\n },\n abort(): void {\n // Idempotent: subsequent finish() / abort() calls become no-ops.\n if (finalised) return;\n finalised = Promise.resolve(EMPTY_BYTES);\n if (stream) {\n // destroy() releases the fd synchronously without flushing the\n // pending buffer — exactly what we want for an aborted save.\n stream.destroy();\n }\n // Fire-and-forget unlink — abort() is sync (void), and the caller\n // is already on a failure path so any unlink error is noise.\n void cleanupOnFailure();\n },\n };\n },\n result(): string {\n return path;\n },\n };\n}\n\n/**\n * Wrap a Node.js {@link Readable} as an XlsxSource. `toBytes` consumes the\n * entire stream synchronously (collecting chunks); `toStream` bridges to a Web\n * ReadableStream via `Readable.toWeb` so the ZIP reader can pull chunks lazily.\n */\nexport function fromReadable(readable: Readable): XlsxSource {\n if (!(readable instanceof Readable)) {\n throw new OpenXmlIoError('fromReadable expects a Node Readable');\n }\n let bytes: Promise<Uint8Array> | undefined;\n return {\n async toBytes() {\n if (bytes) return bytes;\n bytes = (async () => {\n const chunks: Uint8Array[] = [];\n for await (const c of readable) {\n chunks.push(c instanceof Uint8Array ? c : new Uint8Array(c));\n }\n let total = 0;\n for (const c of chunks) total += c.byteLength;\n const out = new Uint8Array(total);\n let off = 0;\n for (const c of chunks) {\n out.set(c, off);\n off += c.byteLength;\n }\n return out;\n })();\n return bytes;\n },\n toStream() {\n return Readable.toWeb(readable) as unknown as ReadableStream<Uint8Array>;\n },\n };\n}\n\n/**\n * Wrap a Node.js {@link Writable} as an XlsxSink. The actual\n * `writable.write` for each chunk is queued behind any pending `drain`, so\n * the writable's internal buffer never exceeds its `highWaterMark` regardless\n * of how fast the producer is. See {@link toFile} for the same caveat about\n * producer-side memory: the synchronous `write(chunk)` API does not let\n * backpressure flow back to the caller, so a tight non-yielding producer can\n * still let chunk references accumulate in the queue.\n *\n * `result()` returns the writable itself for downstream chaining.\n */\nexport function toWritable(writable: Writable): XlsxSink & { toBytes(): BufferedSinkWriter; result(): Writable } {\n if (!(writable instanceof Writable)) {\n throw new OpenXmlIoError('toWritable expects a Node Writable');\n }\n let finalised: Promise<Uint8Array> | undefined;\n let pendingError: Error | undefined;\n let writeQueue: Promise<void> = Promise.resolve();\n writable.on('error', (err) => {\n pendingError = err instanceof Error ? err : new Error(String(err));\n });\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) throw new OpenXmlIoError('toWritable sink: write after finish');\n if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError('toWritable sink: chunk is not a Uint8Array');\n if (pendingError) throw new OpenXmlIoError('toWritable sink: write error', { cause: pendingError });\n writeQueue = writeQueue.then(async () => {\n if (pendingError) return;\n const ok = writable.write(chunk);\n if (!ok) {\n await once(writable, 'drain');\n }\n });\n },\n async finish(): Promise<Uint8Array> {\n if (finalised) return finalised;\n finalised = (async () => {\n await writeQueue;\n await new Promise<void>((resolve, reject) => {\n writable.end((err?: Error | null) => (err ? reject(err) : resolve()));\n });\n if (pendingError) throw new OpenXmlIoError('toWritable sink: write error', { cause: pendingError });\n return EMPTY_BYTES;\n })();\n return finalised;\n },\n abort(cause?: unknown): void {\n if (finalised) return;\n finalised = Promise.resolve(EMPTY_BYTES);\n // Pass the cause to destroy() so downstream `error` listeners can\n // distinguish a deliberate abort from spontaneous fs/network errors.\n writable.destroy(cause instanceof Error ? cause : undefined);\n },\n };\n },\n result(): Writable {\n return writable;\n },\n };\n}\n","// Node-only counterpart to `workbookToBytes` in `./save`. Returns a Buffer\n// directly so Node consumers don't pay a `Buffer.from(uint8Array)` copy.\n\nimport type { Workbook } from '../workbook/workbook';\nimport { toBuffer } from './node';\nimport { saveWorkbook, type SaveOptions } from './save';\n\nexport async function workbookToBuffer(wb: Workbook, opts?: SaveOptions): Promise<Buffer> {\n const sink = toBuffer();\n await saveWorkbook(wb, sink, opts);\n return sink.result();\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,WAAW,KAAsC;CAC/D,IAAI,EAAE,eAAe,aACnB,MAAM,IAAI,eAAe,2CAA2C;CAGtE,MAAM,QAAoB,eAAe,SAAS,IAAI,WAAW,IAAI,QAAQ,IAAI,YAAY,IAAI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;IACA,MAAM,OAAuB;KAC3B,IAAI,WAAW;KACf,YAAY,QAAQ,QAAQ,WAAW;KAGvC,SAAS,QAAQ,iBAAiB,QAAQ,QAAQ,KAAA,CAAS;IAC7D;GACF;EACF;EACA,SAAmB;GACjB,OAAO;EACT;CACF;AACF;;;AC/RA,eAAsB,iBAAiB,IAAc,MAAqC;CACxF,MAAM,OAAO,SAAS;CACtB,MAAM,aAAa,IAAI,MAAM,IAAI;CACjC,OAAO,KAAK,OAAO;AACrB"}
1
+ {"version":3,"file":"node.mjs","names":[],"sources":["../src/io/node.ts","../src/io/node-fs.ts","../src/io/node-save.ts"],"sourcesContent":["// In-memory Node helpers.\n//\n// `fromBuffer` / `toBuffer` rely only on the global `Buffer` symbol — no\n// `node:*` imports — so they're safe to ship through the `@office-kit/xlsx/streaming`\n// browser-targeted entry too. Filesystem + Readable / Writable helpers live in\n// `./node-fs.ts` (re-exported via `@office-kit/xlsx/node`) where the `node:fs` /\n// `node:stream` imports stay out of the browser-safe surface.\n\nimport { OpenXmlIoError } from '../utils/exceptions.js';\nimport type { BufferedSinkWriter, XlsxSink } from './sink.js';\nimport type { XlsxSource } from './source.js';\n\n/**\n * Wrap a Buffer or Uint8Array as an XlsxSource. The underlying bytes are\n * referenced — no copy — so callers must not mutate them while the source is in\n * use.\n */\nexport function fromBuffer(buf: Buffer | Uint8Array): XlsxSource {\n if (!(buf instanceof Uint8Array)) {\n throw new OpenXmlIoError('fromBuffer expects a Buffer or Uint8Array');\n }\n // Buffer is a subclass of Uint8Array, so a single normalisation suffices.\n const bytes: Uint8Array = buf instanceof Buffer ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf;\n return {\n async toBytes() {\n return bytes;\n },\n toStream() {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n },\n };\n}\n\n/**\n * In-memory Buffer sink. The buffered path concatenates appended chunks into a\n * single allocation when {@link BufferedSinkWriter.finish} resolves; the\n * convenience `result()` returns it as a Node Buffer.\n */\nexport function toBuffer(): XlsxSink & { toBytes(): BufferedSinkWriter; result(): Buffer } {\n const chunks: Uint8Array[] = [];\n let finalised: Uint8Array | undefined;\n\n const finalise = (): Uint8Array => {\n if (finalised !== undefined) return finalised;\n let total = 0;\n for (const c of chunks) total += c.byteLength;\n const out = new Uint8Array(total);\n let off = 0;\n for (const c of chunks) {\n out.set(c, off);\n off += c.byteLength;\n }\n finalised = out;\n chunks.length = 0;\n return out;\n };\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) {\n throw new OpenXmlIoError('toBuffer sink: write after finish');\n }\n if (!(chunk instanceof Uint8Array)) {\n throw new OpenXmlIoError('toBuffer sink: chunk is not a Uint8Array');\n }\n chunks.push(chunk);\n },\n async finish(): Promise<Uint8Array> {\n return finalise();\n },\n abort(): void {\n if (finalised !== undefined) return;\n finalised = new Uint8Array(0);\n chunks.length = 0;\n },\n };\n },\n result(): Buffer {\n const bytes = finalise();\n return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n },\n };\n}\n","// Node filesystem + Readable / Writable I/O helpers.\n//\n// Kept separate from `./node.ts` so the buffer-only entry stays free of\n// `node:fs` / `node:stream` imports — important for the `@office-kit/xlsx/streaming`\n// browser-targeted bundle, which can re-export `fromBuffer` / `toBuffer`\n// without dragging Node-only modules into the browser surface. Users who want\n// filesystem I/O reach this module directly (or through `@office-kit/xlsx/node` once\n// that subpath lands).\n\nimport { createReadStream, createWriteStream, readFileSync } from 'node:fs';\nimport { readFile, unlink } from 'node:fs/promises';\nimport { once } from 'node:events';\nimport { Readable, Writable } from 'node:stream';\nimport { OpenXmlIoError } from '../utils/exceptions.js';\nimport type { BufferedSinkWriter, XlsxSink } from './sink.js';\nimport type { XlsxSource } from './source.js';\n\nconst EMPTY_BYTES = new Uint8Array(0);\n\n/**\n * Wrap a filesystem path as an XlsxSource. `toBytes` reads the whole file into\n * memory; `toStream` opens a `fs.createReadStream` and bridges it to a Web\n * {@link ReadableStream} via `Readable.toWeb` so the ZIP reader can iterate\n * without loading the entire xlsx up front.\n */\nexport function fromFile(path: string): XlsxSource {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('fromFile expects a non-empty path string');\n }\n return {\n async toBytes() {\n try {\n return new Uint8Array(await readFile(path));\n } catch (cause) {\n throw new OpenXmlIoError(`fromFile: failed to read \"${path}\"`, { cause });\n }\n },\n toStream() {\n const nodeStream = createReadStream(path);\n return Readable.toWeb(nodeStream) as unknown as ReadableStream<Uint8Array>;\n },\n };\n}\n\n/**\n * Synchronous variant of {@link fromFile}. Convenience for tooling / scripts\n * where the cost of `await fs.readFile` outweighs the ergonomic gain. The\n * returned source's `toBytes` resolves immediately with the bytes already in\n * memory.\n */\nexport function fromFileSync(path: string): XlsxSource {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('fromFileSync expects a non-empty path string');\n }\n let bytes: Uint8Array;\n try {\n bytes = new Uint8Array(readFileSync(path));\n } catch (cause) {\n throw new OpenXmlIoError(`fromFileSync: failed to read \"${path}\"`, { cause });\n }\n return {\n async toBytes() {\n return bytes;\n },\n toStream() {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n },\n };\n}\n\n/**\n * Filesystem sink. Each `write(chunk)` call streams the bytes to disk via\n * `fs.createWriteStream`, honouring backpressure: the actual `writable.write`\n * for each chunk is queued behind any pending `drain`, so the writable's\n * internal buffer never grows past its `highWaterMark` (default 16 KB) no\n * matter how fast the producer hands chunks over.\n *\n * Note on the producer-side memory budget: the sink contract is\n * intentionally synchronous (`write(chunk): void`), so a producer that races\n * ahead without yielding will let chunk references pile up in the queue.\n * That keeps `writable`'s buffer bounded but does not bound the queue\n * itself. Producers that need a hard ceiling should yield between writes\n * (`await new Promise(setImmediate)` is enough) or use a sink with an async\n * write contract.\n *\n * `result()` returns the destination path; `finish()` resolves with an empty\n * `Uint8Array` once the stream has flushed. Callers that need the on-disk\n * bytes should `readFile()` the returned path themselves — re-reading inside\n * `finish()` would defeat the \"streamed to disk, never resident\" guarantee.\n */\nexport function toFile(path: string): XlsxSink & { toBytes(): BufferedSinkWriter; result(): string } {\n if (typeof path !== 'string' || path.length === 0) {\n throw new OpenXmlIoError('toFile expects a non-empty path string');\n }\n let stream: ReturnType<typeof createWriteStream> | undefined;\n let streamCreated = false;\n let finalised: Promise<Uint8Array> | undefined;\n let pendingError: Error | undefined;\n // Backpressure queue: every chunk's actual `writable.write` call is staged\n // behind the previous chunk's completion. When a write returns `false` the\n // queue parks on `drain` before the next chunk goes out, so the writable's\n // internal buffer stays within its highWaterMark.\n let writeQueue: Promise<void> = Promise.resolve();\n\n const ensureStream = (): NonNullable<typeof stream> => {\n if (!stream) {\n stream = createWriteStream(path);\n streamCreated = true;\n stream.on('error', (err) => {\n pendingError = err instanceof Error ? err : new Error(String(err));\n });\n }\n return stream;\n };\n\n // Best-effort: remove a half-written file when finish() fails so callers\n // don't mistake a corrupt artefact for a successful save. Swallows unlink\n // errors because we're already in a failure path and the original cause\n // is what the caller needs to see.\n const cleanupOnFailure = async (): Promise<void> => {\n if (!streamCreated) return;\n try {\n await unlink(path);\n } catch {\n // ignore — file may be gone, path may be on a read-only fs, etc.\n }\n };\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) throw new OpenXmlIoError(`toFile sink: write after finish (\"${path}\")`);\n if (!(chunk instanceof Uint8Array)) {\n throw new OpenXmlIoError(`toFile sink: chunk is not a Uint8Array (\"${path}\")`);\n }\n if (pendingError) throw new OpenXmlIoError(`toFile sink: write error on \"${path}\"`, { cause: pendingError });\n const s = ensureStream();\n writeQueue = writeQueue.then(async () => {\n // Skip remaining work once the stream has errored — the error\n // surfaces from `finish()` so callers see one consistent failure.\n if (pendingError) return;\n const ok = s.write(chunk);\n if (!ok) {\n // Writable's internal buffer is over highWaterMark; wait for it\n // to flush before the next queued chunk runs.\n await once(s, 'drain');\n }\n });\n },\n async finish(): Promise<Uint8Array> {\n if (finalised) return finalised;\n finalised = (async () => {\n const s = ensureStream();\n try {\n await writeQueue;\n await new Promise<void>((resolve, reject) => {\n s.end((err?: Error | null) => (err ? reject(err) : resolve()));\n });\n if (pendingError) {\n throw new OpenXmlIoError(`toFile sink: write error on \"${path}\"`, { cause: pendingError });\n }\n } catch (err) {\n await cleanupOnFailure();\n throw err;\n }\n return EMPTY_BYTES;\n })();\n return finalised;\n },\n abort(): void {\n // Idempotent: subsequent finish() / abort() calls become no-ops.\n if (finalised) return;\n finalised = Promise.resolve(EMPTY_BYTES);\n if (stream) {\n // destroy() releases the fd synchronously without flushing the\n // pending buffer — exactly what we want for an aborted save.\n stream.destroy();\n }\n // Fire-and-forget unlink — abort() is sync (void), and the caller\n // is already on a failure path so any unlink error is noise.\n void cleanupOnFailure();\n },\n };\n },\n result(): string {\n return path;\n },\n };\n}\n\n/**\n * Wrap a Node.js {@link Readable} as an XlsxSource. `toBytes` consumes the\n * entire stream synchronously (collecting chunks); `toStream` bridges to a Web\n * ReadableStream via `Readable.toWeb` so the ZIP reader can pull chunks lazily.\n */\nexport function fromReadable(readable: Readable): XlsxSource {\n if (!(readable instanceof Readable)) {\n throw new OpenXmlIoError('fromReadable expects a Node Readable');\n }\n let bytes: Promise<Uint8Array> | undefined;\n return {\n async toBytes() {\n if (bytes) return bytes;\n bytes = (async () => {\n const chunks: Uint8Array[] = [];\n for await (const c of readable) {\n chunks.push(c instanceof Uint8Array ? c : new Uint8Array(c));\n }\n let total = 0;\n for (const c of chunks) total += c.byteLength;\n const out = new Uint8Array(total);\n let off = 0;\n for (const c of chunks) {\n out.set(c, off);\n off += c.byteLength;\n }\n return out;\n })();\n return bytes;\n },\n toStream() {\n return Readable.toWeb(readable) as unknown as ReadableStream<Uint8Array>;\n },\n };\n}\n\n/**\n * Wrap a Node.js {@link Writable} as an XlsxSink. The actual\n * `writable.write` for each chunk is queued behind any pending `drain`, so\n * the writable's internal buffer never exceeds its `highWaterMark` regardless\n * of how fast the producer is. See {@link toFile} for the same caveat about\n * producer-side memory: the synchronous `write(chunk)` API does not let\n * backpressure flow back to the caller, so a tight non-yielding producer can\n * still let chunk references accumulate in the queue.\n *\n * `result()` returns the writable itself for downstream chaining.\n */\nexport function toWritable(writable: Writable): XlsxSink & { toBytes(): BufferedSinkWriter; result(): Writable } {\n if (!(writable instanceof Writable)) {\n throw new OpenXmlIoError('toWritable expects a Node Writable');\n }\n let finalised: Promise<Uint8Array> | undefined;\n let pendingError: Error | undefined;\n let writeQueue: Promise<void> = Promise.resolve();\n writable.on('error', (err) => {\n pendingError = err instanceof Error ? err : new Error(String(err));\n });\n\n return {\n toBytes(): BufferedSinkWriter {\n return {\n write(chunk: Uint8Array): void {\n if (finalised !== undefined) throw new OpenXmlIoError('toWritable sink: write after finish');\n if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError('toWritable sink: chunk is not a Uint8Array');\n if (pendingError) throw new OpenXmlIoError('toWritable sink: write error', { cause: pendingError });\n writeQueue = writeQueue.then(async () => {\n if (pendingError) return;\n const ok = writable.write(chunk);\n if (!ok) {\n await once(writable, 'drain');\n }\n });\n },\n async finish(): Promise<Uint8Array> {\n if (finalised) return finalised;\n finalised = (async () => {\n await writeQueue;\n await new Promise<void>((resolve, reject) => {\n writable.end((err?: Error | null) => (err ? reject(err) : resolve()));\n });\n if (pendingError) throw new OpenXmlIoError('toWritable sink: write error', { cause: pendingError });\n return EMPTY_BYTES;\n })();\n return finalised;\n },\n abort(cause?: unknown): void {\n if (finalised) return;\n finalised = Promise.resolve(EMPTY_BYTES);\n // Pass the cause to destroy() so downstream `error` listeners can\n // distinguish a deliberate abort from spontaneous fs/network errors.\n writable.destroy(cause instanceof Error ? cause : undefined);\n },\n };\n },\n result(): Writable {\n return writable;\n },\n };\n}\n","// Node-only counterpart to `workbookToBytes` in `./save`. Returns a Buffer\n// directly so Node consumers don't pay a `Buffer.from(uint8Array)` copy.\n\nimport type { Workbook } from '../workbook/workbook.js';\nimport { toBuffer } from './node.js';\nimport { saveWorkbook, type SaveOptions } from './save.js';\n\nexport async function workbookToBuffer(wb: Workbook, opts?: SaveOptions): Promise<Buffer> {\n const sink = toBuffer();\n await saveWorkbook(wb, sink, opts);\n return sink.result();\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,WAAW,KAAsC;CAC/D,IAAI,EAAE,eAAe,aACnB,MAAM,IAAI,eAAe,2CAA2C;CAGtE,MAAM,QAAoB,eAAe,SAAS,IAAI,WAAW,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU,IAAI;CAC/G,OAAO;EACL,MAAM,UAAU;GACd,OAAO;EACT;EACA,WAAW;GACT,OAAO,IAAI,eAA2B,EACpC,MAAM,YAAY;IAChB,WAAW,QAAQ,KAAK;IACxB,WAAW,MAAM;GACnB,EACF,CAAC;EACH;CACF;AACF;;;;;;AAOA,SAAgB,WAA2E;CACzF,MAAM,SAAuB,CAAC;CAC9B,IAAI;CAEJ,MAAM,iBAA6B;EACjC,IAAI,cAAc,KAAA,GAAW,OAAO;EACpC,IAAI,QAAQ;EACZ,KAAK,MAAM,KAAK,QAAQ,SAAS,EAAE;EACnC,MAAM,MAAM,IAAI,WAAW,KAAK;EAChC,IAAI,MAAM;EACV,KAAK,MAAM,KAAK,QAAQ;GACtB,IAAI,IAAI,GAAG,GAAG;GACd,OAAO,EAAE;EACX;EACA,YAAY;EACZ,OAAO,SAAS;EAChB,OAAO;CACT;CAEA,OAAO;EACL,UAA8B;GAC5B,OAAO;IACL,MAAM,OAAyB;KAC7B,IAAI,cAAc,KAAA,GAChB,MAAM,IAAI,eAAe,mCAAmC;KAE9D,IAAI,EAAE,iBAAiB,aACrB,MAAM,IAAI,eAAe,0CAA0C;KAErE,OAAO,KAAK,KAAK;IACnB;IACA,MAAM,SAA8B;KAClC,OAAO,SAAS;IAClB;IACA,QAAc;KACZ,IAAI,cAAc,KAAA,GAAW;KAC7B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AI,cAAc;MAElB,IAAI,CADO,SAAS,MAAM,KACpB,GACJ,MAAM,KAAK,UAAU,OAAO;KAEhC,CAAC;IACH;IACA,MAAM,SAA8B;KAClC,IAAI,WAAW,OAAO;KACtB,aAAa,YAAY;MACvB,MAAM;MACN,MAAM,IAAI,SAAe,SAAS,WAAW;OAC3C,SAAS,KAAK,QAAwB,MAAM,OAAO,GAAG,IAAI,QAAQ,CAAE;MACtE,CAAC;MACD,IAAI,cAAc,MAAM,IAAI,eAAe,gCAAgC,EAAE,OAAO,aAAa,CAAC;MAClG,OAAO;KACT,EAAA,CAAG;KACH,OAAO;IACT;IACA,MAAM,OAAuB;KAC3B,IAAI,WAAW;KACf,YAAY,QAAQ,QAAQ,WAAW;KAGvC,SAAS,QAAQ,iBAAiB,QAAQ,QAAQ,KAAA,CAAS;IAC7D;GACF;EACF;EACA,SAAmB;GACjB,OAAO;EACT;CACF;AACF;;;AC/RA,eAAsB,iBAAiB,IAAc,MAAqC;CACxF,MAAM,OAAO,SAAS;CACtB,MAAM,aAAa,IAAI,MAAM,IAAI;CACjC,OAAO,KAAK,OAAO;AACrB"}
@@ -28,7 +28,7 @@ export interface CoreProperties {
28
28
  export declare function makeCoreProperties(): CoreProperties;
29
29
  export declare function corePropsToBytes(p: CoreProperties): Uint8Array;
30
30
  export declare function corePropsFromBytes(bytes: Uint8Array | string): CoreProperties;
31
- import type { Workbook } from '../workbook/workbook';
31
+ import type { Workbook } from '../workbook/workbook.js';
32
32
  /** Set the document author (Excel "File → Properties → Author"). */
33
33
  export declare const setWorkbookCreator: (wb: Workbook, creator: string) => void;
34
34
  /** Set the document title. */
@@ -1,4 +1,4 @@
1
- import { type XmlNode } from '../xml/tree';
1
+ import { type XmlNode } from '../xml/tree.js';
2
2
  export interface CustomProperty {
3
3
  /** User-visible property name (must be unique within the workbook). */
4
4
  name: string;
@@ -32,7 +32,7 @@ export declare function appendCustomProperty(props: CustomProperties, name: stri
32
32
  export declare function findCustomPropertyByName(props: CustomProperties, name: string): CustomProperty | undefined;
33
33
  export declare function customPropsToBytes(p: CustomProperties): Uint8Array;
34
34
  export declare function customPropsFromBytes(bytes: Uint8Array | string): CustomProperties;
35
- import type { Workbook } from '../workbook/workbook';
35
+ import type { Workbook } from '../workbook/workbook.js';
36
36
  /** Set (or replace) a custom string property. */
37
37
  export declare const setCustomStringProperty: (wb: Workbook, name: string, value: string) => CustomProperty;
38
38
  /**
@@ -1,4 +1,4 @@
1
- import type { XmlNode } from '../xml/tree';
1
+ import type { XmlNode } from '../xml/tree.js';
2
2
  export interface ExtendedProperties {
3
3
  application?: string;
4
4
  appVersion?: string;
@@ -32,7 +32,7 @@ export interface ExtendedProperties {
32
32
  export declare function makeExtendedProperties(): ExtendedProperties;
33
33
  export declare function extendedPropsToBytes(p: ExtendedProperties): Uint8Array;
34
34
  export declare function extendedPropsFromBytes(bytes: Uint8Array | string): ExtendedProperties;
35
- import type { Workbook } from '../workbook/workbook';
35
+ import type { Workbook } from '../workbook/workbook.js';
36
36
  /** Set the company name on docProps/app.xml. */
37
37
  export declare const setWorkbookCompany: (wb: Workbook, company: string) => void;
38
38
  /** Set the manager / supervisor name on docProps/app.xml. */
@@ -1,10 +1,10 @@
1
- export type { CoreProperties } from './core';
2
- export { corePropsFromBytes, corePropsToBytes, makeCoreProperties, setWorkbookCategory, setWorkbookCreator, setWorkbookDescription, setWorkbookKeywords, setWorkbookLastModifiedBy, setWorkbookSubject, setWorkbookTitle, } from './core';
3
- export type { CustomProperties, CustomProperty } from './custom';
4
- export { appendCustomProperty, customPropsFromBytes, customPropsToBytes, findCustomPropertyByName, getCustomPropertyValue, listCustomProperties, makeAsciiStringValue, makeBoolValue, makeCustomProperties, makeDateValue, makeDoubleValue, makeFiletimeValue, makeIntValue, makeStringValue, readBoolValue, readDoubleValue, readFiletimeValue, readIntValue, readStringValue, removeCustomProperty, setCustomBoolProperty, setCustomDateProperty, setCustomNumberProperty, setCustomStringProperty, } from './custom';
5
- export type { ExtendedProperties } from './extended';
6
- export { extendedPropsFromBytes, extendedPropsToBytes, makeExtendedProperties, setWorkbookAppVersion, setWorkbookApplication, setWorkbookCompany, setWorkbookHyperlinkBase, setWorkbookManager, } from './extended';
7
- export type { DefaultEntry, Manifest, OverrideEntry } from './manifest';
8
- export { addDefault, addOverride, findOverride, findOverrideByContentType, makeManifest, manifestFromBytes, manifestToBytes, } from './manifest';
9
- export type { Relationship, Relationships } from './relationships';
10
- export { appendRel, findAllByType, findById, findByType, makeRelationships, relsFromBytes, relsToBytes, } from './relationships';
1
+ export type { CoreProperties } from './core.js';
2
+ export { corePropsFromBytes, corePropsToBytes, makeCoreProperties, setWorkbookCategory, setWorkbookCreator, setWorkbookDescription, setWorkbookKeywords, setWorkbookLastModifiedBy, setWorkbookSubject, setWorkbookTitle, } from './core.js';
3
+ export type { CustomProperties, CustomProperty } from './custom.js';
4
+ export { appendCustomProperty, customPropsFromBytes, customPropsToBytes, findCustomPropertyByName, getCustomPropertyValue, listCustomProperties, makeAsciiStringValue, makeBoolValue, makeCustomProperties, makeDateValue, makeDoubleValue, makeFiletimeValue, makeIntValue, makeStringValue, readBoolValue, readDoubleValue, readFiletimeValue, readIntValue, readStringValue, removeCustomProperty, setCustomBoolProperty, setCustomDateProperty, setCustomNumberProperty, setCustomStringProperty, } from './custom.js';
5
+ export type { ExtendedProperties } from './extended.js';
6
+ export { extendedPropsFromBytes, extendedPropsToBytes, makeExtendedProperties, setWorkbookAppVersion, setWorkbookApplication, setWorkbookCompany, setWorkbookHyperlinkBase, setWorkbookManager, } from './extended.js';
7
+ export type { DefaultEntry, Manifest, OverrideEntry } from './manifest.js';
8
+ export { addDefault, addOverride, findOverride, findOverrideByContentType, makeManifest, manifestFromBytes, manifestToBytes, } from './manifest.js';
9
+ export type { Relationship, Relationships } from './relationships.js';
10
+ export { appendRel, findAllByType, findById, findByType, makeRelationships, relsFromBytes, relsToBytes, } from './relationships.js';
@@ -1,2 +1,2 @@
1
- import { $ as findByType, A as readBoolValue, B as corePropsFromBytes, C as makeBoolValue, D as makeFiletimeValue, E as makeDoubleValue, F as removeCustomProperty, G as setWorkbookDescription, H as makeCoreProperties, I as setCustomBoolProperty, J as setWorkbookSubject, K as setWorkbookKeywords, L as setCustomDateProperty, M as readFiletimeValue, N as readIntValue, O as makeIntValue, P as readStringValue, Q as findById, R as setCustomNumberProperty, S as makeAsciiStringValue, T as makeDateValue, U as setWorkbookCategory, V as corePropsToBytes, W as setWorkbookCreator, X as appendRel, Y as setWorkbookTitle, Z as findAllByType, _ as customPropsFromBytes, a as makeManifest, b as getCustomPropertyValue, c as extendedPropsFromBytes, d as setWorkbookAppVersion, f as setWorkbookApplication, g as appendCustomProperty, h as setWorkbookManager, i as findOverrideByContentType, j as readDoubleValue, k as makeStringValue, l as extendedPropsToBytes, m as setWorkbookHyperlinkBase, n as addOverride, nt as relsFromBytes, o as manifestFromBytes, p as setWorkbookCompany, q as setWorkbookLastModifiedBy, r as findOverride, rt as relsToBytes, s as manifestToBytes, t as addDefault, tt as makeRelationships, u as makeExtendedProperties, v as customPropsToBytes, w as makeCustomProperties, x as listCustomProperties, y as findCustomPropertyByName, z as setCustomStringProperty } from "./manifest-Cm9K7D62.mjs";
1
+ import { $ as findByType, A as readBoolValue, B as corePropsFromBytes, C as makeBoolValue, D as makeFiletimeValue, E as makeDoubleValue, F as removeCustomProperty, G as setWorkbookDescription, H as makeCoreProperties, I as setCustomBoolProperty, J as setWorkbookSubject, K as setWorkbookKeywords, L as setCustomDateProperty, M as readFiletimeValue, N as readIntValue, O as makeIntValue, P as readStringValue, Q as findById, R as setCustomNumberProperty, S as makeAsciiStringValue, T as makeDateValue, U as setWorkbookCategory, V as corePropsToBytes, W as setWorkbookCreator, X as appendRel, Y as setWorkbookTitle, Z as findAllByType, _ as customPropsFromBytes, a as makeManifest, b as getCustomPropertyValue, c as extendedPropsFromBytes, d as setWorkbookAppVersion, f as setWorkbookApplication, g as appendCustomProperty, h as setWorkbookManager, i as findOverrideByContentType, j as readDoubleValue, k as makeStringValue, l as extendedPropsToBytes, m as setWorkbookHyperlinkBase, n as addOverride, nt as relsFromBytes, o as manifestFromBytes, p as setWorkbookCompany, q as setWorkbookLastModifiedBy, r as findOverride, rt as relsToBytes, s as manifestToBytes, t as addDefault, tt as makeRelationships, u as makeExtendedProperties, v as customPropsToBytes, w as makeCustomProperties, x as listCustomProperties, y as findCustomPropertyByName, z as setCustomStringProperty } from "./manifest-pLmx7KYh.mjs";
2
2
  export { addDefault, addOverride, appendCustomProperty, appendRel, corePropsFromBytes, corePropsToBytes, customPropsFromBytes, customPropsToBytes, extendedPropsFromBytes, extendedPropsToBytes, findAllByType, findById, findByType, findCustomPropertyByName, findOverride, findOverrideByContentType, getCustomPropertyValue, listCustomProperties, makeAsciiStringValue, makeBoolValue, makeCoreProperties, makeCustomProperties, makeDateValue, makeDoubleValue, makeExtendedProperties, makeFiletimeValue, makeIntValue, makeManifest, makeRelationships, makeStringValue, manifestFromBytes, manifestToBytes, readBoolValue, readDoubleValue, readFiletimeValue, readIntValue, readStringValue, relsFromBytes, relsToBytes, removeCustomProperty, setCustomBoolProperty, setCustomDateProperty, setCustomNumberProperty, setCustomStringProperty, setWorkbookAppVersion, setWorkbookApplication, setWorkbookCategory, setWorkbookCompany, setWorkbookCreator, setWorkbookDescription, setWorkbookHyperlinkBase, setWorkbookKeywords, setWorkbookLastModifiedBy, setWorkbookManager, setWorkbookSubject, setWorkbookTitle };