@noir-lang/noir_wasm 0.3.0 → 0.3.1-07b7576

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@07b7576](https://github.com/noir-lang/noir/tree/07b757611e7838d58bb763140888b7961eb0ff48)
@@ -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;
@@ -1,45 +1,40 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { read_file } = require(String.raw`./snippets/fm-cffb18dcbd478425/file_reader.js`);
5
- const { TextDecoder, TextEncoder } = require(`util`);
4
+ const { read_file } = require(`@noir-lang/noir-source-resolver`);
5
+ const { TextEncoder, TextDecoder } = require(`util`);
6
6
 
7
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
7
+ const heap = new Array(128).fill(undefined);
8
8
 
9
- cachedTextDecoder.decode();
9
+ heap.push(undefined, null, true, false);
10
10
 
11
- let cachedUint8Memory0 = new Uint8Array();
11
+ function getObject(idx) { return heap[idx]; }
12
12
 
13
- function getUint8Memory0() {
14
- if (cachedUint8Memory0.byteLength === 0) {
15
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
16
- }
17
- return cachedUint8Memory0;
18
- }
13
+ let heap_next = heap.length;
19
14
 
20
- function getStringFromWasm0(ptr, len) {
21
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
15
+ function dropObject(idx) {
16
+ if (idx < 132) return;
17
+ heap[idx] = heap_next;
18
+ heap_next = idx;
22
19
  }
23
20
 
24
- const heap = new Array(32).fill(undefined);
25
-
26
- heap.push(undefined, null, true, false);
21
+ function takeObject(idx) {
22
+ const ret = getObject(idx);
23
+ dropObject(idx);
24
+ return ret;
25
+ }
27
26
 
28
- let heap_next = heap.length;
27
+ let WASM_VECTOR_LEN = 0;
29
28
 
30
- function addHeapObject(obj) {
31
- if (heap_next === heap.length) heap.push(heap.length + 1);
32
- const idx = heap_next;
33
- heap_next = heap[idx];
29
+ let cachedUint8Memory0 = null;
34
30
 
35
- heap[idx] = obj;
36
- return idx;
31
+ function getUint8Memory0() {
32
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
33
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
34
+ }
35
+ return cachedUint8Memory0;
37
36
  }
38
37
 
39
- function getObject(idx) { return heap[idx]; }
40
-
41
- let WASM_VECTOR_LEN = 0;
42
-
43
38
  let cachedTextEncoder = new TextEncoder('utf-8');
44
39
 
45
40
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -93,34 +88,41 @@ function passStringToWasm0(arg, malloc, realloc) {
93
88
  return ptr;
94
89
  }
95
90
 
96
- let cachedInt32Memory0 = new Int32Array();
91
+ function isLikeNone(x) {
92
+ return x === undefined || x === null;
93
+ }
94
+
95
+ let cachedInt32Memory0 = null;
97
96
 
98
97
  function getInt32Memory0() {
99
- if (cachedInt32Memory0.byteLength === 0) {
98
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
100
99
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
101
100
  }
102
101
  return cachedInt32Memory0;
103
102
  }
104
103
 
105
- function dropObject(idx) {
106
- if (idx < 36) return;
107
- heap[idx] = heap_next;
108
- heap_next = idx;
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));
109
110
  }
110
111
 
111
- function takeObject(idx) {
112
- const ret = getObject(idx);
113
- dropObject(idx);
114
- return ret;
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;
115
119
  }
116
120
  /**
117
- * @param {string} src
121
+ * @param {any} args
118
122
  * @returns {any}
119
123
  */
120
- module.exports.compile = function(src) {
121
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
122
- const len0 = WASM_VECTOR_LEN;
123
- const ret = wasm.compile(ptr0, len0);
124
+ module.exports.compile = function(args) {
125
+ const ret = wasm.compile(addHeapObject(args));
124
126
  return takeObject(ret);
125
127
  };
126
128
 
@@ -162,6 +164,43 @@ module.exports.acir_to_bytes = function(acir) {
162
164
  }
163
165
  };
164
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
+
165
204
  function handleError(f, args) {
166
205
  try {
167
206
  return f.apply(this, args);
@@ -170,38 +209,21 @@ function handleError(f, args) {
170
209
  }
171
210
  }
172
211
 
173
- module.exports.__wbindgen_json_parse = function(arg0, arg1) {
174
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
175
- return addHeapObject(ret);
176
- };
177
-
178
- module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
179
- const obj = getObject(arg1);
180
- const ret = JSON.stringify(obj === undefined ? null : obj);
181
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
182
- const len0 = WASM_VECTOR_LEN;
183
- getInt32Memory0()[arg0 / 4 + 1] = len0;
184
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
212
+ module.exports.__wbindgen_is_undefined = function(arg0) {
213
+ const ret = getObject(arg0) === undefined;
214
+ return ret;
185
215
  };
186
216
 
187
217
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
188
218
  takeObject(arg0);
189
219
  };
190
220
 
191
- module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError(function (arg0, arg1, arg2) {
192
- const ret = read_file(getStringFromWasm0(arg1, arg2));
193
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
194
- const len0 = WASM_VECTOR_LEN;
195
- getInt32Memory0()[arg0 / 4 + 1] = len0;
196
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
197
- }, arguments) };
198
-
199
- module.exports.__wbg_new_693216e109162396 = function() {
221
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
200
222
  const ret = new Error();
201
223
  return addHeapObject(ret);
202
224
  };
203
225
 
204
- module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
226
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
205
227
  const ret = getObject(arg1).stack;
206
228
  const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
207
229
  const len0 = WASM_VECTOR_LEN;
@@ -209,7 +231,7 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
209
231
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
210
232
  };
211
233
 
212
- module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
234
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
213
235
  try {
214
236
  console.error(getStringFromWasm0(arg0, arg1));
215
237
  } finally {
@@ -217,6 +239,37 @@ module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
217
239
  }
218
240
  };
219
241
 
242
+ module.exports.__wbg_readfile_1583649552f79b9c = 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
+
220
273
  const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
221
274
  const bytes = require('fs').readFileSync(path);
222
275
 
Binary file
@@ -1,13 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function compile(a: number, b: number): number;
4
+ export function compile(a: number): number;
5
5
  export function acir_from_bytes(a: number, b: number): number;
6
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;
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;
11
10
  export function __wbindgen_export_0(a: number): number;
12
11
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
13
12
  export function __wbindgen_add_to_stack_pointer(a: number): number;
package/package.json CHANGED
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "version": "0.3.0",
3
+ "collaborators": [
4
+ "The Noir Team <kevtheappdev@gmail.com>"
5
+ ],
6
+ "version": "0.3.1-07b7576",
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": "07b757611e7838d58bb763140888b7961eb0ff48"
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_1583649552f79b9c = 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,17 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {string} src
5
- * @returns {any}
6
- */
7
- export function compile(src: string): 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;
package/noir_wasm_bg.wasm DELETED
Binary file
@@ -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
- };