@vaadin/hilla-file-router 24.6.0 → 24.7.0-alpha3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-file-router",
3
- "version": "24.6.0",
3
+ "version": "24.7.0-alpha3",
4
4
  "description": "Hilla file-based router",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -59,33 +59,35 @@
59
59
  "peerDependencies": {
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
- "react-router-dom": "^6.28.0"
62
+ "react-router": "^7"
63
63
  },
64
64
  "devDependencies": {
65
- "@esm-bundle/chai": "^4.3.4-fix.0",
66
65
  "@types/chai-as-promised": "^7.1.8",
67
- "@types/chai-fs": "^2.0.4",
66
+ "@types/chai-fs": "^2.0.5",
68
67
  "@types/chai-like": "^1.1.3",
69
- "@types/deep-equal-in-any-order": "^1.0.3",
70
- "@types/mocha": "^10.0.6",
71
- "@types/sinon": "^10.0.17",
68
+ "@types/deep-equal-in-any-order": "^1.0.4",
69
+ "@types/mocha": "^10.0.10",
70
+ "@types/sinon": "^10.0.20",
72
71
  "@types/sinon-chai": "^3.2.12",
73
- "chai-as-promised": "^7.1.1",
72
+ "chai": "^5.1.2",
73
+ "chai-as-promised": "^7.1.2",
74
74
  "chai-deep-equal-ignore-undefined": "^1.1.1",
75
75
  "chai-fs": "^2.0.0",
76
- "chai-like": "^1.1.1",
76
+ "chai-like": "^1.1.3",
77
77
  "deep-equal-in-any-order": "^2.0.6",
78
- "mocha": "^10.2.0",
79
- "sinon": "^16.0.0",
78
+ "mocha": "^10.8.2",
79
+ "sinon": "^16.1.3",
80
80
  "sinon-chai": "^3.7.0",
81
- "type-fest": "^4.9.0"
81
+ "type-fest": "^4.30.2"
82
82
  },
83
83
  "dependencies": {
84
- "@vaadin/hilla-generator-utils": "24.6.0",
85
- "@vaadin/hilla-react-auth": "24.6.0",
86
- "@vaadin/hilla-react-signals": "24.6.0",
84
+ "@types/chai": "^5.0.1",
85
+ "@vaadin/hilla-generator-utils": "24.7.0-alpha3",
86
+ "@vaadin/hilla-react-auth": "24.7.0-alpha3",
87
+ "@vaadin/hilla-react-signals": "24.7.0-alpha3",
88
+ "c8": "^10.1.3",
87
89
  "react": "^18.2.0",
88
- "rollup": "^4.12.0",
89
- "typescript": "5.6.2"
90
+ "rollup": "^4.21.0",
91
+ "typescript": "5.7.2"
90
92
  }
91
93
  }
@@ -1,5 +1,5 @@
1
1
  import { type ComponentType } from 'react';
2
- import { type RouteObject } from 'react-router-dom';
2
+ import { type RouteObject } from 'react-router';
3
3
  import type { AgnosticRoute, RouterBuildOptions, RouterConfiguration, ViewConfig } from '../types.js';
