@cereusdb/standard 0.1.2 → 0.3.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.
@@ -27,11 +27,19 @@ export class CereusDB {
27
27
  * Requires the full GDAL-enabled build.
28
28
  */
29
29
  register_geotiff_buffer(table_name: string, data: Uint8Array): void;
30
+ /**
31
+ * Register browser-backed object stores for ranged/listing reads.
32
+ */
33
+ register_object_stores(config: any): void;
30
34
  /**
31
35
  * Register a Uint8Array containing Parquet data as a named table.
32
36
  * Use for files obtained via the browser File API.
33
37
  */
34
38
  register_parquet_buffer(table_name: string, data: Uint8Array): Promise<void>;
39
+ /**
40
+ * Register a remote Parquet object or prefix as a DataFusion listing table.
41
+ */
42
+ register_parquet_table(table_name: string, table_url: string, options: any): Promise<void>;
35
43
  /**
36
44
  * Register a raster buffer as a single-column raster table.
37
45
  * Requires the full GDAL-enabled build.
@@ -60,6 +68,9 @@ export class CereusDB {
60
68
  tables(): any;
61
69
  /**
62
70
  * Get version information.
71
+ *
72
+ * Release builds set `CEREUSDB_VERSION` to the full npm version, including
73
+ * prerelease suffixes; other builds fall back to the crate version.
63
74
  */
64
75
  version(): string;
65
76
  }
