@tanstack/react-router 0.0.1-beta.48 → 0.0.1-beta.49

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,64 @@
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 withSelector = require('use-sync-external-store/shim/with-selector');
16
+
17
+ function useStore(store, selector = d => d, compareShallow) {
18
+ const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined);
19
+ return slice;
20
+ }
21
+ function shallow(objA, objB) {
22
+ if (Object.is(objA, objB)) {
23
+ return true;
24
+ }
25
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
26
+ return false;
27
+ }
28
+
29
+ // if (objA instanceof Map && objB instanceof Map) {
30
+ // if (objA.size !== objB.size) return false
31
+
32
+ // for (const [key, value] of objA) {
33
+ // if (!Object.is(value, objB.get(key))) {
34
+ // return false
35
+ // }
36
+ // }
37
+ // return true
38
+ // }
39
+
40
+ // if (objA instanceof Set && objB instanceof Set) {
41
+ // if (objA.size !== objB.size) return false
42
+
43
+ // for (const value of objA) {
44
+ // if (!objB.has(value)) {
45
+ // return false
46
+ // }
47
+ // }
48
+ // return true
49
+ // }
50
+
51
+ const keysA = Object.keys(objA);
52
+ if (keysA.length !== Object.keys(objB).length) {
53
+ return false;
54
+ }
55
+ for (let i = 0; i < keysA.length; i++) {
56
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
57
+ return false;
58
+ }
59
+ }
60
+ return true;
61
+ }
62
+
63
+ exports.useStore = useStore;
64
+ //# sourceMappingURL=useStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStore.js","sources":["../../src/useStore.ts"],"sourcesContent":["import { Store } from '@tanstack/router-core'\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'\n\nexport function useStore<TState, TSelected = TState>(\n store: Store<TState>,\n selector: (state: TState) => TSelected = (d) => d as any,\n compareShallow?: boolean,\n) {\n const slice = useSyncExternalStoreWithSelector(\n store.subscribe,\n () => store.state,\n () => store.state,\n selector,\n compareShallow ? shallow : undefined,\n )\n\n return slice\n}\n\nfunction shallow<T>(objA: T, objB: T) {\n if (Object.is(objA, objB)) {\n return true\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false\n }\n\n // if (objA instanceof Map && objB instanceof Map) {\n // if (objA.size !== objB.size) return false\n\n // for (const [key, value] of objA) {\n // if (!Object.is(value, objB.get(key))) {\n // return false\n // }\n // }\n // return true\n // }\n\n // if (objA instanceof Set && objB instanceof Set) {\n // if (objA.size !== objB.size) return false\n\n // for (const value of objA) {\n // if (!objB.has(value)) {\n // return false\n // }\n // }\n // return true\n // }\n\n const keysA = Object.keys(objA)\n if (keysA.length !== Object.keys(objB).length) {\n return false\n }\n\n for (let i = 0; i < keysA.length; i++) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, keysA[i] as string) ||\n !Object.is(objA[keysA[i] as keyof T], objB[keysA[i] as keyof T])\n ) {\n return false\n }\n }\n return true\n}\n"],"names":["useStore","store","selector","d","compareShallow","slice","useSyncExternalStoreWithSelector","subscribe","state","shallow","undefined","objA","objB","Object","is","keysA","keys","length","i","prototype","hasOwnProperty","call"],"mappings":";;;;;;;;;;;;;;;;AAGO,SAASA,QAAQ,CACtBC,KAAoB,EACpBC,QAAsC,GAAIC,CAAC,IAAKA,CAAQ,EACxDC,cAAwB,EACxB;EACA,MAAMC,KAAK,GAAGC,6CAAgC,CAC5CL,KAAK,CAACM,SAAS,EACf,MAAMN,KAAK,CAACO,KAAK,EACjB,MAAMP,KAAK,CAACO,KAAK,EACjBN,QAAQ,EACRE,cAAc,GAAGK,OAAO,GAAGC,SAAS,CACrC,CAAA;AAED,EAAA,OAAOL,KAAK,CAAA;AACd,CAAA;AAEA,SAASI,OAAO,CAAIE,IAAO,EAAEC,IAAO,EAAE;EACpC,IAAIC,MAAM,CAACC,EAAE,CAACH,IAAI,EAAEC,IAAI,CAAC,EAAE;AACzB,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,IACE,OAAOD,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,OAAOC,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,EACb;AACA,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAA,MAAMG,KAAK,GAAGF,MAAM,CAACG,IAAI,CAACL,IAAI,CAAC,CAAA;AAC/B,EAAA,IAAII,KAAK,CAACE,MAAM,KAAKJ,MAAM,CAACG,IAAI,CAACJ,IAAI,CAAC,CAACK,MAAM,EAAE;AAC7C,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACE,MAAM,EAAEC,CAAC,EAAE,EAAE;AACrC,IAAA,IACE,CAACL,MAAM,CAACM,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,IAAI,EAAEG,KAAK,CAACG,CAAC,CAAC,CAAW,IAC/D,CAACL,MAAM,CAACC,EAAE,CAACH,IAAI,CAACI,KAAK,CAACG,CAAC,CAAC,CAAY,EAAEN,IAAI,CAACG,KAAK,CAACG,CAAC,CAAC,CAAY,CAAC,EAChE;AACA,MAAA,OAAO,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,OAAO,IAAI,CAAA;AACb;;;;"}
@@ -9,11 +9,9 @@
9
9
  * @license MIT
10
10
  */
11
11
  import * as React from 'react';
12
- import { useSyncExternalStore } from 'use-sync-external-store/shim';
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';
12
+ import { functionalUpdate, Router, warning, invariant, last } from '@tanstack/router-core';
16
13
  export * from '@tanstack/router-core';
14
+ import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
17
15
 
18
16
  function _extends() {
19
17
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -30,6 +28,54 @@ function _extends() {
30
28
  return _extends.apply(this, arguments);
31
29
  }
32
30
 
31
+ function useStore(store, selector = d => d, compareShallow) {
32
+ const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined);
33
+ return slice;
34
+ }
35
+ function shallow(objA, objB) {
36
+ if (Object.is(objA, objB)) {
37
+ return true;
38
+ }
39
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
40
+ return false;
41
+ }
42
+
43
+ // if (objA instanceof Map && objB instanceof Map) {
44
+ // if (objA.size !== objB.size) return false
45
+
46
+ // for (const [key, value] of objA) {
47
+ // if (!Object.is(value, objB.get(key))) {
48
+ // return false
49
+ // }
50
+ // }
51
+ // return true
52
+ // }
53
+
54
+ // if (objA instanceof Set && objB instanceof Set) {
55
+ // if (objA.size !== objB.size) return false
56
+
57
+ // for (const value of objA) {
58
+ // if (!objB.has(value)) {
59
+ // return false
60
+ // }
61
+ // }
62
+ // return true
63
+ // }
64
+
65
+ const keysA = Object.keys(objA);
66
+ if (keysA.length !== Object.keys(objB).length) {
67
+ return false;
68
+ }
69
+ for (let i = 0; i < keysA.length; i++) {
70
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
71
+ return false;
72
+ }
73
+ }
74
+ return true;
75
+ }
76
+
77
+ //
78
+
33
79
  function lazy(importer) {
34
80
  const lazyComp = /*#__PURE__*/React.lazy(importer);
35
81
  const finalComp = lazyComp;
@@ -59,7 +105,7 @@ function useLinkProps(options) {
59
105
  hash,
60
106
  search,
61
107
  params,
62
- to,
108
+ to = '.',
63
109
  preload,
64
110
  preloadDelay,
65
111
  preloadMaxAge,
@@ -150,82 +196,26 @@ const Link = /*#__PURE__*/React.forwardRef((props, ref) => {
150
196
  });
151
197
  const matchesContext = /*#__PURE__*/React.createContext(null);
152
198
  const routerContext = /*#__PURE__*/React.createContext(null);
153
- const EMPTY = {};
154
- const __useStoreValue = (seed, selector) => {
155
- const valueRef = React.useRef(EMPTY);
156
-
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()));
160
-
161
- // If empty, initialize the value
162
- if (valueRef.current === EMPTY) {
163
- valueRef.current = sharedClone(undefined, getValue());
164
- }
165
-
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
- });
199
+ class ReactRouter extends Router {
200
+ constructor(opts) {
201
+ super({
202
+ ...opts,
203
+ loadComponent: async component => {
204
+ if (component.preload) {
205
+ await component.preload();
206
+ }
207
+ return component;
208
+ }
183
209
  });
184
- }, []);
185
- return useSyncExternalStore(getStore, getSnapshot, getSnapshot);
186
- };
187
- const [store, setStore] = createStore({
188
- foo: 'foo',
189
- bar: {
190
- baz: 'baz'
191
210
  }
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,
211
- loadComponent: async component => {
212
- if (component.preload) {
213
- await component.preload();
214
- }
215
- return component;
216
- }
217
- });
218
- return coreRouter;
219
211
  }
220
- function RouterProvider(_ref) {
221
- let {
222
- router,
223
- ...rest
224
- } = _ref;
212
+ function RouterProvider({
213
+ router,
214
+ ...rest
215
+ }) {
225
216
  router.update(rest);
226
- const [,, currentMatches] = __useStoreValue(() => router.store, s => [s.status, s.pendingMatches, s.currentMatches]);
217
+ const [,, currentMatches] = useStore(router.store, s => [s.status, s.pendingMatches, s.currentMatches], true);
227
218
  React.useEffect(router.mount, [router]);
228
- console.log('current', currentMatches);
229
219
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(routerContext.Provider, {
230
220
  value: {
231
221
  router: router
@@ -239,9 +229,9 @@ function useRouter() {
239
229
  warning(!value, 'useRouter must be used inside a <Router> component!');
240
230
  return value.router;
241
231
  }
242
- function useRouterStore(selector) {
232
+ function useRouterStore(selector, shallow) {
243
233
  const router = useRouter();
244
- return __useStoreValue(() => router.store, selector);
234
+ return useStore(router.store, selector, shallow);
245
235
  }
246
236
  function useMatches() {
247
237
  return React.useContext(matchesContext);
@@ -249,12 +239,12 @@ function useMatches() {
249
239
  function useMatch(opts) {
250
240
  const router = useRouter();
251
241
  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?`);
242
+ const match = opts?.from ? router.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
243
+ invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
244
+ if (opts?.strict ?? true) {
245
+ invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
256
246
  }
257
- __useStoreValue(() => match.store);
247
+ useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
258
248
  return match;
259
249
  }
260
250
  function useRoute(routeId) {
@@ -265,18 +255,22 @@ function useRoute(routeId) {
265
255
  }
266
256
  function useLoaderData(opts) {
267
257
  const match = useMatch(opts);
268
- return __useStoreValue(() => match == null ? void 0 : match.store.loaderData, opts == null ? void 0 : opts.select);
258
+ invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
259
+ useStore(match.store, d => opts?.track?.(d.loaderData) ?? d.loaderData);
260
+ return match.store.state.loaderData;
269
261
  }
270
262
  function useSearch(opts) {
271
263
  const match = useMatch(opts);
272
- return __useStoreValue(() => match == null ? void 0 : match.store.search, opts == null ? void 0 : opts.select);
264
+ useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
265
+ return match.store.state.search;
273
266
  }
274
267
  function useParams(opts) {
275
268
  const router = useRouter();
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);
269
+ useStore(router.store, d => {
270
+ const params = last(d.currentMatches)?.params;
271
+ return opts?.track?.(params) ?? params;
272
+ });
273
+ return last(router.store.state.currentMatches)?.params;
280
274
  }
281
275
  function useNavigate(defaultOpts) {
282
276
  const router = useRouter();
@@ -287,12 +281,6 @@ function useNavigate(defaultOpts) {
287
281
  });
288
282
  };
289
283
  }
290
- function useAction(opts) {
291
- const route = useRoute(opts.from);
292
- const action = route.action;
293
- __useStoreValue(() => action);
294
- return action;
295
- }
296
284
  function useMatchRoute() {
297
285
  const router = useRouter();
298
286
  return opts => {
@@ -313,37 +301,49 @@ function MatchRoute(props) {
313
301
  if (!params) {
314
302
  return null;
315
303
  }
316
- return /*#__PURE__*/React.createElement(typeof props.children === 'function' ? props.children(params) : props.children, props);
304
+ if (typeof props.children === 'function') {
305
+ return props.children(params);
306
+ }
307
+ return params ? props.children : null;
317
308
  }
318
309
  function Outlet() {
319
- const router = useRouter();
320
310
  const matches = useMatches().slice(1);
321
311
  const match = matches[0];
312
+ if (!match) {
313
+ return null;
314
+ }
315
+ return /*#__PURE__*/React.createElement(SubOutlet, {
316
+ matches: matches,
317
+ match: match
318
+ });
319
+ }
320
+ function SubOutlet({
321
+ matches,
322
+ match
323
+ }) {
324
+ const router = useRouter();
325
+ useStore(match.store);
322
326
  const defaultPending = React.useCallback(() => null, []);
323
- __useStoreValue(() => match == null ? void 0 : match.store);
324
327
  const Inner = React.useCallback(props => {
325
- if (props.match.store.status === 'error') {
326
- throw props.match.store.error;
328
+ if (props.match.store.state.status === 'error') {
329
+ throw props.match.store.state.error;
327
330
  }
328
- if (props.match.store.status === 'success') {
329
- return /*#__PURE__*/React.createElement(props.match.__.component ?? router.options.defaultComponent ?? Outlet);
331
+ if (props.match.store.state.status === 'success') {
332
+ return /*#__PURE__*/React.createElement(props.match.component ?? router.options.defaultComponent ?? Outlet);
330
333
  }
331
- if (props.match.store.status === 'loading') {
332
- throw props.match.__.loadPromise;
334
+ if (props.match.store.state.status === 'loading') {
335
+ throw props.match.__loadPromise;
333
336
  }
334
337
  invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
335
338
  }, []);
336
- if (!match) {
337
- return null;
338
- }
339
- const PendingComponent = match.__.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
340
- const errorComponent = match.__.errorComponent ?? router.options.defaultErrorComponent;
339
+ const PendingComponent = match.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
340
+ const errorComponent = match.errorComponent ?? router.options.defaultErrorComponent;
341
341
  return /*#__PURE__*/React.createElement(matchesContext.Provider, {
342
342
  value: matches
343
343
  }, /*#__PURE__*/React.createElement(React.Suspense, {
344
344
  fallback: /*#__PURE__*/React.createElement(PendingComponent, null)
345
345
  }, /*#__PURE__*/React.createElement(CatchBoundary, {
346
- key: match.routeId,
346
+ key: match.route.id,
347
347
  errorComponent: errorComponent,
348
348
  match: match
349
349
  }, /*#__PURE__*/React.createElement(Inner, {
@@ -356,7 +356,7 @@ class CatchBoundary extends React.Component {
356
356
  info: undefined
357
357
  };
358
358
  componentDidCatch(error, info) {
359
- console.error(`Error in route match: ${this.props.match.matchId}`);
359
+ console.error(`Error in route match: ${this.props.match.id}`);
360
360
  console.error(error);
361
361
  this.setState({
362
362
  error,
@@ -376,20 +376,27 @@ class CatchBoundary extends React.Component {
376
376
  // router's location key changes.
377
377
  function CatchBoundaryInner(props) {
378
378
  const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
379
- const router = useRouter();
379
+ useRouter();
380
380
  const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
381
- React.useEffect(() => {
382
- if (activeErrorState) {
383
- let prevKey = router.store.currentLocation.key;
384
- return createRoot(() => createEffect(() => {
385
- if (router.store.currentLocation.key !== prevKey) {
386
- prevKey = router.store.currentLocation.key;
387
- setActiveErrorState({});
388
- }
389
- }));
390
- }
391
- return;
392
- }, [activeErrorState]);
381
+
382
+ // React.useEffect(() => {
383
+ // if (activeErrorState) {
384
+ // let prevKey = router.store.currentLocation.key
385
+ // return createRoot((dispose) => {
386
+ // createEffect(() => {
387
+ // if (router.store.currentLocation.key !== prevKey) {
388
+ // prevKey = router.store.currentLocation.key
389
+ // setActiveErrorState({} as any)
390
+ // }
391
+ // })
392
+
393
+ // return dispose
394
+ // })
395
+ // }
396
+
397
+ // return
398
+ // }, [activeErrorState])
399
+
393
400
  React.useEffect(() => {
394
401
  if (props.errorState.error) {
395
402
  setActiveErrorState(props.errorState);
@@ -401,10 +408,9 @@ function CatchBoundaryInner(props) {
401
408
  }
402
409
  return props.children;
403
410
  }
404
- function DefaultErrorBoundary(_ref2) {
405
- let {
406
- error
407
- } = _ref2;
411
+ function DefaultErrorBoundary({
412
+ error
413
+ }) {
408
414
  return /*#__PURE__*/React.createElement("div", {
409
415
  style: {
410
416
  padding: '.5rem',
@@ -428,47 +434,43 @@ function DefaultErrorBoundary(_ref2) {
428
434
  }
429
435
  }, error.message) : null)));
430
436
  }
431
- function usePrompt(message, when) {
432
- const router = useRouter();
433
- React.useEffect(() => {
434
- if (!when) return;
435
- let unblock = router.history.block(transition => {
436
- if (window.confirm(message)) {
437
- unblock();
438
- transition.retry();
439
- } else {
440
- router.store.currentLocation.pathname = window.location.pathname;
441
- }
442
- });
443
- return unblock;
444
- }, [when, message]);
445
- }
446
- function Prompt(_ref3) {
447
- let {
448
- message,
449
- when,
450
- children
451
- } = _ref3;
452
- usePrompt(message, when ?? true);
453
- return children ?? null;
437
+ function useAction(action, opts) {
438
+ useStore(action.store, d => opts?.track?.(d) ?? d, true);
439
+ const [ref] = React.useState({});
440
+ Object.assign(ref, {
441
+ ...action,
442
+ latestSubmission: action.store.state.submissions[action.store.state.submissions.length - 1],
443
+ pendingSubmissions: React.useMemo(() => action.store.state.submissions.filter(d => d.status === 'pending'), [action.store.state.submissions])
444
+ });
445
+ return ref;
454
446
  }
455
447
 
456
- // function circularStringify(obj: any) {
457
- // const seen = new Set()
448
+ // TODO: While we migrate away from the history package, these need to be disabled
449
+ // export function usePrompt(message: string, when: boolean | any): void {
450
+ // const router = useRouter()
458
451
 
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)
452
+ // React.useEffect(() => {
453
+ // if (!when) return
454
+
455
+ // let unblock = router.getHistory().block((transition) => {
456
+ // if (window.confirm(message)) {
457
+ // unblock()
458
+ // transition.retry()
459
+ // } else {
460
+ // router.setStore((s) => {
461
+ // s.currentLocation.pathname = window.location.pathname
462
+ // })
467
463
  // }
468
- // return value
469
- // }) || ''
470
- // )
464
+ // })
465
+
466
+ // return unblock
467
+ // }, [when, message])
468
+ // }
469
+
470
+ // export function Prompt({ message, when, children }: PromptProps) {
471
+ // usePrompt(message, when ?? true)
472
+ // return (children ?? null) as ReactNode
471
473
  // }
472
474
 
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 };
475
+ export { DefaultErrorBoundary, Link, MatchRoute, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useAction, useLinkProps, useLoaderData, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterStore, useSearch, useStore };
474
476
  //# sourceMappingURL=index.js.map