@vaadin/hilla-file-router 25.0.0-alpha1 → 25.0.0-alpha10

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 (50) hide show
  1. package/package.json +5 -5
  2. package/runtime/configuration-builder/RouterConfigurationBuilder.d.ts +131 -0
  3. package/runtime/configuration-builder/RouterConfigurationBuilder.js +162 -0
  4. package/runtime/configuration-builder/RouterConfigurationBuilder.js.map +1 -0
  5. package/runtime/configuration-builder/createFallbackTransformer.d.ts +44 -0
  6. package/runtime/configuration-builder/createFallbackTransformer.js +66 -0
  7. package/runtime/configuration-builder/createFallbackTransformer.js.map +1 -0
  8. package/runtime/configuration-builder/createProtectTransformer.d.ts +11 -0
  9. package/runtime/configuration-builder/createProtectTransformer.js +21 -0
  10. package/runtime/configuration-builder/createProtectTransformer.js.map +1 -0
  11. package/runtime/configuration-builder/fileRouteTransformer.d.ts +17 -0
  12. package/runtime/configuration-builder/fileRouteTransformer.js +47 -0
  13. package/runtime/configuration-builder/fileRouteTransformer.js.map +1 -0
  14. package/runtime/configuration-builder/mergeDeepWildcard.d.ts +2 -0
  15. package/runtime/configuration-builder/mergeDeepWildcard.js +17 -0
  16. package/runtime/configuration-builder/mergeDeepWildcard.js.map +1 -0
  17. package/runtime/configuration-builder/mergeLayout.d.ts +24 -0
  18. package/runtime/configuration-builder/mergeLayout.js +71 -0
  19. package/runtime/configuration-builder/mergeLayout.js.map +1 -0
  20. package/runtime/configuration-builder/mergeRouteTrees.d.ts +24 -0
  21. package/runtime/configuration-builder/mergeRouteTrees.js +179 -0
  22. package/runtime/configuration-builder/mergeRouteTrees.js.map +1 -0
  23. package/runtime/configuration-builder/mergeSkipLayout.d.ts +18 -0
  24. package/runtime/configuration-builder/mergeSkipLayout.js +56 -0
  25. package/runtime/configuration-builder/mergeSkipLayout.js.map +1 -0
  26. package/runtime/configuration-builder/utils.d.ts +105 -0
  27. package/runtime/configuration-builder/utils.js +79 -0
  28. package/runtime/configuration-builder/utils.js.map +1 -0
  29. package/runtime/createMenuItems.js +1 -1
  30. package/runtime/createMenuItems.js.map +1 -1
  31. package/runtime/createRoute.js.map +1 -1
  32. package/runtime/useViewConfig.js.map +1 -1
  33. package/runtime.d.ts +1 -1
  34. package/runtime.js +1 -1
  35. package/runtime.js.map +1 -1
  36. package/shared/convertComponentNameToTitle.js.map +1 -1
  37. package/shared/routeParamType.js.map +1 -1
  38. package/shared/transformTree.d.ts +11 -1
  39. package/shared/transformTree.js.map +1 -1
  40. package/vite-plugin/applyLayouts.js.map +1 -1
  41. package/vite-plugin/collectRoutesFromFS.js +1 -1
  42. package/vite-plugin/collectRoutesFromFS.js.map +1 -1
  43. package/vite-plugin/createRoutesFromMeta.js.map +1 -1
  44. package/vite-plugin/createViewConfigJson.js.map +1 -1
  45. package/vite-plugin/generateRuntimeFiles.js.map +1 -1
  46. package/vite-plugin/utils.js.map +1 -1
  47. package/vite-plugin.js.map +1 -1
  48. package/runtime/RouterConfigurationBuilder.d.ts +0 -76
  49. package/runtime/RouterConfigurationBuilder.js +0 -305
  50. package/runtime/RouterConfigurationBuilder.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-file-router",
3
- "version": "25.0.0-alpha1",
3
+ "version": "25.0.0-alpha10",
4
4
  "description": "Hilla file-based router",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -62,10 +62,10 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@ungap/with-resolvers": "0.1.0",
65
- "@vaadin/hilla-generator-utils": "25.0.0-alpha1",
66
- "@vaadin/hilla-react-auth": "25.0.0-alpha1",
67
- "@vaadin/hilla-react-signals": "25.0.0-alpha1",
65
+ "@vaadin/hilla-generator-utils": "25.0.0-alpha10",
66
+ "@vaadin/hilla-react-auth": "25.0.0-alpha10",
67
+ "@vaadin/hilla-react-signals": "25.0.0-alpha10",
68
68
  "tsc-template": "0.2.3",
69
- "typescript": "5.8.3"
69
+ "typescript": "5.9.3"
70
70
  }
71
71
  }
