@rangojs/router 0.0.0-experimental.107 → 0.0.0-experimental.109
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 +4 -4
- package/dist/bin/rango.js +16 -16
- package/dist/vite/index.js +146 -150
- package/package.json +6 -6
- package/skills/hooks/SKILL.md +2 -0
- package/skills/links/SKILL.md +13 -1
- package/skills/loader/SKILL.md +1 -1
- package/skills/middleware/SKILL.md +3 -3
- package/skills/mime-routes/SKILL.md +27 -0
- package/skills/prerender/SKILL.md +13 -13
- package/skills/rango/SKILL.md +9 -0
- package/skills/response-routes/SKILL.md +58 -9
- package/skills/router-setup/SKILL.md +3 -3
- package/skills/typesafety/SKILL.md +273 -31
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +117 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/react/location-state-shared.ts +3 -3
- package/src/browser/react/use-handle.ts +17 -9
- package/src/browser/rsc-router.tsx +14 -14
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/build/generate-manifest.ts +3 -3
- package/src/build/route-types/codegen.ts +4 -4
- package/src/build/route-types/include-resolution.ts +1 -1
- package/src/build/route-types/per-module-writer.ts +3 -3
- package/src/build/route-types/router-processing.ts +4 -4
- package/src/build/route-types/scan-filter.ts +1 -1
- package/src/client.tsx +4 -7
- package/src/errors.ts +1 -1
- package/src/handle.ts +2 -2
- package/src/href-client.ts +136 -19
- package/src/index.rsc.ts +4 -4
- package/src/index.ts +2 -2
- package/src/loader.rsc.ts +1 -1
- package/src/loader.ts +1 -1
- package/src/prerender.ts +4 -4
- package/src/route-definition/dsl-helpers.ts +2 -2
- package/src/route-definition/helpers-types.ts +2 -2
- package/src/router/error-handling.ts +1 -1
- package/src/router/lazy-includes.ts +2 -2
- package/src/router/metrics.ts +1 -1
- package/src/router/middleware-types.ts +1 -1
- package/src/router/prerender-match.ts +1 -1
- package/src/router/router-interfaces.ts +34 -28
- package/src/router/router-options.ts +1 -1
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +2 -2
- package/src/router/segment-resolution/revalidation.ts +2 -2
- package/src/router.ts +13 -16
- package/src/rsc/handler-context.ts +2 -2
- package/src/rsc/index.ts +1 -1
- package/src/rsc/types.ts +2 -2
- package/src/search-params.ts +4 -4
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +16 -16
- package/src/static-handler.ts +1 -1
- package/src/types/global-namespace.ts +39 -26
- package/src/types/handler-context.ts +3 -3
- package/src/urls/path-helper-types.ts +2 -2
- package/src/urls/pattern-types.ts +34 -0
- package/src/urls/type-extraction.ts +6 -1
- package/src/use-loader.tsx +6 -4
- package/src/vite/discovery/bundle-postprocess.ts +6 -6
- package/src/vite/discovery/discover-routers.ts +3 -3
- package/src/vite/discovery/discovery-errors.ts +1 -1
- package/src/vite/discovery/prerender-collection.ts +19 -25
- package/src/vite/discovery/route-types-writer.ts +3 -3
- package/src/vite/discovery/state.ts +4 -4
- package/src/vite/plugins/cloudflare-protocol-stub.ts +1 -1
- package/src/vite/plugins/expose-action-id.ts +2 -2
- package/src/vite/plugins/expose-id-utils.ts +12 -8
- package/src/vite/plugins/expose-ids/export-analysis.ts +33 -9
- package/src/vite/plugins/expose-internal-ids.ts +1 -1
- package/src/vite/plugins/performance-tracks.ts +12 -16
- package/src/vite/plugins/use-cache-transform.ts +1 -1
- package/src/vite/plugins/version-plugin.ts +2 -2
- package/src/vite/plugins/virtual-entries.ts +2 -2
- package/src/vite/rango.ts +11 -11
- package/src/vite/router-discovery.ts +26 -29
- package/src/vite/utils/ast-handler-extract.ts +15 -15
- package/src/vite/utils/bundle-analysis.ts +4 -2
- package/src/vite/utils/forward-user-plugins.ts +46 -17
- package/src/vite/utils/shared-utils.ts +26 -22
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "../server/context";
|
|
17
17
|
import { invariant } from "../errors";
|
|
18
18
|
import { isCachedFunction } from "../cache/taint.js";
|
|
19
|
-
import {
|
|
19
|
+
import { RangoContext } from "../server/context";
|
|
20
20
|
import { isStaticHandler } from "../static-handler.js";
|
|
21
21
|
import RootLayout from "../server/root-layout";
|
|
22
22
|
import type {
|
|
@@ -232,7 +232,7 @@ const cache: RouteHelpers<any, any>["cache"] = (
|
|
|
232
232
|
} else if (typeof optionsOrChildren === "string") {
|
|
233
233
|
// cache('profileName') or cache('profileName', () => [...])
|
|
234
234
|
// Resolve from context-scoped profiles (set per-router via HelperContext).
|
|
235
|
-
const ctxStore =
|
|
235
|
+
const ctxStore = RangoContext.getStore();
|
|
236
236
|
const profile = ctxStore?.cacheProfiles?.[optionsOrChildren];
|
|
237
237
|
invariant(
|
|
238
238
|
profile,
|
|
@@ -198,10 +198,10 @@ export type RouteHelpers<T extends RouteDefinition, TEnv> = {
|
|
|
198
198
|
use?: () => UseItems<InterceptUseItem>,
|
|
199
199
|
): InterceptItem;
|
|
200
200
|
// Global: unprefixed, params inferred from global route map
|
|
201
|
-
<K extends keyof
|
|
201
|
+
<K extends keyof Rango.GeneratedRouteMap & string>(
|
|
202
202
|
slotName: `@${string}`,
|
|
203
203
|
routeName: K,
|
|
204
|
-
handler: ReactNode | Handler<K,
|
|
204
|
+
handler: ReactNode | Handler<K, Rango.GeneratedRouteMap, TEnv>,
|
|
205
205
|
use?: () => UseItems<InterceptUseItem>,
|
|
206
206
|
): InterceptItem;
|
|
207
207
|
};
|
|
@@ -2,7 +2,7 @@ import { registerRouteMap } from "../route-map-builder.js";
|
|
|
2
2
|
import { extractStaticPrefix } from "./pattern-matching.js";
|
|
3
3
|
import {
|
|
4
4
|
type EntryData,
|
|
5
|
-
|
|
5
|
+
RangoContext,
|
|
6
6
|
runWithPrefixes,
|
|
7
7
|
getIsolatedLazyParent,
|
|
8
8
|
} from "../server/context";
|
|
@@ -131,7 +131,7 @@ export function evaluateLazyEntry<TEnv = any>(
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
RangoContext.run(
|
|
135
135
|
{
|
|
136
136
|
manifest,
|
|
137
137
|
patterns,
|
package/src/router/metrics.ts
CHANGED
|
@@ -140,7 +140,7 @@ export interface MiddlewareContext<
|
|
|
140
140
|
* @template TEnv - Environment type - defaults to any for internal flexibility
|
|
141
141
|
* @template TParams - URL params type (typed for route middleware)
|
|
142
142
|
*
|
|
143
|
-
* When using middleware with global augmentation (
|
|
143
|
+
* When using middleware with global augmentation (Rango.Env), explicitly
|
|
144
144
|
* annotate your middleware functions, or the types will be inferred from context:
|
|
145
145
|
*
|
|
146
146
|
* @example
|
|
@@ -126,7 +126,7 @@ export async function matchForPrerender<TEnv = any>(
|
|
|
126
126
|
get env() {
|
|
127
127
|
if (buildEnv !== undefined) return buildEnv;
|
|
128
128
|
throw new Error(
|
|
129
|
-
"[
|
|
129
|
+
"[rango] ctx.env is not available during dev-mode getParams(). " +
|
|
130
130
|
"Configure buildEnv in your rango() plugin options to enable build-time env access.",
|
|
131
131
|
);
|
|
132
132
|
},
|
|
@@ -2,7 +2,7 @@ import type { ComponentType, ReactNode } from "react";
|
|
|
2
2
|
import type { SerializedManifest } from "../debug.js";
|
|
3
3
|
import type { ReverseFunction } from "../reverse.js";
|
|
4
4
|
import type { UrlPatterns } from "../urls.js";
|
|
5
|
-
import type { UrlBuilder } from "../urls/pattern-types.js";
|
|
5
|
+
import type { UrlBuilder, EnvCompatible } from "../urls/pattern-types.js";
|
|
6
6
|
import type { EntryData } from "../server/context";
|
|
7
7
|
import type { ErrorInfo, MatchResult } from "../types";
|
|
8
8
|
import type { NonceProvider } from "../rsc/types.js";
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
} from "../cache/types.js";
|
|
14
14
|
import type { MiddlewareEntry, MiddlewareFn } from "./middleware.js";
|
|
15
15
|
import { RSC_ROUTER_BRAND } from "./router-registry.js";
|
|
16
|
-
import type {
|
|
16
|
+
import type { RangoOptions, RootLayoutProps } from "./router-options.js";
|
|
17
17
|
import type { DefaultVars } from "../types/global-namespace.js";
|
|
18
18
|
import type { ResolvedTimeouts, OnTimeoutCallback } from "./timeout.js";
|
|
19
19
|
|
|
@@ -49,16 +49,16 @@ type MergeRoutesWithResponses<
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Public
|
|
52
|
+
* Public Rango router interface — the user-facing API surface.
|
|
53
53
|
*
|
|
54
54
|
* Users interact with this type when building and using routers.
|
|
55
|
-
* Internal framework code uses
|
|
55
|
+
* Internal framework code uses RangoInternal (via toInternal()) to access
|
|
56
56
|
* matching, build-time, and configuration members that are not part of the
|
|
57
57
|
* public contract.
|
|
58
58
|
*
|
|
59
59
|
* TRoutes accumulates all registered route types through the builder chain.
|
|
60
60
|
*/
|
|
61
|
-
export interface
|
|
61
|
+
export interface Rango<
|
|
62
62
|
TEnv = any,
|
|
63
63
|
TRoutes extends Record<string, unknown> = Record<string, string>,
|
|
64
64
|
> {
|
|
@@ -89,16 +89,16 @@ export interface RSCRouter<
|
|
|
89
89
|
* ])
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
routes<T extends UrlPatterns<
|
|
93
|
-
patterns: T,
|
|
94
|
-
):
|
|
92
|
+
routes<T extends UrlPatterns<any, any, any>>(
|
|
93
|
+
patterns: T & EnvCompatible<T, TEnv>,
|
|
94
|
+
): Rango<
|
|
95
95
|
TEnv,
|
|
96
96
|
TRoutes &
|
|
97
97
|
(NonNullable<T["_routes"]> extends Record<string, unknown>
|
|
98
98
|
? MergeRoutesWithResponses<NonNullable<T["_routes"]>, T["_responses"]>
|
|
99
99
|
: Record<string, string>)
|
|
100
100
|
>;
|
|
101
|
-
routes(builder: UrlBuilder<TEnv>):
|
|
101
|
+
routes(builder: UrlBuilder<TEnv>): Rango<TEnv, TRoutes>;
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Add global middleware that runs on all routes
|
|
@@ -114,7 +114,7 @@ export interface RSCRouter<
|
|
|
114
114
|
use(
|
|
115
115
|
patternOrMiddleware: string | MiddlewareFn<TEnv>,
|
|
116
116
|
middleware?: MiddlewareFn<TEnv>,
|
|
117
|
-
):
|
|
117
|
+
): Rango<TEnv, TRoutes>;
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Type-safe URL builder for registered routes
|
|
@@ -141,7 +141,7 @@ export interface RSCRouter<
|
|
|
141
141
|
* type AppRoutes = typeof _router.routeMap;
|
|
142
142
|
*
|
|
143
143
|
* declare global {
|
|
144
|
-
* namespace
|
|
144
|
+
* namespace Rango {
|
|
145
145
|
* interface RegisteredRoutes extends AppRoutes {}
|
|
146
146
|
* }
|
|
147
147
|
* }
|
|
@@ -177,16 +177,16 @@ export interface RSCRouter<
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* Internal
|
|
180
|
+
* Internal Rango router interface — the full framework-facing API.
|
|
181
181
|
*
|
|
182
182
|
* This type includes all members used by the Vite plugin, RSC handler,
|
|
183
183
|
* pre-rendering pipeline, and other framework internals. It is NOT exported
|
|
184
184
|
* from the public package API.
|
|
185
185
|
*
|
|
186
|
-
* Use toInternal(router) to assert a public
|
|
186
|
+
* Use toInternal(router) to assert a public Rango into this type
|
|
187
187
|
* at the boundary where framework code receives a user-provided router.
|
|
188
188
|
*/
|
|
189
|
-
export interface
|
|
189
|
+
export interface RangoInternal<
|
|
190
190
|
TEnv = any,
|
|
191
191
|
TRoutes extends Record<string, unknown> = Record<string, string>,
|
|
192
192
|
> {
|
|
@@ -206,18 +206,24 @@ export interface RSCRouterInternal<
|
|
|
206
206
|
readonly basename: string | undefined;
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
|
-
* Register routes using URL patterns from urls() or a builder function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
* Register routes using URL patterns from urls() or a builder function.
|
|
210
|
+
*
|
|
211
|
+
* Env compatibility is checked by EnvCompatible: an env-agnostic urls() block
|
|
212
|
+
* (its env is `unknown` — e.g. a shared module, or an app that does not augment
|
|
213
|
+
* `Rango.Env`) attaches to any router, while a urls<TEnv>() block carrying a
|
|
214
|
+
* concrete env is accepted only when this router's `TEnv` satisfies it. So a
|
|
215
|
+
* `urls<{ DB }>()` cannot be mounted on a `createRouter<{}>()`.
|
|
216
|
+
*/
|
|
217
|
+
routes<T extends UrlPatterns<any, any, any>>(
|
|
218
|
+
patterns: T & EnvCompatible<T, TEnv>,
|
|
219
|
+
): Rango<
|
|
214
220
|
TEnv,
|
|
215
221
|
TRoutes &
|
|
216
222
|
(NonNullable<T["_routes"]> extends Record<string, unknown>
|
|
217
223
|
? MergeRoutesWithResponses<NonNullable<T["_routes"]>, T["_responses"]>
|
|
218
224
|
: Record<string, string>)
|
|
219
225
|
>;
|
|
220
|
-
routes(builder: UrlBuilder<TEnv>):
|
|
226
|
+
routes(builder: UrlBuilder<TEnv>): Rango<TEnv, TRoutes>;
|
|
221
227
|
|
|
222
228
|
/**
|
|
223
229
|
* Add global middleware that runs on all routes
|
|
@@ -225,7 +231,7 @@ export interface RSCRouterInternal<
|
|
|
225
231
|
use(
|
|
226
232
|
patternOrMiddleware: string | MiddlewareFn<TEnv>,
|
|
227
233
|
middleware?: MiddlewareFn<TEnv>,
|
|
228
|
-
):
|
|
234
|
+
): Rango<TEnv, TRoutes>;
|
|
229
235
|
|
|
230
236
|
/**
|
|
231
237
|
* Type-safe URL builder for registered routes
|
|
@@ -247,17 +253,17 @@ export interface RSCRouterInternal<
|
|
|
247
253
|
* Error callback for monitoring/alerting
|
|
248
254
|
* Called when errors occur in loaders, actions, or routes
|
|
249
255
|
*/
|
|
250
|
-
readonly onError?:
|
|
256
|
+
readonly onError?: RangoOptions<TEnv>["onError"];
|
|
251
257
|
|
|
252
258
|
/**
|
|
253
259
|
* Cache configuration
|
|
254
260
|
*/
|
|
255
|
-
readonly cache?:
|
|
261
|
+
readonly cache?: RangoOptions<TEnv>["cache"];
|
|
256
262
|
|
|
257
263
|
/**
|
|
258
264
|
* Not found component to render when no route matches
|
|
259
265
|
*/
|
|
260
|
-
readonly notFound?:
|
|
266
|
+
readonly notFound?: RangoOptions<TEnv>["notFound"];
|
|
261
267
|
|
|
262
268
|
/**
|
|
263
269
|
* Resolved theme configuration (null if theme not enabled)
|
|
@@ -469,16 +475,16 @@ export interface RSCRouterInternal<
|
|
|
469
475
|
}
|
|
470
476
|
|
|
471
477
|
/**
|
|
472
|
-
* Assert a public
|
|
478
|
+
* Assert a public Rango into the internal type.
|
|
473
479
|
*
|
|
474
480
|
* Use this at the boundary where framework code receives a user-provided
|
|
475
481
|
* router and needs access to internal members (match, config, build-time).
|
|
476
482
|
* The cast is safe because createRouter() always produces an object that
|
|
477
|
-
* satisfies
|
|
483
|
+
* satisfies RangoInternal; the public type is just a narrower view.
|
|
478
484
|
*/
|
|
479
485
|
export function toInternal<
|
|
480
486
|
TEnv = any,
|
|
481
487
|
TRoutes extends Record<string, unknown> = Record<string, string>,
|
|
482
|
-
>(router:
|
|
483
|
-
return router as
|
|
488
|
+
>(router: Rango<TEnv, TRoutes>): RangoInternal<TEnv, TRoutes> {
|
|
489
|
+
return router as RangoInternal<TEnv, TRoutes>;
|
|
484
490
|
}
|
|
@@ -73,7 +73,7 @@ export interface RootLayoutProps {
|
|
|
73
73
|
/**
|
|
74
74
|
* Router configuration options
|
|
75
75
|
*/
|
|
76
|
-
export interface
|
|
76
|
+
export interface RangoOptions<TEnv = any> {
|
|
77
77
|
/**
|
|
78
78
|
* Unique identifier for this router instance.
|
|
79
79
|
* Used to namespace static output files and route maps.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RangoInternal } from "./router-interfaces.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Brand marker for identifying router instances at build time.
|
|
@@ -12,10 +12,7 @@ export const RSC_ROUTER_BRAND = "__rsc_router__" as const;
|
|
|
12
12
|
* Used by the Vite plugin at build time to discover routers and extract
|
|
13
13
|
* manifests, prefix trees, and pre-render candidates.
|
|
14
14
|
*/
|
|
15
|
-
export const RouterRegistry: Map<
|
|
16
|
-
string,
|
|
17
|
-
RSCRouterInternal<any, any>
|
|
18
|
-
> = new Map();
|
|
15
|
+
export const RouterRegistry: Map<string, RangoInternal<any, any>> = new Map();
|
|
19
16
|
|
|
20
17
|
export let routerAutoId = 0;
|
|
21
18
|
|
|
@@ -32,7 +32,7 @@ import { getRouterContext } from "../router-context.js";
|
|
|
32
32
|
import { resolveSink, safeEmit } from "../telemetry.js";
|
|
33
33
|
import {
|
|
34
34
|
track,
|
|
35
|
-
|
|
35
|
+
RangoContext,
|
|
36
36
|
runInsideLoaderScope,
|
|
37
37
|
} from "../../server/context.js";
|
|
38
38
|
|
|
@@ -632,7 +632,7 @@ export async function resolveAllSegments<TEnv>(
|
|
|
632
632
|
// can guard non-cacheable variable reads. Also guards response-level
|
|
633
633
|
// side effects (headers.set). Persists for all descendant entries.
|
|
634
634
|
if (entry.type === "cache") {
|
|
635
|
-
const store =
|
|
635
|
+
const store = RangoContext.getStore();
|
|
636
636
|
if (store) store.insideCacheScope = true;
|
|
637
637
|
}
|
|
638
638
|
const doneEntry = track(`segment:${entry.id}`, 1);
|
|
@@ -43,7 +43,7 @@ import { getRouterContext } from "../router-context.js";
|
|
|
43
43
|
import { resolveSink, safeEmit } from "../telemetry.js";
|
|
44
44
|
import {
|
|
45
45
|
track,
|
|
46
|
-
|
|
46
|
+
RangoContext,
|
|
47
47
|
runInsideLoaderScope,
|
|
48
48
|
} from "../../server/context.js";
|
|
49
49
|
|
|
@@ -1356,7 +1356,7 @@ export async function resolveAllSegmentsWithRevalidation<TEnv>(
|
|
|
1356
1356
|
|
|
1357
1357
|
const nonParallelEntry = entry as Exclude<EntryData, { type: "parallel" }>;
|
|
1358
1358
|
if (entry.type === "cache") {
|
|
1359
|
-
const store =
|
|
1359
|
+
const store = RangoContext.getStore();
|
|
1360
1360
|
if (store) store.insideCacheScope = true;
|
|
1361
1361
|
}
|
|
1362
1362
|
const doneEntry = track(`segment:${entry.id}`, 1);
|
package/src/router.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { urls } from "./urls.js";
|
|
|
24
24
|
import {
|
|
25
25
|
type EntryData,
|
|
26
26
|
getContext,
|
|
27
|
-
|
|
27
|
+
RangoContext,
|
|
28
28
|
type MetricsStore,
|
|
29
29
|
} from "./server/context";
|
|
30
30
|
import { createHandleStore, type HandleStore } from "./server/handle-store.js";
|
|
@@ -90,13 +90,10 @@ import {
|
|
|
90
90
|
RouterRegistry,
|
|
91
91
|
nextRouterAutoId,
|
|
92
92
|
} from "./router/router-registry.js";
|
|
93
|
+
import type { RangoOptions, RootLayoutProps } from "./router/router-options.js";
|
|
93
94
|
import type {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} from "./router/router-options.js";
|
|
97
|
-
import type {
|
|
98
|
-
RSCRouter,
|
|
99
|
-
RSCRouterInternal,
|
|
95
|
+
Rango,
|
|
96
|
+
RangoInternal,
|
|
100
97
|
RouterRequestInput,
|
|
101
98
|
} from "./router/router-interfaces.js";
|
|
102
99
|
|
|
@@ -115,22 +112,22 @@ import {
|
|
|
115
112
|
// Re-export public types and values from extracted modules
|
|
116
113
|
export { RSC_ROUTER_BRAND, RouterRegistry } from "./router/router-registry.js";
|
|
117
114
|
export type {
|
|
118
|
-
|
|
115
|
+
RangoOptions,
|
|
119
116
|
RootLayoutProps,
|
|
120
117
|
SSRStreamMode,
|
|
121
118
|
SSROptions,
|
|
122
119
|
ResolveStreamingContext,
|
|
123
120
|
} from "./router/router-options.js";
|
|
124
121
|
export type {
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
Rango,
|
|
123
|
+
RangoInternal,
|
|
127
124
|
RouterRequestInput,
|
|
128
125
|
} from "./router/router-interfaces.js";
|
|
129
126
|
export { toInternal } from "./router/router-interfaces.js";
|
|
130
127
|
|
|
131
128
|
export function createRouter<TEnv = any>(
|
|
132
|
-
options:
|
|
133
|
-
):
|
|
129
|
+
options: RangoOptions<TEnv> = {},
|
|
130
|
+
): Rango<TEnv, {}> {
|
|
134
131
|
const {
|
|
135
132
|
id: userProvidedId,
|
|
136
133
|
$$id: injectedId,
|
|
@@ -673,7 +670,7 @@ export function createRouter<TEnv = any>(
|
|
|
673
670
|
* The type system tracks accumulated routes through the builder chain
|
|
674
671
|
* Initial TRoutes is {} (empty) to avoid poisoning accumulated types with Record<string, string>
|
|
675
672
|
*/
|
|
676
|
-
const router:
|
|
673
|
+
const router: RangoInternal<TEnv, {}> = {
|
|
677
674
|
__brand: RSC_ROUTER_BRAND,
|
|
678
675
|
id: routerId,
|
|
679
676
|
basename,
|
|
@@ -721,7 +718,7 @@ export function createRouter<TEnv = any>(
|
|
|
721
718
|
};
|
|
722
719
|
|
|
723
720
|
let handlerResult: AllUseItems[] = [];
|
|
724
|
-
|
|
721
|
+
RangoContext.run(
|
|
725
722
|
{
|
|
726
723
|
manifest,
|
|
727
724
|
patterns: routePatterns,
|
|
@@ -1045,9 +1042,9 @@ export function createRouter<TEnv = any>(
|
|
|
1045
1042
|
|
|
1046
1043
|
// If urls option was provided, auto-register them
|
|
1047
1044
|
if (typeof urlsOption === "function") {
|
|
1048
|
-
return router.routes(urlsOption) as
|
|
1045
|
+
return router.routes(urlsOption) as Rango<TEnv, {}>;
|
|
1049
1046
|
} else if (urlsOption) {
|
|
1050
|
-
return router.routes(urlsOption) as
|
|
1047
|
+
return router.routes(urlsOption) as Rango<TEnv, {}>;
|
|
1051
1048
|
}
|
|
1052
1049
|
|
|
1053
1050
|
return router;
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
* RSC rendering) so they can be standalone modules without closure coupling.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { RangoInternal } from "../router/router-interfaces.js";
|
|
10
10
|
import type { ErrorPhase } from "../types.js";
|
|
11
11
|
import type { InvokeOnErrorContext } from "../router/error-handling.js";
|
|
12
12
|
import type { RSCDependencies, LoadSSRModule } from "./types.js";
|
|
13
13
|
import type { SSRStreamMode } from "../router/router-options.js";
|
|
14
14
|
|
|
15
15
|
export interface HandlerContext<TEnv = unknown> {
|
|
16
|
-
router:
|
|
16
|
+
router: RangoInternal<TEnv, any>;
|
|
17
17
|
version: string;
|
|
18
18
|
renderToReadableStream: RSCDependencies["renderToReadableStream"];
|
|
19
19
|
decodeReply: RSCDependencies["decodeReply"];
|
package/src/rsc/index.ts
CHANGED
package/src/rsc/types.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { ResolvedSegment, SlotState } from "../types.js";
|
|
9
9
|
import type { HandleData } from "../server/handle-store.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type { RangoInternal } from "../router/router-interfaces.js";
|
|
11
11
|
import type { ResolvedThemeConfig, Theme } from "../theme/types.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -185,7 +185,7 @@ export interface CreateRSCHandlerOptions<
|
|
|
185
185
|
/**
|
|
186
186
|
* The RSC router instance
|
|
187
187
|
*/
|
|
188
|
-
router:
|
|
188
|
+
router: RangoInternal<TEnv, TRoutes>;
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
* RSC dependencies from @vitejs/plugin-rsc/rsc.
|
package/src/search-params.ts
CHANGED
|
@@ -81,11 +81,11 @@ export type ResolveSearchSchema<T extends SearchSchema> = Simplify<
|
|
|
81
81
|
// ============================================================================
|
|
82
82
|
|
|
83
83
|
/** Resolve the global route map from RegisteredRoutes or GeneratedRouteMap. */
|
|
84
|
-
type GlobalRouteMap = keyof
|
|
85
|
-
? keyof
|
|
84
|
+
type GlobalRouteMap = keyof Rango.RegisteredRoutes extends never
|
|
85
|
+
? keyof Rango.GeneratedRouteMap extends never
|
|
86
86
|
? Record<string, string>
|
|
87
|
-
:
|
|
88
|
-
:
|
|
87
|
+
: Rango.GeneratedRouteMap
|
|
88
|
+
: Rango.RegisteredRoutes;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Extract the resolved search params type for a named route.
|