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
@@ -0,0 +1,410 @@
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
+ * The workbook model (docs/api.md §3).
25
+ *
26
+ * Plain data only: objects, arrays, strings, numbers, booleans and `Date`s, so
27
+ * a workbook can be `structuredClone`d and posted to a worker. The writer
28
+ * accepts loose `CellInput`; the reader returns normalised `Cell`s.
29
+ * Indices are zero-based; references and ranges are A1 strings.
30
+ */
31
+ /** A workbook. `C` is the cell type: `CellInput` for writer input, `Cell` for reader output. */
32
+ interface Workbook<C = CellInput> {
33
+ /** At least one sheet (`NO_SHEETS` otherwise). */
34
+ sheets: Sheet<C>[];
35
+ /** Index into `sheets` of the sheet shown when the file opens. Default 0. Must not be hidden. */
36
+ activeSheet?: number | undefined;
37
+ /** Use the 1904 date system (`workbookPr/@date1904`). Default false (1900 system). */
38
+ date1904?: boolean | undefined;
39
+ properties?: DocProperties | undefined;
40
+ definedNames?: DefinedName[] | undefined;
41
+ /** Workbook default font, used for `fonts[0]` in styles.xml and for width maths. Default Calibri 11. */
42
+ defaultFont?: Font | undefined;
43
+ /** Reader output only: theme colours and fonts, for resolving theme colours (§3.5.6). Ignored on write in 2.0. */
44
+ theme?: Theme | undefined;
45
+ /** Reader output only: a custom indexed palette (ARGB, index 0..63) from styles.xml, if the file has one. */
46
+ indexedColors?: string[] | undefined;
47
+ /** Calculation flags (`calcPr`). `fullCalcOnLoad` write default: `'auto'`. */
48
+ calc?: {
49
+ fullCalcOnLoad?: boolean | "auto" | undefined;
50
+ } | undefined;
51
+ }
52
+ /** Document properties from docProps/core.xml, app.xml and custom.xml. */
53
+ interface DocProperties {
54
+ title?: string | undefined;
55
+ subject?: string | undefined;
56
+ creator?: string | undefined;
57
+ keywords?: string | undefined;
58
+ description?: string | undefined;
59
+ lastModifiedBy?: string | undefined;
60
+ category?: string | undefined;
61
+ /** Write default: now. */
62
+ created?: Date | undefined;
63
+ /** Write default: now. Also used for zip entry timestamps. */
64
+ modified?: Date | undefined;
65
+ company?: string | undefined;
66
+ manager?: string | undefined;
67
+ /** Write default: `'javascript-excel'`. */
68
+ application?: string | undefined;
69
+ /** docProps/custom.xml. An array, not an object keyed by name, so file-supplied names are never object keys. */
70
+ custom?: Array<{
71
+ name: string;
72
+ value: string | number | boolean | Date;
73
+ }> | undefined;
74
+ }
75
+ /** A workbook- or sheet-level defined name. */
76
+ interface DefinedName {
77
+ /** For example `'TaxRate'`. */
78
+ name: string;
79
+ /** Formula text without `=`: `"'Sheet 1'!$A$1:$B$4"`. */
80
+ ref: string;
81
+ /** Sheet index when the name is local to a sheet (`localSheetId`). */
82
+ sheet?: number | undefined;
83
+ hidden?: boolean | undefined;
84
+ comment?: string | undefined;
85
+ }
86
+ /** A worksheet. */
87
+ interface Sheet<C = CellInput> {
88
+ /** 1–31 characters, none of `\ / ? * [ ] :`, no leading or trailing `'`, unique case-insensitively. */
89
+ name: string;
90
+ /** `rows[r][c]`; both levels may be sparse. Max 1,048,576 rows x 16,384 columns. */
91
+ rows: Array<Array<C | undefined> | undefined>;
92
+ /** Per-row properties, indexed like `rows`. */
93
+ rowProps?: Array<RowProps | undefined> | undefined;
94
+ /** Per-column properties, index 0 = column A. */
95
+ colProps?: Array<ColumnProps | undefined> | undefined;
96
+ /** Merged ranges as A1 strings, e.g. `['A1:C1']`. Must not overlap. */
97
+ merges?: string[] | undefined;
98
+ /** Autofilter range, e.g. `'A1:F1'`. */
99
+ autoFilter?: string | undefined;
100
+ view?: SheetView | undefined;
101
+ print?: PrintSetup | undefined;
102
+ /** Default `'visible'`. */
103
+ state?: "visible" | "hidden" | "veryHidden" | undefined;
104
+ tabColor?: Color | undefined;
105
+ /** Default column width in characters (`sheetFormatPr/@defaultColWidth`). */
106
+ defaultColWidth?: number | undefined;
107
+ /** Default row height in points (`sheetFormatPr/@defaultRowHeight`). */
108
+ defaultRowHeight?: number | undefined;
109
+ /** Style applied under column, row and cell styles on write (§3.5.7). Not produced by the reader. */
110
+ defaultStyle?: Style | undefined;
111
+ /** Reader output only: the used range computed from the cells read, e.g. `'A1:F120'`. */
112
+ dimension?: string | undefined;
113
+ }
114
+ /** Row properties. */
115
+ interface RowProps {
116
+ /** Points, 0..409. */
117
+ height?: number | undefined;
118
+ hidden?: boolean | undefined;
119
+ style?: Style | undefined;
120
+ /** 0..7. */
121
+ outlineLevel?: number | undefined;
122
+ collapsed?: boolean | undefined;
123
+ }
124
+ /** Column properties. */
125
+ interface ColumnProps {
126
+ width?: ColumnWidth | undefined;
127
+ hidden?: boolean | undefined;
128
+ style?: Style | undefined;
129
+ /** 0..7. */
130
+ outlineLevel?: number | undefined;
131
+ collapsed?: boolean | undefined;
132
+ }
133
+ /**
134
+ * Column width.
135
+ * - number or `{ wch }`: width in characters, as Excel's UI shows it (8.43 is the Calibri 11 default).
136
+ * - `{ wpx }`: width in pixels at 96 dpi.
137
+ * - `'auto'`: estimated by the writer from the column's text (no font metrics).
138
+ *
139
+ * Reader output is always a number in characters.
140
+ */
141
+ type ColumnWidth = number | {
142
+ wch: number;
143
+ } | {
144
+ wpx: number;
145
+ } | "auto";
146
+ /** Sheet view settings. */
147
+ interface SheetView {
148
+ /** Frozen panes: rows above and columns left of the split stay visible. */
149
+ freeze?: {
150
+ rows?: number | undefined;
151
+ cols?: number | undefined;
152
+ } | undefined;
153
+ /** `sheetView/@rightToLeft`: column A on the right. */
154
+ rightToLeft?: boolean | undefined;
155
+ /** Default true. */
156
+ showGridLines?: boolean | undefined;
157
+ /** Default true. */
158
+ showRowColHeaders?: boolean | undefined;
159
+ /** Percent, 10..400. */
160
+ zoom?: number | undefined;
161
+ /** For example `'B2'`. */
162
+ activeCell?: string | undefined;
163
+ /** For example `'B2:D5'`. */
164
+ selection?: string | undefined;
165
+ }
166
+ /** Print setup. */
167
+ interface PrintSetup {
168
+ orientation?: "portrait" | "landscape" | undefined;
169
+ /** Paper size code, e.g. 1 = Letter, 9 = A4. */
170
+ paperSize?: number | undefined;
171
+ /** Fit to N pages wide / tall; 0 = automatic. Sets `sheetPr/pageSetUpPr/@fitToPage`. */
172
+ fitTo?: {
173
+ width?: number | undefined;
174
+ height?: number | undefined;
175
+ } | undefined;
176
+ /** Percent, 10..400; ignored when `fitTo` is set. */
177
+ scale?: number | undefined;
178
+ /** Inches. */
179
+ margins?: {
180
+ left?: number | undefined;
181
+ right?: number | undefined;
182
+ top?: number | undefined;
183
+ bottom?: number | undefined;
184
+ header?: number | undefined;
185
+ footer?: number | undefined;
186
+ } | undefined;
187
+ center?: {
188
+ horizontal?: boolean | undefined;
189
+ vertical?: boolean | undefined;
190
+ } | undefined;
191
+ gridLines?: boolean | undefined;
192
+ headings?: boolean | undefined;
193
+ /** Written as the `_xlnm.Print_Area` defined name, e.g. `'A1:F40'`. */
194
+ printArea?: string | undefined;
195
+ /** Written as `_xlnm.Print_Titles`. Rows `'1:2'`, columns `'A:B'`. */
196
+ printTitles?: {
197
+ rows?: string | undefined;
198
+ cols?: string | undefined;
199
+ } | undefined;
200
+ /** Raw header strings with Excel's &-codes, e.g. `'&CPage &P of &N'`. */
201
+ header?: {
202
+ odd?: string | undefined;
203
+ even?: string | undefined;
204
+ first?: string | undefined;
205
+ } | undefined;
206
+ /** Raw footer strings with Excel's &-codes. */
207
+ footer?: {
208
+ odd?: string | undefined;
209
+ even?: string | undefined;
210
+ first?: string | undefined;
211
+ } | undefined;
212
+ }
213
+ /** What the writer accepts in a cell slot. */
214
+ type CellInput = CellValue | Cell | null | undefined;
215
+ /** Bare values. A string is always text, even when it starts with `=`. Only `Cell.formula` makes a formula. */
216
+ type CellValue = string | number | boolean | Date | CellErrorValue | RichText;
217
+ /** An error value such as `#N/A`. */
218
+ interface CellErrorValue {
219
+ error: ErrorCode;
220
+ }
221
+ /** Rich text: a sequence of runs, each with its own font. */
222
+ interface RichText {
223
+ richText: RichTextRun[];
224
+ }
225
+ /** One run of rich text. */
226
+ interface RichTextRun {
227
+ text: string;
228
+ font?: Font | undefined;
229
+ }
230
+ /** The seven error values defined by ECMA-376. */
231
+ type ErrorCode = "#NULL!" | "#DIV/0!" | "#VALUE!" | "#REF!" | "#NAME?" | "#NUM!" | "#N/A";
232
+ /** The type of a cell's value (for formulas, of the cached value). */
233
+ type CellType = "string" | "number" | "boolean" | "date" | "error" | "richText" | "empty";
234
+ /** A cell with value, formula, style and hyperlink. */
235
+ interface Cell {
236
+ /** Literal value, or the cached result when `formula` is set. null/undefined = empty (styled if `style` is set). */
237
+ value?: CellValue | null | undefined;
238
+ /** Formula text without the leading `=`. A leading `=` is accepted on write and stripped. */
239
+ formula?: string | undefined;
240
+ /** Array formula (CSE) range, e.g. `'D1:D3'`; set on the anchor cell only. */
241
+ arrayRef?: string | undefined;
242
+ /**
243
+ * Reader: always set; describes `value` (for formulas, the cached value).
244
+ * Writer: optional. If set, it must match `value` (`INVALID_CELL` otherwise). It is a check, not a coercion.
245
+ */
246
+ type?: CellType | undefined;
247
+ style?: Style | undefined;
248
+ hyperlink?: Hyperlink | undefined;
249
+ }
250
+ /**
251
+ * A cell hyperlink.
252
+ * - string: external URL, shorthand for `{ target }`.
253
+ * - `{ target }`: external (http, https, mailto, ...).
254
+ * - `{ location }`: internal, `"'Sheet 2'!A1"` or a defined name.
255
+ */
256
+ type Hyperlink = string | {
257
+ target: string;
258
+ tooltip?: string | undefined;
259
+ } | {
260
+ location: string;
261
+ tooltip?: string | undefined;
262
+ };
263
+ /** A cell, row, column or default style. Every field is optional. */
264
+ interface Style {
265
+ font?: Font | undefined;
266
+ fill?: Fill | undefined;
267
+ border?: Border | undefined;
268
+ alignment?: Alignment | undefined;
269
+ numFmt?: NumFmt | undefined;
270
+ /** Only takes effect once sheet protection exists (later release). */
271
+ protection?: {
272
+ locked?: boolean | undefined;
273
+ hidden?: boolean | undefined;
274
+ } | undefined;
275
+ }
276
+ /** Font. */
277
+ interface Font {
278
+ /** For example `'Calibri'`. */
279
+ name?: string | undefined;
280
+ /** Points. */
281
+ size?: number | undefined;
282
+ color?: Color | undefined;
283
+ bold?: boolean | undefined;
284
+ italic?: boolean | undefined;
285
+ /** `true` = `'single'`. */
286
+ underline?: boolean | "single" | "double" | "singleAccounting" | "doubleAccounting" | undefined;
287
+ strike?: boolean | undefined;
288
+ vertAlign?: "superscript" | "subscript" | "baseline" | undefined;
289
+ /** Font family class: 0 n/a, 1 Roman, 2 Swiss, 3 Modern, 4 Script, 5 Decorative. */
290
+ family?: number | undefined;
291
+ charset?: number | undefined;
292
+ scheme?: "major" | "minor" | "none" | undefined;
293
+ /** Mac-only rendering. */
294
+ outline?: boolean | undefined;
295
+ /** Mac-only rendering. */
296
+ shadow?: boolean | undefined;
297
+ condense?: boolean | undefined;
298
+ extend?: boolean | undefined;
299
+ }
300
+ /** A fill. A string is shorthand for a solid fill in that colour: `fill: 'FFFF00'`. */
301
+ type Fill = string | PatternFill | GradientFill;
302
+ /** Pattern fill. */
303
+ interface PatternFill {
304
+ type?: "pattern" | undefined;
305
+ pattern: PatternType;
306
+ /** Pattern colour. For `'solid'` this is the cell colour (OOXML puts a solid fill in fgColor). */
307
+ fgColor?: Color | undefined;
308
+ bgColor?: Color | undefined;
309
+ }
310
+ /** `ST_PatternType`, all 19 values. */
311
+ type PatternType = "none" | "solid" | "mediumGray" | "darkGray" | "lightGray" | "darkHorizontal" | "darkVertical" | "darkDown" | "darkUp" | "darkGrid" | "darkTrellis" | "lightHorizontal" | "lightVertical" | "lightDown" | "lightUp" | "lightGrid" | "lightTrellis" | "gray125" | "gray0625";
312
+ /** Gradient fill. */
313
+ interface GradientFill {
314
+ type: "gradient";
315
+ gradient: "linear" | "path";
316
+ /** Linear only. */
317
+ degree?: number | undefined;
318
+ /** Path only, 0..1. */
319
+ left?: number | undefined;
320
+ /** Path only, 0..1. */
321
+ right?: number | undefined;
322
+ /** Path only, 0..1. */
323
+ top?: number | undefined;
324
+ /** Path only, 0..1. */
325
+ bottom?: number | undefined;
326
+ /** Positions 0..1. */
327
+ stops: Array<{
328
+ position: number;
329
+ color: Color;
330
+ }>;
331
+ }
332
+ /** Cell border; each side is independent. */
333
+ interface Border {
334
+ left?: BorderSide | undefined;
335
+ right?: BorderSide | undefined;
336
+ top?: BorderSide | undefined;
337
+ bottom?: BorderSide | undefined;
338
+ diagonal?: BorderSide | undefined;
339
+ diagonalUp?: boolean | undefined;
340
+ diagonalDown?: boolean | undefined;
341
+ }
342
+ /** One border side. */
343
+ interface BorderSide {
344
+ style: BorderStyle;
345
+ /** Default: automatic (black). */
346
+ color?: Color | undefined;
347
+ }
348
+ /** `ST_BorderStyle`, all 14 values. */
349
+ type BorderStyle = "none" | "thin" | "medium" | "thick" | "double" | "hair" | "dotted" | "dashed" | "dashDot" | "dashDotDot" | "mediumDashed" | "mediumDashDot" | "mediumDashDotDot" | "slantDashDot";
350
+ /** Cell alignment. */
351
+ interface Alignment {
352
+ horizontal?: "general" | "left" | "center" | "right" | "fill" | "justify" | "centerContinuous" | "distributed" | undefined;
353
+ vertical?: "top" | "center" | "bottom" | "justify" | "distributed" | undefined;
354
+ wrapText?: boolean | undefined;
355
+ shrinkToFit?: boolean | undefined;
356
+ /** Indent level, in steps of about three character widths. Excel shows it for left, right and distributed. */
357
+ indent?: number | undefined;
358
+ /** Degrees, -90..90, positive = counter-clockwise; or `'vertical'` for stacked text. */
359
+ rotation?: number | "vertical" | undefined;
360
+ readingOrder?: "context" | "ltr" | "rtl" | undefined;
361
+ justifyLastLine?: boolean | undefined;
362
+ }
363
+ /** Number format: a number is a built-in format id (0..163), a string is a format code. */
364
+ type NumFmt = number | string;
365
+ /**
366
+ * A colour.
367
+ * - string: `'RRGGBB'`, `'AARRGGBB'`, `'#RRGGBB'` or `'#AARRGGBB'` (case-insensitive), same as `{ rgb }`.
368
+ * - `{ rgb }`: ARGB, e.g. `'FF336699'`.
369
+ * - `{ theme, tint }`: theme colour index 0..11, tint -1..1.
370
+ * - `{ indexed }`: legacy palette 0..63; 64 = system foreground, 65 = system background.
371
+ * - `{ auto: true }`: automatic colour.
372
+ */
373
+ type Color = string | {
374
+ rgb: string;
375
+ } | {
376
+ theme: number;
377
+ tint?: number | undefined;
378
+ } | {
379
+ indexed: number;
380
+ } | {
381
+ auto: true;
382
+ };
383
+ /** Theme colours and fonts read from xl/theme/theme1.xml. */
384
+ interface Theme {
385
+ /** ARGB in clrScheme order: dk1, lt1, dk2, lt2, accent1..6, hlink, folHlink. */
386
+ colors: string[];
387
+ /** Major (headings) latin typeface. */
388
+ majorFont?: string | undefined;
389
+ /** Minor (body) latin typeface. */
390
+ minorFont?: string | undefined;
391
+ }
392
+ /**
393
+ * Warnings (docs/api.md §7.3).
394
+ *
395
+ * The reader and the CSV parser collect warnings for damage they can recover
396
+ * from, instead of throwing. Each warning is plain data.
397
+ */
398
+ /** Every warning code the library reports. */
399
+ 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" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
400
+ /** A recoverable problem found while reading or building. */
401
+ interface ExcelWarning {
402
+ code: ExcelWarningCode;
403
+ message: string;
404
+ /** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
405
+ part?: string | undefined;
406
+ sheet?: string | undefined;
407
+ /** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
408
+ ref?: string | undefined;
409
+ }
410
+ export { SheetView as A, PatternFill as C, RichTextRun as D, RichText as E, BlobLike as F, BlobType as I, Theme as M, Workbook as N, RowProps as O, BinaryInput as P, NumFmt as S, PrintSetup as T, ErrorCode as _, BorderSide as a, GradientFill as b, CellErrorValue as c, CellValue as d, Color as f, DocProperties as g, DefinedName as h, Border as i, Style as j, Sheet as k, CellInput as l, ColumnWidth as m, ExcelWarningCode as n, BorderStyle as o, ColumnProps as p, Alignment as r, Cell as s, ExcelWarning as t, CellType as u, Fill as v, PatternType as w, Hyperlink as x, Font as y };
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/worker.ts
3
+ /**
4
+ * javascript-excel/worker: Web Worker entry.
5
+ *
6
+ * Placeholder module so the exports map, type resolution and tree-shaking are
7
+ * tested from the start. The real implementation lands in a later pull request.
8
+ */
9
+ /** Name of this entry point. */
10
+ const ENTRY = "javascript-excel/worker";
11
+ exports.ENTRY = ENTRY;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * javascript-excel/worker: Web Worker entry.
3
+ *
4
+ * Placeholder module so the exports map, type resolution and tree-shaking are
5
+ * tested from the start. The real implementation lands in a later pull request.
6
+ */
7
+ /** Name of this entry point. */
8
+ export declare const ENTRY = "javascript-excel/worker";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * javascript-excel/worker: Web Worker entry.
3
+ *
4
+ * Placeholder module so the exports map, type resolution and tree-shaking are
5
+ * tested from the start. The real implementation lands in a later pull request.
6
+ */
7
+ /** Name of this entry point. */
8
+ export declare const ENTRY = "javascript-excel/worker";
package/dist/worker.js ADDED
@@ -0,0 +1,10 @@
1
+ // src/worker.ts
2
+ /**
3
+ * javascript-excel/worker: Web Worker entry.
4
+ *
5
+ * Placeholder module so the exports map, type resolution and tree-shaking are
6
+ * tested from the start. The real implementation lands in a later pull request.
7
+ */
8
+ /** Name of this entry point. */
9
+ const ENTRY = "javascript-excel/worker";
10
+ export { ENTRY };
@@ -0,0 +1,29 @@
1
+ import { I as Workbook, a as BlobType } from "./warnings-C_12PT4t.cjs";
2
+ import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
3
+ /** MIME type of an .xlsx file. */
4
+ declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
5
+ /** Progress of a write or read. */
6
+ interface Progress {
7
+ phase: "prepare" | "styles" | "sheets" | "zip" | "unzip" | "parse";
8
+ sheet?: string | undefined;
9
+ /** Overall progress estimate 0..1, non-decreasing. */
10
+ ratio: number;
11
+ }
12
+ /** Options for toUint8Array and toBlob. */
13
+ interface WriteOptions {
14
+ /** 'deflate' (default) or 'store' (no compression; faster, bigger). */
15
+ compression?: "deflate" | "store" | undefined;
16
+ /** Shared strings table (default true) or inline strings (false). */
17
+ sharedStrings?: boolean | undefined;
18
+ /** Time zone used to turn Date into serials. Default 'local'. */
19
+ dateZone?: "local" | "utc" | undefined;
20
+ /** URL schemes allowed in external hyperlinks. Default ['http', 'https', 'mailto']. */
21
+ hyperlinkSchemes?: string[] | undefined;
22
+ signal?: AbortSignalLike | undefined;
23
+ onProgress?: ((p: Progress) => void) | undefined;
24
+ }
25
+ /** Writes a workbook as .xlsx bytes. */
26
+ declare function toUint8Array(wb: Workbook, options?: WriteOptions): Promise<Uint8Array>;
27
+ /** Writes a workbook as an .xlsx Blob (type XLSX_MIME). */
28
+ declare function toBlob(wb: Workbook, options?: WriteOptions): Promise<BlobType>;
29
+ export { toUint8Array as a, toBlob as i, WriteOptions as n, XLSX_MIME as r, Progress as t };
@@ -0,0 +1,29 @@
1
+ import { I as BlobType, N as Workbook } from "./warnings-DXJKe1lx.js";
2
+ import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
3
+ /** MIME type of an .xlsx file. */
4
+ declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
5
+ /** Progress of a write or read. */
6
+ interface Progress {
7
+ phase: "prepare" | "styles" | "sheets" | "zip" | "unzip" | "parse";
8
+ sheet?: string | undefined;
9
+ /** Overall progress estimate 0..1, non-decreasing. */
10
+ ratio: number;
11
+ }
12
+ /** Options for toUint8Array and toBlob. */
13
+ interface WriteOptions {
14
+ /** 'deflate' (default) or 'store' (no compression; faster, bigger). */
15
+ compression?: "deflate" | "store" | undefined;
16
+ /** Shared strings table (default true) or inline strings (false). */
17
+ sharedStrings?: boolean | undefined;
18
+ /** Time zone used to turn Date into serials. Default 'local'. */
19
+ dateZone?: "local" | "utc" | undefined;
20
+ /** URL schemes allowed in external hyperlinks. Default ['http', 'https', 'mailto']. */
21
+ hyperlinkSchemes?: string[] | undefined;
22
+ signal?: AbortSignalLike | undefined;
23
+ onProgress?: ((p: Progress) => void) | undefined;
24
+ }
25
+ /** Writes a workbook as .xlsx bytes. */
26
+ declare function toUint8Array(wb: Workbook, options?: WriteOptions): Promise<Uint8Array>;
27
+ /** Writes a workbook as an .xlsx Blob (type XLSX_MIME). */
28
+ declare function toBlob(wb: Workbook, options?: WriteOptions): Promise<BlobType>;
29
+ export { toUint8Array as a, toBlob as i, WriteOptions as n, XLSX_MIME as r, Progress as t };
package/package.json CHANGED
@@ -1,65 +1,81 @@
1
1
  {
2
2
  "name": "javascript-excel",
3
- "author": {
4
- "name": "Afzal Ahmad",
5
- "email": "securedeveloper@gmail.com",
6
- "url": "https://github.com/securedeveloper"
7
- },
8
- "description": "A lightweight library to build excel sheet with JavaScript",
3
+ "version": "2.0.0-alpha.1",
4
+ "private": false,
5
+ "description": "Read and write .xlsx and .csv files in browsers, Web Workers and Node. 2.0 is a from-scratch rewrite in progress.",
9
6
  "keywords": [
10
- "js-excel",
11
- "javascript-excel",
12
7
  "excel",
13
8
  "xlsx",
14
- "js-csv",
15
- "javascript-csv",
16
- "csv"
9
+ "csv",
10
+ "spreadsheet",
11
+ "typescript"
17
12
  ],
18
- "version": "1.0.2",
19
- "main": "lib/index.js",
20
13
  "license": "MIT",
21
- "scripts": {
22
- "type-check": "tsc --noEmit",
23
- "type-check:watch": "npm run type-check -- --watch",
24
- "bundle": "webpack",
25
- "build": "npm run test && npm run build:types && npm run build:js",
26
- "build:types": "tsc --emitDeclarationOnly",
27
- "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
28
- "test": "mocha test/**/*.js",
29
- "clean": "rm -rf ./dist && mkdir ./dist",
30
- "build:watch": "babel -w src --out-dir lib",
31
- "lint": "eslint .",
32
- "lint:watch": "esw -w lib/**",
33
- "prepare": "npm run build"
34
- },
35
- "devDependencies": {
36
- "@babel/cli": "7.0.0",
37
- "@babel/core": "7.0.0",
38
- "@babel/plugin-proposal-class-properties": "7.0.0",
39
- "@babel/plugin-proposal-object-rest-spread": "7.0.0",
40
- "@babel/preset-env": "7.0.0",
41
- "@babel/preset-typescript": "7.0.0",
42
- "@types/file-saver": "1.3.0",
43
- "@types/jszip": "3.1.4",
44
- "babel-loader": "8.0.0",
45
- "mocha": "5.2.0",
46
- "typescript": "3.0.3",
47
- "webpack": "4.18.0"
48
- },
49
- "dependencies": {
50
- "file-saver": "1.3.8",
51
- "jszip": "3.1.5"
52
- },
53
- "directories": {
54
- "test": "test"
14
+ "author": {
15
+ "name": "Afzal Ahmad",
16
+ "url": "https://github.com/securedeveloper"
55
17
  },
56
18
  "repository": {
57
19
  "type": "git",
58
- "url": "git+https://github.com/securedeveloper/javascript-excel.git"
20
+ "url": "git+https://github.com/securedeveloper/javascript-excel.git",
21
+ "directory": "packages/javascript-excel"
59
22
  },
60
23
  "bugs": {
61
- "url": "https://github.com/securedeveloper/javascript-excel/issues",
62
- "email": "securedeveloper@gmail.com"
24
+ "url": "https://github.com/securedeveloper/javascript-excel/issues"
25
+ },
26
+ "homepage": "https://github.com/securedeveloper/javascript-excel#readme",
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.cts",
35
+ "exports": {
36
+ ".": {
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.cjs"
39
+ },
40
+ "./read": {
41
+ "import": "./dist/read.js",
42
+ "require": "./dist/read.cjs"
43
+ },
44
+ "./csv": {
45
+ "import": "./dist/csv.js",
46
+ "require": "./dist/csv.cjs"
47
+ },
48
+ "./dom": {
49
+ "import": "./dist/dom.js",
50
+ "require": "./dist/dom.cjs"
51
+ },
52
+ "./worker": {
53
+ "import": "./dist/worker.js",
54
+ "require": "./dist/worker.cjs"
55
+ },
56
+ "./package.json": "./package.json"
63
57
  },
64
- "homepage": "https://github.com/securedeveloper/javascript-excel#readme"
58
+ "engines": {
59
+ "node": ">=22"
60
+ },
61
+ "scripts": {
62
+ "build": "tsdown",
63
+ "test": "vitest run",
64
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.dom.json",
65
+ "lint": "publint --strict",
66
+ "smoke": "node scripts/smoke-pack.mjs",
67
+ "consumer-ts": "node scripts/consumer-ts.mjs",
68
+ "test:browser": "vitest run --config vitest.browser.config.ts"
69
+ },
70
+ "devDependencies": {
71
+ "@types/node": "22.20.5",
72
+ "@vitest/browser-playwright": "5.1.0",
73
+ "happy-dom": "21.0.4",
74
+ "playwright": "1.65.1",
75
+ "publint": "0.3.25",
76
+ "tsdown": "0.23.7",
77
+ "typescript": "7.0.2",
78
+ "vite": "8.3.8",
79
+ "vitest": "5.1.0"
80
+ }
65
81
  }
package/.babelrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "presets": [
3
- "@babel/env",
4
- "@babel/typescript"
5
- ],
6
- "plugins": [
7
- "@babel/proposal-class-properties",
8
- "@babel/proposal-object-rest-spread"
9
- ]
10
- }