@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,801 @@
1
+ import { o as OpenXmlSchemaError } from "./exceptions-D-CFwxgm.mjs";
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-Bbs1C8Rc.mjs";
3
+ import { t as parseXml } from "./parser-DuLejQy1.mjs";
4
+ import { n as toTree, r as defineSchema, t as fromTree } from "./serialize-55EnT30e.mjs";
5
+ import { t as serializeXml } from "./serializer-BwbgHYJV.mjs";
6
+ //#region src/packaging/relationships.ts
7
+ const RelationshipSchema = defineSchema({
8
+ tagname: "Relationship",
9
+ xmlNs: PKG_REL_NS,
10
+ attrs: {
11
+ id: {
12
+ kind: "string",
13
+ xmlName: "Id"
14
+ },
15
+ type: {
16
+ kind: "string",
17
+ xmlName: "Type"
18
+ },
19
+ target: {
20
+ kind: "string",
21
+ xmlName: "Target"
22
+ },
23
+ targetMode: {
24
+ kind: "enum",
25
+ values: ["External", "Internal"],
26
+ xmlName: "TargetMode",
27
+ optional: true
28
+ }
29
+ },
30
+ elements: []
31
+ });
32
+ const RelationshipsSchema = defineSchema({
33
+ tagname: "Relationships",
34
+ xmlNs: PKG_REL_NS,
35
+ attrs: {},
36
+ elements: [{
37
+ kind: "sequence",
38
+ key: "rels",
39
+ itemName: "Relationship",
40
+ itemNs: PKG_REL_NS,
41
+ itemSchema: () => RelationshipSchema
42
+ }]
43
+ });
44
+ function makeRelationships() {
45
+ return { rels: [] };
46
+ }
47
+ const RID_RE = /^rId(\d+)$/;
48
+ const allocateNextId = (rels) => {
49
+ const used = /* @__PURE__ */ new Set();
50
+ for (const r of rels.rels) {
51
+ const m = RID_RE.exec(r.id);
52
+ if (m !== null) {
53
+ const n = Number.parseInt(m[1] ?? "0", 10);
54
+ if (Number.isFinite(n) && n > 0) used.add(n);
55
+ }
56
+ }
57
+ let n = 1;
58
+ while (used.has(n)) n++;
59
+ return `rId${n}`;
60
+ };
61
+ /**
62
+ * Append a relationship and return the resulting object. Auto-assigns the next
63
+ * free `rId{N}` Id.
64
+ */
65
+ function appendRel(rels, type, target, targetMode) {
66
+ const next = {
67
+ id: allocateNextId(rels),
68
+ type,
69
+ target
70
+ };
71
+ if (targetMode !== void 0) next.targetMode = targetMode;
72
+ rels.rels.push(next);
73
+ return next;
74
+ }
75
+ function findById(rels, id) {
76
+ for (const r of rels.rels) if (r.id === id) return r;
77
+ }
78
+ /**
79
+ * Build an id → relationship index for callers that look up the same .rels
80
+ * file many times in a hot loop. Cheaper than repeated {@link findById} once
81
+ * the rels count crosses a handful of entries.
82
+ */
83
+ function indexRelsById(rels) {
84
+ const out = /* @__PURE__ */ new Map();
85
+ for (const r of rels.rels) out.set(r.id, r);
86
+ return out;
87
+ }
88
+ function findByType(rels, type) {
89
+ for (const r of rels.rels) if (r.type === type) return r;
90
+ }
91
+ function findAllByType(rels, type) {
92
+ const out = [];
93
+ for (const r of rels.rels) if (r.type === type) out.push(r);
94
+ return out;
95
+ }
96
+ function relsToBytes(rels) {
97
+ return serializeXml(toTree(rels, RelationshipsSchema));
98
+ }
99
+ function relsFromBytes(bytes) {
100
+ return fromTree(parseXml(bytes), RelationshipsSchema);
101
+ }
102
+ //#endregion
103
+ //#region src/packaging/core.ts
104
+ const W3CDTF_ATTRS = { [`{${XSI_NS}}type`]: "dcterms:W3CDTF" };
105
+ const CorePropertiesSchema = defineSchema({
106
+ tagname: "coreProperties",
107
+ xmlNs: COREPROPS_NS,
108
+ attrs: {},
109
+ elements: [
110
+ {
111
+ kind: "text",
112
+ key: "category",
113
+ xmlNs: COREPROPS_NS,
114
+ primitive: "string",
115
+ optional: true
116
+ },
117
+ {
118
+ kind: "text",
119
+ key: "contentStatus",
120
+ xmlNs: COREPROPS_NS,
121
+ primitive: "string",
122
+ optional: true
123
+ },
124
+ {
125
+ kind: "text",
126
+ key: "keywords",
127
+ xmlNs: COREPROPS_NS,
128
+ primitive: "string",
129
+ optional: true
130
+ },
131
+ {
132
+ kind: "text",
133
+ key: "lastModifiedBy",
134
+ xmlNs: COREPROPS_NS,
135
+ primitive: "string",
136
+ optional: true
137
+ },
138
+ {
139
+ kind: "text",
140
+ key: "lastPrinted",
141
+ xmlNs: DCTERMS_NS,
142
+ primitive: "string",
143
+ optional: true,
144
+ attrs: W3CDTF_ATTRS
145
+ },
146
+ {
147
+ kind: "text",
148
+ key: "revision",
149
+ xmlNs: COREPROPS_NS,
150
+ primitive: "string",
151
+ optional: true
152
+ },
153
+ {
154
+ kind: "text",
155
+ key: "version",
156
+ xmlNs: COREPROPS_NS,
157
+ primitive: "string",
158
+ optional: true
159
+ },
160
+ {
161
+ kind: "text",
162
+ key: "description",
163
+ xmlNs: DCORE_NS,
164
+ primitive: "string",
165
+ optional: true
166
+ },
167
+ {
168
+ kind: "text",
169
+ key: "identifier",
170
+ xmlNs: DCORE_NS,
171
+ primitive: "string",
172
+ optional: true
173
+ },
174
+ {
175
+ kind: "text",
176
+ key: "language",
177
+ xmlNs: DCORE_NS,
178
+ primitive: "string",
179
+ optional: true
180
+ },
181
+ {
182
+ kind: "text",
183
+ key: "subject",
184
+ xmlNs: DCORE_NS,
185
+ primitive: "string",
186
+ optional: true
187
+ },
188
+ {
189
+ kind: "text",
190
+ key: "title",
191
+ xmlNs: DCORE_NS,
192
+ primitive: "string",
193
+ optional: true
194
+ },
195
+ {
196
+ kind: "text",
197
+ key: "creator",
198
+ xmlNs: DCORE_NS,
199
+ primitive: "string",
200
+ optional: true
201
+ },
202
+ {
203
+ kind: "text",
204
+ key: "created",
205
+ xmlNs: DCTERMS_NS,
206
+ primitive: "string",
207
+ optional: true,
208
+ attrs: W3CDTF_ATTRS
209
+ },
210
+ {
211
+ kind: "text",
212
+ key: "modified",
213
+ xmlNs: DCTERMS_NS,
214
+ primitive: "string",
215
+ optional: true,
216
+ attrs: W3CDTF_ATTRS
217
+ }
218
+ ]
219
+ });
220
+ function makeCoreProperties() {
221
+ return {};
222
+ }
223
+ function corePropsToBytes(p) {
224
+ return serializeXml(toTree(p, CorePropertiesSchema));
225
+ }
226
+ function corePropsFromBytes(bytes) {
227
+ return fromTree(parseXml(bytes), CorePropertiesSchema);
228
+ }
229
+ const ensureCoreProperties = (wb) => {
230
+ if (!wb.properties) wb.properties = {};
231
+ return wb.properties;
232
+ };
233
+ /** Set the document author (Excel "File → Properties → Author"). */
234
+ const setWorkbookCreator = (wb, creator) => {
235
+ ensureCoreProperties(wb).creator = creator;
236
+ };
237
+ /** Set the document title. */
238
+ const setWorkbookTitle = (wb, title) => {
239
+ ensureCoreProperties(wb).title = title;
240
+ };
241
+ /** Set the document subject. */
242
+ const setWorkbookSubject = (wb, subject) => {
243
+ ensureCoreProperties(wb).subject = subject;
244
+ };
245
+ /** Set the document description / abstract. */
246
+ const setWorkbookDescription = (wb, description) => {
247
+ ensureCoreProperties(wb).description = description;
248
+ };
249
+ /** Set comma- or semicolon-separated keywords. */
250
+ const setWorkbookKeywords = (wb, keywords) => {
251
+ ensureCoreProperties(wb).keywords = keywords;
252
+ };
253
+ /** Set the "last modified by" name (defaults to creator if absent). */
254
+ const setWorkbookLastModifiedBy = (wb, name) => {
255
+ ensureCoreProperties(wb).lastModifiedBy = name;
256
+ };
257
+ /** Set the document category (e.g. "Reports", "Drafts"). */
258
+ const setWorkbookCategory = (wb, category) => {
259
+ ensureCoreProperties(wb).category = category;
260
+ };
261
+ //#endregion
262
+ //#region src/packaging/custom.ts
263
+ function makeCustomProperties() {
264
+ return { properties: [] };
265
+ }
266
+ const PROPERTY_NAME = `{${CUSTPROPS_NS}}property`;
267
+ const PROPERTIES_NAME = `{${CUSTPROPS_NS}}Properties`;
268
+ const vt = (local, text) => el(`{${VTYPES_NS}}${local}`, {}, [], text);
269
+ function makeStringValue(s) {
270
+ return vt("lpwstr", s);
271
+ }
272
+ function makeAsciiStringValue(s) {
273
+ return vt("lpstr", s);
274
+ }
275
+ function makeIntValue(n) {
276
+ if (!Number.isInteger(n)) throw new OpenXmlSchemaError(`makeIntValue: ${n} is not an integer`);
277
+ return vt("i4", String(n));
278
+ }
279
+ function makeDoubleValue(n) {
280
+ if (!Number.isFinite(n)) throw new OpenXmlSchemaError(`makeDoubleValue: ${n} is not finite`);
281
+ return vt("r8", String(n));
282
+ }
283
+ function makeBoolValue(b) {
284
+ return vt("bool", b ? "1" : "0");
285
+ }
286
+ function makeFiletimeValue(iso) {
287
+ return vt("filetime", iso);
288
+ }
289
+ function makeDateValue(iso) {
290
+ return vt("date", iso);
291
+ }
292
+ const localNameOf = (n) => parseQName(n.name).local;
293
+ function readStringValue(v) {
294
+ const ln = localNameOf(v);
295
+ if (ln === "lpwstr" || ln === "lpstr" || ln === "bstr") return v.text ?? "";
296
+ }
297
+ function readIntValue(v) {
298
+ const ln = localNameOf(v);
299
+ if (ln === "i4" || ln === "i2" || ln === "i1" || ln === "int" || ln === "uint" || ln === "ui4" || ln === "ui2" || ln === "ui1") {
300
+ const n = Number.parseInt(v.text ?? "", 10);
301
+ return Number.isFinite(n) ? n : void 0;
302
+ }
303
+ }
304
+ function readDoubleValue(v) {
305
+ const ln = localNameOf(v);
306
+ if (ln === "r4" || ln === "r8" || ln === "decimal" || ln === "cy") {
307
+ const n = Number.parseFloat(v.text ?? "");
308
+ return Number.isFinite(n) ? n : void 0;
309
+ }
310
+ }
311
+ function readBoolValue(v) {
312
+ if (localNameOf(v) !== "bool") return void 0;
313
+ const t = (v.text ?? "").toLowerCase();
314
+ if (t === "1" || t === "true" || t === "t") return true;
315
+ if (t === "0" || t === "false" || t === "f") return false;
316
+ }
317
+ function readFiletimeValue(v) {
318
+ if (localNameOf(v) === "filetime") return v.text ?? "";
319
+ }
320
+ const allocatePid = (props) => {
321
+ const used = /* @__PURE__ */ new Set();
322
+ for (const p of props.properties) used.add(p.pid);
323
+ let n = 2;
324
+ while (used.has(n)) n++;
325
+ return n;
326
+ };
327
+ function appendCustomProperty(props, name, value, opts) {
328
+ const out = {
329
+ name,
330
+ pid: opts?.pid ?? allocatePid(props),
331
+ value
332
+ };
333
+ if (opts?.fmtid !== void 0) out.fmtid = opts.fmtid;
334
+ props.properties.push(out);
335
+ return out;
336
+ }
337
+ function findCustomPropertyByName(props, name) {
338
+ for (const p of props.properties) if (p.name === name) return p;
339
+ }
340
+ function customPropsToBytes(p) {
341
+ const root = el(PROPERTIES_NAME);
342
+ for (const prop of p.properties) {
343
+ const propEl = el(PROPERTY_NAME, {
344
+ fmtid: prop.fmtid ?? "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
345
+ pid: String(prop.pid),
346
+ name: prop.name
347
+ });
348
+ propEl.children.push(prop.value);
349
+ root.children.push(propEl);
350
+ }
351
+ return serializeXml(root);
352
+ }
353
+ function customPropsFromBytes(bytes) {
354
+ const root = parseXml(bytes);
355
+ if (root.name !== PROPERTIES_NAME) throw new OpenXmlSchemaError(`customPropsFromBytes: expected <Properties>, got "${root.name}"`);
356
+ const properties = [];
357
+ for (const propEl of root.children) {
358
+ if (propEl.name !== PROPERTY_NAME) continue;
359
+ const fmtid = propEl.attrs["fmtid"];
360
+ const pidRaw = propEl.attrs["pid"];
361
+ const name = propEl.attrs["name"];
362
+ if (name === void 0 || pidRaw === void 0) throw new OpenXmlSchemaError("custom.xml: <property> requires name and pid attributes");
363
+ const pid = Number.parseInt(pidRaw, 10);
364
+ if (!Number.isFinite(pid)) throw new OpenXmlSchemaError(`custom.xml: <property> pid is not an integer (got "${pidRaw}")`);
365
+ const value = propEl.children[0];
366
+ if (value === void 0) throw new OpenXmlSchemaError(`custom.xml: <property name="${name}"> has no typed-value child`);
367
+ const out = {
368
+ name,
369
+ pid,
370
+ value
371
+ };
372
+ if (fmtid !== void 0) out.fmtid = fmtid;
373
+ properties.push(out);
374
+ }
375
+ return { properties };
376
+ }
377
+ const ensureCustomProperties = (wb) => {
378
+ if (!wb.customProperties) wb.customProperties = makeCustomProperties();
379
+ return wb.customProperties;
380
+ };
381
+ const replaceOrAppend = (wb, name, value, opts) => {
382
+ const props = ensureCustomProperties(wb);
383
+ const existing = findCustomPropertyByName(props, name);
384
+ if (existing) {
385
+ existing.value = value;
386
+ if (opts?.fmtid !== void 0) existing.fmtid = opts.fmtid;
387
+ return existing;
388
+ }
389
+ return appendCustomProperty(props, name, value, opts);
390
+ };
391
+ /** Set (or replace) a custom string property. */
392
+ const setCustomStringProperty = (wb, name, value) => replaceOrAppend(wb, name, makeStringValue(value));
393
+ /**
394
+ * Set (or replace) a custom numeric property. Integers (within Int32 range) are
395
+ * stored as `vt:i4`; non-integer / out-of-range numbers as `vt:r8` doubles.
396
+ */
397
+ const setCustomNumberProperty = (wb, name, value) => {
398
+ if (!Number.isFinite(value)) throw new OpenXmlSchemaError(`setCustomNumberProperty: value "${value}" is not finite`);
399
+ return replaceOrAppend(wb, name, Number.isInteger(value) && value >= -2147483648 && value <= 2147483647 ? makeIntValue(value) : makeDoubleValue(value));
400
+ };
401
+ /** Set (or replace) a custom boolean property. */
402
+ const setCustomBoolProperty = (wb, name, value) => replaceOrAppend(wb, name, makeBoolValue(value));
403
+ /**
404
+ * Set (or replace) a custom date property. Accepts a `Date` (converted to ISO
405
+ * via `toISOString()`) or a pre-formatted W3C-DTF string.
406
+ */
407
+ const setCustomDateProperty = (wb, name, value) => {
408
+ return replaceOrAppend(wb, name, makeFiletimeValue(value instanceof Date ? value.toISOString() : value));
409
+ };
410
+ /**
411
+ * Read the typed value of a custom property by name. Tries each decoder in turn
412
+ * — string, int, double, bool, filetime — and returns the first hit. Returns
413
+ * `undefined` for unknown names or unsupported types.
414
+ */
415
+ const getCustomPropertyValue = (wb, name) => {
416
+ if (!wb.customProperties) return void 0;
417
+ const prop = findCustomPropertyByName(wb.customProperties, name);
418
+ if (!prop) return void 0;
419
+ const s = readStringValue(prop.value);
420
+ if (s !== void 0) return s;
421
+ const i = readIntValue(prop.value);
422
+ if (i !== void 0) return i;
423
+ const d = readDoubleValue(prop.value);
424
+ if (d !== void 0) return d;
425
+ const b = readBoolValue(prop.value);
426
+ if (b !== void 0) return b;
427
+ const ft = readFiletimeValue(prop.value);
428
+ if (ft !== void 0) return ft;
429
+ };
430
+ /**
431
+ * Remove a custom property by name. Returns `true` when one was removed,
432
+ * `false` when the name wasn't found.
433
+ */
434
+ const removeCustomProperty = (wb, name) => {
435
+ if (!wb.customProperties) return false;
436
+ const arr = wb.customProperties.properties;
437
+ const i = arr.findIndex((p) => p.name === name);
438
+ if (i < 0) return false;
439
+ arr.splice(i, 1);
440
+ return true;
441
+ };
442
+ /** Read-only snapshot of every custom property. */
443
+ const listCustomProperties = (wb) => {
444
+ return wb.customProperties?.properties ?? [];
445
+ };
446
+ //#endregion
447
+ //#region src/packaging/extended.ts
448
+ const ExtendedSchema = defineSchema({
449
+ tagname: "Properties",
450
+ xmlNs: XPROPS_NS,
451
+ attrs: {},
452
+ elements: [
453
+ {
454
+ kind: "text",
455
+ key: "template",
456
+ xmlNs: XPROPS_NS,
457
+ name: "Template",
458
+ primitive: "string",
459
+ optional: true
460
+ },
461
+ {
462
+ kind: "text",
463
+ key: "manager",
464
+ xmlNs: XPROPS_NS,
465
+ name: "Manager",
466
+ primitive: "string",
467
+ optional: true
468
+ },
469
+ {
470
+ kind: "text",
471
+ key: "company",
472
+ xmlNs: XPROPS_NS,
473
+ name: "Company",
474
+ primitive: "string",
475
+ optional: true
476
+ },
477
+ {
478
+ kind: "text",
479
+ key: "pages",
480
+ xmlNs: XPROPS_NS,
481
+ name: "Pages",
482
+ primitive: "int",
483
+ optional: true
484
+ },
485
+ {
486
+ kind: "text",
487
+ key: "words",
488
+ xmlNs: XPROPS_NS,
489
+ name: "Words",
490
+ primitive: "int",
491
+ optional: true
492
+ },
493
+ {
494
+ kind: "text",
495
+ key: "characters",
496
+ xmlNs: XPROPS_NS,
497
+ name: "Characters",
498
+ primitive: "int",
499
+ optional: true
500
+ },
501
+ {
502
+ kind: "text",
503
+ key: "presentationFormat",
504
+ xmlNs: XPROPS_NS,
505
+ name: "PresentationFormat",
506
+ primitive: "string",
507
+ optional: true
508
+ },
509
+ {
510
+ kind: "text",
511
+ key: "lines",
512
+ xmlNs: XPROPS_NS,
513
+ name: "Lines",
514
+ primitive: "int",
515
+ optional: true
516
+ },
517
+ {
518
+ kind: "text",
519
+ key: "paragraphs",
520
+ xmlNs: XPROPS_NS,
521
+ name: "Paragraphs",
522
+ primitive: "int",
523
+ optional: true
524
+ },
525
+ {
526
+ kind: "text",
527
+ key: "slides",
528
+ xmlNs: XPROPS_NS,
529
+ name: "Slides",
530
+ primitive: "int",
531
+ optional: true
532
+ },
533
+ {
534
+ kind: "text",
535
+ key: "notes",
536
+ xmlNs: XPROPS_NS,
537
+ name: "Notes",
538
+ primitive: "int",
539
+ optional: true
540
+ },
541
+ {
542
+ kind: "text",
543
+ key: "totalTime",
544
+ xmlNs: XPROPS_NS,
545
+ name: "TotalTime",
546
+ primitive: "int",
547
+ optional: true
548
+ },
549
+ {
550
+ kind: "text",
551
+ key: "hiddenSlides",
552
+ xmlNs: XPROPS_NS,
553
+ name: "HiddenSlides",
554
+ primitive: "int",
555
+ optional: true
556
+ },
557
+ {
558
+ kind: "text",
559
+ key: "mmClips",
560
+ xmlNs: XPROPS_NS,
561
+ name: "MMClips",
562
+ primitive: "int",
563
+ optional: true
564
+ },
565
+ {
566
+ kind: "text",
567
+ key: "scaleCrop",
568
+ xmlNs: XPROPS_NS,
569
+ name: "ScaleCrop",
570
+ primitive: "bool",
571
+ optional: true
572
+ },
573
+ {
574
+ kind: "raw",
575
+ key: "headingPairs",
576
+ xmlNs: XPROPS_NS,
577
+ name: "HeadingPairs",
578
+ optional: true
579
+ },
580
+ {
581
+ kind: "raw",
582
+ key: "titlesOfParts",
583
+ xmlNs: XPROPS_NS,
584
+ name: "TitlesOfParts",
585
+ optional: true
586
+ },
587
+ {
588
+ kind: "raw",
589
+ key: "hLinks",
590
+ xmlNs: XPROPS_NS,
591
+ name: "HLinks",
592
+ optional: true
593
+ },
594
+ {
595
+ kind: "raw",
596
+ key: "hyperlinks",
597
+ xmlNs: XPROPS_NS,
598
+ name: "Hyperlinks",
599
+ optional: true
600
+ },
601
+ {
602
+ kind: "text",
603
+ key: "linksUpToDate",
604
+ xmlNs: XPROPS_NS,
605
+ name: "LinksUpToDate",
606
+ primitive: "bool",
607
+ optional: true
608
+ },
609
+ {
610
+ kind: "text",
611
+ key: "sharedDoc",
612
+ xmlNs: XPROPS_NS,
613
+ name: "SharedDoc",
614
+ primitive: "bool",
615
+ optional: true
616
+ },
617
+ {
618
+ kind: "text",
619
+ key: "hyperlinkBase",
620
+ xmlNs: XPROPS_NS,
621
+ name: "HyperlinkBase",
622
+ primitive: "string",
623
+ optional: true
624
+ },
625
+ {
626
+ kind: "text",
627
+ key: "hyperlinksChanged",
628
+ xmlNs: XPROPS_NS,
629
+ name: "HyperlinksChanged",
630
+ primitive: "bool",
631
+ optional: true
632
+ },
633
+ {
634
+ kind: "raw",
635
+ key: "digitalSignature",
636
+ xmlNs: XPROPS_NS,
637
+ name: "DigSig",
638
+ optional: true
639
+ },
640
+ {
641
+ kind: "text",
642
+ key: "application",
643
+ xmlNs: XPROPS_NS,
644
+ name: "Application",
645
+ primitive: "string",
646
+ optional: true
647
+ },
648
+ {
649
+ kind: "text",
650
+ key: "appVersion",
651
+ xmlNs: XPROPS_NS,
652
+ name: "AppVersion",
653
+ primitive: "string",
654
+ optional: true
655
+ },
656
+ {
657
+ kind: "text",
658
+ key: "docSecurity",
659
+ xmlNs: XPROPS_NS,
660
+ name: "DocSecurity",
661
+ primitive: "int",
662
+ optional: true
663
+ },
664
+ {
665
+ kind: "text",
666
+ key: "charactersWithSpaces",
667
+ xmlNs: XPROPS_NS,
668
+ name: "CharactersWithSpaces",
669
+ primitive: "int",
670
+ optional: true
671
+ }
672
+ ]
673
+ });
674
+ function makeExtendedProperties() {
675
+ return {};
676
+ }
677
+ function extendedPropsToBytes(p) {
678
+ return serializeXml(toTree(p, ExtendedSchema));
679
+ }
680
+ function extendedPropsFromBytes(bytes) {
681
+ return fromTree(parseXml(bytes), ExtendedSchema);
682
+ }
683
+ const ensureAppProperties = (wb) => {
684
+ if (!wb.appProperties) wb.appProperties = {};
685
+ return wb.appProperties;
686
+ };
687
+ /** Set the company name on docProps/app.xml. */
688
+ const setWorkbookCompany = (wb, company) => {
689
+ ensureAppProperties(wb).company = company;
690
+ };
691
+ /** Set the manager / supervisor name on docProps/app.xml. */
692
+ const setWorkbookManager = (wb, manager) => {
693
+ ensureAppProperties(wb).manager = manager;
694
+ };
695
+ /** Set the application name (e.g. `"Microsoft Excel"`). */
696
+ const setWorkbookApplication = (wb, application) => {
697
+ ensureAppProperties(wb).application = application;
698
+ };
699
+ /** Set the application version (typically `"16.0300"` for Excel 365). */
700
+ const setWorkbookAppVersion = (wb, version) => {
701
+ ensureAppProperties(wb).appVersion = version;
702
+ };
703
+ /** Set the hyperlink base URL — Excel uses this as a prefix for relative `&F` codes. */
704
+ const setWorkbookHyperlinkBase = (wb, base) => {
705
+ ensureAppProperties(wb).hyperlinkBase = base;
706
+ };
707
+ //#endregion
708
+ //#region src/packaging/manifest.ts
709
+ const DefaultSchema = defineSchema({
710
+ tagname: "Default",
711
+ xmlNs: CONTYPES_NS,
712
+ attrs: {
713
+ ext: {
714
+ kind: "string",
715
+ xmlName: "Extension"
716
+ },
717
+ contentType: {
718
+ kind: "string",
719
+ xmlName: "ContentType"
720
+ }
721
+ },
722
+ elements: []
723
+ });
724
+ const OverrideSchema = defineSchema({
725
+ tagname: "Override",
726
+ xmlNs: CONTYPES_NS,
727
+ attrs: {
728
+ partName: {
729
+ kind: "string",
730
+ xmlName: "PartName"
731
+ },
732
+ contentType: {
733
+ kind: "string",
734
+ xmlName: "ContentType"
735
+ }
736
+ },
737
+ elements: []
738
+ });
739
+ const ManifestSchema = defineSchema({
740
+ tagname: "Types",
741
+ xmlNs: CONTYPES_NS,
742
+ attrs: {},
743
+ elements: [{
744
+ kind: "sequence",
745
+ key: "defaults",
746
+ itemName: "Default",
747
+ itemNs: CONTYPES_NS,
748
+ itemSchema: () => DefaultSchema
749
+ }, {
750
+ kind: "sequence",
751
+ key: "overrides",
752
+ itemName: "Override",
753
+ itemNs: CONTYPES_NS,
754
+ itemSchema: () => OverrideSchema
755
+ }]
756
+ });
757
+ function makeManifest() {
758
+ return {
759
+ defaults: [],
760
+ overrides: []
761
+ };
762
+ }
763
+ /** Register a default content type for an extension. Idempotent. */
764
+ function addDefault(m, ext, contentType) {
765
+ for (const d of m.defaults) if (d.ext === ext) {
766
+ if (d.contentType !== contentType) d.contentType = contentType;
767
+ return;
768
+ }
769
+ m.defaults.push({
770
+ ext,
771
+ contentType
772
+ });
773
+ }
774
+ /** Register an Override for a specific part. Idempotent. */
775
+ function addOverride(m, partName, contentType) {
776
+ for (const o of m.overrides) if (o.partName === partName) {
777
+ if (o.contentType !== contentType) o.contentType = contentType;
778
+ return;
779
+ }
780
+ m.overrides.push({
781
+ partName,
782
+ contentType
783
+ });
784
+ }
785
+ function findOverride(m, partName) {
786
+ for (const o of m.overrides) if (o.partName === partName) return o;
787
+ }
788
+ /** Find the first Override matching a content type. */
789
+ function findOverrideByContentType(m, contentType) {
790
+ for (const o of m.overrides) if (o.contentType === contentType) return o;
791
+ }
792
+ function manifestToBytes(m) {
793
+ return serializeXml(toTree(m, ManifestSchema));
794
+ }
795
+ function manifestFromBytes(bytes) {
796
+ return fromTree(parseXml(bytes), ManifestSchema);
797
+ }
798
+ //#endregion
799
+ 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 };
800
+
801
+ //# sourceMappingURL=manifest-Dps1-OpP.mjs.map