reactive-route 0.0.1-alpha.3 → 0.0.1-alpha.5
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/adapters/mobx/index.js +42 -0
- package/dist/cjs/adapters/mobx/package.json +1 -0
- package/dist/cjs/adapters/solid/index.js +47 -0
- package/dist/cjs/adapters/solid/package.json +1 -0
- package/dist/cjs/index.js +56 -60
- package/dist/cjs/react/index.js +6 -6
- package/dist/cjs/solid/index.js +7 -7
- package/dist/esm/adapters/mobx/index.js +21 -0
- package/dist/esm/adapters/mobx/package.json +1 -0
- package/dist/esm/adapters/solid/index.js +26 -0
- package/dist/esm/adapters/solid/package.json +1 -0
- package/dist/esm/index.js +56 -60
- package/dist/esm/react/index.js +6 -6
- package/dist/esm/solid/index.js +7 -7
- package/dist/types/adapters/mobx.d.ts +3 -0
- package/dist/types/adapters/mobx.d.ts.map +1 -0
- package/dist/types/adapters/solid.d.ts +3 -0
- package/dist/types/adapters/solid.d.ts.map +1 -0
- package/dist/types/core/createRouterStore.d.ts +1 -1
- package/dist/types/core/createRouterStore.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/types/InterfaceRouterStore.d.ts +9 -5
- package/dist/types/core/types/InterfaceRouterStore.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +17 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/adapters/mobx.ts
|
|
21
|
+
var mobx_exports = {};
|
|
22
|
+
__export(mobx_exports, {
|
|
23
|
+
adapters: () => adapters
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(mobx_exports);
|
|
26
|
+
var import_mobx = require("mobx");
|
|
27
|
+
var adapters = {
|
|
28
|
+
batch: import_mobx.runInAction,
|
|
29
|
+
autorun: import_mobx.autorun,
|
|
30
|
+
replaceObject: (obj, newObj) => {
|
|
31
|
+
(0, import_mobx.runInAction)(() => {
|
|
32
|
+
for (const variableKey in obj) {
|
|
33
|
+
if (obj.hasOwnProperty(variableKey)) {
|
|
34
|
+
delete obj[variableKey];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
Object.assign(obj, newObj);
|
|
38
|
+
});
|
|
39
|
+
return obj;
|
|
40
|
+
},
|
|
41
|
+
makeObservable: import_mobx.observable
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/adapters/solid.ts
|
|
21
|
+
var solid_exports = {};
|
|
22
|
+
__export(solid_exports, {
|
|
23
|
+
adapters: () => adapters
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(solid_exports);
|
|
26
|
+
var import_solid_js = require("solid-js");
|
|
27
|
+
var import_store = require("solid-js/store");
|
|
28
|
+
var adapters = {
|
|
29
|
+
batch: import_solid_js.batch,
|
|
30
|
+
autorun: import_solid_js.createRenderEffect,
|
|
31
|
+
replaceObject: (obj, newObj) => {
|
|
32
|
+
(0, import_store.modifyMutable)(
|
|
33
|
+
obj,
|
|
34
|
+
(0, import_store.produce)((state) => {
|
|
35
|
+
if (typeof state === "object" && state != null) {
|
|
36
|
+
for (const variableKey in state) {
|
|
37
|
+
if (state.hasOwnProperty(variableKey)) {
|
|
38
|
+
delete state[variableKey];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
Object.assign(state || {}, newObj);
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
makeObservable: import_store.createMutable
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -90,6 +90,37 @@ function getDynamicValues(params) {
|
|
|
90
90
|
return dynamicParams;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// packages/core/utils/findRouteByPathname.ts
|
|
94
|
+
function completeStaticMatch(pathname, path) {
|
|
95
|
+
return !path.includes(constants.dynamicSeparator) && (pathname === path || pathname === `${path}${constants.pathPartSeparator}`);
|
|
96
|
+
}
|
|
97
|
+
function findRouteByPathname({
|
|
98
|
+
pathname,
|
|
99
|
+
routes
|
|
100
|
+
}) {
|
|
101
|
+
let dynamicRouteMatch;
|
|
102
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split(constants.pathPartSeparator).filter(Boolean);
|
|
103
|
+
for (const routeName in routes) {
|
|
104
|
+
if (!Object.hasOwn(routes, routeName)) continue;
|
|
105
|
+
const route = routes[routeName];
|
|
106
|
+
if (completeStaticMatch(pathname, route.path)) return route;
|
|
107
|
+
if (dynamicRouteMatch) continue;
|
|
108
|
+
const routePathnameArray = route.path.split(constants.pathPartSeparator).filter(Boolean);
|
|
109
|
+
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
110
|
+
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
111
|
+
const paramFromUrl = pathnameArray[i];
|
|
112
|
+
if (!isDynamic(paramName)) return paramName !== paramFromUrl;
|
|
113
|
+
const validator = route.params?.[clearDynamic(paramName)];
|
|
114
|
+
if (typeof validator !== "function") {
|
|
115
|
+
throw new Error(`findRoute: missing validator for param "${paramName}"`);
|
|
116
|
+
}
|
|
117
|
+
return !validator(paramFromUrl);
|
|
118
|
+
});
|
|
119
|
+
if (!someParamInvalid) dynamicRouteMatch = route;
|
|
120
|
+
}
|
|
121
|
+
return dynamicRouteMatch;
|
|
122
|
+
}
|
|
123
|
+
|
|
93
124
|
// packages/core/utils/getQueryValues.ts
|
|
94
125
|
var import_query_string = __toESM(require("query-string"));
|
|
95
126
|
|
|
@@ -111,6 +142,16 @@ function getQueryValues(params) {
|
|
|
111
142
|
return query;
|
|
112
143
|
}
|
|
113
144
|
|
|
145
|
+
// packages/core/utils/getInitialRoute.ts
|
|
146
|
+
function getInitialRoute(params) {
|
|
147
|
+
const route = findRouteByPathname({ pathname: params.pathname, routes: params.routes }) || params.routes[params.fallback];
|
|
148
|
+
return {
|
|
149
|
+
route: route.name,
|
|
150
|
+
query: getQueryValues({ route, pathname: params.pathname }),
|
|
151
|
+
params: getDynamicValues({ route, pathname: params.pathname })
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
114
155
|
// packages/core/utils/history.ts
|
|
115
156
|
var import_history = require("history");
|
|
116
157
|
var history = constants.isClient ? (0, import_history.createBrowserHistory)() : null;
|
|
@@ -150,29 +191,22 @@ function replaceDynamicValues({
|
|
|
150
191
|
|
|
151
192
|
// packages/core/createRouterStore.ts
|
|
152
193
|
function createRouterStore({
|
|
153
|
-
|
|
194
|
+
adapters,
|
|
154
195
|
routes,
|
|
155
|
-
autorun,
|
|
156
|
-
replaceObject,
|
|
157
196
|
routeError500,
|
|
158
|
-
makeObservable,
|
|
159
197
|
lifecycleParams
|
|
160
198
|
}) {
|
|
161
|
-
const routerStore = makeObservable({
|
|
199
|
+
const routerStore = adapters.makeObservable({
|
|
162
200
|
routesHistory: [],
|
|
163
201
|
currentRoute: {},
|
|
164
202
|
isRedirecting: false,
|
|
165
203
|
redirectTo: void 0,
|
|
204
|
+
restoreFromURL: void 0,
|
|
166
205
|
restoreFromServer: void 0,
|
|
167
|
-
|
|
168
|
-
batch,
|
|
169
|
-
autorun,
|
|
170
|
-
replaceObject,
|
|
171
|
-
makeObservable
|
|
172
|
-
}
|
|
206
|
+
adapters
|
|
173
207
|
});
|
|
174
208
|
routerStore.restoreFromServer = function restoreFromServer(obj) {
|
|
175
|
-
batch(() => {
|
|
209
|
+
adapters.batch(() => {
|
|
176
210
|
routerStore.routesHistory.push(...obj.routesHistory || []);
|
|
177
211
|
Object.assign(routerStore.currentRoute, obj.currentRoute);
|
|
178
212
|
});
|
|
@@ -181,6 +215,9 @@ function createRouterStore({
|
|
|
181
215
|
);
|
|
182
216
|
return loadComponentToConfig({ route: routes[preloadedRouteName] });
|
|
183
217
|
};
|
|
218
|
+
routerStore.restoreFromURL = function restoreFromURL(params) {
|
|
219
|
+
return routerStore.redirectTo(getInitialRoute({ routes, ...params }));
|
|
220
|
+
};
|
|
184
221
|
routerStore.redirectTo = async function redirectTo(config) {
|
|
185
222
|
const { route: routeName, noHistoryPush, asClient } = config;
|
|
186
223
|
const isClient = typeof asClient === "boolean" ? asClient : constants.isClient;
|
|
@@ -224,8 +261,8 @@ function createRouterStore({
|
|
|
224
261
|
if (currentUrl === nextUrl) return Promise.resolve();
|
|
225
262
|
if (currentPathname === nextPathname) {
|
|
226
263
|
if (currentSearch !== nextSearch) {
|
|
227
|
-
batch(() => {
|
|
228
|
-
replaceObject(routerStore.currentRoute.query, nextQuery || {});
|
|
264
|
+
adapters.batch(() => {
|
|
265
|
+
adapters.replaceObject(routerStore.currentRoute.query, nextQuery || {});
|
|
229
266
|
routerStore.routesHistory.push(nextUrl);
|
|
230
267
|
});
|
|
231
268
|
if (history && !noHistoryPush) {
|
|
@@ -238,7 +275,7 @@ function createRouterStore({
|
|
|
238
275
|
}
|
|
239
276
|
return Promise.resolve();
|
|
240
277
|
}
|
|
241
|
-
batch(() => {
|
|
278
|
+
adapters.batch(() => {
|
|
242
279
|
routerStore.isRedirecting = true;
|
|
243
280
|
});
|
|
244
281
|
try {
|
|
@@ -299,8 +336,8 @@ function createRouterStore({
|
|
|
299
336
|
}
|
|
300
337
|
console.error(error);
|
|
301
338
|
await loadComponentToConfig({ route: routeError500 });
|
|
302
|
-
batch(() => {
|
|
303
|
-
replaceObject(routerStore.currentRoute, {
|
|
339
|
+
adapters.batch(() => {
|
|
340
|
+
adapters.replaceObject(routerStore.currentRoute, {
|
|
304
341
|
name: routeError500.name,
|
|
305
342
|
path: routeError500.path,
|
|
306
343
|
props: routes[routeError500.name].props,
|
|
@@ -312,8 +349,8 @@ function createRouterStore({
|
|
|
312
349
|
});
|
|
313
350
|
return Promise.resolve();
|
|
314
351
|
}
|
|
315
|
-
batch(() => {
|
|
316
|
-
replaceObject(routerStore.currentRoute, {
|
|
352
|
+
adapters.batch(() => {
|
|
353
|
+
adapters.replaceObject(routerStore.currentRoute, {
|
|
317
354
|
name: nextRoute.name,
|
|
318
355
|
path: nextRoute.path,
|
|
319
356
|
props: routes[nextRoute.name].props,
|
|
@@ -338,44 +375,3 @@ function createRouterStore({
|
|
|
338
375
|
};
|
|
339
376
|
return routerStore;
|
|
340
377
|
}
|
|
341
|
-
|
|
342
|
-
// packages/core/utils/findRouteByPathname.ts
|
|
343
|
-
function completeStaticMatch(pathname, path) {
|
|
344
|
-
return !path.includes(constants.dynamicSeparator) && (pathname === path || pathname === `${path}${constants.pathPartSeparator}`);
|
|
345
|
-
}
|
|
346
|
-
function findRouteByPathname({
|
|
347
|
-
pathname,
|
|
348
|
-
routes
|
|
349
|
-
}) {
|
|
350
|
-
let dynamicRouteMatch;
|
|
351
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(constants.pathPartSeparator).filter(Boolean);
|
|
352
|
-
for (const routeName in routes) {
|
|
353
|
-
if (!Object.hasOwn(routes, routeName)) continue;
|
|
354
|
-
const route = routes[routeName];
|
|
355
|
-
if (completeStaticMatch(pathname, route.path)) return route;
|
|
356
|
-
if (dynamicRouteMatch) continue;
|
|
357
|
-
const routePathnameArray = route.path.split(constants.pathPartSeparator).filter(Boolean);
|
|
358
|
-
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
359
|
-
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
360
|
-
const paramFromUrl = pathnameArray[i];
|
|
361
|
-
if (!isDynamic(paramName)) return paramName !== paramFromUrl;
|
|
362
|
-
const validator = route.params?.[clearDynamic(paramName)];
|
|
363
|
-
if (typeof validator !== "function") {
|
|
364
|
-
throw new Error(`findRoute: missing validator for param "${paramName}"`);
|
|
365
|
-
}
|
|
366
|
-
return !validator(paramFromUrl);
|
|
367
|
-
});
|
|
368
|
-
if (!someParamInvalid) dynamicRouteMatch = route;
|
|
369
|
-
}
|
|
370
|
-
return dynamicRouteMatch;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// packages/core/utils/getInitialRoute.ts
|
|
374
|
-
function getInitialRoute(params) {
|
|
375
|
-
const route = findRouteByPathname({ pathname: params.pathname, routes: params.routes }) || params.routes[params.fallback];
|
|
376
|
-
return {
|
|
377
|
-
route: route.name,
|
|
378
|
-
query: getQueryValues({ route, pathname: params.pathname }),
|
|
379
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
380
|
-
};
|
|
381
|
-
}
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -75,14 +75,14 @@ var VM = class {
|
|
|
75
75
|
loadedComponentPage = void 0;
|
|
76
76
|
loadedComponent;
|
|
77
77
|
currentProps = {};
|
|
78
|
-
get
|
|
79
|
-
return this.props.routerStore.
|
|
78
|
+
get adapters() {
|
|
79
|
+
return this.props.routerStore.adapters;
|
|
80
80
|
}
|
|
81
81
|
beforeMount() {
|
|
82
82
|
this.props.beforeMount?.();
|
|
83
83
|
this.redirectOnHistoryPop();
|
|
84
84
|
this.setLoadedComponent();
|
|
85
|
-
this.autorunDisposers.push(this.
|
|
85
|
+
this.autorunDisposers.push(this.adapters.autorun(this.setLoadedComponent));
|
|
86
86
|
}
|
|
87
87
|
redirectOnHistoryPop() {
|
|
88
88
|
if (!import_reactive_route.history) return;
|
|
@@ -90,7 +90,7 @@ var VM = class {
|
|
|
90
90
|
if (params.action !== "POP") return;
|
|
91
91
|
const previousRoutePathname = this.props.routerStore.routesHistory[this.props.routerStore.routesHistory.length - 2];
|
|
92
92
|
if (previousRoutePathname === params.location.pathname) {
|
|
93
|
-
this.
|
|
93
|
+
this.adapters.batch(() => this.props.routerStore.routesHistory.pop());
|
|
94
94
|
}
|
|
95
95
|
void this.props.routerStore.redirectTo({
|
|
96
96
|
noHistoryPush: true,
|
|
@@ -113,14 +113,14 @@ var VM = class {
|
|
|
113
113
|
else if (loadedComponentPage != null && currentRouteName != null) {
|
|
114
114
|
if (loadedComponentPage === currentRoutePage) {
|
|
115
115
|
const componentConfig = this.props.routes[currentRouteName];
|
|
116
|
-
this.
|
|
116
|
+
this.adapters.batch(() => {
|
|
117
117
|
this.currentProps = "props" in componentConfig ? componentConfig.props || {} : {};
|
|
118
118
|
});
|
|
119
119
|
preventRedirect = true;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
if (preventRedirect) return;
|
|
123
|
-
this.
|
|
123
|
+
this.adapters.batch(() => {
|
|
124
124
|
if (!loadedComponentName) {
|
|
125
125
|
this.setComponent(currentRouteName);
|
|
126
126
|
} else {
|
package/dist/cjs/solid/index.js
CHANGED
|
@@ -52,13 +52,13 @@ var VM = class {
|
|
|
52
52
|
loadedComponentName = void 0;
|
|
53
53
|
loadedComponentPage = void 0;
|
|
54
54
|
currentProps = {};
|
|
55
|
-
get
|
|
56
|
-
return this.props.routerStore.
|
|
55
|
+
get adapters() {
|
|
56
|
+
return this.props.routerStore.adapters;
|
|
57
57
|
}
|
|
58
58
|
beforeMount() {
|
|
59
59
|
this.props.beforeMount?.();
|
|
60
60
|
this.redirectOnHistoryPop();
|
|
61
|
-
this.
|
|
61
|
+
this.adapters.autorun(() => this.setLoadedComponent());
|
|
62
62
|
}
|
|
63
63
|
redirectOnHistoryPop() {
|
|
64
64
|
if (!import_reactive_route.history) return;
|
|
@@ -88,12 +88,12 @@ var VM = class {
|
|
|
88
88
|
} else if (this.loadedComponentPage != null && currentRouteName != null) {
|
|
89
89
|
if (this.loadedComponentPage === currentRoutePage) {
|
|
90
90
|
const componentConfig = this.props.routes[currentRouteName];
|
|
91
|
-
this.
|
|
91
|
+
this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
|
|
92
92
|
preventRedirect = true;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
if (preventRedirect) return;
|
|
96
|
-
this.
|
|
96
|
+
this.adapters.batch(() => {
|
|
97
97
|
if (!this.loadedComponentName) {
|
|
98
98
|
this.setComponent();
|
|
99
99
|
} else {
|
|
@@ -106,8 +106,8 @@ var VM = class {
|
|
|
106
106
|
const currentRouteName = this.props.routerStore.currentRoute.name;
|
|
107
107
|
const componentConfig = this.props.routes[currentRouteName];
|
|
108
108
|
this.props.beforeSetPageComponent?.(componentConfig);
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
109
|
+
this.adapters.batch(() => {
|
|
110
|
+
this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
|
|
111
111
|
this.loadedComponentName = currentRouteName;
|
|
112
112
|
this.loadedComponentPage = componentConfig.pageName;
|
|
113
113
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/adapters/mobx.ts
|
|
2
|
+
import { autorun, observable, runInAction } from "mobx";
|
|
3
|
+
var adapters = {
|
|
4
|
+
batch: runInAction,
|
|
5
|
+
autorun,
|
|
6
|
+
replaceObject: (obj, newObj) => {
|
|
7
|
+
runInAction(() => {
|
|
8
|
+
for (const variableKey in obj) {
|
|
9
|
+
if (obj.hasOwnProperty(variableKey)) {
|
|
10
|
+
delete obj[variableKey];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
Object.assign(obj, newObj);
|
|
14
|
+
});
|
|
15
|
+
return obj;
|
|
16
|
+
},
|
|
17
|
+
makeObservable: observable
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
adapters
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// packages/adapters/solid.ts
|
|
2
|
+
import { batch, createRenderEffect } from "solid-js";
|
|
3
|
+
import { createMutable, modifyMutable, produce } from "solid-js/store";
|
|
4
|
+
var adapters = {
|
|
5
|
+
batch,
|
|
6
|
+
autorun: createRenderEffect,
|
|
7
|
+
replaceObject: (obj, newObj) => {
|
|
8
|
+
modifyMutable(
|
|
9
|
+
obj,
|
|
10
|
+
produce((state) => {
|
|
11
|
+
if (typeof state === "object" && state != null) {
|
|
12
|
+
for (const variableKey in state) {
|
|
13
|
+
if (state.hasOwnProperty(variableKey)) {
|
|
14
|
+
delete state[variableKey];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
Object.assign(state || {}, newObj);
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
makeObservable: createMutable
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
adapters
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
package/dist/esm/index.js
CHANGED
|
@@ -47,6 +47,37 @@ function getDynamicValues(params) {
|
|
|
47
47
|
return dynamicParams;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// packages/core/utils/findRouteByPathname.ts
|
|
51
|
+
function completeStaticMatch(pathname, path) {
|
|
52
|
+
return !path.includes(constants.dynamicSeparator) && (pathname === path || pathname === `${path}${constants.pathPartSeparator}`);
|
|
53
|
+
}
|
|
54
|
+
function findRouteByPathname({
|
|
55
|
+
pathname,
|
|
56
|
+
routes
|
|
57
|
+
}) {
|
|
58
|
+
let dynamicRouteMatch;
|
|
59
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split(constants.pathPartSeparator).filter(Boolean);
|
|
60
|
+
for (const routeName in routes) {
|
|
61
|
+
if (!Object.hasOwn(routes, routeName)) continue;
|
|
62
|
+
const route = routes[routeName];
|
|
63
|
+
if (completeStaticMatch(pathname, route.path)) return route;
|
|
64
|
+
if (dynamicRouteMatch) continue;
|
|
65
|
+
const routePathnameArray = route.path.split(constants.pathPartSeparator).filter(Boolean);
|
|
66
|
+
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
67
|
+
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
68
|
+
const paramFromUrl = pathnameArray[i];
|
|
69
|
+
if (!isDynamic(paramName)) return paramName !== paramFromUrl;
|
|
70
|
+
const validator = route.params?.[clearDynamic(paramName)];
|
|
71
|
+
if (typeof validator !== "function") {
|
|
72
|
+
throw new Error(`findRoute: missing validator for param "${paramName}"`);
|
|
73
|
+
}
|
|
74
|
+
return !validator(paramFromUrl);
|
|
75
|
+
});
|
|
76
|
+
if (!someParamInvalid) dynamicRouteMatch = route;
|
|
77
|
+
}
|
|
78
|
+
return dynamicRouteMatch;
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
// packages/core/utils/getQueryValues.ts
|
|
51
82
|
import queryString from "query-string";
|
|
52
83
|
|
|
@@ -68,6 +99,16 @@ function getQueryValues(params) {
|
|
|
68
99
|
return query;
|
|
69
100
|
}
|
|
70
101
|
|
|
102
|
+
// packages/core/utils/getInitialRoute.ts
|
|
103
|
+
function getInitialRoute(params) {
|
|
104
|
+
const route = findRouteByPathname({ pathname: params.pathname, routes: params.routes }) || params.routes[params.fallback];
|
|
105
|
+
return {
|
|
106
|
+
route: route.name,
|
|
107
|
+
query: getQueryValues({ route, pathname: params.pathname }),
|
|
108
|
+
params: getDynamicValues({ route, pathname: params.pathname })
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
71
112
|
// packages/core/utils/history.ts
|
|
72
113
|
import { createBrowserHistory } from "history";
|
|
73
114
|
var history = constants.isClient ? createBrowserHistory() : null;
|
|
@@ -107,29 +148,22 @@ function replaceDynamicValues({
|
|
|
107
148
|
|
|
108
149
|
// packages/core/createRouterStore.ts
|
|
109
150
|
function createRouterStore({
|
|
110
|
-
|
|
151
|
+
adapters,
|
|
111
152
|
routes,
|
|
112
|
-
autorun,
|
|
113
|
-
replaceObject,
|
|
114
153
|
routeError500,
|
|
115
|
-
makeObservable,
|
|
116
154
|
lifecycleParams
|
|
117
155
|
}) {
|
|
118
|
-
const routerStore = makeObservable({
|
|
156
|
+
const routerStore = adapters.makeObservable({
|
|
119
157
|
routesHistory: [],
|
|
120
158
|
currentRoute: {},
|
|
121
159
|
isRedirecting: false,
|
|
122
160
|
redirectTo: void 0,
|
|
161
|
+
restoreFromURL: void 0,
|
|
123
162
|
restoreFromServer: void 0,
|
|
124
|
-
|
|
125
|
-
batch,
|
|
126
|
-
autorun,
|
|
127
|
-
replaceObject,
|
|
128
|
-
makeObservable
|
|
129
|
-
}
|
|
163
|
+
adapters
|
|
130
164
|
});
|
|
131
165
|
routerStore.restoreFromServer = function restoreFromServer(obj) {
|
|
132
|
-
batch(() => {
|
|
166
|
+
adapters.batch(() => {
|
|
133
167
|
routerStore.routesHistory.push(...obj.routesHistory || []);
|
|
134
168
|
Object.assign(routerStore.currentRoute, obj.currentRoute);
|
|
135
169
|
});
|
|
@@ -138,6 +172,9 @@ function createRouterStore({
|
|
|
138
172
|
);
|
|
139
173
|
return loadComponentToConfig({ route: routes[preloadedRouteName] });
|
|
140
174
|
};
|
|
175
|
+
routerStore.restoreFromURL = function restoreFromURL(params) {
|
|
176
|
+
return routerStore.redirectTo(getInitialRoute({ routes, ...params }));
|
|
177
|
+
};
|
|
141
178
|
routerStore.redirectTo = async function redirectTo(config) {
|
|
142
179
|
const { route: routeName, noHistoryPush, asClient } = config;
|
|
143
180
|
const isClient = typeof asClient === "boolean" ? asClient : constants.isClient;
|
|
@@ -181,8 +218,8 @@ function createRouterStore({
|
|
|
181
218
|
if (currentUrl === nextUrl) return Promise.resolve();
|
|
182
219
|
if (currentPathname === nextPathname) {
|
|
183
220
|
if (currentSearch !== nextSearch) {
|
|
184
|
-
batch(() => {
|
|
185
|
-
replaceObject(routerStore.currentRoute.query, nextQuery || {});
|
|
221
|
+
adapters.batch(() => {
|
|
222
|
+
adapters.replaceObject(routerStore.currentRoute.query, nextQuery || {});
|
|
186
223
|
routerStore.routesHistory.push(nextUrl);
|
|
187
224
|
});
|
|
188
225
|
if (history && !noHistoryPush) {
|
|
@@ -195,7 +232,7 @@ function createRouterStore({
|
|
|
195
232
|
}
|
|
196
233
|
return Promise.resolve();
|
|
197
234
|
}
|
|
198
|
-
batch(() => {
|
|
235
|
+
adapters.batch(() => {
|
|
199
236
|
routerStore.isRedirecting = true;
|
|
200
237
|
});
|
|
201
238
|
try {
|
|
@@ -256,8 +293,8 @@ function createRouterStore({
|
|
|
256
293
|
}
|
|
257
294
|
console.error(error);
|
|
258
295
|
await loadComponentToConfig({ route: routeError500 });
|
|
259
|
-
batch(() => {
|
|
260
|
-
replaceObject(routerStore.currentRoute, {
|
|
296
|
+
adapters.batch(() => {
|
|
297
|
+
adapters.replaceObject(routerStore.currentRoute, {
|
|
261
298
|
name: routeError500.name,
|
|
262
299
|
path: routeError500.path,
|
|
263
300
|
props: routes[routeError500.name].props,
|
|
@@ -269,8 +306,8 @@ function createRouterStore({
|
|
|
269
306
|
});
|
|
270
307
|
return Promise.resolve();
|
|
271
308
|
}
|
|
272
|
-
batch(() => {
|
|
273
|
-
replaceObject(routerStore.currentRoute, {
|
|
309
|
+
adapters.batch(() => {
|
|
310
|
+
adapters.replaceObject(routerStore.currentRoute, {
|
|
274
311
|
name: nextRoute.name,
|
|
275
312
|
path: nextRoute.path,
|
|
276
313
|
props: routes[nextRoute.name].props,
|
|
@@ -295,47 +332,6 @@ function createRouterStore({
|
|
|
295
332
|
};
|
|
296
333
|
return routerStore;
|
|
297
334
|
}
|
|
298
|
-
|
|
299
|
-
// packages/core/utils/findRouteByPathname.ts
|
|
300
|
-
function completeStaticMatch(pathname, path) {
|
|
301
|
-
return !path.includes(constants.dynamicSeparator) && (pathname === path || pathname === `${path}${constants.pathPartSeparator}`);
|
|
302
|
-
}
|
|
303
|
-
function findRouteByPathname({
|
|
304
|
-
pathname,
|
|
305
|
-
routes
|
|
306
|
-
}) {
|
|
307
|
-
let dynamicRouteMatch;
|
|
308
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(constants.pathPartSeparator).filter(Boolean);
|
|
309
|
-
for (const routeName in routes) {
|
|
310
|
-
if (!Object.hasOwn(routes, routeName)) continue;
|
|
311
|
-
const route = routes[routeName];
|
|
312
|
-
if (completeStaticMatch(pathname, route.path)) return route;
|
|
313
|
-
if (dynamicRouteMatch) continue;
|
|
314
|
-
const routePathnameArray = route.path.split(constants.pathPartSeparator).filter(Boolean);
|
|
315
|
-
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
316
|
-
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
317
|
-
const paramFromUrl = pathnameArray[i];
|
|
318
|
-
if (!isDynamic(paramName)) return paramName !== paramFromUrl;
|
|
319
|
-
const validator = route.params?.[clearDynamic(paramName)];
|
|
320
|
-
if (typeof validator !== "function") {
|
|
321
|
-
throw new Error(`findRoute: missing validator for param "${paramName}"`);
|
|
322
|
-
}
|
|
323
|
-
return !validator(paramFromUrl);
|
|
324
|
-
});
|
|
325
|
-
if (!someParamInvalid) dynamicRouteMatch = route;
|
|
326
|
-
}
|
|
327
|
-
return dynamicRouteMatch;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// packages/core/utils/getInitialRoute.ts
|
|
331
|
-
function getInitialRoute(params) {
|
|
332
|
-
const route = findRouteByPathname({ pathname: params.pathname, routes: params.routes }) || params.routes[params.fallback];
|
|
333
|
-
return {
|
|
334
|
-
route: route.name,
|
|
335
|
-
query: getQueryValues({ route, pathname: params.pathname }),
|
|
336
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
335
|
export {
|
|
340
336
|
createRouterConfig,
|
|
341
337
|
createRouterStore,
|
package/dist/esm/react/index.js
CHANGED
|
@@ -49,14 +49,14 @@ var VM = class {
|
|
|
49
49
|
loadedComponentPage = void 0;
|
|
50
50
|
loadedComponent;
|
|
51
51
|
currentProps = {};
|
|
52
|
-
get
|
|
53
|
-
return this.props.routerStore.
|
|
52
|
+
get adapters() {
|
|
53
|
+
return this.props.routerStore.adapters;
|
|
54
54
|
}
|
|
55
55
|
beforeMount() {
|
|
56
56
|
this.props.beforeMount?.();
|
|
57
57
|
this.redirectOnHistoryPop();
|
|
58
58
|
this.setLoadedComponent();
|
|
59
|
-
this.autorunDisposers.push(this.
|
|
59
|
+
this.autorunDisposers.push(this.adapters.autorun(this.setLoadedComponent));
|
|
60
60
|
}
|
|
61
61
|
redirectOnHistoryPop() {
|
|
62
62
|
if (!history) return;
|
|
@@ -64,7 +64,7 @@ var VM = class {
|
|
|
64
64
|
if (params.action !== "POP") return;
|
|
65
65
|
const previousRoutePathname = this.props.routerStore.routesHistory[this.props.routerStore.routesHistory.length - 2];
|
|
66
66
|
if (previousRoutePathname === params.location.pathname) {
|
|
67
|
-
this.
|
|
67
|
+
this.adapters.batch(() => this.props.routerStore.routesHistory.pop());
|
|
68
68
|
}
|
|
69
69
|
void this.props.routerStore.redirectTo({
|
|
70
70
|
noHistoryPush: true,
|
|
@@ -87,14 +87,14 @@ var VM = class {
|
|
|
87
87
|
else if (loadedComponentPage != null && currentRouteName != null) {
|
|
88
88
|
if (loadedComponentPage === currentRoutePage) {
|
|
89
89
|
const componentConfig = this.props.routes[currentRouteName];
|
|
90
|
-
this.
|
|
90
|
+
this.adapters.batch(() => {
|
|
91
91
|
this.currentProps = "props" in componentConfig ? componentConfig.props || {} : {};
|
|
92
92
|
});
|
|
93
93
|
preventRedirect = true;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
if (preventRedirect) return;
|
|
97
|
-
this.
|
|
97
|
+
this.adapters.batch(() => {
|
|
98
98
|
if (!loadedComponentName) {
|
|
99
99
|
this.setComponent(currentRouteName);
|
|
100
100
|
} else {
|
package/dist/esm/solid/index.js
CHANGED
|
@@ -26,13 +26,13 @@ var VM = class {
|
|
|
26
26
|
loadedComponentName = void 0;
|
|
27
27
|
loadedComponentPage = void 0;
|
|
28
28
|
currentProps = {};
|
|
29
|
-
get
|
|
30
|
-
return this.props.routerStore.
|
|
29
|
+
get adapters() {
|
|
30
|
+
return this.props.routerStore.adapters;
|
|
31
31
|
}
|
|
32
32
|
beforeMount() {
|
|
33
33
|
this.props.beforeMount?.();
|
|
34
34
|
this.redirectOnHistoryPop();
|
|
35
|
-
this.
|
|
35
|
+
this.adapters.autorun(() => this.setLoadedComponent());
|
|
36
36
|
}
|
|
37
37
|
redirectOnHistoryPop() {
|
|
38
38
|
if (!history) return;
|
|
@@ -62,12 +62,12 @@ var VM = class {
|
|
|
62
62
|
} else if (this.loadedComponentPage != null && currentRouteName != null) {
|
|
63
63
|
if (this.loadedComponentPage === currentRoutePage) {
|
|
64
64
|
const componentConfig = this.props.routes[currentRouteName];
|
|
65
|
-
this.
|
|
65
|
+
this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
|
|
66
66
|
preventRedirect = true;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
if (preventRedirect) return;
|
|
70
|
-
this.
|
|
70
|
+
this.adapters.batch(() => {
|
|
71
71
|
if (!this.loadedComponentName) {
|
|
72
72
|
this.setComponent();
|
|
73
73
|
} else {
|
|
@@ -80,8 +80,8 @@ var VM = class {
|
|
|
80
80
|
const currentRouteName = this.props.routerStore.currentRoute.name;
|
|
81
81
|
const componentConfig = this.props.routes[currentRouteName];
|
|
82
82
|
this.props.beforeSetPageComponent?.(componentConfig);
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
83
|
+
this.adapters.batch(() => {
|
|
84
|
+
this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
|
|
85
85
|
this.loadedComponentName = currentRouteName;
|
|
86
86
|
this.loadedComponentPage = componentConfig.pageName;
|
|
87
87
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobx.d.ts","sourceRoot":"","sources":["../../../packages/adapters/mobx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,YAgBtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../../../packages/adapters/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,eAAO,MAAM,QAAQ,EAAE,YAoBtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { InterfaceRouterStore, TypeCreateRouterStore } from './types/InterfaceRouterStore';
|
|
2
2
|
import { TypeRoute } from './types/TypeRoute';
|
|
3
|
-
export declare function createRouterStore<TRoutes extends Record<string, TypeRoute>>({
|
|
3
|
+
export declare function createRouterStore<TRoutes extends Record<string, TypeRoute>>({ adapters, routes, routeError500, lifecycleParams, }: TypeCreateRouterStore<TRoutes>): InterfaceRouterStore<TRoutes>;
|
|
4
4
|
//# sourceMappingURL=createRouterStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouterStore.d.ts","sourceRoot":"","sources":["../../../packages/core/createRouterStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"createRouterStore.d.ts","sourceRoot":"","sources":["../../../packages/core/createRouterStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAS9C,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAC3E,QAAQ,EACR,MAAM,EACN,aAAa,EACb,eAAe,GAChB,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CA0PhE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createRouterConfig } from './createRouterConfig';
|
|
2
2
|
export { createRouterStore } from './createRouterStore';
|
|
3
|
-
export type { InterfaceRouterStore } from './types/InterfaceRouterStore';
|
|
3
|
+
export type { InterfaceRouterStore, TypeAdapters } from './types/InterfaceRouterStore';
|
|
4
4
|
export type { TypeCurrentRoute } from './types/TypeCurrentRoute';
|
|
5
5
|
export type { TypePropsRouter } from './types/TypePropsRouter';
|
|
6
6
|
export type { TypeRedirectToParams } from './types/TypeRedirectToParams';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACvF,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { TypeCurrentRoute } from './TypeCurrentRoute';
|
|
2
2
|
import { TypeRedirectToParams } from './TypeRedirectToParams';
|
|
3
3
|
import { TypeRoute } from './TypeRoute';
|
|
4
|
-
type
|
|
4
|
+
export type TypeAdapters = {
|
|
5
5
|
batch: (cb: () => void) => void;
|
|
6
6
|
autorun: (cb: () => void) => any;
|
|
7
7
|
replaceObject: <TObj extends Record<string, any>>(obj: TObj, newObj: TObj) => void;
|
|
8
8
|
makeObservable: <TObj extends Record<string, any>>(obj: TObj) => TObj;
|
|
9
9
|
};
|
|
10
|
-
export type TypeCreateRouterStore<TRoutes extends Record<string, TypeRoute>> =
|
|
10
|
+
export type TypeCreateRouterStore<TRoutes extends Record<string, TypeRoute>> = {
|
|
11
11
|
routes: TRoutes;
|
|
12
12
|
routeError500: TRoutes[keyof TRoutes];
|
|
13
13
|
lifecycleParams?: Array<any>;
|
|
14
|
+
adapters: TypeAdapters;
|
|
14
15
|
};
|
|
15
16
|
export type InterfaceRouterStore<TRoutes extends Record<string, TypeRoute>> = {
|
|
16
|
-
|
|
17
|
+
adapters: TypeAdapters;
|
|
17
18
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
19
|
+
routesHistory: Array<string>;
|
|
18
20
|
isRedirecting: boolean;
|
|
19
21
|
redirectTo<TRouteName extends keyof TRoutes>(config: TypeRedirectToParams<TRoutes, TRouteName>): Promise<void>;
|
|
20
|
-
|
|
22
|
+
restoreFromURL(params: {
|
|
23
|
+
pathname: string;
|
|
24
|
+
fallback: TRoutes[keyof TRoutes]['name'];
|
|
25
|
+
}): Promise<void>;
|
|
21
26
|
restoreFromServer(obj: InterfaceRouterStore<TRoutes>): Promise<void>;
|
|
22
27
|
};
|
|
23
|
-
export {};
|
|
24
28
|
//# sourceMappingURL=InterfaceRouterStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceRouterStore.d.ts","sourceRoot":"","sources":["../../../../packages/core/types/InterfaceRouterStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,
|
|
1
|
+
{"version":3,"file":"InterfaceRouterStore.d.ts","sourceRoot":"","sources":["../../../../packages/core/types/InterfaceRouterStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,GAAG,CAAC;IACjC,aAAa,EAAE,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,IAAI,CAAC;IACnF,cAAc,EAAE,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;IAC7E,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;IAC5E,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;IACvD,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,UAAU,SAAS,MAAM,OAAO,EACzC,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;KAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../packages/core/createRouterConfig.ts","../../packages/core/createRouterStore.ts","../../packages/core/index.ts","../../packages/core/types/InterfaceRouterStore.ts","../../packages/core/types/TypeCurrentRoute.ts","../../packages/core/types/TypeLifecycleConfig.ts","../../packages/core/types/TypePropsRouter.ts","../../packages/core/types/TypeRedirectToParams.ts","../../packages/core/types/TypeRoute.ts","../../packages/core/types/TypeRouteRaw.ts","../../packages/core/types/TypeRouteWithParams.ts","../../packages/core/types/TypeValidator.ts","../../packages/core/utils/addNames.ts","../../packages/core/utils/constants.ts","../../packages/core/utils/dynamic.ts","../../packages/core/utils/findRouteByPathname.ts","../../packages/core/utils/getDynamicValues.ts","../../packages/core/utils/getInitialRoute.ts","../../packages/core/utils/getQueryValues.ts","../../packages/core/utils/getTypedEntries.ts","../../packages/core/utils/history.ts","../../packages/core/utils/loadComponentToConfig.ts","../../packages/core/utils/replaceDynamicValues.ts","../../packages/react/Router.tsx","../../packages/react/index.ts","../../packages/react/useStore.ts","../../packages/solid/Router.tsx","../../packages/solid/index.ts","../../packages/solid/useStore.ts"],"version":"5.9.2"}
|
|
1
|
+
{"root":["../../packages/adapters/mobx.ts","../../packages/adapters/solid.ts","../../packages/core/createRouterConfig.ts","../../packages/core/createRouterStore.ts","../../packages/core/index.ts","../../packages/core/types/InterfaceRouterStore.ts","../../packages/core/types/TypeCurrentRoute.ts","../../packages/core/types/TypeLifecycleConfig.ts","../../packages/core/types/TypePropsRouter.ts","../../packages/core/types/TypeRedirectToParams.ts","../../packages/core/types/TypeRoute.ts","../../packages/core/types/TypeRouteRaw.ts","../../packages/core/types/TypeRouteWithParams.ts","../../packages/core/types/TypeValidator.ts","../../packages/core/utils/addNames.ts","../../packages/core/utils/constants.ts","../../packages/core/utils/dynamic.ts","../../packages/core/utils/findRouteByPathname.ts","../../packages/core/utils/getDynamicValues.ts","../../packages/core/utils/getInitialRoute.ts","../../packages/core/utils/getQueryValues.ts","../../packages/core/utils/getTypedEntries.ts","../../packages/core/utils/history.ts","../../packages/core/utils/loadComponentToConfig.ts","../../packages/core/utils/replaceDynamicValues.ts","../../packages/react/Router.tsx","../../packages/react/index.ts","../../packages/react/useStore.ts","../../packages/solid/Router.tsx","../../packages/solid/index.ts","../../packages/solid/useStore.ts"],"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "reactive-route",
|
|
3
3
|
"author": "Dmitry Kazakov",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.1-alpha.
|
|
5
|
+
"version": "0.0.1-alpha.5",
|
|
6
6
|
"description": "Reactive Router for different frameworks",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -17,9 +17,14 @@
|
|
|
17
17
|
"analyze:js": "biome check --no-errors-on-unmatched .",
|
|
18
18
|
"format:js": "biome check --no-errors-on-unmatched --write",
|
|
19
19
|
"check-types": "tsc --project tsconfig.json",
|
|
20
|
-
"check-types-example": "tsc --project
|
|
20
|
+
"check-types-example": "tsc --project examples/react-mobx/tsconfig.json",
|
|
21
21
|
"prepare": "husky"
|
|
22
22
|
},
|
|
23
|
+
"lint-staged": {
|
|
24
|
+
"(*.js|*.ts|*.tsx|*.mjs)": [
|
|
25
|
+
"pnpm run format:js"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
23
28
|
"dependencies": {
|
|
24
29
|
"history": "5.3.0",
|
|
25
30
|
"query-string": "7.1.3"
|
|
@@ -69,6 +74,16 @@
|
|
|
69
74
|
"types": "./dist/types/solid/index.d.ts",
|
|
70
75
|
"require": "./dist/cjs/solid/index.js",
|
|
71
76
|
"import": "./dist/esm/solid/index.js"
|
|
77
|
+
},
|
|
78
|
+
"./adapters/mobx": {
|
|
79
|
+
"types": "./dist/types/adapters/mobx.d.ts",
|
|
80
|
+
"require": "./dist/cjs/adapters/mobx/index.js",
|
|
81
|
+
"import": "./dist/esm/adapters/mobx/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./adapters/solid": {
|
|
84
|
+
"types": "./dist/types/adapters/solid.d.ts",
|
|
85
|
+
"require": "./dist/cjs/adapters/solid/index.js",
|
|
86
|
+
"import": "./dist/esm/adapters/solid/index.js"
|
|
72
87
|
}
|
|
73
88
|
},
|
|
74
89
|
"main": "dist/cjs/index.js",
|