hyperdb-wasm 0.0.26298-dev.wasm.gd63c7938 → 0.0.26301-dev.wasm.g560c2cb5
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 +6 -0
- package/dist/browser.js +62 -14
- package/dist/browser_worker.js +9 -5
- 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/index.d.ts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/node.js +76 -19
- package/dist/node_worker.js +10 -7
- package/dist/protocol.d.ts +3 -0
- package/dist/raw.browser.js +12 -5
- package/dist/raw.node.js +12 -5
- package/dist/wasm_bindings.d.ts +1 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface HyperDBClient {
|
|
|
9
9
|
disconnect(connection: number): Promise<WasmResult>;
|
|
10
10
|
createDatabase(databaseName: string, persistent: boolean): Promise<WasmResult>;
|
|
11
11
|
openDatabase(databaseName: string): Promise<WasmResult>;
|
|
12
|
+
listDatabases(): Promise<WasmResult>;
|
|
12
13
|
checkpointDatabase(databaseName: string): Promise<WasmResult>;
|
|
13
14
|
dropDatabase(databaseName: string): Promise<WasmResult>;
|
|
14
15
|
attachDatabase(connection: number, databaseName: string, alias: string): Promise<WasmResult>;
|
|
@@ -31,6 +32,10 @@ export interface ArrowInsertOptions {
|
|
|
31
32
|
export interface DatabaseCreateOptions {
|
|
32
33
|
readonly storage?: 'memory' | 'persistent';
|
|
33
34
|
}
|
|
35
|
+
export interface DatabaseMetadata {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly storage: 'memory' | 'persistent';
|
|
38
|
+
}
|
|
34
39
|
export declare class HyperDB {
|
|
35
40
|
private readonly client;
|
|
36
41
|
private terminated;
|
|
@@ -43,6 +48,7 @@ export declare class HyperDB {
|
|
|
43
48
|
connect(): Promise<HyperDBConnection>;
|
|
44
49
|
createDatabase(databaseName: string, options?: DatabaseCreateOptions): Promise<void>;
|
|
45
50
|
openDatabase(databaseName: string): Promise<void>;
|
|
51
|
+
listDatabases(): Promise<DatabaseMetadata[]>;
|
|
46
52
|
checkpointDatabase(databaseName: string): Promise<void>;
|
|
47
53
|
dropDatabase(databaseName: string): Promise<void>;
|
|
48
54
|
terminate(): Promise<void>;
|
package/dist/browser.js
CHANGED
|
@@ -13,7 +13,7 @@ var __export = (target, all) => {
|
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
// protocol.ts
|
|
16
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/protocol.ts
|
|
17
17
|
function isRecord(value) {
|
|
18
18
|
return typeof value === "object" && value !== null;
|
|
19
19
|
}
|
|
@@ -54,15 +54,15 @@ function isWorkerEvent(message) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
var init_protocol = __esm({
|
|
57
|
-
"protocol.ts"() {
|
|
57
|
+
"../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/protocol.ts"() {
|
|
58
58
|
"use strict";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// client.ts
|
|
62
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/client.ts
|
|
63
63
|
var HyperDBEngineClient;
|
|
64
64
|
var init_client = __esm({
|
|
65
|
-
"client.ts"() {
|
|
65
|
+
"../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/client.ts"() {
|
|
66
66
|
"use strict";
|
|
67
67
|
init_protocol();
|
|
68
68
|
HyperDBEngineClient = class {
|
|
@@ -101,6 +101,9 @@ var init_client = __esm({
|
|
|
101
101
|
openDatabase(databaseName) {
|
|
102
102
|
return this.request({ id: this.nextId++, type: "openDatabase", databaseName });
|
|
103
103
|
}
|
|
104
|
+
listDatabases() {
|
|
105
|
+
return this.request({ id: this.nextId++, type: "listDatabases" });
|
|
106
|
+
}
|
|
104
107
|
checkpointDatabase(databaseName) {
|
|
105
108
|
return this.request({ id: this.nextId++, type: "checkpointDatabase", databaseName });
|
|
106
109
|
}
|
|
@@ -139,8 +142,8 @@ var init_client = __esm({
|
|
|
139
142
|
return this.request({ id: this.nextId++, type: "releaseQuery", query });
|
|
140
143
|
}
|
|
141
144
|
async terminate() {
|
|
142
|
-
this.fail(new Error("engine worker terminated"));
|
|
143
145
|
await this.transport.terminate();
|
|
146
|
+
this.fail(new Error("engine worker terminated"));
|
|
144
147
|
}
|
|
145
148
|
request(request, transfer = []) {
|
|
146
149
|
if (this.failed) return Promise.reject(this.failed);
|
|
@@ -182,7 +185,7 @@ var init_client = __esm({
|
|
|
182
185
|
}
|
|
183
186
|
});
|
|
184
187
|
|
|
185
|
-
// browser.ts
|
|
188
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/browser.ts
|
|
186
189
|
var browser_exports = {};
|
|
187
190
|
__export(browser_exports, {
|
|
188
191
|
BrowserWorker: () => BrowserWorker,
|
|
@@ -201,7 +204,7 @@ function createBrowserClient(options = {}) {
|
|
|
201
204
|
}
|
|
202
205
|
var BrowserWorker;
|
|
203
206
|
var init_browser = __esm({
|
|
204
|
-
"browser.ts"() {
|
|
207
|
+
"../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/browser.ts"() {
|
|
205
208
|
"use strict";
|
|
206
209
|
init_client();
|
|
207
210
|
BrowserWorker = class {
|
|
@@ -12073,7 +12076,7 @@ RecordBatchWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
|
12073
12076
|
RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12074
12077
|
RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12075
12078
|
|
|
12076
|
-
// api.ts
|
|
12079
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/api.ts
|
|
12077
12080
|
function normalizeArrowInsertOptions(options) {
|
|
12078
12081
|
if (!options.name) throw new Error("Arrow insert table name must not be empty");
|
|
12079
12082
|
return { name: options.name, schema: options.schema ?? null, create: options.create ?? true };
|
|
@@ -12116,6 +12119,34 @@ function readErrorFromResult(result, operation) {
|
|
|
12116
12119
|
function expectOk(result, operation) {
|
|
12117
12120
|
if (result.state !== "ok") throw readErrorFromResult(result, operation);
|
|
12118
12121
|
}
|
|
12122
|
+
function readDatabasesFromResult(result) {
|
|
12123
|
+
expectOk(result, "list databases");
|
|
12124
|
+
const invalidResult = () => new Error("list databases returned invalid metadata");
|
|
12125
|
+
if (result.payload.byteLength < 4) throw invalidResult();
|
|
12126
|
+
const view = new DataView(result.payload.buffer, result.payload.byteOffset, result.payload.byteLength);
|
|
12127
|
+
const count = view.getUint32(0, true);
|
|
12128
|
+
let offset = 4;
|
|
12129
|
+
const databases = [];
|
|
12130
|
+
const decoder2 = new TextDecoder("utf-8", { fatal: true });
|
|
12131
|
+
for (let index = 0; index < count; ++index) {
|
|
12132
|
+
if (offset + 8 > result.payload.byteLength) throw invalidResult();
|
|
12133
|
+
const rawStorage = view.getUint32(offset, true);
|
|
12134
|
+
const nameLength = view.getUint32(offset + 4, true);
|
|
12135
|
+
offset += 8;
|
|
12136
|
+
if (nameLength > result.payload.byteLength - offset) throw invalidResult();
|
|
12137
|
+
let name;
|
|
12138
|
+
try {
|
|
12139
|
+
name = decoder2.decode(result.payload.subarray(offset, offset + nameLength));
|
|
12140
|
+
} catch {
|
|
12141
|
+
throw invalidResult();
|
|
12142
|
+
}
|
|
12143
|
+
if (!name || name.includes("\0") || rawStorage !== 0 && rawStorage !== 1) throw invalidResult();
|
|
12144
|
+
databases.push({ name, storage: rawStorage === 0 ? "memory" : "persistent" });
|
|
12145
|
+
offset += nameLength;
|
|
12146
|
+
}
|
|
12147
|
+
if (offset !== result.payload.byteLength) throw invalidResult();
|
|
12148
|
+
return databases;
|
|
12149
|
+
}
|
|
12119
12150
|
function yieldToEventLoop() {
|
|
12120
12151
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
12121
12152
|
}
|
|
@@ -12130,9 +12161,18 @@ var HyperDB = class _HyperDB {
|
|
|
12130
12161
|
connections = /* @__PURE__ */ new Set();
|
|
12131
12162
|
static async create(options = {}) {
|
|
12132
12163
|
const { createBrowserClient: createBrowserClient2 } = await Promise.resolve().then(() => (init_browser(), browser_exports));
|
|
12133
|
-
const
|
|
12134
|
-
|
|
12135
|
-
|
|
12164
|
+
const client = createBrowserClient2(options);
|
|
12165
|
+
const database = new _HyperDB(client);
|
|
12166
|
+
try {
|
|
12167
|
+
await database.ready();
|
|
12168
|
+
return database;
|
|
12169
|
+
} catch (error) {
|
|
12170
|
+
try {
|
|
12171
|
+
await client.terminate();
|
|
12172
|
+
} catch {
|
|
12173
|
+
}
|
|
12174
|
+
throw error;
|
|
12175
|
+
}
|
|
12136
12176
|
}
|
|
12137
12177
|
ready() {
|
|
12138
12178
|
this.ensureRunning();
|
|
@@ -12160,6 +12200,9 @@ var HyperDB = class _HyperDB {
|
|
|
12160
12200
|
expectOk(await this.client.openDatabase(databaseName), "open database");
|
|
12161
12201
|
});
|
|
12162
12202
|
}
|
|
12203
|
+
listDatabases() {
|
|
12204
|
+
return this.runDatabaseOperation(async () => readDatabasesFromResult(await this.client.listDatabases()));
|
|
12205
|
+
}
|
|
12163
12206
|
async checkpointDatabase(databaseName) {
|
|
12164
12207
|
validateDatabaseName(databaseName);
|
|
12165
12208
|
await this.runDatabaseOperation(async () => {
|
|
@@ -12189,8 +12232,13 @@ var HyperDB = class _HyperDB {
|
|
|
12189
12232
|
this.termination = void 0;
|
|
12190
12233
|
throw error;
|
|
12191
12234
|
}
|
|
12192
|
-
|
|
12193
|
-
|
|
12235
|
+
try {
|
|
12236
|
+
await this.client.terminate();
|
|
12237
|
+
this.terminated = true;
|
|
12238
|
+
} catch (error) {
|
|
12239
|
+
this.termination = void 0;
|
|
12240
|
+
throw error;
|
|
12241
|
+
}
|
|
12194
12242
|
})();
|
|
12195
12243
|
}
|
|
12196
12244
|
await this.termination;
|
|
@@ -12203,7 +12251,7 @@ var HyperDB = class _HyperDB {
|
|
|
12203
12251
|
this.ensureRunning();
|
|
12204
12252
|
++this.activeDatabaseOperations;
|
|
12205
12253
|
try {
|
|
12206
|
-
await operation();
|
|
12254
|
+
return await operation();
|
|
12207
12255
|
} finally {
|
|
12208
12256
|
--this.activeDatabaseOperations;
|
|
12209
12257
|
}
|
package/dist/browser_worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// wasm_bindings.ts
|
|
3
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/wasm_bindings.ts
|
|
4
4
|
var resultStates = ["ok", "pending", "chunk", "done", "error", "busy"];
|
|
5
5
|
function safeInteger(value, name) {
|
|
6
6
|
const number = typeof value === "bigint" && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
disconnect;
|
|
18
18
|
createDatabase;
|
|
19
19
|
openDatabase;
|
|
20
|
+
listDatabases;
|
|
20
21
|
checkpointDatabase;
|
|
21
22
|
dropDatabase;
|
|
22
23
|
shutdown;
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
38
39
|
this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
39
40
|
this.openDatabase = module.cwrap("hyperdb_wasm_open_database", "pointer", ["string"]);
|
|
41
|
+
this.listDatabases = module.cwrap("hyperdb_wasm_list_databases", "pointer", []);
|
|
40
42
|
this.checkpointDatabase = module.cwrap("hyperdb_wasm_checkpoint_database", "pointer", ["string"]);
|
|
41
43
|
this.dropDatabase = module.cwrap("hyperdb_wasm_drop_database", "pointer", ["string"]);
|
|
42
44
|
this.shutdown = module.cwrap("hyperdb_wasm_shutdown", "pointer", []);
|
|
@@ -79,6 +81,8 @@
|
|
|
79
81
|
case "openDatabase":
|
|
80
82
|
validateCString(request.databaseName, "database name");
|
|
81
83
|
return this.openDatabase(request.databaseName);
|
|
84
|
+
case "listDatabases":
|
|
85
|
+
return this.listDatabases();
|
|
82
86
|
case "checkpointDatabase":
|
|
83
87
|
validateCString(request.databaseName, "database name");
|
|
84
88
|
return this.checkpointDatabase(request.databaseName);
|
|
@@ -140,7 +144,7 @@
|
|
|
140
144
|
}
|
|
141
145
|
};
|
|
142
146
|
|
|
143
|
-
// protocol.ts
|
|
147
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/protocol.ts
|
|
144
148
|
function isRecord(value) {
|
|
145
149
|
return typeof value === "object" && value !== null;
|
|
146
150
|
}
|
|
@@ -153,6 +157,7 @@
|
|
|
153
157
|
if (!isRecord(value) || !Number.isSafeInteger(value.id) || typeof value.type !== "string") return false;
|
|
154
158
|
switch (value.type) {
|
|
155
159
|
case "connect":
|
|
160
|
+
case "listDatabases":
|
|
156
161
|
return hasKeys(value, ["id", "type"]);
|
|
157
162
|
case "disconnect":
|
|
158
163
|
return hasKeys(value, ["id", "type", "connection"]) && Number.isSafeInteger(value.connection);
|
|
@@ -185,7 +190,7 @@
|
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
// worker_setup.ts
|
|
193
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/worker_setup.ts
|
|
189
194
|
function errorText(error) {
|
|
190
195
|
return error instanceof Error ? error.message : String(error);
|
|
191
196
|
}
|
|
@@ -263,7 +268,6 @@
|
|
|
263
268
|
transport.onMessage((message) => {
|
|
264
269
|
if (isEngineRequest(message)) handle(message);
|
|
265
270
|
});
|
|
266
|
-
module.arguments = ["--no-demo"];
|
|
267
271
|
module.print = (text) => transport.postMessage({ type: "log", text });
|
|
268
272
|
module.printErr = (text) => transport.postMessage({ type: "log", text });
|
|
269
273
|
module.onRuntimeInitialized = () => {
|
|
@@ -280,7 +284,7 @@
|
|
|
280
284
|
module.onAbort = (reason) => transport.postMessage({ type: "fatal", error: `engine aborted: ${String(reason)}` });
|
|
281
285
|
}
|
|
282
286
|
|
|
283
|
-
// browser_worker.ts
|
|
287
|
+
// ../../../../../../../hyper-cache/bazel/bazel_user_root/18bf2c17ab56269933d5cfcb90730d2f/execroot/_main/hyper/wasm/npm/src/browser_worker.ts
|
|
284
288
|
var configuredEngineUrl = new URL(self.location.href).searchParams.get("engineUrl");
|
|
285
289
|
var engineUrl = self.HYPERDB_WASM_ENGINE_URL ?? configuredEngineUrl ?? "hyperdb-wasm.js";
|
|
286
290
|
var resolvedEngineUrl = new URL(engineUrl, self.location.href);
|
package/dist/client.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class HyperDBEngineClient {
|
|
|
14
14
|
disconnect(connection: number): Promise<WasmResult>;
|
|
15
15
|
createDatabase(databaseName: string, persistent: boolean): Promise<WasmResult>;
|
|
16
16
|
openDatabase(databaseName: string): Promise<WasmResult>;
|
|
17
|
+
listDatabases(): Promise<WasmResult>;
|
|
17
18
|
checkpointDatabase(databaseName: string): Promise<WasmResult>;
|
|
18
19
|
dropDatabase(databaseName: string): Promise<WasmResult>;
|
|
19
20
|
attachDatabase(connection: number, databaseName: string, alias: string): Promise<WasmResult>;
|