@ethlete/core 4.29.6 → 4.29.8
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 +12 -0
- package/fesm2022/ethlete-core.mjs +10 -30
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ethlete/core
|
|
2
2
|
|
|
3
|
+
## 4.29.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1e9dca5`](https://github.com/ethlete-io/ethdk/commit/1e9dca56ca6cf57b6a65a93e971649cacaa5428f) Thanks [@TomTomB](https://github.com/TomTomB)! - Do not try to create a router state based on the native browser url
|
|
8
|
+
|
|
9
|
+
## 4.29.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`b79cf6a`](https://github.com/ethlete-io/ethdk/commit/b79cf6a845496d4e5c1df63c851c96dceba50881) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix router event signal skipping the initial navigation
|
|
14
|
+
|
|
3
15
|
## 4.29.6
|
|
4
16
|
|
|
5
17
|
### 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,
|
|
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
|
|
2243
|
+
const routerStateService = inject(RouterStateService);
|
|
2243
2244
|
const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
2244
2245
|
if (!isBrowser) {
|
|
2245
|
-
return
|
|
2246
|
+
return routerStateService.latestEvent.asReadonly();
|
|
2246
2247
|
}
|
|
2247
2248
|
const route = window.location.pathname + window.location.search + window.location.hash;
|
|
2248
|
-
return
|
|
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.
|
|
@@ -2296,37 +2300,13 @@ const createRouterState = (router) => {
|
|
|
2296
2300
|
fragment,
|
|
2297
2301
|
};
|
|
2298
2302
|
};
|
|
2299
|
-
const createInitialRouterState = () => {
|
|
2300
|
-
if (!isPlatformBrowser(inject(PLATFORM_ID)))
|
|
2301
|
-
return {
|
|
2302
|
-
data: {},
|
|
2303
|
-
pathParams: {},
|
|
2304
|
-
queryParams: {},
|
|
2305
|
-
title: null,
|
|
2306
|
-
fragment: null,
|
|
2307
|
-
};
|
|
2308
|
-
const url = new URL(window.location.href);
|
|
2309
|
-
const queryParams = {};
|
|
2310
|
-
url.searchParams.forEach((value, key) => {
|
|
2311
|
-
queryParams[key] = value;
|
|
2312
|
-
});
|
|
2313
|
-
const fragment = url.hash ? url.hash.substring(1) : null;
|
|
2314
|
-
const title = document.title || null;
|
|
2315
|
-
return {
|
|
2316
|
-
data: {},
|
|
2317
|
-
pathParams: {}, // Cannot determine path params without route configuration
|
|
2318
|
-
queryParams,
|
|
2319
|
-
title,
|
|
2320
|
-
fragment,
|
|
2321
|
-
};
|
|
2322
|
-
};
|
|
2323
2303
|
/**
|
|
2324
2304
|
* Inject the complete router state. This includes the current route data, path params, query params, title and fragment.
|
|
2325
2305
|
*/
|
|
2326
2306
|
const injectRouterState = () => {
|
|
2327
2307
|
const event = injectRouterEvent();
|
|
2328
2308
|
const router = inject(Router);
|
|
2329
|
-
const routerState = signal(
|
|
2309
|
+
const routerState = signal(createRouterState(router), ...(ngDevMode ? [{ debugName: "routerState" }] : []));
|
|
2330
2310
|
effect(() => {
|
|
2331
2311
|
const e = event();
|
|
2332
2312
|
untracked(() => {
|