tanaid-tcl 0.2.1 → 0.3.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/dist/index.d.mts CHANGED
@@ -1,29 +1,25 @@
1
1
  //#region ../../crates/tanaid-wasm/pkg/bundler/tanaid_wasm.d.ts
2
2
  /* tslint:disable */
3
3
  /* eslint-disable */
4
- interface InterpreterOptions {
4
+ interface RunOptions {
5
+ handleEventLoopStatus?: (countPending: number) => void;
6
+ }
7
+ interface TclOptions {
5
8
  handleStdout: (output: string) => void;
6
9
  setTimeout: (callback: () => void, delayMs: number) => unknown;
7
10
  clearTimeout: (timeoutId: unknown) => void;
8
- handleEventLoopStatus: (pendingTimers: number) => void;
9
11
  }
10
- declare class Interpreter {
12
+ declare class Tcl {
11
13
  private constructor();
12
14
  free(): void;
13
15
  [Symbol.dispose](): void;
14
- static create(options: InterpreterOptions): Interpreter;
15
- runEventLoop(): Promise<void>;
16
- run(src: string): Promise<any>;
16
+ static create(options: TclOptions): Tcl;
17
+ run(src: string, options?: RunOptions | null): Promise<any>;
17
18
  }
18
19
  //#endregion
19
20
  //#region src/index.d.ts
20
- type CreateInterpreterOptions = Omit<InterpreterOptions, "handleStdout" | "handleEventLoopStatus" | "setTimeout" | "clearTimeout"> & {
21
- handleStdout?: InterpreterOptions["handleStdout"];
22
- handleEventLoopStatus?: InterpreterOptions["handleEventLoopStatus"];
23
- setTimeout?: InterpreterOptions["setTimeout"];
24
- clearTimeout?: InterpreterOptions["clearTimeout"];
25
- };
26
- /** Interpreter.create with default options for convenience */
27
- declare function createInterpreter(options: CreateInterpreterOptions): Interpreter;
21
+ type CreateTclOptions = Partial<TclOptions>;
22
+ /** Tcl.create with default options for convenience */
23
+ declare function createTcl(options?: CreateTclOptions): Tcl;
28
24
  //#endregion
29
- export { CreateInterpreterOptions, Interpreter, InterpreterOptions, createInterpreter };
25
+ export { CreateTclOptions, RunOptions, Tcl, TclOptions, createTcl };
package/dist/index.mjs CHANGED
@@ -36,49 +36,44 @@ function loadWasmModule(sync, fileUrl, src, imports) {
36
36
  }
37
37
  //#endregion
38
38
  //#region ../../crates/tanaid-wasm/pkg/bundler/tanaid_wasm_bg.js
39
- var Interpreter = class Interpreter {
39
+ var Tcl = class Tcl {
40
40
  static __wrap(ptr) {
41
- const obj = Object.create(Interpreter.prototype);
41
+ const obj = Object.create(Tcl.prototype);
42
42
  obj.__wbg_ptr = ptr;
43
- InterpreterFinalization.register(obj, obj.__wbg_ptr, obj);
43
+ TclFinalization.register(obj, obj.__wbg_ptr, obj);
44
44
  return obj;
45
45
  }
46
46
  __destroy_into_raw() {
47
47
  const ptr = this.__wbg_ptr;
48
48
  this.__wbg_ptr = 0;
49
- InterpreterFinalization.unregister(this);
49
+ TclFinalization.unregister(this);
50
50
  return ptr;
51
51
  }
52
52
  free() {
53
53
  const ptr = this.__destroy_into_raw();
54
- wasm.__wbg_interpreter_free(ptr, 0);
54
+ wasm.__wbg_tcl_free(ptr, 0);
55
55
  }
56
56
  /**
57
- * @param {InterpreterOptions} options
58
- * @returns {Interpreter}
57
+ * @param {TclOptions} options
58
+ * @returns {Tcl}
59
59
  */
60
60
  static create(options) {
61
- const ret = wasm.interpreter_create(options);
61
+ const ret = wasm.tcl_create(options);
62
62
  if (ret[2]) throw takeFromExternrefTable0(ret[1]);
63
- return Interpreter.__wrap(ret[0]);
64
- }
65
- /**
66
- * @returns {Promise<void>}
67
- */
68
- runEventLoop() {
69
- return wasm.interpreter_runEventLoop(this.__wbg_ptr);
63
+ return Tcl.__wrap(ret[0]);
70
64
  }
71
65
  /**
72
66
  * @param {string} src
67
+ * @param {RunOptions | null} [options]
73
68
  * @returns {Promise<any>}
74
69
  */
75
- run(src) {
70
+ run(src, options) {
76
71
  const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
72
  const len0 = WASM_VECTOR_LEN;
78
- return wasm.interpreter_run(this.__wbg_ptr, ptr0, len0);
73
+ return wasm.tcl_run(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
79
74
  }
80
75
  };
81
- if (Symbol.dispose) Interpreter.prototype[Symbol.dispose] = Interpreter.prototype.free;
76
+ if (Symbol.dispose) Tcl.prototype[Symbol.dispose] = Tcl.prototype.free;
82
77
  function __wbg_Error_67e7344beaa85059(arg0, arg1) {
83
78
  return Error(getStringFromWasm0(arg0, arg1));
84
79
  }
@@ -243,25 +238,8 @@ function __wbg_new_1da3429bc3c4541c(arg0) {
243
238
  function __wbg_new_227d7c05414eb861() {
244
239
  return /* @__PURE__ */ new Error();
245
240
  }
246
- function __wbg_new_8f72ed7c652bf5a2(arg0, arg1) {
247
- try {
248
- var state0 = {
249
- a: arg0,
250
- b: arg1
251
- };
252
- var cb0 = (arg0, arg1) => {
253
- const a = state0.a;
254
- state0.a = 0;
255
- try {
256
- return wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_$1(a, state0.b, arg0, arg1);
257
- } finally {
258
- state0.a = a;
259
- }
260
- };
261
- return new Promise(cb0);
262
- } finally {
263
- state0.a = 0;
264
- }
241
+ function __wbg_new_no_args_61f96c76373d34b7(arg0, arg1) {
242
+ return new Function(getStringFromWasm0(arg0, arg1));
265
243
  }
266
244
  function __wbg_new_typed_6f8b0d724fe26c07(arg0, arg1) {
267
245
  try {
@@ -332,9 +310,6 @@ function __wbg_static_accessor_WINDOW_fd0bc376bf0f8b42() {
332
310
  const ret = typeof window === "undefined" ? null : window;
333
311
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
334
312
  }
335
- function __wbg_then_7a850dae4493f353(arg0, arg1, arg2) {
336
- return arg0.then(arg1, arg2);
337
- }
338
313
  function __wbg_then_b830475380919203(arg0, arg1) {
339
314
  return arg0.then(arg1);
340
315
  }
@@ -345,7 +320,7 @@ function __wbindgen_generic_0000000000000001(arg0, arg1) {
345
320
  return makeMutClosure(arg0, arg1, wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_$1);
346
321
  }
347
322
  function __wbindgen_generic_0000000000000002(arg0, arg1) {
348
- return makeMutClosure(arg0, arg1, wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_$1);
323
+ return makeMutClosure(arg0, arg1, wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_$1);
349
324
  }
350
325
  function __wbindgen_generic_0000000000000003(arg0) {
351
326
  return arg0;
@@ -362,8 +337,8 @@ function __wbindgen_init_externref_table() {
362
337
  table.set(offset + 2, true);
363
338
  table.set(offset + 3, false);
364
339
  }
365
- function wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_$1(arg0, arg1) {
366
- wasm.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_(arg0, arg1);
340
+ function wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_$1(arg0, arg1) {
341
+ wasm.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_(arg0, arg1);
367
342
  }
368
343
  function wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_$1(arg0, arg1, arg2) {
369
344
  const ret = wasm.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_(arg0, arg1, arg2);
@@ -372,10 +347,10 @@ function wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bin
372
347
  function wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_$1(arg0, arg1, arg2, arg3) {
373
348
  wasm.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
374
349
  }
375
- const InterpreterFinalization = typeof FinalizationRegistry === "undefined" ? {
350
+ const TclFinalization = typeof FinalizationRegistry === "undefined" ? {
376
351
  register: () => {},
377
352
  unregister: () => {}
378
- } : new FinalizationRegistry((ptr) => wasm.__wbg_interpreter_free(ptr, 1));
353
+ } : new FinalizationRegistry((ptr) => wasm.__wbg_tcl_free(ptr, 1));
379
354
  function addToExternrefTable0(obj) {
380
355
  const idx = wasm.__externref_table_alloc();
381
356
  wasm.__wbindgen_externrefs.set(idx, obj);
@@ -547,7 +522,7 @@ var tanaid_wasm_bg_exports = /* @__PURE__ */ __exportAll({
547
522
  __externref_table_alloc: () => __externref_table_alloc,
548
523
  __externref_table_dealloc: () => __externref_table_dealloc,
549
524
  __instance_terminated: () => __instance_terminated,
550
- __wbg_interpreter_free: () => __wbg_interpreter_free,
525
+ __wbg_tcl_free: () => __wbg_tcl_free,
551
526
  __wbindgen_destroy_closure: () => __wbindgen_destroy_closure,
552
527
  __wbindgen_exn_store: () => __wbindgen_exn_store,
553
528
  __wbindgen_externrefs: () => __wbindgen_externrefs,
@@ -555,27 +530,24 @@ var tanaid_wasm_bg_exports = /* @__PURE__ */ __exportAll({
555
530
  __wbindgen_malloc: () => __wbindgen_malloc,
556
531
  __wbindgen_realloc: () => __wbindgen_realloc,
557
532
  __wbindgen_start: () => __wbindgen_start,
558
- interpreter_create: () => interpreter_create,
559
- interpreter_run: () => interpreter_run,
560
- interpreter_runEventLoop: () => interpreter_runEventLoop,
561
533
  memory: () => memory,
562
- wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_: () => wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_,
534
+ tcl_create: () => tcl_create,
535
+ tcl_run: () => tcl_run,
536
+ wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_: () => wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_,
563
537
  wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_: () => wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_,
564
538
  wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_: () => wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_
565
539
  });
566
540
  function __wasm_init(imports) {
567
- return loadWasmModule(false, new URL("5f6bca66e463fbdd.wasm", import.meta.url), null, imports);
541
+ return loadWasmModule(false, new URL("a860f810fa490009.wasm", import.meta.url), null, imports);
568
542
  }
569
543
  const instance = await __wasm_init({ "./tanaid_wasm_bg.js": {
570
- "__wbg_next_f31ecb8646d2c605": __wbg_next_f31ecb8646d2c605,
571
- "__wbg_done_cffed884d87aa22e": __wbg_done_cffed884d87aa22e,
572
- "__wbg_value_c227f843d21da141": __wbg_value_c227f843d21da141,
573
- "__wbg_then_7a850dae4493f353": __wbg_then_7a850dae4493f353,
574
544
  "__wbg_new_typed_6f8b0d724fe26c07": __wbg_new_typed_6f8b0d724fe26c07,
575
545
  "__wbg_get_unchecked_363572bdd397d473": __wbg_get_unchecked_363572bdd397d473,
576
546
  "__wbg_call_6bcf8d3e20937e46": __wbg_call_6bcf8d3e20937e46,
547
+ "__wbg_next_f31ecb8646d2c605": __wbg_next_f31ecb8646d2c605,
548
+ "__wbg_done_cffed884d87aa22e": __wbg_done_cffed884d87aa22e,
549
+ "__wbg_value_c227f843d21da141": __wbg_value_c227f843d21da141,
577
550
  "__wbg_call_7bbd9cceba9949ad": __wbg_call_7bbd9cceba9949ad,
578
- "__wbg_new_8f72ed7c652bf5a2": __wbg_new_8f72ed7c652bf5a2,
579
551
  "__wbg_length_4e1adc0d42e23620": __wbg_length_4e1adc0d42e23620,
580
552
  "__wbg_new_227d7c05414eb861": __wbg_new_227d7c05414eb861,
581
553
  "__wbg_stack_3b0d974bbf31e44f": __wbg_stack_3b0d974bbf31e44f,
@@ -592,6 +564,7 @@ const instance = await __wasm_init({ "./tanaid_wasm_bg.js": {
592
564
  "__wbg_next_95053e306b1c3aed": __wbg_next_95053e306b1c3aed,
593
565
  "__wbg_isArray_5674713bb7b79043": __wbg_isArray_5674713bb7b79043,
594
566
  "__wbg_message_1cbc5bc03dcf1dee": __wbg_message_1cbc5bc03dcf1dee,
567
+ "__wbg_new_no_args_61f96c76373d34b7": __wbg_new_no_args_61f96c76373d34b7,
595
568
  "__wbg_isSafeInteger_8f51c743827d1ec5": __wbg_isSafeInteger_8f51c743827d1ec5,
596
569
  "__wbg_now_d1fb6650485d7f3e": __wbg_now_d1fb6650485d7f3e,
597
570
  "__wbg_length_31bdaf014f5fbde2": __wbg_length_31bdaf014f5fbde2,
@@ -627,15 +600,14 @@ const instance = await __wasm_init({ "./tanaid_wasm_bg.js": {
627
600
  "__wbindgen_generic_0000000000000004": __wbindgen_generic_0000000000000004
628
601
  } });
629
602
  const memory = instance.exports.memory;
630
- const __wbg_interpreter_free = instance.exports.__wbg_interpreter_free;
631
- const interpreter_create = instance.exports.interpreter_create;
632
- const interpreter_run = instance.exports.interpreter_run;
633
- const interpreter_runEventLoop = instance.exports.interpreter_runEventLoop;
603
+ const __wbg_tcl_free = instance.exports.__wbg_tcl_free;
604
+ const tcl_create = instance.exports.tcl_create;
605
+ const tcl_run = instance.exports.tcl_run;
634
606
  const __abort_handler = instance.exports.__abort_handler;
635
607
  const __instance_terminated = instance.exports.__instance_terminated;
636
608
  const wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_ = instance.exports.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined___js_sys_9bd2705a32432e88___Function_fn_wasm_bindgen_254878bcf0ae536b___JsValue_____wasm_bindgen_254878bcf0ae536b___sys__Undefined_______true_;
637
609
  const wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_ = instance.exports.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke___wasm_bindgen_254878bcf0ae536b___JsValue__core_3db1b4038a372208___result__Result_____wasm_bindgen_254878bcf0ae536b___JsError___true_;
638
- const wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_ = instance.exports.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______false_;
610
+ const wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_ = instance.exports.wasm_bindgen_254878bcf0ae536b___convert__closures_____invoke_______true_;
639
611
  const __wbindgen_malloc = instance.exports.__wbindgen_malloc;
640
612
  const __wbindgen_realloc = instance.exports.__wbindgen_realloc;
641
613
  const __wbindgen_exn_store = instance.exports.__wbindgen_exn_store;
@@ -651,13 +623,12 @@ __wbg_set_wasm(tanaid_wasm_bg_exports);
651
623
  __wbindgen_start();
652
624
  //#endregion
653
625
  //#region src/index.ts
654
- /** Interpreter.create with default options for convenience */
655
- function createInterpreter(options) {
656
- return Interpreter.create({
626
+ /** Tcl.create with default options for convenience */
627
+ function createTcl(options = {}) {
628
+ return Tcl.create({
657
629
  handleStdout: (stdout) => {
658
630
  console.log(stdout);
659
631
  },
660
- handleEventLoopStatus: (_nPending) => {},
661
632
  setTimeout: (callback, delayMs) => {
662
633
  return globalThis.setTimeout(callback, delayMs);
663
634
  },
@@ -668,4 +639,4 @@ function createInterpreter(options) {
668
639
  });
669
640
  }
670
641
  //#endregion
671
- export { Interpreter, createInterpreter };
642
+ export { Tcl, createTcl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tanaid-tcl",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "license": "MPL-2.0",
5
5
  "repository": {
6
6
  "type": "git",