@real-router/core 0.40.1 → 0.42.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.
Files changed (77) hide show
  1. package/dist/cjs/Router-B2tmtNiM.d.ts +353 -0
  2. package/dist/cjs/Router-CVNR-dug.js +6 -0
  3. package/dist/cjs/Router-CVNR-dug.js.map +1 -0
  4. package/dist/cjs/RouterError-BkgjTHQg.js +2 -0
  5. package/dist/cjs/RouterError-BkgjTHQg.js.map +1 -0
  6. package/dist/cjs/RouterValidator-TUi8eT8Q.d.ts +112 -0
  7. package/dist/cjs/api.d.ts +17 -12
  8. package/dist/cjs/api.js +2 -1
  9. package/dist/cjs/api.js.map +1 -1
  10. package/dist/cjs/getPluginApi-BXrM_Nwv.js +2 -0
  11. package/dist/cjs/getPluginApi-BXrM_Nwv.js.map +1 -0
  12. package/dist/cjs/index.d.ts +206 -196
  13. package/dist/cjs/index.js +2 -1
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/internals-na15rxo_.js +2 -0
  16. package/dist/cjs/internals-na15rxo_.js.map +1 -0
  17. package/dist/cjs/utils.d.ts +6 -3
  18. package/dist/cjs/utils.js +2 -1
  19. package/dist/cjs/utils.js.map +1 -1
  20. package/dist/cjs/validation.d.ts +153 -152
  21. package/dist/cjs/validation.js +1 -1
  22. package/dist/esm/Router-4JRfQLMM.d.mts +353 -0
  23. package/dist/esm/Router-C_k70gHi.mjs +6 -0
  24. package/dist/esm/Router-C_k70gHi.mjs.map +1 -0
  25. package/dist/esm/RouterError-D0RlQE_5.mjs +2 -0
  26. package/dist/esm/RouterError-D0RlQE_5.mjs.map +1 -0
  27. package/dist/esm/RouterValidator-DphcVMEp.d.mts +112 -0
  28. package/dist/esm/api.d.mts +17 -12
  29. package/dist/esm/api.mjs +2 -1
  30. package/dist/esm/api.mjs.map +1 -1
  31. package/dist/esm/getPluginApi-D0bBPuLp.mjs +2 -0
  32. package/dist/esm/getPluginApi-D0bBPuLp.mjs.map +1 -0
  33. package/dist/esm/index.d.mts +206 -196
  34. package/dist/esm/index.mjs +2 -1
  35. package/dist/esm/index.mjs.map +1 -1
  36. package/dist/esm/internals-CCymabFj.mjs +2 -0
  37. package/dist/{cjs/validation.js.map → esm/internals-CCymabFj.mjs.map} +1 -1
  38. package/dist/esm/utils.d.mts +6 -3
  39. package/dist/esm/utils.mjs +2 -1
  40. package/dist/esm/utils.mjs.map +1 -1
  41. package/dist/esm/validation.d.mts +153 -152
  42. package/dist/esm/validation.mjs +1 -1
  43. package/package.json +5 -7
  44. package/src/Router.ts +4 -6
  45. package/src/api/getPluginApi.ts +2 -3
  46. package/src/helpers.ts +9 -7
  47. package/src/index.ts +0 -1
  48. package/src/internals.ts +4 -5
  49. package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -1
  50. package/src/namespaces/OptionsNamespace/constants.ts +1 -0
  51. package/src/namespaces/OptionsNamespace/helpers.ts +0 -1
  52. package/src/namespaces/RouterLifecycleNamespace/types.ts +1 -3
  53. package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +3 -3
  54. package/src/namespaces/RoutesNamespace/types.ts +2 -2
  55. package/src/namespaces/StateNamespace/StateNamespace.ts +30 -34
  56. package/src/namespaces/StateNamespace/helpers.ts +8 -27
  57. package/src/stateMetaStore.ts +15 -0
  58. package/src/transitionPath.ts +13 -16
  59. package/src/types/RouterValidator.ts +0 -1
  60. package/src/wiring/RouterWiringBuilder.ts +1 -1
  61. package/dist/cjs/Router-B-Pev7K2.d.ts +0 -46
  62. package/dist/cjs/RouterValidator-mx2Zooya.d.ts +0 -136
  63. package/dist/cjs/index.d-y2b-8_3Y.d.ts +0 -236
  64. package/dist/cjs/metafile-cjs.json +0 -1
  65. package/dist/esm/Router-B-Pev7K2.d.mts +0 -46
  66. package/dist/esm/RouterValidator-mx2Zooya.d.mts +0 -136
  67. package/dist/esm/chunk-5QXFUUDL.mjs +0 -1
  68. package/dist/esm/chunk-5QXFUUDL.mjs.map +0 -1
  69. package/dist/esm/chunk-HHIXK5UM.mjs +0 -1
  70. package/dist/esm/chunk-HHIXK5UM.mjs.map +0 -1
  71. package/dist/esm/chunk-MNRZAE7T.mjs +0 -1
  72. package/dist/esm/chunk-MNRZAE7T.mjs.map +0 -1
  73. package/dist/esm/chunk-QUUNDESP.mjs +0 -1
  74. package/dist/esm/chunk-QUUNDESP.mjs.map +0 -1
  75. package/dist/esm/index.d-y2b-8_3Y.d.mts +0 -236
  76. package/dist/esm/metafile-esm.json +0 -1
  77. package/dist/esm/validation.mjs.map +0 -1
