@ionic/angular 9.0.13-nightly.20261118 → 9.0.13-nightly.20261120

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.
@@ -1,5 +1,5 @@
1
1
  import { Injectable, Optional } from '@angular/core';
2
- import { NavigationStart, NavigationCancel, NavigationError, } from '@angular/router';
2
+ import { NavigationStart, NavigationEnd, NavigationCancel, NavigationError, NavigationSkipped, } from '@angular/router';
3
3
  import * as i0 from "@angular/core";
4
4
  import * as i1 from "./platform";
5
5
  import * as i2 from "@angular/common";
@@ -15,6 +15,15 @@ export class NavController {
15
15
  guessDirection = 'forward';
16
16
  guessAnimation;
17
17
  lastNavId = -1;
18
+ /**
19
+ * Navigation ids of the history entries seen so far. `pop()` uses them to
20
+ * tell whether the previous view is the entry directly behind.
21
+ */
22
+ historyEntries = [];
23
+ /** Index of the current entry in `historyEntries`, or `-1` when unknown. */
24
+ historyIndex = -1;
25
+ /** How the navigation in progress changes history, applied on `NavigationEnd`. */
26
+ pendingEntry;
18
27
  constructor(platform, location, serializer, router) {
19
28
  this.location = location;
20
29
  this.serializer = serializer;
@@ -27,6 +36,38 @@ export class NavController {
27
36
  const id = ev.restoredState ? ev.restoredState.navigationId : ev.id;
28
37
  this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward';
29
38
  this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
39
+ const fromPath = this.location.path();
40
+ const fromTrackedEntry = this.isOnCurrentHistoryEntry();
41
+ if (ev.navigationTrigger === 'popstate') {
42
+ this.pendingEntry = {
43
+ id: ev.id,
44
+ kind: 'restore',
45
+ fromPath,
46
+ fromTrackedEntry,
47
+ restoredId: ev.restoredState?.navigationId,
48
+ };
49
+ }
50
+ else if (ev.navigationTrigger === 'hashchange') {
51
+ // The browser added or changed the entry itself.
52
+ this.pendingEntry = { id: undefined, kind: 'unknown', fromPath, fromTrackedEntry };
53
+ }
54
+ else {
55
+ const extras = router.getCurrentNavigation()?.extras ?? {};
56
+ if (extras.skipLocationChange) {
57
+ this.pendingEntry = { id: undefined, kind: 'none', fromPath, fromTrackedEntry };
58
+ }
59
+ else {
60
+ this.pendingEntry = {
61
+ id: ev.id,
62
+ kind: extras.replaceUrl ? 'replace' : 'push',
63
+ fromPath,
64
+ fromTrackedEntry,
65
+ };
66
+ }
67
+ }
68
+ }
69
+ if (ev instanceof NavigationEnd) {
70
+ this.commitHistoryEntry(ev.id);
30
71
  }
31
72
  // Reset explicit direction when navigation is canceled (e.g., guard rejection)
32
73
  // to prevent stale direction from leaking into the next navigation
@@ -34,6 +75,19 @@ export class NavController {
34
75
  this.direction = DEFAULT_DIRECTION;
35
76
  this.animated = DEFAULT_ANIMATED;
36
77
  this.animationBuilder = undefined;
78
+ /**
79
+ * Drop the tracked history if the browser might not be on the tracked
80
+ * entry anymore. An error can come after the URL was written, and the
81
+ * router may have rewritten an untracked entry to look tracked.
82
+ */
83
+ const pending = this.pendingEntry;
84
+ if (ev instanceof NavigationError ||
85
+ pending?.kind === 'restore' ||
86
+ !pending?.fromTrackedEntry ||
87
+ !this.isOnCurrentHistoryEntry()) {
88
+ this.resetHistoryEntries();
89
+ }
90
+ this.pendingEntry = undefined;
37
91
  }
38
92
  });
39
93
  }
@@ -145,6 +199,104 @@ export class NavController {
145
199
  this.animated = getAnimation(direction, animated, animationDirection);
146
200
  this.animationBuilder = animationBuilder;
147
201
  }
