| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/server/ |
Upload File : |
{"version":3,"file":"app-browser-stream.js","names":[],"sources":["../../src/server/app-browser-stream.ts"],"sourcesContent":["import type { ReactFormState } from \"react-dom/client\";\nimport { RSC_FORM_STATE_GLOBAL } from \"./app-browser-hydration.js\";\n\ntype NavigationSnapshot = {\n pathname: string;\n searchParams: [string, string][];\n};\n\ntype LegacyRscEmbedData = {\n rsc: string[];\n params?: Record<string, string | string[]>;\n nav?: NavigationSnapshot;\n};\n\ntype VinextBrowserGlobals = {\n __VINEXT_RSC__?: LegacyRscEmbedData;\n __VINEXT_RSC_CHUNKS__?: string[];\n __VINEXT_RSC_DONE__?: boolean;\n [RSC_FORM_STATE_GLOBAL]?: ReactFormState;\n __VINEXT_RSC_PARAMS__?: Record<string, string | string[]>;\n __VINEXT_RSC_NAV__?: NavigationSnapshot;\n};\n\nexport function getVinextBrowserGlobal(): typeof globalThis & VinextBrowserGlobals {\n return globalThis as typeof globalThis & VinextBrowserGlobals;\n}\n\nfunction createUnexpectedRscStreamCloseError(): Error {\n return new Error(\n \"The connection to the page was unexpectedly closed, possibly due to the stop button being clicked, loss of Wi-Fi, or an unstable internet connection.\",\n );\n}\n\n/**\n * Convert embedded text chunks back to a ReadableStream of Uint8Array chunks.\n */\nexport function chunksToReadableStream(chunks: readonly string[]): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n return new ReadableStream<Uint8Array>({\n start(controller) {\n for (const chunk of chunks) {\n controller.enqueue(encoder.encode(chunk));\n }\n controller.close();\n },\n });\n}\n\n/**\n * Create a ReadableStream from progressively-embedded RSC chunks.\n *\n * The server pushes chunks into `__VINEXT_RSC_CHUNKS__` via inline <script>\n * tags. We monkey-patch `push()` so new chunks stream to React immediately\n * instead of polling with setTimeout.\n */\nexport function createProgressiveRscStream(): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n\n return new ReadableStream<Uint8Array>({\n start(controller) {\n const vinext = getVinextBrowserGlobal();\n const initialChunks = vinext.__VINEXT_RSC_CHUNKS__ ?? [];\n\n for (const chunk of initialChunks) {\n controller.enqueue(encoder.encode(chunk));\n }\n\n if (vinext.__VINEXT_RSC_DONE__) {\n controller.close();\n return;\n }\n\n let closed = false;\n let cancelDocumentCompletionCheck: (() => void) | undefined;\n const cancelPendingDocumentCompletionCheck = () => {\n const cancel = cancelDocumentCompletionCheck;\n cancelDocumentCompletionCheck = undefined;\n cancel?.();\n };\n const closeOnce = () => {\n if (!closed) {\n closed = true;\n cancelPendingDocumentCompletionCheck();\n controller.close();\n }\n };\n const errorOnce = () => {\n if (!closed) {\n closed = true;\n cancelPendingDocumentCompletionCheck();\n controller.error(createUnexpectedRscStreamCloseError());\n }\n };\n\n const arr = (vinext.__VINEXT_RSC_CHUNKS__ ??= []);\n arr.push = function (...chunks: string[]): number {\n const length = Array.prototype.push.apply(this, chunks);\n\n if (closed) return length;\n\n for (const chunk of chunks) {\n controller.enqueue(encoder.encode(chunk));\n }\n\n if (vinext.__VINEXT_RSC_DONE__) {\n closeOnce();\n }\n\n return length;\n };\n\n if (typeof document !== \"undefined\") {\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", errorOnce);\n cancelDocumentCompletionCheck = () =>\n document.removeEventListener(\"DOMContentLoaded\", errorOnce);\n } else {\n const timeoutId = setTimeout(errorOnce);\n cancelDocumentCompletionCheck = () => clearTimeout(timeoutId);\n }\n }\n },\n });\n}\n"],"mappings":";AAuBA,SAAgB,yBAAmE;CACjF,OAAO;;AAGT,SAAS,sCAA6C;CACpD,uBAAO,IAAI,MACT,wJAC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