@@ -1,12 +1,14 @@
1
- import { L as Limits, R as RouterValidator } from './RouterValidator-mx2Zooya.mjs';
2
- import { DefaultDependencies, Params, ForwardToCallback, GuardFnFactory, State, SimpleState, GuardFn, RouteTreeState, Options, EventName, Plugin, EventMethodMap, Unsubscribe, PluginFactory, Router } from '@real-router/types';
3
- import { a as RouteDefinition, R as RouteTree, M as Matcher, C as CreateMatcherOptions } from './index.d-y2b-8_3Y.mjs';
1
+ import { a as Limits, d as RouteDefinition, f as RouteTree, i as GuardFnFactory, l as CreateMatcherOptions, o as PluginFactory, r as EventMethodMap, u as Matcher } from "./Router-4JRfQLMM.mjs";
2
+ import { t as RouterValidator } from "./RouterValidator-DphcVMEp.mjs";
3
+ import { DefaultDependencies, EventName, ForwardToCallback, GuardFn, Options, Params, Plugin, RouteTreeState, Router, SimpleState, State, Unsubscribe } from "@real-router/types";
4
4
 
5
+ //#region src/namespaces/DependenciesNamespace/dependenciesStore.d.ts
5
6
  interface DependenciesStore<Dependencies extends DefaultDependencies = DefaultDependencies> {
6
- dependencies: Partial<Dependencies>;
7
- limits: Limits;
7
+ dependencies: Partial<Dependencies>;
8
+ limits: Limits;
8
9
  }
9
-
10
+ //#endregion
11
+ //#region src/namespaces/RoutesNamespace/types.d.ts
10
12
  /**
11
13
  * Dependencies injected into RoutesNamespace.
12
14
  *
@@ -14,42 +16,44 @@ interface DependenciesStore<Dependencies extends DefaultDependencies = DefaultDe
14
16
  * avoiding the need to pass the entire Router object.
15
17
  */
16
18
  interface RoutesDependencies<Dependencies extends DefaultDependencies = DefaultDependencies> {
17
- /** Register canActivate handler for a route */
18
- addActivateGuard: (name: string, handler: GuardFnFactory<Dependencies>) => void;
19
- /** Register canDeactivate handler for a route */
20
- addDeactivateGuard: (name: string, handler: GuardFnFactory<Dependencies>) => void;
21
- /** Create state object */
22
- makeState: <P extends Params = Params, MP extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P, MP>;
23
- /** Get current router state */
24
- getState: () => State | undefined;
25
- /** Compare two states for equality */
26
- areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
27
- /** Get a dependency by name */
28
- getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K];
29
- /** Forward state through facade (allows plugin interception) */
30
- forwardState: <P extends Params = Params>(name: string, params: P) => SimpleState<P>;
19
+ /** Register canActivate handler for a route */
20
+ addActivateGuard: (name: string, handler: GuardFnFactory<Dependencies>) => void;
21
+ /** Register canDeactivate handler for a route */
22
+ addDeactivateGuard: (name: string, handler: GuardFnFactory<Dependencies>) => void;
23
+ /** Create state object */
24
+ makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
25
+ /** Get current router state */
26
+ getState: () => State | undefined;
27
+ /** Compare two states for equality */
28
+ areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
29
+ /** Get a dependency by name */
30
+ getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K];
31
+ /** Forward state through facade (allows plugin interception) */
32
+ forwardState: <P extends Params = Params>(name: string, params: P) => SimpleState<P>;
31
33
  }
