@tanstack/router-core 1.121.16 → 1.121.17

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.
Files changed (125) hide show
  1. package/package.json +1 -1
  2. package/src/redirect.ts +3 -0
  3. package/src/router.ts +15 -1
  4. package/dist/cjs/Matches.cjs +0 -13
  5. package/dist/cjs/Matches.cjs.map +0 -1
  6. package/dist/cjs/Matches.d.cts +0 -109
  7. package/dist/cjs/RouterProvider.d.cts +0 -26
  8. package/dist/cjs/defer.cjs +0 -25
  9. package/dist/cjs/defer.cjs.map +0 -1
  10. package/dist/cjs/defer.d.cts +0 -20
  11. package/dist/cjs/fileRoute.d.cts +0 -23
  12. package/dist/cjs/history.d.cts +0 -8
  13. package/dist/cjs/index.cjs +0 -79
  14. package/dist/cjs/index.cjs.map +0 -1
  15. package/dist/cjs/index.d.cts +0 -41
  16. package/dist/cjs/link.cjs +0 -5
  17. package/dist/cjs/link.cjs.map +0 -1
  18. package/dist/cjs/link.d.cts +0 -212
  19. package/dist/cjs/location.d.cts +0 -12
  20. package/dist/cjs/manifest.d.cts +0 -24
  21. package/dist/cjs/not-found.cjs +0 -13
  22. package/dist/cjs/not-found.cjs.map +0 -1
  23. package/dist/cjs/not-found.d.cts +0 -20
  24. package/dist/cjs/path.cjs +0 -412
  25. package/dist/cjs/path.cjs.map +0 -1
  26. package/dist/cjs/path.d.cts +0 -56
  27. package/dist/cjs/qss.cjs +0 -36
  28. package/dist/cjs/qss.cjs.map +0 -1
  29. package/dist/cjs/qss.d.cts +0 -31
  30. package/dist/cjs/redirect.cjs +0 -39
  31. package/dist/cjs/redirect.cjs.map +0 -1
  32. package/dist/cjs/redirect.d.cts +0 -41
  33. package/dist/cjs/root.cjs +0 -5
  34. package/dist/cjs/root.cjs.map +0 -1
  35. package/dist/cjs/root.d.cts +0 -2
  36. package/dist/cjs/route.cjs +0 -119
  37. package/dist/cjs/route.cjs.map +0 -1
  38. package/dist/cjs/route.d.cts +0 -432
  39. package/dist/cjs/routeInfo.d.cts +0 -54
  40. package/dist/cjs/router.cjs +0 -1792
  41. package/dist/cjs/router.cjs.map +0 -1
  42. package/dist/cjs/router.d.cts +0 -627
  43. package/dist/cjs/scroll-restoration.cjs +0 -207
  44. package/dist/cjs/scroll-restoration.cjs.map +0 -1
  45. package/dist/cjs/scroll-restoration.d.cts +0 -38
  46. package/dist/cjs/searchMiddleware.cjs +0 -42
  47. package/dist/cjs/searchMiddleware.cjs.map +0 -1
  48. package/dist/cjs/searchMiddleware.d.cts +0 -5
  49. package/dist/cjs/searchParams.cjs +0 -61
  50. package/dist/cjs/searchParams.cjs.map +0 -1
  51. package/dist/cjs/searchParams.d.cts +0 -7
  52. package/dist/cjs/serializer.d.cts +0 -22
  53. package/dist/cjs/structuralSharing.d.cts +0 -4
  54. package/dist/cjs/typePrimitives.d.cts +0 -65
  55. package/dist/cjs/useLoaderData.d.cts +0 -5
  56. package/dist/cjs/useLoaderDeps.d.cts +0 -5
  57. package/dist/cjs/useNavigate.d.cts +0 -3
  58. package/dist/cjs/useParams.d.cts +0 -5
  59. package/dist/cjs/useRouteContext.d.cts +0 -9
  60. package/dist/cjs/useSearch.d.cts +0 -5
  61. package/dist/cjs/utils.cjs +0 -165
  62. package/dist/cjs/utils.cjs.map +0 -1
  63. package/dist/cjs/utils.d.cts +0 -94
  64. package/dist/cjs/validators.d.cts +0 -51
  65. package/dist/esm/Matches.d.ts +0 -109
  66. package/dist/esm/Matches.js +0 -13
  67. package/dist/esm/Matches.js.map +0 -1
  68. package/dist/esm/RouterProvider.d.ts +0 -26
  69. package/dist/esm/defer.d.ts +0 -20
  70. package/dist/esm/defer.js +0 -25
  71. package/dist/esm/defer.js.map +0 -1
  72. package/dist/esm/fileRoute.d.ts +0 -23
  73. package/dist/esm/history.d.ts +0 -8
  74. package/dist/esm/index.d.ts +0 -41
  75. package/dist/esm/index.js +0 -79
  76. package/dist/esm/index.js.map +0 -1
  77. package/dist/esm/link.d.ts +0 -212
  78. package/dist/esm/link.js +0 -5
  79. package/dist/esm/link.js.map +0 -1
  80. package/dist/esm/location.d.ts +0 -12
  81. package/dist/esm/manifest.d.ts +0 -24
  82. package/dist/esm/not-found.d.ts +0 -20
  83. package/dist/esm/not-found.js +0 -13
  84. package/dist/esm/not-found.js.map +0 -1
  85. package/dist/esm/path.d.ts +0 -56
  86. package/dist/esm/path.js +0 -412
  87. package/dist/esm/path.js.map +0 -1
  88. package/dist/esm/qss.d.ts +0 -31
  89. package/dist/esm/qss.js +0 -36
  90. package/dist/esm/qss.js.map +0 -1
  91. package/dist/esm/redirect.d.ts +0 -41
  92. package/dist/esm/redirect.js +0 -39
  93. package/dist/esm/redirect.js.map +0 -1
  94. package/dist/esm/root.d.ts +0 -2
  95. package/dist/esm/root.js +0 -5
  96. package/dist/esm/root.js.map +0 -1
  97. package/dist/esm/route.d.ts +0 -432
  98. package/dist/esm/route.js +0 -119
  99. package/dist/esm/route.js.map +0 -1
  100. package/dist/esm/routeInfo.d.ts +0 -54
  101. package/dist/esm/router.d.ts +0 -627
  102. package/dist/esm/router.js +0 -1792
  103. package/dist/esm/router.js.map +0 -1
  104. package/dist/esm/scroll-restoration.d.ts +0 -38
  105. package/dist/esm/scroll-restoration.js +0 -207
  106. package/dist/esm/scroll-restoration.js.map +0 -1
  107. package/dist/esm/searchMiddleware.d.ts +0 -5
  108. package/dist/esm/searchMiddleware.js +0 -42
  109. package/dist/esm/searchMiddleware.js.map +0 -1
  110. package/dist/esm/searchParams.d.ts +0 -7
  111. package/dist/esm/searchParams.js +0 -61
  112. package/dist/esm/searchParams.js.map +0 -1
  113. package/dist/esm/serializer.d.ts +0 -22
  114. package/dist/esm/structuralSharing.d.ts +0 -4
  115. package/dist/esm/typePrimitives.d.ts +0 -65
  116. package/dist/esm/useLoaderData.d.ts +0 -5
  117. package/dist/esm/useLoaderDeps.d.ts +0 -5
  118. package/dist/esm/useNavigate.d.ts +0 -3
  119. package/dist/esm/useParams.d.ts +0 -5
  120. package/dist/esm/useRouteContext.d.ts +0 -9
  121. package/dist/esm/useSearch.d.ts +0 -5
  122. package/dist/esm/utils.d.ts +0 -94
  123. package/dist/esm/utils.js +0 -165
  124. package/dist/esm/utils.js.map +0 -1
  125. package/dist/esm/validators.d.ts +0 -51
