@mmstack/router-core 19.0.1 → 19.0.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025-present Miha Mulec
3
+ Copyright (c) 2025-present Miha J. Mulec
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,9 +1,173 @@
1
- import { inject, computed, isSignal, untracked } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { inject, Injectable, input, booleanAttribute, untracked, isDevMode, ElementRef, DestroyRef, Directive, computed, isSignal } from '@angular/core';
3
+ import * as i1 from '@angular/router';
4
+ import { Router, PreloadingStrategy, NoPreloading, PreloadAllModules, RouterPreloader, RouterLink, RouterLinkWithHref, ActivatedRoute, EventType } from '@angular/router';
5
+ import { EMPTY } from 'rxjs';
2
6
  import { toSignal } from '@angular/core/rxjs-interop';
3
- import { ActivatedRoute, Router, EventType } from '@angular/router';
4
7
  import { toWritable } from '@mmstack/primitives';
5
8
  import { filter, map } from 'rxjs/operators';
6
9
 
10
+ function flattenRoutes(routes) {
11
+ return routes;
12
+ }
13
+
14
+ function hasSlowConnection() {
15
+ if (globalThis.window &&
16
+ 'navigator' in globalThis.window &&
17
+ 'connection' in globalThis.window.navigator &&
18
+ typeof globalThis.window.navigator.connection === 'object' &&
19
+ !!globalThis.window.navigator.connection &&
20
+ 'effectiveType' in globalThis.window.navigator.connection &&
21
+ typeof globalThis.window.navigator.connection.effectiveType === 'string')
22
+ return globalThis.window.navigator.connection.effectiveType.endsWith('2g');
23
+ return false;
24
+ }
25
+ const HAS_SLOW_CONNECTION = hasSlowConnection();
26
+ function noPreload(route) {
27
+ return route.data && route.data['preload'] === false;
28
+ }
29
+ class PreloadLinkStrategy {
30
+ routeMap = flattenRoutes(inject(Router).config);
31
+ preload(route, fn) {
32
+ if (HAS_SLOW_CONNECTION || noPreload(route))
33
+ return EMPTY;
34
+ return EMPTY;
35
+ }
36
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: PreloadLinkStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
37
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: PreloadLinkStrategy, providedIn: 'root' });
38
+ }
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: PreloadLinkStrategy, decorators: [{
40
+ type: Injectable,
41
+ args: [{
42
+ providedIn: 'root',
43
+ }]
44
+ }] });
45
+ function observerSupported() {
46
+ return typeof IntersectionObserver !== 'undefined';
47
+ }
48
+ function injectPreloader() {
49
+ const strategy = inject(PreloadingStrategy, {
50
+ optional: true,
51
+ });
52
+ if (!strategy ||
53
+ strategy instanceof NoPreloading ||
54
+ strategy instanceof PreloadAllModules)
55
+ return null;
56
+ return inject(RouterPreloader, {
57
+ optional: true,
58
+ });
59
+ }
60
+ class VisibleLinkHandler {
61
+ map = new WeakMap();
62
+ observer = observerSupported()
63
+ ? new IntersectionObserver((entries) => {
64
+ entries.forEach((entry) => {
65
+ if (!entry.isIntersecting)
66
+ return;
67
+ this.map.get(entry.target)?.();
68
+ this.observer?.unobserve(entry.target);
69
+ });
70
+ })
71
+ : null;
72
+ register(el, onVisible) {
73
+ if (!this.observer)
74
+ return () => {
75
+ // noop
76
+ };
77
+ this.map.set(el, onVisible);
78
+ this.observer.observe(el);
79
+ return () => {
80
+ this.map.delete(el);
81
+ this.observer?.unobserve(el);
82
+ };
83
+ }
84
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: VisibleLinkHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
85
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: VisibleLinkHandler, providedIn: 'root' });
86
+ }
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: VisibleLinkHandler, decorators: [{
88
+ type: Injectable,
89
+ args: [{
90
+ providedIn: 'root',
91
+ }]
92
+ }] });
93
+ class LinkDirective {
94
+ routerLink = inject(RouterLink, {
95
+ self: true,
96
+ optional: true,
97
+ }) ?? inject(RouterLinkWithHref, { self: true, optional: true });
98
+ preloader = injectPreloader();
99
+ target = input();
100
+ queryParams = input();
101
+ fragment = input();
102
+ queryParamsHandling = input();
103
+ state = input();
104
+ info = input();
105
+ relativeTo = input();
106
+ skipLocationChange = input(false, { transform: booleanAttribute });
107
+ replaceUrl = input(false, { transform: booleanAttribute });
108
+ mmLink = input.required();
109
+ preloadOn = input(null);
110
+ onHover() {
111
+ if (untracked(this.preloadOn) !== 'hover')
112
+ return;
113
+ if (!this.preloader) {
114
+ if (isDevMode())
115
+ console.error('Preloader not available, please configure a preloading strategy');
116
+ return;
117
+ }
118
+ this.preloader?.preload().subscribe();
119
+ }
120
+ onVisible() {
121
+ if (untracked(this.preloadOn) !== 'visible')
122
+ return;
123
+ if (!this.preloader) {
124
+ if (isDevMode())
125
+ console.error('Preloader not available, please configure a preloading strategy');
126
+ return;
127
+ }
128
+ }
129
+ constructor() {
130
+ const el = inject(ElementRef, {
131
+ self: true,
132
+ });
133
+ const unsub = inject(VisibleLinkHandler).register(el.nativeElement, (() => {
134
+ this.onVisible();
135
+ }).bind(this));
136
+ inject(DestroyRef).onDestroy(() => unsub());
137
+ }
138
+ onClick(button, ctrlKey, shiftKey, altKey, metaKey) {
139
+ return this.routerLink?.onClick(button, ctrlKey, shiftKey, altKey, metaKey);
140
+ }
141
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: LinkDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
142
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.3", type: LinkDirective, isStandalone: true, selector: "[mmLink]", inputs: { target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: false, transformFunction: null }, queryParams: { classPropertyName: "queryParams", publicName: "queryParams", isSignal: true, isRequired: false, transformFunction: null }, fragment: { classPropertyName: "fragment", publicName: "fragment", isSignal: true, isRequired: false, transformFunction: null }, queryParamsHandling: { classPropertyName: "queryParamsHandling", publicName: "queryParamsHandling", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, info: { classPropertyName: "info", publicName: "info", isSignal: true, isRequired: false, transformFunction: null }, relativeTo: { classPropertyName: "relativeTo", publicName: "relativeTo", isSignal: true, isRequired: false, transformFunction: null }, skipLocationChange: { classPropertyName: "skipLocationChange", publicName: "skipLocationChange", isSignal: true, isRequired: false, transformFunction: null }, replaceUrl: { classPropertyName: "replaceUrl", publicName: "replaceUrl", isSignal: true, isRequired: false, transformFunction: null }, mmLink: { classPropertyName: "mmLink", publicName: "mmLink", isSignal: true, isRequired: true, transformFunction: null }, preloadOn: { classPropertyName: "preloadOn", publicName: "preloadOn", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "onHover()" } }, exportAs: ["mmLink"], hostDirectives: [{ directive: i1.RouterLink, inputs: ["routerLink", "mmLink", "target", "target", "queryParams", "queryParams", "fragment", "fragment", "queryParamsHandling", "queryParamsHandling", "state", "state", "relativeTo", "relativeTo", "skipLocationChange", "skipLocationChange", "replaceUrl", "replaceUrl"] }], ngImport: i0 });
143
+ }
144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: LinkDirective, decorators: [{
145
+ type: Directive,
146
+ args: [{
147
+ selector: '[mmLink]',
148
+ exportAs: 'mmLink',
149
+ host: {
150
+ '(mouseenter)': 'onHover()',
151
+ },
152
+ hostDirectives: [
153
+ {
154
+ directive: RouterLink,
155
+ inputs: [
156
+ 'routerLink: mmLink',
157
+ 'target',
158
+ 'queryParams',
159
+ 'fragment',
160
+ 'queryParamsHandling',
161
+ 'state',
162
+ 'relativeTo',
163
+ 'skipLocationChange',
164
+ 'replaceUrl',
165
+ ],
166
+ },
167
+ ],
168
+ }]
169
+ }], ctorParameters: () => [] });
170
+
7
171
  /**
8
172
  * Creates a WritableSignal that synchronizes with a specific URL query parameter,
9
173
  * enabling two-way binding between the signal's state and the URL.
@@ -163,5 +327,5 @@ function url() {
163
327
  * Generated bundle index. Do not edit.
164
328
  */
