@noir-lang/noir_wasm 0.11.0 → 0.16.0-1b40af8c1

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/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## [0.7.0](https://github.com/noir-lang/noir/compare/noir_wasm-v0.6.0...noir_wasm-v0.7.0) (2023-06-19)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * update to ACVM 0.13.0 ([#1393](https://github.com/noir-lang/noir/issues/1393))
9
+
10
+ ### Features
11
+
12
+ * **ci:** update noir to build wasm with a nix flake file ([#1208](https://github.com/noir-lang/noir/issues/1208)) ([2209369](https://github.com/noir-lang/noir/commit/22093699a1a9c0c654c57fcce683fb42808db3e4))
13
+ * pass in closure to `Driver` to signal backend opcode support ([#1349](https://github.com/noir-lang/noir/issues/1349)) ([1e958c2](https://github.com/noir-lang/noir/commit/1e958c2aef89328e5354457c2a1e8697486e2978))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Fix nargo not showing compiler errors or warnings ([#1694](https://github.com/noir-lang/noir/issues/1694)) ([4233068](https://github.com/noir-lang/noir/commit/4233068e790e6b2544b61571183fdfe8dbaa7c57))
19
+ * **noirc_driver:** Move error printing into nargo ([#1598](https://github.com/noir-lang/noir/issues/1598)) ([561cd63](https://github.com/noir-lang/noir/commit/561cd63debc24d96fa95d3eced72d8b2f8122f49))
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * update to ACVM 0.13.0 ([#1393](https://github.com/noir-lang/noir/issues/1393)) ([22dee75](https://github.com/noir-lang/noir/commit/22dee75464d3d02af17109d9065d37342fbbcddb))
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Noir Lang WASM JavaScript Package
2
+
3
+ This JavaScript package enables users to compile a Noir program, i.e. generating its artifacts.
4
+
5
+ The package also handles dependency management like how Nargo (Noir's CLI tool) operates, but the package is used just for compilation, not proving, verifying and simulating functions.
6
+
7
+ ## Building from source
8
+
9
+ Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below:
10
+
11
+ ```bash
12
+ nix build -L github:noir-lang/noir/master#noir_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 #noir_wasm
19
+ ```
@@ -0,0 +1,25 @@
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 {string} level
10
+ */
11
+ export function init_log_level(level: string): void;
12
+ /**
13
+ * @returns {any}
14
+ */
15
+ export function build_info(): any;
16
+ /**
17
+ * @param {Uint8Array} bytes
18
+ * @returns {any}
19
+ */
20
+ export function acir_read_bytes(bytes: Uint8Array): any;
21
+ /**
22
+ * @param {any} acir
23
+ * @returns {Uint8Array}
24
+ */
25
+ export function acir_write_bytes(acir: any): Uint8Array;
@@ -0,0 +1,299 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { read_file } = require(`@noir-lang/source-resolver`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ const heap = new Array(128).fill(undefined);
8
+
9
+ heap.push(undefined, null, true, false);
10
+
11
+ function getObject(idx) { return heap[idx]; }
12
+
13
+ let heap_next = heap.length;
14
+
15
+ function dropObject(idx) {
16
+ if (idx < 132) return;
17
+ heap[idx] = heap_next;
18
+ heap_next = idx;
19
+ }
20
+
21
+ function takeObject(idx) {
22
+ const ret = getObject(idx);
23
+ dropObject(idx);
24
+ return ret;
25
+ }
26
+
27
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
28
+
29
+ cachedTextDecoder.decode();
30
+
31
+ let cachedUint8Memory0 = null;
32
+
33
+ function getUint8Memory0() {
34
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
35
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
36
+ }
37
+ return cachedUint8Memory0;
38
+ }
39
+
40
+ function getStringFromWasm0(ptr, len) {
41
+ ptr = ptr >>> 0;
42
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
43
+ }
44
+
45
+ function addHeapObject(obj) {
46
+ if (heap_next === heap.length) heap.push(heap.length + 1);
47
+ const idx = heap_next;
48
+ heap_next = heap[idx];
49
+
50
+ heap[idx] = obj;
51
+ return idx;
52
+ }
53
+
54
+ let WASM_VECTOR_LEN = 0;
55
+
56
+ let cachedTextEncoder = new TextEncoder('utf-8');
57
+
58
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
59
+ ? function (arg, view) {
60
+ return cachedTextEncoder.encodeInto(arg, view);
61
+ }
62
+ : function (arg, view) {
63
+ const buf = cachedTextEncoder.encode(arg);
64
+ view.set(buf);
65
+ return {
66
+ read: arg.length,
67
+ written: buf.length
68
+ };
69
+ });
70
+
71
+ function passStringToWasm0(arg, malloc, realloc) {
72
+
73
+ if (realloc === undefined) {
74
+ const buf = cachedTextEncoder.encode(arg);
75
+ const ptr = malloc(buf.length) >>> 0;
76
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
77
+ WASM_VECTOR_LEN = buf.length;
78
+ return ptr;
79
+ }
80
+
81
+ let len = arg.length;
82
+ let ptr = malloc(len) >>> 0;
83
+
84
+ const mem = getUint8Memory0();
85
+
86
+ let offset = 0;
87
+
88
+ for (; offset < len; offset++) {
89
+ const code = arg.charCodeAt(offset);
90
+ if (code > 0x7F) break;
91
+ mem[ptr + offset] = code;
92
+ }
93
+
94
+ if (offset !== len) {
95
+ if (offset !== 0) {
96
+ arg = arg.slice(offset);
97
+ }
98
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
99
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
100
+ const ret = encodeString(arg, view);
101
+
102
+ offset += ret.written;
103
+ }
104
+
105
+ WASM_VECTOR_LEN = offset;
106
+ return ptr;
107
+ }
108
+
109
+ function isLikeNone(x) {
110
+ return x === undefined || x === null;
111
+ }
112
+
113
+ let cachedInt32Memory0 = null;
114
+
115
+ function getInt32Memory0() {
116
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
117
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
118
+ }
119
+ return cachedInt32Memory0;
120
+ }
121
+ /**
122
+ * @param {any} args
123
+ * @returns {any}
124
+ */
125
+ module.exports.compile = function(args) {
126
+ const ret = wasm.compile(addHeapObject(args));
127
+ return takeObject(ret);
128
+ };
129
+
130
+ function handleError(f, args) {
131
+ try {
132
+ return f.apply(this, args);
133
+ } catch (e) {
134
+ wasm.__wbindgen_export_2(addHeapObject(e));
135
+ }
136
+ }
137
+ /**
138
+ * @param {string} level
139
+ */
140
+ module.exports.init_log_level = function(level) {
141
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
142
+ const len0 = WASM_VECTOR_LEN;
143
+ wasm.init_log_level(ptr0, len0);
144
+ };
145
+
146
+ /**
147
+ * @returns {any}
148
+ */
149
+ module.exports.build_info = function() {
150
+ const ret = wasm.build_info();
151
+ return takeObject(ret);
152
+ };
153
+
154
+ function passArray8ToWasm0(arg, malloc) {
155
+ const ptr = malloc(arg.length * 1) >>> 0;
156
+ getUint8Memory0().set(arg, ptr / 1);
157
+ WASM_VECTOR_LEN = arg.length;
158
+ return ptr;
159
+ }
160
+ /**
161
+ * @param {Uint8Array} bytes
162
+ * @returns {any}
163
+ */
164
+ module.exports.acir_read_bytes = function(bytes) {
165
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
166
+ const len0 = WASM_VECTOR_LEN;
167
+ const ret = wasm.acir_read_bytes(ptr0, len0);
168
+ return takeObject(ret);
169
+ };
170
+
171
+ function getArrayU8FromWasm0(ptr, len) {
172
+ ptr = ptr >>> 0;
173
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
174
+ }
175
+ /**
176
+ * @param {any} acir
177
+ * @returns {Uint8Array}
178
+ */
179
+ module.exports.acir_write_bytes = function(acir) {
180
+ try {
181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
182
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
183
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
184
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
185
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
186
+ wasm.__wbindgen_export_3(r0, r1 * 1);
187
+ return v1;
188
+ } finally {
189
+ wasm.__wbindgen_add_to_stack_pointer(16);
190
+ }
191
+ };
192
+
193
+ module.exports.__wbindgen_is_undefined = function(arg0) {
194
+ const ret = getObject(arg0) === undefined;
195
+ return ret;
196
+ };
197
+
198
+ module.exports.__wbindgen_is_null = function(arg0) {
199
+ const ret = getObject(arg0) === null;
200
+ return ret;
201
+ };
202
+
203
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
204
+ takeObject(arg0);
205
+ };
206
+
207
+ module.exports.__wbg_readfile_0c1777c7c5aa8c92 = function() { return handleError(function (arg0, arg1, arg2) {
208
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
209
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
210
+ const len1 = WASM_VECTOR_LEN;
211
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
212
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
213
+ }, arguments) };
214
+
215
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
216
+ const ret = getStringFromWasm0(arg0, arg1);
217
+ return addHeapObject(ret);
218
+ };
219
+
220
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
221
+ const ret = new Error();
222
+ return addHeapObject(ret);
223
+ };
224
+
225
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
226
+ const ret = getObject(arg1).stack;
227
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
228
+ const len1 = WASM_VECTOR_LEN;
229
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
230
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
231
+ };
232
+
233
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
234
+ let deferred0_0;
235
+ let deferred0_1;
236
+ try {
237
+ deferred0_0 = arg0;
238
+ deferred0_1 = arg1;
239
+ console.error(getStringFromWasm0(arg0, arg1));
240
+ } finally {
241
+ wasm.__wbindgen_export_3(deferred0_0, deferred0_1);
242
+ }
243
+ };
244
+
245
+ module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
246
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
247
+ };
248
+
249
+ module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
250
+ console.error(getObject(arg0));
251
+ };
252
+
253
+ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
254
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
255
+ };
256
+
257
+ module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
258
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
259
+ };
260
+
261
+ module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
262
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
263
+ };
264
+
265
+ module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
266
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
267
+ };
268
+
269
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
270
+ const obj = getObject(arg1);
271
+ const ret = typeof(obj) === 'string' ? obj : undefined;
272
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
273
+ var len1 = WASM_VECTOR_LEN;
274
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
275
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
276
+ };
277
+
278
+ module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
279
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
280
+ return addHeapObject(ret);
281
+ }, arguments) };
282
+
283
+ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
284
+ const ret = JSON.stringify(getObject(arg0));
285
+ return addHeapObject(ret);
286
+ }, arguments) };
287
+
288
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
289
+ throw new Error(getStringFromWasm0(arg0, arg1));
290
+ };
291
+
292
+ const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
293
+ const bytes = require('fs').readFileSync(path);
294
+
295
+ const wasmModule = new WebAssembly.Module(bytes);
296
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
297
+ wasm = wasmInstance.exports;
298
+ module.exports.__wasm = wasm;
299
+
Binary file
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function compile(a: number): number;
5
+ export function init_log_level(a: number, b: number): void;
6
+ export function build_info(): number;
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 __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_add_to_stack_pointer(a: number): number;
13
+ export function __wbindgen_export_3(a: number, b: number): void;
package/package.json CHANGED
@@ -1,13 +1,41 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "version": "0.11.0",
3
+ "collaborators": [
4
+ "The Noir Team <team@noir-lang.org>"
5
+ ],
6
+ "version": "0.16.0-1b40af8c1",
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
- "noir_wasm_bg.wasm",
6
- "noir_wasm.js",
7
- "noir_wasm_bg.wasm.d.ts",
8
- "noir_wasm.d.ts",
9
- "snippets/*"
12
+ "nodejs",
13
+ "web",
14
+ "package.json"
10
15
  ],
