import { currentSite } from "./site"; import { shipsPwa as contractShipsPwa } from "yt-dlp-transcript-common/lib/archive/contract"; // The export app renders one of two shells, selected at build time: // site (default): a single-site archive, exactly as before. // hub: the federated Archilyzer hub, reading many sites at runtime. // // The single-site path is never touched unless INSTANCE_MODE is explicitly // "hub", so a plain `next build` stays a site build. export type InstanceMode = "site" | "hub"; export function instanceMode(): InstanceMode { return process.env.INSTANCE_MODE === "hub" ? "hub" : "site"; } // Whether this build ships an installable PWA — the "dangerous permissions" // surface: a service worker, a web manifest, and installability. See // lib/archive/contract.ts shipsPwa() for what the axis means; this wrapper only // supplies the site, which the export app resolves at build/render time. // // Was a second copy of the predicate with a "keep in sync" comment pointing at // compose-site.ts's copy. Both are gone; there is one. // // Hub mode needs no branch of its own any more: currentSite() already returns // hubSite(), which sets `pwa: true` (export/app/lib/site.ts), and the contract // predicate reads INSTANCE_MODE itself — so the old // `if (instanceMode() === "hub") return true` short-circuit was true twice over. // // SERVER-ONLY, deliberately: the contract predicate reads // `process.env.INSTANCE_MODE`, which is not a `NEXT_PUBLIC_` var and is not in a // next.config `env:` block, so Next does NOT inline it into a client bundle. // The only caller is export/app/layout.tsx, a server component — and // currentSite() is server-only regardless, since it reads the sites dir. // Calling this from a client component would read `undefined` and silently turn // hub mode off; that would need a guard there, not an assumption here. export function shipsPwa(): boolean { return contractShipsPwa(currentSite()); }