hyperdb-wasm 0.0.26305-dev.wasm.gdf59cd37 → 0.0.26308-dev.wasm.gae25030d
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 +10 -0
- package/dist/browser_worker.js +7 -0
- 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 +11 -0
- package/dist/node_worker.js +7 -0
- package/dist/protocol.d.ts +4 -0
- package/dist/raw.browser.js +8 -0
- package/dist/raw.node.js +8 -0
- 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
|
@@ -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
|
}
|
|
@@ -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
|
@@ -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":
|
|
@@ -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"]);
|
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>;
|