reactive-route 0.0.1-alpha.32 → 0.0.1-alpha.33
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/core/createRouter.d.ts.map +1 -1
- package/core/types/TypeRouter.d.ts +0 -2
- package/core/types/TypeRouter.d.ts.map +1 -1
- package/core/utils/getInitialRoute.d.ts +1 -0
- package/core/utils/getInitialRoute.d.ts.map +1 -1
- package/index.cjs +4 -14
- package/index.mjs +4 -14
- package/package.json +1 -1
- package/solid/Router.d.ts.map +1 -1
- package/solid/index.cjs +4 -1
- package/solid/index.mjs +5 -2
|
@@ -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;AAWhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,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;AAWhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,CAuPtB"}
|
|
@@ -6,7 +6,6 @@ export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalErr
|
|
|
6
6
|
routes: TRoutes;
|
|
7
7
|
adapters: TypeAdapters;
|
|
8
8
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
9
|
-
routesHistory: Array<string>;
|
|
10
9
|
isRedirecting: boolean;
|
|
11
10
|
redirect<TRouteName extends keyof TRoutes>(config: TypeRedirectParams<TRoutes, TRouteName>): Promise<void>;
|
|
12
11
|
restoreFromURL(params: {
|
|
@@ -14,7 +13,6 @@ export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalErr
|
|
|
14
13
|
replace?: boolean;
|
|
15
14
|
}): Promise<void>;
|
|
16
15
|
restoreFromServer(obj: {
|
|
17
|
-
routesHistory: Array<string>;
|
|
18
16
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
19
17
|
}): Promise<void>;
|
|
20
18
|
lifecycleParams?: Array<any>;
|
|
@@ -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,SAA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OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -3,5 +3,6 @@ import { TypeRoute } from '../types/TypeRoute';
|
|
|
3
3
|
export declare function getInitialRoute<TRoutes extends Record<string | 'notFound' | 'internalError', TypeRoute>>(params: {
|
|
4
4
|
routes: TRoutes;
|
|
5
5
|
pathname: string;
|
|
6
|
+
replace?: boolean;
|
|
6
7
|
}): TypeRedirectParams<TRoutes, keyof TRoutes>;
|
|
7
8
|
//# sourceMappingURL=getInitialRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInitialRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getInitialRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"getInitialRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getInitialRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,CAW7C"}
|
package/index.cjs
CHANGED
|
@@ -131,7 +131,8 @@ function getInitialRoute(params) {
|
|
|
131
131
|
return {
|
|
132
132
|
route: route.name,
|
|
133
133
|
query: getQueryValues({ route, pathname: params.pathname }),
|
|
134
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
134
|
+
params: getDynamicValues({ route, pathname: params.pathname }),
|
|
135
|
+
replace: params.replace
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -185,7 +186,6 @@ function replaceDynamicValues({
|
|
|
185
186
|
// packages/core/createRouter.ts
|
|
186
187
|
function createRouter(config) {
|
|
187
188
|
const router = config.adapters.makeObservable({
|
|
188
|
-
routesHistory: [],
|
|
189
189
|
currentRoute: {},
|
|
190
190
|
isRedirecting: false,
|
|
191
191
|
redirect: void 0,
|
|
@@ -204,7 +204,6 @@ function createRouter(config) {
|
|
|
204
204
|
});
|
|
205
205
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
206
206
|
router.adapters.batch(() => {
|
|
207
|
-
router.routesHistory.push(...obj.routesHistory || []);
|
|
208
207
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
209
208
|
});
|
|
210
209
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
@@ -259,7 +258,6 @@ function createRouter(config) {
|
|
|
259
258
|
...router.currentRoute,
|
|
260
259
|
query: nextQuery || {}
|
|
261
260
|
});
|
|
262
|
-
router.routesHistory.push(nextUrl);
|
|
263
261
|
});
|
|
264
262
|
if (constants.isClient) {
|
|
265
263
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
@@ -340,12 +338,8 @@ function createRouter(config) {
|
|
|
340
338
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
341
339
|
pageId: router.routes[nextRoute.name].pageId
|
|
342
340
|
});
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
router.routesHistory.push(nextUrl);
|
|
346
|
-
if (constants.isClient) {
|
|
347
|
-
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
348
|
-
}
|
|
341
|
+
if (constants.isClient) {
|
|
342
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
349
343
|
}
|
|
350
344
|
router.isRedirecting = false;
|
|
351
345
|
});
|
|
@@ -353,10 +347,6 @@ function createRouter(config) {
|
|
|
353
347
|
};
|
|
354
348
|
function popHandler() {
|
|
355
349
|
const currentUrl = `${location.pathname}${location.search}`;
|
|
356
|
-
const previousUrl = router.routesHistory[router.routesHistory.length - 2];
|
|
357
|
-
if (previousUrl === currentUrl) {
|
|
358
|
-
router.adapters.batch(() => router.routesHistory.pop());
|
|
359
|
-
}
|
|
360
350
|
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
361
351
|
}
|
|
362
352
|
if (constants.isClient) {
|
package/index.mjs
CHANGED
|
@@ -100,7 +100,8 @@ function getInitialRoute(params) {
|
|
|
100
100
|
return {
|
|
101
101
|
route: route.name,
|
|
102
102
|
query: getQueryValues({ route, pathname: params.pathname }),
|
|
103
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
103
|
+
params: getDynamicValues({ route, pathname: params.pathname }),
|
|
104
|
+
replace: params.replace
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -154,7 +155,6 @@ function replaceDynamicValues({
|
|
|
154
155
|
// packages/core/createRouter.ts
|
|
155
156
|
function createRouter(config) {
|
|
156
157
|
const router = config.adapters.makeObservable({
|
|
157
|
-
routesHistory: [],
|
|
158
158
|
currentRoute: {},
|
|
159
159
|
isRedirecting: false,
|
|
160
160
|
redirect: void 0,
|
|
@@ -173,7 +173,6 @@ function createRouter(config) {
|
|
|
173
173
|
});
|
|
174
174
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
175
175
|
router.adapters.batch(() => {
|
|
176
|
-
router.routesHistory.push(...obj.routesHistory || []);
|
|
177
176
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
178
177
|
});
|
|
179
178
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
@@ -228,7 +227,6 @@ function createRouter(config) {
|
|
|
228
227
|
...router.currentRoute,
|
|
229
228
|
query: nextQuery || {}
|
|
230
229
|
});
|
|
231
|
-
router.routesHistory.push(nextUrl);
|
|
232
230
|
});
|
|
233
231
|
if (constants.isClient) {
|
|
234
232
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
@@ -309,12 +307,8 @@ function createRouter(config) {
|
|
|
309
307
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
310
308
|
pageId: router.routes[nextRoute.name].pageId
|
|
311
309
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
router.routesHistory.push(nextUrl);
|
|
315
|
-
if (constants.isClient) {
|
|
316
|
-
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
317
|
-
}
|
|
310
|
+
if (constants.isClient) {
|
|
311
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
318
312
|
}
|
|
319
313
|
router.isRedirecting = false;
|
|
320
314
|
});
|
|
@@ -322,10 +316,6 @@ function createRouter(config) {
|
|
|
322
316
|
};
|
|
323
317
|
function popHandler() {
|
|
324
318
|
const currentUrl = `${location.pathname}${location.search}`;
|
|
325
|
-
const previousUrl = router.routesHistory[router.routesHistory.length - 2];
|
|
326
|
-
if (previousUrl === currentUrl) {
|
|
327
|
-
router.adapters.batch(() => router.routesHistory.pop());
|
|
328
|
-
}
|
|
329
319
|
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
330
320
|
}
|
|
331
321
|
if (constants.isClient) {
|
package/package.json
CHANGED
package/solid/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItF,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,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,kCAsChG"}
|
package/solid/index.cjs
CHANGED
|
@@ -42,7 +42,10 @@ function Router(props) {
|
|
|
42
42
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
props.router.adapters.autorun(() => (0, import_reactive_route.routerSetLoadedComponent)(props, config));
|
|
45
|
+
const disposer = props.router.adapters.autorun(() => (0, import_reactive_route.routerSetLoadedComponent)(props, config));
|
|
46
|
+
(0, import_solid_js.onCleanup)(() => {
|
|
47
|
+
if (typeof disposer === "function") disposer();
|
|
48
|
+
});
|
|
46
49
|
return (
|
|
47
50
|
// @ts-ignore
|
|
48
51
|
(0, import_web.createComponent)(import_solid_js.Show, {
|
package/solid/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
3
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
4
|
import { routerSetLoadedComponent } from "reactive-route";
|
|
5
|
-
import { Show } from "solid-js";
|
|
5
|
+
import { onCleanup, Show } from "solid-js";
|
|
6
6
|
import { Dynamic } from "solid-js/web";
|
|
7
7
|
function Router(props) {
|
|
8
8
|
const config = props.router.adapters.makeObservable({
|
|
@@ -16,7 +16,10 @@ function Router(props) {
|
|
|
16
16
|
routerSetLoadedComponent(props, config);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
props.router.adapters.autorun(() => routerSetLoadedComponent(props, config));
|
|
19
|
+
const disposer = props.router.adapters.autorun(() => routerSetLoadedComponent(props, config));
|
|
20
|
+
onCleanup(() => {
|
|
21
|
+
if (typeof disposer === "function") disposer();
|
|
22
|
+
});
|
|
20
23
|
return (
|
|
21
24
|
// @ts-ignore
|
|
22
25
|
_$createComponent(Show, {
|