@rangojs/router 0.0.0-experimental.91 → 0.0.0-experimental.92
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
CHANGED
|
@@ -2040,7 +2040,7 @@ import { resolve } from "node:path";
|
|
|
2040
2040
|
// package.json
|
|
2041
2041
|
var package_default = {
|
|
2042
2042
|
name: "@rangojs/router",
|
|
2043
|
-
version: "0.0.0-experimental.
|
|
2043
|
+
version: "0.0.0-experimental.92",
|
|
2044
2044
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
2045
2045
|
keywords: [
|
|
2046
2046
|
"react",
|
package/package.json
CHANGED
package/skills/loader/SKILL.md
CHANGED
|
@@ -248,6 +248,37 @@ path("/product/:slug", ProductPage, { name: "product" }, () => [
|
|
|
248
248
|
]);
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
+
### `revalidate()` return shapes
|
|
252
|
+
|
|
253
|
+
A `revalidate(fn)` callback can return one of four shapes. The chain
|
|
254
|
+
processes revalidators in order; each call's return controls how the
|
|
255
|
+
chain continues:
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
// 1) Hard decision — short-circuits the chain, used as the final answer.
|
|
259
|
+
revalidate(() => true);
|
|
260
|
+
revalidate(({ actionId }) => actionId?.includes("Cart") ?? false);
|
|
261
|
+
|
|
262
|
+
// 2) Soft decision — updates the running suggestion for downstream
|
|
263
|
+
// revalidators on the same segment, chain continues.
|
|
264
|
+
revalidate(({ defaultShouldRevalidate }) => ({
|
|
265
|
+
defaultShouldRevalidate: !defaultShouldRevalidate,
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
// 3) Defer (no opinion) — leaves the running suggestion unchanged and
|
|
269
|
+
// continues to the next revalidator. Implicit return / null /
|
|
270
|
+
// undefined are all equivalent and consumer-friendly.
|
|
271
|
+
revalidate(({ actionId }) => {
|
|
272
|
+
if (actionId?.includes("Cart")) return true; // hard for this branch only
|
|
273
|
+
// implicit return — let downstream revalidators or the segment default decide
|
|
274
|
+
});
|
|
275
|
+
revalidate(() => undefined); // explicit defer
|
|
276
|
+
revalidate(() => null); // explicit defer
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
If every revalidator on a segment defers, the segment-type default
|
|
280
|
+
(e.g. params-changed for routes, `false` for parallels) is used.
|
|
281
|
+
|
|
251
282
|
### Revalidation Contracts for Loader Dependencies
|
|
252
283
|
|
|
253
284
|
If a loader reads `ctx.get()` data produced by an outer handler/layout, share
|
package/skills/parallel/SKILL.md
CHANGED
|
@@ -347,6 +347,13 @@ Revalidating only the parallel does not re-run outer handlers/layouts.
|
|
|
347
347
|
If the slot reads `ctx.get()` data established above it, opt the outer
|
|
348
348
|
segment into revalidation as well.
|
|
349
349
|
|
|
350
|
+
A `revalidate()` callback may return a hard `boolean`, a soft
|
|
351
|
+
`{ defaultShouldRevalidate }` object, or nothing (`void` / `null` /
|
|
352
|
+
`undefined`) to defer to the next revalidator. See
|
|
353
|
+
[loader/SKILL.md#revalidate-return-shapes](../loader/SKILL.md#revalidate-return-shapes)
|
|
354
|
+
for the full contract — it's the same across `loader()`, `path()`,
|
|
355
|
+
`layout()`, `parallel()`, and `intercept()`.
|
|
356
|
+
|
|
350
357
|
### Revalidation Contracts for Parallel Dependencies
|
|
351
358
|
|
|
352
359
|
Prefer named revalidation contracts shared by both the upstream producer and
|
|
@@ -259,7 +259,12 @@ export type RouteHelpers<T extends RouteDefinition, TEnv> = {
|
|
|
259
259
|
* ({ defaultShouldRevalidate: true })
|
|
260
260
|
* )
|
|
261
261
|
* ```
|
|
262
|
-
* @param fn - Function
|
|
262
|
+
* @param fn - Function returning either:
|
|
263
|
+
* - `boolean` (hard decision — short-circuits the chain),
|
|
264
|
+
* - `{ defaultShouldRevalidate: boolean }` (soft — updates the suggestion
|
|
265
|
+
* for downstream revalidators),
|
|
266
|
+
* - or nothing / `null` / `undefined` (defer — leaves the suggestion
|
|
267
|
+
* unchanged and continues to the next revalidator).
|
|
263
268
|
*/
|
|
264
269
|
revalidate: (fn: ShouldRevalidateFn<any, TEnv>) => RevalidateItem;
|
|
265
270
|
/**
|
|
@@ -471,13 +471,16 @@ export type RevalidateParams<TParams = GenericParams, TEnv = any> = Parameters<
|
|
|
471
471
|
* **Return Types:**
|
|
472
472
|
* - `boolean` - Hard decision: immediately returns this value (short-circuits)
|
|
473
473
|
* - `{ defaultShouldRevalidate: boolean }` - Soft decision: updates suggestion for next revalidator
|
|
474
|
+
* - `void` / `null` / `undefined` - Defer to the current suggestion (no opinion); the
|
|
475
|
+
* loop continues to the next revalidator without changing the running default
|
|
474
476
|
*
|
|
475
477
|
* **Execution Flow:**
|
|
476
478
|
* 1. Start with built-in `defaultShouldRevalidate` (true if params changed)
|
|
477
479
|
* 2. Execute global revalidators first, then route-specific
|
|
478
480
|
* 3. Hard decision (boolean): stop immediately and use that value
|
|
479
481
|
* 4. Soft decision (object): update suggestion and continue to next revalidator
|
|
480
|
-
* 5.
|
|
482
|
+
* 5. Defer (`void` / `null` / `undefined`): leave suggestion unchanged and continue
|
|
483
|
+
* 6. If no hard decision was returned: use the final running suggestion
|
|
481
484
|
*
|
|
482
485
|
* @param args.currentParams - Previous route params (generic by default, can be narrowed)
|
|
483
486
|
* @param args.currentUrl - Previous URL
|
|
@@ -489,7 +492,8 @@ export type RevalidateParams<TParams = GenericParams, TEnv = any> = Parameters<
|
|
|
489
492
|
* @param args.formData - Form data from action (future support)
|
|
490
493
|
* @param args.formMethod - HTTP method from action (future support)
|
|
491
494
|
*
|
|
492
|
-
* @returns Hard decision (boolean)
|
|
495
|
+
* @returns Hard decision (boolean), soft suggestion (object), or defer
|
|
496
|
+
* (`void` / `null` / `undefined`) to keep the running suggestion as-is.
|
|
493
497
|
*
|
|
494
498
|
* @example
|
|
495
499
|
* ```typescript
|
|
@@ -514,8 +518,9 @@ export type RevalidateParams<TParams = GenericParams, TEnv = any> = Parameters<
|
|
|
514
518
|
* a segment (layout, route, parallel slot, or loader) should be re-rendered.
|
|
515
519
|
*
|
|
516
520
|
* Return `true` to re-render, `false` to skip (keep client's current version),
|
|
517
|
-
*
|
|
518
|
-
* downstream
|
|
521
|
+
* `{ defaultShouldRevalidate: boolean }` to update the running suggestion for
|
|
522
|
+
* downstream revalidators, or nothing (`void` / `null` / `undefined`) to defer
|
|
523
|
+
* to the current suggestion without changing it.
|
|
519
524
|
*
|
|
520
525
|
* @example
|
|
521
526
|
* ```ts
|
|
@@ -615,7 +620,7 @@ export type ShouldRevalidateFn<TParams = GenericParams, TEnv = any> = (args: {
|
|
|
615
620
|
* action that may have mutated backend state.
|
|
616
621
|
*/
|
|
617
622
|
stale?: boolean;
|
|
618
|
-
}) => boolean | { defaultShouldRevalidate: boolean };
|
|
623
|
+
}) => boolean | { defaultShouldRevalidate: boolean } | null | void;
|
|
619
624
|
|
|
620
625
|
// MiddlewareFn is imported from "../router/middleware.js" and re-exported
|
|
621
626
|
|