@rangojs/router 0.0.0-experimental.12 → 0.0.0-experimental.121
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/AGENTS.md +9 -0
- package/README.md +1037 -4
- package/dist/__internal.d.ts +83 -0
- package/dist/__internal.d.ts.map +1 -0
- package/dist/__internal.js +19 -0
- package/dist/__internal.js.map +1 -0
- package/dist/__mocks__/version.d.ts +7 -0
- package/dist/__mocks__/version.d.ts.map +1 -0
- package/dist/__mocks__/version.js +7 -0
- package/dist/__mocks__/version.js.map +1 -0
- package/dist/__tests__/client-href.test.d.ts +2 -0
- package/dist/__tests__/client-href.test.d.ts.map +1 -0
- package/dist/__tests__/client-href.test.js +74 -0
- package/dist/__tests__/client-href.test.js.map +1 -0
- package/dist/__tests__/component-utils.test.d.ts +2 -0
- package/dist/__tests__/component-utils.test.d.ts.map +1 -0
- package/dist/__tests__/component-utils.test.js +51 -0
- package/dist/__tests__/component-utils.test.js.map +1 -0
- package/dist/__tests__/event-controller.test.d.ts +2 -0
- package/dist/__tests__/event-controller.test.d.ts.map +1 -0
- package/dist/__tests__/event-controller.test.js +538 -0
- package/dist/__tests__/event-controller.test.js.map +1 -0
- package/dist/__tests__/helpers/route-tree.d.ts +118 -0
- package/dist/__tests__/helpers/route-tree.d.ts.map +1 -0
- package/dist/__tests__/helpers/route-tree.js +374 -0
- package/dist/__tests__/helpers/route-tree.js.map +1 -0
- package/dist/__tests__/match-result.test.d.ts +2 -0
- package/dist/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/__tests__/match-result.test.js +154 -0
- package/dist/__tests__/match-result.test.js.map +1 -0
- package/dist/__tests__/navigation-store.test.d.ts +2 -0
- package/dist/__tests__/navigation-store.test.d.ts.map +1 -0
- package/dist/__tests__/navigation-store.test.js +440 -0
- package/dist/__tests__/navigation-store.test.js.map +1 -0
- package/dist/__tests__/partial-update.test.d.ts +2 -0
- package/dist/__tests__/partial-update.test.d.ts.map +1 -0
- package/dist/__tests__/partial-update.test.js +1009 -0
- package/dist/__tests__/partial-update.test.js.map +1 -0
- package/dist/__tests__/reverse-types.test.d.ts +8 -0
- package/dist/__tests__/reverse-types.test.d.ts.map +1 -0
- package/dist/__tests__/reverse-types.test.js +656 -0
- package/dist/__tests__/reverse-types.test.js.map +1 -0
- package/dist/__tests__/route-definition.test.d.ts +2 -0
- package/dist/__tests__/route-definition.test.d.ts.map +1 -0
- package/dist/__tests__/route-definition.test.js +55 -0
- package/dist/__tests__/route-definition.test.js.map +1 -0
- package/dist/__tests__/router-helpers.test.d.ts +2 -0
- package/dist/__tests__/router-helpers.test.d.ts.map +1 -0
- package/dist/__tests__/router-helpers.test.js +377 -0
- package/dist/__tests__/router-helpers.test.js.map +1 -0
- package/dist/__tests__/router-integration-2.test.d.ts +2 -0
- package/dist/__tests__/router-integration-2.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration-2.test.js +426 -0
- package/dist/__tests__/router-integration-2.test.js.map +1 -0
- package/dist/__tests__/router-integration.test.d.ts +2 -0
- package/dist/__tests__/router-integration.test.d.ts.map +1 -0
- package/dist/__tests__/router-integration.test.js +1051 -0
- package/dist/__tests__/router-integration.test.js.map +1 -0
- package/dist/__tests__/search-params.test.d.ts +5 -0
- package/dist/__tests__/search-params.test.d.ts.map +1 -0
- package/dist/__tests__/search-params.test.js +306 -0
- package/dist/__tests__/search-params.test.js.map +1 -0
- package/dist/__tests__/segment-system.test.d.ts +2 -0
- package/dist/__tests__/segment-system.test.d.ts.map +1 -0
- package/dist/__tests__/segment-system.test.js +627 -0
- package/dist/__tests__/segment-system.test.js.map +1 -0
- package/dist/__tests__/static-handler-types.test.d.ts +8 -0
- package/dist/__tests__/static-handler-types.test.d.ts.map +1 -0
- package/dist/__tests__/static-handler-types.test.js +63 -0
- package/dist/__tests__/static-handler-types.test.js.map +1 -0
- package/dist/__tests__/urls.test.d.ts +2 -0
- package/dist/__tests__/urls.test.d.ts.map +1 -0
- package/dist/__tests__/urls.test.js +421 -0
- package/dist/__tests__/urls.test.js.map +1 -0
- package/dist/__tests__/use-mount.test.d.ts +2 -0
- package/dist/__tests__/use-mount.test.d.ts.map +1 -0
- package/dist/__tests__/use-mount.test.js +35 -0
- package/dist/__tests__/use-mount.test.js.map +1 -0
- package/dist/bin/rango.d.ts +2 -0
- package/dist/bin/rango.d.ts.map +1 -0
- package/dist/bin/rango.js +1704 -212
- package/dist/bin/rango.js.map +1 -0
- package/dist/browser/event-controller.d.ts +191 -0
- package/dist/browser/event-controller.d.ts.map +1 -0
- package/dist/browser/event-controller.js +559 -0
- package/dist/browser/event-controller.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/link-interceptor.d.ts +38 -0
- package/dist/browser/link-interceptor.d.ts.map +1 -0
- package/dist/browser/link-interceptor.js +99 -0
- package/dist/browser/link-interceptor.js.map +1 -0
- package/dist/browser/logging.d.ts +10 -0
- package/dist/browser/logging.d.ts.map +1 -0
- package/dist/browser/logging.js +29 -0
- package/dist/browser/logging.js.map +1 -0
- package/dist/browser/lru-cache.d.ts +17 -0
- package/dist/browser/lru-cache.d.ts.map +1 -0
- package/dist/browser/lru-cache.js +50 -0
- package/dist/browser/lru-cache.js.map +1 -0
- package/dist/browser/merge-segment-loaders.d.ts +39 -0
- package/dist/browser/merge-segment-loaders.d.ts.map +1 -0
- package/dist/browser/merge-segment-loaders.js +102 -0
- package/dist/browser/merge-segment-loaders.js.map +1 -0
- package/dist/browser/navigation-bridge.d.ts +102 -0
- package/dist/browser/navigation-bridge.d.ts.map +1 -0
- package/dist/browser/navigation-bridge.js +708 -0
- package/dist/browser/navigation-bridge.js.map +1 -0
- package/dist/browser/navigation-client.d.ts +25 -0
- package/dist/browser/navigation-client.d.ts.map +1 -0
- package/dist/browser/navigation-client.js +157 -0
- package/dist/browser/navigation-client.js.map +1 -0
- package/dist/browser/navigation-store.d.ts +101 -0
- package/dist/browser/navigation-store.d.ts.map +1 -0
- package/dist/browser/navigation-store.js +625 -0
- package/dist/browser/navigation-store.js.map +1 -0
- package/dist/browser/partial-update.d.ts +75 -0
- package/dist/browser/partial-update.d.ts.map +1 -0
- package/dist/browser/partial-update.js +426 -0
- package/dist/browser/partial-update.js.map +1 -0
- package/dist/browser/react/Link.d.ts +86 -0
- package/dist/browser/react/Link.d.ts.map +1 -0
- package/dist/browser/react/Link.js +128 -0
- package/dist/browser/react/Link.js.map +1 -0
- package/dist/browser/react/NavigationProvider.d.ts +63 -0
- package/dist/browser/react/NavigationProvider.d.ts.map +1 -0
- package/dist/browser/react/NavigationProvider.js +216 -0
- package/dist/browser/react/NavigationProvider.js.map +1 -0
- package/dist/browser/react/ScrollRestoration.d.ts +75 -0
- package/dist/browser/react/ScrollRestoration.d.ts.map +1 -0
- package/dist/browser/react/ScrollRestoration.js +57 -0
- package/dist/browser/react/ScrollRestoration.js.map +1 -0
- package/dist/browser/react/context.d.ts +46 -0
- package/dist/browser/react/context.d.ts.map +1 -0
- package/dist/browser/react/context.js +10 -0
- package/dist/browser/react/context.js.map +1 -0
- package/dist/browser/react/index.d.ts +11 -0
- package/dist/browser/react/index.d.ts.map +1 -0
- package/dist/browser/react/index.js +22 -0
- package/dist/browser/react/index.js.map +1 -0
- package/dist/browser/react/location-state-shared.d.ts +63 -0
- package/dist/browser/react/location-state-shared.d.ts.map +1 -0
- package/dist/browser/react/location-state-shared.js +81 -0
- package/dist/browser/react/location-state-shared.js.map +1 -0
- package/dist/browser/react/location-state.d.ts +23 -0
- package/dist/browser/react/location-state.d.ts.map +1 -0
- package/dist/browser/react/location-state.js +29 -0
- package/dist/browser/react/location-state.js.map +1 -0
- package/dist/browser/react/mount-context.d.ts +24 -0
- package/dist/browser/react/mount-context.d.ts.map +1 -0
- package/dist/browser/react/mount-context.js +24 -0
- package/dist/browser/react/mount-context.js.map +1 -0
- package/dist/browser/react/use-action.d.ts +64 -0
- package/dist/browser/react/use-action.d.ts.map +1 -0
- package/dist/browser/react/use-action.js +134 -0
- package/dist/browser/react/use-action.js.map +1 -0
- package/dist/browser/react/use-client-cache.d.ts +41 -0
- package/dist/browser/react/use-client-cache.d.ts.map +1 -0
- package/dist/browser/react/use-client-cache.js +39 -0
- package/dist/browser/react/use-client-cache.js.map +1 -0
- package/dist/browser/react/use-handle.d.ts +31 -0
- package/dist/browser/react/use-handle.d.ts.map +1 -0
- package/dist/browser/react/use-handle.js +144 -0
- package/dist/browser/react/use-handle.js.map +1 -0
- package/dist/browser/react/use-href.d.ts +33 -0
- package/dist/browser/react/use-href.d.ts.map +1 -0
- package/dist/browser/react/use-href.js +39 -0
- package/dist/browser/react/use-href.js.map +1 -0
- package/dist/browser/react/use-link-status.d.ts +37 -0
- package/dist/browser/react/use-link-status.d.ts.map +1 -0
- package/dist/browser/react/use-link-status.js +99 -0
- package/dist/browser/react/use-link-status.js.map +1 -0
- package/dist/browser/react/use-mount.d.ts +25 -0
- package/dist/browser/react/use-mount.d.ts.map +1 -0
- package/dist/browser/react/use-mount.js +30 -0
- package/dist/browser/react/use-mount.js.map +1 -0
- package/dist/browser/react/use-navigation.d.ts +27 -0
- package/dist/browser/react/use-navigation.d.ts.map +1 -0
- package/dist/browser/react/use-navigation.js +87 -0
- package/dist/browser/react/use-navigation.js.map +1 -0
- package/dist/browser/react/use-segments.d.ts +38 -0
- package/dist/browser/react/use-segments.d.ts.map +1 -0
- package/dist/browser/react/use-segments.js +130 -0
- package/dist/browser/react/use-segments.js.map +1 -0
- package/dist/browser/request-controller.d.ts +26 -0
- package/dist/browser/request-controller.d.ts.map +1 -0
- package/dist/browser/request-controller.js +147 -0
- package/dist/browser/request-controller.js.map +1 -0
- package/dist/browser/rsc-router.d.ts +129 -0
- package/dist/browser/rsc-router.d.ts.map +1 -0
- package/dist/browser/rsc-router.js +195 -0
- package/dist/browser/rsc-router.js.map +1 -0
- package/dist/browser/scroll-restoration.d.ts +93 -0
- package/dist/browser/scroll-restoration.d.ts.map +1 -0
- package/dist/browser/scroll-restoration.js +321 -0
- package/dist/browser/scroll-restoration.js.map +1 -0
- package/dist/browser/segment-structure-assert.d.ts +17 -0
- package/dist/browser/segment-structure-assert.d.ts.map +1 -0
- package/dist/browser/segment-structure-assert.js +59 -0
- package/dist/browser/segment-structure-assert.js.map +1 -0
- package/dist/browser/server-action-bridge.d.ts +26 -0
- package/dist/browser/server-action-bridge.d.ts.map +1 -0
- package/dist/browser/server-action-bridge.js +668 -0
- package/dist/browser/server-action-bridge.js.map +1 -0
- package/dist/browser/shallow.d.ts +12 -0
- package/dist/browser/shallow.d.ts.map +1 -0
- package/dist/browser/shallow.js +34 -0
- package/dist/browser/shallow.js.map +1 -0
- package/dist/browser/types.d.ts +369 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/build/__tests__/generate-cli.test.d.ts +2 -0
- package/dist/build/__tests__/generate-cli.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-cli.test.js +237 -0
- package/dist/build/__tests__/generate-cli.test.js.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/generate-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-manifest.test.js +119 -0
- package/dist/build/__tests__/generate-manifest.test.js.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts +2 -0
- package/dist/build/__tests__/generate-route-types.test.d.ts.map +1 -0
- package/dist/build/__tests__/generate-route-types.test.js +620 -0
- package/dist/build/__tests__/generate-route-types.test.js.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts +2 -0
- package/dist/build/__tests__/per-router-manifest.test.d.ts.map +1 -0
- package/dist/build/__tests__/per-router-manifest.test.js +308 -0
- package/dist/build/__tests__/per-router-manifest.test.js.map +1 -0
- package/dist/build/generate-manifest.d.ts +81 -0
- package/dist/build/generate-manifest.d.ts.map +1 -0
- package/dist/build/generate-manifest.js +276 -0
- package/dist/build/generate-manifest.js.map +1 -0
- package/dist/build/generate-route-types.d.ts +115 -0
- package/dist/build/generate-route-types.d.ts.map +1 -0
- package/dist/build/generate-route-types.js +740 -0
- package/dist/build/generate-route-types.js.map +1 -0
- package/dist/build/index.d.ts +21 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +21 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/route-trie.d.ts +71 -0
- package/dist/build/route-trie.d.ts.map +1 -0
- package/dist/build/route-trie.js +175 -0
- package/dist/build/route-trie.js.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts +2 -0
- package/dist/cache/__tests__/cache-scope.test.d.ts.map +1 -0
- package/dist/cache/__tests__/cache-scope.test.js +208 -0
- package/dist/cache/__tests__/cache-scope.test.js.map +1 -0
- package/dist/cache/__tests__/document-cache.test.d.ts +2 -0
- package/dist/cache/__tests__/document-cache.test.d.ts.map +1 -0
- package/dist/cache/__tests__/document-cache.test.js +345 -0
- package/dist/cache/__tests__/document-cache.test.js.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-segment-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-segment-store.test.js +425 -0
- package/dist/cache/__tests__/memory-segment-store.test.js.map +1 -0
- package/dist/cache/__tests__/memory-store.test.d.ts +2 -0
- package/dist/cache/__tests__/memory-store.test.d.ts.map +1 -0
- package/dist/cache/__tests__/memory-store.test.js +367 -0
- package/dist/cache/__tests__/memory-store.test.js.map +1 -0
- package/dist/cache/cache-scope.d.ts +102 -0
- package/dist/cache/cache-scope.d.ts.map +1 -0
- package/dist/cache/cache-scope.js +440 -0
- package/dist/cache/cache-scope.js.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts +2 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.d.ts.map +1 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js +330 -0
- package/dist/cache/cf/__tests__/cf-cache-store.test.js.map +1 -0
- package/dist/cache/cf/cf-cache-store.d.ts +165 -0
- package/dist/cache/cf/cf-cache-store.d.ts.map +1 -0
- package/dist/cache/cf/cf-cache-store.js +242 -0
- package/dist/cache/cf/cf-cache-store.js.map +1 -0
- package/dist/cache/cf/index.d.ts +14 -0
- package/dist/cache/cf/index.d.ts.map +1 -0
- package/dist/cache/cf/index.js +17 -0
- package/dist/cache/cf/index.js.map +1 -0
- package/dist/cache/document-cache.d.ts +64 -0
- package/dist/cache/document-cache.d.ts.map +1 -0
- package/dist/cache/document-cache.js +228 -0
- package/dist/cache/document-cache.js.map +1 -0
- package/dist/cache/index.d.ts +19 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +21 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory-segment-store.d.ts +110 -0
- package/dist/cache/memory-segment-store.d.ts.map +1 -0
- package/dist/cache/memory-segment-store.js +117 -0
- package/dist/cache/memory-segment-store.js.map +1 -0
- package/dist/cache/memory-store.d.ts +41 -0
- package/dist/cache/memory-store.d.ts.map +1 -0
- package/dist/cache/memory-store.js +191 -0
- package/dist/cache/memory-store.js.map +1 -0
- package/dist/cache/types.d.ts +317 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +12 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/client.d.ts +248 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +367 -0
- package/dist/client.js.map +1 -0
- package/dist/client.rsc.d.ts +26 -0
- package/dist/client.rsc.d.ts.map +1 -0
- package/dist/client.rsc.js +46 -0
- package/dist/client.rsc.js.map +1 -0
- package/dist/component-utils.d.ts +36 -0
- package/dist/component-utils.d.ts.map +1 -0
- package/dist/component-utils.js +61 -0
- package/dist/component-utils.js.map +1 -0
- package/dist/components/DefaultDocument.d.ts +13 -0
- package/dist/components/DefaultDocument.d.ts.map +1 -0
- package/dist/components/DefaultDocument.js +15 -0
- package/dist/components/DefaultDocument.js.map +1 -0
- package/dist/debug.d.ts +58 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +157 -0
- package/dist/debug.js.map +1 -0
- package/dist/default-error-boundary.d.ts +11 -0
- package/dist/default-error-boundary.d.ts.map +1 -0
- package/dist/default-error-boundary.js +45 -0
- package/dist/default-error-boundary.js.map +1 -0
- package/dist/deps/browser.d.ts +2 -0
- package/dist/deps/browser.d.ts.map +1 -0
- package/dist/deps/browser.js +3 -0
- package/dist/deps/browser.js.map +1 -0
- package/dist/deps/html-stream-client.d.ts +2 -0
- package/dist/deps/html-stream-client.d.ts.map +1 -0
- package/dist/deps/html-stream-client.js +3 -0
- package/dist/deps/html-stream-client.js.map +1 -0
- package/dist/deps/html-stream-server.d.ts +2 -0
- package/dist/deps/html-stream-server.d.ts.map +1 -0
- package/dist/deps/html-stream-server.js +3 -0
- package/dist/deps/html-stream-server.js.map +1 -0
- package/dist/deps/rsc.d.ts +2 -0
- package/dist/deps/rsc.d.ts.map +1 -0
- package/dist/deps/rsc.js +4 -0
- package/dist/deps/rsc.js.map +1 -0
- package/dist/deps/ssr.d.ts +2 -0
- package/dist/deps/ssr.d.ts.map +1 -0
- package/dist/deps/ssr.js +3 -0
- package/dist/deps/ssr.js.map +1 -0
- package/dist/errors.d.ts +174 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +241 -0
- package/dist/errors.js.map +1 -0
- package/dist/handle.d.ts +78 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +82 -0
- package/dist/handle.js.map +1 -0
- package/dist/handles/MetaTags.d.ts +14 -0
- package/dist/handles/MetaTags.d.ts.map +1 -0
- package/dist/handles/MetaTags.js +136 -0
- package/dist/handles/MetaTags.js.map +1 -0
- package/dist/handles/index.d.ts +6 -0
- package/dist/handles/index.d.ts.map +1 -0
- package/dist/handles/index.js +6 -0
- package/dist/handles/index.js.map +1 -0
- package/dist/handles/meta.d.ts +39 -0
- package/dist/handles/meta.d.ts.map +1 -0
- package/dist/handles/meta.js +202 -0
- package/dist/handles/meta.js.map +1 -0
- package/dist/host/__tests__/errors.test.d.ts +2 -0
- package/dist/host/__tests__/errors.test.d.ts.map +1 -0
- package/dist/host/__tests__/errors.test.js +76 -0
- package/dist/host/__tests__/errors.test.js.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-comprehensive.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js +732 -0
- package/dist/host/__tests__/pattern-comprehensive.test.js.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts +2 -0
- package/dist/host/__tests__/pattern-matcher.test.d.ts.map +1 -0
- package/dist/host/__tests__/pattern-matcher.test.js +251 -0
- package/dist/host/__tests__/pattern-matcher.test.js.map +1 -0
- package/dist/host/__tests__/router.test.d.ts +2 -0
- package/dist/host/__tests__/router.test.d.ts.map +1 -0
- package/dist/host/__tests__/router.test.js +241 -0
- package/dist/host/__tests__/router.test.js.map +1 -0
- package/dist/host/__tests__/testing.test.d.ts +2 -0
- package/dist/host/__tests__/testing.test.d.ts.map +1 -0
- package/dist/host/__tests__/testing.test.js +64 -0
- package/dist/host/__tests__/testing.test.js.map +1 -0
- package/dist/host/__tests__/utils.test.d.ts +2 -0
- package/dist/host/__tests__/utils.test.d.ts.map +1 -0
- package/dist/host/__tests__/utils.test.js +29 -0
- package/dist/host/__tests__/utils.test.js.map +1 -0
- package/dist/host/cookie-handler.d.ts +34 -0
- package/dist/host/cookie-handler.d.ts.map +1 -0
- package/dist/host/cookie-handler.js +124 -0
- package/dist/host/cookie-handler.js.map +1 -0
- package/dist/host/errors.d.ts +56 -0
- package/dist/host/errors.d.ts.map +1 -0
- package/dist/host/errors.js +79 -0
- package/dist/host/errors.js.map +1 -0
- package/dist/host/index.d.ts +29 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +32 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/pattern-matcher.d.ts +36 -0
- package/dist/host/pattern-matcher.d.ts.map +1 -0
- package/dist/host/pattern-matcher.js +172 -0
- package/dist/host/pattern-matcher.js.map +1 -0
- package/dist/host/router.d.ts +26 -0
- package/dist/host/router.d.ts.map +1 -0
- package/dist/host/router.js +218 -0
- package/dist/host/router.js.map +1 -0
- package/dist/host/testing.d.ts +36 -0
- package/dist/host/testing.d.ts.map +1 -0
- package/dist/host/testing.js +55 -0
- package/dist/host/testing.js.map +1 -0
- package/dist/host/types.d.ts +115 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +7 -0
- package/dist/host/types.js.map +1 -0
- package/dist/host/utils.d.ts +21 -0
- package/dist/host/utils.d.ts.map +1 -0
- package/dist/host/utils.js +23 -0
- package/dist/host/utils.js.map +1 -0
- package/dist/href-client.d.ts +131 -0
- package/dist/href-client.d.ts.map +1 -0
- package/dist/href-client.js +64 -0
- package/dist/href-client.js.map +1 -0
- package/{src/href-context.ts → dist/href-context.d.ts} +7 -11
- package/dist/href-context.d.ts.map +1 -0
- package/dist/href-context.js +21 -0
- package/dist/href-context.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/index.rsc.d.ts +32 -0
- package/dist/index.rsc.d.ts.map +1 -0
- package/dist/index.rsc.js +40 -0
- package/dist/index.rsc.js.map +1 -0
- package/dist/internal-debug.d.ts +2 -0
- package/dist/internal-debug.d.ts.map +1 -0
- package/dist/internal-debug.js +5 -0
- package/dist/internal-debug.js.map +1 -0
- package/dist/loader.d.ts +14 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/loader.js.map +1 -0
- package/dist/loader.rsc.d.ts +19 -0
- package/dist/loader.rsc.d.ts.map +1 -0
- package/dist/loader.rsc.js +99 -0
- package/dist/loader.rsc.js.map +1 -0
- package/dist/network-error-thrower.d.ts +17 -0
- package/dist/network-error-thrower.d.ts.map +1 -0
- package/dist/network-error-thrower.js +14 -0
- package/dist/network-error-thrower.js.map +1 -0
- package/dist/outlet-context.d.ts +13 -0
- package/dist/outlet-context.d.ts.map +1 -0
- package/dist/outlet-context.js +3 -0
- package/dist/outlet-context.js.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts +2 -0
- package/dist/prerender/__tests__/param-hash.test.d.ts.map +1 -0
- package/dist/prerender/__tests__/param-hash.test.js +148 -0
- package/dist/prerender/__tests__/param-hash.test.js.map +1 -0
- package/dist/prerender/param-hash.d.ts +16 -0
- package/dist/prerender/param-hash.d.ts.map +1 -0
- package/dist/prerender/param-hash.js +36 -0
- package/dist/prerender/param-hash.js.map +1 -0
- package/dist/prerender/store.d.ts +38 -0
- package/dist/prerender/store.d.ts.map +1 -0
- package/dist/prerender/store.js +61 -0
- package/dist/prerender/store.js.map +1 -0
- package/dist/prerender.d.ts +66 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +57 -0
- package/dist/prerender.js.map +1 -0
- package/dist/reverse.d.ts +196 -0
- package/dist/reverse.d.ts.map +1 -0
- package/dist/reverse.js +78 -0
- package/dist/reverse.js.map +1 -0
- package/dist/root-error-boundary.d.ts +33 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/root-error-boundary.js +165 -0
- package/dist/root-error-boundary.js.map +1 -0
- package/dist/route-content-wrapper.d.ts +46 -0
- package/dist/route-content-wrapper.d.ts.map +1 -0
- package/dist/route-content-wrapper.js +77 -0
- package/dist/route-content-wrapper.js.map +1 -0
- package/dist/route-definition.d.ts +421 -0
- package/dist/route-definition.d.ts.map +1 -0
- package/dist/route-definition.js +868 -0
- package/dist/route-definition.js.map +1 -0
- package/dist/route-map-builder.d.ts +155 -0
- package/dist/route-map-builder.d.ts.map +1 -0
- package/dist/route-map-builder.js +237 -0
- package/dist/route-map-builder.js.map +1 -0
- package/dist/route-types.d.ts +165 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +7 -0
- package/dist/route-types.js.map +1 -0
- package/dist/router/__tests__/handler-context.test.d.ts +2 -0
- package/dist/router/__tests__/handler-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/handler-context.test.js +65 -0
- package/dist/router/__tests__/handler-context.test.js.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts +2 -0
- package/dist/router/__tests__/loader-cycle-detection.test.d.ts.map +1 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js +221 -0
- package/dist/router/__tests__/loader-cycle-detection.test.js.map +1 -0
- package/dist/router/__tests__/match-context.test.d.ts +2 -0
- package/dist/router/__tests__/match-context.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-context.test.js +92 -0
- package/dist/router/__tests__/match-context.test.js.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts +2 -0
- package/dist/router/__tests__/match-pipelines.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-pipelines.test.js +417 -0
- package/dist/router/__tests__/match-pipelines.test.js.map +1 -0
- package/dist/router/__tests__/match-result.test.d.ts +2 -0
- package/dist/router/__tests__/match-result.test.d.ts.map +1 -0
- package/dist/router/__tests__/match-result.test.js +457 -0
- package/dist/router/__tests__/match-result.test.js.map +1 -0
- package/dist/router/__tests__/on-error.test.d.ts +2 -0
- package/dist/router/__tests__/on-error.test.d.ts.map +1 -0
- package/dist/router/__tests__/on-error.test.js +678 -0
- package/dist/router/__tests__/on-error.test.js.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts +2 -0
- package/dist/router/__tests__/pattern-matching.test.d.ts.map +1 -0
- package/dist/router/__tests__/pattern-matching.test.js +629 -0
- package/dist/router/__tests__/pattern-matching.test.js.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts +2 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.d.ts.map +1 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js +155 -0
- package/dist/router/__tests__/segment-resolution-parallel-loading.test.js.map +1 -0
- package/dist/router/error-handling.d.ts +77 -0
- package/dist/router/error-handling.d.ts.map +1 -0
- package/dist/router/error-handling.js +202 -0
- package/dist/router/error-handling.js.map +1 -0
- package/dist/router/handler-context.d.ts +20 -0
- package/dist/router/handler-context.d.ts.map +1 -0
- package/dist/router/handler-context.js +198 -0
- package/dist/router/handler-context.js.map +1 -0
- package/dist/router/intercept-resolution.d.ts +66 -0
- package/dist/router/intercept-resolution.d.ts.map +1 -0
- package/dist/router/intercept-resolution.js +246 -0
- package/dist/router/intercept-resolution.js.map +1 -0
- package/dist/router/loader-resolution.d.ts +64 -0
- package/dist/router/loader-resolution.d.ts.map +1 -0
- package/dist/router/loader-resolution.js +284 -0
- package/dist/router/loader-resolution.js.map +1 -0
- package/dist/router/logging.d.ts +15 -0
- package/dist/router/logging.d.ts.map +1 -0
- package/dist/router/logging.js +99 -0
- package/dist/router/logging.js.map +1 -0
- package/dist/router/manifest.d.ts +22 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +181 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/match-api.d.ts +35 -0
- package/dist/router/match-api.d.ts.map +1 -0
- package/dist/router/match-api.js +406 -0
- package/dist/router/match-api.js.map +1 -0
- package/dist/router/match-context.d.ts +206 -0
- package/dist/router/match-context.d.ts.map +1 -0
- package/dist/router/match-context.js +17 -0
- package/dist/router/match-context.js.map +1 -0
- package/dist/router/match-middleware/background-revalidation.d.ts +127 -0
- package/dist/router/match-middleware/background-revalidation.d.ts.map +1 -0
- package/dist/router/match-middleware/background-revalidation.js +75 -0
- package/dist/router/match-middleware/background-revalidation.js.map +1 -0
- package/dist/router/match-middleware/cache-lookup.d.ts +112 -0
- package/dist/router/match-middleware/cache-lookup.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-lookup.js +257 -0
- package/dist/router/match-middleware/cache-lookup.js.map +1 -0
- package/dist/router/match-middleware/cache-store.d.ts +113 -0
- package/dist/router/match-middleware/cache-store.d.ts.map +1 -0
- package/dist/router/match-middleware/cache-store.js +108 -0
- package/dist/router/match-middleware/cache-store.js.map +1 -0
- package/dist/router/match-middleware/index.d.ts +81 -0
- package/dist/router/match-middleware/index.d.ts.map +1 -0
- package/dist/router/match-middleware/index.js +80 -0
- package/dist/router/match-middleware/index.js.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts +117 -0
- package/dist/router/match-middleware/intercept-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/intercept-resolution.js +134 -0
- package/dist/router/match-middleware/intercept-resolution.js.map +1 -0
- package/dist/router/match-middleware/segment-resolution.d.ts +99 -0
- package/dist/router/match-middleware/segment-resolution.d.ts.map +1 -0
- package/dist/router/match-middleware/segment-resolution.js +53 -0
- package/dist/router/match-middleware/segment-resolution.js.map +1 -0
- package/dist/router/match-pipelines.d.ts +147 -0
- package/dist/router/match-pipelines.d.ts.map +1 -0
- package/dist/router/match-pipelines.js +82 -0
- package/dist/router/match-pipelines.js.map +1 -0
- package/dist/router/match-result.d.ts +126 -0
- package/dist/router/match-result.d.ts.map +1 -0
- package/dist/router/match-result.js +93 -0
- package/dist/router/match-result.js.map +1 -0
- package/dist/router/metrics.d.ts +20 -0
- package/dist/router/metrics.d.ts.map +1 -0
- package/dist/router/metrics.js +47 -0
- package/dist/router/metrics.js.map +1 -0
- package/dist/router/middleware.d.ts +249 -0
- package/dist/router/middleware.d.ts.map +1 -0
- package/dist/router/middleware.js +434 -0
- package/dist/router/middleware.js.map +1 -0
- package/dist/router/middleware.test.d.ts +2 -0
- package/dist/router/middleware.test.d.ts.map +1 -0
- package/dist/router/middleware.test.js +816 -0
- package/dist/router/middleware.test.js.map +1 -0
- package/dist/router/pattern-matching.d.ts +149 -0
- package/dist/router/pattern-matching.d.ts.map +1 -0
- package/dist/router/pattern-matching.js +349 -0
- package/dist/router/pattern-matching.js.map +1 -0
- package/dist/router/revalidation.d.ts +44 -0
- package/dist/router/revalidation.d.ts.map +1 -0
- package/dist/router/revalidation.js +147 -0
- package/dist/router/revalidation.js.map +1 -0
- package/dist/router/router-context.d.ts +135 -0
- package/dist/router/router-context.d.ts.map +1 -0
- package/dist/router/router-context.js +36 -0
- package/dist/router/router-context.js.map +1 -0
- package/dist/router/segment-resolution.d.ts +127 -0
- package/dist/router/segment-resolution.d.ts.map +1 -0
- package/dist/router/segment-resolution.js +919 -0
- package/dist/router/segment-resolution.js.map +1 -0
- package/dist/router/trie-matching.d.ts +40 -0
- package/dist/router/trie-matching.d.ts.map +1 -0
- package/dist/router/trie-matching.js +127 -0
- package/dist/router/trie-matching.js.map +1 -0
- package/dist/router/types.d.ts +136 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +7 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router.d.ts +753 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.gen.d.ts +6 -0
- package/dist/router.gen.d.ts.map +1 -0
- package/dist/router.gen.js +6 -0
- package/dist/router.gen.js.map +1 -0
- package/dist/router.js +1304 -0
- package/dist/router.js.map +1 -0
- package/dist/rsc/__tests__/helpers.test.d.ts +2 -0
- package/dist/rsc/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/rsc/__tests__/helpers.test.js +140 -0
- package/dist/rsc/__tests__/helpers.test.js.map +1 -0
- package/dist/rsc/handler.d.ts +45 -0
- package/dist/rsc/handler.d.ts.map +1 -0
- package/dist/rsc/handler.js +1172 -0
- package/dist/rsc/handler.js.map +1 -0
- package/dist/rsc/helpers.d.ts +16 -0
- package/dist/rsc/helpers.d.ts.map +1 -0
- package/dist/rsc/helpers.js +55 -0
- package/dist/rsc/helpers.js.map +1 -0
- package/dist/rsc/index.d.ts +22 -0
- package/dist/rsc/index.d.ts.map +1 -0
- package/dist/rsc/index.js +23 -0
- package/dist/rsc/index.js.map +1 -0
- package/dist/rsc/nonce.d.ts +9 -0
- package/dist/rsc/nonce.d.ts.map +1 -0
- package/dist/rsc/nonce.js +18 -0
- package/dist/rsc/nonce.js.map +1 -0
- package/dist/rsc/types.d.ts +206 -0
- package/dist/rsc/types.d.ts.map +1 -0
- package/dist/rsc/types.js +8 -0
- package/dist/rsc/types.js.map +1 -0
- package/dist/search-params.d.ts +103 -0
- package/dist/search-params.d.ts.map +1 -0
- package/dist/search-params.js +74 -0
- package/dist/search-params.js.map +1 -0
- package/dist/segment-system.d.ts +75 -0
- package/dist/segment-system.d.ts.map +1 -0
- package/dist/segment-system.js +336 -0
- package/dist/segment-system.js.map +1 -0
- package/dist/server/context.d.ts +245 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +197 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/fetchable-loader-store.d.ts +18 -0
- package/dist/server/fetchable-loader-store.d.ts.map +1 -0
- package/dist/server/fetchable-loader-store.js +18 -0
- package/dist/server/fetchable-loader-store.js.map +1 -0
- package/dist/server/handle-store.d.ts +85 -0
- package/dist/server/handle-store.d.ts.map +1 -0
- package/dist/server/handle-store.js +142 -0
- package/dist/server/handle-store.js.map +1 -0
- package/dist/server/loader-registry.d.ts +55 -0
- package/dist/server/loader-registry.d.ts.map +1 -0
- package/dist/server/loader-registry.js +132 -0
- package/dist/server/loader-registry.js.map +1 -0
- package/dist/server/request-context.d.ts +226 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/request-context.js +290 -0
- package/dist/server/request-context.js.map +1 -0
- package/dist/server/root-layout.d.ts +4 -0
- package/dist/server/root-layout.d.ts.map +1 -0
- package/dist/server/root-layout.js +5 -0
- package/dist/server/root-layout.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +20 -0
- package/dist/server.js.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts +2 -0
- package/dist/ssr/__tests__/ssr-handler.test.d.ts.map +1 -0
- package/dist/ssr/__tests__/ssr-handler.test.js +132 -0
- package/dist/ssr/__tests__/ssr-handler.test.js.map +1 -0
- package/dist/ssr/index.d.ts +98 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +158 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/static-handler.d.ts +50 -0
- package/dist/static-handler.d.ts.map +1 -0
- package/dist/static-handler.gen.d.ts +5 -0
- package/dist/static-handler.gen.d.ts.map +1 -0
- package/dist/static-handler.gen.js +5 -0
- package/dist/static-handler.gen.js.map +1 -0
- package/dist/static-handler.js +29 -0
- package/dist/static-handler.js.map +1 -0
- package/dist/testing/vitest.js +82 -0
- package/dist/theme/ThemeProvider.d.ts +20 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +240 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/ThemeScript.d.ts +48 -0
- package/dist/theme/ThemeScript.d.ts.map +1 -0
- package/dist/theme/ThemeScript.js +13 -0
- package/dist/theme/ThemeScript.js.map +1 -0
- package/dist/theme/__tests__/theme.test.d.ts +2 -0
- package/dist/theme/__tests__/theme.test.d.ts.map +1 -0
- package/dist/theme/__tests__/theme.test.js +103 -0
- package/dist/theme/__tests__/theme.test.js.map +1 -0
- package/dist/theme/constants.d.ts +29 -0
- package/dist/theme/constants.d.ts.map +1 -0
- package/dist/theme/constants.js +48 -0
- package/dist/theme/constants.js.map +1 -0
- package/dist/theme/index.d.ts +31 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +36 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-context.d.ts +40 -0
- package/dist/theme/theme-context.d.ts.map +1 -0
- package/dist/theme/theme-context.js +60 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/theme/theme-script.d.ts +27 -0
- package/dist/theme/theme-script.d.ts.map +1 -0
- package/dist/theme/theme-script.js +147 -0
- package/dist/theme/theme-script.js.map +1 -0
- package/dist/theme/types.d.ts +163 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +11 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme/use-theme.d.ts +12 -0
- package/dist/theme/use-theme.d.ts.map +1 -0
- package/dist/theme/use-theme.js +40 -0
- package/dist/theme/use-theme.js.map +1 -0
- package/dist/types.d.ts +1479 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/urls.d.ts +441 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.gen.d.ts +8 -0
- package/dist/urls.gen.d.ts.map +1 -0
- package/dist/urls.gen.js +8 -0
- package/dist/urls.gen.js.map +1 -0
- package/dist/urls.js +443 -0
- package/dist/urls.js.map +1 -0
- package/dist/use-loader.d.ts +127 -0
- package/dist/use-loader.d.ts.map +1 -0
- package/dist/use-loader.js +237 -0
- package/dist/use-loader.js.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts +2 -0
- package/dist/vite/__tests__/ast-handler-extract.test.d.ts.map +1 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js +294 -0
- package/dist/vite/__tests__/ast-handler-extract.test.js.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-id-utils.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-id-utils.test.js +224 -0
- package/dist/vite/__tests__/expose-id-utils.test.js.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-internal-ids.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js +647 -0
- package/dist/vite/__tests__/expose-internal-ids.test.js.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts +2 -0
- package/dist/vite/__tests__/expose-router-id.test.d.ts.map +1 -0
- package/dist/vite/__tests__/expose-router-id.test.js +39 -0
- package/dist/vite/__tests__/expose-router-id.test.js.map +1 -0
- package/dist/vite/ast-handler-extract.d.ts +49 -0
- package/dist/vite/ast-handler-extract.d.ts.map +1 -0
- package/dist/vite/ast-handler-extract.js +249 -0
- package/dist/vite/ast-handler-extract.js.map +1 -0
- package/dist/vite/expose-action-id.d.ts +19 -0
- package/dist/vite/expose-action-id.d.ts.map +1 -0
- package/dist/vite/expose-action-id.js +250 -0
- package/dist/vite/expose-action-id.js.map +1 -0
- package/dist/vite/expose-id-utils.d.ts +69 -0
- package/dist/vite/expose-id-utils.d.ts.map +1 -0
- package/dist/vite/expose-id-utils.js +289 -0
- package/dist/vite/expose-id-utils.js.map +1 -0
- package/dist/vite/expose-internal-ids.d.ts +22 -0
- package/dist/vite/expose-internal-ids.d.ts.map +1 -0
- package/dist/vite/expose-internal-ids.js +886 -0
- package/dist/vite/expose-internal-ids.js.map +1 -0
- package/dist/vite/index.d.ts +149 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +5994 -2763
- package/dist/vite/index.js.bak +5448 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/index.named-routes.gen.ts +103 -0
- package/dist/vite/package-resolution.d.ts +43 -0
- package/dist/vite/package-resolution.d.ts.map +1 -0
- package/{src/vite/package-resolution.ts → dist/vite/package-resolution.js} +53 -66
- package/dist/vite/package-resolution.js.map +1 -0
- package/dist/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/dist/vite/virtual-entries.d.ts +25 -0
- package/dist/vite/virtual-entries.d.ts.map +1 -0
- package/{src/vite/virtual-entries.ts → dist/vite/virtual-entries.js} +12 -16
- package/dist/vite/virtual-entries.js.map +1 -0
- package/package.json +64 -54
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +252 -0
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +484 -0
- package/skills/caching/SKILL.md +202 -24
- package/skills/composability/SKILL.md +197 -0
- package/skills/css/SKILL.md +76 -0
- package/skills/debug-manifest/SKILL.md +12 -8
- package/skills/document-cache/SKILL.md +87 -62
- package/skills/fonts/SKILL.md +6 -4
- package/skills/handler-use/SKILL.md +364 -0
- package/skills/hooks/SKILL.md +537 -70
- package/skills/host-router/SKILL.md +264 -0
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +173 -8
- package/skills/layout/SKILL.md +123 -5
- package/skills/links/SKILL.md +304 -25
- package/skills/loader/SKILL.md +600 -54
- package/skills/middleware/SKILL.md +211 -37
- package/skills/migrate-nextjs/SKILL.md +562 -0
- package/skills/migrate-react-router/SKILL.md +769 -0
- package/skills/mime-routes/SKILL.md +41 -10
- package/skills/observability/SKILL.md +137 -0
- package/skills/parallel/SKILL.md +271 -3
- package/skills/prerender/SKILL.md +413 -52
- package/skills/rango/SKILL.md +301 -21
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +248 -120
- package/skills/route/SKILL.md +279 -21
- package/skills/router-setup/SKILL.md +211 -33
- package/skills/server-actions/SKILL.md +751 -0
- package/skills/streams-and-websockets/SKILL.md +283 -0
- package/skills/tailwind/SKILL.md +27 -3
- package/skills/theme/SKILL.md +9 -8
- package/skills/typesafety/SKILL.md +547 -107
- package/skills/use-cache/SKILL.md +353 -0
- package/skills/view-transitions/SKILL.md +294 -0
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +116 -0
- package/src/__internal.ts +102 -4
- package/src/bin/rango.ts +312 -15
- package/src/browser/action-coordinator.ts +114 -0
- package/src/browser/app-shell.ts +39 -0
- package/src/browser/app-version.ts +14 -0
- package/src/browser/event-controller.ts +172 -128
- package/src/browser/history-state.ts +101 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/link-interceptor.ts +24 -4
- package/src/browser/logging.ts +11 -0
- package/src/browser/merge-segment-loaders.ts +20 -12
- package/src/browser/navigation-bridge.ts +309 -562
- package/src/browser/navigation-client.ts +206 -75
- package/src/browser/navigation-store.ts +80 -63
- package/src/browser/navigation-transaction.ts +279 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +355 -314
- package/src/browser/prefetch/cache.ts +363 -0
- package/src/browser/prefetch/fetch.ts +350 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +48 -0
- package/src/browser/prefetch/queue.ts +191 -0
- package/src/browser/prefetch/resource-ready.ts +77 -0
- package/src/browser/rango-state.ts +136 -0
- package/src/browser/react/Link.tsx +255 -71
- package/src/browser/react/NavigationProvider.tsx +153 -33
- package/src/browser/react/context.ts +11 -0
- package/src/browser/react/filter-segment-order.ts +55 -0
- package/src/browser/react/index.ts +15 -12
- package/src/browser/react/location-state-shared.ts +269 -56
- package/src/browser/react/location-state.ts +90 -19
- package/src/browser/react/mount-context.ts +6 -1
- package/src/browser/react/nonce-context.ts +23 -0
- package/src/browser/react/shallow-equal.ts +27 -0
- package/src/browser/react/use-action.ts +29 -51
- package/src/browser/react/use-client-cache.ts +5 -3
- package/src/browser/react/use-handle.ts +41 -123
- package/src/browser/react/use-link-status.ts +6 -5
- package/src/browser/react/use-navigation.ts +44 -65
- package/src/browser/react/use-params.ts +77 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +97 -0
- package/src/browser/react/use-search-params.ts +56 -0
- package/src/browser/react/use-segments.ts +85 -99
- package/src/browser/response-adapter.ts +124 -0
- package/src/browser/rsc-router.tsx +275 -72
- package/src/browser/scroll-restoration.ts +132 -49
- package/src/browser/segment-reconciler.ts +243 -0
- package/src/browser/segment-structure-assert.ts +17 -1
- package/src/browser/server-action-bridge.ts +508 -610
- package/src/browser/shallow.ts +6 -1
- package/src/browser/types.ts +149 -48
- package/src/browser/validate-redirect-origin.ts +29 -0
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +123 -56
- package/src/build/generate-route-types.ts +41 -1029
- package/src/build/index.ts +4 -0
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +127 -31
- package/src/build/route-types/ast-helpers.ts +25 -0
- package/src/build/route-types/ast-route-extraction.ts +98 -0
- package/src/build/route-types/codegen.ts +102 -0
- package/src/build/route-types/include-resolution.ts +418 -0
- package/src/build/route-types/param-extraction.ts +48 -0
- package/src/build/route-types/per-module-writer.ts +131 -0
- package/src/build/route-types/router-processing.ts +659 -0
- package/src/build/route-types/scan-filter.ts +85 -0
- package/src/build/route-types/source-scan.ts +118 -0
- package/src/build/runtime-discovery.ts +220 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-key-utils.ts +44 -0
- package/src/cache/cache-policy.ts +125 -0
- package/src/cache/cache-runtime.ts +354 -0
- package/src/cache/cache-scope.ts +170 -308
- package/src/cache/cf/cf-cache-store.ts +716 -30
- package/src/cache/cf/index.ts +13 -3
- package/src/cache/document-cache.ts +116 -77
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +144 -0
- package/src/cache/index.ts +1 -15
- package/src/cache/memory-segment-store.ts +192 -13
- package/src/cache/profile-registry.ts +73 -0
- package/src/cache/read-through-swr.ts +134 -0
- package/src/cache/segment-codec.ts +256 -0
- package/src/cache/taint.ts +153 -0
- package/src/cache/types.ts +78 -124
- package/src/client.rsc.tsx +6 -1
- package/src/client.tsx +117 -322
- package/src/component-utils.ts +4 -4
- package/src/components/DefaultDocument.tsx +5 -1
- package/src/context-var.ts +156 -0
- package/src/debug.ts +19 -9
- package/src/decode-loader-results.ts +36 -0
- package/src/errors.ts +106 -10
- package/src/handle.ts +54 -11
- package/src/handles/MetaTags.tsx +73 -20
- package/src/handles/breadcrumbs.ts +66 -0
- package/src/handles/index.ts +1 -0
- package/src/handles/meta.ts +30 -13
- package/src/host/cookie-handler.ts +21 -15
- package/src/host/errors.ts +8 -8
- package/src/host/index.ts +6 -9
- package/src/host/pattern-matcher.ts +27 -27
- package/src/host/router.ts +176 -82
- package/src/host/testing.ts +8 -8
- package/src/host/types.ts +46 -9
- package/src/host/utils.ts +2 -2
- package/src/href-client.ts +196 -57
- package/src/index.rsc.ts +112 -42
- package/src/index.ts +178 -74
- package/src/internal-debug.ts +9 -3
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +15 -93
- package/src/loader.ts +20 -10
- package/src/missing-id-error.ts +68 -0
- package/src/network-error-thrower.tsx +3 -1
- package/src/outlet-context.ts +1 -1
- package/src/outlet-provider.tsx +45 -0
- package/src/prerender/param-hash.ts +4 -2
- package/src/prerender/store.ts +125 -18
- package/src/prerender.ts +389 -23
- package/src/response-utils.ts +37 -0
- package/src/reverse.ts +198 -128
- package/src/root-error-boundary.tsx +41 -29
- package/src/route-content-wrapper.tsx +13 -32
- package/src/route-definition/dsl-helpers.ts +1109 -0
- package/src/route-definition/helper-factories.ts +90 -0
- package/src/route-definition/helpers-types.ts +506 -0
- package/src/route-definition/index.ts +55 -0
- package/src/route-definition/redirect.ts +101 -0
- package/src/route-definition/resolve-handler-use.ts +155 -0
- package/src/route-definition/use-item-types.ts +32 -0
- package/src/route-definition.ts +1 -1450
- package/src/route-map-builder.ts +87 -133
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +72 -41
- package/src/router/content-negotiation.ts +228 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +10 -10
- package/src/router/find-match.ts +208 -0
- package/src/router/handler-context.ts +372 -125
- package/src/router/intercept-resolution.ts +24 -26
- package/src/router/lazy-includes.ts +256 -0
- package/src/router/loader-resolution.ts +367 -140
- package/src/router/logging.ts +112 -6
- package/src/router/manifest.ts +89 -28
- package/src/router/match-api.ts +175 -238
- package/src/router/match-context.ts +4 -2
- package/src/router/match-handlers.ts +441 -0
- package/src/router/match-middleware/background-revalidation.ts +97 -89
- package/src/router/match-middleware/cache-lookup.ts +289 -54
- package/src/router/match-middleware/cache-store.ts +78 -17
- package/src/router/match-middleware/intercept-resolution.ts +45 -22
- package/src/router/match-middleware/segment-resolution.ts +73 -9
- package/src/router/match-pipelines.ts +10 -45
- package/src/router/match-result.ts +146 -24
- package/src/router/metrics.ts +241 -16
- package/src/router/middleware-cookies.ts +55 -0
- package/src/router/middleware-types.ts +209 -0
- package/src/router/middleware.ts +354 -384
- package/src/router/navigation-snapshot.ts +182 -0
- package/src/router/pattern-matching.ts +279 -44
- package/src/router/prerender-match.ts +527 -0
- package/src/router/preview-match.ts +100 -0
- package/src/router/request-classification.ts +313 -0
- package/src/router/revalidation.ts +163 -16
- package/src/router/route-snapshot.ts +245 -0
- package/src/router/router-context.ts +41 -21
- package/src/router/router-interfaces.ts +500 -0
- package/src/router/router-options.ts +642 -0
- package/src/router/router-registry.ts +21 -0
- package/src/router/segment-resolution/fresh.ts +769 -0
- package/src/router/segment-resolution/helpers.ts +268 -0
- package/src/router/segment-resolution/loader-cache.ts +199 -0
- package/src/router/segment-resolution/revalidation.ts +1420 -0
- package/src/router/segment-resolution/static-store.ts +81 -0
- package/src/router/segment-resolution/view-transition-default.ts +36 -0
- package/src/router/segment-resolution.ts +21 -1354
- package/src/router/segment-wrappers.ts +291 -0
- package/src/router/substitute-pattern-params.ts +56 -0
- package/src/router/telemetry-otel.ts +299 -0
- package/src/router/telemetry.ts +300 -0
- package/src/router/timeout.ts +148 -0
- package/src/router/trie-matching.ts +133 -42
- package/src/router/types.ts +24 -9
- package/src/router/url-params.ts +49 -0
- package/src/router.ts +710 -2373
- package/src/rsc/handler-context.ts +45 -0
- package/src/rsc/handler.ts +821 -1128
- package/src/rsc/helpers.ts +182 -19
- package/src/rsc/index.ts +1 -21
- package/src/rsc/loader-fetch.ts +229 -0
- package/src/rsc/manifest-init.ts +77 -0
- package/src/rsc/nonce.ts +14 -0
- package/src/rsc/origin-guard.ts +161 -0
- package/src/rsc/progressive-enhancement.ts +395 -0
- package/src/rsc/response-error.ts +104 -0
- package/src/rsc/response-route-handler.ts +362 -0
- package/src/rsc/rsc-rendering.ts +240 -0
- package/src/rsc/runtime-warnings.ts +41 -0
- package/src/rsc/server-action.ts +350 -0
- package/src/rsc/ssr-setup.ts +144 -0
- package/src/rsc/types.ts +52 -11
- package/src/search-params.ts +70 -58
- package/src/segment-content-promise.ts +67 -0
- package/src/segment-loader-promise.ts +122 -0
- package/src/segment-system.tsx +237 -73
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +439 -85
- package/src/server/cookie-store.ts +214 -0
- package/src/server/fetchable-loader-store.ts +11 -6
- package/src/server/handle-store.ts +113 -15
- package/src/server/loader-registry.ts +24 -64
- package/src/server/request-context.ts +640 -107
- package/src/server.ts +26 -164
- package/src/ssr/index.tsx +107 -30
- package/src/static-handler.ts +39 -9
- package/src/theme/ThemeProvider.tsx +21 -15
- package/src/theme/ThemeScript.tsx +5 -5
- package/src/theme/constants.ts +5 -2
- package/src/theme/index.ts +4 -14
- package/src/theme/theme-context.ts +4 -30
- package/src/theme/theme-script.ts +21 -18
- package/src/types/boundaries.ts +158 -0
- package/src/types/cache-types.ts +198 -0
- package/src/types/error-types.ts +192 -0
- package/src/types/global-namespace.ts +113 -0
- package/src/types/handler-context.ts +809 -0
- package/src/types/index.ts +89 -0
- package/src/types/loader-types.ts +212 -0
- package/src/types/request-scope.ts +126 -0
- package/src/types/route-config.ts +170 -0
- package/src/types/route-entry.ts +120 -0
- package/src/types/segments.ts +184 -0
- package/src/types.ts +1 -1795
- package/src/urls/include-helper.ts +164 -0
- package/src/urls/index.ts +49 -0
- package/src/urls/path-helper-types.ts +386 -0
- package/src/urls/path-helper.ts +329 -0
- package/src/urls/pattern-types.ts +124 -0
- package/src/urls/response-types.ts +109 -0
- package/src/urls/type-extraction.ts +291 -0
- package/src/urls/urls-function.ts +94 -0
- package/src/urls.ts +1 -1323
- package/src/use-loader.tsx +559 -108
- package/src/vite/debug.ts +185 -0
- package/src/vite/discovery/bundle-postprocess.ts +181 -0
- package/src/vite/discovery/discover-routers.ts +379 -0
- package/src/vite/discovery/discovery-errors.ts +194 -0
- package/src/vite/discovery/gate-state.ts +171 -0
- package/src/vite/discovery/prerender-collection.ts +480 -0
- package/src/vite/discovery/route-types-writer.ts +214 -0
- package/src/vite/discovery/self-gen-tracking.ts +73 -0
- package/src/vite/discovery/state.ts +150 -0
- package/src/vite/discovery/virtual-module-codegen.ts +193 -0
- package/src/vite/index.ts +17 -2261
- package/src/vite/plugin-types.ts +170 -0
- package/src/vite/plugins/cjs-to-esm.ts +94 -0
- package/src/vite/plugins/client-ref-dedup.ts +131 -0
- package/src/vite/plugins/client-ref-hashing.ts +128 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.d.mts +23 -0
- package/src/vite/plugins/cloudflare-protocol-loader-hook.mjs +76 -0
- package/src/vite/plugins/cloudflare-protocol-stub.ts +214 -0
- package/src/vite/{expose-action-id.ts → plugins/expose-action-id.ts} +109 -60
- package/src/vite/{expose-id-utils.ts → plugins/expose-id-utils.ts} +32 -51
- package/src/vite/plugins/expose-ids/export-analysis.ts +376 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +156 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +72 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +127 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +796 -0
- package/src/vite/plugins/performance-tracks.ts +92 -0
- package/src/vite/plugins/refresh-cmd.ts +127 -0
- package/src/vite/plugins/use-cache-transform.ts +338 -0
- package/src/vite/plugins/version-injector.ts +99 -0
- package/src/vite/plugins/version-plugin.ts +323 -0
- package/src/vite/plugins/virtual-entries.ts +123 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +549 -0
- package/src/vite/router-discovery.ts +1567 -0
- package/src/vite/{ast-handler-extract.ts → utils/ast-handler-extract.ts} +194 -22
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +139 -0
- package/src/vite/utils/client-chunks.ts +190 -0
- package/src/vite/utils/forward-user-plugins.ts +193 -0
- package/src/vite/utils/manifest-utils.ts +19 -0
- package/src/vite/utils/package-resolution.ts +161 -0
- package/src/vite/utils/prerender-utils.ts +222 -0
- package/src/vite/utils/shared-utils.ts +251 -0
- package/CLAUDE.md +0 -43
- package/src/browser/lru-cache.ts +0 -69
- package/src/browser/request-controller.ts +0 -164
- package/src/cache/memory-store.ts +0 -253
- package/src/router.gen.ts +0 -6
- package/src/static-handler.gen.ts +0 -5
- package/src/urls.gen.ts +0 -8
- package/src/vite/expose-internal-ids.ts +0 -1167
- /package/src/vite/{version.d.ts → plugins/version.d.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bundle-analysis
|
|
3
|
+
description: Audit a Rango app's production bundle for server-side code leaking into the client, dev/prod React duplication, oversized chunks, and inefficient client-reference grouping. Use when investigating bundle size growth, before a production deploy, or when the client/SSR/RSC output suddenly balloons.
|
|
4
|
+
argument-hint: "<app-dir>"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Bundle Analysis
|
|
8
|
+
|
|
9
|
+
Use this when you want **proof** that your Rango app is shipping the bundles you expect: small client, no server leaks, no doubled React, reasonable RSC worker size.
|
|
10
|
+
|
|
11
|
+
## What this checks
|
|
12
|
+
|
|
13
|
+
Your app builds in three Vite environments — `client`, `ssr`, and `rsc` — and each ships its own bundle. The most common bundle bugs in a Rango app are:
|
|
14
|
+
|
|
15
|
+
1. **Server code leaking into the client.** A file that imports `node:fs`, calls a database, or contains action logic ends up in the client bundle because a client component pulled it in transitively. Symptom: your client bundle is much larger than expected, sometimes with imports that fail at runtime.
|
|
16
|
+
2. **Both dev and prod React in the SSR/RSC bundle.** When `process.env.NODE_ENV` isn't folded at build time, React's CJS files ship both `.development.js` _and_ `.production.js` variants — doubling React's footprint. The Cloudflare vite plugin folds NODE_ENV automatically; vanilla `vite build` does it for client but not always for SSR/RSC.
|
|
17
|
+
3. **An oversized routes-manifest in your RSC worker.** The `virtual:rsc-router/routes-manifest/<routerId>` chunk holds your route trie and precomputed entries — large only in proportion to your route count. If it's surprisingly big, you may have unintentionally generated routes (e.g., parametrized fixtures) that bloated the trie.
|
|
18
|
+
4. **Inefficient client-reference grouping.** Each `"use client"` boundary becomes a chunk. Too many small client components = many tiny chunks; one giant client component = one giant chunk that defeats code-splitting.
|
|
19
|
+
|
|
20
|
+
Tree-shaking does _not_ catch (1) generated data inlined as string literals or (2) data-dependent conditionals like React's. You need a visualizer.
|
|
21
|
+
|
|
22
|
+
## Step 1: Install the visualizer
|
|
23
|
+
|
|
24
|
+
In your app's directory:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm add -D rollup-plugin-visualizer
|
|
28
|
+
# or: npm install --save-dev rollup-plugin-visualizer
|
|
29
|
+
# or: yarn add -D rollup-plugin-visualizer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Step 2: Wire it into your `vite.config.ts`
|
|
33
|
+
|
|
34
|
+
Add a small helper that registers one visualizer instance **per Vite environment** (not just one global). The plugin caches its options after the first call, so a single instance can't handle multi-environment builds — you'll get a report for one environment and silence for the others.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// vite.config.ts
|
|
38
|
+
import { defineConfig, type PluginOption, type Plugin } from "vite";
|
|
39
|
+
import { visualizer } from "rollup-plugin-visualizer";
|
|
40
|
+
import { join } from "node:path";
|
|
41
|
+
// ... your other imports ...
|
|
42
|
+
|
|
43
|
+
function analyze(): PluginOption[] {
|
|
44
|
+
if (!process.env.ANALYZE) return [];
|
|
45
|
+
return (["client", "ssr", "rsc"] as const).map((envName) => {
|
|
46
|
+
const inner = visualizer({
|
|
47
|
+
filename: join("bundle-stats", `${envName}.html`),
|
|
48
|
+
template: "treemap",
|
|
49
|
+
gzipSize: true,
|
|
50
|
+
brotliSize: true,
|
|
51
|
+
}) as Plugin;
|
|
52
|
+
return {
|
|
53
|
+
...inner,
|
|
54
|
+
name: `analyze-${envName}`,
|
|
55
|
+
applyToEnvironment(env) {
|
|
56
|
+
return env.name === envName;
|
|
57
|
+
},
|
|
58
|
+
} as Plugin;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default defineConfig(({ command }) => ({
|
|
63
|
+
plugins: [
|
|
64
|
+
// your existing plugins...
|
|
65
|
+
...analyze(),
|
|
66
|
+
],
|
|
67
|
+
// For non-Cloudflare apps, fold NODE_ENV explicitly so React's CJS files
|
|
68
|
+
// emit only the .production.js variants in SSR/RSC. Skip if your build
|
|
69
|
+
// setup already does this (the Cloudflare vite plugin does).
|
|
70
|
+
define:
|
|
71
|
+
command === "build"
|
|
72
|
+
? { "process.env.NODE_ENV": JSON.stringify("production") }
|
|
73
|
+
: undefined,
|
|
74
|
+
}));
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Add `bundle-stats/` to your `.gitignore`.
|
|
78
|
+
|
|
79
|
+
## Step 3: Build with the analyzer enabled
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
ANALYZE=1 pnpm exec vite build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You'll get three HTML reports in `bundle-stats/`:
|
|
86
|
+
|
|
87
|
+
- `bundle-stats/client.html` — what runs in the browser
|
|
88
|
+
- `bundle-stats/ssr.html` — what runs during HTML stream
|
|
89
|
+
- `bundle-stats/rsc.html` — what runs in your RSC server (Worker / Node)
|
|
90
|
+
|
|
91
|
+
Open them with a quick local server (file:// has CORS issues with the embedded scripts):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm dlx serve -l 5050 .
|
|
95
|
+
# then visit http://localhost:5050/bundle-stats/client.html
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Step 4: Triage the reports
|
|
99
|
+
|
|
100
|
+
### Open `client.html` first
|
|
101
|
+
|
|
102
|
+
The treemap shows nested boxes; box area = uncompressed size. Hover for gzip/brotli numbers.
|
|
103
|
+
|
|
104
|
+
**Look for:**
|
|
105
|
+
|
|
106
|
+
- **Your server code.** Any of your own files that contain database queries, secret keys, server actions implementation (not the action _reference_), or `node:` imports. If they appear in the client treemap with non-zero bytes, they leaked. Common causes:
|
|
107
|
+
- A shared module that mixes client and server code without a `"use client"` or `"use server"` directive.
|
|
108
|
+
- A barrel file (`index.ts`) that re-exports both client and server symbols. Tree-shaking should help, but `JSON.parse('{...}')` data and side-effecting top-level statements survive.
|
|
109
|
+
- Client component imports a server-only utility through an indirect path (e.g., shared types file that pulls server modules).
|
|
110
|
+
- **Multiple copies of the same package.** Look for two boxes with the same package name but different version paths. Usually means a transitive dep pinned a different version.
|
|
111
|
+
- **The `@rangojs/router` chunk** should be roughly **50 KB gzip** (74 files). If significantly larger, you might be importing client-incompatible APIs from the wrong subpath.
|
|
112
|
+
- **Per-route client-reference chunks** (named like `chunk-<hash>.js`). Each `"use client"` boundary can become its own chunk. If you have hundreds of tiny chunks, you may have over-split (every leaf component as a client component); if you have one massive 200 KB chunk, you've under-split (a wide client tree behind one boundary).
|
|
113
|
+
|
|
114
|
+
### Now check `ssr.html`
|
|
115
|
+
|
|
116
|
+
**Look for:**
|
|
117
|
+
|
|
118
|
+
- **`react-dom-server.edge.development-*.js`** (or any `*.development*.js` chunk). This is the dev/prod React doubling. Fix: add `define: { "process.env.NODE_ENV": '"production"' }` to your vite config (see Step 2).
|
|
119
|
+
- **Your client components** appearing in SSR. They're _expected_ here — SSR hydration needs to produce HTML for them. The same components show up in `client.html` too because the browser hydrates them. This is not a leak.
|
|
120
|
+
- **Total SSR size**: a reasonable Rango SSR is ~140 KB gzip plus your app code. If it's >300 KB, almost always (1) dev/prod React duplication or (2) a giant data structure being inlined.
|
|
121
|
+
|
|
122
|
+
### Now check `rsc.html`
|
|
123
|
+
|
|
124
|
+
**Look for:**
|
|
125
|
+
|
|
126
|
+
- **`virtual:rsc-router/routes-manifest`** should be **tiny** (< 1 KB). If it's > 100 KB, you're on an old version of `@rangojs/router` that inlined the trie eagerly — upgrade to a release that includes commit `d10a2470`.
|
|
127
|
+
- **`virtual:rsc-router/routes-manifest/<hash>`** is the lazy per-router chunk. Its size is proportional to your route count. For a typical app: 5–50 KB gzip. For a stress-test app with thousands of routes: hundreds of KB. If yours is unexpectedly huge, check whether you're generating routes you don't need.
|
|
128
|
+
- **`<your-router>.named-routes.gen.ts`** — generated route map. Should match your route count.
|
|
129
|
+
- **Your action and loader implementations** — these run server-side. Expected to be here, not in client.
|
|
130
|
+
- **Worker-incompatible code** (Node-only imports like `node:fs` that Cloudflare doesn't support). The build will usually fail before the analyzer runs, but if you're seeing runtime errors at the edge, the RSC treemap shows what made it in.
|
|
131
|
+
|
|
132
|
+
## Step 5: Fix what you find
|
|
133
|
+
|
|
134
|
+
| Finding | Fix |
|
|
135
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
136
|
+
| Your server code in `client.html` (non-zero bytes) | Audit the import chain. Add `"use server"` to server-only files. Move shared data out of barrel files. Use the `@rangojs/router/server` subpath for explicitly server APIs. |
|
|
137
|
+
| Your server code in `client.html` listed but 0 bytes | Tree-shaking already eliminated it. Cosmetic. Leave it. |
|
|
138
|
+
| `react-dom-server.edge.development-*.js` in SSR or RSC | Add the `define` block from Step 2 to your vite config. |
|
|
139
|
+
| Routes-manifest > 100 KB gzip in RSC eager chunk | Update `@rangojs/router` to a release that includes the lazy-only manifest fix. |
|
|
140
|
+
| Same package version present twice | Run `pnpm dedupe` (or `npm dedupe`). If the duplication persists, a transitive dep pins an incompatible version — open a PR upstream or pin the resolution. |
|
|
141
|
+
| Client chunk > 500 KB gzip with a single dominant module | That module is your largest client component. Consider lazy-loading via dynamic `import()` or moving non-interactive parts to server components. |
|
|
142
|
+
| Hundreds of tiny client chunks | You've sprinkled `"use client"` too liberally. Hoist directives to higher boundaries so React groups them. |
|
|
143
|
+
|
|
144
|
+
## When to re-run
|
|
145
|
+
|
|
146
|
+
- Before every production deploy, especially after adding new dependencies.
|
|
147
|
+
- After upgrading `@rangojs/router`, React, or `@vitejs/plugin-rsc`.
|
|
148
|
+
- After adding routes that scale with data (e.g., one route per item from a content directory) — the manifest may have grown.
|
|
149
|
+
- When CI starts reporting larger artifact sizes.
|
|
150
|
+
|
|
151
|
+
## Reporting Rango regressions
|
|
152
|
+
|
|
153
|
+
If a finding looks like a `@rangojs/router` regression (the framework is shipping more than it should, not your app), open an issue at the [@rangojs/router GitHub](https://github.com/ivogt/vite-rsc/issues) and include:
|
|
154
|
+
|
|
155
|
+
- The output of `client.html` / `rsc.html` (screenshots or the JSON `data = {...}` block from the HTML).
|
|
156
|
+
- The `@rangojs/router` version (`pnpm why @rangojs/router`).
|
|
157
|
+
- Your `vite.config.ts`.
|
|
158
|
+
|
|
159
|
+
The framework maintainers run a similar audit internally — the methodology in this skill mirrors what they use to validate every release.
|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cache-guide
|
|
3
|
+
description: When to use cache() DSL vs "use cache" directive — key differences and decision guide
|
|
4
|
+
argument-hint:
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# cache() vs "use cache" — When to Use Which
|
|
8
|
+
|
|
9
|
+
Both mechanisms share the same backing store and cache profiles, and both accept
|
|
10
|
+
an optional `tags` field (not yet honored by the built-in stores — see "Two axes"
|
|
11
|
+
below). They differ in scope, cache key, execution model, and runtime control.
|
|
12
|
+
|
|
13
|
+
## Two axes — do not conflate
|
|
14
|
+
|
|
15
|
+
Everything on this page is **axis 1: stored-value freshness** — _is a cached
|
|
16
|
+
value still good?_ There is a second, orthogonal axis it is easy to mistake for
|
|
17
|
+
caching:
|
|
18
|
+
|
|
19
|
+
1. **Stored-value freshness** — _is a cached value still good?_
|
|
20
|
+
→ `"use cache"` (fn/component), `cache()` (segment), loader `cache()` (loader data).
|
|
21
|
+
Entries expire by **TTL/SWR**. They accept an optional `tags` field, but the
|
|
22
|
+
built-in stores (`MemorySegmentCacheStore`, `CFCacheStore`) do not yet index or
|
|
23
|
+
invalidate by tag, so tag-based invalidation (`revalidateTag`) is a
|
|
24
|
+
forward-looking API requiring a custom store with secondary indices.
|
|
25
|
+
2. **Client-update selection** — _should this segment re-run and stream to the
|
|
26
|
+
client on this navigation/action?_
|
|
27
|
+
→ `revalidate()`. Covered in `/loader` and `/route`, **not here**.
|
|
28
|
+
|
|
29
|
+
They are orthogonal and compose: a segment selected by `revalidate()` still
|
|
30
|
+
consults its cache (hit → no recompute); a cache bust does **not** force a client
|
|
31
|
+
update, and `revalidate()` never reads, writes, or expires a cached value. If you
|
|
32
|
+
know React Router, `revalidate()` is `shouldRevalidate`, not `Cache-Control`. See
|
|
33
|
+
`/rango` → "Coming from another framework" for the cross-framework mapping.
|
|
34
|
+
|
|
35
|
+
## Fast choice
|
|
36
|
+
|
|
37
|
+
Read this first; use the rest of the page when the choice has edge cases.
|
|
38
|
+
|
|
39
|
+
1. Do you want to cache an entire route or group of routes?
|
|
40
|
+
**Yes** -> `cache()`
|
|
41
|
+
2. Do you need runtime conditions, such as skip for authed users or key by
|
|
42
|
+
locale?
|
|
43
|
+
**Yes** -> `cache()` with `condition` / `key`
|
|
44
|
+
3. Do you want to cache a data fetch or helper shared across routes?
|
|
45
|
+
**Yes** -> `"use cache"`
|
|
46
|
+
4. Do you need different cache entries for different function arguments?
|
|
47
|
+
**Yes** -> `"use cache"` (keyed by args)
|
|
48
|
+
5. Is the expensive part rendering a subtree?
|
|
49
|
+
**Yes** -> `cache()` (caches rendered segments)
|
|
50
|
+
6. Is the expensive part one query inside a larger live handler?
|
|
51
|
+
**Yes** -> `"use cache"` on the query function
|
|
52
|
+
|
|
53
|
+
## Correctness & invalidation
|
|
54
|
+
|
|
55
|
+
rango's caches are built so a hit can't serve wrong or stale-shaped data. These
|
|
56
|
+
guarantees are mostly automatic — worth knowing so you don't reimplement
|
|
57
|
+
protection the framework already gives you (or assume one it deliberately
|
|
58
|
+
doesn't).
|
|
59
|
+
|
|
60
|
+
There are two guard models to keep separate. Both block response side effects
|
|
61
|
+
(`ctx.header()`, cookie writes) that would be lost on a hit; they differ in what
|
|
62
|
+
else they allow:
|
|
63
|
+
|
|
64
|
+
- **`cache()` boundary guard** (route-level) — fires while the handler runs on a
|
|
65
|
+
miss. `cookies()` and `headers()` throw (request-scoped data would be baked into
|
|
66
|
+
the shared cached shell), `ctx.get(nonCacheableVar)` throws (a tainted value
|
|
67
|
+
would be baked in), and response side effects (`ctx.header()`, `ctx.setCookie()`,
|
|
68
|
+
`ctx.setStatus()`, `ctx.onResponse()`) throw. `ctx.set()` of a cacheable var is
|
|
69
|
+
**allowed** — children are cached too and can read it. **Loaders are exempt**
|
|
70
|
+
(they always run fresh) — read request data inside a loader.
|
|
71
|
+
- **`"use cache"` exec-guard** (function-level) — the same request-scoped APIs
|
|
72
|
+
throw inside the cached function (`cookies()`, `headers()`, `ctx.set()`,
|
|
73
|
+
`ctx.header()`); additionally, tainted `ctx`/`env`/`req` args are excluded from
|
|
74
|
+
the cache key.
|
|
75
|
+
|
|
76
|
+
### Cross-deploy safety: version-segmented store keys
|
|
77
|
+
|
|
78
|
+
`CFCacheStore` prefixes every **physical** store key (the CF Cache API URL and
|
|
79
|
+
the KV key) with the build version — auto-generated from the
|
|
80
|
+
`@rangojs/router:version` virtual module, overridable via the store's `version`
|
|
81
|
+
option. A new deploy reads under a new prefix, so it can **never** read a
|
|
82
|
+
previous build's entries: no cross-deploy shape drift, and no dead client-chunk
|
|
83
|
+
references baked into cached RSC.
|
|
84
|
+
|
|
85
|
+
The tradeoff to know: **loader/data caches use the same store**, so they're
|
|
86
|
+
version-segmented too. Every deploy is therefore a _cold data cache_ — SWR can't
|
|
87
|
+
soften it, because no stale entry exists under the new key. For high-traffic,
|
|
88
|
+
frequently-deploying, data-bound apps that's a deploy-time origin warm-up. Decide
|
|
89
|
+
deliberately: accept it (correctness over hit-rate), or split the policy — let
|
|
90
|
+
the render/edge cache auto-version while a separate data store gets a stable
|
|
91
|
+
`version` so its entries survive deploys. (Per-process stores like
|
|
92
|
+
`MemorySegmentCacheStore` are cold on every restart anyway; this matters for
|
|
93
|
+
persistent stores.) See `/caching` for store setup.
|
|
94
|
+
|
|
95
|
+
### Client cache: forward/back is mutation-aware
|
|
96
|
+
|
|
97
|
+
The browser keeps a history (forward/back) cache of rendered segments. Any
|
|
98
|
+
client-side mutation (a server action) marks those entries **stale** and
|
|
99
|
+
broadcasts it to other tabs. On back/forward (popstate) the router looks up the
|
|
100
|
+
entry, sees it's stale, and revalidates — so your `revalidate()` predicates re-run
|
|
101
|
+
and the segment refreshes (SWR: the stale view paints instantly, fresh data
|
|
102
|
+
streams in). It's the client-side analog of the server-cache correctness problem,
|
|
103
|
+
solved on the partial-render axis.
|
|
104
|
+
|
|
105
|
+
### Request-scoped data: the `cache: false` taint
|
|
106
|
+
|
|
107
|
+
`createVar({ cache: false })` (or a `ctx.set(var, v, { cache: false })` write)
|
|
108
|
+
taints a value as request-scoped; reading it **directly** with `ctx.get()` inside
|
|
109
|
+
a `cache()` boundary throws — the guard against the catastrophic "serve user A's
|
|
110
|
+
data to user B" bug. The guarantee is precise and intentionally narrow — see
|
|
111
|
+
"Context Variable Cache Safety" below for exactly what it does and does not catch.
|
|
112
|
+
|
|
113
|
+
## Stale-while-revalidate
|
|
114
|
+
|
|
115
|
+
SWR is a first-class cache behavior when the backing store supports it: while an
|
|
116
|
+
entry is within its SWR window the cache serves the **stale value instantly** and
|
|
117
|
+
refreshes it in the **background** (`waitUntil`), so users never wait on a
|
|
118
|
+
recompute for a merely-aging entry.
|
|
119
|
+
|
|
120
|
+
- **`"use cache"`** resolves to the `default` profile `{ ttl: 900, swr: 1800 }`,
|
|
121
|
+
so function/component caching gets a 30-minute SWR window **out of the box**.
|
|
122
|
+
Tune or add profiles via `createRouter({ cacheProfiles: { … } })`
|
|
123
|
+
(`"use cache: short"` → the `short` profile).
|
|
124
|
+
- **`cache()` DSL and loader caches** take an explicit `swr` in seconds (or
|
|
125
|
+
inherit `store.defaults.swr`): `cache({ ttl: 60, swr: 300 })` → fresh ≤60s,
|
|
126
|
+
stale-served 60–360s, miss after 360s in stores that implement SWR for that
|
|
127
|
+
layer.
|
|
128
|
+
- **Client forward/back** is SWR after a mutation — see "Correctness &
|
|
129
|
+
invalidation" → Client cache.
|
|
130
|
+
- **Edge / document layer** uses the HTTP `stale-while-revalidate` directive; see
|
|
131
|
+
`/document-cache`.
|
|
132
|
+
|
|
133
|
+
SWR softens normal TTL expiry, **not** a cross-deploy cold cache — a new build
|
|
134
|
+
has no stale entry to serve (see version-segmented store keys above).
|
|
135
|
+
|
|
136
|
+
Store support is layer-specific. `CFCacheStore` supports SWR for segment,
|
|
137
|
+
document/response, and `"use cache"` item entries. `MemorySegmentCacheStore`
|
|
138
|
+
supports SWR for response and `"use cache"` item entries, but its route-segment
|
|
139
|
+
entries expire at TTL and never background-revalidate. Use the memory store for
|
|
140
|
+
local/dev behavior, not as proof that segment SWR is active.
|
|
141
|
+
|
|
142
|
+
## Key Differences
|
|
143
|
+
|
|
144
|
+
| | `cache()` DSL | `"use cache"` directive |
|
|
145
|
+
| -------------------- | ----------------------------------------------------- | -------------------------------------------------- |
|
|
146
|
+
| **Scope** | Route segment tree (handler + children + parallels) | Single function return value |
|
|
147
|
+
| **Defined at** | Route definition site (`urls.ts`) | Inside function body or at file top |
|
|
148
|
+
| **Cache key** | Request type + pathname + params (+ optional custom) | Function identity + serialized non-tainted args |
|
|
149
|
+
| **Execution on hit** | All-or-nothing: entire handler skipped | Partial: function body skipped, calling code runs |
|
|
150
|
+
| **Runtime control** | `condition` to disable, custom `key` function | None — if the directive is present, it caches |
|
|
151
|
+
| **Side effects** | Response side effects throw inside the boundary | `ctx.header()`, `ctx.set()`, etc. throw at runtime |
|
|
152
|
+
| **Handle data** | Captured and replayed | Captured and replayed |
|
|
153
|
+
| **Loaders** | Always fresh — excluded from cache, opt-in per loader | Can be used inside loaders |
|
|
154
|
+
| **Nesting** | Nest `cache()` boundaries with different TTLs | Compose by calling cached functions from uncached |
|
|
155
|
+
|
|
156
|
+
### cache() Cache Key
|
|
157
|
+
|
|
158
|
+
The key is `{requestType}:{pathname}:{params}` where requestType is one of
|
|
159
|
+
`doc:`, `partial:`, or `intercept:`. This means the same URL cached separately
|
|
160
|
+
for full document loads, client navigations, and intercept navigations.
|
|
161
|
+
|
|
162
|
+
Custom `key` functions can segment the cache further (e.g., by user role or locale).
|
|
163
|
+
`condition` can disable caching entirely at runtime (e.g., skip for authenticated users).
|
|
164
|
+
|
|
165
|
+
### "use cache" Cache Key
|
|
166
|
+
|
|
167
|
+
The key is `use-cache:{functionId}:{serializedArgs}` where functionId is a stable
|
|
168
|
+
ID from the Vite transform (module path + export name) and args are serialized via
|
|
169
|
+
RSC `encodeReply()`. Tainted arguments (ctx, env, req) are excluded.
|
|
170
|
+
|
|
171
|
+
## Execution Model
|
|
172
|
+
|
|
173
|
+
This is the most important distinction.
|
|
174
|
+
|
|
175
|
+
### cache() — all-or-nothing
|
|
176
|
+
|
|
177
|
+
On cache hit, the cache-lookup middleware short-circuits the entire pipeline.
|
|
178
|
+
No handler code runs. On miss, all handlers execute normally and segments are
|
|
179
|
+
stored.
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
HIT → cached segments served, loaders resolved fresh, no handler runs
|
|
183
|
+
MISS → all handlers run, segments cached, response built normally
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Headers, cookies, and ctx.set() calls inside handlers naturally don't execute on
|
|
187
|
+
hit. There is no partial execution, so no runtime guards are needed.
|
|
188
|
+
|
|
189
|
+
### "use cache" — partial execution
|
|
190
|
+
|
|
191
|
+
Only the wrapped function body is skipped on hit. The code that calls the
|
|
192
|
+
cached function still runs. This means ctx side effects inside the cached body
|
|
193
|
+
would silently disappear on hit.
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
HIT → function body skipped, calling code runs, handle data replayed
|
|
197
|
+
MISS → function body runs, return value + handle data cached
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Runtime guards throw if you call cookies(), headers(), ctx.header(), ctx.set(),
|
|
201
|
+
ctx.onResponse(), ctx.setTheme(), or ctx.setLocationState() inside a "use cache"
|
|
202
|
+
function. cookies() and headers() are blocked because per-request data is not in the
|
|
203
|
+
cache key. Side-effect methods are blocked because their effects are lost on hit.
|
|
204
|
+
Use ctx.use(Handle) instead for data — handle data is captured and replayed.
|
|
205
|
+
|
|
206
|
+
## When to Use cache()
|
|
207
|
+
|
|
208
|
+
Use the route-level `cache()` DSL when:
|
|
209
|
+
|
|
210
|
+
- **Caching entire routes or sections** — wrap a set of paths with one TTL.
|
|
211
|
+
- **You need runtime control** — disable caching for authenticated users with
|
|
212
|
+
`condition`, or segment cache keys by user/locale with `key`.
|
|
213
|
+
- **UI rendering is expensive** — the cached segments include the rendered
|
|
214
|
+
component tree, skipping RSC rendering on hit.
|
|
215
|
+
- **You want one cache entry per URL** — keyed on pathname + params, not on
|
|
216
|
+
function arguments.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
export const urlpatterns = urls(({ path, cache }) => [
|
|
220
|
+
cache({ ttl: 300, condition: (ctx) => !ctx.get("user") }, () => [
|
|
221
|
+
path("/blog", BlogIndex, { name: "blog" }),
|
|
222
|
+
path("/blog/:slug", BlogPost, { name: "blogPost" }),
|
|
223
|
+
]),
|
|
224
|
+
]);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## When to Use "use cache"
|
|
228
|
+
|
|
229
|
+
Use the `"use cache"` directive when:
|
|
230
|
+
|
|
231
|
+
- **Caching a specific data fetch** — one database query used across multiple
|
|
232
|
+
routes or components.
|
|
233
|
+
- **Different call sites need different cache entries** — the cache key includes
|
|
234
|
+
all non-tainted arguments, so `getProduct("a")` and `getProduct("b")` cache
|
|
235
|
+
separately.
|
|
236
|
+
- **Fine-grained caching within a handler** — cache the expensive part, keep
|
|
237
|
+
ctx side effects outside.
|
|
238
|
+
- **Caching an RSC component** — a component that fetches its own data can cache
|
|
239
|
+
its entire render.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
async function getProductData(slug: string) {
|
|
243
|
+
"use cache: short";
|
|
244
|
+
return await db.query("SELECT * FROM products WHERE slug = ?", [slug]);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Handler calls cached function, sets headers outside
|
|
248
|
+
async function ProductPage(ctx) {
|
|
249
|
+
const data = await getProductData(ctx.params.slug);
|
|
250
|
+
ctx.header("X-Product", data.id);
|
|
251
|
+
return <Product data={data} />;
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Combining Both
|
|
256
|
+
|
|
257
|
+
They compose naturally. Use `cache()` for the route boundary and `"use cache"`
|
|
258
|
+
for shared data functions:
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// urls.tsx — route-level cache for the rendered segment tree
|
|
262
|
+
cache({ ttl: 60 }, () => [
|
|
263
|
+
path("/product/:slug", ProductPage, { name: "product" }),
|
|
264
|
+
]);
|
|
265
|
+
|
|
266
|
+
// data.ts — function-level cache for the database query
|
|
267
|
+
export async function getProductData(slug: string) {
|
|
268
|
+
"use cache: long";
|
|
269
|
+
return await db.query("SELECT * FROM products WHERE slug = ?", [slug]);
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
On cache hit for the route, the handler doesn't run and `getProductData` is never
|
|
274
|
+
called. On cache miss, the handler runs and `getProductData` may itself return a
|
|
275
|
+
cached value from a previous call with the same slug.
|
|
276
|
+
|
|
277
|
+
### Nesting rule: the outer window bounds the inner
|
|
278
|
+
|
|
279
|
+
A cache's window bounds everything rendered inside it (loaders excepted). An
|
|
280
|
+
inner shorter TTL only takes effect when the **enclosing** cache recomputes — it
|
|
281
|
+
does **not** keep a value fresher than its parent:
|
|
282
|
+
|
|
283
|
+
- Outer `cache()` **fresh hit** → the subtree is served from stored RSC, so inner
|
|
284
|
+
`"use cache"` functions are **not consulted** (frozen at the outer's age — no
|
|
285
|
+
code inside the boundary runs on a hit).
|
|
286
|
+
- Outer **miss / SWR revalidation** → inner caches are consulted, each per its own
|
|
287
|
+
ttl/swr. With SWR on the outer, a stale subtree serves instantly and refreshes
|
|
288
|
+
in the background, so under traffic it keeps refreshing rather than rotting to
|
|
289
|
+
the worst case.
|
|
290
|
+
- **Loaders are the exception** — excluded from the segment cache, re-resolved
|
|
291
|
+
live even on an outer hit.
|
|
292
|
+
|
|
293
|
+
So `"use cache: short"` (60s) inside `cache({ ttl: 600 })` yields ~600s freshness
|
|
294
|
+
on hits, **not** 60s. This is not a bug: setting `cache({ ttl: 600 })` declares
|
|
295
|
+
"this subtree may be ~600s stale." **If a value must be fresher than its
|
|
296
|
+
enclosing segment, put it in a loader** (always live). `debugPerformance` prints
|
|
297
|
+
cache hits per layer, so the actual per-request behavior is observable.
|
|
298
|
+
|
|
299
|
+
## Headers and Cookies
|
|
300
|
+
|
|
301
|
+
Neither mechanism caches response headers or cookies.
|
|
302
|
+
|
|
303
|
+
- **cache()**: Response-level side effects throw inside the cache boundary even
|
|
304
|
+
on a miss: `ctx.header()`, `ctx.setCookie()`, `ctx.deleteCookie()`,
|
|
305
|
+
`ctx.setStatus()`, `ctx.onResponse()`, and direct `ctx.headers` mutation. On a
|
|
306
|
+
hit the handler would be skipped, so allowing the write on a miss would produce
|
|
307
|
+
inconsistent responses. If you need headers or cookies on every response, set
|
|
308
|
+
them in middleware or a live segment outside the cache boundary.
|
|
309
|
+
- **"use cache"**: cookies() and headers() throw inside the cached function
|
|
310
|
+
(both reads and writes). ctx.header() also throws. Move them outside.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// Set headers that must appear on every response in middleware
|
|
314
|
+
middleware(async (ctx, next) => {
|
|
315
|
+
ctx.header("X-Frame-Options", "DENY");
|
|
316
|
+
await next();
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Context Variable Cache Safety
|
|
321
|
+
|
|
322
|
+
Context variables created with `createVar()` are cacheable by default and can
|
|
323
|
+
be read freely inside cached scopes. A non-cacheable var throws when read
|
|
324
|
+
**directly** with `ctx.get()` inside a `cache()` boundary — where the value would
|
|
325
|
+
otherwise be serialized into the stored segment.
|
|
326
|
+
|
|
327
|
+
There are two ways to mark a value as non-cacheable:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// Var-level policy — inherently request-specific data
|
|
331
|
+
const Session = createVar<SessionData>({ cache: false });
|
|
332
|
+
|
|
333
|
+
// Write-level escalation — this specific write is non-cacheable
|
|
334
|
+
ctx.set(Theme, derivedTheme, { cache: false });
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
"Least cacheable wins": if either the var definition or the `ctx.set()` call
|
|
338
|
+
specifies `cache: false`, the value is non-cacheable.
|
|
339
|
+
|
|
340
|
+
**Behavior inside a `cache()` boundary:**
|
|
341
|
+
|
|
342
|
+
| Operation | Inside a `cache()` boundary |
|
|
343
|
+
| ----------------------------------------- | ------------------------------------------------------ |
|
|
344
|
+
| `cookies()` / `headers()` (read or write) | Throws (request-scoped, would poison the shared entry) |
|
|
345
|
+
| `ctx.get(cacheableVar)` | Allowed |
|
|
346
|
+
| `ctx.get(nonCacheableVar)` | Throws (would be baked in) |
|
|
347
|
+
| `ctx.set(var, value)` (cacheable) | Allowed |
|
|
348
|
+
| `ctx.header()` / cookie writes | Throws (response side effect would be lost on hit) |
|
|
349
|
+
| Any of the above **inside a loader** | Allowed (loaders always run fresh) |
|
|
350
|
+
|
|
351
|
+
(Both scopes block the same request-scoped APIs — `cookies()`, `headers()`,
|
|
352
|
+
response side effects, and non-cacheable `ctx.get()` — because each would leak
|
|
353
|
+
per-request data into a shared cache entry. The `cache()` boundary tracks the
|
|
354
|
+
scope via `isInsideCacheScope()`; `"use cache"` uses the exec guard and also
|
|
355
|
+
excludes tainted `ctx`/`env`/`req` args from the cache key. Loaders are exempt in
|
|
356
|
+
both — see "Headers and Cookies" and the precise guarantee below.)
|
|
357
|
+
|
|
358
|
+
Write is dumb — `ctx.set()` stores the cache metadata but does not enforce.
|
|
359
|
+
Enforcement happens at read time (`ctx.get()`), where ALS detects the cache
|
|
360
|
+
scope and rejects non-cacheable reads.
|
|
361
|
+
|
|
362
|
+
### The guarantee is precise — a direct read inside `cache()`, not propagating
|
|
363
|
+
|
|
364
|
+
The guard fires on a **direct** `ctx.get(taintedVar)` **inside a `cache()`
|
|
365
|
+
boundary** (the scope `isInsideCacheScope` detects). The taint lives on the
|
|
366
|
+
variable; a value **derived** from it and read **outside** the boundary is not
|
|
367
|
+
tracked:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
// CAUGHT — direct read of a tainted var inside a cache() boundary
|
|
371
|
+
cache({ ttl: 60 }, () => [
|
|
372
|
+
path("/dashboard", (ctx) => {
|
|
373
|
+
const user = ctx.get(User); // throws: non-cacheable read inside cache()
|
|
374
|
+
return <Dashboard user={user} />;
|
|
375
|
+
}, { name: "dashboard" }),
|
|
376
|
+
]);
|
|
377
|
+
|
|
378
|
+
// NOT CAUGHT — read outside the boundary, derived value cached
|
|
379
|
+
layout((ctx) => {
|
|
380
|
+
const name = ctx.get(User).name; // allowed — this layout is not cached
|
|
381
|
+
ctx.set(UserName, name); // now a plain (cacheable) string
|
|
382
|
+
return <Outlet />;
|
|
383
|
+
}, () => [
|
|
384
|
+
cache({ ttl: 60 }, () => [
|
|
385
|
+
// a child reads ctx.get(UserName) and silently caches user-derived data
|
|
386
|
+
]),
|
|
387
|
+
]);
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
So do **not** read this as "you can't cache user data" — that overstates it and
|
|
391
|
+
breeds the false confidence that makes the derived leak _more_ likely. The guard
|
|
392
|
+
is deliberately non-propagating (propagation would cost a wrapper per derivation
|
|
393
|
+
on the hot path), and it is scoped to the `cache()` segment boundary. `"use
|
|
394
|
+
cache"` functions block the same request-scoped reads (`cookies()` / `headers()`
|
|
395
|
+
throw inside them) and additionally exclude tainted `ctx`/`env`/`req` args from
|
|
396
|
+
the cache key. The pattern that stays safe is also the natural one:
|
|
397
|
+
**read tainted context at the point of use, in the path that needs it (a loader or
|
|
398
|
+
live segment) — never extract user data into a plain value and cache that.**
|
|
399
|
+
Loaders are exempt because they run outside the cache scope and resolve fresh
|
|
400
|
+
every request.
|
|
401
|
+
|
|
402
|
+
## Loaders Are Always Fresh
|
|
403
|
+
|
|
404
|
+
Loaders are **never cached** by route-level `cache()`. Even on a full cache hit
|
|
405
|
+
where all UI segments are served from cache, loaders are re-resolved fresh on
|
|
406
|
+
every request. This is enforced at two levels:
|
|
407
|
+
|
|
408
|
+
1. **Storage**: `cacheRoute()` filters out loader segments before serialization
|
|
409
|
+
(`segments.filter(s => s.type !== "loader")`).
|
|
410
|
+
2. **Retrieval**: On cache hit, `resolveLoadersOnly()` runs after yielding cached
|
|
411
|
+
UI segments, ensuring fresh data regardless of cache state.
|
|
412
|
+
|
|
413
|
+
This means `cache()` gives you cached UI + fresh data by default. To also cache
|
|
414
|
+
a loader's data, explicitly opt in with `loader(Fn, () => [cache({...})])`.
|
|
415
|
+
|
|
416
|
+
## cache() Placement Patterns
|
|
417
|
+
|
|
418
|
+
### Wrapping children of a path
|
|
419
|
+
|
|
420
|
+
An orphan `cache()` inside a path's children becomes the parent for all
|
|
421
|
+
subsequent siblings. Everything below the cache boundary is cached as one unit:
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
path("/dashboard", DashboardPage, { name: "dashboard" }, () => [
|
|
425
|
+
cache("long"),
|
|
426
|
+
layout(DashboardSidebar, () => [
|
|
427
|
+
parallel("@stats", StatsPanel),
|
|
428
|
+
parallel("@activity", ActivityFeed),
|
|
429
|
+
]),
|
|
430
|
+
]),
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
On hit: DashboardPage, DashboardSidebar, StatsPanel, and ActivityFeed are all
|
|
434
|
+
served from cache. On miss: all handlers run, all segments cached together.
|
|
435
|
+
|
|
436
|
+
### Uncached layout with cached children
|
|
437
|
+
|
|
438
|
+
The cache boundary only covers what's inside it. Parent segments above the
|
|
439
|
+
boundary are not cached and always re-render:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
layout(RootLayout, () => [
|
|
443
|
+
// RootLayout is NOT cached — runs every request
|
|
444
|
+
path("/products/:slug", ProductPage, { name: "product" }, () => [
|
|
445
|
+
cache("long"),
|
|
446
|
+
layout(ProductSidebar),
|
|
447
|
+
parallel("@reviews", ReviewsPanel),
|
|
448
|
+
parallel("@related", RelatedProducts),
|
|
449
|
+
]),
|
|
450
|
+
]),
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
RootLayout renders fresh every request. ProductPage, ProductSidebar,
|
|
454
|
+
ReviewsPanel, and RelatedProducts are all inside the cache boundary and
|
|
455
|
+
served from cache on hit. This is useful when the root layout depends on
|
|
456
|
+
request-specific data (user session, theme) but the product content is
|
|
457
|
+
cacheable.
|
|
458
|
+
|
|
459
|
+
### Loader-level caching
|
|
460
|
+
|
|
461
|
+
Loaders are excluded from route-level `cache()` by default — they always
|
|
462
|
+
resolve fresh. To opt a specific loader into caching, give it its own
|
|
463
|
+
`cache()` child:
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
path("/product/:slug", ProductPage, { name: "product" }, () => [
|
|
467
|
+
// This loader is cached for 5 minutes
|
|
468
|
+
loader(ProductLoader, () => [cache({ ttl: 300 })]),
|
|
469
|
+
|
|
470
|
+
// This loader is always fresh
|
|
471
|
+
loader(CartLoader),
|
|
472
|
+
]),
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
This attaches the cache config directly to the loader entry. The loader's
|
|
476
|
+
data is cached independently from the route's segment cache. Loader caching
|
|
477
|
+
supports custom keys, tags, SWR, conditional bypass, and per-loader store
|
|
478
|
+
overrides — see `/loader` for the full reference.
|
|
479
|
+
|
|
480
|
+
## See Also
|
|
481
|
+
|
|
482
|
+
- `/caching` — cache() DSL setup, stores, nested boundaries
|
|
483
|
+
- `/use-cache` — "use cache" directive details, profiles, transforms, guards
|
|
484
|
+
- `/document-cache` — Edge caching with Cache-Control headers (different layer)
|