@tanstack/react-router 0.0.1-beta.38 → 0.0.1-beta.39

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.
@@ -10,7 +10,9 @@
10
10
  */
11
11
  import * as React from 'react';
12
12
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
13
- import { createRouter, rootRouteId, warning, invariant, last, functionalUpdate } from '@tanstack/router-core';
13
+ import { createStore, createRoot, createEffect, untrack, unwrap } from '@solidjs/reactivity';
14
+ export * from '@solidjs/reactivity';
15
+ import { sharedClone, functionalUpdate, createRouter, warning, invariant, last } from '@tanstack/router-core';
14
16
  export * from '@tanstack/router-core';
15
17
 
16
18
  function _extends() {
@@ -27,280 +29,316 @@ function _extends() {
27
29
  };
28
30
  return _extends.apply(this, arguments);
29
31
  }
30
- function _objectWithoutPropertiesLoose(source, excluded) {
31
- if (source == null) return {};
32
- var target = {};
33
- var sourceKeys = Object.keys(source);
34
- var key, i;
35
- for (i = 0; i < sourceKeys.length; i++) {
36
- key = sourceKeys[i];
37
- if (excluded.indexOf(key) >= 0) continue;
38
- target[key] = source[key];
39
- }
40
- return target;
41
- }
42
32
 
