Feat: Web loader

This commit is contained in:
MangoPig
2026-06-15 06:59:57 +01:00
parent 90de5ca868
commit 99538e30c8
14 changed files with 559 additions and 3 deletions

24
Loader/scripts/storage.js Normal file
View File

@@ -0,0 +1,24 @@
// Path: Loader/scripts/storage.js
import { LOADER_INTENT_STORAGE_KEY, LOADER_META_STORAGE_KEY, LOADER_SEEN_COOKIE_MAX_AGE_SECONDS, LOADER_SEEN_COOKIE_NAME } from "./config.js";
import { collectClientHints } from "./hints.js";
export const persistLoaderState = (intent) => {
const payload = {
intent,
hints: collectClientHints(),
};
try {
window.sessionStorage.setItem(LOADER_INTENT_STORAGE_KEY, intent);
window.sessionStorage.setItem(LOADER_META_STORAGE_KEY, JSON.stringify(payload));
} catch (error) {
console.warn("[Loader] Unable to persist bootstrap state.", error);
}
return payload;
};
export const markLoaderSeen = () => {
document.cookie = `${LOADER_SEEN_COOKIE_NAME}=1; Path=/; Max-Age=${LOADER_SEEN_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax`;
};