Scratchpadに非同期のエラーを処理する機能を追加 (#11850)
* opts.callをtopCallに置換 * AiScriptのエラーコールバックをscratchpadに導入 * lint * Update CHANGELOG.md
This commit is contained in:
parent
b0f6c44f36
commit
578b0ebe0c
|
@ -57,6 +57,7 @@
|
||||||
- AiScriptを0.16.0に更新
|
- AiScriptを0.16.0に更新
|
||||||
- Mk:apiが失敗した時にエラー型の値(AiScript 0.16.0で追加)を返すように
|
- Mk:apiが失敗した時にエラー型の値(AiScript 0.16.0で追加)を返すように
|
||||||
- タイムラインでリスト/アンテナ選択時のパフォーマンスを改善
|
- タイムラインでリスト/アンテナ選択時のパフォーマンスを改善
|
||||||
|
- ScratchpadでAsync:系関数やボタンのコールバックなどのエラーにもダイアログを出すように(試験的なためPlayなどには未実装)
|
||||||
- 「Moderation note」、「Add moderation note」をローカライズできるように
|
- 「Moderation note」、「Add moderation note」をローカライズできるように
|
||||||
- 新しい実績を追加
|
- 新しい実績を追加
|
||||||
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
|
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
|
||||||
|
|
|
@ -109,6 +109,13 @@ async function run() {
|
||||||
print: true,
|
print: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
err: (err) => {
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
title: 'AiScript Error',
|
||||||
|
text: err.toString(),
|
||||||
|
});
|
||||||
|
},
|
||||||
log: (type, params) => {
|
log: (type, params) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'end': logs.value.push({
|
case 'end': logs.value.push({
|
||||||
|
@ -124,20 +131,23 @@ async function run() {
|
||||||
let ast;
|
let ast;
|
||||||
try {
|
try {
|
||||||
ast = parser.parse(code.value);
|
ast = parser.parse(code.value);
|
||||||
} catch (error) {
|
} catch (err: any) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: 'Syntax error :(',
|
title: 'Syntax Error',
|
||||||
|
text: err.toString(),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await aiscript.exec(ast);
|
await aiscript.exec(ast);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
// AiScript runtime errors should be processed by error callback function
|
||||||
|
// so errors caught here are AiScript's internal errors.
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'AiScript Error',
|
title: 'Internal Error',
|
||||||
text: err.message,
|
text: err.toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,55 +551,55 @@ export function registerAsUiLib(components: Ref<AsUiComponent>[], done: (root: R
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:container': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:container': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('container', def, id, getContainerOptions, opts.call);
|
return createComponentInstance('container', def, id, getContainerOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:text': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:text': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('text', def, id, getTextOptions, opts.call);
|
return createComponentInstance('text', def, id, getTextOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:mfm': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:mfm': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('mfm', def, id, getMfmOptions, opts.call);
|
return createComponentInstance('mfm', def, id, getMfmOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:textarea': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:textarea': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('textarea', def, id, getTextareaOptions, opts.call);
|
return createComponentInstance('textarea', def, id, getTextareaOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:textInput': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:textInput': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('textInput', def, id, getTextInputOptions, opts.call);
|
return createComponentInstance('textInput', def, id, getTextInputOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:numberInput': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:numberInput': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('numberInput', def, id, getNumberInputOptions, opts.call);
|
return createComponentInstance('numberInput', def, id, getNumberInputOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:button': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:button': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('button', def, id, getButtonOptions, opts.call);
|
return createComponentInstance('button', def, id, getButtonOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:buttons': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:buttons': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('buttons', def, id, getButtonsOptions, opts.call);
|
return createComponentInstance('buttons', def, id, getButtonsOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:switch': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:switch': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('switch', def, id, getSwitchOptions, opts.call);
|
return createComponentInstance('switch', def, id, getSwitchOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:select': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:select': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('select', def, id, getSelectOptions, opts.call);
|
return createComponentInstance('select', def, id, getSelectOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:folder': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:folder': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('folder', def, id, getFolderOptions, opts.call);
|
return createComponentInstance('folder', def, id, getFolderOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:postFormButton': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:postFormButton': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('postFormButton', def, id, getPostFormButtonOptions, opts.call);
|
return createComponentInstance('postFormButton', def, id, getPostFormButtonOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Ui:C:postForm': values.FN_NATIVE(([def, id], opts) => {
|
'Ui:C:postForm': values.FN_NATIVE(([def, id], opts) => {
|
||||||
return createComponentInstance('postForm', def, id, getPostFormOptions, opts.call);
|
return createComponentInstance('postForm', def, id, getPostFormOptions, opts.topCall);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue