belobog-stellar-grid 1.0.0 → 1.0.1

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.
@@ -1,4 +1,448 @@
1
- let wasm;
1
+ /* @ts-self-types="./belobog_stellar_grid.d.ts" */
2
+
3
+ /**
4
+ * 导出格式枚举
5
+ * @enum {0 | 1}
6
+ */
7
+ export const ExportFormat = Object.freeze({
8
+ /**
9
+ * CSV 格式(默认)
10
+ */
11
+ Csv: 0, "0": "Csv",
12
+ /**
13
+ * Excel XLSX 格式
14
+ */
15
+ Xlsx: 1, "1": "Xlsx",
16
+ });
17
+
18
+ /**
19
+ * 统一的表格导出函数(带进度回调)
20
+ *
21
+ * 支持导出为 CSV 或 Excel 格式,通过 format 参数控制,支持进度回调
22
+ *
23
+ * # 参数
24
+ * * `table_id` - 要导出的 HTML 表格元素的 ID
25
+ * * `filename` - 可选的导出文件名(不包含扩展名时会自动添加)
26
+ * * `format` - 导出格式(Csv 或 Xlsx),默认为 Csv
27
+ * * `progress_callback` - 可选的进度回调函数,接收 0-100 的进度值
28
+ *
29
+ * # 返回值
30
+ * * `Ok(())` - 导出成功
31
+ * * `Err(JsValue)` - 导出失败,包含错误信息
32
+ *
33
+ * # 示例
34
+ * ```javascript
35
+ * import init, { export_table, ExportFormat } from './pkg/excel_exporter.js';
36
+ * await init();
37
+ *
38
+ * // 导出为 CSV(默认,无进度回调)
39
+ * export_table('my-table');
40
+ * export_table('my-table', '数据.csv');
41
+ *
42
+ * // 导出为 CSV(带进度回调)
43
+ * export_table('my-table', '数据', ExportFormat.Csv, (progress) => {
44
+ * console.log(`进度: ${progress.toFixed(1)}%`);
45
+ * });
46
+ *
47
+ * // 导出为 Excel(带进度回调)
48
+ * export_table('my-table', '报表', ExportFormat.Xlsx, (progress) => {
49
+ * document.getElementById('progress').style.width = `${progress}%`;
50
+ * });
51
+ * ```
52
+ * @param {string} table_id
53
+ * @param {string | null} [filename]
54
+ * @param {ExportFormat | null} [format]
55
+ * @param {Function | null} [progress_callback]
56
+ */
57
+ export function export_table(table_id, filename, format, progress_callback) {
58
+ const ptr0 = passStringToWasm0(table_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
+ const len0 = WASM_VECTOR_LEN;
60
+ var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
61
+ var len1 = WASM_VECTOR_LEN;
62
+ const ret = wasm.export_table(ptr0, len0, ptr1, len1, isLikeNone(format) ? 2 : format, isLikeNone(progress_callback) ? 0 : addToExternrefTable0(progress_callback));
63
+ if (ret[1]) {
64
+ throw takeFromExternrefTable0(ret[0]);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * 分批异步导出 HTML 表格到 CSV 文件
70
+ *
71
+ * 这个函数将表格数据分批处理,在批次之间让出控制权给浏览器事件循环,
72
+ * 从而避免在处理大量数据时阻塞主线程导致页面卡死。
73
+ * 支持合并单元格(colspan/rowspan)的正确处理。
74
+ *
75
+ * # 参数
76
+ * * `table_id` - 要导出的 HTML 表格元素的 ID
77
+ * * `tbody_id` - 可选的数据表格体 ID(用于分离表头和数据)
78
+ * * `filename` - 可选的导出文件名(可选,默认为 "table_export.csv")
79
+ * * `batch_size` - 每批处理的行数(默认 1000)
80
+ * * `progress_callback` - 进度回调函数,接收进度百分比 (0-100)
81
+ *
82
+ * # 返回值
83
+ * * `Promise<void>` - 异步操作的 Promise
84
+ *
85
+ * # 示例
86
+ * ```javascript
87
+ * import { export_table_to_csv_batch } from './pkg/excel_exporter.js';
88
+ *
89
+ * await export_table_to_csv_batch(
90
+ * 'my-table',
91
+ * 'my-tbody', // 可选的 tbody ID
92
+ * 'data.csv',
93
+ * 1000, // 每批 1000 行
94
+ * (progress) => {
95
+ * console.log(`进度: ${progress}%`);
96
+ * }
97
+ * );
98
+ * ```
99
+ * @param {string} table_id
100
+ * @param {string | null} [tbody_id]
101
+ * @param {string | null} [filename]
102
+ * @param {number | null} [batch_size]
103
+ * @param {Function | null} [progress_callback]
104
+ * @returns {Promise<any>}
105
+ */
106
+ export function export_table_to_csv_batch(table_id, tbody_id, filename, batch_size, progress_callback) {
107
+ const ptr0 = passStringToWasm0(table_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
108
+ const len0 = WASM_VECTOR_LEN;
109
+ var ptr1 = isLikeNone(tbody_id) ? 0 : passStringToWasm0(tbody_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ var len1 = WASM_VECTOR_LEN;
111
+ var ptr2 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ var len2 = WASM_VECTOR_LEN;
113
+ const ret = wasm.export_table_to_csv_batch(ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(batch_size) ? 0x100000001 : (batch_size) >>> 0, isLikeNone(progress_callback) ? 0 : addToExternrefTable0(progress_callback));
114
+ return ret;
115
+ }
116
+
117
+ /**
118
+ * 分批异步导出 HTML 表格到 XLSX 文件
119
+ *
120
+ * 采用两阶段策略避免阻塞主线程:
121
+ * 1. 分批读取 DOM 数据(异步,可 yield 让出控制权)
122
+ * 2. 同步生成 XLSX 文件(内存操作,快速)
123
+ *
124
+ * # 参数
125
+ * * `table_id` - 要导出的 HTML 表格元素的 ID
126
+ * * `tbody_id` - 可选的数据表格体 ID(用于分离表头和数据)
127
+ * * `filename` - 可选的导出文件名(默认为 "table_export.xlsx")
128
+ * * `batch_size` - 每批处理的行数(默认 1000)
129
+ * * `progress_callback` - 进度回调函数,接收进度百分比 (0-100)
130
+ *
131
+ * # 返回值
132
+ * * `Promise<void>` - 异步操作的 Promise
133
+ *
134
+ * # 示例
135
+ * ```javascript
136
+ * import { export_table_to_xlsx_batch } from './pkg/belobog_stellar_grid.js';
137
+ *
138
+ * await export_table_to_xlsx_batch(
139
+ * 'my-table',
140
+ * 'my-tbody', // 可选的 tbody ID
141
+ * 'data.xlsx',
142
+ * 1000, // 每批 1000 行
143
+ * (progress) => {
144
+ * console.log(`进度: ${progress}%`);
145
+ * }
146
+ * );
147
+ * ```
148
+ * @param {string} table_id
149
+ * @param {string | null} [tbody_id]
150
+ * @param {string | null} [filename]
151
+ * @param {number | null} [batch_size]
152
+ * @param {Function | null} [progress_callback]
153
+ * @returns {Promise<any>}
154
+ */
155
+ export function export_table_to_xlsx_batch(table_id, tbody_id, filename, batch_size, progress_callback) {
156
+ const ptr0 = passStringToWasm0(table_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len0 = WASM_VECTOR_LEN;
158
+ var ptr1 = isLikeNone(tbody_id) ? 0 : passStringToWasm0(tbody_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ var len1 = WASM_VECTOR_LEN;
160
+ var ptr2 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ var len2 = WASM_VECTOR_LEN;
162
+ const ret = wasm.export_table_to_xlsx_batch(ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(batch_size) ? 0x100000001 : (batch_size) >>> 0, isLikeNone(progress_callback) ? 0 : addToExternrefTable0(progress_callback));
163
+ return ret;
164
+ }
165
+
166
+ function __wbg_get_imports() {
167
+ const import0 = {
168
+ __proto__: null,
169
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
170
+ const ret = debugString(arg1);
171
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
172
+ const len1 = WASM_VECTOR_LEN;
173
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
174
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
175
+ },
176
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
177
+ const ret = typeof(arg0) === 'function';
178
+ return ret;
179
+ },
180
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
181
+ const ret = arg0 === undefined;
182
+ return ret;
183
+ },
184
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
185
+ throw new Error(getStringFromWasm0(arg0, arg1));
186
+ },
187
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
188
+ arg0._wbg_cb_unref();
189
+ },
190
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
191
+ const ret = arg0.call(arg1);
192
+ return ret;
193
+ }, arguments); },
194
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
195
+ const ret = arg0.call(arg1, arg2);
196
+ return ret;
197
+ }, arguments); },
198
+ __wbg_cells_28d7fcc1e192bfd7: function(arg0) {
199
+ const ret = arg0.cells;
200
+ return ret;
201
+ },
202
+ __wbg_click_0e9c20848b655ed3: function(arg0) {
203
+ arg0.click();
204
+ },
205
+ __wbg_colSpan_66e25bfdd5211dc0: function(arg0) {
206
+ const ret = arg0.colSpan;
207
+ return ret;
208
+ },
209
+ __wbg_createElement_49f60fdcaae809c8: function() { return handleError(function (arg0, arg1, arg2) {
210
+ const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
211
+ return ret;
212
+ }, arguments); },
213
+ __wbg_createObjectURL_918185db6a10a0c8: function() { return handleError(function (arg0, arg1) {
214
+ const ret = URL.createObjectURL(arg1);
215
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216
+ const len1 = WASM_VECTOR_LEN;
217
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
218
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
219
+ }, arguments); },
220
+ __wbg_document_ee35a3d3ae34ef6c: function(arg0) {
221
+ const ret = arg0.document;
222
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
223
+ },
224
+ __wbg_getElementById_e34377b79d7285f6: function(arg0, arg1, arg2) {
225
+ const ret = arg0.getElementById(getStringFromWasm0(arg1, arg2));
226
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
227
+ },
228
+ __wbg_get_with_index_d26da38d2c038e1a: function(arg0, arg1) {
229
+ const ret = arg0[arg1 >>> 0];
230
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
231
+ },
232
+ __wbg_innerText_c7afd03414ca5e37: function(arg0, arg1) {
233
+ const ret = arg1.innerText;
234
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len1 = WASM_VECTOR_LEN;
236
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
237
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
238
+ },
239
+ __wbg_instanceof_HtmlAnchorElement_770fa141c7731617: function(arg0) {
240
+ let result;
241
+ try {
242
+ result = arg0 instanceof HTMLAnchorElement;
243
+ } catch (_) {
244
+ result = false;
245
+ }
246
+ const ret = result;
247
+ return ret;
248
+ },
249
+ __wbg_instanceof_HtmlTableCellElement_0904d70d7fed1c74: function(arg0) {
250
+ let result;
251
+ try {
252
+ result = arg0 instanceof HTMLTableCellElement;
253
+ } catch (_) {
254
+ result = false;
255
+ }
256
+ const ret = result;
257
+ return ret;
258
+ },
259
+ __wbg_instanceof_HtmlTableElement_32b8f9e35d615f5b: function(arg0) {
260
+ let result;
261
+ try {
262
+ result = arg0 instanceof HTMLTableElement;
263
+ } catch (_) {
264
+ result = false;
265
+ }
266
+ const ret = result;
267
+ return ret;
268
+ },
269
+ __wbg_instanceof_HtmlTableRowElement_934ff95a4f83256d: function(arg0) {
270
+ let result;
271
+ try {
272
+ result = arg0 instanceof HTMLTableRowElement;
273
+ } catch (_) {
274
+ result = false;
275
+ }
276
+ const ret = result;
277
+ return ret;
278
+ },
279
+ __wbg_instanceof_HtmlTableSectionElement_6f929e32ffffdc64: function(arg0) {
280
+ let result;
281
+ try {
282
+ result = arg0 instanceof HTMLTableSectionElement;
283
+ } catch (_) {
284
+ result = false;
285
+ }
286
+ const ret = result;
287
+ return ret;
288
+ },
289
+ __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
290
+ let result;
291
+ try {
292
+ result = arg0 instanceof Window;
293
+ } catch (_) {
294
+ result = false;
295
+ }
296
+ const ret = result;
297
+ return ret;
298
+ },
299
+ __wbg_length_e455564ce5cbf46e: function(arg0) {
300
+ const ret = arg0.length;
301
+ return ret;
302
+ },
303
+ __wbg_new_361308b2356cecd0: function() {
304
+ const ret = new Object();
305
+ return ret;
306
+ },
307
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
308
+ try {
309
+ var state0 = {a: arg0, b: arg1};
310
+ var cb0 = (arg0, arg1) => {
311
+ const a = state0.a;
312
+ state0.a = 0;
313
+ try {
314
+ return wasm_bindgen__convert__closures_____invoke__h532f206189913be7(a, state0.b, arg0, arg1);
315
+ } finally {
316
+ state0.a = a;
317
+ }
318
+ };
319
+ const ret = new Promise(cb0);
320
+ return ret;
321
+ } finally {
322
+ state0.a = state0.b = 0;
323
+ }
324
+ },
325
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
326
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
327
+ return ret;
328
+ },
329
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
330
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
331
+ return ret;
332
+ },
333
+ __wbg_new_with_u8_array_sequence_and_options_cc0f8f2c1ef62e68: function() { return handleError(function (arg0, arg1) {
334
+ const ret = new Blob(arg0, arg1);
335
+ return ret;
336
+ }, arguments); },
337
+ __wbg_now_a3af9a2f4bbaa4d1: function() {
338
+ const ret = Date.now();
339
+ return ret;
340
+ },
341
+ __wbg_of_f915f7cd925b21a5: function(arg0) {
342
+ const ret = Array.of(arg0);
343
+ return ret;
344
+ },
345
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
346
+ const ret = arg0.queueMicrotask;
347
+ return ret;
348
+ },
349
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
350
+ queueMicrotask(arg0);
351
+ },
352
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
353
+ const ret = Promise.resolve(arg0);
354
+ return ret;
355
+ },
356
+ __wbg_revokeObjectURL_ba5712ef5af8bc9a: function() { return handleError(function (arg0, arg1) {
357
+ URL.revokeObjectURL(getStringFromWasm0(arg0, arg1));
358
+ }, arguments); },
359
+ __wbg_rowSpan_91d5a09e54424f2b: function(arg0) {
360
+ const ret = arg0.rowSpan;
361
+ return ret;
362
+ },
363
+ __wbg_rows_6ceaceafcb953da9: function(arg0) {
364
+ const ret = arg0.rows;
365
+ return ret;
366
+ },
367
+ __wbg_rows_c2bcff591f66a0c1: function(arg0) {
368
+ const ret = arg0.rows;
369
+ return ret;
370
+ },
371
+ __wbg_setTimeout_eff32631ea138533: function() { return handleError(function (arg0, arg1, arg2) {
372
+ const ret = arg0.setTimeout(arg1, arg2);
373
+ return ret;
374
+ }, arguments); },
375
+ __wbg_set_download_781b1800b8ba28de: function(arg0, arg1, arg2) {
376
+ arg0.download = getStringFromWasm0(arg1, arg2);
377
+ },
378
+ __wbg_set_href_d58528c85ef24c47: function(arg0, arg1, arg2) {
379
+ arg0.href = getStringFromWasm0(arg1, arg2);
380
+ },
381
+ __wbg_set_type_148de20768639245: function(arg0, arg1, arg2) {
382
+ arg0.type = getStringFromWasm0(arg1, arg2);
383
+ },
384
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
385
+ const ret = typeof global === 'undefined' ? null : global;
386
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
387
+ },
388
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
389
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
390
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
391
+ },
392
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
393
+ const ret = typeof self === 'undefined' ? null : self;
394
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
395
+ },
396
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
397
+ const ret = typeof window === 'undefined' ? null : window;
398
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
399
+ },
400
+ __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
401
+ const ret = arg0.then(arg1, arg2);
402
+ return ret;
403
+ },
404
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
405
+ const ret = arg0.then(arg1);
406
+ return ret;
407
+ },
408
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
409
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 753, function: Function { arguments: [Externref], shim_idx: 754, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
410
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hfa0c196dc31165a7, wasm_bindgen__convert__closures_____invoke__h44abe8207b381064);
411
+ return ret;
412
+ },
413
+ __wbindgen_cast_0000000000000002: function(arg0) {
414
+ // Cast intrinsic for `F64 -> Externref`.
415
+ const ret = arg0;
416
+ return ret;
417
+ },
418
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
419
+ // Cast intrinsic for `Ref(String) -> Externref`.
420
+ const ret = getStringFromWasm0(arg0, arg1);
421
+ return ret;
422
+ },
423
+ __wbindgen_init_externref_table: function() {
424
+ const table = wasm.__wbindgen_externrefs;
425
+ const offset = table.grow(4);
426
+ table.set(0, undefined);
427
+ table.set(offset + 0, undefined);
428
+ table.set(offset + 1, null);
429
+ table.set(offset + 2, true);
430
+ table.set(offset + 3, false);
431
+ },
432
+ };
433
+ return {
434
+ __proto__: null,
435
+ "./belobog_stellar_grid_bg.js": import0,
436
+ };
437
+ }
438
+
439
+ function wasm_bindgen__convert__closures_____invoke__h44abe8207b381064(arg0, arg1, arg2) {
440
+ wasm.wasm_bindgen__convert__closures_____invoke__h44abe8207b381064(arg0, arg1, arg2);
441
+ }
442
+
443
+ function wasm_bindgen__convert__closures_____invoke__h532f206189913be7(arg0, arg1, arg2, arg3) {
444
+ wasm.wasm_bindgen__convert__closures_____invoke__h532f206189913be7(arg0, arg1, arg2, arg3);
445
+ }
2
446
 
