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

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 (159) hide show
  1. package/CHANGELOG.md +83 -5
  2. package/README.md +694 -0
  3. package/dist/esm/NavigationConfigurator.interface.js +2 -0
  4. package/dist/esm/NavigationConfigurator.interface.js.map +1 -0
  5. package/dist/esm/NavigationConfigurator.js +144 -0
  6. package/dist/esm/NavigationConfigurator.js.map +1 -0
  7. package/dist/esm/NavigationProvider.interface.js +2 -0
  8. package/dist/esm/NavigationProvider.interface.js.map +1 -0
  9. package/dist/esm/NavigationProvider.js +256 -0
  10. package/dist/esm/NavigationProvider.js.map +1 -0
  11. package/dist/esm/enable-navigation.js +52 -0
  12. package/dist/esm/enable-navigation.js.map +1 -0
  13. package/dist/esm/events.js +23 -0
  14. package/dist/esm/events.js.map +1 -0
  15. package/dist/esm/index.js +6 -5
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/lib/BaseHistory.js +189 -0
  18. package/dist/esm/lib/BaseHistory.js.map +1 -0
  19. package/dist/esm/lib/BrowserHistory.js +91 -0
  20. package/dist/esm/lib/BrowserHistory.js.map +1 -0
  21. package/dist/esm/lib/BrowserHistoryHashStack.js +53 -0
  22. package/dist/esm/lib/BrowserHistoryHashStack.js.map +1 -0
  23. package/dist/esm/lib/BrowserHistoryStack.js +77 -0
  24. package/dist/esm/lib/BrowserHistoryStack.js.map +1 -0
  25. package/dist/esm/lib/MemoryHistory.js +47 -0
  26. package/dist/esm/lib/MemoryHistory.js.map +1 -0
  27. package/dist/esm/lib/MemoryStack.js +98 -0
  28. package/dist/esm/lib/MemoryStack.js.map +1 -0
  29. package/dist/esm/lib/create-history.js +48 -0
  30. package/dist/esm/lib/create-history.js.map +1 -0
  31. package/dist/esm/lib/index.js +8 -1
  32. package/dist/esm/lib/index.js.map +1 -1
  33. package/dist/esm/lib/state/history.actions.js +71 -0
  34. package/dist/esm/lib/state/history.actions.js.map +1 -0
  35. package/dist/esm/lib/state/history.flows.js +212 -0
  36. package/dist/esm/lib/state/history.flows.js.map +1 -0
  37. package/dist/esm/lib/state/history.reducer.js +59 -0
  38. package/dist/esm/lib/state/history.reducer.js.map +1 -0
  39. package/dist/esm/lib/state/history.state.js +37 -0
  40. package/dist/esm/lib/state/history.state.js.map +1 -0
  41. package/dist/esm/lib/state/index.js +4 -0
  42. package/dist/esm/lib/state/index.js.map +1 -0
  43. package/dist/esm/lib/types.js +25 -0
  44. package/dist/esm/lib/types.js.map +1 -0
  45. package/dist/esm/lib/utils/encode-trailing-whitespace.js +19 -0
  46. package/dist/esm/lib/utils/encode-trailing-whitespace.js.map +1 -0
  47. package/dist/esm/lib/utils/has-protocol.js +22 -0
  48. package/dist/esm/lib/utils/has-protocol.js.map +1 -0
  49. package/dist/esm/lib/utils/index.js +6 -0
  50. package/dist/esm/lib/utils/index.js.map +1 -0
  51. package/dist/esm/lib/utils/path-to-string.js +23 -0
  52. package/dist/esm/lib/utils/path-to-string.js.map +1 -0
  53. package/dist/esm/lib/utils/path-to-url.js +47 -0
  54. package/dist/esm/lib/utils/path-to-url.js.map +1 -0
  55. package/dist/esm/lib/utils/resolve-browser-location.js +53 -0
  56. package/dist/esm/lib/utils/resolve-browser-location.js.map +1 -0
  57. package/dist/esm/lib/utils/resolve-path.js +21 -0
  58. package/dist/esm/lib/utils/resolve-path.js.map +1 -0
  59. package/dist/esm/module.js +34 -25
  60. package/dist/esm/module.js.map +1 -1
  61. package/dist/esm/version.js +1 -1
  62. package/dist/esm/version.js.map +1 -1
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/dist/types/NavigationConfigurator.d.ts +60 -0
  65. package/dist/types/NavigationConfigurator.interface.d.ts +17 -0
  66. package/dist/types/NavigationProvider.d.ts +112 -0
  67. package/dist/types/NavigationProvider.interface.d.ts +75 -0
  68. package/dist/types/enable-navigation.d.ts +40 -0
  69. package/dist/types/events.d.ts +48 -0
  70. package/dist/types/index.d.ts +13 -6
  71. package/dist/types/lib/BaseHistory.d.ts +122 -0
  72. package/dist/types/lib/BrowserHistory.d.ts +53 -0
  73. package/dist/types/lib/BrowserHistoryHashStack.d.ts +41 -0
  74. package/dist/types/lib/BrowserHistoryStack.d.ts +51 -0
  75. package/dist/types/lib/MemoryHistory.d.ts +27 -0
  76. package/dist/types/lib/MemoryStack.d.ts +57 -0
  77. package/dist/types/lib/create-history.d.ts +35 -0
  78. package/dist/types/lib/index.d.ts +7 -1
  79. package/dist/types/lib/state/history.actions.d.ts +61 -0
  80. package/dist/types/lib/state/history.flows.d.ts +102 -0
  81. package/dist/types/lib/state/history.reducer.d.ts +85 -0
  82. package/dist/types/lib/state/history.state.d.ts +27 -0
  83. package/dist/types/lib/state/index.d.ts +3 -0
  84. package/dist/types/lib/types.d.ts +145 -0
  85. package/dist/types/lib/utils/encode-trailing-whitespace.d.ts +16 -0
  86. package/dist/types/lib/utils/has-protocol.d.ts +19 -0
  87. package/dist/types/lib/utils/index.d.ts +5 -0
  88. package/dist/types/lib/utils/path-to-string.d.ts +17 -0
  89. package/dist/types/lib/utils/path-to-url.d.ts +32 -0
  90. package/dist/types/lib/utils/resolve-browser-location.d.ts +42 -0
  91. package/dist/types/lib/utils/resolve-path.d.ts +17 -0
  92. package/dist/types/module.d.ts +33 -5
  93. package/dist/types/version.d.ts +1 -1
  94. package/package.json +25 -7
  95. package/src/NavigationConfigurator.interface.ts +18 -0
  96. package/src/NavigationConfigurator.ts +184 -0
  97. package/src/NavigationProvider.interface.ts +86 -0
  98. package/src/NavigationProvider.ts +313 -0
  99. package/src/__tests__/BrowserHistory.test.ts +151 -0
  100. package/src/__tests__/HashHistory.test.ts +121 -0
  101. package/src/__tests__/MemoryHistory.test.ts +185 -0
  102. package/src/__tests__/NavigationProvider.test.ts +60 -0
  103. package/src/__tests__/setup.ts +8 -0
  104. package/src/enable-navigation.ts +59 -0
  105. package/src/events.ts +65 -0
  106. package/src/index.ts +27 -6
  107. package/src/lib/BaseHistory.ts +229 -0
  108. package/src/lib/BrowserHistory.ts +123 -0
  109. package/src/lib/BrowserHistoryHashStack.ts +56 -0
  110. package/src/lib/BrowserHistoryStack.ts +82 -0
  111. package/src/lib/MemoryHistory.ts +66 -0
  112. package/src/lib/MemoryStack.ts +106 -0
  113. package/src/lib/create-history.ts +63 -0
  114. package/src/lib/index.ts +22 -1
  115. package/src/lib/state/history.actions.ts +108 -0
  116. package/src/lib/state/history.flows.ts +279 -0
  117. package/src/lib/state/history.reducer.ts +70 -0
  118. package/src/lib/state/history.state.ts +62 -0
  119. package/src/lib/state/index.ts +3 -0
  120. package/src/lib/types.ts +159 -0
  121. package/src/lib/utils/encode-trailing-whitespace.ts +18 -0
  122. package/src/lib/utils/has-protocol.ts +21 -0
  123. package/src/lib/utils/index.ts +5 -0
  124. package/src/lib/utils/path-to-string.ts +24 -0
  125. package/src/lib/utils/path-to-url.ts +52 -0
  126. package/src/lib/utils/resolve-browser-location.ts +60 -0
  127. package/src/lib/utils/resolve-path.ts +22 -0
  128. package/src/module.ts +53 -37
  129. package/src/version.ts +1 -1
  130. package/tsconfig.json +10 -1
  131. package/vitest.config.ts +14 -0
  132. package/dist/esm/configurator.js +0 -5
  133. package/dist/esm/configurator.js.map +0 -1
  134. package/dist/esm/createHistory.js +0 -18
  135. package/dist/esm/createHistory.js.map +0 -1
  136. package/dist/esm/lib/provider/INavigationProvider.js +0 -2
  137. package/dist/esm/lib/provider/INavigationProvider.js.map +0 -1
  138. package/dist/esm/lib/provider/NavigationProvider.js +0 -82
  139. package/dist/esm/lib/provider/NavigationProvider.js.map +0 -1
  140. package/dist/esm/lib/provider/index.js +0 -2
  141. package/dist/esm/lib/provider/index.js.map +0 -1
  142. package/dist/esm/navigator.js +0 -158
  143. package/dist/esm/navigator.js.map +0 -1
  144. package/dist/esm/types.js +0 -2
  145. package/dist/esm/types.js.map +0 -1
  146. package/dist/types/configurator.d.ts +0 -9
  147. package/dist/types/createHistory.d.ts +0 -4
  148. package/dist/types/lib/provider/INavigationProvider.d.ts +0 -38
  149. package/dist/types/lib/provider/NavigationProvider.d.ts +0 -22
  150. package/dist/types/lib/provider/index.d.ts +0 -2
  151. package/dist/types/navigator.d.ts +0 -105
  152. package/dist/types/types.d.ts +0 -3
  153. package/src/configurator.ts +0 -11
  154. package/src/createHistory.ts +0 -21
  155. package/src/lib/provider/INavigationProvider.ts +0 -46
  156. package/src/lib/provider/NavigationProvider.ts +0 -117
  157. package/src/lib/provider/index.ts +0 -2
  158. package/src/navigator.ts +0 -204
  159. package/src/types.ts +0 -4