11
- "main": "noir_wasm.js",
12
- "types": "noir_wasm.d.ts"
16
+ "sideEffects": false,
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/noir-lang/noir.git"
20
+ },
21
+ "scripts": {
22
+ "build": "bash ./build.sh",
23
+ "test": "yarn test:node && yarn test:browser",
24
+ "test:node": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha",
25
+ "test:browser": "web-test-runner",
26
+ "clean": "chmod u+w web nodejs || true && rm -rf ./nodejs ./web ./target ./result",
27
+ "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)\" '.version = .version + $new_version' package.json > package-tmp.json && mv package-tmp.json package.json",
28
+ "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish",
29
+ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
30
+ },
31
+ "peerDependencies": {
32
+ "@noir-lang/source-resolver": "0.16.0-1b40af8c1"
33
+ },
34
+ "devDependencies": {
35
+ "@esm-bundle/chai": "^4.3.4-fix.0",
36
+ "@web/dev-server-esbuild": "^0.3.6",
37
+ "@web/test-runner": "^0.15.3",
38
+ "@web/test-runner-playwright": "^0.10.0",
39
+ "mocha": "^10.2.0"
40
+ }
13
41
  }
@@ -1,37 +1,43 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} src
4
+ * @param {any} args
5
5
  * @returns {any}
