javascript-excel 2.0.0 → 2.2.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.
Files changed (51) hide show
  1. package/README.md +9 -1
  2. package/dist/{auto-width-DRHsPKNk.d.cts → auto-width-DZvQSucm.d.cts} +1 -1
  3. package/dist/{csv-pXfaputs.js → csv-CrWF7JS1.js} +57 -13
  4. package/dist/{csv-DyVH9y7S.cjs → csv-DzGOFyHs.cjs} +57 -13
  5. package/dist/csv.cjs +3 -1
  6. package/dist/csv.d.cts +23 -5
  7. package/dist/csv.d.ts +23 -5
  8. package/dist/csv.js +3 -1
  9. package/dist/dom.cjs +2 -0
  10. package/dist/dom.d.cts +4 -4
  11. package/dist/dom.d.ts +3 -3
  12. package/dist/dom.js +2 -1
  13. package/dist/format.d.cts +1 -1
  14. package/dist/format.d.ts +1 -1
  15. package/dist/import.cjs +3 -1
  16. package/dist/import.d.cts +3 -3
  17. package/dist/import.d.ts +3 -3
  18. package/dist/import.js +3 -1
  19. package/dist/index.cjs +3 -1
  20. package/dist/index.d.cts +6 -6
  21. package/dist/index.d.ts +5 -5
  22. package/dist/index.js +3 -2
  23. package/dist/{infer-D9EC9vJ-.cjs → infer-BniOucP6.cjs} +65 -0
  24. package/dist/{infer-BR-J9BZa.js → infer-DcUyZ1T-.js} +54 -1
  25. package/dist/{model-0JikLfuM.d.cts → model-BUNp7B0Z.d.cts} +6 -0
  26. package/dist/{model-0JikLfuM.d.ts → model-BUNp7B0Z.d.ts} +6 -0
  27. package/dist/{pipeline-BuG_nn_S.d.ts → pipeline-6PmlmH1-.d.ts} +5 -2
  28. package/dist/{pipeline-2dw9aehe.js → pipeline-BNhGRJcx.js} +6 -3
  29. package/dist/{pipeline-DM7n0aRI.d.cts → pipeline-C63qD7Ym.d.cts} +5 -2
  30. package/dist/{pipeline-DMskqxiU.cjs → pipeline-DLYtAkPU.cjs} +6 -3
  31. package/dist/{read-ClszMDAE.js → read-CFmZioBG.js} +547 -119
  32. package/dist/{read-ByceXfiL.cjs → read-D5Gz4ph8.cjs} +547 -119
  33. package/dist/read.cjs +3 -1
  34. package/dist/read.d.cts +69 -7
  35. package/dist/read.d.ts +69 -7
  36. package/dist/read.js +3 -1
  37. package/dist/render.d.cts +1 -1
  38. package/dist/render.d.ts +1 -1
  39. package/dist/warnings-BPz1Ia3s.js +42 -0
  40. package/dist/warnings-CJPiDqei.cjs +47 -0
  41. package/dist/warnings-DhonqJ7A.d.cts +79 -0
  42. package/dist/warnings-DhonqJ7A.d.ts +79 -0
  43. package/dist/worker.cjs +3 -3
  44. package/dist/worker.d.cts +4 -4
  45. package/dist/worker.d.ts +4 -4
  46. package/dist/worker.js +3 -3
  47. package/dist/{write-DM6ieuQY.d.ts → write-BaMv1Z7W.d.ts} +2 -2
  48. package/dist/{write-DtjfdIFm.d.cts → write-Izl2NG0Y.d.cts} +2 -2
  49. package/package.json +1 -1
  50. package/dist/warnings-B1v58nCZ.d.cts +0 -41
  51. package/dist/warnings-B1v58nCZ.d.ts +0 -41
package/dist/read.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_read = require("./read-ByceXfiL.cjs");
2
+ const require_warnings = require("./warnings-CJPiDqei.cjs");
3
+ const require_read = require("./read-D5Gz4ph8.cjs");
3
4
  exports.DEFAULT_READ_LIMITS = require_read.DEFAULT_READ_LIMITS;
4
5
  exports.detectFormat = require_read.detectFormat;
6
+ exports.isDataLossWarning = require_warnings.isDataLossWarning;
5
7
  exports.read = require_read.read;
6
8
  exports.readSheetNames = require_read.readSheetNames;
package/dist/read.d.cts CHANGED
@@ -10,10 +10,10 @@
10
10
  *
11
11
  * @module javascript-excel/read
12
12
  */
13
- import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.cjs";
14
- 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-0JikLfuM.cjs";
13
+ 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";
14
+ 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";
15
15
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
16
- import { t as Progress } from "./write-DtjfdIFm.cjs";
16
+ import { t as Progress } from "./write-Izl2NG0Y.cjs";
17
17
  /** Result of `read`. */
