diff --git a/src/components/App.tsx b/src/components/App.tsx
index 50e52dc..dfa4396 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -1,19 +1,19 @@
-import {
- Browser,
- BrowserStateProvider,
- Navigator,
-} from "@/components/Browser.tsx";
-import Lume from "@/components/Lume.tsx";
import {
AuthProvider,
LumeStatusProvider,
NetworksProvider,
} from "@lumeweb/sdk";
-export default function () {
+import {
+ Browser,
+ BrowserStateProvider,
+ Navigator,
+} from "@/components/Browser.tsx";
+import Lume from "@/components/Lume.tsx";
+
+const App: React.FC = () => {
return (
- <>
@@ -30,7 +30,8 @@ export default function () {
- >
);
}
+
+export default App;
diff --git a/src/components/Browser.tsx b/src/components/Browser.tsx
index d07787f..b6d19d9 100644
--- a/src/components/Browser.tsx
+++ b/src/components/Browser.tsx
@@ -65,19 +65,24 @@ export function useBrowserState() {
return context;
}
-async function boot(status: LumeStatusContextType, auth: AuthContextType) {
+async function boot({
+ onInit,
+ onAuth,
+ onBoot,
+}: {onInit: (inited: boolean) => Promise | void, onAuth: (authed: boolean) => Promise | void, onBoot: (booted: boolean) => Promise | void}) {
const reg = await navigator.serviceWorker.register("/sw.js");
await reg.update();
await kernel.serviceWorkerReady();
- kernel.init().then(() => {
- status.setInited(true);
+ await kernel.init().catch((err) => {
+ console.error("[Browser.tsx] Failed to init kernel", {error: err});
});
-
- await kernelLoaded();
-
- auth.setIsLoggedIn(true);
+ await onInit(true);
+ await kernelLoaded().catch((err) => {
+ console.error("[Browser.tsx] Failed to load kernel", {error: err});
+ });
+ await onAuth(true);
BOOT_FUNCTIONS.push(
async () =>
@@ -112,7 +117,7 @@ async function boot(status: LumeStatusContextType, auth: AuthContextType) {
for (const resolver of resolvers) {
BOOT_FUNCTIONS.push(async () => dnsClient.registerResolver(resolver));
}
- BOOT_FUNCTIONS.push(async () => status.setReady(true));
+ BOOT_FUNCTIONS.push(async () => onBoot(true));
await bootup();
@@ -186,7 +191,17 @@ export function Browser() {
const iframeRef = useRef(null);
useEffect(() => {
- boot(status, auth);
+ boot({
+ onAuth(authed) {
+ auth.setIsLoggedIn(authed)
+ },
+ onBoot(booted) {
+ status.setReady(booted)
+ },
+ onInit(inited) {
+ status.setInited(inited)
+ }
+ }).catch((err) => console.error("[Browser.tsx] Failed to Boot Lume", {error: err}));
}, []);
const handleIframeLoad = () => {
diff --git a/src/components/Lume.tsx b/src/components/Lume.tsx
index aa6cc91..d08629a 100644
--- a/src/components/Lume.tsx
+++ b/src/components/Lume.tsx
@@ -6,7 +6,7 @@ import {
useLumeStatus,
} from "@lumeweb/sdk";
-export default function () {
+const Lume: React.FC = () => {
const { isLoggedIn } = useAuth();
const { ready, inited } = useLumeStatus();
@@ -30,3 +30,5 @@ export default function () {
>
);
}
+
+export default Lume;
\ No newline at end of file