@casoon/opengrid 0.16.0 → 0.18.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +171 -1
  2. package/README.md +3 -3
  3. package/collation/opengrid_collation.d.ts +47 -0
  4. package/collation/opengrid_collation.js +256 -0
  5. package/collation/opengrid_collation_bg.wasm +0 -0
  6. package/collation/opengrid_collation_bg.wasm.d.ts +10 -0
  7. package/collation.js +48 -0
  8. package/engine/opengrid_wasm.d.ts +77 -1
  9. package/engine/opengrid_wasm.js +187 -0
  10. package/engine/opengrid_wasm_bg.wasm +0 -0
  11. package/engine/opengrid_wasm_bg.wasm.d.ts +14 -1
  12. package/loader.d.ts +45 -0
  13. package/loader.js +452 -8
  14. package/package.json +4 -1
  15. package/pkg/opengrid_web_components.d.ts +10 -10
  16. package/pkg/opengrid_web_components.js +50 -50
  17. package/pkg/opengrid_web_components_bg.wasm +0 -0
  18. package/pkg/opengrid_web_components_bg.wasm.d.ts +10 -10
  19. package/react/index.d.ts +2 -0
  20. package/react/index.js +1 -0
  21. package/svelte/OpengridGrid.svelte +2 -0
  22. package/svelte/index.d.ts +2 -0
  23. package/vue/index.d.ts +2 -0
  24. package/vue/index.js +1 -0
  25. package/worker.js +84 -1
  26. package/xlsx/opengrid_xlsx_bg.wasm +0 -0
  27. /package/pkg/snippets/{opengrid-web-components-35ed06b453a9b215 → opengrid-web-components-bcd23b5e2228bf0e}/inline0.js +0 -0
  28. /package/pkg/snippets/{opengrid-web-components-35ed06b453a9b215 → opengrid-web-components-bcd23b5e2228bf0e}/inline1.js +0 -0
  29. /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline0.js +0 -0
  30. /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline1.js +0 -0
  31. /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline2.js +0 -0
