2323
2424<script setup lang="ts">
2525import { ref } from ' vue' ;
26- import { utils , errors } from ' @syuilo/aiscript' ;
27- import type { Interpreter , Parser } from ' @syuilo/aiscript' ;
26+ import { Parser , Interpreter , utils , errors } from ' @syuilo/aiscript' ;
2827
2928const props = defineProps <{
3029 code: string ;
@@ -36,9 +35,6 @@ const logs = ref<{
3635}[]>([]);
3736const loading = ref (false );
3837
39- let ParserClass: typeof Parser | null = null ;
40- let InterpreterClass: typeof Interpreter | null = null ;
41-
4238let parser: Parser | null = null ;
4339let interpreter: Interpreter | null = null ;
4440
@@ -55,27 +51,16 @@ async function run() {
5551 type: ' info' ,
5652 }];
5753
58- if (! ParserClass || ! InterpreterClass ) {
59- const [
60- { Parser, Interpreter },
61- ] = await Promise .all ([
62- import (' @syuilo/aiscript' ),
63- new Promise ((resolve ) => setTimeout (resolve , 250 )), // あまりにも高速に切り替わると実行できてるのかわかりにくいので、最低250msはロード画面を挟む
64- ]);
65- ParserClass = Parser ;
66- InterpreterClass = Interpreter ;
67- } else {
68- await new Promise ((resolve ) => setTimeout (resolve , 250 )); // あまりにも高速に切り替わると実行できてるのかわかりにくいので、最低250msはロード画面を挟む
69- }
54+ await new Promise ((resolve ) => setTimeout (resolve , 250 )); // あまりにも高速に切り替わると実行できてるのかわかりにくいので、最低250msはロード画面を挟む
7055
7156 if (! parser ) {
72- parser = new ParserClass ();
57+ parser = new Parser ();
7358 }
7459 if (interpreter ) {
7560 interpreter .abort ();
7661 }
7762
78- interpreter = new InterpreterClass ({}, {
63+ interpreter = new Interpreter ({}, {
7964 out : (value ) => {
8065 logs .value .push ({
8166 text: value .type === ' num' ? value .value .toString () : value .type === ' str' ? ` "${value .value }" ` : JSON .stringify (utils .valToJs (value ), null , 2 ) ?? ' ' ,
0 commit comments