@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
@@ -9631,7 +9631,7 @@ var init_default = __esm({
9631
9631
  }
9632
9632
  });
9633
9633
 
9634
- // node_modules/.pnpm/micromark-util-character@2.1.0/node_modules/micromark-util-character/index.js
9634
+ // node_modules/.pnpm/micromark-util-character@2.1.1/node_modules/micromark-util-character/index.js
9635
9635
  function asciiControl(code3) {
9636
9636
  return (
9637
9637
  // Special whitespace codes (which have negative values), C0 and Control
@@ -9656,7 +9656,7 @@ function regexCheck(regex3) {
9656
9656
  }
9657
9657
  var asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace;
9658
9658
  var init_micromark_util_character = __esm({
9659
- "node_modules/.pnpm/micromark-util-character@2.1.0/node_modules/micromark-util-character/index.js"() {
9659
+ "node_modules/.pnpm/micromark-util-character@2.1.1/node_modules/micromark-util-character/index.js"() {
9660
9660
  asciiAlpha = regexCheck(/[A-Za-z]/);
9661
9661
  asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
9662
9662
  asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
@@ -10464,12 +10464,12 @@ var init_mdast_util_gfm_autolink_literal = __esm({
10464
10464
  }
10465
10465
  });
10466
10466
 
10467
- // node_modules/.pnpm/micromark-util-normalize-identifier@2.0.0/node_modules/micromark-util-normalize-identifier/index.js
10467
+ // node_modules/.pnpm/micromark-util-normalize-identifier@2.0.1/node_modules/micromark-util-normalize-identifier/index.js
10468
10468
  function normalizeIdentifier(value2) {
10469
10469
  return value2.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
10470
10470
  }
10471
10471
  var init_micromark_util_normalize_identifier = __esm({
10472
- "node_modules/.pnpm/micromark-util-normalize-identifier@2.0.0/node_modules/micromark-util-normalize-identifier/index.js"() {
10472
+ "node_modules/.pnpm/micromark-util-normalize-identifier@2.0.1/node_modules/micromark-util-normalize-identifier/index.js"() {
10473
10473
  }
10474
10474
  });
10475
10475
 
@@ -12180,7 +12180,7 @@ var init_mdast_util_gfm = __esm({
12180
12180
  }
12181
12181
  });
12182
12182
 
12183
- // node_modules/.pnpm/micromark-util-chunked@2.0.0/node_modules/micromark-util-chunked/index.js
12183
+ // node_modules/.pnpm/micromark-util-chunked@2.0.1/node_modules/micromark-util-chunked/index.js
12184
12184
  function splice(list3, start, remove, items) {
12185
12185
  const end = list3.length;
12186
12186
  let chunkStart = 0;
@@ -12207,11 +12207,11 @@ function splice(list3, start, remove, items) {
12207
12207
  }
12208
12208
  }
12209
12209
  var init_micromark_util_chunked = __esm({
12210
- "node_modules/.pnpm/micromark-util-chunked@2.0.0/node_modules/micromark-util-chunked/index.js"() {
12210
+ "node_modules/.pnpm/micromark-util-chunked@2.0.1/node_modules/micromark-util-chunked/index.js"() {
12211
12211
  }
12212
12212
  });
12213
12213
 
12214
- // node_modules/.pnpm/micromark-util-combine-extensions@2.0.0/node_modules/micromark-util-combine-extensions/index.js
12214
+ // node_modules/.pnpm/micromark-util-combine-extensions@2.0.1/node_modules/micromark-util-combine-extensions/index.js
12215
12215
  function combineExtensions(extensions) {
12216
12216
  const all3 = {};
12217
12217
  let index = -1;
@@ -12251,7 +12251,7 @@ function constructs(existing, list3) {
12251
12251
  }
12252
12252
  var hasOwnProperty;
12253
12253
  var init_micromark_util_combine_extensions = __esm({
12254
- "node_modules/.pnpm/micromark-util-combine-extensions@2.0.0/node_modules/micromark-util-combine-extensions/index.js"() {
12254
+ "node_modules/.pnpm/micromark-util-combine-extensions@2.0.1/node_modules/micromark-util-combine-extensions/index.js"() {
12255
12255
  init_micromark_util_chunked();
12256
12256
  hasOwnProperty = {}.hasOwnProperty;
12257
12257
  }
@@ -12617,7 +12617,7 @@ var init_micromark_extension_gfm_autolink_literal = __esm({
12617
12617
  }
12618
12618
  });
12619
12619
 
12620
- // node_modules/.pnpm/micromark-util-classify-character@2.0.0/node_modules/micromark-util-classify-character/index.js
12620
+ // node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/index.js
12621
12621
  function classifyCharacter(code3) {
12622
12622
  if (code3 === null || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3)) {
12623
12623
  return 1;
@@ -12627,12 +12627,12 @@ function classifyCharacter(code3) {
12627
12627
  }
12628
12628
  }
12629
12629
  var init_micromark_util_classify_character = __esm({
12630
- "node_modules/.pnpm/micromark-util-classify-character@2.0.0/node_modules/micromark-util-classify-character/index.js"() {
12630
+ "node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/index.js"() {
12631
12631
  init_micromark_util_character();
12632
12632
  }
12633
12633
  });
12634
12634
 
12635
- // node_modules/.pnpm/micromark-util-resolve-all@2.0.0/node_modules/micromark-util-resolve-all/index.js
12635
+ // node_modules/.pnpm/micromark-util-resolve-all@2.0.1/node_modules/micromark-util-resolve-all/index.js
12636
12636
  function resolveAll(constructs2, events, context) {
12637
12637
  const called = [];
12638
12638
  let index = -1;
@@ -12646,11 +12646,11 @@ function resolveAll(constructs2, events, context) {
12646
12646
  return events;
12647
12647
  }
12648
12648
  var init_micromark_util_resolve_all = __esm({
12649
- "node_modules/.pnpm/micromark-util-resolve-all@2.0.0/node_modules/micromark-util-resolve-all/index.js"() {
12649
+ "node_modules/.pnpm/micromark-util-resolve-all@2.0.1/node_modules/micromark-util-resolve-all/index.js"() {
12650
12650
  }
12651
12651
  });
12652
12652
 
12653
- // node_modules/.pnpm/micromark-factory-space@2.0.0/node_modules/micromark-factory-space/index.js
12653
+ // node_modules/.pnpm/micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.js
12654
12654
  function factorySpace(effects, ok3, type, max) {
12655
12655
  const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
12656
12656
  let size = 0;
@@ -12672,12 +12672,12 @@ function factorySpace(effects, ok3, type, max) {
12672
12672
  }
12673
12673
  }
12674
12674
  var init_micromark_factory_space = __esm({
12675
- "node_modules/.pnpm/micromark-factory-space@2.0.0/node_modules/micromark-factory-space/index.js"() {
12675
+ "node_modules/.pnpm/micromark-factory-space@2.0.1/node_modules/micromark-factory-space/index.js"() {
12676
12676
  init_micromark_util_character();
12677
12677
  }
12678
12678
  });
12679
12679
 
12680
- // node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/lib/blank-line.js
12680
+ // node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/lib/blank-line.js
12681
12681
  function tokenizeBlankLine(effects, ok3, nok) {
12682
12682
  return start;
12683
12683
  function start(code3) {
@@ -12689,19 +12689,19 @@ function tokenizeBlankLine(effects, ok3, nok) {
12689
12689
  }
12690
12690
  var blankLine;
12691
12691
  var init_blank_line = __esm({
12692
- "node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/lib/blank-line.js"() {
12692
+ "node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/lib/blank-line.js"() {
12693
12693
  init_micromark_factory_space();
12694
12694
  init_micromark_util_character();
12695
12695
  blankLine = {
12696
- tokenize: tokenizeBlankLine,
12697
- partial: true
12696
+ partial: true,
12697
+ tokenize: tokenizeBlankLine
12698
12698
  };
12699
12699
  }
12700
12700
  });
12701
12701
 
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
  var init_micromark_core_commonmark = __esm({
12704
- "node_modules/.pnpm/micromark-core-commonmark@2.0.1/node_modules/micromark-core-commonmark/index.js"() {
12704
+ "node_modules/.pnpm/micromark-core-commonmark@2.0.2/node_modules/micromark-core-commonmark/index.js"() {
12705
12705
  init_blank_line();
12706
12706
  }
12707
12707
  });
@@ -14271,13 +14271,13 @@ var init_rehype_autolink_headings = __esm({
14271
14271
  });
14272
14272
 
14273
14273
  // packages/qwik-router/src/buildtime/vite/index.ts
14274
- var vite_exports = {};
14275
- __export(vite_exports, {
14274
+ var index_exports = {};
14275
+ __export(index_exports, {
14276
14276
  extendConfig: () => extendConfig,
14277
14277
  qwikCity: () => qwikCity,
14278
14278
  qwikRouter: () => qwikRouter
14279
14279
  });
14280
- module.exports = __toCommonJS(vite_exports);
14280
+ module.exports = __toCommonJS(index_exports);
14281
14281
 
14282
14282
  // packages/qwik-router/src/buildtime/vite/config.ts
14283
14283
  var import_vite = require("vite");
@@ -14296,7 +14296,7 @@ function extendConfig(baseConfigExport, serverConfigExport) {
14296
14296
  }
14297
14297
 
14298
14298
  // sw-reg:@qwik-router-sw-register-build
14299
- 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.")})([])';
14299
+ 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.")';
14300
14300
 
14301
14301
  // packages/qwik-router/src/buildtime/vite/plugin.ts
14302
14302
  var import_node_fs9 = __toESM(require("node:fs"), 1);
@@ -14306,17 +14306,11 @@ var import_vite2 = require("vite");
14306
14306
  // packages/qwik-router/src/middleware/request-handler/error-handler.ts
14307
14307
  var ServerError = class extends Error {
14308
14308
  constructor(status, data) {
14309
- super();
14309
+ super(typeof data === "string" ? data : void 0);
14310
14310
  this.status = status;
14311
14311
  this.data = data;
14312
14312
  }
14313
14313
  };
14314
- var ErrorResponse = class extends Error {
14315
- constructor(status, message) {
14316
- super(message);
14317
- this.status = status;
14318
- }
14319
- };
14320
14314
  function getErrorHtml(status, e) {
14321
14315
  let message = "Server Error";
14322
14316
  if (e != null) {
@@ -14681,8 +14675,7 @@ function createCacheControl(cacheControl) {
14681
14675
  cacheControl = {
14682
14676
  public: true,
14683
14677
  immutable: true,
14684
- maxAge: 60 * 60 * 24 * 365,
14685
- staleWhileRevalidate: 60 * 60 * 24 * 365
14678
+ maxAge: 60 * 60 * 24 * 365
14686
14679
  };
14687
14680
  } else if (cacheControl === "no-cache") {
14688
14681
  cacheControl = {
@@ -14692,8 +14685,7 @@ function createCacheControl(cacheControl) {
14692
14685
  if (typeof cacheControl === "number") {
14693
14686
  cacheControl = {
14694
14687
  maxAge: cacheControl,
14695
- sMaxAge: cacheControl,
14696
- staleWhileRevalidate: cacheControl
14688
+ sMaxAge: cacheControl
14697
14689
  };
14698
14690
  }
14699
14691
  if (cacheControl.immutable) {
@@ -14738,14 +14730,13 @@ import("node:async_hooks").then((module2) => {
14738
14730
  err
14739
14731
  );
14740
14732
  });
14741
- function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, manifest, trailingSlash = true, basePathname = "/", qwikSerializer) {
14733
+ function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, trailingSlash = true, basePathname = "/", qwikSerializer) {
14742
14734
  let resolve4;
14743
14735
  const responsePromise = new Promise((r2) => resolve4 = r2);
14744
14736
  const requestEv = createRequestEvent(
14745
14737
  serverRequestEv,
14746
14738
  loadedRoute,
14747
14739
  requestHandlers,
14748
- manifest,
14749
14740
  trailingSlash,
14750
14741
  basePathname,
14751
14742
  qwikSerializer,
@@ -14764,12 +14755,18 @@ async function runNext(requestEv, resolve4) {
14764
14755
  if (e instanceof RedirectMessage) {
14765
14756
  const stream = requestEv.getWritableStream();
14766
14757
  await stream.close();
14767
- } else if (e instanceof ErrorResponse) {
14768
- console.error(e);
14758
+ } else if (e instanceof ServerError) {
14769
14759
  if (!requestEv.headersSent) {
14770
- const html5 = getErrorHtml(e.status, e);
14771
14760
  const status = e.status;
14772
- requestEv.html(status, html5);
14761
+ const accept = requestEv.request.headers.get("Accept");
14762
+ if (accept && !accept.includes("text/html")) {
14763
+ const qwikSerializer = requestEv[RequestEvQwikSerializer];
14764
+ requestEv.headers.set("Content-Type", "application/qwik-json");
14765
+ requestEv.send(status, await qwikSerializer._serialize([e.data]));
14766
+ } else {
14767
+ const html5 = getErrorHtml(e.status, e.data);
14768
+ requestEv.html(status, html5);
14769
+ }
14773
14770
  }
14774
14771
  } else if (!(e instanceof AbortMessage)) {
14775
14772
  if (getRequestMode(requestEv) !== "dev") {
@@ -14822,7 +14819,7 @@ var RequestRouteName = "@routeName";
14822
14819
  var RequestEvSharedActionId = "@actionId";
14823
14820
  var RequestEvSharedActionFormData = "@actionFormData";
14824
14821
  var RequestEvSharedNonce = "@nonce";
14825
- function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manifest, trailingSlash, basePathname, qwikSerializer, resolved) {
14822
+ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trailingSlash, basePathname, qwikSerializer, resolved) {
14826
14823
  const { request, platform, env: env2 } = serverRequestEv;
14827
14824
  const sharedMap = /* @__PURE__ */ new Map();
14828
14825
  const cookie = new Cookie(request.headers.get("cookie"));
@@ -14835,7 +14832,6 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14835
14832
  }
14836
14833
  sharedMap.set(IsQData, true);
14837
14834
  }
14838
- sharedMap.set("@manifest", manifest);
14839
14835
  let routeModuleIndex = -1;
14840
14836
  let writableStream = null;
14841
14837
  let requestData = void 0;
@@ -14869,17 +14865,25 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14869
14865
  } else {
14870
14866
  status = statusOrResponse.status;
14871
14867
  statusOrResponse.headers.forEach((value2, key) => {
14868
+ if (key.toLowerCase() === "set-cookie") {
14869
+ return;
14870
+ }
14872
14871
  headers.append(key, value2);
14873
14872
  });
14873
+ statusOrResponse.headers.getSetCookie().forEach((ck) => {
14874
+ const index = ck.indexOf("=");
14875
+ if (index === -1) {
14876
+ return;
14877
+ }
14878
+ const key = ck.slice(0, index).trim();
14879
+ const value2 = ck.slice(index + 1).trim();
14880
+ cookie.set(key, value2);
14881
+ });
14874
14882
  if (statusOrResponse.body) {
14875
14883
  const writableStream2 = requestEv.getWritableStream();
14876
14884
  statusOrResponse.body.pipeTo(writableStream2);
14877
14885
  } else {
14878
- if (status >= 300 && status < 400) {
14879
- return new RedirectMessage();
14880
- } else {
14881
- requestEv.getWritableStream().getWriter().close();
14882
- }
14886
+ requestEv.getWritableStream().getWriter().close();
14883
14887
  }
14884
14888
  }
14885
14889
  return exit2();
@@ -14950,7 +14954,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
14950
14954
  },
14951
14955
  error: (statusCode, message) => {
14952
14956
  status = statusCode;
14953
- return new ErrorResponse(statusCode, message);
14957
+ return new ServerError(statusCode, message);
14954
14958
  },
14955
14959
  redirect: (statusCode, url2) => {
14956
14960
  check();
@@ -15051,7 +15055,7 @@ var parseRequest = async ({ request, method, query }, sharedMap, qwikSerializer)
15051
15055
  if (data) {
15052
15056
  try {
15053
15057
  return qwikSerializer._deserialize(decodeURIComponent(data));
15054
- } catch (err) {
15058
+ } catch {
15055
15059
  }
15056
15060
  }
15057
15061
  }
@@ -15365,13 +15369,9 @@ async function pureServerFunction(ev) {
15365
15369
  }
15366
15370
  } catch (err) {
15367
15371
  if (err instanceof ServerError) {
15368
- ev.headers.set("Content-Type", "application/qwik-json");
15369
- ev.send(err.status, await qwikSerializer._serialize([err.data]));
15370
- return;
15372
+ throw ev.error(err.status, err.data);
15371
15373
  }
15372
- ev.headers.set("Content-Type", "application/qwik-json");
15373
- ev.send(500, await qwikSerializer._serialize([err]));
15374
- return;
15374
+ throw ev.error(500, "Invalid request");
15375
15375
  }
15376
15376
  if (isAsyncIterator(result)) {
15377
15377
  ev.headers.set("Content-Type", "text/qwik-json-stream");
@@ -15491,10 +15491,10 @@ async function handleRedirect(requestEv) {
15491
15491
  return;
15492
15492
  }
15493
15493
  const status = requestEv.status();
15494
- const location2 = requestEv.headers.get("Location");
15495
- const isRedirect = status >= 301 && status <= 308 && location2;
15494
+ const location = requestEv.headers.get("Location");
15495
+ const isRedirect = status >= 301 && status <= 308 && location;
15496
15496
  if (isRedirect) {
15497
- const adaptedLocation = makeQDataPath(location2);
15497
+ const adaptedLocation = makeQDataPath(location);
15498
15498
  if (adaptedLocation) {
15499
15499
  requestEv.headers.set("Location", adaptedLocation);
15500
15500
  requestEv.getWritableStream().close();
@@ -15515,7 +15515,7 @@ async function renderQData(requestEv) {
15515
15515
  return;
15516
15516
  }
15517
15517
  const status = requestEv.status();
15518
- const location2 = requestEv.headers.get("Location");
15518
+ const location = requestEv.headers.get("Location");
15519
15519
  const trailingSlash = getRequestTrailingSlash(requestEv);
15520
15520
  const requestHeaders = {};
15521
15521
  requestEv.request.headers.forEach((value2, key) => requestHeaders[key] = value2);
@@ -15525,7 +15525,7 @@ async function renderQData(requestEv) {
15525
15525
  action: requestEv.sharedMap.get(RequestEvSharedActionId),
15526
15526
  status: status !== 200 ? status : 200,
15527
15527
  href: getPathname(requestEv.url, trailingSlash),
15528
- redirect: location2 ?? void 0
15528
+ redirect: location ?? void 0
15529
15529
  };
15530
15530
  const writer = requestEv.getWritableStream().getWriter();
15531
15531
  const qwikSerializer = requestEv[RequestEvQwikSerializer];
@@ -15562,7 +15562,7 @@ async function measure(requestEv, name, fn) {
15562
15562
  }
15563
15563
  function isContentType(headers, ...types) {
15564
15564
  var _a;
15565
- const type = ((_a = headers.get("content-type")) == null ? void 0 : _a.split(/;,/, 1)[0].trim()) ?? "";
15565
+ const type = ((_a = headers.get("content-type")) == null ? void 0 : _a.split(/;/, 1)[0].trim()) ?? "";
15566
15566
  return types.includes(type);
15567
15567
  }
15568
15568
 
@@ -25963,6 +25963,9 @@ async function createMdxTransformer(ctx) {
25963
25963
  const addImport = `import { jsx } from '@qwik.dev/core';
25964
25964
  `;
25965
25965
  const newDefault = `
25966
+ function _missingMdxReference(id, component, place) {
25967
+ 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 + "\`" : ""));
25968
+ }
25966
25969
  const WrappedMdxContent = () => {
25967
25970
  const content = _createMdxContent({});
25968
25971
  return typeof MDXLayout === 'function' ? jsx(MDXLayout, {children: content}) : content;
@@ -26177,130 +26180,6 @@ function generateServiceWorkerRegister(ctx, swRegister) {
26177
26180
  }
26178
26181
  return `export default ${JSON.stringify(swReg)};`;
26179
26182
  }
26180
- function prependManifestToServiceWorker(ctx, manifest, prefetch, swCode) {
26181
- const key = `/* Qwik Service Worker */`;
26182
- if (swCode.includes(key)) {
26183
- return null;
26184
- }
26185
- const appBundles = [];
26186
- const appBundlesCode = generateAppBundles(appBundles, manifest);
26187
- const libraryBundlesCode = generateLibraryBundles(appBundles, manifest);
26188
- const [linkBundlesCode] = generateLinkBundles(ctx, appBundles, manifest, prefetch);
26189
- return [key, appBundlesCode, libraryBundlesCode, linkBundlesCode, swCode].join("\n");
26190
- }
26191
- function generateAppBundles(appBundles, manifest) {
26192
- const sortedBundles = Object.keys(manifest.bundles).sort();
26193
- for (const appBundleName of sortedBundles) {
26194
- const appBundle = [appBundleName, []];
26195
- appBundles.push(appBundle);
26196
- const symbolHashesInBundle = [];
26197
- const manifestBundle = manifest.bundles[appBundleName];
26198
- const importedBundleNames = Array.isArray(manifestBundle.imports) ? manifestBundle.imports : [];
26199
- const depsSet = new Set(importedBundleNames);
26200
- for (const importedBundleName of importedBundleNames) {
26201
- clearTransitiveDeps(depsSet, /* @__PURE__ */ new Set(), importedBundleName);
26202
- }
26203
- appBundle[1] = Array.from(depsSet).map((dep) => sortedBundles.indexOf(dep));
26204
- if (manifestBundle.symbols) {
26205
- for (const manifestBundleSymbolName of manifestBundle.symbols) {
26206
- const symbol = manifest.symbols[manifestBundleSymbolName];
26207
- if ((symbol == null ? void 0 : symbol.hash) && !symbolHashesInBundle.includes(symbol.hash)) {
26208
- symbolHashesInBundle.push(symbol.hash);
26209
- }
26210
- }
26211
- }
26212
- if (symbolHashesInBundle.length > 0) {
26213
- appBundle[2] = symbolHashesInBundle;
26214
- }
26215
- }
26216
- function clearTransitiveDeps(deps, seen, depName) {
26217
- const childBundle = manifest.bundles[depName];
26218
- for (const childDepImport of childBundle.imports || []) {
26219
- if (deps.has(childDepImport)) {
26220
- deps.delete(childDepImport);
26221
- }
26222
- if (!seen.has(childDepImport)) {
26223
- seen.add(childDepImport);
26224
- clearTransitiveDeps(deps, seen, childDepImport);
26225
- }
26226
- }
26227
- }
26228
- return `const appBundles=${JSON.stringify(appBundles)};`;
26229
- }
26230
- function generateLibraryBundles(appBundles, manifest) {
26231
- const libraryBundleIds = [];
26232
- for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26233
- if (bundle.origins && bundle.origins.includes("@qwik-router-config")) {
26234
- libraryBundleIds.push(getAppBundleIndex(appBundles, bundleName));
26235
- break;
26236
- }
26237
- }
26238
- return `const libraryBundleIds=${JSON.stringify(libraryBundleIds)};`;
26239
- }
26240
- function generateLinkBundles(ctx, appBundles, manifest, prefetch) {
26241
- var _a, _b;
26242
- const linkBundles = [];
26243
- const symbolToBundle = /* @__PURE__ */ new Map();
26244
- const routeToBundles = {};
26245
- for (const bundleName in manifest.bundles || []) {
26246
- (_a = manifest.bundles[bundleName].symbols) == null ? void 0 : _a.forEach((symbol) => {
26247
- const idx = symbol.lastIndexOf("_");
26248
- symbolToBundle.set(idx === -1 ? symbol : symbol.substring(idx + 1), bundleName);
26249
- });
26250
- }
26251
- for (const r2 of ctx.routes) {
26252
- const linkBundleNames = [];
26253
- const addFileBundles = (filePath) => {
26254
- for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26255
- if (bundle.origins) {
26256
- for (const bundleOrigin of bundle.origins) {
26257
- const srcPath = removeExtension(filePath);
26258
- const bundleOriginPath = removeExtension(bundleOrigin);
26259
- if (srcPath.endsWith(bundleOriginPath)) {
26260
- if (!linkBundleNames.includes(bundleName)) {
26261
- linkBundleNames.push(bundleName);
26262
- }
26263
- if (bundle.dynamicImports) {
26264
- for (const dynamicImport of bundle.dynamicImports) {
26265
- if (!linkBundleNames.includes(dynamicImport)) {
26266
- linkBundleNames.push(dynamicImport);
26267
- }
26268
- }
26269
- }
26270
- }
26271
- }
26272
- }
26273
- }
26274
- };
26275
- for (const layout of r2.layouts) {
26276
- addFileBundles(layout.filePath);
26277
- }
26278
- addFileBundles(r2.filePath);
26279
- if (prefetch) {
26280
- const symbolsForRoute = prefetch.find((p) => p.route === r2.routeName);
26281
- (_b = symbolsForRoute == null ? void 0 : symbolsForRoute.symbols) == null ? void 0 : _b.reverse().forEach((symbol) => {
26282
- const bundle = symbolToBundle.get(symbol);
26283
- if (bundle) {
26284
- const idx = linkBundleNames.indexOf(bundle);
26285
- if (idx !== -1) {
26286
- linkBundleNames.splice(idx, 1);
26287
- }
26288
- linkBundleNames.unshift(bundle);
26289
- }
26290
- });
26291
- }
26292
- linkBundles.push(
26293
- `[${r2.pattern.toString()},${JSON.stringify(
26294
- linkBundleNames.map((bundleName) => getAppBundleIndex(appBundles, bundleName))
26295
- )}]`
26296
- );
26297
- routeToBundles[r2.routeName] = linkBundleNames;
26298
- }
26299
- return [`const linkBundles=[${linkBundles.join(",")}];`, routeToBundles];
26300
- }
26301
- function getAppBundleIndex(appBundles, bundleName) {
26302
- return appBundles.findIndex((b) => b[0] === bundleName);
26303
- }
26304
26183
  var SW_UNREGISTER = `
26305
26184
  navigator.serviceWorker?.getRegistrations().then((regs) => {
26306
26185
  for (const reg of regs) {
@@ -26531,6 +26410,16 @@ function generateCodeFrame(source, start = 0, end) {
26531
26410
  }
26532
26411
  return res.join("\n");
26533
26412
  }
26413
+ function parseId(originalId) {
26414
+ const [pathId, query] = originalId.split("?");
26415
+ const queryStr = query || "";
26416
+ return {
26417
+ originalId,
26418
+ pathId,
26419
+ query: queryStr ? `?${query}` : "",
26420
+ params: new URLSearchParams(queryStr)
26421
+ };
26422
+ }
26534
26423
 
26535
26424
  // packages/qwik-router/src/buildtime/vite/format-error.ts
26536
26425
  var import_node_fs5 = __toESM(require("node:fs"), 1);
@@ -26713,21 +26602,12 @@ function ssrDevMiddleware(ctx, server) {
26713
26602
  if (requestHandlers.length > 0) {
26714
26603
  const serverRequestEv = await fromNodeHttp(url, req, res, "dev");
26715
26604
  Object.assign(serverRequestEv.platform, ctx.opts.platform);
26716
- const manifest = {
26717
- manifestHash: "",
26718
- symbols: {},
26719
- mapping: {},
26720
- bundles: {},
26721
- injections: [],
26722
- version: "1"
26723
- };
26724
26605
  const { _deserialize, _serialize, _verifySerializable } = await server.ssrLoadModule("@qwik-serializer");
26725
26606
  const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
26726
26607
  const { completion, requestEv } = runQwikRouter(
26727
26608
  serverRequestEv,
26728
26609
  loadedRoute,
26729
26610
  requestHandlers,
26730
- manifest,
26731
26611
  ctx.opts.trailingSlash,
26732
26612
  ctx.opts.basePathname,
26733
26613
  qwikSerializer
@@ -26890,7 +26770,7 @@ function staticDistMiddleware({ config }) {
26890
26770
  import_node_fs6.default.createReadStream(filePath).pipe(res);
26891
26771
  return;
26892
26772
  }
26893
- } catch (e) {
26773
+ } catch {
26894
26774
  }
26895
26775
  }
26896
26776
  next();
@@ -26922,7 +26802,7 @@ function formatDevSerializeError(err, routeModulePaths) {
26922
26802
  if (line > -1) {
26923
26803
  err.loc.line = line + 1;
26924
26804
  }
26925
- } catch (e) {
26805
+ } catch {
26926
26806
  }
26927
26807
  }
26928
26808
  }
@@ -26986,29 +26866,55 @@ self.addEventListener('install', () => self.skipWaiting());
26986
26866
  self.addEventListener('activate', (ev) => ev.waitUntil(self.clients.claim()));
26987
26867
  `;
26988
26868
 
26869
+ // packages/qwik-router/src/buildtime/vite/get-route-imports.ts
26870
+ function getRouteImports(routes, manifest) {
26871
+ var _a, _b;
26872
+ const result = {};
26873
+ routes.forEach((route) => {
26874
+ const routePath = removeExtension(route.filePath);
26875
+ const layoutPaths = route.layouts ? route.layouts.map((layout) => removeExtension(layout.filePath)) : [];
26876
+ const routeAndLayoutPaths = [routePath, ...layoutPaths];
26877
+ const bundles = [];
26878
+ for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
26879
+ if (isBundlePartOfRoute(bundle, routeAndLayoutPaths)) {
26880
+ bundles.push(bundleName);
26881
+ }
26882
+ }
26883
+ if (bundles.length > 0) {
26884
+ result[route.routeName] = { dynamicImports: bundles };
26885
+ }
26886
+ });
26887
+ for (const bundleName of Object.keys(manifest.bundles)) {
26888
+ const bundle = manifest.bundles[bundleName];
26889
+ if ((_a = bundle.origins) == null ? void 0 : _a.some((s2) => s2.endsWith(QWIK_ROUTER_CONFIG_ID))) {
26890
+ result[bundleName] = {
26891
+ ...bundle,
26892
+ dynamicImports: (_b = bundle.dynamicImports) == null ? void 0 : _b.filter(
26893
+ (d) => {
26894
+ var _a2;
26895
+ return (_a2 = manifest.bundles[d].origins) == null ? void 0 : _a2.some((s2) => s2.endsWith("menu.md"));
26896
+ }
26897
+ )
26898
+ };
26899
+ break;
26900
+ }
26901
+ }
26902
+ return result;
26903
+ }
26904
+ function isBundlePartOfRoute(bundle, routeAndLayoutPaths) {
26905
+ if (!bundle.origins) {
26906
+ return false;
26907
+ }
26908
+ for (const bundleOrigin of bundle.origins) {
26909
+ const originPath = removeExtension(bundleOrigin);
26910
+ return routeAndLayoutPaths.some((path3) => path3.endsWith(originPath));
26911
+ }
26912
+ }
26913
+
26989
26914
  // packages/qwik-router/src/buildtime/vite/image-jsx.ts
26990
26915
  var import_node_fs7 = __toESM(require("node:fs"), 1);
26991
26916
  var import_node_path9 = __toESM(require("node:path"), 1);
26992
26917
  var import_svgo = require("svgo");
26993
-
26994
- // packages/qwik/src/optimizer/src/versions.ts
26995
- var versions = {
26996
- qwik: globalThis.QWIK_VERSION
26997
- };
26998
-
26999
- // packages/qwik/src/optimizer/src/plugins/plugin.ts
27000
- function parseId(originalId) {
27001
- const [pathId, query] = originalId.split("?");
27002
- const queryStr = query || "";
27003
- return {
27004
- originalId,
27005
- pathId,
27006
- query: queryStr ? `?${query}` : "",
27007
- params: new URLSearchParams(queryStr)
27008
- };
27009
- }
27010
-
27011
- // packages/qwik-router/src/buildtime/vite/image-jsx.ts
27012
26918
  function imagePlugin(userOpts) {
27013
26919
  const supportedExtensions = [".jpg", ".jpeg", ".png", ".webp", ".gif", ".avif", ".tiff"];
27014
26920
  return [
@@ -27041,7 +26947,7 @@ function imagePlugin(userOpts) {
27041
26947
  defaultDirectives: (url) => {
27042
26948
  var _a;
27043
26949
  if (url.searchParams.has("jsx")) {
27044
- const { jsx: jsx2, ...params } = Object.fromEntries(url.searchParams.entries());
26950
+ const { jsx: _2, ...params } = Object.fromEntries(url.searchParams.entries());
27045
26951
  return new URLSearchParams({
27046
26952
  format: "webp",
27047
26953
  quality: "75",
@@ -27265,7 +27171,7 @@ function qwikRouterPlugin(userOpts) {
27265
27171
  return updatedViteConfig;
27266
27172
  },
27267
27173
  async configResolved(config) {
27268
- var _a, _b, _c;
27174
+ var _a, _b, _c, _d, _e;
27269
27175
  Object.assign(process.env, (0, import_vite2.loadEnv)(config.mode, process.cwd(), ""));
27270
27176
  rootDir = (0, import_node_path11.resolve)(config.root);
27271
27177
  const target = ((_a = config.build) == null ? void 0 : _a.ssr) || config.mode === "ssr" ? "ssr" : "client";
@@ -27278,10 +27184,13 @@ function qwikRouterPlugin(userOpts) {
27278
27184
  if (!qwikPlugin) {
27279
27185
  throw new Error("Missing vite-plugin-qwik");
27280
27186
  }
27281
- if (((_b = config.ssr) == null ? void 0 : _b.format) === "cjs") {
27187
+ (_c = (_b = qwikPlugin.api).registerBundleGraphAdder) == null ? void 0 : _c.call(_b, (manifest) => {
27188
+ return getRouteImports(ctx.routes, manifest);
27189
+ });
27190
+ if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
27282
27191
  ssrFormat = "cjs";
27283
27192
  }
27284
- outDir = (_c = config.build) == null ? void 0 : _c.outDir;
27193
+ outDir = (_e = config.build) == null ? void 0 : _e.outDir;
27285
27194
  },
27286
27195
  configureServer(server) {
27287
27196
  return () => {
@@ -27423,34 +27332,7 @@ function qwikRouterPlugin(userOpts) {
27423
27332
  sequential: true,
27424
27333
  async handler() {
27425
27334
  if ((ctx == null ? void 0 : ctx.target) === "ssr" && !(ctx == null ? void 0 : ctx.isDevServer)) {
27426
- const manifest = qwikPlugin.api.getManifest();
27427
27335
  const clientOutDir = qwikPlugin.api.getClientOutDir();
27428
- if (manifest && clientOutDir) {
27429
- const basePathRelDir = api.getBasePathname().replace(/^\/|\/$/, "");
27430
- const clientOutBaseDir = (0, import_node_path11.join)(clientOutDir, basePathRelDir);
27431
- const insightsManifest = await qwikPlugin.api.getInsightsManifest(clientOutDir);
27432
- for (const swEntry of ctx.serviceWorkers) {
27433
- try {
27434
- const swClientDistPath = (0, import_node_path11.join)(clientOutBaseDir, swEntry.chunkFileName);
27435
- const swCode = await import_node_fs9.default.promises.readFile(swClientDistPath, "utf-8");
27436
- try {
27437
- const swCodeUpdate = prependManifestToServiceWorker(
27438
- ctx,
27439
- manifest,
27440
- (insightsManifest == null ? void 0 : insightsManifest.prefetch) || null,
27441
- swCode
27442
- );
27443
- if (swCodeUpdate) {
27444
- await import_node_fs9.default.promises.mkdir(clientOutDir, { recursive: true });
27445
- await import_node_fs9.default.promises.writeFile(swClientDistPath, swCodeUpdate);
27446
- }
27447
- } catch (e2) {
27448
- console.error(e2);
27449
- }
27450
- } catch (e) {
27451
- }
27452
- }
27453
- }
27454
27336
  if (outDir && clientOutDir) {
27455
27337
  const assetsDir = qwikPlugin.api.getAssetsDir();
27456
27338
  const { staticPathsCode, notFoundPathsCode } = await postBuild(