@react-router/dev 0.0.0-experimental-4d16b23b6 → 0.0.0-experimental-4d6793aa7
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/bin.js +4 -2
- package/dist/build-VA3X4T4U.js +239 -0
- package/dist/chunk-B25E3JGK.js +2624 -0
- package/dist/chunk-B3M3SF27.js +219 -0
- package/dist/chunk-HICCFFJA.js +81 -0
- package/dist/chunk-VTJ3CG32.js +49 -0
- package/dist/chunk-X234P535.js +57 -0
- package/dist/chunk-XJYIKBPH.js +31 -0
- package/dist/cli/index.js +83 -1396
- package/dist/config.js +1 -19
- package/dist/dev-SLPL2UHO.js +74 -0
- package/dist/routes.js +12 -179
- package/dist/vite/cloudflare.js +17 -155
- package/dist/vite.js +10 -2737
- package/package.json +7 -6
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-4d6793aa7
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
invariant
|
|
13
|
+
} from "./chunk-XJYIKBPH.js";
|
|
14
|
+
|
|
15
|
+
// config/routes.ts
|
|
16
|
+
import * as Path from "pathe";
|
|
17
|
+
import * as v from "valibot";
|
|
18
|
+
import pick from "lodash/pick.js";
|
|
19
|
+
function setAppDirectory(directory) {
|
|
20
|
+
globalThis.__reactRouterAppDirectory = directory;
|
|
21
|
+
}
|
|
22
|
+
function getAppDirectory() {
|
|
23
|
+
invariant(globalThis.__reactRouterAppDirectory);
|
|
24
|
+
return globalThis.__reactRouterAppDirectory;
|
|
25
|
+
}
|
|
26
|
+
var routeConfigEntrySchema = v.pipe(
|
|
27
|
+
v.custom((value) => {
|
|
28
|
+
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
29
|
+
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
30
|
+
v.object({
|
|
31
|
+
id: v.optional(v.string()),
|
|
32
|
+
path: v.optional(v.string()),
|
|
33
|
+
index: v.optional(v.boolean()),
|
|
34
|
+
caseSensitive: v.optional(v.boolean()),
|
|
35
|
+
file: v.string(),
|
|
36
|
+
children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
|
|
40
|
+
function validateRouteConfig({
|
|
41
|
+
routeConfigFile,
|
|
42
|
+
routeConfig
|
|
43
|
+
}) {
|
|
44
|
+
if (!routeConfig) {
|
|
45
|
+
return {
|
|
46
|
+
valid: false,
|
|
47
|
+
message: `Route config must be the default export in "${routeConfigFile}".`
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!Array.isArray(routeConfig)) {
|
|
51
|
+
return {
|
|
52
|
+
valid: false,
|
|
53
|
+
message: `Route config in "${routeConfigFile}" must be an array.`
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
let { issues } = v.safeParse(resolvedRouteConfigSchema, routeConfig);
|
|
57
|
+
if (issues?.length) {
|
|
58
|
+
let { root, nested } = v.flatten(issues);
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
message: [
|
|
62
|
+
`Route config in "${routeConfigFile}" is invalid.`,
|
|
63
|
+
root ? `${root}` : [],
|
|
64
|
+
nested ? Object.entries(nested).map(
|
|
65
|
+
([path, message]) => `Path: routes.${path}
|
|
66
|
+
${message}`
|
|
67
|
+
) : []
|
|
68
|
+
].flat().join("\n\n")
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return { valid: true };
|
|
72
|
+
}
|
|
73
|
+
var createConfigRouteOptionKeys = [
|
|
74
|
+
"id",
|
|
75
|
+
"index",
|
|
76
|
+
"caseSensitive"
|
|
77
|
+
];
|
|
78
|
+
function route(path, file, optionsOrChildren, children) {
|
|
79
|
+
let options = {};
|
|
80
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
81
|
+
children = optionsOrChildren;
|
|
82
|
+
} else {
|
|
83
|
+
options = optionsOrChildren;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
file,
|
|
87
|
+
children,
|
|
88
|
+
path: path ?? void 0,
|
|
89
|
+
...pick(options, createConfigRouteOptionKeys)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var createIndexOptionKeys = ["id"];
|
|
93
|
+
function index(file, options) {
|
|
94
|
+
return {
|
|
95
|
+
file,
|
|
96
|
+
index: true,
|
|
97
|
+
...pick(options, createIndexOptionKeys)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var createLayoutOptionKeys = ["id"];
|
|
101
|
+
function layout(file, optionsOrChildren, children) {
|
|
102
|
+
let options = {};
|
|
103
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
104
|
+
children = optionsOrChildren;
|
|
105
|
+
} else {
|
|
106
|
+
options = optionsOrChildren;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
file,
|
|
110
|
+
children,
|
|
111
|
+
...pick(options, createLayoutOptionKeys)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function prefix(prefixPath, routes) {
|
|
115
|
+
return routes.map((route2) => {
|
|
116
|
+
if (route2.index || typeof route2.path === "string") {
|
|
117
|
+
return {
|
|
118
|
+
...route2,
|
|
119
|
+
path: route2.path ? joinRoutePaths(prefixPath, route2.path) : prefixPath,
|
|
120
|
+
children: route2.children
|
|
121
|
+
};
|
|
122
|
+
} else if (route2.children) {
|
|
123
|
+
return {
|
|
124
|
+
...route2,
|
|
125
|
+
children: prefix(prefixPath, route2.children)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return route2;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function relative2(directory) {
|
|
132
|
+
return {
|
|
133
|
+
/**
|
|
134
|
+
* Helper function for creating a route config entry, for use within
|
|
135
|
+
* `routes.ts`. Note that this helper has been scoped, meaning that file
|
|
136
|
+
* path will be resolved relative to the directory provided to the
|
|
137
|
+
* `relative` call that created this helper.
|
|
138
|
+
*/
|
|
139
|
+
route: (path, file, ...rest) => {
|
|
140
|
+
return route(path, Path.resolve(directory, file), ...rest);
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Helper function for creating a route config entry for an index route, for
|
|
144
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
145
|
+
* that file path will be resolved relative to the directory provided to the
|
|
146
|
+
* `relative` call that created this helper.
|
|
147
|
+
*/
|
|
148
|
+
index: (file, ...rest) => {
|
|
149
|
+
return index(Path.resolve(directory, file), ...rest);
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Helper function for creating a route config entry for a layout route, for
|
|
153
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
154
|
+
* that file path will be resolved relative to the directory provided to the
|
|
155
|
+
* `relative` call that created this helper.
|
|
156
|
+
*/
|
|
157
|
+
layout: (file, ...rest) => {
|
|
158
|
+
return layout(Path.resolve(directory, file), ...rest);
|
|
159
|
+
},
|
|
160
|
+
// Passthrough of helper functions that don't need relative scoping so that
|
|
161
|
+
// a complete API is still provided.
|
|
162
|
+
prefix
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function configRoutesToRouteManifest(appDirectory, routes, rootId = "root") {
|
|
166
|
+
let routeManifest = {};
|
|
167
|
+
function walk(route2, parentId) {
|
|
168
|
+
let id = route2.id || createRouteId(route2.file);
|
|
169
|
+
let manifestItem = {
|
|
170
|
+
id,
|
|
171
|
+
parentId,
|
|
172
|
+
file: Path.isAbsolute(route2.file) ? Path.relative(appDirectory, route2.file) : route2.file,
|
|
173
|
+
path: route2.path,
|
|
174
|
+
index: route2.index,
|
|
175
|
+
caseSensitive: route2.caseSensitive
|
|
176
|
+
};
|
|
177
|
+
if (routeManifest.hasOwnProperty(id)) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
`Unable to define routes with duplicate route id: "${id}"`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
routeManifest[id] = manifestItem;
|
|
183
|
+
if (route2.children) {
|
|
184
|
+
for (let child of route2.children) {
|
|
185
|
+
walk(child, id);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (let route2 of routes) {
|
|
190
|
+
walk(route2, rootId);
|
|
191
|
+
}
|
|
192
|
+
return routeManifest;
|
|
193
|
+
}
|
|
194
|
+
function createRouteId(file) {
|
|
195
|
+
return Path.normalize(stripFileExtension(file));
|
|
196
|
+
}
|
|
197
|
+
function stripFileExtension(file) {
|
|
198
|
+
return file.replace(/\.[a-z0-9]+$/i, "");
|
|
199
|
+
}
|
|
200
|
+
function joinRoutePaths(path1, path2) {
|
|
201
|
+
return [
|
|
202
|
+
path1.replace(/\/+$/, ""),
|
|
203
|
+
// Remove trailing slashes
|
|
204
|
+
path2.replace(/^\/+/, "")
|
|
205
|
+
// Remove leading slashes
|
|
206
|
+
].join("/");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export {
|
|
210
|
+
setAppDirectory,
|
|
211
|
+
getAppDirectory,
|
|
212
|
+
validateRouteConfig,
|
|
213
|
+
route,
|
|
214
|
+
index,
|
|
215
|
+
layout,
|
|
216
|
+
prefix,
|
|
217
|
+
relative2 as relative,
|
|
218
|
+
configRoutesToRouteManifest
|
|
219
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-4d6793aa7
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
invariant
|
|
13
|
+
} from "./chunk-XJYIKBPH.js";
|
|
14
|
+
|
|
15
|
+
// vite/node-adapter.ts
|
|
16
|
+
import { once } from "node:events";
|
|
17
|
+
import { Readable } from "node:stream";
|
|
18
|
+
import { splitCookiesString } from "set-cookie-parser";
|
|
19
|
+
import { createReadableStreamFromReadable } from "@react-router/node";
|
|
20
|
+
function fromNodeHeaders(nodeHeaders) {
|
|
21
|
+
let headers = new Headers();
|
|
22
|
+
for (let [key, values] of Object.entries(nodeHeaders)) {
|
|
23
|
+
if (values) {
|
|
24
|
+
if (Array.isArray(values)) {
|
|
25
|
+
for (let value of values) {
|
|
26
|
+
headers.append(key, value);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
headers.set(key, values);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return headers;
|
|
34
|
+
}
|
|
35
|
+
function fromNodeRequest(nodeReq, nodeRes) {
|
|
36
|
+
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `http://${nodeReq.headers.host}`;
|
|
37
|
+
invariant(
|
|
38
|
+
nodeReq.originalUrl,
|
|
39
|
+
"Expected `nodeReq.originalUrl` to be defined"
|
|
40
|
+
);
|
|
41
|
+
let url = new URL(nodeReq.originalUrl, origin);
|
|
42
|
+
let controller = new AbortController();
|
|
43
|
+
let init = {
|
|
44
|
+
method: nodeReq.method,
|
|
45
|
+
headers: fromNodeHeaders(nodeReq.headers),
|
|
46
|
+
signal: controller.signal
|
|
47
|
+
};
|
|
48
|
+
nodeRes.on("finish", () => controller = null);
|
|
49
|
+
nodeRes.on("close", () => controller?.abort());
|
|
50
|
+
if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
|
|
51
|
+
init.body = createReadableStreamFromReadable(nodeReq);
|
|
52
|
+
init.duplex = "half";
|
|
53
|
+
}
|
|
54
|
+
return new Request(url.href, init);
|
|
55
|
+
}
|
|
56
|
+
async function toNodeRequest(res, nodeRes) {
|
|
57
|
+
nodeRes.statusCode = res.status;
|
|
58
|
+
nodeRes.statusMessage = res.statusText;
|
|
59
|
+
let cookiesStrings = [];
|
|
60
|
+
for (let [name, value] of res.headers) {
|
|
61
|
+
if (name === "set-cookie") {
|
|
62
|
+
cookiesStrings.push(...splitCookiesString(value));
|
|
63
|
+
} else nodeRes.setHeader(name, value);
|
|
64
|
+
}
|
|
65
|
+
if (cookiesStrings.length) {
|
|
66
|
+
nodeRes.setHeader("set-cookie", cookiesStrings);
|
|
67
|
+
}
|
|
68
|
+
if (res.body) {
|
|
69
|
+
let responseBody = res.body;
|
|
70
|
+
let readable = Readable.from(responseBody);
|
|
71
|
+
readable.pipe(nodeRes);
|
|
72
|
+
await once(readable, "end");
|
|
73
|
+
} else {
|
|
74
|
+
nodeRes.end();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
fromNodeRequest,
|
|
80
|
+
toNodeRequest
|
|
81
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-4d6793aa7
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// vite/profiler.ts
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import colors from "picocolors";
|
|
16
|
+
var getSession = () => global.__reactRouter_profile_session;
|
|
17
|
+
var start = async (callback) => {
|
|
18
|
+
let inspector = await import("node:inspector").then((r) => r.default);
|
|
19
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
20
|
+
session.connect();
|
|
21
|
+
session.post("Profiler.enable", () => {
|
|
22
|
+
session.post("Profiler.start", callback);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var profileCount = 0;
|
|
26
|
+
var stop = (log) => {
|
|
27
|
+
let session = getSession();
|
|
28
|
+
if (!session) return;
|
|
29
|
+
return new Promise((res, rej) => {
|
|
30
|
+
session.post("Profiler.stop", (err, { profile }) => {
|
|
31
|
+
if (err) return rej(err);
|
|
32
|
+
let outPath = path.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
33
|
+
fs.writeFileSync(outPath, JSON.stringify(profile));
|
|
34
|
+
log(
|
|
35
|
+
colors.yellow(
|
|
36
|
+
`CPU profile written to ${colors.white(colors.dim(outPath))}`
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
global.__reactRouter_profile_session = void 0;
|
|
40
|
+
res();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
getSession,
|
|
47
|
+
start,
|
|
48
|
+
stop
|
|
49
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-4d6793aa7
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
invariant
|
|
13
|
+
} from "./chunk-XJYIKBPH.js";
|
|
14
|
+
|
|
15
|
+
// vite/vite.ts
|
|
16
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
17
|
+
import path2 from "pathe";
|
|
18
|
+
|
|
19
|
+
// config/is-react-router-repo.ts
|
|
20
|
+
import path from "pathe";
|
|
21
|
+
import { createRequire } from "node:module";
|
|
22
|
+
var require2 = createRequire(import.meta.url);
|
|
23
|
+
function isReactRouterRepo() {
|
|
24
|
+
let serverRuntimePath = path.dirname(
|
|
25
|
+
require2.resolve("@react-router/node/package.json")
|
|
26
|
+
);
|
|
27
|
+
let serverRuntimeParentDir = path.basename(
|
|
28
|
+
path.resolve(serverRuntimePath, "..")
|
|
29
|
+
);
|
|
30
|
+
return serverRuntimeParentDir === "packages";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// vite/vite.ts
|
|
34
|
+
var require3 = createRequire2(import.meta.url);
|
|
35
|
+
var vite;
|
|
36
|
+
var viteImportSpecifier = isReactRouterRepo() ? (
|
|
37
|
+
// Support testing against different versions of Vite by ensuring that Vite
|
|
38
|
+
// is resolved from the current working directory when running within this
|
|
39
|
+
// repo. If we don't do this, Vite will always be imported relative to this
|
|
40
|
+
// file, which means that it will always resolve to Vite 6.
|
|
41
|
+
`file:///${path2.normalize(
|
|
42
|
+
require3.resolve("vite/package.json", { paths: [process.cwd()] })
|
|
43
|
+
).replace("package.json", "dist/node/index.js")}`
|
|
44
|
+
) : "vite";
|
|
45
|
+
async function preloadVite() {
|
|
46
|
+
vite = await import(viteImportSpecifier);
|
|
47
|
+
}
|
|
48
|
+
function getVite() {
|
|
49
|
+
invariant(vite, "getVite() called before preloadVite()");
|
|
50
|
+
return vite;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
isReactRouterRepo,
|
|
55
|
+
preloadVite,
|
|
56
|
+
getVite
|
|
57
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-4d6793aa7
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
+
}) : x)(function(x) {
|
|
14
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// invariant.ts
|
|
19
|
+
function invariant(value, message) {
|
|
20
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
21
|
+
console.error(
|
|
22
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
23
|
+
);
|
|
24
|
+
throw new Error(message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
__require,
|
|
30
|
+
invariant
|
|
31
|
+
};
|