picovolt 1.0.0 → 1.1.0
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/README.md +1 -1
- package/package.json +1 -1
- package/picovolt.d.ts +12 -0
- package/picovolt_bg.js +153 -1
- package/picovolt_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# PicoVolt (PVDB)
|
|
2
2
|
|
|
3
3
|
[](https://github.com/MiniJe/picovolt/actions/workflows/ci.yml)
|
|
4
|
-
[](CHANGELOG.md)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|

|
|
7
7
|
[](https://github.com/MiniJe/picovolt)
|
package/package.json
CHANGED
package/picovolt.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export class Db {
|
|
|
25
25
|
* Create a new, empty in-memory database.
|
|
26
26
|
*/
|
|
27
27
|
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Open a baked `.pvdb` served over HTTP **without downloading it whole**:
|
|
30
|
+
* `read(offset, len)` must synchronously return a `Uint8Array` of that byte
|
|
31
|
+
* range (e.g. a synchronous range request). Pages are then fetched on demand
|
|
32
|
+
* as queries touch them. `totalSize` is the image's byte length.
|
|
33
|
+
*/
|
|
34
|
+
static openRemote(read: Function, total_size: number): Db;
|
|
28
35
|
/**
|
|
29
36
|
* Run one SQL statement, optionally binding `?` placeholders to `params` (a
|
|
30
37
|
* JS array, e.g. `db.query("SELECT * FROM t WHERE id = ?", [1])`). Returns a
|
|
@@ -33,4 +40,9 @@ export class Db {
|
|
|
33
40
|
* `{"done":true}` otherwise. Throws the error message (a string) on failure.
|
|
34
41
|
*/
|
|
35
42
|
query(sql: string, params: any): string;
|
|
43
|
+
/**
|
|
44
|
+
* A JSON array of the table names in this database (for introspecting an
|
|
45
|
+
* uploaded `.pvdb` whose schema is unknown).
|
|
46
|
+
*/
|
|
47
|
+
tables(): string;
|
|
36
48
|
}
|
package/picovolt_bg.js
CHANGED
|
@@ -64,6 +64,22 @@ export class Db {
|
|
|
64
64
|
DbFinalization.register(this, this.__wbg_ptr, this);
|
|
65
65
|
return this;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Open a baked `.pvdb` served over HTTP **without downloading it whole**:
|
|
69
|
+
* `read(offset, len)` must synchronously return a `Uint8Array` of that byte
|
|
70
|
+
* range (e.g. a synchronous range request). Pages are then fetched on demand
|
|
71
|
+
* as queries touch them. `totalSize` is the image's byte length.
|
|
72
|
+
* @param {Function} read
|
|
73
|
+
* @param {number} total_size
|
|
74
|
+
* @returns {Db}
|
|
75
|
+
*/
|
|
76
|
+
static openRemote(read, total_size) {
|
|
77
|
+
const ret = wasm.db_openRemote(read, total_size);
|
|
78
|
+
if (ret[2]) {
|
|
79
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
80
|
+
}
|
|
81
|
+
return Db.__wrap(ret[0]);
|
|
82
|
+
}
|
|
67
83
|
/**
|
|
68
84
|
* Run one SQL statement, optionally binding `?` placeholders to `params` (a
|
|
69
85
|
* JS array, e.g. `db.query("SELECT * FROM t WHERE id = ?", [1])`). Returns a
|
|
@@ -94,6 +110,29 @@ export class Db {
|
|
|
94
110
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
95
111
|
}
|
|
96
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* A JSON array of the table names in this database (for introspecting an
|
|
115
|
+
* uploaded `.pvdb` whose schema is unknown).
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
tables() {
|
|
119
|
+
let deferred2_0;
|
|
120
|
+
let deferred2_1;
|
|
121
|
+
try {
|
|
122
|
+
const ret = wasm.db_tables(this.__wbg_ptr);
|
|
123
|
+
var ptr1 = ret[0];
|
|
124
|
+
var len1 = ret[1];
|
|
125
|
+
if (ret[3]) {
|
|
126
|
+
ptr1 = 0; len1 = 0;
|
|
127
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
128
|
+
}
|
|
129
|
+
deferred2_0 = ptr1;
|
|
130
|
+
deferred2_1 = len1;
|
|
131
|
+
return getStringFromWasm0(ptr1, len1);
|
|
132
|
+
} finally {
|
|
133
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
97
136
|
}
|
|
98
137
|
if (Symbol.dispose) Db.prototype[Symbol.dispose] = Db.prototype.free;
|
|
99
138
|
export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(arg0) {
|
|
@@ -101,6 +140,13 @@ export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(arg0) {
|
|
|
101
140
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
102
141
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
103
142
|
}
|
|
143
|
+
export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
|
|
144
|
+
const ret = debugString(arg1);
|
|
145
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
148
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
149
|
+
}
|
|
104
150
|
export function __wbg___wbindgen_is_null_ea9085d691f535d3(arg0) {
|
|
105
151
|
const ret = arg0 === null;
|
|
106
152
|
return ret;
|
|
@@ -126,6 +172,10 @@ export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
|
|
|
126
172
|
export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
|
|
127
173
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
128
174
|
}
|
|
175
|
+
export function __wbg_call_e3b662382210db98() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
176
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
177
|
+
return ret;
|
|
178
|
+
}, arguments); }
|
|
129
179
|
export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
|
|
130
180
|
let deferred0_0;
|
|
131
181
|
let deferred0_1;
|
|
@@ -145,6 +195,20 @@ export function __wbg_get_unchecked_6e0ad6d2a41b06f6(arg0, arg1) {
|
|
|
145
195
|
const ret = arg0[arg1 >>> 0];
|
|
146
196
|
return ret;
|
|
147
197
|
}
|
|
198
|
+
export function __wbg_instanceof_Uint8Array_309b927aaf7a3fc7(arg0) {
|
|
199
|
+
let result;
|
|
200
|
+
try {
|
|
201
|
+
result = arg0 instanceof Uint8Array;
|
|
202
|
+
} catch (_) {
|
|
203
|
+
result = false;
|
|
204
|
+
}
|
|
205
|
+
const ret = result;
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
|
|
209
|
+
const ret = arg0.length;
|
|
210
|
+
return ret;
|
|
211
|
+
}
|
|
148
212
|
export function __wbg_length_370319915dc99107(arg0) {
|
|
149
213
|
const ret = arg0.length;
|
|
150
214
|
return ret;
|
|
@@ -153,6 +217,9 @@ export function __wbg_new_227d7c05414eb861() {
|
|
|
153
217
|
const ret = new Error();
|
|
154
218
|
return ret;
|
|
155
219
|
}
|
|
220
|
+
export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
|
|
221
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
222
|
+
}
|
|
156
223
|
export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
157
224
|
const ret = arg1.stack;
|
|
158
225
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -160,7 +227,12 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
|
160
227
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
161
228
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
162
229
|
}
|
|
163
|
-
export function __wbindgen_cast_0000000000000001(arg0
|
|
230
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
231
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
232
|
+
const ret = arg0;
|
|
233
|
+
return ret;
|
|
234
|
+
}
|
|
235
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
164
236
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
165
237
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
166
238
|
return ret;
|
|
@@ -178,6 +250,77 @@ const DbFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
178
250
|
? { register: () => {}, unregister: () => {} }
|
|
179
251
|
: new FinalizationRegistry(ptr => wasm.__wbg_db_free(ptr, 1));
|
|
180
252
|
|
|
253
|
+
function addToExternrefTable0(obj) {
|
|
254
|
+
const idx = wasm.__externref_table_alloc();
|
|
255
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
256
|
+
return idx;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function debugString(val) {
|
|
260
|
+
// primitive types
|
|
261
|
+
const type = typeof val;
|
|
262
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
263
|
+
return `${val}`;
|
|
264
|
+
}
|
|
265
|
+
if (type == 'string') {
|
|
266
|
+
return `"${val}"`;
|
|
267
|
+
}
|
|
268
|
+
if (type == 'symbol') {
|
|
269
|
+
const description = val.description;
|
|
270
|
+
if (description == null) {
|
|
271
|
+
return 'Symbol';
|
|
272
|
+
} else {
|
|
273
|
+
return `Symbol(${description})`;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (type == 'function') {
|
|
277
|
+
const name = val.name;
|
|
278
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
279
|
+
return `Function(${name})`;
|
|
280
|
+
} else {
|
|
281
|
+
return 'Function';
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// objects
|
|
285
|
+
if (Array.isArray(val)) {
|
|
286
|
+
const length = val.length;
|
|
287
|
+
let debug = '[';
|
|
288
|
+
if (length > 0) {
|
|
289
|
+
debug += debugString(val[0]);
|
|
290
|
+
}
|
|
291
|
+
for(let i = 1; i < length; i++) {
|
|
292
|
+
debug += ', ' + debugString(val[i]);
|
|
293
|
+
}
|
|
294
|
+
debug += ']';
|
|
295
|
+
return debug;
|
|
296
|
+
}
|
|
297
|
+
// Test for built-in
|
|
298
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
299
|
+
let className;
|
|
300
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
301
|
+
className = builtInMatches[1];
|
|
302
|
+
} else {
|
|
303
|
+
// Failed to match the standard '[object ClassName]'
|
|
304
|
+
return toString.call(val);
|
|
305
|
+
}
|
|
306
|
+
if (className == 'Object') {
|
|
307
|
+
// we're a user defined class or Object
|
|
308
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
309
|
+
// easier than looping through ownProperties of `val`.
|
|
310
|
+
try {
|
|
311
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
312
|
+
} catch (_) {
|
|
313
|
+
return 'Object';
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// errors
|
|
317
|
+
if (val instanceof Error) {
|
|
318
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
319
|
+
}
|
|
320
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
321
|
+
return className;
|
|
322
|
+
}
|
|
323
|
+
|
|
181
324
|
function getArrayU8FromWasm0(ptr, len) {
|
|
182
325
|
ptr = ptr >>> 0;
|
|
183
326
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -203,6 +346,15 @@ function getUint8ArrayMemory0() {
|
|
|
203
346
|
return cachedUint8ArrayMemory0;
|
|
204
347
|
}
|
|
205
348
|
|
|
349
|
+
function handleError(f, args) {
|
|
350
|
+
try {
|
|
351
|
+
return f.apply(this, args);
|
|
352
|
+
} catch (e) {
|
|
353
|
+
const idx = addToExternrefTable0(e);
|
|
354
|
+
wasm.__wbindgen_exn_store(idx);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
206
358
|
function isLikeNone(x) {
|
|
207
359
|
return x === undefined || x === null;
|
|
208
360
|
}
|
package/picovolt_bg.wasm
CHANGED
|
Binary file
|