@real-router/core 0.56.0 → 0.57.1

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 (112) hide show
  1. package/dist/cjs/Router-Brp6_4FE.js +6 -0
  2. package/dist/cjs/Router-Brp6_4FE.js.map +1 -0
  3. package/dist/cjs/api.d.ts +1 -1
  4. package/dist/cjs/api.js +1 -1
  5. package/dist/cjs/{cloneRouter-DRieJvam.js → cloneRouter-CZx0T0RQ.js} +2 -2
  6. package/dist/cjs/{cloneRouter-DRieJvam.js.map → cloneRouter-CZx0T0RQ.js.map} +1 -1
  7. package/dist/cjs/{index-C-i6vx5Y.d.ts → index-BWUmnecT.d.ts} +1 -2
  8. package/dist/cjs/index-BWUmnecT.d.ts.map +1 -0
  9. package/dist/cjs/index-CYpAZCoc.d.ts.map +1 -1
  10. package/dist/cjs/index.d.ts +1 -1
  11. package/dist/cjs/index.js +1 -1
  12. package/dist/cjs/utils.js +1 -1
  13. package/dist/cjs/utils.js.map +1 -1
  14. package/dist/cjs/validation.d.ts +1 -1
  15. package/dist/esm/Router-LT61erYH.mjs +6 -0
  16. package/dist/esm/Router-LT61erYH.mjs.map +1 -0
  17. package/dist/esm/api.d.mts +1 -1
  18. package/dist/esm/api.mjs +1 -1
  19. package/dist/esm/{cloneRouter-DHrH6D_z.mjs → cloneRouter-DAscsmmF.mjs} +2 -2
  20. package/dist/esm/{cloneRouter-DHrH6D_z.mjs.map → cloneRouter-DAscsmmF.mjs.map} +1 -1
  21. package/dist/esm/{index-C-i6vx5Y.d.mts → index-BWUmnecT.d.mts} +1 -2
  22. package/dist/esm/index-BWUmnecT.d.mts.map +1 -0
  23. package/dist/esm/index-CYpAZCoc.d.mts.map +1 -1
  24. package/dist/esm/index.d.mts +1 -1
  25. package/dist/esm/index.mjs +1 -1
  26. package/dist/esm/utils.mjs +1 -1
  27. package/dist/esm/utils.mjs.map +1 -1
  28. package/dist/esm/validation.d.mts +1 -1
  29. package/package.json +4 -5
  30. package/dist/cjs/Router-IEGavTKk.js +0 -6
  31. package/dist/cjs/Router-IEGavTKk.js.map +0 -1
  32. package/dist/cjs/index-C-i6vx5Y.d.ts.map +0 -1
  33. package/dist/esm/Router-B3aeavRb.mjs +0 -6
  34. package/dist/esm/Router-B3aeavRb.mjs.map +0 -1
  35. package/dist/esm/index-C-i6vx5Y.d.mts.map +0 -1
  36. package/src/Router.ts +0 -737
  37. package/src/RouterError.ts +0 -324
  38. package/src/api/cloneRouter.ts +0 -159
  39. package/src/api/getDependenciesApi.ts +0 -160
  40. package/src/api/getLifecycleApi.ts +0 -65
  41. package/src/api/getPluginApi.ts +0 -228
  42. package/src/api/getRoutesApi.ts +0 -831
  43. package/src/api/helpers.ts +0 -10
  44. package/src/api/index.ts +0 -16
  45. package/src/api/types.ts +0 -12
  46. package/src/constants.ts +0 -101
  47. package/src/createRouter.ts +0 -32
  48. package/src/fsm/index.ts +0 -5
  49. package/src/fsm/routerFSM.ts +0 -130
  50. package/src/getNavigator.ts +0 -30
  51. package/src/guards.ts +0 -46
  52. package/src/helpers.ts +0 -197
  53. package/src/index.ts +0 -66
  54. package/src/internals.ts +0 -228
  55. package/src/namespaces/DependenciesNamespace/dependenciesStore.ts +0 -30
  56. package/src/namespaces/DependenciesNamespace/index.ts +0 -5
  57. package/src/namespaces/EventBusNamespace/EventBusNamespace.ts +0 -522
  58. package/src/namespaces/EventBusNamespace/index.ts +0 -5
  59. package/src/namespaces/EventBusNamespace/types.ts +0 -11
  60. package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -552
  61. package/src/namespaces/NavigationNamespace/constants.ts +0 -55
  62. package/src/namespaces/NavigationNamespace/index.ts +0 -5
  63. package/src/namespaces/NavigationNamespace/transition/completeTransition.ts +0 -108
  64. package/src/namespaces/NavigationNamespace/transition/errorHandling.ts +0 -124
  65. package/src/namespaces/NavigationNamespace/transition/guardPhase.ts +0 -283
  66. package/src/namespaces/NavigationNamespace/types.ts +0 -110
  67. package/src/namespaces/OptionsNamespace/OptionsNamespace.ts +0 -28
  68. package/src/namespaces/OptionsNamespace/constants.ts +0 -19
  69. package/src/namespaces/OptionsNamespace/helpers.ts +0 -50
  70. package/src/namespaces/OptionsNamespace/index.ts +0 -7
  71. package/src/namespaces/OptionsNamespace/validators.ts +0 -13
  72. package/src/namespaces/PluginsNamespace/PluginsNamespace.ts +0 -291
  73. package/src/namespaces/PluginsNamespace/constants.ts +0 -34
  74. package/src/namespaces/PluginsNamespace/index.ts +0 -7
  75. package/src/namespaces/PluginsNamespace/types.ts +0 -22
  76. package/src/namespaces/PluginsNamespace/validators.ts +0 -28
  77. package/src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts +0 -558
  78. package/src/namespaces/RouteLifecycleNamespace/index.ts +0 -5
  79. package/src/namespaces/RouteLifecycleNamespace/types.ts +0 -10
  80. package/src/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.ts +0 -81
  81. package/src/namespaces/RouterLifecycleNamespace/constants.ts +0 -25
  82. package/src/namespaces/RouterLifecycleNamespace/index.ts +0 -5
  83. package/src/namespaces/RouterLifecycleNamespace/types.ts +0 -30
  84. package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +0 -582
  85. package/src/namespaces/RoutesNamespace/constants.ts +0 -6
  86. package/src/namespaces/RoutesNamespace/forwardChain.ts +0 -34
  87. package/src/namespaces/RoutesNamespace/helpers.ts +0 -204
  88. package/src/namespaces/RoutesNamespace/index.ts +0 -11
  89. package/src/namespaces/RoutesNamespace/routeGuards.ts +0 -62
  90. package/src/namespaces/RoutesNamespace/routesStore.ts +0 -566
  91. package/src/namespaces/RoutesNamespace/types.ts +0 -81
  92. package/src/namespaces/StateNamespace/StateNamespace.ts +0 -224
  93. package/src/namespaces/StateNamespace/helpers.ts +0 -24
  94. package/src/namespaces/StateNamespace/index.ts +0 -5
  95. package/src/namespaces/StateNamespace/types.ts +0 -15
  96. package/src/namespaces/index.ts +0 -35
  97. package/src/stateMetaStore.ts +0 -15
  98. package/src/transitionPath.ts +0 -440
  99. package/src/typeGuards.ts +0 -59
  100. package/src/types/RouterValidator.ts +0 -156
  101. package/src/types.ts +0 -77
  102. package/src/utils/createRequestScope.ts +0 -174
  103. package/src/utils/getStaticPaths.ts +0 -50
  104. package/src/utils/hydrateRouter.ts +0 -89
  105. package/src/utils/index.ts +0 -27
  106. package/src/utils/serializeRouterState.ts +0 -120
  107. package/src/utils/serializeState.ts +0 -63
  108. package/src/validation.ts +0 -12
  109. package/src/wiring/RouterWiringBuilder.ts +0 -275
  110. package/src/wiring/index.ts +0 -7
  111. package/src/wiring/types.ts +0 -47
  112. package/src/wiring/wireRouter.ts +0 -26
