javascript-excel 2.0.0-alpha.5 → 2.0.0-alpha.7

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/dist/index.d.ts CHANGED
@@ -170,8 +170,14 @@ interface DatasetOptions<T> {
170
170
  /** COERCION_FAILED and NON_FINITE_NUMBER. */
171
171
  onWarning?: ((w: ExcelWarning) => void) | undefined;
172
172
  }
173
- /** A block for `fromDatasets`, optionally offset from the previous one. */
173
+ /** A block for `fromDatasets`: placed below or to the right of the previous one, optionally offset. */
174
174
  type DatasetBlock<T> = Dataset<T> & {
175
+ /**
176
+ * 'below' (default): `gap` empty rows below the lowest row used so far by the previous
177
+ * row of blocks, at the origin column. 'right': on the previous block's top row, `gap`
178
+ * empty columns after its last column.
179
+ */
180
+ placement?: "below" | "right" | undefined;
175
181
  offset?: {
176
182
  rows?: number | undefined;
177
183
  cols?: number | undefined;
@@ -180,10 +186,14 @@ type DatasetBlock<T> = Dataset<T> & {
180
186
  /** Builds a sheet from `{ columns, data }`. */
181
187
  export declare function fromDataset<T>(dataset: Dataset<T>, options?: DatasetOptions<T>): Sheet;
182
188
  /**
183
- * Stacks several datasets on one sheet (replaces the old xSteps/ySteps).
184
- * Each block starts `gap` empty rows (default 1) below the previous one, or
189
+ * Places several datasets on one sheet (replaces the old xSteps/ySteps).
190
+ * A block with placement 'below' (the default) starts `gap` empty rows
191
+ * (default 1) below the lowest row used by the previous row of blocks, or
185
192
  * `offset.rows` rows when given, and `offset.cols` columns right of the
186
- * origin. Freeze and filter apply to the first block with header rows.
193
+ * origin. A block with placement 'right' starts on the previous block's top
194
+ * row (moved down by `offset.rows`), `gap` empty columns plus `offset.cols`
195
+ * after the previous block's last column. Freeze and filter apply to the
196
+ * first block with header rows.
187
197
  */
188
198
  export declare function fromDatasets(blocks: Array<DatasetBlock<any>>, options?: DatasetOptions<any> & {
189
199
  gap?: number | undefined;
@@ -277,5 +287,5 @@ export declare function encodeRange(r: RangeAddress): string;
277
287
  /** 'A1:C3' or 'A1' → range, normalised so start is top-left. */
278
288
  export declare function decodeRange(ref: string): RangeAddress;
279
289
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
280
- export declare const VERSION = "2.0.0-alpha.5";
290
+ export declare const VERSION = "2.0.0-alpha.7";
281
291
  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 ErrorCode, type ExcelErrorCode, type ExcelErrorOptions, 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, toBlob, toUint8Array };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  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";
2
- import { n as toBlob, r as toUint8Array, t as XLSX_MIME } from "./write-DjgWy1PK.js";
2
+ import { n as toBlob, r as toUint8Array, t as XLSX_MIME } from "./write-DyOq-Efq.js";
3
3
  import { n as serialToDate, t as dateToSerial } from "./dates-BXcSWf9_.js";
4
4
  import { m as mergeStyles, n as validateSheetName, t as sanitizeSheetName } from "./sheet-names-7p-joVsG.js";
5
5
  import { t as resolveColor } from "./colors-B8Nf_xTx.js";
6
6
  import { t as cellText } from "./cells-CrMF8h_t.js";
7
- import { n as fromDatasets, r as toDataset, t as fromDataset } from "./dataset-KeMzHCGl.js";
7
+ import { n as fromDatasets, r as toDataset, t as fromDataset } from "./dataset-GVrEbJwI.js";
8
8
  import { n as isDateFormat, t as BUILTIN_NUM_FMTS } from "./numfmt-DCDrX9P1.js";
9
9
  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";
10
10
  // src/index.ts
11
11
  /** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
12
- const VERSION = "2.0.0-alpha.5";
12
+ const VERSION = "2.0.0-alpha.7";
13
13
  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, isDateFormat, isExcelError, mergeStyles, resolveColor, sanitizeSheetName, serialToDate, toBlob, toDataset, toUint8Array, validateSheetName };
@@ -1,7 +1,7 @@
1
1
  import { r as readCsv } from "./csv-pXfaputs.js";
2
- import { i as toDatasetDetailed } from "./dataset-KeMzHCGl.js";
2
+ import { i as toDatasetDetailed } from "./dataset-GVrEbJwI.js";
3
3
  import { a as LimitError, i as FormatError, o as ValidationError } from "./errors-CvGlfw0E.js";
4
- import { i as readSheetNames, n as detectFormat, r as read } from "./read-LWti17lz.js";
4
+ import { i as readSheetNames, n as detectFormat, r as read } from "./read-DK5URBoq.js";
5
5
  import { n as parseIsoDate, r as toBytes } from "./infer-BR-J9BZa.js";
6
6
  import { a as decodeRange } from "./address-DUn7-5OS.js";
7
7
  import { t as isoDate } from "./iso-date-CXnn-9mT.js";
@@ -386,6 +386,11 @@ function mapColumns(columns, schema, mapping) {
386
386
  };
387
387
  }
388
388
  function applyMapping(dataset, mapping, schema) {
389
+ const { sources: _s, ...result } = applyMappingDetailed(dataset, mapping, schema);
390
+ return result;
391
+ }
392
+ /** @internal applyMapping plus each source column key's key in the rows (columns the mapping drops are absent). */
393
+ function applyMappingDetailed(dataset, mapping, schema) {
389
394
  const fields = fieldsOf(schema);
390
395
  const byKey = new Map(dataset.columns.map((c, i) => [c.key, {
391
396
  ...c,
@@ -456,29 +461,35 @@ function applyMapping(dataset, mapping, schema) {
456
461
  }
457
462
  }
458
463
  const required = fields.filter(([name, spec]) => spec.required && plan.some((p) => p.out === name && p.from !== null)).map(([name]) => name);
464
+ const data = dataset.data.map((row, i) => {
465
+ const out = Object.create(null);
466
+ for (const { out: k, from } of plan) out[k] = from === null ? null : row[from] ?? null;
467
+ for (const name of required) {
468
+ const v = out[name];
469
+ if (v === null || v === void 0 || typeof v === "string" && v.trim() === "") {
470
+ const from = plan.find((p) => p.out === name).from;
471
+ const letter = byKey.get(from)?.letter;
472
+ issues.push({
473
+ row: rowNumbers[i],
474
+ field: name,
475
+ column: from,
476
+ ...letter ? { ref: `${letter}${rowNumbers[i]}` } : {},
477
+ code: "REQUIRED",
478
+ message: `Row ${rowNumbers[i]}: "${name}" is required.`,
479
+ severity: "error"
480
+ });
481
+ }
482
+ }
483
+ return out;
484
+ });
485
+ const sources = /* @__PURE__ */ new Map();
486
+ for (const p of plan) if (p.from !== null) sources.set(p.from, p.out);
459
487
  return {
460
488
  columns,
461
- data: dataset.data.map((row, i) => {
462
- const out = Object.create(null);
463
- for (const { out: k, from } of plan) out[k] = from === null ? null : row[from] ?? null;
464
- for (const name of required) {
465
- const v = out[name];
466
- if (v === null || v === void 0 || typeof v === "string" && v.trim() === "") {
467
- const letter = byKey.get(plan.find((p) => p.out === name).from)?.letter;
468
- issues.push({
469
- row: rowNumbers[i],
470
- field: name,
471
- ...letter ? { ref: `${letter}${rowNumbers[i]}` } : {},
472
- code: "REQUIRED",
473
- message: `Row ${rowNumbers[i]}: "${name}" is required.`,
474
- severity: "error"
475
- });
476
- }
477
- }
478
- return out;
479
- }),
489
+ data,
480
490
  rowNumbers,
481
- issues
491
+ issues,
492
+ sources
482
493
  };
483
494
  }
484
495
  // src/internal/import/types.ts
@@ -740,6 +751,7 @@ function coerceColumns(dataset, types, options = {}) {
740
751
  issues.push({
741
752
  row: rowNumber,
742
753
  field: column.key,
754
+ column: column.key,
743
755
  ...column.letter ? { ref: `${column.letter}${rowNumber}` } : {},
744
756
  code: "TYPE",
745
757
  message: `${column.letter ? `${column.letter}${rowNumber}` : `Row ${rowNumber}`}: ${JSON.stringify(String(textOf(row[column.key]) ?? row[column.key]))} is not a ${spec.type}.`,
@@ -783,6 +795,30 @@ function readCap(options) {
783
795
  const h = options.header ?? "auto";
784
796
  return (h === false ? 0 : typeof h === "number" ? h + 1 : typeof h === "object" ? (h.row === void 0 ? 25 : h.row) + h.rows : 25) + rows + 1;
785
797
  }
798
+ /**
799
+ * Issues after mapping: `field` becomes the key in the rows, issues on
800
+ * columns the mapping drops go, and a cell with a TYPE issue gets no
801
+ * REQUIRED issue as well (its value didn't convert; it wasn't empty).
802
+ */
803
+ function renameIssues(issues, sources) {
804
+ const cell = (row, column) => `${row}\u0000${column}`;
805
+ const typed = new Set(issues.filter((i) => i.code === "TYPE" && i.column !== void 0).map((i) => cell(i.row, i.column)));
806
+ const out = [];
807
+ for (const i of issues) {
808
+ if (i.column === void 0) {
809
+ out.push(i);
810
+ continue;
811
+ }
812
+ const field = sources.get(i.column);
813
+ if (field === void 0) continue;
814
+ if (i.code === "REQUIRED" && typed.has(cell(i.row, i.column))) continue;
815
+ out.push(i.field === field ? i : {
816
+ ...i,
817
+ field
818
+ });
819
+ }
820
+ return out;
821
+ }
786
822
  async function importDataset(input, options = {}) {
787
823
  const o = options;
788
824
  checkEnum("format", o.format, [
@@ -997,6 +1033,7 @@ async function importDataset(input, options = {}) {
997
1033
  issues.push({
998
1034
  row: rowNumbers[i],
999
1035
  field: c.key,
1036
+ column: c.key,
1000
1037
  ref,
1001
1038
  code: "ERROR_CELL",
1002
1039
  message: `${ref} holds the error ${v.error}; read as empty.`,
@@ -1047,6 +1084,7 @@ async function importDataset(input, options = {}) {
1047
1084
  if (inf.ambiguousDates) issues.push({
1048
1085
  row: 0,
1049
1086
  field: inf.key,
1087
+ column: inf.key,
1050
1088
  code: "DATE_ORDER_AMBIGUOUS",
1051
1089
  message: `Column "${inf.key}" looks like dates, but the day/month order can't be told from the data; set locale.dateOrder.`,
1052
1090
  severity: "warning"
@@ -1067,13 +1105,14 @@ async function importDataset(input, options = {}) {
1067
1105
  progress("dataset", .97);
1068
1106
  let result;
1069
1107
  if (mapped) {
1070
- const m = applyMapping({
1108
+ const { sources, ...m } = applyMappingDetailed({
1071
1109
  columns: typedColumns,
1072
1110
  data: coerced.data,
1073
1111
  rowNumbers
1074
1112
  }, mapped.mapping, o.schema);
1075
1113
  issues.push(...m.issues);
1076
1114
  result = m;
1115
+ issues.splice(0, issues.length, ...renameIssues(issues, sources));
1077
1116
  meta.mapping = mapped.mapping;
1078
1117
  meta.unmappedColumns = mapped.unmapped;
1079
1118
  } else result = {
@@ -60,7 +60,10 @@ type ImportIssueCode = "TYPE" | "REQUIRED" | "MAPPING_MISSING" | "ERROR_CELL" |
60
60
  interface ImportIssue {
61
61
  /** Spreadsheet row (1-based); 0 for column- or file-level issues. */
62
62
  row: number;
63
+ /** The key the value has in `data` rows: the schema field with a schema, the column key without one. */
63
64
  field?: string | undefined;
65
+ /** The source column's key, for cell- and column-level issues. */
66
+ column?: string | undefined;
64
67
  ref?: string | undefined;
65
68
  code: ImportIssueCode;
66
69
  message: string;
@@ -1,7 +1,7 @@
1
1
  const require_csv = require("./csv-DyVH9y7S.cjs");
2
- const require_dataset = require("./dataset-UUZCzsi3.cjs");
2
+ const require_dataset = require("./dataset-CLc6y5j8.cjs");
3
3
  const require_errors = require("./errors-DOPrrGS4.cjs");
4
- const require_read = require("./read-CZEWV4rK.cjs");
4
+ const require_read = require("./read-tIwYuXES.cjs");
5
5
  const require_infer = require("./infer-D9EC9vJ-.cjs");
6
6
  const require_address = require("./address-DZBHchLv.cjs");
7
7
  const require_iso_date = require("./iso-date-3TY1OlGd.cjs");
@@ -386,6 +386,11 @@ function mapColumns(columns, schema, mapping) {
386
386
  };
387
387
  }
388
388
  function applyMapping(dataset, mapping, schema) {
389
+ const { sources: _s, ...result } = applyMappingDetailed(dataset, mapping, schema);
390
+ return result;
391
+ }
392
+ /** @internal applyMapping plus each source column key's key in the rows (columns the mapping drops are absent). */
393
+ function applyMappingDetailed(dataset, mapping, schema) {
389
394
  const fields = fieldsOf(schema);
390
395
  const byKey = new Map(dataset.columns.map((c, i) => [c.key, {
391
396
  ...c,
@@ -456,29 +461,35 @@ function applyMapping(dataset, mapping, schema) {
456
461
  }
457
462
  }
458
463
  const required = fields.filter(([name, spec]) => spec.required && plan.some((p) => p.out === name && p.from !== null)).map(([name]) => name);
464
+ const data = dataset.data.map((row, i) => {
465
+ const out = Object.create(null);
466
+ for (const { out: k, from } of plan) out[k] = from === null ? null : row[from] ?? null;
467
+ for (const name of required) {
468
+ const v = out[name];
469
+ if (v === null || v === void 0 || typeof v === "string" && v.trim() === "") {
470
+ const from = plan.find((p) => p.out === name).from;
471
+ const letter = byKey.get(from)?.letter;
472
+ issues.push({
473
+ row: rowNumbers[i],
474
+ field: name,
475
+ column: from,
476
+ ...letter ? { ref: `${letter}${rowNumbers[i]}` } : {},
477
+ code: "REQUIRED",
478
+ message: `Row ${rowNumbers[i]}: "${name}" is required.`,
479
+ severity: "error"
480
+ });
481
+ }
482
+ }
483
+ return out;
484
+ });
485
+ const sources = /* @__PURE__ */ new Map();
486
+ for (const p of plan) if (p.from !== null) sources.set(p.from, p.out);
459
487
  return {
460
488
  columns,
461
- data: dataset.data.map((row, i) => {
462
- const out = Object.create(null);
463
- for (const { out: k, from } of plan) out[k] = from === null ? null : row[from] ?? null;
464
- for (const name of required) {
465
- const v = out[name];
466
- if (v === null || v === void 0 || typeof v === "string" && v.trim() === "") {
467
- const letter = byKey.get(plan.find((p) => p.out === name).from)?.letter;
468
- issues.push({
469
- row: rowNumbers[i],
470
- field: name,
471
- ...letter ? { ref: `${letter}${rowNumbers[i]}` } : {},
472
- code: "REQUIRED",
473
- message: `Row ${rowNumbers[i]}: "${name}" is required.`,
474
- severity: "error"
475
- });
476
- }
477
- }
478
- return out;
479
- }),
489
+ data,
480
490
  rowNumbers,
481
- issues
491
+ issues,
492
+ sources
482
493
  };
483
494
  }
484
495
  // src/internal/import/types.ts
@@ -740,6 +751,7 @@ function coerceColumns(dataset, types, options = {}) {
740
751
  issues.push({
741
752
  row: rowNumber,
742
753
  field: column.key,
754
+ column: column.key,
743
755
  ...column.letter ? { ref: `${column.letter}${rowNumber}` } : {},
744
756
  code: "TYPE",
745
757
  message: `${column.letter ? `${column.letter}${rowNumber}` : `Row ${rowNumber}`}: ${JSON.stringify(String(textOf(row[column.key]) ?? row[column.key]))} is not a ${spec.type}.`,
@@ -783,6 +795,30 @@ function readCap(options) {
783
795
  const h = options.header ?? "auto";
784
796
  return (h === false ? 0 : typeof h === "number" ? h + 1 : typeof h === "object" ? (h.row === void 0 ? 25 : h.row) + h.rows : 25) + rows + 1;
785
797
  }
798
+ /**
799
+ * Issues after mapping: `field` becomes the key in the rows, issues on
800
+ * columns the mapping drops go, and a cell with a TYPE issue gets no
801
+ * REQUIRED issue as well (its value didn't convert; it wasn't empty).
802
+ */
803
+ function renameIssues(issues, sources) {
804
+ const cell = (row, column) => `${row}\u0000${column}`;
805
+ const typed = new Set(issues.filter((i) => i.code === "TYPE" && i.column !== void 0).map((i) => cell(i.row, i.column)));
806
+ const out = [];
807
+ for (const i of issues) {
808
+ if (i.column === void 0) {
809
+ out.push(i);
810
+ continue;
811
+ }
812
+ const field = sources.get(i.column);
813
+ if (field === void 0) continue;
814
+ if (i.code === "REQUIRED" && typed.has(cell(i.row, i.column))) continue;
815
+ out.push(i.field === field ? i : {
816
+ ...i,
817
+ field
818
+ });
819
+ }
820
+ return out;
821
+ }
786
822
  async function importDataset(input, options = {}) {
787
823
  const o = options;
788
824
  checkEnum("format", o.format, [
@@ -997,6 +1033,7 @@ async function importDataset(input, options = {}) {
997
1033
  issues.push({
998
1034
  row: rowNumbers[i],
999
1035
  field: c.key,
1036
+ column: c.key,
1000
1037
  ref,
1001
1038
  code: "ERROR_CELL",
1002
1039
  message: `${ref} holds the error ${v.error}; read as empty.`,
@@ -1047,6 +1084,7 @@ async function importDataset(input, options = {}) {
1047
1084
  if (inf.ambiguousDates) issues.push({
1048
1085
  row: 0,
1049
1086
  field: inf.key,
1087
+ column: inf.key,
1050
1088
  code: "DATE_ORDER_AMBIGUOUS",
1051
1089
  message: `Column "${inf.key}" looks like dates, but the day/month order can't be told from the data; set locale.dateOrder.`,
1052
1090
  severity: "warning"
@@ -1067,13 +1105,14 @@ async function importDataset(input, options = {}) {
1067
1105
  progress("dataset", .97);
1068
1106
  let result;
1069
1107
  if (mapped) {
1070
- const m = applyMapping({
1108
+ const { sources, ...m } = applyMappingDetailed({
1071
1109
  columns: typedColumns,
1072
1110
  data: coerced.data,
1073
1111
  rowNumbers
1074
1112
  }, mapped.mapping, o.schema);
1075
1113
  issues.push(...m.issues);
1076
1114
  result = m;
1115
+ issues.splice(0, issues.length, ...renameIssues(issues, sources));
1077
1116
  meta.mapping = mapped.mapping;
1078
1117
  meta.unmappedColumns = mapped.unmapped;
1079
1118
  } else result = {
@@ -60,7 +60,10 @@ type ImportIssueCode = "TYPE" | "REQUIRED" | "MAPPING_MISSING" | "ERROR_CELL" |
60
60
  interface ImportIssue {
61
61
  /** Spreadsheet row (1-based); 0 for column- or file-level issues. */
62
62
  row: number;
63
+ /** The key the value has in `data` rows: the schema field with a schema, the column key without one. */
63
64
  field?: string | undefined;
65
+ /** The source column's key, for cell- and column-level issues. */
66
+ column?: string | undefined;
64
67
  ref?: string | undefined;
65
68
  code: ImportIssueCode;
66
69
  message: string;
@@ -1,6 +1,6 @@
1
1
  import { n as parseIsoDate, r as toBytes } from "./infer-BR-J9BZa.js";
2
2
  import { a as LimitError, i as FormatError } from "./errors-CvGlfw0E.js";
3
- import { a as decodeUtf8Strict, i as nativeCodec, l as concatBytes, r as crc32, s as throttleProgress, t as fromDosDateTime, u as throwIfAborted$1 } from "./dos-time-dD0z1YWU.js";
3
+ import { a as decodeUtf8Strict, c as throttleProgress, d as throwIfAborted$1, i as nativeCodec, r as crc32, s as createYielder, t as fromDosDateTime, u as concatBytes } from "./dos-time-BsH7f0ef.js";
4
4
  import { n as isDateFormat } from "./numfmt-DCDrX9P1.js";
5
5
  import { n as serialToDate } from "./dates-BXcSWf9_.js";
6
6
  // src/internal/read/limits.ts
@@ -660,6 +660,8 @@ var ReadContext = class {
660
660
  this.onProgress = throttleProgress(onProgress);
661
661
  }
662
662
  onProgress;
663
+ /** Returns to the event loop about every 16 ms between chunks, so a big read does not freeze the page (JSE-24). */
664
+ pause = createYielder();
663
665
  warn(code, message, where) {
664
666
  if (this.warnings.length >= this.limits.maxWarnings) {
665
667
  if (this.dropped++ === 0) {
@@ -718,6 +720,11 @@ var ReadContext = class {
718
720
  } else tok.feed(decoder.decode(chunk, { stream: true }));
719
721
  onChunk?.(chunk.length);
720
722
  this.checkAbort();
723
+ const pause = this.pause();
724
+ if (pause) {
725
+ await pause;
726
+ this.checkAbort();
727
+ }
721
728
  }
722
729
  if (decoder) tok.feed(decoder.decode());
723
730
  tok.end();
@@ -1,6 +1,6 @@
1
1
  const require_infer = require("./infer-D9EC9vJ-.cjs");
2
2
  const require_errors = require("./errors-DOPrrGS4.cjs");
3
- const require_dos_time = require("./dos-time-FZ7-1tot.cjs");
3
+ const require_dos_time = require("./dos-time-CxEs--rI.cjs");
4
4
  const require_numfmt = require("./numfmt-BmEbm78Y.cjs");
5
5
  const require_dates = require("./dates-CA1dCizp.cjs");
6
6
  // src/internal/read/limits.ts
@@ -660,6 +660,8 @@ var ReadContext = class {
660
660
  this.onProgress = require_dos_time.throttleProgress(onProgress);
661
661
  }
662
662
  onProgress;
663
+ /** Returns to the event loop about every 16 ms between chunks, so a big read does not freeze the page (JSE-24). */
664
+ pause = require_dos_time.createYielder();
663
665
  warn(code, message, where) {
664
666
  if (this.warnings.length >= this.limits.maxWarnings) {
665
667
  if (this.dropped++ === 0) {
@@ -718,6 +720,11 @@ var ReadContext = class {
718
720
  } else tok.feed(decoder.decode(chunk, { stream: true }));
719
721
  onChunk?.(chunk.length);
720
722
  this.checkAbort();
723
+ const pause = this.pause();
724
+ if (pause) {
725
+ await pause;
726
+ this.checkAbort();
727
+ }
721
728
  }
722
729
  if (decoder) tok.feed(decoder.decode());
723
730
  tok.end();
package/dist/read.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_read = require("./read-CZEWV4rK.cjs");
2
+ const require_read = require("./read-tIwYuXES.cjs");
3
3
  exports.DEFAULT_READ_LIMITS = require_read.DEFAULT_READ_LIMITS;
4
4
  exports.detectFormat = require_read.detectFormat;
5
5
  exports.read = require_read.read;
package/dist/read.js CHANGED
@@ -1 +1 @@
1
- export { t as DEFAULT_READ_LIMITS, n as detectFormat, r as read, i as readSheetNames } from "./read-LWti17lz.js";
1
+ export { t as DEFAULT_READ_LIMITS, n as detectFormat, r as read, i as readSheetNames } from "./read-DK5URBoq.js";
package/dist/worker.cjs CHANGED
@@ -1,9 +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-CZEWV4rK.cjs");
5
- const require_pipeline = require("./pipeline-BV2q-khO.cjs");
6
- const require_write = require("./write-f9kcYf5K.cjs");
4
+ const require_read = require("./read-tIwYuXES.cjs");
5
+ const require_pipeline = require("./pipeline-CwLNDrKo.cjs");
6
+ const require_write = require("./write-CXnhqht-.cjs");
7
7
  // src/worker.ts
8
8
  /** Marks the library's messages, so an app can use the same worker for its own messages too. */
9
9
  const TAG = "javascript-excel/worker@1";
package/dist/worker.d.cts CHANGED
@@ -25,7 +25,7 @@ import { r as BinaryInput } from "./warnings-B1v58nCZ.cjs";
25
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.cjs";
26
26
  import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.cjs";
27
27
  import { ReadOptions, ReadResult } from "./read.cjs";
28
- import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-CctEa86r.cjs";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-DM7n0aRI.cjs";
29
29
  import { n as WriteOptions, t as Progress } from "./write-DtjfdIFm.cjs";
30
30
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
31
31
  /** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
package/dist/worker.d.ts CHANGED
@@ -25,7 +25,7 @@ import { r as BinaryInput } from "./warnings-B1v58nCZ.js";
25
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.js";
26
26
  import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.js";
27
27
  import { ReadOptions, ReadResult } from "./read.js";
28
- import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-I8SLmV9S.js";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-BuG_nn_S.js";
29
29
  import { n as WriteOptions, t as Progress } from "./write-DM6ieuQY.js";
30
30
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
31
31
  /** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
package/dist/worker.js CHANGED
@@ -1,8 +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-LWti17lz.js";
4
- import { t as importDataset } from "./pipeline-Snu8wBXd.js";
5
- import { r as toUint8Array } from "./write-DjgWy1PK.js";
3
+ import { r as read } from "./read-DK5URBoq.js";
4
+ import { t as importDataset } from "./pipeline-B9-qglvn.js";
5
+ import { r as toUint8Array } from "./write-DyOq-Efq.js";
6
6
  // src/worker.ts
7
7
  /** Marks the library's messages, so an app can use the same worker for its own messages too. */
8
8
  const TAG = "javascript-excel/worker@1";
@@ -1,5 +1,5 @@
1
1
  const require_errors = require("./errors-DOPrrGS4.cjs");
2
- const require_dos_time = require("./dos-time-FZ7-1tot.cjs");
2
+ const require_dos_time = require("./dos-time-CxEs--rI.cjs");
3
3
  const require_sheet_names = require("./sheet-names-B8U5RAW0.cjs");
4
4
  const require_address = require("./address-DZBHchLv.cjs");
5
5
  const require_dates = require("./dates-CA1dCizp.cjs");
@@ -1346,6 +1346,7 @@ async function toUint8Array(wb, options = {}) {
1346
1346
  dateZone: options.dateZone ?? "local",
1347
1347
  formulaWithoutValue: false
1348
1348
  };
1349
+ const yieldNow = require_dos_time.createYielder();
1349
1350
  let rowsDone = 0;
1350
1351
  let lastReported = 0;
1351
1352
  const ratioOf = () => plan.totalRows === 0 ? .9 : .9 * (rowsDone / plan.totalRows);
@@ -1395,6 +1396,11 @@ async function toUint8Array(wb, options = {}) {
1395
1396
  data: (async function* () {
1396
1397
  for await (const chunk of chunks) {
1397
1398
  require_dos_time.throwIfAborted(signal);
1399
+ const pause = yieldNow();
1400
+ if (pause) {
1401
+ await pause;
1402
+ require_dos_time.throwIfAborted(signal);
1403
+ }
1398
1404
  yield chunk;
1399
1405
  }
1400
1406
  })()
@@ -1416,6 +1422,11 @@ async function toUint8Array(wb, options = {}) {
1416
1422
  data: (async function* () {
1417
1423
  for (const chunk of strings.chunks()) {
1418
1424
  require_dos_time.throwIfAborted(signal);
1425
+ const pause = yieldNow();
1426
+ if (pause) {
1427
+ await pause;
1428
+ require_dos_time.throwIfAborted(signal);
1429
+ }
1419
1430
  yield chunk;
1420
1431
  }
1421
1432
  })()
@@ -1,5 +1,5 @@
1
1
  import { n as EnvironmentError, o as ValidationError } from "./errors-CvGlfw0E.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";
2
+ import { c as throttleProgress, d as throwIfAborted, i as nativeCodec, l as ByteWriter, n as toDosDateTime, o as encodeUtf8, r as crc32, s as createYielder, u as concatBytes } from "./dos-time-BsH7f0ef.js";
3
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
4
  import { a as decodeRange, n as MAX_ROWS, s as encodeCol } from "./address-DUn7-5OS.js";
5
5
  import { t as dateToSerial } from "./dates-BXcSWf9_.js";
@@ -1346,6 +1346,7 @@ async function toUint8Array(wb, options = {}) {
1346
1346
  dateZone: options.dateZone ?? "local",
1347
1347
  formulaWithoutValue: false
1348
1348
  };
1349
+ const yieldNow = createYielder();
1349
1350
  let rowsDone = 0;
1350
1351
  let lastReported = 0;
1351
1352
  const ratioOf = () => plan.totalRows === 0 ? .9 : .9 * (rowsDone / plan.totalRows);
@@ -1395,6 +1396,11 @@ async function toUint8Array(wb, options = {}) {
1395
1396
  data: (async function* () {
1396
1397
  for await (const chunk of chunks) {
1397
1398
  throwIfAborted(signal);
1399
+ const pause = yieldNow();
1400
+ if (pause) {
1401
+ await pause;
1402
+ throwIfAborted(signal);
1403
+ }
1398
1404
  yield chunk;
1399
1405
  }
1400
1406
  })()
@@ -1416,6 +1422,11 @@ async function toUint8Array(wb, options = {}) {
1416
1422
  data: (async function* () {
1417
1423
  for (const chunk of strings.chunks()) {
1418
1424
  throwIfAborted(signal);
1425
+ const pause = yieldNow();
1426
+ if (pause) {
1427
+ await pause;
1428
+ throwIfAborted(signal);
1429
+ }
1419
1430
  yield chunk;
1420
1431
  }
1421
1432
  })()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-excel",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.7",
4
4
  "private": false,
5
5
  "description": "Read and write .xlsx and .csv files in browsers, Web Workers and Node. 2.0 is a from-scratch rewrite in progress.",
6
6
  "keywords": [