@extend-ai/react-xlsx 0.10.2 → 0.10.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 CHANGED
@@ -24,6 +24,69 @@ pnpm add @extend-ai/react-xlsx react react-dom
24
24
 
25
25
  `react` and `react-dom` are peer dependencies.
26
26
 
27
+ ## WebAssembly Asset
28
+
29
+ Workbook parsing and calculation run through the `@dukelib/sheets-wasm` WebAssembly module. The module loads lazily, on the first workbook parse.
30
+
31
+ Most apps can use the default loader. If your bundler or deployment needs to host the WASM binary somewhere explicit, configure it before the first parse:
32
+
33
+ ```ts
34
+ import { setWasmSource } from "@extend-ai/react-xlsx";
35
+
36
+ setWasmSource("https://cdn.example.com/duke_sheets_wasm_bg.wasm");
37
+ // or pass a URL, Request, Response, ArrayBuffer/TypedArray, or compiled WebAssembly.Module
38
+ ```
39
+
40
+ The Duke WASM binary is also exposed as a package subpath:
41
+
42
+ ```ts
43
+ import wasmUrl from "@extend-ai/react-xlsx/duke_sheets_wasm_bg.wasm?url";
44
+ import { setWasmSource } from "@extend-ai/react-xlsx";
45
+
46
+ setWasmSource(wasmUrl);
47
+ ```
48
+
49
+ ### Next.js Turbopack
50
+
51
+ Turbopack may try to treat `.wasm?url` imports as WebAssembly modules during static analysis. For Turbopack apps, use a plain public or CDN URL instead of importing the WASM file with `?url`.
52
+
53
+ Copy the WASM file into your app's `public/` directory:
54
+
55
+ ```bash
56
+ cp node_modules/@extend-ai/react-xlsx/dist/duke_sheets_wasm_bg.wasm public/duke_sheets_wasm_bg.wasm
57
+ ```
58
+
59
+ Then configure the source from a shared client module before any workbook is parsed:
60
+
61
+ ```ts
62
+ // app/xlsx-wasm.ts
63
+ "use client";
64
+
65
+ import { setWasmSource } from "@extend-ai/react-xlsx";
66
+
67
+ setWasmSource("/duke_sheets_wasm_bg.wasm");
68
+ ```
69
+
70
+ Import that setup module before rendering any XLSX viewer, provider, or controller:
71
+
72
+ ```tsx
73
+ // app/workbook-preview.tsx
74
+ "use client";
75
+
76
+ import "./xlsx-wasm";
77
+ import { XlsxViewer } from "@extend-ai/react-xlsx";
78
+
79
+ export function WorkbookPreview({ file }: { file: ArrayBuffer }) {
80
+ return <XlsxViewer file={file} height={600} />;
81
+ }
82
+ ```
83
+
84
+ If several routes use the viewer, import the same setup module from a shared client boundary such as `app/providers.tsx`. Calling `setWasmSource()` more than once with the same source is fine before initialization, but the source must not change after the first parse because the WASM module is initialized once per JavaScript context.
85
+
86
+ Configured string, URL, Request URL, bytes, and `WebAssembly.Module` sources are forwarded into the XLSX worker. `Response` sources are supported on the main thread; worker-backed parsing is skipped for that source type.
87
+
88
+ You can also call `initWasm()` (optionally with a source) ahead of time to warm the module before the first workbook is opened.
89
+
27
90
  ## Main Entry Points
28
91
 
29
92
  The package exports three useful levels of API:
Binary file