@beyondwork/xlsx-substrate-bindings 0.1.0 → 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.
- package/README.md +136 -0
- package/dist/ai/agent-metadata.d.ts +363 -0
- package/dist/ai/agent-metadata.js +227 -0
- package/dist/ai/index.d.ts +5 -1
- package/dist/ai/index.js +6 -0
- package/dist/ai/mutation-bridge.d.ts +82 -0
- package/dist/ai/mutation-bridge.js +179 -0
- package/dist/ai/types.d.ts +448 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +20 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/types.d.ts +57 -1
- package/dist/wasm/ai-session-bridge.d.ts +97 -0
- package/dist/wasm/ai-session-bridge.js +154 -0
- package/dist/wasm/bridge-contract.d.ts +108 -6
- package/dist/wasm/bridge-contract.js +146 -7
- package/dist/wasm/index.d.ts +43 -2
- package/dist/wasm/index.js +253 -23
- package/dist/wasm/memory-budget.d.ts +77 -0
- package/dist/wasm/memory-budget.js +532 -0
- package/dist/wasm/runtime-guard.d.ts +141 -0
- package/dist/wasm/runtime-guard.js +373 -0
- package/dist/wasm/web.d.ts +16 -3
- package/dist/wasm/web.js +91 -9
- package/generated/wasm-web/xlsx_substrate_wasm.d.ts +66 -0
- package/generated/wasm-web/xlsx_substrate_wasm.js +2488 -2104
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm.d.ts +15 -0
- package/package.json +18 -4
- package/dist/wasm/chart-test-fixture.d.ts +0 -19
- package/dist/wasm/chart-test-fixture.js +0 -42
- package/dist/wasm/media-test-fixture.d.ts +0 -44
- package/dist/wasm/media-test-fixture.js +0 -160
- package/dist/wasm/volatile-test-fixture.d.ts +0 -7
- package/dist/wasm/volatile-test-fixture.js +0 -35
- package/generated/wasm/package.json +0 -3
- package/generated/wasm/sheet-window-binary.mjs +0 -482
- package/generated/wasm/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +0 -45
- package/generated/wasm/xlsx_substrate_wasm.d.ts +0 -336
- package/generated/wasm/xlsx_substrate_wasm.js +0 -2108
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm.d.ts +0 -105
|
Binary file
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const aiSessionCall: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
4
5
|
export const bindUiRuntimeSession: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
5
6
|
export const bindUiSession: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
7
|
export const cancelKernelRun: (a: number, b: number, c: any) => [number, number, number];
|
|
7
8
|
export const classifyUiState: (a: number, b: number) => [number, number, number];
|
|
8
9
|
export const commitApplyFilter: (a: number, b: number, c: any) => [number, number, number];
|
|
10
|
+
export const commitApplyFilterInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
9
11
|
export const commitApplySort: (a: number, b: number, c: any) => [number, number, number];
|
|
12
|
+
export const commitApplySortInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
10
13
|
export const commitCellFormula: (a: number, b: number, c: any) => [number, number, number];
|
|
11
14
|
export const commitCellFormulaInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
12
15
|
export const commitClearFilter: (a: number, b: number, c: any) => [number, number, number];
|
|
16
|
+
export const commitClearFilterInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
13
17
|
export const commitRangeClear: (a: number, b: number, c: any) => [number, number, number];
|
|
14
18
|
export const commitRangeClearInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
15
19
|
export const commitRangeDataValidation: (a: number, b: number, c: any) => [number, number, number];
|
|
20
|
+
export const commitRangeDataValidationInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
16
21
|
export const commitRangeFill: (a: number, b: number, c: any) => [number, number, number];
|
|
17
22
|
export const commitRangeFillInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
18
23
|
export const commitRangeFormat: (a: number, b: number, c: any) => [number, number, number];
|
|
19
24
|
export const commitRangeFormatInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
20
25
|
export const commitRangeHyperlink: (a: number, b: number, c: any) => [number, number, number];
|
|
26
|
+
export const commitRangeHyperlinkInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
21
27
|
export const commitRangePaste: (a: number, b: number, c: any) => [number, number, number];
|
|
22
28
|
export const commitRangePasteInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
23
29
|
export const commitRangeTransfer: (a: number, b: number, c: any) => [number, number, number];
|
|
24
30
|
export const commitRangeTransferInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
25
31
|
export const commitReviewComment: (a: number, b: number, c: any) => [number, number, number];
|
|
32
|
+
export const commitReviewCommentInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
26
33
|
export const commitSelectionSetClear: (a: number, b: number, c: any) => [number, number, number];
|
|
34
|
+
export const commitSelectionSetClearInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
27
35
|
export const commitSelectionSetFormat: (a: number, b: number, c: any) => [number, number, number];
|
|
36
|
+
export const commitSelectionSetFormatInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
28
37
|
export const commitSelectionSetPaste: (a: number, b: number, c: any) => [number, number, number];
|
|
38
|
+
export const commitSelectionSetPasteInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
29
39
|
export const commitShiftCells: (a: number, b: number, c: any) => [number, number, number];
|
|
30
40
|
export const commitShiftCellsInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
31
41
|
export const commitTableAppendRow: (a: number, b: number, c: any) => [number, number, number];
|
|
@@ -33,6 +43,8 @@ export const commitTableAppendRowInSession: (a: number, b: number, c: any) => [n
|
|
|
33
43
|
export const completeKernelRun: (a: number, b: number, c: any) => [number, number, number];
|
|
34
44
|
export const createKernelBinding: (a: number, b: number, c: any) => [number, number, number];
|
|
35
45
|
export const dataRegionInRuntimeSession: (a: number, b: number, c: any) => [number, number, number];
|
|
46
|
+
export const defineName: (a: number, b: number, c: any) => [number, number, number];
|
|
47
|
+
export const defineNameInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
36
48
|
export const deleteKernelBinding: (a: number, b: number, c: any) => [number, number, number];
|
|
37
49
|
export const detachKernelOutput: (a: number, b: number, c: any) => [number, number, number];
|
|
38
50
|
export const disposeWorkbookRuntimeSession: (a: number, b: number) => [number, number, number];
|
|
@@ -85,12 +97,15 @@ export const resolveReference: (a: number, b: number, c: any) => [number, number
|
|
|
85
97
|
export const setColumnHidden: (a: number, b: number, c: any) => [number, number, number];
|
|
86
98
|
export const setColumnHiddenInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
87
99
|
export const setColumnOutlineGroupHidden: (a: number, b: number, c: any) => [number, number, number];
|
|
100
|
+
export const setColumnOutlineGroupHiddenInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
88
101
|
export const setFrozenPane: (a: number, b: number, c: any) => [number, number, number];
|
|
89
102
|
export const setFrozenPaneInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
90
103
|
export const setRowHidden: (a: number, b: number, c: any) => [number, number, number];
|
|
91
104
|
export const setRowHiddenInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
92
105
|
export const setRowOutlineGroupHidden: (a: number, b: number, c: any) => [number, number, number];
|
|
106
|
+
export const setRowOutlineGroupHiddenInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
93
107
|
export const setSheetOutlineLevel: (a: number, b: number, c: any) => [number, number, number];
|
|
108
|
+
export const setSheetOutlineLevelInSession: (a: number, b: number, c: any) => [number, number, number];
|
|
94
109
|
export const startKernelRun: (a: number, b: number, c: any) => [number, number, number];
|
|
95
110
|
export const summarizeAccessibility: (a: number, b: number, c: any, d: any, e: any) => [number, number, number];
|
|
96
111
|
export const summarizeRuntimeSessionAccessibility: (a: number, b: number, c: any, d: any, e: any) => [number, number, number];
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beyondwork/xlsx-substrate-bindings",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Conductor, the Ensemble spreadsheet runtime: native XLSX sessions compiled to WebAssembly for Node and browsers.",
|
|
5
|
+
"conductor": {
|
|
6
|
+
"bridgeVersion": "xlsx-wasm-bridge-v46",
|
|
7
|
+
"versionPolicy": "Versions stay 0.x. A release is MINOR when its bridgeVersion differs from the last published release's, PATCH for fixes on the same bridgeVersion, and MAJOR only for removing a required method or capability. A bridge version change on pe2 does not by itself need a release.",
|
|
8
|
+
"wasm": "generated/wasm-web/xlsx_substrate_wasm_bg.wasm",
|
|
9
|
+
"linearMemoryMaximumBytes": 2147483648
|
|
10
|
+
},
|
|
5
11
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.12"
|
|
14
|
+
},
|
|
6
15
|
"type": "module",
|
|
7
16
|
"sideEffects": false,
|
|
8
17
|
"exports": {
|
|
@@ -18,6 +27,11 @@
|
|
|
18
27
|
"types": "./dist/wasm/web.d.ts",
|
|
19
28
|
"import": "./dist/wasm/web.js"
|
|
20
29
|
},
|
|
30
|
+
"./wasm/web/glue": {
|
|
31
|
+
"types": "./generated/wasm-web/xlsx_substrate_wasm.d.ts",
|
|
32
|
+
"import": "./generated/wasm-web/xlsx_substrate_wasm.js"
|
|
33
|
+
},
|
|
34
|
+
"./wasm/web/binary": "./generated/wasm-web/xlsx_substrate_wasm_bg.wasm",
|
|
21
35
|
"./package.json": "./package.json"
|
|
22
36
|
},
|
|
23
37
|
"publishConfig": {
|
|
@@ -25,9 +39,9 @@
|
|
|
25
39
|
},
|
|
26
40
|
"files": [
|
|
27
41
|
"dist",
|
|
28
|
-
"generated/wasm",
|
|
29
42
|
"generated/wasm-web",
|
|
30
|
-
"LICENSE.md"
|
|
43
|
+
"LICENSE.md",
|
|
44
|
+
"README.md"
|
|
31
45
|
],
|
|
32
46
|
"devDependencies": {
|
|
33
47
|
"wasm-opt": "1.4.0"
|
|
@@ -39,6 +53,6 @@
|
|
|
39
53
|
"test:wasm": "pnpm run build:wasm && XLSX_WASM_REQUIRED=1 pnpm exec tsx --test --test-timeout=120000 src/wasm/**/*.test.ts",
|
|
40
54
|
"build:wasm": "node scripts/build-wasm.mjs",
|
|
41
55
|
"lint:tsgo": "tsgo --noEmit -p tsconfig.json",
|
|
42
|
-
"build": "tsc -p tsconfig.dist.json"
|
|
56
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.dist.json"
|
|
43
57
|
}
|
|
44
58
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
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;
|
|
@@ -1,160 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function volatileWorkbookBytes(): Uint8Array;
|
|
2
|
-
export declare function volatileExportValues(bytes: Uint8Array): Record<string, number>;
|
|
3
|
-
export declare const volatileInputs: {
|
|
4
|
-
epochMillisUtc: number;
|
|
5
|
-
randomSeed: number;
|
|
6
|
-
};
|
|
7
|
-
export declare function assertVolatileValues(values: Record<string, number>, dayOffset?: number): void;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
|
|
4
|
-
// Synthetic cached values deliberately disagree with the explicit test clock.
|
|
5
|
-
export function volatileWorkbookBytes() {
|
|
6
|
-
const parts = unzipSync(readFileSync(new URL("../../../../test/fixtures/xlsx/recalc/x1-d-053-volatile-recalc.xlsx", import.meta.url)));
|
|
7
|
-
// Modern Excel functions use the _xlfn. storage spelling in OOXML.
|
|
8
|
-
const formulas = ["NOW()", "TODAY()", "RAND()", "RANDBETWEEN(1,10)", "_xlfn.RANDARRAY(2,2)"];
|
|
9
|
-
parts["xl/worksheets/sheet1.xml"] = strToU8(strFromU8(parts["xl/worksheets/sheet1.xml"])
|
|
10
|
-
.replace(/<sheetData>[\s\S]*?<\/sheetData>/u, `<sheetData>${formulas.map((formula, index) => `<row r="${index + 1}"><c r="B${index + 1}"><f>${formula}</f><v>45000</v></c></row>`).join("")}</sheetData>`));
|
|
11
|
-
return zipSync(parts);
|
|
12
|
-
}
|
|
13
|
-
// Read the actual exported package with an independent ZIP reader.
|
|
14
|
-
export function volatileExportValues(bytes) {
|
|
15
|
-
const xml = strFromU8(unzipSync(bytes)["xl/worksheets/sheet1.xml"]);
|
|
16
|
-
const values = {};
|
|
17
|
-
for (const cell of xml.matchAll(/<c\b[^>]*\br="([BC][1-6])"[^>]*>([\s\S]*?)<\/c>/gu)) {
|
|
18
|
-
const value = cell[2].match(/<v>([^<]+)<\/v>/u);
|
|
19
|
-
if (value)
|
|
20
|
-
values[cell[1]] = Number(value[1]);
|
|
21
|
-
}
|
|
22
|
-
for (const formula of ["NOW()", "TODAY()", "RAND()", "RANDBETWEEN(1,10)", "RANDARRAY(2,2)"]) {
|
|
23
|
-
assert.ok(xml.includes(`>${formula}</f>`) || xml.includes(`>_xlfn.${formula}</f>`), `${formula} survives export`);
|
|
24
|
-
}
|
|
25
|
-
return values;
|
|
26
|
-
}
|
|
27
|
-
export const volatileInputs = { epochMillisUtc: 1_706_702_400_000, randomSeed: 12345 };
|
|
28
|
-
export function assertVolatileValues(values, dayOffset = 0) {
|
|
29
|
-
assert.equal(values.B1, 45322.5 + dayOffset, "NOW uses the explicit UTC clock");
|
|
30
|
-
assert.equal(values.B2, 45322 + dayOffset, "TODAY uses the explicit UTC clock");
|
|
31
|
-
for (const address of ["B3", "B5", "C5", "B6", "C6"]) {
|
|
32
|
-
assert.ok(values[address] >= 0 && values[address] < 1, `${address} is a refreshed random value`);
|
|
33
|
-
}
|
|
34
|
-
assert.ok(Number.isInteger(values.B4) && values.B4 >= 1 && values.B4 <= 10);
|
|
35
|
-
}
|