202
+ /**
203
+ * @internal
204
+ * Goes back one history entry with a `back` transition and resolves
205
+ * once the router has handled it.
206
+ */
207
+ backInHistory(animationBuilder) {
208
+ const settled = new Promise((resolve) => {
209
+ const sub = this.router.events.subscribe((ev) => {
210
+ if (ev instanceof NavigationSkipped) {
211
+ // Nothing transitions, so clear the direction here.
212
+ this.consumeTransition();
213
+ }
214
+ if (ev instanceof NavigationEnd ||
215
+ ev instanceof NavigationCancel ||
216
+ ev instanceof NavigationError ||
217
+ ev instanceof NavigationSkipped) {
218
+ sub.unsubscribe();
219
+ resolve();
220
+ }
221
+ });
222
+ });
223
+ this.back({ animation: animationBuilder });
224
+ return settled;
225
+ }
226
+ /**
227
+ * @internal
228
+ * The id of the history entry the navigation in progress shows,
229
+ * recorded on the view it activates.
230
+ */
231
+ getPendingHistoryEntryId() {
232
+ return this.pendingEntry ? this.pendingEntry.id : this.router?.getCurrentNavigation()?.id;
233
+ }
234
+ /**
235
+ * @internal
236
+ * The id of the history entry currently shown, if known.
237
+ */
238
+ getCurrentHistoryEntryId() {
239
+ return this.historyIndex >= 0 ? this.historyEntries[this.historyIndex] : undefined;
240
+ }
241
+ /**
242
+ * @internal
243
+ * Whether the given history entry is the one directly behind
244
+ * the current entry, so going back in history lands on it.
245
+ */
246
+ isPreviousHistoryEntry(entryId) {
247
+ return (entryId !== undefined &&
248
+ this.historyIndex > 0 &&
249
+ this.isOnCurrentHistoryEntry() &&
250
+ this.historyEntries[this.historyIndex - 1] === entryId);
251
+ }
252
+ /**
253
+ * Entries added outside the router, like with `Location.go()`, aren't
254
+ * tracked, so check the browser is on the tracked entry.
255
+ */
256
+ isOnCurrentHistoryEntry() {
257
+ const currentId = this.location.getState()?.navigationId;
258
+ return this.historyIndex >= 0 && currentId === this.historyEntries[this.historyIndex];
259
+ }
260
+ commitHistoryEntry(navigationId) {
261
+ const pending = this.pendingEntry;
262
+ this.pendingEntry = undefined;
263
+ if (pending?.kind === 'none') {
264
+ return;
265
+ }
266
+ let index = -1;
267
+ if (pending?.kind === 'restore' && pending.restoredId !== undefined) {
268
+ index = this.historyEntries.indexOf(pending.restoredId);
269
+ }
270
+ else if ((pending?.kind === 'push' || pending?.kind === 'replace') && pending.fromTrackedEntry) {
271
+ index = this.historyIndex;
272
+ }
273
+ /**
274
+ * There's no known entry to anchor to, so start over from this one. The
275
+ * first navigation can start before this service is created.
276
+ */
277
+ if (pending === undefined || pending.kind === 'unknown' || index < 0) {
278
+ this.historyEntries = [navigationId];
279
+ this.historyIndex = 0;
280
+ return;
281
+ }
282
+ /**
283
+ * The router replaces the current entry instead of pushing when asked
284
+ * to, or when the URL doesn't change. Like the router, compare the old
285
+ * path without its hash to the new one with it.
286
+ */
287
+ const replaced = pending.kind !== 'push' || this.location.path(true) === pending.fromPath;
288
+ if (!replaced) {
289
+ index++;
290
+ this.historyEntries.length = index;
291
+ }
292
+ // The router writes this navigation's id into the entry, replacing any old one.
293
+ this.historyEntries[index] = navigationId;
294
+ this.historyIndex = index;
295
+ }
296
+ resetHistoryEntries() {
297
+ this.historyEntries = [];
298
+ this.historyIndex = -1;
299
+ }
148
300
  /**
149
301
  * @internal
150
302
  */