@@ -1,1792 +0,0 @@
1
- import { Store, batch } from "@tanstack/store";
2
- import { createMemoryHistory, createBrowserHistory, parseHref } from "@tanstack/history";
3
- import invariant from "tiny-invariant";
4
- import { pick, createControlledPromise, deepEqual, replaceEqualDeep, last, functionalUpdate } from "./utils.js";
5
- import { trimPath, resolvePath, cleanPath, matchPathname, trimPathRight, interpolatePath, joinPaths, trimPathLeft, parsePathname } from "./path.js";
6
- import { isNotFound } from "./not-found.js";
7
- import { setupScrollRestoration } from "./scroll-restoration.js";
8
- import { defaultParseSearch, defaultStringifySearch } from "./searchParams.js";
9
- import { rootRouteId } from "./root.js";
10
- import { isRedirect } from "./redirect.js";
11
- function defaultSerializeError(err) {
12
- if (err instanceof Error) {
13
- const obj = {
14
- name: err.name,
15
- message: err.message
16
- };
17
- if (process.env.NODE_ENV === "development") {
18
- obj.stack = err.stack;
19
- }
20
- return obj;
21
- }
22
- return {
23
- data: err
24
- };
25
- }
26
- function getLocationChangeInfo(routerState) {
27
- const fromLocation = routerState.resolvedLocation;
28
- const toLocation = routerState.location;
29
- const pathChanged = (fromLocation == null ? void 0 : fromLocation.pathname) !== toLocation.pathname;
30
- const hrefChanged = (fromLocation == null ? void 0 : fromLocation.href) !== toLocation.href;
31
- const hashChanged = (fromLocation == null ? void 0 : fromLocation.hash) !== toLocation.hash;
32
- return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
33
- }
34
- class RouterCore {
35
- /**
36
- * @deprecated Use the `createRouter` function instead
37
- */
38
- constructor(options) {
39
- this.tempLocationKey = `${Math.round(
40
- Math.random() * 1e7
41
- )}`;
42
- this.resetNextScroll = true;
43
- this.shouldViewTransition = void 0;
44
- this.isViewTransitionTypesSupported = void 0;
45
- this.subscribers = /* @__PURE__ */ new Set();
46
- this.isScrollRestoring = false;
47
- this.isScrollRestorationSetup = false;
48
- this.startTransition = (fn) => fn();
49
- this.isShell = false;
50
- this.update = (newOptions) => {
51
- var _a;
52
- if (newOptions.notFoundRoute) {
53
- console.warn(
54
- "The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info."
55
- );
56
- }
57
- const previousOptions = this.options;
58
- this.options = {
59
- ...this.options,
60
- ...newOptions
61
- };
62
- this.isServer = this.options.isServer ?? typeof document === "undefined";
63
- this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map(
64
- this.options.pathParamsAllowedCharacters.map((char) => [
65
- encodeURIComponent(char),
66
- char
67
- ])
68
- ) : void 0;
69
- if (!this.basepath || newOptions.basepath && newOptions.basepath !== previousOptions.basepath) {
70
- if (newOptions.basepath === void 0 || newOptions.basepath === "" || newOptions.basepath === "/") {
71
- this.basepath = "/";
72
- } else {
73
- this.basepath = `/${trimPath(newOptions.basepath)}`;
74
- }
75
- }
76
- if (!this.history || this.options.history && this.options.history !== this.history) {
77
- this.history = this.options.history ?? (this.isServer ? createMemoryHistory({
78
- initialEntries: [this.basepath || "/"]
79
- }) : createBrowserHistory());
80
- this.latestLocation = this.parseLocation();
81
- }
82
- if (this.options.routeTree !== this.routeTree) {
83
- this.routeTree = this.options.routeTree;
84
- this.buildRouteTree();
85
- }
86
- if (!this.__store) {
87
- this.__store = new Store(getInitialRouterState(this.latestLocation), {
88
- onUpdate: () => {
89
- this.__store.state = {
90
- ...this.state,
91
- cachedMatches: this.state.cachedMatches.filter(
92
- (d) => !["redirected"].includes(d.status)
93
- )
94
- };
95
- }
96
- });
97
- setupScrollRestoration(this);
98
- }
99
- if (typeof window !== "undefined" && "CSS" in window && typeof ((_a = window.CSS) == null ? void 0 : _a.supports) === "function") {
100
- this.isViewTransitionTypesSupported = window.CSS.supports(
101
- "selector(:active-view-transition-type(a)"
102
- );
103
- }
104
- if (this.latestLocation.search.__TSS_SHELL) {
105
- this.isShell = true;
106
- }
107
- };
108
- this.buildRouteTree = () => {
109
- const { routesById, routesByPath, flatRoutes } = processRouteTree({
110
- routeTree: this.routeTree,
111
- initRoute: (route, i) => {
112
- route.init({
113
- originalIndex: i,
114
- defaultSsr: this.options.defaultSsr
115
- });
116
- }
117
- });
118
- this.routesById = routesById;
119
- this.routesByPath = routesByPath;
120
- this.flatRoutes = flatRoutes;
121
- const notFoundRoute = this.options.notFoundRoute;
122
- if (notFoundRoute) {
123
- notFoundRoute.init({
124
- originalIndex: 99999999999,
125
- defaultSsr: this.options.defaultSsr
126
- });
127
- this.routesById[notFoundRoute.id] = notFoundRoute;
128
- }
129
- };
130
- this.subscribe = (eventType, fn) => {
131
- const listener = {
132
- eventType,
133
- fn
134
- };
135
- this.subscribers.add(listener);
136
- return () => {
137
- this.subscribers.delete(listener);
138
- };
139
- };
140
- this.emit = (routerEvent) => {
141
- this.subscribers.forEach((listener) => {
142
- if (listener.eventType === routerEvent.type) {
143
- listener.fn(routerEvent);
144
- }
145
- });
146
- };
147
- this.parseLocation = (previousLocation, locationToParse) => {
148
- const parse = ({
149
- pathname,
150
- search,
151
- hash,
152
- state
153
- }) => {
154
- const parsedSearch = this.options.parseSearch(search);
155
- const searchStr = this.options.stringifySearch(parsedSearch);
156
- return {
157
- pathname,
158
- searchStr,
159
- search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
160
- hash: hash.split("#").reverse()[0] ?? "",
161
- href: `${pathname}${searchStr}${hash}`,
162
- state: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
163
- };
164
- };
165
- const location = parse(locationToParse ?? this.history.location);
166
- const { __tempLocation, __tempKey } = location.state;
167
- if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
168
- const parsedTempLocation = parse(__tempLocation);
169
- parsedTempLocation.state.key = location.state.key;
170
- delete parsedTempLocation.state.__tempLocation;
171
- return {
172
- ...parsedTempLocation,
173
- maskedLocation: location
174
- };
175
- }
176
- return location;
177
- };
178
- this.resolvePathWithBase = (from, path) => {
179
- const resolvedPath = resolvePath({
180
- basepath: this.basepath,
181
- base: from,
182
- to: cleanPath(path),
183
- trailingSlash: this.options.trailingSlash,
184
- caseSensitive: this.options.caseSensitive
185
- });
186
- return resolvedPath;
187
- };
188
- this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
189
- if (typeof pathnameOrNext === "string") {
190
- return this.matchRoutesInternal(
191
- {
192
- pathname: pathnameOrNext,
193
- search: locationSearchOrOpts
194
- },
195
- opts
196
- );
197
- }
198
- return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
199
- };
200
- this.getMatchedRoutes = (pathname, routePathname) => {
201
- return getMatchedRoutes({
202
- pathname,
203
- routePathname,
204
- basepath: this.basepath,
205
- caseSensitive: this.options.caseSensitive,
206
- routesByPath: this.routesByPath,
207
- routesById: this.routesById,
208
- flatRoutes: this.flatRoutes
209
- });
210
- };
211
- this.cancelMatch = (id) => {
212
- const match = this.getMatch(id);
213
- if (!match) return;
214
- match.abortController.abort();
215
- clearTimeout(match.pendingTimeout);
216
- };
217
- this.cancelMatches = () => {
218
- var _a;
219
- (_a = this.state.pendingMatches) == null ? void 0 : _a.forEach((match) => {
220
- this.cancelMatch(match.id);
221
- });
222
- };
223
- this.buildLocation = (opts) => {
224
- const build = (dest = {}) => {
225
- var _a;
226
- const currentLocation = dest._fromLocation || this.latestLocation;
227
- const allFromMatches = this.matchRoutes(currentLocation, {
228
- _buildLocation: true
229
- });
230
- const lastMatch = last(allFromMatches);
231
- let fromPath = lastMatch.fullPath;
232
- if (dest.unsafeRelative === "path") {
233
- fromPath = currentLocation.pathname;
234
- } else if (dest.to && dest.from) {
235
- fromPath = dest.from;
236
- const existingFrom = [...allFromMatches].reverse().find((d) => {
237
- return d.fullPath === fromPath || d.fullPath === joinPaths([fromPath, "/"]);
238
- });
239
- if (!existingFrom) {
240
- console.warn(`Could not find match for from: ${dest.from}`);
241
- }
242
- }
243
- const fromSearch = lastMatch.search;
244
- const fromParams = { ...lastMatch.params };
245
- const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : fromPath;
246
- let nextParams = (dest.params ?? true) === true ? fromParams : {
247
- ...fromParams,
248
- ...functionalUpdate(dest.params, fromParams)
249
- };
250
- const destRoutes = this.matchRoutes(
251
- nextTo,
252
- {},
253
- {
254
- _buildLocation: true
255
- }
256
- ).map((d) => this.looseRoutesById[d.routeId]);
257
- if (Object.keys(nextParams).length > 0) {
258
- destRoutes.map((route) => {
259
- var _a2;
260
- return ((_a2 = route.options.params) == null ? void 0 : _a2.stringify) ?? route.options.stringifyParams;
261
- }).filter(Boolean).forEach((fn) => {
262
- nextParams = { ...nextParams, ...fn(nextParams) };
263
- });
264
- }
265
- const nextPathname = interpolatePath({
266
- path: nextTo,
267
- params: nextParams ?? {},
268
- leaveWildcards: false,
269
- leaveParams: opts.leaveParams,
270
- decodeCharMap: this.pathParamsDecodeCharMap
271
- }).interpolatedPath;
272
- let nextSearch = fromSearch;
273
- if (opts._includeValidateSearch && ((_a = this.options.search) == null ? void 0 : _a.strict)) {
274
- let validatedSearch = {};
275
- destRoutes.forEach((route) => {
276
- try {
277
- if (route.options.validateSearch) {
278
- validatedSearch = {
279
- ...validatedSearch,
280
- ...validateSearch(route.options.validateSearch, {
281
- ...validatedSearch,
282
- ...nextSearch
283
- }) ?? {}
284
- };
285
- }
286
- } catch {
287
- }
288
- });
289
- nextSearch = validatedSearch;
290
- }
291
- nextSearch = applySearchMiddleware({
292
- search: nextSearch,
293
- dest,
294
- destRoutes,
295
- _includeValidateSearch: opts._includeValidateSearch
296
- });
297
- nextSearch = replaceEqualDeep(fromSearch, nextSearch);
298
- const searchStr = this.options.stringifySearch(nextSearch);
299
- const hash = dest.hash === true ? currentLocation.hash : dest.hash ? functionalUpdate(dest.hash, currentLocation.hash) : void 0;
300
- const hashStr = hash ? `#${hash}` : "";
301
- let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
302
- nextState = replaceEqualDeep(currentLocation.state, nextState);
303
- return {
304
- pathname: nextPathname,
305
- search: nextSearch,
306
- searchStr,
307
- state: nextState,
308
- hash: hash ?? "",
309
- href: `${nextPathname}${searchStr}${hashStr}`,
310
- unmaskOnReload: dest.unmaskOnReload
311
- };
312
- };
313
- const buildWithMatches = (dest = {}, maskedDest) => {
314
- var _a;
315
- const next = build(dest);
316
- let maskedNext = maskedDest ? build(maskedDest) : void 0;
317
- if (!maskedNext) {
318
- let params = {};
319
- const foundMask = (_a = this.options.routeMasks) == null ? void 0 : _a.find((d) => {
320
- const match = matchPathname(this.basepath, next.pathname, {
321
- to: d.from,
322
- caseSensitive: false,
323
- fuzzy: false
324
- });
325
- if (match) {
326
- params = match;
327
- return true;
328
- }
329
- return false;
330
- });
331
- if (foundMask) {
332
- const { from: _from, ...maskProps } = foundMask;
333
- maskedDest = {
334
- ...pick(opts, ["from"]),
335
- ...maskProps,
336
- params
337
- };
338
- maskedNext = build(maskedDest);
339
- }
340
- }
341
- if (maskedNext) {
342
- const maskedFinal = build(maskedDest);
343
- next.maskedLocation = maskedFinal;
344
- }
345
- return next;
346
- };
347
- if (opts.mask) {
348
- return buildWithMatches(opts, {
349
- ...pick(opts, ["from"]),
350
- ...opts.mask
351
- });
352
- }
353
- return buildWithMatches(opts);
354
- };
355
- this.commitLocation = ({
356
- viewTransition,
357
- ignoreBlocker,
358
- ...next
359
- }) => {
360
- const isSameState = () => {
361
- const ignoredProps = [
362
- "key",
363
- "__TSR_index",
364
- "__hashScrollIntoViewOptions"
365
- ];
366
- ignoredProps.forEach((prop) => {
367
- next.state[prop] = this.latestLocation.state[prop];
368
- });
369
- const isEqual = deepEqual(next.state, this.latestLocation.state);
370
- ignoredProps.forEach((prop) => {
371
- delete next.state[prop];
372
- });
373
- return isEqual;
374
- };
375
- const isSameUrl = this.latestLocation.href === next.href;
376
- const previousCommitPromise = this.commitLocationPromise;
377
- this.commitLocationPromise = createControlledPromise(() => {
378
- previousCommitPromise == null ? void 0 : previousCommitPromise.resolve();
379
- });
380
- if (isSameUrl && isSameState()) {
381
- this.load();
382
- } else {
383
- let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;
384
- if (maskedLocation) {
385
- nextHistory = {
386
- ...maskedLocation,
387
- state: {
388
- ...maskedLocation.state,
389
- __tempKey: void 0,
390
- __tempLocation: {
391
- ...nextHistory,
392
- search: nextHistory.searchStr,
393
- state: {
394
- ...nextHistory.state,
395
- __tempKey: void 0,
396
- __tempLocation: void 0,
397
- key: void 0
398
- }
399
- }
400
- }
401
- };
402
- if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
403
- nextHistory.state.__tempKey = this.tempLocationKey;
404
- }
405
- }
406
- nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
407
- this.shouldViewTransition = viewTransition;
408
- this.history[next.replace ? "replace" : "push"](
409
- nextHistory.href,
410
- nextHistory.state,
411
- { ignoreBlocker }
412
- );
413
- }
414
- this.resetNextScroll = next.resetScroll ?? true;
415
- if (!this.history.subscribers.size) {
416
- this.load();
417
- }
418
- return this.commitLocationPromise;
419
- };
420
- this.buildAndCommitLocation = ({
421
- replace,
422
- resetScroll,
423
- hashScrollIntoView,
424
- viewTransition,
425
- ignoreBlocker,
426
- href,
427
- ...rest
428
- } = {}) => {
429
- if (href) {
430
- const currentIndex = this.history.location.state.__TSR_index;
431
- const parsed = parseHref(href, {
432
- __TSR_index: replace ? currentIndex : currentIndex + 1
433
- });
434
- rest.to = parsed.pathname;
435
- rest.search = this.options.parseSearch(parsed.search);
436
- rest.hash = parsed.hash.slice(1);
437
- }
438
- const location = this.buildLocation({
439
- ...rest,
440
- _includeValidateSearch: true
441
- });
442
- return this.commitLocation({
443
- ...location,
444
- viewTransition,
445
- replace,
446
- resetScroll,
447
- hashScrollIntoView,
448
- ignoreBlocker
449
- });
450
- };
451
- this.navigate = ({ to, reloadDocument, href, ...rest }) => {
452
- if (!reloadDocument && href) {
453
- try {
454
- new URL(`${href}`);
455
- reloadDocument = true;
456
- } catch {
457
- }
458
- }
459
- if (reloadDocument) {
460
- if (!href) {
461
- const location = this.buildLocation({ to, ...rest });
462
- href = this.history.createHref(location.href);
463
- }
464
- if (rest.replace) {
465
- window.location.replace(href);
466
- } else {
467
- window.location.href = href;
468
- }
469
- return;
470
- }
471
- return this.buildAndCommitLocation({
472
- ...rest,
473
- href,
474
- to
475
- });
476
- };
477
- this.beforeLoad = () => {
478
- this.cancelMatches();
479
- this.latestLocation = this.parseLocation(this.latestLocation);
480
- const pendingMatches = this.matchRoutes(this.latestLocation);
481
- this.__store.setState((s) => ({
482
- ...s,
483
- status: "pending",
484
- isLoading: true,
485
- location: this.latestLocation,
486
- pendingMatches,
487
- // If a cached moved to pendingMatches, remove it from cachedMatches
488
- cachedMatches: s.cachedMatches.filter((d) => {
489
- return !pendingMatches.find((e) => e.id === d.id);
490
- })
491
- }));
492
- };
493
- this.load = async (opts) => {
494
- let redirect;
495
- let notFound;
496
- let loadPromise;
497
- loadPromise = new Promise((resolve) => {
498
- this.startTransition(async () => {
499
- var _a;
500
- try {
501
- this.beforeLoad();
502
- const next = this.latestLocation;
503
- const prevLocation = this.state.resolvedLocation;
504
- if (!this.state.redirect) {
505
- this.emit({
506
- type: "onBeforeNavigate",
507
- ...getLocationChangeInfo({
508
- resolvedLocation: prevLocation,
509
- location: next
510
- })
511
- });
512
- }
513
- this.emit({
514
- type: "onBeforeLoad",
515
- ...getLocationChangeInfo({
516
- resolvedLocation: prevLocation,
517
- location: next
518
- })
519
- });
520
- await this.loadMatches({
521
- sync: opts == null ? void 0 : opts.sync,
522
- matches: this.state.pendingMatches,
523
- location: next,
524
- // eslint-disable-next-line @typescript-eslint/require-await
525
- onReady: async () => {
526
- this.startViewTransition(async () => {
527
- let exitingMatches;
528
- let enteringMatches;
529
- let stayingMatches;
530
- batch(() => {
531
- this.__store.setState((s) => {
532
- const previousMatches = s.matches;
533
- const newMatches = s.pendingMatches || s.matches;
534
- exitingMatches = previousMatches.filter(
535
- (match) => !newMatches.find((d) => d.id === match.id)
536
- );
537
- enteringMatches = newMatches.filter(
538
- (match) => !previousMatches.find((d) => d.id === match.id)
539
- );
540
- stayingMatches = previousMatches.filter(
541
- (match) => newMatches.find((d) => d.id === match.id)
542
- );
543
- return {
544
- ...s,
545
- isLoading: false,
546
- loadedAt: Date.now(),
547
- matches: newMatches,
548
- pendingMatches: void 0,
549
- cachedMatches: [
550
- ...s.cachedMatches,
551
- ...exitingMatches.filter((d) => d.status !== "error")
552
- ]
553
- };
554
- });
555
- this.clearExpiredCache();
556
- });
557
- [
558
- [exitingMatches, "onLeave"],
559
- [enteringMatches, "onEnter"],
560
- [stayingMatches, "onStay"]
561
- ].forEach(([matches, hook]) => {
562
- matches.forEach((match) => {
563
- var _a2, _b;
564
- (_b = (_a2 = this.looseRoutesById[match.routeId].options)[hook]) == null ? void 0 : _b.call(_a2, match);
565
- });
566
- });
567
- });
568
- }
569
- });
570
- } catch (err) {
571
- if (isRedirect(err)) {
572
- redirect = err;
573
- if (!this.isServer) {
574
- this.navigate({
575
- ...redirect.options,
576
- replace: true,
577
- ignoreBlocker: true
578
- });
579
- }
580
- } else if (isNotFound(err)) {
581
- notFound = err;
582
- }
583
- this.__store.setState((s) => ({
584
- ...s,
585
- statusCode: redirect ? redirect.status : notFound ? 404 : s.matches.some((d) => d.status === "error") ? 500 : 200,
586
- redirect
587
- }));
588
- }
589
- if (this.latestLoadPromise === loadPromise) {
590
- (_a = this.commitLocationPromise) == null ? void 0 : _a.resolve();
591
- this.latestLoadPromise = void 0;
592
- this.commitLocationPromise = void 0;
593
- }
594
- resolve();
595
- });
596
- });
597
- this.latestLoadPromise = loadPromise;
598
- await loadPromise;
599
- while (this.latestLoadPromise && loadPromise !== this.latestLoadPromise) {
600
- await this.latestLoadPromise;
601
- }
602
- if (this.hasNotFoundMatch()) {
603
- this.__store.setState((s) => ({
604
- ...s,
605
- statusCode: 404
606
- }));
607
- }
608
- };
609
- this.startViewTransition = (fn) => {
610
- const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
611
- delete this.shouldViewTransition;
612
- if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
613
- let startViewTransitionParams;
614
- if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
615
- const next = this.latestLocation;
616
- const prevLocation = this.state.resolvedLocation;
617
- const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(
618
- getLocationChangeInfo({
619
- resolvedLocation: prevLocation,
620
- location: next
621
- })
622
- ) : shouldViewTransition.types;
623
- startViewTransitionParams = {
624
- update: fn,
625
- types: resolvedViewTransitionTypes
626
- };
627
- } else {
628
- startViewTransitionParams = fn;
629
- }
630
- document.startViewTransition(startViewTransitionParams);
631
- } else {
632
- fn();
633
- }
634
- };
635
- this.updateMatch = (id, updater) => {
636
- var _a;
637
- let updated;
638
- const isPending = (_a = this.state.pendingMatches) == null ? void 0 : _a.find((d) => d.id === id);
639
- const isMatched = this.state.matches.find((d) => d.id === id);
640
- const isCached = this.state.cachedMatches.find((d) => d.id === id);
641
- const matchesKey = isPending ? "pendingMatches" : isMatched ? "matches" : isCached ? "cachedMatches" : "";
642
- if (matchesKey) {
643
- this.__store.setState((s) => {
644
- var _a2;
645
- return {
646
- ...s,
647
- [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map(
648
- (d) => d.id === id ? updated = updater(d) : d
649
- )
650
- };
651
- });
652
- }
653
- return updated;
654
- };
655
- this.getMatch = (matchId) => {
656
- return [
657
- ...this.state.cachedMatches,
658
- ...this.state.pendingMatches ?? [],
659
- ...this.state.matches
660
- ].find((d) => d.id === matchId);
661
- };
662
- this.loadMatches = async ({
663
- location,
664
- matches,
665
- preload: allPreload,
666
- onReady,
667
- updateMatch = this.updateMatch,
668
- sync
669
- }) => {
670
- let firstBadMatchIndex;
671
- let rendered = false;
672
- const triggerOnReady = async () => {
673
- if (!rendered) {
674
- rendered = true;
675
- await (onReady == null ? void 0 : onReady());
676
- }
677
- };
678
- const resolvePreload = (matchId) => {
679
- return !!(allPreload && !this.state.matches.find((d) => d.id === matchId));
680
- };
681
- const handleRedirectAndNotFound = (match, err) => {
682
- var _a, _b, _c, _d;
683
- if (isRedirect(err) || isNotFound(err)) {
684
- if (isRedirect(err)) {
685
- if (err.redirectHandled) {
686
- if (!err.options.reloadDocument) {
687
- throw err;
688
- }
689
- }
690
- }
691
- (_a = match.beforeLoadPromise) == null ? void 0 : _a.resolve();
692
- (_b = match.loaderPromise) == null ? void 0 : _b.resolve();
693
- updateMatch(match.id, (prev) => ({
694
- ...prev,
695
- status: isRedirect(err) ? "redirected" : isNotFound(err) ? "notFound" : "error",
696
- isFetching: false,
697
- error: err,
698
- beforeLoadPromise: void 0,
699
- loaderPromise: void 0
700
- }));
701
- if (!err.routeId) {
702
- err.routeId = match.routeId;
703
- }
704
- (_c = match.loadPromise) == null ? void 0 : _c.resolve();
705
- if (isRedirect(err)) {
706
- rendered = true;
707
- err.options._fromLocation = location;
708
- err.redirectHandled = true;
709
- err = this.resolveRedirect(err);
710
- throw err;
711
- } else if (isNotFound(err)) {
712
- this._handleNotFound(matches, err, {
713
- updateMatch
714
- });
715
- (_d = this.serverSsr) == null ? void 0 : _d.onMatchSettled({
716
- router: this,
717
- match: this.getMatch(match.id)
718
- });
719
- throw err;
720
- }
721
- }
722
- };
723
- try {
724
- await new Promise((resolveAll, rejectAll) => {
725
- ;
726
- (async () => {
727
- var _a, _b, _c, _d;
728
- try {
729
- const handleSerialError = (index, err, routerCode) => {
730
- var _a2, _b2;
731
- const { id: matchId, routeId } = matches[index];
732
- const route = this.looseRoutesById[routeId];
733
- if (err instanceof Promise) {
734
- throw err;
735
- }
736
- err.routerCode = routerCode;
737
- firstBadMatchIndex = firstBadMatchIndex ?? index;
738
- handleRedirectAndNotFound(this.getMatch(matchId), err);
739
- try {
740
- (_b2 = (_a2 = route.options).onError) == null ? void 0 : _b2.call(_a2, err);
741
- } catch (errorHandlerErr) {
742
- err = errorHandlerErr;
743
- handleRedirectAndNotFound(this.getMatch(matchId), err);
744
- }
745
- updateMatch(matchId, (prev) => {
746
- var _a3, _b3;
747
- (_a3 = prev.beforeLoadPromise) == null ? void 0 : _a3.resolve();
748
- (_b3 = prev.loadPromise) == null ? void 0 : _b3.resolve();
749
- return {
750
- ...prev,
751
- error: err,
752
- status: "error",
753
- isFetching: false,
754
- updatedAt: Date.now(),
755
- abortController: new AbortController(),
756
- beforeLoadPromise: void 0
757
- };
758
- });
759
- };
760
- for (const [index, { id: matchId, routeId }] of matches.entries()) {
761
- const existingMatch = this.getMatch(matchId);
762
- const parentMatchId = (_a = matches[index - 1]) == null ? void 0 : _a.id;
763
- const route = this.looseRoutesById[routeId];
764
- const pendingMs = route.options.pendingMs ?? this.options.defaultPendingMs;
765
- const shouldPending = !!(onReady && !this.isServer && !resolvePreload(matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? ((_b = this.options) == null ? void 0 : _b.defaultPendingComponent)));
766
- let executeBeforeLoad = true;
767
- if (
768
- // If we are in the middle of a load, either of these will be present
769
- // (not to be confused with `loadPromise`, which is always defined)
770
- existingMatch.beforeLoadPromise || existingMatch.loaderPromise
771
- ) {
772
- if (shouldPending) {
773
- setTimeout(() => {
774
- try {
775
- triggerOnReady();
776
- } catch {
777
- }
778
- }, pendingMs);
779
- }
780
- await existingMatch.beforeLoadPromise;
781
- executeBeforeLoad = this.getMatch(matchId).status === "error";
782
- }
783
- if (executeBeforeLoad) {
784
- try {
785
- updateMatch(matchId, (prev) => {
786
- const prevLoadPromise = prev.loadPromise;
787
- return {
788
- ...prev,
789
- loadPromise: createControlledPromise(() => {
790
- prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
791
- }),
792
- beforeLoadPromise: createControlledPromise()
793
- };
794
- });
795
- const abortController = new AbortController();
796
- let pendingTimeout;
797
- if (shouldPending) {
798
- pendingTimeout = setTimeout(() => {
799
- try {
800
- triggerOnReady();
801
- } catch {
802
- }
803
- }, pendingMs);
804
- }
805
- const { paramsError, searchError } = this.getMatch(matchId);
806
- if (paramsError) {
807
- handleSerialError(index, paramsError, "PARSE_PARAMS");
808
- }
809
- if (searchError) {
810
- handleSerialError(index, searchError, "VALIDATE_SEARCH");
811
- }
812
- const getParentMatchContext = () => parentMatchId ? this.getMatch(parentMatchId).context : this.options.context ?? {};
813
- updateMatch(matchId, (prev) => ({
814
- ...prev,
815
- isFetching: "beforeLoad",
816
- fetchCount: prev.fetchCount + 1,
817
- abortController,
818
- pendingTimeout,
819
- context: {
820
- ...getParentMatchContext(),
821
- ...prev.__routeContext
822
- }
823
- }));
824
- const { search, params, context, cause } = this.getMatch(matchId);
825
- const preload = resolvePreload(matchId);
826
- const beforeLoadFnContext = {
827
- search,
828
- abortController,
829
- params,
830
- preload,
831
- context,
832
- location,
833
- navigate: (opts) => this.navigate({ ...opts, _fromLocation: location }),
834
- buildLocation: this.buildLocation,
835
- cause: preload ? "preload" : cause,
836
- matches
837
- };
838
- const beforeLoadContext = await ((_d = (_c = route.options).beforeLoad) == null ? void 0 : _d.call(_c, beforeLoadFnContext)) ?? {};
839
- if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {
840
- handleSerialError(index, beforeLoadContext, "BEFORE_LOAD");
841
- }
842
- updateMatch(matchId, (prev) => {
843
- return {
844
- ...prev,
845
- __beforeLoadContext: beforeLoadContext,
846
- context: {
847
- ...getParentMatchContext(),
848
- ...prev.__routeContext,
849
- ...beforeLoadContext
850
- },
851
- abortController
852
- };
853
- });
854
- } catch (err) {
855
- handleSerialError(index, err, "BEFORE_LOAD");
856
- }
857
- updateMatch(matchId, (prev) => {
858
- var _a2;
859
- (_a2 = prev.beforeLoadPromise) == null ? void 0 : _a2.resolve();
860
- return {
861
- ...prev,
862
- beforeLoadPromise: void 0,
863
- isFetching: false
864
- };
865
- });
866
- }
867
- }
868
- const validResolvedMatches = matches.slice(0, firstBadMatchIndex);
869
- const matchPromises = [];
870
- validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
871
- matchPromises.push(
872
- (async () => {
873
- const { loaderPromise: prevLoaderPromise } = this.getMatch(matchId);
874
- let loaderShouldRunAsync = false;
875
- let loaderIsRunningAsync = false;
876
- if (prevLoaderPromise) {
877
- await prevLoaderPromise;
878
- const match = this.getMatch(matchId);
879
- if (match.error) {
880
- handleRedirectAndNotFound(match, match.error);
881
- }
882
- } else {
883
- const parentMatchPromise = matchPromises[index - 1];
884
- const route = this.looseRoutesById[routeId];
885
- const getLoaderContext = () => {
886
- const {
887
- params,
888
- loaderDeps,
889
- abortController,
890
- context,
891
- cause
892
- } = this.getMatch(matchId);
893
- const preload2 = resolvePreload(matchId);
894
- return {
895
- params,
896
- deps: loaderDeps,
897
- preload: !!preload2,
898
- parentMatchPromise,
899
- abortController,
900
- context,
901
- location,
902
- navigate: (opts) => this.navigate({ ...opts, _fromLocation: location }),
903
- cause: preload2 ? "preload" : cause,
904
- route
905
- };
906
- };
907
- const age = Date.now() - this.getMatch(matchId).updatedAt;
908
- const preload = resolvePreload(matchId);
909
- const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
910
- const shouldReloadOption = route.options.shouldReload;
911
- const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext()) : shouldReloadOption;
912
- updateMatch(matchId, (prev) => ({
913
- ...prev,
914
- loaderPromise: createControlledPromise(),
915
- preload: !!preload && !this.state.matches.find((d) => d.id === matchId)
916
- }));
917
- const executeHead = async () => {
918
- var _a2, _b2, _c2, _d2, _e, _f;
919
- const match = this.getMatch(matchId);
920
- if (!match) {
921
- return;
922
- }
923
- const assetContext = {
924
- matches,
925
- match,
926
- params: match.params,
927
- loaderData: match.loaderData
928
- };
929
- const headFnContent = await ((_b2 = (_a2 = route.options).head) == null ? void 0 : _b2.call(_a2, assetContext));
930
- const meta = headFnContent == null ? void 0 : headFnContent.meta;
931
- const links = headFnContent == null ? void 0 : headFnContent.links;
932
- const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
933
- const scripts = await ((_d2 = (_c2 = route.options).scripts) == null ? void 0 : _d2.call(_c2, assetContext));
934
- const headers = await ((_f = (_e = route.options).headers) == null ? void 0 : _f.call(_e, assetContext));
935
- return { meta, links, headScripts, headers, scripts };
936
- };
937
- const runLoader = async () => {
938
- var _a2, _b2, _c2, _d2, _e;
939
- try {
940
- const potentialPendingMinPromise = async () => {
941
- const latestMatch = this.getMatch(matchId);
942
- if (latestMatch.minPendingPromise) {
943
- await latestMatch.minPendingPromise;
944
- }
945
- };
946
- try {
947
- this.loadRouteChunk(route);
948
- updateMatch(matchId, (prev) => ({
949
- ...prev,
950
- isFetching: "loader"
951
- }));
952
- const loaderData = await ((_b2 = (_a2 = route.options).loader) == null ? void 0 : _b2.call(_a2, getLoaderContext()));
953
- handleRedirectAndNotFound(
954
- this.getMatch(matchId),
955
- loaderData
956
- );
957
- await route._lazyPromise;
958
- await potentialPendingMinPromise();
959
- await route._componentsPromise;
960
- updateMatch(matchId, (prev) => ({
961
- ...prev,
962
- error: void 0,
963
- status: "success",
964
- isFetching: false,
965
- updatedAt: Date.now(),
966
- loaderData
967
- }));
968
- const head = await executeHead();
969
- updateMatch(matchId, (prev) => ({
970
- ...prev,
971
- ...head
972
- }));
973
- } catch (e) {
974
- let error = e;
975
- await potentialPendingMinPromise();
976
- handleRedirectAndNotFound(this.getMatch(matchId), e);
977
- try {
978
- (_d2 = (_c2 = route.options).onError) == null ? void 0 : _d2.call(_c2, e);
979
- } catch (onErrorError) {
980
- error = onErrorError;
981
- handleRedirectAndNotFound(
982
- this.getMatch(matchId),
983
- onErrorError
984
- );
985
- }
986
- const head = await executeHead();
987
- updateMatch(matchId, (prev) => ({
988
- ...prev,
989
- error,
990
- status: "error",
991
- isFetching: false,
992
- ...head
993
- }));
994
- }
995
- (_e = this.serverSsr) == null ? void 0 : _e.onMatchSettled({
996
- router: this,
997
- match: this.getMatch(matchId)
998
- });
999
- } catch (err) {
1000
- const head = await executeHead();
1001
- updateMatch(matchId, (prev) => ({
1002
- ...prev,
1003
- loaderPromise: void 0,
1004
- ...head
1005
- }));
1006
- handleRedirectAndNotFound(this.getMatch(matchId), err);
1007
- }
1008
- };
1009
- const { status, invalid } = this.getMatch(matchId);
1010
- loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? age > staleAge));
1011
- if (preload && route.options.preload === false) {
1012
- } else if (loaderShouldRunAsync && !sync) {
1013
- loaderIsRunningAsync = true;
1014
- (async () => {
1015
- try {
1016
- await runLoader();
1017
- const { loaderPromise, loadPromise } = this.getMatch(matchId);
1018
- loaderPromise == null ? void 0 : loaderPromise.resolve();
1019
- loadPromise == null ? void 0 : loadPromise.resolve();
1020
- updateMatch(matchId, (prev) => ({
1021
- ...prev,
1022
- loaderPromise: void 0
1023
- }));
1024
- } catch (err) {
1025
- if (isRedirect(err)) {
1026
- await this.navigate(err.options);
1027
- }
1028
- }
1029
- })();
1030
- } else if (status !== "success" || loaderShouldRunAsync && sync) {
1031
- await runLoader();
1032
- } else {
1033
- const head = await executeHead();
1034
- updateMatch(matchId, (prev) => ({
1035
- ...prev,
1036
- ...head
1037
- }));
1038
- }
1039
- }
1040
- if (!loaderIsRunningAsync) {
1041
- const { loaderPromise, loadPromise } = this.getMatch(matchId);
1042
- loaderPromise == null ? void 0 : loaderPromise.resolve();
1043
- loadPromise == null ? void 0 : loadPromise.resolve();
1044
- }
1045
- updateMatch(matchId, (prev) => ({
1046
- ...prev,
1047
- isFetching: loaderIsRunningAsync ? prev.isFetching : false,
1048
- loaderPromise: loaderIsRunningAsync ? prev.loaderPromise : void 0,
1049
- invalid: false
1050
- }));
1051
- return this.getMatch(matchId);
1052
- })()
1053
- );
1054
- });
1055
- await Promise.all(matchPromises);
1056
- resolveAll();
1057
- } catch (err) {
1058
- rejectAll(err);
1059
- }
1060
- })();
1061
- });
1062
- await triggerOnReady();
1063
- } catch (err) {
1064
- if (isRedirect(err) || isNotFound(err)) {
1065
- if (isNotFound(err) && !allPreload) {
1066
- await triggerOnReady();
1067
- }
1068
- throw err;
1069
- }
1070
- }
1071
- return matches;
1072
- };
1073
- this.invalidate = (opts) => {
1074
- const invalidate = (d) => {
1075
- var _a;
1076
- if (((_a = opts == null ? void 0 : opts.filter) == null ? void 0 : _a.call(opts, d)) ?? true) {
1077
- return {
1078
- ...d,
1079
- invalid: true,
1080
- ...d.status === "error" ? { status: "pending", error: void 0 } : {}
1081
- };
1082
- }
1083
- return d;
1084
- };
1085
- this.__store.setState((s) => {
1086
- var _a;
1087
- return {
1088
- ...s,
1089
- matches: s.matches.map(invalidate),
1090
- cachedMatches: s.cachedMatches.map(invalidate),
1091
- pendingMatches: (_a = s.pendingMatches) == null ? void 0 : _a.map(invalidate)
1092
- };
1093
- });
1094
- this.shouldViewTransition = false;
1095
- return this.load({ sync: opts == null ? void 0 : opts.sync });
1096
- };
1097
- this.resolveRedirect = (redirect) => {
1098
- if (!redirect.options.href) {
1099
- redirect.options.href = this.buildLocation(redirect.options).href;
1100
- redirect.headers.set("Location", redirect.options.href);
1101
- }
1102
- if (!redirect.headers.get("Location")) {
1103
- redirect.headers.set("Location", redirect.options.href);
1104
- }
1105
- return redirect;
1106
- };
1107
- this.clearCache = (opts) => {
1108
- const filter = opts == null ? void 0 : opts.filter;
1109
- if (filter !== void 0) {
1110
- this.__store.setState((s) => {
1111
- return {
1112
- ...s,
1113
- cachedMatches: s.cachedMatches.filter(
1114
- (m) => !filter(m)
1115
- )
1116
- };
1117
- });
1118
- } else {
1119
- this.__store.setState((s) => {
1120
- return {
1121
- ...s,
1122
- cachedMatches: []
1123
- };
1124
- });
1125
- }
1126
- };
1127
- this.clearExpiredCache = () => {
1128
- const filter = (d) => {
1129
- const route = this.looseRoutesById[d.routeId];
1130
- if (!route.options.loader) {
1131
- return true;
1132
- }
1133
- const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
1134
- return !(d.status !== "error" && Date.now() - d.updatedAt < gcTime);
1135
- };
1136
- this.clearCache({ filter });
1137
- };
1138
- this.loadRouteChunk = (route) => {
1139
- if (route._lazyPromise === void 0) {
1140
- if (route.lazyFn) {
1141
- route._lazyPromise = route.lazyFn().then((lazyRoute) => {
1142
- const { id: _id, ...options2 } = lazyRoute.options;
1143
- Object.assign(route.options, options2);
1144
- });
1145
- } else {
1146
- route._lazyPromise = Promise.resolve();
1147
- }
1148
- }
1149
- if (route._componentsPromise === void 0) {
1150
- route._componentsPromise = route._lazyPromise.then(
1151
- () => Promise.all(
1152
- componentTypes.map(async (type) => {
1153
- const component = route.options[type];
1154
- if (component == null ? void 0 : component.preload) {
1155
- await component.preload();
1156
- }
1157
- })
1158
- )
1159
- );
1160
- }
1161
- return route._componentsPromise;
1162
- };
1163
- this.preloadRoute = async (opts) => {
1164
- const next = this.buildLocation(opts);
1165
- let matches = this.matchRoutes(next, {
1166
- throwOnError: true,
1167
- preload: true,
1168
- dest: opts
1169
- });
1170
- const activeMatchIds = new Set(
1171
- [...this.state.matches, ...this.state.pendingMatches ?? []].map(
1172
- (d) => d.id
1173
- )
1174
- );
1175
- const loadedMatchIds = /* @__PURE__ */ new Set([
1176
- ...activeMatchIds,
1177
- ...this.state.cachedMatches.map((d) => d.id)
1178
- ]);
1179
- batch(() => {
1180
- matches.forEach((match) => {
1181
- if (!loadedMatchIds.has(match.id)) {
1182
- this.__store.setState((s) => ({
1183
- ...s,
1184
- cachedMatches: [...s.cachedMatches, match]
1185
- }));
1186
- }
1187
- });
1188
- });
1189
- try {
1190
- matches = await this.loadMatches({
1191
- matches,
1192
- location: next,
1193
- preload: true,
1194
- updateMatch: (id, updater) => {
1195
- if (activeMatchIds.has(id)) {
1196
- matches = matches.map((d) => d.id === id ? updater(d) : d);
1197
- } else {
1198
- this.updateMatch(id, updater);
1199
- }
1200
- }
1201
- });
1202
- return matches;
1203
- } catch (err) {
1204
- if (isRedirect(err)) {
1205
- if (err.options.reloadDocument) {
1206
- return void 0;
1207
- }
1208
- return await this.preloadRoute({
1209
- ...err.options,
1210
- _fromLocation: next
1211
- });
1212
- }
1213
- if (!isNotFound(err)) {
1214
- console.error(err);
1215
- }
1216
- return void 0;
1217
- }
1218
- };
1219
- this.matchRoute = (location, opts) => {
1220
- const matchLocation = {
1221
- ...location,
1222
- to: location.to ? this.resolvePathWithBase(
1223
- location.from || "",
1224
- location.to
1225
- ) : void 0,
1226
- params: location.params || {},
1227
- leaveParams: true
1228
- };
1229
- const next = this.buildLocation(matchLocation);
1230
- if ((opts == null ? void 0 : opts.pending) && this.state.status !== "pending") {
1231
- return false;
1232
- }
1233
- const pending = (opts == null ? void 0 : opts.pending) === void 0 ? !this.state.isLoading : opts.pending;
1234
- const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
1235
- const match = matchPathname(this.basepath, baseLocation.pathname, {
1236
- ...opts,
1237
- to: next.pathname
1238
- });
1239
- if (!match) {
1240
- return false;
1241
- }
1242
- if (location.params) {
1243
- if (!deepEqual(match, location.params, { partial: true })) {
1244
- return false;
1245
- }
1246
- }
1247
- if (match && ((opts == null ? void 0 : opts.includeSearch) ?? true)) {
1248
- return deepEqual(baseLocation.search, next.search, { partial: true }) ? match : false;
1249
- }
1250
- return match;
1251
- };
1252
- this._handleNotFound = (matches, err, {
1253
- updateMatch = this.updateMatch
1254
- } = {}) => {
1255
- var _a;
1256
- const routeCursor = this.routesById[err.routeId ?? ""] ?? this.routeTree;
1257
- const matchesByRouteId = {};
1258
- for (const match of matches) {
1259
- matchesByRouteId[match.routeId] = match;
1260
- }
1261
- if (!routeCursor.options.notFoundComponent && ((_a = this.options) == null ? void 0 : _a.defaultNotFoundComponent)) {
1262
- routeCursor.options.notFoundComponent = this.options.defaultNotFoundComponent;
1263
- }
1264
- invariant(
1265
- routeCursor.options.notFoundComponent,
1266
- "No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router."
1267
- );
1268
- const matchForRoute = matchesByRouteId[routeCursor.id];
1269
- invariant(
1270
- matchForRoute,
1271
- "Could not find match for route: " + routeCursor.id
1272
- );
1273
- updateMatch(matchForRoute.id, (prev) => ({
1274
- ...prev,
1275
- status: "notFound",
1276
- error: err,
1277
- isFetching: false
1278
- }));
1279
- if (err.routerCode === "BEFORE_LOAD" && routeCursor.parentRoute) {
1280
- err.routeId = routeCursor.parentRoute.id;
1281
- this._handleNotFound(matches, err, {
1282
- updateMatch
1283
- });
1284
- }
1285
- };
1286
- this.hasNotFoundMatch = () => {
1287
- return this.__store.state.matches.some(
1288
- (d) => d.status === "notFound" || d.globalNotFound
1289
- );
1290
- };
1291
- this.update({
1292
- defaultPreloadDelay: 50,
1293
- defaultPendingMs: 1e3,
1294
- defaultPendingMinMs: 500,
1295
- context: void 0,
1296
- ...options,
1297
- caseSensitive: options.caseSensitive ?? false,
1298
- notFoundMode: options.notFoundMode ?? "fuzzy",
1299
- stringifySearch: options.stringifySearch ?? defaultStringifySearch,
1300
- parseSearch: options.parseSearch ?? defaultParseSearch
1301
- });
1302
- if (typeof document !== "undefined") {
1303
- window.__TSR_ROUTER__ = this;
1304
- }
1305
- }
1306
- get state() {
1307
- return this.__store.state;
1308
- }
1309
- get looseRoutesById() {
1310
- return this.routesById;
1311
- }
1312
- matchRoutesInternal(next, opts) {
1313
- var _a;
1314
- const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
1315
- next.pathname,
1316
- (_a = opts == null ? void 0 : opts.dest) == null ? void 0 : _a.to
1317
- );
1318
- let isGlobalNotFound = false;
1319
- if (
1320
- // If we found a route, and it's not an index route and we have left over path
1321
- foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
1322
- // Or if we didn't find a route and we have left over path
1323
- trimPathRight(next.pathname)
1324
- )
1325
- ) {
1326
- if (this.options.notFoundRoute) {
1327
- matchedRoutes.push(this.options.notFoundRoute);
1328
- } else {
1329
- isGlobalNotFound = true;
1330
- }
1331
- }
1332
- const globalNotFoundRouteId = (() => {
1333
- if (!isGlobalNotFound) {
1334
- return void 0;
1335
- }
1336
- if (this.options.notFoundMode !== "root") {
1337
- for (let i = matchedRoutes.length - 1; i >= 0; i--) {
1338
- const route = matchedRoutes[i];
1339
- if (route.children) {
1340
- return route.id;
1341
- }
1342
- }
1343
- }
1344
- return rootRouteId;
1345
- })();
1346
- const parseErrors = matchedRoutes.map((route) => {
1347
- var _a2;
1348
- let parsedParamsError;
1349
- const parseParams = ((_a2 = route.options.params) == null ? void 0 : _a2.parse) ?? route.options.parseParams;
1350
- if (parseParams) {
1351
- try {
1352
- const parsedParams = parseParams(routeParams);
1353
- Object.assign(routeParams, parsedParams);
1354
- } catch (err) {
1355
- parsedParamsError = new PathParamError(err.message, {
1356
- cause: err
1357
- });
1358
- if (opts == null ? void 0 : opts.throwOnError) {
1359
- throw parsedParamsError;
1360
- }
1361
- return parsedParamsError;
1362
- }
1363
- }
1364
- return;
1365
- });
1366
- const matches = [];
1367
- const getParentContext = (parentMatch) => {
1368
- const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
1369
- const parentContext = !parentMatchId ? this.options.context ?? {} : parentMatch.context ?? this.options.context ?? {};
1370
- return parentContext;
1371
- };
1372
- matchedRoutes.forEach((route, index) => {
1373
- var _a2, _b;
1374
- const parentMatch = matches[index - 1];
1375
- const [preMatchSearch, strictMatchSearch, searchError] = (() => {
1376
- const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
1377
- const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? {};
1378
- try {
1379
- const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? {};
1380
- return [
1381
- {
1382
- ...parentSearch,
1383
- ...strictSearch
1384
- },
1385
- { ...parentStrictSearch, ...strictSearch },
1386
- void 0
1387
- ];
1388
- } catch (err) {
1389
- let searchParamError = err;
1390
- if (!(err instanceof SearchParamError)) {
1391
- searchParamError = new SearchParamError(err.message, {
1392
- cause: err
1393
- });
1394
- }
1395
- if (opts == null ? void 0 : opts.throwOnError) {
1396
- throw searchParamError;
1397
- }
1398
- return [parentSearch, {}, searchParamError];
1399
- }
1400
- })();
1401
- const loaderDeps = ((_b = (_a2 = route.options).loaderDeps) == null ? void 0 : _b.call(_a2, {
1402
- search: preMatchSearch
1403
- })) ?? "";
1404
- const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
1405
- const { usedParams, interpolatedPath } = interpolatePath({
1406
- path: route.fullPath,
1407
- params: routeParams,
1408
- decodeCharMap: this.pathParamsDecodeCharMap
1409
- });
1410
- const matchId = interpolatePath({
1411
- path: route.id,
1412
- params: routeParams,
1413
- leaveWildcards: true,
1414
- decodeCharMap: this.pathParamsDecodeCharMap
1415
- }).interpolatedPath + loaderDepsHash;
1416
- const existingMatch = this.getMatch(matchId);
1417
- const previousMatch = this.state.matches.find(
1418
- (d) => d.routeId === route.id
1419
- );
1420
- const cause = previousMatch ? "stay" : "enter";
1421
- let match;
1422
- if (existingMatch) {
1423
- match = {
1424
- ...existingMatch,
1425
- cause,
1426
- params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1427
- _strictParams: usedParams,
1428
- search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
1429
- _strictSearch: strictMatchSearch
1430
- };
1431
- } else {
1432
- const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
1433
- match = {
1434
- id: matchId,
1435
- index,
1436
- routeId: route.id,
1437
- params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1438
- _strictParams: usedParams,
1439
- pathname: joinPaths([this.basepath, interpolatedPath]),
1440
- updatedAt: Date.now(),
1441
- search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
1442
- _strictSearch: strictMatchSearch,
1443
- searchError: void 0,
1444
- status,
1445
- isFetching: false,
1446
- error: void 0,
1447
- paramsError: parseErrors[index],
1448
- __routeContext: {},
1449
- __beforeLoadContext: {},
1450
- context: {},
1451
- abortController: new AbortController(),
1452
- fetchCount: 0,
1453
- cause,
1454
- loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
1455
- invalid: false,
1456
- preload: false,
1457
- links: void 0,
1458
- scripts: void 0,
1459
- headScripts: void 0,
1460
- meta: void 0,
1461
- staticData: route.options.staticData || {},
1462
- loadPromise: createControlledPromise(),
1463
- fullPath: route.fullPath
1464
- };
1465
- }
1466
- if (!(opts == null ? void 0 : opts.preload)) {
1467
- match.globalNotFound = globalNotFoundRouteId === route.id;
1468
- }
1469
- match.searchError = searchError;
1470
- const parentContext = getParentContext(parentMatch);
1471
- match.context = {
1472
- ...parentContext,
1473
- ...match.__routeContext,
1474
- ...match.__beforeLoadContext
1475
- };
1476
- matches.push(match);
1477
- });
1478
- matches.forEach((match, index) => {
1479
- var _a2, _b;
1480
- const route = this.looseRoutesById[match.routeId];
1481
- const existingMatch = this.getMatch(match.id);
1482
- if (!existingMatch && (opts == null ? void 0 : opts._buildLocation) !== true) {
1483
- const parentMatch = matches[index - 1];
1484
- const parentContext = getParentContext(parentMatch);
1485
- const contextFnContext = {
1486
- deps: match.loaderDeps,
1487
- params: match.params,
1488
- context: parentContext,
1489
- location: next,
1490
- navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
1491
- buildLocation: this.buildLocation,
1492
- cause: match.cause,
1493
- abortController: match.abortController,
1494
- preload: !!match.preload,
1495
- matches
1496
- };
1497
- match.__routeContext = ((_b = (_a2 = route.options).context) == null ? void 0 : _b.call(_a2, contextFnContext)) ?? {};
1498
- match.context = {
1499
- ...parentContext,
1500
- ...match.__routeContext,
1501
- ...match.__beforeLoadContext
1502
- };
1503
- }
1504
- });
1505
- return matches;
1506
- }
1507
- }
1508
- class SearchParamError extends Error {
1509
- }
1510
- class PathParamError extends Error {
1511
- }
1512
- function lazyFn(fn, key) {
1513
- return async (...args) => {
1514
- const imported = await fn();
1515
- return imported[key || "default"](...args);
1516
- };
1517
- }
1518
- function getInitialRouterState(location) {
1519
- return {
1520
- loadedAt: 0,
1521
- isLoading: false,
1522
- isTransitioning: false,
1523
- status: "idle",
1524
- resolvedLocation: void 0,
1525
- location,
1526
- matches: [],
1527
- pendingMatches: [],
1528
- cachedMatches: [],
1529
- statusCode: 200
1530
- };
1531
- }
1532
- function validateSearch(validateSearch2, input) {
1533
- if (validateSearch2 == null) return {};
1534
- if ("~standard" in validateSearch2) {
1535
- const result = validateSearch2["~standard"].validate(input);
1536
- if (result instanceof Promise)
1537
- throw new SearchParamError("Async validation not supported");
1538
- if (result.issues)
1539
- throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), {
1540
- cause: result
1541
- });
1542
- return result.value;
1543
- }
1544
- if ("parse" in validateSearch2) {
1545
- return validateSearch2.parse(input);
1546
- }
1547
- if (typeof validateSearch2 === "function") {
1548
- return validateSearch2(input);
1549
- }
1550
- return {};
1551
- }
1552
- const componentTypes = [
1553
- "component",
1554
- "errorComponent",
1555
- "pendingComponent",
1556
- "notFoundComponent"
1557
- ];
1558
- function routeNeedsPreload(route) {
1559
- var _a;
1560
- for (const componentType of componentTypes) {
1561
- if ((_a = route.options[componentType]) == null ? void 0 : _a.preload) {
1562
- return true;
1563
- }
1564
- }
1565
- return false;
1566
- }
1567
- function processRouteTree({
1568
- routeTree,
1569
- initRoute
1570
- }) {
1571
- const routesById = {};
1572
- const routesByPath = {};
1573
- const recurseRoutes = (childRoutes) => {
1574
- childRoutes.forEach((childRoute, i) => {
1575
- initRoute == null ? void 0 : initRoute(childRoute, i);
1576
- const existingRoute = routesById[childRoute.id];
1577
- invariant(
1578
- !existingRoute,
1579
- `Duplicate routes found with id: ${String(childRoute.id)}`
1580
- );
1581
- routesById[childRoute.id] = childRoute;
1582
- if (!childRoute.isRoot && childRoute.path) {
1583
- const trimmedFullPath = trimPathRight(childRoute.fullPath);
1584
- if (!routesByPath[trimmedFullPath] || childRoute.fullPath.endsWith("/")) {
1585
- routesByPath[trimmedFullPath] = childRoute;
1586
- }
1587
- }
1588
- const children = childRoute.children;
1589
- if (children == null ? void 0 : children.length) {
1590
- recurseRoutes(children);
1591
- }
1592
- });
1593
- };
1594
- recurseRoutes([routeTree]);
1595
- const scoredRoutes = [];
1596
- const routes = Object.values(routesById);
1597
- routes.forEach((d, i) => {
1598
- var _a;
1599
- if (d.isRoot || !d.path) {
1600
- return;
1601
- }
1602
- const trimmed = trimPathLeft(d.fullPath);
1603
- const parsed = parsePathname(trimmed);
1604
- while (parsed.length > 1 && ((_a = parsed[0]) == null ? void 0 : _a.value) === "/") {
1605
- parsed.shift();
1606
- }
1607
- const scores = parsed.map((segment) => {
1608
- if (segment.value === "/") {
1609
- return 0.75;
1610
- }
1611
- if (segment.type === "param" && segment.prefixSegment && segment.suffixSegment) {
1612
- return 0.55;
1613
- }
1614
- if (segment.type === "param" && segment.prefixSegment) {
1615
- return 0.52;
1616
- }
1617
- if (segment.type === "param" && segment.suffixSegment) {
1618
- return 0.51;
1619
- }
1620
- if (segment.type === "param") {
1621
- return 0.5;
1622
- }
1623
- if (segment.type === "wildcard" && segment.prefixSegment && segment.suffixSegment) {
1624
- return 0.3;
1625
- }
1626
- if (segment.type === "wildcard" && segment.prefixSegment) {
1627
- return 0.27;
1628
- }
1629
- if (segment.type === "wildcard" && segment.suffixSegment) {
1630
- return 0.26;
1631
- }
1632
- if (segment.type === "wildcard") {
1633
- return 0.25;
1634
- }
1635
- return 1;
1636
- });
1637
- scoredRoutes.push({ child: d, trimmed, parsed, index: i, scores });
1638
- });
1639
- const flatRoutes = scoredRoutes.sort((a, b) => {
1640
- const minLength = Math.min(a.scores.length, b.scores.length);
1641
- for (let i = 0; i < minLength; i++) {
1642
- if (a.scores[i] !== b.scores[i]) {
1643
- return b.scores[i] - a.scores[i];
1644
- }
1645
- }
1646
- if (a.scores.length !== b.scores.length) {
1647
- return b.scores.length - a.scores.length;
1648
- }
1649
- for (let i = 0; i < minLength; i++) {
1650
- if (a.parsed[i].value !== b.parsed[i].value) {
1651
- return a.parsed[i].value > b.parsed[i].value ? 1 : -1;
1652
- }
1653
- }
1654
- return a.index - b.index;
1655
- }).map((d, i) => {
1656
- d.child.rank = i;
1657
- return d.child;
1658
- });
1659
- return { routesById, routesByPath, flatRoutes };
1660
- }
1661
- function getMatchedRoutes({
1662
- pathname,
1663
- routePathname,
1664
- basepath,
1665
- caseSensitive,
1666
- routesByPath,
1667
- routesById,
1668
- flatRoutes
1669
- }) {
1670
- let routeParams = {};
1671
- const trimmedPath = trimPathRight(pathname);
1672
- const getMatchedParams = (route) => {
1673
- var _a;
1674
- const result = matchPathname(basepath, trimmedPath, {
1675
- to: route.fullPath,
1676
- caseSensitive: ((_a = route.options) == null ? void 0 : _a.caseSensitive) ?? caseSensitive,
1677
- fuzzy: true
1678
- });
1679
- return result;
1680
- };
1681
- let foundRoute = routePathname !== void 0 ? routesByPath[routePathname] : void 0;
1682
- if (foundRoute) {
1683
- routeParams = getMatchedParams(foundRoute);
1684
- } else {
1685
- foundRoute = flatRoutes.find((route) => {
1686
- const matchedParams = getMatchedParams(route);
1687
- if (matchedParams) {
1688
- routeParams = matchedParams;
1689
- return true;
1690
- }
1691
- return false;
1692
- });
1693
- }
1694
- let routeCursor = foundRoute || routesById[rootRouteId];
1695
- const matchedRoutes = [routeCursor];
1696
- while (routeCursor.parentRoute) {
1697
- routeCursor = routeCursor.parentRoute;
1698
- matchedRoutes.unshift(routeCursor);
1699
- }
1700
- return { matchedRoutes, routeParams, foundRoute };
1701
- }
1702
- function applySearchMiddleware({
1703
- search,
1704
- dest,
1705
- destRoutes,
1706
- _includeValidateSearch
1707
- }) {
1708
- const allMiddlewares = destRoutes.reduce(
1709
- (acc, route) => {
1710
- var _a;
1711
- const middlewares = [];
1712
- if ("search" in route.options) {
1713
- if ((_a = route.options.search) == null ? void 0 : _a.middlewares) {
1714
- middlewares.push(...route.options.search.middlewares);
1715
- }
1716
- } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
1717
- const legacyMiddleware = ({
1718
- search: search2,
1719
- next
1720
- }) => {
1721
- let nextSearch = search2;
1722
- if ("preSearchFilters" in route.options && route.options.preSearchFilters) {
1723
- nextSearch = route.options.preSearchFilters.reduce(
1724
- (prev, next2) => next2(prev),
1725
- search2
1726
- );
1727
- }
1728
- const result = next(nextSearch);
1729
- if ("postSearchFilters" in route.options && route.options.postSearchFilters) {
1730
- return route.options.postSearchFilters.reduce(
1731
- (prev, next2) => next2(prev),
1732
- result
1733
- );
1734
- }
1735
- return result;
1736
- };
1737
- middlewares.push(legacyMiddleware);
1738
- }
1739
- if (_includeValidateSearch && route.options.validateSearch) {
1740
- const validate = ({ search: search2, next }) => {
1741
- const result = next(search2);
1742
- try {
1743
- const validatedSearch = {
1744
- ...result,
1745
- ...validateSearch(route.options.validateSearch, result) ?? {}
1746
- };
1747
- return validatedSearch;
1748
- } catch {
1749
- return result;
1750
- }
1751
- };
1752
- middlewares.push(validate);
1753
- }
1754
- return acc.concat(middlewares);
1755
- },
1756
- []
1757
- ) ?? [];
1758
- const final = ({ search: search2 }) => {
1759
- if (!dest.search) {
1760
- return {};
1761
- }
1762
- if (dest.search === true) {
1763
- return search2;
1764
- }
1765
- return functionalUpdate(dest.search, search2);
1766
- };
1767
- allMiddlewares.push(final);
1768
- const applyNext = (index, currentSearch) => {
1769
- if (index >= allMiddlewares.length) {
1770
- return currentSearch;
1771
- }
1772
- const middleware = allMiddlewares[index];
1773
- const next = (newSearch) => {
1774
- return applyNext(index + 1, newSearch);
1775
- };
1776
- return middleware({ search: currentSearch, next });
1777
- };
1778
- return applyNext(0, search);
1779
- }
1780
- export {
1781
- PathParamError,
1782
- RouterCore,
1783
- SearchParamError,
1784
- componentTypes,
1785
- defaultSerializeError,
1786
- getInitialRouterState,
1787
- getLocationChangeInfo,
1788
- getMatchedRoutes,
1789
- lazyFn,
1790
- processRouteTree
1791
- };
1792
- //# sourceMappingURL=router.js.map