@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.3

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cli/index.d.ts +2 -1
  3. package/dist/cli/index.js +1352 -8
  4. package/dist/routes.d.ts +4 -2
  5. package/dist/routes.js +181 -11
  6. package/dist/typescript/plugin.d.ts +5 -2
  7. package/dist/typescript/plugin.js +479 -31
  8. package/dist/vite/cloudflare.d.ts +1 -1
  9. package/dist/vite/cloudflare.js +171 -5
  10. package/dist/vite.d.ts +2 -2
  11. package/dist/vite.js +2394 -5
  12. package/package.json +28 -7
  13. package/dist/cli/commands.d.ts +0 -13
  14. package/dist/cli/commands.js +0 -179
  15. package/dist/cli/detectPackageManager.d.ts +0 -10
  16. package/dist/cli/detectPackageManager.js +0 -39
  17. package/dist/cli/run.d.ts +0 -5
  18. package/dist/cli/run.js +0 -188
  19. package/dist/cli/useJavascript.d.ts +0 -4
  20. package/dist/cli/useJavascript.js +0 -66
  21. package/dist/colors.d.ts +0 -17
  22. package/dist/colors.js +0 -49
  23. package/dist/config/format.d.ts +0 -5
  24. package/dist/config/format.js +0 -68
  25. package/dist/config/routes.d.ts +0 -129
  26. package/dist/config/routes.js +0 -253
  27. package/dist/config/serverModes.d.ts +0 -9
  28. package/dist/invariant.d.ts +0 -2
  29. package/dist/invariant.js +0 -20
  30. package/dist/manifest.d.ts +0 -28
  31. package/dist/typescript/typegen.d.ts +0 -10
  32. package/dist/typescript/typegen.js +0 -190
  33. package/dist/vite/babel.d.ts +0 -20
  34. package/dist/vite/babel.js +0 -49
  35. package/dist/vite/build.d.ts +0 -15
  36. package/dist/vite/build.js +0 -249
  37. package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
  38. package/dist/vite/cloudflare-dev-proxy.js +0 -89
  39. package/dist/vite/combine-urls-test.d.ts +0 -1
  40. package/dist/vite/combine-urls.d.ts +0 -1
  41. package/dist/vite/combine-urls.js +0 -20
  42. package/dist/vite/config.d.ts +0 -234
  43. package/dist/vite/config.js +0 -282
  44. package/dist/vite/dev.d.ts +0 -15
  45. package/dist/vite/dev.js +0 -81
  46. package/dist/vite/import-vite-esm-sync.d.ts +0 -4
  47. package/dist/vite/import-vite-esm-sync.js +0 -28
  48. package/dist/vite/node-adapter.d.ts +0 -6
  49. package/dist/vite/node-adapter.js +0 -90
  50. package/dist/vite/plugin.d.ts +0 -75
  51. package/dist/vite/plugin.js +0 -1301
  52. package/dist/vite/profiler.d.ts +0 -5
  53. package/dist/vite/profiler.js +0 -55
  54. package/dist/vite/remove-exports-test.d.ts +0 -1
  55. package/dist/vite/remove-exports.d.ts +0 -2
  56. package/dist/vite/remove-exports.js +0 -148
  57. package/dist/vite/resolve-file-url.d.ts +0 -3
  58. package/dist/vite/resolve-file-url.js +0 -53
  59. package/dist/vite/styles.d.ts +0 -14
  60. package/dist/vite/styles.js +0 -199
  61. package/dist/vite/vite-node.d.ts +0 -9
  62. package/dist/vite/vite-node.js +0 -57
  63. package/dist/vite/vmod.d.ts +0 -3
  64. package/dist/vite/vmod.js +0 -21
  65. package/dist/vite/with-props.d.ts +0 -4
  66. package/dist/vite/with-props.js +0 -151
  67. /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
