@nuschtos/fixx 0.1.0 → 0.2.0

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
@@ -5,7 +5,7 @@ ixx is the search engine and index creation tool used by [NüschtOS Search](http
5
5
  ## Building fixx
6
6
 
7
7
  ```
8
- wasm-pack build --release fixx --target web
8
+ wasm-pack build --release fixx --target web --reference-types
9
9
  ```
10
10
 
11
11
  The result will be in `fixx/pkg`.
package/fixx.d.ts CHANGED
@@ -1,59 +1,66 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
3
4
  export class Index {
4
- private constructor();
5
- free(): void;
6
- static read(buf: Uint8Array): Index;
7
- chunk_size(): number;
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;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ get_idx_by_name(scope_id: number, name: string): number | undefined;
9
+ static read(buf: Uint8Array): Index;
10
+ search(scope_id: number | null | undefined, query: string, max_results: number): SearchedOption[];
11
+ size(): number;
11
12
  }
13
+
12
14
  export class SearchedOption {
13
- private constructor();
14
- free(): void;
15
- idx(): number;
16
- scope_id(): number;
17
- name(): string;
15
+ private constructor();
16
+ free(): void;
17
+ [Symbol.dispose](): void;
18
+ idx(): number;
19
+ name(): string;
20
+ scope_id(): number;
18
21
  }
19
22
 
20
23
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
21
24
 
22
25
  export interface InitOutput {
23
- readonly memory: WebAssembly.Memory;
24
- readonly __wbg_index_free: (a: number, b: number) => void;
25
- readonly __wbg_searchedoption_free: (a: number, b: number) => void;
26
- readonly index_read: (a: number, b: number, c: number) => void;
27
- readonly index_chunk_size: (a: number) => number;
28
- readonly index_scopes: (a: number, b: number) => void;
29
- readonly index_search: (a: number, b: number, c: number, d: number, e: number, f: 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;
32
- readonly searchedoption_name: (a: number, b: number) => void;
33
- readonly searchedoption_idx: (a: number) => number;
34
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
35
- readonly __wbindgen_export_0: (a: number, b: number) => number;
36
- readonly __wbindgen_export_1: (a: number, b: number, c: number) => void;
37
- readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
26
+ readonly memory: WebAssembly.Memory;
27
+ readonly __wbg_index_free: (a: number, b: number) => void;
28
+ readonly __wbg_searchedoption_free: (a: number, b: number) => void;
29
+ readonly index_get_idx_by_name: (a: number, b: number, c: number, d: any) => void;
30
+ readonly index_read: (a: number, b: number, c: number) => void;
31
+ readonly index_search: (a: number, b: number, c: number, d: any, e: number) => void;
32
+ readonly index_size: (a: number) => number;
33
+ readonly searchedoption_idx: (a: number) => number;
34
+ readonly searchedoption_name: (a: number, b: number) => void;
35
+ readonly searchedoption_scope_id: (a: number) => number;
36
+ readonly __wbindgen_export: (a: number, b: number) => number;
37
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
38
+ readonly __wbindgen_externrefs: WebAssembly.Table;
39
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
40
+ readonly __wbindgen_export3: (a: number) => void;
41
+ readonly __wbindgen_export4: (a: number, b: number) => void;
42
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
43
+ readonly __wbindgen_start: () => void;
38
44
  }
39
45
 
40
46
  export type SyncInitInput = BufferSource | WebAssembly.Module;
47
+
41
48
  /**
42
- * Instantiates the given `module`, which can either be bytes or
43
- * a precompiled `WebAssembly.Module`.
44
- *
45
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
46
- *
47
- * @returns {InitOutput}
48
- */
49
+ * Instantiates the given `module`, which can either be bytes or
50
+ * a precompiled `WebAssembly.Module`.
51
+ *
52
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
53
+ *
54
+ * @returns {InitOutput}
55
+ */
49
56
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
50
57
 
51
58
  /**
52
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
53
- * for everything else, calls `WebAssembly.instantiate` directly.
54
- *
55
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
56
- *
57
- * @returns {Promise<InitOutput>}
58
- */
59
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
60
+ * for everything else, calls `WebAssembly.instantiate` directly.
61
+ *
62
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
63
+ *
64
+ * @returns {Promise<InitOutput>}
65
+ */
59
66
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/fixx.js CHANGED
@@ -1,144 +1,6 @@
1
- let wasm;
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
-
18
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
19
-
20
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
21
-
22
- let cachedUint8ArrayMemory0 = null;
23
-
24
- function getUint8ArrayMemory0() {
25
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
26
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
27
- }
28
- return cachedUint8ArrayMemory0;
29
- }
30
-
31
- function getStringFromWasm0(ptr, len) {
32
- ptr = ptr >>> 0;
33
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
34
- }
35
-
36
- let WASM_VECTOR_LEN = 0;
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
-
82
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
83
-
84
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
85
- ? function (arg, view) {
86
- return cachedTextEncoder.encodeInto(arg, view);
87
- }
88
- : function (arg, view) {
89
- const buf = cachedTextEncoder.encode(arg);
90
- view.set(buf);
91
- return {
92
- read: arg.length,
93
- written: buf.length
94
- };
95
- });
96
-
97
- function passStringToWasm0(arg, malloc, realloc) {
98
-
99
- if (realloc === undefined) {
100
- const buf = cachedTextEncoder.encode(arg);
101
- const ptr = malloc(buf.length, 1) >>> 0;
102
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
103
- WASM_VECTOR_LEN = buf.length;
104
- return ptr;
105
- }
106
-
107
- let len = arg.length;
108
- let ptr = malloc(len, 1) >>> 0;
109
-
110
- const mem = getUint8ArrayMemory0();
111
-
112
- let offset = 0;
113
-
114
- for (; offset < len; offset++) {
115
- const code = arg.charCodeAt(offset);
116
- if (code > 0x7F) break;
117
- mem[ptr + offset] = code;
118
- }
119
-
120
- if (offset !== len) {
121
- if (offset !== 0) {
122
- arg = arg.slice(offset);
123
- }
124
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
125
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
126
- const ret = encodeString(arg, view);
127
-
128
- offset += ret.written;
129
- ptr = realloc(ptr, len, offset, 1) >>> 0;
130
- }
131
-
132
- WASM_VECTOR_LEN = offset;
133
- return ptr;
134
- }
135
-
136
- const IndexFinalization = (typeof FinalizationRegistry === 'undefined')
137
- ? { register: () => {}, unregister: () => {} }
138
- : new FinalizationRegistry(ptr => wasm.__wbg_index_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./fixx.d.ts" */
139
2
 
140
3
  export class Index {
141
-
142
4
  static __wrap(ptr) {
143
5
  ptr = ptr >>> 0;
144
6
  const obj = Object.create(Index.prototype);
@@ -146,63 +8,53 @@ export class Index {
146
8
  IndexFinalization.register(obj, obj.__wbg_ptr, obj);
147
9
  return obj;
148
10
  }
149
-
150
11
  __destroy_into_raw() {
151
12
  const ptr = this.__wbg_ptr;
152
13
  this.__wbg_ptr = 0;
153
14
  IndexFinalization.unregister(this);
154
15
  return ptr;
155
16
  }
156
-
157
17
  free() {
158
18
  const ptr = this.__destroy_into_raw();
159
19
  wasm.__wbg_index_free(ptr, 0);
160
20
  }
161
21
  /**
162
- * @param {Uint8Array} buf
163
- * @returns {Index}
22
+ * @param {number} scope_id
23
+ * @param {string} name
24
+ * @returns {number | undefined}
164
25
  */
165
- static read(buf) {
26
+ get_idx_by_name(scope_id, name) {
166
27
  try {
167
28
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
168
- const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_export_0);
169
- const len0 = WASM_VECTOR_LEN;
170
- wasm.index_read(retptr, ptr0, len0);
171
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
172
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
29
+ wasm.index_get_idx_by_name(retptr, this.__wbg_ptr, scope_id, name);
30
+ var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
173
31
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
174
- if (r2) {
175
- throw takeObject(r1);
32
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
33
+ if (r3) {
34
+ throw takeFromExternrefTable0(r2);
176
35
  }
177
- return Index.__wrap(r0);
36
+ return r0 === 0x100000001 ? undefined : r0;
178
37
  } finally {
179
38
  wasm.__wbindgen_add_to_stack_pointer(16);
180
39
  }
181
40
  }
182
41
  /**
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[]}
42
+ * @param {Uint8Array} buf
43
+ * @returns {Index}
191
44
  */
192
- scopes() {
45
+ static read(buf) {
193
46
  try {
194
47
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
- wasm.index_scopes(retptr, this.__wbg_ptr);
48
+ const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_export);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ wasm.index_read(retptr, ptr0, len0);
196
51
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
197
52
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
198
53
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
199
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
200
- if (r3) {
201
- throw takeObject(r2);
54
+ if (r2) {
55
+ throw takeFromExternrefTable0(r1);
202
56
  }
203
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
204
- wasm.__wbindgen_export_1(r0, r1 * 4, 4);
205
- return v1;
57
+ return Index.__wrap(r0);
206
58
  } finally {
207
59
  wasm.__wbindgen_add_to_stack_pointer(16);
208
60
  }
@@ -216,53 +68,32 @@ export class Index {
216
68
  search(scope_id, query, max_results) {
217
69
  try {
218
70
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
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);
71
+ wasm.index_search(retptr, this.__wbg_ptr, isLikeNone(scope_id) ? 0xFFFFFF : scope_id, query, max_results);
222
72
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
223
73
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
224
74
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
225
75
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
226
76
  if (r3) {
227
- throw takeObject(r2);
77
+ throw takeFromExternrefTable0(r2);
228
78
  }
229
- var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
230
- wasm.__wbindgen_export_1(r0, r1 * 4, 4);
231
- return v2;
79
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
80
+ wasm.__wbindgen_export5(r0, r1 * 4, 4);
81
+ return v1;
232
82
  } finally {
233
83
  wasm.__wbindgen_add_to_stack_pointer(16);
234
84
  }
235
85
  }
236
86
  /**
237
- * @param {number} scope_id
238
- * @param {string} name
239
- * @returns {number | undefined}
87
+ * @returns {number}
240
88
  */
241
- get_idx_by_name(scope_id, name) {
242
- try {
243
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
244
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_2);
245
- const len0 = WASM_VECTOR_LEN;
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
- 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 === 0x100000001 ? undefined : r0;
254
- } finally {
255
- wasm.__wbindgen_add_to_stack_pointer(16);
256
- }
89
+ size() {
90
+ const ret = wasm.index_size(this.__wbg_ptr);
91
+ return ret >>> 0;
257
92
  }
258
93
  }
259
-
260
- const SearchedOptionFinalization = (typeof FinalizationRegistry === 'undefined')
261
- ? { register: () => {}, unregister: () => {} }
262
- : new FinalizationRegistry(ptr => wasm.__wbg_searchedoption_free(ptr >>> 0, 1));
94
+ if (Symbol.dispose) Index.prototype[Symbol.dispose] = Index.prototype.free;
263
95
 
264
96
  export class SearchedOption {
265
-
266
97
  static __wrap(ptr) {
267
98
  ptr = ptr >>> 0;
268
99
  const obj = Object.create(SearchedOption.prototype);
@@ -270,14 +101,12 @@ export class SearchedOption {
270
101
  SearchedOptionFinalization.register(obj, obj.__wbg_ptr, obj);
271
102
  return obj;
272
103
  }
273
-
274
104
  __destroy_into_raw() {
275
105
  const ptr = this.__wbg_ptr;
276
106
  this.__wbg_ptr = 0;
277
107
  SearchedOptionFinalization.unregister(this);
278
108
  return ptr;
279
109
  }
280
-
281
110
  free() {
282
111
  const ptr = this.__destroy_into_raw();
283
112
  wasm.__wbg_searchedoption_free(ptr, 0);
@@ -286,16 +115,9 @@ export class SearchedOption {
286
115
  * @returns {number}
287
116
  */
288
117
  idx() {
289
- const ret = wasm.index_chunk_size(this.__wbg_ptr);
118
+ const ret = wasm.searchedoption_idx(this.__wbg_ptr);
290
119
  return ret >>> 0;
291
120
  }
292
- /**
293
- * @returns {number}
294
- */
295
- scope_id() {
296
- const ret = wasm.searchedoption_scope_id(this.__wbg_ptr);
297
- return ret;
298
- }
299
121
  /**
300
122
  * @returns {string}
301
123
  */
@@ -313,80 +135,230 @@ export class SearchedOption {
313
135
  return getStringFromWasm0(r0, r1);
314
136
  } finally {
315
137
  wasm.__wbindgen_add_to_stack_pointer(16);
316
- wasm.__wbindgen_export_1(deferred1_0, deferred1_1, 1);
138
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
317
139
  }
318
140
  }
141
+ /**
142
+ * @returns {number}
143
+ */
144
+ scope_id() {
145
+ const ret = wasm.searchedoption_scope_id(this.__wbg_ptr);
146
+ return ret;
147
+ }
319
148
  }
149
+ if (Symbol.dispose) SearchedOption.prototype[Symbol.dispose] = SearchedOption.prototype.free;
320
150
 
321
- async function __wbg_load(module, imports) {
322
- if (typeof Response === 'function' && module instanceof Response) {
323
- if (typeof WebAssembly.instantiateStreaming === 'function') {
324
- try {
325
- return await WebAssembly.instantiateStreaming(module, imports);
151
+ function __wbg_get_imports() {
152
+ const import0 = {
153
+ __proto__: null,
154
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
155
+ const obj = arg1;
156
+ const ret = typeof(obj) === 'string' ? obj : undefined;
157
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
158
+ var len1 = WASM_VECTOR_LEN;
159
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
160
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
161
+ },
162
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
163
+ throw new Error(getStringFromWasm0(arg0, arg1));
164
+ },
165
+ __wbg_searchedoption_new: function(arg0) {
166
+ const ret = SearchedOption.__wrap(arg0);
167
+ return ret;
168
+ },
169
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
170
+ // Cast intrinsic for `Ref(String) -> Externref`.
171
+ const ret = getStringFromWasm0(arg0, arg1);
172
+ return ret;
173
+ },
174
+ __wbindgen_init_externref_table: function() {
175
+ const table = wasm.__wbindgen_externrefs;
176
+ const offset = table.grow(4);
177
+ table.set(0, undefined);
178
+ table.set(offset + 0, undefined);
179
+ table.set(offset + 1, null);
180
+ table.set(offset + 2, true);
181
+ table.set(offset + 3, false);
182
+ },
183
+ };
184
+ return {
185
+ __proto__: null,
186
+ "./fixx_bg.js": import0,
187
+ };
188
+ }
326
189
 
327
- } catch (e) {
328
- if (module.headers.get('Content-Type') != 'application/wasm') {
329
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
190
+ const IndexFinalization = (typeof FinalizationRegistry === 'undefined')
191
+ ? { register: () => {}, unregister: () => {} }
192
+ : new FinalizationRegistry(ptr => wasm.__wbg_index_free(ptr >>> 0, 1));
193
+ const SearchedOptionFinalization = (typeof FinalizationRegistry === 'undefined')
194
+ ? { register: () => {}, unregister: () => {} }
195
+ : new FinalizationRegistry(ptr => wasm.__wbg_searchedoption_free(ptr >>> 0, 1));
330
196
 
331
- } else {
332
- throw e;
333
- }
334
- }
335
- }
197
+ function getArrayJsValueFromWasm0(ptr, len) {
198
+ ptr = ptr >>> 0;
199
+ const mem = getDataViewMemory0();
200
+ const result = [];
201
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
202
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
203
+ }
204
+ wasm.__wbindgen_export4(ptr, len);
205
+ return result;
206
+ }
336
207
 
337
- const bytes = await module.arrayBuffer();
338
- return await WebAssembly.instantiate(bytes, imports);
208
+ let cachedDataViewMemory0 = null;
209
+ function getDataViewMemory0() {
210
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
211
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
212
+ }
213
+ return cachedDataViewMemory0;
214
+ }
339
215
 
340
- } else {
341
- const instance = await WebAssembly.instantiate(module, imports);
216
+ function getStringFromWasm0(ptr, len) {
217
+ ptr = ptr >>> 0;
218
+ return decodeText(ptr, len);
219
+ }
342
220
 
343
- if (instance instanceof WebAssembly.Instance) {
344
- return { instance, module };
221
+ let cachedUint8ArrayMemory0 = null;
222
+ function getUint8ArrayMemory0() {
223
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
224
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
225
+ }
226
+ return cachedUint8ArrayMemory0;
227
+ }
345
228
 
346
- } else {
347
- return instance;
229
+ function isLikeNone(x) {
230
+ return x === undefined || x === null;
231
+ }
232
+
233
+ function passArray8ToWasm0(arg, malloc) {
234
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
235
+ getUint8ArrayMemory0().set(arg, ptr / 1);
236
+ WASM_VECTOR_LEN = arg.length;
237
+ return ptr;
238
+ }
239
+
240
+ function passStringToWasm0(arg, malloc, realloc) {
241
+ if (realloc === undefined) {
242
+ const buf = cachedTextEncoder.encode(arg);
243
+ const ptr = malloc(buf.length, 1) >>> 0;
244
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
245
+ WASM_VECTOR_LEN = buf.length;
246
+ return ptr;
247
+ }
248
+
249
+ let len = arg.length;
250
+ let ptr = malloc(len, 1) >>> 0;
251
+
252
+ const mem = getUint8ArrayMemory0();
253
+
254
+ let offset = 0;
255
+
256
+ for (; offset < len; offset++) {
257
+ const code = arg.charCodeAt(offset);
258
+ if (code > 0x7F) break;
259
+ mem[ptr + offset] = code;
260
+ }
261
+ if (offset !== len) {
262
+ if (offset !== 0) {
263
+ arg = arg.slice(offset);
348
264
  }
265
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
266
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
267
+ const ret = cachedTextEncoder.encodeInto(arg, view);
268
+
269
+ offset += ret.written;
270
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
349
271
  }
272
+
273
+ WASM_VECTOR_LEN = offset;
274
+ return ptr;
350
275
  }
351
276
 
352
- function __wbg_get_imports() {
353
- const imports = {};
354
- imports.wbg = {};
355
- imports.wbg.__wbg_searchedoption_new = function(arg0) {
356
- const ret = SearchedOption.__wrap(arg0);
357
- return addHeapObject(ret);
358
- };
359
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
360
- const ret = getStringFromWasm0(arg0, arg1);
361
- return addHeapObject(ret);
362
- };
363
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
364
- throw new Error(getStringFromWasm0(arg0, arg1));
365
- };
277
+ function takeFromExternrefTable0(idx) {
278
+ const value = wasm.__wbindgen_externrefs.get(idx);
279
+ wasm.__wbindgen_export3(idx);
280
+ return value;
281
+ }
366
282
 
367
- return imports;
283
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
284
+ cachedTextDecoder.decode();
285
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
286
+ let numBytesDecoded = 0;
287
+ function decodeText(ptr, len) {
288
+ numBytesDecoded += len;
289
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
290
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
291
+ cachedTextDecoder.decode();
292
+ numBytesDecoded = len;
293
+ }
294
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
368
295
  }
369
296
 
370
- function __wbg_init_memory(imports, memory) {
297
+ const cachedTextEncoder = new TextEncoder();
371
298
 
299
+ if (!('encodeInto' in cachedTextEncoder)) {
300
+ cachedTextEncoder.encodeInto = function (arg, view) {
301
+ const buf = cachedTextEncoder.encode(arg);
302
+ view.set(buf);
303
+ return {
304
+ read: arg.length,
305
+ written: buf.length
306
+ };
307
+ };
372
308
  }
373
309
 
310
+ let WASM_VECTOR_LEN = 0;
311
+
312
+ let wasmModule, wasm;
374
313
  function __wbg_finalize_init(instance, module) {
375
314
  wasm = instance.exports;
376
- __wbg_init.__wbindgen_wasm_module = module;
315
+ wasmModule = module;
377
316
  cachedDataViewMemory0 = null;
378
317
  cachedUint8ArrayMemory0 = null;
318
+ wasm.__wbindgen_start();
319
+ return wasm;
320
+ }
379
321
 
322
+ async function __wbg_load(module, imports) {
323
+ if (typeof Response === 'function' && module instanceof Response) {
324
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
325
+ try {
326
+ return await WebAssembly.instantiateStreaming(module, imports);
327
+ } catch (e) {
328
+ const validResponse = module.ok && expectedResponseType(module.type);
380
329
 
330
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
331
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
381
332
 
382
- return wasm;
333
+ } else { throw e; }
334
+ }
335
+ }
336
+
337
+ const bytes = await module.arrayBuffer();
338
+ return await WebAssembly.instantiate(bytes, imports);
339
+ } else {
340
+ const instance = await WebAssembly.instantiate(module, imports);
341
+
342
+ if (instance instanceof WebAssembly.Instance) {
343
+ return { instance, module };
344
+ } else {
345
+ return instance;
346
+ }
347
+ }
348
+
349
+ function expectedResponseType(type) {
350
+ switch (type) {
351
+ case 'basic': case 'cors': case 'default': return true;
352
+ }
353
+ return false;
354
+ }
383
355
  }
384
356
 
385
357
  function initSync(module) {
386
358
  if (wasm !== undefined) return wasm;
387
359
 
388
360
 
389
- if (typeof module !== 'undefined') {
361
+ if (module !== undefined) {
390
362
  if (Object.getPrototypeOf(module) === Object.prototype) {
391
363
  ({module} = module)
392
364
  } else {
@@ -395,15 +367,10 @@ function initSync(module) {
395
367
  }
396
368
 
397
369
  const imports = __wbg_get_imports();
398
-
399
- __wbg_init_memory(imports);
400
-
401
370
  if (!(module instanceof WebAssembly.Module)) {
402
371
  module = new WebAssembly.Module(module);
403
372
  }
404
-
405
373
  const instance = new WebAssembly.Instance(module, imports);
406
-
407
374
  return __wbg_finalize_init(instance, module);
408
375
  }
409
376
 
@@ -411,7 +378,7 @@ async function __wbg_init(module_or_path) {
411
378
  if (wasm !== undefined) return wasm;
412
379
 
413
380
 
414
- if (typeof module_or_path !== 'undefined') {
381
+ if (module_or_path !== undefined) {
415
382
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
416
383
  ({module_or_path} = module_or_path)
417
384
  } else {
@@ -419,7 +386,7 @@ async function __wbg_init(module_or_path) {
419
386
  }
420
387
  }
421
388
 
422
- if (typeof module_or_path === 'undefined') {
389
+ if (module_or_path === undefined) {
423
390
  module_or_path = new URL('fixx_bg.wasm', import.meta.url);
424
391
  }
425
392
  const imports = __wbg_get_imports();
@@ -428,12 +395,9 @@ async function __wbg_init(module_or_path) {
428
395
  module_or_path = fetch(module_or_path);
429
396
  }
430
397
 
431
- __wbg_init_memory(imports);
432
-
433
398
  const { instance, module } = await __wbg_load(await module_or_path, imports);
434
399
 
435
400
  return __wbg_finalize_init(instance, module);
436
401
  }
437
402
 
438
- export { initSync };
439
- export default __wbg_init;
403
+ export { initSync, __wbg_init as default };
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.1.0",
4
+ "version": "0.2.0",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",