@qwik.dev/router 2.0.0-rc.2 → 2.0.0-rc.3

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.
@@ -29,7 +29,7 @@ export declare interface NetlifyEdgeAdapterOptions extends ServerAdapterOptions
29
29
  * - /build/*
30
30
  * - /favicon.ico
31
31
  * - /robots.txt
32
- * - /mainifest.json
32
+ * - /manifest.json
33
33
  * - /~partytown/*
34
34
  * - /service-worker.js
35
35
  * - /sitemap.xml
@@ -31,7 +31,7 @@ function netlifyEdgeAdapter(opts = {}) {
31
31
  const excludedPath = [];
32
32
  if (typeof opts.excludedPath === "string") excludedPath.push(opts.excludedPath);
33
33
  else if (Array.isArray(opts.excludedPath)) excludedPath.push(...opts.excludedPath);
34
- else excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/mainifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
34
+ else excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/manifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
35
35
  const netlifyEdgeManifest = {
36
36
  functions: [{
37
37
  path: basePathname + "*",
@@ -1,9 +1,9 @@
1
1
  import { t as ensureSlash } from "./pathname.mjs";
2
2
  import { o as getLoaderName } from "./request-path.mjs";
3
3
  import { i as RedirectMessage, n as throwIfControlFlowSignal, t as ServerError } from "./server-error.mjs";
4
- import { r as unescapeStaticTrieKey, t as escapeStaticTrieKey } from "./route-trie-key.mjs";
4
+ import { n as isStaticTrieKey, r as unescapeStaticTrieKey, t as escapeStaticTrieKey } from "./route-trie-key.mjs";
5
5
  import { _capturesObj, createComputedQrl, createContextId, implicit$FirstArg, inlinedQrl, isBrowser, isDev, isServer, untrack, useServerData, withLocale } from "@qwik.dev/core";
6
- import { SerializerSymbol, _UNINITIALIZED, _deserialize, _getAsyncLocalStorage, _injectAsyncSignalValue, _markSignalAsExternallyOwned, _qwikSymbol, _registerSingleton, _resolveContextWithoutSequentialScope, _verifySerializable } from "@qwik.dev/core/internal";
6
+ import { SerializerSymbol, _deserialize, _getAsyncLocalStorage, _injectAsyncSignalValue, _markSignalAsExternallyOwned, _qwikSymbol, _registerSingleton, _resolveContextWithoutSequentialScope, _verifySerializable } from "@qwik.dev/core/internal";
7
7
  import { isServer as isServer$1 } from "@qwik.dev/core/build";
8
8
  var createRequestStore = () => {
9
9
  const AsyncLocalStorage = _getAsyncLocalStorage();
@@ -37,8 +37,40 @@ var DocumentHeadContext = /*#__PURE__*/ createContextId("qr-h");
37
37
  var RouteLocationContext = /*#__PURE__*/ createContextId("qr-l");
38
38
  var RouteNavigateContext = /*#__PURE__*/ createContextId("qr-n");
39
39
  var RouteActionContext = /*#__PURE__*/ createContextId("qr-a");
40
- var RoutePreventNavigateContext = /*#__PURE__*/ createContextId("qr-p");
40
+ var RouteActionRunnerContext = /*#__PURE__*/ createContextId("qr-ar");
41
41
  var HttpStatusContext = /*#__PURE__*/ createContextId("qr-hs");
