@noir-lang/noir_wasm 0.4.0 → 0.4.1-3d2233d

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@3d2233d](https://github.com/noir-lang/noir/tree/3d2233de810ab6d4a0f4f83007232133c88a49fe)
@@ -0,0 +1,35 @@
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
+ * @param {string} level
30
+ */
31
+ export function init_log_level(level: string): void;
32
+ /**
33
+ * @returns {any}
34
+ */
35
+ export function build_info(): any;
@@ -1,26 +1,57 @@
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 { TextEncoder, TextDecoder } = require(`util`);
4
+ const { read_file } = require(`@noir-lang/noir-source-resolver`);
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
 
11
11
  function getObject(idx) { return heap[idx]; }
12
12
 
13
- let WASM_VECTOR_LEN = 0;
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
+ }
14
20
 
15
- let cachedUint8Memory0 = new Uint8Array();
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;
16
32
 
17
33
  function getUint8Memory0() {
18
- if (cachedUint8Memory0.byteLength === 0) {
34
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
19
35
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
20
36
  }
21
37
  return cachedUint8Memory0;
22
38
  }
23
39
 
40
+ function getStringFromWasm0(ptr, len) {
41
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
42
+ }
43
+
44
+ function addHeapObject(obj) {
45
+ if (heap_next === heap.length) heap.push(heap.length + 1);
46
+ const idx = heap_next;
47
+ heap_next = heap[idx];
48
+
49
+ heap[idx] = obj;
50
+ return idx;
51
+ }
52
+
53
+ let WASM_VECTOR_LEN = 0;
54
+
24
55
  let cachedTextEncoder = new TextEncoder('utf-8');
25
56
 
26
57
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -74,53 +105,24 @@ function passStringToWasm0(arg, malloc, realloc) {
74
105
  return ptr;
75
106
  }
76
107
 
77
- let cachedInt32Memory0 = new Int32Array();
108
+ function isLikeNone(x) {
109
+ return x === undefined || x === null;
110
+ }
111
+
112
+ let cachedInt32Memory0 = null;
78
113
 
79
114
  function getInt32Memory0() {
80
- if (cachedInt32Memory0.byteLength === 0) {
115
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
81
116
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
82
117
  }
83
118
  return cachedInt32Memory0;
84
119
  }
85
-
86
- let heap_next = heap.length;
87
-
88
- function dropObject(idx) {
89
- if (idx < 36) return;
90
- heap[idx] = heap_next;
91
- heap_next = idx;
92
- }
93
-
94
- function takeObject(idx) {
95
- const ret = getObject(idx);
96
- dropObject(idx);
97
- return ret;
98
- }
99
-
100
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
101
-
102
- cachedTextDecoder.decode();
103
-
104
- function getStringFromWasm0(ptr, len) {
105
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
106
- }
107
-
108
- function addHeapObject(obj) {
109
- if (heap_next === heap.length) heap.push(heap.length + 1);
110
- const idx = heap_next;
111
- heap_next = heap[idx];
112
-
113
- heap[idx] = obj;
114
- return idx;
115
- }
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,52 @@ 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
+ * @param {string} level
198
+ */
199
+ module.exports.init_log_level = function(level) {
200
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
201
+ const len0 = WASM_VECTOR_LEN;
202
+ wasm.init_log_level(ptr0, len0);
203
+ };
204
+
205
+ /**
206
+ * @returns {any}
207
+ */
208
+ module.exports.build_info = function() {
209
+ const ret = wasm.build_info();
210
+ return takeObject(ret);
211
+ };
212
+
165
213
  function handleError(f, args) {
166
214
  try {
167
215
  return f.apply(this, args);
@@ -170,38 +218,31 @@ function handleError(f, args) {
170
218
  }
171
219
  }
172
220
 
173
- module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
174
- const obj = getObject(arg1);
175
- const ret = JSON.stringify(obj === undefined ? null : obj);
176
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
177
- const len0 = WASM_VECTOR_LEN;
178
- getInt32Memory0()[arg0 / 4 + 1] = len0;
179
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
221
+ module.exports.__wbindgen_is_undefined = function(arg0) {
222
+ const ret = getObject(arg0) === undefined;
223
+ return ret;
224
+ };
225
+
226
+ module.exports.__wbindgen_is_null = function(arg0) {
227
+ const ret = getObject(arg0) === null;
228
+ return ret;
180
229
  };
181
230
 
182
231
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
183
232
  takeObject(arg0);
184
233
  };
185
234
 
186
- module.exports.__wbindgen_json_parse = function(arg0, arg1) {
187
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
235
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
236
+ const ret = getStringFromWasm0(arg0, arg1);
188
237
  return addHeapObject(ret);
189
238
  };
