@tanstack/react-router 0.0.1-beta.18 → 0.0.1-beta.19
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 +82 -52
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +62 -36
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +101 -46
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -43
- package/build/types/index.d.ts +33 -14
- package/build/umd/index.development.js +109 -52
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -3
- package/src/index.tsx +89 -25
|
@@ -15,8 +15,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
15
15
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
var shim = require('use-sync-external-store/shim');
|
|
18
|
-
var index
|
|
19
|
-
var index = require('react-lazy-with-preload/lib/index');
|
|
18
|
+
var index = require('../../router-core/build/esm/index.js');
|
|
20
19
|
|
|
21
20
|
function _interopNamespace(e) {
|
|
22
21
|
if (e && e.__esModule) return e;
|
|
@@ -41,9 +40,38 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
41
40
|
const _excluded = ["type", "children", "target", "activeProps", "inactiveProps", "activeOptions", "disabled", "hash", "search", "params", "to", "preload", "preloadDelay", "preloadMaxAge", "replace", "style", "className", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onTouchStart", "onTouchEnd"],
|
|
42
41
|
_excluded2 = ["pending", "caseSensitive", "children"],
|
|
43
42
|
_excluded3 = ["children", "router"];
|
|
43
|
+
function lazy(importer) {
|
|
44
|
+
const lazyComp = /*#__PURE__*/React__namespace.lazy(importer);
|
|
45
|
+
let promise;
|
|
46
|
+
let resolvedComp;
|
|
47
|
+
const forwardedComp = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
|
|
48
|
+
const resolvedCompRef = React__namespace.useRef(resolvedComp || lazyComp);
|
|
49
|
+
return /*#__PURE__*/React__namespace.createElement(resolvedCompRef.current, _rollupPluginBabelHelpers["extends"]({}, ref ? {
|
|
50
|
+
ref
|
|
51
|
+
} : {}, props));
|
|
52
|
+
});
|
|
53
|
+
const finalComp = forwardedComp;
|
|
54
|
+
|
|
55
|
+
finalComp.preload = () => {
|
|
56
|
+
if (!promise) {
|
|
57
|
+
promise = importer().then(module => {
|
|
58
|
+
resolvedComp = module.default;
|
|
59
|
+
return resolvedComp;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return promise;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return finalComp;
|
|
67
|
+
}
|
|
44
68
|
//
|
|
69
|
+
function Link(props) {
|
|
70
|
+
const router = useRouter();
|
|
71
|
+
return /*#__PURE__*/React__namespace.createElement(router.Link, props);
|
|
72
|
+
}
|
|
45
73
|
const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
46
|
-
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
74
|
+
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
47
75
|
function MatchesProvider(props) {
|
|
48
76
|
return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, props);
|
|
49
77
|
}
|
|
@@ -63,7 +91,7 @@ function createReactRouter(opts) {
|
|
|
63
91
|
const resolvedRouteId = router.resolvePath(route.routeId, subRouteId);
|
|
64
92
|
const resolvedRoute = router.getRoute(resolvedRouteId);
|
|
65
93
|
useRouterSubscription(router);
|
|
66
|
-
index
|
|
94
|
+
index.invariant(resolvedRoute, "Could not find a route for route \"" + resolvedRouteId + "\"! Did you forget to add it to your route config?");
|
|
67
95
|
return resolvedRoute;
|
|
68
96
|
},
|
|
69
97
|
linkProps: options => {
|
|
@@ -121,9 +149,9 @@ function createReactRouter(opts) {
|
|
|
121
149
|
}; // Get the active props
|
|
122
150
|
|
|
123
151
|
|
|
124
|
-
const resolvedActiveProps = isActive ? (_functionalUpdate = index
|
|
152
|
+
const resolvedActiveProps = isActive ? (_functionalUpdate = index.functionalUpdate(activeProps, {})) != null ? _functionalUpdate : {} : {}; // Get the inactive props
|
|
125
153
|
|
|
126
|
-
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = index
|
|
154
|
+
const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = index.functionalUpdate(inactiveProps, {})) != null ? _functionalUpdate2 : {};
|
|
127
155
|
return _rollupPluginBabelHelpers["extends"]({}, resolvedActiveProps, resolvedInactiveProps, rest, {
|
|
128
156
|
href: disabled ? undefined : next.href,
|
|
129
157
|
onClick: composeHandlers([reactHandleClick, onClick]),
|
|
@@ -172,7 +200,7 @@ function createReactRouter(opts) {
|
|
|
172
200
|
};
|
|
173
201
|
};
|
|
174
202
|
|
|
175
|
-
const coreRouter = index
|
|
203
|
+
const coreRouter = index.createRouter(_rollupPluginBabelHelpers["extends"]({}, opts, {
|
|
176
204
|
createRouter: router => {
|
|
177
205
|
const routerExt = {
|
|
178
206
|
useState: () => {
|
|
@@ -183,13 +211,13 @@ function createReactRouter(opts) {
|
|
|
183
211
|
var _useMatches, _opts$strict;
|
|
184
212
|
|
|
185
213
|
useRouterSubscription(router);
|
|
186
|
-
index
|
|
214
|
+
index.invariant(routeId !== index.rootRouteId, "\"" + index.rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + index.rootRouteId + "\")?");
|
|
187
215
|
const runtimeMatch = (_useMatches = useMatches()) == null ? void 0 : _useMatches[0];
|
|
188
216
|
const match = router.state.matches.find(d => d.routeId === routeId);
|
|
189
217
|
|
|
190
218
|
if ((_opts$strict = opts == null ? void 0 : opts.strict) != null ? _opts$strict : true) {
|
|
191
|
-
index
|
|
192
|
-
index
|
|
219
|
+
index.invariant(match, "Could not find an active match for \"" + routeId + "\"!");
|
|
220
|
+
index.invariant(runtimeMatch.routeId == (match == null ? void 0 : match.routeId), "useMatch(\"" + (match == null ? void 0 : match.routeId) + "\") is being called in a component that is meant to render the '" + runtimeMatch.routeId + "' route. Did you mean to 'useMatch(\"" + (match == null ? void 0 : match.routeId) + "\", { strict: false })' or 'useRoute(\"" + (match == null ? void 0 : match.routeId) + "\")' instead?");
|
|
193
221
|
}
|
|
194
222
|
|
|
195
223
|
return match;
|
|
@@ -226,11 +254,12 @@ function RouterProvider(_ref2) {
|
|
|
226
254
|
router.update(rest);
|
|
227
255
|
useRouterSubscription(router);
|
|
228
256
|
React__namespace.useEffect(() => {
|
|
257
|
+
console.log('hello');
|
|
229
258
|
return router.mount();
|
|
230
259
|
}, [router]);
|
|
231
260
|
return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
|
|
232
261
|
value: {
|
|
233
|
-
router
|
|
262
|
+
router: router
|
|
234
263
|
}
|
|
235
264
|
}, /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
|
|
236
265
|
value: router.state.matches
|
|
@@ -238,13 +267,17 @@ function RouterProvider(_ref2) {
|
|
|
238
267
|
}
|
|
239
268
|
function useRouter() {
|
|
240
269
|
const value = React__namespace.useContext(routerContext);
|
|
241
|
-
index
|
|
270
|
+
index.warning(!value, 'useRouter must be used inside a <Router> component!');
|
|
242
271
|
useRouterSubscription(value.router);
|
|
243
272
|
return value.router;
|
|
244
273
|
}
|
|
245
274
|
function useMatches() {
|
|
246
275
|
return React__namespace.useContext(matchesContext);
|
|
247
276
|
}
|
|
277
|
+
function useMatch(routeId, opts) {
|
|
278
|
+
const router = useRouter();
|
|
279
|
+
return router.useMatch(routeId, opts);
|
|
280
|
+
}
|
|
248
281
|
function Outlet() {
|
|
249
282
|
var _ref3, _match$__$pendingComp, _match$__$errorCompon;
|
|
250
283
|
|
|
@@ -276,12 +309,8 @@ function Outlet() {
|
|
|
276
309
|
return /*#__PURE__*/React__namespace.createElement((_ref4 = (_ref5 = match.__.component) != null ? _ref5 : router.options.defaultComponent) != null ? _ref4 : Outlet);
|
|
277
310
|
}
|
|
278
311
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
throw match.__.loadPromise;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
index$1.invariant(false, 'This should never happen!');
|
|
312
|
+
console.log(match.matchId, 'suspend');
|
|
313
|
+
throw match.__.loadPromise;
|
|
285
314
|
})())));
|
|
286
315
|
}
|
|
287
316
|
|
|
@@ -367,46 +396,47 @@ function Prompt(_ref7) {
|
|
|
367
396
|
return children != null ? children : null;
|
|
368
397
|
}
|
|
369
398
|
|
|
370
|
-
exports.cleanPath = index
|
|
371
|
-
exports.createBrowserHistory = index
|
|
372
|
-
exports.createHashHistory = index
|
|
373
|
-
exports.createMemoryHistory = index
|
|
374
|
-
exports.createRoute = index
|
|
375
|
-
exports.createRouteConfig = index
|
|
376
|
-
exports.createRouteMatch = index
|
|
377
|
-
exports.createRouter = index
|
|
378
|
-
exports.decode = index
|
|
379
|
-
exports.defaultParseSearch = index
|
|
380
|
-
exports.defaultStringifySearch = index
|
|
381
|
-
exports.encode = index
|
|
382
|
-
exports.functionalUpdate = index
|
|
383
|
-
exports.interpolatePath = index
|
|
384
|
-
exports.invariant = index
|
|
385
|
-
exports.joinPaths = index
|
|
386
|
-
exports.last = index
|
|
387
|
-
exports.matchByPath = index
|
|
388
|
-
exports.matchPathname = index
|
|
389
|
-
exports.parsePathname = index
|
|
390
|
-
exports.parseSearchWith = index
|
|
391
|
-
exports.pick = index
|
|
392
|
-
exports.replaceEqualDeep = index
|
|
393
|
-
exports.resolvePath = index
|
|
394
|
-
exports.rootRouteId = index
|
|
395
|
-
exports.stringifySearchWith = index
|
|
396
|
-
exports.trimPath = index
|
|
397
|
-
exports.trimPathLeft = index
|
|
398
|
-
exports.trimPathRight = index
|
|
399
|
-
exports.warning = index
|
|
400
|
-
Object.defineProperty(exports, 'lazy', {
|
|
401
|
-
enumerable: true,
|
|
402
|
-
get: function () { return index.lazyWithPreload; }
|
|
403
|
-
});
|
|
399
|
+
exports.cleanPath = index.cleanPath;
|
|
400
|
+
exports.createBrowserHistory = index.createBrowserHistory;
|
|
401
|
+
exports.createHashHistory = index.createHashHistory;
|
|
402
|
+
exports.createMemoryHistory = index.createMemoryHistory;
|
|
403
|
+
exports.createRoute = index.createRoute;
|
|
404
|
+
exports.createRouteConfig = index.createRouteConfig;
|
|
405
|
+
exports.createRouteMatch = index.createRouteMatch;
|
|
406
|
+
exports.createRouter = index.createRouter;
|
|
407
|
+
exports.decode = index.decode;
|
|
408
|
+
exports.defaultParseSearch = index.defaultParseSearch;
|
|
409
|
+
exports.defaultStringifySearch = index.defaultStringifySearch;
|
|
410
|
+
exports.encode = index.encode;
|
|
411
|
+
exports.functionalUpdate = index.functionalUpdate;
|
|
412
|
+
exports.interpolatePath = index.interpolatePath;
|
|
413
|
+
exports.invariant = index.invariant;
|
|
414
|
+
exports.joinPaths = index.joinPaths;
|
|
415
|
+
exports.last = index.last;
|
|
416
|
+
exports.matchByPath = index.matchByPath;
|
|
417
|
+
exports.matchPathname = index.matchPathname;
|
|
418
|
+
exports.parsePathname = index.parsePathname;
|
|
419
|
+
exports.parseSearchWith = index.parseSearchWith;
|
|
420
|
+
exports.pick = index.pick;
|
|
421
|
+
exports.replaceEqualDeep = index.replaceEqualDeep;
|
|
422
|
+
exports.resolvePath = index.resolvePath;
|
|
423
|
+
exports.rootRouteId = index.rootRouteId;
|
|
424
|
+
exports.stringifySearchWith = index.stringifySearchWith;
|
|
425
|
+
exports.trimPath = index.trimPath;
|
|
426
|
+
exports.trimPathLeft = index.trimPathLeft;
|
|
427
|
+
exports.trimPathRight = index.trimPathRight;
|
|
428
|
+
exports.warning = index.warning;
|
|
404
429
|
exports.DefaultErrorBoundary = DefaultErrorBoundary;
|
|
430
|
+
exports.Link = Link;
|
|
405
431
|
exports.MatchesProvider = MatchesProvider;
|
|
406
432
|
exports.Outlet = Outlet;
|
|
407
433
|
exports.Prompt = Prompt;
|
|
408
434
|
exports.RouterProvider = RouterProvider;
|
|
409
435
|
exports.createReactRouter = createReactRouter;
|
|
436
|
+
exports.lazy = lazy;
|
|
437
|
+
exports.matchesContext = matchesContext;
|
|
438
|
+
exports.routerContext = routerContext;
|
|
439
|
+
exports.useMatch = useMatch;
|
|
410
440
|
exports.useMatches = useMatches;
|
|
411
441
|
exports.usePrompt = usePrompt;
|
|
412
442
|
exports.useRouter = useRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { useSyncExternalStore } from 'use-sync-external-store/shim'\n\nimport {\n AnyRoute,\n CheckId,\n rootRouteId,\n Router,\n RouterState,\n ToIdOption,\n} from '@tanstack/router-core'\nimport {\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n RouteConfig,\n AnyRouteConfig,\n AnyAllRouteInfo,\n DefaultAllRouteInfo,\n functionalUpdate,\n createRouter,\n AnyRouteInfo,\n AllRouteInfo,\n RouteInfo,\n ValidFromPath,\n LinkOptions,\n RouteInfoByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n} from '@tanstack/router-core'\n\nexport * from '@tanstack/router-core'\n\nexport { lazyWithPreload as lazy } from 'react-lazy-with-preload/lib/index'\nexport type { PreloadableComponent as LazyComponent } from 'react-lazy-with-preload'\n\ntype SyncRouteComponent = (props?: {}) => React.ReactNode\nexport type RouteComponent = SyncRouteComponent & {\n preload?: () => Promise<{\n default: SyncRouteComponent\n }>\n}\n\ndeclare module '@tanstack/router-core' {\n interface FrameworkGenerics {\n Component: RouteComponent\n }\n\n interface Router<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,\n > {\n useState: () => RouterState\n useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(\n routeId: TId,\n ) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n useMatch: <\n TId extends keyof TAllRouteInfo['routeInfoById'],\n TStrict extends true | false = true,\n >(\n routeId: TId,\n opts?: { strict?: TStrict },\n ) => TStrict extends true\n ? RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n :\n | RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n | undefined\n linkProps: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, '/', TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n ) => React.AnchorHTMLAttributes<HTMLAnchorElement>\n Link: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, '/', TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\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 | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n },\n ) => JSX.Element\n MatchRoute: <TTo extends string = '.'>(\n props: ToOptions<TAllRouteInfo, '/', TTo> &\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 | React.ReactNode\n | ((\n params: RouteInfoByPath<\n TAllRouteInfo,\n ResolveRelativePath<'/', NoInfer<TTo>>\n >['allParams'],\n ) => React.ReactNode)\n },\n ) => JSX.Element\n }\n\n interface Route<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n > {\n useRoute: <\n TTo extends string = '.',\n TResolved extends string = ResolveRelativePath<\n TRouteInfo['id'],\n NoInfer<TTo>\n >,\n >(\n routeId: CheckId<\n TAllRouteInfo,\n TResolved,\n ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo>\n >,\n opts?: { strict?: boolean },\n ) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TResolved]>\n linkProps: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n ) => React.AnchorHTMLAttributes<HTMLAnchorElement>\n Link: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\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 | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n },\n ) => JSX.Element\n MatchRoute: <TTo extends string = '.'>(\n props: ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\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 | React.ReactNode\n | ((\n params: RouteInfoByPath<\n TAllRouteInfo,\n ResolveRelativePath<TRouteInfo['fullPath'], NoInfer<TTo>>\n >['allParams'],\n ) => React.ReactNode)\n },\n ) => JSX.Element\n }\n}\n\ntype LinkPropsOptions<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TFrom extends ValidFromPath<TAllRouteInfo> = '/',\n TTo extends string = '.',\n> = LinkOptions<TAllRouteInfo, TFrom, TTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n\nexport type PromptProps = {\n message: string\n when?: boolean | any\n children?: React.ReactNode\n}\n\n//\n\nconst matchesContext = React.createContext<RouteMatch[]>(null!)\nconst routerContext = React.createContext<{ router: Router<any, any> }>(null!)\n\n// Detect if we're in the DOM\nconst isDOM = Boolean(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement,\n)\n\nconst useLayoutEffect = isDOM ? React.useLayoutEffect : React.useEffect\n\nexport type MatchesProviderProps = {\n value: RouteMatch[]\n children: React.ReactNode\n}\n\nexport function MatchesProvider(props: MatchesProviderProps) {\n return <matchesContext.Provider {...props} />\n}\n\nconst useRouterSubscription = (router: Router<any, any>) => {\n useSyncExternalStore(\n (cb) => router.subscribe(() => cb()),\n () => router.state,\n () => router.state,\n )\n}\n\nexport function createReactRouter<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n>(opts: RouterOptions<TRouteConfig>): Router<TRouteConfig> {\n const makeRouteExt = (\n route: AnyRoute,\n router: Router<any, any>,\n ): Pick<AnyRoute, 'useRoute' | 'linkProps' | 'Link' | 'MatchRoute'> => {\n return {\n useRoute: (subRouteId = '.' as any) => {\n const resolvedRouteId = router.resolvePath(\n route.routeId,\n subRouteId as string,\n )\n const resolvedRoute = router.getRoute(resolvedRouteId)\n useRouterSubscription(router)\n invariant(\n resolvedRoute,\n `Could not find a route for route \"${\n resolvedRouteId as string\n }\"! Did you forget to add it to your route config?`,\n )\n return resolvedRoute\n },\n linkProps: (options) => {\n const {\n // custom props\n type,\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n // fromCurrent,\n hash,\n search,\n params,\n to,\n preload,\n preloadDelay,\n preloadMaxAge,\n replace,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n ...rest\n } = options\n\n const linkInfo = route.buildLink(options)\n\n if (linkInfo.type === 'external') {\n const { href } = linkInfo\n return { href }\n }\n\n const {\n handleClick,\n handleFocus,\n handleEnter,\n handleLeave,\n isActive,\n next,\n } = linkInfo\n\n const reactHandleClick = (e: Event) => {\n React.startTransition(() => {\n handleClick(e)\n })\n }\n\n const composeHandlers =\n (handlers: (undefined | ((e: any) => void))[]) =>\n (e: React.SyntheticEvent) => {\n e.persist()\n handlers.forEach((handler) => {\n if (handler) handler(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? functionalUpdate(activeProps, {}) ?? {} : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {}\n\n return {\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n ...rest,\n href: disabled ? undefined : next.href,\n onClick: composeHandlers([reactHandleClick, onClick]),\n onFocus: composeHandlers([handleFocus, onFocus]),\n onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),\n onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),\n target,\n style: {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n },\n className:\n [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n ...(disabled\n ? {\n role: 'link',\n 'aria-disabled': true,\n }\n : undefined),\n ['data-status']: isActive ? 'active' : undefined,\n }\n },\n Link: React.forwardRef((props: any, ref) => {\n const linkProps = route.linkProps(props)\n\n useRouterSubscription(router)\n\n return (\n <a\n {...{\n ref: ref as any,\n ...linkProps,\n children:\n typeof props.children === 'function'\n ? props.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : props.children,\n }}\n />\n )\n }) as any,\n MatchRoute: (opts) => {\n const { pending, caseSensitive, children, ...rest } = opts\n\n const params = route.matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n\n if (!params) {\n return null\n }\n\n return typeof opts.children === 'function'\n ? opts.children(params as any)\n : (opts.children as any)\n },\n }\n }\n\n const coreRouter = createRouter<TRouteConfig>({\n ...opts,\n createRouter: (router) => {\n const routerExt: Pick<Router<any, any>, 'useMatch' | 'useState'> = {\n useState: () => {\n useRouterSubscription(router)\n return router.state\n },\n useMatch: (routeId, opts) => {\n useRouterSubscription(router)\n\n invariant(\n routeId !== rootRouteId,\n `\"${rootRouteId}\" cannot be used with useMatch! Did you mean to useRoute(\"${rootRouteId}\")?`,\n )\n\n const runtimeMatch = useMatches()?.[0]!\n const match = router.state.matches.find((d) => d.routeId === routeId)\n\n if (opts?.strict ?? true) {\n invariant(\n match,\n `Could not find an active match for \"${routeId as string}\"!`,\n )\n\n invariant(\n runtimeMatch.routeId == match?.routeId,\n `useMatch(\"${\n match?.routeId as string\n }\") is being called in a component that is meant to render the '${\n runtimeMatch.routeId\n }' route. Did you mean to 'useMatch(\"${\n match?.routeId as string\n }\", { strict: false })' or 'useRoute(\"${\n match?.routeId as string\n }\")' instead?`,\n )\n }\n\n return match as any\n },\n }\n\n const routeExt = makeRouteExt(router.getRoute('/'), router)\n\n Object.assign(router, routerExt, routeExt)\n },\n createRoute: ({ router, route }) => {\n const routeExt = makeRouteExt(route, router)\n\n Object.assign(route, routeExt)\n },\n loadComponent: async (component) => {\n if (component.preload && typeof document !== 'undefined') {\n component.preload()\n // return await component.preload()\n }\n\n return component as any\n },\n })\n\n return coreRouter as any\n}\n\nexport type RouterProps<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n> = RouterOptions<TRouteConfig> & {\n router: Router<TRouteConfig, TAllRouteInfo>\n // Children will default to `<Outlet />` if not provided\n children?: React.ReactNode\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n>({ children, router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo>) {\n router.update(rest)\n\n useRouterSubscription(router)\n React.useEffect(() => {\n return router.mount()\n }, [router])\n\n return (\n <routerContext.Provider value={{ router }}>\n <MatchesProvider value={router.state.matches}>\n {children ?? <Outlet />}\n </MatchesProvider>\n </routerContext.Provider>\n )\n}\n\nexport function useRouter(): Router {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n\n useRouterSubscription(value.router)\n\n return value.router as Router\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function Outlet() {\n const router = useRouter()\n const matches = useMatches().slice(1)\n const match = matches[0]\n\n const defaultPending = React.useCallback(() => null, [])\n\n if (!match) {\n return null\n }\n\n const PendingComponent = (match.__.pendingComponent ??\n router.options.defaultPendingComponent ??\n defaultPending) as any\n\n const errorComponent =\n match.__.errorComponent ?? router.options.defaultErrorComponent\n\n return (\n <MatchesProvider value={matches}>\n <React.Suspense fallback={<PendingComponent />}>\n <CatchBoundary errorComponent={errorComponent}>\n {\n ((): React.ReactNode => {\n if (match.status === 'error') {\n throw match.error\n }\n\n if (match.status === 'success') {\n return React.createElement(\n (match.__.component as any) ??\n router.options.defaultComponent ??\n Outlet,\n )\n }\n\n if (match.__.loadPromise) {\n console.log(match.matchId, 'suspend')\n throw match.__.loadPromise\n }\n\n invariant(false, 'This should never happen!')\n })() as JSX.Element\n }\n </CatchBoundary>\n </React.Suspense>\n </MatchesProvider>\n )\n}\n\nclass CatchBoundary extends React.Component<{\n children: any\n errorComponent: any\n}> {\n state = {\n error: false,\n }\n componentDidCatch(error: any, info: any) {\n console.error(error)\n\n this.setState({\n error,\n info,\n })\n }\n render() {\n const errorComponent = this.props.errorComponent ?? DefaultErrorBoundary\n\n if (this.state.error) {\n return React.createElement(errorComponent, this.state)\n }\n\n return this.props.children\n }\n}\n\nexport function DefaultErrorBoundary({ error }: { error: any }) {\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <strong style={{ fontSize: '1.2rem' }}>Something went wrong!</strong>\n <div style={{ height: '.5rem' }} />\n <div>\n <pre>\n {error.message ? (\n <code\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.5rem',\n color: 'red',\n }}\n >\n {error.message}\n </code>\n ) : null}\n </pre>\n </div>\n </div>\n )\n}\n\nexport function usePrompt(message: string, when: boolean | any): void {\n const router = useRouter()\n\n React.useEffect(() => {\n if (!when) return\n\n let unblock = router.history.block((transition) => {\n if (window.confirm(message)) {\n unblock()\n transition.retry()\n } else {\n router.location.pathname = window.location.pathname\n }\n })\n\n return unblock\n }, [when, location, message])\n}\n\nexport function Prompt({ message, when, children }: PromptProps) {\n usePrompt(message, when ?? true)\n return (children ?? null) as React.ReactNode\n}\n"],"names":["matchesContext","React","createContext","routerContext","MatchesProvider","props","useRouterSubscription","router","useSyncExternalStore","cb","subscribe","state","createReactRouter","opts","makeRouteExt","route","useRoute","subRouteId","resolvedRouteId","resolvePath","routeId","resolvedRoute","getRoute","invariant","linkProps","options","target","activeProps","className","inactiveProps","disabled","style","onClick","onFocus","onMouseEnter","onMouseLeave","rest","linkInfo","buildLink","type","href","handleClick","handleFocus","handleEnter","handleLeave","isActive","next","reactHandleClick","e","startTransition","composeHandlers","handlers","persist","forEach","handler","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","_extends","undefined","filter","Boolean","join","role","Link","forwardRef","ref","children","MatchRoute","pending","caseSensitive","params","matchRoute","coreRouter","createRouter","routerExt","useState","useMatch","rootRouteId","runtimeMatch","useMatches","match","matches","find","d","strict","routeExt","Object","assign","createRoute","loadComponent","component","preload","document","RouterProvider","_objectWithoutPropertiesLoose","update","useEffect","mount","useRouter","value","useContext","warning","Outlet","slice","defaultPending","useCallback","PendingComponent","__","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","status","error","createElement","defaultComponent","loadPromise","console","log","matchId","CatchBoundary","Component","componentDidCatch","info","setState","render","DefaultErrorBoundary","padding","maxWidth","fontSize","height","message","border","borderRadius","color","usePrompt","when","unblock","history","block","transition","window","confirm","retry","location","pathname","Prompt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2KA;AAEA,MAAMA,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AAeX,OAAf,CAAJ,EAA6B;QAC3BM,OAAO,EAAA,CAAA;AACPG,QAAAA,UAAU,CAACG,KAAX,EAAA,CAAA;AACD,OAHD,MAGO;QACLzI,MAAM,CAAC0I,QAAP,CAAgBC,QAAhB,GAA2BJ,MAAM,CAACG,QAAP,CAAgBC,QAA3C,CAAA;AACD,OAAA;AACF,KAPa,CAAd,CAAA;AASA,IAAA,OAAOR,OAAP,CAAA;AACD,GAbD,EAaG,CAACD,IAAD,EAAOQ,QAAP,EAAiBb,OAAjB,CAbH,CAAA,CAAA;AAcD,CAAA;AAEM,SAASe,MAAT,CAA0D,KAAA,EAAA;EAAA,IAA1C;IAAEf,OAAF;IAAWK,IAAX;AAAiBtE,IAAAA,QAAAA;GAAyB,GAAA,KAAA,CAAA;EAC/DqE,SAAS,CAACJ,OAAD,EAAUK,IAAV,WAAUA,IAAV,GAAkB,IAAlB,CAAT,CAAA;AACA,EAAA,OAAQtE,QAAR,IAAA,IAAA,GAAQA,QAAR,GAAoB,IAApB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { useSyncExternalStore } from 'use-sync-external-store/shim'\n\nimport {\n AnyRoute,\n CheckId,\n rootRouteId,\n RouterState,\n ToIdOption,\n} from '@tanstack/router-core'\nimport {\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n RouteConfig,\n AnyRouteConfig,\n AnyAllRouteInfo,\n DefaultAllRouteInfo,\n functionalUpdate,\n createRouter,\n AnyRouteInfo,\n AllRouteInfo,\n RouteInfo,\n ValidFromPath,\n LinkOptions,\n RouteInfoByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n Router,\n} from '@tanstack/router-core'\n\nexport * from '@tanstack/router-core'\n\nexport interface ResolveRouter {\n // router: Router\n}\n\nexport type ResolvedRouter = ResolveRouter extends {\n router: Router<infer TRouteConfig, infer TAllRouteInfo>\n}\n ? Router<TRouteConfig, TAllRouteInfo>\n : Router\n\nexport type ResolvedAllRouteInfo = ResolveRouter extends {\n router: Router<infer TRouteConfig, infer TAllRouteInfo>\n}\n ? TAllRouteInfo\n : AnyAllRouteInfo\n\nexport type SyncRouteComponent = (props?: {}) => JSX.Element | React.ReactNode\n\nexport type RouteComponent = SyncRouteComponent & {\n preload?: () => Promise<SyncRouteComponent>\n}\n\nexport function lazy(\n importer: () => Promise<{ default: SyncRouteComponent }>,\n): RouteComponent {\n const lazyComp = React.lazy(importer as any)\n let promise: Promise<SyncRouteComponent>\n let resolvedComp: SyncRouteComponent\n\n const forwardedComp = React.forwardRef((props, ref) => {\n const resolvedCompRef = React.useRef(resolvedComp || lazyComp)\n return React.createElement(\n resolvedCompRef.current as any,\n { ...(ref ? { ref } : {}), ...props } as any,\n )\n })\n\n const finalComp = forwardedComp as unknown as RouteComponent\n\n finalComp.preload = () => {\n if (!promise) {\n promise = importer().then((module) => {\n resolvedComp = module.default\n return resolvedComp\n })\n }\n\n return promise\n }\n\n return finalComp\n}\n\ndeclare module '@tanstack/router-core' {\n interface FrameworkGenerics {\n Component: RouteComponent\n }\n\n interface Router<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,\n > {\n useState: () => RouterState\n useRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(\n routeId: TId,\n ) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n useMatch: <\n TId extends keyof TAllRouteInfo['routeInfoById'],\n TStrict extends true | false = true,\n >(\n routeId: TId,\n opts?: { strict?: TStrict },\n ) => TStrict extends true\n ? RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n :\n | RouteMatch<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>\n | undefined\n linkProps: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, '/', TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n ) => React.AnchorHTMLAttributes<HTMLAnchorElement>\n Link: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, '/', TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\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 | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n },\n ) => JSX.Element\n MatchRoute: <TTo extends string = '.'>(\n props: ToOptions<TAllRouteInfo, '/', TTo> &\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 | React.ReactNode\n | ((\n params: RouteInfoByPath<\n TAllRouteInfo,\n ResolveRelativePath<'/', NoInfer<TTo>>\n >['allParams'],\n ) => React.ReactNode)\n },\n ) => JSX.Element\n }\n\n interface Route<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n > {\n useRoute: <\n TTo extends string = '.',\n TResolved extends string = ResolveRelativePath<\n TRouteInfo['id'],\n NoInfer<TTo>\n >,\n >(\n routeId: CheckId<\n TAllRouteInfo,\n TResolved,\n ToIdOption<TAllRouteInfo, TRouteInfo['id'], TTo>\n >,\n opts?: { strict?: boolean },\n ) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TResolved]>\n linkProps: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n ) => React.AnchorHTMLAttributes<HTMLAnchorElement>\n Link: <TTo extends string = '.'>(\n props: LinkPropsOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\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 | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n },\n ) => JSX.Element\n MatchRoute: <TTo extends string = '.'>(\n props: ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo> &\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 | React.ReactNode\n | ((\n params: RouteInfoByPath<\n TAllRouteInfo,\n ResolveRelativePath<TRouteInfo['fullPath'], NoInfer<TTo>>\n >['allParams'],\n ) => React.ReactNode)\n },\n ) => JSX.Element\n }\n}\n\ntype LinkPropsOptions<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TFrom extends ValidFromPath<TAllRouteInfo> = '/',\n TTo extends string = '.',\n> = LinkOptions<TAllRouteInfo, TFrom, TTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n\nexport type PromptProps = {\n message: string\n when?: boolean | any\n children?: React.ReactNode\n}\n\n//\n\nexport function Link<TTo extends string = '.'>(\n props: LinkPropsOptions<ResolvedAllRouteInfo, '/', TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n children?:\n | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n },\n): JSX.Element {\n const router = useRouter()\n return <router.Link {...(props as any)} />\n}\n\nexport const matchesContext = React.createContext<RouteMatch[]>(null!)\nexport const routerContext = React.createContext<{ router: ResolvedRouter }>(\n null!,\n)\n\nexport type MatchesProviderProps = {\n value: RouteMatch[]\n children: React.ReactNode\n}\n\nexport function MatchesProvider(props: MatchesProviderProps) {\n return <matchesContext.Provider {...props} />\n}\n\nconst useRouterSubscription = (router: Router<any, any>) => {\n useSyncExternalStore(\n (cb) => router.subscribe(() => cb()),\n () => router.state,\n () => router.state,\n )\n}\n\nexport function createReactRouter<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n>(opts: RouterOptions<TRouteConfig>): Router<TRouteConfig> {\n const makeRouteExt = (\n route: AnyRoute,\n router: Router<any, any>,\n ): Pick<AnyRoute, 'useRoute' | 'linkProps' | 'Link' | 'MatchRoute'> => {\n return {\n useRoute: (subRouteId = '.' as any) => {\n const resolvedRouteId = router.resolvePath(\n route.routeId,\n subRouteId as string,\n )\n const resolvedRoute = router.getRoute(resolvedRouteId)\n useRouterSubscription(router)\n invariant(\n resolvedRoute,\n `Could not find a route for route \"${\n resolvedRouteId as string\n }\"! Did you forget to add it to your route config?`,\n )\n return resolvedRoute\n },\n linkProps: (options) => {\n const {\n // custom props\n type,\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n // fromCurrent,\n hash,\n search,\n params,\n to,\n preload,\n preloadDelay,\n preloadMaxAge,\n replace,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n ...rest\n } = options\n\n const linkInfo = route.buildLink(options)\n\n if (linkInfo.type === 'external') {\n const { href } = linkInfo\n return { href }\n }\n\n const {\n handleClick,\n handleFocus,\n handleEnter,\n handleLeave,\n isActive,\n next,\n } = linkInfo\n\n const reactHandleClick = (e: Event) => {\n React.startTransition(() => {\n handleClick(e)\n })\n }\n\n const composeHandlers =\n (handlers: (undefined | ((e: any) => void))[]) =>\n (e: React.SyntheticEvent) => {\n e.persist()\n handlers.forEach((handler) => {\n if (handler) handler(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? functionalUpdate(activeProps, {}) ?? {} : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {}\n\n return {\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n ...rest,\n href: disabled ? undefined : next.href,\n onClick: composeHandlers([reactHandleClick, onClick]),\n onFocus: composeHandlers([handleFocus, onFocus]),\n onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),\n onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),\n target,\n style: {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n },\n className:\n [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n ...(disabled\n ? {\n role: 'link',\n 'aria-disabled': true,\n }\n : undefined),\n ['data-status']: isActive ? 'active' : undefined,\n }\n },\n Link: React.forwardRef((props: any, ref) => {\n const linkProps = route.linkProps(props)\n\n useRouterSubscription(router)\n\n return (\n <a\n {...{\n ref: ref as any,\n ...linkProps,\n children:\n typeof props.children === 'function'\n ? props.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : props.children,\n }}\n />\n )\n }) as any,\n MatchRoute: (opts) => {\n const { pending, caseSensitive, children, ...rest } = opts\n\n const params = route.matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n\n if (!params) {\n return null\n }\n\n return typeof opts.children === 'function'\n ? opts.children(params as any)\n : (opts.children as any)\n },\n }\n }\n\n const coreRouter = createRouter<TRouteConfig>({\n ...opts,\n createRouter: (router) => {\n const routerExt: Pick<Router<any, any>, 'useMatch' | 'useState'> = {\n useState: () => {\n useRouterSubscription(router)\n return router.state\n },\n useMatch: (routeId, opts) => {\n useRouterSubscription(router)\n\n invariant(\n routeId !== rootRouteId,\n `\"${rootRouteId}\" cannot be used with useMatch! Did you mean to useRoute(\"${rootRouteId}\")?`,\n )\n\n const runtimeMatch = useMatches()?.[0]!\n const match = router.state.matches.find((d) => d.routeId === routeId)\n\n if (opts?.strict ?? true) {\n invariant(\n match,\n `Could not find an active match for \"${routeId as string}\"!`,\n )\n\n invariant(\n runtimeMatch.routeId == match?.routeId,\n `useMatch(\"${\n match?.routeId as string\n }\") is being called in a component that is meant to render the '${\n runtimeMatch.routeId\n }' route. Did you mean to 'useMatch(\"${\n match?.routeId as string\n }\", { strict: false })' or 'useRoute(\"${\n match?.routeId as string\n }\")' instead?`,\n )\n }\n\n return match as any\n },\n }\n\n const routeExt = makeRouteExt(router.getRoute('/'), router)\n\n Object.assign(router, routerExt, routeExt)\n },\n createRoute: ({ router, route }) => {\n const routeExt = makeRouteExt(route, router)\n\n Object.assign(route, routeExt)\n },\n loadComponent: async (component) => {\n if (component.preload && typeof document !== 'undefined') {\n component.preload()\n // return await component.preload()\n }\n\n return component as any\n },\n })\n\n return coreRouter as any\n}\n\nexport type RouterProps<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n> = RouterOptions<TRouteConfig> & {\n router: Router<TRouteConfig, TAllRouteInfo>\n // Children will default to `<Outlet />` if not provided\n children?: React.ReactNode\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n>({ children, router, ...rest }: RouterProps<TRouteConfig, TAllRouteInfo>) {\n router.update(rest)\n\n useRouterSubscription(router)\n React.useEffect(() => {\n console.log('hello')\n return router.mount()\n }, [router])\n\n return (\n <routerContext.Provider value={{ router: router as any }}>\n <MatchesProvider value={router.state.matches}>\n {children ?? <Outlet />}\n </MatchesProvider>\n </routerContext.Provider>\n )\n}\n\nexport function useRouter(): ResolvedRouter {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n\n useRouterSubscription(value.router)\n\n return value.router\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function useMatch<\n TId extends keyof ResolvedAllRouteInfo['routeInfoById'],\n TStrict extends true | false = true,\n>(\n routeId: TId,\n opts?: { strict?: TStrict },\n): TStrict extends true\n ? RouteMatch<ResolvedAllRouteInfo, ResolvedAllRouteInfo['routeInfoById'][TId]>\n :\n | RouteMatch<\n ResolvedAllRouteInfo,\n ResolvedAllRouteInfo['routeInfoById'][TId]\n >\n | undefined {\n const router = useRouter()\n return router.useMatch(routeId as any, opts) as any\n}\n\nexport function Outlet() {\n const router = useRouter()\n const matches = useMatches().slice(1)\n const match = matches[0]\n\n const defaultPending = React.useCallback(() => null, [])\n\n if (!match) {\n return null\n }\n\n const PendingComponent = (match.__.pendingComponent ??\n router.options.defaultPendingComponent ??\n defaultPending) as any\n\n const errorComponent =\n match.__.errorComponent ?? router.options.defaultErrorComponent\n\n return (\n <MatchesProvider value={matches}>\n <React.Suspense fallback={<PendingComponent />}>\n <CatchBoundary errorComponent={errorComponent}>\n {\n ((): React.ReactNode => {\n if (match.status === 'error') {\n throw match.error\n }\n\n if (match.status === 'success') {\n return React.createElement(\n (match.__.component as any) ??\n router.options.defaultComponent ??\n Outlet,\n )\n }\n\n console.log(match.matchId, 'suspend')\n throw match.__.loadPromise\n })() as JSX.Element\n }\n </CatchBoundary>\n </React.Suspense>\n </MatchesProvider>\n )\n}\n\nclass CatchBoundary extends React.Component<{\n children: any\n errorComponent: any\n}> {\n state = {\n error: false,\n }\n componentDidCatch(error: any, info: any) {\n console.error(error)\n\n this.setState({\n error,\n info,\n })\n }\n render() {\n const errorComponent = this.props.errorComponent ?? DefaultErrorBoundary\n\n if (this.state.error) {\n return React.createElement(errorComponent, this.state)\n }\n\n return this.props.children\n }\n}\n\nexport function DefaultErrorBoundary({ error }: { error: any }) {\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <strong style={{ fontSize: '1.2rem' }}>Something went wrong!</strong>\n <div style={{ height: '.5rem' }} />\n <div>\n <pre>\n {error.message ? (\n <code\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.5rem',\n color: 'red',\n }}\n >\n {error.message}\n </code>\n ) : null}\n </pre>\n </div>\n </div>\n )\n}\n\nexport function usePrompt(message: string, when: boolean | any): void {\n const router = useRouter()\n\n React.useEffect(() => {\n if (!when) return\n\n let unblock = router.history.block((transition) => {\n if (window.confirm(message)) {\n unblock()\n transition.retry()\n } else {\n router.location.pathname = window.location.pathname\n }\n })\n\n return unblock\n }, [when, location, message])\n}\n\nexport function Prompt({ message, when, children }: PromptProps) {\n usePrompt(message, when ?? true)\n return (children ?? null) as React.ReactNode\n}\n"],"names":["lazy","importer","lazyComp","React","promise","resolvedComp","forwardedComp","forwardRef","props","ref","resolvedCompRef","useRef","createElement","current","finalComp","preload","then","module","default","Link","router","useRouter","matchesContext","createContext","routerContext","MatchesProvider","useRouterSubscription","useSyncExternalStore","cb","subscribe","state","createReactRouter","opts","makeRouteExt","route","useRoute","subRouteId","resolvedRouteId","resolvePath","routeId","resolvedRoute","getRoute","invariant","linkProps","options","target","activeProps","className","inactiveProps","disabled","style","onClick","onFocus","onMouseEnter","onMouseLeave","rest","linkInfo","buildLink","type","href","handleClick","handleFocus","handleEnter","handleLeave","isActive","next","reactHandleClick","e","startTransition","composeHandlers","handlers","persist","forEach","handler","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","_extends","undefined","filter","Boolean","join","role","children","MatchRoute","pending","caseSensitive","params","matchRoute","coreRouter","createRouter","routerExt","useState","useMatch","rootRouteId","runtimeMatch","useMatches","match","matches","find","d","strict","routeExt","Object","assign","createRoute","loadComponent","component","document","RouterProvider","_objectWithoutPropertiesLoose","update","useEffect","console","log","mount","value","useContext","warning","Outlet","slice","defaultPending","useCallback","PendingComponent","__","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","status","error","defaultComponent","matchId","loadPromise","CatchBoundary","Component","componentDidCatch","info","setState","render","DefaultErrorBoundary","padding","maxWidth","fontSize","height","message","border","borderRadius","color","usePrompt","when","unblock","history","block","transition","window","confirm","retry","location","pathname","Prompt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DO,SAASA,IAAT,CACLC,QADK,EAEW;AAChB,EAAA,MAAMC,QAAQ,gBAAGC,gBAAK,CAACH,IAAN,CAAWC,QAAX,CAAjB,CAAA;AACA,EAAA,IAAIG,OAAJ,CAAA;AACA,EAAA,IAAIC,YAAJ,CAAA;EAEA,MAAMC,aAAa,gBAAGH,gBAAK,CAACI,UAAN,CAAiB,CAACC,KAAD,EAAQC,GAAR,KAAgB;IACrD,MAAMC,eAAe,GAAGP,gBAAK,CAACQ,MAAN,CAAaN,YAAY,IAAIH,QAA7B,CAAxB,CAAA;IACA,oBAAOC,gBAAK,CAACS,aAAN,CACLF,eAAe,CAACG,OADX,EAECJ,oCAAAA,CAAAA,EAAAA,EAAAA,GAAG,GAAG;AAAEA,MAAAA,GAAAA;AAAF,KAAH,GAAa,EAFjB,EAEyBD,KAFzB,CAAP,CAAA,CAAA;AAID,GANqB,CAAtB,CAAA;EAQA,MAAMM,SAAS,GAAGR,aAAlB,CAAA;;EAEAQ,SAAS,CAACC,OAAV,GAAoB,MAAM;IACxB,IAAI,CAACX,OAAL,EAAc;AACZA,MAAAA,OAAO,GAAGH,QAAQ,EAAA,CAAGe,IAAX,CAAiBC,MAAD,IAAY;QACpCZ,YAAY,GAAGY,MAAM,CAACC,OAAtB,CAAA;AACA,QAAA,OAAOb,YAAP,CAAA;AACD,OAHS,CAAV,CAAA;AAID,KAAA;;AAED,IAAA,OAAOD,OAAP,CAAA;GARF,CAAA;;AAWA,EAAA,OAAOU,SAAP,CAAA;AACD,CAAA;AA8HD;AAEO,SAASK,IAAT,CACLX,KADK,EAQQ;EACb,MAAMY,MAAM,GAAGC,SAAS,EAAxB,CAAA;AACA,EAAA,oBAAOlB,+BAA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AA;EAEAlB,gBAAK,CAAC6G,SAAN,CAAgB,MAAM;IACpB,IAAI,CAACsC,IAAL,EAAW,OAAA;IAEX,IAAIC,OAAO,GAAGnI,MAAM,CAACoI,OAAP,CAAeC,KAAf,CAAsBC,UAAD,IAAgB;AACjD,MAAA,IAAIC,MAAM,CAACC,OAAP,CAAeX,OAAf,CAAJ,EAA6B;QAC3BM,OAAO,EAAA,CAAA;AACPG,QAAAA,UAAU,CAACG,KAAX,EAAA,CAAA;AACD,OAHD,MAGO;QACLzI,MAAM,CAAC0I,QAAP,CAAgBC,QAAhB,GAA2BJ,MAAM,CAACG,QAAP,CAAgBC,QAA3C,CAAA;AACD,OAAA;AACF,KAPa,CAAd,CAAA;AASA,IAAA,OAAOR,OAAP,CAAA;AACD,GAbD,EAaG,CAACD,IAAD,EAAOQ,QAAP,EAAiBb,OAAjB,CAbH,CAAA,CAAA;AAcD,CAAA;AAEM,SAASe,MAAT,CAA0D,KAAA,EAAA;EAAA,IAA1C;IAAEf,OAAF;IAAWK,IAAX;AAAiBnE,IAAAA,QAAAA;GAAyB,GAAA,KAAA,CAAA;EAC/DkE,SAAS,CAACJ,OAAD,EAAUK,IAAV,WAAUA,IAAV,GAAkB,IAAlB,CAAT,CAAA;AACA,EAAA,OAAQnE,QAAR,IAAA,IAAA,GAAQA,QAAR,GAAoB,IAApB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1502,11 +1502,19 @@ function createRouteMatch(router, route, opts) {
|
|
|
1502
1502
|
}
|
|
1503
1503
|
},
|
|
1504
1504
|
fetch: async opts => {
|
|
1505
|
-
const
|
|
1506
|
-
routeMatch.__.latestId =
|
|
1505
|
+
const loadId = '' + Date.now() + Math.random();
|
|
1506
|
+
routeMatch.__.latestId = loadId;
|
|
1507
|
+
|
|
1508
|
+
const checkLatest = async () => {
|
|
1509
|
+
if (loadId !== routeMatch.__.latestId) {
|
|
1510
|
+
// warning(true, 'Data loader is out of date!')
|
|
1511
|
+
return new Promise(() => {});
|
|
1512
|
+
}
|
|
1513
|
+
}; // If the match was in an error state, set it
|
|
1507
1514
|
// to a loading state again. Otherwise, keep it
|
|
1508
1515
|
// as loading or resolved
|
|
1509
1516
|
|
|
1517
|
+
|
|
1510
1518
|
if (routeMatch.status === 'idle') {
|
|
1511
1519
|
routeMatch.status = 'loading';
|
|
1512
1520
|
} // We started loading the route, so it's no longer invalid
|
|
@@ -1538,19 +1546,8 @@ function createRouteMatch(router, route, opts) {
|
|
|
1538
1546
|
var _ref, _ref2, _opts$maxAge;
|
|
1539
1547
|
|
|
1540
1548
|
if (routeMatch.options.loader) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
const data = await routeMatch.options.loader({
|
|
1544
|
-
parentLoaderPromise: (_routeMatch$parentMat3 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat3.__.dataPromise,
|
|
1545
|
-
params: routeMatch.params,
|
|
1546
|
-
search: routeMatch.routeSearch,
|
|
1547
|
-
signal: routeMatch.__.abortController.signal
|
|
1548
|
-
});
|
|
1549
|
-
|
|
1550
|
-
if (id !== routeMatch.__.latestId) {
|
|
1551
|
-
return routeMatch.__.loadPromise;
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1549
|
+
const data = await router.loadMatchData(routeMatch);
|
|
1550
|
+
await checkLatest();
|
|
1554
1551
|
routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
|
|
1555
1552
|
}
|
|
1556
1553
|
|
|
@@ -1560,9 +1557,7 @@ function createRouteMatch(router, route, opts) {
|
|
|
1560
1557
|
routeMatch.invalidAt = routeMatch.updatedAt + ((_ref = (_ref2 = (_opts$maxAge = opts == null ? void 0 : opts.maxAge) != null ? _opts$maxAge : routeMatch.options.loaderMaxAge) != null ? _ref2 : router.options.defaultLoaderMaxAge) != null ? _ref : 0);
|
|
1561
1558
|
return routeMatch.routeLoaderData;
|
|
1562
1559
|
} catch (err) {
|
|
1563
|
-
|
|
1564
|
-
return routeMatch.__.loadPromise;
|
|
1565
|
-
}
|
|
1560
|
+
await checkLatest();
|
|
1566
1561
|
|
|
1567
1562
|
if (process.env.NODE_ENV !== 'production') {
|
|
1568
1563
|
console.error(err);
|
|
@@ -1575,29 +1570,23 @@ function createRouteMatch(router, route, opts) {
|
|
|
1575
1570
|
}
|
|
1576
1571
|
});
|
|
1577
1572
|
|
|
1578
|
-
|
|
1579
|
-
await
|
|
1580
|
-
|
|
1581
|
-
if (id !== routeMatch.__.latestId) {
|
|
1582
|
-
return routeMatch.__.loadPromise;
|
|
1583
|
-
}
|
|
1584
|
-
} finally {
|
|
1585
|
-
if (id !== routeMatch.__.latestId) {
|
|
1586
|
-
return routeMatch.__.loadPromise;
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1573
|
+
const after = async () => {
|
|
1574
|
+
await checkLatest();
|
|
1589
1575
|
routeMatch.isFetching = false;
|
|
1576
|
+
delete routeMatch.__.loadPromise;
|
|
1590
1577
|
|
|
1591
1578
|
routeMatch.__.notify();
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
try {
|
|
1582
|
+
await Promise.all([routeMatch.__.componentsPromise, routeMatch.__.dataPromise.catch(() => {})]);
|
|
1583
|
+
after();
|
|
1584
|
+
} catch (_unused) {
|
|
1585
|
+
after();
|
|
1592
1586
|
}
|
|
1593
1587
|
});
|
|
1594
1588
|
await routeMatch.__.loadPromise;
|
|
1595
|
-
|
|
1596
|
-
if (id !== routeMatch.__.latestId) {
|
|
1597
|
-
return routeMatch.__.loadPromise;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
delete routeMatch.__.loadPromise;
|
|
1589
|
+
await checkLatest();
|
|
1601
1590
|
}
|
|
1602
1591
|
});
|
|
1603
1592
|
|
|
@@ -1691,6 +1680,8 @@ function createRouter(userOptions) {
|
|
|
1691
1680
|
});
|
|
1692
1681
|
|
|
1693
1682
|
let router = {
|
|
1683
|
+
types: undefined,
|
|
1684
|
+
// public api
|
|
1694
1685
|
history,
|
|
1695
1686
|
options: originalOptions,
|
|
1696
1687
|
listeners: [],
|
|
@@ -1699,7 +1690,6 @@ function createRouter(userOptions) {
|
|
|
1699
1690
|
routeTree: undefined,
|
|
1700
1691
|
routesById: {},
|
|
1701
1692
|
location: undefined,
|
|
1702
|
-
allRouteInfo: undefined,
|
|
1703
1693
|
//
|
|
1704
1694
|
navigationPromise: Promise.resolve(),
|
|
1705
1695
|
resolveNavigation: () => {},
|
|
@@ -2082,6 +2072,11 @@ function createRouter(userOptions) {
|
|
|
2082
2072
|
match.__.validate();
|
|
2083
2073
|
|
|
2084
2074
|
match.load(loaderOpts);
|
|
2075
|
+
const search = match.search;
|
|
2076
|
+
|
|
2077
|
+
if (search.__data && search.__data.matchId !== match.matchId) {
|
|
2078
|
+
return;
|
|
2079
|
+
}
|
|
2085
2080
|
|
|
2086
2081
|
if (match.__.loadPromise) {
|
|
2087
2082
|
// Wait for the first sign of activity from the match
|
|
@@ -2091,6 +2086,37 @@ function createRouter(userOptions) {
|
|
|
2091
2086
|
router.notify();
|
|
2092
2087
|
await Promise.all(matchPromises);
|
|
2093
2088
|
},
|
|
2089
|
+
loadMatchData: async routeMatch => {
|
|
2090
|
+
if (isServer || !router.options.useServerData) {
|
|
2091
|
+
var _await$routeMatch$opt;
|
|
2092
|
+
|
|
2093
|
+
return (_await$routeMatch$opt = await (routeMatch.options.loader == null ? void 0 : routeMatch.options.loader({
|
|
2094
|
+
// parentLoaderPromise: routeMatch.parentMatch?.__.dataPromise,
|
|
2095
|
+
params: routeMatch.params,
|
|
2096
|
+
search: routeMatch.routeSearch,
|
|
2097
|
+
signal: routeMatch.__.abortController.signal
|
|
2098
|
+
}))) != null ? _await$routeMatch$opt : {};
|
|
2099
|
+
} else {
|
|
2100
|
+
const next = router.buildNext({
|
|
2101
|
+
to: '.',
|
|
2102
|
+
search: d => _extends({}, d != null ? d : {}, {
|
|
2103
|
+
__data: {
|
|
2104
|
+
matchId: routeMatch.matchId
|
|
2105
|
+
}
|
|
2106
|
+
})
|
|
2107
|
+
});
|
|
2108
|
+
const res = await fetch(next.href, {
|
|
2109
|
+
method: 'GET' // signal: routeMatch.__.abortController.signal,
|
|
2110
|
+
|
|
2111
|
+
});
|
|
2112
|
+
|
|
2113
|
+
if (res.ok) {
|
|
2114
|
+
return res.json();
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
throw new Error('Failed to fetch match data');
|
|
2118
|
+
}
|
|
2119
|
+
},
|
|
2094
2120
|
invalidateRoute: opts => {
|
|
2095
2121
|
var _router$state$pending5, _router$state$pending6;
|
|
2096
2122
|
|