@noir-lang/noir_wasm 0.2.0 → 0.3.0-e7fea94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Noir Lang WASM JavaScript Package
2
+
3
+ ## Tracks
4
+ Noir lang Repository [noir-lang/noir@e7fea94](https://github.com/noir-lang/noir/tree/e7fea94b0921a5c35cebc7024c61feb1d1d235bb)
@@ -0,0 +1,31 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {any} args
5
+ * @returns {any}
6
+ */
7
+ export function compile(args: any): any;
8
+ /**
9
+ * @param {Uint8Array} bytes
10
+ * @returns {any}
11
+ */
12
+ export function acir_from_bytes(bytes: Uint8Array): any;
13
+ /**
14
+ * @param {any} acir
15
+ * @returns {Uint8Array}
16
+ */
17
+ export function acir_to_bytes(acir: any): Uint8Array;
18
+ /**
19
+ * @param {Uint8Array} bytes
20
+ * @returns {any}
21
+ */
22
+ export function acir_read_bytes(bytes: Uint8Array): any;
23
+ /**
24
+ * @param {any} acir
25
+ * @returns {Uint8Array}
26
+ */
27
+ export function acir_write_bytes(acir: any): Uint8Array;
28
+ /**
29
+ * @returns {any}
30
+ */
31
+ export function build_info(): any;
@@ -0,0 +1,280 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { read_file } = require(`@noir-lang/noir-source-resolver`);
5
+ const { TextEncoder, TextDecoder } = 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 WASM_VECTOR_LEN = 0;
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
+ let cachedTextEncoder = new TextEncoder('utf-8');
39
+
40
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
41
+ ? function (arg, view) {
42
+ return cachedTextEncoder.encodeInto(arg, view);
43
+ }
44
+ : function (arg, view) {
45
+ const buf = cachedTextEncoder.encode(arg);
46
+ view.set(buf);
47
+ return {
48
+ read: arg.length,
49
+ written: buf.length
50
+ };
51
+ });
52
+
53
+ function passStringToWasm0(arg, malloc, realloc) {
54
+
55
+ if (realloc === undefined) {
56
+ const buf = cachedTextEncoder.encode(arg);
57
+ const ptr = malloc(buf.length);
58
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
59
+ WASM_VECTOR_LEN = buf.length;
60
+ return ptr;
61
+ }
62
+
63
+ let len = arg.length;
64
+ let ptr = malloc(len);
65
+
66
+ const mem = getUint8Memory0();
67
+
68
+ let offset = 0;
69
+
70
+ for (; offset < len; offset++) {
71
+ const code = arg.charCodeAt(offset);
72
+ if (code > 0x7F) break;
73
+ mem[ptr + offset] = code;
74
+ }
75
+
76
+ if (offset !== len) {
77
+ if (offset !== 0) {
78
+ arg = arg.slice(offset);
79
+ }
80
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
81
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
82
+ const ret = encodeString(arg, view);
83
+
84
+ offset += ret.written;
85
+ }
86
+
87
+ WASM_VECTOR_LEN = offset;
88
+ return ptr;
89
+ }
90
+
91
+ function isLikeNone(x) {
92
+ return x === undefined || x === null;
93
+ }
94
+
95
+ let cachedInt32Memory0 = null;
96
+
97
+ function getInt32Memory0() {
98
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
99
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
100
+ }
101
+ return cachedInt32Memory0;
102
+ }
103
+
104
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
105
+
106
+ cachedTextDecoder.decode();
107
+
108
+ function getStringFromWasm0(ptr, len) {
109
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
110
+ }
111
+
112
+ function addHeapObject(obj) {
113
+ if (heap_next === heap.length) heap.push(heap.length + 1);
114
+ const idx = heap_next;
115
+ heap_next = heap[idx];
116
+
117
+ heap[idx] = obj;
118
+ return idx;
119
+ }
120
+ /**
121
+ * @param {any} args
122
+ * @returns {any}
123
+ */
124
+ module.exports.compile = function(args) {
125
+ const ret = wasm.compile(addHeapObject(args));
126
+ return takeObject(ret);
127
+ };
128
+
129
+ function passArray8ToWasm0(arg, malloc) {
130
+ const ptr = malloc(arg.length * 1);
131
+ getUint8Memory0().set(arg, ptr / 1);
132
+ WASM_VECTOR_LEN = arg.length;
133
+ return ptr;
134
+ }
135
+ /**
136
+ * @param {Uint8Array} bytes
137
+ * @returns {any}
138
+ */
139
+ module.exports.acir_from_bytes = function(bytes) {
140
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
141
+ const len0 = WASM_VECTOR_LEN;
142
+ const ret = wasm.acir_from_bytes(ptr0, len0);
143
+ return takeObject(ret);
144
+ };
145
+
146
+ function getArrayU8FromWasm0(ptr, len) {
147
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
148
+ }
149
+ /**
150
+ * @param {any} acir
151
+ * @returns {Uint8Array}
152
+ */
153
+ module.exports.acir_to_bytes = function(acir) {
154
+ try {
155
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
+ wasm.acir_to_bytes(retptr, addHeapObject(acir));
157
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
158
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
159
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
160
+ wasm.__wbindgen_export_2(r0, r1 * 1);
161
+ return v0;
162
+ } finally {
163
+ wasm.__wbindgen_add_to_stack_pointer(16);
164
+ }
165
+ };
166
+
167
+ /**
168
+ * @param {Uint8Array} bytes
169
+ * @returns {any}
170
+ */
171
+ module.exports.acir_read_bytes = function(bytes) {
172
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
173
+ const len0 = WASM_VECTOR_LEN;
174
+ const ret = wasm.acir_read_bytes(ptr0, len0);
175
+ return takeObject(ret);
176
+ };
177
+
178
+ /**
179
+ * @param {any} acir
180
+ * @returns {Uint8Array}
181
+ */
182
+ module.exports.acir_write_bytes = function(acir) {
183
+ try {
184
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
185
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
186
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
187
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
188
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
189
+ wasm.__wbindgen_export_2(r0, r1 * 1);
190
+ return v0;
191
+ } finally {
192
+ wasm.__wbindgen_add_to_stack_pointer(16);
193
+ }
194
+ };
195
+
196
+ /**
197
+ * @returns {any}
198
+ */
199
+ module.exports.build_info = function() {
200
+ const ret = wasm.build_info();
201
+ return takeObject(ret);
202
+ };
203
+
204
+ function handleError(f, args) {
205
+ try {
206
+ return f.apply(this, args);
207
+ } catch (e) {
208
+ wasm.__wbindgen_export_3(addHeapObject(e));
209
+ }
210
+ }
211
+
212
+ module.exports.__wbindgen_is_undefined = function(arg0) {
213
+ const ret = getObject(arg0) === undefined;
214
+ return ret;
215
+ };
216
+
217
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
218
+ takeObject(arg0);
219
+ };
220
+
221
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
222
+ const ret = new Error();
223
+ return addHeapObject(ret);
224
+ };
225
+
226
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
227
+ const ret = getObject(arg1).stack;
228
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
229
+ const len0 = WASM_VECTOR_LEN;
230
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
231
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
232
+ };
233
+
234
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
235
+ try {
236
+ console.error(getStringFromWasm0(arg0, arg1));
237
+ } finally {
238
+ wasm.__wbindgen_export_2(arg0, arg1);
239
+ }
240
+ };
241
+
242
+ module.exports.__wbg_readfile_af3dcb3ef9845626 = function() { return handleError(function (arg0, arg1, arg2) {
243
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
244
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
245
+ const len0 = WASM_VECTOR_LEN;
246
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
247
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
248
+ }, arguments) };
249
+
250
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
251
+ const obj = getObject(arg1);
252
+ const ret = typeof(obj) === 'string' ? obj : undefined;
253
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
254
+ var len0 = WASM_VECTOR_LEN;
255
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
256
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
257
+ };
258
+
259
+ module.exports.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
260
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
261
+ return addHeapObject(ret);
262
+ }, arguments) };
263
+
264
+ module.exports.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
265
+ const ret = JSON.stringify(getObject(arg0));
266
+ return addHeapObject(ret);
267
+ }, arguments) };
268
+
269
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
270
+ throw new Error(getStringFromWasm0(arg0, arg1));
271
+ };
272
+
273
+ const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
274
+ const bytes = require('fs').readFileSync(path);
275
+
276
+ const wasmModule = new WebAssembly.Module(bytes);
277
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
278
+ wasm = wasmInstance.exports;
279
+ module.exports.__wasm = wasm;
280
+
Binary file
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function compile(a: 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 acir_read_bytes(a: number, b: number): number;
8
+ export function acir_write_bytes(a: number, b: number): void;
9
+ export function build_info(): number;
10
+ export function __wbindgen_export_0(a: number): number;
11
+ export function __wbindgen_export_1(a: number, b: number, c: number): number;
12
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
13
+ export function __wbindgen_export_2(a: number, b: number): void;
14
+ export function __wbindgen_export_3(a: number): void;
package/package.json CHANGED
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "version": "0.2.0",
3
+ "collaborators": [
4
+ "The Noir Team <kevtheappdev@gmail.com>"
5
+ ],
6
+ "version": "0.3.0-e7fea94",
4
7
  "files": [
5
- "noir_wasm_bg.wasm",
6
- "noir_wasm.js",
7
- "noir_wasm_bg.wasm.d.ts",
8
- "noir_wasm.d.ts",
9
- "snippets/*"
8
+ "nodejs",
9
+ "web",
10
+ "package.json"
10
11
  ],
11
- "main": "noir_wasm.js",
12
- "types": "noir_wasm.d.ts"
13
- }
12
+ "main": "./nodejs/noir_wasm.js",
13
+ "types": "./web/noir_wasm.d.ts",
14
+ "module": "./web/noir_wasm.js",
15
+ "sideEffects": false,
16
+ "peerDependencies": {
17
+ "@noir-lang/noir-source-resolver": "1.0.0"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/noir-lang/noir_wasm.git"
22
+ },
23
+ "compiler": {
24
+ "versionHash": "e7fea94b0921a5c35cebc7024c61feb1d1d235bb"
25
+ }
26
+ }
@@ -0,0 +1,69 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {any} args
5
+ * @returns {any}
6
+ */
7
+ export function compile(args: any): any;
8
+ /**
9
+ * @param {Uint8Array} bytes
10
+ * @returns {any}
11
+ */
12
+ export function acir_from_bytes(bytes: Uint8Array): any;
13
+ /**
14
+ * @param {any} acir
15
+ * @returns {Uint8Array}
16
+ */
17
+ export function acir_to_bytes(acir: any): Uint8Array;
18
+ /**
19
+ * @param {Uint8Array} bytes
20
+ * @returns {any}
21
+ */
22
+ export function acir_read_bytes(bytes: Uint8Array): any;
23
+ /**
24
+ * @param {any} acir
25
+ * @returns {Uint8Array}
26
+ */
27
+ export function acir_write_bytes(acir: any): Uint8Array;
28
+ /**
29
+ * @returns {any}
30
+ */
31
+ export function build_info(): any;
32
+
33
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
34
+
35
+ export interface InitOutput {
36
+ readonly memory: WebAssembly.Memory;
37
+ readonly compile: (a: number) => number;
38
+ readonly acir_from_bytes: (a: number, b: number) => number;
39
+ readonly acir_to_bytes: (a: number, b: number) => void;
40
+ readonly acir_read_bytes: (a: number, b: number) => number;
41
+ readonly acir_write_bytes: (a: number, b: number) => void;
42
+ readonly build_info: () => number;
43
+ readonly __wbindgen_export_0: (a: number) => number;
44
+ readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
45
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
46
+ readonly __wbindgen_export_2: (a: number, b: number) => void;
47
+ readonly __wbindgen_export_3: (a: number) => void;
48
+ }
49
+
50
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
51
+ /**
52
+ * Instantiates the given `module`, which can either be bytes or
53
+ * a precompiled `WebAssembly.Module`.
54
+ *
55
+ * @param {SyncInitInput} module
56
+ *
57
+ * @returns {InitOutput}
58
+ */
59
+ export function initSync(module: SyncInitInput): InitOutput;
60
+
61
+ /**
62
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
63
+ * for everything else, calls `WebAssembly.instantiate` directly.
64
+ *
65
+ * @param {InitInput | Promise<InitInput>} module_or_path
66
+ *
67
+ * @returns {Promise<InitOutput>}
68
+ */
69
+ export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,345 @@
1
+ import { read_file } from '@noir-lang/noir-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
+ let WASM_VECTOR_LEN = 0;
26
+
27
+ let cachedUint8Memory0 = null;
28
+
29
+ function getUint8Memory0() {
30
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
31
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
32
+ }
33
+ return cachedUint8Memory0;
34
+ }
35
+
36
+ const cachedTextEncoder = new TextEncoder('utf-8');
37
+
38
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
39
+ ? function (arg, view) {
40
+ return cachedTextEncoder.encodeInto(arg, view);
41
+ }
42
+ : function (arg, view) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ view.set(buf);
45
+ return {
46
+ read: arg.length,
47
+ written: buf.length
48
+ };
49
+ });
50
+
51
+ function passStringToWasm0(arg, malloc, realloc) {
52
+
53
+ if (realloc === undefined) {
54
+ const buf = cachedTextEncoder.encode(arg);
55
+ const ptr = malloc(buf.length);
56
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
57
+ WASM_VECTOR_LEN = buf.length;
58
+ return ptr;
59
+ }
60
+
61
+ let len = arg.length;
62
+ let ptr = malloc(len);
63
+
64
+ const mem = getUint8Memory0();
65
+
66
+ let offset = 0;
67
+
68
+ for (; offset < len; offset++) {
69
+ const code = arg.charCodeAt(offset);
70
+ if (code > 0x7F) break;
71
+ mem[ptr + offset] = code;
72
+ }
73
+
74
+ if (offset !== len) {
75
+ if (offset !== 0) {
76
+ arg = arg.slice(offset);
77
+ }
78
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
79
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
80
+ const ret = encodeString(arg, view);
81
+
82
+ offset += ret.written;
83
+ }
84
+
85
+ WASM_VECTOR_LEN = offset;
86
+ return ptr;
87
+ }
88
+
89
+ function isLikeNone(x) {
90
+ return x === undefined || x === null;
91
+ }
92
+
93
+ let cachedInt32Memory0 = null;
94
+
95
+ function getInt32Memory0() {
96
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
97
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
98
+ }
99
+ return cachedInt32Memory0;
100
+ }
101
+
102
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
103
+
104
+ cachedTextDecoder.decode();
105
+
106
+ function getStringFromWasm0(ptr, len) {
107
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
108
+ }
109
+
110
+ function addHeapObject(obj) {
111
+ if (heap_next === heap.length) heap.push(heap.length + 1);
112
+ const idx = heap_next;
113
+ heap_next = heap[idx];
114
+
115
+ heap[idx] = obj;
116
+ return idx;
117
+ }
118
+ /**
119
+ * @param {any} args
120
+ * @returns {any}
121
+ */
122
+ export function compile(args) {
123
+ const ret = wasm.compile(addHeapObject(args));
124
+ return takeObject(ret);
125
+ }
126
+
127
+ function passArray8ToWasm0(arg, malloc) {
128
+ const ptr = malloc(arg.length * 1);
129
+ getUint8Memory0().set(arg, ptr / 1);
130
+ WASM_VECTOR_LEN = arg.length;
131
+ return ptr;
132
+ }
133
+ /**
134
+ * @param {Uint8Array} bytes
135
+ * @returns {any}
136
+ */
137
+ export function acir_from_bytes(bytes) {
138
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ret = wasm.acir_from_bytes(ptr0, len0);
141
+ return takeObject(ret);
142
+ }
143
+
144
+ function getArrayU8FromWasm0(ptr, len) {
145
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
146
+ }
147
+ /**
148
+ * @param {any} acir
149
+ * @returns {Uint8Array}
150
+ */
151
+ export function acir_to_bytes(acir) {
152
+ try {
153
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
154
+ wasm.acir_to_bytes(retptr, addHeapObject(acir));
155
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
156
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
157
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
158
+ wasm.__wbindgen_export_2(r0, r1 * 1);
159
+ return v0;
160
+ } finally {
161
+ wasm.__wbindgen_add_to_stack_pointer(16);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * @param {Uint8Array} bytes
167
+ * @returns {any}
168
+ */
169
+ export function acir_read_bytes(bytes) {
170
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
171
+ const len0 = WASM_VECTOR_LEN;
172
+ const ret = wasm.acir_read_bytes(ptr0, len0);
173
+ return takeObject(ret);
174
+ }
175
+
176
+ /**
177
+ * @param {any} acir
178
+ * @returns {Uint8Array}
179
+ */
180
+ export function acir_write_bytes(acir) {
181
+ try {
182
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
183
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
184
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
185
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
186
+ var v0 = getArrayU8FromWasm0(r0, r1).slice();
187
+ wasm.__wbindgen_export_2(r0, r1 * 1);
188
+ return v0;
189
+ } finally {
190
+ wasm.__wbindgen_add_to_stack_pointer(16);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * @returns {any}
196
+ */
197
+ export function build_info() {
198
+ const ret = wasm.build_info();
199
+ return takeObject(ret);
200
+ }
201
+
202
+ function handleError(f, args) {
203
+ try {
204
+ return f.apply(this, args);
205
+ } catch (e) {
206
+ wasm.__wbindgen_export_3(addHeapObject(e));
207
+ }
208
+ }
209
+
210
+ async function load(module, imports) {
211
+ if (typeof Response === 'function' && module instanceof Response) {
212
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
213
+ try {
214
+ return await WebAssembly.instantiateStreaming(module, imports);
215
+
216
+ } catch (e) {
217
+ if (module.headers.get('Content-Type') != 'application/wasm') {
218
+ 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);
219
+
220
+ } else {
221
+ throw e;
222
+ }
223
+ }
224
+ }
225
+
226
+ const bytes = await module.arrayBuffer();
227
+ return await WebAssembly.instantiate(bytes, imports);
228
+
229
+ } else {
230
+ const instance = await WebAssembly.instantiate(module, imports);
231
+
232
+ if (instance instanceof WebAssembly.Instance) {
233
+ return { instance, module };
234
+
235
+ } else {
236
+ return instance;
237
+ }
238
+ }
239
+ }
240
+
241
+ function getImports() {
242
+ const imports = {};
243
+ imports.wbg = {};
244
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
245
+ const ret = getObject(arg0) === undefined;
246
+ return ret;
247
+ };
248
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
249
+ takeObject(arg0);
250
+ };
251
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
252
+ const ret = new Error();
253
+ return addHeapObject(ret);
254
+ };
255
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
256
+ const ret = getObject(arg1).stack;
257
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
260
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
261
+ };
262
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
263
+ try {
264
+ console.error(getStringFromWasm0(arg0, arg1));
265
+ } finally {
266
+ wasm.__wbindgen_export_2(arg0, arg1);
267
+ }
268
+ };
269
+ imports.wbg.__wbg_readfile_af3dcb3ef9845626 = function() { return handleError(function (arg0, arg1, arg2) {
270
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
271
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
274
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
275
+ }, arguments) };
276
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
277
+ const obj = getObject(arg1);
278
+ const ret = typeof(obj) === 'string' ? obj : undefined;
279
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
280
+ var len0 = WASM_VECTOR_LEN;
281
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
282
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
283
+ };
284
+ imports.wbg.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
285
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
286
+ return addHeapObject(ret);
287
+ }, arguments) };
288
+ imports.wbg.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
289
+ const ret = JSON.stringify(getObject(arg0));
290
+ return addHeapObject(ret);
291
+ }, arguments) };
292
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
293
+ throw new Error(getStringFromWasm0(arg0, arg1));
294
+ };
295
+
296
+ return imports;
297
+ }
298
+
299
+ function initMemory(imports, maybe_memory) {
300
+
301
+ }
302
+
303
+ function finalizeInit(instance, module) {
304
+ wasm = instance.exports;
305
+ init.__wbindgen_wasm_module = module;
306
+ cachedInt32Memory0 = null;
307
+ cachedUint8Memory0 = null;
308
+
309
+
310
+ return wasm;
311
+ }
312
+
313
+ function initSync(module) {
314
+ const imports = getImports();
315
+
316
+ initMemory(imports);
317
+
318
+ if (!(module instanceof WebAssembly.Module)) {
319
+ module = new WebAssembly.Module(module);
320
+ }
321
+
322
+ const instance = new WebAssembly.Instance(module, imports);
323
+
324
+ return finalizeInit(instance, module);
325
+ }
326
+
327
+ async function init(input) {
328
+ if (typeof input === 'undefined') {
329
+ input = new URL('noir_wasm_bg.wasm', import.meta.url);
330
+ }
331
+ const imports = getImports();
332
+
333
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
334
+ input = fetch(input);
335
+ }
336
+
337
+ initMemory(imports);
338
+
339
+ const { instance, module } = await load(await input, imports);
340
+
341
+ return finalizeInit(instance, module);
342
+ }
343
+
344
+ export { initSync }
345
+ export default init;
Binary file
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function compile(a: 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 acir_read_bytes(a: number, b: number): number;
8
+ export function acir_write_bytes(a: number, b: number): void;
9
+ export function build_info(): number;
10
+ export function __wbindgen_export_0(a: number): number;
11
+ export function __wbindgen_export_1(a: number, b: number, c: number): number;
12
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
13
+ export function __wbindgen_export_2(a: number, b: number): void;
14
+ export function __wbindgen_export_3(a: number): void;
package/noir_wasm.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {string} src
5
- * @returns {any}
6
- */
7
- export function compile(src: string): any;
package/noir_wasm.js DELETED
@@ -1,181 +0,0 @@
1
- let imports = {};
2
- imports['__wbindgen_placeholder__'] = module.exports;
3
- let wasm;
4
- const { read_file } = require(String.raw`./snippets/fm-cffb18dcbd478425/file_reader.js`);
5
- const { TextDecoder, TextEncoder } = require(`util`);
6
-
7
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
8
-
9
- cachedTextDecoder.decode();
10
-
11
- let cachedUint8Memory0;
12
- function getUint8Memory0() {
13
- if (cachedUint8Memory0.byteLength === 0) {
14
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
15
- }
16
- return cachedUint8Memory0;
17
- }
18
-
19
- function getStringFromWasm0(ptr, len) {
20
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
21
- }
22
-
23
- const heap = new Array(32).fill(undefined);
24
-
25
- heap.push(undefined, null, true, false);
26
-
27
- let heap_next = heap.length;
28
-
29
- function addHeapObject(obj) {
30
- if (heap_next === heap.length) heap.push(heap.length + 1);
31
- const idx = heap_next;
32
- heap_next = heap[idx];
33
-
34
- heap[idx] = obj;
35
- return idx;
36
- }
37
-
38
- function getObject(idx) { return heap[idx]; }
39
-
40
- function dropObject(idx) {
41
- if (idx < 36) return;
42
- heap[idx] = heap_next;
43
- heap_next = idx;
44
- }
45
-
46
- function takeObject(idx) {
47
- const ret = getObject(idx);
48
- dropObject(idx);
49
- return ret;
50
- }
51
-
52
- let WASM_VECTOR_LEN = 0;
53
-
54
- let cachedTextEncoder = new TextEncoder('utf-8');
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);
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);
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);
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
- * @param {string} src
108
- * @returns {any}
109
- */
110
- module.exports.compile = function(src) {
111
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
112
- const len0 = WASM_VECTOR_LEN;
113
- const ret = wasm.compile(ptr0, len0);
114
- return takeObject(ret);
115
- };
116
-
117
- let cachedInt32Memory0;
118
- function getInt32Memory0() {
119
- if (cachedInt32Memory0.byteLength === 0) {
120
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
121
- }
122
- return cachedInt32Memory0;
123
- }
124
-
125
- function handleError(f, args) {
126
- try {
127
- return f.apply(this, args);
128
- } catch (e) {
129
- wasm.__wbindgen_export_2(addHeapObject(e));
130
- }
131
- }
132
-
133
- module.exports.__wbindgen_json_parse = function(arg0, arg1) {
134
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
135
- return addHeapObject(ret);
136
- };
137
-
138
- module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError(function (arg0, arg1, arg2) {
139
- const ret = read_file(getStringFromWasm0(arg1, arg2));
140
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
- const len0 = WASM_VECTOR_LEN;
142
- getInt32Memory0()[arg0 / 4 + 1] = len0;
143
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
144
- }, arguments) };
145
-
146
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
147
- takeObject(arg0);
148
- };
149
-
150
- module.exports.__wbg_new_693216e109162396 = function() {
151
- const ret = new Error();
152
- return addHeapObject(ret);
153
- };
154
-
155
- module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
156
- const ret = getObject(arg1).stack;
157
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
158
- const len0 = WASM_VECTOR_LEN;
159
- getInt32Memory0()[arg0 / 4 + 1] = len0;
160
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
161
- };
162
-
163
- module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
164
- try {
165
- console.error(getStringFromWasm0(arg0, arg1));
166
- } finally {
167
- wasm.__wbindgen_export_3(arg0, arg1);
168
- }
169
- };
170
-
171
- const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
172
- const bytes = require('fs').readFileSync(path);
173
-
174
- const wasmModule = new WebAssembly.Module(bytes);
175
- const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
176
- wasm = wasmInstance.exports;
177
- module.exports.__wasm = wasm;
178
-
179
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
180
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
181
-
package/noir_wasm_bg.wasm DELETED
Binary file
@@ -1,12 +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 rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
6
- export function rust_psm_stack_direction(): number;
7
- export function rust_psm_stack_pointer(): number;
8
- export function rust_psm_replace_stack(a: number, b: number, c: number): void;
9
- export function __wbindgen_export_0(a: number): number;
10
- export function __wbindgen_export_1(a: number, b: number, c: number): number;
11
- export function __wbindgen_export_2(a: number): void;
12
- export function __wbindgen_export_3(a: number, b: number): void;
@@ -1,6 +0,0 @@
1
- // Synchronously reads a file
2
- const fs = require("fs");
3
-
4
- module.exports.read_file = function (path) {
5
- return fs.readFileSync(path, { encoding: "utf8" });
6
- };