@coolon/angular-ui-powerups 16.1.0-alpha.272 → 16.1.0-alpha.273

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.
@@ -9062,8 +9062,17 @@ class Visit {
9062
9062
  return this.segments.find(v => v.placeDefinition === placeDefinition);
9063
9063
  }
9064
9064
  getRouterCommands() {
9065
- return this.segments.reduce((result, v) => {
9065
+ return this.segments.reduce((result, v, index) => {
9066
9066
  const path = v.placeDefinition.path;
9067
+ // A NON-terminal route-id segment must have a resolved id: createRouterCommands omits a nil
9068
+ // id, so the next place's path would silently bind into the id slot (e.g. groups/:g followed
9069
+ // by a child serialises as groups/<child>, navigating to a "circuit" called <child>). A
9070
+ // TERMINAL nil id is fine — the generated `<path> -> <path>/` redirect supplies the empty
9071
+ // slot and the guard's sanitiser takes it from there.
9072
+ if (index < this.segments.length - 1 && v.placeDefinition.hasRouteId() && !v.hasRouteId()) {
9073
+ lang$1.illegalState(`can't build a url for '${this.destinationPlaceDef.path}' while ancestor '${path}' has no route id — ` +
9074
+ `the child path would bind into the empty id slot`);
9075
+ }
9067
9076
  return isEmpty(path) ?
9068
9077
  [...result, path] : // Angular doesn't support route params on empty path segments
9069
9078
  [...result, path, ...v.createRouterCommands()];
@@ -9589,6 +9598,11 @@ class NavigatingDuringInteraction extends NavigationSession {
9589
9598
  isPopState = false;
9590
9599
  // @Trace()
9591
9600
  onRouterCancelled(event) {
9601
+ // A guard/sanitiser redirect is the navigation continuing — keep the session for the chain
9602
+ // (see Navigating / PopStateNavigation).
9603
+ if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
9604
+ return;
9605
+ }
9592
9606
  this.context.finishRoutingSession();
9593
9607
  }
9594
9608
  // @Trace()
@@ -9599,6 +9613,11 @@ class NavigatingDuringInteraction extends NavigationSession {
9599
9613
  // @Trace()
9600
9614
  onRouterEnd(event) {
9601
9615
  if (this.context.routerInteractionAdapter.isActive()) {
9616
+ // The sync handover's own finish is deliberately visitless, so record the completed visit
9617
+ // HERE — dropping it left activeVisit$ (and remember/rememberLastChild history) stale, and a
9618
+ // later navigate() then built its url from an id-less groups-style segment, collapsing the
9619
+ // child path into the route-id slot.
9620
+ this.context.recordVisit(this.createUpdatedVisit(event.urlAfterRedirects));
9602
9621
  this.context.transitionTo(new SynchroniseInteractionContextIdsWithRoute(this.context, this.startingUrl, false));
9603
9622
  }
9604
9623
  else {
@@ -9639,6 +9658,11 @@ class PopStateDuringInteractionNavigation extends AbstractPopStateNavigation {
9639
9658
  */
9640
9659
  // @Trace()
9641
9660
  onRouterCancelled(event) {
9661
+ // A guard/sanitiser redirect is the navigation continuing, not the refusal this handler was
9662
+ // written for — keep the session and let the redirect chain run (see PopStateNavigation).
9663
+ if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
9664
+ return;
9665
+ }
9642
9666
  this.repairBrowserHistoryAndUrlAfterGuardCancellation();
9643
9667
  // NOTE: for now we need to wasTriggeredByPopState=false because we're resetting the url and history in the previous line.
9644
9668
  this.context.transitionTo(new SynchroniseInteractionContextIdsWithRoute(this.context, this.poppedHistoryUrl, false));
@@ -9842,12 +9866,14 @@ var NavigationContext;
9842
9866
  navigateByUrl;
9843
9867
  transitionTo;
9844
9868
  finishRoutingSession;
9845
- constructor(urlService, routerInteractionAdapter, navigateByUrl, transitionTo, finishRoutingSession) {
9869
+ recordVisit;
9870
+ constructor(urlService, routerInteractionAdapter, navigateByUrl, transitionTo, finishRoutingSession, recordVisit) {
9846
9871
  this.urlService = urlService;
9847
9872
  this.routerInteractionAdapter = routerInteractionAdapter;
9848
9873
  this.navigateByUrl = navigateByUrl;
9849
9874
  this.transitionTo = transitionTo;
9850
9875
  this.finishRoutingSession = finishRoutingSession;
9876
+ this.recordVisit = recordVisit;
9851
9877
  }
9852
9878
  }
9853
9879
  NavigationContext.Impl = Impl;
@@ -9920,6 +9946,16 @@ class WaitUntilPopStateDuringCanDeactivateInteractionFinishes extends EventClean
9920
9946
 
9921
9947
  class PopStateNavigation extends AbstractPopStateNavigation {
9922
9948
  onRouterCancelled(event) {
9949
+ // A guard/sanitiser redirect is the navigation CONTINUING, not a rejection: keep the session
9950
+ // (as Navigating does) and repair nothing. Angular replaces the popped entry with the redirect
9951
+ // target for browser-triggered navigations, so history collapses correctly by itself — the
9952
+ // repair's replace+push here was what stranded the popped entry and made Back appear dead
9953
+ // (see the DEFECT PIN in place-router.spec.ts and master-detail-sanitiser-back.cy.ts).
9954
+ if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
9955
+ return;
9956
+ }
9957
+ // A genuine rejection (e.g. canDeactivate refusal): the browser has already moved even though
9958
+ // the app refused, so restore it — the angular #13586 workaround.
9923
9959
  this.repairBrowserHistoryAndUrlAfterGuardCancellation();
9924
9960
  this.context.finishRoutingSession();
9925
9961
  }
@@ -10538,6 +10574,8 @@ class PlaceRouter extends GarbageCollector {
10538
10574
  this.transitionTo(state);
10539
10575
  }, (segments) => {
10540
10576
  this.routingSessionFinished(segments);
10577
+ }, (visit) => {
10578
+ this.recordFinishedVisit(visit);
10541
10579
  });
10542
10580
  const { chain } = Dsl.disposeWith(this);
10543
10581
  this.navigationInProgress$ = chain(this.navigationSession$).isNotNil();
@@ -10840,11 +10878,7 @@ class PlaceRouter extends GarbageCollector {
10840
10878
  routingSessionFinished(visit) {
10841
10879
  if (visit) {
10842
10880
  assert.isTruthy(this.navigationInProgress$.value);
10843
- this.placeHistory.notifyNavigationFinished(visit);
10844
- // We update the active visits before we finish the session so the
10845
- // place outlets can ignore the incoming changes until things are settled.
10846
- this._activeVisit$.value = visit;
10847
- // console.log(visit.toDebugString())
10881
+ this.recordFinishedVisit(visit);
10848
10882
  }
10849
10883
  const session = this.currentSession;
10850
10884
  session.dispose();
@@ -10858,6 +10892,17 @@ class PlaceRouter extends GarbageCollector {
10858
10892
  this.sessionFinishedJobs = [];
10859
10893
  jobs.forEach((job) => job());
10860
10894
  }
10895
+ /**
10896
+ * Records a completed navigation's visit without finishing the session. Shared by the normal
10897
+ * finish path and sessions that hand over to visitless housekeeping (see
10898
+ * NavigationContext.recordVisit).
10899
+ */
10900
+ recordFinishedVisit(visit) {
10901
+ this.placeHistory.notifyNavigationFinished(visit);
10902
+ // We update the active visits before we finish the session so the
10903
+ // place outlets can ignore the incoming changes until things are settled.
10904
+ this._activeVisit$.value = visit;
10905
+ }
10861
10906
  /**
10862
10907
  * Runs `func` when the NEXT navigation session finishes — which may be a session that hasn't
10863
10908
  * started yet (the interaction-id sync registers its completion job before starting the sync