@beyondwork/xlsx-substrate-bindings 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +31 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +1 -0
- package/dist/ai/types.d.ts +320 -0
- package/dist/ai/types.js +23 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +72 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/types.d.ts +1379 -0
- package/dist/runtime/types.js +15 -0
- package/dist/shared.d.ts +69 -0
- package/dist/shared.js +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/types.d.ts +765 -0
- package/dist/ui/types.js +12 -0
- package/dist/wasm/bridge-contract.d.ts +541 -0
- package/dist/wasm/bridge-contract.js +862 -0
- package/dist/wasm/chart-test-fixture.d.ts +19 -0
- package/dist/wasm/chart-test-fixture.js +42 -0
- package/dist/wasm/index.d.ts +9 -0
- package/dist/wasm/index.js +67 -0
- package/dist/wasm/media-test-fixture.d.ts +44 -0
- package/dist/wasm/media-test-fixture.js +160 -0
- package/dist/wasm/session-router.d.ts +98 -0
- package/dist/wasm/session-router.js +184 -0
- package/dist/wasm/sheet-window-binary-reference.d.ts +9 -0
- package/dist/wasm/sheet-window-binary-reference.js +308 -0
- package/dist/wasm/sheet-window-binary.d.ts +279 -0
- package/dist/wasm/sheet-window-binary.js +636 -0
- package/dist/wasm/volatile-test-fixture.d.ts +7 -0
- package/dist/wasm/volatile-test-fixture.js +35 -0
- package/dist/wasm/web.d.ts +59 -0
- package/dist/wasm/web.js +60 -0
- package/generated/wasm/package.json +3 -0
- package/generated/wasm/sheet-window-binary.mjs +482 -0
- package/generated/wasm/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +45 -0
- package/generated/wasm/xlsx_substrate_wasm.d.ts +336 -0
- package/generated/wasm/xlsx_substrate_wasm.js +2108 -0
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm.d.ts +105 -0
- package/generated/wasm-web/package.json +3 -0
- package/generated/wasm-web/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +42 -0
- package/generated/wasm-web/xlsx_substrate_wasm.d.ts +466 -0
- package/generated/wasm-web/xlsx_substrate_wasm.js +2109 -0
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm.d.ts +105 -0
- package/package.json +41 -3
- package/README.md +0 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D4-R2b (bridge v20) chart test fixture: a minimal in-code XLSX package
|
|
3
|
+
* with one worksheet and one chart-bearing drawing anchor. Built in-code —
|
|
4
|
+
* no binary fixtures are committed (mirrors the crate test package in
|
|
5
|
+
* `crates/sheets-package/tests/import_values_formulas.rs`); the bindings
|
|
6
|
+
* chart round-trip test and the xlsx-conductor chart route smoke share it.
|
|
7
|
+
*
|
|
8
|
+
* Content-safe: every byte below is synthetic.
|
|
9
|
+
*/
|
|
10
|
+
/** Synthetic single-series bar chartSpace with a cached literal point. */
|
|
11
|
+
export declare const SYNTHETIC_CHART_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><c:chart><c:plotArea><c:barChart><c:ser><c:idx val=\"0\"/><c:val><c:numRef><c:numCache><c:pt idx=\"0\"><c:v>1</c:v></c:pt></c:numCache></c:numRef></c:val></c:ser></c:barChart></c:plotArea></c:chart></c:chartSpace>";
|
|
12
|
+
/** Synthetic theme carrying the standard accent slots. */
|
|
13
|
+
export declare const SYNTHETIC_THEME_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Synthetic\"><a:themeElements><a:clrScheme name=\"Synthetic\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"1F2937\"/></a:dk2><a:lt2><a:srgbClr val=\"E5E7EB\"/></a:lt2><a:accent1><a:srgbClr val=\"4472C4\"/></a:accent1><a:accent2><a:srgbClr val=\"ED7D31\"/></a:accent2><a:accent3><a:srgbClr val=\"A5A5A5\"/></a:accent3><a:accent4><a:srgbClr val=\"FFC000\"/></a:accent4><a:accent5><a:srgbClr val=\"5B9BD5\"/></a:accent5><a:accent6><a:srgbClr val=\"70AD47\"/></a:accent6><a:hlink><a:srgbClr val=\"0563C1\"/></a:hlink><a:folHlink><a:srgbClr val=\"954F72\"/></a:folHlink></a:clrScheme></a:themeElements></a:theme>";
|
|
14
|
+
/**
|
|
15
|
+
* Deterministic single-chart workbook: one sheet, one two-cell-anchored
|
|
16
|
+
* graphicFrame chart at `xl/charts/chart1.xml` (path-confined XML part, so
|
|
17
|
+
* the import mints a verified chart handle) plus a workbook theme.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildDrawingChartXlsxBytes(): Uint8Array;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D4-R2b (bridge v20) chart test fixture: a minimal in-code XLSX package
|
|
3
|
+
* with one worksheet and one chart-bearing drawing anchor. Built in-code —
|
|
4
|
+
* no binary fixtures are committed (mirrors the crate test package in
|
|
5
|
+
* `crates/sheets-package/tests/import_values_formulas.rs`); the bindings
|
|
6
|
+
* chart round-trip test and the xlsx-conductor chart route smoke share it.
|
|
7
|
+
*
|
|
8
|
+
* Content-safe: every byte below is synthetic.
|
|
9
|
+
*/
|
|
10
|
+
import { zipStored } from "./media-test-fixture.js";
|
|
11
|
+
/** Synthetic single-series bar chartSpace with a cached literal point. */
|
|
12
|
+
export const SYNTHETIC_CHART_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><c:chart><c:plotArea><c:barChart><c:ser><c:idx val="0"/><c:val><c:numRef><c:numCache><c:pt idx="0"><c:v>1</c:v></c:pt></c:numCache></c:numRef></c:val></c:ser></c:barChart></c:plotArea></c:chart></c:chartSpace>';
|
|
13
|
+
/** Synthetic theme carrying the standard accent slots. */
|
|
14
|
+
export const SYNTHETIC_THEME_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Synthetic"><a:themeElements><a:clrScheme name="Synthetic"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F2937"/></a:dk2><a:lt2><a:srgbClr val="E5E7EB"/></a:lt2><a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2><a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4><a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme></a:themeElements></a:theme>';
|
|
15
|
+
const CONTENT_TYPES_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/drawings/drawing1.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml"/><Override PartName="/xl/charts/chart1.xml" ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml"/><Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/></Types>';
|
|
16
|
+
const ROOT_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>';
|
|
17
|
+
const WORKBOOK_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="Charts" sheetId="1" r:id="rId1"/></sheets></workbook>';
|
|
18
|
+
const WORKBOOK_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>';
|
|
19
|
+
const SHEET_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetData><row r="1"><c r="A1"><v>1</v></c></row></sheetData><drawing r:id="rId1"/></worksheet>';
|
|
20
|
+
const SHEET_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" Target="../drawings/drawing1.xml"/></Relationships>';
|
|
21
|
+
const DRAWING_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>9525</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>19050</xdr:rowOff></xdr:from><xdr:to><xdr:col>8</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>16</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="2" name="Chart 1"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart r:id="rId1"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>';
|
|
22
|
+
const DRAWING_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" Target="../charts/chart1.xml"/></Relationships>';
|
|
23
|
+
/**
|
|
24
|
+
* Deterministic single-chart workbook: one sheet, one two-cell-anchored
|
|
25
|
+
* graphicFrame chart at `xl/charts/chart1.xml` (path-confined XML part, so
|
|
26
|
+
* the import mints a verified chart handle) plus a workbook theme.
|
|
27
|
+
*/
|
|
28
|
+
export function buildDrawingChartXlsxBytes() {
|
|
29
|
+
const encoder = new TextEncoder();
|
|
30
|
+
return zipStored([
|
|
31
|
+
["[Content_Types].xml", encoder.encode(CONTENT_TYPES_XML)],
|
|
32
|
+
["_rels/.rels", encoder.encode(ROOT_RELS_XML)],
|
|
33
|
+
["xl/workbook.xml", encoder.encode(WORKBOOK_XML)],
|
|
34
|
+
["xl/_rels/workbook.xml.rels", encoder.encode(WORKBOOK_RELS_XML)],
|
|
35
|
+
["xl/worksheets/sheet1.xml", encoder.encode(SHEET_XML)],
|
|
36
|
+
["xl/worksheets/_rels/sheet1.xml.rels", encoder.encode(SHEET_RELS_XML)],
|
|
37
|
+
["xl/drawings/drawing1.xml", encoder.encode(DRAWING_XML)],
|
|
38
|
+
["xl/drawings/_rels/drawing1.xml.rels", encoder.encode(DRAWING_RELS_XML)],
|
|
39
|
+
["xl/charts/chart1.xml", encoder.encode(SYNTHETIC_CHART_XML)],
|
|
40
|
+
["xl/theme/theme1.xml", encoder.encode(SYNTHETIC_THEME_XML)]
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type XlsxWasmBridgeLoadResult } from "./bridge-contract.ts";
|
|
2
|
+
export * from "./bridge-contract.ts";
|
|
3
|
+
export declare function loadGeneratedXlsxWasmBridge(): XlsxWasmBridgeLoadResult;
|
|
4
|
+
/**
|
|
5
|
+
* SHA-256 of the WebAssembly binary this loader instantiates. Hosts report it
|
|
6
|
+
* with the bridge version so a deployed runtime is identifiable without
|
|
7
|
+
* reading the package's directory layout.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generatedWasmModuleSha256(): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Node.js loader shell over the `--target nodejs` CJS wasm artifact in
|
|
2
|
+
// `generated/wasm/`. The full target-independent bridge contract (types,
|
|
3
|
+
// required-capability / required-method lists, `validateRawXlsxWasmModule`,
|
|
4
|
+
// `createXlsxWasmBridge`, result normalizers, and the sheet-window binary
|
|
5
|
+
// decoder re-exports) lives in `bridge-contract.ts` so the browser loader
|
|
6
|
+
// (`web.ts`) shares it verbatim without pulling `node:` imports.
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { dirname, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { createXlsxWasmBridge, validateRawXlsxWasmModule } from "./bridge-contract.js";
|
|
13
|
+
export * from "./bridge-contract.js";
|
|
14
|
+
function loadCommonJsModule(moduleUrl, modulePath) {
|
|
15
|
+
const nativeRequire = typeof __non_webpack_require__ === "function"
|
|
16
|
+
? __non_webpack_require__
|
|
17
|
+
: createRequire(moduleUrl);
|
|
18
|
+
return nativeRequire(modulePath);
|
|
19
|
+
}
|
|
20
|
+
export function loadGeneratedXlsxWasmBridge() {
|
|
21
|
+
const modulePath = generatedWasmModulePath();
|
|
22
|
+
if (!existsSync(modulePath)) {
|
|
23
|
+
return {
|
|
24
|
+
wasmBinding: "not-mounted",
|
|
25
|
+
reason: "generated WASM module is absent; run build:wasm"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const raw = loadCommonJsModule(import.meta.url, modulePath);
|
|
30
|
+
const validation = validateRawXlsxWasmModule(raw);
|
|
31
|
+
if (!validation.ok) {
|
|
32
|
+
if (process.env.XLSX_WASM_REQUIRED === "1") {
|
|
33
|
+
throw new Error(validation.requiredModeMessage);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
wasmBinding: "not-mounted",
|
|
37
|
+
reason: validation.reason
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
wasmBinding: "mounted",
|
|
42
|
+
bridge: createXlsxWasmBridge(raw, validation.status)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (process.env.XLSX_WASM_REQUIRED === "1") {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
wasmBinding: "not-mounted",
|
|
51
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function generatedWasmModulePath() {
|
|
56
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
57
|
+
return resolve(here, "../../generated/wasm/xlsx_substrate_wasm.js");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* SHA-256 of the WebAssembly binary this loader instantiates. Hosts report it
|
|
61
|
+
* with the bridge version so a deployed runtime is identifiable without
|
|
62
|
+
* reading the package's directory layout.
|
|
63
|
+
*/
|
|
64
|
+
export function generatedWasmModuleSha256() {
|
|
65
|
+
const binary = resolve(dirname(generatedWasmModulePath()), "xlsx_substrate_wasm_bg.wasm");
|
|
66
|
+
return createHash("sha256").update(readFileSync(binary)).digest("hex");
|
|
67
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BR-3 (bridge v18) media test fixture: a minimal in-code XLSX package with
|
|
3
|
+
* one worksheet and one image-bearing drawing anchor. Built in-code — no
|
|
4
|
+
* binary media fixtures are committed (mirrors the BR-2 crate test package
|
|
5
|
+
* in `crates/sheets-package/tests/import_values_formulas.rs`); the bindings
|
|
6
|
+
* media round-trip test and the xlsx-conductor media route smoke share it.
|
|
7
|
+
*
|
|
8
|
+
* Content-safe: every byte below is synthetic.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Minimal PNG header: magic + IHDR (3x2 px) is all the substrate sniffer
|
|
12
|
+
* and dimension reader need; trailing bytes stand in for the stream.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tinyPngBytes(): Uint8Array;
|
|
15
|
+
export declare const DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>9525</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>19050</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:pic><xdr:nvPicPr><xdr:cNvPr id=\"2\" name=\"Picture 1\"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed=\"rId1\"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr/></xdr:pic><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>";
|
|
16
|
+
/**
|
|
17
|
+
* D4-R1b-3 fill inset (bridge v25): the same single-image workbook with a
|
|
18
|
+
* picture whose `a:stretch/a:fillRect` insets the fill inside the frame and
|
|
19
|
+
* whose `a:srcRect` has a NEGATIVE edge (an outward crop).
|
|
20
|
+
*/
|
|
21
|
+
export declare const FILL_INSET_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:pic><xdr:nvPicPr><xdr:cNvPr id=\"2\" name=\"Picture 1\"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed=\"rId1\"/><a:srcRect l=\"-20000\" t=\"10000\"/><a:stretch><a:fillRect l=\"10000\" t=\"20000\" r=\"-5000\"/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"914400\" cy=\"914400\"/></a:xfrm></xdr:spPr></xdr:pic><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>";
|
|
22
|
+
/**
|
|
23
|
+
* D4-R1b-3 fill inset (bridge v25): a picture inside a mirrored `xdr:grpSp`
|
|
24
|
+
* whose child space (chOff 100,200 / chExt 1000x500) differs from its frame,
|
|
25
|
+
* sitting at child (600,200) sized 400x250 and turned 10 degrees. Mirrors the
|
|
26
|
+
* crate fixture `GROUPED_PICTURE_CHILD_FRAME_DRAWING_XML`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const GROUPED_CHILD_FRAME_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:grpSp><xdr:nvGrpSpPr><xdr:cNvPr id=\"3\" name=\"Group 2\"/><xdr:cNvGrpSpPr/></xdr:nvGrpSpPr><xdr:grpSpPr><a:xfrm flipH=\"1\"><a:off x=\"500000\" y=\"700000\"/><a:ext cx=\"2000000\" cy=\"1000000\"/><a:chOff x=\"100\" y=\"200\"/><a:chExt cx=\"1000\" cy=\"500\"/></a:xfrm></xdr:grpSpPr><xdr:pic><xdr:nvPicPr><xdr:cNvPr id=\"4\" name=\"Picture 3\"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed=\"rId1\"/><a:srcRect r=\"-20000\"/><a:stretch><a:fillRect b=\"10000\"/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm rot=\"600000\"><a:off x=\"600\" y=\"200\"/><a:ext cx=\"400\" cy=\"250\"/></a:xfrm></xdr:spPr></xdr:pic></xdr:grpSp><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>";
|
|
29
|
+
/**
|
|
30
|
+
* Deterministic single-image workbook: one sheet, one two-cell-anchored
|
|
31
|
+
* PNG picture at `xl/media/image1.png` (allowlisted content type, valid
|
|
32
|
+
* PNG magic + IHDR so the import mints a verified media handle). Pass a
|
|
33
|
+
* `drawingXml` to swap the drawing part (the picture keeps `rId1`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildDrawingImageXlsxBytes(options?: {
|
|
36
|
+
readonly drawingXml?: string;
|
|
37
|
+
}): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Minimal deterministic ZIP writer: stored (uncompressed) entries only.
|
|
40
|
+
* Exported so sibling test suites (e.g. the xlsx-conductor BR-4
|
|
41
|
+
* record-enablement proof) can assemble tiny synthetic workbooks without
|
|
42
|
+
* committing binaries.
|
|
43
|
+
*/
|
|
44
|
+
export declare function zipStored(parts: readonly (readonly [string, Uint8Array])[]): Uint8Array;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BR-3 (bridge v18) media test fixture: a minimal in-code XLSX package with
|
|
3
|
+
* one worksheet and one image-bearing drawing anchor. Built in-code — no
|
|
4
|
+
* binary media fixtures are committed (mirrors the BR-2 crate test package
|
|
5
|
+
* in `crates/sheets-package/tests/import_values_formulas.rs`); the bindings
|
|
6
|
+
* media round-trip test and the xlsx-conductor media route smoke share it.
|
|
7
|
+
*
|
|
8
|
+
* Content-safe: every byte below is synthetic.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Minimal PNG header: magic + IHDR (3x2 px) is all the substrate sniffer
|
|
12
|
+
* and dimension reader need; trailing bytes stand in for the stream.
|
|
13
|
+
*/
|
|
14
|
+
export function tinyPngBytes() {
|
|
15
|
+
const bytes = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
16
|
+
const pushU32 = (value) => {
|
|
17
|
+
bytes.push((value >>> 24) & 0xff, (value >>> 16) & 0xff, (value >>> 8) & 0xff, value & 0xff);
|
|
18
|
+
};
|
|
19
|
+
pushU32(13);
|
|
20
|
+
bytes.push(0x49, 0x48, 0x44, 0x52); // IHDR
|
|
21
|
+
pushU32(3); // width
|
|
22
|
+
pushU32(2); // height
|
|
23
|
+
bytes.push(8, 6, 0, 0, 0);
|
|
24
|
+
bytes.push(0xde, 0xad, 0xbe, 0xef);
|
|
25
|
+
return Uint8Array.from(bytes);
|
|
26
|
+
}
|
|
27
|
+
const CONTENT_TYPES_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Default Extension="png" ContentType="image/png"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/drawings/drawing1.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml"/></Types>';
|
|
28
|
+
const ROOT_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>';
|
|
29
|
+
const WORKBOOK_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="Media" sheetId="1" r:id="rId1"/></sheets></workbook>';
|
|
30
|
+
const WORKBOOK_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>';
|
|
31
|
+
const SHEET_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetData><row r="1"><c r="A1"><v>1</v></c></row></sheetData><drawing r:id="rId1"/></worksheet>';
|
|
32
|
+
const SHEET_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" Target="../drawings/drawing1.xml"/></Relationships>';
|
|
33
|
+
export const DRAWING_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>9525</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>19050</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="2" name="Picture 1"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="rId1"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr/></xdr:pic><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>';
|
|
34
|
+
const DRAWING_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image1.png"/></Relationships>';
|
|
35
|
+
/**
|
|
36
|
+
* D4-R1b-3 fill inset (bridge v25): the same single-image workbook with a
|
|
37
|
+
* picture whose `a:stretch/a:fillRect` insets the fill inside the frame and
|
|
38
|
+
* whose `a:srcRect` has a NEGATIVE edge (an outward crop).
|
|
39
|
+
*/
|
|
40
|
+
export const FILL_INSET_DRAWING_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="2" name="Picture 1"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="rId1"/><a:srcRect l="-20000" t="10000"/><a:stretch><a:fillRect l="10000" t="20000" r="-5000"/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="914400" cy="914400"/></a:xfrm></xdr:spPr></xdr:pic><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>';
|
|
41
|
+
/**
|
|
42
|
+
* D4-R1b-3 fill inset (bridge v25): a picture inside a mirrored `xdr:grpSp`
|
|
43
|
+
* whose child space (chOff 100,200 / chExt 1000x500) differs from its frame,
|
|
44
|
+
* sitting at child (600,200) sized 400x250 and turned 10 degrees. Mirrors the
|
|
45
|
+
* crate fixture `GROUPED_PICTURE_CHILD_FRAME_DRAWING_XML`.
|
|
46
|
+
*/
|
|
47
|
+
export const GROUPED_CHILD_FRAME_DRAWING_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><xdr:twoCellAnchor><xdr:from><xdr:col>1</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>4</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>6</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:grpSp><xdr:nvGrpSpPr><xdr:cNvPr id="3" name="Group 2"/><xdr:cNvGrpSpPr/></xdr:nvGrpSpPr><xdr:grpSpPr><a:xfrm flipH="1"><a:off x="500000" y="700000"/><a:ext cx="2000000" cy="1000000"/><a:chOff x="100" y="200"/><a:chExt cx="1000" cy="500"/></a:xfrm></xdr:grpSpPr><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="4" name="Picture 3"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="rId1"/><a:srcRect r="-20000"/><a:stretch><a:fillRect b="10000"/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm rot="600000"><a:off x="600" y="200"/><a:ext cx="400" cy="250"/></a:xfrm></xdr:spPr></xdr:pic></xdr:grpSp><xdr:clientData/></xdr:twoCellAnchor></xdr:wsDr>';
|
|
48
|
+
/**
|
|
49
|
+
* Deterministic single-image workbook: one sheet, one two-cell-anchored
|
|
50
|
+
* PNG picture at `xl/media/image1.png` (allowlisted content type, valid
|
|
51
|
+
* PNG magic + IHDR so the import mints a verified media handle). Pass a
|
|
52
|
+
* `drawingXml` to swap the drawing part (the picture keeps `rId1`).
|
|
53
|
+
*/
|
|
54
|
+
export function buildDrawingImageXlsxBytes(options = {}) {
|
|
55
|
+
const encoder = new TextEncoder();
|
|
56
|
+
return zipStored([
|
|
57
|
+
["[Content_Types].xml", encoder.encode(CONTENT_TYPES_XML)],
|
|
58
|
+
["_rels/.rels", encoder.encode(ROOT_RELS_XML)],
|
|
59
|
+
["xl/workbook.xml", encoder.encode(WORKBOOK_XML)],
|
|
60
|
+
["xl/_rels/workbook.xml.rels", encoder.encode(WORKBOOK_RELS_XML)],
|
|
61
|
+
["xl/worksheets/sheet1.xml", encoder.encode(SHEET_XML)],
|
|
62
|
+
["xl/worksheets/_rels/sheet1.xml.rels", encoder.encode(SHEET_RELS_XML)],
|
|
63
|
+
["xl/drawings/drawing1.xml", encoder.encode(options.drawingXml ?? DRAWING_XML)],
|
|
64
|
+
["xl/drawings/_rels/drawing1.xml.rels", encoder.encode(DRAWING_RELS_XML)],
|
|
65
|
+
["xl/media/image1.png", tinyPngBytes()]
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
const CRC32_TABLE = (() => {
|
|
69
|
+
const table = new Uint32Array(256);
|
|
70
|
+
for (let index = 0; index < 256; index += 1) {
|
|
71
|
+
let value = index;
|
|
72
|
+
for (let bit = 0; bit < 8; bit += 1) {
|
|
73
|
+
value = value & 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
|
|
74
|
+
}
|
|
75
|
+
table[index] = value >>> 0;
|
|
76
|
+
}
|
|
77
|
+
return table;
|
|
78
|
+
})();
|
|
79
|
+
function crc32(bytes) {
|
|
80
|
+
let crc = 0xffffffff;
|
|
81
|
+
for (const byte of bytes) {
|
|
82
|
+
crc = CRC32_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);
|
|
83
|
+
}
|
|
84
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Minimal deterministic ZIP writer: stored (uncompressed) entries only.
|
|
88
|
+
* Exported so sibling test suites (e.g. the xlsx-conductor BR-4
|
|
89
|
+
* record-enablement proof) can assemble tiny synthetic workbooks without
|
|
90
|
+
* committing binaries.
|
|
91
|
+
*/
|
|
92
|
+
export function zipStored(parts) {
|
|
93
|
+
const encoder = new TextEncoder();
|
|
94
|
+
const chunks = [];
|
|
95
|
+
const centralChunks = [];
|
|
96
|
+
let offset = 0;
|
|
97
|
+
const u16 = (value) => Uint8Array.from([value & 0xff, (value >>> 8) & 0xff]);
|
|
98
|
+
const u32 = (value) => Uint8Array.from([value & 0xff, (value >>> 8) & 0xff, (value >>> 16) & 0xff, (value >>> 24) & 0xff]);
|
|
99
|
+
for (const [name, bytes] of parts) {
|
|
100
|
+
const nameBytes = encoder.encode(name);
|
|
101
|
+
const checksum = crc32(bytes);
|
|
102
|
+
const localHeader = concat([
|
|
103
|
+
u32(0x04034b50),
|
|
104
|
+
u16(20), // version needed
|
|
105
|
+
u16(0), // flags
|
|
106
|
+
u16(0), // stored
|
|
107
|
+
u16(0), // mod time
|
|
108
|
+
u16(0), // mod date
|
|
109
|
+
u32(checksum),
|
|
110
|
+
u32(bytes.length),
|
|
111
|
+
u32(bytes.length),
|
|
112
|
+
u16(nameBytes.length),
|
|
113
|
+
u16(0)
|
|
114
|
+
]);
|
|
115
|
+
centralChunks.push(concat([
|
|
116
|
+
u32(0x02014b50),
|
|
117
|
+
u16(20), // version made by
|
|
118
|
+
u16(20), // version needed
|
|
119
|
+
u16(0),
|
|
120
|
+
u16(0),
|
|
121
|
+
u16(0),
|
|
122
|
+
u16(0),
|
|
123
|
+
u32(checksum),
|
|
124
|
+
u32(bytes.length),
|
|
125
|
+
u32(bytes.length),
|
|
126
|
+
u16(nameBytes.length),
|
|
127
|
+
u16(0), // extra len
|
|
128
|
+
u16(0), // comment len
|
|
129
|
+
u16(0), // disk number
|
|
130
|
+
u16(0), // internal attrs
|
|
131
|
+
u32(0), // external attrs
|
|
132
|
+
u32(offset),
|
|
133
|
+
nameBytes
|
|
134
|
+
]));
|
|
135
|
+
chunks.push(localHeader, nameBytes, bytes);
|
|
136
|
+
offset += localHeader.length + nameBytes.length + bytes.length;
|
|
137
|
+
}
|
|
138
|
+
const centralDirectory = concat(centralChunks);
|
|
139
|
+
const endRecord = concat([
|
|
140
|
+
u32(0x06054b50),
|
|
141
|
+
u16(0),
|
|
142
|
+
u16(0),
|
|
143
|
+
u16(parts.length),
|
|
144
|
+
u16(parts.length),
|
|
145
|
+
u32(centralDirectory.length),
|
|
146
|
+
u32(offset),
|
|
147
|
+
u16(0)
|
|
148
|
+
]);
|
|
149
|
+
return concat([...chunks, centralDirectory, endRecord]);
|
|
150
|
+
}
|
|
151
|
+
function concat(chunks) {
|
|
152
|
+
const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
153
|
+
const out = new Uint8Array(total);
|
|
154
|
+
let cursor = 0;
|
|
155
|
+
for (const chunk of chunks) {
|
|
156
|
+
out.set(chunk, cursor);
|
|
157
|
+
cursor += chunk.length;
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { XlsxFormulaCommitRequest, XlsxFormulaCommitResult, XlsxFormulaRecalculateResult, XlsxLayoutMetricResizeRequest, XlsxLayoutMetricResizeResult, XlsxLayoutMetricVisibilityRequest, XlsxLayoutMetricVisibilityResult, XlsxFrozenPaneRequest, XlsxFrozenPaneResult, XlsxMergeCellsRequest, XlsxMergeCellsResult, XlsxRangeClearCommitRequest, XlsxRangeClearCommitResult, XlsxRangeFillCommitRequest, XlsxRangeFillCommitResult, XlsxRangeFormatCommitRequest, XlsxRangeFormatCommitResult, XlsxRangePasteCommitRequest, XlsxRangePasteCommitResult, XlsxRangeTransferCommitRequest, XlsxRangeTransferCommitResult, XlsxRuntimeSessionExportRequest, XlsxRuntimeSessionMutationReceipt, XlsxRuntimeWarning, XlsxSessionRecalculateRequest, XlsxSheetStructureMutationRequest, XlsxSheetStructureMutationResult, XlsxSheetTabMutationRequest, XlsxSheetTabMutationResult, XlsxShiftCellsCommitRequest, XlsxShiftCellsCommitResult, XlsxTableAppendRowRequest, XlsxTableAppendRowResult } from "../runtime/index.ts";
|
|
2
|
+
import type { XlsxBlocker } from "../shared.ts";
|
|
3
|
+
import type { XlsxRuntimeCommandVerdict } from "../runtime/index.ts";
|
|
4
|
+
import { type XlsxWasmBridge } from "./index.ts";
|
|
5
|
+
/**
|
|
6
|
+
* T1 (runtime-session-mutations-v1): host-side routing seam for workbook
|
|
7
|
+
* mutations.
|
|
8
|
+
*
|
|
9
|
+
* - `mode: "session"` — a runtime session handle exists AND the mounted wasm
|
|
10
|
+
* build exposes the full `*InSession` surface; every mutation family
|
|
11
|
+
* (formula, clear, fill, paste, transfer, format, resize, visibility,
|
|
12
|
+
* structure, tabs, table append) routes through the stateful session (no
|
|
13
|
+
* per-commit workbook re-parse, no per-commit byte export). Recalc defaults
|
|
14
|
+
* to the dirty differential path.
|
|
15
|
+
* - `mode: "bytes"` — no handle, or an older wasm build without the session
|
|
16
|
+
* exports (feature-detected via `supportsRuntimeSessionMutations`): edits
|
|
17
|
+
* route through today's byte-based exports byte-for-byte. Applied commits
|
|
18
|
+
* adopt `exportedBytes` as the current workbook truth, exactly like the
|
|
19
|
+
* existing byte pipeline.
|
|
20
|
+
*
|
|
21
|
+
* In BOTH modes results keep the byte-based DTO shape, so consumers keep
|
|
22
|
+
* consuming `result.invalidation` for tile damage exactly as today (the
|
|
23
|
+
* ui/react tile scheduler reads classes + range buckets unchanged).
|
|
24
|
+
*
|
|
25
|
+
* Byte-surface truth-fork protection: in session mode `currentBytes()` is
|
|
26
|
+
* auto-export-first — whenever the session revision advanced past the last
|
|
27
|
+
* export, it materializes fresh bytes through the read-only session export
|
|
28
|
+
* before returning. A consumer that mixes byte-based calls with an active
|
|
29
|
+
* session therefore always operates on post-mutation bytes; a failed export
|
|
30
|
+
* throws instead of silently serving stale pre-session bytes.
|
|
31
|
+
*/
|
|
32
|
+
export type XlsxWorkbookMutationMode = "session" | "bytes";
|
|
33
|
+
export interface XlsxWorkbookMutationRouterInit {
|
|
34
|
+
/** Current workbook byte truth; required as the byte-mode fallback seed. */
|
|
35
|
+
readonly bytes: Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* Open runtime-session handle (from `openWorkbookRuntimeSession`). When
|
|
38
|
+
* absent — or when the wasm build lacks runtime-session-mutations-v1 —
|
|
39
|
+
* the router stays on the byte path.
|
|
40
|
+
*/
|
|
41
|
+
readonly sessionHandleId?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface XlsxWorkbookBytesSnapshot {
|
|
44
|
+
readonly verdict: XlsxRuntimeCommandVerdict;
|
|
45
|
+
readonly bytes: Uint8Array;
|
|
46
|
+
/** Which pipeline produced the bytes. */
|
|
47
|
+
readonly source: "session-export" | "byte-truth";
|
|
48
|
+
/** Session receipt; present only when `source` is "session-export". */
|
|
49
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
50
|
+
readonly blockers: readonly XlsxBlocker[];
|
|
51
|
+
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
52
|
+
}
|
|
53
|
+
export interface XlsxWorkbookMutationRouter {
|
|
54
|
+
readonly mode: XlsxWorkbookMutationMode;
|
|
55
|
+
/** Present only in session mode. */
|
|
56
|
+
readonly sessionHandleId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Latest byte truth known to the router. Byte mode: advances with every
|
|
59
|
+
* applied commit. Session mode: auto-export-first — if any session
|
|
60
|
+
* mutation applied since the last export, a fresh read-only session export
|
|
61
|
+
* runs before returning, so byte-surface consumers can never silently fork
|
|
62
|
+
* from stale pre-session bytes (a failed export throws).
|
|
63
|
+
*/
|
|
64
|
+
currentBytes(): Uint8Array;
|
|
65
|
+
commitCellFormula(request: XlsxFormulaCommitRequest): XlsxFormulaCommitResult;
|
|
66
|
+
commitRangeClear(request: XlsxRangeClearCommitRequest): XlsxRangeClearCommitResult;
|
|
67
|
+
commitRangeFill(request: XlsxRangeFillCommitRequest): XlsxRangeFillCommitResult;
|
|
68
|
+
commitRangePaste(request: XlsxRangePasteCommitRequest): XlsxRangePasteCommitResult;
|
|
69
|
+
commitRangeTransfer(request: XlsxRangeTransferCommitRequest): XlsxRangeTransferCommitResult;
|
|
70
|
+
commitRangeFormat(request: XlsxRangeFormatCommitRequest): XlsxRangeFormatCommitResult;
|
|
71
|
+
resizeColumnWidth(request: XlsxLayoutMetricResizeRequest): XlsxLayoutMetricResizeResult;
|
|
72
|
+
resizeRowHeight(request: XlsxLayoutMetricResizeRequest): XlsxLayoutMetricResizeResult;
|
|
73
|
+
setColumnHidden(request: XlsxLayoutMetricVisibilityRequest): XlsxLayoutMetricVisibilityResult;
|
|
74
|
+
setRowHidden(request: XlsxLayoutMetricVisibilityRequest): XlsxLayoutMetricVisibilityResult;
|
|
75
|
+
/** X5-U-004 freeze/unfreeze panes (frozen-pane-v1). */
|
|
76
|
+
setFrozenPane(request: XlsxFrozenPaneRequest): XlsxFrozenPaneResult;
|
|
77
|
+
/** X5-U-037 merge/unmerge cells (merge-cells-v1). */
|
|
78
|
+
mergeCells(request: XlsxMergeCellsRequest): XlsxMergeCellsResult;
|
|
79
|
+
mutateSheetStructure(request: XlsxSheetStructureMutationRequest): XlsxSheetStructureMutationResult;
|
|
80
|
+
mutateSheetTabs(request: XlsxSheetTabMutationRequest): XlsxSheetTabMutationResult;
|
|
81
|
+
commitTableAppendRow(request: XlsxTableAppendRowRequest): XlsxTableAppendRowResult;
|
|
82
|
+
/** X5-U-006 insert/delete cells with shift (shift-cells-v1). */
|
|
83
|
+
commitShiftCells(request: XlsxShiftCellsCommitRequest): XlsxShiftCellsCommitResult;
|
|
84
|
+
/**
|
|
85
|
+
* Session mode: `recalculateInSession` (dirty differential by default,
|
|
86
|
+
* `mode: "full"` forces the full plan). Byte mode: the existing full-plan
|
|
87
|
+
* `recalculateFormulas`; the session-only `mode` field is stripped and surfaced as a
|
|
88
|
+
* `session-request-fields-stripped` warning on the result.
|
|
89
|
+
*/
|
|
90
|
+
recalculate(request?: XlsxSessionRecalculateRequest): XlsxFormulaRecalculateResult;
|
|
91
|
+
/**
|
|
92
|
+
* Materialize exportable workbook bytes. Session mode runs the read-only
|
|
93
|
+
* session export (no revision bump); byte mode returns the current byte
|
|
94
|
+
* truth as-is (it already IS the export of every applied commit).
|
|
95
|
+
*/
|
|
96
|
+
exportWorkbookBytes(request?: XlsxRuntimeSessionExportRequest): XlsxWorkbookBytesSnapshot;
|
|
97
|
+
}
|
|
98
|
+
export declare function createXlsxWorkbookMutationRouter(bridge: XlsxWasmBridge, init: XlsxWorkbookMutationRouterInit): XlsxWorkbookMutationRouter;
|