@noir-lang/noir_wasm 0.4.0 → 0.4.1-b51f74a

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@b51f74a](https://github.com/noir-lang/noir/tree/b51f74a20831e0a2602167855cf405c11f5b70d3)
@@ -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 {Uint8Array} bytes
10
+ * @returns {any}
11
+ */
12
+ export function acir_read_bytes(bytes: Uint8Array): any;
13
+ /**
14
+ * @param {any} acir
15
+ * @returns {Uint8Array}
16
+ */
17
+ export function acir_write_bytes(acir: any): Uint8Array;
18
+ /**
19
+ * @param {string} level
20
+ */
21
+ export function init_log_level(level: string): void;
22
+ /**
23
+ * @returns {any}
24
+ */
25
+ 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
+ }
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 });
14
28
 
15
- let cachedUint8Memory0 = new Uint8Array();
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
 
@@ -134,10 +136,10 @@ function passArray8ToWasm0(arg, malloc) {
134
136
  * @param {Uint8Array} bytes
135
137
  * @returns {any}
136
138
  */
137
- module.exports.acir_from_bytes = function(bytes) {
139
+ module.exports.acir_read_bytes = function(bytes) {
138
140
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
139
141
  const len0 = WASM_VECTOR_LEN;
140
- const ret = wasm.acir_from_bytes(ptr0, len0);
142
+ const ret = wasm.acir_read_bytes(ptr0, len0);
141
143
  return takeObject(ret);
142
144
  };
143
145
 
@@ -148,10 +150,10 @@ function getArrayU8FromWasm0(ptr, len) {
148
150
  * @param {any} acir
149
151
  * @returns {Uint8Array}
150
152
  */
151
- module.exports.acir_to_bytes = function(acir) {
153
+ module.exports.acir_write_bytes = function(acir) {
152
154
  try {
153
155
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
154
- wasm.acir_to_bytes(retptr, addHeapObject(acir));
156
+ wasm.acir_write_bytes(retptr, addHeapObject(acir));
155
157
  var r0 = getInt32Memory0()[retptr / 4 + 0];
156
158
  var r1 = getInt32Memory0()[retptr / 4 + 1];
157
159
  var v0 = getArrayU8FromWasm0(r0, r1).slice();
@@ -162,6 +164,23 @@ module.exports.acir_to_bytes = function(acir) {
162
164
  }
163
165
  };
164
166
 
167
+ /**
168
+ * @param {string} level
169
+ */
170
+ module.exports.init_log_level = function(level) {
171
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
172
+ const len0 = WASM_VECTOR_LEN;
173
+ wasm.init_log_level(ptr0, len0);
174
+ };
175
+
176
+ /**
177
+ * @returns {any}
178
+ */
179
+ module.exports.build_info = function() {
180
+ const ret = wasm.build_info();
181
+ return takeObject(ret);
182
+ };
183
+
165
184
  function handleError(f, args) {
166
185
  try {
167
186
  return f.apply(this, args);
@@ -170,38 +189,31 @@ function handleError(f, args) {
170
189
  }
171
190
  }
172
191
 
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;
192
+ module.exports.__wbindgen_is_undefined = function(arg0) {
193
+ const ret = getObject(arg0) === undefined;
194
+ return ret;
195
+ };
196
+
197
+ module.exports.__wbindgen_is_null = function(arg0) {
198
+ const ret = getObject(arg0) === null;
199
+ return ret;
180
200
  };
181
201
 
182
202
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
183
203
  takeObject(arg0);
184
204
  };
185
205
 
186
- module.exports.__wbindgen_json_parse = function(arg0, arg1) {
187
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
206
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
207
+ const ret = getStringFromWasm0(arg0, arg1);
188
208
  return addHeapObject(ret);
189
209
  };
190
210
 
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() {
211
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
200
212
  const ret = new Error();
201
213
  return addHeapObject(ret);
202
214
  };
203
215
 
204
- module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
216
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
205
217
  const ret = getObject(arg1).stack;
206
218
  const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
207
219
  const len0 = WASM_VECTOR_LEN;
@@ -209,7 +221,7 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
209
221
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
210
222
  };
211
223
 
212
- module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
224
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
213
225
  try {
214
226
  console.error(getStringFromWasm0(arg0, arg1));
215
227
  } finally {
@@ -217,138 +229,61 @@ module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
217
229
  }
218
230
  };
219
231
 
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));
232
+ module.exports.__wbg_readfile_e0e65427440b9915 = function() { return handleError(function (arg0, arg1, arg2) {
233
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
234
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
237
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
226
238
  }, arguments) };
227
239
 
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;
237
- };
238
-
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);
240
+ module.exports.__wbg_debug_7960d327fd96f71a = function(arg0, arg1, arg2, arg3) {
241
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
247
242
  };
