@ethlete/core 4.29.5 → 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 +6 -0
- package/fesm2022/ethlete-core.mjs +34 -3
- package/fesm2022/ethlete-core.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 4.29.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -2296,16 +2296,47 @@ 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
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
|
-
event();
|
|
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
2341
|
return computed(() => routerState(), { equal });
|
|
2311
2342
|
};
|