@@ -0,0 +1,17 @@
1
+ import type { Path, To } from '../types';
2
+ /**
3
+ * Resolves a 'to' value into a Path object.
4
+ *
5
+ * @param to - The target path (string, Path object, or Location object)
6
+ * @returns A Path object with the pathname, search, and hash components
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * resolvePath('/users?id=1#section')
11
+ * // { pathname: '/users', search: '?id=1', hash: '#section' }
12
+ *
13
+ * resolvePath({ pathname: '/users', search: 'id=1', hash: 'section' })
14
+ * // { pathname: '/users', search: '?id=1', hash: '#section' }
15
+ * ```
16
+ */
17
+ export declare const resolvePath: (to: To) => Path;
@@ -1,10 +1,38 @@
1
- import { type IModuleConfigurator, type IModulesConfigurator, type Module } from '@equinor/fusion-framework-module';
2
- import { type INavigationConfigurator } from './configurator';
3
- import { type INavigationProvider } from './lib';
1
+ import { type Module } from '@equinor/fusion-framework-module';
2
+ import { NavigationConfigurator } from './NavigationConfigurator';
3
+ import type { INavigationProvider } from './NavigationProvider.interface';
4
+ /**
5
+ * Module key identifier for the navigation module.
6
+ */
4
7
  export declare const moduleKey = "navigation";