42
+ /** Passed to the router's navigate function to run the action set on the action context. */
43
+ var RUN_PENDING_ACTION = Symbol();
44
+ /** Passed to the router's navigate function to re-resolve the document head. */
45
+ var REFRESH_HEAD = Symbol();
46
+ var preventNav = {};
47
+ var internalState = {
48
+ navCount: 0,
49
+ attemptCount: 0
50
+ };
51
+ var registerPreventNav = (fn$) => {
52
+ if (!isBrowser) return;
53
+ preventNav.$handler$ ||= (event) => {
54
+ internalState.attemptCount++;
55
+ if (!preventNav.$cbs$) return;
56
+ if ([...preventNav.$cbs$.values()].map((cb) => cb.resolved ? cb.resolved() : cb()).some(Boolean)) {
57
+ event.preventDefault();
58
+ event.returnValue = true;
59
+ }
60
+ };
61
+ (preventNav.$cbs$ ||= /* @__PURE__ */ new Set()).add(fn$);
62
+ fn$.resolve();
63
+ window.addEventListener("beforeunload", preventNav.$handler$);
64
+ return () => {
65
+ if (preventNav.$cbs$) {
66
+ preventNav.$cbs$.delete(fn$);
67
+ if (!preventNav.$cbs$.size) {
68
+ preventNav.$cbs$ = void 0;
69
+ window.removeEventListener("beforeunload", preventNav.$handler$);
70
+ }
71
+ }
72
+ };
73
+ };
42
74
  var holder = {};
43
75
  /** The config this router copy holds, else the one of the app serving the current request. */
44
76
  var findRouterConfig = () => holder.config ?? getServingRouterConfig();
@@ -113,7 +145,6 @@ var REQUEST_ROUTE_LOADERS = "@routeLoaders";
113
145
  var REQUEST_ROUTE_LOADER_PROMISES = "@routeLoaderPromises";
114
146
  var REQUEST_ROUTE_LOADER_EVENTS = "@routeLoaderEvents";
115
147
  var REQUEST_ROUTE_LOADER_ROOT_EVENT = "@routeLoaderRootEvent";
116
- var ROUTE_LOADER_VALUE_PREFIX = "__qwik_route_loader_value__";
117
148
  /** Header name sent by client to tell the server the actual page URL for loader requests. */
118
149
  var FULLPATH_HEADER = "X-Qwik-fullpath";
119
150
  /** Dev route hint that preserves the loader URL. */
@@ -124,6 +155,8 @@ var ROUTE_PATH_HEADER = "X-Qwik-route-path";
124
155
  * across navigations the browser HTTP cache is the freshness authority.
125
156
  */
126
157
  var navFetchCache = /* @__PURE__ */ new Map();
158
+ /** Entries a loader signal already used: they only dedupe prefetches, so `invalidate()` refetches. */
159
+ var signalFetches = /* @__PURE__ */ new WeakSet();
127
160
  var clearNavFetchCache = () => {
128
161
  navFetchCache = /* @__PURE__ */ new Map();
129
162
  };
@@ -176,7 +209,6 @@ function assertCurrentLoaderRequest(ctx, signal, request, abortSignal) {
176
209
  abortSignal.throwIfAborted();
177
210
  if (!request.active || clientRouteLoaders.get(ctx)?.current.requests.get(signal) !== request) throw new DOMException(isDev ? "Route loader navigation was superseded" : "", "AbortError");
178
211
  }