6
6
  */
7
- export function compile(src: string): any;
7
+ export function compile(args: any): any;
8
+ /**
9
+ * @param {string} level
10
+ */
11
+ export function init_log_level(level: string): void;
12
+ /**
13
+ * @returns {any}
14
+ */
15
+ export function build_info(): any;
8
16
  /**
9
17
  * @param {Uint8Array} bytes
10
18
  * @returns {any}
11
19
  */
12
- export function acir_from_bytes(bytes: Uint8Array): any;
20
+ export function acir_read_bytes(bytes: Uint8Array): any;
13
21
  /**
14
22
  * @param {any} acir
15
23
  * @returns {Uint8Array}
16
24
  */
17
- export function acir_to_bytes(acir: any): Uint8Array;
25
+ export function acir_write_bytes(acir: any): Uint8Array;
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;
26
- readonly rust_psm_on_stack: (a: number, b: number, c: number, d: number) => void;
27
- readonly rust_psm_stack_direction: () => number;
28
- readonly rust_psm_stack_pointer: () => number;
29
- readonly rust_psm_replace_stack: (a: number, b: number, c: number) => void;
31
+ readonly compile: (a: number) => number;
32
+ readonly init_log_level: (a: number, b: number) => void;
33
+ readonly build_info: () => number;
34
+ readonly acir_read_bytes: (a: number, b: number) => number;
35
+ readonly acir_write_bytes: (a: number, b: number) => void;
30
36
  readonly __wbindgen_export_0: (a: number) => number;
