@raviqqe/stak 0.2.22 → 0.2.24

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@raviqqe/stak",
3
3
  "type": "module",
4
4
  "description": "Stak Scheme VM in WebAssembly",
5
- "version": "0.2.22",
5
+ "version": "0.2.24",
6
6
  "license": "SEE LICENSE IN ../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",
package/stak_wasm.d.ts CHANGED
@@ -39,18 +39,18 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
39
39
  * Instantiates the given `module`, which can either be bytes or
40
40
  * a precompiled `WebAssembly.Module`.
41
41
  *
42
- * @param {SyncInitInput} module
42
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
43
43
  *
44
44
  * @returns {InitOutput}
45
45
  */
46
- export function initSync(module: SyncInitInput): InitOutput;
46
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
47
47
 
48
48
  /**
49
49
  * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
50
50
  * for everything else, calls `WebAssembly.instantiate` directly.
51
51
  *
52
- * @param {InitInput | Promise<InitInput>} module_or_path
52
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
53
53
  *
54
54
  * @returns {Promise<InitOutput>}
55
55
  */
56
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
56
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/stak_wasm.js CHANGED
@@ -4,18 +4,18 @@ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder(
4
4
 
5
5
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
6
6
 
7
- let cachedUint8Memory0 = null;
7
+ let cachedUint8ArrayMemory0 = null;
8
8
 
9
- function getUint8Memory0() {
10
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
11
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
12
  }
13
- return cachedUint8Memory0;
13
+ return cachedUint8ArrayMemory0;
14
14
  }
15
15
 
16
16
  function getStringFromWasm0(ptr, len) {
17
17
  ptr = ptr >>> 0;
18
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
18
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
19
19
  }
20
20
 
21
21
  const heap = new Array(128).fill(undefined);
