@@ -63,6 +63,8 @@ SPDX-License-Identifier: AGPL-3.0-only
6363<script lang="ts" setup>
6464import { computed , onDeactivated , onUnmounted , ref , watch , shallowRef , defineAsyncComponent } from ' vue' ;
6565import * as Misskey from ' misskey-js' ;
66+ import { utils } from ' @syuilo/aiscript' ;
67+ import { compareVersions } from ' compare-versions' ;
6668import { url } from ' @@/js/config.js' ;
6769import type { Ref } from ' vue' ;
6870import type { AsUiComponent , AsUiRoot } from ' @/aiscript/ui.js' ;
@@ -74,7 +76,6 @@ import { misskeyApi } from '@/utility/misskey-api.js';
7476import { i18n } from ' @/i18n.js' ;
7577import { definePage } from ' @/page.js' ;
7678import MkAsUi from ' @/components/MkAsUi.vue' ;
77- import { getAiScriptVersion } from ' @/aiscript/common.js' ;
7879import { registerAsUiLib } from ' @/aiscript/ui.js' ;
7980import { aiScriptReadline , createAiScriptEnv } from ' @/aiscript/api.js' ;
8081import MkFolder from ' @/components/MkFolder.vue' ;
@@ -191,12 +192,21 @@ function start() {
191192 run ();
192193}
193194
195+ function getIsLegacy(version : string | null ): boolean {
196+ if (version == null ) return false ;
197+ try {
198+ return compareVersions (version , ' 1.0.0' ) < 0 ;
199+ } catch {
200+ return false ;
201+ }
202+ }
203+
194204async function run() {
195205 if (aiscript .value ) aiscript .value .abort ();
196206 if (! flash .value ) return ;
197207
198- const version = getAiScriptVersion (flash .value .script );
199- const isLegacy = version ? version . major < 1 : false ;
208+ const version = utils . getLangVersion (flash .value .script );
209+ const isLegacy = version != null && getIsLegacy ( version ) ;
200210
201211 const { Interpreter, Parser, values } = isLegacy ? (await import (' @syuilo/aiscript-0-19-0' ) as any ) : await import (' @syuilo/aiscript' );
202212
0 commit comments