@ethlete/core 4.29.6 → 4.29.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ethlete/core
2
2
 
3
+ ## 4.29.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b79cf6a`](https://github.com/ethlete-io/ethdk/commit/b79cf6a845496d4e5c1df63c851c96dceba50881) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix router event signal skipping the initial navigation
8
+
3
9
  ## 4.29.6
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, HostBinding, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, assertInInjectionContext, DestroyRef, ElementRef, TemplateRef, Injectable, isSignal, signal, QueryList, computed, Injector, effect, untracked, runInInjectionContext, afterNextRender, Renderer2, RendererStyleFlags2, NgZone, isDevMode, PLATFORM_ID, Directive, model, ViewContainerRef, booleanAttribute, EventEmitter, Output, numberAttribute, Pipe, input } from '@angular/core';
2
+ import { inject, HostBinding, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, assertInInjectionContext, DestroyRef, ElementRef, TemplateRef, Injectable, signal, isSignal, QueryList, computed, Injector, effect, untracked, runInInjectionContext, afterNextRender, Renderer2, RendererStyleFlags2, NgZone, isDevMode, PLATFORM_ID, linkedSignal, Directive, model, ViewContainerRef, booleanAttribute, EventEmitter, Output, numberAttribute, Pipe, input } from '@angular/core';
3
3
  import { DomSanitizer, Meta, Title } from '@angular/platform-browser';
4
4
  import { Subject, BehaviorSubject, takeUntil, switchMap, of, tap, map, startWith, Observable, combineLatest, timer, fromEvent, distinctUntilChanged, pairwise, shareReplay, filter, debounceTime, finalize, merge, take, skip, takeWhile } from 'rxjs';
5
5
  import { END, HOME, PAGE_DOWN, PAGE_UP, UP_ARROW, DOWN_ARROW } from '@angular/cdk/keycodes';
@@ -1115,8 +1115,9 @@ class RouterStateService {
1115
1115
  this._state$ = new BehaviorSubject(this._getInitialState());
1116
1116
  this._afterInitialize$ = new BehaviorSubject(false);
1117
1117
  this.afterInitialize$ = this._afterInitialize$.pipe(filter((v) => v));
1118
+ this.latestEvent = signal(null, ...(ngDevMode ? [{ debugName: "latestEvent" }] : []));
1118
1119
  this._router.events
1119
- .pipe(filter((event) => event instanceof NavigationEnd), distinctUntilChanged((a, b) => a.url === b.url), map((event) => {
1120
+ .pipe(tap((event) => this.latestEvent.set(event)), filter((event) => event instanceof NavigationEnd), distinctUntilChanged((a, b) => a.url === b.url), map((event) => {
1120
1121
  const { url } = event;
1121
1122
  const urlWithoutQueryParams = url.split('?')[0] ?? '';
1122
1123
  const withoutFragment = urlWithoutQueryParams.split('#')[0] ?? '';
@@ -2239,13 +2240,16 @@ const transformOrReturn = (src, config) => {
2239
2240
  };
2240
2241
  /** Inject the current router event */
2241
2242
  const injectRouterEvent = () => {
2242
- const router = inject(Router);
2243
+ const routerStateService = inject(RouterStateService);
2243
2244
  const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
2244
2245
  if (!isBrowser) {
2245
- return toSignal(router.events, { initialValue: null });
2246
+ return routerStateService.latestEvent.asReadonly();
2246
2247
  }
2247
2248
  const route = window.location.pathname + window.location.search + window.location.hash;
2248
- return toSignal(router.events, { initialValue: new NavigationEnd(-1, route, route) });
2249
+ return linkedSignal({
2250
+ source: () => new NavigationEnd(-1, route, route),
2251
+ computation: () => routerStateService.latestEvent(),
2252
+ }).asReadonly();
2249
2253
  };
2250
2254
  /**
2251
2255
  * Inject the current url.