Bugfixes. Documentation update.
This commit is contained in:
Vendored
+10
@@ -8,6 +8,7 @@ export default async function ({ req }) {
|
||||
? global.BUNDLER_CTX_MAP?.find((m) => m.local_path == match.filePath)
|
||||
: undefined;
|
||||
let controller;
|
||||
let heartbeat;
|
||||
const stream = new ReadableStream({
|
||||
start(c) {
|
||||
controller = c;
|
||||
@@ -16,8 +17,17 @@ export default async function ({ req }) {
|
||||
page_url: referer_url.href,
|
||||
target_map,
|
||||
});
|
||||
heartbeat = setInterval(() => {
|
||||
try {
|
||||
c.enqueue(": keep-alive\n\n");
|
||||
}
|
||||
catch {
|
||||
clearInterval(heartbeat);
|
||||
}
|
||||
}, 5000);
|
||||
},
|
||||
cancel() {
|
||||
clearInterval(heartbeat);
|
||||
const targetControllerIndex = global.HMR_CONTROLLERS.findIndex((c) => c.controller == controller);
|
||||
if (typeof targetControllerIndex == "number" &&
|
||||
targetControllerIndex >= 0) {
|
||||
|
||||
@@ -19,6 +19,7 @@ export default async function (params) {
|
||||
script += `window.addEventListener("error", (e) => __bunext_show_error(e.message, e.filename ? e.filename + ":" + e.lineno + ":" + e.colno : "", e.error?.stack ?? ""));\n`;
|
||||
script += `window.addEventListener("unhandledrejection", (e) => __bunext_show_error(String(e.reason?.message ?? e.reason), "", e.reason?.stack ?? ""));\n\n`;
|
||||
script += `const hmr = new EventSource("/__hmr");\n`;
|
||||
script += `window.BUNEXT_HMR = hmr;\n`;
|
||||
script += `window.addEventListener("beforeunload", () => hmr.close());\n`;
|
||||
script += `hmr.addEventListener("update", async (event) => {\n`;
|
||||
script += ` if (event?.data) {\n`;
|
||||
|
||||
Reference in New Issue
Block a user