@noir-lang/noir_wasm 0.11.0 → 0.16.0-10eae15.nightly
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/CHANGELOG.md +24 -0
- package/README.md +19 -0
- package/nodejs/noir_wasm.d.ts +54 -0
- package/nodejs/noir_wasm.js +381 -0
- package/nodejs/noir_wasm_bg.wasm +0 -0
- package/nodejs/noir_wasm_bg.wasm.d.ts +18 -0
- package/package.json +38 -8
- package/web/noir_wasm.d.ts +96 -0
- package/web/noir_wasm.js +438 -0
- package/web/noir_wasm_bg.wasm +0 -0
- package/web/noir_wasm_bg.wasm.d.ts +18 -0
- package/noir_wasm.d.ts +0 -56
- package/noir_wasm.js +0 -295
- package/noir_wasm_bg.wasm +0 -0
- package/noir_wasm_bg.wasm.d.ts +0 -15
- package/snippets/fm-cffb18dcbd478425/file_reader.js +0 -6
package/noir_wasm.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { read_file } from './snippets/fm-cffb18dcbd478425/file_reader.js';
|
|
2
|
-
|
|
3
|
-
let wasm;
|
|
4
|
-
|
|
5
|
-
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
6
|
-
|
|
7
|
-
cachedTextDecoder.decode();
|
|
8
|
-
|
|
9
|
-
let cachedUint8Memory0 = new Uint8Array();
|
|
10
|
-
|
|
11
|
-
function getUint8Memory0() {
|
|
12
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
13
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
-
}
|
|
15
|
-
return cachedUint8Memory0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getStringFromWasm0(ptr, len) {
|
|
19
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const heap = new Array(32).fill(undefined);
|
|
23
|
-
|
|
24
|
-
heap.push(undefined, null, true, false);
|
|
25
|
-
|
|
26
|
-
let heap_next = heap.length;
|
|
27
|
-
|
|
28
|
-
function addHeapObject(obj) {
|
|
29
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
30
|
-
const idx = heap_next;
|
|
31
|
-
heap_next = heap[idx];
|
|
32
|
-
|
|
33
|
-
heap[idx] = obj;
|
|
34
|
-
return idx;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getObject(idx) { return heap[idx]; }
|
|
38
|
-
|
|
39
|
-
let WASM_VECTOR_LEN = 0;
|
|
40
|
-
|
|
41
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
|
42
|
-
|
|
43
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
44
|
-
? function (arg, view) {
|
|
45
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
46
|
-
}
|
|
47
|
-
: function (arg, view) {
|
|
48
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
49
|
-
view.set(buf);
|
|
50
|
-
return {
|
|
51
|
-
read: arg.length,
|
|
52
|
-
written: buf.length
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
57
|
-
|
|
58
|
-
if (realloc === undefined) {
|
|
59
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
60
|
-
const ptr = malloc(buf.length);
|
|
61
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
62
|
-
WASM_VECTOR_LEN = buf.length;
|
|
63
|
-
return ptr;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let len = arg.length;
|
|
67
|
-
let ptr = malloc(len);
|
|
68
|
-
|
|
69
|
-
const mem = getUint8Memory0();
|
|
70
|
-
|
|
71
|
-
let offset = 0;
|
|
72
|
-
|
|
73
|
-
for (; offset < len; offset++) {
|
|
74
|
-
const code = arg.charCodeAt(offset);
|
|
75
|
-
if (code > 0x7F) break;
|
|
76
|
-
mem[ptr + offset] = code;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (offset !== len) {
|
|
80
|
-
if (offset !== 0) {
|
|
81
|
-
arg = arg.slice(offset);
|
|
82
|
-
}
|
|
83
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
84
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
85
|
-
const ret = encodeString(arg, view);
|
|
86
|
-
|
|
87
|
-
offset += ret.written;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
WASM_VECTOR_LEN = offset;
|
|
91
|
-
return ptr;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let cachedInt32Memory0 = new Int32Array();
|
|
95
|
-
|
|
96
|
-
function getInt32Memory0() {
|
|
97
|
-
if (cachedInt32Memory0.byteLength === 0) {
|
|
98
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
99
|
-
}
|
|
100
|
-
return cachedInt32Memory0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function dropObject(idx) {
|
|
104
|
-
if (idx < 36) return;
|
|
105
|
-
heap[idx] = heap_next;
|
|
106
|
-
heap_next = idx;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function takeObject(idx) {
|
|
110
|
-
const ret = getObject(idx);
|
|
111
|
-
dropObject(idx);
|
|
112
|
-
return ret;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* @param {string} src
|
|
116
|
-
* @returns {any}
|
|
117
|
-
*/
|
|
118
|
-
export function compile(src) {
|
|
119
|
-
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
120
|
-
const len0 = WASM_VECTOR_LEN;
|
|
121
|
-
const ret = wasm.compile(ptr0, len0);
|
|
122
|
-
return takeObject(ret);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
126
|
-
const ptr = malloc(arg.length * 1);
|
|
127
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
128
|
-
WASM_VECTOR_LEN = arg.length;
|
|
129
|
-
return ptr;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* @param {Uint8Array} bytes
|
|
133
|
-
* @returns {any}
|
|
134
|
-
*/
|
|
135
|
-
export function acir_from_bytes(bytes) {
|
|
136
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
|
|
137
|
-
const len0 = WASM_VECTOR_LEN;
|
|
138
|
-
const ret = wasm.acir_from_bytes(ptr0, len0);
|
|
139
|
-
return takeObject(ret);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
143
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* @param {any} acir
|
|
147
|
-
* @returns {Uint8Array}
|
|
148
|
-
*/
|
|
149
|
-
export function acir_to_bytes(acir) {
|
|
150
|
-
try {
|
|
151
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
152
|
-
wasm.acir_to_bytes(retptr, addHeapObject(acir));
|
|
153
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
154
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
155
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
156
|
-
wasm.__wbindgen_export_2(r0, r1 * 1);
|
|
157
|
-
return v0;
|
|
158
|
-
} finally {
|
|
159
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function handleError(f, args) {
|
|
164
|
-
try {
|
|
165
|
-
return f.apply(this, args);
|
|
166
|
-
} catch (e) {
|
|
167
|
-
wasm.__wbindgen_export_3(addHeapObject(e));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async function load(module, imports) {
|
|
172
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
173
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
174
|
-
try {
|
|
175
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
176
|
-
|
|
177
|
-
} catch (e) {
|
|
178
|
-
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
179
|
-
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);
|
|
180
|
-
|
|
181
|
-
} else {
|
|
182
|
-
throw e;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const bytes = await module.arrayBuffer();
|
|
188
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
192
|
-
|
|
193
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
194
|
-
return { instance, module };
|
|
195
|
-
|
|
196
|
-
} else {
|
|
197
|
-
return instance;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function getImports() {
|
|
203
|
-
const imports = {};
|
|
204
|
-
imports.wbg = {};
|
|
205
|
-
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
|
|
206
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
207
|
-
return addHeapObject(ret);
|
|
208
|
-
};
|
|
209
|
-
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
210
|
-
const obj = getObject(arg1);
|
|
211
|
-
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
212
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
213
|
-
const len0 = WASM_VECTOR_LEN;
|
|
214
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
215
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
216
|
-
};
|
|
217
|
-
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
218
|
-
takeObject(arg0);
|
|
219
|
-
};
|
|
220
|
-
imports.wbg.__wbg_readfile_a255adfa6d841e23 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
221
|
-
const ret = read_file(getStringFromWasm0(arg1, arg2));
|
|
222
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
223
|
-
const len0 = WASM_VECTOR_LEN;
|
|
224
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
225
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
226
|
-
}, arguments) };
|
|
227
|
-
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
228
|
-
const ret = new Error();
|
|
229
|
-
return addHeapObject(ret);
|
|
230
|
-
};
|
|
231
|
-
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
232
|
-
const ret = getObject(arg1).stack;
|
|
233
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
234
|
-
const len0 = WASM_VECTOR_LEN;
|
|
235
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
236
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
237
|
-
};
|
|
238
|
-
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
239
|
-
try {
|
|
240
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
241
|
-
} finally {
|
|
242
|
-
wasm.__wbindgen_export_2(arg0, arg1);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
return imports;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function initMemory(imports, maybe_memory) {
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function finalizeInit(instance, module) {
|
|
254
|
-
wasm = instance.exports;
|
|
255
|
-
init.__wbindgen_wasm_module = module;
|
|
256
|
-
cachedInt32Memory0 = new Int32Array();
|
|
257
|
-
cachedUint8Memory0 = new Uint8Array();
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return wasm;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function initSync(module) {
|
|
264
|
-
const imports = getImports();
|
|
265
|
-
|
|
266
|
-
initMemory(imports);
|
|
267
|
-
|
|
268
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
269
|
-
module = new WebAssembly.Module(module);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
273
|
-
|
|
274
|
-
return finalizeInit(instance, module);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async function init(input) {
|
|
278
|
-
if (typeof input === 'undefined') {
|
|
279
|
-
input = new URL('noir_wasm_bg.wasm', import.meta.url);
|
|
280
|
-
}
|
|
281
|
-
const imports = getImports();
|
|
282
|
-
|
|
283
|
-
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
284
|
-
input = fetch(input);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
initMemory(imports);
|
|
288
|
-
|
|
289
|
-
const { instance, module } = await load(await input, imports);
|
|
290
|
-
|
|
291
|
-
return finalizeInit(instance, module);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export { initSync }
|
|
295
|
-
export default init;
|
package/noir_wasm_bg.wasm
DELETED
|
Binary file
|
package/noir_wasm_bg.wasm.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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 rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
|
|
8
|
-
export function rust_psm_stack_direction(): number;
|
|
9
|
-
export function rust_psm_stack_pointer(): number;
|
|
10
|
-
export function rust_psm_replace_stack(a: number, b: number, c: number): void;
|
|
11
|
-
export function __wbindgen_export_0(a: number): number;
|
|
12
|
-
export function __wbindgen_export_1(a: number, b: number, c: number): number;
|
|
13
|
-
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
14
|
-
export function __wbindgen_export_2(a: number, b: number): void;
|
|
15
|
-
export function __wbindgen_export_3(a: number): void;
|