@tanstack/react-router 1.7.1 → 1.8.0

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 (200) hide show
  1. package/dist/cjs/CatchBoundary.cjs +106 -0
  2. package/dist/cjs/CatchBoundary.cjs.map +1 -0
  3. package/dist/cjs/Matches.cjs +278 -0
  4. package/dist/cjs/Matches.cjs.map +1 -0
  5. package/{build/cjs/RouterProvider.js → dist/cjs/RouterProvider.cjs} +55 -58
  6. package/dist/cjs/RouterProvider.cjs.map +1 -0
  7. package/dist/cjs/awaited.cjs +51 -0
  8. package/dist/cjs/awaited.cjs.map +1 -0
  9. package/dist/cjs/defer.cjs +30 -0
  10. package/dist/cjs/defer.cjs.map +1 -0
  11. package/dist/cjs/fileRoute.cjs +19 -0
  12. package/dist/cjs/fileRoute.cjs.map +1 -0
  13. package/dist/cjs/history.d.cts +7 -0
  14. package/{build/cjs/index.js → dist/cjs/index.cjs} +39 -51
  15. package/dist/cjs/index.cjs.map +1 -0
  16. package/dist/cjs/lazyRouteComponent.cjs +40 -0
  17. package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
  18. package/dist/cjs/link.cjs +196 -0
  19. package/dist/cjs/link.cjs.map +1 -0
  20. package/dist/cjs/link.d.cts +85 -0
  21. package/{build/cjs/path.js → dist/cjs/path.cjs} +77 -94
  22. package/dist/cjs/path.cjs.map +1 -0
  23. package/dist/cjs/qss.cjs +45 -0
  24. package/dist/cjs/qss.cjs.map +1 -0
  25. package/dist/cjs/redirects.cjs +15 -0
  26. package/dist/cjs/redirects.cjs.map +1 -0
  27. package/dist/cjs/route.cjs +143 -0
  28. package/dist/cjs/route.cjs.map +1 -0
  29. package/dist/cjs/router.cjs +1070 -0
  30. package/dist/cjs/router.cjs.map +1 -0
  31. package/dist/cjs/routerContext.cjs +29 -0
  32. package/dist/cjs/routerContext.cjs.map +1 -0
  33. package/{build/cjs/scroll-restoration.js → dist/cjs/scroll-restoration.cjs} +58 -75
  34. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  35. package/{build/cjs/searchParams.js → dist/cjs/searchParams.cjs} +18 -36
  36. package/dist/cjs/searchParams.cjs.map +1 -0
  37. package/dist/cjs/useBlocker.cjs +36 -0
  38. package/dist/cjs/useBlocker.cjs.map +1 -0
  39. package/dist/cjs/useNavigate.cjs +55 -0
  40. package/dist/cjs/useNavigate.cjs.map +1 -0
  41. package/dist/cjs/useParams.cjs +16 -0
  42. package/dist/cjs/useParams.cjs.map +1 -0
  43. package/dist/cjs/useRouteContext.cjs +11 -0
  44. package/dist/cjs/useRouteContext.cjs.map +1 -0
  45. package/dist/cjs/useRouter.cjs +33 -0
  46. package/dist/cjs/useRouter.cjs.map +1 -0
  47. package/dist/cjs/useRouterState.cjs +12 -0
  48. package/dist/cjs/useRouterState.cjs.map +1 -0
  49. package/dist/cjs/useSearch.cjs +13 -0
  50. package/dist/cjs/useSearch.cjs.map +1 -0
  51. package/{build/cjs/utils.js → dist/cjs/utils.cjs} +25 -116
  52. package/dist/cjs/utils.cjs.map +1 -0
  53. package/dist/esm/CatchBoundary.d.ts +36 -0
  54. package/dist/esm/CatchBoundary.js +89 -0
  55. package/dist/esm/CatchBoundary.js.map +1 -0
  56. package/dist/esm/Matches.d.ts +71 -0
  57. package/dist/esm/Matches.js +261 -0
  58. package/{build/cjs → dist/esm}/Matches.js.map +1 -1
  59. package/dist/esm/RouterProvider.d.ts +27 -0
  60. package/dist/esm/RouterProvider.js +136 -0
  61. package/{build/cjs → dist/esm}/RouterProvider.js.map +1 -1
  62. package/dist/esm/awaited.d.ts +9 -0
  63. package/dist/esm/awaited.js +51 -0
  64. package/dist/esm/awaited.js.map +1 -0
  65. package/dist/esm/defer.d.ts +22 -0
  66. package/dist/esm/defer.js +30 -0
  67. package/{build/cjs → dist/esm}/defer.js.map +1 -1
  68. package/dist/esm/fileRoute.d.ts +21 -0
  69. package/dist/esm/fileRoute.js +19 -0
  70. package/dist/esm/fileRoute.js.map +1 -0
  71. package/{build/types → dist/esm}/history.d.ts +1 -1
  72. package/dist/esm/index.d.ts +30 -0
  73. package/dist/esm/index.js +118 -0
  74. package/dist/esm/index.js.map +1 -0
  75. package/dist/esm/lazyRouteComponent.d.ts +2 -0
  76. package/dist/esm/lazyRouteComponent.js +23 -0
  77. package/{build/cjs → dist/esm}/lazyRouteComponent.js.map +1 -1
  78. package/{build/types → dist/esm}/link.d.ts +3 -1
  79. package/dist/esm/link.js +179 -0
  80. package/dist/esm/link.js.map +1 -0
  81. package/dist/esm/location.d.ts +12 -0
  82. package/dist/esm/path.d.ts +17 -0
  83. package/dist/esm/path.js +200 -0
  84. package/dist/esm/path.js.map +1 -0
  85. package/dist/esm/qss.d.ts +2 -0
  86. package/dist/esm/qss.js +45 -0
  87. package/dist/esm/qss.js.map +1 -0
  88. package/dist/esm/redirects.d.ts +11 -0
  89. package/dist/esm/redirects.js +15 -0
  90. package/{build/cjs → dist/esm}/redirects.js.map +1 -1
  91. package/dist/esm/route.d.ts +300 -0
  92. package/dist/esm/route.js +143 -0
  93. package/dist/esm/route.js.map +1 -0
  94. package/dist/esm/routeInfo.d.ts +31 -0
  95. package/dist/esm/router.d.ts +201 -0
  96. package/dist/esm/router.js +1070 -0
  97. package/{build/cjs → dist/esm}/router.js.map +1 -1
  98. package/dist/esm/routerContext.d.ts +3 -0
  99. package/dist/esm/routerContext.js +13 -0
  100. package/{build/cjs → dist/esm}/routerContext.js.map +1 -1
  101. package/dist/esm/scroll-restoration.d.ts +18 -0
  102. package/dist/esm/scroll-restoration.js +168 -0
  103. package/dist/esm/scroll-restoration.js.map +1 -0
  104. package/dist/esm/searchParams.d.ts +7 -0
  105. package/dist/esm/searchParams.js +63 -0
  106. package/{build/cjs → dist/esm}/searchParams.js.map +1 -1
  107. package/dist/esm/useBlocker.d.ts +9 -0
  108. package/dist/esm/useBlocker.js +19 -0
  109. package/{build/cjs → dist/esm}/useBlocker.js.map +1 -1
  110. package/dist/esm/useNavigate.d.ts +20 -0
  111. package/dist/esm/useNavigate.js +38 -0
  112. package/{build/cjs → dist/esm}/useNavigate.js.map +1 -1
  113. package/dist/esm/useParams.d.ts +7 -0
  114. package/dist/esm/useParams.js +16 -0
  115. package/{build/cjs → dist/esm}/useParams.js.map +1 -1
  116. package/dist/esm/useRouteContext.d.ts +7 -0
  117. package/dist/esm/useRouteContext.js +11 -0
  118. package/{build/cjs → dist/esm}/useRouteContext.js.map +1 -1
  119. package/dist/esm/useRouter.d.ts +5 -0
  120. package/dist/esm/useRouter.js +16 -0
  121. package/{build/cjs → dist/esm}/useRouter.js.map +1 -1
  122. package/dist/esm/useRouterState.d.ts +6 -0
  123. package/dist/esm/useRouterState.js +12 -0
  124. package/{build/cjs → dist/esm}/useRouterState.js.map +1 -1
  125. package/dist/esm/useSearch.d.ts +7 -0
  126. package/dist/esm/useSearch.js +13 -0
  127. package/dist/esm/useSearch.js.map +1 -0
  128. package/dist/esm/utils.d.ts +46 -0
  129. package/dist/esm/utils.js +137 -0
  130. package/{build/cjs → dist/esm}/utils.js.map +1 -1
  131. package/package.json +43 -22
  132. package/src/fileRoute.ts +4 -5
  133. package/src/link.tsx +5 -4
  134. package/src/route.ts +5 -6
  135. package/src/useSearch.tsx +5 -2
  136. package/build/cjs/CatchBoundary.js +0 -128
  137. package/build/cjs/CatchBoundary.js.map +0 -1
  138. package/build/cjs/Matches.js +0 -260
  139. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -29
  140. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  141. package/build/cjs/awaited.js +0 -60
  142. package/build/cjs/awaited.js.map +0 -1
  143. package/build/cjs/defer.js +0 -42
  144. package/build/cjs/fileRoute.js +0 -31
  145. package/build/cjs/fileRoute.js.map +0 -1
  146. package/build/cjs/index.js.map +0 -1
  147. package/build/cjs/lazyRouteComponent.js +0 -54
  148. package/build/cjs/link.js +0 -224
  149. package/build/cjs/link.js.map +0 -1
  150. package/build/cjs/path.js.map +0 -1
  151. package/build/cjs/qss.js +0 -63
  152. package/build/cjs/qss.js.map +0 -1
  153. package/build/cjs/redirects.js +0 -28
  154. package/build/cjs/route.js +0 -292
  155. package/build/cjs/route.js.map +0 -1
  156. package/build/cjs/router.js +0 -1116
  157. package/build/cjs/routerContext.js +0 -42
  158. package/build/cjs/scroll-restoration.js.map +0 -1
  159. package/build/cjs/useBlocker.js +0 -55
  160. package/build/cjs/useNavigate.js +0 -88
  161. package/build/cjs/useParams.js +0 -27
  162. package/build/cjs/useRouteContext.js +0 -23
  163. package/build/cjs/useRouter.js +0 -44
  164. package/build/cjs/useRouterState.js +0 -24
  165. package/build/cjs/useSearch.js +0 -25
  166. package/build/cjs/useSearch.js.map +0 -1
  167. package/build/esm/index.js +0 -2874
  168. package/build/esm/index.js.map +0 -1
  169. package/build/stats-html.html +0 -4838
  170. package/build/stats-react.json +0 -1471
  171. package/build/umd/index.development.js +0 -3573
  172. package/build/umd/index.development.js.map +0 -1
  173. package/build/umd/index.production.js +0 -22
  174. package/build/umd/index.production.js.map +0 -1
  175. /package/{build/types/CatchBoundary.d.ts → dist/cjs/CatchBoundary.d.cts} +0 -0
  176. /package/{build/types/Matches.d.ts → dist/cjs/Matches.d.cts} +0 -0
  177. /package/{build/types/RouterProvider.d.ts → dist/cjs/RouterProvider.d.cts} +0 -0
  178. /package/{build/types/awaited.d.ts → dist/cjs/awaited.d.cts} +0 -0
  179. /package/{build/types/defer.d.ts → dist/cjs/defer.d.cts} +0 -0
  180. /package/{build/types/fileRoute.d.ts → dist/cjs/fileRoute.d.cts} +0 -0
  181. /package/{build/types/index.d.ts → dist/cjs/index.d.cts} +0 -0
  182. /package/{build/types/lazyRouteComponent.d.ts → dist/cjs/lazyRouteComponent.d.cts} +0 -0
  183. /package/{build/types/location.d.ts → dist/cjs/location.d.cts} +0 -0
  184. /package/{build/types/path.d.ts → dist/cjs/path.d.cts} +0 -0
  185. /package/{build/types/qss.d.ts → dist/cjs/qss.d.cts} +0 -0
  186. /package/{build/types/redirects.d.ts → dist/cjs/redirects.d.cts} +0 -0
  187. /package/{build/types/route.d.ts → dist/cjs/route.d.cts} +0 -0
  188. /package/{build/types/routeInfo.d.ts → dist/cjs/routeInfo.d.cts} +0 -0
  189. /package/{build/types/router.d.ts → dist/cjs/router.d.cts} +0 -0
  190. /package/{build/types/routerContext.d.ts → dist/cjs/routerContext.d.cts} +0 -0
  191. /package/{build/types/scroll-restoration.d.ts → dist/cjs/scroll-restoration.d.cts} +0 -0
  192. /package/{build/types/searchParams.d.ts → dist/cjs/searchParams.d.cts} +0 -0
  193. /package/{build/types/useBlocker.d.ts → dist/cjs/useBlocker.d.cts} +0 -0
  194. /package/{build/types/useNavigate.d.ts → dist/cjs/useNavigate.d.cts} +0 -0
  195. /package/{build/types/useParams.d.ts → dist/cjs/useParams.d.cts} +0 -0
  196. /package/{build/types/useRouteContext.d.ts → dist/cjs/useRouteContext.d.cts} +0 -0
  197. /package/{build/types/useRouter.d.ts → dist/cjs/useRouter.d.cts} +0 -0
  198. /package/{build/types/useRouterState.d.ts → dist/cjs/useRouterState.d.cts} +0 -0
  199. /package/{build/types/useSearch.d.ts → dist/cjs/useSearch.d.cts} +0 -0
  200. /package/{build/types/utils.d.ts → dist/cjs/utils.d.cts} +0 -0