@@ -11,6 +11,39 @@
11
11
  export class Engine {
12
12
  free(): void;
13
13
  [Symbol.dispose](): void;
14
+ /**
15
+ * Drops the rows `begin_columns` started, nothing registered. Nothing to drop is not an
16
+ * error.
17
+ */
18
+ abort_columns(): void;
19
+ /**
20
+ * Drops the file `begin_csv` started, nothing registered: for a page whose reading of the
21
+ * file failed. Nothing to drop is not an error.
22
+ */
23
+ abort_csv(): void;
24
+ /**
25
+ * Starts reading the rows a page holds as packs of typed columns (issue #445): `push_columns`
26
+ * for each pack, then `end_columns`. `rows` is the number of rows of the whole table; the
27
+ * columns are sized by it. The format of a pack is in `opengrid_engine::ingest`. Rows begun
28
+ * before and not ended are dropped. An error here or later sends the page to `load_rows`,
29
+ * which owns every message.
30
+ */
31
+ begin_columns(name: string, schema_json: string, rows: number): void;
32
+ /**
33
+ * Starts reading a CSV file in pieces (issue #427): `push_csv` for each piece, then
34
+ * `end_csv`. Only a piece and the columns are in memory, not the whole file as well. The
35
+ * pieces may end anywhere. `size_hint` is the file's size in bytes, 0 when unknown; it only
36
+ * sizes the columns. A file begun before and not ended is dropped.
37
+ */
38
+ begin_csv(name: string, schema_json: string, size_hint: number): void;
39
+ /**
40
+ * The end of the rows: registers the source, replacing one of that name.
41
+ */
42
+ end_columns(): void;
43
+ /**
44
+ * The end of the file: registers the source, replacing one of that name.
45
+ */
46
+ end_csv(): void;
14
47
  /**
15
48
  * Runs a query JSON and answers with the result JSON.
16
49
  *
@@ -56,6 +89,24 @@ export class Engine {
56
89
  * hand the element.
57
90
  */
58
91
  pivot_columns(pivot_json: string): Uint8Array;
92
+ /**
93
+ * The next pack of the rows `begin_columns` started. A pack that does not hold ends the
94
+ * reading: nothing is registered.
95
+ */
96
+ push_columns(pack: Uint8Array): void;
97
+ /**
98
+ * The next piece of the file `begin_csv` started. A piece that cannot be read ends the
99
+ * file: nothing is registered, and the error names the line.
100
+ */
101
+ push_csv(bytes: Uint8Array): void;
102
+ /**
103
+ * Gives the engine its collator (rule S4a, issue #391): `sort_keys` of
104
+ * the collation module, which a page loads when a query first sorts by a
105
+ * locale — the providers of the package do. Until then such a sort is
106
+ * refused; a sort without a locale never needs it. It holds for every
107
+ * engine and planner of this module.
108
+ */
109
+ set_collator(sort_keys: any): void;
59
110
  /**
60
111
  * The names of the registered sources, in unspecified order.
61
112
  */
@@ -69,6 +120,13 @@ export class Engine {
69
120
  * it. Sources by name.
70
121
  */
71
122
  stats(): string;
123
+ /**
124
+ * Frees the source `name` (issue #459); `true` when there was one. The
125
+ * module's memory does not shrink — WebAssembly memory only grows — but
126
+ * the next load takes the room the table had, so a page that unloads
127
+ * before it loads again needs one table's room, not two.
128
+ */
129
+ unload(name: string): boolean;
72
130
  /**
73
131
  * The query of a view (issue #144): what `get_query()` answers on an
74
132
  * `<opengrid-grid datasource=source columns=…>` once `view_json` is
@@ -133,6 +191,11 @@ export class Planner {
133
191
  * [`finish`](Planner::finish), or `null` when the source answers it all.
134
192
  */
135
193
  plan(query_json: string, mode: string): string;
194
+ /**
195
+ * The collator for the half of a query the planner finishes here, as
196
+ * [`Engine::set_collator`].
197
+ */
198
+ set_collator(sort_keys: any): void;
136
199
  }
137
200
 
138
201
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -141,6 +204,12 @@ export interface InitOutput {
141
204
  readonly memory: WebAssembly.Memory;
142
205
  readonly __wbg_engine_free: (a: number, b: number) => void;
143
206
  readonly __wbg_planner_free: (a: number, b: number) => void;
207
+ readonly engine_abort_columns: (a: number) => void;
208
+ readonly engine_abort_csv: (a: number) => void;
209
+ readonly engine_begin_columns: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
210
+ readonly engine_begin_csv: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
211
+ readonly engine_end_columns: (a: number) => [number, number];
212
+ readonly engine_end_csv: (a: number) => [number, number];
144
213
  readonly engine_execute: (a: number, b: number, c: number) => [number, number, number, number];
145
214
  readonly engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
146
215
  readonly engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
@@ -148,16 +217,23 @@ export interface InitOutput {
148
217
  readonly engine_new: () => number;
149
218
  readonly engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
150
219
  readonly engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
220
+ readonly engine_push_columns: (a: number, b: number, c: number) => [number, number];
221
+ readonly engine_push_csv: (a: number, b: number, c: number) => [number, number];
222
+ readonly engine_set_collator: (a: number, b: any) => void;
151
223
  readonly engine_source_names: (a: number) => [number, number];
152
224
  readonly engine_stats: (a: number) => [number, number];
225
+ readonly engine_unload: (a: number, b: number, c: number) => number;
153
226
  readonly engine_view_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
154
227
  readonly planner_finish: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
155
228
  readonly planner_finish_columns: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
156
229
  readonly planner_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
157
230
  readonly planner_plan: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
158
- readonly __wbindgen_externrefs: WebAssembly.Table;
231
+ readonly planner_set_collator: (a: number, b: any) => void;
159
232
  readonly __wbindgen_malloc: (a: number, b: number) => number;
160
233
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
234
+ readonly __wbindgen_exn_store: (a: number) => void;
235
+ readonly __externref_table_alloc: () => number;
236
+ readonly __wbindgen_externrefs: WebAssembly.Table;
161
237
  readonly __externref_table_dealloc: (a: number) => void;
162
238
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
163
239
  readonly __externref_drop_slice: (a: number, b: number) => void;
@@ -18,6 +18,77 @@ export class Engine {
18
18
  const ptr = this.__destroy_into_raw();
19
19
  wasm.__wbg_engine_free(ptr, 0);
20
20
  }
21
+ /**
22
+ * Drops the rows `begin_columns` started, nothing registered. Nothing to drop is not an
23
+ * error.
24
+ */
25
+ abort_columns() {
26
+ wasm.engine_abort_columns(this.__wbg_ptr);
27
+ }
28
+ /**
29
+ * Drops the file `begin_csv` started, nothing registered: for a page whose reading of the
30
+ * file failed. Nothing to drop is not an error.
31
+ */
32
+ abort_csv() {
33
+ wasm.engine_abort_csv(this.__wbg_ptr);
34
+ }
35
+ /**
36
+ * Starts reading the rows a page holds as packs of typed columns (issue #445): `push_columns`
37
+ * for each pack, then `end_columns`. `rows` is the number of rows of the whole table; the
38
+ * columns are sized by it. The format of a pack is in `opengrid_engine::ingest`. Rows begun
39
+ * before and not ended are dropped. An error here or later sends the page to `load_rows`,
40
+ * which owns every message.
41
+ * @param {string} name
42
+ * @param {string} schema_json
43
+ * @param {number} rows
44
+ */
45
+ begin_columns(name, schema_json, rows) {
46
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
+ const len0 = WASM_VECTOR_LEN;
48
+ const ptr1 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len1 = WASM_VECTOR_LEN;
50
+ const ret = wasm.engine_begin_columns(this.__wbg_ptr, ptr0, len0, ptr1, len1, rows);
51
+ if (ret[1]) {
52
+ throw takeFromExternrefTable0(ret[0]);
53
+ }
54
+ }
55
+ /**
56
+ * Starts reading a CSV file in pieces (issue #427): `push_csv` for each piece, then
57
+ * `end_csv`. Only a piece and the columns are in memory, not the whole file as well. The
58
+ * pieces may end anywhere. `size_hint` is the file's size in bytes, 0 when unknown; it only
59
+ * sizes the columns. A file begun before and not ended is dropped.
60
+ * @param {string} name
61
+ * @param {string} schema_json
62
+ * @param {number} size_hint
63
+ */
64
+ begin_csv(name, schema_json, size_hint) {
65
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ptr1 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len1 = WASM_VECTOR_LEN;
69
+ const ret = wasm.engine_begin_csv(this.__wbg_ptr, ptr0, len0, ptr1, len1, size_hint);
70
+ if (ret[1]) {
71
+ throw takeFromExternrefTable0(ret[0]);
72
+ }
73
+ }
74
+ /**
75
+ * The end of the rows: registers the source, replacing one of that name.
76
+ */
77
+ end_columns() {
78
+ const ret = wasm.engine_end_columns(this.__wbg_ptr);
79
+ if (ret[1]) {
80
+ throw takeFromExternrefTable0(ret[0]);
81
+ }
82
+ }
83
+ /**
84
+ * The end of the file: registers the source, replacing one of that name.
85
+ */
86
+ end_csv() {
87
+ const ret = wasm.engine_end_csv(this.__wbg_ptr);
88
+ if (ret[1]) {
89
+ throw takeFromExternrefTable0(ret[0]);
90
+ }
91
+ }
21
92
  /**
22
93
  * Runs a query JSON and answers with the result JSON.
23
94
  *
@@ -162,6 +233,43 @@ export class Engine {
162
233
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
163
234
  return v2;
164
235
  }
236
+ /**
237
+ * The next pack of the rows `begin_columns` started. A pack that does not hold ends the
238
+ * reading: nothing is registered.
239
+ * @param {Uint8Array} pack
240
+ */
241
+ push_columns(pack) {
242
+ const ptr0 = passArray8ToWasm0(pack, wasm.__wbindgen_malloc);
243
+ const len0 = WASM_VECTOR_LEN;
244
+ const ret = wasm.engine_push_columns(this.__wbg_ptr, ptr0, len0);
245
+ if (ret[1]) {
246
+ throw takeFromExternrefTable0(ret[0]);
247
+ }
248
+ }
249
+ /**
250
+ * The next piece of the file `begin_csv` started. A piece that cannot be read ends the
251
+ * file: nothing is registered, and the error names the line.
252
+ * @param {Uint8Array} bytes
253
+ */
254
+ push_csv(bytes) {
255
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
256
+ const len0 = WASM_VECTOR_LEN;
257
+ const ret = wasm.engine_push_csv(this.__wbg_ptr, ptr0, len0);
258
+ if (ret[1]) {
259
+ throw takeFromExternrefTable0(ret[0]);
260
+ }
261
+ }
262
+ /**
263
+ * Gives the engine its collator (rule S4a, issue #391): `sort_keys` of
264
+ * the collation module, which a page loads when a query first sorts by a
265
+ * locale — the providers of the package do. Until then such a sort is
266
+ * refused; a sort without a locale never needs it. It holds for every
267
+ * engine and planner of this module.
268
+ * @param {any} sort_keys
269
+ */
270
+ set_collator(sort_keys) {
271
+ wasm.engine_set_collator(this.__wbg_ptr, sort_keys);
272
+ }
165
273
  /**
166
274
  * The names of the registered sources, in unspecified order.
167
275
  * @returns {string[]}
@@ -193,6 +301,20 @@ export class Engine {
193
301
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
194
302
  }
195
303
  }
304
+ /**
305
+ * Frees the source `name` (issue #459); `true` when there was one. The
306
+ * module's memory does not shrink — WebAssembly memory only grows — but
307
+ * the next load takes the room the table had, so a page that unloads
308
+ * before it loads again needs one table's room, not two.
309
+ * @param {string} name
310
+ * @returns {boolean}
311
+ */
312
+ unload(name) {
313
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
314
+ const len0 = WASM_VECTOR_LEN;
315
+ const ret = wasm.engine_unload(this.__wbg_ptr, ptr0, len0);
316
+ return ret !== 0;
317
+ }
196
318
  /**
197
319
  * The query of a view (issue #144): what `get_query()` answers on an
198
320
  * `<opengrid-grid datasource=source columns=…>` once `view_json` is
@@ -373,6 +495,14 @@ export class Planner {
373
495
  wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
374
496
  }
375
497
  }
498
+ /**
499
+ * The collator for the half of a query the planner finishes here, as
500
+ * [`Engine::set_collator`].
501
+ * @param {any} sort_keys
502
+ */
503
+ set_collator(sort_keys) {
504
+ wasm.planner_set_collator(this.__wbg_ptr, sort_keys);
505
+ }
376
506
  }
377
507
  if (Symbol.dispose) Planner.prototype[Symbol.dispose] = Planner.prototype.free;
378
508
  function __wbg_get_imports() {
@@ -382,9 +512,33 @@ function __wbg_get_imports() {
382
512
  const ret = Error(getStringFromWasm0(arg0, arg1));
383
513
  return ret;
384
514
  },
515
+ __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
516
+ const val = arg0;
517
+ const ret = typeof(val) === 'object' && val !== null;
518
+ return ret;
519
+ },
520
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
521
+ const obj = arg1;
522
+ const ret = typeof(obj) === 'string' ? obj : undefined;
523
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
524
+ var len1 = WASM_VECTOR_LEN;
525
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
526
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
527
+ },
385
528
  __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
386
529
  throw new Error(getStringFromWasm0(arg0, arg1));
387
530
  },
