javascript-excel 2.0.0-alpha.2 → 2.0.0-alpha.3

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 (65) hide show
  1. package/README.md +151 -21
  2. package/dist/address-DUn7-5OS.js +75 -0
  3. package/dist/address-DZBHchLv.cjs +122 -0
  4. package/dist/{auto-width-2oBzjeNG.d.cts → auto-width-DRHsPKNk.d.cts} +1 -1
  5. package/dist/cells-CPXU722t.cjs +33 -0
  6. package/dist/cells-CrMF8h_t.js +28 -0
  7. package/dist/colors-B8Nf_xTx.js +114 -0
  8. package/dist/colors-oBpjx97l.cjs +119 -0
  9. package/dist/csv.d.cts +4 -1
  10. package/dist/csv.d.ts +4 -1
  11. package/dist/dataset-KeMzHCGl.js +664 -0
  12. package/dist/dataset-UUZCzsi3.cjs +687 -0
  13. package/dist/dates-BXcSWf9_.js +64 -0
  14. package/dist/dates-CA1dCizp.cjs +75 -0
  15. package/dist/dom.cjs +5 -2
  16. package/dist/dom.d.cts +5 -2
  17. package/dist/dom.d.ts +4 -1
  18. package/dist/dom.js +4 -1
  19. package/dist/{numfmt-Dv6AjopS.cjs → dos-time-FZ7-1tot.cjs} +0 -199
  20. package/dist/{numfmt-BBgB7iQA.js → dos-time-dD0z1YWU.js} +2 -177
  21. package/dist/format.cjs +1264 -0
  22. package/dist/format.d.cts +59 -0
  23. package/dist/format.d.ts +59 -0
  24. package/dist/format.js +1262 -0
  25. package/dist/import.cjs +10 -0
  26. package/dist/import.d.cts +10 -0
  27. package/dist/import.d.ts +10 -0
  28. package/dist/import.js +1 -0
  29. package/dist/index.cjs +24 -607
  30. package/dist/index.d.cts +32 -6
  31. package/dist/index.d.ts +31 -5
  32. package/dist/index.js +10 -594
  33. package/dist/{warnings-C_12PT4t.d.cts → model-0JikLfuM.d.cts} +1 -41
  34. package/dist/{warnings-DXJKe1lx.d.ts → model-0JikLfuM.d.ts} +1 -41
  35. package/dist/numfmt-BmEbm78Y.cjs +125 -0
  36. package/dist/numfmt-DCDrX9P1.js +114 -0
  37. package/dist/pipeline-BAJtzBdW.js +1085 -0
  38. package/dist/pipeline-Bnf7EU3X.cjs +1132 -0
  39. package/dist/pipeline-CctEa86r.d.cts +186 -0
  40. package/dist/pipeline-I8SLmV9S.d.ts +186 -0
  41. package/dist/{read-Ym1voUct.cjs → read-CZEWV4rK.cjs} +181 -17
  42. package/dist/{read-DDN5ZsPe.js → read-LWti17lz.js} +169 -5
  43. package/dist/read.cjs +1 -1
  44. package/dist/read.d.cts +78 -4
  45. package/dist/read.d.ts +78 -4
  46. package/dist/read.js +1 -1
  47. package/dist/render.cjs +751 -0
  48. package/dist/render.d.cts +215 -0
  49. package/dist/render.d.ts +215 -0
  50. package/dist/render.js +732 -0
  51. package/dist/{sheet-names-uT2EH5Ui.js → sheet-names-7p-joVsG.js} +2 -101
  52. package/dist/{sheet-names-qpXsvMpM.cjs → sheet-names-B8U5RAW0.cjs} +14 -167
  53. package/dist/warnings-B1v58nCZ.d.cts +41 -0
  54. package/dist/warnings-B1v58nCZ.d.ts +41 -0
  55. package/dist/worker.cjs +10 -2
  56. package/dist/worker.d.cts +10 -4
  57. package/dist/worker.d.ts +10 -4
  58. package/dist/worker.js +10 -2
  59. package/dist/{write-CYpLGuzl.d.ts → write-DM6ieuQY.d.ts} +2 -1
  60. package/dist/{write-DubvcG-x.js → write-DjgWy1PK.js} +5 -2
  61. package/dist/{write-C5JgeIar.d.cts → write-DtjfdIFm.d.cts} +2 -1
  62. package/dist/{write-BOh9jfu1.cjs → write-f9kcYf5K.cjs} +31 -28
  63. package/package.json +32 -1
  64. package/dist/read-C6L7Nyy3.d.cts +0 -78
  65. package/dist/read-Ddkks7qC.d.ts +0 -78
@@ -1,5 +1,5 @@
1
1
  import { o as ValidationError } from "./errors-CvGlfw0E.js";
2
- import { t as isoDate } from "./iso-date-CXnn-9mT.js";
2
+ import { a as decodeRange, i as decodeCol, n as MAX_ROWS, o as encodeCell, r as decodeCell, s as encodeCol, t as MAX_COLS } from "./address-DUn7-5OS.js";
3
3
  // src/internal/xml.ts
