@cereusdb/minimal 0.2.0 → 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.
@@ -68,6 +68,9 @@ export class CereusDB {
68
68
  tables(): any;
69
69
  /**
70
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.
71
74
  */
72
75
  version(): string;
73
76
  }
@@ -106,6 +109,14 @@ export interface InitOutput {
106
109
  readonly abort: () => void;
107
110
  readonly emscripten_builtin_free: (a: number) => void;
108
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;
109
120
  readonly __cpp_exception: WebAssembly.Tag;
110
121
  readonly wasm_bindgen__closure__destroy__h8db467765ce434ac: (a: number, b: number) => void;
111
122
  readonly wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504: (a: number, b: number, c: any) => [number, number];
@@ -1,4 +1,4 @@
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" */
@@ -271,6 +271,9 @@ export class CereusDB {
271
271
  }
272
272
  /**
273
273
  * Get version information.
274
+ *
275
+ * Release builds set `CEREUSDB_VERSION` to the full npm version, including
276
+ * prerelease suffixes; other builds fall back to the crate version.
274
277
  * @returns {string}
275
278
  */
276
279
  version() {
@@ -302,9 +305,9 @@ const import1 = __env;
302
305
  const import2 = __env;
303
306
  const import3 = __env;
304
307
  const import4 = __env;
305
- const import5 = __wasi;
308
+ const import5 = __env;
306
309
  const import6 = __wasi;
307
- const import7 = __env;
310
+ const import7 = __wasi;
308
311
  const import8 = __env;
309
312
  const import9 = __wasi;
310
313
 
@@ -528,7 +531,7 @@ function __wbg_get_imports() {
528
531
  return ret;
529
532
  },
530
533
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
531
- // Cast intrinsic for `Closure(Closure { dtor_idx: 4368, function: Function { arguments: [Externref], shim_idx: 20024, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
534
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 4534, function: Function { arguments: [Externref], shim_idx: 20198, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
532
535
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h8db467765ce434ac, wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504);
533
536
  return ret;
534
537
  },
@@ -556,9 +559,9 @@ function __wbg_get_imports() {
556
559
  "env": import2,
557
560
  "env": import3,
558
561
  "env": import4,
559
- "wasi_snapshot_preview1": import5,
562
+ "env": import5,
560
563
  "wasi_snapshot_preview1": import6,
561
- "env": import7,
564
+ "wasi_snapshot_preview1": import7,
562
565
  "env": import8,
563
566
  "wasi_snapshot_preview1": import9,
564
567
  };
Binary file
@@ -31,6 +31,14 @@ export const realloc: (a: number, b: number) => number;
31
31
  export const abort: () => void;
32
32
  export const emscripten_builtin_free: (a: number) => void;
33
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;
34
42
  export const __cpp_exception: WebAssembly.Tag;
35
43
  export const wasm_bindgen__closure__destroy__h8db467765ce434ac: (a: number, b: number) => void;
36
44
  export const wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504: (a: number, b: number, c: any) => [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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cereusdb/minimal",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Minimal CereusDB browser package with GEOS-backed spatial SQL",
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
  },