@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.4
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/CHANGELOG.md +20 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +1198 -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/typescript/plugin.d.ts +5 -2
- package/dist/typescript/plugin.js +479 -31
- 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 +28 -7
- 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/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
package/dist/config/format.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function formatRoutes(routeManifest, format) {
|
|
16
|
-
switch (format) {
|
|
17
|
-
case "json":
|
|
18
|
-
return formatRoutesAsJson(routeManifest);
|
|
19
|
-
case "jsx":
|
|
20
|
-
return formatRoutesAsJsx(routeManifest);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function formatRoutesAsJson(routeManifest) {
|
|
24
|
-
function handleRoutesRecursive(parentId) {
|
|
25
|
-
let routes = Object.values(routeManifest).filter(route => route.parentId === parentId);
|
|
26
|
-
let children = [];
|
|
27
|
-
for (let route of routes) {
|
|
28
|
-
children.push({
|
|
29
|
-
id: route.id,
|
|
30
|
-
index: route.index,
|
|
31
|
-
path: route.path,
|
|
32
|
-
caseSensitive: route.caseSensitive,
|
|
33
|
-
file: route.file,
|
|
34
|
-
children: handleRoutesRecursive(route.id)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (children.length > 0) {
|
|
38
|
-
return children;
|
|
39
|
-
}
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return JSON.stringify(handleRoutesRecursive() || null, null, 2);
|
|
43
|
-
}
|
|
44
|
-
function formatRoutesAsJsx(routeManifest) {
|
|
45
|
-
let output = "<Routes>";
|
|
46
|
-
function handleRoutesRecursive(parentId, level = 1) {
|
|
47
|
-
let routes = Object.values(routeManifest).filter(route => route.parentId === parentId);
|
|
48
|
-
let indent = Array(level * 2).fill(" ").join("");
|
|
49
|
-
for (let route of routes) {
|
|
50
|
-
output += "\n" + indent;
|
|
51
|
-
output += `<Route${route.path ? ` path=${JSON.stringify(route.path)}` : ""}${route.index ? " index" : ""}${route.file ? ` file=${JSON.stringify(route.file)}` : ""}>`;
|
|
52
|
-
if (handleRoutesRecursive(route.id, level + 1)) {
|
|
53
|
-
output += "\n" + indent;
|
|
54
|
-
output += "</Route>";
|
|
55
|
-
} else {
|
|
56
|
-
output = output.slice(0, -1) + " />";
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return routes.length > 0;
|
|
60
|
-
}
|
|
61
|
-
handleRoutesRecursive();
|
|
62
|
-
output += "\n</Routes>";
|
|
63
|
-
return output;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exports.formatRoutes = formatRoutes;
|
|
67
|
-
exports.formatRoutesAsJson = formatRoutesAsJson;
|
|
68
|
-
exports.formatRoutesAsJsx = formatRoutesAsJsx;
|
package/dist/config/routes.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var path = require('node:path');
|
|
16
|
-
var v = require('valibot');
|
|
17
|
-
var pick = require('lodash/pick');
|
|
18
|
-
var invariant = require('../invariant.js');
|
|
19
|
-
|
|
20
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
-
|
|
22
|
-
function _interopNamespace(e) {
|
|
23
|
-
if (e && e.__esModule) return e;
|
|
24
|
-
var n = Object.create(null);
|
|
25
|
-
if (e) {
|
|
26
|
-
Object.keys(e).forEach(function (k) {
|
|
27
|
-
if (k !== 'default') {
|
|
28
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
29
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return e[k]; }
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
n["default"] = e;
|
|
37
|
-
return Object.freeze(n);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var v__namespace = /*#__PURE__*/_interopNamespace(v);
|
|
41
|
-
var pick__default = /*#__PURE__*/_interopDefaultLegacy(pick);
|
|
42
|
-
|
|
43
|
-
let appDirectory;
|
|
44
|
-
function setAppDirectory(directory) {
|
|
45
|
-
appDirectory = directory;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Provides the absolute path to the app directory, for use within `routes.ts`.
|
|
49
|
-
* This is designed to support resolving file system routes.
|
|
50
|
-
*/
|
|
51
|
-
function getAppDirectory() {
|
|
52
|
-
invariant(appDirectory);
|
|
53
|
-
return appDirectory;
|
|
54
|
-
}
|
|
55
|
-
const routeConfigEntrySchema = v__namespace.pipe(v__namespace.custom(value => {
|
|
56
|
-
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
57
|
-
}, "Invalid type: Expected object but received a promise. Did you forget to await?"), v__namespace.object({
|
|
58
|
-
id: v__namespace.optional(v__namespace.string()),
|
|
59
|
-
path: v__namespace.optional(v__namespace.string()),
|
|
60
|
-
index: v__namespace.optional(v__namespace.boolean()),
|
|
61
|
-
caseSensitive: v__namespace.optional(v__namespace.boolean()),
|
|
62
|
-
file: v__namespace.string(),
|
|
63
|
-
children: v__namespace.optional(v__namespace.array(v__namespace.lazy(() => routeConfigEntrySchema)))
|
|
64
|
-
}));
|
|
65
|
-
const resolvedRouteConfigSchema = v__namespace.array(routeConfigEntrySchema);
|
|
66
|
-
function validateRouteConfig({
|
|
67
|
-
routeConfigFile,
|
|
68
|
-
routeConfig
|
|
69
|
-
}) {
|
|
70
|
-
if (!routeConfig) {
|
|
71
|
-
return {
|
|
72
|
-
valid: false,
|
|
73
|
-
message: `No "routes" export defined in "${routeConfigFile}.`
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (!Array.isArray(routeConfig)) {
|
|
77
|
-
return {
|
|
78
|
-
valid: false,
|
|
79
|
-
message: `Route config in "${routeConfigFile}" must be an array.`
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
let {
|
|
83
|
-
issues
|
|
84
|
-
} = v__namespace.safeParse(resolvedRouteConfigSchema, routeConfig);
|
|
85
|
-
if (issues !== null && issues !== void 0 && issues.length) {
|
|
86
|
-
let {
|
|
87
|
-
root,
|
|
88
|
-
nested
|
|
89
|
-
} = v__namespace.flatten(issues);
|
|
90
|
-
return {
|
|
91
|
-
valid: false,
|
|
92
|
-
message: [`Route config in "${routeConfigFile}" is invalid.`, root ? `${root}` : [], nested ? Object.entries(nested).map(([path, message]) => `Path: routes.${path}\n${message}`) : []].flat().join("\n\n")
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
valid: true
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const createConfigRouteOptionKeys = ["id", "index", "caseSensitive"];
|
|
100
|
-
function route(path, file, optionsOrChildren, children) {
|
|
101
|
-
let options = {};
|
|
102
|
-
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
103
|
-
children = optionsOrChildren;
|
|
104
|
-
} else {
|
|
105
|
-
options = optionsOrChildren;
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
file,
|
|
109
|
-
children,
|
|
110
|
-
path: path ?? undefined,
|
|
111
|
-
...pick__default["default"](options, createConfigRouteOptionKeys)
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
const createIndexOptionKeys = ["id"];
|
|
115
|
-
/**
|
|
116
|
-
* Helper function for creating a route config entry for an index route, for use
|
|
117
|
-
* within `routes.ts`.
|
|
118
|
-
*/
|
|
119
|
-
function index(file, options) {
|
|
120
|
-
return {
|
|
121
|
-
file,
|
|
122
|
-
index: true,
|
|
123
|
-
...pick__default["default"](options, createIndexOptionKeys)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const createLayoutOptionKeys = ["id"];
|
|
127
|
-
function layout(file, optionsOrChildren, children) {
|
|
128
|
-
let options = {};
|
|
129
|
-
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
130
|
-
children = optionsOrChildren;
|
|
131
|
-
} else {
|
|
132
|
-
options = optionsOrChildren;
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
file,
|
|
136
|
-
children,
|
|
137
|
-
...pick__default["default"](options, createLayoutOptionKeys)
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Helper function for adding a path prefix to a set of routes without needing
|
|
142
|
-
* to introduce a parent route file, for use within `routes.ts`.
|
|
143
|
-
*/
|
|
144
|
-
function prefix(prefixPath, routes) {
|
|
145
|
-
return routes.map(route => {
|
|
146
|
-
if (route.index || typeof route.path === "string") {
|
|
147
|
-
return {
|
|
148
|
-
...route,
|
|
149
|
-
path: route.path ? joinRoutePaths(prefixPath, route.path) : prefixPath,
|
|
150
|
-
children: route.children
|
|
151
|
-
};
|
|
152
|
-
} else if (route.children) {
|
|
153
|
-
return {
|
|
154
|
-
...route,
|
|
155
|
-
children: prefix(prefixPath, route.children)
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return route;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Creates a set of route config helpers that resolve file paths relative to the
|
|
163
|
-
* given directory, for use within `routes.ts`. This is designed to support
|
|
164
|
-
* splitting route config into multiple files within different directories.
|
|
165
|
-
*/
|
|
166
|
-
function relative(directory) {
|
|
167
|
-
return {
|
|
168
|
-
/**
|
|
169
|
-
* Helper function for creating a route config entry, for use within
|
|
170
|
-
* `routes.ts`. Note that this helper has been scoped, meaning that file
|
|
171
|
-
* path will be resolved relative to the directory provided to the
|
|
172
|
-
* `relative` call that created this helper.
|
|
173
|
-
*/
|
|
174
|
-
route: (path$1, file, ...rest) => {
|
|
175
|
-
return route(path$1, path.resolve(directory, file), ...rest);
|
|
176
|
-
},
|
|
177
|
-
/**
|
|
178
|
-
* Helper function for creating a route config entry for an index route, for
|
|
179
|
-
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
180
|
-
* that file path will be resolved relative to the directory provided to the
|
|
181
|
-
* `relative` call that created this helper.
|
|
182
|
-
*/
|
|
183
|
-
index: (file, ...rest) => {
|
|
184
|
-
return index(path.resolve(directory, file), ...rest);
|
|
185
|
-
},
|
|
186
|
-
/**
|
|
187
|
-
* Helper function for creating a route config entry for a layout route, for
|
|
188
|
-
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
189
|
-
* that file path will be resolved relative to the directory provided to the
|
|
190
|
-
* `relative` call that created this helper.
|
|
191
|
-
*/
|
|
192
|
-
layout: (file, ...rest) => {
|
|
193
|
-
return layout(path.resolve(directory, file), ...rest);
|
|
194
|
-
},
|
|
195
|
-
// Passthrough of helper functions that don't need relative scoping so that
|
|
196
|
-
// a complete API is still provided.
|
|
197
|
-
prefix
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function configRoutesToRouteManifest(routes, rootId = "root") {
|
|
201
|
-
let routeManifest = {};
|
|
202
|
-
function walk(route, parentId) {
|
|
203
|
-
let id = route.id || createRouteId(route.file);
|
|
204
|
-
let manifestItem = {
|
|
205
|
-
id,
|
|
206
|
-
parentId,
|
|
207
|
-
file: route.file,
|
|
208
|
-
path: route.path,
|
|
209
|
-
index: route.index,
|
|
210
|
-
caseSensitive: route.caseSensitive
|
|
211
|
-
};
|
|
212
|
-
if (routeManifest.hasOwnProperty(id)) {
|
|
213
|
-
throw new Error(`Unable to define routes with duplicate route id: "${id}"`);
|
|
214
|
-
}
|
|
215
|
-
routeManifest[id] = manifestItem;
|
|
216
|
-
if (route.children) {
|
|
217
|
-
for (let child of route.children) {
|
|
218
|
-
walk(child, id);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
for (let route of routes) {
|
|
223
|
-
walk(route, rootId);
|
|
224
|
-
}
|
|
225
|
-
return routeManifest;
|
|
226
|
-
}
|
|
227
|
-
function createRouteId(file) {
|
|
228
|
-
return normalizeSlashes(stripFileExtension(file));
|
|
229
|
-
}
|
|
230
|
-
function normalizeSlashes(file) {
|
|
231
|
-
return file.split(path.win32.sep).join("/");
|
|
232
|
-
}
|
|
233
|
-
function stripFileExtension(file) {
|
|
234
|
-
return file.replace(/\.[a-z0-9]+$/i, "");
|
|
235
|
-
}
|
|
236
|
-
function joinRoutePaths(path1, path2) {
|
|
237
|
-
return [path1.replace(/\/+$/, ""),
|
|
238
|
-
// Remove trailing slashes
|
|
239
|
-
path2.replace(/^\/+/, "") // Remove leading slashes
|
|
240
|
-
].join("/");
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
exports.configRoutesToRouteManifest = configRoutesToRouteManifest;
|
|
244
|
-
exports.getAppDirectory = getAppDirectory;
|
|
245
|
-
exports.index = index;
|
|
246
|
-
exports.layout = layout;
|
|
247
|
-
exports.prefix = prefix;
|
|
248
|
-
exports.relative = relative;
|
|
249
|
-
exports.resolvedRouteConfigSchema = resolvedRouteConfigSchema;
|
|
250
|
-
exports.route = route;
|
|
251
|
-
exports.routeConfigEntrySchema = routeConfigEntrySchema;
|
|
252
|
-
exports.setAppDirectory = setAppDirectory;
|
|
253
|
-
exports.validateRouteConfig = validateRouteConfig;
|
package/dist/invariant.d.ts
DELETED
package/dist/invariant.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
function invariant(value, message) {
|
|
14
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
15
|
-
console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose");
|
|
16
|
-
throw new Error(message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = invariant;
|
package/dist/manifest.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type Manifest = {
|
|
2
|
-
version: string;
|
|
3
|
-
url?: string;
|
|
4
|
-
entry: {
|
|
5
|
-
module: string;
|
|
6
|
-
imports: string[];
|
|
7
|
-
};
|
|
8
|
-
routes: {
|
|
9
|
-
[routeId: string]: {
|
|
10
|
-
id: string;
|
|
11
|
-
parentId?: string;
|
|
12
|
-
path?: string;
|
|
13
|
-
index?: boolean;
|
|
14
|
-
caseSensitive?: boolean;
|
|
15
|
-
module: string;
|
|
16
|
-
imports?: string[];
|
|
17
|
-
hasAction: boolean;
|
|
18
|
-
hasLoader: boolean;
|
|
19
|
-
hasClientAction: boolean;
|
|
20
|
-
hasClientLoader: boolean;
|
|
21
|
-
hasErrorBoundary: boolean;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
hmr?: {
|
|
25
|
-
timestamp?: number;
|
|
26
|
-
runtime: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type RouteManifest, type RouteManifestEntry } from "../config/routes";
|
|
2
|
-
type Context = {
|
|
3
|
-
rootDirectory: string;
|
|
4
|
-
appDirectory: string;
|
|
5
|
-
routes: RouteManifest;
|
|
6
|
-
};
|
|
7
|
-
export declare function getPath(ctx: Context, route: RouteManifestEntry): string;
|
|
8
|
-
export declare function watch(rootDirectory: string): Promise<void>;
|
|
9
|
-
export declare function writeAll(ctx: Context): Promise<void>;
|
|
10
|
-
export {};
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var fs = require('node:fs');
|
|
16
|
-
var Chokidar = require('chokidar');
|
|
17
|
-
var dedent = require('dedent');
|
|
18
|
-
var Path = require('pathe');
|
|
19
|
-
var Pathe = require('pathe/utils');
|
|
20
|
-
var routes = require('../config/routes.js');
|
|
21
|
-
var viteNode = require('../vite/vite-node.js');
|
|
22
|
-
var config = require('../vite/config.js');
|
|
23
|
-
var plugin = require('../vite/plugin.js');
|
|
24
|
-
|
|
25
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
-
|
|
27
|
-
function _interopNamespace(e) {
|
|
28
|
-
if (e && e.__esModule) return e;
|
|
29
|
-
var n = Object.create(null);
|
|
30
|
-
if (e) {
|
|
31
|
-
Object.keys(e).forEach(function (k) {
|
|
32
|
-
if (k !== 'default') {
|
|
33
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
34
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () { return e[k]; }
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
n["default"] = e;
|
|
42
|
-
return Object.freeze(n);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
46
|
-
var Chokidar__default = /*#__PURE__*/_interopDefaultLegacy(Chokidar);
|
|
47
|
-
var dedent__default = /*#__PURE__*/_interopDefaultLegacy(dedent);
|
|
48
|
-
var Path__namespace = /*#__PURE__*/_interopNamespace(Path);
|
|
49
|
-
var Pathe__namespace = /*#__PURE__*/_interopNamespace(Pathe);
|
|
50
|
-
|
|
51
|
-
function getDirectory(ctx) {
|
|
52
|
-
return Path__namespace.join(ctx.rootDirectory, ".react-router/types");
|
|
53
|
-
}
|
|
54
|
-
function getPath(ctx, route) {
|
|
55
|
-
return Path__namespace.join(getDirectory(ctx), "app", Path__namespace.dirname(route.file), "+types." + Pathe__namespace.filename(route.file) + ".d.ts");
|
|
56
|
-
}
|
|
57
|
-
async function watch(rootDirectory) {
|
|
58
|
-
const vitePluginCtx = await plugin.loadPluginContext({
|
|
59
|
-
root: rootDirectory
|
|
60
|
-
});
|
|
61
|
-
const routesTsPath = Path__namespace.join(vitePluginCtx.reactRouterConfig.appDirectory, "routes.ts");
|
|
62
|
-
const routesViteNodeContext = await viteNode.createContext({
|
|
63
|
-
root: rootDirectory
|
|
64
|
-
});
|
|
65
|
-
async function getRoutes() {
|
|
66
|
-
const routes$1 = {};
|
|
67
|
-
const rootRouteFile = config.findEntry(vitePluginCtx.reactRouterConfig.appDirectory, "root");
|
|
68
|
-
if (rootRouteFile) {
|
|
69
|
-
routes$1.root = {
|
|
70
|
-
path: "",
|
|
71
|
-
id: "root",
|
|
72
|
-
file: rootRouteFile
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
routesViteNodeContext.devServer.moduleGraph.invalidateAll();
|
|
76
|
-
routesViteNodeContext.runner.moduleCache.clear();
|
|
77
|
-
const routeConfig = (await routesViteNodeContext.runner.executeFile(routesTsPath)).routes;
|
|
78
|
-
return {
|
|
79
|
-
...routes$1,
|
|
80
|
-
...routes.configRoutesToRouteManifest(await routeConfig)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const ctx = {
|
|
84
|
-
rootDirectory,
|
|
85
|
-
appDirectory: vitePluginCtx.reactRouterConfig.appDirectory,
|
|
86
|
-
routes: await getRoutes()
|
|
87
|
-
};
|
|
88
|
-
await writeAll(ctx);
|
|
89
|
-
const watcher = Chokidar__default["default"].watch(ctx.appDirectory, {
|
|
90
|
-
ignoreInitial: true
|
|
91
|
-
});
|
|
92
|
-
watcher.on("all", async (event, path) => {
|
|
93
|
-
path = Path__namespace.normalize(path);
|
|
94
|
-
ctx.routes = await getRoutes();
|
|
95
|
-
const routeConfigChanged = Boolean(routesViteNodeContext.devServer.moduleGraph.getModuleById(path));
|
|
96
|
-
if (routeConfigChanged) {
|
|
97
|
-
await writeAll(ctx);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const isRoute = Object.values(ctx.routes).find(route => path === Path__namespace.join(ctx.appDirectory, route.file));
|
|
101
|
-
if (isRoute && (event === "add" || event === "unlink")) {
|
|
102
|
-
await writeAll(ctx);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
async function writeAll(ctx) {
|
|
108
|
-
fs__default["default"].rmSync(getDirectory(ctx), {
|
|
109
|
-
recursive: true,
|
|
110
|
-
force: true
|
|
111
|
-
});
|
|
112
|
-
Object.values(ctx.routes).forEach(route => {
|
|
113
|
-
if (!fs__default["default"].existsSync(Path__namespace.join(ctx.appDirectory, route.file))) return;
|
|
114
|
-
const typesPath = getPath(ctx, route);
|
|
115
|
-
const content = getModule(ctx.routes, route);
|
|
116
|
-
fs__default["default"].mkdirSync(Path__namespace.dirname(typesPath), {
|
|
117
|
-
recursive: true
|
|
118
|
-
});
|
|
119
|
-
fs__default["default"].writeFileSync(typesPath, content);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function getModule(routes, route) {
|
|
123
|
-
return dedent__default["default"]`
|
|
124
|
-
// React Router generated types for route:
|
|
125
|
-
// ${route.file}
|
|
126
|
-
|
|
127
|
-
import * as T from "react-router/types"
|
|
128
|
-
|
|
129
|
-
export type Params = {${formattedParamsProperties(routes, route)}}
|
|
130
|
-
|
|
131
|
-
type Route = typeof import("./${Pathe__namespace.filename(route.file)}")
|
|
132
|
-
|
|
133
|
-
export type LoaderData = T.CreateLoaderData<Route>
|
|
134
|
-
export type ActionData = T.CreateActionData<Route>
|
|
135
|
-
|
|
136
|
-
export type LoaderArgs = T.CreateServerLoaderArgs<Params>
|
|
137
|
-
export type ClientLoaderArgs = T.CreateClientLoaderArgs<Params, Route>
|
|
138
|
-
export type ActionArgs = T.CreateServerActionArgs<Params>
|
|
139
|
-
export type ClientActionArgs = T.CreateClientActionArgs<Params, Route>
|
|
140
|
-
|
|
141
|
-
export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Params>
|
|
142
|
-
export type ComponentProps = T.CreateComponentProps<Params, LoaderData, ActionData>
|
|
143
|
-
export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Params, LoaderData, ActionData>
|
|
144
|
-
`;
|
|
145
|
-
}
|
|
146
|
-
function formattedParamsProperties(routes, route) {
|
|
147
|
-
const urlpath = routeLineage(routes, route).map(route => route.path).join("/");
|
|
148
|
-
const params = parseParams(urlpath);
|
|
149
|
-
const indent = " ".repeat(3);
|
|
150
|
-
const properties = Object.entries(params).map(([name, values]) => {
|
|
151
|
-
if (values.length === 1) {
|
|
152
|
-
const isOptional = values[0];
|
|
153
|
-
return indent + (isOptional ? `${name}?: string` : `${name}: string`);
|
|
154
|
-
}
|
|
155
|
-
const items = values.map(isOptional => isOptional ? "string | undefined" : "string");
|
|
156
|
-
return indent + `${name}: [${items.join(", ")}]`;
|
|
157
|
-
});
|
|
158
|
-
// prettier-ignore
|
|
159
|
-
const body = properties.length === 0 ? "" : "\n" + properties.join("\n") + "\n";
|
|
160
|
-
return body;
|
|
161
|
-
}
|
|
162
|
-
function routeLineage(routes, route) {
|
|
163
|
-
const result = [];
|
|
164
|
-
while (route) {
|
|
165
|
-
result.push(route);
|
|
166
|
-
if (!route.parentId) break;
|
|
167
|
-
route = routes[route.parentId];
|
|
168
|
-
}
|
|
169
|
-
result.reverse();
|
|
170
|
-
return result;
|
|
171
|
-
}
|
|
172
|
-
function parseParams(urlpath) {
|
|
173
|
-
const result = {};
|
|
174
|
-
let segments = urlpath.split("/");
|
|
175
|
-
segments.filter(s => s.startsWith(":")).forEach(param => {
|
|
176
|
-
param = param.slice(1); // omit leading `:`
|
|
177
|
-
let isOptional = param.endsWith("?");
|
|
178
|
-
if (isOptional) {
|
|
179
|
-
param = param.slice(0, -1); // omit trailing `?`
|
|
180
|
-
}
|
|
181
|
-
result[param] ??= [];
|
|
182
|
-
result[param].push(isOptional);
|
|
183
|
-
return;
|
|
184
|
-
});
|
|
185
|
-
return result;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
exports.getPath = getPath;
|
|
189
|
-
exports.watch = watch;
|
|
190
|
-
exports.writeAll = writeAll;
|
package/dist/vite/babel.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from "@babel/traverse";
|
|
2
|
-
import type { types as Babel } from "@babel/core";
|
|
3
|
-
import { parse, type ParseResult } from "@babel/parser";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
declare const traverse: {
|
|
6
|
-
<S>(parent: Babel.Node, opts: import("@babel/traverse").TraverseOptions<S>, scope: import("@babel/traverse").Scope | undefined, state: S, parentPath?: NodePath<Babel.Node> | undefined): void;
|
|
7
|
-
(parent: Babel.Node, opts?: import("@babel/traverse").TraverseOptions<Babel.Node> | undefined, scope?: import("@babel/traverse").Scope | undefined, state?: any, parentPath?: NodePath<Babel.Node> | undefined): void;
|
|
8
|
-
visitors: typeof import("@babel/traverse").visitors;
|
|
9
|
-
verify: typeof import("@babel/traverse").visitors.verify;
|
|
10
|
-
explode: typeof import("@babel/traverse").visitors.explode;
|
|
11
|
-
cheap: (node: Babel.Node, enter: (node: Babel.Node) => void) => void;
|
|
12
|
-
node: (node: Babel.Node, opts: import("@babel/traverse").TraverseOptions<Babel.Node>, scope?: import("@babel/traverse").Scope | undefined, state?: any, path?: NodePath<Babel.Node> | undefined, skipKeys?: Record<string, boolean> | undefined) => void;
|
|
13
|
-
clearNode: (node: Babel.Node, opts?: Babel.RemovePropertiesOptions | undefined) => void;
|
|
14
|
-
removeProperties: (tree: Babel.Node, opts?: Babel.RemovePropertiesOptions | undefined) => Babel.Node;
|
|
15
|
-
hasType: (tree: Babel.Node, type: "ArrayPattern" | "ObjectPattern" | "Identifier" | "RestElement" | "AssignmentPattern" | "TSAsExpression" | "TSSatisfiesExpression" | "TSTypeAssertion" | "TSNonNullExpression" | "MemberExpression" | "TSParameterProperty" | "ObjectProperty" | "ArrayExpression" | "AssignmentExpression" | "BinaryExpression" | "CallExpression" | "ConditionalExpression" | "FunctionExpression" | "StringLiteral" | "NumericLiteral" | "NullLiteral" | "BooleanLiteral" | "RegExpLiteral" | "LogicalExpression" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "ParenthesizedExpression" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "ArrowFunctionExpression" | "ClassExpression" | "ImportExpression" | "MetaProperty" | "Super" | "TaggedTemplateExpression" | "TemplateLiteral" | "YieldExpression" | "AwaitExpression" | "Import" | "BigIntLiteral" | "OptionalMemberExpression" | "OptionalCallExpression" | "TypeCastExpression" | "JSXElement" | "JSXFragment" | "BindExpression" | "DoExpression" | "RecordExpression" | "TupleExpression" | "DecimalLiteral" | "ModuleExpression" | "TopicReference" | "PipelineTopicExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "TSInstantiationExpression" | "PrivateName" | "File" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BlockStatement" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "BreakStatement" | "CatchClause" | "ClassAccessorProperty" | "ClassBody" | "ClassDeclaration" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "ContinueStatement" | "DebuggerStatement" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoWhileStatement" | "EmptyStatement" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportAllDeclaration" | "ExportDefaultDeclaration" | "ExportDefaultSpecifier" | "ExportNamedDeclaration" | "ExportNamespaceSpecifier" | "ExportSpecifier" | "ExpressionStatement" | "ForInStatement" | "ForOfStatement" | "ForStatement" | "FunctionDeclaration" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "IfStatement" | "ImportAttribute" | "ImportDeclaration" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ImportSpecifier" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "LabeledStatement" | "MixedTypeAnnotation" | "Noop" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "ObjectMethod" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalIndexedAccessType" | "Placeholder" | "Program" | "QualifiedTypeIdentifier" | "RegexLiteral" | "RestProperty" | "ReturnStatement" | "SpreadElement" | "SpreadProperty" | "StaticBlock" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SwitchCase" | "SwitchStatement" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "TemplateElement" | "ThisTypeAnnotation" | "ThrowStatement" | "TryStatement" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "VariableDeclaration" | "VariableDeclarator" | "Variance" | "VoidTypeAnnotation" | "WhileStatement" | "WithStatement", denylistTypes?: string[] | undefined) => boolean;
|
|
16
|
-
cache: typeof import("@babel/traverse").cache;
|
|
17
|
-
};
|
|
18
|
-
declare const generate: typeof import("@babel/generator").default;
|
|
19
|
-
export { traverse, generate, parse, t };
|
|
20
|
-
export type { Babel, NodePath, ParseResult };
|
package/dist/vite/babel.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v7.0.0-pre.2
|
|
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
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var parser = require('@babel/parser');
|
|
16
|
-
var t = require('@babel/types');
|
|
17
|
-
|
|
18
|
-
function _interopNamespace(e) {
|
|
19
|
-
if (e && e.__esModule) return e;
|
|
20
|
-
var n = Object.create(null);
|
|
21
|
-
if (e) {
|
|
22
|
-
Object.keys(e).forEach(function (k) {
|
|
23
|
-
if (k !== 'default') {
|
|
24
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return e[k]; }
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
n["default"] = e;
|
|
33
|
-
return Object.freeze(n);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
37
|
-
|
|
38
|
-
// These `require`s were needed to support building within vite-ecosystem-ci,
|
|
39
|
-
// otherwise we get errors that `traverse` and `generate` are not functions.
|
|
40
|
-
const traverse = require("@babel/traverse").default;
|
|
41
|
-
const generate = require("@babel/generator").default;
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(exports, 'parse', {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return parser.parse; }
|
|
46
|
-
});
|
|
47
|
-
exports.t = t__namespace;
|
|
48
|
-
exports.generate = generate;
|
|
49
|
-
exports.traverse = traverse;
|