@real-router/angular 0.16.4 → 0.17.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 +25 -21
- package/dist/README.md +25 -21
- package/dist/fesm2022/real-router-angular.mjs +88 -16
- package/dist/fesm2022/real-router-angular.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/types/real-router-angular.d.ts +14 -3
- package/dist/types/real-router-angular.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -103,17 +103,17 @@ export class UsersLayoutComponent {}
|
|
|
103
103
|
|
|
104
104
|
All inject functions must be called within an injection context (constructor, field initializer, or `runInInjectionContext`). Route state functions return `RouteSignals` — an object with a `routeState` signal and a stable `navigator` reference.
|
|
105
105
|
|
|
106
|
-
| Function
|
|
107
|
-
|
|
|
108
|
-
| `injectRouter()`
|
|
109
|
-
| `injectNavigator()`
|
|
110
|
-
| `injectRoute()`
|
|
111
|
-
| `injectRouteNode(name)`
|
|
112
|
-
| `injectRouteUtils()`
|
|
113
|
-
| `injectRouterTransition()`
|
|
114
|
-
| `injectIsActiveRoute(name, params?,
|
|
115
|
-
| `injectRouteExit(handler, options?)`
|
|
116
|
-
| `injectRouteEnter(handler, options?)`
|
|
106
|
+
| Function | Returns | Reactive? |
|
|
107
|
+
| ------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `injectRouter()` | `Router` | Never |
|
|
109
|
+
| `injectNavigator()` | `Navigator` | Never |
|
|
110
|
+
| `injectRoute()` | `RouteSignals` | `routeState` on every navigation |
|
|
111
|
+
| `injectRouteNode(name)` | `RouteSignals` | When the node subtree is entered, left, or changes between descendants (uses `shouldUpdateNode` — sibling-leaf transitions within the same subtree still fire) |
|
|
112
|
+
| `injectRouteUtils()` | `RouteUtils` | Never |
|
|
113
|
+
| `injectRouterTransition()` | `Signal<RouterTransitionSnapshot>` | On transition start/end |
|
|
114
|
+
| `injectIsActiveRoute(name, params?, search?, options?)` | `Signal<boolean>` | On active state change |
|
|
115
|
+
| `injectRouteExit(handler, options?)` | `void` — wraps `subscribeLeave` with abort + same-route guards | Never (handler captured at injection time) |
|
|
116
|
+
| `injectRouteEnter(handler, options?)` | `void` — fires once on nav-driven mount via `effect()` + `transition.from` | Never (handler captured at injection time) |
|
|
117
117
|
|
|
118
118
|
`RouteSignals` shape:
|
|
119
119
|
|
|
@@ -404,6 +404,7 @@ Navigation directive for `<a>` elements. Handles click events, sets `href`, and
|
|
|
404
404
|
realLink
|
|
405
405
|
routeName="users.profile"
|
|
406
406
|
[routeParams]="{ id: '123' }"
|
|
407
|
+
[routeSearch]="{ tab: 'posts' }"
|
|
407
408
|
activeClassName="is-active"
|
|
408
409
|
[activeStrict]="false"
|
|
409
410
|
[ignoreQueryParams]="true"
|
|
@@ -413,15 +414,16 @@ Navigation directive for `<a>` elements. Handles click events, sets `href`, and
|
|
|
413
414
|
</a>
|
|
414
415
|
```
|
|
415
416
|
|
|
416
|
-
| Input | Type | Default | Description
|
|
417
|
-
| ------------------- | ------------------- | ----------- |
|
|
418
|
-
| `routeName` | `string` | `""` | Target route name
|
|
419
|
-
| `routeParams` | `Params` | `undefined` | Route parameters (omitted → `undefined`, shares one active-route source with `injectIsActiveRoute(name)`, #776)
|
|
420
|
-
| `
|
|
421
|
-
| `
|
|
422
|
-
| `
|
|
423
|
-
| `
|
|
424
|
-
| `
|
|
417
|
+
| Input | Type | Default | Description |
|
|
418
|
+
| ------------------- | ------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
419
|
+
| `routeName` | `string` | `""` | Target route name |
|
|
420
|
+
| `routeParams` | `Params` | `undefined` | Route (path) parameters (omitted → `undefined`, shares one active-route source with `injectIsActiveRoute(name)`, #776) |
|
|
421
|
+
| `routeSearch` | `SearchParams` | `undefined` | Query (search) params for the link's target (RFC-4 M2, #1548) — parallel to `routeParams`, the path/query split's view-layer channel |
|
|
422
|
+
| `routeOptions` | `NavigationOptions` | `{}` | Navigation options (replace, etc.) |
|
|
423
|
+
| `activeClassName` | `string` | `"active"` | CSS class applied when route is active |
|
|
424
|
+
| `activeStrict` | `boolean` | `false` | Exact match only (no ancestor match) |
|
|
425
|
+
| `ignoreQueryParams` | `boolean` | `true` | Query params don't affect active state |
|
|
426
|
+
| `hash` | `string` | `undefined` | URL fragment (decoded). Tri-state: undefined preserves, `""` clears, value sets. (#532) |
|
|
425
427
|
|
|
426
428
|
#### `hash` input — URL fragment / tab-style UIs
|
|
427
429
|
|
|
@@ -446,6 +448,8 @@ readonly params = computed(() => ({ filters: [1, 2] }));
|
|
|
446
448
|
// <a realLink routeName="search" [routeParams]="params()" />
|
|
447
449
|
```
|
|
448
450
|
|
|
451
|
+
`routeSearch` is **not** content-stabilized the same way (#1548) — an inline `[routeSearch]="{ tab: 'x' }"` literal re-creates the active-route source and re-runs `buildHref` on every change detection, even when the query content is unchanged. Bind a stable reference (a component field or signal) if churn matters for your use case.
|
|
452
|
+
|
|
449
453
|
### `[realLinkActive]`
|
|
450
454
|
|
|
451
455
|
Applies an active CSS class to any element when a route is active. Use this when you need active state on a non-`<a>` element, or when the clickable element and the styled element are different.
|
|
@@ -738,7 +742,7 @@ The adapter is signal-first and does not depend on Zone.js. It works with `provi
|
|
|
738
742
|
|
|
739
743
|
### Reactive Source Setup via `effect()` (#630)
|
|
740
744
|
|
|
741
|
-
`RealLink`, `RealLinkActive`, and `RouteView` create their subscription sources inside `effect(...)` blocks scheduled from the **constructor** (not `ngOnInit`). Reading signal inputs inside `effect()` makes the source-creation REACTIVE — when `[realLink]`, `[routeParams]`, `[hash]`, `[realLinkActive]`, or `[routeNode]` change in AOT, the effect tears down the previous source via `onCleanup` and creates a new one with the current input values. The legacy `ngOnInit` setup captured inputs once at mount and produced a real AOT bug (#630). Effect cleanup is bound automatically to the host directive's injection-context `DestroyRef`.
|
|
745
|
+
`RealLink`, `RealLinkActive`, and `RouteView` create their subscription sources inside `effect(...)` blocks scheduled from the **constructor** (not `ngOnInit`). Reading signal inputs inside `effect()` makes the source-creation REACTIVE — when `[realLink]`, `[routeParams]`, `[routeSearch]`, `[hash]`, `[realLinkActive]`, or `[routeNode]` change in AOT, the effect tears down the previous source via `onCleanup` and creates a new one with the current input values. The legacy `ngOnInit` setup captured inputs once at mount and produced a real AOT bug (#630). Effect cleanup is bound automatically to the host directive's injection-context `DestroyRef`.
|
|
742
746
|
|
|
743
747
|
In `RealLink` / `RealLinkActive`, `[routeParams]` is routed through `shallowEqual` content-stabilization before the effect reads it, so an inline-literal binding re-allocated on every change detection only re-creates the source on real content change (see [Object `routeParams`](#object-routeparams--content-stabilized), #988).
|
|
744
748
|
|
package/dist/README.md
CHANGED
|
@@ -103,17 +103,17 @@ export class UsersLayoutComponent {}
|
|
|
103
103
|
|
|
104
104
|
All inject functions must be called within an injection context (constructor, field initializer, or `runInInjectionContext`). Route state functions return `RouteSignals` — an object with a `routeState` signal and a stable `navigator` reference.
|
|
105
105
|
|
|
106
|
-
| Function
|
|
107
|
-
|
|
|
108
|
-
| `injectRouter()`
|
|
109
|
-
| `injectNavigator()`
|
|
110
|
-
| `injectRoute()`
|
|
111
|
-
| `injectRouteNode(name)`
|
|
112
|
-
| `injectRouteUtils()`
|
|
113
|
-
| `injectRouterTransition()`
|
|
114
|
-
| `injectIsActiveRoute(name, params?,
|
|
115
|
-
| `injectRouteExit(handler, options?)`
|
|
116
|
-
| `injectRouteEnter(handler, options?)`
|
|
106
|
+
| Function | Returns | Reactive? |
|
|
107
|
+
| ------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `injectRouter()` | `Router` | Never |
|
|
109
|
+
| `injectNavigator()` | `Navigator` | Never |
|
|
110
|
+
| `injectRoute()` | `RouteSignals` | `routeState` on every navigation |
|
|
111
|
+
| `injectRouteNode(name)` | `RouteSignals` | When the node subtree is entered, left, or changes between descendants (uses `shouldUpdateNode` — sibling-leaf transitions within the same subtree still fire) |
|
|
112
|
+
| `injectRouteUtils()` | `RouteUtils` | Never |
|
|
113
|
+
| `injectRouterTransition()` | `Signal<RouterTransitionSnapshot>` | On transition start/end |
|
|
114
|
+
| `injectIsActiveRoute(name, params?, search?, options?)` | `Signal<boolean>` | On active state change |
|
|
115
|
+
| `injectRouteExit(handler, options?)` | `void` — wraps `subscribeLeave` with abort + same-route guards | Never (handler captured at injection time) |
|
|
116
|
+
| `injectRouteEnter(handler, options?)` | `void` — fires once on nav-driven mount via `effect()` + `transition.from` | Never (handler captured at injection time) |
|
|
117
117
|
|
|
118
118
|
`RouteSignals` shape:
|
|
119
119
|
|
|
@@ -404,6 +404,7 @@ Navigation directive for `<a>` elements. Handles click events, sets `href`, and
|
|
|
404
404
|
realLink
|
|
405
405
|
routeName="users.profile"
|
|
406
406
|
[routeParams]="{ id: '123' }"
|
|
407
|
+
[routeSearch]="{ tab: 'posts' }"
|
|
407
408
|
activeClassName="is-active"
|
|
408
409
|
[activeStrict]="false"
|
|
409
410
|
[ignoreQueryParams]="true"
|
|
@@ -413,15 +414,16 @@ Navigation directive for `<a>` elements. Handles click events, sets `href`, and
|
|
|
413
414
|
</a>
|
|
414
415
|
```
|
|
415
416
|
|
|
416
|
-
| Input | Type | Default | Description
|
|
417
|
-
| ------------------- | ------------------- | ----------- |
|
|
418
|
-
| `routeName` | `string` | `""` | Target route name
|
|
419
|
-
| `routeParams` | `Params` | `undefined` | Route parameters (omitted → `undefined`, shares one active-route source with `injectIsActiveRoute(name)`, #776)
|
|
420
|
-
| `
|
|
421
|
-
| `
|
|
422
|
-
| `
|
|
423
|
-
| `
|
|
424
|
-
| `
|
|
417
|
+
| Input | Type | Default | Description |
|
|
418
|
+
| ------------------- | ------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
419
|
+
| `routeName` | `string` | `""` | Target route name |
|
|
420
|
+
| `routeParams` | `Params` | `undefined` | Route (path) parameters (omitted → `undefined`, shares one active-route source with `injectIsActiveRoute(name)`, #776) |
|
|
421
|
+
| `routeSearch` | `SearchParams` | `undefined` | Query (search) params for the link's target (RFC-4 M2, #1548) — parallel to `routeParams`, the path/query split's view-layer channel |
|
|
422
|
+
| `routeOptions` | `NavigationOptions` | `{}` | Navigation options (replace, etc.) |
|
|
423
|
+
| `activeClassName` | `string` | `"active"` | CSS class applied when route is active |
|
|
424
|
+
| `activeStrict` | `boolean` | `false` | Exact match only (no ancestor match) |
|
|
425
|
+
| `ignoreQueryParams` | `boolean` | `true` | Query params don't affect active state |
|
|
426
|
+
| `hash` | `string` | `undefined` | URL fragment (decoded). Tri-state: undefined preserves, `""` clears, value sets. (#532) |
|
|
425
427
|
|
|
426
428
|
#### `hash` input — URL fragment / tab-style UIs
|
|
427
429
|
|
|
@@ -446,6 +448,8 @@ readonly params = computed(() => ({ filters: [1, 2] }));
|
|
|
446
448
|
// <a realLink routeName="search" [routeParams]="params()" />
|
|
447
449
|
```
|
|
448
450
|
|
|
451
|
+
`routeSearch` is **not** content-stabilized the same way (#1548) — an inline `[routeSearch]="{ tab: 'x' }"` literal re-creates the active-route source and re-runs `buildHref` on every change detection, even when the query content is unchanged. Bind a stable reference (a component field or signal) if churn matters for your use case.
|
|
452
|
+
|
|
449
453
|
### `[realLinkActive]`
|
|
450
454
|
|
|
451
455
|
Applies an active CSS class to any element when a route is active. Use this when you need active state on a non-`<a>` element, or when the clickable element and the styled element are different.
|
|
@@ -738,7 +742,7 @@ The adapter is signal-first and does not depend on Zone.js. It works with `provi
|
|
|
738
742
|
|
|
739
743
|
### Reactive Source Setup via `effect()` (#630)
|
|
740
744
|
|
|
741
|
-
`RealLink`, `RealLinkActive`, and `RouteView` create their subscription sources inside `effect(...)` blocks scheduled from the **constructor** (not `ngOnInit`). Reading signal inputs inside `effect()` makes the source-creation REACTIVE — when `[realLink]`, `[routeParams]`, `[hash]`, `[realLinkActive]`, or `[routeNode]` change in AOT, the effect tears down the previous source via `onCleanup` and creates a new one with the current input values. The legacy `ngOnInit` setup captured inputs once at mount and produced a real AOT bug (#630). Effect cleanup is bound automatically to the host directive's injection-context `DestroyRef`.
|
|
745
|
+
`RealLink`, `RealLinkActive`, and `RouteView` create their subscription sources inside `effect(...)` blocks scheduled from the **constructor** (not `ngOnInit`). Reading signal inputs inside `effect()` makes the source-creation REACTIVE — when `[realLink]`, `[routeParams]`, `[routeSearch]`, `[hash]`, `[realLinkActive]`, or `[routeNode]` change in AOT, the effect tears down the previous source via `onCleanup` and creates a new one with the current input values. The legacy `ngOnInit` setup captured inputs once at mount and produced a real AOT bug (#630). Effect cleanup is bound automatically to the host directive's injection-context `DestroyRef`.
|
|
742
746
|
|
|
743
747
|
In `RealLink` / `RealLinkActive`, `[routeParams]` is routed through `shallowEqual` content-stabilization before the effect reads it, so an inline-literal binding re-allocated on every change detection only re-creates the source on real content change (see [Object `routeParams`](#object-routeparams--content-stabilized), #988).
|
|
744
748
|
|
|
@@ -613,7 +613,11 @@ function keyOf(state) {
|
|
|
613
613
|
if (cached !== undefined) {
|
|
614
614
|
return cached;
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
// Key over BOTH channels — path params AND query (RFC-4 M2 / #1548). Merged
|
|
617
|
+
// (not `params:search`) so a query-less route keeps its v1 key shape
|
|
618
|
+
// (`name:{}`), and an unserializable value (BigInt / cyclic) in EITHER channel
|
|
619
|
+
// still throws in `canonicalJson` → `safeKeyOf` drops+warns.
|
|
620
|
+
const key = `${state.name}:${canonicalJson({ ...state.params, ...state.search })}`;
|
|
617
621
|
KEY_CACHE.set(state, key);
|
|
618
622
|
return key;
|
|
619
623
|
}
|
|
@@ -1126,7 +1130,13 @@ function createScrollSpy(router, options) {
|
|
|
1126
1130
|
// changes microtask schedule and breaks "spy continues after rejection".
|
|
1127
1131
|
selfEmitting = true;
|
|
1128
1132
|
router
|
|
1129
|
-
|
|
1133
|
+
// Both channels of the CURRENT state, not just the path bag (RFC-4 M2 /
|
|
1134
|
+
// #1548): this is a same-route re-navigation to move the hash, so
|
|
1135
|
+
// whatever query the user is already looking at has to survive it.
|
|
1136
|
+
// Passing `undefined` in slot 3 dropped it — scrolling a page at
|
|
1137
|
+
// `/docs?tab=api` silently rewrote the URL to `/docs`. Options stay at
|
|
1138
|
+
// slot 4.
|
|
1139
|
+
.navigate(state.name, state.params, state.search, opts)
|
|
1130
1140
|
.catch(() => {
|
|
1131
1141
|
// Fire-and-forget — suppress expected rejections (concurrent
|
|
1132
1142
|
// navigate, router stopped, etc.) consistent with `<Link>` adapter
|
|
@@ -1306,6 +1316,34 @@ function createViewTransitions(router) {
|
|
|
1306
1316
|
};
|
|
1307
1317
|
}
|
|
1308
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* Collapses a `<Link>`'s two prop forms (RFC-4 M2 B2, #1548) into one channel
|
|
1321
|
+
* triple:
|
|
1322
|
+
*
|
|
1323
|
+
* - **Descriptor** — `to={{ name, params?, search? }}` (a `NavigationTarget`).
|
|
1324
|
+
* - **Channel props** — `routeName` + `routeParams?` + `routeSearch?`.
|
|
1325
|
+
*
|
|
1326
|
+
* The forms are mutually exclusive: the TS union on each adapter's `LinkProps`
|
|
1327
|
+
* rejects mixing them at compile time, and this helper is the runtime backstop —
|
|
1328
|
+
* when `to` is present it **wins**, and a `dev`-visible `console.warn` fires if
|
|
1329
|
+
* channel props were also supplied (a JS consumer, an object spread, or an
|
|
1330
|
+
* adapter without a strict union can still slip both through). `routeOptions` /
|
|
1331
|
+
* `hash` are separate props under BOTH forms (hash is not part of
|
|
1332
|
+
* `NavigationTarget` — #532), so they are resolved by the caller, not here.
|
|
1333
|
+
*/
|
|
1334
|
+
function resolveLinkTarget(to, routeName, routeParams, routeSearch) {
|
|
1335
|
+
if (to !== undefined) {
|
|
1336
|
+
if (routeName !== "" ||
|
|
1337
|
+
routeParams !== undefined ||
|
|
1338
|
+
routeSearch !== undefined) {
|
|
1339
|
+
console.warn("[real-router] <Link> received both `to` and channel props " +
|
|
1340
|
+
"(routeName / routeParams / routeSearch). `to` wins; the channel " +
|
|
1341
|
+
"props are ignored. Use one form or the other.");
|
|
1342
|
+
}
|
|
1343
|
+
return { name: to.name, params: to.params, search: to.search };
|
|
1344
|
+
}
|
|
1345
|
+
return { name: routeName, params: routeParams, search: routeSearch };
|
|
1346
|
+
}
|
|
1309
1347
|
function shouldNavigate(evt) {
|
|
1310
1348
|
return (evt.button === 0 &&
|
|
1311
1349
|
!evt.metaKey &&
|
|
@@ -1346,7 +1384,7 @@ function encodeFragmentInline(decoded) {
|
|
|
1346
1384
|
* passed positionally to mirror `navigateWithHash(router, name, params, hash)`
|
|
1347
1385
|
* (#1442). Previous 3-arg call sites continue to work unchanged.
|
|
1348
1386
|
*/
|
|
1349
|
-
function buildHref(router, routeName, routeParams, hash) {
|
|
1387
|
+
function buildHref(router, routeName, routeParams, routeSearch, hash) {
|
|
1350
1388
|
try {
|
|
1351
1389
|
let normHash;
|
|
1352
1390
|
if (hash !== undefined) {
|
|
@@ -1354,7 +1392,11 @@ function buildHref(router, routeName, routeParams, hash) {
|
|
|
1354
1392
|
}
|
|
1355
1393
|
const buildUrl = router.buildUrl;
|
|
1356
1394
|
if (buildUrl) {
|
|
1357
|
-
const url = buildUrl(routeName, routeParams,
|
|
1395
|
+
const url = buildUrl(routeName, routeParams,
|
|
1396
|
+
// Query channel at position 3 (RFC-4 M2 / #1548) — from the `routeSearch`
|
|
1397
|
+
// prop; hash options at position 4. `undefined` when the link has no
|
|
1398
|
+
// `routeSearch` (its query, if any, still rides in routeParams).
|
|
1399
|
+
routeSearch, normHash === undefined ? undefined : { hash: normHash });
|
|
1358
1400
|
// Accept only non-empty strings. The BuildUrlFn type contract is
|
|
1359
1401
|
// `string | undefined`, but defensive against:
|
|
1360
1402
|
// - `""` (empty string) → would render `<a href="">`, which resolves
|
|
@@ -1366,7 +1408,7 @@ function buildHref(router, routeName, routeParams, hash) {
|
|
|
1366
1408
|
return url;
|
|
1367
1409
|
}
|
|
1368
1410
|
}
|
|
1369
|
-
const path = router.buildPath(routeName, routeParams);
|
|
1411
|
+
const path = router.buildPath(routeName, routeParams, routeSearch);
|
|
1370
1412
|
// Symmetric to the buildUrl guard above (#S1 audit, Invariant 12).
|
|
1371
1413
|
// `router.buildPath` is typed `string`, but defends against:
|
|
1372
1414
|
// - `""` (empty string) — would render `<a href="">`, which resolves
|
|
@@ -1384,14 +1426,19 @@ function buildHref(router, routeName, routeParams, hash) {
|
|
|
1384
1426
|
return undefined;
|
|
1385
1427
|
}
|
|
1386
1428
|
}
|
|
1387
|
-
function navigateWithHash(router, routeName, routeParams, hash, extraOptions) {
|
|
1429
|
+
function navigateWithHash(router, routeName, routeParams, routeSearch, hash, extraOptions) {
|
|
1388
1430
|
const opts = { ...extraOptions };
|
|
1389
1431
|
if (hash !== undefined) {
|
|
1390
1432
|
opts.hash = hash;
|
|
1391
1433
|
}
|
|
1392
1434
|
const current = router.getState();
|
|
1393
1435
|
if (current?.name === routeName &&
|
|
1394
|
-
shallowEqual(current.params, routeParams)
|
|
1436
|
+
shallowEqual(current.params, routeParams) &&
|
|
1437
|
+
// Same-route hash bypass must also match the query channel (RFC-4 M2 /
|
|
1438
|
+
// #1548): a `routeSearch`-less link ignores it (compare current.search to
|
|
1439
|
+
// itself), so hash-only navigation on an unchanged query still bypasses
|
|
1440
|
+
// SAME_STATES.
|
|
1441
|
+
shallowEqual(current.search, routeSearch ?? current.search)) {
|
|
1395
1442
|
const currentHash = current.context?.url?.hash ??
|
|
1396
1443
|
"";
|
|
1397
1444
|
const newHash = hash ?? currentHash;
|
|
@@ -1400,7 +1447,9 @@ function navigateWithHash(router, routeName, routeParams, hash, extraOptions) {
|
|
|
1400
1447
|
opts.hashChange = true;
|
|
1401
1448
|
}
|
|
1402
1449
|
}
|
|
1403
|
-
|
|
1450
|
+
// Query channel at position 3 (RFC-4 M2 / #1548) — from the `routeSearch`
|
|
1451
|
+
// prop; opts at position 4. `undefined` when the link has no `routeSearch`.
|
|
1452
|
+
return router.navigate(routeName, routeParams, routeSearch, opts);
|
|
1404
1453
|
}
|
|
1405
1454
|
// Match-any-whitespace regex shared across calls. RegExp literals at
|
|
1406
1455
|
// call-site recompile in some engines; lifting it avoids that microcost
|
|
@@ -1947,7 +1996,7 @@ function injectRouterTransition() {
|
|
|
1947
1996
|
return sourceToSignal(source);
|
|
1948
1997
|
}
|
|
1949
1998
|
|
|
1950
|
-
function injectIsActiveRoute(routeName, params, options) {
|
|
1999
|
+
function injectIsActiveRoute(routeName, params, search, options) {
|
|
1951
2000
|
assertInInjectionContext(injectIsActiveRoute);
|
|
1952
2001
|
const router = injectRouter();
|
|
1953
2002
|
// Route through the shared fast/slow builder (mirrors RealLink / RealLinkActive):
|
|
@@ -1955,7 +2004,7 @@ function injectIsActiveRoute(routeName, params, options) {
|
|
|
1955
2004
|
// hash) shares the per-router createActiveNameSelector fast path instead of a
|
|
1956
2005
|
// dedicated createActiveRouteSource + subscription (#1437). Behavior-identical —
|
|
1957
2006
|
// createActiveRouteSource normalizes the options internally either way.
|
|
1958
|
-
const source = createActiveSource(router, routeName, params, options?.strict ?? false, options?.ignoreQueryParams ?? true, options?.hash);
|
|
2007
|
+
const source = createActiveSource(router, routeName, params, search, options?.strict ?? false, options?.ignoreQueryParams ?? true, options?.hash);
|
|
1959
2008
|
return sourceToSignal(source);
|
|
1960
2009
|
}
|
|
1961
2010
|
|
|
@@ -2497,6 +2546,19 @@ class RealLink {
|
|
|
2497
2546
|
// the same logical question into a second eager subscription (#776).
|
|
2498
2547
|
routeParams = input(undefined, /* @ts-ignore */
|
|
2499
2548
|
...(ngDevMode ? [{ debugName: "routeParams" }] : /* istanbul ignore next */ []));
|
|
2549
|
+
/**
|
|
2550
|
+
* Query (search) params for the link's target (RFC-4 M2, #1548) — parallel to
|
|
2551
|
+
* `routeParams`, the path/query split's view-layer channel.
|
|
2552
|
+
*/
|
|
2553
|
+
routeSearch = input(undefined, /* @ts-ignore */
|
|
2554
|
+
...(ngDevMode ? [{ debugName: "routeSearch" }] : /* istanbul ignore next */ []));
|
|
2555
|
+
/**
|
|
2556
|
+
* Descriptor form (RFC-4 M2 B2, #1548): `[to]="{ name, params?, search? }"` —
|
|
2557
|
+
* mutually exclusive with the routeName/routeParams/routeSearch channels
|
|
2558
|
+
* (runtime dev-warn on conflict via `resolveLinkTarget`, `to` wins).
|
|
2559
|
+
*/
|
|
2560
|
+
to = input(undefined, /* @ts-ignore */
|
|
2561
|
+
...(ngDevMode ? [{ debugName: "to" }] : /* istanbul ignore next */ []));
|
|
2500
2562
|
routeOptions = input({}, /* @ts-ignore */
|
|
2501
2563
|
...(ngDevMode ? [{ debugName: "routeOptions" }] : /* istanbul ignore next */ []));
|
|
2502
2564
|
activeClassName = input("active", /* @ts-ignore */
|
|
@@ -2529,7 +2591,10 @@ class RealLink {
|
|
|
2529
2591
|
// equality already collapses repeated `string` results, so no custom
|
|
2530
2592
|
// comparator is required (review §8b note 3 — applies after verifying that
|
|
2531
2593
|
// `buildHref` returns a primitive).
|
|
2532
|
-
href = computed(() =>
|
|
2594
|
+
href = computed(() => {
|
|
2595
|
+
const resolved = resolveLinkTarget(this.to(), this.routeName(), this.stableParams(), this.routeSearch());
|
|
2596
|
+
return buildHref(this.router, resolved.name, resolved.params ?? EMPTY_PARAMS, resolved.search, this.hash());
|
|
2597
|
+
}, /* @ts-ignore */
|
|
2533
2598
|
...(ngDevMode ? [{ debugName: "href" }] : /* istanbul ignore next */ []));
|
|
2534
2599
|
prevActiveClass = "";
|
|
2535
2600
|
prevHref = undefined;
|
|
@@ -2546,7 +2611,10 @@ class RealLink {
|
|
|
2546
2611
|
effect((onCleanup) => {
|
|
2547
2612
|
// Fast path (#1103) for default-options links — shared name selector
|
|
2548
2613
|
// instead of a per-link source; see `createActiveSource`.
|
|
2549
|
-
|
|
2614
|
+
// Resolve the two prop forms (RFC-4 M2 B2, #1548): `to` supersedes the
|
|
2615
|
+
// channel inputs (dev-warn on conflict).
|
|
2616
|
+
const resolved = resolveLinkTarget(this.to(), this.routeName(), this.stableParams(), this.routeSearch());
|
|
2617
|
+
const source = createActiveSource(this.router, resolved.name, resolved.params, resolved.search, this.activeStrict(), this.ignoreQueryParams(), this.hash());
|
|
2550
2618
|
onCleanup(subscribeSourceToSignal(source, (snap) => {
|
|
2551
2619
|
// Pure-href refresh: when the active flag did not change, only the
|
|
2552
2620
|
// href may have moved (e.g. param-only update on a parent route).
|
|
@@ -2568,7 +2636,8 @@ class RealLink {
|
|
|
2568
2636
|
return;
|
|
2569
2637
|
}
|
|
2570
2638
|
event.preventDefault();
|
|
2571
|
-
|
|
2639
|
+
const resolved = resolveLinkTarget(this.to(), this.routeName(), this.routeParams(), this.routeSearch());
|
|
2640
|
+
navigateWithHash(this.router, resolved.name, resolved.params ?? EMPTY_PARAMS, resolved.search, this.hash(), this.routeOptions()).catch(NOOP_CATCH);
|
|
2572
2641
|
}
|
|
2573
2642
|
updateHref() {
|
|
2574
2643
|
const href = this.href();
|
|
@@ -2588,7 +2657,7 @@ class RealLink {
|
|
|
2588
2657
|
this.prevActiveClass = activeClass;
|
|
2589
2658
|
}
|
|
2590
2659
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RealLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2591
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RealLink, isStandalone: true, selector: "a[realLink]", inputs: { routeName: { classPropertyName: "routeName", publicName: "routeName", isSignal: true, isRequired: false, transformFunction: null }, routeParams: { classPropertyName: "routeParams", publicName: "routeParams", isSignal: true, isRequired: false, transformFunction: null }, routeOptions: { classPropertyName: "routeOptions", publicName: "routeOptions", isSignal: true, isRequired: false, transformFunction: null }, activeClassName: { classPropertyName: "activeClassName", publicName: "activeClassName", isSignal: true, isRequired: false, transformFunction: null }, activeStrict: { classPropertyName: "activeStrict", publicName: "activeStrict", isSignal: true, isRequired: false, transformFunction: null }, ignoreQueryParams: { classPropertyName: "ignoreQueryParams", publicName: "ignoreQueryParams", isSignal: true, isRequired: false, transformFunction: null }, hash: { classPropertyName: "hash", publicName: "hash", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
|
|
2660
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: RealLink, isStandalone: true, selector: "a[realLink]", inputs: { routeName: { classPropertyName: "routeName", publicName: "routeName", isSignal: true, isRequired: false, transformFunction: null }, routeParams: { classPropertyName: "routeParams", publicName: "routeParams", isSignal: true, isRequired: false, transformFunction: null }, routeSearch: { classPropertyName: "routeSearch", publicName: "routeSearch", isSignal: true, isRequired: false, transformFunction: null }, to: { classPropertyName: "to", publicName: "to", isSignal: true, isRequired: false, transformFunction: null }, routeOptions: { classPropertyName: "routeOptions", publicName: "routeOptions", isSignal: true, isRequired: false, transformFunction: null }, activeClassName: { classPropertyName: "activeClassName", publicName: "activeClassName", isSignal: true, isRequired: false, transformFunction: null }, activeStrict: { classPropertyName: "activeStrict", publicName: "activeStrict", isSignal: true, isRequired: false, transformFunction: null }, ignoreQueryParams: { classPropertyName: "ignoreQueryParams", publicName: "ignoreQueryParams", isSignal: true, isRequired: false, transformFunction: null }, hash: { classPropertyName: "hash", publicName: "hash", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
|
|
2592
2661
|
}
|
|
2593
2662
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: RealLink, decorators: [{
|
|
2594
2663
|
type: Directive,
|
|
@@ -2598,7 +2667,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2598
2667
|
"(click)": "onClick($event)",
|
|
2599
2668
|
},
|
|
2600
2669
|
}]
|
|
2601
|
-
}], ctorParameters: () => [], propDecorators: { routeName: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeName", required: false }] }], routeParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeParams", required: false }] }], routeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeOptions", required: false }] }], activeClassName: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeClassName", required: false }] }], activeStrict: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeStrict", required: false }] }], ignoreQueryParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "ignoreQueryParams", required: false }] }], hash: [{ type: i0.Input, args: [{ isSignal: true, alias: "hash", required: false }] }] } });
|
|
2670
|
+
}], ctorParameters: () => [], propDecorators: { routeName: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeName", required: false }] }], routeParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeParams", required: false }] }], routeSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeSearch", required: false }] }], to: [{ type: i0.Input, args: [{ isSignal: true, alias: "to", required: false }] }], routeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeOptions", required: false }] }], activeClassName: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeClassName", required: false }] }], activeStrict: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeStrict", required: false }] }], ignoreQueryParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "ignoreQueryParams", required: false }] }], hash: [{ type: i0.Input, args: [{ isSignal: true, alias: "hash", required: false }] }] } });
|
|
2602
2671
|
|
|
2603
2672
|
class RealLinkActive {
|
|
2604
2673
|
realLinkActive = input("", /* @ts-ignore */
|
|
@@ -2639,7 +2708,10 @@ class RealLinkActive {
|
|
|
2639
2708
|
// Fast path (#1103) for default-options links — shared name selector
|
|
2640
2709
|
// instead of a per-link source; see `createActiveSource`. RealLinkActive
|
|
2641
2710
|
// has no `hash` input, so it is always passed `undefined`.
|
|
2642
|
-
const source = createActiveSource(this.router, this.routeName(), this.stableParams(),
|
|
2711
|
+
const source = createActiveSource(this.router, this.routeName(), this.stableParams(),
|
|
2712
|
+
// Query channel (RFC-4 M2, #1548) — RealLinkActive is styling-only and
|
|
2713
|
+
// has no `routeSearch` input (parity with its no-`hash` policy).
|
|
2714
|
+
undefined, this.activeStrict(), this.ignoreQueryParams(), undefined);
|
|
2643
2715
|
onCleanup(subscribeSourceToSignal(source, (snap) => {
|
|
2644
2716
|
if (snap === this.prevActive) {
|
|
2645
2717
|
return;
|