@tanstack/react-router 0.0.1-beta.33 → 0.0.1-beta.35

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.
@@ -4024,7 +4024,7 @@ var drawChart = (function (exports) {
4024
4024
  </script>
4025
4025
  <script>
4026
4026
  /*<!--*/
4027
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"5f6f-59","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules/.pnpm","children":[{"name":"@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js","uid":"5f6f-61"},{"name":"history@5.3.0/node_modules/history/index.js","uid":"5f6f-63"},{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"5f6f-65"}]},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"5f6f-67"},{"name":"react-router/src/index.tsx","uid":"5f6f-69"}]}]}],"isRoot":true},"nodeParts":{"5f6f-59":{"renderedLength":793,"gzipLength":363,"brotliLength":0,"mainUid":"5f6f-58"},"5f6f-61":{"renderedLength":435,"gzipLength":241,"brotliLength":0,"mainUid":"5f6f-60"},"5f6f-63":{"renderedLength":20630,"gzipLength":3800,"brotliLength":0,"mainUid":"5f6f-62"},"5f6f-65":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"5f6f-64"},"5f6f-67":{"renderedLength":54818,"gzipLength":12329,"brotliLength":0,"mainUid":"5f6f-66"},"5f6f-69":{"renderedLength":14166,"gzipLength":3535,"brotliLength":0,"mainUid":"5f6f-68"}},"nodeMetas":{"5f6f-58":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"5f6f-59"},"imported":[],"importedBy":[{"uid":"5f6f-68"}]},"5f6f-60":{"id":"/node_modules/.pnpm/@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js","moduleParts":{"index.production.js":"5f6f-61"},"imported":[],"importedBy":[{"uid":"5f6f-62"}]},"5f6f-62":{"id":"/node_modules/.pnpm/history@5.3.0/node_modules/history/index.js","moduleParts":{"index.production.js":"5f6f-63"},"imported":[{"uid":"5f6f-60"}],"importedBy":[{"uid":"5f6f-66"}]},"5f6f-64":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"5f6f-65"},"imported":[],"importedBy":[{"uid":"5f6f-66"}]},"5f6f-66":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"5f6f-67"},"imported":[{"uid":"5f6f-62"},{"uid":"5f6f-64"}],"importedBy":[{"uid":"5f6f-68"}]},"5f6f-68":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"5f6f-69"},"imported":[{"uid":"5f6f-58"},{"uid":"5f6f-70"},{"uid":"5f6f-71"},{"uid":"5f6f-66"}],"importedBy":[],"isEntry":true},"5f6f-70":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"5f6f-68"}],"isExternal":true},"5f6f-71":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"5f6f-68"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4027
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"3fab-59","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules/.pnpm","children":[{"name":"@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js","uid":"3fab-61"},{"name":"history@5.3.0/node_modules/history/index.js","uid":"3fab-63"},{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"3fab-65"}]},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"3fab-67"},{"name":"react-router/src/index.tsx","uid":"3fab-69"}]}]}],"isRoot":true},"nodeParts":{"3fab-59":{"renderedLength":793,"gzipLength":363,"brotliLength":0,"mainUid":"3fab-58"},"3fab-61":{"renderedLength":435,"gzipLength":241,"brotliLength":0,"mainUid":"3fab-60"},"3fab-63":{"renderedLength":20630,"gzipLength":3800,"brotliLength":0,"mainUid":"3fab-62"},"3fab-65":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"3fab-64"},"3fab-67":{"renderedLength":55144,"gzipLength":12425,"brotliLength":0,"mainUid":"3fab-66"},"3fab-69":{"renderedLength":14166,"gzipLength":3535,"brotliLength":0,"mainUid":"3fab-68"}},"nodeMetas":{"3fab-58":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"3fab-59"},"imported":[],"importedBy":[{"uid":"3fab-68"}]},"3fab-60":{"id":"/node_modules/.pnpm/@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js","moduleParts":{"index.production.js":"3fab-61"},"imported":[],"importedBy":[{"uid":"3fab-62"}]},"3fab-62":{"id":"/node_modules/.pnpm/history@5.3.0/node_modules/history/index.js","moduleParts":{"index.production.js":"3fab-63"},"imported":[{"uid":"3fab-60"}],"importedBy":[{"uid":"3fab-66"}]},"3fab-64":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"3fab-65"},"imported":[],"importedBy":[{"uid":"3fab-66"}]},"3fab-66":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"3fab-67"},"imported":[{"uid":"3fab-62"},{"uid":"3fab-64"}],"importedBy":[{"uid":"3fab-68"}]},"3fab-68":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"3fab-69"},"imported":[{"uid":"3fab-58"},{"uid":"3fab-70"},{"uid":"3fab-71"},{"uid":"3fab-66"}],"importedBy":[],"isEntry":true},"3fab-70":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"3fab-68"}],"isExternal":true},"3fab-71":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"3fab-68"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4028
4028
 
