Files
edentext/src/main.ts
T
Steffen Becker b19409aacb feat: the editor installs and runs with the network gone
Nothing here talks to a server at runtime, so a cached shell is the whole
editor. The worker reads the build's hashed asset names out of the entry
document, which precaches without a build step; the document itself stays
network-first, or it would keep naming the assets of the build it was
cached with. Matching ignores Vary: a precached asset is fetched without
the page's Origin, and a server answering "Vary: Origin" never matches it.

Verified in a headless Chromium with the network cut.
2026-08-14 22:11:49 +02:00

29 lines
1007 B
TypeScript

import { mount } from 'svelte';
import App from './App.svelte';
import './styles/global.css';
import { loadTheme, applyTheme } from './lib/storage/theme';
import { locale } from './lib/i18n/i18n.svelte';
// Apply saved theme before mount to prevent flash of wrong theme
applyTheme(loadTheme());
// Resolve the UI locale before mount and reflect it on <html lang> (chrome a11y)
document.documentElement.lang = locale();
// Keep 'auto' in sync when system theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (loadTheme() === 'auto') applyTheme('auto');
});
// Offline support (public/sw.js). Not in dev, where a worker would serve the cached
// build over the one being edited.
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch(() => {});
});
}
const app = mount(App, { target: document.getElementById('app')! });
export default app;