@react-router/dev 7.15.1 → 8.0.0-pre.0
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 +18 -0
- package/bin.cjs +20 -0
- package/dist/build-DM91F_L-.js +41 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +378 -2591
- package/dist/config-DvmRcD4Z.d.ts +279 -0
- package/dist/config.d.ts +2 -280
- package/dist/config.js +2 -19
- package/dist/dev-CNEgIjT-.js +53 -0
- package/dist/routes-DXogguGb.js +194 -0
- package/dist/{routes-CZR-bKRt.d.ts → routes-Kx8VZRs3.d.ts} +63 -62
- package/dist/routes.d.ts +3 -2
- package/dist/routes.js +3 -190
- package/dist/typegen-BLMwBSoM.js +859 -0
- package/dist/vite.d.ts +7 -6
- package/dist/vite.js +3225 -6492
- package/module-sync-enabled/index.mjs +2 -2
- package/package.json +53 -59
- package/bin.js +0 -15
- package/dist/vite/cloudflare.d.ts +0 -24
- package/dist/vite/cloudflare.js +0 -891
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @react-router/dev v8.0.0-pre.0
|
|
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 * as Path from "pathe";
|
|
12
|
+
import pick from "lodash/pick.js";
|
|
13
|
+
import * as v from "valibot";
|
|
14
|
+
//#region invariant.ts
|
|
15
|
+
function invariant(value, message) {
|
|
16
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
17
|
+
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");
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region config/routes.ts
|
|
23
|
+
function setAppDirectory(directory) {
|
|
24
|
+
globalThis.__reactRouterAppDirectory = directory;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Provides the absolute path to the app directory, for use within `routes.ts`.
|
|
28
|
+
* This is designed to support resolving file system routes.
|
|
29
|
+
*/
|
|
30
|
+
function getAppDirectory() {
|
|
31
|
+
invariant(globalThis.__reactRouterAppDirectory);
|
|
32
|
+
return globalThis.__reactRouterAppDirectory;
|
|
33
|
+
}
|
|
34
|
+
const routeConfigEntrySchema = v.pipe(v.custom((value) => {
|
|
35
|
+
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
36
|
+
}, "Invalid type: Expected object but received a promise. Did you forget to await?"), v.object({
|
|
37
|
+
id: v.optional(v.pipe(v.string(), v.notValue("root", "A route cannot use the reserved id 'root'."))),
|
|
38
|
+
path: v.optional(v.string()),
|
|
39
|
+
index: v.optional(v.boolean()),
|
|
40
|
+
caseSensitive: v.optional(v.boolean()),
|
|
41
|
+
file: v.string(),
|
|
42
|
+
children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
|
|
43
|
+
}));
|
|
44
|
+
const resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
|
|
45
|
+
function validateRouteConfig({ routeConfigFile, routeConfig }) {
|
|
46
|
+
if (!routeConfig) return {
|
|
47
|
+
valid: false,
|
|
48
|
+
message: `Route config must be the default export in "${routeConfigFile}".`
|
|
49
|
+
};
|
|
50
|
+
if (!Array.isArray(routeConfig)) return {
|
|
51
|
+
valid: false,
|
|
52
|
+
message: `Route config in "${routeConfigFile}" must be an array.`
|
|
53
|
+
};
|
|
54
|
+
let { issues } = v.safeParse(resolvedRouteConfigSchema, routeConfig);
|
|
55
|
+
if (issues?.length) {
|
|
56
|
+
let { root, nested } = v.flatten(issues);
|
|
57
|
+
return {
|
|
58
|
+
valid: false,
|
|
59
|
+
message: [
|
|
60
|
+
`Route config in "${routeConfigFile}" is invalid.`,
|
|
61
|
+
root ? `${root}` : [],
|
|
62
|
+
nested ? Object.entries(nested).map(([path, message]) => `Path: routes.${path}\n${message}`) : []
|
|
63
|
+
].flat().join("\n\n")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
valid: true,
|
|
68
|
+
routeConfig
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const createConfigRouteOptionKeys = [
|
|
72
|
+
"id",
|
|
73
|
+
"index",
|
|
74
|
+
"caseSensitive"
|
|
75
|
+
];
|
|
76
|
+
function route(path, file, optionsOrChildren, children) {
|
|
77
|
+
let options = {};
|
|
78
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) children = optionsOrChildren;
|
|
79
|
+
else options = optionsOrChildren;
|
|
80
|
+
return {
|
|
81
|
+
file,
|
|
82
|
+
children,
|
|
83
|
+
path: path ?? void 0,
|
|
84
|
+
...pick(options, createConfigRouteOptionKeys)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const createIndexOptionKeys = ["id"];
|
|
88
|
+
/**
|
|
89
|
+
* Helper function for creating a route config entry for an index route, for use
|
|
90
|
+
* within `routes.ts`.
|
|
91
|
+
*/
|
|
92
|
+
function index(file, options) {
|
|
93
|
+
return {
|
|
94
|
+
file,
|
|
95
|
+
index: true,
|
|
96
|
+
...pick(options, createIndexOptionKeys)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const createLayoutOptionKeys = ["id"];
|
|
100
|
+
function layout(file, optionsOrChildren, children) {
|
|
101
|
+
let options = {};
|
|
102
|
+
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) children = optionsOrChildren;
|
|
103
|
+
else options = optionsOrChildren;
|
|
104
|
+
return {
|
|
105
|
+
file,
|
|
106
|
+
children,
|
|
107
|
+
...pick(options, createLayoutOptionKeys)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Helper function for adding a path prefix to a set of routes without needing
|
|
112
|
+
* to introduce a parent route file, for use within `routes.ts`.
|
|
113
|
+
*/
|
|
114
|
+
function prefix(prefixPath, routes) {
|
|
115
|
+
return routes.map((route) => {
|
|
116
|
+
if (route.index || typeof route.path === "string") return {
|
|
117
|
+
...route,
|
|
118
|
+
path: route.path ? joinRoutePaths(prefixPath, route.path) : prefixPath,
|
|
119
|
+
children: route.children
|
|
120
|
+
};
|
|
121
|
+
else if (route.children) return {
|
|
122
|
+
...route,
|
|
123
|
+
children: prefix(prefixPath, route.children)
|
|
124
|
+
};
|
|
125
|
+
return route;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates a set of route config helpers that resolve file paths relative to the
|
|
130
|
+
* given directory, for use within `routes.ts`. This is designed to support
|
|
131
|
+
* splitting route config into multiple files within different directories.
|
|
132
|
+
*/
|
|
133
|
+
function relative(directory) {
|
|
134
|
+
return {
|
|
135
|
+
/**
|
|
136
|
+
* Helper function for creating a route config entry, for use within
|
|
137
|
+
* `routes.ts`. Note that this helper has been scoped, meaning that file
|
|
138
|
+
* path will be resolved relative to the directory provided to the
|
|
139
|
+
* `relative` call that created this helper.
|
|
140
|
+
*/
|
|
141
|
+
route: (path, file, ...rest) => {
|
|
142
|
+
return route(path, Path.resolve(directory, file), ...rest);
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* Helper function for creating a route config entry for an index route, for
|
|
146
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
147
|
+
* that file path will be resolved relative to the directory provided to the
|
|
148
|
+
* `relative` call that created this helper.
|
|
149
|
+
*/
|
|
150
|
+
index: (file, ...rest) => {
|
|
151
|
+
return index(Path.resolve(directory, file), ...rest);
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Helper function for creating a route config entry for a layout route, for
|
|
155
|
+
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
156
|
+
* that file path will be resolved relative to the directory provided to the
|
|
157
|
+
* `relative` call that created this helper.
|
|
158
|
+
*/
|
|
159
|
+
layout: (file, ...rest) => {
|
|
160
|
+
return layout(Path.resolve(directory, file), ...rest);
|
|
161
|
+
},
|
|
162
|
+
prefix
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function configRoutesToRouteManifest(appDirectory, routes) {
|
|
166
|
+
let routeManifest = {};
|
|
167
|
+
function walk(route, parentId) {
|
|
168
|
+
let id = route.id || createRouteId(route.file);
|
|
169
|
+
let manifestItem = {
|
|
170
|
+
id,
|
|
171
|
+
parentId,
|
|
172
|
+
file: Path.isAbsolute(route.file) ? Path.relative(appDirectory, route.file) : route.file,
|
|
173
|
+
path: route.path,
|
|
174
|
+
index: route.index,
|
|
175
|
+
caseSensitive: route.caseSensitive
|
|
176
|
+
};
|
|
177
|
+
if (routeManifest.hasOwnProperty(id)) throw new Error(`Unable to define routes with duplicate route id: "${id}"`);
|
|
178
|
+
routeManifest[id] = manifestItem;
|
|
179
|
+
if (route.children) for (let child of route.children) walk(child, id);
|
|
180
|
+
}
|
|
181
|
+
for (let route of routes) walk(route);
|
|
182
|
+
return routeManifest;
|
|
183
|
+
}
|
|
184
|
+
function createRouteId(file) {
|
|
185
|
+
return Path.normalize(stripFileExtension(file));
|
|
186
|
+
}
|
|
187
|
+
function stripFileExtension(file) {
|
|
188
|
+
return file.replace(/\.[a-z0-9]+$/i, "");
|
|
189
|
+
}
|
|
190
|
+
function joinRoutePaths(path1, path2) {
|
|
191
|
+
return [path1.replace(/\/+$/, ""), path2.replace(/^\/+/, "")].join("/");
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { prefix as a, setAppDirectory as c, layout as i, validateRouteConfig as l, getAppDirectory as n, relative as o, index as r, route as s, configRoutesToRouteManifest as t, invariant as u };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
1
|
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
|
|
4
|
+
//#region config/routes.d.ts
|
|
3
5
|
declare global {
|
|
4
|
-
|
|
6
|
+
var __reactRouterAppDirectory: string;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Provides the absolute path to the app directory, for use within `routes.ts`.
|
|
@@ -9,36 +11,36 @@ declare global {
|
|
|
9
11
|
*/
|
|
10
12
|
declare function getAppDirectory(): string;
|
|
11
13
|
interface RouteManifestEntry {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The path this route uses to match on the URL pathname.
|
|
16
|
+
*/
|
|
17
|
+
path?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Should be `true` if it is an index route. This disallows child routes.
|
|
20
|
+
*/
|
|
21
|
+
index?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Should be `true` if the `path` is case-sensitive. Defaults to `false`.
|
|
24
|
+
*/
|
|
25
|
+
caseSensitive?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The unique id for this route, named like its `file` but without the
|
|
28
|
+
* extension. So `app/routes/gists/$username.tsx` will have an `id` of
|
|
29
|
+
* `routes/gists/$username`.
|
|
30
|
+
*/
|
|
31
|
+
id: string;
|
|
32
|
+
/**
|
|
33
|
+
* The unique `id` for this route's parent route, if there is one.
|
|
34
|
+
*/
|
|
35
|
+
parentId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The path to the entry point for this route, relative to
|
|
38
|
+
* `config.appDirectory`.
|
|
39
|
+
*/
|
|
40
|
+
file: string;
|
|
39
41
|
}
|
|
40
42
|
interface RouteManifest {
|
|
41
|
-
|
|
43
|
+
[routeId: string]: RouteManifestEntry;
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* Configuration for an individual route, for use within `routes.ts`. As a
|
|
@@ -46,31 +48,31 @@ interface RouteManifest {
|
|
|
46
48
|
* {@link index} and {@link layout} helper functions.
|
|
47
49
|
*/
|
|
48
50
|
interface RouteConfigEntry {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The unique id for this route.
|
|
53
|
+
*/
|
|
54
|
+
id?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The path this route uses to match on the URL pathname.
|
|
57
|
+
*/
|
|
58
|
+
path?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Should be `true` if it is an index route. This disallows child routes.
|
|
61
|
+
*/
|
|
62
|
+
index?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Should be `true` if the `path` is case-sensitive. Defaults to `false`.
|
|
65
|
+
*/
|
|
66
|
+
caseSensitive?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The path to the entry point for this route, relative to
|
|
69
|
+
* `config.appDirectory`.
|
|
70
|
+
*/
|
|
71
|
+
file: string;
|
|
72
|
+
/**
|
|
73
|
+
* The child routes.
|
|
74
|
+
*/
|
|
75
|
+
children?: RouteConfigEntry[];
|
|
74
76
|
}
|
|
75
77
|
declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
|
|
76
78
|
type ResolvedRouteConfig = v.InferInput<typeof resolvedRouteConfigSchema>;
|
|
@@ -107,17 +109,16 @@ declare function layout(file: string, options: CreateLayoutOptions, children?: R
|
|
|
107
109
|
*/
|
|
108
110
|
declare function prefix(prefixPath: string, routes: RouteConfigEntry[]): RouteConfigEntry[];
|
|
109
111
|
declare const helpers: {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
route: typeof route;
|
|
113
|
+
index: typeof index;
|
|
114
|
+
layout: typeof layout;
|
|
115
|
+
prefix: typeof prefix;
|
|
114
116
|
};
|
|
115
|
-
|
|
116
117
|
/**
|
|
117
118
|
* Creates a set of route config helpers that resolve file paths relative to the
|
|
118
119
|
* given directory, for use within `routes.ts`. This is designed to support
|
|
119
120
|
* splitting route config into multiple files within different directories.
|
|
120
121
|
*/
|
|
121
122
|
declare function relative(directory: string): typeof helpers;
|
|
122
|
-
|
|
123
|
-
export {
|
|
123
|
+
//#endregion
|
|
124
|
+
export { getAppDirectory as a, prefix as c, RouteManifestEntry as i, relative as l, RouteConfigEntry as n, index as o, RouteManifest as r, layout as s, RouteConfig as t, route as u };
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
|
|
2
|
+
import { a as getAppDirectory, c as prefix, l as relative, n as RouteConfigEntry, o as index, s as layout, t as RouteConfig, u as route } from "./routes-Kx8VZRs3.js";
|
|
3
|
+
export { type RouteConfig, type RouteConfigEntry, getAppDirectory, index, layout, prefix, relative, route };
|
package/dist/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev
|
|
2
|
+
* @react-router/dev v8.0.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,192 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
39
|
-
|
|
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: () => relative2,
|
|
48
|
-
route: () => route
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(routes_exports);
|
|
51
|
-
|
|
52
|
-
// config/routes.ts
|
|
53
|
-
var Path = __toESM(require("pathe"));
|
|
54
|
-
var v = __toESM(require("valibot"));
|
|
55
|
-
var import_pick = __toESM(require("lodash/pick"));
|
|
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
|
-
}
|
|
66
|
-
|
|
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(
|
|
78
|
-
v.pipe(
|
|
79
|
-
v.string(),
|
|
80
|
-
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
81
|
-
)
|
|
82
|
-
),
|
|
83
|
-
path: v.optional(v.string()),
|
|
84
|
-
index: v.optional(v.boolean()),
|
|
85
|
-
caseSensitive: v.optional(v.boolean()),
|
|
86
|
-
file: v.string(),
|
|
87
|
-
children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
|
|
91
|
-
var createConfigRouteOptionKeys = [
|
|
92
|
-
"id",
|
|
93
|
-
"index",
|
|
94
|
-
"caseSensitive"
|
|
95
|
-
];
|
|
96
|
-
function route(path, file, optionsOrChildren, children) {
|
|
97
|
-
let options = {};
|
|
98
|
-
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
99
|
-
children = optionsOrChildren;
|
|
100
|
-
} else {
|
|
101
|
-
options = optionsOrChildren;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
file,
|
|
105
|
-
children,
|
|
106
|
-
path: path ?? void 0,
|
|
107
|
-
...(0, import_pick.default)(options, createConfigRouteOptionKeys)
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
var createIndexOptionKeys = ["id"];
|
|
111
|
-
function index(file, options) {
|
|
112
|
-
return {
|
|
113
|
-
file,
|
|
114
|
-
index: true,
|
|
115
|
-
...(0, import_pick.default)(options, createIndexOptionKeys)
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
var createLayoutOptionKeys = ["id"];
|
|
119
|
-
function layout(file, optionsOrChildren, children) {
|
|
120
|
-
let options = {};
|
|
121
|
-
if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
|
|
122
|
-
children = optionsOrChildren;
|
|
123
|
-
} else {
|
|
124
|
-
options = optionsOrChildren;
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
file,
|
|
128
|
-
children,
|
|
129
|
-
...(0, import_pick.default)(options, createLayoutOptionKeys)
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function prefix(prefixPath, routes) {
|
|
133
|
-
return routes.map((route2) => {
|
|
134
|
-
if (route2.index || typeof route2.path === "string") {
|
|
135
|
-
return {
|
|
136
|
-
...route2,
|
|
137
|
-
path: route2.path ? joinRoutePaths(prefixPath, route2.path) : prefixPath,
|
|
138
|
-
children: route2.children
|
|
139
|
-
};
|
|
140
|
-
} else if (route2.children) {
|
|
141
|
-
return {
|
|
142
|
-
...route2,
|
|
143
|
-
children: prefix(prefixPath, route2.children)
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
return route2;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function relative2(directory) {
|
|
150
|
-
return {
|
|
151
|
-
/**
|
|
152
|
-
* Helper function for creating a route config entry, for use within
|
|
153
|
-
* `routes.ts`. Note that this helper has been scoped, meaning that file
|
|
154
|
-
* path will be resolved relative to the directory provided to the
|
|
155
|
-
* `relative` call that created this helper.
|
|
156
|
-
*/
|
|
157
|
-
route: (path, file, ...rest) => {
|
|
158
|
-
return route(path, Path.resolve(directory, file), ...rest);
|
|
159
|
-
},
|
|
160
|
-
/**
|
|
161
|
-
* Helper function for creating a route config entry for an index route, for
|
|
162
|
-
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
163
|
-
* that file path will be resolved relative to the directory provided to the
|
|
164
|
-
* `relative` call that created this helper.
|
|
165
|
-
*/
|
|
166
|
-
index: (file, ...rest) => {
|
|
167
|
-
return index(Path.resolve(directory, file), ...rest);
|
|
168
|
-
},
|
|
169
|
-
/**
|
|
170
|
-
* Helper function for creating a route config entry for a layout route, for
|
|
171
|
-
* use within `routes.ts`. Note that this helper has been scoped, meaning
|
|
172
|
-
* that file path will be resolved relative to the directory provided to the
|
|
173
|
-
* `relative` call that created this helper.
|
|
174
|
-
*/
|
|
175
|
-
layout: (file, ...rest) => {
|
|
176
|
-
return layout(Path.resolve(directory, file), ...rest);
|
|
177
|
-
},
|
|
178
|
-
// Passthrough of helper functions that don't need relative scoping so that
|
|
179
|
-
// a complete API is still provided.
|
|
180
|
-
prefix
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function joinRoutePaths(path1, path2) {
|
|
184
|
-
return [
|
|
185
|
-
path1.replace(/\/+$/, ""),
|
|
186
|
-
// Remove trailing slashes
|
|
187
|
-
path2.replace(/^\/+/, "")
|
|
188
|
-
// Remove leading slashes
|
|
189
|
-
].join("/");
|
|
190
|
-
}
|
|
191
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
-
0 && (module.exports = {
|
|
193
|
-
getAppDirectory,
|
|
194
|
-
index,
|
|
195
|
-
layout,
|
|
196
|
-
prefix,
|
|
197
|
-
relative,
|
|
198
|
-
route
|
|
199
|
-
});
|
|
11
|
+
import { a as prefix, i as layout, n as getAppDirectory, o as relative, r as index, s as route } from "./routes-DXogguGb.js";
|
|
12
|
+
export { getAppDirectory, index, layout, prefix, relative, route };
|