javascript-excel 1.0.2 → 2.0.0-alpha.1

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 (49) hide show
  1. package/README.md +50 -2
  2. package/dist/auto-width-2oBzjeNG.d.cts +11 -0
  3. package/dist/auto-width-CT-BihTW.d.ts +10 -0
  4. package/dist/csv.cjs +623 -0
  5. package/dist/csv.d.cts +89 -0
  6. package/dist/csv.d.ts +89 -0
  7. package/dist/csv.js +618 -0
  8. package/dist/dom.cjs +464 -0
  9. package/dist/dom.d.cts +78 -0
  10. package/dist/dom.d.ts +78 -0
  11. package/dist/dom.js +461 -0
  12. package/dist/errors-CvGlfw0E.js +28 -0
  13. package/dist/errors-DOPrrGS4.cjs +69 -0
  14. package/dist/index.cjs +1424 -0
  15. package/dist/index.d.cts +140 -0
  16. package/dist/index.d.ts +140 -0
  17. package/dist/index.js +1397 -0
  18. package/dist/infer-BR-J9BZa.js +88 -0
  19. package/dist/infer-D9EC9vJ-.cjs +105 -0
  20. package/dist/iso-date-B22IvwL1.js +21 -0
  21. package/dist/iso-date-BSUsPSWO.cjs +26 -0
  22. package/dist/numfmt-B-TlCgr7.cjs +476 -0
  23. package/dist/numfmt-DEm0sYBJ.js +399 -0
  24. package/dist/read.cjs +2899 -0
  25. package/dist/read.d.cts +88 -0
  26. package/dist/read.d.ts +88 -0
  27. package/dist/read.js +2895 -0
  28. package/dist/sheet-names-CDsVK15c.js +831 -0
  29. package/dist/sheet-names-Cm-IhbBk.cjs +1004 -0
  30. package/dist/signal-Dz0ZYe6d.d.cts +13 -0
  31. package/dist/signal-Dz0ZYe6d.d.ts +13 -0
  32. package/dist/warnings-C_12PT4t.d.cts +410 -0
  33. package/dist/warnings-DXJKe1lx.d.ts +410 -0
  34. package/dist/worker.cjs +11 -0
  35. package/dist/worker.d.cts +8 -0
  36. package/dist/worker.d.ts +8 -0
  37. package/dist/worker.js +10 -0
  38. package/dist/write-C5JgeIar.d.cts +29 -0
  39. package/dist/write-CYpLGuzl.d.ts +29 -0
  40. package/package.json +67 -51
  41. package/.babelrc +0 -10
  42. package/.circleci/config.yml +0 -39
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.js +0 -23
  45. package/src/index.tsx +0 -11
  46. package/test/unit/sample.spec.js +0 -5
  47. package/tsconfig.json +0 -54
  48. package/webpack.config.js +0 -19
  49. /package/{LICENSE.md → LICENSE} +0 -0
package/dist/csv.d.cts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * javascript-excel/csv: CSV parse and serialize (docs/api.md §5.3).
3
+ *
4
+ * RFC 4180 with the usual real-world extensions: delimiter detection, CRLF,
5
+ * LF and CR newlines, a UTF-8 BOM, and lenient recovery from malformed
6
+ * quoting (warnings) unless `mode: 'strict'`. Pulls in nothing from the xlsx
7
+ * code.
8
+ */
9
+ import { A as RichTextRun, I as Workbook, M as Sheet, a as BlobType, b as ErrorCode, d as CellErrorValue, f as CellInput, i as BlobLike, k as RichText, m as CellValue, n as ExcelWarningCode, p as CellType, r as BinaryInput, t as ExcelWarning, u as Cell } from "./warnings-C_12PT4t.cjs";
10
+ import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
11
+ /** Options for `parseCsv` and `readCsv`. */
12
+ export interface CsvParseOptions {
13
+ /** A single character, or `'auto'` (default): picks from `, ; TAB |` by field-count consistency over the first records. */
14
+ delimiter?: string | undefined;
15
+ /** Default `'"'`. A quote inside a quoted field is doubled (RFC 4180). */
16
+ quote?: string | undefined;
17
+ /**
18
+ * Default false: every field is a string. true: unquoted fields that are numbers,
19
+ * `TRUE`/`FALSE` (or `true`/`false`) or ISO 8601 dates become numbers, booleans and
20
+ * `Date`s. No locale guessing. Quoted fields always stay strings.
21
+ */
22
+ inferTypes?: boolean | undefined;
23
+ /** Time zone for ISO dates without an offset when `inferTypes` is on. Default `'local'`. */
24
+ dateZone?: "local" | "utc" | undefined;
25
+ /** Default false. A blank line otherwise gives an empty row (`[]`). */
26
+ skipEmptyLines?: boolean | undefined;
27
+ /** `'lenient'` (default): malformed input gives warnings. `'strict'`: throws `CsvError` (`CSV_MALFORMED`). */
28
+ mode?: "lenient" | "strict" | undefined;
29
+ /** Stop after this many rows, with warning `CSV_ROWS_TRUNCATED`. Default unlimited. */
30
+ maxRows?: number | undefined;
31
+ /** Largest field, in UTF-8 bytes; a bigger one throws `LimitError` (`LIMIT_EXCEEDED`). Default 1,048,576 (1 MiB). */
32
+ maxFieldBytes?: number | undefined;
33
+ }
34
+ /** Options for `readCsv`. */
35
+ export interface CsvReadOptions extends CsvParseOptions {
36
+ /** Used when the bytes have no BOM. Any label `TextDecoder` accepts. Default `'utf-8'`. */
37
+ encoding?: string | undefined;
38
+ /** Rejects with `signal.reason` when aborted. */
39
+ signal?: AbortSignalLike | undefined;
40
+ }
41
+ /** Result of `parseCsv` and `readCsv`. */
42
+ export interface CsvParseResult {
43
+ /** `string[][]` unless `inferTypes`. */
44
+ rows: CellValue[][];
45
+ /** The delimiter used (detected or given). */
46
+ delimiter: string;
47
+ /** The first newline seen; `'\r\n'` when the input has none. */
48
+ newline: "\r\n" | "\n" | "\r";
49
+ /** The input started with a BOM (removed from the data). */
50
+ bom: boolean;
51
+ /** `CSV_UNTERMINATED_QUOTE`, `CSV_STRAY_QUOTE`, `CSV_FIELD_COUNT`, `CSV_INVALID_ENCODING`, `CSV_ROWS_TRUNCATED`. */
52
+ warnings: ExcelWarning[];
53
+ }
54
+ /** Options for `toCsv` and `toCsvBlob`. */
55
+ export interface CsvWriteOptions {
56
+ /** Default `','`. */
57
+ delimiter?: string | undefined;
58
+ /** Default `'\r\n'` (RFC 4180). */
59
+ newline?: "\r\n" | "\n" | undefined;
60
+ /** `'auto'` (default): quote fields containing the delimiter, a quote, CR or LF. `'all'`: quote every field. */
61
+ quote?: "auto" | "all" | undefined;
62
+ /** Prepend a UTF-8 BOM so Excel detects UTF-8. `toCsvBlob` default true, `toCsv` default false. */
63
+ bom?: boolean | undefined;
64
+ /**
65
+ * Formula-injection guard, default true: a string field starting with `=`, `+`, `-`, `@`,
66
+ * TAB or CR gets a leading `'`. Numbers, booleans and dates are never prefixed.
67
+ */
68
+ escapeFormulas?: boolean | undefined;
69
+ /** `'iso'` (default): `YYYY-MM-DD`, or `YYYY-MM-DDTHH:mm:ss` (`.sss` when there are milliseconds). Or a function. */
70
+ dates?: "iso" | ((d: Date) => string) | undefined;
71
+ /** Time zone for `'iso'` dates. Default `'local'`. */
72
+ dateZone?: "local" | "utc" | undefined;
73
+ /** Formula cells: the cached value (default) or the formula text (`'formula'`, which still passes the guard). */
74
+ formulas?: "value" | "formula" | undefined;
75
+ }
76
+ /** MIME type of `toCsvBlob` output. */
77
+ export declare const CSV_MIME = "text/csv;charset=utf-8";
78
+ /** Parses CSV text synchronously. */
79
+ export declare function parseCsv(text: string, options?: CsvParseOptions): CsvParseResult;
80
+ /**
81
+ * Decodes (for bytes) and parses CSV without blocking: it yields to the event
82
+ * loop between chunks of records and honours `signal`.
83
+ */
84
+ export declare function readCsv(input: string | BinaryInput, options?: CsvReadOptions): Promise<CsvParseResult>;
85
+ /** Serializes a sheet (A1 to its last used cell) or an array of rows to CSV text. */
86
+ export declare function toCsv(source: Sheet | CellInput[][], options?: CsvWriteOptions): string;
87
+ /** Like `toCsv`, as a `Blob` of type `text/csv;charset=utf-8`, with a BOM unless `bom: false`. */
88
+ export declare function toCsvBlob(source: Sheet | CellInput[][], options?: CsvWriteOptions): BlobType;
89
+ export type { AbortSignalLike, BinaryInput, BlobLike, BlobType, Cell, CellErrorValue, CellInput, CellType, CellValue, ErrorCode, ExcelWarning, ExcelWarningCode, RichText, RichTextRun, Sheet, Workbook };
package/dist/csv.d.ts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * javascript-excel/csv: CSV parse and serialize (docs/api.md §5.3).
3
+ *
4
+ * RFC 4180 with the usual real-world extensions: delimiter detection, CRLF,
5
+ * LF and CR newlines, a UTF-8 BOM, and lenient recovery from malformed
6
+ * quoting (warnings) unless `mode: 'strict'`. Pulls in nothing from the xlsx
7
+ * code.
8
+ */
9
+ import { D as RichTextRun, E as RichText, F as BlobLike, I as BlobType, N as Workbook, P as BinaryInput, _ as ErrorCode, c as CellErrorValue, d as CellValue, k as Sheet, l as CellInput, n as ExcelWarningCode, s as Cell, t as ExcelWarning, u as CellType } from "./warnings-DXJKe1lx.js";
10
+ import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
11
+ /** Options for `parseCsv` and `readCsv`. */
12
+ export interface CsvParseOptions {
13
+ /** A single character, or `'auto'` (default): picks from `, ; TAB |` by field-count consistency over the first records. */
14
+ delimiter?: string | undefined;
15
+ /** Default `'"'`. A quote inside a quoted field is doubled (RFC 4180). */
16
+ quote?: string | undefined;
17
+ /**
18
+ * Default false: every field is a string. true: unquoted fields that are numbers,
19
+ * `TRUE`/`FALSE` (or `true`/`false`) or ISO 8601 dates become numbers, booleans and
20
+ * `Date`s. No locale guessing. Quoted fields always stay strings.
21
+ */
22
+ inferTypes?: boolean | undefined;
23
+ /** Time zone for ISO dates without an offset when `inferTypes` is on. Default `'local'`. */
24
+ dateZone?: "local" | "utc" | undefined;
25
+ /** Default false. A blank line otherwise gives an empty row (`[]`). */
26
+ skipEmptyLines?: boolean | undefined;
27
+ /** `'lenient'` (default): malformed input gives warnings. `'strict'`: throws `CsvError` (`CSV_MALFORMED`). */
28
+ mode?: "lenient" | "strict" | undefined;
29
+ /** Stop after this many rows, with warning `CSV_ROWS_TRUNCATED`. Default unlimited. */
30
+ maxRows?: number | undefined;
31
+ /** Largest field, in UTF-8 bytes; a bigger one throws `LimitError` (`LIMIT_EXCEEDED`). Default 1,048,576 (1 MiB). */
32
+ maxFieldBytes?: number | undefined;
33
+ }
34
+ /** Options for `readCsv`. */
35
+ export interface CsvReadOptions extends CsvParseOptions {
36
+ /** Used when the bytes have no BOM. Any label `TextDecoder` accepts. Default `'utf-8'`. */
37
+ encoding?: string | undefined;
38
+ /** Rejects with `signal.reason` when aborted. */
39
+ signal?: AbortSignalLike | undefined;
40
+ }
41
+ /** Result of `parseCsv` and `readCsv`. */
42
+ export interface CsvParseResult {
43
+ /** `string[][]` unless `inferTypes`. */
44
+ rows: CellValue[][];
45
+ /** The delimiter used (detected or given). */
46
+ delimiter: string;
47
+ /** The first newline seen; `'\r\n'` when the input has none. */
48
+ newline: "\r\n" | "\n" | "\r";
49
+ /** The input started with a BOM (removed from the data). */
50
+ bom: boolean;
51
+ /** `CSV_UNTERMINATED_QUOTE`, `CSV_STRAY_QUOTE`, `CSV_FIELD_COUNT`, `CSV_INVALID_ENCODING`, `CSV_ROWS_TRUNCATED`. */
52
+ warnings: ExcelWarning[];
53
+ }
54
+ /** Options for `toCsv` and `toCsvBlob`. */
55
+ export interface CsvWriteOptions {
56
+ /** Default `','`. */
57
+ delimiter?: string | undefined;
58
+ /** Default `'\r\n'` (RFC 4180). */
59
+ newline?: "\r\n" | "\n" | undefined;
60
+ /** `'auto'` (default): quote fields containing the delimiter, a quote, CR or LF. `'all'`: quote every field. */
61
+ quote?: "auto" | "all" | undefined;
62
+ /** Prepend a UTF-8 BOM so Excel detects UTF-8. `toCsvBlob` default true, `toCsv` default false. */
63
+ bom?: boolean | undefined;
64
+ /**
65
+ * Formula-injection guard, default true: a string field starting with `=`, `+`, `-`, `@`,
66
+ * TAB or CR gets a leading `'`. Numbers, booleans and dates are never prefixed.
67
+ */
68
+ escapeFormulas?: boolean | undefined;
69
+ /** `'iso'` (default): `YYYY-MM-DD`, or `YYYY-MM-DDTHH:mm:ss` (`.sss` when there are milliseconds). Or a function. */
70
+ dates?: "iso" | ((d: Date) => string) | undefined;
71
+ /** Time zone for `'iso'` dates. Default `'local'`. */
72
+ dateZone?: "local" | "utc" | undefined;
73
+ /** Formula cells: the cached value (default) or the formula text (`'formula'`, which still passes the guard). */
74
+ formulas?: "value" | "formula" | undefined;
75
+ }
76
+ /** MIME type of `toCsvBlob` output. */
77
+ export declare const CSV_MIME = "text/csv;charset=utf-8";
78
+ /** Parses CSV text synchronously. */
79
+ export declare function parseCsv(text: string, options?: CsvParseOptions): CsvParseResult;
80
+ /**
81
+ * Decodes (for bytes) and parses CSV without blocking: it yields to the event
82
+ * loop between chunks of records and honours `signal`.
83
+ */
84
+ export declare function readCsv(input: string | BinaryInput, options?: CsvReadOptions): Promise<CsvParseResult>;
85
+ /** Serializes a sheet (A1 to its last used cell) or an array of rows to CSV text. */
86
+ export declare function toCsv(source: Sheet | CellInput[][], options?: CsvWriteOptions): string;
87
+ /** Like `toCsv`, as a `Blob` of type `text/csv;charset=utf-8`, with a BOM unless `bom: false`. */
88
+ export declare function toCsvBlob(source: Sheet | CellInput[][], options?: CsvWriteOptions): BlobType;
89
+ export type { AbortSignalLike, BinaryInput, BlobLike, BlobType, Cell, CellErrorValue, CellInput, CellType, CellValue, ErrorCode, ExcelWarning, ExcelWarningCode, RichText, RichTextRun, Sheet, Workbook };