31
37
  readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
38
+ readonly __wbindgen_export_2: (a: number) => void;
32
39
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
33
- readonly __wbindgen_export_2: (a: number, b: number) => void;
34
- readonly __wbindgen_export_3: (a: number) => void;
40
+ readonly __wbindgen_export_3: (a: number, b: number) => void;
35
41
  }
36
42
 
37
43
  export type SyncInitInput = BufferSource | WebAssembly.Module;
@@ -53,4 +59,4 @@ export function initSync(module: SyncInitInput): InitOutput;
53
59
  *
54
60
  * @returns {Promise<InitOutput>}
55
61
  */
56
- export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
62
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -1,30 +1,45 @@
1
- import { read_file } from './snippets/fm-cffb18dcbd478425/file_reader.js';
1
+ import { read_file } from '@noir-lang/source-resolver';
2
2
 
3
3
  let wasm;
4
4
 
5
- const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
+ const heap = new Array(128).fill(undefined);
6
6
 
7
- cachedTextDecoder.decode();
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
+ }
8
18
 
9
- let cachedUint8Memory0 = new Uint8Array();
19
+ function takeObject(idx) {
20
+ const ret = getObject(idx);
21
+ dropObject(idx);
22
+ return ret;
23
+ }
24
+
25
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
26
+
27
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
28
+
29
+ let cachedUint8Memory0 = null;
10
30
 
11
31
  function getUint8Memory0() {
12
- if (cachedUint8Memory0.byteLength === 0) {
32
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
13
33
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
14
34
  }
15
35
  return cachedUint8Memory0;
16
36
  }
17
37
 
18
38
  function getStringFromWasm0(ptr, len) {
39
+ ptr = ptr >>> 0;
19
40
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
20
41
  }
21
42
 