@@ -81,7 +92,9 @@ export interface InitOutput {
81
92
  readonly cereusdb_drop_table: (a: number, b: number, c: number) => [number, number];
82
93
  readonly cereusdb_register_geojson: (a: number, b: number, c: number, d: number, e: number) => [number, number];
83
94
  readonly cereusdb_register_geotiff_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
95
+ readonly cereusdb_register_object_stores: (a: number, b: any) => [number, number];
84
96
  readonly cereusdb_register_parquet_buffer: (a: number, b: number, c: number, d: number, e: number) => any;
97
+ readonly cereusdb_register_parquet_table: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
85
98
  readonly cereusdb_register_raster_buffer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
86
99
  readonly cereusdb_register_remote_parquet: (a: number, b: number, c: number, d: number, e: number) => any;
87
100
  readonly cereusdb_sql: (a: number, b: number, c: number) => any;
@@ -96,8 +109,16 @@ export interface InitOutput {
96
109
  readonly abort: () => void;
97
110
  readonly emscripten_builtin_free: (a: number) => void;
98
111
  readonly emscripten_builtin_malloc: (a: number) => number;
112
+ readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
113
+ readonly rust_zstd_wasm_shim_free: (a: number) => void;
114
+ readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
115
+ readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
116
+ readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
117
+ readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
118
+ readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
119
+ readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
99
120
  readonly __cpp_exception: WebAssembly.Tag;
100
- readonly wasm_bindgen__closure__destroy__hcd35ec5c66a281ba: (a: number, b: number) => void;
121
+ readonly wasm_bindgen__closure__destroy__h8db467765ce434ac: (a: number, b: number) => void;
101
122
  readonly wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504: (a: number, b: number, c: any) => [number, number];
102
123
  readonly wasm_bindgen__convert__closures_____invoke__h3bcc27440de746c0: (a: number, b: number, c: any, d: any) => void;
103
124
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -1,7 +1,8 @@
1
- import { createEnvImports, createWasiImports, setMemory } from "./env_shim.js?v=ehfix-20260406-1";
1
+ import { createEnvImports, createWasiImports, setMemory } from "./env_shim.js?v=emsdk6-20261001-2";
2
2
  const __env = createEnvImports();
3
3
  const __wasi = createWasiImports();
4
4
  /* @ts-self-types="./cereusdb.d.ts" */
5
+ import { cereusdbFetch, cereusdbSetFetchConcurrency } from './snippets/cereusdb-object-store-0da8c74e50551289/inline0.js';
5
6
 
6
7
  /**
7
8
  * Main CereusDB instance for browser use.
@@ -110,6 +111,22 @@ export class CereusDB {
110
111
  throw takeFromExternrefTable0(ret[0]);
111
112
  }
112
113
  }
114
+ /**
115
+ * Register browser-backed object stores for ranged/listing reads.
116
+ * @param {any} config
117
+ */
118
+ register_object_stores(config) {
119
+ let ret;
120
+ __wbg_termination_guard();
121
+ try {
122
+ ret = wasm.cereusdb_register_object_stores(this.__wbg_ptr, config);;
123
+ } catch(e) {
124
+ __wbg_handle_catch(e);
125
+ }
126
+ if (ret[1]) {
127
+ throw takeFromExternrefTable0(ret[0]);
128
+ }
129
+ }
113
130
  /**
114
131
  * Register a Uint8Array containing Parquet data as a named table.
115
132
  * Use for files obtained via the browser File API.
@@ -131,6 +148,27 @@ export class CereusDB {
131
148
  }
132
149
  return ret;
133
150
  }
151
+ /**
152
+ * Register a remote Parquet object or prefix as a DataFusion listing table.
153
+ * @param {string} table_name
154
+ * @param {string} table_url
155
+ * @param {any} options
156
+ * @returns {Promise<void>}
157
+ */
158
+ register_parquet_table(table_name, table_url, options) {
159
+ const ptr0 = passStringToWasm0(table_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
160
+ const len0 = WASM_VECTOR_LEN;
161
+ const ptr1 = passStringToWasm0(table_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
162
+ const len1 = WASM_VECTOR_LEN;
163
+ let ret;
164
+ __wbg_termination_guard();
165
+ try {
166
+ ret = wasm.cereusdb_register_parquet_table(this.__wbg_ptr, ptr0, len0, ptr1, len1, options);;
167
+ } catch(e) {
168
+ __wbg_handle_catch(e);
169
+ }
170
+ return ret;
171
+ }
134
172
  /**
135
173
  * Register a raster buffer as a single-column raster table.
136
174
  * Requires the full GDAL-enabled build.
@@ -234,6 +272,9 @@ export class CereusDB {
234
272
  }
235
273
  /**
236
274
  * Get version information.
275
+ *
276
+ * Release builds set `CEREUSDB_VERSION` to the full npm version, including
277
+ * prerelease suffixes; other builds fall back to the crate version.
237
278
  * @returns {string}
238
279
  */
239
280
  version() {
@@ -276,26 +317,26 @@ const import12 = __wasi;
276
317
  const import13 = __env;
277
318
  const import14 = __env;
278
319
  const import15 = __env;
279
- const import16 = __wasi;
320
+ const import16 = __env;
280
321
  const import17 = __env;
281
322
  const import18 = __env;
282
323
  const import19 = __env;
283
324
  const import20 = __env;
284
- const import21 = __env;
325
+ const import21 = __wasi;
285
326
  const import22 = __env;
286
327
  const import23 = __env;
287
328
  const import24 = __env;
288
- const import25 = __wasi;
289
- const import26 = __env;
329
+ const import25 = __env;
330
+ const import26 = __wasi;
290
331
  const import27 = __env;
291
332
  const import28 = __env;
292
333
  const import29 = __env;
293
334
  const import30 = __env;
294
335
  const import31 = __env;
295
336
  const import32 = __env;
296
- const import33 = __env;
337
+ const import33 = __wasi;
297
338
  const import34 = __wasi;
298
- const import35 = __wasi;
339
+ const import35 = __env;
299
340
  const import36 = __env;
300
341
  const import37 = __env;
301
342
  const import38 = __env;
@@ -303,12 +344,19 @@ const import39 = __env;
303
344
  const import40 = __env;
304
345
  const import41 = __env;
305
346
  const import42 = __env;
306
- const import43 = __env;
307
- const import44 = __wasi;
347
+ const import43 = __wasi;
308
348
 
309
349
  function __wbg_get_imports() {
310
350
  const import0 = {
311
351
  __proto__: null,
352
+ __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
353
+ const ret = Error(getStringFromWasm0(arg0, arg1));
354
+ return ret;
355
+ },
356
+ __wbg_Number_a5a435bd7bbec835: function(arg0) {
357
+ const ret = Number(arg0);
358
+ return ret;
359
+ },
312
360
  __wbg_String_8564e559799eccda: function(arg0, arg1) {
313
361
  const ret = String(arg1);
314
362
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -316,6 +364,17 @@ function __wbg_get_imports() {
316
364
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
317
365
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
318
366
  },
367
+ __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda: function(arg0, arg1) {
368
+ const v = arg1;
369
+ const ret = typeof(v) === 'bigint' ? v : undefined;
370
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
371
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
372
+ },
373
+ __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
374
+ const v = arg0;
375
+ const ret = typeof(v) === 'boolean' ? v : undefined;
376
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
377
+ },
319
378
  __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
320
379
  const ret = debugString(arg1);
321
380
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -323,14 +382,57 @@ function __wbg_get_imports() {
323
382
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
324
383
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
325
384
  },
385
+ __wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
386
+ const ret = arg0 in arg1;
387
+ return ret;
388
+ },
389
+ __wbg___wbindgen_is_bigint_e2141d4f045b7eda: function(arg0) {
390
+ const ret = typeof(arg0) === 'bigint';
391
+ return ret;
392
+ },
326
393
  __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
327
394
  const ret = typeof(arg0) === 'function';
328
395
  return ret;
329
396
  },
397
+ __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
398
+ const ret = arg0 === null;
399
+ return ret;
400
+ },
401
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
402
+ const val = arg0;
403
+ const ret = typeof(val) === 'object' && val !== null;
404
+ return ret;
405
+ },
406
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
407
+ const ret = typeof(arg0) === 'string';
408
+ return ret;
409
+ },
330
410
  __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
331
411
  const ret = arg0 === undefined;
332
412
  return ret;
333
413
  },
