javascript-excel 2.3.0 → 2.4.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.
package/README.md CHANGED
@@ -181,7 +181,7 @@ const bytes = await excel.write(workbook, { signal: controller.signal, onProgres
181
181
  - **Reader:** `.xlsx`, `.xlsm`, `.xltx` and `.xltm`, including ISO 29500 Strict files.
182
182
  - Reads values, shared, inline and rich strings, and formula text with cached values (shared formulas expanded).
183
183
  - Styles come back as shared frozen objects. Merges, column widths and row heights, views and panes, print setup, hyperlinks, defined names and document properties are read too.
184
- - **Untrusted files:** bounded by limits on size, zip entries, compression ratio, XML depth and token length, sheets, cells, shared strings and the length of one cell's text. A `DOCTYPE` is rejected, nothing is ever fetched or executed, and file content never becomes an object key.
184
+ - **Untrusted files:** bounded by limits on size, zip entries, compression ratio, XML depth and token length, sheets, cells, sheet width (`maxColumns`; set it low, for example 256, for untrusted files), shared strings and the length of one cell's text; a shared formula is expanded only from a master within Excel's 8,192-character formula limit. A `DOCTYPE` is rejected, nothing is ever fetched or executed, and file content never becomes an object key.
185
185
  - **Rejected formats:** `.xls`, `.xlsb`, `.ods` and encrypted files throw `UNSUPPORTED_FORMAT`.
186
186
  - **CSV:** RFC 4180 parsing with delimiter detection, BOM and CRLF/LF/CR handling, lenient or strict modes, and optional type inference. `readCsv` decodes bytes in any `TextDecoder` encoding. Serializing gives you quoting, a BOM for Excel, ISO dates and a formula-injection guard, which is on by default.
187
187
  - **Datasets:** `fromDataset` and `fromDatasets` support `key`, `path` and function accessors, grouped headers, number formats, widths and a totals row. `toDataset` reads a sheet back into `{ columns, data }`.
@@ -78,6 +78,12 @@ function cellRef(row, col) {
78
78
  const DEFAULT_MAX_FIELD_BYTES = 1048576;
79
79
  /** Default `maxCellTextLength`: 1 Mi UTF-16 code units per field, as `DEFAULT_READ_LIMITS` for xlsx (JSE-58). */
80
80
  const DEFAULT_MAX_CELL_TEXT_LENGTH = 1048576;
81
+ /**
82
+ * Default `maxColumns`: fields in one record (JSE-68). 1 Mi, 64 times Excel's 16,384 columns and
83
+ * beyond any spreadsheet's width, so it refuses no CSV file that 2.3 read; a record that wide is
84
+ * at least 1 MiB of text, so the rows parseCsv returns stay linear in the input.
85
+ */
86
+ const DEFAULT_MAX_COLUMNS = 1048576;
81
87
  /** Default `maxWarnings`: warnings kept per parse before the cap (internal/warning-cap.ts) applies. */
82
88
  const MAX_WARNINGS = 1e3;
83
89
  const CANDIDATES = [
@@ -175,6 +181,7 @@ var CsvParser = class {
175
181
  value = this.quotedField(row, col);
176
182
  } else value = this.plainField(row, col);
177
183
  this.checkSize(value, row, col);
184
+ this.checkWidth(col, row);
178
185
  fields.push({
179
186
  text: value,
180
187
  quoted
@@ -183,6 +190,7 @@ var CsvParser = class {
183
190
  if (text.charCodeAt(this.pos) === this.delimCode) {
184
191
  this.pos++;
185
192
  if (this.pos >= len) {
193
+ this.checkWidth(fields.length, row);
186
194
  fields.push({
187
195
  text: "",
188
196
  quoted: false
@@ -300,6 +308,20 @@ var CsvParser = class {
300
308
  ref: cellRef(row, col)
301
309
  } });
302
310
  }
311
+ /**
312
+ * Field `col` (zero-based) of a record, before it is kept: refused past maxColumns (JSE-68). The
313
+ * record read only to find that maxRows was reached is dropped, so it is not checked.
314
+ */
315
+ checkWidth(col, row) {
316
+ const max = this.cfg.maxColumns;
317
+ if (col < max || row >= this.cfg.maxRows) return;
318
+ throw new require_errors.LimitError("LIMIT_EXCEEDED", `Row ${row + 1} has more than maxColumns (${max}) fields.`, { details: {
319
+ limit: "maxColumns",
320
+ value: col + 1,
321
+ max,
322
+ ref: cellRef(row, col)
323
+ } });
324
+ }
303
325
  warn(code, message, ref, malformed = true) {
304
326
  if (this.cfg.strict && malformed) throw new require_errors.CsvError("CSV_MALFORMED", message, { details: {
305
327
  warning: code,
@@ -338,6 +360,7 @@ function validateConfig(cfg) {
338
360
  if (!(cfg.maxRows >= 0)) throw new TypeError("maxRows must be a non-negative number");
339
361
  if (!(cfg.maxFieldBytes > 0)) throw new TypeError("maxFieldBytes must be a positive number");
340
362
  if (!(cfg.maxCellTextLength > 0)) throw new TypeError("maxCellTextLength must be a positive number");
363
+ if (!(cfg.maxColumns > 0)) throw new TypeError("maxColumns must be a positive number");
341
364
  require_infer.checkMaxWarnings("maxWarnings", cfg.maxWarnings);
342
365
  }
343
366
  /** A delimiter or quote: exactly one UTF-16 code unit, not CR or LF. */
@@ -573,6 +596,7 @@ function parseConfig(options) {
573
596
  maxRows: o.maxRows ?? Number.POSITIVE_INFINITY,
574
597
  maxFieldBytes: o.maxFieldBytes ?? 1048576,
575
598
  maxCellTextLength: o.maxCellTextLength === void 0 ? DEFAULT_MAX_CELL_TEXT_LENGTH : o.maxCellTextLength,
599
+ maxColumns: o.maxColumns === void 0 ? DEFAULT_MAX_COLUMNS : o.maxColumns,
576
600
  dateZone: o.dateZone ?? "local",
577
601
  maxWarnings: o.maxWarnings === void 0 ? MAX_WARNINGS : o.maxWarnings
578
602
  };
@@ -78,6 +78,12 @@ function cellRef(row, col) {
78
78
  const DEFAULT_MAX_FIELD_BYTES = 1048576;
79
79
  /** Default `maxCellTextLength`: 1 Mi UTF-16 code units per field, as `DEFAULT_READ_LIMITS` for xlsx (JSE-58). */
80
80
  const DEFAULT_MAX_CELL_TEXT_LENGTH = 1048576;
81
+ /**
82
+ * Default `maxColumns`: fields in one record (JSE-68). 1 Mi, 64 times Excel's 16,384 columns and
83
+ * beyond any spreadsheet's width, so it refuses no CSV file that 2.3 read; a record that wide is
84
+ * at least 1 MiB of text, so the rows parseCsv returns stay linear in the input.
85
+ */
86
+ const DEFAULT_MAX_COLUMNS = 1048576;
81
87
  /** Default `maxWarnings`: warnings kept per parse before the cap (internal/warning-cap.ts) applies. */
82
88
  const MAX_WARNINGS = 1e3;
83
89
  const CANDIDATES = [
@@ -175,6 +181,7 @@ var CsvParser = class {
175
181
  value = this.quotedField(row, col);
176
182
  } else value = this.plainField(row, col);
177
183
  this.checkSize(value, row, col);
184
+ this.checkWidth(col, row);
178
185
  fields.push({
179
186
  text: value,
180
187
  quoted
@@ -183,6 +190,7 @@ var CsvParser = class {
183
190
  if (text.charCodeAt(this.pos) === this.delimCode) {
184
191
  this.pos++;
185
192
  if (this.pos >= len) {
193
+ this.checkWidth(fields.length, row);
186
194
  fields.push({
187
195
  text: "",
188
196
  quoted: false
@@ -300,6 +308,20 @@ var CsvParser = class {
300
308
  ref: cellRef(row, col)
301
309
  } });
302
310
  }
311
+ /**
312
+ * Field `col` (zero-based) of a record, before it is kept: refused past maxColumns (JSE-68). The
313
+ * record read only to find that maxRows was reached is dropped, so it is not checked.
314
+ */
315
+ checkWidth(col, row) {
316
+ const max = this.cfg.maxColumns;
317
+ if (col < max || row >= this.cfg.maxRows) return;
318
+ throw new LimitError("LIMIT_EXCEEDED", `Row ${row + 1} has more than maxColumns (${max}) fields.`, { details: {
319
+ limit: "maxColumns",
320
+ value: col + 1,
321
+ max,
322
+ ref: cellRef(row, col)
323
+ } });
324
+ }
303
325
  warn(code, message, ref, malformed = true) {
304
326
  if (this.cfg.strict && malformed) throw new CsvError("CSV_MALFORMED", message, { details: {
305
327
  warning: code,
@@ -338,6 +360,7 @@ function validateConfig(cfg) {
338
360
  if (!(cfg.maxRows >= 0)) throw new TypeError("maxRows must be a non-negative number");
339
361
  if (!(cfg.maxFieldBytes > 0)) throw new TypeError("maxFieldBytes must be a positive number");
340
362
  if (!(cfg.maxCellTextLength > 0)) throw new TypeError("maxCellTextLength must be a positive number");
363
+ if (!(cfg.maxColumns > 0)) throw new TypeError("maxColumns must be a positive number");
341
364
  checkMaxWarnings("maxWarnings", cfg.maxWarnings);
342
365
  }
343
366
  /** A delimiter or quote: exactly one UTF-16 code unit, not CR or LF. */
@@ -573,6 +596,7 @@ function parseConfig(options) {
573
596
  maxRows: o.maxRows ?? Number.POSITIVE_INFINITY,
574
597
  maxFieldBytes: o.maxFieldBytes ?? 1048576,
575
598
  maxCellTextLength: o.maxCellTextLength === void 0 ? DEFAULT_MAX_CELL_TEXT_LENGTH : o.maxCellTextLength,
599
+ maxColumns: o.maxColumns === void 0 ? DEFAULT_MAX_COLUMNS : o.maxColumns,
576
600
  dateZone: o.dateZone ?? "local",
577
601
  maxWarnings: o.maxWarnings === void 0 ? MAX_WARNINGS : o.maxWarnings
578
602
  };
package/dist/csv.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_warnings = require("./warnings-CJPiDqei.cjs");
3
- const require_csv = require("./csv-f4P3fGs-.cjs");
3
+ const require_csv = require("./csv-DZ241Y5F.cjs");
4
4
  exports.CSV_MIME = require_csv.CSV_MIME;
5
5
  exports.isDataLossWarning = require_warnings.isDataLossWarning;
6
6
  exports.parseCsv = require_csv.parseCsv;
package/dist/csv.d.cts CHANGED
@@ -52,6 +52,14 @@ export interface CsvParseOptions {
52
52
  * as `maxFieldBytes`, as before. A positive number; default 1,048,576 (1 Mi).
53
53
  */
54
54
  maxCellTextLength?: number | undefined;
55
+ /**
56
+ * Fields in one record; a record with more throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit`
57
+ * `'maxColumns'`, `details.value` the field's 1-based position, `details.ref` its cell) while it
58
+ * is read. The same name as `ReadLimits.maxColumns` for xlsx (added in 2.4). A positive number;
59
+ * default 1,048,576, wider than any spreadsheet (Excel: 16,384 columns), so no existing file is
60
+ * refused; set it to the widest file you accept (for example 256) for untrusted input.
61
+ */
62
+ maxColumns?: number | undefined;
55
63
  /**
56
64
  * Warnings kept before the cap applies (as `ReadLimits.maxWarnings` for `read`). Past it,
57
65
  * informational warnings are dropped and counted in one `WARNINGS_TRUNCATED` at the end;
package/dist/csv.d.ts CHANGED
@@ -52,6 +52,14 @@ export interface CsvParseOptions {
52
52
  * as `maxFieldBytes`, as before. A positive number; default 1,048,576 (1 Mi).
53
53
  */
54
54
  maxCellTextLength?: number | undefined;
55
+ /**
56
+ * Fields in one record; a record with more throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit`
57
+ * `'maxColumns'`, `details.value` the field's 1-based position, `details.ref` its cell) while it
58
+ * is read. The same name as `ReadLimits.maxColumns` for xlsx (added in 2.4). A positive number;
59
+ * default 1,048,576, wider than any spreadsheet (Excel: 16,384 columns), so no existing file is
60
+ * refused; set it to the widest file you accept (for example 256) for untrusted input.
61
+ */
62
+ maxColumns?: number | undefined;
55
63
  /**
56
64
  * Warnings kept before the cap applies (as `ReadLimits.maxWarnings` for `read`). Past it,
57
65
  * informational warnings are dropped and counted in one `WARNINGS_TRUNCATED` at the end;
package/dist/csv.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
2
- import { a as toCsvBlob, i as toCsv, n as parseCsv, r as readCsv, t as CSV_MIME } from "./csv-Bck8eW_D.js";
2
+ import { a as toCsvBlob, i as toCsv, n as parseCsv, r as readCsv, t as CSV_MIME } from "./csv-Dn4MIESx.js";
3
3
  export { CSV_MIME, isDataLossWarning, parseCsv, readCsv, toCsv, toCsvBlob };
@@ -594,8 +594,51 @@ function toDataset(sheet, options = {}) {
594
594
  data
595
595
  };
596
596
  }
597
+ /**
598
+ * Every data row gets a key for every column, null where the row has no cell
599
+ * (the contract of toDataset). A wide header over short rows therefore costs
600
+ * rows × columns, far beyond the cells the sheet holds: 16,384 titles over
601
+ * 10,000 three-cell rows are 164 million fields. This counts those empty
602
+ * fields, row by row in the order they would be built, and refuses at the
603
+ * first row that passes `max`, before any row is built (JSE-68). A cell with
604
+ * neither value nor formula (only a hyperlink, which the reader charges to
605
+ * maxItems, or a style) is an empty field too. Work is
606
+ * bounded by the cells visited plus `max`: a row costs at most its stored
607
+ * cells plus its empty fields.
608
+ */
609
+ function checkPadding(s, rng, firstData, max) {
610
+ const width = rng.end.col - rng.start.col + 1;
611
+ const height = rng.end.row - firstData + 1;
612
+ if (height <= 0 || width * height <= max) return;
613
+ let padding = 0;
614
+ let rows = 0;
615
+ for (let r = firstData; r <= rng.end.row; r++) {
616
+ const row = s.rows[r];
617
+ if (!row) continue;
618
+ const end = Math.min(rng.end.col, row.length - 1);
619
+ let any = false;
620
+ let present = 0;
621
+ for (let c = rng.start.col; c <= end; c++) {
622
+ const v = row[c];
623
+ if (v === void 0 || v === null) continue;
624
+ if (isCellObject(v) && (v.value === void 0 || v.value === null) && !v.formula) continue;
625
+ present++;
626
+ any = true;
627
+ }
628
+ if (!any) continue;
629
+ rows++;
630
+ padding += width - present;
631
+ if (padding > max) throw new require_errors.LimitError("LIMIT_EXCEEDED", `The dataset needs more than maxCells (${max}) empty fields: ${rows} data rows × ${width} columns hold few cells. Read a narrower range or set maxColumns.`, { details: {
632
+ limit: "maxCells",
633
+ value: padding,
634
+ max,
635
+ rows,
636
+ columns: width
637
+ } });
638
+ }
639
+ }
597
640
  /** @internal */
598
- function toDatasetDetailed(sheet, options = {}) {
641
+ function toDatasetDetailed(sheet, options = {}, budget) {
599
642
  const s = sheet;
600
643
  const rng = options.range ? require_address.decodeRange(options.range) : s.dimension ? require_address.decodeRange(s.dimension) : usedRange(s);
601
644
  if (!rng) return {
@@ -631,6 +674,7 @@ function toDatasetDetailed(sheet, options = {}) {
631
674
  const rowNumbers = [];
632
675
  let lastRaw;
633
676
  const firstData = headerRow === false ? rng.start.row : Math.max(rng.start.row, headerRow + headerRows);
677
+ if (budget) checkPadding(s, rng, firstData, budget.maxCells);
634
678
  for (let r = firstData; r <= rng.end.row; r++) {
635
679
  const row = s.rows[r];
636
680
  if (!row) continue;
@@ -1,7 +1,7 @@
1
1
  import { a as decodeRange, c as encodeRange, o as encodeCell, r as decodeCell, s as encodeCol, t as MAX_COLS } from "./address-DUn7-5OS.js";
2
2
  import { t as cellText } from "./cells-CrMF8h_t.js";
3
3
  import { t as dateToSerial } from "./dates-BXcSWf9_.js";
4
- import { o as ValidationError } from "./errors-CvGlfw0E.js";
4
+ import { a as LimitError, o as ValidationError } from "./errors-CvGlfw0E.js";
5
5
  import { n as parseIsoDate, t as isoDate } from "./iso-date-CXnn-9mT.js";
6
6
  import { l as textWidth, m as mergeStyles, n as validateSheetName, r as AUTO_WIDTH } from "./sheet-names-BLrwcn33.js";
7
7
  // src/dataset.ts
@@ -594,8 +594,51 @@ function toDataset(sheet, options = {}) {
594
594
  data
595
595
  };
596
596
  }
597
+ /**
598
+ * Every data row gets a key for every column, null where the row has no cell
599
+ * (the contract of toDataset). A wide header over short rows therefore costs
600
+ * rows × columns, far beyond the cells the sheet holds: 16,384 titles over
601
+ * 10,000 three-cell rows are 164 million fields. This counts those empty
602
+ * fields, row by row in the order they would be built, and refuses at the
603
+ * first row that passes `max`, before any row is built (JSE-68). A cell with
604
+ * neither value nor formula (only a hyperlink, which the reader charges to
605
+ * maxItems, or a style) is an empty field too. Work is
606
+ * bounded by the cells visited plus `max`: a row costs at most its stored
607
+ * cells plus its empty fields.
608
+ */
609
+ function checkPadding(s, rng, firstData, max) {
610
+ const width = rng.end.col - rng.start.col + 1;
611
+ const height = rng.end.row - firstData + 1;
612
+ if (height <= 0 || width * height <= max) return;
613
+ let padding = 0;
614
+ let rows = 0;
615
+ for (let r = firstData; r <= rng.end.row; r++) {
616
+ const row = s.rows[r];
617
+ if (!row) continue;
618
+ const end = Math.min(rng.end.col, row.length - 1);
619
+ let any = false;
620
+ let present = 0;
621
+ for (let c = rng.start.col; c <= end; c++) {
622
+ const v = row[c];
623
+ if (v === void 0 || v === null) continue;
624
+ if (isCellObject(v) && (v.value === void 0 || v.value === null) && !v.formula) continue;
625
+ present++;
626
+ any = true;
627
+ }
628
+ if (!any) continue;
629
+ rows++;
630
+ padding += width - present;
631
+ if (padding > max) throw new LimitError("LIMIT_EXCEEDED", `The dataset needs more than maxCells (${max}) empty fields: ${rows} data rows × ${width} columns hold few cells. Read a narrower range or set maxColumns.`, { details: {
632
+ limit: "maxCells",
633
+ value: padding,
634
+ max,
635
+ rows,
636
+ columns: width
637
+ } });
638
+ }
639
+ }
597
640
  /** @internal */
598
- function toDatasetDetailed(sheet, options = {}) {
641
+ function toDatasetDetailed(sheet, options = {}, budget) {
599
642
  const s = sheet;
600
643
  const rng = options.range ? decodeRange(options.range) : s.dimension ? decodeRange(s.dimension) : usedRange(s);
601
644
  if (!rng) return {
@@ -631,6 +674,7 @@ function toDatasetDetailed(sheet, options = {}) {
631
674
  const rowNumbers = [];
632
675
  let lastRaw;
633
676
  const firstData = headerRow === false ? rng.start.row : Math.max(rng.start.row, headerRow + headerRows);
677
+ if (budget) checkPadding(s, rng, firstData, budget.maxCells);
634
678
  for (let r = firstData; r <= rng.end.row; r++) {
635
679
  const row = s.rows[r];
636
680
  if (!row) continue;
package/dist/import.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_pipeline = require("./pipeline-LCTU0Eg_.cjs");
2
+ const require_pipeline = require("./pipeline-BwkRpV5Z.cjs");
3
3
  const require_warnings = require("./warnings-CJPiDqei.cjs");
4
4
  exports.applyMapping = require_pipeline.applyMapping;
5
5
  exports.coerceColumns = require_pipeline.coerceColumns;
package/dist/import.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * (docs/api.md §5.6). Header detection, type inference, locale-aware
4
4
  * parsing and column mapping, plus the `importDataset` pipeline.
5
5
  */
6
- import { A as NumberGroup, C as coerceColumns, D as ImportLocale, E as HeaderDetection, M as parseNumber, O as detectHeader, S as TypeOptions, T as DetectHeaderOptions, _ as ColumnType, a as ImportProgress, b as ImportIssueCode, c as FieldSpec, d as MappableDataset, f as MappedDataset, g as CoerceResult, h as mapColumns, i as ImportMeta, j as parseDate, k as DateOrder, l as ImportSchema, m as applyMapping, n as ImportDatasetOptions, o as importDataset, p as MappingResult, r as ImportDatasetResult, s as ColumnMapping, t as DroppedIssues, u as ImportedColumn, v as DatasetLike, w as inferColumnTypes, x as InferredColumn, y as ImportIssue } from "./pipeline-D1eAhqJu.cjs";
6
+ import { A as NumberGroup, C as coerceColumns, D as ImportLocale, E as HeaderDetection, M as parseNumber, O as detectHeader, S as TypeOptions, T as DetectHeaderOptions, _ as ColumnType, a as ImportProgress, b as ImportIssueCode, c as FieldSpec, d as MappableDataset, f as MappedDataset, g as CoerceResult, h as mapColumns, i as ImportMeta, j as parseDate, k as DateOrder, l as ImportSchema, m as applyMapping, n as ImportDatasetOptions, o as importDataset, p as MappingResult, r as ImportDatasetResult, s as ColumnMapping, t as DroppedIssues, u as ImportedColumn, v as DatasetLike, w as inferColumnTypes, x as InferredColumn, y as ImportIssue } from "./pipeline-4U7Xnuc1.cjs";
7
7
  import { a as isDataLossWarning, c as BlobType, i as ExcelWarningCode, n as ExcelPartKind, o as BinaryInput, r as ExcelWarning, s as BlobLike, t as DroppedWarnings } from "./warnings-DhonqJ7A.cjs";
8
8
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
9
9
  import { ReadLimits, SheetInfo } from "./read.cjs";
package/dist/import.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * (docs/api.md §5.6). Header detection, type inference, locale-aware
4
4
  * parsing and column mapping, plus the `importDataset` pipeline.
5
5
  */
6
- import { A as NumberGroup, C as coerceColumns, D as ImportLocale, E as HeaderDetection, M as parseNumber, O as detectHeader, S as TypeOptions, T as DetectHeaderOptions, _ as ColumnType, a as ImportProgress, b as ImportIssueCode, c as FieldSpec, d as MappableDataset, f as MappedDataset, g as CoerceResult, h as mapColumns, i as ImportMeta, j as parseDate, k as DateOrder, l as ImportSchema, m as applyMapping, n as ImportDatasetOptions, o as importDataset, p as MappingResult, r as ImportDatasetResult, s as ColumnMapping, t as DroppedIssues, u as ImportedColumn, v as DatasetLike, w as inferColumnTypes, x as InferredColumn, y as ImportIssue } from "./pipeline-Bh7FUyzW.js";
6
+ import { A as NumberGroup, C as coerceColumns, D as ImportLocale, E as HeaderDetection, M as parseNumber, O as detectHeader, S as TypeOptions, T as DetectHeaderOptions, _ as ColumnType, a as ImportProgress, b as ImportIssueCode, c as FieldSpec, d as MappableDataset, f as MappedDataset, g as CoerceResult, h as mapColumns, i as ImportMeta, j as parseDate, k as DateOrder, l as ImportSchema, m as applyMapping, n as ImportDatasetOptions, o as importDataset, p as MappingResult, r as ImportDatasetResult, s as ColumnMapping, t as DroppedIssues, u as ImportedColumn, v as DatasetLike, w as inferColumnTypes, x as InferredColumn, y as ImportIssue } from "./pipeline-BegSPu8X.js";
7
7
  import { a as isDataLossWarning, c as BlobType, i as ExcelWarningCode, n as ExcelPartKind, o as BinaryInput, r as ExcelWarning, s as BlobLike, t as DroppedWarnings } from "./warnings-DhonqJ7A.js";
8
8
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
9
9
  import { ReadLimits, SheetInfo } from "./read.js";
package/dist/import.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as mapColumns, c as parseNumber, i as applyMapping, n as coerceColumns, o as detectHeader, r as inferColumnTypes, s as parseDate, t as importDataset } from "./pipeline-2dgQM9E9.js";
1
+ import { a as mapColumns, c as parseNumber, i as applyMapping, n as coerceColumns, o as detectHeader, r as inferColumnTypes, s as parseDate, t as importDataset } from "./pipeline-C8F9lecW.js";
2
2
  import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
3
3
  export { applyMapping, coerceColumns, detectHeader, importDataset, inferColumnTypes, isDataLossWarning, mapColumns, parseDate, parseNumber };
package/dist/index.cjs CHANGED
@@ -6,12 +6,12 @@ const require_dates = require("./dates-CA1dCizp.cjs");
6
6
  const require_sheet_names = require("./sheet-names-DDY64-dt.cjs");
7
7
  const require_colors = require("./colors-oBpjx97l.cjs");
8
8
  const require_cells = require("./cells-CPXU722t.cjs");
9
- const require_dataset = require("./dataset-DzoMeOG1.cjs");
9
+ const require_dataset = require("./dataset-CbZnEWXu.cjs");
10
10
  const require_numfmt = require("./numfmt-DwsnhZKe.cjs");
11
11
  const require_address = require("./address-DZBHchLv.cjs");
12
12
  // src/index.ts
13
13
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
14
- const VERSION = "2.3.0";
14
+ const VERSION = "2.4.0";
15
15
  exports.BUILTIN_NUM_FMTS = require_numfmt.BUILTIN_NUM_FMTS;
16
16
  exports.CsvError = require_errors.CsvError;
17
17
  exports.EnvironmentError = require_errors.EnvironmentError;
package/dist/index.d.cts CHANGED
@@ -293,5 +293,5 @@ export declare function encodeRange(r: RangeAddress): string;
293
293
  /** 'A1:C3' or 'A1' → range, normalised so start is top-left. */
294
294
  export declare function decodeRange(ref: string): RangeAddress;
295
295
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
296
- export declare const VERSION = "2.3.0";
296
+ export declare const VERSION = "2.4.0";
297
297
  export { type AbortSignalLike, type Alignment, type AutoWidthOptions, type BinaryInput, type BlobLike, type BlobType, type Border, type BorderSide, type BorderStyle, type Cell, type CellAddress, type CellErrorValue, type CellInput, type CellTextOptions, type CellType, type CellValue, type Color, type ColorContext, type ColumnDef, type ColumnProps, type ColumnTotal, type ColumnWidth, type Dataset, type DatasetBlock, type DatasetOptions, type DatasetResult, type DateOptions, type DefinedName, type DocProperties, type DroppedWarnings, type ErrorCode, type ExcelErrorCode, type ExcelErrorOptions, type ExcelPartKind, type ExcelWarning, type ExcelWarningCode, type Fill, type Font, type GradientFill, type GroupColumn, type Hyperlink, type LeafColumn, type NumFmt, type PatternFill, type PatternType, type PrintSetup, type Progress, type RangeAddress, type RichText, type RichTextRun, type RowProps, type Sheet, type SheetNameProblem, type SheetView, type Style, type Theme, type ToDatasetOptions, type Workbook, type WriteOptions, XLSX_MIME, isDataLossWarning, toBlob, toUint8Array };
package/dist/index.d.ts CHANGED
@@ -293,5 +293,5 @@ export declare function encodeRange(r: RangeAddress): string;
293
293
  /** 'A1:C3' or 'A1' → range, normalised so start is top-left. */
294
294
  export declare function decodeRange(ref: string): RangeAddress;
295
295
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
296
- export declare const VERSION = "2.3.0";
296
+ export declare const VERSION = "2.4.0";
297
297
  export { type AbortSignalLike, type Alignment, type AutoWidthOptions, type BinaryInput, type BlobLike, type BlobType, type Border, type BorderSide, type BorderStyle, type Cell, type CellAddress, type CellErrorValue, type CellInput, type CellTextOptions, type CellType, type CellValue, type Color, type ColorContext, type ColumnDef, type ColumnProps, type ColumnTotal, type ColumnWidth, type Dataset, type DatasetBlock, type DatasetOptions, type DatasetResult, type DateOptions, type DefinedName, type DocProperties, type DroppedWarnings, type ErrorCode, type ExcelErrorCode, type ExcelErrorOptions, type ExcelPartKind, type ExcelWarning, type ExcelWarningCode, type Fill, type Font, type GradientFill, type GroupColumn, type Hyperlink, type LeafColumn, type NumFmt, type PatternFill, type PatternType, type PrintSetup, type Progress, type RangeAddress, type RichText, type RichTextRun, type RowProps, type Sheet, type SheetNameProblem, type SheetView, type Style, type Theme, type ToDatasetOptions, type Workbook, type WriteOptions, XLSX_MIME, isDataLossWarning, toBlob, toUint8Array };
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ import { n as serialToDate, t as dateToSerial } from "./dates-BXcSWf9_.js";
5
5
  import { m as mergeStyles, n as validateSheetName, t as sanitizeSheetName } from "./sheet-names-BLrwcn33.js";
6
6
  import { t as resolveColor } from "./colors-B8Nf_xTx.js";
7
7
  import { t as cellText } from "./cells-CrMF8h_t.js";
8
- import { n as fromDatasets, r as toDataset, t as fromDataset } from "./dataset-BLo9CwB-.js";
8
+ import { n as fromDatasets, r as toDataset, t as fromDataset } from "./dataset-CyEHVht4.js";
9
9
  import { n as isDateFormat, t as BUILTIN_NUM_FMTS } from "./numfmt-Ci_oW11p.js";
10
10
  import { a as decodeRange, c as encodeRange, 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";
11
11
  // src/index.ts
12
12
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
13
- const VERSION = "2.3.0";
13
+ const VERSION = "2.4.0";
14
14
  export { BUILTIN_NUM_FMTS, CsvError, EnvironmentError, ExcelError, FormatError, LimitError, MAX_COLS, MAX_ROWS, VERSION, ValidationError, XLSX_MIME, cellText, dateToSerial, decodeCell, decodeCol, decodeRange, encodeCell, encodeCol, encodeRange, fromDataset, fromDatasets, isDataLossWarning, isDateFormat, isExcelError, mergeStyles, resolveColor, sanitizeSheetName, serialToDate, toBlob, toDataset, toUint8Array, validateSheetName };
@@ -50,7 +50,8 @@ declare function detectHeader(sheet: Sheet<CellInput>, options?: DetectHeaderOpt
50
50
  /**
51
51
  * A column's type. `'day'` is never inferred: forced (by `types` or a schema
52
52
  * field), it converts like `'date'` and then drops the time of day, giving
53
- * 00:00 of the calendar day in `dateZone` (docs/api.md §5.6, "Type rules").
53
+ * 00:00 of the calendar day in `dateZone`; for ISO text with an offset, the
54
+ * day written (docs/api.md §5.6, "Type rules").
54
55
  */
55
56
  type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "day" | "mixed" | "empty";
56
57
  interface DatasetLike {
@@ -177,8 +178,10 @@ interface ImportDatasetOptions {
177
178
  */
178
179
  maxIssues?: number | undefined;
179
180
  /**
180
- * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings and
181
- * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match).
181
+ * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings,
182
+ * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match)
183
+ * and `maxColumns` the fields of one record. For both formats, `maxCells` also bounds
184
+ * the empty fields the dataset pads short rows with (since 2.4; docs/api.md §5.6).
182
185
  */
183
186
  limits?: Partial<ReadLimits> | undefined;
184
187
  signal?: AbortSignalLike | undefined;
@@ -50,7 +50,8 @@ declare function detectHeader(sheet: Sheet<CellInput>, options?: DetectHeaderOpt
50
50
  /**
51
51
  * A column's type. `'day'` is never inferred: forced (by `types` or a schema
52
52
  * field), it converts like `'date'` and then drops the time of day, giving
53
- * 00:00 of the calendar day in `dateZone` (docs/api.md §5.6, "Type rules").
53
+ * 00:00 of the calendar day in `dateZone`; for ISO text with an offset, the
54
+ * day written (docs/api.md §5.6, "Type rules").
54
55
  */
55
56
  type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "day" | "mixed" | "empty";
56
57
  interface DatasetLike {
@@ -177,8 +178,10 @@ interface ImportDatasetOptions {
177
178
  */
178
179
  maxIssues?: number | undefined;
179
180
  /**
180
- * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings and
181
- * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match).
181
+ * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings,
182
+ * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match)
183
+ * and `maxColumns` the fields of one record. For both formats, `maxCells` also bounds
184
+ * the empty fields the dataset pads short rows with (since 2.4; docs/api.md §5.6).
182
185
  */
183
186
  limits?: Partial<ReadLimits> | undefined;
184
187
  signal?: AbortSignalLike | undefined;
@@ -1,7 +1,7 @@
1
- const require_csv = require("./csv-f4P3fGs-.cjs");
2
- const require_dataset = require("./dataset-DzoMeOG1.cjs");
1
+ const require_csv = require("./csv-DZ241Y5F.cjs");
2
+ const require_dataset = require("./dataset-CbZnEWXu.cjs");
3
3
  const require_errors = require("./errors-DOPrrGS4.cjs");
4
- const require_read = require("./read-BYI7EVMo.cjs");
4
+ const require_read = require("./read-DmUPztqh.cjs");
5
5
  const require_infer = require("./infer-BniOucP6.cjs");
6
6
  const require_address = require("./address-DZBHchLv.cjs");
7
7
  const require_iso_date = require("./iso-date-3TY1OlGd.cjs");
@@ -612,6 +612,20 @@ function startOfDay(d, zone) {
612
612
  function isExcelDayZero(d, zone) {
613
613
  return zone === "utc" ? d.getUTCFullYear() === 1899 && d.getUTCMonth() === 11 && d.getUTCDate() === 31 : d.getFullYear() === 1899 && d.getMonth() === 11 && d.getDate() === 31;
614
614
  }
615
+ /**
616
+ * For 'day' (JSE-69): ISO text with an explicit offset or `Z` names its day in
617
+ * its date part, so that day, at 00:00 in `zone`; the offset does not move it.
618
+ * Undefined for anything else, including text the ISO parser refuses (an
619
+ * invalid date, time or offset), which then goes the usual way.
620
+ */
621
+ function isoDayAsWritten(text, zone) {
622
+ const s = text.trim();
623
+ if (s.length <= 16 || s.charCodeAt(4) !== 45 || require_infer.parseIsoDate(s, zone) === void 0) return void 0;
624
+ for (let i = 11; i < s.length; i++) {
625
+ const c = s.charCodeAt(i);
626
+ if (c === 90 || c === 43 || c === 45) return require_infer.parseIsoDate(s.slice(0, 10), zone);
627
+ }
628
+ }
615
629
  function textOf(v) {
616
630
  if (typeof v === "string") return v;
617
631
  if (v && typeof v === "object" && "richText" in v) return v.richText.map((r) => r.text).join("");
@@ -825,8 +839,11 @@ function convert(v, col, locale, zone) {
825
839
  let d;
826
840
  if (v instanceof Date) d = v;
827
841
  else if (t !== void 0) {
828
- const order = col.dateOrder ?? (locale.dateOrder && locale.dateOrder !== "auto" ? locale.dateOrder : void 0);
829
- d = order ? textToDate(t, order, zone, locale.twoDigitYearPivot) : parseDate(t, { zone });
842
+ if (col.type === "day") d = isoDayAsWritten(t, zone);
843
+ if (d === void 0) {
844
+ const order = col.dateOrder ?? (locale.dateOrder && locale.dateOrder !== "auto" ? locale.dateOrder : void 0);
845
+ d = order ? textToDate(t, order, zone, locale.twoDigitYearPivot) : parseDate(t, { zone });
846
+ }
830
847
  }
831
848
  if (d === void 0) return { ok: false };
832
849
  if (col.type !== "day") return {
@@ -1006,6 +1023,8 @@ async function importDataset(input, options = {}) {
1006
1023
  if (o.maxIssues !== Number.POSITIVE_INFINITY) checkCount("maxIssues", o.maxIssues, 1);
1007
1024
  const maxText = o.limits?.maxCellTextLength;
1008
1025
  if (maxText !== void 0 && (typeof maxText !== "number" || !(maxText > 0))) throw new TypeError("limits.maxCellTextLength must be a positive number");
1026
+ const maxColumns = o.limits?.maxColumns;
1027
+ if (maxColumns !== void 0 && (typeof maxColumns !== "number" || !(maxColumns > 0))) throw new TypeError("limits.maxColumns must be a positive number");
1009
1028
  if (typeof o.header === "object" && o.header !== null) {
1010
1029
  checkCount("header.rows", o.header.rows, 1);
1011
1030
  checkCount("header.row", o.header.row, 0);
@@ -1059,6 +1078,7 @@ async function importDataset(input, options = {}) {
1059
1078
  maxRows: cap,
1060
1079
  maxWarnings: o.limits?.maxWarnings,
1061
1080
  maxCellTextLength: maxText,
1081
+ maxColumns,
1062
1082
  maxFieldBytes: maxText !== void 0 && maxText > 1048576 ? 3 * maxText : void 0,
1063
1083
  signal: o.signal,
1064
1084
  inferTypes: false
@@ -1085,7 +1105,7 @@ async function importDataset(input, options = {}) {
1085
1105
  sheet: want,
1086
1106
  sheets: sheets.map((s) => s.name)
1087
1107
  } });
1088
- const { workbook } = await require_read.read(bytes, {
1108
+ const { workbook } = await require_read.readImpl(bytes, {
1089
1109
  sheets: [info.index],
1090
1110
  styles: false,
1091
1111
  richText: "plain",
@@ -1100,7 +1120,7 @@ async function importDataset(input, options = {}) {
1100
1120
  if (w.code === "ROWS_TRUNCATED") truncatedRead = true;
1101
1121
  warn(w);
1102
1122
  }
1103
- });
1123
+ }, { sharedFormulaText: "master" });
1104
1124
  sheet = workbook.sheets[info.index];
1105
1125
  meta.sheet = {
1106
1126
  name: info.name,
@@ -1139,13 +1159,15 @@ async function importDataset(input, options = {}) {
1139
1159
  headerRows = Array.from({ length: header.rows }, (_, i) => start + i);
1140
1160
  join = header.join;
1141
1161
  }
1162
+ const maxCells = o.limits?.maxCells;
1163
+ if (maxCells !== void 0 && (typeof maxCells !== "number" || !(maxCells > 0))) throw new TypeError("limits.maxCells must be a positive number");
1142
1164
  const ds = require_dataset.toDatasetDetailed(sheet, {
1143
1165
  headerRow: headerRows.length ? headerRows[0] : false,
1144
1166
  headerRows: Math.max(1, headerRows.length),
1145
1167
  join,
1146
1168
  range: o.range,
1147
1169
  skipTotals: o.skipTotals ?? "auto"
1148
- });
1170
+ }, { maxCells: maxCells ?? require_read.DEFAULT_LIMITS.maxCells });
1149
1171
  const issueCap = new IssueCap(o.maxIssues ?? 1e5);
1150
1172
  const issues = issueCap.issues;
1151
1173
  const base = {