43
- 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"],
44
- _excluded2 = ["pending", "caseSensitive", "children"],
45
- _excluded3 = ["router"];
46
33
  function lazy(importer) {
47
34
  const lazyComp = /*#__PURE__*/React.lazy(importer);
48
- let promise;
49
- let resolvedComp;
50
- const forwardedComp = /*#__PURE__*/React.forwardRef((props, ref) => {
51
- const resolvedCompRef = React.useRef(resolvedComp || lazyComp);
52
- return /*#__PURE__*/React.createElement(resolvedCompRef.current, _extends({}, ref ? {
53
- ref
54
- } : {}, props));
55
- });
56
- const finalComp = forwardedComp;
57
- finalComp.preload = () => {
58
- if (!promise) {
59
- promise = importer().then(module => {
60
- resolvedComp = module.default;
61
- return resolvedComp;
62
- });
35
+ const finalComp = lazyComp;
36
+ finalComp.preload = async () => {
37
+ {
38
+ await importer();
63
39
  }
64
- return promise;
65
40
  };
66
41
  return finalComp;
67
42
  }
68
43
  //
69
44
 
70
- function Link(props) {
45
+ function useLinkProps(options) {
71
46
  const router = useRouter();
72
- return /*#__PURE__*/React.createElement(router.Link, props);
47
+ const {
48
+ // custom props
49
+ type,
50
+ children,
51
+ target,
52
+ activeProps = () => ({
53
+ className: 'active'
54
+ }),
55
+ inactiveProps = () => ({}),
56
+ activeOptions,
57
+ disabled,
58
+ // fromCurrent,
59
+ hash,
60
+ search,
61
+ params,
62
+ to,
63
+ preload,
64
+ preloadDelay,
65
+ preloadMaxAge,
66
+ replace,
67
+ // element props
68
+ style,
69
+ className,
70
+ onClick,
71
+ onFocus,
72
+ onMouseEnter,
73
+ onMouseLeave,
74
+ onTouchStart,
75
+ onTouchEnd,
76
+ ...rest
77
+ } = options;
78
+ const linkInfo = router.buildLink(options);
79
+ if (linkInfo.type === 'external') {
80
+ const {
81
+ href
82
+ } = linkInfo;
83
+ return {
84
+ href
85
+ };
86
+ }
87
+ const {
88
+ handleClick,
89
+ handleFocus,
90
+ handleEnter,
91
+ handleLeave,
92
+ isActive,
93
+ next
94
+ } = linkInfo;
95
+ const reactHandleClick = e => {
96
+ if (React.startTransition) {
97
+ // This is a hack for react < 18
98
+ React.startTransition(() => {
99
+ handleClick(e);
100
+ });
101
+ } else {
102
+ handleClick(e);
103
+ }
104
+ };
105
+ const composeHandlers = handlers => e => {
106
+ if (e.persist) e.persist();
107
+ handlers.filter(Boolean).forEach(handler => {
108
+ if (e.defaultPrevented) return;
109
+ handler(e);
110
+ });
111
+ };
112
+
113
+ // Get the active props
114
+ const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? {} : {};
115
+
116
+ // Get the inactive props
117
+ const resolvedInactiveProps = isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {};
118
+ return {
119
+ ...resolvedActiveProps,
120
+ ...resolvedInactiveProps,
121
+ ...rest,
122
+ href: disabled ? undefined : next.href,
123
+ onClick: composeHandlers([onClick, reactHandleClick]),
124
+ onFocus: composeHandlers([onFocus, handleFocus]),
125
+ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
126
+ onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
127
+ target,
128
+ style: {
129
+ ...style,
130
+ ...resolvedActiveProps.style,
131
+ ...resolvedInactiveProps.style
132
+ },
133
+ className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined,
134
+ ...(disabled ? {
135
+ role: 'link',
136
+ 'aria-disabled': true
137
+ } : undefined),
138
+ ['data-status']: isActive ? 'active' : undefined
139
+ };
73
140
  }
141
+ const Link = /*#__PURE__*/React.forwardRef((props, ref) => {
142
+ const linkProps = useLinkProps(props);
143
+ return /*#__PURE__*/React.createElement("a", _extends({
144
+ ref: ref
145
+ }, linkProps, {
146
+ children: typeof props.children === 'function' ? props.children({
147
+ isActive: linkProps['data-status'] === 'active'
148
+ }) : props.children
149
+ }));
150
+ });
74
151
  const matchesContext = /*#__PURE__*/React.createContext(null);
75
152
  const routerContext = /*#__PURE__*/React.createContext(null);
76
- function MatchesProvider(props) {
77
- return /*#__PURE__*/React.createElement(matchesContext.Provider, props);
78
- }
79
- const useRouterSubscription = router => {
80
- useSyncExternalStore(cb => router.subscribe(() => cb()), () => router.state, () => router.state);
81
- };
82
- function createReactRouter(opts) {
83
- const makeRouteExt = (route, router) => {
84
- return {
85
- useRoute: function useRoute(subRouteId) {
86
- if (subRouteId === void 0) {
87
- subRouteId = '.';
88
- }
89
- const resolvedRouteId = router.resolvePath(route.routeId, subRouteId);
90
- const resolvedRoute = router.getRoute(resolvedRouteId);
91
- useRouterSubscription(router);
92
- invariant(resolvedRoute, "Could not find a route for route \"" + resolvedRouteId + "\"! Did you forget to add it to your route config?");
93
- return resolvedRoute;
94
- },
95
- linkProps: options => {
96
- var _functionalUpdate, _functionalUpdate2;
97
- const {
98
- // custom props
153
+ const EMPTY = {};
154
+ const __useStoreValue = (seed, selector) => {
155
+ const valueRef = React.useRef(EMPTY);
99
156
 
100
- target,
101
- activeProps = () => ({
102
- className: 'active'
103
- }),
104
- inactiveProps = () => ({}),
105
- disabled,
106
- // element props
107
- style,
108
- className,
109
- onClick,
110
- onFocus,
111
- onMouseEnter,
112
- onMouseLeave
113
- } = options,
114
- rest = _objectWithoutPropertiesLoose(options, _excluded);
115
- const linkInfo = route.buildLink(options);
116
- if (linkInfo.type === 'external') {
117
- const {
118
- href
119
- } = linkInfo;
120
- return {
121
- href
122
- };
123
- }
124
- const {
125
- handleClick,
126
- handleFocus,
127
- handleEnter,
128
- handleLeave,
129
- isActive,
130
- next
131
- } = linkInfo;
132
- const reactHandleClick = e => {
133
- if (React.startTransition)
134
- // This is a hack for react < 18
135
- React.startTransition(() => {
136
- handleClick(e);
137
- });else handleClick(e);
138
- };
139
- const composeHandlers = handlers => e => {
140
- if (e.persist) e.persist();
141
- handlers.forEach(handler => {
142
- if (e.defaultPrevented) return;
143
- if (handler) handler(e);
144
- });
145
- };
157
+ // If there is no selector, track the seed
158
+ // If there is a selector, do not track the seed
159
+ const getValue = () => !selector ? seed() : selector(untrack(() => seed()));
146
160
 
147
- // Get the active props
148
- const resolvedActiveProps = isActive ? (_functionalUpdate = functionalUpdate(activeProps, {})) != null ? _functionalUpdate : {} : {};
161
+ // If empty, initialize the value
162
+ if (valueRef.current === EMPTY) {
163
+ valueRef.current = sharedClone(undefined, getValue());
164
+ }
149
165
 
150
- // Get the inactive props
151
- const resolvedInactiveProps = isActive ? {} : (_functionalUpdate2 = functionalUpdate(inactiveProps, {})) != null ? _functionalUpdate2 : {};
152
- return _extends({}, resolvedActiveProps, resolvedInactiveProps, rest, {
153
- href: disabled ? undefined : next.href,
154
- onClick: composeHandlers([reactHandleClick, onClick]),
155
- onFocus: composeHandlers([handleFocus, onFocus]),
156
- onMouseEnter: composeHandlers([handleEnter, onMouseEnter]),
157
- onMouseLeave: composeHandlers([handleLeave, onMouseLeave]),
158
- target,
159
- style: _extends({}, style, resolvedActiveProps.style, resolvedInactiveProps.style),
160
- className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined
161
- }, disabled ? {
162
- role: 'link',
163
- 'aria-disabled': true
164
- } : undefined, {
165
- ['data-status']: isActive ? 'active' : undefined
166
- });
167
- },
168
- Link: /*#__PURE__*/React.forwardRef((props, ref) => {
169
- const linkProps = route.linkProps(props);
170
- useRouterSubscription(router);
171
- return /*#__PURE__*/React.createElement("a", _extends({
172
- ref: ref
173
- }, linkProps, {
174
- children: typeof props.children === 'function' ? props.children({
175
- isActive: linkProps['data-status'] === 'active'
176
- }) : props.children
177
- }));
178
- }),
179
- MatchRoute: opts => {
180
- const {
181
- pending,
182
- caseSensitive
183
- } = opts,
184
- rest = _objectWithoutPropertiesLoose(opts, _excluded2);
185
- const params = route.matchRoute(rest, {
186
- pending,
187
- caseSensitive
188
- });
189
- if (!params) {
190
- return null;
191
- }
192
- return typeof opts.children === 'function' ? opts.children(params) : opts.children;
193
- }
194
- };
195
- };
196
- const coreRouter = createRouter(_extends({}, opts, {
197
- createRouter: router => {
198
- const routerExt = {
199
- useState: () => {
200
- useRouterSubscription(router);
201
- return router.state;
202
- },
203
- useMatch: (routeId, opts) => {
204
- var _opts$strict;
205
- useRouterSubscription(router);
206
- const nearestMatch = useNearestMatch();
207
- const match = router.state.currentMatches.find(d => d.routeId === routeId);
208
- if ((_opts$strict = opts == null ? void 0 : opts.strict) != null ? _opts$strict : true) {
209
- invariant(match, "Could not find an active match for \"" + routeId + "\"!");
210
- invariant(nearestMatch.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 '" + nearestMatch.routeId + "' route. Did you mean to 'useMatch(\"" + (match == null ? void 0 : match.routeId) + "\", { strict: false })' or 'useRoute(\"" + (match == null ? void 0 : match.routeId) + "\")' instead?");
211
- }
212
- return match;
213
- }
214
- };
215
- const routeExt = makeRouteExt(router.getRoute(rootRouteId), router);
216
- Object.assign(router, routerExt, routeExt);
217
- },
218
- createRoute: _ref => {
219
- let {
220
- router,
221
- route
222
- } = _ref;
223
- const routeExt = makeRouteExt(route, router);
224
- Object.assign(route, routeExt);
225
- },
166
+ // Snapshot should just return the current cached value
167
+ const getSnapshot = React.useCallback(() => valueRef.current, []);
168
+ const getStore = React.useCallback(cb => {
169
+ // A root is necessary to track effects
170
+ return createRoot(() => {
171
+ createEffect(() => {
172
+ // Read and update the value
173
+ // getValue will handle which values are accessed and
174
+ // thus tracked.
175
+ // sharedClone will both recursively track the end result
176
+ // and ensure that the previous value is structurally shared
177
+ // into the new version.
178
+ valueRef.current = unwrap(
179
+ // Unwrap the value to get rid of any proxy structures
180
+ sharedClone(valueRef.current, getValue()));
181
+ cb();
182
+ });
183
+ });
184
+ }, []);
185
+ return useSyncExternalStore(getStore, getSnapshot, getSnapshot);
186
+ };
187
+ const [store, setStore] = createStore({
188
+ foo: 'foo',
189
+ bar: {
190
+ baz: 'baz'
191
+ }
192
+ });
193
+ createRoot(() => {
194
+ let prev;
195
+ createEffect(() => {
196
+ console.log('effect');
197
+ const next = sharedClone(prev, store);
198
+ console.log(next);
199
+ prev = untrack(() => next);
200
+ });
201
+ });
202
+ setStore(s => {
203
+ s.foo = '1';
204
+ });
205
+ setStore(s => {
206
+ s.bar.baz = '2';
207
+ });
208
+ function createReactRouter(opts) {
209
+ const coreRouter = createRouter({
210
+ ...opts,
226
211
  loadComponent: async component => {
227
- if (component.preload && typeof document !== 'undefined') {
228
- component.preload();
229
- // return await component.preload()
212
+ if (component.preload) {
213
+ await component.preload();
230
214
  }
231
-
232
215
  return component;
233
216
  }
234
- }));
217
+ });
235
218
  return coreRouter;
236
219
  }
237
- function RouterProvider(_ref2) {
220
+ function RouterProvider(_ref) {
238
221
  let {
239
- router
240
- } = _ref2,
241
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded3);
222
+ router,
223
+ ...rest
224
+ } = _ref;
242
225
  router.update(rest);
243
- useRouterSubscription(router);
244
- React.useEffect(() => {
245
- return router.mount();
246
- }, [router]);
226
+ const [,, currentMatches] = __useStoreValue(() => router.store, s => [s.status, s.pendingMatches, s.currentMatches]);
227
+ React.useEffect(router.mount, [router]);
228
+ console.log('current', currentMatches);
247
229
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(routerContext.Provider, {
248
230
  value: {
249
231
  router: router
250
232
  }
251
- }, /*#__PURE__*/React.createElement(MatchesProvider, {
252
- value: [undefined, ...router.state.currentMatches]
233
+ }, /*#__PURE__*/React.createElement(matchesContext.Provider, {
234
+ value: [undefined, ...currentMatches]
253
235
  }, /*#__PURE__*/React.createElement(Outlet, null))));
254
236
  }
255
237
  function useRouter() {
256
238
  const value = React.useContext(routerContext);
257
239
  warning(!value, 'useRouter must be used inside a <Router> component!');
258
- useRouterSubscription(value.router);
259
240
  return value.router;
260
241
  }
242
+ function useRouterStore(selector) {
243
+ const router = useRouter();
244
+ return __useStoreValue(() => router.store, selector);
245
+ }
261
246
  function useMatches() {
262
247
  return React.useContext(matchesContext);
263
248
  }
264
- function useMatch(routeId, opts) {
249
+ function useMatch(opts) {
265
250
  const router = useRouter();
266
- return router.useMatch(routeId, opts);
267
- }
268
- function useNearestMatch() {
269
- const runtimeMatch = useMatches()[0];
270
- invariant(runtimeMatch, "Could not find a nearest match!");
271
- return runtimeMatch;
251
+ const nearestMatch = useMatches()[0];
252
+ const match = opts != null && opts.from ? router.store.currentMatches.find(d => d.routeId === (opts == null ? void 0 : opts.from)) : nearestMatch;
253
+ invariant(match, `Could not find ${opts != null && opts.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
254
+ if ((opts == null ? void 0 : opts.strict) ?? true) {
255
+ invariant(nearestMatch.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 '${nearestMatch.routeId}' route. Did you mean to 'useMatch("${match == null ? void 0 : match.routeId}", { strict: false })' or 'useRoute("${match == null ? void 0 : match.routeId}")' instead?`);
256
+ }
257
+ __useStoreValue(() => match.store);
258
+ return match;
272
259
  }
273
260
  function useRoute(routeId) {
274
261
  const router = useRouter();
275
- return router.useRoute(routeId);
262
+ const resolvedRoute = router.getRoute(routeId);
263
+ invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
264
+ return resolvedRoute;
276
265
  }
277
- function useSearch() {
278
- return useRouter().state.currentLocation.search;
266
+ function useLoaderData(opts) {
267
+ const match = useMatch(opts);
268
+ return __useStoreValue(() => match == null ? void 0 : match.store.loaderData, opts == null ? void 0 : opts.select);
279
269
  }
280
- function useParams() {
281
- var _last;
282
- return (_last = last(useRouter().state.currentMatches)) == null ? void 0 : _last.params;
270
+ function useSearch(opts) {
271
+ const match = useMatch(opts);
272
+ return __useStoreValue(() => match == null ? void 0 : match.store.search, opts == null ? void 0 : opts.select);
283
273
  }
284
- function linkProps(props) {
274
+ function useParams(opts) {
285
275
  const router = useRouter();
286
- return router.linkProps(props);
276
+ return __useStoreValue(() => {
277
+ var _last;
278
+ return (_last = last(router.store.currentMatches)) == null ? void 0 : _last.params;
279
+ }, opts == null ? void 0 : opts.select);
287
280
  }
288
- function MatchRoute(props) {
281
+ function useNavigate(defaultOpts) {
282
+ return opts => {
283
+ const router = useRouter();
284
+ return router.navigate({
285
+ ...defaultOpts,
286
+ ...opts
287
+ });
288
+ };
289
+ }
290
+ function useAction(opts) {
291
+ const route = useRoute(opts.from);
292
+ const action = route.action;
293
+ __useStoreValue(() => action);
294
+ return action;
295
+ }
296
+ function useMatchRoute() {
289
297
  const router = useRouter();
290
- return /*#__PURE__*/React.createElement(router.MatchRoute, props);
298
+ return opts => {
299
+ const {
300
+ pending,
301
+ caseSensitive,
302
+ ...rest
303
+ } = opts;
304
+ return router.matchRoute(rest, {
305
+ pending,
306
+ caseSensitive
307
+ });
308
+ };
309
+ }
310
+ function MatchRoute(props) {
311
+ const matchRoute = useMatchRoute();
312
+ const params = matchRoute(props);
313
+ if (!params) {
314
+ return null;
315
+ }
316
+ return /*#__PURE__*/React.createElement(typeof props.children === 'function' ? props.children(params) : props.children, props);
291
317
  }
292
318
  function Outlet() {
293
- var _ref3, _match$__$pendingComp, _match$__$errorCompon;
294
319
  const router = useRouter();
295
320
  const matches = useMatches().slice(1);
296
321
  const match = matches[0];
297
322
  const defaultPending = React.useCallback(() => null, []);
323
+ __useStoreValue(() => match == null ? void 0 : match.store);
324
+ const Inner = React.useCallback(props => {
325
+ if (props.match.store.status === 'error') {
326
+ throw props.match.store.error;
327
+ }
328
+ if (props.match.store.status === 'success') {
329
+ return /*#__PURE__*/React.createElement(props.match.__.component ?? router.options.defaultComponent ?? Outlet);
330
+ }
331
+ if (props.match.store.status === 'loading') {
332
+ throw props.match.__.loadPromise;
333
+ }
334
+ invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
335
+ }, []);
298
336
  if (!match) {
299
337
  return null;
300
338
  }
301
- const PendingComponent = (_ref3 = (_match$__$pendingComp = match.__.pendingComponent) != null ? _match$__$pendingComp : router.options.defaultPendingComponent) != null ? _ref3 : defaultPending;
302
- const errorComponent = (_match$__$errorCompon = match.__.errorComponent) != null ? _match$__$errorCompon : router.options.defaultErrorComponent;
303
- return /*#__PURE__*/React.createElement(MatchesProvider, {
339
+ const PendingComponent = match.__.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
340
+ const errorComponent = match.__.errorComponent ?? router.options.defaultErrorComponent;
341
+ return /*#__PURE__*/React.createElement(matchesContext.Provider, {
304
342
  value: matches
305
343
  }, /*#__PURE__*/React.createElement(React.Suspense, {
306
344
  fallback: /*#__PURE__*/React.createElement(PendingComponent, null)
@@ -308,27 +346,17 @@ function Outlet() {
308
346
  key: match.routeId,
309
347
  errorComponent: errorComponent,
310
348
  match: match
311
- }, (() => {
312
- if (match.status === 'error') {
313
- throw match.error;
314
- }
315
- if (match.status === 'success') {
316
- var _ref4, _ref5;
317
- return /*#__PURE__*/React.createElement((_ref4 = (_ref5 = match.__.component) != null ? _ref5 : router.options.defaultComponent) != null ? _ref4 : Outlet);
318
- }
319
- throw match.__.loadPromise;
320
- })())));
349
+ }, /*#__PURE__*/React.createElement(Inner, {
350
+ match: match
351
+ }))));
321
352
  }
322
353
  class CatchBoundary extends React.Component {
323
- constructor() {
324
- super(...arguments);
325
- this.state = {
326
- error: false,
327
- info: undefined
328
- };
329
- }
354
+ state = {
355
+ error: false,
356
+ info: undefined
357
+ };
330
358
  componentDidCatch(error, info) {
331
- console.error("Error in route match: " + this.props.match.matchId);
359
+ console.error(`Error in route match: ${this.props.match.matchId}`);
332
360
  console.error(error);
333
361
  this.setState({
334
362
  error,
@@ -347,19 +375,18 @@ class CatchBoundary extends React.Component {
347
375
  // there has to be a better way to reset error boundaries when the
348
376
  // router's location key changes.
349
377
  function CatchBoundaryInner(props) {
350
- var _props$errorComponent;
351
378
  const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
352
379
  const router = useRouter();
353
- const errorComponent = (_props$errorComponent = props.errorComponent) != null ? _props$errorComponent : DefaultErrorBoundary;
380
+ const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
354
381
  React.useEffect(() => {
355
382
  if (activeErrorState) {
356
- let prevKey = router.state.currentLocation.key;
357
- return router.subscribe(() => {
358
- if (router.state.currentLocation.key !== prevKey) {
359
- prevKey = router.state.currentLocation.key;
383
+ let prevKey = router.store.currentLocation.key;
384
+ return createRoot(() => createEffect(() => {
385
+ if (router.store.currentLocation.key !== prevKey) {
386
+ prevKey = router.store.currentLocation.key;
360
387
  setActiveErrorState({});
361
388
  }
362
- });
389
+ }));
363
390
  }
364
391
  return;
365
392
  }, [activeErrorState]);
@@ -369,15 +396,15 @@ function CatchBoundaryInner(props) {
369
396
  }
370
397
  props.reset();
371
398
  }, [props.errorState.error]);
372
- if (activeErrorState.error) {
399
+ if (props.errorState.error) {
373
400
  return /*#__PURE__*/React.createElement(errorComponent, activeErrorState);
374
401
  }
375
402
  return props.children;
376
403
  }
377
- function DefaultErrorBoundary(_ref6) {
404
+ function DefaultErrorBoundary(_ref2) {
378
405
  let {
379
406
  error
380
- } = _ref6;
407
+ } = _ref2;
381
408
  return /*#__PURE__*/React.createElement("div", {
382
409
  style: {
383
410
  padding: '.5rem',
@@ -410,21 +437,38 @@ function usePrompt(message, when) {
410
437
  unblock();
411
438
  transition.retry();
412
439
  } else {
413
- router.state.currentLocation.pathname = window.location.pathname;
440
+ router.store.currentLocation.pathname = window.location.pathname;
414
441
  }
415
442
  });
416
443
  return unblock;
417
444
  }, [when, message]);
418
445
  }
419
- function Prompt(_ref7) {
446
+ function Prompt(_ref3) {
420
447
  let {
421
448
  message,
422
449
  when,
423
450
  children
424
- } = _ref7;
425
- usePrompt(message, when != null ? when : true);
426
- return children != null ? children : null;
451
+ } = _ref3;
452
+ usePrompt(message, when ?? true);
453
+ return children ?? null;
427
454
  }
428
455
 
429
- export { DefaultErrorBoundary, Link, MatchRoute, MatchesProvider, Outlet, Prompt, RouterProvider, createReactRouter, lazy, linkProps, matchesContext, routerContext, useMatch, useMatches, useNearestMatch, useParams, usePrompt, useRoute, useRouter, useSearch };
456
+ // function circularStringify(obj: any) {
457
+ // const seen = new Set()
458
+
459
+ // return (
460
+ // JSON.stringify(obj, (_, value) => {
461
+ // if (typeof value === 'function') {
462
+ // return undefined
463
+ // }
464
+ // if (typeof value === 'object' && value !== null) {
465
+ // if (seen.has(value)) return
466
+ // seen.add(value)
467
+ // }
468
+ // return value
469
+ // }) || ''
470
+ // )
471
+ // }
472
+
473
+ export { DefaultErrorBoundary, Link, MatchRoute, Outlet, Prompt, RouterProvider, __useStoreValue, createReactRouter, lazy, matchesContext, routerContext, useAction, useLinkProps, useLoaderData, useMatch, useMatchRoute, useMatches, useNavigate, useParams, usePrompt, useRoute, useRouter, useRouterStore, useSearch };
430
474
  //# sourceMappingURL=index.js.map