414
+ __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
415
+ const ret = arg0 === arg1;
416
+ return ret;
417
+ },
418
+ __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
419
+ const ret = arg0 == arg1;
420
+ return ret;
421
+ },
422
+ __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
423
+ const obj = arg1;
424
+ const ret = typeof(obj) === 'number' ? obj : undefined;
425
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
426
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
427
+ },
428
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
429
+ const obj = arg1;
430
+ const ret = typeof(obj) === 'string' ? obj : undefined;
431
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
432
+ var len1 = WASM_VECTOR_LEN;
433
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
434
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
435
+ },
334
436
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
335
437
  throw new WebAssembly.Exception(__wbindgen_wrapped_jstag, [new Error(getStringFromWasm0(arg0, arg1))]);
336
438
  },
@@ -345,6 +447,25 @@ function __wbg_get_imports() {
345
447
  const ret = arg0.call(arg1, arg2);
346
448
  return ret;
347
449
  },
450
+ __wbg_call_e133b57c9155d22c: function(arg0, arg1) {
451
+ const ret = arg0.call(arg1);
452
+ return ret;
453
+ },
454
+ __wbg_cereusdbFetch_ef03c6e2e53e5d27: function(arg0) {
455
+ const ret = cereusdbFetch(arg0);
456
+ return ret;
457
+ },
458
+ __wbg_cereusdbSetFetchConcurrency_5dba4b72020a565e: function(arg0) {
459
+ cereusdbSetFetchConcurrency(arg0 >>> 0);
460
+ },
461
+ __wbg_done_08ce71ee07e3bd17: function(arg0) {
462
+ const ret = arg0.done;
463
+ return ret;
464
+ },
465
+ __wbg_entries_e8a20ff8c9757101: function(arg0) {
466
+ const ret = Object.entries(arg0);
467
+ return ret;
468
+ },
348
469
  __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
349
470
  let deferred0_0;
350
471
  let deferred0_1;
@@ -379,6 +500,42 @@ function __wbg_get_imports() {
379
500
  const ret = arg0.getTime();
380
501
  return ret;
381
502
  },
