@lightvm/core-browser-wasm 0.1.0-alpha.7 → 0.1.0-alpha.8-nightly.20260626.2f8bade

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/README.md CHANGED
@@ -206,7 +206,7 @@ LightVM uses a strict capability-based security model. You must explicitly grant
206
206
  </details>
207
207
 
208
208
  > [!NOTE]
209
- > __Capability Required__: no spesific capability
209
+ > __Capability Required__: no specific capability
210
210
 
211
211
  3. ``inspect()`` method:
212
212
  Function to view state, number of instructions, and capability.
@@ -282,7 +282,7 @@ LightVM uses a strict capability-based security model. You must explicitly grant
282
282
  </details>
283
283
 
284
284
  > [!NOTE]
285
- > __Capability Required__: no spesific capability
285
+ > __Capability Required__: no specific capability
286
286
  > __Event__: tick, halt, and panic
287
287
 
288
288
  6. ``export()`` method:
@@ -303,8 +303,8 @@ LightVM uses a strict capability-based security model. You must explicitly grant
303
303
  ```rust
304
304
  let mut add = vm.export("add".to_string());
305
305
  let args = vec![serde_json::json!(5), serde_json::json!(6)];
306
- if let Some(hasil) = add_func(args) {
307
- println!("Hasil dari VM: {}", hasil);
306
+ if let Some(result) = add_func(args) {
307
+ println!("Result from VM: {}", result);
308
308
  }
309
309
  ```
310
310
  </details>
@@ -407,7 +407,7 @@ LightVM uses a strict capability-based security model. You must explicitly grant
407
407
  </ol>
408
408
 
409
409
  > [!NOTE]
410
- > __Capability Required__: no spesific capability
410
+ > __Capability Required__: no specific capability
411
411
 
412
412
  ## References
413
413
  ### Supported Primitive Types
