@cloudflare/vite-plugin 0.0.0-e55f489db → 0.0.0-e5ae13ade

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.
@@ -1,5 +1,5 @@
1
1
  // ../workers-shared/dist/asset-worker.mjs
2
- import { WorkerEntrypoint as lo } from "cloudflare:workers";
2
+ import { WorkerEntrypoint as po } from "cloudflare:workers";
3
3
  var K = class {
4
4
  constructor(e) {
5
5
  this.performanceTimer = e;
@@ -2038,7 +2038,7 @@ var Zn = (t14) => {
2038
2038
  var Qe = (t14, e) => !!t14.compatibility_flags.find((n) => n === e.enable);
2039
2039
  var Jt = (t14) => {
2040
2040
  let e = Zn(t14);
2041
- return { compatibility_date: e.compatibilityDate, compatibility_flags: e.compatibilityFlags, html_handling: t14?.html_handling ?? "auto-trailing-slash", not_found_handling: t14?.not_found_handling ?? "none", redirects: t14?.redirects ?? { version: 1, staticRules: {}, rules: {} }, headers: t14?.headers ?? { version: 2, rules: {} }, account_id: t14?.account_id ?? -1, script_id: t14?.script_id ?? -1, debug: t14?.debug ?? false };
2041
+ return { compatibility_date: e.compatibilityDate, compatibility_flags: e.compatibilityFlags, html_handling: t14?.html_handling ?? "auto-trailing-slash", not_found_handling: t14?.not_found_handling ?? "none", redirects: t14?.redirects ?? { version: 1, staticRules: {}, rules: {} }, headers: t14?.headers ?? { version: 2, rules: {} }, has_static_routing: t14?.has_static_routing ?? false, account_id: t14?.account_id ?? -1, script_id: t14?.script_id ?? -1, debug: t14?.debug ?? false };
2042
2042
  };
2043
2043
  var et = class {
2044
2044
  constructor(e) {
@@ -2149,19 +2149,21 @@ var Vt = (t14, e) => {
2149
2149
  for (let [n, r] of Object.entries(e)) t14 = t14.replaceAll(`:${n}`, r);
2150
2150
  return t14;
2151
2151
  };
2152
+ var to = (t14) => {
2153
+ t14 = t14.split("*").map(Xs).join("(?<splat>.*)");
2154
+ let e = t14.matchAll(Qs);
2155
+ for (let r of e) t14 = t14.split(r[0]).join(`(?<${r[1]}>[^/.]+)`);
2156
+ let n = t14.matchAll(eo);
2157
+ for (let r of n) t14 = t14.split(r[0]).join(`(?<${r[1]}>[^/]+)`);
2158
+ return t14 = "^" + t14 + "$", RegExp(t14);
2159
+ };
2152
2160
  var qt = (t14, e = (n) => n) => {
2153
2161
  if (!t14) return () => [];
2154
2162
  let n = Object.entries(t14).map(([r, s]) => {
2155
2163
  let o = r.startsWith("https://");
2156
- r = r.split("*").map(Xs).join("(?<splat>.*)");
2157
- let i = r.matchAll(Qs);
2158
- for (let c of i) r = r.split(c[0]).join(`(?<${c[1]}>[^/.]+)`);
2159
- let a = r.matchAll(eo);
2160
- for (let c of a) r = r.split(c[0]).join(`(?<${c[1]}>[^/]+)`);
2161
- r = "^" + r + "$";
2162
2164
  try {
2163
- let c = new RegExp(r);
2164
- return [{ crossHost: o, regExp: c }, s];
2165
+ let i = to(r);
2166
+ return [{ crossHost: o, regExp: i }, s];
2165
2167
  } catch {
2166
2168
  }
2167
2169
  }).filter((r) => r !== void 0);
@@ -2180,9 +2182,9 @@ var Qn = (t14, e, n) => {
2180
2182
  var er = (t14) => qt(t14.redirects.version === tr ? t14.redirects.rules : {}, ({ status: e, to: n }, r) => ({ status: e, to: Vt(n, r) }));
2181
2183
  function nr({ eTag: t14, resolver: e }, n, r, s, o) {
2182
2184
  let i = new Headers({ ETag: `"${t14}"` });
2183
- return n !== void 0 && i.append("Content-Type", n), to(s) && i.append("Cache-Control", Xn), i.append("CF-Cache-Status", r), o.debug && e === "not-found" && Qe(o, _e) && i.append("X-Mf-Additional-Response-Log", "`Sec-Fetch-Mode: navigate` header present - using `not_found_handling` behavior"), i;
2185
+ return n !== void 0 && i.append("Content-Type", n), no(s) && i.append("Cache-Control", Xn), i.append("CF-Cache-Status", r), o.debug && e === "not-found" && Qe(o, _e) && i.append("X-Mf-Additional-Response-Log", "`Sec-Fetch-Mode: navigate` header present - using `not_found_handling` behavior"), i;
2184
2186
  }
2185
- function to(t14) {
2187
+ function no(t14) {
2186
2188
  return !t14.headers.has("Authorization") && !t14.headers.has("Range");
2187
2189
  }
2188
2190
  function rr(t14, e, n, r) {
@@ -2205,19 +2207,19 @@ function rr(t14, e, n, r) {
2205
2207
  var tr = 1;
2206
2208
  var sr = 2;
2207
2209
  var or = async (t14, e, n, r) => {
2208
- let s = new URL(t14.url), { search: o } = s, i = uo(e, t14, n, s.host, s.pathname, o);
2210
+ let s = new URL(t14.url), { search: o } = s, i = lo(e, t14, n, s.host, s.pathname, o);
2209
2211
  if (i instanceof Response) return i;
2210
- let { proxied: a, pathname: c } = i, u = ao(c), l = await cr(u, t14, n, r);
2212
+ let { proxied: a, pathname: c } = i, u = co(c), l = await cr(u, t14, n, r);
2211
2213
  if (!l) {
2212
2214
  let m = a ? new B() : new Ee();
2213
2215
  return e.JAEGER.enterSpan("no_intent", (W) => (W.setTags({ decodedPathname: u, configuration: JSON.stringify(n), proxied: a, status: m.status }), m));
2214
2216
  }
2215
2217
  let p = t14.method.toUpperCase();
2216
2218
  if (!["GET", "HEAD"].includes(p)) return e.JAEGER.enterSpan("method_not_allowed", (m) => (m.setTags({ method: p, status: Se.status }), new Se()));
2217
- let f = l.redirect ?? u, d = co(f);
2219
+ let f = l.redirect ?? u, d = uo(f);
2218
2220
  return d !== c && l.asset || l.redirect ? e.JAEGER.enterSpan("redirect", (m) => (m.setTags({ originalPath: c, location: d !== c ? d : l.redirect ?? "<unknown>", status: q.status }), new q(d + o))) : l.asset ? { ...l.asset, resolver: l.resolver } : e.JAEGER.enterSpan("unknown_action", (m) => (m.setTags({ pathname: c, status: H.status }), new H(new Error("Unknown action"))));
2219
2221
  };
2220
- var no = async (t14, e, n, r, s, o) => {
2222
+ var ro = async (t14, e, n, r, s, o) => {
2221
2223
  let { pathname: i } = new URL(e.url), a = e.method.toUpperCase(), c = await n.JAEGER.enterSpan("getByETag", async (d) => (d.setTags({ pathname: i, eTag: t14.eTag, status: t14.status }), await s(t14.eTag, e))), u = nr(t14, c.contentType, c.cacheStatus, e, r);
2222
2224
  o.setData({ cacheStatus: c.cacheStatus });
2223
2225
  let l = `"${t14.eTag}"`, p = `W/${l}`, f = e.headers.get("If-None-Match") || "";
@@ -2232,24 +2234,24 @@ var no = async (t14, e, n, r, s, o) => {
2232
2234
  }
2233
2235
  });
2234
2236
  };
2235
- var ir = async (t14, e, n, r) => (Qe(n, _e) && t14.headers.get("Sec-Fetch-Mode") === "navigate" || (n = { ...n, not_found_handling: "none" }), !(await or(t14, e, n, r) instanceof Ee));
2237
+ var ir = async (t14, e, n, r) => (Qe(n, _e) && t14.headers.get("Sec-Fetch-Mode") === "navigate" && !n.has_static_routing || (n = { ...n, not_found_handling: "none" }), !(await or(t14, e, n, r) instanceof Ee));
2236
2238
  var ar = async (t14, e, n, r, s, o) => {
2237
- let i = await or(t14, e, n, r), a = i instanceof Response ? i : await no(i, t14, e, n, s, o);
2239
+ let i = await or(t14, e, n, r), a = i instanceof Response ? i : await ro(i, t14, e, n, s, o);
2238
2240
  return rr(t14, a, n, e);
2239
2241
  };
2240
2242
  var cr = async (t14, e, n, r, s = false) => {
2241
2243
  switch (n.html_handling) {
2242
2244
  case "auto-trailing-slash":
2243
- return ro(t14, e, n, r, s);
2244
- case "force-trailing-slash":
2245
2245
  return so(t14, e, n, r, s);
2246
- case "drop-trailing-slash":
2246
+ case "force-trailing-slash":
2247
2247
  return oo(t14, e, n, r, s);
2248
+ case "drop-trailing-slash":
2249
+ return io(t14, e, n, r, s);
2248
2250
  case "none":
2249
- return io(t14, e, n, r);
2251
+ return ao(t14, e, n, r);
2250
2252
  }
2251
2253
  };
2252
- var ro = async (t14, e, n, r, s) => {
2254
+ var so = async (t14, e, n, r, s) => {
2253
2255
  let o = null, i = null, a = await r(t14, e);
2254
2256
  if (t14.endsWith("/index")) {
2255
2257
  if (a) return { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" };
@@ -2267,7 +2269,7 @@ var ro = async (t14, e, n, r, s) => {
2267
2269
  }
2268
2270
  return a ? { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" } : (i = await r(`${t14}.html`, e)) ? { asset: { eTag: i, status: y.status }, redirect: null, resolver: "html-handling" } : (o = await E(`${t14}/index.html`, e, `${t14}/`, n, r, s, "html-handling")) ? o : tt(t14, e, n, r);
2269
2271
  };
2270
- var so = async (t14, e, n, r, s) => {
2272
+ var oo = async (t14, e, n, r, s) => {
2271
2273
  let o = null, i = null, a = await r(t14, e);
2272
2274
  if (t14.endsWith("/index")) {
2273
2275
  if (a) return { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" };
@@ -2286,7 +2288,7 @@ var so = async (t14, e, n, r, s) => {
2286
2288
  }
2287
2289
  return a ? { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" } : (o = await E(`${t14}.html`, e, `${t14}/`, n, r, s, "html-handling")) || (o = await E(`${t14}/index.html`, e, `${t14}/`, n, r, s, "html-handling")) ? o : tt(t14, e, n, r);
2288
2290
  };
2289
- var oo = async (t14, e, n, r, s) => {
2291
+ var io = async (t14, e, n, r, s) => {
2290
2292
  let o = null, i = null, a = await r(t14, e);
2291
2293
  if (t14.endsWith("/index")) {
2292
2294
  if (a) return { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" };
@@ -2315,7 +2317,7 @@ var oo = async (t14, e, n, r, s) => {
2315
2317
  }
2316
2318
  return a ? { asset: { eTag: a, status: y.status }, redirect: null, resolver: "html-handling" } : (i = await r(`${t14}.html`, e)) ? { asset: { eTag: i, status: y.status }, redirect: null, resolver: "html-handling" } : (i = await r(`${t14}/index.html`, e)) ? { asset: { eTag: i, status: y.status }, redirect: null, resolver: "html-handling" } : tt(t14, e, n, r);
2317
2319
  };
2318
- var io = async (t14, e, n, r) => {
2320
+ var ao = async (t14, e, n, r) => {
2319
2321
  let s = await r(t14, e);
2320
2322
  return s ? { asset: { eTag: s, status: y.status }, redirect: null, resolver: "html-handling" } : tt(t14, e, n, r);
2321
2323
  };
@@ -2347,21 +2349,21 @@ var E = async (t14, e, n, r, s, o, i) => {
2347
2349
  }
2348
2350
  return null;
2349
2351
  };
2350
- var ao = (t14) => t14.split("/").map((e) => {
2352
+ var co = (t14) => t14.split("/").map((e) => {
2351
2353
  try {
2352
2354
  return decodeURIComponent(e);
2353
2355
  } catch {
2354
2356
  return e;
2355
2357
  }
2356
2358
  }).join("/").replace(/\/+/g, "/");
2357
- var co = (t14) => t14.split("/").map((e) => {
2359
+ var uo = (t14) => t14.split("/").map((e) => {
2358
2360
  try {
2359
2361
  return encodeURIComponent(e);
2360
2362
  } catch {
2361
2363
  return e;
2362
2364
  }
2363
2365
  }).join("/");
2364
- var uo = (t14, e, n, r, s, o) => (t14.JAEGER ?? v()).enterSpan("handle_redirects", (a) => {
2366
+ var lo = (t14, e, n, r, s, o) => (t14.JAEGER ?? v()).enterSpan("handle_redirects", (a) => {
2365
2367
  let c = Qn(n, r, s) || er(n)({ request: e })[0], u = false;
2366
2368
  if (c) if (c.status === 200) s = new URL(c.to, e.url).pathname, u = true, a.setTags({ matched: true, proxied: true, new_path: s, status: c.status });
2367
2369
  else {
@@ -2415,7 +2417,7 @@ async function pr(t14, e, n, r = 1) {
2415
2417
  await new Promise((i) => setTimeout(i, Math.pow(2, s++) * 1e3));
2416
2418
  }
2417
2419
  }
2418
- var dr = class extends lo {
2420
+ var dr = class extends po {
2419
2421
  async fetch(t14) {
2420
2422
  let e, n = new Ke(this.env.ANALYTICS), r = new K(this.env.UNSAFE_PERFORMANCE), s = r.now();
2421
2423
  try {
@@ -2476,7 +2478,7 @@ var ADDITIONAL_MODULE_TYPES = [
2476
2478
 
2477
2479
  // src/shared.ts
2478
2480
  var UNKNOWN_HOST = "http://localhost";
2479
- var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)__`;
2481
+ var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)__CLOUDFLARE_MODULE__`;
2480
2482
  var additionalModuleRE = new RegExp(ADDITIONAL_MODULE_PATTERN);
2481
2483
  var additionalModuleGlobalRE = new RegExp(
2482
2484
  ADDITIONAL_MODULE_PATTERN,