@nuschtos/fixx 0.0.2 → 0.0.4

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 ADDED
@@ -0,0 +1,26 @@
1
+ # ixx
2
+
3
+ ## Building fixx
4
+
5
+ ```
6
+ wasm-pack build --release fixx --target web
7
+ ```
8
+
9
+ The result will be in fixx/pkg
10
+
11
+ ## License
12
+
13
+ Licensed under either of
14
+
15
+ * Apache License, Version 2.0
16
+ ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
17
+ * MIT license
18
+ ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
19
+
20
+ at your option.
21
+
22
+ ## Contribution
23
+
24
+ Unless you explicitly state otherwise, any contribution intentionally submitted
25
+ for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
26
+ dual licensed as above, without any additional terms or conditions.
package/fixx.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * @param {string} option
5
- * @returns {number}
6
- */
7
- export function hash(option: string): number;
8
3
  export class Index {
9
4
  free(): void;
10
5
  /**
@@ -13,25 +8,55 @@ export class Index {
13
8
  */
14
9
  static read(buf: Uint8Array): Index;
15
10
  /**
11
+ * @returns {number}
12
+ */
13
+ chunk_size(): number;
14
+ /**
15
+ * @returns {(string)[]}
16
+ */
17
+ scopes(): (string)[];
18
+ /**
19
+ * @param {number | undefined} scope_id
16
20
  * @param {string} query
17
21
  * @param {number} max_results
18
- * @returns {(string)[]}
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}
19
28
  */
20
- search(query: string, max_results: number): (string)[];
29
+ get_idx_by_name(name: string): number | undefined;
30
+ }
31
+ export class SearchedOption {
32
+ free(): void;
33
+ /**
34
+ * @returns {number}
35
+ */
36
+ idx(): number;
37
+ /**
38
+ * @returns {string}
39
+ */
40
+ name(): string;
21
41
  }
22
42
 
23
43
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
24
44
 
25
45
  export interface InitOutput {
26
46
  readonly memory: WebAssembly.Memory;
27
- readonly hash: (a: number, b: number) => number;
28
47
  readonly __wbg_index_free: (a: number, b: number) => void;
48
+ readonly __wbg_searchedoption_free: (a: number, b: number) => void;
29
49
  readonly index_read: (a: number, b: number, c: number) => void;
30
- readonly index_search: (a: number, b: number, c: number, d: number, e: number) => void;
31
- readonly __wbindgen_export_0: (a: number, b: number) => number;
32
- readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
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;
53
+ readonly index_get_idx_by_name: (a: number, b: number, c: number, d: number) => void;
54
+ readonly searchedoption_name: (a: number, b: number) => void;
55
+ readonly searchedoption_idx: (a: number) => number;
33
56
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
34
- readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
57
+ readonly __wbindgen_export_0: (a: number, b: number) => number;
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;
35
60
  }
36
61
 
37
62
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/fixx.js CHANGED
@@ -35,6 +35,50 @@ function addHeapObject(obj) {
35
35
 
36
36
  let WASM_VECTOR_LEN = 0;
37
37
 
38
+ function passArray8ToWasm0(arg, malloc) {
39
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
40
+ getUint8ArrayMemory0().set(arg, ptr / 1);
41
+ WASM_VECTOR_LEN = arg.length;
42
+ return ptr;
43
+ }
44
+
45
+ let cachedDataViewMemory0 = null;
46
+
47
+ function getDataViewMemory0() {
48
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
49
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
50
+ }
51
+ return cachedDataViewMemory0;
52
+ }
53
+
54
+ function getObject(idx) { return heap[idx]; }
55
+
56
+ function dropObject(idx) {
57
+ if (idx < 132) return;
58
+ heap[idx] = heap_next;
59
+ heap_next = idx;
60
+ }
61
+
62
+ function takeObject(idx) {
63
+ const ret = getObject(idx);
64
+ dropObject(idx);
65
+ return ret;
66
+ }
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
+
38
82
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
39
83
 
40
84
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -88,56 +132,6 @@ function passStringToWasm0(arg, malloc, realloc) {
88
132
  WASM_VECTOR_LEN = offset;
89
133
  return ptr;
90
134
  }
91
- /**
92
- * @param {string} option
93
- * @returns {number}
94
- */
95
- export function hash(option) {
96
- const ptr0 = passStringToWasm0(option, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
97
- const len0 = WASM_VECTOR_LEN;
98
- const ret = wasm.hash(ptr0, len0);
99
- return ret;
100
- }
101
-
102
- function passArray8ToWasm0(arg, malloc) {
103
- const ptr = malloc(arg.length * 1, 1) >>> 0;
104
- getUint8ArrayMemory0().set(arg, ptr / 1);
105
- WASM_VECTOR_LEN = arg.length;
106
- return ptr;
107
- }
108
-
109
- let cachedDataViewMemory0 = null;
110
-
111
- function getDataViewMemory0() {
112
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
113
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
114
- }
115
- return cachedDataViewMemory0;
116
- }
117
-
118
- function getObject(idx) { return heap[idx]; }
119
-
120
- function dropObject(idx) {
121
- if (idx < 132) return;
122
- heap[idx] = heap_next;
123
- heap_next = idx;
124
- }
125
-
126
- function takeObject(idx) {
127
- const ret = getObject(idx);
128
- dropObject(idx);
129
- return ret;
130
- }
131
-
132
- function getArrayJsValueFromWasm0(ptr, len) {
133
- ptr = ptr >>> 0;
134
- const mem = getDataViewMemory0();
135
- const result = [];
136
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
137
- result.push(takeObject(mem.getUint32(i, true)));
138
- }
139
- return result;
140
- }
141
135
 
