From 2cc6276b3b88fa0dccf4c22783c593452be70630 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Tue, 23 May 2023 17:57:27 -0400 Subject: [PATCH] feat!: Update AiScript version from 0.11.1 to 0.13.3 This enables usage of the more modern language features of AiScript 0.12 as well as the new math functions from 0.13. Note that this is a breaking change, as any currently-functioning AiScript plugins, buttons, scripts, etc will need to be updated to work with 0.12+'s new syntax. --- packages/backend/package.json | 2 +- packages/client/package.json | 2 +- packages/client/src/components/page/page.vue | 5 +-- packages/client/src/pages/scratchpad.vue | 7 ++-- .../src/pages/settings/plugin.install.vue | 10 +++--- packages/client/src/plugin.ts | 9 +++-- packages/client/src/scripts/hpml/evaluator.ts | 6 ++-- packages/client/src/widgets/aiscript.vue | 7 ++-- packages/client/src/widgets/button.vue | 7 ++-- pnpm-lock.yaml | 36 +++++++------------ 10 files changed, 41 insertions(+), 50 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 96edb7f026..b207b21378 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -35,7 +35,7 @@ "@peertube/http-signature": "1.7.0", "@redocly/openapi-core": "1.0.0-beta.120", "@sinonjs/fake-timers": "9.1.2", - "@syuilo/aiscript": "0.11.1", + "@syuilo/aiscript": "0.13.3", "@tensorflow/tfjs": "^4.2.0", "adm-zip": "^0.5.10", "ajv": "8.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 1af31dd099..19fc45279a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -13,7 +13,7 @@ "@rollup/plugin-alias": "3.1.9", "@rollup/plugin-json": "4.1.0", "@rollup/pluginutils": "^4.2.1", - "@syuilo/aiscript": "0.11.1", + "@syuilo/aiscript": "^0.13.3", "@types/escape-regexp": "0.0.1", "@types/glob": "8.0.0", "@types/gulp": "4.0.10", diff --git a/packages/client/src/components/page/page.vue b/packages/client/src/components/page/page.vue index f2079c9ba8..5b830a25e2 100644 --- a/packages/client/src/components/page/page.vue +++ b/packages/client/src/components/page/page.vue @@ -22,7 +22,7 @@ import { onUnmounted, PropType, } from "vue"; -import { parse } from "@syuilo/aiscript"; +import { Parser } from "@syuilo/aiscript"; import XBlock from "./page.block.vue"; import { Hpml } from "@/scripts/hpml/evaluator"; import { url } from "@/config"; @@ -51,8 +51,9 @@ export default defineComponent({ nextTick(() => { if (props.page.script && hpml.aiscript) { let ast; + const parser = new Parser() try { - ast = parse(props.page.script); + ast = parser.parse(props.page.script); } catch (err) { console.error(err); /*os.alert({ diff --git a/packages/client/src/pages/scratchpad.vue b/packages/client/src/pages/scratchpad.vue index 06c6a8c27f..7db8833b86 100644 --- a/packages/client/src/pages/scratchpad.vue +++ b/packages/client/src/pages/scratchpad.vue @@ -45,7 +45,7 @@ import "prismjs/components/prism-javascript"; import "prismjs/themes/prism-okaidia.css"; import { PrismEditor } from "vue-prism-editor"; import "vue-prism-editor/dist/prismeditor.min.css"; -import { AiScript, parse, utils } from "@syuilo/aiscript"; +import { Interpreter, Parser, utils } from "@syuilo/aiscript"; import MkContainer from "@/components/MkContainer.vue"; import MkButton from "@/components/MkButton.vue"; import { createAiScriptEnv } from "@/scripts/aiscript/api"; @@ -68,7 +68,8 @@ watch(code, () => { async function run() { logs.value = []; - const aiscript = new AiScript( + const parser = new Parser() + const aiscript = new Interpreter( createAiScriptEnv({ storageKey: "scratchpad", token: $i?.token, @@ -111,7 +112,7 @@ async function run() { let ast; try { - ast = parse(code.value); + ast = parser.parse(code.value); } catch (error) { os.alert({ type: "error", diff --git a/packages/client/src/pages/settings/plugin.install.vue b/packages/client/src/pages/settings/plugin.install.vue index ab678cf990..362e4e1091 100644 --- a/packages/client/src/pages/settings/plugin.install.vue +++ b/packages/client/src/pages/settings/plugin.install.vue @@ -19,8 +19,7 @@