503
+ __wbg_get_326e41e095fb2575: function(arg0, arg1) {
504
+ const ret = Reflect.get(arg0, arg1);
505
+ return ret;
506
+ },
507
+ __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
508
+ const ret = arg0[arg1 >>> 0];
509
+ return ret;
510
+ },
511
+ __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
512
+ const ret = arg0[arg1 >>> 0];
513
+ return ret;
514
+ },
515
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
516
+ const ret = arg0[arg1];
517
+ return ret;
518
+ },
519
+ __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
520
+ let result;
521
+ try {
522
+ result = arg0 instanceof ArrayBuffer;
523
+ } catch (_) {
524
+ result = false;
525
+ }
526
+ const ret = result;
527
+ return ret;
528
+ },
529
+ __wbg_instanceof_Map_f194b366846aca0c: function(arg0) {
530
+ let result;
531
+ try {
532
+ result = arg0 instanceof Map;
533
+ } catch (_) {
534
+ result = false;
535
+ }
536
+ const ret = result;
537
+ return ret;
538
+ },
382
539
  __wbg_instanceof_Response_9b4d9fd451e051b1: function(arg0) {
383
540
  let result;
384
541
  try {
@@ -389,6 +546,16 @@ function __wbg_get_imports() {
389
546
  const ret = result;
390
547
  return ret;
391
548
  },
549
+ __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
550
+ let result;
551
+ try {
552
+ result = arg0 instanceof Uint8Array;
553
+ } catch (_) {
554
+ result = false;
555
+ }
556
+ const ret = result;
557
+ return ret;
558
+ },
392
559
  __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
393
560
  let result;
394
561
  try {
@@ -399,6 +566,22 @@ function __wbg_get_imports() {
399
566
  const ret = result;
400
567
  return ret;
401
568
  },
569
+ __wbg_isArray_33b91feb269ff46e: function(arg0) {
570
+ const ret = Array.isArray(arg0);
571
+ return ret;
572
+ },
573
+ __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
574
+ const ret = Number.isSafeInteger(arg0);
575
+ return ret;
576
+ },
577
+ __wbg_iterator_d8f549ec8fb061b1: function() {
578
+ const ret = Symbol.iterator;
579
+ return ret;
580
+ },
581
+ __wbg_length_b3416cf66a5452c8: function(arg0) {
582
+ const ret = arg0.length;
583
+ return ret;
584
+ },
402
585
  __wbg_length_ea16607d7b61445b: function(arg0) {
403
586
  const ret = arg0.length;
404
587
  return ret;
@@ -452,6 +635,14 @@ function __wbg_get_imports() {
452
635
  const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
453
636
  return ret;
454
637
  },
638
+ __wbg_next_11b99ee6237339e3: function(arg0) {
639
+ const ret = arg0.next();
640
+ return ret;
641
+ },
642
+ __wbg_next_e01a967809d1aa68: function(arg0) {
643
+ const ret = arg0.next;
644
+ return ret;
645
+ },
455
646
  __wbg_now_e7c6795a7f81e10f: function(arg0) {
456
647
  const ret = arg0.now();
457
648
  return ret;
@@ -481,6 +672,9 @@ function __wbg_get_imports() {
481
672
  __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
482
673
  arg0[arg1 >>> 0] = arg2;
483
674
  },
675
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
676
+ arg0[arg1] = arg2;
677
+ },
484
678
  __wbg_set_8c0b3ffcf05d61c2: function(arg0, arg1, arg2) {
485
679
  arg0.set(getArrayU8FromWasm0(arg1, arg2));
486
680
  },
@@ -517,6 +711,10 @@ function __wbg_get_imports() {
517
711
  const ret = arg0.status;
518
712
  return ret;
519
713
  },
714
+ __wbg_stringify_5ae93966a84901ac: function(arg0) {
715
+ const ret = JSON.stringify(arg0);
716
+ return ret;
717
+ },
520
718
  __wbg_then_098abe61755d12f6: function(arg0, arg1) {
521
719
  const ret = arg0.then(arg1);
522
720
  return ret;
@@ -525,16 +723,35 @@ function __wbg_get_imports() {
525
723
  const ret = arg0.then(arg1, arg2);
526
724
  return ret;
527
725
  },
726
+ __wbg_value_21fc78aab0322612: function(arg0) {
727
+ const ret = arg0.value;
728
+ return ret;
729
+ },
528
730
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
529
- // Cast intrinsic for `Closure(Closure { dtor_idx: 7156, function: Function { arguments: [Externref], shim_idx: 22227, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
530
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hcd35ec5c66a281ba, wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504);
731
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 7619, function: Function { arguments: [Externref], shim_idx: 24967, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
732
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h8db467765ce434ac, wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504);
733
+ return ret;
734
+ },
735
+ __wbindgen_cast_0000000000000002: function(arg0) {
736
+ // Cast intrinsic for `F64 -> Externref`.
737
+ const ret = arg0;
531
738
  return ret;
532
739
  },
533
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
740
+ __wbindgen_cast_0000000000000003: function(arg0) {
741
+ // Cast intrinsic for `I64 -> Externref`.
742
+ const ret = arg0;
743
+ return ret;
744
+ },
745
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
534
746
  // Cast intrinsic for `Ref(String) -> Externref`.
535
747
  const ret = getStringFromWasm0(arg0, arg1);
536
748
  return ret;
537
749
  },
