@betteroffice/xlsx 0.5.1 → 0.6.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.
- package/LICENSES/MIT-ruzstd.txt +21 -0
- package/LICENSES/MIT-twox-hash.txt +21 -0
- package/LICENSES/MIT-wuff.txt +20 -0
- package/README.md +45 -10
- package/dist/chunk-3HDY7PGX.js +1 -0
- package/dist/chunk-4YUSZI3G.js +2 -0
- package/dist/chunk-6OSHYRMV.js +1 -0
- package/dist/chunk-AZDGFDN2.js +1 -0
- package/dist/chunk-B5K4E4KI.js +1 -0
- package/dist/chunk-E4HKBJOP.js +7 -0
- package/dist/chunk-FEO7P5TH.js +1 -0
- package/dist/chunk-GHET7GIK.js +1 -0
- package/dist/chunk-JABP2QRG.js +1 -0
- package/dist/chunk-K2GIAESV.js +2 -0
- package/dist/chunk-KNQOCV7P.js +1 -0
- package/dist/chunk-OUNTNO7R.js +1 -0
- package/dist/chunk-QUHWI3QK.js +1 -0
- package/dist/chunk-S6UYP4BX.js +1 -0
- package/dist/chunk-T4GUPT57.js +1 -0
- package/dist/chunk-VJDPZ75R.js +1 -0
- package/dist/chunk-X5HR6GJB.js +4 -0
- package/dist/collaboration.js +1 -1
- package/dist/{editPeer-DiFeIMPk.d.ts → editPeer-CVhOkqsr.d.ts} +426 -61
- package/dist/generated/preflight/xlsx_preflight_bg.wasm +0 -0
- package/dist/generated/xlsx_wasm_bg.wasm +0 -0
- package/dist/generated/xlsx_wasm_lean_bg.wasm +0 -0
- package/dist/headless.d.ts +8 -2
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +27 -5
- package/dist/index.js +1 -4
- package/dist/sessionWorker.missing.d.ts +3 -0
- package/dist/sessionWorker.missing.js +1 -0
- package/dist/sessionWorker.node.d.ts +3 -0
- package/dist/sessionWorker.node.js +1 -0
- package/dist/{types-DdoEoFSX.d.ts → types-BXjmeL2E.d.ts} +71 -3
- package/dist/wasm-preflight.d.ts +26 -0
- package/dist/wasm-preflight.js +1 -0
- package/dist/worker.d.ts +3 -3
- package/dist/worker.js +1 -1
- package/dist/xlsxSessionWorker.mjs +7 -1
- package/dist/xlsxSessionWorker.node.mjs +1 -0
- package/dist/xlsxWorkerStart.d.ts +11 -0
- package/dist/xlsxWorkerStart.js +1 -0
- package/package.json +20 -6
- package/dist/chunk-DIDVDN7H.js +0 -1
- package/dist/chunk-HJJEOLPD.js +0 -1
- package/dist/chunk-JGTBRHCP.js +0 -1
- package/dist/chunk-K7TMSGNA.js +0 -1
- package/dist/chunk-SXM2HKJL.js +0 -4
- /package/dist/{xlsxSessionWorker.d.ts → xlsxSessionWorker.node.d.ts} +0 -0
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as PatternType, D as DisplayList, c as ChartRegion, R as Rect, d as Direction, l as SelectionData } from './types-BXjmeL2E.js';
|
|
2
2
|
import { C as CollaborationReplica, u as CollaborationUpdateOrigin, P as PipeCommandPayload, g as AwarenessCursor, m as AsyncReplicaAdapter } from './asyncReplica-DuZEFXjI.js';
|
|
3
3
|
|
|
4
|
-
/** Format-owned, structured-cloneable methods. */
|
|
5
|
-
type SessionMethods = Record<string, (...args: any[]) => unknown>;
|
|
6
|
-
type Promisified<M extends SessionMethods> = {
|
|
7
|
-
[K in keyof M]: (...args: Parameters<M[K]>) => Promise<Awaited<ReturnType<M[K]>>>;
|
|
8
|
-
};
|
|
9
|
-
interface SessionState {
|
|
10
|
-
format: string;
|
|
11
|
-
stage: 'preview' | 'ready';
|
|
12
|
-
version: number;
|
|
13
|
-
dirty: boolean;
|
|
14
|
-
}
|
|
15
|
-
type SessionFailureCode = 'crash' | 'trap' | 'out-of-memory' | 'message' | 'silence' | 'disposed';
|
|
16
|
-
/** A terminal session failure. */
|
|
17
|
-
declare class SessionFailure extends Error {
|
|
18
|
-
readonly code: SessionFailureCode;
|
|
19
|
-
readonly diagnostics?: string | undefined;
|
|
20
|
-
constructor(code: SessionFailureCode, message: string, diagnostics?: string | undefined);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
4
|
interface ChartSeriesInfo {
|
|
24
5
|
index: number;
|
|
25
6
|
name: string | null;
|
|
@@ -42,6 +23,17 @@ interface ChartInfo {
|
|
|
42
23
|
richTitle: boolean;
|
|
43
24
|
series: ChartSeriesInfo[];
|
|
44
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* How far each edge of a chart frame moves, in content pixels: a positive
|
|
28
|
+
* value moves the left or right edge right and the top or bottom edge down.
|
|
29
|
+
* The engine computes the new anchor and clamps the result to the grid.
|
|
30
|
+
*/
|
|
31
|
+
interface ChartResizeEdges {
|
|
32
|
+
left: number;
|
|
33
|
+
top: number;
|
|
34
|
+
right: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
}
|
|
45
37
|
type ChartSeriesName = {
|
|
46
38
|
text: string;
|
|
47
39
|
} | {
|
|
@@ -90,10 +82,56 @@ interface XlsxDefinedNamesResult {
|
|
|
90
82
|
items: XlsxDefinedName[];
|
|
91
83
|
total: number;
|
|
92
84
|
nextOffset: number | null;
|
|
85
|
+
/**
|
|
86
|
+
* Present while the whole table is over the engine's size limit, which
|
|
87
|
+
* collaborators can reach together. Adding to it is refused, deleting always
|
|
88
|
+
* works, and it still saves, but BetterOffice reopens such a file only once
|
|
89
|
+
* the table is back under the limit.
|
|
90
|
+
*/
|
|
91
|
+
overLimit?: true;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
96
95
|
|
|
96
|
+
type FontDecoder = (bytes: ArrayBuffer | Uint8Array, options: {
|
|
97
|
+
codec: string;
|
|
98
|
+
dict?: ArrayBuffer | Uint8Array;
|
|
99
|
+
maxOutput?: number;
|
|
100
|
+
}) => Promise<{
|
|
101
|
+
font: ArrayBuffer;
|
|
102
|
+
payload?: ArrayBuffer;
|
|
103
|
+
}>;
|
|
104
|
+
type FontDecodeResult = Awaited<ReturnType<FontDecoder>>;
|
|
105
|
+
type FontDecoderMethods = {
|
|
106
|
+
decodeFontFace(bytes: ArrayBuffer, options: Parameters<FontDecoder>[1], wasm?: ArrayBuffer | WebAssembly.Module): FontDecodeResult;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `unwritable-reference`: the document holds a reference with a character XML 1.0 cannot carry, which the
|
|
111
|
+
* part cannot be written with, so the save kept the part as the file wrote it. `unrewritable-formula`: the part
|
|
112
|
+
* holds a formula, kept as the file wrote it, that a sheet rename could not rewrite, so it was kept unrenamed.
|
|
113
|
+
* New codes may be added; handle a code you do not know as a generic warning.
|
|
114
|
+
*/
|
|
115
|
+
type SaveWarningCode = 'unwritable-reference' | 'unrewritable-formula';
|
|
116
|
+
/** A part a save wrote differently from what the document holds, and why. */
|
|
117
|
+
interface SaveWarning {
|
|
118
|
+
/** Stable, to match on. */
|
|
119
|
+
code: SaveWarningCode;
|
|
120
|
+
/** The package part, such as `xl/charts/chart1.xml`. */
|
|
121
|
+
part: string;
|
|
122
|
+
/** What inside the part, such as `chart`. */
|
|
123
|
+
element?: string;
|
|
124
|
+
/** The sheet the part belongs to, in a workbook. */
|
|
125
|
+
sheet?: string;
|
|
126
|
+
/** A sentence for people; not stable, match on `code`. */
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
/** The saved bytes and the warnings the save carries; `warnings` is empty on an ordinary save. */
|
|
130
|
+
interface SaveResult {
|
|
131
|
+
bytes: Uint8Array;
|
|
132
|
+
warnings: SaveWarning[];
|
|
133
|
+
}
|
|
134
|
+
|
|
97
135
|
/**
|
|
98
136
|
* Result envelopes shared by the formats' host edit APIs. Targets, steps, receipts and failure
|
|
99
137
|
* codes stay format-owned; these shapes only fix how every format reports success and refusal.
|
|
@@ -409,7 +447,7 @@ interface XlsxCellPosition {
|
|
|
409
447
|
* An A1 cell or `A1:B2` range (`$` allowed), or zero-based corners. Sheet-qualified, union,
|
|
410
448
|
* whole-row/column and named references are refused.
|
|
411
449
|
*/
|
|
412
|
-
type XlsxRangeAddress = {
|
|
450
|
+
type XlsxRangeAddress$1 = {
|
|
413
451
|
kind: 'a1';
|
|
414
452
|
a1: string;
|
|
415
453
|
} | {
|
|
@@ -419,7 +457,7 @@ type XlsxRangeAddress = {
|
|
|
419
457
|
};
|
|
420
458
|
interface XlsxRangeTarget {
|
|
421
459
|
sheetId: string;
|
|
422
|
-
range: XlsxRangeAddress;
|
|
460
|
+
range: XlsxRangeAddress$1;
|
|
423
461
|
}
|
|
424
462
|
/** One cell in canonical form. */
|
|
425
463
|
interface XlsxCellAddress {
|
|
@@ -477,6 +515,28 @@ type XlsxEditOperation = {
|
|
|
477
515
|
op: 'patchStyle';
|
|
478
516
|
target: XlsxRangeTarget;
|
|
479
517
|
patch: RangeStylePatch;
|
|
518
|
+
} | {
|
|
519
|
+
/**
|
|
520
|
+
* Literal replacement in each cell's entered text inside `target`, case-insensitive
|
|
521
|
+
* unless `matchCase`; the result is entered as if typed, as `setCellInputs` does.
|
|
522
|
+
*
|
|
523
|
+
* `values` reports formula cells as skipped; `formulas` rewrites them too. Dates,
|
|
524
|
+
* booleans, errors, merged-follower, array-filled and locked cells are skipped; a rich
|
|
525
|
+
* text cell or an entry that would not parse is refused alone while the rest applies.
|
|
526
|
+
* Limit exhaustion refuses the whole batch. It takes no `expect` guards.
|
|
527
|
+
*/
|
|
528
|
+
op: 'replaceText';
|
|
529
|
+
target: XlsxRangeTarget;
|
|
530
|
+
query: string;
|
|
531
|
+
replacement: string;
|
|
532
|
+
/** Match only a cell whose whole searched text equals `query`. */
|
|
533
|
+
entireCell?: boolean;
|
|
534
|
+
/** Defaults to `values`. */
|
|
535
|
+
lookIn?: 'values' | 'formulas';
|
|
536
|
+
/** Match letter case exactly. */
|
|
537
|
+
matchCase?: boolean;
|
|
538
|
+
/** Defaults to `sheet`. `workbook` skips a hidden, very hidden or non-worksheet target. */
|
|
539
|
+
within?: 'sheet' | 'workbook';
|
|
480
540
|
};
|
|
481
541
|
type XlsxEditStep = XlsxEditOperation & {
|
|
482
542
|
expect?: {
|
|
@@ -493,6 +553,7 @@ interface XlsxEditRequest {
|
|
|
493
553
|
history?: XlsxEditHistory;
|
|
494
554
|
/** Overrides the handle clock for this request; without either clock, NOW() has no clock. */
|
|
495
555
|
calculation?: {
|
|
556
|
+
/** Current local date and time as a 1900 date-system serial (days since 1899-12-30), also in 1904 workbooks. */
|
|
496
557
|
nowSerial?: number;
|
|
497
558
|
};
|
|
498
559
|
steps: readonly XlsxEditStep[];
|
|
@@ -505,12 +566,35 @@ interface XlsxEditRequest {
|
|
|
505
566
|
type XlsxEditFailureCode = 'stale-version' | 'missing-target' | 'content-mismatch' | 'overlapping-steps' | 'locked-target' | 'read-only' | 'unsupported' | 'invalid-step' | 'limit-exceeded';
|
|
506
567
|
type XlsxEditFailure = OperationFailure<XlsxEditFailureCode, XlsxRangeTarget>;
|
|
507
568
|
type XlsxEditRefusal = OperationRefusal<XlsxEditFailure>;
|
|
569
|
+
/** Counts for one `replaceText` step; omitted for other operations. */
|
|
570
|
+
interface XlsxReplaceStats {
|
|
571
|
+
/** Cells whose searched text matched, including cells that could not be rewritten. */
|
|
572
|
+
matched: number;
|
|
573
|
+
/** Cells whose stored input changed. */
|
|
574
|
+
replaced: number;
|
|
575
|
+
/** Formula results that matched in `values` mode; their formulas are untouched. */
|
|
576
|
+
skippedFormulas: number;
|
|
577
|
+
/** Matches on merged followers, array fills or locked cells of a protected sheet. */
|
|
578
|
+
skippedLocked: number;
|
|
579
|
+
/** Dates, booleans and errors whose displayed or entered text matched; they are untouched. */
|
|
580
|
+
skippedValues?: number;
|
|
581
|
+
/** A1 references of the first skipped values, at most 10,000. */
|
|
582
|
+
skippedCells?: string[];
|
|
583
|
+
/** Matched cells left unchanged because their new entry cannot be stored, at most 10,000. */
|
|
584
|
+
refusedCells?: {
|
|
585
|
+
cell: string;
|
|
586
|
+
reason: string;
|
|
587
|
+
}[];
|
|
588
|
+
/** Every refused cell, including those past the `refusedCells` cap. */
|
|
589
|
+
refused?: number;
|
|
590
|
+
}
|
|
508
591
|
interface XlsxEditReceipt {
|
|
509
592
|
stepIndex: number;
|
|
510
593
|
changed: boolean;
|
|
511
594
|
target: XlsxRangeTarget;
|
|
512
595
|
/** Row-major. */
|
|
513
596
|
changedCells: XlsxCellAddress[];
|
|
597
|
+
replace?: XlsxReplaceStats;
|
|
514
598
|
}
|
|
515
599
|
/** What one step would do; it cannot be committed later. */
|
|
516
600
|
interface XlsxEditPreview {
|
|
@@ -518,6 +602,7 @@ interface XlsxEditPreview {
|
|
|
518
602
|
target: XlsxRangeTarget;
|
|
519
603
|
wouldChange: boolean;
|
|
520
604
|
changedCellCount: number;
|
|
605
|
+
replace?: XlsxReplaceStats;
|
|
521
606
|
}
|
|
522
607
|
interface XlsxEditCalculation {
|
|
523
608
|
/** Dependents whose value moved. */
|
|
@@ -538,8 +623,34 @@ interface XlsxReadRequest {
|
|
|
538
623
|
/** Empty reads only the sheet catalog. */
|
|
539
624
|
ranges: readonly XlsxRangeTarget[];
|
|
540
625
|
}
|
|
626
|
+
/** Stored text with xstring escapes decoded; printable sections use dialog field tokens and normalized line breaks. */
|
|
627
|
+
interface XlsxHeaderFooterText {
|
|
628
|
+
raw: string;
|
|
629
|
+
left: string;
|
|
630
|
+
center: string;
|
|
631
|
+
right: string;
|
|
632
|
+
}
|
|
633
|
+
/** Absent or empty header and footer parts are null. */
|
|
634
|
+
interface XlsxHeaderFooterPair {
|
|
635
|
+
header: XlsxHeaderFooterText | null;
|
|
636
|
+
footer: XlsxHeaderFooterText | null;
|
|
637
|
+
}
|
|
638
|
+
/** Printable variants; even and first are null unless their respective flags are enabled. */
|
|
639
|
+
interface XlsxSheetHeaderFooter {
|
|
640
|
+
differentFirst: boolean;
|
|
641
|
+
differentOddEven: boolean;
|
|
642
|
+
scaleWithDoc: boolean;
|
|
643
|
+
alignWithMargins: boolean;
|
|
644
|
+
odd: XlsxHeaderFooterPair;
|
|
645
|
+
even: XlsxHeaderFooterPair | null;
|
|
646
|
+
first: XlsxHeaderFooterPair | null;
|
|
647
|
+
}
|
|
541
648
|
interface XlsxSheetEntry {
|
|
649
|
+
/** Null means known absent or empty; omitted means source facts are unknown. */
|
|
650
|
+
headerFooter?: XlsxSheetHeaderFooter | null;
|
|
542
651
|
visibility?: XlsxSheetVisibility;
|
|
652
|
+
/** The source part's sheet type; `worksheet` for sheets without a source. */
|
|
653
|
+
kind?: 'worksheet' | 'chartsheet' | 'dialogsheet' | 'macrosheet' | 'other';
|
|
543
654
|
sheetId: string;
|
|
544
655
|
name: string;
|
|
545
656
|
/**
|
|
@@ -559,9 +670,21 @@ interface XlsxRangeRead {
|
|
|
559
670
|
/** Row-major. */
|
|
560
671
|
cells: XlsxCellRead[][];
|
|
561
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* A formula cell the engine could not compute: it keeps Excel's saved value.
|
|
675
|
+
* When the file saved none, an uncomputable function leaves it blank, an
|
|
676
|
+
* unknown function shows what the engine answered (`#NAME?`, or what a handler
|
|
677
|
+
* like `IFERROR` made of it), and an engine gap alone shows its error.
|
|
678
|
+
*/
|
|
679
|
+
interface XlsxUnevaluatedCell extends XlsxCellAddress {
|
|
680
|
+
/** Functions involved, sorted: uncomputable ones (`WEBSERVICE`, `RTD`, an add-in) and names the engine does not know (a VBA function, a typo); empty when only engine gaps were. */
|
|
681
|
+
functions: string[];
|
|
682
|
+
}
|
|
562
683
|
interface XlsxReadCalculation {
|
|
563
684
|
cycleCells: XlsxCellAddress[];
|
|
564
685
|
limitedCells: XlsxCellAddress[];
|
|
686
|
+
/** Formula cells the engine could not compute; omitted by cores built before the list. */
|
|
687
|
+
unevaluatedCells?: XlsxUnevaluatedCell[];
|
|
565
688
|
/** Whether a list stopped at 10,000 cells. */
|
|
566
689
|
truncated: boolean;
|
|
567
690
|
}
|
|
@@ -572,11 +695,22 @@ type XlsxReadResult = {
|
|
|
572
695
|
ranges: XlsxRangeRead[];
|
|
573
696
|
calculation: XlsxReadCalculation;
|
|
574
697
|
} | XlsxEditRefusal;
|
|
575
|
-
/**
|
|
698
|
+
/** A literal substring search over display text, case-insensitive unless `matchCase`. */
|
|
576
699
|
interface XlsxFindRequest {
|
|
577
700
|
text: string;
|
|
578
701
|
/** Defaults to every sheet. */
|
|
579
702
|
sheetIds?: readonly string[];
|
|
703
|
+
/** Restricts the search to one rectangle. Takes precedence over `sheetIds`. */
|
|
704
|
+
range?: XlsxRangeTarget;
|
|
705
|
+
/**
|
|
706
|
+
* Omit or pass `values` to search the display text of every stored cell; `formulas`
|
|
707
|
+
* searches the entered text the formula bar shows, which is what `replaceText` edits.
|
|
708
|
+
*/
|
|
709
|
+
lookIn?: 'values' | 'formulas';
|
|
710
|
+
/** Match only cells whose whole searched text equals `text`. */
|
|
711
|
+
entireCell?: boolean;
|
|
712
|
+
/** Match letter case exactly. */
|
|
713
|
+
matchCase?: boolean;
|
|
580
714
|
/** Defaults to 100; at most 10,000. */
|
|
581
715
|
limit?: number;
|
|
582
716
|
}
|
|
@@ -592,6 +726,8 @@ type XlsxFindResult = {
|
|
|
592
726
|
truncated: boolean;
|
|
593
727
|
} | XlsxEditRefusal;
|
|
594
728
|
|
|
729
|
+
declare const decodeFontFace: FontDecoder;
|
|
730
|
+
|
|
595
731
|
/**
|
|
596
732
|
* A scrolled window into a sheet. `x`/`y` are content-pixel offsets into the
|
|
597
733
|
* non-frozen body. Mirrors the Rust `Viewport`.
|
|
@@ -674,6 +810,20 @@ interface CalculationStatus {
|
|
|
674
810
|
limitedCells: string[];
|
|
675
811
|
/** The last recalculation ran out of its budget; the cells it could not evaluate keep their saved values. */
|
|
676
812
|
budgetExhausted?: boolean;
|
|
813
|
+
/** Formula cells the engine could not compute, at most 10,000; omitted by cores built before the list. */
|
|
814
|
+
unevaluatedCells?: UnevaluatedCellStatus[];
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* A formula cell the engine could not compute: it keeps Excel's saved value.
|
|
818
|
+
* When the file saved none, an uncomputable function leaves it blank, an
|
|
819
|
+
* unknown function shows what the engine answered (`#NAME?`, or what a handler
|
|
820
|
+
* like `IFERROR` made of it), and an engine gap alone shows its error.
|
|
821
|
+
*/
|
|
822
|
+
interface UnevaluatedCellStatus {
|
|
823
|
+
/** The cell, qualified by its sheet when that is not the active one. */
|
|
824
|
+
address: string;
|
|
825
|
+
/** Functions involved, sorted: uncomputable ones (`WEBSERVICE`, `RTD`, an add-in) and names the engine does not know (a VBA function, a typo); empty when only engine gaps were. */
|
|
826
|
+
functions: string[];
|
|
677
827
|
}
|
|
678
828
|
type NumberFormat = 'automatic' | 'plainText' | 'number' | 'percent' | 'scientific' | 'currency' | 'date' | 'time' | 'custom';
|
|
679
829
|
type BorderPreset = 'all' | 'inner' | 'horizontal' | 'vertical' | 'outer' | 'left' | 'top' | 'right' | 'bottom' | 'none';
|
|
@@ -760,6 +910,7 @@ interface CapturedCellFormat {
|
|
|
760
910
|
bold?: boolean;
|
|
761
911
|
italic?: boolean;
|
|
762
912
|
underline?: boolean;
|
|
913
|
+
underline_style?: 'double' | 'singleAccounting' | 'doubleAccounting';
|
|
763
914
|
strike?: boolean;
|
|
764
915
|
color?: CapturedColor | null;
|
|
765
916
|
};
|
|
@@ -850,6 +1001,7 @@ interface WorkbookUpdateInfo {
|
|
|
850
1001
|
}
|
|
851
1002
|
type WorkbookUpdateListener = (update: Uint8Array, origin: WorkbookUpdateOrigin, info: WorkbookUpdateInfo) => void;
|
|
852
1003
|
interface WorkbookCalculationContext {
|
|
1004
|
+
/** Current local date and time as a 1900 date-system serial (days since 1899-12-30), also in 1904 workbooks. */
|
|
853
1005
|
nowSerial: number;
|
|
854
1006
|
randSeed: number;
|
|
855
1007
|
}
|
|
@@ -859,6 +1011,12 @@ interface OpenWorkbookOptions {
|
|
|
859
1011
|
/** Peer-unique positive safe integer. Generated securely when omitted. */
|
|
860
1012
|
clientId?: number;
|
|
861
1013
|
calculation?: WorkbookCalculationContext;
|
|
1014
|
+
/**
|
|
1015
|
+
* `'stale'` shows the results the file cached, recalculating every formula only when one has
|
|
1016
|
+
* no cached result or `calcPr` asks for a full calculation on load. Edits still recalculate
|
|
1017
|
+
* what they reach. Defaults to `'all'`. Unavailable for collaborative workbooks.
|
|
1018
|
+
*/
|
|
1019
|
+
recalculate?: 'all' | 'stale';
|
|
862
1020
|
}
|
|
863
1021
|
/**
|
|
864
1022
|
* The editable view of one cell: A1 address, the exact string the user would
|
|
@@ -871,6 +1029,15 @@ interface CellEdit {
|
|
|
871
1029
|
isFormula: boolean;
|
|
872
1030
|
isArrayFormula?: boolean;
|
|
873
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Options for a direct cell or format write. `protectedSheets: 'allow'` writes locked cells,
|
|
1034
|
+
* formats and chart moves and resizes on protected sheets, as edit batches' opt-in does; the protection
|
|
1035
|
+
* itself is kept. The default `'refuse'` throws like Excel. `'allow'` throws on a collaborative
|
|
1036
|
+
* workbook, and any other value throws as an invalid request.
|
|
1037
|
+
*/
|
|
1038
|
+
interface XlsxWriteOptions {
|
|
1039
|
+
protectedSheets?: 'refuse' | 'allow';
|
|
1040
|
+
}
|
|
874
1041
|
interface XlsxTextSearchOptions {
|
|
875
1042
|
/** Defaults to false. */
|
|
876
1043
|
caseSensitive?: boolean;
|
|
@@ -917,6 +1084,7 @@ interface ProposalCell {
|
|
|
917
1084
|
a1: string;
|
|
918
1085
|
oldText: string;
|
|
919
1086
|
newText: string;
|
|
1087
|
+
stale?: boolean;
|
|
920
1088
|
}
|
|
921
1089
|
/**
|
|
922
1090
|
* A pending, un-applied set of cell changes an agent has staged for human
|
|
@@ -928,6 +1096,12 @@ interface Proposal {
|
|
|
928
1096
|
agentId: string;
|
|
929
1097
|
note: string | null;
|
|
930
1098
|
cells: ProposalCell[];
|
|
1099
|
+
/**
|
|
1100
|
+
* A1 addresses of the cells whose target moved, the same strings as
|
|
1101
|
+
* {@link StaleProposalError.cells}. A changed dependency only shows at accept.
|
|
1102
|
+
*/
|
|
1103
|
+
staleTargets?: string[];
|
|
1104
|
+
forceBlocked?: boolean;
|
|
931
1105
|
}
|
|
932
1106
|
/** A drifted proposal cell: its sheet index and catalog id beside the coordinates. */
|
|
933
1107
|
interface StaleProposalTarget extends XlsxCellAddress {
|
|
@@ -971,6 +1145,12 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
971
1145
|
/** Metadata for `sheet`, with that index in `activeSheet`; leaves the workbook unchanged. */
|
|
972
1146
|
sheetInfoFor(sheet: number): SheetInfo;
|
|
973
1147
|
calculationStatus(): CalculationStatus;
|
|
1148
|
+
/**
|
|
1149
|
+
* Recalculate every formula with the handle's calculation context (or the host clock).
|
|
1150
|
+
* The next `save()` writes the recalculated values; a formula the engine cannot evaluate
|
|
1151
|
+
* keeps the result the file stored.
|
|
1152
|
+
*/
|
|
1153
|
+
recalculate(): CalculationStatus;
|
|
974
1154
|
/** Clamps tracks to the grid and truncates oversized frames at the scroll origin. */
|
|
975
1155
|
displayList(viewport: Viewport): DisplayList;
|
|
976
1156
|
/** `displayList` with build and encode time measured inside the core. */
|
|
@@ -987,24 +1167,45 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
987
1167
|
* mutation the canvas has not drawn yet will move the answer off the pixels.
|
|
988
1168
|
*/
|
|
989
1169
|
chartAtPoint(viewport: Viewport, x: number, y: number): ChartRegion | null;
|
|
1170
|
+
/**
|
|
1171
|
+
* the encoded bytes (PNG, JPEG, GIF, ...) of the image an `image` draw
|
|
1172
|
+
* command names by `assetId`. throws for a part no picture draws.
|
|
1173
|
+
*/
|
|
1174
|
+
mediaBytes(assetId: string): Uint8Array;
|
|
990
1175
|
/**
|
|
991
1176
|
* slide the chart frame `chart` names — a {@link ChartRegion} id — by a
|
|
992
1177
|
* content-pixel delta, clamped to the grid, as one undo step. the new anchor
|
|
993
1178
|
* is written back on save. throws for a chart pinned to the sheet by an
|
|
994
1179
|
* absolute anchor.
|
|
995
1180
|
*/
|
|
996
|
-
moveChart(sheet: number, chart: string, dx: number, dy: number): EditResult;
|
|
1181
|
+
moveChart(sheet: number, chart: string, dx: number, dy: number, options?: XlsxWriteOptions): EditResult;
|
|
1182
|
+
/**
|
|
1183
|
+
* move the edges of the chart frame `chart` names — a {@link ChartRegion} id
|
|
1184
|
+
* — by content-pixel deltas, clamped to the grid and a 1x1px minimum, as one
|
|
1185
|
+
* undo step. the new two-cell anchor is written back on save. throws for a
|
|
1186
|
+
* chart pinned by an absolute anchor or held by a one-cell extent, neither of
|
|
1187
|
+
* which a save can rewrite.
|
|
1188
|
+
*/
|
|
1189
|
+
resizeChart(sheet: number, chart: string, edges: ChartResizeEdges, options?: XlsxWriteOptions): EditResult;
|
|
997
1190
|
setActiveSheet(index: number): void;
|
|
998
1191
|
/**
|
|
999
1192
|
* apply one user input to a cell (parses number/bool/formula/text) and
|
|
1000
1193
|
* recalc its transitive dependents. one undo step; moved dependents come back
|
|
1001
1194
|
* in `EditResult.changed`.
|
|
1002
1195
|
*/
|
|
1003
|
-
editCell(sheet: number, row: number, col: number, input: string): EditResult;
|
|
1196
|
+
editCell(sheet: number, row: number, col: number, input: string, options?: XlsxWriteOptions): EditResult;
|
|
1004
1197
|
/** `editCell` with the facade's stage timings attached. */
|
|
1005
1198
|
editCellProfiled(sheet: number, row: number, col: number, input: string): ProfiledEditResult;
|
|
1006
1199
|
/** apply a batch of inputs (paste path) as one undo step; dependents recalc. */
|
|
1007
|
-
editCells(sheet: number, edits: CellInputEdit[]): EditResult;
|
|
1200
|
+
editCells(sheet: number, edits: CellInputEdit[], options?: XlsxWriteOptions): EditResult;
|
|
1201
|
+
/**
|
|
1202
|
+
* Fill copies `source` over the complete rectangle `destination` as one undo
|
|
1203
|
+
* step. `destination` includes the source and must start at its top-left
|
|
1204
|
+
* corner; values and styles are copied, formulas are translated with `$`
|
|
1205
|
+
* preserved. Array formulas, merged cells, tables, and charts anchored in
|
|
1206
|
+
* either rectangle are refused without changing the workbook.
|
|
1207
|
+
*/
|
|
1208
|
+
fillRange(sheet: number, source: string, destination: string): EditResult;
|
|
1008
1209
|
/** Move a range within one sheet and rewrite references in one native undo step. */
|
|
1009
1210
|
moveRange(sheet: number, source: string, destination: string): EditResult;
|
|
1010
1211
|
setHyperlink(sheet: number, hyperlink: WorkbookHyperlink): EditResult;
|
|
@@ -1028,31 +1229,36 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
1028
1229
|
selectionData(sheet: number, row: number, col: number, direction?: Direction | 'usedRange' | 'rowEnd' | 'merge'): SelectionData;
|
|
1029
1230
|
/** row-major editable views for a range, e.g. "A1:C3" (clipboard copy). */
|
|
1030
1231
|
rangeCells(sheet: number, range: string): CellEdit[][];
|
|
1031
|
-
patchRangeStyle(sheet: number, range: string, patch: RangeStylePatch): EditResult;
|
|
1032
|
-
setNumberFormat(sheet: number, range: string, format: NumberFormatMutation): EditResult;
|
|
1232
|
+
patchRangeStyle(sheet: number, range: string, patch: RangeStylePatch, options?: XlsxWriteOptions): EditResult;
|
|
1233
|
+
setNumberFormat(sheet: number, range: string, format: NumberFormatMutation, options?: XlsxWriteOptions): EditResult;
|
|
1033
1234
|
selectionFormatting(sheet: number, range: string): SelectionFormatting;
|
|
1034
1235
|
captureFormat(sheet: number, range: string): CapturedFormat;
|
|
1035
|
-
applyFormat(sheet: number, range: string, format: CapturedFormat): EditResult;
|
|
1236
|
+
applyFormat(sheet: number, range: string, format: CapturedFormat, options?: XlsxWriteOptions): EditResult;
|
|
1036
1237
|
mergedRanges(sheet: number, range: string): MergedRange[];
|
|
1037
1238
|
visibleMergedRanges(sheet: number, viewport: Viewport): MergedRange[];
|
|
1038
1239
|
historyState(): HistoryState;
|
|
1039
1240
|
/**
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1241
|
+
* Draws a viewport or a cell range of a sheet as PNG bytes, with the
|
|
1242
|
+
* editor's painter on a canvas. Rejects with `PngExportError` rather than
|
|
1243
|
+
* paint a substitute font, and where no canvas exists names
|
|
1244
|
+
* `@betteroffice/xlsx-native`.
|
|
1245
|
+
*/
|
|
1246
|
+
renderPng(target: XlsxPngTarget, options?: XlsxPngOptions): Promise<Uint8Array>;
|
|
1247
|
+
/**
|
|
1248
|
+
* The fonts `renderPng` would paint for the same target. The editors use it to forward the faces they paint with; not public until every format has it.
|
|
1249
|
+
* @internal
|
|
1044
1250
|
*/
|
|
1045
|
-
|
|
1251
|
+
renderPngFonts(target: XlsxPngTarget, options?: XlsxPngOptions): XlsxPngFont[];
|
|
1046
1252
|
/**
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1253
|
+
* serialize the workbook back to .xlsx bytes. each save warning is also emitted as a Node process
|
|
1254
|
+
* warning with code `BETTEROFFICE_SAVE_WARNING`; {@link WorkbookHandle.saveWithWarnings} returns them.
|
|
1049
1255
|
*/
|
|
1050
|
-
renderRangePng(opts?: {
|
|
1051
|
-
range?: string;
|
|
1052
|
-
scale?: number;
|
|
1053
|
-
}): Uint8Array;
|
|
1054
|
-
/** serialize the workbook back to .xlsx bytes. */
|
|
1055
1256
|
save(): Uint8Array;
|
|
1257
|
+
/**
|
|
1258
|
+
* serialize the workbook back to .xlsx bytes, with a warning for every part the save wrote differently
|
|
1259
|
+
* from what the workbook holds; none on an ordinary save.
|
|
1260
|
+
*/
|
|
1261
|
+
saveWithWarnings(): SaveResult;
|
|
1056
1262
|
/**
|
|
1057
1263
|
* stage an agent's proposed edits for human review without applying them.
|
|
1058
1264
|
* returns the {@link Proposal} with per-cell formatted before/after previews.
|
|
@@ -1062,6 +1268,11 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
1062
1268
|
propose(agentId: string, note: string | null, edits: ProposalEdit[]): Proposal;
|
|
1063
1269
|
/** every pending proposal, oldest first. empty when none or unsupported. */
|
|
1064
1270
|
listProposals(): Proposal[];
|
|
1271
|
+
/** The pending state or the last decision made through this handle. */
|
|
1272
|
+
getProposalStatus(id: string): 'pending' | 'accepted' | 'rejected' | undefined;
|
|
1273
|
+
isProposalStale(id: string): boolean;
|
|
1274
|
+
/** Observe proposals created or decided through this handle. */
|
|
1275
|
+
onProposalChange(listener: (proposals: Proposal[]) => void): () => void;
|
|
1065
1276
|
/**
|
|
1066
1277
|
* apply a pending proposal as one undo step and recalc dependents. throws
|
|
1067
1278
|
* {@link StaleProposalError} when the base changed since it was staged and
|
|
@@ -1085,7 +1296,7 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
1085
1296
|
listDefinedNames(request?: XlsxDefinedNamesRequest): XlsxDefinedNamesResult;
|
|
1086
1297
|
/** Cells with the version they were read at; empty `ranges` reads the sheet catalog. */
|
|
1087
1298
|
readCells(request: XlsxReadRequest): XlsxReadResult;
|
|
1088
|
-
/**
|
|
1299
|
+
/** Literal search over display text, one match per cell; ignores case unless `matchCase`. */
|
|
1089
1300
|
findText(request: XlsxFindRequest): XlsxFindResult;
|
|
1090
1301
|
/** Resolves, stages and rehearses a batch like `applyEdits`, changing nothing. */
|
|
1091
1302
|
validateEdits(request: XlsxEditRequest): XlsxValidationResult;
|
|
@@ -1105,8 +1316,15 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
1105
1316
|
dispose(): void;
|
|
1106
1317
|
}
|
|
1107
1318
|
type WasmInitInput = InitInput | Promise<InitInput>;
|
|
1319
|
+
interface WasmInitOptions {
|
|
1320
|
+
/**
|
|
1321
|
+
* `false` loads the smaller core without peer snapshots or standalone
|
|
1322
|
+
* {@link renderXlsxMarkdown}; `exportMarkdown` on a workbook still works.
|
|
1323
|
+
*/
|
|
1324
|
+
png?: boolean;
|
|
1325
|
+
}
|
|
1108
1326
|
/** Initialize the workbook engine. Concurrent calls share the same attempt. */
|
|
1109
|
-
declare function initWasm(input?: WasmInitInput): Promise<void>;
|
|
1327
|
+
declare function initWasm(input?: WasmInitInput, options?: WasmInitOptions): Promise<void>;
|
|
1110
1328
|
/** Maximum counted cells per frame, including boundary and frozen tracks; call after `initWasm`. */
|
|
1111
1329
|
declare function getDisplayListCellLimit(): number;
|
|
1112
1330
|
/**
|
|
@@ -1114,9 +1332,8 @@ declare function getDisplayListCellLimit(): number;
|
|
|
1114
1332
|
*/
|
|
1115
1333
|
declare function isWasmAvailable(): boolean;
|
|
1116
1334
|
/**
|
|
1117
|
-
* Whether
|
|
1118
|
-
*
|
|
1119
|
-
* so chrome can disable an export control instead of calling and catching.
|
|
1335
|
+
* Whether `renderPng` can draw here through a canvas or the native engine.
|
|
1336
|
+
* Callers can disable an export control instead of calling and catching.
|
|
1120
1337
|
*/
|
|
1121
1338
|
declare function isPngExportAvailable(): boolean;
|
|
1122
1339
|
/**
|
|
@@ -1130,6 +1347,21 @@ declare function isProposalsAvailable(): boolean;
|
|
|
1130
1347
|
* Throws an `Error` if the bytes are not a readable workbook.
|
|
1131
1348
|
*/
|
|
1132
1349
|
declare function openWorkbook(bytes: Uint8Array, options?: OpenWorkbookOptions): WorkbookHandle;
|
|
1350
|
+
/**
|
|
1351
|
+
* @internal Formulas, without their `=`, moved from one cell to another as a paste moves them, by
|
|
1352
|
+
* the engine of `handle`; per item the moved formula, or why a paste would refuse it.
|
|
1353
|
+
*/
|
|
1354
|
+
declare function translateFormulasOn(handle: WorkbookHandle, items: readonly {
|
|
1355
|
+
formula: string;
|
|
1356
|
+
from: CellPoint;
|
|
1357
|
+
to: CellPoint;
|
|
1358
|
+
}[]): ({
|
|
1359
|
+
ok: true;
|
|
1360
|
+
formula: string;
|
|
1361
|
+
} | {
|
|
1362
|
+
ok: false;
|
|
1363
|
+
error: string;
|
|
1364
|
+
})[];
|
|
1133
1365
|
/**
|
|
1134
1366
|
* Exports `.xlsx` bytes as read, initializing the core if needed. Formula results are the
|
|
1135
1367
|
* stored ones: nothing is recalculated and no clock is read, so the same bytes and options
|
|
@@ -1145,6 +1377,96 @@ declare function renderXlsxMarkdown(content: XlsxStructuredContent, options?: Xl
|
|
|
1145
1377
|
*/
|
|
1146
1378
|
declare function wasmVersion(): string;
|
|
1147
1379
|
|
|
1380
|
+
/** A sheet by zero-based index or by tab name. */
|
|
1381
|
+
type XlsxSheetRef = number | string;
|
|
1382
|
+
/** A cell range as an A1 string, an A1 object, or zero-based row and column corners. */
|
|
1383
|
+
type XlsxRangeAddress = string | {
|
|
1384
|
+
kind: 'a1';
|
|
1385
|
+
a1: string;
|
|
1386
|
+
} | {
|
|
1387
|
+
kind: 'rowCol';
|
|
1388
|
+
start: {
|
|
1389
|
+
row: number;
|
|
1390
|
+
col: number;
|
|
1391
|
+
};
|
|
1392
|
+
end: {
|
|
1393
|
+
row: number;
|
|
1394
|
+
col: number;
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
/**
|
|
1398
|
+
* What `renderPng` draws: a viewport of a sheet, or a cell range of it.
|
|
1399
|
+
* `range: 'used'` draws the sheet's used range as the engine finds it at call time.
|
|
1400
|
+
*/
|
|
1401
|
+
type XlsxPngTarget = {
|
|
1402
|
+
sheet: number | string;
|
|
1403
|
+
viewport: Viewport;
|
|
1404
|
+
} | {
|
|
1405
|
+
sheet: number | string;
|
|
1406
|
+
range: XlsxRangeAddress | 'used';
|
|
1407
|
+
};
|
|
1408
|
+
/** A font face an export paints with, the same shape as `VsdxFontFace`. */
|
|
1409
|
+
interface XlsxFontFace {
|
|
1410
|
+
family: string;
|
|
1411
|
+
bold?: boolean;
|
|
1412
|
+
italic?: boolean;
|
|
1413
|
+
bytes: Uint8Array;
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* A family and style a PNG export paints, for callers that supply faces.
|
|
1417
|
+
* @internal
|
|
1418
|
+
*/
|
|
1419
|
+
interface XlsxPngFont {
|
|
1420
|
+
family: string;
|
|
1421
|
+
bold: boolean;
|
|
1422
|
+
italic: boolean;
|
|
1423
|
+
}
|
|
1424
|
+
interface XlsxPngOptions {
|
|
1425
|
+
/** Device pixels per sheet pixel. Defaults to 1. */
|
|
1426
|
+
scale?: number;
|
|
1427
|
+
/** Largest PNG width in pixels; a wider target is cut at its right edge. */
|
|
1428
|
+
maxWidth?: number;
|
|
1429
|
+
/** Largest PNG height in pixels; a taller target is cut at its bottom edge. */
|
|
1430
|
+
maxHeight?: number;
|
|
1431
|
+
signal?: AbortSignal;
|
|
1432
|
+
/**
|
|
1433
|
+
* Faces to paint the sheet's fonts with, matched by family and style. Each
|
|
1434
|
+
* export installs them under private names and drops them afterwards; one
|
|
1435
|
+
* that fails to load rejects with `PngExportError` `font-unavailable`. The
|
|
1436
|
+
* editors pass the faces they paint with. Without this option the export
|
|
1437
|
+
* loads the bundled faces `@betteroffice/xlsx-native` draws the sheet's fonts
|
|
1438
|
+
* with, and rejects if one fails to load. A list, even an empty one, replaces
|
|
1439
|
+
* them: a family it does not cover is painted with the engine's built-in
|
|
1440
|
+
* substitute.
|
|
1441
|
+
*/
|
|
1442
|
+
fonts?: ReadonlyArray<XlsxFontFace>;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/** Format-owned, structured-cloneable methods. */
|
|
1446
|
+
type SessionMethods = Record<string, (...args: any[]) => unknown>;
|
|
1447
|
+
type Promisified<M extends SessionMethods> = {
|
|
1448
|
+
[K in keyof M]: (...args: Parameters<M[K]>) => Promise<Awaited<ReturnType<M[K]>>>;
|
|
1449
|
+
};
|
|
1450
|
+
interface SessionState {
|
|
1451
|
+
format: string;
|
|
1452
|
+
stage: 'preview' | 'ready';
|
|
1453
|
+
version: number;
|
|
1454
|
+
dirty: boolean;
|
|
1455
|
+
}
|
|
1456
|
+
type SessionFailureCode = 'crash' | 'trap' | 'out-of-memory' | 'message' | 'silence' | 'disposed';
|
|
1457
|
+
/** A terminal session failure. */
|
|
1458
|
+
declare class SessionFailure extends Error {
|
|
1459
|
+
readonly code: SessionFailureCode;
|
|
1460
|
+
readonly diagnostics?: string | undefined;
|
|
1461
|
+
constructor(code: SessionFailureCode, message: string, diagnostics?: string | undefined);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/** @internal */
|
|
1465
|
+
interface FontCdnConfiguration {
|
|
1466
|
+
baseUrl: string | false;
|
|
1467
|
+
timeoutMs: number;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1148
1470
|
/** @internal */
|
|
1149
1471
|
type BaseRefusal = 'read-only' | 'stale' | 'superseded' | 'not-ready' | 'busy' | 'disposed' | 'invalid-payload' | 'unsupported' | 'dependency-refused' | 'unknown-outcome';
|
|
1150
1472
|
/** @internal */
|
|
@@ -1237,6 +1559,7 @@ type CommandAck$1<S, E, F> = {
|
|
|
1237
1559
|
version: number;
|
|
1238
1560
|
outcomes: CommandOutcome[];
|
|
1239
1561
|
selection?: S;
|
|
1562
|
+
cause?: 'remote';
|
|
1240
1563
|
editState?: E;
|
|
1241
1564
|
frame?: FrameEnvelope<F>;
|
|
1242
1565
|
revisions?: {
|
|
@@ -1270,6 +1593,8 @@ type CommandLane = 'input' | 'collab' | 'background';
|
|
|
1270
1593
|
type SubmitOptions<X> = {
|
|
1271
1594
|
lane?: CommandLane;
|
|
1272
1595
|
after?: CommandTicket;
|
|
1596
|
+
/** Keep this command unsent until its dependency settles. */
|
|
1597
|
+
waitForAfter?: boolean;
|
|
1273
1598
|
expectVersion?: boolean;
|
|
1274
1599
|
inputTime?: number;
|
|
1275
1600
|
lastInputTime?: number;
|
|
@@ -1309,6 +1634,7 @@ type EditSessionState<S, E> = {
|
|
|
1309
1634
|
throughSeq: number;
|
|
1310
1635
|
presentedThroughSeq: number;
|
|
1311
1636
|
selection: S | undefined;
|
|
1637
|
+
selectionCause?: 'remote';
|
|
1312
1638
|
editState: E | undefined;
|
|
1313
1639
|
};
|
|
1314
1640
|
/** @internal Shared asynchronous editor contract for worker and legacy backends. */
|
|
@@ -1403,6 +1729,7 @@ type WorkerEditSessionOptions<O, P, S, E, F, X, Q extends QueryTable = {}> = {
|
|
|
1403
1729
|
declare const WORKBOOK_REPLAY_MUTATORS: {
|
|
1404
1730
|
editCell: true;
|
|
1405
1731
|
editCells: true;
|
|
1732
|
+
fillRange: true;
|
|
1406
1733
|
applyEdits: true;
|
|
1407
1734
|
applyOps: true;
|
|
1408
1735
|
propose: true;
|
|
@@ -1412,16 +1739,21 @@ declare const WORKBOOK_REPLAY_MUTATORS: {
|
|
|
1412
1739
|
setNumberFormat: true;
|
|
1413
1740
|
applyFormat: true;
|
|
1414
1741
|
moveChart: true;
|
|
1742
|
+
resizeChart: true;
|
|
1415
1743
|
moveRange: true;
|
|
1416
1744
|
undo: true;
|
|
1417
1745
|
redo: true;
|
|
1418
1746
|
setActiveSheet: true;
|
|
1419
1747
|
};
|
|
1420
1748
|
type WorkbookReplayMethod = keyof typeof WORKBOOK_REPLAY_MUTATORS;
|
|
1749
|
+
type DirectWriteMethod = 'editCell' | 'editCells' | 'patchRangeStyle' | 'setNumberFormat' | 'applyFormat' | 'moveChart' | 'resizeChart';
|
|
1750
|
+
type WithoutLast<P extends unknown[]> = P extends [...infer Head, unknown] ? Head : P;
|
|
1751
|
+
/** Replayed arguments; a direct write's trailing `XlsxWriteOptions` never replays. */
|
|
1752
|
+
type WorkbookReplayArgs<K extends WorkbookReplayMethod> = K extends DirectWriteMethod ? WithoutLast<Required<Parameters<WorkbookHandle[K]>>> : Parameters<WorkbookHandle[K]>;
|
|
1421
1753
|
type WorkbookReplayOp = {
|
|
1422
1754
|
[K in WorkbookReplayMethod]: {
|
|
1423
1755
|
method: K;
|
|
1424
|
-
args:
|
|
1756
|
+
args: WorkbookReplayArgs<K>;
|
|
1425
1757
|
};
|
|
1426
1758
|
}[WorkbookReplayMethod] & {
|
|
1427
1759
|
calculation?: WorkbookCalculationContext;
|
|
@@ -1533,6 +1865,7 @@ type WorkbookCommandPayload<K extends WorkbookCommandKind> = K extends WorkbookR
|
|
|
1533
1865
|
updates?: Uint8Array[];
|
|
1534
1866
|
} : {
|
|
1535
1867
|
readOnly: boolean;
|
|
1868
|
+
allowHostProposals?: boolean;
|
|
1536
1869
|
};
|
|
1537
1870
|
interface WorkbookCommandFrameRequest {
|
|
1538
1871
|
sheet: number;
|
|
@@ -1607,6 +1940,9 @@ type WorkbookCommandTicket = Omit<CommandTicket, 'ack'> & {
|
|
|
1607
1940
|
type WorkbookSubmitOptions<X = unknown> = SubmitOptions<X>;
|
|
1608
1941
|
type WorkbookEchoHooks<X = unknown> = EchoHooks<X, WorkbookCommandFrame>;
|
|
1609
1942
|
|
|
1943
|
+
/** PNG options a session call carries; an abort signal stays on the caller's side. */
|
|
1944
|
+
type WorkbookPngOptions = Omit<XlsxPngOptions, 'signal'>;
|
|
1945
|
+
|
|
1610
1946
|
/** @experimental */
|
|
1611
1947
|
declare class WorkbookPngUnavailableError extends Error {
|
|
1612
1948
|
readonly code = "png-unavailable";
|
|
@@ -1659,6 +1995,9 @@ type WorkbookWireFrame = Omit<WorkbookFrame, 'displayList'> & {
|
|
|
1659
1995
|
*/
|
|
1660
1996
|
interface WorkbookSessionOpenOptions extends OpenWorkbookOptions {
|
|
1661
1997
|
wasm?: ArrayBuffer | WebAssembly.Module;
|
|
1998
|
+
/** @internal */
|
|
1999
|
+
fontCdn?: FontCdnConfiguration;
|
|
2000
|
+
png?: boolean;
|
|
1662
2001
|
initialViewport?: WorkbookInitialPaintRequest;
|
|
1663
2002
|
includeEditState?: boolean;
|
|
1664
2003
|
initialUpdate?: Uint8Array;
|
|
@@ -1729,9 +2068,10 @@ interface WorkbookSessionEvents {
|
|
|
1729
2068
|
* Workbook RPC methods; engine version tokens remain strings.
|
|
1730
2069
|
* @experimental
|
|
1731
2070
|
*/
|
|
1732
|
-
type WorkbookSessionMethods = {
|
|
2071
|
+
type WorkbookSessionMethods = FontDecoderMethods & {
|
|
1733
2072
|
open(bytes: ArrayBuffer, options?: WorkbookSessionOpenOptions): WorkbookSessionOpenReply;
|
|
1734
|
-
|
|
2073
|
+
/** Checkpoints are only restorable by the same engine version and codec. */
|
|
2074
|
+
openRecovery(checkpoint: Checkpoint, options?: Pick<WorkbookSessionOpenOptions, 'wasm' | 'png' | 'fontCdn'>): WorkbookSessionOpenReply;
|
|
1735
2075
|
version(): string;
|
|
1736
2076
|
collaborationStateVector(): Uint8Array;
|
|
1737
2077
|
collaborationStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
|
|
@@ -1742,25 +2082,43 @@ type WorkbookSessionMethods = {
|
|
|
1742
2082
|
applyEdits(request: XlsxEditRequest): XlsxEditResult;
|
|
1743
2083
|
command(command: WorkbookCommand): WorkbookWireAck;
|
|
1744
2084
|
edit(command: WorkbookSharedCommand): WorkbookSharedWireAck;
|
|
2085
|
+
/** Checkpoints are only restorable by the same engine version and codec. */
|
|
1745
2086
|
checkpoint(preserveHistory?: boolean): WorkbookCheckpoint;
|
|
1746
2087
|
commandFrame(request?: WorkbookCommandFrameRequest): FrameEnvelope<WorkbookCommandWireFrame> | undefined;
|
|
1747
2088
|
frame(viewport: Viewport, options?: WorkbookFrameOptions): WorkbookWireFrame;
|
|
1748
2089
|
sheetView(sheet: number): WorkbookSheetView;
|
|
1749
2090
|
cellGeometry(sheet: number, row: number, col: number): WorkbookCellGeometry;
|
|
1750
2091
|
cellInputs(sheet: number, range: string): WorkbookCellInputs;
|
|
2092
|
+
/** @internal Formulas, without their `=`, moved between cells as a paste moves them. */
|
|
2093
|
+
translateFormulas(items: readonly {
|
|
2094
|
+
formula: string;
|
|
2095
|
+
from: CellPoint;
|
|
2096
|
+
to: CellPoint;
|
|
2097
|
+
}[]): ({
|
|
2098
|
+
ok: true;
|
|
2099
|
+
formula: string;
|
|
2100
|
+
} | {
|
|
2101
|
+
ok: false;
|
|
2102
|
+
error: string;
|
|
2103
|
+
})[];
|
|
1751
2104
|
selectionData(sheet: number, row: number, col: number, direction?: Direction | 'usedRange' | 'rowEnd' | 'merge'): SelectionData;
|
|
1752
2105
|
captureFormat(sheet: number, range: string): CapturedFormat;
|
|
1753
2106
|
sheets(): WorkbookSheetSummary[];
|
|
1754
2107
|
calculationStatus(): CalculationStatus;
|
|
1755
|
-
renderPng(
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
2108
|
+
renderPng(target: XlsxPngTarget, options?: WorkbookPngOptions): ArrayBuffer;
|
|
2109
|
+
/**
|
|
2110
|
+
* The fonts `renderPng` would paint for the same target. The editors use it to forward the faces they paint with; not public until every format has it.
|
|
2111
|
+
* @internal
|
|
2112
|
+
*/
|
|
2113
|
+
renderPngFonts(target: XlsxPngTarget, options?: WorkbookPngOptions): XlsxPngFont[];
|
|
1760
2114
|
exportStructured(options?: XlsxExportOptions): XlsxExportResult<XlsxStructuredContent>;
|
|
1761
2115
|
exportMarkdown(options?: XlsxExportOptions, markdownOptions?: XlsxMarkdownOptions): XlsxExportResult<XlsxMarkdownContent>;
|
|
1762
2116
|
printDisplayList(sheet: number, range: string, metrics: PrintMetrics, gridlines: boolean): ArrayBuffer;
|
|
1763
2117
|
save(): ArrayBuffer;
|
|
2118
|
+
saveWithWarnings(): {
|
|
2119
|
+
bytes: ArrayBuffer;
|
|
2120
|
+
warnings: SaveWarning[];
|
|
2121
|
+
};
|
|
1764
2122
|
dispose(): void;
|
|
1765
2123
|
};
|
|
1766
2124
|
|
|
@@ -1794,6 +2152,7 @@ declare function createWorkbookEditSession<X = unknown>(options: Omit<SessionOpt
|
|
|
1794
2152
|
interface OpenWorkbookSessionOptions extends OpenWorkbookOptions {
|
|
1795
2153
|
worker?: () => Worker;
|
|
1796
2154
|
wasm?: ArrayBuffer | WebAssembly.Module;
|
|
2155
|
+
png?: boolean;
|
|
1797
2156
|
/** Retain source bytes and a compiled module for edit peer hydration. */
|
|
1798
2157
|
retainPeerHydration?: boolean;
|
|
1799
2158
|
/** Aborting closes the session worker while the open is still in flight. */
|
|
@@ -1823,12 +2182,9 @@ interface WorkbookSession {
|
|
|
1823
2182
|
onAck(listener: (ack: WorkbookAck) => void): () => void;
|
|
1824
2183
|
markPresented(frame: WorkbookCommandFrame | Pick<WorkbookCommandFrame, 'session' | 'incarnation' | 'coversThroughSeq'>): boolean;
|
|
1825
2184
|
whenPresented(seq: number): Promise<void>;
|
|
1826
|
-
readonly call: Promisified<Omit<WorkbookSessionMethods, 'open' | 'openRecovery' | 'dispose' | 'frame' | 'command' | 'edit' | 'checkpoint' | 'commandFrame' | '
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
range?: string;
|
|
1830
|
-
scale?: number;
|
|
1831
|
-
}, frameOptions?: WorkbookFrameOptions): Promise<Uint8Array>;
|
|
2185
|
+
readonly call: Promisified<Omit<WorkbookSessionMethods, 'open' | 'openRecovery' | 'dispose' | 'frame' | 'command' | 'edit' | 'checkpoint' | 'commandFrame' | 'decodeFontFace' | 'renderPng' | 'printDisplayList'>> & {
|
|
2186
|
+
decodeFontFace: FontDecoder;
|
|
2187
|
+
renderPng(target: XlsxPngTarget, options?: XlsxPngOptions): Promise<Uint8Array>;
|
|
1832
2188
|
printDisplayList(...args: Parameters<WorkbookHandle['printDisplayList']>): Promise<ReturnType<WorkbookHandle['printDisplayList']>>;
|
|
1833
2189
|
command(command: WorkbookCommand): Promise<WorkbookAck>;
|
|
1834
2190
|
/**
|
|
@@ -1837,7 +2193,10 @@ interface WorkbookSession {
|
|
|
1837
2193
|
*/
|
|
1838
2194
|
frame(viewport: Viewport, options?: WorkbookFrameOptions): Promise<WorkbookFrame>;
|
|
1839
2195
|
};
|
|
2196
|
+
/** saved bytes; each save warning is also emitted as a Node process warning on this thread. */
|
|
1840
2197
|
save(): Promise<Uint8Array>;
|
|
2198
|
+
/** saved bytes with a warning for every part the save wrote differently from what the workbook holds. */
|
|
2199
|
+
saveWithWarnings(): Promise<SaveResult>;
|
|
1841
2200
|
on<K extends keyof WorkbookSessionEvents>(name: K, listener: (payload: WorkbookSessionEvents[K]) => void): () => void;
|
|
1842
2201
|
onFailure(listener: (failure: SessionFailure) => void): () => void;
|
|
1843
2202
|
readonly failure: SessionFailure | undefined;
|
|
@@ -1869,6 +2228,12 @@ interface WorkbookSessionRecovery {
|
|
|
1869
2228
|
/** @experimental */
|
|
1870
2229
|
declare const workbookSessionRecovery: WeakMap<WorkbookSession, WorkbookSessionRecovery>;
|
|
1871
2230
|
|
|
2231
|
+
type PngExportCode = 'canvas-unavailable' | 'canvas-too-large' | 'font-unavailable' | 'picture-unavailable';
|
|
2232
|
+
declare class PngExportError extends Error {
|
|
2233
|
+
readonly code: PngExportCode;
|
|
2234
|
+
constructor(code: PngExportCode, message: string);
|
|
2235
|
+
}
|
|
2236
|
+
|
|
1872
2237
|
type WorkbookPeerHydrationErrorCode = 'mutation-outside-replay' | 'version-mismatch' | 'missing-hydration' | 'missing-module';
|
|
1873
2238
|
declare class WorkbookPeerHydrationError extends Error {
|
|
1874
2239
|
readonly code: WorkbookPeerHydrationErrorCode;
|
|
@@ -1905,4 +2270,4 @@ declare class WorkbookEditPeerFailedError extends Error {
|
|
|
1905
2270
|
/** @internal */
|
|
1906
2271
|
declare function createWorkbookEditPeer(options: WorkbookEditPeerOptions): WorkbookEditPeer;
|
|
1907
2272
|
|
|
1908
|
-
export { type
|
|
2273
|
+
export { type WorkbookSubmitOptions as $, type WorkbookEditState as A, type WorkbookFrame as B, type CommandBasis as C, type WorkbookFrameOptions as D, type WorkbookInitialPaint as E, type WorkbookInitialPaintRequest as F, WorkbookPeerHydrationError as G, type WorkbookPngOptions as H, WorkbookPngUnavailableError as I, WorkbookRecoveryReplayError as J, type WorkbookSession as K, type WorkbookSessionEvents as L, type WorkbookSessionMethods as M, type WorkbookSessionOpenOptions as N, type OpenWorkbookSessionOptions as O, type PngExportCode as P, type WorkbookSessionOpenReply as Q, type WorkbookSessionRecovery as R, type SaveResult as S, type WorkbookSessionState as T, type WorkbookSharedAck as U, type WorkbookSharedCommand as V, type WorkbookReplayReply as W, type WorkbookSharedOutcome as X, type WorkbookSharedWireAck as Y, type WorkbookSheetSummary as Z, type WorkbookSheetView as _, type WorkbookEditPeer as a, StaleProposalError as a$, type WorkbookTicketOutcome as a0, type XlsxFontFace as a1, type XlsxPngFont as a2, type XlsxPngOptions as a3, type XlsxPngTarget as a4, type XlsxRangeAddress as a5, type XlsxSheetRef as a6, createWorkbookEditPeer as a7, createWorkbookEditSession as a8, hydratePeer as a9, type DifferentialFormatInput as aA, type DisplayListProfile as aB, DisplayTooLargeError as aC, type EditProfile as aD, type EditResult as aE, type EditSuccess as aF, type ExportCompletion as aG, type ExportDiagnostic as aH, type ExportSeverity as aI, type HistoryState as aJ, type HorizontalAlignment as aK, type MarkdownAnchor as aL, type MergedRange as aM, type NumberFormat as aN, type NumberFormatMutation as aO, type OpenWorkbookOptions as aP, type OperationFailure as aQ, type OperationRefusal as aR, type PrintMetrics as aS, type ProfiledDisplayList as aT, type ProfiledEditResult as aU, type Proposal as aV, type ProposalCell as aW, type ProposalEdit as aX, type RangeStylePatch as aY, type SelectionFormatting as aZ, type SheetInfo as a_, openWorkbookSession as aa, workbookSessionInternals as ab, workbookSessionRecovery as ac, type BorderPatch as ad, type BorderPreset as ae, type BorderStyle as af, type CalculationStatus as ag, type CapturedBorderEdge as ah, type CapturedBorderStyle as ai, type CapturedCellFormat as aj, type CapturedColor as ak, type CapturedFill as al, type CapturedFormat as am, type CellEdit as an, type CellInputEdit as ao, type CellPoint as ap, type CellPosition as aq, type ChartEdit as ar, type ChartInfo as as, type ChartMutation as at, type ChartResizeEdges as au, type ChartSeriesInfo as av, type ChartSeriesName as aw, type ConditionalFormatInfo as ax, type ConditionalFormatOp as ay, type ConditionalFormatRuleInput as az, type WorkbookReplayMethod as b, type XlsxRangeAddress$1 as b$, type StaleProposalTarget as b0, type StyleProperty as b1, type TextWrapping as b2, type UnevaluatedCellStatus as b3, type ValidationSuccess as b4, type VerticalAlignment as b5, type Viewport as b6, type WasmInitInput as b7, type WasmInitOptions as b8, type WorkbookCalculationContext as b9, type XlsxEditSource as bA, type XlsxEditStep as bB, type XlsxErrorValue as bC, type XlsxExportCell as bD, type XlsxExportDefinedName as bE, type XlsxExportDiagnostic as bF, type XlsxExportDiagnosticCode as bG, type XlsxExportFailure as bH, type XlsxExportFailureCode as bI, type XlsxExportHyperlink as bJ, type XlsxExportMerge as bK, type XlsxExportObject as bL, type XlsxExportOptions as bM, type XlsxExportResult as bN, type XlsxExportScope as bO, type XlsxExportSheet as bP, type XlsxExportTable as bQ, type XlsxExportValue as bR, type XlsxFindMatch as bS, type XlsxFindRequest as bT, type XlsxFindResult as bU, type XlsxFormulaResult as bV, type XlsxHeaderFooterPair as bW, type XlsxHeaderFooterText as bX, type XlsxMarkdownContent as bY, type XlsxMarkdownOptions as bZ, type XlsxObjectKind as b_, type WorkbookHandle as ba, type WorkbookHyperlink as bb, type WorkbookUpdateInfo as bc, type WorkbookUpdateListener as bd, type WorkbookUpdateOrigin as be, type XlsxAnchor as bf, type XlsxAutoFilterOp as bg, type XlsxCellAddress as bh, type XlsxCellGuard as bi, type XlsxCellPosition as bj, type XlsxCellRead as bk, type XlsxCellValue as bl, type XlsxDefinedName as bm, type XlsxDefinedNameOp as bn, type XlsxDefinedNamesRequest as bo, type XlsxDefinedNamesResult as bp, type XlsxEditCalculation as bq, type XlsxEditFailure as br, type XlsxEditFailureCode as bs, type XlsxEditHistory as bt, type XlsxEditOperation as bu, type XlsxEditPreview as bv, type XlsxEditReceipt as bw, type XlsxEditRefusal as bx, type XlsxEditRequest as by, type XlsxEditResult as bz, type WorkbookReplayOp as c, type XlsxRangeRead as c0, type XlsxRangeTarget as c1, type XlsxReadCalculation as c2, type XlsxReadRequest as c3, type XlsxReadResult as c4, type XlsxReplaceStats as c5, type XlsxSheetEntry as c6, type XlsxSheetHeaderFooter as c7, type XlsxSheetIdentity as c8, type XlsxSheetVisibility as c9, type XlsxSourcePart as ca, type XlsxStructuredContent as cb, type XlsxTextMatch as cc, type XlsxTextSearchOptions as cd, type XlsxUnevaluatedCell as ce, type XlsxValidationResult as cf, type XlsxWriteOptions as cg, decodeFontFace as ch, exportXlsxMarkdown as ci, exportXlsxStructured as cj, getDisplayListCellLimit as ck, initWasm as cl, isPngExportAvailable as cm, isProposalsAvailable as cn, isWasmAvailable as co, openWorkbook as cp, renderXlsxMarkdown as cq, translateFormulasOn as cr, wasmVersion as cs, type CommandIdentity as d, type CommandStatus as e, PngExportError as f, type SaveWarning as g, type SaveWarningCode as h, type WorkbookAck as i, type WorkbookCellGeometry as j, type WorkbookCellInputs as k, type WorkbookCommand as l, type WorkbookCommandContext as m, type WorkbookCommandFrame as n, type WorkbookCommandFrameRequest as o, type WorkbookCommandKind as p, type WorkbookCommandPayload as q, type WorkbookCommandSelection as r, type WorkbookCommandTicket as s, type WorkbookEchoHooks as t, type WorkbookEditConnection as u, type WorkbookEditFrame as v, type WorkbookEditPayload as w, WorkbookEditPeerFailedError as x, type WorkbookEditPeerOptions as y, type WorkbookEditSession as z };
|