5
- export type NavigationModule = Module<typeof moduleKey, INavigationProvider, INavigationConfigurator>;
8
+ /**
9
+ * Type definition for the navigation module.
10
+ *
11
+ * This is the main type definition for the navigation module. It represents the complete
12
+ * module structure with its key identifier, provider interface, and configurator class.
13
+ *
14
+ * The navigation module provides routing and navigation capabilities compatible with
15
+ * industry-standard routers (Remix/React Router), with support for browser history,
16
+ * hash routing, and memory history. It integrates with the Fusion Framework module
17
+ * system and provides a {@link INavigationProvider} instance that can be used to
18
+ * access navigation functionality.
19
+ *
20
+ * @see {@link INavigationProvider} - The provider interface for accessing navigation
21
+ * @see {@link NavigationConfigurator} - The configurator class for setting up navigation
22
+ * @see {@link enableNavigation} - Helper function to enable the navigation module
23
+ * @see {@link module} - The module implementation instance
24
+ */
25
+ export type NavigationModule = Module<typeof moduleKey, INavigationProvider, NavigationConfigurator>;
26
+ /**
27
+ * Navigation module implementation.
28
+ * Provides routing and navigation capabilities compatible with industry-standard routers (Remix/React Router).
29
+ *
30
+ * @remarks
31
+ * - Uses BaseConfigBuilder pattern with Zod validation
32
+ * - Basename must match the URL path prefix where your app is served
33
+ * - The router requires URL pathname to start with the basename
34
+ */
6
35
  export declare const module: NavigationModule;
7
- export declare const enableNavigation: <TRef = unknown>(configurator: IModulesConfigurator<any, any>, basenameOrOptions?: string | Omit<IModuleConfigurator<NavigationModule, TRef>, "module">) => void;
8
36
  export default module;
9
37
  declare module '@equinor/fusion-framework-module' {
10
38
  interface Modules {
@@ -1 +1 @@
1
- export declare const version = "6.0.1";
1
+ export declare const version = "7.0.0-next.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-navigation",
3
- "version": "6.0.1",
4
- "description": "",
3
+ "version": "7.0.0-next.2",
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",
7
7
  "types": "dist/types/index.d.ts",
@@ -9,6 +9,14 @@
9
9
  ".": {
10
10
  "import": "./dist/esm/index.js",
11
11
  "types": "./dist/types/index.d.ts"
12
+ },
13
+ "./lib": {
14
+ "import": "./dist/esm/lib/index.js",
15
+ "types": "./dist/types/lib/index.d.ts"
16
+ },
17
+ "./utils": {
18
+ "import": "./dist/esm/utils/index.js",
19
+ "types": "./dist/types/utils/index.d.ts"
12
20
  }
13
21
  },
14
22
  "keywords": [],
@@ -23,19 +31,29 @@
23
31
  "directory": "packages/modules/navigation"
24
32
  },
25
33
  "dependencies": {
26
- "@remix-run/router": "^1.8.0"
34
+ "@remix-run/router": "^1.23.0",
35
+ "uuid": "^13.0.0",
36
+ "zod": "^4.1.11"
27
37
  },
28
38
  "devDependencies": {
39
+ "@types/uuid": "^11.0.0",
40
+ "jsdom": "^27.1.0",
29
41
  "rxjs": "^7.8.1",
30
42
  "typescript": "^5.8.2",
31
- "@equinor/fusion-framework-module": "^5.0.6"
43
+ "vitest": "^3.2.4",
44
+ "@equinor/fusion-framework-module": "^5.0.7-next.0",
45
+ "@equinor/fusion-framework-module-event": "^5.0.2-next.0",
46
+ "@equinor/fusion-framework-module-telemetry": "^4.6.5-next.0",
47
+ "@equinor/fusion-observable": "^8.5.9-next.0"
32
48
  },