32
34
  /**
33
35
  * Configuration storage for routes.
34
36
  * Stores decoders, encoders, default params, and forward mappings.
35
37
  */
36
38
  interface RouteConfig {
37
- /** Custom param decoders per route */
38
- decoders: Record<string, (params: Params) => Params>;
39
- /** Custom param encoders per route */
40
- encoders: Record<string, (params: Params) => Params>;
41
- /** Default params per route */
42
- defaultParams: Record<string, Params>;
43
- /** Forward mappings (source -> target) */
44
- forwardMap: Record<string, string>;
45
- /** Dynamic forward callbacks (source -> callback) */
46
- forwardFnMap: Record<string, ForwardToCallback<any>>;
39
+ /** Custom param decoders per route */
40
+ decoders: Record<string, (params: Params) => Params>;
41
+ /** Custom param encoders per route */
42
+ encoders: Record<string, (params: Params) => Params>;
43
+ /** Default params per route */
44
+ defaultParams: Record<string, Params>;
45
+ /** Forward mappings (source -> target) */
46
+ forwardMap: Record<string, string>;
47
+ /** Dynamic forward callbacks (source -> callback) */
48
+ forwardFnMap: Record<string, ForwardToCallback<any>>;
47
49
  }
48
-
50
+ //#endregion
51
+ //#region src/namespaces/RouteLifecycleNamespace/types.d.ts
49
52
  interface RouteLifecycleDependencies<Dependencies extends DefaultDependencies = DefaultDependencies> {
50
- compileFactory: (factory: GuardFnFactory<Dependencies>) => GuardFn;
53
+ compileFactory: (factory: GuardFnFactory<Dependencies>) => GuardFn;
51
54
  }
52
-
55
+ //#endregion
56
+ //#region src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts
53
57
  /**
54
58
  * Independent namespace for managing route lifecycle handlers.
55
59
  *
@@ -57,128 +61,125 @@ interface RouteLifecycleDependencies<Dependencies extends DefaultDependencies =
57
61
  * Instance methods handle state-dependent validation, storage and business logic.
58
62
  */