190
239
 
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() {
240
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
200
241
  const ret = new Error();
201
242
  return addHeapObject(ret);
202
243
  };
203
244
 
204
- module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
245
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
205
246
  const ret = getObject(arg1).stack;
206
247
  const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
207
248
  const len0 = WASM_VECTOR_LEN;
@@ -209,7 +250,7 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
209
250
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
210
251
  };
211
252
 
212
- module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
253
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
213
254
  try {
214
255
  console.error(getStringFromWasm0(arg0, arg1));
215
256
  } finally {
@@ -217,138 +258,61 @@ module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
217
258
  }
218
259
  };
219
260
 
220
- module.exports.__wbg_randomFillSync_91e2b39becca6147 = function() { return handleError(function (arg0, arg1, arg2) {
221
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
222
- }, arguments) };
223
-
224
- module.exports.__wbg_getRandomValues_b14734aa289bc356 = function() { return handleError(function (arg0, arg1) {
225
- getObject(arg0).getRandomValues(getObject(arg1));
261
+ module.exports.__wbg_readfile_e0e65427440b9915 = function() { return handleError(function (arg0, arg1, arg2) {
262
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
263
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
264
+ const len0 = WASM_VECTOR_LEN;
265
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
266
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
226
267
  }, arguments) };
227
268
 
228
- module.exports.__wbg_process_e56fd54cf6319b6c = function(arg0) {
229
- const ret = getObject(arg0).process;
230
- return addHeapObject(ret);
231
- };
232
-
233
- module.exports.__wbindgen_is_object = function(arg0) {
234
- const val = getObject(arg0);
235
- const ret = typeof(val) === 'object' && val !== null;
236
- return ret;
269
+ module.exports.__wbg_debug_7960d327fd96f71a = function(arg0, arg1, arg2, arg3) {
270
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
237
271
  };
238
272
 
239
- module.exports.__wbg_versions_77e21455908dad33 = function(arg0) {
240
- const ret = getObject(arg0).versions;
241
- return addHeapObject(ret);
242
- };
243
-
244
- module.exports.__wbg_node_0dd25d832e4785d5 = function(arg0) {
245
- const ret = getObject(arg0).node;
246
- return addHeapObject(ret);
247
- };
248
-
249
- module.exports.__wbindgen_is_string = function(arg0) {
250
- const ret = typeof(getObject(arg0)) === 'string';
251
- return ret;
273
+ module.exports.__wbg_error_fe807da27c4a4ced = function(arg0) {
274
+ console.error(getObject(arg0));
252
275
  };
253
276
 
254
- module.exports.__wbg_crypto_b95d7173266618a9 = function(arg0) {
255
- const ret = getObject(arg0).crypto;
256
- return addHeapObject(ret);
277
+ module.exports.__wbg_error_fd84ca2a8a977774 = function(arg0, arg1, arg2, arg3) {
278
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
257
279
  };
258
280
 
259
- module.exports.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
260
- const ret = getObject(arg0).msCrypto;
261
- return addHeapObject(ret);
281
+ module.exports.__wbg_info_5566be377f5b52ae = function(arg0, arg1, arg2, arg3) {
282
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
262
283
  };
263
284
 
264
- module.exports.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
265
- const ret = module;
266
- return addHeapObject(ret);
285
+ module.exports.__wbg_log_7b690f184ae4519b = function(arg0, arg1, arg2, arg3) {
286
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
267
287
  };
268
288
 
269
- module.exports.__wbg_require_0db1598d9ccecb30 = function() { return handleError(function (arg0, arg1, arg2) {
270
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
271
- return addHeapObject(ret);
272
- }, arguments) };
273
-
274
- module.exports.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
275
- const ret = new Function(getStringFromWasm0(arg0, arg1));
276
- return addHeapObject(ret);
289
+ module.exports.__wbg_warn_48cbddced45e5414 = function(arg0, arg1, arg2, arg3) {
290
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
277
291
  };
278
292
 
279
- module.exports.__wbg_call_33d7bcddbbfa394a = function() { return handleError(function (arg0, arg1) {
280
- const ret = getObject(arg0).call(getObject(arg1));
281
- return addHeapObject(ret);
282
- }, arguments) };
283
-
284
- module.exports.__wbindgen_object_clone_ref = function(arg0) {
285
- const ret = getObject(arg0);
286
- return addHeapObject(ret);
293
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
294
+ const obj = getObject(arg1);
295
+ const ret = typeof(obj) === 'string' ? obj : undefined;
296
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
297
+ var len0 = WASM_VECTOR_LEN;
298
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
299
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
287
300
  };
288
301
 
289
- module.exports.__wbg_self_fd00a1ef86d1b2ed = function() { return handleError(function () {
290
- const ret = self.self;
291
- return addHeapObject(ret);
292
- }, arguments) };
293
-
294
- module.exports.__wbg_window_6f6e346d8bbd61d7 = function() { return handleError(function () {
295
- const ret = window.window;
296
- return addHeapObject(ret);
297
- }, arguments) };
298
-
299
- module.exports.__wbg_globalThis_3348936ac49df00a = function() { return handleError(function () {
300
- const ret = globalThis.globalThis;
302
+ module.exports.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
303
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
301
304
  return addHeapObject(ret);
302
305
  }, arguments) };
303
306
 
304
- module.exports.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
305
- const ret = global.global;
307
+ module.exports.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
308
+ const ret = JSON.stringify(getObject(arg0));
306
309
  return addHeapObject(ret);
307
310
  }, arguments) };
308
311
 
309
- module.exports.__wbindgen_is_undefined = function(arg0) {
310
- const ret = getObject(arg0) === undefined;
311
- return ret;
312
- };
313
-
314
- module.exports.__wbg_buffer_34f5ec9f8a838ba0 = function(arg0) {
315
- const ret = getObject(arg0).buffer;
316
- return addHeapObject(ret);
317
- };
318
-
319
- module.exports.__wbg_new_cda198d9dbc6d7ea = function(arg0) {
320
- const ret = new Uint8Array(getObject(arg0));
321
- return addHeapObject(ret);
322
- };
323
-
324
- module.exports.__wbg_set_1a930cfcda1a8067 = function(arg0, arg1, arg2) {
325
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
326
- };
327
-
328
- module.exports.__wbg_length_51f19f73d6d9eff3 = function(arg0) {
329
- const ret = getObject(arg0).length;
330
- return ret;
331
- };
332
-
333
- module.exports.__wbg_newwithlength_66e5530e7079ea1b = function(arg0) {
334
- const ret = new Uint8Array(arg0 >>> 0);
335
- return addHeapObject(ret);
336
- };
337
-
338
- module.exports.__wbg_subarray_270ff8dd5582c1ac = function(arg0, arg1, arg2) {
339
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
340
- return addHeapObject(ret);
341
- };
342
-
343
312
  module.exports.__wbindgen_throw = function(arg0, arg1) {
344
313
  throw new Error(getStringFromWasm0(arg0, arg1));
345
314
  };
346
315
 
347
- module.exports.__wbindgen_memory = function() {
348
- const ret = wasm.memory;
349
- return addHeapObject(ret);
350
- };
351
-
352
316
  const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
353
317
  const bytes = require('fs').readFileSync(path);
354
318
 
Binary file
@@ -1,13 +1,13 @@
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 init_log_level(a: number, b: number): void;
10
+ export function build_info(): number;
11
11
  export function __wbindgen_export_0(a: number): number;
12
12
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
13
13
  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.4.0",
3
+ "collaborators": [
4
+ "The Noir Team <team@noir-lang.org>"
5
+ ],
6
+ "version": "0.4.1-3d2233d",
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.1.2"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/noir-lang/noir_wasm.git"
22
+ },
23
+ "compiler": {
24
+ "versionHash": "3d2233de810ab6d4a0f4f83007232133c88a49fe"
25
+ }
26
+ }
@@ -0,0 +1,74 @@
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
+ * @param {string} level
30
+ */
31
+ export function init_log_level(level: string): void;
32
+ /**
33
+ * @returns {any}
34
+ */
35
+ export function build_info(): any;
36
+
37
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
38
+
39
+ export interface InitOutput {
40
+ readonly memory: WebAssembly.Memory;
41
+ readonly compile: (a: number) => number;
42
+ readonly acir_from_bytes: (a: number, b: number) => number;
43
+ readonly acir_to_bytes: (a: number, b: number) => void;
44
+ readonly acir_read_bytes: (a: number, b: number) => number;
45
+ readonly acir_write_bytes: (a: number, b: number) => void;
46
+ readonly init_log_level: (a: number, b: number) => void;
47
+ readonly build_info: () => number;
48
+ readonly __wbindgen_export_0: (a: number) => number;
49
+ readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
50
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
51
+ readonly __wbindgen_export_2: (a: number, b: number) => void;
52
+ readonly __wbindgen_export_3: (a: number) => void;
53
+ }
54
+
55
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
56
+ /**
57
+ * Instantiates the given `module`, which can either be bytes or
58
+ * a precompiled `WebAssembly.Module`.
59
+ *
60
+ * @param {SyncInitInput} module
61
+ *
62
+ * @returns {InitOutput}
63
+ */
64
+ export function initSync(module: SyncInitInput): InitOutput;
65
+
66
+ /**
67
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
68
+ * for everything else, calls `WebAssembly.instantiate` directly.
69
+ *
70
+ * @param {InitInput | Promise<InitInput>} module_or_path
71
+ *
72
+ * @returns {Promise<InitOutput>}
73
+ */
74
+ export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,380 @@
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
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+
27
+ cachedTextDecoder.decode();
28
+
29
+ let cachedUint8Memory0 = null;
30
+
31
+ function getUint8Memory0() {
32
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
33
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
34
+ }
35
+ return cachedUint8Memory0;
36
+ }
37
+
38
+ function getStringFromWasm0(ptr, len) {
39
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
40
+ }
41
+
42
+ function addHeapObject(obj) {
43
+ if (heap_next === heap.length) heap.push(heap.length + 1);
44
+ const idx = heap_next;
45
+ heap_next = heap[idx];
46
+
47
+ heap[idx] = obj;
48
+ return idx;
49
+ }
50
+
51
+ let WASM_VECTOR_LEN = 0;
52
+
53
+ const cachedTextEncoder = new TextEncoder('utf-8');
54
+
55
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
56
+ ? function (arg, view) {
57
+ return cachedTextEncoder.encodeInto(arg, view);
58
+ }
59
+ : function (arg, view) {
60
+ const buf = cachedTextEncoder.encode(arg);
61
+ view.set(buf);
62
+ return {
63
+ read: arg.length,
64
+ written: buf.length
65
+ };
66
+ });
67
+
68
+ function passStringToWasm0(arg, malloc, realloc) {
69
+
70
+ if (realloc === undefined) {
71
+ const buf = cachedTextEncoder.encode(arg);
72
+ const ptr = malloc(buf.length);
73
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
74
+ WASM_VECTOR_LEN = buf.length;
75
+ return ptr;
76
+ }
77
+
78
+ let len = arg.length;
79
+ let ptr = malloc(len);
80
+
81
+ const mem = getUint8Memory0();
82
+
83
+ let offset = 0;
84
+
85
+ for (; offset < len; offset++) {
86
+ const code = arg.charCodeAt(offset);
87
+ if (code > 0x7F) break;
88
+ mem[ptr + offset] = code;
89
+ }
90
+
91
+ if (offset !== len) {
92
+ if (offset !== 0) {
93
+ arg = arg.slice(offset);
94
+ }
95
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
96
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
97
+ const ret = encodeString(arg, view);
98
+
99
+ offset += ret.written;
100
+ }
101
+
102
+ WASM_VECTOR_LEN = offset;
103
+ return ptr;
104
+ }
105
+
106
+ function isLikeNone(x) {
107
+ return x === undefined || x === null;
108
+ }
109
+
110
+ let cachedInt32Memory0 = null;
111
+
112
+ function getInt32Memory0() {
113
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
114
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
115
+ }
116
+ return cachedInt32Memory0;
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
+ * @param {string} level
196
+ */
197
+ export function init_log_level(level) {
198
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
199
+ const len0 = WASM_VECTOR_LEN;
200
+ wasm.init_log_level(ptr0, len0);
201
+ }
202
+
203
+ /**
204
+ * @returns {any}
205
+ */
206
+ export function build_info() {
207
+ const ret = wasm.build_info();
208
+ return takeObject(ret);
209
+ }
210
+
211
+ function handleError(f, args) {
212
+ try {
213
+ return f.apply(this, args);
214
+ } catch (e) {
215
+ wasm.__wbindgen_export_3(addHeapObject(e));
216
+ }
217
+ }
218
+
219
+ async function load(module, imports) {
220
+ if (typeof Response === 'function' && module instanceof Response) {
221
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
222
+ try {
223
+ return await WebAssembly.instantiateStreaming(module, imports);
224
+
225
+ } catch (e) {
226
+ if (module.headers.get('Content-Type') != 'application/wasm') {
227
+ 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);
228
+
229
+ } else {
230
+ throw e;
231
+ }
232
+ }
233
+ }
234
+
235
+ const bytes = await module.arrayBuffer();
236
+ return await WebAssembly.instantiate(bytes, imports);
237
+
238
+ } else {
239
+ const instance = await WebAssembly.instantiate(module, imports);
240
+
241
+ if (instance instanceof WebAssembly.Instance) {
242
+ return { instance, module };
243
+
244
+ } else {
245
+ return instance;
246
+ }
247
+ }
248
+ }
249
+
250
+ function getImports() {
251
+ const imports = {};
252
+ imports.wbg = {};
253
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
254
+ const ret = getObject(arg0) === undefined;
255
+ return ret;
256
+ };
257
+ imports.wbg.__wbindgen_is_null = function(arg0) {
258
+ const ret = getObject(arg0) === null;
259
+ return ret;
260
+ };
261
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
262
+ takeObject(arg0);
263
+ };
264
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
265
+ const ret = getStringFromWasm0(arg0, arg1);
266
+ return addHeapObject(ret);
267
+ };
268
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
269
+ const ret = new Error();
270
+ return addHeapObject(ret);
271
+ };
272
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
273
+ const ret = getObject(arg1).stack;
274
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
275
+ const len0 = WASM_VECTOR_LEN;
276
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
277
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
278
+ };
279
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
280
+ try {
281
+ console.error(getStringFromWasm0(arg0, arg1));
282
+ } finally {
283
+ wasm.__wbindgen_export_2(arg0, arg1);
284
+ }
285
+ };
286
+ imports.wbg.__wbg_readfile_e0e65427440b9915 = function() { return handleError(function (arg0, arg1, arg2) {
287
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
288
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
289
+ const len0 = WASM_VECTOR_LEN;
290
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
291
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
292
+ }, arguments) };
293
+ imports.wbg.__wbg_debug_7960d327fd96f71a = function(arg0, arg1, arg2, arg3) {
294
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
295
+ };
296
+ imports.wbg.__wbg_error_fe807da27c4a4ced = function(arg0) {
297
+ console.error(getObject(arg0));
298
+ };
299
+ imports.wbg.__wbg_error_fd84ca2a8a977774 = function(arg0, arg1, arg2, arg3) {
300
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
301
+ };
302
+ imports.wbg.__wbg_info_5566be377f5b52ae = function(arg0, arg1, arg2, arg3) {
303
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
304
+ };
305
+ imports.wbg.__wbg_log_7b690f184ae4519b = function(arg0, arg1, arg2, arg3) {
306
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
307
+ };
308
+ imports.wbg.__wbg_warn_48cbddced45e5414 = function(arg0, arg1, arg2, arg3) {
309
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
310
+ };
311
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
312
+ const obj = getObject(arg1);
313
+ const ret = typeof(obj) === 'string' ? obj : undefined;
314
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
315
+ var len0 = WASM_VECTOR_LEN;
316
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
317
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
318
+ };
319
+ imports.wbg.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
320
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
321
+ return addHeapObject(ret);
322
+ }, arguments) };
323
+ imports.wbg.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
324
+ const ret = JSON.stringify(getObject(arg0));
325
+ return addHeapObject(ret);
326
+ }, arguments) };
327
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
328
+ throw new Error(getStringFromWasm0(arg0, arg1));
329
+ };
330
+
331
+ return imports;
332
+ }
333
+
334
+ function initMemory(imports, maybe_memory) {
335
+
336
+ }
337
+
338
+ function finalizeInit(instance, module) {
339
+ wasm = instance.exports;
340
+ init.__wbindgen_wasm_module = module;
341
+ cachedInt32Memory0 = null;
342
+ cachedUint8Memory0 = null;
343
+
344
+
345
+ return wasm;
346
+ }
347
+
348
+ function initSync(module) {
349
+ const imports = getImports();
350
+
351
+ initMemory(imports);
352
+
353
+ if (!(module instanceof WebAssembly.Module)) {
354
+ module = new WebAssembly.Module(module);
355
+ }
356
+
357
+ const instance = new WebAssembly.Instance(module, imports);
358
+
359
+ return finalizeInit(instance, module);
360
+ }
361
+
362
+ async function init(input) {
363
+ if (typeof input === 'undefined') {
364
+ input = new URL('noir_wasm_bg.wasm', import.meta.url);
365
+ }
366
+ const imports = getImports();
367
+
368
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
369
+ input = fetch(input);
370
+ }
371
+
372
+ initMemory(imports);
373
+
374
+ const { instance, module } = await load(await input, imports);
375
+
376
+ return finalizeInit(instance, module);
377
+ }
378
+
379
+ export { initSync }
380
+ export default init;
Binary file
@@ -0,0 +1,15 @@
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 init_log_level(a: number, b: number): void;
10
+ export function build_info(): number;
11
+ export function __wbindgen_export_0(a: number): number;
12
+ export function __wbindgen_export_1(a: number, b: number, c: number): number;
13
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
14
+ export function __wbindgen_export_2(a: number, b: number): void;
15
+ export function __wbindgen_export_3(a: number): void;
package/noir_wasm.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
- };