@beyondwork/xlsx-substrate-bindings 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE.md +31 -0
  2. package/README.md +135 -2
  3. package/dist/ai/agent-metadata.d.ts +363 -0
  4. package/dist/ai/agent-metadata.js +227 -0
  5. package/dist/ai/index.d.ts +6 -0
  6. package/dist/ai/index.js +7 -0
  7. package/dist/ai/mutation-bridge.d.ts +82 -0
  8. package/dist/ai/mutation-bridge.js +179 -0
  9. package/dist/ai/types.d.ts +765 -0
  10. package/dist/ai/types.js +23 -0
  11. package/dist/index.d.ts +50 -0
  12. package/dist/index.js +90 -0
  13. package/dist/runtime/index.d.ts +2 -0
  14. package/dist/runtime/index.js +1 -0
  15. package/dist/runtime/types.d.ts +1435 -0
  16. package/dist/runtime/types.js +15 -0
  17. package/dist/shared.d.ts +69 -0
  18. package/dist/shared.js +1 -0
  19. package/dist/ui/index.d.ts +2 -0
  20. package/dist/ui/index.js +1 -0
  21. package/dist/ui/types.d.ts +765 -0
  22. package/dist/ui/types.js +12 -0
  23. package/dist/wasm/ai-session-bridge.d.ts +97 -0
  24. package/dist/wasm/ai-session-bridge.js +154 -0
  25. package/dist/wasm/bridge-contract.d.ts +643 -0
  26. package/dist/wasm/bridge-contract.js +1001 -0
  27. package/dist/wasm/index.d.ts +50 -0
  28. package/dist/wasm/index.js +297 -0
  29. package/dist/wasm/memory-budget.d.ts +77 -0
  30. package/dist/wasm/memory-budget.js +532 -0
  31. package/dist/wasm/runtime-guard.d.ts +141 -0
  32. package/dist/wasm/runtime-guard.js +373 -0
  33. package/dist/wasm/session-router.d.ts +98 -0
  34. package/dist/wasm/session-router.js +184 -0
  35. package/dist/wasm/sheet-window-binary-reference.d.ts +9 -0
  36. package/dist/wasm/sheet-window-binary-reference.js +308 -0
  37. package/dist/wasm/sheet-window-binary.d.ts +279 -0
  38. package/dist/wasm/sheet-window-binary.js +636 -0
  39. package/dist/wasm/web.d.ts +72 -0
  40. package/dist/wasm/web.js +142 -0
  41. package/generated/wasm-web/package.json +3 -0
  42. package/generated/wasm-web/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +42 -0
  43. package/generated/wasm-web/xlsx_substrate_wasm.d.ts +532 -0
  44. package/generated/wasm-web/xlsx_substrate_wasm.js +2493 -0
  45. package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm +0 -0
  46. package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm.d.ts +120 -0
  47. package/package.json +55 -3