18
18
  export interface ReadResult {
19
19
  workbook: Workbook<Cell>;
@@ -33,6 +33,18 @@ export interface ReadOptions {
33
33
  dateZone?: "local" | "utc" | undefined;
34
34
  /** Rich text as runs (default) or flattened to a plain string. */
35
35
  richText?: "runs" | "plain" | undefined;
36
+ /**
37
+ * Also return the text stored in the file for number and ISO-date cells, as
38
+ * `cell.rawText`, exactly as written in `<v>` (entities decoded and line ends
39
+ * normalised as for any XML text, nothing trimmed): `50.30`, `1E-7`, `1234567890123456789`,
40
+ * `2024-01-15`. `value` and `type` are unchanged, so a cell still says
41
+ * whether it was a number or a date. Set on `t="n"` (the default) and
42
+ * `t="d"` cells that have a value, including formula cells (the cached
43
+ * `<v>`) and date-formatted serials (the serial as stored, with `dates`
44
+ * `'date'` or `'serial'`). Strings, booleans, errors and cells with an
45
+ * empty or blank `<v>` never get it. Default false: no `rawText` key at all.
46
+ */
47
+ rawText?: boolean | undefined;
36
48
  /**
37
49
  * Read only the first `maxRows` rows of each parsed sheet (zero-based rows
38
50
  * 0..maxRows-1). Later rows are skipped without building cells, with one
@@ -47,7 +59,11 @@ export interface ReadOptions {
47
59
  /** Called as warnings occur, in addition to `ReadResult.warnings`. */
48
60
  onWarning?: ((w: ExcelWarning) => void) | undefined;
49
61
  }
50
- /** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
62
+ /**
63
+ * Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it).
64
+ * New optional members may be added in minor releases, so do not write `Required<ReadLimits>` literals;
65
+ * spread `DEFAULT_READ_LIMITS` instead.
66
+ */
51
67
  export interface ReadLimits {
52
68
  maxInputBytes: number;
53
69
  maxEntries: number;
@@ -58,14 +74,60 @@ export interface ReadLimits {
58
74
  /** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
59
75
  maxRatio: number;
60
76
  maxXmlDepth: number;
77
+ /**
78
+ * Characters (UTF-16 code units, as `string.length` counts them) in one XML
79
+ * tag with its attributes, comment, CDATA section or processing instruction.
80
+ * Checked while the token is read, so it is never buffered past this. Text
81
+ * between tags is streamed and not limited by it. On a `LimitError`,
82
+ * `details.value` is `max + 1` ("more than max"): the token's full length is
83
+ * not read. Default 16 Mi (`DEFAULT_READ_LIMITS`).
84
+ *
85
+ * Optional only so that a complete `ReadLimits` object written for 2.0
86
+ * still compiles; when it is left out the default applies.
87
+ */
88
+ maxXmlTokenLength?: number;
89
+ /**
90
+ * Sheet entries (`<sheet>` elements, worksheets or not) that `xl/workbook.xml`
91
+ * may declare. Checked while that part is parsed, before any sheet is read;
92
+ * `readSheetNames` applies it too. Default 10,000 (`DEFAULT_READ_LIMITS`).
93
+ * It bounds the sheet list and the bookkeeping per entry. It does not bound
94
+ * memory on its own: several entries can name the same part, which is then
95
+ * read once per entry; memory is bounded by `maxCells`, `maxItems` and
96
+ * `maxTotalBytes`, which count what every sheet builds and every read of a
97
+ * part. On a `LimitError`, `details.value` is `max + 1` and
98
+ * `details.part` names the workbook part.
99
+ *
100
+ * Optional only so that a complete `ReadLimits` object written for 2.0 or
101
+ * 2.1 still compiles; when it is left out the default applies.
102
+ */
103
+ maxSheets?: number;
61
104
  /** All sheets together. */
62
105
  maxCells: number;
106
+ /**
107
+ * Items other than cells that a read builds, all sheets together (added in
108
+ * 2.2): one per column object of a `<col>` range, row-property object,
109
+ * merge, hyperlink (with the empty cell it may create), selection, defined
110
+ * name, kept style record (number format, cell format, indexed colour, and
111
+ * with `styles` on: font, fill, gradient stop, border), custom document
112
+ * property, and rich-text run after the first of a string. Each is counted
113
+ * before it is built. `readSheetNames` counts defined names. Default
114
+ * 10,000,000 (`DEFAULT_READ_LIMITS`). On a `LimitError`, `details.value` is
115
+ * `max + 1`.
116
+ *
117
+ * Optional only so that a complete `ReadLimits` object written for 2.0 or
118
+ * 2.1 still compiles; when it is left out the default applies.
119
+ */
120
+ maxItems?: number;
63
121
  maxSharedStrings: number;
64
- /** Then a single `WARNINGS_TRUNCATED`. */
122
+ /**
123
+ * Warnings kept before the cap applies. Past it, informational warnings are dropped and
124
+ * counted in one `WARNINGS_TRUNCATED` (added where the first one is dropped); data-loss
125
+ * warnings (`isDataLossWarning`) are still kept, up to the first 100 of each code.
126
+ */
65
127
  maxWarnings: number;
66
128
  }
67
129
  /** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
68
- export declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
130
+ export declare const DEFAULT_READ_LIMITS: Readonly<Required<ReadLimits>>;
69
131
  /** A sheet as listed by `readSheetNames`. */
70
132
  export interface SheetInfo {
71
133
  name: string;
@@ -86,4 +148,4 @@ export declare function readSheetNames(input: BinaryInput, options?: {
86
148
  }): Promise<SheetInfo[]>;
87
149
  /** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
88
150
  export declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
89
- export type { AbortSignalLike, Alignment, BinaryInput, BlobLike, BlobType, Border, BorderSide, BorderStyle, Cell, CellErrorValue, CellInput, CellType, CellValue, Color, ColumnProps, ColumnWidth, DefinedName, DocProperties, ErrorCode, ExcelWarning, ExcelWarningCode, Fill, Font, GradientFill, Hyperlink, NumFmt, PatternFill, PatternType, PrintSetup, Progress, RichText, RichTextRun, RowProps, Sheet, SheetView, Style, Theme, Workbook };
151
+ export { type AbortSignalLike, type Alignment, type BinaryInput, type BlobLike, type BlobType, type Border, type BorderSide, type BorderStyle, type Cell, type CellErrorValue, type CellInput, type CellType, type CellValue, type Color, type ColumnProps, type ColumnWidth, type DefinedName, type DocProperties, type DroppedWarnings, type ErrorCode, type ExcelPartKind, type ExcelWarning, type ExcelWarningCode, type Fill, type Font, type GradientFill, type Hyperlink, type NumFmt, type PatternFill, type PatternType, type PrintSetup, type Progress, type RichText, type RichTextRun, type RowProps, type Sheet, type SheetView, type Style, type Theme, type Workbook, isDataLossWarning };
package/dist/read.d.ts CHANGED
@@ -10,10 +10,10 @@
10
10
  *
11
11
  * @module javascript-excel/read
12
12
  */
13
- import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.js";
14
- 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-0JikLfuM.js";
13
+ 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";
14
+ 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";
15
15
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
16
- import { t as Progress } from "./write-DM6ieuQY.js";
16
+ import { t as Progress } from "./write-BaMv1Z7W.js";
17
17
  /** Result of `read`. */
18
18
  export interface ReadResult {
19
19
  workbook: Workbook<Cell>;
@@ -33,6 +33,18 @@ export interface ReadOptions {
33
33
  dateZone?: "local" | "utc" | undefined;
34
34
  /** Rich text as runs (default) or flattened to a plain string. */
35
35
  richText?: "runs" | "plain" | undefined;
36
+ /**
37
+ * Also return the text stored in the file for number and ISO-date cells, as
38
+ * `cell.rawText`, exactly as written in `<v>` (entities decoded and line ends
39
+ * normalised as for any XML text, nothing trimmed): `50.30`, `1E-7`, `1234567890123456789`,
40
+ * `2024-01-15`. `value` and `type` are unchanged, so a cell still says
41
+ * whether it was a number or a date. Set on `t="n"` (the default) and
42
+ * `t="d"` cells that have a value, including formula cells (the cached
43
+ * `<v>`) and date-formatted serials (the serial as stored, with `dates`
44
+ * `'date'` or `'serial'`). Strings, booleans, errors and cells with an
45
+ * empty or blank `<v>` never get it. Default false: no `rawText` key at all.
46
+ */
47
+ rawText?: boolean | undefined;
36
48
  /**
37
49
  * Read only the first `maxRows` rows of each parsed sheet (zero-based rows
38
50
  * 0..maxRows-1). Later rows are skipped without building cells, with one
@@ -47,7 +59,11 @@ export interface ReadOptions {
47
59
  /** Called as warnings occur, in addition to `ReadResult.warnings`. */
48
60
  onWarning?: ((w: ExcelWarning) => void) | undefined;
49
61
  }
50
- /** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
62
+ /**
63
+ * Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it).
64
+ * New optional members may be added in minor releases, so do not write `Required<ReadLimits>` literals;
65
+ * spread `DEFAULT_READ_LIMITS` instead.
66
+ */
51
67
  export interface ReadLimits {
52
68
  maxInputBytes: number;
53
69
  maxEntries: number;
@@ -58,14 +74,60 @@ export interface ReadLimits {
58
74
  /** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
59
75
  maxRatio: number;
60
76
  maxXmlDepth: number;
77
+ /**
78
+ * Characters (UTF-16 code units, as `string.length` counts them) in one XML
79
+ * tag with its attributes, comment, CDATA section or processing instruction.
80
+ * Checked while the token is read, so it is never buffered past this. Text
81
+ * between tags is streamed and not limited by it. On a `LimitError`,
82
+ * `details.value` is `max + 1` ("more than max"): the token's full length is
83
+ * not read. Default 16 Mi (`DEFAULT_READ_LIMITS`).
84
+ *
85
+ * Optional only so that a complete `ReadLimits` object written for 2.0
86
+ * still compiles; when it is left out the default applies.
87
+ */
88
+ maxXmlTokenLength?: number;
89
+ /**
90
+ * Sheet entries (`<sheet>` elements, worksheets or not) that `xl/workbook.xml`
91
+ * may declare. Checked while that part is parsed, before any sheet is read;
92
+ * `readSheetNames` applies it too. Default 10,000 (`DEFAULT_READ_LIMITS`).
93
+ * It bounds the sheet list and the bookkeeping per entry. It does not bound
94
+ * memory on its own: several entries can name the same part, which is then
95
+ * read once per entry; memory is bounded by `maxCells`, `maxItems` and
96
+ * `maxTotalBytes`, which count what every sheet builds and every read of a
97
+ * part. On a `LimitError`, `details.value` is `max + 1` and
98
+ * `details.part` names the workbook part.
99
+ *
100
+ * Optional only so that a complete `ReadLimits` object written for 2.0 or
101
+ * 2.1 still compiles; when it is left out the default applies.
102
+ */
103
+ maxSheets?: number;
61
104
  /** All sheets together. */
62
105
  maxCells: number;
106
+ /**
107
+ * Items other than cells that a read builds, all sheets together (added in
108
+ * 2.2): one per column object of a `<col>` range, row-property object,
109
+ * merge, hyperlink (with the empty cell it may create), selection, defined
110
+ * name, kept style record (number format, cell format, indexed colour, and
111
+ * with `styles` on: font, fill, gradient stop, border), custom document
112
+ * property, and rich-text run after the first of a string. Each is counted
113
+ * before it is built. `readSheetNames` counts defined names. Default
114
+ * 10,000,000 (`DEFAULT_READ_LIMITS`). On a `LimitError`, `details.value` is
115
+ * `max + 1`.
116
+ *
117
+ * Optional only so that a complete `ReadLimits` object written for 2.0 or
118
+ * 2.1 still compiles; when it is left out the default applies.
119
+ */
120
+ maxItems?: number;
63
121
  maxSharedStrings: number;
64
- /** Then a single `WARNINGS_TRUNCATED`. */
122
+ /**
123
+ * Warnings kept before the cap applies. Past it, informational warnings are dropped and
124
+ * counted in one `WARNINGS_TRUNCATED` (added where the first one is dropped); data-loss
125
+ * warnings (`isDataLossWarning`) are still kept, up to the first 100 of each code.
126
+ */
65
127
  maxWarnings: number;
66
128
  }
67
129
  /** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
68
- export declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
130
+ export declare const DEFAULT_READ_LIMITS: Readonly<Required<ReadLimits>>;
69
131
  /** A sheet as listed by `readSheetNames`. */
70
132
  export interface SheetInfo {
71
133
  name: string;
@@ -86,4 +148,4 @@ export declare function readSheetNames(input: BinaryInput, options?: {
86
148
  }): Promise<SheetInfo[]>;
87
149
  /** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
88
150
  export declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
89
- export type { AbortSignalLike, Alignment, BinaryInput, BlobLike, BlobType, Border, BorderSide, BorderStyle, Cell, CellErrorValue, CellInput, CellType, CellValue, Color, ColumnProps, ColumnWidth, DefinedName, DocProperties, ErrorCode, ExcelWarning, ExcelWarningCode, Fill, Font, GradientFill, Hyperlink, NumFmt, PatternFill, PatternType, PrintSetup, Progress, RichText, RichTextRun, RowProps, Sheet, SheetView, Style, Theme, Workbook };
151
+ export { type AbortSignalLike, type Alignment, type BinaryInput, type BlobLike, type BlobType, type Border, type BorderSide, type BorderStyle, type Cell, type CellErrorValue, type CellInput, type CellType, type CellValue, type Color, type ColumnProps, type ColumnWidth, type DefinedName, type DocProperties, type DroppedWarnings, type ErrorCode, type ExcelPartKind, type ExcelWarning, type ExcelWarningCode, type Fill, type Font, type GradientFill, type Hyperlink, type NumFmt, type PatternFill, type PatternType, type PrintSetup, type Progress, type RichText, type RichTextRun, type RowProps, type Sheet, type SheetView, type Style, type Theme, type Workbook, isDataLossWarning };
package/dist/read.js CHANGED
@@ -1 +1,3 @@
1
- export { t as DEFAULT_READ_LIMITS, n as detectFormat, r as read, i as readSheetNames } from "./read-ClszMDAE.js";
1
+ import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
2
+ import { i as readSheetNames, n as detectFormat, r as read, t as DEFAULT_READ_LIMITS } from "./read-CFmZioBG.js";
3
+ export { DEFAULT_READ_LIMITS, detectFormat, isDataLossWarning, read, readSheetNames };
package/dist/render.d.cts CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module javascript-excel/render
9
9
  */
10
- import { S as PatternType, a as Cell, c as CellType, i as BorderStyle, j as Workbook, l as CellValue, s as CellInput } from "./model-0JikLfuM.cjs";
10
+ import { S as PatternType, a as Cell, c as CellType, i as BorderStyle, j as Workbook, l as CellValue, s as CellInput } from "./model-BUNp7B0Z.cjs";
11
11
  /** Any function with this shape; `formatCell` from javascript-excel/format fits. */
12
12
  export type RenderFormatter = (cell: Cell, options: {
13
13
  locale?: string | undefined;
package/dist/render.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module javascript-excel/render
9
9
  */
10
- import { S as PatternType, a as Cell, c as CellType, i as BorderStyle, j as Workbook, l as CellValue, s as CellInput } from "./model-0JikLfuM.js";
10
+ import { S as PatternType, a as Cell, c as CellType, i as BorderStyle, j as Workbook, l as CellValue, s as CellInput } from "./model-BUNp7B0Z.js";
11
11
  /** Any function with this shape; `formatCell` from javascript-excel/format fits. */
12
12
  export type RenderFormatter = (cell: Cell, options: {
13
13
  locale?: string | undefined;
@@ -0,0 +1,42 @@
1
+ // src/warnings.ts
2
+ /**
3
+ * Which codes mean that data was lost: a value was dropped, replaced, cut or
4
+ * decoded wrongly, or rows or parts are missing (docs/api.md §7.3). The others
5
+ * are informational: the data is all there, perhaps in another form.
6
+ * Typed as a full record, so a new code cannot be added without classifying it.
7
+ */
8
+ const WARNING_DATA_LOSS = Object.freeze({
9
+ UNSUPPORTED_PART: true,
10
+ INVALID_STYLE_INDEX: false,
11
+ INVALID_SHARED_STRING: true,
12
+ CELL_OUT_OF_BOUNDS: true,
13
+ INVALID_CELL_REF: true,
14
+ DUPLICATE_CELL: true,
15
+ INVALID_DATE_SERIAL: false,
16
+ SHARED_FORMULA_UNRESOLVED: true,
17
+ MISSING_PART: true,
18
+ BROKEN_OPTIONAL_PART: true,
19
+ HYPERLINK_RANGE_REDUCED: true,
20
+ SPLIT_PANE_IGNORED: false,
21
+ ROWS_TRUNCATED: true,
22
+ COERCION_FAILED: false,
23
+ NON_FINITE_NUMBER: true,
24
+ HYPERLINK_DROPPED: true,
25
+ CSV_UNTERMINATED_QUOTE: true,
26
+ CSV_STRAY_QUOTE: false,
27
+ CSV_FIELD_COUNT: false,
28
+ CSV_INVALID_ENCODING: true,
29
+ CSV_ROWS_TRUNCATED: true,
30
+ WARNINGS_TRUNCATED: false
31
+ });
32
+ /**
33
+ * True when the warning (or code) means data was lost: a value was dropped,
34
+ * replaced, cut or decoded wrongly, or rows or parts are missing. The warning
35
+ * cap never hides a kind of data loss, so checking every returned warning is
36
+ * enough to refuse a damaged file. Unknown codes give false.
37
+ */
38
+ function isDataLossWarning(warning) {
39
+ const code = typeof warning === "string" ? warning : warning.code;
40
+ return Object.prototype.hasOwnProperty.call(WARNING_DATA_LOSS, code) && WARNING_DATA_LOSS[code];
41
+ }
42
+ export { isDataLossWarning as t };
@@ -0,0 +1,47 @@
1
+ // src/warnings.ts
2
+ /**
3
+ * Which codes mean that data was lost: a value was dropped, replaced, cut or
4
+ * decoded wrongly, or rows or parts are missing (docs/api.md §7.3). The others
5
+ * are informational: the data is all there, perhaps in another form.
6
+ * Typed as a full record, so a new code cannot be added without classifying it.
7
+ */
8
+ const WARNING_DATA_LOSS = Object.freeze({
9
+ UNSUPPORTED_PART: true,
10
+ INVALID_STYLE_INDEX: false,
11
+ INVALID_SHARED_STRING: true,
12
+ CELL_OUT_OF_BOUNDS: true,
13
+ INVALID_CELL_REF: true,
14
+ DUPLICATE_CELL: true,
15
+ INVALID_DATE_SERIAL: false,
16
+ SHARED_FORMULA_UNRESOLVED: true,
17
+ MISSING_PART: true,
18
+ BROKEN_OPTIONAL_PART: true,
19
+ HYPERLINK_RANGE_REDUCED: true,
20
+ SPLIT_PANE_IGNORED: false,
21
+ ROWS_TRUNCATED: true,
22
+ COERCION_FAILED: false,
23
+ NON_FINITE_NUMBER: true,
24
+ HYPERLINK_DROPPED: true,
25
+ CSV_UNTERMINATED_QUOTE: true,
26
+ CSV_STRAY_QUOTE: false,
27
+ CSV_FIELD_COUNT: false,
28
+ CSV_INVALID_ENCODING: true,
29
+ CSV_ROWS_TRUNCATED: true,
30
+ WARNINGS_TRUNCATED: false
31
+ });
32
+ /**
33
+ * True when the warning (or code) means data was lost: a value was dropped,
34
+ * replaced, cut or decoded wrongly, or rows or parts are missing. The warning
35
+ * cap never hides a kind of data loss, so checking every returned warning is
36
+ * enough to refuse a damaged file. Unknown codes give false.
37
+ */
38
+ function isDataLossWarning(warning) {
39
+ const code = typeof warning === "string" ? warning : warning.code;
40
+ return Object.prototype.hasOwnProperty.call(WARNING_DATA_LOSS, code) && WARNING_DATA_LOSS[code];
41
+ }
42
+ Object.defineProperty(exports, "isDataLossWarning", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return isDataLossWarning;
46
+ }
47
+ });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Binary input and Blob types shared by the reader and the CSV entry.
3
+ *
4
+ * The package compiles without DOM types, so `Blob` cannot be named directly
5
+ * in a published signature. `BlobType` resolves to the platform's own `Blob`
6
+ * whenever the consumer's TypeScript setup declares one (lib "dom", or
7
+ * @types/node), and to the structural `BlobLike` otherwise.
8
+ */
9
+ /** The members of `Blob` the library uses. */
10
+ interface BlobLike {
11
+ readonly size: number;
12
+ readonly type: string;
13
+ arrayBuffer(): Promise<ArrayBuffer>;
14
+ }
15
+ /** The platform `Blob` type when the consumer has one, else `BlobLike`. */
16
+ type BlobType = typeof globalThis extends {
17
+ Blob: {
18
+ prototype: infer B;
19
+ };
20
+ } ? B : BlobLike;
21
+ /** Bytes the library can read. A Node `Buffer` is a `Uint8Array`. */
22
+ type BinaryInput = Uint8Array | ArrayBuffer | BlobType;
23
+ /**
24
+ * Warnings (docs/api.md §7.3).
25
+ *
26
+ * The reader and the CSV parser collect warnings for damage they can recover
27
+ * from, instead of throwing. Each warning is plain data.
28
+ */
29
+ /** Every warning code the library reports. */
30
+ type ExcelWarningCode = "UNSUPPORTED_PART" | "INVALID_STYLE_INDEX" | "INVALID_SHARED_STRING" | "CELL_OUT_OF_BOUNDS" | "INVALID_CELL_REF" | "DUPLICATE_CELL" | "INVALID_DATE_SERIAL" | "SHARED_FORMULA_UNRESOLVED" | "MISSING_PART" | "BROKEN_OPTIONAL_PART" | "HYPERLINK_RANGE_REDUCED" | "SPLIT_PANE_IGNORED" | "ROWS_TRUNCATED" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
31
+ /**
32
+ * The kind of package part a `MISSING_PART`, `BROKEN_OPTIONAL_PART` or
33
+ * `UNSUPPORTED_PART` warning is about. The names are the last segment of the
34
+ * OOXML relationship type (`.../relationships/worksheet` is `'worksheet'`),
35
+ * in camelCase for the document-property parts. Kinds may be added in a minor
36
+ * release, so a `switch` over it needs a `default` branch.
37
+ */
38
+ type ExcelPartKind = "worksheet" | "sharedStrings" | "styles" | "theme" | "coreProperties" | "extendedProperties" | "customProperties" | "drawing" | "vmlDrawing" | "comments" | "threadedComment" | "pivotTable" | "pivotCacheDefinition" | "table" | "oleObject" | "ctrlProp" | "image" | "vbaProject" | "externalLink" | "connections" | "queryTable" | "slicer" | "slicerCache" | "timeline" | "chartsheet" | "dialogsheet" | "macrosheet";
39
+ /** What the warning cap left out; on `WARNINGS_TRUNCATED` only. */
40
+ interface DroppedWarnings {
41
+ /** Warnings not recorded, in total. */
42
+ total: number;
43
+ /**
44
+ * Of those, data-loss warnings (see `isDataLossWarning`). They are dropped only
45
+ * after the first 100 of their code were kept, so every
46
+ * kind of data loss that occurred is still in the list at least once.
47
+ */
48
+ dataLoss: number;
49
+ /** Warnings not recorded, per code. */
50
+ byCode: Partial<Record<ExcelWarningCode, number>>;
51
+ }
52
+ /** A recoverable problem found while reading or building. */
53
+ interface ExcelWarning {
54
+ code: ExcelWarningCode;
55
+ message: string;
56
+ /** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
57
+ part?: string | undefined;
58
+ sheet?: string | undefined;
59
+ /** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
60
+ ref?: string | undefined;
61
+ /** On `MISSING_PART`, `BROKEN_OPTIONAL_PART` and `UNSUPPORTED_PART`: the kind of part. */
62
+ partKind?: ExcelPartKind | undefined;
63
+ /**
64
+ * On `WARNINGS_TRUNCATED`: counts of the warnings that were not recorded. The
65
+ * counts are final in the returned `warnings` only. `read` calls `onWarning`
66
+ * with this warning at the first drop: on the main thread it is the same object,
67
+ * updated until the read ends; through the worker client it is a copy taken at
68
+ * that moment (`total: 1`).
69
+ */
70
+ dropped?: DroppedWarnings | undefined;
71
+ }
72
+ /**
73
+ * True when the warning (or code) means data was lost: a value was dropped,
74
+ * replaced, cut or decoded wrongly, or rows or parts are missing. The warning
75
+ * cap never hides a kind of data loss, so checking every returned warning is
76
+ * enough to refuse a damaged file. Unknown codes give false.
77
+ */
78
+ declare function isDataLossWarning(warning: ExcelWarning | ExcelWarningCode): boolean;
79
+ export { isDataLossWarning as a, BlobType as c, ExcelWarningCode as i, ExcelPartKind as n, BinaryInput as o, ExcelWarning as r, BlobLike as s, DroppedWarnings as t };
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Binary input and Blob types shared by the reader and the CSV entry.
3
+ *
4
+ * The package compiles without DOM types, so `Blob` cannot be named directly
5
+ * in a published signature. `BlobType` resolves to the platform's own `Blob`
6
+ * whenever the consumer's TypeScript setup declares one (lib "dom", or
7
+ * @types/node), and to the structural `BlobLike` otherwise.
8
+ */
9
+ /** The members of `Blob` the library uses. */
10
+ interface BlobLike {
11
+ readonly size: number;
12
+ readonly type: string;
13
+ arrayBuffer(): Promise<ArrayBuffer>;
14
+ }
15
+ /** The platform `Blob` type when the consumer has one, else `BlobLike`. */
16
+ type BlobType = typeof globalThis extends {
17
+ Blob: {
18
+ prototype: infer B;
19
+ };
20
+ } ? B : BlobLike;
21
+ /** Bytes the library can read. A Node `Buffer` is a `Uint8Array`. */
22
+ type BinaryInput = Uint8Array | ArrayBuffer | BlobType;
23
+ /**
24
+ * Warnings (docs/api.md §7.3).
25
+ *
26
+ * The reader and the CSV parser collect warnings for damage they can recover
27
+ * from, instead of throwing. Each warning is plain data.
28
+ */
29
+ /** Every warning code the library reports. */
30
+ type ExcelWarningCode = "UNSUPPORTED_PART" | "INVALID_STYLE_INDEX" | "INVALID_SHARED_STRING" | "CELL_OUT_OF_BOUNDS" | "INVALID_CELL_REF" | "DUPLICATE_CELL" | "INVALID_DATE_SERIAL" | "SHARED_FORMULA_UNRESOLVED" | "MISSING_PART" | "BROKEN_OPTIONAL_PART" | "HYPERLINK_RANGE_REDUCED" | "SPLIT_PANE_IGNORED" | "ROWS_TRUNCATED" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
31
+ /**
32
+ * The kind of package part a `MISSING_PART`, `BROKEN_OPTIONAL_PART` or
33
+ * `UNSUPPORTED_PART` warning is about. The names are the last segment of the
34
+ * OOXML relationship type (`.../relationships/worksheet` is `'worksheet'`),
35
+ * in camelCase for the document-property parts. Kinds may be added in a minor
36
+ * release, so a `switch` over it needs a `default` branch.
37
+ */
38
+ type ExcelPartKind = "worksheet" | "sharedStrings" | "styles" | "theme" | "coreProperties" | "extendedProperties" | "customProperties" | "drawing" | "vmlDrawing" | "comments" | "threadedComment" | "pivotTable" | "pivotCacheDefinition" | "table" | "oleObject" | "ctrlProp" | "image" | "vbaProject" | "externalLink" | "connections" | "queryTable" | "slicer" | "slicerCache" | "timeline" | "chartsheet" | "dialogsheet" | "macrosheet";
39
+ /** What the warning cap left out; on `WARNINGS_TRUNCATED` only. */
40
+ interface DroppedWarnings {
41
+ /** Warnings not recorded, in total. */
42
+ total: number;
43
+ /**
44
+ * Of those, data-loss warnings (see `isDataLossWarning`). They are dropped only
45
+ * after the first 100 of their code were kept, so every
46
+ * kind of data loss that occurred is still in the list at least once.
47
+ */
48
+ dataLoss: number;
49
+ /** Warnings not recorded, per code. */
50
+ byCode: Partial<Record<ExcelWarningCode, number>>;
51
+ }
52
+ /** A recoverable problem found while reading or building. */
53
+ interface ExcelWarning {
54
+ code: ExcelWarningCode;
55
+ message: string;
56
+ /** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
57
+ part?: string | undefined;
58
+ sheet?: string | undefined;
59
+ /** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
60
+ ref?: string | undefined;
61
+ /** On `MISSING_PART`, `BROKEN_OPTIONAL_PART` and `UNSUPPORTED_PART`: the kind of part. */
62
+ partKind?: ExcelPartKind | undefined;
63
+ /**
64
+ * On `WARNINGS_TRUNCATED`: counts of the warnings that were not recorded. The
65
+ * counts are final in the returned `warnings` only. `read` calls `onWarning`
66
+ * with this warning at the first drop: on the main thread it is the same object,
67
+ * updated until the read ends; through the worker client it is a copy taken at
68
+ * that moment (`total: 1`).
69
+ */
70
+ dropped?: DroppedWarnings | undefined;
71
+ }
72
+ /**
73
+ * True when the warning (or code) means data was lost: a value was dropped,
74
+ * replaced, cut or decoded wrongly, or rows or parts are missing. The warning
75
+ * cap never hides a kind of data loss, so checking every returned warning is
76
+ * enough to refuse a damaged file. Unknown codes give false.
77
+ */
78
+ declare function isDataLossWarning(warning: ExcelWarning | ExcelWarningCode): boolean;
79
+ export { isDataLossWarning as a, BlobType as c, ExcelWarningCode as i, ExcelPartKind as n, BinaryInput as o, ExcelWarning as r, BlobLike as s, DroppedWarnings as t };
package/dist/worker.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_csv = require("./csv-DyVH9y7S.cjs");
2
+ const require_csv = require("./csv-DzGOFyHs.cjs");
3
3
  const require_errors = require("./errors-DOPrrGS4.cjs");
4
- const require_read = require("./read-ByceXfiL.cjs");
5
- const require_pipeline = require("./pipeline-DMskqxiU.cjs");
4
+ const require_read = require("./read-D5Gz4ph8.cjs");
5
+ const require_pipeline = require("./pipeline-DLYtAkPU.cjs");
6
6
  const require_write = require("./write-DKXhuvKR.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. */
package/dist/worker.d.cts CHANGED
@@ -21,12 +21,12 @@
21
21
  *
22
22
  * @module javascript-excel/worker
23
23
  */
24
- import { r as BinaryInput } from "./warnings-B1v58nCZ.cjs";
24
+ import { o as BinaryInput } from "./warnings-DhonqJ7A.cjs";
25
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.cjs";
26
- import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.cjs";
26
+ import { D as Sheet, j as Workbook, s as CellInput } from "./model-BUNp7B0Z.cjs";
27
27
  import { ReadOptions, ReadResult } from "./read.cjs";
28
- import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-DM7n0aRI.cjs";
29
- import { n as WriteOptions, t as Progress } from "./write-DtjfdIFm.cjs";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-C63qD7Ym.cjs";
29
+ import { n as WriteOptions, t as Progress } from "./write-Izl2NG0Y.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`. */
32
32
  export interface MessageEndpoint {
package/dist/worker.d.ts CHANGED
@@ -21,12 +21,12 @@
21
21
  *
22
22
  * @module javascript-excel/worker
23
23
  */
24
- import { r as BinaryInput } from "./warnings-B1v58nCZ.js";
24
+ import { o as BinaryInput } from "./warnings-DhonqJ7A.js";
25
25
  import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.js";
26
- import { D as Sheet, j as Workbook, s as CellInput } from "./model-0JikLfuM.js";
26
+ import { D as Sheet, j as Workbook, s as CellInput } from "./model-BUNp7B0Z.js";
27
27
  import { ReadOptions, ReadResult } from "./read.js";
28
- import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-BuG_nn_S.js";
29
- import { n as WriteOptions, t as Progress } from "./write-DM6ieuQY.js";
28
+ import { n as ImportDatasetResult, t as ImportDatasetOptions } from "./pipeline-6PmlmH1-.js";
29
+ import { n as WriteOptions, t as Progress } from "./write-BaMv1Z7W.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`. */
32
32
  export interface MessageEndpoint {
package/dist/worker.js CHANGED
@@ -1,7 +1,7 @@
1
- import { i as toCsv, r as readCsv } from "./csv-pXfaputs.js";
1
+ import { i as toCsv, r as readCsv } from "./csv-CrWF7JS1.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-ClszMDAE.js";
4
- import { t as importDataset } from "./pipeline-2dw9aehe.js";
3
+ import { r as read } from "./read-CFmZioBG.js";
4
+ import { t as importDataset } from "./pipeline-BNhGRJcx.js";
5
5
  import { r as toUint8Array } from "./write-BVXB2_2C.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. */
@@ -1,6 +1,6 @@
1
- import { a as BlobType } from "./warnings-B1v58nCZ.js";
1
+ import { c as BlobType } from "./warnings-DhonqJ7A.js";
2
2
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
3
- import { j as Workbook } from "./model-0JikLfuM.js";
3
+ import { j as Workbook } from "./model-BUNp7B0Z.js";
4
4
  /** MIME type of an .xlsx file. */
5
5
  declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
6
6
  /** Progress of a write or read. */
@@ -1,6 +1,6 @@
1
- import { a as BlobType } from "./warnings-B1v58nCZ.cjs";
1
+ import { c as BlobType } from "./warnings-DhonqJ7A.cjs";
2
2
  import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
3
- import { j as Workbook } from "./model-0JikLfuM.cjs";
3
+ import { j as Workbook } from "./model-BUNp7B0Z.cjs";
4
4
  /** MIME type of an .xlsx file. */
5
5
  declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
6
6
  /** Progress of a write or read. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-excel",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
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": [