import { mount } from 'svelte'; import App from './App.svelte'; import Popout from './Popout.svelte'; import { popup } from './lib/popouts.svelte'; import '@xyflow/svelte/dist/base.css'; import './app.css'; // Code a page loads later is fetched by hashed name; after `albedo web` starts // serving a newer build those files are gone, and reloading picks up the new ones. addEventListener('vite:preloadError', () => location.reload()); // Missing a chat must never let a file drop navigate either app or popout away. function keepFileDrop(event: DragEvent) { if (event.dataTransfer?.types.includes('Files')) event.preventDefault(); } window.addEventListener('dragover', keepFileDrop); window.addEventListener('drop', keepFileDrop); if (new URLSearchParams(location.search).has('input-trace')) { const { traceSecondaryClick } = await import('./lib/menu-trace'); traceSecondaryClick( new URL(import.meta.url).pathname.split('/').pop() ?? 'dev', ); } // Reserve Ctrl + secondary click in the app and its popouts. Some platforms // request the menu after release, when Ctrl may already be up. let ctrlRight = false; window.addEventListener( 'pointerdown', (event) => { ctrlRight = event.button === 2 && event.ctrlKey; }, true, ); window.addEventListener( 'keydown', (event) => { if (event.key === 'ContextMenu' || event.key === 'F10') ctrlRight = false; }, true, ); window.addEventListener('blur', () => { ctrlRight = false; }); window.addEventListener( 'contextmenu', (event) => { if (event.button === 2 && (event.ctrlKey || ctrlRight)) { event.preventDefault(); event.stopImmediatePropagation(); } ctrlRight = false; }, true, ); const target = document.getElementById('app')!; if (popup) mount(Popout, { target }); else mount(App, { target });