| Server IP : 159.203.156.69 / Your IP : 216.73.216.37 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 : |
//#region src/server/rsc-stream-hints.ts
const REACT_FLIGHT_STYLESHEET_PRELOAD_HINT = /(\d*:HL\[.*?),"stylesheet"(\]|,)/g;
/**
* React Flight emits HL hints with "stylesheet" for CSS preloads, but the
* HTML spec requires "style" for <link rel="preload">. Rewrite each complete
* Flight line so SSR embeds, navigation, and server actions see valid hints.
*/
function normalizeReactFlightHintLine(line) {
return line.replace(REACT_FLIGHT_STYLESHEET_PRELOAD_HINT, "$1,\"style\"$2");
}
function normalizeReactFlightPreloadHints(stream) {
const decoder = new TextDecoder();
const encoder = new TextEncoder();
let carry = "";
return stream.pipeThrough(new TransformStream({
transform(chunk, controller) {
const text = carry + decoder.decode(chunk, { stream: true });
const lastNewline = text.lastIndexOf("\n");
if (lastNewline === -1) {
carry = text;
return;
}
carry = text.slice(lastNewline + 1);
controller.enqueue(encoder.encode(normalizeReactFlightHintLine(text.slice(0, lastNewline + 1))));
},
flush(controller) {
const text = carry + decoder.decode();
if (text) controller.enqueue(encoder.encode(normalizeReactFlightHintLine(text)));
}
}));
}
function createRscRenderer(render) {
return (model, options) => normalizeReactFlightPreloadHints(render(model, options));
}
//#endregion
export { createRscRenderer, normalizeReactFlightPreloadHints };
//# sourceMappingURL=rsc-stream-hints.js.map