@rangojs/router 0.0.0-experimental.19 → 0.0.0-experimental.1fa245e2

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 (160) hide show
  1. package/{CLAUDE.md → AGENTS.md} +4 -0
  2. package/README.md +122 -30
  3. package/dist/bin/rango.js +245 -63
  4. package/dist/vite/index.js +859 -418
  5. package/package.json +3 -3
  6. package/skills/breadcrumbs/SKILL.md +250 -0
  7. package/skills/cache-guide/SKILL.md +32 -0
  8. package/skills/caching/SKILL.md +49 -8
  9. package/skills/document-cache/SKILL.md +2 -2
  10. package/skills/hooks/SKILL.md +33 -31
  11. package/skills/host-router/SKILL.md +218 -0
  12. package/skills/links/SKILL.md +3 -1
  13. package/skills/loader/SKILL.md +72 -22
  14. package/skills/middleware/SKILL.md +2 -0
  15. package/skills/parallel/SKILL.md +126 -0
  16. package/skills/prerender/SKILL.md +112 -70
  17. package/skills/rango/SKILL.md +0 -1
  18. package/skills/route/SKILL.md +34 -4
  19. package/skills/router-setup/SKILL.md +95 -5
  20. package/skills/typesafety/SKILL.md +35 -23
  21. package/src/__internal.ts +92 -0
  22. package/src/bin/rango.ts +18 -0
  23. package/src/browser/app-version.ts +14 -0
  24. package/src/browser/event-controller.ts +5 -0
  25. package/src/browser/link-interceptor.ts +4 -0
  26. package/src/browser/navigation-bridge.ts +114 -18
  27. package/src/browser/navigation-client.ts +126 -44
  28. package/src/browser/navigation-store.ts +43 -8
  29. package/src/browser/navigation-transaction.ts +11 -9
  30. package/src/browser/partial-update.ts +80 -15
  31. package/src/browser/prefetch/cache.ts +166 -27
  32. package/src/browser/prefetch/fetch.ts +52 -39
  33. package/src/browser/prefetch/policy.ts +6 -0
  34. package/src/browser/prefetch/queue.ts +92 -20
  35. package/src/browser/prefetch/resource-ready.ts +77 -0
  36. package/src/browser/react/Link.tsx +70 -14
  37. package/src/browser/react/NavigationProvider.tsx +40 -4
  38. package/src/browser/react/context.ts +7 -2
  39. package/src/browser/react/use-handle.ts +9 -58
  40. package/src/browser/react/use-router.ts +21 -8
  41. package/src/browser/rsc-router.tsx +143 -59
  42. package/src/browser/scroll-restoration.ts +41 -42
  43. package/src/browser/segment-reconciler.ts +6 -1
  44. package/src/browser/server-action-bridge.ts +454 -436
  45. package/src/browser/types.ts +60 -5
  46. package/src/build/generate-manifest.ts +6 -6
  47. package/src/build/generate-route-types.ts +5 -0
  48. package/src/build/route-trie.ts +19 -3
  49. package/src/build/route-types/include-resolution.ts +8 -1
  50. package/src/build/route-types/router-processing.ts +346 -87
  51. package/src/build/route-types/scan-filter.ts +8 -1
  52. package/src/cache/cache-runtime.ts +15 -11
  53. package/src/cache/cache-scope.ts +48 -7
  54. package/src/cache/cf/cf-cache-store.ts +453 -11
  55. package/src/cache/cf/index.ts +5 -1
  56. package/src/cache/document-cache.ts +17 -7
  57. package/src/cache/index.ts +1 -0
  58. package/src/cache/taint.ts +55 -0
  59. package/src/client.rsc.tsx +2 -1
  60. package/src/client.tsx +3 -102
  61. package/src/context-var.ts +72 -2
  62. package/src/debug.ts +2 -2
  63. package/src/handle.ts +40 -0
  64. package/src/handles/breadcrumbs.ts +66 -0
  65. package/src/handles/index.ts +1 -0
  66. package/src/host/index.ts +0 -3
  67. package/src/index.rsc.ts +8 -37
  68. package/src/index.ts +40 -66
  69. package/src/prerender/store.ts +57 -15
  70. package/src/prerender.ts +138 -77
  71. package/src/reverse.ts +22 -1
  72. package/src/route-definition/dsl-helpers.ts +73 -25
  73. package/src/route-definition/helpers-types.ts +10 -6
  74. package/src/route-definition/index.ts +3 -3
  75. package/src/route-definition/redirect.ts +11 -3
  76. package/src/route-definition/resolve-handler-use.ts +149 -0
  77. package/src/route-map-builder.ts +7 -1
  78. package/src/route-types.ts +11 -0
  79. package/src/router/content-negotiation.ts +100 -1
  80. package/src/router/find-match.ts +4 -2
  81. package/src/router/handler-context.ts +108 -25
  82. package/src/router/intercept-resolution.ts +11 -4
  83. package/src/router/lazy-includes.ts +4 -1
  84. package/src/router/loader-resolution.ts +123 -11
  85. package/src/router/logging.ts +5 -2
  86. package/src/router/manifest.ts +9 -3
  87. package/src/router/match-api.ts +125 -190
  88. package/src/router/match-middleware/background-revalidation.ts +30 -2
  89. package/src/router/match-middleware/cache-lookup.ts +88 -16
  90. package/src/router/match-middleware/cache-store.ts +53 -10
  91. package/src/router/match-middleware/intercept-resolution.ts +9 -7
  92. package/src/router/match-middleware/segment-resolution.ts +61 -5
  93. package/src/router/match-result.ts +22 -15
  94. package/src/router/metrics.ts +238 -13
  95. package/src/router/middleware-types.ts +53 -12
  96. package/src/router/middleware.ts +172 -85
  97. package/src/router/navigation-snapshot.ts +182 -0
  98. package/src/router/pattern-matching.ts +20 -5
  99. package/src/router/prerender-match.ts +114 -10
  100. package/src/router/preview-match.ts +30 -102
  101. package/src/router/request-classification.ts +310 -0
  102. package/src/router/revalidation.ts +27 -7
  103. package/src/router/route-snapshot.ts +245 -0
  104. package/src/router/router-context.ts +6 -1
  105. package/src/router/router-interfaces.ts +50 -5
  106. package/src/router/router-options.ts +50 -19
  107. package/src/router/segment-resolution/fresh.ts +200 -19
  108. package/src/router/segment-resolution/helpers.ts +30 -25
  109. package/src/router/segment-resolution/loader-cache.ts +1 -0
  110. package/src/router/segment-resolution/revalidation.ts +429 -301
  111. package/src/router/segment-wrappers.ts +2 -0
  112. package/src/router/trie-matching.ts +20 -2
  113. package/src/router/types.ts +1 -0
  114. package/src/router.ts +88 -15
  115. package/src/rsc/handler.ts +546 -359
  116. package/src/rsc/index.ts +0 -20
  117. package/src/rsc/manifest-init.ts +5 -1
  118. package/src/rsc/progressive-enhancement.ts +25 -8
  119. package/src/rsc/rsc-rendering.ts +35 -43
  120. package/src/rsc/server-action.ts +16 -10
  121. package/src/rsc/ssr-setup.ts +128 -0
  122. package/src/rsc/types.ts +10 -1
  123. package/src/search-params.ts +16 -13
  124. package/src/segment-system.tsx +140 -4
  125. package/src/server/context.ts +148 -16
  126. package/src/server/loader-registry.ts +9 -8
  127. package/src/server/request-context.ts +182 -34
  128. package/src/server.ts +6 -0
  129. package/src/ssr/index.tsx +4 -0
  130. package/src/static-handler.ts +18 -6
  131. package/src/theme/index.ts +4 -13
  132. package/src/types/cache-types.ts +4 -4
  133. package/src/types/handler-context.ts +149 -49
  134. package/src/types/loader-types.ts +36 -9
  135. package/src/types/route-config.ts +17 -8
  136. package/src/types/route-entry.ts +8 -1
  137. package/src/types/segments.ts +2 -5
  138. package/src/urls/path-helper-types.ts +9 -2
  139. package/src/urls/path-helper.ts +48 -13
  140. package/src/urls/pattern-types.ts +12 -0
  141. package/src/urls/response-types.ts +16 -6
  142. package/src/use-loader.tsx +73 -4
  143. package/src/vite/discovery/bundle-postprocess.ts +61 -89
  144. package/src/vite/discovery/discover-routers.ts +23 -5
  145. package/src/vite/discovery/prerender-collection.ts +48 -15
  146. package/src/vite/discovery/state.ts +17 -13
  147. package/src/vite/index.ts +8 -3
  148. package/src/vite/plugin-types.ts +51 -79
  149. package/src/vite/plugins/client-ref-dedup.ts +115 -0
  150. package/src/vite/plugins/expose-action-id.ts +1 -3
  151. package/src/vite/plugins/performance-tracks.ts +88 -0
  152. package/src/vite/plugins/refresh-cmd.ts +127 -0
  153. package/src/vite/plugins/version-plugin.ts +13 -1
  154. package/src/vite/rango.ts +174 -211
  155. package/src/vite/router-discovery.ts +169 -42
  156. package/src/vite/utils/banner.ts +3 -3
  157. package/src/vite/utils/prerender-utils.ts +78 -0
  158. package/src/vite/utils/shared-utils.ts +3 -2
  159. package/skills/testing/SKILL.md +0 -226
  160. package/src/route-definition/route-function.ts +0 -119
