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.
This commit is contained in:
parent
4fae29e471
commit
2cc6276b3b
10 changed files with 41 additions and 50 deletions
|
@ -35,7 +35,7 @@
|
||||||
"@peertube/http-signature": "1.7.0",
|
"@peertube/http-signature": "1.7.0",
|
||||||
"@redocly/openapi-core": "1.0.0-beta.120",
|
"@redocly/openapi-core": "1.0.0-beta.120",
|
||||||
"@sinonjs/fake-timers": "9.1.2",
|
"@sinonjs/fake-timers": "9.1.2",
|
||||||
"@syuilo/aiscript": "0.11.1",
|
"@syuilo/aiscript": "0.13.3",
|
||||||
"@tensorflow/tfjs": "^4.2.0",
|
"@tensorflow/tfjs": "^4.2.0",
|
||||||
"adm-zip": "^0.5.10",
|
"adm-zip": "^0.5.10",
|
||||||
"ajv": "8.11.2",
|
"ajv": "8.11.2",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"@rollup/plugin-alias": "3.1.9",
|
"@rollup/plugin-alias": "3.1.9",
|
||||||
"@rollup/plugin-json": "4.1.0",
|
"@rollup/plugin-json": "4.1.0",
|
||||||
"@rollup/pluginutils": "^4.2.1",
|
"@rollup/pluginutils": "^4.2.1",
|
||||||
"@syuilo/aiscript": "0.11.1",
|
"@syuilo/aiscript": "^0.13.3",
|
||||||
"@types/escape-regexp": "0.0.1",
|
"@types/escape-regexp": "0.0.1",
|
||||||
"@types/glob": "8.0.0",
|
"@types/glob": "8.0.0",
|
||||||
"@types/gulp": "4.0.10",
|
"@types/gulp": "4.0.10",
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
onUnmounted,
|
onUnmounted,
|
||||||
PropType,
|
PropType,
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { parse } from "@syuilo/aiscript";
|
import { Parser } from "@syuilo/aiscript";
|
||||||
import XBlock from "./page.block.vue";
|
import XBlock from "./page.block.vue";
|
||||||
import { Hpml } from "@/scripts/hpml/evaluator";
|
import { Hpml } from "@/scripts/hpml/evaluator";
|
||||||
import { url } from "@/config";
|
import { url } from "@/config";
|
||||||
|
@ -51,8 +51,9 @@ export default defineComponent({
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (props.page.script && hpml.aiscript) {
|
if (props.page.script && hpml.aiscript) {
|
||||||
let ast;
|
let ast;
|
||||||
|
const parser = new Parser()
|
||||||
try {
|
try {
|
||||||
ast = parse(props.page.script);
|
ast = parser.parse(props.page.script);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
/*os.alert({
|
/*os.alert({
|
||||||
|
|
|
@ -45,7 +45,7 @@ import "prismjs/components/prism-javascript";
|
||||||
import "prismjs/themes/prism-okaidia.css";
|
import "prismjs/themes/prism-okaidia.css";
|
||||||
import { PrismEditor } from "vue-prism-editor";
|
import { PrismEditor } from "vue-prism-editor";
|
||||||
import "vue-prism-editor/dist/prismeditor.min.css";
|
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 MkContainer from "@/components/MkContainer.vue";
|
||||||
import MkButton from "@/components/MkButton.vue";
|
import MkButton from "@/components/MkButton.vue";
|
||||||
import { createAiScriptEnv } from "@/scripts/aiscript/api";
|
import { createAiScriptEnv } from "@/scripts/aiscript/api";
|
||||||
|
@ -68,7 +68,8 @@ watch(code, () => {
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
logs.value = [];
|
logs.value = [];
|
||||||
const aiscript = new AiScript(
|
const parser = new Parser()
|
||||||
|
const aiscript = new Interpreter(
|
||||||
createAiScriptEnv({
|
createAiScriptEnv({
|
||||||
storageKey: "scratchpad",
|
storageKey: "scratchpad",
|
||||||
token: $i?.token,
|
token: $i?.token,
|
||||||
|
@ -111,7 +112,7 @@ async function run() {
|
||||||
|
|
||||||
let ast;
|
let ast;
|
||||||
try {
|
try {
|
||||||
ast = parse(code.value);
|
ast = parser.parse(code.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, nextTick, ref } from "vue";
|
import { defineAsyncComponent, nextTick, ref } from "vue";
|
||||||
import { AiScript, parse } from "@syuilo/aiscript";
|
import { Interpreter, Parser } from "@syuilo/aiscript";
|
||||||
import { serialize } from "@syuilo/aiscript/built/serializer";
|
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
import FormTextarea from "@/components/form/textarea.vue";
|
import FormTextarea from "@/components/form/textarea.vue";
|
||||||
import FormButton from "@/components/MkButton.vue";
|
import FormButton from "@/components/MkButton.vue";
|
||||||
|
@ -49,8 +48,9 @@ function installPlugin({ id, meta, ast, token }) {
|
||||||
|
|
||||||
async function install() {
|
async function install() {
|
||||||
let ast;
|
let ast;
|
||||||
|
const parser = new Parser()
|
||||||
try {
|
try {
|
||||||
ast = parse(code.value);
|
ast = parser.parse(code.value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
@ -59,7 +59,7 @@ async function install() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = AiScript.collectMetadata(ast);
|
const meta = Interpreter.collectMetadata(ast);
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
@ -132,7 +132,7 @@ async function install() {
|
||||||
config,
|
config,
|
||||||
},
|
},
|
||||||
token,
|
token,
|
||||||
ast: serialize(ast),
|
ast: ast,
|
||||||
});
|
});
|
||||||
|
|
||||||
os.success();
|
os.success();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { AiScript, utils, values } from "@syuilo/aiscript";
|
import { Interpreter, utils, values } from "@syuilo/aiscript";
|
||||||
import { deserialize } from "@syuilo/aiscript/built/serializer";
|
|
||||||
import { jsToVal } from "@syuilo/aiscript/built/interpreter/util";
|
import { jsToVal } from "@syuilo/aiscript/built/interpreter/util";
|
||||||
import { createAiScriptEnv } from "@/scripts/aiscript/api";
|
import { createAiScriptEnv } from "@/scripts/aiscript/api";
|
||||||
import { inputText } from "@/os";
|
import { inputText } from "@/os";
|
||||||
|
@ -11,12 +10,12 @@ import {
|
||||||
userActions,
|
userActions,
|
||||||
} from "@/store";
|
} from "@/store";
|
||||||
|
|
||||||
const pluginContexts = new Map<string, AiScript>();
|
const pluginContexts = new Map<string, Interpreter>();
|
||||||
|
|
||||||
export function install(plugin) {
|
export function install(plugin) {
|
||||||
console.info("Plugin installed:", plugin.name, `v${plugin.version}`);
|
console.info("Plugin installed:", plugin.name, `v${plugin.version}`);
|
||||||
|
|
||||||
const aiscript = new AiScript(
|
const aiscript = new Interpreter(
|
||||||
createPluginEnv({
|
createPluginEnv({
|
||||||
plugin: plugin,
|
plugin: plugin,
|
||||||
storageKey: `plugins:${plugin.id}`,
|
storageKey: `plugins:${plugin.id}`,
|
||||||
|
@ -40,7 +39,7 @@ export function install(plugin) {
|
||||||
|
|
||||||
initPlugin({ plugin, aiscript });
|
initPlugin({ plugin, aiscript });
|
||||||
|
|
||||||
aiscript.exec(deserialize(plugin.ast));
|
aiscript.exec(plugin.ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPluginEnv(opts) {
|
function createPluginEnv(opts) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import autobind from "autobind-decorator";
|
import autobind from "autobind-decorator";
|
||||||
import { PageVar, envVarsDef, Fn, HpmlScope, HpmlError } from ".";
|
import { PageVar, envVarsDef, Fn, HpmlScope, HpmlError } from ".";
|
||||||
import { version } from "@/config";
|
import { version } from "@/config";
|
||||||
import { AiScript, utils, values } from "@syuilo/aiscript";
|
import { Interpreter, utils, values } from "@syuilo/aiscript";
|
||||||
import { createAiScriptEnv } from "../aiscript/api";
|
import { createAiScriptEnv } from "../aiscript/api";
|
||||||
import { collectPageVars } from "../collect-page-vars";
|
import { collectPageVars } from "../collect-page-vars";
|
||||||
import { initHpmlLib, initAiLib } from "./lib";
|
import { initHpmlLib, initAiLib } from "./lib";
|
||||||
|
@ -16,7 +16,7 @@ export class Hpml {
|
||||||
private variables: Variable[];
|
private variables: Variable[];
|
||||||
private pageVars: PageVar[];
|
private pageVars: PageVar[];
|
||||||
private envVars: Record<keyof typeof envVarsDef, any>;
|
private envVars: Record<keyof typeof envVarsDef, any>;
|
||||||
public aiscript?: AiScript;
|
public aiscript?: Interpreter;
|
||||||
public pageVarUpdatedCallback?: values.VFn;
|
public pageVarUpdatedCallback?: values.VFn;
|
||||||
public canvases: Record<string, HTMLCanvasElement> = {};
|
public canvases: Record<string, HTMLCanvasElement> = {};
|
||||||
public vars: Ref<Record<string, any>> = ref({});
|
public vars: Ref<Record<string, any>> = ref({});
|
||||||
|
@ -37,7 +37,7 @@ export class Hpml {
|
||||||
|
|
||||||
if (this.opts.enableAiScript) {
|
if (this.opts.enableAiScript) {
|
||||||
this.aiscript = markRaw(
|
this.aiscript = markRaw(
|
||||||
new AiScript(
|
new Interpreter(
|
||||||
{
|
{
|
||||||
...createAiScriptEnv({
|
...createAiScriptEnv({
|
||||||
storageKey: `pages:${this.page.id}`,
|
storageKey: `pages:${this.page.id}`,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, onUnmounted, ref, watch } from "vue";
|
import { onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { AiScript, parse, utils } from "@syuilo/aiscript";
|
import { Interpreter, Parser, utils } from "@syuilo/aiscript";
|
||||||
import {
|
import {
|
||||||
useWidgetPropsManager,
|
useWidgetPropsManager,
|
||||||
Widget,
|
Widget,
|
||||||
|
@ -82,7 +82,7 @@ const logs = ref<
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
logs.value = [];
|
logs.value = [];
|
||||||
const aiscript = new AiScript(
|
const aiscript = new Interpreter(
|
||||||
createAiScriptEnv({
|
createAiScriptEnv({
|
||||||
storageKey: "widget",
|
storageKey: "widget",
|
||||||
token: $i?.token,
|
token: $i?.token,
|
||||||
|
@ -124,8 +124,9 @@ const run = async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
let ast;
|
let ast;
|
||||||
|
const parser = new Parser()
|
||||||
try {
|
try {
|
||||||
ast = parse(widgetProps.script);
|
ast = parser.parse(widgetProps.script);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, onUnmounted, ref, watch } from "vue";
|
import { onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { AiScript, parse, utils } from "@syuilo/aiscript";
|
import { Interpreter, Parser, utils } from "@syuilo/aiscript";
|
||||||
import {
|
import {
|
||||||
useWidgetPropsManager,
|
useWidgetPropsManager,
|
||||||
Widget,
|
Widget,
|
||||||
|
@ -56,7 +56,7 @@ const { widgetProps, configure } = useWidgetPropsManager(
|
||||||
);
|
);
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const aiscript = new AiScript(
|
const aiscript = new Interpreter(
|
||||||
createAiScriptEnv({
|
createAiScriptEnv({
|
||||||
storageKey: "widget",
|
storageKey: "widget",
|
||||||
token: $i?.token,
|
token: $i?.token,
|
||||||
|
@ -81,8 +81,9 @@ const run = async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
let ast;
|
let ast;
|
||||||
|
const parser = new Parser()
|
||||||
try {
|
try {
|
||||||
ast = parse(widgetProps.script);
|
ast = parser.parse(widgetProps.script);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
|
|
@ -114,8 +114,8 @@ importers:
|
||||||
specifier: 9.1.2
|
specifier: 9.1.2
|
||||||
version: 9.1.2
|
version: 9.1.2
|
||||||
'@syuilo/aiscript':
|
'@syuilo/aiscript':
|
||||||
specifier: 0.11.1
|
specifier: 0.13.3
|
||||||
version: 0.11.1
|
version: 0.13.3
|
||||||
'@tensorflow/tfjs':
|
'@tensorflow/tfjs':
|
||||||
specifier: ^4.2.0
|
specifier: ^4.2.0
|
||||||
version: 4.2.0(seedrandom@3.0.5)
|
version: 4.2.0(seedrandom@3.0.5)
|
||||||
|
@ -678,8 +678,8 @@ importers:
|
||||||
specifier: ^4.2.1
|
specifier: ^4.2.1
|
||||||
version: 4.2.1
|
version: 4.2.1
|
||||||
'@syuilo/aiscript':
|
'@syuilo/aiscript':
|
||||||
specifier: 0.11.1
|
specifier: ^0.13.3
|
||||||
version: 0.11.1
|
version: 0.13.3
|
||||||
'@types/escape-regexp':
|
'@types/escape-regexp':
|
||||||
specifier: 0.0.1
|
specifier: 0.0.1
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
@ -2720,14 +2720,13 @@ packages:
|
||||||
resolution: {integrity: sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==}
|
resolution: {integrity: sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
|
||||||
/@syuilo/aiscript@0.11.1:
|
/@syuilo/aiscript@0.13.3:
|
||||||
resolution: {integrity: sha512-chwOIA3yLUKvOB0G611hjLArKTeOWNmTm3lHERSaDW1d+dS6do56naX6Lkwy2UpnwWC0qzeNSgg35elk6t2gZg==}
|
resolution: {integrity: sha512-0YFlWA+7YhyRRsp+9Nl72SoSUg5ghskthjCdLvj4qdGyLedeyanKZWJlH2A9d47Nes03UYY8CRDsMHHv64IWcg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
autobind-decorator: 2.4.0
|
autobind-decorator: 2.4.0
|
||||||
chalk: 4.0.0
|
|
||||||
seedrandom: 3.0.5
|
seedrandom: 3.0.5
|
||||||
stringz: 2.1.0
|
stringz: 2.1.0
|
||||||
uuid: 7.0.3
|
uuid: 9.0.0
|
||||||
|
|
||||||
/@szmarczak/http-timer@4.0.6:
|
/@szmarczak/http-timer@4.0.6:
|
||||||
resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==}
|
resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==}
|
||||||
|
@ -5166,13 +5165,6 @@ packages:
|
||||||
escape-string-regexp: 1.0.5
|
escape-string-regexp: 1.0.5
|
||||||
supports-color: 5.5.0
|
supports-color: 5.5.0
|
||||||
|
|
||||||
/chalk@4.0.0:
|
|
||||||
resolution: {integrity: sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==}
|
|
||||||
engines: {node: '>=10'}
|
|
||||||
dependencies:
|
|
||||||
ansi-styles: 4.3.0
|
|
||||||
supports-color: 7.2.0
|
|
||||||
|
|
||||||
/chalk@4.1.2:
|
/chalk@4.1.2:
|
||||||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -5880,8 +5872,8 @@ packages:
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/core-js@3.30.1:
|
/core-js@3.30.2:
|
||||||
resolution: {integrity: sha512-ZNS5nbiSwDTq4hFosEDqm65izl2CWmLz0hARJMyNQBgkUZMIF51cQiMvIQKA6hvuaeWxQDP3hEedM1JZIgTldQ==}
|
resolution: {integrity: sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -7564,7 +7556,7 @@ packages:
|
||||||
resolution: {integrity: sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==}
|
resolution: {integrity: sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==}
|
||||||
engines: {node: '>= 0.10'}
|
engines: {node: '>= 0.10'}
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
through2: 2.0.5
|
through2: 2.0.5
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
@ -14464,10 +14456,6 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/uuid@7.0.3:
|
|
||||||
resolution: {integrity: sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==}
|
|
||||||
hasBin: true
|
|
||||||
|
|
||||||
/uuid@8.0.0:
|
/uuid@8.0.0:
|
||||||
resolution: {integrity: sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==}
|
resolution: {integrity: sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -14571,7 +14559,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
append-buffer: 1.0.2
|
append-buffer: 1.0.2
|
||||||
convert-source-map: 1.9.0
|
convert-source-map: 1.9.0
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
normalize-path: 2.1.1
|
normalize-path: 2.1.1
|
||||||
now-and-later: 2.0.1
|
now-and-later: 2.0.1
|
||||||
remove-bom-buffer: 3.0.0
|
remove-bom-buffer: 3.0.0
|
||||||
|
@ -15309,7 +15297,7 @@ packages:
|
||||||
name: plyr
|
name: plyr
|
||||||
version: 3.7.0
|
version: 3.7.0
|
||||||
dependencies:
|
dependencies:
|
||||||
core-js: 3.30.1
|
core-js: 3.30.2
|
||||||
custom-event-polyfill: 1.0.7
|
custom-event-polyfill: 1.0.7
|
||||||
loadjs: 4.2.0
|
loadjs: 4.2.0
|
||||||
rangetouch: 2.0.1
|
rangetouch: 2.0.1
|
||||||
|
|
Loading…
Reference in a new issue