750
+ __wbindgen_cast_0000000000000005: function(arg0) {
751
+ // Cast intrinsic for `U64 -> Externref`.
752
+ const ret = BigInt.asUintN(64, arg0);
753
+ return ret;
754
+ },
538
755
  __wbindgen_init_externref_table: function() {
539
756
  const table = wasm.__wbindgen_externrefs;
540
757
  const offset = table.grow(4);
@@ -565,26 +782,26 @@ function __wbg_get_imports() {
565
782
  "env": import13,
566
783
  "env": import14,
567
784
  "env": import15,
568
- "wasi_snapshot_preview1": import16,
785
+ "env": import16,
569
786
  "env": import17,
570
787
  "env": import18,
571
788
  "env": import19,
572
789
  "env": import20,
573
- "env": import21,
790
+ "wasi_snapshot_preview1": import21,
574
791
  "env": import22,
575
792
  "env": import23,
576
793
  "env": import24,
577
- "wasi_snapshot_preview1": import25,
578
- "env": import26,
794
+ "env": import25,
795
+ "wasi_snapshot_preview1": import26,
579
796
  "env": import27,
580
797
  "env": import28,
581
798
  "env": import29,
582
799
  "env": import30,
583
800
  "env": import31,
584
801
  "env": import32,
585
- "env": import33,
802
+ "wasi_snapshot_preview1": import33,
586
803
  "wasi_snapshot_preview1": import34,
587
- "wasi_snapshot_preview1": import35,
804
+ "env": import35,
588
805
  "env": import36,
589
806
  "env": import37,
590
807
  "env": import38,
@@ -592,8 +809,7 @@ function __wbg_get_imports() {
592
809
  "env": import40,
593
810
  "env": import41,
594
811
  "env": import42,
595
- "env": import43,
596
- "wasi_snapshot_preview1": import44,
812
+ "wasi_snapshot_preview1": import43,
597
813
  };
598
814
  }
599
815
 
Binary file
@@ -14,7 +14,9 @@ export const cereusdb_create: () => [number, number, number];
14
14
  export const cereusdb_drop_table: (a: number, b: number, c: number) => [number, number];
15
15
  export const cereusdb_register_geojson: (a: number, b: number, c: number, d: number, e: number) => [number, number];
16
16
  export const cereusdb_register_geotiff_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
17
+ export const cereusdb_register_object_stores: (a: number, b: any) => [number, number];
17
18
  export const cereusdb_register_parquet_buffer: (a: number, b: number, c: number, d: number, e: number) => any;
19
+ export const cereusdb_register_parquet_table: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
18
20
  export const cereusdb_register_raster_buffer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
19
21
  export const cereusdb_register_remote_parquet: (a: number, b: number, c: number, d: number, e: number) => any;
20
22
  export const cereusdb_sql: (a: number, b: number, c: number) => any;
@@ -29,8 +31,16 @@ export const realloc: (a: number, b: number) => number;
29
31
  export const abort: () => void;
30
32
  export const emscripten_builtin_free: (a: number) => void;
31
33
  export const emscripten_builtin_malloc: (a: number) => number;
34
+ export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
35
+ export const rust_zstd_wasm_shim_free: (a: number) => void;
36
+ export const rust_zstd_wasm_shim_malloc: (a: number) => number;
37
+ export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
38
+ export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
39
+ export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
40
+ export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
41
+ export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
32
42
  export const __cpp_exception: WebAssembly.Tag;
33
- export const wasm_bindgen__closure__destroy__hcd35ec5c66a281ba: (a: number, b: number) => void;
43
+ export const wasm_bindgen__closure__destroy__h8db467765ce434ac: (a: number, b: number) => void;
34
44
  export const wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504: (a: number, b: number, c: any) => [number, number];
35
45
  export const wasm_bindgen__convert__closures_____invoke__h3bcc27440de746c0: (a: number, b: number, c: any, d: any) => void;
36
46
  export const __wbindgen_malloc: (a: number, b: number) => number;
@@ -26,6 +26,48 @@ function writeU64(ptr, value) {
26
26
  }
27
27
  }