@@ -0,0 +1,131 @@
1
+ import type { ComponentType } from "react";
2
+ import { type RouteObject } from "react-router";
3
+ import type { AgnosticRoute, RouterBuildOptions, RouterConfiguration, ViewConfig } from "../../types.js";
4
+ import type { RouteLike, RouteTransformer } from "./utils.js";
5
+ /**
6
+ * A configuration builder for creating a Vaadin-specific router for React with
7
+ * authentication and server routes support.
8
+ *
9
+ * The configuration builder allows you to compose and modify route trees by
10
+ * chaining methods that add custom React routes, generated file-based routes,
11
+ * layout components, etc. Modifiers are accumulated and applied in order when
12
+ * building the final router configuration.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const { routes, router } = new RouteConfigurationBuilder()
17
+ * .withFileRoutes(fileRoutes)
18
+ * .withReactRoutes({ path: '/foo/baz', element: <FooBazPage /> })
19
+ * .withFallback(Flow)
20
+ * .protect('/login')
21
+ * .build();
22
+ * ```
23
+ */
24
+ export declare class RouterConfigurationBuilder {
25
+ #private;
26
+ /**
27
+ * Adds the given React routes to the current list of routes. All the routes
28
+ * are deeply merged to preserve the path uniqueness.
29
+ *
30
+ * @param routes - An array of React Router route objects to be merged into
31
+ * the current route list.
32
+ *
33
+ * @returns The current instance of the builder for method chaining.
34
+ */
35
+ withReactRoutes(routes: readonly RouteObject[]): this;
36
+ /**
37
+ * Adds the given file routes to the current list of routes. All the routes
38
+ * are transformed to React RouterObjects and deeply merged to preserve the
39
+ * path uniqueness.
40
+ *
41
+ * @param routes - An array of file-based route objects to be processed and
42
+ * merged into the current route list.
43
+ *
44
+ * @returns The current instance of the builder for method chaining.
45
+ */
46
+ withFileRoutes(routes: readonly AgnosticRoute[]): this;
47
+ /**
48
+ * Adds a fallback component for each branch of the current route tree.
49
+ *
50
+ * The fallback component is used when no other route matches the requested
51
+ * URL. In terms of Vaadin application, after no match on the client side, the
52
+ * turn goes to the server-side router.
53
+ *
54
+ * @remarks This method can be called only once. All the subsequent calls will
55
+ * be ignored.
56
+ *
57
+ * @remarks This method also runs the `withLayout` method with the given
58
+ * component to make sure server-side layout is applied to routes.
59
+ *
60
+ * @param component - The component to use as the fallback and layout
61
+ * component.
62
+ * @param config - Optional view configuration for the fallback component.
63
+ *
64
+ * @returns The current instance of the builder for method chaining.
65
+ */
66
+ withFallback(component: ComponentType, config?: ViewConfig): this;
67
+ withDeepWildcard(): this;
68
+ /**
69
+ * Adds the parent layout to all views with the `flowLayouts` flag set in the
70
+ * ViewConfiguration.
71
+ *
72
+ * @remarks This method can be called only once. All the subsequent calls will
73
+ * be ignored.
74
+ *
75
+ * @param component - The component to use as the layout for the routes.
76
+ * Usually, it is `Flow` component.
77
+ *
78
+ * @returns The current instance of the builder for method chaining.
79
+ */
80
+ withLayout(component: ComponentType): this;
81
+ withLayoutSkipping(): this;
82
+ /**
83
+ * Adds protection to the route, requiring authentication or authorization to
84
+ * access it.
85
+ *
86
+ * @param redirectPath - Optional path to redirect to when protection fails.
87
+ * If not provided, the default redirect page (`/login`) will be used.
88
+ *
89
+ * @returns The current instance of the builder for method chaining.
90
+ */
91
+ protect(redirectPath?: string): this;
92
+ /**
93
+ * Deeply updates the current route tree, merging the existing routes with the
94
+ * given routes using the provided transformer callback.
95
+ *
96
+ * @param routes - The routes used to update the current route tree.
97
+ * @param callback - A transformer function that defines how the routes should
98
+ * be modified. Required if `routes` are not provided.
99
+ *
100
+ * @returns This RouteConfigurationBuilder instance for method chaining
101
+ */
102
+ update(routes: undefined, callback: RouteTransformer): this;
103
+ /**
104
+ * Deeply updates the current route tree, merging the existing routes with the
105
+ * given routes using the provided transformer callback.
106
+ *
107
+ * @typeParam T - The type of routes being updated.
108
+ *
109
+ * @param routes - The routes used to update the current route tree.
110
+ * @param callback - A transformer function that defines how the routes should
111
+ * be modified. Required if `routes` are not provided.
112
+ *
113
+ * @returns This RouteConfigurationBuilder instance for method chaining
114
+ */
115
+ update<T extends RouteLike>(routes: readonly T[], callback?: RouteTransformer<T>): this;
116
+ /**
117
+ * Builds the router configuration by applying all registered modifiers to the
118
+ * routes.
119
+ *
120
+ * @remarks
121
+ * This method applies the the logic for layout skipping along with any other
122
+ * registered modifiers to transform the routes.
123
+ *
124
+ * @param options - Optional React `createBrowserRouter` options to configure
125
+ * the router.
126
+ *
127
+ * @returns A RouterConfiguration object containing the processed routes and
128
+ * configured browser router
129
+ */
130
+ build(options?: RouterBuildOptions): RouterConfiguration;
131
+ }
@@ -0,0 +1,162 @@
1
+ import { createBrowserRouter } from "react-router";
2
+ import createFallbackTransformer, { createFallbackRoutes } from "./createFallbackTransformer.js";
3
+ import createProtectTransformer from "./createProtectTransformer.js";
4
+ import fileRouteTransformer from "./fileRouteTransformer.js";
5
+ import mergeDeepWildcard from "./mergeDeepWildcard.js";
6
+ import mergeLayout from "./mergeLayout.js";
7
+ import { mergeRouteTrees } from "./mergeRouteTrees.js";
8
+ import mergeSkipLayouts from "./mergeSkipLayout.js";
9
+ /**
10
+ * A configuration builder for creating a Vaadin-specific router for React with
11
+ * authentication and server routes support.
12
+ *
13
+ * The configuration builder allows you to compose and modify route trees by
14
+ * chaining methods that add custom React routes, generated file-based routes,
15
+ * layout components, etc. Modifiers are accumulated and applied in order when
16
+ * building the final router configuration.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const { routes, router } = new RouteConfigurationBuilder()
21
+ * .withFileRoutes(fileRoutes)
22
+ * .withReactRoutes({ path: '/foo/baz', element: <FooBazPage /> })
23
+ * .withFallback(Flow)
24
+ * .protect('/login')
25
+ * .build();
26
+ * ```
27
+ */
28
+ export class RouterConfigurationBuilder {
29
+ #modifiers = [];
30
+ #isFallbackSet = false;
31
+ #isLayoutSet = false;
32
+ /**
33
+ * Adds the given React routes to the current list of routes. All the routes
34
+ * are deeply merged to preserve the path uniqueness.
35
+ *
36
+ * @param routes - An array of React Router route objects to be merged into
37
+ * the current route list.
38
+ *
39
+ * @returns The current instance of the builder for method chaining.
40
+ */
41
+ withReactRoutes(routes) {
42
+ this.update(routes);
43
+ return this;
44
+ }
45
+ /**
46
+ * Adds the given file routes to the current list of routes. All the routes
47
+ * are transformed to React RouterObjects and deeply merged to preserve the
48
+ * path uniqueness.
49
+ *
50
+ * @param routes - An array of file-based route objects to be processed and
51
+ * merged into the current route list.
52
+ *
53
+ * @returns The current instance of the builder for method chaining.
54
+ */
55
+ withFileRoutes(routes) {
56
+ this.update(routes, fileRouteTransformer);
57
+ return this;
58
+ }
59
+ /**
60
+ * Adds a fallback component for each branch of the current route tree.
61
+ *
62
+ * The fallback component is used when no other route matches the requested
63
+ * URL. In terms of Vaadin application, after no match on the client side, the
64
+ * turn goes to the server-side router.
65
+ *
66
+ * @remarks This method can be called only once. All the subsequent calls will
67
+ * be ignored.
68
+ *
69
+ * @remarks This method also runs the `withLayout` method with the given
70
+ * component to make sure server-side layout is applied to routes.
71
+ *
72
+ * @param component - The component to use as the fallback and layout
73
+ * component.
74
+ * @param config - Optional view configuration for the fallback component.
75
+ *
76
+ * @returns The current instance of the builder for method chaining.
77
+ */
78
+ withFallback(component, config) {
79
+ if (!this.#isFallbackSet) {
80
+ this.#isFallbackSet = true;
81
+ this.withLayout(component);
82
+ const fallbackRoutes = createFallbackRoutes(component, config);
83
+ this.update(
84
+ // Add the fallback routes to the end of the route tree.
85
+ fallbackRoutes,
86
+ // Add the fallback routes to each route tree branch via transformer.
87
+ createFallbackTransformer(fallbackRoutes)
88
+ );
89
+ }
90
+ return this;
91
+ }
92
+ withDeepWildcard() {
93
+ this.#modifiers.push((originalRoutes) => mergeDeepWildcard(originalRoutes));
94
+ return this;
95
+ }
96
+ /**
97
+ * Adds the parent layout to all views with the `flowLayouts` flag set in the
98
+ * ViewConfiguration.
99
+ *
100
+ * @remarks This method can be called only once. All the subsequent calls will
101
+ * be ignored.
102
+ *
103
+ * @param component - The component to use as the layout for the routes.
104
+ * Usually, it is `Flow` component.
105
+ *
106
+ * @returns The current instance of the builder for method chaining.
107
+ */
108
+ withLayout(component) {
109
+ if (!this.#isLayoutSet) {
110
+ this.#isLayoutSet = true;
111
+ this.#modifiers.push((originalRoutes) => mergeLayout(originalRoutes, component));
112
+ }
113
+ return this;
114
+ }
115
+ withLayoutSkipping() {
116
+ this.#modifiers.push((originalRoutes) => mergeSkipLayouts(originalRoutes));
117
+ return this;
118
+ }
119
+ /**
120
+ * Adds protection to the route, requiring authentication or authorization to
121
+ * access it.
122
+ *
123
+ * @param redirectPath - Optional path to redirect to when protection fails.
124
+ * If not provided, the default redirect page (`/login`) will be used.
125
+ *
126
+ * @returns The current instance of the builder for method chaining.
127
+ */
128
+ protect(redirectPath) {
129
+ this.update(undefined, createProtectTransformer(redirectPath));
130
+ return this;
131
+ }
132
+ update(routes, callback) {
133
+ this.#modifiers.push((originalRoutes) => mergeRouteTrees(originalRoutes, routes, callback));
134
+ return this;
135
+ }
136
+ /**
137
+ * Builds the router configuration by applying all registered modifiers to the
138
+ * routes.
139
+ *
140
+ * @remarks
141
+ * This method applies the the logic for layout skipping along with any other
142
+ * registered modifiers to transform the routes.
143
+ *
144
+ * @param options - Optional React `createBrowserRouter` options to configure
145
+ * the router.
146
+ *
147
+ * @returns A RouterConfiguration object containing the processed routes and
148
+ * configured browser router
149
+ */
150
+ build(options) {
151
+ this.withLayoutSkipping();
152
+ const routes = this.#modifiers.reduce((acc, mod) => mod(acc) ?? acc, undefined) ?? [];
153
+ return {
154
+ routes,
155
+ router: createBrowserRouter([...routes], {
156
+ basename: new URL(document.baseURI).pathname,
157
+ ...options
158
+ })
159
+ };
160
+ }
161
+ }
162
+ //# sourceMappingURL=./RouterConfigurationBuilder.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAEA,SAAS,yCAA4D;AAErE,OAAO,6BAA6B,4DAA6D;AACjG,OAAO,6DAA8D;AACrE,OAAO,qDAAsD;AAC7D,OAAO,+CAAgD;AACvD,OAAO,mCAAoC;AAC3C,SAAS,6CAA8C;AACvD,OAAO,4CAA6C;;;;;;;;;;;;;;;;;;;;AAsBpD,OAAO,MAAM,2BAA2B;CACtC,AAASA,aAAkC,CAAE;CAC7C,iBAAiB;CACjB,eAAe;;;;;;;;;;CAWf,gBAAgBC,QAAsC;AACpD,OAAK,OAAO,OAAO;AACnB,SAAO;CACR;;;;;;;;;;;CAYD,eAAeC,QAAwC;AACrD,OAAK,OAAO,QAAQ,qBAAqB;AACzC,SAAO;CACR;;;;;;;;;;;;;;;;;;;;CAqBD,aAAaC,WAA0BC,QAA2B;AAChE,OAAK,KAAKC,gBAAgB;AACxB,QAAKA,iBAAiB;AACtB,QAAK,WAAW,UAAU;GAE1B,MAAM,iBAAiB,qBAAqB,WAAW,OAAO;AAE9D,QAAK;;IAEH;;IAEA,0BAA0B,eAAe;CAC1C;EACF;AACD,SAAO;CACR;CAED,mBAAyB;AACvB,OAAKL,WAAW,KAAK,CAAC,mBAAmB,kBAAkB,eAAe,CAAC;AAC3E,SAAO;CACR;;;;;;;;;;;;;CAcD,WAAWG,WAAgC;AACzC,OAAK,KAAKG,cAAc;AACtB,QAAKA,eAAe;AACpB,QAAKN,WAAW,KAAK,CAAC,mBAAmB,YAAY,gBAAgB,UAAU,CAAC;EACjF;AACD,SAAO;CACR;CAED,qBAA2B;AACzB,OAAKA,WAAW,KAAK,CAAC,mBAAmB,iBAAiB,eAAe,CAAC;AAC1E,SAAO;CACR;;;;;;;;;;CAWD,QAAQO,cAA6B;AACnC,OAAK,OAAO,WAAW,yBAAyB,aAAa,CAAC;AAC9D,SAAO;CACR;CA2BD,OAA4BC,QAAkCC,UAAqC;AACjG,OAAKT,WAAW,KAAK,CAAC,mBAAmB,gBAAgB,gBAAgB,QAAQ,SAAS,CAAC;AAC3F,SAAO;CACR;;;;;;;;;;;;;;;CAgBD,MAAMU,SAAmD;AACvD,OAAK,oBAAoB;EACzB,MAAM,SACJ,KAAKV,WAAW,OAA2C,CAAC,KAAK,QAAQ,IAAI,IAAI,IAAI,KAAK,UAAU,IAAI,CAAE;AAE5G,SAAO;GACL;GACA,QAAQ,oBAAoB,CAAC,GAAG,MAAO,GAAE;IAAE,UAAU,IAAI,IAAI,SAAS,SAAS;IAAU,GAAG;GAAS,EAAC;EACvG;CACF;AACF","names":["#modifiers","routes: readonly RouteObject[]","routes: readonly AgnosticRoute[]","component: ComponentType","config?: ViewConfig","#isFallbackSet","#isLayoutSet","redirectPath?: string","routes: readonly T[] | undefined","callback: RouteTransformer<T>","options?: RouterBuildOptions"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/configuration-builder/RouterConfigurationBuilder.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type { ComponentType } from 'react';\nimport { createBrowserRouter, type RouteObject } from 'react-router';\nimport type { AgnosticRoute, RouterBuildOptions, RouterConfiguration, ViewConfig } from '../../types.js';\nimport createFallbackTransformer, { createFallbackRoutes } from './createFallbackTransformer.js';\nimport createProtectTransformer from './createProtectTransformer.js';\nimport fileRouteTransformer from './fileRouteTransformer.js';\nimport mergeDeepWildcard from './mergeDeepWildcard.js';\nimport mergeLayout from './mergeLayout.js';\nimport { mergeRouteTrees } from './mergeRouteTrees.js';\nimport mergeSkipLayouts from './mergeSkipLayout.js';\nimport type { RouteLike, RouteTreeModifier, RouteTransformer } from './utils.js';\n\n/**\n * A configuration builder for creating a Vaadin-specific router for React with\n * authentication and server routes support.\n *\n * The configuration builder allows you to compose and modify route trees by\n * chaining methods that add custom React routes, generated file-based routes,\n * layout components, etc. Modifiers are accumulated and applied in order when\n * building the final router configuration.\n *\n * @example\n * ```typescript\n * const { routes, router } = new RouteConfigurationBuilder()\n * .withFileRoutes(fileRoutes)\n * .withReactRoutes({ path: '/foo/baz', element: <FooBazPage /> })\n * .withFallback(Flow)\n * .protect('/login')\n * .build();\n * ```\n */\nexport class RouterConfigurationBuilder {\n readonly #modifiers: RouteTreeModifier[] = [];\n #isFallbackSet = false;\n #isLayoutSet = false;\n\n /**\n * Adds the given React routes to the current list of routes. All the routes\n * are deeply merged to preserve the path uniqueness.\n *\n * @param routes - An array of React Router route objects to be merged into\n * the current route list.\n *\n * @returns The current instance of the builder for method chaining.\n */\n withReactRoutes(routes: readonly RouteObject[]): this {\n this.update(routes);\n return this;\n }\n\n /**\n * Adds the given file routes to the current list of routes. All the routes\n * are transformed to React RouterObjects and deeply merged to preserve the\n * path uniqueness.\n *\n * @param routes - An array of file-based route objects to be processed and\n * merged into the current route list.\n *\n * @returns The current instance of the builder for method chaining.\n */\n withFileRoutes(routes: readonly AgnosticRoute[]): this {\n this.update(routes, fileRouteTransformer);\n return this;\n }\n\n /**\n * Adds a fallback component for each branch of the current route tree.\n *\n * The fallback component is used when no other route matches the requested\n * URL. In terms of Vaadin application, after no match on the client side, the\n * turn goes to the server-side router.\n *\n * @remarks This method can be called only once. All the subsequent calls will\n * be ignored.\n *\n * @remarks This method also runs the `withLayout` method with the given\n * component to make sure server-side layout is applied to routes.\n *\n * @param component - The component to use as the fallback and layout\n * component.\n * @param config - Optional view configuration for the fallback component.\n *\n * @returns The current instance of the builder for method chaining.\n */\n withFallback(component: ComponentType, config?: ViewConfig): this {\n if (!this.#isFallbackSet) {\n this.#isFallbackSet = true;\n this.withLayout(component);\n\n const fallbackRoutes = createFallbackRoutes(component, config);\n\n this.update(\n // Add the fallback routes to the end of the route tree.\n fallbackRoutes,\n // Add the fallback routes to each route tree branch via transformer.\n createFallbackTransformer(fallbackRoutes),\n );\n }\n return this;\n }\n\n withDeepWildcard(): this {\n this.#modifiers.push((originalRoutes) => mergeDeepWildcard(originalRoutes));\n return this;\n }\n\n /**\n * Adds the parent layout to all views with the `flowLayouts` flag set in the\n * ViewConfiguration.\n *\n * @remarks This method can be called only once. All the subsequent calls will\n * be ignored.\n *\n * @param component - The component to use as the layout for the routes.\n * Usually, it is `Flow` component.\n *\n * @returns The current instance of the builder for method chaining.\n */\n withLayout(component: ComponentType): this {\n if (!this.#isLayoutSet) {\n this.#isLayoutSet = true;\n this.#modifiers.push((originalRoutes) => mergeLayout(originalRoutes, component));\n }\n return this;\n }\n\n withLayoutSkipping(): this {\n this.#modifiers.push((originalRoutes) => mergeSkipLayouts(originalRoutes));\n return this;\n }\n\n /**\n * Adds protection to the route, requiring authentication or authorization to\n * access it.\n *\n * @param redirectPath - Optional path to redirect to when protection fails.\n * If not provided, the default redirect page (`/login`) will be used.\n *\n * @returns The current instance of the builder for method chaining.\n */\n protect(redirectPath?: string): this {\n this.update(undefined, createProtectTransformer(redirectPath));\n return this;\n }\n\n /**\n * Deeply updates the current route tree, merging the existing routes with the\n * given routes using the provided transformer callback.\n *\n * @param routes - The routes used to update the current route tree.\n * @param callback - A transformer function that defines how the routes should\n * be modified. Required if `routes` are not provided.\n *\n * @returns This RouteConfigurationBuilder instance for method chaining\n */\n update(routes: undefined, callback: RouteTransformer): this;\n\n /**\n * Deeply updates the current route tree, merging the existing routes with the\n * given routes using the provided transformer callback.\n *\n * @typeParam T - The type of routes being updated.\n *\n * @param routes - The routes used to update the current route tree.\n * @param callback - A transformer function that defines how the routes should\n * be modified. Required if `routes` are not provided.\n *\n * @returns This RouteConfigurationBuilder instance for method chaining\n */\n update<T extends RouteLike>(routes: readonly T[], callback?: RouteTransformer<T>): this;\n update<T extends RouteLike>(routes: readonly T[] | undefined, callback: RouteTransformer<T>): this {\n this.#modifiers.push((originalRoutes) => mergeRouteTrees(originalRoutes, routes, callback));\n return this;\n }\n\n /**\n * Builds the router configuration by applying all registered modifiers to the\n * routes.\n *\n * @remarks\n * This method applies the the logic for layout skipping along with any other\n * registered modifiers to transform the routes.\n *\n * @param options - Optional React `createBrowserRouter` options to configure\n * the router.\n *\n * @returns A RouterConfiguration object containing the processed routes and\n * configured browser router\n */\n build(options?: RouterBuildOptions): RouterConfiguration {\n this.withLayoutSkipping();\n const routes =\n this.#modifiers.reduce<readonly RouteObject[] | undefined>((acc, mod) => mod(acc) ?? acc, undefined) ?? [];\n\n return {\n routes,\n router: createBrowserRouter([...routes], { basename: new URL(document.baseURI).pathname, ...options }),\n };\n }\n}\n"],"version":3}
@@ -0,0 +1,44 @@
1
+ import { type ComponentType } from "react";
2
+ import type { RouteObject } from "react-router";
3
+ import type { ViewConfig } from "../../types.js";
4
+ import { type RouteTransformer } from "./utils.js";
5
+ /**
6
+ * A tuple of fallback routes:
7
+ * - A wildcard route (`path: '*'`) that renders the component for any unmatched
8
+ * path.
9
+ * - An index route (`index: true`) that renders the component for the empty
10
+ * path.
11
+ */
12
+ export type FallbackRoutes = readonly [notFoundFallback: RouteObject, indexFallback: RouteObject];
13
+ /**
14
+ * Creates fallback routes for handling unmatched paths and index routes.
15
+ *
16
+ * @param component - The React component to render for the fallback routes
17
+ * @param config - Optional view configuration to attach to the route handles
18
+ *
19
+ * @returns A tuple of fallback routes.
20
+ */
21
+ export declare function createFallbackRoutes(component: ComponentType, config?: ViewConfig): FallbackRoutes;
22
+ /**
23
+ * Creates a route transformer that adds fallback routes to handle unmatched
24
+ * paths.
25
+ *
26
+ * This transformer adds two types of fallback routes:
27
+ * - A wildcard route (`path: '*'`) that renders the specified fallback
28
+ * component for any unmatched path.
29
+ * - An index fallback route (`index: true`) that renders the fallback component
30
+ * for the empty path.
31
+ *
32
+ * The transformer logic determines which fallback to add based on the existing
33
+ * child routes:
34
+ * - If a wildcard child route already defined, only the index fallback is
35
+ * added.
36
+ * - If an index or optional child route exists, only the wildcard fallback is
37
+ * added.
38
+ * - Otherwise, both fallback routes are added.
39
+ *
40
+ * @param component - The React component to render as the fallback.
41
+ * @param config - A view configuration of the fallback route if any.
42
+ * @returns A route transformer function.
43
+ */
44
+ export default function createFallbackTransformer([notFoundFallback, indexFallback]: FallbackRoutes): RouteTransformer;
@@ -0,0 +1,66 @@
1
+ import { createElement } from "react";
2
+ import { getHandleFlag, isIndexRoute, isOptionalRoute, isWildcardRoute, RouteHandleFlag } from "./utils.js";
3
+ /**
4
+ * Creates fallback routes for handling unmatched paths and index routes.
5
+ *
6
+ * @param component - The React component to render for the fallback routes
7
+ * @param config - Optional view configuration to attach to the route handles
8
+ *
9
+ * @returns A tuple of fallback routes.
10
+ */
11
+ export function createFallbackRoutes(component, config) {
12
+ return [{
13
+ path: "*",
14
+ element: createElement(component),
15
+ handle: config
16
+ }, {
17
+ index: true,
18
+ element: createElement(component),
19
+ handle: config
20
+ }];
21
+ }
22
+ /**
23
+ * Creates a route transformer that adds fallback routes to handle unmatched
24
+ * paths.
25
+ *
26
+ * This transformer adds two types of fallback routes:
27
+ * - A wildcard route (`path: '*'`) that renders the specified fallback
28
+ * component for any unmatched path.
29
+ * - An index fallback route (`index: true`) that renders the fallback component
30
+ * for the empty path.
31
+ *
32
+ * The transformer logic determines which fallback to add based on the existing
33
+ * child routes:
34
+ * - If a wildcard child route already defined, only the index fallback is
35
+ * added.
36
+ * - If an index or optional child route exists, only the wildcard fallback is
37
+ * added.
38
+ * - Otherwise, both fallback routes are added.
39
+ *
40
+ * @param component - The React component to render as the fallback.
41
+ * @param config - A view configuration of the fallback route if any.
42
+ * @returns A route transformer function.
43
+ */
44
+ export default function createFallbackTransformer([notFoundFallback, indexFallback]) {
45
+ return ({ original, override, children, dupe }) => {
46
+ if (original && !getHandleFlag(original, RouteHandleFlag.IGNORE_FALLBACK) && !dupe) {
47
+ if (!children) {
48
+ return original;
49
+ }
50
+ let fallback;
51
+ if (children.some((route) => isWildcardRoute(route))) {
52
+ fallback = [indexFallback];
53
+ } else if (children.some((route) => isIndexRoute(route) || isOptionalRoute(route))) {
54
+ fallback = [notFoundFallback];
55
+ } else {
56
+ fallback = [notFoundFallback, indexFallback];
57
+ }
58
+ return {
59
+ ...original,
60
+ children: [...children, ...fallback]
61
+ };
62
+ }
63
+ return override;
64
+ };
65
+ }
66
+ //# sourceMappingURL=./createFallbackTransformer.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA,SAA6B,4BAA6B;AAG1D,SACE,eACA,cACA,iBACA,iBACA,mCAEkB;;;;;;;;;AAmBpB,OAAO,SAAS,qBAAqBA,WAA0BC,QAAqC;AAClG,QAAO,CACL;EAAE,MAAM;EAAK,SAAS,cAAc,UAAU;EAAE,QAAQ;CAAQ,GAChE;EAAE,OAAO;EAAM,SAAS,cAAc,UAAU;EAAE,QAAQ;CAAQ,CACnE;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBD,eAAe,SAAS,0BAA0B,CAAC,kBAAkB,cAA8B,EAAoB;AACrH,QAAO,CAAC,EAAE,UAAU,UAAU,UAAU,MAAM,KAAK;AACjD,MAAI,aAAa,cAAc,UAAU,gBAAgB,gBAAgB,KAAK,MAAM;AAClF,QAAK,UAAU;AACb,WAAO;GACR;GAED,IAAIC;AAEJ,OAAI,SAAS,KAAK,CAAC,UAAU,gBAAgB,MAAM,CAAC,EAAE;AACpD,eAAW,CAAC,aAAc;GAC3B,WAAU,SAAS,KAAK,CAAC,UAAU,aAAa,MAAM,IAAI,gBAAgB,MAAM,CAAC,EAAE;AAClF,eAAW,CAAC,gBAAiB;GAC9B,OAAM;AACL,eAAW,CAAC,kBAAkB,aAAc;GAC7C;AAGD,UAAO;IACL,GAAG;IACH,UAAU,CAAC,GAAG,UAAU,GAAG,QAAS;GACrC;EACF;AAED,SAAO;CACR;AACF","names":["component: ComponentType","config?: ViewConfig","fallback: RouteObject[]"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/configuration-builder/createFallbackTransformer.ts"],"sourcesContent":["import { type ComponentType, createElement } from 'react';\nimport type { RouteObject, NonIndexRouteObject } from 'react-router';\nimport type { ViewConfig } from '../../types.js';\nimport {\n getHandleFlag,\n isIndexRoute,\n isOptionalRoute,\n isWildcardRoute,\n RouteHandleFlag,\n type RouteTransformer,\n} from './utils.js';\n\n/**\n * A tuple of fallback routes:\n * - A wildcard route (`path: '*'`) that renders the component for any unmatched\n * path.\n * - An index route (`index: true`) that renders the component for the empty\n * path.\n */\nexport type FallbackRoutes = readonly [notFoundFallback: RouteObject, indexFallback: RouteObject];\n\n/**\n * Creates fallback routes for handling unmatched paths and index routes.\n *\n * @param component - The React component to render for the fallback routes\n * @param config - Optional view configuration to attach to the route handles\n *\n * @returns A tuple of fallback routes.\n */\nexport function createFallbackRoutes(component: ComponentType, config?: ViewConfig): FallbackRoutes {\n return [\n { path: '*', element: createElement(component), handle: config },\n { index: true, element: createElement(component), handle: config },\n ];\n}\n\n/**\n * Creates a route transformer that adds fallback routes to handle unmatched\n * paths.\n *\n * This transformer adds two types of fallback routes:\n * - A wildcard route (`path: '*'`) that renders the specified fallback\n * component for any unmatched path.\n * - An index fallback route (`index: true`) that renders the fallback component\n * for the empty path.\n *\n * The transformer logic determines which fallback to add based on the existing\n * child routes:\n * - If a wildcard child route already defined, only the index fallback is\n * added.\n * - If an index or optional child route exists, only the wildcard fallback is\n * added.\n * - Otherwise, both fallback routes are added.\n *\n * @param component - The React component to render as the fallback.\n * @param config - A view configuration of the fallback route if any.\n * @returns A route transformer function.\n */\nexport default function createFallbackTransformer([notFoundFallback, indexFallback]: FallbackRoutes): RouteTransformer {\n return ({ original, override, children, dupe }) => {\n if (original && !getHandleFlag(original, RouteHandleFlag.IGNORE_FALLBACK) && !dupe) {\n if (!children) {\n return original; //: IndexRouteObject;\n }\n\n let fallback: RouteObject[];\n\n if (children.some((route) => isWildcardRoute(route))) {\n fallback = [indexFallback];\n } else if (children.some((route) => isIndexRoute(route) || isOptionalRoute(route))) {\n fallback = [notFoundFallback];\n } else {\n fallback = [notFoundFallback, indexFallback];\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return {\n ...original,\n children: [...children, ...fallback],\n } as NonIndexRouteObject;\n }\n\n return override as RouteObject | undefined;\n };\n}\n"],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { RouteTransformer } from "./utils.js";
2
+ /**
3
+ * Creates a route transformer that applies route protection to a given route,
4
+ * optionally redirecting unauthorized access to a specified path.
5
+ *
6
+ * @param redirectPath - Optional path to redirect unauthorized users to.
7
+ * Defaults to '/login'.
8
+ *
9
+ * @returns A route transformer function that applies protection to the route.
10
+ */
11
+ export default function createProtectTransformer(redirectPath?: string): RouteTransformer;
@@ -0,0 +1,21 @@
1
+ import { protectRoute } from "@vaadin/hilla-react-auth";
2
+ /**
3
+ * Creates a route transformer that applies route protection to a given route,
4
+ * optionally redirecting unauthorized access to a specified path.
5
+ *
6
+ * @param redirectPath - Optional path to redirect unauthorized users to.
7
+ * Defaults to '/login'.
8
+ *
9
+ * @returns A route transformer function that applies protection to the route.
10
+ */
11
+ export default function createProtectTransformer(redirectPath) {
12
+ return ({ original, children }) => {
13
+ if (!original) {
14
+ return original;
15
+ }
16
+ const finalRoute = protectRoute(original, redirectPath);
17
+ finalRoute.children = children;
18
+ return finalRoute;
19
+ };
20
+ }
21
+ //# sourceMappingURL=./createProtectTransformer.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA,SAAS,8CAA+C;;;;;;;;;;AAaxD,eAAe,SAAS,yBAAyBA,cAAyC;AACxF,QAAO,CAAC,EAAE,UAAU,UAAU,KAAK;AACjC,OAAK,UAAU;AACb,UAAO;EACR;EAED,MAAM,aAAa,aAAa,UAAU,aAAa;AACvD,aAAW,WAAW;AACtB,SAAO;CACR;AACF","names":["redirectPath?: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/configuration-builder/createProtectTransformer.ts"],"sourcesContent":["import { protectRoute } from '@vaadin/hilla-react-auth';\nimport type { RouteObject } from 'react-router';\nimport type { RouteTransformer } from './utils.js';\n\n/**\n * Creates a route transformer that applies route protection to a given route,\n * optionally redirecting unauthorized access to a specified path.\n *\n * @param redirectPath - Optional path to redirect unauthorized users to.\n * Defaults to '/login'.\n *\n * @returns A route transformer function that applies protection to the route.\n */\nexport default function createProtectTransformer(redirectPath?: string): RouteTransformer {\n return ({ original, children }) => {\n if (!original) {\n return original;\n }\n\n const finalRoute = protectRoute(original, redirectPath);\n finalRoute.children = children as RouteObject[] | undefined;\n return finalRoute;\n };\n}\n"],"version":3}
@@ -0,0 +1,17 @@
1
+ import type { RouteObject } from "react-router";
2
+ import type { AgnosticRoute } from "../../types.js";
3
+ import { type RouteTransformerOptions } from "./utils.js";
4
+ /**
5
+ * Transforms a framework-agnostic route into a route object compatible with
6
+ * React Router and merges it with the existing route object if any.
7
+ *
8
+ * @param options - The route transformer options containing the existing route,
9
+ * any overrides, and child routes.
10
+ *
11
+ * @returns A `RouteObject` representing the transformed route, or the original
12
+ * route if no override is provided.
13
+ *
14
+ * @throws If the provided module does not export a React component by default
15
+ * nor a ViewConfig object as "config".
16
+ */
17
+ export default function fileRouteTransformer({ original, override, children }: RouteTransformerOptions<AgnosticRoute>): RouteObject | undefined;
@@ -0,0 +1,47 @@
1
+ import { createElement } from "react";
2
+ import { convertComponentNameToTitle } from "../../shared/convertComponentNameToTitle.js";
3
+ import { isReactRouteModule } from "./utils.js";
4
+ /**
5
+ * Transforms a framework-agnostic route into a route object compatible with
6
+ * React Router and merges it with the existing route object if any.
7
+ *
8
+ * @param options - The route transformer options containing the existing route,
9
+ * any overrides, and child routes.
10
+ *
11
+ * @returns A `RouteObject` representing the transformed route, or the original
12
+ * route if no override is provided.
13
+ *
14
+ * @throws If the provided module does not export a React component by default
15
+ * nor a ViewConfig object as "config".
16
+ */
17
+ export default function fileRouteTransformer({ original, override, children }) {
18
+ if (!override) {
19
+ return original;
20
+ }
21
+ const { module, component = module?.default, config = module?.config, path, flowLayout } = override;
22
+ if (module && !isReactRouteModule(module)) {
23
+ throw new Error(`The module for the "${path}" section doesn't have the React component exported by default or a ViewConfig object exported as "config"`);
24
+ }
25
+ const element = component ? createElement(component) : undefined;
26
+ const handle = {
27
+ ...config,
28
+ title: config?.title ?? convertComponentNameToTitle(component),
29
+ flowLayout: config?.flowLayout ?? flowLayout
30
+ };
31
+ if (path === "" && !children) {
32
+ return {
33
+ ...original,
34
+ element,
35
+ handle,
36
+ index: true
37
+ };
38
+ }
39
+ return {
40
+ ...original,
41
+ path: config?.route ?? path,
42
+ element,
43
+ children,
44
+ handle
45
+ };
46
+ }
47
+ //# sourceMappingURL=./fileRouteTransformer.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA,SAAS,4BAA6B;AAEtC,SAAS,gFAAiF;AAE1F,SAAS,sCAAqE;;;;;;;;;;;;;;AAe9E,eAAe,SAAS,qBAAqB,EAC3C,UACA,UACA,UACuC,EAA2B;AAClE,MAAK,UAAU;AACb,SAAO;CACR;CAED,MAAM,EAAE,QAAQ,YAAY,QAAQ,SAAS,SAAS,QAAQ,QAAQ,MAAM,YAAY,GAAG;AAE3F,KAAI,WAAW,mBAAmB,OAAO,EAAE;AACzC,QAAM,IAAI,OACP,sBAAsB,KAAK;CAE/B;CAED,MAAM,UAAU,YAAY,cAAc,UAAU,GAAG;CACvD,MAAM,SAAS;EACb,GAAG;EACH,OAAO,QAAQ,SAAS,4BAA4B,UAAU;EAC9D,YAAY,QAAQ,cAAc;CACnC;AAED,KAAI,SAAS,OAAO,UAAU;AAC5B,SAAO;GACL,GAAI;GACJ;GACA;GACA,OAAO;EACR;CACF;AAED,QAAO;EACL,GAAI;EACJ,MAAM,QAAQ,SAAS;EACvB;EACU;EACV;CACD;AACF","names":[],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/configuration-builder/fileRouteTransformer.ts"],"sourcesContent":["import { createElement } from 'react';\nimport type { IndexRouteObject, NonIndexRouteObject, RouteObject } from 'react-router';\nimport { convertComponentNameToTitle } from '../../shared/convertComponentNameToTitle.js';\nimport type { AgnosticRoute } from '../../types.js';\nimport { isReactRouteModule, type RouteTransformerOptions } from './utils.js';\n\n/**\n * Transforms a framework-agnostic route into a route object compatible with\n * React Router and merges it with the existing route object if any.\n *\n * @param options - The route transformer options containing the existing route,\n * any overrides, and child routes.\n *\n * @returns A `RouteObject` representing the transformed route, or the original\n * route if no override is provided.\n *\n * @throws If the provided module does not export a React component by default\n * nor a ViewConfig object as \"config\".\n */\nexport default function fileRouteTransformer({\n original,\n override,\n children,\n}: RouteTransformerOptions<AgnosticRoute>): RouteObject | undefined {\n if (!override) {\n return original;\n }\n\n const { module, component = module?.default, config = module?.config, path, flowLayout } = override;\n\n if (module && !isReactRouteModule(module)) {\n throw new Error(\n `The module for the \"${path}\" section doesn't have the React component exported by default or a ViewConfig object exported as \"config\"`,\n );\n }\n\n const element = component ? createElement(component) : undefined;\n const handle = {\n ...config,\n title: config?.title ?? convertComponentNameToTitle(component),\n flowLayout: config?.flowLayout ?? flowLayout,\n };\n\n if (path === '' && !children) {\n return {\n ...(original as IndexRouteObject),\n element,\n handle,\n index: true,\n } satisfies IndexRouteObject;\n }\n\n return {\n ...(original as NonIndexRouteObject),\n path: config?.route ?? path,\n element,\n children: children as RouteObject[] | undefined,\n handle,\n } satisfies NonIndexRouteObject;\n}\n"],"version":3}
@@ -0,0 +1,2 @@
1
+ import type { RouteObject } from "react-router";
2
+ export default function mergeDeepWildcard(originalRoutes: readonly RouteObject[] | undefined): readonly RouteObject[] | undefined;
@@ -0,0 +1,17 @@
1
+ import { transformTree } from "../../shared/transformTree.js";
2
+ import { isWildcardRoute } from "./utils.js";
3
+ export default function mergeDeepWildcard(originalRoutes) {
4
+ if (!originalRoutes) {
5
+ return originalRoutes;
6
+ }
7
+ return transformTree(originalRoutes, null, (routes, next) => routes.reduce((acc, route, _, arr) => {
8
+ const wildcard = arr.find(isWildcardRoute);
9
+ const children = route.children ? next(wildcard && route.children.every((r) => !isWildcardRoute(r)) ? [...route.children, wildcard] : route.children) : undefined;
10
+ acc.push({
11
+ ...route,
12
+ children
13
+ });
14
+ return acc;
15
+ }, []));
16
+ }
17
+ //# sourceMappingURL=./mergeDeepWildcard.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AACA,SAAS,oDAAqD;AAC9D,SAAS,mCAAoC;AAE7C,eAAe,SAAS,kBACtBA,gBACoC;AACpC,MAAK,gBAAgB;AACnB,SAAO;CACR;AAED,QAAO,cAA8D,gBAAgB,MAAM,CAAC,QAAQ,SAClG,OAAO,OAAsB,CAAC,KAAK,OAAO,GAAG,QAAQ;EACnD,MAAM,WAAW,IAAI,KAAK,gBAAgB;EAC1C,MAAM,WAAW,MAAM,WACnB,KACE,YAAY,MAAM,SAAS,MAAM,CAAC,OAAO,gBAAgB,EAAE,CAAC,GACxD,CAAC,GAAG,MAAM,UAAU,QAAS,IAC7B,MAAM,SACX,GACD;AAEJ,MAAI,KAAK;GACP,GAAG;GACH;EACD,EAAgB;AAEjB,SAAO;CACR,GAAE,CAAE,EAAC,CACP;AACF","names":["originalRoutes: readonly RouteObject[] | undefined"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/configuration-builder/mergeDeepWildcard.ts"],"sourcesContent":["import type { RouteObject } from 'react-router';\nimport { transformTree } from '../../shared/transformTree.js';\nimport { isWildcardRoute } from './utils.js';\n\nexport default function mergeDeepWildcard(\n originalRoutes: readonly RouteObject[] | undefined,\n): readonly RouteObject[] | undefined {\n if (!originalRoutes) {\n return originalRoutes;\n }\n\n return transformTree<readonly RouteObject[], readonly RouteObject[]>(originalRoutes, null, (routes, next) =>\n routes.reduce<RouteObject[]>((acc, route, _, arr) => {\n const wildcard = arr.find(isWildcardRoute);\n const children = route.children\n ? next(\n wildcard && route.children.every((r) => !isWildcardRoute(r))\n ? [...route.children, wildcard]\n : route.children,\n )\n : undefined;\n\n acc.push({\n ...route,\n children,\n } as RouteObject);\n\n return acc;\n }, []),\n );\n}\n"],"version":3}
@@ -0,0 +1,24 @@
1
+ import { type ComponentType } from "react";
2
+ import type { RouteObject } from "react-router";
3
+ /**
4
+ * Splits out the server-side route tree based on the {@link ViewConfiguration.flowLayout}
5
+ * flag, and wraps them in the provided server layout component.
6
+ *
7
+ * @remarks
8
+ * Internally, routes are categorized into three groups:
9
+ * - **Server routes**: Routes with `flowLayout` flag explicitly set to `true`,
10
+ * or routes whose children have the flag enabled.
11
+ * - **Client routes**: Routes with `flowLayout` flag explicitly set to `false`,
12
+ * or routes with client-side children.
13
+ * - **Unknown routes**: Routes without explicit flags that inherit behavior
14
+ * from their parent context.
15
+ *
16
+ * Server routes get the {@link RouteHandleFlag.IGNORE_FALLBACK} flag set to
17
+ * prevent fallback route interference. Client routes are preserved as-is.
18
+ *
19
+ * @param originalRoutes - The current route tree to process.
20
+ * @param component - The layout component to wrap around server routes.
21
+ *
22
+ * @returns A new route configuration with the layout applied to server routes.
23
+ */
24
+ export default function mergeLayout(originalRoutes: readonly RouteObject[] | undefined, component: ComponentType): readonly RouteObject[] | undefined;