@tanstack/react-router 0.0.1-beta.18 → 0.0.1-beta.180

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.
@@ -0,0 +1,27 @@
1
+ import * as React from 'react'
2
+ import {
3
+ ScrollRestorationOptions,
4
+ restoreScrollPositions,
5
+ watchScrollPositions,
6
+ } from '@tanstack/router-core'
7
+ import { useRouter } from './react'
8
+
9
+ const useLayoutEffect =
10
+ typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
11
+
12
+ export function useScrollRestoration(options?: ScrollRestorationOptions) {
13
+ const router = useRouter()
14
+
15
+ useLayoutEffect(() => {
16
+ return watchScrollPositions(router, options)
17
+ }, [])
18
+
19
+ useLayoutEffect(() => {
20
+ restoreScrollPositions(router, options)
21
+ })
22
+ }
23
+
24
+ export function ScrollRestoration(props: ScrollRestorationOptions) {
25
+ useScrollRestoration(props)
26
+ return null
27
+ }
@@ -1,413 +0,0 @@
1
- /**
2
- * react-router
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
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
16
- var React = require('react');
17
- var shim = require('use-sync-external-store/shim');
18
- var index$1 = require('../../router-core/build/esm/index.js');
19
- var index = require('react-lazy-with-preload/lib/index');
20
-
21
- function _interopNamespace(e) {
22
- if (e && e.__esModule) return e;
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
31
- });
32
- }
33
- });
34
- }
35
- n["default"] = e;
36
- return Object.freeze(n);
37
- }
38
-
39
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
40
-
41
- 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
- _excluded2 = ["pending", "caseSensitive", "children"],
43
- _excluded3 = ["children", "router"];
44
- //
45
- const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
46
- const routerContext = /*#__PURE__*/React__namespace.createContext(null); // Detect if we're in the DOM
47
- function MatchesProvider(props) {
48
- return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, props);
49
- }
50
-
51
- const useRouterSubscription = router => {
52
- shim.useSyncExternalStore(cb => router.subscribe(() => cb()), () => router.state, () => router.state);
53
- };
54
-
55
- function createReactRouter(opts) {
56
- const makeRouteExt = (route, router) => {
57
- return {
58
- useRoute: function useRoute(subRouteId) {
59
- if (subRouteId === void 0) {
60
- subRouteId = '.';
61
- }
62
-
63
- const resolvedRouteId = router.resolvePath(route.routeId, subRouteId);
64
- const resolvedRoute = router.getRoute(resolvedRouteId);
65
- useRouterSubscription(router);
66
- index$1.invariant(resolvedRoute, "Could not find a route for route \"" + resolvedRouteId + "\"! Did you forget to add it to your route config?");
67
- return resolvedRoute;
68
- },
69
- linkProps: options => {
70
- var _functionalUpdate, _functionalUpdate2;
71
-
72
- const {
73
- // custom props
74
- target,
75
- activeProps = () => ({
76
- className: 'active'
77
- }),
78
- inactiveProps = () => ({}),
79
- disabled,
80
- // element props
81
- style,
82
- className,
83
- onClick,
84
- onFocus,
85
- onMouseEnter,
86
- onMouseLeave
87
- } = options,
88
- rest = _rollupPluginBabelHelpers.objectWithoutPropertiesLoose(options, _excluded);
89
-
90
- const linkInfo = route.buildLink(options);
91
-
92
- if (linkInfo.type === 'external') {
93
- const {
94
- href
95
- } = linkInfo;
96
- return {
97
- href
98
- };
99
- }
100
-
101
- const {
102
- handleClick,
103
- handleFocus,
104
- handleEnter,
105
- handleLeave,
106
- isActive,
107
- next
108
- } = linkInfo;
109
-
110
- const reactHandleClick = e => {
111
- React__namespace.startTransition(() => {
112
- handleClick(e);
113
- });
114
- };
115
-
116
- const composeHandlers = handlers => e => {
117
- e.persist();
118
- handlers.forEach(handler => {
119
- if (handler) handler(e);
120
- });
121
- }; // Get the active props
122
-
123
-
124
- const resolvedActiveProps = isActive ? (_functionalUpdate = index$1.functionalUpdate(activeProps, {})) != null ? _functionalUpdate : {} : {}; // Get the inactive props
125
-
126
- const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = index$1.functionalUpdate(inactiveProps, {})) != null ? _functionalUpdate2 : {};
127
- return _rollupPluginBabelHelpers["extends"]({}, resolvedActiveProps, resolvedInactiveProps, rest, {
128
- href: disabled ? undefined : next.href,
129
- onClick: composeHandlers([reactHandleClick, onClick]),
130
- onFocus: composeHandlers([handleFocus, onFocus]),
131
- onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),
132
- onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),
133
- target,
134
- style: _rollupPluginBabelHelpers["extends"]({}, style, resolvedActiveProps.style, resolvedInactiveProps.style),
135
- className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined
136
- }, disabled ? {
137
- role: 'link',
138
- 'aria-disabled': true
139
- } : undefined, {
140
- ['data-status']: isActive ? 'active' : undefined
141
- });
142
- },
143
- Link: /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
144
- const linkProps = route.linkProps(props);
145
- useRouterSubscription(router);
146
- return /*#__PURE__*/React__namespace.createElement("a", _rollupPluginBabelHelpers["extends"]({
147
- ref: ref
148
- }, linkProps, {
149
- children: typeof props.children === 'function' ? props.children({
150
- isActive: linkProps['data-status'] === 'active'
151
- }) : props.children
152
- }));
153
- }),
154
- MatchRoute: opts => {
155
- const {
156
- pending,
157
- caseSensitive
158
- } = opts,
159
- rest = _rollupPluginBabelHelpers.objectWithoutPropertiesLoose(opts, _excluded2);
160
-
161
- const params = route.matchRoute(rest, {
162
- pending,
163
- caseSensitive
164
- });
165
-
166
- if (!params) {
167
- return null;
168
- }
169
-
170
- return typeof opts.children === 'function' ? opts.children(params) : opts.children;
171
- }
172
- };
173
- };
174
-
175
- const coreRouter = index$1.createRouter(_rollupPluginBabelHelpers["extends"]({}, opts, {
176
- createRouter: router => {
177
- const routerExt = {
178
- useState: () => {
179
- useRouterSubscription(router);
180
- return router.state;
181
- },
182
- useMatch: (routeId, opts) => {
183
- var _useMatches, _opts$strict;
184
-
185
- useRouterSubscription(router);
186
- index$1.invariant(routeId !== index$1.rootRouteId, "\"" + index$1.rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + index$1.rootRouteId + "\")?");
187
- const runtimeMatch = (_useMatches = useMatches()) == null ? void 0 : _useMatches[0];
188
- const match = router.state.matches.find(d => d.routeId === routeId);
189
-
190
- if ((_opts$strict = opts == null ? void 0 : opts.strict) != null ? _opts$strict : true) {
191
- index$1.invariant(match, "Could not find an active match for \"" + routeId + "\"!");
192
- index$1.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
- }
194
-
195
- return match;
196
- }
197
- };
198
- const routeExt = makeRouteExt(router.getRoute('/'), router);
199
- Object.assign(router, routerExt, routeExt);
200
- },
201
- createRoute: _ref => {
202
- let {
203
- router,
204
- route
205
- } = _ref;
206
- const routeExt = makeRouteExt(route, router);
207
- Object.assign(route, routeExt);
208
- },
209
- loadComponent: async component => {
210
- if (component.preload && typeof document !== 'undefined') {
211
- component.preload(); // return await component.preload()
212
- }
213
-
214
- return component;
215
- }
216
- }));
217
- return coreRouter;
218
- }
219
- function RouterProvider(_ref2) {
220
- let {
221
- children,
222
- router
223
- } = _ref2,
224
- rest = _rollupPluginBabelHelpers.objectWithoutPropertiesLoose(_ref2, _excluded3);
225
-
226
- router.update(rest);
227
- useRouterSubscription(router);
228
- React__namespace.useEffect(() => {
229
- return router.mount();
230
- }, [router]);
231
- return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
232
- value: {
233
- router
234
- }
235
- }, /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
236
- value: router.state.matches
237
- }, children != null ? children : /*#__PURE__*/React__namespace.createElement(Outlet, null)));
238
- }
239
- function useRouter() {
240
- const value = React__namespace.useContext(routerContext);
241
- index$1.warning(!value, 'useRouter must be used inside a <Router> component!');
242
- useRouterSubscription(value.router);
243
- return value.router;
244
- }
245
- function useMatches() {
246
- return React__namespace.useContext(matchesContext);
247
- }
248
- function Outlet() {
249
- var _ref3, _match$__$pendingComp, _match$__$errorCompon;
250
-
251
- const router = useRouter();
252
- const matches = useMatches().slice(1);
253
- const match = matches[0];
254
- const defaultPending = React__namespace.useCallback(() => null, []);
255
-
256
- if (!match) {
257
- return null;
258
- }
259
-
260
- const PendingComponent = (_ref3 = (_match$__$pendingComp = match.__.pendingComponent) != null ? _match$__$pendingComp : router.options.defaultPendingComponent) != null ? _ref3 : defaultPending;
261
- const errorComponent = (_match$__$errorCompon = match.__.errorComponent) != null ? _match$__$errorCompon : router.options.defaultErrorComponent;
262
- return /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
263
- value: matches
264
- }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
265
- fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, null)
266
- }, /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
267
- errorComponent: errorComponent
268
- }, (() => {
269
- if (match.status === 'error') {
270
- throw match.error;
271
- }
272
-
273
- if (match.status === 'success') {
274
- var _ref4, _ref5;
275
-
276
- return /*#__PURE__*/React__namespace.createElement((_ref4 = (_ref5 = match.__.component) != null ? _ref5 : router.options.defaultComponent) != null ? _ref4 : Outlet);
277
- }
278
-
279
- if (match.__.loadPromise) {
280
- console.log(match.matchId, 'suspend');
281
- throw match.__.loadPromise;
282
- }
283
-
284
- index$1.invariant(false, 'This should never happen!');
285
- })())));
286
- }
287
-
288
- class CatchBoundary extends React__namespace.Component {
289
- constructor() {
290
- super(...arguments);
291
- this.state = {
292
- error: false
293
- };
294
- }
295
-
296
- componentDidCatch(error, info) {
297
- console.error(error);
298
- this.setState({
299
- error,
300
- info
301
- });
302
- }
303
-
304
- render() {
305
- var _this$props$errorComp;
306
-
307
- const errorComponent = (_this$props$errorComp = this.props.errorComponent) != null ? _this$props$errorComp : DefaultErrorBoundary;
308
-
309
- if (this.state.error) {
310
- return /*#__PURE__*/React__namespace.createElement(errorComponent, this.state);
311
- }
312
-
313
- return this.props.children;
314
- }
315
-
316
- }
317
-
318
- function DefaultErrorBoundary(_ref6) {
319
- let {
320
- error
321
- } = _ref6;
322
- return /*#__PURE__*/React__namespace.createElement("div", {
323
- style: {
324
- padding: '.5rem',
325
- maxWidth: '100%'
326
- }
327
- }, /*#__PURE__*/React__namespace.createElement("strong", {
328
- style: {
329
- fontSize: '1.2rem'
330
- }
331
- }, "Something went wrong!"), /*#__PURE__*/React__namespace.createElement("div", {
332
- style: {
333
- height: '.5rem'
334
- }
335
- }), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", null, error.message ? /*#__PURE__*/React__namespace.createElement("code", {
336
- style: {
337
- fontSize: '.7em',
338
- border: '1px solid red',
339
- borderRadius: '.25rem',
340
- padding: '.5rem',
341
- color: 'red'
342
- }
343
- }, error.message) : null)));
344
- }
345
- function usePrompt(message, when) {
346
- const router = useRouter();
347
- React__namespace.useEffect(() => {
348
- if (!when) return;
349
- let unblock = router.history.block(transition => {
350
- if (window.confirm(message)) {
351
- unblock();
352
- transition.retry();
353
- } else {
354
- router.location.pathname = window.location.pathname;
355
- }
356
- });
357
- return unblock;
358
- }, [when, location, message]);
359
- }
360
- function Prompt(_ref7) {
361
- let {
362
- message,
363
- when,
364
- children
365
- } = _ref7;
366
- usePrompt(message, when != null ? when : true);
367
- return children != null ? children : null;
368
- }
369
-
370
- exports.cleanPath = index$1.cleanPath;
371
- exports.createBrowserHistory = index$1.createBrowserHistory;
372
- exports.createHashHistory = index$1.createHashHistory;
373
- exports.createMemoryHistory = index$1.createMemoryHistory;
374
- exports.createRoute = index$1.createRoute;
375
- exports.createRouteConfig = index$1.createRouteConfig;
376
- exports.createRouteMatch = index$1.createRouteMatch;
377
- exports.createRouter = index$1.createRouter;
378
- exports.decode = index$1.decode;
379
- exports.defaultParseSearch = index$1.defaultParseSearch;
380
- exports.defaultStringifySearch = index$1.defaultStringifySearch;
381
- exports.encode = index$1.encode;
382
- exports.functionalUpdate = index$1.functionalUpdate;
383
- exports.interpolatePath = index$1.interpolatePath;
384
- exports.invariant = index$1.invariant;
385
- exports.joinPaths = index$1.joinPaths;
386
- exports.last = index$1.last;
387
- exports.matchByPath = index$1.matchByPath;
388
- exports.matchPathname = index$1.matchPathname;
389
- exports.parsePathname = index$1.parsePathname;
390
- exports.parseSearchWith = index$1.parseSearchWith;
391
- exports.pick = index$1.pick;
392
- exports.replaceEqualDeep = index$1.replaceEqualDeep;
393
- exports.resolvePath = index$1.resolvePath;
394
- exports.rootRouteId = index$1.rootRouteId;
395
- exports.stringifySearchWith = index$1.stringifySearchWith;
396
- exports.trimPath = index$1.trimPath;
397
- exports.trimPathLeft = index$1.trimPathLeft;
398
- exports.trimPathRight = index$1.trimPathRight;
399
- exports.warning = index$1.warning;
400
- Object.defineProperty(exports, 'lazy', {
401
- enumerable: true,
402
- get: function () { return index.lazyWithPreload; }
403
- });
404
- exports.DefaultErrorBoundary = DefaultErrorBoundary;
405
- exports.MatchesProvider = MatchesProvider;
406
- exports.Outlet = Outlet;
407
- exports.Prompt = Prompt;
408
- exports.RouterProvider = RouterProvider;
409
- exports.createReactRouter = createReactRouter;
410
- exports.useMatches = useMatches;
411
- exports.usePrompt = usePrompt;
412
- exports.useRouter = useRouter;
413
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,cAAc,gBAAGC,gBAAK,CAACC,aAAN,CAAkC,IAAlC,CAAvB,CAAA;AACA,MAAMC,aAAa,gBAAGF,gBAAK,CAACC,aAAN,CAAkD,IAAlD,CAAtB;AAgBO,SAASE,eAAT,CAAyBC,KAAzB,EAAsD;AAC3D,EAAA,oBAAOJ,+BAAC,cAAD,CAAgB,QAAhB,EAA6BI,KAA7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