@@ -4,24 +4,217 @@
4
4
  * Performance metrics collection and reporting for RSC Router.
5
5
  */
6
6
 
7
- import type { MetricsStore } from "../server/context";
7
+ import type { MetricsStore, PerformanceMetric } from "../server/context";
8
+
9
+ const BASE_INDENT = 2;
10
+ const DEPTH_INDENT = 2;
11
+ const TIMELINE_WIDTH = 40;
12
+
13
+ function formatMs(value: number): string {
14
+ return `${value.toFixed(2)}ms`;
15
+ }
16
+
17
+ function sortMetrics(metrics: PerformanceMetric[]): PerformanceMetric[] {
18
+ return [...metrics].sort((a, b) => {
19
+ // handler:total always goes last (it wraps everything)
20
+ if (a.label === "handler:total") return 1;
21
+ if (b.label === "handler:total") return -1;
22
+ return a.startTime - b.startTime;
23
+ });
24
+ }
25
+
26
+ interface Span {
27
+ startTime: number;
28
+ duration: number;
29
+ }
30
+
31
+ function renderTimeline(spans: Span[], total: number): string {
32
+ if (TIMELINE_WIDTH <= 0) {
33
+ return "||";
34
+ }
35
+
36
+ const cells = Array(TIMELINE_WIDTH).fill(".");
37
+
38
+ if (!(total > 0)) {
39
+ cells[0] = "#";
40
+ return `|${cells.join("")}|`;
41
+ }
42
+
43
+ for (const span of spans) {
44
+ const start = Math.max(0, span.startTime);
45
+ const end = Math.max(start, span.startTime + span.duration);
46
+ const startColumn = Math.min(
47
+ TIMELINE_WIDTH - 1,
48
+ Math.floor((start / total) * TIMELINE_WIDTH),
49
+ );
50
+ const endColumn = Math.max(
51
+ startColumn + 1,
52
+ Math.min(
53
+ TIMELINE_WIDTH,
54
+ Math.ceil((Math.min(total, end) / total) * TIMELINE_WIDTH),
55
+ ),
56
+ );
57
+
58
+ cells.fill("#", startColumn, endColumn);
59
+ }
60
+
61
+ return `|${cells.join("")}|`;
62
+ }
63
+
64
+ function createTimelineAxis(total: number): string {
65
+ const totalLabel = formatMs(total);
66
+ return `0ms${" ".repeat(
67
+ Math.max(1, TIMELINE_WIDTH - "0ms".length - totalLabel.length),
68
+ )}${totalLabel}`;
69
+ }
8
70
 
