@real-router/types 0.15.0 → 0.17.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.
@@ -109,7 +109,6 @@ interface RouterError extends Error {
109
109
  * @see {@link State.meta} for where options are stored after navigation
110
110
  */
111
111
  interface NavigationOptions {
112
- [key: string]: string | number | boolean | Record<string, unknown> | undefined;
113
112
  /**
114
113
  * Replace the current history entry instead of pushing a new one.
115
114
  *
@@ -245,6 +244,17 @@ interface NavigationOptions {
245
244
  * @see {@link NavigationOptions.redirected} for the input mechanism
246
245
  */
247
246
  redirected?: boolean | undefined;
247
+ /**
248
+ * Optional abort signal for cancelling the navigation.
249
+ *
250
+ * @description
251
+ * When provided, this signal can be used to cancel the navigation operation.
252
+ * If the signal is aborted, the navigation will be cancelled and any pending
253
+ * guards or transitions will be interrupted.
254
+ *
255
+ * @default undefined
256
+ */
257
+ signal?: AbortSignal | undefined;
248
258
  }
249
259
  interface Params {
250
260
  [key: string]: string | string[] | number | number[] | boolean | boolean[] | Params | Params[] | Record<string, string | number | boolean> | null | undefined;
@@ -300,11 +310,11 @@ interface LimitsConfig {
300
310
  }
301
311
 
302
312
  /**
303
- * Base router types without Router class dependency.
313
+ * Router types and interfaces.
304
314
  *
305
- * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
306
- * PluginFactory) are defined in @real-router/core
307
- * to avoid circular dependencies.
315
+ * Factory types (PluginFactory, GuardFnFactory) and
316
+ * route config types (Route, RouteConfigUpdate) use self-referencing Router<D>
317
+ * within this single file to resolve circular dependencies.
308
318
  */
309
319
 
310
320
  type LogLevel = "log" | "warn" | "error";
@@ -416,8 +426,7 @@ interface Options {
416
426
  */
417
427
  noValidate?: boolean;
418
428
  }
419
- type ActivationFn = (toState: State, fromState: State | undefined) => boolean | Promise<boolean | State | void> | State | void;
420
- type GuardFn = (toState: State, fromState: State | undefined) => boolean | Promise<boolean>;
429
+ type GuardFn = (toState: State, fromState: State | undefined, signal?: AbortSignal) => boolean | Promise<boolean>;
421
430
  type DefaultDependencies = object;
422
431
  interface Config {
423
432
  decoders: Record<string, (params: Params) => Params>;
@@ -465,64 +474,94 @@ interface Navigator {
465
474
  subscribe: (listener: SubscribeFn) => Unsubscribe;
466
475
  }
467
476
  /**
468
- * Router interface - public API for route navigation and lifecycle management.
477
+ * Router interface full public API for route navigation and lifecycle management.
469
478
  *
470
- * Defines the contract for router implementations. The actual Router class in
471
- * @real-router/core implements this interface with full functionality.
472
- *
473
- * This interface uses `GuardFn | boolean` for guard types to avoid circular
474
- * dependencies. The concrete Router class in @real-router/core narrows this to
475
- * `GuardFnFactory | boolean` for more precise type checking.
479
+ * Generic parameter D constrains dependency injection types.
480
+ * Factory types (PluginFactory, GuardFnFactory) self-reference this interface
481
+ * within the same file to avoid circular dependencies.
476
482
  */
477
- interface Router {
478
- /**
479
- * Register an activation guard for a route.
480
- *
481
- * @param name - Route name
482
- * @param guard - Guard function or boolean
483
- * @returns this for method chaining
484
- */
485
- addActivateGuard: (name: string, guard: GuardFn | boolean) => this;
486
- /**
487
- * Register a deactivation guard for a route.
488
- *
489
- * @param name - Route name
490
- * @param guard - Guard function or boolean
491
- * @returns this for method chaining
492
- */
493
- addDeactivateGuard: (name: string, guard: GuardFn | boolean) => this;
494
- /**
495
- * Remove an activation guard from a route.
496
- *
497
- * @param name - Route name
498
- */
499
- removeActivateGuard: (name: string) => void;
500
- /**
501
- * Remove a deactivation guard from a route.
502
- *
503
- * @param name - Route name
504
- */
505
- removeDeactivateGuard: (name: string) => void;
483
+ interface Router<D extends DefaultDependencies = DefaultDependencies> {
484
+ [key: string]: unknown;
485
+ isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
486
+ buildPath: (route: string, params?: Params) => string;
487
+ getState: <P extends Params = Params, MP extends Params = Params>() => State<P, MP> | undefined;
488
+ getPreviousState: () => State | undefined;
489
+ areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
490
+ shouldUpdateNode: (nodeName: string) => (toState: State, fromState?: State) => boolean;
491
+ isActive: () => boolean;
492
+ start: (startPath: string) => Promise<State>;
493
+ stop: () => this;
494
+ dispose: () => void;
495
+ canNavigateTo: (name: string, params?: Params) => boolean;
496
+ usePlugin: (...plugins: PluginFactory<D>[]) => Unsubscribe;
497
+ subscribe: (listener: SubscribeFn) => Unsubscribe;
498
+ navigate: (routeName: string, routeParams?: Params, options?: NavigationOptions) => Promise<State>;
499
+ navigateToDefault: (options?: NavigationOptions) => Promise<State>;
500
+ }
501
+ /**
502
+ * Factory function for creating plugins.
503
+ * Receives the router instance and a dependency getter.
504
+ */
505
+ type PluginFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => Plugin;
506
+ /**
507
+ * Factory function for creating guards.
508
+ * Receives the router instance and a dependency getter.
509
+ */
510
+ type GuardFnFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => GuardFn;
511
+ /**
512
+ * Route configuration.
513
+ */
514
+ interface Route<Dependencies extends DefaultDependencies = DefaultDependencies> {
515
+ [key: string]: unknown;
516
+ /** Route name (dot-separated for nested routes). */
517
+ name: string;
518
+ /** URL path pattern for this route. */
519
+ path: string;
520
+ /** Factory function that returns a guard for route activation. */
521
+ canActivate?: GuardFnFactory<Dependencies>;
522
+ /** Factory function that returns a guard for route deactivation. */
523
+ canDeactivate?: GuardFnFactory<Dependencies>;
506
524
  /**
507
- * Check if navigation to a route is allowed without performing actual navigation.
525
+ * Redirects navigation to another route.
508
526
  *
509
- * Synchronously checks all activation and deactivation guards in the transition path.
510
- * Async guards return false with a console warning.
527
+ * IMPORTANT: forwardTo creates a URL alias, not a transition chain.
528
+ * Guards (canActivate) on the source route are NOT executed.
529
+ * Only guards on the final destination are executed.
511
530
  *
512
- * @param name - Route name to check
513
- * @param params - Route parameters (optional)
514
- * @returns true if navigation is allowed, false otherwise
531
+ * This matches Vue Router and Angular Router behavior.
515
532
  */
516
- canNavigateTo: (name: string, params?: Params) => boolean;
533
+ forwardTo?: string | ForwardToCallback<Dependencies>;
534
+ /** Nested child routes. */
535
+ children?: Route<Dependencies>[];
536
+ /** Encodes state params to URL params. */
537
+ encodeParams?: (stateParams: Params) => Params;
538
+ /** Decodes URL params to state params. */
539
+ decodeParams?: (pathParams: Params) => Params;
517
540
  /**
518
- * Dispose the router and release all resources.
541
+ * Default parameters for this route.
519
542
  *
520
- * Stops the router if active, calls plugin teardown, clears all event
521
- * listeners, routes, and dependencies. After disposal, all
522
- * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
523
- * call multiple times.
543
+ * These values are merged into state.params when creating route states.
544
+ * Missing URL params are filled from defaultParams.
524
545
  */
525
- dispose: () => void;
546
+ defaultParams?: Params;
547
+ }
548
+ /**
549
+ * Configuration update options for updateRoute().
550
+ * All properties are optional. Set to null to remove the configuration.
551
+ */
552
+ interface RouteConfigUpdate<Dependencies extends DefaultDependencies = DefaultDependencies> {
553
+ /** Set to null to remove forwardTo */
554
+ forwardTo?: string | ForwardToCallback<Dependencies> | null;
555
+ /** Set to null to remove defaultParams */
556
+ defaultParams?: Params | null;
557
+ /** Set to null to remove decoder */
558
+ decodeParams?: ((params: Params) => Params) | null;
559
+ /** Set to null to remove encoder */
560
+ encodeParams?: ((params: Params) => Params) | null;
561
+ /** Set to null to remove canActivate */
562
+ canActivate?: GuardFnFactory<Dependencies> | null;
563
+ /** Set to null to remove canDeactivate */
564
+ canDeactivate?: GuardFnFactory<Dependencies> | null;
526
565
  }
527
566
 
528
567
  /**
@@ -567,6 +606,13 @@ interface EventToNameMap {
567
606
  TRANSITION_SUCCESS: "$$success";
568
607
  TRANSITION_ERROR: "$$error";
569
608
  }
609
+ /**
610
+ * Mapping of event names to plugin method names.
611
+ * Type-level computation from EventToNameMap + EventToPluginMap.
612
+ */
613
+ type EventMethodMap = {
614
+ [K in EventsKeys as EventToNameMap[K]]: EventToPluginMap[K];
615
+ };
570
616
  /**
571
617
  * Mapping of error code keys to their values
572
618
  */
@@ -583,4 +629,64 @@ interface ErrorCodeToValueMap {
583
629
  ROUTER_DISPOSED: "DISPOSED";
584
630
  }
585
631
 
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 };
632
+ /**
633
+ * API interfaces for modular router access.
634
+ * These interfaces are implemented by standalone API functions in @real-router/core.
635
+ */
636
+
637
+ /**
638
+ * Plugin API — for plugins and infrastructure packages.
639
+ * Hides plugin-internal methods from public autocomplete.
640
+ */
641
+ interface PluginApi {
642
+ makeState: <P extends Params = Params, MP extends Params = Params>(name: string, params?: P, path?: string, meta?: StateMetaInput<MP>, forceId?: number) => State<P, MP>;
643
+ buildState: (routeName: string, routeParams: Params) => RouteTreeState | undefined;
644
+ forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
645
+ matchPath: <P extends Params = Params, MP extends Params = Params>(path: string) => State<P, MP> | undefined;
646
+ setRootPath: (rootPath: string) => void;
647
+ getRootPath: () => string;
648
+ navigateToState: (toState: State, fromState: State | undefined, opts: NavigationOptions) => Promise<State>;
649
+ addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
650
+ buildNavigationState: (name: string, params?: Params) => State | undefined;
651
+ getOptions: () => Options;
652
+ getTree: () => unknown;
653
+ getForwardState: () => <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
654
+ setForwardState: (fn: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>) => void;
655
+ }
656
+ /**
657
+ * Routes API — for dynamic route mutation.
658
+ */
659
+ interface RoutesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
660
+ add: (routes: Route<Dependencies>[] | Route<Dependencies>, options?: {
661
+ parent?: string;
662
+ }) => void;
663
+ remove: (name: string) => void;
664
+ update: (name: string, updates: RouteConfigUpdate<Dependencies>) => void;
665
+ clear: () => void;
666
+ has: (name: string) => boolean;
667
+ get: (name: string) => Route<Dependencies> | undefined;
668
+ getConfig: (name: string) => Record<string, unknown> | undefined;
669
+ }
670
+ /**
671
+ * Dependencies API — CRUD for dependency injection.
672
+ */
673
+ interface DependenciesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
674
+ get: <K extends keyof Dependencies>(key: K) => Dependencies[K];
675
+ getAll: () => Partial<Dependencies>;
676
+ set: <K extends keyof Dependencies & string>(name: K, value: Dependencies[K]) => void;
677
+ setAll: (deps: Dependencies) => void;
678
+ remove: (name: keyof Dependencies) => void;
679
+ reset: () => void;
680
+ has: (name: keyof Dependencies) => boolean;
681
+ }
682
+ /**
683
+ * Lifecycle API — guard registration (addActivateGuard, addDeactivateGuard, etc.)
684
+ */
685
+ interface LifecycleApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
686
+ addActivateGuard: (name: string, canActivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
687
+ addDeactivateGuard: (name: string, canDeactivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
688
+ removeActivateGuard: (name: string) => void;
689
+ removeDeactivateGuard: (name: string) => void;
690
+ }
691
+
692
+ export type { Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, DependenciesApi, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, GuardFnFactory, LifecycleApi, LimitsConfig, Listener, NavigationOptions, Navigator, Options, Params, Plugin, PluginApi, PluginFactory, PluginMethod, QueryParamsMode, QueryParamsOptions, Route, RouteConfigUpdate, RouteParams, RouteTreeState, Router, RouterError, RoutesApi, 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":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}}}
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":1349,"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}}}
@@ -109,7 +109,6 @@ interface RouterError extends Error {
109
109
  * @see {@link State.meta} for where options are stored after navigation
110
110
  */
111
111
  interface NavigationOptions {
112
- [key: string]: string | number | boolean | Record<string, unknown> | undefined;
113
112
  /**
114
113
  * Replace the current history entry instead of pushing a new one.
115
114
  *
@@ -245,6 +244,17 @@ interface NavigationOptions {
245
244
  * @see {@link NavigationOptions.redirected} for the input mechanism
246
245
  */
247
246
  redirected?: boolean | undefined;
247
+ /**
248
+ * Optional abort signal for cancelling the navigation.
249
+ *
250
+ * @description
251
+ * When provided, this signal can be used to cancel the navigation operation.
252
+ * If the signal is aborted, the navigation will be cancelled and any pending
253
+ * guards or transitions will be interrupted.
254
+ *
255
+ * @default undefined
256
+ */
257
+ signal?: AbortSignal | undefined;
248
258
  }
249
259
  interface Params {
250
260
  [key: string]: string | string[] | number | number[] | boolean | boolean[] | Params | Params[] | Record<string, string | number | boolean> | null | undefined;
@@ -300,11 +310,11 @@ interface LimitsConfig {
300
310
  }
301
311
 
302
312
  /**
303
- * Base router types without Router class dependency.
313
+ * Router types and interfaces.
304
314
  *
305
- * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
306
- * PluginFactory) are defined in @real-router/core
307
- * to avoid circular dependencies.
315
+ * Factory types (PluginFactory, GuardFnFactory) and
316
+ * route config types (Route, RouteConfigUpdate) use self-referencing Router<D>
317
+ * within this single file to resolve circular dependencies.
308
318
  */
309
319
 
310
320
  type LogLevel = "log" | "warn" | "error";
@@ -416,8 +426,7 @@ interface Options {
416
426
  */
417
427
  noValidate?: boolean;
418
428
  }
419
- type ActivationFn = (toState: State, fromState: State | undefined) => boolean | Promise<boolean | State | void> | State | void;
420
- type GuardFn = (toState: State, fromState: State | undefined) => boolean | Promise<boolean>;
429
+ type GuardFn = (toState: State, fromState: State | undefined, signal?: AbortSignal) => boolean | Promise<boolean>;
421
430
  type DefaultDependencies = object;
422
431
  interface Config {
423
432
  decoders: Record<string, (params: Params) => Params>;
@@ -465,64 +474,94 @@ interface Navigator {
465
474
  subscribe: (listener: SubscribeFn) => Unsubscribe;
466
475
  }
467
476
  /**
468
- * Router interface - public API for route navigation and lifecycle management.
477
+ * Router interface full public API for route navigation and lifecycle management.
469
478
  *
470
- * Defines the contract for router implementations. The actual Router class in
471
- * @real-router/core implements this interface with full functionality.
472
- *
473
- * This interface uses `GuardFn | boolean` for guard types to avoid circular
474
- * dependencies. The concrete Router class in @real-router/core narrows this to
475
- * `GuardFnFactory | boolean` for more precise type checking.
479
+ * Generic parameter D constrains dependency injection types.
480
+ * Factory types (PluginFactory, GuardFnFactory) self-reference this interface
481
+ * within the same file to avoid circular dependencies.
476
482
  */
477
- interface Router {
478
- /**
479
- * Register an activation guard for a route.
480
- *
481
- * @param name - Route name
482
- * @param guard - Guard function or boolean
483
- * @returns this for method chaining
484
- */
485
- addActivateGuard: (name: string, guard: GuardFn | boolean) => this;
486
- /**
487
- * Register a deactivation guard for a route.
488
- *
489
- * @param name - Route name
490
- * @param guard - Guard function or boolean
491
- * @returns this for method chaining
492
- */
493
- addDeactivateGuard: (name: string, guard: GuardFn | boolean) => this;
494
- /**
495
- * Remove an activation guard from a route.
496
- *
497
- * @param name - Route name
498
- */
499
- removeActivateGuard: (name: string) => void;
500
- /**
501
- * Remove a deactivation guard from a route.
502
- *
503
- * @param name - Route name
504
- */
505
- removeDeactivateGuard: (name: string) => void;
483
+ interface Router<D extends DefaultDependencies = DefaultDependencies> {
484
+ [key: string]: unknown;
485
+ isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
486
+ buildPath: (route: string, params?: Params) => string;
487
+ getState: <P extends Params = Params, MP extends Params = Params>() => State<P, MP> | undefined;
488
+ getPreviousState: () => State | undefined;
489
+ areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
490
+ shouldUpdateNode: (nodeName: string) => (toState: State, fromState?: State) => boolean;
491
+ isActive: () => boolean;
492
+ start: (startPath: string) => Promise<State>;
493
+ stop: () => this;
494
+ dispose: () => void;
495
+ canNavigateTo: (name: string, params?: Params) => boolean;
496
+ usePlugin: (...plugins: PluginFactory<D>[]) => Unsubscribe;
497
+ subscribe: (listener: SubscribeFn) => Unsubscribe;
498
+ navigate: (routeName: string, routeParams?: Params, options?: NavigationOptions) => Promise<State>;
499
+ navigateToDefault: (options?: NavigationOptions) => Promise<State>;
500
+ }
501
+ /**
502
+ * Factory function for creating plugins.
503
+ * Receives the router instance and a dependency getter.
504
+ */
505
+ type PluginFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => Plugin;
506
+ /**
507
+ * Factory function for creating guards.
508
+ * Receives the router instance and a dependency getter.
509
+ */
510
+ type GuardFnFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => GuardFn;
511
+ /**
512
+ * Route configuration.
513
+ */
514
+ interface Route<Dependencies extends DefaultDependencies = DefaultDependencies> {
515
+ [key: string]: unknown;
516
+ /** Route name (dot-separated for nested routes). */
517
+ name: string;
518
+ /** URL path pattern for this route. */
519
+ path: string;
520
+ /** Factory function that returns a guard for route activation. */
521
+ canActivate?: GuardFnFactory<Dependencies>;
522
+ /** Factory function that returns a guard for route deactivation. */
523
+ canDeactivate?: GuardFnFactory<Dependencies>;
506
524
  /**
507
- * Check if navigation to a route is allowed without performing actual navigation.
525
+ * Redirects navigation to another route.
508
526
  *
509
- * Synchronously checks all activation and deactivation guards in the transition path.
510
- * Async guards return false with a console warning.
527
+ * IMPORTANT: forwardTo creates a URL alias, not a transition chain.
528
+ * Guards (canActivate) on the source route are NOT executed.
529
+ * Only guards on the final destination are executed.
511
530
  *
512
- * @param name - Route name to check
513
- * @param params - Route parameters (optional)
514
- * @returns true if navigation is allowed, false otherwise
531
+ * This matches Vue Router and Angular Router behavior.
515
532
  */
516
- canNavigateTo: (name: string, params?: Params) => boolean;
533
+ forwardTo?: string | ForwardToCallback<Dependencies>;
534
+ /** Nested child routes. */
535
+ children?: Route<Dependencies>[];
536
+ /** Encodes state params to URL params. */
537
+ encodeParams?: (stateParams: Params) => Params;
538
+ /** Decodes URL params to state params. */
539
+ decodeParams?: (pathParams: Params) => Params;
517
540
  /**
518
- * Dispose the router and release all resources.
541
+ * Default parameters for this route.
519
542
  *
520
- * Stops the router if active, calls plugin teardown, clears all event
521
- * listeners, routes, and dependencies. After disposal, all
522
- * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
523
- * call multiple times.
543
+ * These values are merged into state.params when creating route states.
544
+ * Missing URL params are filled from defaultParams.
524
545
  */
525
- dispose: () => void;
546
+ defaultParams?: Params;
547
+ }
548
+ /**
549
+ * Configuration update options for updateRoute().
550
+ * All properties are optional. Set to null to remove the configuration.
551
+ */
552
+ interface RouteConfigUpdate<Dependencies extends DefaultDependencies = DefaultDependencies> {
553
+ /** Set to null to remove forwardTo */
554
+ forwardTo?: string | ForwardToCallback<Dependencies> | null;
555
+ /** Set to null to remove defaultParams */
556
+ defaultParams?: Params | null;
557
+ /** Set to null to remove decoder */
558
+ decodeParams?: ((params: Params) => Params) | null;
559
+ /** Set to null to remove encoder */
560
+ encodeParams?: ((params: Params) => Params) | null;
561
+ /** Set to null to remove canActivate */
562
+ canActivate?: GuardFnFactory<Dependencies> | null;
563
+ /** Set to null to remove canDeactivate */
564
+ canDeactivate?: GuardFnFactory<Dependencies> | null;
526
565
  }
527
566
 
528
567
  /**
@@ -567,6 +606,13 @@ interface EventToNameMap {
567
606
  TRANSITION_SUCCESS: "$$success";
568
607
  TRANSITION_ERROR: "$$error";
569
608
  }
609
+ /**
610
+ * Mapping of event names to plugin method names.
611
+ * Type-level computation from EventToNameMap + EventToPluginMap.
612
+ */
613
+ type EventMethodMap = {
614
+ [K in EventsKeys as EventToNameMap[K]]: EventToPluginMap[K];
615
+ };
570
616
  /**
571
617
  * Mapping of error code keys to their values
572
618
  */
@@ -583,4 +629,64 @@ interface ErrorCodeToValueMap {
583
629
  ROUTER_DISPOSED: "DISPOSED";
584
630
  }
585
631
 
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 };
632
+ /**
633
+ * API interfaces for modular router access.
634
+ * These interfaces are implemented by standalone API functions in @real-router/core.
635
+ */
636
+
637
+ /**
638
+ * Plugin API — for plugins and infrastructure packages.
639
+ * Hides plugin-internal methods from public autocomplete.
640
+ */
641
+ interface PluginApi {
642
+ makeState: <P extends Params = Params, MP extends Params = Params>(name: string, params?: P, path?: string, meta?: StateMetaInput<MP>, forceId?: number) => State<P, MP>;
643
+ buildState: (routeName: string, routeParams: Params) => RouteTreeState | undefined;
644
+ forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
645
+ matchPath: <P extends Params = Params, MP extends Params = Params>(path: string) => State<P, MP> | undefined;
646
+ setRootPath: (rootPath: string) => void;
647
+ getRootPath: () => string;
648
+ navigateToState: (toState: State, fromState: State | undefined, opts: NavigationOptions) => Promise<State>;
649
+ addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
650
+ buildNavigationState: (name: string, params?: Params) => State | undefined;
651
+ getOptions: () => Options;
652
+ getTree: () => unknown;
653
+ getForwardState: () => <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
654
+ setForwardState: (fn: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>) => void;
655
+ }
656
+ /**
657
+ * Routes API — for dynamic route mutation.
658
+ */
659
+ interface RoutesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
660
+ add: (routes: Route<Dependencies>[] | Route<Dependencies>, options?: {
661
+ parent?: string;
662
+ }) => void;
663
+ remove: (name: string) => void;
664
+ update: (name: string, updates: RouteConfigUpdate<Dependencies>) => void;
665
+ clear: () => void;
666
+ has: (name: string) => boolean;
667
+ get: (name: string) => Route<Dependencies> | undefined;
668
+ getConfig: (name: string) => Record<string, unknown> | undefined;
669
+ }
670
+ /**
671
+ * Dependencies API — CRUD for dependency injection.
672
+ */
673
+ interface DependenciesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
674
+ get: <K extends keyof Dependencies>(key: K) => Dependencies[K];
675
+ getAll: () => Partial<Dependencies>;
676
+ set: <K extends keyof Dependencies & string>(name: K, value: Dependencies[K]) => void;
677
+ setAll: (deps: Dependencies) => void;
678
+ remove: (name: keyof Dependencies) => void;
679
+ reset: () => void;
680
+ has: (name: keyof Dependencies) => boolean;
681
+ }
682
+ /**
683
+ * Lifecycle API — guard registration (addActivateGuard, addDeactivateGuard, etc.)
684
+ */
685
+ interface LifecycleApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
686
+ addActivateGuard: (name: string, canActivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
687
+ addDeactivateGuard: (name: string, canDeactivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
688
+ removeActivateGuard: (name: string) => void;
689
+ removeDeactivateGuard: (name: string) => void;
690
+ }
691
+
692
+ export type { Config, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, DependenciesApi, ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, ForwardToCallback, GuardFn, GuardFnFactory, LifecycleApi, LimitsConfig, Listener, NavigationOptions, Navigator, Options, Params, Plugin, PluginApi, PluginFactory, PluginMethod, QueryParamsMode, QueryParamsOptions, Route, RouteConfigUpdate, RouteParams, RouteTreeState, Router, RouterError, RoutesApi, SimpleState, State, StateMeta, StateMetaInput, SubscribeFn, SubscribeState, Subscription, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe };
@@ -1 +1 @@
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}}}
1
+ {"inputs":{"src/index.ts":{"bytes":1349,"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.15.0",
3
+ "version": "0.17.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/api.ts ADDED
@@ -0,0 +1,145 @@
1
+ // packages/core-types/modules/api.ts
2
+
3
+ /**
4
+ * API interfaces for modular router access.
5
+ * These interfaces are implemented by standalone API functions in @real-router/core.
6
+ */
7
+
8
+ import type {
9
+ Params,
10
+ State,
11
+ SimpleState,
12
+ StateMetaInput,
13
+ NavigationOptions,
14
+ Unsubscribe,
15
+ } from "./base";
16
+ import type { EventMethodMap, EventName } from "./constants";
17
+ import type { RouteTreeState } from "./route-node-types";
18
+ import type {
19
+ DefaultDependencies,
20
+ GuardFnFactory,
21
+ Options,
22
+ Plugin,
23
+ Route,
24
+ RouteConfigUpdate,
25
+ } from "./router";
26
+
27
+ /**
28
+ * Plugin API — for plugins and infrastructure packages.
29
+ * Hides plugin-internal methods from public autocomplete.
30
+ */
31
+ export interface PluginApi {
32
+ makeState: <P extends Params = Params, MP extends Params = Params>(
33
+ name: string,
34
+ params?: P,
35
+ path?: string,
36
+ meta?: StateMetaInput<MP>,
37
+ forceId?: number,
38
+ ) => State<P, MP>;
39
+
40
+ buildState: (
41
+ routeName: string,
42
+ routeParams: Params,
43
+ ) => RouteTreeState | undefined;
44
+
45
+ forwardState: <P extends Params = Params>(
46
+ routeName: string,
47
+ routeParams: P,
48
+ ) => SimpleState<P>;
49
+
50
+ matchPath: <P extends Params = Params, MP extends Params = Params>(
51
+ path: string,
52
+ ) => State<P, MP> | undefined;
53
+
54
+ setRootPath: (rootPath: string) => void;
55
+ getRootPath: () => string;
56
+
57
+ navigateToState: (
58
+ toState: State,
59
+ fromState: State | undefined,
60
+ opts: NavigationOptions,
61
+ ) => Promise<State>;
62
+
63
+ addEventListener: <E extends EventName>(
64
+ eventName: E,
65
+ cb: Plugin[EventMethodMap[E]],
66
+ ) => Unsubscribe;
67
+
68
+ buildNavigationState: (name: string, params?: Params) => State | undefined;
69
+
70
+ getOptions: () => Options;
71
+
72
+ getTree: () => unknown;
73
+
74
+ getForwardState: () => <P extends Params = Params>(
75
+ routeName: string,
76
+ routeParams: P,
77
+ ) => SimpleState<P>;
78
+
79
+ setForwardState: (
80
+ fn: <P extends Params = Params>(
81
+ routeName: string,
82
+ routeParams: P,
83
+ ) => SimpleState<P>,
84
+ ) => void;
85
+ }
86
+
87
+ /**
88
+ * Routes API — for dynamic route mutation.
89
+ */
90
+ export interface RoutesApi<
91
+ Dependencies extends DefaultDependencies = DefaultDependencies,
92
+ > {
93
+ add: (
94
+ routes: Route<Dependencies>[] | Route<Dependencies>,
95
+ options?: { parent?: string },
96
+ ) => void;
97
+
98
+ remove: (name: string) => void;
99
+
100
+ update: (name: string, updates: RouteConfigUpdate<Dependencies>) => void;
101
+
102
+ clear: () => void;
103
+
104
+ has: (name: string) => boolean;
105
+
106
+ get: (name: string) => Route<Dependencies> | undefined;
107
+
108
+ getConfig: (name: string) => Record<string, unknown> | undefined;
109
+ }
110
+
111
+ /**
112
+ * Dependencies API — CRUD for dependency injection.
113
+ */
114
+ export interface DependenciesApi<
115
+ Dependencies extends DefaultDependencies = DefaultDependencies,
116
+ > {
117
+ get: <K extends keyof Dependencies>(key: K) => Dependencies[K];
118
+ getAll: () => Partial<Dependencies>;
119
+ set: <K extends keyof Dependencies & string>(
120
+ name: K,
121
+ value: Dependencies[K],
122
+ ) => void;
123
+ setAll: (deps: Dependencies) => void;
124
+ remove: (name: keyof Dependencies) => void;
125
+ reset: () => void;
126
+ has: (name: keyof Dependencies) => boolean;
127
+ }
128
+
129
+ /**
130
+ * Lifecycle API — guard registration (addActivateGuard, addDeactivateGuard, etc.)
131
+ */
132
+ export interface LifecycleApi<
133
+ Dependencies extends DefaultDependencies = DefaultDependencies,
134
+ > {
135
+ addActivateGuard: (
136
+ name: string,
137
+ canActivateHandler: GuardFnFactory<Dependencies> | boolean,
138
+ ) => void;
139
+ addDeactivateGuard: (
140
+ name: string,
141
+ canDeactivateHandler: GuardFnFactory<Dependencies> | boolean,
142
+ ) => void;
143
+ removeActivateGuard: (name: string) => void;
144
+ removeDeactivateGuard: (name: string) => void;
145
+ }
package/src/base.ts CHANGED
@@ -86,13 +86,6 @@ export interface RouterError extends Error {
86
86
  * @see {@link State.meta} for where options are stored after navigation
87
87
  */
88
88
  export interface NavigationOptions {
89
- [key: string]:
90
- | string
91
- | number
92
- | boolean
93
- | Record<string, unknown>
94
- | undefined;
95
-
96
89
  /**
97
90
  * Replace the current history entry instead of pushing a new one.
98
91
  *
@@ -232,6 +225,18 @@ export interface NavigationOptions {
232
225
  * @see {@link NavigationOptions.redirected} for the input mechanism
233
226
  */
234
227
  redirected?: boolean | undefined;
228
+
229
+ /**
230
+ * Optional abort signal for cancelling the navigation.
231
+ *
232
+ * @description
233
+ * When provided, this signal can be used to cancel the navigation operation.
234
+ * If the signal is aborted, the navigation will be cancelled and any pending
235
+ * guards or transitions will be interrupted.
236
+ *
237
+ * @default undefined
238
+ */
239
+ signal?: AbortSignal | undefined;
235
240
  }
236
241
 
237
242
  export interface Params {
package/src/constants.ts CHANGED
@@ -87,6 +87,14 @@ export interface EventToNameMap {
87
87
  TRANSITION_ERROR: "$$error";
88
88
  }
89
89
 
90
+ /**
91
+ * Mapping of event names to plugin method names.
92
+ * Type-level computation from EventToNameMap + EventToPluginMap.
93
+ */
94
+ export type EventMethodMap = {
95
+ [K in EventsKeys as EventToNameMap[K]]: EventToPluginMap[K];
96
+ };
97
+
90
98
  /**
91
99
  * Mapping of error code keys to their values
92
100
  */
package/src/index.ts CHANGED
@@ -23,25 +23,26 @@ export type {
23
23
  TransitionMeta,
24
24
  } from "./base";
25
25
 
26
- // Router types (base types without Router dependency)
27
- // Note: Route, RouteConfigUpdate, ActivationFnFactory,
28
- // PluginFactory, BuildStateResultWithSegments are in @real-router/core
26
+ // Router types, factory types, and route config types
29
27
  export type {
28
+ Router,
29
+ Navigator,
30
+ Route,
31
+ Plugin,
32
+ Listener,
30
33
  Options,
31
34
  DefaultRouteCallback,
32
35
  ForwardToCallback,
33
36
  DefaultParamsCallback,
34
- ActivationFn,
35
37
  GuardFn,
36
38
  DefaultDependencies,
37
39
  Config,
38
- Plugin,
39
40
  SubscribeState,
40
41
  SubscribeFn,
41
- Listener,
42
42
  Subscription,
43
- Navigator,
44
- Router,
43
+ PluginFactory,
44
+ GuardFnFactory,
45
+ RouteConfigUpdate,
45
46
  } from "./router";
46
47
 
47
48
  // Limits configuration
@@ -56,7 +57,16 @@ export type {
56
57
  EventToPluginMap,
57
58
  EventToNameMap,
58
59
  ErrorCodeToValueMap,
60
+ EventMethodMap,
59
61
  } from "./constants";
60
62
 
63
+ // API interfaces (modular router access)
64
+ export type {
65
+ PluginApi,
66
+ RoutesApi,
67
+ DependenciesApi,
68
+ LifecycleApi,
69
+ } from "./api";
70
+
61
71
  // Note: RouterError type is a forward declaration matching the class in real-router package
62
72
  // Use import { RouterError } from "real-router" for the actual class implementation
package/src/router.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  // packages/core-types/modules/router.ts
2
2
 
3
3
  /**
4
- * Base router types without Router class dependency.
4
+ * Router types and interfaces.
5
5
  *
6
- * Router-dependent types (Route, RouteConfigUpdate, ActivationFnFactory,
7
- * PluginFactory) are defined in @real-router/core
8
- * to avoid circular dependencies.
6
+ * Factory types (PluginFactory, GuardFnFactory) and
7
+ * route config types (Route, RouteConfigUpdate) use self-referencing Router<D>
8
+ * within this single file to resolve circular dependencies.
9
9
  */
10
10
 
11
11
  import type {
@@ -155,15 +155,10 @@ export interface Options {
155
155
  noValidate?: boolean;
156
156
  }
157
157
 
158
- export type ActivationFn = (
159
- toState: State,
160
- fromState: State | undefined,
161
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
162
- ) => boolean | Promise<boolean | State | void> | State | void;
163
-
164
158
  export type GuardFn = (
165
159
  toState: State,
166
160
  fromState: State | undefined,
161
+ signal?: AbortSignal,
167
162
  ) => boolean | Promise<boolean>;
168
163
 
169
164
  export type DefaultDependencies = object;
@@ -238,67 +233,152 @@ export interface Navigator {
238
233
  }
239
234
 
240
235
  /**
241
- * Router interface - public API for route navigation and lifecycle management.
242
- *
243
- * Defines the contract for router implementations. The actual Router class in
244
- * @real-router/core implements this interface with full functionality.
236
+ * Router interface full public API for route navigation and lifecycle management.
245
237
  *
246
- * This interface uses `GuardFn | boolean` for guard types to avoid circular
247
- * dependencies. The concrete Router class in @real-router/core narrows this to
248
- * `GuardFnFactory | boolean` for more precise type checking.
238
+ * Generic parameter D constrains dependency injection types.
239
+ * Factory types (PluginFactory, GuardFnFactory) self-reference this interface
240
+ * within the same file to avoid circular dependencies.
249
241
  */
250
- export interface Router {
251
- /**
252
- * Register an activation guard for a route.
253
- *
254
- * @param name - Route name
255
- * @param guard - Guard function or boolean
256
- * @returns this for method chaining
257
- */
258
- addActivateGuard: (name: string, guard: GuardFn | boolean) => this;
242
+ export interface Router<D extends DefaultDependencies = DefaultDependencies> {
243
+ // Plugins add properties at runtime (e.g. browser-plugin adds buildUrl, matchUrl).
244
+ // Index signature allows property access when module augmentation isn't in scope.
245
+ [key: string]: unknown;
259
246
 
260
- /**
261
- * Register a deactivation guard for a route.
262
- *
263
- * @param name - Route name
264
- * @param guard - Guard function or boolean
265
- * @returns this for method chaining
266
- */
267
- addDeactivateGuard: (name: string, guard: GuardFn | boolean) => this;
247
+ isActiveRoute: (
248
+ name: string,
249
+ params?: Params,
250
+ strictEquality?: boolean,
251
+ ignoreQueryParams?: boolean,
252
+ ) => boolean;
268
253
 
269
- /**
270
- * Remove an activation guard from a route.
271
- *
272
- * @param name - Route name
273
- */
274
- removeActivateGuard: (name: string) => void;
254
+ buildPath: (route: string, params?: Params) => string;
275
255
 
276
- /**
277
- * Remove a deactivation guard from a route.
278
- *
279
- * @param name - Route name
280
- */
281
- removeDeactivateGuard: (name: string) => void;
256
+ getState: <P extends Params = Params, MP extends Params = Params>() =>
257
+ | State<P, MP>
258
+ | undefined;
259
+
260
+ getPreviousState: () => State | undefined;
261
+
262
+ areStatesEqual: (
263
+ state1: State | undefined,
264
+ state2: State | undefined,
265
+ ignoreQueryParams?: boolean,
266
+ ) => boolean;
267
+
268
+ shouldUpdateNode: (
269
+ nodeName: string,
270
+ ) => (toState: State, fromState?: State) => boolean;
271
+
272
+ isActive: () => boolean;
273
+
274
+ start: (startPath: string) => Promise<State>;
275
+
276
+ stop: () => this;
277
+
278
+ dispose: () => void;
279
+
280
+ canNavigateTo: (name: string, params?: Params) => boolean;
281
+
282
+ usePlugin: (...plugins: PluginFactory<D>[]) => Unsubscribe;
283
+
284
+ subscribe: (listener: SubscribeFn) => Unsubscribe;
285
+
286
+ navigate: (
287
+ routeName: string,
288
+ routeParams?: Params,
289
+ options?: NavigationOptions,
290
+ ) => Promise<State>;
291
+
292
+ navigateToDefault: (options?: NavigationOptions) => Promise<State>;
293
+ }
294
+
295
+ // =============================================================================
296
+ // Factory Types (self-reference Router<D>)
297
+ // =============================================================================
298
+
299
+ /**
300
+ * Factory function for creating plugins.
301
+ * Receives the router instance and a dependency getter.
302
+ */
303
+ export type PluginFactory<
304
+ Dependencies extends DefaultDependencies = DefaultDependencies,
305
+ > = (
306
+ router: Router<Dependencies>,
307
+ getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K],
308
+ ) => Plugin;
309
+
310
+ /**
311
+ * Factory function for creating guards.
312
+ * Receives the router instance and a dependency getter.
313
+ */
314
+ export type GuardFnFactory<
315
+ Dependencies extends DefaultDependencies = DefaultDependencies,
316
+ > = (
317
+ router: Router<Dependencies>,
318
+ getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K],
319
+ ) => GuardFn;
320
+
321
+ // =============================================================================
322
+ // Route Configuration Types (use GuardFnFactory<D> + ForwardToCallback<D>)
323
+ // =============================================================================
282
324
 
325
+ /**
326
+ * Route configuration.
327
+ */
328
+ export interface Route<
329
+ Dependencies extends DefaultDependencies = DefaultDependencies,
330
+ > {
331
+ [key: string]: unknown;
332
+ /** Route name (dot-separated for nested routes). */
333
+ name: string;
334
+ /** URL path pattern for this route. */
335
+ path: string;
336
+ /** Factory function that returns a guard for route activation. */
337
+ canActivate?: GuardFnFactory<Dependencies>;
338
+ /** Factory function that returns a guard for route deactivation. */
339
+ canDeactivate?: GuardFnFactory<Dependencies>;
283
340
  /**
284
- * Check if navigation to a route is allowed without performing actual navigation.
341
+ * Redirects navigation to another route.
285
342
  *
286
- * Synchronously checks all activation and deactivation guards in the transition path.
287
- * Async guards return false with a console warning.
343
+ * IMPORTANT: forwardTo creates a URL alias, not a transition chain.
344
+ * Guards (canActivate) on the source route are NOT executed.
345
+ * Only guards on the final destination are executed.
288
346
  *
289
- * @param name - Route name to check
290
- * @param params - Route parameters (optional)
291
- * @returns true if navigation is allowed, false otherwise
347
+ * This matches Vue Router and Angular Router behavior.
292
348
  */
293
- canNavigateTo: (name: string, params?: Params) => boolean;
294
-
349
+ forwardTo?: string | ForwardToCallback<Dependencies>;
350
+ /** Nested child routes. */
351
+ children?: Route<Dependencies>[];
352
+ /** Encodes state params to URL params. */
353
+ encodeParams?: (stateParams: Params) => Params;
354
+ /** Decodes URL params to state params. */
355
+ decodeParams?: (pathParams: Params) => Params;
295
356
  /**
296
- * Dispose the router and release all resources.
357
+ * Default parameters for this route.
297
358
  *
298
- * Stops the router if active, calls plugin teardown, clears all event
299
- * listeners, routes, and dependencies. After disposal, all
300
- * mutating methods throw a ROUTER_DISPOSED error. Idempotent — safe to
301
- * call multiple times.
359
+ * These values are merged into state.params when creating route states.
360
+ * Missing URL params are filled from defaultParams.
302
361
  */
303
- dispose: () => void;
362
+ defaultParams?: Params;
363
+ }
364
+
365
+ /**
366
+ * Configuration update options for updateRoute().
367
+ * All properties are optional. Set to null to remove the configuration.
368
+ */
369
+ export interface RouteConfigUpdate<
370
+ Dependencies extends DefaultDependencies = DefaultDependencies,
371
+ > {
372
+ /** Set to null to remove forwardTo */
373
+ forwardTo?: string | ForwardToCallback<Dependencies> | null;
374
+ /** Set to null to remove defaultParams */
375
+ defaultParams?: Params | null;
376
+ /** Set to null to remove decoder */
377
+ decodeParams?: ((params: Params) => Params) | null;
378
+ /** Set to null to remove encoder */
379
+ encodeParams?: ((params: Params) => Params) | null;
380
+ /** Set to null to remove canActivate */
381
+ canActivate?: GuardFnFactory<Dependencies> | null;
382
+ /** Set to null to remove canDeactivate */
383
+ canDeactivate?: GuardFnFactory<Dependencies> | null;
304
384
  }