@furystack/shades 13.2.2 → 15.0.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/CHANGELOG.md +157 -0
- package/esm/component-factory.spec.d.ts.map +1 -1
- package/esm/component-factory.spec.js +2 -2
- package/esm/component-factory.spec.js.map +1 -1
- package/esm/components/define-nested-routes.d.ts +27 -0
- package/esm/components/define-nested-routes.d.ts.map +1 -0
- package/esm/components/define-nested-routes.js +26 -0
- package/esm/components/define-nested-routes.js.map +1 -0
- package/esm/components/define-nested-routes.spec.d.ts +2 -0
- package/esm/components/define-nested-routes.spec.d.ts.map +1 -0
- package/esm/components/define-nested-routes.spec.js +81 -0
- package/esm/components/define-nested-routes.spec.js.map +1 -0
- package/esm/components/index.d.ts +3 -3
- package/esm/components/index.d.ts.map +1 -1
- package/esm/components/index.js +3 -3
- package/esm/components/index.js.map +1 -1
- package/esm/components/nested-hooks.d.ts +62 -0
- package/esm/components/nested-hooks.d.ts.map +1 -0
- package/esm/components/nested-hooks.js +73 -0
- package/esm/components/nested-hooks.js.map +1 -0
- package/esm/components/nested-hooks.spec.d.ts +2 -0
- package/esm/components/nested-hooks.spec.d.ts.map +1 -0
- package/esm/components/nested-hooks.spec.js +211 -0
- package/esm/components/nested-hooks.spec.js.map +1 -0
- package/esm/components/nested-navigate.d.ts +52 -21
- package/esm/components/nested-navigate.d.ts.map +1 -1
- package/esm/components/nested-navigate.js +32 -17
- package/esm/components/nested-navigate.js.map +1 -1
- package/esm/components/nested-navigate.spec.js +109 -19
- package/esm/components/nested-navigate.spec.js.map +1 -1
- package/esm/components/nested-replace.d.ts +36 -0
- package/esm/components/nested-replace.d.ts.map +1 -0
- package/esm/components/nested-replace.js +38 -0
- package/esm/components/nested-replace.js.map +1 -0
- package/esm/components/nested-replace.spec.d.ts +2 -0
- package/esm/components/nested-replace.spec.d.ts.map +1 -0
- package/esm/components/nested-replace.spec.js +59 -0
- package/esm/components/nested-replace.spec.js.map +1 -0
- package/esm/components/nested-route-link.d.ts +36 -26
- package/esm/components/nested-route-link.d.ts.map +1 -1
- package/esm/components/nested-route-link.js +18 -20
- package/esm/components/nested-route-link.js.map +1 -1
- package/esm/components/nested-route-link.spec.js +67 -17
- package/esm/components/nested-route-link.spec.js.map +1 -1
- package/esm/components/nested-route-types.d.ts +79 -2
- package/esm/components/nested-route-types.d.ts.map +1 -1
- package/esm/components/nested-router.d.ts +77 -7
- package/esm/components/nested-router.d.ts.map +1 -1
- package/esm/components/nested-router.js +139 -13
- package/esm/components/nested-router.js.map +1 -1
- package/esm/components/nested-router.spec.js +283 -52
- package/esm/components/nested-router.spec.js.map +1 -1
- package/esm/services/location-service.d.ts +39 -42
- package/esm/services/location-service.d.ts.map +1 -1
- package/esm/services/location-service.js +115 -134
- package/esm/services/location-service.js.map +1 -1
- package/esm/services/location-service.spec.js +59 -24
- package/esm/services/location-service.spec.js.map +1 -1
- package/esm/services/route-match-service.d.ts +3 -2
- package/esm/services/route-match-service.d.ts.map +1 -1
- package/esm/services/route-match-service.js +13 -22
- package/esm/services/route-match-service.js.map +1 -1
- package/esm/services/route-match-service.spec.js +42 -49
- package/esm/services/route-match-service.spec.js.map +1 -1
- package/esm/services/route-meta-utils.d.ts +28 -6
- package/esm/services/route-meta-utils.d.ts.map +1 -1
- package/esm/services/route-meta-utils.js +18 -4
- package/esm/services/route-meta-utils.js.map +1 -1
- package/esm/services/route-meta-utils.spec.js +60 -5
- package/esm/services/route-meta-utils.spec.js.map +1 -1
- package/esm/services/screen-service.d.ts +13 -72
- package/esm/services/screen-service.d.ts.map +1 -1
- package/esm/services/screen-service.js +45 -137
- package/esm/services/screen-service.js.map +1 -1
- package/esm/services/screen-service.spec.js +19 -18
- package/esm/services/screen-service.spec.js.map +1 -1
- package/esm/services/spatial-navigation-service.d.ts +17 -39
- package/esm/services/spatial-navigation-service.d.ts.map +1 -1
- package/esm/services/spatial-navigation-service.js +280 -313
- package/esm/services/spatial-navigation-service.js.map +1 -1
- package/esm/services/spatial-navigation-service.spec.js +163 -158
- package/esm/services/spatial-navigation-service.spec.js.map +1 -1
- package/esm/shade.d.ts +1 -1
- package/esm/shade.d.ts.map +1 -1
- package/esm/shade.js +10 -7
- package/esm/shade.js.map +1 -1
- package/esm/vnode.d.ts +1 -1
- package/esm/vnode.js +1 -1
- package/package.json +5 -4
- package/src/component-factory.spec.tsx +3 -2
- package/src/components/define-nested-routes.spec.ts +91 -0
- package/src/components/define-nested-routes.ts +27 -0
- package/src/components/index.ts +3 -3
- package/src/components/nested-hooks.spec.ts +254 -0
- package/src/components/nested-hooks.ts +109 -0
- package/src/components/nested-navigate.spec.ts +136 -32
- package/src/components/nested-navigate.ts +75 -26
- package/src/components/nested-replace.spec.ts +89 -0
- package/src/components/nested-replace.ts +46 -0
- package/src/components/nested-route-link.spec.tsx +90 -22
- package/src/components/nested-route-link.tsx +54 -29
- package/src/components/nested-route-types.ts +82 -2
- package/src/components/nested-router.spec.tsx +334 -51
- package/src/components/nested-router.tsx +184 -24
- package/src/services/location-service.spec.ts +68 -25
- package/src/services/location-service.tsx +156 -122
- package/src/services/route-match-service.spec.ts +41 -28
- package/src/services/route-match-service.ts +17 -8
- package/src/services/route-meta-utils.spec.ts +78 -10
- package/src/services/route-meta-utils.ts +44 -15
- package/src/services/screen-service.spec.ts +19 -18
- package/src/services/screen-service.ts +65 -110
- package/src/services/spatial-navigation-service.spec.ts +165 -160
- package/src/services/spatial-navigation-service.ts +299 -287
- package/src/shade.ts +11 -8
- package/src/vnode.ts +1 -1
- package/esm/components/link-to-route.d.ts +0 -10
- package/esm/components/link-to-route.d.ts.map +0 -1
- package/esm/components/link-to-route.js +0 -16
- package/esm/components/link-to-route.js.map +0 -1
- package/esm/components/link-to-route.spec.d.ts +0 -2
- package/esm/components/link-to-route.spec.d.ts.map +0 -1
- package/esm/components/link-to-route.spec.js +0 -30
- package/esm/components/link-to-route.spec.js.map +0 -1
- package/esm/components/route-link.d.ts +0 -10
- package/esm/components/route-link.d.ts.map +0 -1
- package/esm/components/route-link.js +0 -25
- package/esm/components/route-link.js.map +0 -1
- package/esm/components/route-link.spec.d.ts +0 -2
- package/esm/components/route-link.spec.d.ts.map +0 -1
- package/esm/components/route-link.spec.js +0 -34
- package/esm/components/route-link.spec.js.map +0 -1
- package/esm/components/router.d.ts +0 -44
- package/esm/components/router.d.ts.map +0 -1
- package/esm/components/router.js +0 -66
- package/esm/components/router.js.map +0 -1
- package/esm/components/router.spec.d.ts +0 -2
- package/esm/components/router.spec.d.ts.map +0 -1
- package/esm/components/router.spec.js +0 -161
- package/esm/components/router.spec.js.map +0 -1
- package/src/components/link-to-route.spec.tsx +0 -45
- package/src/components/link-to-route.tsx +0 -26
- package/src/components/route-link.spec.tsx +0 -44
- package/src/components/route-link.tsx +0 -29
- package/src/components/router.spec.tsx +0 -217
- package/src/components/router.tsx +0 -103
|
@@ -12,10 +12,10 @@ export type ConcatPaths<Parent extends string, Child extends string> = Parent ex
|
|
|
12
12
|
* Recursively extracts all valid full URL paths from a nested route tree.
|
|
13
13
|
* @typeParam T - A record of route patterns to NestedRoute definitions
|
|
14
14
|
*/
|
|
15
|
-
export type ExtractRoutePaths<T extends Record<string, NestedRoute<any>>> = {
|
|
15
|
+
export type ExtractRoutePaths<T extends Record<string, NestedRoute<any, any, any>>> = {
|
|
16
16
|
[K in keyof T & string]:
|
|
17
17
|
| K
|
|
18
|
-
| (T[K] extends { children: infer C extends Record<string, NestedRoute<any>> }
|
|
18
|
+
| (T[K] extends { children: infer C extends Record<string, NestedRoute<any, any, any>> }
|
|
19
19
|
? ConcatPaths<K, ExtractRoutePaths<C> & string>
|
|
20
20
|
: never)
|
|
21
21
|
}[keyof T & string]
|
|
@@ -40,3 +40,83 @@ export type ExtractRouteParams<T extends string> = T extends `${string}:${infer
|
|
|
40
40
|
export type UrlTree<TPaths extends string> = {
|
|
41
41
|
[key: string]: TPaths | UrlTree<TPaths>
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A query string validator function for a nested route. Receives the deserialized
|
|
46
|
+
* query string object and returns either the typed query value or `null` when
|
|
47
|
+
* the URL's query does not match the route's expected shape.
|
|
48
|
+
* @typeParam TQuery - The typed query shape the route expects
|
|
49
|
+
*/
|
|
50
|
+
export type QueryValidator<TQuery> = (raw: Record<string, unknown>) => TQuery | null
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A readonly tuple of string literals describing the allowed URL hash values
|
|
54
|
+
* for a nested route.
|
|
55
|
+
*/
|
|
56
|
+
export type HashLiterals = readonly string[]
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Extracts the typed query shape declared by a {@link NestedRoute}'s `query` validator.
|
|
60
|
+
* Resolves to `never` when the route has no `query` validator.
|
|
61
|
+
* @typeParam R - A NestedRoute value type
|
|
62
|
+
*/
|
|
63
|
+
export type ExtractRouteQuery<R> = R extends { query: QueryValidator<infer Q> } ? Q : never
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Extracts the typed hash literal union declared by a {@link NestedRoute}'s `hash` tuple.
|
|
67
|
+
* Resolves to `never` when the route has no `hash` declaration.
|
|
68
|
+
* @typeParam R - A NestedRoute value type
|
|
69
|
+
*/
|
|
70
|
+
export type ExtractRouteHash<R> = R extends { hash: infer H extends HashLiterals } ? H[number] : never
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Walks a nested route tree and resolves the route value at the given composed path.
|
|
74
|
+
* Used to surface per-route `query` / `hash` metadata to call-site helpers.
|
|
75
|
+
* @typeParam TRoutes - The route tree
|
|
76
|
+
* @typeParam TPath - A full composed route path (as produced by {@link ExtractRoutePaths})
|
|
77
|
+
*/
|
|
78
|
+
export type RouteAt<TRoutes extends Record<string, NestedRoute<any, any, any>>, TPath extends string> = {
|
|
79
|
+
[K in keyof TRoutes & string]: TPath extends K
|
|
80
|
+
? TRoutes[K]
|
|
81
|
+
: K extends '/'
|
|
82
|
+
? TRoutes[K] extends { children: infer C extends Record<string, NestedRoute<any, any, any>> }
|
|
83
|
+
? RouteAt<C, TPath>
|
|
84
|
+
: never
|
|
85
|
+
: TPath extends `${K}${infer Rest}`
|
|
86
|
+
? TRoutes[K] extends { children: infer C extends Record<string, NestedRoute<any, any, any>> }
|
|
87
|
+
? RouteAt<C, Rest>
|
|
88
|
+
: never
|
|
89
|
+
: never
|
|
90
|
+
}[keyof TRoutes & string]
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Builds the `params` portion of a typed navigation / link argument.
|
|
94
|
+
* Resolves to `{ params?: Record<string, string> }` when the path has no `:param`
|
|
95
|
+
* segments and `{ params: {...} }` when at least one is required.
|
|
96
|
+
* @typeParam TPath - A URL pattern string
|
|
97
|
+
*/
|
|
98
|
+
export type TypedParamsArg<TPath extends string> = string extends keyof ExtractRouteParams<TPath>
|
|
99
|
+
? { params?: Record<string, string> }
|
|
100
|
+
: { params: ExtractRouteParams<TPath> }
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Builds the `query` portion of a typed navigation / link argument.
|
|
104
|
+
* - `never` (route declared no schema) → property is forbidden.
|
|
105
|
+
* - All-optional schema → property itself is optional.
|
|
106
|
+
* - Any required key → property is required.
|
|
107
|
+
* @typeParam TQuery - The route's typed query shape
|
|
108
|
+
*/
|
|
109
|
+
export type TypedQueryArg<TQuery> = [TQuery] extends [never]
|
|
110
|
+
? { query?: never }
|
|
111
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- `{} extends T` is the idiomatic way to detect "all keys optional" on an arbitrary object shape.
|
|
112
|
+
{} extends TQuery
|
|
113
|
+
? { query?: TQuery }
|
|
114
|
+
: { query: TQuery }
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Builds the `hash` portion of a typed navigation / link argument.
|
|
118
|
+
* Hash is always optional at the call site (URL fragments are never required
|
|
119
|
+
* for correctness of navigation).
|
|
120
|
+
* @typeParam THash - The route's hash literal union
|
|
121
|
+
*/
|
|
122
|
+
export type TypedHashArg<THash> = [THash] extends [never] ? { hash?: never } : { hash?: THash }
|