hyperdb-wasm 0.0.27136-dev.wasm.gd997ff1c → 0.0.27136-dev.wasm.ged3c25a2
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/api.d.ts +3 -1
- package/dist/browser.js +21 -20
- package/dist/browser_external_directory.d.ts +7 -2
- package/dist/browser_worker.js +96 -45
- package/dist/client.d.ts +1 -0
- 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.js +20 -13
- package/dist/node_external_directory.d.ts +4 -2
- package/dist/node_worker.js +93 -37
- package/dist/protocol.d.ts +5 -3
- package/dist/raw.browser.js +37 -10
- package/dist/raw.node.js +37 -10
- package/dist/wasm_bindings.d.ts +9 -3
- package/dist/worker_setup.d.ts +3 -2
- package/package.json +1 -1
package/dist/raw.node.js
CHANGED
|
@@ -93,6 +93,9 @@ var HyperDBEngineClient = class {
|
|
|
93
93
|
unmount(path) {
|
|
94
94
|
return this.request({ id: this.nextId++, type: "unmount", path });
|
|
95
95
|
}
|
|
96
|
+
refreshMount(path) {
|
|
97
|
+
return this.request({ id: this.nextId++, type: "refreshMount", path });
|
|
98
|
+
}
|
|
96
99
|
pollQuery(query) {
|
|
97
100
|
return this.request({ id: this.nextId++, type: "pollQuery", query });
|
|
98
101
|
}
|
|
@@ -209,6 +212,7 @@ var HyperDBBindings = class {
|
|
|
209
212
|
registerExternalFile;
|
|
210
213
|
registerExternalDirectory;
|
|
211
214
|
removeExternalRegistration;
|
|
215
|
+
refreshExternalDirectory;
|
|
212
216
|
projectExternalFile;
|
|
213
217
|
projectExternalDirectory;
|
|
214
218
|
startQuery;
|
|
@@ -219,6 +223,7 @@ var HyperDBBindings = class {
|
|
|
219
223
|
resultPayloadLength;
|
|
220
224
|
free;
|
|
221
225
|
mountedPaths = /* @__PURE__ */ new Set();
|
|
226
|
+
mountedDirectoryPaths = /* @__PURE__ */ new Set();
|
|
222
227
|
constructor(module) {
|
|
223
228
|
this.module = module;
|
|
224
229
|
this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string", "string", "number"]);
|
|
@@ -228,6 +233,7 @@ var HyperDBBindings = class {
|
|
|
228
233
|
this.registerExternalFile = module.cwrap("hyperdb_wasm_register_external_file", "pointer", ["string", "string", "number", "number"]);
|
|
229
234
|
this.registerExternalDirectory = module.cwrap("hyperdb_wasm_register_external_directory", "pointer", ["string", "string", "number", "number"]);
|
|
230
235
|
this.removeExternalRegistration = module.cwrap("hyperdb_wasm_remove_external_registration", "pointer", ["string", "number"]);
|
|
236
|
+
this.refreshExternalDirectory = module.cwrap("hyperdb_wasm_refresh_external_directory", "pointer", ["string", "number"]);
|
|
231
237
|
this.projectExternalFile = module.cwrap("hyperdb_wasm_project_external_file", "pointer", ["string", "string", "number", "number"]);
|
|
232
238
|
this.projectExternalDirectory = module.cwrap("hyperdb_wasm_project_external_directory", "pointer", ["string", "string", "number"]);
|
|
233
239
|
this.startQuery = module.cwrap("hyperdb_wasm_query_start", "pointer", ["number", "string", "number", "number"]);
|
|
@@ -247,20 +253,32 @@ var HyperDBBindings = class {
|
|
|
247
253
|
if (registration.kind === "directory") return this.mountDirectory(request, request.source.path);
|
|
248
254
|
return this.mountFile(request, registration.locator, registration.size, this.module.externalFileBackend);
|
|
249
255
|
}
|
|
250
|
-
if (request.type === "mount" && request.source.kind === "browser-file" && !this.module.externalFileBackendAvailable) {
|
|
251
|
-
return { response: { id: request.id, type: "response", result: { state: "error", error: "Blob external files are supported only by the browser client" } }, transfer: [] };
|
|
252
|
-
}
|
|
253
256
|
if (request.type === "mount" && request.source.kind === "browser-directory") {
|
|
254
257
|
return this.mountDirectory(request, request.source.handle);
|
|
255
258
|
}
|
|
256
259
|
if (request.type === "mount" && request.source.kind === "browser-file") {
|
|
257
|
-
|
|
260
|
+
validateCString(request.path, "external registration path");
|
|
261
|
+
const backend = this.module.externalDirectoryBackend;
|
|
262
|
+
if (!backend?.registerFile) {
|
|
263
|
+
return { response: { id: request.id, type: "response", result: { state: "error", error: "Browser external files are supported only by the browser client" } }, transfer: [] };
|
|
264
|
+
}
|
|
265
|
+
const file = backend.registerFile(request.source.file);
|
|
266
|
+
return this.mountFile(request, file.locator, file.size, backend);
|
|
267
|
+
}
|
|
268
|
+
if (request.type === "refreshMount") {
|
|
269
|
+
validateCString(request.path, "external registration path");
|
|
270
|
+
if (!this.module.externalDirectoryBackend) return { response: { id: request.id, type: "response", result: { state: "error", error: "External directories are not supported by this client" } }, transfer: [] };
|
|
271
|
+
if (!this.mountedDirectoryPaths.has(request.path)) {
|
|
272
|
+
const error = this.mountedPaths.has(request.path) ? "Only directory mounts can be refreshed" : "External directory registration was not found";
|
|
273
|
+
return { response: { id: request.id, type: "response", result: { state: "error", error } }, transfer: [] };
|
|
274
|
+
}
|
|
258
275
|
}
|
|
259
276
|
if (request.type === "unmount" && (this.module.externalFileBackend || this.module.externalDirectoryBackend)) {
|
|
260
277
|
validateCString(request.path, "external registration path");
|
|
261
278
|
const pointer2 = safeInteger(this.removeExternalRegistration(request.path, request.id), "result pointer");
|
|
262
279
|
const result2 = this.decodeResult(pointer2);
|
|
263
280
|
if (result2.state === "ok" || result2.state === "error" && result2.error === "External registration was not found" && this.mountedPaths.has(request.path)) {
|
|
281
|
+
this.mountedDirectoryPaths.delete(request.path);
|
|
264
282
|
const cleanup = async () => {
|
|
265
283
|
await Promise.all([
|
|
266
284
|
this.module.externalFileBackend?.removed(request.path),
|
|
@@ -272,12 +290,14 @@ var HyperDBBindings = class {
|
|
|
272
290
|
}
|
|
273
291
|
return { response: { id: request.id, type: "response", result: result2 }, transfer: [] };
|
|
274
292
|
}
|
|
275
|
-
if (request.type === "unmount"
|
|
293
|
+
if (request.type === "unmount") {
|
|
276
294
|
return { response: { id: request.id, type: "response", result: { state: "error", error: "External files are not supported by this client" } }, transfer: [] };
|
|
277
295
|
}
|
|
278
296
|
const pointer = safeInteger(this.invoke(request), "result pointer");
|
|
279
297
|
const result = this.decodeResult(pointer);
|
|
280
298
|
if (request.type === "shutdown" && result.state === "ok") {
|
|
299
|
+
this.mountedPaths.clear();
|
|
300
|
+
this.mountedDirectoryPaths.clear();
|
|
281
301
|
const completion = completionFor([
|
|
282
302
|
this.module.externalFileBackend?.shutdown(),
|
|
283
303
|
this.module.externalDirectoryBackend?.shutdown()
|
|
@@ -312,6 +332,8 @@ var HyperDBBindings = class {
|
|
|
312
332
|
case "unmount":
|
|
313
333
|
validateCString(request.path, "external registration path");
|
|
314
334
|
return this.removeExternalRegistration(request.path, request.id);
|
|
335
|
+
case "refreshMount":
|
|
336
|
+
return this.refreshExternalDirectory(request.path, request.id);
|
|
315
337
|
case "startQuery":
|
|
316
338
|
validateCStringContents(request.sql, "SQL");
|
|
317
339
|
return this.startQuery(request.connection, request.sql, Number(request.sqlTestMode ?? false), request.id);
|
|
@@ -332,13 +354,13 @@ var HyperDBBindings = class {
|
|
|
332
354
|
try {
|
|
333
355
|
const result = this.decodeResult(safeInteger(this.registerExternalFile(request.path, locator, size, request.id), "result pointer"));
|
|
334
356
|
if (result.state !== "ok") {
|
|
335
|
-
backend
|
|
336
|
-
return { response: { id: request.id, type: "response", result }, transfer: [] };
|
|
357
|
+
const completion = completionFor([backend.removed(locator)]);
|
|
358
|
+
return { response: { id: request.id, type: "response", result }, transfer: [], ...completion && { completion } };
|
|
337
359
|
}
|
|
338
360
|
path = new TextDecoder("utf-8", { fatal: true }).decode(result.payload);
|
|
339
361
|
const projection = this.decodeResult(safeInteger(this.projectExternalFile(path, locator, size, request.id), "result pointer"));
|
|
340
362
|
if (projection.state !== "ok") throw new Error(resultError(projection));
|
|
341
|
-
backend
|
|
363
|
+
backend.registered(path, locator);
|
|
342
364
|
registered = true;
|
|
343
365
|
this.mountedPaths.add(path);
|
|
344
366
|
return { response: { id: request.id, type: "response", result }, transfer: [] };
|
|
@@ -353,12 +375,15 @@ var HyperDBBindings = class {
|
|
|
353
375
|
}
|
|
354
376
|
if (rollbackError !== void 0) {
|
|
355
377
|
if (path !== void 0) {
|
|
356
|
-
backend
|
|
378
|
+
backend.registered(path, locator);
|
|
357
379
|
this.mountedPaths.add(path);
|
|
358
380
|
}
|
|
359
381
|
throw new Error(`mount failed and rollback also failed: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`, { cause: error });
|
|
360
382
|
}
|
|
361
|
-
backend
|
|
383
|
+
const completion = completionFor([backend.removed(registered && path !== void 0 ? path : locator)]);
|
|
384
|
+
if (completion) {
|
|
385
|
+
return { response: { id: request.id, type: "response", result: { state: "error", error: error instanceof Error ? error.message : String(error) } }, transfer: [], completion };
|
|
386
|
+
}
|
|
362
387
|
throw error;
|
|
363
388
|
}
|
|
364
389
|
}
|
|
@@ -382,12 +407,14 @@ var HyperDBBindings = class {
|
|
|
382
407
|
if (projection.state !== "ok") throw new Error(resultError(projection));
|
|
383
408
|
backend.registered(path, registration.locator);
|
|
384
409
|
this.mountedPaths.add(path);
|
|
410
|
+
this.mountedDirectoryPaths.add(path);
|
|
385
411
|
} catch (error) {
|
|
386
412
|
const cleanupPointer = safeInteger(this.removeExternalRegistration(path, request.id), "result pointer");
|
|
387
413
|
const cleanup = this.decodeResult(cleanupPointer);
|
|
388
414
|
if (cleanup.state !== "ok") {
|
|
389
415
|
backend.registered(path, registration.locator);
|
|
390
416
|
this.mountedPaths.add(path);
|
|
417
|
+
this.mountedDirectoryPaths.add(path);
|
|
391
418
|
preserveBackend = true;
|
|
392
419
|
throw new Error(`mount failed and rollback also failed: ${resultError(cleanup)}`, { cause: error });
|
|
393
420
|
}
|
package/dist/wasm_bindings.d.ts
CHANGED
|
@@ -22,25 +22,30 @@ export interface ExternalFileBackend {
|
|
|
22
22
|
shutdown(): void;
|
|
23
23
|
}
|
|
24
24
|
export interface ExternalDirectoryBackend {
|
|
25
|
+
registerFile?(file: unknown): {
|
|
26
|
+
readonly locator: string;
|
|
27
|
+
readonly size: number;
|
|
28
|
+
};
|
|
25
29
|
register(handle: unknown, mode: 'read' | 'readwrite'): {
|
|
26
30
|
readonly name: string;
|
|
27
31
|
readonly locator: string;
|
|
28
32
|
};
|
|
29
33
|
registered(path: string, locator: string): void;
|
|
34
|
+
releaseGeneration(locator: string, generation: string): void | Promise<void>;
|
|
30
35
|
removed(path: string): void | Promise<void>;
|
|
31
36
|
list(locator: string): Promise<readonly string[]>;
|
|
32
37
|
listEntries?(locator: string, path: string): Promise<readonly {
|
|
33
38
|
readonly name: string;
|
|
34
39
|
readonly kind: 'file' | 'directory';
|
|
35
40
|
}[]>;
|
|
36
|
-
lookup?(locator: string, path: string): Promise<{
|
|
41
|
+
lookup?(locator: string, path: string, generation: string): Promise<{
|
|
37
42
|
readonly kind: 'directory';
|
|
38
43
|
} | {
|
|
39
44
|
readonly kind: 'file';
|
|
40
45
|
readonly locator: string;
|
|
41
46
|
readonly size: number;
|
|
42
47
|
} | undefined>;
|
|
43
|
-
open(locator: string, path: string): Promise<{
|
|
48
|
+
open(locator: string, path: string, generation: string): Promise<{
|
|
44
49
|
readonly locator: string;
|
|
45
50
|
readonly size: number;
|
|
46
51
|
}>;
|
|
@@ -60,7 +65,6 @@ export interface HyperDBWasmModule {
|
|
|
60
65
|
mount(type: unknown, options: Record<string, unknown>, path: string): void;
|
|
61
66
|
};
|
|
62
67
|
hyperdbWasmStoragePath?: string;
|
|
63
|
-
externalFileBackendAvailable?: boolean;
|
|
64
68
|
externalFileBackend?: ExternalFileBackend;
|
|
65
69
|
externalDirectoryBackend?: ExternalDirectoryBackend;
|
|
66
70
|
_malloc(size: number): number | bigint;
|
|
@@ -80,6 +84,7 @@ export declare class HyperDBBindings {
|
|
|
80
84
|
private readonly registerExternalFile;
|
|
81
85
|
private readonly registerExternalDirectory;
|
|
82
86
|
private readonly removeExternalRegistration;
|
|
87
|
+
private readonly refreshExternalDirectory;
|
|
83
88
|
private readonly projectExternalFile;
|
|
84
89
|
private readonly projectExternalDirectory;
|
|
85
90
|
private readonly startQuery;
|
|
@@ -90,6 +95,7 @@ export declare class HyperDBBindings {
|
|
|
90
95
|
private readonly resultPayloadLength;
|
|
91
96
|
private readonly free;
|
|
92
97
|
private readonly mountedPaths;
|
|
98
|
+
private readonly mountedDirectoryPaths;
|
|
93
99
|
constructor(module: HyperDBWasmModule);
|
|
94
100
|
handle(request: EngineRequest): BindingResponse;
|
|
95
101
|
private invoke;
|
package/dist/worker_setup.d.ts
CHANGED
|
@@ -35,13 +35,14 @@ export interface HyperDBWasmRuntimeModule extends HyperDBWasmModule {
|
|
|
35
35
|
hyperdbWasmHostFileClose?: (id: number) => void;
|
|
36
36
|
hyperdbWasmHostDirectoryListStart?: (id: number, path: string) => void;
|
|
37
37
|
hyperdbWasmExternalDirectoryListStart?: (id: number, locator: string) => void;
|
|
38
|
-
hyperdbWasmExternalDirectoryOpenStart?: (id: number, locator: string, path: string) => void;
|
|
38
|
+
hyperdbWasmExternalDirectoryOpenStart?: (id: number, locator: string, path: string, generation: string) => void;
|
|
39
|
+
hyperdbWasmExternalDirectoryReleaseGeneration?: (locator: string, generation: string) => void;
|
|
39
40
|
hyperdbWasmExternalDirectoryCreateDirectoriesStart?: (id: number, locator: string, path: string) => void;
|
|
40
41
|
hyperdbWasmExternalDirectoryWriterWriteStart?: (writer: number, id: number, locator: string, path: string, offset: number, pointer: number | bigint, length: number) => void;
|
|
41
42
|
hyperdbWasmExternalDirectoryWriterFinishStart?: (writer: number, id: number, locator: string, path: string, size: number) => void;
|
|
42
43
|
hyperdbWasmExternalDirectoryWriterAbortStart?: (writer: number, id: number) => void;
|
|
43
44
|
hyperdbWasmFilesystemListStart?: (id: number, locator: string, path: string) => void;
|
|
44
|
-
hyperdbWasmFilesystemLookupStart?: (id: number, locator: string, path: string) => void;
|
|
45
|
+
hyperdbWasmFilesystemLookupStart?: (id: number, locator: string, path: string, generation: string) => void;
|
|
45
46
|
hyperdbWasmFilesystemReadStart?: (id: number, locator: string, offset: number, length: number, expectedSize: number, pointer: number | bigint) => void;
|
|
46
47
|
hyperdbWasmShouldOpenHostFile?: (path: string) => boolean;
|
|
47
48
|
hyperdbWasmShouldListHostDirectory?: (path: string) => boolean;
|