@real-router/angular 0.11.13 → 0.12.1
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 +2 -2
- package/dist/README.md +2 -2
- package/dist/fesm2022/real-router-angular-ssr.mjs +23 -16
- package/dist/fesm2022/real-router-angular-ssr.mjs.map +1 -1
- package/dist/fesm2022/real-router-angular.mjs +124 -51
- package/dist/fesm2022/real-router-angular.mjs.map +1 -1
- package/dist/package.json +57 -0
- package/dist/types/real-router-angular.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, DestroyRef, ApplicationRef, signal, InjectionToken, provideEnvironmentInitializer, makeEnvironmentProviders, makeStateKey, REQUEST, provideAppInitializer, TransferState, assertInInjectionContext, effect, input, TemplateRef, Directive, contentChildren, computed, Component, output, ElementRef } from '@angular/core';
|
|
3
3
|
import { getNavigator, UNKNOWN_ROUTE } from '@real-router/core';
|
|
4
|
-
import { getTransitionSource, createRouteSource, primeErrorSource, createRouteNodeSource, createActiveRouteSource, createDismissableError } from '@real-router/sources';
|
|
4
|
+
import { getTransitionSource, createRouteSource, primeErrorSource, createRouteNodeSource, createActiveRouteSource, createDismissableError, createActiveNameSelector } from '@real-router/sources';
|
|
5
5
|
import { cloneRouter, getPluginApi } from '@real-router/core/api';
|
|
6
6
|
import { hydrateRouter, serializeRouterState } from '@real-router/core/utils';
|
|
7
7
|
import { getRouteUtils, startsWithSegment } from '@real-router/route-utils';
|
|
@@ -1555,7 +1555,8 @@ function installViewTransitions() {
|
|
|
1555
1555
|
|
|
1556
1556
|
/** Must be called within an injection context (constructor, field initializer, runInInjectionContext). */
|
|
1557
1557
|
function sourceToSignal(source) {
|
|
1558
|
-
const sig = signal(source.getSnapshot(),
|
|
1558
|
+
const sig = signal(source.getSnapshot(), /* @ts-ignore */
|
|
1559
|
+
...(ngDevMode ? [{ debugName: "sig" }] : /* istanbul ignore next */ []));
|
|
1559
1560
|
const destroyRef = inject(DestroyRef);
|
|
1560
1561
|
const unsubscribe = source.subscribe(() => {
|
|
1561
1562
|
sig.set(source.getSnapshot());
|
|
@@ -2034,32 +2035,33 @@ function injectRouteEnter(handler, options) {
|
|
|
2034
2035
|
}
|
|
2035
2036
|
|
|
2036
2037
|
class RouteMatch {
|
|
2037
|
-
routeMatch = input.required(
|
|
2038
|
+
routeMatch = input.required(/* @ts-ignore */
|
|
2039
|
+
...(ngDevMode ? [{ debugName: "routeMatch" }] : /* istanbul ignore next */ []));
|
|
2038
2040
|
templateRef = inject(TemplateRef);
|
|
2039
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2040
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
2041
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteMatch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2042
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: RouteMatch, isStandalone: true, selector: "ng-template[routeMatch]", inputs: { routeMatch: { classPropertyName: "routeMatch", publicName: "routeMatch", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
2041
2043
|
}
|
|
2042
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2044
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteMatch, decorators: [{
|
|
2043
2045
|
type: Directive,
|
|
2044
2046
|
args: [{ selector: "ng-template[routeMatch]" }]
|
|
2045
2047
|
}], propDecorators: { routeMatch: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeMatch", required: true }] }] } });
|
|
2046
2048
|
|
|
2047
2049
|
class RouteNotFound {
|
|
2048
2050
|
templateRef = inject(TemplateRef);
|
|
2049
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2050
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
2051
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteNotFound, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2052
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: RouteNotFound, isStandalone: true, selector: "ng-template[routeNotFound]", ngImport: i0 });
|
|
2051
2053
|
}
|
|
2052
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2054
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteNotFound, decorators: [{
|
|
2053
2055
|
type: Directive,
|
|
2054
2056
|
args: [{ selector: "ng-template[routeNotFound]" }]
|
|
2055
2057
|
}] });
|
|
2056
2058
|
|
|
2057
2059
|
class RouteSelf {
|
|
2058
2060
|
templateRef = inject(TemplateRef);
|
|
2059
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2060
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
2061
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteSelf, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2062
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: RouteSelf, isStandalone: true, selector: "ng-template[routeSelf]", ngImport: i0 });
|
|
2061
2063
|
}
|
|
2062
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2064
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteSelf, decorators: [{
|
|
2063
2065
|
type: Directive,
|
|
2064
2066
|
args: [{ selector: "ng-template[routeSelf]" }]
|
|
2065
2067
|
}] });
|
|
@@ -2115,9 +2117,11 @@ class RouteView {
|
|
|
2115
2117
|
matches = contentChildren(RouteMatch, { ...(ngDevMode ? { debugName: "matches" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2116
2118
|
selfs = contentChildren(RouteSelf, { ...(ngDevMode ? { debugName: "selfs" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2117
2119
|
notFounds = contentChildren(RouteNotFound, { ...(ngDevMode ? { debugName: "notFounds" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2118
|
-
activeTemplate = computed(() => this.matchedTemplate() ?? this.fallbackTemplate(),
|
|
2120
|
+
activeTemplate = computed(() => this.matchedTemplate() ?? this.fallbackTemplate(), /* @ts-ignore */
|
|
2121
|
+
...(ngDevMode ? [{ debugName: "activeTemplate" }] : /* istanbul ignore next */ []));
|
|
2119
2122
|
router = injectRouter();
|
|
2120
|
-
routeState = signal(EMPTY_SNAPSHOT,
|
|
2123
|
+
routeState = signal(EMPTY_SNAPSHOT, /* @ts-ignore */
|
|
2124
|
+
...(ngDevMode ? [{ debugName: "routeState" }] : /* istanbul ignore next */ []));
|
|
2121
2125
|
matchEntries = computed(() => {
|
|
2122
2126
|
const nodeName = this.nodeName();
|
|
2123
2127
|
return this.matches().map((match) => {
|
|
@@ -2127,7 +2131,8 @@ class RouteView {
|
|
|
2127
2131
|
fullSegmentName: nodeName ? `${nodeName}.${segment}` : segment,
|
|
2128
2132
|
};
|
|
2129
2133
|
});
|
|
2130
|
-
},
|
|
2134
|
+
}, /* @ts-ignore */
|
|
2135
|
+
...(ngDevMode ? [{ debugName: "matchEntries" }] : /* istanbul ignore next */ []));
|
|
2131
2136
|
// The matched template (Match priority) is independent of the Self /
|
|
2132
2137
|
// NotFound fallback chain. Splitting the two paths into separate computeds
|
|
2133
2138
|
// localises re-runs: a change to `selfs()` / `notFounds()` no longer
|
|
@@ -2145,7 +2150,8 @@ class RouteView {
|
|
|
2145
2150
|
}
|
|
2146
2151
|
}
|
|
2147
2152
|
return null;
|
|
2148
|
-
},
|
|
2153
|
+
}, /* @ts-ignore */
|
|
2154
|
+
...(ngDevMode ? [{ debugName: "matchedTemplate" }] : /* istanbul ignore next */ []));
|
|
2149
2155
|
// Fallback chain — only consulted when `matchedTemplate()` returned `null`.
|
|
2150
2156
|
// Template priority: Self → NotFound. Selection rules differ on purpose:
|
|
2151
2157
|
// - **Self uses first-wins** (`.at(0)`) for parity with React / Preact /
|
|
@@ -2174,7 +2180,8 @@ class RouteView {
|
|
|
2174
2180
|
}
|
|
2175
2181
|
}
|
|
2176
2182
|
return null;
|
|
2177
|
-
},
|
|
2183
|
+
}, /* @ts-ignore */
|
|
2184
|
+
...(ngDevMode ? [{ debugName: "fallbackTemplate" }] : /* istanbul ignore next */ []));
|
|
2178
2185
|
constructor() {
|
|
2179
2186
|
// Reactive source-creation effect (#630 fix) — see
|
|
2180
2187
|
// `packages/angular/CLAUDE.md` → "Directives use constructor + effect()".
|
|
@@ -2185,14 +2192,14 @@ class RouteView {
|
|
|
2185
2192
|
}));
|
|
2186
2193
|
});
|
|
2187
2194
|
}
|
|
2188
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2189
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
2195
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteView, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2196
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: RouteView, isStandalone: true, selector: "route-view", inputs: { nodeName: { classPropertyName: "nodeName", publicName: "routeNode", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "matches", predicate: RouteMatch, descendants: true, isSignal: true }, { propertyName: "selfs", predicate: RouteSelf, descendants: true, isSignal: true }, { propertyName: "notFounds", predicate: RouteNotFound, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
2190
2197
|
@if (activeTemplate()) {
|
|
2191
2198
|
<ng-container [ngTemplateOutlet]="activeTemplate()!" />
|
|
2192
2199
|
}
|
|
2193
2200
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
2194
2201
|
}
|
|
2195
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2202
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouteView, decorators: [{
|
|
2196
2203
|
type: Component,
|
|
2197
2204
|
args: [{
|
|
2198
2205
|
selector: "route-view",
|
|
@@ -2206,7 +2213,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
2206
2213
|
}], ctorParameters: () => [], propDecorators: { nodeName: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeNode", required: false }] }], matches: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => RouteMatch), { ...{ descendants: true }, isSignal: true }] }], selfs: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => RouteSelf), { ...{ descendants: true }, isSignal: true }] }], notFounds: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => RouteNotFound), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
2207
2214
|
|
|
2208
2215
|
class RouterErrorBoundary {
|
|
2209
|
-
errorTemplate = input(
|
|
2216
|
+
errorTemplate = input(/* @ts-ignore */
|
|
2217
|
+
...(ngDevMode ? [undefined, { debugName: "errorTemplate" }] : /* istanbul ignore next */ []));
|
|
2210
2218
|
onError = output();
|
|
2211
2219
|
errorContext = computed(() => {
|
|
2212
2220
|
const snap = this.snapshot();
|
|
@@ -2217,7 +2225,8 @@ class RouterErrorBoundary {
|
|
|
2217
2225
|
$implicit: snap.error,
|
|
2218
2226
|
resetError: snap.resetError,
|
|
2219
2227
|
};
|
|
2220
|
-
},
|
|
2228
|
+
}, /* @ts-ignore */
|
|
2229
|
+
...(ngDevMode ? [{ debugName: "errorContext" }] : /* istanbul ignore next */ []));
|
|
2221
2230
|
router = injectRouter();
|
|
2222
2231
|
snapshot = sourceToSignal(createDismissableError(this.router));
|
|
2223
2232
|
constructor() {
|
|
@@ -2238,8 +2247,8 @@ class RouterErrorBoundary {
|
|
|
2238
2247
|
}
|
|
2239
2248
|
});
|
|
2240
2249
|
}
|
|
2241
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2242
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
2250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouterErrorBoundary, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2251
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: RouterErrorBoundary, isStandalone: true, selector: "router-error-boundary", inputs: { errorTemplate: { classPropertyName: "errorTemplate", publicName: "errorTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onError: "onError" }, ngImport: i0, template: `
|
|
2243
2252
|
<ng-content />
|
|
2244
2253
|
@if (errorContext() && errorTemplate()) {
|
|
2245
2254
|
<ng-container
|
|
@@ -2249,7 +2258,7 @@ class RouterErrorBoundary {
|
|
|
2249
2258
|
}
|
|
2250
2259
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
2251
2260
|
}
|
|
2252
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2261
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RouterErrorBoundary, decorators: [{
|
|
2253
2262
|
type: Component,
|
|
2254
2263
|
args: [{
|
|
2255
2264
|
selector: "router-error-boundary",
|
|
@@ -2273,10 +2282,10 @@ class NavigationAnnouncer {
|
|
|
2273
2282
|
this.announcer.destroy();
|
|
2274
2283
|
});
|
|
2275
2284
|
}
|
|
2276
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2277
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2285
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: NavigationAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2286
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: NavigationAnnouncer, isStandalone: true, selector: "navigation-announcer", ngImport: i0, template: "", isInline: true });
|
|
2278
2287
|
}
|
|
2279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2288
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: NavigationAnnouncer, decorators: [{
|
|
2280
2289
|
type: Component,
|
|
2281
2290
|
args: [{
|
|
2282
2291
|
selector: "navigation-announcer",
|
|
@@ -2284,6 +2293,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
2284
2293
|
}]
|
|
2285
2294
|
}], ctorParameters: () => [] });
|
|
2286
2295
|
|
|
2296
|
+
const NOOP = () => { };
|
|
2297
|
+
/**
|
|
2298
|
+
* Build the active-route `RouterSource<boolean>` for a Link-style directive
|
|
2299
|
+
* (`RealLink`, `RealLinkActive`), choosing a fast or slow path from the inputs.
|
|
2300
|
+
*
|
|
2301
|
+
* **Fast path (#1103)** — a default-options link (a non-empty `routeName`, no
|
|
2302
|
+
* custom `params`, non-strict, query params ignored, no `hash`) shares the
|
|
2303
|
+
* per-router `createActiveNameSelector`: ONE `router.subscribe` handle serves
|
|
2304
|
+
* any number of distinct-`routeName` links, instead of a per-link
|
|
2305
|
+
* `createActiveRouteSource` (which allocates a `BaseSource` AND opens its own
|
|
2306
|
+
* router subscription for every link). This mirrors the Svelte adapter's fast
|
|
2307
|
+
* path ([#1101](https://github.com/greydragon888/real-router/pull/1101)) and the
|
|
2308
|
+
* Solid `routeSelector`. The selector is wrapped as a `RouterSource<boolean>`
|
|
2309
|
+
* (its `isActive` is exactly non-strict, query-ignoring, name-only matching —
|
|
2310
|
+
* identical to the default `createActiveRouteSource`) so the caller's existing
|
|
2311
|
+
* `subscribeSourceToSignal` pipeline is unchanged. `destroy()` is a no-op: the
|
|
2312
|
+
* selector is per-router cached and lives with the router; the returned
|
|
2313
|
+
* subscribe's unsubscribe removes just this link's listener.
|
|
2314
|
+
*
|
|
2315
|
+
* **Slow path** — any deviation from the defaults (custom `params`,
|
|
2316
|
+
* `activeStrict`, `ignoreQueryParams: false`, hash-aware #532) falls to the
|
|
2317
|
+
* per-link `createActiveRouteSource`, whose cache handles the full argument
|
|
2318
|
+
* surface. An **empty `routeName`** also takes the slow path: it is a misuse (it
|
|
2319
|
+
* builds no `href` and logs a `console.error`), and the selector's root-active
|
|
2320
|
+
* semantics (`isActive("") === true`) would flip a misused link to active,
|
|
2321
|
+
* whereas `router.isActiveRoute("")` returns `false` — the slow path preserves
|
|
2322
|
+
* that behaviour.
|
|
2323
|
+
*/
|
|
2324
|
+
function createActiveSource(router, routeName, params, strict, ignoreQueryParams, hash) {
|
|
2325
|
+
if (routeName !== "" &&
|
|
2326
|
+
params === undefined &&
|
|
2327
|
+
!strict &&
|
|
2328
|
+
ignoreQueryParams &&
|
|
2329
|
+
hash === undefined) {
|
|
2330
|
+
const selector = createActiveNameSelector(router);
|
|
2331
|
+
return {
|
|
2332
|
+
subscribe: (listener) => selector.subscribe(routeName, listener),
|
|
2333
|
+
getSnapshot: () => selector.isActive(routeName),
|
|
2334
|
+
destroy: NOOP,
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
return createActiveRouteSource(router, routeName, params, buildActiveRouteOptions(strict, ignoreQueryParams, hash));
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2287
2340
|
/**
|
|
2288
2341
|
* Content-stable `routeParams` signal. Angular re-allocates an inline
|
|
2289
2342
|
* `[routeParams]="{ id: 1 }"` literal on every change detection, so a signal
|
|
@@ -2338,28 +2391,36 @@ const NOOP_CATCH = () => { };
|
|
|
2338
2391
|
// `injectIsActiveRoute(name)` instead of keying "{}" (#776).
|
|
2339
2392
|
const EMPTY_PARAMS = Object.freeze({});
|
|
2340
2393
|
class RealLink {
|
|
2341
|
-
routeName = input("",
|
|
2394
|
+
routeName = input("", /* @ts-ignore */
|
|
2395
|
+
...(ngDevMode ? [{ debugName: "routeName" }] : /* istanbul ignore next */ []));
|
|
2342
2396
|
// Default `undefined` (NOT {}): an omitted `routeParams` must reach
|
|
2343
2397
|
// `createActiveRouteSource` (via `stableParams`) as `undefined` so the active
|
|
2344
2398
|
// source keys "" and shares ONE cached source / router subscription with a
|
|
2345
2399
|
// manual `injectIsActiveRoute(name)`. Defaulting to {} keys "{}" and splits
|
|
2346
2400
|
// the same logical question into a second eager subscription (#776).
|
|
2347
|
-
routeParams = input(undefined,
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2401
|
+
routeParams = input(undefined, /* @ts-ignore */
|
|
2402
|
+
...(ngDevMode ? [{ debugName: "routeParams" }] : /* istanbul ignore next */ []));
|
|
2403
|
+
routeOptions = input({}, /* @ts-ignore */
|
|
2404
|
+
...(ngDevMode ? [{ debugName: "routeOptions" }] : /* istanbul ignore next */ []));
|
|
2405
|
+
activeClassName = input("active", /* @ts-ignore */
|
|
2406
|
+
...(ngDevMode ? [{ debugName: "activeClassName" }] : /* istanbul ignore next */ []));
|
|
2407
|
+
activeStrict = input(false, /* @ts-ignore */
|
|
2408
|
+
...(ngDevMode ? [{ debugName: "activeStrict" }] : /* istanbul ignore next */ []));
|
|
2409
|
+
ignoreQueryParams = input(true, /* @ts-ignore */
|
|
2410
|
+
...(ngDevMode ? [{ debugName: "ignoreQueryParams" }] : /* istanbul ignore next */ []));
|
|
2352
2411
|
/**
|
|
2353
2412
|
* URL fragment (decoded form, no leading "#") (#532).
|
|
2354
2413
|
* - omitted/`undefined` → preserve current fragment on same-route navigation
|
|
2355
2414
|
* - `""` → clear fragment
|
|
2356
2415
|
* - non-empty → set fragment
|
|
2357
2416
|
*/
|
|
2358
|
-
hash = input(undefined,
|
|
2417
|
+
hash = input(undefined, /* @ts-ignore */
|
|
2418
|
+
...(ngDevMode ? [{ debugName: "hash" }] : /* istanbul ignore next */ []));
|
|
2359
2419
|
router = injectRouter();
|
|
2360
2420
|
anchor = inject(ElementRef)
|
|
2361
2421
|
.nativeElement;
|
|
2362
|
-
isActive = signal(false,
|
|
2422
|
+
isActive = signal(false, /* @ts-ignore */
|
|
2423
|
+
...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
2363
2424
|
// Content-stable `routeParams` (#988). Angular re-allocates an inline
|
|
2364
2425
|
// `[routeParams]="{ id: 1 }"` literal on every change detection, so the raw
|
|
2365
2426
|
// signal input changes identity each navigation even when the param content
|
|
@@ -2374,7 +2435,8 @@ class RealLink {
|
|
|
2374
2435
|
href = computed(() => {
|
|
2375
2436
|
const hashValue = this.hash();
|
|
2376
2437
|
return buildHref(this.router, this.routeName(), this.stableParams() ?? EMPTY_PARAMS, hashValue === undefined ? undefined : { hash: hashValue });
|
|
2377
|
-
},
|
|
2438
|
+
}, /* @ts-ignore */
|
|
2439
|
+
...(ngDevMode ? [{ debugName: "href" }] : /* istanbul ignore next */ []));
|
|
2378
2440
|
prevActiveClass = "";
|
|
2379
2441
|
prevHref = undefined;
|
|
2380
2442
|
// Skip-same-value: only re-touch the DOM `class` list when the active state
|
|
@@ -2388,7 +2450,9 @@ class RealLink {
|
|
|
2388
2450
|
// source whenever any input changes; `onCleanup` tears the previous
|
|
2389
2451
|
// subscription down.
|
|
2390
2452
|
effect((onCleanup) => {
|
|
2391
|
-
|
|
2453
|
+
// Fast path (#1103) for default-options links — shared name selector
|
|
2454
|
+
// instead of a per-link source; see `createActiveSource`.
|
|
2455
|
+
const source = createActiveSource(this.router, this.routeName(), this.stableParams(), this.activeStrict(), this.ignoreQueryParams(), this.hash());
|
|
2392
2456
|
onCleanup(subscribeSourceToSignal(source, (snap) => {
|
|
2393
2457
|
// Pure-href refresh: when the active flag did not change, only the
|
|
2394
2458
|
// href may have moved (e.g. param-only update on a parent route).
|
|
@@ -2429,10 +2493,10 @@ class RealLink {
|
|
|
2429
2493
|
}
|
|
2430
2494
|
this.prevActiveClass = activeClass;
|
|
2431
2495
|
}
|
|
2432
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2433
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
2496
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RealLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2497
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", 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 });
|
|
2434
2498
|
}
|
|
2435
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RealLink, decorators: [{
|
|
2436
2500
|
type: Directive,
|
|
2437
2501
|
args: [{
|
|
2438
2502
|
selector: "a[realLink]",
|
|
@@ -2443,19 +2507,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
2443
2507
|
}], 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 }] }] } });
|
|
2444
2508
|
|
|
2445
2509
|
class RealLinkActive {
|
|
2446
|
-
realLinkActive = input("",
|
|
2447
|
-
|
|
2510
|
+
realLinkActive = input("", /* @ts-ignore */
|
|
2511
|
+
...(ngDevMode ? [{ debugName: "realLinkActive" }] : /* istanbul ignore next */ []));
|
|
2512
|
+
routeName = input("", /* @ts-ignore */
|
|
2513
|
+
...(ngDevMode ? [{ debugName: "routeName" }] : /* istanbul ignore next */ []));
|
|
2448
2514
|
// Default `undefined` (NOT {}): an omitted `routeParams` must reach
|
|
2449
2515
|
// `createActiveRouteSource` (via `stableParams`) as `undefined` so the active
|
|
2450
2516
|
// source keys "" and shares ONE cached source with a manual
|
|
2451
2517
|
// `injectIsActiveRoute(name)`, instead of keying "{}" and opening a second
|
|
2452
2518
|
// eager subscription for the same question (#776). Mirrors `RealLink`.
|
|
2453
|
-
routeParams = input(undefined,
|
|
2454
|
-
|
|
2455
|
-
|
|
2519
|
+
routeParams = input(undefined, /* @ts-ignore */
|
|
2520
|
+
...(ngDevMode ? [{ debugName: "routeParams" }] : /* istanbul ignore next */ []));
|
|
2521
|
+
activeStrict = input(false, /* @ts-ignore */
|
|
2522
|
+
...(ngDevMode ? [{ debugName: "activeStrict" }] : /* istanbul ignore next */ []));
|
|
2523
|
+
ignoreQueryParams = input(true, /* @ts-ignore */
|
|
2524
|
+
...(ngDevMode ? [{ debugName: "ignoreQueryParams" }] : /* istanbul ignore next */ []));
|
|
2456
2525
|
router = injectRouter();
|
|
2457
2526
|
element = inject(ElementRef).nativeElement;
|
|
2458
|
-
isActive = signal(false,
|
|
2527
|
+
isActive = signal(false, /* @ts-ignore */
|
|
2528
|
+
...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
2459
2529
|
// Content-stable `routeParams` (#988) — see the matching field in `RealLink`.
|
|
2460
2530
|
// Lets the source-creation effect bail until param content actually changes
|
|
2461
2531
|
// instead of churning on every fresh inline-literal binding.
|
|
@@ -2472,7 +2542,10 @@ class RealLinkActive {
|
|
|
2472
2542
|
// Reactive source-creation effect (#630 fix) — see
|
|
2473
2543
|
// `packages/angular/CLAUDE.md` → "Directives use constructor + effect()".
|
|
2474
2544
|
effect((onCleanup) => {
|
|
2475
|
-
|
|
2545
|
+
// Fast path (#1103) for default-options links — shared name selector
|
|
2546
|
+
// instead of a per-link source; see `createActiveSource`. RealLinkActive
|
|
2547
|
+
// has no `hash` input, so it is always passed `undefined`.
|
|
2548
|
+
const source = createActiveSource(this.router, this.routeName(), this.stableParams(), this.activeStrict(), this.ignoreQueryParams(), undefined);
|
|
2476
2549
|
onCleanup(subscribeSourceToSignal(source, (snap) => {
|
|
2477
2550
|
if (snap === this.prevActive) {
|
|
2478
2551
|
return;
|
|
@@ -2490,10 +2563,10 @@ class RealLinkActive {
|
|
|
2490
2563
|
}
|
|
2491
2564
|
this.element.classList.toggle(className, this.isActive());
|
|
2492
2565
|
}
|
|
2493
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2494
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
2566
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RealLinkActive, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2567
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: RealLinkActive, isStandalone: true, selector: "[realLinkActive]", inputs: { realLinkActive: { classPropertyName: "realLinkActive", publicName: "realLinkActive", isSignal: true, isRequired: false, transformFunction: null }, routeName: { classPropertyName: "routeName", publicName: "routeName", isSignal: true, isRequired: false, transformFunction: null }, routeParams: { classPropertyName: "routeParams", publicName: "routeParams", 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 } }, ngImport: i0 });
|
|
2495
2568
|
}
|
|
2496
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2569
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: RealLinkActive, decorators: [{
|
|
2497
2570
|
type: Directive,
|
|
2498
2571
|
args: [{ selector: "[realLinkActive]" }]
|
|
2499
2572
|
}], ctorParameters: () => [], propDecorators: { realLinkActive: [{ type: i0.Input, args: [{ isSignal: true, alias: "realLinkActive", required: false }] }], routeName: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeName", required: false }] }], routeParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeParams", required: false }] }], activeStrict: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeStrict", required: false }] }], ignoreQueryParams: [{ type: i0.Input, args: [{ isSignal: true, alias: "ignoreQueryParams", required: false }] }] } });
|