@equinor/fusion-framework-module-navigation 7.0.0-next.2 → 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.
- package/CHANGELOG.md +32 -24
- package/README.md +97 -614
- package/dist/esm/NavigationProvider.js +57 -23
- package/dist/esm/NavigationProvider.js.map +1 -1
- package/dist/esm/events.js +20 -3
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/BaseHistory.js +23 -6
- package/dist/esm/lib/BaseHistory.js.map +1 -1
- package/dist/esm/lib/BrowserHistoryStack.js +5 -6
- package/dist/esm/lib/BrowserHistoryStack.js.map +1 -1
- package/dist/esm/lib/MemoryHistory.js +13 -6
- package/dist/esm/lib/MemoryHistory.js.map +1 -1
- package/dist/esm/lib/MemoryStack.js +1 -0
- package/dist/esm/lib/MemoryStack.js.map +1 -1
- package/dist/esm/lib/create-history.js +7 -13
- package/dist/esm/lib/create-history.js.map +1 -1
- package/dist/esm/lib/index.js +9 -0
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/state/history.flows.js +7 -12
- package/dist/esm/lib/state/history.flows.js.map +1 -1
- package/dist/esm/lib/state/history.reducer.js +8 -4
- package/dist/esm/lib/state/history.reducer.js.map +1 -1
- package/dist/esm/lib/state/history.state.js +9 -3
- package/dist/esm/lib/state/history.state.js.map +1 -1
- package/dist/esm/lib/utils/resolve-browser-location.js +2 -2
- package/dist/esm/lib/utils/resolve-browser-location.js.map +1 -1
- package/dist/esm/module.js +4 -4
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/NavigationConfigurator.interface.d.ts +25 -5
- package/dist/types/NavigationProvider.d.ts +57 -23
- package/dist/types/NavigationProvider.interface.d.ts +20 -7
- package/dist/types/events.d.ts +20 -3
- package/dist/types/index.d.ts +24 -1
- package/dist/types/lib/BaseHistory.d.ts +23 -6
- package/dist/types/lib/BrowserHistoryStack.d.ts +5 -6
- package/dist/types/lib/MemoryHistory.d.ts +5 -5
- package/dist/types/lib/create-history.d.ts +7 -13
- package/dist/types/lib/index.d.ts +9 -0
- package/dist/types/lib/state/history.flows.d.ts +6 -11
- package/dist/types/lib/state/history.reducer.d.ts +8 -4
- package/dist/types/lib/state/history.state.d.ts +9 -3
- package/dist/types/lib/types.d.ts +39 -8
- package/dist/types/version.d.ts +1 -1
- package/package.json +11 -12
- package/src/NavigationConfigurator.interface.ts +28 -5
- package/src/NavigationProvider.interface.ts +20 -7
- package/src/NavigationProvider.ts +57 -23
- package/src/events.ts +20 -3
- package/src/index.ts +25 -1
- package/src/lib/BaseHistory.ts +23 -6
- package/src/lib/BrowserHistoryStack.ts +5 -6
- package/src/lib/MemoryHistory.ts +13 -6
- package/src/lib/MemoryStack.ts +1 -0
- package/src/lib/create-history.ts +7 -13
- package/src/lib/index.ts +10 -0
- package/src/lib/state/history.flows.ts +7 -12
- package/src/lib/state/history.reducer.ts +8 -4
- package/src/lib/state/history.state.ts +9 -3
- package/src/lib/types.ts +39 -8
- package/src/lib/utils/resolve-browser-location.ts +2 -2
- package/src/module.ts +4 -4
- package/src/version.ts +1 -1
package/src/lib/types.ts
CHANGED
|
@@ -42,12 +42,16 @@ export type Path = {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Location object representing a navigation entry.
|
|
45
|
-
* Extends Path with state and a unique key.
|
|
45
|
+
* Extends {@link Path} with arbitrary state data and a unique key.
|
|
46
|
+
*
|
|
47
|
+
* @template T - The type of the state payload stored in this location entry
|
|
46
48
|
*/
|
|
47
49
|
// biome-ignore lint/suspicious/noExplicitAny: necessary
|
|
48
50
|
export type Location<T = any> = Path & {
|
|
49
51
|
state: T;
|
|
50
52
|
key: string;
|
|
53
|
+
/** Masked path used by react-router 7.13+ for unstable view-transition masking. */
|
|
54
|
+
unstable_mask: Path | undefined;
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -65,7 +69,10 @@ export type LocationState = {
|
|
|
65
69
|
export type NavigationListener = (update: Readonly<NavigationUpdate>) => void;
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
|
-
* Navigation update event containing action and
|
|
72
|
+
* Navigation update event containing the action, location, and stack delta.
|
|
73
|
+
*
|
|
74
|
+
* @template A - The type of navigation action (defaults to {@link Action})
|
|
75
|
+
* @template T - The type of the state payload in the location
|
|
69
76
|
*/
|
|
70
77
|
export type NavigationUpdate<A extends string = Action, T = unknown> = {
|
|
71
78
|
delta: number;
|
|
@@ -108,7 +115,16 @@ export interface NavigateOptions {
|
|
|
108
115
|
|
|
109
116
|
/**
|
|
110
117
|
* History interface for managing navigation state.
|
|
111
|
-
*
|
|
118
|
+
*
|
|
119
|
+
* Compatible with Remix / React Router and provides observable
|
|
120
|
+
* state management via RxJS.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const history = createHistory('browser');
|
|
125
|
+
* history.push('/dashboard');
|
|
126
|
+
* history.state$.subscribe(update => console.log(update.location.pathname));
|
|
127
|
+
* ```
|
|
112
128
|
*/
|
|
113
129
|
export interface History extends Disposable {
|
|
114
130
|
/** Observable stream of navigation state updates. */
|
|
@@ -120,11 +136,20 @@ export interface History extends Disposable {
|
|
|
120
136
|
/** Current location in the history stack. */
|
|
121
137
|
readonly location: Location;
|
|
122
138
|
|
|
123
|
-
/** Creates a valid href string for a given path.
|
|
139
|
+
/** Creates a valid href string for a given path.
|
|
140
|
+
* @param to - Target path or partial path object
|
|
141
|
+
* @returns Fully-qualified href string
|
|
142
|
+
*/
|
|
124
143
|
createHref(to: To): string;
|
|
125
|
-
/** Creates a URL object for a given path.
|
|
144
|
+
/** Creates a {@link URL} object for a given path.
|
|
145
|
+
* @param to - Target path or partial path object
|
|
146
|
+
* @returns Resolved {@link URL} instance
|
|
147
|
+
*/
|
|
126
148
|
createURL(to: To): URL;
|
|
127
|
-
/** Encodes a location by properly URL-encoding the pathname.
|
|
149
|
+
/** Encodes a location by properly URL-encoding the pathname.
|
|
150
|
+
* @param to - Target path or partial path object
|
|
151
|
+
* @returns A {@link Path} with URL-encoded components
|
|
152
|
+
*/
|
|
128
153
|
encodeLocation(to: To): Path;
|
|
129
154
|
/** Pushes a new navigation entry onto the history stack. */
|
|
130
155
|
push(to: To, state?: unknown): void;
|
|
@@ -134,9 +159,15 @@ export interface History extends Disposable {
|
|
|
134
159
|
navigate(to: To, options?: NavigateOptions): void;
|
|
135
160
|
/** Navigates backward or forward in the history stack. */
|
|
136
161
|
go(delta: number): void;
|
|
137
|
-
/** Sets up a listener for navigation changes.
|
|
162
|
+
/** Sets up a listener for navigation changes.
|
|
163
|
+
* @param listener - Callback invoked on POP actions (browser back/forward)
|
|
164
|
+
* @returns A function that unsubscribes the listener when called
|
|
165
|
+
*/
|
|
138
166
|
listen(listener: NavigationListener): () => void;
|
|
139
|
-
/** Registers a blocker to intercept navigation attempts.
|
|
167
|
+
/** Registers a blocker to intercept navigation attempts.
|
|
168
|
+
* @param blocker - Callback invoked before each navigation to allow or prevent it
|
|
169
|
+
* @returns A function that removes the blocker when called
|
|
170
|
+
*/
|
|
140
171
|
block(blocker: NavigationBlocker): VoidFunction;
|
|
141
172
|
}
|
|
142
173
|
|
|
@@ -31,7 +31,7 @@ const resolveState = (target?: { state: unknown }): { state: unknown; key: strin
|
|
|
31
31
|
export const resolveWindowLocation = (window: Window, target?: { state: unknown }): Location => {
|
|
32
32
|
const { pathname, search, hash } = resolvePath(window.location);
|
|
33
33
|
const { state, key } = resolveState(target);
|
|
34
|
-
return { pathname, search, hash, state, key };
|
|
34
|
+
return { pathname, search, hash, state, key, unstable_mask: undefined };
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -56,5 +56,5 @@ export const resolveHashLocation = (window: Window, target?: { state: unknown })
|
|
|
56
56
|
const location = resolveWindowLocation(window, target);
|
|
57
57
|
const { pathname, search, hash } = resolvePath(location.hash?.replace('#', '') ?? '');
|
|
58
58
|
const { state, key } = resolveState(target);
|
|
59
|
-
return { pathname, search, hash, state, key };
|
|
59
|
+
return { pathname, search, hash, state, key, unstable_mask: undefined };
|
|
60
60
|
};
|
package/src/module.ts
CHANGED
|
@@ -46,16 +46,16 @@ export const module: NavigationModule = {
|
|
|
46
46
|
version: new SemanticVersion(version),
|
|
47
47
|
name: moduleKey,
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Creates a new {@link NavigationConfigurator} for the module.
|
|
50
50
|
*
|
|
51
|
-
* @returns A
|
|
51
|
+
* @returns A fresh {@link NavigationConfigurator} instance with default settings
|
|
52
52
|
*/
|
|
53
53
|
configure: () => new NavigationConfigurator(),
|
|
54
54
|
/**
|
|
55
55
|
* Initializes the navigation module with validated configuration.
|
|
56
56
|
*
|
|
57
|
-
* @param init - Module initialization arguments
|
|
58
|
-
* @returns A
|
|
57
|
+
* @param init - Module initialization arguments containing config and refs
|
|
58
|
+
* @returns A promise that resolves to a configured {@link NavigationProvider}
|
|
59
59
|
*/
|
|
60
60
|
initialize: async (init) => {
|
|
61
61
|
const config = await init.config.createConfigAsync(init);
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '7.0.0
|
|
2
|
+
export const version = '7.0.0';
|