165
329
 
166
- export { queryParam, url };
330
+ export { LinkDirective, PreloadLinkStrategy, queryParam, url };
167
331
  //# sourceMappingURL=mmstack-router-core.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mmstack-router-core.mjs","sources":["../../../../../packages/router/core/src/lib/query-param.ts","../../../../../packages/router/core/src/lib/url.ts","../../../../../packages/router/core/src/mmstack-router-core.ts"],"sourcesContent":["import {\n computed,\n inject,\n isSignal,\n untracked,\n type WritableSignal,\n} from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { toWritable } from '@mmstack/primitives';\n\n/**\n * Creates a WritableSignal that synchronizes with a specific URL query parameter,\n * enabling two-way binding between the signal's state and the URL.\n *\n * Reading the signal provides the current value of the query parameter (or null if absent).\n * Setting the signal updates the URL query parameter using `Router.navigate`, triggering\n * navigation and causing the signal to update reactively if the navigation is successful.\n *\n * @param key The key of the query parameter to synchronize with.\n * Can be a static string (e.g., `'search'`) or a function/signal returning a string\n * for dynamic keys (e.g., `() => this.userId() + '_filter'` or `computed(() => this.category() + '_sort')`).\n * The signal will reactively update if the key returned by the function/signal changes.\n * @returns {WritableSignal<string | null>} A signal representing the query parameter's value.\n * - Reading returns the current value string, or `null` if the parameter is absent in the URL.\n * - Setting the signal to a string updates the query parameter in the URL (e.g., `signal.set('value')` results in `?key=value`).\n * - Setting the signal to `null` removes the query parameter from the URL (e.g., `signal.set(null)` results in `?otherParam=...`).\n * - Automatically reflects changes if the query parameters update due to external navigation.\n * @remarks\n * - Requires Angular's `ActivatedRoute` and `Router` to be available in the injection context.\n * - Uses `Router.navigate` with `queryParamsHandling: 'merge'` to preserve other existing query parameters during updates.\n * - Handles dynamic keys reactively. If the result of the `key` function/signal changes, the signal will start reflecting the value of the *new* query parameter key.\n * - During Server-Side Rendering (SSR), it reads the initial value from the route snapshot. Write operations (`set`) might have limited or no effect on the server depending on the platform configuration.\n *\n * @example\n * ```ts\n * import { Component, computed, effect, signal } from '@angular/core';\n * import { queryParam } from '@mmstack/router-core'; // Adjust import path as needed\n * // import { FormsModule } from '@angular/forms'; // If using ngModel\n *\n * @Component({\n * selector: 'app-product-list',\n * standalone: true,\n * // imports: [FormsModule], // If using ngModel\n * template: `\n * <div>\n * Sort By:\n * <select [value]=\"sortSignal() ?? ''\" (change)=\"sortSignal.set($any($event.target).value || null)\">\n * <option value=\"\">Default</option>\n * <option value=\"price_asc\">Price Asc</option>\n * <option value=\"price_desc\">Price Desc</option>\n * <option value=\"name\">Name</option>\n * </select>\n * <button (click)=\"sortSignal.set(null)\" [disabled]=\"!sortSignal()\">Clear Sort</button>\n * </div>\n * <div>\n * Page:\n * <input type=\"number\" min=\"1\" [value]=\"pageSignal() ?? '1'\" #p (input)=\"setPage(p.value)\"/>\n * </div>\n * * `\n * })\n * export class ProductListComponent {\n * // Two-way bind the 'sort' query parameter (?sort=...)\n * // Defaults to null if param is missing\n * sortSignal = queryParam('sort');\n *\n * // Example with a different type (needs serialization or separate logic)\n * // For simplicity, we treat page as string | null here\n * pageSignal = queryParam('page');\n *\n * constructor() {\n * effect(() => {\n * const currentSort = this.sortSignal();\n * const currentPage = this.pageSignal(); // Read as string | null\n * console.log('Sort/Page changed, reloading products for:', { sort: currentSort, page: currentPage });\n * // --- Fetch data based on currentSort and currentPage ---\n * });\n * }\n *\n * setPage(value: string): void {\n * const pageNum = parseInt(value, 10);\n * // Set to null if page is 1 (to remove param), otherwise set string value\n * this.pageSignal.set(isNaN(pageNum) || pageNum <= 1 ? null : pageNum.toString());\n * }\n * }\n * ```\n */\nexport function queryParam(\n key: string | (() => string),\n): WritableSignal<string | null> {\n const route = inject(ActivatedRoute);\n const router = inject(Router);\n\n const keySignal =\n typeof key === 'string'\n ? computed(() => key)\n : isSignal(key)\n ? key\n : computed(key);\n\n const queryParamMap = toSignal(route.queryParamMap, {\n initialValue: route.snapshot.queryParamMap,\n });\n\n const queryParams = toSignal(route.queryParams, {\n initialValue: route.snapshot.queryParams,\n });\n\n const queryParam = computed(() => queryParamMap().get(keySignal()));\n\n const set = (newValue: string | null) => {\n const next = {\n ...untracked(queryParams),\n };\n const key = untracked(keySignal);\n\n if (newValue === null) {\n delete next[key];\n } else {\n next[key] = newValue;\n }\n\n router.navigate([], {\n relativeTo: route,\n queryParams: next,\n queryParamsHandling: 'merge',\n });\n };\n\n return toWritable(queryParam, set);\n}\n","import { inject, type Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport {\n type Event,\n EventType,\n type NavigationEnd,\n Router,\n} from '@angular/router';\nimport { filter, map } from 'rxjs/operators';\n\n/**\n * Type guard to check if a Router Event is a NavigationEnd event.\n * @internal\n */\nfunction isNavigationEnd(e: Event): e is NavigationEnd {\n return 'type' in e && e.type === EventType.NavigationEnd;\n}\n\n/**\n * Creates a Signal that tracks the current router URL.\n *\n * The signal emits the URL string reflecting the router state *after* redirects\n * have completed for each successful navigation. It initializes with the router's\n * current URL state.\n *\n * @returns {Signal<string>} A Signal emitting the `urlAfterRedirects` upon successful navigation.\n *\n * @example\n * ```ts\n * import { Component, effect } from '@angular/core';\n * import { url } from '@mmstack/router-core'; // Adjust import path\n *\n * @Component({\n * selector: 'app-root',\n * template: `Current URL: {{ currentUrl() }}`\n * })\n * export class AppComponent {\n * currentUrl = url();\n *\n * constructor() {\n * effect(() => {\n * console.log('Navigation ended. New URL:', this.currentUrl());\n * // e.g., track page view with analytics\n * });\n * }\n * }\n * ```\n */\nexport function url(): Signal<string> {\n const router = inject(Router);\n\n return toSignal(\n router.events.pipe(\n filter(isNavigationEnd),\n map((e) => e.urlAfterRedirects),\n ),\n {\n initialValue: router.url,\n },\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EG;AACG,SAAU,UAAU,CACxB,GAA4B,EAAA;AAE5B,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;AACpC,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAE7B,IAAA,MAAM,SAAS,GACb,OAAO,GAAG,KAAK;AACb,UAAE,QAAQ,CAAC,MAAM,GAAG;AACpB,UAAE,QAAQ,CAAC,GAAG;AACZ,cAAE;AACF,cAAE,QAAQ,CAAC,GAAG,CAAC;AAErB,IAAA,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAE;AAClD,QAAA,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa;AAC3C,KAAA,CAAC;AAEF,IAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE;AAC9C,QAAA,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;AACzC,KAAA,CAAC;AAEF,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,aAAa,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;AAEnE,IAAA,MAAM,GAAG,GAAG,CAAC,QAAuB,KAAI;AACtC,QAAA,MAAM,IAAI,GAAG;YACX,GAAG,SAAS,CAAC,WAAW,CAAC;SAC1B;AACD,QAAA,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC;AAEhC,QAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,YAAA,OAAO,IAAI,CAAC,GAAG,CAAC;;aACX;AACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ;;AAGtB,QAAA,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE;AAClB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,mBAAmB,EAAE,OAAO;AAC7B,SAAA,CAAC;AACJ,KAAC;AAED,IAAA,OAAO,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC;AACpC;;ACxHA;;;AAGG;AACH,SAAS,eAAe,CAAC,CAAQ,EAAA;IAC/B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC1D;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;SACa,GAAG,GAAA;AACjB,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,OAAO,QAAQ,CACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,MAAM,CAAC,eAAe,CAAC,EACvB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAChC,EACD;QACE,YAAY,EAAE,MAAM,CAAC,GAAG;AACzB,KAAA,CACF;AACH;;AC5DA;;AAEG;;;;"}
