@equinor/fusion-framework-module-navigation 7.0.0-next.1 → 7.0.0

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 (66) hide show
  1. package/CHANGELOG.md +35 -8
  2. package/README.md +97 -614
  3. package/dist/esm/NavigationProvider.js +57 -23
  4. package/dist/esm/NavigationProvider.js.map +1 -1
  5. package/dist/esm/events.js +20 -3
  6. package/dist/esm/events.js.map +1 -1
  7. package/dist/esm/index.js +23 -0
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/lib/BaseHistory.js +23 -6
  10. package/dist/esm/lib/BaseHistory.js.map +1 -1
  11. package/dist/esm/lib/BrowserHistoryStack.js +5 -6
  12. package/dist/esm/lib/BrowserHistoryStack.js.map +1 -1
  13. package/dist/esm/lib/MemoryHistory.js +13 -6
  14. package/dist/esm/lib/MemoryHistory.js.map +1 -1
  15. package/dist/esm/lib/MemoryStack.js +1 -0
  16. package/dist/esm/lib/MemoryStack.js.map +1 -1
  17. package/dist/esm/lib/create-history.js +7 -13
  18. package/dist/esm/lib/create-history.js.map +1 -1
  19. package/dist/esm/lib/index.js +9 -0
  20. package/dist/esm/lib/index.js.map +1 -1
  21. package/dist/esm/lib/state/history.flows.js +7 -12
  22. package/dist/esm/lib/state/history.flows.js.map +1 -1
  23. package/dist/esm/lib/state/history.reducer.js +8 -4
  24. package/dist/esm/lib/state/history.reducer.js.map +1 -1
  25. package/dist/esm/lib/state/history.state.js +9 -3
  26. package/dist/esm/lib/state/history.state.js.map +1 -1
  27. package/dist/esm/lib/utils/resolve-browser-location.js +2 -2
  28. package/dist/esm/lib/utils/resolve-browser-location.js.map +1 -1
  29. package/dist/esm/module.js +4 -4
  30. package/dist/esm/version.js +1 -1
  31. package/dist/esm/version.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/dist/types/NavigationConfigurator.interface.d.ts +25 -5
  34. package/dist/types/NavigationProvider.d.ts +57 -23
  35. package/dist/types/NavigationProvider.interface.d.ts +20 -7
  36. package/dist/types/events.d.ts +20 -3
  37. package/dist/types/index.d.ts +24 -1
  38. package/dist/types/lib/BaseHistory.d.ts +23 -6
  39. package/dist/types/lib/BrowserHistoryStack.d.ts +5 -6
  40. package/dist/types/lib/MemoryHistory.d.ts +5 -5
  41. package/dist/types/lib/create-history.d.ts +7 -13
  42. package/dist/types/lib/index.d.ts +9 -0
  43. package/dist/types/lib/state/history.flows.d.ts +6 -11
  44. package/dist/types/lib/state/history.reducer.d.ts +8 -4
  45. package/dist/types/lib/state/history.state.d.ts +9 -3
  46. package/dist/types/lib/types.d.ts +39 -8
  47. package/dist/types/version.d.ts +1 -1
  48. package/package.json +11 -12
  49. package/src/NavigationConfigurator.interface.ts +28 -5
  50. package/src/NavigationProvider.interface.ts +20 -7
  51. package/src/NavigationProvider.ts +57 -23
  52. package/src/events.ts +20 -3
  53. package/src/index.ts +25 -1
  54. package/src/lib/BaseHistory.ts +23 -6
  55. package/src/lib/BrowserHistoryStack.ts +5 -6
  56. package/src/lib/MemoryHistory.ts +13 -6
  57. package/src/lib/MemoryStack.ts +1 -0
  58. package/src/lib/create-history.ts +7 -13
  59. package/src/lib/index.ts +10 -0
  60. package/src/lib/state/history.flows.ts +7 -12
  61. package/src/lib/state/history.reducer.ts +8 -4
  62. package/src/lib/state/history.state.ts +9 -3
  63. package/src/lib/types.ts +39 -8
  64. package/src/lib/utils/resolve-browser-location.ts +2 -2
  65. package/src/module.ts +4 -4
  66. package/src/version.ts +1 -1
@@ -3,15 +3,35 @@ import type { ITelemetryProvider } from '@equinor/fusion-framework-module-teleme
3
3
  import type { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
4
4
  /**
5
5
  * Configuration object for the navigation module.
6
- * Provides options for customizing history, basename, telemetry, and event settings.
6
+ *
7
+ * Provides options for customizing the history implementation, basename prefix,
8
+ * telemetry tracking, and event dispatching used by the {@link NavigationProvider}.
7
9
  */
8
10
  export interface INavigationConfigurator {
9
- /** Optional base pathname for the application (e.g., "/app") */
11
+ /**
12
+ * Base pathname prefix for the application (e.g. `"/apps/my-app"`).
13
+ *
14
+ * When set, the navigation provider automatically prepends this prefix to
15
+ * outgoing paths and strips it from incoming paths, so consumer code
16
+ * operates on clean, basename-free paths.
17
+ */
10
18
  basename?: string;
11
- /** Optional custom history instance (browser, hash, or memory). If not provided, defaults to browser history. */
19
+ /**
20
+ * Custom {@link History} instance for navigation.
21
+ *
22
+ * If not provided, defaults to browser history in browser environments
23
+ * or memory history in Node.js environments. Create instances with
24
+ * {@link createHistory}.
25
+ */
12
26
  history?: History;
13
- /** Optional telemetry provider for tracking navigation events */
27
+ /**
28
+ * Telemetry provider for tracking navigation events, location changes,
29
+ * and errors for monitoring and debugging.
30
+ */
14
31
  telemetry?: ITelemetryProvider;
15
- /** Optional event provider for dispatching navigation events */
32
+ /**
33
+ * Event provider for dispatching {@link NavigateEvent} and {@link NavigatedEvent}.
34
+ * Allows other modules to listen for and react to navigation changes.
35
+ */
16
36
  eventProvider?: IEventModuleProvider;
17
37
  }
@@ -6,27 +6,38 @@ import type { INavigationConfigurator } from './NavigationConfigurator.interface
6
6
  import type { History, NavigateOptions, NavigationUpdate, Path, To } from './lib/types';
7
7
  /**
8
8
  * Navigation provider implementation.
9
- * Manages routing and navigation state with basename localization.
9
+ *
10
+ * Manages routing and navigation state with automatic basename localization.
11
+ * Wraps a {@link History} instance to expose observable state, path localization,
12
+ * and router creation.
10
13
  *
11
14
  * @remarks
12
- * This provider:
13
- * - Wraps the Navigator to provide observable navigation state
14
- * - Localizes paths by removing basename prefix
15
- * - Creates routers compatible with industry-standard routers (Remix/React Router)
16
- * - Handles navigation actions (push, replace, createHref, etc.)
15
+ * - Emits localized paths (basename removed) to consumers via {@link NavigationProvider.state$ | state$}
16
+ * - Internally prefixes paths with the basename before forwarding to the history stack
17
+ * - Creates routers compatible with Remix / React Router via {@link NavigationProvider.createRouter | createRouter}
18
+ * - Dispatches {@link NavigatedEvent} and telemetry on navigation changes
17
19
  *
18
- * Path localization ensures that consumers receive paths relative to the basename,
19
- * while internally we work with full paths including basename.
20
+ * @example
21
+ * ```ts
22
+ * const provider = new NavigationProvider({ version, config });
23
+ * provider.push('/users');
24
+ * console.log(provider.path.pathname); // '/users'
25
+ * ```
20
26
  */
21
27
  export declare class NavigationProvider extends BaseModuleProvider<INavigationConfigurator> implements INavigationProvider {
22
28
  #private;
23
29
  /**
24
30
  * Observable stream of navigation state updates.
25
- * Emits localized paths (with basename removed) for consumers.
31
+ *
32
+ * Emits localized paths (with basename removed) and filters to only
33
+ * paths within the basename scope. Late subscribers receive the last
34
+ * emitted value immediately.
26
35
  */
27
36
  get state$(): Observable<NavigationUpdate>;
28
37
  /**
29
- * Gets the basename.
38
+ * Gets the basename prefix configured for this provider.
39
+ *
40
+ * @returns The basename string, or an empty string if none is configured
30
41
  */
31
42
  get basename(): string;
32
43
  /**
@@ -34,16 +45,22 @@ export declare class NavigationProvider extends BaseModuleProvider<INavigationCo
34
45
  */
35
46
  get navigator(): History;
36
47
  /**
37
- * Gets the history instance.
48
+ * Gets the underlying history instance.
49
+ *
50
+ * @returns The {@link History} instance used for navigation
38
51
  */
39
52
  get history(): History;
40
53
  /**
41
- * Gets the current localized path (basename removed).
54
+ * Gets the current localized path with the basename prefix removed.
55
+ *
56
+ * @returns A {@link Path} object representing the current location without basename
42
57
  */
43
58
  get path(): Path;
44
59
  /**
60
+ * Creates a new {@link NavigationProvider}.
61
+ *
45
62
  * @param args - Configuration arguments containing module config
46
- * @throws {Error} If no history is provided in the configuration
63
+ * @throws {Error} If no history instance is provided in the configuration
47
64
  */
48
65
  constructor(args: BaseModuleProviderCtorArgs<INavigationConfigurator>);
49
66
  /**
@@ -58,22 +75,30 @@ export declare class NavigationProvider extends BaseModuleProvider<INavigationCo
58
75
  /**
59
76
  * Creates a router instance from route configuration.
60
77
  *
61
- * @deprecated Use `@equinor/fusion-framework-react-router` instead
78
+ * @deprecated Use `@equinor/fusion-framework-react-router` instead.
62
79
  *
63
- * @param routes - Route configuration objects compatible with industry-standard routers (Remix/React Router)
64
- * @returns A configured and initialized router instance
80
+ * @param routes - Route configuration objects compatible with Remix/React Router
81
+ * @returns A configured and initialized {@link Router} instance with basename applied
65
82
  */
66
83
  createRouter(routes: AgnosticRouteObject[]): import("@remix-run/router").Router;
67
84
  /**
68
- * Creates a localized href string for navigation.
85
+ * Creates a localized href string including the basename prefix.
69
86
  *
70
- * @param to - Optional path or location (defaults to current path)
87
+ * @param to - Path or location to resolve (defaults to current path)
88
+ * @returns Fully-qualified href string with basename included
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // basename = '/apps/my-app'
93
+ * provider.createHref('/users'); // '/apps/my-app/users'
94
+ * ```
71
95
  */
72
96
  createHref(to?: To): string;
73
97
  /**
74
- * Creates a full URL object for navigation.
98
+ * Creates a full {@link URL} object including the basename prefix.
75
99
  *
76
- * @param to - Optional path or location (defaults to current path)
100
+ * @param to - Path or location to resolve (defaults to current path)
101
+ * @returns A {@link URL} instance representing the resolved navigation target
77
102
  */
78
103
  createURL(to?: To): URL;
79
104
  /**
@@ -98,15 +123,24 @@ export declare class NavigationProvider extends BaseModuleProvider<INavigationCo
98
123
  */
99
124
  navigate(to?: To, options?: Partial<NavigateOptions>): void;
100
125
  /**
101
- * Checks if a pathname is within the basename scope.
126
+ * Checks whether a pathname falls within the configured basename scope.
127
+ *
128
+ * @param pathname - The pathname to check
129
+ * @returns `true` if the pathname starts with the basename (or no basename is set)
102
130
  */
103
131
  protected _isWithinBasenameScope(pathname: string): boolean;
104
132
  /**
105
- * Localizes a path by removing the basename prefix.
133
+ * Localizes a path by stripping the basename prefix from the pathname.
134
+ *
135
+ * @param location - The full path to localize
136
+ * @returns A new {@link Path} with the basename removed from the pathname
106
137
  */
107
138
  protected _localizePath(location: Path): Path;
108
139
  /**
109
- * Creates a full path object from a target location, adding basename prefix.
140
+ * Creates a full path object from a target location, prepending the basename prefix.
141
+ *
142
+ * @param to - The target location (string path or partial {@link Path} object)
143
+ * @returns A partial {@link Path} with basename prepended to the pathname
110
144
  */
111
145
  protected _createToPath(to: To): Partial<Path>;
112
146
  }
@@ -5,7 +5,17 @@ import type { Observable } from 'rxjs';
5
5
  import type { IModuleProvider } from '@equinor/fusion-framework-module';
6
6
  /**
7
7
  * Navigation provider interface.
8
- * Provides routing and navigation capabilities with basename localization.
8
+ *
9
+ * Provides routing and navigation capabilities with automatic basename
10
+ * localization. Consumers work with clean paths (e.g. `/users`) while the
11
+ * underlying history operates on full paths (e.g. `/apps/my-app/users`).
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const nav: INavigationProvider = framework.modules.navigation;
16
+ * nav.push('/users');
17
+ * console.log(nav.path.pathname); // '/users'
18
+ * ```
9
19
  */
10
20
  export interface INavigationProvider extends IModuleProvider {
11
21
  /**
@@ -35,20 +45,23 @@ export interface INavigationProvider extends IModuleProvider {
35
45
  /**
36
46
  * Creates a router instance from route configuration.
37
47
  *
38
- * @param routes - Route configuration objects compatible with industry-standard routers (Remix/React Router)
39
- * @returns A configured and initialized router instance
48
+ * @deprecated Use `@equinor/fusion-framework-react-router` instead.
49
+ * @param routes - Route configuration objects compatible with Remix/React Router
50
+ * @returns A configured and initialized {@link Router} instance with basename applied
40
51
  */
41
52
  createRouter(routes: AgnosticRouteObject[]): Router;
42
53
  /**
43
- * Creates a localized href string for navigation.
54
+ * Creates a localized href string including the basename prefix.
44
55
  *
45
- * @param to - Optional path or location (defaults to current path)
56
+ * @param to - Path or location to resolve (defaults to current path)
57
+ * @returns Fully-qualified href string with basename included
46
58
  */
47
59
  createHref(to?: To): string;
48
60
  /**
49
- * Creates a full URL object for navigation.
61
+ * Creates a full {@link URL} object including the basename prefix.
50
62
  *
51
- * @param to - Optional path or location (defaults to current path)
63
+ * @param to - Path or location to resolve (defaults to current path)
64
+ * @returns A {@link URL} instance representing the resolved navigation target
52
65
  */
53
66
  createURL(to?: To): URL;
54
67
  /**
@@ -12,7 +12,16 @@ export interface NavigateEventDetail {
12
12
  }
13
13
  /**
14
14
  * Event emitted before navigation occurs.
15
- * Can be canceled by calling `preventDefault()`.
15
+ * Can be canceled by calling `preventDefault()` to block the navigation.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * eventProvider.addEventListener('onNavigate', (event) => {
20
+ * if (hasUnsavedChanges) {
21
+ * event.preventDefault();
22
+ * }
23
+ * });
24
+ * ```
16
25
  */
17
26
  export declare class NavigateEvent extends FrameworkEvent<FrameworkEventInit<NavigateEventDetail, INavigationProvider>> {
18
27
  constructor(detail: NavigateEventDetail, source: INavigationProvider);
@@ -29,8 +38,16 @@ export interface NavigatedEventDetail {
29
38
  previous: NavigationUpdate;
30
39
  }
31
40
  /**
32
- * Event emitted after navigation occurs.
33
- * Contains the navigation action and location details.
41
+ * Event emitted after navigation completes.
42
+ * Contains the navigation action type and both current and previous locations.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * eventProvider.addEventListener('onNavigated', (event) => {
47
+ * const { action, current, previous } = event.detail;
48
+ * console.log(`${action}: ${previous.location.pathname} → ${current.location.pathname}`);
49
+ * });
50
+ * ```
34
51
  */
35
52
  export declare class NavigatedEvent extends FrameworkEvent<FrameworkEventInit<NavigatedEventDetail, INavigationProvider>> {
36
53
  constructor(detail: NavigatedEventDetail, source: INavigationProvider);
@@ -1,3 +1,26 @@
1
+ /**
2
+ * @module @equinor/fusion-framework-module-navigation
3
+ *
4
+ * Navigation module for Fusion Framework providing routing and navigation capabilities.
5
+ *
6
+ * Manages observable navigation state with automatic basename localization,
7
+ * so consumers work with clean paths while the underlying history receives
8
+ * full paths including the basename prefix.
9
+ *
10
+ * @remarks
11
+ * Supports browser, hash, and memory history types. Integrates with
12
+ * `@remix-run/router` for router creation and is compatible with
13
+ * industry-standard routers (Remix / React Router).
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { enableNavigation, createHistory } from '@equinor/fusion-framework-module-navigation';
18
+ *
19
+ * enableNavigation(configurator, '/apps/my-app');
20
+ * ```
21
+ *
22
+ * @packageDocumentation
23
+ */
1
24
  export type { INavigationConfigurator } from './NavigationConfigurator.interface';
2
25
  export { NavigationConfigurator } from './NavigationConfigurator';
3
26
  export { NavigationModule, module, moduleKey } from './module';
@@ -8,6 +31,6 @@ export { createHistory } from './lib/create-history';
8
31
  export { NavigateEvent, NavigatedEvent, type NavigateEventDetail, type NavigatedEventDetail, } from './events';
9
32
  export type { Path, To, Location, History, NavigationBlocker, NavigationListener, } from './lib/types';
10
33
  /**
11
- * @deprecated use History instead
34
+ * @deprecated Use {@link History} instead.
12
35
  */
13
36
  export type { History as INavigator } from './lib';
@@ -3,17 +3,23 @@ import type { Actions, HistoryState } from './state';
3
3
  import type { NavigateOptions, NavigationListener, Path, To, History, NavigationBlocker } from './types';
4
4
  /**
5
5
  * Abstract base class for history implementations.
6
- * Provides common state management and navigation logic that can be shared
7
- * across different history implementations (browser, memory, etc.).
6
+ *
7
+ * Provides common state management, navigation logic, and subscription
8
+ * lifecycle that is shared across different history backends (browser,
9
+ * hash, memory).
8
10
  */
9
11
  export declare abstract class BaseHistory implements History {
10
12
  #private;
11
13
  /**
12
- * Gets the current location.
14
+ * Gets the current location in the history stack.
15
+ *
16
+ * @returns The current {@link Location} including pathname, search, hash, state, and key
13
17
  */
14
18
  get location(): History['location'];
15
19
  /**
16
- * Gets the current action.
20
+ * Gets the current navigation action type.
21
+ *
22
+ * @returns The most recent {@link Action} (`Pop`, `Push`, or `Replace`)
17
23
  */
18
24
  get action(): History['action'];
19
25
  /**
@@ -26,20 +32,31 @@ export declare abstract class BaseHistory implements History {
26
32
  */
27
33
  get action$(): History['action$'];
28
34
  /**
29
- * Checks if there are any active navigation blockers.
35
+ * Checks whether there are any active navigation blockers.
36
+ *
37
+ * @returns `true` if one or more blockers are registered
30
38
  */
31
39
  get hasBlockers(): boolean;
32
40
  protected constructor(state: HistoryState);
33
41
  /**
34
42
  * Creates a valid href string for a given path.
43
+ *
44
+ * @param to - Target path or partial path object
45
+ * @returns Fully-qualified href string
35
46
  */
36
47
  createHref(to: To): string;
37
48
  /**
38
- * Creates a URL object for a given path.
49
+ * Creates a {@link URL} object for a given path.
50
+ *
51
+ * @param to - Target path or partial path object
52
+ * @returns Resolved {@link URL} instance
39
53
  */
40
54
  createURL(to: To): URL;
41
55
  /**
42
56
  * Encodes a location by properly URL-encoding the pathname.
57
+ *
58
+ * @param to - Target path or partial path object
59
+ * @returns A {@link Path} with URL-encoded components
43
60
  */
44
61
  encodeLocation(to: To): Path;
45
62
  /**
@@ -1,16 +1,15 @@
1
1
  import type { HistoryStack, Location, To } from './types';
2
2
  /**
3
- * Browser history stack implementation using native browser APIs.
3
+ * Browser history stack implementation using the native History API.
4
4
  *
5
- * Manages navigation state using the browser's History API (pushState/replaceState).
6
- * Stores location state in history.state and uses relative paths for navigation.
7
- * This is the base implementation for regular (non-hash) routing.
5
+ * Manages navigation state via `pushState` / `replaceState` and stores
6
+ * location state in `history.state`. This is the default stack for
7
+ * pathname-based (non-hash) routing.
8
8
  *
9
9
  * @example
10
10
  * ```ts
11
11
  * const stack = new BrowserHistoryStack(window);
12
- * stack.push({ pathname: '/users', key: 'abc123', state: { userId: 1 } });
13
- * // Updates URL to /users and adds entry to history
12
+ * stack.push({ pathname: '/users', search: '', hash: '', key: 'abc', state: null });
14
13
  * ```
15
14
  */
16
15
  export declare class BrowserHistoryStack implements HistoryStack {
@@ -12,11 +12,11 @@ export type MemoryHistoryOptions = {
12
12
  /**
13
13
  * Memory history implementation using in-memory storage.
14
14
  *
15
- * Useful for:
16
- * - Testing: Control navigation state in tests without browser APIs
17
- * - SSR: Server-side rendering where window is not available
18
- * - Widgets: Serving applications as widgets without affecting the main browser history
19
- * - Node.js environments: Environments without browser APIs
15
+ * Does not touch browser APIs, making it suitable for:
16
+ * - **Testing** deterministic navigation state without a DOM
17
+ * - **SSR** — server-side rendering where `window` is unavailable
18
+ * - **Widgets** embedded apps that must not alter the host page URL
19
+ * - **Node.js** any environment without browser history APIs
20
20
  */
21
21
  export declare class MemoryHistory extends BaseHistory {
22
22
  constructor(options?: MemoryHistoryOptions);
@@ -9,25 +9,19 @@ type HistoryCtorMap = {
9
9
  * Creates a history instance based on the specified type.
10
10
  *
11
11
  * Factory function for creating different history implementations:
12
- * - `'browser'`: Creates a {@link BrowserHistory} instance using regular routing (pathname-based)
13
- * - `'hash'`: Creates a {@link BrowserHistory} instance using hash routing (hash-based)
14
- * - `'memory'`: Creates a {@link MemoryHistory} instance for testing or SSR (in-memory)
12
+ * - `'browser'`: Creates a {@link BrowserHistory} using pathname-based routing
13
+ * - `'hash'`: Creates a {@link BrowserHistory} using hash-based routing (`#/path`)
14
+ * - `'memory'`: Creates a {@link MemoryHistory} for testing, SSR, or widget apps
15
15
  *
16
- * All returned instances are compatible with industry-standard routers (Remix/React Router).
17
- *
18
- * @param type - The type of history to create ('browser', 'hash', or 'memory')
19
- * @param args - Optional arguments for the history type
20
- * @returns A History instance compatible with industry-standard routers (Remix/React Router)
16
+ * @param type - The type of history to create (`'browser'`, `'hash'`, or `'memory'`)
17
+ * @param args - Optional arguments forwarded to the history constructor
18
+ * @returns A {@link History} instance of the requested type
19
+ * @throws {Error} If `type` is not one of `'browser'`, `'hash'`, or `'memory'`
21
20
  *
22
21
  * @example
23
22
  * ```ts
24
- * // Regular browser routing
25
23
  * const history = createHistory('browser');
26
- *
27
- * // Hash-based routing
28
24
  * const hashHistory = createHistory('hash');
29
- *
30
- * // In-memory history for testing
31
25
  * const memoryHistory = createHistory('memory', { initialLocation: { ... } });
32
26
  * ```
33
27
  */
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Internal history implementations, stacks, and types.
3
+ *
4
+ * @remarks
5
+ * This sub-module is re-exported as `@equinor/fusion-framework-module-navigation/lib`
6
+ * and provides the low-level building blocks for navigation state management.
7
+ *
8
+ * @packageDocumentation
9
+ */
1
10
  export { BaseHistory } from './BaseHistory';
2
11
  export { BrowserHistory } from './BrowserHistory';
3
12
  export { MemoryHistory } from './MemoryHistory';
@@ -74,19 +74,14 @@ export declare const validateCurrentLocation: HistoryFlowCreator;
74
74
  /**
75
75
  * Creates a combined history flow from multiple flow creators.
76
76
  *
77
- * Execution flow:
78
- * 1. Creates a preprocessing step that applies blocker checking (unless skipped)
79
- * 2. Initializes each flow creator with the stack to create individual flows
80
- * 3. Merges all flows so they process actions in parallel
81
- * 4. Returns a combined flow that:
82
- * - First applies preprocessing (blocker checking)
83
- * - Then processes actions through all merged flows
84
- * - Emits results from any flow that matches the action
77
+ * Merges all provided flows so they process actions in parallel.
78
+ * Optionally prepends a blocker-checking step that gates navigation
79
+ * actions through registered {@link NavigationBlocker | blockers}.
85
80
  *
86
81
  * @param flowCreators - Array of flow creators to combine
87
- * @param options - Optional configuration options
88
- * @param options.skipBlockCheck - If true, skip blocker checking
89
- * @returns A combined history flow creator
82
+ * @param options - Optional configuration
83
+ * @param options.skipBlockCheck - If `true`, skip blocker checking
84
+ * @returns A combined {@link HistoryFlowCreator} that merges all provided flows
90
85
  */
91
86
  export declare const createFlow: (flowCreators: HistoryFlowCreator[], options?: {
92
87
  skipBlockCheck?: boolean;
@@ -2,10 +2,14 @@ import type { LocationState, NavigationUpdate } from '../types';
2
2
  /**
3
3
  * Creates a reducer for history state management.
4
4
  *
5
- * @param initial - Initial navigation update or function that returns initial state
6
- * @param options - Optional configuration options
7
- * @param options.maxHistory - Maximum number of history entries to keep (default: 100)
8
- * @returns A reducer for history state
5
+ * Handles navigate, go, and pop success actions by updating the
6
+ * history array and current location. Enforces a maximum history
7
+ * length to prevent unbounded memory growth.
8
+ *
9
+ * @param initial - Initial navigation update or factory returning initial state
10
+ * @param options - Optional configuration
11
+ * @param options.maxHistory - Maximum number of history entries to keep (default: `100`)
12
+ * @returns A reducer with initial state for use with {@link createStore}
9
13
  */
10
14
  export declare const createHistoryReducer: (initial: NavigationUpdate | (() => LocationState), options?: {
11
15
  maxHistory?: number;
@@ -15,10 +15,16 @@ export declare const defaultFlows: HistoryFlowCreator[];
15
15
  /**
16
16
  * Creates a history store with the specified stack and reducer.
17
17
  *
18
- * @param stack - The history stack implementation
19
- * @param reducer - The reducer for history state
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
20
23
  * @param options - Optional configuration options
21
- * @returns A HistoryState instance
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
22
28
  */
23
29
  export declare const createStore: (stack: HistoryStack, reducer: ReducerWithInitialState<LocationState, Actions>, options?: {
24
30
  flows?: HistoryFlowCreator[];
@@ -38,11 +38,15 @@ export type Path = {
38
38
  };
39
39
  /**
40
40
  * Location object representing a navigation entry.
41
- * Extends Path with state and a unique key.
41
+ * Extends {@link Path} with arbitrary state data and a unique key.
42
+ *
43
+ * @template T - The type of the state payload stored in this location entry
42
44
  */
43
45
  export type Location<T = any> = Path & {
44
46
  state: T;
45
47
  key: string;
48
+ /** Masked path used by react-router 7.13+ for unstable view-transition masking. */
49
+ unstable_mask: Path | undefined;
46
50
  };
47
51
  /**
48
52
  * Internal state for history management.
@@ -57,7 +61,10 @@ export type LocationState = {
57
61
  */
58
62
  export type NavigationListener = (update: Readonly<NavigationUpdate>) => void;
59
63
  /**
60
- * Navigation update event containing action and location.
64
+ * Navigation update event containing the action, location, and stack delta.
65
+ *
66
+ * @template A - The type of navigation action (defaults to {@link Action})
67
+ * @template T - The type of the state payload in the location
61
68
  */
62
69
  export type NavigationUpdate<A extends string = Action, T = unknown> = {
63
70
  delta: number;
@@ -96,7 +103,16 @@ export interface NavigateOptions {
96
103
  }
97
104
  /**
98
105
  * History interface for managing navigation state.
99
- * Compatible with industry-standard routers (Remix/React Router) and provides observable state management.
106
+ *
107
+ * Compatible with Remix / React Router and provides observable
108
+ * state management via RxJS.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const history = createHistory('browser');
113
+ * history.push('/dashboard');
114
+ * history.state$.subscribe(update => console.log(update.location.pathname));
115
+ * ```
100
116
  */
101
117
  export interface History extends Disposable {
102
118
  /** Observable stream of navigation state updates. */
@@ -107,11 +123,20 @@ export interface History extends Disposable {
107
123
  readonly action: Action;
108
124
  /** Current location in the history stack. */
109
125
  readonly location: Location;
110
- /** Creates a valid href string for a given path. */
126
+ /** Creates a valid href string for a given path.
127
+ * @param to - Target path or partial path object
128
+ * @returns Fully-qualified href string
129
+ */
111
130
  createHref(to: To): string;
112
- /** Creates a URL object for a given path. */
131
+ /** Creates a {@link URL} object for a given path.
132
+ * @param to - Target path or partial path object
133
+ * @returns Resolved {@link URL} instance
134
+ */
113
135
  createURL(to: To): URL;
114
- /** Encodes a location by properly URL-encoding the pathname. */
136
+ /** Encodes a location by properly URL-encoding the pathname.
137
+ * @param to - Target path or partial path object
138
+ * @returns A {@link Path} with URL-encoded components
139
+ */
115
140
  encodeLocation(to: To): Path;
116
141
  /** Pushes a new navigation entry onto the history stack. */
117
142
  push(to: To, state?: unknown): void;
@@ -121,9 +146,15 @@ export interface History extends Disposable {
121
146
  navigate(to: To, options?: NavigateOptions): void;
122
147
  /** Navigates backward or forward in the history stack. */
123
148
  go(delta: number): void;
124
- /** Sets up a listener for navigation changes. */
149
+ /** Sets up a listener for navigation changes.
150
+ * @param listener - Callback invoked on POP actions (browser back/forward)
151
+ * @returns A function that unsubscribes the listener when called
152
+ */
125
153
  listen(listener: NavigationListener): () => void;
126
- /** Registers a blocker to intercept navigation attempts. */
154
+ /** Registers a blocker to intercept navigation attempts.
155
+ * @param blocker - Callback invoked before each navigation to allow or prevent it
156
+ * @returns A function that removes the blocker when called
157
+ */
127
158
  block(blocker: NavigationBlocker): VoidFunction;
128
159
  }
129
160
  /**
@@ -1 +1 @@
1
- export declare const version = "7.0.0-next.1";
1
+ export declare const version = "7.0.0";