@noir-lang/noir_wasm 0.10.0-f5d04f1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,22 @@
1
1
  # Noir Lang WASM JavaScript Package
2
2
 
3
- ## Tracks
4
- Noir lang Repository [noir-lang/noir@f5d04f1](https://github.com/noir-lang/noir/tree/f5d04f1ec406cb7325de8f81497c7861b89b3a48)
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
+ ```
20
+
21
+ ## Tracking
22
+ Built from [noir-lang/noir@2db759f43971c57e2f1f8284c82943e31a555d0c](https://github.com/noir-lang/noir/tree/2db759f43971c57e2f1f8284c82943e31a555d0c)
@@ -1,17 +1,25 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} src
4
+ * @param {string} level
5
+ */
6
+ export function init_log_level(level: string): void;
7
+ /**
5
8
  * @returns {any}
6
9
  */
7
- export function compile(src: string): any;
10
+ export function build_info(): any;
8
11
  /**
9
12
  * @param {Uint8Array} bytes
10
13
  * @returns {any}
11
14
  */
12
- export function acir_from_bytes(bytes: Uint8Array): any;
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 acir_to_bytes(acir: any): Uint8Array;
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;
@@ -2,9 +2,9 @@ let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
4
  const { read_file } = require(`@noir-lang/noir-source-resolver`);
5
- const { TextEncoder, TextDecoder } = require(`util`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
6
 
7
- const heap = new Array(32).fill(undefined);
7
+ const heap = new Array(128).fill(undefined);
8
8
 
9
9
  heap.push(undefined, null, true, false);
10
10
 
@@ -13,7 +13,7 @@ function getObject(idx) { return heap[idx]; }
13
13
  let heap_next = heap.length;
14
14
 
15
15
  function dropObject(idx) {
16
- if (idx < 36) return;
16
+ if (idx < 132) return;
17
17
  heap[idx] = heap_next;
18
18
  heap_next = idx;
19
19
  }
@@ -24,17 +24,35 @@ function takeObject(idx) {
24
24
  return ret;
25
25
  }
26
26
 
27
- let WASM_VECTOR_LEN = 0;
27
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
28
28
 
29
- let cachedUint8Memory0 = new Uint8Array();
29
+ cachedTextDecoder.decode();
30
+
31
+ let cachedUint8Memory0 = null;
30
32
 
31
33
  function getUint8Memory0() {
32
- if (cachedUint8Memory0.byteLength === 0) {
34
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
33
35
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
34
36
  }
35
37
  return cachedUint8Memory0;
36
38
  }
37
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
+
38
56
  let cachedTextEncoder = new TextEncoder('utf-8');
39
57
 
40
58
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -54,14 +72,14 @@ function passStringToWasm0(arg, malloc, realloc) {
54
72
 
55
73
  if (realloc === undefined) {
56
74
  const buf = cachedTextEncoder.encode(arg);
57
- const ptr = malloc(buf.length);
75
+ const ptr = malloc(buf.length) >>> 0;
58
76
  getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
59
77
  WASM_VECTOR_LEN = buf.length;
60
78
  return ptr;
61
79
  }
62
80
 
63
81
  let len = arg.length;
64
- let ptr = malloc(len);
82
+ let ptr = malloc(len) >>> 0;
65
83
 
66
84
  const mem = getUint8Memory0();
67
85
 
@@ -77,7 +95,7 @@ function passStringToWasm0(arg, malloc, realloc) {
77
95
  if (offset !== 0) {
78
96
  arg = arg.slice(offset);
79
97
  }
80
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
98
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
81
99
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
82
100
  const ret = encodeString(arg, view);
83
101
 
@@ -92,35 +110,33 @@ function isLikeNone(x) {
92
110
  return x === undefined || x === null;
93
111
  }
94
112
 
95
- let cachedInt32Memory0 = new Int32Array();
113
+ let cachedInt32Memory0 = null;
96
114
 
97
115
  function getInt32Memory0() {
98
- if (cachedInt32Memory0.byteLength === 0) {
116
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
99
117
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
100
118
  }
101
119
  return cachedInt32Memory0;
102
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
+ };
103
129
 
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
130
  /**
112
- * @param {string} src
113
131
  * @returns {any}
114
132
  */
115
- module.exports.compile = function(src) {
116
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
117
- const len0 = WASM_VECTOR_LEN;
118
- const ret = wasm.compile(ptr0, len0);
133
+ module.exports.build_info = function() {
134
+ const ret = wasm.build_info();
119
135
  return takeObject(ret);
120
136
  };
121
137
 
122
138
  function passArray8ToWasm0(arg, malloc) {
123
- const ptr = malloc(arg.length * 1);
139
+ const ptr = malloc(arg.length * 1) >>> 0;
124
140
  getUint8Memory0().set(arg, ptr / 1);
125
141
  WASM_VECTOR_LEN = arg.length;
126
142
  return ptr;
@@ -129,43 +145,44 @@ function passArray8ToWasm0(arg, malloc) {
129
145
  * @param {Uint8Array} bytes
130
146
  * @returns {any}
131
147
  */
132
- module.exports.acir_from_bytes = function(bytes) {
148
+ module.exports.acir_read_bytes = function(bytes) {
133
149
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
134
150
  const len0 = WASM_VECTOR_LEN;
135
- const ret = wasm.acir_from_bytes(ptr0, len0);
151
+ const ret = wasm.acir_read_bytes(ptr0, len0);
136
152
  return takeObject(ret);
137
153
  };
138
154
 
139
- function addHeapObject(obj) {
140
- if (heap_next === heap.length) heap.push(heap.length + 1);
141
- const idx = heap_next;
142
- heap_next = heap[idx];
143
-
144
- heap[idx] = obj;
145
- return idx;
146
- }
147
-
148
155
  function getArrayU8FromWasm0(ptr, len) {
156
+ ptr = ptr >>> 0;
149
157
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
150
158
  }
151
159
  /**
152
160
  * @param {any} acir
153
161
  * @returns {Uint8Array}
154
162
  */
155
- module.exports.acir_to_bytes = function(acir) {
163
+ module.exports.acir_write_bytes = function(acir) {
156
164
  try {
157
165
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
158
- wasm.acir_to_bytes(retptr, addHeapObject(acir));
166
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
159
167
  var r0 = getInt32Memory0()[retptr / 4 + 0];
160
168
  var r1 = getInt32Memory0()[retptr / 4 + 1];
161
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
169
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
162
170
  wasm.__wbindgen_export_2(r0, r1 * 1);
163
- return v0;
171
+ return v1;
164
172
  } finally {
165
173
  wasm.__wbindgen_add_to_stack_pointer(16);
166
174
  }
167
175
  };
168
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
+
169
186
  function handleError(f, args) {
170
187
  try {
171
188
  return f.apply(this, args);
@@ -174,22 +191,24 @@ function handleError(f, args) {
174
191
  }
175
192
  }
176
193
 
194
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
195
+ takeObject(arg0);
196
+ };
197
+
177
198
  module.exports.__wbindgen_is_undefined = function(arg0) {
178
199
  const ret = getObject(arg0) === undefined;
179
200
  return ret;
180
201
  };
181
202
 
182
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
183
- takeObject(arg0);
203
+ module.exports.__wbindgen_is_null = function(arg0) {
204
+ const ret = getObject(arg0) === null;
205
+ return ret;
184
206
  };
185
207
 
186
- module.exports.__wbg_readfile_160f965573651611 = function() { return handleError(function (arg0, arg1, arg2) {
187
- const ret = read_file(getStringFromWasm0(arg1, arg2));
188
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
189
- const len0 = WASM_VECTOR_LEN;
190
- getInt32Memory0()[arg0 / 4 + 1] = len0;
191
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
192
- }, arguments) };
208
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
209
+ const ret = getStringFromWasm0(arg0, arg1);
210
+ return addHeapObject(ret);
211
+ };
193
212
 
194
213
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
195
214
  const ret = new Error();
@@ -198,35 +217,71 @@ module.exports.__wbg_new_abda76e883ba8a5f = function() {
198
217
 
199
218
  module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
200
219
  const ret = getObject(arg1).stack;
201
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
202
- const len0 = WASM_VECTOR_LEN;
203
- getInt32Memory0()[arg0 / 4 + 1] = len0;
204
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
220
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
221
+ const len1 = WASM_VECTOR_LEN;
222
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
223
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
205
224
  };
206
225
 
207
226
  module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
227
+ let deferred0_0;
228
+ let deferred0_1;
208
229
  try {
230
+ deferred0_0 = arg0;
231
+ deferred0_1 = arg1;
209
232
  console.error(getStringFromWasm0(arg0, arg1));
210
233
  } finally {
211
- wasm.__wbindgen_export_2(arg0, arg1);
234
+ wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
212
235
  }
213
236
  };
214
237
 
238
+ module.exports.__wbg_readfile_6641677e84090077 = function() { return handleError(function (arg0, arg1, arg2) {
239
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
240
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
241
+ const len1 = WASM_VECTOR_LEN;
242
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
243
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
244
+ }, arguments) };
245
+
246
+ module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
247
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
248
+ };
249
+
250
+ module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
251
+ console.error(getObject(arg0));
252
+ };
253
+
254
+ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
255
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
256
+ };
257
+
258
+ module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
259
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
260
+ };
261
+
262
+ module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
263
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
264
+ };
265
+
266
+ module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
267
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
268
+ };
269
+
215
270
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
216
271
  const obj = getObject(arg1);
217
272
  const ret = typeof(obj) === 'string' ? obj : undefined;
218
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
219
- var len0 = WASM_VECTOR_LEN;
220
- getInt32Memory0()[arg0 / 4 + 1] = len0;
221
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
273
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
274
+ var len1 = WASM_VECTOR_LEN;
275
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
276
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
222
277
  };
223
278
 
224
- module.exports.__wbg_parse_e23be3fecd886e2a = function() { return handleError(function (arg0, arg1) {
279
+ module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
225
280
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
226
281
  return addHeapObject(ret);
227
282
  }, arguments) };
228
283
 
229
- module.exports.__wbg_stringify_d6471d300ded9b68 = function() { return handleError(function (arg0) {
284
+ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
230
285
  const ret = JSON.stringify(getObject(arg0));
231
286
  return addHeapObject(ret);
232
287
  }, arguments) };
Binary file
@@ -1,9 +1,11 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
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;
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;
7
9
  export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
8
10
  export function rust_psm_stack_direction(): number;
9
11
  export function rust_psm_stack_pointer(): number;
package/package.json CHANGED
@@ -1,20 +1,40 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "version": "0.10.0-f5d04f1",
3
+ "collaborators": [
4
+ "The Noir Team <team@noir-lang.org>"
5
+ ],
6
+ "version": "0.10.3",
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
12
  "nodejs",
6
13
  "web",
7
14
  "package.json"
8
15
  ],
9
- "main": "./nodejs/noir_wasm.js",
10
- "types": "./web/noir_wasm.d.ts",
11
- "module": "./web/noir_wasm.js",
12
16
  "sideEffects": false,
13
- "peerDependencies": {
14
- "@noir-lang/noir-source-resolver": "1.0.0"
15
- },
17
+ "packageManager": "yarn@3.5.1",
16
18
  "repository": {
17
19
  "type": "git",
18
20
  "url": "https://github.com/noir-lang/noir_wasm.git"
21
+ },
22
+ "scripts": {
23
+ "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
24
+ "test:browser": "web-test-runner"
25
+ },
26
+ "peerDependencies": {
27
+ "@noir-lang/noir-source-resolver": "1.1.2"
28
+ },
29
+ "devDependencies": {
30
+ "@esm-bundle/chai": "^4.3.4-fix.0",
31
+ "@noir-lang/noir-source-resolver": "1.1.2",
32
+ "@web/dev-server-esbuild": "^0.3.6",
33
+ "@web/test-runner": "^0.15.3",
34
+ "@web/test-runner-playwright": "^0.10.0",
35
+ "chai": "^4.3.7",
36
+ "mocha": "^10.2.0",
37
+ "ts-node": "^10.9.1",
38
+ "typescript": "^5.0.4"
19
39
  }
20
40
  }
@@ -1,28 +1,38 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} src
4
+ * @param {string} level
5
+ */
6
+ export function init_log_level(level: string): void;
7
+ /**
5
8
  * @returns {any}
6
9
  */
7
- export function compile(src: string): any;
10
+ export function build_info(): any;
8
11
  /**
9
12
  * @param {Uint8Array} bytes
10
13
  * @returns {any}
11
14
  */
12
- export function acir_from_bytes(bytes: Uint8Array): any;
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 acir_to_bytes(acir: any): Uint8Array;
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;
18
26
 
19
27
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
20
28
 
21
29
  export interface InitOutput {
22
30
  readonly memory: WebAssembly.Memory;
23
- readonly compile: (a: number, b: number) => number;
24
- readonly acir_from_bytes: (a: number, b: number) => number;
25
- readonly acir_to_bytes: (a: number, b: number) => void;
31
+ readonly init_log_level: (a: number, b: number) => void;
32
+ readonly build_info: () => number;
33
+ readonly acir_read_bytes: (a: number, b: number) => number;
34
+ readonly acir_write_bytes: (a: number, b: number) => void;
35
+ readonly compile: (a: number) => number;
26
36
  readonly rust_psm_on_stack: (a: number, b: number, c: number, d: number) => void;
27
37
  readonly rust_psm_stack_direction: () => number;
28
38
  readonly rust_psm_stack_pointer: () => number;
@@ -53,4 +63,4 @@ export function initSync(module: SyncInitInput): InitOutput;
53
63
  *
54
64
  * @returns {Promise<InitOutput>}
55
65
  */
56
- export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
66
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
package/web/noir_wasm.js CHANGED
@@ -2,7 +2,7 @@ import { read_file } from '@noir-lang/noir-source-resolver';
2
2
 
3
3
  let wasm;
4
4
 
5
- const heap = new Array(32).fill(undefined);
5
+ const heap = new Array(128).fill(undefined);
6
6
 
7
7
  heap.push(undefined, null, true, false);
8
8
 
@@ -11,7 +11,7 @@ function getObject(idx) { return heap[idx]; }
11
11
  let heap_next = heap.length;
12
12
 
13
13
  function dropObject(idx) {
14
- if (idx < 36) return;
14
+ if (idx < 132) return;
15
15
  heap[idx] = heap_next;
16
16
  heap_next = idx;
17
17
  }
@@ -22,18 +22,36 @@ function takeObject(idx) {
22
22
  return ret;
23
23
  }
24
24
 
25
- let WASM_VECTOR_LEN = 0;
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(); };
26
28
 
27
- let cachedUint8Memory0 = new Uint8Array();
29
+ let cachedUint8Memory0 = null;
28
30
 
29
31
  function getUint8Memory0() {
30
- if (cachedUint8Memory0.byteLength === 0) {
32
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
31
33
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
32
34
  }
33
35
  return cachedUint8Memory0;
34
36
  }
35
37
 
36
- const cachedTextEncoder = new TextEncoder('utf-8');
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') } } );
37
55
 
38
56
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
39
57
  ? function (arg, view) {
@@ -52,14 +70,14 @@ function passStringToWasm0(arg, malloc, realloc) {
52
70
 
53
71
  if (realloc === undefined) {
54
72
  const buf = cachedTextEncoder.encode(arg);
55
- const ptr = malloc(buf.length);
73
+ const ptr = malloc(buf.length) >>> 0;
56
74
  getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
57
75
  WASM_VECTOR_LEN = buf.length;
58
76
  return ptr;
59
77
  }
60
78
 
61
79
  let len = arg.length;
62
- let ptr = malloc(len);
80
+ let ptr = malloc(len) >>> 0;
63
81
 
64
82
  const mem = getUint8Memory0();
65
83
 
@@ -75,7 +93,7 @@ function passStringToWasm0(arg, malloc, realloc) {
75
93
  if (offset !== 0) {
76
94
  arg = arg.slice(offset);
77
95
  }
78
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
96
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
79
97
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
80
98
  const ret = encodeString(arg, view);
81
99
 
@@ -90,35 +108,33 @@ function isLikeNone(x) {
90
108
  return x === undefined || x === null;
91
109
  }
92
110
 
93
- let cachedInt32Memory0 = new Int32Array();
111
+ let cachedInt32Memory0 = null;
94
112
 
95
113
  function getInt32Memory0() {
96
- if (cachedInt32Memory0.byteLength === 0) {
114
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
97
115
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
98
116
  }
99
117
  return cachedInt32Memory0;
100
118
  }
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));
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);
108
126
  }
127
+
109
128
  /**
110
- * @param {string} src
111
129
  * @returns {any}
112
130
  */
113
- export function compile(src) {
114
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
115
- const len0 = WASM_VECTOR_LEN;
116
- const ret = wasm.compile(ptr0, len0);
131
+ export function build_info() {
132
+ const ret = wasm.build_info();
117
133
  return takeObject(ret);
118
134
  }
119
135
 
120
136
  function passArray8ToWasm0(arg, malloc) {
121
- const ptr = malloc(arg.length * 1);
137
+ const ptr = malloc(arg.length * 1) >>> 0;
122
138
  getUint8Memory0().set(arg, ptr / 1);
123
139
  WASM_VECTOR_LEN = arg.length;
124
140
  return ptr;
@@ -127,43 +143,44 @@ function passArray8ToWasm0(arg, malloc) {
127
143
  * @param {Uint8Array} bytes
128
144
  * @returns {any}
129
145
  */
130
- export function acir_from_bytes(bytes) {
146
+ export function acir_read_bytes(bytes) {
131
147
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
132
148
  const len0 = WASM_VECTOR_LEN;
133
- const ret = wasm.acir_from_bytes(ptr0, len0);
149
+ const ret = wasm.acir_read_bytes(ptr0, len0);
134
150
  return takeObject(ret);
135
151
  }
136
152
 
137
- function addHeapObject(obj) {
138
- if (heap_next === heap.length) heap.push(heap.length + 1);
139
- const idx = heap_next;
140
- heap_next = heap[idx];
141
-
142
- heap[idx] = obj;
143
- return idx;
144
- }
145
-
146
153
  function getArrayU8FromWasm0(ptr, len) {
154
+ ptr = ptr >>> 0;
147
155
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
148
156
  }
149
157
  /**
150
158
  * @param {any} acir
151
159
  * @returns {Uint8Array}
152
160
  */
153
- export function acir_to_bytes(acir) {
161
+ export function acir_write_bytes(acir) {
154
162
  try {
155
163
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
- wasm.acir_to_bytes(retptr, addHeapObject(acir));
164
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
157
165
  var r0 = getInt32Memory0()[retptr / 4 + 0];
158
166
  var r1 = getInt32Memory0()[retptr / 4 + 1];
159
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
167
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
160
168
  wasm.__wbindgen_export_2(r0, r1 * 1);
161
- return v0;
169
+ return v1;
162
170
  } finally {
163
171
  wasm.__wbindgen_add_to_stack_pointer(16);
164
172
  }
165
173
  }
166
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
+
167
184
  function handleError(f, args) {
168
185
  try {
169
186
  return f.apply(this, args);
@@ -172,7 +189,7 @@ function handleError(f, args) {
172
189
  }
173
190
  }
174
191
 
175
- async function load(module, imports) {
192
+ async function __wbg_load(module, imports) {
176
193
  if (typeof Response === 'function' && module instanceof Response) {
177
194
  if (typeof WebAssembly.instantiateStreaming === 'function') {
178
195
  try {
@@ -203,54 +220,84 @@ async function load(module, imports) {
203
220
  }
204
221
  }
205
222
 
206
- function getImports() {
223
+ function __wbg_get_imports() {
207
224
  const imports = {};
208
225
  imports.wbg = {};
226
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
227
+ takeObject(arg0);
228
+ };
209
229
  imports.wbg.__wbindgen_is_undefined = function(arg0) {
210
230
  const ret = getObject(arg0) === undefined;
211
231
  return ret;
212
232
  };
213
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
214
- takeObject(arg0);
233
+ imports.wbg.__wbindgen_is_null = function(arg0) {
234
+ const ret = getObject(arg0) === null;
235
+ return ret;
236
+ };
237
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
238
+ const ret = getStringFromWasm0(arg0, arg1);
239
+ return addHeapObject(ret);
215
240
  };
216
- imports.wbg.__wbg_readfile_160f965573651611 = function() { return handleError(function (arg0, arg1, arg2) {
217
- const ret = read_file(getStringFromWasm0(arg1, arg2));
218
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
219
- const len0 = WASM_VECTOR_LEN;
220
- getInt32Memory0()[arg0 / 4 + 1] = len0;
221
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
222
- }, arguments) };
223
241
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
224
242
  const ret = new Error();
225
243
  return addHeapObject(ret);
226
244
  };
227
245
  imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
228
246
  const ret = getObject(arg1).stack;
229
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
230
- const len0 = WASM_VECTOR_LEN;
231
- getInt32Memory0()[arg0 / 4 + 1] = len0;
232
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
247
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
248
+ const len1 = WASM_VECTOR_LEN;
249
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
250
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
233
251
  };
234
252
  imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
253
+ let deferred0_0;
254
+ let deferred0_1;
235
255
  try {
256
+ deferred0_0 = arg0;
257
+ deferred0_1 = arg1;
236
258
  console.error(getStringFromWasm0(arg0, arg1));
237
259
  } finally {
238
- wasm.__wbindgen_export_2(arg0, arg1);
260
+ wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
239
261
  }
240
262
  };
263
+ imports.wbg.__wbg_readfile_6641677e84090077 = 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
+ imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
271
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
272
+ };
273
+ imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
274
+ console.error(getObject(arg0));
275
+ };
276
+ imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
277
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
278
+ };
279
+ imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
280
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
281
+ };
282
+ imports.wbg.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
283
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
284
+ };
285
+ imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
286
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
287
+ };
241
288
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
242
289
  const obj = getObject(arg1);
243
290
  const ret = typeof(obj) === 'string' ? obj : undefined;
244
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
245
- var len0 = WASM_VECTOR_LEN;
246
- getInt32Memory0()[arg0 / 4 + 1] = len0;
247
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
291
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
292
+ var len1 = WASM_VECTOR_LEN;
293
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
294
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
248
295
  };
249
- imports.wbg.__wbg_parse_e23be3fecd886e2a = function() { return handleError(function (arg0, arg1) {
296
+ imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
250
297
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
251
298
  return addHeapObject(ret);
252
299
  }, arguments) };
253
- imports.wbg.__wbg_stringify_d6471d300ded9b68 = function() { return handleError(function (arg0) {
300
+ imports.wbg.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
254
301
  const ret = JSON.stringify(getObject(arg0));
255
302
  return addHeapObject(ret);
256
303
  }, arguments) };
@@ -261,24 +308,26 @@ function getImports() {
261
308
  return imports;
262
309
  }
263
310
 
264
- function initMemory(imports, maybe_memory) {
311
+ function __wbg_init_memory(imports, maybe_memory) {
265
312
 
266
313
  }
267
314
 
268
- function finalizeInit(instance, module) {
315
+ function __wbg_finalize_init(instance, module) {
269
316
  wasm = instance.exports;
270
- init.__wbindgen_wasm_module = module;
271
- cachedInt32Memory0 = new Int32Array();
272
- cachedUint8Memory0 = new Uint8Array();
317
+ __wbg_init.__wbindgen_wasm_module = module;
318
+ cachedInt32Memory0 = null;
319
+ cachedUint8Memory0 = null;
273
320
 
274
321
 
275
322
  return wasm;
276
323
  }
277
324
 
278
325
  function initSync(module) {
279
- const imports = getImports();
326
+ if (wasm !== undefined) return wasm;
327
+
328
+ const imports = __wbg_get_imports();
280
329
 
281
- initMemory(imports);
330
+ __wbg_init_memory(imports);
282
331
 
283
332
  if (!(module instanceof WebAssembly.Module)) {
284
333
  module = new WebAssembly.Module(module);
@@ -286,25 +335,27 @@ function initSync(module) {
286
335
 
287
336
  const instance = new WebAssembly.Instance(module, imports);
288
337
 
289
- return finalizeInit(instance, module);
338
+ return __wbg_finalize_init(instance, module);
290
339
  }
291
340
 
292
- async function init(input) {
341
+ async function __wbg_init(input) {
342
+ if (wasm !== undefined) return wasm;
343
+
293
344
  if (typeof input === 'undefined') {
294
345
  input = new URL('noir_wasm_bg.wasm', import.meta.url);
295
346
  }
296
- const imports = getImports();
347
+ const imports = __wbg_get_imports();
297
348
 
298
349
  if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
299
350
  input = fetch(input);
300
351
  }
301
352
 
302
- initMemory(imports);
353
+ __wbg_init_memory(imports);
303
354
 
304
- const { instance, module } = await load(await input, imports);
355
+ const { instance, module } = await __wbg_load(await input, imports);
305
356
 
306
- return finalizeInit(instance, module);
357
+ return __wbg_finalize_init(instance, module);
307
358
  }
308
359
 
309
360
  export { initSync }
310
- export default init;
361
+ export default __wbg_init;
Binary file
@@ -1,9 +1,11 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
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;
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;
7
9
  export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
8
10
  export function rust_psm_stack_direction(): number;
9
11
  export function rust_psm_stack_pointer(): number;