@noir-lang/noir_wasm 0.1.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/noir_wasm.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {string} src
5
+ * @returns {any}
6
+ */
7
+ export function compile(src: string): any;
package/noir_wasm.js ADDED
@@ -0,0 +1,181 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { read_file } = require(String.raw`./snippets/fm-cffb18dcbd478425/file_reader.js`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
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);
24
+
25
+ heap.push(undefined, null, true, false);
26
+
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
+ function getObject(idx) { return heap[idx]; }
39
+
40
+ function dropObject(idx) {
41
+ if (idx < 36) return;
42
+ heap[idx] = heap_next;
43
+ heap_next = idx;
44
+ }
45
+
46
+ function takeObject(idx) {
47
+ const ret = getObject(idx);
48
+ dropObject(idx);
49
+ return ret;
50
+ }
51
+
52
+ let WASM_VECTOR_LEN = 0;
53
+
54
+ let cachedTextEncoder = new TextEncoder('utf-8');
55
+
56
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
57
+ ? function (arg, view) {
58
+ return cachedTextEncoder.encodeInto(arg, view);
59
+ }
60
+ : function (arg, view) {
61
+ const buf = cachedTextEncoder.encode(arg);
62
+ view.set(buf);
63
+ return {
64
+ read: arg.length,
65
+ written: buf.length
66
+ };
67
+ });
68
+
69
+ function passStringToWasm0(arg, malloc, realloc) {
70
+
71
+ if (realloc === undefined) {
72
+ const buf = cachedTextEncoder.encode(arg);
73
+ const ptr = malloc(buf.length);
74
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
75
+ WASM_VECTOR_LEN = buf.length;
76
+ return ptr;
77
+ }
78
+
79
+ let len = arg.length;
80
+ let ptr = malloc(len);
81
+
82
+ const mem = getUint8Memory0();
83
+
84
+ let offset = 0;
85
+
86
+ for (; offset < len; offset++) {
87
+ const code = arg.charCodeAt(offset);
88
+ if (code > 0x7F) break;
89
+ mem[ptr + offset] = code;
90
+ }
91
+
92
+ if (offset !== len) {
93
+ if (offset !== 0) {
94
+ arg = arg.slice(offset);
95
+ }
96
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
97
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
98
+ const ret = encodeString(arg, view);
99
+
100
+ offset += ret.written;
101
+ }
102
+
103
+ WASM_VECTOR_LEN = offset;
104
+ return ptr;
105
+ }
106
+ /**
107
+ * @param {string} src
108
+ * @returns {any}
109
+ */
110
+ module.exports.compile = function(src) {
111
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.compile(ptr0, len0);
114
+ return takeObject(ret);
115
+ };
116
+
117
+ let cachedInt32Memory0;
118
+ function getInt32Memory0() {
119
+ if (cachedInt32Memory0.byteLength === 0) {
120
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
121
+ }
122
+ return cachedInt32Memory0;
123
+ }
124
+
125
+ function handleError(f, args) {
126
+ try {
127
+ return f.apply(this, args);
128
+ } catch (e) {
129
+ wasm.__wbindgen_export_2(addHeapObject(e));
130
+ }
131
+ }
132
+
133
+ module.exports.__wbindgen_json_parse = function(arg0, arg1) {
134
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
135
+ return addHeapObject(ret);
136
+ };
137
+
138
+ module.exports.__wbg_readfile_381ecedf0ec0c1aa = function() { return handleError(function (arg0, arg1, arg2) {
139
+ const ret = read_file(getStringFromWasm0(arg1, arg2));
140
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
+ const len0 = WASM_VECTOR_LEN;
142
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
143
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
144
+ }, arguments) };
145
+
146
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
147
+ takeObject(arg0);
148
+ };
149
+
150
+ module.exports.__wbg_new_693216e109162396 = function() {
151
+ const ret = new Error();
152
+ return addHeapObject(ret);
153
+ };
154
+
155
+ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
156
+ const ret = getObject(arg1).stack;
157
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
160
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
161
+ };
162
+
163
+ module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
164
+ try {
165
+ console.error(getStringFromWasm0(arg0, arg1));
166
+ } finally {
167
+ wasm.__wbindgen_export_3(arg0, arg1);
168
+ }
169
+ };
170
+
171
+ const path = require('path').join(__dirname, 'noir_wasm_bg.wasm');
172
+ const bytes = require('fs').readFileSync(path);
173
+
174
+ const wasmModule = new WebAssembly.Module(bytes);
175
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
176
+ wasm = wasmInstance.exports;
177
+ module.exports.__wasm = wasm;
178
+
179
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
180
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
181
+
Binary file
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@noir-lang/noir_wasm",
3
+ "version": "0.1.0",
4
+ "files": [
5
+ "noir_wasm_bg.wasm",
6
+ "noir_wasm.js",
7
+ "noir_wasm.d.ts"
8
+ ],
9
+ "main": "noir_wasm.js",
10
+ "types": "noir_wasm.d.ts"
11
+ }