@tanstack/react-router 0.0.1-beta.22 → 0.0.1-beta.23
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/build/cjs/react-router/src/index.js +9 -2
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +16 -12
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +25 -15
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/types/index.d.ts +6 -2
- package/build/umd/index.development.js +25 -14
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +19 -3
package/build/stats-html.html
CHANGED
|
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
|
|
|
4014
4014
|
</script>
|
|
4015
4015
|
<script>
|
|
4016
4016
|
/*<!--*/
|
|
4017
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"db96-59","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"db96-61"},{"name":"react-router/src/index.tsx","uid":"db96-63"}]}]}],"isRoot":true},"nodeParts":{"db96-59":{"renderedLength":798,"gzipLength":366,"brotliLength":0,"mainUid":"db96-58"},"db96-61":{"renderedLength":75369,"gzipLength":15785,"brotliLength":0,"mainUid":"db96-60"},"db96-63":{"renderedLength":13128,"gzipLength":3268,"brotliLength":0,"mainUid":"db96-62"}},"nodeMetas":{"db96-58":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"db96-59"},"imported":[],"importedBy":[{"uid":"db96-62"}]},"db96-60":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"db96-61"},"imported":[],"importedBy":[{"uid":"db96-62"}]},"db96-62":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"db96-63"},"imported":[{"uid":"db96-58"},{"uid":"db96-64"},{"uid":"db96-65"},{"uid":"db96-60"}],"importedBy":[],"isEntry":true},"db96-64":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"db96-62"}],"isExternal":true},"db96-65":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"db96-62"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4018
4018
|
|
|
4019
4019
|
const run = () => {
|
|
4020
4020
|
const width = window.innerWidth;
|
package/build/stats-react.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "index.production.js",
|
|
8
8
|
"children": [
|
|
9
9
|
{
|
|
10
|
-
"uid": "
|
|
10
|
+
"uid": "db96-67",
|
|
11
11
|
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"children": [
|
|
16
16
|
{
|
|
17
17
|
"name": "router-core/build/esm/index.js",
|
|
18
|
-
"uid": "
|
|
18
|
+
"uid": "db96-69"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "react-router/src/index.tsx",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "db96-71"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -29,90 +29,90 @@
|
|
|
29
29
|
"isRoot": true
|
|
30
30
|
},
|
|
31
31
|
"nodeParts": {
|
|
32
|
-
"
|
|
32
|
+
"db96-67": {
|
|
33
33
|
"renderedLength": 798,
|
|
34
34
|
"gzipLength": 366,
|
|
35
35
|
"brotliLength": 0,
|
|
36
|
-
"mainUid": "
|
|
36
|
+
"mainUid": "db96-66"
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
"renderedLength":
|
|
40
|
-
"gzipLength":
|
|
38
|
+
"db96-69": {
|
|
39
|
+
"renderedLength": 75369,
|
|
40
|
+
"gzipLength": 15785,
|
|
41
41
|
"brotliLength": 0,
|
|
42
|
-
"mainUid": "
|
|
42
|
+
"mainUid": "db96-68"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
"renderedLength":
|
|
46
|
-
"gzipLength":
|
|
44
|
+
"db96-71": {
|
|
45
|
+
"renderedLength": 13128,
|
|
46
|
+
"gzipLength": 3268,
|
|
47
47
|
"brotliLength": 0,
|
|
48
|
-
"mainUid": "
|
|
48
|
+
"mainUid": "db96-70"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"nodeMetas": {
|
|
52
|
-
"
|
|
52
|
+
"db96-66": {
|
|
53
53
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
54
54
|
"moduleParts": {
|
|
55
|
-
"index.production.js": "
|
|
55
|
+
"index.production.js": "db96-67"
|
|
56
56
|
},
|
|
57
57
|
"imported": [],
|
|
58
58
|
"importedBy": [
|
|
59
59
|
{
|
|
60
|
-
"uid": "
|
|
60
|
+
"uid": "db96-70"
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
"
|
|
64
|
+
"db96-68": {
|
|
65
65
|
"id": "/packages/router-core/build/esm/index.js",
|
|
66
66
|
"moduleParts": {
|
|
67
|
-
"index.production.js": "
|
|
67
|
+
"index.production.js": "db96-69"
|
|
68
68
|
},
|
|
69
69
|
"imported": [],
|
|
70
70
|
"importedBy": [
|
|
71
71
|
{
|
|
72
|
-
"uid": "
|
|
72
|
+
"uid": "db96-70"
|
|
73
73
|
}
|
|
74
74
|
]
|
|
75
75
|
},
|
|
76
|
-
"
|
|
76
|
+
"db96-70": {
|
|
77
77
|
"id": "/packages/react-router/src/index.tsx",
|
|
78
78
|
"moduleParts": {
|
|
79
|
-
"index.production.js": "
|
|
79
|
+
"index.production.js": "db96-71"
|
|
80
80
|
},
|
|
81
81
|
"imported": [
|
|
82
82
|
{
|
|
83
|
-
"uid": "
|
|
83
|
+
"uid": "db96-66"
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
"uid": "
|
|
86
|
+
"uid": "db96-72"
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
"uid": "
|
|
89
|
+
"uid": "db96-73"
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
|
-
"uid": "
|
|
92
|
+
"uid": "db96-68"
|
|
93
93
|
}
|
|
94
94
|
],
|
|
95
95
|
"importedBy": [],
|
|
96
96
|
"isEntry": true
|
|
97
97
|
},
|
|
98
|
-
"
|
|
98
|
+
"db96-72": {
|
|
99
99
|
"id": "react",
|
|
100
100
|
"moduleParts": {},
|
|
101
101
|
"imported": [],
|
|
102
102
|
"importedBy": [
|
|
103
103
|
{
|
|
104
|
-
"uid": "
|
|
104
|
+
"uid": "db96-70"
|
|
105
105
|
}
|
|
106
106
|
],
|
|
107
107
|
"isExternal": true
|
|
108
108
|
},
|
|
109
|
-
"
|
|
109
|
+
"db96-73": {
|
|
110
110
|
"id": "use-sync-external-store/shim",
|
|
111
111
|
"moduleParts": {},
|
|
112
112
|
"imported": [],
|
|
113
113
|
"importedBy": [
|
|
114
114
|
{
|
|
115
|
-
"uid": "
|
|
115
|
+
"uid": "db96-70"
|
|
116
116
|
}
|
|
117
117
|
],
|
|
118
118
|
"isExternal": true
|
package/build/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import { AnyRouteConfig, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch, RouteInfo, DefaultAllRouteInfo, AnyRouteInfo, ResolveRelativePath, NoInfer, CheckId, ToIdOption, Router, ValidFromPath, ToOptions, MatchRouteOptions, RouteInfoByPath, RouterOptions, Route, LinkOptions } from '@tanstack/router-core';
|
|
12
|
+
import { AnyRouteConfig, RouterContext, RouteConfig, AnyAllRouteInfo, AllRouteInfo, RouterState, RouteMatch, RouteInfo, DefaultAllRouteInfo, AnyRouteInfo, ResolveRelativePath, NoInfer, CheckId, ToIdOption, Router, ValidFromPath, ToOptions, MatchRouteOptions, RouteInfoByPath, RouterOptions, Route, LinkOptions } from '@tanstack/router-core';
|
|
13
13
|
export * from '@tanstack/router-core';
|
|
14
14
|
|
|
15
15
|
interface RegisterRouter {
|
|
@@ -44,6 +44,9 @@ declare module '@tanstack/router-core' {
|
|
|
44
44
|
interface FrameworkGenerics {
|
|
45
45
|
Component: RouteComponent;
|
|
46
46
|
}
|
|
47
|
+
interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
48
|
+
useContext?: () => RouterContext;
|
|
49
|
+
}
|
|
47
50
|
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
|
|
48
51
|
useState: () => RouterState;
|
|
49
52
|
useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(routeId: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
|
|
@@ -92,6 +95,7 @@ declare function useMatch<TId extends keyof RegisteredAllRouteInfo['routeInfoByI
|
|
|
92
95
|
}): TStrict extends true ? RouteMatch<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> : RouteMatch<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> | undefined;
|
|
93
96
|
declare function useNearestMatch(): RouteMatch<RegisteredAllRouteInfo, RouteInfo>;
|
|
94
97
|
declare function useRoute<TId extends keyof RegisteredAllRouteInfo['routeInfoById']>(routeId: TId): Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]>;
|
|
98
|
+
declare function useSearch<TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = keyof RegisteredAllRouteInfo['routeInfoById']>(_routeId?: TId): RegisteredAllRouteInfo['fullSearchSchema'];
|
|
95
99
|
declare function linkProps<TTo extends string = '.'>(props: MakeLinkPropsOptions<RegisteredAllRouteInfo, '/', TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
96
100
|
declare function MatchRoute<TTo extends string = '.'>(props: MakeMatchRouteOptions<RegisteredAllRouteInfo, '/', TTo>): JSX.Element;
|
|
97
101
|
declare function Outlet(): JSX.Element | null;
|
|
@@ -101,4 +105,4 @@ declare function DefaultErrorBoundary({ error }: {
|
|
|
101
105
|
declare function usePrompt(message: string, when: boolean | any): void;
|
|
102
106
|
declare function Prompt({ message, when, children }: PromptProps): React.ReactNode;
|
|
103
107
|
|
|
104
|
-
export { DefaultErrorBoundary, Link, MatchRoute, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, createReactRouter, lazy, linkProps, matchesContext, routerContext, useMatch, useMatches, useNearestMatch, usePrompt, useRoute, useRouter };
|
|
108
|
+
export { DefaultErrorBoundary, Link, MatchRoute, MatchesProvider, MatchesProviderProps, Outlet, Prompt, PromptProps, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, createReactRouter, lazy, linkProps, matchesContext, routerContext, useMatch, useMatches, useNearestMatch, usePrompt, useRoute, useRouter, useSearch };
|
|
@@ -893,12 +893,6 @@
|
|
|
893
893
|
throw new Error(value);
|
|
894
894
|
}
|
|
895
895
|
|
|
896
|
-
// type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
897
|
-
// k: infer I,
|
|
898
|
-
// ) => any
|
|
899
|
-
// ? I
|
|
900
|
-
// : never
|
|
901
|
-
|
|
902
896
|
/**
|
|
903
897
|
* This function returns `a` if `b` is deeply equal.
|
|
904
898
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
@@ -1120,10 +1114,7 @@
|
|
|
1120
1114
|
|
|
1121
1115
|
if (matchLocation.to && !pathParams) {
|
|
1122
1116
|
return;
|
|
1123
|
-
}
|
|
1124
|
-
// return
|
|
1125
|
-
// }
|
|
1126
|
-
|
|
1117
|
+
}
|
|
1127
1118
|
|
|
1128
1119
|
return pathParams != null ? pathParams : {};
|
|
1129
1120
|
}
|
|
@@ -1733,6 +1724,7 @@
|
|
|
1733
1724
|
options: originalOptions,
|
|
1734
1725
|
listeners: [],
|
|
1735
1726
|
// Resolved after construction
|
|
1727
|
+
context: {},
|
|
1736
1728
|
basepath: '',
|
|
1737
1729
|
routeTree: undefined,
|
|
1738
1730
|
routesById: {},
|
|
@@ -1877,7 +1869,19 @@
|
|
|
1877
1869
|
|
|
1878
1870
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1879
1871
|
strictParseParams: true
|
|
1880
|
-
});
|
|
1872
|
+
}); // Check if each match middleware to see if the route can be accessed
|
|
1873
|
+
|
|
1874
|
+
try {
|
|
1875
|
+
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
1876
|
+
context: router.context
|
|
1877
|
+
})));
|
|
1878
|
+
} catch (err) {
|
|
1879
|
+
if (err != null && err.then) {
|
|
1880
|
+
await new Promise(() => {});
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
throw err;
|
|
1884
|
+
}
|
|
1881
1885
|
|
|
1882
1886
|
if (typeof document !== 'undefined') {
|
|
1883
1887
|
router.state = _extends({}, router.state, {
|
|
@@ -1947,7 +1951,7 @@
|
|
|
1947
1951
|
});
|
|
1948
1952
|
});
|
|
1949
1953
|
entering.forEach(d => {
|
|
1950
|
-
d.__.onExit = d.options.
|
|
1954
|
+
d.__.onExit = d.options.onLoaded == null ? void 0 : d.options.onLoaded({
|
|
1951
1955
|
params: d.params,
|
|
1952
1956
|
search: d.search
|
|
1953
1957
|
});
|
|
@@ -2745,6 +2749,8 @@
|
|
|
2745
2749
|
return coreRouter;
|
|
2746
2750
|
}
|
|
2747
2751
|
function RouterProvider(_ref2) {
|
|
2752
|
+
var _router$options$useCo;
|
|
2753
|
+
|
|
2748
2754
|
let {
|
|
2749
2755
|
children,
|
|
2750
2756
|
router
|
|
@@ -2752,9 +2758,11 @@
|
|
|
2752
2758
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
2753
2759
|
|
|
2754
2760
|
router.update(rest);
|
|
2761
|
+
const defaultRouterContext = React__namespace.useRef({});
|
|
2762
|
+
const userContext = (_router$options$useCo = router.options.useContext == null ? void 0 : router.options.useContext()) != null ? _router$options$useCo : defaultRouterContext.current;
|
|
2763
|
+
router.context = userContext;
|
|
2755
2764
|
useRouterSubscription(router);
|
|
2756
2765
|
React__namespace.useEffect(() => {
|
|
2757
|
-
console.log('hello');
|
|
2758
2766
|
return router.mount();
|
|
2759
2767
|
}, [router]);
|
|
2760
2768
|
return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
|
|
@@ -2789,6 +2797,9 @@
|
|
|
2789
2797
|
const router = useRouter();
|
|
2790
2798
|
return router.useRoute(routeId);
|
|
2791
2799
|
}
|
|
2800
|
+
function useSearch(_routeId) {
|
|
2801
|
+
return useRouter().state.location.search;
|
|
2802
|
+
}
|
|
2792
2803
|
function linkProps(props) {
|
|
2793
2804
|
const router = useRouter();
|
|
2794
2805
|
return router.linkProps(props);
|
|
@@ -2828,7 +2839,6 @@
|
|
|
2828
2839
|
return /*#__PURE__*/React__namespace.createElement((_ref4 = (_ref5 = match.__.component) != null ? _ref5 : router.options.defaultComponent) != null ? _ref4 : Outlet);
|
|
2829
2840
|
}
|
|
2830
2841
|
|
|
2831
|
-
console.log(match.matchId, 'suspend');
|
|
2832
2842
|
throw match.__.loadPromise;
|
|
2833
2843
|
})())));
|
|
2834
2844
|
}
|
|
@@ -2962,6 +2972,7 @@
|
|
|
2962
2972
|
exports.usePrompt = usePrompt;
|
|
2963
2973
|
exports.useRoute = useRoute;
|
|
2964
2974
|
exports.useRouter = useRouter;
|
|
2975
|
+
exports.useSearch = useSearch;
|
|
2965
2976
|
exports.warning = warning;
|
|
2966
2977
|
|
|
2967
2978
|
Object.defineProperty(exports, '__esModule', { value: true });
|