@miniflare/http-server
Advanced tools
Comparing version 2.0.0-next.2 to 2.0.0-next.3
@@ -356,4 +356,5 @@ var __defProp = Object.defineProperty; | ||
if (reconnected) ws.onopen = reload; | ||
ws.onmessage = reload; | ||
ws.onclose = function(e) { e.code === 1000 || e.code === 1001 || setTimeout(connect, 1000, true); } | ||
ws.onclose = function(e) { | ||
e.code === 1012 ? reload() : e.code === 1000 || e.code === 1001 || setTimeout(connect, 1000, true); | ||
} | ||
} | ||
@@ -363,3 +364,3 @@ connect(); | ||
<\/script>`; | ||
var liveReloadRewriter = void 0; | ||
var liveReloadScriptLength = Buffer.byteLength(liveReloadScript); | ||
async function convertNodeRequest(req, upstream, meta) { | ||
@@ -461,14 +462,11 @@ const url = new URL(req.url ?? "", upstream ?? `http://${req.headers.host}`); | ||
} | ||
res?.writeHead(status, headers); | ||
if (HTTPPlugin2.liveReload && response.encodeBody === "auto" && response.headers.get("content-type")?.toLowerCase().includes("text/html")) { | ||
if (liveReloadRewriter === void 0) { | ||
const { HTMLRewriter } = await import("@miniflare/html-rewriter"); | ||
liveReloadRewriter = new HTMLRewriter().on("body", { | ||
element(end) { | ||
end.append(liveReloadScript, { html: true }); | ||
} | ||
}); | ||
const liveReloadEnabled = HTTPPlugin2.liveReload && response.encodeBody === "auto" && response.headers.get("content-type")?.toLowerCase().includes("text/html"); | ||
const contentLength = response.headers.get("content-length"); | ||
if (liveReloadEnabled && contentLength !== null) { | ||
const length = parseInt(contentLength); | ||
if (!isNaN(length)) { | ||
headers["content-length"] = length + liveReloadScriptLength; | ||
} | ||
response = liveReloadRewriter.transform(response); | ||
} | ||
res?.writeHead(status, headers); | ||
if (res) { | ||
@@ -482,2 +480,5 @@ const passThrough = new PassThrough(); | ||
} | ||
if (liveReloadEnabled) { | ||
passThrough.write(liveReloadScript); | ||
} | ||
} | ||
@@ -563,3 +564,2 @@ passThrough.end(); | ||
for (const ws of liveReloadServer.clients) { | ||
ws.send(""); | ||
ws.close(1012, "Service Restart"); | ||
@@ -566,0 +566,0 @@ } |
{ | ||
"name": "@miniflare/http-server", | ||
"version": "2.0.0-next.2", | ||
"version": "2.0.0-next.3", | ||
"description": "HTTP server module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -20,2 +20,5 @@ "keywords": [ | ||
], | ||
"engines": { | ||
"node": ">=16.7" | ||
}, | ||
"publishConfig": { | ||
@@ -26,9 +29,9 @@ "access": "public" | ||
"type": "git", | ||
"url": "git+https://github.com/mrbbot/miniflare.git", | ||
"url": "git+https://github.com/cloudflare/miniflare.git", | ||
"directory": "packages/http-server" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mrbbot/miniflare/issues" | ||
"url": "https://github.com/cloudflare/miniflare/issues" | ||
}, | ||
"homepage": "https://github.com/mrbbot/miniflare/tree/master/packages/http-server#readme", | ||
"homepage": "https://github.com/cloudflare/miniflare/tree/master/packages/http-server#readme", | ||
"volta": { | ||
@@ -38,9 +41,8 @@ "extends": "../../package.json" | ||
"dependencies": { | ||
"@miniflare/core": "2.0.0-next.2", | ||
"@miniflare/html-rewriter": "2.0.0-next.2", | ||
"@miniflare/shared": "2.0.0-next.2", | ||
"@miniflare/web-sockets": "2.0.0-next.2", | ||
"@miniflare/core": "2.0.0-next.3", | ||
"@miniflare/shared": "2.0.0-next.3", | ||
"@miniflare/web-sockets": "2.0.0-next.3", | ||
"kleur": "^4.1.4", | ||
"selfsigned": "^1.10.11", | ||
"undici": "^4.8.1", | ||
"undici": "^4.9.3", | ||
"ws": "^8.2.2", | ||
@@ -50,5 +52,5 @@ "youch": "^2.2.2" | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0-next.2", | ||
"@miniflare/shared-test": "2.0.0-next.3", | ||
"@types/node-forge": "^0.10.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36747
8
+ Added@miniflare/core@2.0.0-next.3(transitive)
+ Added@miniflare/shared@2.0.0-next.3(transitive)
+ Added@miniflare/web-sockets@2.0.0-next.3(transitive)
- Removed@miniflare/core@2.0.0-next.2(transitive)
- Removed@miniflare/html-rewriter@2.0.0-next.2(transitive)
- Removed@miniflare/shared@2.0.0-next.2(transitive)
- Removed@miniflare/web-sockets@2.0.0-next.2(transitive)
- Removedhtml-rewriter-wasm@0.3.2(transitive)
Updated@miniflare/core@2.0.0-next.3
Updatedundici@^4.9.3