248
243
 
249
- module.exports.__wbindgen_is_string = function(arg0) {
250
- const ret = typeof(getObject(arg0)) === 'string';
251
- return ret;
244
+ module.exports.__wbg_error_fe807da27c4a4ced = function(arg0) {
245
+ console.error(getObject(arg0));
252
246
  };
253
247
 
254
- module.exports.__wbg_crypto_b95d7173266618a9 = function(arg0) {
255
- const ret = getObject(arg0).crypto;
256
- return addHeapObject(ret);
248
+ module.exports.__wbg_error_fd84ca2a8a977774 = function(arg0, arg1, arg2, arg3) {
249
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
257
250
  };
258
251
 
259
- module.exports.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
260
- const ret = getObject(arg0).msCrypto;
261
- return addHeapObject(ret);
252
+ module.exports.__wbg_info_5566be377f5b52ae = function(arg0, arg1, arg2, arg3) {
253
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
262
254
  };
263
255
 
264
- module.exports.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
265
- const ret = module;
266
- return addHeapObject(ret);
256
+ module.exports.__wbg_log_7b690f184ae4519b = function(arg0, arg1, arg2, arg3) {
257
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
267
258
  };
268
259
 
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);
260
+ module.exports.__wbg_warn_48cbddced45e5414 = function(arg0, arg1, arg2, arg3) {
261
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
277
262
  };
278
263
 
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);
264
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
265
+ const obj = getObject(arg1);
266
+ const ret = typeof(obj) === 'string' ? obj : undefined;
267
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
268
+ var len0 = WASM_VECTOR_LEN;
269
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
270
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
287
271
  };
288
272
 
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;
273
+ module.exports.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
274
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
301
275
  return addHeapObject(ret);
302
276
  }, arguments) };
303
277
 
304
- module.exports.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
305
- const ret = global.global;
278
+ module.exports.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
279
+ const ret = JSON.stringify(getObject(arg0));
306
280
  return addHeapObject(ret);
307
281
  }, arguments) };
308
282
 
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
283
  module.exports.__wbindgen_throw = function(arg0, arg1) {
344
284
  throw new Error(getStringFromWasm0(arg0, arg1));
345
285
  };
346
286
 
347
- module.exports.__wbindgen_memory = function() {
348
- const ret = wasm.memory;
349
- return addHeapObject(ret);
350
- };
351
-
352
287
  const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
353
288
  const bytes = require('fs').readFileSync(path);