531
+ __wbg_call_adc28cee1855bc9a: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
532
+ const ret = arg1.call(arg2, getStringFromWasm0(arg3, arg4), getArrayU8FromWasm0(arg5, arg6), getArrayU32FromWasm0(arg7, arg8));
533
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
534
+ const len1 = WASM_VECTOR_LEN;
535
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
536
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
537
+ }, arguments); },
538
+ __wbg_message_a9ff8f5cb38920f2: function(arg0) {
539
+ const ret = arg0.message;
540
+ return ret;
541
+ },
388
542
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
389
543
  // Cast intrinsic for `Ref(String) -> Externref`.
390
544
  const ret = getStringFromWasm0(arg0, arg1);
@@ -413,6 +567,12 @@ const PlannerFinalization = (typeof FinalizationRegistry === 'undefined')
413
567
  ? { register: () => {}, unregister: () => {} }
414
568
  : new FinalizationRegistry(ptr => wasm.__wbg_planner_free(ptr, 1));
415
569
 
570
+ function addToExternrefTable0(obj) {
571
+ const idx = wasm.__externref_table_alloc();
572
+ wasm.__wbindgen_externrefs.set(idx, obj);
573
+ return idx;
574
+ }
575
+
416
576
  function getArrayJsValueFromWasm0(ptr, len) {
417
577
  ptr = ptr >>> 0;
418
578
  const mem = getDataViewMemory0();
@@ -424,6 +584,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
424
584
  return result;
425
585
  }
