@real-router/core 0.56.0 → 0.57.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.
- package/dist/cjs/Router-BSGzVINO.js +6 -0
- package/dist/cjs/Router-BSGzVINO.js.map +1 -0
- package/dist/cjs/api.d.ts +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/{cloneRouter-DRieJvam.js → cloneRouter-7z-60z_f.js} +2 -2
- package/dist/cjs/{cloneRouter-DRieJvam.js.map → cloneRouter-7z-60z_f.js.map} +1 -1
- package/dist/cjs/{index-C-i6vx5Y.d.ts → index-BWUmnecT.d.ts} +1 -2
- package/dist/cjs/index-BWUmnecT.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.d.ts +1 -1
- package/dist/esm/Router-B7txWo9N.mjs +6 -0
- package/dist/esm/Router-B7txWo9N.mjs.map +1 -0
- package/dist/esm/api.d.mts +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/{cloneRouter-DHrH6D_z.mjs → cloneRouter-BNCQ7tIa.mjs} +2 -2
- package/dist/esm/{cloneRouter-DHrH6D_z.mjs.map → cloneRouter-BNCQ7tIa.mjs.map} +1 -1
- package/dist/esm/{index-C-i6vx5Y.d.mts → index-BWUmnecT.d.mts} +1 -2
- package/dist/esm/index-BWUmnecT.d.mts.map +1 -0
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +1 -1
- package/package.json +2 -3
- package/dist/cjs/Router-IEGavTKk.js +0 -6
- package/dist/cjs/Router-IEGavTKk.js.map +0 -1
- package/dist/cjs/index-C-i6vx5Y.d.ts.map +0 -1
- package/dist/esm/Router-B3aeavRb.mjs +0 -6
- package/dist/esm/Router-B3aeavRb.mjs.map +0 -1
- package/dist/esm/index-C-i6vx5Y.d.mts.map +0 -1
- package/src/Router.ts +0 -737
- package/src/RouterError.ts +0 -324
- package/src/api/cloneRouter.ts +0 -159
- package/src/api/getDependenciesApi.ts +0 -160
- package/src/api/getLifecycleApi.ts +0 -65
- package/src/api/getPluginApi.ts +0 -228
- package/src/api/getRoutesApi.ts +0 -831
- package/src/api/helpers.ts +0 -10
- package/src/api/index.ts +0 -16
- package/src/api/types.ts +0 -12
- package/src/constants.ts +0 -101
- package/src/createRouter.ts +0 -32
- package/src/fsm/index.ts +0 -5
- package/src/fsm/routerFSM.ts +0 -130
- package/src/getNavigator.ts +0 -30
- package/src/guards.ts +0 -46
- package/src/helpers.ts +0 -197
- package/src/index.ts +0 -66
- package/src/internals.ts +0 -228
- package/src/namespaces/DependenciesNamespace/dependenciesStore.ts +0 -30
- package/src/namespaces/DependenciesNamespace/index.ts +0 -5
- package/src/namespaces/EventBusNamespace/EventBusNamespace.ts +0 -522
- package/src/namespaces/EventBusNamespace/index.ts +0 -5
- package/src/namespaces/EventBusNamespace/types.ts +0 -11
- package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -552
- package/src/namespaces/NavigationNamespace/constants.ts +0 -55
- package/src/namespaces/NavigationNamespace/index.ts +0 -5
- package/src/namespaces/NavigationNamespace/transition/completeTransition.ts +0 -108
- package/src/namespaces/NavigationNamespace/transition/errorHandling.ts +0 -124
- package/src/namespaces/NavigationNamespace/transition/guardPhase.ts +0 -283
- package/src/namespaces/NavigationNamespace/types.ts +0 -110
- package/src/namespaces/OptionsNamespace/OptionsNamespace.ts +0 -28
- package/src/namespaces/OptionsNamespace/constants.ts +0 -19
- package/src/namespaces/OptionsNamespace/helpers.ts +0 -50
- package/src/namespaces/OptionsNamespace/index.ts +0 -7
- package/src/namespaces/OptionsNamespace/validators.ts +0 -13
- package/src/namespaces/PluginsNamespace/PluginsNamespace.ts +0 -291
- package/src/namespaces/PluginsNamespace/constants.ts +0 -34
- package/src/namespaces/PluginsNamespace/index.ts +0 -7
- package/src/namespaces/PluginsNamespace/types.ts +0 -22
- package/src/namespaces/PluginsNamespace/validators.ts +0 -28
- package/src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts +0 -558
- package/src/namespaces/RouteLifecycleNamespace/index.ts +0 -5
- package/src/namespaces/RouteLifecycleNamespace/types.ts +0 -10
- package/src/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.ts +0 -81
- package/src/namespaces/RouterLifecycleNamespace/constants.ts +0 -25
- package/src/namespaces/RouterLifecycleNamespace/index.ts +0 -5
- package/src/namespaces/RouterLifecycleNamespace/types.ts +0 -30
- package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +0 -582
- package/src/namespaces/RoutesNamespace/constants.ts +0 -6
- package/src/namespaces/RoutesNamespace/forwardChain.ts +0 -34
- package/src/namespaces/RoutesNamespace/helpers.ts +0 -204
- package/src/namespaces/RoutesNamespace/index.ts +0 -11
- package/src/namespaces/RoutesNamespace/routeGuards.ts +0 -62
- package/src/namespaces/RoutesNamespace/routesStore.ts +0 -566
- package/src/namespaces/RoutesNamespace/types.ts +0 -81
- package/src/namespaces/StateNamespace/StateNamespace.ts +0 -224
- package/src/namespaces/StateNamespace/helpers.ts +0 -24
- package/src/namespaces/StateNamespace/index.ts +0 -5
- package/src/namespaces/StateNamespace/types.ts +0 -15
- package/src/namespaces/index.ts +0 -35
- package/src/stateMetaStore.ts +0 -15
- package/src/transitionPath.ts +0 -440
- package/src/typeGuards.ts +0 -59
- package/src/types/RouterValidator.ts +0 -156
- package/src/types.ts +0 -77
- package/src/utils/createRequestScope.ts +0 -174
- package/src/utils/getStaticPaths.ts +0 -50
- package/src/utils/hydrateRouter.ts +0 -89
- package/src/utils/index.ts +0 -27
- package/src/utils/serializeRouterState.ts +0 -120
- package/src/utils/serializeState.ts +0 -63
- package/src/validation.ts +0 -12
- package/src/wiring/RouterWiringBuilder.ts +0 -275
- package/src/wiring/index.ts +0 -7
- package/src/wiring/types.ts +0 -47
- 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
|
-
}
|