59
63
  declare class RouteLifecycleNamespace<Dependencies extends DefaultDependencies = DefaultDependencies> {
60
- #private;
61
- setDependencies(deps: RouteLifecycleDependencies<Dependencies>): void;
62
- /**
63
- * Updates handler registration limits (max lifecycle handlers threshold).
64
- *
65
- * @param limits - Limits configuration with maxLifecycleHandlers
66
- */
67
- setLimits(limits: Limits): void;
68
- setValidatorGetter(getter: () => RouterValidator | null): void;
69
- getHandlerCount(type: "activate" | "deactivate"): number;
70
- /**
71
- * Adds a canActivate guard for a route.
72
- * Handles overwrite detection and registration.
73
- *
74
- * @param name - Route name (input-validated by facade)
75
- * @param handler - Guard function or boolean (input-validated by facade)
76
- * @param isFromDefinition - True when guard comes from route definition (tracked for HMR replace)
77
- */
78
- addCanActivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean): void;
79
- /**
80
- * Adds a canDeactivate guard for a route.
81
- * Handles overwrite detection and registration.
82
- *
83
- * @param name - Route name (input-validated by facade)
84
- * @param handler - Guard function or boolean (input-validated by facade)
85
- * @param isFromDefinition - True when guard comes from route definition (tracked for HMR replace)
86
- */
87
- addCanDeactivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean): void;
88
- /**
89
- * Removes a canActivate guard for a route.
90
- * Input already validated by facade (not registering).
91
- *
92
- * @param name - Route name (already validated by facade)
93
- */
94
- clearCanActivate(name: string): void;
95
- /**
96
- * Removes a canDeactivate guard for a route.
97
- * Input already validated by facade (not registering).
98
- *
99
- * @param name - Route name (already validated by facade)
100
- */
101
- clearCanDeactivate(name: string): void;
102
- /**
103
- * Clears all lifecycle handlers (canActivate and canDeactivate).
104
- * Used by clearRoutes to reset all lifecycle state.
105
- */
106
- clearAll(): void;
107
- /**
108
- * Clears only lifecycle handlers that were registered from route definitions.
109
- * Used by HMR to remove definition-sourced guards without touching externally-added guards.
110
- */
111
- clearDefinitionGuards(): void;
112
- /**
113
- * Returns lifecycle factories as records for cloning.
114
- *
115
- * @returns Tuple of [canDeactivateFactories, canActivateFactories]
116
- */
117
- getFactories(): [
118
- Record<string, GuardFnFactory<Dependencies>>,
119
- Record<string, GuardFnFactory<Dependencies>>
120
- ];
121
- /**
122
- * Returns compiled lifecycle functions for transition execution.
123
- *
124
- * @returns Tuple of [canDeactivateFunctions, canActivateFunctions] as Maps
125
- */
126
- getFunctions(): [Map<string, GuardFn>, Map<string, GuardFn>];
127
- canNavigateTo(toDeactivate: string[], toActivate: string[], toState: State, fromState: State | undefined): boolean;
64
+ #private;
65
+ setDependencies(deps: RouteLifecycleDependencies<Dependencies>): void;
66
+ /**
67
+ * Updates handler registration limits (max lifecycle handlers threshold).
68
+ *
69
+ * @param limits - Limits configuration with maxLifecycleHandlers
70
+ */
71
+ setLimits(limits: Limits): void;
72
+ setValidatorGetter(getter: () => RouterValidator | null): void;
73
+ getHandlerCount(type: "activate" | "deactivate"): number;
74
+ /**
75
+ * Adds a canActivate guard for a route.
76
+ * Handles overwrite detection and registration.
77
+ *
78
+ * @param name - Route name (input-validated by facade)
79
+ * @param handler - Guard function or boolean (input-validated by facade)
80
+ * @param isFromDefinition - True when guard comes from route definition (tracked for HMR replace)
81
+ */
82
+ addCanActivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean): void;
83
+ /**
84
+ * Adds a canDeactivate guard for a route.
85
+ * Handles overwrite detection and registration.
86
+ *
87
+ * @param name - Route name (input-validated by facade)
88
+ * @param handler - Guard function or boolean (input-validated by facade)
89
+ * @param isFromDefinition - True when guard comes from route definition (tracked for HMR replace)
90
+ */
91
+ addCanDeactivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean): void;
92
+ /**
93
+ * Removes a canActivate guard for a route.
94
+ * Input already validated by facade (not registering).
95
+ *
96
+ * @param name - Route name (already validated by facade)
97
+ */
98
+ clearCanActivate(name: string): void;
99
+ /**
100
+ * Removes a canDeactivate guard for a route.
101
+ * Input already validated by facade (not registering).
102
+ *
103
+ * @param name - Route name (already validated by facade)
104
+ */
105
+ clearCanDeactivate(name: string): void;
106
+ /**
107
+ * Clears all lifecycle handlers (canActivate and canDeactivate).
108
+ * Used by clearRoutes to reset all lifecycle state.
109
+ */
110
+ clearAll(): void;
111
+ /**
112
+ * Clears only lifecycle handlers that were registered from route definitions.
113
+ * Used by HMR to remove definition-sourced guards without touching externally-added guards.
114
+ */
115
+ clearDefinitionGuards(): void;
116
+ /**
117
+ * Returns lifecycle factories as records for cloning.
118
+ *
119
+ * @returns Tuple of [canDeactivateFactories, canActivateFactories]
120
+ */
121
+ getFactories(): [Record<string, GuardFnFactory<Dependencies>>, Record<string, GuardFnFactory<Dependencies>>];
122
+ /**
123
+ * Returns compiled lifecycle functions for transition execution.
124
+ *
125
+ * @returns Tuple of [canDeactivateFunctions, canActivateFunctions] as Maps
126
+ */
127
+ getFunctions(): [Map<string, GuardFn>, Map<string, GuardFn>];
128
+ canNavigateTo(toDeactivate: string[], toActivate: string[], toState: State, fromState: State | undefined): boolean;
128
129
  }
