javascript-excel 1.0.3 → 2.0.0-alpha.2

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 (58) hide show
  1. package/README.md +69 -2
  2. package/dist/auto-width-2oBzjeNG.d.cts +11 -0
  3. package/dist/auto-width-CT-BihTW.d.ts +10 -0
  4. package/dist/csv-DyVH9y7S.cjs +647 -0
  5. package/dist/csv-pXfaputs.js +618 -0
  6. package/dist/csv.cjs +7 -0
  7. package/dist/csv.d.cts +89 -0
  8. package/dist/csv.d.ts +89 -0
  9. package/dist/csv.js +1 -0
  10. package/dist/dom.cjs +440 -0
  11. package/dist/dom.d.cts +78 -0
  12. package/dist/dom.d.ts +78 -0
  13. package/dist/dom.js +437 -0
  14. package/dist/errors-CvGlfw0E.js +28 -0
  15. package/dist/errors-DOPrrGS4.cjs +69 -0
  16. package/dist/index.cjs +627 -0
  17. package/dist/index.d.cts +255 -0
  18. package/dist/index.d.ts +255 -0
  19. package/dist/index.js +597 -0
  20. package/dist/infer-BR-J9BZa.js +88 -0
  21. package/dist/infer-D9EC9vJ-.cjs +105 -0
  22. package/dist/iso-date-3TY1OlGd.cjs +57 -0
  23. package/dist/iso-date-CXnn-9mT.js +46 -0
  24. package/dist/numfmt-BBgB7iQA.js +429 -0
  25. package/dist/numfmt-Dv6AjopS.cjs +512 -0
  26. package/dist/read-C6L7Nyy3.d.cts +78 -0
  27. package/dist/read-DDN5ZsPe.js +2909 -0
  28. package/dist/read-Ddkks7qC.d.ts +78 -0
  29. package/dist/read-Ym1voUct.cjs +2932 -0
  30. package/dist/read.cjs +6 -0
  31. package/dist/read.d.cts +15 -0
  32. package/dist/read.d.ts +15 -0
  33. package/dist/read.js +1 -0
  34. package/dist/sheet-names-qpXsvMpM.cjs +1005 -0
  35. package/dist/sheet-names-uT2EH5Ui.js +832 -0
  36. package/dist/signal-Dz0ZYe6d.d.cts +13 -0
  37. package/dist/signal-Dz0ZYe6d.d.ts +13 -0
  38. package/dist/warnings-C_12PT4t.d.cts +410 -0
  39. package/dist/warnings-DXJKe1lx.d.ts +410 -0
  40. package/dist/worker.cjs +240 -0
  41. package/dist/worker.d.cts +65 -0
  42. package/dist/worker.d.ts +65 -0
  43. package/dist/worker.js +238 -0
  44. package/dist/write-BOh9jfu1.cjs +1487 -0
  45. package/dist/write-C5JgeIar.d.cts +29 -0
  46. package/dist/write-CYpLGuzl.d.ts +29 -0
  47. package/dist/write-DubvcG-x.js +1470 -0
  48. package/package.json +101 -51
  49. package/.babelrc +0 -10
  50. package/.circleci/config.yml +0 -39
  51. package/lib/index.d.ts +0 -1
  52. package/lib/index.js +0 -22
  53. package/lib/javascript-excel.js +0 -17703
  54. package/src/index.tsx +0 -11
  55. package/test/unit/sample.spec.js +0 -5
  56. package/tsconfig.json +0 -54
  57. package/webpack.config.js +0 -19
  58. /package/{LICENSE.md → LICENSE} +0 -0