4
4
  interface RouteBase {
5
5
  path?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"RouterConfigurationBuilder.d.ts","sourceRoot":"","sources":["../src/runtime/RouterConfigurationBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACV,aAAa,EAGb,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;CAC5B;AAaD,MAAM,MAAM,SAAS,GAAG,SAAS,WAAW,EAAE,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,WAAW,EAAE,CAAC;AAE9C,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,QAAQ,CAAC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,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IAAI;IAuHvF;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,mBAAmB;CAsFzD"}
@@ -1,8 +1,6 @@
1
1
  import { protectRoute } from "@vaadin/hilla-react-auth";
2
2
  import { createElement } from "react";
3
- import {
4
- createBrowserRouter
5
- } from "react-router-dom";
3
+ import { createBrowserRouter } from "react-router";
6
4
  import { convertComponentNameToTitle } from "../shared/convertComponentNameToTitle.js";
7
5
  import { transformTree } from "../shared/transformTree.js";
8
6
  function isReactRouteModule(module) {
@@ -289,22 +287,7 @@ class RouterConfigurationBuilder {
289
287
  const routes = this.#modifiers.reduce((acc, mod) => mod(acc) ?? acc, void 0) ?? [];
290
288
  return {
291
289
  routes,
292
- router: createBrowserRouter([...routes], {
293
- basename: new URL(document.baseURI).pathname,
294
- future: {
295
- // eslint-disable-next-line camelcase
296
- v7_fetcherPersist: true,
297
- // eslint-disable-next-line camelcase
298
- v7_normalizeFormMethod: true,
299
- // eslint-disable-next-line camelcase
300
- v7_partialHydration: true,
301
- // eslint-disable-next-line camelcase
302
- v7_relativeSplatPath: true,
303
- // eslint-disable-next-line camelcase
304
- v7_skipActionErrorRevalidation: true
305
- },
306
- ...options
307
- })
290
+ router: createBrowserRouter([...routes], { basename: new URL(document.baseURI).pathname, ...options })
308
291
  };
309
292
  }
310
293
  #withLayoutSkipping() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/runtime/RouterConfigurationBuilder.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/consistent-type-assertions */\nimport { protectRoute } from '@vaadin/hilla-react-auth';\nimport { type ComponentType, createElement } from 'react';\nimport {\n createBrowserRouter,\n type IndexRouteObject,\n type NonIndexRouteObject,\n type RouteObject,\n} from 'react-router-dom';\nimport { convertComponentNameToTitle } from '../shared/convertComponentNameToTitle.js';\nimport { transformTree } from '../shared/transformTree.js';\nimport type {\n AgnosticRoute,\n Module,\n RouteModule,\n RouterBuildOptions,\n RouterConfiguration,\n ViewConfig,\n} from '../types.js';\n\ninterface RouteBase {\n path?: string;\n children?: readonly this[];\n}\n\nfunction isReactRouteModule(module?: Module): module is RouteModule<ComponentType> | undefined {\n if (!module) {\n return true;\n }\n\n return (\n ('default' in module && typeof module.default === 'function') ||\n ('config' in module && typeof module.config === 'object')\n );\n}\n\nexport type RouteList = readonly RouteObject[];\nexport type WritableRouteList = RouteObject[];\n\nexport type RouteTransformerOptions<T> = Readonly<{\n children?: RouteList;\n original?: RouteObject;\n overriding?: T;\n dupe: boolean;\n}>;\n\nexport type RouteTransformer<T> = (opts: RouteTransformerOptions<T>) => RouteObject | undefined;\n\ntype RoutesModifier = (routes: RouteList | undefined) => RouteList | undefined;\n\nfunction createRouteKey<T extends RouteBase>(route: T): string {\n return `${route.path ?? ''}-${route.children ? 'n' : 'i'}`;\n}\n\nenum RouteHandleFlags {\n FLOW_LAYOUT = 'flowLayout',\n IGNORE_FALLBACK = 'ignoreFallback',\n SKIP_LAYOUTS = 'skipLayouts',\n}\n\nfunction getRouteHandleFlag<T extends RouteHandleFlags>(route: RouteObject, flag: T): boolean | undefined {\n if (typeof route.handle === 'object' && flag in route.handle) {\n return (route.handle as Record<T, boolean>)[flag];\n }\n\n return undefined;\n}\n\n/**\n * A builder for creating a Vaadin-specific router for React with\n * authentication and server routes support.\n */\nexport class RouterConfigurationBuilder {\n readonly #modifiers: RoutesModifier[] = [];\n\n /**\n * Adds the given routes to the current list of routes. All the routes are\n * deeply merged to preserve the path uniqueness.\n *\n * @param routes - A list of routes to add to the current list.\n */\n withReactRoutes(routes: RouteList): this {\n return this.update(routes);\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 - A list of routes to add to the current list.\n */\n withFileRoutes(routes: readonly AgnosticRoute[]): this {\n return this.update(routes, ({ original, overriding: added, children }) => {\n if (added) {\n const { module, path, flowLayout } = added;\n if (!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 = module?.default ? createElement(module.default) : undefined;\n const handle = {\n ...module?.config,\n title: module?.config?.title ?? convertComponentNameToTitle(module?.default),\n flowLayout: module?.config?.flowLayout ?? flowLayout,\n };\n\n if (path === '' && !children) {\n return {\n ...original,\n element,\n handle,\n index: true,\n } as IndexRouteObject;\n }\n\n return {\n ...original,\n path: module?.config?.route ?? path,\n element,\n children,\n handle,\n } as NonIndexRouteObject;\n }\n\n return original;\n });\n }\n\n /**\n * Adds the given server route element to each branch of the current list of\n * routes.\n *\n * @param component - The React component to add to each branch of the\n * current list of routes.\n * @param config - An optional configuration that will be applied to\n * each fallback component.\n */\n withFallback(component: ComponentType, config?: ViewConfig): this {\n this.withLayout(component);\n\n // Fallback adds two routes, so that the index (empty path) has a fallback too\n const fallbackRoutes: RouteList = [\n { path: '*', element: createElement(component), handle: config },\n { index: true, element: createElement(component), handle: config },\n ];\n\n this.update(fallbackRoutes, ({ original, overriding: added, children, dupe }) => {\n if (original && !getRouteHandleFlag(original, RouteHandleFlags.IGNORE_FALLBACK) && !dupe) {\n if (!children) {\n return original;\n }\n\n const _fallback = [...fallbackRoutes];\n\n if (children.some(({ path }) => path === '*')) {\n _fallback.shift();\n }\n\n if (children.some(({ index: i, path }) => i ?? path?.includes('?'))) {\n _fallback.pop();\n }\n\n return {\n ...original,\n children: [...children, ..._fallback],\n } as RouteObject;\n }\n\n return added!;\n });\n\n return this;\n }\n\n /**\n * Adds the layoutComponent as the parent layout to views with the flowLayouts ViewConfiguration set.\n *\n * @param layoutComponent - layout component to use, usually Flow\n */\n withLayout(layoutComponent: ComponentType): this {\n this.#modifiers.push((originalRoutes) => {\n if (!originalRoutes) {\n return originalRoutes;\n }\n\n type Accumulator<T extends RouteList> = Readonly<{\n server: T;\n client: T;\n ambivalent: T;\n }>;\n\n const result = transformTree<RouteList, Accumulator<RouteList>>(originalRoutes, null, (routes, next) =>\n // Split a single routes list onto three separate lists:\n // - A list of server routes\n // - A list of client routes\n // - A list of routes which will be moved to either server or client\n // list. It depends on the parent route.\n routes.reduce<Accumulator<WritableRouteList>>(\n (lists, route) => {\n const { server, client, ambivalent } = next(route.children ?? []);\n\n const flag = getRouteHandleFlag(route, RouteHandleFlags.FLOW_LAYOUT);\n\n // If the route has `flowLayout` flag explicitly enabled, it goes to\n // the server list. The children are also affected by the flag\n // unless they have it explicitly disabled.\n if (flag === true) {\n lists.server.push({\n ...route,\n children: server.length + ambivalent.length > 0 ? [...server, ...ambivalent] : undefined,\n } as RouteObject);\n } else if (server.length > 0) {\n // Even if the route doesn't have the flag, it goes to the server\n // list if any of the children has the flag enabled.\n lists.server.push({\n ...route,\n children: server,\n } as RouteObject);\n }\n\n // If the route has `flowLayout` flag explicitly disabled, it goes\n // to the client list. The route children are not affected by the\n // flag.\n if (flag === false || client.length > 0) {\n lists.client.push({\n ...route,\n children: client.length > 0 ? client : undefined,\n } as RouteObject);\n }\n\n // The route without the flag go to the `default` list. Then it will\n // be moved to either server or client list based on the parent\n // route.\n if (\n flag === undefined &&\n (lists.server.every(({ path }) => path !== route.path) || ambivalent.length > 0)\n ) {\n lists.ambivalent.push({\n ...route,\n children: ambivalent.length > 0 ? ambivalent : undefined,\n } as RouteObject);\n }\n\n return lists;\n },\n { server: [], client: [], ambivalent: [] },\n ),\n );\n\n return [\n ...(result.server.length\n ? [\n // The server routes are wrapped with the route that has a layout\n // element. It also has the `IGNORE_FALLBACK` flag to remove the\n // fallback route from reach.\n {\n element: createElement(layoutComponent),\n children: result.server as RouteObject[],\n handle: {\n [RouteHandleFlags.IGNORE_FALLBACK]: true,\n },\n },\n ]\n : []),\n // The client routes are preserved without wrapping.\n ...result.client,\n // The ambivalent routes are considered as client routes.\n ...result.ambivalent,\n ];\n });\n\n return this;\n }\n\n /**\n * Protects all the routes that require authentication. For more details see\n * {@link @vaadin/hilla-react-auth#protectRoutes} function.\n *\n * @param redirectPath - the path to redirect to if the route is protected\n * and the user is not authenticated.\n */\n protect(redirectPath?: string): this {\n this.update(undefined, ({ original: route, children }) => {\n const finalRoute = protectRoute(route!, redirectPath);\n finalRoute.children = children as RouteObject[] | undefined;\n return finalRoute;\n });\n\n return this;\n }\n\n /**\n * Deeply updates the current list of routes with the given routes merging\n * them in process.\n *\n * @param routes - A list of routes to merge with the current list.\n * @param callback - A callback to transform the routes during the merge.\n */\n update<T extends RouteBase>(routes: undefined, callback: RouteTransformer<undefined>): this;\n update<T extends RouteBase>(routes: readonly T[], callback?: RouteTransformer<T>): this;\n update<T extends RouteBase>(\n routes: readonly T[] | undefined,\n callback: RouteTransformer<T | undefined> = ({ original, overriding, children }) =>\n ({\n ...original,\n ...overriding,\n children,\n }) as RouteObject,\n ): this {\n this.#modifiers.push((existingRoutes) =>\n // Going through the existing and added list of routes.\n transformTree<readonly [RouteList | undefined, readonly T[] | undefined], RouteList | undefined>(\n [existingRoutes, routes],\n null,\n ([original, added], next) => {\n if (original && added) {\n // If we have both original and added routes, we have to merge them.\n const final: Array<RouteObject | undefined> = [];\n const pathKeys = new Set([...original.map(createRouteKey), ...added.map(createRouteKey)]);\n\n for (const pathKey of pathKeys) {\n // We can have multiple routes with the same path, so we have to\n // consider all of them.\n const originalRoutes = original.filter((r) => createRouteKey(r) === pathKey);\n // We can have only one route with the same path in the added list.\n const addedRoutes = added.filter((r) => createRouteKey(r) === pathKey);\n\n if (addedRoutes.length > 1) {\n throw new Error('Adding multiple routes with the same path is not allowed');\n }\n\n const addedRoute = addedRoutes[0] as T | undefined;\n\n if (originalRoutes.length > 0 && addedRoute) {\n // In case we have both original and added routes, we run\n // the callback for each original route in pair with the added\n // route. To make the difference, we flag all the routes except\n // the last one as `dupe`.\n //\n // Why the last one is not `dupe`? According to the\n // `react-router` logic, the last route is the fallback for all\n // routes with the same path. So, if we apply callback to it,\n // we implicitly apply it to all other routes with the same\n // path.\n //\n // In case this logic doesn't work, the user can apply the\n // callback without considering the `dupe` flag.\n for (let i = 0; i < originalRoutes.length; i++) {\n final.push(\n callback({\n original: originalRoutes[i],\n overriding: addedRoute,\n children: next([originalRoutes[i].children, addedRoute.children]),\n dupe: i < originalRoutes.length - 1,\n }) ?? originalRoutes[i],\n );\n }\n } else if (originalRoutes.length > 0) {\n // In case we don't have the added route with the path being\n // processed, we run the callback for each original route.\n for (let i = 0; i < originalRoutes.length; i++) {\n final.push(\n callback({\n original: originalRoutes[i],\n children: next([originalRoutes[i].children, undefined]),\n dupe: i < originalRoutes.length - 1,\n }) ?? originalRoutes[i],\n );\n }\n } else {\n // In case we don't have the original route with the path being\n // processed, we run the callback for only the added route.\n const result = callback({\n overriding: addedRoute,\n children: next([undefined, addedRoute!.children]),\n dupe: false,\n });\n\n if (result) {\n final.push(result);\n }\n }\n }\n\n return final.filter((r) => r != null);\n } else if (original) {\n // If we have only original routes, we run the callback for each\n // original route.\n return original\n .map((route) =>\n callback({\n original: route,\n children: next([route.children, undefined]),\n dupe: false,\n }),\n )\n .filter((r) => r != null);\n } else if (added) {\n // If we have only added routes, we run the callback for each added\n // route.\n return added\n .map((route) =>\n callback({\n overriding: route,\n children: next([undefined, route.children]),\n dupe: false,\n }),\n )\n .filter((r) => r != null);\n }\n\n return undefined;\n },\n ),\n );\n return this;\n }\n\n /**\n * Builds the router with the current list of routes.\n */\n build(options?: RouterBuildOptions): RouterConfiguration {\n this.#withLayoutSkipping();\n const routes = this.#modifiers.reduce<RouteList | undefined>((acc, mod) => mod(acc) ?? acc, undefined) ?? [];\n\n return {\n routes,\n router: createBrowserRouter([...routes], {\n basename: new URL(document.baseURI).pathname,\n future: {\n // eslint-disable-next-line camelcase\n v7_fetcherPersist: true,\n // eslint-disable-next-line camelcase\n v7_normalizeFormMethod: true,\n // eslint-disable-next-line camelcase\n v7_partialHydration: true,\n // eslint-disable-next-line camelcase\n v7_relativeSplatPath: true,\n // eslint-disable-next-line camelcase\n v7_skipActionErrorRevalidation: true,\n },\n ...options,\n }),\n };\n }\n\n #withLayoutSkipping(): this {\n this.#modifiers.push((originalRoutes) => {\n if (!originalRoutes) {\n return originalRoutes;\n }\n\n type Accumulator<T extends RouteList> = Readonly<{\n skipped: T;\n regular: T;\n }>;\n\n const result = transformTree<RouteList, Accumulator<RouteList>>(originalRoutes, null, (routes, next) =>\n // Split a single routes list onto two separate lists.\n routes.reduce<Accumulator<WritableRouteList>>(\n (lists, route) => {\n // If the route has `skipLayout` flag, it goes to the `skipped` list.\n if (getRouteHandleFlag(route, RouteHandleFlags.SKIP_LAYOUTS)) {\n lists.skipped.push(route);\n return lists;\n }\n\n // If the route is leaf, it goes to the `regular` list.\n if (!route.children?.length) {\n lists.regular.push(route);\n return lists;\n }\n\n // As of children, we have to split them into two lists as well.\n const { skipped, regular } = next(route.children ?? []);\n\n // If we have `skipped` list of children, we have to remove the\n // `element` property of the router to prevent the layout from\n // rendering. Then, we add the current route to the `skipped` list.\n if (skipped.length > 0) {\n const { element, ...rest } = route;\n\n lists.skipped.push({\n ...rest,\n children: skipped,\n } as RouteObject);\n }\n\n // In case of `regular` children, we just add the current route to\n // the `regular` list if there are any children.\n if (regular.length > 0) {\n lists.regular.push({\n ...route,\n children: regular,\n } as RouteObject);\n }\n\n return lists;\n },\n { skipped: [], regular: [] },\n ),\n );\n\n // We don't need a fallback for the skipped routes, so we have to wrap\n // them with the route with the `IGNORE_FALLBACK` flag.\n return [\n ...(result.skipped.length\n ? [\n {\n children: result.skipped as RouteObject[],\n handle: {\n [RouteHandleFlags.IGNORE_FALLBACK]: true,\n },\n },\n ]\n : []),\n ...result.regular,\n ];\n });\n\n return this;\n }\n}\n"],
5
- "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAA6B,qBAAqB;AAClD;AAAA,EACE;AAAA,OAIK;AACP,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAe9B,SAAS,mBAAmB,QAAmE;AAC7F,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SACG,aAAa,UAAU,OAAO,O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AK,IAAI;AAE7B,sBAAM,QAAQ,KAAK;AAAA,kBACjB,GAAG;AAAA,kBACH,UAAU;AAAA,gBACZ,CAAgB;AAAA,cAClB;AAIA,kBAAI,QAAQ,SAAS,GAAG;AACtB,sBAAM,QAAQ,KAAK;AAAA,kBACjB,GAAG;AAAA,kBACH,UAAU;AAAA,gBACZ,CAAgB;AAAA,cAClB;AAEA,qBAAO;AAAA,YACT;AAAA,YACA,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,UAC7B;AAAA;AAAA,MACF;AAIA,aAAO;AAAA,QACL,GAAI,OAAO,QAAQ,SACf;AAAA,UACE;AAAA,YACE,UAAU,OAAO;AAAA,YACjB,QAAQ;AAAA,cACN,CAAC,sCAAgC,GAAG;AAAA,YACtC;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL,GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/consistent-type-assertions */\nimport { protectRoute } from '@vaadin/hilla-react-auth';\nimport { type ComponentType, createElement } from 'react';\nimport { createBrowserRouter, type IndexRouteObject, type NonIndexRouteObject, type RouteObject } from 'react-router';\nimport { convertComponentNameToTitle } from '../shared/convertComponentNameToTitle.js';\nimport { transformTree } from '../shared/transformTree.js';\nimport type {\n AgnosticRoute,\n Module,\n RouteModule,\n RouterBuildOptions,\n RouterConfiguration,\n ViewConfig,\n} from '../types.js';\n\ninterface RouteBase {\n path?: string;\n children?: readonly this[];\n}\n\nfunction isReactRouteModule(module?: Module): module is RouteModule<ComponentType> | undefined {\n if (!module) {\n return true;\n }\n\n return (\n ('default' in module && typeof module.default === 'function') ||\n ('config' in module && typeof module.config === 'object')\n );\n}\n\nexport type RouteList = readonly RouteObject[];\nexport type WritableRouteList = RouteObject[];\n\nexport type RouteTransformerOptions<T> = Readonly<{\n children?: RouteList;\n original?: RouteObject;\n overriding?: T;\n dupe: boolean;\n}>;\n\nexport type RouteTransformer<T> = (opts: RouteTransformerOptions<T>) => RouteObject | undefined;\n\ntype RoutesModifier = (routes: RouteList | undefined) => RouteList | undefined;\n\nfunction createRouteKey<T extends RouteBase>(route: T): string {\n return `${route.path ?? ''}-${route.children ? 'n' : 'i'}`;\n}\n\nenum RouteHandleFlags {\n FLOW_LAYOUT = 'flowLayout',\n IGNORE_FALLBACK = 'ignoreFallback',\n SKIP_LAYOUTS = 'skipLayouts',\n}\n\nfunction getRouteHandleFlag<T extends RouteHandleFlags>(route: RouteObject, flag: T): boolean | undefined {\n if (typeof route.handle === 'object' && flag in route.handle) {\n return (route.handle as Record<T, boolean>)[flag];\n }\n\n return undefined;\n}\n\n/**\n * A builder for creating a Vaadin-specific router for React with\n * authentication and server routes support.\n */\nexport class RouterConfigurationBuilder {\n readonly #modifiers: RoutesModifier[] = [];\n\n /**\n * Adds the given routes to the current list of routes. All the routes are\n * deeply merged to preserve the path uniqueness.\n *\n * @param routes - A list of routes to add to the current list.\n */\n withReactRoutes(routes: RouteList): this {\n return this.update(routes);\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 - A list of routes to add to the current list.\n */\n withFileRoutes(routes: readonly AgnosticRoute[]): this {\n return this.update(routes, ({ original, overriding: added, children }) => {\n if (added) {\n const { module, path, flowLayout } = added;\n if (!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 = module?.default ? createElement(module.default) : undefined;\n const handle = {\n ...module?.config,\n title: module?.config?.title ?? convertComponentNameToTitle(module?.default),\n flowLayout: module?.config?.flowLayout ?? flowLayout,\n };\n\n if (path === '' && !children) {\n return {\n ...original,\n element,\n handle,\n index: true,\n } as IndexRouteObject;\n }\n\n return {\n ...original,\n path: module?.config?.route ?? path,\n element,\n children,\n handle,\n } as NonIndexRouteObject;\n }\n\n return original;\n });\n }\n\n /**\n * Adds the given server route element to each branch of the current list of\n * routes.\n *\n * @param component - The React component to add to each branch of the\n * current list of routes.\n * @param config - An optional configuration that will be applied to\n * each fallback component.\n */\n withFallback(component: ComponentType, config?: ViewConfig): this {\n this.withLayout(component);\n\n // Fallback adds two routes, so that the index (empty path) has a fallback too\n const fallbackRoutes: RouteList = [\n { path: '*', element: createElement(component), handle: config },\n { index: true, element: createElement(component), handle: config },\n ];\n\n this.update(fallbackRoutes, ({ original, overriding: added, children, dupe }) => {\n if (original && !getRouteHandleFlag(original, RouteHandleFlags.IGNORE_FALLBACK) && !dupe) {\n if (!children) {\n return original;\n }\n\n const _fallback = [...fallbackRoutes];\n\n if (children.some(({ path }) => path === '*')) {\n _fallback.shift();\n }\n\n if (children.some(({ index: i, path }) => i ?? path?.includes('?'))) {\n _fallback.pop();\n }\n\n return {\n ...original,\n children: [...children, ..._fallback],\n } as RouteObject;\n }\n\n return added!;\n });\n\n return this;\n }\n\n /**\n * Adds the layoutComponent as the parent layout to views with the flowLayouts ViewConfiguration set.\n *\n * @param layoutComponent - layout component to use, usually Flow\n */\n withLayout(layoutComponent: ComponentType): this {\n this.#modifiers.push((originalRoutes) => {\n if (!originalRoutes) {\n return originalRoutes;\n }\n\n type Accumulator<T extends RouteList> = Readonly<{\n server: T;\n client: T;\n ambivalent: T;\n }>;\n\n const result = transformTree<RouteList, Accumulator<RouteList>>(originalRoutes, null, (routes, next) =>\n // Split a single routes list onto three separate lists:\n // - A list of server routes\n // - A list of client routes\n // - A list of routes which will be moved to either server or client\n // list. It depends on the parent route.\n routes.reduce<Accumulator<WritableRouteList>>(\n (lists, route) => {\n const { server, client, ambivalent } = next(route.children ?? []);\n\n const flag = getRouteHandleFlag(route, RouteHandleFlags.FLOW_LAYOUT);\n\n // If the route has `flowLayout` flag explicitly enabled, it goes to\n // the server list. The children are also affected by the flag\n // unless they have it explicitly disabled.\n if (flag === true) {\n lists.server.push({\n ...route,\n children: server.length + ambivalent.length > 0 ? [...server, ...ambivalent] : undefined,\n } as RouteObject);\n } else if (server.length > 0) {\n // Even if the route doesn't have the flag, it goes to the server\n // list if any of the children has the flag enabled.\n lists.server.push({\n ...route,\n children: server,\n } as RouteObject);\n }\n\n // If the route has `flowLayout` flag explicitly disabled, it goes\n // to the client list. The route children are not affected by the\n // flag.\n if (flag === false || client.length > 0) {\n lists.client.push({\n ...route,\n children: client.length > 0 ? client : undefined,\n } as RouteObject);\n }\n\n // The route without the flag go to the `default` list. Then it will\n // be moved to either server or client list based on the parent\n // route.\n if (\n flag === undefined &&\n (lists.server.every(({ path }) => path !== route.path) || ambivalent.length > 0)\n ) {\n lists.ambivalent.push({\n ...route,\n children: ambivalent.length > 0 ? ambivalent : undefined,\n } as RouteObject);\n }\n\n return lists;\n },\n { server: [], client: [], ambivalent: [] },\n ),\n );\n\n return [\n ...(result.server.length\n ? [\n // The server routes are wrapped with the route that has a layout\n // element. It also has the `IGNORE_FALLBACK` flag to remove the\n // fallback route from reach.\n {\n element: createElement(layoutComponent),\n children: result.server as RouteObject[],\n handle: {\n [RouteHandleFlags.IGNORE_FALLBACK]: true,\n },\n },\n ]\n : []),\n // The client routes are preserved without wrapping.\n ...result.client,\n // The ambivalent routes are considered as client routes.\n ...result.ambivalent,\n ];\n });\n\n return this;\n }\n\n /**\n * Protects all the routes that require authentication. For more details see\n * {@link @vaadin/hilla-react-auth#protectRoutes} function.\n *\n * @param redirectPath - the path to redirect to if the route is protected\n * and the user is not authenticated.\n */\n protect(redirectPath?: string): this {\n this.update(undefined, ({ original: route, children }) => {\n const finalRoute = protectRoute(route!, redirectPath);\n finalRoute.children = children as RouteObject[] | undefined;\n return finalRoute;\n });\n\n return this;\n }\n\n /**\n * Deeply updates the current list of routes with the given routes merging\n * them in process.\n *\n * @param routes - A list of routes to merge with the current list.\n * @param callback - A callback to transform the routes during the merge.\n */\n update<T extends RouteBase>(routes: undefined, callback: RouteTransformer<undefined>): this;\n update<T extends RouteBase>(routes: readonly T[], callback?: RouteTransformer<T>): this;\n update<T extends RouteBase>(\n routes: readonly T[] | undefined,\n callback: RouteTransformer<T | undefined> = ({ original, overriding, children }) =>\n ({\n ...original,\n ...overriding,\n children,\n }) as RouteObject,\n ): this {\n this.#modifiers.push((existingRoutes) =>\n // Going through the existing and added list of routes.\n transformTree<readonly [RouteList | undefined, readonly T[] | undefined], RouteList | undefined>(\n [existingRoutes, routes],\n null,\n ([original, added], next) => {\n if (original && added) {\n // If we have both original and added routes, we have to merge them.\n const final: Array<RouteObject | undefined> = [];\n const pathKeys = new Set([...original.map(createRouteKey), ...added.map(createRouteKey)]);\n\n for (const pathKey of pathKeys) {\n // We can have multiple routes with the same path, so we have to\n // consider all of them.\n const originalRoutes = original.filter((r) => createRouteKey(r) === pathKey);\n // We can have only one route with the same path in the added list.\n const addedRoutes = added.filter((r) => createRouteKey(r) === pathKey);\n\n if (addedRoutes.length > 1) {\n throw new Error('Adding multiple routes with the same path is not allowed');\n }\n\n const addedRoute = addedRoutes[0] as T | undefined;\n\n if (originalRoutes.length > 0 && addedRoute) {\n // In case we have both original and added routes, we run\n // the callback for each original route in pair with the added\n // route. To make the difference, we flag all the routes except\n // the last one as `dupe`.\n //\n // Why the last one is not `dupe`? According to the\n // `react-router` logic, the last route is the fallback for all\n // routes with the same path. So, if we apply callback to it,\n // we implicitly apply it to all other routes with the same\n // path.\n //\n // In case this logic doesn't work, the user can apply the\n // callback without considering the `dupe` flag.\n for (let i = 0; i < originalRoutes.length; i++) {\n final.push(\n callback({\n original: originalRoutes[i],\n overriding: addedRoute,\n children: next([originalRoutes[i].children, addedRoute.children]),\n dupe: i < originalRoutes.length - 1,\n }) ?? originalRoutes[i],\n );\n }\n } else if (originalRoutes.length > 0) {\n // In case we don't have the added route with the path being\n // processed, we run the callback for each original route.\n for (let i = 0; i < originalRoutes.length; i++) {\n final.push(\n callback({\n original: originalRoutes[i],\n children: next([originalRoutes[i].children, undefined]),\n dupe: i < originalRoutes.length - 1,\n }) ?? originalRoutes[i],\n );\n }\n } else {\n // In case we don't have the original route with the path being\n // processed, we run the callback for only the added route.\n const result = callback({\n overriding: addedRoute,\n children: next([undefined, addedRoute!.children]),\n dupe: false,\n });\n\n if (result) {\n final.push(result);\n }\n }\n }\n\n return final.filter((r) => r != null);\n } else if (original) {\n // If we have only original routes, we run the callback for each\n // original route.\n return original\n .map((route) =>\n callback({\n original: route,\n children: next([route.children, undefined]),\n dupe: false,\n }),\n )\n .filter((r) => r != null);\n } else if (added) {\n // If we have only added routes, we run the callback for each added\n // route.\n return added\n .map((route) =>\n callback({\n overriding: route,\n children: next([undefined, route.children]),\n dupe: false,\n }),\n )\n .filter((r) => r != null);\n }\n\n return undefined;\n },\n ),\n );\n return this;\n }\n\n /**\n * Builds the router with the current list of routes.\n */\n build(options?: RouterBuildOptions): RouterConfiguration {\n this.#withLayoutSkipping();\n const routes = this.#modifiers.reduce<RouteList | 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 #withLayoutSkipping(): this {\n this.#modifiers.push((originalRoutes) => {\n if (!originalRoutes) {\n return originalRoutes;\n }\n\n type Accumulator<T extends RouteList> = Readonly<{\n skipped: T;\n regular: T;\n }>;\n\n const result = transformTree<RouteList, Accumulator<RouteList>>(originalRoutes, null, (routes, next) =>\n // Split a single routes list onto two separate lists.\n routes.reduce<Accumulator<WritableRouteList>>(\n (lists, route) => {\n // If the route has `skipLayout` flag, it goes to the `skipped` list.\n if (getRouteHandleFlag(route, RouteHandleFlags.SKIP_LAYOUTS)) {\n lists.skipped.push(route);\n return lists;\n }\n\n // If the route is leaf, it goes to the `regular` list.\n if (!route.children?.length) {\n lists.regular.push(route);\n return lists;\n }\n\n // As of children, we have to split them into two lists as well.\n const { skipped, regular } = next(route.children ?? []);\n\n // If we have `skipped` list of children, we have to remove the\n // `element` property of the router to prevent the layout from\n // rendering. Then, we add the current route to the `skipped` list.\n if (skipped.length > 0) {\n const { element, ...rest } = route;\n\n lists.skipped.push({\n ...rest,\n children: skipped,\n } as RouteObject);\n }\n\n // In case of `regular` children, we just add the current route to\n // the `regular` list if there are any children.\n if (regular.length > 0) {\n lists.regular.push({\n ...route,\n children: regular,\n } as RouteObject);\n }\n\n return lists;\n },\n { skipped: [], regular: [] },\n ),\n );\n\n // We don't need a fallback for the skipped routes, so we have to wrap\n // them with the route with the `IGNORE_FALLBACK` flag.\n return [\n ...(result.skipped.length\n ? [\n {\n children: result.skipped as RouteObject[],\n handle: {\n [RouteHandleFlags.IGNORE_FALLBACK]: true,\n },\n },\n ]\n : []),\n ...result.regular,\n ];\n });\n\n return this;\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,oBAAoB;AAC7B,SAA6B,qBAAqB;AAClD,SAAS,2BAA8F;AACvG,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAe9B,SAAS,mBAAmB,QAAmE;AAC7F,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SACG,aAAa,UAAU,OAAO,OAAO,YAAY,cACjD,YAAY,UAAU,OAAO,OAAO,WAAW;AAEpD;AAgBA,SAAS,eAAoC,OAAkB;AAC7D,SAAO,GAAG,MAAM,QAAQ,EAAE,IAAI,MAAM,WAAW,MAAM,GAAG;AAC1D;AAEA,IAAK,mBAAL,kBAAKA,sBAAL;AACE,EAAAA,kBAAA,iBAAc;AACd,EAAAA,kBAAA,qBAAkB;AAClB,EAAAA,kBAAA,kBAAe;AAHZ,SAAAA;AAAA,GAAA;AAML,SAAS,mBAA+C,OAAoB,MAA8B;AACxG,MAAI,OAAO,MAAM,WAAW,YAAY,QAAQ,MAAM,QAAQ;AAC5D,WAAQ,MAAM,OAA8B,IAAI;AAAA,EAClD;AAEA,SAAO;AACT;AAMO,MAAM,2BAA2B;AAAA,EAC7B,aAA+B,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,gBAAgB,QAAyB;AACv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gB;AACnB,eAAO;AAAA,MACT;AAOA,YAAM,SAAS;AAAA,QAAiD;AAAA,QAAgB;AAAA,QAAM,CAAC,QAAQ;AAAA;AAAA,UAE7F,OAAO;AAAA,YACL,CAAC,OAAO,UAAU;AAEhB,kBAAI,mBAAmB,OAAO,gCAA6B,GAAG;AAC5D,sBAAM,QAAQ,KAAK,KAAK;AACxB,uBAAO;AAAA,cACT;AAGA,kBAAI,CAAC,MAAM,UAAU,QAAQ;AAC3B,sBAAM,QAAQ,KAAK,KAAK;AACxB,uBAAO;AAAA,cACT;AAGA,oBAAM,EAAE,SAAS,QAAQ,IAAI,KAAK,MAAM,YAAY,CAAC,CAAC;AAKtD,kBAAI,QAAQ,SAAS,GAAG;AACtB,sBAAM,EAAE,SAAS,GAAG,KAAK,IAAI;AAE7B,sBAAM,QAAQ,KAAK;AAAA,kBACjB,GAAG;AAAA,kBACH,UAAU;AAAA,gBACZ,CAAgB;AAAA,cAClB;AAIA,kBAAI,QAAQ,SAAS,GAAG;AACtB,sBAAM,QAAQ,KAAK;AAAA,kBACjB,GAAG;AAAA,kBACH,UAAU;AAAA,gBACZ,CAAgB;AAAA,cAClB;AAEA,qBAAO;AAAA,YACT;AAAA,YACA,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,UAC7B;AAAA;AAAA,MACF;AAIA,aAAO;AAAA,QACL,GAAI,OAAO,QAAQ,SACf;AAAA,UACE;AAAA,YACE,UAAU,OAAO;AAAA,YACjB,QAAQ;AAAA,cACN,CAAC,sCAAgC,GAAG;AAAA,YACtC;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL,GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["RouteHandleFlags"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createMenuItems.d.ts","sourceRoot":"","sources":["../src/runtime/createMenuItems.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,WAAW;;;;;;;;aA0BZ,CAAC;aAKc,CAAA;eAEC,CAAC;YAE3B,CAAC;;iBAnCsE,CAAC;AAE1E;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,SAAS,QAAQ,EAAE,CA0BrD"}
1
+ {"version":3,"file":"createMenuItems.d.ts","sourceRoot":"","sources":["../src/runtime/createMenuItems.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,WAAW;;;;;;;;aA0BhB,CAAC;aAKa,CAAC;eAEC,CAAC;YAClB,CAAC;;iBAlCiE,CAAC;AAE1E;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,SAAS,QAAQ,EAAE,CA0BrD"}
@@ -2,7 +2,7 @@ function __REGISTER__(feature, vaadinObj = window.Vaadin ??= {}) {
2
2
  vaadinObj.registrations ??= [];
3
3
  vaadinObj.registrations.push({
4
4
  is: feature ? `${"@vaadin/hilla-file-router"}/${feature}` : "@vaadin/hilla-file-router",
5
- version: "24.6.0"
5
+ version: "24.7.0-alpha3"
6
6
  });
7
7
  }
8
8
  import { signal } from "@vaadin/hilla-react-signals";
@@ -1,4 +1,4 @@
1
- import { useMatches } from "react-router-dom";
1
+ import { useMatches } from "react-router";
2
2
  function useViewConfig() {
3
3
  const matches = useMatches();
4
4
  return matches[matches.length - 1]?.handle;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/runtime/useViewConfig.ts"],
4
- "sourcesContent": ["import type { UIMatch } from '@remix-run/router';\nimport { useMatches } from 'react-router-dom';\nimport type { ViewConfig } from '../types.js';\n\n/**\n * Hook to return the {@link ViewConfig} for the current route.\n */\nexport function useViewConfig<M extends ViewConfig>(): M | undefined {\n const matches = useMatches() as ReadonlyArray<UIMatch<unknown, M>>;\n return matches[matches.length - 1]?.handle;\n}\n"],
4
+ "sourcesContent": ["import type { UIMatch } from 'react-router';\nimport { useMatches } from 'react-router';\nimport type { ViewConfig } from '../types.js';\n\n/**\n * Hook to return the {@link ViewConfig} for the current route.\n */\nexport function useViewConfig<M extends ViewConfig>(): M | undefined {\n const matches = useMatches() as ReadonlyArray<UIMatch<unknown, M>>;\n return matches[matches.length - 1]?.handle;\n}\n"],
5
5
  "mappings": "AACA,SAAS,kBAAkB;AAMpB,SAAS,gBAAqD;AACnE,QAAM,UAAU,WAAW;AAC3B,SAAO,QAAQ,QAAQ,SAAS,CAAC,GAAG;AACtC;",
6
6
  "names": []
7
7
  }
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { createBrowserRouter, RouteObject } from 'react-router-dom';
1
+ import type { createBrowserRouter, RouteObject } from 'react-router';
2
2
 
3
3
  export type ViewConfig = Readonly<{
4
4
  /**