@@ -1,260 +0,0 @@
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 useRouterState = require('./useRouterState.js');
18
- var useRouter = require('./useRouter.js');
19
- var utils = require('./utils.js');
20
-
21
- function _interopNamespaceDefault(e) {
22
- var n = Object.create(null);
23
- if (e) {
24
- Object.keys(e).forEach(function (k) {
25
- if (k !== 'default') {
26
- var d = Object.getOwnPropertyDescriptor(e, k);
27
- Object.defineProperty(n, k, d.get ? d : {
28
- enumerable: true,
29
- get: function () { return e[k]; }
30
- });
31
- }
32
- });
33
- }
34
- n.default = e;
35
- return Object.freeze(n);
36
- }
37
-
38
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
39
-
40
- const matchContext = /*#__PURE__*/React__namespace.createContext(undefined);
41
- function Matches() {
42
- const router = useRouter.useRouter();
43
- const matchId = useRouterState.useRouterState({
44
- select: s => {
45
- return getRenderedMatches(s)[0]?.id;
46
- }
47
- });
48
- return /*#__PURE__*/React__namespace.createElement(matchContext.Provider, {
49
- value: matchId
50
- }, /*#__PURE__*/React__namespace.createElement(CatchBoundary.CatchBoundary, {
51
- getResetKey: () => router.state.resolvedLocation.state?.key,
52
- errorComponent: CatchBoundary.ErrorComponent,
53
- onCatch: () => {
54
- warning(false, `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`);
55
- }
56
- }, matchId ? /*#__PURE__*/React__namespace.createElement(Match, {
57
- matchId: matchId
58
- }) : null));
59
- }
60
- function SafeFragment(props) {
61
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, props.children);
62
- }
63
- function Match({
64
- matchId
65
- }) {
66
- const router = useRouter.useRouter();
67
- const routeId = useRouterState.useRouterState({
68
- select: s => getRenderedMatches(s).find(d => d.id === matchId)?.routeId
69
- });
70
- invariant(routeId, `Could not find routeId for matchId "${matchId}". Please file an issue!`);
71
- const route = router.routesById[routeId];
72
- const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
73
- const pendingElement = PendingComponent ? /*#__PURE__*/React__namespace.createElement(PendingComponent, null) : null;
74
- const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent ?? CatchBoundary.ErrorComponent;
75
- const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? PendingComponent ?? route.options.component?.preload ?? route.options.pendingComponent?.preload ?? route.options.errorComponent?.preload ? React__namespace.Suspense : SafeFragment;
76
- const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary.CatchBoundary : SafeFragment;
77
- return /*#__PURE__*/React__namespace.createElement(matchContext.Provider, {
78
- value: matchId
79
- }, /*#__PURE__*/React__namespace.createElement(ResolvedSuspenseBoundary, {
80
- fallback: pendingElement
81
- }, /*#__PURE__*/React__namespace.createElement(ResolvedCatchBoundary, {
82
- getResetKey: () => router.state.resolvedLocation.state?.key,
83
- errorComponent: routeErrorComponent,
84
- onCatch: () => {
85
- warning(false, `Error in route match: ${matchId}`);
86
- }
87
- }, /*#__PURE__*/React__namespace.createElement(MatchInner, {
88
- matchId: matchId,
89
- pendingElement: pendingElement
90
- }))));
91
- }
92
- function MatchInner({
93
- matchId,
94
- pendingElement
95
- }) {
96
- const router = useRouter.useRouter();
97
- const routeId = useRouterState.useRouterState({
98
- select: s => getRenderedMatches(s).find(d => d.id === matchId)?.routeId
99
- });
100
- const route = router.routesById[routeId];
101
- const match = useRouterState.useRouterState({
102
- select: s => utils.pick(getRenderedMatches(s).find(d => d.id === matchId), ['status', 'error', 'showPending', 'loadPromise'])
103
- });
104
- if (match.status === 'error') {
105
- if (isServerSideError(match.error)) {
106
- const deserializeError = router.options.errorSerializer?.deserialize ?? defaultDeserializeError;
107
- throw deserializeError(match.error.data);
108
- } else {
109
- throw match.error;
110
- }
111
- }
112
- if (match.status === 'pending') {
113
- if (match.showPending) {
114
- return pendingElement;
115
- }
116
- throw match.loadPromise;
117
- }
118
- if (match.status === 'success') {
119
- let Comp = route.options.component ?? router.options.defaultComponent;
120
- if (Comp) {
121
- return /*#__PURE__*/React__namespace.createElement(Comp, null);
122
- }
123
- return /*#__PURE__*/React__namespace.createElement(Outlet, null);
124
- }
125
- invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
126
- }
127
- const Outlet = /*#__PURE__*/React__namespace.memo(function Outlet() {
128
- const matchId = React__namespace.useContext(matchContext);
129
- const childMatchId = useRouterState.useRouterState({
130
- select: s => {
131
- const matches = getRenderedMatches(s);
132
- const index = matches.findIndex(d => d.id === matchId);
133
- return matches[index + 1]?.id;
134
- }
135
- });
136
- if (!childMatchId) {
137
- return null;
138
- }
139
- return /*#__PURE__*/React__namespace.createElement(Match, {
140
- matchId: childMatchId
141
- });
142
- });
143
- function useMatchRoute() {
144
- useRouterState.useRouterState({
145
- select: s => [s.location, s.resolvedLocation]
146
- });
147
- const {
148
- matchRoute
149
- } = useRouter.useRouter();
150
- return React__namespace.useCallback(opts => {
151
- const {
152
- pending,
153
- caseSensitive,
154
- fuzzy,
155
- includeSearch,
156
- ...rest
157
- } = opts;
158
- return matchRoute(rest, {
159
- pending,
160
- caseSensitive,
161
- fuzzy,
162
- includeSearch
163
- });
164
- }, []);
165
- }
166
- function MatchRoute(props) {
167
- const matchRoute = useMatchRoute();
168
- const params = matchRoute(props);
169
- if (typeof props.children === 'function') {
170
- return props.children(params);
171
- }
172
- return !!params ? props.children : null;
173
- }
174
- function getRenderedMatches(state) {
175
- return state.pendingMatches?.some(d => d.showPending) ? state.pendingMatches : state.matches;
176
- }
177
- function useMatch(opts) {
178
- const router = useRouter.useRouter();
179
- const nearestMatchId = React__namespace.useContext(matchContext);
180
- const nearestMatchRouteId = getRenderedMatches(router.state).find(d => d.id === nearestMatchId)?.routeId;
181
- const matchRouteId = (() => {
182
- const matches = getRenderedMatches(router.state);
183
- const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
184
- return match.routeId;
185
- })();
186
- if (opts?.strict ?? true) {
187
- 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?`);
188
- }
189
- const matchSelection = useRouterState.useRouterState({
190
- select: state => {
191
- const match = getRenderedMatches(state).find(d => d.id === nearestMatchId);
192
- invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
193
- return opts?.select ? opts.select(match) : match;
194
- }
195
- });
196
- return matchSelection;
197
- }
198
- function useMatches(opts) {
199
- return useRouterState.useRouterState({
200
- select: state => {
201
- let matches = getRenderedMatches(state);
202
- return opts?.select ? opts.select(matches) : matches;
203
- }
204
- });
205
- }
206
- function useParentMatches(opts) {
207
- const contextMatchId = React__namespace.useContext(matchContext);
208
- return useMatches({
209
- select: matches => {
210
- matches = matches.slice(matches.findIndex(d => d.id === contextMatchId));
211
- return opts?.select ? opts.select(matches) : matches;
212
- }
213
- });
214
- }
215
- function useLoaderDeps(opts) {
216
- return useMatch({
217
- ...opts,
218
- select: s => {
219
- return typeof opts.select === 'function' ? opts.select(s?.loaderDeps) : s?.loaderDeps;
220
- }
221
- });
222
- }
223
- function useLoaderData(opts) {
224
- return useMatch({
225
- ...opts,
226
- select: s => {
227
- return typeof opts.select === 'function' ? opts.select(s?.loaderData) : s?.loaderData;
228
- }
229
- });
230
- }
231
- function isServerSideError(error) {
232
- if (!(typeof error === 'object' && error && 'data' in error)) return false;
233
- if (!('__isServerError' in error && error.__isServerError)) return false;
234
- if (!(typeof error.data === 'object' && error.data)) return false;
235
- return error.__isServerError === true;
236
- }
237
- function defaultDeserializeError(serializedData) {
238
- if ('name' in serializedData && 'message' in serializedData) {
239
- const error = new Error(serializedData.message);
240
- error.name = serializedData.name;
241
- return error;
242
- }
243
- return serializedData.data;
244
- }
245
-
246
- exports.Match = Match;
247
- exports.MatchRoute = MatchRoute;
248
- exports.Matches = Matches;
249
- exports.Outlet = Outlet;
250
- exports.defaultDeserializeError = defaultDeserializeError;
251
- exports.getRenderedMatches = getRenderedMatches;
252
- exports.isServerSideError = isServerSideError;
253
- exports.matchContext = matchContext;
254
- exports.useLoaderData = useLoaderData;
255
- exports.useLoaderDeps = useLoaderDeps;
256
- exports.useMatch = useMatch;
257
- exports.useMatchRoute = useMatchRoute;
258
- exports.useMatches = useMatches;
259
- exports.useParentMatches = useParentMatches;
260
- //# sourceMappingURL=Matches.js.map
@@ -1,29 +0,0 @@
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
- function _extends() {
14
- _extends = Object.assign ? Object.assign.bind() : function (target) {
15
- for (var i = 1; i < arguments.length; i++) {
16
- var source = arguments[i];
17
- for (var key in source) {
18
- if (Object.prototype.hasOwnProperty.call(source, key)) {
19
- target[key] = source[key];
20
- }
21
- }
22
- }
23
- return target;
24
- };
25
- return _extends.apply(this, arguments);
26
- }
27
-
28
- exports.extends = _extends;
29
- //# sourceMappingURL=_rollupPluginBabelHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,60 +0,0 @@
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 warning = require('tiny-warning');
14
- var Matches = require('./Matches.js');
15
- var useRouter = require('./useRouter.js');
16
- var defer = require('./defer.js');
17
- var router = require('./router.js');
18
-
19
- function useAwaited({
20
- promise
21
- }) {
22
- const router$1 = useRouter.useRouter();
23
- let state = promise.__deferredState;
24
- const key = `__TSR__DEFERRED__${state.uid}`;
25
- if (defer.isDehydratedDeferred(promise)) {
26
- state = router$1.hydrateData(key);
27
- if (!state) throw new Error('Could not find dehydrated data');
28
- promise = Promise.resolve(state.data);
29
- promise.__deferredState = state;
30
- }
31
- if (state.status === 'pending') {
32
- throw promise;
33
- }
34
- if (state.status === 'error') {
35
- if (typeof document !== 'undefined') {
36
- if (Matches.isServerSideError(state.error)) {
37
- throw (router$1.options.errorSerializer?.deserialize ?? Matches.defaultDeserializeError)(state.error.data);
38
- } else {
39
- warning(false, "Encountered a server-side error that doesn't fit the expected shape");
40
- throw state.error;
41
- }
42
- } else {
43
- router$1.dehydrateData(key, state);
44
- throw {
45
- data: (router$1.options.errorSerializer?.serialize ?? router.defaultSerializeError)(state.error),
46
- __isServerError: true
47
- };
48
- }
49
- }
50
- router$1.dehydrateData(key, state);
51
- return [state.data];
52
- }
53
- function Await(props) {
54
- const awaited = useAwaited(props);
55
- return props.children(...awaited);
56
- }
57
-
58
- exports.Await = Await;
59
- exports.useAwaited = useAwaited;
60
- //# sourceMappingURL=awaited.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"awaited.js","sources":["../../src/awaited.tsx"],"sourcesContent":["import warning from 'tiny-warning'\nimport { defaultDeserializeError, isServerSideError } from './Matches'\nimport { useRouter } from './useRouter'\nimport { DeferredPromise, isDehydratedDeferred } from './defer'\nimport { defaultSerializeError } from './router'\n\nexport type AwaitOptions<T> = {\n promise: DeferredPromise<T>\n}\n\nexport function useAwaited<T>({ promise }: AwaitOptions<T>): [T] {\n const router = useRouter()\n\n let state = promise.__deferredState\n const key = `__TSR__DEFERRED__${state.uid}`\n\n if (isDehydratedDeferred(promise)) {\n state = router.hydrateData(key)!\n if (!state) throw new Error('Could not find dehydrated data')\n promise = Promise.resolve(state.data) as DeferredPromise<any>\n promise.__deferredState = state\n }\n\n if (state.status === 'pending') {\n throw promise\n }\n\n if (state.status === 'error') {\n if (typeof document !== 'undefined') {\n if (isServerSideError(state.error)) {\n throw (\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n )(state.error.data as any)\n } else {\n warning(\n false,\n \"Encountered a server-side error that doesn't fit the expected shape\",\n )\n throw state.error\n }\n } else {\n router.dehydrateData(key, state)\n throw {\n data: (\n router.options.errorSerializer?.serialize ?? defaultSerializeError\n )(state.error),\n __isServerError: true,\n }\n }\n }\n\n router.dehydrateData(key, state)\n\n return [state.data]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n children: (result: T) => JSX.Element\n },\n) {\n const awaited = useAwaited(props)\n return props.children(...awaited)\n}\n"],"names":["useAwaited","promise","router","useRouter","state","__deferredState","key","uid","isDehydratedDeferred","hydrateData","Error","Promise","resolve","data","status","document","isServerSideError","error","options","errorSerializer","deserialize","defaultDeserializeError","warning","dehydrateData","serialize","defaultSerializeError","__isServerError","Await","props","awaited","children"],"mappings":";;;;;;;;;;;;;;;;;;AAUO,SAASA,UAAUA,CAAI;AAAEC,EAAAA,OAAAA;AAAyB,CAAC,EAAO;AAC/D,EAAA,MAAMC,QAAM,GAAGC,mBAAS,EAAE,CAAA;AAE1B,EAAA,IAAIC,KAAK,GAAGH,OAAO,CAACI,eAAe,CAAA;AACnC,EAAA,MAAMC,GAAG,GAAI,CAAA,iBAAA,EAAmBF,KAAK,CAACG,GAAI,CAAC,CAAA,CAAA;AAE3C,EAAA,IAAIC,0BAAoB,CAACP,OAAO,CAAC,EAAE;AACjCG,IAAAA,KAAK,GAAGF,QAAM,CAACO,WAAW,CAACH,GAAG,CAAE,CAAA;IAChC,IAAI,CAACF,KAAK,EAAE,MAAM,IAAIM,KAAK,CAAC,gCAAgC,CAAC,CAAA;IAC7DT,OAAO,GAAGU,OAAO,CAACC,OAAO,CAACR,KAAK,CAACS,IAAI,CAAyB,CAAA;IAC7DZ,OAAO,CAACI,eAAe,GAAGD,KAAK,CAAA;AACjC,GAAA;AAEA,EAAA,IAAIA,KAAK,CAACU,MAAM,KAAK,SAAS,EAAE;AAC9B,IAAA,MAAMb,OAAO,CAAA;AACf,GAAA;AAEA,EAAA,IAAIG,KAAK,CAACU,MAAM,KAAK,OAAO,EAAE;AAC5B,IAAA,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;AACnC,MAAA,IAAIC,yBAAiB,CAACZ,KAAK,CAACa,KAAK,CAAC,EAAE;AAClC,QAAA,MAAM,CACJf,QAAM,CAACgB,OAAO,CAACC,eAAe,EAAEC,WAAW,IAAIC,+BAAuB,EACtEjB,KAAK,CAACa,KAAK,CAACJ,IAAW,CAAC,CAAA;AAC5B,OAAC,MAAM;AACLS,QAAAA,OAAO,CACL,KAAK,EACL,qEACF,CAAC,CAAA;QACD,MAAMlB,KAAK,CAACa,KAAK,CAAA;AACnB,OAAA;AACF,KAAC,MAAM;AACLf,MAAAA,QAAM,CAACqB,aAAa,CAACjB,GAAG,EAAEF,KAAK,CAAC,CAAA;MAChC,MAAM;AACJS,QAAAA,IAAI,EAAE,CACJX,QAAM,CAACgB,OAAO,CAACC,eAAe,EAAEK,SAAS,IAAIC,4BAAqB,EAClErB,KAAK,CAACa,KAAK,CAAC;AACdS,QAAAA,eAAe,EAAE,IAAA;OAClB,CAAA;AACH,KAAA;AACF,GAAA;AAEAxB,EAAAA,QAAM,CAACqB,aAAa,CAACjB,GAAG,EAAEF,KAAK,CAAC,CAAA;AAEhC,EAAA,OAAO,CAACA,KAAK,CAACS,IAAI,CAAC,CAAA;AACrB,CAAA;AAEO,SAASc,KAAKA,CACnBC,KAEC,EACD;AACA,EAAA,MAAMC,OAAO,GAAG7B,UAAU,CAAC4B,KAAK,CAAC,CAAA;AACjC,EAAA,OAAOA,KAAK,CAACE,QAAQ,CAAC,GAAGD,OAAO,CAAC,CAAA;AACnC;;;;;"}
@@ -1,42 +0,0 @@
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 router = require('./router.js');
14
-
15
- function defer(_promise, options) {
16
- const promise = _promise;
17
- if (!promise.__deferredState) {
18
- promise.__deferredState = {
19
- uid: Math.random().toString(36).slice(2),
20
- status: 'pending'
21
- };
22
- const state = promise.__deferredState;
23
- promise.then(data => {
24
- state.status = 'success';
25
- state.data = data;
26
- }).catch(error => {
27
- state.status = 'error';
28
- state.error = {
29
- data: (options?.serializeError ?? router.defaultSerializeError)(error),
30
- __isServerError: true
31
- };
32
- });
33
- }
34
- return promise;
35
- }
36
- function isDehydratedDeferred(obj) {
37
- return typeof obj === 'object' && obj !== null && !(obj instanceof Promise) && !obj.then && '__deferredState' in obj;
38
- }
39
-
40
- exports.defer = defer;
41
- exports.isDehydratedDeferred = isDehydratedDeferred;
42
- //# sourceMappingURL=defer.js.map
@@ -1,31 +0,0 @@
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 route = require('./route.js');
14
-
15
- class FileRoute {
16
- constructor(path) {
17
- this.path = path;
18
- }
19
- createRoute = options => {
20
- const route$1 = new route.Route(options);
21
- route$1.isRoot = false;
22
- return route$1;
23
- };
24
- }
25
- function FileRouteLoader(_path) {
26
- return loaderFn => loaderFn;
27
- }
28
-
29
- exports.FileRoute = FileRoute;
30
- exports.FileRouteLoader = FileRouteLoader;
31
- //# sourceMappingURL=fileRoute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { NoInfer } from '@tanstack/react-store'\nimport { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n ResolveFullSearchSchemaInput,\n SearchSchemaInput,\n LoaderFnContext,\n RouteLoaderFn,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\ntype ReplaceFirstOccurrence<\n T extends string,\n Search extends string,\n Replacement extends string,\n> = T extends `${infer Prefix}${Search}${infer Suffix}`\n ? `${Prefix}${Replacement}${Suffix}`\n : T\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : ReplaceFirstOccurrence<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> =\n ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}`\n ? ''\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n constructor(public path: TFilePath) {}\n\n createRoute = <\n TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TSearchSchemaUsed extends Record<\n string,\n any\n > = TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema,\n TFullSearchSchemaInput extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContextReturn extends\n RouteConstraints['TRouteContext'] = RouteContext,\n TRouteContext extends RouteConstraints['TRouteContext'] = [\n TRouteContextReturn,\n ] extends [never]\n ? RouteContext\n : TRouteContextReturn,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TFullSearchSchema>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n const route = new Route(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderData extends any>(\n loaderFn: RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n TLoaderData\n >,\n) => RouteLoaderFn<\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['allContext'],\n TRoute['types']['routeContext'],\n NoInfer<TLoaderData>\n> {\n return (loaderFn) => loaderFn\n}\n"],"names":["FileRoute","constructor","path","createRoute","options","route","Route","isRoot","FileRouteLoader","_path","loaderFn"],"mappings":";;;;;;;;;;;;;;AAsFO,MAAMA,SAAS,CAYpB;EACAC,WAAWA,CAAQC,IAAe,EAAE;IAAA,IAAjBA,CAAAA,IAAe,GAAfA,IAAe,CAAA;AAAG,GAAA;EAErCC,WAAW,GA4CTC,OAqB0C,IAsBvC;AACH,IAAA,MAAMC,OAAK,GAAG,IAAIC,WAAK,CAACF,OAAc,CAAC,CAAA;IACrCC,OAAK,CAASE,MAAM,GAAG,KAAK,CAAA;AAC9B,IAAA,OAAOF,OAAK,CAAA;GACb,CAAA;AACH,CAAA;AAEO,SAASG,eAAeA,CAI7BC,KAAgB,EAehB;EACA,OAAQC,QAAQ,IAAKA,QAAQ,CAAA;AAC/B;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,54 +0,0 @@
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 lazyRouteComponent(importer, exportName) {
35
- let loadPromise;
36
- const load = () => {
37
- if (!loadPromise) {
38
- loadPromise = importer();
39
- }
40
- return loadPromise;
41
- };
42
- const lazyComp = /*#__PURE__*/React__namespace.lazy(async () => {
43
- const moduleExports = await load();
44
- const comp = moduleExports[exportName ?? 'default'];
45
- return {
46
- default: comp
47
- };
48
- });
49
- lazyComp.preload = load;
50
- return lazyComp;
51
- }
52
-
53
- exports.lazyRouteComponent = lazyRouteComponent;
54
- //# sourceMappingURL=lazyRouteComponent.js.map