@react-router/dev 0.0.0-experimental-f7761f1cd → 0.0.0-experimental-63fd291ad

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/dist/config.d.ts CHANGED
@@ -1,3 +1,281 @@
1
+ import * as Vite from 'vite';
2
+ import { R as RouteManifest, a as RouteManifestEntry, b as RouteConfigEntry } from './routes-CZR-bKRt.js';
3
+ import 'valibot';
1
4
 
2
- import { i as ServerBundlesFunction, n as Preset, r as ReactRouterConfig, t as BuildManifest } from "./config-DvmRcD4Z.js";
3
- export type { BuildManifest, ReactRouterConfig as Config, Preset, ServerBundlesFunction };
5
+ declare const excludedConfigPresetKeys: readonly ["presets"];
6
+ type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
7
+ type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
8
+ type Preset = {
9
+ name: string;
10
+ reactRouterConfig?: (args: {
11
+ reactRouterUserConfig: ReactRouterConfig;
12
+ }) => ConfigPreset | Promise<ConfigPreset>;
13
+ reactRouterConfigResolved?: (args: {
14
+ reactRouterConfig: ResolvedReactRouterConfig;
15
+ }) => void | Promise<void>;
16
+ };
17
+ declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
18
+ type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
19
+ type ServerBundlesFunction = (args: {
20
+ branch: BranchRoute[];
21
+ }) => string | Promise<string>;
22
+ type BaseBuildManifest = {
23
+ routes: RouteManifest;
24
+ };
25
+ type DefaultBuildManifest = BaseBuildManifest & {
26
+ serverBundles?: never;
27
+ routeIdToServerBundleId?: never;
28
+ };
29
+ type ServerBundlesBuildManifest = BaseBuildManifest & {
30
+ serverBundles: {
31
+ [serverBundleId: string]: {
32
+ id: string;
33
+ file: string;
34
+ };
35
+ };
36
+ routeIdToServerBundleId: Record<string, string>;
37
+ };
38
+ type ServerModuleFormat = "esm" | "cjs";
39
+ interface FutureConfig {
40
+ unstable_optimizeDeps: boolean;
41
+ v8_passThroughRequests: boolean;
42
+ v8_trailingSlashAwareDataRequests: boolean;
43
+ /**
44
+ * Prerender with Vite Preview server
45
+ */
46
+ unstable_previewServerPrerendering?: boolean;
47
+ /**
48
+ * Enable route middleware
49
+ */
50
+ v8_middleware: boolean;
51
+ /**
52
+ * Automatically split route modules into multiple chunks when possible.
53
+ */
54
+ v8_splitRouteModules: boolean | "enforce";
55
+ /**
56
+ * Use Vite Environment API
57
+ */
58
+ v8_viteEnvironmentApi: boolean;
59
+ }
60
+ type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
61
+ type BuildEndHook = (args: {
62
+ buildManifest: BuildManifest | undefined;
63
+ reactRouterConfig: ResolvedReactRouterConfig;
64
+ viteConfig: Vite.ResolvedConfig;
65
+ }) => void | Promise<void>;
66
+ type PrerenderPaths = boolean | Array<string> | ((args: {
67
+ getStaticPaths: () => string[];
68
+ }) => Array<string> | Promise<Array<string>>);
69
+ /**
70
+ * Config to be exported via the default export from `react-router.config.ts`.
71
+ */
72
+ type ReactRouterConfig = {
73
+ /**
74
+ * The path to the `app` directory, relative to the root directory. Defaults
75
+ * to `"app"`.
76
+ */
77
+ appDirectory?: string;
78
+ /**
79
+ * The output format of the server build. Defaults to "esm".
80
+ */
81
+ serverModuleFormat?: ServerModuleFormat;
82
+ /**
83
+ * Enabled future flags
84
+ */
85
+ future?: [keyof FutureConfig] extends [never] ? {
86
+ [key: string]: never;
87
+ } : Partial<FutureConfig>;
88
+ /**
89
+ * The React Router app basename. Defaults to `"/"`.
90
+ */
91
+ basename?: string;
92
+ /**
93
+ * The path to the build directory, relative to the project. Defaults to
94
+ * `"build"`.
95
+ */
96
+ buildDirectory?: string;
97
+ /**
98
+ * A function that is called after the full React Router build is complete.
99
+ */
100
+ buildEnd?: BuildEndHook;
101
+ /**
102
+ * An array of URLs to prerender to HTML files at build time. Can also be a
103
+ * function returning an array to dynamically generate URLs.
104
+ *
105
+ * `concurrency` defaults to 1, which means "no concurrency" - fully serial execution.
106
+ * Setting it to a value more than 1 enables concurrent prerendering.
107
+ * Setting it to a value higher than one can increase the speed of the build,
108
+ * but may consume more resources, and send more concurrent requests to the
109
+ * server/CMS.
110
+ */
111
+ prerender?: PrerenderPaths | {
112
+ paths: PrerenderPaths;
113
+ concurrency?: number;
114
+ };
115
+ /**
116
+ * An array of React Router plugin config presets to ease integration with
117
+ * other platforms and tools.
118
+ */
119
+ presets?: Array<Preset>;
120
+ /**
121
+ * Control the "Lazy Route Discovery" behavior
122
+ *
123
+ * - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
124
+ * lazily discover routes as the user navigates around your application.
125
+ * You can set this to `initial` to opt-out of this behavior and load all
126
+ * routes with the initial HTML document load.
127
+ * - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
128
+ * Only applies to `mode: "lazy"` and defaults to `/__manifest`.
129
+ */
130
+ routeDiscovery?: {
131
+ mode: "lazy";
132
+ manifestPath?: string;
133
+ } | {
134
+ mode: "initial";
135
+ };
136
+ /**
137
+ * The file name of the server build output. This file
138
+ * should end in a `.js` extension and should be deployed to your server.
139
+ * Defaults to `"index.js"`.
140
+ */
141
+ serverBuildFile?: string;
142
+ /**
143
+ * A function for assigning routes to different server bundles. This
144
+ * function should return a server bundle ID which will be used as the
145
+ * bundle's directory name within the server build directory.
146
+ */
147
+ serverBundles?: ServerBundlesFunction;
148
+ /**
149
+ * Enable server-side rendering for your application. Disable to use "SPA
150
+ * Mode", which will request the `/` path at build-time and save it as an
151
+ * `index.html` file with your assets so your application can be deployed as a
152
+ * SPA without server-rendering. Default's to `true`.
153
+ */
154
+ ssr?: boolean;
155
+ /**
156
+ * Enable subresource integrity hashes on asset script tags. Defaults to
157
+ * `false`.
158
+ */
159
+ subResourceIntegrity?: boolean;
160
+ /**
161
+ * An array of allowed origin hosts for action submissions to UI routes (does not apply
162
+ * to resource routes). Supports micromatch glob patterns (`*` to match one segment,
163
+ * `**` to match multiple).
164
+ *
165
+ * ```tsx
166
+ * export default {
167
+ * allowedActionOrigins: [
168
+ * "example.com",
169
+ * "*.example.com", // sub.example.com
170
+ * "**.example.com", // sub.domain.example.com
171
+ * ],
172
+ * } satisfies Config;
173
+ * ```
174
+ *
175
+ * If you need to set this value at runtime, you can do in by setting the value
176
+ * on the server build in your custom server. For example, when using `express`:
177
+ *
178
+ * ```ts
179
+ * import express from "express";
180
+ * import { createRequestHandler } from "@react-router/express";
181
+ * import type { ServerBuild } from "react-router";
182
+ *
183
+ * export const app = express();
184
+ *
185
+ * async function getBuild() {
186
+ * let build: ServerBuild = await import(
187
+ * "virtual:react-router/server-build"
188
+ * );
189
+ * return {
190
+ * ...build,
191
+ * allowedActionOrigins:
192
+ * process.env.NODE_ENV === "development"
193
+ * ? undefined
194
+ * : ["staging.example.com", "www.example.com"],
195
+ * };
196
+ * }
197
+ *
198
+ * app.use(createRequestHandler({ build: getBuild }));
199
+ */
200
+ allowedActionOrigins?: string[];
201
+ };
202
+ type ResolvedReactRouterConfig = Readonly<{
203
+ /**
204
+ * The absolute path to the application source directory.
205
+ */
206
+ appDirectory: string;
207
+ /**
208
+ * The React Router app basename. Defaults to `"/"`.
209
+ */
210
+ basename: string;
211
+ /**
212
+ * The absolute path to the build directory.
213
+ */
214
+ buildDirectory: string;
215
+ /**
216
+ * A function that is called after the full React Router build is complete.
217
+ */
218
+ buildEnd?: BuildEndHook;
219
+ /**
220
+ * Enabled future flags
221
+ */
222
+ future: FutureConfig;
223
+ /**
224
+ * An array of URLs to prerender to HTML files at build time. Can also be a
225
+ * function returning an array to dynamically generate URLs.
226
+ */
227
+ prerender: ReactRouterConfig["prerender"];
228
+ /**
229
+ * Control the "Lazy Route Discovery" behavior
230
+ *
231
+ * - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
232
+ * lazily discover routes as the user navigates around your application.
233
+ * You can set this to `initial` to opt-out of this behavior and load all
234
+ * routes with the initial HTML document load.
235
+ * - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
236
+ * Only applies to `mode: "lazy"` and defaults to `/__manifest`.
237
+ */
238
+ routeDiscovery: ReactRouterConfig["routeDiscovery"];
239
+ /**
240
+ * An object of all available routes, keyed by route id.
241
+ */
242
+ routes: RouteManifest;
243
+ /**
244
+ * The file name of the server build output. This file
245
+ * should end in a `.js` extension and should be deployed to your server.
246
+ * Defaults to `"index.js"`.
247
+ */
248
+ serverBuildFile: string;
249
+ /**
250
+ * A function for assigning routes to different server bundles. This
251
+ * function should return a server bundle ID which will be used as the
252
+ * bundle's directory name within the server build directory.
253
+ */
254
+ serverBundles?: ServerBundlesFunction;
255
+ /**
256
+ * The output format of the server build. Defaults to "esm".
257
+ */
258
+ serverModuleFormat: ServerModuleFormat;
259
+ /**
260
+ * Enable server-side rendering for your application. Disable to use "SPA
261
+ * Mode", which will request the `/` path at build-time and save it as an
262
+ * `index.html` file with your assets so your application can be deployed as a
263
+ * SPA without server-rendering. Default's to `true`.
264
+ */
265
+ ssr: boolean;
266
+ /**
267
+ * Whether to generate subresource integrity hashes for asset script tags.
268
+ */
269
+ subResourceIntegrity: boolean;
270
+ /**
271
+ * The allowed origins for actions / mutations. Does not apply to routes
272
+ * without a component. micromatch glob patterns are supported.
273
+ */
274
+ allowedActionOrigins: string[] | false;
275
+ /**
276
+ * The resolved array of route config entries exported from `routes.ts`
277
+ */
278
+ unstable_routeConfig: RouteConfigEntry[];
279
+ }>;
280
+
281
+ export type { BuildManifest, ReactRouterConfig as Config, Preset, ServerBundlesFunction };
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-f7761f1cd
2
+ * @react-router/dev v0.0.0-experimental-63fd291ad
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,4 +8,21 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- export {};
11
+ "use strict";
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // config.ts
27
+ var config_exports = {};
28
+ module.exports = __toCommonJS(config_exports);
@@ -1,9 +1,7 @@
1
+ import * as v from 'valibot';
1
2
 
