@pushwoosh/kit-helpers 4.11.0 → 4.11.1

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/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './hooks/useClickAway';
5
5
  export { identifyOpenReplaySession } from './analytics/identifyOpenReplay';
6
6
  export { trackEvent } from './analytics/trackEvent';
7
7
  export { formatNumber } from './formatNumber';
8
+ export { readNavigationHistory, writeNavigationHistory } from './navigation';
8
9
  export { default as usePersistentFunction } from './hooks/usePersistentFunction';
9
10
  export { default as useEffectOnce } from './hooks/useEffectOnce';
10
11
  export { default as useMountedState } from './hooks/useMountedState';
package/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './hooks/useClickAway';
5
5
  export { identifyOpenReplaySession } from './analytics/identifyOpenReplay';
6
6
  export { trackEvent } from './analytics/trackEvent';
7
7
  export { formatNumber } from './formatNumber';
8
+ export { readNavigationHistory, writeNavigationHistory } from './navigation';
8
9
  export { default as usePersistentFunction } from './hooks/usePersistentFunction';
9
10
  export { default as useEffectOnce } from './hooks/useEffectOnce';
10
11
  export { default as useMountedState } from './hooks/useMountedState';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reads the navigation stack from sessionStorage.
3
+ * The last element is the current page.
4
+ */
5
+ export declare function readNavigationHistory(): string[];
6
+ /**
7
+ * Persists the navigation stack to sessionStorage.
8
+ */
9
+ export declare function writeNavigationHistory(entries: string[]): void;
package/navigation.js ADDED
@@ -0,0 +1,25 @@
1
+ const STORAGE_KEY = 'pw_navigation_history';
2
+ const MAX_ENTRIES = 50;
3
+ /**
4
+ * Reads the navigation stack from sessionStorage.
5
+ * The last element is the current page.
6
+ */
7
+ export function readNavigationHistory() {
8
+ try {
9
+ const raw = sessionStorage.getItem(STORAGE_KEY);
10
+ const parsed = raw ? JSON.parse(raw) : null;
11
+ return Array.isArray(parsed) && parsed.every(e => typeof e === 'string') ? parsed.slice(-MAX_ENTRIES) : [];
12
+ } catch {
13
+ return [];
14
+ }
15
+ }
16
+ /**
17
+ * Persists the navigation stack to sessionStorage.
18
+ */
19
+ export function writeNavigationHistory(entries) {
20
+ try {
21
+ sessionStorage.setItem(STORAGE_KEY, JSON.stringify(entries.slice(-MAX_ENTRIES)));
22
+ } catch {
23
+ // sessionStorage is unavailable (private mode / quota exceeded) — silently ignore.
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/kit-helpers",
3
- "version": "4.11.0",
3
+ "version": "4.11.1",
4
4
  "description": "React component for build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",