export const STALE_CLIENT_RELOAD_KEY = "jyotisha:stale-client-reload"; const CHUNK_FAILURE = /ChunkLoadError|Loading chunk .+ failed|Failed to fetch dynamically imported module|error loading dynamically imported module|_next\/static\//i; export function isChunkLoadFailure(message: string): boolean { return CHUNK_FAILURE.test(message); } export function consumeStaleClientReload(storage: Pick): boolean { if (storage.getItem(STALE_CLIENT_RELOAD_KEY) === "1") return false; storage.setItem(STALE_CLIENT_RELOAD_KEY, "1"); return true; } export function clearStaleClientReload(storage: Pick): void { storage.removeItem(STALE_CLIENT_RELOAD_KEY); } export function shouldReloadFrozenBootstrap(input: { persisted: boolean; loadingBusy: boolean; loadingError: boolean; }): boolean { return input.persisted && input.loadingBusy && !input.loadingError; }