@@ -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;
@@ -1,129 +0,0 @@
1
- import * as v from "valibot";
2
- export declare function setAppDirectory(directory: string): void;
3
- /**
4
- * Provides the absolute path to the app directory, for use within `routes.ts`.
5
- * This is designed to support resolving file system routes.
6
- */
7
- export declare function getAppDirectory(): string;
8
- export interface RouteManifestEntry {
9
- /**
10
- * The path this route uses to match on the URL pathname.
11
- */
12
- path?: string;
13
- /**
14
- * Should be `true` if it is an index route. This disallows child routes.
15
- */
16
- index?: boolean;
17
- /**
18
- * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
19
- */
20
- caseSensitive?: boolean;
21
- /**
22
- * The unique id for this route, named like its `file` but without the
23
- * extension. So `app/routes/gists/$username.tsx` will have an `id` of
24
- * `routes/gists/$username`.
25
- */
26
- id: string;
27
- /**
28
- * The unique `id` for this route's parent route, if there is one.
29
- */
30
- parentId?: string;
31
- /**
32
- * The path to the entry point for this route, relative to
33
- * `config.appDirectory`.
34
- */
35
- file: string;
36
- }
37
- export interface RouteManifest {
38
- [routeId: string]: RouteManifestEntry;
39
- }
40
- /**
41
- * Configuration for an individual route, for use within `routes.ts`. As a
42
- * convenience, route config entries can be created with the {@link route},
43
- * {@link index} and {@link layout} helper functions.
44
- */
45
- export interface RouteConfigEntry {
46
- /**
47
- * The unique id for this route.
48
- */
49
- id?: string;
50
- /**
51
- * The path this route uses to match on the URL pathname.
52
- */
53
- path?: string;
54
- /**
55
- * Should be `true` if it is an index route. This disallows child routes.
56
- */
57
- index?: boolean;
58
- /**
59
- * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
60
- */
61
- caseSensitive?: boolean;
62
- /**
63
- * The path to the entry point for this route, relative to
64
- * `config.appDirectory`.
65
- */
66
- file: string;
67
- /**
68
- * The child routes.
69
- */
70
- children?: RouteConfigEntry[];
71
- }
72
- export declare const routeConfigEntrySchema: v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>;
73
- export declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
74
- type ResolvedRouteConfig = v.InferInput<typeof resolvedRouteConfigSchema>;
75
- /**
76
- * Route config to be exported via the `routes` export within `routes.ts`.
77
- */
78
- export type RouteConfig = ResolvedRouteConfig | Promise<ResolvedRouteConfig>;
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
- };
88
- declare const createConfigRouteOptionKeys: ["id", "index", "caseSensitive"];
89
- type CreateRouteOptions = Pick<RouteConfigEntry, (typeof createConfigRouteOptionKeys)[number]>;
90
- /**
91
- * Helper function for creating a route config entry, for use within
92
- * `routes.ts`.
93
- */
94
- declare function route(path: string | null | undefined, file: string, children?: RouteConfigEntry[]): RouteConfigEntry;
95
- declare function route(path: string | null | undefined, file: string, options: CreateRouteOptions, children?: RouteConfigEntry[]): RouteConfigEntry;
96
- declare const createIndexOptionKeys: ["id"];
97
- type CreateIndexOptions = Pick<RouteConfigEntry, (typeof createIndexOptionKeys)[number]>;
98
- /**
99
- * Helper function for creating a route config entry for an index route, for use
100
- * within `routes.ts`.
101
- */
102
- declare function index(file: string, options?: CreateIndexOptions): RouteConfigEntry;
103
- declare const createLayoutOptionKeys: ["id"];
104
- type CreateLayoutOptions = Pick<RouteConfigEntry, (typeof createLayoutOptionKeys)[number]>;
105
- /**
106
- * Helper function for creating a route config entry for a layout route, for use
107
- * within `routes.ts`.
108
- */
109
- declare function layout(file: string, children?: RouteConfigEntry[]): RouteConfigEntry;
110
- declare function layout(file: string, options: CreateLayoutOptions, children?: RouteConfigEntry[]): RouteConfigEntry;
111
- /**
112
- * Helper function for adding a path prefix to a set of routes without needing
113
- * to introduce a parent route file, for use within `routes.ts`.
114
- */
115
- declare function prefix(prefixPath: string, routes: RouteConfigEntry[]): RouteConfigEntry[];
116
- declare const helpers: {
117
- route: typeof route;
118
- index: typeof index;
119
- layout: typeof layout;
120
- prefix: typeof prefix;
121
- };
122
- export { route, index, layout, prefix };
123
- /**
124
- * Creates a set of route config helpers that resolve file paths relative to the
125
- * given directory, for use within `routes.ts`. This is designed to support
126
- * splitting route config into multiple files within different directories.
127
- */
128
- export declare function relative(directory: string): typeof helpers;
129
- export declare function configRoutesToRouteManifest(routes: RouteConfigEntry[], rootId?: string): RouteManifest;
@@ -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;
@@ -1,9 +0,0 @@
1
- /**
2
- * The mode to use when running the server.
3
- */
4
- export declare enum ServerMode {
5
- Development = "development",
6
- Production = "production",
7
- Test = "test"
8
- }
9
- export declare function isValidServerMode(mode: string): mode is ServerMode;
@@ -1,2 +0,0 @@
1
- export default function invariant(value: boolean, message?: string): asserts value;
2
- export default function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
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;
@@ -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 {};