feat: add newBootloaderQuery method
This commit is contained in:
parent
cce4884dc3
commit
85615350f0
|
@ -677,6 +677,29 @@ function newKernelQuery(
|
||||||
return [sendUpdate, p];
|
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 {
|
export {
|
||||||
callModule,
|
callModule,
|
||||||
connectModule,
|
connectModule,
|
||||||
|
@ -688,4 +711,5 @@ export {
|
||||||
newKernelQuery,
|
newKernelQuery,
|
||||||
serviceWorkerReady,
|
serviceWorkerReady,
|
||||||
getKernelIframe,
|
getKernelIframe,
|
||||||
|
newBootloaderQuery,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue