@tanstack/router-core 1.167.1 → 1.167.3

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 (164) hide show
  1. package/dist/cjs/Matches.cjs +15 -12
  2. package/dist/cjs/Matches.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/dist/cjs/config.cjs +9 -8
  5. package/dist/cjs/config.cjs.map +1 -1
  6. package/dist/cjs/defer.cjs +37 -21
  7. package/dist/cjs/defer.cjs.map +1 -1
  8. package/dist/cjs/index.cjs +87 -89
  9. package/dist/cjs/isServer/client.cjs +5 -3
  10. package/dist/cjs/isServer/client.cjs.map +1 -1
  11. package/dist/cjs/isServer/development.cjs +5 -3
  12. package/dist/cjs/isServer/development.cjs.map +1 -1
  13. package/dist/cjs/isServer/server.cjs +5 -3
  14. package/dist/cjs/isServer/server.cjs.map +1 -1
  15. package/dist/cjs/link.cjs +5 -4
  16. package/dist/cjs/link.cjs.map +1 -1
  17. package/dist/cjs/load-matches.cjs +622 -766
  18. package/dist/cjs/load-matches.cjs.map +1 -1
  19. package/dist/cjs/lru-cache.cjs +67 -64
  20. package/dist/cjs/lru-cache.cjs.map +1 -1
  21. package/dist/cjs/new-process-route-tree.cjs +707 -792
  22. package/dist/cjs/new-process-route-tree.cjs.map +1 -1
  23. package/dist/cjs/not-found.cjs +20 -7
  24. package/dist/cjs/not-found.cjs.map +1 -1
  25. package/dist/cjs/path.cjs +221 -232
  26. package/dist/cjs/path.cjs.map +1 -1
  27. package/dist/cjs/qss.cjs +62 -28
  28. package/dist/cjs/qss.cjs.map +1 -1
  29. package/dist/cjs/redirect.cjs +44 -30
  30. package/dist/cjs/redirect.cjs.map +1 -1
  31. package/dist/cjs/rewrite.cjs +56 -56
  32. package/dist/cjs/rewrite.cjs.map +1 -1
  33. package/dist/cjs/root.cjs +6 -4
  34. package/dist/cjs/root.cjs.map +1 -1
  35. package/dist/cjs/route.cjs +96 -105
  36. package/dist/cjs/route.cjs.map +1 -1
  37. package/dist/cjs/router.cjs +1154 -1524
  38. package/dist/cjs/router.cjs.map +1 -1
  39. package/dist/cjs/scroll-restoration.cjs +189 -207
  40. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  41. package/dist/cjs/searchMiddleware.cjs +48 -37
  42. package/dist/cjs/searchMiddleware.cjs.map +1 -1
  43. package/dist/cjs/searchParams.cjs +57 -45
  44. package/dist/cjs/searchParams.cjs.map +1 -1
  45. package/dist/cjs/ssr/client.cjs +6 -8
  46. package/dist/cjs/ssr/constants.cjs +6 -5
  47. package/dist/cjs/ssr/constants.cjs.map +1 -1
  48. package/dist/cjs/ssr/createRequestHandler.cjs +41 -59
  49. package/dist/cjs/ssr/createRequestHandler.cjs.map +1 -1
  50. package/dist/cjs/ssr/handlerCallback.cjs +5 -4
  51. package/dist/cjs/ssr/handlerCallback.cjs.map +1 -1
  52. package/dist/cjs/ssr/headers.cjs +17 -26
  53. package/dist/cjs/ssr/headers.cjs.map +1 -1
  54. package/dist/cjs/ssr/json.cjs +8 -4
  55. package/dist/cjs/ssr/json.cjs.map +1 -1
  56. package/dist/cjs/ssr/serializer/RawStream.cjs +268 -268
  57. package/dist/cjs/ssr/serializer/RawStream.cjs.map +1 -1
  58. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs +31 -32
  59. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs.map +1 -1
  60. package/dist/cjs/ssr/serializer/seroval-plugins.cjs +12 -12
  61. package/dist/cjs/ssr/serializer/seroval-plugins.cjs.map +1 -1
  62. package/dist/cjs/ssr/serializer/transformer.cjs +45 -41
  63. package/dist/cjs/ssr/serializer/transformer.cjs.map +1 -1
  64. package/dist/cjs/ssr/server.cjs +12 -14
  65. package/dist/cjs/ssr/ssr-client.cjs +173 -211
  66. package/dist/cjs/ssr/ssr-client.cjs.map +1 -1
  67. package/dist/cjs/ssr/ssr-match-id.cjs +6 -5
  68. package/dist/cjs/ssr/ssr-match-id.cjs.map +1 -1
  69. package/dist/cjs/ssr/ssr-server.cjs +266 -300
  70. package/dist/cjs/ssr/ssr-server.cjs.map +1 -1
  71. package/dist/cjs/ssr/transformStreamWithRouter.cjs +317 -337
  72. package/dist/cjs/ssr/transformStreamWithRouter.cjs.map +1 -1
  73. package/dist/cjs/ssr/tsrScript.cjs +6 -4
  74. package/dist/cjs/ssr/tsrScript.cjs.map +1 -1
  75. package/dist/cjs/utils/batch.cjs +13 -13
  76. package/dist/cjs/utils/batch.cjs.map +1 -1
  77. package/dist/cjs/utils.cjs +274 -208
  78. package/dist/cjs/utils.cjs.map +1 -1
  79. package/dist/esm/Matches.js +16 -13
  80. package/dist/esm/Matches.js.map +1 -1
  81. package/dist/esm/config.js +10 -9
  82. package/dist/esm/config.js.map +1 -1
  83. package/dist/esm/defer.js +37 -22
  84. package/dist/esm/defer.js.map +1 -1
  85. package/dist/esm/index.js +12 -82
  86. package/dist/esm/isServer/client.js +6 -5
  87. package/dist/esm/isServer/client.js.map +1 -1
  88. package/dist/esm/isServer/development.js +6 -5
  89. package/dist/esm/isServer/development.js.map +1 -1
  90. package/dist/esm/isServer/server.js +6 -5
  91. package/dist/esm/isServer/server.js.map +1 -1
  92. package/dist/esm/link.js +6 -5
  93. package/dist/esm/link.js.map +1 -1
  94. package/dist/esm/load-matches.js +617 -765
  95. package/dist/esm/load-matches.js.map +1 -1
  96. package/dist/esm/lru-cache.js +68 -65
  97. package/dist/esm/lru-cache.js.map +1 -1
  98. package/dist/esm/new-process-route-tree.js +705 -797
  99. package/dist/esm/new-process-route-tree.js.map +1 -1
  100. package/dist/esm/not-found.js +21 -9
  101. package/dist/esm/not-found.js.map +1 -1
  102. package/dist/esm/path.js +220 -241
  103. package/dist/esm/path.js.map +1 -1
  104. package/dist/esm/qss.js +63 -30
  105. package/dist/esm/qss.js.map +1 -1
  106. package/dist/esm/redirect.js +45 -34
  107. package/dist/esm/redirect.js.map +1 -1
  108. package/dist/esm/rewrite.js +57 -60
  109. package/dist/esm/rewrite.js.map +1 -1
  110. package/dist/esm/root.js +7 -5
  111. package/dist/esm/root.js.map +1 -1
  112. package/dist/esm/route.js +92 -105
  113. package/dist/esm/route.js.map +1 -1
  114. package/dist/esm/router.js +1148 -1527
  115. package/dist/esm/router.js.map +1 -1
  116. package/dist/esm/scroll-restoration.js +188 -213
  117. package/dist/esm/scroll-restoration.js.map +1 -1
  118. package/dist/esm/searchMiddleware.js +48 -38
  119. package/dist/esm/searchMiddleware.js.map +1 -1
  120. package/dist/esm/searchParams.js +57 -48
  121. package/dist/esm/searchParams.js.map +1 -1
  122. package/dist/esm/ssr/client.js +1 -6
  123. package/dist/esm/ssr/constants.js +7 -7
  124. package/dist/esm/ssr/constants.js.map +1 -1
  125. package/dist/esm/ssr/createRequestHandler.js +39 -58
  126. package/dist/esm/ssr/createRequestHandler.js.map +1 -1
  127. package/dist/esm/ssr/handlerCallback.js +6 -5
  128. package/dist/esm/ssr/handlerCallback.js.map +1 -1
  129. package/dist/esm/ssr/headers.js +16 -26
  130. package/dist/esm/ssr/headers.js.map +1 -1
  131. package/dist/esm/ssr/json.js +9 -5
  132. package/dist/esm/ssr/json.js.map +1 -1
  133. package/dist/esm/ssr/serializer/RawStream.js +267 -273
  134. package/dist/esm/ssr/serializer/RawStream.js.map +1 -1
  135. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js +31 -32
  136. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js.map +1 -1
  137. package/dist/esm/ssr/serializer/seroval-plugins.js +10 -11
  138. package/dist/esm/ssr/serializer/seroval-plugins.js.map +1 -1
  139. package/dist/esm/ssr/serializer/transformer.js +44 -43
  140. package/dist/esm/ssr/serializer/transformer.js.map +1 -1
  141. package/dist/esm/ssr/server.js +2 -12
  142. package/dist/esm/ssr/ssr-client.js +169 -209
  143. package/dist/esm/ssr/ssr-client.js.map +1 -1
  144. package/dist/esm/ssr/ssr-match-id.js +7 -7
  145. package/dist/esm/ssr/ssr-match-id.js.map +1 -1
  146. package/dist/esm/ssr/ssr-server.js +262 -300
  147. package/dist/esm/ssr/ssr-server.js.map +1 -1
  148. package/dist/esm/ssr/transformStreamWithRouter.js +315 -338
  149. package/dist/esm/ssr/transformStreamWithRouter.js.map +1 -1
  150. package/dist/esm/ssr/tsrScript.js +6 -5
  151. package/dist/esm/ssr/tsrScript.js.map +1 -1
  152. package/dist/esm/utils/batch.js +13 -14
  153. package/dist/esm/utils/batch.js.map +1 -1
  154. package/dist/esm/utils.js +273 -224
  155. package/dist/esm/utils.js.map +1 -1
  156. package/package.json +2 -2
  157. package/src/load-matches.ts +4 -1
  158. package/src/router.ts +2 -1
  159. package/dist/cjs/index.cjs.map +0 -1
  160. package/dist/cjs/ssr/client.cjs.map +0 -1
  161. package/dist/cjs/ssr/server.cjs.map +0 -1
  162. package/dist/esm/index.js.map +0 -1
  163. package/dist/esm/ssr/client.js.map +0 -1
  164. package/dist/esm/ssr/server.js.map +0 -1
