hyperdb-wasm 0.0.26304-dev.wasm.g36a4b6a4 → 0.0.26306-dev.wasm.g0f7bea54
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 +12 -2
- package/dist/browser.js +17 -7
- package/dist/browser_worker.js +11 -4
- 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 +4 -2
- package/dist/node.js +20 -9
- package/dist/node_worker.js +12 -5
- package/dist/protocol.d.ts +4 -0
- package/dist/raw.browser.js +12 -4
- package/dist/raw.node.js +12 -4
- package/dist/wasm_bindings.d.ts +1 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { BrowserClientOptions } from './browser.js';
|
|
|
5
5
|
import type { WasmResult } from './protocol.js';
|
|
6
6
|
export interface HyperDBClient {
|
|
7
7
|
ready(): Promise<void>;
|
|
8
|
+
initialize(settings: string): Promise<WasmResult>;
|
|
8
9
|
connect(): Promise<WasmResult>;
|
|
9
10
|
disconnect(connection: number): Promise<WasmResult>;
|
|
10
11
|
createDatabase(databaseName: string, persistent: boolean): Promise<WasmResult>;
|
|
@@ -32,10 +33,19 @@ export interface ArrowInsertOptions {
|
|
|
32
33
|
export interface DatabaseCreateOptions {
|
|
33
34
|
readonly storage?: 'memory' | 'persistent';
|
|
34
35
|
}
|
|
36
|
+
export type HyperDBSettingValue = string | number | boolean | null | readonly HyperDBSettingValue[] | {
|
|
37
|
+
readonly [key: string]: HyperDBSettingValue;
|
|
38
|
+
};
|
|
39
|
+
export type HyperDBSettings = Readonly<Record<string, HyperDBSettingValue>>;
|
|
40
|
+
export interface HyperDBCreateOptions {
|
|
41
|
+
readonly settings?: HyperDBSettings;
|
|
42
|
+
}
|
|
43
|
+
export type BrowserCreateOptions = BrowserClientOptions & HyperDBCreateOptions;
|
|
35
44
|
export interface DatabaseMetadata {
|
|
36
45
|
readonly name: string;
|
|
37
46
|
readonly storage: 'memory' | 'persistent';
|
|
38
47
|
}
|
|
48
|
+
declare function initializeHyperDB(client: HyperDBClient, settings: HyperDBSettings | undefined): Promise<void>;
|
|
39
49
|
export declare class HyperDB {
|
|
40
50
|
private readonly client;
|
|
41
51
|
private terminated;
|
|
@@ -43,7 +53,7 @@ export declare class HyperDB {
|
|
|
43
53
|
private activeDatabaseOperations;
|
|
44
54
|
private readonly connections;
|
|
45
55
|
constructor(client: HyperDBClient);
|
|
46
|
-
static create(options?:
|
|
56
|
+
static create(options?: BrowserCreateOptions): Promise<HyperDB>;
|
|
47
57
|
ready(): Promise<void>;
|
|
48
58
|
connect(): Promise<HyperDBConnection>;
|
|
49
59
|
createDatabase(databaseName: string, options?: DatabaseCreateOptions): Promise<void>;
|
|
@@ -82,4 +92,4 @@ export declare class HyperDBConnection {
|
|
|
82
92
|
closeForTermination(): Promise<void>;
|
|
83
93
|
}
|
|
84
94
|
export type { HyperDBEngineClient };
|
|
85
|
-
export
|
|
95
|
+
export { initializeHyperDB as initializeHyperDBInternal };
|
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
|
-
//
|
|
16
|
+
// 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
|
-
"
|
|
57
|
+
"src/protocol.ts"() {
|
|
58
58
|
"use strict";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
//
|
|
62
|
+
// src/client.ts
|
|
63
63
|
var HyperDBEngineClient;
|
|
64
64
|
var init_client = __esm({
|
|
65
|
-
"
|
|
65
|
+
"src/client.ts"() {
|
|
66
66
|
"use strict";
|
|
67
67
|
init_protocol();
|
|
68
68
|
HyperDBEngineClient = class {
|
|
@@ -89,6 +89,9 @@ var init_client = __esm({
|
|
|
89
89
|
ready() {
|
|
90
90
|
return this.readyPromise;
|
|
91
91
|
}
|
|
92
|
+
initialize(settings) {
|
|
93
|
+
return this.request({ id: this.nextId++, type: "initialize", settings });
|
|
94
|
+
}
|
|
92
95
|
connect() {
|
|
93
96
|
return this.request({ id: this.nextId++, type: "connect" });
|
|
94
97
|
}
|
|
@@ -185,7 +188,7 @@ var init_client = __esm({
|
|
|
185
188
|
}
|
|
186
189
|
});
|
|
187
190
|
|
|
188
|
-
//
|
|
191
|
+
// src/browser.ts
|
|
189
192
|
var browser_exports = {};
|
|
190
193
|
__export(browser_exports, {
|
|
191
194
|
BrowserWorker: () => BrowserWorker,
|
|
@@ -204,7 +207,7 @@ function createBrowserClient(options = {}) {
|
|
|
204
207
|
}
|
|
205
208
|
var BrowserWorker;
|
|
206
209
|
var init_browser = __esm({
|
|
207
|
-
"
|
|
210
|
+
"src/browser.ts"() {
|
|
208
211
|
"use strict";
|
|
209
212
|
init_client();
|
|
210
213
|
BrowserWorker = class {
|
|
@@ -12076,7 +12079,7 @@ RecordBatchWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
|
12076
12079
|
RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12077
12080
|
RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12078
12081
|
|
|
12079
|
-
//
|
|
12082
|
+
// src/api.ts
|
|
12080
12083
|
function normalizeArrowInsertOptions(options) {
|
|
12081
12084
|
if (!options.name) throw new Error("Arrow insert table name must not be empty");
|
|
12082
12085
|
return { name: options.name, schema: options.schema ?? null, create: options.create ?? true };
|
|
@@ -12119,6 +12122,12 @@ function readErrorFromResult(result, operation) {
|
|
|
12119
12122
|
function expectOk(result, operation) {
|
|
12120
12123
|
if (result.state !== "ok") throw readErrorFromResult(result, operation);
|
|
12121
12124
|
}
|
|
12125
|
+
async function initializeHyperDB(client, settings) {
|
|
12126
|
+
if (settings === void 0) return;
|
|
12127
|
+
const serialized = JSON.stringify(settings);
|
|
12128
|
+
if (serialized === void 0) throw new Error("HyperDB settings must be JSON-serializable");
|
|
12129
|
+
expectOk(await client.initialize(serialized), "initialize HyperDB settings");
|
|
12130
|
+
}
|
|
12122
12131
|
function readDatabasesFromResult(result) {
|
|
12123
12132
|
expectOk(result, "list databases");
|
|
12124
12133
|
const invalidResult = () => new Error("list databases returned invalid metadata");
|
|
@@ -12165,6 +12174,7 @@ var HyperDB = class _HyperDB {
|
|
|
12165
12174
|
const database = new _HyperDB(client);
|
|
12166
12175
|
try {
|
|
12167
12176
|
await database.ready();
|
|
12177
|
+
await initializeHyperDB(client, options.settings);
|
|
12168
12178
|
return database;
|
|
12169
12179
|
} catch (error) {
|
|
12170
12180
|
try {
|
package/dist/browser_worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
//
|
|
3
|
+
// 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;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
var HyperDBBindings = class {
|
|
15
15
|
module;
|
|
16
|
+
initialize;
|
|
16
17
|
connect;
|
|
17
18
|
disconnect;
|
|
18
19
|
createDatabase;
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
nextTemporaryFile = 1;
|
|
35
36
|
constructor(module) {
|
|
36
37
|
this.module = module;
|
|
38
|
+
this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
|
|
37
39
|
this.connect = module.cwrap("hyperdb_wasm_connect", "pointer", []);
|
|
38
40
|
this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
39
41
|
this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
@@ -71,6 +73,9 @@
|
|
|
71
73
|
}
|
|
72
74
|
invoke(request) {
|
|
73
75
|
switch (request.type) {
|
|
76
|
+
case "initialize":
|
|
77
|
+
validateCString(request.settings, "settings");
|
|
78
|
+
return this.initialize(request.settings);
|
|
74
79
|
case "connect":
|
|
75
80
|
return this.connect();
|
|
76
81
|
case "disconnect":
|
|
@@ -144,7 +149,7 @@
|
|
|
144
149
|
}
|
|
145
150
|
};
|
|
146
151
|
|
|
147
|
-
//
|
|
152
|
+
// src/protocol.ts
|
|
148
153
|
function isRecord(value) {
|
|
149
154
|
return typeof value === "object" && value !== null;
|
|
150
155
|
}
|
|
@@ -156,6 +161,8 @@
|
|
|
156
161
|
function isEngineRequest(value) {
|
|
157
162
|
if (!isRecord(value) || !Number.isSafeInteger(value.id) || typeof value.type !== "string") return false;
|
|
158
163
|
switch (value.type) {
|
|
164
|
+
case "initialize":
|
|
165
|
+
return hasKeys(value, ["id", "type", "settings"]) && typeof value.settings === "string";
|
|
159
166
|
case "connect":
|
|
160
167
|
case "listDatabases":
|
|
161
168
|
return hasKeys(value, ["id", "type"]);
|
|
@@ -190,7 +197,7 @@
|
|
|
190
197
|
}
|
|
191
198
|
}
|
|
192
199
|
|
|
193
|
-
//
|
|
200
|
+
// src/worker_setup.ts
|
|
194
201
|
function errorText(error) {
|
|
195
202
|
return error instanceof Error ? error.message : String(error);
|
|
196
203
|
}
|
|
@@ -285,7 +292,7 @@
|
|
|
285
292
|
module.onAbort = (reason) => transport.postMessage({ type: "fatal", error: `engine aborted: ${String(reason)}` });
|
|
286
293
|
}
|
|
287
294
|
|
|
288
|
-
//
|
|
295
|
+
// src/browser_worker.ts
|
|
289
296
|
var configuredEngineUrl = new URL(self.location.href).searchParams.get("engineUrl");
|
|
290
297
|
var engineUrl = self.HYPERDB_WASM_ENGINE_URL ?? configuredEngineUrl ?? "hyperdb-wasm.js";
|
|
291
298
|
var resolvedEngineUrl = new URL(engineUrl, self.location.href);
|
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class HyperDBEngineClient {
|
|
|
10
10
|
private readonly unsubscribe;
|
|
11
11
|
constructor(transport: WorkerTransport);
|
|
12
12
|
ready(): Promise<void>;
|
|
13
|
+
initialize(settings: string): Promise<WasmResult>;
|
|
13
14
|
connect(): Promise<WasmResult>;
|
|
14
15
|
disconnect(connection: number): Promise<WasmResult>;
|
|
15
16
|
createDatabase(databaseName: string, persistent: boolean): Promise<WasmResult>;
|