@dreamlake/dreamdb 0.3.0 → 0.3.1

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/dreamdb.d.ts CHANGED
@@ -67,6 +67,24 @@ export class Space {
67
67
  * scalar gate.)
68
68
  */
69
69
  queryHybrid(vector: Float32Array, opts: any): Promise<Array<any>>;
70
+ /**
71
+ * Scalar-index lookup: every anchor whose `field` satisfies `op value`
72
+ * (spec/0011). Returns a `BigUint64Array`-style `Array` of anchors,
73
+ * tombstone-suppressed, sorted ascending and deduped.
74
+ *
75
+ * This is the expansion half of a compact lexical index. A BM25 index
76
+ * built over a scalar field's DISTINCT values returns one representative
77
+ * anchor per matched value; resolving that value back to *every* record
78
+ * carrying it is a scalar-index lookup, not a text-index concern. Keeping
79
+ * the split this way is what lets the text index stay small enough to
80
+ * load in a browser — indexing one document per record instead produced a
81
+ * 406 MB object for ~1,700 distinct strings.
82
+ *
83
+ * `op` is one of `==`, `!=`, `<`, `<=`, `>`, `>=`. `value` may be a
84
+ * string, number, or boolean; strings match both `String` and
85
+ * `Categorical` scalar fields.
86
+ */
87
+ queryScalar(field: string, op: string, value: any): Promise<Array<any>>;
70
88
  /**
71
89
  * Lexical BM25 text search over a text `field` (spec/0015 §3.6).
72
90
  *
@@ -124,6 +142,22 @@ export class Space {
124
142
  readonly manifestHash: string;
125
143
  }
126
144
 
145
+ /**
146
+ * Install a panic hook that logs the panic message AND its `file:line:col`
147
+ * to the console before the wasm trap surfaces to JS.
148
+ *
149
+ * Without this, every Rust panic reaches JavaScript as a bare
150
+ * `RuntimeError: unreachable` with nothing but wasm frame offsets — and it is
151
+ * indistinguishable from an allocation failure, since Rust's alloc-error
152
+ * handler also aborts. That ambiguity cost real debugging time: a browser
153
+ * `unreachable` from exhausting wasm32's 32-bit address space on an oversized
154
+ * index was initially read as an integer-overflow panic.
155
+ *
156
+ * Zero new deps — uses the already-enabled `web-sys` `console` feature.
157
+ * Runs once at module init.
158
+ */
159
+ export function __wasm_init(): void;
160
+
127
161
  /**
128
162
  * Encode arbitrary bytes as lowercase RFC-4648 base32 (no padding).
129
163
  *
package/dreamdb.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./dreamdb_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- S3Backend, Space, bytesToBase32, decodeCbor, version, zeroSpatialKey
8
+ S3Backend, Space, __wasm_init, bytesToBase32, decodeCbor, version, zeroSpatialKey
9
9
  } from "./dreamdb_bg.js";
package/dreamdb_bg.js CHANGED
@@ -163,6 +163,35 @@ export class Space {
163
163
  const ret = wasm.space_queryHybrid(this.__wbg_ptr, ptr0, len0, opts);
164
164
  return ret;
165
165
  }
166
+ /**
167
+ * Scalar-index lookup: every anchor whose `field` satisfies `op value`
168
+ * (spec/0011). Returns a `BigUint64Array`-style `Array` of anchors,
169
+ * tombstone-suppressed, sorted ascending and deduped.
170
+ *
171
+ * This is the expansion half of a compact lexical index. A BM25 index
172
+ * built over a scalar field's DISTINCT values returns one representative
173
+ * anchor per matched value; resolving that value back to *every* record
174
+ * carrying it is a scalar-index lookup, not a text-index concern. Keeping
175
+ * the split this way is what lets the text index stay small enough to
176
+ * load in a browser — indexing one document per record instead produced a
177
+ * 406 MB object for ~1,700 distinct strings.
178
+ *
179
+ * `op` is one of `==`, `!=`, `<`, `<=`, `>`, `>=`. `value` may be a
180
+ * string, number, or boolean; strings match both `String` and
181
+ * `Categorical` scalar fields.
182
+ * @param {string} field
183
+ * @param {string} op
184
+ * @param {any} value
185
+ * @returns {Promise<Array<any>>}
186
+ */
187
+ queryScalar(field, op, value) {
188
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
+ const len0 = WASM_VECTOR_LEN;
190
+ const ptr1 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ const len1 = WASM_VECTOR_LEN;
192
+ const ret = wasm.space_queryScalar(this.__wbg_ptr, ptr0, len0, ptr1, len1, value);
193
+ return ret;
194
+ }
166
195
  /**
167
196
  * Lexical BM25 text search over a text `field` (spec/0015 §3.6).
168
197
  *
@@ -274,6 +303,24 @@ export class Space {
274
303
  }
275
304
  if (Symbol.dispose) Space.prototype[Symbol.dispose] = Space.prototype.free;
276
305
 
306
+ /**
307
+ * Install a panic hook that logs the panic message AND its `file:line:col`
308
+ * to the console before the wasm trap surfaces to JS.
309
+ *
310
+ * Without this, every Rust panic reaches JavaScript as a bare
311
+ * `RuntimeError: unreachable` with nothing but wasm frame offsets — and it is
312
+ * indistinguishable from an allocation failure, since Rust's alloc-error
313
+ * handler also aborts. That ambiguity cost real debugging time: a browser
314
+ * `unreachable` from exhausting wasm32's 32-bit address space on an oversized
315
+ * index was initially read as an integer-overflow panic.
316
+ *
317
+ * Zero new deps — uses the already-enabled `web-sys` `console` feature.
318
+ * Runs once at module init.
319
+ */
320
+ export function __wasm_init() {
321
+ wasm.__wasm_init();
322
+ }
323
+
277
324
  /**
278
325
  * Encode arbitrary bytes as lowercase RFC-4648 base32 (no padding).
279
326
  *
@@ -403,6 +450,9 @@ export function __wbg_call_dfde26266607c996() { return handleError(function (arg
403
450
  const ret = arg0.call(arg1, arg2);
404
451
  return ret;
405
452
  }, arguments); }
453
+ export function __wbg_error_f085d7e62279b703(arg0) {
454
+ console.error(arg0);
455
+ }
406
456
  export function __wbg_get_dcf82ab8aad1a593() { return handleError(function (arg0, arg1) {
407
457
  const ret = Reflect.get(arg0, arg1);
408
458
  return ret;
@@ -411,6 +461,10 @@ export function __wbg_get_unchecked_1dfe6d05ad91d9b7(arg0, arg1) {
411
461
  const ret = arg0[arg1 >>> 0];
412
462
  return ret;
413
463
  }
464
+ export function __wbg_headers_4cfb0c75793d7a8d(arg0) {
465
+ const ret = arg0.headers;
466
+ return ret;
467
+ }
414
468
  export function __wbg_instanceof_Promise_09012cfa9708520a(arg0) {
415
469
  let result;
416
470
  try {
@@ -521,6 +575,9 @@ export function __wbg_set_a0e911be3da02782() { return handleError(function (arg0
521
575
  const ret = Reflect.set(arg0, arg1, arg2);
522
576
  return ret;
523
577
  }, arguments); }
578
+ export function __wbg_set_d57e5106f0271787() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
579
+ arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
580
+ }, arguments); }
524
581
  export function __wbg_set_facb7a5914e0fa39(arg0, arg1, arg2) {
525
582
  const ret = arg0.set(arg1, arg2);
526
583
  return ret;
@@ -558,7 +615,7 @@ export function __wbg_then_bd927500e8905df2(arg0, arg1, arg2) {
558
615
  return ret;
559
616
  }
560
617
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
561
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 380, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
618
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 392, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
562
619
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_);
563
620
  return ret;
564
621
  }
package/dreamdb_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dreamlake/dreamdb",
3
3
  "type": "module",
4
4
  "description": "WebAssembly binding of dreamdb-dataset — the browser DreamDB SDK (@dreamlake/dreamdb)",
5
- "version": "0.3.0",
5
+ "version": "0.3.1",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "files": [
8
8
  "dreamdb_bg.wasm",