mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
WebView2 gives a window created hidden no animation frames, so on Windows the top bands and glowing cards never drew: no particles, no Mochis, and a grey card instead of the deep black. The loop now falls back to a timer when no frame comes, trusts the focused window, and the bands paint their black and colour themselves before the canvas runs. While you dictate, their light and particles follow your voice. Scrollbars are the Mac's thin rounded thumb, without arrows. dev/hub-preview.html and dev/island-preview.html show both windows in a browser with a stand-in for Tauri. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJm3SRL9k3gBPaVtfPhwcT
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
// A stand-in for Tauri in a plain browser, for the dev previews: every command
|
|
// answers from `answers` (or null), events can be fired with window.__emit.
|
|
// Not shipped in the app.
|
|
const listeners = new Map<string, (e: unknown) => void>();
|
|
const answers: Record<string, unknown> = (window as any).__answers ?? {};
|
|
let cb = 0;
|
|
(window as any).__TAURI_INTERNALS__ = {
|
|
transformCallback: (callback: (e: unknown) => void) => {
|
|
const id = ++cb;
|
|
(window as any)[`_${id}`] = callback;
|
|
return id;
|
|
},
|
|
invoke: async (cmd: string, args: any) => {
|
|
if (cmd === "plugin:event|listen") {
|
|
const fn = (window as any)[`_${args.handler}`] ?? args.handler;
|
|
listeners.set(args.event, fn);
|
|
return listeners.size;
|
|
}
|
|
if (cmd === "plugin:event|unlisten") return null;
|
|
const a = answers[cmd];
|
|
if (typeof a === "function") return (a as any)(args);
|
|
return a ?? null;
|
|
},
|
|
metadata: { currentWindow: { label: "hub" }, currentWebview: { label: "hub", windowLabel: "hub" } },
|
|
};
|
|
(window as any).__emit = (event: string, payload: unknown) => listeners.get(event)?.({ event, id: 0, payload });
|