@rangojs/router 0.0.0-experimental.121 → 0.0.0-experimental.124
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/bin/rango.js +7 -2
- package/dist/vite/index.js +47 -6
- package/package.json +61 -21
- package/skills/cache-guide/SKILL.md +8 -6
- package/skills/caching/SKILL.md +148 -1
- package/skills/hooks/SKILL.md +38 -27
- package/skills/host-router/SKILL.md +16 -2
- package/skills/intercept/SKILL.md +4 -2
- package/skills/layout/SKILL.md +11 -6
- package/skills/loader/SKILL.md +6 -2
- package/skills/middleware/SKILL.md +4 -2
- package/skills/migrate-nextjs/SKILL.md +38 -16
- package/skills/parallel/SKILL.md +9 -4
- package/skills/rango/SKILL.md +27 -15
- package/skills/route/SKILL.md +4 -2
- package/skills/testing/SKILL.md +129 -0
- package/skills/testing/bindings.md +89 -0
- package/skills/testing/cache-prerender.md +98 -0
- package/skills/testing/client-components.md +122 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +89 -0
- package/skills/testing/handles.md +129 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +118 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +84 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +120 -0
- package/skills/use-cache/SKILL.md +9 -7
- package/src/browser/action-fence.ts +37 -0
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/navigation-bridge.ts +14 -1
- package/src/browser/navigation-client.ts +14 -1
- package/src/browser/navigation-store-handle.ts +39 -0
- package/src/browser/navigation-store.ts +26 -12
- package/src/browser/prefetch/fetch.ts +7 -0
- package/src/browser/rango-state.ts +176 -97
- package/src/browser/react/index.ts +0 -6
- package/src/browser/rsc-router.tsx +12 -4
- package/src/browser/server-action-bridge.ts +77 -15
- package/src/browser/types.ts +7 -1
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-policy.ts +95 -1
- package/src/cache/cache-runtime.ts +79 -13
- package/src/cache/cache-scope.ts +55 -4
- package/src/cache/cache-tag.ts +135 -0
- package/src/cache/cf/cf-cache-store.ts +2080 -224
- package/src/cache/cf/index.ts +15 -1
- package/src/cache/document-cache.ts +74 -7
- package/src/cache/index.ts +17 -0
- package/src/cache/memory-segment-store.ts +164 -14
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/types.ts +27 -0
- package/src/client.rsc.tsx +1 -1
- package/src/client.tsx +0 -6
- package/src/component-utils.ts +19 -0
- package/src/handle.ts +29 -9
- package/src/host/testing.ts +43 -14
- package/src/index.rsc.ts +29 -1
- package/src/index.ts +43 -1
- package/src/loader.rsc.ts +24 -3
- package/src/loader.ts +16 -2
- package/src/prerender.ts +24 -3
- package/src/router/basename.ts +14 -0
- package/src/router/match-handlers.ts +62 -20
- package/src/router/prerender-match.ts +6 -0
- package/src/router/router-interfaces.ts +7 -0
- package/src/router/router-options.ts +30 -0
- package/src/router/segment-resolution/loader-cache.ts +8 -17
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/telemetry.ts +99 -0
- package/src/router.ts +36 -7
- package/src/rsc/handler.ts +13 -1
- package/src/rsc/helpers.ts +19 -0
- package/src/rsc/progressive-enhancement.ts +2 -0
- package/src/rsc/response-route-handler.ts +8 -1
- package/src/rsc/rsc-rendering.ts +2 -0
- package/src/rsc/types.ts +2 -0
- package/src/runtime-env.ts +18 -0
- package/src/server/cookie-store.ts +52 -1
- package/src/server/request-context.ts +105 -2
- package/src/static-handler.ts +25 -3
- package/src/testing/cache-status.ts +166 -0
- package/src/testing/collect-handle.ts +63 -0
- package/src/testing/dispatch.ts +581 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +149 -0
- package/src/testing/e2e/matchers.ts +51 -0
- package/src/testing/e2e/page-helpers.ts +272 -0
- package/src/testing/e2e/parity.ts +387 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +110 -0
- package/src/testing/flight-normalize.ts +38 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +234 -0
- package/src/testing/generated-routes.ts +223 -0
- package/src/testing/index.ts +119 -0
- package/src/testing/internal/context.ts +390 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +80 -0
- package/src/testing/render-handler.ts +360 -0
- package/src/testing/render-route.tsx +594 -0
- package/src/testing/run-loader.ts +474 -0
- package/src/testing/run-middleware.ts +231 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/types/cache-types.ts +13 -4
- package/src/types/error-types.ts +5 -1
- package/src/types/global-namespace.ts +11 -1
- package/src/types/handler-context.ts +16 -5
- package/src/browser/react/use-client-cache.ts +0 -58
|
@@ -535,13 +535,24 @@ export type ActionRef =
|
|
|
535
535
|
* downstream revalidators, or nothing (`void` / `null` / `undefined`) to defer
|
|
536
536
|
* to the current suggestion without changing it.
|
|
537
537
|
*
|
|
538
|
+
* Two idioms cover almost every case; they differ only in what an _unrelated_
|
|
539
|
+
* action does. Match actions by reference with `ctx.isAction()` (rename-safe)
|
|
540
|
+
* rather than `actionId?.includes("...")` (a renamed or moved action silently
|
|
541
|
+
* stops matching). Because `isAction` returns a raw boolean, combine it with
|
|
542
|
+
* `|| undefined` to defer or leave it bare to suppress.
|
|
543
|
+
*
|
|
538
544
|
* @example
|
|
539
545
|
* ```ts
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* )
|
|
546
|
+
* import * as CartActions from "./actions/cart";
|
|
547
|
+
*
|
|
548
|
+
* // Idiom A — "mine, else defer": re-render on my actions, otherwise return
|
|
549
|
+
* // undefined so the segment's default decision still applies (and downstream
|
|
550
|
+
* // revalidators get a say).
|
|
551
|
+
* revalidate((ctx) => ctx.isAction(CartActions) || undefined)
|
|
552
|
+
*
|
|
553
|
+
* // Idiom B — "mine only": re-render on my actions and suppress everything
|
|
554
|
+
* // else (isAction returns a raw boolean, so an unrelated action yields false).
|
|
555
|
+
* revalidate((ctx) => ctx.isAction(CartActions))
|
|
545
556
|
*
|
|
546
557
|
* // Always re-render when params change (default behavior made explicit)
|
|
547
558
|
* revalidate(({ defaultShouldRevalidate }) => defaultShouldRevalidate)
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useContext, useCallback } from "react";
|
|
4
|
-
import { NavigationStoreContext } from "./context.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Return type for useClientCache hook
|
|
8
|
-
*/
|
|
9
|
-
export interface ClientCacheControls {
|
|
10
|
-
/**
|
|
11
|
-
* Clear the client-side navigation cache.
|
|
12
|
-
* Call this after data changes that happen outside of server actions
|
|
13
|
-
* (e.g., REST API calls, WebSocket updates, etc.)
|
|
14
|
-
*
|
|
15
|
-
* This will also broadcast to other tabs to clear their caches.
|
|
16
|
-
*/
|
|
17
|
-
clear: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hook to access client-side cache controls
|
|
22
|
-
*
|
|
23
|
-
* Use this when you need to manually invalidate the navigation cache
|
|
24
|
-
* after data changes that happen outside of server actions.
|
|
25
|
-
*
|
|
26
|
-
* Server actions automatically clear the cache, so you only need this for:
|
|
27
|
-
* - REST API mutations
|
|
28
|
-
* - WebSocket-driven updates
|
|
29
|
-
* - Other non-RSC data changes
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* function DataEditor() {
|
|
34
|
-
* const { clear } = useClientCache();
|
|
35
|
-
*
|
|
36
|
-
* async function handleSave() {
|
|
37
|
-
* await fetch('/api/data', { method: 'POST', body: JSON.stringify(data) });
|
|
38
|
-
* // Clear cache so back/forward navigation shows fresh data
|
|
39
|
-
* clear();
|
|
40
|
-
* }
|
|
41
|
-
*
|
|
42
|
-
* return <button onClick={handleSave}>Save</button>;
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export function useClientCache(): ClientCacheControls {
|
|
47
|
-
const ctx = useContext(NavigationStoreContext);
|
|
48
|
-
|
|
49
|
-
if (!ctx) {
|
|
50
|
-
throw new Error("useClientCache must be used within NavigationProvider");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const clear = useCallback(() => {
|
|
54
|
-
ctx.store.clearHistoryCache();
|
|
55
|
-
}, [ctx]);
|
|
56
|
-
|
|
57
|
-
return { clear };
|
|
58
|
-
}
|