@nuschtos/fixx 0.0.2 → 0.0.3
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 +26 -0
- package/fixx.d.ts +28 -8
- package/fixx.js +133 -41
- package/fixx_bg.wasm +0 -0
- package/package.json +1 -1
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
|
/**
|
|
@@ -15,22 +10,47 @@ export class Index {
|
|
|
15
10
|
/**
|
|
16
11
|
* @param {string} query
|
|
17
12
|
* @param {number} max_results
|
|
13
|
+
* @returns {(SearchedOption)[]}
|
|
14
|
+
*/
|
|
15
|
+
search(query: string, max_results: number): (SearchedOption)[];
|
|
16
|
+
/**
|
|
17
|
+
* @param {number} max
|
|
18
18
|
* @returns {(string)[]}
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
all(max: number): (string)[];
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} name
|
|
23
|
+
* @returns {number | undefined}
|
|
24
|
+
*/
|
|
25
|
+
get_idx_by_name(name: string): number | undefined;
|
|
26
|
+
}
|
|
27
|
+
export class SearchedOption {
|
|
28
|
+
free(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @returns {number}
|
|
31
|
+
*/
|
|
32
|
+
idx(): number;
|
|
33
|
+
/**
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
name(): string;
|
|
21
37
|
}
|
|
22
38
|
|
|
23
39
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
24
40
|
|
|
25
41
|
export interface InitOutput {
|
|
26
42
|
readonly memory: WebAssembly.Memory;
|
|
27
|
-
readonly hash: (a: number, b: number) => number;
|
|
28
43
|
readonly __wbg_index_free: (a: number, b: number) => void;
|
|
44
|
+
readonly __wbg_searchedoption_free: (a: number, b: number) => void;
|
|
29
45
|
readonly index_read: (a: number, b: number, c: number) => void;
|
|
30
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;
|
|
48
|
+
readonly index_get_idx_by_name: (a: number, b: number, c: number, d: number) => void;
|
|
49
|
+
readonly searchedoption_idx: (a: number) => number;
|
|
50
|
+
readonly searchedoption_name: (a: number, b: number) => void;
|
|
51
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
31
52
|
readonly __wbindgen_export_0: (a: number, b: number) => number;
|
|
32
53
|
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
33
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
34
54
|
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
|
35
55
|
}
|
|
36
56
|
|
package/fixx.js
CHANGED
|
@@ -35,6 +35,36 @@ 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
|
+
|
|
38
68
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
39
69
|
|
|
40
70
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -88,46 +118,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
88
118
|
WASM_VECTOR_LEN = offset;
|
|
89
119
|
return ptr;
|
|
90
120
|
}
|
|
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
121
|
|
|
132
122
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
133
123
|
ptr = ptr >>> 0;
|
|
@@ -188,7 +178,7 @@ export class Index {
|
|
|
188
178
|
/**
|
|
189
179
|
* @param {string} query
|
|
190
180
|
* @param {number} max_results
|
|
191
|
-
* @returns {(
|
|
181
|
+
* @returns {(SearchedOption)[]}
|
|
192
182
|
*/
|
|
193
183
|
search(query, max_results) {
|
|
194
184
|
try {
|
|
@@ -210,6 +200,104 @@ export class Index {
|
|
|
210
200
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
211
201
|
}
|
|
212
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* @param {number} max
|
|
205
|
+
* @returns {(string)[]}
|
|
206
|
+
*/
|
|
207
|
+
all(max) {
|
|
208
|
+
try {
|
|
209
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
210
|
+
wasm.index_all(retptr, this.__wbg_ptr, max);
|
|
211
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
212
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
213
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
214
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
215
|
+
if (r3) {
|
|
216
|
+
throw takeObject(r2);
|
|
217
|
+
}
|
|
218
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
219
|
+
wasm.__wbindgen_export_2(r0, r1 * 4, 4);
|
|
220
|
+
return v1;
|
|
221
|
+
} finally {
|
|
222
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @param {string} name
|
|
227
|
+
* @returns {number | undefined}
|
|
228
|
+
*/
|
|
229
|
+
get_idx_by_name(name) {
|
|
230
|
+
try {
|
|
231
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
232
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
233
|
+
const len0 = WASM_VECTOR_LEN;
|
|
234
|
+
wasm.index_get_idx_by_name(retptr, this.__wbg_ptr, ptr0, len0);
|
|
235
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
236
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
237
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
238
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
239
|
+
if (r3) {
|
|
240
|
+
throw takeObject(r2);
|
|
241
|
+
}
|
|
242
|
+
return r0 === 0 ? undefined : r1 >>> 0;
|
|
243
|
+
} finally {
|
|
244
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const SearchedOptionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
250
|
+
? { register: () => {}, unregister: () => {} }
|
|
251
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_searchedoption_free(ptr >>> 0, 1));
|
|
252
|
+
|
|
253
|
+
export class SearchedOption {
|
|
254
|
+
|
|
255
|
+
static __wrap(ptr) {
|
|
256
|
+
ptr = ptr >>> 0;
|
|
257
|
+
const obj = Object.create(SearchedOption.prototype);
|
|
258
|
+
obj.__wbg_ptr = ptr;
|
|
259
|
+
SearchedOptionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
260
|
+
return obj;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
__destroy_into_raw() {
|
|
264
|
+
const ptr = this.__wbg_ptr;
|
|
265
|
+
this.__wbg_ptr = 0;
|
|
266
|
+
SearchedOptionFinalization.unregister(this);
|
|
267
|
+
return ptr;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
free() {
|
|
271
|
+
const ptr = this.__destroy_into_raw();
|
|
272
|
+
wasm.__wbg_searchedoption_free(ptr, 0);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @returns {number}
|
|
276
|
+
*/
|
|
277
|
+
idx() {
|
|
278
|
+
const ret = wasm.searchedoption_idx(this.__wbg_ptr);
|
|
279
|
+
return ret >>> 0;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @returns {string}
|
|
283
|
+
*/
|
|
284
|
+
name() {
|
|
285
|
+
let deferred1_0;
|
|
286
|
+
let deferred1_1;
|
|
287
|
+
try {
|
|
288
|
+
const ptr = this.__destroy_into_raw();
|
|
289
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
290
|
+
wasm.searchedoption_name(retptr, ptr);
|
|
291
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
292
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
293
|
+
deferred1_0 = r0;
|
|
294
|
+
deferred1_1 = r1;
|
|
295
|
+
return getStringFromWasm0(r0, r1);
|
|
296
|
+
} finally {
|
|
297
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
298
|
+
wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
213
301
|
}
|
|
214
302
|
|
|
215
303
|
async function __wbg_load(module, imports) {
|
|
@@ -250,6 +338,10 @@ function __wbg_get_imports() {
|
|
|
250
338
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
251
339
|
return addHeapObject(ret);
|
|
252
340
|
};
|
|
341
|
+
imports.wbg.__wbg_searchedoption_new = function(arg0) {
|
|
342
|
+
const ret = SearchedOption.__wrap(arg0);
|
|
343
|
+
return addHeapObject(ret);
|
|
344
|
+
};
|
|
253
345
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
254
346
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
255
347
|
};
|
package/fixx_bg.wasm
CHANGED
|
Binary file
|