@@ -55,7 +55,7 @@ function passStringToWasm0(arg, malloc, realloc) {
55
55
  if (realloc === undefined) {
56
56
  const buf = cachedTextEncoder.encode(arg);
57
57
  const ptr = malloc(buf.length, 1) >>> 0;
58
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
58
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
59
59
  WASM_VECTOR_LEN = buf.length;
60
60
  return ptr;
61
61
  }
@@ -63,7 +63,7 @@ function passStringToWasm0(arg, malloc, realloc) {
63
63
  let len = arg.length;
64
64
  let ptr = malloc(len, 1) >>> 0;
65
65
 
66
- const mem = getUint8Memory0();
66
+ const mem = getUint8ArrayMemory0();
67
67
 
68
68
  let offset = 0;
69
69
 
@@ -78,7 +78,7 @@ function passStringToWasm0(arg, malloc, realloc) {
78
78
  arg = arg.slice(offset);
79
79
  }
80
80
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
81
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
81
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
82
82
  const ret = encodeString(arg, view);
83
83
 
84
84
  offset += ret.written;
@@ -89,13 +89,13 @@ function passStringToWasm0(arg, malloc, realloc) {
89
89
  return ptr;
90
90
  }
91
91
 
92
- let cachedInt32Memory0 = null;
92
+ let cachedDataViewMemory0 = null;
93
93
 
94
- function getInt32Memory0() {
95
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
96
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
94
+ function getDataViewMemory0() {
95
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
96
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
97
97
  }
98
- return cachedInt32Memory0;
98
+ return cachedDataViewMemory0;
99
99
  }
100
100
 
101
101
  function getObject(idx) { return heap[idx]; }
@@ -114,7 +114,7 @@ function takeObject(idx) {
114
114
 
115
115
  function getArrayU8FromWasm0(ptr, len) {
116
116
  ptr = ptr >>> 0;
117
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
117
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
118
118
  }
119
119
  /**
120
120
  * Compiles a source code.
@@ -127,10 +127,10 @@ export function compile(source) {
127
127
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
128
  const len0 = WASM_VECTOR_LEN;
129
129
  wasm.compile(retptr, ptr0, len0);
130
- var r0 = getInt32Memory0()[retptr / 4 + 0];
131
- var r1 = getInt32Memory0()[retptr / 4 + 1];
132
- var r2 = getInt32Memory0()[retptr / 4 + 2];
133
- var r3 = getInt32Memory0()[retptr / 4 + 3];
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
134
  if (r3) {
135
135
  throw takeObject(r2);
136
136
  }
@@ -144,7 +144,7 @@ export function compile(source) {
144
144
 
145
145
  function passArray8ToWasm0(arg, malloc) {
146
146
  const ptr = malloc(arg.length * 1, 1) >>> 0;
147
- getUint8Memory0().set(arg, ptr / 1);
147
+ getUint8ArrayMemory0().set(arg, ptr / 1);
148
148
  WASM_VECTOR_LEN = arg.length;
149
149
  return ptr;
150
150
  }
@@ -163,10 +163,10 @@ export function interpret(bytecodes, input, heap_size) {
163
163
  const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
164
164
  const len1 = WASM_VECTOR_LEN;
165
165
  wasm.interpret(retptr, ptr0, len0, ptr1, len1, heap_size);
166
- var r0 = getInt32Memory0()[retptr / 4 + 0];
167
- var r1 = getInt32Memory0()[retptr / 4 + 1];
168
- var r2 = getInt32Memory0()[retptr / 4 + 2];
169
- var r3 = getInt32Memory0()[retptr / 4 + 3];
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
170
  if (r3) {
171
171
  throw takeObject(r2);
172
172
  }
@@ -191,10 +191,10 @@ export function decode(bytecodes) {
191
191
  const ptr0 = passArray8ToWasm0(bytecodes, wasm.__wbindgen_malloc);
192
192
  const len0 = WASM_VECTOR_LEN;
193
193
  wasm.decode(retptr, ptr0, len0);
194
- var r0 = getInt32Memory0()[retptr / 4 + 0];
195
- var r1 = getInt32Memory0()[retptr / 4 + 1];
196
- var r2 = getInt32Memory0()[retptr / 4 + 2];
197
- var r3 = getInt32Memory0()[retptr / 4 + 3];
194
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
195
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
196
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
197
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
198
198
  var ptr2 = r0;
199
199
  var len2 = r1;
200
200
  if (r3) {
@@ -252,15 +252,16 @@ function __wbg_get_imports() {
252
252
  return imports;
253
253
  }
254
254
 
255
- function __wbg_init_memory(imports, maybe_memory) {
255
+ function __wbg_init_memory(imports, memory) {
256
256
 
257
257
  }
258
258
 
259
259
  function __wbg_finalize_init(instance, module) {
260
260
  wasm = instance.exports;
261
261
  __wbg_init.__wbindgen_wasm_module = module;
262
- cachedInt32Memory0 = null;
263
- cachedUint8Memory0 = null;
262
+ cachedDataViewMemory0 = null;
263
+ cachedUint8ArrayMemory0 = null;
264
+
264
265
 
265
266
 
266
267
  return wasm;
@@ -269,6 +270,12 @@ function __wbg_finalize_init(instance, module) {
269
270
  function initSync(module) {
270
271
  if (wasm !== undefined) return wasm;
271
272
 
273
+
274
+ if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
275
+ ({module} = module)
276
+ else
277
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
278
+
272
279
  const imports = __wbg_get_imports();
273
280
 
274
281
  __wbg_init_memory(imports);
@@ -282,24 +289,30 @@ function initSync(module) {
282
289
  return __wbg_finalize_init(instance, module);
283
290
  }
284
291
 
285
- async function __wbg_init(input) {
292
+ async function __wbg_init(module_or_path) {
286
293
  if (wasm !== undefined) return wasm;
287
294
 
288
- if (typeof input === 'undefined') {
289
- input = new URL('stak_wasm_bg.wasm', import.meta.url);
295
+
296
+ if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
297
+ ({module_or_path} = module_or_path)
298
+ else
299
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
300
+
301
+ if (typeof module_or_path === 'undefined') {
302
+ module_or_path = new URL('stak_wasm_bg.wasm', import.meta.url);
290
303
  }
291
304
  const imports = __wbg_get_imports();
292
305
 
293
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
294
- input = fetch(input);
306
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
307
+ module_or_path = fetch(module_or_path);
295
308
  }
296
309
 
297
310
  __wbg_init_memory(imports);
298
311
 
299
- const { instance, module } = await __wbg_load(await input, imports);
312
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
300
313
 
301
314
  return __wbg_finalize_init(instance, module);
302
315
  }
303
316
 
304
- export { initSync }
317
+ export { initSync };
305
318
  export default __wbg_init;
package/stak_wasm_bg.wasm CHANGED
Binary file