@nuschtos/fixx 0.0.3 → 0.0.5

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/fixx.d.ts CHANGED
@@ -8,16 +8,20 @@ export class Index {
8
8
  */
9
9
  static read(buf: Uint8Array): Index;
10
10
  /**
11
- * @param {string} query
12
- * @param {number} max_results
13
- * @returns {(SearchedOption)[]}
11
+ * @returns {number}
14
12
  */
15
- search(query: string, max_results: number): (SearchedOption)[];
13
+ chunk_size(): number;
16
14
  /**
17
- * @param {number} max
18
15
  * @returns {(string)[]}
19
16
  */
20
- all(max: number): (string)[];
17
+ scopes(): (string)[];
18
+ /**
19
+ * @param {number | undefined} scope_id
20
+ * @param {string} query
21
+ * @param {number} max_results
22
+ * @returns {(SearchedOption)[]}
23
+ */
24
+ search(scope_id: number | undefined, query: string, max_results: number): (SearchedOption)[];
21
25
  /**
22
26
  * @param {string} name
23
27
  * @returns {number | undefined}
@@ -43,15 +47,16 @@ export interface InitOutput {
43
47
  readonly __wbg_index_free: (a: number, b: number) => void;
44
48
  readonly __wbg_searchedoption_free: (a: number, b: number) => void;
45
49
  readonly index_read: (a: number, b: number, c: number) => void;
46
- readonly index_search: (a: number, b: number, c: number, d: number, e: number) => void;
47
- readonly index_all: (a: number, b: number, c: number) => void;
50
+ readonly index_chunk_size: (a: number) => number;
51
+ readonly index_scopes: (a: number, b: number) => void;
52
+ readonly index_search: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
48
53
  readonly index_get_idx_by_name: (a: number, b: number, c: number, d: number) => void;
49
- readonly searchedoption_idx: (a: number) => number;
50
54
  readonly searchedoption_name: (a: number, b: number) => void;
55
+ readonly searchedoption_idx: (a: number) => number;
51
56
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
52
57
  readonly __wbindgen_export_0: (a: number, b: number) => number;
53
- readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
54
- readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
58
+ readonly __wbindgen_export_1: (a: number, b: number, c: number) => void;
59
+ readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
55
60
  }
56
61
 
57
62
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/fixx.js CHANGED
@@ -65,6 +65,20 @@ function takeObject(idx) {
65
65
  return ret;
66
66
  }
67
67
 
68
+ function getArrayJsValueFromWasm0(ptr, len) {
69
+ ptr = ptr >>> 0;
70
+ const mem = getDataViewMemory0();
71
+ const result = [];
72
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
73
+ result.push(takeObject(mem.getUint32(i, true)));
74
+ }
75
+ return result;
76
+ }
77
+
78
+ function isLikeNone(x) {
79
+ return x === undefined || x === null;
80
+ }
81
+
68
82
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
69
83
 
70
84
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -119,16 +133,6 @@ function passStringToWasm0(arg, malloc, realloc) {
119
133
  return ptr;
120
134
  }
121
135
 
122
- function getArrayJsValueFromWasm0(ptr, len) {
123
- ptr = ptr >>> 0;
124
- const mem = getDataViewMemory0();
125
- const result = [];
126
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
127
- result.push(takeObject(mem.getUint32(i, true)));
128
- }
129
- return result;
130
- }
131
-
132
136
  const IndexFinalization = (typeof FinalizationRegistry === 'undefined')
133
137
  ? { register: () => {}, unregister: () => {} }
134
138
  : new FinalizationRegistry(ptr => wasm.__wbg_index_free(ptr >>> 0, 1));
@@ -176,16 +180,19 @@ export class Index {
176
180
  }
177
181
  }
178
182
  /**
179
- * @param {string} query
180
- * @param {number} max_results
181
- * @returns {(SearchedOption)[]}
183
+ * @returns {number}
182
184
  */
183
- search(query, max_results) {
185
+ chunk_size() {
186
+ const ret = wasm.index_chunk_size(this.__wbg_ptr);
187
+ return ret >>> 0;
188
+ }
189
+ /**
190
+ * @returns {(string)[]}
191
+ */
192
+ scopes() {
184
193
  try {
185
194
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
186
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
187
- const len0 = WASM_VECTOR_LEN;
188
- wasm.index_search(retptr, this.__wbg_ptr, ptr0, len0, max_results);
195
+ wasm.index_scopes(retptr, this.__wbg_ptr);
189
196
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
190
197
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
191
198
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -193,21 +200,25 @@ export class Index {
193
200
  if (r3) {
194
201
  throw takeObject(r2);
195
202
  }
196
- var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
197
- wasm.__wbindgen_export_2(r0, r1 * 4, 4);
198
- return v2;
203
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
204
+ wasm.__wbindgen_export_1(r0, r1 * 4, 4);
205
+ return v1;
199
206
  } finally {
200
207
  wasm.__wbindgen_add_to_stack_pointer(16);
201
208
  }
202
209
  }
203
210
  /**
204
- * @param {number} max
205
- * @returns {(string)[]}
211
+ * @param {number | undefined} scope_id
212
+ * @param {string} query
213
+ * @param {number} max_results
214
+ * @returns {(SearchedOption)[]}
206
215
  */
207
- all(max) {
216
+ search(scope_id, query, max_results) {
208
217
  try {
209
218
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
210
- wasm.index_all(retptr, this.__wbg_ptr, max);
219
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ wasm.index_search(retptr, this.__wbg_ptr, isLikeNone(scope_id) ? 0xFFFFFF : scope_id, ptr0, len0, max_results);
211
222
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
212
223
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
213
224
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -215,9 +226,9 @@ export class Index {
215
226
  if (r3) {
216
227
  throw takeObject(r2);
217
228
  }
218
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
219
- wasm.__wbindgen_export_2(r0, r1 * 4, 4);
220
- return v1;
229
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
230
+ wasm.__wbindgen_export_1(r0, r1 * 4, 4);
231
+ return v2;
221
232
  } finally {
222
233
  wasm.__wbindgen_add_to_stack_pointer(16);
223
234
  }
@@ -229,7 +240,7 @@ export class Index {
229
240
  get_idx_by_name(name) {
230
241
  try {
231
242
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
232
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
243
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
233
244
  const len0 = WASM_VECTOR_LEN;
234
245
  wasm.index_get_idx_by_name(retptr, this.__wbg_ptr, ptr0, len0);
235
246
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -275,7 +286,7 @@ export class SearchedOption {
275
286
  * @returns {number}
276
287
  */
277
288
  idx() {
278
- const ret = wasm.searchedoption_idx(this.__wbg_ptr);
289
+ const ret = wasm.index_chunk_size(this.__wbg_ptr);
279
290
  return ret >>> 0;
280
291
  }
281
292
  /**
@@ -295,7 +306,7 @@ export class SearchedOption {
295
306
  return getStringFromWasm0(r0, r1);
296
307
  } finally {
297
308
  wasm.__wbindgen_add_to_stack_pointer(16);
298
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
309
+ wasm.__wbindgen_export_1(deferred1_0, deferred1_1, 1);
299
310
  }
300
311
  }
301
312
  }
package/fixx_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuschtos/fixx",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",