Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
75
node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
75
node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
@@ -28,51 +28,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var http_exports = {};
|
||||
__export(http_exports, {
|
||||
httpAddressToString: () => httpAddressToString,
|
||||
installHttpTransport: () => installHttpTransport,
|
||||
startHttpServer: () => startHttpServer
|
||||
addressToString: () => addressToString,
|
||||
startMcpHttpServer: () => startMcpHttpServer
|
||||
});
|
||||
module.exports = __toCommonJS(http_exports);
|
||||
var import_assert = __toESM(require("assert"));
|
||||
var import_http = __toESM(require("http"));
|
||||
var import_crypto = __toESM(require("crypto"));
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("./bundle"));
|
||||
var mcpBundle = __toESM(require("playwright-core/lib/mcpBundle"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var mcpServer = __toESM(require("./server"));
|
||||
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
||||
async function startHttpServer(config, abortSignal) {
|
||||
const { host, port } = config;
|
||||
const httpServer = import_http.default.createServer();
|
||||
decorateServer(httpServer);
|
||||
await new Promise((resolve, reject) => {
|
||||
httpServer.on("error", reject);
|
||||
abortSignal?.addEventListener("abort", () => {
|
||||
httpServer.close();
|
||||
reject(new Error("Aborted"));
|
||||
});
|
||||
httpServer.listen(port, host, () => {
|
||||
resolve();
|
||||
httpServer.removeListener("error", reject);
|
||||
});
|
||||
});
|
||||
return httpServer;
|
||||
async function startMcpHttpServer(config, serverBackendFactory, allowedHosts) {
|
||||
const httpServer = (0, import_utils.createHttpServer)();
|
||||
await (0, import_utils.startHttpServer)(httpServer, config);
|
||||
return await installHttpTransport(httpServer, serverBackendFactory, allowedHosts);
|
||||
}
|
||||
function httpAddressToString(address) {
|
||||
function addressToString(address, options) {
|
||||
(0, import_assert.default)(address, "Could not bind server socket");
|
||||
if (typeof address === "string")
|
||||
return address;
|
||||
const resolvedPort = address.port;
|
||||
let resolvedHost = address.family === "IPv4" ? address.address : `[${address.address}]`;
|
||||
if (resolvedHost === "0.0.0.0" || resolvedHost === "[::]")
|
||||
resolvedHost = "localhost";
|
||||
return `http://${resolvedHost}:${resolvedPort}`;
|
||||
throw new Error("Unexpected address type: " + address);
|
||||
let host = address.family === "IPv4" ? address.address : `[${address.address}]`;
|
||||
if (options.normalizeLoopback && (host === "0.0.0.0" || host === "[::]" || host === "[::1]" || host === "127.0.0.1"))
|
||||
host = "localhost";
|
||||
return `${options.protocol}://${host}:${address.port}`;
|
||||
}
|
||||
async function installHttpTransport(httpServer, serverBackendFactory, unguessableUrl, allowedHosts) {
|
||||
const url = httpAddressToString(httpServer.address());
|
||||
async function installHttpTransport(httpServer, serverBackendFactory, allowedHosts) {
|
||||
const url = addressToString(httpServer.address(), { protocol: "http", normalizeLoopback: true });
|
||||
const host = new URL(url).host;
|
||||
allowedHosts = (allowedHosts || [host]).map((h) => h.toLowerCase());
|
||||
const allowAnyHost = allowedHosts.includes("*");
|
||||
const pathPrefix = unguessableUrl ? `/${import_crypto.default.randomUUID()}` : "";
|
||||
const sseSessions = /* @__PURE__ */ new Map();
|
||||
const streamableSessions = /* @__PURE__ */ new Map();
|
||||
httpServer.on("request", async (req, res) => {
|
||||
@@ -87,12 +72,7 @@ async function installHttpTransport(httpServer, serverBackendFactory, unguessabl
|
||||
return res.end("Access is only allowed at " + allowedHosts.join(", "));
|
||||
}
|
||||
}
|
||||
if (!req.url?.startsWith(pathPrefix)) {
|
||||
res.statusCode = 404;
|
||||
return res.end("Not found");
|
||||
}
|
||||
const path = req.url?.slice(pathPrefix.length);
|
||||
const url2 = new URL(`http://localhost${path}`);
|
||||
const url2 = new URL(`http://localhost${req.url}`);
|
||||
if (url2.pathname === "/killkillkill" && req.method === "GET") {
|
||||
res.statusCode = 200;
|
||||
res.end("Killing process");
|
||||
@@ -104,7 +84,7 @@ async function installHttpTransport(httpServer, serverBackendFactory, unguessabl
|
||||
else
|
||||
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
|
||||
});
|
||||
return `${url}${pathPrefix}`;
|
||||
return url;
|
||||
}
|
||||
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
|
||||
if (req.method === "POST") {
|
||||
@@ -165,23 +145,8 @@ async function handleStreamable(serverBackendFactory, req, res, sessions) {
|
||||
res.statusCode = 400;
|
||||
res.end("Invalid request");
|
||||
}
|
||||
function decorateServer(server) {
|
||||
const sockets = /* @__PURE__ */ new Set();
|
||||
server.on("connection", (socket) => {
|
||||
sockets.add(socket);
|
||||
socket.once("close", () => sockets.delete(socket));
|
||||
});
|
||||
const close = server.close;
|
||||
server.close = (callback) => {
|
||||
for (const socket of sockets)
|
||||
socket.destroy();
|
||||
sockets.clear();
|
||||
return close.call(server, callback);
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
httpAddressToString,
|
||||
installHttpTransport,
|
||||
startHttpServer
|
||||
addressToString,
|
||||
startMcpHttpServer
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user