reactive-route 0.0.1-alpha.23 → 0.0.1-alpha.25
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/index.js +15 -13
- package/dist/cjs/preact/index.js +2 -2
- package/dist/cjs/react/index.js +2 -2
- package/dist/cjs/solid/index.js +2 -2
- package/dist/core/createRouter.d.ts.map +1 -1
- package/dist/core/types/TypePropsRouter.d.ts +0 -1
- package/dist/core/types/TypePropsRouter.d.ts.map +1 -1
- package/dist/core/types/TypeRouter.d.ts +5 -1
- package/dist/core/types/TypeRouter.d.ts.map +1 -1
- package/dist/core/utils/loadComponentToConfig.d.ts.map +1 -1
- package/dist/esm/index.js +15 -13
- package/dist/esm/preact/index.js +2 -2
- package/dist/esm/react/index.js +2 -2
- package/dist/esm/solid/index.js +2 -2
- package/dist/solid/Router.d.ts.map +1 -1
- package/package.json +4 -2
- package/pnpm-workspace.yaml +0 -5
package/dist/cjs/index.js
CHANGED
|
@@ -142,9 +142,8 @@ var history = constants.isClient ? (0, import_history.createBrowserHistory)() :
|
|
|
142
142
|
// packages/core/utils/loadComponentToConfig.ts
|
|
143
143
|
function loadComponentToConfig(params) {
|
|
144
144
|
const { route } = params;
|
|
145
|
-
if (!route.component
|
|
146
|
-
|
|
147
|
-
return loadingFn().then((module2) => {
|
|
145
|
+
if (!route.component) {
|
|
146
|
+
return route.loader().then((module2) => {
|
|
148
147
|
const { default: component, ...rest } = module2;
|
|
149
148
|
route.component = component;
|
|
150
149
|
route.otherExports = rest;
|
|
@@ -202,10 +201,13 @@ function createRouter({
|
|
|
202
201
|
restoreFromServer: void 0,
|
|
203
202
|
get adapters() {
|
|
204
203
|
return adapters;
|
|
204
|
+
},
|
|
205
|
+
get routes() {
|
|
206
|
+
return routes;
|
|
205
207
|
}
|
|
206
208
|
});
|
|
207
209
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
208
|
-
adapters.batch(() => {
|
|
210
|
+
router.adapters.batch(() => {
|
|
209
211
|
router.routesHistory.push(...obj.routesHistory || []);
|
|
210
212
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
211
213
|
});
|
|
@@ -256,8 +258,8 @@ function createRouter({
|
|
|
256
258
|
if (currentUrl === nextUrl) return Promise.resolve();
|
|
257
259
|
if (currentPathname === nextPathname) {
|
|
258
260
|
if (currentSearch !== nextSearch) {
|
|
259
|
-
adapters.batch(() => {
|
|
260
|
-
adapters.replaceObject(router.currentRoute, {
|
|
261
|
+
router.adapters.batch(() => {
|
|
262
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
261
263
|
...router.currentRoute,
|
|
262
264
|
query: nextQuery || {}
|
|
263
265
|
});
|
|
@@ -273,7 +275,7 @@ function createRouter({
|
|
|
273
275
|
}
|
|
274
276
|
return Promise.resolve();
|
|
275
277
|
}
|
|
276
|
-
adapters.batch(() => {
|
|
278
|
+
router.adapters.batch(() => {
|
|
277
279
|
router.isRedirecting = true;
|
|
278
280
|
});
|
|
279
281
|
try {
|
|
@@ -324,21 +326,21 @@ function createRouter({
|
|
|
324
326
|
}
|
|
325
327
|
console.error(error);
|
|
326
328
|
await loadComponentToConfig({ route: routes.internalError });
|
|
327
|
-
adapters.batch(() => {
|
|
328
|
-
adapters.replaceObject(router.currentRoute, {
|
|
329
|
+
router.adapters.batch(() => {
|
|
330
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
329
331
|
name: routes.internalError.name,
|
|
330
332
|
path: routes.internalError.path,
|
|
331
333
|
props: routes[routes.internalError.name].props,
|
|
332
|
-
query: adapters.makeObservable({}),
|
|
333
|
-
params: adapters.makeObservable({}),
|
|
334
|
+
query: router.adapters.makeObservable({}),
|
|
335
|
+
params: router.adapters.makeObservable({}),
|
|
334
336
|
pageId: routes[routes.internalError.name].pageId
|
|
335
337
|
});
|
|
336
338
|
router.isRedirecting = false;
|
|
337
339
|
});
|
|
338
340
|
return Promise.resolve();
|
|
339
341
|
}
|
|
340
|
-
adapters.batch(() => {
|
|
341
|
-
adapters.replaceObject(router.currentRoute, {
|
|
342
|
+
router.adapters.batch(() => {
|
|
343
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
342
344
|
name: nextRoute.name,
|
|
343
345
|
path: nextRoute.path,
|
|
344
346
|
props: routes[nextRoute.name].props,
|
package/dist/cjs/preact/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function RouterInner(props) {
|
|
|
54
54
|
const setLoadedComponent = (0, import_hooks.useCallback)(() => {
|
|
55
55
|
const { loadedComponentName, loadedComponentPage } = config;
|
|
56
56
|
const { currentRoute, isRedirecting } = props.router;
|
|
57
|
-
const componentConfig = props.routes[currentRoute.name];
|
|
57
|
+
const componentConfig = props.router.routes[currentRoute.name];
|
|
58
58
|
let preventRedirect = false;
|
|
59
59
|
if (isRedirecting) preventRedirect = true;
|
|
60
60
|
else if (loadedComponentName === currentRoute.name) preventRedirect = true;
|
|
@@ -89,7 +89,7 @@ function RouterInner(props) {
|
|
|
89
89
|
};
|
|
90
90
|
}, []);
|
|
91
91
|
if (!config.loadedComponentName) return null;
|
|
92
|
-
const LoadedComponent = props.routes[config.loadedComponentName]?.component || null;
|
|
92
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName]?.component || null;
|
|
93
93
|
if (LoadedComponent)
|
|
94
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
95
95
|
return null;
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function RouterInner(props) {
|
|
|
54
54
|
const setLoadedComponent = (0, import_react.useCallback)(() => {
|
|
55
55
|
const { loadedComponentName, loadedComponentPage } = config;
|
|
56
56
|
const { currentRoute, isRedirecting } = props.router;
|
|
57
|
-
const componentConfig = props.routes[currentRoute.name];
|
|
57
|
+
const componentConfig = props.router.routes[currentRoute.name];
|
|
58
58
|
let preventRedirect = false;
|
|
59
59
|
if (isRedirecting) preventRedirect = true;
|
|
60
60
|
else if (loadedComponentName === currentRoute.name) preventRedirect = true;
|
|
@@ -89,7 +89,7 @@ function RouterInner(props) {
|
|
|
89
89
|
};
|
|
90
90
|
}, []);
|
|
91
91
|
if (!config.loadedComponentName) return null;
|
|
92
|
-
const LoadedComponent = props.routes[config.loadedComponentName]?.component || null;
|
|
92
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName]?.component || null;
|
|
93
93
|
if (LoadedComponent)
|
|
94
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
95
95
|
return null;
|
package/dist/cjs/solid/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function Router(props) {
|
|
|
54
54
|
function setLoadedComponent() {
|
|
55
55
|
const currentRouteName = props.router.currentRoute.name;
|
|
56
56
|
const currentRoutePage = props.router.currentRoute.pageId;
|
|
57
|
-
const componentConfig = props.routes[currentRouteName];
|
|
57
|
+
const componentConfig = props.router.routes[currentRouteName];
|
|
58
58
|
let preventRedirect = false;
|
|
59
59
|
if (props.router.isRedirecting) preventRedirect = true;
|
|
60
60
|
else if (config.loadedComponentName === currentRouteName) {
|
|
@@ -97,7 +97,7 @@ function Router(props) {
|
|
|
97
97
|
get children() {
|
|
98
98
|
return (0, import_web.createComponent)(import_web3.Dynamic, (0, import_web2.mergeProps)({
|
|
99
99
|
get component() {
|
|
100
|
-
return props.routes[config.loadedComponentName]?.component || void 0;
|
|
100
|
+
return props.router.routes[config.loadedComponentName]?.component || void 0;
|
|
101
101
|
}
|
|
102
102
|
}, () => Object.keys(config.currentProps).reduce((acc, key) => {
|
|
103
103
|
acc[key] = currentProps[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAYhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,EACA,MAAM,EACN,QAAQ,EACR,eAAe,GAChB,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAYhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,EACA,MAAM,EACN,QAAQ,EACR,eAAe,GAChB,EAAE;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,CAoPtB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TypeRoute } from './TypeRoute';
|
|
2
2
|
import { TypeRouter } from './TypeRouter';
|
|
3
3
|
export type TypePropsRouter<TRoutes extends Record<string, TypeRoute>> = {
|
|
4
|
-
routes: TRoutes;
|
|
5
4
|
router: TypeRouter<TRoutes>;
|
|
6
5
|
beforeMount?: () => void;
|
|
7
6
|
beforeSetPageComponent?: (componentConfig: TRoutes[keyof TRoutes]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypePropsRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypePropsRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;IACvE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"TypePropsRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypePropsRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;IACvE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,sBAAsB,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC;IAC3E,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAC;CACxC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { TypeCurrentRoute } from './TypeCurrentRoute';
|
|
|
3
3
|
import { TypeRedirectParams } from './TypeRedirectParams';
|
|
4
4
|
import { TypeRoute } from './TypeRoute';
|
|
5
5
|
export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalError', TypeRoute>> = {
|
|
6
|
+
routes: TRoutes;
|
|
6
7
|
adapters: TypeAdapters;
|
|
7
8
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
8
9
|
routesHistory: Array<string>;
|
|
@@ -12,6 +13,9 @@ export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalErr
|
|
|
12
13
|
pathname: string;
|
|
13
14
|
noHistoryPush?: boolean;
|
|
14
15
|
}): Promise<void>;
|
|
15
|
-
restoreFromServer(obj:
|
|
16
|
+
restoreFromServer(obj: {
|
|
17
|
+
routesHistory: Array<string>;
|
|
18
|
+
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
19
|
+
}): Promise<void>;
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=TypeRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,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,QAAQ,CAAC,UAAU,SAAS,MAAM,OAAO,EACvC,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,iBAAiB,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,MAAM,EAAE,OAAO,CAAC;IAChB,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,QAAQ,CAAC,UAAU,SAAS,MAAM,OAAO,EACvC,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,iBAAiB,CAAC,GAAG,EAAE;QACrB,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;KACxD,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadComponentToConfig.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/loadComponentToConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"loadComponentToConfig.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/loadComponentToConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAajF"}
|
package/dist/esm/index.js
CHANGED
|
@@ -111,9 +111,8 @@ var history = constants.isClient ? createBrowserHistory() : null;
|
|
|
111
111
|
// packages/core/utils/loadComponentToConfig.ts
|
|
112
112
|
function loadComponentToConfig(params) {
|
|
113
113
|
const { route } = params;
|
|
114
|
-
if (!route.component
|
|
115
|
-
|
|
116
|
-
return loadingFn().then((module) => {
|
|
114
|
+
if (!route.component) {
|
|
115
|
+
return route.loader().then((module) => {
|
|
117
116
|
const { default: component, ...rest } = module;
|
|
118
117
|
route.component = component;
|
|
119
118
|
route.otherExports = rest;
|
|
@@ -171,10 +170,13 @@ function createRouter({
|
|
|
171
170
|
restoreFromServer: void 0,
|
|
172
171
|
get adapters() {
|
|
173
172
|
return adapters;
|
|
173
|
+
},
|
|
174
|
+
get routes() {
|
|
175
|
+
return routes;
|
|
174
176
|
}
|
|
175
177
|
});
|
|
176
178
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
177
|
-
adapters.batch(() => {
|
|
179
|
+
router.adapters.batch(() => {
|
|
178
180
|
router.routesHistory.push(...obj.routesHistory || []);
|
|
179
181
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
180
182
|
});
|
|
@@ -225,8 +227,8 @@ function createRouter({
|
|
|
225
227
|
if (currentUrl === nextUrl) return Promise.resolve();
|
|
226
228
|
if (currentPathname === nextPathname) {
|
|
227
229
|
if (currentSearch !== nextSearch) {
|
|
228
|
-
adapters.batch(() => {
|
|
229
|
-
adapters.replaceObject(router.currentRoute, {
|
|
230
|
+
router.adapters.batch(() => {
|
|
231
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
230
232
|
...router.currentRoute,
|
|
231
233
|
query: nextQuery || {}
|
|
232
234
|
});
|
|
@@ -242,7 +244,7 @@ function createRouter({
|
|
|
242
244
|
}
|
|
243
245
|
return Promise.resolve();
|
|
244
246
|
}
|
|
245
|
-
adapters.batch(() => {
|
|
247
|
+
router.adapters.batch(() => {
|
|
246
248
|
router.isRedirecting = true;
|
|
247
249
|
});
|
|
248
250
|
try {
|
|
@@ -293,21 +295,21 @@ function createRouter({
|
|
|
293
295
|
}
|
|
294
296
|
console.error(error);
|
|
295
297
|
await loadComponentToConfig({ route: routes.internalError });
|
|
296
|
-
adapters.batch(() => {
|
|
297
|
-
adapters.replaceObject(router.currentRoute, {
|
|
298
|
+
router.adapters.batch(() => {
|
|
299
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
298
300
|
name: routes.internalError.name,
|
|
299
301
|
path: routes.internalError.path,
|
|
300
302
|
props: routes[routes.internalError.name].props,
|
|
301
|
-
query: adapters.makeObservable({}),
|
|
302
|
-
params: adapters.makeObservable({}),
|
|
303
|
+
query: router.adapters.makeObservable({}),
|
|
304
|
+
params: router.adapters.makeObservable({}),
|
|
303
305
|
pageId: routes[routes.internalError.name].pageId
|
|
304
306
|
});
|
|
305
307
|
router.isRedirecting = false;
|
|
306
308
|
});
|
|
307
309
|
return Promise.resolve();
|
|
308
310
|
}
|
|
309
|
-
adapters.batch(() => {
|
|
310
|
-
adapters.replaceObject(router.currentRoute, {
|
|
311
|
+
router.adapters.batch(() => {
|
|
312
|
+
router.adapters.replaceObject(router.currentRoute, {
|
|
311
313
|
name: nextRoute.name,
|
|
312
314
|
path: nextRoute.path,
|
|
313
315
|
props: routes[nextRoute.name].props,
|
package/dist/esm/preact/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function RouterInner(props) {
|
|
|
28
28
|
const setLoadedComponent = useCallback(() => {
|
|
29
29
|
const { loadedComponentName, loadedComponentPage } = config;
|
|
30
30
|
const { currentRoute, isRedirecting } = props.router;
|
|
31
|
-
const componentConfig = props.routes[currentRoute.name];
|
|
31
|
+
const componentConfig = props.router.routes[currentRoute.name];
|
|
32
32
|
let preventRedirect = false;
|
|
33
33
|
if (isRedirecting) preventRedirect = true;
|
|
34
34
|
else if (loadedComponentName === currentRoute.name) preventRedirect = true;
|
|
@@ -63,7 +63,7 @@ function RouterInner(props) {
|
|
|
63
63
|
};
|
|
64
64
|
}, []);
|
|
65
65
|
if (!config.loadedComponentName) return null;
|
|
66
|
-
const LoadedComponent = props.routes[config.loadedComponentName]?.component || null;
|
|
66
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName]?.component || null;
|
|
67
67
|
if (LoadedComponent)
|
|
68
68
|
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
69
69
|
return null;
|
package/dist/esm/react/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function RouterInner(props) {
|
|
|
28
28
|
const setLoadedComponent = useCallback(() => {
|
|
29
29
|
const { loadedComponentName, loadedComponentPage } = config;
|
|
30
30
|
const { currentRoute, isRedirecting } = props.router;
|
|
31
|
-
const componentConfig = props.routes[currentRoute.name];
|
|
31
|
+
const componentConfig = props.router.routes[currentRoute.name];
|
|
32
32
|
let preventRedirect = false;
|
|
33
33
|
if (isRedirecting) preventRedirect = true;
|
|
34
34
|
else if (loadedComponentName === currentRoute.name) preventRedirect = true;
|
|
@@ -63,7 +63,7 @@ function RouterInner(props) {
|
|
|
63
63
|
};
|
|
64
64
|
}, []);
|
|
65
65
|
if (!config.loadedComponentName) return null;
|
|
66
|
-
const LoadedComponent = props.routes[config.loadedComponentName]?.component || null;
|
|
66
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName]?.component || null;
|
|
67
67
|
if (LoadedComponent)
|
|
68
68
|
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
69
69
|
return null;
|
package/dist/esm/solid/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function Router(props) {
|
|
|
28
28
|
function setLoadedComponent() {
|
|
29
29
|
const currentRouteName = props.router.currentRoute.name;
|
|
30
30
|
const currentRoutePage = props.router.currentRoute.pageId;
|
|
31
|
-
const componentConfig = props.routes[currentRouteName];
|
|
31
|
+
const componentConfig = props.router.routes[currentRouteName];
|
|
32
32
|
let preventRedirect = false;
|
|
33
33
|
if (props.router.isRedirecting) preventRedirect = true;
|
|
34
34
|
else if (config.loadedComponentName === currentRouteName) {
|
|
@@ -71,7 +71,7 @@ function Router(props) {
|
|
|
71
71
|
get children() {
|
|
72
72
|
return _$createComponent(Dynamic, _$mergeProps({
|
|
73
73
|
get component() {
|
|
74
|
-
return props.routes[config.loadedComponentName]?.component || void 0;
|
|
74
|
+
return props.router.routes[config.loadedComponentName]?.component || void 0;
|
|
75
75
|
}
|
|
76
76
|
}, () => Object.keys(config.currentProps).reduce((acc, key) => {
|
|
77
77
|
acc[key] = currentProps[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIrE,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIrE,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,kCAwGhG"}
|
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.25",
|
|
6
6
|
"description": "Reactive Router for different frameworks",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"check-types": "tsc --project tsconfig.json&&tsc --project tsconfig.solid.json",
|
|
20
20
|
"check-types-example": "tsc --project examples/react/tsconfig.json",
|
|
21
21
|
"prepare": "husky",
|
|
22
|
+
"upgrade-examples": "pnpm upgrade -r reactive-route@latest",
|
|
22
23
|
"docs:dev": "vitepress dev docs",
|
|
23
24
|
"docs:build": "vitepress build docs",
|
|
24
25
|
"docs:preview": "vitepress preview docs"
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"@types/lodash": "4.17.16",
|
|
48
49
|
"@types/node": "22.14.1",
|
|
49
50
|
"@vitest/coverage-istanbul": "3.2.4",
|
|
51
|
+
"vite-tsconfig-paths": "5.1.4",
|
|
50
52
|
"@preact/preset-vite": "2.10.2",
|
|
51
53
|
"badge-maker": "5.0.2",
|
|
52
54
|
"esbuild": "0.25.10",
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
"solid-js": "1.9.9",
|
|
64
66
|
"tsx": "4.20.5",
|
|
65
67
|
"typescript": "5.9.2",
|
|
66
|
-
"vitepress": "
|
|
68
|
+
"vitepress": "2.0.0-alpha.12",
|
|
67
69
|
"vitepress-plugin-group-icons": "1.6.3",
|
|
68
70
|
"vitest": "3.2.4",
|
|
69
71
|
"xml-splitter": "1.2.1"
|