@ethlete/core 4.29.4 → 4.29.6
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 +36 -5
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ethlete/core
|
|
2
2
|
|
|
3
|
+
## 4.29.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
## 4.29.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0ffe4f9`](https://github.com/ethlete-io/ethdk/commit/0ffe4f9b629ab47e0632fa1fdb8eb99a6552ca4b) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix router state not getting updated on initial load once the router is ready
|
|
14
|
+
|
|
3
15
|
## 4.29.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -2296,18 +2296,49 @@ const createRouterState = (router) => {
|
|
|
2296
2296
|
fragment,
|
|
2297
2297
|
};
|
|
2298
2298
|
};
|
|
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
|
+
};
|
|
2299
2323
|
/**
|
|
2300
2324
|
* Inject the complete router state. This includes the current route data, path params, query params, title and fragment.
|
|
2301
2325
|
*/
|
|
2302
2326
|
const injectRouterState = () => {
|
|
2303
|
-
const
|
|
2327
|
+
const event = injectRouterEvent();
|
|
2304
2328
|
const router = inject(Router);
|
|
2305
|
-
const routerState = signal(
|
|
2329
|
+
const routerState = signal(createInitialRouterState(), ...(ngDevMode ? [{ debugName: "routerState" }] : []));
|
|
2306
2330
|
effect(() => {
|
|
2307
|
-
|
|
2308
|
-
untracked(() =>
|
|
2331
|
+
const e = event();
|
|
2332
|
+
untracked(() => {
|
|
2333
|
+
if (e instanceof NavigationEnd && e.id === -1) {
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
else {
|
|
2337
|
+
routerState.set(createRouterState(router));
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2309
2340
|
});
|
|
2310
|
-
return routerState
|
|
2341
|
+
return computed(() => routerState(), { equal });
|
|
2311
2342
|
};
|
|
2312
2343
|
/** Inject a signal containing the current route fragment (the part after the # inside the url if present) */
|
|
2313
2344
|
const injectFragment = (config) => {
|