@reckona/mreact-router 0.0.160 → 0.0.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +6 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/adapters/aws-lambda.d.ts +29 -0
- package/dist/adapters/aws-lambda.d.ts.map +1 -1
- package/dist/adapters/aws-lambda.js.map +1 -1
- package/dist/adapters/cloudflare.d.ts +78 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/edge.d.ts +6 -0
- package/dist/adapters/edge.d.ts.map +1 -1
- package/dist/adapters/edge.js.map +1 -1
- package/dist/adapters/node.d.ts +7 -0
- package/dist/adapters/node.d.ts.map +1 -1
- package/dist/adapters/node.js.map +1 -1
- package/dist/adapters/static.d.ts +6 -0
- package/dist/adapters/static.d.ts.map +1 -1
- package/dist/adapters/static.js.map +1 -1
- package/dist/app-router-globals.d.ts +6 -0
- package/dist/app-router-globals.d.ts.map +1 -1
- package/dist/app-router-globals.js.map +1 -1
- package/dist/assets.d.ts +18 -0
- package/dist/assets.d.ts.map +1 -1
- package/dist/assets.js +6 -0
- package/dist/assets.js.map +1 -1
- package/dist/build.d.ts +30 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +4 -0
- package/dist/build.js.map +1 -1
- package/dist/cache-stats.d.ts +3 -0
- package/dist/cache-stats.d.ts.map +1 -1
- package/dist/cache-stats.js.map +1 -1
- package/dist/cache.d.ts +15 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/cli-options.d.ts.map +1 -1
- package/dist/cli-options.js +2 -0
- package/dist/cli-options.js.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +15 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/cookies.d.ts +3 -0
- package/dist/cookies.d.ts.map +1 -1
- package/dist/cookies.js.map +1 -1
- package/dist/csrf.d.ts +12 -0
- package/dist/csrf.d.ts.map +1 -1
- package/dist/csrf.js +12 -0
- package/dist/csrf.js.map +1 -1
- package/dist/deferred.d.ts +9 -0
- package/dist/deferred.d.ts.map +1 -1
- package/dist/deferred.js +6 -0
- package/dist/deferred.js.map +1 -1
- package/dist/dev-server.d.ts +3 -0
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js.map +1 -1
- package/dist/file-conventions.d.ts +3 -0
- package/dist/file-conventions.d.ts.map +1 -1
- package/dist/file-conventions.js.map +1 -1
- package/dist/i18n.d.ts +15 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/import-policy.d.ts +3 -0
- package/dist/import-policy.d.ts.map +1 -1
- package/dist/import-policy.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/link.d.ts +34 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js.map +1 -1
- package/dist/logger.d.ts +33 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/multipart.d.ts +15 -0
- package/dist/multipart.d.ts.map +1 -1
- package/dist/multipart.js +3 -0
- package/dist/multipart.js.map +1 -1
- package/dist/native-escape.d.ts +3 -0
- package/dist/native-escape.d.ts.map +1 -1
- package/dist/native-escape.js +3 -0
- package/dist/native-escape.js.map +1 -1
- package/dist/navigation-state.d.ts +15 -0
- package/dist/navigation-state.d.ts.map +1 -1
- package/dist/navigation-state.js +6 -0
- package/dist/navigation-state.js.map +1 -1
- package/dist/navigation.d.ts +9 -0
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +6 -0
- package/dist/navigation.js.map +1 -1
- package/dist/prerender-store.d.ts +21 -0
- package/dist/prerender-store.d.ts.map +1 -1
- package/dist/prerender-store.js +9 -0
- package/dist/prerender-store.js.map +1 -1
- package/dist/render.d.ts +12 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +3 -0
- package/dist/render.js.map +1 -1
- package/dist/routes.d.ts +30 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +6 -0
- package/dist/routes.js.map +1 -1
- package/dist/runtime-cache.d.ts +4 -0
- package/dist/runtime-cache.d.ts.map +1 -1
- package/dist/runtime-cache.js +3 -0
- package/dist/runtime-cache.js.map +1 -1
- package/dist/runtime-state.d.ts +3 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +3 -0
- package/dist/runtime-state.js.map +1 -1
- package/dist/serve.d.ts +24 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +6 -0
- package/dist/serve.js.map +1 -1
- package/dist/session.d.ts +12 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/stream-list.d.ts +12 -0
- package/dist/stream-list.d.ts.map +1 -1
- package/dist/stream-list.js +3 -0
- package/dist/stream-list.js.map +1 -1
- package/dist/trace.d.ts +30 -0
- package/dist/trace.d.ts.map +1 -1
- package/dist/trace.js +6 -0
- package/dist/trace.js.map +1 -1
- package/dist/typed-routes.d.ts +33 -0
- package/dist/typed-routes.d.ts.map +1 -1
- package/dist/typed-routes.js.map +1 -1
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/upgrade.d.ts +3 -0
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js.map +1 -1
- package/dist/vite.d.ts +21 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +15 -0
- package/dist/vite.js.map +1 -1
- package/package.json +11 -11
- package/src/actions.ts +6 -0
- package/src/adapters/aws-lambda.ts +29 -0
- package/src/adapters/cloudflare.ts +78 -0
- package/src/adapters/edge.ts +6 -0
- package/src/adapters/node.ts +7 -0
- package/src/adapters/static.ts +6 -0
- package/src/app-router-globals.ts +6 -0
- package/src/assets.ts +18 -0
- package/src/build.ts +38 -0
- package/src/cache-stats.ts +3 -0
- package/src/cache.ts +15 -0
- package/src/cli-options.ts +2 -0
- package/src/cli.ts +1 -0
- package/src/config.ts +15 -0
- package/src/cookies.ts +3 -0
- package/src/csrf.ts +12 -0
- package/src/deferred.ts +9 -0
- package/src/dev-server.ts +3 -0
- package/src/file-conventions.ts +3 -0
- package/src/i18n.ts +15 -0
- package/src/import-policy.ts +3 -0
- package/src/index.ts +19 -0
- package/src/link.ts +34 -0
- package/src/logger.ts +33 -0
- package/src/multipart.ts +15 -0
- package/src/native-escape.ts +3 -0
- package/src/navigation-state.ts +15 -0
- package/src/navigation.ts +9 -0
- package/src/prerender-store.ts +21 -0
- package/src/render.ts +12 -0
- package/src/routes.ts +30 -0
- package/src/runtime-cache.ts +5 -0
- package/src/runtime-state.ts +3 -0
- package/src/serve.ts +24 -0
- package/src/session.ts +12 -0
- package/src/stream-list.ts +12 -0
- package/src/trace.ts +30 -0
- package/src/typed-routes.ts +33 -0
- package/src/types.ts +72 -0
- package/src/upgrade.ts +3 -0
- package/src/vite.ts +21 -0
package/src/typed-routes.ts
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a value accepted in generated route search params.
|
|
3
|
+
*/
|
|
1
4
|
export type RouteSearchValue = boolean | number | string | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Represents search params accepted by typed route href helpers.
|
|
7
|
+
*/
|
|
2
8
|
export type RouteSearchParams = Record<
|
|
3
9
|
string,
|
|
4
10
|
RouteSearchValue | readonly RouteSearchValue[]
|
|
5
11
|
>;
|
|
6
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Extracts dynamic and catch-all params from an app route path pattern.
|
|
15
|
+
*/
|
|
7
16
|
export type RouteParamsFor<Path extends `/${string}`> = Simplify<ExtractRouteParams<Path>>;
|
|
8
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Builds the callable `href()` helper type for a specific app route path.
|
|
20
|
+
*/
|
|
9
21
|
export type AppRouteHref<Path extends `/${string}`> = keyof RouteParamsFor<Path> extends never
|
|
10
22
|
? (options?: StaticHrefOptions) => string
|
|
11
23
|
: (options: DynamicHrefOptions<Path>) => string;
|
|
12
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Builds the Link `href` string type accepted for a specific app route path.
|
|
27
|
+
*/
|
|
13
28
|
export type AppRouteLinkHref<Path extends `/${string}`> =
|
|
14
29
|
`${AppRouteLinkPathname<Path>}${AppRouteLinkHrefSuffix}`;
|
|
15
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Configures a static href with optional search params and hash.
|
|
33
|
+
*/
|
|
16
34
|
export interface StaticHrefOptions {
|
|
17
35
|
hash?: string | undefined;
|
|
18
36
|
search?: RouteSearchParams | undefined;
|
|
19
37
|
}
|
|
20
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Configures a dynamic href with route params, optional search params, and hash.
|
|
41
|
+
*/
|
|
21
42
|
export interface DynamicHrefOptions<Path extends `/${string}`> extends StaticHrefOptions {
|
|
22
43
|
params: RouteParamsFor<Path>;
|
|
23
44
|
}
|
|
@@ -38,18 +59,30 @@ type SegmentRouteParam<Segment extends string> = Segment extends `:...${infer Na
|
|
|
38
59
|
|
|
39
60
|
type Simplify<T> = { [Key in keyof T]: T[Key] } & {};
|
|
40
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Represents the search and hash suffix portion of a typed route href.
|
|
64
|
+
*/
|
|
41
65
|
export type AppRouteLinkHrefSuffix = "" | `?${string}` | `#${string}` | `?${string}#${string}`;
|
|
42
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Builds the pathname string type for a typed route href.
|
|
69
|
+
*/
|
|
43
70
|
export type AppRouteLinkPathname<Path extends `/${string}`> = Path extends "/"
|
|
44
71
|
? "/"
|
|
45
72
|
: Path extends `/${infer Segments}`
|
|
46
73
|
? `/${AppRouteLinkSegments<Segments>}`
|
|
47
74
|
: never;
|
|
48
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Builds the joined path segment string type for a typed route href.
|
|
78
|
+
*/
|
|
49
79
|
export type AppRouteLinkSegments<Segments extends string> = Segments extends `${infer Segment}/${infer Rest}`
|
|
50
80
|
? `${AppRouteLinkSegment<Segment>}/${AppRouteLinkSegments<Rest>}`
|
|
51
81
|
: AppRouteLinkSegment<Segments>;
|
|
52
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Builds the string type for one static or dynamic route segment.
|
|
85
|
+
*/
|
|
53
86
|
export type AppRouteLinkSegment<Segment extends string> = Segment extends `:${string}`
|
|
54
87
|
? string
|
|
55
88
|
: Segment;
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import type { ReactCompatNode } from "@reckona/mreact-compat";
|
|
2
2
|
import type { QueryClient } from "@reckona/mreact-query";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents an app-router loader function.
|
|
6
|
+
*/
|
|
4
7
|
export type RouteLoader = (...args: never[]) => unknown;
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Infers resolved data returned by a route loader.
|
|
11
|
+
*/
|
|
6
12
|
export type InferLoaderData<TLoader extends RouteLoader> = Awaited<ReturnType<TLoader>>;
|
|
7
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Represents dynamic route params passed to loaders, pages, and handlers.
|
|
16
|
+
*/
|
|
8
17
|
export type RouteParams = Record<string, readonly string[] | string>;
|
|
9
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Infers route params from a loader context parameter.
|
|
21
|
+
*/
|
|
10
22
|
export type InferLoaderParams<TLoader extends RouteLoader> = TLoader extends (
|
|
11
23
|
context: infer TContext,
|
|
12
24
|
...args: never[]
|
|
@@ -18,6 +30,9 @@ export type InferLoaderParams<TLoader extends RouteLoader> = TLoader extends (
|
|
|
18
30
|
: RouteParams
|
|
19
31
|
: RouteParams;
|
|
20
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Provides request, params, environment, and query client data to route loaders.
|
|
35
|
+
*/
|
|
21
36
|
export interface LoaderContext<TParams extends RouteParams = RouteParams> {
|
|
22
37
|
env?: unknown;
|
|
23
38
|
params: TParams;
|
|
@@ -39,17 +54,26 @@ export interface GenerateMetadataContext<
|
|
|
39
54
|
request: Request;
|
|
40
55
|
}
|
|
41
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Provides request and params to server route handlers.
|
|
59
|
+
*/
|
|
42
60
|
export interface RouteHandlerContext<TParams extends RouteParams = RouteParams> {
|
|
43
61
|
params: TParams;
|
|
44
62
|
request: Request;
|
|
45
63
|
}
|
|
46
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Provides loader data, params, and request context to page components.
|
|
67
|
+
*/
|
|
47
68
|
export interface PageProps<TData = unknown, TParams extends RouteParams = RouteParams> {
|
|
48
69
|
data: TData;
|
|
49
70
|
params: TParams;
|
|
50
71
|
request: Request;
|
|
51
72
|
}
|
|
52
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Represents a page component whose props are inferred from a route loader.
|
|
76
|
+
*/
|
|
53
77
|
export type PageComponent<TLoader extends RouteLoader> = (
|
|
54
78
|
props: PageProps<InferLoaderData<TLoader>, InferLoaderParams<TLoader>>,
|
|
55
79
|
) => ReactCompatNode;
|
|
@@ -65,16 +89,28 @@ export function definePage<TLoader extends RouteLoader>(
|
|
|
65
89
|
return component;
|
|
66
90
|
}
|
|
67
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Provides children, params, and request context to layout components.
|
|
94
|
+
*/
|
|
68
95
|
export interface LayoutProps<TParams extends RouteParams = RouteParams> {
|
|
69
96
|
children: ReactCompatNode;
|
|
70
97
|
params: TParams;
|
|
71
98
|
request: Request;
|
|
72
99
|
}
|
|
73
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Re-exports the node type accepted by mreact-compatible components.
|
|
103
|
+
*/
|
|
74
104
|
export type MReactNode = ReactCompatNode;
|
|
75
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Represents scalar metadata values rendered into head tags and headers.
|
|
108
|
+
*/
|
|
76
109
|
export type MetadataScalar = boolean | number | string;
|
|
77
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Describes an image value used by route metadata.
|
|
113
|
+
*/
|
|
78
114
|
export interface MetadataImage {
|
|
79
115
|
alt?: MetadataScalar;
|
|
80
116
|
height?: MetadataScalar;
|
|
@@ -124,13 +160,22 @@ export interface RouteMetadata {
|
|
|
124
160
|
viewport?: MetadataScalar | MetadataViewport;
|
|
125
161
|
}
|
|
126
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Describes viewport metadata key-value pairs.
|
|
165
|
+
*/
|
|
127
166
|
export type MetadataViewport = Record<string, MetadataScalar | null | undefined>;
|
|
128
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Describes a theme-color metadata entry with an optional media query.
|
|
170
|
+
*/
|
|
129
171
|
export interface MetadataThemeColor {
|
|
130
172
|
color?: MetadataScalar;
|
|
131
173
|
media?: MetadataScalar;
|
|
132
174
|
}
|
|
133
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Describes an extra head element emitted by route metadata.
|
|
178
|
+
*/
|
|
134
179
|
export interface RouteHeadDescriptor {
|
|
135
180
|
attrs?: Record<string, boolean | number | string | undefined>;
|
|
136
181
|
content?: string;
|
|
@@ -138,6 +183,9 @@ export interface RouteHeadDescriptor {
|
|
|
138
183
|
tag: "base" | "link" | "meta" | "script" | "style";
|
|
139
184
|
}
|
|
140
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Configures security-related response headers from route metadata.
|
|
188
|
+
*/
|
|
141
189
|
export interface RouteSecurityHeaders {
|
|
142
190
|
contentTypeOptions?: "nosniff" | null | undefined;
|
|
143
191
|
frameOptions?: "DENY" | "SAMEORIGIN" | null | undefined;
|
|
@@ -146,36 +194,54 @@ export interface RouteSecurityHeaders {
|
|
|
146
194
|
referrerPolicy?: string | null | undefined;
|
|
147
195
|
}
|
|
148
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Configures the Strict-Transport-Security header from route metadata.
|
|
199
|
+
*/
|
|
149
200
|
export interface RouteStrictTransportSecurity {
|
|
150
201
|
includeSubDomains?: boolean | undefined;
|
|
151
202
|
maxAge: number;
|
|
152
203
|
preload?: boolean | undefined;
|
|
153
204
|
}
|
|
154
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Provides request context to a robots metadata route.
|
|
208
|
+
*/
|
|
155
209
|
export interface RobotsContext {
|
|
156
210
|
baseUrl: string;
|
|
157
211
|
host: string;
|
|
158
212
|
request: Request;
|
|
159
213
|
}
|
|
160
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Describes the robots.txt metadata route result.
|
|
217
|
+
*/
|
|
161
218
|
export interface RobotsManifest {
|
|
162
219
|
host?: string | undefined;
|
|
163
220
|
rules?: RobotsRule | readonly RobotsRule[] | undefined;
|
|
164
221
|
sitemap?: string | readonly string[] | undefined;
|
|
165
222
|
}
|
|
166
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Describes one robots.txt user-agent rule.
|
|
226
|
+
*/
|
|
167
227
|
export interface RobotsRule {
|
|
168
228
|
allow?: string | readonly string[] | undefined;
|
|
169
229
|
disallow?: string | readonly string[] | undefined;
|
|
170
230
|
userAgent: string | readonly string[];
|
|
171
231
|
}
|
|
172
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Provides request context to a sitemap metadata route.
|
|
235
|
+
*/
|
|
173
236
|
export interface SitemapContext {
|
|
174
237
|
baseUrl: string;
|
|
175
238
|
host: string;
|
|
176
239
|
request: Request;
|
|
177
240
|
}
|
|
178
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Describes one URL entry returned by a sitemap metadata route.
|
|
244
|
+
*/
|
|
179
245
|
export interface SitemapEntry {
|
|
180
246
|
changeFrequency?: string | undefined;
|
|
181
247
|
lastModified?: Date | string | number | undefined;
|
|
@@ -183,10 +249,16 @@ export interface SitemapEntry {
|
|
|
183
249
|
url: string;
|
|
184
250
|
}
|
|
185
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Provides request context to a web app manifest metadata route.
|
|
254
|
+
*/
|
|
186
255
|
export interface ManifestContext {
|
|
187
256
|
baseUrl: string;
|
|
188
257
|
host: string;
|
|
189
258
|
request: Request;
|
|
190
259
|
}
|
|
191
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Represents an arbitrary web app manifest descriptor.
|
|
263
|
+
*/
|
|
192
264
|
export type ManifestDescriptor = Record<string, unknown>;
|
package/src/upgrade.ts
CHANGED
package/src/vite.ts
CHANGED
|
@@ -52,6 +52,9 @@ import { hasJsxSyntax } from "./source-jsx.js";
|
|
|
52
52
|
import { prependTailwindSourceDirectives } from "./tailwind-source.js";
|
|
53
53
|
import { workspacePackageFile } from "./workspace-packages.js";
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Configures the app-router Vite middleware used by development servers.
|
|
57
|
+
*/
|
|
55
58
|
export interface AppRouterViteMiddlewareOptions extends AppRouterProjectOptions {
|
|
56
59
|
allowedHosts?: readonly string[] | undefined;
|
|
57
60
|
define?: UserConfig["define"] | undefined;
|
|
@@ -68,6 +71,9 @@ type AppRouterViteRuntimeMiddlewareOptions = AppRouterViteMiddlewareOptions & {
|
|
|
68
71
|
viteDevServer?: ViteDevServer | undefined;
|
|
69
72
|
};
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Configures the app-router Vite plugin.
|
|
76
|
+
*/
|
|
71
77
|
export interface AppRouterVitePluginOptions extends AppRouterProjectOptions {
|
|
72
78
|
allowedHosts?: readonly string[] | undefined;
|
|
73
79
|
hostPolicy?: RequestHostPolicy | undefined;
|
|
@@ -93,6 +99,9 @@ type MreactRouterPlugin = Plugin & {
|
|
|
93
99
|
[mreactRouterConfigKey]: MreactRouterPluginConfig;
|
|
94
100
|
};
|
|
95
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Creates the app-router Vite plugin for route compilation and development middleware.
|
|
104
|
+
*/
|
|
96
105
|
export function createAppRouterVitePlugin(options: AppRouterVitePluginOptions): Plugin {
|
|
97
106
|
const project = resolveAppRouterProjectOptions(options);
|
|
98
107
|
const normalizedSourceDirs = project.allowedSourceDirs.map((directory) =>
|
|
@@ -412,6 +421,9 @@ function isCompatSourcePath(filename: string): boolean {
|
|
|
412
421
|
return /\.compat(?:\.mreact)?(?:\.[cm]?[jt]sx?)?$/.test(filename);
|
|
413
422
|
}
|
|
414
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Alias for `createAppRouterVitePlugin()` used by Vite config files.
|
|
426
|
+
*/
|
|
415
427
|
export const mreactRouter = createAppRouterVitePlugin;
|
|
416
428
|
|
|
417
429
|
function routeTransformUserVitePlugins(
|
|
@@ -448,6 +460,9 @@ function routeTransformUserVitePlugins(
|
|
|
448
460
|
return plugins;
|
|
449
461
|
}
|
|
450
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Reads resolved app-router project config from a Vite plugin list.
|
|
465
|
+
*/
|
|
451
466
|
export function mreactRouterConfigFromPlugins(
|
|
452
467
|
plugins: readonly unknown[],
|
|
453
468
|
): ResolvedAppRouterProject | undefined {
|
|
@@ -466,6 +481,9 @@ export function mreactRouterConfigFromPlugins(
|
|
|
466
481
|
return undefined;
|
|
467
482
|
}
|
|
468
483
|
|
|
484
|
+
/**
|
|
485
|
+
* Creates Connect middleware that renders app-router requests during Vite development.
|
|
486
|
+
*/
|
|
469
487
|
export function createAppRouterViteMiddleware(
|
|
470
488
|
options: AppRouterViteMiddlewareOptions,
|
|
471
489
|
): Connect.NextHandleFunction {
|
|
@@ -572,6 +590,9 @@ async function handleAppRouterViteRequest(
|
|
|
572
590
|
}
|
|
573
591
|
}
|
|
574
592
|
|
|
593
|
+
/**
|
|
594
|
+
* Renders a development client asset generated by the app-router Vite integration.
|
|
595
|
+
*/
|
|
575
596
|
export async function renderAppRouterClientAsset(
|
|
576
597
|
appDir: string,
|
|
577
598
|
pathname: string,
|