9
71
  /**
10
- * Create a metrics store for the request if debugPerformance is enabled
72
+ * Create a metrics store for the request if debugPerformance is enabled.
73
+ * An optional `requestStart` timestamp can anchor the store to an earlier
74
+ * point (e.g. handler start) so that handler:total has startTime=0.
11
75
  */
12
76
  export function createMetricsStore(
13
77
  debugPerformance: boolean,
78
+ requestStart?: number,
14
79
  ): MetricsStore | undefined {
15
80
  if (!debugPerformance) return undefined;
16
81
  return {
17
82
  enabled: true,
18
- requestStart: performance.now(),
83
+ requestStart: requestStart ?? performance.now(),
19
84
  metrics: [],
20
85
  };
21
86
  }
22
87
 
23
88
  /**
24
- * Log metrics to console in a formatted way
89
+ * Append a metric to the request store using an absolute start timestamp.
90
+ */
91
+ export function appendMetric(
92
+ metricsStore: MetricsStore | undefined,
93
+ label: string,
94
+ start: number,
95
+ duration: number,
96
+ depth?: number,
97
+ ): void {
98
+ if (!metricsStore) return;
99
+ metricsStore.metrics.push({
100
+ label,
101
+ duration,
102
+ startTime: start - metricsStore.requestStart,
103
+ depth,
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Log the current request metrics and return the corresponding Server-Timing value.
109
+ */
110
+ export function buildMetricsTiming(
111
+ method: string,
112
+ pathname: string,
113
+ metricsStore: MetricsStore | undefined,
114
+ ): string | undefined {
115
+ if (!metricsStore) return undefined;
116
+ logMetrics(method, pathname, metricsStore);
117
+ return generateServerTiming(metricsStore) || undefined;
118
+ }
119
+
120
+ /** Display row produced by merging :pre/:post metric pairs. */
121
+ interface DisplayRow {
122
+ label: string;
123
+ startTime: number;
124
+ duration: number;
125
+ depth: number | undefined;
126
+ spans: Span[];
127
+ }
128
+
129
+ /**
130
+ * Build display rows from sorted metrics, merging :pre/:post pairs into
131
+ * a single row with disjoint timeline segments.
132
+ */
133
+ function buildDisplayRows(sorted: PerformanceMetric[]): DisplayRow[] {
134
+ // Index :pre and :post metrics by their base label
135
+ const preMap = new Map<string, PerformanceMetric>();
136
+ const postMap = new Map<string, PerformanceMetric>();
137
+ const consumed = new Set<PerformanceMetric>();
138
+
139
+ for (const m of sorted) {
140
+ if (m.label.endsWith(":pre")) {
141
+ preMap.set(m.label.slice(0, -4), m);
142
+ } else if (m.label.endsWith(":post")) {
143
+ postMap.set(m.label.slice(0, -5), m);
144
+ }
145
+ }
146
+
147
+ const rows: DisplayRow[] = [];
148
+
149
+ for (const m of sorted) {
150
+ if (consumed.has(m)) continue;
151
+
152
+ if (m.label.endsWith(":pre")) {
153
+ const base = m.label.slice(0, -4);
154
+ const post = postMap.get(base);
155
+ if (post) {
156
+ // Merge into a single row with two disjoint spans
157
+ consumed.add(m);
158
+ consumed.add(post);
159
+ rows.push({
160
+ label: base,
161
+ startTime: m.startTime,
162
+ duration: m.duration + post.duration,
163
+ depth: m.depth,
164
+ spans: [
165
+ { startTime: m.startTime, duration: m.duration },
166
+ { startTime: post.startTime, duration: post.duration },
167
+ ],
168
+ });
169
+ continue;
170
+ }
171
+ // Lone :pre — display with base label
172
+ consumed.add(m);
173
+ rows.push({
174
+ label: base,
175
+ startTime: m.startTime,
176
+ duration: m.duration,
177
+ depth: m.depth,
178
+ spans: [{ startTime: m.startTime, duration: m.duration }],
179
+ });
180
+ continue;
181
+ }
182
+
183
+ if (m.label.endsWith(":post")) {
184
+ const base = m.label.slice(0, -5);
185
+ if (preMap.has(base)) {
186
+ // Already consumed as part of the pair above
187
+ continue;
188
+ }
189
+ // Lone :post — display with base label
190
+ consumed.add(m);
191
+ rows.push({
192
+ label: base,
193
+ startTime: m.startTime,
194
+ duration: m.duration,
195
+ depth: m.depth,
196
+ spans: [{ startTime: m.startTime, duration: m.duration }],
197
+ });
198
+ continue;
199
+ }
200
+
201
+ // Regular metric
202
+ rows.push({
203
+ label: m.label,
204
+ startTime: m.startTime,
205
+ duration: m.duration,
206
+ depth: m.depth,
207
+ spans: [{ startTime: m.startTime, duration: m.duration }],
208
+ });
209
+ }
210
+
211
+ return rows;
212
+ }
213
+
214
+ /**
215
+ * Log metrics to console in a formatted way.
216
+ * Uses a shared-axis timeline so overlapping work stays visible.
217
+ * Merges :pre/:post pairs onto one row with disjoint timeline segments.
25
218
  */
26
219
  export function logMetrics(
27
220
  method: string,
@@ -30,32 +223,64 @@ export function logMetrics(
30
223
  ): void {
31
224
  const total = performance.now() - metricsStore.requestStart;
32
225
 
33
- // Find max label length for alignment
34
- const maxLabelLen = Math.max(
35
- ...metricsStore.metrics.map((m) => m.label.length),
36
- 20,
226
+ const sorted = sortMetrics(metricsStore.metrics);
227
+ const displayRows = buildDisplayRows(sorted);
228
+
229
+ const labels = displayRows.map(
230
+ (r) =>
231
+ `${" ".repeat(BASE_INDENT + (r.depth ?? 0) * DEPTH_INDENT)}${r.label}`,
232
+ );
233
+ const startValues = displayRows.map((r) => formatMs(r.startTime));
234
+ const durationValues = displayRows.map((r) => formatMs(r.duration));
235
+ const startWidth = Math.max(
236
+ "start".length,
237
+ ...startValues.map((v) => v.length),
238
+ );
239
+ const durationWidth = Math.max(
240
+ "dur".length,
241
+ ...durationValues.map((v) => v.length),
242
+ );
243
+ const spanWidth = Math.max(
244
+ "span".length,
245
+ ...labels.map((label) => label.length),
246
+ 22,
247
+ );
248
+ const timelinePadding = " ".repeat(
249
+ startWidth + 2 + durationWidth + 2 + spanWidth + 2,
250
+ );
251
+
252
+ console.log(`[RSC Perf] ${method} ${pathname} (${total.toFixed(2)}ms)`);
253
+ console.log(
254
+ `${"start".padStart(startWidth)} ${"dur".padStart(durationWidth)} ${"span".padEnd(spanWidth)} timeline`,
37
255
  );
256
+ console.log(`${timelinePadding}${createTimelineAxis(total)}`);
38
257
 
39
- console.log(`[RSC Perf] ${method} ${pathname} (${total.toFixed(1)}ms)`);
258
+ for (let index = 0; index < displayRows.length; index++) {
259
+ const row = displayRows[index];
260
+ const label = labels[index].padEnd(spanWidth);
261
+ const start = formatMs(row.startTime).padStart(startWidth);
262
+ const duration = formatMs(row.duration).padStart(durationWidth);
40
263
 
41
- for (const m of metricsStore.metrics) {
42
- const paddedLabel = m.label.padEnd(maxLabelLen);
43
- console.log(` ${paddedLabel} ${m.duration.toFixed(1)}ms`);
264
+ console.log(
265
+ `${start} ${duration} ${label} ${renderTimeline(row.spans, total)}`,
266
+ );
44
267
  }
45
268
  }
46
269
 
47
270
  /**
48
271
  * Generate Server-Timing header value from metrics
49
272
  * Format: metric-name;dur=X.XX
273
+ * Depth is encoded as a "d{N}-" prefix for nested metrics.
50
274
  */
51
275
  export function generateServerTiming(metricsStore: MetricsStore): string {
52
276
  return metricsStore.metrics
53
277
  .map((m) => {
54
278
  // Convert label to valid Server-Timing name (alphanumeric and hyphens)
55
- const name = m.label
279
+ const base = m.label
56
280
  .replace(/:/g, "-")
57
281
  .replace(/[^a-zA-Z0-9-]/g, "")
58
282
  .toLowerCase();
283
+ const name = m.depth ? `d${m.depth}-${base}` : base;
59
284
  return `${name};dur=${m.duration.toFixed(2)}`;
60
285
  })
61
286
  .join(", ");
@@ -12,6 +12,8 @@ import type {
12
12
  DefaultVars,
13
13
  } from "../types/global-namespace.js";
14
14
  import type { ScopedReverseFunction } from "../reverse.js";
15
+ import type { Theme } from "../theme/types.js";
16
+ import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
15
17
 
16
18
  /**
17
19
  * Get variable function type
@@ -25,8 +27,12 @@ type GetVariableFn = {
25
27
  * Set variable function type
26
28
  */
27
29
  type SetVariableFn = {
28
- <T>(contextVar: ContextVar<T>, value: T): void;
29
- <K extends keyof DefaultVars>(key: K, value: DefaultVars[K]): void;
30
+ <T>(contextVar: ContextVar<T>, value: T, options?: { cache?: boolean }): void;
31
+ <K extends keyof DefaultVars>(
32
+ key: K,
33
+ value: DefaultVars[K],
34
+ options?: { cache?: boolean },
35
+ ): void;
30
36
  };
31
37
 
32
38
  /**
@@ -55,9 +61,15 @@ export interface MiddlewareContext<
55
61
  /** Original request */
56
62
  request: Request;
57
63
 
58
- /** Parsed URL */
64
+ /** Parsed URL (with internal `_rsc*` params stripped) */
59
65
  url: URL;
60
66
 
67
+ /**
68
+ * The original request URL with all parameters intact, including
69
+ * internal `_rsc*` transport params.
70
+ */
71
+ originalUrl: URL;
72
+
61
73
  /** URL pathname */
62
74
  pathname: string;
63
75
 
@@ -71,13 +83,11 @@ export interface MiddlewareContext<
71
83
  params: TParams;
72
84
 
73
85
  /**
74
- * Response stub (read-only). Before `next()`, returns the shared response stub
75
- * where headers and cookies accumulate. After `next()`, returns the downstream response.
76
- *
77
- * Use `ctx.header()` to set response headers, or `cookies()` for cookie mutations.
78
- * To replace the response entirely, return a new `Response` from the middleware.
86
+ * Response headers.
87
+ * Before `next()`, returns headers from the shared response stub.
88
+ * After `next()`, returns headers from the downstream response.
79
89
  */
80
- readonly res: Response;
90
+ readonly headers: Headers;
81
91
 
82
92
  /** Get a context variable (shared with route handlers) */
83
93
  get: GetVariableFn;
@@ -86,11 +96,10 @@ export interface MiddlewareContext<
86
96
  set: SetVariableFn;
87
97
 
88
98
  /**
89
- * Set a response header - can be called before or after `next()`
99
+ * Set a response header - can be called before or after `next()`.
90
100
  *
91
101
  * When called before `next()`, headers are queued and merged into the final response.
92
102
  * When called after `next()`, headers are set directly on the response.
93
- * Shorthand for `ctx.res.headers.set()`.
94
103
  */
95
104
  header(name: string, value: string): void;
96
105
 
@@ -100,6 +109,38 @@ export interface MiddlewareContext<
100
109
  */
101
110
  routeName?: DefaultRouteName;
102
111
 
112
+ /**
113
+ * Enable performance metrics for this request.
114
+ * When called, granular timing breakdown is logged to console and
115
+ * included in the Server-Timing response header, regardless of the
116
+ * router-level `debugPerformance` option.
117
+ *
118
+ * Call **before** `await next()` so the metrics store exists when
119
+ * downstream phases (route matching, rendering, SSR) record their
120
+ * spans. Calling after `next()` returns still emits `handler:total`
121
+ * but misses all upstream metrics.
122
+ */
123
+ debugPerformance(): void;
124
+
125
+ /**
126
+ * Current theme (from cookie or default).
127
+ * Only available when theme is enabled in router config.
128
+ */
129
+ theme?: Theme;
130
+
131
+ /**
132
+ * Set the theme (only available when theme is enabled in router config).
133
+ * Sets a cookie with the new theme value.
134
+ */
135
+ setTheme?: (theme: Theme) => void;
136
+
137
+ /**
138
+ * Attach location state entries to this response.
139
+ * State is delivered to the client via history.pushState and accessible
140
+ * through the useLocationState() hook.
141
+ */
142
+ setLocationState(entries: LocationStateEntry | LocationStateEntry[]): void;
143
+
103
144
  /**
104
145
  * Generate URLs from route names.
105
146
  * - `name` — global route, from the named-routes definition
@@ -155,7 +196,7 @@ export interface MiddlewareEntry<TEnv = any> {
155
196
  }
156
197
 
157
198
  /**
158
- * Mutable response holder - allows ctx.res to be updated after next() is called
199
+ * Mutable response holder - tracks the current response through the middleware chain.
159
200
  */
160
201
  export interface ResponseHolder {
161
202
  response: Response | null;