179
- var getRouteLoaderValueStateKey = (loaderId) => `${ROUTE_LOADER_VALUE_PREFIX}${loaderId}`;
180
212
  var ServerRouteLoaderCapture = class {
181
213
  hash;
182
214
  qrl;
@@ -227,7 +259,12 @@ var fetchRouteLoaderData = async (loaderId, routePath, manifestHash, opts) => {
227
259
  const cache = navFetchCache;
228
260
  if (!opts?.ignoreCache) {
229
261
  const entry = cache.get(cacheKey);
230
- if (entry) return opts?.signal ? wrapWithAbort(entry, opts.signal) : entry;
262
+ const signal = opts?.signal;
263
+ if (entry && !signal) return entry;
264
+ if (entry && signal && !signalFetches.has(entry)) {
265
+ signalFetches.add(entry);
266
+ return wrapWithAbort(entry, signal);
267
+ }
231
268
  }
232
269
  const request = async () => {
233
270
  opts?.signal?.throwIfAborted();
@@ -250,7 +287,11 @@ var fetchRouteLoaderData = async (loaderId, routePath, manifestHash, opts) => {
250
287
  if (opts?.ignoreCache) return request();
251
288
  if (opts?.signal) return request().then((value) => {
252
289
  opts.signal.throwIfAborted();
253
- if (value !== void 0 && !cache.has(cacheKey)) cache.set(cacheKey, Promise.resolve(value));
290
+ if (value !== void 0 && !cache.has(cacheKey)) {
291
+ const settled = Promise.resolve(value);
292
+ signalFetches.add(settled);
293
+ cache.set(cacheKey, settled);
294
+ }
254
295
  return value;
255
296
  });
256
297
  const promise = request().then((value) => {
@@ -265,16 +306,13 @@ var fetchRouteLoaderData = async (loaderId, routePath, manifestHash, opts) => {
265
306
  };
266
307
  var createRouteLoaderSignal = (loader, routeLoaderCtx, state, requestEv3) => {
267
308
  const id = loader.__id;
268
- const stateValues = state;
269
- const resumeValueKey = getRouteLoaderValueStateKey(id);
270
309
  const capture = isServer ? new ServerRouteLoaderCapture(id, loader.__qrl, loader.__validators, loader.__blockSSR, requestEv3 ?? useServerData("qwikrouter")?.ev) : id;
271
310
  const searchFilter = loader.__search;
272
311
  const loaderHash = isDev ? loader.__qrl.getHash() : id;
273
312
  const signal = createComputedQrl(/*#__PURE__*/ inlinedQrl(async (ctx) => {
274
- let capture = _capturesObj._[0], id = _capturesObj._[1], lastFetch = _capturesObj._[2], loaderHash = _capturesObj._[3], resumeValueKey = _capturesObj._[4], routeLoaderCtx = _capturesObj._[5], searchFilter = _capturesObj._[6], state = _capturesObj._[7], stateValues = _capturesObj._[8];
313
+ let capture = _capturesObj._[0], id = _capturesObj._[1], lastFetch = _capturesObj._[2], loaderHash = _capturesObj._[3], routeLoaderCtx = _capturesObj._[4], searchFilter = _capturesObj._[5], state = _capturesObj._[6];
275
314
  if (!!ctx.info && typeof ctx.info === "object" && "__v" in ctx.info) {
276
315
  const value = ctx.info.__v;
277
- if (!isServer && resumeValueKey in stateValues) stateValues[resumeValueKey] = value;
278
316
  lastFetch.raw = void 0;
279
317
  return value;
280
318
  }
@@ -290,7 +328,6 @@ var createRouteLoaderSignal = (loader, routeLoaderCtx, state, requestEv3) => {
290
328
  const pageUrl = new URL(request.pageUrl);
291
329
  const mHash = untrack(() => routeLoaderCtx.manifestHash) || "dev";
292
330
  const basePath = getBasePathname();
293
- const needsResumeFetch = stateValues[resumeValueKey] === _UNINITIALIZED;
294
331
  let fetchUrl = pageUrl;
295
332
  if (searchFilter) {
296
333
  fetchUrl = new URL(pageUrl.href);
@@ -320,18 +357,17 @@ var createRouteLoaderSignal = (loader, routeLoaderCtx, state, requestEv3) => {
320
357
  }
321
358
  if (response.e) throw response.e;
322
359
  lastFetch.raw = result.raw;
323
- if (needsResumeFetch) stateValues[resumeValueKey] = response.d;
360
+ const onValue = routeLoaderCtx.onValue;
361
+ if (onValue) Promise.resolve().then(() => state[id].promise()).then(() => onValue(REFRESH_HEAD));
324
362
  return response.d;
325
363
  }, "createRouteLoaderSignal_signal_createComputed_4s4ZDCYhDOA", [
326
364
  capture,
327
365
  id,
328
366
  {},
329
367
  loaderHash,
330
- resumeValueKey,
331
368
  routeLoaderCtx,
332
369
  searchFilter,
333
- state,
334
- stateValues
370
+ state
335
371
  ]), { serializationStrategy: loader.__serializationStrategy });
336
372
  _markSignalAsExternallyOwned(signal);
337
373
  return signal;
@@ -491,9 +527,7 @@ function prepareRouteLoaders(mods, state, ctx, paths, pageUrl, previousUrl, navC
491
527
  const client = getClientRouteLoaders(ctx, previousUrl.href);
492
528
  if (navigationKey && client.navigationKey === navigationKey) return ensureRouteLoaderSignals(mods, state, ctx);
493
529
  const previous = client.current;
494
- if (client.navCount === void 0) {
495
- for (const id in state) if (!id.startsWith(ROUTE_LOADER_VALUE_PREFIX)) getLoaderRequest(ctx, state, id, id);
496
- }
530
+ if (client.navCount === void 0) for (const id in state) getLoaderRequest(ctx, state, id, id);
497
531
  client.navCount = navCount;
498
532
  client.navigationKey = navigationKey;
499
533
  const current = client.current = {
@@ -508,7 +542,6 @@ function prepareRouteLoaders(mods, state, ctx, paths, pageUrl, previousUrl, navC
508
542
  current.paths[loader.__id] ||= current.paths[loader.__qrl.getHash()] || pageUrl.pathname;
509
543
  }
510
544
  for (const id in state) {
511
- if (id.startsWith(ROUTE_LOADER_VALUE_PREFIX)) continue;
512
545
  const signal = state[id];
513
546
  const old = previous.requests.get(signal);
514
547
  const loader = routeLoaders.get(id);
@@ -539,7 +572,6 @@ function pruneRouteLoaders(state, ctx) {
539
572
  const { requests } = clientRouteLoaders.get(ctx).current;
540
573
  const paths = {};
541
574
  for (const id in state) {
542
- if (id.startsWith(ROUTE_LOADER_VALUE_PREFIX)) continue;
543
575
  const signal = state[id];
544
576
  const request = requests.get(signal);
545
577
  if (request?.active) paths[id] = request.routePath;
@@ -547,7 +579,6 @@ function pruneRouteLoaders(state, ctx) {
547
579
  signal.$dispose();
548
580
  requests.delete(signal);
549
581
  delete state[id];
550
- delete state[getRouteLoaderValueStateKey(id)];
551
582
  }
552
583
  }
553
584
  ctx.loaderPaths = paths;
@@ -568,7 +599,6 @@ function restoreRouteLoaders(state, ctx, navCount) {
568
599
  }
569
600
  var ensureRouteLoaderSignal = (loader, state, routeLoaderCtx, requestEv12) => {
570
601
  if (loader.__cacheControl === "immutable") immutableLoaderIds.add(loader.__id);
571
- if (isServer && loader.__serializationStrategy === "never") state[getRouteLoaderValueStateKey(loader.__id)] = _UNINITIALIZED;
572
602
  return state[loader.__id] ||= createRouteLoaderSignal(loader, routeLoaderCtx, state, requestEv12);
573
603
  };
574
604
  var ensureRouteLoaderSignals = (mods, state, routeLoaderCtx, requestEv13) => {
@@ -1066,6 +1096,34 @@ function matchRestNode(node, parts, partIndex) {
1066
1096
  };
1067
1097
  }
1068
1098
  }
1099
+ /** Whether a `[...rest]` node has route segments below it, e.g. `[...path]/product/[id]`. */
1100
+ function hasChildSegments(node) {
1101
+ for (const key in node) if (key === "_W" || key === "_A" || key === "_M" || isStaticTrieKey(key)) return true;
1102
+ return false;
1103
+ }
1104
+ /**
1105
+ * Partial matches of a node's `[...rest]` child that leave segments for the routes below it, so
1106
+ * `[...path]/product/[id]` matches `/a/b/product/1` (path `a/b`) and `/product/1` (path empty). The
1107
+ * longest rest comes first, like a greedy `(.*)`. Without child segments there is nothing to leave
1108
+ * room for and `matchRestNode` alone applies.
1109
+ */
1110
+ function matchRestSpans(node, parts, partIndex) {
1111
+ const next = node._A;
1112
+ if (!next || !hasChildSegments(next)) return [];
1113
+ const paramName = next._P;
1114
+ const spans = [];
1115
+ for (let span = parts.length - partIndex - 1; span >= 0; span--) spans.push({
1116
+ next,
1117
+ groups: [],
1118
+ routePart: `[...${paramName}]`,
1119
+ done: false,
1120
+ kind: ChildMatchKind.Rest,
1121
+ paramName,
1122
+ paramValue: parts.slice(partIndex, partIndex + span).join("/"),
1123
+ span
1124
+ });
1125
+ return spans;
1126
+ }
1069
1127
  /**
1070
1128
  * Every child of `node` that could match `partLower`, in the same priority order `findChild` walks:
1071
1129
  * exact match → `_M` groups (recursively) → `_W` wildcard → `_A` rest wildcard.
@@ -1099,6 +1157,7 @@ function findChildAll(node, part, partLower, parts, partIndex) {
1099
1157
  ...wildcard,
1100
1158
  groups: []
1101
1159
  });
1160
+ candidates.push(...matchRestSpans(node, parts, partIndex));
1102
1161
  const rest = matchRestNode(node, parts, partIndex);
1103
1162
  if (rest) candidates.push({
1104
1163
  ...rest,
@@ -1116,6 +1175,7 @@ function findChildAll(node, part, partLower, parts, partIndex) {
1116
1175
  */
1117
1176
  function findMatchChain(node, parts, i, toBeat) {
1118
1177
  if (i === parts.length) return !toBeat && (findIndexNode(node) || findRestNode(node)) ? [] : void 0;
1178
+ if (toBeat && toBeat.length === 0) return;
1119
1179
  const part = parts[i];
1120
1180
  const candidates = findChildAll(node, part, part.toLowerCase(), parts, i).sort((a, b) => a.kind - b.kind);
1121
1181
  let best;
@@ -1124,12 +1184,12 @@ function findMatchChain(node, parts, i, toBeat) {
1124
1184
  const bound = best ?? toBeat;
1125
1185
  if (bound && found.kind > bound[0].kind) break;
1126
1186
  const tailToBeat = bound && found.kind === bound[0].kind ? bound.slice(1) : void 0;
1127
- const tail = found.done ? matchRestTail(found.next, tailToBeat) : findMatchChain(found.next, parts, i + 1, tailToBeat);
1187
+ const tail = found.done ? matchRestTail(found.next, tailToBeat) : findMatchChain(found.next, parts, i + (found.span ?? 1), tailToBeat);
1128
1188
  if (tail) best = [found, ...tail];
1129
1189
  }
1130
1190
  return best;
1131
1191
  }
1132
- /** A `[...rest]` match ends the chain; it only counts when it has a page and beats the bound. */
1192
+ /** A full `[...rest]` match ends the chain; it only counts when it has a page and beats the bound. */
1133
1193
  function matchRestTail(restNode, toBeat) {
1134
1194
  return !toBeat && isRouteNode(restNode) ? [] : void 0;
1135
1195
  }
@@ -1234,10 +1294,11 @@ function matchRouteTree(root = {}, pathname) {
1234
1294
  let i = 0;
1235
1295
  const len = parts.length;
1236
1296
  const chain = findMatchChain(root, parts, 0);
1237
- for (; !done && i < len; i++) {
1297
+ let chainIndex = 0;
1298
+ while (!done && i < len) {
1238
1299
  const part = parts[i];
1239
1300
  const partLower = part.toLowerCase();
1240
- const found = chain ? chain[i] : findChild(node, part, partLower, parts, i);
1301
+ const found = chain ? chain[chainIndex++] : findChild(node, part, partLower, parts, i);
1241
1302
  if (!found) {
1242
1303
  matched = false;
1243
1304
  break;
@@ -1263,12 +1324,15 @@ function matchRouteTree(root = {}, pathname) {
1263
1324
  routeParts.push(found.routePart);
1264
1325
  done = found.done;
1265
1326
  node = found.next;
1266
- const matchedPathname = `/${parts.slice(0, found.done ? len : i + 1).join("/")}/`;
1327
+ const span = found.span ?? 1;
1328
+ const matchedParts = parts.slice(0, found.done ? len : i + span);
1329
+ const matchedPathname = matchedParts.length ? `/${matchedParts.join("/")}/` : "/";
1267
1330
  collectNodeMeta(node, found.groups, layouts, errorLoaderRef, notFoundLoaderRef, menuLoaderRef, loaderPathsByHash, matchedPathname, loaderParamsByHash, { ...params });
1268
1331
  if (node._M) groupNodes.push({
1269
1332
  node,
1270
1333
  depth: layouts.length
1271
1334
  });
1335
+ i += span;
1272
1336
  }
1273
1337
  if (matched && !done && i === len) {
1274
1338
  if (!node._I && node._G == null) {
@@ -1567,4 +1631,4 @@ var createDocumentHead = (defaults, manifestHash) => ({
1567
1631
  frontmatter: { ...defaults?.frontmatter },
1568
1632
  manifestHash: manifestHash || "dev"
1569
1633
  });
1570
- export { RoutePreventNavigateContext as $, loadRouteLoader as A, _setRouterConfig as B, getRequestEvent as C, getRouteLoaderValues as D, getRouteLoaderResponse as E, routeLoader$ as F, ContentContext as G, getRouterConfig as H, routeLoaderQrl as I, HttpStatusContext as J, ContentInternalContext as K, setLoaderSignalValue as L, prepareRouteLoaders as M, resolveRouteLoaderByHash as N, getRouteLoaders as O, restoreRouteLoaders as P, RouteNavigateContext as Q, setRouteLoaders as R, getModuleRouteLoaders as S, getRouteLoaderParams as T, getRoutes as U, getBasePathname as V, getTrailingSlash as W, RouteLoaderCtxContext as X, RouteActionContext as Y, RouteLocationContext as Z, commitRouteLoaders as _, isPromise as a, RequestEvRouterConfig as at, getClientRouteLoaders as b, shouldPreload as c, loadRoute as d, RouteStateContext as et, FULLPATH_HEADER as f, clearRouteLoaderData as g, clearNavFetchCache as h, getClientNavPath as i, Q_ROUTE as it, matchesRouteLoaderId as j, isImmutableLoader as k, toPath as l, abortRouteLoaderNavigation as m, resolveHead as n, QDATA_KEY as nt, isSameOrigin as o, _asyncRequestStore as ot, ROUTE_PATH_HEADER as p, DocumentHeadContext as q, resolveRouteConfig as r, QFN_KEY as rt, isSamePath as s, createDocumentHead as t, QACTION_KEY as tt, toUrl as u, ensureRouteLoaderSignals as v, getRouteLoaderCtx as w, getLoaderRequestEvent as x, fetchRouteLoaderData as y, _getServiceWorkerUrl as z };
1634
+ export { HttpStatusContext as $, loadRouteLoader as A, _setRouterConfig as B, getRequestEvent as C, getRouteLoaderValues as D, getRouteLoaderResponse as E, routeLoader$ as F, REFRESH_HEAD as G, getRouterConfig as H, routeLoaderQrl as I, preventNav as J, RUN_PENDING_ACTION as K, setLoaderSignalValue as L, prepareRouteLoaders as M, resolveRouteLoaderByHash as N, getRouteLoaders as O, restoreRouteLoaders as P, DocumentHeadContext as Q, setRouteLoaders as R, getModuleRouteLoaders as S, getRouteLoaderParams as T, getRoutes as U, getBasePathname as V, getTrailingSlash as W, ContentContext as X, registerPreventNav as Y, ContentInternalContext as Z, commitRouteLoaders as _, isPromise as a, RouteStateContext as at, getClientRouteLoaders as b, shouldPreload as c, QFN_KEY as ct, loadRoute as d, _asyncRequestStore as dt, RouteActionContext as et, FULLPATH_HEADER as f, clearRouteLoaderData as g, clearNavFetchCache as h, getClientNavPath as i, RouteNavigateContext as it, matchesRouteLoaderId as j, isImmutableLoader as k, toPath as l, Q_ROUTE as lt, abortRouteLoaderNavigation as m, resolveHead as n, RouteLoaderCtxContext as nt, isSameOrigin as o, QACTION_KEY as ot, ROUTE_PATH_HEADER as p, internalState as q, resolveRouteConfig as r, RouteLocationContext as rt, isSamePath as s, QDATA_KEY as st, createDocumentHead as t, RouteActionRunnerContext as tt, toUrl as u, RequestEvRouterConfig as ut, ensureRouteLoaderSignals as v, getRouteLoaderCtx as w, getLoaderRequestEvent as x, fetchRouteLoaderData as y, _getServiceWorkerUrl as z };
@@ -1,5 +1,5 @@
1
1
  import { t as ensureSlash } from "./pathname.mjs";
2
- import { A as loadRouteLoader, D as getRouteLoaderValues, E as getRouteLoaderResponse, N as resolveRouteLoaderByHash, R as setRouteLoaders, T as getRouteLoaderParams, a as isPromise, at as RequestEvRouterConfig, f as FULLPATH_HEADER, g as clearRouteLoaderData, it as Q_ROUTE, j as matchesRouteLoaderId, nt as QDATA_KEY, ot as _asyncRequestStore, r as resolveRouteConfig, rt as QFN_KEY, tt as QACTION_KEY, w as getRouteLoaderCtx, x as getLoaderRequestEvent } from "./head.qwik.mjs";
2
+ import { A as loadRouteLoader, D as getRouteLoaderValues, E as getRouteLoaderResponse, N as resolveRouteLoaderByHash, R as setRouteLoaders, T as getRouteLoaderParams, a as isPromise, ct as QFN_KEY, dt as _asyncRequestStore, f as FULLPATH_HEADER, g as clearRouteLoaderData, j as matchesRouteLoaderId, lt as Q_ROUTE, ot as QACTION_KEY, r as resolveRouteConfig, st as QDATA_KEY, ut as RequestEvRouterConfig, w as getRouteLoaderCtx, x as getLoaderRequestEvent } from "./head.qwik.mjs";
3
3
  import { a as QLoaderId, c as resolveValidInternalFullPathname, i as QActionId, s as recognizeRequest, t as IsQAction, u as trimRecognizedInternalPathname } from "./request-path.mjs";
4
4
  import { a as shareClassIdentity, i as RedirectMessage, n as throwIfControlFlowSignal, r as AbortMessage, t as ServerError } from "./server-error.mjs";
5
5
  import { inlinedQrl, isDev } from "@qwik.dev/core";
@@ -79,14 +79,14 @@ function createCacheControl(cacheControl) {
79
79
  sMaxAge: cacheControl
80
80
  };
81
81
  if (cacheControl.immutable) controls.push("immutable");
82
- if (cacheControl.maxAge) controls.push(`max-age=${cacheControl.maxAge}`);
83
- if (cacheControl.sMaxAge) controls.push(`s-maxage=${cacheControl.sMaxAge}`);
82
+ if (cacheControl.maxAge !== void 0) controls.push(`max-age=${cacheControl.maxAge}`);
83
+ if (cacheControl.sMaxAge !== void 0) controls.push(`s-maxage=${cacheControl.sMaxAge}`);
84
84
  if (cacheControl.noStore) controls.push("no-store");
85
85
  if (cacheControl.noCache) controls.push("no-cache");
86
86
  if (cacheControl.private) controls.push("private");
87
87
  if (cacheControl.public) controls.push("public");
88
- if (cacheControl.staleWhileRevalidate) controls.push(`stale-while-revalidate=${cacheControl.staleWhileRevalidate}`);
89
- if (cacheControl.staleIfError) controls.push(`stale-if-error=${cacheControl.staleIfError}`);
88
+ if (cacheControl.staleWhileRevalidate !== void 0) controls.push(`stale-while-revalidate=${cacheControl.staleWhileRevalidate}`);
89
+ if (cacheControl.staleIfError !== void 0) controls.push(`stale-if-error=${cacheControl.staleIfError}`);
90
90
  return controls.join(", ");
91
91
  }
92
92
  var SAMESITE = {
@@ -352,7 +352,9 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, baseP
352
352
  exit,
353
353
  cacheControl: (cacheControl, target = "Cache-Control") => {
354
354
  check();
355
- headers.set(target, createCacheControl(cacheControl));
355
+ const directives = createCacheControl(cacheControl);
356
+ if (!directives) return;
357
+ headers.set(target, directives);
356
358
  },
357
359
  resolveValue: (async (loaderOrAction) => {
358
360
  if (loaderOrAction.__brand === "server_loader") {
package/lib/index.d.ts CHANGED
@@ -9,6 +9,7 @@ import { CookieOptions } from '@qwik.dev/router/middleware/request-handler';
9
9
  import { CookieValue } from '@qwik.dev/router/middleware/request-handler';
10
10
  import { DeferReturn } from '@qwik.dev/router/middleware/request-handler';
11
11
  import type { EnvGetter } from '@qwik.dev/router/middleware/request-handler';
12
+ import { EventHandler } from '@qwik.dev/core';
12
13
  import { InternalRequest } from '@qwik.dev/router/middleware/request-handler';
13
14
  import { JSXOutput } from '@qwik.dev/core';
14
15
  import { NoSerialize } from '@qwik.dev/core';
@@ -27,7 +28,6 @@ import { RequestHandler } from '@qwik.dev/router/middleware/request-handler';
27
28
  import type { ResolveSyncValue } from '@qwik.dev/router/middleware/request-handler';
28
29
  import type { SerializationStrategy } from '@qwik.dev/core/internal';
29
30
  import type { ServerError } from '@qwik.dev/router/middleware/request-handler';
30
- import type { Signal } from '@qwik.dev/core';
31
31
  import * as v from 'valibot';
32
32
  import { ValueOrPromise } from '@qwik.dev/core';
33
33
  import { ValueOrPromise as ValueOrPromise_2 } from '@qwik.dev/core/internal';
@@ -416,8 +416,11 @@ export declare interface FormProps<O, I> extends Omit<QwikJSX.IntrinsicElements[
416
416
  * Defaults to `false`
417
417
  */
418
418
  spaReset?: boolean;
419
- /** Event handler executed right after the action is executed successfully and returns some data. */
420
- onSubmitCompleted$?: QRLEventHandlerMulti<CustomEvent<FormSubmitSuccessDetail<O>>, HTMLFormElement> | undefined;
419
+ /**
420
+ * Event handler executed right after the action is executed successfully and returns some data.
421
+ * Like the native `on*$` events, it accepts an inline function as well as a QRL.
422
+ */
423
+ onSubmitCompleted$?: QRLEventHandlerMulti<CustomEvent<FormSubmitSuccessDetail<O>>, HTMLFormElement> | EventHandler<CustomEvent<FormSubmitSuccessDetail<O>>, HTMLFormElement> | undefined;
421
424
  key?: string | number | null;
422
425
  }
423
426
 
@@ -697,7 +700,8 @@ declare type LoaderOptions = {
697
700
  };
698
701
 
699
702
  /** @public */
700
- export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? Signal<ValueOrPromise<VALIDATOR>> : Signal<TYPE>) & Pick<ComputedSignal<any>, 'promise'>;
703
+ export declare interface LoaderSignal<TYPE> extends ComputedSignal<TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ValueOrPromise<VALIDATOR> : TYPE> {
704
+ }
701
705
 
702
706
  declare interface MenuModule {
703
707
  readonly default: ContentMenu;
@@ -1100,7 +1104,11 @@ export declare const routeLoader$: LoaderConstructor;
1100
1104
  declare type RouteLoaderCtx = {
1101
1105
  loaderPaths: Record<string, string | undefined>;
1102
1106
  /** SPA navigation function. Client-only and intentionally omitted from SSR state. */
1103
- goto?: NoSerialize<RouteNavigate>;
1107
+ goto?: NoSerialize<(path: string, options: {
1108
+ replaceState: boolean;
1109
+ }) => unknown>;
1110
+ /** Router callback that re-resolves the document head after a loader gets a new value. */
1111
+ onValue?: RouteNavigate;
1104
1112
  /** Client manifest hash for q-loader fetch URLs. */
1105
1113
  manifestHash?: string;
1106
1114
  };