@noir-lang/noir_wasm 0.20.0-f904ae1.nightly → 0.21.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.
@@ -22,9 +22,10 @@ export function build_info(): any;
22
22
  * @param {string} entry_point
23
23
  * @param {boolean | undefined} contracts
24
24
  * @param {DependencyGraph | undefined} dependency_graph
25
+ * @param {PathToFileSourceMap} file_source_map
25
26
  * @returns {CompileResult}
26
27
  */
27
- export function compile(entry_point: string, contracts?: boolean, dependency_graph?: DependencyGraph): CompileResult;
28
+ export function compile(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
28
29
 
29
30
  export type Diagnostic = {
30
31
  message: string;
@@ -81,3 +82,17 @@ export type CompileResult = (
81
82
  );
82
83
 
83
84
 
85
+ /**
86
+ */
87
+ export class PathToFileSourceMap {
88
+ free(): void;
89
+ /**
90
+ */
91
+ constructor();
92
+ /**
93
+ * @param {string} path
94
+ * @param {string} source_code
95
+ * @returns {boolean}
96
+ */
97
+ add_source_code(path: string, source_code: string): boolean;
98
+ }
@@ -1,7 +1,6 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { read_file } = require(`@noir-lang/source-resolver`);
5
4
  const { TextDecoder, TextEncoder } = require(`util`);
6
5
 
7
6
  const heap = new Array(128).fill(undefined);
@@ -240,18 +239,27 @@ module.exports.build_info = function() {
240
239
  return takeObject(ret);
241
240
  };
242
241
 
242
+ function _assertClass(instance, klass) {
243
+ if (!(instance instanceof klass)) {
244
+ throw new Error(`expected instance of ${klass.name}`);
245
+ }
246
+ return instance.ptr;
247
+ }
243
248
  /**
244
249
  * @param {string} entry_point
245
250
  * @param {boolean | undefined} contracts
246
251
  * @param {DependencyGraph | undefined} dependency_graph
252
+ * @param {PathToFileSourceMap} file_source_map
247
253
  * @returns {CompileResult}
248
254
  */
249
- module.exports.compile = function(entry_point, contracts, dependency_graph) {
255
+ module.exports.compile = function(entry_point, contracts, dependency_graph, file_source_map) {
250
256
  try {
251
257
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
252
258
  const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
253
259
  const len0 = WASM_VECTOR_LEN;
254
- wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph));
260
+ _assertClass(file_source_map, PathToFileSourceMap);
261
+ var ptr1 = file_source_map.__destroy_into_raw();
262
+ wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
255
263
  var r0 = getInt32Memory0()[retptr / 4 + 0];
256
264
  var r1 = getInt32Memory0()[retptr / 4 + 1];
257
265
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -271,12 +279,56 @@ function handleError(f, args) {
271
279
  wasm.__wbindgen_export_3(addHeapObject(e));
272
280
  }
273
281
  }
282
+ /**
283
+ */
284
+ class PathToFileSourceMap {
285
+
286
+ static __wrap(ptr) {
287
+ ptr = ptr >>> 0;
288
+ const obj = Object.create(PathToFileSourceMap.prototype);
289
+ obj.__wbg_ptr = ptr;
290
+
291
+ return obj;
292
+ }
293
+
294
+ __destroy_into_raw() {
295
+ const ptr = this.__wbg_ptr;
296
+ this.__wbg_ptr = 0;
297
+
298
+ return ptr;
299
+ }
300
+
301
+ free() {
302
+ const ptr = this.__destroy_into_raw();
303
+ wasm.__wbg_pathtofilesourcemap_free(ptr);
304
+ }
305
+ /**
306
+ */
307
+ constructor() {
308
+ const ret = wasm.pathtofilesourcemap_new();
309
+ return PathToFileSourceMap.__wrap(ret);
310
+ }
311
+ /**
312
+ * @param {string} path
313
+ * @param {string} source_code
314
+ * @returns {boolean}
315
+ */
316
+ add_source_code(path, source_code) {
317
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
318
+ const len0 = WASM_VECTOR_LEN;
319
+ const ptr1 = passStringToWasm0(source_code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
320
+ const len1 = WASM_VECTOR_LEN;
321
+ const ret = wasm.pathtofilesourcemap_add_source_code(this.__wbg_ptr, ptr0, len0, ptr1, len1);
322
+ return ret !== 0;
323
+ }
324
+ }
325
+ module.exports.PathToFileSourceMap = PathToFileSourceMap;
274
326
 
275
327
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
276
328
  takeObject(arg0);
277
329
  };
278
330
 
279
- module.exports.__wbg_constructor_2f52aa89ce97ba46 = function(arg0) {
331
+ module.exports.__wbg_constructor_35233efb35960b52 = function(arg0) {
280
332
  const ret = new Error(takeObject(arg0));
281
333
  return addHeapObject(ret);
282
334
  };
@@ -286,19 +338,11 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
286
338
  return ret;
287
339
  };
288
340
 
289
- module.exports.__wbg_constructor_1292ee4141d8f79d = function() {
341
+ module.exports.__wbg_constructor_0fbcf25c6da50731 = function() {
290
342
  const ret = new Object();
291
343
  return addHeapObject(ret);
292
344
  };
293
345
 
294
- module.exports.__wbg_readfile_698fcfe83a414130 = function() { return handleError(function (arg0, arg1, arg2) {
295
- const ret = read_file(getStringFromWasm0(arg1, arg2));
296
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
297
- const len1 = WASM_VECTOR_LEN;
298
- getInt32Memory0()[arg0 / 4 + 1] = len1;
299
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
300
- }, arguments) };
301
-
302
346
  module.exports.__wbindgen_string_new = function(arg0, arg1) {
303
347
  const ret = getStringFromWasm0(arg0, arg1);
304
348
  return addHeapObject(ret);
Binary file
@@ -5,7 +5,10 @@ export function acir_read_bytes(a: number, b: number): number;
5
5
  export function acir_write_bytes(a: number, b: number): void;
6
6
  export function init_log_level(a: number, b: number): void;
7
7
  export function build_info(): number;
8
- export function compile(a: number, b: number, c: number, d: number, e: number): void;
8
+ export function __wbg_pathtofilesourcemap_free(a: number): void;
9
+ export function pathtofilesourcemap_new(): number;
10
+ export function pathtofilesourcemap_add_source_code(a: number, b: number, c: number, d: number, e: number): number;
11
+ export function compile(a: number, b: number, c: number, d: number, e: number, f: number): void;
9
12
  export function __wbindgen_export_0(a: number): number;
10
13
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
11
14
  export function __wbindgen_add_to_stack_pointer(a: number): number;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.20.0-f904ae1.nightly",
6
+ "version": "0.21.0",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "main": "./nodejs/noir_wasm.js",
9
9
  "types": "./web/noir_wasm.d.ts",
@@ -30,9 +30,6 @@
30
30
  "build:nix": "nix build -L .#noir_wasm",
31
31
  "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noir_wasm/nodejs ./ && cp -rL ./result/noir_wasm/web ./"
32
32
  },
33
- "peerDependencies": {
34
- "@noir-lang/source-resolver": "0.20.0-f904ae1.nightly"
35
- },
36
33
  "devDependencies": {
37
34
  "@esm-bundle/chai": "^4.3.4-fix.0",
38
35
  "@web/dev-server-esbuild": "^0.3.6",
@@ -22,9 +22,10 @@ export function build_info(): any;
22
22
  * @param {string} entry_point
23
23
  * @param {boolean | undefined} contracts
24
24
  * @param {DependencyGraph | undefined} dependency_graph
25
+ * @param {PathToFileSourceMap} file_source_map
25
26
  * @returns {CompileResult}
26
27
  */
27
- export function compile(entry_point: string, contracts?: boolean, dependency_graph?: DependencyGraph): CompileResult;
28
+ export function compile(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
28
29
 
29
30
  export type Diagnostic = {
30
31
  message: string;
@@ -81,6 +82,20 @@ export type CompileResult = (
81
82
  );
82
83
 
83
84
 
85
+ /**
86
+ */
87
+ export class PathToFileSourceMap {
88
+ free(): void;
89
+ /**
90
+ */
91
+ constructor();
92
+ /**
93
+ * @param {string} path
94
+ * @param {string} source_code
95
+ * @returns {boolean}
96
+ */
97
+ add_source_code(path: string, source_code: string): boolean;
98
+ }
84
99
 
85
100
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
86
101
 
@@ -90,7 +105,10 @@ export interface InitOutput {
90
105
  readonly acir_write_bytes: (a: number, b: number) => void;
91
106
  readonly init_log_level: (a: number, b: number) => void;
92
107
  readonly build_info: () => number;
93
- readonly compile: (a: number, b: number, c: number, d: number, e: number) => void;
108
+ readonly __wbg_pathtofilesourcemap_free: (a: number) => void;
109
+ readonly pathtofilesourcemap_new: () => number;
110
+ readonly pathtofilesourcemap_add_source_code: (a: number, b: number, c: number, d: number, e: number) => number;
111
+ readonly compile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
94
112
  readonly __wbindgen_export_0: (a: number) => number;
95
113
  readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
96
114
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
package/web/noir_wasm.js CHANGED
@@ -1,5 +1,3 @@
1
- import { read_file } from '@noir-lang/source-resolver';
2
-
3
1
  let wasm;
4
2
 
5
3
  const heap = new Array(128).fill(undefined);
@@ -238,18 +236,27 @@ export function build_info() {
238
236
  return takeObject(ret);
239
237
  }
240
238
 
239
+ function _assertClass(instance, klass) {
240
+ if (!(instance instanceof klass)) {
241
+ throw new Error(`expected instance of ${klass.name}`);
242
+ }
243
+ return instance.ptr;
244
+ }
241
245
  /**
242
246
  * @param {string} entry_point
243
247
  * @param {boolean | undefined} contracts
244
248
  * @param {DependencyGraph | undefined} dependency_graph
249
+ * @param {PathToFileSourceMap} file_source_map
245
250
  * @returns {CompileResult}
246
251
  */
247
- export function compile(entry_point, contracts, dependency_graph) {
252
+ export function compile(entry_point, contracts, dependency_graph, file_source_map) {
248
253
  try {
249
254
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
250
255
  const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
251
256
  const len0 = WASM_VECTOR_LEN;
252
- wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph));
257
+ _assertClass(file_source_map, PathToFileSourceMap);
258
+ var ptr1 = file_source_map.__destroy_into_raw();
259
+ wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
253
260
  var r0 = getInt32Memory0()[retptr / 4 + 0];
254
261
  var r1 = getInt32Memory0()[retptr / 4 + 1];
255
262
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -269,6 +276,49 @@ function handleError(f, args) {
269
276
  wasm.__wbindgen_export_3(addHeapObject(e));
270
277
  }
271
278
  }
279
+ /**
280
+ */
281
+ export class PathToFileSourceMap {
282
+
283
+ static __wrap(ptr) {
284
+ ptr = ptr >>> 0;
285
+ const obj = Object.create(PathToFileSourceMap.prototype);
286
+ obj.__wbg_ptr = ptr;
287
+
288
+ return obj;
289
+ }
290
+
291
+ __destroy_into_raw() {
292
+ const ptr = this.__wbg_ptr;
293
+ this.__wbg_ptr = 0;
294
+
295
+ return ptr;
296
+ }
297
+
298
+ free() {
299
+ const ptr = this.__destroy_into_raw();
300
+ wasm.__wbg_pathtofilesourcemap_free(ptr);
301
+ }
302
+ /**
303
+ */
304
+ constructor() {
305
+ const ret = wasm.pathtofilesourcemap_new();
306
+ return PathToFileSourceMap.__wrap(ret);
307
+ }
308
+ /**
309
+ * @param {string} path
310
+ * @param {string} source_code
311
+ * @returns {boolean}
312
+ */
313
+ add_source_code(path, source_code) {
314
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
315
+ const len0 = WASM_VECTOR_LEN;
316
+ const ptr1 = passStringToWasm0(source_code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
317
+ const len1 = WASM_VECTOR_LEN;
318
+ const ret = wasm.pathtofilesourcemap_add_source_code(this.__wbg_ptr, ptr0, len0, ptr1, len1);
319
+ return ret !== 0;
320
+ }
321
+ }
272
322
 
273
323
  async function __wbg_load(module, imports) {
274
324
  if (typeof Response === 'function' && module instanceof Response) {
@@ -307,7 +357,7 @@ function __wbg_get_imports() {
307
357
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
308
358
  takeObject(arg0);
309
359
  };
310
- imports.wbg.__wbg_constructor_2f52aa89ce97ba46 = function(arg0) {
360
+ imports.wbg.__wbg_constructor_35233efb35960b52 = function(arg0) {
311
361
  const ret = new Error(takeObject(arg0));
312
362
  return addHeapObject(ret);
313
363
  };
@@ -315,17 +365,10 @@ function __wbg_get_imports() {
315
365
  const ret = getObject(arg0) === undefined;
316
366
  return ret;
317
367
  };
318
- imports.wbg.__wbg_constructor_1292ee4141d8f79d = function() {
368
+ imports.wbg.__wbg_constructor_0fbcf25c6da50731 = function() {
319
369
  const ret = new Object();
320
370
  return addHeapObject(ret);
321
371
  };
322
- imports.wbg.__wbg_readfile_698fcfe83a414130 = function() { return handleError(function (arg0, arg1, arg2) {
323
- const ret = read_file(getStringFromWasm0(arg1, arg2));
324
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
325
- const len1 = WASM_VECTOR_LEN;
326
- getInt32Memory0()[arg0 / 4 + 1] = len1;
327
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
328
- }, arguments) };
329
372
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
330
373
  const ret = getStringFromWasm0(arg0, arg1);
331
374
  return addHeapObject(ret);
Binary file
@@ -5,7 +5,10 @@ export function acir_read_bytes(a: number, b: number): number;
5
5
  export function acir_write_bytes(a: number, b: number): void;
6
6
  export function init_log_level(a: number, b: number): void;
7
7
  export function build_info(): number;
8
- export function compile(a: number, b: number, c: number, d: number, e: number): void;
8
+ export function __wbg_pathtofilesourcemap_free(a: number): void;
9
+ export function pathtofilesourcemap_new(): number;
10
+ export function pathtofilesourcemap_add_source_code(a: number, b: number, c: number, d: number, e: number): number;
11
+ export function compile(a: number, b: number, c: number, d: number, e: number, f: number): void;
9
12
  export function __wbindgen_export_0(a: number): number;
10
13
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
11
14
  export function __wbindgen_add_to_stack_pointer(a: number): number;