picovolt 0.5.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # PicoVolt (PVDB)
2
2
 
3
3
  [![CI](https://github.com/MiniJe/picovolt/actions/workflows/ci.yml/badge.svg)](https://github.com/MiniJe/picovolt/actions/workflows/ci.yml)
4
- [![Version](https://img.shields.io/badge/version-0.5.0-blue.svg)](CHANGELOG.md)
4
+ [![Version](https://img.shields.io/badge/version-0.7.0-blue.svg)](CHANGELOG.md)
5
5
  [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
6
6
  ![Status: experimental](https://img.shields.io/badge/status-experimental-orange.svg)
7
7
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "picovolt",
3
3
  "type": "module",
4
4
  "description": "PicoVolt (PVDB): a polymorphic embedded database engine in Rust.",
5
- "version": "0.5.0",
5
+ "version": "0.7.0",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
package/picovolt.d.ts CHANGED
@@ -26,10 +26,11 @@ export class Db {
26
26
  */
27
27
  constructor();
28
28
  /**
29
- * Run one SQL statement. Returns a **JSON string** (call `JSON.parse` in JS):
30
- * `{"columns":[...],"rows":[[...]]}` for `SELECT`, `{"mutated":n}` for
31
- * `INSERT`/`UPDATE`/`DELETE`, or `{"done":true}` otherwise. Throws the error
32
- * message (a string) on failure.
29
+ * Run one SQL statement, optionally binding `?` placeholders to `params` (a
30
+ * JS array, e.g. `db.query("SELECT * FROM t WHERE id = ?", [1])`). Returns a
31
+ * **JSON string** (call `JSON.parse` in JS): `{"columns":[...],"rows":[[...]]}`
32
+ * for `SELECT`, `{"mutated":n}` for `INSERT`/`UPDATE`/`DELETE`, or
33
+ * `{"done":true}` otherwise. Throws the error message (a string) on failure.
33
34
  */
34
- query(sql: string): string;
35
+ query(sql: string, params: any): string;
35
36
  }
package/picovolt_bg.js CHANGED
@@ -65,20 +65,22 @@ export class Db {
65
65
  return this;
66
66
  }
67
67
  /**
68
- * Run one SQL statement. Returns a **JSON string** (call `JSON.parse` in JS):
69
- * `{"columns":[...],"rows":[[...]]}` for `SELECT`, `{"mutated":n}` for
70
- * `INSERT`/`UPDATE`/`DELETE`, or `{"done":true}` otherwise. Throws the error
71
- * message (a string) on failure.
68
+ * Run one SQL statement, optionally binding `?` placeholders to `params` (a
69
+ * JS array, e.g. `db.query("SELECT * FROM t WHERE id = ?", [1])`). Returns a
70
+ * **JSON string** (call `JSON.parse` in JS): `{"columns":[...],"rows":[[...]]}`
71
+ * for `SELECT`, `{"mutated":n}` for `INSERT`/`UPDATE`/`DELETE`, or
72
+ * `{"done":true}` otherwise. Throws the error message (a string) on failure.
72
73
  * @param {string} sql
74
+ * @param {any} params
73
75
  * @returns {string}
74
76
  */
75
- query(sql) {
77
+ query(sql, params) {
76
78
  let deferred3_0;
77
79
  let deferred3_1;
78
80
  try {
79
81
  const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
82
  const len0 = WASM_VECTOR_LEN;
81
- const ret = wasm.db_query(this.__wbg_ptr, ptr0, len0);
83
+ const ret = wasm.db_query(this.__wbg_ptr, ptr0, len0, params);
82
84
  var ptr2 = ret[0];
83
85
  var len2 = ret[1];
84
86
  if (ret[3]) {
@@ -94,6 +96,33 @@ export class Db {
94
96
  }
95
97
  }
96
98
  if (Symbol.dispose) Db.prototype[Symbol.dispose] = Db.prototype.free;
99
+ export function __wbg___wbindgen_boolean_get_edaed31a367ce1bd(arg0) {
100
+ const v = arg0;
101
+ const ret = typeof(v) === 'boolean' ? v : undefined;
102
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
103
+ }
104
+ export function __wbg___wbindgen_is_null_6d937fbfb6478470(arg0) {
105
+ const ret = arg0 === null;
106
+ return ret;
107
+ }
108
+ export function __wbg___wbindgen_is_undefined_721f8decd50c87a3(arg0) {
109
+ const ret = arg0 === undefined;
110
+ return ret;
111
+ }
112
+ export function __wbg___wbindgen_number_get_1cc01dd708740256(arg0, arg1) {
113
+ const obj = arg1;
114
+ const ret = typeof(obj) === 'number' ? obj : undefined;
115
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
116
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
117
+ }
118
+ export function __wbg___wbindgen_string_get_71bb4348194e31f0(arg0, arg1) {
119
+ const obj = arg1;
120
+ const ret = typeof(obj) === 'string' ? obj : undefined;
121
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
+ var len1 = WASM_VECTOR_LEN;
123
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
124
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
125
+ }
97
126
  export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
98
127
  throw new Error(getStringFromWasm0(arg0, arg1));
99
128
  }
@@ -108,6 +137,18 @@ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
108
137
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
109
138
  }
110
139
  }
140
+ export function __wbg_from_50138b2ca136f50c(arg0) {
141
+ const ret = Array.from(arg0);
142
+ return ret;
143
+ }
144
+ export function __wbg_get_unchecked_54a4374c38e08460(arg0, arg1) {
145
+ const ret = arg0[arg1 >>> 0];
146
+ return ret;
147
+ }
148
+ export function __wbg_length_c6054974c0a6cdb9(arg0) {
149
+ const ret = arg0.length;
150
+ return ret;
151
+ }
111
152
  export function __wbg_new_227d7c05414eb861() {
112
153
  const ret = new Error();
113
154
  return ret;
@@ -162,6 +203,10 @@ function getUint8ArrayMemory0() {
162
203
  return cachedUint8ArrayMemory0;
163
204
  }
164
205
 
206
+ function isLikeNone(x) {
207
+ return x === undefined || x === null;
208
+ }
209
+
165
210
  function passArray8ToWasm0(arg, malloc) {
166
211
  const ptr = malloc(arg.length * 1, 1) >>> 0;
167
212
  getUint8ArrayMemory0().set(arg, ptr / 1);
package/picovolt_bg.wasm CHANGED
Binary file