@ng-desktop/router 0.0.0-stage → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gaspar1992 and NgDesktop Engine Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # @ng-desktop/router
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ DOM-free Angular Router PlatformLocation & navigation stack for Native GTK4 / WinUI 3 / AppKit windows
4
+
5
+ Part of **[NgDesktop Engine](https://github.com/Gaspar1992/ng-desktop-engine)** — Native desktop rendering engine for Angular 22+ (`GTK4`, `WinUI 3`, `AppKit`).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @ng-desktop/router
11
+ ```
12
+
13
+ - Repository path: `packages/router-native`
14
+ - Documentation & Ecosystem Guide: https://github.com/Gaspar1992/ng-desktop-engine/blob/main/docs/ECOSYSTEM_COMPATIBILITY.md
@@ -0,0 +1,3 @@
1
+ export { NativePlatformLocation, provideNativeRouter } from './platform-location';
2
+ export { NATIVE_TITLE_PREFIX, NativeStackRouteReuseStrategy, NativeTitleStrategy, withNativeRouteReuse, withNativeTitleStrategy, } from './route-strategies';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export { NativePlatformLocation, provideNativeRouter } from './platform-location.js';
2
+ export { NATIVE_TITLE_PREFIX, NativeStackRouteReuseStrategy, NativeTitleStrategy, withNativeRouteReuse, withNativeTitleStrategy, } from './route-strategies.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,40 @@
1
+ import { type LocationChangeListener, PlatformLocation } from '@angular/common';
2
+ import { type EnvironmentProviders } from '@angular/core';
3
+ import { type RouterFeatures, type Routes } from '@angular/router';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * DOM-free Angular `PlatformLocation` implementation for native desktop applications.
7
+ * Maintains an in-memory URL and state history stack so `@angular/router` (`<router-outlet>`,
8
+ * `routerLink`, guards, resolvers, lazy loading) runs natively without `window.location`.
9
+ */
10
+ export declare class NativePlatformLocation extends PlatformLocation {
11
+ private readonly historyStack;
12
+ private currentIndex;
13
+ private readonly popStateListeners;
14
+ private readonly hashChangeListeners;
15
+ readonly hostname = "ng-native.local";
16
+ readonly protocol = "ng-native:";
17
+ readonly port = "";
18
+ getBaseHrefFromDOM(): string;
19
+ getState(): unknown;
20
+ onPopState(fn: LocationChangeListener): VoidFunction;
21
+ onHashChange(fn: LocationChangeListener): VoidFunction;
22
+ get href(): string;
23
+ get pathname(): string;
24
+ get search(): string;
25
+ get hash(): string;
26
+ replaceState(state: unknown, title: string, url: string): void;
27
+ pushState(state: unknown, title: string, url: string): void;
28
+ forward(): void;
29
+ back(): void;
30
+ historyGo(relativePosition?: number): void;
31
+ private currentEntry;
32
+ private normalizeUrl;
33
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativePlatformLocation, never>;
34
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
35
+ }
36
+ /**
37
+ * Provides `@angular/router` backed by `NativePlatformLocation` for DOM-free native windows.
38
+ */
39
+ export declare function provideNativeRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders;
40
+ //# sourceMappingURL=platform-location.d.ts.map
@@ -0,0 +1 @@
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,e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atformLocation, } from '@angular/common';
2
+ import { Injectable, makeEnvironmentProviders } from '@angular/core';
3
+ import { provideRouter } from '@angular/router';
4
+ import { withNativeTitleStrategy } from './route-strategies.js';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * DOM-free Angular `PlatformLocation` implementation for native desktop applications.
8
+ * Maintains an in-memory URL and state history stack so `@angular/router` (`<router-outlet>`,
9
+ * `routerLink`, guards, resolvers, lazy loading) runs natively without `window.location`.
10
+ */
11
+ export class NativePlatformLocation extends PlatformLocation {
12
+ historyStack = [{ url: '/', title: '', state: null }];
13
+ currentIndex = 0;
14
+ popStateListeners = new Set();
15
+ hashChangeListeners = new Set();
16
+ hostname = 'ng-native.local';
17
+ protocol = 'ng-native:';
18
+ port = '';
19
+ getBaseHrefFromDOM() {
20
+ return '/';
21
+ }
22
+ getState() {
23
+ return this.currentEntry().state;
24
+ }
25
+ onPopState(fn) {
26
+ this.popStateListeners.add(fn);
27
+ return () => {
28
+ this.popStateListeners.delete(fn);
29
+ };
30
+ }
31
+ onHashChange(fn) {
32
+ this.hashChangeListeners.add(fn);
33
+ return () => {
34
+ this.hashChangeListeners.delete(fn);
35
+ };
36
+ }
37
+ get href() {
38
+ return `${this.protocol}//${this.hostname}${this.currentEntry().url}`;
39
+ }
40
+ get pathname() {
41
+ const raw = this.currentEntry().url;
42
+ const qIdx = raw.indexOf('?');
43
+ const hIdx = raw.indexOf('#');
44
+ const end = qIdx !== -1 && hIdx !== -1
45
+ ? Math.min(qIdx, hIdx)
46
+ : qIdx !== -1
47
+ ? qIdx
48
+ : hIdx !== -1
49
+ ? hIdx
50
+ : raw.length;
51
+ return raw.slice(0, end) || '/';
52
+ }
53
+ get search() {
54
+ const raw = this.currentEntry().url;
55
+ const qIdx = raw.indexOf('?');
56
+ if (qIdx === -1) {
57
+ return '';
58
+ }
59
+ const hIdx = raw.indexOf('#', qIdx);
60
+ return hIdx === -1 ? raw.slice(qIdx) : raw.slice(qIdx, hIdx);
61
+ }
62
+ get hash() {
63
+ const raw = this.currentEntry().url;
64
+ const hIdx = raw.indexOf('#');
65
+ return hIdx === -1 ? '' : raw.slice(hIdx);
66
+ }
67
+ replaceState(state, title, url) {
68
+ this.historyStack[this.currentIndex] = {
69
+ url: this.normalizeUrl(url),
70
+ title,
71
+ state,
72
+ };
73
+ }
74
+ pushState(state, title, url) {
75
+ this.historyStack.splice(this.currentIndex + 1);
76
+ this.historyStack.push({
77
+ url: this.normalizeUrl(url),
78
+ title,
79
+ state,
80
+ });
81
+ this.currentIndex = this.historyStack.length - 1;
82
+ }
83
+ forward() {
84
+ this.historyGo(1);
85
+ }
86
+ back() {
87
+ this.historyGo(-1);
88
+ }
89
+ historyGo(relativePosition = 0) {
90
+ if (relativePosition === 0) {
91
+ return;
92
+ }
93
+ const nextIdx = this.currentIndex + relativePosition;
94
+ if (nextIdx < 0 || nextIdx >= this.historyStack.length) {
95
+ return;
96
+ }
97
+ this.currentIndex = nextIdx;
98
+ const evt = {
99
+ type: 'popstate',
100
+ state: this.currentEntry().state,
101
+ };
102
+ for (const listener of this.popStateListeners) {
103
+ listener(evt);
104
+ }
105
+ }
106
+ currentEntry() {
107
+ return (this.historyStack[this.currentIndex] ?? {
108
+ url: '/',
109
+ title: '',
110
+ state: null,
111
+ });
112
+ }
113
+ normalizeUrl(url) {
114
+ const trimmed = url.trim();
115
+ if (!trimmed) {
116
+ return '/';
117
+ }
118
+ return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
119
+ }
120
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativePlatformLocation, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
121
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativePlatformLocation, providedIn: 'root' });
122
+ }
123
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativePlatformLocation, decorators: [{
124
+ type: Injectable,
125
+ args: [{ providedIn: 'root' }]
126
+ }] });
127
+ /**
128
+ * Provides `@angular/router` backed by `NativePlatformLocation` for DOM-free native windows.
129
+ */
130
+ export function provideNativeRouter(routes, ...features) {
131
+ return makeEnvironmentProviders([
132
+ { provide: PlatformLocation, useExisting: NativePlatformLocation },
133
+ provideRouter(routes, ...features),
134
+ withNativeTitleStrategy(),
135
+ ]);
136
+ }
137
+ //# sourceMappingURL=platform-location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-location.js","sourceRoot":"","sources":["../../../../packages/router-native/src/platform-location.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,UAAU,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,aAAa,EAAoC,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;;AAQ7D;;;;GAIG;AAEH,MAAM,OAAO,sBAAuB,SAAQ,gBAAgB;IACzC,YAAY,GAAmB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/E,YAAY,GAAG,CAAC,CAAC;IACR,iBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;IACtD,mBAAmB,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEhE,QAAQ,GAAG,iBAAiB,CAAC;IAC7B,QAAQ,GAAG,YAAY,CAAC;IACxB,IAAI,GAAG,EAAE,CAAC;IAEV,kBAAkB;QACzB,OAAO,GAAG,CAAC;IACb,CAAC;IAEQ,QAAQ;QACf,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;IACnC,CAAC;IAEQ,UAAU,CAAC,EAA0B;QAC5C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/B,OAAO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E,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"]}
@@ -0,0 +1,38 @@
1
+ import { EnvironmentProviders, InjectionToken } from '@angular/core';
2
+ import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy, RouterStateSnapshot, TitleStrategy } from '@angular/router';
3
+ import * as i0 from "@angular/core";
4
+ export declare const NATIVE_TITLE_PREFIX: InjectionToken<string>;
5
+ /**
6
+ * Angular `TitleStrategy` that mirrors active route titles directly onto the OS window
7
+ * (`gtk_window_set_title` / `NSWindow.title` / `AppWindow.Title`) via `NativeTitleService`.
8
+ */
9
+ export declare class NativeTitleStrategy extends TitleStrategy {
10
+ private readonly titleService;
11
+ private readonly appPrefix;
12
+ updateTitle(snapshot: RouterStateSnapshot): void;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeTitleStrategy, never>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
15
+ }
16
+ /**
17
+ * Bounded `RouteReuseStrategy` tailored for native desktop navigation stacks (`GtkStack` /
18
+ * `AdwNavigationView`): preserves mounted page handles so back/forward transitions stay instant
19
+ * with scroll, focus, and state intact.
20
+ */
21
+ export declare class NativeStackRouteReuseStrategy implements RouteReuseStrategy {
22
+ private readonly handles;
23
+ private readonly maxCachedPages;
24
+ shouldDetach(route: ActivatedRouteSnapshot): boolean;
25
+ store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle | null): void;
26
+ shouldAttach(route: ActivatedRouteSnapshot): boolean;
27
+ retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
28
+ shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
29
+ retrieveStoredRouteHandles(): DetachedRouteHandle[];
30
+ clearCache(): void;
31
+ cachedRoutes(): string[];
32
+ private routeKey;
33
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeStackRouteReuseStrategy, never>;
34
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
35
+ }
36
+ export declare function withNativeTitleStrategy(appPrefix?: string): EnvironmentProviders;
37
+ export declare function withNativeRouteReuse(): EnvironmentProviders;
38
+ //# sourceMappingURL=route-strategies.d.ts.map
@@ -0,0 +1 @@
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,QAAQ,CAAC,YAAY,CAA8B;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IAEhD,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;yCAJ9C,mBAAmB;;CAW/B;AAED;;;;GAIG;AACH,qBACa,6BAA8B,YAAW,kBAAkB;IACtE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAClE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAM;IAErC,YAAY,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO;IAOpD,KAAK,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,IAAI;IAmB9E,YAAY,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO;IAKpD,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,mBAAmB,GAAG,IAAI;IAQnE,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,sBAAsB,GAAG,OAAO;IAIvF,0BAA0B,IAAI,mBAAmB,EAAE;IAInD,UAAU,IAAI,IAAI;IAIlB,YAAY,IAAI,MAAM,EAAE;IAIxB,OAAO,CAAC,QAAQ;yCA3DL,6BAA6B;;CAoEzC;AAED,wBAAgB,uBAAuB,CAAC,SAAS,SAAK,GAAG,oBAAoB,CAM5E;AAED,wBAAgB,oBAAoB,IAAI,oBAAoB,CAK3D"}
@@ -0,0 +1,114 @@
1
+ import { inject, Injectable, InjectionToken, makeEnvironmentProviders, } from '@angular/core';
2
+ import { RouteReuseStrategy, TitleStrategy, } from '@angular/router';
3
+ import { NativeTitleService } from '@ng-desktop/platform';
4
+ import * as i0 from "@angular/core";
5
+ export const NATIVE_TITLE_PREFIX = new InjectionToken('NATIVE_TITLE_PREFIX', {
6
+ providedIn: 'root',
7
+ factory: () => '',
8
+ });
9
+ /**
10
+ * Angular `TitleStrategy` that mirrors active route titles directly onto the OS window
11
+ * (`gtk_window_set_title` / `NSWindow.title` / `AppWindow.Title`) via `NativeTitleService`.
12
+ */
13
+ export class NativeTitleStrategy extends TitleStrategy {
14
+ titleService = inject(NativeTitleService);
15
+ appPrefix = inject(NATIVE_TITLE_PREFIX);
16
+ updateTitle(snapshot) {
17
+ const routeTitle = this.buildTitle(snapshot);
18
+ if (routeTitle !== undefined) {
19
+ const resolved = this.appPrefix ? `${this.appPrefix} — ${routeTitle}` : routeTitle;
20
+ this.titleService.setTitle(resolved);
21
+ }
22
+ }
23
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
24
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleStrategy, providedIn: 'root' });
25
+ }
26
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleStrategy, decorators: [{
27
+ type: Injectable,
28
+ args: [{ providedIn: 'root' }]
29
+ }] });
30
+ /**
31
+ * Bounded `RouteReuseStrategy` tailored for native desktop navigation stacks (`GtkStack` /
32
+ * `AdwNavigationView`): preserves mounted page handles so back/forward transitions stay instant
33
+ * with scroll, focus, and state intact.
34
+ */
35
+ export class NativeStackRouteReuseStrategy {
36
+ handles = new Map();
37
+ maxCachedPages = 16;
38
+ shouldDetach(route) {
39
+ if (!route.routeConfig || route.routeConfig.loadChildren) {
40
+ return false;
41
+ }
42
+ return route.data['reuse'] !== false;
43
+ }
44
+ store(route, handle) {
45
+ const key = this.routeKey(route);
46
+ if (!key) {
47
+ return;
48
+ }
49
+ if (handle === null) {
50
+ this.handles.delete(key);
51
+ return;
52
+ }
53
+ if (!this.handles.has(key) && this.handles.size >= this.maxCachedPages) {
54
+ const oldestKey = this.handles.keys().next().value;
55
+ if (oldestKey !== undefined) {
56
+ this.handles.delete(oldestKey);
57
+ }
58
+ }
59
+ this.handles.delete(key);
60
+ this.handles.set(key, handle);
61
+ }
62
+ shouldAttach(route) {
63
+ const key = this.routeKey(route);
64
+ return key.length > 0 && this.handles.has(key);
65
+ }
66
+ retrieve(route) {
67
+ const key = this.routeKey(route);
68
+ if (!key) {
69
+ return null;
70
+ }
71
+ return this.handles.get(key) ?? null;
72
+ }
73
+ shouldReuseRoute(future, curr) {
74
+ return future.routeConfig === curr.routeConfig;
75
+ }
76
+ retrieveStoredRouteHandles() {
77
+ return Array.from(this.handles.values());
78
+ }
79
+ clearCache() {
80
+ this.handles.clear();
81
+ }
82
+ cachedRoutes() {
83
+ return Array.from(this.handles.keys());
84
+ }
85
+ routeKey(route) {
86
+ const segments = route.pathFromRoot
87
+ .flatMap((snap) => snap.url.map((seg) => seg.path))
88
+ .filter(Boolean);
89
+ if (segments.length > 0) {
90
+ return `/${segments.join('/')}`;
91
+ }
92
+ return route.routeConfig?.path ?? '';
93
+ }
94
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStackRouteReuseStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
95
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStackRouteReuseStrategy, providedIn: 'root' });
96
+ }
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStackRouteReuseStrategy, decorators: [{
98
+ type: Injectable,
99
+ args: [{ providedIn: 'root' }]
100
+ }] });
101
+ export function withNativeTitleStrategy(appPrefix = '') {
102
+ return makeEnvironmentProviders([
103
+ { provide: NATIVE_TITLE_PREFIX, useValue: appPrefix },
104
+ NativeTitleStrategy,
105
+ { provide: TitleStrategy, useExisting: NativeTitleStrategy },
106
+ ]);
107
+ }
108
+ export function withNativeRouteReuse() {
109
+ return makeEnvironmentProviders([
110
+ NativeStackRouteReuseStrategy,
111
+ { provide: RouteReuseStrategy, useExisting: NativeStackRouteReuseStrategy },
112
+ ]);
113
+ }
114
+ //# sourceMappingURL=route-strategies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-strategies.js","sourceRoot":"","sources":["../../../../packages/router-native/src/route-strategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,UAAU,EACV,cAAc,EACd,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,kBAAkB,EAElB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAS,qBAAqB,EAAE;IACnF,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;CAClB,CAAC,CAAC;AAEH;;;GAGG;AAEH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IACnC,YAAY,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAC1C,SAAS,GAAG,MAAM,CAAC,mBAAm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AAC;IAEO,QAAQ,CAAC,KAA6B;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY;aAChC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aAClD,MAAM,CAAC,OAAO,CAAC,CAAC;QACnB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;IACvC,CAAC;uGAnEU,6BAA6B;2GAA7B,6BAA6B,cADhB,MAAM;;2FACnB,6BAA6B;kBADzC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;AAuElC,MAAM,UAAU,uBAAuB,CAAC,SAAS,GAAG,EAAE;IACpD,OAAO,wBAAwB,CAAC;QAC9B,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,SAAS,EAAE;QACrD,mBAAmB;QACnB,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAAE;KAC7D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,wBAAwB,CAAC;QAC9B,6BAA6B;QAC7B,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,6BAA6B,EAAE;KAC5E,CAAC,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"]}
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@ng-desktop/router",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "DOM-free Angular Router PlatformLocation & navigation stack for Native GTK4 / WinUI 3 / AppKit windows",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "angular",
8
+ "angular22",
9
+ "desktop",
10
+ "native",
11
+ "gtk4",
12
+ "winui3",
13
+ "appkit",
14
+ "rust"
15
+ ],
16
+ "homepage": "https://github.com/Gaspar1992/ng-desktop-engine",
17
+ "bugs": {
18
+ "url": "https://github.com/Gaspar1992/ng-desktop-engine/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Gaspar1992/ng-desktop-engine.git",
23
+ "directory": "packages/router-native"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "files": [
31
+ "fesm2022",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "main": "./fesm2022/index.js",
36
+ "module": "./fesm2022/index.js",
37
+ "types": "./fesm2022/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "types": "./fesm2022/index.d.ts",
41
+ "default": "./fesm2022/index.js"
42
+ },
43
+ "./package.json": {
44
+ "default": "./package.json"
45
+ }
46
+ },
47
+ "peerDependencies": {
48
+ "@angular/common": ">=22.0.0",
49
+ "@angular/core": ">=22.0.0",
50
+ "@angular/router": ">=22.0.0",
51
+ "@ng-desktop/platform": ">=0.3.0"
52
+ }
53
+ }