hyperdb-wasm 0.0.26488-dev.wasm.g022dea1a → 0.0.26500-dev.wasm.gc3a423ec
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/dist/browser_worker.js +21 -5
- package/dist/hyperdb-wasm.cjs +1 -1
- package/dist/hyperdb-wasm.js +1 -1
- package/dist/hyperdb-wasm.wasm.br +0 -0
- package/dist/node_worker.js +21 -5
- package/package.json +1 -1
package/dist/browser_worker.js
CHANGED
|
@@ -217,15 +217,31 @@
|
|
|
217
217
|
module.hyperdbWasmFetchStart = (id, url, offset, length) => {
|
|
218
218
|
const headers = new Headers();
|
|
219
219
|
if (length > 0) headers.set("Range", `bytes=${offset}-${offset + length - 1}`);
|
|
220
|
-
void fetch(url, { headers }).then(async (response) => {
|
|
221
|
-
if (!response.ok
|
|
220
|
+
void fetch(url, { headers, redirect: "manual" }).then(async (response) => {
|
|
221
|
+
if (!response.ok || response.type === "opaqueredirect" || (length === 0 ? response.status !== 200 : response.status !== 206)) {
|
|
222
222
|
module._hyperdb_wasm_fetch_complete(id, 0, -1);
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
+
if (length > 0) {
|
|
226
|
+
const contentRange = /^bytes (\d+)-(\d+)\/(\d+)$/.exec(response.headers.get("content-range") ?? "");
|
|
227
|
+
if (!contentRange || contentRange[1] !== String(offset) || contentRange[2] !== String(offset + length - 1)) {
|
|
228
|
+
module._hyperdb_wasm_fetch_complete(id, 0, -1);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
225
232
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
if (length > 0 && bytes.byteLength !== length) {
|
|
234
|
+
module._hyperdb_wasm_fetch_complete(id, 0, -1);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
module._hyperdb_wasm_fetch_complete(id, allocate(module, bytes), bytes.byteLength);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
transport.postMessage({ type: "log", text: `fetch failed: ${errorText(error)}` });
|
|
241
|
+
module._hyperdb_wasm_fetch_complete(id, 0, -1);
|
|
242
|
+
}
|
|
243
|
+
}).catch(() => {
|
|
244
|
+
transport.postMessage({ type: "log", text: "fetch failed" });
|
|
229
245
|
module._hyperdb_wasm_fetch_complete(id, 0, -1);
|
|
230
246
|
});
|
|
231
247
|
};
|