354
289
 
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 acir_read_bytes(a: number, b: number): number;
6
+ export function acir_write_bytes(a: number, b: number): void;
7
+ export function init_log_level(a: number, b: number): void;
8
+ export function build_info(): number;
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_add_to_stack_pointer(a: number): number;
12
+ export function __wbindgen_export_2(a: number, b: number): void;
13
+ export function __wbindgen_export_3(a: number): void;
package/package.json CHANGED
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "version": "0.4.0",
3
+ "collaborators": [
4
+ "The Noir Team <team@noir-lang.org>"
5
+ ],
6
+ "version": "0.4.1-b51f74a",
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": "b51f74a20831e0a2602167855cf405c11f5b70d3"
25
+ }
26
+ }
@@ -0,0 +1,62 @@
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_read_bytes(bytes: Uint8Array): any;
13
+ /**
14
+ * @param {any} acir
15
+ * @returns {Uint8Array}
16
+ */
17
+ export function acir_write_bytes(acir: any): Uint8Array;
18
+ /**
19
+ * @param {string} level
20
+ */
21
+ export function init_log_level(level: string): void;
22
+ /**
23
+ * @returns {any}
24
+ */
25
+ export function build_info(): any;
26
+
27
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
28
+
29
+ export interface InitOutput {
30
+ readonly memory: WebAssembly.Memory;
31
+ readonly compile: (a: number) => number;
32
+ readonly acir_read_bytes: (a: number, b: number) => number;
33
+ readonly acir_write_bytes: (a: number, b: number) => void;
34
+ readonly init_log_level: (a: number, b: number) => void;
35
+ readonly build_info: () => number;
36
+ readonly __wbindgen_export_0: (a: number) => number;
37
+ readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
38
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
39
+ readonly __wbindgen_export_2: (a: number, b: number) => void;
40
+ readonly __wbindgen_export_3: (a: number) => void;
41
+ }
42
+
43
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
44
+ /**
45
+ * Instantiates the given `module`, which can either be bytes or
46
+ * a precompiled `WebAssembly.Module`.
47
+ *
48
+ * @param {SyncInitInput} module
49
+ *
50
+ * @returns {InitOutput}
51
+ */
52
+ export function initSync(module: SyncInitInput): InitOutput;
53
+
54
+ /**
55
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
56
+ * for everything else, calls `WebAssembly.instantiate` directly.
57
+ *
58
+ * @param {InitInput | Promise<InitInput>} module_or_path
59
+ *
60
+ * @returns {Promise<InitOutput>}
61
+ */
62
+ export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,351 @@
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_read_bytes(bytes) {
138
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ret = wasm.acir_read_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_write_bytes(acir) {
152
+ try {
153
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
154
+ wasm.acir_write_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 {string} level
167
+ */
168
+ export function init_log_level(level) {
169
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
170
+ const len0 = WASM_VECTOR_LEN;
171
+ wasm.init_log_level(ptr0, len0);
172
+ }
173
+
174
+ /**
175
+ * @returns {any}
176
+ */
177
+ export function build_info() {
178
+ const ret = wasm.build_info();
179
+ return takeObject(ret);
180
+ }
181
+
182
+ function handleError(f, args) {
183
+ try {
184
+ return f.apply(this, args);
185
+ } catch (e) {
186
+ wasm.__wbindgen_export_3(addHeapObject(e));
187
+ }
188
+ }
189
+
190
+ async function load(module, imports) {
191
+ if (typeof Response === 'function' && module instanceof Response) {
192
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
193
+ try {
194
+ return await WebAssembly.instantiateStreaming(module, imports);
195
+
196
+ } catch (e) {
197
+ if (module.headers.get('Content-Type') != 'application/wasm') {
198
+ 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);
199
+
200
+ } else {
201
+ throw e;
202
+ }
203
+ }
204
+ }
205
+
206
+ const bytes = await module.arrayBuffer();
207
+ return await WebAssembly.instantiate(bytes, imports);
208
+
209
+ } else {
210
+ const instance = await WebAssembly.instantiate(module, imports);
211
+
212
+ if (instance instanceof WebAssembly.Instance) {
213
+ return { instance, module };
214
+
215
+ } else {
216
+ return instance;
217
+ }
218
+ }
219
+ }
220
+
221
+ function getImports() {
222
+ const imports = {};
223
+ imports.wbg = {};
224
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
225
+ const ret = getObject(arg0) === undefined;
226
+ return ret;
227
+ };
228
+ imports.wbg.__wbindgen_is_null = function(arg0) {
229
+ const ret = getObject(arg0) === null;
230
+ return ret;
231
+ };
232
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
233
+ takeObject(arg0);
234
+ };
235
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
236
+ const ret = getStringFromWasm0(arg0, arg1);
237
+ return addHeapObject(ret);
238
+ };
239
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
240
+ const ret = new Error();
241
+ return addHeapObject(ret);
242
+ };
243
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
244
+ const ret = getObject(arg1).stack;
245
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
246
+ const len0 = WASM_VECTOR_LEN;
247
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
248
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
249
+ };
250
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
251
+ try {
252
+ console.error(getStringFromWasm0(arg0, arg1));
253
+ } finally {
254
+ wasm.__wbindgen_export_2(arg0, arg1);
255
+ }
256
+ };
257
+ imports.wbg.__wbg_readfile_e0e65427440b9915 = function() { return handleError(function (arg0, arg1, arg2) {
258
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
259
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
260
+ const len0 = WASM_VECTOR_LEN;
261
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
262
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
263
+ }, arguments) };
264
+ imports.wbg.__wbg_debug_7960d327fd96f71a = function(arg0, arg1, arg2, arg3) {
265
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
266
+ };
267
+ imports.wbg.__wbg_error_fe807da27c4a4ced = function(arg0) {
268
+ console.error(getObject(arg0));
269
+ };
270
+ imports.wbg.__wbg_error_fd84ca2a8a977774 = function(arg0, arg1, arg2, arg3) {
271
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
272
+ };
273
+ imports.wbg.__wbg_info_5566be377f5b52ae = function(arg0, arg1, arg2, arg3) {
274
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
275
+ };
276
+ imports.wbg.__wbg_log_7b690f184ae4519b = function(arg0, arg1, arg2, arg3) {
277
+ console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
278
+ };
279
+ imports.wbg.__wbg_warn_48cbddced45e5414 = function(arg0, arg1, arg2, arg3) {
280
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
281
+ };
282
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
283
+ const obj = getObject(arg1);
284
+ const ret = typeof(obj) === 'string' ? obj : undefined;
285
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
286
+ var len0 = WASM_VECTOR_LEN;
287
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
288
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
289
+ };
290
+ imports.wbg.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
291
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
292
+ return addHeapObject(ret);
293
+ }, arguments) };
294
+ imports.wbg.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
295
+ const ret = JSON.stringify(getObject(arg0));
296
+ return addHeapObject(ret);
297
+ }, arguments) };
298
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
299
+ throw new Error(getStringFromWasm0(arg0, arg1));
300
+ };
301
+
302
+ return imports;
303
+ }
304
+
305
+ function initMemory(imports, maybe_memory) {
306
+
307
+ }
308
+
309
+ function finalizeInit(instance, module) {
310
+ wasm = instance.exports;
311
+ init.__wbindgen_wasm_module = module;
312
+ cachedInt32Memory0 = null;
313
+ cachedUint8Memory0 = null;
314
+
315
+
316
+ return wasm;
317
+ }
318
+
319
+ function initSync(module) {
320
+ const imports = getImports();
321
+
322
+ initMemory(imports);
323
+
324
+ if (!(module instanceof WebAssembly.Module)) {
325
+ module = new WebAssembly.Module(module);
326
+ }
327
+
328
+ const instance = new WebAssembly.Instance(module, imports);
329
+
330
+ return finalizeInit(instance, module);
331
+ }
332
+
333
+ async function init(input) {
334
+ if (typeof input === 'undefined') {
335
+ input = new URL('noir_wasm_bg.wasm', import.meta.url);
336
+ }
337
+ const imports = getImports();
338
+
339
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
340
+ input = fetch(input);
341
+ }
342
+
343
+ initMemory(imports);
344
+
345
+ const { instance, module } = await load(await input, imports);
346
+
347
+ return finalizeInit(instance, module);
348
+ }
349
+
350
+ export { initSync }
351
+ export default 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 acir_read_bytes(a: number, b: number): number;
6
+ export function acir_write_bytes(a: number, b: number): void;
7
+ export function init_log_level(a: number, b: number): void;
8
+ export function build_info(): number;
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_add_to_stack_pointer(a: number): number;
12
+ export function __wbindgen_export_2(a: number, b: number): void;
13
+ 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,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
- };