// Loro update payloads travel as base64 strings (JSON-friendly on every // transport); the docs themselves work in bytes. export function toBase64(bytes: Uint8Array): string { let binary = ''; const CHUNK = 0x8000; for (let i = 0; i < bytes.length; i += CHUNK) { binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK)); } return btoa(binary); } export function fromBase64(b64: string): Uint8Array { const binary = atob(b64); const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i); return bytes; }