3
447
  function addToExternrefTable0(obj) {
4
448
  const idx = wasm.__externref_table_alloc();
@@ -209,148 +653,33 @@ if (!('encodeInto' in cachedTextEncoder)) {
209
653
  read: arg.length,
210
654
  written: buf.length
211
655
  };
212
- }
656
+ };
213
657
  }
214
658
 
215
659
  let WASM_VECTOR_LEN = 0;
216
660
 
217
- function wasm_bindgen__convert__closures_____invoke__hd548f8095fd5fd71(arg0, arg1, arg2) {
218
- wasm.wasm_bindgen__convert__closures_____invoke__hd548f8095fd5fd71(arg0, arg1, arg2);
219
- }
220
-
221
- function wasm_bindgen__convert__closures_____invoke__h27f1beedb8b1e394(arg0, arg1, arg2, arg3) {
222
- wasm.wasm_bindgen__convert__closures_____invoke__h27f1beedb8b1e394(arg0, arg1, arg2, arg3);
223
- }
224
-
225
- /**
226
- * 导出格式枚举
227
- * @enum {0 | 1}
228
- */
229
- export const ExportFormat = Object.freeze({
230
- /**
231
- * CSV 格式(默认)
232
- */
233
- Csv: 0, "0": "Csv",
234
- /**
235
- * Excel XLSX 格式
236
- */
237
- Xlsx: 1, "1": "Xlsx",
238
- });
239
-
240
- /**
241
- * 统一的表格导出函数(带进度回调)
242
- *
243
- * 支持导出为 CSV 或 Excel 格式,通过 format 参数控制,支持进度回调
244
- *
245
- * # 参数
246
- * * `table_id` - 要导出的 HTML 表格元素的 ID
247
- * * `filename` - 可选的导出文件名(不包含扩展名时会自动添加)
248
- * * `format` - 导出格式(Csv 或 Xlsx),默认为 Csv
249
- * * `progress_callback` - 可选的进度回调函数,接收 0-100 的进度值
250
- *
251
- * # 返回值
252
- * * `Ok(())` - 导出成功
253
- * * `Err(JsValue)` - 导出失败,包含错误信息
254
- *
255
- * # 示例
256
- * ```javascript
257
- * import init, { export_table, ExportFormat } from './pkg/excel_exporter.js';
258
- * await init();
259
- *
260
- * // 导出为 CSV(默认,无进度回调)
261
- * export_table('my-table');
262
- * export_table('my-table', '数据.csv');
263
- *
264
- * // 导出为 CSV(带进度回调)
265
- * export_table('my-table', '数据', ExportFormat.Csv, (progress) => {
266
- * console.log(`进度: ${progress.toFixed(1)}%`);
267
- * });
268
- *
269
- * // 导出为 Excel(带进度回调)
270
- * export_table('my-table', '报表', ExportFormat.Xlsx, (progress) => {
271
- * document.getElementById('progress').style.width = `${progress}%`;
272
- * });
273
- * ```
274
- * @param {string} table_id
275
- * @param {string | null} [filename]
276
- * @param {ExportFormat | null} [format]
277
- * @param {Function | null} [progress_callback]
278
- */
279
- export function export_table(table_id, filename, format, progress_callback) {
280
- const ptr0 = passStringToWasm0(table_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
281
- const len0 = WASM_VECTOR_LEN;
282
- var ptr1 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
- var len1 = WASM_VECTOR_LEN;
284
- const ret = wasm.export_table(ptr0, len0, ptr1, len1, isLikeNone(format) ? 2 : format, isLikeNone(progress_callback) ? 0 : addToExternrefTable0(progress_callback));
285
- if (ret[1]) {
286
- throw takeFromExternrefTable0(ret[0]);
287
- }
288
- }
289
-
290
- /**
291
- * 分批异步导出 HTML 表格到 CSV 文件
292
- *
293
- * 这个函数将表格数据分批处理,在批次之间让出控制权给浏览器事件循环,
294
- * 从而避免在处理大量数据时阻塞主线程导致页面卡死。
295
- *
296
- * # 参数
297
- * * `table_id` - 要导出的 HTML 表格元素的 ID
298
- * * `tbody_id` - 可选的数据表格体 ID(用于分离表头和数据)
299
- * * `filename` - 可选的导出文件名(可选,默认为 "table_export.csv")
300
- * * `batch_size` - 每批处理的行数(默认 1000)
301
- * * `progress_callback` - 进度回调函数,接收进度百分比 (0-100)
302
- *
303
- * # 返回值
304
- * * `Promise<void>` - 异步操作的 Promise
305
- *
306
- * # 示例
307
- * ```javascript
308
- * import { export_table_to_csv_batch } from './pkg/excel_exporter.js';
309
- *
310
- * await export_table_to_csv_batch(
311
- * 'my-table',
312
- * 'my-tbody', // 可选的 tbody ID
313
- * 'data.csv',
314
- * 1000, // 每批 1000 行
315
- * (progress) => {
316
- * console.log(`进度: ${progress}%`);
317
- * }
318
- * );
319
- * ```
320
- * @param {string} table_id
321
- * @param {string | null} [tbody_id]
322
- * @param {string | null} [filename]
323
- * @param {number | null} [batch_size]
324
- * @param {Function | null} [progress_callback]
325
- * @returns {Promise<any>}
326
- */
327
- export function export_table_to_csv_batch(table_id, tbody_id, filename, batch_size, progress_callback) {
328
- const ptr0 = passStringToWasm0(table_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
329
- const len0 = WASM_VECTOR_LEN;
330
- var ptr1 = isLikeNone(tbody_id) ? 0 : passStringToWasm0(tbody_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
331
- var len1 = WASM_VECTOR_LEN;
332
- var ptr2 = isLikeNone(filename) ? 0 : passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
333
- var len2 = WASM_VECTOR_LEN;
334
- const ret = wasm.export_table_to_csv_batch(ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(batch_size) ? 0x100000001 : (batch_size) >>> 0, isLikeNone(progress_callback) ? 0 : addToExternrefTable0(progress_callback));
335
- return ret;
661
+ let wasmModule, wasm;
662
+ function __wbg_finalize_init(instance, module) {
663
+ wasm = instance.exports;
664
+ wasmModule = module;
665
+ cachedDataViewMemory0 = null;
666
+ cachedUint8ArrayMemory0 = null;
667
+ wasm.__wbindgen_start();
668
+ return wasm;
336
669
  }
337
670
 
338
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
339
-
340
671
  async function __wbg_load(module, imports) {
341
672
  if (typeof Response === 'function' && module instanceof Response) {
342
673
  if (typeof WebAssembly.instantiateStreaming === 'function') {
343
674
  try {
344
675
  return await WebAssembly.instantiateStreaming(module, imports);
345
676
  } catch (e) {
346
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
677
+ const validResponse = module.ok && expectedResponseType(module.type);
347
678
 
348
679
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
349
680
  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);
350
681
 
351
- } else {
352
- throw e;
353
- }
682
+ } else { throw e; }
354
683
  }
355
684
  }
356
685
 
@@ -365,286 +694,20 @@ async function __wbg_load(module, imports) {
365
694
  return instance;
366
695
  }
367
696
  }
368
- }
369
697
 
370
- function __wbg_get_imports() {
371
- const imports = {};
372
- imports.wbg = {};
373
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
374
- const ret = debugString(arg1);
375
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
- const len1 = WASM_VECTOR_LEN;
377
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
378
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
379
- };
380
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
381
- const ret = typeof(arg0) === 'function';
382
- return ret;
383
- };
384
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
385
- const ret = arg0 === undefined;
386
- return ret;
387
- };
388
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
389
- throw new Error(getStringFromWasm0(arg0, arg1));
390
- };
391
- imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) {
392
- arg0._wbg_cb_unref();
393
- };
394
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
395
- const ret = arg0.call(arg1, arg2);
396
- return ret;
397
- }, arguments) };
398
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
399
- const ret = arg0.call(arg1);
400
- return ret;
401
- }, arguments) };
402
- imports.wbg.__wbg_cells_545c799983014137 = function(arg0) {
403
- const ret = arg0.cells;
404
- return ret;
405
- };
406
- imports.wbg.__wbg_click_3a8e35c38329dd3a = function(arg0) {
407
- arg0.click();
408
- };
409
- imports.wbg.__wbg_createElement_da4ed2b219560fc6 = function() { return handleError(function (arg0, arg1, arg2) {
410
- const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
411
- return ret;
412
- }, arguments) };
413
- imports.wbg.__wbg_createObjectURL_7d9f7f8f41373850 = function() { return handleError(function (arg0, arg1) {
414
- const ret = URL.createObjectURL(arg1);
415
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
416
- const len1 = WASM_VECTOR_LEN;
417
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
418
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
419
- }, arguments) };
420
- imports.wbg.__wbg_document_5b745e82ba551ca5 = function(arg0) {
421
- const ret = arg0.document;
422
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
423
- };
424
- imports.wbg.__wbg_getElementById_e05488d2143c2b21 = function(arg0, arg1, arg2) {
425
- const ret = arg0.getElementById(getStringFromWasm0(arg1, arg2));
426
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
427
- };
428
- imports.wbg.__wbg_get_with_index_02edcfc1dc5cd213 = function(arg0, arg1) {
429
- const ret = arg0[arg1 >>> 0];
430
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
431
- };
432
- imports.wbg.__wbg_innerText_f0031d4a341b201e = function(arg0, arg1) {
433
- const ret = arg1.innerText;
434
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
435
- const len1 = WASM_VECTOR_LEN;
436
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
437
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
438
- };
439
- imports.wbg.__wbg_instanceof_HtmlAnchorElement_2ac07b5cf25eac0c = function(arg0) {
440
- let result;
441
- try {
442
- result = arg0 instanceof HTMLAnchorElement;
443
- } catch (_) {
444
- result = false;
445
- }
446
- const ret = result;
447
- return ret;
448
- };
449
- imports.wbg.__wbg_instanceof_HtmlTableCellElement_75e96f69f361508a = function(arg0) {
450
- let result;
451
- try {
452
- result = arg0 instanceof HTMLTableCellElement;
453
- } catch (_) {
454
- result = false;
455
- }
456
- const ret = result;
457
- return ret;
458
- };
459
- imports.wbg.__wbg_instanceof_HtmlTableElement_25f7ed83ddf67808 = function(arg0) {
460
- let result;
461
- try {
462
- result = arg0 instanceof HTMLTableElement;
463
- } catch (_) {
464
- result = false;
465
- }
466
- const ret = result;
467
- return ret;
468
- };
469
- imports.wbg.__wbg_instanceof_HtmlTableRowElement_616c98709e3ec634 = function(arg0) {
470
- let result;
471
- try {
472
- result = arg0 instanceof HTMLTableRowElement;
473
- } catch (_) {
474
- result = false;
698
+ function expectedResponseType(type) {
699
+ switch (type) {
700
+ case 'basic': case 'cors': case 'default': return true;
475
701
  }
476
- const ret = result;
477
- return ret;
478
- };
479
- imports.wbg.__wbg_instanceof_HtmlTableSectionElement_e3071b60d4dbdcd0 = function(arg0) {
480
- let result;
481
- try {
482
- result = arg0 instanceof HTMLTableSectionElement;
483
- } catch (_) {
484
- result = false;
485
- }
486
- const ret = result;
487
- return ret;
488
- };
489
- imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) {
490
- let result;
491
- try {
492
- result = arg0 instanceof Window;
493
- } catch (_) {
494
- result = false;
495
- }
496
- const ret = result;
497
- return ret;
498
- };
499
- imports.wbg.__wbg_length_149bfa5fd618b65f = function(arg0) {
500
- const ret = arg0.length;
501
- return ret;
502
- };
503
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
504
- const ret = new Object();
505
- return ret;
506
- };
507
- imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) {
508
- try {
509
- var state0 = {a: arg0, b: arg1};
510
- var cb0 = (arg0, arg1) => {
511
- const a = state0.a;
512
- state0.a = 0;
513
- try {
514
- return wasm_bindgen__convert__closures_____invoke__h27f1beedb8b1e394(a, state0.b, arg0, arg1);
515
- } finally {
516
- state0.a = a;
517
- }
518
- };
519
- const ret = new Promise(cb0);
520
- return ret;
521
- } finally {
522
- state0.a = state0.b = 0;
523
- }
524
- };
525
- imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) {
526
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
527
- return ret;
528
- };
529
- imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
530
- const ret = new Function(getStringFromWasm0(arg0, arg1));
531
- return ret;
532
- };
533
- imports.wbg.__wbg_new_with_u8_array_sequence_and_options_d4def9ec0588c7ec = function() { return handleError(function (arg0, arg1) {
534
- const ret = new Blob(arg0, arg1);
535
- return ret;
536
- }, arguments) };
537
- imports.wbg.__wbg_now_69d776cd24f5215b = function() {
538
- const ret = Date.now();
539
- return ret;
540
- };
541
- imports.wbg.__wbg_of_6505a0eb509da02e = function(arg0) {
542
- const ret = Array.of(arg0);
543
- return ret;
544
- };
545
- imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) {
546
- const ret = arg0.queueMicrotask;
547
- return ret;
548
- };
549
- imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) {
550
- queueMicrotask(arg0);
551
- };
552
- imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) {
553
- const ret = Promise.resolve(arg0);
554
- return ret;
555
- };
556
- imports.wbg.__wbg_revokeObjectURL_88db3468842ff09e = function() { return handleError(function (arg0, arg1) {
557
- URL.revokeObjectURL(getStringFromWasm0(arg0, arg1));
558
- }, arguments) };
559
- imports.wbg.__wbg_rows_33a123c88e38a6a7 = function(arg0) {
560
- const ret = arg0.rows;
561
- return ret;
562
- };
563
- imports.wbg.__wbg_rows_744ac6d4cb0ec6fa = function(arg0) {
564
- const ret = arg0.rows;
565
- return ret;
566
- };
567
- imports.wbg.__wbg_setTimeout_06477c23d31efef1 = function() { return handleError(function (arg0, arg1, arg2) {
568
- const ret = arg0.setTimeout(arg1, arg2);
569
- return ret;
570
- }, arguments) };
571
- imports.wbg.__wbg_set_download_8403fd66b94b25a2 = function(arg0, arg1, arg2) {
572
- arg0.download = getStringFromWasm0(arg1, arg2);
573
- };
574
- imports.wbg.__wbg_set_href_25c4bcdcbfb4459b = function(arg0, arg1, arg2) {
575
- arg0.href = getStringFromWasm0(arg1, arg2);
576
- };
577
- imports.wbg.__wbg_set_type_7ce650670a34c68f = function(arg0, arg1, arg2) {
578
- arg0.type = getStringFromWasm0(arg1, arg2);
579
- };
580
- imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
581
- const ret = typeof global === 'undefined' ? null : global;
582
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
583
- };
584
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
585
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
586
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
587
- };
588
- imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
589
- const ret = typeof self === 'undefined' ? null : self;
590
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
591
- };
592
- imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
593
- const ret = typeof window === 'undefined' ? null : window;
594
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
595
- };
596
- imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) {
597
- const ret = arg0.then(arg1, arg2);
598
- return ret;
599
- };
600
- imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) {
601
- const ret = arg0.then(arg1);
602
- return ret;
603
- };
604
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
605
- // Cast intrinsic for `Ref(String) -> Externref`.
606
- const ret = getStringFromWasm0(arg0, arg1);
607
- return ret;
608
- };
609
- imports.wbg.__wbindgen_cast_47ef039842436c85 = function(arg0, arg1) {
610
- // Cast intrinsic for `Closure(Closure { dtor_idx: 738, function: Function { arguments: [Externref], shim_idx: 739, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
611
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hd85ddfaf9b76fe33, wasm_bindgen__convert__closures_____invoke__hd548f8095fd5fd71);
612
- return ret;
613
- };
614
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
615
- // Cast intrinsic for `F64 -> Externref`.
616
- const ret = arg0;
617
- return ret;
618
- };
619
- imports.wbg.__wbindgen_init_externref_table = function() {
620
- const table = wasm.__wbindgen_externrefs;
621
- const offset = table.grow(4);
622
- table.set(0, undefined);
623
- table.set(offset + 0, undefined);
624
- table.set(offset + 1, null);
625
- table.set(offset + 2, true);
626
- table.set(offset + 3, false);
627
- };
628
-
629
- return imports;
630
- }
631
-
632
- function __wbg_finalize_init(instance, module) {
633
- wasm = instance.exports;
634
- __wbg_init.__wbindgen_wasm_module = module;
635
- cachedDataViewMemory0 = null;
636
- cachedUint8ArrayMemory0 = null;
637
-
638
-
639
- wasm.__wbindgen_start();
640
- return wasm;
702
+ return false;
703
+ }
641
704
  }
