forked from mirrors/misskey
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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)]));
|
||||
}),
|
||||
});
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user