28
28
 
29
+ const _textDecoder = new TextDecoder();
30
+ const _pendingOutput = new Map();
31
+
32
+ // Gathers a WASI iovec array. Writers such as musl's fwrite retry until every
33
+ // byte is reported as written, so the full length must always be returned.
34
+ function readIovs(iovs, iovcnt) {
35
+ const view = getDataView();
36
+ if (!view) {
37
+ return { bytes: new Uint8Array(0), length: 0 };
38
+ }
39
+ let length = 0;
40
+ for (let i = 0; i < iovcnt; i++) {
41
+ length += view.getUint32(iovs + i * 8 + 4, true);
42
+ }
43
+ const bytes = new Uint8Array(length);
44
+ let offset = 0;
45
+ for (let i = 0; i < iovcnt; i++) {
46
+ const ptr = view.getUint32(iovs + i * 8, true);
47
+ const len = view.getUint32(iovs + i * 8 + 4, true);
48
+ bytes.set(new Uint8Array(_memory.buffer, ptr, len), offset);
49
+ offset += len;
50
+ }
51
+ return { bytes, length };
52
+ }
53
+
54
+ // Forwards stdout/stderr from the C/C++ libraries (GDAL, PROJ, ...) to the
55
+ // console, one line at a time.
56
+ function forwardOutput(fd, bytes) {
57
+ if (fd !== 1 && fd !== 2) {
58
+ return;
59
+ }
60
+ const text = (_pendingOutput.get(fd) ?? "") + _textDecoder.decode(bytes);
61
+ const lines = text.split("\n");
62
+ _pendingOutput.set(fd, lines.pop());
63
+ const log = fd === 2 ? console.warn : console.log;
64
+ for (const line of lines) {
65
+ if (line.trim()) {
66
+ log(`[cereusdb] ${line}`);
67
+ }
68
+ }
69
+ }
70
+
29
71
  function createCppException(ptr, type, destructor, message = "C++ exception") {
30
72
  const error = new WebAssembly.RuntimeError(message);
31
73
  error.__cxa_exception_ptr = ptr >>> 0;
@@ -60,7 +102,10 @@ export function createEnvImports() {
60
102
 
61
103
  // Minimal C++ EH shims. These are enough to satisfy instantiation and
62
104
  // propagate exceptions back to JS on paths that actually throw.
105
+ // LLVM in Emscripten < 6 calls _Unwind_CallPersonality; newer versions
106
+ // import the personality routine directly.
63
107
  _Unwind_CallPersonality: () => 0,
108
+ __gxx_wasm_personality_v0: () => 0,
64
109
  __cxa_begin_catch: (ptr) => {
65
110
  const value = ptr >>> 0;
66
111
  _caughtCxaExceptions.push(value);
@@ -109,6 +154,7 @@ export function createEnvImports() {
109
154
  __syscall_prlimit64: () => UNSUPPORTED_ERRNO,
110
155
  __syscall_dup3: () => UNSUPPORTED_ERRNO,
111
156
  __syscall_pipe: () => UNSUPPORTED_ERRNO,
157
+ __syscall_pipe2: () => UNSUPPORTED_ERRNO,
112
158
  __syscall_wait4: () => UNSUPPORTED_ERRNO,
113
159
  __syscall_getuid32: () => 0,
114
160
  __syscall_geteuid32: () => 0,
@@ -143,16 +189,18 @@ export function createEnvImports() {
143
189
  export function createWasiImports() {
144
190
  return {
145
191
  fd_close: () => 0,
146
- fd_write: (_fd, _iovs, _iovcnt, pnum) => {
147
- writeU32(pnum, 0);
192
+ fd_write: (fd, iovs, iovcnt, pnum) => {
193
+ const { bytes, length } = readIovs(iovs, iovcnt);
194
+ forwardOutput(fd, bytes);
195
+ writeU32(pnum, length);
148
196
  return 0;
149
197
  },
150
198
  fd_read: (_fd, _iovs, _iovcnt, pnum) => {
151
199
  writeU32(pnum, 0);
152
200
  return 0;
153
201
  },
154
- fd_pwrite: (_fd, _iovs, _iovcnt, _offset, pnum) => {
155
- writeU32(pnum, 0);
202
+ fd_pwrite: (_fd, iovs, iovcnt, _offset, pnum) => {
203
+ writeU32(pnum, readIovs(iovs, iovcnt).length);
156
204
  return 0;
157
205
  },
158
206
  fd_pread: (_fd, _iovs, _iovcnt, _offset, pnum) => {
@@ -0,0 +1,61 @@
1
+
2
+ let cereusdbFetchMaxConcurrency = 16;
3
+ let cereusdbFetchActive = 0;
4
+ const cereusdbFetchQueue = [];
5
+
6
+ function cereusdbPumpFetchQueue() {
7
+ while (cereusdbFetchActive < cereusdbFetchMaxConcurrency && cereusdbFetchQueue.length > 0) {
8
+ const task = cereusdbFetchQueue.shift();
9
+ cereusdbFetchActive += 1;
10
+ cereusdbExecuteFetch(task.request)
11
+ .then(task.resolve, task.reject)
12
+ .finally(() => {
13
+ cereusdbFetchActive -= 1;
14
+ cereusdbPumpFetchQueue();
15
+ });
16
+ }
17
+ }
18
+
19
+ async function cereusdbExecuteFetch(request) {
20
+ const headers = new Headers();
21
+ for (const [name, value] of request.headers) {
22
+ headers.append(name, value);
23
+ }
24
+
25
+ const init = {
26
+ method: request.method,
27
+ headers,
28
+ };
29
+
30
+ if (request.body !== undefined && request.body !== null) {
31
+ init.body = request.body;
32
+ }
33
+
34
+ const response = await fetch(request.url, init);
35
+ const responseHeaders = [];
36
+ response.headers.forEach((value, name) => {
37
+ responseHeaders.push([name, value]);
38
+ });
39
+
40
+ return {
41
+ status: response.status,
42
+ statusText: response.statusText,
43
+ headers: responseHeaders,
44
+ body: new Uint8Array(await response.arrayBuffer()),
45
+ };
46
+ }
47
+
48
+ export function cereusdbSetFetchConcurrency(maxConcurrency) {
49
+ const parsed = Number(maxConcurrency);
50
+ if (Number.isFinite(parsed) && parsed >= 1) {
51
+ cereusdbFetchMaxConcurrency = Math.min(Math.trunc(parsed), 256);
52
+ cereusdbPumpFetchQueue();
53
+ }
54
+ }
55
+
56
+ export function cereusdbFetch(request) {
57
+ return new Promise((resolve, reject) => {
58
+ cereusdbFetchQueue.push({ request, resolve, reject });
59
+ cereusdbPumpFetchQueue();
60
+ });
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cereusdb/standard",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Standard CereusDB browser package with GEOS and PROJ support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,10 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js"
13
13
  },
14
+ "./external": {
15
+ "types": "./dist/external.d.ts",
16
+ "import": "./dist/external.js"
17
+ },
14
18
  "./wasm": "./dist/wasm/cereusdb_bg.wasm",
15
19
  "./wasm/*": "./dist/wasm/*"
16
20
  },