@noir-lang/noir_wasm 0.1.0 → 0.1.1-fd64be5
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 +21 -0
- package/{noir_wasm.js → nodejs/noir_wasm.js} +125 -53
- package/nodejs/noir_wasm_bg.wasm +0 -0
- package/nodejs/noir_wasm_bg.wasm.d.ts +12 -0
- package/package.json +22 -7
- package/web/noir_wasm.d.ts +57 -0
- package/web/noir_wasm.js +318 -0
- package/web/noir_wasm_bg.wasm +0 -0
- package/web/noir_wasm_bg.wasm.d.ts +12 -0
- package/noir_wasm.d.ts +0 -7
- package/noir_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
* @returns {any}
|
|
20
|
+
*/
|
|
21
|
+
export function build_info(): any;
|
|
@@ -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,79 @@ 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;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
149
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
123
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
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @returns {any}
|
|
171
|
+
*/
|
|
172
|
+
module.exports.build_info = function() {
|
|
173
|
+
const ret = wasm.build_info();
|
|
174
|
+
return takeObject(ret);
|
|
175
|
+
};
|
|
124
176
|
|
|
125
177
|
function handleError(f, args) {
|
|
126
178
|
try {
|
|
127
179
|
return f.apply(this, args);
|
|
128
180
|
} catch (e) {
|
|
129
|
-
wasm.
|
|
181
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
130
182
|
}
|
|
131
183
|
}
|
|
132
184
|
|
|
133
|
-
module.exports.
|
|
134
|
-
const ret =
|
|
135
|
-
return
|
|
185
|
+
module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
186
|
+
const ret = getObject(arg0) === undefined;
|
|
187
|
+
return ret;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
191
|
+
takeObject(arg0);
|
|
136
192
|
};
|
|
137
193
|
|
|
138
|
-
module.exports.
|
|
194
|
+
module.exports.__wbg_readfile_141fe7d2c0f1edde = function() { return handleError(function (arg0, arg1, arg2) {
|
|
139
195
|
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
140
196
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
141
197
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -143,16 +199,12 @@ module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError
|
|
|
143
199
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
144
200
|
}, arguments) };
|
|
145
201
|
|
|
146
|
-
module.exports.
|
|
147
|
-
takeObject(arg0);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
module.exports.__wbg_new_693216e109162396 = function() {
|
|
202
|
+
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
151
203
|
const ret = new Error();
|
|
152
204
|
return addHeapObject(ret);
|
|
153
205
|
};
|
|
154
206
|
|
|
155
|
-
module.exports.
|
|
207
|
+
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
156
208
|
const ret = getObject(arg1).stack;
|
|
157
209
|
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
158
210
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -160,14 +212,37 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
|
|
|
160
212
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
161
213
|
};
|
|
162
214
|
|
|
163
|
-
module.exports.
|
|
215
|
+
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
164
216
|
try {
|
|
165
217
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
166
218
|
} finally {
|
|
167
|
-
wasm.
|
|
219
|
+
wasm.__wbindgen_export_2(arg0, arg1);
|
|
168
220
|
}
|
|
169
221
|
};
|
|
170
222
|
|
|
223
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
224
|
+
const obj = getObject(arg1);
|
|
225
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
226
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
227
|
+
var len0 = WASM_VECTOR_LEN;
|
|
228
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
229
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
module.exports.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
|
|
233
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
234
|
+
return addHeapObject(ret);
|
|
235
|
+
}, arguments) };
|
|
236
|
+
|
|
237
|
+
module.exports.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
|
|
238
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
239
|
+
return addHeapObject(ret);
|
|
240
|
+
}, arguments) };
|
|
241
|
+
|
|
242
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
243
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
244
|
+
};
|
|
245
|
+
|
|
171
246
|
const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
|
|
172
247
|
const bytes = require('fs').readFileSync(path);
|
|
173
248
|
|
|
@@ -176,6 +251,3 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
|
176
251
|
wasm = wasmInstance.exports;
|
|
177
252
|
module.exports.__wasm = wasm;
|
|
178
253
|
|
|
179
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
180
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
181
|
-
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
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 build_info(): number;
|
|
8
|
+
export function __wbindgen_export_0(a: number): number;
|
|
9
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
10
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
11
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
12
|
+
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-fd64be5",
|
|
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": "fd64be55fc905a032d53c9ac7a7f7b71da899c37"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
* @returns {any}
|
|
20
|
+
*/
|
|
21
|
+
export function build_info(): any;
|
|
22
|
+
|
|
23
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
24
|
+
|
|
25
|
+
export interface InitOutput {
|
|
26
|
+
readonly memory: WebAssembly.Memory;
|
|
27
|
+
readonly compile: (a: number, b: number) => number;
|
|
28
|
+
readonly acir_from_bytes: (a: number, b: number) => number;
|
|
29
|
+
readonly acir_to_bytes: (a: number, b: number) => void;
|
|
30
|
+
readonly build_info: () => number;
|
|
31
|
+
readonly __wbindgen_export_0: (a: number) => number;
|
|
32
|
+
readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
|
|
33
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
34
|
+
readonly __wbindgen_export_2: (a: number, b: number) => void;
|
|
35
|
+
readonly __wbindgen_export_3: (a: number) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
39
|
+
/**
|
|
40
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
41
|
+
* a precompiled `WebAssembly.Module`.
|
|
42
|
+
*
|
|
43
|
+
* @param {SyncInitInput} module
|
|
44
|
+
*
|
|
45
|
+
* @returns {InitOutput}
|
|
46
|
+
*/
|
|
47
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
51
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
52
|
+
*
|
|
53
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
54
|
+
*
|
|
55
|
+
* @returns {Promise<InitOutput>}
|
|
56
|
+
*/
|
|
57
|
+
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/web/noir_wasm.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
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
|
+
/**
|
|
168
|
+
* @returns {any}
|
|
169
|
+
*/
|
|
170
|
+
export function build_info() {
|
|
171
|
+
const ret = wasm.build_info();
|
|
172
|
+
return takeObject(ret);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function handleError(f, args) {
|
|
176
|
+
try {
|
|
177
|
+
return f.apply(this, args);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function load(module, imports) {
|
|
184
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
185
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
186
|
+
try {
|
|
187
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
188
|
+
|
|
189
|
+
} catch (e) {
|
|
190
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
191
|
+
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);
|
|
192
|
+
|
|
193
|
+
} else {
|
|
194
|
+
throw e;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const bytes = await module.arrayBuffer();
|
|
200
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
201
|
+
|
|
202
|
+
} else {
|
|
203
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
204
|
+
|
|
205
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
206
|
+
return { instance, module };
|
|
207
|
+
|
|
208
|
+
} else {
|
|
209
|
+
return instance;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getImports() {
|
|
215
|
+
const imports = {};
|
|
216
|
+
imports.wbg = {};
|
|
217
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
218
|
+
const ret = getObject(arg0) === undefined;
|
|
219
|
+
return ret;
|
|
220
|
+
};
|
|
221
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
222
|
+
takeObject(arg0);
|
|
223
|
+
};
|
|
224
|
+
imports.wbg.__wbg_readfile_141fe7d2c0f1edde = function() { return handleError(function (arg0, arg1, arg2) {
|
|
225
|
+
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
226
|
+
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
227
|
+
const len0 = WASM_VECTOR_LEN;
|
|
228
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
229
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
230
|
+
}, arguments) };
|
|
231
|
+
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
232
|
+
const ret = new Error();
|
|
233
|
+
return addHeapObject(ret);
|
|
234
|
+
};
|
|
235
|
+
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
236
|
+
const ret = getObject(arg1).stack;
|
|
237
|
+
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
238
|
+
const len0 = WASM_VECTOR_LEN;
|
|
239
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
240
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
241
|
+
};
|
|
242
|
+
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
243
|
+
try {
|
|
244
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
245
|
+
} finally {
|
|
246
|
+
wasm.__wbindgen_export_2(arg0, arg1);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
250
|
+
const obj = getObject(arg1);
|
|
251
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
252
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
253
|
+
var len0 = WASM_VECTOR_LEN;
|
|
254
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
255
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
256
|
+
};
|
|
257
|
+
imports.wbg.__wbg_parse_3ac95b51fc312db8 = function() { return handleError(function (arg0, arg1) {
|
|
258
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
259
|
+
return addHeapObject(ret);
|
|
260
|
+
}, arguments) };
|
|
261
|
+
imports.wbg.__wbg_stringify_029a979dfb73aa17 = function() { return handleError(function (arg0) {
|
|
262
|
+
const ret = JSON.stringify(getObject(arg0));
|
|
263
|
+
return addHeapObject(ret);
|
|
264
|
+
}, arguments) };
|
|
265
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
266
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
return imports;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function initMemory(imports, maybe_memory) {
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function finalizeInit(instance, module) {
|
|
277
|
+
wasm = instance.exports;
|
|
278
|
+
init.__wbindgen_wasm_module = module;
|
|
279
|
+
cachedInt32Memory0 = null;
|
|
280
|
+
cachedUint8Memory0 = null;
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
return wasm;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function initSync(module) {
|
|
287
|
+
const imports = getImports();
|
|
288
|
+
|
|
289
|
+
initMemory(imports);
|
|
290
|
+
|
|
291
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
292
|
+
module = new WebAssembly.Module(module);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
296
|
+
|
|
297
|
+
return finalizeInit(instance, module);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function init(input) {
|
|
301
|
+
if (typeof input === 'undefined') {
|
|
302
|
+
input = new URL('noir_wasm_bg.wasm', import.meta.url);
|
|
303
|
+
}
|
|
304
|
+
const imports = getImports();
|
|
305
|
+
|
|
306
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
307
|
+
input = fetch(input);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
initMemory(imports);
|
|
311
|
+
|
|
312
|
+
const { instance, module } = await load(await input, imports);
|
|
313
|
+
|
|
314
|
+
return finalizeInit(instance, module);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export { initSync }
|
|
318
|
+
export default init;
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
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 build_info(): number;
|
|
8
|
+
export function __wbindgen_export_0(a: number): number;
|
|
9
|
+
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
10
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
11
|
+
export function __wbindgen_export_2(a: number, b: number): void;
|
|
12
|
+
export function __wbindgen_export_3(a: number): void;
|
package/noir_wasm.d.ts
DELETED
package/noir_wasm_bg.wasm
DELETED
|
Binary file
|