diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0827091532..848bf4bb43 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -481,6 +481,8 @@ descendingOrder: "降順" scratchpad: "スクラッチパッド" scratchpadDescription: "スクラッチパッドは、AiScriptの実験環境を提供します。Misskeyと対話するコードの記述、実行、結果の確認ができます。" output: "出力" +script: "スクリプト" +disablePagesScript: "Pagesのスクリプトを無効にする" _theme: explore: "テーマを探す" @@ -813,6 +815,9 @@ _pages: message: "押したときに表示するメッセージ" variable: "送信する変数" no-variable: "なし" + callAiScript: "AiScript呼び出し" + _callAiScript: + functionName: "関数名" radioButton: "選択肢" _radioButton: @@ -975,6 +980,7 @@ _pages: _splitStrByLine: arg1: "テキスト" ref: "変数" + aiScriptVar: "AiScript変数" fn: "関数" _fn: slots: "スロット" diff --git a/migration/1586708940386-pageAiScript.ts b/migration/1586708940386-pageAiScript.ts new file mode 100644 index 0000000000..fdd6e76b9b --- /dev/null +++ b/migration/1586708940386-pageAiScript.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class pageAiScript1586708940386 implements MigrationInterface { + name = 'pageAiScript1586708940386' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "page" ADD "script" character varying(16384) NOT NULL DEFAULT ''`, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "page" DROP COLUMN "script"`, undefined); + } + +} diff --git a/package.json b/package.json index 98ca48014c..8fa0129cb9 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@koa/cors": "3.0.0", "@koa/multer": "2.0.2", "@koa/router": "8.0.8", - "@syuilo/aiscript": "0.1.2", + "@syuilo/aiscript": "0.1.4", "@types/bcryptjs": "2.4.2", "@types/bull": "3.12.1", "@types/cbor": "5.0.0", diff --git a/src/client/components/page/page.button.vue b/src/client/components/page/page.button.vue index eeb56d5eca..148fdc8e9c 100644 --- a/src/client/components/page/page.button.vue +++ b/src/client/components/page/page.button.vue @@ -28,7 +28,7 @@ export default Vue.extend({ text: this.script.interpolate(this.value.content) }); } else if (this.value.action === 'resetRandom') { - this.script.aiScript.updateRandomSeed(Math.random()); + this.script.aoiScript.updateRandomSeed(Math.random()); this.script.eval(); } else if (this.value.action === 'pushEvent') { this.$root.api('page-push', { @@ -43,6 +43,8 @@ export default Vue.extend({ type: 'success', text: this.script.interpolate(this.value.message) }); + } else if (this.value.action === 'callAiScript') { + this.script.callAiScript(this.value.fn); } } } diff --git a/src/client/components/page/page.counter.vue b/src/client/components/page/page.counter.vue index 781a1bd549..f7557c003a 100644 --- a/src/client/components/page/page.counter.vue +++ b/src/client/components/page/page.counter.vue @@ -27,7 +27,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } }, diff --git a/src/client/components/page/page.number-input.vue b/src/client/components/page/page.number-input.vue index 9ee2730fac..9ea1ebb642 100644 --- a/src/client/components/page/page.number-input.vue +++ b/src/client/components/page/page.number-input.vue @@ -27,7 +27,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } } diff --git a/src/client/components/page/page.radio-button.vue b/src/client/components/page/page.radio-button.vue index fda0a03927..dd5cbcbded 100644 --- a/src/client/components/page/page.radio-button.vue +++ b/src/client/components/page/page.radio-button.vue @@ -28,7 +28,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } } diff --git a/src/client/components/page/page.switch.vue b/src/client/components/page/page.switch.vue index 416c36e9ad..79d871df8f 100644 --- a/src/client/components/page/page.switch.vue +++ b/src/client/components/page/page.switch.vue @@ -27,7 +27,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } } diff --git a/src/client/components/page/page.text-input.vue b/src/client/components/page/page.text-input.vue index fcc181d673..843d541de6 100644 --- a/src/client/components/page/page.text-input.vue +++ b/src/client/components/page/page.text-input.vue @@ -27,7 +27,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } } diff --git a/src/client/components/page/page.textarea-input.vue b/src/client/components/page/page.textarea-input.vue index d1cf9813c4..5ba22e7c58 100644 --- a/src/client/components/page/page.textarea-input.vue +++ b/src/client/components/page/page.textarea-input.vue @@ -27,7 +27,7 @@ export default Vue.extend({ }, watch: { v() { - this.script.aiScript.updatePageVar(this.value.name, this.v); + this.script.aoiScript.updatePageVar(this.value.name, this.v); this.script.eval(); } } diff --git a/src/client/components/page/page.vue b/src/client/components/page/page.vue index 977d384b30..0f1769fc8f 100644 --- a/src/client/components/page/page.vue +++ b/src/client/components/page/page.vue @@ -6,30 +6,57 @@ diff --git a/src/client/pages/page-editor/els/page-editor.el.if.vue b/src/client/pages/page-editor/els/page-editor.el.if.vue index 5e531a7ab5..0c40e41d8a 100644 --- a/src/client/pages/page-editor/els/page-editor.el.if.vue +++ b/src/client/pages/page-editor/els/page-editor.el.if.vue @@ -10,16 +10,16 @@
- + - + - + - +
@@ -45,7 +45,7 @@ export default Vue.extend({ value: { required: true }, - aiScript: { + aoiScript: { required: true, }, }, diff --git a/src/client/pages/page-editor/els/page-editor.el.section.vue b/src/client/pages/page-editor/els/page-editor.el.section.vue index 8de796e6d6..97f063a287 100644 --- a/src/client/pages/page-editor/els/page-editor.el.section.vue +++ b/src/client/pages/page-editor/els/page-editor.el.section.vue @@ -11,7 +11,7 @@
- +
@@ -37,7 +37,7 @@ export default Vue.extend({ value: { required: true }, - aiScript: { + aoiScript: { required: true, }, }, diff --git a/src/client/pages/page-editor/els/page-editor.el.text.vue b/src/client/pages/page-editor/els/page-editor.el.text.vue index 00b6cd8a36..c6722236eb 100644 --- a/src/client/pages/page-editor/els/page-editor.el.text.vue +++ b/src/client/pages/page-editor/els/page-editor.el.text.vue @@ -2,7 +2,7 @@ -
+
@@ -40,7 +40,7 @@ export default Vue.extend({ diff --git a/src/client/pages/page-editor/els/page-editor.el.textarea.vue b/src/client/pages/page-editor/els/page-editor.el.textarea.vue index fd75849684..d31da5dfa3 100644 --- a/src/client/pages/page-editor/els/page-editor.el.textarea.vue +++ b/src/client/pages/page-editor/els/page-editor.el.textarea.vue @@ -55,6 +55,7 @@ export default Vue.extend({ background: transparent; color: var(--fg); font-size: 14px; + box-sizing: border-box; } } diff --git a/src/client/pages/page-editor/page-editor.blocks.vue b/src/client/pages/page-editor/page-editor.blocks.vue index 4d7293231f..bfc75cada4 100644 --- a/src/client/pages/page-editor/page-editor.blocks.vue +++ b/src/client/pages/page-editor/page-editor.blocks.vue @@ -1,6 +1,6 @@ @@ -31,7 +31,7 @@ export default Vue.extend({ type: Array, required: true }, - aiScript: { + aoiScript: { required: true, }, }, diff --git a/src/client/pages/page-editor/page-editor.script-block.vue b/src/client/pages/page-editor/page-editor.script-block.vue index 4f30b7136b..7e3bbf0c88 100644 --- a/src/client/pages/page-editor/page-editor.script-block.vue +++ b/src/client/pages/page-editor/page-editor.script-block.vue @@ -2,7 +2,7 @@ @@ -24,30 +24,33 @@
+
+ +
{{ $t('_pages.script.blocks._fn.slots') }} - +
- +
- +
@@ -85,7 +88,7 @@ export default Vue.extend({ required: false, default: false }, - aiScript: { + aoiScript: { required: true, }, name: { @@ -153,7 +156,7 @@ export default Vue.extend({ if (this.value.type && this.value.type.startsWith('fn:')) { const fnName = this.value.type.split(':')[1]; - const fn = this.aiScript.getVarByName(fnName); + const fn = this.aoiScript.getVarByName(fnName); const empties = []; for (let i = 0; i < fn.value.slots.length; i++) { @@ -199,9 +202,9 @@ export default Vue.extend({ deep: true }); - this.$watch('aiScript.variables', () => { + this.$watch('aoiScript.variables', () => { if (this.type != null && this.value) { - this.error = this.aiScript.typeCheck(this.value); + this.error = this.aoiScript.typeCheck(this.value); } }, { deep: true @@ -223,7 +226,7 @@ export default Vue.extend({ }, _getExpectedType(slot: number) { - return this.aiScript.getExpectedType(this.value, slot); + return this.aoiScript.getExpectedType(this.value, slot); } } }); @@ -258,6 +261,7 @@ export default Vue.extend({ font-size: 16px; background: transparent; color: var(--fg); + box-sizing: border-box; } > textarea { diff --git a/src/client/pages/page-editor/page-editor.vue b/src/client/pages/page-editor/page-editor.vue index b3350e0c63..6177663b71 100644 --- a/src/client/pages/page-editor/page-editor.vue +++ b/src/client/pages/page-editor/page-editor.vue @@ -46,7 +46,7 @@ - + @@ -62,7 +62,7 @@ @input="v => updateVariable(v)" @remove="() => removeVariable(variable)" :key="variable.name" - :ai-script="aiScript" + :aoi-script="aoiScript" :name="variable.name" :title="variable.name" :draggable="true" @@ -73,11 +73,10 @@ - - -
- {{ $t('_pages.content') }} - {{ $t('_pages.variables') }} + + +
+
@@ -86,6 +85,9 @@