@cloudflare/vite-plugin 1.36.4 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import assert from "node:assert";
|
|
|
3
3
|
import { CoreHeaders, CorePaths, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, buildPublicUrl, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
|
|
4
4
|
import * as wrangler from "wrangler";
|
|
5
5
|
import * as nodePath from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import path3, { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
7
|
import * as util$1 from "node:util";
|
|
8
8
|
import { format, inspect, promisify } from "node:util";
|
|
9
9
|
import * as vite from "vite";
|
|
@@ -24,7 +24,7 @@ import v8 from "node:v8";
|
|
|
24
24
|
import { defineEnv } from "unenv";
|
|
25
25
|
import * as nativeFs$1 from "fs";
|
|
26
26
|
import nativeFs from "fs";
|
|
27
|
-
import path
|
|
27
|
+
import path, { basename, dirname as dirname$1, normalize, posix, relative as relative$1, resolve as resolve$1, sep } from "path";
|
|
28
28
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
29
29
|
import { createRequire as createRequire$1 } from "module";
|
|
30
30
|
import { WebSocketServer } from "ws";
|
|
@@ -1503,7 +1503,7 @@ async function assertWranglerVersion() {
|
|
|
1503
1503
|
* The default compatibility date to use when the user omits one.
|
|
1504
1504
|
* This value is injected at build time and remains fixed for each release.
|
|
1505
1505
|
*/
|
|
1506
|
-
const DEFAULT_COMPAT_DATE = "2026-05-
|
|
1506
|
+
const DEFAULT_COMPAT_DATE = "2026-05-14";
|
|
1507
1507
|
|
|
1508
1508
|
//#endregion
|
|
1509
1509
|
//#region ../../node_modules/.pnpm/@remix-run+node-fetch-server@0.8.0/node_modules/@remix-run/node-fetch-server/dist/node-fetch-server.js
|
|
@@ -4330,7 +4330,7 @@ function resolveWranglerConfigPath({ config, script }, options) {
|
|
|
4330
4330
|
deployConfigPath: void 0,
|
|
4331
4331
|
redirected: false
|
|
4332
4332
|
};
|
|
4333
|
-
return findWranglerConfig$1(script !== void 0 ?
|
|
4333
|
+
return findWranglerConfig$1(script !== void 0 ? path3.dirname(script) : process.cwd(), options);
|
|
4334
4334
|
}
|
|
4335
4335
|
__name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
|
|
4336
4336
|
function findWranglerConfig$1(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
|
|
@@ -4361,15 +4361,15 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4361
4361
|
const deployConfigFile = readFileSync$1(deployConfigPath);
|
|
4362
4362
|
try {
|
|
4363
4363
|
const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
|
|
4364
|
-
redirectedConfigPath = deployConfig.configPath &&
|
|
4364
|
+
redirectedConfigPath = deployConfig.configPath && path3.resolve(path3.dirname(deployConfigPath), deployConfig.configPath);
|
|
4365
4365
|
} catch (e) {
|
|
4366
|
-
throw new UserError(`Failed to parse the deploy configuration file at ${
|
|
4366
|
+
throw new UserError(`Failed to parse the deploy configuration file at ${path3.relative(".", deployConfigPath)}`, {
|
|
4367
4367
|
cause: e,
|
|
4368
4368
|
telemetryMessage: false
|
|
4369
4369
|
});
|
|
4370
4370
|
}
|
|
4371
4371
|
if (!redirectedConfigPath) throw new UserError(esm_default`
|
|
4372
|
-
A deploy configuration file was found at "${
|
|
4372
|
+
A deploy configuration file was found at "${path3.relative(".", deployConfigPath)}".
|
|
4373
4373
|
But this is not valid - the required "configPath" property was not found.
|
|
4374
4374
|
Instead this file contains:
|
|
4375
4375
|
\`\`\`
|
|
@@ -4377,13 +4377,13 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4377
4377
|
\`\`\`
|
|
4378
4378
|
`, { telemetryMessage: false });
|
|
4379
4379
|
if (!existsSync(redirectedConfigPath)) throw new UserError(esm_default`
|
|
4380
|
-
There is a deploy configuration at "${
|
|
4381
|
-
But the redirected configuration path it points to, "${
|
|
4380
|
+
There is a deploy configuration at "${path3.relative(".", deployConfigPath)}".
|
|
4381
|
+
But the redirected configuration path it points to, "${path3.relative(".", redirectedConfigPath)}", does not exist.
|
|
4382
4382
|
`, { telemetryMessage: false });
|
|
4383
4383
|
if (userConfigPath) {
|
|
4384
|
-
if (
|
|
4385
|
-
Found both a user configuration file at "${
|
|
4386
|
-
and a deploy configuration file at "${
|
|
4384
|
+
if (path3.join(path3.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) throw new UserError(esm_default`
|
|
4385
|
+
Found both a user configuration file at "${path3.relative(".", userConfigPath)}"
|
|
4386
|
+
and a deploy configuration file at "${path3.relative(".", deployConfigPath)}".
|
|
4387
4387
|
But these do not share the same base path so it is not clear which should be used.
|
|
4388
4388
|
`, { telemetryMessage: false });
|
|
4389
4389
|
}
|
|
@@ -5592,10 +5592,10 @@ var require_util$5 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
5592
5592
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5593
5593
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
5594
5594
|
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
5595
|
-
let path$
|
|
5595
|
+
let path$1 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
5596
5596
|
if (origin[origin.length - 1] === "/") origin = origin.slice(0, origin.length - 1);
|
|
5597
|
-
if (path$
|
|
5598
|
-
return new URL(`${origin}${path$
|
|
5597
|
+
if (path$1 && path$1[0] !== "/") path$1 = `/${path$1}`;
|
|
5598
|
+
return new URL(`${origin}${path$1}`);
|
|
5599
5599
|
}
|
|
5600
5600
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5601
5601
|
return url;
|
|
@@ -6470,8 +6470,8 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6470
6470
|
debugLog("connection to %s%s using %s%s errored - %s", host, port ? `:${port}` : "", protocol, version$2, error.message);
|
|
6471
6471
|
});
|
|
6472
6472
|
diagnosticsChannel$1.subscribe("undici:client:sendHeaders", (evt) => {
|
|
6473
|
-
const { request: { method, path: path$
|
|
6474
|
-
debugLog("sending request to %s %s%s", method, origin, path$
|
|
6473
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6474
|
+
debugLog("sending request to %s %s%s", method, origin, path$1);
|
|
6475
6475
|
});
|
|
6476
6476
|
}
|
|
6477
6477
|
let isTrackingRequestEvents = false;
|
|
@@ -6483,16 +6483,16 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6483
6483
|
}
|
|
6484
6484
|
isTrackingRequestEvents = true;
|
|
6485
6485
|
diagnosticsChannel$1.subscribe("undici:request:headers", (evt) => {
|
|
6486
|
-
const { request: { method, path: path$
|
|
6487
|
-
debugLog("received response to %s %s%s - HTTP %d", method, origin, path$
|
|
6486
|
+
const { request: { method, path: path$1, origin }, response: { statusCode } } = evt;
|
|
6487
|
+
debugLog("received response to %s %s%s - HTTP %d", method, origin, path$1, statusCode);
|
|
6488
6488
|
});
|
|
6489
6489
|
diagnosticsChannel$1.subscribe("undici:request:trailers", (evt) => {
|
|
6490
|
-
const { request: { method, path: path$
|
|
6491
|
-
debugLog("trailers received from %s %s%s", method, origin, path$
|
|
6490
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6491
|
+
debugLog("trailers received from %s %s%s", method, origin, path$1);
|
|
6492
6492
|
});
|
|
6493
6493
|
diagnosticsChannel$1.subscribe("undici:request:error", (evt) => {
|
|
6494
|
-
const { request: { method, path: path$
|
|
6495
|
-
debugLog("request to %s %s%s errored - %s", method, origin, path$
|
|
6494
|
+
const { request: { method, path: path$1, origin }, error } = evt;
|
|
6495
|
+
debugLog("request to %s %s%s errored - %s", method, origin, path$1, error.message);
|
|
6496
6496
|
});
|
|
6497
6497
|
}
|
|
6498
6498
|
let isTrackingWebSocketEvents = false;
|
|
@@ -6545,10 +6545,10 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6545
6545
|
const invalidPathRegex = /[^\u0021-\u00ff]/;
|
|
6546
6546
|
const kHandler = Symbol("handler");
|
|
6547
6547
|
var Request$6 = class {
|
|
6548
|
-
constructor(origin, { path: path$
|
|
6549
|
-
if (typeof path$
|
|
6550
|
-
else if (path$
|
|
6551
|
-
else if (invalidPathRegex.test(path$
|
|
6548
|
+
constructor(origin, { path: path$1, method, body, headers, query, idempotent, blocking, upgrade: upgrade$1, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
|
|
6549
|
+
if (typeof path$1 !== "string") throw new InvalidArgumentError$35("path must be a string");
|
|
6550
|
+
else if (path$1[0] !== "/" && !(path$1.startsWith("http://") || path$1.startsWith("https://")) && method !== "CONNECT") throw new InvalidArgumentError$35("path must be an absolute URL or start with a slash");
|
|
6551
|
+
else if (invalidPathRegex.test(path$1)) throw new InvalidArgumentError$35("invalid request path");
|
|
6552
6552
|
if (typeof method !== "string") throw new InvalidArgumentError$35("method must be a string");
|
|
6553
6553
|
else if (normalizedMethodRecords$1[method] === void 0 && !isValidHTTPToken$2(method)) throw new InvalidArgumentError$35("invalid request method");
|
|
6554
6554
|
if (upgrade$1 && typeof upgrade$1 !== "string") throw new InvalidArgumentError$35("upgrade must be a string");
|
|
@@ -6589,7 +6589,7 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6589
6589
|
this.completed = false;
|
|
6590
6590
|
this.aborted = false;
|
|
6591
6591
|
this.upgrade = upgrade$1 || null;
|
|
6592
|
-
this.path = query ? serializePathWithQuery$3(path$
|
|
6592
|
+
this.path = query ? serializePathWithQuery$3(path$1, query) : path$1;
|
|
6593
6593
|
this.origin = origin;
|
|
6594
6594
|
this.protocol = getProtocolFromUrlString(origin);
|
|
6595
6595
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -11072,7 +11072,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11072
11072
|
* @returns
|
|
11073
11073
|
*/
|
|
11074
11074
|
function writeH1(client, request$2) {
|
|
11075
|
-
const { method, path: path$
|
|
11075
|
+
const { method, path: path$1, host, upgrade: upgrade$1, blocking, reset } = request$2;
|
|
11076
11076
|
let { body, headers, contentLength } = request$2;
|
|
11077
11077
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
11078
11078
|
if (util$23.isFormDataLike(body)) {
|
|
@@ -11117,7 +11117,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11117
11117
|
if (client[kMaxRequests$1] && socket[kCounter$1]++ >= client[kMaxRequests$1]) socket[kReset$1] = true;
|
|
11118
11118
|
if (blocking) socket[kBlocking] = true;
|
|
11119
11119
|
if (socket.setTypeOfService) socket.setTypeOfService(request$2.typeOfService);
|
|
11120
|
-
let header = `${method} ${path$
|
|
11120
|
+
let header = `${method} ${path$1} HTTP/1.1\r\n`;
|
|
11121
11121
|
if (typeof host === "string") header += `host: ${host}\r\n`;
|
|
11122
11122
|
else header += client[kHostHeader$1];
|
|
11123
11123
|
if (upgrade$1) header += `connection: upgrade\r\nupgrade: ${upgrade$1}\r\n`;
|
|
@@ -11653,7 +11653,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11653
11653
|
function writeH2(client, request$2) {
|
|
11654
11654
|
const requestTimeout = request$2.bodyTimeout ?? client[kBodyTimeout$1];
|
|
11655
11655
|
const session = client[kHTTP2Session];
|
|
11656
|
-
const { method, path: path$
|
|
11656
|
+
const { method, path: path$1, host, upgrade: upgrade$1, expectContinue, signal, protocol, headers: reqHeaders } = request$2;
|
|
11657
11657
|
let { body } = request$2;
|
|
11658
11658
|
if (upgrade$1 != null && upgrade$1 !== "websocket") {
|
|
11659
11659
|
util$22.errorRequest(client, request$2, new InvalidArgumentError$30(`Custom upgrade "${upgrade$1}" not supported over HTTP/2`));
|
|
@@ -11706,7 +11706,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11706
11706
|
}
|
|
11707
11707
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
11708
11708
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
11709
|
-
headers[HTTP2_HEADER_PATH] = path$
|
|
11709
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11710
11710
|
if (protocol === "ws:" || protocol === "wss:") headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
11711
11711
|
else headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11712
11712
|
stream$2 = session.request(headers, {
|
|
@@ -11748,7 +11748,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11748
11748
|
stream$2.setTimeout(requestTimeout);
|
|
11749
11749
|
return true;
|
|
11750
11750
|
}
|
|
11751
|
-
headers[HTTP2_HEADER_PATH] = path$
|
|
11751
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11752
11752
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11753
11753
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
11754
11754
|
if (body && typeof body.read === "function") body.read(0);
|
|
@@ -13574,8 +13574,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
13574
13574
|
}
|
|
13575
13575
|
if (onHeaders) onHeaders.call(this, statusCode, data$1, resume$1);
|
|
13576
13576
|
};
|
|
13577
|
-
const { origin, path: path$
|
|
13578
|
-
opts.path = origin + path$
|
|
13577
|
+
const { origin, path: path$1 = "/", headers = {} } = opts;
|
|
13578
|
+
opts.path = origin + path$1;
|
|
13579
13579
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
13580
13580
|
const { host } = new URL(origin);
|
|
13581
13581
|
headers.host = host;
|
|
@@ -15359,16 +15359,16 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15359
15359
|
}
|
|
15360
15360
|
return normalizedQp;
|
|
15361
15361
|
}
|
|
15362
|
-
function safeUrl(path$
|
|
15363
|
-
if (typeof path$
|
|
15364
|
-
const pathSegments = path$
|
|
15365
|
-
if (pathSegments.length !== 2) return path$
|
|
15362
|
+
function safeUrl(path$1) {
|
|
15363
|
+
if (typeof path$1 !== "string") return path$1;
|
|
15364
|
+
const pathSegments = path$1.split("?", 3);
|
|
15365
|
+
if (pathSegments.length !== 2) return path$1;
|
|
15366
15366
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
15367
15367
|
qp.sort();
|
|
15368
15368
|
return [...pathSegments, qp.toString()].join("?");
|
|
15369
15369
|
}
|
|
15370
|
-
function matchKey(mockDispatch$1, { path: path$
|
|
15371
|
-
const pathMatch = matchValue$1(mockDispatch$1.path, path$
|
|
15370
|
+
function matchKey(mockDispatch$1, { path: path$1, method, body, headers }) {
|
|
15371
|
+
const pathMatch = matchValue$1(mockDispatch$1.path, path$1);
|
|
15372
15372
|
const methodMatch = matchValue$1(mockDispatch$1.method, method);
|
|
15373
15373
|
const bodyMatch = typeof mockDispatch$1.body !== "undefined" ? matchValue$1(mockDispatch$1.body, body) : true;
|
|
15374
15374
|
const headersMatch = matchHeaders(mockDispatch$1, headers);
|
|
@@ -15386,8 +15386,8 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15386
15386
|
const basePath = key.query ? serializePathWithQuery$2(key.path, key.query) : key.path;
|
|
15387
15387
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
15388
15388
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
15389
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path$
|
|
15390
|
-
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path$
|
|
15389
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path$1, ignoreTrailingSlash }) => {
|
|
15390
|
+
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path$1)), resolvedPathWithoutTrailingSlash) : matchValue$1(safeUrl(path$1), resolvedPath);
|
|
15391
15391
|
});
|
|
15392
15392
|
if (matchedMockDispatches.length === 0) throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
15393
15393
|
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue$1(method, key.method));
|
|
@@ -15430,15 +15430,15 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15430
15430
|
/**
|
|
15431
15431
|
* @param {string} path Path to remove trailing slash from
|
|
15432
15432
|
*/
|
|
15433
|
-
function removeTrailingSlash(path$
|
|
15434
|
-
while (path$
|
|
15435
|
-
if (path$
|
|
15436
|
-
return path$
|
|
15433
|
+
function removeTrailingSlash(path$1) {
|
|
15434
|
+
while (path$1.endsWith("/")) path$1 = path$1.slice(0, -1);
|
|
15435
|
+
if (path$1.length === 0) path$1 = "/";
|
|
15436
|
+
return path$1;
|
|
15437
15437
|
}
|
|
15438
15438
|
function buildKey$1(opts) {
|
|
15439
|
-
const { path: path$
|
|
15439
|
+
const { path: path$1, method, body, headers, query } = opts;
|
|
15440
15440
|
return {
|
|
15441
|
-
path: path$
|
|
15441
|
+
path: path$1,
|
|
15442
15442
|
method,
|
|
15443
15443
|
body,
|
|
15444
15444
|
headers,
|
|
@@ -16005,10 +16005,10 @@ var require_pending_interceptors_formatter = /* @__PURE__ */ __commonJS$1({ "../
|
|
|
16005
16005
|
});
|
|
16006
16006
|
}
|
|
16007
16007
|
format(pendingInterceptors) {
|
|
16008
|
-
const withPrettyHeaders = pendingInterceptors.map(({ method, path: path$
|
|
16008
|
+
const withPrettyHeaders = pendingInterceptors.map(({ method, path: path$1, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
16009
16009
|
Method: method,
|
|
16010
16010
|
Origin: origin,
|
|
16011
|
-
Path: path$
|
|
16011
|
+
Path: path$1,
|
|
16012
16012
|
"Status code": statusCode,
|
|
16013
16013
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
16014
16014
|
Invocations: timesInvoked,
|
|
@@ -16066,8 +16066,8 @@ var require_mock_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
16066
16066
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
16067
16067
|
const dispatchOpts = { ...opts };
|
|
16068
16068
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
16069
|
-
const [path$
|
|
16070
|
-
dispatchOpts.path = `${path$
|
|
16069
|
+
const [path$1, searchParams] = dispatchOpts.path.split("?");
|
|
16070
|
+
dispatchOpts.path = `${path$1}?${normalizeSearchParams(searchParams, acceptNonStandardSearchParameters)}`;
|
|
16071
16071
|
}
|
|
16072
16072
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
16073
16073
|
}
|
|
@@ -16544,10 +16544,10 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16544
16544
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
16545
16545
|
*/
|
|
16546
16546
|
async loadSnapshots(filePath) {
|
|
16547
|
-
const path$
|
|
16548
|
-
if (!path$
|
|
16547
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16548
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16549
16549
|
try {
|
|
16550
|
-
const data$1 = await readFile(resolve$3(path$
|
|
16550
|
+
const data$1 = await readFile(resolve$3(path$1), "utf8");
|
|
16551
16551
|
const parsed = JSON.parse(data$1);
|
|
16552
16552
|
if (Array.isArray(parsed)) {
|
|
16553
16553
|
this.#snapshots.clear();
|
|
@@ -16555,7 +16555,7 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16555
16555
|
} else this.#snapshots = new Map(Object.entries(parsed));
|
|
16556
16556
|
} catch (error) {
|
|
16557
16557
|
if (error.code === "ENOENT") this.#snapshots.clear();
|
|
16558
|
-
else throw new UndiciError$1(`Failed to load snapshots from ${path$
|
|
16558
|
+
else throw new UndiciError$1(`Failed to load snapshots from ${path$1}`, { cause: error });
|
|
16559
16559
|
}
|
|
16560
16560
|
}
|
|
16561
16561
|
/**
|
|
@@ -16565,9 +16565,9 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16565
16565
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
16566
16566
|
*/
|
|
16567
16567
|
async saveSnapshots(filePath) {
|
|
16568
|
-
const path$
|
|
16569
|
-
if (!path$
|
|
16570
|
-
const resolvedPath = resolve$3(path$
|
|
16568
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16569
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16570
|
+
const resolvedPath = resolve$3(path$1);
|
|
16571
16571
|
await mkdir(dirname$2(resolvedPath), { recursive: true });
|
|
16572
16572
|
const data$1 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
16573
16573
|
hash,
|
|
@@ -17134,11 +17134,11 @@ var require_redirect_handler = /* @__PURE__ */ __commonJS$1({ "../../node_module
|
|
|
17134
17134
|
return;
|
|
17135
17135
|
}
|
|
17136
17136
|
const { origin, pathname, search } = util$10.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
17137
|
-
const path$
|
|
17138
|
-
const redirectUrlString = `${origin}${path$
|
|
17137
|
+
const path$1 = search ? `${pathname}${search}` : pathname;
|
|
17138
|
+
const redirectUrlString = `${origin}${path$1}`;
|
|
17139
17139
|
for (const historyUrl of this.history) if (historyUrl.toString() === redirectUrlString) throw new InvalidArgumentError$3(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
17140
17140
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
17141
|
-
this.opts.path = path$
|
|
17141
|
+
this.opts.path = path$1;
|
|
17142
17142
|
this.opts.origin = origin;
|
|
17143
17143
|
this.opts.query = null;
|
|
17144
17144
|
}
|
|
@@ -22096,10 +22096,10 @@ var require_fetch = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/und
|
|
|
22096
22096
|
const url = requestCurrentURL(request$2);
|
|
22097
22097
|
/** @type {import('../../..').Agent} */
|
|
22098
22098
|
const agent = fetchParams.controller.dispatcher;
|
|
22099
|
-
const path$
|
|
22099
|
+
const path$1 = url.pathname + url.search;
|
|
22100
22100
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
22101
22101
|
return new Promise((resolve$4, reject) => agent.dispatch({
|
|
22102
|
-
path: hasTrailingQuestionMark ? `${path$
|
|
22102
|
+
path: hasTrailingQuestionMark ? `${path$1}?` : path$1,
|
|
22103
22103
|
origin: url.origin,
|
|
22104
22104
|
method: request$2.method,
|
|
22105
22105
|
body: agent.isMockActive ? request$2.body && (request$2.body.source || request$2.body.stream) : body,
|
|
@@ -22881,9 +22881,9 @@ var require_util$2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
22881
22881
|
* path-value = <any CHAR except CTLs or ";">
|
|
22882
22882
|
* @param {string} path
|
|
22883
22883
|
*/
|
|
22884
|
-
function validateCookiePath(path$
|
|
22885
|
-
for (let i$1 = 0; i$1 < path$
|
|
22886
|
-
const code = path$
|
|
22884
|
+
function validateCookiePath(path$1) {
|
|
22885
|
+
for (let i$1 = 0; i$1 < path$1.length; ++i$1) {
|
|
22886
|
+
const code = path$1.charCodeAt(i$1);
|
|
22887
22887
|
if (code < 32 || code === 127 || code === 59) throw new Error("Invalid cookie path");
|
|
22888
22888
|
}
|
|
22889
22889
|
}
|
|
@@ -25991,9 +25991,9 @@ var require_undici = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
25991
25991
|
if (opts != null && typeof opts !== "object") throw new InvalidArgumentError("invalid opts");
|
|
25992
25992
|
if (opts && opts.path != null) {
|
|
25993
25993
|
if (typeof opts.path !== "string") throw new InvalidArgumentError("invalid opts.path");
|
|
25994
|
-
let path$
|
|
25995
|
-
if (!opts.path.startsWith("/")) path$
|
|
25996
|
-
url = new URL(util$3.parseOrigin(url).origin + path$
|
|
25994
|
+
let path$1 = opts.path;
|
|
25995
|
+
if (!opts.path.startsWith("/")) path$1 = `/${path$1}`;
|
|
25996
|
+
url = new URL(util$3.parseOrigin(url).origin + path$1);
|
|
25997
25997
|
} else {
|
|
25998
25998
|
if (!opts) opts = typeof url === "object" ? url : {};
|
|
25999
25999
|
url = util$3.parseURL(url);
|
|
@@ -30369,7 +30369,7 @@ __reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
|
|
|
30369
30369
|
var mod_esm_default = import_mod_cjs.default;
|
|
30370
30370
|
function getGlobalWranglerConfigPath() {
|
|
30371
30371
|
const configDir = mod_esm_default(".wrangler").config();
|
|
30372
|
-
const legacyConfigDir =
|
|
30372
|
+
const legacyConfigDir = path3.join(os.homedir(), ".wrangler");
|
|
30373
30373
|
if (isDirectory(legacyConfigDir)) return legacyConfigDir;
|
|
30374
30374
|
else return configDir;
|
|
30375
30375
|
}
|
|
@@ -30465,7 +30465,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({ variableName: "WRA
|
|
|
30465
30465
|
var getRegistryPath = getEnvironmentVariableFactory({
|
|
30466
30466
|
variableName: "WRANGLER_REGISTRY_PATH",
|
|
30467
30467
|
defaultValue() {
|
|
30468
|
-
return
|
|
30468
|
+
return path3.join(getGlobalWranglerConfigPath(), "registry");
|
|
30469
30469
|
}
|
|
30470
30470
|
});
|
|
30471
30471
|
var getD1ExtraLocationChoices = getEnvironmentVariableFactory({ variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES" });
|
|
@@ -30877,7 +30877,7 @@ function isPagesConfig(rawConfig) {
|
|
|
30877
30877
|
}
|
|
30878
30878
|
__name(isPagesConfig, "isPagesConfig");
|
|
30879
30879
|
function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
|
|
30880
|
-
const diagnostics = new Diagnostics(`Processing ${configPath ?
|
|
30880
|
+
const diagnostics = new Diagnostics(`Processing ${configPath ? path3.relative(process.cwd(), configPath) : "wrangler"} configuration:`);
|
|
30881
30881
|
validateOptionalProperty(diagnostics, "", "legacy_env", rawConfig.legacy_env, "boolean");
|
|
30882
30882
|
validateOptionalProperty(diagnostics, "", "send_metrics", rawConfig.send_metrics, "boolean");
|
|
30883
30883
|
validateOptionalProperty(diagnostics, "", "keep_vars", rawConfig.keep_vars, "boolean");
|
|
@@ -30981,34 +30981,34 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
|
|
|
30981
30981
|
else validateOptionalProperty(diagnostics, "build", "watch_dir", watch_dir, "string");
|
|
30982
30982
|
return {
|
|
30983
30983
|
command,
|
|
30984
|
-
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) =>
|
|
30984
|
+
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) => path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${dir}`))) : path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${watch_dir}`)) : watch_dir,
|
|
30985
30985
|
cwd
|
|
30986
30986
|
};
|
|
30987
30987
|
}
|
|
30988
30988
|
__name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
|
|
30989
30989
|
function normalizeAndValidateMainField(configPath, rawMain) {
|
|
30990
|
-
const configDir =
|
|
30990
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
30991
30991
|
if (rawMain !== void 0) if (typeof rawMain === "string") {
|
|
30992
|
-
const directory =
|
|
30993
|
-
return
|
|
30992
|
+
const directory = path3.resolve(configDir);
|
|
30993
|
+
return path3.resolve(directory, rawMain);
|
|
30994
30994
|
} else return rawMain;
|
|
30995
30995
|
else return;
|
|
30996
30996
|
}
|
|
30997
30997
|
__name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
|
|
30998
30998
|
function normalizeAndValidateBaseDirField(configPath, rawDir) {
|
|
30999
|
-
const configDir =
|
|
30999
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
31000
31000
|
if (rawDir !== void 0) if (typeof rawDir === "string") {
|
|
31001
|
-
const directory =
|
|
31002
|
-
return
|
|
31001
|
+
const directory = path3.resolve(configDir);
|
|
31002
|
+
return path3.resolve(directory, rawDir);
|
|
31003
31003
|
} else return rawDir;
|
|
31004
31004
|
else return;
|
|
31005
31005
|
}
|
|
31006
31006
|
__name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
|
|
31007
31007
|
function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
|
|
31008
|
-
const configDir =
|
|
31008
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
31009
31009
|
if (rawPagesDir !== void 0) if (typeof rawPagesDir === "string") {
|
|
31010
|
-
const directory =
|
|
31011
|
-
return
|
|
31010
|
+
const directory = path3.resolve(configDir);
|
|
31011
|
+
return path3.resolve(directory, rawPagesDir);
|
|
31012
31012
|
} else return rawPagesDir;
|
|
31013
31013
|
else return;
|
|
31014
31014
|
}
|
|
@@ -31061,7 +31061,7 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
|
|
|
31061
31061
|
validateOptionalProperty(diagnostics, "site", "entry-point", rawConfig.site["entry-point"], "string");
|
|
31062
31062
|
deprecated(diagnostics, rawConfig, `site.entry-point`, `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
31063
31063
|
\`\`\`
|
|
31064
|
-
main = "${
|
|
31064
|
+
main = "${path3.join(String(rawConfig.site["entry-point"]) || "workers-site", path3.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js")}"
|
|
31065
31065
|
\`\`\``, false, void 0, "warning");
|
|
31066
31066
|
let siteEntryPoint = rawConfig.site["entry-point"];
|
|
31067
31067
|
if (!mainEntryPoint && !siteEntryPoint) {
|
|
@@ -31074,7 +31074,7 @@ main = "workers-site/index.js"
|
|
|
31074
31074
|
} else if (mainEntryPoint && siteEntryPoint) diagnostics.errors.push(`Don't define both the \`main\` and \`site.entry-point\` fields in your configuration.
|
|
31075
31075
|
They serve the same purpose: to point to the entry-point of your worker.
|
|
31076
31076
|
Delete the deprecated \`site.entry-point\` field from your config.`);
|
|
31077
|
-
if (configPath && siteEntryPoint) siteEntryPoint =
|
|
31077
|
+
if (configPath && siteEntryPoint) siteEntryPoint = path3.relative(process.cwd(), path3.join(path3.dirname(configPath), siteEntryPoint));
|
|
31078
31078
|
return {
|
|
31079
31079
|
bucket,
|
|
31080
31080
|
"entry-point": siteEntryPoint,
|
|
@@ -31106,7 +31106,7 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
|
|
|
31106
31106
|
if (rawMapping === void 0) return;
|
|
31107
31107
|
const mapping = {};
|
|
31108
31108
|
for (const [name, filePath] of Object.entries(rawMapping)) if (isString$2(diagnostics, `${field}['${name}']`, filePath, void 0)) {
|
|
31109
|
-
if (configPath) mapping[name] = configPath ?
|
|
31109
|
+
if (configPath) mapping[name] = configPath ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), filePath)) : filePath;
|
|
31110
31110
|
}
|
|
31111
31111
|
return mapping;
|
|
31112
31112
|
}
|
|
@@ -31263,7 +31263,7 @@ var validateStreamingTailConsumers = /* @__PURE__ */ __name((diagnostics, field,
|
|
|
31263
31263
|
}, "validateStreamingTailConsumers");
|
|
31264
31264
|
function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDispatchNamespace, preserveOriginalMain, envName = "top level", topLevelEnv, useServiceEnvironments, rawConfig) {
|
|
31265
31265
|
deprecated(diagnostics, rawEnv, "node_compat", `The "node_compat" field is no longer supported as of Wrangler v4. Instead, use the \`nodejs_compat\` compatibility flag. This includes the functionality from legacy \`node_compat\` polyfills and natively implemented Node.js APIs. See https://developers.cloudflare.com/workers/runtime-apis/nodejs for more information.`, true, "Removed", "error");
|
|
31266
|
-
experimental(diagnostics, rawEnv, "unsafe");
|
|
31266
|
+
if (topLevelEnv === void 0 || rawConfig?.unsafe === void 0) experimental(diagnostics, rawEnv, "unsafe");
|
|
31267
31267
|
const route = normalizeAndValidateRoute(diagnostics, topLevelEnv, rawEnv);
|
|
31268
31268
|
const account_id = inheritableInWranglerEnvironments(diagnostics, useServiceEnvironments, topLevelEnv, mutateEmptyStringAccountIDValue(diagnostics, rawEnv), "account_id", isString$2, void 0, void 0);
|
|
31269
31269
|
const routes = validateRoutes(diagnostics, topLevelEnv, rawEnv);
|
|
@@ -31354,7 +31354,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
|
31354
31354
|
__name(normalizeAndValidateEnvironment, "normalizeAndValidateEnvironment");
|
|
31355
31355
|
function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath) {
|
|
31356
31356
|
const tsconfig = inheritable(diagnostics, topLevelEnv, rawEnv, "tsconfig", isString$2, void 0);
|
|
31357
|
-
return configPath && tsconfig ?
|
|
31357
|
+
return configPath && tsconfig ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), tsconfig)) : tsconfig;
|
|
31358
31358
|
}
|
|
31359
31359
|
__name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
|
|
31360
31360
|
var validateAndNormalizeRules = /* @__PURE__ */ __name((diagnostics, topLevelEnv, rawEnv, envName) => {
|
|
@@ -31426,9 +31426,11 @@ var validateDefines = /* @__PURE__ */ __name((envName) => (diagnostics, field, v
|
|
|
31426
31426
|
if (configDefines.length > 0) {
|
|
31427
31427
|
if (typeof value === "object" && value !== null) {
|
|
31428
31428
|
const configEnvDefines = config === void 0 ? [] : Object.keys(value);
|
|
31429
|
-
|
|
31430
|
-
|
|
31431
|
-
|
|
31429
|
+
const missingDefines = configDefines.filter((varName) => !(varName in value));
|
|
31430
|
+
if (missingDefines.length > 0) diagnostics.warnings.push(`The following define entries exist at the top level, but not on "${fieldPath}".
|
|
31431
|
+
This is probably not what you want, since "define" configuration is not inherited by environments.
|
|
31432
|
+
Please add these entries to "env.${envName}.define":
|
|
31433
|
+
` + missingDefines.map((varName) => `- ${varName}`).join("\n"));
|
|
31432
31434
|
for (const varName of configEnvDefines) if (!configDefines.includes(varName)) diagnostics.warnings.push(`"${varName}" exists on "env.${envName}", but not on the top level.
|
|
31433
31435
|
This is not what you probably want, since "define" configuration within environments can only override existing top level "define" configuration
|
|
31434
31436
|
Please remove "${fieldPath}.${varName}", or add "define.${varName}".`);
|
|
@@ -31452,9 +31454,11 @@ var validateVars = /* @__PURE__ */ __name((envName) => (diagnostics, field, valu
|
|
|
31452
31454
|
const configVars = Object.keys(config?.vars ?? {});
|
|
31453
31455
|
if (configVars.length > 0) {
|
|
31454
31456
|
if (typeof value === "object" && value !== null) {
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31457
|
+
const missingVars = configVars.filter((varName) => !(varName in value));
|
|
31458
|
+
if (missingVars.length > 0) diagnostics.warnings.push(`The following vars exist at the top level, but not on "${fieldPath}".
|
|
31459
|
+
This is probably not what you want, since "vars" configuration is not inherited by environments.
|
|
31460
|
+
Please add these vars to "env.${envName}.vars":
|
|
31461
|
+
` + missingVars.map((varName) => `- ${varName}`).join("\n"));
|
|
31458
31462
|
}
|
|
31459
31463
|
}
|
|
31460
31464
|
return isValid2;
|
|
@@ -31827,9 +31831,9 @@ function validateContainerApp(envName, topLevelName, configPath) {
|
|
|
31827
31831
|
let resolvedBuildContextPath = void 0;
|
|
31828
31832
|
try {
|
|
31829
31833
|
if (isDockerfile(resolvedImage, configPath)) {
|
|
31830
|
-
const baseDir = configPath ?
|
|
31831
|
-
resolvedImage =
|
|
31832
|
-
resolvedBuildContextPath = containerAppOptional.image_build_context ?
|
|
31834
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
31835
|
+
resolvedImage = path3.resolve(baseDir, resolvedImage);
|
|
31836
|
+
resolvedBuildContextPath = containerAppOptional.image_build_context ? path3.resolve(baseDir, containerAppOptional.image_build_context) : path3.dirname(resolvedImage);
|
|
31833
31837
|
}
|
|
31834
31838
|
} catch (err) {
|
|
31835
31839
|
if (err instanceof Error && err.message) diagnostics.errors.push(err.message);
|
|
@@ -32968,8 +32972,8 @@ function isRemoteValid(targetObject, fieldPath, diagnostics) {
|
|
|
32968
32972
|
}
|
|
32969
32973
|
__name(isRemoteValid, "isRemoteValid");
|
|
32970
32974
|
function isDockerfile(imagePath, configPath) {
|
|
32971
|
-
const baseDir = configPath ?
|
|
32972
|
-
const maybeDockerfile =
|
|
32975
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
32976
|
+
const maybeDockerfile = path3.resolve(baseDir, imagePath);
|
|
32973
32977
|
if (fs.existsSync(maybeDockerfile)) {
|
|
32974
32978
|
if (isDirectory(maybeDockerfile)) throw new UserError(`${imagePath} is a directory, you should specify a path to the Dockerfile`, { telemetryMessage: false });
|
|
32975
32979
|
return true;
|
|
@@ -33475,27 +33479,36 @@ function startTunnel(options) {
|
|
|
33475
33479
|
const timeoutMs = options.timeoutMs ?? TUNNEL_STARTUP_TIMEOUT_MS;
|
|
33476
33480
|
const reminderIntervalMs = options.reminderIntervalMs ?? DEFAULT_TUNNEL_REMINDER_INTERVAL_MS;
|
|
33477
33481
|
const defaultExpiryMs = options.expiryMs ?? DEFAULT_TUNNEL_EXPIRY_MS;
|
|
33482
|
+
const isNamedTunnel = options.token !== void 0;
|
|
33478
33483
|
const timeFormatter = new Intl.DateTimeFormat(void 0, { timeStyle: "short" });
|
|
33479
|
-
const readyPromise = spawnCloudflared([
|
|
33484
|
+
const readyPromise = spawnCloudflared(isNamedTunnel ? [
|
|
33485
|
+
"tunnel",
|
|
33486
|
+
"--no-autoupdate",
|
|
33487
|
+
"run"
|
|
33488
|
+
] : [
|
|
33480
33489
|
"tunnel",
|
|
33481
33490
|
"--no-autoupdate",
|
|
33482
33491
|
"--url",
|
|
33483
33492
|
options.origin.href
|
|
33484
33493
|
], {
|
|
33485
33494
|
stdio: "pipe",
|
|
33495
|
+
env: options.token ? { TUNNEL_TOKEN: options.token } : void 0,
|
|
33486
33496
|
skipVersionCheck: true,
|
|
33487
33497
|
logger
|
|
33488
33498
|
}).then((process2) => {
|
|
33489
33499
|
cloudflaredProcess = process2;
|
|
33490
33500
|
if (disposed) terminateCloudflared(process2);
|
|
33491
33501
|
return process2;
|
|
33492
|
-
}).then((process2) =>
|
|
33493
|
-
|
|
33494
|
-
|
|
33495
|
-
|
|
33502
|
+
}).then((process2) => {
|
|
33503
|
+
if (isNamedTunnel) return { mode: "named" };
|
|
33504
|
+
return waitForQuickTunnelReady(process2, timeoutMs, {
|
|
33505
|
+
logger,
|
|
33506
|
+
origin: options.origin
|
|
33507
|
+
});
|
|
33508
|
+
}).then((result) => {
|
|
33496
33509
|
expiresAt = Date.now() + defaultExpiryMs;
|
|
33497
33510
|
scheduleExpiryTimeout();
|
|
33498
|
-
scheduleReminder(result.publicUrl.origin);
|
|
33511
|
+
scheduleReminder(result.mode === "quick" ? result.publicUrl.origin : void 0);
|
|
33499
33512
|
return result;
|
|
33500
33513
|
});
|
|
33501
33514
|
function disposeTunnel() {
|
|
@@ -33521,7 +33534,7 @@ function startTunnel(options) {
|
|
|
33521
33534
|
if (disposed) return;
|
|
33522
33535
|
const remainingMs = expiresAt - Date.now();
|
|
33523
33536
|
if (remainingMs <= 0) return;
|
|
33524
|
-
logger?.log(`The tunnel is still open at ${publicURL}. It expires in ${formatTunnelDuration(remainingMs)}. ${options.extendHint ?? ""}`);
|
|
33537
|
+
logger?.log(`${publicURL ? `The tunnel is still open at ${publicURL}.` : "The tunnel is still open."} It expires in ${formatTunnelDuration(remainingMs)}. ${options.extendHint ?? ""}`);
|
|
33525
33538
|
}, reminderIntervalMs);
|
|
33526
33539
|
reminderInterval.unref?.();
|
|
33527
33540
|
}
|
|
@@ -33555,6 +33568,7 @@ function startTunnel(options) {
|
|
|
33555
33568
|
__name(extendExpiry, "extendExpiry");
|
|
33556
33569
|
return {
|
|
33557
33570
|
ready: /* @__PURE__ */ __name(() => readyPromise, "ready"),
|
|
33571
|
+
isOpen: /* @__PURE__ */ __name(() => !disposed, "isOpen"),
|
|
33558
33572
|
dispose: disposeTunnel,
|
|
33559
33573
|
extendExpiry
|
|
33560
33574
|
};
|
|
@@ -33600,7 +33614,10 @@ function waitForQuickTunnelReady(cloudflared, timeoutMs, options) {
|
|
|
33600
33614
|
if (match && !resolved) {
|
|
33601
33615
|
resolved = true;
|
|
33602
33616
|
clearTimeout(timeoutId);
|
|
33603
|
-
resolve$4({
|
|
33617
|
+
resolve$4({
|
|
33618
|
+
mode: "quick",
|
|
33619
|
+
publicUrl: new URL(match[0])
|
|
33620
|
+
});
|
|
33604
33621
|
}
|
|
33605
33622
|
});
|
|
33606
33623
|
cloudflared.on("error", (error) => {
|
|
@@ -33808,53 +33825,84 @@ var require_picocolors = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
33808
33825
|
//#endregion
|
|
33809
33826
|
//#region src/plugins/tunnel.ts
|
|
33810
33827
|
var import_picocolors$5 = /* @__PURE__ */ __toESM$1(require_picocolors(), 1);
|
|
33811
|
-
|
|
33812
|
-
"
|
|
33813
|
-
|
|
33814
|
-
|
|
33815
|
-
|
|
33816
|
-
|
|
33817
|
-
|
|
33818
|
-
|
|
33819
|
-
|
|
33820
|
-
|
|
33821
|
-
|
|
33828
|
+
function createPublicExposureWarning(mode, name, shortcutPressed) {
|
|
33829
|
+
const intro = name === void 0 ? import_picocolors$5.default.dim("Once connected, this tunnel will be ") + "publicly accessible" + import_picocolors$5.default.dim(". Anyone who can reach it can:") : import_picocolors$5.default.dim("Once connected, this tunnel may be reachable from the Internet. Anyone who can reach it can:");
|
|
33830
|
+
const concerns = [
|
|
33831
|
+
"Call ungated endpoints",
|
|
33832
|
+
"Trigger logic that uses remote bindings",
|
|
33833
|
+
"Reach internal services if your Worker proxies requests"
|
|
33834
|
+
];
|
|
33835
|
+
const hints = [name === void 0 ? "Consider using a named tunnel with Cloudflare Access to restrict access." : "Consider using Cloudflare Access to restrict access."];
|
|
33836
|
+
if (mode === "dev") {
|
|
33837
|
+
concerns.push("Request module source and other dev-server assets", "Access HMR messages, including absolute file system paths", "Observe file-change cadence and parts of the live module graph");
|
|
33838
|
+
hints.unshift("If you only need to share a running build, use vite preview to avoid HMR and other dev-server exposure.");
|
|
33839
|
+
}
|
|
33840
|
+
const lines = [
|
|
33841
|
+
intro,
|
|
33842
|
+
...concerns.map((concern) => import_picocolors$5.default.dim(`• ${concern}`)),
|
|
33822
33843
|
"",
|
|
33823
|
-
import_picocolors$5.default.dim(
|
|
33844
|
+
...hints.map((guidance) => import_picocolors$5.default.dim(guidance)),
|
|
33824
33845
|
""
|
|
33825
|
-
]
|
|
33846
|
+
];
|
|
33847
|
+
if (shortcutPressed) lines.push("Press t + enter again to close the tunnel.", "");
|
|
33848
|
+
const spacing = " ";
|
|
33849
|
+
return lines.map((line) => spacing + line).join("\n");
|
|
33826
33850
|
}
|
|
33827
|
-
const DEV_PUBLIC_EXPOSURE_WARNING = createPublicExposureWarning([
|
|
33828
|
-
...COMMON_PUBLIC_EXPOSURE_CONCERNS,
|
|
33829
|
-
"Request module source and other dev-server assets",
|
|
33830
|
-
"Access HMR messages, including absolute file system paths",
|
|
33831
|
-
"Observe file-change cadence and parts of the live module graph"
|
|
33832
|
-
], `If you only need to share a running build, use vite preview to avoid HMR and other dev-server exposure. ${COMMON_PUBLIC_EXPOSURE_GUIDANCE}`);
|
|
33833
|
-
const PREVIEW_PUBLIC_EXPOSURE_WARNING = createPublicExposureWarning(COMMON_PUBLIC_EXPOSURE_CONCERNS, COMMON_PUBLIC_EXPOSURE_GUIDANCE);
|
|
33834
33851
|
const QUICK_TUNNEL_SSE_WARNING = "Quick tunnels do not support Server-Sent Events (SSE). Use a named Cloudflare Tunnel if you need SSE over a public URL.";
|
|
33835
33852
|
const QUICK_TUNNEL_ALLOWED_HOST = ".trycloudflare.com";
|
|
33836
33853
|
var TunnelManager = class {
|
|
33837
33854
|
#logger;
|
|
33838
33855
|
#origin;
|
|
33839
|
-
#
|
|
33856
|
+
#publicUrls;
|
|
33857
|
+
#requestedTunnel;
|
|
33840
33858
|
#tunnel;
|
|
33859
|
+
#abortController;
|
|
33841
33860
|
#hasWarnedAboutSse = false;
|
|
33842
33861
|
constructor(logger) {
|
|
33843
33862
|
this.#logger = logger;
|
|
33844
33863
|
}
|
|
33845
|
-
isStarted(origin) {
|
|
33846
|
-
return this.#origin === origin && this.#
|
|
33864
|
+
isStarted(origin, name) {
|
|
33865
|
+
return this.#origin === origin && this.#requestedTunnel === name;
|
|
33847
33866
|
}
|
|
33848
|
-
|
|
33867
|
+
isOpen() {
|
|
33868
|
+
if (!this.#tunnel) return this.#origin !== void 0;
|
|
33869
|
+
const isOpen = this.#tunnel.isOpen();
|
|
33870
|
+
if (!isOpen) {
|
|
33871
|
+
this.#tunnel = void 0;
|
|
33872
|
+
this.dispose();
|
|
33873
|
+
}
|
|
33874
|
+
return isOpen;
|
|
33875
|
+
}
|
|
33876
|
+
async startTunnel(options) {
|
|
33849
33877
|
try {
|
|
33850
|
-
if (this.#origin === origin && this.#tunnel) return await this.#waitForPublicUrl(this.#tunnel);
|
|
33851
|
-
this.#logger.info(import_picocolors$5.default.dim("\n ➜ Starting tunnel (usually takes a few seconds)...\n"));
|
|
33852
33878
|
if (this.#tunnel) this.dispose();
|
|
33853
|
-
|
|
33854
|
-
this.#
|
|
33879
|
+
const abortController = new AbortController();
|
|
33880
|
+
this.#abortController = abortController;
|
|
33881
|
+
this.#origin = options.origin;
|
|
33882
|
+
this.#requestedTunnel = options.name;
|
|
33883
|
+
this.#logger.info(import_picocolors$5.default.dim("\n ➜ Starting tunnel (usually takes a few seconds)...\n"));
|
|
33884
|
+
this.#logger.warn(createPublicExposureWarning(options.mode, options.name, options.shortcutPressed ?? false));
|
|
33885
|
+
const namedTunnel = options.name !== void 0 ? await wrangler.unstable_resolveNamedTunnel(options.name, new URL(options.origin), {
|
|
33886
|
+
accountId: options.accountId,
|
|
33887
|
+
complianceRegion: options.complianceRegion
|
|
33888
|
+
}) : void 0;
|
|
33889
|
+
if (abortController.signal.aborted) return null;
|
|
33890
|
+
if (namedTunnel) this.#publicUrls = namedTunnel.hostnames.map((hostname) => `https://${hostname}`);
|
|
33891
|
+
if (options.mode === "preview") {
|
|
33892
|
+
if (namedTunnel) {
|
|
33893
|
+
const allowedUrls = getAllowedTunnelUrls(this.#publicUrls ?? [], options.allowedHosts);
|
|
33894
|
+
if (allowedUrls.length === 0) {
|
|
33895
|
+
const suggestedAllowedHosts = getSuggestedAllowedHosts(namedTunnel.hostnames);
|
|
33896
|
+
throw new Error("The resolved tunnel hostnames are not allowed by Vite preview host validation.\n\nAdd at least one of these hosts to `preview.allowedHosts` in your Vite config.\nYou can use exact hostnames or a domain suffix:\n" + suggestedAllowedHosts.map((hostname) => ` - ${hostname}`).join("\n") + "\n");
|
|
33897
|
+
}
|
|
33898
|
+
this.#publicUrls = allowedUrls;
|
|
33899
|
+
} else if (!isQuickTunnelAllowed(options.allowedHosts)) throw new Error(`Quick tunnel hostnames are not allowed by Vite preview host validation.
|
|
33900
|
+
Add \`${QUICK_TUNNEL_ALLOWED_HOST}\` to \`preview.allowedHosts\` in your Vite config.\n`);
|
|
33901
|
+
}
|
|
33855
33902
|
const tunnel = startTunnel({
|
|
33856
|
-
origin: new URL(origin),
|
|
33857
|
-
|
|
33903
|
+
origin: new URL(options.origin),
|
|
33904
|
+
token: namedTunnel?.token,
|
|
33905
|
+
extendHint: "Press a + enter to extend by 1 hour.",
|
|
33858
33906
|
logger: {
|
|
33859
33907
|
log: (message) => this.#logger.info(message),
|
|
33860
33908
|
warn: (message) => this.#logger.warn(message),
|
|
@@ -33862,47 +33910,54 @@ var TunnelManager = class {
|
|
|
33862
33910
|
}
|
|
33863
33911
|
});
|
|
33864
33912
|
this.#tunnel = tunnel;
|
|
33865
|
-
return await this.#
|
|
33913
|
+
return await this.#waitForPublicUrls(tunnel);
|
|
33866
33914
|
} catch (error) {
|
|
33867
|
-
|
|
33915
|
+
this.#origin = void 0;
|
|
33916
|
+
this.#publicUrls = void 0;
|
|
33917
|
+
this.#requestedTunnel = void 0;
|
|
33918
|
+
throw error;
|
|
33868
33919
|
}
|
|
33869
33920
|
}
|
|
33870
|
-
async #
|
|
33921
|
+
async #waitForPublicUrls(tunnel) {
|
|
33871
33922
|
try {
|
|
33872
|
-
const
|
|
33923
|
+
const result = await tunnel.ready();
|
|
33873
33924
|
if (this.#tunnel !== tunnel) {
|
|
33874
|
-
debuglog("Tunnel was restarted before it finished starting. Ignoring this tunnel's public URL:", publicUrl);
|
|
33925
|
+
debuglog("Tunnel was restarted before it finished starting. Ignoring this tunnel's public URL:", result.mode === "quick" ? result.publicUrl : this.#publicUrls);
|
|
33875
33926
|
return null;
|
|
33876
33927
|
}
|
|
33928
|
+
if (result.mode === "named") return this.#publicUrls ?? null;
|
|
33929
|
+
const { publicUrl } = result;
|
|
33877
33930
|
debuglog("Tunnel is ready with public URL:", publicUrl);
|
|
33878
|
-
this.#
|
|
33879
|
-
return
|
|
33931
|
+
this.#publicUrls = [publicUrl.toString()];
|
|
33932
|
+
return this.#publicUrls;
|
|
33880
33933
|
} catch (error) {
|
|
33881
33934
|
if (this.#tunnel !== tunnel) return null;
|
|
33882
|
-
this.#publicUrl = void 0;
|
|
33883
33935
|
this.#tunnel = void 0;
|
|
33884
33936
|
throw error;
|
|
33885
33937
|
}
|
|
33886
33938
|
}
|
|
33887
|
-
get
|
|
33888
|
-
return this.#
|
|
33939
|
+
get publicUrls() {
|
|
33940
|
+
return this.#publicUrls;
|
|
33889
33941
|
}
|
|
33890
33942
|
extendExpiry() {
|
|
33891
33943
|
this.#tunnel?.extendExpiry();
|
|
33892
33944
|
}
|
|
33893
33945
|
warnIfQuickTunnelSseResponse(contentType) {
|
|
33894
|
-
if (this.#hasWarnedAboutSse || !this.#tunnel || contentType === null || !contentType.toLowerCase().startsWith("text/event-stream")) return;
|
|
33946
|
+
if (this.#hasWarnedAboutSse || this.#requestedTunnel !== void 0 || !this.#tunnel || contentType === null || !contentType.toLowerCase().startsWith("text/event-stream")) return;
|
|
33895
33947
|
this.#hasWarnedAboutSse = true;
|
|
33896
33948
|
this.#logger.warn(QUICK_TUNNEL_SSE_WARNING);
|
|
33897
33949
|
}
|
|
33898
33950
|
dispose() {
|
|
33899
33951
|
const tunnel = this.#tunnel;
|
|
33952
|
+
this.#abortController?.abort();
|
|
33900
33953
|
this.#origin = void 0;
|
|
33901
|
-
this.#
|
|
33954
|
+
this.#publicUrls = void 0;
|
|
33955
|
+
this.#requestedTunnel = void 0;
|
|
33902
33956
|
this.#tunnel = void 0;
|
|
33903
33957
|
this.#hasWarnedAboutSse = false;
|
|
33904
33958
|
debuglog("Disposing tunnel...");
|
|
33905
33959
|
if (tunnel) tunnel.dispose();
|
|
33960
|
+
this.#logger.info(" ➜ Tunnel closed");
|
|
33906
33961
|
}
|
|
33907
33962
|
disposeOnExit() {
|
|
33908
33963
|
try {
|
|
@@ -33922,6 +33977,16 @@ function warnIfQuickTunnelSseResponse(contentType) {
|
|
|
33922
33977
|
function extendTunnelExpiry() {
|
|
33923
33978
|
tunnelManager?.extendExpiry();
|
|
33924
33979
|
}
|
|
33980
|
+
async function toggleTunnel(server, ctx) {
|
|
33981
|
+
if (!tunnelManager) return;
|
|
33982
|
+
if (tunnelManager.isOpen()) {
|
|
33983
|
+
ctx.clearTunnelHostnames();
|
|
33984
|
+
tunnelManager.dispose();
|
|
33985
|
+
return;
|
|
33986
|
+
}
|
|
33987
|
+
if ("restart" in server) await setupDevTunnel(server, ctx, tunnelManager, true);
|
|
33988
|
+
else await setupPreviewTunnel(server, ctx, tunnelManager, true);
|
|
33989
|
+
}
|
|
33925
33990
|
/**
|
|
33926
33991
|
* Resolve the dev tunnel origin from the running server.
|
|
33927
33992
|
*
|
|
@@ -33952,8 +34017,8 @@ async function resolveDevTunnelOrigin(server) {
|
|
|
33952
34017
|
async function resolvePreviewTunnelOrigin(server) {
|
|
33953
34018
|
const { preview } = server.config;
|
|
33954
34019
|
const host = typeof preview.host === "string" ? preview.host : void 0;
|
|
33955
|
-
let resolvedPort;
|
|
33956
|
-
if (preview.port === 0) resolvedPort = await getPorts({
|
|
34020
|
+
let resolvedPort = preview.port;
|
|
34021
|
+
if (!server.httpServer.listening) if (preview.port === 0) resolvedPort = await getPorts({
|
|
33957
34022
|
port: 0,
|
|
33958
34023
|
host
|
|
33959
34024
|
});
|
|
@@ -33978,18 +34043,28 @@ async function resolvePreviewTunnelOrigin(server) {
|
|
|
33978
34043
|
secure: !!preview.https
|
|
33979
34044
|
}));
|
|
33980
34045
|
}
|
|
33981
|
-
async function setupDevTunnel(server, ctx, manager) {
|
|
34046
|
+
async function setupDevTunnel(server, ctx, manager, shortcutPressed) {
|
|
33982
34047
|
const origin = await resolveDevTunnelOrigin(server);
|
|
33983
|
-
|
|
34048
|
+
const tunnel = ctx.resolvedPluginConfig.tunnel;
|
|
34049
|
+
if (manager.isStarted(origin, tunnel.name)) {
|
|
33984
34050
|
debuglog("Tunnel is already started on", origin);
|
|
33985
34051
|
return;
|
|
33986
34052
|
}
|
|
33987
|
-
const
|
|
33988
|
-
|
|
34053
|
+
const publicUrls = await manager.startTunnel({
|
|
34054
|
+
mode: "dev",
|
|
34055
|
+
origin,
|
|
34056
|
+
shortcutPressed,
|
|
34057
|
+
name: tunnel.name,
|
|
34058
|
+
accountId: ctx.entryWorkerConfig?.account_id,
|
|
34059
|
+
complianceRegion: ctx.entryWorkerConfig?.compliance_region,
|
|
34060
|
+
allowedHosts: true
|
|
34061
|
+
});
|
|
34062
|
+
if (!publicUrls) return;
|
|
33989
34063
|
const allowedHosts = server.config.server.allowedHosts;
|
|
33990
|
-
const tunnelHostnames =
|
|
34064
|
+
const tunnelHostnames = publicUrls.map((url) => new URL(url).hostname);
|
|
33991
34065
|
ctx.replaceTunnelHostnames(tunnelHostnames);
|
|
33992
34066
|
if (allowedHosts !== true && tunnelHostnames.some((hostname) => !allowedHosts.includes(hostname))) await server.restart();
|
|
34067
|
+
if (shortcutPressed) server.printUrls();
|
|
33993
34068
|
}
|
|
33994
34069
|
/**
|
|
33995
34070
|
* Start a preview tunnel on the resolved preview origin.
|
|
@@ -33997,7 +34072,7 @@ async function setupDevTunnel(server, ctx, manager) {
|
|
|
33997
34072
|
* We write the resolved port back to preview config so the server binds the
|
|
33998
34073
|
* same port that the tunnel is sharing.
|
|
33999
34074
|
*/
|
|
34000
|
-
async function setupPreviewTunnel(server, manager) {
|
|
34075
|
+
async function setupPreviewTunnel(server, ctx, manager, shortcutPressed) {
|
|
34001
34076
|
const { preview } = server.config;
|
|
34002
34077
|
const originalPort = preview.port;
|
|
34003
34078
|
const resolvedOrigin = await resolvePreviewTunnelOrigin(server);
|
|
@@ -34005,17 +34080,58 @@ async function setupPreviewTunnel(server, manager) {
|
|
|
34005
34080
|
preview.port = resolvedPort;
|
|
34006
34081
|
preview.strictPort = true;
|
|
34007
34082
|
if (originalPort !== 0 && resolvedPort !== originalPort) server.config.logger.info(import_picocolors$5.default.dim(`Port ${originalPort} is in use, using ${resolvedPort} instead for preview tunnel sharing.\n`));
|
|
34008
|
-
|
|
34009
|
-
|
|
34010
|
-
|
|
34083
|
+
const tunnel = ctx.resolvedPluginConfig.tunnel;
|
|
34084
|
+
const origin = resolvedOrigin.toString();
|
|
34085
|
+
if (manager.isStarted(origin, tunnel.name)) {
|
|
34086
|
+
debuglog("Tunnel is already started on", origin);
|
|
34087
|
+
return;
|
|
34088
|
+
}
|
|
34089
|
+
if (!await manager.startTunnel({
|
|
34090
|
+
mode: "preview",
|
|
34091
|
+
origin,
|
|
34092
|
+
shortcutPressed,
|
|
34093
|
+
name: tunnel.name,
|
|
34094
|
+
allowedHosts: preview?.allowedHosts,
|
|
34095
|
+
accountId: ctx.allWorkerConfigs[0]?.account_id,
|
|
34096
|
+
complianceRegion: ctx.allWorkerConfigs[0]?.compliance_region
|
|
34097
|
+
})) return;
|
|
34098
|
+
if (shortcutPressed) server.printUrls();
|
|
34099
|
+
}
|
|
34100
|
+
function patchPrintUrls(server) {
|
|
34011
34101
|
const serverPrintUrls = server.printUrls.bind(server);
|
|
34012
34102
|
server.printUrls = () => {
|
|
34013
34103
|
serverPrintUrls();
|
|
34014
|
-
const
|
|
34015
|
-
if (!
|
|
34016
|
-
server.config.logger.info(`${import_picocolors$5.default.green(" ➜")} ${import_picocolors$5.default.bold("Tunnel:")} ${import_picocolors$5.default.cyan(
|
|
34017
|
-
server.config.logger.
|
|
34018
|
-
|
|
34104
|
+
const publicUrls = tunnelManager?.publicUrls;
|
|
34105
|
+
if (!publicUrls || publicUrls.length === 0) return;
|
|
34106
|
+
for (let i$1 = 0; i$1 < publicUrls.length; i$1++) if (i$1 === 0) server.config.logger.info(`${import_picocolors$5.default.green(" ➜")} ${import_picocolors$5.default.bold("Tunnel:")} ${import_picocolors$5.default.cyan(publicUrls[i$1])}`);
|
|
34107
|
+
else server.config.logger.info(` ${import_picocolors$5.default.cyan(publicUrls[i$1])}`);
|
|
34108
|
+
server.config.logger.info("");
|
|
34109
|
+
};
|
|
34110
|
+
}
|
|
34111
|
+
function isQuickTunnelAllowed(allowedHosts) {
|
|
34112
|
+
if (allowedHosts === void 0) return false;
|
|
34113
|
+
if (allowedHosts === true) return true;
|
|
34114
|
+
return allowedHosts.some((allowedHost) => allowedHost.toLowerCase() === QUICK_TUNNEL_ALLOWED_HOST);
|
|
34115
|
+
}
|
|
34116
|
+
function getAllowedTunnelUrls(publicUrls, allowedHosts) {
|
|
34117
|
+
if (allowedHosts === void 0) return [];
|
|
34118
|
+
if (allowedHosts === true) return publicUrls;
|
|
34119
|
+
return publicUrls.filter((publicUrl) => {
|
|
34120
|
+
const hostname = new URL(publicUrl).hostname.toLowerCase();
|
|
34121
|
+
return allowedHosts.some((allowedHost) => {
|
|
34122
|
+
const normalizedAllowedHost = allowedHost.toLowerCase();
|
|
34123
|
+
if (normalizedAllowedHost.startsWith(".")) return hostname === normalizedAllowedHost.slice(1) || hostname.endsWith(normalizedAllowedHost);
|
|
34124
|
+
return hostname === normalizedAllowedHost;
|
|
34125
|
+
});
|
|
34126
|
+
});
|
|
34127
|
+
}
|
|
34128
|
+
function getSuggestedAllowedHosts(hostnames) {
|
|
34129
|
+
const suggestions = new Set(hostnames);
|
|
34130
|
+
for (const hostname of hostnames) {
|
|
34131
|
+
const segments = hostname.split(".");
|
|
34132
|
+
if (segments.length > 2) suggestions.add(`.${segments.slice(1).join(".")}`);
|
|
34133
|
+
}
|
|
34134
|
+
return Array.from(suggestions);
|
|
34019
34135
|
}
|
|
34020
34136
|
const tunnelPlugin = createPlugin("tunnel", (ctx) => {
|
|
34021
34137
|
function stopTunnel() {
|
|
@@ -34028,12 +34144,9 @@ const tunnelPlugin = createPlugin("tunnel", (ctx) => {
|
|
|
34028
34144
|
},
|
|
34029
34145
|
configureServer(server) {
|
|
34030
34146
|
assertIsNotPreview(ctx);
|
|
34031
|
-
if (!ctx.resolvedPluginConfig.tunnel) {
|
|
34032
|
-
stopTunnel();
|
|
34033
|
-
return;
|
|
34034
|
-
}
|
|
34035
34147
|
tunnelManager ??= new TunnelManager(server.config.logger);
|
|
34036
|
-
patchPrintUrls(server
|
|
34148
|
+
patchPrintUrls(server);
|
|
34149
|
+
if (!ctx.resolvedPluginConfig.tunnel.autoStart) return;
|
|
34037
34150
|
const serverListen = server.listen.bind(server);
|
|
34038
34151
|
server.listen = async (...args) => {
|
|
34039
34152
|
const result = await serverListen(...args);
|
|
@@ -34050,13 +34163,9 @@ const tunnelPlugin = createPlugin("tunnel", (ctx) => {
|
|
|
34050
34163
|
},
|
|
34051
34164
|
async configurePreviewServer(server) {
|
|
34052
34165
|
assertIsPreview(ctx);
|
|
34053
|
-
if (!ctx.resolvedPluginConfig.tunnel) {
|
|
34054
|
-
stopTunnel();
|
|
34055
|
-
return;
|
|
34056
|
-
}
|
|
34057
34166
|
tunnelManager ??= new TunnelManager(server.config.logger);
|
|
34058
|
-
patchPrintUrls(server
|
|
34059
|
-
await setupPreviewTunnel(server, tunnelManager);
|
|
34167
|
+
patchPrintUrls(server);
|
|
34168
|
+
if (ctx.resolvedPluginConfig.tunnel.autoStart) await setupPreviewTunnel(server, ctx, tunnelManager);
|
|
34060
34169
|
const closePreviewServer = server.close.bind(server);
|
|
34061
34170
|
server.close = async () => {
|
|
34062
34171
|
const closePromise = closePreviewServer();
|
|
@@ -34094,8 +34203,8 @@ const postfixRE = /[?#].*$/;
|
|
|
34094
34203
|
function cleanUrl(url) {
|
|
34095
34204
|
return url.replace(postfixRE, "");
|
|
34096
34205
|
}
|
|
34097
|
-
function withTrailingSlash(path$
|
|
34098
|
-
return path$
|
|
34206
|
+
function withTrailingSlash(path$1) {
|
|
34207
|
+
return path$1.endsWith("/") ? path$1 : `${path$1}/`;
|
|
34099
34208
|
}
|
|
34100
34209
|
function createRequestHandler(handler) {
|
|
34101
34210
|
return async (req, res, next) => {
|
|
@@ -39492,15 +39601,15 @@ function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
39492
39601
|
function withTrailingSlash$1(input = "", respectQueryAndFragment) {
|
|
39493
39602
|
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
39494
39603
|
if (hasTrailingSlash(input, true)) return input || "/";
|
|
39495
|
-
let path$
|
|
39604
|
+
let path$1 = input;
|
|
39496
39605
|
let fragment = "";
|
|
39497
39606
|
const fragmentIndex = input.indexOf("#");
|
|
39498
39607
|
if (fragmentIndex >= 0) {
|
|
39499
|
-
path$
|
|
39608
|
+
path$1 = input.slice(0, fragmentIndex);
|
|
39500
39609
|
fragment = input.slice(fragmentIndex);
|
|
39501
|
-
if (!path$
|
|
39610
|
+
if (!path$1) return fragment;
|
|
39502
39611
|
}
|
|
39503
|
-
const [s0, ...s] = path$
|
|
39612
|
+
const [s0, ...s] = path$1.split("?");
|
|
39504
39613
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
39505
39614
|
}
|
|
39506
39615
|
function isNonEmptyURL(url) {
|
|
@@ -39526,8 +39635,8 @@ const isAbsolute$1 = function(p$1) {
|
|
|
39526
39635
|
//#endregion
|
|
39527
39636
|
//#region ../../node_modules/.pnpm/mlly@1.7.4/node_modules/mlly/dist/index.mjs
|
|
39528
39637
|
const BUILTIN_MODULES = new Set(builtinModules);
|
|
39529
|
-
function normalizeSlash(path$
|
|
39530
|
-
return path$
|
|
39638
|
+
function normalizeSlash(path$1) {
|
|
39639
|
+
return path$1.replace(/\\/g, "/");
|
|
39531
39640
|
}
|
|
39532
39641
|
/**
|
|
39533
39642
|
* @typedef ErrnoExceptionFields
|
|
@@ -39647,8 +39756,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
39647
39756
|
* @param {string} [base]
|
|
39648
39757
|
* @param {string} [message]
|
|
39649
39758
|
*/
|
|
39650
|
-
(path$
|
|
39651
|
-
return `Invalid package config ${path$
|
|
39759
|
+
(path$1, base, message) => {
|
|
39760
|
+
return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
39652
39761
|
},
|
|
39653
39762
|
Error
|
|
39654
39763
|
);
|
|
@@ -39678,8 +39787,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
39678
39787
|
* @param {string} base
|
|
39679
39788
|
* @param {boolean} [exactUrl]
|
|
39680
39789
|
*/
|
|
39681
|
-
(path$
|
|
39682
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path$
|
|
39790
|
+
(path$1, base, exactUrl = false) => {
|
|
39791
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
|
|
39683
39792
|
},
|
|
39684
39793
|
Error
|
|
39685
39794
|
);
|
|
@@ -39717,8 +39826,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
39717
39826
|
* @param {string} extension
|
|
39718
39827
|
* @param {string} path
|
|
39719
39828
|
*/
|
|
39720
|
-
(extension, path$
|
|
39721
|
-
return `Unknown file extension "${extension}" for ${path$
|
|
39829
|
+
(extension, path$1) => {
|
|
39830
|
+
return `Unknown file extension "${extension}" for ${path$1}`;
|
|
39722
39831
|
},
|
|
39723
39832
|
TypeError
|
|
39724
39833
|
);
|
|
@@ -39875,7 +39984,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
39875
39984
|
/** @type {string | undefined} */
|
|
39876
39985
|
let string;
|
|
39877
39986
|
try {
|
|
39878
|
-
string = fs.readFileSync(
|
|
39987
|
+
string = fs.readFileSync(path3.toNamespacedPath(jsonPath), "utf8");
|
|
39879
39988
|
} catch (error) {
|
|
39880
39989
|
const exception = error;
|
|
39881
39990
|
if (exception.code !== "ENOENT") throw exception;
|
|
@@ -40081,15 +40190,15 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
|
40081
40190
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
40082
40191
|
const basePath = fileURLToPath(base);
|
|
40083
40192
|
if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
40084
|
-
else if (
|
|
40193
|
+
else if (path3.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
40085
40194
|
}
|
|
40086
40195
|
/**
|
|
40087
40196
|
* @param {string} path
|
|
40088
40197
|
* @returns {Stats | undefined}
|
|
40089
40198
|
*/
|
|
40090
|
-
function tryStatSync(path$
|
|
40199
|
+
function tryStatSync(path$1) {
|
|
40091
40200
|
try {
|
|
40092
|
-
return statSync(path$
|
|
40201
|
+
return statSync(path$1);
|
|
40093
40202
|
} catch {}
|
|
40094
40203
|
}
|
|
40095
40204
|
/**
|
|
@@ -40188,7 +40297,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
40188
40297
|
{
|
|
40189
40298
|
const real = realpathSync(filePath);
|
|
40190
40299
|
const { search, hash } = resolved;
|
|
40191
|
-
resolved = pathToFileURL(real + (filePath.endsWith(
|
|
40300
|
+
resolved = pathToFileURL(real + (filePath.endsWith(path3.sep) ? "/" : ""));
|
|
40192
40301
|
resolved.search = search;
|
|
40193
40302
|
resolved.hash = hash;
|
|
40194
40303
|
}
|
|
@@ -41274,7 +41383,10 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
41274
41383
|
const shared = {
|
|
41275
41384
|
persistState: pluginConfig.persistState ?? true,
|
|
41276
41385
|
inspectorPort: pluginConfig.inspectorPort,
|
|
41277
|
-
tunnel: pluginConfig.tunnel
|
|
41386
|
+
tunnel: typeof pluginConfig.tunnel === "boolean" ? { autoStart: pluginConfig.tunnel } : {
|
|
41387
|
+
autoStart: pluginConfig.tunnel?.autoStart ?? false,
|
|
41388
|
+
name: pluginConfig.tunnel?.name
|
|
41389
|
+
},
|
|
41278
41390
|
experimental: { headersAndRedirectsDevModeSupport: pluginConfig.experimental?.headersAndRedirectsDevModeSupport }
|
|
41279
41391
|
};
|
|
41280
41392
|
const root = userConfig.root ? nodePath.resolve(userConfig.root) : process.cwd();
|
|
@@ -42565,9 +42677,9 @@ function constructHeaders({ headers, headersFile, logger }) {
|
|
|
42565
42677
|
|
|
42566
42678
|
//#endregion
|
|
42567
42679
|
//#region ../workers-shared/utils/configuration/validateURL.ts
|
|
42568
|
-
const extractPathname = (path$
|
|
42569
|
-
if (!path$
|
|
42570
|
-
const url = new URL(`//${path$
|
|
42680
|
+
const extractPathname = (path$1 = "/", includeSearch, includeHash) => {
|
|
42681
|
+
if (!path$1.startsWith("/")) path$1 = `/${path$1}`;
|
|
42682
|
+
const url = new URL(`//${path$1}`, "relative://");
|
|
42571
42683
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
42572
42684
|
};
|
|
42573
42685
|
const URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -42626,7 +42738,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42626
42738
|
lineNumber: i$1 + 1,
|
|
42627
42739
|
message: "No headers specified"
|
|
42628
42740
|
});
|
|
42629
|
-
const [path$
|
|
42741
|
+
const [path$1, pathError] = validateUrl(line, false, true);
|
|
42630
42742
|
if (pathError) {
|
|
42631
42743
|
invalid.push({
|
|
42632
42744
|
line,
|
|
@@ -42637,7 +42749,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42637
42749
|
skipUntilNextPath = true;
|
|
42638
42750
|
continue;
|
|
42639
42751
|
}
|
|
42640
|
-
const wildcardError = validateNoMultipleWildcards(path$
|
|
42752
|
+
const wildcardError = validateNoMultipleWildcards(path$1);
|
|
42641
42753
|
if (wildcardError) {
|
|
42642
42754
|
invalid.push({
|
|
42643
42755
|
line,
|
|
@@ -42649,7 +42761,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42649
42761
|
continue;
|
|
42650
42762
|
}
|
|
42651
42763
|
rule = {
|
|
42652
|
-
path: path$
|
|
42764
|
+
path: path$1,
|
|
42653
42765
|
line,
|
|
42654
42766
|
headers: {},
|
|
42655
42767
|
unsetHeaders: []
|
|
@@ -42732,11 +42844,11 @@ function isValidRule(rule) {
|
|
|
42732
42844
|
* `:splat` placeholder, would result in duplicate `:splat` parameters which is
|
|
42733
42845
|
* unsupported.
|
|
42734
42846
|
*/
|
|
42735
|
-
function validateNoMultipleWildcards(path$
|
|
42736
|
-
const wildcardCount = (path$
|
|
42737
|
-
const hasSplatPlaceholder = /:splat(?!\w)/.test(path$
|
|
42738
|
-
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path$
|
|
42739
|
-
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path$
|
|
42847
|
+
function validateNoMultipleWildcards(path$1) {
|
|
42848
|
+
const wildcardCount = (path$1.match(SPLAT_REGEX) ?? []).length;
|
|
42849
|
+
const hasSplatPlaceholder = /:splat(?!\w)/.test(path$1);
|
|
42850
|
+
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path$1}.`;
|
|
42851
|
+
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path$1}.`;
|
|
42740
42852
|
}
|
|
42741
42853
|
|
|
42742
42854
|
//#endregion
|
|
@@ -42953,13 +43065,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
42953
43065
|
const throwError = (message, Ctor) => {
|
|
42954
43066
|
throw new Ctor(message);
|
|
42955
43067
|
};
|
|
42956
|
-
const checkPath = (path$
|
|
42957
|
-
if (!isString$1(path$
|
|
42958
|
-
if (!path$
|
|
42959
|
-
if (checkPath.isNotRelative(path$
|
|
43068
|
+
const checkPath = (path$1, originalPath, doThrow) => {
|
|
43069
|
+
if (!isString$1(path$1)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
43070
|
+
if (!path$1) return doThrow(`path must not be empty`, TypeError);
|
|
43071
|
+
if (checkPath.isNotRelative(path$1)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
42960
43072
|
return true;
|
|
42961
43073
|
};
|
|
42962
|
-
const isNotRelative = (path$
|
|
43074
|
+
const isNotRelative = (path$1) => REGEX_TEST_INVALID_PATH.test(path$1);
|
|
42963
43075
|
checkPath.isNotRelative = isNotRelative;
|
|
42964
43076
|
checkPath.convert = (p$1) => p$1;
|
|
42965
43077
|
var Ignore = class {
|
|
@@ -42995,13 +43107,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
42995
43107
|
addPattern(pattern) {
|
|
42996
43108
|
return this.add(pattern);
|
|
42997
43109
|
}
|
|
42998
|
-
_testOne(path$
|
|
43110
|
+
_testOne(path$1, checkUnignored) {
|
|
42999
43111
|
let ignored = false;
|
|
43000
43112
|
let unignored = false;
|
|
43001
43113
|
this._rules.forEach((rule) => {
|
|
43002
43114
|
const { negative } = rule;
|
|
43003
43115
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) return;
|
|
43004
|
-
if (rule.regex.test(path$
|
|
43116
|
+
if (rule.regex.test(path$1)) {
|
|
43005
43117
|
ignored = !negative;
|
|
43006
43118
|
unignored = negative;
|
|
43007
43119
|
}
|
|
@@ -43012,33 +43124,33 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43012
43124
|
};
|
|
43013
43125
|
}
|
|
43014
43126
|
_test(originalPath, cache$2, checkUnignored, slices) {
|
|
43015
|
-
const path$
|
|
43016
|
-
checkPath(path$
|
|
43017
|
-
return this._t(path$
|
|
43127
|
+
const path$1 = originalPath && checkPath.convert(originalPath);
|
|
43128
|
+
checkPath(path$1, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
43129
|
+
return this._t(path$1, cache$2, checkUnignored, slices);
|
|
43018
43130
|
}
|
|
43019
|
-
_t(path$
|
|
43020
|
-
if (path$
|
|
43021
|
-
if (!slices) slices = path$
|
|
43131
|
+
_t(path$1, cache$2, checkUnignored, slices) {
|
|
43132
|
+
if (path$1 in cache$2) return cache$2[path$1];
|
|
43133
|
+
if (!slices) slices = path$1.split(SLASH);
|
|
43022
43134
|
slices.pop();
|
|
43023
|
-
if (!slices.length) return cache$2[path$
|
|
43135
|
+
if (!slices.length) return cache$2[path$1] = this._testOne(path$1, checkUnignored);
|
|
43024
43136
|
const parent = this._t(slices.join(SLASH) + SLASH, cache$2, checkUnignored, slices);
|
|
43025
|
-
return cache$2[path$
|
|
43137
|
+
return cache$2[path$1] = parent.ignored ? parent : this._testOne(path$1, checkUnignored);
|
|
43026
43138
|
}
|
|
43027
|
-
ignores(path$
|
|
43028
|
-
return this._test(path$
|
|
43139
|
+
ignores(path$1) {
|
|
43140
|
+
return this._test(path$1, this._ignoreCache, false).ignored;
|
|
43029
43141
|
}
|
|
43030
43142
|
createFilter() {
|
|
43031
|
-
return (path$
|
|
43143
|
+
return (path$1) => !this.ignores(path$1);
|
|
43032
43144
|
}
|
|
43033
43145
|
filter(paths) {
|
|
43034
43146
|
return makeArray(paths).filter(this.createFilter());
|
|
43035
43147
|
}
|
|
43036
|
-
test(path$
|
|
43037
|
-
return this._test(path$
|
|
43148
|
+
test(path$1) {
|
|
43149
|
+
return this._test(path$1, this._testCache, true);
|
|
43038
43150
|
}
|
|
43039
43151
|
};
|
|
43040
43152
|
const factory = (options) => new Ignore(options);
|
|
43041
|
-
const isPathValid = (path$
|
|
43153
|
+
const isPathValid = (path$1) => checkPath(path$1 && checkPath.convert(path$1), path$1, RETURN_FALSE);
|
|
43042
43154
|
factory.isPathValid = isPathValid;
|
|
43043
43155
|
factory.default = factory;
|
|
43044
43156
|
module.exports = factory;
|
|
@@ -43047,7 +43159,7 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43047
43159
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
43048
43160
|
checkPath.convert = makePosix;
|
|
43049
43161
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
43050
|
-
checkPath.isNotRelative = (path$
|
|
43162
|
+
checkPath.isNotRelative = (path$1) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path$1) || isNotRelative(path$1);
|
|
43051
43163
|
}
|
|
43052
43164
|
}) });
|
|
43053
43165
|
|
|
@@ -44402,11 +44514,11 @@ var Mime = class {
|
|
|
44402
44514
|
}
|
|
44403
44515
|
return this;
|
|
44404
44516
|
}
|
|
44405
|
-
getType(path$
|
|
44406
|
-
if (typeof path$
|
|
44407
|
-
const last = path$
|
|
44517
|
+
getType(path$1) {
|
|
44518
|
+
if (typeof path$1 !== "string") return null;
|
|
44519
|
+
const last = path$1.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
44408
44520
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
44409
|
-
const hasPath = last.length < path$
|
|
44521
|
+
const hasPath = last.length < path$1.length;
|
|
44410
44522
|
if (!(ext.length < last.length - 1) && hasPath) return null;
|
|
44411
44523
|
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
44412
44524
|
}
|
|
@@ -44740,8 +44852,8 @@ function getErrorMap() {
|
|
|
44740
44852
|
//#endregion
|
|
44741
44853
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
44742
44854
|
const makeIssue = (params) => {
|
|
44743
|
-
const { data: data$1, path: path$
|
|
44744
|
-
const fullPath = [...path$
|
|
44855
|
+
const { data: data$1, path: path$1, errorMaps, issueData } = params;
|
|
44856
|
+
const fullPath = [...path$1, ...issueData.path || []];
|
|
44745
44857
|
const fullIssue = {
|
|
44746
44858
|
...issueData,
|
|
44747
44859
|
path: fullPath
|
|
@@ -44853,11 +44965,11 @@ var errorUtil;
|
|
|
44853
44965
|
//#endregion
|
|
44854
44966
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
44855
44967
|
var ParseInputLazyPath = class {
|
|
44856
|
-
constructor(parent, value, path$
|
|
44968
|
+
constructor(parent, value, path$1, key) {
|
|
44857
44969
|
this._cachedPath = [];
|
|
44858
44970
|
this.parent = parent;
|
|
44859
44971
|
this.data = value;
|
|
44860
|
-
this._path = path$
|
|
44972
|
+
this._path = path$1;
|
|
44861
44973
|
this._key = key;
|
|
44862
44974
|
}
|
|
44863
44975
|
get path() {
|
|
@@ -48520,10 +48632,7 @@ function validateWorkerEnvironmentOptions(resolvedPluginConfig, resolvedViteConf
|
|
|
48520
48632
|
const configPlugin = createPlugin("config", (ctx) => {
|
|
48521
48633
|
return {
|
|
48522
48634
|
config(userConfig, env$1) {
|
|
48523
|
-
if (ctx.resolvedPluginConfig.type === "preview") return {
|
|
48524
|
-
appType: "custom",
|
|
48525
|
-
preview: { allowedHosts: getAllowedHosts(ctx.resolvedPluginConfig.tunnel ? [QUICK_TUNNEL_ALLOWED_HOST] : [], userConfig.preview?.allowedHosts ?? userConfig.server?.allowedHosts) }
|
|
48526
|
-
};
|
|
48635
|
+
if (ctx.resolvedPluginConfig.type === "preview") return { appType: "custom" };
|
|
48527
48636
|
if (!ctx.hasShownWorkerConfigWarnings) {
|
|
48528
48637
|
ctx.setHasShownWorkerConfigWarnings(true);
|
|
48529
48638
|
const workerConfigWarnings = getWarningForWorkersConfigs(ctx.resolvedPluginConfig.rawConfigs);
|
|
@@ -48892,11 +49001,11 @@ const getQueryString = (params) => {
|
|
|
48892
49001
|
};
|
|
48893
49002
|
const getUrl = (config, options) => {
|
|
48894
49003
|
const encoder$1 = config.ENCODE_PATH || encodeURI;
|
|
48895
|
-
const path$
|
|
49004
|
+
const path$1 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
48896
49005
|
if (options.path?.hasOwnProperty(group)) return encoder$1(String(options.path[group]));
|
|
48897
49006
|
return substring;
|
|
48898
49007
|
});
|
|
48899
|
-
const url = `${config.BASE}${path$
|
|
49008
|
+
const url = `${config.BASE}${path$1}`;
|
|
48900
49009
|
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
48901
49010
|
return url;
|
|
48902
49011
|
};
|
|
@@ -49911,7 +50020,7 @@ function getContainerOptions(options) {
|
|
|
49911
50020
|
return containersConfig.map((container) => {
|
|
49912
50021
|
if (isDockerfile(container.image, configPath)) return {
|
|
49913
50022
|
dockerfile: container.image,
|
|
49914
|
-
image_build_context: container.image_build_context ??
|
|
50023
|
+
image_build_context: container.image_build_context ?? path3.dirname(container.image),
|
|
49915
50024
|
image_vars: container.image_vars,
|
|
49916
50025
|
class_name: container.class_name,
|
|
49917
50026
|
image_tag: getDevContainerImageName(container.class_name, containerBuildId)
|
|
@@ -49927,26 +50036,26 @@ function getContainerOptions(options) {
|
|
|
49927
50036
|
//#endregion
|
|
49928
50037
|
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
49929
50038
|
var __require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
|
49930
|
-
function cleanPath(path$
|
|
49931
|
-
let normalized = normalize(path$
|
|
50039
|
+
function cleanPath(path$1) {
|
|
50040
|
+
let normalized = normalize(path$1);
|
|
49932
50041
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
49933
50042
|
return normalized;
|
|
49934
50043
|
}
|
|
49935
50044
|
const SLASHES_REGEX = /[\\/]/g;
|
|
49936
|
-
function convertSlashes(path$
|
|
49937
|
-
return path$
|
|
50045
|
+
function convertSlashes(path$1, separator) {
|
|
50046
|
+
return path$1.replace(SLASHES_REGEX, separator);
|
|
49938
50047
|
}
|
|
49939
50048
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
49940
|
-
function isRootDirectory(path$
|
|
49941
|
-
return path$
|
|
50049
|
+
function isRootDirectory(path$1) {
|
|
50050
|
+
return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1);
|
|
49942
50051
|
}
|
|
49943
|
-
function normalizePath$1(path$
|
|
50052
|
+
function normalizePath$1(path$1, options) {
|
|
49944
50053
|
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
49945
|
-
const pathNeedsCleaning = process.platform === "win32" && path$
|
|
49946
|
-
if (resolvePaths) path$
|
|
49947
|
-
if (normalizePath$1$1 || pathNeedsCleaning) path$
|
|
49948
|
-
if (path$
|
|
49949
|
-
return convertSlashes(path$
|
|
50054
|
+
const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith(".");
|
|
50055
|
+
if (resolvePaths) path$1 = resolve$1(path$1);
|
|
50056
|
+
if (normalizePath$1$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);
|
|
50057
|
+
if (path$1 === ".") return "";
|
|
50058
|
+
return convertSlashes(path$1[path$1.length - 1] !== pathSeparator ? path$1 + pathSeparator : path$1, pathSeparator);
|
|
49950
50059
|
}
|
|
49951
50060
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
49952
50061
|
return directoryPath + filename;
|
|
@@ -49982,8 +50091,8 @@ const pushDirectory = (directoryPath, paths) => {
|
|
|
49982
50091
|
paths.push(directoryPath || ".");
|
|
49983
50092
|
};
|
|
49984
50093
|
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
49985
|
-
const path$
|
|
49986
|
-
if (filters.every((filter) => filter(path$
|
|
50094
|
+
const path$1 = directoryPath || ".";
|
|
50095
|
+
if (filters.every((filter) => filter(path$1, true))) paths.push(path$1);
|
|
49987
50096
|
};
|
|
49988
50097
|
const empty$2 = () => {};
|
|
49989
50098
|
function build$6(root, options) {
|
|
@@ -50032,26 +50141,26 @@ const empty = () => {};
|
|
|
50032
50141
|
function build$3(options) {
|
|
50033
50142
|
return options.group ? groupFiles : empty;
|
|
50034
50143
|
}
|
|
50035
|
-
const resolveSymlinksAsync = function(path$
|
|
50144
|
+
const resolveSymlinksAsync = function(path$1, state, callback$1) {
|
|
50036
50145
|
const { queue, fs: fs$3, options: { suppressErrors } } = state;
|
|
50037
50146
|
queue.enqueue();
|
|
50038
|
-
fs$3.realpath(path$
|
|
50147
|
+
fs$3.realpath(path$1, (error, resolvedPath) => {
|
|
50039
50148
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
50040
50149
|
fs$3.stat(resolvedPath, (error$1, stat) => {
|
|
50041
50150
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
50042
|
-
if (stat.isDirectory() && isRecursive(path$
|
|
50151
|
+
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
50043
50152
|
callback$1(stat, resolvedPath);
|
|
50044
50153
|
queue.dequeue(null, state);
|
|
50045
50154
|
});
|
|
50046
50155
|
});
|
|
50047
50156
|
};
|
|
50048
|
-
const resolveSymlinks = function(path$
|
|
50157
|
+
const resolveSymlinks = function(path$1, state, callback$1) {
|
|
50049
50158
|
const { queue, fs: fs$3, options: { suppressErrors } } = state;
|
|
50050
50159
|
queue.enqueue();
|
|
50051
50160
|
try {
|
|
50052
|
-
const resolvedPath = fs$3.realpathSync(path$
|
|
50161
|
+
const resolvedPath = fs$3.realpathSync(path$1);
|
|
50053
50162
|
const stat = fs$3.statSync(resolvedPath);
|
|
50054
|
-
if (stat.isDirectory() && isRecursive(path$
|
|
50163
|
+
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
50055
50164
|
callback$1(stat, resolvedPath);
|
|
50056
50165
|
} catch (e) {
|
|
50057
50166
|
if (!suppressErrors) throw e;
|
|
@@ -50061,16 +50170,16 @@ function build$2(options, isSynchronous) {
|
|
|
50061
50170
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
50062
50171
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
50063
50172
|
}
|
|
50064
|
-
function isRecursive(path$
|
|
50173
|
+
function isRecursive(path$1, resolved, state) {
|
|
50065
50174
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
50066
|
-
let parent = dirname$1(path$
|
|
50175
|
+
let parent = dirname$1(path$1);
|
|
50067
50176
|
let depth$1 = 1;
|
|
50068
50177
|
while (parent !== state.root && depth$1 < 2) {
|
|
50069
50178
|
const resolvedPath = state.symlinks.get(parent);
|
|
50070
50179
|
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++;
|
|
50071
50180
|
else parent = dirname$1(parent);
|
|
50072
50181
|
}
|
|
50073
|
-
state.symlinks.set(path$
|
|
50182
|
+
state.symlinks.set(path$1, resolved);
|
|
50074
50183
|
return depth$1 > 1;
|
|
50075
50184
|
}
|
|
50076
50185
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -50251,19 +50360,19 @@ var Walker = class {
|
|
|
50251
50360
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
50252
50361
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
50253
50362
|
} else if (entry.isDirectory()) {
|
|
50254
|
-
let path$
|
|
50255
|
-
if (exclude && exclude(entry.name, path$
|
|
50256
|
-
this.pushDirectory(path$
|
|
50257
|
-
this.walkDirectory(this.state, path$
|
|
50363
|
+
let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
50364
|
+
if (exclude && exclude(entry.name, path$1)) continue;
|
|
50365
|
+
this.pushDirectory(path$1, paths, filters);
|
|
50366
|
+
this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk);
|
|
50258
50367
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
50259
|
-
let path$
|
|
50260
|
-
this.resolveSymlink(path$
|
|
50368
|
+
let path$1 = joinPathWithBasePath(entry.name, directoryPath);
|
|
50369
|
+
this.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {
|
|
50261
50370
|
if (stat.isDirectory()) {
|
|
50262
50371
|
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
50263
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$
|
|
50264
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$
|
|
50372
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
50373
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk);
|
|
50265
50374
|
} else {
|
|
50266
|
-
resolvedPath = useRealPaths ? resolvedPath : path$
|
|
50375
|
+
resolvedPath = useRealPaths ? resolvedPath : path$1;
|
|
50267
50376
|
const filename = basename(resolvedPath);
|
|
50268
50377
|
const directoryPath$1 = normalizePath$1(dirname$1(resolvedPath), this.state.options);
|
|
50269
50378
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
@@ -50428,7 +50537,7 @@ var Builder = class {
|
|
|
50428
50537
|
isMatch = globFn(patterns, ...options);
|
|
50429
50538
|
this.globCache[patterns.join("\0")] = isMatch;
|
|
50430
50539
|
}
|
|
50431
|
-
this.options.filters.push((path$
|
|
50540
|
+
this.options.filters.push((path$1) => isMatch(path$1));
|
|
50432
50541
|
return this;
|
|
50433
50542
|
}
|
|
50434
50543
|
};
|
|
@@ -50639,8 +50748,8 @@ var require_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
|
|
|
50639
50748
|
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
50640
50749
|
return output;
|
|
50641
50750
|
};
|
|
50642
|
-
exports.basename = (path$
|
|
50643
|
-
const segs = path$
|
|
50751
|
+
exports.basename = (path$1, { windows } = {}) => {
|
|
50752
|
+
const segs = path$1.split(windows ? /[\\/]/ : "/");
|
|
50644
50753
|
const last = segs[segs.length - 1];
|
|
50645
50754
|
if (last === "") return segs[segs.length - 2];
|
|
50646
50755
|
return last;
|
|
@@ -52175,15 +52284,15 @@ function buildRelative(cwd, root) {
|
|
|
52175
52284
|
};
|
|
52176
52285
|
}
|
|
52177
52286
|
const splitPatternOptions = { parts: true };
|
|
52178
|
-
function splitPattern(path$1
|
|
52287
|
+
function splitPattern(path$1) {
|
|
52179
52288
|
var _result$parts;
|
|
52180
|
-
const result = import_picomatch.default.scan(path$1
|
|
52181
|
-
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1
|
|
52289
|
+
const result = import_picomatch.default.scan(path$1, splitPatternOptions);
|
|
52290
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
|
52182
52291
|
}
|
|
52183
52292
|
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
52184
52293
|
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
52185
|
-
const escapePosixPath = (path$1
|
|
52186
|
-
const escapeWin32Path = (path$1
|
|
52294
|
+
const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
52295
|
+
const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
52187
52296
|
/**
|
|
52188
52297
|
* Escapes a path's special characters depending on the platform.
|
|
52189
52298
|
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
@@ -52218,7 +52327,7 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
52218
52327
|
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
|
52219
52328
|
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
|
52220
52329
|
const escapedCwd = escapePath(cwd);
|
|
52221
|
-
if (path
|
|
52330
|
+
if (path.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
|
|
52222
52331
|
else result = posix.normalize(result);
|
|
52223
52332
|
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
52224
52333
|
const parts = splitPattern(result);
|
|
@@ -52277,15 +52386,15 @@ function processPatterns({ patterns = ["**/*"], ignore: ignore$1 = [], expandDir
|
|
|
52277
52386
|
}
|
|
52278
52387
|
function formatPaths(paths, relative$2) {
|
|
52279
52388
|
for (let i$1 = paths.length - 1; i$1 >= 0; i$1--) {
|
|
52280
|
-
const path$1
|
|
52281
|
-
paths[i$1] = relative$2(path$1
|
|
52389
|
+
const path$1 = paths[i$1];
|
|
52390
|
+
paths[i$1] = relative$2(path$1);
|
|
52282
52391
|
}
|
|
52283
52392
|
return paths;
|
|
52284
52393
|
}
|
|
52285
52394
|
function normalizeCwd(cwd) {
|
|
52286
52395
|
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
|
52287
52396
|
if (cwd instanceof URL) return fileURLToPath$1(cwd).replace(BACKSLASHES, "/");
|
|
52288
|
-
return path
|
|
52397
|
+
return path.resolve(cwd).replace(BACKSLASHES, "/");
|
|
52289
52398
|
}
|
|
52290
52399
|
function getCrawler(patterns, inputOptions = {}) {
|
|
52291
52400
|
const options = process.env.TINYGLOBBY_DEBUG ? {
|
|
@@ -52330,9 +52439,9 @@ function getCrawler(patterns, inputOptions = {}) {
|
|
|
52330
52439
|
const formatExclude = options.absolute ? format$2 : buildFormat(cwd, props.root, true);
|
|
52331
52440
|
const fdirOptions = {
|
|
52332
52441
|
filters: [options.debug ? (p$1, isDirectory$1) => {
|
|
52333
|
-
const path$1
|
|
52334
|
-
const matches = matcher(path$1
|
|
52335
|
-
if (matches) log(`matched ${path$1
|
|
52442
|
+
const path$1 = format$2(p$1, isDirectory$1);
|
|
52443
|
+
const matches = matcher(path$1);
|
|
52444
|
+
if (matches) log(`matched ${path$1}`);
|
|
52336
52445
|
return matches;
|
|
52337
52446
|
} : (p$1, isDirectory$1) => matcher(format$2(p$1, isDirectory$1))],
|
|
52338
52447
|
exclude: options.debug ? (_, p$1) => {
|
|
@@ -53324,13 +53433,13 @@ const wslDefaultBrowser = async () => {
|
|
|
53324
53433
|
const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
|
|
53325
53434
|
return stdout.trim();
|
|
53326
53435
|
};
|
|
53327
|
-
const convertWslPathToWindows = async (path$
|
|
53328
|
-
if (/^[a-z]+:\/\//i.test(path$
|
|
53436
|
+
const convertWslPathToWindows = async (path$1) => {
|
|
53437
|
+
if (/^[a-z]+:\/\//i.test(path$1)) return path$1;
|
|
53329
53438
|
try {
|
|
53330
|
-
const { stdout } = await execFile$1("wslpath", ["-aw", path$
|
|
53439
|
+
const { stdout } = await execFile$1("wslpath", ["-aw", path$1], { encoding: "utf8" });
|
|
53331
53440
|
return stdout.trim();
|
|
53332
53441
|
} catch {
|
|
53333
|
-
return path$
|
|
53442
|
+
return path$1;
|
|
53334
53443
|
}
|
|
53335
53444
|
};
|
|
53336
53445
|
|
|
@@ -53516,8 +53625,8 @@ var is_in_ssh_default = isInSsh;
|
|
|
53516
53625
|
//#endregion
|
|
53517
53626
|
//#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
53518
53627
|
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
53519
|
-
const __dirname = import.meta.url ?
|
|
53520
|
-
const localXdgOpenPath =
|
|
53628
|
+
const __dirname = import.meta.url ? path3.dirname(fileURLToPath(import.meta.url)) : "";
|
|
53629
|
+
const localXdgOpenPath = path3.join(__dirname, "xdg-open");
|
|
53521
53630
|
const { platform, arch: arch$1 } = process$1;
|
|
53522
53631
|
const tryEachApp = async (apps$1, opener) => {
|
|
53523
53632
|
if (apps$1.length === 0) return;
|
|
@@ -53742,14 +53851,14 @@ const shortcutsPlugin = createPlugin("shortcuts", (ctx) => {
|
|
|
53742
53851
|
assertIsNotPreview(ctx);
|
|
53743
53852
|
addBindingsShortcut(viteDevServer, ctx);
|
|
53744
53853
|
addExplorerShortcut(viteDevServer);
|
|
53745
|
-
|
|
53854
|
+
addTunnelShortcut(viteDevServer, ctx);
|
|
53746
53855
|
},
|
|
53747
53856
|
async configurePreviewServer(vitePreviewServer) {
|
|
53748
53857
|
if (!isCustomShortcutsSupported) return;
|
|
53749
53858
|
assertIsPreview(ctx);
|
|
53750
53859
|
addBindingsShortcut(vitePreviewServer, ctx);
|
|
53751
53860
|
addExplorerShortcut(vitePreviewServer);
|
|
53752
|
-
|
|
53861
|
+
addTunnelShortcut(vitePreviewServer, ctx);
|
|
53753
53862
|
}
|
|
53754
53863
|
};
|
|
53755
53864
|
});
|
|
@@ -53806,10 +53915,19 @@ function addExplorerShortcut(server) {
|
|
|
53806
53915
|
};
|
|
53807
53916
|
server.bindCLIShortcuts({ customShortcuts: [openExplorerShortcut] });
|
|
53808
53917
|
}
|
|
53809
|
-
function addTunnelShortcut(server) {
|
|
53918
|
+
function addTunnelShortcut(server, ctx) {
|
|
53810
53919
|
if (!process.stdin.isTTY) return;
|
|
53811
53920
|
server.bindCLIShortcuts({ customShortcuts: [{
|
|
53812
53921
|
key: "t",
|
|
53922
|
+
description: "start or close tunnel",
|
|
53923
|
+
action: () => {
|
|
53924
|
+
toggleTunnel(server, ctx).catch((error) => {
|
|
53925
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53926
|
+
server.config.logger.error(import_picocolors.default.red(`Error: ${message}`));
|
|
53927
|
+
});
|
|
53928
|
+
}
|
|
53929
|
+
}, {
|
|
53930
|
+
key: "a",
|
|
53813
53931
|
description: "extend tunnel by 1 hour",
|
|
53814
53932
|
action: () => {
|
|
53815
53933
|
extendTunnelExpiry();
|