@noir-lang/noir_wasm 0.24.0-b5e5c30.nightly → 0.24.0-b60279b.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 +189 -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/web/main.mjs +194 -137
- package/dist/web/main.mjs.map +1 -1
- package/package.json +2 -2
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
|
|
|
@@ -208,33 +198,22 @@ function _assertClass(instance, klass) {
|
|
|
208
198
|
}
|
|
209
199
|
return instance.ptr;
|
|
210
200
|
}
|
|
211
|
-
|
|
212
|
-
function _assertNum(n) {
|
|
213
|
-
if (typeof(n) !== 'number') throw new Error('expected a number argument');
|
|
214
|
-
}
|
|
215
201
|
/**
|
|
216
202
|
* This is a method that exposes the same API as `compile`
|
|
217
203
|
* But uses the Context based APi internally
|
|
218
204
|
* @param {string} entry_point
|
|
219
|
-
* @param {boolean | undefined} contracts
|
|
220
205
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
221
206
|
* @param {PathToFileSourceMap} file_source_map
|
|
222
|
-
* @returns {
|
|
207
|
+
* @returns {ProgramCompileResult}
|
|
223
208
|
*/
|
|
224
|
-
module.exports.
|
|
209
|
+
module.exports.compile_program_ = function(entry_point, dependency_graph, file_source_map) {
|
|
225
210
|
try {
|
|
226
211
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
227
212
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
228
213
|
const len0 = WASM_VECTOR_LEN;
|
|
229
|
-
if (!isLikeNone(contracts)) {
|
|
230
|
-
_assertBoolean(contracts);
|
|
231
|
-
}
|
|
232
214
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
233
|
-
if (file_source_map.__wbg_ptr === 0) {
|
|
234
|
-
throw new Error('Attempt to use a moved value');
|
|
235
|
-
}
|
|
236
215
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
237
|
-
wasm.
|
|
216
|
+
wasm.compile_program_(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
238
217
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
239
218
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
240
219
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -247,42 +226,74 @@ module.exports.compile_ = function(entry_point, contracts, dependency_graph, fil
|
|
|
247
226
|
}
|
|
248
227
|
};
|
|
249
228
|
|
|
250
|
-
|
|
229
|
+
/**
|
|
230
|
+
* This is a method that exposes the same API as `compile`
|
|
231
|
+
* But uses the Context based APi internally
|
|
232
|
+
* @param {string} entry_point
|
|
233
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
234
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
235
|
+
* @returns {ContractCompileResult}
|
|
236
|
+
*/
|
|
237
|
+
module.exports.compile_contract_ = function(entry_point, dependency_graph, file_source_map) {
|
|
251
238
|
try {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
239
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
240
|
+
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
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);
|
|
250
|
+
}
|
|
251
|
+
return takeObject(r0);
|
|
252
|
+
} finally {
|
|
253
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
263
254
|
}
|
|
264
|
-
}
|
|
255
|
+
};
|
|
256
|
+
|
|
265
257
|
/**
|
|
266
258
|
* @param {string} entry_point
|
|
267
|
-
* @param {boolean | undefined} contracts
|
|
268
259
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
269
260
|
* @param {PathToFileSourceMap} file_source_map
|
|
270
|
-
* @returns {
|
|
261
|
+
* @returns {ProgramCompileResult}
|
|
271
262
|
*/
|
|
272
|
-
module.exports.
|
|
263
|
+
module.exports.compile_program = function(entry_point, dependency_graph, file_source_map) {
|
|
273
264
|
try {
|
|
274
265
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
275
266
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
276
267
|
const len0 = WASM_VECTOR_LEN;
|
|
277
|
-
if (!isLikeNone(contracts)) {
|
|
278
|
-
_assertBoolean(contracts);
|
|
279
|
-
}
|
|
280
268
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
281
|
-
|
|
282
|
-
|
|
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);
|
|
283
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);
|
|
284
295
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
285
|
-
wasm.
|
|
296
|
+
wasm.compile_contract(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
286
297
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
287
298
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
288
299
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -296,10 +307,10 @@ module.exports.compile = function(entry_point, contracts, dependency_graph, file
|
|
|
296
307
|
};
|
|
297
308
|
|
|
298
309
|
/**
|
|
299
|
-
* @param {string}
|
|
310
|
+
* @param {string} level
|
|
300
311
|
*/
|
|
301
|
-
module.exports.init_log_level = function(
|
|
302
|
-
const ptr0 = passStringToWasm0(
|
|
312
|
+
module.exports.init_log_level = function(level) {
|
|
313
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
303
314
|
const len0 = WASM_VECTOR_LEN;
|
|
304
315
|
wasm.init_log_level(ptr0, len0);
|
|
305
316
|
};
|
|
@@ -350,9 +361,6 @@ class CompilerContext {
|
|
|
350
361
|
*/
|
|
351
362
|
constructor(source_map) {
|
|
352
363
|
_assertClass(source_map, PathToFileSourceMap);
|
|
353
|
-
if (source_map.__wbg_ptr === 0) {
|
|
354
|
-
throw new Error('Attempt to use a moved value');
|
|
355
|
-
}
|
|
356
364
|
var ptr0 = source_map.__destroy_into_raw();
|
|
357
365
|
const ret = wasm.compilercontext_new(ptr0);
|
|
358
366
|
return CompilerContext.__wrap(ret);
|
|
@@ -362,8 +370,6 @@ class CompilerContext {
|
|
|
362
370
|
* @returns {CrateId}
|
|
363
371
|
*/
|
|
364
372
|
process_root_crate(path_to_crate) {
|
|
365
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
366
|
-
_assertNum(this.__wbg_ptr);
|
|
367
373
|
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
368
374
|
const len0 = WASM_VECTOR_LEN;
|
|
369
375
|
const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
|
|
@@ -374,8 +380,6 @@ class CompilerContext {
|
|
|
374
380
|
* @returns {CrateId}
|
|
375
381
|
*/
|
|
376
382
|
process_dependency_crate(path_to_crate) {
|
|
377
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
378
|
-
_assertNum(this.__wbg_ptr);
|
|
379
383
|
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
380
384
|
const len0 = WASM_VECTOR_LEN;
|
|
381
385
|
const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
|
|
@@ -388,19 +392,11 @@ class CompilerContext {
|
|
|
388
392
|
*/
|
|
389
393
|
add_dependency_edge(crate_name, from, to) {
|
|
390
394
|
try {
|
|
391
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
392
395
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
393
|
-
_assertNum(this.__wbg_ptr);
|
|
394
396
|
const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
395
397
|
const len0 = WASM_VECTOR_LEN;
|
|
396
398
|
_assertClass(from, CrateId);
|
|
397
|
-
if (from.__wbg_ptr === 0) {
|
|
398
|
-
throw new Error('Attempt to use a moved value');
|
|
399
|
-
}
|
|
400
399
|
_assertClass(to, CrateId);
|
|
401
|
-
if (to.__wbg_ptr === 0) {
|
|
402
|
-
throw new Error('Attempt to use a moved value');
|
|
403
|
-
}
|
|
404
400
|
wasm.compilercontext_add_dependency_edge(retptr, this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
|
|
405
401
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
406
402
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -413,15 +409,12 @@ class CompilerContext {
|
|
|
413
409
|
}
|
|
414
410
|
/**
|
|
415
411
|
* @param {number} program_width
|
|
416
|
-
* @returns {
|
|
412
|
+
* @returns {ProgramCompileResult}
|
|
417
413
|
*/
|
|
418
414
|
compile_program(program_width) {
|
|
419
415
|
try {
|
|
420
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
421
416
|
const ptr = this.__destroy_into_raw();
|
|
422
417
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
423
|
-
_assertNum(ptr);
|
|
424
|
-
_assertNum(program_width);
|
|
425
418
|
wasm.compilercontext_compile_program(retptr, ptr, program_width);
|
|
426
419
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
427
420
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -436,15 +429,12 @@ class CompilerContext {
|
|
|
436
429
|
}
|
|
437
430
|
/**
|
|
438
431
|
* @param {number} program_width
|
|
439
|
-
* @returns {
|
|
432
|
+
* @returns {ContractCompileResult}
|
|
440
433
|
*/
|
|
441
434
|
compile_contract(program_width) {
|
|
442
435
|
try {
|
|
443
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
444
436
|
const ptr = this.__destroy_into_raw();
|
|
445
437
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
446
|
-
_assertNum(ptr);
|
|
447
|
-
_assertNum(program_width);
|
|
448
438
|
wasm.compilercontext_compile_contract(retptr, ptr, program_width);
|
|
449
439
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
450
440
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
@@ -463,10 +453,6 @@ module.exports.CompilerContext = CompilerContext;
|
|
|
463
453
|
*/
|
|
464
454
|
class CrateId {
|
|
465
455
|
|
|
466
|
-
constructor() {
|
|
467
|
-
throw new Error('cannot invoke `new` directly');
|
|
468
|
-
}
|
|
469
|
-
|
|
470
456
|
static __wrap(ptr) {
|
|
471
457
|
ptr = ptr >>> 0;
|
|
472
458
|
const obj = Object.create(CrateId.prototype);
|
|
@@ -523,8 +509,6 @@ class PathToFileSourceMap {
|
|
|
523
509
|
* @returns {boolean}
|
|
524
510
|
*/
|
|
525
511
|
add_source_code(path, source_code) {
|
|
526
|
-
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
527
|
-
_assertNum(this.__wbg_ptr);
|
|
528
512
|
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
529
513
|
const len0 = WASM_VECTOR_LEN;
|
|
530
514
|
const ptr1 = passStringToWasm0(source_code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
@@ -539,36 +523,35 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
539
523
|
takeObject(arg0);
|
|
540
524
|
};
|
|
541
525
|
|
|
542
|
-
module.exports.
|
|
526
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
527
|
+
const ret = getObject(arg0) === undefined;
|
|
528
|
+
return ret;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
module.exports.__wbg_constructor_05d6d198f3477d6f = function() {
|
|
543
532
|
const ret = new Object();
|
|
544
533
|
return addHeapObject(ret);
|
|
545
|
-
}
|
|
534
|
+
};
|
|
546
535
|
|
|
547
|
-
module.exports.__wbg_constructor_e8767839abf8a966 = function(
|
|
536
|
+
module.exports.__wbg_constructor_e8767839abf8a966 = function(arg0) {
|
|
548
537
|
const ret = new Error(takeObject(arg0));
|
|
549
538
|
return addHeapObject(ret);
|
|
550
|
-
}, arguments) };
|
|
551
|
-
|
|
552
|
-
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
553
|
-
const ret = getObject(arg0) === undefined;
|
|
554
|
-
_assertBoolean(ret);
|
|
555
|
-
return ret;
|
|
556
539
|
};
|
|
557
540
|
|
|
558
|
-
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
541
|
+
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
559
542
|
const ret = new Error();
|
|
560
543
|
return addHeapObject(ret);
|
|
561
|
-
}
|
|
544
|
+
};
|
|
562
545
|
|
|
563
|
-
module.exports.__wbg_stack_658279fe44541cf6 = function(
|
|
546
|
+
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
564
547
|
const ret = getObject(arg1).stack;
|
|
565
548
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
566
549
|
const len1 = WASM_VECTOR_LEN;
|
|
567
550
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
568
551
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
569
|
-
}
|
|
552
|
+
};
|
|
570
553
|
|
|
571
|
-
module.exports.__wbg_error_f851667af71bcfc6 = function(
|
|
554
|
+
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
572
555
|
let deferred0_0;
|
|
573
556
|
let deferred0_1;
|
|
574
557
|
try {
|
|
@@ -578,52 +561,44 @@ module.exports.__wbg_error_f851667af71bcfc6 = function() { return logError(funct
|
|
|
578
561
|
} finally {
|
|
579
562
|
wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
|
|
580
563
|
}
|
|
581
|
-
}
|
|
564
|
+
};
|
|
582
565
|
|
|
583
566
|
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
584
567
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
585
568
|
return addHeapObject(ret);
|
|
586
569
|
};
|
|
587
570
|
|
|
588
|
-
module.exports.__wbg_debug_e3f6a1578e6d45ca = function(
|
|
571
|
+
module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
|
|
589
572
|
console.debug(getObject(arg0));
|
|
590
|
-
}
|
|
573
|
+
};
|
|
591
574
|
|
|
592
|
-
module.exports.__wbg_debug_efabe4eb183aa5d4 = function(
|
|
575
|
+
module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
|
|
593
576
|
console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
594
|
-
}
|
|
577
|
+
};
|
|
595
578
|
|
|
596
|
-
module.exports.__wbg_error_a7e23606158b68b9 = function(
|
|
579
|
+
module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
|
|
597
580
|
console.error(getObject(arg0));
|
|
598
|
-
}
|
|
581
|
+
};
|
|
599
582
|
|
|
600
|
-
module.exports.__wbg_error_50f42b952a595a23 = function(
|
|
583
|
+
module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
|
|
601
584
|
console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
602
|
-
}
|
|
585
|
+
};
|
|
603
586
|
|
|
604
|
-
module.exports.__wbg_info_05db236d79f1b785 = function(
|
|
587
|
+
module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
|
|
605
588
|
console.info(getObject(arg0));
|
|
606
|
-
}
|
|
589
|
+
};
|
|
607
590
|
|
|
608
|
-
module.exports.__wbg_info_24d8f53d98f12b95 = function(
|
|
591
|
+
module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
|
|
609
592
|
console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
module.exports.__wbg_log_dc06ec929fc95a20 = function() { return logError(function (arg0) {
|
|
613
|
-
console.log(getObject(arg0));
|
|
614
|
-
}, arguments) };
|
|
615
|
-
|
|
616
|
-
module.exports.__wbg_log_2f6947e39440ae3b = function() { return logError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
617
|
-
console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
|
|
618
|
-
}, arguments) };
|
|
593
|
+
};
|
|
619
594
|
|
|
620
|
-
module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(
|
|
595
|
+
module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
|
|
621
596
|
console.warn(getObject(arg0));
|
|
622
|
-
}
|
|
597
|
+
};
|
|
623
598
|
|
|
624
|
-
module.exports.__wbg_warn_8342bfbc6028193a = function(
|
|
599
|
+
module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
|
|
625
600
|
console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
|
|
626
|
-
}
|
|
601
|
+
};
|
|
627
602
|
|
|
628
603
|
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
629
604
|
const obj = getObject(arg1);
|
|
@@ -646,7 +621,6 @@ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleErro
|
|
|
646
621
|
|
|
647
622
|
module.exports.__wbg_set_07da13cc24b69217 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
648
623
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
649
|
-
_assertBoolean(ret);
|
|
650
624
|
return ret;
|
|
651
625
|
}, arguments) };
|
|
652
626
|
|
|
@@ -1237,18 +1211,54 @@ class NoirWasmCompiler {
|
|
|
1237
1211
|
/**
|
|
1238
1212
|
* Compile EntryPoint
|
|
1239
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
|
+
}
|
|
1240
1251
|
/**
|
|
1241
1252
|
* Compile EntryPoint
|
|
1242
1253
|
*/
|
|
1243
|
-
async
|
|
1254
|
+
async compile_contract() {
|
|
1244
1255
|
console.log(`Compiling at ${this.#package.getEntryPointPath()}`);
|
|
1245
|
-
if (
|
|
1246
|
-
throw new Error(`
|
|
1256
|
+
if (this.#package.getType() !== 'contract') {
|
|
1257
|
+
throw new Error(`Expected to find package type "contract" but found ${this.#package.getType()}`);
|
|
1247
1258
|
}
|
|
1248
1259
|
await this.#dependencyManager.resolveDependencies();
|
|
1249
1260
|
this.#debugLog(`Dependencies: ${this.#dependencyManager.getPackageNames().join(', ')}`);
|
|
1250
1261
|
try {
|
|
1251
|
-
const isContract = this.#package.getType() === 'contract';
|
|
1252
1262
|
const entrypoint = this.#package.getEntryPointPath();
|
|
1253
1263
|
const deps = {
|
|
1254
1264
|
/* eslint-disable camelcase */
|
|
@@ -1264,10 +1274,7 @@ class NoirWasmCompiler {
|
|
|
1264
1274
|
this.#debugLog(`Adding source ${sourceFile.path}`);
|
|
1265
1275
|
this.#sourceMap.add_source_code(sourceFile.path, sourceFile.source);
|
|
1266
1276
|
});
|
|
1267
|
-
const result = this.#wasmCompiler.
|
|
1268
|
-
if ((isContract && !('contract' in result)) || (!isContract && !('program' in result))) {
|
|
1269
|
-
throw new Error('Invalid compilation result');
|
|
1270
|
-
}
|
|
1277
|
+
const result = this.#wasmCompiler.compile_contract(entrypoint, deps, this.#sourceMap);
|
|
1271
1278
|
return result;
|
|
1272
1279
|
}
|
|
1273
1280
|
catch (err) {
|
|
@@ -1396,7 +1403,7 @@ class Package {
|
|
|
1396
1403
|
* Gets this package's dependencies.
|
|
1397
1404
|
*/
|
|
1398
1405
|
getDependencies() {
|
|
1399
|
-
return this.#config.dependencies;
|
|
1406
|
+
return this.#config.dependencies ?? {};
|
|
1400
1407
|
}
|
|
1401
1408
|
/**
|
|
1402
1409
|
* Gets this package's sources.
|
|
@@ -1408,7 +1415,12 @@ class Package {
|
|
|
1408
1415
|
return Promise.all(handles
|
|
1409
1416
|
.filter((handle) => SOURCE_EXTENSIONS.find((ext) => handle.endsWith(ext)))
|
|
1410
1417
|
.map(async (file) => {
|
|
1411
|
-
|
|
1418
|
+
// Github deps are directly added to the file manager, which causes them to be missing the absolute path to the source file
|
|
1419
|
+
// and only include the extraction directory relative to the fm root directory
|
|
1420
|
+
// This regexp ensures we remove the "real" source path for all dependencies, providing the compiler with what it expects for each source file:
|
|
1421
|
+
// <absoluteSourcePath> -> <sourceAsString> for bin/contract packages
|
|
1422
|
+
// <depAlias/relativePathToSource> -> <sourceAsString> for libs
|
|
1423
|
+
const suffix = file.replace(new RegExp(`.*${this.#srcPath}`), '');
|
|
1412
1424
|
return {
|
|
1413
1425
|
path: this.getType() === 'lib' ? `${alias ? alias : this.#config.package.name}${suffix}` : file,
|
|
1414
1426
|
source: (await fm.readFile(file, 'utf-8')).toString(),
|
|
@@ -12816,7 +12828,7 @@ var exports = __webpack_exports__;
|
|
|
12816
12828
|
\***********************/
|
|
12817
12829
|
|
|
12818
12830
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
12819
|
-
exports.inflateDebugSymbols = exports.createFileManager = exports.compile = void 0;
|
|
12831
|
+
exports.inflateDebugSymbols = exports.createFileManager = exports.compile_contract = exports.compile_program = exports.compile = void 0;
|
|
12820
12832
|
const nodejs_file_manager_1 = __webpack_require__(/*! ./noir/file-manager/nodejs-file-manager */ "./src/noir/file-manager/nodejs-file-manager.ts");
|
|
12821
12833
|
const noir_wasm_compiler_1 = __webpack_require__(/*! ./noir/noir-wasm-compiler */ "./src/noir/noir-wasm-compiler.ts");
|
|
12822
12834
|
const debug_1 = __webpack_require__(/*! ./noir/debug */ "./src/noir/debug.ts");
|
|
@@ -12833,30 +12845,71 @@ Object.defineProperty(exports, "inflateDebugSymbols", ({ enumerable: true, get:
|
|
|
12833
12845
|
* ```typescript
|
|
12834
12846
|
* // Node.js
|
|
12835
12847
|
*
|
|
12836
|
-
* import {
|
|
12848
|
+
* import { compile_program, createFileManager } from '@noir-lang/noir_wasm';
|
|
12837
12849
|
*
|
|
12838
12850
|
* const fm = createFileManager(myProjectPath);
|
|
12839
|
-
* const myCompiledCode = await
|
|
12851
|
+
* const myCompiledCode = await compile_program(fm);
|
|
12840
12852
|
* ```
|
|
12841
12853
|
*
|
|
12842
12854
|
* ```typescript
|
|
12843
12855
|
* // Browser
|
|
12844
12856
|
*
|
|
12845
|
-
* import {
|
|
12857
|
+
* import { compile_program, createFileManager } from '@noir-lang/noir_wasm';
|
|
12846
12858
|
*
|
|
12847
12859
|
* const fm = createFileManager('/');
|
|
12848
12860
|
* for (const path of files) {
|
|
12849
12861
|
* await fm.writeFile(path, await getFileAsStream(path));
|
|
12850
12862
|
* }
|
|
12851
|
-
* const myCompiledCode = await
|
|
12863
|
+
* const myCompiledCode = await compile_program(fm);
|
|
12852
12864
|
* ```
|
|
12853
12865
|
*/
|
|
12854
|
-
async function
|
|
12866
|
+
async function compile_program(fileManager, projectPath, logFn, debugLogFn) {
|
|
12867
|
+
const compiler = await setup_compiler(fileManager, projectPath, logFn, debugLogFn);
|
|
12868
|
+
return await compiler.compile_program();
|
|
12869
|
+
}
|
|
12870
|
+
exports.compile = compile_program;
|
|
12871
|
+
exports.compile_program = compile_program;
|
|
12872
|
+
/**
|
|
12873
|
+
* Compiles a Noir project
|
|
12874
|
+
*
|
|
12875
|
+
* @param fileManager - The file manager to use
|
|
12876
|
+
* @param projectPath - The path to the project inside the file manager. Defaults to the root of the file manager
|
|
12877
|
+
* @param logFn - A logging function. If not provided, console.log will be used
|
|
12878
|
+
* @param debugLogFn - A debug logging function. If not provided, logFn will be used
|
|
12879
|
+
*
|
|
12880
|
+
* @example
|
|
12881
|
+
* ```typescript
|
|
12882
|
+
* // Node.js
|
|
12883
|
+
*
|
|
12884
|
+
* import { compile_contract, createFileManager } from '@noir-lang/noir_wasm';
|
|
12885
|
+
*
|
|
12886
|
+
* const fm = createFileManager(myProjectPath);
|
|
12887
|
+
* const myCompiledCode = await compile_contract(fm);
|
|
12888
|
+
* ```
|
|
12889
|
+
*
|
|
12890
|
+
* ```typescript
|
|
12891
|
+
* // Browser
|
|
12892
|
+
*
|
|
12893
|
+
* import { compile_contract, createFileManager } from '@noir-lang/noir_wasm';
|
|
12894
|
+
*
|
|
12895
|
+
* const fm = createFileManager('/');
|
|
12896
|
+
* for (const path of files) {
|
|
12897
|
+
* await fm.writeFile(path, await getFileAsStream(path));
|
|
12898
|
+
* }
|
|
12899
|
+
* const myCompiledCode = await compile_contract(fm);
|
|
12900
|
+
* ```
|
|
12901
|
+
*/
|
|
12902
|
+
async function compile_contract(fileManager, projectPath, logFn, debugLogFn) {
|
|
12903
|
+
const compiler = await setup_compiler(fileManager, projectPath, logFn, debugLogFn);
|
|
12904
|
+
return await compiler.compile_contract();
|
|
12905
|
+
}
|
|
12906
|
+
exports.compile_contract = compile_contract;
|
|
12907
|
+
async function setup_compiler(fileManager, projectPath, logFn, debugLogFn) {
|
|
12855
12908
|
if (logFn && !debugLogFn) {
|
|
12856
12909
|
debugLogFn = logFn;
|
|
12857
12910
|
}
|
|
12858
12911
|
const cjs = await __webpack_require__(/*! ../build/cjs */ "./build/cjs/index.js");
|
|
12859
|
-
|
|
12912
|
+
return await noir_wasm_compiler_1.NoirWasmCompiler.new(fileManager, projectPath ?? fileManager.getDataDir(), cjs, new cjs.PathToFileSourceMap(), {
|
|
12860
12913
|
log: logFn ??
|
|
12861
12914
|
function (msg, data) {
|
|
12862
12915
|
if (data) {
|
|
@@ -12876,9 +12929,7 @@ async function compile(fileManager, projectPath, logFn, debugLogFn) {
|
|
|
12876
12929
|
}
|
|
12877
12930
|
},
|
|
12878
12931
|
});
|
|
12879
|
-
return await compiler.compile();
|
|
12880
12932
|
}
|
|
12881
|
-
exports.compile = compile;
|
|
12882
12933
|
const createFileManager = nodejs_file_manager_1.createNodejsFileManager;
|
|
12883
12934
|
exports.createFileManager = createFileManager;
|
|
12884
12935
|
|