package/index.js ADDED
@@ -0,0 +1,870 @@
1
+ /* @ts-self-types="./lightvm.d.ts" */
2
+
3
+ export class LightVM {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ LightVMFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_lightvm_free(ptr, 0);
13
+ }
14
+ /**
15
+ * @param {string} name
16
+ * @param {any} args
17
+ * @returns {any}
18
+ */
19
+ callExport(name, args) {
20
+ try {
21
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
22
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ wasm.lightvm_callExport(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(args));
25
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
26
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
27
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
28
+ if (r2) {
29
+ throw takeObject(r1);
30
+ }
31
+ return takeObject(r0);
32
+ } finally {
33
+ wasm.__wbindgen_add_to_stack_pointer(16);
34
+ }
35
+ }
36
+ /**
37
+ * @returns {any}
38
+ */
39
+ embedded() {
40
+ try {
41
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
42
+ wasm.lightvm_embedded(retptr, this.__wbg_ptr);
43
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
44
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
45
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
46
+ if (r2) {
47
+ throw takeObject(r1);
48
+ }
49
+ return takeObject(r0);
50
+ } finally {
51
+ wasm.__wbindgen_add_to_stack_pointer(16);
52
+ }
53
+ }
54
+ halt() {
55
+ try {
56
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
57
+ wasm.lightvm_halt(retptr, this.__wbg_ptr);
58
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
59
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
60
+ if (r1) {
61
+ throw takeObject(r0);
62
+ }
63
+ } finally {
64
+ wasm.__wbindgen_add_to_stack_pointer(16);
65
+ }
66
+ }
67
+ /**
68
+ * @returns {any}
69
+ */
70
+ inspect() {
71
+ try {
72
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
73
+ wasm.lightvm_inspect(retptr, this.__wbg_ptr);
74
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
75
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
76
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
77
+ if (r2) {
78
+ throw takeObject(r1);
79
+ }
80
+ return takeObject(r0);
81
+ } finally {
82
+ wasm.__wbindgen_add_to_stack_pointer(16);
83
+ }
84
+ }
85
+ /**
86
+ * @param {string} source
87
+ */
88
+ load(source) {
89
+ try {
90
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
91
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
92
+ const len0 = WASM_VECTOR_LEN;
93
+ wasm.lightvm_load(retptr, this.__wbg_ptr, ptr0, len0);
94
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
95
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
96
+ if (r1) {
97
+ throw takeObject(r0);
98
+ }
99
+ } finally {
100
+ wasm.__wbindgen_add_to_stack_pointer(16);
101
+ }
102
+ }
103
+ /**
104
+ * @param {any} config
105
+ */
106
+ constructor(config) {
107
+ try {
108
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
109
+ wasm.lightvm_new(retptr, addHeapObject(config));
110
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
111
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
112
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
113
+ if (r2) {
114
+ throw takeObject(r1);
115
+ }
116
+ this.__wbg_ptr = r0;
117
+ LightVMFinalization.register(this, this.__wbg_ptr, this);
118
+ return this;
119
+ } finally {
120
+ wasm.__wbindgen_add_to_stack_pointer(16);
121
+ }
122
+ }
123
+ /**
124
+ * @param {string} event_type
125
+ * @param {Function} callback
126
+ */
127
+ on(event_type, callback) {
128
+ try {
129
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
130
+ const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ wasm.lightvm_on(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(callback));
133
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
134
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
135
+ if (r1) {
136
+ throw takeObject(r0);
137
+ }
138
+ } finally {
139
+ wasm.__wbindgen_add_to_stack_pointer(16);
140
+ }
141
+ }
142
+ /**
143
+ * @param {string} name
144
+ * @param {any} value
145
+ */
146
+ provide(name, value) {
147
+ try {
148
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
149
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
150
+ const len0 = WASM_VECTOR_LEN;
151
+ wasm.lightvm_provide(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
152
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
153
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
154
+ if (r1) {
155
+ throw takeObject(r0);
156
+ }
157
+ } finally {
158
+ wasm.__wbindgen_add_to_stack_pointer(16);
159
+ }
160
+ }
161
+ run() {
162
+ try {
163
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
164
+ wasm.lightvm_run(retptr, this.__wbg_ptr);
165
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
166
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
167
+ if (r1) {
168
+ throw takeObject(r0);
169
+ }
170
+ } finally {
171
+ wasm.__wbindgen_add_to_stack_pointer(16);
172
+ }
173
+ }
174
+ /**
175
+ * @returns {LightVMTools}
176
+ */
177
+ tools() {
178
+ const ret = wasm.lightvm_tools(this.__wbg_ptr);
179
+ return LightVMTools.__wrap(ret);
180
+ }
181
+ }
182
+ if (Symbol.dispose) LightVM.prototype[Symbol.dispose] = LightVM.prototype.free;
183
+
184
+ export class LightVMTools {
185
+ static __wrap(ptr) {
186
+ const obj = Object.create(LightVMTools.prototype);
187
+ obj.__wbg_ptr = ptr;
188
+ LightVMToolsFinalization.register(obj, obj.__wbg_ptr, obj);
189
+ return obj;
190
+ }
191
+ __destroy_into_raw() {
192
+ const ptr = this.__wbg_ptr;
193
+ this.__wbg_ptr = 0;
194
+ LightVMToolsFinalization.unregister(this);
195
+ return ptr;
196
+ }
197
+ free() {
198
+ const ptr = this.__destroy_into_raw();
199
+ wasm.__wbg_lightvmtools_free(ptr, 0);
200
+ }
201
+ /**
202
+ * @returns {boolean}
203
+ */
204
+ get explain() {
205
+ const ret = wasm.__wbg_get_lightvmtools_explain(this.__wbg_ptr);
206
+ return ret !== 0;
207
+ }
208
+ /**
209
+ * @returns {boolean}
210
+ */
211
+ get hint() {
212
+ const ret = wasm.__wbg_get_lightvmtools_hint(this.__wbg_ptr);
213
+ return ret !== 0;
214
+ }
215
+ /**
216
+ * @returns {boolean}
217
+ */
218
+ get nightly() {
219
+ const ret = wasm.__wbg_get_lightvmtools_nightly(this.__wbg_ptr);
220
+ return ret !== 0;
221
+ }
222
+ /**
223
+ * @param {any} bytecode
224
+ * @returns {any}
225
+ */
226
+ optimizeBytecode(bytecode) {
227
+ try {
228
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
229
+ wasm.lightvmtools_optimizeBytecode(retptr, this.__wbg_ptr, addHeapObject(bytecode));
230
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
231
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
232
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
233
+ if (r2) {
234
+ throw takeObject(r1);
235
+ }
236
+ return takeObject(r0);
237
+ } finally {
238
+ wasm.__wbindgen_add_to_stack_pointer(16);
239
+ }
240
+ }
241
+ /**
242
+ * @param {string} code
243
+ * @returns {string}
244
+ */
245
+ parseLtc(code) {
246
+ let deferred3_0;
247
+ let deferred3_1;
248
+ try {
249
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
250
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
251
+ const len0 = WASM_VECTOR_LEN;
252
+ wasm.lightvmtools_parseLtc(retptr, this.__wbg_ptr, ptr0, len0);
253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
256
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
257
+ var ptr2 = r0;
258
+ var len2 = r1;
259
+ if (r3) {
260
+ ptr2 = 0; len2 = 0;
261
+ throw takeObject(r2);
262
+ }
263
+ deferred3_0 = ptr2;
264
+ deferred3_1 = len2;
265
+ return getStringFromWasm0(ptr2, len2);
266
+ } finally {
267
+ wasm.__wbindgen_add_to_stack_pointer(16);
268
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
269
+ }
270
+ }
271
+ /**
272
+ * @param {string} code
273
+ * @returns {any}
274
+ */
275
+ parseLtcArray(code) {
276
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
277
+ const len0 = WASM_VECTOR_LEN;
278
+ const ret = wasm.lightvmtools_parseLtcArray(this.__wbg_ptr, ptr0, len0);
279
+ return takeObject(ret);
280
+ }
281
+ /**
282
+ * @param {any} json
283
+ * @returns {string}
284
+ */
285
+ stringifyLtc(json) {
286
+ let deferred2_0;
287
+ let deferred2_1;
288
+ try {
289
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
290
+ wasm.lightvmtools_stringifyLtc(retptr, this.__wbg_ptr, addHeapObject(json));
291
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
292
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
293
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
294
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
295
+ var ptr1 = r0;
296
+ var len1 = r1;
297
+ if (r3) {
298
+ ptr1 = 0; len1 = 0;
299
+ throw takeObject(r2);
300
+ }
301
+ deferred2_0 = ptr1;
302
+ deferred2_1 = len1;
303
+ return getStringFromWasm0(ptr1, len1);
304
+ } finally {
305
+ wasm.__wbindgen_add_to_stack_pointer(16);
306
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
307
+ }
308
+ }
309
+ /**
310
+ * @param {boolean} arg0
311
+ */
312
+ set explain(arg0) {
313
+ wasm.__wbg_set_lightvmtools_explain(this.__wbg_ptr, arg0);
314
+ }
315
+ /**
316
+ * @param {boolean} arg0
317
+ */
318
+ set hint(arg0) {
319
+ wasm.__wbg_set_lightvmtools_hint(this.__wbg_ptr, arg0);
320
+ }
321
+ /**
322
+ * @param {boolean} arg0
323
+ */
324
+ set nightly(arg0) {
325
+ wasm.__wbg_set_lightvmtools_nightly(this.__wbg_ptr, arg0);
326
+ }
327
+ }
328
+ if (Symbol.dispose) LightVMTools.prototype[Symbol.dispose] = LightVMTools.prototype.free;
329
+ function __wbg_get_imports() {
330
+ const import0 = {
331
+ __proto__: null,
332
+ __wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
333
+ const ret = Error(getStringFromWasm0(arg0, arg1));
334
+ return addHeapObject(ret);
335
+ },
336
+ __wbg_Number_4779d427bae39753: function(arg0) {
337
+ const ret = Number(getObject(arg0));
338
+ return ret;
339
+ },
340
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
341
+ const ret = String(getObject(arg1));
342
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
343
+ const len1 = WASM_VECTOR_LEN;
344
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
345
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
346
+ },
347
+ __wbg___wbindgen_bigint_get_as_i64_8ea6736501f396b6: function(arg0, arg1) {
348
+ const v = getObject(arg1);
349
+ const ret = typeof(v) === 'bigint' ? v : undefined;
350
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
351
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
352
+ },
353
+ __wbg___wbindgen_boolean_get_b131b2f36d6b2f55: function(arg0) {
354
+ const v = getObject(arg0);
355
+ const ret = typeof(v) === 'boolean' ? v : undefined;
356
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
357
+ },
358
+ __wbg___wbindgen_debug_string_56c147eb1a51f0c4: function(arg0, arg1) {
359
+ const ret = debugString(getObject(arg1));
360
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
361
+ const len1 = WASM_VECTOR_LEN;
362
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
363
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
364
+ },
365
+ __wbg___wbindgen_in_ce8569b2fc6f5088: function(arg0, arg1) {
366
+ const ret = getObject(arg0) in getObject(arg1);
367
+ return ret;
368
+ },
369
+ __wbg___wbindgen_is_bigint_df272c65456269c2: function(arg0) {
370
+ const ret = typeof(getObject(arg0)) === 'bigint';
371
+ return ret;
372
+ },
373
+ __wbg___wbindgen_is_function_147961669f068cd4: function(arg0) {
374
+ const ret = typeof(getObject(arg0)) === 'function';
375
+ return ret;
376
+ },
377
+ __wbg___wbindgen_is_object_3a2c414391dbf751: function(arg0) {
378
+ const val = getObject(arg0);
379
+ const ret = typeof(val) === 'object' && val !== null;
380
+ return ret;
381
+ },
382
+ __wbg___wbindgen_is_string_6541b0f6ecd4e8e5: function(arg0) {
383
+ const ret = typeof(getObject(arg0)) === 'string';
384
+ return ret;
385
+ },
386
+ __wbg___wbindgen_is_undefined_4410e3c20a99fa97: function(arg0) {
387
+ const ret = getObject(arg0) === undefined;
388
+ return ret;
389
+ },
390
+ __wbg___wbindgen_jsval_eq_174c93ec61bab0c5: function(arg0, arg1) {
391
+ const ret = getObject(arg0) === getObject(arg1);
392
+ return ret;
393
+ },
394
+ __wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c: function(arg0, arg1) {
395
+ const ret = getObject(arg0) == getObject(arg1);
396
+ return ret;
397
+ },
398
+ __wbg___wbindgen_number_get_588ed6b97f0d7e14: function(arg0, arg1) {
399
+ const obj = getObject(arg1);
400
+ const ret = typeof(obj) === 'number' ? obj : undefined;
401
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
402
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
403
+ },
404
+ __wbg___wbindgen_string_get_fa2687d531ed17a5: function(arg0, arg1) {
405
+ const obj = getObject(arg1);
406
+ const ret = typeof(obj) === 'string' ? obj : undefined;
407
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
408
+ var len1 = WASM_VECTOR_LEN;
409
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
410
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
411
+ },
412
+ __wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
413
+ throw new Error(getStringFromWasm0(arg0, arg1));
414
+ },
415
+ __wbg_call_91f00ddc43e01490: function() { return handleError(function (arg0, arg1) {
416
+ const ret = getObject(arg0).call(getObject(arg1));
417
+ return addHeapObject(ret);
418
+ }, arguments); },
419
+ __wbg_call_ec09a4cf93377d3a: function() { return handleError(function (arg0, arg1, arg2) {
420
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
421
+ return addHeapObject(ret);
422
+ }, arguments); },
423
+ __wbg_done_6a8439e544ec6206: function(arg0) {
424
+ const ret = getObject(arg0).done;
425
+ return ret;
426
+ },
427
+ __wbg_entries_5a6a7e7e0df09fe5: function(arg0) {
428
+ const ret = Object.entries(getObject(arg0));
429
+ return addHeapObject(ret);
430
+ },
431
+ __wbg_get_44e98e27bda25b5b: function() { return handleError(function (arg0, arg1) {
432
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
433
+ return addHeapObject(ret);
434
+ }, arguments); },
435
+ __wbg_get_4b90d6d8c5deb5d5: function(arg0, arg1) {
436
+ const ret = getObject(arg0)[arg1 >>> 0];
437
+ return addHeapObject(ret);
438
+ },
439
+ __wbg_get_unchecked_46e778e3cec74b5e: function(arg0, arg1) {
440
+ const ret = getObject(arg0)[arg1 >>> 0];
441
+ return addHeapObject(ret);
442
+ },
443
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
444
+ const ret = getObject(arg0)[getObject(arg1)];
445
+ return addHeapObject(ret);
446
+ },
447
+ __wbg_instanceof_ArrayBuffer_a581da923203f29f: function(arg0) {
448
+ let result;
449
+ try {
450
+ result = getObject(arg0) instanceof ArrayBuffer;
451
+ } catch (_) {
452
+ result = false;
453
+ }
454
+ const ret = result;
455
+ return ret;
456
+ },
457
+ __wbg_instanceof_Map_7f94c740225003e2: function(arg0) {
458
+ let result;
459
+ try {
460
+ result = getObject(arg0) instanceof Map;
461
+ } catch (_) {
462
+ result = false;
463
+ }
464
+ const ret = result;
465
+ return ret;
466
+ },
467
+ __wbg_instanceof_Uint8Array_b6fe1ac89eba107e: function(arg0) {
468
+ let result;
469
+ try {
470
+ result = getObject(arg0) instanceof Uint8Array;
471
+ } catch (_) {
472
+ result = false;
473
+ }
474
+ const ret = result;
475
+ return ret;
476
+ },
477
+ __wbg_isArray_139f48e3c057ede8: function(arg0) {
478
+ const ret = Array.isArray(getObject(arg0));
479
+ return ret;
480
+ },
481
+ __wbg_isSafeInteger_c22ccb4af2201fe9: function(arg0) {
482
+ const ret = Number.isSafeInteger(getObject(arg0));
483
+ return ret;
484
+ },
485
+ __wbg_iterator_9b36cebf3be7b7cd: function() {
486
+ const ret = Symbol.iterator;
487
+ return addHeapObject(ret);
488
+ },
489
+ __wbg_length_68a9d5278d084f4f: function(arg0) {
490
+ const ret = getObject(arg0).length;
491
+ return ret;
492
+ },
493
+ __wbg_length_fb04d16d7bdf6d4c: function(arg0) {
494
+ const ret = getObject(arg0).length;
495
+ return ret;
496
+ },
497
+ __wbg_new_0b303268aa395a38: function() {
498
+ const ret = new Array();
499
+ return addHeapObject(ret);
500
+ },
501
+ __wbg_new_20b778a4c5c691c3: function() {
502
+ const ret = new Object();
503
+ return addHeapObject(ret);
504
+ },
505
+ __wbg_new_5fae30e6b23db8df: function(arg0, arg1) {
506
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
507
+ return addHeapObject(ret);
508
+ },
509
+ __wbg_new_883c0db065f06efd: function() {
510
+ const ret = new Map();
511
+ return addHeapObject(ret);
512
+ },
513
+ __wbg_new_b06772b280cc6e52: function(arg0) {
514
+ const ret = new Uint8Array(getObject(arg0));
515
+ return addHeapObject(ret);
516
+ },
517
+ __wbg_next_8cb028b6ba50743f: function() { return handleError(function (arg0) {
518
+ const ret = getObject(arg0).next();
519
+ return addHeapObject(ret);
520
+ }, arguments); },
521
+ __wbg_next_cfd0b146c9538df8: function(arg0) {
522
+ const ret = getObject(arg0).next;
523
+ return addHeapObject(ret);
524
+ },
525
+ __wbg_prototypesetcall_956c7493c68e29b4: function(arg0, arg1, arg2) {
526
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
527
+ },
528
+ __wbg_set_5f806304fb633ab3: function(arg0, arg1, arg2) {
529
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
530
+ return addHeapObject(ret);
531
+ },
532
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
533
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
534
+ },
535
+ __wbg_set_da33c120a6584674: function(arg0, arg1, arg2) {
536
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
537
+ },
538
+ __wbg_value_3d3defe09fb1ffca: function(arg0) {
539
+ const ret = getObject(arg0).value;
540
+ return addHeapObject(ret);
541
+ },
542
+ __wbindgen_cast_0000000000000001: function(arg0) {
543
+ // Cast intrinsic for `F64 -> Externref`.
544
+ const ret = arg0;
545
+ return addHeapObject(ret);
546
+ },
547
+ __wbindgen_cast_0000000000000002: function(arg0) {
548
+ // Cast intrinsic for `I64 -> Externref`.
549
+ const ret = arg0;
550
+ return addHeapObject(ret);
551
+ },
552
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
553
+ // Cast intrinsic for `Ref(String) -> Externref`.
554
+ const ret = getStringFromWasm0(arg0, arg1);
555
+ return addHeapObject(ret);
556
+ },
557
+ __wbindgen_cast_0000000000000004: function(arg0) {
558
+ // Cast intrinsic for `U64 -> Externref`.
559
+ const ret = BigInt.asUintN(64, arg0);
560
+ return addHeapObject(ret);
561
+ },
562
+ __wbindgen_object_clone_ref: function(arg0) {
563
+ const ret = getObject(arg0);
564
+ return addHeapObject(ret);
565
+ },
566
+ __wbindgen_object_drop_ref: function(arg0) {
567
+ takeObject(arg0);
568
+ },
569
+ };
570
+ return {
571
+ __proto__: null,
572
+ "./lightvm_bg.js": import0,
573
+ };
574
+ }
575
+
576
+ const LightVMFinalization = (typeof FinalizationRegistry === 'undefined')
577
+ ? { register: () => {}, unregister: () => {} }
578
+ : new FinalizationRegistry(ptr => wasm.__wbg_lightvm_free(ptr, 1));
579
+ const LightVMToolsFinalization = (typeof FinalizationRegistry === 'undefined')
580
+ ? { register: () => {}, unregister: () => {} }
581
+ : new FinalizationRegistry(ptr => wasm.__wbg_lightvmtools_free(ptr, 1));
582
+
583
+ function addHeapObject(obj) {
584
+ if (heap_next === heap.length) heap.push(heap.length + 1);
585
+ const idx = heap_next;
586
+ heap_next = heap[idx];
587
+
588
+ heap[idx] = obj;
589
+ return idx;
590
+ }
591
+
592
+ function debugString(val) {
593
+ // primitive types
594
+ const type = typeof val;
595
+ if (type == 'number' || type == 'boolean' || val == null) {
596
+ return `${val}`;
597
+ }
598
+ if (type == 'string') {
599
+ return `"${val}"`;
600
+ }
601
+ if (type == 'symbol') {
602
+ const description = val.description;
603
+ if (description == null) {
604
+ return 'Symbol';
605
+ } else {
606
+ return `Symbol(${description})`;
607
+ }
608
+ }
609
+ if (type == 'function') {
610
+ const name = val.name;
611
+ if (typeof name == 'string' && name.length > 0) {
612
+ return `Function(${name})`;
613
+ } else {
614
+ return 'Function';
615
+ }
616
+ }
617
+ // objects
618
+ if (Array.isArray(val)) {
619
+ const length = val.length;
620
+ let debug = '[';
621
+ if (length > 0) {
622
+ debug += debugString(val[0]);
623
+ }
624
+ for(let i = 1; i < length; i++) {
625
+ debug += ', ' + debugString(val[i]);
626
+ }
627
+ debug += ']';
628
+ return debug;
629
+ }
630
+ // Test for built-in
631
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
632
+ let className;
633
+ if (builtInMatches && builtInMatches.length > 1) {
634
+ className = builtInMatches[1];
635
+ } else {
636
+ // Failed to match the standard '[object ClassName]'
637
+ return toString.call(val);
638
+ }
639
+ if (className == 'Object') {
640
+ // we're a user defined class or Object
641
+ // JSON.stringify avoids problems with cycles, and is generally much
642
+ // easier than looping through ownProperties of `val`.
643
+ try {
644
+ return 'Object(' + JSON.stringify(val) + ')';
645
+ } catch (_) {
646
+ return 'Object';
647
+ }
648
+ }
649
+ // errors
650
+ if (val instanceof Error) {
651
+ return `${val.name}: ${val.message}\n${val.stack}`;
652
+ }
653
+ // TODO we could test for more things here, like `Set`s and `Map`s.
654
+ return className;
655
+ }
656
+
657
+ function dropObject(idx) {
658
+ if (idx < 1028) return;
659
+ heap[idx] = heap_next;
660
+ heap_next = idx;
661
+ }
662
+
663
+ function getArrayU8FromWasm0(ptr, len) {
664
+ ptr = ptr >>> 0;
665
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
666
+ }
667
+
668
+ let cachedDataViewMemory0 = null;
669
+ function getDataViewMemory0() {
670
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
671
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
672
+ }
673
+ return cachedDataViewMemory0;
674
+ }
675
+
676
+ function getStringFromWasm0(ptr, len) {
677
+ return decodeText(ptr >>> 0, len);
678
+ }
679
+
680
+ let cachedUint8ArrayMemory0 = null;
681
+ function getUint8ArrayMemory0() {
682
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
683
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
684
+ }
685
+ return cachedUint8ArrayMemory0;
686
+ }
687
+
688
+ function getObject(idx) { return heap[idx]; }
689
+
690
+ function handleError(f, args) {
691
+ try {
692
+ return f.apply(this, args);
693
+ } catch (e) {
694
+ wasm.__wbindgen_export3(addHeapObject(e));
695
+ }
696
+ }
697
+
698
+ let heap = new Array(1024).fill(undefined);
699
+ heap.push(undefined, null, true, false);
700
+
701
+ let heap_next = heap.length;
702
+
703
+ function isLikeNone(x) {
704
+ return x === undefined || x === null;
705
+ }
706
+
707
+ function passStringToWasm0(arg, malloc, realloc) {
708
+ if (realloc === undefined) {
709
+ const buf = cachedTextEncoder.encode(arg);
710
+ const ptr = malloc(buf.length, 1) >>> 0;
711
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
712
+ WASM_VECTOR_LEN = buf.length;
713
+ return ptr;
714
+ }
715
+
716
+ let len = arg.length;
717
+ let ptr = malloc(len, 1) >>> 0;
718
+
719
+ const mem = getUint8ArrayMemory0();
720
+
721
+ let offset = 0;
722
+
723
+ for (; offset < len; offset++) {
724
+ const code = arg.charCodeAt(offset);
725
+ if (code > 0x7F) break;
726
+ mem[ptr + offset] = code;
727
+ }
728
+ if (offset !== len) {
729
+ if (offset !== 0) {
730
+ arg = arg.slice(offset);
731
+ }
732
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
733
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
734
+ const ret = cachedTextEncoder.encodeInto(arg, view);
735
+
736
+ offset += ret.written;
737
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
738
+ }
739
+
740
+ WASM_VECTOR_LEN = offset;
741
+ return ptr;
742
+ }
743
+
744
+ function takeObject(idx) {
745
+ const ret = getObject(idx);
746
+ dropObject(idx);
747
+ return ret;
748
+ }
749
+
750
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
751
+ cachedTextDecoder.decode();
752
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
753
+ let numBytesDecoded = 0;
754
+ function decodeText(ptr, len) {
755
+ numBytesDecoded += len;
756
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
757
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
758
+ cachedTextDecoder.decode();
759
+ numBytesDecoded = len;
760
+ }
761
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
762
+ }
763
+
764
+ const cachedTextEncoder = new TextEncoder();
765
+
766
+ if (!('encodeInto' in cachedTextEncoder)) {
767
+ cachedTextEncoder.encodeInto = function (arg, view) {
768
+ const buf = cachedTextEncoder.encode(arg);
769
+ view.set(buf);
770
+ return {
771
+ read: arg.length,
772
+ written: buf.length
773
+ };
774
+ };
775
+ }
776
+
777
+ let WASM_VECTOR_LEN = 0;
778
+
779
+ let wasmModule, wasmInstance, wasm;
780
+ function __wbg_finalize_init(instance, module) {
781
+ wasmInstance = instance;
782
+ wasm = instance.exports;
783
+ wasmModule = module;
784
+ cachedDataViewMemory0 = null;
785
+ cachedUint8ArrayMemory0 = null;
786
+ return wasm;
787
+ }
788
+
789
+ async function __wbg_load(module, imports) {
790
+ if (typeof Response === 'function' && module instanceof Response) {
791
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
792
+ try {
793
+ return await WebAssembly.instantiateStreaming(module, imports);
794
+ } catch (e) {
795
+ const validResponse = module.ok && expectedResponseType(module.type);
796
+
797
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
798
+ 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);
799
+
800
+ } else { throw e; }
801
+ }
802
+ }
803
+
804
+ const bytes = await module.arrayBuffer();
805
+ return await WebAssembly.instantiate(bytes, imports);
806
+ } else {
807
+ const instance = await WebAssembly.instantiate(module, imports);
808
+
809
+ if (instance instanceof WebAssembly.Instance) {
810
+ return { instance, module };
811
+ } else {
812
+ return instance;
813
+ }
814
+ }
815
+
816
+ function expectedResponseType(type) {
817
+ switch (type) {
818
+ case 'basic': case 'cors': case 'default': return true;
819
+ }
820
+ return false;
821
+ }
822
+ }
823
+
824
+ function initSync(module) {
825
+ if (wasm !== undefined) return wasm;
826
+
827
+
828
+ if (module !== undefined) {
829
+ if (Object.getPrototypeOf(module) === Object.prototype) {
830
+ ({module} = module)
831
+ } else {
832
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
833
+ }
834
+ }
835
+
836
+ const imports = __wbg_get_imports();
837
+ if (!(module instanceof WebAssembly.Module)) {
838
+ module = new WebAssembly.Module(module);
839
+ }
840
+ const instance = new WebAssembly.Instance(module, imports);
841
+ return __wbg_finalize_init(instance, module);
842
+ }
843
+
844
+ async function __wbg_init(module_or_path) {
845
+ if (wasm !== undefined) return wasm;
846
+
847
+
848
+ if (module_or_path !== undefined) {
849
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
850
+ ({module_or_path} = module_or_path)
851
+ } else {
852
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
853
+ }
854
+ }
855
+
856
+ if (module_or_path === undefined) {
857
+ module_or_path = new URL('lightvm_bg.wasm', import.meta.url);
858
+ }
859
+ const imports = __wbg_get_imports();
860
+
861
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
862
+ module_or_path = fetch(module_or_path);
863
+ }
864
+
865
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
866
+
867
+ return __wbg_finalize_init(instance, module);
868
+ }
869
+
870
+ export { initSync, __wbg_init as default };
package/index.wasm ADDED
Binary file
package/lightvm.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class LightVM {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ callExport(name: string, args: any): any;
8
+ embedded(): any;
9
+ halt(): void;
10
+ inspect(): any;
11
+ load(source: string): void;
12
+ constructor(config: any);
13
+ on(event_type: string, callback: Function): void;
14
+ provide(name: string, value: any): void;
15
+ run(): void;
16
+ tools(): LightVMTools;
17
+ }
18
+
19
+ export class LightVMTools {
20
+ private constructor();
21
+ free(): void;
22
+ [Symbol.dispose](): void;
23
+ optimizeBytecode(bytecode: any): any;
24
+ parseLtc(code: string): string;
25
+ parseLtcArray(code: string): any;
26
+ stringifyLtc(json: any): string;
27
+ explain: boolean;
28
+ hint: boolean;
29
+ nightly: boolean;
30
+ }
31
+
32
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
33
+
34
+ export interface InitOutput {
35
+ readonly memory: WebAssembly.Memory;
36
+ readonly __wbg_get_lightvmtools_explain: (a: number) => number;
37
+ readonly __wbg_get_lightvmtools_hint: (a: number) => number;
38
+ readonly __wbg_get_lightvmtools_nightly: (a: number) => number;
39
+ readonly __wbg_lightvm_free: (a: number, b: number) => void;
40
+ readonly __wbg_lightvmtools_free: (a: number, b: number) => void;
41
+ readonly __wbg_set_lightvmtools_explain: (a: number, b: number) => void;
42
+ readonly __wbg_set_lightvmtools_hint: (a: number, b: number) => void;
43
+ readonly __wbg_set_lightvmtools_nightly: (a: number, b: number) => void;
44
+ readonly lightvm_callExport: (a: number, b: number, c: number, d: number, e: number) => void;
45
+ readonly lightvm_embedded: (a: number, b: number) => void;
46
+ readonly lightvm_halt: (a: number, b: number) => void;
47
+ readonly lightvm_inspect: (a: number, b: number) => void;
48
+ readonly lightvm_load: (a: number, b: number, c: number, d: number) => void;
49
+ readonly lightvm_new: (a: number, b: number) => void;
50
+ readonly lightvm_on: (a: number, b: number, c: number, d: number, e: number) => void;
51
+ readonly lightvm_provide: (a: number, b: number, c: number, d: number, e: number) => void;
52
+ readonly lightvm_run: (a: number, b: number) => void;
53
+ readonly lightvm_tools: (a: number) => number;
54
+ readonly lightvmtools_optimizeBytecode: (a: number, b: number, c: number) => void;
55
+ readonly lightvmtools_parseLtc: (a: number, b: number, c: number, d: number) => void;
56
+ readonly lightvmtools_parseLtcArray: (a: number, b: number, c: number) => number;
57
+ readonly lightvmtools_stringifyLtc: (a: number, b: number, c: number) => void;
58
+ readonly __wbindgen_export: (a: number, b: number) => number;
59
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
60
+ readonly __wbindgen_export3: (a: number) => void;
61
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
62
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
63
+ }
64
+
65
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
66
+
67
+ /**
68
+ * Instantiates the given `module`, which can either be bytes or
69
+ * a precompiled `WebAssembly.Module`.
70
+ *
71
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
72
+ *
73
+ * @returns {InitOutput}
74
+ */
75
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
76
+
77
+ /**
78
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
79
+ * for everything else, calls `WebAssembly.instantiate` directly.
80
+ *
81
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
82
+ *
83
+ * @returns {Promise<InitOutput>}
84
+ */
85
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,30 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_get_lightvmtools_explain: (a: number) => number;
5
+ export const __wbg_get_lightvmtools_hint: (a: number) => number;
6
+ export const __wbg_get_lightvmtools_nightly: (a: number) => number;
7
+ export const __wbg_lightvm_free: (a: number, b: number) => void;
8
+ export const __wbg_lightvmtools_free: (a: number, b: number) => void;
9
+ export const __wbg_set_lightvmtools_explain: (a: number, b: number) => void;
10
+ export const __wbg_set_lightvmtools_hint: (a: number, b: number) => void;
11
+ export const __wbg_set_lightvmtools_nightly: (a: number, b: number) => void;
12
+ export const lightvm_callExport: (a: number, b: number, c: number, d: number, e: number) => void;
13
+ export const lightvm_embedded: (a: number, b: number) => void;
14
+ export const lightvm_halt: (a: number, b: number) => void;
15
+ export const lightvm_inspect: (a: number, b: number) => void;
16
+ export const lightvm_load: (a: number, b: number, c: number, d: number) => void;
17
+ export const lightvm_new: (a: number, b: number) => void;
18
+ export const lightvm_on: (a: number, b: number, c: number, d: number, e: number) => void;
19
+ export const lightvm_provide: (a: number, b: number, c: number, d: number, e: number) => void;
20
+ export const lightvm_run: (a: number, b: number) => void;
21
+ export const lightvm_tools: (a: number) => number;
22
+ export const lightvmtools_optimizeBytecode: (a: number, b: number, c: number) => void;
23
+ export const lightvmtools_parseLtc: (a: number, b: number, c: number, d: number) => void;
24
+ export const lightvmtools_parseLtcArray: (a: number, b: number, c: number) => number;
25
+ export const lightvmtools_stringifyLtc: (a: number, b: number, c: number) => void;
26
+ export const __wbindgen_export: (a: number, b: number) => number;
27
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
28
+ export const __wbindgen_export3: (a: number) => void;
29
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
30
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightvm/core-browser-wasm",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.8-nightly.20260626.2f8bade",
4
4
  "os": [
5
5
  "browser"
6
6
  ],
@@ -9,8 +9,8 @@
9
9
  ],
10
10
  "main": "index.js",
11
11
  "files": [
12
- "*.wasm",
13
- "*.js",
12
+ "index.wasm",
13
+ "index.js",
14
14
  "*.d.ts",
15
15
  "README.md",
16
16
  "LICENSE"