@cereusdb/minimal 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -3
- package/dist/external.d.ts +293 -0
- package/dist/external.js +347 -0
- package/dist/index.d.ts +199 -4
- package/dist/index.js +219 -4
- package/dist/storage.d.ts +64 -0
- package/dist/storage.js +211 -0
- package/dist/wasm/cereusdb-external.d.ts +220 -0
- package/dist/wasm/cereusdb-external.js +1290 -0
- package/dist/wasm/cereusdb.d.ts +79 -1
- package/dist/wasm/cereusdb.js +367 -8
- package/dist/wasm/cereusdb_bg.wasm +0 -0
- package/dist/wasm/cereusdb_bg.wasm.d.ts +20 -0
- package/dist/wasm/env_shim.js +52 -4
- package/package.json +5 -1
|
@@ -10,8 +10,19 @@ export const __libc_malloc: (a: number) => number;
|
|
|
10
10
|
export const malloc: (a: number) => number;
|
|
11
11
|
export const __wbg_cereusdb_free: (a: number, b: number) => void;
|
|
12
12
|
export const _abort_js: () => void;
|
|
13
|
+
export const cereusdb_attach_database: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
14
|
+
export const cereusdb_catalog_json: (a: number) => any;
|
|
15
|
+
export const cereusdb_compact_database: (a: number, b: number, c: number) => any;
|
|
13
16
|
export const cereusdb_create: () => [number, number, number];
|
|
17
|
+
export const cereusdb_detach_database: (a: number, b: number, c: number, d: number) => any;
|
|
18
|
+
export const cereusdb_drop_database: (a: number, b: number, c: number, d: number) => any;
|
|
14
19
|
export const cereusdb_drop_table: (a: number, b: number, c: number) => [number, number];
|
|
20
|
+
export const cereusdb_export_geoparquet: (a: number, b: number, c: number, d: any) => any;
|
|
21
|
+
export const cereusdb_flush: (a: number) => any;
|
|
22
|
+
export const cereusdb_insert_arrow: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
23
|
+
export const cereusdb_list_database_locations: (a: number, b: number, c: number) => any;
|
|
24
|
+
export const cereusdb_qualified_tables: (a: number) => [number, number, number];
|
|
25
|
+
export const cereusdb_register_export_handler: (a: number, b: any) => [number, number];
|
|
15
26
|
export const cereusdb_register_geojson: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
16
27
|
export const cereusdb_register_geotiff_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
17
28
|
export const cereusdb_register_object_stores: (a: number, b: any) => [number, number];
|
|
@@ -19,6 +30,7 @@ export const cereusdb_register_parquet_buffer: (a: number, b: number, c: number,
|
|
|
19
30
|
export const cereusdb_register_parquet_table: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
|
|
20
31
|
export const cereusdb_register_raster_buffer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
21
32
|
export const cereusdb_register_remote_parquet: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
33
|
+
export const cereusdb_register_storage_backend: (a: number, b: number, c: number, d: any) => [number, number];
|
|
22
34
|
export const cereusdb_sql: (a: number, b: number, c: number) => any;
|
|
23
35
|
export const cereusdb_sql_json: (a: number, b: number, c: number) => any;
|
|
24
36
|
export const cereusdb_tables: (a: number) => [number, number, number];
|
|
@@ -31,6 +43,14 @@ export const realloc: (a: number, b: number) => number;
|
|
|
31
43
|
export const abort: () => void;
|
|
32
44
|
export const emscripten_builtin_free: (a: number) => void;
|
|
33
45
|
export const emscripten_builtin_malloc: (a: number) => number;
|
|
46
|
+
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
47
|
+
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
|
48
|
+
export const rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
49
|
+
export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
50
|
+
export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
51
|
+
export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
52
|
+
export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
53
|
+
export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
34
54
|
export const __cpp_exception: WebAssembly.Tag;
|
|
35
55
|
export const wasm_bindgen__closure__destroy__h8db467765ce434ac: (a: number, b: number) => void;
|
|
36
56
|
export const wasm_bindgen__convert__closures_____invoke__h7573a8a64f443504: (a: number, b: number, c: any) => [number, number];
|
package/dist/wasm/env_shim.js
CHANGED
|
@@ -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: (
|
|
147
|
-
|
|
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,
|
|
155
|
-
writeU32(pnum,
|
|
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.
|
|
3
|
+
"version": "0.4.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
|
},
|