@@ -1,797 +1,653 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const invariant = require("tiny-invariant");
4
- const isServer = require("@tanstack/router-core/isServer");
5
- const batch = require("./utils/batch.cjs");
6
- const utils = require("./utils.cjs");
7
- const notFound = require("./not-found.cjs");
8
- const root = require("./root.cjs");
9
- const redirect = require("./redirect.cjs");
10
- const triggerOnReady = (inner) => {
11
- if (!inner.rendered) {
12
- inner.rendered = true;
13
- return inner.onReady?.();
14
- }
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_batch = require("./utils/batch.cjs");
3
+ const require_utils = require("./utils.cjs");
4
+ const require_not_found = require("./not-found.cjs");
5
+ const require_root = require("./root.cjs");
6
+ const require_redirect = require("./redirect.cjs");
7
+ let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
8
+ let tiny_invariant = require("tiny-invariant");
9
+ tiny_invariant = require_runtime.__toESM(tiny_invariant);
10
+ //#region src/load-matches.ts
11
+ var triggerOnReady = (inner) => {
12
+ if (!inner.rendered) {
13
+ inner.rendered = true;
14
+ return inner.onReady?.();
15
+ }
15
16
  };
16
- const resolvePreload = (inner, matchId) => {
17
- return !!(inner.preload && !inner.router.state.matches.some((d) => d.id === matchId));
17
+ var resolvePreload = (inner, matchId) => {
18
+ return !!(inner.preload && !inner.router.state.matches.some((d) => d.id === matchId));
18
19
  };
19
- const buildMatchContext = (inner, index, includeCurrentMatch = true) => {
20
- const context = {
21
- ...inner.router.options.context ?? {}
22
- };
23
- const end = includeCurrentMatch ? index : index - 1;
24
- for (let i = 0; i <= end; i++) {
25
- const innerMatch = inner.matches[i];
26
- if (!innerMatch) continue;
27
- const m = inner.router.getMatch(innerMatch.id);
28
- if (!m) continue;
29
- Object.assign(context, m.__routeContext, m.__beforeLoadContext);
30
- }
31
- return context;
20
+ /**
21
+ * Builds the accumulated context from router options and all matches up to (and optionally including) the given index.
22
+ * Merges __routeContext and __beforeLoadContext from each match.
23
+ */
24
+ var buildMatchContext = (inner, index, includeCurrentMatch = true) => {
25
+ const context = { ...inner.router.options.context ?? {} };
26
+ const end = includeCurrentMatch ? index : index - 1;
27
+ for (let i = 0; i <= end; i++) {
28
+ const innerMatch = inner.matches[i];
29
+ if (!innerMatch) continue;
30
+ const m = inner.router.getMatch(innerMatch.id);
31
+ if (!m) continue;
32
+ Object.assign(context, m.__routeContext, m.__beforeLoadContext);
33
+ }
34
+ return context;
32
35
  };
33
- const getNotFoundBoundaryIndex = (inner, err) => {
34
- if (!inner.matches.length) {
35
- return void 0;
36
- }
37
- const requestedRouteId = err.routeId;
38
- const matchedRootIndex = inner.matches.findIndex(
39
- (m) => m.routeId === inner.router.routeTree.id
40
- );
41
- const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0;
42
- let startIndex = requestedRouteId ? inner.matches.findIndex((match) => match.routeId === requestedRouteId) : inner.firstBadMatchIndex ?? inner.matches.length - 1;
43
- if (startIndex < 0) {
44
- startIndex = rootIndex;
45
- }
46
- for (let i = startIndex; i >= 0; i--) {
47
- const match = inner.matches[i];
48
- const route = inner.router.looseRoutesById[match.routeId];
49
- if (route.options.notFoundComponent) {
50
- return i;
51
- }
52
- }
53
- return requestedRouteId ? startIndex : rootIndex;
36
+ var getNotFoundBoundaryIndex = (inner, err) => {
37
+ if (!inner.matches.length) return;
38
+ const requestedRouteId = err.routeId;
39
+ const matchedRootIndex = inner.matches.findIndex((m) => m.routeId === inner.router.routeTree.id);
40
+ const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0;
41
+ let startIndex = requestedRouteId ? inner.matches.findIndex((match) => match.routeId === requestedRouteId) : inner.firstBadMatchIndex ?? inner.matches.length - 1;
42
+ if (startIndex < 0) startIndex = rootIndex;
43
+ for (let i = startIndex; i >= 0; i--) {
44
+ const match = inner.matches[i];
45
+ if (inner.router.looseRoutesById[match.routeId].options.notFoundComponent) return i;
46
+ }
47
+ return requestedRouteId ? startIndex : rootIndex;
54
48
  };
55
- const handleRedirectAndNotFound = (inner, match, err) => {
56
- if (!redirect.isRedirect(err) && !notFound.isNotFound(err)) return;
57
- if (redirect.isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {
58
- throw err;
59
- }
60
- if (match) {
61
- match._nonReactive.beforeLoadPromise?.resolve();
62
- match._nonReactive.loaderPromise?.resolve();
63
- match._nonReactive.beforeLoadPromise = void 0;
64
- match._nonReactive.loaderPromise = void 0;
65
- match._nonReactive.error = err;
66
- inner.updateMatch(match.id, (prev) => ({
67
- ...prev,
68
- status: redirect.isRedirect(err) ? "redirected" : prev.status === "pending" ? "success" : prev.status,
69
- context: buildMatchContext(inner, match.index),
70
- isFetching: false,
71
- error: err
72
- }));
73
- if (notFound.isNotFound(err) && !err.routeId) {
74
- err.routeId = match.routeId;
75
- }
76
- match._nonReactive.loadPromise?.resolve();
77
- }
78
- if (redirect.isRedirect(err)) {
79
- inner.rendered = true;
80
- err.options._fromLocation = inner.location;
81
- err.redirectHandled = true;
82
- err = inner.router.resolveRedirect(err);
83
- }
84
- throw err;
49
+ var handleRedirectAndNotFound = (inner, match, err) => {
50
+ if (!require_redirect.isRedirect(err) && !require_not_found.isNotFound(err)) return;
51
+ if (require_redirect.isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) throw err;
52
+ if (match) {
53
+ match._nonReactive.beforeLoadPromise?.resolve();
54
+ match._nonReactive.loaderPromise?.resolve();
55
+ match._nonReactive.beforeLoadPromise = void 0;
56
+ match._nonReactive.loaderPromise = void 0;
57
+ match._nonReactive.error = err;
58
+ inner.updateMatch(match.id, (prev) => ({
59
+ ...prev,
60
+ status: require_redirect.isRedirect(err) ? "redirected" : prev.status === "pending" ? "success" : prev.status,
61
+ context: buildMatchContext(inner, match.index),
62
+ isFetching: false,
63
+ error: err
64
+ }));
65
+ if (require_not_found.isNotFound(err) && !err.routeId) err.routeId = match.routeId;
66
+ match._nonReactive.loadPromise?.resolve();
67
+ }
68
+ if (require_redirect.isRedirect(err)) {
69
+ inner.rendered = true;
70
+ err.options._fromLocation = inner.location;
71
+ err.redirectHandled = true;
72
+ err = inner.router.resolveRedirect(err);
73
+ }
74
+ throw err;
85
75
  };
86
- const shouldSkipLoader = (inner, matchId) => {
87
- const match = inner.router.getMatch(matchId);
88
- if (!match) {
89
- return true;
90
- }
91
- if (!(isServer.isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {
92
- return true;
93
- }
94
- if ((isServer.isServer ?? inner.router.isServer) && match.ssr === false) {
95
- return true;
96
- }
97
- return false;
76
+ var shouldSkipLoader = (inner, matchId) => {
77
+ const match = inner.router.getMatch(matchId);
78
+ if (!match) return true;
79
+ if (!(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) return true;
80
+ if ((_tanstack_router_core_isServer.isServer ?? inner.router.isServer) && match.ssr === false) return true;
81
+ return false;
98
82
  };
99
- const syncMatchContext = (inner, matchId, index) => {
100
- const nextContext = buildMatchContext(inner, index);
101
- inner.updateMatch(matchId, (prev) => {
102
- return {
103
- ...prev,
104
- context: nextContext
105
- };
106
- });
83
+ var syncMatchContext = (inner, matchId, index) => {
84
+ const nextContext = buildMatchContext(inner, index);
85
+ inner.updateMatch(matchId, (prev) => {
86
+ return {
87
+ ...prev,
88
+ context: nextContext
89
+ };
90
+ });
107
91
  };
108
- const handleSerialError = (inner, index, err, routerCode) => {
109
- const { id: matchId, routeId } = inner.matches[index];
110
- const route = inner.router.looseRoutesById[routeId];
111
- if (err instanceof Promise) {
112
- throw err;
113
- }
114
- err.routerCode = routerCode;
115
- inner.firstBadMatchIndex ??= index;
116
- handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
117
- try {
118
- route.options.onError?.(err);
119
- } catch (errorHandlerErr) {
120
- err = errorHandlerErr;
121
- handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
122
- }
123
- inner.updateMatch(matchId, (prev) => {
124
- prev._nonReactive.beforeLoadPromise?.resolve();
125
- prev._nonReactive.beforeLoadPromise = void 0;
126
- prev._nonReactive.loadPromise?.resolve();
127
- return {
128
- ...prev,
129
- error: err,
130
- status: "error",
131
- isFetching: false,
132
- updatedAt: Date.now(),
133
- abortController: new AbortController()
134
- };
135
- });
136
- if (!inner.preload && !redirect.isRedirect(err) && !notFound.isNotFound(err)) {
137
- inner.serialError ??= err;
138
- }
92
+ var handleSerialError = (inner, index, err, routerCode) => {
93
+ const { id: matchId, routeId } = inner.matches[index];
94
+ const route = inner.router.looseRoutesById[routeId];
95
+ if (err instanceof Promise) throw err;
96
+ err.routerCode = routerCode;
97
+ inner.firstBadMatchIndex ??= index;
98
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
99
+ try {
100
+ route.options.onError?.(err);
101
+ } catch (errorHandlerErr) {
102
+ err = errorHandlerErr;
103
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
104
+ }
105
+ inner.updateMatch(matchId, (prev) => {
106
+ prev._nonReactive.beforeLoadPromise?.resolve();
107
+ prev._nonReactive.beforeLoadPromise = void 0;
108
+ prev._nonReactive.loadPromise?.resolve();
109
+ return {
110
+ ...prev,
111
+ error: err,
112
+ status: "error",
113
+ isFetching: false,
114
+ updatedAt: Date.now(),
115
+ abortController: new AbortController()
116
+ };
117
+ });
118
+ if (!inner.preload && !require_redirect.isRedirect(err) && !require_not_found.isNotFound(err)) inner.serialError ??= err;
139
119
  };
140
- const isBeforeLoadSsr = (inner, matchId, index, route) => {
141
- const existingMatch = inner.router.getMatch(matchId);
142
- const parentMatchId = inner.matches[index - 1]?.id;
143
- const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
144
- if (inner.router.isShell()) {
145
- existingMatch.ssr = route.id === root.rootRouteId;
146
- return;
147
- }
148
- if (parentMatch?.ssr === false) {
149
- existingMatch.ssr = false;
150
- return;
151
- }
152
- const parentOverride = (tempSsr2) => {
153
- if (tempSsr2 === true && parentMatch?.ssr === "data-only") {
154
- return "data-only";
155
- }
156
- return tempSsr2;
157
- };
158
- const defaultSsr = inner.router.options.defaultSsr ?? true;
159
- if (route.options.ssr === void 0) {
160
- existingMatch.ssr = parentOverride(defaultSsr);
161
- return;
162
- }
163
- if (typeof route.options.ssr !== "function") {
164
- existingMatch.ssr = parentOverride(route.options.ssr);
165
- return;
166
- }
167
- const { search, params } = existingMatch;
168
- const ssrFnContext = {
169
- search: makeMaybe(search, existingMatch.searchError),
170
- params: makeMaybe(params, existingMatch.paramsError),
171
- location: inner.location,
172
- matches: inner.matches.map((match) => ({
173
- index: match.index,
174
- pathname: match.pathname,
175
- fullPath: match.fullPath,
176
- staticData: match.staticData,
177
- id: match.id,
178
- routeId: match.routeId,
179
- search: makeMaybe(match.search, match.searchError),
180
- params: makeMaybe(match.params, match.paramsError),
181
- ssr: match.ssr
182
- }))
183
- };
184
- const tempSsr = route.options.ssr(ssrFnContext);
185
- if (utils.isPromise(tempSsr)) {
186
- return tempSsr.then((ssr) => {
187
- existingMatch.ssr = parentOverride(ssr ?? defaultSsr);
188
- });
189
- }
190
- existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr);
191
- return;
120
+ var isBeforeLoadSsr = (inner, matchId, index, route) => {
121
+ const existingMatch = inner.router.getMatch(matchId);
122
+ const parentMatchId = inner.matches[index - 1]?.id;
123
+ const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
124
+ if (inner.router.isShell()) {
125
+ existingMatch.ssr = route.id === require_root.rootRouteId;
126
+ return;
127
+ }
128
+ if (parentMatch?.ssr === false) {
129
+ existingMatch.ssr = false;
130
+ return;
131
+ }
132
+ const parentOverride = (tempSsr) => {
133
+ if (tempSsr === true && parentMatch?.ssr === "data-only") return "data-only";
134
+ return tempSsr;
135
+ };
136
+ const defaultSsr = inner.router.options.defaultSsr ?? true;
137
+ if (route.options.ssr === void 0) {
138
+ existingMatch.ssr = parentOverride(defaultSsr);
139
+ return;
140
+ }
141
+ if (typeof route.options.ssr !== "function") {
142
+ existingMatch.ssr = parentOverride(route.options.ssr);
143
+ return;
144
+ }
145
+ const { search, params } = existingMatch;
146
+ const ssrFnContext = {
147
+ search: makeMaybe(search, existingMatch.searchError),
148
+ params: makeMaybe(params, existingMatch.paramsError),
149
+ location: inner.location,
150
+ matches: inner.matches.map((match) => ({
151
+ index: match.index,
152
+ pathname: match.pathname,
153
+ fullPath: match.fullPath,
154
+ staticData: match.staticData,
155
+ id: match.id,
156
+ routeId: match.routeId,
157
+ search: makeMaybe(match.search, match.searchError),
158
+ params: makeMaybe(match.params, match.paramsError),
159
+ ssr: match.ssr
160
+ }))
161
+ };
162
+ const tempSsr = route.options.ssr(ssrFnContext);
163
+ if (require_utils.isPromise(tempSsr)) return tempSsr.then((ssr) => {
164
+ existingMatch.ssr = parentOverride(ssr ?? defaultSsr);
165
+ });
166
+ existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr);
192
167
  };
193
- const setupPendingTimeout = (inner, matchId, route, match) => {
194
- if (match._nonReactive.pendingTimeout !== void 0) return;
195
- const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
196
- const shouldPending = !!(inner.onReady && !(isServer.isServer ?? inner.router.isServer) && !resolvePreload(inner, matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? inner.router.options?.defaultPendingComponent));
197
- if (shouldPending) {
198
- const pendingTimeout = setTimeout(() => {
199
- triggerOnReady(inner);
200
- }, pendingMs);
201
- match._nonReactive.pendingTimeout = pendingTimeout;
202
- }
168
+ var setupPendingTimeout = (inner, matchId, route, match) => {
169
+ if (match._nonReactive.pendingTimeout !== void 0) return;
170
+ const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
171
+ if (!!(inner.onReady && !(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) && !resolvePreload(inner, matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? inner.router.options?.defaultPendingComponent))) {
172
+ const pendingTimeout = setTimeout(() => {
173
+ triggerOnReady(inner);
174
+ }, pendingMs);
175
+ match._nonReactive.pendingTimeout = pendingTimeout;
176
+ }
203
177
  };
204
- const preBeforeLoadSetup = (inner, matchId, route) => {
205
- const existingMatch = inner.router.getMatch(matchId);
206
- if (!existingMatch._nonReactive.beforeLoadPromise && !existingMatch._nonReactive.loaderPromise)
207
- return;
208
- setupPendingTimeout(inner, matchId, route, existingMatch);
209
- const then = () => {
210
- const match = inner.router.getMatch(matchId);
211
- if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
212
- handleRedirectAndNotFound(inner, match, match.error);
213
- }
214
- };
215
- return existingMatch._nonReactive.beforeLoadPromise ? existingMatch._nonReactive.beforeLoadPromise.then(then) : then();
178
+ var preBeforeLoadSetup = (inner, matchId, route) => {
179
+ const existingMatch = inner.router.getMatch(matchId);
180
+ if (!existingMatch._nonReactive.beforeLoadPromise && !existingMatch._nonReactive.loaderPromise) return;
181
+ setupPendingTimeout(inner, matchId, route, existingMatch);
182
+ const then = () => {
183
+ const match = inner.router.getMatch(matchId);
184
+ if (match.preload && (match.status === "redirected" || match.status === "notFound")) handleRedirectAndNotFound(inner, match, match.error);
185
+ };
186
+ return existingMatch._nonReactive.beforeLoadPromise ? existingMatch._nonReactive.beforeLoadPromise.then(then) : then();
216
187
  };
217
- const executeBeforeLoad = (inner, matchId, index, route) => {
218
- const match = inner.router.getMatch(matchId);
219
- const prevLoadPromise = match._nonReactive.loadPromise;
220
- match._nonReactive.loadPromise = utils.createControlledPromise(() => {
221
- prevLoadPromise?.resolve();
222
- });
223
- const { paramsError, searchError } = match;
224
- if (paramsError) {
225
- handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
226
- }
227
- if (searchError) {
228
- handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
229
- }
230
- setupPendingTimeout(inner, matchId, route, match);
231
- const abortController = new AbortController();
232
- let isPending = false;
233
- const pending = () => {
234
- if (isPending) return;
235
- isPending = true;
236
- inner.updateMatch(matchId, (prev) => ({
237
- ...prev,
238
- isFetching: "beforeLoad",
239
- fetchCount: prev.fetchCount + 1,
240
- abortController
241
- // Note: We intentionally don't update context here.
242
- // Context should only be updated after beforeLoad resolves to avoid
243
- // components seeing incomplete context during async beforeLoad execution.
244
- }));
245
- };
246
- const resolve = () => {
247
- match._nonReactive.beforeLoadPromise?.resolve();
248
- match._nonReactive.beforeLoadPromise = void 0;
249
- inner.updateMatch(matchId, (prev) => ({
250
- ...prev,
251
- isFetching: false
252
- }));
253
- };
254
- if (!route.options.beforeLoad) {
255
- batch.batch(() => {
256
- pending();
257
- resolve();
258
- });
259
- return;
260
- }
261
- match._nonReactive.beforeLoadPromise = utils.createControlledPromise();
262
- const context = {
263
- ...buildMatchContext(inner, index, false),
264
- ...match.__routeContext
265
- };
266
- const { search, params, cause } = match;
267
- const preload = resolvePreload(inner, matchId);
268
- const beforeLoadFnContext = {
269
- search,
270
- abortController,
271
- params,
272
- preload,
273
- context,
274
- location: inner.location,
275
- navigate: (opts) => inner.router.navigate({
276
- ...opts,
277
- _fromLocation: inner.location
278
- }),
279
- buildLocation: inner.router.buildLocation,
280
- cause: preload ? "preload" : cause,
281
- matches: inner.matches,
282
- routeId: route.id,
283
- ...inner.router.options.additionalContext
284
- };
285
- const updateContext = (beforeLoadContext2) => {
286
- if (beforeLoadContext2 === void 0) {
287
- batch.batch(() => {
288
- pending();
289
- resolve();
290
- });
291
- return;
292
- }
293
- if (redirect.isRedirect(beforeLoadContext2) || notFound.isNotFound(beforeLoadContext2)) {
294
- pending();
295
- handleSerialError(inner, index, beforeLoadContext2, "BEFORE_LOAD");
296
- }
297
- batch.batch(() => {
298
- pending();
299
- inner.updateMatch(matchId, (prev) => ({
300
- ...prev,
301
- __beforeLoadContext: beforeLoadContext2
302
- }));
303
- resolve();
304
- });
305
- };
306
- let beforeLoadContext;
307
- try {
308
- beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
309
- if (utils.isPromise(beforeLoadContext)) {
310
- pending();
311
- return beforeLoadContext.catch((err) => {
312
- handleSerialError(inner, index, err, "BEFORE_LOAD");
313
- }).then(updateContext);
314
- }
315
- } catch (err) {
316
- pending();
317
- handleSerialError(inner, index, err, "BEFORE_LOAD");
318
- }
319
- updateContext(beforeLoadContext);
320
- return;
188
+ var executeBeforeLoad = (inner, matchId, index, route) => {
189
+ const match = inner.router.getMatch(matchId);
190
+ let prevLoadPromise = match._nonReactive.loadPromise;
191
+ match._nonReactive.loadPromise = require_utils.createControlledPromise(() => {
192
+ prevLoadPromise?.resolve();
193
+ prevLoadPromise = void 0;
194
+ });
195
+ const { paramsError, searchError } = match;
196
+ if (paramsError) handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
197
+ if (searchError) handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
198
+ setupPendingTimeout(inner, matchId, route, match);
199
+ const abortController = new AbortController();
200
+ let isPending = false;
201
+ const pending = () => {
202
+ if (isPending) return;
203
+ isPending = true;
204
+ inner.updateMatch(matchId, (prev) => ({
205
+ ...prev,
206
+ isFetching: "beforeLoad",
207
+ fetchCount: prev.fetchCount + 1,
208
+ abortController
209
+ }));
210
+ };
211
+ const resolve = () => {
212
+ match._nonReactive.beforeLoadPromise?.resolve();
213
+ match._nonReactive.beforeLoadPromise = void 0;
214
+ inner.updateMatch(matchId, (prev) => ({
215
+ ...prev,
216
+ isFetching: false
217
+ }));
218
+ };
219
+ if (!route.options.beforeLoad) {
220
+ require_batch.batch(() => {
221
+ pending();
222
+ resolve();
223
+ });
224
+ return;
225
+ }
226
+ match._nonReactive.beforeLoadPromise = require_utils.createControlledPromise();
227
+ const context = {
228
+ ...buildMatchContext(inner, index, false),
229
+ ...match.__routeContext
230
+ };
231
+ const { search, params, cause } = match;
232
+ const preload = resolvePreload(inner, matchId);
233
+ const beforeLoadFnContext = {
234
+ search,
235
+ abortController,
236
+ params,
237
+ preload,
238
+ context,
239
+ location: inner.location,
240
+ navigate: (opts) => inner.router.navigate({
241
+ ...opts,
242
+ _fromLocation: inner.location
243
+ }),
244
+ buildLocation: inner.router.buildLocation,
245
+ cause: preload ? "preload" : cause,
246
+ matches: inner.matches,
247
+ routeId: route.id,
248
+ ...inner.router.options.additionalContext
249
+ };
250
+ const updateContext = (beforeLoadContext) => {
251
+ if (beforeLoadContext === void 0) {
252
+ require_batch.batch(() => {
253
+ pending();
254
+ resolve();
255
+ });
256
+ return;
257
+ }
258
+ if (require_redirect.isRedirect(beforeLoadContext) || require_not_found.isNotFound(beforeLoadContext)) {
259
+ pending();
260
+ handleSerialError(inner, index, beforeLoadContext, "BEFORE_LOAD");
261
+ }
262
+ require_batch.batch(() => {
263
+ pending();
264
+ inner.updateMatch(matchId, (prev) => ({
265
+ ...prev,
266
+ __beforeLoadContext: beforeLoadContext
267
+ }));
268
+ resolve();
269
+ });
270
+ };
271
+ let beforeLoadContext;
272
+ try {
273
+ beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
274
+ if (require_utils.isPromise(beforeLoadContext)) {
275
+ pending();
276
+ return beforeLoadContext.catch((err) => {
277
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
278
+ }).then(updateContext);
279
+ }
280
+ } catch (err) {
281
+ pending();
282
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
283
+ }
284
+ updateContext(beforeLoadContext);
321
285
  };
322
- const handleBeforeLoad = (inner, index) => {
323
- const { id: matchId, routeId } = inner.matches[index];
324
- const route = inner.router.looseRoutesById[routeId];
325
- const serverSsr = () => {
326
- if (isServer.isServer ?? inner.router.isServer) {
327
- const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
328
- if (utils.isPromise(maybePromise)) return maybePromise.then(queueExecution);
329
- }
330
- return queueExecution();
331
- };
332
- const execute = () => executeBeforeLoad(inner, matchId, index, route);
333
- const queueExecution = () => {
334
- if (shouldSkipLoader(inner, matchId)) return;
335
- const result = preBeforeLoadSetup(inner, matchId, route);
336
- return utils.isPromise(result) ? result.then(execute) : execute();
337
- };
338
- return serverSsr();
286
+ var handleBeforeLoad = (inner, index) => {
287
+ const { id: matchId, routeId } = inner.matches[index];
288
+ const route = inner.router.looseRoutesById[routeId];
289
+ const serverSsr = () => {
290
+ if (_tanstack_router_core_isServer.isServer ?? inner.router.isServer) {
291
+ const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
292
+ if (require_utils.isPromise(maybePromise)) return maybePromise.then(queueExecution);
293
+ }
294
+ return queueExecution();
295
+ };
296
+ const execute = () => executeBeforeLoad(inner, matchId, index, route);
297
+ const queueExecution = () => {
298
+ if (shouldSkipLoader(inner, matchId)) return;
299
+ const result = preBeforeLoadSetup(inner, matchId, route);
300
+ return require_utils.isPromise(result) ? result.then(execute) : execute();
301
+ };
302
+ return serverSsr();
339
303
  };
340
- const executeHead = (inner, matchId, route) => {
341
- const match = inner.router.getMatch(matchId);
342
- if (!match) {
343
- return;
344
- }
345
- if (!route.options.head && !route.options.scripts && !route.options.headers) {
346
- return;
347
- }
348
- const assetContext = {
349
- ssr: inner.router.options.ssr,
350
- matches: inner.matches,
351
- match,
352
- params: match.params,
353
- loaderData: match.loaderData
354
- };
355
- return Promise.all([
356
- route.options.head?.(assetContext),
357
- route.options.scripts?.(assetContext),
358
- route.options.headers?.(assetContext)
359
- ]).then(([headFnContent, scripts, headers]) => {
360
- const meta = headFnContent?.meta;
361
- const links = headFnContent?.links;
362
- const headScripts = headFnContent?.scripts;
363
- const styles = headFnContent?.styles;
364
- return {
365
- meta,
366
- links,
367
- headScripts,
368
- headers,
369
- scripts,
370
- styles
371
- };
372
- });
304
+ var executeHead = (inner, matchId, route) => {
305
+ const match = inner.router.getMatch(matchId);
306
+ if (!match) return;
307
+ if (!route.options.head && !route.options.scripts && !route.options.headers) return;
308
+ const assetContext = {
309
+ ssr: inner.router.options.ssr,
310
+ matches: inner.matches,
311
+ match,
312
+ params: match.params,
313
+ loaderData: match.loaderData
314
+ };
315
+ return Promise.all([
316
+ route.options.head?.(assetContext),
317
+ route.options.scripts?.(assetContext),
318
+ route.options.headers?.(assetContext)
319
+ ]).then(([headFnContent, scripts, headers]) => {
320
+ return {
321
+ meta: headFnContent?.meta,
322
+ links: headFnContent?.links,
323
+ headScripts: headFnContent?.scripts,
324
+ headers,
325
+ scripts,
326
+ styles: headFnContent?.styles
327
+ };
328
+ });
373
329
  };
374
- const getLoaderContext = (inner, matchPromises, matchId, index, route) => {
375
- const parentMatchPromise = matchPromises[index - 1];
376
- const { params, loaderDeps, abortController, cause } = inner.router.getMatch(matchId);
377
- const context = buildMatchContext(inner, index);
378
- const preload = resolvePreload(inner, matchId);
379
- return {
380
- params,
381
- deps: loaderDeps,
382
- preload: !!preload,
383
- parentMatchPromise,
384
- abortController,
385
- context,
386
- location: inner.location,
387
- navigate: (opts) => inner.router.navigate({
388
- ...opts,
389
- _fromLocation: inner.location
390
- }),
391
- cause: preload ? "preload" : cause,
392
- route,
393
- ...inner.router.options.additionalContext
394
- };
330
+ var getLoaderContext = (inner, matchPromises, matchId, index, route) => {
331
+ const parentMatchPromise = matchPromises[index - 1];
332
+ const { params, loaderDeps, abortController, cause } = inner.router.getMatch(matchId);
333
+ const context = buildMatchContext(inner, index);
334
+ const preload = resolvePreload(inner, matchId);
335
+ return {
336
+ params,
337
+ deps: loaderDeps,
338
+ preload: !!preload,
339
+ parentMatchPromise,
340
+ abortController,
341
+ context,
342
+ location: inner.location,
343
+ navigate: (opts) => inner.router.navigate({
344
+ ...opts,
345
+ _fromLocation: inner.location
346
+ }),
347
+ cause: preload ? "preload" : cause,
348
+ route,
349
+ ...inner.router.options.additionalContext
350
+ };
395
351
  };
396
- const runLoader = async (inner, matchPromises, matchId, index, route) => {
397
- try {
398
- const match = inner.router.getMatch(matchId);
399
- try {
400
- if (!(isServer.isServer ?? inner.router.isServer) || match.ssr === true) {
401
- loadRouteChunk(route);
402
- }
403
- const routeLoader = route.options.loader;
404
- const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
405
- const loaderResult = loader?.(
406
- getLoaderContext(inner, matchPromises, matchId, index, route)
407
- );
408
- const loaderResultIsPromise = !!loader && utils.isPromise(loaderResult);
409
- const willLoadSomething = !!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise);
410
- if (willLoadSomething) {
411
- inner.updateMatch(matchId, (prev) => ({
412
- ...prev,
413
- isFetching: "loader"
414
- }));
415
- }
416
- if (loader) {
417
- const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
418
- handleRedirectAndNotFound(
419
- inner,
420
- inner.router.getMatch(matchId),
421
- loaderData
422
- );
423
- if (loaderData !== void 0) {
424
- inner.updateMatch(matchId, (prev) => ({
425
- ...prev,
426
- loaderData
427
- }));
428
- }
429
- }
430
- if (route._lazyPromise) await route._lazyPromise;
431
- const pendingPromise = match._nonReactive.minPendingPromise;
432
- if (pendingPromise) await pendingPromise;
433
- if (route._componentsPromise) await route._componentsPromise;
434
- inner.updateMatch(matchId, (prev) => ({
435
- ...prev,
436
- error: void 0,
437
- context: buildMatchContext(inner, index),
438
- status: "success",
439
- isFetching: false,
440
- updatedAt: Date.now()
441
- }));
442
- } catch (e) {
443
- let error = e;
444
- if (error?.name === "AbortError") {
445
- if (match.abortController.signal.aborted) {
446
- match._nonReactive.loaderPromise?.resolve();
447
- match._nonReactive.loaderPromise = void 0;
448
- return;
449
- }
450
- inner.updateMatch(matchId, (prev) => ({
451
- ...prev,
452
- status: prev.status === "pending" ? "success" : prev.status,
453
- isFetching: false,
454
- context: buildMatchContext(inner, index)
455
- }));
456
- return;
457
- }
458
- const pendingPromise = match._nonReactive.minPendingPromise;
459
- if (pendingPromise) await pendingPromise;
460
- if (notFound.isNotFound(e)) {
461
- await route.options.notFoundComponent?.preload?.();
462
- }
463
- handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
464
- try {
465
- route.options.onError?.(e);
466
- } catch (onErrorError) {
467
- error = onErrorError;
468
- handleRedirectAndNotFound(
469
- inner,
470
- inner.router.getMatch(matchId),
471
- onErrorError
472
- );
473
- }
474
- if (!redirect.isRedirect(error) && !notFound.isNotFound(error)) {
475
- await loadRouteChunk(route, ["errorComponent"]);
476
- }
477
- inner.updateMatch(matchId, (prev) => ({
478
- ...prev,
479
- error,
480
- context: buildMatchContext(inner, index),
481
- status: "error",
482
- isFetching: false
483
- }));
484
- }
485
- } catch (err) {
486
- const match = inner.router.getMatch(matchId);
487
- if (match) {
488
- match._nonReactive.loaderPromise = void 0;
489
- }
490
- handleRedirectAndNotFound(inner, match, err);
491
- }
352
+ var runLoader = async (inner, matchPromises, matchId, index, route) => {
353
+ try {
354
+ const match = inner.router.getMatch(matchId);
355
+ try {
356
+ if (!(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) || match.ssr === true) loadRouteChunk(route);
357
+ const routeLoader = route.options.loader;
358
+ const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
359
+ const loaderResult = loader?.(getLoaderContext(inner, matchPromises, matchId, index, route));
360
+ const loaderResultIsPromise = !!loader && require_utils.isPromise(loaderResult);
361
+ if (!!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise)) inner.updateMatch(matchId, (prev) => ({
362
+ ...prev,
363
+ isFetching: "loader"
364
+ }));
365
+ if (loader) {
366
+ const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
367
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), loaderData);
368
+ if (loaderData !== void 0) inner.updateMatch(matchId, (prev) => ({
369
+ ...prev,
370
+ loaderData
371
+ }));
372
+ }
373
+ if (route._lazyPromise) await route._lazyPromise;
374
+ const pendingPromise = match._nonReactive.minPendingPromise;
375
+ if (pendingPromise) await pendingPromise;
376
+ if (route._componentsPromise) await route._componentsPromise;
377
+ inner.updateMatch(matchId, (prev) => ({
378
+ ...prev,
379
+ error: void 0,
380
+ context: buildMatchContext(inner, index),
381
+ status: "success",
382
+ isFetching: false,
383
+ updatedAt: Date.now()
384
+ }));
385
+ } catch (e) {
386
+ let error = e;
387
+ if (error?.name === "AbortError") {
388
+ if (match.abortController.signal.aborted) {
389
+ match._nonReactive.loaderPromise?.resolve();
390
+ match._nonReactive.loaderPromise = void 0;
391
+ return;
392
+ }
393
+ inner.updateMatch(matchId, (prev) => ({
394
+ ...prev,
395
+ status: prev.status === "pending" ? "success" : prev.status,
396
+ isFetching: false,
397
+ context: buildMatchContext(inner, index)
398
+ }));
399
+ return;
400
+ }
401
+ const pendingPromise = match._nonReactive.minPendingPromise;
402
+ if (pendingPromise) await pendingPromise;
403
+ if (require_not_found.isNotFound(e)) await route.options.notFoundComponent?.preload?.();
404
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
405
+ try {
406
+ route.options.onError?.(e);
407
+ } catch (onErrorError) {
408
+ error = onErrorError;
409
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), onErrorError);
410
+ }
411
+ if (!require_redirect.isRedirect(error) && !require_not_found.isNotFound(error)) await loadRouteChunk(route, ["errorComponent"]);
412
+ inner.updateMatch(matchId, (prev) => ({
413
+ ...prev,
414
+ error,
415
+ context: buildMatchContext(inner, index),
416
+ status: "error",
417
+ isFetching: false
418
+ }));
419
+ }
420
+ } catch (err) {
421
+ const match = inner.router.getMatch(matchId);
422
+ if (match) match._nonReactive.loaderPromise = void 0;
423
+ handleRedirectAndNotFound(inner, match, err);
424
+ }
492
425
  };
493
- const loadRouteMatch = async (inner, matchPromises, index) => {
494
- async function handleLoader(preload, prevMatch, previousRouteMatchId, match2, route2) {
495
- const age = Date.now() - prevMatch.updatedAt;
496
- const staleAge = preload ? route2.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route2.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
497
- const shouldReloadOption = route2.options.shouldReload;
498
- const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(
499
- getLoaderContext(inner, matchPromises, matchId, index, route2)
500
- ) : shouldReloadOption;
501
- const { status, invalid } = match2;
502
- const staleMatchShouldReload = age > staleAge && (!!inner.forceStaleReload || match2.cause === "enter" || previousRouteMatchId !== void 0 && previousRouteMatchId !== match2.id);
503
- loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? staleMatchShouldReload));
504
- if (preload && route2.options.preload === false) ;
505
- else if (loaderShouldRunAsync && !inner.sync && shouldReloadInBackground) {
506
- loaderIsRunningAsync = true;
507
- (async () => {
508
- try {
509
- await runLoader(inner, matchPromises, matchId, index, route2);
510
- const match3 = inner.router.getMatch(matchId);
511
- match3._nonReactive.loaderPromise?.resolve();
512
- match3._nonReactive.loadPromise?.resolve();
513
- match3._nonReactive.loaderPromise = void 0;
514
- } catch (err) {
515
- if (redirect.isRedirect(err)) {
516
- await inner.router.navigate(err.options);
517
- }
518
- }
519
- })();
520
- } else if (status !== "success" || loaderShouldRunAsync) {
521
- await runLoader(inner, matchPromises, matchId, index, route2);
522
- } else {
523
- syncMatchContext(inner, matchId, index);
524
- }
525
- }
526
- const { id: matchId, routeId } = inner.matches[index];
527
- let loaderShouldRunAsync = false;
528
- let loaderIsRunningAsync = false;
529
- const route = inner.router.looseRoutesById[routeId];
530
- const routeLoader = route.options.loader;
531
- const shouldReloadInBackground = ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? inner.router.options.defaultStaleReloadMode) !== "blocking";
532
- if (shouldSkipLoader(inner, matchId)) {
533
- const match2 = inner.router.getMatch(matchId);
534
- if (!match2) {
535
- return inner.matches[index];
536
- }
537
- syncMatchContext(inner, matchId, index);
538
- if (isServer.isServer ?? inner.router.isServer) {
539
- return inner.router.getMatch(matchId);
540
- }
541
- } else {
542
- const prevMatch = inner.router.getMatch(matchId);
543
- const previousRouteMatchId = inner.router.state.matches[index]?.routeId === routeId ? inner.router.state.matches[index].id : inner.router.state.matches.find((d) => d.routeId === routeId)?.id;
544
- const preload = resolvePreload(inner, matchId);
545
- if (prevMatch._nonReactive.loaderPromise) {
546
- if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload && shouldReloadInBackground) {
547
- return prevMatch;
548
- }
549
- await prevMatch._nonReactive.loaderPromise;
550
- const match2 = inner.router.getMatch(matchId);
551
- const error = match2._nonReactive.error || match2.error;
552
- if (error) {
553
- handleRedirectAndNotFound(inner, match2, error);
554
- }
555
- if (match2.status === "pending") {
556
- await handleLoader(
557
- preload,
558
- prevMatch,
559
- previousRouteMatchId,
560
- match2,
561
- route
562
- );
563
- }
564
- } else {
565
- const nextPreload = preload && !inner.router.state.matches.some((d) => d.id === matchId);
566
- const match2 = inner.router.getMatch(matchId);
567
- match2._nonReactive.loaderPromise = utils.createControlledPromise();
568
- if (nextPreload !== match2.preload) {
569
- inner.updateMatch(matchId, (prev) => ({
570
- ...prev,
571
- preload: nextPreload
572
- }));
573
- }
574
- await handleLoader(preload, prevMatch, previousRouteMatchId, match2, route);
575
- }
576
- }
577
- const match = inner.router.getMatch(matchId);
578
- if (!loaderIsRunningAsync) {
579
- match._nonReactive.loaderPromise?.resolve();
580
- match._nonReactive.loadPromise?.resolve();
581
- }
582
- clearTimeout(match._nonReactive.pendingTimeout);
583
- match._nonReactive.pendingTimeout = void 0;
584
- if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
585
- match._nonReactive.dehydrated = void 0;
586
- const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
587
- if (nextIsFetching !== match.isFetching || match.invalid !== false) {
588
- inner.updateMatch(matchId, (prev) => ({
589
- ...prev,
590
- isFetching: nextIsFetching,
591
- invalid: false
592
- }));
593
- return inner.router.getMatch(matchId);
594
- } else {
595
- return match;
596
- }
426
+ var loadRouteMatch = async (inner, matchPromises, index) => {
427
+ async function handleLoader(preload, prevMatch, previousRouteMatchId, match, route) {
428
+ const age = Date.now() - prevMatch.updatedAt;
429
+ const staleAge = preload ? route.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
430
+ const shouldReloadOption = route.options.shouldReload;
431
+ const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext(inner, matchPromises, matchId, index, route)) : shouldReloadOption;
432
+ const { status, invalid } = match;
433
+ const staleMatchShouldReload = age > staleAge && (!!inner.forceStaleReload || match.cause === "enter" || previousRouteMatchId !== void 0 && previousRouteMatchId !== match.id);
434
+ loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? staleMatchShouldReload));
435
+ if (preload && route.options.preload === false) {} else if (loaderShouldRunAsync && !inner.sync && shouldReloadInBackground) {
436
+ loaderIsRunningAsync = true;
437
+ (async () => {
438
+ try {
439
+ await runLoader(inner, matchPromises, matchId, index, route);
440
+ const match = inner.router.getMatch(matchId);
441
+ match._nonReactive.loaderPromise?.resolve();
442
+ match._nonReactive.loadPromise?.resolve();
443
+ match._nonReactive.loaderPromise = void 0;
444
+ match._nonReactive.loadPromise = void 0;
445
+ } catch (err) {
446
+ if (require_redirect.isRedirect(err)) await inner.router.navigate(err.options);
447
+ }
448
+ })();
449
+ } else if (status !== "success" || loaderShouldRunAsync) await runLoader(inner, matchPromises, matchId, index, route);
450
+ else syncMatchContext(inner, matchId, index);
451
+ }
452
+ const { id: matchId, routeId } = inner.matches[index];
453
+ let loaderShouldRunAsync = false;
454
+ let loaderIsRunningAsync = false;
455
+ const route = inner.router.looseRoutesById[routeId];
456
+ const routeLoader = route.options.loader;
457
+ const shouldReloadInBackground = ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? inner.router.options.defaultStaleReloadMode) !== "blocking";
458
+ if (shouldSkipLoader(inner, matchId)) {
459
+ if (!inner.router.getMatch(matchId)) return inner.matches[index];
460
+ syncMatchContext(inner, matchId, index);
461
+ if (_tanstack_router_core_isServer.isServer ?? inner.router.isServer) return inner.router.getMatch(matchId);
462
+ } else {
463
+ const prevMatch = inner.router.getMatch(matchId);
464
+ const previousRouteMatchId = inner.router.state.matches[index]?.routeId === routeId ? inner.router.state.matches[index].id : inner.router.state.matches.find((d) => d.routeId === routeId)?.id;
465
+ const preload = resolvePreload(inner, matchId);
466
+ if (prevMatch._nonReactive.loaderPromise) {
467
+ if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload && shouldReloadInBackground) return prevMatch;
468
+ await prevMatch._nonReactive.loaderPromise;
469
+ const match = inner.router.getMatch(matchId);
470
+ const error = match._nonReactive.error || match.error;
471
+ if (error) handleRedirectAndNotFound(inner, match, error);
472
+ if (match.status === "pending") await handleLoader(preload, prevMatch, previousRouteMatchId, match, route);
473
+ } else {
474
+ const nextPreload = preload && !inner.router.state.matches.some((d) => d.id === matchId);
475
+ const match = inner.router.getMatch(matchId);
476
+ match._nonReactive.loaderPromise = require_utils.createControlledPromise();
477
+ if (nextPreload !== match.preload) inner.updateMatch(matchId, (prev) => ({
478
+ ...prev,
479
+ preload: nextPreload
480
+ }));
481
+ await handleLoader(preload, prevMatch, previousRouteMatchId, match, route);
482
+ }
483
+ }
484
+ const match = inner.router.getMatch(matchId);
485
+ if (!loaderIsRunningAsync) {
486
+ match._nonReactive.loaderPromise?.resolve();
487
+ match._nonReactive.loadPromise?.resolve();
488
+ match._nonReactive.loadPromise = void 0;
489
+ }
490
+ clearTimeout(match._nonReactive.pendingTimeout);
491
+ match._nonReactive.pendingTimeout = void 0;
492
+ if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
493
+ match._nonReactive.dehydrated = void 0;
494
+ const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
495
+ if (nextIsFetching !== match.isFetching || match.invalid !== false) {
496
+ inner.updateMatch(matchId, (prev) => ({
497
+ ...prev,
498
+ isFetching: nextIsFetching,
499
+ invalid: false
500
+ }));
501
+ return inner.router.getMatch(matchId);
502
+ } else return match;
597
503
  };
598
504
  async function loadMatches(arg) {
599
- const inner = arg;
600
- const matchPromises = [];
601
- if (!(isServer.isServer ?? inner.router.isServer) && inner.router.state.matches.some((d) => d._forcePending)) {
602
- triggerOnReady(inner);
603
- }
604
- let beforeLoadNotFound;
605
- for (let i = 0; i < inner.matches.length; i++) {
606
- try {
607
- const beforeLoad = handleBeforeLoad(inner, i);
608
- if (utils.isPromise(beforeLoad)) await beforeLoad;
609
- } catch (err) {
610
- if (redirect.isRedirect(err)) {
611
- throw err;
612
- }
613
- if (notFound.isNotFound(err)) {
614
- beforeLoadNotFound = err;
615
- } else {
616
- if (!inner.preload) throw err;
617
- }
618
- break;
619
- }
620
- if (inner.serialError) {
621
- break;
622
- }
623
- }
624
- const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length;
625
- const boundaryIndex = beforeLoadNotFound && !inner.preload ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound) : void 0;
626
- const maxIndexExclusive = beforeLoadNotFound && inner.preload ? 0 : boundaryIndex !== void 0 ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive) : baseMaxIndexExclusive;
627
- let firstNotFound;
628
- let firstUnhandledRejection;
629
- for (let i = 0; i < maxIndexExclusive; i++) {
630
- matchPromises.push(loadRouteMatch(inner, matchPromises, i));
631
- }
632
- try {
633
- await Promise.all(matchPromises);
634
- } catch {
635
- const settled = await Promise.allSettled(matchPromises);
636
- for (const result of settled) {
637
- if (result.status !== "rejected") continue;
638
- const reason = result.reason;
639
- if (redirect.isRedirect(reason)) {
640
- throw reason;
641
- }
642
- if (notFound.isNotFound(reason)) {
643
- firstNotFound ??= reason;
644
- } else {
645
- firstUnhandledRejection ??= reason;
646
- }
647
- }
648
- if (firstUnhandledRejection !== void 0) {
649
- throw firstUnhandledRejection;
650
- }
651
- }
652
- const notFoundToThrow = firstNotFound ?? (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : void 0);
653
- let headMaxIndex = inner.serialError ? inner.firstBadMatchIndex ?? 0 : inner.matches.length - 1;
654
- if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {
655
- return inner.matches;
656
- }
657
- if (notFoundToThrow) {
658
- const renderedBoundaryIndex = getNotFoundBoundaryIndex(
659
- inner,
660
- notFoundToThrow
661
- );
662
- invariant(
663
- renderedBoundaryIndex !== void 0,
664
- "Could not find match for notFound boundary"
665
- );
666
- const boundaryMatch = inner.matches[renderedBoundaryIndex];
667
- const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId];
668
- const defaultNotFoundComponent = inner.router.options?.defaultNotFoundComponent;
669
- if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {
670
- boundaryRoute.options.notFoundComponent = defaultNotFoundComponent;
671
- }
672
- notFoundToThrow.routeId = boundaryMatch.routeId;
673
- const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id;
674
- inner.updateMatch(boundaryMatch.id, (prev) => ({
675
- ...prev,
676
- ...boundaryIsRoot ? (
677
- // For root boundary, use globalNotFound so the root component's
678
- // shell still renders and <Outlet> handles the not-found display,
679
- // instead of replacing the entire root shell via status='notFound'.
680
- { status: "success", globalNotFound: true, error: void 0 }
681
- ) : (
682
- // For non-root boundaries, set status:'notFound' so MatchInner
683
- // renders the notFoundComponent directly.
684
- { status: "notFound", error: notFoundToThrow }
685
- ),
686
- isFetching: false
687
- }));
688
- headMaxIndex = renderedBoundaryIndex;
689
- await loadRouteChunk(boundaryRoute, ["notFoundComponent"]);
690
- } else if (!inner.preload) {
691
- const rootMatch = inner.matches[0];
692
- if (!rootMatch.globalNotFound) {
693
- const currentRootMatch = inner.router.getMatch(rootMatch.id);
694
- if (currentRootMatch?.globalNotFound) {
695
- inner.updateMatch(rootMatch.id, (prev) => ({
696
- ...prev,
697
- globalNotFound: false,
698
- error: void 0
699
- }));
700
- }
701
- }
702
- }
703
- if (inner.serialError && inner.firstBadMatchIndex !== void 0) {
704
- const errorRoute = inner.router.looseRoutesById[inner.matches[inner.firstBadMatchIndex].routeId];
705
- await loadRouteChunk(errorRoute, ["errorComponent"]);
706
- }
707
- for (let i = 0; i <= headMaxIndex; i++) {
708
- const match = inner.matches[i];
709
- const { id: matchId, routeId } = match;
710
- const route = inner.router.looseRoutesById[routeId];
711
- try {
712
- const headResult = executeHead(inner, matchId, route);
713
- if (headResult) {
714
- const head = await headResult;
715
- inner.updateMatch(matchId, (prev) => ({
716
- ...prev,
717
- ...head
718
- }));
719
- }
720
- } catch (err) {
721
- console.error(`Error executing head for route ${routeId}:`, err);
722
- }
723
- }
724
- const readyPromise = triggerOnReady(inner);
725
- if (utils.isPromise(readyPromise)) {
726
- await readyPromise;
727
- }
728
- if (notFoundToThrow) {
729
- throw notFoundToThrow;
730
- }
731
- if (inner.serialError && !inner.preload && !inner.onReady) {
732
- throw inner.serialError;
733
- }
734
- return inner.matches;
505
+ const inner = arg;
506
+ const matchPromises = [];
507
+ if (!(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) && inner.router.state.matches.some((d) => d._forcePending)) triggerOnReady(inner);
508
+ let beforeLoadNotFound;
509
+ for (let i = 0; i < inner.matches.length; i++) {
510
+ try {
511
+ const beforeLoad = handleBeforeLoad(inner, i);
512
+ if (require_utils.isPromise(beforeLoad)) await beforeLoad;
513
+ } catch (err) {
514
+ if (require_redirect.isRedirect(err)) throw err;
515
+ if (require_not_found.isNotFound(err)) beforeLoadNotFound = err;
516
+ else if (!inner.preload) throw err;
517
+ break;
518
+ }
519
+ if (inner.serialError) break;
520
+ }
521
+ const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length;
522
+ const boundaryIndex = beforeLoadNotFound && !inner.preload ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound) : void 0;
523
+ const maxIndexExclusive = beforeLoadNotFound && inner.preload ? 0 : boundaryIndex !== void 0 ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive) : baseMaxIndexExclusive;
524
+ let firstNotFound;
525
+ let firstUnhandledRejection;
526
+ for (let i = 0; i < maxIndexExclusive; i++) matchPromises.push(loadRouteMatch(inner, matchPromises, i));
527
+ try {
528
+ await Promise.all(matchPromises);
529
+ } catch {
530
+ const settled = await Promise.allSettled(matchPromises);
531
+ for (const result of settled) {
532
+ if (result.status !== "rejected") continue;
533
+ const reason = result.reason;
534
+ if (require_redirect.isRedirect(reason)) throw reason;
535
+ if (require_not_found.isNotFound(reason)) firstNotFound ??= reason;
536
+ else firstUnhandledRejection ??= reason;
537
+ }
538
+ if (firstUnhandledRejection !== void 0) throw firstUnhandledRejection;
539
+ }
540
+ const notFoundToThrow = firstNotFound ?? (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : void 0);
541
+ let headMaxIndex = inner.serialError ? inner.firstBadMatchIndex ?? 0 : inner.matches.length - 1;
542
+ if (!notFoundToThrow && beforeLoadNotFound && inner.preload) return inner.matches;
543
+ if (notFoundToThrow) {
544
+ const renderedBoundaryIndex = getNotFoundBoundaryIndex(inner, notFoundToThrow);
545
+ (0, tiny_invariant.default)(renderedBoundaryIndex !== void 0, "Could not find match for notFound boundary");
546
+ const boundaryMatch = inner.matches[renderedBoundaryIndex];
547
+ const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId];
548
+ const defaultNotFoundComponent = inner.router.options?.defaultNotFoundComponent;
549
+ if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) boundaryRoute.options.notFoundComponent = defaultNotFoundComponent;
550
+ notFoundToThrow.routeId = boundaryMatch.routeId;
551
+ const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id;
552
+ inner.updateMatch(boundaryMatch.id, (prev) => ({
553
+ ...prev,
554
+ ...boundaryIsRoot ? {
555
+ status: "success",
556
+ globalNotFound: true,
557
+ error: void 0
558
+ } : {
559
+ status: "notFound",
560
+ error: notFoundToThrow
561
+ },
562
+ isFetching: false
563
+ }));
564
+ headMaxIndex = renderedBoundaryIndex;
565
+ await loadRouteChunk(boundaryRoute, ["notFoundComponent"]);
566
+ } else if (!inner.preload) {
567
+ const rootMatch = inner.matches[0];
568
+ if (!rootMatch.globalNotFound) {
569
+ if (inner.router.getMatch(rootMatch.id)?.globalNotFound) inner.updateMatch(rootMatch.id, (prev) => ({
570
+ ...prev,
571
+ globalNotFound: false,
572
+ error: void 0
573
+ }));
574
+ }
575
+ }
576
+ if (inner.serialError && inner.firstBadMatchIndex !== void 0) {
577
+ const errorRoute = inner.router.looseRoutesById[inner.matches[inner.firstBadMatchIndex].routeId];
578
+ await loadRouteChunk(errorRoute, ["errorComponent"]);
579
+ }
580
+ for (let i = 0; i <= headMaxIndex; i++) {
581
+ const { id: matchId, routeId } = inner.matches[i];
582
+ const route = inner.router.looseRoutesById[routeId];
583
+ try {
584
+ const headResult = executeHead(inner, matchId, route);
585
+ if (headResult) {
586
+ const head = await headResult;
587
+ inner.updateMatch(matchId, (prev) => ({
588
+ ...prev,
589
+ ...head
590
+ }));
591
+ }
592
+ } catch (err) {
593
+ console.error(`Error executing head for route ${routeId}:`, err);
594
+ }
595
+ }
596
+ const readyPromise = triggerOnReady(inner);
597
+ if (require_utils.isPromise(readyPromise)) await readyPromise;
598
+ if (notFoundToThrow) throw notFoundToThrow;
599
+ if (inner.serialError && !inner.preload && !inner.onReady) throw inner.serialError;
600
+ return inner.matches;
735
601
  }
