@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.
Files changed (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cli/index.d.ts +2 -1
  3. package/dist/cli/index.js +1198 -8
  4. package/dist/{config/routes.d.ts → routes-C14jcF98.d.ts} +15 -21
  5. package/dist/routes.d.ts +2 -2
  6. package/dist/routes.js +181 -11
  7. package/dist/typescript/plugin.d.ts +5 -2
  8. package/dist/typescript/plugin.js +479 -31
  9. package/dist/vite/cloudflare.d.ts +23 -1
  10. package/dist/vite/cloudflare.js +171 -5
  11. package/dist/vite.d.ts +169 -2
  12. package/dist/vite.js +2394 -5
  13. package/package.json +28 -7
  14. package/dist/cli/commands.d.ts +0 -13
  15. package/dist/cli/commands.js +0 -179
  16. package/dist/cli/detectPackageManager.d.ts +0 -10
  17. package/dist/cli/detectPackageManager.js +0 -39
  18. package/dist/cli/run.d.ts +0 -5
  19. package/dist/cli/run.js +0 -188
  20. package/dist/cli/useJavascript.d.ts +0 -4
  21. package/dist/cli/useJavascript.js +0 -66
  22. package/dist/colors.d.ts +0 -17
  23. package/dist/colors.js +0 -49
  24. package/dist/config/format.d.ts +0 -5
  25. package/dist/config/format.js +0 -68
  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,11 +1,14 @@
1
- import * as v from "valibot";
2
- export declare function setAppDirectory(directory: string): void;
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
- export declare function getAppDirectory(): string;
8
- export interface RouteManifestEntry {
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
- export interface RouteManifest {
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
- export interface RouteConfigEntry {
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
- 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>;
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
- 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
- };
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
- export { route, index, layout, prefix };
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
- export declare function relative(directory: string): typeof helpers;
129
- export declare function configRoutesToRouteManifest(routes: RouteConfigEntry[], rootId?: string): RouteManifest;
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 type { RouteConfig, RouteConfigEntry } from "./config/routes";
2
- export { route, index, layout, prefix, relative, getAppDirectory, } from "./config/routes";
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 v7.0.0-pre.2
2
+ * @react-router/dev v7.0.0-pre.4
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,17 +8,187 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- 'use strict';
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
- Object.defineProperty(exports, '__esModule', { value: true });
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
- var routes = require('./config/routes.js');
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
- exports.getAppDirectory = routes.getAppDirectory;
20
- exports.index = routes.index;
21
- exports.layout = routes.layout;
22
- exports.prefix = routes.prefix;
23
- exports.relative = routes.relative;
24
- exports.route = routes.route;
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,4 +1,7 @@
1
- import type ts from "typescript/lib/tsserverlibrary";
2
- export default function init(): {
1
+ import ts from 'typescript/lib/tsserverlibrary';
2
+
3
+ declare function init(): {
3
4
  create: (info: ts.server.PluginCreateInfo) => ts.LanguageService;
4
5
  };
6
+
7
+ export { init as default };