Merge branch 'swap-to-handler' of https://github.com/LukeHagar/sveltekit-adapters into swap-to-handler

This commit is contained in:
Luke Hagar
2025-07-13 02:09:21 -05:00
3 changed files with 19 additions and 9 deletions

View File

@@ -34,9 +34,7 @@ async function createWindow() {
stopIntercept?.();
});
await app.whenReady();
// Third setup the handler
// Setup the handler
stopIntercept = await setupHandler(mainWindow);
return mainWindow;
@@ -52,6 +50,11 @@ app.on('window-all-closed', () => {
app.on('activate', async () => {
if (BrowserWindow.getAllWindows().length === 0 && !mainWindow) {
await createWindow();
try {
await createWindow();
} catch (error) {
console.error('Failed to create window:', error);
}
}
});
});

View File

@@ -30,7 +30,14 @@ export const load = (({ cookies }) => {
return gameState
} catch (e) {
console.log("Error getting cookie", e);
console.error("Error loading game state:", e);
// Return a new game state as fallback
const newGame = new Game();
return {
guesses: newGame.guesses,
answers: newGame.answers,
answer: null
};
}
}) satisfies PageServerLoad;

View File

@@ -11,9 +11,9 @@ import { serialize as serializeCookie } from 'cookie';
let server;
let clientDir;
let prerenderedDir;
let Protocol = 'http';
let Host = '127.0.0.1';
let Origin = `${Protocol}://${Host}`;
const Protocol = 'http';
const Host = '127.0.0.1';
const Origin = `${Protocol}://${Host}`;
/**
* Reports errors to the user in a way that can be filed on GitHub
@@ -285,7 +285,7 @@ export async function setupHandler(mainWindow) {
await mainWindow.loadURL(url);
return function stopIntercept() {
protocol.unhandle('http');
protocol.unhandle(Protocol);
};
}