736
602
  function preloadRouteComponents(route, componentTypesToLoad) {
737
- const preloads = componentTypesToLoad.map((type) => route.options[type]?.preload?.()).filter(Boolean);
738
- if (preloads.length === 0) return void 0;
739
- return Promise.all(preloads);
603
+ const preloads = componentTypesToLoad.map((type) => route.options[type]?.preload?.()).filter(Boolean);
604
+ if (preloads.length === 0) return void 0;
605
+ return Promise.all(preloads);
740
606
  }
741
607
  function loadRouteChunk(route, componentTypesToLoad = componentTypes) {
742
- if (!route._lazyLoaded && route._lazyPromise === void 0) {
743
- if (route.lazyFn) {
744
- route._lazyPromise = route.lazyFn().then((lazyRoute) => {
745
- const { id: _id, ...options } = lazyRoute.options;
746
- Object.assign(route.options, options);
747
- route._lazyLoaded = true;
748
- route._lazyPromise = void 0;
749
- });
750
- } else {
751
- route._lazyLoaded = true;
752
- }
753
- }
754
- const runAfterLazy = () => route._componentsLoaded ? void 0 : componentTypesToLoad === componentTypes ? (() => {
755
- if (route._componentsPromise === void 0) {
756
- const componentsPromise = preloadRouteComponents(
757
- route,
758
- componentTypes
759
- );
760
- if (componentsPromise) {
761
- route._componentsPromise = componentsPromise.then(() => {
762
- route._componentsLoaded = true;
763
- route._componentsPromise = void 0;
764
- });
765
- } else {
766
- route._componentsLoaded = true;
767
- }
768
- }
769
- return route._componentsPromise;
770
- })() : preloadRouteComponents(route, componentTypesToLoad);
771
- return route._lazyPromise ? route._lazyPromise.then(runAfterLazy) : runAfterLazy();
608
+ if (!route._lazyLoaded && route._lazyPromise === void 0) if (route.lazyFn) route._lazyPromise = route.lazyFn().then((lazyRoute) => {
609
+ const { id: _id, ...options } = lazyRoute.options;
610
+ Object.assign(route.options, options);
611
+ route._lazyLoaded = true;
612
+ route._lazyPromise = void 0;
613
+ });
614
+ else route._lazyLoaded = true;
615
+ const runAfterLazy = () => route._componentsLoaded ? void 0 : componentTypesToLoad === componentTypes ? (() => {
616
+ if (route._componentsPromise === void 0) {
617
+ const componentsPromise = preloadRouteComponents(route, componentTypes);
618
+ if (componentsPromise) route._componentsPromise = componentsPromise.then(() => {
619
+ route._componentsLoaded = true;
620
+ route._componentsPromise = void 0;
621
+ });
622
+ else route._componentsLoaded = true;
623
+ }
624
+ return route._componentsPromise;
625
+ })() : preloadRouteComponents(route, componentTypesToLoad);
626
+ return route._lazyPromise ? route._lazyPromise.then(runAfterLazy) : runAfterLazy();
772
627
  }
