@raviqqe/stak 0.12.34 → 0.12.36

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/repl.js ADDED
@@ -0,0 +1,459 @@
1
+ let wasm;
2
+
3
+ let cachedUint8ArrayMemory0 = null;
4
+
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
11
+
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ function debugString(val) {
34
+ // primitive types
35
+ const type = typeof val;
36
+ if (type == 'number' || type == 'boolean' || val == null) {
37
+ return `${val}`;
38
+ }
39
+ if (type == 'string') {
40
+ return `"${val}"`;
41
+ }
42
+ if (type == 'symbol') {
43
+ const description = val.description;
44
+ if (description == null) {
45
+ return 'Symbol';
46
+ } else {
47
+ return `Symbol(${description})`;
48
+ }
49
+ }
50
+ if (type == 'function') {
51
+ const name = val.name;
52
+ if (typeof name == 'string' && name.length > 0) {
53
+ return `Function(${name})`;
54
+ } else {
55
+ return 'Function';
56
+ }
57
+ }
58
+ // objects
59
+ if (Array.isArray(val)) {
60
+ const length = val.length;
61
+ let debug = '[';
62
+ if (length > 0) {
63
+ debug += debugString(val[0]);
64
+ }
65
+ for(let i = 1; i < length; i++) {
66
+ debug += ', ' + debugString(val[i]);
67
+ }
68
+ debug += ']';
69
+ return debug;
70
+ }
71
+ // Test for built-in
72
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
73
+ let className;
74
+ if (builtInMatches && builtInMatches.length > 1) {
75
+ className = builtInMatches[1];
76
+ } else {
77
+ // Failed to match the standard '[object ClassName]'
78
+ return toString.call(val);
79
+ }
80
+ if (className == 'Object') {
81
+ // we're a user defined class or Object
82
+ // JSON.stringify avoids problems with cycles, and is generally much
83
+ // easier than looping through ownProperties of `val`.
84
+ try {
85
+ return 'Object(' + JSON.stringify(val) + ')';
86
+ } catch (_) {
87
+ return 'Object';
88
+ }
89
+ }
90
+ // errors
91
+ if (val instanceof Error) {
92
+ return `${val.name}: ${val.message}\n${val.stack}`;
93
+ }
94
+ // TODO we could test for more things here, like `Set`s and `Map`s.
95
+ return className;
96
+ }
97
+
98
+ let WASM_VECTOR_LEN = 0;
99
+
100
+ const cachedTextEncoder = new TextEncoder();
101
+
102
+ if (!('encodeInto' in cachedTextEncoder)) {
103
+ cachedTextEncoder.encodeInto = function (arg, view) {
104
+ const buf = cachedTextEncoder.encode(arg);
105
+ view.set(buf);
106
+ return {
107
+ read: arg.length,
108
+ written: buf.length
109
+ };
110
+ }
111
+ }
112
+
113
+ function passStringToWasm0(arg, malloc, realloc) {
114
+
115
+ if (realloc === undefined) {
116
+ const buf = cachedTextEncoder.encode(arg);
117
+ const ptr = malloc(buf.length, 1) >>> 0;
118
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
119
+ WASM_VECTOR_LEN = buf.length;
120
+ return ptr;
121
+ }
122
+
123
+ let len = arg.length;
124
+ let ptr = malloc(len, 1) >>> 0;
125
+
126
+ const mem = getUint8ArrayMemory0();
127
+
128
+ let offset = 0;
129
+
130
+ for (; offset < len; offset++) {
131
+ const code = arg.charCodeAt(offset);
132
+ if (code > 0x7F) break;
133
+ mem[ptr + offset] = code;
134
+ }
135
+
136
+ if (offset !== len) {
137
+ if (offset !== 0) {
138
+ arg = arg.slice(offset);
139
+ }
140
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
141
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
142
+ const ret = cachedTextEncoder.encodeInto(arg, view);
143
+
144
+ offset += ret.written;
145
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
146
+ }
147
+
148
+ WASM_VECTOR_LEN = offset;
149
+ return ptr;
150
+ }
151
+
152
+ let cachedDataViewMemory0 = null;
153
+
154
+ function getDataViewMemory0() {
155
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
156
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
157
+ }
158
+ return cachedDataViewMemory0;
159
+ }
160
+
161
+ function isLikeNone(x) {
162
+ return x === undefined || x === null;
163
+ }
164
+
165
+ function addToExternrefTable0(obj) {
166
+ const idx = wasm.__externref_table_alloc();
167
+ wasm.__wbindgen_externrefs.set(idx, obj);
168
+ return idx;
169
+ }
170
+
171
+ function handleError(f, args) {
172
+ try {
173
+ return f.apply(this, args);
174
+ } catch (e) {
175
+ const idx = addToExternrefTable0(e);
176
+ wasm.__wbindgen_exn_store(idx);
177
+ }
178
+ }
179
+
180
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
181
+ ? { register: () => {}, unregister: () => {} }
182
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
183
+
184
+ function makeMutClosure(arg0, arg1, dtor, f) {
185
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
186
+ const real = (...args) => {
187
+
188
+ // First up with a closure we increment the internal reference
189
+ // count. This ensures that the Rust closure environment won't
190
+ // be deallocated while we're invoking it.
191
+ state.cnt++;
192
+ const a = state.a;
193
+ state.a = 0;
194
+ try {
195
+ return f(a, state.b, ...args);
196
+ } finally {
197
+ state.a = a;
198
+ real._wbg_cb_unref();
199
+ }
200
+ };
201
+ real._wbg_cb_unref = () => {
202
+ if (--state.cnt === 0) {
203
+ state.dtor(state.a, state.b);
204
+ state.a = 0;
205
+ CLOSURE_DTORS.unregister(state);
206
+ }
207
+ };
208
+ CLOSURE_DTORS.register(real, state, state);
209
+ return real;
210
+ }
211
+ /**
212
+ * Runs a REPL interpreter.
213
+ * @param {number} heap_size
214
+ * @returns {Promise<void>}
215
+ */
216
+ export function repl(heap_size) {
217
+ const ret = wasm.repl(heap_size);
218
+ return ret;
219
+ }
220
+
221
+ function wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2) {
222
+ wasm.wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2);
223
+ }
224
+
225
+ function wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2, arg3) {
226
+ wasm.wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2, arg3);
227
+ }
228
+
229
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
230
+
231
+ async function __wbg_load(module, imports) {
232
+ if (typeof Response === 'function' && module instanceof Response) {
233
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
234
+ try {
235
+ return await WebAssembly.instantiateStreaming(module, imports);
236
+
237
+ } catch (e) {
238
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
239
+
240
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
241
+ 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);
242
+
243
+ } else {
244
+ throw e;
245
+ }
246
+ }
247
+ }
248
+
249
+ const bytes = await module.arrayBuffer();
250
+ return await WebAssembly.instantiate(bytes, imports);
251
+
252
+ } else {
253
+ const instance = await WebAssembly.instantiate(module, imports);
254
+
255
+ if (instance instanceof WebAssembly.Instance) {
256
+ return { instance, module };
257
+
258
+ } else {
259
+ return instance;
260
+ }
261
+ }
262
+ }
263
+
264
+ function __wbg_get_imports() {
265
+ const imports = {};
266
+ imports.wbg = {};
267
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
268
+ const ret = Error(getStringFromWasm0(arg0, arg1));
269
+ return ret;
270
+ };
271
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
272
+ const ret = debugString(arg1);
273
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len1 = WASM_VECTOR_LEN;
275
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
276
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
277
+ };
278
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
279
+ const ret = typeof(arg0) === 'function';
280
+ return ret;
281
+ };
282
+ imports.wbg.__wbg___wbindgen_is_null_5e69f72e906cc57c = function(arg0) {
283
+ const ret = arg0 === null;
284
+ return ret;
285
+ };
286
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
287
+ const ret = arg0 === undefined;
288
+ return ret;
289
+ };
290
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
291
+ const obj = arg1;
292
+ const ret = typeof(obj) === 'number' ? obj : undefined;
293
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
294
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
295
+ };
296
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
297
+ throw new Error(getStringFromWasm0(arg0, arg1));
298
+ };
299
+ imports.wbg.__wbg__wbg_cb_unref_2454a539ea5790d9 = function(arg0) {
300
+ arg0._wbg_cb_unref();
301
+ };
302
+ imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
303
+ const ret = arg0.call(arg1, arg2);
304
+ return ret;
305
+ }, arguments) };
306
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
307
+ const ret = arg0.call(arg1);
308
+ return ret;
309
+ }, arguments) };
310
+ imports.wbg.__wbg_new_3c3d849046688a66 = function(arg0, arg1) {
311
+ try {
312
+ var state0 = {a: arg0, b: arg1};
313
+ var cb0 = (arg0, arg1) => {
314
+ const a = state0.a;
315
+ state0.a = 0;
316
+ try {
317
+ return wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(a, state0.b, arg0, arg1);
318
+ } finally {
319
+ state0.a = a;
320
+ }
321
+ };
322
+ const ret = new Promise(cb0);
323
+ return ret;
324
+ } finally {
325
+ state0.a = state0.b = 0;
326
+ }
327
+ };
328
+ imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
329
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
330
+ return ret;
331
+ };
332
+ imports.wbg.__wbg_queueMicrotask_34d692c25c47d05b = function(arg0) {
333
+ const ret = arg0.queueMicrotask;
334
+ return ret;
335
+ };
336
+ imports.wbg.__wbg_queueMicrotask_9d76cacb20c84d58 = function(arg0) {
337
+ queueMicrotask(arg0);
338
+ };
339
+ imports.wbg.__wbg_read_stdin_77080b6e84e0757b = function() {
340
+ const ret = read_stdin();
341
+ return ret;
342
+ };
343
+ imports.wbg.__wbg_resolve_caf97c30b83f7053 = function(arg0) {
344
+ const ret = Promise.resolve(arg0);
345
+ return ret;
346
+ };
347
+ imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
348
+ const ret = typeof global === 'undefined' ? null : global;
349
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
350
+ };
351
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
352
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
353
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
354
+ };
355
+ imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
356
+ const ret = typeof self === 'undefined' ? null : self;
357
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
358
+ };
359
+ imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
360
+ const ret = typeof window === 'undefined' ? null : window;
361
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
362
+ };
363
+ imports.wbg.__wbg_then_4f46f6544e6b4a28 = function(arg0, arg1) {
364
+ const ret = arg0.then(arg1);
365
+ return ret;
366
+ };
367
+ imports.wbg.__wbg_then_70d05cf780a18d77 = function(arg0, arg1, arg2) {
368
+ const ret = arg0.then(arg1, arg2);
369
+ return ret;
370
+ };
371
+ imports.wbg.__wbg_write_stderr_f819f461d9858a57 = function(arg0) {
372
+ const ret = write_stderr(arg0);
373
+ return ret;
374
+ };
375
+ imports.wbg.__wbg_write_stdout_0d33dd5f146c1bb9 = function(arg0) {
376
+ const ret = write_stdout(arg0);
377
+ return ret;
378
+ };
379
+ imports.wbg.__wbindgen_cast_80e5451c6d1fd870 = function(arg0, arg1) {
380
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 17, function: Function { arguments: [Externref], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
381
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_a10390bb34bad561___closure__destroy___dyn_core_6a51abefd5362b2___ops__function__FnMut__wasm_bindgen_a10390bb34bad561___JsValue____Output_______, wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____);
382
+ return ret;
383
+ };
384
+ imports.wbg.__wbindgen_init_externref_table = function() {
385
+ const table = wasm.__wbindgen_externrefs;
386
+ const offset = table.grow(4);
387
+ table.set(0, undefined);
388
+ table.set(offset + 0, undefined);
389
+ table.set(offset + 1, null);
390
+ table.set(offset + 2, true);
391
+ table.set(offset + 3, false);
392
+ ;
393
+ };
394
+
395
+ return imports;
396
+ }
397
+
398
+ function __wbg_finalize_init(instance, module) {
399
+ wasm = instance.exports;
400
+ __wbg_init.__wbindgen_wasm_module = module;
401
+ cachedDataViewMemory0 = null;
402
+ cachedUint8ArrayMemory0 = null;
403
+
404
+
405
+ wasm.__wbindgen_start();
406
+ return wasm;
407
+ }
408
+
409
+ function initSync(module) {
410
+ if (wasm !== undefined) return wasm;
411
+
412
+
413
+ if (typeof module !== 'undefined') {
414
+ if (Object.getPrototypeOf(module) === Object.prototype) {
415
+ ({module} = module)
416
+ } else {
417
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
418
+ }
419
+ }
420
+
421
+ const imports = __wbg_get_imports();
422
+
423
+ if (!(module instanceof WebAssembly.Module)) {
424
+ module = new WebAssembly.Module(module);
425
+ }
426
+
427
+ const instance = new WebAssembly.Instance(module, imports);
428
+
429
+ return __wbg_finalize_init(instance, module);
430
+ }
431
+
432
+ async function __wbg_init(module_or_path) {
433
+ if (wasm !== undefined) return wasm;
434
+
435
+
436
+ if (typeof module_or_path !== 'undefined') {
437
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
438
+ ({module_or_path} = module_or_path)
439
+ } else {
440
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
441
+ }
442
+ }
443
+
444
+ if (typeof module_or_path === 'undefined') {
445
+ module_or_path = new URL('repl_bg.wasm', import.meta.url);
446
+ }
447
+ const imports = __wbg_get_imports();
448
+
449
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
450
+ module_or_path = fetch(module_or_path);
451
+ }
452
+
453
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
454
+
455
+ return __wbg_finalize_init(instance, module);
456
+ }
457
+
458
+ export { initSync };
459
+ export default __wbg_init;
package/repl_bg.wasm ADDED
Binary file
package/run.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Runs a Scheme script with standard input and returns its standard output.
5
+ */
6
+ export function run(source: string, input: Uint8Array, heap_size: number): Uint8Array;
7
+
8
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
9
+
10
+ export interface InitOutput {
11
+ readonly memory: WebAssembly.Memory;
12
+ readonly run: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
13
+ readonly __wbindgen_externrefs: WebAssembly.Table;
14
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
15
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
16
+ readonly __externref_table_dealloc: (a: number) => void;
17
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
18
+ readonly __wbindgen_start: () => void;
19
+ }
20
+
21
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
22
+ /**
23
+ * Instantiates the given `module`, which can either be bytes or
24
+ * a precompiled `WebAssembly.Module`.
25
+ *
26
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
27
+ *
28
+ * @returns {InitOutput}
29
+ */
30
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
31
+
32
+ /**
33
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
34
+ * for everything else, calls `WebAssembly.instantiate` directly.
35
+ *
36
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
37
+ *
38
+ * @returns {Promise<InitOutput>}
39
+ */
40
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;