2
- import * as v from "valibot";
3
-
4
- //#region config/routes.d.ts
5
3
  declare global {
6
- var __reactRouterAppDirectory: string;
4
+ var __reactRouterAppDirectory: string;
7
5
  }
8
6
  /**
9
7
  * Provides the absolute path to the app directory, for use within `routes.ts`.
@@ -11,36 +9,36 @@ declare global {
11
9
  */
12
10
  declare function getAppDirectory(): string;
13
11
  interface RouteManifestEntry {
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;
12
+ /**
13
+ * The path this route uses to match on the URL pathname.
14
+ */
15
+ path?: string;
16
+ /**
17
+ * Should be `true` if it is an index route. This disallows child routes.
18
+ */
19
+ index?: boolean;
20
+ /**
21
+ * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
22
+ */
23
+ caseSensitive?: boolean;
24
+ /**
25
+ * The unique id for this route, named like its `file` but without the
26
+ * extension. So `app/routes/gists/$username.tsx` will have an `id` of
27
+ * `routes/gists/$username`.
28
+ */
29
+ id: string;
30
+ /**
31
+ * The unique `id` for this route's parent route, if there is one.
32
+ */
33
+ parentId?: string;
34
+ /**
35
+ * The path to the entry point for this route, relative to
36
+ * `config.appDirectory`.
37
+ */
38
+ file: string;
41
39
  }
