@rangojs/router 0.0.0-experimental.97 → 0.0.0-experimental.98914650
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/README.md +24 -9
- package/dist/bin/rango.js +157 -63
- package/dist/testing/vitest.js +82 -0
- package/dist/vite/index.js +1584 -639
- package/package.json +71 -21
- package/skills/api-client/SKILL.md +211 -0
- package/skills/breadcrumbs/SKILL.md +60 -0
- package/skills/bundle-analysis/SKILL.md +159 -0
- package/skills/cache-guide/SKILL.md +222 -30
- package/skills/caching/SKILL.md +263 -8
- package/skills/composability/SKILL.md +27 -2
- package/skills/css/SKILL.md +76 -0
- package/skills/document-cache/SKILL.md +78 -55
- package/skills/handler-use/SKILL.md +3 -1
- package/skills/hooks/SKILL.md +235 -28
- package/skills/host-router/SKILL.md +122 -22
- package/skills/i18n/SKILL.md +276 -0
- package/skills/intercept/SKILL.md +29 -5
- package/skills/layout/SKILL.md +13 -9
- package/skills/links/SKILL.md +173 -17
- package/skills/loader/SKILL.md +170 -23
- package/skills/middleware/SKILL.md +16 -10
- package/skills/migrate-nextjs/SKILL.md +38 -16
- package/skills/mime-routes/SKILL.md +27 -0
- package/skills/observability/SKILL.md +137 -0
- package/skills/parallel/SKILL.md +11 -7
- package/skills/prerender/SKILL.md +14 -33
- package/skills/rango/SKILL.md +250 -25
- package/skills/react-compiler/SKILL.md +168 -0
- package/skills/response-routes/SKILL.md +114 -47
- package/skills/route/SKILL.md +42 -5
- package/skills/router-setup/SKILL.md +3 -3
- package/skills/server-actions/SKILL.md +78 -42
- package/skills/tailwind/SKILL.md +27 -3
- package/skills/testing/SKILL.md +129 -0
- package/skills/testing/bindings.md +89 -0
- package/skills/testing/cache-prerender.md +124 -0
- package/skills/testing/client-components.md +122 -0
- package/skills/testing/e2e-parity.md +125 -0
- package/skills/testing/flight.md +92 -0
- package/skills/testing/handles.md +129 -0
- package/skills/testing/loader.md +128 -0
- package/skills/testing/middleware.md +99 -0
- package/skills/testing/render-handler.md +121 -0
- package/skills/testing/response-routes.md +95 -0
- package/skills/testing/reverse-and-types.md +84 -0
- package/skills/testing/server-actions.md +107 -0
- package/skills/testing/server-tree.md +128 -0
- package/skills/testing/setup.md +120 -0
- package/skills/typesafety/SKILL.md +316 -26
- package/skills/use-cache/SKILL.md +36 -5
- package/skills/vercel/SKILL.md +107 -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 +0 -65
- package/src/browser/action-coordinator.ts +53 -36
- package/src/browser/action-fence.ts +47 -0
- package/src/browser/app-shell.ts +14 -27
- package/src/browser/cookie-name.ts +140 -0
- package/src/browser/event-controller.ts +37 -143
- package/src/browser/history-state.ts +21 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/invalidate-client-cache.ts +52 -0
- package/src/browser/navigation-bridge.ts +30 -59
- package/src/browser/navigation-client.ts +96 -84
- package/src/browser/navigation-store-handle.ts +38 -0
- package/src/browser/navigation-store.ts +32 -82
- package/src/browser/navigation-transaction.ts +9 -59
- package/src/browser/partial-update.ts +60 -127
- package/src/browser/prefetch/cache.ts +82 -72
- package/src/browser/prefetch/fetch.ts +108 -33
- package/src/browser/prefetch/queue.ts +6 -3
- package/src/browser/rango-state.ts +157 -115
- package/src/browser/react/Link.tsx +0 -2
- package/src/browser/react/NavigationProvider.tsx +41 -48
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/filter-segment-order.ts +0 -2
- package/src/browser/react/index.ts +0 -48
- package/src/browser/react/location-state-shared.ts +166 -8
- package/src/browser/react/location-state.ts +39 -14
- package/src/browser/react/use-action.ts +6 -15
- package/src/browser/react/use-handle.ts +17 -14
- package/src/browser/react/use-link-status.ts +0 -4
- package/src/browser/react/use-navigation.ts +0 -3
- package/src/browser/react/use-params.ts +11 -11
- package/src/browser/react/use-reverse.ts +106 -0
- package/src/browser/react/use-router.ts +20 -5
- package/src/browser/react/use-search-params.ts +0 -5
- package/src/browser/react/use-segments.ts +0 -13
- package/src/browser/response-adapter.ts +52 -1
- package/src/browser/rsc-router.tsx +70 -34
- package/src/browser/scroll-restoration.ts +22 -14
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/browser/server-action-bridge.ts +168 -44
- package/src/browser/types.ts +36 -21
- package/src/browser/validate-redirect-origin.ts +43 -16
- package/src/build/collect-fallback-refs.ts +107 -0
- package/src/build/generate-manifest.ts +60 -35
- package/src/build/generate-route-types.ts +3 -0
- package/src/build/index.ts +8 -2
- package/src/build/prefix-tree-utils.ts +123 -0
- package/src/build/route-trie.ts +89 -10
- package/src/build/route-types/codegen.ts +4 -4
- package/src/build/route-types/include-resolution.ts +1 -1
- package/src/build/route-types/param-extraction.ts +6 -3
- package/src/build/route-types/per-module-writer.ts +7 -4
- package/src/build/route-types/router-processing.ts +122 -22
- package/src/build/route-types/scan-filter.ts +1 -1
- package/src/build/route-types/source-scan.ts +118 -0
- package/src/build/runtime-discovery.ts +9 -20
- package/src/cache/cache-error.ts +104 -0
- package/src/cache/cache-policy.ts +68 -28
- package/src/cache/cache-runtime.ts +134 -32
- package/src/cache/cache-scope.ts +100 -74
- package/src/cache/cache-tag.ts +98 -0
- package/src/cache/cf/cf-cache-store.ts +2255 -238
- package/src/cache/cf/index.ts +6 -16
- package/src/cache/document-cache.ts +61 -20
- package/src/cache/handle-snapshot.ts +63 -0
- package/src/cache/index.ts +22 -20
- package/src/cache/memory-segment-store.ts +136 -37
- package/src/cache/profile-registry.ts +6 -30
- package/src/cache/read-through-swr.ts +41 -11
- package/src/cache/segment-codec.ts +0 -16
- package/src/cache/tag-invalidation.ts +230 -0
- package/src/cache/types.ts +33 -100
- package/src/cache/vercel/index.ts +11 -0
- package/src/cache/vercel/vercel-cache-store.ts +799 -0
- package/src/client.rsc.tsx +6 -21
- package/src/client.tsx +25 -61
- package/src/component-utils.ts +19 -0
- package/src/context-var.ts +17 -5
- package/src/decode-loader-results.ts +36 -0
- package/src/defer.ts +196 -0
- package/src/deps/ssr.ts +0 -1
- package/src/errors.ts +30 -4
- package/src/handle.ts +31 -23
- package/src/handles/MetaTags.tsx +0 -14
- package/src/handles/breadcrumbs.ts +16 -5
- package/src/handles/meta.ts +0 -39
- package/src/host/cookie-handler.ts +0 -36
- package/src/host/errors.ts +0 -24
- package/src/host/index.ts +8 -2
- package/src/host/pattern-matcher.ts +7 -50
- package/src/host/router.ts +107 -99
- package/src/host/testing.ts +40 -27
- package/src/host/types.ts +37 -4
- package/src/host/utils.ts +1 -1
- package/src/href-client.ts +137 -22
- package/src/index.rsc.ts +63 -9
- package/src/index.ts +64 -9
- package/src/internal-debug.ts +2 -4
- package/src/loader-store.ts +500 -0
- package/src/loader.rsc.ts +20 -13
- package/src/loader.ts +12 -11
- package/src/missing-id-error.ts +68 -0
- package/src/network-error-thrower.tsx +1 -6
- package/src/outlet-provider.tsx +1 -5
- package/src/prerender/param-hash.ts +10 -11
- package/src/prerender/store.ts +32 -37
- package/src/prerender.ts +61 -6
- package/src/redirect-origin.ts +100 -0
- package/src/response-utils.ts +9 -0
- package/src/reverse.ts +65 -40
- package/src/root-error-boundary.tsx +1 -19
- package/src/route-content-wrapper.tsx +7 -72
- package/src/route-definition/dsl-helpers.ts +244 -281
- package/src/route-definition/helper-factories.ts +29 -139
- package/src/route-definition/helpers-types.ts +40 -17
- package/src/route-definition/redirect.ts +43 -9
- package/src/route-definition/resolve-handler-use.ts +6 -0
- package/src/route-definition/use-item-types.ts +32 -0
- package/src/route-map-builder.ts +0 -16
- package/src/route-types.ts +19 -41
- package/src/router/basename.ts +14 -0
- package/src/router/content-negotiation.ts +15 -15
- package/src/router/error-handling.ts +13 -17
- package/src/router/find-match.ts +44 -23
- package/src/router/handler-context.ts +4 -41
- package/src/router/intercept-resolution.ts +14 -19
- package/src/router/lazy-includes.ts +9 -46
- package/src/router/loader-resolution.ts +91 -46
- package/src/router/logging.ts +0 -6
- package/src/router/manifest.ts +18 -29
- package/src/router/match-api.ts +0 -20
- package/src/router/match-context.ts +0 -22
- package/src/router/match-handlers.ts +57 -58
- package/src/router/match-middleware/background-revalidation.ts +0 -7
- package/src/router/match-middleware/cache-lookup.ts +150 -271
- package/src/router/match-middleware/cache-store.ts +3 -33
- package/src/router/match-middleware/intercept-resolution.ts +0 -22
- package/src/router/match-middleware/segment-resolution.ts +0 -22
- package/src/router/match-pipelines.ts +1 -42
- package/src/router/match-result.ts +31 -80
- package/src/router/metrics.ts +0 -34
- package/src/router/middleware-types.ts +5 -112
- package/src/router/middleware.ts +118 -133
- package/src/router/navigation-snapshot.ts +0 -51
- package/src/router/params-util.ts +23 -0
- package/src/router/pattern-matching.ts +62 -67
- package/src/router/prerender-match.ts +99 -63
- package/src/router/preview-match.ts +3 -1
- package/src/router/request-classification.ts +28 -62
- package/src/router/revalidation.ts +50 -56
- package/src/router/route-snapshot.ts +0 -1
- package/src/router/router-context.ts +0 -27
- package/src/router/router-interfaces.ts +68 -35
- package/src/router/router-options.ts +55 -1
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +44 -63
- package/src/router/segment-resolution/helpers.ts +34 -0
- package/src/router/segment-resolution/loader-cache.ts +40 -37
- package/src/router/segment-resolution/revalidation.ts +203 -285
- package/src/router/segment-resolution/static-store.ts +19 -5
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution/view-transition-default.ts +36 -0
- package/src/router/segment-resolution.ts +4 -1
- package/src/router/segment-wrappers.ts +0 -3
- package/src/router/state-cookie-name.ts +33 -0
- package/src/router/substitute-pattern-params.ts +56 -0
- package/src/router/telemetry-otel.ts +0 -20
- package/src/router/telemetry.ts +96 -19
- package/src/router/timeout.ts +0 -20
- package/src/router/trie-matching.ts +87 -48
- package/src/router/types.ts +9 -63
- package/src/router/url-params.ts +0 -5
- package/src/router.ts +80 -41
- package/src/rsc/handler-context.ts +3 -2
- package/src/rsc/handler.ts +83 -78
- package/src/rsc/helpers.ts +93 -5
- package/src/rsc/index.ts +1 -1
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/manifest-init.ts +28 -41
- package/src/rsc/origin-guard.ts +39 -25
- package/src/rsc/progressive-enhancement.ts +12 -1
- package/src/rsc/redirect-guard.ts +99 -0
- package/src/rsc/response-error.ts +79 -12
- package/src/rsc/response-route-handler.ts +76 -62
- package/src/rsc/rsc-rendering.ts +41 -60
- package/src/rsc/runtime-warnings.ts +23 -10
- package/src/rsc/server-action.ts +62 -67
- package/src/rsc/ssr-setup.ts +16 -0
- package/src/rsc/types.ts +10 -5
- package/src/runtime-env.ts +18 -0
- package/src/search-params.ts +4 -20
- package/src/segment-loader-promise.ts +14 -2
- package/src/segment-system.tsx +199 -142
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +150 -51
- package/src/server/cookie-store.ts +80 -5
- package/src/server/handle-store.ts +7 -24
- package/src/server/loader-registry.ts +5 -24
- package/src/server/request-context.ts +165 -87
- package/src/ssr/index.tsx +14 -14
- package/src/static-handler.ts +10 -13
- package/src/testing/cache-status.ts +162 -0
- package/src/testing/collect-handle.ts +40 -0
- package/src/testing/dispatch.ts +618 -0
- package/src/testing/dom.entry.ts +22 -0
- package/src/testing/e2e/fixture.ts +188 -0
- package/src/testing/e2e/index.ts +128 -0
- package/src/testing/e2e/matchers.ts +35 -0
- package/src/testing/e2e/page-helpers.ts +272 -0
- package/src/testing/e2e/parity.ts +387 -0
- package/src/testing/e2e/server.ts +195 -0
- package/src/testing/flight-matchers.ts +97 -0
- package/src/testing/flight-normalize.ts +11 -0
- package/src/testing/flight-runtime.d.ts +57 -0
- package/src/testing/flight-tree.ts +682 -0
- package/src/testing/flight.entry.ts +52 -0
- package/src/testing/flight.ts +232 -0
- package/src/testing/generated-routes.ts +183 -0
- package/src/testing/index.ts +99 -0
- package/src/testing/internal/context.ts +348 -0
- package/src/testing/internal/flight-client-globals.ts +30 -0
- package/src/testing/internal/seed-vars.ts +54 -0
- package/src/testing/render-handler.ts +330 -0
- package/src/testing/render-route.tsx +566 -0
- package/src/testing/run-loader.ts +378 -0
- package/src/testing/run-middleware.ts +205 -0
- package/src/testing/vitest-stubs/cloudflare-email.ts +9 -0
- package/src/testing/vitest-stubs/cloudflare-workers.ts +21 -0
- package/src/testing/vitest-stubs/plugin-rsc.ts +16 -0
- package/src/testing/vitest-stubs/version.ts +5 -0
- package/src/testing/vitest.ts +305 -0
- package/src/theme/ThemeProvider.tsx +0 -52
- package/src/theme/ThemeScript.tsx +0 -6
- package/src/theme/constants.ts +0 -12
- package/src/theme/index.ts +0 -7
- package/src/theme/theme-context.ts +1 -5
- package/src/theme/theme-script.ts +0 -14
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +0 -35
- package/src/types/cache-types.ts +13 -4
- package/src/types/error-types.ts +30 -90
- package/src/types/global-namespace.ts +54 -41
- package/src/types/handler-context.ts +97 -22
- package/src/types/index.ts +1 -10
- package/src/types/loader-types.ts +6 -3
- package/src/types/request-scope.ts +0 -19
- package/src/types/route-config.ts +6 -50
- package/src/types/route-entry.ts +0 -6
- package/src/types/segments.ts +18 -14
- package/src/urls/include-helper.ts +9 -56
- package/src/urls/index.ts +1 -11
- package/src/urls/path-helper-types.ts +19 -5
- package/src/urls/path-helper.ts +17 -106
- package/src/urls/pattern-types.ts +36 -19
- package/src/urls/response-types.ts +20 -19
- package/src/urls/type-extraction.ts +58 -139
- package/src/urls/urls-function.ts +1 -18
- package/src/use-loader.tsx +292 -107
- package/src/vite/debug.ts +1 -0
- package/src/vite/discovery/bundle-postprocess.ts +8 -7
- package/src/vite/discovery/discover-routers.ts +95 -82
- package/src/vite/discovery/discovery-errors.ts +194 -0
- package/src/vite/discovery/prerender-collection.ts +26 -34
- package/src/vite/discovery/route-types-writer.ts +40 -84
- package/src/vite/discovery/state.ts +39 -1
- package/src/vite/discovery/virtual-module-codegen.ts +14 -34
- package/src/vite/index.ts +4 -0
- package/src/vite/plugin-types.ts +185 -10
- package/src/vite/plugins/cjs-to-esm.ts +3 -18
- package/src/vite/plugins/client-ref-dedup.ts +0 -11
- package/src/vite/plugins/client-ref-hashing.ts +12 -11
- package/src/vite/plugins/cloudflare-protocol-stub.ts +1 -21
- package/src/vite/plugins/expose-action-id.ts +4 -75
- package/src/vite/plugins/expose-id-utils.ts +3 -54
- package/src/vite/plugins/expose-ids/export-analysis.ts +76 -34
- package/src/vite/plugins/expose-ids/handler-transform.ts +6 -74
- package/src/vite/plugins/expose-ids/loader-transform.ts +3 -20
- package/src/vite/plugins/expose-ids/router-transform.ts +0 -13
- package/src/vite/plugins/expose-internal-ids.ts +57 -67
- package/src/vite/plugins/performance-tracks.ts +9 -16
- package/src/vite/plugins/refresh-cmd.ts +1 -1
- package/src/vite/plugins/use-cache-transform.ts +26 -49
- package/src/vite/plugins/vercel-output.ts +258 -0
- package/src/vite/plugins/version-injector.ts +2 -32
- package/src/vite/plugins/version-plugin.ts +32 -23
- package/src/vite/plugins/virtual-entries.ts +35 -17
- package/src/vite/rango.ts +148 -115
- package/src/vite/router-discovery.ts +220 -68
- package/src/vite/utils/ast-handler-extract.ts +15 -31
- package/src/vite/utils/bundle-analysis.ts +10 -15
- package/src/vite/utils/client-chunks.ts +184 -0
- package/src/vite/utils/forward-user-plugins.ts +171 -0
- package/src/vite/utils/manifest-utils.ts +4 -59
- package/src/vite/utils/package-resolution.ts +1 -73
- package/src/vite/utils/prerender-utils.ts +0 -34
- package/src/vite/utils/shared-utils.ts +95 -43
- package/src/browser/action-response-classifier.ts +0 -99
- package/src/browser/react/use-client-cache.ts +0 -58
- package/src/browser/shallow.ts +0 -40
- package/src/handles/index.ts +0 -7
- package/src/router/middleware-cookies.ts +0 -55
package/src/host/types.ts
CHANGED
|
@@ -35,12 +35,24 @@ export type Middleware = (
|
|
|
35
35
|
*/
|
|
36
36
|
export type HostPattern = string | string[];
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Whether a route entry is an inline request handler or a lazy module mount.
|
|
40
|
+
*
|
|
41
|
+
* Stored on the entry so discovery and runtime act on the consumer's declared
|
|
42
|
+
* intent instead of inferring it from the function's shape (arity/return value),
|
|
43
|
+
* which is ambiguous: a lazy loader may declare an ignored param, and an inline
|
|
44
|
+
* handler may be async. `.map()` registers `"handler"`, `.lazy()` registers
|
|
45
|
+
* `"lazy"`.
|
|
46
|
+
*/
|
|
47
|
+
export type RouteEntryKind = "handler" | "lazy";
|
|
48
|
+
|
|
38
49
|
/**
|
|
39
50
|
* Result from testing a hostname against patterns
|
|
40
51
|
*/
|
|
41
52
|
export interface HostMatchResult {
|
|
42
53
|
pattern: string;
|
|
43
54
|
handler: Handler | LazyHandler;
|
|
55
|
+
kind: RouteEntryKind;
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
/**
|
|
@@ -53,9 +65,24 @@ export interface HostRouteBuilder {
|
|
|
53
65
|
use(...middleware: Middleware[]): HostRouteBuilder;
|
|
54
66
|
|
|
55
67
|
/**
|
|
56
|
-
* Map to
|
|
68
|
+
* Map to an inline request handler `(request, input) => Response`.
|
|
69
|
+
*
|
|
70
|
+
* For a lazily-imported sub-app or handler module, use {@link lazy} instead -
|
|
71
|
+
* `.map(() => import(...))` is rejected (the return type is not a `Response`)
|
|
72
|
+
* and would not be discovered at build time.
|
|
73
|
+
*/
|
|
74
|
+
map(handler: Handler): HostRouter;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Mount a lazily-imported handler or host router:
|
|
78
|
+
* `.lazy(() => import("./sub-app"))`.
|
|
79
|
+
*
|
|
80
|
+
* The loader takes no arguments and resolves to a module whose `default`
|
|
81
|
+
* export is a request `Handler` or a nested `HostRouter`. Only `.lazy()`
|
|
82
|
+
* entries are invoked during build-time discovery to trigger the sub-app's
|
|
83
|
+
* `createRouter()` registration.
|
|
57
84
|
*/
|
|
58
|
-
|
|
85
|
+
lazy(handler: LazyHandler): HostRouter;
|
|
59
86
|
}
|
|
60
87
|
|
|
61
88
|
/**
|
|
@@ -83,9 +110,13 @@ export interface HostRouter {
|
|
|
83
110
|
fallback(): HostRouteBuilder;
|
|
84
111
|
|
|
85
112
|
/**
|
|
86
|
-
* Test which handler would match a hostname
|
|
113
|
+
* Test which handler would match a hostname (and optional pathname).
|
|
114
|
+
*
|
|
115
|
+
* `pathname` defaults to `"/"`. Pass it to probe path-prefixed patterns
|
|
116
|
+
* such as `host(["example.com/admin"])`, which only match when the request
|
|
117
|
+
* path is under the prefix.
|
|
87
118
|
*/
|
|
88
|
-
test(hostname: string): HostMatchResult | null;
|
|
119
|
+
test(hostname: string, pathname?: string): HostMatchResult | null;
|
|
89
120
|
}
|
|
90
121
|
|
|
91
122
|
/**
|
|
@@ -134,6 +165,8 @@ export interface RouteEntry {
|
|
|
134
165
|
patterns: string[];
|
|
135
166
|
middleware: Middleware[];
|
|
136
167
|
handler: Handler | LazyHandler;
|
|
168
|
+
/** Whether `handler` is an inline request handler or a lazy module mount. */
|
|
169
|
+
kind: RouteEntryKind;
|
|
137
170
|
isFallback?: boolean;
|
|
138
171
|
}
|
|
139
172
|
|
package/src/host/utils.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* app: ['*', 'www.*']
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
18
|
-
* router.host(hosts.admin).
|
|
18
|
+
* router.host(hosts.admin).lazy(() => import("./apps/admin")); // Type-safe!
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export function defineHosts<T extends Record<string, string | string[]>>(
|
package/src/href-client.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import type { GetRegisteredRoutes } from "./types.js";
|
|
18
|
-
import type {
|
|
18
|
+
import type { JsonSerialize } from "./serialize.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Parse constraint values into a union type for paths
|
|
@@ -103,29 +103,75 @@ type NameForPattern<TPattern extends string, TRoutes = GetRegisteredRoutes> = {
|
|
|
103
103
|
}[keyof TRoutes];
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
106
|
+
* Strip a query (`?…`) and/or hash (`#…`) suffix before matching, so a concrete
|
|
107
|
+
* URL like `/api/health?ts=1` still resolves to its route's response. Removes
|
|
108
|
+
* from the earliest of `?`/`#`: a `#` before the first `?` (the query is part of
|
|
109
|
+
* a fragment, e.g. `/health#top?x=1`) is handled, as is a `/:` that only appears
|
|
110
|
+
* inside the query (e.g. `/health?next=/:id`).
|
|
111
|
+
*/
|
|
112
|
+
type StripPathSuffix<T extends string> = T extends `${infer Base}?${string}`
|
|
113
|
+
? Base extends `${infer Frag}#${string}`
|
|
114
|
+
? Frag
|
|
115
|
+
: Base
|
|
116
|
+
: T extends `${infer Base}#${string}`
|
|
117
|
+
? Base
|
|
118
|
+
: T;
|
|
119
|
+
|
|
120
|
+
/** Extract a route entry's response payload (or `never` for RSC routes). */
|
|
121
|
+
type ResponsePayloadOf<TRoutes, K extends keyof TRoutes> = TRoutes[K] extends {
|
|
122
|
+
readonly response: infer R;
|
|
123
|
+
}
|
|
124
|
+
? Exclude<R, Response>
|
|
125
|
+
: never;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Look up the response payload for a route, keyed by either a route pattern
|
|
129
|
+
* (`/api/products/:id`) or a concrete path (`/api/products/123`). The same type
|
|
130
|
+
* serves a pattern lookup and a typed `fetch` wrapper that forwards a concrete
|
|
131
|
+
* `Rango.Path`:
|
|
110
132
|
*
|
|
111
|
-
*
|
|
112
|
-
* PathResponse<"/api/
|
|
133
|
+
* PathResponse<"/api/products/:id"> → Product // by pattern
|
|
134
|
+
* PathResponse<"/api/products/123"> → Product // by concrete path
|
|
113
135
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
136
|
+
* The query/hash suffix is stripped first; the stripped key is then treated as a
|
|
137
|
+
* pattern when it contains a `/:param` segment and matched exactly (precise even
|
|
138
|
+
* for nested dynamic routes), otherwise as a concrete path matched against each
|
|
139
|
+
* route's `PatternToPath` template. Because those holes are `${string}`
|
|
140
|
+
* (slash-greedy), a concrete path under a *nested* dynamic route can match several
|
|
141
|
+
* patterns and union their responses — pattern lookups do not have this
|
|
142
|
+
* looseness. RSC routes (no response) and unmatched keys resolve to `never`.
|
|
143
|
+
*/
|
|
144
|
+
type ResponsePayloadFor<
|
|
145
|
+
TPath extends string,
|
|
146
|
+
TRoutes = GetRegisteredRoutes,
|
|
147
|
+
> = ResponsePayloadForKey<StripPathSuffix<TPath>, TRoutes>;
|
|
148
|
+
|
|
149
|
+
type ResponsePayloadForKey<
|
|
150
|
+
TKey extends string,
|
|
151
|
+
TRoutes,
|
|
152
|
+
> = TKey extends `${string}/:${string}`
|
|
153
|
+
? {
|
|
154
|
+
[K in keyof TRoutes]: RoutePattern<TRoutes, K> extends TKey
|
|
155
|
+
? ResponsePayloadOf<TRoutes, K>
|
|
156
|
+
: never;
|
|
157
|
+
}[keyof TRoutes]
|
|
158
|
+
: {
|
|
159
|
+
[K in keyof TRoutes]: TKey extends PatternToPath<RoutePattern<TRoutes, K>>
|
|
160
|
+
? ResponsePayloadOf<TRoutes, K>
|
|
161
|
+
: never;
|
|
162
|
+
}[keyof TRoutes];
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Public response type for a route, keyed by pattern or concrete path. JSON
|
|
166
|
+
* response routes send the handler's return value verbatim (bare), so the
|
|
167
|
+
* payload is wrapped only in `JsonSerialize` to describe the JSON **wire** value
|
|
168
|
+
* a consumer receives from `fetch().then(r => r.json())` — e.g. a handler
|
|
169
|
+
* returning `{ createdAt: Date }` resolves here to `{ createdAt: string }`.
|
|
116
170
|
*/
|
|
117
171
|
export type PathResponse<
|
|
118
|
-
|
|
172
|
+
TPath extends string,
|
|
119
173
|
TRoutes = GetRegisteredRoutes,
|
|
120
|
-
> =
|
|
121
|
-
{
|
|
122
|
-
[K in keyof TRoutes]: RoutePattern<TRoutes, K> extends TPattern
|
|
123
|
-
? TRoutes[K] extends { readonly response: infer R }
|
|
124
|
-
? Exclude<R, Response>
|
|
125
|
-
: never
|
|
126
|
-
: never;
|
|
127
|
-
}[keyof TRoutes]
|
|
128
|
-
>;
|
|
174
|
+
> = JsonSerialize<ResponsePayloadFor<TPath, TRoutes>>;
|
|
129
175
|
|
|
130
176
|
/**
|
|
131
177
|
* Strip trailing slash from a path (e.g., "/blog/" -> "/blog" | "/blog/")
|
|
@@ -140,7 +186,7 @@ type OptionalTrailingSlash<T extends string> = T extends `${infer Base}/`
|
|
|
140
186
|
/**
|
|
141
187
|
* Union of all valid paths from registered routes
|
|
142
188
|
*
|
|
143
|
-
* Generated from
|
|
189
|
+
* Generated from Rango.RegisteredRoutes via module augmentation.
|
|
144
190
|
* Allows optional query strings and hash fragments.
|
|
145
191
|
*/
|
|
146
192
|
export type ValidPaths<TRoutes = GetRegisteredRoutes> =
|
|
@@ -154,6 +200,76 @@ export type ValidPaths<TRoutes = GetRegisteredRoutes> =
|
|
|
154
200
|
}[keyof TRoutes]
|
|
155
201
|
>;
|
|
156
202
|
|
|
203
|
+
// Module-scoped alias so the ambient `Rango.PathResponse` below can reference
|
|
204
|
+
// the module-level `PathResponse` without the global namespace shadowing the
|
|
205
|
+
// name when both are called `PathResponse`.
|
|
206
|
+
type GlobalPathResponse<
|
|
207
|
+
TPattern extends string,
|
|
208
|
+
TRoutes = GetRegisteredRoutes,
|
|
209
|
+
> = PathResponse<TPattern, TRoutes>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Ambient path types on the `Rango` namespace.
|
|
213
|
+
*
|
|
214
|
+
* These live on the same global namespace consumers already augment for
|
|
215
|
+
* `Rango.Env` / `Rango.Vars`, so they are reachable with no import wherever the
|
|
216
|
+
* router's types are in scope. They are the public, recommended surface for
|
|
217
|
+
* typing anything that wraps `href()`. `ValidPaths` / `PathResponse` stay as the
|
|
218
|
+
* internal building blocks behind them.
|
|
219
|
+
*/
|
|
220
|
+
declare global {
|
|
221
|
+
namespace Rango {
|
|
222
|
+
/**
|
|
223
|
+
* Union of every valid route path accepted by `href()`.
|
|
224
|
+
*
|
|
225
|
+
* Type a wrapper's path parameter as `Rango.Path` so it shares `href()`'s
|
|
226
|
+
* compile-time validation against the registered routes:
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* import { href } from "@rangojs/router/client";
|
|
230
|
+
*
|
|
231
|
+
* export const appHref = (path: Rango.Path) => href(path);
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* Resolves from `Rango.RegisteredRoutes` when augmented, otherwise the
|
|
235
|
+
* auto-generated `Rango.GeneratedRouteMap`, otherwise a permissive
|
|
236
|
+
* `/${string}` fallback.
|
|
237
|
+
*/
|
|
238
|
+
type Path<TRoutes = GetRegisteredRoutes> = ValidPaths<TRoutes>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Response payload for a route, looked up from the global route map by
|
|
242
|
+
* either a route pattern (`/api/products/:id`) or a concrete path
|
|
243
|
+
* (`/api/products/123`). Because it accepts a concrete `Rango.Path`, it
|
|
244
|
+
* doubles as the return type of a typed `fetch` wrapper:
|
|
245
|
+
*
|
|
246
|
+
* ```ts
|
|
247
|
+
* type Product = Rango.PathResponse<"/api/products/:id">; // by pattern
|
|
248
|
+
* type Same = Rango.PathResponse<"/api/products/42">; // by concrete path
|
|
249
|
+
*
|
|
250
|
+
* const get = async <T extends Rango.Path>(
|
|
251
|
+
* path: T,
|
|
252
|
+
* ): Promise<Rango.PathResponse<T>> =>
|
|
253
|
+
* fetch(href(path)).then((r) => r.json());
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* The payload is the JSON **wire** shape (via `Rango.JsonSerialize`), not the
|
|
257
|
+
* handler's raw return — a handler returning `{ createdAt: Date }` resolves
|
|
258
|
+
* here to `{ createdAt: string }` (bare, no envelope), matching what
|
|
259
|
+
* `fetch().then(r => r.json())` actually yields.
|
|
260
|
+
*
|
|
261
|
+
* Only resolves once `Rango.RegisteredRoutes` carries response metadata (the
|
|
262
|
+
* generated map has paths and search but no payloads). Pass an explicit route
|
|
263
|
+
* map as the second argument to look up against a non-global map (rarely
|
|
264
|
+
* needed in app code).
|
|
265
|
+
*/
|
|
266
|
+
type PathResponse<
|
|
267
|
+
TPath extends string,
|
|
268
|
+
TRoutes = GetRegisteredRoutes,
|
|
269
|
+
> = GlobalPathResponse<TPath, TRoutes>;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
157
273
|
/**
|
|
158
274
|
* Type-safe href function for client-side use
|
|
159
275
|
*
|
|
@@ -182,11 +298,10 @@ export type ValidPaths<TRoutes = GetRegisteredRoutes> =
|
|
|
182
298
|
*/
|
|
183
299
|
export function href<T extends ValidPaths>(path: T, mount?: string): string {
|
|
184
300
|
if (mount && mount !== "/") {
|
|
185
|
-
// Strip trailing slash from mount to avoid double-slash when joining
|
|
186
301
|
const normalizedMount = mount.endsWith("/") ? mount.slice(0, -1) : mount;
|
|
187
302
|
return normalizedMount + path;
|
|
188
303
|
}
|
|
189
|
-
return path;
|
|
304
|
+
return path as string;
|
|
190
305
|
}
|
|
191
306
|
|
|
192
307
|
/**
|
package/src/index.rsc.ts
CHANGED
|
@@ -18,6 +18,7 @@ export {
|
|
|
18
18
|
MiddlewareError,
|
|
19
19
|
HandlerError,
|
|
20
20
|
BuildError,
|
|
21
|
+
DslContextError,
|
|
21
22
|
InvalidHandlerError,
|
|
22
23
|
RouterError,
|
|
23
24
|
Skip,
|
|
@@ -43,6 +44,7 @@ export type {
|
|
|
43
44
|
// Revalidation types
|
|
44
45
|
RevalidateParams,
|
|
45
46
|
Revalidate,
|
|
47
|
+
ActionRef,
|
|
46
48
|
RouteKeys,
|
|
47
49
|
// Loader types
|
|
48
50
|
LoaderDefinition,
|
|
@@ -67,12 +69,19 @@ export type {
|
|
|
67
69
|
|
|
68
70
|
// Router options type (server-only, so import directly)
|
|
69
71
|
export type {
|
|
70
|
-
|
|
72
|
+
RangoOptions,
|
|
71
73
|
SSRStreamMode,
|
|
72
74
|
SSROptions,
|
|
73
75
|
ResolveStreamingContext,
|
|
74
76
|
} from "./router.js";
|
|
75
77
|
|
|
78
|
+
// Origin-check callback types (referenced by the RangoOptions.originCheck JSDoc)
|
|
79
|
+
export type {
|
|
80
|
+
OriginCheckConfig,
|
|
81
|
+
OriginCheckContext,
|
|
82
|
+
OriginCheckPhase,
|
|
83
|
+
} from "./rsc/origin-guard.js";
|
|
84
|
+
|
|
76
85
|
// Server-side createLoader and redirect
|
|
77
86
|
export {
|
|
78
87
|
createLoader,
|
|
@@ -105,6 +114,13 @@ export type {
|
|
|
105
114
|
|
|
106
115
|
// Handle API
|
|
107
116
|
export { createHandle, isHandle, type Handle } from "./handle.js";
|
|
117
|
+
export {
|
|
118
|
+
DEFAULT_DEFER_TIMEOUT_MS,
|
|
119
|
+
type DeferOptions,
|
|
120
|
+
type DeferredHandleEntry,
|
|
121
|
+
type HandlePush,
|
|
122
|
+
type HandlePushFn,
|
|
123
|
+
} from "./defer.js";
|
|
108
124
|
|
|
109
125
|
// Context variable API (typed ctx.set/ctx.get tokens)
|
|
110
126
|
export { createVar, type ContextVar } from "./context-var.js";
|
|
@@ -122,10 +138,15 @@ export {
|
|
|
122
138
|
type BuildContext,
|
|
123
139
|
type StaticBuildContext,
|
|
124
140
|
type GetParamsContext,
|
|
141
|
+
type PrerenderPassthroughResult,
|
|
125
142
|
} from "./prerender.js";
|
|
126
143
|
|
|
127
144
|
// Static handler API
|
|
128
|
-
export {
|
|
145
|
+
export {
|
|
146
|
+
Static,
|
|
147
|
+
type StaticHandlerDefinition,
|
|
148
|
+
type StaticHandlerOptions,
|
|
149
|
+
} from "./static-handler.js";
|
|
129
150
|
|
|
130
151
|
// Django-style URL patterns (RSC/server context)
|
|
131
152
|
export {
|
|
@@ -136,8 +157,7 @@ export {
|
|
|
136
157
|
type IncludeOptions,
|
|
137
158
|
type IncludeItem,
|
|
138
159
|
type RouteResponse,
|
|
139
|
-
type
|
|
140
|
-
type ResponseEnvelope,
|
|
160
|
+
type ProblemDetails,
|
|
141
161
|
type ResponseHandler,
|
|
142
162
|
type ResponseHandlerContext,
|
|
143
163
|
type JsonResponseHandler,
|
|
@@ -151,7 +171,7 @@ export {
|
|
|
151
171
|
// Core router (server-side)
|
|
152
172
|
export {
|
|
153
173
|
createRouter,
|
|
154
|
-
type
|
|
174
|
+
type Rango,
|
|
155
175
|
type RootLayoutProps,
|
|
156
176
|
type RouterRequestInput,
|
|
157
177
|
} from "./router.js";
|
|
@@ -183,16 +203,31 @@ export const getRequestContext: <
|
|
|
183
203
|
export {
|
|
184
204
|
cookies,
|
|
185
205
|
headers,
|
|
206
|
+
invalidateClientCache,
|
|
207
|
+
keepClientCache,
|
|
186
208
|
type CookieStore,
|
|
187
209
|
type Cookie,
|
|
188
210
|
type ReadonlyHeaders,
|
|
189
211
|
} from "./server/cookie-store.js";
|
|
190
212
|
|
|
213
|
+
// Cache tag APIs (server-only)
|
|
214
|
+
// cacheTag: tag the current "use cache" entry at runtime.
|
|
215
|
+
// updateTag: read-your-own-writes invalidation (awaitable, for Server Actions).
|
|
216
|
+
// revalidateTag: background hard-purge invalidation (not awaited, for route handlers / webhooks).
|
|
217
|
+
export { cacheTag } from "./cache/cache-tag.js";
|
|
218
|
+
export { updateTag, revalidateTag } from "./cache/tag-invalidation.js";
|
|
219
|
+
|
|
191
220
|
// Meta types
|
|
192
221
|
export type { MetaDescriptor, MetaDescriptorBase } from "./router/types.js";
|
|
193
222
|
|
|
194
223
|
// Middleware context types
|
|
195
|
-
export type {
|
|
224
|
+
export type {
|
|
225
|
+
MiddlewareContext,
|
|
226
|
+
CookieOptions,
|
|
227
|
+
// The function type of a middleware. Public so the documented "extract the
|
|
228
|
+
// middleware and unit-test it with runMiddleware" pattern has a nameable type.
|
|
229
|
+
MiddlewareFn,
|
|
230
|
+
} from "./router/middleware.js";
|
|
196
231
|
|
|
197
232
|
// Reverse type utilities for type-safe URL generation (Django-style URL reversal)
|
|
198
233
|
export type {
|
|
@@ -220,14 +255,33 @@ export {
|
|
|
220
255
|
type LocationStateOptions,
|
|
221
256
|
} from "./browser/react/location-state-shared.js";
|
|
222
257
|
|
|
223
|
-
// Path
|
|
224
|
-
|
|
258
|
+
// Path and response types are ambient on the `Rango` namespace (`Rango.Path`,
|
|
259
|
+
// `Rango.PathResponse`, declared in href-client.ts) — no import needed.
|
|
225
260
|
|
|
226
261
|
// Telemetry sink
|
|
227
262
|
export { createConsoleSink } from "./router/telemetry.js";
|
|
228
263
|
export { createOTelSink } from "./router/telemetry-otel.js";
|
|
229
264
|
export type { OTelTracer, OTelSpan } from "./router/telemetry-otel.js";
|
|
230
|
-
|
|
265
|
+
// The full TelemetryEvent union PLUS its member types, so a consumer writing a
|
|
266
|
+
// TelemetrySink can annotate a per-`type` handler (or construct an event literal
|
|
267
|
+
// in a test) instead of only narrowing the opaque union.
|
|
268
|
+
export type {
|
|
269
|
+
TelemetrySink,
|
|
270
|
+
TelemetryEvent,
|
|
271
|
+
RequestStartEvent,
|
|
272
|
+
RequestEndEvent,
|
|
273
|
+
RequestErrorEvent,
|
|
274
|
+
LoaderStartEvent,
|
|
275
|
+
LoaderEndEvent,
|
|
276
|
+
LoaderErrorEvent,
|
|
277
|
+
HandlerErrorEvent,
|
|
278
|
+
CacheSegmentStatus,
|
|
279
|
+
CacheSegmentSignal,
|
|
280
|
+
CacheDecisionEvent,
|
|
281
|
+
RevalidationDecisionEvent,
|
|
282
|
+
RequestTimeoutEvent,
|
|
283
|
+
OriginCheckRejectedEvent,
|
|
284
|
+
} from "./router/telemetry.js";
|
|
231
285
|
|
|
232
286
|
// Timeout types and error class
|
|
233
287
|
export { RouterTimeoutError } from "./router/timeout.js";
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export {
|
|
|
18
18
|
MiddlewareError,
|
|
19
19
|
HandlerError,
|
|
20
20
|
BuildError,
|
|
21
|
+
DslContextError,
|
|
21
22
|
InvalidHandlerError,
|
|
22
23
|
RouterError,
|
|
23
24
|
Skip,
|
|
@@ -43,6 +44,7 @@ export type {
|
|
|
43
44
|
// Revalidation types
|
|
44
45
|
RevalidateParams,
|
|
45
46
|
Revalidate,
|
|
47
|
+
ActionRef,
|
|
46
48
|
RouteKeys,
|
|
47
49
|
// Loader types
|
|
48
50
|
LoaderDefinition,
|
|
@@ -102,8 +104,7 @@ export type {
|
|
|
102
104
|
JsonResponsePathFn,
|
|
103
105
|
TextResponsePathFn,
|
|
104
106
|
RouteResponse,
|
|
105
|
-
|
|
106
|
-
ResponseEnvelope,
|
|
107
|
+
ProblemDetails,
|
|
107
108
|
} from "./urls.js";
|
|
108
109
|
|
|
109
110
|
// Middleware context types
|
|
@@ -139,6 +140,13 @@ export function redirect(): never {
|
|
|
139
140
|
|
|
140
141
|
// Handle API (universal - works on both server and client)
|
|
141
142
|
export { createHandle, isHandle, type Handle } from "./handle.js";
|
|
143
|
+
export {
|
|
144
|
+
DEFAULT_DEFER_TIMEOUT_MS,
|
|
145
|
+
type DeferOptions,
|
|
146
|
+
type DeferredHandleEntry,
|
|
147
|
+
type HandlePush,
|
|
148
|
+
type HandlePushFn,
|
|
149
|
+
} from "./defer.js";
|
|
142
150
|
|
|
143
151
|
// Context variable API (typed ctx.set/ctx.get tokens)
|
|
144
152
|
export { createVar, type ContextVar } from "./context-var.js";
|
|
@@ -216,6 +224,17 @@ export function headers(): never {
|
|
|
216
224
|
throw serverOnlyStubError("headers");
|
|
217
225
|
}
|
|
218
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Client implementation of `invalidateClientCache()`. Unlike the server-only
|
|
229
|
+
* stubs above this is a REAL function under the `default` condition (it marks
|
|
230
|
+
* the client's caches stale); the `react-server` condition (index.rsc.ts)
|
|
231
|
+
* selects the server implementation that writes a rotated `Set-Cookie`.
|
|
232
|
+
*/
|
|
233
|
+
export {
|
|
234
|
+
invalidateClientCache,
|
|
235
|
+
keepClientCache,
|
|
236
|
+
} from "./browser/invalidate-client-cache.js";
|
|
237
|
+
|
|
219
238
|
/**
|
|
220
239
|
* Error-throwing stub for server-only `createReverse` function.
|
|
221
240
|
*/
|
|
@@ -236,6 +255,18 @@ export function middleware(): never {
|
|
|
236
255
|
export function revalidate(): never {
|
|
237
256
|
throw serverOnlyStubError("revalidate");
|
|
238
257
|
}
|
|
258
|
+
// Cache tag APIs are server-only (real implementations in index.rsc.ts). These
|
|
259
|
+
// stubs keep the named-export shape identical under the default/non-react-server
|
|
260
|
+
// condition so SSR/client/default bundles that encounter the import link cleanly.
|
|
261
|
+
export function cacheTag(): never {
|
|
262
|
+
throw serverOnlyStubError("cacheTag");
|
|
263
|
+
}
|
|
264
|
+
export function updateTag(): never {
|
|
265
|
+
throw serverOnlyStubError("updateTag");
|
|
266
|
+
}
|
|
267
|
+
export function revalidateTag(): never {
|
|
268
|
+
throw serverOnlyStubError("revalidateTag");
|
|
269
|
+
}
|
|
239
270
|
export function loader(): never {
|
|
240
271
|
throw serverOnlyStubError("loader");
|
|
241
272
|
}
|
|
@@ -302,14 +333,38 @@ export {
|
|
|
302
333
|
type LocationStateOptions,
|
|
303
334
|
} from "./browser/react/location-state-shared.js";
|
|
304
335
|
|
|
305
|
-
// Path
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
// Telemetry
|
|
309
|
-
|
|
310
|
-
|
|
336
|
+
// Path and response types are ambient on the `Rango` namespace (`Rango.Path`,
|
|
337
|
+
// `Rango.PathResponse`, declared in href-client.ts) — no import needed.
|
|
338
|
+
|
|
339
|
+
// Telemetry types only — the createConsoleSink/createOTelSink values are
|
|
340
|
+
// server-only and live in index.rsc.ts (the `react-server` condition of the
|
|
341
|
+
// bare `@rangojs/router` import). Re-exporting them as values from this
|
|
342
|
+
// (default/client) entry would pull telemetry.ts and telemetry-otel.ts into
|
|
343
|
+
// the client module graph; both tree-shake to zero bytes but still appear in
|
|
344
|
+
// bundle analysis output and slow build-time module resolution. Consumers
|
|
345
|
+
// who need the values in non-RSC contexts can import from
|
|
346
|
+
// `@rangojs/router/server`.
|
|
311
347
|
export type { OTelTracer, OTelSpan } from "./router/telemetry-otel.js";
|
|
312
|
-
|
|
348
|
+
// The full TelemetryEvent union PLUS its member types, so a consumer writing a
|
|
349
|
+
// TelemetrySink can annotate a per-`type` handler (or construct an event literal
|
|
350
|
+
// in a test) instead of only narrowing the opaque union.
|
|
351
|
+
export type {
|
|
352
|
+
TelemetrySink,
|
|
353
|
+
TelemetryEvent,
|
|
354
|
+
RequestStartEvent,
|
|
355
|
+
RequestEndEvent,
|
|
356
|
+
RequestErrorEvent,
|
|
357
|
+
LoaderStartEvent,
|
|
358
|
+
LoaderEndEvent,
|
|
359
|
+
LoaderErrorEvent,
|
|
360
|
+
HandlerErrorEvent,
|
|
361
|
+
CacheSegmentStatus,
|
|
362
|
+
CacheSegmentSignal,
|
|
363
|
+
CacheDecisionEvent,
|
|
364
|
+
RevalidationDecisionEvent,
|
|
365
|
+
RequestTimeoutEvent,
|
|
366
|
+
OriginCheckRejectedEvent,
|
|
367
|
+
} from "./router/telemetry.js";
|
|
313
368
|
|
|
314
369
|
// Timeout types and error class
|
|
315
370
|
export { RouterTimeoutError } from "./router/timeout.js";
|
package/src/internal-debug.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// in all runtimes including Cloudflare Workers where process.env is unavailable.
|
|
4
|
-
// Falls back to process.env for non-Vite contexts (tests, direct Node usage).
|
|
1
|
+
// Vite define for compile-time injection; falls back to process.env (tests, Node).
|
|
2
|
+
// Works in all runtimes including Cloudflare Workers where process.env is unavailable.
|
|
5
3
|
export const INTERNAL_RANGO_DEBUG: boolean =
|
|
6
4
|
typeof __RANGO_DEBUG__ !== "undefined"
|
|
7
5
|
? __RANGO_DEBUG__
|