129
-
130
+ //#endregion
131
+ //#region src/namespaces/RoutesNamespace/routesStore.d.ts
130
132
  interface RoutesStore<Dependencies extends DefaultDependencies = DefaultDependencies> {
131
- readonly definitions: RouteDefinition[];
132
- readonly config: RouteConfig;
133
- tree: RouteTree;
134
- matcher: Matcher;
135
- resolvedForwardMap: Record<string, string>;
136
- routeCustomFields: Record<string, Record<string, unknown>>;
137
- rootPath: string;
138
- readonly matcherOptions: CreateMatcherOptions | undefined;
139
- depsStore: RoutesDependencies<Dependencies> | undefined;
140
- lifecycleNamespace: RouteLifecycleNamespace<Dependencies> | undefined;
141
- readonly pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>;
142
- readonly pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>;
143
- readonly treeOperations: {
144
- readonly commitTreeChanges: (store: RoutesStore<Dependencies>) => void;
145
- readonly resetStore: (store: RoutesStore<Dependencies>) => void;
146
- readonly nodeToDefinition: (node: RouteTree) => RouteDefinition;
147
- };
133
+ readonly definitions: RouteDefinition[];
134
+ readonly config: RouteConfig;
135
+ tree: RouteTree;
136
+ matcher: Matcher;
137
+ resolvedForwardMap: Record<string, string>;
138
+ routeCustomFields: Record<string, Record<string, unknown>>;
139
+ rootPath: string;
140
+ readonly matcherOptions: CreateMatcherOptions | undefined;
141
+ depsStore: RoutesDependencies<Dependencies> | undefined;
142
+ lifecycleNamespace: RouteLifecycleNamespace<Dependencies> | undefined;
143
+ readonly pendingCanActivate: Map<string, GuardFnFactory<Dependencies>>;
144
+ readonly pendingCanDeactivate: Map<string, GuardFnFactory<Dependencies>>;
145
+ readonly treeOperations: {
146
+ readonly commitTreeChanges: (store: RoutesStore<Dependencies>) => void;
147
+ readonly resetStore: (store: RoutesStore<Dependencies>) => void;
148
+ readonly nodeToDefinition: (node: RouteTree) => RouteDefinition;
149
+ };
148
150
  }
