geolibre-wasm 1.3.0 → 1.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/geolibre-cli.wasm CHANGED
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "geolibre-wasm",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "description": "Pure-Rust geospatial toolkit (whitebox_next_gen) compiled to WebAssembly (WASI) for GeoLibre's in-browser tool execution",
6
6
  "license": "MIT",
7
7
  "repository": {
package/tools.mjs CHANGED
@@ -132,6 +132,15 @@ async function materializeInput(value) {
132
132
  return new Uint8Array(value);
133
133
  }
134
134
 
135
+ // Build a readable message for a guest trap out of what the tool printed to
136
+ // stderr before aborting. `stdout` here is the shared stdout+stderr capture.
137
+ function describeTrap(argv, err, stdout) {
138
+ const tool = argv[0] ?? "tool";
139
+ const tail = stdout.map((s) => s.trimEnd()).filter(Boolean).slice(-12);
140
+ const detail = tail.length ? `\n${tail.join("\n")}` : "";
141
+ return `${tool} crashed: ${err.message}${detail}`;
142
+ }
143
+
135
144
  async function exec(argv, inputFiles) {
136
145
  const mod = await initTools();
137
146
  const inNames = new Set(Object.keys(inputFiles));
@@ -150,7 +159,14 @@ async function exec(argv, inputFiles) {
150
159
  const inst = await WebAssembly.instantiate(mod, { wasi_snapshot_preview1: wasi.wasiImport });
151
160
  let exitCode = 0;
152
161
  try { exitCode = wasi.start(inst); }
153
- catch (e) { if (e && e.constructor && e.constructor.name === "WASIProcExit") exitCode = e.code; else throw e; }
162
+ catch (e) {
163
+ if (e && e.constructor && e.constructor.name === "WASIProcExit") exitCode = e.code;
164
+ // A guest trap (a Rust panic aborts to `unreachable`) surfaces as a bare
165
+ // RuntimeError whose stack is raw wasm-function offsets. The panic message
166
+ // was already written to stderr, so fold it into the error we rethrow —
167
+ // otherwise the caller only sees unreadable hex addresses.
168
+ else throw new Error(describeTrap(argv, e, stdout), { cause: e });
169
+ }
154
170
  // Collect every new file under /work, recursing into subdirectories so tools
155
171
  // that write a tree (e.g. raster_to_tiles' {z}/{x}/{y}.png) are surfaced too.
156
172
  // Keys are paths relative to /work (nested files use "/" separators).