33
49
  "peerDependencies": {
34
- "@remix-run/router": "^1.8.0",
50
+ "@remix-run/router": "^1.23.0",
35
51
  "rxjs": "^7.0.0",
36
- "@equinor/fusion-framework-module": "^5.0.6"
52
+ "@equinor/fusion-framework-module": "^5.0.7-next.0",
53
+ "@equinor/fusion-observable": "^8.5.9-next.0"
37
54
  },
38
55
  "scripts": {
39
- "build": "tsc -b"
56
+ "build": "tsc -b",
57
+ "test": "vitest"
40
58
  }
41
59
  }
@@ -0,0 +1,18 @@
1
+ import type { History } from './lib/types';
2
+ import type { ITelemetryProvider } from '@equinor/fusion-framework-module-telemetry';
3
+ import type { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
4
+
5
+ /**
6
+ * Configuration object for the navigation module.
7
+ * Provides options for customizing history, basename, telemetry, and event settings.
8
+ */
9
+ export interface INavigationConfigurator {
10
+ /** Optional base pathname for the application (e.g., "/app") */
11
+ basename?: string;
12
+ /** Optional custom history instance (browser, hash, or memory). If not provided, defaults to browser history. */
13
+ history?: History;
14
+ /** Optional telemetry provider for tracking navigation events */
15
+ telemetry?: ITelemetryProvider;
16
+ /** Optional event provider for dispatching navigation events */
17
+ eventProvider?: IEventModuleProvider;
18
+ }
@@ -0,0 +1,184 @@
1
+ import { z } from 'zod';
2
+ import { of, type ObservableInput } from 'rxjs';
3
+ import {
4
+ BaseConfigBuilder,
5
+ type ModulesInstance,
6
+ type ConfigBuilderCallback,
7
+ type ConfigBuilderCallbackArgs,
8
+ } from '@equinor/fusion-framework-module';
9
+ import type { ITelemetryProvider } from '@equinor/fusion-framework-module-telemetry';
10
+ import type { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
11
+ import type { INavigationConfigurator } from './NavigationConfigurator.interface';
12
+
13
+ import type { History } from './lib/types';
14
+ import { createHistory } from './lib/create-history';
15
+ import type { NavigationModule } from './module';
16
+
17
+ /**
18
+ * Zod schema for navigation module configuration validation.
19
+ *
20
+ * @internal
21
+ */
22
+ const navigationConfigSchema = z
23
+ .object({
24
+ basename: z
25
+ .string()
26
+ .optional()
27
+ .describe(
28
+ 'Base pathname for the application (e.g., "/app"). Must match the URL path prefix where your app is served. The router requires the pathname to start with this basename.',
29
+ ),
30
+ history: z
31
+ .custom<History>()
32
+ .describe(
33
+ 'Custom history instance implementing the History interface. Defaults to browser history if not provided. Use createHistory("browser"|"hash"|"memory") to create instances.',
34
+ ),
35
+ telemetry: z
36
+ .custom<ITelemetryProvider>()
37
+ .optional()
38
+ .describe(
39
+ 'Telemetry provider for tracking navigation events. Used to log navigation actions, location changes, and errors for monitoring and debugging.',
40
+ ),
41
+ eventProvider: z
42
+ .custom<IEventModuleProvider>()
43
+ .optional()
44
+ .describe(
45
+ 'Event provider for dispatching navigation events (NavigateEvent, NavigatedEvent). Allows other modules to listen for navigation changes and block navigation attempts.',
46
+ ),
47
+ })
48
+ .describe(
49
+ 'Validates navigation module configuration settings for routing and navigation capabilities.',
50
+ );
51
+
52
+ /**
53
+ * Parses and validates a navigation configuration object.
54
+ *
55
+ * @param config - The configuration object to parse
56
+ * @returns Validated navigation configuration
57
+ * @throws {z.ZodError} If the configuration is invalid
58
+ */
59
+ const parseNavigationConfig = (config: unknown): INavigationConfigurator => {
60
+ return navigationConfigSchema.parse(config);
61
+ };
62
+
63
+ /**
64
+ * Configurator class for navigation module settings.
65
+ * Extends BaseConfigBuilder to provide fluent configuration API with Zod validation.
66
+ */
67
+ export class NavigationConfigurator extends BaseConfigBuilder<INavigationConfigurator> {
68
+ constructor() {
69
+ super();
70
+ this.setEventProvider(async (args) => {
71
+ if (args.hasModule('event')) {
72
+ return await args.requireInstance('event');
73
+ }
74
+ });
75
+ this.setHistory(async (args) => {
76
+ const history = (args.ref as ModulesInstance<[NavigationModule]>)?.navigation?.history;
77
+ if (history) {
78
+ return history;
79
+ }
80
+ if (typeof window !== 'undefined') {
81
+ return createHistory('browser');
82
+ }
83
+ return createHistory('memory');
84
+ });
85
+ }
86
+ /**
87
+ * @deprecated Use `setBasename()` method instead
88
+ */
89
+ public set basename(value: string | undefined) {
90
+ if (process.env.NODE_ENV === 'development') {
91
+ console.warn('NavigationConfigurator.basename', 'use setBasename() method instead');
92
+ }
93
+ this.setBasename(value);
94
+ }
95
+
96
+ /**
97
+ * @deprecated Use `setHistory()` method instead
98
+ */
99
+ public set history(value: History | undefined) {
100
+ if (process.env.NODE_ENV === 'development') {
101
+ console.warn('NavigationConfigurator.history', 'use setHistory() method instead');
102
+ }
103
+ this.setHistory(value);
104
+ }
105
+
106
+ /**
107
+ * Sets the basename for the application.
108
+ *
109
+ * @param basenameOrCallback - Basename string or configuration callback
110
+ * @returns The configurator instance for method chaining
111
+ */
112
+ public setBasename(basenameOrCallback?: string | ConfigBuilderCallback<string>): this {
113
+ const fn =
114
+ typeof basenameOrCallback === 'function'
115
+ ? basenameOrCallback
116
+ : async () => basenameOrCallback;
117
+ this._set('basename', fn);
118
+ return this;
119
+ }
120
+
121
+ /**
122
+ * Sets a custom history instance for the navigation module.
123
+ *
124
+ * @param historyOrCallback - History instance or configuration callback
125
+ * @returns The configurator instance for method chaining
126
+ */
127
+ public setHistory(historyOrCallback?: History | ConfigBuilderCallback<History>): this {
128
+ const fn =
129
+ typeof historyOrCallback === 'function' ? historyOrCallback : async () => historyOrCallback;
130
+ this._set('history', fn);
131
+ return this;
132
+ }
133
+
134
+ /**
135
+ * Sets telemetry configuration for navigation-specific events.
136
+ *
137
+ * @param telemetryOrCallback - Telemetry provider instance or configuration callback
138
+ * @returns The configurator instance for method chaining
139
+ */
140
+ public setTelemetry(
141
+ telemetryOrCallback: ITelemetryProvider | ConfigBuilderCallback<ITelemetryProvider>,
142
+ ): this {
143
+ const fn =
144
+ typeof telemetryOrCallback === 'function'
145
+ ? telemetryOrCallback
146
+ : async () => telemetryOrCallback;
147
+ this._set('telemetry', fn);
148
+ return this;
149
+ }
150
+
151
+ /**
152
+ * Sets event provider for dispatching navigation events.
153
+ *
154
+ * @param eventProviderOrCallback - Event provider instance or configuration callback
155
+ * @returns The configurator instance for method chaining
156
+ */
157
+ public setEventProvider(
158
+ eventProviderOrCallback: IEventModuleProvider | ConfigBuilderCallback<IEventModuleProvider>,
159
+ ): this {
160
+ const fn =
161
+ typeof eventProviderOrCallback === 'function'
162
+ ? eventProviderOrCallback
163
+ : async () => eventProviderOrCallback;
164
+ this._set('eventProvider', fn);
165
+ return this;
166
+ }
167
+
168
+ /**
169
+ * Processes and validates the configuration using Zod schema.
170
+ *
171
+ * @param config - Raw configuration object from builder
172
+ * @param _init - Configuration builder callback arguments (unused)
173
+ * @returns Observable that emits validated and processed configuration object
174
+ * @throws {z.ZodError} If the configuration is invalid
175
+ *
176
+ * @protected
177
+ */
178
+ protected _processConfig(
179
+ config: Partial<INavigationConfigurator>,
180
+ _init: ConfigBuilderCallbackArgs,
181
+ ): ObservableInput<INavigationConfigurator> {
182
+ return of(parseNavigationConfig(config));
183
+ }
184
+ }
@@ -0,0 +1,86 @@
1
+ // TODO: Remove @remix-run/router dependency once all apps have migrated to @equinor/fusion-framework-react-router
2
+ import type { AgnosticRouteObject, Router } from '@remix-run/router';
3
+
4
+ import type { History, NavigateOptions } from './lib/types';
5
+ import type { Action, Path, To } from './lib/types';
6
+
7
+ import type { Observable } from 'rxjs';
8
+ import type { IModuleProvider } from '@equinor/fusion-framework-module';
9
+
10
+ /**
11
+ * Navigation provider interface.
12
+ * Provides routing and navigation capabilities with basename localization.
13
+ */
14
+ export interface INavigationProvider extends IModuleProvider {
15
+ /**
16
+ * Observable stream of navigation state updates.
17
+ * Emits localized paths (with basename removed) for consumers.
18
+ */
19
+ readonly state$: Observable<{ action: Action; location: Path }>;
20
+
21
+ /**
22
+ * Gets the basename.
23
+ */
24
+ readonly basename: string;
25
+
26
+ /**
27
+ * Gets the current localized path (basename removed).
28
+ */
29
+ readonly path: Path;
30
+
31
+ /**
32
+ * @deprecated Use `history` instead
33
+ */
34
+ readonly navigator: History;
35
+
36
+ /**
37
+ * Gets the history instance.
38
+ */
39
+ readonly history: History;
40
+
41
+ /**
42
+ * Creates a router instance from route configuration.
43
+ *
44
+ * @param routes - Route configuration objects compatible with industry-standard routers (Remix/React Router)
45
+ * @returns A configured and initialized router instance
46
+ */
47
+ createRouter(routes: AgnosticRouteObject[]): Router;
48
+
49
+ /**
50
+ * Creates a localized href string for navigation.
51
+ *
52
+ * @param to - Optional path or location (defaults to current path)
53
+ */
54
+ createHref(to?: To): string;
55
+
56
+ /**
57
+ * Creates a full URL object for navigation.
58
+ *
59
+ * @param to - Optional path or location (defaults to current path)
60
+ */
61
+ createURL(to?: To): URL;
62
+
63
+ /**
64
+ * Navigates to a location with explicit options.
65
+ *
66
+ * @param to - Optional path or location (defaults to current path)
67
+ * @param options - Optional navigation options
68
+ */
69
+ navigate(to?: To, options?: Partial<NavigateOptions>): void;
70
+
71
+ /**
72
+ * Pushes a new navigation entry onto the history stack.
73
+ *
74
+ * @param to - Path or location to navigate to (relative to basename)
75
+ * @param state - Optional state to associate with the navigation
76
+ */
77
+ push(to: To, state?: unknown): void;
78
+
79
+ /**
80
+ * Replaces the current history entry with a new one.
81
+ *
82
+ * @param to - Path or location to navigate to (relative to basename)
83
+ * @param state - Optional state to associate with the navigation
84
+ */
85
+ replace(to: To, state?: unknown): void;
86
+ }