4
4
  /**
5
5
  * XML text helpers for the writer.
@@ -62,79 +62,6 @@ const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
62
62
  function num(n) {
63
63
  return Object.is(n, -0) ? "0" : String(n);
64
64
  }
65
- // src/address.ts
66
- /**
67
- * A1 address helpers (docs/api.md §4.1). Indices are zero-based.
68
- */
69
- /** Rows per sheet in the xlsx format. */
70
- const MAX_ROWS = 1048576;
71
- /** Columns per sheet in the xlsx format (A..XFD). */
72
- const MAX_COLS = 16384;
73
- function invalidRef(ref, why) {
74
- return new ValidationError("INVALID_REF", `Invalid reference ${JSON.stringify(ref)}: ${why}.`, { details: { ref } });
75
- }
76
- function checkIndex(n, max, what) {
77
- if (!Number.isInteger(n) || n < 0 || n >= max) throw new ValidationError("OUT_OF_BOUNDS", `${what} index ${n} is outside 0..${max - 1}.`, { details: {
78
- index: n,
79
- max: max - 1
80
- } });
81
- }
82
- /** Column index to letters: 0 → 'A', 16383 → 'XFD'. */
83
- function encodeCol(col) {
84
- checkIndex(col, MAX_COLS, "Column");
85
- let s = "";
86
- for (let n = col + 1; n > 0; n = Math.floor((n - 1) / 26)) s = String.fromCharCode(65 + (n - 1) % 26) + s;
87
- return s;
88
- }
89
- /** Column letters to index: 'A' → 0, 'XFD' → 16383. Case-insensitive. */
90
- function decodeCol(letters) {
91
- if (typeof letters !== "string" || !/^[A-Za-z]{1,3}$/.test(letters)) throw invalidRef(letters, "expected column letters");
92
- let n = 0;
93
- for (const ch of letters.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
94
- if (n > 16384) throw invalidRef(letters, "beyond column XFD");
95
- return n - 1;
96
- }
97
- /** { row: 0, col: 1 } → 'B1'. */
98
- function encodeCell(a) {
99
- checkIndex(a.row, MAX_ROWS, "Row");
100
- return encodeCol(a.col) + String(a.row + 1);
101
- }
102
- const CELL_RE = /^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/;
103
- /** 'B1' or '$B$1' → { row: 0, col: 1 }. */
104
- function decodeCell(ref) {
105
- const m = typeof ref === "string" ? CELL_RE.exec(ref) : null;
106
- if (!m) throw invalidRef(ref, "expected an A1 cell reference");
107
- const row = Number(m[2]) - 1;
108
- if (row >= 1048576) throw invalidRef(ref, "beyond row 1048576");
109
- return {
110
- row,
111
- col: decodeCol(m[1])
112
- };
113
- }
114
- /** Range to 'A1:C3' (a single cell gives 'A1'). */
115
- function encodeRange(r) {
116
- const a = encodeCell(r.start);
117
- const b = encodeCell(r.end);
118
- return a === b ? a : `${a}:${b}`;
119
- }
120
- /** 'A1:C3' or 'A1' → range, normalised so start is top-left. */
121
- function decodeRange(ref) {
122
- if (typeof ref !== "string") throw invalidRef(ref, "expected an A1 range");
123
- const parts = ref.split(":");
124
- if (parts.length > 2) throw invalidRef(ref, "expected an A1 range");
125
- const a = decodeCell(parts[0]);
126
- const b = parts.length === 2 ? decodeCell(parts[1]) : a;
127
- return {
128
- start: {
129
- row: Math.min(a.row, b.row),
130
- col: Math.min(a.col, b.col)
131
- },
132
- end: {
133
- row: Math.max(a.row, b.row),
134
- col: Math.max(a.col, b.col)
135
- }
136
- };
137
- }
138
65
  // src/styles.ts
139
66
  /** Copies `b`'s defined fields over a copy of `a`. */
140
67
  function mergeFields(a, b) {
@@ -181,32 +108,6 @@ function mergeStyles(...styles) {
181
108
  }
182
109
  return out;
183
110
  }
184
- // src/cells.ts
185
- /**
186
- * Cell helpers (docs/api.md §4.2).
187
- */
188
- function valueText(v, zone) {
189
- if (v === null || v === void 0) return "";
190
- if (typeof v === "string") return v;
191
- if (typeof v === "number") return String(v);
192
- if (typeof v === "boolean") return v ? "TRUE" : "FALSE";
193
- if (v instanceof Date) return Number.isFinite(v.getTime()) ? isoDate(v, zone) : "";
194
- if (typeof v === "object" && "error" in v) return String(v.error);
195
- if (typeof v === "object" && "richText" in v && Array.isArray(v.richText)) return v.richText.map((r) => r.text).join("");
196
- return "";
197
- }
198
- /**
199
- * Plain text of a cell: strings as they are, numbers as `String(n)`, booleans
200
- * as TRUE/FALSE, dates as ISO 8601, errors as their code, rich text joined.
201
- * A formula cell gives its cached value's text ('' when there is none).
202
- * Number formats are not applied.
203
- */
204
- function cellText(cell, options) {
205
- const zone = options?.dateZone ?? "local";
206
- if (cell === null || cell === void 0) return "";
207
- if (typeof cell !== "object" || cell instanceof Date || "error" in cell || "richText" in cell) return valueText(cell, zone);
208
- return valueText(cell.value, zone);
209
- }
210
111
  // src/internal/write/package.ts
211
112
  /**
212
113
  * The OPC package: which parts exist, their content types and the
@@ -829,4 +730,4 @@ function sanitizeSheetName(name) {
829
730
  }
830
731
  return s.length === 0 || s.toLowerCase() === "history" ? "Sheet" : s;
831
732
  }
832
- export { encodeRange as C, xmlAttr as D, num as E, xmlText as O, encodeCol as S, needsPreserve as T, MAX_ROWS as _, SheetFeatures as a, decodeRange as b, hyperlinkSchemes as c, PackageParts as d, REL_TYPE as f, MAX_COLS as g, mergeStyles as h, DEFAULT_HYPERLINK_SCHEMES as i, xstring as k, textWidth as l, cellText as m, validateSheetName as n, SheetLinks as o, Rels as p, AUTO_WIDTH as r, hyperlinkOf as s, sanitizeSheetName as t, CONTENT_TYPE as u, decodeCell as v, XML_DECL as w, encodeCell as x, decodeCol as y };
733
+ export { num as _, SheetFeatures as a, xstring as b, hyperlinkSchemes as c, PackageParts as d, REL_TYPE as f, needsPreserve as g, XML_DECL as h, DEFAULT_HYPERLINK_SCHEMES as i, textWidth as l, mergeStyles as m, validateSheetName as n, SheetLinks as o, Rels as p, AUTO_WIDTH as r, hyperlinkOf as s, sanitizeSheetName as t, CONTENT_TYPE as u, xmlAttr as v, xmlText as y };
@@ -1,5 +1,5 @@
1
1
  const require_errors = require("./errors-DOPrrGS4.cjs");
2
- const require_iso_date = require("./iso-date-3TY1OlGd.cjs");
2
+ const require_address = require("./address-DZBHchLv.cjs");
3
3
  // src/internal/xml.ts
4
4
  /**
5
5
  * XML text helpers for the writer.
@@ -62,79 +62,6 @@ const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
62
62
  function num(n) {
63
63
  return Object.is(n, -0) ? "0" : String(n);
64
64
  }
65
- // src/address.ts
66
- /**
67
- * A1 address helpers (docs/api.md §4.1). Indices are zero-based.
68
- */
69
- /** Rows per sheet in the xlsx format. */
70
- const MAX_ROWS = 1048576;
71
- /** Columns per sheet in the xlsx format (A..XFD). */
72
- const MAX_COLS = 16384;
73
- function invalidRef(ref, why) {
74
- return new require_errors.ValidationError("INVALID_REF", `Invalid reference ${JSON.stringify(ref)}: ${why}.`, { details: { ref } });
75
- }
76
- function checkIndex(n, max, what) {
77
- if (!Number.isInteger(n) || n < 0 || n >= max) throw new require_errors.ValidationError("OUT_OF_BOUNDS", `${what} index ${n} is outside 0..${max - 1}.`, { details: {
78
- index: n,
79
- max: max - 1
80
- } });
81
- }
82
- /** Column index to letters: 0 → 'A', 16383 → 'XFD'. */
83
- function encodeCol(col) {
84
- checkIndex(col, MAX_COLS, "Column");
85
- let s = "";
86
- for (let n = col + 1; n > 0; n = Math.floor((n - 1) / 26)) s = String.fromCharCode(65 + (n - 1) % 26) + s;
87
- return s;
88
- }
89
- /** Column letters to index: 'A' → 0, 'XFD' → 16383. Case-insensitive. */
90
- function decodeCol(letters) {
91
- if (typeof letters !== "string" || !/^[A-Za-z]{1,3}$/.test(letters)) throw invalidRef(letters, "expected column letters");
92
- let n = 0;
93
- for (const ch of letters.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
94
- if (n > 16384) throw invalidRef(letters, "beyond column XFD");
95
- return n - 1;
96
- }
97
- /** { row: 0, col: 1 } → 'B1'. */
98
- function encodeCell(a) {
99
- checkIndex(a.row, MAX_ROWS, "Row");
100
- return encodeCol(a.col) + String(a.row + 1);
101
- }
102
- const CELL_RE = /^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/;
103
- /** 'B1' or '$B$1' → { row: 0, col: 1 }. */
104
- function decodeCell(ref) {
105
- const m = typeof ref === "string" ? CELL_RE.exec(ref) : null;
106
- if (!m) throw invalidRef(ref, "expected an A1 cell reference");
107
- const row = Number(m[2]) - 1;
108
- if (row >= 1048576) throw invalidRef(ref, "beyond row 1048576");
109
- return {
110
- row,
111
- col: decodeCol(m[1])
112
- };
113
- }
114
- /** Range to 'A1:C3' (a single cell gives 'A1'). */
115
- function encodeRange(r) {
116
- const a = encodeCell(r.start);
117
- const b = encodeCell(r.end);
118
- return a === b ? a : `${a}:${b}`;
119
- }
120
- /** 'A1:C3' or 'A1' → range, normalised so start is top-left. */
121
- function decodeRange(ref) {
122
- if (typeof ref !== "string") throw invalidRef(ref, "expected an A1 range");
123
- const parts = ref.split(":");
124
- if (parts.length > 2) throw invalidRef(ref, "expected an A1 range");
125
- const a = decodeCell(parts[0]);
126
- const b = parts.length === 2 ? decodeCell(parts[1]) : a;
127
- return {
128
- start: {
129
- row: Math.min(a.row, b.row),
130
- col: Math.min(a.col, b.col)
131
- },
132
- end: {
133
- row: Math.max(a.row, b.row),
134
- col: Math.max(a.col, b.col)
135
- }
136
- };
137
- }
138
65
  // src/styles.ts
139
66
  /** Copies `b`'s defined fields over a copy of `a`. */
140
67
  function mergeFields(a, b) {
@@ -181,32 +108,6 @@ function mergeStyles(...styles) {
181
108
  }
182
109
  return out;
183
110
  }
184
- // src/cells.ts
185
- /**
186
- * Cell helpers (docs/api.md §4.2).
187
- */
188
- function valueText(v, zone) {
189
- if (v === null || v === void 0) return "";
190
- if (typeof v === "string") return v;
191
- if (typeof v === "number") return String(v);
192
- if (typeof v === "boolean") return v ? "TRUE" : "FALSE";
193
- if (v instanceof Date) return Number.isFinite(v.getTime()) ? require_iso_date.isoDate(v, zone) : "";
194
- if (typeof v === "object" && "error" in v) return String(v.error);
195
- if (typeof v === "object" && "richText" in v && Array.isArray(v.richText)) return v.richText.map((r) => r.text).join("");
196
- return "";
197
- }
198
- /**
199
- * Plain text of a cell: strings as they are, numbers as `String(n)`, booleans
200
- * as TRUE/FALSE, dates as ISO 8601, errors as their code, rich text joined.
201
- * A formula cell gives its cached value's text ('' when there is none).
202
- * Number formats are not applied.
203
- */
204
- function cellText(cell, options) {
205
- const zone = options?.dateZone ?? "local";
206
- if (cell === null || cell === void 0) return "";
207
- if (typeof cell !== "object" || cell instanceof Date || "error" in cell || "richText" in cell) return valueText(cell, zone);
208
- return valueText(cell.value, zone);
209
- }
210
111
  // src/internal/write/package.ts
211
112
  /**
212
113
  * The OPC package: which parts exist, their content types and the
@@ -342,26 +243,26 @@ function checkBool(sheet, path, v) {
342
243
  }
343
244
  function checkRange(sheet, path, v) {
344
245
  try {
345
- return decodeRange(v);
246
+ return require_address.decodeRange(v);
346
247
  } catch {
347
248
  throw sheetError(sheet, path, v, "must be an A1 range such as 'A1:C3'", "INVALID_REF");
348
249
  }
349
250
  }
350
251
  function checkCellRef(sheet, path, v) {
351
252
  try {
352
- return encodeCell(decodeCell(v));
253
+ return require_address.encodeCell(require_address.decodeCell(v));
353
254
  } catch {
354
255
  throw sheetError(sheet, path, v, "must be an A1 cell reference", "INVALID_REF");
355
256
  }
356
257
  }
357
258
  const absRange = (r) => {
358
- const a = `$${encodeCol(r.start.col)}$${r.start.row + 1}`;
359
- const b = `$${encodeCol(r.end.col)}$${r.end.row + 1}`;
259
+ const a = `$${require_address.encodeCol(r.start.col)}$${r.start.row + 1}`;
260
+ const b = `$${require_address.encodeCol(r.end.col)}$${r.end.row + 1}`;
360
261
  return a === b ? a : `${a}:${b}`;
361
262
  };
362
263
  const plainRange = (r) => {
363
- const a = encodeCell(r.start);
364
- const b = encodeCell(r.end);
264
+ const a = require_address.encodeCell(r.start);
265
+ const b = require_address.encodeCell(r.end);
365
266
  return a === b ? a : `${a}:${b}`;
366
267
  };
367
268
  /** A sheet name as it appears in a formula reference: always quoted, quotes doubled. */
@@ -398,7 +299,7 @@ var SheetFeatures = class {
398
299
  const colProps = sheet.colProps;
399
300
  if (colProps !== void 0) {
400
301
  if (!Array.isArray(colProps)) throw sheetError(name, "colProps", colProps, "must be an array");
401
- if (colProps.length > 16384) throw sheetError(name, "colProps", colProps.length, `has more than ${MAX_COLS} entries`, "OUT_OF_BOUNDS");
302
+ if (colProps.length > 16384) throw sheetError(name, "colProps", colProps.length, `has more than ${require_address.MAX_COLS} entries`, "OUT_OF_BOUNDS");
402
303
  for (let c = 0; c < colProps.length; c++) {
403
304
  const p = colProps[c];
404
305
  if (p === void 0 || p === null) continue;
@@ -411,7 +312,7 @@ var SheetFeatures = class {
411
312
  this.maxOutlineCol = Math.max(this.maxOutlineCol, outlineLevel);
412
313
  const style = p.style ? styles.xfFor([sheet.defaultStyle, p.style], false, {
413
314
  sheet: name,
414
- ref: `${encodeCol(c)}:${encodeCol(c)}`
315
+ ref: `${require_address.encodeCol(c)}:${require_address.encodeCol(c)}`
415
316
  }) : this.defaultColStyle;
416
317
  this.cols.push({
417
318
  col: c,
@@ -432,7 +333,7 @@ var SheetFeatures = class {
432
333
  const p = rowProps[r];
433
334
  if (p === void 0 || p === null) continue;
434
335
  const path = `rowProps[${r}]`;
435
- if (r >= 1048576) throw sheetError(name, path, r, `is beyond row ${MAX_ROWS}`, "OUT_OF_BOUNDS");
336
+ if (r >= 1048576) throw sheetError(name, path, r, `is beyond row ${require_address.MAX_ROWS}`, "OUT_OF_BOUNDS");
436
337
  if (typeof p !== "object") throw sheetError(name, path, p, "must be an object");
437
338
  let attrs = "";
438
339
  if (p.style) attrs += ` s="${styles.xfFor([sheet.defaultStyle, p.style], false, {
@@ -534,7 +435,7 @@ var SheetFeatures = class {
534
435
  const cols = checkNumber(name, "view.freeze.cols", view.freeze?.cols, 0, 16383, true) ?? 0;
535
436
  if (view.freeze !== void 0 && (typeof view.freeze !== "object" || view.freeze === null)) throw sheetError(name, "view.freeze", view.freeze, "must be { rows?, cols? }");
536
437
  if (rows > 0 || cols > 0) {
537
- const topLeft = encodeCell({
438
+ const topLeft = require_address.encodeCell({
538
439
  row: rows,
539
440
  col: cols
540
441
  });
@@ -627,8 +528,8 @@ var SheetFeatures = class {
627
528
  if (t.cols !== void 0) {
628
529
  const m2 = typeof t.cols === "string" ? /^\$?([A-Za-z]{1,3}):\$?([A-Za-z]{1,3})$/.exec(t.cols) : null;
629
530
  if (!m2) throw sheetError(name, "print.printTitles.cols", t.cols, "must be a column range such as 'A:B'", "INVALID_REF");
630
- const [a, b] = [decodeCol(m2[1]), decodeCol(m2[2])].sort((x, y) => x - y);
631
- refs.push(`${quoteSheet(name)}!$${encodeCol(a)}:$${encodeCol(b)}`);
531
+ const [a, b] = [require_address.decodeCol(m2[1]), require_address.decodeCol(m2[2])].sort((x, y) => x - y);
532
+ refs.push(`${quoteSheet(name)}!$${require_address.encodeCol(a)}:$${require_address.encodeCol(b)}`);
632
533
  }
633
534
  if (t.rows !== void 0) {
634
535
  const m2 = typeof t.rows === "string" ? /^\$?([1-9]\d{0,6}):\$?([1-9]\d{0,6})$/.exec(t.rows) : null;
@@ -707,7 +608,7 @@ var SheetFeatures = class {
707
608
  });
708
609
  next = col + 1;
709
610
  }
710
- fillDefault(MAX_COLS);
611
+ fillDefault(require_address.MAX_COLS);
711
612
  if (specs.length === 0) return "";
712
613
  const merged = [];
713
614
  for (const s of specs) {
@@ -847,18 +748,6 @@ Object.defineProperty(exports, "DEFAULT_HYPERLINK_SCHEMES", {
847
748
  return DEFAULT_HYPERLINK_SCHEMES;
848
749
  }
849
750
  });
850
- Object.defineProperty(exports, "MAX_COLS", {
851
- enumerable: true,
852
- get: function() {
853
- return MAX_COLS;
854
- }
855
- });
856
- Object.defineProperty(exports, "MAX_ROWS", {
857
- enumerable: true,
858
- get: function() {
859
- return MAX_ROWS;
860
- }
861
- });
862
751
  Object.defineProperty(exports, "PackageParts", {
863
752
  enumerable: true,
864
753
  get: function() {
@@ -895,48 +784,6 @@ Object.defineProperty(exports, "XML_DECL", {
895
784
  return XML_DECL;
896
785
  }
897
786
  });
898
- Object.defineProperty(exports, "cellText", {
899
- enumerable: true,
900
- get: function() {
901
- return cellText;
902
- }
903
- });
904
- Object.defineProperty(exports, "decodeCell", {
905
- enumerable: true,
906
- get: function() {
907
- return decodeCell;
908
- }
909
- });
910
- Object.defineProperty(exports, "decodeCol", {
911
- enumerable: true,
912
- get: function() {
913
- return decodeCol;
914
- }
915
- });
916
- Object.defineProperty(exports, "decodeRange", {
917
- enumerable: true,
918
- get: function() {
919
- return decodeRange;
920
- }
921
- });
922
- Object.defineProperty(exports, "encodeCell", {
923
- enumerable: true,
924
- get: function() {
925
- return encodeCell;
926
- }
927
- });
928
- Object.defineProperty(exports, "encodeCol", {
929
- enumerable: true,
930
- get: function() {
931
- return encodeCol;
932
- }
933
- });
934
- Object.defineProperty(exports, "encodeRange", {
935
- enumerable: true,
936
- get: function() {
937
- return encodeRange;
938
- }
939
- });
940
787
  Object.defineProperty(exports, "hyperlinkOf", {
941
788
  enumerable: true,
942
789
  get: function() {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Binary input and Blob types shared by the reader and the CSV entry.
3
+ *
4
+ * The package compiles without DOM types, so `Blob` cannot be named directly
5
+ * in a published signature. `BlobType` resolves to the platform's own `Blob`
6
+ * whenever the consumer's TypeScript setup declares one (lib "dom", or
7
+ * @types/node), and to the structural `BlobLike` otherwise.
8
+ */
9
+ /** The members of `Blob` the library uses. */
10
+ interface BlobLike {
11
+ readonly size: number;
12
+ readonly type: string;
13
+ arrayBuffer(): Promise<ArrayBuffer>;
14
+ }
15
+ /** The platform `Blob` type when the consumer has one, else `BlobLike`. */
16
+ type BlobType = typeof globalThis extends {
17
+ Blob: {
18
+ prototype: infer B;
19
+ };
20
+ } ? B : BlobLike;
21
+ /** Bytes the library can read. A Node `Buffer` is a `Uint8Array`. */
22
+ type BinaryInput = Uint8Array | ArrayBuffer | BlobType;
23
+ /**
24
+ * Warnings (docs/api.md §7.3).
25
+ *
26
+ * The reader and the CSV parser collect warnings for damage they can recover
27
+ * from, instead of throwing. Each warning is plain data.
28
+ */
29
+ /** Every warning code the library reports. */
30
+ type ExcelWarningCode = "UNSUPPORTED_PART" | "INVALID_STYLE_INDEX" | "INVALID_SHARED_STRING" | "CELL_OUT_OF_BOUNDS" | "INVALID_CELL_REF" | "DUPLICATE_CELL" | "INVALID_DATE_SERIAL" | "SHARED_FORMULA_UNRESOLVED" | "MISSING_PART" | "BROKEN_OPTIONAL_PART" | "HYPERLINK_RANGE_REDUCED" | "SPLIT_PANE_IGNORED" | "ROWS_TRUNCATED" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
31
+ /** A recoverable problem found while reading or building. */
32
+ interface ExcelWarning {
33
+ code: ExcelWarningCode;
34
+ message: string;
35
+ /** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
36
+ part?: string | undefined;
37
+ sheet?: string | undefined;
38
+ /** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
39
+ ref?: string | undefined;
40
+ }
41
+ export { BlobType as a, BlobLike as i, ExcelWarningCode as n, BinaryInput as r, ExcelWarning as t };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Binary input and Blob types shared by the reader and the CSV entry.
3
+ *
4
+ * The package compiles without DOM types, so `Blob` cannot be named directly
5
+ * in a published signature. `BlobType` resolves to the platform's own `Blob`
6
+ * whenever the consumer's TypeScript setup declares one (lib "dom", or
7
+ * @types/node), and to the structural `BlobLike` otherwise.
8
+ */
9
+ /** The members of `Blob` the library uses. */
10
+ interface BlobLike {
11
+ readonly size: number;
12
+ readonly type: string;
13
+ arrayBuffer(): Promise<ArrayBuffer>;
14
+ }
15
+ /** The platform `Blob` type when the consumer has one, else `BlobLike`. */
16
+ type BlobType = typeof globalThis extends {
17
+ Blob: {
18
+ prototype: infer B;
19
+ };
20
+ } ? B : BlobLike;
21
+ /** Bytes the library can read. A Node `Buffer` is a `Uint8Array`. */
22
+ type BinaryInput = Uint8Array | ArrayBuffer | BlobType;
23
+ /**
24
+ * Warnings (docs/api.md §7.3).
25
+ *
26
+ * The reader and the CSV parser collect warnings for damage they can recover
27
+ * from, instead of throwing. Each warning is plain data.
28
+ */
29
+ /** Every warning code the library reports. */
30
+ type ExcelWarningCode = "UNSUPPORTED_PART" | "INVALID_STYLE_INDEX" | "INVALID_SHARED_STRING" | "CELL_OUT_OF_BOUNDS" | "INVALID_CELL_REF" | "DUPLICATE_CELL" | "INVALID_DATE_SERIAL" | "SHARED_FORMULA_UNRESOLVED" | "MISSING_PART" | "BROKEN_OPTIONAL_PART" | "HYPERLINK_RANGE_REDUCED" | "SPLIT_PANE_IGNORED" | "ROWS_TRUNCATED" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
31
+ /** A recoverable problem found while reading or building. */
32
+ interface ExcelWarning {
33
+ code: ExcelWarningCode;
34
+ message: string;
35
+ /** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
36
+ part?: string | undefined;
37
+ sheet?: string | undefined;
38
+ /** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
39
+ ref?: string | undefined;
40
+ }
41
+ export { BlobType as a, BlobLike as i, ExcelWarningCode as n, BinaryInput as r, ExcelWarning as t };
package/dist/worker.cjs CHANGED
@@ -1,8 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_csv = require("./csv-DyVH9y7S.cjs");
3
3
  const require_errors = require("./errors-DOPrrGS4.cjs");
4
- const require_read = require("./read-Ym1voUct.cjs");
5
- const require_write = require("./write-BOh9jfu1.cjs");
4
+ const require_read = require("./read-CZEWV4rK.cjs");
5
+ const require_pipeline = require("./pipeline-Bnf7EU3X.cjs");
6
+ const require_write = require("./write-f9kcYf5K.cjs");
6
7
  // src/worker.ts
7
8
  /** Marks the library's messages, so an app can use the same worker for its own messages too. */
8
9
  const TAG = "javascript-excel/worker@1";
@@ -86,6 +87,12 @@ async function run(ep, req, signal) {
86
87
  result: await require_csv.readCsv(req.input, options)
87
88
  });
88
89
  return;
90
+ case "importDataset":
91
+ post({
92
+ done: true,
93
+ result: await require_pipeline.importDataset(req.input, options)
94
+ });
95
+ return;
89
96
  default: throw new TypeError(`Unknown worker operation ${JSON.stringify(req.op)}`);
90
97
  }
91
98
  } catch (err) {
@@ -226,6 +233,7 @@ function createWorkerClient(worker) {
226
233
  read: (input, options) => call("read", input, options),
227
234
  toCsv: (source, options) => call("toCsv", source, options),
228
235
  parseCsv: (input, options) => call("parseCsv", input, options),
236
+ importDataset: (input, options) => call("importDataset", input, options),
229
237
  terminate: () => {
230
238
  worker.terminate();
231
239
  for (const [id, p] of pending) {
package/dist/worker.d.cts CHANGED
@@ -18,11 +18,15 @@
18
18
  * `transfer: true`. Calls on one client run one after another. Code that
19
19
  * imports only `createWorkerClient` does not ship the engine: the writer,
20
20
  * reader and CSV code are referenced from `exposeWorker` alone.
21
+ *
22
+ * @module javascript-excel/worker
21
23
  */
22
- import { I as Workbook, M as Sheet, f as CellInput, r as BinaryInput } from "./warnings-C_12PT4t.cjs";
24
+ import { r as BinaryInput } from "./warnings-B1v58nCZ.cjs";
23
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.cjs";
24
- import { a as ReadResult, i as ReadOptions } from "./read-C6L7Nyy3.cjs";
25
- import { n as WriteOptions, t as Progress } from "./write-C5JgeIar.cjs";
26
+ import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.cjs";
27
+ import { ReadOptions, ReadResult } from "./read.cjs";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-CctEa86r.cjs";
29
+ import { n as WriteOptions, t as Progress } from "./write-DtjfdIFm.cjs";
26
30
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
27
31
  /** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
28
32
  export interface MessageEndpoint {
@@ -52,6 +56,8 @@ export interface WorkerClient {
52
56
  read(input: BinaryInput, options?: ReadOptions & TransferOption): Promise<ReadResult>;
53
57
  toCsv(source: Sheet | CellInput[][], options?: CsvWriteOptions): Promise<string>;
54
58
  parseCsv(input: string | BinaryInput, options?: (CsvParseOptions & Pick<CsvReadOptions, "encoding" | "signal">) & TransferOption): Promise<CsvParseResult>;
59
+ /** Runs javascript-excel/import's `importDataset` in the worker (docs/api.md §5.6). */
60
+ importDataset(input: string | BinaryInput, options?: ImportDatasetOptions & TransferOption): Promise<ImportDatasetResult>;
55
61
  /** Terminates the worker. Calls still in flight reject with an `AbortError`. */
56
62
  terminate(): void;
57
63
  }
@@ -62,4 +68,4 @@ export interface WorkerClient {
62
68
  export declare function exposeWorker(scope?: MessageEndpoint): void;
63
69
  /** Wraps a worker that runs `exposeWorker()`. */
64
70
  export declare function createWorkerClient(worker: WorkerLike): WorkerClient;
65
- export type { AbortSignalLike, Progress };
71
+ export type { AbortSignalLike, ImportDatasetOptions, ImportDatasetResult, Progress };
package/dist/worker.d.ts CHANGED
@@ -18,11 +18,15 @@
18
18
  * `transfer: true`. Calls on one client run one after another. Code that
19
19
  * imports only `createWorkerClient` does not ship the engine: the writer,
20
20
  * reader and CSV code are referenced from `exposeWorker` alone.
21
+ *
22
+ * @module javascript-excel/worker
21
23
  */
22
- import { N as Workbook, P as BinaryInput, k as Sheet, l as CellInput } from "./warnings-DXJKe1lx.js";
24
+ import { r as BinaryInput } from "./warnings-B1v58nCZ.js";
23
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.js";
24
- import { a as ReadResult, i as ReadOptions } from "./read-Ddkks7qC.js";
25
- import { n as WriteOptions, t as Progress } from "./write-CYpLGuzl.js";
26
+ import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.js";
27
+ import { ReadOptions, ReadResult } from "./read.js";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-I8SLmV9S.js";
29
+ import { n as WriteOptions, t as Progress } from "./write-DM6ieuQY.js";
26
30
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
27
31
  /** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
28
32
  export interface MessageEndpoint {
@@ -52,6 +56,8 @@ export interface WorkerClient {
52
56
  read(input: BinaryInput, options?: ReadOptions & TransferOption): Promise<ReadResult>;
53
57
  toCsv(source: Sheet | CellInput[][], options?: CsvWriteOptions): Promise<string>;
54
58
  parseCsv(input: string | BinaryInput, options?: (CsvParseOptions & Pick<CsvReadOptions, "encoding" | "signal">) & TransferOption): Promise<CsvParseResult>;
59
+ /** Runs javascript-excel/import's `importDataset` in the worker (docs/api.md §5.6). */
60
+ importDataset(input: string | BinaryInput, options?: ImportDatasetOptions & TransferOption): Promise<ImportDatasetResult>;
55
61
  /** Terminates the worker. Calls still in flight reject with an `AbortError`. */
56
62
  terminate(): void;
57
63
  }
@@ -62,4 +68,4 @@ export interface WorkerClient {
62
68
  export declare function exposeWorker(scope?: MessageEndpoint): void;
63
69
  /** Wraps a worker that runs `exposeWorker()`. */
64
70
  export declare function createWorkerClient(worker: WorkerLike): WorkerClient;
65
- export type { AbortSignalLike, Progress };
71
+ export type { AbortSignalLike, ImportDatasetOptions, ImportDatasetResult, Progress };
package/dist/worker.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { i as toCsv, r as readCsv } from "./csv-pXfaputs.js";
2
2
  import { a as LimitError, i as FormatError, n as EnvironmentError, o as ValidationError, r as ExcelError, s as isExcelError, t as CsvError } from "./errors-CvGlfw0E.js";
3
- import { r as read } from "./read-DDN5ZsPe.js";
4
- import { r as toUint8Array } from "./write-DubvcG-x.js";
3
+ import { r as read } from "./read-LWti17lz.js";
4
+ import { t as importDataset } from "./pipeline-BAJtzBdW.js";
5
+ import { r as toUint8Array } from "./write-DjgWy1PK.js";
5
6
  // src/worker.ts
6
7
  /** Marks the library's messages, so an app can use the same worker for its own messages too. */
7
8
  const TAG = "javascript-excel/worker@1";
@@ -85,6 +86,12 @@ async function run(ep, req, signal) {
85
86
  result: await readCsv(req.input, options)
86
87
  });
87
88
  return;
89
+ case "importDataset":
90
+ post({
91
+ done: true,
92
+ result: await importDataset(req.input, options)
93
+ });
94
+ return;
88
95
  default: throw new TypeError(`Unknown worker operation ${JSON.stringify(req.op)}`);
89
96
  }
90
97
  } catch (err) {
@@ -225,6 +232,7 @@ function createWorkerClient(worker) {
225
232
  read: (input, options) => call("read", input, options),
226
233
  toCsv: (source, options) => call("toCsv", source, options),
227
234
  parseCsv: (input, options) => call("parseCsv", input, options),
235
+ importDataset: (input, options) => call("importDataset", input, options),
228
236
  terminate: () => {
229
237
  worker.terminate();
230
238
  for (const [id, p] of pending) {
@@ -1,5 +1,6 @@
1
- import { I as BlobType, N as Workbook } from "./warnings-DXJKe1lx.js";
1
+ import { a as BlobType } from "./warnings-B1v58nCZ.js";
2
2
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
3
+ import { j as Workbook } from "./model-0JikLfuM.js";
3
4
  /** MIME type of an .xlsx file. */
4
5
  declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
5
6
  /** Progress of a write or read. */
@@ -1,6 +1,9 @@
1
1
  import { n as EnvironmentError, o as ValidationError } from "./errors-CvGlfw0E.js";
2
- import { c as nativeCodec, d as throttleProgress, f as ByteWriter, m as throwIfAborted, o as toDosDateTime, p as concatBytes, r as dateToSerial, s as crc32, u as encodeUtf8 } from "./numfmt-BBgB7iQA.js";
3
- import { D as xmlAttr, E as num, O as xmlText, S as encodeCol, T as needsPreserve, _ as MAX_ROWS, a as SheetFeatures, b as decodeRange, c as hyperlinkSchemes, d as PackageParts, f as REL_TYPE, h as mergeStyles, k as xstring, m as cellText, n as validateSheetName, o as SheetLinks, p as Rels, s as hyperlinkOf, u as CONTENT_TYPE, w as XML_DECL } from "./sheet-names-uT2EH5Ui.js";
2
+ import { c as ByteWriter, i as nativeCodec, l as concatBytes, n as toDosDateTime, o as encodeUtf8, r as crc32, s as throttleProgress, u as throwIfAborted } from "./dos-time-dD0z1YWU.js";
3
+ import { _ as num, a as SheetFeatures, b as xstring, c as hyperlinkSchemes, d as PackageParts, f as REL_TYPE, g as needsPreserve, h as XML_DECL, m as mergeStyles, n as validateSheetName, o as SheetLinks, p as Rels, s as hyperlinkOf, u as CONTENT_TYPE, v as xmlAttr, y as xmlText } from "./sheet-names-7p-joVsG.js";
4
+ import { a as decodeRange, n as MAX_ROWS, s as encodeCol } from "./address-DUn7-5OS.js";
5
+ import { t as dateToSerial } from "./dates-BXcSWf9_.js";
6
+ import { t as cellText } from "./cells-CrMF8h_t.js";
4
7
  const SIG_LOCAL = 67324752;
5
8
  const SIG_CENTRAL = 33639248;
6
9
  const SIG_EOCD = 101010256;
@@ -1,5 +1,6 @@
1
- import { I as Workbook, a as BlobType } from "./warnings-C_12PT4t.cjs";
1
+ import { a as BlobType } from "./warnings-B1v58nCZ.cjs";
2
2
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
3
+ import { j as Workbook } from "./model-0JikLfuM.cjs";
3
4
  /** MIME type of an .xlsx file. */
4
5
  declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
5
6
  /** Progress of a write or read. */