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
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { HyperDB, HyperDBConnection } from './api.js';
|
|
2
|
-
export type { ArrowInsertOptions, DatabaseCreateOptions, DatabaseMetadata } from './api.js';
|
|
2
|
+
export type { ArrowInsertOptions, BrowserCreateOptions, DatabaseCreateOptions, DatabaseMetadata, HyperDBSettingValue, HyperDBSettings } from './api.js';
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { HyperDB as BaseHyperDB } from './api.js';
|
|
2
|
+
import type { HyperDBCreateOptions } from './api.js';
|
|
2
3
|
import type { NodeClientOptions } from './node.js';
|
|
3
4
|
export { HyperDBConnection } from './api.js';
|
|
4
|
-
export type { ArrowInsertOptions, DatabaseCreateOptions, DatabaseMetadata } from './api.js';
|
|
5
|
+
export type { ArrowInsertOptions, DatabaseCreateOptions, DatabaseMetadata, HyperDBSettingValue, HyperDBSettings } from './api.js';
|
|
6
|
+
export type NodeCreateOptions = NodeClientOptions & HyperDBCreateOptions;
|
|
5
7
|
export declare class HyperDB extends BaseHyperDB {
|
|
6
|
-
static create(options?:
|
|
8
|
+
static create(options?: NodeCreateOptions): Promise<HyperDB>;
|
|
7
9
|
}
|
package/dist/node.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
|
}
|
|
@@ -279,6 +282,12 @@ function readErrorFromResult(result, operation) {
|
|
|
279
282
|
function expectOk(result, operation) {
|
|
280
283
|
if (result.state !== "ok") throw readErrorFromResult(result, operation);
|
|
281
284
|
}
|
|
285
|
+
async function initializeHyperDB(client, settings) {
|
|
286
|
+
if (settings === void 0) return;
|
|
287
|
+
const serialized = JSON.stringify(settings);
|
|
288
|
+
if (serialized === void 0) throw new Error("HyperDB settings must be JSON-serializable");
|
|
289
|
+
expectOk(await client.initialize(serialized), "initialize HyperDB settings");
|
|
290
|
+
}
|
|
282
291
|
function readDatabasesFromResult(result) {
|
|
283
292
|
expectOk(result, "list databases");
|
|
284
293
|
const invalidResult = () => new Error("list databases returned invalid metadata");
|
|
@@ -325,6 +334,7 @@ var HyperDB = class _HyperDB {
|
|
|
325
334
|
const database = new _HyperDB(client);
|
|
326
335
|
try {
|
|
327
336
|
await database.ready();
|
|
337
|
+
await initializeHyperDB(client, options.settings);
|
|
328
338
|
return database;
|
|
329
339
|
} catch (error) {
|
|
330
340
|
try {
|
|
@@ -666,6 +676,7 @@ var HyperDB2 = class _HyperDB extends HyperDB {
|
|
|
666
676
|
const database = new _HyperDB(client);
|
|
667
677
|
try {
|
|
668
678
|
await database.ready();
|
|
679
|
+
await initializeHyperDB(client, options.settings);
|
|
669
680
|
return database;
|
|
670
681
|
} catch (error) {
|
|
671
682
|
try {
|
package/dist/node_worker.js
CHANGED
|
@@ -20,6 +20,7 @@ function validateCString(value, name) {
|
|
|
20
20
|
}
|
|
21
21
|
var HyperDBBindings = class {
|
|
22
22
|
module;
|
|
23
|
+
initialize;
|
|
23
24
|
connect;
|
|
24
25
|
disconnect;
|
|
25
26
|
createDatabase;
|
|
@@ -41,6 +42,7 @@ var HyperDBBindings = class {
|
|
|
41
42
|
nextTemporaryFile = 1;
|
|
42
43
|
constructor(module2) {
|
|
43
44
|
this.module = module2;
|
|
45
|
+
this.initialize = module2.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
|
|
44
46
|
this.connect = module2.cwrap("hyperdb_wasm_connect", "pointer", []);
|
|
45
47
|
this.disconnect = module2.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
46
48
|
this.createDatabase = module2.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
@@ -78,6 +80,9 @@ var HyperDBBindings = class {
|
|
|
78
80
|
}
|
|
79
81
|
invoke(request) {
|
|
80
82
|
switch (request.type) {
|
|
83
|
+
case "initialize":
|
|
84
|
+
validateCString(request.settings, "settings");
|
|
85
|
+
return this.initialize(request.settings);
|
|
81
86
|
case "connect":
|
|
82
87
|
return this.connect();
|
|
83
88
|
case "disconnect":
|
|
@@ -163,6 +168,8 @@ function hasKeys(value, keys) {
|
|
|
163
168
|
function isEngineRequest(value) {
|
|
164
169
|
if (!isRecord(value) || !Number.isSafeInteger(value.id) || typeof value.type !== "string") return false;
|
|
165
170
|
switch (value.type) {
|
|
171
|
+
case "initialize":
|
|
172
|
+
return hasKeys(value, ["id", "type", "settings"]) && typeof value.settings === "string";
|
|
166
173
|
case "connect":
|
|
167
174
|
case "listDatabases":
|
|
168
175
|
return hasKeys(value, ["id", "type"]);
|
package/dist/protocol.d.ts
CHANGED
package/dist/raw.browser.js
CHANGED
|
@@ -64,6 +64,9 @@ var HyperDBEngineClient = class {
|
|
|
64
64
|
ready() {
|
|
65
65
|
return this.readyPromise;
|
|
66
66
|
}
|
|
67
|
+
initialize(settings) {
|
|
68
|
+
return this.request({ id: this.nextId++, type: "initialize", settings });
|
|
69
|
+
}
|
|
67
70
|
connect() {
|
|
68
71
|
return this.request({ id: this.nextId++, type: "connect" });
|
|
69
72
|
}
|
|
@@ -171,6 +174,7 @@ function validateCString(value, name) {
|
|
|
171
174
|
}
|
|
172
175
|
var HyperDBBindings = class {
|
|
173
176
|
module;
|
|
177
|
+
initialize;
|
|
174
178
|
connect;
|
|
175
179
|
disconnect;
|
|
176
180
|
createDatabase;
|
|
@@ -192,6 +196,7 @@ var HyperDBBindings = class {
|
|
|
192
196
|
nextTemporaryFile = 1;
|
|
193
197
|
constructor(module) {
|
|
194
198
|
this.module = module;
|
|
199
|
+
this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
|
|
195
200
|
this.connect = module.cwrap("hyperdb_wasm_connect", "pointer", []);
|
|
196
201
|
this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
197
202
|
this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
@@ -229,6 +234,9 @@ var HyperDBBindings = class {
|
|
|
229
234
|
}
|
|
230
235
|
invoke(request) {
|
|
231
236
|
switch (request.type) {
|
|
237
|
+
case "initialize":
|
|
238
|
+
validateCString(request.settings, "settings");
|
|
239
|
+
return this.initialize(request.settings);
|
|
232
240
|
case "connect":
|
|
233
241
|
return this.connect();
|
|
234
242
|
case "disconnect":
|
package/dist/raw.node.js
CHANGED
|
@@ -64,6 +64,9 @@ var HyperDBEngineClient = class {
|
|
|
64
64
|
ready() {
|
|
65
65
|
return this.readyPromise;
|
|
66
66
|
}
|
|
67
|
+
initialize(settings) {
|
|
68
|
+
return this.request({ id: this.nextId++, type: "initialize", settings });
|
|
69
|
+
}
|
|
67
70
|
connect() {
|
|
68
71
|
return this.request({ id: this.nextId++, type: "connect" });
|
|
69
72
|
}
|
|
@@ -171,6 +174,7 @@ function validateCString(value, name) {
|
|
|
171
174
|
}
|
|
172
175
|
var HyperDBBindings = class {
|
|
173
176
|
module;
|
|
177
|
+
initialize;
|
|
174
178
|
connect;
|
|
175
179
|
disconnect;
|
|
176
180
|
createDatabase;
|
|
@@ -192,6 +196,7 @@ var HyperDBBindings = class {
|
|
|
192
196
|
nextTemporaryFile = 1;
|
|
193
197
|
constructor(module) {
|
|
194
198
|
this.module = module;
|
|
199
|
+
this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
|
|
195
200
|
this.connect = module.cwrap("hyperdb_wasm_connect", "pointer", []);
|
|
196
201
|
this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
197
202
|
this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
@@ -229,6 +234,9 @@ var HyperDBBindings = class {
|
|
|
229
234
|
}
|
|
230
235
|
invoke(request) {
|
|
231
236
|
switch (request.type) {
|
|
237
|
+
case "initialize":
|
|
238
|
+
validateCString(request.settings, "settings");
|
|
239
|
+
return this.initialize(request.settings);
|
|
232
240
|
case "connect":
|
|
233
241
|
return this.connect();
|
|
234
242
|
case "disconnect":
|
package/dist/wasm_bindings.d.ts
CHANGED