hatch-surf/node_modules/next/dist/esm/server/dev/debug-channel.js
Riley Zhang df378d33ef
Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Merge GitHub main into Gitea repo (allow unrelated histories)
Resolved conflicts by taking GitHub versions for:
- .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml

Kept deploy.sh updated to:
- Pull from GitHub (primary source)
- Push to Gitea (push-mirror)
- Build from site/ directory (GitHub structure)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-25 05:20:46 +02:00

57 lines
2.2 KiB
JavaScript

import { createBufferedTransformStream } from '../stream-utils/node-web-streams-helper';
import { HMR_MESSAGE_SENT_TO_BROWSER } from './hot-reloader-types';
const reactDebugChannelsByHtmlRequestId = new Map();
export function connectReactDebugChannel(requestId, debugChannel, sendToClient) {
const reader = debugChannel.readable.pipeThrough(// We're sending the chunks in batches to reduce overhead in the browser.
createBufferedTransformStream({
maxBufferByteLength: 128 * 1024
})).getReader();
const stop = ()=>{
sendToClient({
type: HMR_MESSAGE_SENT_TO_BROWSER.REACT_DEBUG_CHUNK,
requestId,
chunk: null
});
};
const onError = (err)=>{
console.error(Object.defineProperty(new Error('React debug channel stream error', {
cause: err
}), "__NEXT_ERROR_CODE", {
value: "E810",
enumerable: false,
configurable: true
}));
stop();
};
const progress = (entry)=>{
if (entry.done) {
stop();
} else {
sendToClient({
type: HMR_MESSAGE_SENT_TO_BROWSER.REACT_DEBUG_CHUNK,
requestId,
chunk: entry.value
});
reader.read().then(progress, onError);
}
};
reader.read().then(progress, onError);
}
export function connectReactDebugChannelForHtmlRequest(htmlRequestId, sendToClient) {
const debugChannel = reactDebugChannelsByHtmlRequestId.get(htmlRequestId);
if (!debugChannel) {
return;
}
reactDebugChannelsByHtmlRequestId.delete(htmlRequestId);
connectReactDebugChannel(htmlRequestId, debugChannel, sendToClient);
}
export function setReactDebugChannelForHtmlRequest(htmlRequestId, debugChannel) {
// TODO: Clean up after a timeout, in case the client never connects, e.g.
// when CURL'ing the page, or loading the page with JavaScript disabled etc.
reactDebugChannelsByHtmlRequestId.set(htmlRequestId, debugChannel);
}
export function deleteReactDebugChannelForHtmlRequest(htmlRequestId) {
reactDebugChannelsByHtmlRequestId.delete(htmlRequestId);
}
//# sourceMappingURL=debug-channel.js.map