@betteroffice/xlsx 0.0.3 → 0.0.4
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 +14 -5
- package/dist/generated/xlsx_wasm_bg.wasm +0 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +1 -2
- package/package.json +6 -7
- package/dist/chunk-Q26VJ6CE.cjs +0 -4
- package/dist/headless.cjs +0 -1
- package/dist/headless.d.cts +0 -458
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -216
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# @betteroffice/xlsx
|
|
2
2
|
|
|
3
3
|
Framework-free core for the BetterOffice XLSX editor — the Rust engine (parse,
|
|
4
|
-
calc, render) compiled to WebAssembly
|
|
5
|
-
|
|
6
|
-
host.
|
|
4
|
+
calc, render) compiled to WebAssembly, plus display-list, viewport, hit-test, and
|
|
5
|
+
accessibility helpers.
|
|
7
6
|
|
|
8
7
|
> **Experimental (`0.0.x`).** The API is unstable and may change in any release.
|
|
9
8
|
|
|
@@ -18,13 +17,23 @@ Reach for this package directly to render a spreadsheet onto your own canvas.
|
|
|
18
17
|
## Usage
|
|
19
18
|
|
|
20
19
|
```ts
|
|
21
|
-
import { openWorkbook } from "@betteroffice/xlsx";
|
|
20
|
+
import { initWasm, openWorkbook } from "@betteroffice/xlsx";
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
await initWasm();
|
|
24
23
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
25
24
|
const workbook = openWorkbook(bytes);
|
|
26
25
|
```
|
|
27
26
|
|
|
27
|
+
`initWasm()` fetches the packaged wasm asset once in browsers. Pass wasm bytes or
|
|
28
|
+
a precompiled `WebAssembly.Module` explicitly in runtimes that cannot fetch the
|
|
29
|
+
asset URL.
|
|
30
|
+
|
|
31
|
+
## Development
|
|
32
|
+
|
|
33
|
+
The generated `.wasm` binary is intentionally not committed. From the repository
|
|
34
|
+
root, install `wasm-pack` 0.15.0 and run `bun run build:xlsx-wasm`. Package builds,
|
|
35
|
+
tests, demo startup, and CI run this step automatically.
|
|
36
|
+
|
|
28
37
|
From the returned handle you compose the geometry and rendering helpers this
|
|
29
38
|
package exports onto your own `<canvas>` 2D context — `paintDisplayList`,
|
|
30
39
|
`cellAtPoint` / `cellRect` / `rangeRect` (hit-testing), the `viewport` math,
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ export { A11yCell, A11yColumnHeader, A11yGrid, A11yRow, A11yStrings, CellAddr, C
|
|
|
17
17
|
*/
|
|
18
18
|
declare function paintDisplayList(ctx: CanvasRenderingContext2D, dl: DisplayList, dpr: number): void;
|
|
19
19
|
|
|
20
|
+
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* Wasm loader for the xlsx-wasm core.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `wasm-unsafe-eval`). Callers never see the JSON-string boundary: `openWorkbook`
|
|
27
|
-
* returns a typed {@link WorkbookHandle} and wasm throws surface as `Error`.
|
|
25
|
+
* Call {@link initWasm} once before opening workbooks. The default browser path
|
|
26
|
+
* streams the packaged wasm asset; non-fetch environments can pass bytes or a
|
|
27
|
+
* precompiled module. Callers never see the JSON-string boundary.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -186,9 +186,11 @@ interface WorkbookHandle {
|
|
|
186
186
|
isProposalsAvailable(): boolean;
|
|
187
187
|
dispose(): void;
|
|
188
188
|
}
|
|
189
|
+
type WasmInitInput = InitInput | Promise<InitInput>;
|
|
190
|
+
/** Initialize the workbook engine. Concurrent calls share the same attempt. */
|
|
191
|
+
declare function initWasm(input?: WasmInitInput): Promise<void>;
|
|
189
192
|
/**
|
|
190
|
-
* Whether
|
|
191
|
-
* init (idempotent) and reports success so callers can degrade explicitly.
|
|
193
|
+
* Whether this environment exposes the WebAssembly runtime required by the core.
|
|
192
194
|
*/
|
|
193
195
|
declare function isWasmAvailable(): boolean;
|
|
194
196
|
/**
|
|
@@ -213,4 +215,4 @@ declare function openWorkbook(bytes: Uint8Array): WorkbookHandle;
|
|
|
213
215
|
*/
|
|
214
216
|
declare function wasmVersion(): string;
|
|
215
217
|
|
|
216
|
-
export { type CellEdit, type CellInputEdit, DisplayList, type EditResult, type Proposal, type ProposalCell, type ProposalEdit, type SheetInfo, StaleProposalError, type Viewport, type WorkbookHandle, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, wasmVersion };
|
|
218
|
+
export { type CellEdit, type CellInputEdit, DisplayList, type EditResult, type Proposal, type ProposalCell, type ProposalEdit, type SheetInfo, StaleProposalError, type Viewport, type WasmInitInput, type WorkbookHandle, initWasm, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, wasmVersion };
|