@noir-lang/noir_wasm 0.24.0-da1281f.nightly → 0.24.0-ea9a834.nightly
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/dist/node/index_bg.wasm +0 -0
- package/dist/node/main.js +183 -138
- package/dist/node/main.js.map +1 -1
- package/dist/types/build/cjs/index.d.ts +22 -22
- package/dist/types/build/esm/index.d.ts +26 -12
- package/dist/types/src/index.d.cts +38 -7
- package/dist/types/src/index.d.mts +38 -7
- package/dist/types/src/noir/noir-wasm-compiler.d.ts +3 -2
- package/dist/types/src/noir/package.d.ts +2 -2
- package/dist/types/src/types/noir_artifact.d.ts +2 -12
- package/dist/types/src/types/noir_package_config.d.ts +1 -1
- package/dist/types/webpack.config.d.ts +0 -1
- package/dist/web/main.mjs +189 -138
- package/dist/web/main.mjs.map +1 -1
- package/package.json +7 -6
package/dist/node/index_bg.wasm
CHANGED
|
Binary file
|
package/dist/node/main.js
CHANGED
|
@@ -32,12 +32,6 @@ function takeObject(idx) {
|
|
|
32
32
|
return ret;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function _assertBoolean(n) {
|
|
36
|
-
if (typeof(n) !== 'boolean') {
|
|
37
|
-
throw new Error('expected a boolean argument');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
35
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
42
36
|
|
|
43
37
|
cachedTextDecoder.decode();
|
|
@@ -61,8 +55,6 @@ function addHeapObject(obj) {
|
|
|
61
55
|
const idx = heap_next;
|
|
62
56
|
heap_next = heap[idx];
|
|
63
57
|
|
|
64
|
-
if (typeof(heap_next) !== 'number') throw new Error('corrupt heap');
|
|
65
|
-
|
|
66
58
|
heap[idx] = obj;
|
|
67
59
|
return idx;
|
|
68
60
|
}
|
|
@@ -86,8 +78,6 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
|
86
78
|
|
|
87
79
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
88
80
|
|
|
89
|
-
if (typeof(arg) !== 'string') throw new Error('expected a string argument');
|
|
90
|
-
|
|
91
81
|
if (realloc === undefined) {
|
|
92
82
|
const buf = cachedTextEncoder.encode(arg);
|
|
93
83
|
const ptr = malloc(buf.length) >>> 0;
|
|
@@ -116,7 +106,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
116
106
|
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
|
|
117
107
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
118
108
|
const ret = encodeString(arg, view);
|
|
119
|
-
|
|
109
|
+
|
|
120
110
|
offset += ret.written;
|
|
121
111
|
}
|
|
122
112
|
|
|
@@ -202,26 +192,6 @@ function debugString(val) {
|
|
|
202
192
|
return className;
|
|
203
193
|
}
|
|
204
194
|
|
|
205
|
-
function logError(f, args) {
|
|
206
|
-
try {
|
|
207
|
-
return f.apply(this, args);
|
|
208
|
-
} catch (e) {
|
|
209
|
-
let error = (function () {
|
|
210
|
-
try {
|
|
211
|
-
return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
|
|
212
|
-
} catch(_) {
|
|
213
|
-
return "<failed to stringify thrown value>";
|
|
214
|
-
}
|
|
215
|
-
}());
|
|
216
|
-
console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
|
|
217
|
-
throw e;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function _assertNum(n) {
|
|
222
|
-
if (typeof(n) !== 'number') throw new Error('expected a number argument');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
195
|
function _assertClass(instance, klass) {
|
|
226
196
|
if (!(instance instanceof klass)) {
|
|
227
197
|
throw new Error(`expected instance of ${klass.name}`);
|
|
@@ -229,26 +199,21 @@ function _assertClass(instance, klass) {
|
|
|
229
199
|
return instance.ptr;
|
|
230
200
|
}
|
|
231
201
|
/**
|
|
202
|
+
* This is a method that exposes the same API as `compile`
|
|
203
|
+
* But uses the Context based APi internally
|
|
232
204
|
* @param {string} entry_point
|
|
233
|
-
* @param {boolean | undefined} contracts
|
|
234
205
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
235
206
|
* @param {PathToFileSourceMap} file_source_map
|
|
236
|
-
* @returns {
|
|
207
|
+
* @returns {ProgramCompileResult}
|
|
237
208
|
*/
|
|
238
|
-
module.exports.
|
|
209
|
+
module.exports.compile_program_ = function(entry_point, dependency_graph, file_source_map) {
|
|
239
210
|
try {
|
|
240
211
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
241
212
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
242
213
|
const len0 = WASM_VECTOR_LEN;
|
|
243
|
-
if (!isLikeNone(contracts)) {
|
|
244
|
-
_assertBoolean(contracts);
|
|
245
|
-
}
|
|
246
214
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
247
|
-
if (file_source_map.__wbg_ptr === 0) {
|
|
248
|
-
throw new Error('Attempt to use a moved value');
|
|
249
|
-
}
|
|
250
215
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
251
|
-
wasm.
|
|
216
|
+
wasm.compile_program_(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
252
217
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
253
218
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
254
219
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -265,25 +230,70 @@ module.exports.compile = function(entry_point, contracts, dependency_graph, file
|
|
|
265
230
|
* This is a method that exposes the same API as `compile`
|
|
266
231
|
* But uses the Context based APi internally
|
|
267
232
|
* @param {string} entry_point
|
|
268
|
-
* @param {boolean | undefined} contracts
|
|
269
233
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
270
234
|
* @param {PathToFileSourceMap} file_source_map
|
|
271
|
-
* @returns {
|
|
235
|
+
* @returns {ContractCompileResult}
|
|
272
236
|
*/
|
|
273
|
-
module.exports.
|
|
237
|
+
module.exports.compile_contract_ = function(entry_point, dependency_graph, file_source_map) {
|
|
274
238
|
try {
|
|
275
239
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
276
240
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
277
241
|
const len0 = WASM_VECTOR_LEN;
|
|
278
|
-
|
|
279
|
-
|
|
242
|
+
_assertClass(file_source_map, PathToFileSourceMap);
|
|
243
|
+
var ptr1 = file_source_map.__destroy_into_raw();
|
|
244
|
+
wasm.compile_contract_(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
245
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
246
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
247
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
248
|
+
if (r2) {
|
|
249
|
+
throw takeObject(r1);
|
|
280
250
|
}
|
|
251
|
+
return takeObject(r0);
|
|
252
|
+
} finally {
|
|
253
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @param {string} entry_point
|
|
259
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
260
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
261
|
+
* @returns {ProgramCompileResult}
|
|
262
|
+
*/
|
|
263
|
+
module.exports.compile_program = function(entry_point, dependency_graph, file_source_map) {
|
|
264
|
+
try {
|
|
265
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
266
|
+
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
281
268
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
282
|
-
|
|
283
|
-
|
|
269
|
+
var ptr1 = file_source_map.__destroy_into_raw();
|
|
270
|
+
wasm.compile_program(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
271
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
272
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
273
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
274
|
+
if (r2) {
|
|
275
|
+
throw takeObject(r1);
|
|
284
276
|
}
|
|
277
|
+
return takeObject(r0);
|
|
278
|
+
} finally {
|
|
279
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @param {string} entry_point
|
|
285
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
286
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
287
|
+
* @returns {ContractCompileResult}
|
|
288
|
+
*/
|
|
289
|
+
module.exports.compile_contract = function(entry_point, dependency_graph, file_source_map) {
|
|
290
|
+
try {
|
|
291
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
292
|
+
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
_assertClass(file_source_map, PathToFileSourceMap);
|
|
285
295
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
286
|
-
wasm.
|
|
296
|
+
wasm.compile_contract(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
287
297
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
288
298
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
289
299
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -297,10 +307,10 @@ module.exports.compile_ = function(entry_point, contracts, dependency_graph, fil
|
|
|
297
307
|
};
|
|
298
308
|
|
|
299
309
|
/**
|
|
300
|
-
* @param {string}
|
|
310
|
+
* @param {string} level
|
|
301
311
|
*/
|
|
302
|
-
module.exports.init_log_level = function(
|
|
303
|
-
const ptr0 = passStringToWasm0(
|
|
312
|
+
module.exports.init_log_level = function(level) {
|
|
313
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
304
314
|
const len0 = WASM_VECTOR_LEN;
|
|
305
315
|
wasm.init_log_level(ptr0, len0);
|
|
306
316
|
};
|
|
@@ -351,9 +361,6 @@ class CompilerContext {
|
|
|
351
361
|
*/
|
|
352
362
|
constructor(source_map) {
|
|
353
363
|
_assertClass(source_map, PathToFileSourceMap);
|
|
354
|
-
if (source_map.__wbg_ptr === 0) {
|
|
355
|
-
throw new Error('Attempt to use a moved value');
|
|
356
|
-
}
|
|
357
364
|
var ptr0 = source_map.__destroy_into_raw();
|
|
358
365
|
const ret = wasm.compilercontext_new(ptr0);
|
|
359
366
|
return CompilerContext.__wrap(ret);
|
|
@@ -363,8 +370,6 @@ class CompilerContext {
|
|
|
363
370
|
* @returns {CrateId}
|
|
364
371
|
*/
|
|
365
372
|
process_root_crate(path_to_crate) {
|
|
366
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
367
|
-
_assertNum(this.__wbg_ptr);
|
|
368
373
|
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
369
374
|
const len0 = WASM_VECTOR_LEN;
|
|
370
375
|
const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
|
|
@@ -375,8 +380,6 @@ class CompilerContext {
|
|
|
375
380
|
* @returns {CrateId}
|
|
376
381
|
*/
|
|
377
382
|
process_dependency_crate(path_to_crate) {
|
|
378
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
379
|
-
_assertNum(this.__wbg_ptr);
|
|
380
383
|
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
381
384
|
const len0 = WASM_VECTOR_LEN;
|
|
382
385
|
const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
|
|
@@ -389,19 +392,11 @@ class CompilerContext {
|
|
|
389
392
|
*/
|
|
390
393
|
add_dependency_edge(crate_name, from, to) {
|
|
391
394
|
try {
|
|
392
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
393
395
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
394
|
-
_assertNum(this.__wbg_ptr);
|
|
395
396
|
const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
396
397
|
const len0 = WASM_VECTOR_LEN;
|
|
397
398
|
_assertClass(from, CrateId);
|
|
398
|
-
if (from.__wbg_ptr === 0) {
|
|
399
|
-
throw new Error('Attempt to use a moved value');
|
|
400
|
-
}
|
|
401
399
|
_assertClass(to, CrateId);
|
|
402
|
-
if (to.__wbg_ptr === 0) {
|
|
403
|
-
throw new Error('Attempt to use a moved value');
|
|
404
|
-
}
|
|
405
400
|
wasm.compilercontext_add_dependency_edge(retptr, this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
|
|
406
401
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
407
402
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -414,15 +409,12 @@ class CompilerContext {
|
|
|
414
409
|
}
|
|
415
410
|
/**
|
|
416
411
|
* @param {number} program_width
|
|
417
|
-
* @returns {
|
|
412
|
+
* @returns {ProgramCompileResult}
|
|
418
413
|
*/
|
|
419
414
|
compile_program(program_width) {
|
|
420
415
|
try {
|
|
421
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
422
416
|
const ptr = this.__destroy_into_raw();
|
|
423
417
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
424
|
-
_assertNum(ptr);
|
|
425
|
-
_assertNum(program_width);
|
|
426
418
|
wasm.compilercontext_compile_program(retptr, ptr, program_width);
|
|
427
419
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
428
420
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -437,15 +429,12 @@ class CompilerContext {
|
|
|
437
429
|
}
|
|
438
430
|
/**
|
|
439
431
|
* @param {number} program_width
|
|
440
|
-
* @returns {
|
|
432
|
+
* @returns {ContractCompileResult}
|
|
441
433
|
*/
|
|
442
434
|
compile_contract(program_width) {
|
|
443
435
|
try {
|
|
444
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
445
436
|
const ptr = this.__destroy_into_raw();
|
|
446
437
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
447
|
-
_assertNum(ptr);
|
|
448
|
-
_assertNum(program_width);
|
|
449
438
|
wasm.compilercontext_compile_contract(retptr, ptr, program_width);
|
|
450
439
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
451
440
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -464,10 +453,6 @@ module.exports.CompilerContext = CompilerContext;
|
|
|
464
453
|
*/
|
|
465
454
|
class CrateId {
|
|
466
455
|
|
|
467
|
-
constructor() {
|
|
468
|
-
throw new Error('cannot invoke `new` directly');
|
|
469
|
-
}
|
|
470
|
-
|
|
471
456
|
static __wrap(ptr) {
|
|
472
457
|
ptr = ptr >>> 0;
|
|
473
458
|
const obj = Object.create(CrateId.prototype);
|
|
@@ -524,8 +509,6 @@ class PathToFileSourceMap {
|
|
|
524
509
|
* @returns {boolean}
|
|
525
510
|
*/
|
|
526
511
|
add_source_code(path, source_code) {
|
|
527
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
528
|
-
_assertNum(this.__wbg_ptr);
|
|
529
512
|
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
530
513
|
const len0 = WASM_VECTOR_LEN;
|
|
531
514
|
const ptr1 = passStringToWasm0(source_code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
@@ -540,36 +523,35 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
540
523
|
takeObject(arg0);
|
|
541
524
|
};
|
|
542
525
|
|
|
543
|
-
module.exports.__wbg_constructor_05d6d198f3477d6f = function() { return logError(function () {
|
|
544
|
-
const ret = new Object();
|
|
545
|
-
return addHeapObject(ret);
|
|
546
|
-
}, arguments) };
|
|
547
|
-
|
|
548
526
|
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
549
527
|
const ret = getObject(arg0) === undefined;
|
|
550
|
-
_assertBoolean(ret);
|
|
551
528
|
return ret;
|
|
552
529
|
};
|
|
553
530
|
|
|
554
|
-
module.exports.
|
|
531
|
+
module.exports.__wbg_constructor_05d6d198f3477d6f = function() {
|
|
532
|
+
const ret = new Object();
|
|
533
|
+
return addHeapObject(ret);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
module.exports.__wbg_constructor_e8767839abf8a966 = function(arg0) {
|
|
555
537
|
const ret = new Error(takeObject(arg0));
|
|
556
538
|
return addHeapObject(ret);
|
|
557
|
-
}
|
|
539
|
+
};
|
|
558
540
|
|
|
559
|
-
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
541
|
+
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
560
542
|
const ret = new Error();
|
|
561
543
|
return addHeapObject(ret);
|
|
562
|
-
}
|
|
544
|
+
};
|
|
563
545
|
|
|
564
|
-
module.exports.__wbg_stack_658279fe44541cf6 = function(
|
|
546
|
+
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
565
547
|
const ret = getObject(arg1).stack;
|
|
566
548
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
567
549
|
const len1 = WASM_VECTOR_LEN;
|
|
568
550
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
569
551
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
570
|
-
}
|
|
552
|
+
};
|
|
571
553
|
|
|
572
|
-
module.exports.__wbg_error_f851667af71bcfc6 = function(
|
|
554
|
+
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
573
555
|
let deferred0_0;
|
|
574
556
|
let deferred0_1;
|
|
575
557
|
try {
|
|
@@ -579,52 +561,44 @@ module.exports.__wbg_error_f851667af71bcfc6 = function() { return logError(funct
|
|
|
579
561
|
} finally {
|
|
580
562
|
wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
|
|
581
563
|
}
|
|
582
|
-
}
|
|
564
|
+
};
|
|
583
565
|
|
|
584
566
|
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
585
567
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
586
568
|
return addHeapObject(ret);
|
|
587
569
|
};
|
|
588
570
|
|
|
589
|
-
module.exports.__wbg_debug_e3f6a1578e6d45ca = function(
|
|
571
|
+
module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
|
|
590
572
|
console.debug(getObject(arg0));
|
|
591
|
-
}
|
|
573
|
+
};
|
|
592
574
|
|
|
593
|
-
module.exports.__wbg_debug_efabe4eb183aa5d4 = function(
|
|
575
|
+
module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
|
|
594
576
|
console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
595
|
-
}
|
|
577
|
+
};
|
|
596
578
|
|
|
597
|
-
module.exports.__wbg_error_a7e23606158b68b9 = function(
|
|
579
|
+
module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
|
|
598
580
|
console.error(getObject(arg0));
|
|
599
|
-
}
|
|
581
|
+
};
|
|
600
582
|
|
|
601
|
-
module.exports.__wbg_error_50f42b952a595a23 = function(
|
|
583
|
+
module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
|
|
602
584
|
console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
603
|
-
}
|
|
585
|
+
};
|
|
604
586
|
|
|
605
|
-
module.exports.__wbg_info_05db236d79f1b785 = function(
|
|
587
|
+
module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
|
|
606
588
|
console.info(getObject(arg0));
|
|
607
|
-
}
|
|
589
|
+
};
|
|
608
590
|
|
|
609
|
-
module.exports.__wbg_info_24d8f53d98f12b95 = function(
|
|
591
|
+
module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
|
|
610
592
|
console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
module.exports.__wbg_log_dc06ec929fc95a20 = function() { return logError(function (arg0) {
|
|
614
|
-
console.log(getObject(arg0));
|
|
615
|
-
}, arguments) };
|
|
616
|
-
|
|
617
|
-
module.exports.__wbg_log_2f6947e39440ae3b = function() { return logError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
618
|
-
console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
|
|
619
|
-
}, arguments) };
|
|
593
|
+
};
|
|
620
594
|
|
|
621
|
-
module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(
|
|
595
|
+
module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
|
|
622
596
|
console.warn(getObject(arg0));
|
|
623
|
-
}
|
|
597
|
+
};
|
|
624
598
|
|
|
625
|
-
module.exports.__wbg_warn_8342bfbc6028193a = function(
|
|
599
|
+
module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
|
|
626
600
|
console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
627
|
-
}
|
|
601
|
+
};
|
|
628
602
|
|
|
629
603
|
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
630
604
|
const obj = getObject(arg1);
|
|
@@ -647,7 +621,6 @@ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleErro
|
|
|
647
621
|
|
|
648
622
|
module.exports.__wbg_set_07da13cc24b69217 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
649
623
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
650
|
-
_assertBoolean(ret);
|
|
651
624
|
return ret;
|
|
652
625
|
}, arguments) };
|
|
653
626
|
|
|
@@ -1238,18 +1211,54 @@ class NoirWasmCompiler {
|
|
|
1238
1211
|
/**
|
|
1239
1212
|
* Compile EntryPoint
|
|
1240
1213
|
*/
|
|
1214
|
+
async compile_program() {
|
|
1215
|
+
console.log(`Compiling at ${this.#package.getEntryPointPath()}`);
|
|
1216
|
+
if (this.#package.getType() !== 'bin') {
|
|
1217
|
+
throw new Error(`Expected to find package type "bin" but found ${this.#package.getType()}`);
|
|
1218
|
+
}
|
|
1219
|
+
await this.#dependencyManager.resolveDependencies();
|
|
1220
|
+
this.#debugLog(`Dependencies: ${this.#dependencyManager.getPackageNames().join(', ')}`);
|
|
1221
|
+
try {
|
|
1222
|
+
const entrypoint = this.#package.getEntryPointPath();
|
|
1223
|
+
const deps = {
|
|
1224
|
+
/* eslint-disable camelcase */
|
|
1225
|
+
root_dependencies: this.#dependencyManager.getEntrypointDependencies(),
|
|
1226
|
+
library_dependencies: this.#dependencyManager.getLibraryDependencies(),
|
|
1227
|
+
/* eslint-enable camelcase */
|
|
1228
|
+
};
|
|
1229
|
+
const packageSources = await this.#package.getSources(this.#fm);
|
|
1230
|
+
const librarySources = (await Promise.all(this.#dependencyManager
|
|
1231
|
+
.getLibraries()
|
|
1232
|
+
.map(async ([alias, library]) => await library.package.getSources(this.#fm, alias)))).flat();
|
|
1233
|
+
[...packageSources, ...librarySources].forEach((sourceFile) => {
|
|
1234
|
+
this.#debugLog(`Adding source ${sourceFile.path}`);
|
|
1235
|
+
this.#sourceMap.add_source_code(sourceFile.path, sourceFile.source);
|
|
1236
|
+
});
|
|
1237
|
+
const result = this.#wasmCompiler.compile_program(entrypoint, deps, this.#sourceMap);
|
|
1238
|
+
return result;
|
|
1239
|
+
}
|
|
1240
|
+
catch (err) {
|
|
1241
|
+
if (err instanceof Error && err.name === 'CompileError') {
|
|
1242
|
+
const logs = await this.#processCompileError(err);
|
|
1243
|
+
for (const log of logs) {
|
|
1244
|
+
this.#log(log);
|
|
1245
|
+
}
|
|
1246
|
+
throw new Error(logs.join('\n'));
|
|
1247
|
+
}
|
|
1248
|
+
throw err;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1241
1251
|
/**
|
|
1242
1252
|
* Compile EntryPoint
|
|
1243
1253
|
*/
|
|
1244
|
-
async
|
|
1254
|
+
async compile_contract() {
|
|
1245
1255
|
console.log(`Compiling at ${this.#package.getEntryPointPath()}`);
|
|
1246
|
-
if (
|
|
1247
|
-
throw new Error(`
|
|
1256
|
+
if (this.#package.getType() !== 'contract') {
|
|
1257
|
+
throw new Error(`Expected to find package type "contract" but found ${this.#package.getType()}`);
|
|
1248
1258
|
}
|
|
1249
1259
|
await this.#dependencyManager.resolveDependencies();
|
|
1250
1260
|
this.#debugLog(`Dependencies: ${this.#dependencyManager.getPackageNames().join(', ')}`);
|
|
1251
1261
|
try {
|
|
1252
|
-
const isContract = this.#package.getType() === 'contract';
|
|
1253
1262
|
const entrypoint = this.#package.getEntryPointPath();
|
|
1254
1263
|
const deps = {
|
|
1255
1264
|
/* eslint-disable camelcase */
|
|
@@ -1265,10 +1274,7 @@ class NoirWasmCompiler {
|
|
|
1265
1274
|
this.#debugLog(`Adding source ${sourceFile.path}`);
|
|
1266
1275
|
this.#sourceMap.add_source_code(sourceFile.path, sourceFile.source);
|
|
1267
1276
|
});
|
|
1268
|
-
const result = this.#wasmCompiler.
|
|
1269
|
-
if ((isContract && !('contract' in result)) || (!isContract && !('program' in result))) {
|
|
1270
|
-
throw new Error('Invalid compilation result');
|
|
1271
|
-
}
|
|
1277
|
+
const result = this.#wasmCompiler.compile_contract(entrypoint, deps, this.#sourceMap);
|
|
1272
1278
|
return result;
|
|
1273
1279
|
}
|
|
1274
1280
|
catch (err) {
|
|
@@ -1397,7 +1403,7 @@ class Package {
|
|
|
1397
1403
|
* Gets this package's dependencies.
|
|
1398
1404
|
*/
|
|
1399
1405
|
getDependencies() {
|
|
1400
|
-
return this.#config.dependencies;
|
|
1406
|
+
return this.#config.dependencies ?? {};
|
|
1401
1407
|
}
|
|
1402
1408
|
/**
|
|
1403
1409
|
* Gets this package's sources.
|
|
@@ -12817,7 +12823,7 @@ var exports = __webpack_exports__;
|
|
|
12817
12823
|
\***********************/
|
|
12818
12824
|
|
|
12819
12825
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12820
|
-
exports.inflateDebugSymbols = exports.createFileManager = exports.compile = void 0;
|
|
12826
|
+
exports.inflateDebugSymbols = exports.createFileManager = exports.compile_contract = exports.compile_program = exports.compile = void 0;
|
|
12821
12827
|
const nodejs_file_manager_1 = __webpack_require__(/*! ./noir/file-manager/nodejs-file-manager */ "./src/noir/file-manager/nodejs-file-manager.ts");
|
|
12822
12828
|
const noir_wasm_compiler_1 = __webpack_require__(/*! ./noir/noir-wasm-compiler */ "./src/noir/noir-wasm-compiler.ts");
|
|
12823
12829
|
const debug_1 = __webpack_require__(/*! ./noir/debug */ "./src/noir/debug.ts");
|
|
@@ -12834,30 +12840,71 @@ Object.defineProperty(exports, "inflateDebugSymbols", ({ enumerable: true, get:
|
|
|
12834
12840
|
* ```typescript
|
|
12835
12841
|
* // Node.js
|
|
12836
12842
|
*
|
|
12837
|
-
* import {
|
|
12843
|
+
* import { compile_program, createFileManager } from '@noir-lang/noir_wasm';
|
|
12838
12844
|
*
|
|
12839
12845
|
* const fm = createFileManager(myProjectPath);
|
|
12840
|
-
* const myCompiledCode = await
|
|
12846
|
+
* const myCompiledCode = await compile_program(fm);
|
|
12841
12847
|
* ```
|
|
12842
12848
|
*
|
|
12843
12849
|
* ```typescript
|
|
12844
12850
|
* // Browser
|
|
12845
12851
|
*
|
|
12846
|
-
* import {
|
|
12852
|
+
* import { compile_program, createFileManager } from '@noir-lang/noir_wasm';
|
|
12847
12853
|
*
|
|
12848
12854
|
* const fm = createFileManager('/');
|
|
12849
12855
|
* for (const path of files) {
|
|
12850
12856
|
* await fm.writeFile(path, await getFileAsStream(path));
|
|
12851
12857
|
* }
|
|
12852
|
-
* const myCompiledCode = await
|
|
12858
|
+
* const myCompiledCode = await compile_program(fm);
|
|
12853
12859
|
* ```
|
|
12854
12860
|
*/
|
|
12855
|
-
async function
|
|
12861
|
+
async function compile_program(fileManager, projectPath, logFn, debugLogFn) {
|
|
12862
|
+
const compiler = await setup_compiler(fileManager, projectPath, logFn, debugLogFn);
|
|
12863
|
+
return await compiler.compile_program();
|
|
12864
|
+
}
|
|
12865
|
+
exports.compile = compile_program;
|
|
12866
|
+
exports.compile_program = compile_program;
|
|
12867
|
+
/**
|
|
12868
|
+
* Compiles a Noir project
|
|
12869
|
+
*
|
|
12870
|
+
* @param fileManager - The file manager to use
|
|
12871
|
+
* @param projectPath - The path to the project inside the file manager. Defaults to the root of the file manager
|
|
12872
|
+
* @param logFn - A logging function. If not provided, console.log will be used
|
|
12873
|
+
* @param debugLogFn - A debug logging function. If not provided, logFn will be used
|
|
12874
|
+
*
|
|
12875
|
+
* @example
|
|
12876
|
+
* ```typescript
|
|
12877
|
+
* // Node.js
|
|
12878
|
+
*
|
|
12879
|
+
* import { compile_contract, createFileManager } from '@noir-lang/noir_wasm';
|
|
12880
|
+
*
|
|
12881
|
+
* const fm = createFileManager(myProjectPath);
|
|
12882
|
+
* const myCompiledCode = await compile_contract(fm);
|
|
12883
|
+
* ```
|
|
12884
|
+
*
|
|
12885
|
+
* ```typescript
|
|
12886
|
+
* // Browser
|
|
12887
|
+
*
|
|
12888
|
+
* import { compile_contract, createFileManager } from '@noir-lang/noir_wasm';
|
|
12889
|
+
*
|
|
12890
|
+
* const fm = createFileManager('/');
|
|
12891
|
+
* for (const path of files) {
|
|
12892
|
+
* await fm.writeFile(path, await getFileAsStream(path));
|
|
12893
|
+
* }
|
|
12894
|
+
* const myCompiledCode = await compile_contract(fm);
|
|
12895
|
+
* ```
|
|
12896
|
+
*/
|
|
12897
|
+
async function compile_contract(fileManager, projectPath, logFn, debugLogFn) {
|
|
12898
|
+
const compiler = await setup_compiler(fileManager, projectPath, logFn, debugLogFn);
|
|
12899
|
+
return await compiler.compile_contract();
|
|
12900
|
+
}
|
|
12901
|
+
exports.compile_contract = compile_contract;
|
|
12902
|
+
async function setup_compiler(fileManager, projectPath, logFn, debugLogFn) {
|
|
12856
12903
|
if (logFn && !debugLogFn) {
|
|
12857
12904
|
debugLogFn = logFn;
|
|
12858
12905
|
}
|
|
12859
12906
|
const cjs = await __webpack_require__(/*! ../build/cjs */ "./build/cjs/index.js");
|
|
12860
|
-
|
|
12907
|
+
return await noir_wasm_compiler_1.NoirWasmCompiler.new(fileManager, projectPath ?? fileManager.getDataDir(), cjs, new cjs.PathToFileSourceMap(), {
|
|
12861
12908
|
log: logFn ??
|
|
12862
12909
|
function (msg, data) {
|
|
12863
12910
|
if (data) {
|
|
@@ -12877,9 +12924,7 @@ async function compile(fileManager, projectPath, logFn, debugLogFn) {
|
|
|
12877
12924
|
}
|
|
12878
12925
|
},
|
|
12879
12926
|
});
|
|
12880
|
-
return await compiler.compile();
|
|
12881
12927
|
}
|
|
12882
|
-
exports.compile = compile;
|
|
12883
12928
|
const createFileManager = nodejs_file_manager_1.createNodejsFileManager;
|
|
12884
12929
|
exports.createFileManager = createFileManager;
|
|
12885
12930
|
|