@tanstack/react-router 0.0.1-beta.23 → 0.0.1-beta.231

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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/CatchBoundary.js +123 -0
  3. package/build/cjs/CatchBoundary.js.map +1 -0
  4. package/build/cjs/Matches.js +235 -0
  5. package/build/cjs/Matches.js.map +1 -0
  6. package/build/cjs/RouterProvider.js +159 -0
  7. package/build/cjs/RouterProvider.js.map +1 -0
  8. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +2 -22
  9. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  10. package/build/cjs/awaited.js +43 -0
  11. package/build/cjs/awaited.js.map +1 -0
  12. package/build/cjs/defer.js +37 -0
  13. package/build/cjs/defer.js.map +1 -0
  14. package/build/cjs/fileRoute.js +27 -0
  15. package/build/cjs/fileRoute.js.map +1 -0
  16. package/build/cjs/index.js +123 -0
  17. package/build/cjs/index.js.map +1 -0
  18. package/build/cjs/lazyRouteComponent.js +54 -0
  19. package/build/cjs/lazyRouteComponent.js.map +1 -0
  20. package/build/cjs/link.js +148 -0
  21. package/build/cjs/link.js.map +1 -0
  22. package/build/cjs/path.js +209 -0
  23. package/build/cjs/path.js.map +1 -0
  24. package/build/cjs/qss.js +63 -0
  25. package/build/cjs/qss.js.map +1 -0
  26. package/build/cjs/redirects.js +25 -0
  27. package/build/cjs/redirects.js.map +1 -0
  28. package/build/cjs/route.js +134 -0
  29. package/build/cjs/route.js.map +1 -0
  30. package/build/cjs/router.js +1101 -0
  31. package/build/cjs/router.js.map +1 -0
  32. package/build/cjs/scroll-restoration.js +202 -0
  33. package/build/cjs/scroll-restoration.js.map +1 -0
  34. package/build/cjs/searchParams.js +81 -0
  35. package/build/cjs/searchParams.js.map +1 -0
  36. package/build/cjs/useBlocker.js +61 -0
  37. package/build/cjs/useBlocker.js.map +1 -0
  38. package/build/cjs/useNavigate.js +75 -0
  39. package/build/cjs/useNavigate.js.map +1 -0
  40. package/build/cjs/useParams.js +26 -0
  41. package/build/cjs/useParams.js.map +1 -0
  42. package/build/cjs/useSearch.js +25 -0
  43. package/build/cjs/useSearch.js.map +1 -0
  44. package/build/cjs/utils.js +239 -0
  45. package/build/cjs/utils.js.map +1 -0
  46. package/build/esm/index.js +2174 -2557
  47. package/build/esm/index.js.map +1 -1
  48. package/build/stats-html.html +3498 -2694
  49. package/build/stats-react.json +927 -42
  50. package/build/types/CatchBoundary.d.ts +33 -0
  51. package/build/types/Matches.d.ts +57 -0
  52. package/build/types/RouterProvider.d.ts +41 -0
  53. package/build/types/awaited.d.ts +9 -0
  54. package/build/types/defer.d.ts +19 -0
  55. package/build/types/fileRoute.d.ts +35 -0
  56. package/build/types/history.d.ts +7 -0
  57. package/build/types/index.d.ts +27 -108
  58. package/build/types/injectHtml.d.ts +0 -0
  59. package/build/types/lazyRouteComponent.d.ts +2 -0
  60. package/build/types/link.d.ts +105 -0
  61. package/build/types/location.d.ts +14 -0
  62. package/build/types/path.d.ts +16 -0
  63. package/build/types/qss.d.ts +2 -0
  64. package/build/types/redirects.d.ts +10 -0
  65. package/build/types/route.d.ts +278 -0
  66. package/build/types/routeInfo.d.ts +22 -0
  67. package/build/types/router.d.ts +167 -0
  68. package/build/types/scroll-restoration.d.ts +18 -0
  69. package/build/types/searchParams.d.ts +7 -0
  70. package/build/types/useBlocker.d.ts +8 -0
  71. package/build/types/useNavigate.d.ts +20 -0
  72. package/build/types/useParams.d.ts +7 -0
  73. package/build/types/useSearch.d.ts +7 -0
  74. package/build/types/utils.d.ts +66 -0
  75. package/build/umd/index.development.js +2470 -2513
  76. package/build/umd/index.development.js.map +1 -1
  77. package/build/umd/index.production.js +4 -4
  78. package/build/umd/index.production.js.map +1 -1
  79. package/package.json +9 -10
  80. package/src/CatchBoundary.tsx +98 -0
  81. package/src/Matches.tsx +389 -0
  82. package/src/RouterProvider.tsx +226 -0
  83. package/src/awaited.tsx +40 -0
  84. package/src/defer.ts +55 -0
  85. package/src/fileRoute.ts +154 -0
  86. package/src/history.ts +8 -0
  87. package/src/index.tsx +28 -709
  88. package/src/injectHtml.ts +28 -0
  89. package/src/lazyRouteComponent.tsx +33 -0
  90. package/src/link.tsx +508 -0
  91. package/src/location.ts +15 -0
  92. package/src/path.ts +256 -0
  93. package/src/qss.ts +53 -0
  94. package/src/redirects.ts +31 -0
  95. package/src/route.ts +861 -0
  96. package/src/routeInfo.ts +68 -0
  97. package/src/router.ts +1664 -0
  98. package/src/scroll-restoration.tsx +230 -0
  99. package/src/searchParams.ts +79 -0
  100. package/src/useBlocker.tsx +34 -0
  101. package/src/useNavigate.tsx +109 -0
  102. package/src/useParams.tsx +25 -0
  103. package/src/useSearch.tsx +25 -0
  104. package/src/utils.ts +350 -0
  105. package/build/cjs/react-router/src/index.js +0 -473
  106. package/build/cjs/react-router/src/index.js.map +0 -1
  107. package/build/cjs/router-core/build/esm/index.js +0 -2527
  108. package/build/cjs/router-core/build/esm/index.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @tanstack/react-router/src/index.tsx
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ var React = require('react');
14
+
15
+ function _interopNamespaceDefault(e) {
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
33
+
34
+ function CatchBoundary(props) {
35
+ const errorComponent = props.errorComponent ?? ErrorComponent;
36
+ return /*#__PURE__*/React__namespace.createElement(CatchBoundaryImpl, {
37
+ resetKey: props.resetKey,
38
+ onCatch: props.onCatch,
39
+ children: ({
40
+ error
41
+ }) => {
42
+ if (error) {
43
+ return /*#__PURE__*/React__namespace.createElement(errorComponent, {
44
+ error
45
+ });
46
+ }
47
+ return props.children;
48
+ }
49
+ });
50
+ }
51
+ class CatchBoundaryImpl extends React__namespace.Component {
52
+ state = {
53
+ error: null
54
+ };
55
+ static getDerivedStateFromError(error) {
56
+ return {
57
+ error
58
+ };
59
+ }
60
+ componentDidUpdate(prevProps, prevState) {
61
+ if (prevState.error && prevProps.resetKey !== this.props.resetKey) {
62
+ this.setState({
63
+ error: null
64
+ });
65
+ }
66
+ }
67
+ componentDidCatch(error) {
68
+ console.error(error);
69
+ this.props.onCatch?.(error);
70
+ }
71
+ render() {
72
+ return this.props.children(this.state);
73
+ }
74
+ }
75
+ function ErrorComponent({
76
+ error
77
+ }) {
78
+ const [show, setShow] = React__namespace.useState(process.env.NODE_ENV !== 'production');
79
+ return /*#__PURE__*/React__namespace.createElement("div", {
80
+ style: {
81
+ padding: '.5rem',
82
+ maxWidth: '100%'
83
+ }
84
+ }, /*#__PURE__*/React__namespace.createElement("div", {
85
+ style: {
86
+ display: 'flex',
87
+ alignItems: 'center',
88
+ gap: '.5rem'
89
+ }
90
+ }, /*#__PURE__*/React__namespace.createElement("strong", {
91
+ style: {
92
+ fontSize: '1rem'
93
+ }
94
+ }, "Something went wrong!"), /*#__PURE__*/React__namespace.createElement("button", {
95
+ style: {
96
+ appearance: 'none',
97
+ fontSize: '.6em',
98
+ border: '1px solid currentColor',
99
+ padding: '.1rem .2rem',
100
+ fontWeight: 'bold',
101
+ borderRadius: '.25rem'
102
+ },
103
+ onClick: () => setShow(d => !d)
104
+ }, show ? 'Hide Error' : 'Show Error')), /*#__PURE__*/React__namespace.createElement("div", {
105
+ style: {
106
+ height: '.25rem'
107
+ }
108
+ }), show ? /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", {
109
+ style: {
110
+ fontSize: '.7em',
111
+ border: '1px solid red',
112
+ borderRadius: '.25rem',
113
+ padding: '.3rem',
114
+ color: 'red',
115
+ overflow: 'auto'
116
+ }
117
+ }, error.message ? /*#__PURE__*/React__namespace.createElement("code", null, error.message) : null)) : null);
118
+ }
119
+
120
+ exports.CatchBoundary = CatchBoundary;
121
+ exports.CatchBoundaryImpl = CatchBoundaryImpl;
122
+ exports.ErrorComponent = ErrorComponent;
123
+ //# sourceMappingURL=CatchBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatchBoundary.js","sources":["../../src/CatchBoundary.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function CatchBoundary(props: {\n resetKey: string\n children: any\n errorComponent?: any\n onCatch: (error: any) => void\n}) {\n const errorComponent = props.errorComponent ?? ErrorComponent\n\n return (\n <CatchBoundaryImpl\n resetKey={props.resetKey}\n onCatch={props.onCatch}\n children={({ error }) => {\n if (error) {\n return React.createElement(errorComponent, {\n error,\n })\n }\n\n return props.children\n }}\n />\n )\n}\n\nexport class CatchBoundaryImpl extends React.Component<{\n resetKey: string\n children: (props: { error: any; reset: () => void }) => any\n onCatch?: (error: any) => void\n}> {\n state = { error: null } as any\n static getDerivedStateFromError(error: any) {\n return { error }\n }\n componentDidUpdate(\n prevProps: Readonly<{\n resetKey: string\n children: (props: { error: any; reset: () => void }) => any\n onCatch?: ((error: any, info: any) => void) | undefined\n }>,\n prevState: any,\n ): void {\n if (prevState.error && prevProps.resetKey !== this.props.resetKey) {\n this.setState({ error: null })\n }\n }\n componentDidCatch(error: any) {\n console.error(error)\n this.props.onCatch?.(error)\n }\n render() {\n return this.props.children(this.state)\n }\n}\n\nexport function ErrorComponent({ error }: { error: any }) {\n const [show, setShow] = React.useState(process.env.NODE_ENV !== 'production')\n\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <div style={{ display: 'flex', alignItems: 'center', gap: '.5rem' }}>\n <strong style={{ fontSize: '1rem' }}>Something went wrong!</strong>\n <button\n style={{\n appearance: 'none',\n fontSize: '.6em',\n border: '1px solid currentColor',\n padding: '.1rem .2rem',\n fontWeight: 'bold',\n borderRadius: '.25rem',\n }}\n onClick={() => setShow((d) => !d)}\n >\n {show ? 'Hide Error' : 'Show Error'}\n </button>\n </div>\n <div style={{ height: '.25rem' }} />\n {show ? (\n <div>\n <pre\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.3rem',\n color: 'red',\n overflow: 'auto',\n }}\n >\n {error.message ? <code>{error.message}</code> : null}\n </pre>\n </div>\n ) : null}\n </div>\n )\n}\n"],"names":["CatchBoundary","props","errorComponent","ErrorComponent","React","createElement","CatchBoundaryImpl","resetKey","onCatch","children","error","Component","state","getDerivedStateFromError","componentDidUpdate","prevProps","prevState","setState","componentDidCatch","console","render","show","setShow","useState","process","env","NODE_ENV","style","padding","maxWidth","display","alignItems","gap","fontSize","appearance","border","fontWeight","borderRadius","onClick","d","height","color","overflow","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAASA,aAAaA,CAACC,KAK7B,EAAE;AACD,EAAA,MAAMC,cAAc,GAAGD,KAAK,CAACC,cAAc,IAAIC,cAAc,CAAA;AAE7D,EAAA,oBACEC,gBAAA,CAAAC,aAAA,CAACC,iBAAiB,EAAA;IAChBC,QAAQ,EAAEN,KAAK,CAACM,QAAS;IACzBC,OAAO,EAAEP,KAAK,CAACO,OAAQ;AACvBC,IAAAA,QAAQ,EAAEA,CAAC;AAAEC,MAAAA,KAAAA;AAAM,KAAC,KAAK;AACvB,MAAA,IAAIA,KAAK,EAAE;AACT,QAAA,oBAAON,gBAAK,CAACC,aAAa,CAACH,cAAc,EAAE;AACzCQ,UAAAA,KAAAA;AACF,SAAC,CAAC,CAAA;AACJ,OAAA;MAEA,OAAOT,KAAK,CAACQ,QAAQ,CAAA;AACvB,KAAA;AAAE,GACH,CAAC,CAAA;AAEN,CAAA;AAEO,MAAMH,iBAAiB,SAASF,gBAAK,CAACO,SAAS,CAInD;AACDC,EAAAA,KAAK,GAAG;AAAEF,IAAAA,KAAK,EAAE,IAAA;GAAM,CAAA;EACvB,OAAOG,wBAAwBA,CAACH,KAAU,EAAE;IAC1C,OAAO;AAAEA,MAAAA,KAAAA;KAAO,CAAA;AAClB,GAAA;AACAI,EAAAA,kBAAkBA,CAChBC,SAIE,EACFC,SAAc,EACR;AACN,IAAA,IAAIA,SAAS,CAACN,KAAK,IAAIK,SAAS,CAACR,QAAQ,KAAK,IAAI,CAACN,KAAK,CAACM,QAAQ,EAAE;MACjE,IAAI,CAACU,QAAQ,CAAC;AAAEP,QAAAA,KAAK,EAAE,IAAA;AAAK,OAAC,CAAC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CP,MAAAA,OAAO,EAAE,aAAa;AACtBQ,MAAAA,UAAU,EAAE,MAAM;AAClBC,MAAAA,YAAY,EAAE,QAAA;KACd;IACFC,OAAO,EAAEA,MAAMhB,OAAO,CAAEiB,CAAC,IAAK,CAACA,CAAC,CAAA;GAE/BlB,EAAAA,IAAI,GAAG,YAAY,GAAG,YACjB,CACL,CAAC,eACNjB,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKsB,IAAAA,KAAK,EAAE;AAAEa,MAAAA,MAAM,EAAE,QAAA;AAAS,KAAA;GAAI,CAAC,EACnCnB,IAAI,gBACHjB,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAA,IAAA,eACED,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACEsB,IAAAA,KAAK,EAAE;AACLM,MAAAA,QAAQ,EAAE,MAAM;AAChBE,MAAAA,MAAM,EAAE,eAAe;AACvBE,MAAAA,YAAY,EAAE,QAAQ;AACtBT,MAAAA,OAAO,EAAE,OAAO;AAChBa,MAAAA,KAAK,EAAE,KAAK;AACZC,MAAAA,QAAQ,EAAE,MAAA;AACZ,KAAA;AAAE,GAAA,EAEDhC,KAAK,CAACiC,OAAO,gBAAGvC,gBAAA,CAAAC,aAAA,CAAOK,MAAAA,EAAAA,IAAAA,EAAAA,KAAK,CAACiC,OAAc,CAAC,GAAG,IAC7C,CACF,CAAC,GACJ,IACD,CAAC,CAAA;AAEV;;;;;;"}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * @tanstack/react-router/src/index.tsx
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ var React = require('react');
14
+ var invariant = require('tiny-invariant');
15
+ var warning = require('tiny-warning');
16
+ var CatchBoundary = require('./CatchBoundary.js');
17
+ var RouterProvider = require('./RouterProvider.js');
18
+ var route = require('./route.js');
19
+
20
+ function _interopNamespaceDefault(e) {
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n.default = e;
34
+ return Object.freeze(n);
35
+ }
36
+
37
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
38
+
39
+ function Matches() {
40
+ const {
41
+ routesById,
42
+ state
43
+ } = RouterProvider.useRouter();
44
+ const {
45
+ matches
46
+ } = state;
47
+ const locationKey = RouterProvider.useRouterState().location.state.key;
48
+ const route$1 = routesById[route.rootRouteId];
49
+ const errorComponent = React__namespace.useCallback(props => {
50
+ return /*#__PURE__*/React__namespace.createElement(CatchBoundary.ErrorComponent, {
51
+ ...props,
52
+ useMatch: route$1.useMatch,
53
+ useRouteContext: route$1.useRouteContext,
54
+ useSearch: route$1.useSearch,
55
+ useParams: route$1.useParams
56
+ });
57
+ }, [route$1]);
58
+ return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
59
+ value: matches
60
+ }, /*#__PURE__*/React__namespace.createElement(CatchBoundary.CatchBoundary, {
61
+ resetKey: locationKey,
62
+ errorComponent: errorComponent,
63
+ onCatch: () => {
64
+ warning(false, `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`);
65
+ }
66
+ }, matches.length ? /*#__PURE__*/React__namespace.createElement(Match, {
67
+ matches: matches
68
+ }) : null));
69
+ }
70
+ function SafeFragment(props) {
71
+ return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, props.children);
72
+ }
73
+ function Match({
74
+ matches
75
+ }) {
76
+ const {
77
+ options,
78
+ routesById
79
+ } = RouterProvider.useRouter();
80
+ const match = matches[0];
81
+ const routeId = match?.routeId;
82
+ const route = routesById[routeId];
83
+ const router = RouterProvider.useRouter();
84
+ const locationKey = router.latestLocation.state?.key;
85
+ // const locationKey = useRouterState().location.state?.key
86
+
87
+ const PendingComponent = route.options.pendingComponent ?? options.defaultPendingComponent;
88
+ const pendingElement = PendingComponent ? /*#__PURE__*/React__namespace.createElement(PendingComponent, {
89
+ useMatch: route.useMatch,
90
+ useRouteContext: route.useRouteContext,
91
+ useSearch: route.useSearch,
92
+ useParams: route.useParams
93
+ }) : undefined;
94
+ const routeErrorComponent = route.options.errorComponent ?? options.defaultErrorComponent ?? CatchBoundary.ErrorComponent;
95
+ const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? pendingElement ? React__namespace.Suspense : SafeFragment;
96
+ const errorComponent = routeErrorComponent ? React__namespace.useCallback(props => {
97
+ return /*#__PURE__*/React__namespace.createElement(routeErrorComponent, {
98
+ ...props,
99
+ useMatch: route.useMatch,
100
+ useRouteContext: route.useRouteContext,
101
+ useSearch: route.useSearch,
102
+ useParams: route.useParams
103
+ });
104
+ }, [route]) : undefined;
105
+ const ResolvedCatchBoundary = errorComponent ? CatchBoundary.CatchBoundary : SafeFragment;
106
+ return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
107
+ value: matches
108
+ }, /*#__PURE__*/React__namespace.createElement(ResolvedSuspenseBoundary, {
109
+ fallback: pendingElement
110
+ }, /*#__PURE__*/React__namespace.createElement(ResolvedCatchBoundary, {
111
+ resetKey: locationKey,
112
+ errorComponent: errorComponent,
113
+ onCatch: () => {
114
+ warning(false, `Error in route match: ${match.id}`);
115
+ }
116
+ }, /*#__PURE__*/React__namespace.createElement(MatchInner, {
117
+ match: match,
118
+ pendingElement: pendingElement
119
+ }))));
120
+ }
121
+ function MatchInner({
122
+ match,
123
+ pendingElement
124
+ }) {
125
+ const {
126
+ options,
127
+ routesById
128
+ } = RouterProvider.useRouter();
129
+ const route = routesById[match.routeId];
130
+ if (match.status === 'error') {
131
+ throw match.error;
132
+ }
133
+ if (match.status === 'pending') {
134
+ if (match.showPending) {
135
+ return pendingElement || null;
136
+ }
137
+ throw match.loadPromise;
138
+ }
139
+ if (match.status === 'success') {
140
+ let comp = route.options.component ?? options.defaultComponent;
141
+ if (comp) {
142
+ return /*#__PURE__*/React__namespace.createElement(comp, {
143
+ useMatch: route.useMatch,
144
+ useRouteContext: route.useRouteContext,
145
+ useSearch: route.useSearch,
146
+ useParams: route.useParams,
147
+ useLoaderData: route.useLoaderData
148
+ });
149
+ }
150
+ return /*#__PURE__*/React__namespace.createElement(Outlet, null);
151
+ }
152
+ invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
153
+ }
154
+ function Outlet() {
155
+ const matches = React__namespace.useContext(matchesContext).slice(1);
156
+ if (!matches[0]) {
157
+ return null;
158
+ }
159
+ return /*#__PURE__*/React__namespace.createElement(Match, {
160
+ matches: matches
161
+ });
162
+ }
163
+ function useMatchRoute() {
164
+ const {
165
+ matchRoute
166
+ } = RouterProvider.useRouter();
167
+ return React__namespace.useCallback(opts => {
168
+ const {
169
+ pending,
170
+ caseSensitive,
171
+ ...rest
172
+ } = opts;
173
+ return matchRoute(rest, {
174
+ pending,
175
+ caseSensitive
176
+ });
177
+ }, []);
178
+ }
179
+ function MatchRoute(props) {
180
+ const matchRoute = useMatchRoute();
181
+ const params = matchRoute(props);
182
+ if (typeof props.children === 'function') {
183
+ return props.children(params);
184
+ }
185
+ return !!params ? props.children : null;
186
+ }
187
+ function useMatch(opts) {
188
+ const nearestMatch = React__namespace.useContext(matchesContext)[0];
189
+ const nearestMatchRouteId = nearestMatch?.routeId;
190
+ const matchRouteId = RouterProvider.useRouterState({
191
+ select: state => {
192
+ const match = opts?.from ? state.matches.find(d => d.routeId === opts?.from) : state.matches.find(d => d.id === nearestMatch.id);
193
+ return match.routeId;
194
+ }
195
+ });
196
+ if (opts?.strict ?? true) {
197
+ invariant(nearestMatchRouteId == matchRouteId, `useMatch("${matchRouteId}") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch("${matchRouteId}", { strict: false })' or 'useRoute("${matchRouteId}")' instead?`);
198
+ }
199
+ const matchSelection = RouterProvider.useRouterState({
200
+ select: state => {
201
+ const match = opts?.from ? state.matches.find(d => d.routeId === opts?.from) : state.matches.find(d => d.id === nearestMatch.id);
202
+ invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
203
+ return opts?.select ? opts.select(match) : match;
204
+ }
205
+ });
206
+ return matchSelection;
207
+ }
208
+ const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
209
+ function useMatches(opts) {
210
+ const contextMatches = React__namespace.useContext(matchesContext);
211
+ return RouterProvider.useRouterState({
212
+ select: state => {
213
+ const matches = state.matches.slice(state.matches.findIndex(d => d.id === contextMatches[0]?.id));
214
+ return opts?.select ? opts.select(matches) : matches;
215
+ }
216
+ });
217
+ }
218
+ function useLoaderData(opts) {
219
+ const match = useMatch({
220
+ ...opts,
221
+ select: undefined
222
+ });
223
+ return typeof opts.select === 'function' ? opts.select(match?.loaderData) : match?.loaderData;
224
+ }
225
+
226
+ exports.Match = Match;
227
+ exports.MatchRoute = MatchRoute;
228
+ exports.Matches = Matches;
229
+ exports.Outlet = Outlet;
230
+ exports.matchesContext = matchesContext;
231
+ exports.useLoaderData = useLoaderData;
232
+ exports.useMatch = useMatch;
233
+ exports.useMatchRoute = useMatchRoute;
234
+ exports.useMatches = useMatches;
235
+ //# sourceMappingURL=Matches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter, useRouterState } from './RouterProvider'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport { AnyRoute, ReactNode, rootRouteId } from './route'\nimport {\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter } from './router'\nimport { NoInfer, StrictOrFrom, pick } from './utils'\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = AnyRoute,\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: RouteById<TRouteTree, TRouteId>['types']['allParams']\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n invalid: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n __resolveLoadPromise?: () => void\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: FullSearchSchema<TRouteTree> &\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']\n fetchedAt: number\n shouldReloadDeps: any\n abortController: AbortController\n cause: 'enter' | 'stay'\n}\n\nexport type AnyRouteMatch = RouteMatch<any>\n\nexport function Matches() {\n const { routesById, state } = useRouter()\n const { matches } = state\n\n const locationKey = useRouterState().location.state.key\n\n const route = routesById[rootRouteId]!\n\n const errorComponent = React.useCallback(\n (props: any) => {\n return React.createElement(ErrorComponent, {\n ...props,\n useMatch: route.useMatch,\n useRouteContext: route.useRouteContext,\n useSearch: route.useSearch,\n useParams: route.useParams,\n })\n },\n [route],\n )\n\n return (\n <matchesContext.Provider value={matches}>\n <CatchBoundary\n resetKey={locationKey}\n errorComponent={errorComponent}\n onCatch={() => {\n warning(\n false,\n `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`,\n )\n }}\n >\n {matches.length ? <Match matches={matches} /> : null}\n </CatchBoundary>\n </matchesContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matches }: { matches: RouteMatch[] }) {\n const { options, routesById } = useRouter()\n const match = matches[0]!\n const routeId = match?.routeId\n const route = routesById[routeId]!\n const router = useRouter()\n const locationKey = router.latestLocation.state?.key\n // const locationKey = useRouterState().location.state?.key\n\n const PendingComponent = (route.options.pendingComponent ??\n options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent\n ? React.createElement(PendingComponent, {\n useMatch: route.useMatch,\n useRouteContext: route.useRouteContext,\n useSearch: route.useSearch,\n useParams: route.useParams,\n })\n : undefined\n\n const routeErrorComponent =\n route.options.errorComponent ??\n options.defaultErrorComponent ??\n ErrorComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ?? pendingElement\n ? React.Suspense\n : SafeFragment\n\n const errorComponent = routeErrorComponent\n ? React.useCallback(\n (props: any) => {\n return React.createElement(routeErrorComponent, {\n ...props,\n useMatch: route.useMatch,\n useRouteContext: route.useRouteContext,\n useSearch: route.useSearch,\n useParams: route.useParams,\n })\n },\n [route],\n )\n : undefined\n\n const ResolvedCatchBoundary = errorComponent ? CatchBoundary : SafeFragment\n\n return (\n <matchesContext.Provider value={matches}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n resetKey={locationKey}\n errorComponent={errorComponent}\n onCatch={() => {\n warning(false, `Error in route match: ${match.id}`)\n }}\n >\n <MatchInner match={match} pendingElement={pendingElement} />\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchesContext.Provider>\n )\n}\nfunction MatchInner({\n match,\n pendingElement,\n}: {\n match: RouteMatch\n pendingElement: any\n}): any {\n const { options, routesById } = useRouter()\n const route = routesById[match.routeId]!\n\n if (match.status === 'error') {\n throw match.error\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement || null\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let comp = route.options.component ?? options.defaultComponent\n\n if (comp) {\n return React.createElement(comp, {\n useMatch: route.useMatch,\n useRouteContext: route.useRouteContext as any,\n useSearch: route.useSearch,\n useParams: route.useParams as any,\n useLoaderData: route.useLoaderData,\n })\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport function Outlet() {\n const matches = React.useContext(matchesContext).slice(1)\n\n if (!matches[0]) {\n return null\n }\n\n return <Match matches={matches} />\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type MakeUseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<AnyRoute, TFrom, TTo, TMaskFrom, TMaskTo> & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: MakeUseMatchRouteOptions<\n TRouteTree,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n MatchRouteOptions & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n }\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return !!params ? props.children : null\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\n const nearestMatch = React.useContext(matchesContext)[0]!\n const nearestMatchRouteId = nearestMatch?.routeId\n\n const matchRouteId = useRouterState({\n select: (state) => {\n const match = opts?.from\n ? state.matches.find((d) => d.routeId === opts?.from)\n : state.matches.find((d) => d.id === nearestMatch.id)\n\n return match!.routeId\n },\n })\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = opts?.from\n ? state.matches.find((d) => d.routeId === opts?.from)\n : state.matches.find((d) => d.id === nearestMatch.id)\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport const matchesContext = React.createContext<RouteMatch[]>(null!)\n\nexport function useMatches<T = RouteMatch[]>(opts?: {\n select?: (matches: RouteMatch[]) => T\n}): T {\n const contextMatches = React.useContext(matchesContext)\n\n return useRouterState({\n select: (state) => {\n const matches = state.matches.slice(\n state.matches.findIndex((d) => d.id === contextMatches[0]?.id),\n )\n return opts?.select ? opts.select(matches) : (matches as T)\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = TRouteMatch['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\n const match = useMatch({ ...opts, select: undefined })!\n\n return typeof opts.select === 'function'\n ? opts.select(match?.loaderData)\n : match?.loaderData\n}\n"],"names":["Matches","routesById","state","useRouter","matches","locationKey","useRouterState","location","key","route","rootRouteId","errorComponent","React","useCallback","props","createElement","ErrorComponent","useMatch","useRouteContext","useSearch","useParams","matchesContext","Provider","value","CatchBoundary","resetKey","onCatch","warning","length","Match","SafeFragment","Fragment","children","options","match","routeId","router","latestLocation","PendingComponent","pendingComponent","defaultPendingComponent","pendingElement","undefined","routeErrorComponent","defaultErrorComponent","ResolvedSuspenseBoundary","wrapInSuspense","Suspense","ResolvedCatchBoundary","fallback","id","MatchInner","status","error","showPending","loadPromise","comp","component","defaultComponent","useLoaderData","Outlet","invariant","useContext","slice","useMatchRoute","matchRoute","opts","pending","caseSensitive","rest","MatchRoute","params","nearestMatch","nearestMatchRouteId","matchRouteId","select","from","find","d","strict","matchSelection","createContext","useMatches","contextMatches","findIndex","loaderData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,SAASA,OAAOA,GAAG;EACxB,MAAM;IAAEC,UAAU;AAAE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AAC,GAAGA,KAAK,CAAA;AACzD,KAAA;AACF,GAAC,CAAC,CAAA;AAEF,EAAA,OAAO8C,cAAc,CAAA;AACvB,CAAA;AAEO,MAAM3D,cAAc,gBAAGT,gBAAK,CAACqE,aAAa,CAAe,IAAK,EAAC;AAE/D,SAASC,UAAUA,CAAmBhB,IAE5C,EAAK;AACJ,EAAA,MAAMiB,cAAc,GAAGvE,gBAAK,CAACkD,UAAU,CAACzC,cAAc,CAAC,CAAA;AAEvD,EAAA,OAAOf,6BAAc,CAAC;IACpBqE,MAAM,EAAGzE,KAAK,IAAK;MACjB,MAAME,OAAO,GAAGF,KAAK,CAACE,OAAO,CAAC2D,KAAK,CACjC7D,KAAK,CAACE,OAAO,CAACgF,SAAS,CAAEN,CAAC,IAAKA,CAAC,CAAC5B,EAAE,KAAKiC,cAAc,CAAC,CAAC,CAAC,EAAEjC,EAAE,CAC/D,CAAC,CAAA;MACD,OAAOgB,IAAI,EAAES,MAAM,GAAGT,IAAI,CAACS,MAAM,CAACvE,OAAO,CAAC,GAAIA,OAAa,CAAA;AAC7D,KAAA;AACF,GAAC,CAAC,CAAA;AACJ,CAAA;AAEO,SAASuD,aAAaA,CAU3BO,IAEC,EACyD;EAC1D,MAAMhC,KAAK,GAAGjB,QAAQ,CAAC;AAAE,IAAA,GAAGiD,IAAI;AAAES,IAAAA,MAAM,EAAEjC,SAAAA;AAAU,GAAC,CAAE,CAAA;AAEvD,EAAA,OAAO,OAAOwB,IAAI,CAACS,MAAM,KAAK,UAAU,GACpCT,IAAI,CAACS,MAAM,CAACzC,KAAK,EAAEmD,UAAU,CAAC,GAC9BnD,KAAK,EAAEmD,UAAU,CAAA;AACvB;;;;;;;;;;;;"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @tanstack/react-router/src/index.tsx
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ var React = require('react');
14
+ var warning = require('tiny-warning');
15
+ var Matches = require('./Matches.js');
16
+
17
+ function _interopNamespaceDefault(e) {
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n.default = e;
31
+ return Object.freeze(n);
32
+ }
33
+
34
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
35
+
36
+ const routerContext = /*#__PURE__*/React__namespace.createContext(null);
37
+ if (typeof document !== 'undefined') {
38
+ window.__TSR_ROUTER_CONTEXT__ = routerContext;
39
+ }
40
+ class SearchParamError extends Error {}
41
+ class PathParamError extends Error {}
42
+ function getInitialRouterState(location) {
43
+ return {
44
+ status: 'idle',
45
+ resolvedLocation: location,
46
+ location,
47
+ matches: [],
48
+ pendingMatches: [],
49
+ lastUpdated: Date.now()
50
+ };
51
+ }
52
+ function RouterProvider({
53
+ router,
54
+ ...rest
55
+ }) {
56
+ // Allow the router to update options on the router instance
57
+ router.updateOptions({
58
+ ...router.options,
59
+ ...rest,
60
+ context: {
61
+ ...router.options.context,
62
+ ...rest?.context
63
+ }
64
+ });
65
+ const [preState, setState] = React__namespace.useState(() => router.state);
66
+ const [isTransitioning, startReactTransition] = React__namespace.useTransition();
67
+ const isAnyTransitioning = isTransitioning || preState.matches.some(d => d.status === 'pending');
68
+ const state = React__namespace.useMemo(() => ({
69
+ ...preState,
70
+ status: isAnyTransitioning ? 'pending' : 'idle',
71
+ location: isTransitioning ? router.latestLocation : preState.location,
72
+ pendingMatches: router.pendingMatches
73
+ }), [preState, isTransitioning]);
74
+ router.setState = setState;
75
+ router.state = state;
76
+ router.startReactTransition = startReactTransition;
77
+ React__namespace.useLayoutEffect(() => {
78
+ const unsub = router.history.subscribe(() => {
79
+ router.latestLocation = router.parseLocation(router.latestLocation);
80
+ if (state.location !== router.latestLocation) {
81
+ startReactTransition(() => {
82
+ try {
83
+ router.load();
84
+ } catch (err) {
85
+ console.error(err);
86
+ }
87
+ });
88
+ }
89
+ });
90
+ const nextLocation = router.buildLocation({
91
+ search: true,
92
+ params: true,
93
+ hash: true,
94
+ state: true
95
+ });
96
+ if (state.location.href !== nextLocation.href) {
97
+ router.commitLocation({
98
+ ...nextLocation,
99
+ replace: true
100
+ });
101
+ }
102
+ return () => {
103
+ unsub();
104
+ };
105
+ }, [router.history]);
106
+ React__namespace.useLayoutEffect(() => {
107
+ if (!isTransitioning && state.resolvedLocation !== state.location) {
108
+ router.emit({
109
+ type: 'onResolved',
110
+ fromLocation: state.resolvedLocation,
111
+ toLocation: state.location,
112
+ pathChanged: state.location.href !== state.resolvedLocation?.href
113
+ });
114
+ router.pendingMatches = [];
115
+ setState(s => ({
116
+ ...s,
117
+ resolvedLocation: s.location
118
+ }));
119
+ }
120
+ });
121
+ React__namespace.useLayoutEffect(() => {
122
+ startReactTransition(() => {
123
+ try {
124
+ router.load();
125
+ } catch (err) {
126
+ console.error(err);
127
+ }
128
+ });
129
+ }, []);
130
+ return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
131
+ value: router
132
+ }, /*#__PURE__*/React__namespace.createElement(Matches.Matches, null));
133
+ }
134
+ function getRouteMatch(state, id) {
135
+ return [...state.pendingMatches, ...state.matches].find(d => d.id === id);
136
+ }
137
+ function useRouterState(opts) {
138
+ const {
139
+ state
140
+ } = useRouter();
141
+ // return useStore(router.__store, opts?.select as any)
142
+ return opts?.select ? opts.select(state) : state;
143
+ }
144
+ function useRouter() {
145
+ const resolvedContext = window.__TSR_ROUTER_CONTEXT__ || routerContext;
146
+ const value = React__namespace.useContext(resolvedContext);
147
+ warning(value, 'useRouter must be used inside a <RouterProvider> component!');
148
+ return value;
149
+ }
150
+
151
+ exports.PathParamError = PathParamError;
152
+ exports.RouterProvider = RouterProvider;
153
+ exports.SearchParamError = SearchParamError;
154
+ exports.getInitialRouterState = getInitialRouterState;
155
+ exports.getRouteMatch = getRouteMatch;
156
+ exports.routerContext = routerContext;
157
+ exports.useRouter = useRouter;
158
+ exports.useRouterState = useRouterState;
159
+ //# sourceMappingURL=RouterProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { Matches } from './Matches'\nimport {\n LinkInfo,\n LinkOptions,\n NavigateOptions,\n ResolveRelativePath,\n ToOptions,\n} from './link'\nimport { ParsedLocation } from './location'\nimport { AnyRoute } from './route'\nimport { RouteById, RoutePaths } from './routeInfo'\nimport {\n BuildNextOptions,\n RegisteredRouter,\n Router,\n RouterOptions,\n RouterState,\n} from './router'\nimport { NoInfer, PickAsRequired } from './utils'\nimport { MatchRouteOptions } from './Matches'\nimport { RouteMatch } from './Matches'\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n startTransition?: boolean\n}\n\nexport interface MatchLocation {\n to?: string | number | null\n fuzzy?: boolean\n caseSensitive?: boolean\n from?: string\n}\n\nexport type BuildLinkFn<TRouteTree extends AnyRoute> = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n>(\n dest: LinkOptions<TRouteTree, TFrom, TTo>,\n) => LinkInfo\n\nexport type NavigateFn<TRouteTree extends AnyRoute> = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Promise<void>\n\nexport type MatchRouteFn<TRouteTree extends AnyRoute> = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n>(\n location: ToOptions<TRouteTree, TFrom, TTo>,\n opts?: MatchRouteOptions,\n) => false | RouteById<TRouteTree, TResolved>['types']['allParams']\n\nexport type BuildLocationFn<TRouteTree extends AnyRoute> = (\n opts: BuildNextOptions,\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport const routerContext = React.createContext<Router<any>>(null!)\n\nif (typeof document !== 'undefined') {\n window.__TSR_ROUTER_CONTEXT__ = routerContext as any\n}\n\nexport class SearchParamError extends Error {}\n\nexport class PathParamError extends Error {}\n\nexport function getInitialRouterState(\n location: ParsedLocation,\n): RouterState<any> {\n return {\n status: 'idle',\n resolvedLocation: location,\n location,\n matches: [],\n pendingMatches: [],\n lastUpdated: Date.now(),\n }\n}\n\nexport function RouterProvider<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>) {\n // Allow the router to update options on the router instance\n router.updateOptions({\n ...router.options,\n ...rest,\n\n context: {\n ...router.options.context,\n ...rest?.context,\n },\n } as PickAsRequired<\n RouterOptions<TRouteTree, TDehydrated>,\n 'stringifySearch' | 'parseSearch' | 'context'\n >)\n\n const [preState, setState] = React.useState(() => router.state)\n const [isTransitioning, startReactTransition] = React.useTransition()\n const isAnyTransitioning =\n isTransitioning || preState.matches.some((d) => d.status === 'pending')\n\n const state = React.useMemo<RouterState<TRouteTree>>(\n () => ({\n ...preState,\n status: isAnyTransitioning ? 'pending' : 'idle',\n location: isTransitioning ? router.latestLocation : preState.location,\n pendingMatches: router.pendingMatches,\n }),\n [preState, isTransitioning],\n )\n\n router.setState = setState\n router.state = state\n router.startReactTransition = startReactTransition\n\n React.useLayoutEffect(() => {\n const unsub = router.history.subscribe(() => {\n router.latestLocation = router.parseLocation(router.latestLocation)\n\n if (state.location !== router.latestLocation) {\n startReactTransition(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }\n })\n\n const nextLocation = router.buildLocation({\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (state.location.href !== nextLocation.href) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router.history])\n\n React.useLayoutEffect(() => {\n if (!isTransitioning && state.resolvedLocation !== state.location) {\n router.emit({\n type: 'onResolved',\n fromLocation: state.resolvedLocation,\n toLocation: state.location,\n pathChanged: state.location!.href !== state.resolvedLocation?.href,\n })\n router.pendingMatches = []\n\n setState((s) => ({\n ...s,\n resolvedLocation: s.location,\n }))\n }\n })\n\n React.useLayoutEffect(() => {\n startReactTransition(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }, [])\n\n return (\n <routerContext.Provider value={router}>\n <Matches />\n </routerContext.Provider>\n )\n}\n\nexport function getRouteMatch<TRouteTree extends AnyRoute>(\n state: RouterState<TRouteTree>,\n id: string,\n): undefined | RouteMatch<TRouteTree> {\n return [...state.pendingMatches, ...state.matches].find((d) => d.id === id)\n}\n\nexport function useRouterState<\n TSelected = RouterState<RegisteredRouter['routeTree']>,\n>(opts?: {\n select: (state: RouterState<RegisteredRouter['routeTree']>) => TSelected\n}): TSelected {\n const { state } = useRouter()\n // return useStore(router.__store, opts?.select as any)\n return opts?.select ? opts.select(state) : (state as any)\n}\n\nexport type RouterProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {\n router: Router<TRouteTree>\n context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>\n}\n\nexport function useRouter<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(): Router<TRouteTree> {\n const resolvedContext = window.__TSR_ROUTER_CONTEXT__ || routerContext\n const value = React.useContext(resolvedContext)\n warning(value, 'useRouter must be used inside a <RouterProvider> component!')\n return value as any\n}\n"],"names":["routerContext","React","createContext","document","window","__TSR_ROUTER_CONTEXT__","SearchParamError","Error","PathParamError","getInitialRouterState","location","status","resolvedLocation","matches","pendingMatches","lastUpdated","Date","now","RouterProvider","router","rest","updateOptions","options","context","preState","setState","useState","state","isTransitioning","startReactTransition","useTransition","isAnyTransitioning","some","d","useMemo","latestLocation","useLayoutEffect","unsub","history","subscribe","parseLocation","load","err","console","error","nextLocation","buildLocation","search","params","hash","href","commitLocation","replace","emit","type","fromLocation","toLocation","pathChanged","s","createElement","Provider","value","Matches","getRouteMatch","id","find","useRouterState","opts","useRouter","select","resolvedContext","useContext","warning"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEO,MAAMA,aAAa,gBAAGC,gBAAK,CAACC,aAAa,CAAc,IAAK,EAAC;AAEpE,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACnCC,MAAM,CAACC,sBAAsB,GAAGL,aAAoB,CAAA;AACtD,CAAA;AAEO,MAAMM,gBAAgB,SAASC,KAAK,CAAC,EAAA;AAErC,MAAMC,cAAc,SAASD,KAAK,CAAC,EAAA;AAEnC,SAASE,qBAAqBA,CACnCC,QAAwB,EACN;EAClB,OAAO;AACLC,IAAAA,MAAM,EAAE,MAAM;AACdC,IAAAA,gBAAgB,EAAEF,QAAQ;IAC1BA,QAAQ;AACRG,IAAAA,OAAO,EAAE,EAAE;AACXC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAAA,WAAW,EAAEC,IAAI,CAACC,GAAG,EAAC;GACvB,CAAA;AACH,CAAA;AAEO,SAASC,cAAcA,CAG5B;EAAEC,MAAM;EAAE,GAAGC,IAAAA;AAA2C,CAAC,EAAE;AAC3D;EACAD,MAAM,CAACE,aAAa,CAAC;IACnB,GAAGF,MAAM,CAACG,OAAO;AACjB,IAAA,GAAGF,IAAI;AAEPG,IAAAA,OAAO,EAAE;AACP,MAAA,GAAGJ,MAAM,CAACG,OAAO,CAACC,OAAO;AACzB,MAAA,GAAGH,IAAI,EAAEG,OAAAA;AACX,KAAA;AACF,GAGC,CAAC,CA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