@raviqqe/stak 0.2.45 → 0.2.47
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/package.json +1 -1
- package/stak_wasm.d.ts +20 -18
- package/stak_wasm.js +68 -109
- package/stak_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/stak_wasm.d.ts
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* Compiles a source code.
|
|
5
|
-
* @param {string} source
|
|
6
|
-
* @returns {Uint8Array}
|
|
7
|
-
*/
|
|
4
|
+
* Compiles a source code.
|
|
5
|
+
* @param {string} source
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
|
+
*/
|
|
8
8
|
export function compile(source: string): Uint8Array;
|
|
9
9
|
/**
|
|
10
|
-
* Interprets bytecodes with a standard input and returns its standard output.
|
|
11
|
-
* @param {Uint8Array} bytecodes
|
|
12
|
-
* @param {Uint8Array} input
|
|
13
|
-
* @param {number} heap_size
|
|
14
|
-
* @returns {Uint8Array}
|
|
15
|
-
*/
|
|
10
|
+
* Interprets bytecodes with a standard input and returns its standard output.
|
|
11
|
+
* @param {Uint8Array} bytecodes
|
|
12
|
+
* @param {Uint8Array} input
|
|
13
|
+
* @param {number} heap_size
|
|
14
|
+
* @returns {Uint8Array}
|
|
15
|
+
*/
|
|
16
16
|
export function interpret(bytecodes: Uint8Array, input: Uint8Array, heap_size: number): Uint8Array;
|
|
17
17
|
/**
|
|
18
|
-
* Decodes bytecodes into its Markdown format.
|
|
19
|
-
* @param {Uint8Array} bytecodes
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
18
|
+
* Decodes bytecodes into its Markdown format.
|
|
19
|
+
* @param {Uint8Array} bytecodes
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
22
|
export function decode(bytecodes: Uint8Array): string;
|
|
23
23
|
|
|
24
24
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
25
25
|
|
|
26
26
|
export interface InitOutput {
|
|
27
27
|
readonly memory: WebAssembly.Memory;
|
|
28
|
-
readonly compile: (a: number, b: number
|
|
29
|
-
readonly interpret: (a: number, b: number, c: number, d: number, e: number
|
|
30
|
-
readonly decode: (a: number, b: number
|
|
31
|
-
readonly
|
|
28
|
+
readonly compile: (a: number, b: number) => Array;
|
|
29
|
+
readonly interpret: (a: number, b: number, c: number, d: number, e: number) => Array;
|
|
30
|
+
readonly decode: (a: number, b: number) => Array;
|
|
31
|
+
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
32
32
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
33
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
34
35
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
36
|
+
readonly __wbindgen_start: () => void;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
package/stak_wasm.js
CHANGED
|
@@ -18,21 +18,6 @@ function getStringFromWasm0(ptr, len) {
|
|
|
18
18
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const heap = new Array(128).fill(undefined);
|
|
22
|
-
|
|
23
|
-
heap.push(undefined, null, true, false);
|
|
24
|
-
|
|
25
|
-
let heap_next = heap.length;
|
|
26
|
-
|
|
27
|
-
function addHeapObject(obj) {
|
|
28
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
29
|
-
const idx = heap_next;
|
|
30
|
-
heap_next = heap[idx];
|
|
31
|
-
|
|
32
|
-
heap[idx] = obj;
|
|
33
|
-
return idx;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
21
|
let WASM_VECTOR_LEN = 0;
|
|
37
22
|
|
|
38
23
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
@@ -89,27 +74,10 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
89
74
|
return ptr;
|
|
90
75
|
}
|
|
91
76
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
97
|
-
}
|
|
98
|
-
return cachedDataViewMemory0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getObject(idx) { return heap[idx]; }
|
|
102
|
-
|
|
103
|
-
function dropObject(idx) {
|
|
104
|
-
if (idx < 132) 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;
|
|
77
|
+
function takeFromExternrefTable0(idx) {
|
|
78
|
+
const value = wasm.__wbindgen_export_0.get(idx);
|
|
79
|
+
wasm.__externref_table_dealloc(idx);
|
|
80
|
+
return value;
|
|
113
81
|
}
|
|
114
82
|
|
|
115
83
|
function getArrayU8FromWasm0(ptr, len) {
|
|
@@ -117,29 +85,20 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
117
85
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
118
86
|
}
|
|
119
87
|
/**
|
|
120
|
-
* Compiles a source code.
|
|
121
|
-
* @param {string} source
|
|
122
|
-
* @returns {Uint8Array}
|
|
123
|
-
*/
|
|
88
|
+
* Compiles a source code.
|
|
89
|
+
* @param {string} source
|
|
90
|
+
* @returns {Uint8Array}
|
|
91
|
+
*/
|
|
124
92
|
export function compile(source) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
131
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
132
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
133
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
134
|
-
if (r3) {
|
|
135
|
-
throw takeObject(r2);
|
|
136
|
-
}
|
|
137
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
138
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
139
|
-
return v2;
|
|
140
|
-
} finally {
|
|
141
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
93
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
94
|
+
const len0 = WASM_VECTOR_LEN;
|
|
95
|
+
const ret = wasm.compile(ptr0, len0);
|
|
96
|
+
if (ret[3]) {
|
|
97
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
142
98
|
}
|
|
99
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
100
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
101
|
+
return v2;
|
|
143
102
|
}
|
|
144
103
|
|
|
145
104
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -149,63 +108,48 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
149
108
|
return ptr;
|
|
150
109
|
}
|
|
151
110
|
/**
|
|
152
|
-
* Interprets bytecodes with a standard input and returns its standard output.
|
|
153
|
-
* @param {Uint8Array} bytecodes
|
|
154
|
-
* @param {Uint8Array} input
|
|
155
|
-
* @param {number} heap_size
|
|
156
|
-
* @returns {Uint8Array}
|
|
157
|
-
*/
|
|
111
|
+
* Interprets bytecodes with a standard input and returns its standard output.
|
|
112
|
+
* @param {Uint8Array} bytecodes
|
|
113
|
+
* @param {Uint8Array} input
|
|
114
|
+
* @param {number} heap_size
|
|
115
|
+
* @returns {Uint8Array}
|
|
116
|
+
*/
|
|
158
117
|
export function interpret(bytecodes, input, heap_size) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
167
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
168
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
169
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
170
|
-
if (r3) {
|
|
171
|
-
throw takeObject(r2);
|
|
172
|
-
}
|
|
173
|
-
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
174
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
175
|
-
return v3;
|
|
176
|
-
} finally {
|
|
177
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
118
|
+
const ptr0 = passArray8ToWasm0(bytecodes, wasm.__wbindgen_malloc);
|
|
119
|
+
const len0 = WASM_VECTOR_LEN;
|
|
120
|
+
const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
121
|
+
const len1 = WASM_VECTOR_LEN;
|
|
122
|
+
const ret = wasm.interpret(ptr0, len0, ptr1, len1, heap_size);
|
|
123
|
+
if (ret[3]) {
|
|
124
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
178
125
|
}
|
|
126
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
127
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
128
|
+
return v3;
|
|
179
129
|
}
|
|
180
130
|
|
|
181
131
|
/**
|
|
182
|
-
* Decodes bytecodes into its Markdown format.
|
|
183
|
-
* @param {Uint8Array} bytecodes
|
|
184
|
-
* @returns {string}
|
|
185
|
-
*/
|
|
132
|
+
* Decodes bytecodes into its Markdown format.
|
|
133
|
+
* @param {Uint8Array} bytecodes
|
|
134
|
+
* @returns {string}
|
|
135
|
+
*/
|
|
186
136
|
export function decode(bytecodes) {
|
|
187
137
|
let deferred3_0;
|
|
188
138
|
let deferred3_1;
|
|
189
139
|
try {
|
|
190
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
191
140
|
const ptr0 = passArray8ToWasm0(bytecodes, wasm.__wbindgen_malloc);
|
|
192
141
|
const len0 = WASM_VECTOR_LEN;
|
|
193
|
-
wasm.decode(
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
198
|
-
var ptr2 = r0;
|
|
199
|
-
var len2 = r1;
|
|
200
|
-
if (r3) {
|
|
142
|
+
const ret = wasm.decode(ptr0, len0);
|
|
143
|
+
var ptr2 = ret[0];
|
|
144
|
+
var len2 = ret[1];
|
|
145
|
+
if (ret[3]) {
|
|
201
146
|
ptr2 = 0; len2 = 0;
|
|
202
|
-
throw
|
|
147
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
203
148
|
}
|
|
204
149
|
deferred3_0 = ptr2;
|
|
205
150
|
deferred3_1 = len2;
|
|
206
151
|
return getStringFromWasm0(ptr2, len2);
|
|
207
152
|
} finally {
|
|
208
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
209
153
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
210
154
|
}
|
|
211
155
|
}
|
|
@@ -218,7 +162,7 @@ async function __wbg_load(module, imports) {
|
|
|
218
162
|
|
|
219
163
|
} catch (e) {
|
|
220
164
|
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
221
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve
|
|
165
|
+
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);
|
|
222
166
|
|
|
223
167
|
} else {
|
|
224
168
|
throw e;
|
|
@@ -246,7 +190,17 @@ function __wbg_get_imports() {
|
|
|
246
190
|
imports.wbg = {};
|
|
247
191
|
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
248
192
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
249
|
-
return
|
|
193
|
+
return ret;
|
|
194
|
+
};
|
|
195
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
196
|
+
const table = wasm.__wbindgen_export_0;
|
|
197
|
+
const offset = table.grow(4);
|
|
198
|
+
table.set(0, undefined);
|
|
199
|
+
table.set(offset + 0, undefined);
|
|
200
|
+
table.set(offset + 1, null);
|
|
201
|
+
table.set(offset + 2, true);
|
|
202
|
+
table.set(offset + 3, false);
|
|
203
|
+
;
|
|
250
204
|
};
|
|
251
205
|
|
|
252
206
|
return imports;
|
|
@@ -259,11 +213,10 @@ function __wbg_init_memory(imports, memory) {
|
|
|
259
213
|
function __wbg_finalize_init(instance, module) {
|
|
260
214
|
wasm = instance.exports;
|
|
261
215
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
262
|
-
cachedDataViewMemory0 = null;
|
|
263
216
|
cachedUint8ArrayMemory0 = null;
|
|
264
217
|
|
|
265
218
|
|
|
266
|
-
|
|
219
|
+
wasm.__wbindgen_start();
|
|
267
220
|
return wasm;
|
|
268
221
|
}
|
|
269
222
|
|
|
@@ -271,10 +224,13 @@ function initSync(module) {
|
|
|
271
224
|
if (wasm !== undefined) return wasm;
|
|
272
225
|
|
|
273
226
|
|
|
274
|
-
if (typeof module !== 'undefined'
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
227
|
+
if (typeof module !== 'undefined') {
|
|
228
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
229
|
+
({module} = module)
|
|
230
|
+
} else {
|
|
231
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
232
|
+
}
|
|
233
|
+
}
|
|
278
234
|
|
|
279
235
|
const imports = __wbg_get_imports();
|
|
280
236
|
|
|
@@ -293,10 +249,13 @@ async function __wbg_init(module_or_path) {
|
|
|
293
249
|
if (wasm !== undefined) return wasm;
|
|
294
250
|
|
|
295
251
|
|
|
296
|
-
if (typeof module_or_path !== 'undefined'
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
252
|
+
if (typeof module_or_path !== 'undefined') {
|
|
253
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
254
|
+
({module_or_path} = module_or_path)
|
|
255
|
+
} else {
|
|
256
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
257
|
+
}
|
|
258
|
+
}
|
|
300
259
|
|
|
301
260
|
if (typeof module_or_path === 'undefined') {
|
|
302
261
|
module_or_path = new URL('stak_wasm_bg.wasm', import.meta.url);
|
package/stak_wasm_bg.wasm
CHANGED
|
Binary file
|