javascript-excel 2.0.0-alpha.6 → 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.
@@ -500,10 +500,14 @@ function fromDataset(dataset, options = {}) {
500
500
  return finish(g, options, layoutBlock(g, dataset, options, origin.row, origin.col, name), name);
501
501
  }
502
502
  /**
503
- * Stacks several datasets on one sheet (replaces the old xSteps/ySteps).
504
- * Each block starts `gap` empty rows (default 1) below the previous one, or
503
+ * Places several datasets on one sheet (replaces the old xSteps/ySteps).
504
+ * A block with placement 'below' (the default) starts `gap` empty rows
505
+ * (default 1) below the lowest row used by the previous row of blocks, or
505
506
  * `offset.rows` rows when given, and `offset.cols` columns right of the
506
- * origin. Freeze and filter apply to the first block with header rows.
507
+ * origin. A block with placement 'right' starts on the previous block's top
508
+ * row (moved down by `offset.rows`), `gap` empty columns plus `offset.cols`
509
+ * after the previous block's last column. Freeze and filter apply to the
510
+ * first block with header rows.
507
511
  */
508
512
  function fromDatasets(blocks, options = {}) {
509
513
  if (!Array.isArray(blocks)) throw columnError("fromDatasets needs an array of datasets.");
@@ -513,14 +517,33 @@ function fromDatasets(blocks, options = {}) {
513
517
  if (!Number.isInteger(gap) || gap < 0) throw columnError(`gap must be a non-negative integer, got ${String(gap)}.`);
514
518
  const g = newGrid();
515
519
  let first;
516
- let nextRow = origin.row;
520
+ let prev;
521
+ let bottom = origin.row - 1;
517
522
  blocks.forEach((block, i) => {
523
+ const placement = block?.placement ?? "below";
524
+ if (placement !== "below" && placement !== "right") throw columnError(`placement must be 'below' or 'right', got ${JSON.stringify(placement)}.`, {
525
+ block: i,
526
+ placement
527
+ });
518
528
  const offRows = block.offset?.rows;
519
529
  const offCols = block.offset?.cols ?? 0;
520
- const top = i === 0 ? origin.row + (offRows ?? 0) : nextRow + (offRows ?? gap);
521
- const result = layoutBlock(g, block, options, top, origin.col + offCols, name);
530
+ let top;
531
+ let left;
532
+ if (prev && placement === "right") {
533
+ top = prev.top + (offRows ?? 0);
534
+ left = prev.lastCol + 1 + gap + offCols;
535
+ } else {
536
+ top = i === 0 ? origin.row + (offRows ?? 0) : bottom + 1 + (offRows ?? gap);
537
+ left = origin.col + offCols;
538
+ bottom = top - 1;
539
+ }
540
+ const result = layoutBlock(g, block, options, top, left, name);
522
541
  if (!first && result.headerRows > 0) first = result;
523
- nextRow = result.lastRow + 1;
542
+ prev = {
543
+ top,
544
+ lastCol: result.lastCol
545
+ };
546
+ bottom = Math.max(bottom, result.lastRow);
524
547
  });
525
548
  return finish(g, options, first, name);
526
549
  }
@@ -500,10 +500,14 @@ function fromDataset(dataset, options = {}) {
500
500
  return finish(g, options, layoutBlock(g, dataset, options, origin.row, origin.col, name), name);
501
501
  }
502
502
  /**
503
- * Stacks several datasets on one sheet (replaces the old xSteps/ySteps).
504
- * Each block starts `gap` empty rows (default 1) below the previous one, or
503
+ * Places several datasets on one sheet (replaces the old xSteps/ySteps).
504
+ * A block with placement 'below' (the default) starts `gap` empty rows
505
+ * (default 1) below the lowest row used by the previous row of blocks, or
505
506
  * `offset.rows` rows when given, and `offset.cols` columns right of the
506
- * origin. Freeze and filter apply to the first block with header rows.
507
+ * origin. A block with placement 'right' starts on the previous block's top
508
+ * row (moved down by `offset.rows`), `gap` empty columns plus `offset.cols`
509
+ * after the previous block's last column. Freeze and filter apply to the
510
+ * first block with header rows.
507
511
  */
508
512
  function fromDatasets(blocks, options = {}) {
509
513
  if (!Array.isArray(blocks)) throw columnError("fromDatasets needs an array of datasets.");
@@ -513,14 +517,33 @@ function fromDatasets(blocks, options = {}) {
513
517
  if (!Number.isInteger(gap) || gap < 0) throw columnError(`gap must be a non-negative integer, got ${String(gap)}.`);
514
518
  const g = newGrid();
515
519
  let first;
516
- let nextRow = origin.row;
520
+ let prev;
521
+ let bottom = origin.row - 1;
517
522
  blocks.forEach((block, i) => {
523
+ const placement = block?.placement ?? "below";
524
+ if (placement !== "below" && placement !== "right") throw columnError(`placement must be 'below' or 'right', got ${JSON.stringify(placement)}.`, {
525
+ block: i,
526
+ placement
527
+ });
518
528
  const offRows = block.offset?.rows;
519
529
  const offCols = block.offset?.cols ?? 0;
520
- const top = i === 0 ? origin.row + (offRows ?? 0) : nextRow + (offRows ?? gap);
521
- const result = layoutBlock(g, block, options, top, origin.col + offCols, name);
530
+ let top;
531
+ let left;
532
+ if (prev && placement === "right") {
533
+ top = prev.top + (offRows ?? 0);
534
+ left = prev.lastCol + 1 + gap + offCols;
535
+ } else {
536
+ top = i === 0 ? origin.row + (offRows ?? 0) : bottom + 1 + (offRows ?? gap);
537
+ left = origin.col + offCols;
538
+ bottom = top - 1;
539
+ }
540
+ const result = layoutBlock(g, block, options, top, left, name);
522
541
  if (!first && result.headerRows > 0) first = result;
523
- nextRow = result.lastRow + 1;
542
+ prev = {
543
+ top,
544
+ lastCol: result.lastCol
545
+ };
546
+ bottom = Math.max(bottom, result.lastRow);
524
547
  });
525
548
  return finish(g, options, first, name);
526
549
  }
@@ -64,6 +64,36 @@ function throttleProgress(cb, intervalMs = 50) {
64
64
  cb(out);
65
65
  };
66
66
  }
67
+ function macrotask() {
68
+ const g = globalThis;
69
+ const si = g.setImmediate;
70
+ if (typeof si === "function") return () => new Promise((r) => void si(r));
71
+ const MC = g.MessageChannel;
72
+ if (typeof MC === "function") return () => new Promise((r) => {
73
+ const ch = new MC();
74
+ ch.port1.onmessage = () => {
75
+ ch.port1.close();
76
+ r();
77
+ };
78
+ ch.port2.postMessage(null);
79
+ });
80
+ const st = g.setTimeout;
81
+ if (typeof st === "function") return () => new Promise((r) => void st(r, 0));
82
+ return () => Promise.resolve();
83
+ }
84
+ /** A check to await between chunks of work: yields a macrotask once `budgetMs` has passed. */
85
+ function createYielder(budgetMs = 16) {
86
+ const perf = globalThis.performance;
87
+ const now = perf && typeof perf.now === "function" ? () => perf.now() : () => Date.now();
88
+ const wait = macrotask();
89
+ let last = now();
90
+ return () => {
91
+ if (now() - last < budgetMs) return void 0;
92
+ return wait().then(() => {
93
+ last = now();
94
+ });
95
+ };
96
+ }
67
97
  // src/internal/platform.ts
68
98
  /**
69
99
  * Minimal structural types for the web platform APIs the engine uses.
@@ -108,6 +138,8 @@ function decodeUtf8Strict(bytes) {
108
138
  return strictDecoder.decode(bytes);
109
139
  }
110
140
  const ignore = () => {};
141
+ /** Compressed bytes written to the decompressor at a time. */
142
+ const INFLATE_SLICE = 262144;
111
143
  async function deflateRaw(chunks, signal) {
112
144
  throwIfAborted(signal);
113
145
  const stream = createStream("compress");
@@ -142,7 +174,10 @@ async function* inflateRaw(data, limits, signal) {
142
174
  const stream = createStream("decompress");
143
175
  const writer = stream.writable.getWriter();
144
176
  const reader = stream.readable.getReader();
145
- const writing = writer.write(data).then(() => writer.close());
177
+ const writing = (async () => {
178
+ for (let at = 0; at < data.length; at += INFLATE_SLICE) await writer.write(data.subarray(at, at + INFLATE_SLICE));
179
+ await writer.close();
180
+ })();
146
181
  writing.catch(ignore);
147
182
  let produced = 0;
148
183
  let finished = false;
@@ -251,4 +286,4 @@ function fromDosDateTime(date, time) {
251
286
  const day = Math.max(1, date & 31);
252
287
  return new Date(Date.UTC(year, month, day, time >>> 11, time >>> 5 & 63, (time & 31) * 2));
253
288
  }
254
- export { decodeUtf8Strict as a, ByteWriter as c, nativeCodec as i, concatBytes as l, toDosDateTime as n, encodeUtf8 as o, crc32 as r, throttleProgress as s, fromDosDateTime as t, throwIfAborted as u };
289
+ export { decodeUtf8Strict as a, throttleProgress as c, throwIfAborted as d, nativeCodec as i, ByteWriter as l, toDosDateTime as n, encodeUtf8 as o, crc32 as r, createYielder as s, fromDosDateTime as t, concatBytes as u };
@@ -64,6 +64,36 @@ function throttleProgress(cb, intervalMs = 50) {
64
64
  cb(out);
65
65
  };
66
66
  }
67
+ function macrotask() {
68
+ const g = globalThis;
69
+ const si = g.setImmediate;
70
+ if (typeof si === "function") return () => new Promise((r) => void si(r));
71
+ const MC = g.MessageChannel;
72
+ if (typeof MC === "function") return () => new Promise((r) => {
73
+ const ch = new MC();
74
+ ch.port1.onmessage = () => {
75
+ ch.port1.close();
76
+ r();
77
+ };
78
+ ch.port2.postMessage(null);
79
+ });
80
+ const st = g.setTimeout;
81
+ if (typeof st === "function") return () => new Promise((r) => void st(r, 0));
82
+ return () => Promise.resolve();
83
+ }
84
+ /** A check to await between chunks of work: yields a macrotask once `budgetMs` has passed. */
85
+ function createYielder(budgetMs = 16) {
86
+ const perf = globalThis.performance;
87
+ const now = perf && typeof perf.now === "function" ? () => perf.now() : () => Date.now();
88
+ const wait = macrotask();
89
+ let last = now();
90
+ return () => {
91
+ if (now() - last < budgetMs) return void 0;
92
+ return wait().then(() => {
93
+ last = now();
94
+ });
95
+ };
96
+ }
67
97
  // src/internal/platform.ts
68
98
  /**
69
99
  * Minimal structural types for the web platform APIs the engine uses.
@@ -108,6 +138,8 @@ function decodeUtf8Strict(bytes) {
108
138
  return strictDecoder.decode(bytes);
109
139
  }
110
140
  const ignore = () => {};
141
+ /** Compressed bytes written to the decompressor at a time. */
142
+ const INFLATE_SLICE = 262144;
111
143
  async function deflateRaw(chunks, signal) {
112
144
  throwIfAborted(signal);
113
145
  const stream = createStream("compress");
@@ -142,7 +174,10 @@ async function* inflateRaw(data, limits, signal) {
142
174
  const stream = createStream("decompress");
143
175
  const writer = stream.writable.getWriter();
144
176
  const reader = stream.readable.getReader();
145
- const writing = writer.write(data).then(() => writer.close());
177
+ const writing = (async () => {
178
+ for (let at = 0; at < data.length; at += INFLATE_SLICE) await writer.write(data.subarray(at, at + INFLATE_SLICE));
179
+ await writer.close();
180
+ })();
146
181
  writing.catch(ignore);
147
182
  let produced = 0;
148
183
  let finished = false;
@@ -269,6 +304,12 @@ Object.defineProperty(exports, "crc32", {
269
304
  return crc32;
270
305
  }
271
306
  });
307
+ Object.defineProperty(exports, "createYielder", {
308
+ enumerable: true,
309
+ get: function() {
310
+ return createYielder;
311
+ }
312
+ });
272
313
  Object.defineProperty(exports, "decodeUtf8Strict", {
273
314
  enumerable: true,
274
315
  get: function() {
package/dist/import.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_pipeline = require("./pipeline-DwJjPL7r.cjs");
2
+ const require_pipeline = require("./pipeline-CwLNDrKo.cjs");
3
3
  exports.applyMapping = require_pipeline.applyMapping;
4
4
  exports.coerceColumns = require_pipeline.coerceColumns;
5
5
  exports.detectHeader = require_pipeline.detectHeader;
package/dist/import.js CHANGED
@@ -1 +1 @@
1
- export { i as applyMapping, n as coerceColumns, o as detectHeader, t as importDataset, r as inferColumnTypes, a as mapColumns, s as parseDate, c as parseNumber } from "./pipeline-DyWvM9t2.js";
1
+ export { i as applyMapping, n as coerceColumns, o as detectHeader, t as importDataset, r as inferColumnTypes, a as mapColumns, s as parseDate, c as parseNumber } from "./pipeline-B9-qglvn.js";
package/dist/index.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors = require("./errors-DOPrrGS4.cjs");
3
- const require_write = require("./write-f9kcYf5K.cjs");
3
+ const require_write = require("./write-CXnhqht-.cjs");
4
4
  const require_dates = require("./dates-CA1dCizp.cjs");
5
5
  const require_sheet_names = require("./sheet-names-B8U5RAW0.cjs");
6
6
  const require_colors = require("./colors-oBpjx97l.cjs");
7
7
  const require_cells = require("./cells-CPXU722t.cjs");
8
- const require_dataset = require("./dataset-UUZCzsi3.cjs");
8
+ const require_dataset = require("./dataset-CLc6y5j8.cjs");
9
9
  const require_numfmt = require("./numfmt-BmEbm78Y.cjs");
10
10
  const require_address = require("./address-DZBHchLv.cjs");
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.0.0-alpha.6";
13
+ const VERSION = "2.0.0-alpha.7";
14
14
  exports.BUILTIN_NUM_FMTS = require_numfmt.BUILTIN_NUM_FMTS;
15
15
  exports.CsvError = require_errors.CsvError;
16
16
  exports.EnvironmentError = require_errors.EnvironmentError;
package/dist/index.d.cts 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.6";
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.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.6";
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.6";
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";
@@ -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");
@@ -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-DwJjPL7r.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.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-DyWvM9t2.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.6",
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": [