142
136
  const IndexFinalization = (typeof FinalizationRegistry === 'undefined')
143
137
  ? { register: () => {}, unregister: () => {} }
@@ -186,16 +180,45 @@ export class Index {
186
180
  }
187
181
  }
188
182
  /**
183
+ * @returns {number}
184
+ */
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() {
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ wasm.index_scopes(retptr, this.__wbg_ptr);
196
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
197
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
198
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
199
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
200
+ if (r3) {
201
+ throw takeObject(r2);
202
+ }
203
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
204
+ wasm.__wbindgen_export_1(r0, r1 * 4, 4);
205
+ return v1;
206
+ } finally {
207
+ wasm.__wbindgen_add_to_stack_pointer(16);
208
+ }
209
+ }
210
+ /**
211
+ * @param {number | undefined} scope_id
189
212
  * @param {string} query
190
213
  * @param {number} max_results
191
- * @returns {(string)[]}
214
+ * @returns {(SearchedOption)[]}
192
215
  */
193
- search(query, max_results) {
216
+ search(scope_id, query, max_results) {
194
217
  try {
195
218
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
196
- const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
219
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
197
220
  const len0 = WASM_VECTOR_LEN;
198
- wasm.index_search(retptr, this.__wbg_ptr, ptr0, len0, max_results);
221
+ wasm.index_search(retptr, this.__wbg_ptr, isLikeNone(scope_id) ? 0xFFFFFF : scope_id, ptr0, len0, max_results);
199
222
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
200
223
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
201
224
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -204,12 +227,88 @@ export class Index {
204
227
  throw takeObject(r2);
205
228
  }
206
229
  var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
207
- wasm.__wbindgen_export_2(r0, r1 * 4, 4);
230
+ wasm.__wbindgen_export_1(r0, r1 * 4, 4);
208
231
  return v2;
209
232
  } finally {
210
233
  wasm.__wbindgen_add_to_stack_pointer(16);
211
234
  }
212
235
  }
236
+ /**
237
+ * @param {string} name
238
+ * @returns {number | undefined}
239
+ */
240
+ get_idx_by_name(name) {
241
+ try {
242
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
243
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
244
+ 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);
248
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
249
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
250
+ if (r3) {
251
+ throw takeObject(r2);
252
+ }
253
+ return r0 === 0 ? undefined : r1 >>> 0;
254
+ } finally {
255
+ wasm.__wbindgen_add_to_stack_pointer(16);
256
+ }
257
+ }
258
+ }
259
+
260
+ const SearchedOptionFinalization = (typeof FinalizationRegistry === 'undefined')
261
+ ? { register: () => {}, unregister: () => {} }
262
+ : new FinalizationRegistry(ptr => wasm.__wbg_searchedoption_free(ptr >>> 0, 1));
263
+
264
+ export class SearchedOption {
265
+
266
+ static __wrap(ptr) {
267
+ ptr = ptr >>> 0;
268
+ const obj = Object.create(SearchedOption.prototype);
269
+ obj.__wbg_ptr = ptr;
270
+ SearchedOptionFinalization.register(obj, obj.__wbg_ptr, obj);
271
+ return obj;
272
+ }
273
+
274
+ __destroy_into_raw() {
275
+ const ptr = this.__wbg_ptr;
276
+ this.__wbg_ptr = 0;
277
+ SearchedOptionFinalization.unregister(this);
278
+ return ptr;
279
+ }
280
+
281
+ free() {
282
+ const ptr = this.__destroy_into_raw();
283
+ wasm.__wbg_searchedoption_free(ptr, 0);
284
+ }
285
+ /**
286
+ * @returns {number}
287
+ */
288
+ idx() {
289
+ const ret = wasm.index_chunk_size(this.__wbg_ptr);
290
+ return ret >>> 0;
291
+ }
292
+ /**
293
+ * @returns {string}
294
+ */
295
+ name() {
296
+ let deferred1_0;
297
+ let deferred1_1;
298
+ try {
299
+ const ptr = this.__destroy_into_raw();
300
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
301
+ wasm.searchedoption_name(retptr, ptr);
302
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
303
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
304
+ deferred1_0 = r0;
305
+ deferred1_1 = r1;
306
+ return getStringFromWasm0(r0, r1);
307
+ } finally {
308
+ wasm.__wbindgen_add_to_stack_pointer(16);
309
+ wasm.__wbindgen_export_1(deferred1_0, deferred1_1, 1);
310
+ }
311
+ }
213
312
  }
214
313
 
215
314
  async function __wbg_load(module, imports) {
@@ -250,6 +349,10 @@ function __wbg_get_imports() {
250
349
  const ret = getStringFromWasm0(arg0, arg1);
251
350
  return addHeapObject(ret);
252
351
  };
352
+ imports.wbg.__wbg_searchedoption_new = function(arg0) {
353
+ const ret = SearchedOption.__wrap(arg0);
354
+ return addHeapObject(ret);
355
+ };
253
356
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
254
357
  throw new Error(getStringFromWasm0(arg0, arg1));
255
358
  };
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.2",
4
+ "version": "0.0.4",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",