@noir-lang/noir_wasm 0.23.0 → 0.24.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 +24 -1
- 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 +39 -5
- package/dist/node/main.js.map +1 -1
- package/dist/types/build/cjs/index.d.ts +2 -2
- package/dist/types/src/index.d.cts +30 -0
- package/dist/types/src/index.d.mts +30 -0
- package/dist/types/src/noir/debug.d.ts +4 -1
- package/dist/types/src/noir/file-manager/nodejs-file-manager.d.ts +3 -2
- package/dist/types/src/types/noir_artifact.d.ts +1 -1
- package/dist/web/main.mjs +40 -6
- package/dist/web/main.mjs.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# Noir Lang WASM JavaScript Package
|
|
2
2
|
|
|
3
|
-
This JavaScript package enables users to compile a Noir program, i.e. generating its artifacts.
|
|
3
|
+
This JavaScript package enables users to compile a Noir program, i.e. generating its artifacts, both in Node.JS environments and the browser.
|
|
4
4
|
|
|
5
5
|
The package also handles dependency management like how Nargo (Noir's CLI tool) operates, but the package is used just for compilation, not proving, verifying and simulating functions.
|
|
6
6
|
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// Node.js
|
|
11
|
+
|
|
12
|
+
import { compile, createFileManager } from '@noir-lang/noir_wasm';
|
|
13
|
+
|
|
14
|
+
const fm = createFileManager(myProjectPath);
|
|
15
|
+
const myCompiledCode = await compile(fm);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// Browser
|
|
20
|
+
|
|
21
|
+
import { compile, createFileManager } from '@noir-lang/noir_wasm';
|
|
22
|
+
|
|
23
|
+
const fm = createFileManager('/');
|
|
24
|
+
for (const path of files) {
|
|
25
|
+
await fm.writeFile(path, await getFileAsStream(path));
|
|
26
|
+
}
|
|
27
|
+
const myCompiledCode = await compile(fm);
|
|
28
|
+
```
|
|
29
|
+
|
|
7
30
|
## Building from source
|
|
8
31
|
|
|
9
32
|
Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below:
|
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
|
@@ -540,7 +540,7 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
540
540
|
takeObject(arg0);
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
-
module.exports.
|
|
543
|
+
module.exports.__wbg_constructor_05d6d198f3477d6f = function() { return logError(function () {
|
|
544
544
|
const ret = new Object();
|
|
545
545
|
return addHeapObject(ret);
|
|
546
546
|
}, arguments) };
|
|
@@ -551,7 +551,7 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
|
551
551
|
return ret;
|
|
552
552
|
};
|
|
553
553
|
|
|
554
|
-
module.exports.
|
|
554
|
+
module.exports.__wbg_constructor_e8767839abf8a966 = function() { return logError(function (arg0) {
|
|
555
555
|
const ret = new Error(takeObject(arg0));
|
|
556
556
|
return addHeapObject(ret);
|
|
557
557
|
}, arguments) };
|
|
@@ -686,7 +686,10 @@ module.exports.__wasm = wasm;
|
|
|
686
686
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
687
687
|
exports.inflateDebugSymbols = void 0;
|
|
688
688
|
const pako_1 = __webpack_require__(/*! pako */ "../../node_modules/pako/index.js");
|
|
689
|
-
/**
|
|
689
|
+
/**
|
|
690
|
+
* Decompresses and decodes the debug symbols
|
|
691
|
+
* @param debugSymbols - The base64 encoded debug symbols
|
|
692
|
+
*/
|
|
690
693
|
function inflateDebugSymbols(debugSymbols) {
|
|
691
694
|
return JSON.parse((0, pako_1.inflate)(Buffer.from(debugSymbols, 'base64'), { to: 'string', raw: true }));
|
|
692
695
|
}
|
|
@@ -1143,8 +1146,9 @@ async function readdirRecursive(dir) {
|
|
|
1143
1146
|
}
|
|
1144
1147
|
exports.readdirRecursive = readdirRecursive;
|
|
1145
1148
|
/**
|
|
1146
|
-
* Creates a new FileManager instance based on
|
|
1147
|
-
*
|
|
1149
|
+
* Creates a new FileManager instance based on fs in node and memfs in the browser (via webpack alias)
|
|
1150
|
+
*
|
|
1151
|
+
* @param dataDir - root of the file system
|
|
1148
1152
|
*/
|
|
1149
1153
|
function createNodejsFileManager(dataDir) {
|
|
1150
1154
|
return new file_manager_1.FileManager({
|
|
@@ -12818,6 +12822,36 @@ const nodejs_file_manager_1 = __webpack_require__(/*! ./noir/file-manager/nodejs
|
|
|
12818
12822
|
const noir_wasm_compiler_1 = __webpack_require__(/*! ./noir/noir-wasm-compiler */ "./src/noir/noir-wasm-compiler.ts");
|
|
12819
12823
|
const debug_1 = __webpack_require__(/*! ./noir/debug */ "./src/noir/debug.ts");
|
|
12820
12824
|
Object.defineProperty(exports, "inflateDebugSymbols", ({ enumerable: true, get: function () { return debug_1.inflateDebugSymbols; } }));
|
|
12825
|
+
/**
|
|
12826
|
+
* Compiles a Noir project
|
|
12827
|
+
*
|
|
12828
|
+
* @param fileManager - The file manager to use
|
|
12829
|
+
* @param projectPath - The path to the project inside the file manager. Defaults to the root of the file manager
|
|
12830
|
+
* @param logFn - A logging function. If not provided, console.log will be used
|
|
12831
|
+
* @param debugLogFn - A debug logging function. If not provided, logFn will be used
|
|
12832
|
+
*
|
|
12833
|
+
* @example
|
|
12834
|
+
* ```typescript
|
|
12835
|
+
* // Node.js
|
|
12836
|
+
*
|
|
12837
|
+
* import { compile, createFileManager } from '@noir-lang/noir_wasm';
|
|
12838
|
+
*
|
|
12839
|
+
* const fm = createFileManager(myProjectPath);
|
|
12840
|
+
* const myCompiledCode = await compile(fm);
|
|
12841
|
+
* ```
|
|
12842
|
+
*
|
|
12843
|
+
* ```typescript
|
|
12844
|
+
* // Browser
|
|
12845
|
+
*
|
|
12846
|
+
* import { compile, createFileManager } from '@noir-lang/noir_wasm';
|
|
12847
|
+
*
|
|
12848
|
+
* const fm = createFileManager('/');
|
|
12849
|
+
* for (const path of files) {
|
|
12850
|
+
* await fm.writeFile(path, await getFileAsStream(path));
|
|
12851
|
+
* }
|
|
12852
|
+
* const myCompiledCode = await compile(fm);
|
|
12853
|
+
* ```
|
|
12854
|
+
*/
|
|
12821
12855
|
async function compile(fileManager, projectPath, logFn, debugLogFn) {
|
|
12822
12856
|
if (logFn && !debugLogFn) {
|
|
12823
12857
|
debugLogFn = logFn;
|