@noir-lang/noir_wasm 0.11.0 → 0.12.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 +19 -0
- package/nodejs/noir_wasm.d.ts +35 -0
- package/nodejs/noir_wasm.js +345 -0
- package/nodejs/noir_wasm_bg.wasm +0 -0
- package/nodejs/noir_wasm_bg.wasm.d.ts +15 -0
- package/package.json +34 -9
- package/{noir_wasm.d.ts → web/noir_wasm.d.ts} +30 -12
- package/web/noir_wasm.js +401 -0
- package/web/noir_wasm_bg.wasm +0 -0
- package/web/noir_wasm_bg.wasm.d.ts +15 -0
- package/noir_wasm.js +0 -295
- package/noir_wasm_bg.wasm +0 -0
- package/noir_wasm_bg.wasm.d.ts +0 -15
- package/snippets/fm-cffb18dcbd478425/file_reader.js +0 -6
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Noir Lang WASM JavaScript Package
|
|
2
|
+
|
|
3
|
+
This JavaScript package enables users to compile a Noir program, i.e. generating its artifacts.
|
|
4
|
+
|
|
5
|
+
The package also handles dependency management like how Nargo (Noir's CLI tool) operates, but the package is used just for compilation, not proving, verifying and simulating functions.
|
|
6
|
+
|
|
7
|
+
## Building from source
|
|
8
|
+
|
|
9
|
+
Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
nix build -L github:noir-lang/noir/master#wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If you are within the noir repo and would like to build local changes, you can use:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
nix build -L #wasm
|
|
19
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} level
|
|
5
|
+
*/
|
|
6
|
+
export function init_log_level(level: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* @returns {any}
|
|
9
|
+
*/
|
|
10
|
+
export function build_info(): any;
|
|
11
|
+
/**
|
|
12
|
+
* @param {Uint8Array} bytes
|
|
13
|
+
* @returns {any}
|
|
14
|
+
*/
|
|
15
|
+
export function acir_read_bytes(bytes: Uint8Array): any;
|
|
16
|
+
/**
|
|
17
|
+
* @param {any} acir
|
|
18
|
+
* @returns {Uint8Array}
|
|
19
|
+
*/
|
|
20
|
+
export function acir_write_bytes(acir: any): Uint8Array;
|
|
21
|
+
/**
|
|
22
|
+
* @param {any} args
|
|
23
|
+
* @returns {any}
|
|
24
|
+
*/
|
|
25
|
+
export function compile(args: any): any;
|
|
26
|
+
/**
|
|
27
|
+
* A struct representing a Trap
|
|
28
|
+
*/
|
|
29
|
+
export class Trap {
|
|
30
|
+
free(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @returns {Symbol}
|
|
33
|
+
*/
|
|
34
|
+
static __wbgd_downcast_token(): Symbol;
|
|
35
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
let imports = {};
|
|
2
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
|
+
let wasm;
|
|
4
|
+
const { read_file } = require(`@noir-lang/source-resolver`);
|
|
5
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
|
6
|
+
|
|
7
|
+
const heap = new Array(128).fill(undefined);
|
|
8
|
+
|
|
9
|
+
heap.push(undefined, null, true, false);
|
|
10
|
+
|
|
11
|
+
function getObject(idx) { return heap[idx]; }
|
|
12
|
+
|
|
13
|
+
let heap_next = heap.length;
|
|
14
|
+
|
|
15
|
+
function dropObject(idx) {
|
|
16
|
+
if (idx < 132) return;
|
|
17
|
+
heap[idx] = heap_next;
|
|
18
|
+
heap_next = idx;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function takeObject(idx) {
|
|
22
|
+
const ret = getObject(idx);
|
|
23
|
+
dropObject(idx);
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
28
|
+
|
|
29
|
+
cachedTextDecoder.decode();
|
|
30
|
+
|
|
31
|
+
let cachedUint8Memory0 = null;
|
|
32
|
+
|
|
33
|
+
function getUint8Memory0() {
|
|
34
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
35
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
36
|
+
}
|
|
37
|
+
return cachedUint8Memory0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getStringFromWasm0(ptr, len) {
|
|
41
|
+
ptr = ptr >>> 0;
|
|
42
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function addHeapObject(obj) {
|
|
46
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
47
|
+
const idx = heap_next;
|
|
48
|
+
heap_next = heap[idx];
|
|
49
|
+
|
|
50
|
+
heap[idx] = obj;
|
|
51
|
+
return idx;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let WASM_VECTOR_LEN = 0;
|
|
55
|
+
|
|
56
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
57
|
+
|
|
58
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
59
|
+
? function (arg, view) {
|
|
60
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
61
|
+
}
|
|
62
|
+
: function (arg, view) {
|
|
63
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
64
|
+
view.set(buf);
|
|
65
|
+
return {
|
|
66
|
+
read: arg.length,
|
|
67
|
+
written: buf.length
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
72
|
+
|
|
73
|
+
if (realloc === undefined) {
|
|
74
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
75
|
+
const ptr = malloc(buf.length) >>> 0;
|
|
76
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
77
|
+
WASM_VECTOR_LEN = buf.length;
|
|
78
|
+
return ptr;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let len = arg.length;
|
|
82
|
+
let ptr = malloc(len) >>> 0;
|
|
83
|
+
|
|
84
|
+
const mem = getUint8Memory0();
|
|
85
|
+
|
|
86
|
+
let offset = 0;
|
|
87
|
+
|
|
88
|
+
for (; offset < len; offset++) {
|
|
89
|
+
const code = arg.charCodeAt(offset);
|
|
90
|
+
if (code > 0x7F) break;
|
|
91
|
+
mem[ptr + offset] = code;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (offset !== len) {
|
|
95
|
+
if (offset !== 0) {
|
|
96
|
+
arg = arg.slice(offset);
|
|
97
|
+
}
|
|
98
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
|
99
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
100
|
+
const ret = encodeString(arg, view);
|
|
101
|
+
|
|
102
|
+
offset += ret.written;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
WASM_VECTOR_LEN = offset;
|
|
106
|
+
return ptr;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isLikeNone(x) {
|
|
110
|
+
return x === undefined || x === null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let cachedInt32Memory0 = null;
|
|
114
|
+
|
|
115
|
+
function getInt32Memory0() {
|
|
116
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
117
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
118
|
+
}
|
|
119
|
+
return cachedInt32Memory0;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} level
|
|
123
|
+
*/
|
|
124
|
+
module.exports.init_log_level = function(level) {
|
|
125
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
126
|
+
const len0 = WASM_VECTOR_LEN;
|
|
127
|
+
wasm.init_log_level(ptr0, len0);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @returns {any}
|
|
132
|
+
*/
|
|
133
|
+
module.exports.build_info = function() {
|
|
134
|
+
const ret = wasm.build_info();
|
|
135
|
+
return takeObject(ret);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
139
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
140
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
141
|
+
WASM_VECTOR_LEN = arg.length;
|
|
142
|
+
return ptr;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @param {Uint8Array} bytes
|
|
146
|
+
* @returns {any}
|
|
147
|
+
*/
|
|
148
|
+
module.exports.acir_read_bytes = function(bytes) {
|
|
149
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
const ret = wasm.acir_read_bytes(ptr0, len0);
|
|
152
|
+
return takeObject(ret);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
156
|
+
ptr = ptr >>> 0;
|
|
157
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @param {any} acir
|
|
161
|
+
* @returns {Uint8Array}
|
|
162
|
+
*/
|
|
163
|
+
module.exports.acir_write_bytes = function(acir) {
|
|
164
|
+
try {
|
|
165
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
166
|
+
wasm.acir_write_bytes(retptr, addHeapObject(acir));
|
|
167
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
168
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
169
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
170
|
+
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
171
|
+
return v1;
|
|
172
|
+
} finally {
|
|
173
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {any} args
|
|
179
|
+
* @returns {any}
|
|
180
|
+
*/
|
|
181
|
+
module.exports.compile = function(args) {
|
|
182
|
+
const ret = wasm.compile(addHeapObject(args));
|
|
183
|
+
return takeObject(ret);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function handleError(f, args) {
|
|
187
|
+
try {
|
|
188
|
+
return f.apply(this, args);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A struct representing a Trap
|
|
195
|
+
*/
|
|
196
|
+
class Trap {
|
|
197
|
+
|
|
198
|
+
__destroy_into_raw() {
|
|
199
|
+
const ptr = this.__wbg_ptr;
|
|
200
|
+
this.__wbg_ptr = 0;
|
|
201
|
+
|
|
202
|
+
return ptr;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
free() {
|
|
206
|
+
const ptr = this.__destroy_into_raw();
|
|
207
|
+
wasm.__wbg_trap_free(ptr);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns {Symbol}
|
|
211
|
+
*/
|
|
212
|
+
static __wbgd_downcast_token() {
|
|
213
|
+
const ret = wasm.trap___wbgd_downcast_token();
|
|
214
|
+
return takeObject(ret);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
module.exports.Trap = Trap;
|
|
218
|
+
|
|
219
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
220
|
+
takeObject(arg0);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
224
|
+
const ret = getObject(arg0) === undefined;
|
|
225
|
+
return ret;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
module.exports.__wbindgen_is_null = function(arg0) {
|
|
229
|
+
const ret = getObject(arg0) === null;
|
|
230
|
+
return ret;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
234
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
235
|
+
return addHeapObject(ret);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
239
|
+
const ret = new Error();
|
|
240
|
+
return addHeapObject(ret);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
244
|
+
const ret = getObject(arg1).stack;
|
|
245
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
246
|
+
const len1 = WASM_VECTOR_LEN;
|
|
247
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
248
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
252
|
+
let deferred0_0;
|
|
253
|
+
let deferred0_1;
|
|
254
|
+
try {
|
|
255
|
+
deferred0_0 = arg0;
|
|
256
|
+
deferred0_1 = arg1;
|
|
257
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
258
|
+
} finally {
|
|
259
|
+
wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
module.exports.__wbg_readfile_8efacfffd6a3a749 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
264
|
+
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
265
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
266
|
+
const len1 = WASM_VECTOR_LEN;
|
|
267
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
268
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
269
|
+
}, arguments) };
|
|
270
|
+
|
|
271
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
272
|
+
const ret = getObject(arg0);
|
|
273
|
+
return addHeapObject(ret);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
277
|
+
const obj = getObject(arg1);
|
|
278
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
279
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
280
|
+
var len1 = WASM_VECTOR_LEN;
|
|
281
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
282
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
module.exports.__wbg_static_accessor_SYMBOL_45d4d15e3c4aeb33 = function() {
|
|
286
|
+
const ret = Symbol;
|
|
287
|
+
return addHeapObject(ret);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
module.exports.__wbindgen_is_symbol = function(arg0) {
|
|
291
|
+
const ret = typeof(getObject(arg0)) === 'symbol';
|
|
292
|
+
return ret;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
|
|
296
|
+
console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
|
|
300
|
+
console.error(getObject(arg0));
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
|
|
304
|
+
console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
|
|
308
|
+
console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
|
|
312
|
+
console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
|
|
316
|
+
console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
module.exports.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) {
|
|
320
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
321
|
+
return addHeapObject(ret);
|
|
322
|
+
}, arguments) };
|
|
323
|
+
|
|
324
|
+
module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
|
|
325
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
326
|
+
return addHeapObject(ret);
|
|
327
|
+
}, arguments) };
|
|
328
|
+
|
|
329
|
+
module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
|
|
330
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
331
|
+
return addHeapObject(ret);
|
|
332
|
+
}, arguments) };
|
|
333
|
+
|
|
334
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
335
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
|
|
339
|
+
const bytes = require('fs').readFileSync(path);
|
|
340
|
+
|
|
341
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
342
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
343
|
+
wasm = wasmInstance.exports;
|
|
344
|
+
module.exports.__wasm = wasm;
|
|
345
|
+
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function init_log_level(a: number, b: number): void;
|
|
5
|
+
export function build_info(): number;
|
|
6
|
+
export function acir_read_bytes(a: number, b: number): number;
|
|
7
|
+
export function acir_write_bytes(a: number, b: number): void;
|
|
8
|
+
export function compile(a: number): number;
|
|
9
|
+
export function __wbg_trap_free(a: number): void;
|
|
10
|
+
export function trap___wbgd_downcast_token(): number;
|
|
11
|
+
export function __wbindgen_export_0(a: number): number;
|
|
12
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
13
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
14
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
15
|
+
export function __wbindgen_export_3(a: number): void;
|
package/package.json
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noir-lang/noir_wasm",
|
|
3
|
-
"
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"The Noir Team <team@noir-lang.org>"
|
|
5
|
+
],
|
|
6
|
+
"version": "0.12.0",
|
|
7
|
+
"license": "(MIT OR Apache-2.0)",
|
|
8
|
+
"main": "./nodejs/noir_wasm.js",
|
|
9
|
+
"types": "./web/noir_wasm.d.ts",
|
|
10
|
+
"module": "./web/noir_wasm.js",
|
|
4
11
|
"files": [
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"noir_wasm.d.ts",
|
|
9
|
-
"snippets/*"
|
|
12
|
+
"nodejs",
|
|
13
|
+
"web",
|
|
14
|
+
"package.json"
|
|
10
15
|
],
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/noir-lang/noir.git"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "bash ./build.sh",
|
|
23
|
+
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
|
|
24
|
+
"test:node": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
|
|
25
|
+
"test:browser": "web-test-runner"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@noir-lang/source-resolver": "workspace:*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
32
|
+
"@web/dev-server-esbuild": "^0.3.6",
|
|
33
|
+
"@web/test-runner": "^0.15.3",
|
|
34
|
+
"@web/test-runner-playwright": "^0.10.0",
|
|
35
|
+
"@web/test-runner-webdriver": "^0.7.0",
|
|
36
|
+
"mocha": "^10.2.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,32 +1,50 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* @param {string}
|
|
4
|
+
* @param {string} level
|
|
5
|
+
*/
|
|
6
|
+
export function init_log_level(level: string): void;
|
|
7
|
+
/**
|
|
5
8
|
* @returns {any}
|
|
6
9
|
*/
|
|
7
|
-
export function
|
|
10
|
+
export function build_info(): any;
|
|
8
11
|
/**
|
|
9
12
|
* @param {Uint8Array} bytes
|
|
10
13
|
* @returns {any}
|
|
11
14
|
*/
|
|
12
|
-
export function
|
|
15
|
+
export function acir_read_bytes(bytes: Uint8Array): any;
|
|
13
16
|
/**
|
|
14
17
|
* @param {any} acir
|
|
15
18
|
* @returns {Uint8Array}
|
|
16
19
|
*/
|
|
17
|
-
export function
|
|
20
|
+
export function acir_write_bytes(acir: any): Uint8Array;
|
|
21
|
+
/**
|
|
22
|
+
* @param {any} args
|
|
23
|
+
* @returns {any}
|
|
24
|
+
*/
|
|
25
|
+
export function compile(args: any): any;
|
|
26
|
+
/**
|
|
27
|
+
* A struct representing a Trap
|
|
28
|
+
*/
|
|
29
|
+
export class Trap {
|
|
30
|
+
free(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @returns {Symbol}
|
|
33
|
+
*/
|
|
34
|
+
static __wbgd_downcast_token(): Symbol;
|
|
35
|
+
}
|
|
18
36
|
|
|
19
37
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
20
38
|
|
|
21
39
|
export interface InitOutput {
|
|
22
40
|
readonly memory: WebAssembly.Memory;
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
41
|
+
readonly init_log_level: (a: number, b: number) => void;
|
|
42
|
+
readonly build_info: () => number;
|
|
43
|
+
readonly acir_read_bytes: (a: number, b: number) => number;
|
|
44
|
+
readonly acir_write_bytes: (a: number, b: number) => void;
|
|
45
|
+
readonly compile: (a: number) => number;
|
|
46
|
+
readonly __wbg_trap_free: (a: number) => void;
|
|
47
|
+
readonly trap___wbgd_downcast_token: () => number;
|
|
30
48
|
readonly __wbindgen_export_0: (a: number) => number;
|
|
31
49
|
readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
|
|
32
50
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
@@ -53,4 +71,4 @@ export function initSync(module: SyncInitInput): InitOutput;
|
|
|
53
71
|
*
|
|
54
72
|
* @returns {Promise<InitOutput>}
|
|
55
73
|
*/
|
|
56
|
-
export default function
|
|
74
|
+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/web/noir_wasm.js
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { read_file } from '@noir-lang/source-resolver';
|
|
2
|
+
|
|
3
|
+
let wasm;
|
|
4
|
+
|
|
5
|
+
const heap = new Array(128).fill(undefined);
|
|
6
|
+
|
|
7
|
+
heap.push(undefined, null, true, false);
|
|
8
|
+
|
|
9
|
+
function getObject(idx) { return heap[idx]; }
|
|
10
|
+
|
|
11
|
+
let heap_next = heap.length;
|
|
12
|
+
|
|
13
|
+
function dropObject(idx) {
|
|
14
|
+
if (idx < 132) return;
|
|
15
|
+
heap[idx] = heap_next;
|
|
16
|
+
heap_next = idx;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function takeObject(idx) {
|
|
20
|
+
const ret = getObject(idx);
|
|
21
|
+
dropObject(idx);
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
26
|
+
|
|
27
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
28
|
+
|
|
29
|
+
let cachedUint8Memory0 = null;
|
|
30
|
+
|
|
31
|
+
function getUint8Memory0() {
|
|
32
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
33
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
34
|
+
}
|
|
35
|
+
return cachedUint8Memory0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getStringFromWasm0(ptr, len) {
|
|
39
|
+
ptr = ptr >>> 0;
|
|
40
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function addHeapObject(obj) {
|
|
44
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
45
|
+
const idx = heap_next;
|
|
46
|
+
heap_next = heap[idx];
|
|
47
|
+
|
|
48
|
+
heap[idx] = obj;
|
|
49
|
+
return idx;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let WASM_VECTOR_LEN = 0;
|
|
53
|
+
|
|
54
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
55
|
+
|
|
56
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
57
|
+
? function (arg, view) {
|
|
58
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
59
|
+
}
|
|
60
|
+
: function (arg, view) {
|
|
61
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
62
|
+
view.set(buf);
|
|
63
|
+
return {
|
|
64
|
+
read: arg.length,
|
|
65
|
+
written: buf.length
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
70
|
+
|
|
71
|
+
if (realloc === undefined) {
|
|
72
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
73
|
+
const ptr = malloc(buf.length) >>> 0;
|
|
74
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
75
|
+
WASM_VECTOR_LEN = buf.length;
|
|
76
|
+
return ptr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let len = arg.length;
|
|
80
|
+
let ptr = malloc(len) >>> 0;
|
|
81
|
+
|
|
82
|
+
const mem = getUint8Memory0();
|
|
83
|
+
|
|
84
|
+
let offset = 0;
|
|
85
|
+
|
|
86
|
+
for (; offset < len; offset++) {
|
|
87
|
+
const code = arg.charCodeAt(offset);
|
|
88
|
+
if (code > 0x7F) break;
|
|
89
|
+
mem[ptr + offset] = code;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (offset !== len) {
|
|
93
|
+
if (offset !== 0) {
|
|
94
|
+
arg = arg.slice(offset);
|
|
95
|
+
}
|
|
96
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
|
97
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
98
|
+
const ret = encodeString(arg, view);
|
|
99
|
+
|
|
100
|
+
offset += ret.written;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
WASM_VECTOR_LEN = offset;
|
|
104
|
+
return ptr;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isLikeNone(x) {
|
|
108
|
+
return x === undefined || x === null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let cachedInt32Memory0 = null;
|
|
112
|
+
|
|
113
|
+
function getInt32Memory0() {
|
|
114
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
115
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
116
|
+
}
|
|
117
|
+
return cachedInt32Memory0;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @param {string} level
|
|
121
|
+
*/
|
|
122
|
+
export function init_log_level(level) {
|
|
123
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
wasm.init_log_level(ptr0, len0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @returns {any}
|
|
130
|
+
*/
|
|
131
|
+
export function build_info() {
|
|
132
|
+
const ret = wasm.build_info();
|
|
133
|
+
return takeObject(ret);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
137
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
138
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
139
|
+
WASM_VECTOR_LEN = arg.length;
|
|
140
|
+
return ptr;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @param {Uint8Array} bytes
|
|
144
|
+
* @returns {any}
|
|
145
|
+
*/
|
|
146
|
+
export function acir_read_bytes(bytes) {
|
|
147
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
const ret = wasm.acir_read_bytes(ptr0, len0);
|
|
150
|
+
return takeObject(ret);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
154
|
+
ptr = ptr >>> 0;
|
|
155
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @param {any} acir
|
|
159
|
+
* @returns {Uint8Array}
|
|
160
|
+
*/
|
|
161
|
+
export function acir_write_bytes(acir) {
|
|
162
|
+
try {
|
|
163
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
164
|
+
wasm.acir_write_bytes(retptr, addHeapObject(acir));
|
|
165
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
166
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
167
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
168
|
+
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
169
|
+
return v1;
|
|
170
|
+
} finally {
|
|
171
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @param {any} args
|
|
177
|
+
* @returns {any}
|
|
178
|
+
*/
|
|
179
|
+
export function compile(args) {
|
|
180
|
+
const ret = wasm.compile(addHeapObject(args));
|
|
181
|
+
return takeObject(ret);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function handleError(f, args) {
|
|
185
|
+
try {
|
|
186
|
+
return f.apply(this, args);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* A struct representing a Trap
|
|
193
|
+
*/
|
|
194
|
+
export class Trap {
|
|
195
|
+
|
|
196
|
+
__destroy_into_raw() {
|
|
197
|
+
const ptr = this.__wbg_ptr;
|
|
198
|
+
this.__wbg_ptr = 0;
|
|
199
|
+
|
|
200
|
+
return ptr;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
free() {
|
|
204
|
+
const ptr = this.__destroy_into_raw();
|
|
205
|
+
wasm.__wbg_trap_free(ptr);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @returns {Symbol}
|
|
209
|
+
*/
|
|
210
|
+
static __wbgd_downcast_token() {
|
|
211
|
+
const ret = wasm.trap___wbgd_downcast_token();
|
|
212
|
+
return takeObject(ret);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function __wbg_load(module, imports) {
|
|
217
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
218
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
219
|
+
try {
|
|
220
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
221
|
+
|
|
222
|
+
} catch (e) {
|
|
223
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
224
|
+
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);
|
|
225
|
+
|
|
226
|
+
} else {
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const bytes = await module.arrayBuffer();
|
|
233
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
234
|
+
|
|
235
|
+
} else {
|
|
236
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
237
|
+
|
|
238
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
239
|
+
return { instance, module };
|
|
240
|
+
|
|
241
|
+
} else {
|
|
242
|
+
return instance;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function __wbg_get_imports() {
|
|
248
|
+
const imports = {};
|
|
249
|
+
imports.wbg = {};
|
|
250
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
251
|
+
takeObject(arg0);
|
|
252
|
+
};
|
|
253
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
254
|
+
const ret = getObject(arg0) === undefined;
|
|
255
|
+
return ret;
|
|
256
|
+
};
|
|
257
|
+
imports.wbg.__wbindgen_is_null = function(arg0) {
|
|
258
|
+
const ret = getObject(arg0) === null;
|
|
259
|
+
return ret;
|
|
260
|
+
};
|
|
261
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
262
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
263
|
+
return addHeapObject(ret);
|
|
264
|
+
};
|
|
265
|
+
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
266
|
+
const ret = new Error();
|
|
267
|
+
return addHeapObject(ret);
|
|
268
|
+
};
|
|
269
|
+
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
270
|
+
const ret = getObject(arg1).stack;
|
|
271
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
272
|
+
const len1 = WASM_VECTOR_LEN;
|
|
273
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
274
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
275
|
+
};
|
|
276
|
+
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
277
|
+
let deferred0_0;
|
|
278
|
+
let deferred0_1;
|
|
279
|
+
try {
|
|
280
|
+
deferred0_0 = arg0;
|
|
281
|
+
deferred0_1 = arg1;
|
|
282
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
283
|
+
} finally {
|
|
284
|
+
wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
imports.wbg.__wbg_readfile_8efacfffd6a3a749 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
288
|
+
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
289
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
290
|
+
const len1 = WASM_VECTOR_LEN;
|
|
291
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
292
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
293
|
+
}, arguments) };
|
|
294
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
295
|
+
const ret = getObject(arg0);
|
|
296
|
+
return addHeapObject(ret);
|
|
297
|
+
};
|
|
298
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
299
|
+
const obj = getObject(arg1);
|
|
300
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
301
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
302
|
+
var len1 = WASM_VECTOR_LEN;
|
|
303
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
304
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
305
|
+
};
|
|
306
|
+
imports.wbg.__wbg_static_accessor_SYMBOL_45d4d15e3c4aeb33 = function() {
|
|
307
|
+
const ret = Symbol;
|
|
308
|
+
return addHeapObject(ret);
|
|
309
|
+
};
|
|
310
|
+
imports.wbg.__wbindgen_is_symbol = function(arg0) {
|
|
311
|
+
const ret = typeof(getObject(arg0)) === 'symbol';
|
|
312
|
+
return ret;
|
|
313
|
+
};
|
|
314
|
+
imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
|
|
315
|
+
console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
316
|
+
};
|
|
317
|
+
imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
|
|
318
|
+
console.error(getObject(arg0));
|
|
319
|
+
};
|
|
320
|
+
imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
|
|
321
|
+
console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
322
|
+
};
|
|
323
|
+
imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
|
|
324
|
+
console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
325
|
+
};
|
|
326
|
+
imports.wbg.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
|
|
327
|
+
console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
328
|
+
};
|
|
329
|
+
imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
|
|
330
|
+
console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
331
|
+
};
|
|
332
|
+
imports.wbg.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) {
|
|
333
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
334
|
+
return addHeapObject(ret);
|
|
335
|
+
}, arguments) };
|
|
336
|
+
imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
|
|
337
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
338
|
+
return addHeapObject(ret);
|
|
339
|
+
}, arguments) };
|
|
340
|
+
imports.wbg.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
|
|
341
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
342
|
+
return addHeapObject(ret);
|
|
343
|
+
}, arguments) };
|
|
344
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
345
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
return imports;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function __wbg_finalize_init(instance, module) {
|
|
356
|
+
wasm = instance.exports;
|
|
357
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
358
|
+
cachedInt32Memory0 = null;
|
|
359
|
+
cachedUint8Memory0 = null;
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
return wasm;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function initSync(module) {
|
|
366
|
+
if (wasm !== undefined) return wasm;
|
|
367
|
+
|
|
368
|
+
const imports = __wbg_get_imports();
|
|
369
|
+
|
|
370
|
+
__wbg_init_memory(imports);
|
|
371
|
+
|
|
372
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
373
|
+
module = new WebAssembly.Module(module);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
377
|
+
|
|
378
|
+
return __wbg_finalize_init(instance, module);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
async function __wbg_init(input) {
|
|
382
|
+
if (wasm !== undefined) return wasm;
|
|
383
|
+
|
|
384
|
+
if (typeof input === 'undefined') {
|
|
385
|
+
input = new URL('noir_wasm_bg.wasm', import.meta.url);
|
|
386
|
+
}
|
|
387
|
+
const imports = __wbg_get_imports();
|
|
388
|
+
|
|
389
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
390
|
+
input = fetch(input);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
__wbg_init_memory(imports);
|
|
394
|
+
|
|
395
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
396
|
+
|
|
397
|
+
return __wbg_finalize_init(instance, module);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export { initSync }
|
|
401
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function init_log_level(a: number, b: number): void;
|
|
5
|
+
export function build_info(): number;
|
|
6
|
+
export function acir_read_bytes(a: number, b: number): number;
|
|
7
|
+
export function acir_write_bytes(a: number, b: number): void;
|
|
8
|
+
export function compile(a: number): number;
|
|
9
|
+
export function __wbg_trap_free(a: number): void;
|
|
10
|
+
export function trap___wbgd_downcast_token(): number;
|
|
11
|
+
export function __wbindgen_export_0(a: number): number;
|
|
12
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
13
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
14
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
15
|
+
export function __wbindgen_export_3(a: number): void;
|
package/noir_wasm.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { read_file } from './snippets/fm-cffb18dcbd478425/file_reader.js';
|
|
2
|
-
|
|
3
|
-
let wasm;
|
|
4
|
-
|
|
5
|
-
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
6
|
-
|
|
7
|
-
cachedTextDecoder.decode();
|
|
8
|
-
|
|
9
|
-
let cachedUint8Memory0 = new Uint8Array();
|
|
10
|
-
|
|
11
|
-
function getUint8Memory0() {
|
|
12
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
13
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
-
}
|
|
15
|
-
return cachedUint8Memory0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getStringFromWasm0(ptr, len) {
|
|
19
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const heap = new Array(32).fill(undefined);
|
|
23
|
-
|
|
24
|
-
heap.push(undefined, null, true, false);
|
|
25
|
-
|
|
26
|
-
let heap_next = heap.length;
|
|
27
|
-
|
|
28
|
-
function addHeapObject(obj) {
|
|
29
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
30
|
-
const idx = heap_next;
|
|
31
|
-
heap_next = heap[idx];
|
|
32
|
-
|
|
33
|
-
heap[idx] = obj;
|
|
34
|
-
return idx;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getObject(idx) { return heap[idx]; }
|
|
38
|
-
|
|
39
|
-
let WASM_VECTOR_LEN = 0;
|
|
40
|
-
|
|
41
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
|
42
|
-
|
|
43
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
44
|
-
? function (arg, view) {
|
|
45
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
46
|
-
}
|
|
47
|
-
: function (arg, view) {
|
|
48
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
49
|
-
view.set(buf);
|
|
50
|
-
return {
|
|
51
|
-
read: arg.length,
|
|
52
|
-
written: buf.length
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
57
|
-
|
|
58
|
-
if (realloc === undefined) {
|
|
59
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
60
|
-
const ptr = malloc(buf.length);
|
|
61
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
62
|
-
WASM_VECTOR_LEN = buf.length;
|
|
63
|
-
return ptr;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let len = arg.length;
|
|
67
|
-
let ptr = malloc(len);
|
|
68
|
-
|
|
69
|
-
const mem = getUint8Memory0();
|
|
70
|
-
|
|
71
|
-
let offset = 0;
|
|
72
|
-
|
|
73
|
-
for (; offset < len; offset++) {
|
|
74
|
-
const code = arg.charCodeAt(offset);
|
|
75
|
-
if (code > 0x7F) break;
|
|
76
|
-
mem[ptr + offset] = code;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (offset !== len) {
|
|
80
|
-
if (offset !== 0) {
|
|
81
|
-
arg = arg.slice(offset);
|
|
82
|
-
}
|
|
83
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
84
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
85
|
-
const ret = encodeString(arg, view);
|
|
86
|
-
|
|
87
|
-
offset += ret.written;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
WASM_VECTOR_LEN = offset;
|
|
91
|
-
return ptr;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let cachedInt32Memory0 = new Int32Array();
|
|
95
|
-
|
|
96
|
-
function getInt32Memory0() {
|
|
97
|
-
if (cachedInt32Memory0.byteLength === 0) {
|
|
98
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
99
|
-
}
|
|
100
|
-
return cachedInt32Memory0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function dropObject(idx) {
|
|
104
|
-
if (idx < 36) return;
|
|
105
|
-
heap[idx] = heap_next;
|
|
106
|
-
heap_next = idx;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function takeObject(idx) {
|
|
110
|
-
const ret = getObject(idx);
|
|
111
|
-
dropObject(idx);
|
|
112
|
-
return ret;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @param {string} src
|
|
116
|
-
* @returns {any}
|
|
117
|
-
*/
|
|
118
|
-
export function compile(src) {
|
|
119
|
-
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
120
|
-
const len0 = WASM_VECTOR_LEN;
|
|
121
|
-
const ret = wasm.compile(ptr0, len0);
|
|
122
|
-
return takeObject(ret);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
126
|
-
const ptr = malloc(arg.length * 1);
|
|
127
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
128
|
-
WASM_VECTOR_LEN = arg.length;
|
|
129
|
-
return ptr;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* @param {Uint8Array} bytes
|
|
133
|
-
* @returns {any}
|
|
134
|
-
*/
|
|
135
|
-
export function acir_from_bytes(bytes) {
|
|
136
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
137
|
-
const len0 = WASM_VECTOR_LEN;
|
|
138
|
-
const ret = wasm.acir_from_bytes(ptr0, len0);
|
|
139
|
-
return takeObject(ret);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
143
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* @param {any} acir
|
|
147
|
-
* @returns {Uint8Array}
|
|
148
|
-
*/
|
|
149
|
-
export function acir_to_bytes(acir) {
|
|
150
|
-
try {
|
|
151
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
152
|
-
wasm.acir_to_bytes(retptr, addHeapObject(acir));
|
|
153
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
154
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
155
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
156
|
-
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
157
|
-
return v0;
|
|
158
|
-
} finally {
|
|
159
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function handleError(f, args) {
|
|
164
|
-
try {
|
|
165
|
-
return f.apply(this, args);
|
|
166
|
-
} catch (e) {
|
|
167
|
-
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async function load(module, imports) {
|
|
172
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
173
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
174
|
-
try {
|
|
175
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
176
|
-
|
|
177
|
-
} catch (e) {
|
|
178
|
-
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
179
|
-
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);
|
|
180
|
-
|
|
181
|
-
} else {
|
|
182
|
-
throw e;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const bytes = await module.arrayBuffer();
|
|
188
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
192
|
-
|
|
193
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
194
|
-
return { instance, module };
|
|
195
|
-
|
|
196
|
-
} else {
|
|
197
|
-
return instance;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function getImports() {
|
|
203
|
-
const imports = {};
|
|
204
|
-
imports.wbg = {};
|
|
205
|
-
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
|
|
206
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
207
|
-
return addHeapObject(ret);
|
|
208
|
-
};
|
|
209
|
-
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
210
|
-
const obj = getObject(arg1);
|
|
211
|
-
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
212
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
213
|
-
const len0 = WASM_VECTOR_LEN;
|
|
214
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
215
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
216
|
-
};
|
|
217
|
-
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
218
|
-
takeObject(arg0);
|
|
219
|
-
};
|
|
220
|
-
imports.wbg.__wbg_readfile_a255adfa6d841e23 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
221
|
-
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
222
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
223
|
-
const len0 = WASM_VECTOR_LEN;
|
|
224
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
225
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
226
|
-
}, arguments) };
|
|
227
|
-
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
228
|
-
const ret = new Error();
|
|
229
|
-
return addHeapObject(ret);
|
|
230
|
-
};
|
|
231
|
-
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
232
|
-
const ret = getObject(arg1).stack;
|
|
233
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
234
|
-
const len0 = WASM_VECTOR_LEN;
|
|
235
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
236
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
237
|
-
};
|
|
238
|
-
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
239
|
-
try {
|
|
240
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
241
|
-
} finally {
|
|
242
|
-
wasm.__wbindgen_export_2(arg0, arg1);
|
|
243
|
-
}
|
|
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
|
-
cachedInt32Memory0 = new Int32Array();
|
|
257
|
-
cachedUint8Memory0 = new Uint8Array();
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return wasm;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function initSync(module) {
|
|
264
|
-
const imports = getImports();
|
|
265
|
-
|
|
266
|
-
initMemory(imports);
|
|
267
|
-
|
|
268
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
269
|
-
module = new WebAssembly.Module(module);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
273
|
-
|
|
274
|
-
return finalizeInit(instance, module);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async function init(input) {
|
|
278
|
-
if (typeof input === 'undefined') {
|
|
279
|
-
input = new URL('noir_wasm_bg.wasm', import.meta.url);
|
|
280
|
-
}
|
|
281
|
-
const imports = getImports();
|
|
282
|
-
|
|
283
|
-
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
284
|
-
input = fetch(input);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
initMemory(imports);
|
|
288
|
-
|
|
289
|
-
const { instance, module } = await load(await input, imports);
|
|
290
|
-
|
|
291
|
-
return finalizeInit(instance, module);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export { initSync }
|
|
295
|
-
export default init;
|
package/noir_wasm_bg.wasm
DELETED
|
Binary file
|
package/noir_wasm_bg.wasm.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export function compile(a: number, b: number): number;
|
|
5
|
-
export function acir_from_bytes(a: number, b: number): number;
|
|
6
|
-
export function acir_to_bytes(a: number, b: number): void;
|
|
7
|
-
export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
|
|
8
|
-
export function rust_psm_stack_direction(): number;
|
|
9
|
-
export function rust_psm_stack_pointer(): number;
|
|
10
|
-
export function rust_psm_replace_stack(a: number, b: number, c: number): void;
|
|
11
|
-
export function __wbindgen_export_0(a: number): number;
|
|
12
|
-
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
13
|
-
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
14
|
-
export function __wbindgen_export_2(a: number, b: number): void;
|
|
15
|
-
export function __wbindgen_export_3(a: number): void;
|