426
586
 
587
+ function getArrayU32FromWasm0(ptr, len) {
588
+ ptr = ptr >>> 0;
589
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
590
+ }
591
+
427
592
  function getArrayU8FromWasm0(ptr, len) {
428
593
  ptr = ptr >>> 0;
429
594
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -441,6 +606,14 @@ function getStringFromWasm0(ptr, len) {
441
606
  return decodeText(ptr >>> 0, len);
442
607
  }
443
608
 
609
+ let cachedUint32ArrayMemory0 = null;
610
+ function getUint32ArrayMemory0() {
611
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
612
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
613
+ }
614
+ return cachedUint32ArrayMemory0;
615
+ }
616
+
444
617
  let cachedUint8ArrayMemory0 = null;
445
618
  function getUint8ArrayMemory0() {
446
619
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -449,6 +622,19 @@ function getUint8ArrayMemory0() {
449
622
  return cachedUint8ArrayMemory0;
450
623
  }
451
624
 
625
+ function handleError(f, args) {
626
+ try {
627
+ return f.apply(this, args);
628
+ } catch (e) {
629
+ const idx = addToExternrefTable0(e);
630
+ wasm.__wbindgen_exn_store(idx);
631
+ }
632
+ }
633
+
634
+ function isLikeNone(x) {
635
+ return x === undefined || x === null;
636
+ }
637
+
452
638
  function passArray8ToWasm0(arg, malloc) {
453
639
  const ptr = malloc(arg.length * 1, 1) >>> 0;
454
640
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -534,6 +720,7 @@ function __wbg_finalize_init(instance, module) {
534
720
  wasm = instance.exports;
535
721
  wasmModule = module;
536
722
  cachedDataViewMemory0 = null;
723
+ cachedUint32ArrayMemory0 = null;
537
724
  cachedUint8ArrayMemory0 = null;
538
725
  wasm.__wbindgen_start();
539
726
  return wasm;
Binary file
@@ -3,6 +3,12 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_engine_free: (a: number, b: number) => void;
5
5
  export const __wbg_planner_free: (a: number, b: number) => void;
6
+ export const engine_abort_columns: (a: number) => void;
7
+ export const engine_abort_csv: (a: number) => void;
8
+ export const engine_begin_columns: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
9
+ export const engine_begin_csv: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
10
+ export const engine_end_columns: (a: number) => [number, number];
11
+ export const engine_end_csv: (a: number) => [number, number];
6
12
  export const engine_execute: (a: number, b: number, c: number) => [number, number, number, number];
7
13
  export const engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
8
14
  export const engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
@@ -10,16 +16,23 @@ export const engine_load_rows: (a: number, b: number, c: number, d: number, e: n
10
16
  export const engine_new: () => number;
11
17
  export const engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
12
18
  export const engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
19
+ export const engine_push_columns: (a: number, b: number, c: number) => [number, number];
20
+ export const engine_push_csv: (a: number, b: number, c: number) => [number, number];
21
+ export const engine_set_collator: (a: number, b: any) => void;
13
22
  export const engine_source_names: (a: number) => [number, number];
14
23
  export const engine_stats: (a: number) => [number, number];
24
+ export const engine_unload: (a: number, b: number, c: number) => number;
15
25
  export const engine_view_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
16
26
  export const planner_finish: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
17
27
  export const planner_finish_columns: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
18
28
  export const planner_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
19
29
  export const planner_plan: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
20
- export const __wbindgen_externrefs: WebAssembly.Table;
30
+ export const planner_set_collator: (a: number, b: any) => void;
21
31
  export const __wbindgen_malloc: (a: number, b: number) => number;
22
32
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
33
+ export const __wbindgen_exn_store: (a: number) => void;
34
+ export const __externref_table_alloc: () => number;
35
+ export const __wbindgen_externrefs: WebAssembly.Table;
23
36
  export const __externref_table_dealloc: (a: number) => void;
24
37
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
25
38
  export const __externref_drop_slice: (a: number, b: number) => void;
package/loader.d.ts CHANGED
@@ -311,6 +311,20 @@ export interface ExecuteOptions {
311
311
  export interface EngineProvider extends Provider {
312
312
  /** Loads CSV bytes as the source `name`, against a schema (JSON). */
313
313
  load(name: string, bytes: ArrayBuffer | Uint8Array, schema: string): Promise<void>;
314
+ /**
315
+ * Loads a CSV file piece by piece as the source `name` (issue #427): a `File` or
316
+ * `Blob` (read a slice at a time), a `ReadableStream` of bytes or an async
317
+ * iterable of them. Only a piece and the columns are in the engine's memory, not
318
+ * the whole file as well. The pieces may end anywhere. A name that is already
319
+ * loaded is replaced, all or nothing; a piece that cannot be read rejects with
320
+ * the line, and the old source stays.
321
+ */
322
+ loadStream(
323
+ name: string,
324
+ source: Blob | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,
325
+ schema: string,
326
+ options?: { chunkSize?: number },
327
+ ): Promise<void>;
314
328
  /**
315
329
  * Loads rows the page already holds as the source `name` (issue #182): an
316
330
  * array of objects keyed by field name — or that array as JSON text — with
@@ -322,6 +336,14 @@ export interface EngineProvider extends Provider {
322
336
  loadRows(name: string, rows: readonly Record<string, unknown>[] | string, schema: string): Promise<void>;
323
337
  /** Called by `set_provider`; the grid is told when a source it shows is replaced. */
324
338
  watch(host: HTMLElement): void;
339
+ /**
340
+ * Frees the source `name` (issue #459) and resolves with whether there was one.
341
+ * The engine's memory does not shrink — WebAssembly memory only grows — but the
342
+ * next load takes the room the table had: unloading before loading again needs
343
+ * one table's room instead of two, at the price of no data while the load runs.
344
+ * A grid on the name answers its next query with an unknown source.
345
+ */
346
+ unload(name: string): Promise<boolean>;
325
347
  /** What the engine holds: its memory and each source's size (issue #70). */
326
348
  stats(): Promise<EngineStats>;
327
349
  /** Stops a worker; a no-op in the tab. */
@@ -340,12 +362,27 @@ export interface EngineStats {
340
362
  /** The engine of the engine module, as `createLocalProvider` uses it. */
341
363
  export interface Engine {
342
364
  load_csv(name: string, bytes: Uint8Array, schema: string): void;
365
+ /** Reads a CSV file in pieces (issue #427): `begin_csv`, `push_csv` for each piece, `end_csv`. */
366
+ begin_csv(name: string, schema: string, sizeHint: number): void;
367
+ push_csv(bytes: Uint8Array): void;
368
+ end_csv(): void;
369
+ /** Drops a file `begin_csv` started. */
370
+ abort_csv(): void;
343
371
  /** Rows as JSON text (an array of objects); replaces a source of that name (issue #182). */
344
372
  load_rows(name: string, rowsJson: string, schema: string): void;
345
373
  /** The result as JSON. */
346
374
  execute(queryJson: string): string;
347
375
  /** The result in the binary form — what the tab and worker providers answer. */
348
376
  execute_columns(queryJson: string): Uint8Array;
377
+ /**
378
+ * Gives the engine its collator: `sort_keys` of the collation module
379
+ * (`collation/opengrid_collation.js`). A sort key that names a locale needs
380
+ * it; the providers of the package load the module and call this when a
381
+ * query first sorts by one.
382
+ */
383
+ set_collator(sortKeys: (locale: string, texts: Uint8Array, ends: Uint32Array) => Uint8Array): void;
384
+ /** Frees the source `name`; whether there was one (issue #459). */
385
+ unload(name: string): boolean;
349
386
  /** What it holds, as JSON (see `EngineStats`). */
350
387
  stats(): string;
351
388
  /** A pivot over the engine's sources, as JSON (issue #28). */
@@ -400,6 +437,8 @@ export interface PlannerLike {
400
437
  plan(queryJson: string, mode: string): string;
401
438
  /** Finishes the client half over the source's answer; the result as JSON. */
402
439
  finish(clientQueryJson: string, resultJson: string): string;
440
+ /** The collator for the client half, as `Engine.set_collator`. */
441
+ set_collator(sortKeys: (locale: string, texts: Uint8Array, ends: Uint32Array) => Uint8Array): void;
403
442
  /** The same over an answer in the binary form; the result as bytes. */
404
443
  finish_columns(clientQueryJson: string, result: Uint8Array): Uint8Array;
405
444
  }
@@ -1447,6 +1486,12 @@ export interface OpengridGridAttributes {
1447
1486
  * and-ed onto every query the grid sends. Not the reader's and not in the view.
1448
1487
  */
1449
1488
  filter?: string;
1489
+ /**
1490
+ * The locale text columns sort by — `de`, `sv`, `sr-Latn`, `und` for the root
1491
+ * collation. Every sort key of the grid on a text column carries it; without
1492
+ * it text sorts by code point. Not in the view.
1493
+ */
1494
+ collation?: string;
1450
1495
  "group-by"?: string;
1451
1496
  /** The field holding a row's parent key: the rows show as a tree. */
1452
1497
  tree?: string;