@@ -1 +1 @@
1
- {"version":3,"file":"nav-controller.js","sourceRoot":"","sources":["../../../src/common/providers/nav-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAKL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;;;;;AAkBzB,MAAM,OAAO,aAAa;IAWd;IACA;IACY;IAZd,SAAS,CAAmB;IAC5B,SAAS,GAAyC,iBAAiB,CAAC;IACpE,QAAQ,GAAkB,gBAAgB,CAAC;IAC3C,gBAAgB,CAAoB;IACpC,cAAc,GAAoB,SAAS,CAAC;IAC5C,cAAc,CAAgB;IAC9B,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YACE,QAAkB,EACV,QAAkB,EAClB,UAAyB,EACb,MAAe;QAF3B,aAAQ,GAAR,QAAQ,CAAU;QAClB,eAAU,GAAV,UAAU,CAAe;QACb,WAAM,GAAN,MAAM,CAAS;QAEnC,iDAAiD;QACjD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE;gBAC7B,IAAI,EAAE,YAAY,eAAe,EAAE,CAAC;oBAClC,kEAAkE;oBAClE,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,C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IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YACtC,CAAC;YAED;;;;eAIG;YACH,OAAO,IAAI,CAAC,MAAO,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;0HA5NU,aAAa;8HAAb,aAAa,cAFZ,MAAM;;2FAEP,aAAa;kBAHzB,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;0BAcI,QAAQ;;AAkNb,MAAM,YAAY,GAAG,CACnB,SAA0B,EAC1B,QAA6B,EAC7B,kBAAkD,EACxB,EAAE;IAC5B,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,SAAS,KAAK,MAAM,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,gBAAgB,GAAG,SAAS,CAAC","sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable, Optional } from '@angular/core';\nimport {\n NavigationExtras,\n Router,\n UrlSerializer,\n UrlTree,\n NavigationStart,\n NavigationCancel,\n NavigationError,\n} from '@angular/router';\nimport type { AnimationBuilder, NavDirection, RouterDirection } from '@ionic/core/components';\n\nimport { IonRouterOutlet } from '../directives/navigation/router-outlet';\n\nimport { Platform } from './platform';\n\nexport interface AnimationOptions {\n animated?: boolean;\n animation?: AnimationBuilder;\n animationDirection?: 'forward' | 'back';\n}\n\nexport interface NavigationOptions extends NavigationExtras, AnimationOptions {}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NavController {\n private topOutlet?: IonRouterOutlet;\n private direction: 'forward' | 'back' | 'root' | 'auto' = DEFAULT_DIRECTION;\n private animated?: NavDirection = DEFAULT_ANIMATED;\n private animationBuilder?: AnimationBuilder;\n private guessDirection: RouterDirection = 'forward';\n private guessAnimation?: NavDirection;\n private lastNavId = -1;\n\n constructor(\n platform: Platform,\n private location: Location,\n private serializer: UrlSerializer,\n @Optional() private router?: Router\n ) {\n // Subscribe to router events to detect direction\n if (router) {\n router.events.subscribe((ev) => {\n if (ev instanceof NavigationStart) {\n // restoredState is set if the browser back/forward button is used\n const id = ev.restoredState ? ev.restoredState.navigationId : ev.id;\n this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward';\n this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;\n }\n\n // Reset explicit direction when navigation is canceled (e.g., guard rejection)\n // to prevent stale direction from leaking into the next navigation\n if (ev instanceof NavigationCancel || ev instanceof NavigationError) {\n this.direction = DEFAULT_DIRECTION;\n this.animated = DEFAULT_ANIMATED;\n this.animationBuilder = undefined;\n }\n });\n }\n\n // Subscribe to backButton events\n platform.backButton.subscribeWithPriority(0, (processNextHandler) => {\n this.pop();\n processNextHandler();\n });\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling `this.router.navigateByUrl()`, but it's explicit about the **direction** of the transition.\n *\n * Going **forward** means that a new page is going to be pushed to the stack of the outlet (ion-router-outlet),\n * and that it will show a \"forward\" animation by default.\n *\n * Navigating forward can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"forward\">Link</a>\n * ```\n */\n navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('forward', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling:\n *\n * ```ts\n * this.navController.setDirection('back');\n * this.router.navigateByUrl(path);\n * ```\n *\n * Going **back** means that all the pages in the stack until the navigated page is found will be popped,\n * and that it will show a \"back\" animation by default.\n *\n * Navigating back can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"back\">Link</a>\n * ```\n */\n navigateBack(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('back', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling:\n *\n * ```ts\n * this.navController.setDirection('root');\n * this.router.navigateByUrl(path);\n * ```\n *\n * Going **root** means that all existing pages in the stack will be removed,\n * and the navigated page will become the single page in the stack.\n *\n * Navigating root can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"root\">Link</a>\n * ```\n */\n navigateRoot(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('root', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * Same as [Location](https://angular.io/api/common/Location)'s back() method.\n * It will use the standard `window.history.back()` under the hood, but featuring a `back` animation\n * by default.\n */\n back(options: AnimationOptions = { animated: true, animationDirection: 'back' }): void {\n this.setDirection('back', options.animated, options.animationDirection, options.animation);\n return this.location.back();\n }\n\n /**\n * This methods goes back in the context of Ionic's stack navigation.\n *\n * It recursively finds the top active `ion-router-outlet` and calls `pop()`.\n * This is the recommended way to go back when you are using `ion-router-outlet`.\n *\n * Resolves to `true` if it was able to pop.\n */\n async pop(): Promise<boolean> {\n let outlet = this.topOutlet;\n\n while (outlet) {\n if (await outlet.pop()) {\n return true;\n } else {\n outlet = outlet.parentOutlet;\n }\n }\n\n return false;\n }\n\n /**\n * This methods specifies the direction of the next navigation performed by the Angular router.\n *\n * `setDirection()` does not trigger any transition, it just sets some flags to be consumed by `ion-router-outlet`.\n *\n * It's recommended to use `navigateForward()`, `navigateBack()` and `navigateRoot()` instead of `setDirection()`.\n */\n setDirection(\n direction: RouterDirection,\n animated?: boolean,\n animationDirection?: 'forward' | 'back',\n animationBuilder?: AnimationBuilder\n ): void {\n this.direction = direction;\n this.animated = getAnimation(direction, animated, animationDirection);\n this.animationBuilder = animationBuilder;\n }\n\n /**\n * @internal\n */\n setTopOutlet(outlet: IonRouterOutlet): void {\n this.topOutlet = outlet;\n }\n\n /**\n * @internal\n */\n consumeTransition(): {\n direction: RouterDirection;\n animation: NavDirection | undefined;\n animationBuilder: AnimationBuilder | undefined;\n } {\n let direction: RouterDirection = 'root';\n let animation: NavDirection | undefined;\n const animationBuilder = this.animationBuilder;\n\n if (this.direction === 'auto') {\n direction = this.guessDirection;\n animation = this.guessAnimation;\n } else {\n animation = this.animated;\n direction = this.direction;\n }\n this.direction = DEFAULT_DIRECTION;\n this.animated = DEFAULT_ANIMATED;\n this.animationBuilder = undefined;\n\n return {\n direction,\n animation,\n animationBuilder,\n };\n }\n\n private navigate(url: string | UrlTree | any[], options: NavigationOptions) {\n if (Array.isArray(url)) {\n return this.router!.navigate(url, options);\n } else {\n /**\n * navigateByUrl ignores any properties that\n * would change the url, so things like queryParams\n * would be ignored unless we create a url tree\n * More Info: https://github.com/angular/angular/issues/18798\n */\n const urlTree = this.serializer.parse(url.toString());\n\n if (options.queryParams !== undefined) {\n urlTree.queryParams = { ...options.queryParams };\n }\n\n if (options.fragment !== undefined) {\n urlTree.fragment = options.fragment;\n }\n\n /**\n * `navigateByUrl` will still apply `NavigationExtras` properties\n * that do not modify the url, such as `replaceUrl` which is why\n * `options` is passed in here.\n */\n return this.router!.navigateByUrl(urlTree, options);\n }\n }\n}\n\nconst getAnimation = (\n direction: RouterDirection,\n animated: boolean | undefined,\n animationDirection: 'forward' | 'back' | undefined\n): NavDirection | undefined => {\n if (animated === false) {\n return undefined;\n }\n if (animationDirection !== undefined) {\n return animationDirection;\n }\n if (direction === 'forward' || direction === 'back') {\n return direction;\n } else if (direction === 'root' && animated === true) {\n return 'forward';\n }\n return undefined;\n};\n\nconst DEFAULT_DIRECTION = 'auto';\nconst DEFAULT_ANIMATED = undefined;\n"]}
1
+ {"version":3,"file":"nav-controller.js","sourceRoot":"","sources":["../../../src/common/providers/nav-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAKL,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;;;;;AAkBzB,MAAM,OAAO,aAAa;IA4Bd;IACA;IACY;IA7Bd,SAAS,CAAmB;IAC5B,SAAS,GAAyC,iBAAiB,CAAC;IACpE,QAAQ,GAAkB,gBAAgB,CAAC;IAC3C,gBAAgB,CAAoB;IACpC,cAAc,GAAoB,SAAS,CAAC;IAC5C,cAAc,CAAgB;IAC9B,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB;;;OAGG;IACK,cAAc,GAAa,EAAE,CAAC;IACtC,4EAA4E;IACpE,YAAY,GAAG,CAAC,CAAC,CAAC;IAC1B,kFAAkF;IAC1E,YAAY,CAOlB;IAEF,YACE,QAAkB,EACV,QAAkB,EAClB,UAAyB,EACb,MAAe;QAF3B,aAAQ,GAAR,QAAQ,CAAU;QAClB,eAAU,GAAV,UAAU,CAAe;QACb,WAAM,GAAN,MAAM,CAAS;QAEnC,iDAAiD;QACjD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE;gBAC7B,IAAI,EAAE,YAAY,eAAe,EAAE,CAAC;oBAClC,kEAAkE;oBAClE,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,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KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,SAAS,KAAK,MAAM,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,gBAAgB,GAAG,SAAS,CAAC","sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable, Optional } from '@angular/core';\nimport {\n NavigationExtras,\n Router,\n UrlSerializer,\n UrlTree,\n NavigationStart,\n NavigationEnd,\n NavigationCancel,\n NavigationError,\n NavigationSkipped,\n} from '@angular/router';\nimport type { AnimationBuilder, NavDirection, RouterDirection } from '@ionic/core/components';\n\nimport { IonRouterOutlet } from '../directives/navigation/router-outlet';\n\nimport { Platform } from './platform';\n\nexport interface AnimationOptions {\n animated?: boolean;\n animation?: AnimationBuilder;\n animationDirection?: 'forward' | 'back';\n}\n\nexport interface NavigationOptions extends NavigationExtras, AnimationOptions {}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NavController {\n private topOutlet?: IonRouterOutlet;\n private direction: 'forward' | 'back' | 'root' | 'auto' = DEFAULT_DIRECTION;\n private animated?: NavDirection = DEFAULT_ANIMATED;\n private animationBuilder?: AnimationBuilder;\n private guessDirection: RouterDirection = 'forward';\n private guessAnimation?: NavDirection;\n private lastNavId = -1;\n\n /**\n * Navigation ids of the history entries seen so far. `pop()` uses them to\n * tell whether the previous view is the entry directly behind.\n */\n private historyEntries: number[] = [];\n /** Index of the current entry in `historyEntries`, or `-1` when unknown. */\n private historyIndex = -1;\n /** How the navigation in progress changes history, applied on `NavigationEnd`. */\n private pendingEntry?: {\n id: number | undefined;\n kind: 'push' | 'replace' | 'restore' | 'none' | 'unknown';\n fromPath: string;\n restoredId?: number;\n /** Whether the browser was on the tracked entry when the navigation started. */\n fromTrackedEntry: boolean;\n };\n\n constructor(\n platform: Platform,\n private location: Location,\n private serializer: UrlSerializer,\n @Optional() private router?: Router\n ) {\n // Subscribe to router events to detect direction\n if (router) {\n router.events.subscribe((ev) => {\n if (ev instanceof NavigationStart) {\n // restoredState is set if the browser back/forward button is used\n const id = ev.restoredState ? ev.restoredState.navigationId : ev.id;\n this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward';\n this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;\n\n const fromPath = this.location.path();\n const fromTrackedEntry = this.isOnCurrentHistoryEntry();\n if (ev.navigationTrigger === 'popstate') {\n this.pendingEntry = {\n id: ev.id,\n kind: 'restore',\n fromPath,\n fromTrackedEntry,\n restoredId: ev.restoredState?.navigationId,\n };\n } else if (ev.navigationTrigger === 'hashchange') {\n // The browser added or changed the entry itself.\n this.pendingEntry = { id: undefined, kind: 'unknown', fromPath, fromTrackedEntry };\n } else {\n const extras = router.getCurrentNavigation()?.extras ?? {};\n if (extras.skipLocationChange) {\n this.pendingEntry = { id: undefined, kind: 'none', fromPath, fromTrackedEntry };\n } else {\n this.pendingEntry = {\n id: ev.id,\n kind: extras.replaceUrl ? 'replace' : 'push',\n fromPath,\n fromTrackedEntry,\n };\n }\n }\n }\n\n if (ev instanceof NavigationEnd) {\n this.commitHistoryEntry(ev.id);\n }\n\n // Reset explicit direction when navigation is canceled (e.g., guard rejection)\n // to prevent stale direction from leaking into the next navigation\n if (ev instanceof NavigationCancel || ev instanceof NavigationError) {\n this.direction = DEFAULT_DIRECTION;\n this.animated = DEFAULT_ANIMATED;\n this.animationBuilder = undefined;\n\n /**\n * Drop the tracked history if the browser might not be on the tracked\n * entry anymore. An error can come after the URL was written, and the\n * router may have rewritten an untracked entry to look tracked.\n */\n const pending = this.pendingEntry;\n if (\n ev instanceof NavigationError ||\n pending?.kind === 'restore' ||\n !pending?.fromTrackedEntry ||\n !this.isOnCurrentHistoryEntry()\n ) {\n this.resetHistoryEntries();\n }\n this.pendingEntry = undefined;\n }\n });\n }\n\n // Subscribe to backButton events\n platform.backButton.subscribeWithPriority(0, (processNextHandler) => {\n this.pop();\n processNextHandler();\n });\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling `this.router.navigateByUrl()`, but it's explicit about the **direction** of the transition.\n *\n * Going **forward** means that a new page is going to be pushed to the stack of the outlet (ion-router-outlet),\n * and that it will show a \"forward\" animation by default.\n *\n * Navigating forward can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"forward\">Link</a>\n * ```\n */\n navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('forward', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling:\n *\n * ```ts\n * this.navController.setDirection('back');\n * this.router.navigateByUrl(path);\n * ```\n *\n * Going **back** means that all the pages in the stack until the navigated page is found will be popped,\n * and that it will show a \"back\" animation by default.\n *\n * Navigating back can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"back\">Link</a>\n * ```\n */\n navigateBack(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('back', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,\n * it's equivalent to calling:\n *\n * ```ts\n * this.navController.setDirection('root');\n * this.router.navigateByUrl(path);\n * ```\n *\n * Going **root** means that all existing pages in the stack will be removed,\n * and the navigated page will become the single page in the stack.\n *\n * Navigating root can also be triggered in a declarative manner by using the `[routerDirection]` directive:\n *\n * ```html\n * <a routerLink=\"/path/to/page\" routerDirection=\"root\">Link</a>\n * ```\n */\n navigateRoot(url: string | UrlTree | any[], options: NavigationOptions = {}): Promise<boolean> {\n this.setDirection('root', options.animated, options.animationDirection, options.animation);\n return this.navigate(url, options);\n }\n\n /**\n * Same as [Location](https://angular.io/api/common/Location)'s back() method.\n * It will use the standard `window.history.back()` under the hood, but featuring a `back` animation\n * by default.\n */\n back(options: AnimationOptions = { animated: true, animationDirection: 'back' }): void {\n this.setDirection('back', options.animated, options.animationDirection, options.animation);\n return this.location.back();\n }\n\n /**\n * This methods goes back in the context of Ionic's stack navigation.\n *\n * It recursively finds the top active `ion-router-outlet` and calls `pop()`.\n * This is the recommended way to go back when you are using `ion-router-outlet`.\n *\n * Resolves to `true` if it was able to pop.\n */\n async pop(): Promise<boolean> {\n let outlet = this.topOutlet;\n\n while (outlet) {\n if (await outlet.pop()) {\n return true;\n } else {\n outlet = outlet.parentOutlet;\n }\n }\n\n return false;\n }\n\n /**\n * This methods specifies the direction of the next navigation performed by the Angular router.\n *\n * `setDirection()` does not trigger any transition, it just sets some flags to be consumed by `ion-router-outlet`.\n *\n * It's recommended to use `navigateForward()`, `navigateBack()` and `navigateRoot()` instead of `setDirection()`.\n */\n setDirection(\n direction: RouterDirection,\n animated?: boolean,\n animationDirection?: 'forward' | 'back',\n animationBuilder?: AnimationBuilder\n ): void {\n this.direction = direction;\n this.animated = getAnimation(direction, animated, animationDirection);\n this.animationBuilder = animationBuilder;\n }\n\n /**\n * @internal\n * Goes back one history entry with a `back` transition and resolves\n * once the router has handled it.\n */\n backInHistory(animationBuilder?: AnimationBuilder): Promise<void> {\n const settled = new Promise<void>((resolve) => {\n const sub = this.router!.events.subscribe((ev) => {\n if (ev instanceof NavigationSkipped) {\n // Nothing transitions, so clear the direction here.\n this.consumeTransition();\n }\n if (\n ev instanceof NavigationEnd ||\n ev instanceof NavigationCancel ||\n ev instanceof NavigationError ||\n ev instanceof NavigationSkipped\n ) {\n sub.unsubscribe();\n resolve();\n }\n });\n });\n this.back({ animation: animationBuilder });\n return settled;\n }\n\n /**\n * @internal\n * The id of the history entry the navigation in progress shows,\n * recorded on the view it activates.\n */\n getPendingHistoryEntryId(): number | undefined {\n return this.pendingEntry ? this.pendingEntry.id : this.router?.getCurrentNavigation()?.id;\n }\n\n /**\n * @internal\n * The id of the history entry currently shown, if known.\n */\n getCurrentHistoryEntryId(): number | undefined {\n return this.historyIndex >= 0 ? this.historyEntries[this.historyIndex] : undefined;\n }\n\n /**\n * @internal\n * Whether the given history entry is the one directly behind\n * the current entry, so going back in history lands on it.\n */\n isPreviousHistoryEntry(entryId: number | undefined): boolean {\n return (\n entryId !== undefined &&\n this.historyIndex > 0 &&\n this.isOnCurrentHistoryEntry() &&\n this.historyEntries[this.historyIndex - 1] === entryId\n );\n }\n\n /**\n * Entries added outside the router, like with `Location.go()`, aren't\n * tracked, so check the browser is on the tracked entry.\n */\n private isOnCurrentHistoryEntry(): boolean {\n const currentId = (this.location.getState() as { navigationId?: number } | null)?.navigationId;\n return this.historyIndex >= 0 && currentId === this.historyEntries[this.historyIndex];\n }\n\n private commitHistoryEntry(navigationId: number) {\n const pending = this.pendingEntry;\n this.pendingEntry = undefined;\n\n if (pending?.kind === 'none') {\n return;\n }\n\n let index = -1;\n if (pending?.kind === 'restore' && pending.restoredId !== undefined) {\n index = this.historyEntries.indexOf(pending.restoredId);\n } else if ((pending?.kind === 'push' || pending?.kind === 'replace') && pending.fromTrackedEntry) {\n index = this.historyIndex;\n }\n\n /**\n * There's no known entry to anchor to, so start over from this one. The\n * first navigation can start before this service is created.\n */\n if (pending === undefined || pending.kind === 'unknown' || index < 0) {\n this.historyEntries = [navigationId];\n this.historyIndex = 0;\n return;\n }\n\n /**\n * The router replaces the current entry instead of pushing when asked\n * to, or when the URL doesn't change. Like the router, compare the old\n * path without its hash to the new one with it.\n */\n const replaced = pending.kind !== 'push' || this.location.path(true) === pending.fromPath;\n if (!replaced) {\n index++;\n this.historyEntries.length = index;\n }\n // The router writes this navigation's id into the entry, replacing any old one.\n this.historyEntries[index] = navigationId;\n this.historyIndex = index;\n }\n\n private resetHistoryEntries() {\n this.historyEntries = [];\n this.historyIndex = -1;\n }\n\n /**\n * @internal\n */\n setTopOutlet(outlet: IonRouterOutlet): void {\n this.topOutlet = outlet;\n }\n\n /**\n * @internal\n */\n consumeTransition(): {\n direction: RouterDirection;\n animation: NavDirection | undefined;\n animationBuilder: AnimationBuilder | undefined;\n } {\n let direction: RouterDirection = 'root';\n let animation: NavDirection | undefined;\n const animationBuilder = this.animationBuilder;\n\n if (this.direction === 'auto') {\n direction = this.guessDirection;\n animation = this.guessAnimation;\n } else {\n animation = this.animated;\n direction = this.direction;\n }\n this.direction = DEFAULT_DIRECTION;\n this.animated = DEFAULT_ANIMATED;\n this.animationBuilder = undefined;\n\n return {\n direction,\n animation,\n animationBuilder,\n };\n }\n\n private navigate(url: string | UrlTree | any[], options: NavigationOptions) {\n if (Array.isArray(url)) {\n return this.router!.navigate(url, options);\n } else {\n /**\n * navigateByUrl ignores any properties that\n * would change the url, so things like queryParams\n * would be ignored unless we create a url tree\n * More Info: https://github.com/angular/angular/issues/18798\n */\n const urlTree = this.serializer.parse(url.toString());\n\n if (options.queryParams !== undefined) {\n urlTree.queryParams = { ...options.queryParams };\n }\n\n if (options.fragment !== undefined) {\n urlTree.fragment = options.fragment;\n }\n\n /**\n * `navigateByUrl` will still apply `NavigationExtras` properties\n * that do not modify the url, such as `replaceUrl` which is why\n * `options` is passed in here.\n */\n return this.router!.navigateByUrl(urlTree, options);\n }\n }\n}\n\nconst getAnimation = (\n direction: RouterDirection,\n animated: boolean | undefined,\n animationDirection: 'forward' | 'back' | undefined\n): NavDirection | undefined => {\n if (animated === false) {\n return undefined;\n }\n if (animationDirection !== undefined) {\n return animationDirection;\n }\n if (direction === 'forward' || direction === 'back') {\n return direction;\n } else if (direction === 'root' && animated === true) {\n return 'forward';\n }\n return undefined;\n};\n\nconst DEFAULT_DIRECTION = 'auto';\nconst DEFAULT_ANIMATED = undefined;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionic/angular",
3
- "version": "9.0.13-nightly.20261118",
3
+ "version": "9.0.13-nightly.20261120",
4
4
  "description": "Angular specific wrappers for @ionic/core",
5
5
  "keywords": [
6
6
  "ionic",
@@ -168,8 +168,8 @@
168
168
  "css/"
169
169
  ],
170
170
  "dependencies": {
171
- "@ionic/core": "9.0.13-nightly.20261118",
172
- "ionicons": "^8.0.13",
171
+ "@ionic/core": "9.0.13-nightly.20261120",
172
+ "ionicons": "^8.1.1",
173
173
  "jsonc-parser": "^3.0.0",
174
174
  "tslib": "^2.3.0"
175
175
  },