[feat] add plugin addCharaJS

This commit is contained in:
kwaroran
2023-11-11 13:26:58 +09:00
parent 8fe2da4aec
commit 55f508bff7
5 changed files with 88 additions and 27 deletions

View File

@@ -173,6 +173,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
body: char
});
}
function addCharaJs(code, position) {
if (position === void 0) { position = 'back'; }
var codeString = code.toString().replace(/.+?\{/, '{');
postMessage({
type: 'addCharaJs',
body: {
code: codeString,
position: position
}
});
}
function handleOnmessage(data) {
return __awaiter(this, void 0, void 0, function () {
var _a, body, providers, providerfunc, _i, providers_1, provider, _b, error_1;

View File

@@ -119,6 +119,17 @@
body: char
})
}
function addCharaJs(code:Function, position:'front'|'back' = 'back'){
const codeString = code.toString().replace(/.+?\{/, '{')
postMessage({
type: 'addCharaJs',
body: {
code: codeString,
position: position
}
})
}
async function handleOnmessage(data:{type:string,body:any}) {
if(!data.type){