@react-router/dev 0.0.0-experimental-7c6c0664d → 0.0.0-experimental-9f7fdccd4
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/cli/index.d.ts +2 -1
- package/dist/cli/index.js +1402 -8
- package/dist/{config/routes.d.ts → routes-C14jcF98.d.ts} +15 -21
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +181 -11
- package/dist/vite/cloudflare.d.ts +23 -1
- package/dist/vite/cloudflare.js +171 -5
- package/dist/vite.d.ts +169 -2
- package/dist/vite.js +2394 -5
- package/package.json +29 -10
- package/dist/cli/commands.d.ts +0 -13
- package/dist/cli/commands.js +0 -179
- package/dist/cli/detectPackageManager.d.ts +0 -10
- package/dist/cli/detectPackageManager.js +0 -39
- package/dist/cli/run.d.ts +0 -5
- package/dist/cli/run.js +0 -188
- package/dist/cli/useJavascript.d.ts +0 -4
- package/dist/cli/useJavascript.js +0 -66
- package/dist/colors.d.ts +0 -17
- package/dist/colors.js +0 -49
- package/dist/config/format.d.ts +0 -5
- package/dist/config/format.js +0 -68
- package/dist/config/routes.js +0 -253
- package/dist/config/serverModes.d.ts +0 -9
- package/dist/invariant.d.ts +0 -2
- package/dist/invariant.js +0 -20
- package/dist/manifest.d.ts +0 -28
- package/dist/typescript/plugin.d.ts +0 -4
- package/dist/typescript/plugin.js +0 -52
- package/dist/typescript/typegen.d.ts +0 -10
- package/dist/typescript/typegen.js +0 -190
- package/dist/vite/babel.d.ts +0 -20
- package/dist/vite/babel.js +0 -49
- package/dist/vite/build.d.ts +0 -15
- package/dist/vite/build.js +0 -249
- package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
- package/dist/vite/cloudflare-dev-proxy.js +0 -89
- package/dist/vite/combine-urls-test.d.ts +0 -1
- package/dist/vite/combine-urls.d.ts +0 -1
- package/dist/vite/combine-urls.js +0 -20
- package/dist/vite/config.d.ts +0 -234
- package/dist/vite/config.js +0 -282
- package/dist/vite/dev.d.ts +0 -15
- package/dist/vite/dev.js +0 -81
- package/dist/vite/import-vite-esm-sync.d.ts +0 -4
- package/dist/vite/import-vite-esm-sync.js +0 -28
- package/dist/vite/node-adapter.d.ts +0 -6
- package/dist/vite/node-adapter.js +0 -90
- package/dist/vite/plugin.d.ts +0 -75
- package/dist/vite/plugin.js +0 -1301
- package/dist/vite/profiler.d.ts +0 -5
- package/dist/vite/profiler.js +0 -55
- package/dist/vite/remove-exports-test.d.ts +0 -1
- package/dist/vite/remove-exports.d.ts +0 -2
- package/dist/vite/remove-exports.js +0 -148
- package/dist/vite/resolve-file-url.d.ts +0 -3
- package/dist/vite/resolve-file-url.js +0 -53
- package/dist/vite/styles.d.ts +0 -14
- package/dist/vite/styles.js +0 -199
- package/dist/vite/vite-node.d.ts +0 -9
- package/dist/vite/vite-node.js +0 -57
- package/dist/vite/vmod.d.ts +0 -3
- package/dist/vite/vmod.js +0 -21
- package/dist/vite/with-props.d.ts +0 -4
- package/dist/vite/with-props.js +0 -151
- /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import * as v from
|
|
2
|
-
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
var __reactRouterAppDirectory: string;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Provides the absolute path to the app directory, for use within `routes.ts`.
|
|
5
8
|
* This is designed to support resolving file system routes.
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
declare function getAppDirectory(): string;
|
|
11
|
+
interface RouteManifestEntry {
|
|
9
12
|
/**
|
|
10
13
|
* The path this route uses to match on the URL pathname.
|
|
11
14
|
*/
|
|
@@ -34,7 +37,7 @@ export interface RouteManifestEntry {
|
|
|
34
37
|
*/
|
|
35
38
|
file: string;
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
interface RouteManifest {
|
|
38
41
|
[routeId: string]: RouteManifestEntry;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
@@ -42,7 +45,7 @@ export interface RouteManifest {
|
|
|
42
45
|
* convenience, route config entries can be created with the {@link route},
|
|
43
46
|
* {@link index} and {@link layout} helper functions.
|
|
44
47
|
*/
|
|
45
|
-
|
|
48
|
+
interface RouteConfigEntry {
|
|
46
49
|
/**
|
|
47
50
|
* The unique id for this route.
|
|
48
51
|
*/
|
|
@@ -69,22 +72,12 @@ export interface RouteConfigEntry {
|
|
|
69
72
|
*/
|
|
70
73
|
children?: RouteConfigEntry[];
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
export declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
|
|
75
|
+
declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
|
|
74
76
|
type ResolvedRouteConfig = v.InferInput<typeof resolvedRouteConfigSchema>;
|
|
75
77
|
/**
|
|
76
78
|
* Route config to be exported via the `routes` export within `routes.ts`.
|
|
77
79
|
*/
|
|
78
|
-
|
|
79
|
-
export declare function validateRouteConfig({ routeConfigFile, routeConfig, }: {
|
|
80
|
-
routeConfigFile: string;
|
|
81
|
-
routeConfig: unknown;
|
|
82
|
-
}): {
|
|
83
|
-
valid: false;
|
|
84
|
-
message: string;
|
|
85
|
-
} | {
|
|
86
|
-
valid: true;
|
|
87
|
-
};
|
|
80
|
+
type RouteConfig = ResolvedRouteConfig | Promise<ResolvedRouteConfig>;
|
|
88
81
|
declare const createConfigRouteOptionKeys: ["id", "index", "caseSensitive"];
|
|
89
82
|
type CreateRouteOptions = Pick<RouteConfigEntry, (typeof createConfigRouteOptionKeys)[number]>;
|
|
90
83
|
/**
|
|
@@ -119,11 +112,12 @@ declare const helpers: {
|
|
|
119
112
|
layout: typeof layout;
|
|
120
113
|
prefix: typeof prefix;
|
|
121
114
|
};
|
|
122
|
-
|
|
115
|
+
|
|
123
116
|
/**
|
|
124
117
|
* Creates a set of route config helpers that resolve file paths relative to the
|
|
125
118
|
* given directory, for use within `routes.ts`. This is designed to support
|
|
126
119
|
* splitting route config into multiple files within different directories.
|
|
127
120
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
declare function relative(directory: string): typeof helpers;
|
|
122
|
+
|
|
123
|
+
export { type RouteManifest as R, type RouteManifestEntry as a, type RouteConfig as b, type RouteConfigEntry as c, relative as d, getAppDirectory as g, index as i, layout as l, prefix as p, route as r };
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export { b as RouteConfig, c as RouteConfigEntry, g as getAppDirectory, i as index, l as layout, p as prefix, d as relative, r as route } from './routes-C14jcF98.js';
|
|
2
|
+
import 'valibot';
|
package/dist/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-9f7fdccd4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,17 +8,187 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
"use strict";
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
12
39
|
|
|
13
|
-
|
|
40
|
+
// routes.ts
|
|
41
|
+
var routes_exports = {};
|
|
42
|
+
__export(routes_exports, {
|
|
43
|
+
getAppDirectory: () => getAppDirectory,
|
|
44
|
+
index: () => index,
|
|
45
|
+
layout: () => layout,
|
|
46
|
+
prefix: () => prefix,
|
|
47
|
+
relative: () => relative,
|
|
48
|
+
route: () => route
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(routes_exports);
|
|
14
51
|
|
|
15
|
-
|
|
52
|
+
// config/routes.ts
|
|
53
|
+
var import_node_path = require("path");
|
|
54
|
+
var v = __toESM(require("valibot"));
|
|
55
|
+
var import_pick = __toESM(require("lodash/pick"));
|
|
16
56
|
|
|
57
|
+
// invariant.ts
|
|
58
|
+
function invariant(value, message) {
|
|
59
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
60
|
+
console.error(
|
|
61
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
62
|
+
);
|
|
63
|
+
throw new Error(message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
17
66
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
67
|
+
// config/routes.ts
|
|
68
|
+
function getAppDirectory() {
|
|
69
|
+
invariant(globalThis.__reactRouterAppDirectory);
|
|
70
|
+
return globalThis.__reactRouterAppDirectory;
|
|
71
|
+
}
|
|
72
|
+
var routeConfigEntrySchema = v.pipe(
|
|
73
|
+
v.custom((value) => {
|
|
74
|
+
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
75
|
+
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
76
|
+
v.object({
|
|
77
|
+
id: v.optional(v.string()),
|
|
78
|
+
path: v.optional(v.string()),
|
|
79
|
+
index: v.optional(v.boolean()),
|
|
80
|
+
caseSensitive: v.optional(v.boolean()),
|
|
81
|
+
file: v.string(),
|
|
82
|
+
children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
|
|
86
|
+
var createConfigRouteOptionKeys = [
|
|
87
|
+
"id",
|
|
88
|
+
"index",
|
|
89
|
+
"caseSensitive"
|
|
90
|
+
];
|
|
91
|
+
function route(path, file, optionsOrChildren, children) {
|
|
92
|
+
let options = {};
|
|
93
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
94
|
+
children = optionsOrChildren;
|
|
95
|
+
} else {
|
|
96
|
+
options = optionsOrChildren;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
file,
|
|
100
|
+
children,
|
|
101
|
+
path: path ?? void 0,
|
|
102
|
+
...(0, import_pick.default)(options, createConfigRouteOptionKeys)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var createIndexOptionKeys = ["id"];
|
|
106
|
+
function index(file, options) {
|
|
107
|
+
return {
|
|
108
|
+
file,
|
|
109
|
+
index: true,
|
|
110
|
+
...(0, import_pick.default)(options, createIndexOptionKeys)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
var createLayoutOptionKeys = ["id"];
|
|
114
|
+
function layout(file, optionsOrChildren, children) {
|
|
115
|
+
let options = {};
|
|
116
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
117
|
+
children = optionsOrChildren;
|
|
118
|
+
} else {
|
|
119
|
+
options = optionsOrChildren;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
file,
|
|
123
|
+
children,
|
|
124
|
+
...(0, import_pick.default)(options, createLayoutOptionKeys)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function prefix(prefixPath, routes) {
|
|
128
|
+
return routes.map((route2) => {
|
|
129
|
+
if (route2.index || typeof route2.path === "string") {
|
|
130
|
+
return {
|
|
131
|
+
...route2,
|
|
132
|
+
path: route2.path ? joinRoutePaths(prefixPath, route2.path) : prefixPath,
|
|
133
|
+
children: route2.children
|
|
134
|
+
};
|
|
135
|
+
} else if (route2.children) {
|
|
136
|
+
return {
|
|
137
|
+
...route2,
|
|
138
|
+
children: prefix(prefixPath, route2.children)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return route2;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function relative(directory) {
|
|
145
|
+
return {
|
|
146
|
+
/**
|
|
147
|
+
* Helper function for creating a route config entry, for use within
|
|
148
|
+
* `routes.ts`. Note that this helper has been scoped, meaning that file
|
|
149
|
+
* path will be resolved relative to the directory provided to the
|
|
150
|
+
* `relative` call that created this helper.
|
|
151
|
+
*/
|
|
152
|
+
route: (path, file, ...rest) => {
|
|
153
|
+
return route(path, (0, import_node_path.resolve)(directory, file), ...rest);
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Helper function for creating a route config entry for an index route, for
|
|
157
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
158
|
+
* that file path will be resolved relative to the directory provided to the
|
|
159
|
+
* `relative` call that created this helper.
|
|
160
|
+
*/
|
|
161
|
+
index: (file, ...rest) => {
|
|
162
|
+
return index((0, import_node_path.resolve)(directory, file), ...rest);
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* Helper function for creating a route config entry for a layout route, for
|
|
166
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
167
|
+
* that file path will be resolved relative to the directory provided to the
|
|
168
|
+
* `relative` call that created this helper.
|
|
169
|
+
*/
|
|
170
|
+
layout: (file, ...rest) => {
|
|
171
|
+
return layout((0, import_node_path.resolve)(directory, file), ...rest);
|
|
172
|
+
},
|
|
173
|
+
// Passthrough of helper functions that don't need relative scoping so that
|
|
174
|
+
// a complete API is still provided.
|
|
175
|
+
prefix
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function joinRoutePaths(path1, path2) {
|
|
179
|
+
return [
|
|
180
|
+
path1.replace(/\/+$/, ""),
|
|
181
|
+
// Remove trailing slashes
|
|
182
|
+
path2.replace(/^\/+/, "")
|
|
183
|
+
// Remove leading slashes
|
|
184
|
+
].join("/");
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
getAppDirectory,
|
|
189
|
+
index,
|
|
190
|
+
layout,
|
|
191
|
+
prefix,
|
|
192
|
+
relative,
|
|
193
|
+
route
|
|
194
|
+
});
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { AppLoadContext } from 'react-router';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { GetPlatformProxyOptions, PlatformProxy } from 'wrangler';
|
|
4
|
+
|
|
5
|
+
type CfProperties = Record<string, unknown>;
|
|
6
|
+
type LoadContext<Env, Cf extends CfProperties> = {
|
|
7
|
+
cloudflare: Omit<PlatformProxy<Env, Cf>, "dispose">;
|
|
8
|
+
};
|
|
9
|
+
type GetLoadContext<Env, Cf extends CfProperties> = (args: {
|
|
10
|
+
request: Request;
|
|
11
|
+
context: LoadContext<Env, Cf>;
|
|
12
|
+
}) => AppLoadContext | Promise<AppLoadContext>;
|
|
13
|
+
/**
|
|
14
|
+
* Vite plugin that provides [Node proxies to local workerd
|
|
15
|
+
* bindings](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy)
|
|
16
|
+
* to `context.cloudflare` in your server loaders and server actions during
|
|
17
|
+
* development.
|
|
18
|
+
*/
|
|
19
|
+
declare const cloudflareDevProxyVitePlugin: <Env, Cf extends CfProperties>(options?: {
|
|
20
|
+
getLoadContext?: GetLoadContext<Env, Cf>;
|
|
21
|
+
} & GetPlatformProxyOptions) => Plugin;
|
|
22
|
+
|
|
23
|
+
export { cloudflareDevProxyVitePlugin as cloudflareDevProxy };
|
package/dist/vite/cloudflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-9f7fdccd4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,12 +8,178 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
"use strict";
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
12
39
|
|
|
13
|
-
|
|
40
|
+
// vite/cloudflare.ts
|
|
41
|
+
var cloudflare_exports = {};
|
|
42
|
+
__export(cloudflare_exports, {
|
|
43
|
+
cloudflareDevProxy: () => cloudflareDevProxyVitePlugin
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(cloudflare_exports);
|
|
14
46
|
|
|
15
|
-
|
|
47
|
+
// vite/cloudflare-dev-proxy.ts
|
|
48
|
+
var import_react_router = require("react-router");
|
|
16
49
|
|
|
50
|
+
// vite/node-adapter.ts
|
|
51
|
+
var import_node_events = require("events");
|
|
52
|
+
var import_node_stream = require("stream");
|
|
53
|
+
var import_set_cookie_parser = require("set-cookie-parser");
|
|
54
|
+
var import_node = require("@react-router/node");
|
|
17
55
|
|
|
56
|
+
// invariant.ts
|
|
57
|
+
function invariant(value, message) {
|
|
58
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
59
|
+
console.error(
|
|
60
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
61
|
+
);
|
|
62
|
+
throw new Error(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
18
65
|
|
|
19
|
-
|
|
66
|
+
// vite/node-adapter.ts
|
|
67
|
+
function fromNodeHeaders(nodeHeaders) {
|
|
68
|
+
let headers = new Headers();
|
|
69
|
+
for (let [key, values] of Object.entries(nodeHeaders)) {
|
|
70
|
+
if (values) {
|
|
71
|
+
if (Array.isArray(values)) {
|
|
72
|
+
for (let value of values) {
|
|
73
|
+
headers.append(key, value);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
headers.set(key, values);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return headers;
|
|
81
|
+
}
|
|
82
|
+
function fromNodeRequest(nodeReq, nodeRes) {
|
|
83
|
+
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `http://${nodeReq.headers.host}`;
|
|
84
|
+
invariant(
|
|
85
|
+
nodeReq.originalUrl,
|
|
86
|
+
"Expected `nodeReq.originalUrl` to be defined"
|
|
87
|
+
);
|
|
88
|
+
let url = new URL(nodeReq.originalUrl, origin);
|
|
89
|
+
let controller = new AbortController();
|
|
90
|
+
let init = {
|
|
91
|
+
method: nodeReq.method,
|
|
92
|
+
headers: fromNodeHeaders(nodeReq.headers),
|
|
93
|
+
signal: controller.signal
|
|
94
|
+
};
|
|
95
|
+
nodeRes.on("finish", () => controller = null);
|
|
96
|
+
nodeRes.on("close", () => controller?.abort());
|
|
97
|
+
if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
|
|
98
|
+
init.body = (0, import_node.createReadableStreamFromReadable)(nodeReq);
|
|
99
|
+
init.duplex = "half";
|
|
100
|
+
}
|
|
101
|
+
return new Request(url.href, init);
|
|
102
|
+
}
|
|
103
|
+
async function toNodeRequest(res, nodeRes) {
|
|
104
|
+
nodeRes.statusCode = res.status;
|
|
105
|
+
nodeRes.statusMessage = res.statusText;
|
|
106
|
+
let cookiesStrings = [];
|
|
107
|
+
for (let [name, value] of res.headers) {
|
|
108
|
+
if (name === "set-cookie") {
|
|
109
|
+
cookiesStrings.push(...(0, import_set_cookie_parser.splitCookiesString)(value));
|
|
110
|
+
} else nodeRes.setHeader(name, value);
|
|
111
|
+
}
|
|
112
|
+
if (cookiesStrings.length) {
|
|
113
|
+
nodeRes.setHeader("set-cookie", cookiesStrings);
|
|
114
|
+
}
|
|
115
|
+
if (res.body) {
|
|
116
|
+
let responseBody = res.body;
|
|
117
|
+
let readable = import_node_stream.Readable.from(responseBody);
|
|
118
|
+
readable.pipe(nodeRes);
|
|
119
|
+
await (0, import_node_events.once)(readable, "end");
|
|
120
|
+
} else {
|
|
121
|
+
nodeRes.end();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// vite/cloudflare-dev-proxy.ts
|
|
126
|
+
var serverBuildId = "virtual:react-router/server-build";
|
|
127
|
+
function importWrangler() {
|
|
128
|
+
try {
|
|
129
|
+
return import("wrangler");
|
|
130
|
+
} catch (_) {
|
|
131
|
+
throw Error("Could not import `wrangler`. Do you have it installed?");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
var PLUGIN_NAME = "react-router-cloudflare-vite-dev-proxy";
|
|
135
|
+
var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
136
|
+
let { getLoadContext, ...restOptions } = options;
|
|
137
|
+
return {
|
|
138
|
+
name: PLUGIN_NAME,
|
|
139
|
+
config: () => ({
|
|
140
|
+
ssr: {
|
|
141
|
+
resolve: {
|
|
142
|
+
externalConditions: ["workerd", "worker"]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
configResolved: (viteConfig) => {
|
|
147
|
+
let pluginIndex = (name) => viteConfig.plugins.findIndex((plugin) => plugin.name === name);
|
|
148
|
+
let reactRouterPluginIndex = pluginIndex("react-router");
|
|
149
|
+
if (reactRouterPluginIndex >= 0 && reactRouterPluginIndex < pluginIndex(PLUGIN_NAME)) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`The "${PLUGIN_NAME}" plugin should be placed before the React Router plugin in your Vite config file`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
configureServer: async (viteDevServer) => {
|
|
156
|
+
let { getPlatformProxy } = await importWrangler();
|
|
157
|
+
let { dispose, ...cloudflare } = await getPlatformProxy(
|
|
158
|
+
restOptions
|
|
159
|
+
);
|
|
160
|
+
let context = { cloudflare };
|
|
161
|
+
return () => {
|
|
162
|
+
if (!viteDevServer.config.server.middlewareMode) {
|
|
163
|
+
viteDevServer.middlewares.use(async (nodeReq, nodeRes, next) => {
|
|
164
|
+
try {
|
|
165
|
+
let build = await viteDevServer.ssrLoadModule(
|
|
166
|
+
serverBuildId
|
|
167
|
+
);
|
|
168
|
+
let handler = (0, import_react_router.createRequestHandler)(build, "development");
|
|
169
|
+
let req = fromNodeRequest(nodeReq, nodeRes);
|
|
170
|
+
let loadContext = getLoadContext ? await getLoadContext({ request: req, context }) : context;
|
|
171
|
+
let res = await handler(req, loadContext);
|
|
172
|
+
await toNodeRequest(res, nodeRes);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
next(error);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
cloudflareDevProxy
|
|
185
|
+
});
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,2 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as Vite from 'vite';
|
|
2
|
+
import { R as RouteManifest, a as RouteManifestEntry } from './routes-C14jcF98.js';
|
|
3
|
+
import 'valibot';
|
|
4
|
+
|
|
5
|
+
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
6
|
+
type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
|
|
7
|
+
type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
|
|
8
|
+
type Preset = {
|
|
9
|
+
name: string;
|
|
10
|
+
reactRouterConfig?: (args: {
|
|
11
|
+
reactRouterUserConfig: ReactRouterConfig;
|
|
12
|
+
}) => ConfigPreset | Promise<ConfigPreset>;
|
|
13
|
+
reactRouterConfigResolved?: (args: {
|
|
14
|
+
reactRouterConfig: ResolvedReactRouterConfig;
|
|
15
|
+
}) => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
|
|
18
|
+
type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
|
|
19
|
+
type ServerBundlesFunction = (args: {
|
|
20
|
+
branch: BranchRoute[];
|
|
21
|
+
}) => string | Promise<string>;
|
|
22
|
+
type BaseBuildManifest = {
|
|
23
|
+
routes: RouteManifest;
|
|
24
|
+
};
|
|
25
|
+
type DefaultBuildManifest = BaseBuildManifest & {
|
|
26
|
+
serverBundles?: never;
|
|
27
|
+
routeIdToServerBundleId?: never;
|
|
28
|
+
};
|
|
29
|
+
type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
30
|
+
serverBundles: {
|
|
31
|
+
[serverBundleId: string]: {
|
|
32
|
+
id: string;
|
|
33
|
+
file: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
routeIdToServerBundleId: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
type ServerModuleFormat = "esm" | "cjs";
|
|
39
|
+
interface FutureConfig {
|
|
40
|
+
}
|
|
41
|
+
type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
42
|
+
type BuildEndHook = (args: {
|
|
43
|
+
buildManifest: BuildManifest | undefined;
|
|
44
|
+
reactRouterConfig: ResolvedReactRouterConfig;
|
|
45
|
+
viteConfig: Vite.ResolvedConfig;
|
|
46
|
+
}) => void | Promise<void>;
|
|
47
|
+
type ReactRouterConfig = {
|
|
48
|
+
/**
|
|
49
|
+
* The path to the `app` directory, relative to `remix.config.js`. Defaults
|
|
50
|
+
* to `"app"`.
|
|
51
|
+
*/
|
|
52
|
+
appDirectory?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The output format of the server build. Defaults to "esm".
|
|
55
|
+
*/
|
|
56
|
+
serverModuleFormat?: ServerModuleFormat;
|
|
57
|
+
/**
|
|
58
|
+
* Enabled future flags
|
|
59
|
+
*/
|
|
60
|
+
future?: [keyof FutureConfig] extends [never] ? {
|
|
61
|
+
[key: string]: never;
|
|
62
|
+
} : Partial<FutureConfig>;
|
|
63
|
+
/**
|
|
64
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
65
|
+
*/
|
|
66
|
+
basename?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The path to the build directory, relative to the project. Defaults to
|
|
69
|
+
* `"build"`.
|
|
70
|
+
*/
|
|
71
|
+
buildDirectory?: string;
|
|
72
|
+
/**
|
|
73
|
+
* A function that is called after the full React Router build is complete.
|
|
74
|
+
*/
|
|
75
|
+
buildEnd?: BuildEndHook;
|
|
76
|
+
/**
|
|
77
|
+
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
78
|
+
* function returning an array to dynamically generate URLs.
|
|
79
|
+
*/
|
|
80
|
+
prerender?: boolean | Array<string> | ((args: {
|
|
81
|
+
getStaticPaths: () => string[];
|
|
82
|
+
}) => Array<string> | Promise<Array<string>>);
|
|
83
|
+
/**
|
|
84
|
+
* An array of React Router plugin config presets to ease integration with
|
|
85
|
+
* other platforms and tools.
|
|
86
|
+
*/
|
|
87
|
+
presets?: Array<Preset>;
|
|
88
|
+
/**
|
|
89
|
+
* The file name of the server build output. This file
|
|
90
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
91
|
+
* Defaults to `"index.js"`.
|
|
92
|
+
*/
|
|
93
|
+
serverBuildFile?: string;
|
|
94
|
+
/**
|
|
95
|
+
* A function for assigning routes to different server bundles. This
|
|
96
|
+
* function should return a server bundle ID which will be used as the
|
|
97
|
+
* bundle's directory name within the server build directory.
|
|
98
|
+
*/
|
|
99
|
+
serverBundles?: ServerBundlesFunction;
|
|
100
|
+
/**
|
|
101
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
102
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
103
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
104
|
+
* SPA without server-rendering. Default's to `true`.
|
|
105
|
+
*/
|
|
106
|
+
ssr?: boolean;
|
|
107
|
+
};
|
|
108
|
+
type ResolvedReactRouterConfig = Readonly<{
|
|
109
|
+
/**
|
|
110
|
+
* The absolute path to the application source directory.
|
|
111
|
+
*/
|
|
112
|
+
appDirectory: string;
|
|
113
|
+
/**
|
|
114
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
115
|
+
*/
|
|
116
|
+
basename: string;
|
|
117
|
+
/**
|
|
118
|
+
* The absolute path to the build directory.
|
|
119
|
+
*/
|
|
120
|
+
buildDirectory: string;
|
|
121
|
+
/**
|
|
122
|
+
* A function that is called after the full React Router build is complete.
|
|
123
|
+
*/
|
|
124
|
+
buildEnd?: BuildEndHook;
|
|
125
|
+
/**
|
|
126
|
+
* Enabled future flags
|
|
127
|
+
*/
|
|
128
|
+
future: FutureConfig;
|
|
129
|
+
/**
|
|
130
|
+
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
131
|
+
* function returning an array to dynamically generate URLs.
|
|
132
|
+
*/
|
|
133
|
+
prerender: ReactRouterConfig["prerender"];
|
|
134
|
+
/**
|
|
135
|
+
* An object of all available routes, keyed by route id.
|
|
136
|
+
*/
|
|
137
|
+
routes: RouteManifest;
|
|
138
|
+
/**
|
|
139
|
+
* The file name of the server build output. This file
|
|
140
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
141
|
+
* Defaults to `"index.js"`.
|
|
142
|
+
*/
|
|
143
|
+
serverBuildFile: string;
|
|
144
|
+
/**
|
|
145
|
+
* A function for assigning routes to different server bundles. This
|
|
146
|
+
* function should return a server bundle ID which will be used as the
|
|
147
|
+
* bundle's directory name within the server build directory.
|
|
148
|
+
*/
|
|
149
|
+
serverBundles?: ServerBundlesFunction;
|
|
150
|
+
/**
|
|
151
|
+
* The output format of the server build. Defaults to "esm".
|
|
152
|
+
*/
|
|
153
|
+
serverModuleFormat: ServerModuleFormat;
|
|
154
|
+
/**
|
|
155
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
156
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
157
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
158
|
+
* SPA without server-rendering. Default's to `true`.
|
|
159
|
+
*/
|
|
160
|
+
ssr: boolean;
|
|
161
|
+
}>;
|
|
162
|
+
|
|
163
|
+
type ReactRouterVitePlugin = (config?: ReactRouterConfig) => Vite.Plugin[];
|
|
164
|
+
/**
|
|
165
|
+
* React Router [Vite plugin.](https://vitejs.dev/guide/using-plugins.html)
|
|
166
|
+
*/
|
|
167
|
+
declare const reactRouterVitePlugin: ReactRouterVitePlugin;
|
|
168
|
+
|
|
169
|
+
export { type BuildManifest, type Preset, type ReactRouterConfig, type ServerBundlesFunction, reactRouterVitePlugin as reactRouter };
|