@tanstack/react-router 0.0.1-beta.74 → 0.0.1-beta.76

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.
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "ef61-109",
10
+ "uid": "f796-109",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,11 +15,11 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
18
- "uid": "ef61-111"
18
+ "uid": "f796-111"
19
19
  },
20
20
  {
21
21
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
22
- "uid": "ef61-113"
22
+ "uid": "f796-113"
23
23
  }
24
24
  ]
25
25
  },
@@ -28,19 +28,19 @@
28
28
  "children": [
29
29
  {
30
30
  "name": "store/build/esm/index.js",
31
- "uid": "ef61-115"
31
+ "uid": "f796-115"
32
32
  },
33
33
  {
34
34
  "name": "router/build/esm/index.js",
35
- "uid": "ef61-117"
35
+ "uid": "f796-117"
36
36
  },
37
37
  {
38
38
  "name": "react-store/build/esm/index.js",
39
- "uid": "ef61-119"
39
+ "uid": "f796-119"
40
40
  },
41
41
  {
42
42
  "name": "react-router/src/index.tsx",
43
- "uid": "ef61-121"
43
+ "uid": "f796-121"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,176 +50,176 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "ef61-109": {
53
+ "f796-109": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "ef61-108"
57
+ "mainUid": "f796-108"
58
58
  },
59
- "ef61-111": {
59
+ "f796-111": {
60
60
  "renderedLength": 181,
61
61
  "gzipLength": 129,
62
62
  "brotliLength": 0,
63
- "mainUid": "ef61-110"
63
+ "mainUid": "f796-110"
64
64
  },
65
- "ef61-113": {
65
+ "f796-113": {
66
66
  "renderedLength": 44,
67
67
  "gzipLength": 62,
68
68
  "brotliLength": 0,
69
- "mainUid": "ef61-112"
69
+ "mainUid": "f796-112"
70
70
  },
71
- "ef61-115": {
71
+ "f796-115": {
72
72
  "renderedLength": 1288,
73
73
  "gzipLength": 497,
74
74
  "brotliLength": 0,
75
- "mainUid": "ef61-114"
75
+ "mainUid": "f796-114"
76
76
  },
77
- "ef61-117": {
78
- "renderedLength": 46875,
79
- "gzipLength": 11092,
77
+ "f796-117": {
78
+ "renderedLength": 46874,
79
+ "gzipLength": 11076,
80
80
  "brotliLength": 0,
81
- "mainUid": "ef61-116"
81
+ "mainUid": "f796-116"
82
82
  },
83
- "ef61-119": {
83
+ "f796-119": {
84
84
  "renderedLength": 1571,
85
85
  "gzipLength": 594,
86
86
  "brotliLength": 0,
87
- "mainUid": "ef61-118"
87
+ "mainUid": "f796-118"
88
88
  },
89
- "ef61-121": {
90
- "renderedLength": 12514,
91
- "gzipLength": 3242,
89
+ "f796-121": {
90
+ "renderedLength": 12591,
91
+ "gzipLength": 3262,
92
92
  "brotliLength": 0,
93
- "mainUid": "ef61-120"
93
+ "mainUid": "f796-120"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "ef61-108": {
97
+ "f796-108": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "ef61-109"
100
+ "index.production.js": "f796-109"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "ef61-120"
105
+ "uid": "f796-120"
106
106
  }
107
107
  ]
108
108
  },
109
- "ef61-110": {
109
+ "f796-110": {
110
110
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
111
111
  "moduleParts": {
112
- "index.production.js": "ef61-111"
112
+ "index.production.js": "f796-111"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "ef61-116"
117
+ "uid": "f796-116"
118
118
  }
119
119
  ]
120
120
  },
121
- "ef61-112": {
121
+ "f796-112": {
122
122
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
123
123
  "moduleParts": {
124
- "index.production.js": "ef61-113"
124
+ "index.production.js": "f796-113"
125
125
  },
126
126
  "imported": [],
127
127
  "importedBy": [
128
128
  {
129
- "uid": "ef61-116"
129
+ "uid": "f796-116"
130
130
  }
131
131
  ]
132
132
  },
133
- "ef61-114": {
133
+ "f796-114": {
134
134
  "id": "/packages/store/build/esm/index.js",
135
135
  "moduleParts": {
136
- "index.production.js": "ef61-115"
136
+ "index.production.js": "f796-115"
137
137
  },
138
138
  "imported": [],
139
139
  "importedBy": [
140
140
  {
141
- "uid": "ef61-116"
141
+ "uid": "f796-116"
142
142
  }
143
143
  ]
144
144
  },
145
- "ef61-116": {
145
+ "f796-116": {
146
146
  "id": "/packages/router/build/esm/index.js",
147
147
  "moduleParts": {
148
- "index.production.js": "ef61-117"
148
+ "index.production.js": "f796-117"
149
149
  },
150
150
  "imported": [
151
151
  {
152
- "uid": "ef61-110"
152
+ "uid": "f796-110"
153
153
  },
154
154
  {
155
- "uid": "ef61-112"
155
+ "uid": "f796-112"
156
156
  },
157
157
  {
158
- "uid": "ef61-114"
158
+ "uid": "f796-114"
159
159
  }
160
160
  ],
161
161
  "importedBy": [
162
162
  {
163
- "uid": "ef61-120"
163
+ "uid": "f796-120"
164
164
  }
165
165
  ]
166
166
  },
167
- "ef61-118": {
167
+ "f796-118": {
168
168
  "id": "/packages/react-store/build/esm/index.js",
169
169
  "moduleParts": {
170
- "index.production.js": "ef61-119"
170
+ "index.production.js": "f796-119"
171
171
  },
172
172
  "imported": [
173
173
  {
174
- "uid": "ef61-123"
174
+ "uid": "f796-123"
175
175
  }
176
176
  ],
177
177
  "importedBy": [
178
178
  {
179
- "uid": "ef61-120"
179
+ "uid": "f796-120"
180
180
  }
181
181
  ]
182
182
  },
183
- "ef61-120": {
183
+ "f796-120": {
184
184
  "id": "/packages/react-router/src/index.tsx",
185
185
  "moduleParts": {
186
- "index.production.js": "ef61-121"
186
+ "index.production.js": "f796-121"
187
187
  },
188
188
  "imported": [
189
189
  {
190
- "uid": "ef61-108"
190
+ "uid": "f796-108"
191
191
  },
192
192
  {
193
- "uid": "ef61-122"
193
+ "uid": "f796-122"
194
194
  },
195
195
  {
196
- "uid": "ef61-116"
196
+ "uid": "f796-116"
197
197
  },
198
198
  {
199
- "uid": "ef61-118"
199
+ "uid": "f796-118"
200
200
  }
201
201
  ],
202
202
  "importedBy": [],
203
203
  "isEntry": true
204
204
  },
205
- "ef61-122": {
205
+ "f796-122": {
206
206
  "id": "react",
207
207
  "moduleParts": {},
208
208
  "imported": [],
209
209
  "importedBy": [
210
210
  {
211
- "uid": "ef61-120"
211
+ "uid": "f796-120"
212
212
  }
213
213
  ],
214
214
  "isExternal": true
215
215
  },
216
- "ef61-123": {
216
+ "f796-123": {
217
217
  "id": "use-sync-external-store/shim/with-selector",
218
218
  "moduleParts": {},
219
219
  "imported": [],
220
220
  "importedBy": [
221
221
  {
222
- "uid": "ef61-118"
222
+ "uid": "f796-118"
223
223
  }
224
224
  ],
225
225
  "isExternal": true
@@ -79,7 +79,7 @@ type RouterProps<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo exte
79
79
  };
80
80
  declare function RouterProvider<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>): JSX.Element;
81
81
  declare function useRouterContext(): RegisteredRouter;
82
- declare function useRouter<T = RouterStore>(track?: (state: Router['store']) => T, shallow?: boolean): RegisteredRouter;
82
+ declare function useRouter<T = RouterStore>(track?: (state: Router['__store']) => T, shallow?: boolean): RegisteredRouter;
83
83
  declare function useMatches(): RouteMatch[];
84
84
  declare function useMatch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteMatch = RouteMatch<RegisteredRoutesInfo, RegisteredRoutesInfo['routesById'][TFrom]>>(opts?: {
85
85
  from: TFrom;
@@ -783,12 +783,12 @@
783
783
  parseSearch: options?.parseSearch ?? defaultParseSearch,
784
784
  fetchServerDataFn: options?.fetchServerDataFn ?? defaultFetchServerDataFn
785
785
  };
786
- this.store = new Store(getInitialRouterState(), {
786
+ this.__store = new Store(getInitialRouterState(), {
787
787
  onUpdate: state => {
788
788
  this.state = state;
789
789
  }
790
790
  });
791
- this.state = this.store.state;
791
+ this.state = this.__store.state;
792
792
  this.basepath = '';
793
793
  this.update(options);
794
794
 
@@ -808,7 +808,7 @@
808
808
  }
809
809
  }
810
810
  reset = () => {
811
- this.store.setState(s => Object.assign(s, getInitialRouterState()));
811
+ this.__store.setState(s => Object.assign(s, getInitialRouterState()));
812
812
  };
813
813
  mount = () => {
814
814
  // Mount only does anything on the client
@@ -828,7 +828,7 @@
828
828
  }
829
829
  this.history = this.options.history ?? (isServer ? createMemoryHistory() : createBrowserHistory());
830
830
  const parsedLocation = this.#parseLocation();
831
- this.store.setState(s => ({
831
+ this.__store.setState(s => ({
832
832
  ...s,
833
833
  latestLocation: parsedLocation,
834
834
  currentLocation: parsedLocation
@@ -877,10 +877,10 @@
877
877
  // Cancel any pending matches
878
878
  this.cancelMatches();
879
879
  let matches;
880
- this.store.batch(() => {
880
+ this.__store.batch(() => {
881
881
  if (opts?.next) {
882
882
  // Ingest the new location
883
- this.store.setState(s => ({
883
+ this.__store.setState(s => ({
884
884
  ...s,
885
885
  latestLocation: opts.next
886
886
  }));
@@ -890,7 +890,7 @@
890
890
  matches = this.matchRoutes(this.state.latestLocation.pathname, {
891
891
  strictParseParams: true
892
892
  });
893
- this.store.setState(s => ({
893
+ this.__store.setState(s => ({
894
894
  ...s,
895
895
  status: 'pending',
896
896
  pendingMatches: matches,
@@ -929,7 +929,7 @@
929
929
 
930
930
  // Clear non-loading error states when match leaves
931
931
  if (d.state.status === 'error') {
932
- this.store.setState(s => ({
932
+ this.__store.setState(s => ({
933
933
  ...s,
934
934
  status: 'idle',
935
935
  error: undefined
@@ -949,7 +949,7 @@
949
949
  });
950
950
  });
951
951
  const prevLocation = this.state.currentLocation;
952
- this.store.setState(s => ({
952
+ this.__store.setState(s => ({
953
953
  ...s,
954
954
  status: 'idle',
955
955
  currentLocation: this.state.latestLocation,
@@ -1270,7 +1270,7 @@
1270
1270
  };
1271
1271
  };
1272
1272
  hydrate = dehydratedRouter => {
1273
- this.store.setState(s => {
1273
+ this.__store.setState(s => {
1274
1274
  // Match the routes
1275
1275
  const currentMatches = this.matchRoutes(dehydratedRouter.state.latestLocation.pathname, {
1276
1276
  strictParseParams: true
@@ -1278,7 +1278,7 @@
1278
1278
  currentMatches.forEach((match, index) => {
1279
1279
  const dehydratedMatch = dehydratedRouter.state.currentMatches[index];
1280
1280
  invariant(dehydratedMatch && dehydratedMatch.id === match.id, 'Oh no! There was a hydration mismatch when attempting to hydrate the state of the router! 😬');
1281
- match.store.setState(s => ({
1281
+ match.__store.setState(s => ({
1282
1282
  ...s,
1283
1283
  ...dehydratedMatch.state
1284
1284
  }));
@@ -1464,7 +1464,6 @@
1464
1464
  const componentTypes = ['component', 'errorComponent', 'pendingComponent'];
1465
1465
  class RouteMatch {
1466
1466
  abortController = new AbortController();
1467
- onLoaderDataListeners = new Set();
1468
1467
  constructor(router, route, opts) {
1469
1468
  Object.assign(this, {
1470
1469
  route,
@@ -1472,7 +1471,7 @@
1472
1471
  id: opts.id,
1473
1472
  pathname: opts.pathname,
1474
1473
  params: opts.params,
1475
- store: new Store({
1474
+ __store: new Store({
1476
1475
  updatedAt: 0,
1477
1476
  routeSearch: {},
1478
1477
  search: {},
@@ -1483,7 +1482,7 @@
1483
1482
  }
1484
1483
  })
1485
1484
  });
1486
- this.state = this.store.state;
1485
+ this.state = this.__store.state;
1487
1486
  componentTypes.map(async type => {
1488
1487
  const component = this.route.options[type];
1489
1488
  if (typeof this[type] !== 'function') {
@@ -1491,7 +1490,7 @@
1491
1490
  }
1492
1491
  });
1493
1492
  if (this.state.status === 'idle' && !this.#hasLoaders()) {
1494
- this.store.setState(s => ({
1493
+ this.__store.setState(s => ({
1495
1494
  ...s,
1496
1495
  status: 'success'
1497
1496
  }));
@@ -1511,7 +1510,7 @@
1511
1510
  });
1512
1511
  this.context = context;
1513
1512
  this.routeContext = routeContext;
1514
- this.store.setState(s => ({
1513
+ this.__store.setState(s => ({
1515
1514
  ...s,
1516
1515
  routeSearch: replaceEqualDeep(s.routeSearch, routeSearch),
1517
1516
  search: replaceEqualDeep(s.search, search)
@@ -1582,7 +1581,7 @@
1582
1581
  return;
1583
1582
  }
1584
1583
  this.route.options.onError?.(err);
1585
- this.store.setState(s => ({
1584
+ this.__store.setState(s => ({
1586
1585
  ...s,
1587
1586
  status: 'error',
1588
1587
  error: err
@@ -1616,7 +1615,7 @@
1616
1615
  // to a loading state again. Otherwise, keep it
1617
1616
  // as loading or resolved
1618
1617
  if (this.state.status === 'idle') {
1619
- this.store.setState(s => ({
1618
+ this.__store.setState(s => ({
1620
1619
  ...s,
1621
1620
  status: 'pending'
1622
1621
  }));
@@ -1649,7 +1648,7 @@
1649
1648
  try {
1650
1649
  await Promise.all([componentsPromise, dataPromise]);
1651
1650
  if (latestPromise = checkLatest()) return await latestPromise;
1652
- this.store.setState(s => ({
1651
+ this.__store.setState(s => ({
1653
1652
  ...s,
1654
1653
  error: undefined,
1655
1654
  status: 'success',
@@ -1662,7 +1661,7 @@
1662
1661
  }
1663
1662
  this.route.options.onLoadError?.(err);
1664
1663
  this.route.options.onError?.(err);
1665
- this.store.setState(s => ({
1664
+ this.__store.setState(s => ({
1666
1665
  ...s,
1667
1666
  error: err,
1668
1667
  status: 'error',
@@ -1881,7 +1880,7 @@
1881
1880
  ...rest
1882
1881
  }) {
1883
1882
  router.update(rest);
1884
- const currentMatches = useStore(router.store, s => s.currentMatches);
1883
+ const currentMatches = useStore(router.__store, s => s.currentMatches);
1885
1884
  React__namespace.useEffect(router.mount, [router]);
1886
1885
  return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
1887
1886
  value: {
@@ -1899,12 +1898,12 @@
1899
1898
  function useRouterContext() {
1900
1899
  const value = React__namespace.useContext(routerContext);
1901
1900
  warning(value, 'useRouter must be used inside a <Router> component!');
1902
- useStore(value.router.store);
1901
+ useStore(value.router.__store);
1903
1902
  return value.router;
1904
1903
  }
1905
1904
  function useRouter(track, shallow) {
1906
1905
  const router = useRouterContext();
1907
- useStore(router.store, track, shallow);
1906
+ useStore(router.__store, track, shallow);
1908
1907
  return router;
1909
1908
  }
1910
1909
  function useMatches() {
@@ -1918,7 +1917,7 @@
1918
1917
  if (opts?.strict ?? true) {
1919
1918
  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?`);
1920
1919
  }
1921
- useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
1920
+ useStore(match.__store, d => opts?.track?.(match) ?? match, opts?.shallow);
1922
1921
  return match;
1923
1922
  }
1924
1923
  function useRoute(routeId) {
@@ -1928,13 +1927,17 @@
1928
1927
  return resolvedRoute;
1929
1928
  }
1930
1929
  function useSearch(opts) {
1931
- const match = useMatch(opts);
1932
- useStore(match.store, d => opts?.track?.(d.search) ?? d.search, true);
1930
+ const {
1931
+ track,
1932
+ ...matchOpts
1933
+ } = opts;
1934
+ const match = useMatch(matchOpts);
1935
+ useStore(match.__store, d => opts?.track?.(d.search) ?? d.search, true);
1933
1936
  return match.state.search;
1934
1937
  }
1935
1938
  function useParams(opts) {
1936
1939
  const router = useRouterContext();
1937
- useStore(router.store, d => {
1940
+ useStore(router.__store, d => {
1938
1941
  const params = last(d.currentMatches)?.params;
1939
1942
  return opts?.track?.(params) ?? params;
1940
1943
  }, true);
@@ -1990,7 +1993,7 @@
1990
1993
  match
1991
1994
  }) {
1992
1995
  const router = useRouterContext();
1993
- useStore(match.store, store => [store.status, store.error], true);
1996
+ useStore(match.__store, store => [store.status, store.error], true);
1994
1997
  const defaultPending = React__namespace.useCallback(() => null, []);
1995
1998
  const Inner = React__namespace.useCallback(props => {
1996
1999
  if (props.match.state.status === 'error') {