@betteroffice/xlsx 0.2.1 → 0.3.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.
- package/README.md +118 -12
- package/dist/generated/xlsx_wasm_bg.wasm +0 -0
- package/dist/index.d.ts +574 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,9 +32,8 @@ workbook.editCell(0, 9, 2, "=SUM(C1:C9)"); // recalcs dependents
|
|
|
32
32
|
const bytes = workbook.save();
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`initWasm()` fetches the packaged wasm asset once in browsers
|
|
36
|
-
or a precompiled `WebAssembly.Module
|
|
37
|
-
the asset URL.
|
|
35
|
+
`initWasm()` fetches the packaged wasm asset once in browsers; other runtimes
|
|
36
|
+
pass wasm bytes or a precompiled `WebAssembly.Module`.
|
|
38
37
|
|
|
39
38
|
Around the handle, the package exports the helpers a custom grid needs:
|
|
40
39
|
`cellAtPoint` / `cellRect` / `rangeRect` (hit-testing), the viewport math,
|
|
@@ -78,8 +77,108 @@ if (isProposalsAvailable()) {
|
|
|
78
77
|
```
|
|
79
78
|
|
|
80
79
|
The React editor paints pending proposals as in-cell tracked-change ghosts with
|
|
81
|
-
an accept/reject panel.
|
|
82
|
-
|
|
80
|
+
an accept/reject panel. `isProposalsAvailable()` reports proposal availability.
|
|
81
|
+
`StaleProposalError.targets` names each drifted cell's sheet beside `cells`.
|
|
82
|
+
|
|
83
|
+
## Version-checked edit batches
|
|
84
|
+
|
|
85
|
+
Read cells with the version they were read at, then apply a batch against it.
|
|
86
|
+
Every step commits as one recalculated change and one undo step, or the batch
|
|
87
|
+
returns a typed refusal and nothing changes:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const read = workbook.readCells({
|
|
91
|
+
ranges: [{ sheetId: "sheet:0", range: { kind: "a1", a1: "B3" } }],
|
|
92
|
+
});
|
|
93
|
+
if (!read.ok) throw new Error(read.failure.message);
|
|
94
|
+
|
|
95
|
+
const result = workbook.applyEdits({
|
|
96
|
+
expectVersion: read.version,
|
|
97
|
+
steps: [
|
|
98
|
+
{
|
|
99
|
+
op: "setCellInputs",
|
|
100
|
+
target: { sheetId: "sheet:0", range: { kind: "a1", a1: "B3" } },
|
|
101
|
+
inputs: [["120"]],
|
|
102
|
+
expect: { cells: [[{ value: read.ranges[0].cells[0][0].value }]] },
|
|
103
|
+
},
|
|
104
|
+
{ op: "setNumberFormat", target: { sheetId: "sheet:0", range: { kind: "a1", a1: "B3" } }, format: "currency" },
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
if (!result.ok) console.warn(result.failure.code); // e.g. "stale-version"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Steps: `setCellInputs` (parsed like typing, against each cell's current
|
|
111
|
+
number format), `setFormulas` (source without `=`, stored as formulas whatever
|
|
112
|
+
the format), `setNumberFormat` and `patchStyle`. Content and formatting may
|
|
113
|
+
combine on the same cells; writing one property twice refuses with
|
|
114
|
+
`overlapping-steps`.
|
|
115
|
+
- Targets name a sheet id from the current catalog (`sheet:{index}` standalone,
|
|
116
|
+
the replica's sheet keys in collaboration) and an A1 range or zero-based
|
|
117
|
+
corners. Matrices and guards match the target's shape exactly. Guards compare
|
|
118
|
+
a cell's value, formula (`null` for none) or display text before the batch.
|
|
119
|
+
- `validateEdits` stages a batch without changing anything; `findText` searches
|
|
120
|
+
display text exactly and case-sensitively. Update listeners run once, before
|
|
121
|
+
`applyEdits` returns, and see the recalculated state and its new version.
|
|
122
|
+
`changedSheets` names every sheet the batch or its recalculation changed.
|
|
123
|
+
- Requests over 16 MiB and results over 64 MiB refuse with `limit-exceeded`;
|
|
124
|
+
calculation diagnostics stop at 10,000 cells per list and set `truncated`.
|
|
125
|
+
- `history: "none"` keeps a batch out of undo; standalone undo still replays
|
|
126
|
+
older steps over its cells. `source` records provenance only. Volatile
|
|
127
|
+
functions see only `calculation.nowSerial`.
|
|
128
|
+
- Versions and sheet ids are session-scoped; standalone sheet ids are
|
|
129
|
+
positional, so each is valid only for the version it was read at.
|
|
130
|
+
|
|
131
|
+
## Structured export
|
|
132
|
+
|
|
133
|
+
XLSX exports bounded sparse worksheet content and Markdown with positional
|
|
134
|
+
anchors, formulas, stored values, formatted text, explicit hidden-content
|
|
135
|
+
options, and omission diagnostics. Export reads stored values:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { exportXlsxStructured } from "@betteroffice/xlsx";
|
|
139
|
+
|
|
140
|
+
const read = workbook.exportStructured({ scope: [{ sheet: 0, range: "A1:D20" }] });
|
|
141
|
+
if (read.ok) console.log(read.content.sheets[0].cells);
|
|
142
|
+
|
|
143
|
+
const markdown = workbook.exportMarkdown({}, { maxRows: 100 });
|
|
144
|
+
const fromBytes = await exportXlsxStructured(bytes); // no session, no clock
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- Each sheet lists its stored cells in row-major order (formula cells and
|
|
148
|
+
styled empty cells included, empty positions skipped) with value, formula,
|
|
149
|
+
display text, number format and merge membership, plus merges, tables,
|
|
150
|
+
hyperlinks, hidden row and column spans, and charts, pictures and shapes as
|
|
151
|
+
placeholders with alt text. Defined names are listed read-only.
|
|
152
|
+
- Anchors are `{ sheet: { sheetId, index, name }, a1 }` positions in the
|
|
153
|
+
exported version (`anchorScope: "session"`) or bytes snapshot (`"snapshot"`);
|
|
154
|
+
neither follows later row, column or sheet edits. `sheetId` is the id edit
|
|
155
|
+
batches take in that session (`sheet:{index}` for bytes), so a cell or range
|
|
156
|
+
anchor's `{ sheetId: anchor.sheet.sheetId, range: { kind: "a1", a1: anchor.a1 } }`
|
|
157
|
+
is its batch target at the exported version. Retained drawings carry a `sourcePart`
|
|
158
|
+
provenance with the part's SHA-256.
|
|
159
|
+
- Formula results are the stored values (`calculation.policy: "asStored"`,
|
|
160
|
+
`freshness: "unverified"`); cells mark results the file did not store as
|
|
161
|
+
`missing` (`uncertain` once anything has calculated, or where it cannot be
|
|
162
|
+
traced) and the last calculation's `cycle` and `limited` cells. Live exports
|
|
163
|
+
reflect whatever calculation already ran, and the same version and options
|
|
164
|
+
always export the same content; `exportXlsxStructured` reads bytes without
|
|
165
|
+
recalculating.
|
|
166
|
+
- Hidden sheets, rows, columns and names are excluded unless requested
|
|
167
|
+
(`includeHiddenSheets`, `includeHiddenRows`, `includeHiddenColumns`,
|
|
168
|
+
`includeHiddenNames`), with a `hidden-content-excluded` diagnostic. A sheet
|
|
169
|
+
whose visibility is unknown, such as one from a model handed in without its
|
|
170
|
+
package, counts as hidden.
|
|
171
|
+
- `maxCells` (default 100,000) and `maxBytes` (default 8 MiB) stop at a complete
|
|
172
|
+
record with `truncated: true` and a `truncated` diagnostic; an absent cell is
|
|
173
|
+
empty only before that point. Scope refusals (`invalid-scope`,
|
|
174
|
+
`invalid-options`, `limit-exceeded`) return `{ ok: false, version, failure }`.
|
|
175
|
+
- Markdown renders one grid per sheet labelled with its A1 columns and row
|
|
176
|
+
numbers (200 rows, 50 columns and 10,000 positions by default), using an
|
|
177
|
+
escaped HTML table where merges need spans, and `<!-- xlsx-export:N -->`
|
|
178
|
+
markers whose anchors come back in `anchors`. Document text is escaped and
|
|
179
|
+
kept on one line, and hyperlinks become Markdown links only for `http`,
|
|
180
|
+
`https` and `mailto` destinations. `renderXlsxMarkdown` renders content you
|
|
181
|
+
already hold, refusing content that does not validate.
|
|
83
182
|
|
|
84
183
|
## Collaboration
|
|
85
184
|
|
|
@@ -106,17 +205,15 @@ function dispose() {
|
|
|
106
205
|
}
|
|
107
206
|
```
|
|
108
207
|
|
|
109
|
-
The provider
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
and the Rust/WASM Yrs replica without a second JavaScript `Y.Doc`.
|
|
208
|
+
The provider handles Yjs sync-v1 and awareness. Room routing, authentication,
|
|
209
|
+
WebRTC signaling, and reconnection remain transport concerns; document updates
|
|
210
|
+
flow directly into the Rust/WASM Yrs replica.
|
|
113
211
|
After a close, the transport may reopen itself or the caller may invoke
|
|
114
212
|
`provider.connect()` for another connection attempt.
|
|
115
213
|
Call `provider.destroy()` before discarding its transport or workbook.
|
|
116
214
|
|
|
117
|
-
Collaborative sessions
|
|
118
|
-
|
|
119
|
-
they have stable axis identities and a Yrs-aware undo manager.
|
|
215
|
+
Collaborative sessions synchronize cell content, formulas, styles, column widths,
|
|
216
|
+
and row heights, with Yrs-backed undo and redo. Structural operations throw.
|
|
120
217
|
|
|
121
218
|
## Development
|
|
122
219
|
|
|
@@ -127,3 +224,12 @@ step automatically.
|
|
|
127
224
|
|
|
128
225
|
[JavaScript guide](https://docs.betteroffice.dev/docs/javascript) ·
|
|
129
226
|
[Changelog](https://github.com/openooxml/betteroffice/blob/main/packages/xlsx/CHANGELOG.md) · Apache-2.0.
|
|
227
|
+
|
|
228
|
+
### Operation profiles
|
|
229
|
+
|
|
230
|
+
`editCellProfiled`, `applyOpsProfiled`, and `displayListProfiled` perform the same
|
|
231
|
+
operations as their unprofiled counterparts and return engine stage durations
|
|
232
|
+
in milliseconds. Edit results include `profile` (validate, apply, recalc, result);
|
|
233
|
+
display results contain `{ displayList, profile }` (build, encode). The normal
|
|
234
|
+
entry points do not read profiling clocks. See the
|
|
235
|
+
[corpus and browser tests](../../e2e/README.md) for usage and timing limits.
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,494 @@ declare function paintDisplayList(ctx: CanvasRenderingContext2D, dl: DisplayList
|
|
|
23
23
|
|
|
24
24
|
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Result envelopes shared by the formats' host edit APIs. Targets, steps, receipts and failure
|
|
28
|
+
* codes stay format-owned; these shapes only fix how every format reports success and refusal.
|
|
29
|
+
*/
|
|
30
|
+
/** Why a host operation was refused, as data. The document is unchanged. */
|
|
31
|
+
interface OperationFailure<Code extends string, Target> {
|
|
32
|
+
code: Code;
|
|
33
|
+
/** The request step that failed, when one did. */
|
|
34
|
+
stepIndex?: number;
|
|
35
|
+
/** The earlier step an `overlapping-steps` failure conflicts with. */
|
|
36
|
+
conflictingStepIndex?: number;
|
|
37
|
+
/** The failing step's target as requested or resolved. */
|
|
38
|
+
target?: Target;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
/** A policy refusal carrying the version the document is still at. */
|
|
42
|
+
interface OperationRefusal<Failure> {
|
|
43
|
+
ok: false;
|
|
44
|
+
version: string;
|
|
45
|
+
failure: Failure;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* An accepted edit request. `applied` is false when every step was a no-op; the version then
|
|
49
|
+
* stays `baseVersion` and no history or change notification was produced.
|
|
50
|
+
*/
|
|
51
|
+
interface EditSuccess<Receipt> {
|
|
52
|
+
ok: true;
|
|
53
|
+
baseVersion: string;
|
|
54
|
+
version: string;
|
|
55
|
+
applied: boolean;
|
|
56
|
+
/** One receipt per request step, in request order. */
|
|
57
|
+
receipts: Receipt[];
|
|
58
|
+
}
|
|
59
|
+
/** A validated edit request. Validation reserves nothing and cannot be committed later. */
|
|
60
|
+
interface ValidationSuccess<Preview> {
|
|
61
|
+
ok: true;
|
|
62
|
+
baseVersion: string;
|
|
63
|
+
wouldApply: boolean;
|
|
64
|
+
previews: Preview[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Versioned reads and version-checked edit batches over one workbook. Every shape here is plain
|
|
69
|
+
* JSON; the semantics live in Rust.
|
|
70
|
+
*
|
|
71
|
+
* Rows and columns are zero-based and ranges inclusive. Sheet ids come from the current catalog:
|
|
72
|
+
* `sheet:{index}` standalone, the replica's sheet keys in collaboration. Versions and sheet ids
|
|
73
|
+
* are session-scoped; neither survives save and reopen. Standalone ids are positional, so each is
|
|
74
|
+
* valid only for the version it was read at.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/** Provenance only: it neither grants permission nor selects history. */
|
|
78
|
+
type XlsxEditSource = 'host' | 'agent';
|
|
79
|
+
/**
|
|
80
|
+
* `separate`: exactly one undo step. `none`: no undo step, existing entries kept; standalone
|
|
81
|
+
* undo replays inverse operations, so undoing an older step that wrote the same cell still
|
|
82
|
+
* overwrites it.
|
|
83
|
+
*
|
|
84
|
+
* @experimental `none` only: its interaction with standalone undo may change in a minor release.
|
|
85
|
+
*/
|
|
86
|
+
type XlsxEditHistory = 'separate' | 'none';
|
|
87
|
+
interface XlsxCellPosition {
|
|
88
|
+
row: number;
|
|
89
|
+
col: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* An A1 cell or `A1:B2` range (`$` allowed), or zero-based corners. Sheet-qualified, union,
|
|
93
|
+
* whole-row/column and named references are refused.
|
|
94
|
+
*/
|
|
95
|
+
type XlsxRangeAddress = {
|
|
96
|
+
kind: 'a1';
|
|
97
|
+
a1: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'rowCol';
|
|
100
|
+
start: XlsxCellPosition;
|
|
101
|
+
end: XlsxCellPosition;
|
|
102
|
+
};
|
|
103
|
+
interface XlsxRangeTarget {
|
|
104
|
+
sheetId: string;
|
|
105
|
+
range: XlsxRangeAddress;
|
|
106
|
+
}
|
|
107
|
+
/** One cell in canonical form. */
|
|
108
|
+
interface XlsxCellAddress {
|
|
109
|
+
sheetId: string;
|
|
110
|
+
row: number;
|
|
111
|
+
col: number;
|
|
112
|
+
a1: string;
|
|
113
|
+
}
|
|
114
|
+
type XlsxErrorValue = '#DIV/0!' | '#N/A' | '#NAME?' | '#NULL!' | '#NUM!' | '#REF!' | '#VALUE!' | '#SPILL!' | '#CALC!';
|
|
115
|
+
type XlsxCellValue = {
|
|
116
|
+
kind: 'empty';
|
|
117
|
+
} | {
|
|
118
|
+
kind: 'number';
|
|
119
|
+
value: number;
|
|
120
|
+
} | {
|
|
121
|
+
kind: 'text';
|
|
122
|
+
value: string;
|
|
123
|
+
} | {
|
|
124
|
+
kind: 'bool';
|
|
125
|
+
value: boolean;
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'error';
|
|
128
|
+
value: XlsxErrorValue;
|
|
129
|
+
};
|
|
130
|
+
/** Conditions on a cell's pre-batch state; an absent field imposes none. */
|
|
131
|
+
interface XlsxCellGuard {
|
|
132
|
+
/** The stored value, a formula's current result included. */
|
|
133
|
+
value?: XlsxCellValue;
|
|
134
|
+
/** Formula source without the leading `=`; `null` asserts there is no formula. */
|
|
135
|
+
formula?: string | null;
|
|
136
|
+
/** The exact text the engine formats the cell as. */
|
|
137
|
+
displayText?: string;
|
|
138
|
+
}
|
|
139
|
+
/** Matrices are row-major and exactly the target's shape. */
|
|
140
|
+
type XlsxEditOperation = {
|
|
141
|
+
/** What a user would type, parsed against each cell's current number format. */
|
|
142
|
+
op: 'setCellInputs';
|
|
143
|
+
target: XlsxRangeTarget;
|
|
144
|
+
inputs: string[][];
|
|
145
|
+
} | {
|
|
146
|
+
/** Formula source without the leading `=`, stored as a formula whatever the format. */
|
|
147
|
+
op: 'setFormulas';
|
|
148
|
+
target: XlsxRangeTarget;
|
|
149
|
+
formulas: string[][];
|
|
150
|
+
} | {
|
|
151
|
+
/** Relative mutations resolve against each cell's current format. */
|
|
152
|
+
op: 'setNumberFormat';
|
|
153
|
+
target: XlsxRangeTarget;
|
|
154
|
+
format: NumberFormatMutation;
|
|
155
|
+
} | {
|
|
156
|
+
op: 'patchStyle';
|
|
157
|
+
target: XlsxRangeTarget;
|
|
158
|
+
patch: RangeStylePatch;
|
|
159
|
+
};
|
|
160
|
+
type XlsxEditStep = XlsxEditOperation & {
|
|
161
|
+
expect?: {
|
|
162
|
+
cells: XlsxCellGuard[][];
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/** Requests above 16 MiB and results above 64 MiB are refused with `limit-exceeded`. */
|
|
166
|
+
interface XlsxEditRequest {
|
|
167
|
+
/** The version the targets were read at; a changed workbook refuses with `stale-version`. */
|
|
168
|
+
expectVersion: string;
|
|
169
|
+
/** Defaults to `host`. */
|
|
170
|
+
source?: XlsxEditSource;
|
|
171
|
+
/** Defaults to `separate`. */
|
|
172
|
+
history?: XlsxEditHistory;
|
|
173
|
+
/** Without `nowSerial`, volatile functions such as NOW() have no clock. */
|
|
174
|
+
calculation?: {
|
|
175
|
+
nowSerial?: number;
|
|
176
|
+
};
|
|
177
|
+
steps: readonly XlsxEditStep[];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* `locked-target` covers any write to merged-cell followers, array-formula cells and protected
|
|
181
|
+
* sheets. `read-only` comes only from an editor that does not accept edits.
|
|
182
|
+
*/
|
|
183
|
+
type XlsxEditFailureCode = 'stale-version' | 'missing-target' | 'content-mismatch' | 'overlapping-steps' | 'locked-target' | 'read-only' | 'unsupported' | 'invalid-step' | 'limit-exceeded';
|
|
184
|
+
type XlsxEditFailure = OperationFailure<XlsxEditFailureCode, XlsxRangeTarget>;
|
|
185
|
+
type XlsxEditRefusal = OperationRefusal<XlsxEditFailure>;
|
|
186
|
+
interface XlsxEditReceipt {
|
|
187
|
+
stepIndex: number;
|
|
188
|
+
changed: boolean;
|
|
189
|
+
target: XlsxRangeTarget;
|
|
190
|
+
/** Row-major. */
|
|
191
|
+
changedCells: XlsxCellAddress[];
|
|
192
|
+
}
|
|
193
|
+
/** What one step would do; it cannot be committed later. */
|
|
194
|
+
interface XlsxEditPreview {
|
|
195
|
+
stepIndex: number;
|
|
196
|
+
target: XlsxRangeTarget;
|
|
197
|
+
wouldChange: boolean;
|
|
198
|
+
changedCellCount: number;
|
|
199
|
+
}
|
|
200
|
+
interface XlsxEditCalculation {
|
|
201
|
+
/** Dependents whose value moved. */
|
|
202
|
+
changed: XlsxCellAddress[];
|
|
203
|
+
cycleCells: XlsxCellAddress[];
|
|
204
|
+
limitedCells: XlsxCellAddress[];
|
|
205
|
+
/** Whether a list stopped at 10,000 cells. */
|
|
206
|
+
truncated: boolean;
|
|
207
|
+
}
|
|
208
|
+
type XlsxEditResult = (EditSuccess<XlsxEditReceipt> & {
|
|
209
|
+
source: XlsxEditSource;
|
|
210
|
+
/** Sheets the batch or its recalculation changed, as ids in sheet order. */
|
|
211
|
+
changedSheets: string[];
|
|
212
|
+
calculation: XlsxEditCalculation;
|
|
213
|
+
}) | XlsxEditRefusal;
|
|
214
|
+
type XlsxValidationResult = ValidationSuccess<XlsxEditPreview> | XlsxEditRefusal;
|
|
215
|
+
interface XlsxReadRequest {
|
|
216
|
+
/** Empty reads only the sheet catalog. */
|
|
217
|
+
ranges: readonly XlsxRangeTarget[];
|
|
218
|
+
}
|
|
219
|
+
interface XlsxSheetEntry {
|
|
220
|
+
sheetId: string;
|
|
221
|
+
name: string;
|
|
222
|
+
/** False for sheets batches refuse to write: non-worksheets and protected worksheets. */
|
|
223
|
+
editable: boolean;
|
|
224
|
+
}
|
|
225
|
+
interface XlsxCellRead {
|
|
226
|
+
a1: string;
|
|
227
|
+
value: XlsxCellValue;
|
|
228
|
+
formula: string | null;
|
|
229
|
+
displayText: string;
|
|
230
|
+
}
|
|
231
|
+
interface XlsxRangeRead {
|
|
232
|
+
target: XlsxRangeTarget;
|
|
233
|
+
/** Row-major. */
|
|
234
|
+
cells: XlsxCellRead[][];
|
|
235
|
+
}
|
|
236
|
+
interface XlsxReadCalculation {
|
|
237
|
+
cycleCells: XlsxCellAddress[];
|
|
238
|
+
limitedCells: XlsxCellAddress[];
|
|
239
|
+
/** Whether a list stopped at 10,000 cells. */
|
|
240
|
+
truncated: boolean;
|
|
241
|
+
}
|
|
242
|
+
type XlsxReadResult = {
|
|
243
|
+
ok: true;
|
|
244
|
+
version: string;
|
|
245
|
+
sheets: XlsxSheetEntry[];
|
|
246
|
+
ranges: XlsxRangeRead[];
|
|
247
|
+
calculation: XlsxReadCalculation;
|
|
248
|
+
} | XlsxEditRefusal;
|
|
249
|
+
/** An exact, case-sensitive substring search over display text. */
|
|
250
|
+
interface XlsxFindRequest {
|
|
251
|
+
text: string;
|
|
252
|
+
/** Defaults to every sheet. */
|
|
253
|
+
sheetIds?: readonly string[];
|
|
254
|
+
/** Defaults to 100; at most 10,000. */
|
|
255
|
+
limit?: number;
|
|
256
|
+
}
|
|
257
|
+
interface XlsxFindMatch {
|
|
258
|
+
cell: XlsxCellAddress;
|
|
259
|
+
/** The cell's whole display text. */
|
|
260
|
+
text: string;
|
|
261
|
+
}
|
|
262
|
+
type XlsxFindResult = {
|
|
263
|
+
ok: true;
|
|
264
|
+
version: string;
|
|
265
|
+
matches: XlsxFindMatch[];
|
|
266
|
+
truncated: boolean;
|
|
267
|
+
} | XlsxEditRefusal;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Shapes shared by the formats' read-only structured exports. Content trees, anchors, story or
|
|
271
|
+
* sheet selectors, diagnostic codes and limits stay format-owned; these only fix how every format
|
|
272
|
+
* reports diagnostics, truncation and Markdown markers.
|
|
273
|
+
*/
|
|
274
|
+
type ExportSeverity = 'info' | 'warning' | 'error';
|
|
275
|
+
/** Something an export omitted or could not represent, anchored where it applies. */
|
|
276
|
+
interface ExportDiagnostic<Code extends string, Anchor> {
|
|
277
|
+
code: Code;
|
|
278
|
+
severity: ExportSeverity;
|
|
279
|
+
anchor: Anchor | null;
|
|
280
|
+
message: string;
|
|
281
|
+
}
|
|
282
|
+
/** Whether an export stopped at its limits before the end of the content. */
|
|
283
|
+
interface ExportCompletion {
|
|
284
|
+
truncated: boolean;
|
|
285
|
+
}
|
|
286
|
+
/** A Markdown marker comment and the anchor of the content it precedes. */
|
|
287
|
+
interface MarkdownAnchor<Anchor> {
|
|
288
|
+
marker: string;
|
|
289
|
+
anchor: Anchor;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Read-only structured export of workbook content and its Markdown projection. Every shape
|
|
294
|
+
* here is plain JSON; the walker, limits and Markdown renderer live in Rust.
|
|
295
|
+
*
|
|
296
|
+
* Export never recalculates: formula results are the stored values (`calculation.policy:
|
|
297
|
+
* 'asStored'`, `freshness: 'unverified'`). Anchors name positions by sheet id, index and name
|
|
298
|
+
* and A1 in the exported version or snapshot; none follows later row, column or sheet edits.
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
/** A zero-based sheet index and at most one rectangular A1 range, defaulting to the used range. */
|
|
302
|
+
interface XlsxExportScope {
|
|
303
|
+
sheet: number;
|
|
304
|
+
range?: string;
|
|
305
|
+
}
|
|
306
|
+
/** Hidden sheets, rows, columns and names are excluded unless asked for. */
|
|
307
|
+
interface XlsxExportOptions {
|
|
308
|
+
/** Defaults to every sheet. Unions, whole rows or columns and sheet-qualified ranges refuse. */
|
|
309
|
+
scope?: readonly XlsxExportScope[];
|
|
310
|
+
includeHiddenSheets?: boolean;
|
|
311
|
+
includeHiddenRows?: boolean;
|
|
312
|
+
includeHiddenColumns?: boolean;
|
|
313
|
+
/** Defaults to `true`. */
|
|
314
|
+
includeDefinedNames?: boolean;
|
|
315
|
+
includeHiddenNames?: boolean;
|
|
316
|
+
/** Stored cells, 1 to 1,000,000; defaults to 100,000. */
|
|
317
|
+
maxCells?: number;
|
|
318
|
+
/** Compact UTF-8 JSON bytes of the content, at most 16 MiB; defaults to 8 MiB. */
|
|
319
|
+
maxBytes?: number;
|
|
320
|
+
}
|
|
321
|
+
/** Empty grid positions count toward `maxCells`. */
|
|
322
|
+
interface XlsxMarkdownOptions {
|
|
323
|
+
/** Grid rows per sheet; defaults to 200. */
|
|
324
|
+
maxRows?: number;
|
|
325
|
+
/** Grid columns per sheet; defaults to 50. */
|
|
326
|
+
maxColumns?: number;
|
|
327
|
+
/** Grid positions across all sheets; defaults to 10,000. */
|
|
328
|
+
maxCells?: number;
|
|
329
|
+
/** UTF-8 bytes of Markdown; defaults to 8 MiB. */
|
|
330
|
+
maxBytes?: number;
|
|
331
|
+
}
|
|
332
|
+
/** A sheet by the id edit batches take and, descriptively, its current position and name. */
|
|
333
|
+
interface XlsxSheetIdentity {
|
|
334
|
+
/** The exporting session's catalog id; `sheet:{index}` for bytes. */
|
|
335
|
+
sheetId: string;
|
|
336
|
+
index: number;
|
|
337
|
+
name: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* A `cell` or `range` anchor's `{ sheetId: sheet.sheetId, range: { kind: 'a1', a1 } }` is its
|
|
341
|
+
* `XlsxRangeTarget` at the exported version.
|
|
342
|
+
*/
|
|
343
|
+
type XlsxAnchor = {
|
|
344
|
+
kind: 'sheet';
|
|
345
|
+
sheet: XlsxSheetIdentity;
|
|
346
|
+
} | {
|
|
347
|
+
kind: 'cell';
|
|
348
|
+
sheet: XlsxSheetIdentity;
|
|
349
|
+
a1: string;
|
|
350
|
+
} | {
|
|
351
|
+
kind: 'range';
|
|
352
|
+
sheet: XlsxSheetIdentity;
|
|
353
|
+
a1: string;
|
|
354
|
+
} | {
|
|
355
|
+
kind: 'definedName';
|
|
356
|
+
name: string;
|
|
357
|
+
localSheet: XlsxSheetIdentity | null;
|
|
358
|
+
/** Position in the workbook's defined-name list. */
|
|
359
|
+
ordinal: number;
|
|
360
|
+
} | {
|
|
361
|
+
kind: 'sourcePart';
|
|
362
|
+
part: string;
|
|
363
|
+
partSha256: string;
|
|
364
|
+
path: number[];
|
|
365
|
+
};
|
|
366
|
+
/** Retained source XML: part, SHA-256 of its bytes, element-child ordinals from its root. */
|
|
367
|
+
interface XlsxSourcePart {
|
|
368
|
+
part: string;
|
|
369
|
+
partSha256: string;
|
|
370
|
+
path: number[];
|
|
371
|
+
}
|
|
372
|
+
type XlsxExportDiagnosticCode = 'hidden-content-excluded' | 'visibility-unknown' | 'unsupported-sheet' | 'unsupported-content' | 'object-placeholder' | 'unreadable-object' | 'provenance-unavailable' | 'comments-omitted' | 'rich-text-omitted' | 'formatting-approximate' | 'formula-cache-unverified' | 'formula-result-missing' | 'calculation-failure' | 'value-unavailable' | 'truncated' | 'markdown-lossy';
|
|
373
|
+
type XlsxExportDiagnostic = ExportDiagnostic<XlsxExportDiagnosticCode, XlsxAnchor>;
|
|
374
|
+
/** A cell value; `unavailable` stands for one JSON cannot carry, such as a non-finite number. */
|
|
375
|
+
type XlsxExportValue = XlsxCellValue | {
|
|
376
|
+
kind: 'unavailable';
|
|
377
|
+
reason: string;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* `unverified`: a result is stored, not checked. `missing`: none is stored, and the value is the
|
|
381
|
+
* engine's placeholder. `uncertain`: presence cannot be established, as once anything has
|
|
382
|
+
* calculated since a file that stored none was read. `cycle` and `limited`: what the last
|
|
383
|
+
* calculation reported.
|
|
384
|
+
*/
|
|
385
|
+
type XlsxFormulaResult = 'unverified' | 'missing' | 'uncertain' | 'cycle' | 'limited';
|
|
386
|
+
interface XlsxExportCell {
|
|
387
|
+
id: string;
|
|
388
|
+
anchor: XlsxAnchor;
|
|
389
|
+
value: XlsxExportValue;
|
|
390
|
+
/** Without the leading `=`. */
|
|
391
|
+
formula: string | null;
|
|
392
|
+
/** The engine's formatting of the value, without column-width clipping or overflow. */
|
|
393
|
+
displayText: string;
|
|
394
|
+
numberFormat: string;
|
|
395
|
+
/** `null` for cells without a formula. */
|
|
396
|
+
formulaResult: XlsxFormulaResult | null;
|
|
397
|
+
merge: {
|
|
398
|
+
range: string;
|
|
399
|
+
origin: boolean;
|
|
400
|
+
} | null;
|
|
401
|
+
}
|
|
402
|
+
interface XlsxExportMerge {
|
|
403
|
+
id: string;
|
|
404
|
+
anchor: XlsxAnchor;
|
|
405
|
+
/** Whether the merge extends past the selected range. */
|
|
406
|
+
clipped: boolean;
|
|
407
|
+
}
|
|
408
|
+
/** A ListObject. */
|
|
409
|
+
interface XlsxExportTable {
|
|
410
|
+
id: string;
|
|
411
|
+
anchor: XlsxAnchor;
|
|
412
|
+
name: string;
|
|
413
|
+
headerRows: number;
|
|
414
|
+
totalsRows: number;
|
|
415
|
+
columns: string[];
|
|
416
|
+
clipped: boolean;
|
|
417
|
+
}
|
|
418
|
+
interface XlsxExportHyperlink {
|
|
419
|
+
id: string;
|
|
420
|
+
anchor: XlsxAnchor;
|
|
421
|
+
externalTarget: string | null;
|
|
422
|
+
location: string | null;
|
|
423
|
+
tooltip: string | null;
|
|
424
|
+
display: string | null;
|
|
425
|
+
clipped: boolean;
|
|
426
|
+
}
|
|
427
|
+
type XlsxObjectKind = 'chart' | 'picture' | 'shape' | 'group' | 'connector' | 'diagram' | 'graphicFrame' | 'contentPart' | 'unknown';
|
|
428
|
+
/** A drawing object as a placeholder: no chart data, image bytes or shape text. */
|
|
429
|
+
interface XlsxExportObject {
|
|
430
|
+
id: string;
|
|
431
|
+
kind: XlsxObjectKind;
|
|
432
|
+
/** The cells holding its corners; `null` when its grid position is unknown. */
|
|
433
|
+
anchor: XlsxAnchor | null;
|
|
434
|
+
name: string | null;
|
|
435
|
+
altText: string | null;
|
|
436
|
+
title: string | null;
|
|
437
|
+
hidden: boolean;
|
|
438
|
+
/** The chart or image part. */
|
|
439
|
+
part: string | null;
|
|
440
|
+
source: XlsxSourcePart | null;
|
|
441
|
+
}
|
|
442
|
+
interface XlsxExportDefinedName {
|
|
443
|
+
id: string;
|
|
444
|
+
anchor: XlsxAnchor;
|
|
445
|
+
name: string;
|
|
446
|
+
formula: string;
|
|
447
|
+
hidden: boolean;
|
|
448
|
+
localSheet: XlsxSheetIdentity | null;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* One sheet. `truncated` means export stopped inside it: its lists are complete in the order
|
|
452
|
+
* hidden spans, merges, tables, hyperlinks, objects, cells, up to where it stopped.
|
|
453
|
+
*/
|
|
454
|
+
interface XlsxExportSheet extends ExportCompletion {
|
|
455
|
+
id: string;
|
|
456
|
+
anchor: XlsxAnchor;
|
|
457
|
+
kind: 'worksheet' | 'chartsheet' | 'dialogsheet' | 'macrosheet' | 'other';
|
|
458
|
+
visibility: 'visible' | 'hidden' | 'veryHidden' | 'unknown';
|
|
459
|
+
/** Stored cells and hyperlinks; drawings, merges and tables do not extend it. */
|
|
460
|
+
usedRange: string | null;
|
|
461
|
+
selectedRange: string | null;
|
|
462
|
+
/** Hidden row spans such as `"5:7"` inside the selected range, exported or not. */
|
|
463
|
+
hiddenRows: string[];
|
|
464
|
+
/** Hidden column spans such as `"C:D"` inside the selected range, exported or not. */
|
|
465
|
+
hiddenColumns: string[];
|
|
466
|
+
merges: XlsxExportMerge[];
|
|
467
|
+
tables: XlsxExportTable[];
|
|
468
|
+
hyperlinks: XlsxExportHyperlink[];
|
|
469
|
+
objects: XlsxExportObject[];
|
|
470
|
+
/** Stored cells in row-major order, styled empty cells included. */
|
|
471
|
+
cells: XlsxExportCell[];
|
|
472
|
+
source: XlsxSourcePart | null;
|
|
473
|
+
}
|
|
474
|
+
interface XlsxStructuredContent extends ExportCompletion {
|
|
475
|
+
schemaVersion: 1;
|
|
476
|
+
/** `session` for a live export, `snapshot` for bytes. */
|
|
477
|
+
anchorScope: 'session' | 'snapshot';
|
|
478
|
+
dateSystem: '1900' | '1904';
|
|
479
|
+
calculation: {
|
|
480
|
+
policy: 'asStored';
|
|
481
|
+
freshness: 'unverified';
|
|
482
|
+
};
|
|
483
|
+
included: {
|
|
484
|
+
hiddenSheets: boolean;
|
|
485
|
+
hiddenRows: boolean;
|
|
486
|
+
hiddenColumns: boolean;
|
|
487
|
+
definedNames: boolean;
|
|
488
|
+
hiddenNames: boolean;
|
|
489
|
+
};
|
|
490
|
+
sheets: XlsxExportSheet[];
|
|
491
|
+
definedNames: XlsxExportDefinedName[];
|
|
492
|
+
diagnostics: XlsxExportDiagnostic[];
|
|
493
|
+
}
|
|
494
|
+
interface XlsxMarkdownContent extends ExportCompletion {
|
|
495
|
+
markdown: string;
|
|
496
|
+
/** One per `<!-- xlsx-export:N -->` marker, in order. */
|
|
497
|
+
anchors: MarkdownAnchor<XlsxAnchor>[];
|
|
498
|
+
/** The structured export's diagnostics, then what Markdown lost. */
|
|
499
|
+
diagnostics: XlsxExportDiagnostic[];
|
|
500
|
+
}
|
|
501
|
+
type XlsxExportFailureCode = 'invalid-options' | 'invalid-scope' | 'limit-exceeded';
|
|
502
|
+
interface XlsxExportFailure {
|
|
503
|
+
code: XlsxExportFailureCode;
|
|
504
|
+
/** The sheet a scope failure names, else `null`. */
|
|
505
|
+
target: XlsxAnchor | null;
|
|
506
|
+
message: string;
|
|
507
|
+
}
|
|
508
|
+
type XlsxExportResult<T> = {
|
|
509
|
+
ok: true;
|
|
510
|
+
version: string;
|
|
511
|
+
content: T;
|
|
512
|
+
} | OperationRefusal<XlsxExportFailure>;
|
|
513
|
+
|
|
26
514
|
/**
|
|
27
515
|
* Wasm loader for the xlsx-wasm core.
|
|
28
516
|
*
|
|
@@ -85,6 +573,24 @@ interface EditResult {
|
|
|
85
573
|
changed?: string[];
|
|
86
574
|
limitedCells?: string[];
|
|
87
575
|
}
|
|
576
|
+
/** Facade stage latencies of one profiled mutation, in ms. */
|
|
577
|
+
interface EditProfile {
|
|
578
|
+
validateMs: number;
|
|
579
|
+
applyMs: number;
|
|
580
|
+
recalcMs: number;
|
|
581
|
+
resultMs: number;
|
|
582
|
+
}
|
|
583
|
+
interface ProfiledEditResult extends EditResult {
|
|
584
|
+
profile: EditProfile;
|
|
585
|
+
}
|
|
586
|
+
interface DisplayListProfile {
|
|
587
|
+
buildMs: number;
|
|
588
|
+
encodeMs: number;
|
|
589
|
+
}
|
|
590
|
+
interface ProfiledDisplayList {
|
|
591
|
+
displayList: DisplayList;
|
|
592
|
+
profile: DisplayListProfile;
|
|
593
|
+
}
|
|
88
594
|
interface CalculationStatus {
|
|
89
595
|
limitedCells: string[];
|
|
90
596
|
}
|
|
@@ -172,6 +678,23 @@ interface CellEdit {
|
|
|
172
678
|
input: string;
|
|
173
679
|
isFormula: boolean;
|
|
174
680
|
}
|
|
681
|
+
interface XlsxTextSearchOptions {
|
|
682
|
+
/** Defaults to false. */
|
|
683
|
+
caseSensitive?: boolean;
|
|
684
|
+
/** Maximum matches; defaults to 1000. */
|
|
685
|
+
limit?: number;
|
|
686
|
+
}
|
|
687
|
+
/** Zero-based sheet, row, and column. */
|
|
688
|
+
interface XlsxTextMatch {
|
|
689
|
+
sheet: number;
|
|
690
|
+
sheetId: string;
|
|
691
|
+
sheetName: string;
|
|
692
|
+
row: number;
|
|
693
|
+
col: number;
|
|
694
|
+
a1: string;
|
|
695
|
+
/** Formatted display text. */
|
|
696
|
+
text: string;
|
|
697
|
+
}
|
|
175
698
|
/** One cell of a batch edit: target coordinates plus the raw user input. */
|
|
176
699
|
interface CellInputEdit {
|
|
177
700
|
row: number;
|
|
@@ -212,15 +735,20 @@ interface Proposal {
|
|
|
212
735
|
note: string | null;
|
|
213
736
|
cells: ProposalCell[];
|
|
214
737
|
}
|
|
738
|
+
/** A drifted proposal cell: its sheet index and catalog id beside the coordinates. */
|
|
739
|
+
interface StaleProposalTarget extends XlsxCellAddress {
|
|
740
|
+
sheet: number;
|
|
741
|
+
}
|
|
215
742
|
/**
|
|
216
743
|
* Thrown by {@link WorkbookHandle.acceptProposal} when the workbook changed
|
|
217
744
|
* under a proposal since it was staged (an edit touched one of its base cells)
|
|
218
745
|
* and `force` was not set. `cells` are the a1 addresses that moved, so the UI
|
|
219
|
-
* can name them and offer a force-apply.
|
|
746
|
+
* can name them and offer a force-apply; `targets` also carry each one's sheet.
|
|
220
747
|
*/
|
|
221
748
|
declare class StaleProposalError extends Error {
|
|
222
749
|
readonly cells: string[];
|
|
223
|
-
|
|
750
|
+
readonly targets: StaleProposalTarget[];
|
|
751
|
+
constructor(cells: string[], targets?: StaleProposalTarget[]);
|
|
224
752
|
}
|
|
225
753
|
/**
|
|
226
754
|
* A typed handle over an open workbook, hiding the wasm object and its JSON
|
|
@@ -239,6 +767,8 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
239
767
|
sheetInfo(): SheetInfo;
|
|
240
768
|
calculationStatus(): CalculationStatus;
|
|
241
769
|
displayList(viewport: Viewport): DisplayList;
|
|
770
|
+
/** `displayList` with build and encode time measured inside the core. */
|
|
771
|
+
displayListProfiled(viewport: Viewport): ProfiledDisplayList;
|
|
242
772
|
printDisplayList(sheet: number, range: string, metrics: PrintMetrics, gridlines: boolean): DisplayList;
|
|
243
773
|
/**
|
|
244
774
|
* the chart under a viewport-local point on the active sheet, or `null`,
|
|
@@ -265,14 +795,20 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
265
795
|
* in `EditResult.changed`.
|
|
266
796
|
*/
|
|
267
797
|
editCell(sheet: number, row: number, col: number, input: string): EditResult;
|
|
798
|
+
/** `editCell` with the facade's stage timings attached. */
|
|
799
|
+
editCellProfiled(sheet: number, row: number, col: number, input: string): ProfiledEditResult;
|
|
268
800
|
/** apply a batch of inputs (paste path) as one undo step; dependents recalc. */
|
|
269
801
|
editCells(sheet: number, edits: CellInputEdit[]): EditResult;
|
|
270
802
|
/** raw op-list escape hatch for structural ops (insert/delete rows, merges…). */
|
|
271
803
|
applyOps(ops: unknown[]): EditResult;
|
|
804
|
+
/** `applyOps` with the facade's stage timings attached. */
|
|
805
|
+
applyOpsProfiled(ops: unknown[]): ProfiledEditResult;
|
|
272
806
|
undo(): EditResult;
|
|
273
807
|
redo(): EditResult;
|
|
274
808
|
/** the editable view of one cell (formula bar / in-cell editor prefill). */
|
|
275
809
|
cell(sheet: number, row: number, col: number): CellEdit;
|
|
810
|
+
/** Searches formatted text in sheet and row order. */
|
|
811
|
+
searchText(query: string, options?: XlsxTextSearchOptions): XlsxTextMatch[];
|
|
276
812
|
cellPosition(sheet: number, row: number, col: number): CellPosition;
|
|
277
813
|
/** row-major editable views for a range, e.g. "A1:C3" (clipboard copy). */
|
|
278
814
|
rangeCells(sheet: number, range: string): CellEdit[][];
|
|
@@ -323,6 +859,31 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
323
859
|
rejectProposal(id: string): boolean;
|
|
324
860
|
/** whether the embedded wasm core was built with the proposals api. */
|
|
325
861
|
isProposalsAvailable(): boolean;
|
|
862
|
+
/**
|
|
863
|
+
* The session-scoped version of the committed workbook. Committed edits, peer updates, undo,
|
|
864
|
+
* redo and a recalculation that changes values or what an export reports about results move
|
|
865
|
+
* it; selection, the active sheet and proposals do not.
|
|
866
|
+
*/
|
|
867
|
+
version(): string;
|
|
868
|
+
/** Cells with the version they were read at; empty `ranges` reads the sheet catalog. */
|
|
869
|
+
readCells(request: XlsxReadRequest): XlsxReadResult;
|
|
870
|
+
/** Exact, case-sensitive search over display text, one match per cell. */
|
|
871
|
+
findText(request: XlsxFindRequest): XlsxFindResult;
|
|
872
|
+
/** Resolves, stages and rehearses a batch like `applyEdits`, changing nothing. */
|
|
873
|
+
validateEdits(request: XlsxEditRequest): XlsxValidationResult;
|
|
874
|
+
/**
|
|
875
|
+
* Applies every step as one committed, recalculated change, or refuses with nothing changed.
|
|
876
|
+
* Update listeners run once, after the call returns. Malformed requests throw.
|
|
877
|
+
*/
|
|
878
|
+
applyEdits(request: XlsxEditRequest): XlsxEditResult;
|
|
879
|
+
/**
|
|
880
|
+
* Exports the committed workbook with the version it was read at: sparse cells with values,
|
|
881
|
+
* formulas and display text, plus sheet metadata and diagnostics. Nothing is recalculated,
|
|
882
|
+
* flushed or published. Options it cannot honor refuse; malformed ones throw.
|
|
883
|
+
*/
|
|
884
|
+
exportStructured(options?: XlsxExportOptions): XlsxExportResult<XlsxStructuredContent>;
|
|
885
|
+
/** {@link WorkbookHandle.exportStructured} rendered as Markdown from the same read. */
|
|
886
|
+
exportMarkdown(options?: XlsxExportOptions, markdownOptions?: XlsxMarkdownOptions): XlsxExportResult<XlsxMarkdownContent>;
|
|
326
887
|
dispose(): void;
|
|
327
888
|
}
|
|
328
889
|
type WasmInitInput = InitInput | Promise<InitInput>;
|
|
@@ -349,9 +910,19 @@ declare function isProposalsAvailable(): boolean;
|
|
|
349
910
|
* Throws an `Error` if the bytes are not a readable workbook.
|
|
350
911
|
*/
|
|
351
912
|
declare function openWorkbook(bytes: Uint8Array, options?: OpenWorkbookOptions): WorkbookHandle;
|
|
913
|
+
/**
|
|
914
|
+
* Exports `.xlsx` bytes as read, initializing the core if needed. Formula results are the
|
|
915
|
+
* stored ones: nothing is recalculated and no clock is read, so the same bytes and options
|
|
916
|
+
* always give the same content. Unreadable bytes and unusable options reject.
|
|
917
|
+
*/
|
|
918
|
+
declare function exportXlsxStructured(bytes: Uint8Array, options?: XlsxExportOptions): Promise<XlsxStructuredContent>;
|
|
919
|
+
/** {@link exportXlsxStructured} rendered as Markdown. */
|
|
920
|
+
declare function exportXlsxMarkdown(bytes: Uint8Array, options?: XlsxExportOptions, markdownOptions?: XlsxMarkdownOptions): Promise<XlsxMarkdownContent>;
|
|
921
|
+
/** Renders structured content as Markdown; content that does not validate rejects. */
|
|
922
|
+
declare function renderXlsxMarkdown(content: XlsxStructuredContent, options?: XlsxMarkdownOptions): Promise<XlsxMarkdownContent>;
|
|
352
923
|
/**
|
|
353
924
|
* The crate version string, for asserting wasm/js parity.
|
|
354
925
|
*/
|
|
355
926
|
declare function wasmVersion(): string;
|
|
356
927
|
|
|
357
|
-
export { type BorderPatch, type BorderPreset, type BorderStyle, type CalculationStatus, type CapturedFormat, type CellEdit, type CellInputEdit, type CellPoint, type CellPosition, ChartRegion, DisplayList, type EditResult, type HistoryState, type HorizontalAlignment, type MergedRange, type NumberFormat, type NumberFormatMutation, type OpenWorkbookOptions, type PrintMetrics, type Proposal, type ProposalCell, type ProposalEdit, type RangeStylePatch, type SelectionFormatting, type SheetInfo, StaleProposalError, type StyleProperty, type TextWrapping, type VerticalAlignment, type Viewport, type WasmInitInput, type WorkbookHandle, type WorkbookUpdateListener, type WorkbookUpdateOrigin, initWasm, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, wasmVersion };
|
|
928
|
+
export { type BorderPatch, type BorderPreset, type BorderStyle, type CalculationStatus, type CapturedFormat, type CellEdit, type CellInputEdit, type CellPoint, type CellPosition, ChartRegion, DisplayList, type DisplayListProfile, type EditProfile, type EditResult, type EditSuccess, type ExportCompletion, type ExportDiagnostic, type ExportSeverity, type HistoryState, type HorizontalAlignment, type MarkdownAnchor, type MergedRange, type NumberFormat, type NumberFormatMutation, type OpenWorkbookOptions, type OperationFailure, type OperationRefusal, type PrintMetrics, type ProfiledDisplayList, type ProfiledEditResult, type Proposal, type ProposalCell, type ProposalEdit, type RangeStylePatch, type SelectionFormatting, type SheetInfo, StaleProposalError, type StaleProposalTarget, type StyleProperty, type TextWrapping, type ValidationSuccess, type VerticalAlignment, type Viewport, type WasmInitInput, type WorkbookHandle, type WorkbookUpdateListener, type WorkbookUpdateOrigin, type XlsxAnchor, type XlsxCellAddress, type XlsxCellGuard, type XlsxCellPosition, type XlsxCellRead, type XlsxCellValue, type XlsxEditCalculation, type XlsxEditFailure, type XlsxEditFailureCode, type XlsxEditHistory, type XlsxEditOperation, type XlsxEditPreview, type XlsxEditReceipt, type XlsxEditRefusal, type XlsxEditRequest, type XlsxEditResult, type XlsxEditSource, type XlsxEditStep, type XlsxErrorValue, type XlsxExportCell, type XlsxExportDefinedName, type XlsxExportDiagnostic, type XlsxExportDiagnosticCode, type XlsxExportFailure, type XlsxExportFailureCode, type XlsxExportHyperlink, type XlsxExportMerge, type XlsxExportObject, type XlsxExportOptions, type XlsxExportResult, type XlsxExportScope, type XlsxExportSheet, type XlsxExportTable, type XlsxExportValue, type XlsxFindMatch, type XlsxFindRequest, type XlsxFindResult, type XlsxFormulaResult, type XlsxMarkdownContent, type XlsxMarkdownOptions, type XlsxObjectKind, type XlsxRangeAddress, type XlsxRangeRead, type XlsxRangeTarget, type XlsxReadCalculation, type XlsxReadRequest, type XlsxReadResult, type XlsxSheetEntry, type XlsxSheetIdentity, type XlsxSourcePart, type XlsxStructuredContent, type XlsxTextMatch, type XlsxTextSearchOptions, type XlsxValidationResult, exportXlsxMarkdown, exportXlsxStructured, initWasm, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, renderXlsxMarkdown, wasmVersion };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{w as buildA11yGrid,o as cellAtPoint,j as cellCount,p as cellRect,n as chartRegionAtPoint,e as clampScroll,k as extendTo,v as fromTsv,r as hyperlinkAtCell,l as moveFocus,h as normalizeRange,t as parseHyperlinkLocation,i as rangeContains,q as rangeRect,s as safeExternalHyperlink,g as selectionAt,m as selectionKeyReducer,u as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-E6PJOEEH.js';import {a}from'./chunk-O2XFH626.js';var he=1.3333333333333333,xe={left:"left",center:"center",right:"right"},ve={dashed:[4,2],dotted:[1,2]};function Ce(r,e,n,t={x:0,y:0}){r.save(),r.setTransform(n,0,0,n,t.x,t.y),r.beginPath(),r.rect(0,0,e.width,e.height),r.clip(),r.clearRect(0,0,e.width,e.height);for(let o of e.commands)Se(r,o);r.restore();}function Se(r,e){switch(e.op){case "fillRect":W(r,e.clip,()=>{r.fillStyle=e.color,r.fillRect(e.x,e.y,e.w,e.h);});return;case "line":W(r,e.clip,()=>Re(r,e));return;case "path":W(r,e.clip,()=>Pe(r,e));return;case "text":Je(r,e);return}}function W(r,e,n){if(!e){n();return}r.save(),r.beginPath(),r.rect(e.x,e.y,e.w,e.h),r.clip(),n(),r.restore();}function Pe(r,e){r.beginPath();for(let n of e.commands)switch(n.type){case "move":r.moveTo(n.x,n.y);break;case "line":r.lineTo(n.x,n.y);break;case "quad":r.quadraticCurveTo(n.cpx,n.cpy,n.x,n.y);break;case "cubic":r.bezierCurveTo(n.cp1x,n.cp1y,n.cp2x,n.cp2y,n.x,n.y);break;case "close":r.closePath();break}r.fillStyle=e.fill,r.fill(),e.stroke&&(r.strokeStyle=e.stroke.color,r.lineWidth=e.stroke.width,r.setLineDash([]),r.stroke());}function Re(r,e){if(r.strokeStyle=e.color,e.style==="double"){let n=Math.max(e.width*.8,.8),t=Math.abs(e.y1-e.y2)<=Math.abs(e.x1-e.x2),[o,i]=t?[0,n]:[n,0];r.lineWidth=Math.max(e.width*.6,.5),O(r,e.x1-o,e.y1-i,e.x2-o,e.y2-i),O(r,e.x1+o,e.y1+i,e.x2+o,e.y2+i);return}r.lineWidth=e.width,r.save(),r.setLineDash(e.style?ve[e.style]:[]),O(r,e.x1,e.y1,e.x2,e.y2),r.restore();}function O(r,e,n,t,o){r.beginPath(),r.moveTo(e,n),r.lineTo(t,o),r.stroke();}function Je(r,e){r.save(),e.clip&&(r.beginPath(),r.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),r.clip()),r.fillStyle=e.color,r.font=Ae(e),r.textAlign=xe[e.align??"left"],r.textBaseline="alphabetic",e.highlight&&ke(r,e),r.fillStyle=e.color,r.fillText(e.text,e.x,e.y),(e.underline||e.strike||e.dashedUnderline)&&Ee(r,e),r.restore();}function Ae(r){let e=r.italic?"italic ":"",n=r.bold?"bold ":"",t=r.fontFamily?r.chart?r.fontFamily:`"${r.fontFamily.replace(/"/g,'\\"')}", sans-serif`:"sans-serif";return `${e}${n}${D(r)}px ${t}`}function D(r){return r.fontSize*he}function Ee(r,e){let n=r.measureText(e.text).width,t=e.align??"left",o=t==="right"?e.x-n:t==="center"?e.x-n/2:e.x,i=D(e),c=Math.max(i*.05,.5);r.fillStyle=e.color,e.underline&&r.fillRect(o,e.y+i*.1,n,c),e.strike&&r.fillRect(o,e.y-i*.26,n,c),e.dashedUnderline&&(r.save(),r.strokeStyle=e.color,r.lineWidth=c,r.setLineDash([3,2]),O(r,o,e.y+i*.1,o+n,e.y+i*.1),r.restore());}function ke(r,e){let n=r.measureText(e.text),t=n.width,o=e.align??"left",i=o==="right"?e.x-t:o==="center"?e.x-t/2:e.x,c=D(e),d=n.actualBoundingBoxAscent||c*.8,a=n.actualBoundingBoxDescent||c*.2;r.fillStyle=e.highlight,r.fillRect(i-2,e.y-d-1,t+4,d+a+2);}var h=class r{static __wrap(e){let n=Object.create(r.prototype);return n.__wbg_ptr=e,V.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){let e=this.__destroy_into_raw();s.__wbg_xlsxdocument_free(e,0);}acceptProposalJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_acceptProposalJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}applyFormatJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_applyFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}applyOpsJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_applyOpsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}applyUpdateJson(e){let n,t;try{let c=U(e,s.__wbindgen_malloc),d=g,a=s.xlsxdocument_applyUpdateJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}calculationStatusJson(){let e,n;try{let i=s.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}captureFormatJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_captureFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}cellJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_cellJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}cellPositionJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_cellPositionJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}chartAtPointJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_chartAtPointJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}clearUpdateObservation(){s.xlsxdocument_clearUpdateObservation(this.__wbg_ptr);}get clientId(){return s.xlsxdocument_clientId(this.__wbg_ptr)}displayListJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_displayListJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}drainUpdateEvent(){let e=s.xlsxdocument_drainUpdateEvent(this.__wbg_ptr);if(e[3])throw _(e[2]);var n=v(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}editCellJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_editCellJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}editCellsJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_editCellsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}encodeDiff(e){let n=U(e,s.__wbindgen_malloc),t=g,o=s.xlsxdocument_encodeDiff(this.__wbg_ptr,n,t);if(o[3])throw _(o[2]);var i=v(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}encodeStateAsUpdate(){let e=s.xlsxdocument_encodeStateAsUpdate(this.__wbg_ptr);var n=v(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}encodeStateVector(){let e=s.xlsxdocument_encodeStateVector(this.__wbg_ptr);var n=v(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}historyStateJson(){let e,n;try{let i=s.xlsxdocument_historyStateJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}listProposalsJson(){let e,n;try{let i=s.xlsxdocument_listProposalsJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}mergedRangesJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_mergedRangesJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}moveChartJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_moveChartJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}static open(e){let n=U(e,s.__wbindgen_malloc),t=g,o=s.xlsxdocument_open(n,t);if(o[2])throw _(o[1]);return r.__wrap(o[0])}static openCollaborative(e,n){let t=U(e,s.__wbindgen_malloc),o=g,i=s.xlsxdocument_openCollaborative(t,o,n);if(i[2])throw _(i[1]);return r.__wrap(i[0])}patchRangeStyleJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_patchRangeStyleJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}printDisplayListJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_printDisplayListJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}proposeJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_proposeJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}rangeCellsJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_rangeCellsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}redoJson(){let e,n;try{let i=s.xlsxdocument_redoJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}rejectProposalJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_rejectProposalJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}renderPng(e){let n=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),t=g,o=s.xlsxdocument_renderPng(this.__wbg_ptr,n,t);if(o[3])throw _(o[2]);var i=v(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}renderRangePng(e){let n=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),t=g,o=s.xlsxdocument_renderRangePng(this.__wbg_ptr,n,t);if(o[3])throw _(o[2]);var i=v(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}saveBytes(){let e=s.xlsxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw _(e[2]);var n=v(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}selectionFormattingJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_selectionFormattingJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}setActiveSheet(e){let n=s.xlsxdocument_setActiveSheet(this.__wbg_ptr,e);if(n[1])throw _(n[0])}setRangeNumberFormatJson(e){let n,t;try{let c=y(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_setRangeNumberFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,_(a[2]);return n=o,t=i,p(o,i)}finally{s.__wbindgen_free(n,t,1);}}sheetInfoJson(){let e,n;try{let i=s.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}startUpdateObservation(){let e=s.xlsxdocument_startUpdateObservation(this.__wbg_ptr);if(e[1])throw _(e[0])}undoJson(){let e,n;try{let i=s.xlsxdocument_undoJson(this.__wbg_ptr);var t=i[0],o=i[1];if(i[3])throw t=0,o=0,_(i[2]);return e=t,n=o,p(t,o)}finally{s.__wbindgen_free(e,n,1);}}static version(){let e,n;try{let t=s.xlsxdocument_version();return e=t[0],n=t[1],p(t[0],t[1])}finally{s.__wbindgen_free(e,n,1);}}};Symbol.dispose&&(h.prototype[Symbol.dispose]=h.prototype.free);function Oe(){return {__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(e,n){throw new Error(p(e,n))},__wbg_getRandomValues_3f44b700395062e5:function(){return Ie(function(e,n){globalThis.crypto.getRandomValues(v(e,n));},arguments)},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbindgen_cast_0000000000000001:function(e,n){return p(e,n)},__wbindgen_init_externref_table:function(){let e=s.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,true),e.set(n+3,false);}}}}var V=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_xlsxdocument_free(r,1));function Ue(r){let e=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(e,r),e}function v(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}function p(r,e){return Fe(r>>>0,e)}var P=null;function S(){return (P===null||P.byteLength===0)&&(P=new Uint8Array(s.memory.buffer)),P}function Ie(r,e){try{return r.apply(this,e)}catch(n){let t=Ue(n);s.__wbindgen_exn_store(t);}}function U(r,e){let n=e(r.length*1,1)>>>0;return S().set(r,n/1),g=r.length,n}function y(r,e,n){if(n===void 0){let d=R.encode(r),a=e(d.length,1)>>>0;return S().subarray(a,a+d.length).set(d),g=d.length,a}let t=r.length,o=e(t,1)>>>0,i=S(),c=0;for(;c<t;c++){let d=r.charCodeAt(c);if(d>127)break;i[o+c]=d;}if(c!==t){c!==0&&(r=r.slice(c)),o=n(o,t,t=c+r.length*3,1)>>>0;let d=S().subarray(o+c,o+t),a=R.encodeInto(r,d);c+=a.written,o=n(o,t,c,1)>>>0;}return g=c,o}function _(r){let e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}var I=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});I.decode();var Te=2146435072,N=0;function Fe(r,e){return N+=e,N>=Te&&(I=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),I.decode(),N=e),I.decode(S().subarray(r,r+e))}var R=new TextEncoder;"encodeInto"in R||(R.encodeInto=function(r,e){let n=R.encode(r);return e.set(n),{read:r.length,written:n.length}});var g=0,s;function Ne(r,e){return s=r.exports,P=null,s.__wbindgen_start(),s}async function Le(r,e){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(r.ok&&n(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let t=await r.arrayBuffer();return await WebAssembly.instantiate(t,e)}else {let t=await WebAssembly.instantiate(r,e);return t instanceof WebAssembly.Instance?{instance:t,module:r}:t}function n(t){switch(t){case "basic":case "cors":case "default":return true}return false}}async function B(r){if(s!==void 0)return s;if(r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let e=Oe();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));let{instance:n,module:t}=await Le(await r,e);return Ne(n)}var T=class extends Error{constructor(n){super(`stale: ${n.join(", ")}`);a(this,"cells");this.name="StaleProposalError",this.cells=n;}},H="stale: ";function Me(r){let e=r.slice(H.length).split(",").map(n=>n.trim()).filter(n=>n.length>0);return new T(e)}var L=false,J;function ze(r=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return L?Promise.resolve():J||(J=B({module_or_path:r}).then(()=>{L=true;},e=>{throw J=void 0,A(e)}),J)}function j(){if(!L)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function A(r){return r instanceof Error?r:new Error(typeof r=="string"?r:String(r))}function Ve(){return typeof WebAssembly=="object"}function Be(){return typeof h.prototype.renderPng=="function"}function He(){return typeof h.prototype.proposeJson=="function"}function je(r,e={}){j();let n=qe(e),t;try{t=n===void 0?h.open(r):h.openCollaborative(r,n);}catch(l){throw A(l)}let o=new Map,i=[],c=0,d=false,a=false,E=0,F=false;function M(){if(d)throw new Error("workbook handle is disposed")}function q(){if(!(d||F||E!==0)){F=true;try{for(;!d&&i.length>0;){let l=i.shift();if(!l)break;for(let[u,f]of [...o]){if(d)return;if(o.get(u)===f)try{f(l.update.slice(),l.origin);}catch{}}}}finally{F=false,d&&(i.length=0);}}}function X(){if(!(!a||d))for(;;){let l=t.drainUpdateEvent();if(l.byteLength===0)return;let u=l[0];if(u!==0&&u!==1)throw new Error(`xlsx wasm returned unknown update origin ${u}`);i.push({update:l.subarray(1),origin:u===0?"local":"remote"});}}function w(l,u=false){M(),E+=1;try{let f,m,C=!1;try{f=l();}catch(x){m=x,C=!0;}if(u)try{X();}catch(x){C||(m=x,C=!0);}if(C)throw A(m);return f}finally{E-=1,E===0&&q();}}function k(l){return w(l,true)}function b(l,u=false){return w(()=>JSON.parse(l()),u)}function G(){a||(w(()=>t.startUpdateObservation()),a=true);}function $(){!a||o.size>0||d||(i.length=0,w(()=>t.clearUpdateObservation()),a=false);}return {get clientId(){return w(()=>t.clientId)},encodeStateVector(){return w(()=>t.encodeStateVector())},encodeStateAsUpdate(l){return w(()=>l===void 0?t.encodeStateAsUpdate():t.encodeDiff(l))},applyUpdate(l){return b(()=>t.applyUpdateJson(l),true)},onUpdate(l){if(M(),typeof l!="function")throw new TypeError("update listener must be a function");let u=c++;o.set(u,l);try{G();}catch(m){throw o.delete(u),m}let f=true;return ()=>{f&&(f=false,o.delete(u),$());}},sheetInfo(){return b(()=>t.sheetInfoJson())},calculationStatus(){return w(()=>{let l=t.calculationStatusJson;return typeof l!="function"?{limitedCells:[]}:JSON.parse(l.call(t))})},displayList(l){return b(()=>t.displayListJson(JSON.stringify(l)))},printDisplayList(l,u,f,m){return b(()=>t.printDisplayListJson(JSON.stringify({sheet:l,range:u,metrics:f,gridlines:m})))},chartAtPoint(l,u,f){return b(()=>t.chartAtPointJson(JSON.stringify({viewport:l,x:u,y:f})))},moveChart(l,u,f,m){return b(()=>t.moveChartJson(JSON.stringify({sheet:l,chart:u,dx:f,dy:m})),true)},setActiveSheet(l){k(()=>t.setActiveSheet(l));},editCell(l,u,f,m){return b(()=>t.editCellJson(JSON.stringify({sheet:l,row:u,col:f,input:m})),true)},editCells(l,u){return b(()=>t.editCellsJson(JSON.stringify({sheet:l,edits:u})),true)},applyOps(l){return b(()=>t.applyOpsJson(JSON.stringify({ops:l})),true)},undo(){return b(()=>t.undoJson(),true)},redo(){return b(()=>t.redoJson(),true)},cell(l,u,f){return b(()=>t.cellJson(JSON.stringify({sheet:l,row:u,col:f})))},cellPosition(l,u,f){return b(()=>t.cellPositionJson(JSON.stringify({sheet:l,row:u,col:f})))},rangeCells(l,u){return b(()=>t.rangeCellsJson(JSON.stringify({sheet:l,range:u}))).cells},patchRangeStyle(l,u,f){return b(()=>t.patchRangeStyleJson(JSON.stringify({sheet:l,range:u,patch:f})),true)},setNumberFormat(l,u,f){let m=typeof f=="string"?{type:f}:f;return b(()=>t.setRangeNumberFormatJson(JSON.stringify({sheet:l,range:u,format:m})),true)},selectionFormatting(l,u){return b(()=>t.selectionFormattingJson(JSON.stringify({sheet:l,range:u})))},captureFormat(l,u){return b(()=>t.captureFormatJson(JSON.stringify({sheet:l,range:u})))},applyFormat(l,u,f){return b(()=>t.applyFormatJson(JSON.stringify({sheet:l,range:u,format:f})),true)},mergedRanges(l,u){return b(()=>t.mergedRangesJson(JSON.stringify({sheet:l,range:u}))).ranges},historyState(){return b(()=>t.historyStateJson())},renderPng(l){return w(()=>{let u=t.renderPng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(t,JSON.stringify(l)).slice()})},renderRangePng(l){return w(()=>{let u=t.renderRangePng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(t,JSON.stringify(l??{})).slice()})},save(){return w(()=>t.saveBytes())},propose(l,u,f){return k(()=>{let m=t.proposeJson;if(typeof m!="function")throw new Error("proposals not in this build");let C=f.map(({numberFormat:x,...K})=>({...K,...x===void 0?{}:{numberFormat:typeof x=="string"?{type:x}:x}}));return JSON.parse(m.call(t,JSON.stringify({agentId:l,note:u,edits:C})))})},listProposals(){return w(()=>{let l=t.listProposalsJson;return typeof l!="function"?[]:JSON.parse(l.call(t)).proposals})},acceptProposal(l,u){try{return k(()=>{let f=t.acceptProposalJson;if(typeof f!="function")throw new Error("proposals not in this build");return JSON.parse(f.call(t,JSON.stringify({id:l,force:u?.force??!1})))})}catch(f){let m=f instanceof Error?f.message:typeof f=="string"?f:String(f);throw m.startsWith(H)?Me(m):A(f)}},rejectProposal(l){return k(()=>{let u=t.rejectProposalJson;return typeof u!="function"?false:JSON.parse(u.call(t,JSON.stringify({id:l}))).removed})},isProposalsAvailable(){return w(()=>typeof t.proposeJson=="function")},dispose(){if(d)return;d=true,o.clear(),i.length=0;let l;if(a){try{t.clearUpdateObservation();}catch(u){l=u;}a=false;}try{t.free();}catch(u){l??(l=u);}if(l!==void 0)throw A(l)}}}function qe(r){if(!r.collaborative){if(r.clientId!==void 0)throw new TypeError("clientId requires collaborative mode");return}if(r.clientId!==void 0){if(!Number.isSafeInteger(r.clientId)||r.clientId<=0||r.clientId>Number.MAX_SAFE_INTEGER)throw new RangeError("clientId must be a nonzero safe integer");return r.clientId}let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate a collaboration client ID");let n=new Uint32Array(2),t;do e.getRandomValues(n),t=(n[0]&2097151)*4294967296+n[1];while(t===0);return t}function Xe(){return j(),h.version()}export{T as StaleProposalError,ze as initWasm,Be as isPngExportAvailable,He as isProposalsAvailable,Ve as isWasmAvailable,je as openWorkbook,Ce as paintDisplayList,Xe as wasmVersion};
|
|
1
|
+
export{w as buildA11yGrid,o as cellAtPoint,j as cellCount,p as cellRect,n as chartRegionAtPoint,e as clampScroll,k as extendTo,v as fromTsv,r as hyperlinkAtCell,l as moveFocus,h as normalizeRange,t as parseHyperlinkLocation,i as rangeContains,q as rangeRect,s as safeExternalHyperlink,g as selectionAt,m as selectionKeyReducer,u as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-E6PJOEEH.js';import {a}from'./chunk-O2XFH626.js';var Ce=1.3333333333333333,Re={left:"left",center:"center",right:"right"},Je={dashed:[4,2],dotted:[1,2]};function Ee(s,e,r,t={x:0,y:0}){s.save(),s.setTransform(r,0,0,r,t.x,t.y),s.beginPath(),s.rect(0,0,e.width,e.height),s.clip(),s.clearRect(0,0,e.width,e.height);for(let n of e.commands)Pe(s,n);s.restore();}function Pe(s,e){switch(e.op){case "fillRect":L(s,e.clip,()=>{s.fillStyle=e.color,s.fillRect(e.x,e.y,e.w,e.h);});return;case "line":L(s,e.clip,()=>ke(s,e));return;case "path":L(s,e.clip,()=>Xe(s,e));return;case "text":Ae(s,e);return}}function L(s,e,r){if(!e){r();return}s.save(),s.beginPath(),s.rect(e.x,e.y,e.w,e.h),s.clip(),r(),s.restore();}function Xe(s,e){s.beginPath();for(let r of e.commands)switch(r.type){case "move":s.moveTo(r.x,r.y);break;case "line":s.lineTo(r.x,r.y);break;case "quad":s.quadraticCurveTo(r.cpx,r.cpy,r.x,r.y);break;case "cubic":s.bezierCurveTo(r.cp1x,r.cp1y,r.cp2x,r.cp2y,r.x,r.y);break;case "close":s.closePath();break}s.fillStyle=e.fill,s.fill(),e.stroke&&(s.strokeStyle=e.stroke.color,s.lineWidth=e.stroke.width,s.setLineDash([]),s.stroke());}function ke(s,e){if(s.strokeStyle=e.color,e.style==="double"){let r=Math.max(e.width*.8,.8),t=Math.abs(e.y1-e.y2)<=Math.abs(e.x1-e.x2),[n,i]=t?[0,r]:[r,0];s.lineWidth=Math.max(e.width*.6,.5),M(s,e.x1-n,e.y1-i,e.x2-n,e.y2-i),M(s,e.x1+n,e.y1+i,e.x2+n,e.y2+i);return}s.lineWidth=e.width,s.save(),s.setLineDash(e.style?Je[e.style]:[]),M(s,e.x1,e.y1,e.x2,e.y2),s.restore();}function M(s,e,r,t,n){s.beginPath(),s.moveTo(e,r),s.lineTo(t,n),s.stroke();}function Ae(s,e){s.save(),e.clip&&(s.beginPath(),s.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),s.clip()),s.fillStyle=e.color,s.font=Oe(e),s.textAlign=Re[e.align??"left"],s.textBaseline="alphabetic",e.highlight&&Fe(s,e),s.fillStyle=e.color,s.fillText(e.text,e.x,e.y),(e.underline||e.strike||e.dashedUnderline)&&Te(s,e),s.restore();}function Oe(s){let e=s.italic?"italic ":"",r=s.bold?"bold ":"",t=s.fontFamily?s.chart?s.fontFamily:`"${s.fontFamily.replace(/"/g,'\\"')}", sans-serif`:"sans-serif";return `${e}${r}${V(s)}px ${t}`}function V(s){return s.fontSize*Ce}function Te(s,e){let r=s.measureText(e.text).width,t=e.align??"left",n=t==="right"?e.x-r:t==="center"?e.x-r/2:e.x,i=V(e),d=Math.max(i*.05,.5);s.fillStyle=e.color,e.underline&&s.fillRect(n,e.y+i*.1,r,d),e.strike&&s.fillRect(n,e.y-i*.26,r,d),e.dashedUnderline&&(s.save(),s.strokeStyle=e.color,s.lineWidth=d,s.setLineDash([3,2]),M(s,n,e.y+i*.1,n+r,e.y+i*.1),s.restore());}function Fe(s,e){let r=s.measureText(e.text),t=r.width,n=e.align??"left",i=n==="right"?e.x-t:n==="center"?e.x-t/2:e.x,d=V(e),u=r.actualBoundingBoxAscent||d*.8,l=r.actualBoundingBoxDescent||d*.2;s.fillStyle=e.highlight,s.fillRect(i-2,e.y-u-1,t+4,u+l+2);}var v=class s{static __wrap(e){let r=Object.create(s.prototype);return r.__wbg_ptr=e,H.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_xlsxdocument_free(e,0);}acceptProposalJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_acceptProposalJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}applyEditsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_applyEditsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}applyFormatJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_applyFormatJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}applyOpsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_applyOpsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}applyOpsProfiledJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_applyOpsProfiledJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}applyUpdateJson(e){let r,t;try{let d=P(e,o.__wbindgen_malloc),u=p,l=o.xlsxdocument_applyUpdateJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}calculationStatusJson(){let e,r;try{let i=o.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}captureFormatJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_captureFormatJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}cellJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_cellJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}cellPositionJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_cellPositionJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}chartAtPointJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_chartAtPointJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}clearUpdateObservation(){o.xlsxdocument_clearUpdateObservation(this.__wbg_ptr);}get clientId(){return o.xlsxdocument_clientId(this.__wbg_ptr)}displayListJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_displayListJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}displayListProfiledJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_displayListProfiledJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}documentVersion(){let e,r;try{let t=o.xlsxdocument_documentVersion(this.__wbg_ptr);return e=t[0],r=t[1],g(t[0],t[1])}finally{o.__wbindgen_free(e,r,1);}}drainUpdateEvent(){let e=o.xlsxdocument_drainUpdateEvent(this.__wbg_ptr);if(e[3])throw f(e[2]);var r=R(e[0],e[1]).slice();return o.__wbindgen_free(e[0],e[1]*1,1),r}editCellJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_editCellJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}editCellProfiledJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_editCellProfiledJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}editCellsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_editCellsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}encodeDiff(e){let r=P(e,o.__wbindgen_malloc),t=p,n=o.xlsxdocument_encodeDiff(this.__wbg_ptr,r,t);if(n[3])throw f(n[2]);var i=R(n[0],n[1]).slice();return o.__wbindgen_free(n[0],n[1]*1,1),i}encodeStateAsUpdate(){let e=o.xlsxdocument_encodeStateAsUpdate(this.__wbg_ptr);var r=R(e[0],e[1]).slice();return o.__wbindgen_free(e[0],e[1]*1,1),r}encodeStateVector(){let e=o.xlsxdocument_encodeStateVector(this.__wbg_ptr);var r=R(e[0],e[1]).slice();return o.__wbindgen_free(e[0],e[1]*1,1),r}exportMarkdownJson(e,r){let t,n;try{let u=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),l=p,h=b(r,o.__wbindgen_malloc,o.__wbindgen_realloc),w=p,S=o.xlsxdocument_exportMarkdownJson(this.__wbg_ptr,u,l,h,w);var i=S[0],d=S[1];if(S[3])throw i=0,d=0,f(S[2]);return t=i,n=d,g(i,d)}finally{o.__wbindgen_free(t,n,1);}}exportStructuredJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_exportStructuredJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}findTextJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_findTextJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}historyStateJson(){let e,r;try{let i=o.xlsxdocument_historyStateJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}listProposalsJson(){let e,r;try{let i=o.xlsxdocument_listProposalsJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}mergedRangesJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_mergedRangesJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}moveChartJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_moveChartJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}static open(e){let r=P(e,o.__wbindgen_malloc),t=p,n=o.xlsxdocument_open(r,t);if(n[2])throw f(n[1]);return s.__wrap(n[0])}static openCollaborative(e,r){let t=P(e,o.__wbindgen_malloc),n=p,i=o.xlsxdocument_openCollaborative(t,n,r);if(i[2])throw f(i[1]);return s.__wrap(i[0])}patchRangeStyleJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_patchRangeStyleJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}printDisplayListJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_printDisplayListJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}proposeJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_proposeJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}rangeCellsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_rangeCellsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}readCellsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_readCellsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}redoJson(){let e,r;try{let i=o.xlsxdocument_redoJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}rejectProposalJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_rejectProposalJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}renderPng(e){let r=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),t=p,n=o.xlsxdocument_renderPng(this.__wbg_ptr,r,t);if(n[3])throw f(n[2]);var i=R(n[0],n[1]).slice();return o.__wbindgen_free(n[0],n[1]*1,1),i}renderRangePng(e){let r=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),t=p,n=o.xlsxdocument_renderRangePng(this.__wbg_ptr,r,t);if(n[3])throw f(n[2]);var i=R(n[0],n[1]).slice();return o.__wbindgen_free(n[0],n[1]*1,1),i}saveBytes(){let e=o.xlsxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw f(e[2]);var r=R(e[0],e[1]).slice();return o.__wbindgen_free(e[0],e[1]*1,1),r}searchTextJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_searchTextJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}selectionFormattingJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_selectionFormattingJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}setActiveSheet(e){let r=o.xlsxdocument_setActiveSheet(this.__wbg_ptr,e);if(r[1])throw f(r[0])}setRangeNumberFormatJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_setRangeNumberFormatJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}sheetInfoJson(){let e,r;try{let i=o.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}startUpdateObservation(){let e=o.xlsxdocument_startUpdateObservation(this.__wbg_ptr);if(e[1])throw f(e[0])}undoJson(){let e,r;try{let i=o.xlsxdocument_undoJson(this.__wbg_ptr);var t=i[0],n=i[1];if(i[3])throw t=0,n=0,f(i[2]);return e=t,r=n,g(t,n)}finally{o.__wbindgen_free(e,r,1);}}validateEditsJson(e){let r,t;try{let d=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=o.xlsxdocument_validateEditsJson(this.__wbg_ptr,d,u);var n=l[0],i=l[1];if(l[3])throw n=0,i=0,f(l[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}static version(){let e,r;try{let t=o.xlsxdocument_version();return e=t[0],r=t[1],g(t[0],t[1])}finally{o.__wbindgen_free(e,r,1);}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function j(s,e,r){let t,n;try{let u=P(s,o.__wbindgen_malloc),l=p,h=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),w=p,S=b(r,o.__wbindgen_malloc,o.__wbindgen_realloc),D=p,J=o.exportXlsxMarkdownJson(u,l,h,w,S,D);var i=J[0],d=J[1];if(J[3])throw i=0,d=0,f(J[2]);return t=i,n=d,g(i,d)}finally{o.__wbindgen_free(t,n,1);}}function G(s,e){let r,t;try{let d=P(s,o.__wbindgen_malloc),u=p,l=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),h=p,w=o.exportXlsxStructuredJson(d,u,l,h);var n=w[0],i=w[1];if(w[3])throw n=0,i=0,f(w[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}function $(s,e){let r,t;try{let d=b(s,o.__wbindgen_malloc,o.__wbindgen_realloc),u=p,l=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),h=p,w=o.renderXlsxMarkdownJson(d,u,l,h);var n=w[0],i=w[1];if(w[3])throw n=0,i=0,f(w[2]);return r=n,t=i,g(n,i)}finally{o.__wbindgen_free(r,t,1);}}function Me(){return {__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(e,r){throw new Error(g(e,r))},__wbg_getRandomValues_3f44b700395062e5:function(){return Ie(function(e,r){globalThis.crypto.getRandomValues(R(e,r));},arguments)},__wbg_now_10f06390f30d43ea:function(){return performance.now()},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbindgen_cast_0000000000000001:function(e,r){return g(e,r)},__wbindgen_init_externref_table:function(){let e=o.__wbindgen_externrefs,r=e.grow(4);e.set(0,void 0),e.set(r+0,void 0),e.set(r+1,null),e.set(r+2,true),e.set(r+3,false);}}}}var H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(s=>o.__wbg_xlsxdocument_free(s,1));function Ue(s){let e=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(e,s),e}function R(s,e){return s=s>>>0,X().subarray(s/1,s/1+e)}function g(s,e){return De(s>>>0,e)}var A=null;function X(){return (A===null||A.byteLength===0)&&(A=new Uint8Array(o.memory.buffer)),A}function Ie(s,e){try{return s.apply(this,e)}catch(r){let t=Ue(r);o.__wbindgen_exn_store(t);}}function P(s,e){let r=e(s.length*1,1)>>>0;return X().set(s,r/1),p=s.length,r}function b(s,e,r){if(r===void 0){let u=O.encode(s),l=e(u.length,1)>>>0;return X().subarray(l,l+u.length).set(u),p=u.length,l}let t=s.length,n=e(t,1)>>>0,i=X(),d=0;for(;d<t;d++){let u=s.charCodeAt(d);if(u>127)break;i[n+d]=u;}if(d!==t){d!==0&&(s=s.slice(d)),n=r(n,t,t=d+s.length*3,1)>>>0;let u=X().subarray(n+d,n+t),l=O.encodeInto(s,u);d+=l.written,n=r(n,t,d,1)>>>0;}return p=d,n}function f(s){let e=o.__wbindgen_externrefs.get(s);return o.__externref_table_dealloc(s),e}var U=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});U.decode();var Ne=2146435072,z=0;function De(s,e){return z+=e,z>=Ne&&(U=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),U.decode(),z=e),U.decode(X().subarray(s,s+e))}var O=new TextEncoder;"encodeInto"in O||(O.encodeInto=function(s,e){let r=O.encode(s);return e.set(r),{read:s.length,written:r.length}});var p=0,o;function Ve(s,e){return o=s.exports,A=null,o.__wbindgen_start(),o}async function ze(s,e){if(typeof Response=="function"&&s instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(s,e)}catch(n){if(s.ok&&r(s.type)&&s.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}let t=await s.arrayBuffer();return await WebAssembly.instantiate(t,e)}else {let t=await WebAssembly.instantiate(s,e);return t instanceof WebAssembly.Instance?{instance:t,module:s}:t}function r(t){switch(t){case "basic":case "cors":case "default":return true}return false}}async function K(s){if(o!==void 0)return o;if(s!==void 0&&(Object.getPrototypeOf(s)===Object.prototype?{module_or_path:s}=s:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),s===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let e=Me();(typeof s=="string"||typeof Request=="function"&&s instanceof Request||typeof URL=="function"&&s instanceof URL)&&(s=fetch(s));let{instance:r,module:t}=await ze(await s,e);return Ve(r)}var I=class extends Error{constructor(r,t=[]){super(`stale: ${r.join(", ")}`);a(this,"cells");a(this,"targets");this.name="StaleProposalError",this.cells=r,this.targets=t;}};function qe(s){if(!s.startsWith("{"))return null;try{let e=JSON.parse(s);return e.code!=="staleProposal"||!Array.isArray(e.cells)?null:new I(e.cells,Array.isArray(e.targets)?e.targets:[])}catch{return null}}var q=false,T;function N(s=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return q?Promise.resolve():T||(T=K({module_or_path:s}).then(()=>{q=true;},e=>{throw T=void 0,k(e)}),T)}function Y(){if(!q)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function k(s){return s instanceof Error?s:new Error(typeof s=="string"?s:String(s))}function Be(){return typeof WebAssembly=="object"}function He(){return typeof v.prototype.renderPng=="function"}function je(){return typeof v.prototype.proposeJson=="function"}function Ge(s,e={}){Y();let r=$e(e),t;try{t=r===void 0?v.open(s):v.openCollaborative(s,r);}catch(a){throw k(a)}let n=new Map,i=[],d=0,u=false,l=false,h=0,w=false;function S(){if(u)throw new Error("workbook handle is disposed")}function D(){if(!(u||w||h!==0)){w=true;try{for(;!u&&i.length>0;){let a=i.shift();if(!a)break;for(let[c,_]of [...n]){if(u)return;if(n.get(c)===_)try{_(a.update.slice(),a.origin);}catch{}}}}finally{w=false,u&&(i.length=0);}}}function J(){if(!(!l||u))for(;;){let a=t.drainUpdateEvent();if(a.byteLength===0)return;let c=a[0];if(c!==0&&c!==1)throw new Error(`xlsx wasm returned unknown update origin ${c}`);i.push({update:a.subarray(1),origin:c===0?"local":"remote"});}}function m(a,c=false){S(),h+=1;try{let _,x,E=!1;try{_=a();}catch(C){x=C,E=!0;}if(c)try{J();}catch(C){E||(x=C,E=!0);}if(E)throw k(x);return _}finally{h-=1,h===0&&D();}}function F(a){return m(a,true)}function y(a,c=false){return m(()=>JSON.parse(a()),c)}function Q(){l||(m(()=>t.startUpdateObservation()),l=true);}function Z(){!l||n.size>0||u||(i.length=0,m(()=>t.clearUpdateObservation()),l=false);}return {get clientId(){return m(()=>t.clientId)},encodeStateVector(){return m(()=>t.encodeStateVector())},encodeStateAsUpdate(a){return m(()=>a===void 0?t.encodeStateAsUpdate():t.encodeDiff(a))},applyUpdate(a){return y(()=>t.applyUpdateJson(a),true)},onUpdate(a){if(S(),typeof a!="function")throw new TypeError("update listener must be a function");let c=d++;n.set(c,a);try{Q();}catch(x){throw n.delete(c),x}let _=true;return ()=>{_&&(_=false,n.delete(c),Z());}},sheetInfo(){return y(()=>t.sheetInfoJson())},calculationStatus(){return m(()=>{let a=t.calculationStatusJson;return typeof a!="function"?{limitedCells:[]}:JSON.parse(a.call(t))})},displayList(a){return y(()=>t.displayListJson(JSON.stringify(a)))},displayListProfiled(a){return y(()=>t.displayListProfiledJson(JSON.stringify(a)))},printDisplayList(a,c,_,x){return y(()=>t.printDisplayListJson(JSON.stringify({sheet:a,range:c,metrics:_,gridlines:x})))},chartAtPoint(a,c,_){return y(()=>t.chartAtPointJson(JSON.stringify({viewport:a,x:c,y:_})))},moveChart(a,c,_,x){return y(()=>t.moveChartJson(JSON.stringify({sheet:a,chart:c,dx:_,dy:x})),true)},setActiveSheet(a){F(()=>t.setActiveSheet(a));},editCell(a,c,_,x){return y(()=>t.editCellJson(JSON.stringify({sheet:a,row:c,col:_,input:x})),true)},editCellProfiled(a,c,_,x){return y(()=>t.editCellProfiledJson(JSON.stringify({sheet:a,row:c,col:_,input:x})),true)},editCells(a,c){return y(()=>t.editCellsJson(JSON.stringify({sheet:a,edits:c})),true)},applyOps(a){return y(()=>t.applyOpsJson(JSON.stringify({ops:a})),true)},applyOpsProfiled(a){return y(()=>t.applyOpsProfiledJson(JSON.stringify({ops:a})),true)},undo(){return y(()=>t.undoJson(),true)},redo(){return y(()=>t.redoJson(),true)},cell(a,c,_){return y(()=>t.cellJson(JSON.stringify({sheet:a,row:c,col:_})))},searchText(a,c){if(!a)return [];let _=c?.limit;if(_!==void 0&&(!Number.isSafeInteger(_)||_<0||_>4294967295))throw new RangeError("search limit must be an unsigned 32-bit integer");return y(()=>t.searchTextJson(JSON.stringify({query:a,caseSensitive:c?.caseSensitive??false,..._===void 0?{}:{limit:_}})))},cellPosition(a,c,_){return y(()=>t.cellPositionJson(JSON.stringify({sheet:a,row:c,col:_})))},rangeCells(a,c){return y(()=>t.rangeCellsJson(JSON.stringify({sheet:a,range:c}))).cells},patchRangeStyle(a,c,_){return y(()=>t.patchRangeStyleJson(JSON.stringify({sheet:a,range:c,patch:_})),true)},setNumberFormat(a,c,_){let x=typeof _=="string"?{type:_}:_;return y(()=>t.setRangeNumberFormatJson(JSON.stringify({sheet:a,range:c,format:x})),true)},selectionFormatting(a,c){return y(()=>t.selectionFormattingJson(JSON.stringify({sheet:a,range:c})))},captureFormat(a,c){return y(()=>t.captureFormatJson(JSON.stringify({sheet:a,range:c})))},applyFormat(a,c,_){return y(()=>t.applyFormatJson(JSON.stringify({sheet:a,range:c,format:_})),true)},mergedRanges(a,c){return y(()=>t.mergedRangesJson(JSON.stringify({sheet:a,range:c}))).ranges},historyState(){return y(()=>t.historyStateJson())},renderPng(a){return m(()=>{let c=t.renderPng;if(typeof c!="function")throw new Error("png export not in this build");return c.call(t,JSON.stringify(a)).slice()})},renderRangePng(a){return m(()=>{let c=t.renderRangePng;if(typeof c!="function")throw new Error("png export not in this build");return c.call(t,JSON.stringify(a??{})).slice()})},save(){return m(()=>t.saveBytes())},propose(a,c,_){return F(()=>{let x=t.proposeJson;if(typeof x!="function")throw new Error("proposals not in this build");let E=_.map(({numberFormat:C,...ee})=>({...ee,...C===void 0?{}:{numberFormat:typeof C=="string"?{type:C}:C}}));return JSON.parse(x.call(t,JSON.stringify({agentId:a,note:c,edits:E})))})},listProposals(){return m(()=>{let a=t.listProposalsJson;return typeof a!="function"?[]:JSON.parse(a.call(t)).proposals})},acceptProposal(a,c){try{return F(()=>{let _=t.acceptProposalJson;if(typeof _!="function")throw new Error("proposals not in this build");return JSON.parse(_.call(t,JSON.stringify({id:a,force:c?.force??!1})))})}catch(_){let x=_ instanceof Error?_.message:typeof _=="string"?_:String(_);throw qe(x)??k(_)}},rejectProposal(a){return F(()=>{let c=t.rejectProposalJson;return typeof c!="function"?false:JSON.parse(c.call(t,JSON.stringify({id:a}))).removed})},isProposalsAvailable(){return m(()=>typeof t.proposeJson=="function")},version(){return m(()=>t.documentVersion())},readCells(a){return y(()=>t.readCellsJson(JSON.stringify(a)))},findText(a){return y(()=>t.findTextJson(JSON.stringify(a)))},validateEdits(a){return y(()=>t.validateEditsJson(JSON.stringify(a)))},applyEdits(a){return y(()=>t.applyEditsJson(JSON.stringify(a)),true)},exportStructured(a={}){return y(()=>t.exportStructuredJson(JSON.stringify(a)))},exportMarkdown(a={},c={}){return y(()=>t.exportMarkdownJson(JSON.stringify(a),JSON.stringify(c)))},dispose(){if(u)return;u=true,n.clear(),i.length=0;let a;if(l){try{t.clearUpdateObservation();}catch(c){a=c;}l=false;}try{t.free();}catch(c){a??(a=c);}if(a!==void 0)throw k(a)}}}function $e(s){if(!s.collaborative){if(s.clientId!==void 0)throw new TypeError("clientId requires collaborative mode");return}if(s.clientId!==void 0){if(!Number.isSafeInteger(s.clientId)||s.clientId<=0||s.clientId>Number.MAX_SAFE_INTEGER)throw new RangeError("clientId must be a nonzero safe integer");return s.clientId}let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate a collaboration client ID");let r=new Uint32Array(2),t;do e.getRandomValues(r),t=(r[0]&2097151)*4294967296+r[1];while(t===0);return t}function B(s){try{return JSON.parse(s())}catch(e){throw k(e)}}async function Ke(s,e={}){return await N(),B(()=>G(s,JSON.stringify(e)))}async function Ye(s,e={},r={}){return await N(),B(()=>j(s,JSON.stringify(e),JSON.stringify(r)))}async function Qe(s,e={}){return await N(),B(()=>$(JSON.stringify(s),JSON.stringify(e)))}function Ze(){return Y(),v.version()}export{I as StaleProposalError,Ye as exportXlsxMarkdown,Ke as exportXlsxStructured,N as initWasm,He as isPngExportAvailable,je as isProposalsAvailable,Be as isWasmAvailable,Ge as openWorkbook,Ee as paintDisplayList,Qe as renderXlsxMarkdown,Ze as wasmVersion};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Excel-faithful XLSX spreadsheet editor and viewer core — full OOXML fidelity, real-time human + AI agent collaboration. Framework-free (Rust/Wasm).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xlsx",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typecheck": "tsc --noEmit -p ."
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/bun": "^1.
|
|
55
|
+
"@types/bun": "^1.4.2",
|
|
56
56
|
"@types/node": "^26.0.0",
|
|
57
57
|
"tsup": "^8.5.1",
|
|
58
58
|
"typescript": "^6.0.3"
|