feat: add newBootloaderQuery method

This commit is contained in:
Derrick Hammer 2023-09-11 06:39:21 -04:00
parent cce4884dc3
commit 85615350f0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 24 additions and 0 deletions

View File

@ -677,6 +677,29 @@ function newKernelQuery(
return [sendUpdate, p];
}
function newBootloaderQuery(method: string, data: any): Promise<any> {
return new Promise((resolve) => {
let receiveResponse = function (data: any) {
resolve(data.data);
};
initDefer.promise.then(() => {
if (getKernelIframe().contentWindow === null) {
console.error(
"kernelFrame.contentWindow was null, cannot send message!",
);
return;
}
let nonce = nextNonce();
queries[nonce] = { resolve: receiveResponse };
getKernelIframe().contentWindow?.postMessage(
{ method, data },
kernelOrigin,
);
});
});
}
export {
callModule,
connectModule,
@ -688,4 +711,5 @@ export {
newKernelQuery,
serviceWorkerReady,
getKernelIframe,
newBootloaderQuery,
};