22
- const heap = new Array(32).fill(undefined);
23
-
24
- heap.push(undefined, null, true, false);
25
-
26
- let heap_next = heap.length;
27
-
28
43
  function addHeapObject(obj) {
29
44
  if (heap_next === heap.length) heap.push(heap.length + 1);
30
45
  const idx = heap_next;
@@ -34,11 +49,9 @@ function addHeapObject(obj) {
34
49
  return idx;
35
50
  }
36
51
 
37
- function getObject(idx) { return heap[idx]; }
38
-
39
52
  let WASM_VECTOR_LEN = 0;
40
53
 
41
- const cachedTextEncoder = new TextEncoder('utf-8');
54
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
42
55
 
43
56
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
44
57
  ? function (arg, view) {
@@ -57,14 +70,14 @@ function passStringToWasm0(arg, malloc, realloc) {
57
70
 
58
71
  if (realloc === undefined) {
59
72
  const buf = cachedTextEncoder.encode(arg);
60
- const ptr = malloc(buf.length);
73
+ const ptr = malloc(buf.length) >>> 0;
61
74
  getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
62
75
  WASM_VECTOR_LEN = buf.length;
63
76
  return ptr;
64
77
  }
65
78
 
66
79
  let len = arg.length;
67
- let ptr = malloc(len);
80
+ let ptr = malloc(len) >>> 0;
68
81
 
69
82
  const mem = getUint8Memory0();
70
83
 
@@ -80,7 +93,7 @@ function passStringToWasm0(arg, malloc, realloc) {
80
93
  if (offset !== 0) {
81
94
  arg = arg.slice(offset);
82
95
  }
83
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
96
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
84
97
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
85
98
  const ret = encodeString(arg, view);
86
99
 
@@ -91,39 +104,53 @@ function passStringToWasm0(arg, malloc, realloc) {
91
104
  return ptr;
92
105
  }
93
106
 
94
- let cachedInt32Memory0 = new Int32Array();
107
+ function isLikeNone(x) {
108
+ return x === undefined || x === null;
109
+ }
110
+
111
+ let cachedInt32Memory0 = null;
95
112
 
96
113
  function getInt32Memory0() {
97
- if (cachedInt32Memory0.byteLength === 0) {
114
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
98
115
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
99
116
  }
100
117
  return cachedInt32Memory0;
101
118
  }
102
-
103
- function dropObject(idx) {
104
- if (idx < 36) return;
105
- heap[idx] = heap_next;
106
- heap_next = idx;
119
+ /**
120
+ * @param {any} args
121
+ * @returns {any}
122
+ */
123
+ export function compile(args) {
124
+ const ret = wasm.compile(addHeapObject(args));
125
+ return takeObject(ret);
107
126
  }
108
127
 
109
- function takeObject(idx) {
110
- const ret = getObject(idx);
111
- dropObject(idx);
112
- return ret;
128
+ function handleError(f, args) {
129
+ try {
130
+ return f.apply(this, args);
131
+ } catch (e) {
132
+ wasm.__wbindgen_export_2(addHeapObject(e));
133
+ }
113
134
  }
114
135
  /**
115
- * @param {string} src
116
- * @returns {any}
136
+ * @param {string} level
117
137
  */
118
- export function compile(src) {
119
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
138
+ export function init_log_level(level) {
139
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
120
140
  const len0 = WASM_VECTOR_LEN;
121
- const ret = wasm.compile(ptr0, len0);
141
+ wasm.init_log_level(ptr0, len0);
142
+ }
143
+
144
+ /**
145
+ * @returns {any}
146
+ */
147
+ export function build_info() {
148
+ const ret = wasm.build_info();
122
149
  return takeObject(ret);
123
150
  }
124
151
 
125
152
  function passArray8ToWasm0(arg, malloc) {
126
- const ptr = malloc(arg.length * 1);
153
+ const ptr = malloc(arg.length * 1) >>> 0;
127
154
  getUint8Memory0().set(arg, ptr / 1);
128
155
  WASM_VECTOR_LEN = arg.length;
129
156
  return ptr;
@@ -132,43 +159,36 @@ function passArray8ToWasm0(arg, malloc) {
132
159
  * @param {Uint8Array} bytes
133
160
  * @returns {any}
134
161
  */
135
- export function acir_from_bytes(bytes) {
162
+ export function acir_read_bytes(bytes) {
136
163
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
137
164
  const len0 = WASM_VECTOR_LEN;
138
- const ret = wasm.acir_from_bytes(ptr0, len0);
165
+ const ret = wasm.acir_read_bytes(ptr0, len0);
139
166
  return takeObject(ret);
140
167
  }
141
168
 
142
169
  function getArrayU8FromWasm0(ptr, len) {
170
+ ptr = ptr >>> 0;
143
171
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
144
172
  }
145
173
  /**
146
174
  * @param {any} acir
147
175
  * @returns {Uint8Array}
148
176
  */
149
- export function acir_to_bytes(acir) {
177
+ export function acir_write_bytes(acir) {
150
178
  try {
151
179
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
152
- wasm.acir_to_bytes(retptr, addHeapObject(acir));
180
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
153
181
  var r0 = getInt32Memory0()[retptr / 4 + 0];
154
182
  var r1 = getInt32Memory0()[retptr / 4 + 1];
155
- var v0 = getArrayU8FromWasm0(r0, r1).slice();
156
- wasm.__wbindgen_export_2(r0, r1 * 1);
157
- return v0;
183
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
184
+ wasm.__wbindgen_export_3(r0, r1 * 1);
185
+ return v1;
158
186
  } finally {
159
187
  wasm.__wbindgen_add_to_stack_pointer(16);
160
188
  }
161
189
  }
162
190
 
163
- function handleError(f, args) {
164
- try {
165
- return f.apply(this, args);
166
- } catch (e) {
167
- wasm.__wbindgen_export_3(addHeapObject(e));
168
- }
169
- }
170
-
171
- async function load(module, imports) {
191
+ async function __wbg_load(module, imports) {
172
192
  if (typeof Response === 'function' && module instanceof Response) {
173
193
  if (typeof WebAssembly.instantiateStreaming === 'function') {
174
194
  try {
@@ -199,71 +219,114 @@ async function load(module, imports) {
199
219
  }
200
220
  }
201
221
 
202
- function getImports() {
222
+ function __wbg_get_imports() {
203
223
  const imports = {};
204
224
  imports.wbg = {};
205
- imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
206
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
207
- return addHeapObject(ret);
225
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
226
+ const ret = getObject(arg0) === undefined;
227
+ return ret;
208
228
  };
209
- imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
210
- const obj = getObject(arg1);
211
- const ret = JSON.stringify(obj === undefined ? null : obj);
212
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
213
- const len0 = WASM_VECTOR_LEN;
214
- getInt32Memory0()[arg0 / 4 + 1] = len0;
215
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
229
+ imports.wbg.__wbindgen_is_null = function(arg0) {
230
+ const ret = getObject(arg0) === null;
231
+ return ret;
216
232
  };
217
233
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
218
234
  takeObject(arg0);
219
235
  };
220
- imports.wbg.__wbg_readfile_a255adfa6d841e23 = function() { return handleError(function (arg0, arg1, arg2) {
236
+ imports.wbg.__wbg_readfile_0c1777c7c5aa8c92 = function() { return handleError(function (arg0, arg1, arg2) {
221
237
  const ret = read_file(getStringFromWasm0(arg1, arg2));
222
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
223
- const len0 = WASM_VECTOR_LEN;
224
- getInt32Memory0()[arg0 / 4 + 1] = len0;
225
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
238
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
239
+ const len1 = WASM_VECTOR_LEN;
240
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
241
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
226
242
  }, arguments) };
243
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
244
+ const ret = getStringFromWasm0(arg0, arg1);
245
+ return addHeapObject(ret);
246
+ };
227
247
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
228
248
  const ret = new Error();
229
249
  return addHeapObject(ret);
230
250
  };
231
251
  imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
232
252
  const ret = getObject(arg1).stack;
233
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
234
- const len0 = WASM_VECTOR_LEN;
235
- getInt32Memory0()[arg0 / 4 + 1] = len0;
236
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
253
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
254
+ const len1 = WASM_VECTOR_LEN;
255
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
256
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
237
257
  };
238
258
  imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
259
+ let deferred0_0;
260
+ let deferred0_1;
239
261
  try {
262
+ deferred0_0 = arg0;
263
+ deferred0_1 = arg1;
240
264
  console.error(getStringFromWasm0(arg0, arg1));
241
265
  } finally {
242
- wasm.__wbindgen_export_2(arg0, arg1);
266
+ wasm.__wbindgen_export_3(deferred0_0, deferred0_1);
243
267
  }
244
268
  };
269
+ imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
270
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
271
+ };
272
+ imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
273
+ console.error(getObject(arg0));
274
+ };
275
+ imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
276
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
277
+ };
278
+ imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
279
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
280
+ };
281
+ imports.wbg.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
282
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
283
+ };
284
+ imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
285
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
286
+ };
287
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
288
+ const obj = getObject(arg1);
289
+ const ret = typeof(obj) === 'string' ? obj : undefined;
290
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
291
+ var len1 = WASM_VECTOR_LEN;
292
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
293
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
294
+ };
295
+ imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
296
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
297
+ return addHeapObject(ret);
298
+ }, arguments) };
299
+ imports.wbg.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
300
+ const ret = JSON.stringify(getObject(arg0));
301
+ return addHeapObject(ret);
302
+ }, arguments) };
303
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
304
+ throw new Error(getStringFromWasm0(arg0, arg1));
305
+ };
245
306
 
246
307
  return imports;
247
308
  }
248
309
 
249
- function initMemory(imports, maybe_memory) {
310
+ function __wbg_init_memory(imports, maybe_memory) {
250
311
 
251
312
  }
252
313
 
253
- function finalizeInit(instance, module) {
314
+ function __wbg_finalize_init(instance, module) {
254
315
  wasm = instance.exports;
255
- init.__wbindgen_wasm_module = module;
256
- cachedInt32Memory0 = new Int32Array();
257
- cachedUint8Memory0 = new Uint8Array();
316
+ __wbg_init.__wbindgen_wasm_module = module;
317
+ cachedInt32Memory0 = null;
318
+ cachedUint8Memory0 = null;
258
319
 
259
320
 
260
321
  return wasm;
261
322
  }
262
323
 
263
324
  function initSync(module) {
264
- const imports = getImports();
325
+ if (wasm !== undefined) return wasm;
265
326
 
266
- initMemory(imports);
327
+ const imports = __wbg_get_imports();
328
+
329
+ __wbg_init_memory(imports);
267
330
 
268
331
  if (!(module instanceof WebAssembly.Module)) {
269
332
  module = new WebAssembly.Module(module);
@@ -271,25 +334,27 @@ function initSync(module) {
271
334
 
272
335
  const instance = new WebAssembly.Instance(module, imports);
273
336
 
274
- return finalizeInit(instance, module);
337
+ return __wbg_finalize_init(instance, module);
275
338
  }
276
339
 
277
- async function init(input) {
340
+ async function __wbg_init(input) {
341
+ if (wasm !== undefined) return wasm;
342
+
278
343
  if (typeof input === 'undefined') {
279
344
  input = new URL('noir_wasm_bg.wasm', import.meta.url);
280
345
  }
281
- const imports = getImports();
346
+ const imports = __wbg_get_imports();
282
347
 
283
348
  if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
284
349
  input = fetch(input);
285
350
  }
286
351
 
287
- initMemory(imports);
352
+ __wbg_init_memory(imports);
288
353
 
289
- const { instance, module } = await load(await input, imports);
354
+ const { instance, module } = await __wbg_load(await input, imports);
290
355
 
291
- return finalizeInit(instance, module);
356
+ return __wbg_finalize_init(instance, module);
292
357
  }
293
358
 
294
359
  export { initSync }
295
- export default init;
360
+ export default __wbg_init;
Binary file
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function compile(a: number): number;
5
+ export function init_log_level(a: number, b: number): void;
6
+ export function build_info(): number;
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 __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_add_to_stack_pointer(a: number): number;
13
+ export function __wbindgen_export_3(a: number, b: number): void;
package/noir_wasm_bg.wasm DELETED
Binary file
@@ -1,15 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export const memory: WebAssembly.Memory;
4
- export function compile(a: number, b: number): number;
5
- export function acir_from_bytes(a: number, b: number): number;
6
- export function acir_to_bytes(a: number, b: number): void;
7
- export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
8
- export function rust_psm_stack_direction(): number;
9
- export function rust_psm_stack_pointer(): number;
10
- export function rust_psm_replace_stack(a: number, b: number, c: number): void;
11
- export function __wbindgen_export_0(a: number): number;
12
- export function __wbindgen_export_1(a: number, b: number, c: number): number;
13
- export function __wbindgen_add_to_stack_pointer(a: number): number;
14
- export function __wbindgen_export_2(a: number, b: number): void;
15
- export function __wbindgen_export_3(a: number): void;
@@ -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
- };