@office-kit/xlsx 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +319 -0
  3. package/THIRD_PARTY_NOTICES.md +56 -0
  4. package/dist/cell/cell.d.ts +234 -0
  5. package/dist/cell/index.d.ts +4 -0
  6. package/dist/cell/rich-text.d.ts +37 -0
  7. package/dist/cell-D9CaNKnU.mjs +320 -0
  8. package/dist/cell-D9CaNKnU.mjs.map +1 -0
  9. package/dist/cell-style-BEDjMX1y.mjs +1579 -0
  10. package/dist/cell-style-BEDjMX1y.mjs.map +1 -0
  11. package/dist/cell.mjs +2 -0
  12. package/dist/chart/chart-xml.d.ts +16 -0
  13. package/dist/chart/chart.d.ts +735 -0
  14. package/dist/chart/cx/chartex-xml.d.ts +6 -0
  15. package/dist/chart/cx/chartex.d.ts +279 -0
  16. package/dist/chart/index.d.ts +6 -0
  17. package/dist/chart/user-shapes-xml.d.ts +4 -0
  18. package/dist/chart/user-shapes.d.ts +61 -0
  19. package/dist/chart.mjs +232 -0
  20. package/dist/chart.mjs.map +1 -0
  21. package/dist/chartsheet/chartsheet-xml.d.ts +17 -0
  22. package/dist/chartsheet/chartsheet.d.ts +121 -0
  23. package/dist/chartsheet/index.d.ts +2 -0
  24. package/dist/chartsheet-C3-tqkPy.mjs +23 -0
  25. package/dist/chartsheet-C3-tqkPy.mjs.map +1 -0
  26. package/dist/chartsheet.mjs +2 -0
  27. package/dist/colors-ovWAwnZI.mjs +67 -0
  28. package/dist/colors-ovWAwnZI.mjs.map +1 -0
  29. package/dist/compat/numbers.d.ts +14 -0
  30. package/dist/coordinate-96Ecci4d.mjs +276 -0
  31. package/dist/coordinate-96Ecci4d.mjs.map +1 -0
  32. package/dist/datetime-B2ySVlXt.mjs +71 -0
  33. package/dist/datetime-B2ySVlXt.mjs.map +1 -0
  34. package/dist/defined-names-CviWmtQg.mjs +89 -0
  35. package/dist/defined-names-CviWmtQg.mjs.map +1 -0
  36. package/dist/differential-D4dg-qtZ.mjs +37 -0
  37. package/dist/differential-D4dg-qtZ.mjs.map +1 -0
  38. package/dist/drawing/anchor.d.ts +63 -0
  39. package/dist/drawing/dml/colors.d.ts +109 -0
  40. package/dist/drawing/dml/dml-xml.d.ts +35 -0
  41. package/dist/drawing/dml/effect.d.ts +92 -0
  42. package/dist/drawing/dml/fill.d.ts +115 -0
  43. package/dist/drawing/dml/geometry.d.ts +113 -0
  44. package/dist/drawing/dml/line.d.ts +41 -0
  45. package/dist/drawing/dml/shape-properties.d.ts +33 -0
  46. package/dist/drawing/dml/text.d.ts +218 -0
  47. package/dist/drawing/drawing-xml.d.ts +5 -0
  48. package/dist/drawing/drawing.d.ts +117 -0
  49. package/dist/drawing/image.d.ts +40 -0
  50. package/dist/drawing/index.d.ts +14 -0
  51. package/dist/drawing-BxzLuryn.mjs +415 -0
  52. package/dist/drawing-BxzLuryn.mjs.map +1 -0
  53. package/dist/drawing.mjs +119 -0
  54. package/dist/drawing.mjs.map +1 -0
  55. package/dist/escape-DFTE7ZJc.mjs +51 -0
  56. package/dist/escape-DFTE7ZJc.mjs.map +1 -0
  57. package/dist/exceptions-D-CFwxgm.mjs +37 -0
  58. package/dist/exceptions-D-CFwxgm.mjs.map +1 -0
  59. package/dist/formula/tokenizer.d.ts +61 -0
  60. package/dist/formula/translate.d.ts +67 -0
  61. package/dist/inference-B3ES3KEJ.mjs +42 -0
  62. package/dist/inference-B3ES3KEJ.mjs.map +1 -0
  63. package/dist/io/browser.d.ts +41 -0
  64. package/dist/io/index.d.ts +7 -0
  65. package/dist/io/load.d.ts +46 -0
  66. package/dist/io/node-fs.d.ts +62 -0
  67. package/dist/io/node-save.d.ts +3 -0
  68. package/dist/io/node.d.ts +17 -0
  69. package/dist/io/save.d.ts +14 -0
  70. package/dist/io/sink.d.ts +54 -0
  71. package/dist/io/source.d.ts +14 -0
  72. package/dist/io.mjs +212 -0
  73. package/dist/io.mjs.map +1 -0
  74. package/dist/load-D5cbhoGx.mjs +1069 -0
  75. package/dist/load-D5cbhoGx.mjs.map +1 -0
  76. package/dist/manifest-Dps1-OpP.mjs +801 -0
  77. package/dist/manifest-Dps1-OpP.mjs.map +1 -0
  78. package/dist/node.d.ts +3 -0
  79. package/dist/node.mjs +308 -0
  80. package/dist/node.mjs.map +1 -0
  81. package/dist/packaging/core.d.ts +45 -0
  82. package/dist/packaging/custom.d.ts +62 -0
  83. package/dist/packaging/extended.d.ts +45 -0
  84. package/dist/packaging/index.d.ts +10 -0
  85. package/dist/packaging/manifest.d.ts +24 -0
  86. package/dist/packaging/relationships.d.ts +30 -0
  87. package/dist/packaging.mjs +2 -0
  88. package/dist/parser-DuLejQy1.mjs +156 -0
  89. package/dist/parser-DuLejQy1.mjs.map +1 -0
  90. package/dist/reader-D1fNW9k1.mjs +534 -0
  91. package/dist/reader-D1fNW9k1.mjs.map +1 -0
  92. package/dist/save-RohQtgEZ.mjs +745 -0
  93. package/dist/save-RohQtgEZ.mjs.map +1 -0
  94. package/dist/schema/core.d.ts +133 -0
  95. package/dist/schema/index.d.ts +3 -0
  96. package/dist/schema/serialize.d.ts +6 -0
  97. package/dist/schema.mjs +2 -0
  98. package/dist/serialize-55EnT30e.mjs +254 -0
  99. package/dist/serialize-55EnT30e.mjs.map +1 -0
  100. package/dist/serializer-BwbgHYJV.mjs +116 -0
  101. package/dist/serializer-BwbgHYJV.mjs.map +1 -0
  102. package/dist/streaming/index.d.ts +2 -0
  103. package/dist/streaming/read-only.d.ts +38 -0
  104. package/dist/streaming/write-only.d.ts +47 -0
  105. package/dist/streaming.mjs +612 -0
  106. package/dist/streaming.mjs.map +1 -0
  107. package/dist/styles/alignment.d.ts +33 -0
  108. package/dist/styles/alignment.schema.d.ts +3 -0
  109. package/dist/styles/borders.d.ts +40 -0
  110. package/dist/styles/borders.schema.d.ts +4 -0
  111. package/dist/styles/cell-style.d.ts +270 -0
  112. package/dist/styles/colors.d.ts +128 -0
  113. package/dist/styles/colors.schema.d.ts +3 -0
  114. package/dist/styles/differential.d.ts +41 -0
  115. package/dist/styles/fills.d.ts +54 -0
  116. package/dist/styles/fills.schema.d.ts +6 -0
  117. package/dist/styles/fonts.d.ts +44 -0
  118. package/dist/styles/fonts.schema.d.ts +3 -0
  119. package/dist/styles/index.d.ts +21 -0
  120. package/dist/styles/named-styles.d.ts +52 -0
  121. package/dist/styles/numbers.d.ts +39 -0
  122. package/dist/styles/numbers.schema.d.ts +3 -0
  123. package/dist/styles/protection.d.ts +9 -0
  124. package/dist/styles/protection.schema.d.ts +3 -0
  125. package/dist/styles/stylesheet-reader.d.ts +7 -0
  126. package/dist/styles/stylesheet-writer.d.ts +3 -0
  127. package/dist/styles/stylesheet.d.ts +95 -0
  128. package/dist/styles.mjs +4 -0
  129. package/dist/stylesheet-writer-C2eRmn22.mjs +8624 -0
  130. package/dist/stylesheet-writer-C2eRmn22.mjs.map +1 -0
  131. package/dist/table-DkX6UniA.mjs +113 -0
  132. package/dist/table-DkX6UniA.mjs.map +1 -0
  133. package/dist/tree-Bbs1C8Rc.mjs +192 -0
  134. package/dist/tree-Bbs1C8Rc.mjs.map +1 -0
  135. package/dist/units-rOMQqXh2.mjs +41 -0
  136. package/dist/units-rOMQqXh2.mjs.map +1 -0
  137. package/dist/user-shapes-DfmCGKB0.mjs +252 -0
  138. package/dist/user-shapes-DfmCGKB0.mjs.map +1 -0
  139. package/dist/utf8-D91g1XTG.mjs +143 -0
  140. package/dist/utf8-D91g1XTG.mjs.map +1 -0
  141. package/dist/utils/coordinate.d.ts +103 -0
  142. package/dist/utils/css.d.ts +18 -0
  143. package/dist/utils/datetime.d.ts +38 -0
  144. package/dist/utils/escape.d.ts +34 -0
  145. package/dist/utils/exceptions.d.ts +34 -0
  146. package/dist/utils/index.d.ts +11 -0
  147. package/dist/utils/inference.d.ts +24 -0
  148. package/dist/utils/stable-stringify.d.ts +7 -0
  149. package/dist/utils/units.d.ts +14 -0
  150. package/dist/utils/utf8.d.ts +1 -0
  151. package/dist/utils.mjs +39 -0
  152. package/dist/utils.mjs.map +1 -0
  153. package/dist/workbook/calc-properties.d.ts +47 -0
  154. package/dist/workbook/defined-names.d.ts +121 -0
  155. package/dist/workbook/file-recovery.d.ts +11 -0
  156. package/dist/workbook/file-sharing.d.ts +14 -0
  157. package/dist/workbook/file-version.d.ts +13 -0
  158. package/dist/workbook/function-groups.d.ts +10 -0
  159. package/dist/workbook/index.d.ts +24 -0
  160. package/dist/workbook/protection.d.ts +35 -0
  161. package/dist/workbook/shared-strings.d.ts +57 -0
  162. package/dist/workbook/smart-tags.d.ts +13 -0
  163. package/dist/workbook/views.d.ts +89 -0
  164. package/dist/workbook/workbook-properties.d.ts +57 -0
  165. package/dist/workbook/workbook.d.ts +643 -0
  166. package/dist/workbook-HGYNRBlV.mjs +636 -0
  167. package/dist/workbook-HGYNRBlV.mjs.map +1 -0
  168. package/dist/workbook.mjs +58 -0
  169. package/dist/workbook.mjs.map +1 -0
  170. package/dist/worksheet/auto-filter.d.ts +34 -0
  171. package/dist/worksheet/cell-range.d.ts +121 -0
  172. package/dist/worksheet/comments-xml.d.ts +24 -0
  173. package/dist/worksheet/comments.d.ts +13 -0
  174. package/dist/worksheet/conditional-formatting.d.ts +150 -0
  175. package/dist/worksheet/custom-sheet-views.d.ts +43 -0
  176. package/dist/worksheet/data-consolidate.d.ts +29 -0
  177. package/dist/worksheet/data-validations.d.ts +72 -0
  178. package/dist/worksheet/dimensions.d.ts +40 -0
  179. package/dist/worksheet/errors.d.ts +40 -0
  180. package/dist/worksheet/hyperlinks.d.ts +42 -0
  181. package/dist/worksheet/index.d.ts +46 -0
  182. package/dist/worksheet/ole-objects.d.ts +37 -0
  183. package/dist/worksheet/page-setup.d.ts +173 -0
  184. package/dist/worksheet/phonetic.d.ts +11 -0
  185. package/dist/worksheet/properties.d.ts +34 -0
  186. package/dist/worksheet/protected-ranges.d.ts +19 -0
  187. package/dist/worksheet/protection.d.ts +44 -0
  188. package/dist/worksheet/reader.d.ts +38 -0
  189. package/dist/worksheet/scenarios.d.ts +36 -0
  190. package/dist/worksheet/smart-tags.d.ts +23 -0
  191. package/dist/worksheet/sort-state.d.ts +28 -0
  192. package/dist/worksheet/table-xml.d.ts +5 -0
  193. package/dist/worksheet/table.d.ts +80 -0
  194. package/dist/worksheet/views.d.ts +47 -0
  195. package/dist/worksheet/web-publish.d.ts +21 -0
  196. package/dist/worksheet/worksheet.d.ts +935 -0
  197. package/dist/worksheet/writer.d.ts +72 -0
  198. package/dist/worksheet-CmCNoIgD.mjs +1726 -0
  199. package/dist/worksheet-CmCNoIgD.mjs.map +1 -0
  200. package/dist/worksheet.mjs +247 -0
  201. package/dist/worksheet.mjs.map +1 -0
  202. package/dist/writer-DspzfkNA.mjs +221 -0
  203. package/dist/writer-DspzfkNA.mjs.map +1 -0
  204. package/dist/xml/index.d.ts +10 -0
  205. package/dist/xml/iterparse.d.ts +22 -0
  206. package/dist/xml/namespaces.d.ts +91 -0
  207. package/dist/xml/parser.d.ts +7 -0
  208. package/dist/xml/serializer.d.ts +14 -0
  209. package/dist/xml/stream-writer.d.ts +39 -0
  210. package/dist/xml/tree.d.ts +37 -0
  211. package/dist/xml.mjs +140 -0
  212. package/dist/xml.mjs.map +1 -0
  213. package/dist/zip/decompression-guard.d.ts +70 -0
  214. package/dist/zip/index.d.ts +6 -0
  215. package/dist/zip/random-access-reader.d.ts +16 -0
  216. package/dist/zip/reader.d.ts +45 -0
  217. package/dist/zip/writer.d.ts +65 -0
  218. package/dist/zip/zip64-patch.d.ts +12 -0
  219. package/dist/zip.mjs +3 -0
  220. package/package.json +147 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-Dps1-OpP.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';\nimport { fromTree, toTree } from '../schema/serialize';\nimport { PKG_REL_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { serializeXml } from '../xml/serializer';\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';\nimport { fromTree, toTree } from '../schema/serialize';\nimport { COREPROPS_NS, DCORE_NS, DCTERMS_NS, XSI_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { serializeXml } from '../xml/serializer';\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';\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';\nimport { CPROPS_FMTID, CUSTPROPS_NS, parseQName, VTYPES_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { serializeXml } from '../xml/serializer';\nimport { el, type XmlNode } from '../xml/tree';\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';\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';\nimport { fromTree, toTree } from '../schema/serialize';\nimport { XPROPS_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { serializeXml } from '../xml/serializer';\nimport type { XmlNode } from '../xml/tree';\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';\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';\nimport { fromTree, toTree } from '../schema/serialize';\nimport { CONTYPES_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { serializeXml } from '../xml/serializer';\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;EAA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;CACtE,OAAO,SAAS,SAAS,KAAK,GAAG,cAAc;AACjD"}
package/dist/node.d.ts ADDED
@@ -0,0 +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';
package/dist/node.mjs ADDED
@@ -0,0 +1,308 @@
1
+ import { i as OpenXmlIoError } from "./exceptions-D-CFwxgm.mjs";
2
+ import { t as saveWorkbook } from "./save-RohQtgEZ.mjs";
3
+ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
4
+ import { readFile, unlink } from "node:fs/promises";
5
+ import { once } from "node:events";
6
+ import { Readable, Writable } from "node:stream";
7
+ //#region src/io/node.ts
8
+ /**
9
+ * Wrap a Buffer or Uint8Array as an XlsxSource. The underlying bytes are
10
+ * referenced — no copy — so callers must not mutate them while the source is in
11
+ * use.
12
+ */
13
+ function fromBuffer(buf) {
14
+ if (!(buf instanceof Uint8Array)) throw new OpenXmlIoError("fromBuffer expects a Buffer or Uint8Array");
15
+ const bytes = buf instanceof Buffer ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf;
16
+ return {
17
+ async toBytes() {
18
+ return bytes;
19
+ },
20
+ toStream() {
21
+ return new ReadableStream({ start(controller) {
22
+ controller.enqueue(bytes);
23
+ controller.close();
24
+ } });
25
+ }
26
+ };
27
+ }
28
+ /**
29
+ * In-memory Buffer sink. The buffered path concatenates appended chunks into a
30
+ * single allocation when {@link BufferedSinkWriter.finish} resolves; the
31
+ * convenience `result()` returns it as a Node Buffer.
32
+ */
33
+ function toBuffer() {
34
+ const chunks = [];
35
+ let finalised;
36
+ const finalise = () => {
37
+ if (finalised !== void 0) return finalised;
38
+ let total = 0;
39
+ for (const c of chunks) total += c.byteLength;
40
+ const out = new Uint8Array(total);
41
+ let off = 0;
42
+ for (const c of chunks) {
43
+ out.set(c, off);
44
+ off += c.byteLength;
45
+ }
46
+ finalised = out;
47
+ chunks.length = 0;
48
+ return out;
49
+ };
50
+ return {
51
+ toBytes() {
52
+ return {
53
+ write(chunk) {
54
+ if (finalised !== void 0) throw new OpenXmlIoError("toBuffer sink: write after finish");
55
+ if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError("toBuffer sink: chunk is not a Uint8Array");
56
+ chunks.push(chunk);
57
+ },
58
+ async finish() {
59
+ return finalise();
60
+ },
61
+ abort() {
62
+ if (finalised !== void 0) return;
63
+ finalised = new Uint8Array(0);
64
+ chunks.length = 0;
65
+ }
66
+ };
67
+ },
68
+ result() {
69
+ const bytes = finalise();
70
+ return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
71
+ }
72
+ };
73
+ }
74
+ //#endregion
75
+ //#region src/io/node-fs.ts
76
+ const EMPTY_BYTES = new Uint8Array(0);
77
+ /**
78
+ * Wrap a filesystem path as an XlsxSource. `toBytes` reads the whole file into
79
+ * memory; `toStream` opens a `fs.createReadStream` and bridges it to a Web
80
+ * {@link ReadableStream} via `Readable.toWeb` so the ZIP reader can iterate
81
+ * without loading the entire xlsx up front.
82
+ */
83
+ function fromFile(path) {
84
+ if (typeof path !== "string" || path.length === 0) throw new OpenXmlIoError("fromFile expects a non-empty path string");
85
+ return {
86
+ async toBytes() {
87
+ try {
88
+ return new Uint8Array(await readFile(path));
89
+ } catch (cause) {
90
+ throw new OpenXmlIoError(`fromFile: failed to read "${path}"`, { cause });
91
+ }
92
+ },
93
+ toStream() {
94
+ const nodeStream = createReadStream(path);
95
+ return Readable.toWeb(nodeStream);
96
+ }
97
+ };
98
+ }
99
+ /**
100
+ * Synchronous variant of {@link fromFile}. Convenience for tooling / scripts
101
+ * where the cost of `await fs.readFile` outweighs the ergonomic gain. The
102
+ * returned source's `toBytes` resolves immediately with the bytes already in
103
+ * memory.
104
+ */
105
+ function fromFileSync(path) {
106
+ if (typeof path !== "string" || path.length === 0) throw new OpenXmlIoError("fromFileSync expects a non-empty path string");
107
+ let bytes;
108
+ try {
109
+ bytes = new Uint8Array(readFileSync(path));
110
+ } catch (cause) {
111
+ throw new OpenXmlIoError(`fromFileSync: failed to read "${path}"`, { cause });
112
+ }
113
+ return {
114
+ async toBytes() {
115
+ return bytes;
116
+ },
117
+ toStream() {
118
+ return new ReadableStream({ start(controller) {
119
+ controller.enqueue(bytes);
120
+ controller.close();
121
+ } });
122
+ }
123
+ };
124
+ }
125
+ /**
126
+ * Filesystem sink. Each `write(chunk)` call streams the bytes to disk via
127
+ * `fs.createWriteStream`, honouring backpressure: the actual `writable.write`
128
+ * for each chunk is queued behind any pending `drain`, so the writable's
129
+ * internal buffer never grows past its `highWaterMark` (default 16 KB) no
130
+ * matter how fast the producer hands chunks over.
131
+ *
132
+ * Note on the producer-side memory budget: the sink contract is
133
+ * intentionally synchronous (`write(chunk): void`), so a producer that races
134
+ * ahead without yielding will let chunk references pile up in the queue.
135
+ * That keeps `writable`'s buffer bounded but does not bound the queue
136
+ * itself. Producers that need a hard ceiling should yield between writes
137
+ * (`await new Promise(setImmediate)` is enough) or use a sink with an async
138
+ * write contract.
139
+ *
140
+ * `result()` returns the destination path; `finish()` resolves with an empty
141
+ * `Uint8Array` once the stream has flushed. Callers that need the on-disk
142
+ * bytes should `readFile()` the returned path themselves — re-reading inside
143
+ * `finish()` would defeat the "streamed to disk, never resident" guarantee.
144
+ */
145
+ function toFile(path) {
146
+ if (typeof path !== "string" || path.length === 0) throw new OpenXmlIoError("toFile expects a non-empty path string");
147
+ let stream;
148
+ let streamCreated = false;
149
+ let finalised;
150
+ let pendingError;
151
+ let writeQueue = Promise.resolve();
152
+ const ensureStream = () => {
153
+ if (!stream) {
154
+ stream = createWriteStream(path);
155
+ streamCreated = true;
156
+ stream.on("error", (err) => {
157
+ pendingError = err instanceof Error ? err : new Error(String(err));
158
+ });
159
+ }
160
+ return stream;
161
+ };
162
+ const cleanupOnFailure = async () => {
163
+ if (!streamCreated) return;
164
+ try {
165
+ await unlink(path);
166
+ } catch {}
167
+ };
168
+ return {
169
+ toBytes() {
170
+ return {
171
+ write(chunk) {
172
+ if (finalised !== void 0) throw new OpenXmlIoError(`toFile sink: write after finish ("${path}")`);
173
+ if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError(`toFile sink: chunk is not a Uint8Array ("${path}")`);
174
+ if (pendingError) throw new OpenXmlIoError(`toFile sink: write error on "${path}"`, { cause: pendingError });
175
+ const s = ensureStream();
176
+ writeQueue = writeQueue.then(async () => {
177
+ if (pendingError) return;
178
+ if (!s.write(chunk)) await once(s, "drain");
179
+ });
180
+ },
181
+ async finish() {
182
+ if (finalised) return finalised;
183
+ finalised = (async () => {
184
+ const s = ensureStream();
185
+ try {
186
+ await writeQueue;
187
+ await new Promise((resolve, reject) => {
188
+ s.end((err) => err ? reject(err) : resolve());
189
+ });
190
+ if (pendingError) throw new OpenXmlIoError(`toFile sink: write error on "${path}"`, { cause: pendingError });
191
+ } catch (err) {
192
+ await cleanupOnFailure();
193
+ throw err;
194
+ }
195
+ return EMPTY_BYTES;
196
+ })();
197
+ return finalised;
198
+ },
199
+ abort() {
200
+ if (finalised) return;
201
+ finalised = Promise.resolve(EMPTY_BYTES);
202
+ if (stream) stream.destroy();
203
+ cleanupOnFailure();
204
+ }
205
+ };
206
+ },
207
+ result() {
208
+ return path;
209
+ }
210
+ };
211
+ }
212
+ /**
213
+ * Wrap a Node.js {@link Readable} as an XlsxSource. `toBytes` consumes the
214
+ * entire stream synchronously (collecting chunks); `toStream` bridges to a Web
215
+ * ReadableStream via `Readable.toWeb` so the ZIP reader can pull chunks lazily.
216
+ */
217
+ function fromReadable(readable) {
218
+ if (!(readable instanceof Readable)) throw new OpenXmlIoError("fromReadable expects a Node Readable");
219
+ let bytes;
220
+ return {
221
+ async toBytes() {
222
+ if (bytes) return bytes;
223
+ bytes = (async () => {
224
+ const chunks = [];
225
+ for await (const c of readable) chunks.push(c instanceof Uint8Array ? c : new Uint8Array(c));
226
+ let total = 0;
227
+ for (const c of chunks) total += c.byteLength;
228
+ const out = new Uint8Array(total);
229
+ let off = 0;
230
+ for (const c of chunks) {
231
+ out.set(c, off);
232
+ off += c.byteLength;
233
+ }
234
+ return out;
235
+ })();
236
+ return bytes;
237
+ },
238
+ toStream() {
239
+ return Readable.toWeb(readable);
240
+ }
241
+ };
242
+ }
243
+ /**
244
+ * Wrap a Node.js {@link Writable} as an XlsxSink. The actual
245
+ * `writable.write` for each chunk is queued behind any pending `drain`, so
246
+ * the writable's internal buffer never exceeds its `highWaterMark` regardless
247
+ * of how fast the producer is. See {@link toFile} for the same caveat about
248
+ * producer-side memory: the synchronous `write(chunk)` API does not let
249
+ * backpressure flow back to the caller, so a tight non-yielding producer can
250
+ * still let chunk references accumulate in the queue.
251
+ *
252
+ * `result()` returns the writable itself for downstream chaining.
253
+ */
254
+ function toWritable(writable) {
255
+ if (!(writable instanceof Writable)) throw new OpenXmlIoError("toWritable expects a Node Writable");
256
+ let finalised;
257
+ let pendingError;
258
+ let writeQueue = Promise.resolve();
259
+ writable.on("error", (err) => {
260
+ pendingError = err instanceof Error ? err : new Error(String(err));
261
+ });
262
+ return {
263
+ toBytes() {
264
+ return {
265
+ write(chunk) {
266
+ if (finalised !== void 0) throw new OpenXmlIoError("toWritable sink: write after finish");
267
+ if (!(chunk instanceof Uint8Array)) throw new OpenXmlIoError("toWritable sink: chunk is not a Uint8Array");
268
+ if (pendingError) throw new OpenXmlIoError("toWritable sink: write error", { cause: pendingError });
269
+ writeQueue = writeQueue.then(async () => {
270
+ if (pendingError) return;
271
+ if (!writable.write(chunk)) await once(writable, "drain");
272
+ });
273
+ },
274
+ async finish() {
275
+ if (finalised) return finalised;
276
+ finalised = (async () => {
277
+ await writeQueue;
278
+ await new Promise((resolve, reject) => {
279
+ writable.end((err) => err ? reject(err) : resolve());
280
+ });
281
+ if (pendingError) throw new OpenXmlIoError("toWritable sink: write error", { cause: pendingError });
282
+ return EMPTY_BYTES;
283
+ })();
284
+ return finalised;
285
+ },
286
+ abort(cause) {
287
+ if (finalised) return;
288
+ finalised = Promise.resolve(EMPTY_BYTES);
289
+ writable.destroy(cause instanceof Error ? cause : void 0);
290
+ }
291
+ };
292
+ },
293
+ result() {
294
+ return writable;
295
+ }
296
+ };
297
+ }
298
+ //#endregion
299
+ //#region src/io/node-save.ts
300
+ async function workbookToBuffer(wb, opts) {
301
+ const sink = toBuffer();
302
+ await saveWorkbook(wb, sink, opts);
303
+ return sink.result();
304
+ }
305
+ //#endregion
306
+ export { fromBuffer, fromFile, fromFileSync, fromReadable, toBuffer, toFile, toWritable, workbookToBuffer };
307
+
308
+ //# sourceMappingURL=node.mjs.map
@@ -0,0 +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,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,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,WAAW,KAAK,YAAY;MACvC,IAAI,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,GAAG;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"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Set of properties exposed under `docProps/core.xml`. All fields are optional;
3
+ * the workbook only emits those that are set. Timestamps are stored as ISO-8601
4
+ * strings (the W3CDTF subset) — no Date conversion happens at this layer;
5
+ * phase-3 saveWorkbook is responsible for stamping `modified` to `now()` on
6
+ * each save.
7
+ */
8
+ export interface CoreProperties {
9
+ category?: string;
10
+ contentStatus?: string;
11
+ /** ISO-8601 W3CDTF; auto-stamped on save in phase 3. */
12
+ created?: string;
13
+ creator?: string;
14
+ description?: string;
15
+ identifier?: string;
16
+ keywords?: string;
17
+ language?: string;
18
+ lastModifiedBy?: string;
19
+ /** ISO-8601 W3CDTF. */
20
+ lastPrinted?: string;
21
+ /** ISO-8601 W3CDTF; auto-stamped on save in phase 3. */
22
+ modified?: string;
23
+ revision?: string;
24
+ subject?: string;
25
+ title?: string;
26
+ version?: string;
27
+ }
28
+ export declare function makeCoreProperties(): CoreProperties;
29
+ export declare function corePropsToBytes(p: CoreProperties): Uint8Array;
30
+ export declare function corePropsFromBytes(bytes: Uint8Array | string): CoreProperties;
31
+ import type { Workbook } from '../workbook/workbook';
32
+ /** Set the document author (Excel "File → Properties → Author"). */
33
+ export declare const setWorkbookCreator: (wb: Workbook, creator: string) => void;
34
+ /** Set the document title. */
35
+ export declare const setWorkbookTitle: (wb: Workbook, title: string) => void;
36
+ /** Set the document subject. */
37
+ export declare const setWorkbookSubject: (wb: Workbook, subject: string) => void;
38
+ /** Set the document description / abstract. */
39
+ export declare const setWorkbookDescription: (wb: Workbook, description: string) => void;
40
+ /** Set comma- or semicolon-separated keywords. */
41
+ export declare const setWorkbookKeywords: (wb: Workbook, keywords: string) => void;
42
+ /** Set the "last modified by" name (defaults to creator if absent). */
43
+ export declare const setWorkbookLastModifiedBy: (wb: Workbook, name: string) => void;
44
+ /** Set the document category (e.g. "Reports", "Drafts"). */
45
+ export declare const setWorkbookCategory: (wb: Workbook, category: string) => void;
@@ -0,0 +1,62 @@
1
+ import { type XmlNode } from '../xml/tree';
2
+ export interface CustomProperty {
3
+ /** User-visible property name (must be unique within the workbook). */
4
+ name: string;
5
+ /** OOXML "Property Identifier"; ≥ 2. Auto-allocated if absent on append. */
6
+ pid: number;
7
+ /** Format ID GUID. Defaults to the well-known {D5CDD505-…} on append. */
8
+ fmtid?: string;
9
+ /** Typed value as a raw vt: element. Use the `make*Value` helpers. */
10
+ value: XmlNode;
11
+ }
12
+ export interface CustomProperties {
13
+ properties: CustomProperty[];
14
+ }
15
+ export declare function makeCustomProperties(): CustomProperties;
16
+ export declare function makeStringValue(s: string): XmlNode;
17
+ export declare function makeAsciiStringValue(s: string): XmlNode;
18
+ export declare function makeIntValue(n: number): XmlNode;
19
+ export declare function makeDoubleValue(n: number): XmlNode;
20
+ export declare function makeBoolValue(b: boolean): XmlNode;
21
+ export declare function makeFiletimeValue(iso: string): XmlNode;
22
+ export declare function makeDateValue(iso: string): XmlNode;
23
+ export declare function readStringValue(v: XmlNode): string | undefined;
24
+ export declare function readIntValue(v: XmlNode): number | undefined;
25
+ export declare function readDoubleValue(v: XmlNode): number | undefined;
26
+ export declare function readBoolValue(v: XmlNode): boolean | undefined;
27
+ export declare function readFiletimeValue(v: XmlNode): string | undefined;
28
+ export declare function appendCustomProperty(props: CustomProperties, name: string, value: XmlNode, opts?: {
29
+ pid?: number;
30
+ fmtid?: string;
31
+ }): CustomProperty;
32
+ export declare function findCustomPropertyByName(props: CustomProperties, name: string): CustomProperty | undefined;
33
+ export declare function customPropsToBytes(p: CustomProperties): Uint8Array;
34
+ export declare function customPropsFromBytes(bytes: Uint8Array | string): CustomProperties;
35
+ import type { Workbook } from '../workbook/workbook';
36
+ /** Set (or replace) a custom string property. */
37
+ export declare const setCustomStringProperty: (wb: Workbook, name: string, value: string) => CustomProperty;
38
+ /**
39
+ * Set (or replace) a custom numeric property. Integers (within Int32 range) are
40
+ * stored as `vt:i4`; non-integer / out-of-range numbers as `vt:r8` doubles.
41
+ */
42
+ export declare const setCustomNumberProperty: (wb: Workbook, name: string, value: number) => CustomProperty;
43
+ /** Set (or replace) a custom boolean property. */
44
+ export declare const setCustomBoolProperty: (wb: Workbook, name: string, value: boolean) => CustomProperty;
45
+ /**
46
+ * Set (or replace) a custom date property. Accepts a `Date` (converted to ISO
47
+ * via `toISOString()`) or a pre-formatted W3C-DTF string.
48
+ */
49
+ export declare const setCustomDateProperty: (wb: Workbook, name: string, value: Date | string) => CustomProperty;
50
+ /**
51
+ * Read the typed value of a custom property by name. Tries each decoder in turn
52
+ * — string, int, double, bool, filetime — and returns the first hit. Returns
53
+ * `undefined` for unknown names or unsupported types.
54
+ */
55
+ export declare const getCustomPropertyValue: (wb: Workbook, name: string) => string | number | boolean | undefined;
56
+ /**
57
+ * Remove a custom property by name. Returns `true` when one was removed,
58
+ * `false` when the name wasn't found.
59
+ */
60
+ export declare const removeCustomProperty: (wb: Workbook, name: string) => boolean;
61
+ /** Read-only snapshot of every custom property. */
62
+ export declare const listCustomProperties: (wb: Workbook) => ReadonlyArray<CustomProperty>;
@@ -0,0 +1,45 @@
1
+ import type { XmlNode } from '../xml/tree';
2
+ export interface ExtendedProperties {
3
+ application?: string;
4
+ appVersion?: string;
5
+ characters?: number;
6
+ charactersWithSpaces?: number;
7
+ company?: string;
8
+ digitalSignature?: XmlNode;
9
+ docSecurity?: number;
10
+ hLinks?: XmlNode;
11
+ headingPairs?: XmlNode;
12
+ hiddenSlides?: number;
13
+ hyperlinkBase?: string;
14
+ hyperlinks?: XmlNode;
15
+ hyperlinksChanged?: boolean;
16
+ lines?: number;
17
+ linksUpToDate?: boolean;
18
+ manager?: string;
19
+ mmClips?: number;
20
+ notes?: number;
21
+ pages?: number;
22
+ paragraphs?: number;
23
+ presentationFormat?: string;
24
+ scaleCrop?: boolean;
25
+ sharedDoc?: boolean;
26
+ slides?: number;
27
+ template?: string;
28
+ titlesOfParts?: XmlNode;
29
+ totalTime?: number;
30
+ words?: number;
31
+ }
32
+ export declare function makeExtendedProperties(): ExtendedProperties;
33
+ export declare function extendedPropsToBytes(p: ExtendedProperties): Uint8Array;
34
+ export declare function extendedPropsFromBytes(bytes: Uint8Array | string): ExtendedProperties;
35
+ import type { Workbook } from '../workbook/workbook';
36
+ /** Set the company name on docProps/app.xml. */
37
+ export declare const setWorkbookCompany: (wb: Workbook, company: string) => void;
38
+ /** Set the manager / supervisor name on docProps/app.xml. */
39
+ export declare const setWorkbookManager: (wb: Workbook, manager: string) => void;
40
+ /** Set the application name (e.g. `"Microsoft Excel"`). */
41
+ export declare const setWorkbookApplication: (wb: Workbook, application: string) => void;
42
+ /** Set the application version (typically `"16.0300"` for Excel 365). */
43
+ export declare const setWorkbookAppVersion: (wb: Workbook, version: string) => void;
44
+ /** Set the hyperlink base URL — Excel uses this as a prefix for relative `&F` codes. */
45
+ export declare const setWorkbookHyperlinkBase: (wb: Workbook, base: string) => void;
@@ -0,0 +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';