42
40
  interface RouteManifest {
43
- [routeId: string]: RouteManifestEntry;
41
+ [routeId: string]: RouteManifestEntry;
44
42
  }
45
43
  /**
46
44
  * Configuration for an individual route, for use within `routes.ts`. As a
@@ -48,31 +46,31 @@ interface RouteManifest {
48
46
  * {@link index} and {@link layout} helper functions.
49
47
  */
50
48
  interface RouteConfigEntry {
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[];
49
+ /**
50
+ * The unique id for this route.
51
+ */
52
+ id?: string;
53
+ /**
54
+ * The path this route uses to match on the URL pathname.
55
+ */
56
+ path?: string;
57
+ /**
58
+ * Should be `true` if it is an index route. This disallows child routes.
59
+ */
60
+ index?: boolean;
61
+ /**
62
+ * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
63
+ */
64
+ caseSensitive?: boolean;
65
+ /**
66
+ * The path to the entry point for this route, relative to
67
+ * `config.appDirectory`.
68
+ */
69
+ file: string;
70
+ /**
71
+ * The child routes.
72
+ */
73
+ children?: RouteConfigEntry[];
76
74
  }
77
75
  declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
78
76
  type ResolvedRouteConfig = v.InferInput<typeof resolvedRouteConfigSchema>;
