*Refactor background to start everything up in a boot function
*Preload the dns and rpc subsystem with the dns ready call
This commit is contained in:
parent
5be2d72d48
commit
25db9704ce
|
@ -6,6 +6,7 @@ import SkynetProvider from "../contentProviders/skynetProvider.js";
|
||||||
import ServerProvider from "../contentProviders/serverProvider.js";
|
import ServerProvider from "../contentProviders/serverProvider.js";
|
||||||
import { init } from "libkernel";
|
import { init } from "libkernel";
|
||||||
import IpfsProvider from "../contentProviders/ipfsProvider.js";
|
import IpfsProvider from "../contentProviders/ipfsProvider.js";
|
||||||
|
import { ready as dnsReady } from "@lumeweb/kernel-dns-client";
|
||||||
|
|
||||||
declare var browser: any; // tsc
|
declare var browser: any; // tsc
|
||||||
let queriesNonce = 1;
|
let queriesNonce = 1;
|
||||||
|
@ -38,8 +39,7 @@ let blockForBootloader = new Promise((resolve) => {
|
||||||
let blockForBridge = new Promise((resolve) => {
|
let blockForBridge = new Promise((resolve) => {
|
||||||
bridgeLoadedResolve = resolve;
|
bridgeLoadedResolve = resolve;
|
||||||
});
|
});
|
||||||
|
let kernelFrame: HTMLIFrameElement;
|
||||||
tldEnum.list.push("localhost");
|
|
||||||
|
|
||||||
export function queryKernel(query: any): Promise<any> {
|
export function queryKernel(query: any): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@ -132,7 +132,6 @@ function handleKernelMessage(event: MessageEvent) {
|
||||||
|
|
||||||
receiveResult(event.data);
|
receiveResult(event.data);
|
||||||
}
|
}
|
||||||
window.addEventListener("message", handleKernelMessage);
|
|
||||||
|
|
||||||
function handleBridgeMessage(
|
function handleBridgeMessage(
|
||||||
port: any,
|
port: any,
|
||||||
|
@ -186,16 +185,25 @@ function bridgeListener(port: any) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
browser.runtime.onConnect.addListener(bridgeListener);
|
|
||||||
|
|
||||||
const engine = new WebEngine();
|
async function boot() {
|
||||||
engine.registerContentProvider(new InternalProvider(engine));
|
tldEnum.list.push("localhost");
|
||||||
engine.registerContentProvider(new ServerProvider(engine));
|
window.addEventListener("message", handleKernelMessage);
|
||||||
engine.registerContentProvider(new SkynetProvider(engine));
|
browser.runtime.onConnect.addListener(bridgeListener);
|
||||||
engine.registerContentProvider(new IpfsProvider(engine));
|
|
||||||
|
|
||||||
// @ts-ignore
|
const engine = new WebEngine();
|
||||||
let kernelFrame: HTMLIFrameElement = document.createElement("iframe");
|
engine.registerContentProvider(new InternalProvider(engine));
|
||||||
kernelFrame.src = "http://kernel.skynet";
|
engine.registerContentProvider(new ServerProvider(engine));
|
||||||
kernelFrame.onload = init;
|
engine.registerContentProvider(new SkynetProvider(engine));
|
||||||
document.body.appendChild(kernelFrame);
|
engine.registerContentProvider(new IpfsProvider(engine));
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
kernelFrame = document.createElement("iframe");
|
||||||
|
kernelFrame.src = "http://kernel.skynet";
|
||||||
|
kernelFrame.onload = init;
|
||||||
|
document.body.appendChild(kernelFrame);
|
||||||
|
|
||||||
|
await dnsReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
boot();
|
||||||
|
|
Reference in New Issue