From e44f83fb9c13e4fab8aee07603632d533d12b4d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 15:51:49 +0900 Subject: update AiScript to 0.12.0 --- packages/frontend/src/scripts/hpml/evaluator.ts | 61 ++----------------------- 1 file changed, 5 insertions(+), 56 deletions(-) (limited to 'packages/frontend/src/scripts/hpml/evaluator.ts') diff --git a/packages/frontend/src/scripts/hpml/evaluator.ts b/packages/frontend/src/scripts/hpml/evaluator.ts index 196b3142a1..d4090ea15c 100644 --- a/packages/frontend/src/scripts/hpml/evaluator.ts +++ b/packages/frontend/src/scripts/hpml/evaluator.ts @@ -1,13 +1,11 @@ import autobind from 'autobind-decorator'; -import { PageVar, envVarsDef, Fn, HpmlScope, HpmlError } from '.'; -import { version } from '@/config'; -import { AiScript, utils, values } from '@syuilo/aiscript'; -import { createAiScriptEnv } from '../aiscript/api'; +import { markRaw, ref, Ref, unref } from 'vue'; import { collectPageVars } from '../collect-page-vars'; import { initHpmlLib, initAiLib } from './lib'; -import * as os from '@/os'; -import { markRaw, ref, Ref, unref } from 'vue'; import { Expr, isLiteralValue, Variable } from './expr'; +import { PageVar, envVarsDef, Fn, HpmlScope, HpmlError } from '.'; +import { version } from '@/config'; +import * as os from '@/os'; /** * Hpml evaluator @@ -16,7 +14,6 @@ export class Hpml { private variables: Variable[]; private pageVars: PageVar[]; private envVars: Record; - public aiscript?: AiScript; public pageVarUpdatedCallback?: values.VFn; public canvases: Record = {}; public vars: Ref> = ref({}); @@ -24,7 +21,6 @@ export class Hpml { private opts: { randomSeed: string; visitor?: any; url?: string; - enableAiScript: boolean; }; constructor(page: Hpml['page'], opts: Hpml['opts']) { @@ -33,31 +29,6 @@ export class Hpml { this.pageVars = collectPageVars(this.page.content); this.opts = opts; - if (this.opts.enableAiScript) { - this.aiscript = markRaw(new AiScript({ ...createAiScriptEnv({ - storageKey: 'pages:' + this.page.id, - }), ...initAiLib(this) }, { - in: (q) => { - return new Promise(ok => { - os.inputText({ - title: q, - }).then(({ canceled, result: a }) => { - ok(a); - }); - }); - }, - out: (value) => { - console.log(value); - }, - log: (type, params) => { - }, - })); - - this.aiscript.scope.opts.onUpdated = (name, value) => { - this.eval(); - }; - } - const date = new Date(); this.envVars = { @@ -74,7 +45,7 @@ export class Hpml { IS_CAT: opts.visitor ? opts.visitor.isCat : false, SEED: opts.randomSeed ? opts.randomSeed : '', YMD: `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`, - AISCRIPT_DISABLED: !this.opts.enableAiScript, + AISCRIPT_DISABLED: true, NULL: null, }; @@ -99,13 +70,6 @@ export class Hpml { }); } - @autobind - public callAiScript(fn: string) { - try { - if (this.aiscript) this.aiscript.execFn(this.aiscript.scope.get(fn), []); - } catch (err) {} - } - @autobind public registerCanvas(id: string, canvas: any) { this.canvases[id] = canvas; @@ -116,9 +80,6 @@ export class Hpml { const pageVar = this.pageVars.find(v => v.name === name); if (pageVar !== undefined) { pageVar.value = value; - if (this.pageVarUpdatedCallback) { - if (this.aiscript) this.aiscript.execFn(this.pageVarUpdatedCallback, [values.STR(name), utils.jsToVal(value)]); - } } else { throw new HpmlError(`No such page var '${name}'`); } @@ -180,18 +141,6 @@ export class Hpml { return scope.getState(expr.value); } - if (expr.type === 'aiScriptVar') { - if (this.aiscript) { - try { - return utils.valToJs(this.aiscript.scope.get(expr.value)); - } catch (err) { - return null; - } - } else { - return null; - } - } - // Define user function if (expr.type === 'fn') { return { -- cgit v1.2.3-freya