summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-08-06 13:32:59 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-08-06 13:32:59 +0900
commit998beeae59bbe9c272e3248b29b89a07259a3624 (patch)
tree4b209b8b18b0aac8d94afa906b976e1d30f5c96d
parent🎨 (diff)
downloadmisskey-998beeae59bbe9c272e3248b29b89a07259a3624.tar.gz
misskey-998beeae59bbe9c272e3248b29b89a07259a3624.tar.bz2
misskey-998beeae59bbe9c272e3248b29b89a07259a3624.zip
feat(frontend): AiScriptを1.0に更新
Close #16277
-rw-r--r--CHANGELOG.md4
-rw-r--r--packages/frontend/package.json3
-rw-r--r--packages/frontend/src/components/MkNote.vue28
-rw-r--r--packages/frontend/src/components/MkNoteDetailed.vue27
-rw-r--r--packages/frontend/src/pages/flash/flash-edit.vue8
-rw-r--r--packages/frontend/src/pages/flash/flash.vue10
-rw-r--r--packages/frontend/src/plugin.ts8
-rw-r--r--pnpm-lock.yaml18
8 files changed, 62 insertions, 44 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0b23ed891..4734033c54 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,10 @@
- Fix: Unicode絵文字に隣接する異体字セレクタ(`U+FE0F`)が絵文字として認識される問題を修正
### Client
+- Feat: AiScriptが1.0に更新されました
+ - プラグインは1.0に対応したものが必要です
+ - Playはそのまま動作しますが、新規に作られるプリセットは1.0になります
+ - 以前のバージョンから無効化されていた note_view_interruptor が有効になりました
- Feat: セーフモード
- プラグイン・テーマ・カスタムCSSの使用でクライアントの起動に問題が発生した際に、これらを無効にして起動できます
- 以下の方法でセーフモードを起動できます
diff --git a/packages/frontend/package.json b/packages/frontend/package.json
index e2880bee7e..f4f72d944a 100644
--- a/packages/frontend/package.json
+++ b/packages/frontend/package.json
@@ -25,7 +25,8 @@
"@rollup/plugin-replace": "6.0.2",
"@rollup/pluginutils": "5.2.0",
"@sentry/vue": "10.0.0",
- "@syuilo/aiscript": "0.19.0",
+ "@syuilo/aiscript": "1.0.0",
+ "@syuilo/aiscript-0-19-0": "npm:@syuilo/aiscript@^0.19.0",
"@twemoji/parser": "16.0.0",
"@vitejs/plugin-vue": "6.0.1",
"@vue/compiler-sfc": "3.5.18",
diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue
index b9cb37e99a..043af4cc96 100644
--- a/packages/frontend/src/components/MkNote.vue
+++ b/packages/frontend/src/components/MkNote.vue
@@ -265,21 +265,19 @@ const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', nul
let note = deepClone(props.note);
-// コンポーネント初期化に非同期的な処理を行うとTransitionのレンダリングがバグるため同期的に実行できるメソッドが実装されるのを待つ必要がある
-// https://github.com/aiscript-dev/aiscript/issues/937
-//// plugin
-//const noteViewInterruptors = getPluginHandlers('note_view_interruptor');
-//if (noteViewInterruptors.length > 0) {
-// let result: Misskey.entities.Note | null = deepClone(note);
-// for (const interruptor of noteViewInterruptors) {
-// try {
-// result = await interruptor.handler(result!) as Misskey.entities.Note | null;
-// } catch (err) {
-// console.error(err);
-// }
-// }
-// note = result as Misskey.entities.Note;
-//}
+// plugin
+const noteViewInterruptors = getPluginHandlers('note_view_interruptor');
+if (noteViewInterruptors.length > 0) {
+ let result: Misskey.entities.Note | null = deepClone(note);
+ for (const interruptor of noteViewInterruptors) {
+ try {
+ result = interruptor.handler(result!) as Misskey.entities.Note | null;
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ note = result as Misskey.entities.Note;
+}
const isRenote = Misskey.note.isPureRenote(note);
const appearNote = getAppearNote(note) ?? note;
diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue
index c04959b97a..f3e990e65a 100644
--- a/packages/frontend/src/components/MkNoteDetailed.vue
+++ b/packages/frontend/src/components/MkNoteDetailed.vue
@@ -287,20 +287,19 @@ const inChannel = inject('inChannel', null);
let note = deepClone(props.note);
-// コンポーネント初期化に非同期的な処理を行うとTransitionのレンダリングがバグるため同期的に実行できるメソッドが実装されるのを待つ必要がある
-//// plugin
-//const noteViewInterruptors = getPluginHandlers('note_view_interruptor');
-//if (noteViewInterruptors.length > 0) {
-// let result: Misskey.entities.Note | null = deepClone(note);
-// for (const interruptor of noteViewInterruptors) {
-// try {
-// result = await interruptor.handler(result!) as Misskey.entities.Note | null;
-// } catch (err) {
-// console.error(err);
-// }
-// }
-// note = result as Misskey.entities.Note;
-//}
+// plugin
+const noteViewInterruptors = getPluginHandlers('note_view_interruptor');
+if (noteViewInterruptors.length > 0) {
+ let result: Misskey.entities.Note | null = deepClone(note);
+ for (const interruptor of noteViewInterruptors) {
+ try {
+ result = interruptor.handler(result!) as Misskey.entities.Note | null;
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ note = result as Misskey.entities.Note;
+}
const isRenote = Misskey.note.isPureRenote(note);
const appearNote = getAppearNote(note);
diff --git a/packages/frontend/src/pages/flash/flash-edit.vue b/packages/frontend/src/pages/flash/flash-edit.vue
index a964b33a52..bf4911f648 100644
--- a/packages/frontend/src/pages/flash/flash-edit.vue
+++ b/packages/frontend/src/pages/flash/flash-edit.vue
@@ -88,7 +88,7 @@ let choices = [
]
// シードが「PlayID+ユーザーID+今日の日付」である乱数生成器を用意
-let random = Math:gen_rng(\`{THIS_ID}{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`)
+let random = Math:gen_rng(\`{THIS_ID}{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`, { algorithm: 'rc4_legacy' })
// ランダムに選択肢を選ぶ
let chosen = choices[random(0, (choices.len - 1))]
@@ -127,7 +127,7 @@ var results = []
// どれだけ巻き戻しているか
var cursor = 0
-@do() {
+@main() {
if (cursor != 0) {
results = results.slice(0, (cursor + 1))
cursor = 0
@@ -175,7 +175,7 @@ var cursor = 0
onClick: forward
}, {
text: "引き直す"
- onClick: do
+ onClick: main
}]
})
Ui:C:postFormButton({
@@ -191,7 +191,7 @@ var cursor = 0
])
}
-do()
+main()
`;
const PRESET_QUIZ = `/// @ ${AISCRIPT_VERSION}
diff --git a/packages/frontend/src/pages/flash/flash.vue b/packages/frontend/src/pages/flash/flash.vue
index 8443293d34..560d2a46ea 100644
--- a/packages/frontend/src/pages/flash/flash.vue
+++ b/packages/frontend/src/pages/flash/flash.vue
@@ -63,11 +63,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { computed, onDeactivated, onUnmounted, ref, watch, shallowRef, defineAsyncComponent } from 'vue';
import * as Misskey from 'misskey-js';
-import { Interpreter, Parser, values } from '@syuilo/aiscript';
import { url } from '@@/js/config.js';
import type { Ref } from 'vue';
import type { AsUiComponent, AsUiRoot } from '@/aiscript/ui.js';
import type { MenuItem } from '@/types/menu.js';
+import type { Interpreter } from '@syuilo/aiscript';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/utility/misskey-api.js';
@@ -180,8 +180,6 @@ async function unlike() {
watch(() => props.id, fetchFlash, { immediate: true });
-const parser = new Parser();
-
const started = ref(false);
const aiscript = shallowRef<Interpreter | null>(null);
const root = ref<AsUiRoot>();
@@ -196,6 +194,12 @@ async function run() {
if (aiscript.value) aiscript.value.abort();
if (!flash.value) return;
+ const isLegacy = !flash.value.script.replaceAll(' ', '').startsWith('///@1.0.0');
+
+ const { Interpreter, Parser, values } = isLegacy ? await import('@syuilo/aiscript-0-19-0') : await import('@syuilo/aiscript');
+
+ const parser = new Parser();
+
components.value = [];
aiscript.value = new Interpreter({
diff --git a/packages/frontend/src/plugin.ts b/packages/frontend/src/plugin.ts
index 5610ae7095..d47c6cd0e5 100644
--- a/packages/frontend/src/plugin.ts
+++ b/packages/frontend/src/plugin.ts
@@ -7,15 +7,15 @@ import { ref, defineAsyncComponent } from 'vue';
import { Interpreter, Parser, utils, values } from '@syuilo/aiscript';
import { compareVersions } from 'compare-versions';
import { isSafeMode } from '@@/js/config.js';
-import { genId } from '@/utility/id.js';
import * as Misskey from 'misskey-js';
+import type { FormWithDefault } from '@/utility/form.js';
+import { genId } from '@/utility/id.js';
import { aiScriptReadline, createAiScriptEnv } from '@/aiscript/api.js';
import { store } from '@/store.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/utility/misskey-api.js';
import { i18n } from '@/i18n.js';
import { prefer } from '@/preferences.js';
-import type { FormWithDefault } from '@/utility/form.js';
export type Plugin = {
installId: string;
@@ -394,8 +394,8 @@ function createPluginEnv(opts: { plugin: Plugin; storageKey: string }): Record<s
'Plugin:register:note_view_interruptor': values.FN_NATIVE(([handler]) => {
utils.assertFunction(handler);
addPluginHandler(id, 'note_view_interruptor', {
- handler: withContext(ctx => async (note) => {
- return utils.valToJs(await ctx.execFn(handler, [utils.jsToVal(note)]));
+ handler: withContext(ctx => (note) => {
+ return utils.valToJs(ctx.execFnSync(handler, [utils.jsToVal(note)]));
}),
});
}),
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8249aa52e2..8121822fb7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -731,8 +731,11 @@ importers:
specifier: 10.0.0
version: 10.0.0(vue@3.5.18(typescript@5.9.2))
'@syuilo/aiscript':
- specifier: 0.19.0
- version: 0.19.0
+ specifier: 1.0.0
+ version: 1.0.0
+ '@syuilo/aiscript-0-19-0':
+ specifier: npm:@syuilo/aiscript@^0.19.0
+ version: '@syuilo/aiscript@0.19.0'
'@twemoji/parser':
specifier: 16.0.0
version: 16.0.0
@@ -4302,6 +4305,9 @@ packages:
'@syuilo/aiscript@0.19.0':
resolution: {integrity: sha512-ZWG4s1m6RrFjE7NeIMaxFz769YO1jW5ReTrOROrEO4IHheOrjxxJ/Ffe2TUNqX9/XxDloMwfWplKhfSzx8LGMA==}
+ '@syuilo/aiscript@1.0.0':
+ resolution: {integrity: sha512-m+Dxx0g2pDI198OCj/OJgiJnE4ajlbOFAMyh84FmbY1S8ss/MHytxY82dCnMZj5WVt7VE7a1rtW7biuRRfuyaA==}
+
'@szmarczak/http-timer@5.0.1':
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
engines: {node: '>=14.16'}
@@ -14637,7 +14643,7 @@ snapshots:
eslint-visitor-keys: 4.2.1
espree: 10.4.0
estraverse: 5.3.0
- picomatch: 4.0.2
+ picomatch: 4.0.3
transitivePeerDependencies:
- supports-color
- typescript
@@ -14735,6 +14741,12 @@ snapshots:
stringz: 2.1.0
uuid: 9.0.1
+ '@syuilo/aiscript@1.0.0':
+ dependencies:
+ seedrandom: 3.0.5
+ stringz: 2.1.0
+ uuid: 11.1.0
+
'@szmarczak/http-timer@5.0.1':
dependencies:
defer-to-connect: 2.0.1