delightloop-spreadsheet-wasm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # @delightloop/spreadsheet-wasm
2
+
3
+ High-performance spreadsheet engine compiled to WebAssembly using Rust.
4
+
5
+ ## Features
6
+
7
+ - **High-Performance CSV Parsing**: Parse large CSV files efficiently
8
+ - **Multi-Column Sorting**: Stable sort with multiple columns support
9
+ - **Advanced Filtering**: Text, number, date, and enum filters
10
+ - **Global Search**: Fuzzy matching across all cells
11
+ - **Data Validation**: Email, phone, URL, LinkedIn validation
12
+ - **Aggregations**: Count, sum, avg, min, max, unique operations
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @delightloop/spreadsheet-wasm
18
+ # or
19
+ pnpm add @delightloop/spreadsheet-wasm
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```typescript
25
+ import init, { SpreadsheetEngine } from '@delightloop/spreadsheet-wasm';
26
+
27
+ // Initialize WASM
28
+ await init();
29
+
30
+ // Create engine instance
31
+ const engine = new SpreadsheetEngine();
32
+
33
+ // Load CSV data
34
+ const response = await fetch('/data.csv');
35
+ const bytes = new Uint8Array(await response.arrayBuffer());
36
+ const result = engine.load_csv(bytes);
37
+
38
+ if (result.success) {
39
+ console.log(`Loaded ${result.rowCount} rows with ${result.columnCount} columns`);
40
+ }
41
+
42
+ // Get rows (paginated)
43
+ const rows = engine.get_rows(0, 100);
44
+
45
+ // Sort by column
46
+ engine.sort([
47
+ { columnId: 'col1', direction: 'asc' },
48
+ { columnId: 'col2', direction: 'desc' },
49
+ ]);
50
+
51
+ // Filter rows
52
+ engine.filter([
53
+ { columnId: 'col1', operator: 'contains', value: 'search term' },
54
+ ]);
55
+
56
+ // Search across all columns
57
+ engine.search('query');
58
+
59
+ // Update cell
60
+ const validation = engine.update_cell('row-id', 'email', 'test@example.com');
61
+ if (validation.valid) {
62
+ console.log('Cell updated successfully');
63
+ }
64
+
65
+ // Export to CSV
66
+ const csvBytes = engine.export_csv();
67
+ ```
68
+
69
+ ## API Reference
70
+
71
+ ### SpreadsheetEngine
72
+
73
+ #### Constructor
74
+
75
+ ```typescript
76
+ const engine = new SpreadsheetEngine();
77
+ ```
78
+
79
+ #### CSV Operations
80
+
81
+ - `load_csv(bytes: Uint8Array): CsvParseResult` - Parse CSV data
82
+ - `export_csv(): Uint8Array` - Export data as CSV
83
+
84
+ #### Data Operations
85
+
86
+ - `set_data(rows: Row[])` - Set all rows
87
+ - `set_columns(columns: ColumnConfig[])` - Set column configuration
88
+ - `get_rows(start: number, count: number): Row[]` - Get paginated rows
89
+ - `get_row(rowId: string): Row | null` - Get single row
90
+ - `get_columns(): ColumnConfig[]` - Get all columns
91
+ - `update_cell(rowId: string, colKey: string, value: any): ValidationResult`
92
+ - `add_row(row: Row): string` - Add row and return ID
93
+ - `delete_rows(rowIds: string[])` - Delete multiple rows
94
+ - `duplicate_rows(rowIds: string[]): string[]` - Duplicate rows
95
+
96
+ #### Column Operations
97
+
98
+ - `add_column(config: ColumnConfig): string` - Add column
99
+ - `update_column(colId: string, config: ColumnConfig)` - Update column
100
+ - `delete_column(colId: string)` - Delete column
101
+ - `reorder_columns(colIds: string[])` - Reorder columns
102
+
103
+ #### Sort/Filter/Search
104
+
105
+ - `sort(configs: SortConfig[])` - Apply sort
106
+ - `filter(configs: FilterConfig[])` - Apply filters
107
+ - `search(query: string)` - Global search
108
+ - `clear_filters()` - Clear all filters, sorts, and search
109
+
110
+ #### Validation
111
+
112
+ - `validate_cell(value: any, dataType: string): ValidationResult`
113
+
114
+ #### Aggregations
115
+
116
+ - `aggregate(colKey: string, op: string): AggregationResult`
117
+ - `get_unique_values(colKey: string): any[]`
118
+
119
+ #### State
120
+
121
+ - `get_total_rows(): number` - Total row count
122
+ - `get_visible_rows(): number` - Visible row count (after filter)
123
+
124
+ ## Building from Source
125
+
126
+ ### Prerequisites
127
+
128
+ - Rust (latest stable)
129
+ - wasm-pack (`cargo install wasm-pack`)
130
+
131
+ ### Build
132
+
133
+ ```bash
134
+ # Build WASM
135
+ wasm-pack build --target web --release
136
+
137
+ # Run tests
138
+ cargo test
139
+ ```
140
+
141
+ ## License
142
+
143
+ MIT
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "delightloop-spreadsheet-wasm",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "DelightLoop <dev@delightloop.com>"
6
+ ],
7
+ "description": "High-performance spreadsheet engine compiled to WebAssembly",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/labs-delightloop/spreadsheet-wasm"
13
+ },
14
+ "files": [
15
+ "spreadsheet_wasm_bg.wasm",
16
+ "spreadsheet_wasm.js",
17
+ "spreadsheet_wasm.d.ts"
18
+ ],
19
+ "main": "spreadsheet_wasm.js",
20
+ "types": "spreadsheet_wasm.d.ts",
21
+ "sideEffects": [
22
+ "./snippets/*"
23
+ ]
24
+ }
@@ -0,0 +1,193 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Main spreadsheet engine exposed to JavaScript
6
+ */
7
+ export class SpreadsheetEngine {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Add a new column
12
+ */
13
+ add_column(config: any): string;
14
+ /**
15
+ * Add a new row
16
+ */
17
+ add_row(row: any): string;
18
+ /**
19
+ * Perform aggregation on a column
20
+ */
21
+ aggregate(col_key: string, op: string): any;
22
+ /**
23
+ * Clear all filters, sorts, and search
24
+ */
25
+ clear_filters(): void;
26
+ /**
27
+ * Delete a column
28
+ */
29
+ delete_column(col_id: string): void;
30
+ /**
31
+ * Delete rows by IDs
32
+ */
33
+ delete_rows(row_ids: any): void;
34
+ /**
35
+ * Duplicate rows and return new IDs
36
+ */
37
+ duplicate_rows(row_ids: any): any;
38
+ /**
39
+ * Export current data to CSV bytes
40
+ */
41
+ export_csv(): Uint8Array;
42
+ /**
43
+ * Apply filter configuration
44
+ */
45
+ filter(configs: any): void;
46
+ /**
47
+ * Get all columns
48
+ */
49
+ get_columns(): any;
50
+ /**
51
+ * Get current filter configuration
52
+ */
53
+ get_filter_configs(): any;
54
+ /**
55
+ * Get a single row by ID
56
+ */
57
+ get_row(row_id: string): any;
58
+ /**
59
+ * Get rows (paginated)
60
+ */
61
+ get_rows(start: number, count: number): any;
62
+ /**
63
+ * Get current sort configuration
64
+ */
65
+ get_sort_configs(): any;
66
+ /**
67
+ * Get total row count
68
+ */
69
+ get_total_rows(): number;
70
+ /**
71
+ * Get unique values for a column (for filter dropdowns)
72
+ */
73
+ get_unique_values(col_key: string): any;
74
+ /**
75
+ * Get visible row count (after filters)
76
+ */
77
+ get_visible_rows(): number;
78
+ /**
79
+ * Load data from CSV bytes
80
+ * Returns a CsvParseResult as JsValue
81
+ */
82
+ load_csv(bytes: Uint8Array): any;
83
+ /**
84
+ * Create a new SpreadsheetEngine instance
85
+ */
86
+ constructor();
87
+ /**
88
+ * Reorder columns
89
+ */
90
+ reorder_columns(col_ids: any): void;
91
+ /**
92
+ * Search across all columns
93
+ */
94
+ search(query: string): void;
95
+ /**
96
+ * Set columns configuration
97
+ */
98
+ set_columns(columns: any): void;
99
+ /**
100
+ * Set data from JavaScript array
101
+ */
102
+ set_data(rows: any): void;
103
+ /**
104
+ * Apply sort configuration
105
+ */
106
+ sort(configs: any): void;
107
+ /**
108
+ * Update a cell value
109
+ */
110
+ update_cell(row_id: string, col_key: string, value: any): any;
111
+ /**
112
+ * Update column configuration
113
+ */
114
+ update_column(col_id: string, config: any): void;
115
+ /**
116
+ * Validate a single cell value
117
+ */
118
+ validate_cell(value: any, data_type: string): any;
119
+ /**
120
+ * Validate an entire row
121
+ */
122
+ validate_row(row: any, columns: any): any;
123
+ }
124
+
125
+ /**
126
+ * Initialize panic hook for better error messages
127
+ */
128
+ export function init(): void;
129
+
130
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
131
+
132
+ export interface InitOutput {
133
+ readonly memory: WebAssembly.Memory;
134
+ readonly __wbg_spreadsheetengine_free: (a: number, b: number) => void;
135
+ readonly init: () => void;
136
+ readonly spreadsheetengine_add_column: (a: number, b: any) => [number, number];
137
+ readonly spreadsheetengine_add_row: (a: number, b: any) => [number, number];
138
+ readonly spreadsheetengine_aggregate: (a: number, b: number, c: number, d: number, e: number) => any;
139
+ readonly spreadsheetengine_clear_filters: (a: number) => void;
140
+ readonly spreadsheetengine_delete_column: (a: number, b: number, c: number) => void;
141
+ readonly spreadsheetengine_delete_rows: (a: number, b: any) => void;
142
+ readonly spreadsheetengine_duplicate_rows: (a: number, b: any) => any;
143
+ readonly spreadsheetengine_export_csv: (a: number) => [number, number];
144
+ readonly spreadsheetengine_filter: (a: number, b: any) => void;
145
+ readonly spreadsheetengine_get_columns: (a: number) => any;
146
+ readonly spreadsheetengine_get_filter_configs: (a: number) => any;
147
+ readonly spreadsheetengine_get_row: (a: number, b: number, c: number) => any;
148
+ readonly spreadsheetengine_get_rows: (a: number, b: number, c: number) => any;
149
+ readonly spreadsheetengine_get_sort_configs: (a: number) => any;
150
+ readonly spreadsheetengine_get_total_rows: (a: number) => number;
151
+ readonly spreadsheetengine_get_unique_values: (a: number, b: number, c: number) => any;
152
+ readonly spreadsheetengine_get_visible_rows: (a: number) => number;
153
+ readonly spreadsheetengine_load_csv: (a: number, b: number, c: number) => any;
154
+ readonly spreadsheetengine_new: () => number;
155
+ readonly spreadsheetengine_reorder_columns: (a: number, b: any) => void;
156
+ readonly spreadsheetengine_search: (a: number, b: number, c: number) => void;
157
+ readonly spreadsheetengine_set_columns: (a: number, b: any) => void;
158
+ readonly spreadsheetengine_set_data: (a: number, b: any) => void;
159
+ readonly spreadsheetengine_sort: (a: number, b: any) => void;
160
+ readonly spreadsheetengine_update_cell: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
161
+ readonly spreadsheetengine_update_column: (a: number, b: number, c: number, d: any) => void;
162
+ readonly spreadsheetengine_validate_cell: (a: number, b: any, c: number, d: number) => any;
163
+ readonly spreadsheetengine_validate_row: (a: number, b: any, c: any) => any;
164
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
165
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
166
+ readonly __wbindgen_exn_store: (a: number) => void;
167
+ readonly __externref_table_alloc: () => number;
168
+ readonly __wbindgen_externrefs: WebAssembly.Table;
169
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
170
+ readonly __wbindgen_start: () => void;
171
+ }
172
+
173
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
174
+
175
+ /**
176
+ * Instantiates the given `module`, which can either be bytes or
177
+ * a precompiled `WebAssembly.Module`.
178
+ *
179
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
180
+ *
181
+ * @returns {InitOutput}
182
+ */
183
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
184
+
185
+ /**
186
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
187
+ * for everything else, calls `WebAssembly.instantiate` directly.
188
+ *
189
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
190
+ *
191
+ * @returns {Promise<InitOutput>}
192
+ */
193
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,833 @@
1
+ /* @ts-self-types="./spreadsheet_wasm.d.ts" */
2
+
3
+ /**
4
+ * Main spreadsheet engine exposed to JavaScript
5
+ */
6
+ export class SpreadsheetEngine {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ SpreadsheetEngineFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_spreadsheetengine_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Add a new column
19
+ * @param {any} config
20
+ * @returns {string}
21
+ */
22
+ add_column(config) {
23
+ let deferred1_0;
24
+ let deferred1_1;
25
+ try {
26
+ const ret = wasm.spreadsheetengine_add_column(this.__wbg_ptr, config);
27
+ deferred1_0 = ret[0];
28
+ deferred1_1 = ret[1];
29
+ return getStringFromWasm0(ret[0], ret[1]);
30
+ } finally {
31
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
32
+ }
33
+ }
34
+ /**
35
+ * Add a new row
36
+ * @param {any} row
37
+ * @returns {string}
38
+ */
39
+ add_row(row) {
40
+ let deferred1_0;
41
+ let deferred1_1;
42
+ try {
43
+ const ret = wasm.spreadsheetengine_add_row(this.__wbg_ptr, row);
44
+ deferred1_0 = ret[0];
45
+ deferred1_1 = ret[1];
46
+ return getStringFromWasm0(ret[0], ret[1]);
47
+ } finally {
48
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
49
+ }
50
+ }
51
+ /**
52
+ * Perform aggregation on a column
53
+ * @param {string} col_key
54
+ * @param {string} op
55
+ * @returns {any}
56
+ */
57
+ aggregate(col_key, op) {
58
+ const ptr0 = passStringToWasm0(col_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
+ const len0 = WASM_VECTOR_LEN;
60
+ const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
61
+ const len1 = WASM_VECTOR_LEN;
62
+ const ret = wasm.spreadsheetengine_aggregate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
63
+ return ret;
64
+ }
65
+ /**
66
+ * Clear all filters, sorts, and search
67
+ */
68
+ clear_filters() {
69
+ wasm.spreadsheetengine_clear_filters(this.__wbg_ptr);
70
+ }
71
+ /**
72
+ * Delete a column
73
+ * @param {string} col_id
74
+ */
75
+ delete_column(col_id) {
76
+ const ptr0 = passStringToWasm0(col_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
+ const len0 = WASM_VECTOR_LEN;
78
+ wasm.spreadsheetengine_delete_column(this.__wbg_ptr, ptr0, len0);
79
+ }
80
+ /**
81
+ * Delete rows by IDs
82
+ * @param {any} row_ids
83
+ */
84
+ delete_rows(row_ids) {
85
+ wasm.spreadsheetengine_delete_rows(this.__wbg_ptr, row_ids);
86
+ }
87
+ /**
88
+ * Duplicate rows and return new IDs
89
+ * @param {any} row_ids
90
+ * @returns {any}
91
+ */
92
+ duplicate_rows(row_ids) {
93
+ const ret = wasm.spreadsheetengine_duplicate_rows(this.__wbg_ptr, row_ids);
94
+ return ret;
95
+ }
96
+ /**
97
+ * Export current data to CSV bytes
98
+ * @returns {Uint8Array}
99
+ */
100
+ export_csv() {
101
+ const ret = wasm.spreadsheetengine_export_csv(this.__wbg_ptr);
102
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
103
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
104
+ return v1;
105
+ }
106
+ /**
107
+ * Apply filter configuration
108
+ * @param {any} configs
109
+ */
110
+ filter(configs) {
111
+ wasm.spreadsheetengine_filter(this.__wbg_ptr, configs);
112
+ }
113
+ /**
114
+ * Get all columns
115
+ * @returns {any}
116
+ */
117
+ get_columns() {
118
+ const ret = wasm.spreadsheetengine_get_columns(this.__wbg_ptr);
119
+ return ret;
120
+ }
121
+ /**
122
+ * Get current filter configuration
123
+ * @returns {any}
124
+ */
125
+ get_filter_configs() {
126
+ const ret = wasm.spreadsheetengine_get_filter_configs(this.__wbg_ptr);
127
+ return ret;
128
+ }
129
+ /**
130
+ * Get a single row by ID
131
+ * @param {string} row_id
132
+ * @returns {any}
133
+ */
134
+ get_row(row_id) {
135
+ const ptr0 = passStringToWasm0(row_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ret = wasm.spreadsheetengine_get_row(this.__wbg_ptr, ptr0, len0);
138
+ return ret;
139
+ }
140
+ /**
141
+ * Get rows (paginated)
142
+ * @param {number} start
143
+ * @param {number} count
144
+ * @returns {any}
145
+ */
146
+ get_rows(start, count) {
147
+ const ret = wasm.spreadsheetengine_get_rows(this.__wbg_ptr, start, count);
148
+ return ret;
149
+ }
150
+ /**
151
+ * Get current sort configuration
152
+ * @returns {any}
153
+ */
154
+ get_sort_configs() {
155
+ const ret = wasm.spreadsheetengine_get_sort_configs(this.__wbg_ptr);
156
+ return ret;
157
+ }
158
+ /**
159
+ * Get total row count
160
+ * @returns {number}
161
+ */
162
+ get_total_rows() {
163
+ const ret = wasm.spreadsheetengine_get_total_rows(this.__wbg_ptr);
164
+ return ret >>> 0;
165
+ }
166
+ /**
167
+ * Get unique values for a column (for filter dropdowns)
168
+ * @param {string} col_key
169
+ * @returns {any}
170
+ */
171
+ get_unique_values(col_key) {
172
+ const ptr0 = passStringToWasm0(col_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
+ const len0 = WASM_VECTOR_LEN;
174
+ const ret = wasm.spreadsheetengine_get_unique_values(this.__wbg_ptr, ptr0, len0);
175
+ return ret;
176
+ }
177
+ /**
178
+ * Get visible row count (after filters)
179
+ * @returns {number}
180
+ */
181
+ get_visible_rows() {
182
+ const ret = wasm.spreadsheetengine_get_visible_rows(this.__wbg_ptr);
183
+ return ret >>> 0;
184
+ }
185
+ /**
186
+ * Load data from CSV bytes
187
+ * Returns a CsvParseResult as JsValue
188
+ * @param {Uint8Array} bytes
189
+ * @returns {any}
190
+ */
191
+ load_csv(bytes) {
192
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
193
+ const len0 = WASM_VECTOR_LEN;
194
+ const ret = wasm.spreadsheetengine_load_csv(this.__wbg_ptr, ptr0, len0);
195
+ return ret;
196
+ }
197
+ /**
198
+ * Create a new SpreadsheetEngine instance
199
+ */
200
+ constructor() {
201
+ const ret = wasm.spreadsheetengine_new();
202
+ this.__wbg_ptr = ret >>> 0;
203
+ SpreadsheetEngineFinalization.register(this, this.__wbg_ptr, this);
204
+ return this;
205
+ }
206
+ /**
207
+ * Reorder columns
208
+ * @param {any} col_ids
209
+ */
210
+ reorder_columns(col_ids) {
211
+ wasm.spreadsheetengine_reorder_columns(this.__wbg_ptr, col_ids);
212
+ }
213
+ /**
214
+ * Search across all columns
215
+ * @param {string} query
216
+ */
217
+ search(query) {
218
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ wasm.spreadsheetengine_search(this.__wbg_ptr, ptr0, len0);
221
+ }
222
+ /**
223
+ * Set columns configuration
224
+ * @param {any} columns
225
+ */
226
+ set_columns(columns) {
227
+ wasm.spreadsheetengine_set_columns(this.__wbg_ptr, columns);
228
+ }
229
+ /**
230
+ * Set data from JavaScript array
231
+ * @param {any} rows
232
+ */
233
+ set_data(rows) {
234
+ wasm.spreadsheetengine_set_data(this.__wbg_ptr, rows);
235
+ }
236
+ /**
237
+ * Apply sort configuration
238
+ * @param {any} configs
239
+ */
240
+ sort(configs) {
241
+ wasm.spreadsheetengine_sort(this.__wbg_ptr, configs);
242
+ }
243
+ /**
244
+ * Update a cell value
245
+ * @param {string} row_id
246
+ * @param {string} col_key
247
+ * @param {any} value
248
+ * @returns {any}
249
+ */
250
+ update_cell(row_id, col_key, value) {
251
+ const ptr0 = passStringToWasm0(row_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
252
+ const len0 = WASM_VECTOR_LEN;
253
+ const ptr1 = passStringToWasm0(col_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
254
+ const len1 = WASM_VECTOR_LEN;
255
+ const ret = wasm.spreadsheetengine_update_cell(this.__wbg_ptr, ptr0, len0, ptr1, len1, value);
256
+ return ret;
257
+ }
258
+ /**
259
+ * Update column configuration
260
+ * @param {string} col_id
261
+ * @param {any} config
262
+ */
263
+ update_column(col_id, config) {
264
+ const ptr0 = passStringToWasm0(col_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
265
+ const len0 = WASM_VECTOR_LEN;
266
+ wasm.spreadsheetengine_update_column(this.__wbg_ptr, ptr0, len0, config);
267
+ }
268
+ /**
269
+ * Validate a single cell value
270
+ * @param {any} value
271
+ * @param {string} data_type
272
+ * @returns {any}
273
+ */
274
+ validate_cell(value, data_type) {
275
+ const ptr0 = passStringToWasm0(data_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
276
+ const len0 = WASM_VECTOR_LEN;
277
+ const ret = wasm.spreadsheetengine_validate_cell(this.__wbg_ptr, value, ptr0, len0);
278
+ return ret;
279
+ }
280
+ /**
281
+ * Validate an entire row
282
+ * @param {any} row
283
+ * @param {any} columns
284
+ * @returns {any}
285
+ */
286
+ validate_row(row, columns) {
287
+ const ret = wasm.spreadsheetengine_validate_row(this.__wbg_ptr, row, columns);
288
+ return ret;
289
+ }
290
+ }
291
+ if (Symbol.dispose) SpreadsheetEngine.prototype[Symbol.dispose] = SpreadsheetEngine.prototype.free;
292
+
293
+ /**
294
+ * Initialize panic hook for better error messages
295
+ */
296
+ export function init() {
297
+ wasm.init();
298
+ }
299
+
300
+ function __wbg_get_imports() {
301
+ const import0 = {
302
+ __proto__: null,
303
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
304
+ const ret = Error(getStringFromWasm0(arg0, arg1));
305
+ return ret;
306
+ },
307
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
308
+ const ret = Number(arg0);
309
+ return ret;
310
+ },
311
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
312
+ const v = arg1;
313
+ const ret = typeof(v) === 'bigint' ? v : undefined;
314
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
315
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
316
+ },
317
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
318
+ const v = arg0;
319
+ const ret = typeof(v) === 'boolean' ? v : undefined;
320
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
321
+ },
322
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
323
+ const ret = debugString(arg1);
324
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
325
+ const len1 = WASM_VECTOR_LEN;
326
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
327
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
328
+ },
329
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
330
+ const ret = arg0 in arg1;
331
+ return ret;
332
+ },
333
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
334
+ const ret = typeof(arg0) === 'bigint';
335
+ return ret;
336
+ },
337
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
338
+ const ret = typeof(arg0) === 'function';
339
+ return ret;
340
+ },
341
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
342
+ const val = arg0;
343
+ const ret = typeof(val) === 'object' && val !== null;
344
+ return ret;
345
+ },
346
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
347
+ const ret = typeof(arg0) === 'string';
348
+ return ret;
349
+ },
350
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
351
+ const ret = arg0 === undefined;
352
+ return ret;
353
+ },
354
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
355
+ const ret = arg0 === arg1;
356
+ return ret;
357
+ },
358
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
359
+ const ret = arg0 == arg1;
360
+ return ret;
361
+ },
362
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
363
+ const obj = arg1;
364
+ const ret = typeof(obj) === 'number' ? obj : undefined;
365
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
366
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
367
+ },
368
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
369
+ const obj = arg1;
370
+ const ret = typeof(obj) === 'string' ? obj : undefined;
371
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
372
+ var len1 = WASM_VECTOR_LEN;
373
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
374
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
375
+ },
376
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
377
+ throw new Error(getStringFromWasm0(arg0, arg1));
378
+ },
379
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
380
+ const ret = arg0.call(arg1);
381
+ return ret;
382
+ }, arguments); },
383
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
384
+ const ret = arg0.done;
385
+ return ret;
386
+ },
387
+ __wbg_entries_58c7934c745daac7: function(arg0) {
388
+ const ret = Object.entries(arg0);
389
+ return ret;
390
+ },
391
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
392
+ let deferred0_0;
393
+ let deferred0_1;
394
+ try {
395
+ deferred0_0 = arg0;
396
+ deferred0_1 = arg1;
397
+ console.error(getStringFromWasm0(arg0, arg1));
398
+ } finally {
399
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
400
+ }
401
+ },
402
+ __wbg_getRandomValues_71d446877d8b0ad4: function() { return handleError(function (arg0, arg1) {
403
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
404
+ }, arguments); },
405
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
406
+ const ret = arg0[arg1 >>> 0];
407
+ return ret;
408
+ },
409
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
410
+ const ret = Reflect.get(arg0, arg1);
411
+ return ret;
412
+ }, arguments); },
413
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
414
+ const ret = arg0[arg1];
415
+ return ret;
416
+ },
417
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
418
+ let result;
419
+ try {
420
+ result = arg0 instanceof ArrayBuffer;
421
+ } catch (_) {
422
+ result = false;
423
+ }
424
+ const ret = result;
425
+ return ret;
426
+ },
427
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
428
+ let result;
429
+ try {
430
+ result = arg0 instanceof Map;
431
+ } catch (_) {
432
+ result = false;
433
+ }
434
+ const ret = result;
435
+ return ret;
436
+ },
437
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
438
+ let result;
439
+ try {
440
+ result = arg0 instanceof Uint8Array;
441
+ } catch (_) {
442
+ result = false;
443
+ }
444
+ const ret = result;
445
+ return ret;
446
+ },
447
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
448
+ const ret = Array.isArray(arg0);
449
+ return ret;
450
+ },
451
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
452
+ const ret = Number.isSafeInteger(arg0);
453
+ return ret;
454
+ },
455
+ __wbg_iterator_6ff6560ca1568e55: function() {
456
+ const ret = Symbol.iterator;
457
+ return ret;
458
+ },
459
+ __wbg_length_32ed9a279acd054c: function(arg0) {
460
+ const ret = arg0.length;
461
+ return ret;
462
+ },
463
+ __wbg_length_35a7bace40f36eac: function(arg0) {
464
+ const ret = arg0.length;
465
+ return ret;
466
+ },
467
+ __wbg_new_361308b2356cecd0: function() {
468
+ const ret = new Object();
469
+ return ret;
470
+ },
471
+ __wbg_new_3eb36ae241fe6f44: function() {
472
+ const ret = new Array();
473
+ return ret;
474
+ },
475
+ __wbg_new_8a6f238a6ece86ea: function() {
476
+ const ret = new Error();
477
+ return ret;
478
+ },
479
+ __wbg_new_dca287b076112a51: function() {
480
+ const ret = new Map();
481
+ return ret;
482
+ },
483
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
484
+ const ret = new Uint8Array(arg0);
485
+ return ret;
486
+ },
487
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
488
+ const ret = arg0.next();
489
+ return ret;
490
+ }, arguments); },
491
+ __wbg_next_418f80d8f5303233: function(arg0) {
492
+ const ret = arg0.next;
493
+ return ret;
494
+ },
495
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
496
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
497
+ },
498
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
499
+ const ret = arg0.set(arg1, arg2);
500
+ return ret;
501
+ },
502
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
503
+ arg0[arg1] = arg2;
504
+ },
505
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
506
+ arg0[arg1 >>> 0] = arg2;
507
+ },
508
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
509
+ const ret = arg1.stack;
510
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
511
+ const len1 = WASM_VECTOR_LEN;
512
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
513
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
514
+ },
515
+ __wbg_value_0546255b415e96c1: function(arg0) {
516
+ const ret = arg0.value;
517
+ return ret;
518
+ },
519
+ __wbindgen_cast_0000000000000001: function(arg0) {
520
+ // Cast intrinsic for `F64 -> Externref`.
521
+ const ret = arg0;
522
+ return ret;
523
+ },
524
+ __wbindgen_cast_0000000000000002: function(arg0) {
525
+ // Cast intrinsic for `I64 -> Externref`.
526
+ const ret = arg0;
527
+ return ret;
528
+ },
529
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
530
+ // Cast intrinsic for `Ref(String) -> Externref`.
531
+ const ret = getStringFromWasm0(arg0, arg1);
532
+ return ret;
533
+ },
534
+ __wbindgen_cast_0000000000000004: function(arg0) {
535
+ // Cast intrinsic for `U64 -> Externref`.
536
+ const ret = BigInt.asUintN(64, arg0);
537
+ return ret;
538
+ },
539
+ __wbindgen_init_externref_table: function() {
540
+ const table = wasm.__wbindgen_externrefs;
541
+ const offset = table.grow(4);
542
+ table.set(0, undefined);
543
+ table.set(offset + 0, undefined);
544
+ table.set(offset + 1, null);
545
+ table.set(offset + 2, true);
546
+ table.set(offset + 3, false);
547
+ },
548
+ };
549
+ return {
550
+ __proto__: null,
551
+ "./spreadsheet_wasm_bg.js": import0,
552
+ };
553
+ }
554
+
555
+ const SpreadsheetEngineFinalization = (typeof FinalizationRegistry === 'undefined')
556
+ ? { register: () => {}, unregister: () => {} }
557
+ : new FinalizationRegistry(ptr => wasm.__wbg_spreadsheetengine_free(ptr >>> 0, 1));
558
+
559
+ function addToExternrefTable0(obj) {
560
+ const idx = wasm.__externref_table_alloc();
561
+ wasm.__wbindgen_externrefs.set(idx, obj);
562
+ return idx;
563
+ }
564
+
565
+ function debugString(val) {
566
+ // primitive types
567
+ const type = typeof val;
568
+ if (type == 'number' || type == 'boolean' || val == null) {
569
+ return `${val}`;
570
+ }
571
+ if (type == 'string') {
572
+ return `"${val}"`;
573
+ }
574
+ if (type == 'symbol') {
575
+ const description = val.description;
576
+ if (description == null) {
577
+ return 'Symbol';
578
+ } else {
579
+ return `Symbol(${description})`;
580
+ }
581
+ }
582
+ if (type == 'function') {
583
+ const name = val.name;
584
+ if (typeof name == 'string' && name.length > 0) {
585
+ return `Function(${name})`;
586
+ } else {
587
+ return 'Function';
588
+ }
589
+ }
590
+ // objects
591
+ if (Array.isArray(val)) {
592
+ const length = val.length;
593
+ let debug = '[';
594
+ if (length > 0) {
595
+ debug += debugString(val[0]);
596
+ }
597
+ for(let i = 1; i < length; i++) {
598
+ debug += ', ' + debugString(val[i]);
599
+ }
600
+ debug += ']';
601
+ return debug;
602
+ }
603
+ // Test for built-in
604
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
605
+ let className;
606
+ if (builtInMatches && builtInMatches.length > 1) {
607
+ className = builtInMatches[1];
608
+ } else {
609
+ // Failed to match the standard '[object ClassName]'
610
+ return toString.call(val);
611
+ }
612
+ if (className == 'Object') {
613
+ // we're a user defined class or Object
614
+ // JSON.stringify avoids problems with cycles, and is generally much
615
+ // easier than looping through ownProperties of `val`.
616
+ try {
617
+ return 'Object(' + JSON.stringify(val) + ')';
618
+ } catch (_) {
619
+ return 'Object';
620
+ }
621
+ }
622
+ // errors
623
+ if (val instanceof Error) {
624
+ return `${val.name}: ${val.message}\n${val.stack}`;
625
+ }
626
+ // TODO we could test for more things here, like `Set`s and `Map`s.
627
+ return className;
628
+ }
629
+
630
+ function getArrayU8FromWasm0(ptr, len) {
631
+ ptr = ptr >>> 0;
632
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
633
+ }
634
+
635
+ let cachedDataViewMemory0 = null;
636
+ function getDataViewMemory0() {
637
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
638
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
639
+ }
640
+ return cachedDataViewMemory0;
641
+ }
642
+
643
+ function getStringFromWasm0(ptr, len) {
644
+ ptr = ptr >>> 0;
645
+ return decodeText(ptr, len);
646
+ }
647
+
648
+ let cachedUint8ArrayMemory0 = null;
649
+ function getUint8ArrayMemory0() {
650
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
651
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
652
+ }
653
+ return cachedUint8ArrayMemory0;
654
+ }
655
+
656
+ function handleError(f, args) {
657
+ try {
658
+ return f.apply(this, args);
659
+ } catch (e) {
660
+ const idx = addToExternrefTable0(e);
661
+ wasm.__wbindgen_exn_store(idx);
662
+ }
663
+ }
664
+
665
+ function isLikeNone(x) {
666
+ return x === undefined || x === null;
667
+ }
668
+
669
+ function passArray8ToWasm0(arg, malloc) {
670
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
671
+ getUint8ArrayMemory0().set(arg, ptr / 1);
672
+ WASM_VECTOR_LEN = arg.length;
673
+ return ptr;
674
+ }
675
+
676
+ function passStringToWasm0(arg, malloc, realloc) {
677
+ if (realloc === undefined) {
678
+ const buf = cachedTextEncoder.encode(arg);
679
+ const ptr = malloc(buf.length, 1) >>> 0;
680
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
681
+ WASM_VECTOR_LEN = buf.length;
682
+ return ptr;
683
+ }
684
+
685
+ let len = arg.length;
686
+ let ptr = malloc(len, 1) >>> 0;
687
+
688
+ const mem = getUint8ArrayMemory0();
689
+
690
+ let offset = 0;
691
+
692
+ for (; offset < len; offset++) {
693
+ const code = arg.charCodeAt(offset);
694
+ if (code > 0x7F) break;
695
+ mem[ptr + offset] = code;
696
+ }
697
+ if (offset !== len) {
698
+ if (offset !== 0) {
699
+ arg = arg.slice(offset);
700
+ }
701
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
702
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
703
+ const ret = cachedTextEncoder.encodeInto(arg, view);
704
+
705
+ offset += ret.written;
706
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
707
+ }
708
+
709
+ WASM_VECTOR_LEN = offset;
710
+ return ptr;
711
+ }
712
+
713
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
714
+ cachedTextDecoder.decode();
715
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
716
+ let numBytesDecoded = 0;
717
+ function decodeText(ptr, len) {
718
+ numBytesDecoded += len;
719
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
720
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
721
+ cachedTextDecoder.decode();
722
+ numBytesDecoded = len;
723
+ }
724
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
725
+ }
726
+
727
+ const cachedTextEncoder = new TextEncoder();
728
+
729
+ if (!('encodeInto' in cachedTextEncoder)) {
730
+ cachedTextEncoder.encodeInto = function (arg, view) {
731
+ const buf = cachedTextEncoder.encode(arg);
732
+ view.set(buf);
733
+ return {
734
+ read: arg.length,
735
+ written: buf.length
736
+ };
737
+ };
738
+ }
739
+
740
+ let WASM_VECTOR_LEN = 0;
741
+
742
+ let wasmModule, wasm;
743
+ function __wbg_finalize_init(instance, module) {
744
+ wasm = instance.exports;
745
+ wasmModule = module;
746
+ cachedDataViewMemory0 = null;
747
+ cachedUint8ArrayMemory0 = null;
748
+ wasm.__wbindgen_start();
749
+ return wasm;
750
+ }
751
+
752
+ async function __wbg_load(module, imports) {
753
+ if (typeof Response === 'function' && module instanceof Response) {
754
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
755
+ try {
756
+ return await WebAssembly.instantiateStreaming(module, imports);
757
+ } catch (e) {
758
+ const validResponse = module.ok && expectedResponseType(module.type);
759
+
760
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
761
+ 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);
762
+
763
+ } else { throw e; }
764
+ }
765
+ }
766
+
767
+ const bytes = await module.arrayBuffer();
768
+ return await WebAssembly.instantiate(bytes, imports);
769
+ } else {
770
+ const instance = await WebAssembly.instantiate(module, imports);
771
+
772
+ if (instance instanceof WebAssembly.Instance) {
773
+ return { instance, module };
774
+ } else {
775
+ return instance;
776
+ }
777
+ }
778
+
779
+ function expectedResponseType(type) {
780
+ switch (type) {
781
+ case 'basic': case 'cors': case 'default': return true;
782
+ }
783
+ return false;
784
+ }
785
+ }
786
+
787
+ function initSync(module) {
788
+ if (wasm !== undefined) return wasm;
789
+
790
+
791
+ if (module !== undefined) {
792
+ if (Object.getPrototypeOf(module) === Object.prototype) {
793
+ ({module} = module)
794
+ } else {
795
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
796
+ }
797
+ }
798
+
799
+ const imports = __wbg_get_imports();
800
+ if (!(module instanceof WebAssembly.Module)) {
801
+ module = new WebAssembly.Module(module);
802
+ }
803
+ const instance = new WebAssembly.Instance(module, imports);
804
+ return __wbg_finalize_init(instance, module);
805
+ }
806
+
807
+ async function __wbg_init(module_or_path) {
808
+ if (wasm !== undefined) return wasm;
809
+
810
+
811
+ if (module_or_path !== undefined) {
812
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
813
+ ({module_or_path} = module_or_path)
814
+ } else {
815
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
816
+ }
817
+ }
818
+
819
+ if (module_or_path === undefined) {
820
+ module_or_path = new URL('spreadsheet_wasm_bg.wasm', import.meta.url);
821
+ }
822
+ const imports = __wbg_get_imports();
823
+
824
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
825
+ module_or_path = fetch(module_or_path);
826
+ }
827
+
828
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
829
+
830
+ return __wbg_finalize_init(instance, module);
831
+ }
832
+
833
+ export { initSync, __wbg_init as default };
Binary file