@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.
@@ -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. The options object is stored in state.meta.options and is
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 from
229
- * guards or lifecycle hooks. This flag is used internally to track redirect chains
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 lifecycle
236
- * router.addActivateGuard('dashboard', (toState, fromState) => {
237
- * if (toState.meta?.options?.redirected) {
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
@@ -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. The options object is stored in state.meta.options and is
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 from
229
- * guards or lifecycle hooks. This flag is used internally to track redirect chains
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 lifecycle
236
- * router.addActivateGuard('dashboard', (toState, fromState) => {
237
- * if (toState.meta?.options?.redirected) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/types",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "commonjs",
5
5
  "description": "Shared TypeScript types for Real Router ecosystem",
6
6
  "types": "./dist/esm/index.d.mts",
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. The options object is stored in state.meta.options and is
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 from
210
- * guards or lifecycle hooks. This flag is used internally to track redirect chains
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 lifecycle
217
- * router.addActivateGuard('dashboard', (toState, fromState) => {
218
- * if (toState.meta?.options?.redirected) {
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