773
628
  function makeMaybe(value, error) {
774
- if (error) {
775
- return { status: "error", error };
776
- }
777
- return { status: "success", value };
629
+ if (error) return {
630
+ status: "error",
631
+ error
632
+ };
633
+ return {
634
+ status: "success",
635
+ value
636
+ };
778
637
  }
779
638
  function routeNeedsPreload(route) {
780
- for (const componentType of componentTypes) {
781
- if (route.options[componentType]?.preload) {
782
- return true;
783
- }
784
- }
785
- return false;
639
+ for (const componentType of componentTypes) if (route.options[componentType]?.preload) return true;
640
+ return false;
786
641
  }
787
- const componentTypes = [
788
- "component",
789
- "errorComponent",
790
- "pendingComponent",
791
- "notFoundComponent"
642
+ var componentTypes = [
643
+ "component",
644
+ "errorComponent",
645
+ "pendingComponent",
646
+ "notFoundComponent"
792
647
  ];
793
- exports.componentTypes = componentTypes;
648
+ //#endregion
794
649
  exports.loadMatches = loadMatches;
795
650
  exports.loadRouteChunk = loadRouteChunk;
796
651
  exports.routeNeedsPreload = routeNeedsPreload;
797
- //# sourceMappingURL=load-matches.cjs.map
652
+
653
+ //# sourceMappingURL=load-matches.cjs.map