@ethlete/core 4.29.5 → 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 +12 -0
- package/fesm2022/ethlete-core.mjs +43 -8
- 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.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
|
+
|
|
9
|
+
## 4.29.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`452c6f9`](https://github.com/ethlete-io/ethdk/commit/452c6f9d3ff446fee37b719c233daf1216930e98) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix initial values inside router state being null by default
|
|
14
|
+
|
|
3
15
|
## 4.29.5
|
|
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,16 +2300,47 @@ const createRouterState = (router) => {
|
|
|
2296
2300
|
fragment,
|
|
2297
2301
|
};
|
|
2298
2302
|
};
|
|
2303
|
+
const createInitialRouterState = () => {
|
|
2304
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID)))
|
|
2305
|
+
return {
|
|
2306
|
+
data: {},
|
|
2307
|
+
pathParams: {},
|
|
2308
|
+
queryParams: {},
|
|
2309
|
+
title: null,
|
|
2310
|
+
fragment: null,
|
|
2311
|
+
};
|
|
2312
|
+
const url = new URL(window.location.href);
|
|
2313
|
+
const queryParams = {};
|
|
2314
|
+
url.searchParams.forEach((value, key) => {
|
|
2315
|
+
queryParams[key] = value;
|
|
2316
|
+
});
|
|
2317
|
+
const fragment = url.hash ? url.hash.substring(1) : null;
|
|
2318
|
+
const title = document.title || null;
|
|
2319
|
+
return {
|
|
2320
|
+
data: {},
|
|
2321
|
+
pathParams: {}, // Cannot determine path params without route configuration
|
|
2322
|
+
queryParams,
|
|
2323
|
+
title,
|
|
2324
|
+
fragment,
|
|
2325
|
+
};
|
|
2326
|
+
};
|
|
2299
2327
|
/**
|
|
2300
2328
|
* Inject the complete router state. This includes the current route data, path params, query params, title and fragment.
|
|
2301
2329
|
*/
|
|
2302
2330
|
const injectRouterState = () => {
|
|
2303
2331
|
const event = injectRouterEvent();
|
|
2304
2332
|
const router = inject(Router);
|
|
2305
|
-
const routerState = signal(
|
|
2333
|
+
const routerState = signal(createInitialRouterState(), ...(ngDevMode ? [{ debugName: "routerState" }] : []));
|
|
2306
2334
|
effect(() => {
|
|
2307
|
-
event();
|
|
2308
|
-
untracked(() =>
|
|
2335
|
+
const e = event();
|
|
2336
|
+
untracked(() => {
|
|
2337
|
+
if (e instanceof NavigationEnd && e.id === -1) {
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
else {
|
|
2341
|
+
routerState.set(createRouterState(router));
|
|
2342
|
+
}
|
|
2343
|
+
});
|
|
2309
2344
|
});
|
|
2310
2345
|
return computed(() => routerState(), { equal });
|
|
2311
2346
|
};
|