// serverData returns the per-page data the backend injected for this render, or
// null when there's none.
//
// Three render contexts, one accessor:
// - ISR server render (goja): the handler sets globalThis.__SERVER_DATA__
// before rendering, so the page renders with real data.
// - Browser takeover: the handler inlines the same data as
// before the bundle, so the
// client re-renders identical markup (no refetch, no flash).
// - Static skeleton bake (cmd/bundle): nothing is set, so this returns null
// and the component renders its placeholder/skeleton.
//
// Read it inside the reactive body (not captured at module load) so the value is
// observed at render time in every context.
export function serverData(): T | null {
return ((globalThis as unknown as { __SERVER_DATA__?: T }).__SERVER_DATA__) ?? null;
}