package/src/internals.ts DELETED
@@ -1,228 +0,0 @@
1
- import type { DependenciesStore } from "./namespaces";
2
- import type { RoutesStore } from "./namespaces/RoutesNamespace";
3
- import type { Router as RouterClass } from "./Router";
4
- import type { EventMethodMap, GuardFnFactory, PluginFactory } from "./types";
5
- import type { RouterValidator } from "./types/RouterValidator";
6
- import type { SerializedRouterState } from "./utils";
7
- import type {
8
- DefaultDependencies,
9
- EventName,
10
- NavigationOptions,
11
- Options,
12
- Params,
13
- Plugin,
14
- Router as RouterInterface,
15
- RouteTreeState,
16
- SimpleState,
17
- State,
18
- TreeChangedEvent,
19
- Unsubscribe,
20
- } from "@real-router/types";
21
- import type { RouteTree } from "route-tree";
22
-
23
- export interface RouterInternals<
24
- D extends DefaultDependencies = DefaultDependencies,
25
- > {
26
- readonly makeState: <P extends Params = Params>(
27
- name: string,
28
- params?: P,
29
- path?: string,
30
- meta?: Record<string, Record<string, "url" | "query">>,
31
- ) => State<P>;
32
-
33
- readonly forwardState: <P extends Params = Params>(
34
- routeName: string,
35
- routeParams: P,
36
- ) => SimpleState<P>;
37
-
38
- readonly buildStateResolved: (
39
- resolvedName: string,
40
- resolvedParams: Params,
41
- ) => RouteTreeState | undefined;
42
-
43
- readonly matchPath: <P extends Params = Params>(
44
- path: string,
45
- options?: Options,
46
- ) => State<P> | undefined;
47
-
48
- readonly getOptions: () => Options;
49
-
50
- readonly addEventListener: <E extends EventName>(
51
- eventName: E,
52
- cb: Plugin[EventMethodMap[E]],
53
- ) => Unsubscribe;
54
-
55
- /**
56
- * Route-tree mutation channel — internal access for the `getRoutesApi`
57
- * wrapper. A dedicated bridge is required because the public
58
- * `addEventListener<E extends EventName>` structurally rejects
59
- * `"TREE_CHANGED"` (it is not in the public `EventName` union), is strict on
60
- * duplicates, and exposes neither `emit` nor `listenerCount`.
61
- */
62
- readonly treeChanged: {
63
- readonly emit: (event: TreeChangedEvent) => void;
64
- readonly subscribe: (
65
- handler: (event: TreeChangedEvent) => void,
66
- ) => Unsubscribe;
67
- readonly listenerCount: () => number;
68
- };
69
-
70
- readonly buildPath: (route: string, params?: Params) => string;
71
-
72
- readonly emitTransitionError: (error: Error) => void;
73
-
74
- readonly start: (path: string) => Promise<State>;
75
-
76
- /**
77
- * Plugin-only navigation entry point — delegates to
78
- * `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).
79
- * Hidden from `Router`/`Navigator` to keep the userland surface minimal;
80
- * see `core-types/src/api.ts` for usage docs.
81
- */
82
- readonly navigateToState: (
83
- state: State,
84
- options?: NavigationOptions,
85
- ) => Promise<State>;
86
-
87
- /* eslint-disable @typescript-eslint/no-explicit-any -- heterogeneous map: stores different InterceptorFn<M> types under different keys */
88
- readonly interceptors: Map<
89
- string,
90
- ((next: (...args: any[]) => any, ...args: any[]) => any)[]
91
- >;
92
- /* eslint-enable @typescript-eslint/no-explicit-any */
93
-
94
- readonly setRootPath: (rootPath: string) => void;
95
- readonly getRootPath: () => string;
96
-
97
- readonly getTree: () => RouteTree;
98
-
99
- readonly isDisposed: () => boolean;
100
-
101
- validator: RouterValidator | null;
102
-
103
- // Dependencies (issue #172)
104
- readonly dependenciesGetStore: () => DependenciesStore<D>;
105
-
106
- // Clone support (issue #173)
107
- readonly cloneOptions: () => Options;
108
- readonly cloneDependencies: () => Record<string, unknown>;
109
- readonly getLifecycleFactories: () => [
110
- Record<string, GuardFnFactory<D>>,
111
- Record<string, GuardFnFactory<D>>,
112
- ];
113
- readonly getPluginFactories: () => PluginFactory<D>[];
114
-
115
- // Consolidated route data store (issue #174 Phase 2)
116
- readonly routeGetStore: () => RoutesStore<D>;
117
-
118
- // Cross-namespace state (issue #174)
119
- readonly getStateName: () => string | undefined;
120
- readonly isTransitioning: () => boolean;
121
- readonly clearState: () => void;
122
- readonly setState: (state: State) => void;
123
- readonly routerExtensions: { keys: string[] }[];
124
- readonly contextClaimRecords: Set<string>;
125
-
126
- /**
127
- * One-shot hydration scratchpad populated by `hydrateRouter` immediately
128
- * before delegating to `router.start(parsed.path)` and cleared in the
129
- * matching `finally`. SSR loader plugins read this slot directly via
130
- * `getInternals(router).hydrationState` to short-circuit their own loader
131
- * call when the server-resolved namespace value is already present in the
132
- * parsed state (#596). `null` outside of an active `hydrateRouter`
133
- * invocation.
134
- */
135
- hydrationState: SerializedRouterState | null;
136
- }
137
-
138
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- existential type: stores RouterInternals for all Dependencies types
139
- const internals = new WeakMap<object, RouterInternals<any>>();
140
-
141
- export function getInternals<D extends DefaultDependencies>(
142
- router: RouterInterface<D>,
143
- ): RouterInternals<D> {
144
- const ctx = internals.get(router);
145
-
146
- if (!ctx) {
147
- throw new TypeError(
148
- "[real-router] Invalid router instance — not found in internals registry",
149
- );
150
- }
151
-
152
- return ctx as RouterInternals<D>;
153
- }
154
-
155
- export function registerInternals<D extends DefaultDependencies>(
156
- router: RouterClass<D>,
157
- ctx: RouterInternals<D>,
158
- ): void {
159
- internals.set(router, ctx);
160
- }
161
-
162
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument -- internal chain execution: type safety enforced at public API boundary (PluginApi.addInterceptor) */
163
- function executeInterceptorChain<T>(
164
- interceptors: ((next: (...args: any[]) => any, ...args: any[]) => any)[],
165
- original: (...args: any[]) => T,
166
- args: any[],
167
- ): T {
168
- let chain = original as (...args: any[]) => any;
169
-
170
- for (const interceptor of interceptors) {
171
- const prev = chain;
172
-
173
- chain = (...chainArgs: any[]) => interceptor(prev, ...chainArgs);
174
- }
175
-
176
- return chain(...args) as T;
177
- }
178
-
179
- /**
180
- * Variadic interceptor wrapper — wraps a function of any arity, returning the
181
- * same callable type `T`. Use {@link createBinaryInterceptable} instead when the
182
- * wrapped method takes exactly two args and the caller needs the precise
183
- * `(a, b) => r` signature preserved (the variadic form widens args to `any[]`).
184
- */
185
- export function createInterceptable<T extends (...args: any[]) => any>(
186
- name: string,
187
- original: T,
188
- interceptors: Map<
189
- string,
190
- ((next: (...args: any[]) => any, ...args: any[]) => any)[]
191
- >,
192
- ): T {
193
- return ((...args: any[]) => {
194
- const chain = interceptors.get(name);
195
-
196
- if (!chain || chain.length === 0) {
197
- return original(...args);
198
- }
199
-
200
- return executeInterceptorChain(chain, original, args);
201
- }) as T;
202
- }
203
-
204
- /**
205
- * Two-argument interceptor wrapper — preserves the exact `(a: A, b: B) => R`
206
- * signature, which the variadic {@link createInterceptable} cannot express
207
- * (it widens args to `any[]`). Used for the binary interceptable methods
208
- * `forwardState(routeName, routeParams)` and `buildPath(route, params)`.
209
- */
210
- export function createBinaryInterceptable<A, B, R>(
211
- name: string,
212
- original: (a: A, b: B) => R,
213
- interceptors: Map<
214
- string,
215
- ((next: (...args: any[]) => any, ...args: any[]) => any)[]
216
- >,
217
- ): (a: A, b: B) => R {
218
- return (arg1: A, arg2: B) => {
219
- const chain = interceptors.get(name);
220
-
221
- if (!chain || chain.length === 0) {
222
- return original(arg1, arg2);
223
- }
224
-
225
- return executeInterceptorChain(chain, original, [arg1, arg2]);
226
- };
227
- }
228
- /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */
@@ -1,30 +0,0 @@
1
- import { DEFAULT_LIMITS } from "../../constants";
2
-
3
- import type { Limits } from "../../types";
4
- import type { DefaultDependencies } from "@real-router/types";
5
-
6
- export interface DependenciesStore<
7
- Dependencies extends DefaultDependencies = DefaultDependencies,
8
- > {
9
- dependencies: Partial<Dependencies>;
10
- limits: Limits;
11
- }
12
-
13
- export function createDependenciesStore<
14
- Dependencies extends DefaultDependencies = DefaultDependencies,
15
- >(
16
- initialDependencies: Partial<Dependencies> = {},
17
- ): DependenciesStore<Dependencies> {
18
- const dependencies = Object.create(null) as Partial<Dependencies>;
19
-
20
- for (const key in initialDependencies) {
21
- if (initialDependencies[key] !== undefined) {
22
- dependencies[key] = initialDependencies[key];
23
- }
24
- }
25
-
26
- return {
27
- dependencies,
28
- limits: DEFAULT_LIMITS,
29
- };
30
- }
@@ -1,5 +0,0 @@
1
- // packages/core/src/namespaces/DependenciesNamespace/index.ts
2
-
3
- export { createDependenciesStore } from "./dependenciesStore";
4
-
5
- export type { DependenciesStore } from "./dependenciesStore";