@nuschtos/fixx 0.0.5 → 0.0.7

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,12 +1,20 @@
1
1
  # ixx
2
2
 
3
+ ixx is the search engine and index creation tool used by [NüschtOS Search](https://github.com/NuschtOS/search).
4
+
3
5
  ## Building fixx
4
6
 
5
7
  ```
6
8
  wasm-pack build --release fixx --target web
7
9
  ```
8
10
 
9
- The result will be in fixx/pkg
11
+ The result will be in `fixx/pkg`.
12
+
13
+ ## Contact
14
+
15
+ For bugs and issues please open an issue in this repository.
16
+
17
+ If you want to chat about things or have ideas, feel free to join the [Matrix Chat](https://matrix.to/#/#nuschtos:c3d2.de).
10
18
 
11
19
  ## License
12
20
 
package/fixx.d.ts CHANGED
@@ -1,42 +1,19 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export class Index {
4
+ private constructor();
4
5
  free(): void;
5
- /**
6
- * @param {Uint8Array} buf
7
- * @returns {Index}
8
- */
9
6
  static read(buf: Uint8Array): Index;
10
- /**
11
- * @returns {number}
12
- */
13
7
  chunk_size(): number;
14
- /**
15
- * @returns {(string)[]}
16
- */
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)[];
25
- /**
26
- * @param {string} name
27
- * @returns {number | undefined}
28
- */
29
- get_idx_by_name(name: string): number | undefined;
8
+ scopes(): string[];
9
+ search(scope_id: number | null | undefined, query: string, max_results: number): SearchedOption[];
10
+ get_idx_by_name(scope_id: number, name: string): number | undefined;
30
11
  }
31
12
  export class SearchedOption {
13
+ private constructor();
32
14
  free(): void;
33
- /**
34
- * @returns {number}
35
- */
36
15
  idx(): number;
37
- /**
38
- * @returns {string}
39
- */
16
+ scope_id(): number;
40
17
  name(): string;
41
18
  }
42
19
 
@@ -50,7 +27,8 @@ export interface InitOutput {
50
27
  readonly index_chunk_size: (a: number) => number;
51
28
  readonly index_scopes: (a: number, b: number) => void;
52
29
  readonly index_search: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
53
- readonly index_get_idx_by_name: (a: number, b: number, c: number, d: number) => void;
30
+ readonly index_get_idx_by_name: (a: number, b: number, c: number, d: number, e: number) => void;
31
+ readonly searchedoption_scope_id: (a: number) => number;
54
32
  readonly searchedoption_name: (a: number, b: number) => void;
55
33
  readonly searchedoption_idx: (a: number) => number;
56
34
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
package/fixx.js CHANGED
@@ -1,5 +1,20 @@
1
1
  let wasm;
2
2
 
3
+ const heap = new Array(128).fill(undefined);
4
+
5
+ heap.push(undefined, null, true, false);
6
+
7
+ let heap_next = heap.length;
8
+
9
+ function addHeapObject(obj) {
10
+ if (heap_next === heap.length) heap.push(heap.length + 1);
11
+ const idx = heap_next;
12
+ heap_next = heap[idx];
13
+
14
+ heap[idx] = obj;
15
+ return idx;
16
+ }
17
+
3
18
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
4
19
 
5
20
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
@@ -18,21 +33,6 @@ function getStringFromWasm0(ptr, len) {
18
33
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
19
34
  }
20
35
 
21
- const heap = new Array(128).fill(undefined);
22
-
23
- heap.push(undefined, null, true, false);
24
-
25
- let heap_next = heap.length;
26
-
27
- function addHeapObject(obj) {
28
- if (heap_next === heap.length) heap.push(heap.length + 1);
29
- const idx = heap_next;
30
- heap_next = heap[idx];
31
-
32
- heap[idx] = obj;
33
- return idx;
34
- }
35
-
36
36
  let WASM_VECTOR_LEN = 0;
37
37
 
38
38
  function passArray8ToWasm0(arg, malloc) {
@@ -187,7 +187,7 @@ export class Index {
187
187
  return ret >>> 0;
188
188
  }
189
189
  /**
190
- * @returns {(string)[]}
190
+ * @returns {string[]}
191
191
  */
192
192
  scopes() {
193
193
  try {
@@ -208,10 +208,10 @@ export class Index {
208
208
  }
209
209
  }
210
210
  /**
211
- * @param {number | undefined} scope_id
211
+ * @param {number | null | undefined} scope_id
212
212
  * @param {string} query
213
213
  * @param {number} max_results
214
- * @returns {(SearchedOption)[]}
214
+ * @returns {SearchedOption[]}
215
215
  */
216
216
  search(scope_id, query, max_results) {
217
217
  try {
@@ -234,23 +234,23 @@ export class Index {
234
234
  }
235
235
  }
236
236
  /**
237
+ * @param {number} scope_id
237
238
  * @param {string} name
238
239
  * @returns {number | undefined}
239
240
  */
240
- get_idx_by_name(name) {
241
+ get_idx_by_name(scope_id, name) {
241
242
  try {
242
243
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
243
244
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
244
245
  const len0 = WASM_VECTOR_LEN;
245
- wasm.index_get_idx_by_name(retptr, this.__wbg_ptr, ptr0, len0);
246
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
247
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
246
+ wasm.index_get_idx_by_name(retptr, this.__wbg_ptr, scope_id, ptr0, len0);
247
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
248
248
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
249
249
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
250
250
  if (r3) {
251
251
  throw takeObject(r2);
252
252
  }
253
- return r0 === 0 ? undefined : r1 >>> 0;
253
+ return r0 === 0x100000001 ? undefined : r0;
254
254
  } finally {
255
255
  wasm.__wbindgen_add_to_stack_pointer(16);
256
256
  }
@@ -289,6 +289,13 @@ export class SearchedOption {
289
289
  const ret = wasm.index_chunk_size(this.__wbg_ptr);
290
290
  return ret >>> 0;
291
291
  }
292
+ /**
293
+ * @returns {number}
294
+ */
295
+ scope_id() {
296
+ const ret = wasm.searchedoption_scope_id(this.__wbg_ptr);
297
+ return ret;
298
+ }
292
299
  /**
293
300
  * @returns {string}
294
301
  */
@@ -345,14 +352,14 @@ async function __wbg_load(module, imports) {
345
352
  function __wbg_get_imports() {
346
353
  const imports = {};
347
354
  imports.wbg = {};
348
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
349
- const ret = getStringFromWasm0(arg0, arg1);
350
- return addHeapObject(ret);
351
- };
352
355
  imports.wbg.__wbg_searchedoption_new = function(arg0) {
353
356
  const ret = SearchedOption.__wrap(arg0);
354
357
  return addHeapObject(ret);
355
358
  };
359
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
360
+ const ret = getStringFromWasm0(arg0, arg1);
361
+ return addHeapObject(ret);
362
+ };
356
363
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
357
364
  throw new Error(getStringFromWasm0(arg0, arg1));
358
365
  };
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.5",
4
+ "version": "0.0.7",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",