@qwik.dev/router 2.0.0-alpha.1 → 2.0.0-alpha.10

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.
Files changed (48) hide show
  1. package/lib/adapters/azure-swa/vite/index.cjs +3 -3
  2. package/lib/adapters/azure-swa/vite/index.d.ts +13 -13
  3. package/lib/adapters/bun-server/vite/index.cjs +3 -3
  4. package/lib/adapters/bun-server/vite/index.d.ts +14 -14
  5. package/lib/adapters/cloud-run/vite/index.cjs +3 -3
  6. package/lib/adapters/cloud-run/vite/index.d.ts +13 -13
  7. package/lib/adapters/cloudflare-pages/vite/index.cjs +3 -3
  8. package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -27
  9. package/lib/adapters/deno-server/vite/index.cjs +3 -3
  10. package/lib/adapters/deno-server/vite/index.d.ts +14 -14
  11. package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
  12. package/lib/adapters/netlify-edge/vite/index.d.ts +44 -44
  13. package/lib/adapters/node-server/vite/index.cjs +3 -3
  14. package/lib/adapters/node-server/vite/index.d.ts +14 -14
  15. package/lib/adapters/shared/vite/index.cjs +10 -3
  16. package/lib/adapters/shared/vite/index.d.ts +114 -114
  17. package/lib/adapters/shared/vite/index.mjs +7 -0
  18. package/lib/adapters/static/vite/index.cjs +10 -3
  19. package/lib/adapters/static/vite/index.d.ts +10 -10
  20. package/lib/adapters/static/vite/index.mjs +7 -0
  21. package/lib/adapters/vercel-edge/vite/index.cjs +3 -3
  22. package/lib/adapters/vercel-edge/vite/index.d.ts +45 -45
  23. package/lib/index.d.ts +878 -801
  24. package/lib/index.qwik.cjs +84 -84
  25. package/lib/index.qwik.mjs +64 -64
  26. package/lib/middleware/aws-lambda/index.d.ts +48 -50
  27. package/lib/middleware/azure-swa/index.d.ts +28 -28
  28. package/lib/middleware/bun/index.d.ts +35 -35
  29. package/lib/middleware/cloudflare-pages/index.d.ts +35 -35
  30. package/lib/middleware/deno/index.d.ts +47 -47
  31. package/lib/middleware/firebase/index.d.ts +26 -26
  32. package/lib/middleware/netlify-edge/index.d.ts +27 -27
  33. package/lib/middleware/node/index.cjs +3 -3
  34. package/lib/middleware/node/index.d.ts +64 -66
  35. package/lib/middleware/request-handler/index.cjs +37 -38
  36. package/lib/middleware/request-handler/index.d.ts +676 -681
  37. package/lib/middleware/request-handler/index.mjs +34 -35
  38. package/lib/middleware/vercel-edge/index.d.ts +26 -26
  39. package/lib/service-worker.cjs +13 -263
  40. package/lib/service-worker.d.ts +15 -4
  41. package/lib/service-worker.mjs +13 -263
  42. package/lib/static/index.cjs +3 -3
  43. package/lib/static/index.d.ts +96 -98
  44. package/lib/static/node.cjs +3 -3
  45. package/lib/vite/index.cjs +129 -247
  46. package/lib/vite/index.d.ts +154 -154
  47. package/lib/vite/index.mjs +127 -245
  48. package/package.json +10 -9
@@ -7,7 +7,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __esm = (fn, res) => function __init() {
8
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
9
  };