@@ -0,0 +1,512 @@
1
+ const require_errors = require("./errors-DOPrrGS4.cjs");
2
+ // src/internal/zip/bytes.ts
3
+ /** Rejects with `signal.reason`, the same as fetch. */
4
+ function throwIfAborted(signal) {
5
+ if (signal?.aborted) throw signal.reason ?? /* @__PURE__ */ new Error("The operation was aborted.");
6
+ }
7
+ function concatBytes(parts) {
8
+ if (parts.length === 1) return parts[0];
9
+ let total = 0;
10
+ for (const p of parts) total += p.length;
11
+ const out = new Uint8Array(total);
12
+ let offset = 0;
13
+ for (const p of parts) {
14
+ out.set(p, offset);
15
+ offset += p.length;
16
+ }
17
+ return out;
18
+ }
19
+ /** Little-endian writer into a fixed-size buffer. */
20
+ var ByteWriter = class {
21
+ bytes;
22
+ view;
23
+ pos = 0;
24
+ constructor(size) {
25
+ this.bytes = new Uint8Array(size);
26
+ this.view = new DataView(this.bytes.buffer);
27
+ }
28
+ u16(v) {
29
+ this.view.setUint16(this.pos, v, true);
30
+ this.pos += 2;
31
+ }
32
+ u32(v) {
33
+ this.view.setUint32(this.pos, v >>> 0, true);
34
+ this.pos += 4;
35
+ }
36
+ raw(b) {
37
+ this.bytes.set(b, this.pos);
38
+ this.pos += b.length;
39
+ }
40
+ };
41
+ const clock = (() => {
42
+ const perf = globalThis.performance;
43
+ return perf && typeof perf.now === "function" ? () => perf.now() : () => Date.now();
44
+ })();
45
+ /** Wraps a progress callback: monotonic ratio, throttled. Returns undefined when there is no callback. */
46
+ function throttleProgress(cb, intervalMs = 50) {
47
+ if (!cb) return void 0;
48
+ let last = -1e400;
49
+ let lastPhase;
50
+ let lastSheet;
51
+ let ratio = 0;
52
+ return (p) => {
53
+ ratio = Math.min(1, Math.max(ratio, p.ratio));
54
+ const now = clock();
55
+ if (!(p.phase !== lastPhase || p.sheet !== lastSheet) && ratio < 1 && now - last < intervalMs) return;
56
+ last = now;
57
+ lastPhase = p.phase;
58
+ lastSheet = p.sheet;
59
+ const out = {
60
+ phase: p.phase,
61
+ ratio
62
+ };
63
+ if (p.sheet !== void 0) out.sheet = p.sheet;
64
+ cb(out);
65
+ };
66
+ }
67
+ // src/internal/platform.ts
68
+ /**
69
+ * Minimal structural types for the web platform APIs the engine uses.
70
+ *
71
+ * The package compiles against `lib: ES2022` with no DOM or Node types, so the
72
+ * published declarations never depend on a consumer's `lib` setting. These
73
+ * interfaces describe only the members the engine calls. They are internal and
74
+ * never appear in a public signature.
75
+ */
76
+ const g = globalThis;
77
+ function missing(api) {
78
+ return new require_errors.EnvironmentError("ENVIRONMENT_UNSUPPORTED", `${api} is not available in this runtime. javascript-excel needs Node.js 22 or later, or a browser with CompressionStream('deflate-raw') support.`, { details: { api } });
79
+ }
80
+ /** Creates a raw-DEFLATE compression or decompression stream, or throws ENVIRONMENT_UNSUPPORTED. */
81
+ function createStream(kind) {
82
+ const name = kind === "compress" ? "CompressionStream" : "DecompressionStream";
83
+ const Ctor = kind === "compress" ? g.CompressionStream : g.DecompressionStream;
84
+ if (typeof Ctor !== "function") throw missing(name);
85
+ try {
86
+ return new Ctor("deflate-raw");
87
+ } catch (cause) {
88
+ const err = missing(`${name}('deflate-raw')`);
89
+ err.cause = cause;
90
+ throw err;
91
+ }
92
+ }
93
+ let encoder;
94
+ let strictDecoder;
95
+ function encodeUtf8(text) {
96
+ if (!encoder) {
97
+ if (typeof g.TextEncoder !== "function") throw missing("TextEncoder");
98
+ encoder = new g.TextEncoder();
99
+ }
100
+ return encoder.encode(text);
101
+ }
102
+ /** Decodes UTF-8 and throws a TypeError on invalid bytes. */
103
+ function decodeUtf8Strict(bytes) {
104
+ if (!strictDecoder) {
105
+ if (typeof g.TextDecoder !== "function") throw missing("TextDecoder");
106
+ strictDecoder = new g.TextDecoder("utf-8", { fatal: true });
107
+ }
108
+ return strictDecoder.decode(bytes);
109
+ }
110
+ const ignore = () => {};
111
+ async function deflateRaw(chunks, signal) {
112
+ throwIfAborted(signal);
113
+ const stream = createStream("compress");
114
+ const writer = stream.writable.getWriter();
115
+ const reader = stream.readable.getReader();
116
+ const out = [];
117
+ const reading = (async () => {
118
+ for (;;) {
119
+ const r = await reader.read();
120
+ if (r.done) return;
121
+ if (r.value) out.push(r.value);
122
+ }
123
+ })();
124
+ try {
125
+ for await (const chunk of chunks) {
126
+ throwIfAborted(signal);
127
+ if (chunk.length > 0) await writer.write(chunk);
128
+ }
129
+ throwIfAborted(signal);
130
+ await writer.close();
131
+ await reading;
132
+ } catch (err) {
133
+ writer.abort(err).catch(ignore);
134
+ reader.cancel(err).catch(ignore);
135
+ await reading.catch(ignore);
136
+ throw err;
137
+ }
138
+ return concatBytes(out);
139
+ }
140
+ async function* inflateRaw(data, limits, signal) {
141
+ throwIfAborted(signal);
142
+ const stream = createStream("decompress");
143
+ const writer = stream.writable.getWriter();
144
+ const reader = stream.readable.getReader();
145
+ const writing = writer.write(data).then(() => writer.close());
146
+ writing.catch(ignore);
147
+ let produced = 0;
148
+ let finished = false;
149
+ try {
150
+ for (;;) {
151
+ throwIfAborted(signal);
152
+ let r;
153
+ try {
154
+ r = await reader.read();
155
+ } catch (cause) {
156
+ throw new require_errors.FormatError("ZIP_INVALID", "Invalid or truncated DEFLATE data.", { cause });
157
+ }
158
+ if (r.done) break;
159
+ const chunk = r.value;
160
+ if (!chunk || chunk.length === 0) continue;
161
+ produced += chunk.length;
162
+ if (produced > limits.maxOutputBytes) throw new require_errors.LimitError("LIMIT_EXCEEDED", `Decompressed entry exceeds ${limits.maxOutputBytes} bytes.`, { details: {
163
+ limit: "maxEntryBytes",
164
+ value: produced,
165
+ max: limits.maxOutputBytes
166
+ } });
167
+ if (produced > 1048576 && produced / Math.max(1, data.length) > limits.maxRatio) throw new require_errors.LimitError("LIMIT_EXCEEDED", `Compression ratio exceeds ${limits.maxRatio}.`, { details: {
168
+ limit: "maxRatio",
169
+ value: produced / Math.max(1, data.length),
170
+ max: limits.maxRatio
171
+ } });
172
+ yield chunk;
173
+ }
174
+ try {
175
+ await writing;
176
+ } catch (cause) {
177
+ throw new require_errors.FormatError("ZIP_INVALID", "Invalid or truncated DEFLATE data.", { cause });
178
+ }
179
+ finished = true;
180
+ } finally {
181
+ if (!finished) {
182
+ reader.cancel().catch(ignore);
183
+ writer.abort().catch(ignore);
184
+ }
185
+ }
186
+ }
187
+ /** The default codec: native CompressionStream / DecompressionStream('deflate-raw'). */
188
+ const nativeCodec = {
189
+ deflateRaw,
190
+ inflateRaw
191
+ };
192
+ // src/internal/zip/crc32.ts
193
+ /**
194
+ * CRC-32 as used by zip (ISO 3309 / ITU-T V.42): reflected polynomial
195
+ * 0xEDB88320, initial value and final XOR 0xFFFFFFFF.
196
+ *
197
+ * Slicing-by-8 tables: 8 KiB, built lazily on first use so importing the
198
+ * module costs nothing. Slicing-by-8 measured 1,150–1,270 MB/s against
199
+ * 850–940 MB/s for slicing-by-4 on Node 24 (JSE-8).
200
+ */
201
+ let tables;
202
+ function buildTables() {
203
+ const t = /* @__PURE__ */ new Uint32Array(2048);
204
+ for (let n = 0; n < 256; n++) {
205
+ let c = n;
206
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
207
+ t[n] = c >>> 0;
208
+ }
209
+ for (let n = 0; n < 256; n++) {
210
+ let c = t[n];
211
+ for (let k = 1; k < 8; k++) {
212
+ c = t[c & 255] ^ c >>> 8;
213
+ t[k * 256 + n] = c >>> 0;
214
+ }
215
+ }
216
+ return t;
217
+ }
218
+ /**
219
+ * Returns the CRC-32 of `data`. Pass the previous result as `crc` to continue
220
+ * over several chunks: `crc32(b, crc32(a))` equals `crc32(a + b)`.
221
+ */
222
+ function crc32(data, crc = 0) {
223
+ const t = tables ??= buildTables();
224
+ let c = ~crc >>> 0;
225
+ const n = data.length;
226
+ let i = 0;
227
+ for (const end = n - n % 8; i < end; i += 8) {
228
+ c ^= data[i] | data[i + 1] << 8 | data[i + 2] << 16 | data[i + 3] << 24;
229
+ const hi = data[i + 4] | data[i + 5] << 8 | data[i + 6] << 16 | data[i + 7] << 24;
230
+ c = t[1792 + (c & 255)] ^ t[1536 + (c >>> 8 & 255)] ^ t[1280 + (c >>> 16 & 255)] ^ t[1024 + (c >>> 24)] ^ t[768 + (hi & 255)] ^ t[512 + (hi >>> 8 & 255)] ^ t[256 + (hi >>> 16 & 255)] ^ t[hi >>> 24];
231
+ }
232
+ for (; i < n; i++) c = t[(c ^ data[i]) & 255] ^ c >>> 8;
233
+ return ~c >>> 0;
234
+ }
235
+ // src/internal/zip/dos-time.ts
236
+ const MIN_MS = Date.UTC(1980, 0, 1);
237
+ const MAX_MS = Date.UTC(2107, 11, 31, 23, 59, 58);
238
+ function toDosDateTime(d) {
239
+ let ms = d.getTime();
240
+ if (!Number.isFinite(ms) || ms < MIN_MS) ms = MIN_MS;
241
+ else if (ms > MAX_MS) ms = MAX_MS;
242
+ const u = new Date(ms);
243
+ return {
244
+ date: u.getUTCFullYear() - 1980 << 9 | u.getUTCMonth() + 1 << 5 | u.getUTCDate(),
245
+ time: u.getUTCHours() << 11 | u.getUTCMinutes() << 5 | u.getUTCSeconds() >> 1
246
+ };
247
+ }
248
+ function fromDosDateTime(date, time) {
249
+ const year = 1980 + (date >>> 9);
250
+ const month = Math.max(1, date >>> 5 & 15) - 1;
251
+ const day = Math.max(1, date & 31);
252
+ return new Date(Date.UTC(year, month, day, time >>> 11, time >>> 5 & 63, (time & 31) * 2));
253
+ }
254
+ // src/dates.ts
255
+ /**
256
+ * Date ↔ serial conversion (docs/api.md §3.4.1, §4.5).
257
+ *
258
+ * 1900 system: serial 1 = 1900-01-01. Excel treats 1900 as a leap year, so
259
+ * serial 60 is the non-existent 1900-02-29: dates before 1900-03-01 use the
260
+ * epoch 1899-12-31, later dates 1899-12-30.
261
+ * 1904 system: serial 0 = 1904-01-01.
262
+ *
263
+ * `dateZone: 'local'` (default) reads and builds dates from their local
264
+ * calendar fields, so `new Date(2024, 0, 15)` is serial 45306 in every zone.
265
+ * `'utc'` uses the UTC fields.
266
+ */
267
+ const DAY_MS = 864e5;
268
+ const EPOCH_1900 = Date.UTC(1899, 11, 30);
269
+ const EPOCH_1900_EARLY = Date.UTC(1899, 11, 31);
270
+ const LEAP_BUG_START = Date.UTC(1900, 2, 1);
271
+ const EPOCH_1904 = Date.UTC(1904, 0, 1);
272
+ /** Excel's day 0 ("1900-01-00", 1899-12-31): time-only values live there, serials 0 to <1. */
273
+ const MIN_1900 = Date.UTC(1899, 11, 31);
274
+ const MAX = Date.UTC(9999, 11, 31, 23, 59, 59, 999);
275
+ /** Wall-clock time of `d` in the chosen zone, as UTC milliseconds. */
276
+ function wallClock(d, zone) {
277
+ if (zone === "utc") return d.getTime();
278
+ const year = d.getFullYear();
279
+ if (year < 1e3) return NaN;
280
+ return Date.UTC(year, d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
281
+ }
282
+ /**
283
+ * Converts a Date to an Excel serial number.
284
+ * Throws `INVALID_DATE` for an invalid Date or one outside the date system's
285
+ * range: 1899-12-31 (Excel's day 0, where time-only values live, as serials
286
+ * 0 to <1; serialToDate returns those) or 1904-01-01, to 9999-12-31.
287
+ */
288
+ function dateToSerial(d, options) {
289
+ const ms = Number.isFinite(d.getTime()) ? wallClock(d, options?.dateZone ?? "local") : NaN;
290
+ const min = options?.date1904 ? EPOCH_1904 : MIN_1900;
291
+ if (!Number.isFinite(ms) || ms < min || ms > MAX) throw new require_errors.ValidationError("INVALID_DATE", `Date ${String(d)} is outside the range Excel can store.`, { details: { value: Number.isFinite(d.getTime()) ? d.toISOString() : "Invalid Date" } });
292
+ if (options?.date1904) return (ms - EPOCH_1904) / DAY_MS;
293
+ return (ms - (ms < LEAP_BUG_START ? EPOCH_1900_EARLY : EPOCH_1900)) / DAY_MS;
294
+ }
295
+ /**
296
+ * Converts an Excel serial number to a Date (inverse of `dateToSerial`).
297
+ * - 1900 system: serials 0 to <1 are Excel's day 0 ("1900-01-00", i.e.
298
+ * 1899-12-31), which is how time-only values such as 0.5 (12:00) are
299
+ * stored. Serial 60 (the fictitious 1900-02-29) has no real date and gives
300
+ * 1900-03-01; callers that must flag it (the reader) check for it themselves.
301
+ * - 1904 system: serial 0 = 1904-01-01.
302
+ * Throws `INVALID_DATE` for negative, non-finite or out-of-range serials.
303
+ */
304
+ function serialToDate(serial, options) {
305
+ const max = options?.date1904 ? (MAX - EPOCH_1904) / DAY_MS : (MAX - EPOCH_1900) / DAY_MS;
306
+ if (!Number.isFinite(serial) || serial < 0 || serial > max) throw new require_errors.ValidationError("INVALID_DATE", `Serial ${serial} is not a valid date.`, { details: { value: serial } });
307
+ let ms;
308
+ if (options?.date1904) ms = EPOCH_1904 + Math.round(serial * DAY_MS);
309
+ else if (serial < 60) ms = EPOCH_1900_EARLY + Math.round(serial * DAY_MS);
310
+ else if (serial < 61) ms = EPOCH_1900 + Math.round((serial + 1) * DAY_MS);
311
+ else ms = EPOCH_1900 + Math.round(serial * DAY_MS);
312
+ if ((options?.dateZone ?? "local") === "utc") return new Date(ms);
313
+ const u = new Date(ms);
314
+ return new Date(u.getUTCFullYear(), u.getUTCMonth(), u.getUTCDate(), u.getUTCHours(), u.getUTCMinutes(), u.getUTCSeconds(), u.getUTCMilliseconds());
315
+ }
316
+ // src/numfmt.ts
317
+ /** The built-in number formats ECMA-376 §18.8.30 defines (§11.2). Ids 14–17 and 22 render in the user's locale in Excel. */
318
+ const BUILTIN_NUM_FMTS = Object.freeze({
319
+ 0: "General",
320
+ 1: "0",
321
+ 2: "0.00",
322
+ 3: "#,##0",
323
+ 4: "#,##0.00",
324
+ 9: "0%",
325
+ 10: "0.00%",
326
+ 11: "0.00E+00",
327
+ 12: "# ?/?",
328
+ 13: "# ??/??",
329
+ 14: "mm-dd-yy",
330
+ 15: "d-mmm-yy",
331
+ 16: "d-mmm",
332
+ 17: "mmm-yy",
333
+ 18: "h:mm AM/PM",
334
+ 19: "h:mm:ss AM/PM",
335
+ 20: "h:mm",
336
+ 21: "h:mm:ss",
337
+ 22: "m/d/yy h:mm",
338
+ 37: "#,##0 ;(#,##0)",
339
+ 38: "#,##0 ;[Red](#,##0)",
340
+ 39: "#,##0.00;(#,##0.00)",
341
+ 40: "#,##0.00;[Red](#,##0.00)",
342
+ 45: "mm:ss",
343
+ 46: "[h]:mm:ss",
344
+ 47: "mmss.0",
345
+ 48: "##0.0E+0",
346
+ 49: "@"
347
+ });
348
+ /** Built-in ids that are dates or times: 14–22, 45 and 47, and the East Asian locale ids 27–36 and 50–58. 46 is `[h]:mm:ss`, a duration. */
349
+ const DATE_IDS = /* @__PURE__ */ new Set([
350
+ 14,
351
+ 15,
352
+ 16,
353
+ 17,
354
+ 18,
355
+ 19,
356
+ 20,
357
+ 21,
358
+ 22,
359
+ 27,
360
+ 28,
361
+ 29,
362
+ 30,
363
+ 31,
364
+ 32,
365
+ 33,
366
+ 34,
367
+ 35,
368
+ 36,
369
+ 45,
370
+ 47,
371
+ 50,
372
+ 51,
373
+ 52,
374
+ 53,
375
+ 54,
376
+ 55,
377
+ 56,
378
+ 57,
379
+ 58
380
+ ]);
381
+ const cache = /* @__PURE__ */ new Map();
382
+ /**
383
+ * True when a number format shows a date or a time of day (§3.4.1): built-in
384
+ * ids 14–22, 45, 47, 27–36 and 50–58, or a custom code that contains a date or
385
+ * time token outside quoted text, escapes and brackets. Elapsed-time formats
386
+ * (`[h]:mm:ss`, built-in 46) are durations and return false.
387
+ */
388
+ function isDateFormat(fmt) {
389
+ if (fmt === void 0) return false;
390
+ if (typeof fmt === "number") return DATE_IDS.has(fmt);
391
+ let hit = cache.get(fmt);
392
+ if (hit === void 0) {
393
+ hit = detect(fmt);
394
+ if (cache.size < 1e3) cache.set(fmt, hit);
395
+ }
396
+ return hit;
397
+ }
398
+ function detect(code) {
399
+ let s = "";
400
+ let inQuote = false;
401
+ for (let i = 0; i < code.length; i++) {
402
+ const ch = code[i];
403
+ if (inQuote) {
404
+ if (ch === "\"") inQuote = false;
405
+ continue;
406
+ }
407
+ if (ch === "\"") {
408
+ inQuote = true;
409
+ continue;
410
+ }
411
+ if (ch === "\\" || ch === "_" || ch === "*") {
412
+ i++;
413
+ continue;
414
+ }
415
+ if (ch === ";") break;
416
+ if (ch === "[") {
417
+ const end = code.indexOf("]", i + 1);
418
+ if (end === -1) break;
419
+ const inner = code.slice(i + 1, end).toLowerCase();
420
+ if (/^(h+|m+|s+)$/.test(inner)) return false;
421
+ i = end;
422
+ continue;
423
+ }
424
+ s += ch;
425
+ }
426
+ s = s.replace(/general/gi, "").replace(/e[+-]/gi, "");
427
+ return /[ymdhs]|am\/pm|a\/p|[egb]/i.test(s);
428
+ }
429
+ Object.defineProperty(exports, "BUILTIN_NUM_FMTS", {
430
+ enumerable: true,
431
+ get: function() {
432
+ return BUILTIN_NUM_FMTS;
433
+ }
434
+ });
435
+ Object.defineProperty(exports, "ByteWriter", {
436
+ enumerable: true,
437
+ get: function() {
438
+ return ByteWriter;
439
+ }
440
+ });
441
+ Object.defineProperty(exports, "concatBytes", {
442
+ enumerable: true,
443
+ get: function() {
444
+ return concatBytes;
445
+ }
446
+ });
447
+ Object.defineProperty(exports, "crc32", {
448
+ enumerable: true,
449
+ get: function() {
450
+ return crc32;
451
+ }
452
+ });
453
+ Object.defineProperty(exports, "dateToSerial", {
454
+ enumerable: true,
455
+ get: function() {
456
+ return dateToSerial;
457
+ }
458
+ });
459
+ Object.defineProperty(exports, "decodeUtf8Strict", {
460
+ enumerable: true,
461
+ get: function() {
462
+ return decodeUtf8Strict;
463
+ }
464
+ });
465
+ Object.defineProperty(exports, "encodeUtf8", {
466
+ enumerable: true,
467
+ get: function() {
468
+ return encodeUtf8;
469
+ }
470
+ });
471
+ Object.defineProperty(exports, "fromDosDateTime", {
472
+ enumerable: true,
473
+ get: function() {
474
+ return fromDosDateTime;
475
+ }
476
+ });
477
+ Object.defineProperty(exports, "isDateFormat", {
478
+ enumerable: true,
479
+ get: function() {
480
+ return isDateFormat;
481
+ }
482
+ });
483
+ Object.defineProperty(exports, "nativeCodec", {
484
+ enumerable: true,
485
+ get: function() {
486
+ return nativeCodec;
487
+ }
488
+ });
489
+ Object.defineProperty(exports, "serialToDate", {
490
+ enumerable: true,
491
+ get: function() {
492
+ return serialToDate;
493
+ }
494
+ });
495
+ Object.defineProperty(exports, "throttleProgress", {
496
+ enumerable: true,
497
+ get: function() {
498
+ return throttleProgress;
499
+ }
500
+ });
501
+ Object.defineProperty(exports, "throwIfAborted", {
502
+ enumerable: true,
503
+ get: function() {
504
+ return throwIfAborted;
505
+ }
506
+ });
507
+ Object.defineProperty(exports, "toDosDateTime", {
508
+ enumerable: true,
509
+ get: function() {
510
+ return toDosDateTime;
511
+ }
512
+ });
@@ -0,0 +1,78 @@
1
+ import { I as Workbook, r as BinaryInput, t as ExcelWarning, u as Cell } from "./warnings-C_12PT4t.cjs";
2
+ import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
3
+ import { t as Progress } from "./write-C5JgeIar.cjs";
4
+ /**
5
+ * Format detection tables for the reader (docs/api.md §5.2). Internal.
6
+ *
7
+ * Detection is data: container signatures first, then, for OPC packages, the
8
+ * workbook part's content type. Supporting another format later (.xlsb, .xls)
9
+ * is one more row plus a decoder; the reader dispatches on `decoder`.
10
+ */
11
+ /** Every format `detectFormat` can name. */
12
+ type FormatName = "xlsx" | "xlsm" | "xltx" | "xltm" | "xlsb" | "ods" | "cfb" | "zip" | "unknown";
13
+ /** Result of `read`. */
14
+ interface ReadResult {
15
+ workbook: Workbook<Cell>;
16
+ warnings: ExcelWarning[];
17
+ }
18
+ /** Options for `read`. */
19
+ interface ReadOptions {
20
+ /** Only parse these sheets (by name or index); the others are listed with empty rows. Default: all. */
21
+ sheets?: Array<string | number> | undefined;
22
+ /** Parse styles (default true). false is faster: no `cell.style`, but date detection still uses the number format. */
23
+ styles?: boolean | undefined;
24
+ /** Return formula text (default true). false: cached values only. */
25
+ formulas?: boolean | undefined;
26
+ /** `'date'` (default): date-formatted numbers become `Date`. `'serial'`: leave them as numbers. */
27
+ dates?: "date" | "serial" | undefined;
28
+ /** Default `'local'`. */
29
+ dateZone?: "local" | "utc" | undefined;
30
+ /** Rich text as runs (default) or flattened to a plain string. */
31
+ richText?: "runs" | "plain" | undefined;
32
+ limits?: Partial<ReadLimits> | undefined;
33
+ /** Rejects with `signal.reason` when aborted. */
34
+ signal?: AbortSignalLike | undefined;
35
+ onProgress?: ((p: Progress) => void) | undefined;
36
+ /** Called as warnings occur, in addition to `ReadResult.warnings`. */
37
+ onWarning?: ((w: ExcelWarning) => void) | undefined;
38
+ }
39
+ /** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
40
+ interface ReadLimits {
41
+ maxInputBytes: number;
42
+ maxEntries: number;
43
+ /** Decompressed bytes of one part. */
44
+ maxEntryBytes: number;
45
+ /** Decompressed bytes of all parts read. */
46
+ maxTotalBytes: number;
47
+ /** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
48
+ maxRatio: number;
49
+ maxXmlDepth: number;
50
+ /** All sheets together. */
51
+ maxCells: number;
52
+ maxSharedStrings: number;
53
+ /** Then a single `WARNINGS_TRUNCATED`. */
54
+ maxWarnings: number;
55
+ }
56
+ /** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
57
+ declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
58
+ /** A sheet as listed by `readSheetNames`. */
59
+ interface SheetInfo {
60
+ name: string;
61
+ index: number;
62
+ state: "visible" | "hidden" | "veryHidden";
63
+ }
64
+ /**
65
+ * What `detectFormat` recognises. `'cfb'` is a legacy `.xls` or an encrypted OOXML file.
66
+ * `read` reads xlsx, xlsm, xltx and xltm; the others are rejected with UNSUPPORTED_FORMAT.
67
+ */
68
+ type DetectedFormat = FormatName;
69
+ /** Detects the file format from the bytes. Never throws for unreadable input; returns `'unknown'` or `'zip'` instead. */
70
+ declare function detectFormat(input: BinaryInput): Promise<DetectedFormat>;
71
+ /** Lists the worksheets (name, index, visibility) without parsing any sheet. */
72
+ declare function readSheetNames(input: BinaryInput, options?: {
73
+ limits?: Partial<ReadLimits> | undefined;
74
+ signal?: AbortSignalLike | undefined;
75
+ }): Promise<SheetInfo[]>;
76
+ /** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
77
+ declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
78
+ export { ReadResult as a, read as c, ReadOptions as i, readSheetNames as l, DetectedFormat as n, SheetInfo as o, ReadLimits as r, detectFormat as s, DEFAULT_READ_LIMITS as t };