@real-router/types 0.14.0 → 0.15.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.
@@ -44,7 +44,7 @@ interface SimpleState<P extends Params = Params> {
44
44
  name: string;
45
45
  params: P;
46
46
  }
47
- type TransitionPhase = "deactivating" | "activating" | "middleware";
47
+ type TransitionPhase = "deactivating" | "activating";
48
48
  type TransitionReason = "success" | "blocked" | "cancelled" | "error";
49
49
  interface TransitionMeta {
50
50
  phase: TransitionPhase;
@@ -103,7 +103,7 @@ interface RouterError extends Error {
103
103
  *
104
104
  * All options are optional and have sensible defaults. Options can be combined to achieve
105
105
  * complex navigation behaviors. The options object is stored in state.meta.options and is
106
- * available to middleware, guards, and event listeners.
106
+ * available to guards and event listeners.
107
107
  *
108
108
  * @see {@link Router.navigate} for navigation method that accepts these options
109
109
  * @see {@link State.meta} for where options are stored after navigation
@@ -137,11 +137,11 @@ interface NavigationOptions {
137
137
  *
138
138
  * Without `reload`:
139
139
  * - Navigation to current route throws SAME_STATES error
140
- * - No lifecycle hooks or middleware execute
140
+ * - No lifecycle hooks execute
141
141
  * - No events are fired
142
142
  *
143
143
  * With `reload`:
144
- * - Full transition executes (deactivate → activate → middleware)
144
+ * - Full transition executes (deactivate → activate)
145
145
  * - All lifecycle hooks run again
146
146
  * - TRANSITION_SUCCESS event fires with same state
147
147
  * - State object is recreated (new reference)
@@ -192,16 +192,16 @@ interface NavigationOptions {
192
192
  *
193
193
  * @description
194
194
  * When `true`, bypasses only the canDeactivate lifecycle hooks for segments being
195
- * deactivated. canActivate guards and middleware still execute normally. This allows
195
+ * deactivated. canActivate guards still execute normally. This allows
196
196
  * forcing navigation away from routes with confirmation dialogs or unsaved changes.
197
197
  *
198
198
  * Skipped vs executed:
199
199
  * ```
200
200
  * // Normal transition
201
- * deactivate(fromSegments) → activate(toSegments) → middleware → success
201
+ * deactivate(fromSegments) → activate(toSegments) → success
202
202
  *
203
203
  * // With forceDeactivate: true
204
- * [skip deactivate] → activate(toSegments) → middleware → success
204
+ * [skip deactivate] → activate(toSegments) → success
205
205
  * ```
206
206
  *
207
207
  * ⚠️ Data loss risk: Bypassing canDeactivate means unsaved changes will be lost
@@ -227,21 +227,12 @@ interface NavigationOptions {
227
227
  *
228
228
  * @description
229
229
  * Automatically set by the router when a navigation is triggered by a redirect from
230
- * middleware or lifecycle hooks. This flag is used internally to track redirect chains
230
+ * guards or lifecycle hooks. This flag is used internally to track redirect chains
231
231
  * and is stored in state.meta.options.redirected.
232
232
  *
233
233
  * @default false (auto-set by router during redirects)
234
234
  *
235
235
  * @example
236
- * // Middleware triggers automatic redirect
237
- * router.useMiddleware((toState, fromState, opts) => {
238
- * if (!isAuthenticated && toState.name !== 'login') {
239
- * // Router will automatically set redirected: true
240
- * return { name: 'login', params: { next: toState.path } };
241
- * }
242
- * });
243
- *
244
- * @example
245
236
  * // Accessing redirect flag in lifecycle
246
237
  * router.addActivateGuard('dashboard', (toState, fromState) => {
247
238
  * if (toState.meta?.options?.redirected) {
@@ -278,13 +269,6 @@ interface LimitsConfig {
278
269
  * @default 50
279
270
  */
280
271
  maxPlugins: number;
281
- /**
282
- * Maximum number of middleware functions in the navigation pipeline.
283
- * Controls middleware chain length to prevent stack overflow and performance issues.
284
- *
285
- * @default 50
286
- */
287
- maxMiddleware: number;
288
272
  /**
289
273
  * Maximum number of event listeners per event type.
290
274
  * Prevents memory leaks from excessive listener registration.
@@ -319,7 +303,7 @@ interface LimitsConfig {
319
303
  * Base router types without Router class dependency.
320
304
  *
321
305
  * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
322
- * MiddlewareFactory, PluginFactory) are defined in @real-router/core
306
+ * PluginFactory) are defined in @real-router/core
323
307
  * to avoid circular dependencies.
324
308
  */
325
309
 
@@ -450,7 +434,6 @@ interface Plugin {
450
434
  onTransitionSuccess?: (toState: State, fromState: State | undefined, opts: NavigationOptions) => void;
451
435
  teardown?: () => void;
452
436
  }
453
- type Middleware = ActivationFn;
454
437
  interface SubscribeState {
455
438
  route: State;
456
439
  previousRoute?: State | undefined;
@@ -535,7 +518,7 @@ interface Router {
535
518
  * Dispose the router and release all resources.
536
519
  *
537
520
  * Stops the router if active, calls plugin teardown, clears all event
538
- * listeners, middleware, routes, and dependencies. After disposal, all
521
+ * listeners, routes, and dependencies. After disposal, all
539
522
  * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
540
523
  * call multiple times.
541
524
  */
@@ -600,4 +583,4 @@ interface ErrorCodeToValueMap {
600
583
  ROUTER_DISPOSED: "DISPOSED";
601
584
  }
602
585
 
603
- export type { ActivationFn, Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, LimitsConfig, Listener, Middleware, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState, Router, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe };
586
+ export type { ActivationFn, Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, LimitsConfig, Listener, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState, Router, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe };
@@ -1 +1 @@
1
- {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/index.ts":{"bytes":1309,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
1
+ {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/index.ts":{"bytes":1276,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
@@ -44,7 +44,7 @@ interface SimpleState<P extends Params = Params> {
44
44
  name: string;
45
45
  params: P;
46
46
  }
47
- type TransitionPhase = "deactivating" | "activating" | "middleware";
47
+ type TransitionPhase = "deactivating" | "activating";
48
48
  type TransitionReason = "success" | "blocked" | "cancelled" | "error";
49
49
  interface TransitionMeta {
50
50
  phase: TransitionPhase;
@@ -103,7 +103,7 @@ interface RouterError extends Error {
103
103
  *
104
104
  * All options are optional and have sensible defaults. Options can be combined to achieve
105
105
  * complex navigation behaviors. The options object is stored in state.meta.options and is
106
- * available to middleware, guards, and event listeners.
106
+ * available to guards and event listeners.
107
107
  *
108
108
  * @see {@link Router.navigate} for navigation method that accepts these options
109
109
  * @see {@link State.meta} for where options are stored after navigation
@@ -137,11 +137,11 @@ interface NavigationOptions {
137
137
  *
138
138
  * Without `reload`:
139
139
  * - Navigation to current route throws SAME_STATES error
140
- * - No lifecycle hooks or middleware execute
140
+ * - No lifecycle hooks execute
141
141
  * - No events are fired
142
142
  *
143
143
  * With `reload`:
144
- * - Full transition executes (deactivate → activate → middleware)
144
+ * - Full transition executes (deactivate → activate)
145
145
  * - All lifecycle hooks run again
146
146
  * - TRANSITION_SUCCESS event fires with same state
147
147
  * - State object is recreated (new reference)
@@ -192,16 +192,16 @@ interface NavigationOptions {
192
192
  *
193
193
  * @description
194
194
  * When `true`, bypasses only the canDeactivate lifecycle hooks for segments being
195
- * deactivated. canActivate guards and middleware still execute normally. This allows
195
+ * deactivated. canActivate guards still execute normally. This allows
196
196
  * forcing navigation away from routes with confirmation dialogs or unsaved changes.
197
197
  *
198
198
  * Skipped vs executed:
199
199
  * ```
200
200
  * // Normal transition
201
- * deactivate(fromSegments) → activate(toSegments) → middleware → success
201
+ * deactivate(fromSegments) → activate(toSegments) → success
202
202
  *
203
203
  * // With forceDeactivate: true
204
- * [skip deactivate] → activate(toSegments) → middleware → success
204
+ * [skip deactivate] → activate(toSegments) → success
205
205
  * ```
206
206
  *
207
207
  * ⚠️ Data loss risk: Bypassing canDeactivate means unsaved changes will be lost
@@ -227,21 +227,12 @@ interface NavigationOptions {
227
227
  *
228
228
  * @description
229
229
  * Automatically set by the router when a navigation is triggered by a redirect from
230
- * middleware or lifecycle hooks. This flag is used internally to track redirect chains
230
+ * guards or lifecycle hooks. This flag is used internally to track redirect chains
231
231
  * and is stored in state.meta.options.redirected.
232
232
  *
233
233
  * @default false (auto-set by router during redirects)
234
234
  *
235
235
  * @example
236
- * // Middleware triggers automatic redirect
237
- * router.useMiddleware((toState, fromState, opts) => {
238
- * if (!isAuthenticated && toState.name !== 'login') {
239
- * // Router will automatically set redirected: true
240
- * return { name: 'login', params: { next: toState.path } };
241
- * }
242
- * });
243
- *
244
- * @example
245
236
  * // Accessing redirect flag in lifecycle
246
237
  * router.addActivateGuard('dashboard', (toState, fromState) => {
247
238
  * if (toState.meta?.options?.redirected) {
@@ -278,13 +269,6 @@ interface LimitsConfig {
278
269
  * @default 50
279
270
  */
280
271
  maxPlugins: number;
281
- /**
282
- * Maximum number of middleware functions in the navigation pipeline.
283
- * Controls middleware chain length to prevent stack overflow and performance issues.
284
- *
285
- * @default 50
286
- */
287
- maxMiddleware: number;
288
272
  /**
289
273
  * Maximum number of event listeners per event type.
290
274
  * Prevents memory leaks from excessive listener registration.
@@ -319,7 +303,7 @@ interface LimitsConfig {
319
303
  * Base router types without Router class dependency.
320
304
  *
321
305
  * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
322
- * MiddlewareFactory, PluginFactory) are defined in @real-router/core
306
+ * PluginFactory) are defined in @real-router/core
323
307
  * to avoid circular dependencies.
324
308
  */
325
309
 
@@ -450,7 +434,6 @@ interface Plugin {
450
434
  onTransitionSuccess?: (toState: State, fromState: State | undefined, opts: NavigationOptions) => void;
451
435
  teardown?: () => void;
452
436
  }
453
- type Middleware = ActivationFn;
454
437
  interface SubscribeState {
455
438
  route: State;
456
439
  previousRoute?: State | undefined;
@@ -535,7 +518,7 @@ interface Router {
535
518
  * Dispose the router and release all resources.
536
519
  *
537
520
  * Stops the router if active, calls plugin teardown, clears all event
538
- * listeners, middleware, routes, and dependencies. After disposal, all
521
+ * listeners, routes, and dependencies. After disposal, all
539
522
  * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
540
523
  * call multiple times.
541
524
  */
@@ -600,4 +583,4 @@ interface ErrorCodeToValueMap {
600
583
  ROUTER_DISPOSED: "DISPOSED";
601
584
  }
602
585
 
603
- export type { ActivationFn, Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, LimitsConfig, Listener, Middleware, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState, Router, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe };
586
+ export type { ActivationFn, Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, LimitsConfig, Listener, NavigationOptions, Navigator, Options, Params, Plugin, PluginMethod, QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState, Router, RouterError, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe };
@@ -1 +1 @@
1
- {"inputs":{"src/index.ts":{"bytes":1309,"imports":[],"format":"esm"}},"outputs":{"dist/esm/index.mjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
1
+ {"inputs":{"src/index.ts":{"bytes":1276,"imports":[],"format":"esm"}},"outputs":{"dist/esm/index.mjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":0}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/types",
3
- "version": "0.14.0",
3
+ "version": "0.15.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
@@ -11,7 +11,7 @@ export interface SimpleState<P extends Params = Params> {
11
11
  params: P;
12
12
  }
13
13
 
14
- export type TransitionPhase = "deactivating" | "activating" | "middleware";
14
+ export type TransitionPhase = "deactivating" | "activating";
15
15
 
16
16
  export type TransitionReason = "success" | "blocked" | "cancelled" | "error";
17
17
 
@@ -80,7 +80,7 @@ export interface RouterError extends Error {
80
80
  *
81
81
  * All options are optional and have sensible defaults. Options can be combined to achieve
82
82
  * complex navigation behaviors. The options object is stored in state.meta.options and is
83
- * available to middleware, guards, and event listeners.
83
+ * available to guards and event listeners.
84
84
  *
85
85
  * @see {@link Router.navigate} for navigation method that accepts these options
86
86
  * @see {@link State.meta} for where options are stored after navigation
@@ -121,11 +121,11 @@ export interface NavigationOptions {
121
121
  *
122
122
  * Without `reload`:
123
123
  * - Navigation to current route throws SAME_STATES error
124
- * - No lifecycle hooks or middleware execute
124
+ * - No lifecycle hooks execute
125
125
  * - No events are fired
126
126
  *
127
127
  * With `reload`:
128
- * - Full transition executes (deactivate → activate → middleware)
128
+ * - Full transition executes (deactivate → activate)
129
129
  * - All lifecycle hooks run again
130
130
  * - TRANSITION_SUCCESS event fires with same state
131
131
  * - State object is recreated (new reference)
@@ -178,16 +178,16 @@ export interface NavigationOptions {
178
178
  *
179
179
  * @description
180
180
  * When `true`, bypasses only the canDeactivate lifecycle hooks for segments being
181
- * deactivated. canActivate guards and middleware still execute normally. This allows
181
+ * deactivated. canActivate guards still execute normally. This allows
182
182
  * forcing navigation away from routes with confirmation dialogs or unsaved changes.
183
183
  *
184
184
  * Skipped vs executed:
185
185
  * ```
186
186
  * // Normal transition
187
- * deactivate(fromSegments) → activate(toSegments) → middleware → success
187
+ * deactivate(fromSegments) → activate(toSegments) → success
188
188
  *
189
189
  * // With forceDeactivate: true
190
- * [skip deactivate] → activate(toSegments) → middleware → success
190
+ * [skip deactivate] → activate(toSegments) → success
191
191
  * ```
192
192
  *
193
193
  * ⚠️ Data loss risk: Bypassing canDeactivate means unsaved changes will be lost
@@ -214,21 +214,12 @@ export interface NavigationOptions {
214
214
  *
215
215
  * @description
216
216
  * Automatically set by the router when a navigation is triggered by a redirect from
217
- * middleware or lifecycle hooks. This flag is used internally to track redirect chains
217
+ * guards or lifecycle hooks. This flag is used internally to track redirect chains
218
218
  * and is stored in state.meta.options.redirected.
219
219
  *
220
220
  * @default false (auto-set by router during redirects)
221
221
  *
222
222
  * @example
223
- * // Middleware triggers automatic redirect
224
- * router.useMiddleware((toState, fromState, opts) => {
225
- * if (!isAuthenticated && toState.name !== 'login') {
226
- * // Router will automatically set redirected: true
227
- * return { name: 'login', params: { next: toState.path } };
228
- * }
229
- * });
230
- *
231
- * @example
232
223
  * // Accessing redirect flag in lifecycle
233
224
  * router.addActivateGuard('dashboard', (toState, fromState) => {
234
225
  * if (toState.meta?.options?.redirected) {
package/src/index.ts CHANGED
@@ -24,7 +24,7 @@ export type {
24
24
  } from "./base";
25
25
 
26
26
  // Router types (base types without Router dependency)
27
- // Note: Route, RouteConfigUpdate, ActivationFnFactory, MiddlewareFactory,
27
+ // Note: Route, RouteConfigUpdate, ActivationFnFactory,
28
28
  // PluginFactory, BuildStateResultWithSegments are in @real-router/core
29
29
  export type {
30
30
  Options,
@@ -36,7 +36,6 @@ export type {
36
36
  DefaultDependencies,
37
37
  Config,
38
38
  Plugin,
39
- Middleware,
40
39
  SubscribeState,
41
40
  SubscribeFn,
42
41
  Listener,
package/src/limits.ts CHANGED
@@ -19,14 +19,6 @@ export interface LimitsConfig {
19
19
  */
20
20
  maxPlugins: number;
21
21
 
22
- /**
23
- * Maximum number of middleware functions in the navigation pipeline.
24
- * Controls middleware chain length to prevent stack overflow and performance issues.
25
- *
26
- * @default 50
27
- */
28
- maxMiddleware: number;
29
-
30
22
  /**
31
23
  * Maximum number of event listeners per event type.
32
24
  * Prevents memory leaks from excessive listener registration.
package/src/router.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Base router types without Router class dependency.
5
5
  *
6
6
  * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
7
- * MiddlewareFactory, PluginFactory) are defined in @real-router/core
7
+ * PluginFactory) are defined in @real-router/core
8
8
  * to avoid circular dependencies.
9
9
  */
10
10
 
@@ -193,9 +193,6 @@ export interface Plugin {
193
193
  teardown?: () => void;
194
194
  }
195
195
 
196
- // eslint-disable-next-line sonarjs/redundant-type-aliases
197
- export type Middleware = ActivationFn;
198
-
199
196
  export interface SubscribeState {
200
197
  route: State;
201
198
  previousRoute?: State | undefined;
@@ -299,7 +296,7 @@ export interface Router {
299
296
  * Dispose the router and release all resources.
300
297
  *
301
298
  * Stops the router if active, calls plugin teardown, clears all event
302
- * listeners, middleware, routes, and dependencies. After disposal, all
299
+ * listeners, routes, and dependencies. After disposal, all
303
300
  * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
304
301
  * call multiple times.
305
302
  */