@@ -0,0 +1,1001 @@
1
+ // Target-independent XLSX wasm bridge contract — shared verbatim by the
2
+ // Node.js loader (`index.ts`, `--target nodejs` CJS artifact) and the
3
+ // browser loader (`web.ts`, `--target web` ESM artifact). This module must
4
+ // stay free of `node:` imports and of static references to the gitignored
5
+ // `generated/` artifacts so it bundles cleanly for browser hosts and lints
6
+ // on artifact-less checkouts. Loader shells own artifact resolution and
7
+ // instantiation; everything after a raw module object exists (validation,
8
+ // wrapping, normalization) lives here.
9
+ import { AI_SESSION_AGENT_CAPABILITY, AI_SESSION_RAW_METHODS, attachAiSessionMethods } from "./ai-session-bridge.js";
10
+ import { createXlsxWasmRuntime } from "./runtime-guard.js";
11
+ import { createSheetWindowDecodedReader } from "./sheet-window-binary.js";
12
+ // R4 (runtime 0.2.0): the memory contract and the typed bridge errors.
13
+ export { createXlsxWasmRuntime, deserializeXlsxWasmBridgeError, isXlsxWasmBridgeError, serializeXlsxWasmBridgeError, XlsxWasmBridgeError } from "./runtime-guard.js";
14
+ export { estimateXlsxPackageMemory, readWasmMemoryLimits, XLSX_WASM_LINEAR_MEMORY_MAXIMUM_BYTES } from "./memory-budget.js";
15
+ /** Every runtime-session-mutations-v1 method name, used by feature detection. */
16
+ const RUNTIME_SESSION_MUTATION_METHODS = [
17
+ "commitCellFormulaInSession",
18
+ "commitRangeClearInSession",
19
+ "recalculateInSession",
20
+ "exportRuntimeSessionBytes",
21
+ "commitRangeFillInSession",
22
+ "commitRangePasteInSession",
23
+ "commitRangeTransferInSession",
24
+ "commitRangeFormatInSession",
25
+ "resizeColumnWidthInSession",
26
+ "resizeRowHeightInSession",
27
+ "setColumnHiddenInSession",
28
+ "setRowHiddenInSession",
29
+ "setFrozenPaneInSession",
30
+ "mergeCellsInSession",
31
+ "mutateSheetStructureInSession",
32
+ "mutateSheetTabsInSession",
33
+ "commitTableAppendRowInSession",
34
+ "commitShiftCellsInSession",
35
+ // UX-P-102 P2a (v42).
36
+ "commitSelectionSetPasteInSession",
37
+ "commitSelectionSetClearInSession",
38
+ "commitSelectionSetFormatInSession",
39
+ "commitRangeHyperlinkInSession",
40
+ "commitRangeDataValidationInSession",
41
+ "commitReviewCommentInSession",
42
+ // UX-P-102 P2b (v43).
43
+ "commitApplyFilterInSession",
44
+ "commitClearFilterInSession",
45
+ "commitApplySortInSession",
46
+ "setRowOutlineGroupHiddenInSession",
47
+ "setColumnOutlineGroupHiddenInSession",
48
+ "setSheetOutlineLevelInSession",
49
+ // X5-U-023 (v44).
50
+ "defineNameInSession"
51
+ ];
52
+ /**
53
+ * T1 feature detection: true when the mounted wasm build advertises
54
+ * `runtime-session-mutations-v1` AND the session-mutation methods were
55
+ * attached from the raw module object. Older wasm builds fail this check and
56
+ * callers must stay on the byte-based mutation surface (see
57
+ * `createXlsxWorkbookMutationRouter` for the routing/fallback seam).
58
+ */
59
+ /**
60
+ * The capabilities in `required` that `bridge` does not advertise. Hosts gate
61
+ * on the capabilities they call instead of pinning a bridge version, which
62
+ * changes whenever the native contract grows.
63
+ */
64
+ export function missingXlsxWasmCapabilities(bridge, required) {
65
+ const available = bridge.status.capabilities;
66
+ return required.filter((capability) => !available.includes(capability));
67
+ }
68
+ export function supportsRuntimeSessionMutations(bridge) {
69
+ return (bridge.status.capabilities.includes("runtime-session-mutations-v1") &&
70
+ RUNTIME_SESSION_MUTATION_METHODS.every((method) => typeof bridge[method] === "function"));
71
+ }
72
+ export { createSheetWindowDecodedReader, decodeSheetWindowBinary, SHEET_WINDOW_BINARY_SCHEMA_ID } from "./sheet-window-binary.js";
73
+ const requiredBridgeVersion = "xlsx-wasm-bridge-v46"; // v46: X5-U-083 (table-append empty cell; v45 was WP-DOC-T-O)
74
+ const requiredCapabilities = [
75
+ "workflow-context-v2",
76
+ "workflow-overlay-lanes-v1",
77
+ "sheet-window-paint-geometry-v1",
78
+ "sheet-window-coordinate-posture-v1",
79
+ "formula-diagnostics-v2",
80
+ "formula-address-commit-v1",
81
+ "formula-recalculate-commit-v1",
82
+ "formula-recalculate-volatile-inputs-v1",
83
+ "formula-translation-interaction-v1",
84
+ "kernel-ui-v1",
85
+ "runtime-session-handles-v1",
86
+ "staged-open-v1",
87
+ "sheet-window-cache-v1",
88
+ "readback-envelope-v1",
89
+ "preserve-only-entities-v1",
90
+ "selection-set-v1",
91
+ "range-fill-commit-v1",
92
+ "range-paste-commit-v1",
93
+ "range-clear-commit-v1",
94
+ "range-format-commit-v1",
95
+ "range-transfer-v1",
96
+ "layout-metric-resize-v1",
97
+ "layout-metric-visibility-v1",
98
+ "outline-group-visibility-v1",
99
+ "sheet-structure-v1",
100
+ "sheet-tabs-v1",
101
+ "table-mutation-v1",
102
+ "operation-pattern-hints-v1",
103
+ "ai-compressed-bundles-v1",
104
+ "ui-capability-records-v1",
105
+ "drawing-media-v1",
106
+ "drawing-chart-v1",
107
+ "frozen-pane-v1",
108
+ // X5-U-037 merge/unmerge cells authoring.
109
+ "merge-cells-v1",
110
+ // UX-P-104: the mounted grid sizes its scroll surface from `sheetExtent`,
111
+ // so a bridge that cannot supply it fails the mount gate rather than
112
+ // silently falling back to the estimate.
113
+ "sheet-window-extent-v1",
114
+ // X5-U-028: the selection readback carries anchor/head and the read echoes
115
+ // a validated `selectionCursor`. A bridge without it would accept the extra
116
+ // argument, drop it, and hand the host a readback whose missing anchor
117
+ // sends every Shift+Arrow from the wrong corner — so it fails the mount
118
+ // gate instead.
119
+ "selection-cursor-v1",
120
+ // X5-U-006 insert/delete cells with shift (bridge v26).
121
+ "shift-cells-v1",
122
+ // X5-U-025: the selection-set readback carries the set's capability record
123
+ // set (`capabilities`) and typed set-level blockers, and row/column/sheet
124
+ // handles are range write targets. A bridge without it answers a multi-area
125
+ // read with no records, so the host index would fail closed on every verb
126
+ // for every Ctrl+click selection — it fails the mount gate instead
127
+ // (bridge v27).
128
+ "selection-set-capabilities-v1",
129
+ // X5-U-038 (bridge v34): `findInRuntimeSession` and the `edit.find` /
130
+ // `edit.replace` records. A bridge without it would answer Ctrl+F with
131
+ // `not a function` and grey the Find unit as record-missing, so it fails
132
+ // the mount gate instead.
133
+ "find-v1",
134
+ // X5-U-023 (bridge v35): `goToInRuntimeSession`. A bridge without it would
135
+ // answer Enter in the name box with `not a function`, so it fails the
136
+ // mount gate instead.
137
+ "go-to-v1",
138
+ // X3-R-012 (bridge v40): `dataRegionInRuntimeSession`. A bridge without it
139
+ // would answer Ctrl+Down with `not a function`, so it fails the mount gate
140
+ // instead.
141
+ "data-region-v1",
142
+ // XB5: the AI session lane is all-or-nothing per build (Q8). A bridge
143
+ // without it would answer every fenced AI call with `not a function`, so
144
+ // it fails the mount gate instead.
145
+ AI_SESSION_AGENT_CAPABILITY
146
+ ];
147
+ /**
148
+ * R5: the bridge version this package mounts. A host reports it with
149
+ * `generatedWasmModuleSha256()`; the package version policy (README, the
150
+ * package.json `conductor` field) moves the MINOR version whenever the
151
+ * published value of this constant changes.
152
+ */
153
+ export const BRIDGE_VERSION = requiredBridgeVersion;
154
+ /**
155
+ * R5: the capabilities every mounted bridge advertises (the mount gate's
156
+ * list). Hosts gate on the capabilities they call; see
157
+ * `missingXlsxWasmCapabilities`.
158
+ */
159
+ export const BRIDGE_CAPABILITIES = Object.freeze([...requiredCapabilities]);
160
+ const requiredRawMethods = [
161
+ "getWasmStatus",
162
+ "openWorkbookRuntimeSession",
163
+ "disposeWorkbookRuntimeSession",
164
+ "inspectWorkbookRuntimeSession",
165
+ "listRuntimeSessionScopes",
166
+ "readRuntimeSessionCompressedContext",
167
+ "readRuntimeSessionCompressedDrilldown",
168
+ "explainRuntimeSessionFormula",
169
+ "bindUiRuntimeSession",
170
+ "readRuntimeSessionSelection",
171
+ "readRuntimeSessionSelectionSet",
172
+ "summarizeRuntimeSessionAccessibility",
173
+ "findInRuntimeSession",
174
+ "goToInRuntimeSession",
175
+ "dataRegionInRuntimeSession",
176
+ "readRuntimeSessionSheetWindow",
177
+ "readRuntimeSessionOverlayLanes",
178
+ "readRuntimeSessionKernelPanel",
179
+ "readRuntimeSessionMediaBytes",
180
+ "readRuntimeSessionChartBytes",
181
+ "inspectWorkbook",
182
+ "readPreserveOnlyEntities",
183
+ "readRuntimeSessionPreserveOnlyEntities",
184
+ "listScopes",
185
+ "readCompressedContext",
186
+ "readCompressedDrilldown",
187
+ "resolveReference",
188
+ "explainFormula",
189
+ "bindUiSession",
190
+ "classifyUiState",
191
+ "projectViewportHint",
192
+ "readSelection",
193
+ "readSelectionSet",
194
+ "summarizeAccessibility",
195
+ "readSheetWindow",
196
+ "readWorkflowOverlayLanes",
197
+ "readKernelPanel",
198
+ "validateKernelAction",
199
+ "createKernelBinding",
200
+ "updateKernelSource",
201
+ "startKernelRun",
202
+ "completeKernelRun",
203
+ "cancelKernelRun",
204
+ "detachKernelOutput",
205
+ "deleteKernelBinding",
206
+ "commitCellFormula",
207
+ "recalculateFormulas",
208
+ "commitRangeFill",
209
+ "commitRangePaste",
210
+ "commitRangeTransfer",
211
+ "commitRangeClear",
212
+ "commitRangeFormat",
213
+ "commitRangeHyperlink",
214
+ "commitRangeDataValidation",
215
+ "commitReviewComment",
216
+ "commitSelectionSetPaste",
217
+ "commitSelectionSetClear",
218
+ "commitSelectionSetFormat",
219
+ "resizeColumnWidth",
220
+ "resizeRowHeight",
221
+ "setColumnHidden",
222
+ "setRowHidden",
223
+ "setFrozenPane",
224
+ "mergeCells",
225
+ "setColumnOutlineGroupHidden",
226
+ "setRowOutlineGroupHidden",
227
+ "setSheetOutlineLevel",
228
+ "mutateSheetStructure",
229
+ "commitTableAppendRow",
230
+ "commitApplyFilter",
231
+ "commitClearFilter",
232
+ "commitApplySort",
233
+ "mutateSheetTabs",
234
+ "commitShiftCells",
235
+ // X5-U-023 (bridge v44): defined-name authoring over bytes.
236
+ "defineName",
237
+ // XB5 (§5.5 under Q8's fold): the AI lane's ONE raw export, declared once
238
+ // in ai-session-bridge.ts and spread here so the mount gate and the pool
239
+ // allowlists read one declaration (the eight verbs are its `op` values).
240
+ ...AI_SESSION_RAW_METHODS
241
+ ];
242
+ /**
243
+ * Target-independent mount gate: role, bridge version, required
244
+ * capabilities, and required raw methods. Both the Node.js loader
245
+ * (`loadGeneratedXlsxWasmBridge`) and the browser loader
246
+ * (`loadXlsxWasmBridgeWeb`) run this exact check so the two artifacts can
247
+ * never mount divergent contracts.
248
+ */
249
+ export function validateRawXlsxWasmModule(raw) {
250
+ const status = raw.getWasmStatus();
251
+ if (status.role !== "wasm-ai-ui-runtime-binding") {
252
+ return {
253
+ ok: false,
254
+ reason: `generated WASM role ${status.role} is stale; run build:wasm`,
255
+ requiredModeMessage: `generated WASM role ${status.role} does not match current bridge`
256
+ };
257
+ }
258
+ if (status.bridgeVersion !== requiredBridgeVersion) {
259
+ return {
260
+ ok: false,
261
+ reason: `generated WASM bridge version ${String(status.bridgeVersion)} is stale; run build:wasm`,
262
+ requiredModeMessage: `generated WASM bridge version ${String(status.bridgeVersion)} does not match ${requiredBridgeVersion}`
263
+ };
264
+ }
265
+ const missingCapability = requiredCapabilities.find((capability) => !status.capabilities?.includes(capability));
266
+ if (missingCapability) {
267
+ const message = `generated WASM capability ${missingCapability} is absent; run build:wasm`;
268
+ return { ok: false, reason: message, requiredModeMessage: message };
269
+ }
270
+ const missingMethod = requiredRawMethods.find((method) => typeof raw[method] !== "function");
271
+ if (missingMethod) {
272
+ const message = `generated WASM method ${missingMethod} is absent; run build:wasm`;
273
+ return { ok: false, reason: message, requiredModeMessage: message };
274
+ }
275
+ return { ok: true, status };
276
+ }
277
+ /**
278
+ * Wrap a raw wasm module object in the typed bridge. Every call goes through
279
+ * `runtime` (R4): pre-admission against the memory budget before open and
280
+ * recalculate, and trap containment at the call boundary. Without a runtime
281
+ * the bridge builds one over `source` that can contain a trap but has no
282
+ * Module to re-instantiate from (the loaders always pass one that can).
283
+ */
284
+ export function createXlsxWasmBridge(source, status, runtime = createXlsxWasmRuntime({ instance: { raw: source } })) {
285
+ const raw = runtime.raw;
286
+ const bridgeStatus = status ?? raw.getWasmStatus();
287
+ // T1 feature detection: session-mutation exports are optional on the raw
288
+ // wasm module object so older generated builds keep mounting with the
289
+ // byte-based surface only. Capture the raw functions once so the closures
290
+ // below stay narrowed.
291
+ const rawCommitCellFormulaInSession = typeof raw.commitCellFormulaInSession === "function" ? raw.commitCellFormulaInSession.bind(raw) : undefined;
292
+ const rawCommitRangeClearInSession = typeof raw.commitRangeClearInSession === "function" ? raw.commitRangeClearInSession.bind(raw) : undefined;
293
+ const rawRecalculateInSession = typeof raw.recalculateInSession === "function" ? raw.recalculateInSession.bind(raw) : undefined;
294
+ const rawExportRuntimeSessionBytes = typeof raw.exportRuntimeSessionBytes === "function" ? raw.exportRuntimeSessionBytes.bind(raw) : undefined;
295
+ const rawCommitRangeFillInSession = typeof raw.commitRangeFillInSession === "function" ? raw.commitRangeFillInSession.bind(raw) : undefined;
296
+ const rawCommitRangePasteInSession = typeof raw.commitRangePasteInSession === "function" ? raw.commitRangePasteInSession.bind(raw) : undefined;
297
+ const rawCommitRangeTransferInSession = typeof raw.commitRangeTransferInSession === "function" ? raw.commitRangeTransferInSession.bind(raw) : undefined;
298
+ const rawCommitRangeFormatInSession = typeof raw.commitRangeFormatInSession === "function" ? raw.commitRangeFormatInSession.bind(raw) : undefined;
299
+ const rawResizeColumnWidthInSession = typeof raw.resizeColumnWidthInSession === "function" ? raw.resizeColumnWidthInSession.bind(raw) : undefined;
300
+ const rawResizeRowHeightInSession = typeof raw.resizeRowHeightInSession === "function" ? raw.resizeRowHeightInSession.bind(raw) : undefined;
301
+ const rawSetColumnHiddenInSession = typeof raw.setColumnHiddenInSession === "function" ? raw.setColumnHiddenInSession.bind(raw) : undefined;
302
+ const rawSetRowHiddenInSession = typeof raw.setRowHiddenInSession === "function" ? raw.setRowHiddenInSession.bind(raw) : undefined;
303
+ const rawSetFrozenPaneInSession = typeof raw.setFrozenPaneInSession === "function" ? raw.setFrozenPaneInSession.bind(raw) : undefined;
304
+ const rawMergeCellsInSession = typeof raw.mergeCellsInSession === "function" ? raw.mergeCellsInSession.bind(raw) : undefined;
305
+ const rawMutateSheetStructureInSession = typeof raw.mutateSheetStructureInSession === "function" ? raw.mutateSheetStructureInSession.bind(raw) : undefined;
306
+ const rawMutateSheetTabsInSession = typeof raw.mutateSheetTabsInSession === "function" ? raw.mutateSheetTabsInSession.bind(raw) : undefined;
307
+ const rawCommitTableAppendRowInSession = typeof raw.commitTableAppendRowInSession === "function" ? raw.commitTableAppendRowInSession.bind(raw) : undefined;
308
+ const rawCommitShiftCellsInSession = typeof raw.commitShiftCellsInSession === "function" ? raw.commitShiftCellsInSession.bind(raw) : undefined;
309
+ // UX-P-102 P2a (v42): the six families that had only a bytes export.
310
+ const rawCommitSelectionSetPasteInSession = typeof raw.commitSelectionSetPasteInSession === "function" ? raw.commitSelectionSetPasteInSession.bind(raw) : undefined;
311
+ const rawCommitSelectionSetClearInSession = typeof raw.commitSelectionSetClearInSession === "function" ? raw.commitSelectionSetClearInSession.bind(raw) : undefined;
312
+ const rawCommitSelectionSetFormatInSession = typeof raw.commitSelectionSetFormatInSession === "function" ? raw.commitSelectionSetFormatInSession.bind(raw) : undefined;
313
+ const rawCommitRangeHyperlinkInSession = typeof raw.commitRangeHyperlinkInSession === "function" ? raw.commitRangeHyperlinkInSession.bind(raw) : undefined;
314
+ const rawCommitRangeDataValidationInSession = typeof raw.commitRangeDataValidationInSession === "function"
315
+ ? raw.commitRangeDataValidationInSession.bind(raw)
316
+ : undefined;
317
+ const rawCommitReviewCommentInSession = typeof raw.commitReviewCommentInSession === "function" ? raw.commitReviewCommentInSession.bind(raw) : undefined;
318
+ // UX-P-102 P2b (v43): the last six bytes-only families.
319
+ const rawCommitApplyFilterInSession = typeof raw.commitApplyFilterInSession === "function" ? raw.commitApplyFilterInSession.bind(raw) : undefined;
320
+ const rawCommitClearFilterInSession = typeof raw.commitClearFilterInSession === "function" ? raw.commitClearFilterInSession.bind(raw) : undefined;
321
+ const rawCommitApplySortInSession = typeof raw.commitApplySortInSession === "function" ? raw.commitApplySortInSession.bind(raw) : undefined;
322
+ const rawSetRowOutlineGroupHiddenInSession = typeof raw.setRowOutlineGroupHiddenInSession === "function" ? raw.setRowOutlineGroupHiddenInSession.bind(raw) : undefined;
323
+ const rawSetColumnOutlineGroupHiddenInSession = typeof raw.setColumnOutlineGroupHiddenInSession === "function"
324
+ ? raw.setColumnOutlineGroupHiddenInSession.bind(raw)
325
+ : undefined;
326
+ const rawSetSheetOutlineLevelInSession = typeof raw.setSheetOutlineLevelInSession === "function" ? raw.setSheetOutlineLevelInSession.bind(raw) : undefined;
327
+ // X5-U-023 (v44): defined-name authoring.
328
+ const rawDefineNameInSession = typeof raw.defineNameInSession === "function" ? raw.defineNameInSession.bind(raw) : undefined;
329
+ // X5-U-012 feature detection: the delimited-text export is optional and
330
+ // independent of the mutation family, so it is attached on its own.
331
+ const rawExportRuntimeSessionDelimitedText = typeof raw.exportRuntimeSessionDelimitedText === "function"
332
+ ? raw.exportRuntimeSessionDelimitedText.bind(raw)
333
+ : undefined;
334
+ // T5 feature detection: the binary sheet-window export is optional on the
335
+ // raw wasm module object (older builds lack it); `readSheetWindowDecoded`
336
+ // routes through it when present and stays on JSON otherwise.
337
+ const rawReadSheetWindowBinary = typeof raw.readRuntimeSessionSheetWindowBinary === "function"
338
+ ? raw.readRuntimeSessionSheetWindowBinary.bind(raw)
339
+ : undefined;
340
+ // T5 decoded seam with the permanent-JSON-fallback latch. The factory
341
+ // covers BOTH eager decode throws and lazy section-getter failures at
342
+ // consumer access time (routed back via onSectionDecodeError) — see
343
+ // createSheetWindowDecodedReader in sheet-window-binary.ts.
344
+ const readSheetWindowDecodedImpl = createSheetWindowDecodedReader({
345
+ readBinary: rawReadSheetWindowBinary
346
+ ? (handleId, viewportHint, activeHandle, workflowContext) => normalizeSheetWindowBinaryEnvelope(rawReadSheetWindowBinary(handleId, viewportHint, activeHandle, workflowContext))
347
+ : undefined,
348
+ readJson: (handleId, viewportHint, activeHandle, workflowContext) => raw.readRuntimeSessionSheetWindow(handleId, viewportHint, activeHandle, workflowContext)
349
+ });
350
+ const sessionMutationMethods = rawCommitCellFormulaInSession && rawCommitRangeClearInSession && rawRecalculateInSession &&
351
+ rawExportRuntimeSessionBytes && rawCommitRangeFillInSession && rawCommitRangePasteInSession &&
352
+ rawCommitRangeTransferInSession && rawCommitRangeFormatInSession && rawResizeColumnWidthInSession &&
353
+ rawResizeRowHeightInSession && rawSetColumnHiddenInSession && rawSetRowHiddenInSession &&
354
+ rawSetFrozenPaneInSession && rawMergeCellsInSession &&
355
+ rawMutateSheetStructureInSession && rawMutateSheetTabsInSession && rawCommitTableAppendRowInSession &&
356
+ rawCommitShiftCellsInSession && rawCommitSelectionSetPasteInSession && rawCommitSelectionSetClearInSession &&
357
+ rawCommitSelectionSetFormatInSession && rawCommitRangeHyperlinkInSession &&
358
+ rawCommitRangeDataValidationInSession && rawCommitReviewCommentInSession && rawCommitApplyFilterInSession &&
359
+ rawCommitClearFilterInSession && rawCommitApplySortInSession && rawSetRowOutlineGroupHiddenInSession &&
360
+ rawSetColumnOutlineGroupHiddenInSession && rawSetSheetOutlineLevelInSession && rawDefineNameInSession
361
+ ? {
362
+ commitCellFormulaInSession(handleId, request) {
363
+ return normalizeFormulaCommitResult(rawCommitCellFormulaInSession(handleId, request));
364
+ },
365
+ commitRangeClearInSession(handleId, request) {
366
+ return normalizeRangeClearCommitResult(rawCommitRangeClearInSession(handleId, request));
367
+ },
368
+ recalculateInSession(handleId, request = {}) {
369
+ return normalizeFormulaRecalculateResult(rawRecalculateInSession(handleId, request));
370
+ },
371
+ exportRuntimeSessionBytes(handleId, request = {}) {
372
+ return normalizeRuntimeSessionExportResult(rawExportRuntimeSessionBytes(handleId, request));
373
+ },
374
+ commitRangeFillInSession(handleId, request) {
375
+ return normalizeRangeFillCommitResult(rawCommitRangeFillInSession(handleId, request));
376
+ },
377
+ commitRangePasteInSession(handleId, request) {
378
+ return normalizeRangePasteCommitResult(rawCommitRangePasteInSession(handleId, request));
379
+ },
380
+ commitRangeTransferInSession(handleId, request) {
381
+ return normalizeRangeTransferCommitResult(rawCommitRangeTransferInSession(handleId, request));
382
+ },
383
+ commitRangeFormatInSession(handleId, request) {
384
+ return normalizeRangeFormatCommitResult(rawCommitRangeFormatInSession(handleId, request));
385
+ },
386
+ resizeColumnWidthInSession(handleId, request) {
387
+ return normalizeLayoutMetricResizeResult(rawResizeColumnWidthInSession(handleId, request));
388
+ },
389
+ resizeRowHeightInSession(handleId, request) {
390
+ return normalizeLayoutMetricResizeResult(rawResizeRowHeightInSession(handleId, request));
391
+ },
392
+ setColumnHiddenInSession(handleId, request) {
393
+ return normalizeLayoutMetricVisibilityResult(rawSetColumnHiddenInSession(handleId, request));
394
+ },
395
+ setRowHiddenInSession(handleId, request) {
396
+ return normalizeLayoutMetricVisibilityResult(rawSetRowHiddenInSession(handleId, request));
397
+ },
398
+ setFrozenPaneInSession(handleId, request) {
399
+ return normalizeFrozenPaneResult(rawSetFrozenPaneInSession(handleId, request));
400
+ },
401
+ mergeCellsInSession(handleId, request) {
402
+ return normalizeMergeCellsResult(rawMergeCellsInSession(handleId, request));
403
+ },
404
+ mutateSheetStructureInSession(handleId, request) {
405
+ return normalizeSheetStructureMutationResult(rawMutateSheetStructureInSession(handleId, request));
406
+ },
407
+ mutateSheetTabsInSession(handleId, request) {
408
+ return normalizeSheetTabMutationResult(rawMutateSheetTabsInSession(handleId, request));
409
+ },
410
+ commitTableAppendRowInSession(handleId, request) {
411
+ return normalizeTableAppendRowResult(rawCommitTableAppendRowInSession(handleId, request));
412
+ },
413
+ commitShiftCellsInSession(handleId, request) {
414
+ return normalizeShiftCellsCommitResult(rawCommitShiftCellsInSession(handleId, request));
415
+ },
416
+ commitSelectionSetPasteInSession(handleId, request) {
417
+ return normalizeRangePasteCommitResult(rawCommitSelectionSetPasteInSession(handleId, request));
418
+ },
419
+ commitSelectionSetClearInSession(handleId, request) {
420
+ return normalizeRangeClearCommitResult(rawCommitSelectionSetClearInSession(handleId, request));
421
+ },
422
+ commitSelectionSetFormatInSession(handleId, request) {
423
+ return normalizeRangeFormatCommitResult(rawCommitSelectionSetFormatInSession(handleId, request));
424
+ },
425
+ commitRangeHyperlinkInSession(handleId, request) {
426
+ return normalizeRangeHyperlinkCommitResult(rawCommitRangeHyperlinkInSession(handleId, request));
427
+ },
428
+ commitRangeDataValidationInSession(handleId, request) {
429
+ return normalizeRangeDataValidationCommitResult(rawCommitRangeDataValidationInSession(handleId, request));
430
+ },
431
+ commitReviewCommentInSession(handleId, request) {
432
+ return normalizeReviewCommentCommitResult(rawCommitReviewCommentInSession(handleId, request));
433
+ },
434
+ commitApplyFilterInSession(handleId, request) {
435
+ return normalizeRangeFilterResult(rawCommitApplyFilterInSession(handleId, request));
436
+ },
437
+ commitClearFilterInSession(handleId, request) {
438
+ return normalizeRangeFilterResult(rawCommitClearFilterInSession(handleId, request));
439
+ },
440
+ commitApplySortInSession(handleId, request) {
441
+ return normalizeRangeSortResult(rawCommitApplySortInSession(handleId, request));
442
+ },
443
+ setRowOutlineGroupHiddenInSession(handleId, request) {
444
+ return normalizeOutlineGroupVisibilityResult(rawSetRowOutlineGroupHiddenInSession(handleId, request));
445
+ },
446
+ setColumnOutlineGroupHiddenInSession(handleId, request) {
447
+ return normalizeOutlineGroupVisibilityResult(rawSetColumnOutlineGroupHiddenInSession(handleId, request));
448
+ },
449
+ setSheetOutlineLevelInSession(handleId, request) {
450
+ return normalizeOutlineLevelResult(rawSetSheetOutlineLevelInSession(handleId, request));
451
+ },
452
+ defineNameInSession(handleId, request) {
453
+ return normalizeDefinedNameMutationResult(rawDefineNameInSession(handleId, request));
454
+ }
455
+ }
456
+ : undefined;
457
+ return {
458
+ status: bridgeStatus,
459
+ wasmMemoryBytes() {
460
+ return runtime.wasmMemoryBytes();
461
+ },
462
+ highWater(bytes) {
463
+ return runtime.highWater(bytes);
464
+ },
465
+ ...(sessionMutationMethods ?? {}),
466
+ // XB5: the eight typed AI methods, each dispatching to the one required
467
+ // raw export `aiSessionCall` with its verb.
468
+ ...attachAiSessionMethods(raw),
469
+ openWorkbookRuntimeSession(bytes, request = {}) {
470
+ return raw.openWorkbookRuntimeSession(bytes, request);
471
+ },
472
+ disposeWorkbookRuntimeSession(handleId) {
473
+ return raw.disposeWorkbookRuntimeSession(handleId);
474
+ },
475
+ inspectWorkbookRuntimeSession(handleId) {
476
+ return raw.inspectWorkbookRuntimeSession(handleId);
477
+ },
478
+ listRuntimeSessionScopes(handleId, request = {}) {
479
+ return raw.listRuntimeSessionScopes(handleId, request);
480
+ },
481
+ readRuntimeSessionCompressedContext(handleId, request = {}) {
482
+ return raw.readRuntimeSessionCompressedContext(handleId, request);
483
+ },
484
+ readRuntimeSessionCompressedDrilldown(handleId, request) {
485
+ return raw.readRuntimeSessionCompressedDrilldown(handleId, request);
486
+ },
487
+ explainRuntimeSessionFormula(handleId, target) {
488
+ return raw.explainRuntimeSessionFormula(handleId, target);
489
+ },
490
+ bindUiRuntimeSession(handleId, requestedActiveSheetId) {
491
+ return raw.bindUiRuntimeSession(handleId, requestedActiveSheetId);
492
+ },
493
+ readRuntimeSessionSelection(handleId, handle, viewportHint, workflowContext, selectionCursor) {
494
+ return raw.readRuntimeSessionSelection(handleId, handle, viewportHint, workflowContext, selectionCursor);
495
+ },
496
+ readRuntimeSessionSelectionSet(handleId, request) {
497
+ return raw.readRuntimeSessionSelectionSet(handleId, request);
498
+ },
499
+ summarizeRuntimeSessionAccessibility(handleId, handle, viewportHint, workflowContext) {
500
+ return raw.summarizeRuntimeSessionAccessibility(handleId, handle, viewportHint, workflowContext);
501
+ },
502
+ findInRuntimeSession(handleId, request) {
503
+ return raw.findInRuntimeSession(handleId, request);
504
+ },
505
+ goToInRuntimeSession(handleId, request) {
506
+ return raw.goToInRuntimeSession(handleId, request);
507
+ },
508
+ dataRegionInRuntimeSession(handleId, request) {
509
+ return raw.dataRegionInRuntimeSession(handleId, request);
510
+ },
511
+ readRuntimeSessionSheetWindow(handleId, viewportHint, activeHandle, workflowContext) {
512
+ return raw.readRuntimeSessionSheetWindow(handleId, viewportHint, activeHandle, workflowContext);
513
+ },
514
+ ...(rawReadSheetWindowBinary
515
+ ? {
516
+ readRuntimeSessionSheetWindowBinary(handleId, viewportHint, activeHandle, workflowContext) {
517
+ return normalizeSheetWindowBinaryEnvelope(rawReadSheetWindowBinary(handleId, viewportHint, activeHandle, workflowContext));
518
+ }
519
+ }
520
+ : {}),
521
+ ...(rawExportRuntimeSessionDelimitedText
522
+ ? {
523
+ exportRuntimeSessionDelimitedText(handleId, request = {}) {
524
+ return rawExportRuntimeSessionDelimitedText(handleId, request);
525
+ }
526
+ }
527
+ : {}),
528
+ readSheetWindowDecoded(handleId, viewportHint, activeHandle, workflowContext) {
529
+ // T5 feature detection: binary export + decode when the wasm build
530
+ // carries it; the JSON export otherwise. Any decode failure — eager
531
+ // header validation OR lazy section decode at consumer access — logs
532
+ // once and permanently falls back to JSON for this bridge instance;
533
+ // defensive only (the differential parity test guards the layout).
534
+ return readSheetWindowDecodedImpl(handleId, viewportHint, activeHandle, workflowContext);
535
+ },
536
+ readRuntimeSessionOverlayLanes(handleId, request = {}) {
537
+ return raw.readRuntimeSessionOverlayLanes(handleId, request);
538
+ },
539
+ readRuntimeSessionKernelPanel(handleId, workflowContext) {
540
+ return raw.readRuntimeSessionKernelPanel(handleId, workflowContext);
541
+ },
542
+ readRuntimeSessionMediaBytes(handleId, mediaId) {
543
+ return normalizeMediaBytesReadback(raw.readRuntimeSessionMediaBytes(handleId, mediaId));
544
+ },
545
+ readRuntimeSessionChartBytes(handleId, chartId) {
546
+ return raw.readRuntimeSessionChartBytes(handleId, chartId);
547
+ },
548
+ inspectWorkbook(bytes, sourceLabel) {
549
+ return raw.inspectWorkbook(bytes, sourceLabel);
550
+ },
551
+ readPreserveOnlyEntities(bytes, sourceLabel) {
552
+ return raw.readPreserveOnlyEntities(bytes, sourceLabel);
553
+ },
554
+ readRuntimeSessionPreserveOnlyEntities(handleId) {
555
+ return raw.readRuntimeSessionPreserveOnlyEntities(handleId);
556
+ },
557
+ listScopes(bytes, request = {}) {
558
+ return raw.listScopes(bytes, request);
559
+ },
560
+ readCompressedContext(bytes, request = {}) {
561
+ return raw.readCompressedContext(bytes, request);
562
+ },
563
+ readCompressedDrilldown(bytes, request) {
564
+ return raw.readCompressedDrilldown(bytes, request);
565
+ },
566
+ resolveReference(bytes, query) {
567
+ return raw.resolveReference(bytes, query);
568
+ },
569
+ explainFormula(bytes, target) {
570
+ return raw.explainFormula(bytes, target);
571
+ },
572
+ bindUiSession(bytes, requestedActiveSheetId) {
573
+ return raw.bindUiSession(bytes, requestedActiveSheetId);
574
+ },
575
+ classifyUiState(namespace) {
576
+ return raw.classifyUiState(namespace);
577
+ },
578
+ projectViewportHint(bytes, hint) {
579
+ return raw.projectViewportHint(bytes, hint);
580
+ },
581
+ readSelection(bytes, handle, viewportHint, workflowContext, selectionCursor) {
582
+ return raw.readSelection(bytes, handle, viewportHint, workflowContext, selectionCursor);
583
+ },
584
+ readSelectionSet(bytes, request) {
585
+ return raw.readSelectionSet(bytes, request);
586
+ },
587
+ summarizeAccessibility(bytes, handle, viewportHint, workflowContext) {
588
+ return raw.summarizeAccessibility(bytes, handle, viewportHint, workflowContext);
589
+ },
590
+ readSheetWindow(bytes, viewportHint, activeHandle, workflowContext) {
591
+ return raw.readSheetWindow(bytes, viewportHint, activeHandle, workflowContext);
592
+ },
593
+ readWorkflowOverlayLanes(bytes, request = {}) {
594
+ return raw.readWorkflowOverlayLanes(bytes, request);
595
+ },
596
+ readKernelPanel(bytes, workflowContext) {
597
+ return raw.readKernelPanel(bytes, workflowContext);
598
+ },
599
+ validateKernelAction(bytes, request) {
600
+ return raw.validateKernelAction(bytes, request);
601
+ },
602
+ createKernelBinding(bytes, request) {
603
+ return normalizeKernelMutationResult(raw.createKernelBinding(bytes, request));
604
+ },
605
+ updateKernelSource(bytes, request) {
606
+ return normalizeKernelMutationResult(raw.updateKernelSource(bytes, request));
607
+ },
608
+ startKernelRun(bytes, request) {
609
+ return normalizeKernelMutationResult(raw.startKernelRun(bytes, request));
610
+ },
611
+ completeKernelRun(bytes, request) {
612
+ return normalizeKernelMutationResult(raw.completeKernelRun(bytes, request));
613
+ },
614
+ cancelKernelRun(bytes, request) {
615
+ return normalizeKernelMutationResult(raw.cancelKernelRun(bytes, request));
616
+ },
617
+ detachKernelOutput(bytes, request) {
618
+ return normalizeKernelMutationResult(raw.detachKernelOutput(bytes, request));
619
+ },
620
+ deleteKernelBinding(bytes, request) {
621
+ return normalizeKernelMutationResult(raw.deleteKernelBinding(bytes, request));
622
+ },
623
+ commitCellFormula(bytes, request) {
624
+ return normalizeFormulaCommitResult(raw.commitCellFormula(bytes, request));
625
+ },
626
+ recalculateFormulas(bytes, request = {}) {
627
+ return normalizeFormulaRecalculateResult(raw.recalculateFormulas(bytes, request));
628
+ },
629
+ commitRangeFill(bytes, request) {
630
+ return normalizeRangeFillCommitResult(raw.commitRangeFill(bytes, request));
631
+ },
632
+ commitRangePaste(bytes, request) {
633
+ return normalizeRangePasteCommitResult(raw.commitRangePaste(bytes, request));
634
+ },
635
+ commitRangeTransfer(bytes, request) {
636
+ return normalizeRangeTransferCommitResult(raw.commitRangeTransfer(bytes, request));
637
+ },
638
+ commitRangeClear(bytes, request) {
639
+ return normalizeRangeClearCommitResult(raw.commitRangeClear(bytes, request));
640
+ },
641
+ commitRangeFormat(bytes, request) {
642
+ return normalizeRangeFormatCommitResult(raw.commitRangeFormat(bytes, request));
643
+ },
644
+ commitRangeHyperlink(bytes, request) {
645
+ return normalizeRangeHyperlinkCommitResult(raw.commitRangeHyperlink(bytes, request));
646
+ },
647
+ commitRangeDataValidation(bytes, request) {
648
+ return normalizeRangeDataValidationCommitResult(raw.commitRangeDataValidation(bytes, request));
649
+ },
650
+ commitReviewComment(bytes, request) {
651
+ return normalizeReviewCommentCommitResult(raw.commitReviewComment(bytes, request));
652
+ },
653
+ commitSelectionSetPaste(bytes, request) {
654
+ return normalizeRangePasteCommitResult(raw.commitSelectionSetPaste(bytes, request));
655
+ },
656
+ commitSelectionSetClear(bytes, request) {
657
+ return normalizeRangeClearCommitResult(raw.commitSelectionSetClear(bytes, request));
658
+ },
659
+ commitSelectionSetFormat(bytes, request) {
660
+ return normalizeRangeFormatCommitResult(raw.commitSelectionSetFormat(bytes, request));
661
+ },
662
+ resizeColumnWidth(bytes, request) {
663
+ return normalizeLayoutMetricResizeResult(raw.resizeColumnWidth(bytes, request));
664
+ },
665
+ resizeRowHeight(bytes, request) {
666
+ return normalizeLayoutMetricResizeResult(raw.resizeRowHeight(bytes, request));
667
+ },
668
+ setColumnHidden(bytes, request) {
669
+ return normalizeLayoutMetricVisibilityResult(raw.setColumnHidden(bytes, request));
670
+ },
671
+ setRowHidden(bytes, request) {
672
+ return normalizeLayoutMetricVisibilityResult(raw.setRowHidden(bytes, request));
673
+ },
674
+ setFrozenPane(bytes, request) {
675
+ return normalizeFrozenPaneResult(raw.setFrozenPane(bytes, request));
676
+ },
677
+ mergeCells(bytes, request) {
678
+ return normalizeMergeCellsResult(raw.mergeCells(bytes, request));
679
+ },
680
+ setColumnOutlineGroupHidden(bytes, request) {
681
+ return normalizeOutlineGroupVisibilityResult(raw.setColumnOutlineGroupHidden(bytes, request));
682
+ },
683
+ setRowOutlineGroupHidden(bytes, request) {
684
+ return normalizeOutlineGroupVisibilityResult(raw.setRowOutlineGroupHidden(bytes, request));
685
+ },
686
+ setSheetOutlineLevel(bytes, request) {
687
+ return normalizeOutlineLevelResult(raw.setSheetOutlineLevel(bytes, request));
688
+ },
689
+ mutateSheetStructure(bytes, request) {
690
+ return normalizeSheetStructureMutationResult(raw.mutateSheetStructure(bytes, request));
691
+ },
692
+ commitTableAppendRow(bytes, request) {
693
+ return normalizeTableAppendRowResult(raw.commitTableAppendRow(bytes, request));
694
+ },
695
+ commitApplyFilter(bytes, request) {
696
+ return normalizeRangeFilterResult(raw.commitApplyFilter(bytes, request));
697
+ },
698
+ commitClearFilter(bytes, request) {
699
+ return normalizeRangeFilterResult(raw.commitClearFilter(bytes, request));
700
+ },
701
+ commitApplySort(bytes, request) {
702
+ return normalizeRangeSortResult(raw.commitApplySort(bytes, request));
703
+ },
704
+ mutateSheetTabs(bytes, request) {
705
+ return normalizeSheetTabMutationResult(raw.mutateSheetTabs(bytes, request));
706
+ },
707
+ defineName(bytes, request) {
708
+ return normalizeDefinedNameMutationResult(raw.defineName(bytes, request));
709
+ },
710
+ commitShiftCells(bytes, request) {
711
+ return normalizeShiftCellsCommitResult(raw.commitShiftCells(bytes, request));
712
+ }
713
+ };
714
+ }
715
+ function normalizeFormulaCommitResult(result) {
716
+ const exportedBytes = result.exportedBytes
717
+ ? result.exportedBytes instanceof Uint8Array
718
+ ? result.exportedBytes
719
+ : Uint8Array.from(result.exportedBytes)
720
+ : undefined;
721
+ return {
722
+ ...result,
723
+ exportedBytes
724
+ };
725
+ }
726
+ function normalizeRuntimeSessionExportResult(result) {
727
+ const exportedBytes = result.exportedBytes
728
+ ? result.exportedBytes instanceof Uint8Array
729
+ ? result.exportedBytes
730
+ : Uint8Array.from(result.exportedBytes)
731
+ : undefined;
732
+ return {
733
+ ...result,
734
+ exportedBytes
735
+ };
736
+ }
737
+ function normalizeFormulaRecalculateResult(result) {
738
+ const exportedBytes = result.exportedBytes
739
+ ? result.exportedBytes instanceof Uint8Array
740
+ ? result.exportedBytes
741
+ : Uint8Array.from(result.exportedBytes)
742
+ : undefined;
743
+ return {
744
+ ...result,
745
+ exportedBytes
746
+ };
747
+ }
748
+ function normalizeRangeFillCommitResult(result) {
749
+ const exportedBytes = result.exportedBytes
750
+ ? result.exportedBytes instanceof Uint8Array
751
+ ? result.exportedBytes
752
+ : Uint8Array.from(result.exportedBytes)
753
+ : undefined;
754
+ return {
755
+ ...result,
756
+ exportedBytes
757
+ };
758
+ }
759
+ function normalizeRangePasteCommitResult(result) {
760
+ const exportedBytes = result.exportedBytes
761
+ ? result.exportedBytes instanceof Uint8Array
762
+ ? result.exportedBytes
763
+ : Uint8Array.from(result.exportedBytes)
764
+ : undefined;
765
+ return {
766
+ ...result,
767
+ exportedBytes
768
+ };
769
+ }
770
+ function normalizeRangeTransferCommitResult(result) {
771
+ const exportedBytes = result.exportedBytes
772
+ ? result.exportedBytes instanceof Uint8Array
773
+ ? result.exportedBytes
774
+ : Uint8Array.from(result.exportedBytes)
775
+ : undefined;
776
+ return {
777
+ ...result,
778
+ exportedBytes
779
+ };
780
+ }
781
+ function normalizeRangeClearCommitResult(result) {
782
+ const exportedBytes = result.exportedBytes
783
+ ? result.exportedBytes instanceof Uint8Array
784
+ ? result.exportedBytes
785
+ : Uint8Array.from(result.exportedBytes)
786
+ : undefined;
787
+ return {
788
+ ...result,
789
+ exportedBytes
790
+ };
791
+ }
792
+ function normalizeRangeFormatCommitResult(result) {
793
+ const exportedBytes = result.exportedBytes
794
+ ? result.exportedBytes instanceof Uint8Array
795
+ ? result.exportedBytes
796
+ : Uint8Array.from(result.exportedBytes)
797
+ : undefined;
798
+ return {
799
+ ...result,
800
+ exportedBytes
801
+ };
802
+ }
803
+ function normalizeReviewCommentCommitResult(result) {
804
+ const exportedBytes = result.exportedBytes
805
+ ? result.exportedBytes instanceof Uint8Array
806
+ ? result.exportedBytes
807
+ : Uint8Array.from(result.exportedBytes)
808
+ : undefined;
809
+ return {
810
+ ...result,
811
+ exportedBytes
812
+ };
813
+ }
814
+ function normalizeRangeDataValidationCommitResult(result) {
815
+ const exportedBytes = result.exportedBytes
816
+ ? result.exportedBytes instanceof Uint8Array
817
+ ? result.exportedBytes
818
+ : Uint8Array.from(result.exportedBytes)
819
+ : undefined;
820
+ return {
821
+ ...result,
822
+ exportedBytes
823
+ };
824
+ }
825
+ function normalizeRangeHyperlinkCommitResult(result) {
826
+ const exportedBytes = result.exportedBytes
827
+ ? result.exportedBytes instanceof Uint8Array
828
+ ? result.exportedBytes
829
+ : Uint8Array.from(result.exportedBytes)
830
+ : undefined;
831
+ return {
832
+ ...result,
833
+ exportedBytes
834
+ };
835
+ }
836
+ function normalizeLayoutMetricResizeResult(result) {
837
+ const exportedBytes = result.exportedBytes
838
+ ? result.exportedBytes instanceof Uint8Array
839
+ ? result.exportedBytes
840
+ : Uint8Array.from(result.exportedBytes)
841
+ : undefined;
842
+ return {
843
+ ...result,
844
+ exportedBytes
845
+ };
846
+ }
847
+ function normalizeLayoutMetricVisibilityResult(result) {
848
+ const exportedBytes = result.exportedBytes
849
+ ? result.exportedBytes instanceof Uint8Array
850
+ ? result.exportedBytes
851
+ : Uint8Array.from(result.exportedBytes)
852
+ : undefined;
853
+ return {
854
+ ...result,
855
+ exportedBytes
856
+ };
857
+ }
858
+ function normalizeFrozenPaneResult(result) {
859
+ const exportedBytes = result.exportedBytes
860
+ ? result.exportedBytes instanceof Uint8Array
861
+ ? result.exportedBytes
862
+ : Uint8Array.from(result.exportedBytes)
863
+ : undefined;
864
+ return {
865
+ ...result,
866
+ exportedBytes
867
+ };
868
+ }
869
+ function normalizeMergeCellsResult(result) {
870
+ const exportedBytes = result.exportedBytes
871
+ ? result.exportedBytes instanceof Uint8Array
872
+ ? result.exportedBytes
873
+ : Uint8Array.from(result.exportedBytes)
874
+ : undefined;
875
+ return {
876
+ ...result,
877
+ exportedBytes
878
+ };
879
+ }
880
+ function normalizeOutlineGroupVisibilityResult(result) {
881
+ const exportedBytes = result.exportedBytes
882
+ ? result.exportedBytes instanceof Uint8Array
883
+ ? result.exportedBytes
884
+ : Uint8Array.from(result.exportedBytes)
885
+ : undefined;
886
+ return {
887
+ ...result,
888
+ exportedBytes
889
+ };
890
+ }
891
+ function normalizeOutlineLevelResult(result) {
892
+ const exportedBytes = result.exportedBytes
893
+ ? result.exportedBytes instanceof Uint8Array
894
+ ? result.exportedBytes
895
+ : Uint8Array.from(result.exportedBytes)
896
+ : undefined;
897
+ return {
898
+ ...result,
899
+ exportedBytes
900
+ };
901
+ }
902
+ function normalizeSheetStructureMutationResult(result) {
903
+ const exportedBytes = result.exportedBytes
904
+ ? result.exportedBytes instanceof Uint8Array
905
+ ? result.exportedBytes
906
+ : Uint8Array.from(result.exportedBytes)
907
+ : undefined;
908
+ return {
909
+ ...result,
910
+ exportedBytes
911
+ };
912
+ }
913
+ function normalizeTableAppendRowResult(result) {
914
+ const exportedBytes = result.exportedBytes
915
+ ? result.exportedBytes instanceof Uint8Array
916
+ ? result.exportedBytes
917
+ : Uint8Array.from(result.exportedBytes)
918
+ : undefined;
919
+ return {
920
+ ...result,
921
+ exportedBytes
922
+ };
923
+ }
924
+ function normalizeRangeFilterResult(result) {
925
+ const exportedBytes = result.exportedBytes
926
+ ? result.exportedBytes instanceof Uint8Array
927
+ ? result.exportedBytes
928
+ : Uint8Array.from(result.exportedBytes)
929
+ : undefined;
930
+ return {
931
+ ...result,
932
+ exportedBytes
933
+ };
934
+ }
935
+ function normalizeRangeSortResult(result) {
936
+ const exportedBytes = result.exportedBytes
937
+ ? result.exportedBytes instanceof Uint8Array
938
+ ? result.exportedBytes
939
+ : Uint8Array.from(result.exportedBytes)
940
+ : undefined;
941
+ return {
942
+ ...result,
943
+ exportedBytes
944
+ };
945
+ }
946
+ function normalizeDefinedNameMutationResult(result) {
947
+ const exportedBytes = result.exportedBytes
948
+ ? result.exportedBytes instanceof Uint8Array
949
+ ? result.exportedBytes
950
+ : Uint8Array.from(result.exportedBytes)
951
+ : undefined;
952
+ return {
953
+ ...result,
954
+ exportedBytes
955
+ };
956
+ }
957
+ function normalizeSheetTabMutationResult(result) {
958
+ const exportedBytes = result.exportedBytes
959
+ ? result.exportedBytes instanceof Uint8Array
960
+ ? result.exportedBytes
961
+ : Uint8Array.from(result.exportedBytes)
962
+ : undefined;
963
+ return {
964
+ ...result,
965
+ exportedBytes
966
+ };
967
+ }
968
+ function normalizeShiftCellsCommitResult(result) {
969
+ const exportedBytes = result.exportedBytes
970
+ ? result.exportedBytes instanceof Uint8Array
971
+ ? result.exportedBytes
972
+ : Uint8Array.from(result.exportedBytes)
973
+ : undefined;
974
+ return {
975
+ ...result,
976
+ exportedBytes
977
+ };
978
+ }
979
+ function normalizeMediaBytesReadback(result) {
980
+ return {
981
+ ...result,
982
+ bytes: result.bytes instanceof Uint8Array ? result.bytes : Uint8Array.from(result.bytes)
983
+ };
984
+ }
985
+ function normalizeSheetWindowBinaryEnvelope(result) {
986
+ return {
987
+ ...result,
988
+ bytes: result.bytes instanceof Uint8Array ? result.bytes : Uint8Array.from(result.bytes)
989
+ };
990
+ }
991
+ function normalizeKernelMutationResult(result) {
992
+ const exportedBytes = result.exportedBytes
993
+ ? result.exportedBytes instanceof Uint8Array
994
+ ? result.exportedBytes
995
+ : Uint8Array.from(result.exportedBytes)
996
+ : undefined;
997
+ return {
998
+ ...result,
999
+ exportedBytes
1000
+ };
1001
+ }