149
-
151
+ //#endregion
152
+ //#region src/internals.d.ts
150
153
  interface RouterInternals<D extends DefaultDependencies = DefaultDependencies> {
151
- readonly makeState: <P extends Params = Params, MP extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>, forceId?: number) => State<P, MP>;
152
- readonly forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
153
- readonly buildStateResolved: (resolvedName: string, resolvedParams: Params) => RouteTreeState | undefined;
154
- readonly matchPath: <P extends Params = Params, MP extends Params = Params>(path: string, options?: Options) => State<P, MP> | undefined;
155
- readonly getOptions: () => Options;
156
- readonly addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
157
- readonly buildPath: (route: string, params?: Params) => string;
158
- readonly start: (path: string) => Promise<State>;
159
- readonly interceptors: Map<string, ((next: (...args: any[]) => any, ...args: any[]) => any)[]>;
160
- readonly setRootPath: (rootPath: string) => void;
161
- readonly getRootPath: () => string;
162
- readonly getTree: () => RouteTree;
163
- readonly isDisposed: () => boolean;
164
- validator: RouterValidator | null;
165
- readonly dependenciesGetStore: () => DependenciesStore<D>;
166
- readonly cloneOptions: () => Options;
167
- readonly cloneDependencies: () => Record<string, unknown>;
168
- readonly getLifecycleFactories: () => [
169
- Record<string, GuardFnFactory<D>>,
170
- Record<string, GuardFnFactory<D>>
171
- ];
172
- readonly getPluginFactories: () => PluginFactory<D>[];
173
- readonly routeGetStore: () => RoutesStore<D>;
174
- readonly getStateName: () => string | undefined;
175
- readonly isTransitioning: () => boolean;
176
- readonly clearState: () => void;
177
- readonly setState: (state: State) => void;
178
- readonly routerExtensions: {
179
- keys: string[];
180
- }[];
154
+ readonly makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
155
+ readonly forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
156
+ readonly buildStateResolved: (resolvedName: string, resolvedParams: Params) => RouteTreeState | undefined;
157
+ readonly matchPath: <P extends Params = Params>(path: string, options?: Options) => State<P> | undefined;
158
+ readonly getOptions: () => Options;
159
+ readonly addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
160
+ readonly buildPath: (route: string, params?: Params) => string;
161
+ readonly start: (path: string) => Promise<State>;
162
+ readonly interceptors: Map<string, ((next: (...args: any[]) => any, ...args: any[]) => any)[]>;
163
+ readonly setRootPath: (rootPath: string) => void;
164
+ readonly getRootPath: () => string;
165
+ readonly getTree: () => RouteTree;
166
+ readonly isDisposed: () => boolean;
167
+ validator: RouterValidator | null;
168
+ readonly dependenciesGetStore: () => DependenciesStore<D>;
169
+ readonly cloneOptions: () => Options;
170
+ readonly cloneDependencies: () => Record<string, unknown>;
171
+ readonly getLifecycleFactories: () => [Record<string, GuardFnFactory<D>>, Record<string, GuardFnFactory<D>>];
172
+ readonly getPluginFactories: () => PluginFactory<D>[];
173
+ readonly routeGetStore: () => RoutesStore<D>;
174
+ readonly getStateName: () => string | undefined;
175
+ readonly isTransitioning: () => boolean;
176
+ readonly clearState: () => void;
177
+ readonly setState: (state: State) => void;
178
+ readonly routerExtensions: {
179
+ keys: string[];
180
+ }[];
181
181
  }
182
182
  declare function getInternals<D extends DefaultDependencies>(router: Router<D>): RouterInternals<D>;
183
-
184
- export { type RouterInternals, RouterValidator, getInternals };
183
+ //#endregion
184
+ export { type RouterInternals, type RouterValidator, getInternals };
185
+ //# sourceMappingURL=validation.d.mts.map
@@ -1 +1 @@
1
- export{getInternals}from"./chunk-QUUNDESP.mjs";//# sourceMappingURL=validation.mjs.map
1
+ import{r as e}from"./internals-CCymabFj.mjs";export{e as getInternals};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/core",
3
- "version": "0.40.1",
3
+ "version": "0.42.0",
4
4
  "type": "commonjs",
5
5
  "description": "A simple, powerful, view-agnostic, modular and extensible router",
6
6
  "main": "./dist/cjs/index.js",
@@ -85,20 +85,18 @@
85
85
  "url": "https://github.com/greydragon888/real-router/issues"
86
86
  },
87
87
  "homepage": "https://github.com/greydragon888/real-router",
88
- "sideEffects": [
89
- "./dist/esm/chunk-*.mjs"
90
- ],
88
+ "sideEffects": false,
91
89
  "dependencies": {
92
90
  "@real-router/fsm": "^0.2.2",
93
91
  "@real-router/logger": "^0.2.1",
94
- "@real-router/types": "^0.26.0"
92
+ "@real-router/types": "^0.28.0"
95
93
  },
96
94
  "devDependencies": {
97
95
  "event-emitter": "^0.1.2",
98
96
  "route-tree": "^0.3.4"
99
97
  },
