refactor: change bootup process to setup all modules when authStatus is emitted and loginComplete is true
This commit is contained in:
parent
501b208ade
commit
0eb3209aa2
|
@ -6,29 +6,65 @@ import WebEngine from "../../webEngine.js";
|
||||||
import InternalProvider from "../../contentProviders/internalProvider.js";
|
import InternalProvider from "../../contentProviders/internalProvider.js";
|
||||||
import IpfsProvider from "../../contentProviders/ipfsProvider.js";
|
import IpfsProvider from "../../contentProviders/ipfsProvider.js";
|
||||||
import ServerProvider from "../../contentProviders/serverProvider.js";
|
import ServerProvider from "../../contentProviders/serverProvider.js";
|
||||||
import { getKernelIframe, setKernelIframe, weAreBooted } from "../../vars.js";
|
import { events, getKernelIframe, setKernelIframe } from "../../vars.js";
|
||||||
import { init } from "@lumeweb/libkernel/kernel";
|
import { init } from "@lumeweb/libkernel/kernel";
|
||||||
|
import {
|
||||||
|
dnsClient,
|
||||||
|
ethClient,
|
||||||
|
handshakeClient,
|
||||||
|
ipfsClient,
|
||||||
|
networkRegistryClient,
|
||||||
|
peerDiscoveryClient,
|
||||||
|
swarmClient,
|
||||||
|
} from "../../clients.js";
|
||||||
|
import { KernelAuthStatus } from "@lumeweb/libweb";
|
||||||
|
|
||||||
|
let engine: WebEngine;
|
||||||
|
|
||||||
export async function boot() {
|
export async function boot() {
|
||||||
tldEnum.list.push("localhost");
|
tldEnum.list.push("localhost");
|
||||||
window.addEventListener("message", handleKernelMessage);
|
window.addEventListener("message", handleKernelMessage);
|
||||||
browser.runtime.onConnect.addListener(bridgeListener);
|
browser.runtime.onConnect.addListener(bridgeListener);
|
||||||
|
|
||||||
const engine = new WebEngine();
|
engine = new WebEngine();
|
||||||
engine.registerContentProvider(new InternalProvider(engine));
|
engine.registerContentProvider(new InternalProvider(engine));
|
||||||
|
|
||||||
engine.registerContentProvider(new IpfsProvider(engine));
|
|
||||||
engine.registerContentProvider(new ServerProvider(engine));
|
|
||||||
|
|
||||||
setKernelIframe(document.createElement("iframe"));
|
setKernelIframe(document.createElement("iframe"));
|
||||||
getKernelIframe().src = "http://kernel.lume";
|
getKernelIframe().src = "http://kernel.lume";
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
getKernelIframe().onload = init;
|
||||||
getKernelIframe().onload = () => {
|
document.body.appendChild(getKernelIframe());
|
||||||
init().then(resolve);
|
events.on("authStatus", async (changes: KernelAuthStatus) => {
|
||||||
};
|
if (changes.loginComplete) {
|
||||||
document.body.appendChild(getKernelIframe());
|
await doInit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
weAreBooted();
|
|
||||||
|
export async function doInit() {
|
||||||
|
engine.registerContentProvider(new IpfsProvider(engine));
|
||||||
|
engine.registerContentProvider(new ServerProvider(engine));
|
||||||
|
|
||||||
|
await swarmClient.addRelay(
|
||||||
|
"2d7ae1517caf4aae4de73c6d6f400765d2dd00b69d65277a29151437ef1c7d1d",
|
||||||
|
);
|
||||||
|
// IRC
|
||||||
|
await peerDiscoveryClient.register(
|
||||||
|
"zduL5de7GC5DVpf92FkShUZZrTpUi6hki2BaTaVwjs9cnmCmKWNywBWyHR",
|
||||||
|
);
|
||||||
|
|
||||||
|
await networkRegistryClient.registerType("content");
|
||||||
|
await networkRegistryClient.registerType("blockchain");
|
||||||
|
await handshakeClient.register();
|
||||||
|
await ethClient.register();
|
||||||
|
await ipfsClient.register();
|
||||||
|
|
||||||
|
const resolvers = [
|
||||||
|
"zduR2MPhx4qMxNwmM2GzFBdbgr1gvA33iM9Ve8RxL4SF4msWAy9RwiDGjq", // ENS
|
||||||
|
"zduMGDuZ1juBTn6sNS4J1eT81wb8RMswacXEVGmgWKm8snY7viketDsYsZ", // HNS
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const resolver of resolvers) {
|
||||||
|
await dnsClient.registerResolver(resolver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue