@real-router/core 0.44.2 → 0.45.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.
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/package.json +6 -7
- package/src/Router.ts +0 -684
- package/src/RouterError.ts +0 -324
- package/src/api/cloneRouter.ts +0 -77
- package/src/api/getDependenciesApi.ts +0 -168
- package/src/api/getLifecycleApi.ts +0 -65
- package/src/api/getPluginApi.ts +0 -167
- package/src/api/getRoutesApi.ts +0 -562
- 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 -87
- package/src/createRouter.ts +0 -32
- package/src/fsm/index.ts +0 -5
- package/src/fsm/routerFSM.ts +0 -120
- package/src/getNavigator.ts +0 -30
- package/src/guards.ts +0 -46
- package/src/helpers.ts +0 -179
- package/src/index.ts +0 -50
- package/src/internals.ts +0 -173
- package/src/namespaces/DependenciesNamespace/dependenciesStore.ts +0 -30
- package/src/namespaces/DependenciesNamespace/index.ts +0 -5
- package/src/namespaces/EventBusNamespace/EventBusNamespace.ts +0 -311
- package/src/namespaces/EventBusNamespace/index.ts +0 -5
- package/src/namespaces/EventBusNamespace/types.ts +0 -11
- package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -405
- package/src/namespaces/NavigationNamespace/constants.ts +0 -55
- package/src/namespaces/NavigationNamespace/index.ts +0 -5
- package/src/namespaces/NavigationNamespace/transition/completeTransition.ts +0 -100
- package/src/namespaces/NavigationNamespace/transition/errorHandling.ts +0 -124
- package/src/namespaces/NavigationNamespace/transition/guardPhase.ts +0 -221
- package/src/namespaces/NavigationNamespace/types.ts +0 -100
- 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 -377
- 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 -26
- package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +0 -535
- package/src/namespaces/RoutesNamespace/constants.ts +0 -6
- package/src/namespaces/RoutesNamespace/forwardChain.ts +0 -34
- package/src/namespaces/RoutesNamespace/helpers.ts +0 -126
- package/src/namespaces/RoutesNamespace/index.ts +0 -11
- package/src/namespaces/RoutesNamespace/routeGuards.ts +0 -62
- package/src/namespaces/RoutesNamespace/routesStore.ts +0 -346
- package/src/namespaces/RoutesNamespace/types.ts +0 -81
- package/src/namespaces/StateNamespace/StateNamespace.ts +0 -211
- 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 -436
- package/src/typeGuards.ts +0 -59
- package/src/types/RouterValidator.ts +0 -154
- package/src/types.ts +0 -69
- package/src/utils/getStaticPaths.ts +0 -50
- package/src/utils/index.ts +0 -5
- package/src/utils/serializeState.ts +0 -22
- package/src/validation.ts +0 -12
- package/src/wiring/RouterWiringBuilder.ts +0 -261
- package/src/wiring/index.ts +0 -7
- package/src/wiring/types.ts +0 -47
- package/src/wiring/wireRouter.ts +0 -26
package/src/api/getPluginApi.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { throwIfDisposed } from "./helpers";
|
|
2
|
-
import { errorCodes } from "../constants";
|
|
3
|
-
import { getInternals } from "../internals";
|
|
4
|
-
import { RouterError } from "../RouterError";
|
|
5
|
-
|
|
6
|
-
import type { PluginApi } from "./types";
|
|
7
|
-
import type { DefaultDependencies, Params, Router } from "@real-router/types";
|
|
8
|
-
|
|
9
|
-
export function getPluginApi<
|
|
10
|
-
Dependencies extends DefaultDependencies = DefaultDependencies,
|
|
11
|
-
>(router: Router<Dependencies>): PluginApi {
|
|
12
|
-
const ctx = getInternals(router);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
makeState: (name, params, path, meta) => {
|
|
16
|
-
ctx.validator?.state.validateMakeStateArgs(name, params, path);
|
|
17
|
-
|
|
18
|
-
return ctx.makeState(
|
|
19
|
-
name,
|
|
20
|
-
params,
|
|
21
|
-
path,
|
|
22
|
-
meta?.params as
|
|
23
|
-
| Record<string, Record<string, "url" | "query">>
|
|
24
|
-
| undefined,
|
|
25
|
-
);
|
|
26
|
-
},
|
|
27
|
-
buildState: (routeName, routeParams) => {
|
|
28
|
-
ctx.validator?.routes.validateStateBuilderArgs(
|
|
29
|
-
routeName,
|
|
30
|
-
routeParams,
|
|
31
|
-
"buildState",
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const { name, params } = ctx.forwardState(routeName, routeParams);
|
|
35
|
-
|
|
36
|
-
return ctx.buildStateResolved(name, params);
|
|
37
|
-
},
|
|
38
|
-
forwardState: <P extends Params = Params>(
|
|
39
|
-
routeName: string,
|
|
40
|
-
routeParams: P,
|
|
41
|
-
) => {
|
|
42
|
-
ctx.validator?.routes.validateStateBuilderArgs(
|
|
43
|
-
routeName,
|
|
44
|
-
routeParams,
|
|
45
|
-
"forwardState",
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return ctx.forwardState(routeName, routeParams);
|
|
49
|
-
},
|
|
50
|
-
matchPath: (path) => {
|
|
51
|
-
ctx.validator?.routes.validateMatchPathArgs(path);
|
|
52
|
-
|
|
53
|
-
return ctx.matchPath(path, ctx.getOptions());
|
|
54
|
-
},
|
|
55
|
-
setRootPath: (rootPath) => {
|
|
56
|
-
throwIfDisposed(ctx.isDisposed);
|
|
57
|
-
|
|
58
|
-
ctx.validator?.routes.validateSetRootPathArgs(rootPath);
|
|
59
|
-
|
|
60
|
-
ctx.setRootPath(rootPath);
|
|
61
|
-
},
|
|
62
|
-
getRootPath: ctx.getRootPath,
|
|
63
|
-
addEventListener: (eventName, cb) => {
|
|
64
|
-
throwIfDisposed(ctx.isDisposed);
|
|
65
|
-
|
|
66
|
-
ctx.validator?.eventBus.validateListenerArgs(eventName, cb);
|
|
67
|
-
|
|
68
|
-
return ctx.addEventListener(eventName, cb);
|
|
69
|
-
},
|
|
70
|
-
buildNavigationState: (name, params = {}) => {
|
|
71
|
-
ctx.validator?.routes.validateStateBuilderArgs(
|
|
72
|
-
name,
|
|
73
|
-
params,
|
|
74
|
-
"buildNavigationState",
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const { name: resolvedName, params: resolvedParams } = ctx.forwardState(
|
|
78
|
-
name,
|
|
79
|
-
params,
|
|
80
|
-
);
|
|
81
|
-
const routeInfo = ctx.buildStateResolved(resolvedName, resolvedParams);
|
|
82
|
-
|
|
83
|
-
if (!routeInfo) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return ctx.makeState(
|
|
88
|
-
routeInfo.name,
|
|
89
|
-
routeInfo.params,
|
|
90
|
-
ctx.buildPath(routeInfo.name, routeInfo.params),
|
|
91
|
-
routeInfo.meta,
|
|
92
|
-
);
|
|
93
|
-
},
|
|
94
|
-
getOptions: ctx.getOptions,
|
|
95
|
-
getTree: ctx.getTree,
|
|
96
|
-
addInterceptor: (method, fn) => {
|
|
97
|
-
throwIfDisposed(ctx.isDisposed);
|
|
98
|
-
ctx.validator?.plugins.validateAddInterceptorArgs(method, fn);
|
|
99
|
-
let list = ctx.interceptors.get(method);
|
|
100
|
-
|
|
101
|
-
if (!list) {
|
|
102
|
-
list = [];
|
|
103
|
-
ctx.interceptors.set(method, list);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
list.push(fn);
|
|
107
|
-
|
|
108
|
-
return () => {
|
|
109
|
-
const index = list.indexOf(fn);
|
|
110
|
-
|
|
111
|
-
if (index !== -1) {
|
|
112
|
-
list.splice(index, 1);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
getRouteConfig: (name) => {
|
|
117
|
-
const store = ctx.routeGetStore();
|
|
118
|
-
|
|
119
|
-
if (!store.matcher.hasRoute(name)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return store.routeCustomFields[name];
|
|
124
|
-
},
|
|
125
|
-
extendRouter: (extensions: Record<string, unknown>) => {
|
|
126
|
-
throwIfDisposed(ctx.isDisposed);
|
|
127
|
-
|
|
128
|
-
const keys = Object.keys(extensions);
|
|
129
|
-
|
|
130
|
-
for (const key of keys) {
|
|
131
|
-
if (key in router) {
|
|
132
|
-
throw new RouterError(errorCodes.PLUGIN_CONFLICT, {
|
|
133
|
-
message: `Cannot extend router: property "${key}" already exists`,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (const key of keys) {
|
|
139
|
-
(router as Record<string, unknown>)[key] = extensions[key];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const extensionRecord = { keys };
|
|
143
|
-
|
|
144
|
-
ctx.routerExtensions.push(extensionRecord);
|
|
145
|
-
|
|
146
|
-
let removed = false;
|
|
147
|
-
|
|
148
|
-
return () => {
|
|
149
|
-
if (removed) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
removed = true;
|
|
154
|
-
|
|
155
|
-
for (const key of extensionRecord.keys) {
|
|
156
|
-
delete (router as Record<string, unknown>)[key];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const idx = ctx.routerExtensions.indexOf(extensionRecord);
|
|
160
|
-
|
|
161
|
-
if (idx !== -1) {
|
|
162
|
-
ctx.routerExtensions.splice(idx, 1);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|