@sheetkit/node 0.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.
Files changed (3) hide show
  1. package/index.d.ts +698 -0
  2. package/index.js +584 -0
  3. package/package.json +50 -0
package/index.d.ts ADDED
@@ -0,0 +1,698 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /** Forward-only streaming writer for large sheets. */
4
+ export declare class JsStreamWriter {
5
+ /** Get the sheet name. */
6
+ get sheetName(): string
7
+ /** Set column width (1-based column number). */
8
+ setColWidth(col: number, width: number): void
9
+ /** Set column width for a range of columns. */
10
+ setColWidthRange(minCol: number, maxCol: number, width: number): void
11
+ /** Write a row of values. Rows must be written in ascending order. */
12
+ writeRow(row: number, values: Array<string | number | boolean | null>): void
13
+ /** Add a merge cell reference (e.g., "A1:C3"). */
14
+ addMergeCell(reference: string): void
15
+ }
16
+
17
+ /** Excel workbook for reading and writing .xlsx files. */
18
+ export declare class Workbook {
19
+ /** Create a new empty workbook with a single sheet named "Sheet1". */
20
+ constructor()
21
+ /** Open an existing .xlsx file from disk. */
22
+ static openSync(path: string): Workbook
23
+ /** Open an existing .xlsx file from disk asynchronously. */
24
+ static open(path: string): Promise<Workbook>
25
+ /** Save the workbook to a .xlsx file. */
26
+ saveSync(path: string): void
27
+ /** Save the workbook to a .xlsx file asynchronously. */
28
+ save(path: string): Promise<void>
29
+ /** Open an encrypted .xlsx file using a password. */
30
+ static openWithPasswordSync(path: string, password: string): Workbook
31
+ /** Open an encrypted .xlsx file using a password asynchronously. */
32
+ static openWithPassword(path: string, password: string): Promise<Workbook>
33
+ /** Save the workbook as an encrypted .xlsx file. */
34
+ saveWithPasswordSync(path: string, password: string): void
35
+ /** Save the workbook as an encrypted .xlsx file asynchronously. */
36
+ saveWithPassword(path: string, password: string): Promise<void>
37
+ /** Get the names of all sheets in workbook order. */
38
+ get sheetNames(): Array<string>
39
+ /** Get the value of a cell. Returns string, number, boolean, DateValue, or null. */
40
+ getCellValue(sheet: string, cell: string): null | boolean | number | string | DateValue
41
+ /** Set the value of a cell. Pass string, number, boolean, DateValue, or null to clear. */
42
+ setCellValue(sheet: string, cell: string, value: string | number | boolean | DateValue | null): void
43
+ /** Create a new empty sheet. Returns the 0-based sheet index. */
44
+ newSheet(name: string): number
45
+ /** Delete a sheet by name. */
46
+ deleteSheet(name: string): void
47
+ /** Rename a sheet. */
48
+ setSheetName(oldName: string, newName: string): void
49
+ /** Copy a sheet. Returns the new sheet's 0-based index. */
50
+ copySheet(source: string, target: string): number
51
+ /** Get the 0-based index of a sheet, or null if not found. */
52
+ getSheetIndex(name: string): number | null
53
+ /** Get the name of the active sheet. */
54
+ getActiveSheet(): string
55
+ /** Set the active sheet by name. */
56
+ setActiveSheet(name: string): void
57
+ /** Insert empty rows starting at the given 1-based row number. */
58
+ insertRows(sheet: string, startRow: number, count: number): void
59
+ /** Remove a row (1-based). */
60
+ removeRow(sheet: string, row: number): void
61
+ /** Duplicate a row (1-based). */
62
+ duplicateRow(sheet: string, row: number): void
63
+ /** Set the height of a row (1-based). */
64
+ setRowHeight(sheet: string, row: number, height: number): void
65
+ /** Get the height of a row, or null if not explicitly set. */
66
+ getRowHeight(sheet: string, row: number): number | null
67
+ /** Set whether a row is visible. */
68
+ setRowVisible(sheet: string, row: number, visible: boolean): void
69
+ /** Get whether a row is visible. Returns true if visible (not hidden). */
70
+ getRowVisible(sheet: string, row: number): boolean
71
+ /** Set the outline level of a row (0-7). */
72
+ setRowOutlineLevel(sheet: string, row: number, level: number): void
73
+ /** Get the outline level of a row. Returns 0 if not set. */
74
+ getRowOutlineLevel(sheet: string, row: number): number
75
+ /** Set the width of a column (e.g., "A", "B", "AA"). */
76
+ setColWidth(sheet: string, col: string, width: number): void
77
+ /** Get the width of a column, or null if not explicitly set. */
78
+ getColWidth(sheet: string, col: string): number | null
79
+ /** Set whether a column is visible. */
80
+ setColVisible(sheet: string, col: string, visible: boolean): void
81
+ /** Get whether a column is visible. Returns true if visible (not hidden). */
82
+ getColVisible(sheet: string, col: string): boolean
83
+ /** Set the outline level of a column (0-7). */
84
+ setColOutlineLevel(sheet: string, col: string, level: number): void
85
+ /** Get the outline level of a column. Returns 0 if not set. */
86
+ getColOutlineLevel(sheet: string, col: string): number
87
+ /** Insert empty columns starting at the given column letter. */
88
+ insertCols(sheet: string, col: string, count: number): void
89
+ /** Remove a column by letter. */
90
+ removeCol(sheet: string, col: string): void
91
+ /** Add a style definition. Returns the style ID for use with setCellStyle. */
92
+ addStyle(style: JsStyle): number
93
+ /** Get the style ID applied to a cell, or null if default. */
94
+ getCellStyle(sheet: string, cell: string): number | null
95
+ /** Apply a style ID to a cell. */
96
+ setCellStyle(sheet: string, cell: string, styleId: number): void
97
+ /** Apply a style ID to an entire row. */
98
+ setRowStyle(sheet: string, row: number, styleId: number): void
99
+ /** Get the style ID for a row. Returns 0 if not set. */
100
+ getRowStyle(sheet: string, row: number): number
101
+ /** Apply a style ID to an entire column. */
102
+ setColStyle(sheet: string, col: string, styleId: number): void
103
+ /** Get the style ID for a column. Returns 0 if not set. */
104
+ getColStyle(sheet: string, col: string): number
105
+ /** Add a chart to a sheet. */
106
+ addChart(sheet: string, fromCell: string, toCell: string, config: JsChartConfig): void
107
+ /** Add an image to a sheet. */
108
+ addImage(sheet: string, config: JsImageConfig): void
109
+ /** Merge a range of cells on a sheet. */
110
+ mergeCells(sheet: string, topLeft: string, bottomRight: string): void
111
+ /** Remove a merged cell range from a sheet. */
112
+ unmergeCell(sheet: string, reference: string): void
113
+ /** Get all merged cell ranges on a sheet. */
114
+ getMergeCells(sheet: string): Array<string>
115
+ /** Add a data validation rule to a sheet. */
116
+ addDataValidation(sheet: string, config: JsDataValidationConfig): void
117
+ /** Get all data validations on a sheet. */
118
+ getDataValidations(sheet: string): Array<JsDataValidationConfig>
119
+ /** Remove a data validation by sqref. */
120
+ removeDataValidation(sheet: string, sqref: string): void
121
+ /** Set conditional formatting rules on a cell range. */
122
+ setConditionalFormat(sheet: string, sqref: string, rules: Array<JsConditionalFormatRule>): void
123
+ /** Get all conditional formatting rules for a sheet. */
124
+ getConditionalFormats(sheet: string): Array<JsConditionalFormatEntry>
125
+ /** Delete conditional formatting for a specific cell range. */
126
+ deleteConditionalFormat(sheet: string, sqref: string): void
127
+ /** Add a comment to a cell. */
128
+ addComment(sheet: string, config: JsCommentConfig): void
129
+ /** Get all comments on a sheet. */
130
+ getComments(sheet: string): Array<JsCommentConfig>
131
+ /** Remove a comment from a cell. */
132
+ removeComment(sheet: string, cell: string): void
133
+ /** Set an auto-filter on a sheet. */
134
+ setAutoFilter(sheet: string, range: string): void
135
+ /** Remove the auto-filter from a sheet. */
136
+ removeAutoFilter(sheet: string): void
137
+ /** Create a new stream writer for a new sheet. */
138
+ newStreamWriter(sheetName: string): JsStreamWriter
139
+ /** Apply a stream writer's output to the workbook. Returns the sheet index. */
140
+ applyStreamWriter(writer: JsStreamWriter): number
141
+ /** Set core document properties (title, creator, etc.). */
142
+ setDocProps(props: JsDocProperties): void
143
+ /** Get core document properties. */
144
+ getDocProps(): JsDocProperties
145
+ /** Set application properties (company, app version, etc.). */
146
+ setAppProps(props: JsAppProperties): void
147
+ /** Get application properties. */
148
+ getAppProps(): JsAppProperties
149
+ /** Set a custom property. Value can be string, number, or boolean. */
150
+ setCustomProperty(name: string, value: string | number | boolean): void
151
+ /** Get a custom property value, or null if not found. */
152
+ getCustomProperty(name: string): string | number | boolean | null
153
+ /** Delete a custom property. Returns true if it existed. */
154
+ deleteCustomProperty(name: string): boolean
155
+ /** Protect the workbook structure/windows with optional password. */
156
+ protectWorkbook(config: JsWorkbookProtectionConfig): void
157
+ /** Remove workbook protection. */
158
+ unprotectWorkbook(): void
159
+ /** Check if the workbook is protected. */
160
+ isWorkbookProtected(): boolean
161
+ /**
162
+ * Set freeze panes on a sheet.
163
+ * The cell reference indicates the top-left cell of the scrollable area.
164
+ * For example, "A2" freezes row 1, "B1" freezes column A.
165
+ */
166
+ setPanes(sheet: string, cell: string): void
167
+ /** Remove any freeze or split panes from a sheet. */
168
+ unsetPanes(sheet: string): void
169
+ /** Get the current freeze pane cell reference for a sheet, or null if none. */
170
+ getPanes(sheet: string): string | null
171
+ /** Set page margins on a sheet (values in inches). */
172
+ setPageMargins(sheet: string, margins: JsPageMargins): void
173
+ /** Get page margins for a sheet. Returns defaults if not explicitly set. */
174
+ getPageMargins(sheet: string): JsPageMargins
175
+ /** Set page setup options (paper size, orientation, scale, fit-to-page). */
176
+ setPageSetup(sheet: string, setup: JsPageSetup): void
177
+ /** Get the page setup for a sheet. */
178
+ getPageSetup(sheet: string): JsPageSetup
179
+ /** Set header and footer text for printing. */
180
+ setHeaderFooter(sheet: string, header?: string | undefined | null, footer?: string | undefined | null): void
181
+ /**
182
+ * Get the header and footer text for a sheet.
183
+ * Returns an object with `header` and `footer` fields, each possibly null.
184
+ */
185
+ getHeaderFooter(sheet: string): JsHeaderFooter
186
+ /** Set print options on a sheet. */
187
+ setPrintOptions(sheet: string, opts: JsPrintOptions): void
188
+ /** Get print options for a sheet. */
189
+ getPrintOptions(sheet: string): JsPrintOptions
190
+ /** Insert a horizontal page break before the given 1-based row. */
191
+ insertPageBreak(sheet: string, row: number): void
192
+ /** Remove a horizontal page break at the given 1-based row. */
193
+ removePageBreak(sheet: string, row: number): void
194
+ /** Get all row page break positions (1-based row numbers). */
195
+ getPageBreaks(sheet: string): Array<number>
196
+ /** Set a hyperlink on a cell. */
197
+ setCellHyperlink(sheet: string, cell: string, opts: JsHyperlinkOptions): void
198
+ /** Get hyperlink information for a cell, or null if no hyperlink exists. */
199
+ getCellHyperlink(sheet: string, cell: string): JsHyperlinkInfo | null
200
+ /** Delete a hyperlink from a cell. */
201
+ deleteCellHyperlink(sheet: string, cell: string): void
202
+ /**
203
+ * Get all rows with their data from a sheet.
204
+ * Only rows that contain at least one cell are included.
205
+ */
206
+ getRows(sheet: string): Array<JsRowData>
207
+ /**
208
+ * Get all columns with their data from a sheet.
209
+ * Only columns that have data are included.
210
+ */
211
+ getCols(sheet: string): Array<JsColData>
212
+ /** Evaluate a formula string against the current workbook data. */
213
+ evaluateFormula(sheet: string, formula: string): null | boolean | number | string | DateValue
214
+ /** Recalculate all formula cells in the workbook. */
215
+ calculateAll(): void
216
+ /** Add a pivot table to the workbook. */
217
+ addPivotTable(config: JsPivotTableConfig): void
218
+ /** Get all pivot tables in the workbook. */
219
+ getPivotTables(): Array<JsPivotTableInfo>
220
+ /** Delete a pivot table by name. */
221
+ deletePivotTable(name: string): void
222
+ /** Add a sparkline to a worksheet. */
223
+ addSparkline(sheet: string, config: JsSparklineConfig): void
224
+ /** Get all sparklines for a worksheet. */
225
+ getSparklines(sheet: string): Array<JsSparklineConfig>
226
+ /** Remove a sparkline by its location cell reference. */
227
+ removeSparkline(sheet: string, location: string): void
228
+ /** Set a cell to a rich text value with multiple formatted runs. */
229
+ setCellRichText(sheet: string, cell: string, runs: Array<JsRichTextRun>): void
230
+ /** Get rich text runs for a cell, or null if not rich text. */
231
+ getCellRichText(sheet: string, cell: string): Array<JsRichTextRun> | null
232
+ /**
233
+ * Resolve a theme color by index (0-11) with optional tint.
234
+ * Returns the ARGB hex string (e.g. "FF4472C4") or null if out of range.
235
+ */
236
+ getThemeColor(index: number, tint?: number | undefined | null): string | null
237
+ /**
238
+ * Add or update a defined name. If a name with the same name and scope
239
+ * already exists, its value and comment are updated.
240
+ */
241
+ setDefinedName(config: JsDefinedNameConfig): void
242
+ /**
243
+ * Get a defined name by name and optional scope (sheet name).
244
+ * Returns null if no matching defined name is found.
245
+ */
246
+ getDefinedName(name: string, scope?: string | undefined | null): JsDefinedNameInfo | null
247
+ /** Get all defined names in the workbook. */
248
+ getDefinedNames(): Array<JsDefinedNameInfo>
249
+ /** Delete a defined name by name and optional scope (sheet name). */
250
+ deleteDefinedName(name: string, scope?: string | undefined | null): void
251
+ /** Protect a sheet with optional password and permission settings. */
252
+ protectSheet(sheet: string, config?: JsSheetProtectionConfig | undefined | null): void
253
+ /** Remove sheet protection. */
254
+ unprotectSheet(sheet: string): void
255
+ /** Check if a sheet is protected. */
256
+ isSheetProtected(sheet: string): boolean
257
+ }
258
+
259
+ export interface DateValue {
260
+ type: string
261
+ serial: number
262
+ iso?: string
263
+ }
264
+
265
+ export interface JsAlignmentStyle {
266
+ horizontal?: string
267
+ vertical?: string
268
+ wrapText?: boolean
269
+ textRotation?: number
270
+ indent?: number
271
+ shrinkToFit?: boolean
272
+ }
273
+
274
+ export interface JsAppProperties {
275
+ application?: string
276
+ docSecurity?: number
277
+ company?: string
278
+ appVersion?: string
279
+ manager?: string
280
+ template?: string
281
+ }
282
+
283
+ export interface JsBorderSideStyle {
284
+ style?: string
285
+ color?: string
286
+ }
287
+
288
+ export interface JsBorderStyle {
289
+ left?: JsBorderSideStyle
290
+ right?: JsBorderSideStyle
291
+ top?: JsBorderSideStyle
292
+ bottom?: JsBorderSideStyle
293
+ diagonal?: JsBorderSideStyle
294
+ }
295
+
296
+ export interface JsChartConfig {
297
+ chartType: string
298
+ title?: string
299
+ series: Array<JsChartSeries>
300
+ showLegend?: boolean
301
+ view3D?: JsView3DConfig
302
+ }
303
+
304
+ export interface JsChartSeries {
305
+ name: string
306
+ categories: string
307
+ values: string
308
+ xValues?: string
309
+ bubbleSizes?: string
310
+ }
311
+
312
+ /** A single cell entry with its row number and value. */
313
+ export interface JsColCell {
314
+ /** 1-based row number. */
315
+ row: number
316
+ /** Cell value type: "string", "number", "boolean", "date", "empty", "error", "formula". */
317
+ valueType: string
318
+ /** String representation of the cell value. */
319
+ value?: string
320
+ /** Numeric value (only set when value_type is "number"). */
321
+ numberValue?: number
322
+ /** Boolean value (only set when value_type is "boolean"). */
323
+ boolValue?: boolean
324
+ }
325
+
326
+ /** A column with its name and cell data. */
327
+ export interface JsColData {
328
+ /** Column name (e.g., "A", "B", "AA"). */
329
+ column: string
330
+ /** Cells with data in this column. */
331
+ cells: Array<JsColCell>
332
+ }
333
+
334
+ export interface JsCommentConfig {
335
+ cell: string
336
+ author: string
337
+ text: string
338
+ }
339
+
340
+ /** Result of getting conditional formats from a sheet. */
341
+ export interface JsConditionalFormatEntry {
342
+ /** Cell range (e.g., "A1:A100"). */
343
+ sqref: string
344
+ /** Rules applied to this range. */
345
+ rules: Array<JsConditionalFormatRule>
346
+ }
347
+
348
+ /** Conditional formatting rule configuration. */
349
+ export interface JsConditionalFormatRule {
350
+ /**
351
+ * Rule type: "cellIs", "expression", "colorScale", "dataBar",
352
+ * "duplicateValues", "uniqueValues", "top10", "bottom10",
353
+ * "aboveAverage", "containsBlanks", "notContainsBlanks",
354
+ * "containsErrors", "notContainsErrors", "containsText",
355
+ * "notContainsText", "beginsWith", "endsWith".
356
+ */
357
+ ruleType: string
358
+ /** Comparison operator for cellIs rules. */
359
+ operator?: string
360
+ /** First formula/value. */
361
+ formula?: string
362
+ /** Second formula/value (for between/notBetween). */
363
+ formula2?: string
364
+ /** Text for text-based rules. */
365
+ text?: string
366
+ /** Rank for top10/bottom10 rules. */
367
+ rank?: number
368
+ /** Whether rank is a percentage. */
369
+ percent?: boolean
370
+ /** Whether rule is above average (for aboveAverage rules). */
371
+ above?: boolean
372
+ /** Whether equal values count as matching (for aboveAverage rules). */
373
+ equalAverage?: boolean
374
+ /** Color scale minimum value type. */
375
+ minType?: string
376
+ /** Color scale minimum value. */
377
+ minValue?: string
378
+ /** Color scale minimum color (ARGB hex). */
379
+ minColor?: string
380
+ /** Color scale middle value type. */
381
+ midType?: string
382
+ /** Color scale middle value. */
383
+ midValue?: string
384
+ /** Color scale middle color (ARGB hex). */
385
+ midColor?: string
386
+ /** Color scale maximum value type. */
387
+ maxType?: string
388
+ /** Color scale maximum value. */
389
+ maxValue?: string
390
+ /** Color scale maximum color (ARGB hex). */
391
+ maxColor?: string
392
+ /** Data bar color (ARGB hex). */
393
+ barColor?: string
394
+ /** Whether to show the cell value alongside the data bar. */
395
+ showValue?: boolean
396
+ /** Differential style to apply. */
397
+ format?: JsConditionalStyle
398
+ /** Rule priority (lower = higher precedence). */
399
+ priority?: number
400
+ /** If true, no lower-priority rules apply when this matches. */
401
+ stopIfTrue?: boolean
402
+ }
403
+
404
+ /** Conditional formatting style (differential format). */
405
+ export interface JsConditionalStyle {
406
+ font?: JsFontStyle
407
+ fill?: JsFillStyle
408
+ border?: JsBorderStyle
409
+ customNumFmt?: string
410
+ }
411
+
412
+ export interface JsDataValidationConfig {
413
+ sqref: string
414
+ validationType: string
415
+ operator?: string
416
+ formula1?: string
417
+ formula2?: string
418
+ allowBlank?: boolean
419
+ errorStyle?: string
420
+ errorTitle?: string
421
+ errorMessage?: string
422
+ promptTitle?: string
423
+ promptMessage?: string
424
+ showInputMessage?: boolean
425
+ showErrorMessage?: boolean
426
+ }
427
+
428
+ /** Configuration for setting a defined name. */
429
+ export interface JsDefinedNameConfig {
430
+ /** The name to define (e.g., "SalesData"). */
431
+ name: string
432
+ /** The reference or formula (e.g., "Sheet1!$A$1:$D$10"). */
433
+ value: string
434
+ /** Optional sheet name for sheet-scoped names. Omit for workbook scope. */
435
+ scope?: string
436
+ /** Optional comment for the defined name. */
437
+ comment?: string
438
+ }
439
+
440
+ /** Information about a defined name returned by getDefinedName/getDefinedNames. */
441
+ export interface JsDefinedNameInfo {
442
+ /** The defined name. */
443
+ name: string
444
+ /** The reference or formula. */
445
+ value: string
446
+ /** Sheet name if sheet-scoped, or null if workbook-scoped. */
447
+ scope?: string
448
+ /** Optional comment. */
449
+ comment?: string
450
+ }
451
+
452
+ export interface JsDocProperties {
453
+ title?: string
454
+ subject?: string
455
+ creator?: string
456
+ keywords?: string
457
+ description?: string
458
+ lastModifiedBy?: string
459
+ revision?: string
460
+ created?: string
461
+ modified?: string
462
+ category?: string
463
+ contentStatus?: string
464
+ }
465
+
466
+ export interface JsFillStyle {
467
+ pattern?: string
468
+ fgColor?: string
469
+ bgColor?: string
470
+ }
471
+
472
+ export interface JsFontStyle {
473
+ name?: string
474
+ size?: number
475
+ bold?: boolean
476
+ italic?: boolean
477
+ underline?: boolean
478
+ strikethrough?: boolean
479
+ color?: string
480
+ }
481
+
482
+ /** Header and footer text. */
483
+ export interface JsHeaderFooter {
484
+ /** Header text (may use Excel formatting codes like &L, &C, &R). */
485
+ header?: string
486
+ /** Footer text (may use Excel formatting codes like &L, &C, &R). */
487
+ footer?: string
488
+ }
489
+
490
+ export interface JsHyperlinkInfo {
491
+ /** Type of hyperlink: "external", "internal", or "email". */
492
+ linkType: string
493
+ /** The target URL, sheet reference, or email address. */
494
+ target: string
495
+ /** Optional display text. */
496
+ display?: string
497
+ /** Optional tooltip text. */
498
+ tooltip?: string
499
+ }
500
+
501
+ export interface JsHyperlinkOptions {
502
+ /** Type of hyperlink: "external", "internal", or "email". */
503
+ linkType: string
504
+ /** The target URL, sheet reference, or email address. */
505
+ target: string
506
+ /** Optional display text. */
507
+ display?: string
508
+ /** Optional tooltip text. */
509
+ tooltip?: string
510
+ }
511
+
512
+ export interface JsImageConfig {
513
+ data: Buffer
514
+ format: string
515
+ fromCell: string
516
+ widthPx: number
517
+ heightPx: number
518
+ }
519
+
520
+ /** Page margins configuration in inches. */
521
+ export interface JsPageMargins {
522
+ /** Left margin in inches (default 0.7). */
523
+ left: number
524
+ /** Right margin in inches (default 0.7). */
525
+ right: number
526
+ /** Top margin in inches (default 0.75). */
527
+ top: number
528
+ /** Bottom margin in inches (default 0.75). */
529
+ bottom: number
530
+ /** Header margin in inches (default 0.3). */
531
+ header: number
532
+ /** Footer margin in inches (default 0.3). */
533
+ footer: number
534
+ }
535
+
536
+ /** Page setup configuration. */
537
+ export interface JsPageSetup {
538
+ /** Paper size: "letter", "tabloid", "legal", "a3", "a4", "a5", "b4", "b5". */
539
+ paperSize?: string
540
+ /** Orientation: "portrait" or "landscape". */
541
+ orientation?: string
542
+ /** Print scale percentage (10-400). */
543
+ scale?: number
544
+ /** Fit to this many pages wide. */
545
+ fitToWidth?: number
546
+ /** Fit to this many pages tall. */
547
+ fitToHeight?: number
548
+ }
549
+
550
+ export interface JsPivotDataField {
551
+ name: string
552
+ function: string
553
+ displayName?: string
554
+ }
555
+
556
+ export interface JsPivotField {
557
+ name: string
558
+ }
559
+
560
+ export interface JsPivotTableConfig {
561
+ name: string
562
+ sourceSheet: string
563
+ sourceRange: string
564
+ targetSheet: string
565
+ targetCell: string
566
+ rows: Array<JsPivotField>
567
+ columns: Array<JsPivotField>
568
+ data: Array<JsPivotDataField>
569
+ }
570
+
571
+ export interface JsPivotTableInfo {
572
+ name: string
573
+ sourceSheet: string
574
+ sourceRange: string
575
+ targetSheet: string
576
+ location: string
577
+ }
578
+
579
+ /** Print options configuration. */
580
+ export interface JsPrintOptions {
581
+ /** Print gridlines. */
582
+ gridLines?: boolean
583
+ /** Print row/column headings. */
584
+ headings?: boolean
585
+ /** Center horizontally on page. */
586
+ horizontalCentered?: boolean
587
+ /** Center vertically on page. */
588
+ verticalCentered?: boolean
589
+ }
590
+
591
+ export interface JsProtectionStyle {
592
+ locked?: boolean
593
+ hidden?: boolean
594
+ }
595
+
596
+ /** A single formatted text segment within a rich text cell. */
597
+ export interface JsRichTextRun {
598
+ text: string
599
+ font?: string
600
+ size?: number
601
+ bold?: boolean
602
+ italic?: boolean
603
+ color?: string
604
+ }
605
+
606
+ /** A single cell entry with its column name and value. */
607
+ export interface JsRowCell {
608
+ /** Column name (e.g., "A", "B", "AA"). */
609
+ column: string
610
+ /** Cell value type: "string", "number", "boolean", "date", "empty", "error", "formula". */
611
+ valueType: string
612
+ /** String representation of the cell value. */
613
+ value?: string
614
+ /** Numeric value (only set when value_type is "number"). */
615
+ numberValue?: number
616
+ /** Boolean value (only set when value_type is "boolean"). */
617
+ boolValue?: boolean
618
+ }
619
+
620
+ /** A row with its 1-based row number and cell data. */
621
+ export interface JsRowData {
622
+ /** 1-based row number. */
623
+ row: number
624
+ /** Cells with data in this row. */
625
+ cells: Array<JsRowCell>
626
+ }
627
+
628
+ /** Configuration for sheet protection. */
629
+ export interface JsSheetProtectionConfig {
630
+ /** Optional password (hashed with legacy Excel algorithm). */
631
+ password?: string
632
+ /** Allow selecting locked cells. */
633
+ selectLockedCells?: boolean
634
+ /** Allow selecting unlocked cells. */
635
+ selectUnlockedCells?: boolean
636
+ /** Allow formatting cells. */
637
+ formatCells?: boolean
638
+ /** Allow formatting columns. */
639
+ formatColumns?: boolean
640
+ /** Allow formatting rows. */
641
+ formatRows?: boolean
642
+ /** Allow inserting columns. */
643
+ insertColumns?: boolean
644
+ /** Allow inserting rows. */
645
+ insertRows?: boolean
646
+ /** Allow inserting hyperlinks. */
647
+ insertHyperlinks?: boolean
648
+ /** Allow deleting columns. */
649
+ deleteColumns?: boolean
650
+ /** Allow deleting rows. */
651
+ deleteRows?: boolean
652
+ /** Allow sorting. */
653
+ sort?: boolean
654
+ /** Allow using auto-filter. */
655
+ autoFilter?: boolean
656
+ /** Allow using pivot tables. */
657
+ pivotTables?: boolean
658
+ }
659
+
660
+ export interface JsSparklineConfig {
661
+ dataRange: string
662
+ location: string
663
+ sparklineType?: string
664
+ markers?: boolean
665
+ highPoint?: boolean
666
+ lowPoint?: boolean
667
+ firstPoint?: boolean
668
+ lastPoint?: boolean
669
+ negativePoints?: boolean
670
+ showAxis?: boolean
671
+ lineWeight?: number
672
+ style?: number
673
+ }
674
+
675
+ export interface JsStyle {
676
+ font?: JsFontStyle
677
+ fill?: JsFillStyle
678
+ border?: JsBorderStyle
679
+ alignment?: JsAlignmentStyle
680
+ numFmtId?: number
681
+ customNumFmt?: string
682
+ protection?: JsProtectionStyle
683
+ }
684
+
685
+ export interface JsView3DConfig {
686
+ rotX?: number
687
+ rotY?: number
688
+ depthPercent?: number
689
+ rightAngleAxes?: boolean
690
+ perspective?: number
691
+ }
692
+
693
+ export interface JsWorkbookProtectionConfig {
694
+ password?: string
695
+ lockStructure?: boolean
696
+ lockWindows?: boolean
697
+ lockRevision?: boolean
698
+ }
package/index.js ADDED
@@ -0,0 +1,584 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ import { createRequire } from 'node:module'
7
+ const require = createRequire(import.meta.url)
8
+ const __dirname = new URL('.', import.meta.url).pathname
9
+
10
+ const { readFileSync } = require('node:fs')
11
+ let nativeBinding = null
12
+ const loadErrors = []
13
+
14
+ const isMusl = () => {
15
+ let musl = false
16
+ if (process.platform === 'linux') {
17
+ musl = isMuslFromFilesystem()
18
+ if (musl === null) {
19
+ musl = isMuslFromReport()
20
+ }
21
+ if (musl === null) {
22
+ musl = isMuslFromChildProcess()
23
+ }
24
+ }
25
+ return musl
26
+ }
27
+
28
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
29
+
30
+ const isMuslFromFilesystem = () => {
31
+ try {
32
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
33
+ } catch {
34
+ return null
35
+ }
36
+ }
37
+
38
+ const isMuslFromReport = () => {
39
+ let report = null
40
+ if (typeof process.report?.getReport === 'function') {
41
+ process.report.excludeNetwork = true
42
+ report = process.report.getReport()
43
+ }
44
+ if (!report) {
45
+ return null
46
+ }
47
+ if (report.header && report.header.glibcVersionRuntime) {
48
+ return false
49
+ }
50
+ if (Array.isArray(report.sharedObjects)) {
51
+ if (report.sharedObjects.some(isFileMusl)) {
52
+ return true
53
+ }
54
+ }
55
+ return false
56
+ }
57
+
58
+ const isMuslFromChildProcess = () => {
59
+ try {
60
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
61
+ } catch (e) {
62
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
63
+ return false
64
+ }
65
+ }
66
+
67
+ function requireNative() {
68
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
69
+ try {
70
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
+ } catch (err) {
72
+ loadErrors.push(err)
73
+ }
74
+ } else if (process.platform === 'android') {
75
+ if (process.arch === 'arm64') {
76
+ try {
77
+ return require('./sheetkit.android-arm64.node')
78
+ } catch (e) {
79
+ loadErrors.push(e)
80
+ }
81
+ try {
82
+ const binding = require('@sheetkit/node-android-arm64')
83
+ const bindingPackageVersion = require('@sheetkit/node-android-arm64/package.json').version
84
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
+ }
87
+ return binding
88
+ } catch (e) {
89
+ loadErrors.push(e)
90
+ }
91
+ } else if (process.arch === 'arm') {
92
+ try {
93
+ return require('./sheetkit.android-arm-eabi.node')
94
+ } catch (e) {
95
+ loadErrors.push(e)
96
+ }
97
+ try {
98
+ const binding = require('@sheetkit/node-android-arm-eabi')
99
+ const bindingPackageVersion = require('@sheetkit/node-android-arm-eabi/package.json').version
100
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
+ }
103
+ return binding
104
+ } catch (e) {
105
+ loadErrors.push(e)
106
+ }
107
+ } else {
108
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
109
+ }
110
+ } else if (process.platform === 'win32') {
111
+ if (process.arch === 'x64') {
112
+ if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
113
+ try {
114
+ return require('./sheetkit.win32-x64-gnu.node')
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
118
+ try {
119
+ const binding = require('@sheetkit/node-win32-x64-gnu')
120
+ const bindingPackageVersion = require('@sheetkit/node-win32-x64-gnu/package.json').version
121
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
+ }
124
+ return binding
125
+ } catch (e) {
126
+ loadErrors.push(e)
127
+ }
128
+ } else {
129
+ try {
130
+ return require('./sheetkit.win32-x64-msvc.node')
131
+ } catch (e) {
132
+ loadErrors.push(e)
133
+ }
134
+ try {
135
+ const binding = require('@sheetkit/node-win32-x64-msvc')
136
+ const bindingPackageVersion = require('@sheetkit/node-win32-x64-msvc/package.json').version
137
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
+ }
140
+ return binding
141
+ } catch (e) {
142
+ loadErrors.push(e)
143
+ }
144
+ }
145
+ } else if (process.arch === 'ia32') {
146
+ try {
147
+ return require('./sheetkit.win32-ia32-msvc.node')
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+ try {
152
+ const binding = require('@sheetkit/node-win32-ia32-msvc')
153
+ const bindingPackageVersion = require('@sheetkit/node-win32-ia32-msvc/package.json').version
154
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
156
+ }
157
+ return binding
158
+ } catch (e) {
159
+ loadErrors.push(e)
160
+ }
161
+ } else if (process.arch === 'arm64') {
162
+ try {
163
+ return require('./sheetkit.win32-arm64-msvc.node')
164
+ } catch (e) {
165
+ loadErrors.push(e)
166
+ }
167
+ try {
168
+ const binding = require('@sheetkit/node-win32-arm64-msvc')
169
+ const bindingPackageVersion = require('@sheetkit/node-win32-arm64-msvc/package.json').version
170
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
+ }
173
+ return binding
174
+ } catch (e) {
175
+ loadErrors.push(e)
176
+ }
177
+ } else {
178
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
179
+ }
180
+ } else if (process.platform === 'darwin') {
181
+ try {
182
+ return require('./sheetkit.darwin-universal.node')
183
+ } catch (e) {
184
+ loadErrors.push(e)
185
+ }
186
+ try {
187
+ const binding = require('@sheetkit/node-darwin-universal')
188
+ const bindingPackageVersion = require('@sheetkit/node-darwin-universal/package.json').version
189
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
191
+ }
192
+ return binding
193
+ } catch (e) {
194
+ loadErrors.push(e)
195
+ }
196
+ if (process.arch === 'x64') {
197
+ try {
198
+ return require('./sheetkit.darwin-x64.node')
199
+ } catch (e) {
200
+ loadErrors.push(e)
201
+ }
202
+ try {
203
+ const binding = require('@sheetkit/node-darwin-x64')
204
+ const bindingPackageVersion = require('@sheetkit/node-darwin-x64/package.json').version
205
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
+ }
208
+ return binding
209
+ } catch (e) {
210
+ loadErrors.push(e)
211
+ }
212
+ } else if (process.arch === 'arm64') {
213
+ try {
214
+ return require('./sheetkit.darwin-arm64.node')
215
+ } catch (e) {
216
+ loadErrors.push(e)
217
+ }
218
+ try {
219
+ const binding = require('@sheetkit/node-darwin-arm64')
220
+ const bindingPackageVersion = require('@sheetkit/node-darwin-arm64/package.json').version
221
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
+ }
224
+ return binding
225
+ } catch (e) {
226
+ loadErrors.push(e)
227
+ }
228
+ } else {
229
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
230
+ }
231
+ } else if (process.platform === 'freebsd') {
232
+ if (process.arch === 'x64') {
233
+ try {
234
+ return require('./sheetkit.freebsd-x64.node')
235
+ } catch (e) {
236
+ loadErrors.push(e)
237
+ }
238
+ try {
239
+ const binding = require('@sheetkit/node-freebsd-x64')
240
+ const bindingPackageVersion = require('@sheetkit/node-freebsd-x64/package.json').version
241
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
243
+ }
244
+ return binding
245
+ } catch (e) {
246
+ loadErrors.push(e)
247
+ }
248
+ } else if (process.arch === 'arm64') {
249
+ try {
250
+ return require('./sheetkit.freebsd-arm64.node')
251
+ } catch (e) {
252
+ loadErrors.push(e)
253
+ }
254
+ try {
255
+ const binding = require('@sheetkit/node-freebsd-arm64')
256
+ const bindingPackageVersion = require('@sheetkit/node-freebsd-arm64/package.json').version
257
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
+ }
260
+ return binding
261
+ } catch (e) {
262
+ loadErrors.push(e)
263
+ }
264
+ } else {
265
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
266
+ }
267
+ } else if (process.platform === 'linux') {
268
+ if (process.arch === 'x64') {
269
+ if (isMusl()) {
270
+ try {
271
+ return require('./sheetkit.linux-x64-musl.node')
272
+ } catch (e) {
273
+ loadErrors.push(e)
274
+ }
275
+ try {
276
+ const binding = require('@sheetkit/node-linux-x64-musl')
277
+ const bindingPackageVersion = require('@sheetkit/node-linux-x64-musl/package.json').version
278
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
280
+ }
281
+ return binding
282
+ } catch (e) {
283
+ loadErrors.push(e)
284
+ }
285
+ } else {
286
+ try {
287
+ return require('./sheetkit.linux-x64-gnu.node')
288
+ } catch (e) {
289
+ loadErrors.push(e)
290
+ }
291
+ try {
292
+ const binding = require('@sheetkit/node-linux-x64-gnu')
293
+ const bindingPackageVersion = require('@sheetkit/node-linux-x64-gnu/package.json').version
294
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
+ }
297
+ return binding
298
+ } catch (e) {
299
+ loadErrors.push(e)
300
+ }
301
+ }
302
+ } else if (process.arch === 'arm64') {
303
+ if (isMusl()) {
304
+ try {
305
+ return require('./sheetkit.linux-arm64-musl.node')
306
+ } catch (e) {
307
+ loadErrors.push(e)
308
+ }
309
+ try {
310
+ const binding = require('@sheetkit/node-linux-arm64-musl')
311
+ const bindingPackageVersion = require('@sheetkit/node-linux-arm64-musl/package.json').version
312
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
314
+ }
315
+ return binding
316
+ } catch (e) {
317
+ loadErrors.push(e)
318
+ }
319
+ } else {
320
+ try {
321
+ return require('./sheetkit.linux-arm64-gnu.node')
322
+ } catch (e) {
323
+ loadErrors.push(e)
324
+ }
325
+ try {
326
+ const binding = require('@sheetkit/node-linux-arm64-gnu')
327
+ const bindingPackageVersion = require('@sheetkit/node-linux-arm64-gnu/package.json').version
328
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
+ }
331
+ return binding
332
+ } catch (e) {
333
+ loadErrors.push(e)
334
+ }
335
+ }
336
+ } else if (process.arch === 'arm') {
337
+ if (isMusl()) {
338
+ try {
339
+ return require('./sheetkit.linux-arm-musleabihf.node')
340
+ } catch (e) {
341
+ loadErrors.push(e)
342
+ }
343
+ try {
344
+ const binding = require('@sheetkit/node-linux-arm-musleabihf')
345
+ const bindingPackageVersion = require('@sheetkit/node-linux-arm-musleabihf/package.json').version
346
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
348
+ }
349
+ return binding
350
+ } catch (e) {
351
+ loadErrors.push(e)
352
+ }
353
+ } else {
354
+ try {
355
+ return require('./sheetkit.linux-arm-gnueabihf.node')
356
+ } catch (e) {
357
+ loadErrors.push(e)
358
+ }
359
+ try {
360
+ const binding = require('@sheetkit/node-linux-arm-gnueabihf')
361
+ const bindingPackageVersion = require('@sheetkit/node-linux-arm-gnueabihf/package.json').version
362
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
+ }
365
+ return binding
366
+ } catch (e) {
367
+ loadErrors.push(e)
368
+ }
369
+ }
370
+ } else if (process.arch === 'loong64') {
371
+ if (isMusl()) {
372
+ try {
373
+ return require('./sheetkit.linux-loong64-musl.node')
374
+ } catch (e) {
375
+ loadErrors.push(e)
376
+ }
377
+ try {
378
+ const binding = require('@sheetkit/node-linux-loong64-musl')
379
+ const bindingPackageVersion = require('@sheetkit/node-linux-loong64-musl/package.json').version
380
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
382
+ }
383
+ return binding
384
+ } catch (e) {
385
+ loadErrors.push(e)
386
+ }
387
+ } else {
388
+ try {
389
+ return require('./sheetkit.linux-loong64-gnu.node')
390
+ } catch (e) {
391
+ loadErrors.push(e)
392
+ }
393
+ try {
394
+ const binding = require('@sheetkit/node-linux-loong64-gnu')
395
+ const bindingPackageVersion = require('@sheetkit/node-linux-loong64-gnu/package.json').version
396
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
+ }
399
+ return binding
400
+ } catch (e) {
401
+ loadErrors.push(e)
402
+ }
403
+ }
404
+ } else if (process.arch === 'riscv64') {
405
+ if (isMusl()) {
406
+ try {
407
+ return require('./sheetkit.linux-riscv64-musl.node')
408
+ } catch (e) {
409
+ loadErrors.push(e)
410
+ }
411
+ try {
412
+ const binding = require('@sheetkit/node-linux-riscv64-musl')
413
+ const bindingPackageVersion = require('@sheetkit/node-linux-riscv64-musl/package.json').version
414
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
416
+ }
417
+ return binding
418
+ } catch (e) {
419
+ loadErrors.push(e)
420
+ }
421
+ } else {
422
+ try {
423
+ return require('./sheetkit.linux-riscv64-gnu.node')
424
+ } catch (e) {
425
+ loadErrors.push(e)
426
+ }
427
+ try {
428
+ const binding = require('@sheetkit/node-linux-riscv64-gnu')
429
+ const bindingPackageVersion = require('@sheetkit/node-linux-riscv64-gnu/package.json').version
430
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
+ }
433
+ return binding
434
+ } catch (e) {
435
+ loadErrors.push(e)
436
+ }
437
+ }
438
+ } else if (process.arch === 'ppc64') {
439
+ try {
440
+ return require('./sheetkit.linux-ppc64-gnu.node')
441
+ } catch (e) {
442
+ loadErrors.push(e)
443
+ }
444
+ try {
445
+ const binding = require('@sheetkit/node-linux-ppc64-gnu')
446
+ const bindingPackageVersion = require('@sheetkit/node-linux-ppc64-gnu/package.json').version
447
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
+ }
450
+ return binding
451
+ } catch (e) {
452
+ loadErrors.push(e)
453
+ }
454
+ } else if (process.arch === 's390x') {
455
+ try {
456
+ return require('./sheetkit.linux-s390x-gnu.node')
457
+ } catch (e) {
458
+ loadErrors.push(e)
459
+ }
460
+ try {
461
+ const binding = require('@sheetkit/node-linux-s390x-gnu')
462
+ const bindingPackageVersion = require('@sheetkit/node-linux-s390x-gnu/package.json').version
463
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
+ }
466
+ return binding
467
+ } catch (e) {
468
+ loadErrors.push(e)
469
+ }
470
+ } else {
471
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
472
+ }
473
+ } else if (process.platform === 'openharmony') {
474
+ if (process.arch === 'arm64') {
475
+ try {
476
+ return require('./sheetkit.openharmony-arm64.node')
477
+ } catch (e) {
478
+ loadErrors.push(e)
479
+ }
480
+ try {
481
+ const binding = require('@sheetkit/node-openharmony-arm64')
482
+ const bindingPackageVersion = require('@sheetkit/node-openharmony-arm64/package.json').version
483
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
485
+ }
486
+ return binding
487
+ } catch (e) {
488
+ loadErrors.push(e)
489
+ }
490
+ } else if (process.arch === 'x64') {
491
+ try {
492
+ return require('./sheetkit.openharmony-x64.node')
493
+ } catch (e) {
494
+ loadErrors.push(e)
495
+ }
496
+ try {
497
+ const binding = require('@sheetkit/node-openharmony-x64')
498
+ const bindingPackageVersion = require('@sheetkit/node-openharmony-x64/package.json').version
499
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
501
+ }
502
+ return binding
503
+ } catch (e) {
504
+ loadErrors.push(e)
505
+ }
506
+ } else if (process.arch === 'arm') {
507
+ try {
508
+ return require('./sheetkit.openharmony-arm.node')
509
+ } catch (e) {
510
+ loadErrors.push(e)
511
+ }
512
+ try {
513
+ const binding = require('@sheetkit/node-openharmony-arm')
514
+ const bindingPackageVersion = require('@sheetkit/node-openharmony-arm/package.json').version
515
+ if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
+ }
518
+ return binding
519
+ } catch (e) {
520
+ loadErrors.push(e)
521
+ }
522
+ } else {
523
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
524
+ }
525
+ } else {
526
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
527
+ }
528
+ }
529
+
530
+ nativeBinding = requireNative()
531
+
532
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
533
+ let wasiBinding = null
534
+ let wasiBindingError = null
535
+ try {
536
+ wasiBinding = require('./sheetkit.wasi.cjs')
537
+ nativeBinding = wasiBinding
538
+ } catch (err) {
539
+ if (process.env.NAPI_RS_FORCE_WASI) {
540
+ wasiBindingError = err
541
+ }
542
+ }
543
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
544
+ try {
545
+ wasiBinding = require('@sheetkit/node-wasm32-wasi')
546
+ nativeBinding = wasiBinding
547
+ } catch (err) {
548
+ if (process.env.NAPI_RS_FORCE_WASI) {
549
+ if (!wasiBindingError) {
550
+ wasiBindingError = err
551
+ } else {
552
+ wasiBindingError.cause = err
553
+ }
554
+ loadErrors.push(err)
555
+ }
556
+ }
557
+ }
558
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
559
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
560
+ error.cause = wasiBindingError
561
+ throw error
562
+ }
563
+ }
564
+
565
+ if (!nativeBinding) {
566
+ if (loadErrors.length > 0) {
567
+ throw new Error(
568
+ `Cannot find native binding. ` +
569
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
570
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
571
+ {
572
+ cause: loadErrors.reduce((err, cur) => {
573
+ cur.cause = err
574
+ return cur
575
+ }),
576
+ },
577
+ )
578
+ }
579
+ throw new Error(`Failed to load native binding`)
580
+ }
581
+
582
+ const { JsStreamWriter, Workbook } = nativeBinding
583
+ export { JsStreamWriter }
584
+ export { Workbook }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@sheetkit/node",
3
+ "version": "0.1.0",
4
+ "license": "MIT OR Apache-2.0",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "napi": {
9
+ "binaryName": "sheetkit",
10
+ "targets": [
11
+ "x86_64-apple-darwin",
12
+ "aarch64-apple-darwin",
13
+ "x86_64-pc-windows-msvc",
14
+ "aarch64-pc-windows-msvc",
15
+ "x86_64-unknown-linux-gnu",
16
+ "aarch64-unknown-linux-gnu",
17
+ "x86_64-unknown-linux-musl",
18
+ "aarch64-unknown-linux-musl"
19
+ ]
20
+ },
21
+ "files": [
22
+ "index.js",
23
+ "index.d.ts"
24
+ ],
25
+ "publishConfig": {
26
+ "registry": "https://registry.npmjs.org/",
27
+ "access": "public"
28
+ },
29
+ "devDependencies": {
30
+ "@napi-rs/cli": "^3.5.1"
31
+ },
32
+ "optionalDependencies": {
33
+ "@sheetkit/node-darwin-x64": "0.1.0",
34
+ "@sheetkit/node-darwin-arm64": "0.1.0",
35
+ "@sheetkit/node-win32-x64-msvc": "0.1.0",
36
+ "@sheetkit/node-win32-arm64-msvc": "0.1.0",
37
+ "@sheetkit/node-linux-x64-gnu": "0.1.0",
38
+ "@sheetkit/node-linux-arm64-gnu": "0.1.0",
39
+ "@sheetkit/node-linux-x64-musl": "0.1.0",
40
+ "@sheetkit/node-linux-arm64-musl": "0.1.0"
41
+ },
42
+ "scripts": {
43
+ "artifacts": "napi artifacts",
44
+ "build": "napi build --platform --release --esm",
45
+ "build:debug": "napi build --platform",
46
+ "test": "vitest run",
47
+ "test:watch": "vitest",
48
+ "version": "napi version"
49
+ }
50
+ }