@cloudparker/moldex.js 0.0.109 → 0.0.110
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.
|
@@ -25,6 +25,10 @@ export declare const registerBackPress: (state: BackStateType) => void;
|
|
|
25
25
|
export declare const addBackKeyListener: (callback: (event?: PopStateEvent) => boolean) => ((event: PopStateEvent) => void) | undefined;
|
|
26
26
|
export declare const removeBackKeyListener: (listener: () => boolean) => void;
|
|
27
27
|
export declare function goBack(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Jump back to the first history entry in this tab (i.e. “home”).
|
|
30
|
+
* Falls back to a hard redirect if history is too shallow or cross‑origin.
|
|
31
|
+
*/
|
|
28
32
|
export declare function goHome(): void;
|
|
29
33
|
export declare function createRedirectUrl(): string | null;
|
|
30
34
|
/**
|
|
@@ -41,10 +41,22 @@ export const removeBackKeyListener = (listener) => {
|
|
|
41
41
|
export function goBack() {
|
|
42
42
|
history.back();
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Jump back to the first history entry in this tab (i.e. “home”).
|
|
46
|
+
* Falls back to a hard redirect if history is too shallow or cross‑origin.
|
|
47
|
+
*/
|
|
44
48
|
export function goHome() {
|
|
45
|
-
|
|
49
|
+
// number of steps back to the first entry
|
|
50
|
+
const stepsBack = -(window.history.length - 1);
|
|
51
|
+
// if we have at least one previous entry, navigate there
|
|
52
|
+
if (stepsBack < 0) {
|
|
53
|
+
window.history.go(stepsBack);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// no history to go back to — just load your root
|
|
57
|
+
window.location.replace('/');
|
|
58
|
+
}
|
|
46
59
|
}
|
|
47
|
-
;
|
|
48
60
|
export function createRedirectUrl() {
|
|
49
61
|
let pathname = window.location.pathname;
|
|
50
62
|
let redirectUrl = pathname + window.location.search || '';
|