@noir-lang/noir_wasm 0.26.0 → 0.27.0
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 +0 -14
- package/build/cjs/package.json +1 -1
- package/build/esm/package.json +1 -1
- package/dist/node/index_bg.wasm +0 -0
- package/dist/node/main.js +35 -22
- package/dist/node/main.js.map +1 -1
- package/dist/types/build/cjs/index.d.ts +7 -5
- package/dist/types/build/esm/index.d.ts +8 -8
- package/dist/types/src/noir/dependencies/github-dependency-resolver.d.ts +1 -1
- package/dist/web/main.mjs +33 -22
- package/dist/web/main.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,17 +26,3 @@ for (const path of files) {
|
|
|
26
26
|
}
|
|
27
27
|
const myCompiledCode = await compile(fm);
|
|
28
28
|
```
|
|
29
|
-
|
|
30
|
-
## Building from source
|
|
31
|
-
|
|
32
|
-
Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
nix build -L github:noir-lang/noir/master#noir_wasm
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
If you are within the noir repo and would like to build local changes, you can use:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
nix build -L #noir_wasm
|
|
42
|
-
```
|
package/build/cjs/package.json
CHANGED
package/build/esm/package.json
CHANGED
package/dist/node/index_bg.wasm
CHANGED
|
Binary file
|
package/dist/node/main.js
CHANGED
|
@@ -215,21 +215,19 @@ function _assertClass(instance, klass) {
|
|
|
215
215
|
return instance.ptr;
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
|
-
* This is a method that exposes the same API as `compile`
|
|
219
|
-
* But uses the Context based APi internally
|
|
220
218
|
* @param {string} entry_point
|
|
221
219
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
222
220
|
* @param {PathToFileSourceMap} file_source_map
|
|
223
221
|
* @returns {ProgramCompileResult}
|
|
224
222
|
*/
|
|
225
|
-
module.exports.
|
|
223
|
+
module.exports.compile_program = function(entry_point, dependency_graph, file_source_map) {
|
|
226
224
|
try {
|
|
227
225
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
226
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
229
227
|
const len0 = WASM_VECTOR_LEN;
|
|
230
228
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
231
229
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
232
|
-
wasm.
|
|
230
|
+
wasm.compile_program(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
233
231
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
234
232
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
235
233
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -243,21 +241,19 @@ module.exports.compile_program_ = function(entry_point, dependency_graph, file_s
|
|
|
243
241
|
};
|
|
244
242
|
|
|
245
243
|
/**
|
|
246
|
-
* This is a method that exposes the same API as `compile`
|
|
247
|
-
* But uses the Context based APi internally
|
|
248
244
|
* @param {string} entry_point
|
|
249
245
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
250
246
|
* @param {PathToFileSourceMap} file_source_map
|
|
251
247
|
* @returns {ContractCompileResult}
|
|
252
248
|
*/
|
|
253
|
-
module.exports.
|
|
249
|
+
module.exports.compile_contract = function(entry_point, dependency_graph, file_source_map) {
|
|
254
250
|
try {
|
|
255
251
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
256
252
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
257
253
|
const len0 = WASM_VECTOR_LEN;
|
|
258
254
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
259
255
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
260
|
-
wasm.
|
|
256
|
+
wasm.compile_contract(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
261
257
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
262
258
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
263
259
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -271,19 +267,21 @@ module.exports.compile_contract_ = function(entry_point, dependency_graph, file_
|
|
|
271
267
|
};
|
|
272
268
|
|
|
273
269
|
/**
|
|
270
|
+
* This is a method that exposes the same API as `compile`
|
|
271
|
+
* But uses the Context based APi internally
|
|
274
272
|
* @param {string} entry_point
|
|
275
273
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
276
274
|
* @param {PathToFileSourceMap} file_source_map
|
|
277
275
|
* @returns {ProgramCompileResult}
|
|
278
276
|
*/
|
|
279
|
-
module.exports.
|
|
277
|
+
module.exports.compile_program_ = function(entry_point, dependency_graph, file_source_map) {
|
|
280
278
|
try {
|
|
281
279
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
282
280
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
283
281
|
const len0 = WASM_VECTOR_LEN;
|
|
284
282
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
285
283
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
286
|
-
wasm.
|
|
284
|
+
wasm.compile_program_(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
287
285
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
288
286
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
289
287
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -297,19 +295,21 @@ module.exports.compile_program = function(entry_point, dependency_graph, file_so
|
|
|
297
295
|
};
|
|
298
296
|
|
|
299
297
|
/**
|
|
298
|
+
* This is a method that exposes the same API as `compile`
|
|
299
|
+
* But uses the Context based APi internally
|
|
300
300
|
* @param {string} entry_point
|
|
301
301
|
* @param {DependencyGraph | undefined} dependency_graph
|
|
302
302
|
* @param {PathToFileSourceMap} file_source_map
|
|
303
303
|
* @returns {ContractCompileResult}
|
|
304
304
|
*/
|
|
305
|
-
module.exports.
|
|
305
|
+
module.exports.compile_contract_ = function(entry_point, dependency_graph, file_source_map) {
|
|
306
306
|
try {
|
|
307
307
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
308
308
|
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
309
309
|
const len0 = WASM_VECTOR_LEN;
|
|
310
310
|
_assertClass(file_source_map, PathToFileSourceMap);
|
|
311
311
|
var ptr1 = file_source_map.__destroy_into_raw();
|
|
312
|
-
wasm.
|
|
312
|
+
wasm.compile_contract_(retptr, ptr0, len0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
313
313
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
314
314
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
315
315
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -518,21 +518,21 @@ class PathToFileSourceMap {
|
|
|
518
518
|
}
|
|
519
519
|
module.exports.PathToFileSourceMap = PathToFileSourceMap;
|
|
520
520
|
|
|
521
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
522
|
+
const ret = getObject(arg0) === undefined;
|
|
523
|
+
return ret;
|
|
524
|
+
};
|
|
525
|
+
|
|
521
526
|
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
522
527
|
takeObject(arg0);
|
|
523
528
|
};
|
|
524
529
|
|
|
525
|
-
module.exports.
|
|
530
|
+
module.exports.__wbg_constructor_d324422a76f57e97 = function(arg0) {
|
|
526
531
|
const ret = new Error(takeObject(arg0));
|
|
527
532
|
return addHeapObject(ret);
|
|
528
533
|
};
|
|
529
534
|
|
|
530
|
-
module.exports.
|
|
531
|
-
const ret = getObject(arg0) === undefined;
|
|
532
|
-
return ret;
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
module.exports.__wbg_constructor_16652445ed5bfc27 = function() {
|
|
535
|
+
module.exports.__wbg_constructor_5ba06a405a88a2ec = function() {
|
|
536
536
|
const ret = new Object();
|
|
537
537
|
return addHeapObject(ret);
|
|
538
538
|
};
|
|
@@ -608,6 +608,16 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
|
608
608
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
+
module.exports.__wbg_getTime_40bd09e020e8bc8c = function(arg0) {
|
|
612
|
+
const ret = getObject(arg0).getTime();
|
|
613
|
+
return ret;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
module.exports.__wbg_new0_494c19a27871d56f = function() {
|
|
617
|
+
const ret = new Date();
|
|
618
|
+
return addHeapObject(ret);
|
|
619
|
+
};
|
|
620
|
+
|
|
611
621
|
module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
|
|
612
622
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
613
623
|
return addHeapObject(ret);
|
|
@@ -10860,9 +10870,11 @@ const package_1 = __webpack_require__(/*! ../package */ "./src/noir/package.ts")
|
|
|
10860
10870
|
*/
|
|
10861
10871
|
class GithubDependencyResolver {
|
|
10862
10872
|
#fm;
|
|
10873
|
+
#fetch;
|
|
10863
10874
|
#log;
|
|
10864
|
-
constructor(fm) {
|
|
10875
|
+
constructor(fm, fetcher) {
|
|
10865
10876
|
this.#fm = fm;
|
|
10877
|
+
this.#fetch = fetcher;
|
|
10866
10878
|
this.#log = (msg, _data) => {
|
|
10867
10879
|
console.log(msg);
|
|
10868
10880
|
};
|
|
@@ -10897,7 +10909,7 @@ class GithubDependencyResolver {
|
|
|
10897
10909
|
this.#log('using cached archive', { url: url.href, path: localArchivePath });
|
|
10898
10910
|
return localArchivePath;
|
|
10899
10911
|
}
|
|
10900
|
-
const response = await fetch(url, {
|
|
10912
|
+
const response = await this.#fetch(url, {
|
|
10901
10913
|
method: 'GET',
|
|
10902
10914
|
});
|
|
10903
10915
|
if (!response.ok || !response.body) {
|
|
@@ -11238,7 +11250,8 @@ class NoirWasmCompiler {
|
|
|
11238
11250
|
const noirPackage = await package_1.Package.open(projectPath, fileManager);
|
|
11239
11251
|
const dependencyManager = new dependency_manager_1.DependencyManager([
|
|
11240
11252
|
new local_dependency_resolver_1.LocalDependencyResolver(fileManager),
|
|
11241
|
-
|
|
11253
|
+
// use node's global fetch
|
|
11254
|
+
new github_dependency_resolver_1.GithubDependencyResolver(fileManager, fetch),
|
|
11242
11255
|
// TODO support actual Git repositories
|
|
11243
11256
|
], noirPackage);
|
|
11244
11257
|
return new NoirWasmCompiler(noirPackage, dependencyManager, fileManager, wasmCompiler, sourceMap, opts);
|