@qwik.dev/router 2.0.0-beta.35 → 2.0.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { createQwikRouter as createQwikRouter$1 } from '@qwik.dev/router/middleware/node';
2
+ import { e as ensureSlash } from '../../chunks/pathname.mjs';
2
3
 
3
4
  function createQwikRouter(opts) {
4
5
  try {
@@ -22,7 +23,7 @@ function createQwikRouter(opts) {
22
23
  return pathT;
23
24
  }
24
25
  if (!url.pathname.endsWith("/")) {
25
- return url.pathname + "/" + url.search;
26
+ return ensureSlash(url.pathname) + url.search;
26
27
  }
27
28
  }
28
29
  return pathT;
@@ -10,7 +10,6 @@ import type { RenderOptions } from '@qwik.dev/core/server';
10
10
  import { RequestEvent as RequestEvent_2 } from '@qwik.dev/router/middleware/request-handler';
11
11
  import type { RequestHandler as RequestHandler_2 } from '@qwik.dev/router/middleware/request-handler';
12
12
  import type { ResolveSyncValue as ResolveSyncValue_2 } from '@qwik.dev/router/middleware/request-handler';
13
- import { SerializationStrategy } from '@qwik.dev/core/internal';
14
13
  import type { ValueOrPromise } from '@qwik.dev/core';
15
14
 
16
15
  /** @public */
@@ -92,15 +91,35 @@ declare interface CacheControlOptions {
92
91
  declare type CacheControlTarget = 'Cache-Control' | 'CDN-Cache-Control' | 'Cloudflare-CDN-Cache-Control' | 'Vercel-CDN-Cache-Control' | '~ANY-OTHER-STRING' | (string & {});
93
92
 
94
93
  /**
95
- * The cacheKey export type. When exported from a page module alongside eTag, enables in-memory SSR
96
- * caching.
94
+ * Cache key function. Used by `routeConfig.cacheKey` (SSR HTML cache) and by `routeLoader$`'s
95
+ * `cacheKey` option (per-loader JSON cache).
97
96
  *
98
- * - `true`: use the default cache key `status|eTag|pathname`
99
- * - Function: receives status, eTag, and pathname; returns a cache key string or null (no cache)
97
+ * - `true`: use the surface's default key.
98
+ *
99
+ * - SSR default: `${status}|${eTag}|${pathname}` when an eTag is set, otherwise
100
+ * `${status}|${pathname}`.
101
+ * - Loader default: `${pathname}|${filteredSearch}|${loaderId}|${eTag}` when an eTag is set,
102
+ * otherwise `${pathname}|${filteredSearch}|${loaderId}`.
103
+ * - Function: receives the request event and the normalized, unquoted eTag (or an empty string when
104
+ * none was provided). Return the cache key string, or `null` or `''` to skip caching for this
105
+ * request. Loader callbacks receive the loader-scoped request event, with `url`, `query`, and
106
+ * `request.url` filtered by the loader's `search` allowlist.
107
+ *
108
+ * Note: valid cacheKeys are non-empty strings.
100
109
  *
101
110
  * @public
102
111
  */
103
- declare type CacheKeyFn = true | ((status: number, eTag: string, pathname: string) => string | null);
112
+ declare type CacheKeyFn = true | ((requestEv: RequestEvent_2, eTag: string) => string | null);
113
+
114
+ /**
115
+ * Clear the in-memory loader cache. Call after deployments or data changes.
116
+ *
117
+ * When `cacheKey` is provided, only that single entry is removed; otherwise the entire cache is
118
+ * cleared.
119
+ *
120
+ * @public
121
+ */
122
+ export declare function clearLoaderCache(cacheKey?: string): void;
104
123
 
105
124
  /**
106
125
  * Clear the in-memory SSR cache. Call after deployments or data changes.
@@ -141,7 +160,18 @@ declare interface ContentMenu {
141
160
  declare type ContentModule = PageModule | LayoutModule;
142
161
 
143
162
  /**
144
- * The eTag export type: a static string or a function receiving DocumentHeadProps.
163
+ * The eTag export type for routeConfig.
164
+ *
165
+ * - `string` — static ETag value.
166
+ * - `(props: DocumentHeadProps) => string | null` — compute the ETag from route context (params, URL,
167
+ * loaded data via `resolveValue`, etc.). Return `null` to skip eTag for this request.
168
+ *
169
+ * Qwik normalizes eTag values by stripping weak-form `W/` prefixes, quotes, and forbidden chars,
170
+ * then sends a strong `ETag` header. Values that normalize to an empty string are treated as
171
+ * absent.
172
+ *
173
+ * When set (and a value is produced), the server includes an `ETag` header and returns `304` if
174
+ * `If-None-Match` matches.
145
175
  *
146
176
  * @public
147
177
  */
@@ -332,6 +362,13 @@ export declare function getNotFound(prefix: string): string;
332
362
  */
333
363
  declare type InformationalCode = 100 | 101 | 102 | 103;
334
364
 
365
+ /**
366
+ * Internal JSON request kind handled by Qwik Router, or `false` for normal page requests.
367
+ *
368
+ * @public
369
+ */
370
+ export declare type InternalRequest = false | 'loader' | 'action';
371
+
335
372
  /**
336
373
  * Decide whether a given request path is a static path, for optimizing file access.
337
374
  *
@@ -361,6 +398,10 @@ declare interface LoadedRoute {
361
398
  $notFound$?: boolean;
362
399
  /** The error module loader (nearest _E ancestor), for rendering ServerErrors */
363
400
  $errorLoader$?: ContentModuleLoader;
401
+ /** Merged array of routeLoader$ hashes from all matched nodes (layouts + page) */
402
+ $loaders$?: string[];
403
+ /** Runtime-only mapping of routeLoader$ hashes to the matched pathname used for q-loader fetches */
404
+ $loaderPaths$?: Record<string, string>;
364
405
  }
365
406
 
366
407
  /** @public */
@@ -464,6 +505,14 @@ export declare interface RequestEventBase<PLATFORM = QwikRouterPlatform> {
464
505
  readonly query: URLSearchParams;
465
506
  /** HTTP request URL. */
466
507
  readonly url: URL;
508
+ /**
509
+ * Identifies Qwik Router internal JSON requests, such as route loader fetches and fetch-based
510
+ * action submissions. Returns `false` for normal page requests.
511
+ *
512
+ * Check this before applying broad rewrite rules so internal JSON requests keep their routing
513
+ * behavior.
514
+ */
515
+ readonly internalRequest: InternalRequest;
467
516
  /**
468
517
  * The original HTTP request URL.
469
518
  *
@@ -582,8 +631,6 @@ export declare interface RequestEventCommon<PLATFORM = QwikRouterPlatform> exten
582
631
  }
583
632
 
584
633
  declare interface RequestEventInternal extends Readonly<RequestEvent>, Readonly<RequestEventLoader> {
585
- readonly [RequestEvLoaders]: Record<string, ValueOrPromise<unknown> | undefined>;
586
- readonly [RequestEvLoaderSerializationStrategyMap]: Map<string, SerializationStrategy>;
587
634
  readonly [RequestEvMode]: ServerRequestMode;
588
635
  readonly [RequestEvRoute]: LoadedRoute;
589
636
  /**
@@ -608,17 +655,10 @@ export declare interface RequestEventLoader<PLATFORM = QwikRouterPlatform> exten
608
655
  defer: <T>(returnData: Promise<T> | (() => Promise<T>)) => DeferReturn<T>;
609
656
  }
610
657
 
611
- declare const RequestEvLoaders: unique symbol;
612
-
613
- declare const RequestEvLoaderSerializationStrategyMap: unique symbol;
614
-
615
658
  declare const RequestEvMode: unique symbol;
616
659
 
617
660
  declare const RequestEvRoute: unique symbol;
618
661
 
619
- /** @internal */
620
- export declare const RequestEvShareQData = "qData";
621
-
622
662
  /** @public */
623
663
  export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: RequestEvent<PLATFORM>) => Promise<void> | void;
624
664