@rangojs/router 0.0.0-experimental.26 → 0.0.0-experimental.28
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.
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/router/revalidation.ts +27 -7
package/dist/vite/index.js
CHANGED
|
@@ -1745,7 +1745,7 @@ import { resolve } from "node:path";
|
|
|
1745
1745
|
// package.json
|
|
1746
1746
|
var package_default = {
|
|
1747
1747
|
name: "@rangojs/router",
|
|
1748
|
-
version: "0.0.0-experimental.
|
|
1748
|
+
version: "0.0.0-experimental.28",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
package/package.json
CHANGED
|
@@ -84,6 +84,7 @@ export async function evaluateRevalidation<TEnv>(
|
|
|
84
84
|
} = options;
|
|
85
85
|
const nextParams = segment.params || {};
|
|
86
86
|
const paramsChanged = !paramsEqual(nextParams, prevParams);
|
|
87
|
+
const searchChanged = prevUrl.search !== nextUrl.search;
|
|
87
88
|
|
|
88
89
|
// Trace helper: push a structured entry to the request-scoped trace buffer.
|
|
89
90
|
// Guarded by isTraceActive() so object construction is skipped in production.
|
|
@@ -134,19 +135,38 @@ export async function evaluateRevalidation<TEnv>(
|
|
|
134
135
|
// Only the route segment revalidates by default - all others require explicit opt-in
|
|
135
136
|
|
|
136
137
|
if (segment.type === "route") {
|
|
137
|
-
// Route segments revalidate when params change
|
|
138
|
-
//
|
|
139
|
-
|
|
138
|
+
// Route segments revalidate when path params OR search params change.
|
|
139
|
+
// Search params (e.g., ?page=2&sort=price) are server-parsed via ctx.search,
|
|
140
|
+
// so the handler must re-execute to produce updated content.
|
|
141
|
+
const routeChanged = paramsChanged || searchChanged;
|
|
142
|
+
defaultShouldRevalidate = routeChanged;
|
|
140
143
|
defaultReason = paramsChanged
|
|
141
144
|
? "nav:params-changed"
|
|
142
|
-
:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
: searchChanged
|
|
146
|
+
? "nav:search-changed"
|
|
147
|
+
: "nav:params-unchanged";
|
|
148
|
+
if (routeChanged) {
|
|
149
|
+
debugLog("revalidation", "route revalidating", {
|
|
145
150
|
segmentId: segment.id,
|
|
151
|
+
paramsChanged,
|
|
152
|
+
searchChanged,
|
|
146
153
|
});
|
|
147
154
|
}
|
|
155
|
+
} else if (segment.belongsToRoute && (paramsChanged || searchChanged)) {
|
|
156
|
+
// Children of the route path (loaders, orphan layouts/parallels)
|
|
157
|
+
// revalidate when path params or search params change
|
|
158
|
+
defaultShouldRevalidate = true;
|
|
159
|
+
defaultReason = paramsChanged
|
|
160
|
+
? "nav:route-child-params-changed"
|
|
161
|
+
: "nav:route-child-search-changed";
|
|
162
|
+
debugLog("revalidation", "route child revalidating", {
|
|
163
|
+
segmentId: segment.id,
|
|
164
|
+
segmentType: segment.type,
|
|
165
|
+
paramsChanged,
|
|
166
|
+
searchChanged,
|
|
167
|
+
});
|
|
148
168
|
} else {
|
|
149
|
-
//
|
|
169
|
+
// Parent layouts and parallels default to no revalidation
|
|
150
170
|
// Cannot assume these segments depend on params without explicit declaration
|
|
151
171
|
// Use custom revalidation functions to opt-in when needed
|
|
152
172
|
defaultShouldRevalidate = false;
|