1
+ {"version":3,"file":"mmstack-router-core.mjs","sources":["../../../../../packages/router/core/src/lib/preloading/flat-routes.ts","../../../../../packages/router/core/src/lib/preloading/link.directive.ts","../../../../../packages/router/core/src/lib/query-param.ts","../../../../../packages/router/core/src/lib/url.ts","../../../../../packages/router/core/src/mmstack-router-core.ts"],"sourcesContent":["import { Route } from '@angular/router';\n\nexport function flattenRoutes(routes: Route[]): Route[] {\n return routes;\n}\n","import {\r\n booleanAttribute,\r\n DestroyRef,\r\n Directive,\r\n ElementRef,\r\n inject,\r\n Injectable,\r\n input,\r\n isDevMode,\r\n untracked,\r\n} from '@angular/core';\r\nimport {\r\n NoPreloading,\r\n PreloadAllModules,\r\n PreloadingStrategy,\r\n Route,\r\n Router,\r\n RouterLink,\r\n RouterLinkWithHref,\r\n RouterPreloader,\r\n type ActivatedRoute,\r\n type Params,\r\n type UrlTree,\r\n} from '@angular/router';\r\nimport { EMPTY, Observable } from 'rxjs';\r\nimport { flattenRoutes } from './flat-routes';\r\n\r\nexport function hasSlowConnection() {\r\n if (\r\n globalThis.window &&\r\n 'navigator' in globalThis.window &&\r\n 'connection' in globalThis.window.navigator &&\r\n typeof globalThis.window.navigator.connection === 'object' &&\r\n !!globalThis.window.navigator.connection &&\r\n 'effectiveType' in globalThis.window.navigator.connection &&\r\n typeof globalThis.window.navigator.connection.effectiveType === 'string'\r\n )\r\n return globalThis.window.navigator.connection.effectiveType.endsWith('2g');\r\n\r\n return false;\r\n}\r\n\r\nconst HAS_SLOW_CONNECTION = hasSlowConnection();\r\n\r\nfunction noPreload(route: Route) {\r\n return route.data && route.data['preload'] === false;\r\n}\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class PreloadLinkStrategy implements PreloadingStrategy {\r\n private readonly routeMap = flattenRoutes(inject(Router).config);\r\n preload(route: Route, fn: () => Observable<any>): Observable<any> {\r\n if (HAS_SLOW_CONNECTION || noPreload(route)) return EMPTY;\r\n return EMPTY;\r\n }\r\n}\r\n\r\nfunction observerSupported() {\r\n return typeof IntersectionObserver !== 'undefined';\r\n}\r\n\r\nfunction injectPreloader(): RouterPreloader | null {\r\n const strategy = inject(PreloadingStrategy, {\r\n optional: true,\r\n });\r\n\r\n if (\r\n !strategy ||\r\n strategy instanceof NoPreloading ||\r\n strategy instanceof PreloadAllModules\r\n )\r\n return null;\r\n\r\n return inject(RouterPreloader, {\r\n optional: true,\r\n });\r\n}\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class VisibleLinkHandler {\r\n private readonly map = new WeakMap<Element, () => void>();\r\n private readonly observer: IntersectionObserver | null = observerSupported()\r\n ? new IntersectionObserver((entries) => {\r\n entries.forEach((entry) => {\r\n if (!entry.isIntersecting) return;\r\n this.map.get(entry.target)?.();\r\n this.observer?.unobserve(entry.target);\r\n });\r\n })\r\n : null;\r\n\r\n register(el: Element, onVisible: () => void) {\r\n if (!this.observer)\r\n return () => {\r\n // noop\r\n };\r\n\r\n this.map.set(el, onVisible);\r\n this.observer.observe(el);\r\n\r\n return () => {\r\n this.map.delete(el);\r\n this.observer?.unobserve(el);\r\n };\r\n }\r\n}\r\n\r\n@Directive({\r\n selector: '[mmLink]',\r\n exportAs: 'mmLink',\r\n host: {\r\n '(mouseenter)': 'onHover()',\r\n },\r\n hostDirectives: [\r\n {\r\n directive: RouterLink,\r\n inputs: [\r\n 'routerLink: mmLink',\r\n 'target',\r\n 'queryParams',\r\n 'fragment',\r\n 'queryParamsHandling',\r\n 'state',\r\n 'relativeTo',\r\n 'skipLocationChange',\r\n 'replaceUrl',\r\n ],\r\n },\r\n ],\r\n})\r\nexport class LinkDirective {\r\n private readonly routerLink =\r\n inject(RouterLink, {\r\n self: true,\r\n optional: true,\r\n }) ?? inject(RouterLinkWithHref, { self: true, optional: true });\r\n\r\n private readonly preloader = injectPreloader();\r\n readonly target = input<string>();\r\n readonly queryParams = input<Params>();\r\n readonly fragment = input<string>();\r\n readonly queryParamsHandling = input<'merge' | 'preserve' | ''>();\r\n readonly state = input<Record<string, any>>();\r\n readonly info = input<unknown>();\r\n readonly relativeTo = input<ActivatedRoute>();\r\n readonly skipLocationChange = input(false, { transform: booleanAttribute });\r\n readonly replaceUrl = input(false, { transform: booleanAttribute });\r\n readonly mmLink = input.required<string | any[] | UrlTree>();\r\n readonly preloadOn = input<null | 'hover' | 'visible'>(null);\r\n\r\n protected onHover() {\r\n if (untracked(this.preloadOn) !== 'hover') return;\r\n if (!this.preloader) {\r\n if (isDevMode())\r\n console.error(\r\n 'Preloader not available, please configure a preloading strategy',\r\n );\r\n return;\r\n }\r\n\r\n this.preloader?.preload().subscribe();\r\n }\r\n\r\n protected onVisible() {\r\n if (untracked(this.preloadOn) !== 'visible') return;\r\n if (!this.preloader) {\r\n if (isDevMode())\r\n console.error(\r\n 'Preloader not available, please configure a preloading strategy',\r\n );\r\n return;\r\n }\r\n }\r\n\r\n constructor() {\r\n const el = inject<ElementRef<HTMLElement>>(ElementRef, {\r\n self: true,\r\n });\r\n const unsub = inject(VisibleLinkHandler).register(\r\n el.nativeElement,\r\n (() => {\r\n this.onVisible();\r\n }).bind(this),\r\n );\r\n\r\n inject(DestroyRef).onDestroy(() => unsub());\r\n }\r\n\r\n onClick(\r\n button: number,\r\n ctrlKey: boolean,\r\n shiftKey: boolean,\r\n altKey: boolean,\r\n metaKey: boolean,\r\n ) {\r\n return this.routerLink?.onClick(button, ctrlKey, shiftKey, altKey, metaKey);\r\n }\r\n}\r\n","import {\n computed,\n inject,\n isSignal,\n untracked,\n type WritableSignal,\n} from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { toWritable } from '@mmstack/primitives';\n\n/**\n * Creates a WritableSignal that synchronizes with a specific URL query parameter,\n * enabling two-way binding between the signal's state and the URL.\n *\n * Reading the signal provides the current value of the query parameter (or null if absent).\n * Setting the signal updates the URL query parameter using `Router.navigate`, triggering\n * navigation and causing the signal to update reactively if the navigation is successful.\n *\n * @param key The key of the query parameter to synchronize with.\n * Can be a static string (e.g., `'search'`) or a function/signal returning a string\n * for dynamic keys (e.g., `() => this.userId() + '_filter'` or `computed(() => this.category() + '_sort')`).\n * The signal will reactively update if the key returned by the function/signal changes.\n * @returns {WritableSignal<string | null>} A signal representing the query parameter's value.\n * - Reading returns the current value string, or `null` if the parameter is absent in the URL.\n * - Setting the signal to a string updates the query parameter in the URL (e.g., `signal.set('value')` results in `?key=value`).\n * - Setting the signal to `null` removes the query parameter from the URL (e.g., `signal.set(null)` results in `?otherParam=...`).\n * - Automatically reflects changes if the query parameters update due to external navigation.\n * @remarks\n * - Requires Angular's `ActivatedRoute` and `Router` to be available in the injection context.\n * - Uses `Router.navigate` with `queryParamsHandling: 'merge'` to preserve other existing query parameters during updates.\n * - Handles dynamic keys reactively. If the result of the `key` function/signal changes, the signal will start reflecting the value of the *new* query parameter key.\n * - During Server-Side Rendering (SSR), it reads the initial value from the route snapshot. Write operations (`set`) might have limited or no effect on the server depending on the platform configuration.\n *\n * @example\n * ```ts\n * import { Component, computed, effect, signal } from '@angular/core';\n * import { queryParam } from '@mmstack/router-core'; // Adjust import path as needed\n * // import { FormsModule } from '@angular/forms'; // If using ngModel\n *\n * @Component({\n * selector: 'app-product-list',\n * standalone: true,\n * // imports: [FormsModule], // If using ngModel\n * template: `\n * <div>\n * Sort By:\n * <select [value]=\"sortSignal() ?? ''\" (change)=\"sortSignal.set($any($event.target).value || null)\">\n * <option value=\"\">Default</option>\n * <option value=\"price_asc\">Price Asc</option>\n * <option value=\"price_desc\">Price Desc</option>\n * <option value=\"name\">Name</option>\n * </select>\n * <button (click)=\"sortSignal.set(null)\" [disabled]=\"!sortSignal()\">Clear Sort</button>\n * </div>\n * <div>\n * Page:\n * <input type=\"number\" min=\"1\" [value]=\"pageSignal() ?? '1'\" #p (input)=\"setPage(p.value)\"/>\n * </div>\n * * `\n * })\n * export class ProductListComponent {\n * // Two-way bind the 'sort' query parameter (?sort=...)\n * // Defaults to null if param is missing\n * sortSignal = queryParam('sort');\n *\n * // Example with a different type (needs serialization or separate logic)\n * // For simplicity, we treat page as string | null here\n * pageSignal = queryParam('page');\n *\n * constructor() {\n * effect(() => {\n * const currentSort = this.sortSignal();\n * const currentPage = this.pageSignal(); // Read as string | null\n * console.log('Sort/Page changed, reloading products for:', { sort: currentSort, page: currentPage });\n * // --- Fetch data based on currentSort and currentPage ---\n * });\n * }\n *\n * setPage(value: string): void {\n * const pageNum = parseInt(value, 10);\n * // Set to null if page is 1 (to remove param), otherwise set string value\n * this.pageSignal.set(isNaN(pageNum) || pageNum <= 1 ? null : pageNum.toString());\n * }\n * }\n * ```\n */\nexport function queryParam(\n key: string | (() => string),\n): WritableSignal<string | null> {\n const route = inject(ActivatedRoute);\n const router = inject(Router);\n\n const keySignal =\n typeof key === 'string'\n ? computed(() => key)\n : isSignal(key)\n ? key\n : computed(key);\n\n const queryParamMap = toSignal(route.queryParamMap, {\n initialValue: route.snapshot.queryParamMap,\n });\n\n const queryParams = toSignal(route.queryParams, {\n initialValue: route.snapshot.queryParams,\n });\n\n const queryParam = computed(() => queryParamMap().get(keySignal()));\n\n const set = (newValue: string | null) => {\n const next = {\n ...untracked(queryParams),\n };\n const key = untracked(keySignal);\n\n if (newValue === null) {\n delete next[key];\n } else {\n next[key] = newValue;\n }\n\n router.navigate([], {\n relativeTo: route,\n queryParams: next,\n queryParamsHandling: 'merge',\n });\n };\n\n return toWritable(queryParam, set);\n}\n","import { inject, type Signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport {\n type Event,\n EventType,\n type NavigationEnd,\n Router,\n} from '@angular/router';\nimport { filter, map } from 'rxjs/operators';\n\n/**\n * Type guard to check if a Router Event is a NavigationEnd event.\n * @internal\n */\nfunction isNavigationEnd(e: Event): e is NavigationEnd {\n return 'type' in e && e.type === EventType.NavigationEnd;\n}\n\n/**\n * Creates a Signal that tracks the current router URL.\n *\n * The signal emits the URL string reflecting the router state *after* redirects\n * have completed for each successful navigation. It initializes with the router's\n * current URL state.\n *\n * @returns {Signal<string>} A Signal emitting the `urlAfterRedirects` upon successful navigation.\n *\n * @example\n * ```ts\n * import { Component, effect } from '@angular/core';\n * import { url } from '@mmstack/router-core'; // Adjust import path\n *\n * @Component({\n * selector: 'app-root',\n * template: `Current URL: {{ currentUrl() }}`\n * })\n * export class AppComponent {\n * currentUrl = url();\n *\n * constructor() {\n * effect(() => {\n * console.log('Navigation ended. New URL:', this.currentUrl());\n * // e.g., track page view with analytics\n * });\n * }\n * }\n * ```\n */\nexport function url(): Signal<string> {\n const router = inject(Router);\n\n return toSignal(\n router.events.pipe(\n filter(isNavigationEnd),\n map((e) => e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,EAAE,CAAC,CAAC;AAEnE,IAAA,MAAM,GAAG,GAAG,CAAC,QAAuB,KAAI;AACtC,QAAA,MAAM,IAAI,GAAG;YACX,GAAG,SAAS,CAAC,WAAW,CAAC;SAC1B;AACD,QAAA,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC;AAEhC,QAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,YAAA,OAAO,IAAI,CAAC,GAAG,CAAC;;aACX;AACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ;;AAGtB,QAAA,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE;AAClB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,mBAAmB,EAAE,OAAO;AAC7B,SAAA,CAAC;AACJ,KAAC;AAED,IAAA,OAAO,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC;AACpC;;ACxHA;;;AAGG;AACH,SAAS,eAAe,CAAC,CAAQ,EAAA;IAC/B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC1D;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;SACa,GAAG,GAAA;AACjB,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,OAAO,QAAQ,CACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,MAAM,CAAC,eAAe,CAAC,EACvB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAChC,EACD;QACE,YAAY,EAAE,MAAM,CAAC,GAAG;AACzB,KAAA,CACF;AACH;;AC5DA;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './lib/preloading/public_api';
1
2
  export * from './lib/query-param';
2
3
  export * from './lib/url';
@@ -0,0 +1,2 @@
1
+ import { Route } from '@angular/router';
2
+ export declare function flattenRoutes(routes: Route[]): Route[];
@@ -0,0 +1,39 @@
1
+ import { PreloadingStrategy, Route, type ActivatedRoute, type Params, type UrlTree } from '@angular/router';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from "@angular/core";
4
+ import * as i1 from "@angular/router";
5
+ export declare function hasSlowConnection(): boolean;
6
+ export declare class PreloadLinkStrategy implements PreloadingStrategy {
7
+ private readonly routeMap;
8
+ preload(route: Route, fn: () => Observable<any>): Observable<any>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<PreloadLinkStrategy, never>;
10
+ static ɵprov: i0.ɵɵInjectableDeclaration<PreloadLinkStrategy>;
11
+ }
12
+ export declare class VisibleLinkHandler {
13
+ private readonly map;
14
+ private readonly observer;
15
+ register(el: Element, onVisible: () => void): () => void;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<VisibleLinkHandler, never>;
17
+ static ɵprov: i0.ɵɵInjectableDeclaration<VisibleLinkHandler>;
18
+ }
19
+ export declare class LinkDirective {
20
+ private readonly routerLink;
21
+ private readonly preloader;
22
+ readonly target: import("@angular/core").InputSignal<string | undefined>;
23
+ readonly queryParams: import("@angular/core").InputSignal<Params | undefined>;
24
+ readonly fragment: import("@angular/core").InputSignal<string | undefined>;
25
+ readonly queryParamsHandling: import("@angular/core").InputSignal<"" | "merge" | "preserve" | undefined>;
26
+ readonly state: import("@angular/core").InputSignal<Record<string, any> | undefined>;
27
+ readonly info: import("@angular/core").InputSignal<unknown>;
28
+ readonly relativeTo: import("@angular/core").InputSignal<ActivatedRoute | undefined>;
29
+ readonly skipLocationChange: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
30
+ readonly replaceUrl: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
31
+ readonly mmLink: import("@angular/core").InputSignal<string | any[] | UrlTree>;
32
+ readonly preloadOn: import("@angular/core").InputSignal<"hover" | "visible" | null>;
33
+ protected onHover(): void;
34
+ protected onVisible(): void;
35
+ constructor();
36
+ onClick(button: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean | undefined;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<LinkDirective, never>;
38
+ static ɵdir: i0.ɵɵDirectiveDeclaration<LinkDirective, "[mmLink]", ["mmLink"], { "target": { "alias": "target"; "required": false; "isSignal": true; }; "queryParams": { "alias": "queryParams"; "required": false; "isSignal": true; }; "fragment": { "alias": "fragment"; "required": false; "isSignal": true; }; "queryParamsHandling": { "alias": "queryParamsHandling"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "info": { "alias": "info"; "required": false; "isSignal": true; }; "relativeTo": { "alias": "relativeTo"; "required": false; "isSignal": true; }; "skipLocationChange": { "alias": "skipLocationChange"; "required": false; "isSignal": true; }; "replaceUrl": { "alias": "replaceUrl"; "required": false; "isSignal": true; }; "mmLink": { "alias": "mmLink"; "required": true; "isSignal": true; }; "preloadOn": { "alias": "preloadOn"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.RouterLink; inputs: { "routerLink": "mmLink"; "target": "target"; "queryParams": "queryParams"; "fragment": "fragment"; "queryParamsHandling": "queryParamsHandling"; "state": "state"; "relativeTo": "relativeTo"; "skipLocationChange": "skipLocationChange"; "replaceUrl": "replaceUrl"; }; outputs: {}; }]>;
39
+ }
@@ -0,0 +1 @@
1
+ export { LinkDirective, PreloadLinkStrategy } from './link.directive';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/router-core",
3
- "version": "19.0.1",
3
+ "version": "19.0.2",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",
@@ -19,7 +19,7 @@
19
19
  "@angular/core": "^19.2.3",
20
20
  "@angular/router": "^19.2.3",
21
21
  "rxjs": "~7.8.2",
22
- "@mmstack/primitives": "^19.0.5"
22
+ "@mmstack/primitives": "^19.0.6"
23
23
  },
24
24
  "sideEffects": false,
25
25
  "module": "fesm2022/mmstack-router-core.mjs",