chore: initialize from frontend template 4dc033c
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
import { recordBootFailure } from "../adapters/diagnostics/bounded-diagnostics.ts";
|
||||
import { BootErrorShell } from "../presentation/boundaries/boot-error-shell.tsx";
|
||||
import "../presentation/styles/theme.css";
|
||||
import { createRuntimeComposition } from "./create-runtime-composition.ts";
|
||||
import { initializeColorScheme } from "./initialize-color-scheme.ts";
|
||||
import { ReleaseManifestError } from "./load-release-manifest.ts";
|
||||
import { BootConfigError } from "./load-runtime-config.ts";
|
||||
import { RuntimeApplication } from "./runtime-application.tsx";
|
||||
|
||||
const rootElement = document.getElementById("root");
|
||||
|
||||
if (!rootElement) {
|
||||
throw new Error("Missing #root mount element");
|
||||
}
|
||||
|
||||
const root = createRoot(rootElement);
|
||||
|
||||
async function boot(): Promise<void> {
|
||||
try {
|
||||
const composition = await createRuntimeComposition();
|
||||
document.documentElement.dataset.buildId = composition.release.buildId;
|
||||
document.documentElement.dataset.releaseId = composition.release.releaseId;
|
||||
initializeColorScheme(composition.application.preferences);
|
||||
root.render(<RuntimeApplication composition={composition} />);
|
||||
import.meta.hot?.dispose(() => {
|
||||
void composition.dispose();
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
const safe =
|
||||
error instanceof BootConfigError || error instanceof ReleaseManifestError
|
||||
? error.safe
|
||||
: { supportReference: "boot:unknown" };
|
||||
|
||||
recordBootFailure(error, safe);
|
||||
root.render(<BootErrorShell {...safe} />);
|
||||
}
|
||||
}
|
||||
|
||||
void boot();
|
||||
Reference in New Issue
Block a user