From 30aae4f846c34ce0c413f2909f7c5ebedf597615 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 1 May 2026 18:52:20 +0200 Subject: [PATCH] auto-git: [change] src/main.tsx --- src/main.tsx | 60 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index bb9a15f3..f5dfb4e7 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,7 +4,11 @@ import ReactDOM from "react-dom/client"; import { App } from "./app/App"; import "./app/app.css"; import { createEditorStore } from "./app/editor-store"; -import { getBrowserStorageAccess, loadOrCreateSceneDocument } from "./serialization/local-draft-storage"; +import { + createBrowserEditorDraftStorage, + loadOrCreateEditorDraft +} from "./serialization/editor-draft-storage"; +import { getBrowserStorageAccess } from "./serialization/local-draft-storage"; const rootElement = document.getElementById("root"); @@ -12,21 +16,45 @@ if (rootElement === null) { throw new Error("Expected #root element to bootstrap the editor."); } -const storageAccess = getBrowserStorageAccess(); -const bootstrapResult = loadOrCreateSceneDocument(storageAccess.storage); -const editorStore = createEditorStore({ - initialProjectDocument: bootstrapResult.document, - initialViewportLayoutState: bootstrapResult.viewportLayoutState ?? undefined, - storage: storageAccess.storage -}); -const initialStatusMessage = [storageAccess.diagnostic, bootstrapResult.diagnostic].filter(Boolean).join(" ") || undefined; +async function bootstrapEditor() { + const storageAccess = getBrowserStorageAccess(); + const draftStorageAccess = await createBrowserEditorDraftStorage({ + legacyStorage: storageAccess.storage + }); + const bootstrapResult = await loadOrCreateEditorDraft( + draftStorageAccess.storage + ); + const editorStore = createEditorStore({ + initialProjectDocument: bootstrapResult.document, + initialViewportLayoutState: bootstrapResult.viewportLayoutState ?? undefined, + storage: storageAccess.storage + }); + const initialStatusMessage = + [ + storageAccess.diagnostic, + draftStorageAccess.diagnostic, + bootstrapResult.diagnostic + ] + .filter(Boolean) + .join(" ") || undefined; -if (import.meta.env.DEV) { - (window as Window & { __webeditor3dEditorStore?: typeof editorStore }).__webeditor3dEditorStore = editorStore; + if (import.meta.env.DEV) { + ( + window as Window & { __webeditor3dEditorStore?: typeof editorStore } + ).__webeditor3dEditorStore = editorStore; + } + + ReactDOM.createRoot(rootElement!).render( + + + + ); } -ReactDOM.createRoot(rootElement).render( - - - -); +void bootstrapEditor().catch((error) => { + throw error; +});