@vaadin/hilla-file-router 24.7.0-alpha9 → 24.7.0-beta3

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 (63) hide show
  1. package/package.json +10 -34
  2. package/runtime/RouterConfigurationBuilder.d.ts +65 -66
  3. package/runtime/RouterConfigurationBuilder.js +293 -339
  4. package/runtime/RouterConfigurationBuilder.js.map +1 -7
  5. package/runtime/createMenuItems.d.ts +10 -23
  6. package/runtime/createMenuItems.js +45 -35
  7. package/runtime/createMenuItems.js.map +1 -7
  8. package/runtime/createRoute.d.ts +16 -17
  9. package/runtime/createRoute.js +29 -25
  10. package/runtime/createRoute.js.map +1 -7
  11. package/runtime/useViewConfig.d.ts +3 -4
  12. package/runtime/useViewConfig.js +7 -7
  13. package/runtime/useViewConfig.js.map +1 -7
  14. package/runtime.d.ts +4 -5
  15. package/runtime.js +1 -1
  16. package/runtime.js.map +1 -7
  17. package/shared/convertComponentNameToTitle.d.ts +6 -7
  18. package/shared/convertComponentNameToTitle.js +16 -12
  19. package/shared/convertComponentNameToTitle.js.map +1 -7
  20. package/shared/internal.d.ts +11 -16
  21. package/shared/routeParamType.d.ts +5 -6
  22. package/shared/routeParamType.js +10 -10
  23. package/shared/routeParamType.js.map +1 -7
  24. package/shared/transformTree.d.ts +5 -2
  25. package/shared/transformTree.js +3 -6
  26. package/shared/transformTree.js.map +1 -7
  27. package/types.d.ts +73 -88
  28. package/vite-plugin/applyLayouts.d.ts +10 -11
  29. package/vite-plugin/applyLayouts.js +32 -25
  30. package/vite-plugin/applyLayouts.js.map +1 -7
  31. package/vite-plugin/collectRoutesFromFS.d.ts +34 -35
  32. package/vite-plugin/collectRoutesFromFS.js +96 -87
  33. package/vite-plugin/collectRoutesFromFS.js.map +1 -7
  34. package/vite-plugin/createRoutesFromMeta.d.ts +2 -3
  35. package/vite-plugin/createRoutesFromMeta.js +81 -95
  36. package/vite-plugin/createRoutesFromMeta.js.map +1 -7
  37. package/vite-plugin/createViewConfigJson.d.ts +6 -7
  38. package/vite-plugin/createViewConfigJson.js +71 -76
  39. package/vite-plugin/createViewConfigJson.js.map +1 -7
  40. package/vite-plugin/generateRuntimeFiles.d.ts +24 -25
  41. package/vite-plugin/generateRuntimeFiles.js +66 -47
  42. package/vite-plugin/generateRuntimeFiles.js.map +1 -7
  43. package/vite-plugin/utils.d.ts +21 -22
  44. package/vite-plugin/utils.js +57 -46
  45. package/vite-plugin/utils.js.map +1 -7
  46. package/vite-plugin.d.ts +41 -42
  47. package/vite-plugin.js +78 -85
  48. package/vite-plugin.js.map +1 -7
  49. package/runtime/RouterConfigurationBuilder.d.ts.map +0 -1
  50. package/runtime/createMenuItems.d.ts.map +0 -1
  51. package/runtime/createRoute.d.ts.map +0 -1
  52. package/runtime/useViewConfig.d.ts.map +0 -1
  53. package/runtime.d.ts.map +0 -1
  54. package/shared/convertComponentNameToTitle.d.ts.map +0 -1
  55. package/shared/routeParamType.d.ts.map +0 -1
  56. package/shared/transformTree.d.ts.map +0 -1
  57. package/vite-plugin/applyLayouts.d.ts.map +0 -1
  58. package/vite-plugin/collectRoutesFromFS.d.ts.map +0 -1
  59. package/vite-plugin/createRoutesFromMeta.d.ts.map +0 -1
  60. package/vite-plugin/createViewConfigJson.d.ts.map +0 -1
  61. package/vite-plugin/generateRuntimeFiles.d.ts.map +0 -1
  62. package/vite-plugin/utils.d.ts.map +0 -1
  63. package/vite-plugin.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-file-router",
3
- "version": "24.7.0-alpha9",
3
+ "version": "24.7.0-beta3",
4
4
  "description": "Hilla file-based router",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -20,14 +20,13 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "clean:build": "git clean -fx . -e .vite -e node_modules",
