/** Shared wire format for independently hydrated compat roots. */ export function emitCompatSsrBoundaryHelper(name: string): string { return `function ${name}$compat(name, props, render, children, hasChildren) { const escapedName = String(name).replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">"); let serializable = !${name}$hasNonSerializableProps(props); let json = "{}"; try { if (serializable) json = JSON.stringify(props ?? {}) ?? "{}"; } catch { serializable = false; } const escapedJson = json.replaceAll("<", "\\\\u003c").replaceAll("&", "\\\\u0026").replaceAll(">", "\\\\u003e"); const propsHtml = ''; if (!serializable || hasChildren) return '' + children + propsHtml; const id = "compat-" + globalThis.crypto.randomUUID(); const html = render("", id, JSON.parse(json)); return '' + html + '' + propsHtml; }`; }