@@ -109,16 +107,17 @@ declare function layout(file: string, options: CreateLayoutOptions, children?: R
109
107
  */
110
108
  declare function prefix(prefixPath: string, routes: RouteConfigEntry[]): RouteConfigEntry[];
111
109
  declare const helpers: {
112
- route: typeof route;
113
- index: typeof index;
114
- layout: typeof layout;
115
- prefix: typeof prefix;
110
+ route: typeof route;
111
+ index: typeof index;
112
+ layout: typeof layout;
113
+ prefix: typeof prefix;
116
114
  };
115
+
117
116
  /**
118
117
  * Creates a set of route config helpers that resolve file paths relative to the
119
118
  * given directory, for use within `routes.ts`. This is designed to support
120
119
  * splitting route config into multiple files within different directories.
121
120
  */
122
121
  declare function relative(directory: string): typeof helpers;
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 };
122
+
123
+ export { type RouteManifest as R, type RouteManifestEntry as a, type RouteConfigEntry as b, type RouteConfig 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,3 +1,2 @@
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 };
1
+ export { c as RouteConfig, b as RouteConfigEntry, g as getAppDirectory, i as index, l as layout, p as prefix, d as relative, r as route } from './routes-CZR-bKRt.js';
2
+ import 'valibot';
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-f7761f1cd
2
+ * @react-router/dev v0.0.0-experimental-63fd291ad
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,5 +8,192 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { a as prefix, i as layout, n as getAppDirectory, o as relative, r as index, s as route } from "./routes-Craztzkd.js";
12
- export { getAppDirectory, index, layout, prefix, relative, route };
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);
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
+ });