642
705
 
643
706
  function initSync(module) {
644
707
  if (wasm !== undefined) return wasm;
645
708
 
646
709
 
647
- if (typeof module !== 'undefined') {
710
+ if (module !== undefined) {
648
711
  if (Object.getPrototypeOf(module) === Object.prototype) {
649
712
  ({module} = module)
650
713
  } else {
@@ -664,7 +727,7 @@ async function __wbg_init(module_or_path) {
664
727
  if (wasm !== undefined) return wasm;
665
728
 
666
729
 
667
- if (typeof module_or_path !== 'undefined') {
730
+ if (module_or_path !== undefined) {
668
731
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
669
732
  ({module_or_path} = module_or_path)
670
733
  } else {
@@ -672,7 +735,7 @@ async function __wbg_init(module_or_path) {
672
735
  }
673
736
  }
674
737
 
675
- if (typeof module_or_path === 'undefined') {
738
+ if (module_or_path === undefined) {
676
739
  module_or_path = new URL('belobog_stellar_grid_bg.wasm', import.meta.url);
677
740
  }
678
741
  const imports = __wbg_get_imports();
@@ -686,5 +749,4 @@ async function __wbg_init(module_or_path) {
686
749
  return __wbg_finalize_init(instance, module);
687
750
  }
688
751
 
689
- export { initSync };
690
- export default __wbg_init;
752
+ export { initSync, __wbg_init as default };