@ng-desktop/router 0.3.0 → 0.4.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 +47 -8
- package/fesm2022/index.d.ts +1 -1
- package/fesm2022/index.js +1 -1
- package/fesm2022/platform-location.d.ts +3 -1
- package/fesm2022/platform-location.js +32 -5
- package/fesm2022/route-strategies.d.ts +1 -1
- package/fesm2022/route-strategies.js +23 -8
- package/package.json +4 -3
- package/fesm2022/index.d.ts.map +0 -1
- package/fesm2022/index.js.map +0 -1
- package/fesm2022/platform-location.d.ts.map +0 -1
- package/fesm2022/platform-location.js.map +0 -1
- package/fesm2022/route-strategies.d.ts.map +0 -1
- package/fesm2022/route-strategies.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ng-desktop/router`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native in-memory `PlatformLocation` (`NativePlatformLocation`), route reuse strategy, and window title synchronization enabling `@angular/router` (`<router-outlet />`, `routerLink`, `withComponentInputBinding`, guards, and lazy routes) without a browser URL bar.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
5
|
+
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
pnpm add @ng-desktop/router
|
|
8
|
+
pnpm add @ng-desktop/router @ng-desktop/platform
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `@angular/core >= 22.0.0`, `@angular/router >= 22.0.0`, `@ng-desktop/platform`.
|
|
12
|
+
|
|
13
|
+
## Quick Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { ApplicationConfig } from '@angular/core';
|
|
17
|
+
import {
|
|
18
|
+
provideNativeRouter,
|
|
19
|
+
withComponentInputBinding,
|
|
20
|
+
withNativeTitleStrategy,
|
|
21
|
+
} from '@ng-desktop/router';
|
|
22
|
+
import { appRoutes } from './app.routes';
|
|
23
|
+
|
|
24
|
+
export const appConfig: ApplicationConfig = {
|
|
25
|
+
providers: [
|
|
26
|
+
provideNativeRouter(appRoutes, withComponentInputBinding()),
|
|
27
|
+
withNativeTitleStrategy('My Desktop App'),
|
|
28
|
+
],
|
|
29
|
+
};
|
|
11
30
|
```
|
|
12
31
|
|
|
13
|
-
|
|
14
|
-
|
|
32
|
+
Inside your root template:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<ng-window id="win" title="My Desktop App">
|
|
36
|
+
<ng-box orientation="vertical" spacing="12px">
|
|
37
|
+
<ng-button routerLink="/items">Catalog</ng-button>
|
|
38
|
+
<router-outlet />
|
|
39
|
+
</ng-box>
|
|
40
|
+
</ng-window>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Key Exports
|
|
44
|
+
|
|
45
|
+
- `provideNativeRouter`, `NativePlatformLocation`
|
|
46
|
+
- `withNativeTitleStrategy`, `NativeTitleStrategy`, `NATIVE_TITLE_PREFIX`
|
|
47
|
+
- `withNativeRouteReuse`, `NativeStackRouteReuseStrategy`
|
|
48
|
+
- Re-exported Angular router primitives: `Router`, `RouterOutlet`, `RouterLink`, `RouterLinkActive`, `ActivatedRoute`, `withComponentInputBinding`
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
- [Getting Started with External Angular 22+ & Nx Apps](../../docs/GETTING_STARTED.md)
|
|
53
|
+
- [Architectural Roadmap & OS Maturity Matrix](../../ROADMAP.md)
|
package/fesm2022/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
export { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive, RouterOutlet, withComponentInputBinding, type Routes, } from '@angular/router';
|
|
1
2
|
export { NativePlatformLocation, provideNativeRouter } from './platform-location';
|
|
2
3
|
export { NATIVE_TITLE_PREFIX, NativeStackRouteReuseStrategy, NativeTitleStrategy, withNativeRouteReuse, withNativeTitleStrategy, } from './route-strategies';
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/fesm2022/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
export { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive, RouterOutlet, withComponentInputBinding, } from '@angular/router';
|
|
1
2
|
export { NativePlatformLocation, provideNativeRouter } from './platform-location.js';
|
|
2
3
|
export { NATIVE_TITLE_PREFIX, NativeStackRouteReuseStrategy, NativeTitleStrategy, withNativeRouteReuse, withNativeTitleStrategy, } from './route-strategies.js';
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -25,9 +25,12 @@ export declare class NativePlatformLocation extends PlatformLocation {
|
|
|
25
25
|
get hash(): string;
|
|
26
26
|
replaceState(state: unknown, title: string, url: string): void;
|
|
27
27
|
pushState(state: unknown, title: string, url: string): void;
|
|
28
|
+
canGoBack(): boolean;
|
|
29
|
+
canGoForward(): boolean;
|
|
28
30
|
forward(): void;
|
|
29
31
|
back(): void;
|
|
30
32
|
historyGo(relativePosition?: number): void;
|
|
33
|
+
private notifyHashChange;
|
|
31
34
|
private currentEntry;
|
|
32
35
|
private normalizeUrl;
|
|
33
36
|
static ɵfac: i0.ɵɵFactoryDeclaration<NativePlatformLocation, never>;
|
|
@@ -37,4 +40,3 @@ export declare class NativePlatformLocation extends PlatformLocation {
|
|
|
37
40
|
* Provides `@angular/router` backed by `NativePlatformLocation` for DOM-free native windows.
|
|
38
41
|
*/
|
|
39
42
|
export declare function provideNativeRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders;
|
|
40
|
-
//# sourceMappingURL=platform-location.d.ts.map
|
|
@@ -65,13 +65,18 @@ export class NativePlatformLocation extends PlatformLocation {
|
|
|
65
65
|
return hIdx === -1 ? '' : raw.slice(hIdx);
|
|
66
66
|
}
|
|
67
67
|
replaceState(state, title, url) {
|
|
68
|
+
const prevHash = this.hash;
|
|
68
69
|
this.historyStack[this.currentIndex] = {
|
|
69
70
|
url: this.normalizeUrl(url),
|
|
70
71
|
title,
|
|
71
72
|
state,
|
|
72
73
|
};
|
|
74
|
+
if (this.hash !== prevHash) {
|
|
75
|
+
this.notifyHashChange(state);
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
pushState(state, title, url) {
|
|
79
|
+
const prevHash = this.hash;
|
|
75
80
|
this.historyStack.splice(this.currentIndex + 1);
|
|
76
81
|
this.historyStack.push({
|
|
77
82
|
url: this.normalizeUrl(url),
|
|
@@ -79,6 +84,15 @@ export class NativePlatformLocation extends PlatformLocation {
|
|
|
79
84
|
state,
|
|
80
85
|
});
|
|
81
86
|
this.currentIndex = this.historyStack.length - 1;
|
|
87
|
+
if (this.hash !== prevHash) {
|
|
88
|
+
this.notifyHashChange(state);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
canGoBack() {
|
|
92
|
+
return this.currentIndex > 0;
|
|
93
|
+
}
|
|
94
|
+
canGoForward() {
|
|
95
|
+
return this.currentIndex + 1 < this.historyStack.length;
|
|
82
96
|
}
|
|
83
97
|
forward() {
|
|
84
98
|
this.historyGo(1);
|
|
@@ -94,14 +108,28 @@ export class NativePlatformLocation extends PlatformLocation {
|
|
|
94
108
|
if (nextIdx < 0 || nextIdx >= this.historyStack.length) {
|
|
95
109
|
return;
|
|
96
110
|
}
|
|
111
|
+
const prevHash = this.hash;
|
|
97
112
|
this.currentIndex = nextIdx;
|
|
113
|
+
const state = this.currentEntry().state;
|
|
98
114
|
const evt = {
|
|
99
115
|
type: 'popstate',
|
|
100
|
-
state
|
|
116
|
+
state,
|
|
101
117
|
};
|
|
102
118
|
for (const listener of this.popStateListeners) {
|
|
103
119
|
listener(evt);
|
|
104
120
|
}
|
|
121
|
+
if (this.hash !== prevHash) {
|
|
122
|
+
this.notifyHashChange(state);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
notifyHashChange(state) {
|
|
126
|
+
const evt = {
|
|
127
|
+
type: 'hashchange',
|
|
128
|
+
state,
|
|
129
|
+
};
|
|
130
|
+
for (const listener of this.hashChangeListeners) {
|
|
131
|
+
listener(evt);
|
|
132
|
+
}
|
|
105
133
|
}
|
|
106
134
|
currentEntry() {
|
|
107
135
|
return (this.historyStack[this.currentIndex] ?? {
|
|
@@ -117,10 +145,10 @@ export class NativePlatformLocation extends PlatformLocation {
|
|
|
117
145
|
}
|
|
118
146
|
return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
119
147
|
}
|
|
120
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
121
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
148
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativePlatformLocation, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
149
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativePlatformLocation, providedIn: 'root' });
|
|
122
150
|
}
|
|
123
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativePlatformLocation, decorators: [{
|
|
124
152
|
type: Injectable,
|
|
125
153
|
args: [{ providedIn: 'root' }]
|
|
126
154
|
}] });
|
|
@@ -134,4 +162,3 @@ export function provideNativeRouter(routes, ...features) {
|
|
|
134
162
|
withNativeTitleStrategy(),
|
|
135
163
|
]);
|
|
136
164
|
}
|
|
137
|
-
//# sourceMappingURL=platform-location.js.map
|
|
@@ -28,6 +28,7 @@ export declare class NativeStackRouteReuseStrategy implements RouteReuseStrategy
|
|
|
28
28
|
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
|
|
29
29
|
retrieveStoredRouteHandles(): DetachedRouteHandle[];
|
|
30
30
|
clearCache(): void;
|
|
31
|
+
private destroyDetachedHandle;
|
|
31
32
|
cachedRoutes(): string[];
|
|
32
33
|
private routeKey;
|
|
33
34
|
static ɵfac: i0.ɵɵFactoryDeclaration<NativeStackRouteReuseStrategy, never>;
|
|
@@ -35,4 +36,3 @@ export declare class NativeStackRouteReuseStrategy implements RouteReuseStrategy
|
|
|
35
36
|
}
|
|
36
37
|
export declare function withNativeTitleStrategy(appPrefix?: string): EnvironmentProviders;
|
|
37
38
|
export declare function withNativeRouteReuse(): EnvironmentProviders;
|
|
38
|
-
//# sourceMappingURL=route-strategies.d.ts.map
|
|
@@ -20,10 +20,10 @@ export class NativeTitleStrategy extends TitleStrategy {
|
|
|
20
20
|
this.titleService.setTitle(resolved);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
24
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
23
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeTitleStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
24
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeTitleStrategy, providedIn: 'root' });
|
|
25
25
|
}
|
|
26
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeTitleStrategy, decorators: [{
|
|
27
27
|
type: Injectable,
|
|
28
28
|
args: [{ providedIn: 'root' }]
|
|
29
29
|
}] });
|
|
@@ -46,13 +46,19 @@ export class NativeStackRouteReuseStrategy {
|
|
|
46
46
|
if (!key) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
+
const existing = this.handles.get(key);
|
|
49
50
|
if (handle === null) {
|
|
51
|
+
this.destroyDetachedHandle(existing);
|
|
50
52
|
this.handles.delete(key);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
|
-
if (
|
|
55
|
+
if (existing && existing !== handle) {
|
|
56
|
+
this.destroyDetachedHandle(existing);
|
|
57
|
+
}
|
|
58
|
+
if (!existing && this.handles.size >= this.maxCachedPages) {
|
|
54
59
|
const oldestKey = this.handles.keys().next().value;
|
|
55
60
|
if (oldestKey !== undefined) {
|
|
61
|
+
this.destroyDetachedHandle(this.handles.get(oldestKey));
|
|
56
62
|
this.handles.delete(oldestKey);
|
|
57
63
|
}
|
|
58
64
|
}
|
|
@@ -77,8 +83,18 @@ export class NativeStackRouteReuseStrategy {
|
|
|
77
83
|
return Array.from(this.handles.values());
|
|
78
84
|
}
|
|
79
85
|
clearCache() {
|
|
86
|
+
for (const handle of this.handles.values()) {
|
|
87
|
+
this.destroyDetachedHandle(handle);
|
|
88
|
+
}
|
|
80
89
|
this.handles.clear();
|
|
81
90
|
}
|
|
91
|
+
destroyDetachedHandle(handle) {
|
|
92
|
+
if (!handle || typeof handle !== 'object') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const componentRef = handle.componentRef;
|
|
96
|
+
componentRef?.destroy?.();
|
|
97
|
+
}
|
|
82
98
|
cachedRoutes() {
|
|
83
99
|
return Array.from(this.handles.keys());
|
|
84
100
|
}
|
|
@@ -91,10 +107,10 @@ export class NativeStackRouteReuseStrategy {
|
|
|
91
107
|
}
|
|
92
108
|
return route.routeConfig?.path ?? '';
|
|
93
109
|
}
|
|
94
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
95
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
110
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeStackRouteReuseStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
111
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeStackRouteReuseStrategy, providedIn: 'root' });
|
|
96
112
|
}
|
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeStackRouteReuseStrategy, decorators: [{
|
|
98
114
|
type: Injectable,
|
|
99
115
|
args: [{ providedIn: 'root' }]
|
|
100
116
|
}] });
|
|
@@ -111,4 +127,3 @@ export function withNativeRouteReuse() {
|
|
|
111
127
|
{ provide: RouteReuseStrategy, useExisting: NativeStackRouteReuseStrategy },
|
|
112
128
|
]);
|
|
113
129
|
}
|
|
114
|
-
//# sourceMappingURL=route-strategies.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-desktop/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "DOM-free Angular Router PlatformLocation & navigation stack for Native GTK4 / WinUI 3 / AppKit windows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"fesm2022",
|
|
32
32
|
"README.md",
|
|
33
|
-
"LICENSE"
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"!**/*.map"
|
|
34
35
|
],
|
|
35
36
|
"main": "./fesm2022/index.js",
|
|
36
37
|
"module": "./fesm2022/index.js",
|
|
@@ -48,6 +49,6 @@
|
|
|
48
49
|
"@angular/common": ">=22.0.0",
|
|
49
50
|
"@angular/core": ">=22.0.0",
|
|
50
51
|
"@angular/router": ">=22.0.0",
|
|
51
|
-
"@ng-desktop/platform": ">=0.
|
|
52
|
+
"@ng-desktop/platform": ">=0.4.0"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/fesm2022/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/router-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/fesm2022/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/router-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC","sourcesContent":["export { NativePlatformLocation, provideNativeRouter } from './platform-location';\nexport {\n NATIVE_TITLE_PREFIX,\n NativeStackRouteReuseStrategy,\n NativeTitleStrategy,\n withNativeRouteReuse,\n withNativeTitleStrategy,\n} from './route-strategies';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform-location.d.ts","sourceRoot":"","sources":["../../../../packages/router-native/src/platform-location.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,oBAAoB,EAAwC,MAAM,eAAe,CAAC;AAChG,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AASlF;;;;GAIG;AACH,qBACa,sBAAuB,SAAQ,gBAAgB;IAC1D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0D;IACvF,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO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E,CAAC,KAAK;SACjC,CAAC;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC9C,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAEO,YAAY;QAClB,OAAO,CACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI;YACtC,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,IAAI;SACZ,CACF,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,GAAW;QAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;IAC3D,CAAC;uGA/HU,sBAAsB;2GAAtB,sBAAsB,cADT,MAAM;;2FACnB,sBAAsB;kBADlC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;AAmIlC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,GAAG,QAA0B;IAE7B,OAAO,wBAAwB,CAAC;QAC9B,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAE;QAClE,aAAa,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC;QAClC,uBAAuB,EAAE;KAC1B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type LocationChangeEvent,\n type LocationChangeListener,\n PlatformLocation,\n} from '@angular/common';\nimport { type EnvironmentProviders, Injectable, makeEnvironmentProviders } from '@angular/core';\nimport { provideRouter, type RouterFeatures, type Routes } from '@angular/router';\nimport { withNativeTitleStrategy } from './route-strategies';\n\ninterface HistoryEntry {\n url: string;\n title: string;\n state: unknown;\n}\n\n/**\n * DOM-free Angular `PlatformLocation` implementation for native desktop applications.\n * Maintains an in-memory URL and state history stack so `@angular/router` (`<router-outlet>`,\n * `routerLink`, guards, resolvers, lazy loading) runs natively without `window.location`.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativePlatformLocation extends PlatformLocation {\n private readonly historyStack: HistoryEntry[] = [{ url: '/', title: '', state: null }];\n private currentIndex = 0;\n private readonly popStateListeners = new Set<LocationChangeListener>();\n private readonly hashChangeListeners = new Set<LocationChangeListener>();\n\n readonly hostname = 'ng-native.local';\n readonly protocol = 'ng-native:';\n readonly port = '';\n\n override getBaseHrefFromDOM(): string {\n return '/';\n }\n\n override getState(): unknown {\n return this.currentEntry().state;\n }\n\n override onPopState(fn: LocationChangeListener): VoidFunction {\n this.popStateListeners.add(fn);\n return () => {\n this.popStateListeners.delete(fn);\n };\n }\n\n override onHashChange(fn: LocationChangeListener): VoidFunction {\n this.hashChangeListeners.add(fn);\n return () => {\n this.hashChangeListeners.delete(fn);\n };\n }\n\n override get href(): string {\n return `${this.protocol}//${this.hostname}${this.currentEntry().url}`;\n }\n\n override get pathname(): string {\n const raw = this.currentEntry().url;\n const qIdx = raw.indexOf('?');\n const hIdx = raw.indexOf('#');\n const end =\n qIdx !== -1 && hIdx !== -1\n ? Math.min(qIdx, hIdx)\n : qIdx !== -1\n ? qIdx\n : hIdx !== -1\n ? hIdx\n : raw.length;\n return raw.slice(0, end) || '/';\n }\n\n override get search(): string {\n const raw = this.currentEntry().url;\n const qIdx = raw.indexOf('?');\n if (qIdx === -1) {\n return '';\n }\n const hIdx = raw.indexOf('#', qIdx);\n return hIdx === -1 ? raw.slice(qIdx) : raw.slice(qIdx, hIdx);\n }\n\n override get hash(): string {\n const raw = this.currentEntry().url;\n const hIdx = raw.indexOf('#');\n return hIdx === -1 ? '' : raw.slice(hIdx);\n }\n\n override replaceState(state: unknown, title: string, url: string): void {\n this.historyStack[this.currentIndex] = {\n url: this.normalizeUrl(url),\n title,\n state,\n };\n }\n\n override pushState(state: unknown, title: string, url: string): void {\n this.historyStack.splice(this.currentIndex + 1);\n this.historyStack.push({\n url: this.normalizeUrl(url),\n title,\n state,\n });\n this.currentIndex = this.historyStack.length - 1;\n }\n\n override forward(): void {\n this.historyGo(1);\n }\n\n override back(): void {\n this.historyGo(-1);\n }\n\n override historyGo(relativePosition = 0): void {\n if (relativePosition === 0) {\n return;\n }\n const nextIdx = this.currentIndex + relativePosition;\n if (nextIdx < 0 || nextIdx >= this.historyStack.length) {\n return;\n }\n this.currentIndex = nextIdx;\n const evt: LocationChangeEvent = {\n type: 'popstate',\n state: this.currentEntry().state,\n };\n for (const listener of this.popStateListeners) {\n listener(evt);\n }\n }\n\n private currentEntry(): HistoryEntry {\n return (\n this.historyStack[this.currentIndex] ?? {\n url: '/',\n title: '',\n state: null,\n }\n );\n }\n\n private normalizeUrl(url: string): string {\n const trimmed = url.trim();\n if (!trimmed) {\n return '/';\n }\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n }\n}\n\n/**\n * Provides `@angular/router` backed by `NativePlatformLocation` for DOM-free native windows.\n */\nexport function provideNativeRouter(\n routes: Routes,\n ...features: RouterFeatures[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: PlatformLocation, useExisting: NativePlatformLocation },\n provideRouter(routes, ...features),\n withNativeTitleStrategy(),\n ]);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-strategies.d.ts","sourceRoot":"","sources":["../../../../packages/router-native/src/route-strategies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,cAAc,EAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACd,MAAM,iBAAiB,CAAC;;AAGzB,eAAO,MAAM,mBAAmB,wBAG9B,CAAC;AAEH;;;GAGG;AACH,qBACa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,QA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,CAAC;AACL,CAAC","sourcesContent":["import {\n EnvironmentProviders,\n inject,\n Injectable,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n DetachedRouteHandle,\n RouteReuseStrategy,\n RouterStateSnapshot,\n TitleStrategy,\n} from '@angular/router';\nimport { NativeTitleService } from '@ng-desktop/platform';\n\nexport const NATIVE_TITLE_PREFIX = new InjectionToken<string>('NATIVE_TITLE_PREFIX', {\n providedIn: 'root',\n factory: () => '',\n});\n\n/**\n * Angular `TitleStrategy` that mirrors active route titles directly onto the OS window\n * (`gtk_window_set_title` / `NSWindow.title` / `AppWindow.Title`) via `NativeTitleService`.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeTitleStrategy extends TitleStrategy {\n private readonly titleService = inject(NativeTitleService);\n private readonly appPrefix = inject(NATIVE_TITLE_PREFIX);\n\n override updateTitle(snapshot: RouterStateSnapshot): void {\n const routeTitle = this.buildTitle(snapshot);\n if (routeTitle !== undefined) {\n const resolved = this.appPrefix ? `${this.appPrefix} — ${routeTitle}` : routeTitle;\n this.titleService.setTitle(resolved);\n }\n }\n}\n\n/**\n * Bounded `RouteReuseStrategy` tailored for native desktop navigation stacks (`GtkStack` /\n * `AdwNavigationView`): preserves mounted page handles so back/forward transitions stay instant\n * with scroll, focus, and state intact.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeStackRouteReuseStrategy implements RouteReuseStrategy {\n private readonly handles = new Map<string, DetachedRouteHandle>();\n private readonly maxCachedPages = 16;\n\n shouldDetach(route: ActivatedRouteSnapshot): boolean {\n if (!route.routeConfig || route.routeConfig.loadChildren) {\n return false;\n }\n return route.data['reuse'] !== false;\n }\n\n store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void {\n const key = this.routeKey(route);\n if (!key) {\n return;\n }\n if (handle === null) {\n this.handles.delete(key);\n return;\n }\n if (!this.handles.has(key) && this.handles.size >= this.maxCachedPages) {\n const oldestKey = this.handles.keys().next().value;\n if (oldestKey !== undefined) {\n this.handles.delete(oldestKey);\n }\n }\n this.handles.delete(key);\n this.handles.set(key, handle);\n }\n\n shouldAttach(route: ActivatedRouteSnapshot): boolean {\n const key = this.routeKey(route);\n return key.length > 0 && this.handles.has(key);\n }\n\n retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null {\n const key = this.routeKey(route);\n if (!key) {\n return null;\n }\n return this.handles.get(key) ?? null;\n }\n\n shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {\n return future.routeConfig === curr.routeConfig;\n }\n\n retrieveStoredRouteHandles(): DetachedRouteHandle[] {\n return Array.from(this.handles.values());\n }\n\n clearCache(): void {\n this.handles.clear();\n }\n\n cachedRoutes(): string[] {\n return Array.from(this.handles.keys());\n }\n\n private routeKey(route: ActivatedRouteSnapshot): string {\n const segments = route.pathFromRoot\n .flatMap((snap) => snap.url.map((seg) => seg.path))\n .filter(Boolean);\n if (segments.length > 0) {\n return `/${segments.join('/')}`;\n }\n return route.routeConfig?.path ?? '';\n }\n}\n\nexport function withNativeTitleStrategy(appPrefix = ''): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: NATIVE_TITLE_PREFIX, useValue: appPrefix },\n NativeTitleStrategy,\n { provide: TitleStrategy, useExisting: NativeTitleStrategy },\n ]);\n}\n\nexport function withNativeRouteReuse(): EnvironmentProviders {\n return makeEnvironmentProviders([\n NativeStackRouteReuseStrategy,\n { provide: RouteReuseStrategy, useExisting: NativeStackRouteReuseStrategy },\n ]);\n}\n"]}
|