@canonical/router-react 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -104,10 +104,13 @@ All hooks and `Link` default to `RegisteredRouteMap`. Register your route map on
104
104
  declare module "@canonical/router-react" {
105
105
  interface RouterRegister {
106
106
  routes: typeof routes;
107
+ meta: AppRouteMeta; // optional: types every route's `meta`
107
108
  }
108
109
  }
109
110
  ```
110
111
 
112
+ A declared `meta` is checked at each `route()` call and typed wherever a route is read (`router.routes[name].meta`, `match.route.meta`). Without it, `meta` is `Readonly<Record<string, unknown>>`.
113
+
111
114
  Explicit generics (`<typeof routes>`) still work as an escape hatch for multi-router apps or library code.
112
115
 
113
116
  Important distinction:
@@ -9,15 +9,25 @@ import type { AnyRoute, RouteMap } from "@canonical/router-core";
9
9
  * declare module "@canonical/router-react" {
10
10
  * interface RouterRegister {
11
11
  * routes: typeof appRoutes;
12
+ * meta: AppRouteMeta;
12
13
  * }
13
14
  * }
14
15
  * ```
15
16
  *
16
17
  * When no registration exists the fallback is `RouteMap` (any string key),
17
- * which compiles but provides no autocomplete or typo detection.
18
+ * which compiles but provides no autocomplete or typo detection. A declared
19
+ * `meta` types every route's `meta` (see `RouteMeta` in
20
+ * `@canonical/router-core`).
18
21
  */
19
22
  export interface RouterRegister {
20
23
  }
24
+ /** This package's register, under a name the core augmentation can extend. */
25
+ type ReactRouterRegister = RouterRegister;
26
+ declare module "@canonical/router-core" {
27
+ /** Merges `@canonical/router-react`'s register into the core one. */
28
+ interface RouterRegister extends ReactRouterRegister {
29
+ }
30
+ }
21
31
  /** Resolves to the registered route map, or falls back to `RouteMap`. */
22
32
  export type RegisteredRouteMap = RouterRegister extends {
23
33
  routes: infer T extends RouteMap;
@@ -26,4 +36,5 @@ export type RegisteredRouteMap = RouterRegister extends {
26
36
  export type RegisteredNotFound = RouterRegister extends {
27
37
  notFound: infer T extends AnyRoute | undefined;
28
38
  } ? T : undefined;
39
+ export {};
29
40
  //# sourceMappingURL=register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/lib/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,cAAc;CAAG;AAElC,yEAAyE;AACzE,MAAM,MAAM,kBAAkB,GAAG,cAAc,SAAS;IACtD,MAAM,EAAE,MAAM,CAAC,SAAS,QAAQ,CAAC;CAClC,GACG,CAAC,GACD,QAAQ,CAAC;AAEb,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG,cAAc,SAAS;IACtD,QAAQ,EAAE,MAAM,CAAC,SAAS,QAAQ,GAAG,SAAS,CAAC;CAChD,GACG,CAAC,GACD,SAAS,CAAC"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/lib/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,cAAc;CAAG;AAElC,8EAA8E;AAC9E,KAAK,mBAAmB,GAAG,cAAc,CAAC;AAE1C,OAAO,QAAQ,wBAAwB,CAAC;IACtC,qEAAqE;IACrE,UAAU,cAAe,SAAQ,mBAAmB;KAAG;CACxD;AAED,yEAAyE;AACzE,MAAM,MAAM,kBAAkB,GAAG,cAAc,SAAS;IACtD,MAAM,EAAE,MAAM,CAAC,SAAS,QAAQ,CAAC;CAClC,GACG,CAAC,GACD,QAAQ,CAAC;AAEb,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG,cAAc,SAAS;IACtD,QAAQ,EAAE,MAAM,CAAC,SAAS,QAAQ,GAAG,SAAS,CAAC;CAChD,GACG,CAAC,GACD,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/router-react",
3
3
  "description": "React bindings for @canonical/router-core",
4
- "version": "0.48.0",
4
+ "version": "0.49.0",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -44,16 +44,16 @@
44
44
  "test:coverage": "vitest run --coverage"
45
45
  },
46
46
  "dependencies": {
47
- "@canonical/react-ssr": "^0.48.0",
48
- "@canonical/router-core": "^0.48.0",
47
+ "@canonical/react-ssr": "^0.49.0",
48
+ "@canonical/router-core": "^0.49.0",
49
49
  "react": "^19.2.4",
50
50
  "react-dom": "^19.2.4"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@biomejs/biome": "2.6.9",
54
54
  "@canonical/biome-config": "0.47.0",
55
- "@canonical/typescript-config-react": "^0.48.0",
56
- "@canonical/vitest-config-react": "^0.48.0",
55
+ "@canonical/typescript-config-react": "^0.49.0",
56
+ "@canonical/vitest-config-react": "^0.49.0",
57
57
  "@canonical/webarchitect": "0.46.0",
58
58
  "@testing-library/jest-dom": "^7.0.0",
59
59
  "@testing-library/react": "^16.3.2",
@@ -67,5 +67,5 @@
67
67
  "vite": "^8.0.1",
68
68
  "vitest": "^5.0.0"
69
69
  },
70
- "gitHead": "aee4aebab851f90159776a7ba658d0c62e0d2bf4"
70
+ "gitHead": "9b71099ded16351ee14432246e3d8190f48767ed"
71
71
  }