10
- var __commonJS = (cb, mod) => function __require2() {
10
+ var __commonJS = (cb, mod) => function __require() {
11
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
12
  };
13
13
  var __export = (target, all3) => {
@@ -9629,7 +9629,7 @@ var init_default = __esm({
9629
9629
  }
9630
9630
  });
9631
9631
 
9632
- // node_modules/.pnpm/micromark-util-character@2.1.0/node_modules/micromark-util-character/index.js
9632
+ // node_modules/.pnpm/micromark-util-character@2.1.1/node_modules/micromark-util-character/index.js
9633
9633
  function asciiControl(code3) {
9634
9634
  return (
9635
9635
  // Special whitespace codes (which have negative values), C0 and Control
@@ -9654,7 +9654,7 @@ function regexCheck(regex3) {
9654
9654
  }
9655
9655
  var asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace;
9656
9656
  var init_micromark_util_character = __esm({
9657
- "node_modules/.pnpm/micromark-util-character@2.1.0/node_modules/micromark-util-character/index.js"() {
9657
+ "node_modules/.pnpm/micromark-util-character@2.1.1/node_modules/micromark-util-character/index.js"() {
9658
9658
  asciiAlpha = regexCheck(/[A-Za-z]/);
9659
9659
  asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
9660
9660
  asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
@@ -10462,12 +10462,12 @@ var init_mdast_util_gfm_autolink_literal = __esm({
10462
10462
  }
10463
10463
  });
10464
10464
 
10465
- // node_modules/.pnpm/micromark-util-normalize-identifier@2.0.0/node_modules/micromark-util-normalize-identifier/index.js
10465
+ // node_modules/.pnpm/micromark-util-normalize-identifier@2.0.1/node_modules/micromark-util-normalize-identifier/index.js
10466
10466
  function normalizeIdentifier(value2) {
10467
10467
  return value2.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
10468
10468
  }
10469
10469
  var init_micromark_util_normalize_identifier = __esm({
10470
- "node_modules/.pnpm/micromark-util-normalize-identifier@2.0.0/node_modules/micromark-util-normalize-identifier/index.js"() {
10470
+ "node_modules/.pnpm/micromark-util-normalize-identifier@2.0.1/node_modules/micromark-util-normalize-identifier/index.js"() {
10471
10471
  }
10472
10472
  });
10473
10473
 
@@ -12178,7 +12178,7 @@ var init_mdast_util_gfm = __esm({
12178
12178
  }
12179
12179
  });
12180
12180
 
12181
- // node_modules/.pnpm/micromark-util-chunked@2.0.0/node_modules/micromark-util-chunked/index.js
12181
+ // node_modules/.pnpm/micromark-util-chunked@2.0.1/node_modules/micromark-util-chunked/index.js
12182
12182
  function splice(list3, start, remove, items) {
12183
12183
  const end = list3.length;
12184
12184
  let chunkStart = 0;
@@ -12205,11 +12205,11 @@ function splice(list3, start, remove, items) {
12205
12205
  }
12206
12206
  }
12207
12207
  var init_micromark_util_chunked = __esm({
12208
- "node_modules/.pnpm/micromark-util-chunked@2.0.0/node_modules/micromark-util-chunked/index.js"() {
12208
+ "node_modules/.pnpm/micromark-util-chunked@2.0.1/node_modules/micromark-util-chunked/index.js"() {
12209
12209
  }
12210
12210
  });
12211
12211
 
12212
- // node_modules/.pnpm/micromark-util-combine-extensions@2.0.0/node_modules/micromark-util-combine-extensions/index.js
12212
+ // node_modules/.pnpm/micromark-util-combine-extensions@2.0.1/node_modules/micromark-util-combine-extensions/index.js
12213
12213
  function combineExtensions(extensions) {
12214
12214
  const all3 = {};
12215
12215
  let index = -1;
@@ -12249,7 +12249,7 @@ function constructs(existing, list3) {
12249
12249
  }
12250
12250
  var hasOwnProperty;
12251
12251
  var init_micromark_util_combine_extensions = __esm({
12252
- "node_modules/.pnpm/micromark-util-combine-extensions@2.0.0/node_modules/micromark-util-combine-extensions/index.js"() {
12252
+ "node_modules/.pnpm/micromark-util-combine-extensions@2.0.1/node_modules/micromark-util-combine-extensions/index.js"() {
12253
12253
  init_micromark_util_chunked();
12254
12254
  hasOwnProperty = {}.hasOwnProperty;
12255
12255
  }
@@ -12615,7 +12615,7 @@ var init_micromark_extension_gfm_autolink_literal = __esm({
12615
12615
  }
12616
12616
  });
12617
12617
 
12618
- // node_modules/.pnpm/micromark-util-classify-character@2.0.0/node_modules/micromark-util-classify-character/index.js
12618
+ // node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/index.js
12619
12619
  function classifyCharacter(code3) {
12620
12620
  if (code3 === null || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3)) {
12621
12621
  return 1;
@@ -12625,12 +12625,12 @@ function classifyCharacter(code3) {
12625
12625
  }
12626
12626
  }
12627
12627
  var init_micromark_util_classify_character = __esm({
12628
- "node_modules/.pnpm/micromark-util-classify-character@2.0.0/node_modules/micromark-util-classify-character/index.js"() {
12628
+ "node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/index.js"() {
12629
12629
  init_micromark_util_character();
12630
12630
  }
12631
12631
  });
12632
12632
 
12633
- // node_modules/.pnpm/micromark-util-resolve-all@2.0.0/node_modules/micromark-util-resolve-all/index.js
12633
+ // node_modules/.pnpm/micromark-util-resolve-all@2.0.1/node_modules/micromark-util-resolve-all/index.js
12634
12634
  function resolveAll(constructs2, events, context) {
12635
12635
  const called = [];
12636
12636
  let index = -1;
@@ -12644,11 +12644,11 @@ function resolveAll(constructs2, events, context) {
12644
12644
  return events;
12645
12645
  }
12646
12646
  var init_micromark_util_resolve_all = __esm({
12647
- "node_modules/.pnpm/micromark-util-resolve-all@2.0.0/node_modules/micromark-util-resolve-all/index.js"() {
12647
+ "node_modules/.pnpm/micromark-util-resolve-all@2.0.1/node_modules/micromark-util-resolve-all/index.js"() {
12648
12648
  }
12649
12649
  });
12650
12650
 
12651
- // node_modules/.pnpm/micromark-factory-space@2.0.0/node_modules/micromark-factory-space/index.js
12651
+ // node_modules/.pnpm/micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.js
12652
12652
  function factorySpace(effects, ok3, type, max) {
12653
12653
  const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
12654
12654
  let size = 0;
@@ -12670,12 +12670,12 @@ function factorySpace(effects, ok3, type, max) {
12670
12670
  }
12671
12671
  }
12672
12672
  var init_micromark_factory_space = __esm({
12673
- "node_modules/.pnpm/micromark-factory-space@2.0.0/node_modules/micromark-factory-space/index.js"() {
12673
+ "node_modules/.pnpm/micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.js"() {
12674
12674
  init_micromark_util_character();
12675
12675
  }
12676
12676
  });
12677
12677
 
12678
- // node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/lib/blank-line.js
12678
+ // node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/lib/blank-line.js
12679
12679
  function tokenizeBlankLine(effects, ok3, nok) {
12680
12680
  return start;
12681
12681
  function start(code3) {
@@ -12687,19 +12687,19 @@ function tokenizeBlankLine(effects, ok3, nok) {
12687
12687
  }
12688
12688
  var blankLine;
12689
12689
  var init_blank_line = __esm({
12690
- "node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/lib/blank-line.js"() {
12690
+ "node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/lib/blank-line.js"() {
12691
12691
  init_micromark_factory_space();
12692
12692
  init_micromark_util_character();
12693
12693
  blankLine = {
12694
- tokenize: tokenizeBlankLine,
12695
- partial: true
12694
+ partial: true,
12695
+ tokenize: tokenizeBlankLine
12696
12696
  };
12697
12697
  }
12698
12698
  });
12699
12699
 
12700
- // node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/index.js
12700
+ // node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/index.js
12701
12701
  var init_micromark_core_commonmark = __esm({
12702
- "node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/index.js"() {
12702
+ "node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/index.js"() {
12703
12703
  init_blank_line();
12704
12704
  }
12705
12705
  });
@@ -14285,7 +14285,7 @@ function extendConfig(baseConfigExport, serverConfigExport) {
14285
14285
  }
14286
14286
 
14287
14287
  // sw-reg:@qwik-router-sw-register-build
14288
- var qwik_router_sw_register_build_default = '((i,r,a,o)=>{a=e=>{const t=document.querySelector("[q\\\\:base]");t&&r.active&&r.active.postMessage({type:"qprefetch",base:t.getAttribute("q:base"),...e})},document.addEventListener("qprefetch",e=>{const t=e.detail;r?a(t):i.push(t)}),"serviceWorker"in navigator?navigator.serviceWorker.register("__url").then(e=>{o=()=>{r=e,i.forEach(a),a({bundles:i})},e.installing?e.installing.addEventListener("statechange",t=>{t.target.state=="activated"&&o()}):e.active&&o()}).catch(e=>console.error(e)):console.log("Service worker not supported in this browser.")})([])';
14288
+ var qwik_router_sw_register_build_default = '"serviceWorker"in navigator?navigator.serviceWorker.register("__url").catch(r=>console.error(r)):console.log("Service worker not supported in this browser.")';
14289
14289
 
14290
14290
  // packages/qwik-router/src/buildtime/vite/plugin.ts
14291
14291
  import fs8 from "node:fs";
@@ -14295,17 +14295,11 @@ import { loadEnv } from "vite";
14295
14295
  // packages/qwik-router/src/middleware/request-handler/error-handler.ts
14296
14296
  var ServerError = class extends Error {
14297
14297
  constructor(status, data) {
14298
- super();
14298
+ super(typeof data === "string" ? data : void 0);
14299
14299
  this.status = status;
14300
14300
  this.data = data;
14301
14301
  }
14302
14302
  };
14303
- var ErrorResponse = class extends Error {
14304
- constructor(status, message) {
14305
- super(message);
14306
- this.status = status;
14307
- }
14308
- };
14309
14303
  function getErrorHtml(status, e) {
14310
14304
  let message = "Server Error";
14311
14305
  if (e != null) {
@@ -14670,8 +14664,7 @@ function createCacheControl(cacheControl) {
14670
14664
  cacheControl = {
14671
14665
  public: true,
14672
14666
  immutable: true,
14673
- maxAge: 60 * 60 * 24 * 365,
14674
- staleWhileRevalidate: 60 * 60 * 24 * 365
14667
+ maxAge: 60 * 60 * 24 * 365
14675
14668
  };
14676
14669
  } else if (cacheControl === "no-cache") {
14677
14670
  cacheControl = {
@@ -14681,8 +14674,7 @@ function createCacheControl(cacheControl) {
14681
14674
  if (typeof cacheControl === "number") {
14682
14675
  cacheControl = {
14683
14676
  maxAge: cacheControl,
14684
- sMaxAge: cacheControl,
14685
- staleWhileRevalidate: cacheControl
14677
+ sMaxAge: cacheControl
14686
14678
  };
14687
14679
  }
14688
14680
  if (cacheControl.immutable) {
@@ -14727,14 +14719,13 @@ import("node:async_hooks").then((module) => {
14727
14719
  err
14728
14720
  );
14729
14721
  });
14730
- function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, manifest, trailingSlash = true, basePathname = "/", qwikSerializer) {
14722
+ function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, trailingSlash = true, basePathname = "/", qwikSerializer) {
14731
14723
  let resolve4;
14732
14724
  const responsePromise = new Promise((r2) => resolve4 = r2);
14733
14725
  const requestEv = createRequestEvent(
14734
14726
  serverRequestEv,
14735
14727
  loadedRoute,
14736
14728
  requestHandlers,
14737
- manifest,
14738
14729
  trailingSlash,
14739
14730
  basePathname,
14740
14731
  qwikSerializer,
@@ -14753,12 +14744,18 @@ async function runNext(requestEv, resolve4) {
14753
14744
  if (e instanceof RedirectMessage) {
14754
14745
  const stream = requestEv.getWritableStream();
14755
14746
  await stream.close();
14756
- } else if (e instanceof ErrorResponse) {
14757
- console.error(e);
14747
+ } else if (e instanceof ServerError) {
14758
14748
  if (!requestEv.headersSent) {
14759
- const html5 = getErrorHtml(e.status, e);
14760
14749
  const status = e.status;
14761
- requestEv.html(status, html5);
14750
+ const accept = requestEv.request.headers.get("Accept");
14751
+ if (accept && !accept.includes("text/html")) {
14752
+ const qwikSerializer = requestEv[RequestEvQwikSerializer];
14753
+ requestEv.headers.set("Content-Type", "application/qwik-json");
14754
+ requestEv.send(status, await qwikSerializer._serialize([e.data]));
14755
+ } else {
14756
+ const html5 = getErrorHtml(e.status, e.data);
14757
+ requestEv.html(status, html5);
14758
+ }
14762
14759
  }
14763
14760
  } else if (!(e instanceof AbortMessage)) {
14764
14761
  if (getRequestMode(requestEv) !== "dev") {
@@ -14811,7 +14808,7 @@ var RequestRouteName = "@routeName";
14811
14808
  var RequestEvSharedActionId = "@actionId";
14812
14809
  var RequestEvSharedActionFormData = "@actionFormData";
14813
14810
  var RequestEvSharedNonce = "@nonce";
14814
- function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manifest, trailingSlash, basePathname, qwikSerializer, resolved) {
14811
+ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trailingSlash, basePathname, qwikSerializer, resolved) {
14815
14812
  const { request, platform, env: env2 } = serverRequestEv;
14816
14813
  const sharedMap = /* @__PURE__ */ new Map();
14817
14814
  const cookie = new Cookie(request.headers.get("cookie"));
@@ -14824,7 +14821,6 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14824
14821
  }
14825
14822
  sharedMap.set(IsQData, true);
14826
14823
  }
14827
- sharedMap.set("@manifest", manifest);
14828
14824
  let routeModuleIndex = -1;
14829
14825
  let writableStream = null;
14830
14826
  let requestData = void 0;
@@ -14858,17 +14854,25 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14858
14854
  } else {
14859
14855
  status = statusOrResponse.status;
14860
14856
  statusOrResponse.headers.forEach((value2, key) => {
14857
+ if (key.toLowerCase() === "set-cookie") {
14858
+ return;
14859
+ }
14861
14860
  headers.append(key, value2);
14862
14861
  });
14862
+ statusOrResponse.headers.getSetCookie().forEach((ck) => {
14863
+ const index = ck.indexOf("=");
14864
+ if (index === -1) {
14865
+ return;
14866
+ }
14867
+ const key = ck.slice(0, index).trim();
14868
+ const value2 = ck.slice(index + 1).trim();
14869
+ cookie.set(key, value2);
14870
+ });
14863
14871
  if (statusOrResponse.body) {
14864
14872
  const writableStream2 = requestEv.getWritableStream();
14865
14873
  statusOrResponse.body.pipeTo(writableStream2);
14866
14874
  } else {
14867
- if (status >= 300 && status < 400) {
14868
- return new RedirectMessage();
14869
- } else {
14870
- requestEv.getWritableStream().getWriter().close();
14871
- }
14875
+ requestEv.getWritableStream().getWriter().close();
14872
14876
  }
14873
14877
  }
14874
14878
  return exit2();
@@ -14939,7 +14943,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14939
14943
  },
14940
14944
  error: (statusCode, message) => {
14941
14945
  status = statusCode;
14942
- return new ErrorResponse(statusCode, message);
14946
+ return new ServerError(statusCode, message);
14943
14947
  },
14944
14948
  redirect: (statusCode, url2) => {
14945
14949
  check();
@@ -15040,7 +15044,7 @@ var parseRequest = async ({ request, method, query }, sharedMap, qwikSerializer)
15040
15044
  if (data) {
15041
15045
  try {
15042
15046
  return qwikSerializer._deserialize(decodeURIComponent(data));
15043
- } catch (err) {
15047
+ } catch {
15044
15048
  }
15045
15049
  }
15046
15050
  }
@@ -15354,13 +15358,9 @@ async function pureServerFunction(ev) {
15354
15358
  }
15355
15359
  } catch (err) {
15356
15360
  if (err instanceof ServerError) {
15357
- ev.headers.set("Content-Type", "application/qwik-json");
15358
- ev.send(err.status, await qwikSerializer._serialize([err.data]));
15359
- return;
15361
+ throw ev.error(err.status, err.data);
15360
15362
  }
15361
- ev.headers.set("Content-Type", "application/qwik-json");
15362
- ev.send(500, await qwikSerializer._serialize([err]));
15363
- return;
15363
+ throw ev.error(500, "Invalid request");
15364
15364
  }
15365
15365
  if (isAsyncIterator(result)) {
15366
15366
  ev.headers.set("Content-Type", "text/qwik-json-stream");
@@ -15480,10 +15480,10 @@ async function handleRedirect(requestEv) {
15480
15480
  return;
15481
15481
  }
15482
15482
  const status = requestEv.status();
15483
- const location2 = requestEv.headers.get("Location");
15484
- const isRedirect = status >= 301 && status <= 308 && location2;
15483
+ const location = requestEv.headers.get("Location");
15484
+ const isRedirect = status >= 301 && status <= 308 && location;
15485
15485
  if (isRedirect) {
15486
- const adaptedLocation = makeQDataPath(location2);
15486
+ const adaptedLocation = makeQDataPath(location);
15487
15487
  if (adaptedLocation) {
15488
15488
  requestEv.headers.set("Location", adaptedLocation);
15489
15489
  requestEv.getWritableStream().close();
@@ -15504,7 +15504,7 @@ async function renderQData(requestEv) {
15504
15504
  return;
15505
15505
  }
15506
15506
  const status = requestEv.status();
15507
- const location2 = requestEv.headers.get("Location");
15507
+ const location = requestEv.headers.get("Location");
15508
15508
  const trailingSlash = getRequestTrailingSlash(requestEv);
15509
15509
  const requestHeaders = {};
15510
15510
  requestEv.request.headers.forEach((value2, key) => requestHeaders[key] = value2);
@@ -15514,7 +15514,7 @@ async function renderQData(requestEv) {
15514
15514
  action: requestEv.sharedMap.get(RequestEvSharedActionId),
15515
15515
  status: status !== 200 ? status : 200,
15516
15516
  href: getPathname(requestEv.url, trailingSlash),
15517
- redirect: location2 ?? void 0
15517
+ redirect: location ?? void 0
15518
15518
  };
15519
15519
  const writer = requestEv.getWritableStream().getWriter();
15520
15520
  const qwikSerializer = requestEv[RequestEvQwikSerializer];
@@ -15551,7 +15551,7 @@ async function measure(requestEv, name, fn) {
15551
15551
  }
15552
15552
  function isContentType(headers, ...types) {
15553
15553
  var _a;
15554
- const type = ((_a = headers.get("content-type")) == null ? void 0 : _a.split(/;,/, 1)[0].trim()) ?? "";
15554
+ const type = ((_a = headers.get("content-type")) == null ? void 0 : _a.split(/;/, 1)[0].trim()) ?? "";
15555
15555
  return types.includes(type);
15556
15556
  }
15557
15557
 
@@ -25952,6 +25952,9 @@ async function createMdxTransformer(ctx) {
25952
25952
  const addImport = `import { jsx } from '@qwik.dev/core';
25953
25953
  `;
25954
25954
  const newDefault = `
25955
+ function _missingMdxReference(id, component, place) {
25956
+ throw new Error("${id}: Expected " + (component ? "component" : "object") + " \`" + id + "\` to be defined: you likely forgot to import, pass, or provide it." + (place ? "\\nIt\u2019s referenced in your code at \`" + place + "\`" : ""));
25957
+ }
25955
25958
  const WrappedMdxContent = () => {
25956
25959
  const content = _createMdxContent({});
25957
25960
  return typeof MDXLayout === 'function' ? jsx(MDXLayout, {children: content}) : content;
@@ -26166,130 +26169,6 @@ function generateServiceWorkerRegister(ctx, swRegister) {
26166
26169
  }
26167
26170
  return `export default ${JSON.stringify(swReg)};`;
26168
26171
  }
26169
- function prependManifestToServiceWorker(ctx, manifest, prefetch, swCode) {
26170
- const key = `/* Qwik Service Worker */`;
26171
- if (swCode.includes(key)) {
26172
- return null;
26173
- }
26174
- const appBundles = [];
26175
- const appBundlesCode = generateAppBundles(appBundles, manifest);
26176
- const libraryBundlesCode = generateLibraryBundles(appBundles, manifest);
26177
- const [linkBundlesCode] = generateLinkBundles(ctx, appBundles, manifest, prefetch);
26178
- return [key, appBundlesCode, libraryBundlesCode, linkBundlesCode, swCode].join("\n");
26179
- }
26180
- function generateAppBundles(appBundles, manifest) {
26181
- const sortedBundles = Object.keys(manifest.bundles).sort();
26182
- for (const appBundleName of sortedBundles) {
26183
- const appBundle = [appBundleName, []];
26184
- appBundles.push(appBundle);
26185
- const symbolHashesInBundle = [];
26186
- const manifestBundle = manifest.bundles[appBundleName];
26187
- const importedBundleNames = Array.isArray(manifestBundle.imports) ? manifestBundle.imports : [];
26188
- const depsSet = new Set(importedBundleNames);
26189
- for (const importedBundleName of importedBundleNames) {
26190
- clearTransitiveDeps(depsSet, /* @__PURE__ */ new Set(), importedBundleName);
26191
- }
26192
- appBundle[1] = Array.from(depsSet).map((dep) => sortedBundles.indexOf(dep));
26193
- if (manifestBundle.symbols) {
26194
- for (const manifestBundleSymbolName of manifestBundle.symbols) {
26195
- const symbol = manifest.symbols[manifestBundleSymbolName];
26196
- if ((symbol == null ? void 0 : symbol.hash) && !symbolHashesInBundle.includes(symbol.hash)) {
26197
- symbolHashesInBundle.push(symbol.hash);
26198
- }
26199
- }
26200
- }
26201
- if (symbolHashesInBundle.length > 0) {
26202
- appBundle[2] = symbolHashesInBundle;
26203
- }
26204
- }
26205
- function clearTransitiveDeps(deps, seen, depName) {
26206
- const childBundle = manifest.bundles[depName];
26207
- for (const childDepImport of childBundle.imports || []) {
26208
- if (deps.has(childDepImport)) {
26209
- deps.delete(childDepImport);
26210
- }
26211
- if (!seen.has(childDepImport)) {
26212
- seen.add(childDepImport);
26213
- clearTransitiveDeps(deps, seen, childDepImport);
26214
- }
26215
- }
26216
- }
26217
- return `const appBundles=${JSON.stringify(appBundles)};`;
26218
- }
26219
- function generateLibraryBundles(appBundles, manifest) {
26220
- const libraryBundleIds = [];
26221
- for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26222
- if (bundle.origins && bundle.origins.includes("@qwik-router-config")) {
26223
- libraryBundleIds.push(getAppBundleIndex(appBundles, bundleName));
26224
- break;
26225
- }
26226
- }
26227
- return `const libraryBundleIds=${JSON.stringify(libraryBundleIds)};`;
26228
- }
26229
- function generateLinkBundles(ctx, appBundles, manifest, prefetch) {
26230
- var _a, _b;
26231
- const linkBundles = [];
26232
- const symbolToBundle = /* @__PURE__ */ new Map();
26233
- const routeToBundles = {};
26234
- for (const bundleName in manifest.bundles || []) {
26235
- (_a = manifest.bundles[bundleName].symbols) == null ? void 0 : _a.forEach((symbol) => {
26236
- const idx = symbol.lastIndexOf("_");
26237
- symbolToBundle.set(idx === -1 ? symbol : symbol.substring(idx + 1), bundleName);
26238
- });
26239
- }
26240
- for (const r2 of ctx.routes) {
26241
- const linkBundleNames = [];
26242
- const addFileBundles = (filePath) => {
26243
- for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26244
- if (bundle.origins) {
26245
- for (const bundleOrigin of bundle.origins) {
26246
- const srcPath = removeExtension(filePath);
26247
- const bundleOriginPath = removeExtension(bundleOrigin);
26248
- if (srcPath.endsWith(bundleOriginPath)) {
26249
- if (!linkBundleNames.includes(bundleName)) {
26250
- linkBundleNames.push(bundleName);
26251
- }
26252
- if (bundle.dynamicImports) {
26253
- for (const dynamicImport of bundle.dynamicImports) {
26254
- if (!linkBundleNames.includes(dynamicImport)) {
26255
- linkBundleNames.push(dynamicImport);
26256
- }
26257
- }
26258
- }
26259
- }
26260
- }
26261
- }
26262
- }
26263
- };
26264
- for (const layout of r2.layouts) {
26265
- addFileBundles(layout.filePath);
26266
- }
26267
- addFileBundles(r2.filePath);
26268
- if (prefetch) {
26269
- const symbolsForRoute = prefetch.find((p) => p.route === r2.routeName);
26270
- (_b = symbolsForRoute == null ? void 0 : symbolsForRoute.symbols) == null ? void 0 : _b.reverse().forEach((symbol) => {
26271
- const bundle = symbolToBundle.get(symbol);
26272
- if (bundle) {
26273
- const idx = linkBundleNames.indexOf(bundle);
26274
- if (idx !== -1) {
26275
- linkBundleNames.splice(idx, 1);
26276
- }
26277
- linkBundleNames.unshift(bundle);
26278
- }
26279
- });
26280
- }
26281
- linkBundles.push(
26282
- `[${r2.pattern.toString()},${JSON.stringify(
26283
- linkBundleNames.map((bundleName) => getAppBundleIndex(appBundles, bundleName))
26284
- )}]`
26285
- );
26286
- routeToBundles[r2.routeName] = linkBundleNames;
26287
- }
26288
- return [`const linkBundles=[${linkBundles.join(",")}];`, routeToBundles];
26289
- }
26290
- function getAppBundleIndex(appBundles, bundleName) {
26291
- return appBundles.findIndex((b) => b[0] === bundleName);
26292
- }
26293
26172
  var SW_UNREGISTER = `
26294
26173
  navigator.serviceWorker?.getRegistrations().then((regs) => {
26295
26174
  for (const reg of regs) {
@@ -26520,6 +26399,16 @@ function generateCodeFrame(source, start = 0, end) {
26520
26399
  }
26521
26400
  return res.join("\n");
26522
26401
  }
26402
+ function parseId(originalId) {
26403
+ const [pathId, query] = originalId.split("?");
26404
+ const queryStr = query || "";
26405
+ return {
26406
+ originalId,
26407
+ pathId,
26408
+ query: queryStr ? `?${query}` : "",
26409
+ params: new URLSearchParams(queryStr)
26410
+ };
26411
+ }
26523
26412
 
26524
26413
  // packages/qwik-router/src/buildtime/vite/format-error.ts
26525
26414
  import fs4 from "node:fs";
@@ -26702,21 +26591,12 @@ function ssrDevMiddleware(ctx, server) {
26702
26591
  if (requestHandlers.length > 0) {
26703
26592
  const serverRequestEv = await fromNodeHttp(url, req, res, "dev");
26704
26593
  Object.assign(serverRequestEv.platform, ctx.opts.platform);
26705
- const manifest = {
26706
- manifestHash: "",
26707
- symbols: {},
26708
- mapping: {},
26709
- bundles: {},
26710
- injections: [],
26711
- version: "1"
26712
- };
26713
26594
  const { _deserialize, _serialize, _verifySerializable } = await server.ssrLoadModule("@qwik-serializer");
26714
26595
  const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
26715
26596
  const { completion, requestEv } = runQwikRouter(
26716
26597
  serverRequestEv,
26717
26598
  loadedRoute,
26718
26599
  requestHandlers,
26719
- manifest,
26720
26600
  ctx.opts.trailingSlash,
26721
26601
  ctx.opts.basePathname,
26722
26602
  qwikSerializer
@@ -26879,7 +26759,7 @@ function staticDistMiddleware({ config }) {
26879
26759
  fs5.createReadStream(filePath).pipe(res);
26880
26760
  return;
26881
26761
  }
26882
- } catch (e) {
26762
+ } catch {
26883
26763
  }
26884
26764
  }
26885
26765
  next();
@@ -26911,7 +26791,7 @@ function formatDevSerializeError(err, routeModulePaths) {
26911
26791
  if (line > -1) {
26912
26792
  err.loc.line = line + 1;
26913
26793
  }
26914
- } catch (e) {
26794
+ } catch {
26915
26795
  }
26916
26796
  }
26917
26797
  }
@@ -26975,29 +26855,55 @@ self.addEventListener('install', () => self.skipWaiting());
26975
26855
  self.addEventListener('activate', (ev) => ev.waitUntil(self.clients.claim()));
26976
26856
  `;
26977
26857
 
26858
+ // packages/qwik-router/src/buildtime/vite/get-route-imports.ts
26859
+ function getRouteImports(routes, manifest) {
26860
+ var _a, _b;
26861
+ const result = {};
26862
+ routes.forEach((route) => {
26863
+ const routePath = removeExtension(route.filePath);
26864
+ const layoutPaths = route.layouts ? route.layouts.map((layout) => removeExtension(layout.filePath)) : [];
26865
+ const routeAndLayoutPaths = [routePath, ...layoutPaths];
26866
+ const bundles = [];
26867
+ for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26868
+ if (isBundlePartOfRoute(bundle, routeAndLayoutPaths)) {
26869
+ bundles.push(bundleName);
26870
+ }
26871
+ }
26872
+ if (bundles.length > 0) {
26873
+ result[route.routeName] = { dynamicImports: bundles };
26874
+ }
26875
+ });
26876
+ for (const bundleName of Object.keys(manifest.bundles)) {
26877
+ const bundle = manifest.bundles[bundleName];
26878
+ if ((_a = bundle.origins) == null ? void 0 : _a.some((s2) => s2.endsWith(QWIK_ROUTER_CONFIG_ID))) {
26879
+ result[bundleName] = {
26880
+ ...bundle,
26881
+ dynamicImports: (_b = bundle.dynamicImports) == null ? void 0 : _b.filter(
26882
+ (d) => {
26883
+ var _a2;
26884
+ return (_a2 = manifest.bundles[d].origins) == null ? void 0 : _a2.some((s2) => s2.endsWith("menu.md"));
26885
+ }
26886
+ )
26887
+ };
26888
+ break;
26889
+ }
26890
+ }
26891
+ return result;
26892
+ }
26893
+ function isBundlePartOfRoute(bundle, routeAndLayoutPaths) {
26894
+ if (!bundle.origins) {
26895
+ return false;
26896
+ }
26897
+ for (const bundleOrigin of bundle.origins) {
26898
+ const originPath = removeExtension(bundleOrigin);
26899
+ return routeAndLayoutPaths.some((path3) => path3.endsWith(originPath));
26900
+ }
26901
+ }
26902
+
26978
26903
  // packages/qwik-router/src/buildtime/vite/image-jsx.ts
26979
26904
  import fs6 from "node:fs";
26980
26905
  import path2 from "node:path";
26981
26906
  import { optimize } from "svgo";
26982
-
26983
- // packages/qwik/src/optimizer/src/versions.ts
26984
- var versions = {
26985
- qwik: globalThis.QWIK_VERSION
26986
- };
26987
-
26988
- // packages/qwik/src/optimizer/src/plugins/plugin.ts
26989
- function parseId(originalId) {
26990
- const [pathId, query] = originalId.split("?");
26991
- const queryStr = query || "";
26992
- return {
26993
- originalId,
26994
- pathId,
26995
- query: queryStr ? `?${query}` : "",
26996
- params: new URLSearchParams(queryStr)
26997
- };
26998
- }
26999
-
27000
- // packages/qwik-router/src/buildtime/vite/image-jsx.ts
27001
26907
  function imagePlugin(userOpts) {
27002
26908
  const supportedExtensions = [".jpg", ".jpeg", ".png", ".webp", ".gif", ".avif", ".tiff"];
27003
26909
  return [
@@ -27030,7 +26936,7 @@ function imagePlugin(userOpts) {
27030
26936
  defaultDirectives: (url) => {
27031
26937
  var _a;
27032
26938
  if (url.searchParams.has("jsx")) {
27033
- const { jsx: jsx2, ...params } = Object.fromEntries(url.searchParams.entries());
26939
+ const { jsx: _2, ...params } = Object.fromEntries(url.searchParams.entries());
27034
26940
  return new URLSearchParams({
27035
26941
  format: "webp",
27036
26942
  quality: "75",
@@ -27254,7 +27160,7 @@ function qwikRouterPlugin(userOpts) {
27254
27160
  return updatedViteConfig;
27255
27161
  },
27256
27162
  async configResolved(config) {
27257
- var _a, _b, _c;
27163
+ var _a, _b, _c, _d, _e;
27258
27164
  Object.assign(process.env, loadEnv(config.mode, process.cwd(), ""));
27259
27165
  rootDir = resolve3(config.root);
27260
27166
  const target = ((_a = config.build) == null ? void 0 : _a.ssr) || config.mode === "ssr" ? "ssr" : "client";
@@ -27267,10 +27173,13 @@ function qwikRouterPlugin(userOpts) {
27267
27173
  if (!qwikPlugin) {
27268
27174
  throw new Error("Missing vite-plugin-qwik");
27269
27175
  }
27270
- if (((_b = config.ssr) == null ? void 0 : _b.format) === "cjs") {
27176
+ (_c = (_b = qwikPlugin.api).registerBundleGraphAdder) == null ? void 0 : _c.call(_b, (manifest) => {
27177
+ return getRouteImports(ctx.routes, manifest);
27178
+ });
27179
+ if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
27271
27180
  ssrFormat = "cjs";
27272
27181
  }
27273
- outDir = (_c = config.build) == null ? void 0 : _c.outDir;
27182
+ outDir = (_e = config.build) == null ? void 0 : _e.outDir;
27274
27183
  },
27275
27184
  configureServer(server) {
27276
27185
  return () => {
@@ -27412,34 +27321,7 @@ function qwikRouterPlugin(userOpts) {
27412
27321
  sequential: true,
27413
27322
  async handler() {
27414
27323
  if ((ctx == null ? void 0 : ctx.target) === "ssr" && !(ctx == null ? void 0 : ctx.isDevServer)) {
27415
- const manifest = qwikPlugin.api.getManifest();
27416
27324
  const clientOutDir = qwikPlugin.api.getClientOutDir();
27417
- if (manifest && clientOutDir) {
27418
- const basePathRelDir = api.getBasePathname().replace(/^\/|\/$/, "");
27419
- const clientOutBaseDir = join6(clientOutDir, basePathRelDir);
27420
- const insightsManifest = await qwikPlugin.api.getInsightsManifest(clientOutDir);
27421
- for (const swEntry of ctx.serviceWorkers) {
27422
- try {
27423
- const swClientDistPath = join6(clientOutBaseDir, swEntry.chunkFileName);
27424
- const swCode = await fs8.promises.readFile(swClientDistPath, "utf-8");
27425
- try {
27426
- const swCodeUpdate = prependManifestToServiceWorker(
27427
- ctx,
27428
- manifest,
27429
- (insightsManifest == null ? void 0 : insightsManifest.prefetch) || null,
27430
- swCode
27431
- );
27432
- if (swCodeUpdate) {
27433
- await fs8.promises.mkdir(clientOutDir, { recursive: true });
27434
- await fs8.promises.writeFile(swClientDistPath, swCodeUpdate);
27435
- }
27436
- } catch (e2) {
27437
- console.error(e2);
27438
- }
27439
- } catch (e) {
27440
- }
27441
- }
27442
- }
27443
27325
  if (outDir && clientOutDir) {
27444
27326
  const assetsDir = qwikPlugin.api.getAssetsDir();
27445
27327
  const { staticPathsCode, notFoundPathsCode } = await postBuild(