javascript-excel 2.0.0 → 2.1.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 +9 -1
- package/dist/{auto-width-DRHsPKNk.d.cts → auto-width-DZvQSucm.d.cts} +1 -1
- package/dist/{csv-pXfaputs.js → csv-CrWF7JS1.js} +57 -13
- package/dist/{csv-DyVH9y7S.cjs → csv-DzGOFyHs.cjs} +57 -13
- package/dist/csv.cjs +3 -1
- package/dist/csv.d.cts +23 -5
- package/dist/csv.d.ts +23 -5
- package/dist/csv.js +3 -1
- package/dist/dom.cjs +2 -0
- package/dist/dom.d.cts +4 -4
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +2 -1
- package/dist/format.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/import.cjs +3 -1
- package/dist/import.d.cts +3 -3
- package/dist/import.d.ts +3 -3
- package/dist/import.js +3 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -2
- package/dist/{infer-D9EC9vJ-.cjs → infer-BniOucP6.cjs} +65 -0
- package/dist/{infer-BR-J9BZa.js → infer-DcUyZ1T-.js} +54 -1
- package/dist/{model-0JikLfuM.d.cts → model-BUNp7B0Z.d.cts} +6 -0
- package/dist/{model-0JikLfuM.d.ts → model-BUNp7B0Z.d.ts} +6 -0
- package/dist/{pipeline-BuG_nn_S.d.ts → pipeline-6PmlmH1-.d.ts} +5 -2
- package/dist/{pipeline-DM7n0aRI.d.cts → pipeline-C63qD7Ym.d.cts} +5 -2
- package/dist/{pipeline-2dw9aehe.js → pipeline-CMealW1i.js} +6 -3
- package/dist/{pipeline-DMskqxiU.cjs → pipeline-Dc15gn1t.cjs} +6 -3
- package/dist/{read-ClszMDAE.js → read-CFQ09LlL.js} +253 -70
- package/dist/{read-ByceXfiL.cjs → read-DYDDLxUE.cjs} +253 -70
- package/dist/read.cjs +3 -1
- package/dist/read.d.cts +34 -6
- package/dist/read.d.ts +34 -6
- package/dist/read.js +3 -1
- package/dist/render.d.cts +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/warnings-BPz1Ia3s.js +42 -0
- package/dist/warnings-CJPiDqei.cjs +47 -0
- package/dist/warnings-DhonqJ7A.d.cts +79 -0
- package/dist/warnings-DhonqJ7A.d.ts +79 -0
- package/dist/worker.cjs +3 -3
- package/dist/worker.d.cts +4 -4
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +3 -3
- package/dist/{write-DM6ieuQY.d.ts → write-BaMv1Z7W.d.ts} +2 -2
- package/dist/{write-DtjfdIFm.d.cts → write-Izl2NG0Y.d.cts} +2 -2
- package/package.json +1 -1
- package/dist/warnings-B1v58nCZ.d.cts +0 -41
- package/dist/warnings-B1v58nCZ.d.ts +0 -41
package/dist/index.d.cts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module javascript-excel
|
|
9
9
|
*/
|
|
10
|
-
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-
|
|
11
|
-
import { a as toUint8Array, i as toBlob, n as WriteOptions, r as XLSX_MIME, t as Progress } from "./write-
|
|
12
|
-
import { a as BlobType, i as
|
|
10
|
+
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-BUNp7B0Z.cjs";
|
|
11
|
+
import { a as toUint8Array, i as toBlob, n as WriteOptions, r as XLSX_MIME, t as Progress } from "./write-Izl2NG0Y.cjs";
|
|
12
|
+
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";
|
|
13
13
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
|
|
14
|
-
import { t as AutoWidthOptions } from "./auto-width-
|
|
14
|
+
import { t as AutoWidthOptions } from "./auto-width-DZvQSucm.cjs";
|
|
15
15
|
/**
|
|
16
16
|
* Typed errors (docs/api.md §7).
|
|
17
17
|
*
|
|
@@ -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.
|
|
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 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 };
|
|
296
|
+
export declare const VERSION = "2.1.0";
|
|
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
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module javascript-excel
|
|
9
9
|
*/
|
|
10
|
-
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-
|
|
11
|
-
import { a as toUint8Array, i as toBlob, n as WriteOptions, r as XLSX_MIME, t as Progress } from "./write-
|
|
12
|
-
import { a as BlobType, i as
|
|
10
|
+
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-BUNp7B0Z.js";
|
|
11
|
+
import { a as toUint8Array, i as toBlob, n as WriteOptions, r as XLSX_MIME, t as Progress } from "./write-BaMv1Z7W.js";
|
|
12
|
+
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";
|
|
13
13
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
|
|
14
14
|
import { t as AutoWidthOptions } from "./auto-width-CT-BihTW.js";
|
|
15
15
|
/**
|
|
@@ -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.
|
|
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 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 };
|
|
296
|
+
export declare const VERSION = "2.1.0";
|
|
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
|
@@ -1,5 +1,6 @@
|
|
|
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
2
|
import { n as toBlob, r as toUint8Array, t as XLSX_MIME } from "./write-BVXB2_2C.js";
|
|
3
|
+
import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
|
|
3
4
|
import { n as serialToDate, t as dateToSerial } from "./dates-BXcSWf9_.js";
|
|
4
5
|
import { m as mergeStyles, n as validateSheetName, t as sanitizeSheetName } from "./sheet-names-BLrwcn33.js";
|
|
5
6
|
import { t as resolveColor } from "./colors-B8Nf_xTx.js";
|
|
@@ -9,5 +10,5 @@ import { n as isDateFormat, t as BUILTIN_NUM_FMTS } from "./numfmt-Ci_oW11p.js";
|
|
|
9
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";
|
|
10
11
|
// src/index.ts
|
|
11
12
|
/** Package version. Set from package.json by `npm run version-packages` (scripts/sync-version.mjs); a unit test checks it. */
|
|
12
|
-
const VERSION = "2.
|
|
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 };
|
|
13
|
+
const VERSION = "2.1.0";
|
|
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 };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_warnings = require("./warnings-CJPiDqei.cjs");
|
|
1
2
|
// src/internal/input.ts
|
|
2
3
|
/** Uint8Array (Node Buffer included), ArrayBuffer, any ArrayBufferView, or a Blob -> Uint8Array. */
|
|
3
4
|
async function toBytes(input, fn, also = "") {
|
|
@@ -10,6 +11,58 @@ async function toBytes(input, fn, also = "") {
|
|
|
10
11
|
}
|
|
11
12
|
throw new TypeError(`${fn}: input must be ${also}a Uint8Array, ArrayBuffer or Blob`);
|
|
12
13
|
}
|
|
14
|
+
// src/internal/warning-cap.ts
|
|
15
|
+
/**
|
|
16
|
+
* The warning cap shared by the xlsx reader and the CSV parser (docs/api.md
|
|
17
|
+
* §7.3). Internal.
|
|
18
|
+
*
|
|
19
|
+
* Until `max` warnings are kept, every warning is kept, as in 2.0.0. After
|
|
20
|
+
* that, informational warnings are dropped, and a data-loss warning is still
|
|
21
|
+
* kept while fewer than DATA_LOSS_PER_CODE of its code have been kept since
|
|
22
|
+
* the start. So the list stays bounded (at most `max`, plus one
|
|
23
|
+
* WARNINGS_TRUNCATED, plus DATA_LOSS_PER_CODE per data-loss code), and every
|
|
24
|
+
* kind of data loss that occurred is in it.
|
|
25
|
+
*/
|
|
26
|
+
var WarningCap = class {
|
|
27
|
+
max;
|
|
28
|
+
warnings = [];
|
|
29
|
+
/** Null until the first drop. */
|
|
30
|
+
dropped = null;
|
|
31
|
+
full = false;
|
|
32
|
+
kept = /* @__PURE__ */ new Map();
|
|
33
|
+
constructor(max) {
|
|
34
|
+
this.max = max;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Keeps or counts `w`. Returns true when it was kept; `firstDrop` is called
|
|
38
|
+
* once, at the first warning that is not.
|
|
39
|
+
*/
|
|
40
|
+
add(w, firstDrop) {
|
|
41
|
+
const loss = require_warnings.isDataLossWarning(w.code);
|
|
42
|
+
if (!this.full && this.warnings.length >= this.max) this.full = true;
|
|
43
|
+
const n = loss ? this.kept.get(w.code) ?? 0 : 0;
|
|
44
|
+
if (this.full && (!loss || n >= 100)) {
|
|
45
|
+
const first = this.dropped === null;
|
|
46
|
+
const d = this.dropped ??= {
|
|
47
|
+
total: 0,
|
|
48
|
+
dataLoss: 0,
|
|
49
|
+
byCode: {}
|
|
50
|
+
};
|
|
51
|
+
d.total++;
|
|
52
|
+
if (loss) d.dataLoss++;
|
|
53
|
+
d.byCode[w.code] = (d.byCode[w.code] ?? 0) + 1;
|
|
54
|
+
if (first) firstDrop?.(d);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (loss) this.kept.set(w.code, n + 1);
|
|
58
|
+
this.warnings.push(w);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/** Validates a `maxWarnings` value as `read` does for `limits.maxWarnings`. */
|
|
63
|
+
function checkMaxWarnings(name, v) {
|
|
64
|
+
if (typeof v !== "number" || !(v > 0)) throw new TypeError(`${name} must be a positive number`);
|
|
65
|
+
}
|
|
13
66
|
// src/internal/csv/infer.ts
|
|
14
67
|
const NUMBER = /^[+-]?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
15
68
|
const FRACTION = /^[+-]?\.\d+(?:[eE][+-]?\d+)?$/;
|
|
@@ -85,6 +138,18 @@ function daysInMonth(y, m) {
|
|
|
85
138
|
if (m === 2) return y % 4 === 0 && y % 100 !== 0 || y % 400 === 0 ? 29 : 28;
|
|
86
139
|
return m === 4 || m === 6 || m === 9 || m === 11 ? 30 : 31;
|
|
87
140
|
}
|
|
141
|
+
Object.defineProperty(exports, "WarningCap", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function() {
|
|
144
|
+
return WarningCap;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(exports, "checkMaxWarnings", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function() {
|
|
150
|
+
return checkMaxWarnings;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
88
153
|
Object.defineProperty(exports, "inferValue", {
|
|
89
154
|
enumerable: true,
|
|
90
155
|
get: function() {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
|
|
1
2
|
// src/internal/input.ts
|
|
2
3
|
/** Uint8Array (Node Buffer included), ArrayBuffer, any ArrayBufferView, or a Blob -> Uint8Array. */
|
|
3
4
|
async function toBytes(input, fn, also = "") {
|
|
@@ -10,6 +11,58 @@ async function toBytes(input, fn, also = "") {
|
|
|
10
11
|
}
|
|
11
12
|
throw new TypeError(`${fn}: input must be ${also}a Uint8Array, ArrayBuffer or Blob`);
|
|
12
13
|
}
|
|
14
|
+
// src/internal/warning-cap.ts
|
|
15
|
+
/**
|
|
16
|
+
* The warning cap shared by the xlsx reader and the CSV parser (docs/api.md
|
|
17
|
+
* §7.3). Internal.
|
|
18
|
+
*
|
|
19
|
+
* Until `max` warnings are kept, every warning is kept, as in 2.0.0. After
|
|
20
|
+
* that, informational warnings are dropped, and a data-loss warning is still
|
|
21
|
+
* kept while fewer than DATA_LOSS_PER_CODE of its code have been kept since
|
|
22
|
+
* the start. So the list stays bounded (at most `max`, plus one
|
|
23
|
+
* WARNINGS_TRUNCATED, plus DATA_LOSS_PER_CODE per data-loss code), and every
|
|
24
|
+
* kind of data loss that occurred is in it.
|
|
25
|
+
*/
|
|
26
|
+
var WarningCap = class {
|
|
27
|
+
max;
|
|
28
|
+
warnings = [];
|
|
29
|
+
/** Null until the first drop. */
|
|
30
|
+
dropped = null;
|
|
31
|
+
full = false;
|
|
32
|
+
kept = /* @__PURE__ */ new Map();
|
|
33
|
+
constructor(max) {
|
|
34
|
+
this.max = max;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Keeps or counts `w`. Returns true when it was kept; `firstDrop` is called
|
|
38
|
+
* once, at the first warning that is not.
|
|
39
|
+
*/
|
|
40
|
+
add(w, firstDrop) {
|
|
41
|
+
const loss = isDataLossWarning(w.code);
|
|
42
|
+
if (!this.full && this.warnings.length >= this.max) this.full = true;
|
|
43
|
+
const n = loss ? this.kept.get(w.code) ?? 0 : 0;
|
|
44
|
+
if (this.full && (!loss || n >= 100)) {
|
|
45
|
+
const first = this.dropped === null;
|
|
46
|
+
const d = this.dropped ??= {
|
|
47
|
+
total: 0,
|
|
48
|
+
dataLoss: 0,
|
|
49
|
+
byCode: {}
|
|
50
|
+
};
|
|
51
|
+
d.total++;
|
|
52
|
+
if (loss) d.dataLoss++;
|
|
53
|
+
d.byCode[w.code] = (d.byCode[w.code] ?? 0) + 1;
|
|
54
|
+
if (first) firstDrop?.(d);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (loss) this.kept.set(w.code, n + 1);
|
|
58
|
+
this.warnings.push(w);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/** Validates a `maxWarnings` value as `read` does for `limits.maxWarnings`. */
|
|
63
|
+
function checkMaxWarnings(name, v) {
|
|
64
|
+
if (typeof v !== "number" || !(v > 0)) throw new TypeError(`${name} must be a positive number`);
|
|
65
|
+
}
|
|
13
66
|
// src/internal/csv/infer.ts
|
|
14
67
|
const NUMBER = /^[+-]?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
15
68
|
const FRACTION = /^[+-]?\.\d+(?:[eE][+-]?\d+)?$/;
|
|
@@ -85,4 +138,4 @@ function daysInMonth(y, m) {
|
|
|
85
138
|
if (m === 2) return y % 4 === 0 && y % 100 !== 0 || y % 400 === 0 ? 29 : 28;
|
|
86
139
|
return m === 4 || m === 6 || m === 9 || m === 11 ? 30 : 31;
|
|
87
140
|
}
|
|
88
|
-
export { parseIsoDate as n,
|
|
141
|
+
export { toBytes as a, checkMaxWarnings as i, parseIsoDate as n, WarningCap as r, inferValue as t };
|
|
@@ -222,6 +222,12 @@ interface Cell {
|
|
|
222
222
|
* Writer: optional. If set, it must match `value` (`INVALID_CELL` otherwise). It is a check, not a coercion.
|
|
223
223
|
*/
|
|
224
224
|
type?: CellType | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Reader output with `ReadOptions.rawText` only: the `<v>` text of a number
|
|
227
|
+
* or ISO-date cell exactly as stored in the file, e.g. `'50.30'` for
|
|
228
|
+
* `value` 50.3. Ignored by the writer, which writes `value`.
|
|
229
|
+
*/
|
|
230
|
+
rawText?: string | undefined;
|
|
225
231
|
style?: Style | undefined;
|
|
226
232
|
hyperlink?: Hyperlink | undefined;
|
|
227
233
|
}
|
|
@@ -222,6 +222,12 @@ interface Cell {
|
|
|
222
222
|
* Writer: optional. If set, it must match `value` (`INVALID_CELL` otherwise). It is a check, not a coercion.
|
|
223
223
|
*/
|
|
224
224
|
type?: CellType | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Reader output with `ReadOptions.rawText` only: the `<v>` text of a number
|
|
227
|
+
* or ISO-date cell exactly as stored in the file, e.g. `'50.30'` for
|
|
228
|
+
* `value` 50.3. Ignored by the writer, which writes `value`.
|
|
229
|
+
*/
|
|
230
|
+
rawText?: string | undefined;
|
|
225
231
|
style?: Style | undefined;
|
|
226
232
|
hyperlink?: Hyperlink | undefined;
|
|
227
233
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as BinaryInput, r as ExcelWarning } from "./warnings-DhonqJ7A.js";
|
|
2
2
|
import { ReadLimits, SheetInfo } from "./read.js";
|
|
3
3
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
|
|
4
|
-
import { D as Sheet, s as CellInput } from "./model-
|
|
4
|
+
import { D as Sheet, s as CellInput } from "./model-BUNp7B0Z.js";
|
|
5
5
|
type NumberGroup = "," | "." | " " | "'" | "";
|
|
6
6
|
/**
|
|
7
7
|
* Parses `text` as a number written with `decimal` and `group` separators.
|
|
@@ -141,6 +141,8 @@ interface ImportDatasetOptions {
|
|
|
141
141
|
types?: "infer" | "none" | Record<string, ColumnType> | undefined;
|
|
142
142
|
locale?: ImportLocale | undefined;
|
|
143
143
|
delimiter?: string | undefined;
|
|
144
|
+
/** CSV: the delimiters `'auto'` chooses from, in order of preference (see `CsvParseOptions`). */
|
|
145
|
+
delimiterCandidates?: readonly string[] | undefined;
|
|
144
146
|
encoding?: string | undefined;
|
|
145
147
|
skipTotals?: "auto" | boolean | undefined;
|
|
146
148
|
errorCells?: "null" | "keep" | undefined;
|
|
@@ -150,6 +152,7 @@ interface ImportDatasetOptions {
|
|
|
150
152
|
mapping?: ColumnMapping | undefined;
|
|
151
153
|
maxRows?: number | undefined;
|
|
152
154
|
preview?: number | undefined;
|
|
155
|
+
/** Reader limits for xlsx; `maxWarnings` also caps the warnings of a CSV file. */
|
|
153
156
|
limits?: Partial<ReadLimits> | undefined;
|
|
154
157
|
signal?: AbortSignalLike | undefined;
|
|
155
158
|
onProgress?: ((p: ImportProgress) => void) | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as BinaryInput, r as ExcelWarning } from "./warnings-DhonqJ7A.cjs";
|
|
2
2
|
import { ReadLimits, SheetInfo } from "./read.cjs";
|
|
3
3
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
|
|
4
|
-
import { D as Sheet, s as CellInput } from "./model-
|
|
4
|
+
import { D as Sheet, s as CellInput } from "./model-BUNp7B0Z.cjs";
|
|
5
5
|
type NumberGroup = "," | "." | " " | "'" | "";
|
|
6
6
|
/**
|
|
7
7
|
* Parses `text` as a number written with `decimal` and `group` separators.
|
|
@@ -141,6 +141,8 @@ interface ImportDatasetOptions {
|
|
|
141
141
|
types?: "infer" | "none" | Record<string, ColumnType> | undefined;
|
|
142
142
|
locale?: ImportLocale | undefined;
|
|
143
143
|
delimiter?: string | undefined;
|
|
144
|
+
/** CSV: the delimiters `'auto'` chooses from, in order of preference (see `CsvParseOptions`). */
|
|
145
|
+
delimiterCandidates?: readonly string[] | undefined;
|
|
144
146
|
encoding?: string | undefined;
|
|
145
147
|
skipTotals?: "auto" | boolean | undefined;
|
|
146
148
|
errorCells?: "null" | "keep" | undefined;
|
|
@@ -150,6 +152,7 @@ interface ImportDatasetOptions {
|
|
|
150
152
|
mapping?: ColumnMapping | undefined;
|
|
151
153
|
maxRows?: number | undefined;
|
|
152
154
|
preview?: number | undefined;
|
|
155
|
+
/** Reader limits for xlsx; `maxWarnings` also caps the warnings of a CSV file. */
|
|
153
156
|
limits?: Partial<ReadLimits> | undefined;
|
|
154
157
|
signal?: AbortSignalLike | undefined;
|
|
155
158
|
onProgress?: ((p: ImportProgress) => void) | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as readCsv } from "./csv-
|
|
1
|
+
import { r as readCsv } from "./csv-CrWF7JS1.js";
|
|
2
2
|
import { i as toDatasetDetailed } from "./dataset-BLo9CwB-.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-
|
|
5
|
-
import {
|
|
4
|
+
import { i as readSheetNames, n as detectFormat, r as read } from "./read-CFQ09LlL.js";
|
|
5
|
+
import { a as toBytes, i as checkMaxWarnings, n as parseIsoDate } from "./infer-DcUyZ1T-.js";
|
|
6
6
|
import { a as decodeRange } from "./address-DUn7-5OS.js";
|
|
7
7
|
import { t as isoDate } from "./iso-date-CXnn-9mT.js";
|
|
8
8
|
// src/internal/import/parse.ts
|
|
@@ -874,6 +874,7 @@ async function importDataset(input, options = {}) {
|
|
|
874
874
|
"MDY"
|
|
875
875
|
]);
|
|
876
876
|
checkCount("maxRows", o.maxRows, 0);
|
|
877
|
+
if (o.limits?.maxWarnings !== void 0) checkMaxWarnings("limits.maxWarnings", o.limits.maxWarnings);
|
|
877
878
|
checkCount("preview", o.preview, 0);
|
|
878
879
|
if (typeof o.header === "object" && o.header !== null) {
|
|
879
880
|
checkCount("header.rows", o.header.rows, 1);
|
|
@@ -923,8 +924,10 @@ async function importDataset(input, options = {}) {
|
|
|
923
924
|
if (format === "csv") {
|
|
924
925
|
const r = await readCsv(typeof input === "string" ? input : bytes, {
|
|
925
926
|
delimiter: o.delimiter ?? "auto",
|
|
927
|
+
delimiterCandidates: o.delimiterCandidates,
|
|
926
928
|
encoding: o.encoding,
|
|
927
929
|
maxRows: cap,
|
|
930
|
+
maxWarnings: o.limits?.maxWarnings,
|
|
928
931
|
signal: o.signal,
|
|
929
932
|
inferTypes: false
|
|
930
933
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_csv = require("./csv-
|
|
1
|
+
const require_csv = require("./csv-DzGOFyHs.cjs");
|
|
2
2
|
const require_dataset = require("./dataset-DzoMeOG1.cjs");
|
|
3
3
|
const require_errors = require("./errors-DOPrrGS4.cjs");
|
|
4
|
-
const require_read = require("./read-
|
|
5
|
-
const require_infer = require("./infer-
|
|
4
|
+
const require_read = require("./read-DYDDLxUE.cjs");
|
|
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");
|
|
8
8
|
// src/internal/import/parse.ts
|
|
@@ -874,6 +874,7 @@ async function importDataset(input, options = {}) {
|
|
|
874
874
|
"MDY"
|
|
875
875
|
]);
|
|
876
876
|
checkCount("maxRows", o.maxRows, 0);
|
|
877
|
+
if (o.limits?.maxWarnings !== void 0) require_infer.checkMaxWarnings("limits.maxWarnings", o.limits.maxWarnings);
|
|
877
878
|
checkCount("preview", o.preview, 0);
|
|
878
879
|
if (typeof o.header === "object" && o.header !== null) {
|
|
879
880
|
checkCount("header.rows", o.header.rows, 1);
|
|
@@ -923,8 +924,10 @@ async function importDataset(input, options = {}) {
|
|
|
923
924
|
if (format === "csv") {
|
|
924
925
|
const r = await require_csv.readCsv(typeof input === "string" ? input : bytes, {
|
|
925
926
|
delimiter: o.delimiter ?? "auto",
|
|
927
|
+
delimiterCandidates: o.delimiterCandidates,
|
|
926
928
|
encoding: o.encoding,
|
|
927
929
|
maxRows: cap,
|
|
930
|
+
maxWarnings: o.limits?.maxWarnings,
|
|
928
931
|
signal: o.signal,
|
|
929
932
|
inferTypes: false
|
|
930
933
|
});
|