100
98
  "scripts": {
101
- "build": "tsup",
99
+ "build": "tsdown --config-loader unrun",
102
100
  "test": "vitest run functional/",
103
101
  "test:properties": "vitest run --config vitest.config.properties.mts",
104
102
  "test:coverage": "vitest run functional/ --coverage",
@@ -109,6 +107,6 @@
109
107
  "lint": "eslint --cache --ext .ts src/ tests/ --fix --max-warnings 0",
110
108
  "lint:package": "publint",
111
109
  "lint:types": "attw --pack .",
112
- "build:dist-only": "tsup"
110
+ "build:dist-only": "tsdown --config-loader unrun"
113
111
  }
114
112
  }
package/src/Router.ts CHANGED
@@ -189,8 +189,8 @@ export class Router<
189
189
  const interceptorsMap: RouterInternals["interceptors"] = new Map();
190
190
 
191
191
  registerInternals(this, {
192
- makeState: (name, params, path, meta, forceId) =>
193
- this.#state.makeState(name, params, path, meta, forceId),
192
+ makeState: (name, params, path, meta) =>
193
+ this.#state.makeState(name, params, path, meta),
194
194
  forwardState: createInterceptable2(
195
195
  "forwardState",
196
196
  (name: string, params: Params) =>
@@ -345,10 +345,8 @@ export class Router<
345
345
  // State Management (delegated to StateNamespace)
346
346
  // ============================================================================
347
347
 
348
- getState<P extends Params = Params, MP extends Params = Params>():
349
- | State<P, MP>
350
- | undefined {
351
- return this.#state.get<P, MP>();
348
+ getState<P extends Params = Params>(): State<P> | undefined {
349
+ return this.#state.get<P>();
352
350
  }
353
351
 
354
352
  getPreviousState(): State | undefined {
@@ -12,8 +12,8 @@ export function getPluginApi<
12
12
  const ctx = getInternals(router);
13
13
 
14
14
  return {
15
- makeState: (name, params, path, meta, forceId) => {
16
- ctx.validator?.state.validateMakeStateArgs(name, params, path, forceId);
15
+ makeState: (name, params, path, meta) => {
16
+ ctx.validator?.state.validateMakeStateArgs(name, params, path);
17
17
 
18
18
  return ctx.makeState(
19
19
  name,
@@ -22,7 +22,6 @@ export function getPluginApi<
22
22
  meta?.params as
23
23
  | Record<string, Record<string, "url" | "query">>
24
24
  | undefined,
25
- forceId,
26
25
  );
27
26
  },
28
27
  buildState: (routeName, routeParams) => {
package/src/helpers.ts CHANGED
@@ -91,12 +91,15 @@ export function deepFreezeState<T extends State>(state: T): T {
91
91
  // Freeze the object/array itself
92
92
  Object.freeze(obj);
93
93
 
94
- // Get all values to freeze recursively
95
- const values = Array.isArray(obj) ? obj : Object.values(obj);
96
-
97
- // Recursively freeze nested values
98
- for (const value of values) {
99
- freezeClonedRecursive(value);
94
+ // Iterate without Object.values() allocation
95
+ if (Array.isArray(obj)) {
96
+ for (const item of obj) {
97
+ freezeClonedRecursive(item);
98
+ }
99
+ } else {
100
+ for (const key in obj) {
101
+ freezeClonedRecursive((obj as Record<string, unknown>)[key]);
102
+ }
100
103
  }
101
104
  }
102
105
 
@@ -159,7 +162,6 @@ export function freezeStateInPlace<T extends State>(state: T): T {
159
162
  return state;
160
163
  }
161
164
 
162
- // Freeze the entire state tree
163
165
  freezeRecursive(state);
164
166
 
165
167
  // Mark root as processed for future calls
package/src/index.ts CHANGED
@@ -28,7 +28,6 @@ export type {
28
28
  Plugin,
29
29
  SimpleState,
30
30
  State,
31
- StateMeta,
32
31
  SubscribeFn,
33
32
  SubscribeState,
34
33
  Subscription,
package/src/internals.ts CHANGED
@@ -20,13 +20,12 @@ import type { RouteTree } from "route-tree";
20
20
  export interface RouterInternals<
21
21
  D extends DefaultDependencies = DefaultDependencies,
22
22
  > {
23
- readonly makeState: <P extends Params = Params, MP extends Params = Params>(
23
+ readonly makeState: <P extends Params = Params>(
24
24
  name: string,
25
25
  params?: P,
26
26
  path?: string,
27
27
  meta?: Record<string, Record<string, "url" | "query">>,
28
- forceId?: number,
29
- ) => State<P, MP>;
28
+ ) => State<P>;
30
29
 
31
30
  readonly forwardState: <P extends Params = Params>(
32
31
  routeName: string,
@@ -38,10 +37,10 @@ export interface RouterInternals<
38
37
  resolvedParams: Params,
39
38
  ) => RouteTreeState | undefined;
40
39
 
41
- readonly matchPath: <P extends Params = Params, MP extends Params = Params>(
40
+ readonly matchPath: <P extends Params = Params>(
42
41
  path: string,
43
42
  options?: Options,
44
- ) => State<P, MP> | undefined;
43
+ ) => State<P> | undefined;
45
44
 
46
45
  readonly getOptions: () => Options;
47
46
 
@@ -149,7 +149,6 @@ export class NavigationNamespace {
149
149
  const { toDeactivate, toActivate, intersection } = getTransitionPath(
150
150
  toState,
151
151
  fromState,
152
- opts.reload,
153
152
  );
154
153
 
155
154
  const shouldDeactivate =
@@ -14,6 +14,7 @@ export const defaultOptions: Options = {
14
14
  arrayFormat: "none",
15
15
  booleanFormat: "none",
16
16
  nullFormat: "default",
17
+ numberFormat: "none",
17
18
  },
18
19
  urlParamsEncoding: "default",
19
20
  allowNotFound: true,
@@ -35,7 +35,6 @@ export function resolveOption(
35
35
  getDependency: (name: string) => unknown,
36
36
  ): Params;
37
37
 
38
- // eslint-disable-next-line sonarjs/function-return-type -- overloads: string for defaultRoute, Params for defaultParams
39
38
  export function resolveOption(
40
39
  value: Options["defaultRoute"] | Options["defaultParams"],
41
40
  getDependency: (name: string) => unknown,
@@ -16,9 +16,7 @@ export interface RouterLifecycleDependencies {
16
16
  ) => Promise<State>;
17
17
  navigateToNotFound: (path: string) => State;
18
18
  clearState: () => void;
19
- matchPath: <P extends Params = Params, MP extends Params = Params>(
20
- path: string,
21
- ) => State<P, MP> | undefined;
19
+ matchPath: <P extends Params = Params>(path: string) => State<P> | undefined;
22
20
  completeStart: () => void;
23
21
  emitTransitionError: (
24
22
  toState: State | undefined,
@@ -224,10 +224,10 @@ export class RoutesNamespace<
224
224
  * Matches a URL path to a route in the tree.
225
225
  * Note: Argument validation is done by facade (Router.ts) via validateMatchPathArgs.
226
226
  */
227
- matchPath<P extends Params = Params, MP extends Params = Params>(
227
+ matchPath<P extends Params = Params>(
228
228
  path: string,
229
229
  options?: Options,
230
- ): State<P, MP> | undefined {
230
+ ): State<P> | undefined {
231
231
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Router.ts always passes options
232
232
  const opts = options!;
233
233
 
@@ -268,7 +268,7 @@ export class RoutesNamespace<
268
268
  });
269
269
  }
270
270
 
271
- return this.#deps.makeState<P, MP>(routeName, routeParams, builtPath, meta);
271
+ return this.#deps.makeState<P>(routeName, routeParams, builtPath, meta);
272
272
  }
273
273
 
274
274
  /**
@@ -31,12 +31,12 @@ export interface RoutesDependencies<
31
31
  ) => void;
32
32
 
33
33
  /** Create state object */
34
- makeState: <P extends Params = Params, MP extends Params = Params>(
34
+ makeState: <P extends Params = Params>(
35
35
  name: string,
36
36
  params?: P,
37
37
  path?: string,
38
38
  meta?: Record<string, Record<string, "url" | "query">>,
39
- ) => State<P, MP>;
39
+ ) => State<P>;
40
40
 
41
41
  /** Get current router state */
42
42
  getState: () => State | undefined;