4029
4029
  const run = () => {
4030
4030
  const width = window.innerWidth;
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "5f6f-73",
10
+ "uid": "3fab-73",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,15 +15,15 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js",
18
- "uid": "5f6f-75"
18
+ "uid": "3fab-75"
19
19
  },
20
20
  {
21
21
  "name": "history@5.3.0/node_modules/history/index.js",
22
- "uid": "5f6f-77"
22
+ "uid": "3fab-77"
23
23
  },
24
24
  {
25
25
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
26
- "uid": "5f6f-79"
26
+ "uid": "3fab-79"
27
27
  }
28
28
  ]
29
29
  },
@@ -32,11 +32,11 @@
32
32
  "children": [
33
33
  {
34
34
  "name": "router-core/build/esm/index.js",
35
- "uid": "5f6f-81"
35
+ "uid": "3fab-81"
36
36
  },
37
37
  {
38
38
  "name": "react-router/src/index.tsx",
39
- "uid": "5f6f-83"
39
+ "uid": "3fab-83"
40
40
  }
41
41
  ]
42
42
  }
@@ -46,155 +46,155 @@
46
46
  "isRoot": true
47
47
  },
48
48
  "nodeParts": {
49
- "5f6f-73": {
49
+ "3fab-73": {
50
50
  "renderedLength": 793,
51
51
  "gzipLength": 363,
52
52
  "brotliLength": 0,
53
- "mainUid": "5f6f-72"
53
+ "mainUid": "3fab-72"
54
54
  },
55
- "5f6f-75": {
55
+ "3fab-75": {
56
56
  "renderedLength": 435,
57
57
  "gzipLength": 241,
58
58
  "brotliLength": 0,
59
- "mainUid": "5f6f-74"
59
+ "mainUid": "3fab-74"
60
60
  },
61
- "5f6f-77": {
61
+ "3fab-77": {
62
62
  "renderedLength": 20630,
63
63
  "gzipLength": 3800,
64
64
  "brotliLength": 0,
65
- "mainUid": "5f6f-76"
65
+ "mainUid": "3fab-76"
66
66
  },
67
- "5f6f-79": {
67
+ "3fab-79": {
68
68
  "renderedLength": 181,
69
69
  "gzipLength": 129,
70
70
  "brotliLength": 0,
71
- "mainUid": "5f6f-78"
71
+ "mainUid": "3fab-78"
72
72
  },
73
- "5f6f-81": {
74
- "renderedLength": 54818,
75
- "gzipLength": 12329,
73
+ "3fab-81": {
74
+ "renderedLength": 55144,
75
+ "gzipLength": 12425,
76
76
  "brotliLength": 0,
77
- "mainUid": "5f6f-80"
77
+ "mainUid": "3fab-80"
78
78
  },
79
- "5f6f-83": {
79
+ "3fab-83": {
80
80
  "renderedLength": 14166,
81
81
  "gzipLength": 3535,
82
82
  "brotliLength": 0,
83
- "mainUid": "5f6f-82"
83
+ "mainUid": "3fab-82"
84
84
  }
85
85
  },
86
86
  "nodeMetas": {
87
- "5f6f-72": {
87
+ "3fab-72": {
88
88
  "id": "\u0000rollupPluginBabelHelpers.js",
89
89
  "moduleParts": {
90
- "index.production.js": "5f6f-73"
90
+ "index.production.js": "3fab-73"
91
91
  },
92
92
  "imported": [],
93
93
  "importedBy": [
94
94
  {
95
- "uid": "5f6f-82"
95
+ "uid": "3fab-82"
96
96
  }
97
97
  ]
98
98
  },
99
- "5f6f-74": {
99
+ "3fab-74": {
100
100
  "id": "/node_modules/.pnpm/@babel+runtime@7.20.6/node_modules/@babel/runtime/helpers/esm/extends.js",
101
101
  "moduleParts": {
102
- "index.production.js": "5f6f-75"
102
+ "index.production.js": "3fab-75"
103
103
  },
104
104
  "imported": [],
105
105
  "importedBy": [
106
106
  {
107
- "uid": "5f6f-76"
107
+ "uid": "3fab-76"
108
108
  }
109
109
  ]
110
110
  },
111
- "5f6f-76": {
111
+ "3fab-76": {
112
112
  "id": "/node_modules/.pnpm/history@5.3.0/node_modules/history/index.js",
113
113
  "moduleParts": {
114
- "index.production.js": "5f6f-77"
114
+ "index.production.js": "3fab-77"
115
115
  },
116
116
  "imported": [
117
117
  {
118
- "uid": "5f6f-74"
118
+ "uid": "3fab-74"
119
119
  }
120
120
  ],
121
121
  "importedBy": [
122
122
  {
123
- "uid": "5f6f-80"
123
+ "uid": "3fab-80"
124
124
  }
125
125
  ]
126
126
  },
127
- "5f6f-78": {
127
+ "3fab-78": {
128
128
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
129
129
  "moduleParts": {
130
- "index.production.js": "5f6f-79"
130
+ "index.production.js": "3fab-79"
131
131
  },
132
132
  "imported": [],
133
133
  "importedBy": [
134
134
  {
135
- "uid": "5f6f-80"
135
+ "uid": "3fab-80"
136
136
  }
137
137
  ]
138
138
  },
139
- "5f6f-80": {
139
+ "3fab-80": {
140
140
  "id": "/packages/router-core/build/esm/index.js",
141
141
  "moduleParts": {
142
- "index.production.js": "5f6f-81"
142
+ "index.production.js": "3fab-81"
143
143
  },
144
144
  "imported": [
145
145
  {
146
- "uid": "5f6f-76"
146
+ "uid": "3fab-76"
147
147
  },
148
148
  {
149
- "uid": "5f6f-78"
149
+ "uid": "3fab-78"
150
150
  }
151
151
  ],
152
152
  "importedBy": [
153
153
  {
154
- "uid": "5f6f-82"
154
+ "uid": "3fab-82"
155
155
  }
156
156
  ]
157
157
  },
158
- "5f6f-82": {
158
+ "3fab-82": {
159
159
  "id": "/packages/react-router/src/index.tsx",
160
160
  "moduleParts": {
161
- "index.production.js": "5f6f-83"
161
+ "index.production.js": "3fab-83"
162
162
  },
163
163
  "imported": [
164
164
  {
165
- "uid": "5f6f-72"
165
+ "uid": "3fab-72"
166
166
  },
167
167
  {
168
- "uid": "5f6f-84"
168
+ "uid": "3fab-84"
169
169
  },
170
170
  {
171
- "uid": "5f6f-85"
171
+ "uid": "3fab-85"
172
172
  },
173
173
  {
174
- "uid": "5f6f-80"
174
+ "uid": "3fab-80"
175
175
  }
176
176
  ],
177
177
  "importedBy": [],
178
178
  "isEntry": true
179
179
  },
180
- "5f6f-84": {
180
+ "3fab-84": {
181
181
  "id": "react",
182
182
  "moduleParts": {},
183
183
  "imported": [],
184
184
  "importedBy": [
185
185
  {
186
- "uid": "5f6f-82"
186
+ "uid": "3fab-82"
187
187
  }
188
188
  ],
189
189
  "isExternal": true
190
190
  },
191
- "5f6f-85": {
191
+ "3fab-85": {
192
192
  "id": "use-sync-external-store/shim",
193
193
  "moduleParts": {},
194
194
  "imported": [],
195
195
  "importedBy": [
196
196
  {
197
- "uid": "5f6f-82"
197
+ "uid": "3fab-82"
198
198
  }
199
199
  ],
200
200
  "isExternal": true
@@ -1078,8 +1078,8 @@
1078
1078
  return segment.value;
1079
1079
  }));
1080
1080
  }
1081
- function matchPathname(currentPathname, matchLocation) {
1082
- const pathParams = matchByPath(currentPathname, matchLocation);
1081
+ function matchPathname(basepath, currentPathname, matchLocation) {
1082
+ const pathParams = matchByPath(basepath, currentPathname, matchLocation);
1083
1083
  // const searchMatched = matchBySearch(currentLocation.search, matchLocation)
1084
1084
 
1085
1085
  if (matchLocation.to && !pathParams) {
@@ -1087,10 +1087,15 @@
1087
1087
  }
1088
1088
  return pathParams != null ? pathParams : {};
1089
1089
  }
1090
- function matchByPath(from, matchLocation) {
1090
+ function matchByPath(basepath, from, matchLocation) {
1091
1091
  var _matchLocation$to;
1092
+ if (!from.startsWith(basepath)) {
1093
+ return undefined;
1094
+ }
1095
+ from = basepath != '/' ? from.substring(basepath.length) : from;
1092
1096
  const baseSegments = parsePathname(from);
1093
- const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
1097
+ const to = "" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*');
1098
+ const routeSegments = parsePathname(to);
1094
1099
  const params = {};
1095
1100
  let isMatch = (() => {
1096
1101
  for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
@@ -1701,7 +1706,7 @@
1701
1706
  });
1702
1707
  },
1703
1708
  mount: () => {
1704
- const next = router.__.buildLocation({
1709
+ router.__.buildLocation({
1705
1710
  to: '.',
1706
1711
  search: true,
1707
1712
  hash: true
@@ -1709,9 +1714,10 @@
1709
1714
 
1710
1715
  // If the current location isn't updated, trigger a navigation
1711
1716
  // to the current location. Otherwise, load the current location.
1712
- if (next.href !== router.__location.href) {
1713
- router.__.commitLocation(next, true);
1714
- }
1717
+ // if (next.href !== router.__location.href) {
1718
+ // router.__.commitLocation(next, true)
1719
+ // }
1720
+
1715
1721
  if (!router.state.matches.length) {
1716
1722
  router.load();
1717
1723
  }
@@ -1739,6 +1745,7 @@
1739
1745
  router.load();
1740
1746
  },
1741
1747
  update: opts => {
1748
+ var _trimPath;
1742
1749
  const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
1743
1750
  if (!router.__location || newHistory) {
1744
1751
  if (opts != null && opts.history) {
@@ -1752,7 +1759,7 @@
1752
1759
  basepath,
1753
1760
  routeConfig
1754
1761
  } = router.options;
1755
- router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
1762
+ router.basepath = "/" + ((_trimPath = trimPath(basepath != null ? basepath : '')) != null ? _trimPath : '');
1756
1763
  if (routeConfig) {
1757
1764
  router.routesById = {};
1758
1765
  router.routeTree = router.__.buildRouteTree(routeConfig);
@@ -1803,10 +1810,8 @@
1803
1810
  match
1804
1811
  })));
1805
1812
  } catch (err) {
1806
- if (err != null && err.then) {
1807
- await new Promise(() => {});
1808
- }
1809
- throw err;
1813
+ console.info(err);
1814
+ invariant(false, "A route's beforeLoad middleware failed! \uD83D\uDC46");
1810
1815
  }
1811
1816
  router.notify();
1812
1817
 
@@ -1950,11 +1955,12 @@
1950
1955
  return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
1951
1956
  }
1952
1957
  const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
1953
- const matchParams = matchPathname(pathname, {
1958
+ const matchParams = matchPathname(router.basepath, pathname, {
1954
1959
  to: route.fullPath,
1955
1960
  fuzzy,
1956
1961
  caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
1957
1962
  });
1963
+ console.log(router.basepath, route.fullPath, fuzzy, pathname, matchParams);
1958
1964
  if (matchParams) {
1959
1965
  let parsedParams;
1960
1966
  try {
@@ -2088,11 +2094,11 @@
2088
2094
  if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
2089
2095
  return false;
2090
2096
  }
2091
- return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
2097
+ return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
2092
2098
  to: next.pathname
2093
2099
  }));
2094
2100
  }
2095
- return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
2101
+ return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
2096
2102
  to: next.pathname
2097
2103
  }));
2098
2104
  },