saurus-excel 0.1.1 → 0.1.2
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 +245 -105
- package/dist/react.d.ts +83 -45
- package/dist/react.js +1 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,82 +1,120 @@
|
|
|
1
|
-
# 🦖
|
|
1
|
+
# 🦖 Saurus-Excel
|
|
2
2
|
|
|
3
3
|
> Blazingly fast Excel parser for the web - powered by Rust & WebAssembly
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/saurus-excel)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Saurus-Excel is a high-performance Excel file parser designed for handling **large datasets** in the browser. Built with Rust and compiled to WebAssembly, it processes millions of rows without crashing your browser.
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
11
11
|
|
|
12
12
|
- 🚀 **Blazingly Fast** - 10x faster than SheetJS for large files
|
|
13
|
-
- 💾 **Memory Efficient** -
|
|
13
|
+
- 💾 **Memory Efficient** - Minimal RAM usage
|
|
14
14
|
- 📊 **Multiple Formats** - XLSX, XLS, XLSM, XLSB, ODS
|
|
15
|
-
-
|
|
16
|
-
- ⚛️ **Framework Support** - React hooks & Astro components included
|
|
15
|
+
- ⚛️ **Framework Support** - React hooks included
|
|
17
16
|
- 🔧 **TypeScript First** - Full type definitions
|
|
18
17
|
|
|
19
18
|
## 📦 Installation
|
|
20
19
|
|
|
21
20
|
```bash
|
|
22
|
-
npm install
|
|
21
|
+
npm install saurus-excel
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Basic Usage
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { parseExcel } from "excelsaurus";
|
|
31
|
-
|
|
32
|
-
// Parse from file input
|
|
33
|
-
const file = event.target.files[0];
|
|
34
|
-
const result = await parseExcel(file);
|
|
24
|
+
---
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
## 🚀 Usage
|
|
27
|
+
|
|
28
|
+
### Vanilla JavaScript (Browser)
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<!DOCTYPE html>
|
|
32
|
+
<html>
|
|
33
|
+
<head>
|
|
34
|
+
<title>Excel Parser</title>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<input type="file" id="fileInput" accept=".xlsx,.xls" />
|
|
38
|
+
<pre id="output"></pre>
|
|
39
|
+
|
|
40
|
+
<script type="module">
|
|
41
|
+
// Import from pkg folder for direct Wasm access
|
|
42
|
+
import init, { parseExcel } from "saurus-excel/pkg/excelsaurus.js";
|
|
43
|
+
|
|
44
|
+
// Initialize Wasm module (required once)
|
|
45
|
+
await init();
|
|
46
|
+
|
|
47
|
+
document
|
|
48
|
+
.getElementById("fileInput")
|
|
49
|
+
.addEventListener("change", async (e) => {
|
|
50
|
+
const file = e.target.files[0];
|
|
51
|
+
if (!file) return;
|
|
52
|
+
|
|
53
|
+
// Read file as bytes
|
|
54
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
55
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
56
|
+
|
|
57
|
+
// Parse Excel
|
|
58
|
+
const result = parseExcel(bytes, { hasHeaders: true });
|
|
59
|
+
|
|
60
|
+
console.log(result.headers); // ["Name", "Email", "Age"]
|
|
61
|
+
console.log(result.rows); // [["John", "john@example.com", 30], ...]
|
|
62
|
+
|
|
63
|
+
document.getElementById("output").textContent = JSON.stringify(
|
|
64
|
+
result,
|
|
65
|
+
null,
|
|
66
|
+
2,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
|
39
72
|
```
|
|
40
73
|
|
|
41
|
-
### With
|
|
74
|
+
### With Bundler (Vite, Webpack, etc.)
|
|
42
75
|
|
|
43
76
|
```typescript
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### Streaming Large Files
|
|
77
|
+
// Note: Wasm needs special bundler config (see below)
|
|
78
|
+
import init, {
|
|
79
|
+
parseExcel,
|
|
80
|
+
getSheetNames,
|
|
81
|
+
} from "saurus-excel/pkg/excelsaurus.js";
|
|
82
|
+
|
|
83
|
+
// Initialize once at app startup
|
|
84
|
+
let initialized = false;
|
|
85
|
+
async function ensureInit() {
|
|
86
|
+
if (!initialized) {
|
|
87
|
+
await init();
|
|
88
|
+
initialized = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
59
91
|
|
|
60
|
-
|
|
61
|
-
|
|
92
|
+
export async function parseExcelFile(file: File) {
|
|
93
|
+
await ensureInit();
|
|
62
94
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
onProgress: (p) => console.log(`${p.percent}%`),
|
|
66
|
-
});
|
|
95
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
96
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
67
97
|
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
return parseExcel(bytes, {
|
|
99
|
+
hasHeaders: true,
|
|
100
|
+
limit: 1000, // Optional: limit rows
|
|
101
|
+
});
|
|
70
102
|
}
|
|
71
103
|
```
|
|
72
104
|
|
|
73
|
-
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## ⚛️ React 19 / Next.js (Plug & Play)
|
|
108
|
+
|
|
109
|
+
### Quick Start
|
|
74
110
|
|
|
75
111
|
```tsx
|
|
76
|
-
import { useExcelParser } from "
|
|
112
|
+
import { useExcelParser } from "saurus-excel/react";
|
|
77
113
|
|
|
78
|
-
function
|
|
79
|
-
const { parse, data,
|
|
114
|
+
function ImportPage() {
|
|
115
|
+
const { parse, data, loading, error, ready } = useExcelParser();
|
|
116
|
+
|
|
117
|
+
if (!ready) return <p>Loading parser...</p>;
|
|
80
118
|
|
|
81
119
|
return (
|
|
82
120
|
<div>
|
|
@@ -85,98 +123,200 @@ function ImportComponent() {
|
|
|
85
123
|
accept=".xlsx,.xls"
|
|
86
124
|
onChange={(e) => e.target.files?.[0] && parse(e.target.files[0])}
|
|
87
125
|
/>
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
{error && <
|
|
126
|
+
|
|
127
|
+
{loading && <p>Parsing...</p>}
|
|
128
|
+
{error && <p style={{ color: "red" }}>{error.message}</p>}
|
|
129
|
+
|
|
130
|
+
{data && (
|
|
131
|
+
<table>
|
|
132
|
+
<thead>
|
|
133
|
+
<tr>
|
|
134
|
+
{data.headers.map((h, i) => (
|
|
135
|
+
<th key={i}>{h}</th>
|
|
136
|
+
))}
|
|
137
|
+
</tr>
|
|
138
|
+
</thead>
|
|
139
|
+
<tbody>
|
|
140
|
+
{data.rows.map((row, i) => (
|
|
141
|
+
<tr key={i}>
|
|
142
|
+
{row.map((cell, j) => (
|
|
143
|
+
<td key={j}>{cell}</td>
|
|
144
|
+
))}
|
|
145
|
+
</tr>
|
|
146
|
+
))}
|
|
147
|
+
</tbody>
|
|
148
|
+
</table>
|
|
149
|
+
)}
|
|
91
150
|
</div>
|
|
92
151
|
);
|
|
93
152
|
}
|
|
94
153
|
```
|
|
95
154
|
|
|
96
|
-
###
|
|
155
|
+
### With Provider (Recommended for Next.js App Router)
|
|
97
156
|
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
157
|
+
```tsx
|
|
158
|
+
// app/providers.tsx
|
|
159
|
+
"use client";
|
|
160
|
+
import { ExcelProvider } from "saurus-excel/react";
|
|
161
|
+
|
|
162
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
163
|
+
return <ExcelProvider>{children}</ExcelProvider>;
|
|
164
|
+
}
|
|
103
165
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
customElements.define('excel-importer', ExcelImporter);
|
|
166
|
+
// app/layout.tsx
|
|
167
|
+
import { Providers } from "./providers";
|
|
107
168
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
169
|
+
export default function RootLayout({ children }) {
|
|
170
|
+
return (
|
|
171
|
+
<html>
|
|
172
|
+
<body>
|
|
173
|
+
<Providers>{children}</Providers>
|
|
174
|
+
</body>
|
|
175
|
+
</html>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
112
178
|
```
|
|
113
179
|
|
|
114
|
-
###
|
|
180
|
+
### Drop-in Component
|
|
115
181
|
|
|
116
|
-
```
|
|
117
|
-
import {
|
|
182
|
+
```tsx
|
|
183
|
+
import { ExcelDropzone } from "saurus-excel/react";
|
|
184
|
+
|
|
185
|
+
function UploadPage() {
|
|
186
|
+
return (
|
|
187
|
+
<ExcelDropzone
|
|
188
|
+
onData={(result) => {
|
|
189
|
+
console.log("Headers:", result.headers);
|
|
190
|
+
console.log("Rows:", result.rows);
|
|
191
|
+
}}
|
|
192
|
+
onError={(err) => console.error(err)}
|
|
193
|
+
options={{ hasHeaders: true, limit: 1000 }}
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
118
198
|
|
|
119
|
-
|
|
199
|
+
### Available Hooks
|
|
120
200
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
201
|
+
| Hook | Description |
|
|
202
|
+
| ------------------ | --------------------------- |
|
|
203
|
+
| `useExcelParser()` | Main hook for parsing files |
|
|
204
|
+
| `useExcelSheets()` | Get sheet names from file |
|
|
124
205
|
|
|
125
|
-
|
|
206
|
+
### Hook Return Values
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
const {
|
|
210
|
+
parse, // (file: File, options?) => Promise<ParseResult>
|
|
211
|
+
data, // ParseResult | null
|
|
212
|
+
loading, // boolean
|
|
213
|
+
error, // Error | null
|
|
214
|
+
progress, // number (0-100)
|
|
215
|
+
ready, // boolean - Wasm loaded
|
|
216
|
+
reset, // () => void
|
|
217
|
+
} = useExcelParser();
|
|
126
218
|
```
|
|
127
219
|
|
|
128
|
-
|
|
220
|
+
---
|
|
129
221
|
|
|
130
|
-
|
|
222
|
+
## ⚙️ Bundler Configuration
|
|
131
223
|
|
|
132
|
-
|
|
224
|
+
### Vite
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
// vite.config.ts
|
|
228
|
+
import { defineConfig } from "vite";
|
|
229
|
+
|
|
230
|
+
export default defineConfig({
|
|
231
|
+
optimizeDeps: {
|
|
232
|
+
exclude: ["saurus-excel"],
|
|
233
|
+
},
|
|
234
|
+
build: {
|
|
235
|
+
target: "esnext",
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Next.js
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
// next.config.js
|
|
244
|
+
module.exports = {
|
|
245
|
+
webpack: (config) => {
|
|
246
|
+
config.experiments = {
|
|
247
|
+
...config.experiments,
|
|
248
|
+
asyncWebAssembly: true,
|
|
249
|
+
};
|
|
250
|
+
return config;
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Webpack 5
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
// webpack.config.js
|
|
259
|
+
module.exports = {
|
|
260
|
+
experiments: {
|
|
261
|
+
asyncWebAssembly: true,
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
```
|
|
133
265
|
|
|
134
|
-
|
|
135
|
-
| ------------ | ------------------ | ----------- | -------------------- |
|
|
136
|
-
| `sheet` | `string \| number` | `0` | Sheet name or index |
|
|
137
|
-
| `limit` | `number` | `undefined` | Max rows to parse |
|
|
138
|
-
| `skipRows` | `number` | `0` | Rows to skip |
|
|
139
|
-
| `hasHeaders` | `boolean` | `true` | First row is headers |
|
|
266
|
+
---
|
|
140
267
|
|
|
141
|
-
|
|
268
|
+
## 📖 API Reference
|
|
142
269
|
|
|
143
|
-
|
|
270
|
+
### parseExcel(bytes, options?)
|
|
144
271
|
|
|
145
|
-
|
|
146
|
-
| ------------ | ------------------ | ------------------------------------------------------- |
|
|
147
|
-
| `name` | `string` | Output field name |
|
|
148
|
-
| `column` | `number \| string` | Column index (0-based) or letter (A, B, C...) |
|
|
149
|
-
| `type` | `string` | `string`, `number`, `integer`, `boolean`, `date`, `any` |
|
|
150
|
-
| `required` | `boolean` | Is field required? |
|
|
151
|
-
| `validate` | `string` | Built-in validator: `email`, `phone`, `url`, `nonempty` |
|
|
152
|
-
| `default` | `any` | Default value if empty |
|
|
272
|
+
Parse an Excel file from Uint8Array.
|
|
153
273
|
|
|
154
|
-
|
|
274
|
+
```typescript
|
|
275
|
+
const result = parseExcel(bytes, {
|
|
276
|
+
sheet: 0, // Sheet index or name (default: 0)
|
|
277
|
+
limit: 1000, // Max rows to parse (default: all)
|
|
278
|
+
skipRows: 0, // Rows to skip from start
|
|
279
|
+
hasHeaders: true, // Treat first row as headers
|
|
280
|
+
});
|
|
281
|
+
```
|
|
155
282
|
|
|
156
|
-
|
|
283
|
+
**Returns:**
|
|
157
284
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
285
|
+
```typescript
|
|
286
|
+
{
|
|
287
|
+
headers: string[]; // Column headers
|
|
288
|
+
rows: CellValue[][]; // Row data
|
|
289
|
+
rowCount: number; // Total rows parsed
|
|
290
|
+
sheetName: string; // Sheet name
|
|
291
|
+
}
|
|
292
|
+
```
|
|
162
293
|
|
|
163
|
-
### getSheetNames(
|
|
294
|
+
### getSheetNames(bytes)
|
|
164
295
|
|
|
165
296
|
Get list of sheet names in workbook.
|
|
166
297
|
|
|
298
|
+
```typescript
|
|
299
|
+
const sheets = getSheetNames(bytes);
|
|
300
|
+
// ["Sheet1", "Sheet2", "Data"]
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
167
305
|
## 🏎 Performance
|
|
168
306
|
|
|
169
|
-
|
|
307
|
+
Tested with 100,000 rows:
|
|
308
|
+
|
|
309
|
+
| Metric | SheetJS | Saurus-Excel | Improvement |
|
|
310
|
+
| ------------ | ------- | ------------ | --------------- |
|
|
311
|
+
| Parse Time | ~15s | ~2s | **7.5x faster** |
|
|
312
|
+
| Memory Usage | ~800MB | ~100MB | **8x less** |
|
|
313
|
+
| Bundle Size | ~300KB | ~150KB | **2x smaller** |
|
|
170
314
|
|
|
171
|
-
|
|
172
|
-
| ------------ | ------- | ----------- | --------------- |
|
|
173
|
-
| Parse Time | ~15s | ~2s | **7.5x faster** |
|
|
174
|
-
| Memory Usage | ~800MB | ~100MB | **8x less** |
|
|
175
|
-
| Bundle Size | ~300KB | ~150KB | **2x smaller** |
|
|
315
|
+
---
|
|
176
316
|
|
|
177
317
|
## 📝 License
|
|
178
318
|
|
|
179
|
-
MIT ©
|
|
319
|
+
MIT © trietcn
|
|
180
320
|
|
|
181
321
|
---
|
|
182
322
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,77 +1,115 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export { ReactNode } from 'react';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interface UseExcelParserState<T = CellValue[][]> {
|
|
8
|
-
/** Parsed data */
|
|
9
|
-
data: T | null;
|
|
10
|
-
/** Whether parsing is in progress */
|
|
11
|
-
isLoading: boolean;
|
|
12
|
-
/** Parse progress (0-100) */
|
|
13
|
-
progress: number;
|
|
14
|
-
/** Error if parsing failed */
|
|
15
|
-
error: Error | null;
|
|
16
|
-
/** Sheet name */
|
|
17
|
-
sheetName: string | null;
|
|
18
|
-
/** Row count */
|
|
5
|
+
type CellValue = string | number | boolean | null;
|
|
6
|
+
interface ParseResult {
|
|
7
|
+
headers: string[];
|
|
8
|
+
rows: CellValue[][];
|
|
19
9
|
rowCount: number;
|
|
10
|
+
sheetName: string;
|
|
11
|
+
}
|
|
12
|
+
interface ParseOptions {
|
|
13
|
+
sheet?: string | number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
skipRows?: number;
|
|
16
|
+
hasHeaders?: boolean;
|
|
20
17
|
}
|
|
21
|
-
interface
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
interface UseExcelParserState {
|
|
19
|
+
data: ParseResult | null;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: Error | null;
|
|
22
|
+
progress: number;
|
|
24
23
|
}
|
|
25
|
-
interface UseExcelParserReturn
|
|
26
|
-
|
|
27
|
-
parse: (file: File, options?: UseExcelParserOptions) => Promise<void>;
|
|
28
|
-
/** Reset state */
|
|
24
|
+
interface UseExcelParserReturn extends UseExcelParserState {
|
|
25
|
+
parse: (file: File, options?: ParseOptions) => Promise<ParseResult>;
|
|
29
26
|
reset: () => void;
|
|
27
|
+
ready: boolean;
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
30
|
+
* Provider component for Saurus-Excel
|
|
31
|
+
* Wrap your app or component tree with this
|
|
33
32
|
*
|
|
34
33
|
* @example
|
|
35
34
|
* ```tsx
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* // app/layout.tsx (Next.js App Router)
|
|
36
|
+
* import { ExcelProvider } from 'saurus-excel/react';
|
|
38
37
|
*
|
|
38
|
+
* export default function RootLayout({ children }) {
|
|
39
39
|
* return (
|
|
40
|
-
* <
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* <html>
|
|
41
|
+
* <body>
|
|
42
|
+
* <ExcelProvider>
|
|
43
|
+
* {children}
|
|
44
|
+
* </ExcelProvider>
|
|
45
|
+
* </body>
|
|
46
|
+
* </html>
|
|
44
47
|
* );
|
|
45
48
|
* }
|
|
46
49
|
* ```
|
|
47
50
|
*/
|
|
48
|
-
declare function
|
|
51
|
+
declare function ExcelProvider({ children }: {
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}): react_jsx_runtime.JSX.Element;
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
55
|
+
* Main hook for parsing Excel files
|
|
56
|
+
* Works with or without ExcelProvider
|
|
51
57
|
*
|
|
52
58
|
* @example
|
|
53
59
|
* ```tsx
|
|
54
|
-
* function
|
|
55
|
-
* const {
|
|
60
|
+
* function ImportPage() {
|
|
61
|
+
* const { parse, data, loading, error, ready } = useExcelParser();
|
|
62
|
+
*
|
|
63
|
+
* if (!ready) return <p>Loading parser...</p>;
|
|
56
64
|
*
|
|
57
65
|
* return (
|
|
58
66
|
* <input
|
|
59
67
|
* type="file"
|
|
60
|
-
* onChange={(e) => e.target.files?.[0] &&
|
|
68
|
+
* onChange={(e) => e.target.files?.[0] && parse(e.target.files[0])}
|
|
61
69
|
* />
|
|
62
70
|
* );
|
|
63
71
|
* }
|
|
64
72
|
* ```
|
|
65
73
|
*/
|
|
66
|
-
declare function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
declare function useExcelParser(defaultOptions?: ParseOptions): UseExcelParserReturn;
|
|
75
|
+
/**
|
|
76
|
+
* Hook to get sheet names from Excel file
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* const { getSheetNames, sheets, loading } = useExcelSheets();
|
|
81
|
+
*
|
|
82
|
+
* const handleFile = async (file: File) => {
|
|
83
|
+
* const names = await getSheetNames(file);
|
|
84
|
+
* console.log(names); // ["Sheet1", "Sheet2"]
|
|
85
|
+
* };
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function useExcelSheets(): {
|
|
89
|
+
getSheetNames: (file: File) => Promise<string[]>;
|
|
90
|
+
sheets: string[];
|
|
91
|
+
loading: boolean;
|
|
71
92
|
error: Error | null;
|
|
72
|
-
|
|
73
|
-
/** All rows flattened */
|
|
74
|
-
allRows: CellValue[][];
|
|
93
|
+
ready: boolean;
|
|
75
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Simple drop-in component for file upload
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* <ExcelDropzone
|
|
101
|
+
* onData={(result) => console.log(result)}
|
|
102
|
+
* onError={(err) => console.error(err)}
|
|
103
|
+
* />
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare function ExcelDropzone({ onData, onError, onProgress, options, className, children, }: {
|
|
107
|
+
onData: (result: ParseResult) => void;
|
|
108
|
+
onError?: (error: Error) => void;
|
|
109
|
+
onProgress?: (percent: number) => void;
|
|
110
|
+
options?: ParseOptions;
|
|
111
|
+
className?: string;
|
|
112
|
+
children?: ReactNode;
|
|
113
|
+
}): react_jsx_runtime.JSX.Element;
|
|
76
114
|
|
|
77
|
-
export { useExcelParser,
|
|
115
|
+
export { type CellValue, ExcelDropzone, ExcelProvider, type ParseOptions, type ParseResult, type UseExcelParserReturn, type UseExcelParserState, useExcelParser, useExcelSheets };
|
package/dist/react.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {useState,
|
|
2
|
-
${t.stack}`:r}function te(t){t<132||(w[t]=E,E=t);}function ne(t,e){return t=t>>>0,S().subarray(t/1,t/1+e)}function f(){return (h===null||h.buffer.detached===true||h.buffer.detached===void 0&&h.buffer!==u.memory.buffer)&&(h=new DataView(u.memory.buffer)),h}function U(t,e){return t=t>>>0,se(t,e)}function S(){return (P===null||P.byteLength===0)&&(P=new Uint8Array(u.memory.buffer)),P}function c(t){return w[t]}function x(t){return t==null}function D(t,e){let n=e(t.length*1,1)>>>0;return S().set(t,n/1),p=t.length,n}function O(t,e,n){if(n===void 0){let i=R.encode(t),_=e(i.length,1)>>>0;return S().subarray(_,_+i.length).set(i),p=i.length,_}let r=t.length,s=e(r,1)>>>0,a=S(),o=0;for(;o<r;o++){let i=t.charCodeAt(o);if(i>127)break;a[s+o]=i;}if(o!==r){o!==0&&(t=t.slice(o)),s=n(s,r,r=o+t.length*3,1)>>>0;let i=S().subarray(s+o,s+r),_=R.encodeInto(t,i);o+=_.written,s=n(s,r,o,1)>>>0;}return p=o,s}function m(t){let e=c(t);return te(t),e}function se(t,e){return W+=e,W>=re&&(T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),T.decode(),W=e),T.decode(S().subarray(t,t+e))}function q(t,e){return u=t.exports,h=null,P=null,u.__wbindgen_start(),u}async function ae(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(s){if(t.ok&&n(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}function n(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function ie(t){if(u!==void 0)return u;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=$();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let n=new WebAssembly.Instance(t,e);return q(n)}async function ce(t){if(u!==void 0)return u;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),t===void 0&&(t=new URL("excelsaurus_bg.wasm",import.meta.url));let e=$();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await ae(await t,e);return q(n)}var h,P,w,E,T,re,W,R,p,u,z=N(()=>{h=null;P=null;w=new Array(128).fill(void 0);w.push(void 0,null,true,false);E=w.length;T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});T.decode();re=2146435072,W=0;R=new TextEncoder;"encodeInto"in R||(R.encodeInto=function(t,e){let n=R.encode(t);return e.set(n),{read:t.length,written:n.length}});p=0;});async function ue(){V||(M||(M=(async()=>{let t=await Promise.resolve().then(()=>(z(),H));await t.default(),V=t;})()),await M);}async function le(){if(await ue(),!V)throw new Error("Failed to initialize ExcelSaurus Wasm module");return V}async function C(t,e={}){let n=await le(),r=await fe(t);return n.parseExcel(r,{sheet:e.sheet?.toString(),limit:e.limit,skipRows:e.skipRows,hasHeaders:e.hasHeaders})}async function J(t,e,n={}){let r=await C(t,n),s=[],a=[];for(let o=0;o<r.rows.length;o++){let i=r.rows[o],_={},g=[];for(let l of e.fields){let A=typeof l.column=="number"?l.column:_e(l.column),d=i[A]??null;if((d===null||d==="")&&l.default!==void 0&&(d=l.default),l.required&&(d===null||d==="")){g.push({field:l.name,message:"Field is required"});continue}if(d!==null&&d!==""&&(de(d,l.type)||g.push({field:l.name,message:`Expected ${l.type}, got ${typeof d}`,value:String(d)}),l.validate)){let k=be(l.validate,d);k&&g.push({field:l.name,message:k,value:String(d)});}_[l.name]=d;}g.length>0&&(a.push({valid:false,rowIndex:o,errors:g}),!e.skipInvalid)||s.push(_);}return {data:s,errors:a.length>0?a:void 0,rowCount:s.length,sheetName:r.sheetName}}async function fe(t){if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);let e=await t.arrayBuffer();return new Uint8Array(e)}function _e(t){let e=t.toUpperCase(),n=0;for(let r=0;r<e.length;r++)n=n*26+(e.charCodeAt(r)-64);return n-1}function de(t,e){if(e==="any")return true;switch(e){case "string":return typeof t=="string"||typeof t=="number";case "number":case "integer":return typeof t=="number";case "boolean":return typeof t=="boolean";case "date":case "datetime":return typeof t=="string";default:return true}}function be(t,e){let n=String(e);switch(t.toLowerCase()){case "email":return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?null:"Invalid email format";case "phone":return /^\+?[0-9\s\-()]{7,20}$/.test(n)?null:"Invalid phone number";case "url":return /^https?:\/\/[^\s]+$/.test(n)?null:"Invalid URL";case "nonempty":return n.trim()!==""?null:"Value cannot be empty";default:return null}}var V,M,B=N(()=>{V=null,M=null;});var X={};L(X,{collectStream:()=>we,createExcelStream:()=>ge});async function ge(t,e={}){let n=e.chunkSize??1e3,r=await C(t,{sheet:e.sheet,skipRows:e.skipRows,hasHeaders:e.hasHeaders}),s=r.rows.length,a=Math.ceil(s/n);return {[Symbol.asyncIterator](){let o=0,i=0;return {async next(){if(o>=a)return {done:true,value:void 0};let _=o*n,g=Math.min(_+n,s),l=r.rows.slice(_,g);i+=l.length;let A=o===a-1;if(e.onProgress){let y={rowsProcessed:i,totalRows:s,percent:Math.round(i/s*100),chunkNumber:o+1};e.onProgress(y);}let d={rows:l,chunkIndex:o,isLast:A};return o++,{done:false,value:d}}}}}}async function we(t){let e=[];for await(let n of t)e.push(...n.rows);return e}var Y=N(()=>{B();});B();function Ae(){let[t,e]=useState({data:null,isLoading:false,progress:0,error:null,sheetName:null,rowCount:0}),n=useRef(null),r=useCallback(async(a,o={})=>{n.current?.abort(),n.current=new AbortController,e(i=>({...i,isLoading:true,error:null,progress:0}));try{let i;o.schema?(i=await J(a,o.schema,o),e({data:i.data,isLoading:!1,progress:100,error:null,sheetName:i.sheetName,rowCount:i.rowCount})):(i=await C(a,o),e({data:i.rows,isLoading:!1,progress:100,error:null,sheetName:i.sheetName,rowCount:i.rowCount}));}catch(i){e(_=>({..._,isLoading:false,error:i instanceof Error?i:new Error(String(i))}));}},[]),s=useCallback(()=>{n.current?.abort(),e({data:null,isLoading:false,progress:0,error:null,sheetName:null,rowCount:0});},[]);return {...t,parse:r,reset:s}}function Pe(t=1e3){let[e,n]=useState([]),[r,s]=useState(false),[a,o]=useState(0),[i,_]=useState(null),g=useCallback(async(A,d={})=>{s(true),n([]),o(0),_(null);try{let{createExcelStream:y}=await Promise.resolve().then(()=>(Y(),X)),k=await y(A,{...d,chunkSize:t,onProgress:F=>o(F.percent)});for await(let F of k)n(G=>[...G,F.rows]);}catch(y){_(y instanceof Error?y:new Error(String(y)));}finally{s(false),o(100);}},[t]),l=useCallback(()=>{n([]),o(0),_(null),s(false);},[]);return {stream:g,chunks:e,isStreaming:r,progress:a,error:i,reset:l,allRows:e.flat()}}export{Ae as useExcelParser,Pe as useExcelStream};//# sourceMappingURL=react.js.map
|
|
1
|
+
import {createContext,useState,useEffect,useMemo,useCallback,useContext}from'react';import {jsx,jsxs}from'react/jsx-runtime';var u=null,h=null,E=null;async function P(){if(u)return u;if(h)return h;if(typeof window>"u")throw new Error("Saurus-Excel requires browser environment");return h=(async()=>{try{let e=await import('../pkg/excelsaurus.js');return await e.default(),u=e,e}catch(e){throw E=e instanceof Error?e:new Error(String(e)),E}})(),h}var b=createContext(null);function A({children:e}){let[t,c]=useState(false),[r,o]=useState(null);useEffect(()=>{P().then(()=>c(true)).catch(s=>o(s));},[]);let g=useMemo(()=>({ready:t,error:r,parseExcel:(s,m)=>{if(!u)throw new Error("Wasm not initialized");return u.parseExcel(s,m||{})},getSheetNames:s=>{if(!u)throw new Error("Wasm not initialized");return u.getSheetNames(s)}}),[t,r]);return jsx(b.Provider,{value:g,children:e})}function v(){let e=useContext(b),[t,c]=useState(null);return useEffect(()=>{e||P().then(()=>{c({ready:true,error:null,parseExcel:(r,o)=>u.parseExcel(r,o||{}),getSheetNames:r=>u.getSheetNames(r)});}).catch(r=>{c({ready:false,error:r,parseExcel:()=>{throw r},getSheetNames:()=>{throw r}});});},[e]),e||t||{ready:false,error:null,parseExcel:()=>{throw new Error("Initializing...")},getSheetNames:()=>{throw new Error("Initializing...")}}}function U(e){let t=v(),[c,r]=useState({data:null,loading:false,error:null,progress:0}),o=useCallback(async(s,m)=>{if(!t.ready)throw new Error("Parser not ready. Wait for ready=true or wrap with ExcelProvider");r(l=>({...l,loading:true,error:null,progress:0}));try{r(d=>({...d,progress:30}));let l=await s.arrayBuffer(),a=new Uint8Array(l);r(d=>({...d,progress:60}));let n=t.parseExcel(a,{...e,...m});return r({data:n,loading:!1,error:null,progress:100}),n}catch(l){let a=l instanceof Error?l:new Error(String(l));throw r(n=>({...n,loading:false,error:a,progress:0})),a}},[t,e]),g=useCallback(()=>{r({data:null,loading:false,error:null,progress:0});},[]);return {...c,parse:o,reset:g,ready:t.ready}}function V(){let e=v(),[t,c]=useState([]),[r,o]=useState(false),[g,s]=useState(null);return {getSheetNames:useCallback(async l=>{if(!e.ready)throw new Error("Parser not ready");o(true),s(null);try{let a=new Uint8Array(await l.arrayBuffer()),n=e.getSheetNames(a);return c(n),n}catch(a){let n=a instanceof Error?a:new Error(String(a));throw s(n),n}finally{o(false);}},[e]),sheets:t,loading:r,error:g,ready:e.ready}}function k({onData:e,onError:t,onProgress:c,options:r,className:o,children:g}){let{parse:s,loading:m,ready:l}=U(r),[a,n]=useState(false),d=useCallback(async p=>{try{let i=await s(p);e(i);}catch(i){t?.(i instanceof Error?i:new Error(String(i)));}},[s,e,t]),S=useCallback(p=>{p.preventDefault(),n(false);let i=p.dataTransfer.files[0];i&&d(i);},[d]),C=useCallback(p=>{let i=p.target.files?.[0];i&&d(i);},[d]);return l?jsxs("div",{className:o,onDragOver:p=>{p.preventDefault(),n(true);},onDragLeave:()=>n(false),onDrop:S,style:{border:a?"2px dashed #4f46e5":"2px dashed #d1d5db",borderRadius:"8px",padding:"40px",textAlign:"center",cursor:"pointer",transition:"border-color 0.2s"},onClick:()=>document.getElementById("excel-input")?.click(),children:[jsx("input",{id:"excel-input",type:"file",accept:".xlsx,.xls,.xlsm,.xlsb,.ods",onChange:C,style:{display:"none"}}),g||(m?jsx("p",{children:"Parsing..."}):jsx("p",{children:"Drop Excel file here or click to upload"}))]}):jsx("div",{className:o,children:"Loading parser..."})}export{k as ExcelDropzone,A as ExcelProvider,U as useExcelParser,V as useExcelSheets};//# sourceMappingURL=react.js.map
|
|
3
2
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../pkg/excelsaurus.js","../src/core.ts","../src/streaming.ts","../src/integrations/react.tsx"],"names":["excelsaurus_exports","__export","__wbg_init","getSheetNames","init","initSync","parseExcel","data","retptr","wasm","ptr0","passArray8ToWasm0","len0","WASM_VECTOR_LEN","r0","getDataViewMemory0","r1","r2","takeObject","options","addHeapObject","__wbg_get_imports","arg0","arg1","ret","getStringFromWasm0","getObject","ptr1","passStringToWasm0","len1","v","isLikeNone","debugString","val","obj","deferred0_0","deferred0_1","result","arg2","getArrayU8FromWasm0","heap_next","heap","idx","type","description","name","length","debug","i","builtInMatches","className","dropObject","ptr","len","getUint8ArrayMemory0","cachedDataViewMemory0","decodeText","cachedUint8ArrayMemory0","x","arg","malloc","realloc","buf","cachedTextEncoder","mem","offset","code","view","numBytesDecoded","MAX_SAFARI_DECODE_BYTES","cachedTextDecoder","__wbg_finalize_init","instance","module","__wbg_load","imports","e","expectedResponseType","bytes","module_or_path","init_excelsaurus","__esmMin","initWasm","wasmModule","initPromise","mod","getWasm","input","toUint8Array","parseExcelWithSchema","schema","rawResult","errors","row","rowErrors","field","colIndex","columnLetterToIndex","value","validateType","validatorError","runValidator","buffer","letter","upper","expectedType","validator","str","init_core","streaming_exports","collectStream","createExcelStream","chunkSize","totalRows","totalChunks","currentChunk","rowsProcessed","startIdx","endIdx","rows","isLast","progress","chunk","stream","allRows","init_streaming","useExcelParser","state","setState","useState","abortRef","useRef","parse","useCallback","file","prev","err","reset","useExcelStream","chunks","setChunks","isStreaming","setIsStreaming","setProgress","error","setError","excelStream","p"],"mappings":"gDAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA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AAA,EAA0B,CAAC,GAAGA,CAAAA,CAAMb,CAAAA,CAAM,IAAI,CAAC,EAE9D,CAAA,MAASc,CAAAA,CAAK,CACZS,CAAAA,CAAST,aAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAC,EAC9D,CAAA,OAAE,CACAM,CAAAA,CAAe,KAAK,CAAA,CACpBC,CAAAA,CAAY,GAAG,EACjB,CACF,EACA,CAAC/B,CAAS,CACZ,CAAA,CAEMyB,CAAAA,CAAQJ,WAAAA,CAAY,IAAM,CAC9BO,CAAAA,CAAU,EAAE,CAAA,CACZG,EAAY,CAAC,CAAA,CACbE,CAAAA,CAAS,IAAI,CAAA,CACbH,CAAAA,CAAe,KAAK,EACtB,CAAA,CAAG,EAAE,CAAA,CAEL,OAAO,CACL,MAAA,CAAAnB,CAAAA,CACA,MAAA,CAAAgB,CAAAA,CACA,WAAA,CAAAE,EACA,QAAA,CAAApB,CAAAA,CACA,MAAAuB,CAAAA,CACA,KAAA,CAAAP,EAEA,OAAA,CAASE,CAAAA,CAAO,IAAA,EAClB,CACF","file":"react.js","sourcesContent":["/* @ts-self-types=\"./excelsaurus.d.ts\" */\n\n/**\n * Get list of sheet names in the workbook\n *\n * # Arguments\n * * `data` - Raw bytes of the Excel file\n *\n * # Returns\n * * `Vec<String>` - List of sheet names\n * @param {Uint8Array} data\n * @returns {any}\n */\nexport function getSheetNames(data) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);\n const len0 = WASM_VECTOR_LEN;\n wasm.getSheetNames(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n * Initialize panic hook for better error messages in browser console\n */\nexport function init() {\n wasm.init();\n}\n\n/**\n * Parse an Excel file from bytes\n *\n * # Arguments\n * * `data` - Raw bytes of the Excel file\n * * `options` - Parse options (optional)\n *\n * # Returns\n * * `JsValue` - Parsed result as JavaScript object\n * @param {Uint8Array} data\n * @param {any} options\n * @returns {any}\n */\nexport function parseExcel(data, options) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);\n const len0 = WASM_VECTOR_LEN;\n wasm.parseExcel(retptr, ptr0, len0, addHeapObject(options));\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n if (r2) {\n throw takeObject(r1);\n }\n return takeObject(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n },\n __wbg_Number_04624de7d0e8332d: function(arg0) {\n const ret = Number(getObject(arg0));\n return ret;\n },\n __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {\n const ret = String(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {\n const v = getObject(arg1);\n const ret = typeof(v) === 'bigint' ? v : undefined;\n getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);\n },\n __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {\n const v = getObject(arg0);\n const ret = typeof(v) === 'boolean' ? v : undefined;\n return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;\n },\n __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {\n const ret = debugString(getObject(arg1));\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {\n const ret = getObject(arg0) in getObject(arg1);\n return ret;\n },\n __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {\n const ret = typeof(getObject(arg0)) === 'bigint';\n return ret;\n },\n __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {\n const ret = getObject(arg0) === null;\n return ret;\n },\n __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {\n const val = getObject(arg0);\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {\n const ret = getObject(arg0) === undefined;\n return ret;\n },\n __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {\n const ret = getObject(arg0) === getObject(arg1);\n return ret;\n },\n __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {\n const ret = getObject(arg0) == getObject(arg1);\n return ret;\n },\n __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'number' ? obj : undefined;\n getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);\n },\n __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {\n const obj = getObject(arg1);\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_export3(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {\n const ret = getObject(arg0)[getObject(arg1)];\n return addHeapObject(ret);\n },\n __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof ArrayBuffer;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {\n let result;\n try {\n result = getObject(arg0) instanceof Uint8Array;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {\n const ret = Number.isSafeInteger(getObject(arg0));\n return ret;\n },\n __wbg_length_32ed9a279acd054c: function(arg0) {\n const ret = getObject(arg0).length;\n return ret;\n },\n __wbg_new_361308b2356cecd0: function() {\n const ret = new Object();\n return addHeapObject(ret);\n },\n __wbg_new_3eb36ae241fe6f44: function() {\n const ret = new Array();\n return addHeapObject(ret);\n },\n __wbg_new_8a6f238a6ece86ea: function() {\n const ret = new Error();\n return addHeapObject(ret);\n },\n __wbg_new_dd2b680c8bf6ae29: function(arg0) {\n const ret = new Uint8Array(getObject(arg0));\n return addHeapObject(ret);\n },\n __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));\n },\n __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {\n getObject(arg0)[takeObject(arg1)] = takeObject(arg2);\n },\n __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {\n getObject(arg0)[arg1 >>> 0] = takeObject(arg2);\n },\n __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {\n const ret = getObject(arg1).stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbindgen_cast_0000000000000001: function(arg0) {\n // Cast intrinsic for `F64 -> Externref`.\n const ret = arg0;\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n },\n __wbindgen_cast_0000000000000003: function(arg0) {\n // Cast intrinsic for `U64 -> Externref`.\n const ret = BigInt.asUintN(64, arg0);\n return addHeapObject(ret);\n },\n __wbindgen_object_clone_ref: function(arg0) {\n const ret = getObject(arg0);\n return addHeapObject(ret);\n },\n __wbindgen_object_drop_ref: function(arg0) {\n takeObject(arg0);\n },\n };\n return {\n __proto__: null,\n \"./excelsaurus_bg.js\": import0,\n };\n}\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches && builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nfunction dropObject(idx) {\n if (idx < 132) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap = new Array(128).fill(undefined);\nheap.push(undefined, null, true, false);\n\nlet heap_next = heap.length;\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('excelsaurus_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","/**\n * Core parsing functions\n */\n\nimport type { ParseOptions, ParseResult, Schema, SchemaParseResult, CellValue } from \"./types\";\n\n// Wasm module instance\nlet wasmModule: typeof import(\"../pkg/excelsaurus\") | null = null;\nlet initPromise: Promise<void> | null = null;\n\n/**\n * Initialize the Wasm module\n * This is called automatically on first use\n */\nasync function initWasm(): Promise<void> {\n if (wasmModule) return;\n\n if (!initPromise) {\n initPromise = (async () => {\n // Dynamic import of wasm module\n const mod = await import(\"../pkg/excelsaurus\");\n await mod.default();\n wasmModule = mod;\n })();\n }\n\n await initPromise;\n}\n\n/**\n * Ensure wasm is initialized and get the module\n */\nasync function getWasm() {\n await initWasm();\n if (!wasmModule) {\n throw new Error(\"Failed to initialize ExcelSaurus Wasm module\");\n }\n return wasmModule;\n}\n\n/**\n * Parse an Excel file and return raw data\n *\n * @example\n * ```ts\n * const file = event.target.files[0];\n * const result = await parseExcel(file);\n * console.log(result.rows);\n * ```\n */\nexport async function parseExcel(\n input: File | ArrayBuffer | Uint8Array,\n options: ParseOptions = {}\n): Promise<ParseResult> {\n const wasm = await getWasm();\n const bytes = await toUint8Array(input);\n\n const result = wasm.parseExcel(bytes, {\n sheet: options.sheet?.toString(),\n limit: options.limit,\n skipRows: options.skipRows,\n hasHeaders: options.hasHeaders,\n });\n\n return result as ParseResult;\n}\n\n/**\n * Parse an Excel file with schema validation\n *\n * @example\n * ```ts\n * const result = await parseExcelWithSchema(file, {\n * fields: [\n * { name: 'name', column: 0, type: 'string', required: true },\n * { name: 'email', column: 1, type: 'string', validate: 'email' },\n * { name: 'age', column: 2, type: 'number' },\n * ]\n * });\n * console.log(result.data);\n * ```\n */\nexport async function parseExcelWithSchema<T extends Record<string, CellValue>>(\n input: File | ArrayBuffer | Uint8Array,\n schema: Schema,\n options: ParseOptions = {}\n): Promise<SchemaParseResult<T>> {\n // First, parse the raw data\n const rawResult = await parseExcel(input, options);\n\n // Then apply schema validation in JS\n // (This will be moved to Rust in a future version for better performance)\n const data: T[] = [];\n const errors: { valid: boolean; rowIndex: number; errors: { field: string; message: string; value?: string }[] }[] = [];\n\n for (let i = 0; i < rawResult.rows.length; i++) {\n const row = rawResult.rows[i];\n const obj: Record<string, CellValue> = {};\n const rowErrors: { field: string; message: string; value?: string }[] = [];\n\n for (const field of schema.fields) {\n const colIndex = typeof field.column === \"number\" \n ? field.column \n : columnLetterToIndex(field.column);\n \n let value = row[colIndex] ?? null;\n\n // Apply default if empty\n if ((value === null || value === \"\") && field.default !== undefined) {\n value = field.default;\n }\n\n // Check required\n if (field.required && (value === null || value === \"\")) {\n rowErrors.push({\n field: field.name,\n message: \"Field is required\",\n });\n continue;\n }\n\n // Validate type (basic)\n if (value !== null && value !== \"\") {\n const typeValid = validateType(value, field.type);\n if (!typeValid) {\n rowErrors.push({\n field: field.name,\n message: `Expected ${field.type}, got ${typeof value}`,\n value: String(value),\n });\n }\n\n // Run validator\n if (field.validate) {\n const validatorError = runValidator(field.validate, value);\n if (validatorError) {\n rowErrors.push({\n field: field.name,\n message: validatorError,\n value: String(value),\n });\n }\n }\n }\n\n obj[field.name] = value;\n }\n\n if (rowErrors.length > 0) {\n errors.push({ valid: false, rowIndex: i, errors: rowErrors });\n if (!schema.skipInvalid) {\n continue;\n }\n }\n\n data.push(obj as T);\n }\n\n return {\n data,\n errors: errors.length > 0 ? errors : undefined,\n rowCount: data.length,\n sheetName: rawResult.sheetName,\n };\n}\n\n/**\n * Get list of sheet names in a workbook\n */\nexport async function getSheetNames(\n input: File | ArrayBuffer | Uint8Array\n): Promise<string[]> {\n const wasm = await getWasm();\n const bytes = await toUint8Array(input);\n return wasm.getSheetNames(bytes) as string[];\n}\n\n// Helper functions\n\nasync function toUint8Array(input: File | ArrayBuffer | Uint8Array): Promise<Uint8Array> {\n if (input instanceof Uint8Array) {\n return input;\n }\n if (input instanceof ArrayBuffer) {\n return new Uint8Array(input);\n }\n // File\n const buffer = await input.arrayBuffer();\n return new Uint8Array(buffer);\n}\n\nfunction columnLetterToIndex(letter: string): number {\n const upper = letter.toUpperCase();\n let result = 0;\n for (let i = 0; i < upper.length; i++) {\n result = result * 26 + (upper.charCodeAt(i) - 64);\n }\n return result - 1;\n}\n\nfunction validateType(value: CellValue, expectedType: string): boolean {\n if (expectedType === \"any\") return true;\n \n switch (expectedType) {\n case \"string\":\n return typeof value === \"string\" || typeof value === \"number\";\n case \"number\":\n case \"integer\":\n return typeof value === \"number\";\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"date\":\n case \"datetime\":\n return typeof value === \"string\"; // Dates are strings from Excel\n default:\n return true;\n }\n}\n\nfunction runValidator(validator: string, value: CellValue): string | null {\n const str = String(value);\n \n switch (validator.toLowerCase()) {\n case \"email\":\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(str) ? null : \"Invalid email format\";\n case \"phone\":\n return /^\\+?[0-9\\s\\-()]{7,20}$/.test(str) ? null : \"Invalid phone number\";\n case \"url\":\n return /^https?:\\/\\/[^\\s]+$/.test(str) ? null : \"Invalid URL\";\n case \"nonempty\":\n return str.trim() !== \"\" ? null : \"Value cannot be empty\";\n default:\n return null;\n }\n}\n","/**\n * Streaming API for large Excel files\n */\n\nimport type { StreamOptions, StreamProgress, RowChunk, CellValue } from \"./types\";\nimport { parseExcel } from \"./core\";\n\n/**\n * Create an async iterator for streaming Excel data\n *\n * @example\n * ```ts\n * const stream = await createExcelStream(file, {\n * chunkSize: 1000,\n * onProgress: (p) => console.log(`${p.percent}%`)\n * });\n *\n * for await (const chunk of stream) {\n * await processChunk(chunk.rows);\n * }\n * ```\n */\nexport async function createExcelStream(\n input: File | ArrayBuffer | Uint8Array,\n options: StreamOptions = {}\n): Promise<AsyncIterable<RowChunk>> {\n const chunkSize = options.chunkSize ?? 1000;\n\n // For now, parse all data and chunk it\n // In future, this will use true streaming from Rust\n const result = await parseExcel(input, {\n sheet: options.sheet,\n skipRows: options.skipRows,\n hasHeaders: options.hasHeaders,\n });\n\n const totalRows = result.rows.length;\n const totalChunks = Math.ceil(totalRows / chunkSize);\n\n return {\n [Symbol.asyncIterator](): AsyncIterator<RowChunk> {\n let currentChunk = 0;\n let rowsProcessed = 0;\n\n return {\n async next(): Promise<IteratorResult<RowChunk>> {\n if (currentChunk >= totalChunks) {\n return { done: true, value: undefined };\n }\n\n const startIdx = currentChunk * chunkSize;\n const endIdx = Math.min(startIdx + chunkSize, totalRows);\n const rows = result.rows.slice(startIdx, endIdx);\n\n rowsProcessed += rows.length;\n const isLast = currentChunk === totalChunks - 1;\n\n // Call progress callback\n if (options.onProgress) {\n const progress: StreamProgress = {\n rowsProcessed,\n totalRows,\n percent: Math.round((rowsProcessed / totalRows) * 100),\n chunkNumber: currentChunk + 1,\n };\n options.onProgress(progress);\n }\n\n const chunk: RowChunk = {\n rows,\n chunkIndex: currentChunk,\n isLast,\n };\n\n currentChunk++;\n return { done: false, value: chunk };\n },\n };\n },\n };\n}\n\n/**\n * Collect all chunks from a stream into a single array\n * Useful for testing or when you need all data at once\n */\nexport async function collectStream(\n stream: AsyncIterable<RowChunk>\n): Promise<CellValue[][]> {\n const allRows: CellValue[][] = [];\n for await (const chunk of stream) {\n allRows.push(...chunk.rows);\n }\n return allRows;\n}\n","/**\n * React integration for ExcelSaurus\n */\n\nimport { useState, useCallback, useRef } from \"react\";\nimport type { ParseOptions, ParseResult, Schema, SchemaParseResult, CellValue } from \"../types\";\nimport { parseExcel, parseExcelWithSchema } from \"../core\";\n\ninterface UseExcelParserState<T = CellValue[][]> {\n /** Parsed data */\n data: T | null;\n /** Whether parsing is in progress */\n isLoading: boolean;\n /** Parse progress (0-100) */\n progress: number;\n /** Error if parsing failed */\n error: Error | null;\n /** Sheet name */\n sheetName: string | null;\n /** Row count */\n rowCount: number;\n}\n\ninterface UseExcelParserOptions extends ParseOptions {\n /** Schema for typed parsing */\n schema?: Schema;\n}\n\ninterface UseExcelParserReturn<T = CellValue[][]> extends UseExcelParserState<T> {\n /** Parse a file */\n parse: (file: File, options?: UseExcelParserOptions) => Promise<void>;\n /** Reset state */\n reset: () => void;\n}\n\n/**\n * React hook for parsing Excel files\n *\n * @example\n * ```tsx\n * function ImportComponent() {\n * const { parse, data, isLoading, error } = useExcelParser();\n *\n * return (\n * <input\n * type=\"file\"\n * onChange={(e) => e.target.files?.[0] && parse(e.target.files[0])}\n * />\n * );\n * }\n * ```\n */\nexport function useExcelParser<T extends Record<string, CellValue> = Record<string, CellValue>>(): UseExcelParserReturn<T[] | CellValue[][]> {\n const [state, setState] = useState<UseExcelParserState<T[] | CellValue[][]>>({\n data: null,\n isLoading: false,\n progress: 0,\n error: null,\n sheetName: null,\n rowCount: 0,\n });\n\n const abortRef = useRef<AbortController | null>(null);\n\n const parse = useCallback(async (file: File, options: UseExcelParserOptions = {}) => {\n // Cancel any in-progress parse\n abortRef.current?.abort();\n abortRef.current = new AbortController();\n\n setState((prev: UseExcelParserState<T[] | CellValue[][]>) => ({\n ...prev,\n isLoading: true,\n error: null,\n progress: 0,\n }));\n\n try {\n let result: ParseResult | SchemaParseResult<T>;\n\n if (options.schema) {\n result = await parseExcelWithSchema<T>(file, options.schema, options);\n setState({\n data: (result as SchemaParseResult<T>).data,\n isLoading: false,\n progress: 100,\n error: null,\n sheetName: result.sheetName,\n rowCount: result.rowCount,\n });\n } else {\n result = await parseExcel(file, options);\n setState({\n data: (result as ParseResult).rows,\n isLoading: false,\n progress: 100,\n error: null,\n sheetName: result.sheetName,\n rowCount: result.rowCount,\n });\n }\n } catch (err) {\n setState((prev: UseExcelParserState<T[] | CellValue[][]>) => ({\n ...prev,\n isLoading: false,\n error: err instanceof Error ? err : new Error(String(err)),\n }));\n }\n }, []);\n\n const reset = useCallback(() => {\n abortRef.current?.abort();\n setState({\n data: null,\n isLoading: false,\n progress: 0,\n error: null,\n sheetName: null,\n rowCount: 0,\n });\n }, []);\n\n return {\n ...state,\n parse,\n reset,\n };\n}\n\n/**\n * React hook for streaming Excel files\n *\n * @example\n * ```tsx\n * function StreamingImport() {\n * const { stream, chunks, progress, isStreaming } = useExcelStream();\n *\n * return (\n * <input\n * type=\"file\"\n * onChange={(e) => e.target.files?.[0] && stream(e.target.files[0])}\n * />\n * );\n * }\n * ```\n */\nexport function useExcelStream(chunkSize = 1000) {\n const [chunks, setChunks] = useState<CellValue[][][]>([]);\n const [isStreaming, setIsStreaming] = useState(false);\n const [progress, setProgress] = useState(0);\n const [error, setError] = useState<Error | null>(null);\n\n const stream = useCallback(\n async (file: File, options: ParseOptions = {}) => {\n setIsStreaming(true);\n setChunks([]);\n setProgress(0);\n setError(null);\n\n try {\n const { createExcelStream } = await import(\"../streaming\");\n\n const excelStream = await createExcelStream(file, {\n ...options,\n chunkSize,\n onProgress: (p) => setProgress(p.percent),\n });\n\n for await (const chunk of excelStream) {\n setChunks((prev: CellValue[][][]) => [...prev, chunk.rows]);\n }\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsStreaming(false);\n setProgress(100);\n }\n },\n [chunkSize]\n );\n\n const reset = useCallback(() => {\n setChunks([]);\n setProgress(0);\n setError(null);\n setIsStreaming(false);\n }, []);\n\n return {\n stream,\n chunks,\n isStreaming,\n progress,\n error,\n reset,\n /** All rows flattened */\n allRows: chunks.flat(),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/integrations/react.tsx"],"names":["wasmModule","wasmPromise","wasmError","initWasm","mod","err","WasmContext","createContext","ExcelProvider","children","ready","setReady","useState","error","setError","useEffect","value","useMemo","bytes","options","jsx","useWasm","context","useContext","standalone","setStandalone","opts","useExcelParser","defaultOptions","wasm","state","setState","parse","useCallback","file","prev","arrayBuffer","result","reset","useExcelSheets","sheets","setSheets","loading","setLoading","names","e","ExcelDropzone","onData","onError","onProgress","className","dragOver","setDragOver","handleFile","handleDrop","handleChange","jsxs"],"mappings":"6HAgDA,IAAIA,CAAAA,CAAkB,IAAA,CAClBC,CAAAA,CAAmC,IAAA,CACnCC,EAA0B,IAAA,CAK9B,eAAeC,GAAyB,CAEtC,GAAIH,EAAY,OAAOA,CAAAA,CAGvB,GAAIC,CAAAA,CAAa,OAAOA,EAGxB,GAAI,OAAO,OAAW,GAAA,CACpB,MAAM,IAAI,KAAA,CAAM,2CAA2C,CAAA,CAG7D,OAAAA,CAAAA,CAAAA,CAAe,SAAY,CACzB,GAAI,CAGF,IAAMG,CAAAA,CAAM,aAAuC,uBAAuB,CAAA,CAC1E,aAAMA,CAAAA,CAAI,OAAA,GACVJ,CAAAA,CAAaI,CAAAA,CACNA,CACT,CAAA,MAASC,CAAAA,CAAK,CACZ,MAAAH,CAAAA,CAAYG,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,MAAM,MAAA,CAAOA,CAAG,CAAC,CAAA,CACxDH,CACR,CACF,CAAA,GAAG,CAEID,CACT,CAUA,IAAMK,EAAcC,aAAAA,CAAuC,IAAI,EAwBxD,SAASC,CAAAA,CAAc,CAAE,QAAA,CAAAC,CAAS,CAAA,CAA4B,CACnE,GAAM,CAACC,EAAOC,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6BAAA,CACP,SAAUmC,CAAAA,CACV,KAAA,CAAO,CAAE,OAAA,CAAS,MAAO,EAC3B,CAAA,CACC9C,CAAAA,GACCiC,CAAAA,CACItB,GAAAA,CAAC,GAAA,CAAA,CAAE,QAAA,CAAA,YAAA,CAAU,EACbA,GAAAA,CAAC,GAAA,CAAA,CAAE,mDAAuC,CAAA,CAAA,CAAA,CAElD,CAAA,CA/BOA,IAAC,KAAA,CAAA,CAAI,SAAA,CAAW8B,CAAAA,CAAW,QAAA,CAAA,mBAAA,CAAiB,CAiCvD","file":"react.js","sourcesContent":["/**\n * React integration for Saurus-Excel\n * Plug-and-play hooks for React 19 / Next.js\n */\n\n\"use client\"; // Next.js App Router support\n\nimport { \n useState, \n useCallback, \n useEffect, \n createContext, \n useContext,\n useMemo,\n type ReactNode \n} from \"react\";\n\n// Types\nexport type CellValue = string | number | boolean | null;\n\nexport interface ParseResult {\n headers: string[];\n rows: CellValue[][];\n rowCount: number;\n sheetName: string;\n}\n\nexport interface ParseOptions {\n sheet?: string | number;\n limit?: number;\n skipRows?: number;\n hasHeaders?: boolean;\n}\n\nexport interface UseExcelParserState {\n data: ParseResult | null;\n loading: boolean;\n error: Error | null;\n progress: number;\n}\n\nexport interface UseExcelParserReturn extends UseExcelParserState {\n parse: (file: File, options?: ParseOptions) => Promise<ParseResult>;\n reset: () => void;\n ready: boolean;\n}\n\n// Wasm module state\nlet wasmModule: any = null;\nlet wasmPromise: Promise<any> | null = null;\nlet wasmError: Error | null = null;\n\n/**\n * Initialize Wasm module (singleton)\n */\nasync function initWasm(): Promise<any> {\n // Already initialized\n if (wasmModule) return wasmModule;\n \n // Already loading\n if (wasmPromise) return wasmPromise;\n \n // SSR check\n if (typeof window === 'undefined') {\n throw new Error('Saurus-Excel requires browser environment');\n }\n\n wasmPromise = (async () => {\n try {\n // Dynamic import for code splitting\n // @ts-ignore - pkg is generated at build time\n const mod = await import(/* webpackIgnore: true */ '../pkg/excelsaurus.js');\n await mod.default();\n wasmModule = mod;\n return mod;\n } catch (err) {\n wasmError = err instanceof Error ? err : new Error(String(err));\n throw wasmError;\n }\n })();\n\n return wasmPromise;\n}\n\n// Context for Wasm state\ninterface WasmContextValue {\n ready: boolean;\n error: Error | null;\n parseExcel: (bytes: Uint8Array, options?: ParseOptions) => ParseResult;\n getSheetNames: (bytes: Uint8Array) => string[];\n}\n\nconst WasmContext = createContext<WasmContextValue | null>(null);\n\n/**\n * Provider component for Saurus-Excel\n * Wrap your app or component tree with this\n * \n * @example\n * ```tsx\n * // app/layout.tsx (Next.js App Router)\n * import { ExcelProvider } from 'saurus-excel/react';\n * \n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <ExcelProvider>\n * {children}\n * </ExcelProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function ExcelProvider({ children }: { children: ReactNode }) {\n const [ready, setReady] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n initWasm()\n .then(() => setReady(true))\n .catch((err) => setError(err));\n }, []);\n\n const value = useMemo<WasmContextValue>(() => ({\n ready,\n error,\n parseExcel: (bytes: Uint8Array, options?: ParseOptions) => {\n if (!wasmModule) throw new Error('Wasm not initialized');\n return wasmModule.parseExcel(bytes, options || {});\n },\n getSheetNames: (bytes: Uint8Array) => {\n if (!wasmModule) throw new Error('Wasm not initialized');\n return wasmModule.getSheetNames(bytes);\n }\n }), [ready, error]);\n\n return (\n <WasmContext.Provider value={value}>\n {children}\n </WasmContext.Provider>\n );\n}\n\n/**\n * Hook to access Wasm context\n */\nfunction useWasm(): WasmContextValue {\n const context = useContext(WasmContext);\n \n // If no provider, initialize standalone\n const [standalone, setStandalone] = useState<WasmContextValue | null>(null);\n \n useEffect(() => {\n if (!context) {\n initWasm()\n .then(() => {\n setStandalone({\n ready: true,\n error: null,\n parseExcel: (bytes, opts) => wasmModule.parseExcel(bytes, opts || {}),\n getSheetNames: (bytes) => wasmModule.getSheetNames(bytes)\n });\n })\n .catch((err) => {\n setStandalone({\n ready: false,\n error: err,\n parseExcel: () => { throw err; },\n getSheetNames: () => { throw err; }\n });\n });\n }\n }, [context]);\n\n if (context) return context;\n \n return standalone || {\n ready: false,\n error: null,\n parseExcel: () => { throw new Error('Initializing...'); },\n getSheetNames: () => { throw new Error('Initializing...'); }\n };\n}\n\n/**\n * Main hook for parsing Excel files\n * Works with or without ExcelProvider\n * \n * @example\n * ```tsx\n * function ImportPage() {\n * const { parse, data, loading, error, ready } = useExcelParser();\n * \n * if (!ready) return <p>Loading parser...</p>;\n * \n * return (\n * <input \n * type=\"file\" \n * onChange={(e) => e.target.files?.[0] && parse(e.target.files[0])}\n * />\n * );\n * }\n * ```\n */\nexport function useExcelParser(defaultOptions?: ParseOptions): UseExcelParserReturn {\n const wasm = useWasm();\n const [state, setState] = useState<UseExcelParserState>({\n data: null,\n loading: false,\n error: null,\n progress: 0,\n });\n\n const parse = useCallback(async (file: File, options?: ParseOptions): Promise<ParseResult> => {\n if (!wasm.ready) {\n throw new Error('Parser not ready. Wait for ready=true or wrap with ExcelProvider');\n }\n\n setState(prev => ({ ...prev, loading: true, error: null, progress: 0 }));\n\n try {\n // Read file\n setState(prev => ({ ...prev, progress: 30 }));\n const arrayBuffer = await file.arrayBuffer();\n const bytes = new Uint8Array(arrayBuffer);\n\n // Parse\n setState(prev => ({ ...prev, progress: 60 }));\n const result = wasm.parseExcel(bytes, { ...defaultOptions, ...options });\n\n setState({\n data: result,\n loading: false,\n error: null,\n progress: 100,\n });\n\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setState(prev => ({ ...prev, loading: false, error, progress: 0 }));\n throw error;\n }\n }, [wasm, defaultOptions]);\n\n const reset = useCallback(() => {\n setState({\n data: null,\n loading: false,\n error: null,\n progress: 0,\n });\n }, []);\n\n return {\n ...state,\n parse,\n reset,\n ready: wasm.ready,\n };\n}\n\n/**\n * Hook to get sheet names from Excel file\n * \n * @example\n * ```tsx\n * const { getSheetNames, sheets, loading } = useExcelSheets();\n * \n * const handleFile = async (file: File) => {\n * const names = await getSheetNames(file);\n * console.log(names); // [\"Sheet1\", \"Sheet2\"]\n * };\n * ```\n */\nexport function useExcelSheets() {\n const wasm = useWasm();\n const [sheets, setSheets] = useState<string[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const getSheetNames = useCallback(async (file: File): Promise<string[]> => {\n if (!wasm.ready) {\n throw new Error('Parser not ready');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const bytes = new Uint8Array(await file.arrayBuffer());\n const names = wasm.getSheetNames(bytes);\n setSheets(names);\n return names;\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n throw e;\n } finally {\n setLoading(false);\n }\n }, [wasm]);\n\n return {\n getSheetNames,\n sheets,\n loading,\n error,\n ready: wasm.ready,\n };\n}\n\n/**\n * Simple drop-in component for file upload\n * \n * @example\n * ```tsx\n * <ExcelDropzone \n * onData={(result) => console.log(result)}\n * onError={(err) => console.error(err)}\n * />\n * ```\n */\nexport function ExcelDropzone({\n onData,\n onError,\n onProgress,\n options,\n className,\n children,\n}: {\n onData: (result: ParseResult) => void;\n onError?: (error: Error) => void;\n onProgress?: (percent: number) => void;\n options?: ParseOptions;\n className?: string;\n children?: ReactNode;\n}) {\n const { parse, loading, ready } = useExcelParser(options);\n const [dragOver, setDragOver] = useState(false);\n\n const handleFile = useCallback(async (file: File) => {\n try {\n const result = await parse(file);\n onData(result);\n } catch (err) {\n onError?.(err instanceof Error ? err : new Error(String(err)));\n }\n }, [parse, onData, onError]);\n\n const handleDrop = useCallback((e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n const file = e.dataTransfer.files[0];\n if (file) handleFile(file);\n }, [handleFile]);\n\n const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n const file = e.target.files?.[0];\n if (file) handleFile(file);\n }, [handleFile]);\n\n if (!ready) {\n return <div className={className}>Loading parser...</div>;\n }\n\n return (\n <div\n className={className}\n onDragOver={(e) => { e.preventDefault(); setDragOver(true); }}\n onDragLeave={() => setDragOver(false)}\n onDrop={handleDrop}\n style={{\n border: dragOver ? '2px dashed #4f46e5' : '2px dashed #d1d5db',\n borderRadius: '8px',\n padding: '40px',\n textAlign: 'center',\n cursor: 'pointer',\n transition: 'border-color 0.2s',\n }}\n onClick={() => document.getElementById('excel-input')?.click()}\n >\n <input\n id=\"excel-input\"\n type=\"file\"\n accept=\".xlsx,.xls,.xlsm,.xlsb,.ods\"\n onChange={handleChange}\n style={{ display: 'none' }}\n />\n {children || (\n loading \n ? <p>Parsing...</p>\n : <p>Drop Excel file here or click to upload</p>\n )}\n </div>\n );\n}\n\n// Re-export types\nexport type { ReactNode };\n"]}
|