23
- "build": "concurrently npm:build:*",
24
- "build:esbuild": "tsx ../../../scripts/build.ts",
25
- "build:dts": "tsc --isolatedModules -p tsconfig.build.json",
26
- "build:copy": "cd src && copyfiles *.d.ts **/*.d.ts ..",
23
+ "build": "tsx ../../../scripts/fast-build.ts",
27
24
  "lint": "eslint src test",
28
25
  "lint:fix": "eslint src test --fix",
29
- "test": "mocha test/**/*.spec.{ts,tsx} --config ../../../.mocharc.cjs",
30
- "test:coverage": "c8 --experimental-monocart -c ../../../.c8rc.json npm test",
26
+ "test": "vitest --run",
27
+ "test:coverage": "vitest --run --coverage",
28
+ "test:react": "npm run test",
29
+ "test:watch": "vitest",
31
30
  "typecheck": "tsc --noEmit"
32
31
  },
33
32
  "exports": {
@@ -59,35 +58,12 @@
59
58
  "peerDependencies": {
60
59
  "react": "18 || 19",
61
60
  "react-dom": "18 || 19",
62
- "react-router": "^7"
63
- },
64
- "devDependencies": {
65
- "@types/chai-as-promised": "^7.1.8",
66
- "@types/chai-fs": "^2.0.5",
67
- "@types/chai-like": "^1.1.3",
68
- "@types/deep-equal-in-any-order": "^1.0.4",
69
- "@types/mocha": "^10.0.10",
70
- "@types/sinon": "^10.0.20",
71
- "@types/sinon-chai": "^3.2.12",
72
- "chai": "^5.1.2",
73
- "chai-as-promised": "^7.1.2",
74
- "chai-deep-equal-ignore-undefined": "^1.1.1",
75
- "chai-fs": "^2.0.0",
76
- "chai-like": "^1.1.3",
77
- "deep-equal-in-any-order": "^2.0.6",
78
- "mocha": "^11.1.0",
79
- "sinon": "^16.1.3",
80
- "sinon-chai": "^3.7.0",
81
- "type-fest": "^4.32.0"
61
+ "react-router": "7"
82
62
  },
83
63
  "dependencies": {
84
- "@types/chai": "^5.0.1",
85
- "@vaadin/hilla-generator-utils": "24.7.0-alpha9",
86
- "@vaadin/hilla-react-auth": "24.7.0-alpha9",
87
- "@vaadin/hilla-react-signals": "24.7.0-alpha9",
88
- "c8": "^10.1.3",
89
- "react": "^18.3.1",
90
- "rollup": "^4.21.0",
64
+ "@vaadin/hilla-generator-utils": "24.7.0-beta3",
65
+ "@vaadin/hilla-react-auth": "24.7.0-beta3",
66
+ "@vaadin/hilla-react-signals": "24.7.0-beta3",
91
67
  "typescript": "5.7.3"
92
68
  }
93
69
  }
@@ -1,77 +1,76 @@
1
- import { type ComponentType } from 'react';
2
- import { type RouteObject } from 'react-router';
3
- import type { AgnosticRoute, RouterBuildOptions, RouterConfiguration, ViewConfig } from '../types.js';
1
+ import { type ComponentType } from "react";
2
+ import { type RouteObject } from "react-router";
3
+ import type { AgnosticRoute, RouterBuildOptions, RouterConfiguration, ViewConfig } from "../types.js";
4
4
  interface RouteBase {
5
- path?: string;
6
- children?: readonly this[];
5
+ path?: string;
6
+ children?: readonly this[];
7
7
  }
8
8
  export type RouteList = readonly RouteObject[];
9
9
  export type WritableRouteList = RouteObject[];
10
10
  export type RouteTransformerOptions<T> = Readonly<{
11
- children?: RouteList;
12
- original?: RouteObject;
13
- overriding?: T;
14
- dupe: boolean;
11
+ children?: RouteList
12
+ original?: RouteObject
13
+ overriding?: T
14
+ dupe: boolean
15
15
  }>;
16
16
  export type RouteTransformer<T> = (opts: RouteTransformerOptions<T>) => RouteObject | undefined;
