fix(frontend/aiscript): 各種関数の引数で明示的にnullが指定されている場合のハンドリングを修正 (#16838)
* fix(frontend/aiscript): MkDialogのtitle, textでnull値を許容するように * fix * update aiscript and use new api * fix * fix
This commit is contained in:
parent
666e046399
commit
f10496645c
|
|
@ -25,7 +25,7 @@
|
||||||
"@rollup/plugin-replace": "6.0.3",
|
"@rollup/plugin-replace": "6.0.3",
|
||||||
"@rollup/pluginutils": "5.3.0",
|
"@rollup/pluginutils": "5.3.0",
|
||||||
"@sentry/vue": "10.26.0",
|
"@sentry/vue": "10.26.0",
|
||||||
"@syuilo/aiscript": "1.1.2",
|
"@syuilo/aiscript": "1.2.0",
|
||||||
"@syuilo/aiscript-0-19-0": "npm:@syuilo/aiscript@^0.19.0",
|
"@syuilo/aiscript-0-19-0": "npm:@syuilo/aiscript@^0.19.0",
|
||||||
"@twemoji/parser": "16.0.0",
|
"@twemoji/parser": "16.0.0",
|
||||||
"@vitejs/plugin-vue": "6.0.2",
|
"@vitejs/plugin-vue": "6.0.2",
|
||||||
|
|
|
||||||
|
|
@ -40,29 +40,77 @@ export function createAiScriptEnv(opts: { storageKey: string, token?: string })
|
||||||
CUSTOM_EMOJIS: utils.jsToVal(customEmojis.value),
|
CUSTOM_EMOJIS: utils.jsToVal(customEmojis.value),
|
||||||
LOCALE: values.STR(lang),
|
LOCALE: values.STR(lang),
|
||||||
SERVER_URL: values.STR(url),
|
SERVER_URL: values.STR(url),
|
||||||
'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => {
|
'Mk:dialog': values.FN_NATIVE(async ([_title, _text, _type]) => {
|
||||||
utils.assertString(title);
|
let title: string | undefined = undefined;
|
||||||
utils.assertString(text);
|
let text: string | undefined = undefined;
|
||||||
if (type != null) {
|
let type: typeof DIALOG_TYPES[number] = 'info';
|
||||||
assertStringAndIsIn(type, DIALOG_TYPES);
|
|
||||||
|
if (_title != null) {
|
||||||
|
if (utils.isString(_title)) {
|
||||||
|
title = _title.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_text != null) {
|
||||||
|
if (utils.isString(_text)) {
|
||||||
|
text = _text.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_type != null) {
|
||||||
|
if (utils.isString(_type)) {
|
||||||
|
assertStringAndIsIn(_type, DIALOG_TYPES);
|
||||||
|
type = _type.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await os.alert({
|
await os.alert({
|
||||||
type: type ? type.value : 'info',
|
type,
|
||||||
title: title.value,
|
title,
|
||||||
text: text.value,
|
text,
|
||||||
});
|
});
|
||||||
return values.NULL;
|
return values.NULL;
|
||||||
}),
|
}),
|
||||||
'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => {
|
'Mk:confirm': values.FN_NATIVE(async ([_title, _text, _type]) => {
|
||||||
utils.assertString(title);
|
let title: string | undefined = undefined;
|
||||||
utils.assertString(text);
|
let text: string | undefined = undefined;
|
||||||
if (type != null) {
|
let type: typeof DIALOG_TYPES[number] = 'question';
|
||||||
assertStringAndIsIn(type, DIALOG_TYPES);
|
|
||||||
|
if (_title != null) {
|
||||||
|
if (utils.isString(_title)) {
|
||||||
|
title = _title.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_text != null) {
|
||||||
|
if (utils.isString(_text)) {
|
||||||
|
text = _text.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_type != null) {
|
||||||
|
if (utils.isString(_type)) {
|
||||||
|
assertStringAndIsIn(_type, DIALOG_TYPES);
|
||||||
|
type = _type.value;
|
||||||
|
} else {
|
||||||
|
utils.assertNull(_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const confirm = await os.confirm({
|
const confirm = await os.confirm({
|
||||||
type: type ? type.value : 'question',
|
type,
|
||||||
title: title.value,
|
title,
|
||||||
text: text.value,
|
text,
|
||||||
});
|
});
|
||||||
return confirm.canceled ? values.FALSE : values.TRUE;
|
return confirm.canceled ? values.FALSE : values.TRUE;
|
||||||
}),
|
}),
|
||||||
|
|
@ -76,15 +124,23 @@ export function createAiScriptEnv(opts: { storageKey: string, token?: string })
|
||||||
if (ep.value.includes('://') || ep.value.includes('..')) {
|
if (ep.value.includes('://') || ep.value.includes('..')) {
|
||||||
throw new errors.AiScriptRuntimeError('invalid endpoint');
|
throw new errors.AiScriptRuntimeError('invalid endpoint');
|
||||||
}
|
}
|
||||||
if (token) {
|
|
||||||
|
let actualToken: string | null = null;
|
||||||
|
if (token != null && !utils.isNull(token)) {
|
||||||
utils.assertString(token);
|
utils.assertString(token);
|
||||||
// バグがあればundefinedもあり得るため念のため
|
// バグがあればundefinedもあり得るため念のため
|
||||||
if (typeof token.value !== 'string') throw new Error('invalid token');
|
if (typeof token.value !== 'string') throw new errors.AiScriptRuntimeError('invalid token');
|
||||||
|
actualToken = token.value;
|
||||||
}
|
}
|
||||||
const actualToken: string | null = token?.value ?? opts.token ?? null;
|
|
||||||
|
if (actualToken == null) {
|
||||||
|
actualToken = opts.token ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
if (param == null) {
|
if (param == null) {
|
||||||
throw new errors.AiScriptRuntimeError('expected param');
|
throw new errors.AiScriptRuntimeError('expected param');
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.assertObject(param);
|
utils.assertObject(param);
|
||||||
return misskeyApi(ep.value as keyof Misskey.Endpoints, utils.valToJs(param) as object, actualToken).then(res => {
|
return misskeyApi(ep.value as keyof Misskey.Endpoints, utils.valToJs(param) as object, actualToken).then(res => {
|
||||||
return utils.jsToVal(res);
|
return utils.jsToVal(res);
|
||||||
|
|
|
||||||
|
|
@ -729,8 +729,8 @@ importers:
|
||||||
specifier: 10.26.0
|
specifier: 10.26.0
|
||||||
version: 10.26.0(vue@3.5.24(typescript@5.9.3))
|
version: 10.26.0(vue@3.5.24(typescript@5.9.3))
|
||||||
'@syuilo/aiscript':
|
'@syuilo/aiscript':
|
||||||
specifier: 1.1.2
|
specifier: 1.2.0
|
||||||
version: 1.1.2
|
version: 1.2.0
|
||||||
'@syuilo/aiscript-0-19-0':
|
'@syuilo/aiscript-0-19-0':
|
||||||
specifier: npm:@syuilo/aiscript@^0.19.0
|
specifier: npm:@syuilo/aiscript@^0.19.0
|
||||||
version: '@syuilo/aiscript@0.19.0'
|
version: '@syuilo/aiscript@0.19.0'
|
||||||
|
|
@ -4459,8 +4459,8 @@ packages:
|
||||||
'@syuilo/aiscript@0.19.0':
|
'@syuilo/aiscript@0.19.0':
|
||||||
resolution: {integrity: sha512-ZWG4s1m6RrFjE7NeIMaxFz769YO1jW5ReTrOROrEO4IHheOrjxxJ/Ffe2TUNqX9/XxDloMwfWplKhfSzx8LGMA==}
|
resolution: {integrity: sha512-ZWG4s1m6RrFjE7NeIMaxFz769YO1jW5ReTrOROrEO4IHheOrjxxJ/Ffe2TUNqX9/XxDloMwfWplKhfSzx8LGMA==}
|
||||||
|
|
||||||
'@syuilo/aiscript@1.1.2':
|
'@syuilo/aiscript@1.2.0':
|
||||||
resolution: {integrity: sha512-cijsHTiMjeECocElyjRIcWMPGDhZIX3YfCOyzI6AZM8ajxRQ2hSqJwEh9pDr4mVTml9kLMHWDHmgfHkTHRJ1sg==}
|
resolution: {integrity: sha512-3MkKfqDftqHyouINgHEIHnoTVWEeL0L1o7Y7Y9d8qb5h5vZKphzH/KVG3R2iI6CHtmO1mWHHJx5A499f80H9FA==}
|
||||||
|
|
||||||
'@szmarczak/http-timer@5.0.1':
|
'@szmarczak/http-timer@5.0.1':
|
||||||
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
|
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
|
||||||
|
|
@ -14858,7 +14858,7 @@ snapshots:
|
||||||
stringz: 2.1.0
|
stringz: 2.1.0
|
||||||
uuid: 9.0.1
|
uuid: 9.0.1
|
||||||
|
|
||||||
'@syuilo/aiscript@1.1.2':
|
'@syuilo/aiscript@1.2.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
seedrandom: 3.0.5
|
seedrandom: 3.0.5
|
||||||
stringz: 2.1.0
|
stringz: 2.1.0
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,4 @@ onlyBuiltDependencies:
|
||||||
ignorePatchFailures: false
|
ignorePatchFailures: false
|
||||||
minimumReleaseAge: 10080 # delay 7days to mitigate supply-chain attack
|
minimumReleaseAge: 10080 # delay 7days to mitigate supply-chain attack
|
||||||
minimumReleaseAgeExclude:
|
minimumReleaseAgeExclude:
|
||||||
|
- '@syuilo/aiscript'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue