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

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": "37ac-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": "37ac-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": "37ac-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": "37ac-115"
32
32
  },
33
33
  {
34
34
  "name": "router/build/esm/index.js",
35
- "uid": "ef61-117"
35
+ "uid": "37ac-117"
36
36
  },
37
37
  {
38
38
  "name": "react-store/build/esm/index.js",
39
- "uid": "ef61-119"
39
+ "uid": "37ac-119"
40
40
  },
41
41
  {
42
42
  "name": "react-router/src/index.tsx",
43
- "uid": "ef61-121"
43
+ "uid": "37ac-121"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,176 +50,176 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "ef61-109": {
53
+ "37ac-109": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "ef61-108"
57
+ "mainUid": "37ac-108"
58
58
  },
59
- "ef61-111": {
59
+ "37ac-111": {
60
60
  "renderedLength": 181,
61
61
  "gzipLength": 129,
62
62
  "brotliLength": 0,
63
- "mainUid": "ef61-110"
63
+ "mainUid": "37ac-110"
64
64
  },
65
- "ef61-113": {
65
+ "37ac-113": {
66
66
  "renderedLength": 44,
67
67
  "gzipLength": 62,
68
68
  "brotliLength": 0,
69
- "mainUid": "ef61-112"
69
+ "mainUid": "37ac-112"
70
70
  },
71
- "ef61-115": {
71
+ "37ac-115": {
72
72
  "renderedLength": 1288,
73
73
  "gzipLength": 497,
74
74
  "brotliLength": 0,
75
- "mainUid": "ef61-114"
75
+ "mainUid": "37ac-114"
76
76
  },
77
- "ef61-117": {
78
- "renderedLength": 46875,
79
- "gzipLength": 11092,
77
+ "37ac-117": {
78
+ "renderedLength": 46913,
79
+ "gzipLength": 11093,
80
80
  "brotliLength": 0,
81
- "mainUid": "ef61-116"
81
+ "mainUid": "37ac-116"
82
82
  },
83
- "ef61-119": {
83
+ "37ac-119": {
84
84
  "renderedLength": 1571,
85
85
  "gzipLength": 594,
86
86
  "brotliLength": 0,
87
- "mainUid": "ef61-118"
87
+ "mainUid": "37ac-118"
88
88
  },
89
- "ef61-121": {
90
- "renderedLength": 12514,
91
- "gzipLength": 3242,
89
+ "37ac-121": {
90
+ "renderedLength": 12591,
91
+ "gzipLength": 3262,
92
92
  "brotliLength": 0,
93
- "mainUid": "ef61-120"
93
+ "mainUid": "37ac-120"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "ef61-108": {
97
+ "37ac-108": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "ef61-109"
100
+ "index.production.js": "37ac-109"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "ef61-120"
105
+ "uid": "37ac-120"
106
106
  }
107
107
  ]
108
108
  },
109
- "ef61-110": {
109
+ "37ac-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": "37ac-111"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "ef61-116"
117
+ "uid": "37ac-116"
118
118
  }
119
119
  ]
120
120
  },
121
- "ef61-112": {
121
+ "37ac-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": "37ac-113"
125
125
  },
126
126
  "imported": [],
127
127
  "importedBy": [
128
128
  {
129
- "uid": "ef61-116"
129
+ "uid": "37ac-116"
130
130
  }
131
131
  ]
132
132
  },
133
- "ef61-114": {
133
+ "37ac-114": {
134
134
  "id": "/packages/store/build/esm/index.js",
135
135
  "moduleParts": {
136
- "index.production.js": "ef61-115"
136
+ "index.production.js": "37ac-115"
137
137
  },
138
138
  "imported": [],
139
139
  "importedBy": [
140
140
  {
141
- "uid": "ef61-116"
141
+ "uid": "37ac-116"
142
142
  }
143
143
  ]
144
144
  },
145
- "ef61-116": {
145
+ "37ac-116": {
146
146
  "id": "/packages/router/build/esm/index.js",
147
147
  "moduleParts": {
148
- "index.production.js": "ef61-117"
148
+ "index.production.js": "37ac-117"
149
149
  },
150
150
  "imported": [
151
151
  {
152
- "uid": "ef61-110"
152
+ "uid": "37ac-110"
153
153
  },
154
154
  {
155
- "uid": "ef61-112"
155
+ "uid": "37ac-112"
156
156
  },
157
157
  {
158
- "uid": "ef61-114"
158
+ "uid": "37ac-114"
159
159
  }
160
160
  ],
161
161
  "importedBy": [
162
162
  {
163
- "uid": "ef61-120"
163
+ "uid": "37ac-120"
164
164
  }
165
165
  ]
166
166
  },
167
- "ef61-118": {
167
+ "37ac-118": {
168
168
  "id": "/packages/react-store/build/esm/index.js",
169
169
  "moduleParts": {
170
- "index.production.js": "ef61-119"
170
+ "index.production.js": "37ac-119"
171
171
  },
172
172
  "imported": [
173
173
  {
174
- "uid": "ef61-123"
174
+ "uid": "37ac-123"
175
175
  }
176
176
  ],
177
177
  "importedBy": [
178
178
  {
179
- "uid": "ef61-120"
179
+ "uid": "37ac-120"
180
180
  }
181
181
  ]
182
182
  },
183
- "ef61-120": {
183
+ "37ac-120": {
184
184
  "id": "/packages/react-router/src/index.tsx",
185
185
  "moduleParts": {
186
- "index.production.js": "ef61-121"
186
+ "index.production.js": "37ac-121"
187
187
  },
188
188
  "imported": [
189
189
  {
190
- "uid": "ef61-108"
190
+ "uid": "37ac-108"
191
191
  },
192
192
  {
193
- "uid": "ef61-122"
193
+ "uid": "37ac-122"
194
194
  },
195
195
  {
196
- "uid": "ef61-116"
196
+ "uid": "37ac-116"
197
197
  },
198
198
  {
199
- "uid": "ef61-118"
199
+ "uid": "37ac-118"
200
200
  }
201
201
  ],
202
202
  "importedBy": [],
203
203
  "isEntry": true
204
204
  },
205
- "ef61-122": {
205
+ "37ac-122": {
206
206
  "id": "react",
207
207
  "moduleParts": {},
208
208
  "imported": [],
209
209
  "importedBy": [
210
210
  {
211
- "uid": "ef61-120"
211
+ "uid": "37ac-120"
212
212
  }
213
213
  ],
214
214
  "isExternal": true
215
215
  },
216
- "ef61-123": {
216
+ "37ac-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": "37ac-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
  }));
@@ -1472,7 +1472,7 @@
1472
1472
  id: opts.id,
1473
1473
  pathname: opts.pathname,
1474
1474
  params: opts.params,
1475
- store: new Store({
1475
+ __store: new Store({
1476
1476
  updatedAt: 0,
1477
1477
  routeSearch: {},
1478
1478
  search: {},
@@ -1483,7 +1483,7 @@
1483
1483
  }
1484
1484
  })
1485
1485
  });
1486
- this.state = this.store.state;
1486
+ this.state = this.__store.state;
1487
1487
  componentTypes.map(async type => {
1488
1488
  const component = this.route.options[type];
1489
1489
  if (typeof this[type] !== 'function') {
@@ -1491,7 +1491,7 @@
1491
1491
  }
1492
1492
  });
1493
1493
  if (this.state.status === 'idle' && !this.#hasLoaders()) {
1494
- this.store.setState(s => ({
1494
+ this.__store.setState(s => ({
1495
1495
  ...s,
1496
1496
  status: 'success'
1497
1497
  }));
@@ -1511,7 +1511,7 @@
1511
1511
  });
1512
1512
  this.context = context;
1513
1513
  this.routeContext = routeContext;
1514
- this.store.setState(s => ({
1514
+ this.__store.setState(s => ({
1515
1515
  ...s,
1516
1516
  routeSearch: replaceEqualDeep(s.routeSearch, routeSearch),
1517
1517
  search: replaceEqualDeep(s.search, search)
@@ -1582,7 +1582,7 @@
1582
1582
  return;
1583
1583
  }
1584
1584
  this.route.options.onError?.(err);
1585
- this.store.setState(s => ({
1585
+ this.__store.setState(s => ({
1586
1586
  ...s,
1587
1587
  status: 'error',
1588
1588
  error: err
@@ -1616,7 +1616,7 @@
1616
1616
  // to a loading state again. Otherwise, keep it
1617
1617
  // as loading or resolved
1618
1618
  if (this.state.status === 'idle') {
1619
- this.store.setState(s => ({
1619
+ this.__store.setState(s => ({
1620
1620
  ...s,
1621
1621
  status: 'pending'
1622
1622
  }));
@@ -1649,7 +1649,7 @@
1649
1649
  try {
1650
1650
  await Promise.all([componentsPromise, dataPromise]);
1651
1651
  if (latestPromise = checkLatest()) return await latestPromise;
1652
- this.store.setState(s => ({
1652
+ this.__store.setState(s => ({
1653
1653
  ...s,
1654
1654
  error: undefined,
1655
1655
  status: 'success',
@@ -1662,7 +1662,7 @@
1662
1662
  }
1663
1663
  this.route.options.onLoadError?.(err);
1664
1664
  this.route.options.onError?.(err);
1665
- this.store.setState(s => ({
1665
+ this.__store.setState(s => ({
1666
1666
  ...s,
1667
1667
  error: err,
1668
1668
  status: 'error',
@@ -1881,7 +1881,7 @@
1881
1881
  ...rest
1882
1882
  }) {
1883
1883
  router.update(rest);
1884
- const currentMatches = useStore(router.store, s => s.currentMatches);
1884
+ const currentMatches = useStore(router.__store, s => s.currentMatches);
1885
1885
  React__namespace.useEffect(router.mount, [router]);
1886
1886
  return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
1887
1887
  value: {
@@ -1899,12 +1899,12 @@
1899
1899
  function useRouterContext() {
1900
1900
  const value = React__namespace.useContext(routerContext);
1901
1901
  warning(value, 'useRouter must be used inside a <Router> component!');
1902
- useStore(value.router.store);
1902
+ useStore(value.router.__store);
1903
1903
  return value.router;
1904
1904
  }
1905
1905
  function useRouter(track, shallow) {
1906
1906
  const router = useRouterContext();
1907
- useStore(router.store, track, shallow);
1907
+ useStore(router.__store, track, shallow);
1908
1908
  return router;
1909
1909
  }
1910
1910
  function useMatches() {
@@ -1918,7 +1918,7 @@
1918
1918
  if (opts?.strict ?? true) {
1919
1919
  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
1920
  }
1921
- useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
1921
+ useStore(match.__store, d => opts?.track?.(match) ?? match, opts?.shallow);
1922
1922
  return match;
1923
1923
  }
1924
1924
  function useRoute(routeId) {
@@ -1928,13 +1928,17 @@
1928
1928
  return resolvedRoute;
1929
1929
  }
1930
1930
  function useSearch(opts) {
1931
- const match = useMatch(opts);
1932
- useStore(match.store, d => opts?.track?.(d.search) ?? d.search, true);
1931
+ const {
1932
+ track,
1933
+ ...matchOpts
1934
+ } = opts;
1935
+ const match = useMatch(matchOpts);
1936
+ useStore(match.__store, d => opts?.track?.(d.search) ?? d.search, true);
1933
1937
  return match.state.search;
1934
1938
  }
1935
1939
  function useParams(opts) {
1936
1940
  const router = useRouterContext();
1937
- useStore(router.store, d => {
1941
+ useStore(router.__store, d => {
1938
1942
  const params = last(d.currentMatches)?.params;
1939
1943
  return opts?.track?.(params) ?? params;
1940
1944
  }, true);
@@ -1990,7 +1994,7 @@
1990
1994
  match
1991
1995
  }) {
1992
1996
  const router = useRouterContext();
1993
- useStore(match.store, store => [store.status, store.error], true);
1997
+ useStore(match.__store, store => [store.status, store.error], true);
1994
1998
  const defaultPending = React__namespace.useCallback(() => null, []);
1995
1999
  const Inner = React__namespace.useCallback(props => {
1996
2000
  if (props.match.state.status === 'error') {