17
17
  /**
18
- * A builder for creating a Vaadin-specific router for React with
19
- * authentication and server routes support.
20
- */
18
+ * A builder for creating a Vaadin-specific router for React with
19
+ * authentication and server routes support.
20
+ */
21
21
  export declare class RouterConfigurationBuilder {
22
- #private;
23
- /**
24
- * Adds the given routes to the current list of routes. All the routes are
25
- * deeply merged to preserve the path uniqueness.
26
- *
27
- * @param routes - A list of routes to add to the current list.
28
- */
29
- withReactRoutes(routes: RouteList): this;
30
- /**
31
- * Adds the given file routes to the current list of routes. All the routes
32
- * are transformed to React RouterObjects and deeply merged to preserve the
33
- * path uniqueness.
34
- *
35
- * @param routes - A list of routes to add to the current list.
36
- */
37
- withFileRoutes(routes: readonly AgnosticRoute[]): this;
38
- /**
39
- * Adds the given server route element to each branch of the current list of
40
- * routes.
41
- *
42
- * @param component - The React component to add to each branch of the
43
- * current list of routes.
44
- * @param config - An optional configuration that will be applied to
45
- * each fallback component.
46
- */
47
- withFallback(component: ComponentType, config?: ViewConfig): this;
48
- /**
49
- * Adds the layoutComponent as the parent layout to views with the flowLayouts ViewConfiguration set.
50
- *
51
- * @param layoutComponent - layout component to use, usually Flow
52
- */
53
- withLayout(layoutComponent: ComponentType): this;
54
- /**
55
- * Protects all the routes that require authentication. For more details see
56
- * {@link @vaadin/hilla-react-auth#protectRoutes} function.
57
- *
58
- * @param redirectPath - the path to redirect to if the route is protected
59
- * and the user is not authenticated.
60
- */
61
- protect(redirectPath?: string): this;
62
- /**
63
- * Deeply updates the current list of routes with the given routes merging
64
- * them in process.
65
- *
66
- * @param routes - A list of routes to merge with the current list.
67
- * @param callback - A callback to transform the routes during the merge.
68
- */
69
- update<T extends RouteBase>(routes: undefined, callback: RouteTransformer<undefined>): this;
70
- update<T extends RouteBase>(routes: readonly T[], callback?: RouteTransformer<T>): this;
71
- /**
72
- * Builds the router with the current list of routes.
73
- */
74
- build(options?: RouterBuildOptions): RouterConfiguration;
22
+ #private;
23
+ /**
24
+ * Adds the given routes to the current list of routes. All the routes are
25
+ * deeply merged to preserve the path uniqueness.
26
+ *
27
+ * @param routes - A list of routes to add to the current list.
28
+ */
29
+ withReactRoutes(routes: RouteList): this;
30
+ /**
31
+ * Adds the given file routes to the current list of routes. All the routes
32
+ * are transformed to React RouterObjects and deeply merged to preserve the
33
+ * path uniqueness.
34
+ *
35
+ * @param routes - A list of routes to add to the current list.
36
+ */
37
+ withFileRoutes(routes: readonly AgnosticRoute[]): this;
38
+ /**
39
+ * Adds the given server route element to each branch of the current list of
40
+ * routes.
41
+ *
42
+ * @param component - The React component to add to each branch of the
43
+ * current list of routes.
44
+ * @param config - An optional configuration that will be applied to
45
+ * each fallback component.
46
+ */
47
+ withFallback(component: ComponentType, config?: ViewConfig): this;
48
+ /**
49
+ * Adds the layoutComponent as the parent layout to views with the flowLayouts ViewConfiguration set.
50
+ *
51
+ * @param layoutComponent - layout component to use, usually Flow
52
+ */
53
+ withLayout(layoutComponent: ComponentType): this;
54
+ /**
55
+ * Protects all the routes that require authentication. For more details see
56
+ * {@link @vaadin/hilla-react-auth#protectRoutes} function.
57
+ *
58
+ * @param redirectPath - the path to redirect to if the route is protected
59
+ * and the user is not authenticated.
60
+ */
61
+ protect(redirectPath?: string): this;
62
+ /**
63
+ * Deeply updates the current list of routes with the given routes merging
64
+ * them in process.
65
+ *
66
+ * @param routes - A list of routes to merge with the current list.
67
+ * @param callback - A callback to transform the routes during the merge.
68
+ */
69
+ update(routes: undefined, callback: RouteTransformer<undefined>): this;
70
+ update<T extends RouteBase>(routes: readonly T[], callback?: RouteTransformer<T>): this;
71
+ /**
72
+ * Builds the router with the current list of routes.
73
+ */
74
+ build(options?: RouterBuildOptions): RouterConfiguration;
75
75
  }
76
76
  export {};
77
- //# sourceMappingURL=RouterConfigurationBuilder.d.ts.map