reactive-route 0.0.1-alpha.31 → 0.0.1-alpha.32
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/index.d.ts +0 -1
- package/core/index.d.ts.map +1 -1
- package/core/types/TypeRouter.d.ts +1 -0
- package/core/types/TypeRouter.d.ts.map +1 -1
- package/index.cjs +22 -18
- package/index.mjs +22 -18
- package/package.json +1 -4
- package/preact/Router.d.ts.map +1 -1
- package/preact/index.cjs +0 -15
- package/preact/index.mjs +2 -17
- package/react/Router.d.ts.map +1 -1
- package/react/index.cjs +0 -15
- package/react/index.mjs +2 -17
- package/solid/Router.d.ts.map +1 -1
- package/solid/index.cjs +0 -15
- package/solid/index.mjs +1 -16
- package/vue/index.cjs +0 -0
- package/vue/index.mjs +0 -0
- package/core/utils/history.d.ts +0 -7
- package/core/utils/history.d.ts.map +0 -1
|
@@ -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;
|
|
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,CAqQtB"}
|
package/core/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type { TypePropsRouter } from './types/TypePropsRouter';
|
|
|
6
6
|
export type { TypeRedirectParams } from './types/TypeRedirectParams';
|
|
7
7
|
export type { TypeRoute } from './types/TypeRoute';
|
|
8
8
|
export type { TypeRouter } from './types/TypeRouter';
|
|
9
|
-
export { history } from './utils/history';
|
|
10
9
|
export { loadComponentToConfig } from './utils/loadComponentToConfig';
|
|
11
10
|
export { RedirectError } from './utils/RedirectError';
|
|
12
11
|
export { replaceDynamicValues } from './utils/replaceDynamicValues';
|
package/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY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,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,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;IAClB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
|
package/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(core_exports, {
|
|
|
23
23
|
RedirectError: () => RedirectError,
|
|
24
24
|
createRouter: () => createRouter,
|
|
25
25
|
createRoutes: () => createRoutes,
|
|
26
|
-
history: () => history,
|
|
27
26
|
loadComponentToConfig: () => loadComponentToConfig,
|
|
28
27
|
replaceDynamicValues: () => replaceDynamicValues,
|
|
29
28
|
routerSetLoadedComponent: () => routerSetLoadedComponent
|
|
@@ -136,10 +135,6 @@ function getInitialRoute(params) {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
// packages/core/utils/history.ts
|
|
140
|
-
var import_history = require("history");
|
|
141
|
-
var history = constants.isClient ? (0, import_history.createBrowserHistory)() : null;
|
|
142
|
-
|
|
143
138
|
// packages/core/utils/loadComponentToConfig.ts
|
|
144
139
|
function loadComponentToConfig(params) {
|
|
145
140
|
const { route } = params;
|
|
@@ -196,6 +191,7 @@ function createRouter(config) {
|
|
|
196
191
|
redirect: void 0,
|
|
197
192
|
restoreFromURL: void 0,
|
|
198
193
|
restoreFromServer: void 0,
|
|
194
|
+
destroy: void 0,
|
|
199
195
|
get adapters() {
|
|
200
196
|
return config.adapters;
|
|
201
197
|
},
|
|
@@ -265,12 +261,8 @@ function createRouter(config) {
|
|
|
265
261
|
});
|
|
266
262
|
router.routesHistory.push(nextUrl);
|
|
267
263
|
});
|
|
268
|
-
if (
|
|
269
|
-
history
|
|
270
|
-
hash: history.location.hash,
|
|
271
|
-
search: nextSearch,
|
|
272
|
-
pathname: nextPathname
|
|
273
|
-
});
|
|
264
|
+
if (constants.isClient) {
|
|
265
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
274
266
|
}
|
|
275
267
|
}
|
|
276
268
|
return Promise.resolve();
|
|
@@ -351,18 +343,30 @@ function createRouter(config) {
|
|
|
351
343
|
const lastUrl = router.routesHistory[router.routesHistory.length - 1];
|
|
352
344
|
if (lastUrl !== nextUrl) {
|
|
353
345
|
router.routesHistory.push(nextUrl);
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
hash: history.location.hash,
|
|
358
|
-
search: "query" in config2 ? `?${queryString.stringify(config2.query)}` : "",
|
|
359
|
-
pathname: nextPathname
|
|
360
|
-
});
|
|
346
|
+
if (constants.isClient) {
|
|
347
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
348
|
+
}
|
|
361
349
|
}
|
|
362
350
|
router.isRedirecting = false;
|
|
363
351
|
});
|
|
364
352
|
return Promise.resolve();
|
|
365
353
|
};
|
|
354
|
+
function popHandler() {
|
|
355
|
+
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
|
+
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
361
|
+
}
|
|
362
|
+
if (constants.isClient) {
|
|
363
|
+
window.addEventListener("popstate", popHandler);
|
|
364
|
+
}
|
|
365
|
+
router.destroy = function destroy() {
|
|
366
|
+
if (constants.isClient) {
|
|
367
|
+
window.removeEventListener("popstate", popHandler);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
366
370
|
return router;
|
|
367
371
|
}
|
|
368
372
|
|
package/index.mjs
CHANGED
|
@@ -104,10 +104,6 @@ function getInitialRoute(params) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
// packages/core/utils/history.ts
|
|
108
|
-
import { createBrowserHistory } from "history";
|
|
109
|
-
var history = constants.isClient ? createBrowserHistory() : null;
|
|
110
|
-
|
|
111
107
|
// packages/core/utils/loadComponentToConfig.ts
|
|
112
108
|
function loadComponentToConfig(params) {
|
|
113
109
|
const { route } = params;
|
|
@@ -164,6 +160,7 @@ function createRouter(config) {
|
|
|
164
160
|
redirect: void 0,
|
|
165
161
|
restoreFromURL: void 0,
|
|
166
162
|
restoreFromServer: void 0,
|
|
163
|
+
destroy: void 0,
|
|
167
164
|
get adapters() {
|
|
168
165
|
return config.adapters;
|
|
169
166
|
},
|
|
@@ -233,12 +230,8 @@ function createRouter(config) {
|
|
|
233
230
|
});
|
|
234
231
|
router.routesHistory.push(nextUrl);
|
|
235
232
|
});
|
|
236
|
-
if (
|
|
237
|
-
history
|
|
238
|
-
hash: history.location.hash,
|
|
239
|
-
search: nextSearch,
|
|
240
|
-
pathname: nextPathname
|
|
241
|
-
});
|
|
233
|
+
if (constants.isClient) {
|
|
234
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
242
235
|
}
|
|
243
236
|
}
|
|
244
237
|
return Promise.resolve();
|
|
@@ -319,18 +312,30 @@ function createRouter(config) {
|
|
|
319
312
|
const lastUrl = router.routesHistory[router.routesHistory.length - 1];
|
|
320
313
|
if (lastUrl !== nextUrl) {
|
|
321
314
|
router.routesHistory.push(nextUrl);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
hash: history.location.hash,
|
|
326
|
-
search: "query" in config2 ? `?${queryString.stringify(config2.query)}` : "",
|
|
327
|
-
pathname: nextPathname
|
|
328
|
-
});
|
|
315
|
+
if (constants.isClient) {
|
|
316
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
317
|
+
}
|
|
329
318
|
}
|
|
330
319
|
router.isRedirecting = false;
|
|
331
320
|
});
|
|
332
321
|
return Promise.resolve();
|
|
333
322
|
};
|
|
323
|
+
function popHandler() {
|
|
324
|
+
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
|
+
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
330
|
+
}
|
|
331
|
+
if (constants.isClient) {
|
|
332
|
+
window.addEventListener("popstate", popHandler);
|
|
333
|
+
}
|
|
334
|
+
router.destroy = function destroy() {
|
|
335
|
+
if (constants.isClient) {
|
|
336
|
+
window.removeEventListener("popstate", popHandler);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
334
339
|
return router;
|
|
335
340
|
}
|
|
336
341
|
|
|
@@ -376,7 +381,6 @@ export {
|
|
|
376
381
|
RedirectError,
|
|
377
382
|
createRouter,
|
|
378
383
|
createRoutes,
|
|
379
|
-
history,
|
|
380
384
|
loadComponentToConfig,
|
|
381
385
|
replaceDynamicValues,
|
|
382
386
|
routerSetLoadedComponent
|
package/package.json
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
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.32",
|
|
6
6
|
"description": "Reactive Router for different frameworks",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/dkazakov8/reactive-route.git"
|
|
10
10
|
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"history": "5.3.0"
|
|
13
|
-
},
|
|
14
11
|
"engines": {
|
|
15
12
|
"node": ">=22"
|
|
16
13
|
},
|
package/preact/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6CtF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAK1D,GAAG,CACzC"}
|
package/preact/index.cjs
CHANGED
|
@@ -30,20 +30,6 @@ var import_reactive_route = require("reactive-route");
|
|
|
30
30
|
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
31
31
|
function RouterInner(props) {
|
|
32
32
|
const disposerRef = (0, import_hooks.useRef)(null);
|
|
33
|
-
const redirectOnHistoryPop = (0, import_hooks.useCallback)(() => {
|
|
34
|
-
if (!import_reactive_route.history) return;
|
|
35
|
-
import_reactive_route.history.listen((params) => {
|
|
36
|
-
if (params.action !== "POP") return;
|
|
37
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
38
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
39
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
40
|
-
}
|
|
41
|
-
void props.router.restoreFromURL({
|
|
42
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
43
|
-
replace: true
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}, []);
|
|
47
33
|
const [config] = (0, import_hooks.useState)(
|
|
48
34
|
() => props.router.adapters.makeObservable({
|
|
49
35
|
loadedComponentName: void 0,
|
|
@@ -54,7 +40,6 @@ function RouterInner(props) {
|
|
|
54
40
|
(0, import_hooks.useState)(() => {
|
|
55
41
|
props.router.adapters.batch(() => {
|
|
56
42
|
props.beforeMount?.();
|
|
57
|
-
redirectOnHistoryPop();
|
|
58
43
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
59
44
|
disposerRef.current = props.router.adapters.autorun(
|
|
60
45
|
() => (0, import_reactive_route.routerSetLoadedComponent)(props, config)
|
package/preact/index.mjs
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
// packages/preact/Router.tsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
4
4
|
import { jsx } from "preact/jsx-runtime";
|
|
5
5
|
function RouterInner(props) {
|
|
6
6
|
const disposerRef = useRef(null);
|
|
7
|
-
const redirectOnHistoryPop = useCallback(() => {
|
|
8
|
-
if (!history) return;
|
|
9
|
-
history.listen((params) => {
|
|
10
|
-
if (params.action !== "POP") return;
|
|
11
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
12
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
13
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
14
|
-
}
|
|
15
|
-
void props.router.restoreFromURL({
|
|
16
|
-
pathname: history.location.pathname,
|
|
17
|
-
replace: true
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}, []);
|
|
21
7
|
const [config] = useState(
|
|
22
8
|
() => props.router.adapters.makeObservable({
|
|
23
9
|
loadedComponentName: void 0,
|
|
@@ -28,7 +14,6 @@ function RouterInner(props) {
|
|
|
28
14
|
useState(() => {
|
|
29
15
|
props.router.adapters.batch(() => {
|
|
30
16
|
props.beforeMount?.();
|
|
31
|
-
redirectOnHistoryPop();
|
|
32
17
|
routerSetLoadedComponent(props, config);
|
|
33
18
|
disposerRef.current = props.router.adapters.autorun(
|
|
34
19
|
() => routerSetLoadedComponent(props, config)
|
package/react/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6CtF,iBAAS,aAAa,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAK1D,GAAG,CACzC;AAED,eAAO,MAAM,MAAM,EAA0B,OAAO,aAAa,CAAC"}
|
package/react/index.cjs
CHANGED
|
@@ -30,20 +30,6 @@ var import_reactive_route = require("reactive-route");
|
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
31
|
function RouterInner(props) {
|
|
32
32
|
const disposerRef = (0, import_react.useRef)(null);
|
|
33
|
-
const redirectOnHistoryPop = (0, import_react.useCallback)(() => {
|
|
34
|
-
if (!import_reactive_route.history) return;
|
|
35
|
-
import_reactive_route.history.listen((params) => {
|
|
36
|
-
if (params.action !== "POP") return;
|
|
37
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
38
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
39
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
40
|
-
}
|
|
41
|
-
void props.router.restoreFromURL({
|
|
42
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
43
|
-
replace: true
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}, []);
|
|
47
33
|
const [config] = (0, import_react.useState)(
|
|
48
34
|
() => props.router.adapters.makeObservable({
|
|
49
35
|
loadedComponentName: void 0,
|
|
@@ -54,7 +40,6 @@ function RouterInner(props) {
|
|
|
54
40
|
(0, import_react.useState)(() => {
|
|
55
41
|
props.router.adapters.batch(() => {
|
|
56
42
|
props.beforeMount?.();
|
|
57
|
-
redirectOnHistoryPop();
|
|
58
43
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
59
44
|
disposerRef.current = props.router.adapters.autorun(
|
|
60
45
|
() => (0, import_reactive_route.routerSetLoadedComponent)(props, config)
|
package/react/index.mjs
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
// packages/react/Router.tsx
|
|
2
|
-
import { memo,
|
|
3
|
-
import {
|
|
2
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
function RouterInner(props) {
|
|
6
6
|
const disposerRef = useRef(null);
|
|
7
|
-
const redirectOnHistoryPop = useCallback(() => {
|
|
8
|
-
if (!history) return;
|
|
9
|
-
history.listen((params) => {
|
|
10
|
-
if (params.action !== "POP") return;
|
|
11
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
12
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
13
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
14
|
-
}
|
|
15
|
-
void props.router.restoreFromURL({
|
|
16
|
-
pathname: history.location.pathname,
|
|
17
|
-
replace: true
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}, []);
|
|
21
7
|
const [config] = useState(
|
|
22
8
|
() => props.router.adapters.makeObservable({
|
|
23
9
|
loadedComponentName: void 0,
|
|
@@ -28,7 +14,6 @@ function RouterInner(props) {
|
|
|
28
14
|
useState(() => {
|
|
29
15
|
props.router.adapters.batch(() => {
|
|
30
16
|
props.beforeMount?.();
|
|
31
|
-
redirectOnHistoryPop();
|
|
32
17
|
routerSetLoadedComponent(props, config);
|
|
33
18
|
disposerRef.current = props.router.adapters.autorun(
|
|
34
19
|
() => routerSetLoadedComponent(props, config)
|
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,
|
|
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,kCAkChG"}
|
package/solid/index.cjs
CHANGED
|
@@ -36,22 +36,7 @@ function Router(props) {
|
|
|
36
36
|
loadedComponentPage: void 0,
|
|
37
37
|
currentProps: {}
|
|
38
38
|
});
|
|
39
|
-
function redirectOnHistoryPop() {
|
|
40
|
-
if (!import_reactive_route.history) return;
|
|
41
|
-
import_reactive_route.history.listen((params) => {
|
|
42
|
-
if (params.action !== "POP") return;
|
|
43
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
44
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
45
|
-
props.router.routesHistory.pop();
|
|
46
|
-
}
|
|
47
|
-
void props.router.restoreFromURL({
|
|
48
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
49
|
-
replace: true
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
39
|
props.beforeMount?.();
|
|
54
|
-
redirectOnHistoryPop();
|
|
55
40
|
if (props.router.adapters.immediateSetComponent) {
|
|
56
41
|
props.router.adapters.batch(() => {
|
|
57
42
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
package/solid/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/solid/Router.tsx
|
|
2
2
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
3
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
|
-
import {
|
|
4
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
5
5
|
import { Show } from "solid-js";
|
|
6
6
|
import { Dynamic } from "solid-js/web";
|
|
7
7
|
function Router(props) {
|
|
@@ -10,22 +10,7 @@ function Router(props) {
|
|
|
10
10
|
loadedComponentPage: void 0,
|
|
11
11
|
currentProps: {}
|
|
12
12
|
});
|
|
13
|
-
function redirectOnHistoryPop() {
|
|
14
|
-
if (!history) return;
|
|
15
|
-
history.listen((params) => {
|
|
16
|
-
if (params.action !== "POP") return;
|
|
17
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
18
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
19
|
-
props.router.routesHistory.pop();
|
|
20
|
-
}
|
|
21
|
-
void props.router.restoreFromURL({
|
|
22
|
-
pathname: history.location.pathname,
|
|
23
|
-
replace: true
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
13
|
props.beforeMount?.();
|
|
28
|
-
redirectOnHistoryPop();
|
|
29
14
|
if (props.router.adapters.immediateSetComponent) {
|
|
30
15
|
props.router.adapters.batch(() => {
|
|
31
16
|
routerSetLoadedComponent(props, config);
|
package/vue/index.cjs
CHANGED
|
Binary file
|
package/vue/index.mjs
CHANGED
|
Binary file
|
package/core/utils/history.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAI/C;;;GAGG;AAEH,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAEnD,CAAC"}
|