@real-router/types 0.18.0 → 0.19.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/dist/cjs/index.d.ts +8 -11
- package/dist/esm/index.d.mts +8 -11
- package/package.json +1 -1
- package/src/base.ts +8 -11
package/dist/cjs/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ interface SimpleState<P extends Params = Params> {
|
|
|
47
47
|
type TransitionPhase = "deactivating" | "activating";
|
|
48
48
|
type TransitionReason = "success" | "blocked" | "cancelled" | "error";
|
|
49
49
|
interface TransitionMeta {
|
|
50
|
+
readonly reload?: boolean;
|
|
51
|
+
readonly redirected?: boolean;
|
|
50
52
|
phase: TransitionPhase;
|
|
51
53
|
from?: string;
|
|
52
54
|
reason: TransitionReason;
|
|
@@ -67,7 +69,6 @@ interface State<P extends Params = Params, MP extends Params = Params> {
|
|
|
67
69
|
interface StateMeta<P extends Params = Params> {
|
|
68
70
|
id: number;
|
|
69
71
|
params: P;
|
|
70
|
-
options: NavigationOptions;
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Input type for makeState meta parameter.
|
|
@@ -102,11 +103,9 @@ interface RouterError extends Error {
|
|
|
102
103
|
* guard enforcement, and state comparison logic.
|
|
103
104
|
*
|
|
104
105
|
* All options are optional and have sensible defaults. Options can be combined to achieve
|
|
105
|
-
* complex navigation behaviors.
|
|
106
|
-
* available to guards and event listeners.
|
|
106
|
+
* complex navigation behaviors. These options are available to guards and event listeners.
|
|
107
107
|
*
|
|
108
108
|
* @see {@link Router.navigate} for navigation method that accepts these options
|
|
109
|
-
* @see {@link State.meta} for where options are stored after navigation
|
|
110
109
|
*/
|
|
111
110
|
interface NavigationOptions {
|
|
112
111
|
/**
|
|
@@ -225,19 +224,17 @@ interface NavigationOptions {
|
|
|
225
224
|
* @internal
|
|
226
225
|
*
|
|
227
226
|
* @description
|
|
228
|
-
* Automatically set by the router when a navigation is triggered by a redirect
|
|
229
|
-
*
|
|
230
|
-
* and is stored in state.meta.options.redirected.
|
|
227
|
+
* Automatically set by the router when a navigation is triggered by a redirect.
|
|
228
|
+
* Available on `state.transition` after successful navigation (not during guard execution).
|
|
231
229
|
*
|
|
232
230
|
* @default false (auto-set by router during redirects)
|
|
233
231
|
*
|
|
234
232
|
* @example
|
|
235
|
-
* // Accessing redirect flag in
|
|
236
|
-
* router.
|
|
237
|
-
* if (
|
|
233
|
+
* // Accessing redirect flag in TRANSITION_SUCCESS listener
|
|
234
|
+
* router.addEventListener('TRANSITION_SUCCESS', (state) => {
|
|
235
|
+
* if (state.transition?.redirected) {
|
|
238
236
|
* console.log('This navigation is from a redirect');
|
|
239
237
|
* }
|
|
240
|
-
* return true;
|
|
241
238
|
* });
|
|
242
239
|
*
|
|
243
240
|
* @see {@link Router.navigate} for redirect handling implementation
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -47,6 +47,8 @@ interface SimpleState<P extends Params = Params> {
|
|
|
47
47
|
type TransitionPhase = "deactivating" | "activating";
|
|
48
48
|
type TransitionReason = "success" | "blocked" | "cancelled" | "error";
|
|
49
49
|
interface TransitionMeta {
|
|
50
|
+
readonly reload?: boolean;
|
|
51
|
+
readonly redirected?: boolean;
|
|
50
52
|
phase: TransitionPhase;
|
|
51
53
|
from?: string;
|
|
52
54
|
reason: TransitionReason;
|
|
@@ -67,7 +69,6 @@ interface State<P extends Params = Params, MP extends Params = Params> {
|
|
|
67
69
|
interface StateMeta<P extends Params = Params> {
|
|
68
70
|
id: number;
|
|
69
71
|
params: P;
|
|
70
|
-
options: NavigationOptions;
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Input type for makeState meta parameter.
|
|
@@ -102,11 +103,9 @@ interface RouterError extends Error {
|
|
|
102
103
|
* guard enforcement, and state comparison logic.
|
|
103
104
|
*
|
|
104
105
|
* All options are optional and have sensible defaults. Options can be combined to achieve
|
|
105
|
-
* complex navigation behaviors.
|
|
106
|
-
* available to guards and event listeners.
|
|
106
|
+
* complex navigation behaviors. These options are available to guards and event listeners.
|
|
107
107
|
*
|
|
108
108
|
* @see {@link Router.navigate} for navigation method that accepts these options
|
|
109
|
-
* @see {@link State.meta} for where options are stored after navigation
|
|
110
109
|
*/
|
|
111
110
|
interface NavigationOptions {
|
|
112
111
|
/**
|
|
@@ -225,19 +224,17 @@ interface NavigationOptions {
|
|
|
225
224
|
* @internal
|
|
226
225
|
*
|
|
227
226
|
* @description
|
|
228
|
-
* Automatically set by the router when a navigation is triggered by a redirect
|
|
229
|
-
*
|
|
230
|
-
* and is stored in state.meta.options.redirected.
|
|
227
|
+
* Automatically set by the router when a navigation is triggered by a redirect.
|
|
228
|
+
* Available on `state.transition` after successful navigation (not during guard execution).
|
|
231
229
|
*
|
|
232
230
|
* @default false (auto-set by router during redirects)
|
|
233
231
|
*
|
|
234
232
|
* @example
|
|
235
|
-
* // Accessing redirect flag in
|
|
236
|
-
* router.
|
|
237
|
-
* if (
|
|
233
|
+
* // Accessing redirect flag in TRANSITION_SUCCESS listener
|
|
234
|
+
* router.addEventListener('TRANSITION_SUCCESS', (state) => {
|
|
235
|
+
* if (state.transition?.redirected) {
|
|
238
236
|
* console.log('This navigation is from a redirect');
|
|
239
237
|
* }
|
|
240
|
-
* return true;
|
|
241
238
|
* });
|
|
242
239
|
*
|
|
243
240
|
* @see {@link Router.navigate} for redirect handling implementation
|
package/package.json
CHANGED
package/src/base.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type TransitionPhase = "deactivating" | "activating";
|
|
|
16
16
|
export type TransitionReason = "success" | "blocked" | "cancelled" | "error";
|
|
17
17
|
|
|
18
18
|
export interface TransitionMeta {
|
|
19
|
+
readonly reload?: boolean;
|
|
20
|
+
readonly redirected?: boolean;
|
|
19
21
|
phase: TransitionPhase;
|
|
20
22
|
from?: string;
|
|
21
23
|
reason: TransitionReason;
|
|
@@ -38,7 +40,6 @@ export interface State<P extends Params = Params, MP extends Params = Params> {
|
|
|
38
40
|
export interface StateMeta<P extends Params = Params> {
|
|
39
41
|
id: number;
|
|
40
42
|
params: P;
|
|
41
|
-
options: NavigationOptions;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -79,11 +80,9 @@ export interface RouterError extends Error {
|
|
|
79
80
|
* guard enforcement, and state comparison logic.
|
|
80
81
|
*
|
|
81
82
|
* All options are optional and have sensible defaults. Options can be combined to achieve
|
|
82
|
-
* complex navigation behaviors.
|
|
83
|
-
* available to guards and event listeners.
|
|
83
|
+
* complex navigation behaviors. These options are available to guards and event listeners.
|
|
84
84
|
*
|
|
85
85
|
* @see {@link Router.navigate} for navigation method that accepts these options
|
|
86
|
-
* @see {@link State.meta} for where options are stored after navigation
|
|
87
86
|
*/
|
|
88
87
|
export interface NavigationOptions {
|
|
89
88
|
/**
|
|
@@ -206,19 +205,17 @@ export interface NavigationOptions {
|
|
|
206
205
|
* @internal
|
|
207
206
|
*
|
|
208
207
|
* @description
|
|
209
|
-
* Automatically set by the router when a navigation is triggered by a redirect
|
|
210
|
-
*
|
|
211
|
-
* and is stored in state.meta.options.redirected.
|
|
208
|
+
* Automatically set by the router when a navigation is triggered by a redirect.
|
|
209
|
+
* Available on `state.transition` after successful navigation (not during guard execution).
|
|
212
210
|
*
|
|
213
211
|
* @default false (auto-set by router during redirects)
|
|
214
212
|
*
|
|
215
213
|
* @example
|
|
216
|
-
* // Accessing redirect flag in
|
|
217
|
-
* router.
|
|
218
|
-
* if (
|
|
214
|
+
* // Accessing redirect flag in TRANSITION_SUCCESS listener
|
|
215
|
+
* router.addEventListener('TRANSITION_SUCCESS', (state) => {
|
|
216
|
+
* if (state.transition?.redirected) {
|
|
219
217
|
* console.log('This navigation is from a redirect');
|
|
220
218
|
* }
|
|
221
|
-
* return true;
|
|
222
219
|
* });
|
|
223
220
|
*
|
|
224
221
|
* @see {@link Router.navigate} for redirect handling implementation
|