@noir-lang/noir_wasm 0.1.0 → 0.1.1-0c16089
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 +4 -0
- package/nodejs/noir_wasm.d.ts +17 -0
- package/{noir_wasm.js → nodejs/noir_wasm.js} +117 -53
- package/nodejs/noir_wasm_bg.wasm +0 -0
- package/nodejs/noir_wasm_bg.wasm.d.ts +11 -0
- package/package.json +22 -7
- package/web/noir_wasm.d.ts +52 -0
- package/web/noir_wasm.js +310 -0
- package/web/noir_wasm_bg.wasm +0 -0
- package/web/noir_wasm_bg.wasm.d.ts +11 -0
- package/noir_wasm.d.ts +0 -7
- package/noir_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} src
|
|
5
|
+
* @returns {any}
|
|
6
|
+
*/
|
|
7
|
+
export function compile(src: string): any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {Uint8Array} bytes
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function acir_from_bytes(bytes: Uint8Array): any;
|
|
13
|
+
/**
|
|
14
|
+
* @param {any} acir
|
|
15
|
+
* @returns {Uint8Array}
|
|
16
|
+
*/
|
|
17
|
+
export function acir_to_bytes(acir: any): Uint8Array;
|
|
@@ -1,44 +1,19 @@
|
|
|
1
1
|
let imports = {};
|
|
2
2
|
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
3
|
let wasm;
|
|
4
|
-
const { read_file } = require(
|
|
5
|
-
const {
|
|
4
|
+
const { read_file } = require(`@noir-lang/noir-source-resolver`);
|
|
5
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cachedTextDecoder.decode();
|
|
10
|
-
|
|
11
|
-
let cachedUint8Memory0;
|
|
12
|
-
function getUint8Memory0() {
|
|
13
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
14
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
15
|
-
}
|
|
16
|
-
return cachedUint8Memory0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getStringFromWasm0(ptr, len) {
|
|
20
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const heap = new Array(32).fill(undefined);
|
|
7
|
+
const heap = new Array(128).fill(undefined);
|
|
24
8
|
|
|
25
9
|
heap.push(undefined, null, true, false);
|
|
26
10
|
|
|
27
|
-
let heap_next = heap.length;
|
|
28
|
-
|
|
29
|
-
function addHeapObject(obj) {
|
|
30
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
31
|
-
const idx = heap_next;
|
|
32
|
-
heap_next = heap[idx];
|
|
33
|
-
|
|
34
|
-
heap[idx] = obj;
|
|
35
|
-
return idx;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
11
|
function getObject(idx) { return heap[idx]; }
|
|
39
12
|
|
|
13
|
+
let heap_next = heap.length;
|
|
14
|
+
|
|
40
15
|
function dropObject(idx) {
|
|
41
|
-
if (idx <
|
|
16
|
+
if (idx < 132) return;
|
|
42
17
|
heap[idx] = heap_next;
|
|
43
18
|
heap_next = idx;
|
|
44
19
|
}
|
|
@@ -51,6 +26,15 @@ function takeObject(idx) {
|
|
|
51
26
|
|
|
52
27
|
let WASM_VECTOR_LEN = 0;
|
|
53
28
|
|
|
29
|
+
let cachedUint8Memory0 = null;
|
|
30
|
+
|
|
31
|
+
function getUint8Memory0() {
|
|
32
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
33
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
34
|
+
}
|
|
35
|
+
return cachedUint8Memory0;
|
|
36
|
+
}
|
|
37
|
+
|
|
54
38
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
55
39
|
|
|
56
40
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -103,6 +87,27 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
103
87
|
WASM_VECTOR_LEN = offset;
|
|
104
88
|
return ptr;
|
|
105
89
|
}
|
|
90
|
+
|
|
91
|
+
function isLikeNone(x) {
|
|
92
|
+
return x === undefined || x === null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let cachedInt32Memory0 = null;
|
|
96
|
+
|
|
97
|
+
function getInt32Memory0() {
|
|
98
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
99
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
100
|
+
}
|
|
101
|
+
return cachedInt32Memory0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
105
|
+
|
|
106
|
+
cachedTextDecoder.decode();
|
|
107
|
+
|
|
108
|
+
function getStringFromWasm0(ptr, len) {
|
|
109
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
110
|
+
}
|
|
106
111
|
/**
|
|
107
112
|
* @param {string} src
|
|
108
113
|
* @returns {any}
|
|
@@ -114,28 +119,71 @@ module.exports.compile = function(src) {
|
|
|
114
119
|
return takeObject(ret);
|
|
115
120
|
};
|
|
116
121
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
123
|
+
const ptr = malloc(arg.length * 1);
|
|
124
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
125
|
+
WASM_VECTOR_LEN = arg.length;
|
|
126
|
+
return ptr;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @param {Uint8Array} bytes
|
|
130
|
+
* @returns {any}
|
|
131
|
+
*/
|
|
132
|
+
module.exports.acir_from_bytes = function(bytes) {
|
|
133
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
134
|
+
const len0 = WASM_VECTOR_LEN;
|
|
135
|
+
const ret = wasm.acir_from_bytes(ptr0, len0);
|
|
136
|
+
return takeObject(ret);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
function addHeapObject(obj) {
|
|
140
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
141
|
+
const idx = heap_next;
|
|
142
|
+
heap_next = heap[idx];
|
|
143
|
+
|
|
144
|
+
heap[idx] = obj;
|
|
145
|
+
return idx;
|
|
123
146
|
}
|
|
124
147
|
|
|
148
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
149
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @param {any} acir
|
|
153
|
+
* @returns {Uint8Array}
|
|
154
|
+
*/
|
|
155
|
+
module.exports.acir_to_bytes = function(acir) {
|
|
156
|
+
try {
|
|
157
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
158
|
+
wasm.acir_to_bytes(retptr, addHeapObject(acir));
|
|
159
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
160
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
161
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
162
|
+
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
163
|
+
return v0;
|
|
164
|
+
} finally {
|
|
165
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
125
169
|
function handleError(f, args) {
|
|
126
170
|
try {
|
|
127
171
|
return f.apply(this, args);
|
|
128
172
|
} catch (e) {
|
|
129
|
-
wasm.
|
|
173
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
130
174
|
}
|
|
131
175
|
}
|
|
132
176
|
|
|
133
|
-
module.exports.
|
|
134
|
-
|
|
135
|
-
return addHeapObject(ret);
|
|
177
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
178
|
+
takeObject(arg0);
|
|
136
179
|
};
|
|
137
180
|
|
|
138
|
-
module.exports.
|
|
181
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
182
|
+
const ret = getObject(arg0) === undefined;
|
|
183
|
+
return ret;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
module.exports.__wbg_readfile_141fe7d2c0f1edde = function() { return handleError(function (arg0, arg1, arg2) {
|
|
139
187
|
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
140
188
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
141
189
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -143,16 +191,12 @@ module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError
|
|
|
143
191
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
144
192
|
}, arguments) };
|
|
145
193
|
|
|
146
|
-
module.exports.
|
|
147
|
-
takeObject(arg0);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
module.exports.__wbg_new_693216e109162396 = function() {
|
|
194
|
+
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
151
195
|
const ret = new Error();
|
|
152
196
|
return addHeapObject(ret);
|
|
153
197
|
};
|
|
154
198
|
|
|
155
|
-
module.exports.
|
|
199
|
+
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
156
200
|
const ret = getObject(arg1).stack;
|
|
157
201
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
158
202
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -160,14 +204,37 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
|
|
|
160
204
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
161
205
|
};
|
|
162
206
|
|
|
163
|
-
module.exports.
|
|
207
|
+
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
164
208
|
try {
|
|
165
209
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
166
210
|
} finally {
|
|
167
|
-
wasm.
|
|
211
|
+
wasm.__wbindgen_export_2(arg0, arg1);
|
|
168
212
|
}
|
|
169
213
|
};
|
|
170
214
|
|
|
215
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
216
|
+
const obj = getObject(arg1);
|
|
217
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
218
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
219
|
+
var len0 = WASM_VECTOR_LEN;
|
|
220
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
221
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
module.exports.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
|
|
225
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
226
|
+
return addHeapObject(ret);
|
|
227
|
+
}, arguments) };
|
|
228
|
+
|
|
229
|
+
module.exports.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
|
|
230
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
231
|
+
return addHeapObject(ret);
|
|
232
|
+
}, arguments) };
|
|
233
|
+
|
|
234
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
235
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
236
|
+
};
|
|
237
|
+
|
|
171
238
|
const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
|
|
172
239
|
const bytes = require('fs').readFileSync(path);
|
|
173
240
|
|
|
@@ -176,6 +243,3 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
|
176
243
|
wasm = wasmInstance.exports;
|
|
177
244
|
module.exports.__wasm = wasm;
|
|
178
245
|
|
|
179
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
180
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
181
|
-
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function compile(a: number, b: number): number;
|
|
5
|
+
export function acir_from_bytes(a: number, b: number): number;
|
|
6
|
+
export function acir_to_bytes(a: number, b: number): void;
|
|
7
|
+
export function __wbindgen_export_0(a: number): number;
|
|
8
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
9
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
10
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
11
|
+
export function __wbindgen_export_3(a: number): void;
|
package/package.json
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noir-lang/noir_wasm",
|
|
3
|
-
"
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"The Noir Team <kevtheappdev@gmail.com>"
|
|
5
|
+
],
|
|
6
|
+
"version": "0.1.1-0c16089",
|
|
4
7
|
"files": [
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
+
"nodejs",
|
|
9
|
+
"web",
|
|
10
|
+
"package.json"
|
|
8
11
|
],
|
|
9
|
-
"main": "noir_wasm.js",
|
|
10
|
-
"types": "noir_wasm.d.ts"
|
|
11
|
-
|
|
12
|
+
"main": "./nodejs/noir_wasm.js",
|
|
13
|
+
"types": "./web/noir_wasm.d.ts",
|
|
14
|
+
"module": "./web/noir_wasm.js",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@noir-lang/noir-source-resolver": "1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/noir-lang/noir_wasm.git"
|
|
22
|
+
},
|
|
23
|
+
"compiler": {
|
|
24
|
+
"versionHash": "0c16089f73b64ee489a5c2fa065238421247168b"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} src
|
|
5
|
+
* @returns {any}
|
|
6
|
+
*/
|
|
7
|
+
export function compile(src: string): any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {Uint8Array} bytes
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function acir_from_bytes(bytes: Uint8Array): any;
|
|
13
|
+
/**
|
|
14
|
+
* @param {any} acir
|
|
15
|
+
* @returns {Uint8Array}
|
|
16
|
+
*/
|
|
17
|
+
export function acir_to_bytes(acir: any): Uint8Array;
|
|
18
|
+
|
|
19
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
20
|
+
|
|
21
|
+
export interface InitOutput {
|
|
22
|
+
readonly memory: WebAssembly.Memory;
|
|
23
|
+
readonly compile: (a: number, b: number) => number;
|
|
24
|
+
readonly acir_from_bytes: (a: number, b: number) => number;
|
|
25
|
+
readonly acir_to_bytes: (a: number, b: number) => void;
|
|
26
|
+
readonly __wbindgen_export_0: (a: number) => number;
|
|
27
|
+
readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
|
|
28
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
29
|
+
readonly __wbindgen_export_2: (a: number, b: number) => void;
|
|
30
|
+
readonly __wbindgen_export_3: (a: number) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
34
|
+
/**
|
|
35
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
36
|
+
* a precompiled `WebAssembly.Module`.
|
|
37
|
+
*
|
|
38
|
+
* @param {SyncInitInput} module
|
|
39
|
+
*
|
|
40
|
+
* @returns {InitOutput}
|
|
41
|
+
*/
|
|
42
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
46
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
47
|
+
*
|
|
48
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
49
|
+
*
|
|
50
|
+
* @returns {Promise<InitOutput>}
|
|
51
|
+
*/
|
|
52
|
+
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/web/noir_wasm.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { read_file } from '@noir-lang/noir-source-resolver';
|
|
2
|
+
|
|
3
|
+
let wasm;
|
|
4
|
+
|
|
5
|
+
const heap = new Array(128).fill(undefined);
|
|
6
|
+
|
|
7
|
+
heap.push(undefined, null, true, false);
|
|
8
|
+
|
|
9
|
+
function getObject(idx) { return heap[idx]; }
|
|
10
|
+
|
|
11
|
+
let heap_next = heap.length;
|
|
12
|
+
|
|
13
|
+
function dropObject(idx) {
|
|
14
|
+
if (idx < 132) return;
|
|
15
|
+
heap[idx] = heap_next;
|
|
16
|
+
heap_next = idx;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function takeObject(idx) {
|
|
20
|
+
const ret = getObject(idx);
|
|
21
|
+
dropObject(idx);
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let WASM_VECTOR_LEN = 0;
|
|
26
|
+
|
|
27
|
+
let cachedUint8Memory0 = null;
|
|
28
|
+
|
|
29
|
+
function getUint8Memory0() {
|
|
30
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
31
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
32
|
+
}
|
|
33
|
+
return cachedUint8Memory0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const cachedTextEncoder = new TextEncoder('utf-8');
|
|
37
|
+
|
|
38
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
39
|
+
? function (arg, view) {
|
|
40
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
41
|
+
}
|
|
42
|
+
: function (arg, view) {
|
|
43
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
44
|
+
view.set(buf);
|
|
45
|
+
return {
|
|
46
|
+
read: arg.length,
|
|
47
|
+
written: buf.length
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
52
|
+
|
|
53
|
+
if (realloc === undefined) {
|
|
54
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
55
|
+
const ptr = malloc(buf.length);
|
|
56
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
57
|
+
WASM_VECTOR_LEN = buf.length;
|
|
58
|
+
return ptr;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let len = arg.length;
|
|
62
|
+
let ptr = malloc(len);
|
|
63
|
+
|
|
64
|
+
const mem = getUint8Memory0();
|
|
65
|
+
|
|
66
|
+
let offset = 0;
|
|
67
|
+
|
|
68
|
+
for (; offset < len; offset++) {
|
|
69
|
+
const code = arg.charCodeAt(offset);
|
|
70
|
+
if (code > 0x7F) break;
|
|
71
|
+
mem[ptr + offset] = code;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (offset !== len) {
|
|
75
|
+
if (offset !== 0) {
|
|
76
|
+
arg = arg.slice(offset);
|
|
77
|
+
}
|
|
78
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
79
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
80
|
+
const ret = encodeString(arg, view);
|
|
81
|
+
|
|
82
|
+
offset += ret.written;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
WASM_VECTOR_LEN = offset;
|
|
86
|
+
return ptr;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isLikeNone(x) {
|
|
90
|
+
return x === undefined || x === null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let cachedInt32Memory0 = null;
|
|
94
|
+
|
|
95
|
+
function getInt32Memory0() {
|
|
96
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
97
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
98
|
+
}
|
|
99
|
+
return cachedInt32Memory0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
103
|
+
|
|
104
|
+
cachedTextDecoder.decode();
|
|
105
|
+
|
|
106
|
+
function getStringFromWasm0(ptr, len) {
|
|
107
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} src
|
|
111
|
+
* @returns {any}
|
|
112
|
+
*/
|
|
113
|
+
export function compile(src) {
|
|
114
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
115
|
+
const len0 = WASM_VECTOR_LEN;
|
|
116
|
+
const ret = wasm.compile(ptr0, len0);
|
|
117
|
+
return takeObject(ret);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
121
|
+
const ptr = malloc(arg.length * 1);
|
|
122
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
123
|
+
WASM_VECTOR_LEN = arg.length;
|
|
124
|
+
return ptr;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @param {Uint8Array} bytes
|
|
128
|
+
* @returns {any}
|
|
129
|
+
*/
|
|
130
|
+
export function acir_from_bytes(bytes) {
|
|
131
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.acir_from_bytes(ptr0, len0);
|
|
134
|
+
return takeObject(ret);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function addHeapObject(obj) {
|
|
138
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
139
|
+
const idx = heap_next;
|
|
140
|
+
heap_next = heap[idx];
|
|
141
|
+
|
|
142
|
+
heap[idx] = obj;
|
|
143
|
+
return idx;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
147
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @param {any} acir
|
|
151
|
+
* @returns {Uint8Array}
|
|
152
|
+
*/
|
|
153
|
+
export function acir_to_bytes(acir) {
|
|
154
|
+
try {
|
|
155
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
156
|
+
wasm.acir_to_bytes(retptr, addHeapObject(acir));
|
|
157
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
158
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
159
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
160
|
+
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
161
|
+
return v0;
|
|
162
|
+
} finally {
|
|
163
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function handleError(f, args) {
|
|
168
|
+
try {
|
|
169
|
+
return f.apply(this, args);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function load(module, imports) {
|
|
176
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
177
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
178
|
+
try {
|
|
179
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
180
|
+
|
|
181
|
+
} catch (e) {
|
|
182
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
183
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
184
|
+
|
|
185
|
+
} else {
|
|
186
|
+
throw e;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const bytes = await module.arrayBuffer();
|
|
192
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
193
|
+
|
|
194
|
+
} else {
|
|
195
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
196
|
+
|
|
197
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
198
|
+
return { instance, module };
|
|
199
|
+
|
|
200
|
+
} else {
|
|
201
|
+
return instance;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function getImports() {
|
|
207
|
+
const imports = {};
|
|
208
|
+
imports.wbg = {};
|
|
209
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
210
|
+
takeObject(arg0);
|
|
211
|
+
};
|
|
212
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
213
|
+
const ret = getObject(arg0) === undefined;
|
|
214
|
+
return ret;
|
|
215
|
+
};
|
|
216
|
+
imports.wbg.__wbg_readfile_141fe7d2c0f1edde = function() { return handleError(function (arg0, arg1, arg2) {
|
|
217
|
+
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
218
|
+
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
221
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
222
|
+
}, arguments) };
|
|
223
|
+
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
224
|
+
const ret = new Error();
|
|
225
|
+
return addHeapObject(ret);
|
|
226
|
+
};
|
|
227
|
+
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
228
|
+
const ret = getObject(arg1).stack;
|
|
229
|
+
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
230
|
+
const len0 = WASM_VECTOR_LEN;
|
|
231
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
232
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
233
|
+
};
|
|
234
|
+
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
235
|
+
try {
|
|
236
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
237
|
+
} finally {
|
|
238
|
+
wasm.__wbindgen_export_2(arg0, arg1);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
242
|
+
const obj = getObject(arg1);
|
|
243
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
244
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
245
|
+
var len0 = WASM_VECTOR_LEN;
|
|
246
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
247
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
248
|
+
};
|
|
249
|
+
imports.wbg.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
|
|
250
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
251
|
+
return addHeapObject(ret);
|
|
252
|
+
}, arguments) };
|
|
253
|
+
imports.wbg.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
|
|
254
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
255
|
+
return addHeapObject(ret);
|
|
256
|
+
}, arguments) };
|
|
257
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
258
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
return imports;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function initMemory(imports, maybe_memory) {
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function finalizeInit(instance, module) {
|
|
269
|
+
wasm = instance.exports;
|
|
270
|
+
init.__wbindgen_wasm_module = module;
|
|
271
|
+
cachedInt32Memory0 = null;
|
|
272
|
+
cachedUint8Memory0 = null;
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
return wasm;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function initSync(module) {
|
|
279
|
+
const imports = getImports();
|
|
280
|
+
|
|
281
|
+
initMemory(imports);
|
|
282
|
+
|
|
283
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
284
|
+
module = new WebAssembly.Module(module);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
288
|
+
|
|
289
|
+
return finalizeInit(instance, module);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async function init(input) {
|
|
293
|
+
if (typeof input === 'undefined') {
|
|
294
|
+
input = new URL('noir_wasm_bg.wasm', import.meta.url);
|
|
295
|
+
}
|
|
296
|
+
const imports = getImports();
|
|
297
|
+
|
|
298
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
299
|
+
input = fetch(input);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
initMemory(imports);
|
|
303
|
+
|
|
304
|
+
const { instance, module } = await load(await input, imports);
|
|
305
|
+
|
|
306
|
+
return finalizeInit(instance, module);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export { initSync }
|
|
310
|
+
export default init;
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function compile(a: number, b: number): number;
|
|
5
|
+
export function acir_from_bytes(a: number, b: number): number;
|
|
6
|
+
export function acir_to_bytes(a: number, b: number): void;
|
|
7
|
+
export function __wbindgen_export_0(a: number): number;
|
|
8
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
9
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
10
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
11
|
+
export function __wbindgen_export_3(a: number): void;
|
package/noir_wasm.d.ts
DELETED
package/noir_wasm_bg.wasm
DELETED
|
Binary file
|