@equinor/fusion-framework-module-navigation 7.0.4 → 7.0.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/NavigateEvent.js +24 -0
  3. package/dist/esm/NavigateEvent.js.map +1 -0
  4. package/dist/esm/NavigatedEvent.js +20 -0
  5. package/dist/esm/NavigatedEvent.js.map +1 -0
  6. package/dist/esm/NavigationConfigurator.js +13 -1
  7. package/dist/esm/NavigationConfigurator.js.map +1 -1
  8. package/dist/esm/NavigationProvider.js +8 -2
  9. package/dist/esm/NavigationProvider.js.map +1 -1
  10. package/dist/esm/enable-navigation.js +1 -0
  11. package/dist/esm/enable-navigation.js.map +1 -1
  12. package/dist/esm/index.js +2 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/lib/BaseHistory.js +9 -0
  15. package/dist/esm/lib/BaseHistory.js.map +1 -1
  16. package/dist/esm/lib/BrowserHistory.js +1 -0
  17. package/dist/esm/lib/BrowserHistory.js.map +1 -1
  18. package/dist/esm/lib/BrowserHistoryHashStack.js +1 -0
  19. package/dist/esm/lib/BrowserHistoryHashStack.js.map +1 -1
  20. package/dist/esm/lib/BrowserHistoryStack.js +15 -0
  21. package/dist/esm/lib/BrowserHistoryStack.js.map +1 -1
  22. package/dist/esm/lib/MemoryHistory.js +4 -1
  23. package/dist/esm/lib/MemoryHistory.js.map +1 -1
  24. package/dist/esm/lib/{MemoryStack.js → MemoryHistoryStack.js} +12 -1
  25. package/dist/esm/lib/MemoryHistoryStack.js.map +1 -0
  26. package/dist/esm/lib/ProxyHistory.js +1 -0
  27. package/dist/esm/lib/ProxyHistory.js.map +1 -1
  28. package/dist/esm/lib/create-history.js +1 -0
  29. package/dist/esm/lib/create-history.js.map +1 -1
  30. package/dist/esm/lib/index.js +1 -1
  31. package/dist/esm/lib/index.js.map +1 -1
  32. package/dist/esm/lib/state/{history.actions.js → actions.js} +1 -1
  33. package/dist/esm/lib/state/actions.js.map +1 -0
  34. package/dist/esm/lib/state/check-blockers.js +36 -0
  35. package/dist/esm/lib/state/check-blockers.js.map +1 -0
  36. package/dist/esm/lib/state/create-flow.js +27 -0
  37. package/dist/esm/lib/state/create-flow.js.map +1 -0
  38. package/dist/esm/lib/state/{history.reducer.js → create-history-reducer.js} +5 -2
  39. package/dist/esm/lib/state/create-history-reducer.js.map +1 -0
  40. package/dist/esm/lib/state/create-store.js +26 -0
  41. package/dist/esm/lib/state/create-store.js.map +1 -0
  42. package/dist/esm/lib/state/flow-creators.js +7 -0
  43. package/dist/esm/lib/state/flow-creators.js.map +1 -0
  44. package/dist/esm/lib/state/go.js +12 -0
  45. package/dist/esm/lib/state/go.js.map +1 -0
  46. package/dist/esm/lib/state/history.state.js +1 -39
  47. package/dist/esm/lib/state/history.state.js.map +1 -1
  48. package/dist/esm/lib/state/index.js +3 -3
  49. package/dist/esm/lib/state/index.js.map +1 -1
  50. package/dist/esm/lib/state/navigate.js +43 -0
  51. package/dist/esm/lib/state/navigate.js.map +1 -0
  52. package/dist/esm/lib/state/pop.js +14 -0
  53. package/dist/esm/lib/state/pop.js.map +1 -0
  54. package/dist/esm/lib/state/validate-current-location.js +26 -0
  55. package/dist/esm/lib/state/validate-current-location.js.map +1 -0
  56. package/dist/esm/lib/utils/index.js +2 -2
  57. package/dist/esm/lib/utils/index.js.map +1 -1
  58. package/dist/esm/lib/utils/resolve-browser-location.js +1 -52
  59. package/dist/esm/lib/utils/resolve-browser-location.js.map +1 -1
  60. package/dist/esm/lib/utils/resolve-hash-location.js +20 -0
  61. package/dist/esm/lib/utils/resolve-hash-location.js.map +1 -0
  62. package/dist/esm/lib/utils/resolve-window-location.js +18 -0
  63. package/dist/esm/lib/utils/resolve-window-location.js.map +1 -0
  64. package/dist/esm/version.js +1 -1
  65. package/dist/tsconfig.tsbuildinfo +1 -1
  66. package/dist/types/NavigateEvent.d.ts +36 -0
  67. package/dist/types/NavigatedEvent.d.ts +28 -0
  68. package/dist/types/NavigationConfigurator.d.ts +3 -0
  69. package/dist/types/NavigationProvider.d.ts +3 -0
  70. package/dist/types/index.d.ts +2 -1
  71. package/dist/types/lib/BaseHistory.d.ts +8 -0
  72. package/dist/types/lib/BrowserHistoryHashStack.d.ts +1 -0
  73. package/dist/types/lib/BrowserHistoryStack.d.ts +14 -0
  74. package/dist/types/lib/MemoryHistory.d.ts +3 -0
  75. package/dist/types/lib/{MemoryStack.d.ts → MemoryHistoryStack.d.ts} +6 -0
  76. package/dist/types/lib/ProxyHistory.d.ts +1 -1
  77. package/dist/types/lib/index.d.ts +1 -1
  78. package/dist/types/lib/state/check-blockers.d.ts +3 -0
  79. package/dist/types/lib/state/create-flow.d.ts +10 -0
  80. package/dist/types/lib/state/{history.reducer.d.ts → create-history-reducer.d.ts} +32 -32
  81. package/dist/types/lib/state/create-store.d.ts +17 -0
  82. package/dist/types/lib/state/flow-creators.d.ts +7 -0
  83. package/dist/types/lib/state/go.d.ts +3 -0
  84. package/dist/types/lib/state/history.state.d.ts +2 -23
  85. package/dist/types/lib/state/index.d.ts +4 -3
  86. package/dist/types/lib/state/navigate.d.ts +9 -0
  87. package/dist/types/lib/state/pop.d.ts +3 -0
  88. package/dist/types/lib/state/validate-current-location.d.ts +3 -0
  89. package/dist/types/lib/types.d.ts +1 -1
  90. package/dist/types/lib/utils/index.d.ts +2 -2
  91. package/dist/types/lib/utils/resolve-browser-location.d.ts +1 -42
  92. package/dist/types/lib/utils/resolve-hash-location.d.ts +10 -0
  93. package/dist/types/lib/utils/resolve-window-location.d.ts +10 -0
  94. package/dist/types/version.d.ts +1 -1
  95. package/package.json +9 -9
  96. package/src/NavigateEvent.ts +47 -0
  97. package/src/NavigatedEvent.ts +35 -0
  98. package/src/NavigationConfigurator.ts +13 -3
  99. package/src/NavigationProvider.interface.ts +1 -1
  100. package/src/NavigationProvider.ts +8 -2
  101. package/src/enable-navigation.ts +1 -0
  102. package/src/index.ts +2 -6
  103. package/src/lib/BaseHistory.ts +9 -0
  104. package/src/lib/BrowserHistory.ts +1 -0
  105. package/src/lib/BrowserHistoryHashStack.ts +1 -0
  106. package/src/lib/BrowserHistoryStack.ts +15 -0
  107. package/src/lib/MemoryHistory.ts +4 -1
  108. package/src/lib/{MemoryStack.ts → MemoryHistoryStack.ts} +11 -0
  109. package/src/lib/ProxyHistory.ts +2 -1
  110. package/src/lib/create-history.ts +1 -0
  111. package/src/lib/index.ts +1 -1
  112. package/src/lib/state/check-blockers.ts +52 -0
  113. package/src/lib/state/create-flow.ts +36 -0
  114. package/src/lib/state/{history.reducer.ts → create-history-reducer.ts} +4 -1
  115. package/src/lib/state/create-store.ts +39 -0
  116. package/src/lib/state/flow-creators.ts +7 -0
  117. package/src/lib/state/go.ts +20 -0
  118. package/src/lib/state/history.state.ts +2 -56
  119. package/src/lib/state/index.ts +4 -3
  120. package/src/lib/state/navigate.ts +58 -0
  121. package/src/lib/state/pop.ts +24 -0
  122. package/src/lib/state/validate-current-location.ts +33 -0
  123. package/src/lib/types.ts +1 -1
  124. package/src/lib/utils/index.ts +2 -2
  125. package/src/lib/utils/resolve-browser-location.ts +1 -60
  126. package/src/lib/utils/resolve-hash-location.ts +26 -0
  127. package/src/lib/utils/resolve-window-location.ts +24 -0
  128. package/src/version.ts +1 -1
  129. package/dist/esm/events.js +0 -40
  130. package/dist/esm/events.js.map +0 -1
  131. package/dist/esm/lib/MemoryStack.js.map +0 -1
  132. package/dist/esm/lib/state/history.actions.js.map +0 -1
  133. package/dist/esm/lib/state/history.flows.js +0 -207
  134. package/dist/esm/lib/state/history.flows.js.map +0 -1
  135. package/dist/esm/lib/state/history.reducer.js.map +0 -1
  136. package/dist/types/events.d.ts +0 -65
  137. package/dist/types/lib/state/history.flows.d.ts +0 -97
  138. package/src/events.ts +0 -82
  139. package/src/lib/state/history.flows.ts +0 -274
  140. /package/dist/types/lib/state/{history.actions.d.ts → actions.d.ts} +0 -0
  141. /package/src/lib/state/{history.actions.ts → actions.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ import { FrameworkEvent, type FrameworkEventInit } from '@equinor/fusion-framework-module-event';
2
+ import type { INavigationProvider } from './NavigationProvider.interface';
3
+ import type { NavigationUpdate, Path } from './lib/types';
4
+ /** Event detail for navigation events (before navigation). */
5
+ export interface NavigateEventDetail {
6
+ /** The target path or location to navigate to */
7
+ location: NavigationUpdate;
8
+ /** Optional current location before navigation */
9
+ currentLocation?: Path;
10
+ }
11
+ /**
12
+ * Event emitted before navigation occurs.
13
+ * Can be canceled by calling `preventDefault()` to block the navigation.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * eventProvider.addEventListener('onNavigate', (event) => {
18
+ * if (hasUnsavedChanges) {
19
+ * event.preventDefault();
20
+ * }
21
+ * });
22
+ * ```
23
+ */
24
+ export declare class NavigateEvent extends FrameworkEvent<FrameworkEventInit<NavigateEventDetail, INavigationProvider>> {
25
+ /** @param detail - Navigation target details. @param source - Provider dispatching the event. */
26
+ constructor(detail: NavigateEventDetail, source: INavigationProvider);
27
+ }
28
+ /** Declares navigation events in the FrameworkEventMap for type safety. */
29
+ declare module '@equinor/fusion-framework-module-event' {
30
+ interface FrameworkEventMap {
31
+ /** Event emitted before navigation occurs, can be canceled to prevent navigation */
32
+ onNavigate: NavigateEvent;
33
+ /** Event emitted after navigation occurs */
34
+ onNavigated: import('./NavigatedEvent').NavigatedEvent;
35
+ }
36
+ }
@@ -0,0 +1,28 @@
1
+ import { FrameworkEvent, type FrameworkEventInit } from '@equinor/fusion-framework-module-event';
2
+ import type { INavigationProvider } from './NavigationProvider.interface';
3
+ import type { Action, NavigationUpdate } from './lib/types';
4
+ /** Event detail for navigated events (after navigation). */
5
+ export interface NavigatedEventDetail {
6
+ /** The navigation action that occurred (PUSH, POP, REPLACE) */
7
+ action: Action;
8
+ /** The new location after navigation */
9
+ current: NavigationUpdate;
10
+ /** The previous location before navigation */
11
+ previous: NavigationUpdate;
12
+ }
13
+ /**
14
+ * Event emitted after navigation completes.
15
+ * Contains the navigation action type and both current and previous locations.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * eventProvider.addEventListener('onNavigated', (event) => {
20
+ * const { action, current, previous } = event.detail;
21
+ * console.log(`${action}: ${previous.location.pathname} -> ${current.location.pathname}`);
22
+ * });
23
+ * ```
24
+ */
25
+ export declare class NavigatedEvent extends FrameworkEvent<FrameworkEventInit<NavigatedEventDetail, INavigationProvider>> {
26
+ /** @param detail - Completed navigation details. @param source - Provider dispatching the event. */
27
+ constructor(detail: NavigatedEventDetail, source: INavigationProvider);
28
+ }
@@ -9,13 +9,16 @@ import type { History } from './lib/types';
9
9
  * Extends BaseConfigBuilder to provide fluent configuration API with Zod validation.
10
10
  */
11
11
  export declare class NavigationConfigurator extends BaseConfigBuilder<INavigationConfigurator> {
12
+ /** Creates a navigation configurator with default history and event providers. */
12
13
  constructor();
13
14
  /**
14
15
  * @deprecated Use `setBasename()` method instead
16
+ * @param value - Deprecated basename value to configure.
15
17
  */
16
18
  set basename(value: string | undefined);
17
19
  /**
18
20
  * @deprecated Use `setHistory()` method instead
21
+ * @param value - Deprecated history value to configure.
19
22
  */
20
23
  set history(value: History | undefined);
21
24
  /**
@@ -28,6 +28,7 @@ export declare class NavigationProvider extends BaseModuleProvider<INavigationCo
28
28
  #private;
29
29
  /**
30
30
  * Observable stream of navigation state updates.
31
+ * @returns Observable of navigation updates.
31
32
  *
32
33
  * Emits localized paths (with basename removed) and filters to only
33
34
  * paths within the basename scope. Late subscribers receive the last
@@ -42,10 +43,12 @@ export declare class NavigationProvider extends BaseModuleProvider<INavigationCo
42
43
  get basename(): string;
43
44
  /**
44
45
  * @deprecated Use `history` instead
46
+ * @returns The underlying `History` instance.
45
47
  */
46
48
  get navigator(): History;
47
49
  /**
48
50
  * Gets the underlying history instance.
51
+ * @returns The {@link History} instance used for navigation
49
52
  *
50
53
  * @returns The {@link History} instance used for navigation
51
54
  */
@@ -28,7 +28,8 @@ export { enableNavigation } from './enable-navigation';
28
28
  export type { INavigationProvider } from './NavigationProvider.interface';
29
29
  export { NavigationProvider } from './NavigationProvider';
30
30
  export { createHistory } from './lib/create-history';
31
- export { NavigateEvent, NavigatedEvent, type NavigateEventDetail, type NavigatedEventDetail, } from './events';
31
+ export { NavigateEvent, type NavigateEventDetail } from './NavigateEvent';
32
+ export { NavigatedEvent, type NavigatedEventDetail } from './NavigatedEvent';
32
33
  export type { Path, To, Location, History, NavigationBlocker, NavigationListener, } from './lib/types';
33
34
  /**
34
35
  * @deprecated Use {@link History} instead.
@@ -25,10 +25,12 @@ export declare abstract class BaseHistory implements History {
25
25
  /**
26
26
  * Observable stream of navigation state changes.
27
27
  * Emits on all navigation events (push, replace, pop).
28
+ * @returns Observable of the current navigation update.
28
29
  */
29
30
  get state$(): History['state$'];
30
31
  /**
31
32
  * Observable stream of navigation actions.
33
+ * @returns Observable of navigation actions.
32
34
  */
33
35
  get action$(): History['action$'];
34
36
  /**
@@ -37,6 +39,7 @@ export declare abstract class BaseHistory implements History {
37
39
  * @returns `true` if one or more blockers are registered
38
40
  */
39
41
  get hasBlockers(): boolean;
42
+ /** @param state - Reactive history state backing this implementation. */
40
43
  protected constructor(state: HistoryState);
41
44
  /**
42
45
  * Creates a valid href string for a given path.
@@ -68,10 +71,14 @@ export declare abstract class BaseHistory implements History {
68
71
  navigate(to: To, options: NavigateOptions): void;
69
72
  /**
70
73
  * Pushes a new location onto the history stack.
74
+ * @param to - Target path or partial path object.
75
+ * @param state - Optional state associated with the new location.
71
76
  */
72
77
  push(to: To, state?: unknown): void;
73
78
  /**
74
79
  * Replaces the current location in the history stack.
80
+ * @param to - Target path or partial path object.
81
+ * @param state - Optional state associated with the replacement location.
75
82
  */
76
83
  replace(to: To, state?: unknown): void;
77
84
  /**
@@ -99,6 +106,7 @@ export declare abstract class BaseHistory implements History {
99
106
  * @returns Function to unsubscribe the blocker
100
107
  */
101
108
  block(blocker: NavigationBlocker): VoidFunction;
109
+ /** Triggers a POP action for the current history location. */
102
110
  pop(): void;
103
111
  /**
104
112
  * Disposes of the history instance and cleans up all subscriptions.
@@ -16,6 +16,7 @@ import type { Location, To } from './types';
16
16
  export declare class BrowserHistoryHashStack extends BrowserHistoryStack {
17
17
  /**
18
18
  * Gets the current location from window.location.hash.
19
+ * @returns The current hash-derived navigation location.
19
20
  */
20
21
  get current(): Readonly<Location>;
21
22
  /**
@@ -20,31 +20,45 @@ export declare class BrowserHistoryStack implements HistoryStack {
20
20
  constructor(_window: Window);
21
21
  /**
22
22
  * Gets the origin of the history stack.
23
+ * @returns The browser origin used as the URL base.
23
24
  */
24
25
  get origin(): string;
25
26
  /**
26
27
  * Gets the current location.
28
+ * @returns The current browser location converted to a navigation location.
27
29
  */
28
30
  get current(): Location;
29
31
  /**
30
32
  * Pushes a new entry onto the history stack.
33
+ * @param location - Location to append to browser history.
31
34
  */
32
35
  push(location: Location): void;
33
36
  /**
34
37
  * Replaces the current entry in the history stack.
38
+ * @param location - Location to replace in browser history.
35
39
  */
36
40
  replace(location: Location): void;
37
41
  /**
38
42
  * Navigates to a location with the specified action.
43
+ * @param location - Location to navigate to.
44
+ * @param action - Native history action to perform.
39
45
  */
40
46
  navigate(location: Location, action: 'PUSH' | 'REPLACE'): void;
41
47
  /**
42
48
  * Navigates backward or forward in the history stack.
49
+ * @param delta - Number of entries to move backward or forward.
43
50
  */
44
51
  go(delta: number): void;
45
52
  /**
46
53
  * Creates a URL object for a given path.
54
+ * @param to - Target path or partial path object.
55
+ * @returns URL resolved against the browser origin.
47
56
  */
48
57
  createURL(to: To): URL;
58
+ /**
59
+ * Creates the relative URL path used by native browser history.
60
+ * @param to - Target path or partial path object.
61
+ * @returns Relative URL path for browser history.
62
+ */
49
63
  protected _createRelativePath(to: To): string;
50
64
  }
@@ -19,9 +19,12 @@ export type MemoryHistoryOptions = {
19
19
  * - **Node.js** — any environment without browser history APIs
20
20
  */
21
21
  export declare class MemoryHistory extends BaseHistory {
22
+ /** @param options - Optional initial location and history entries. */
22
23
  constructor(options?: MemoryHistoryOptions);
23
24
  /**
24
25
  * Creates a URL object for a given path using memory:// origin.
26
+ * @param to - Target path or partial path object.
27
+ * @returns URL resolved against memory://.
25
28
  */
26
29
  createURL(to: To): URL;
27
30
  }
@@ -11,10 +11,12 @@ export declare class MemoryHistoryStack implements HistoryStack {
11
11
  /**
12
12
  * Gets the origin of the history stack.
13
13
  * Always returns 'memory://' for in-memory storage.
14
+ * @returns The fixed origin used for in-memory URLs.
14
15
  */
15
16
  get origin(): string;
16
17
  /**
17
18
  * Gets the current location.
19
+ * @returns The current in-memory navigation location.
18
20
  */
19
21
  get current(): Location;
20
22
  /**
@@ -30,12 +32,14 @@ export declare class MemoryHistoryStack implements HistoryStack {
30
32
  * Pushes a new entry onto the history stack.
31
33
  *
32
34
  * Only updates the current location. History entries are managed by the reducer.
35
+ * @param location - Location to make current.
33
36
  */
34
37
  push(location: Location): void;
35
38
  /**
36
39
  * Replaces the current entry in the history stack.
37
40
  *
38
41
  * Only updates the current location. History entries are managed by the reducer.
42
+ * @param location - Location to make current.
39
43
  */
40
44
  replace(location: Location): void;
41
45
  /**
@@ -52,6 +56,8 @@ export declare class MemoryHistoryStack implements HistoryStack {
52
56
  * Creates a URL object for a given path.
53
57
  *
54
58
  * All URLs use the 'memory://' origin since this is in-memory storage.
59
+ * @param to - Target path or partial path object.
60
+ * @returns URL resolved against memory://.
55
61
  */
56
62
  createURL(to: To): URL;
57
63
  }
@@ -1,6 +1,6 @@
1
1
  import type { Observable } from 'rxjs';
2
2
  import type { History, NavigateOptions, NavigationBlocker, NavigationListener, NavigationUpdate, Path, To } from './types';
3
- import type { Actions } from './state/history.actions';
3
+ import type { Actions } from './state/actions';
4
4
  /**
5
5
  * A lightweight proxy that delegates every {@link History} operation to an
6
6
  * underlying target instance.
@@ -13,5 +13,5 @@ export { MemoryHistory } from './MemoryHistory';
13
13
  export { ProxyHistory } from './ProxyHistory';
14
14
  export { BrowserHistoryStack } from './BrowserHistoryStack';
15
15
  export { BrowserHistoryHashStack as HashHistoryStack } from './BrowserHistoryHashStack';
16
- export { MemoryHistoryStack } from './MemoryStack';
16
+ export { MemoryHistoryStack } from './MemoryHistoryStack';
17
17
  export type { Action, History, HistoryStack, Location, NavigateOptions, NavigationListener, NavigationUpdate, Path, To, } from './types';
@@ -0,0 +1,3 @@
1
+ import type { HistoryFlowCreator } from './navigate';
2
+ /** Flow creator that gates navigation actions through registered blockers. */
3
+ export declare const checkBlockers: HistoryFlowCreator;
@@ -0,0 +1,10 @@
1
+ import type { HistoryFlowCreator } from './navigate';
2
+ /**
3
+ * Creates a combined history flow from multiple flow creators.
4
+ * @param flowCreators - Flow creators to combine.
5
+ * @param options - Optional blocker configuration.
6
+ * @returns A combined history flow creator.
7
+ */
8
+ export declare const createFlow: (flowCreators: HistoryFlowCreator[], options?: {
9
+ skipBlockCheck?: boolean;
10
+ }) => HistoryFlowCreator;
@@ -13,59 +13,41 @@ import type { LocationState, NavigationUpdate } from '../types';
13
13
  */
14
14
  export declare const createHistoryReducer: (initial: NavigationUpdate | (() => LocationState), options?: {
15
15
  maxHistory?: number;
16
- }) => import("@equinor/fusion-observable").ReducerWithInitialState<LocationState, import("@equinor/fusion-observable").PayloadAction<{
17
- to: import("..").To;
18
- options: import("..").NavigateOptions;
19
- }, "navigation/navigate::request", {
20
- key: string;
21
- }, never> | {
16
+ }) => import("@equinor/fusion-observable").ReducerWithInitialState<LocationState, {
22
17
  payload: {
23
- reason: string | undefined;
24
- };
25
- type: "navigation/navigate::abort";
26
- } | {
27
- payload: {
28
- delta: number;
18
+ update: NavigationUpdate;
29
19
  };
30
- type: "navigation/go::request";
20
+ type: "navigation/navigate::success";
31
21
  } | {
32
22
  payload: {
33
- update: NavigationUpdate | undefined;
23
+ error: Error;
34
24
  };
35
- type: "navigation/pop::request";
36
- } | {
37
- payload: {};
38
- type: "navigation/navigationValidation::request";
25
+ type: "navigation/navigate::failure";
39
26
  } | {
40
27
  payload: {
41
- blocker: import("../types").NavigationBlocker;
28
+ reason: string | undefined;
42
29
  };
43
- type: "navigation/addBlocker";
30
+ type: "navigation/navigate::abort";
44
31
  } | {
45
32
  payload: {
46
- blocker: import("../types").NavigationBlocker;
33
+ delta: number;
47
34
  };
48
- type: "navigation/removeBlocker";
35
+ type: "navigation/go::request";
49
36
  } | {
50
37
  payload: {
51
38
  update: NavigationUpdate;
52
39
  };
53
- type: "navigation/navigate::success";
40
+ type: "navigation/go::success";
54
41
  } | {
55
42
  payload: {
56
43
  error: Error;
57
44
  };
58
- type: "navigation/navigate::failure";
59
- } | {
60
- payload: {
61
- update: NavigationUpdate;
62
- };
63
- type: "navigation/go::success";
45
+ type: "navigation/go::failure";
64
46
  } | {
65
47
  payload: {
66
- error: Error;
48
+ update: NavigationUpdate | undefined;
67
49
  };
68
- type: "navigation/go::failure";
50
+ type: "navigation/pop::request";
69
51
  } | {
70
52
  payload: {
71
53
  update: NavigationUpdate;
@@ -76,6 +58,9 @@ export declare const createHistoryReducer: (initial: NavigationUpdate | (() => L
76
58
  error: Error;
77
59
  };
78
60
  type: "navigation/pop::failure";
61
+ } | {
62
+ payload: {};
63
+ type: "navigation/navigationValidation::request";
79
64
  } | {
80
65
  payload: {
81
66
  update: NavigationUpdate;
@@ -86,4 +71,19 @@ export declare const createHistoryReducer: (initial: NavigationUpdate | (() => L
86
71
  error: Error;
87
72
  };
88
73
  type: "navigation/navigationValidation::failure";
89
- }>;
74
+ } | {
75
+ payload: {
76
+ blocker: import("../types").NavigationBlocker;
77
+ };
78
+ type: "navigation/addBlocker";
79
+ } | {
80
+ payload: {
81
+ blocker: import("../types").NavigationBlocker;
82
+ };
83
+ type: "navigation/removeBlocker";
84
+ } | import("@equinor/fusion-observable").PayloadAction<{
85
+ to: import("..").To;
86
+ options: import("..").NavigateOptions;
87
+ }, "navigation/navigate::request", {
88
+ key: string;
89
+ }, never>>;
@@ -0,0 +1,17 @@
1
+ import { type ReducerWithInitialState } from '@equinor/fusion-observable';
2
+ import { type Actions } from './actions';
3
+ import type { HistoryFlowCreator } from './navigate';
4
+ import type { HistoryStack, LocationState } from '../types';
5
+ import type { HistoryState } from './history.state';
6
+ /**
7
+ * Creates a history store with the specified stack and reducer.
8
+ * @param stack - The history stack implementation.
9
+ * @param reducer - The reducer that handles state transitions.
10
+ * @param options - Optional flow configuration.
11
+ * @returns A fully-initialized history state with flows attached.
12
+ */
13
+ export declare const createStore: (stack: HistoryStack, reducer: ReducerWithInitialState<LocationState, Actions>, options?: {
14
+ flows?: HistoryFlowCreator[];
15
+ skipBlockCheck?: boolean;
16
+ validateCurrentLocation?: boolean;
17
+ }) => HistoryState;
@@ -0,0 +1,7 @@
1
+ /** Collection of flow creators for history state management. */
2
+ export declare const flowCreators: {
3
+ navigate: import("./navigate").HistoryFlowCreator;
4
+ go: import("./navigate").HistoryFlowCreator;
5
+ pop: import("./navigate").HistoryFlowCreator;
6
+ validateCurrentLocation: import("./navigate").HistoryFlowCreator;
7
+ };
@@ -0,0 +1,3 @@
1
+ import type { HistoryFlowCreator } from './navigate';
2
+ /** Flow creator for handling go back and forward actions. */
3
+ export declare const go: HistoryFlowCreator;
@@ -1,6 +1,5 @@
1
- import { type FlowState, type ReducerWithInitialState } from '@equinor/fusion-observable';
2
- import { actions, type Actions } from './history.actions';
3
- import { type HistoryFlowCreator } from './history.flows';
1
+ import type { FlowState } from '@equinor/fusion-observable';
2
+ import type { actions } from './actions';
4
3
  import type { HistoryStack, LocationState } from '../types';
5
4
  /**
6
5
  * History state containing flow state and stack.
@@ -11,23 +10,3 @@ export type HistoryState = FlowState<LocationState, typeof actions> & {
11
10
  /**
12
11
  * Default flows for history state management.
13
12
  */
14
- export declare const defaultFlows: HistoryFlowCreator[];
15
- /**
16
- * Creates a history store with the specified stack and reducer.
17
- *
18
- * Combines the reactive state container with a {@link HistoryStack} and wires
19
- * up navigation flows for action processing.
20
- *
21
- * @param stack - The history stack implementation (browser, hash, or memory)
22
- * @param reducer - The reducer that handles state transitions
23
- * @param options - Optional configuration options
24
- * @param options.flows - Custom flow creators (defaults to {@link defaultFlows})
25
- * @param options.skipBlockCheck - Skip blocker checking in flows
26
- * @param options.validateCurrentLocation - Add location validation flow
27
- * @returns A fully-initialized {@link HistoryState} with flows attached
28
- */
29
- export declare const createStore: (stack: HistoryStack, reducer: ReducerWithInitialState<LocationState, Actions>, options?: {
30
- flows?: HistoryFlowCreator[];
31
- skipBlockCheck?: boolean;
32
- validateCurrentLocation?: boolean;
33
- }) => HistoryState;
@@ -1,3 +1,4 @@
1
- export { createStore, type HistoryState } from './history.state';
2
- export { createHistoryReducer } from './history.reducer';
3
- export { actions, type Actions } from './history.actions';
1
+ export { createStore } from './create-store';
2
+ export type { HistoryState } from './history.state';
3
+ export { createHistoryReducer } from './create-history-reducer';
4
+ export { actions, type Actions } from './actions';
@@ -0,0 +1,9 @@
1
+ import type { Flow } from '@equinor/fusion-observable';
2
+ import { type Actions } from './actions';
3
+ import { type LocationState, type HistoryStack } from '../types';
4
+ /** History flow for processing navigation actions. */
5
+ export type HistoryFlow = Flow<Actions, LocationState>;
6
+ /** Factory function that creates a history flow from a stack. */
7
+ export type HistoryFlowCreator = (stack: HistoryStack) => HistoryFlow;
8
+ /** Flow creator for handling navigate actions. */
9
+ export declare const navigate: HistoryFlowCreator;
@@ -0,0 +1,3 @@
1
+ import type { HistoryFlowCreator } from './navigate';
2
+ /** Flow creator for handling POP actions from browser navigation. */
3
+ export declare const pop: HistoryFlowCreator;
@@ -0,0 +1,3 @@
1
+ import type { HistoryFlowCreator } from './navigate';
2
+ /** Flow creator that validates the current stack location against reducer state. */
3
+ export declare const validateCurrentLocation: HistoryFlowCreator;
@@ -1,5 +1,5 @@
1
1
  import type { Observable } from 'rxjs';
2
- import type { Actions } from './state/history.actions';
2
+ import type { Actions } from './state/actions';
3
3
  /**
4
4
  * Actions represent the type of change to a location value.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  export { pathToString } from './path-to-string';
2
2
  export { pathToUrl } from './path-to-url';
3
3
  export { resolvePath } from './resolve-path';
4
- export { resolveWindowLocation } from './resolve-browser-location';
5
- export { resolveHashLocation } from './resolve-browser-location';
4
+ export { resolveWindowLocation } from './resolve-window-location';
5
+ export { resolveHashLocation } from './resolve-hash-location';
@@ -1,42 +1 @@
1
- import type { Location } from '../types';
2
- /**
3
- * Resolves the current location from window.location.
4
- *
5
- * @param window - The window object to extract location from
6
- * @param target - Optional target object with state
7
- * @returns The current location with pathname, search, hash, state, and key
8
- *
9
- * @example
10
- * ```ts
11
- * // If window.location is 'https://example.com/users?id=1#section'
12
- * resolveWindowLocation(window)
13
- * // { pathname: '/users', search: '?id=1', hash: '#section', state: undefined, key: 'unknown' }
14
- *
15
- * resolveWindowLocation(window, { state: { userId: 123 } })
16
- * // { pathname: '/users', search: '?id=1', hash: '#section', state: { userId: 123 }, key: 'abc123' }
17
- * ```
18
- */
19
- export declare const resolveWindowLocation: (window: Window, target?: {
20
- state: unknown;
21
- }) => Location;
22
- /**
23
- * Resolves the current location from window.location.hash.
24
- *
25
- * @param window - The window object to extract location from
26
- * @param target - Optional target object with state
27
- * @returns The current location with pathname, search, hash, state, and key
28
- *
29
- * @example
30
- * ```ts
31
- * // If window.location.hash is '#/users?id=1#section'
32
- * resolveHashLocation(window)
33
- * // { pathname: '/users', search: '?id=1', hash: '#section', state: undefined, key: 'unknown' }
34
- *
35
- * // If window.location.hash is '#/dashboard'
36
- * resolveHashLocation(window)
37
- * // { pathname: '/dashboard', search: '', hash: '', state: undefined, key: 'unknown' }
38
- * ```
39
- */
40
- export declare const resolveHashLocation: (window: Window, target?: {
41
- state: unknown;
42
- }) => Location;
1
+ export { resolveWindowLocation } from './resolve-window-location';
@@ -0,0 +1,10 @@
1
+ import type { Location } from '../types';
2
+ /**
3
+ * Resolves the current location from window.location.hash.
4
+ * @param window - The window object to extract location from.
5
+ * @param target - Optional target object with state.
6
+ * @returns The current hash-based navigation location.
7
+ */
8
+ export declare const resolveHashLocation: (window: Window, target?: {
9
+ state: unknown;
10
+ }) => Location;
@@ -0,0 +1,10 @@
1
+ import type { Location } from '../types';
2
+ /**
3
+ * Resolves the current location from window.location.
4
+ * @param window - The window object to extract location from.
5
+ * @param target - Optional target object with state.
6
+ * @returns The current browser navigation location.
7
+ */
8
+ export declare const resolveWindowLocation: (window: Window, target?: {
9
+ state: unknown;
10
+ }) => Location;
@@ -1 +1 @@
1
- export declare const version = "7.0.4";
1
+ export declare const version = "7.0.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-navigation",
3
- "version": "7.0.4",
3
+ "version": "7.0.6",
4
4
  "description": "Navigation module for Fusion Framework providing routing and navigation capabilities using React Router 7",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",
@@ -36,20 +36,20 @@
36
36
  "zod": "^4.4.3"
37
37
  },
38
38
  "devDependencies": {
39
- "jsdom": "^29.0.2",
39
+ "jsdom": "^30.0.1",
40
40
  "rxjs": "^7.8.1",
41
- "typescript": "^6.0.3",
41
+ "typescript": "^7.0.2",
42
42
  "vitest": "^4.1.0",
43
- "@equinor/fusion-framework-module": "^6.1.0",
44
- "@equinor/fusion-framework-module-event": "^6.0.0",
45
- "@equinor/fusion-observable": "^9.0.2",
46
- "@equinor/fusion-framework-module-telemetry": "^6.0.0"
43
+ "@equinor/fusion-framework-module": "^6.1.1",
44
+ "@equinor/fusion-framework-module-event": "^6.0.1",
45
+ "@equinor/fusion-framework-module-telemetry": "^7.0.1",
46
+ "@equinor/fusion-observable": "^9.1.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@remix-run/router": "^1.0.0",
50
50
  "rxjs": "^7.0.0",
51
- "@equinor/fusion-framework-module": "^6.1.0",
52
- "@equinor/fusion-observable": "^9.0.2"
51
+ "@equinor/fusion-framework-module": "^6.1.1",
52
+ "@equinor/fusion-observable": "^9.1.1"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsc -b",