import React, { Suspense } from 'react'; import type { ServerSpout } from './types.js'; type NeededNext = { initData?: Record unknown>; scripts?: React.ReactNode[]; }; /** Serialize data for safe embedding in injection * - Escapes U+2028/U+2029 line separators for older browser compatibility */ export function serializeForScriptTag(data: unknown): string { return JSON.stringify(data) .replace(/, Record, NeededNext > { return next => async props => { const nextProps = await next(props); const scripts: React.ReactNode[] = nextProps.scripts ?? []; Object.entries(nextProps.initData ?? {}).forEach(([key, useData]) => { const globalId = `${id}.${key}`; const Script = () => { const data: any = useData(); try { const encoded = serializeForScriptTag(data); return (