rustfmt
[recipes.git] / backend / static / frontend.js
1
2 let wasm;
3
4 const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
6 cachedTextDecoder.decode();
7
8 let cachedUint8Memory0 = new Uint8Array();
9
10 function getUint8Memory0() {
11 if (cachedUint8Memory0.byteLength === 0) {
12 cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
13 }
14 return cachedUint8Memory0;
15 }
16
17 function getStringFromWasm0(ptr, len) {
18 return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19 }
20
21 const heap = new Array(32).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 function getObject(idx) { return heap[idx]; }
37
38 function dropObject(idx) {
39 if (idx < 36) return;
40 heap[idx] = heap_next;
41 heap_next = idx;
42 }
43
44 function takeObject(idx) {
45 const ret = getObject(idx);
46 dropObject(idx);
47 return ret;
48 }
49
50 let WASM_VECTOR_LEN = 0;
51
52 const cachedTextEncoder = new TextEncoder('utf-8');
53
54 const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
55 ? function (arg, view) {
56 return cachedTextEncoder.encodeInto(arg, view);
57 }
58 : function (arg, view) {
59 const buf = cachedTextEncoder.encode(arg);
60 view.set(buf);
61 return {
62 read: arg.length,
63 written: buf.length
64 };
65 });
66
67 function passStringToWasm0(arg, malloc, realloc) {
68
69 if (realloc === undefined) {
70 const buf = cachedTextEncoder.encode(arg);
71 const ptr = malloc(buf.length);
72 getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
73 WASM_VECTOR_LEN = buf.length;
74 return ptr;
75 }
76
77 let len = arg.length;
78 let ptr = malloc(len);
79
80 const mem = getUint8Memory0();
81
82 let offset = 0;
83
84 for (; offset < len; offset++) {
85 const code = arg.charCodeAt(offset);
86 if (code > 0x7F) break;
87 mem[ptr + offset] = code;
88 }
89
90 if (offset !== len) {
91 if (offset !== 0) {
92 arg = arg.slice(offset);
93 }
94 ptr = realloc(ptr, len, len = offset + arg.length * 3);
95 const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
96 const ret = encodeString(arg, view);
97
98 offset += ret.written;
99 }
100
101 WASM_VECTOR_LEN = offset;
102 return ptr;
103 }
104 /**
105 * @param {string} name
106 */
107 export function greet(name) {
108 const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
109 const len0 = WASM_VECTOR_LEN;
110 wasm.greet(ptr0, len0);
111 }
112
113 /**
114 */
115 export function main() {
116 wasm.main();
117 }
118
119 function handleError(f, args) {
120 try {
121 return f.apply(this, args);
122 } catch (e) {
123 wasm.__wbindgen_export_2(addHeapObject(e));
124 }
125 }
126
127 function isLikeNone(x) {
128 return x === undefined || x === null;
129 }
130
131 async function load(module, imports) {
132 if (typeof Response === 'function' && module instanceof Response) {
133 if (typeof WebAssembly.instantiateStreaming === 'function') {
134 try {
135 return await WebAssembly.instantiateStreaming(module, imports);
136
137 } catch (e) {
138 if (module.headers.get('Content-Type') != 'application/wasm') {
139 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);
140
141 } else {
142 throw e;
143 }
144 }
145 }
146
147 const bytes = await module.arrayBuffer();
148 return await WebAssembly.instantiate(bytes, imports);
149
150 } else {
151 const instance = await WebAssembly.instantiate(module, imports);
152
153 if (instance instanceof WebAssembly.Instance) {
154 return { instance, module };
155
156 } else {
157 return instance;
158 }
159 }
160 }
161
162 function getImports() {
163 const imports = {};
164 imports.wbg = {};
165 imports.wbg.__wbg_alert_02b82f812a9453a9 = function(arg0, arg1) {
166 alert(getStringFromWasm0(arg0, arg1));
167 };
168 imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
169 const ret = getStringFromWasm0(arg0, arg1);
170 return addHeapObject(ret);
171 };
172 imports.wbg.__wbg_log_4b5638ad60bdc54a = function(arg0) {
173 console.log(getObject(arg0));
174 };
175 imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
176 takeObject(arg0);
177 };
178 imports.wbg.__wbg_self_6d479506f72c6a71 = function() { return handleError(function () {
179 const ret = self.self;
180 return addHeapObject(ret);
181 }, arguments) };
182 imports.wbg.__wbg_window_f2557cc78490aceb = function() { return handleError(function () {
183 const ret = window.window;
184 return addHeapObject(ret);
185 }, arguments) };
186 imports.wbg.__wbg_globalThis_7f206bda628d5286 = function() { return handleError(function () {
187 const ret = globalThis.globalThis;
188 return addHeapObject(ret);
189 }, arguments) };
190 imports.wbg.__wbg_global_ba75c50d1cf384f4 = function() { return handleError(function () {
191 const ret = global.global;
192 return addHeapObject(ret);
193 }, arguments) };
194 imports.wbg.__wbindgen_is_undefined = function(arg0) {
195 const ret = getObject(arg0) === undefined;
196 return ret;
197 };
198 imports.wbg.__wbg_newnoargs_b5b063fc6c2f0376 = function(arg0, arg1) {
199 const ret = new Function(getStringFromWasm0(arg0, arg1));
200 return addHeapObject(ret);
201 };
202 imports.wbg.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) {
203 const ret = getObject(arg0).call(getObject(arg1));
204 return addHeapObject(ret);
205 }, arguments) };
206 imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
207 const ret = getObject(arg0);
208 return addHeapObject(ret);
209 };
210 imports.wbg.__wbg_instanceof_Window_acc97ff9f5d2c7b4 = function(arg0) {
211 let result;
212 try {
213 result = getObject(arg0) instanceof Window;
214 } catch {
215 result = false;
216 }
217 const ret = result;
218 return ret;
219 };
220 imports.wbg.__wbg_document_3ead31dbcad65886 = function(arg0) {
221 const ret = getObject(arg0).document;
222 return isLikeNone(ret) ? 0 : addHeapObject(ret);
223 };
224 imports.wbg.__wbg_body_3cb4b4042b9a632b = function(arg0) {
225 const ret = getObject(arg0).body;
226 return isLikeNone(ret) ? 0 : addHeapObject(ret);
227 };
228 imports.wbg.__wbg_createElement_976dbb84fe1661b5 = function() { return handleError(function (arg0, arg1, arg2) {
229 const ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2));
230 return addHeapObject(ret);
231 }, arguments) };
232 imports.wbg.__wbg_setinnerHTML_32081d8a164e6dc4 = function(arg0, arg1, arg2) {
233 getObject(arg0).innerHTML = getStringFromWasm0(arg1, arg2);
234 };
235 imports.wbg.__wbg_appendChild_e513ef0e5098dfdd = function() { return handleError(function (arg0, arg1) {
236 const ret = getObject(arg0).appendChild(getObject(arg1));
237 return addHeapObject(ret);
238 }, arguments) };
239 imports.wbg.__wbindgen_throw = function(arg0, arg1) {
240 throw new Error(getStringFromWasm0(arg0, arg1));
241 };
242 imports.wbg.__wbindgen_rethrow = function(arg0) {
243 throw takeObject(arg0);
244 };
245
246 return imports;
247 }
248
249 function initMemory(imports, maybe_memory) {
250
251 }
252
253 function finalizeInit(instance, module) {
254 wasm = instance.exports;
255 init.__wbindgen_wasm_module = module;
256 cachedUint8Memory0 = new Uint8Array();
257
258 wasm.__wbindgen_start();
259 return wasm;
260 }
261
262 function initSync(module) {
263 const imports = getImports();
264
265 initMemory(imports);
266
267 if (!(module instanceof WebAssembly.Module)) {
268 module = new WebAssembly.Module(module);
269 }
270
271 const instance = new WebAssembly.Instance(module, imports);
272
273 return finalizeInit(instance, module);
274 }
275
276 async function init(input) {
277 if (typeof input === 'undefined') {
278 input = new URL('frontend_bg.wasm', import.meta.url);
279 }
280 const imports = getImports();
281
282 if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
283 input = fetch(input);
284 }
285
286 initMemory(imports);
287
288 const { instance, module } = await load(await input, imports);
289
290 return finalizeInit(instance, module);
291 }
292
293 export { initSync }
294 export default init;