@cereusdb/standard 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 +1428 -0
- package/dist/wasm/cereusdb.d.ts +82 -4
- package/dist/wasm/cereusdb.js +277 -28
- package/dist/wasm/cereusdb_bg.wasm +0 -0
- package/dist/wasm/cereusdb_bg.wasm.d.ts +23 -3
- package/dist/wasm/env_shim.js +52 -4
- package/package.json +5 -1
- /package/dist/wasm/snippets/{cereusdb-object-store-3803cd296f83ecfa → cereusdb-object-store-6ee0e8370430462c}/inline0.js +0 -0
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/standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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
|
},
|