@tanstack/router-core 1.167.1 → 1.167.2

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 (162) 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 +619 -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 +1153 -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 +614 -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 +1147 -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/dist/cjs/index.cjs.map +0 -1
  158. package/dist/cjs/ssr/client.cjs.map +0 -1
  159. package/dist/cjs/ssr/server.cjs.map +0 -1
  160. package/dist/esm/index.js.map +0 -1
  161. package/dist/esm/ssr/client.js.map +0 -1
  162. package/dist/esm/ssr/server.js.map +0 -1
@@ -1,797 +1,650 @@
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
+ const prevLoadPromise = match._nonReactive.loadPromise;
191
+ match._nonReactive.loadPromise = require_utils.createControlledPromise(() => {
192
+ prevLoadPromise?.resolve();
193
+ });
194
+ const { paramsError, searchError } = match;
195
+ if (paramsError) handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
196
+ if (searchError) handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
197
+ setupPendingTimeout(inner, matchId, route, match);
198
+ const abortController = new AbortController();
199
+ let isPending = false;
200
+ const pending = () => {
201
+ if (isPending) return;
202
+ isPending = true;
203
+ inner.updateMatch(matchId, (prev) => ({
204
+ ...prev,
205
+ isFetching: "beforeLoad",
206
+ fetchCount: prev.fetchCount + 1,
207
+ abortController
208
+ }));
209
+ };
210
+ const resolve = () => {
211
+ match._nonReactive.beforeLoadPromise?.resolve();
212
+ match._nonReactive.beforeLoadPromise = void 0;
213
+ inner.updateMatch(matchId, (prev) => ({
214
+ ...prev,
215
+ isFetching: false
216
+ }));
217
+ };
218
+ if (!route.options.beforeLoad) {
219
+ require_batch.batch(() => {
220
+ pending();
221
+ resolve();
222
+ });
223
+ return;
224
+ }
225
+ match._nonReactive.beforeLoadPromise = require_utils.createControlledPromise();
226
+ const context = {
227
+ ...buildMatchContext(inner, index, false),
228
+ ...match.__routeContext
229
+ };
230
+ const { search, params, cause } = match;
231
+ const preload = resolvePreload(inner, matchId);
232
+ const beforeLoadFnContext = {
233
+ search,
234
+ abortController,
235
+ params,
236
+ preload,
237
+ context,
238
+ location: inner.location,
239
+ navigate: (opts) => inner.router.navigate({
240
+ ...opts,
241
+ _fromLocation: inner.location
242
+ }),
243
+ buildLocation: inner.router.buildLocation,
244
+ cause: preload ? "preload" : cause,
245
+ matches: inner.matches,
246
+ routeId: route.id,
247
+ ...inner.router.options.additionalContext
248
+ };
249
+ const updateContext = (beforeLoadContext) => {
250
+ if (beforeLoadContext === void 0) {
251
+ require_batch.batch(() => {
252
+ pending();
253
+ resolve();
254
+ });
255
+ return;
256
+ }
257
+ if (require_redirect.isRedirect(beforeLoadContext) || require_not_found.isNotFound(beforeLoadContext)) {
258
+ pending();
259
+ handleSerialError(inner, index, beforeLoadContext, "BEFORE_LOAD");
260
+ }
261
+ require_batch.batch(() => {
262
+ pending();
263
+ inner.updateMatch(matchId, (prev) => ({
264
+ ...prev,
265
+ __beforeLoadContext: beforeLoadContext
266
+ }));
267
+ resolve();
268
+ });
269
+ };
270
+ let beforeLoadContext;
271
+ try {
272
+ beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
273
+ if (require_utils.isPromise(beforeLoadContext)) {
274
+ pending();
275
+ return beforeLoadContext.catch((err) => {
276
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
277
+ }).then(updateContext);
278
+ }
279
+ } catch (err) {
280
+ pending();
281
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
282
+ }
283
+ updateContext(beforeLoadContext);
321
284
  };
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();
285
+ var handleBeforeLoad = (inner, index) => {
286
+ const { id: matchId, routeId } = inner.matches[index];
287
+ const route = inner.router.looseRoutesById[routeId];
288
+ const serverSsr = () => {
289
+ if (_tanstack_router_core_isServer.isServer ?? inner.router.isServer) {
290
+ const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
291
+ if (require_utils.isPromise(maybePromise)) return maybePromise.then(queueExecution);
292
+ }
293
+ return queueExecution();
294
+ };
295
+ const execute = () => executeBeforeLoad(inner, matchId, index, route);
296
+ const queueExecution = () => {
297
+ if (shouldSkipLoader(inner, matchId)) return;
298
+ const result = preBeforeLoadSetup(inner, matchId, route);
299
+ return require_utils.isPromise(result) ? result.then(execute) : execute();
300
+ };
301
+ return serverSsr();
339
302
  };
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
- });
303
+ var executeHead = (inner, matchId, route) => {
304
+ const match = inner.router.getMatch(matchId);
305
+ if (!match) return;
306
+ if (!route.options.head && !route.options.scripts && !route.options.headers) return;
307
+ const assetContext = {
308
+ ssr: inner.router.options.ssr,
309
+ matches: inner.matches,
310
+ match,
311
+ params: match.params,
312
+ loaderData: match.loaderData
313
+ };
314
+ return Promise.all([
315
+ route.options.head?.(assetContext),
316
+ route.options.scripts?.(assetContext),
317
+ route.options.headers?.(assetContext)
318
+ ]).then(([headFnContent, scripts, headers]) => {
319
+ return {
320
+ meta: headFnContent?.meta,
321
+ links: headFnContent?.links,
322
+ headScripts: headFnContent?.scripts,
323
+ headers,
324
+ scripts,
325
+ styles: headFnContent?.styles
326
+ };
327
+ });
373
328
  };
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
- };
329
+ var getLoaderContext = (inner, matchPromises, matchId, index, route) => {
330
+ const parentMatchPromise = matchPromises[index - 1];
331
+ const { params, loaderDeps, abortController, cause } = inner.router.getMatch(matchId);
332
+ const context = buildMatchContext(inner, index);
333
+ const preload = resolvePreload(inner, matchId);
334
+ return {
335
+ params,
336
+ deps: loaderDeps,
337
+ preload: !!preload,
338
+ parentMatchPromise,
339
+ abortController,
340
+ context,
341
+ location: inner.location,
342
+ navigate: (opts) => inner.router.navigate({
343
+ ...opts,
344
+ _fromLocation: inner.location
345
+ }),
346
+ cause: preload ? "preload" : cause,
347
+ route,
348
+ ...inner.router.options.additionalContext
349
+ };
395
350
  };
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
- }
351
+ var runLoader = async (inner, matchPromises, matchId, index, route) => {
352
+ try {
353
+ const match = inner.router.getMatch(matchId);
354
+ try {
355
+ if (!(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) || match.ssr === true) loadRouteChunk(route);
356
+ const routeLoader = route.options.loader;
357
+ const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
358
+ const loaderResult = loader?.(getLoaderContext(inner, matchPromises, matchId, index, route));
359
+ const loaderResultIsPromise = !!loader && require_utils.isPromise(loaderResult);
360
+ if (!!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise)) inner.updateMatch(matchId, (prev) => ({
361
+ ...prev,
362
+ isFetching: "loader"
363
+ }));
364
+ if (loader) {
365
+ const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
366
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), loaderData);
367
+ if (loaderData !== void 0) inner.updateMatch(matchId, (prev) => ({
368
+ ...prev,
369
+ loaderData
370
+ }));
371
+ }
372
+ if (route._lazyPromise) await route._lazyPromise;
373
+ const pendingPromise = match._nonReactive.minPendingPromise;
374
+ if (pendingPromise) await pendingPromise;
375
+ if (route._componentsPromise) await route._componentsPromise;
376
+ inner.updateMatch(matchId, (prev) => ({
377
+ ...prev,
378
+ error: void 0,
379
+ context: buildMatchContext(inner, index),
380
+ status: "success",
381
+ isFetching: false,
382
+ updatedAt: Date.now()
383
+ }));
384
+ } catch (e) {
385
+ let error = e;
386
+ if (error?.name === "AbortError") {
387
+ if (match.abortController.signal.aborted) {
388
+ match._nonReactive.loaderPromise?.resolve();
389
+ match._nonReactive.loaderPromise = void 0;
390
+ return;
391
+ }
392
+ inner.updateMatch(matchId, (prev) => ({
393
+ ...prev,
394
+ status: prev.status === "pending" ? "success" : prev.status,
395
+ isFetching: false,
396
+ context: buildMatchContext(inner, index)
397
+ }));
398
+ return;
399
+ }
400
+ const pendingPromise = match._nonReactive.minPendingPromise;
401
+ if (pendingPromise) await pendingPromise;
402
+ if (require_not_found.isNotFound(e)) await route.options.notFoundComponent?.preload?.();
403
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
404
+ try {
405
+ route.options.onError?.(e);
406
+ } catch (onErrorError) {
407
+ error = onErrorError;
408
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), onErrorError);
409
+ }
410
+ if (!require_redirect.isRedirect(error) && !require_not_found.isNotFound(error)) await loadRouteChunk(route, ["errorComponent"]);
411
+ inner.updateMatch(matchId, (prev) => ({
412
+ ...prev,
413
+ error,
414
+ context: buildMatchContext(inner, index),
415
+ status: "error",
416
+ isFetching: false
417
+ }));
418
+ }
419
+ } catch (err) {
420
+ const match = inner.router.getMatch(matchId);
421
+ if (match) match._nonReactive.loaderPromise = void 0;
422
+ handleRedirectAndNotFound(inner, match, err);
423
+ }
492
424
  };
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
- }
425
+ var loadRouteMatch = async (inner, matchPromises, index) => {
426
+ async function handleLoader(preload, prevMatch, previousRouteMatchId, match, route) {
427
+ const age = Date.now() - prevMatch.updatedAt;
428
+ const staleAge = preload ? route.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
429
+ const shouldReloadOption = route.options.shouldReload;
430
+ const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext(inner, matchPromises, matchId, index, route)) : shouldReloadOption;
431
+ const { status, invalid } = match;
432
+ const staleMatchShouldReload = age > staleAge && (!!inner.forceStaleReload || match.cause === "enter" || previousRouteMatchId !== void 0 && previousRouteMatchId !== match.id);
433
+ loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? staleMatchShouldReload));
434
+ if (preload && route.options.preload === false) {} else if (loaderShouldRunAsync && !inner.sync && shouldReloadInBackground) {
435
+ loaderIsRunningAsync = true;
436
+ (async () => {
437
+ try {
438
+ await runLoader(inner, matchPromises, matchId, index, route);
439
+ const match = inner.router.getMatch(matchId);
440
+ match._nonReactive.loaderPromise?.resolve();
441
+ match._nonReactive.loadPromise?.resolve();
442
+ match._nonReactive.loaderPromise = void 0;
443
+ } catch (err) {
444
+ if (require_redirect.isRedirect(err)) await inner.router.navigate(err.options);
445
+ }
446
+ })();
447
+ } else if (status !== "success" || loaderShouldRunAsync) await runLoader(inner, matchPromises, matchId, index, route);
448
+ else syncMatchContext(inner, matchId, index);
449
+ }
450
+ const { id: matchId, routeId } = inner.matches[index];
451
+ let loaderShouldRunAsync = false;
452
+ let loaderIsRunningAsync = false;
453
+ const route = inner.router.looseRoutesById[routeId];
454
+ const routeLoader = route.options.loader;
455
+ const shouldReloadInBackground = ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? inner.router.options.defaultStaleReloadMode) !== "blocking";
456
+ if (shouldSkipLoader(inner, matchId)) {
457
+ if (!inner.router.getMatch(matchId)) return inner.matches[index];
458
+ syncMatchContext(inner, matchId, index);
459
+ if (_tanstack_router_core_isServer.isServer ?? inner.router.isServer) return inner.router.getMatch(matchId);
460
+ } else {
461
+ const prevMatch = inner.router.getMatch(matchId);
462
+ 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;
463
+ const preload = resolvePreload(inner, matchId);
464
+ if (prevMatch._nonReactive.loaderPromise) {
465
+ if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload && shouldReloadInBackground) return prevMatch;
466
+ await prevMatch._nonReactive.loaderPromise;
467
+ const match = inner.router.getMatch(matchId);
468
+ const error = match._nonReactive.error || match.error;
469
+ if (error) handleRedirectAndNotFound(inner, match, error);
470
+ if (match.status === "pending") await handleLoader(preload, prevMatch, previousRouteMatchId, match, route);
471
+ } else {
472
+ const nextPreload = preload && !inner.router.state.matches.some((d) => d.id === matchId);
473
+ const match = inner.router.getMatch(matchId);
474
+ match._nonReactive.loaderPromise = require_utils.createControlledPromise();
475
+ if (nextPreload !== match.preload) inner.updateMatch(matchId, (prev) => ({
476
+ ...prev,
477
+ preload: nextPreload
478
+ }));
479
+ await handleLoader(preload, prevMatch, previousRouteMatchId, match, route);
480
+ }
481
+ }
482
+ const match = inner.router.getMatch(matchId);
483
+ if (!loaderIsRunningAsync) {
484
+ match._nonReactive.loaderPromise?.resolve();
485
+ match._nonReactive.loadPromise?.resolve();
486
+ }
487
+ clearTimeout(match._nonReactive.pendingTimeout);
488
+ match._nonReactive.pendingTimeout = void 0;
489
+ if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
490
+ match._nonReactive.dehydrated = void 0;
491
+ const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
492
+ if (nextIsFetching !== match.isFetching || match.invalid !== false) {
493
+ inner.updateMatch(matchId, (prev) => ({
494
+ ...prev,
495
+ isFetching: nextIsFetching,
496
+ invalid: false
497
+ }));
498
+ return inner.router.getMatch(matchId);
499
+ } else return match;
597
500
  };
598
501
  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;
502
+ const inner = arg;
503
+ const matchPromises = [];
504
+ if (!(_tanstack_router_core_isServer.isServer ?? inner.router.isServer) && inner.router.state.matches.some((d) => d._forcePending)) triggerOnReady(inner);
505
+ let beforeLoadNotFound;
506
+ for (let i = 0; i < inner.matches.length; i++) {
507
+ try {
508
+ const beforeLoad = handleBeforeLoad(inner, i);
509
+ if (require_utils.isPromise(beforeLoad)) await beforeLoad;
510
+ } catch (err) {
511
+ if (require_redirect.isRedirect(err)) throw err;
512
+ if (require_not_found.isNotFound(err)) beforeLoadNotFound = err;
513
+ else if (!inner.preload) throw err;
514
+ break;
515
+ }
516
+ if (inner.serialError) break;
517
+ }
518
+ const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length;
519
+ const boundaryIndex = beforeLoadNotFound && !inner.preload ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound) : void 0;
520
+ const maxIndexExclusive = beforeLoadNotFound && inner.preload ? 0 : boundaryIndex !== void 0 ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive) : baseMaxIndexExclusive;
521
+ let firstNotFound;
522
+ let firstUnhandledRejection;
523
+ for (let i = 0; i < maxIndexExclusive; i++) matchPromises.push(loadRouteMatch(inner, matchPromises, i));
524
+ try {
525
+ await Promise.all(matchPromises);
526
+ } catch {
527
+ const settled = await Promise.allSettled(matchPromises);
528
+ for (const result of settled) {
529
+ if (result.status !== "rejected") continue;
530
+ const reason = result.reason;
531
+ if (require_redirect.isRedirect(reason)) throw reason;
532
+ if (require_not_found.isNotFound(reason)) firstNotFound ??= reason;
533
+ else firstUnhandledRejection ??= reason;
534
+ }
535
+ if (firstUnhandledRejection !== void 0) throw firstUnhandledRejection;
536
+ }
537
+ const notFoundToThrow = firstNotFound ?? (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : void 0);
538
+ let headMaxIndex = inner.serialError ? inner.firstBadMatchIndex ?? 0 : inner.matches.length - 1;
539
+ if (!notFoundToThrow && beforeLoadNotFound && inner.preload) return inner.matches;
540
+ if (notFoundToThrow) {
541
+ const renderedBoundaryIndex = getNotFoundBoundaryIndex(inner, notFoundToThrow);
542
+ (0, tiny_invariant.default)(renderedBoundaryIndex !== void 0, "Could not find match for notFound boundary");
543
+ const boundaryMatch = inner.matches[renderedBoundaryIndex];
544
+ const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId];
545
+ const defaultNotFoundComponent = inner.router.options?.defaultNotFoundComponent;
546
+ if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) boundaryRoute.options.notFoundComponent = defaultNotFoundComponent;
547
+ notFoundToThrow.routeId = boundaryMatch.routeId;
548
+ const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id;
549
+ inner.updateMatch(boundaryMatch.id, (prev) => ({
550
+ ...prev,
551
+ ...boundaryIsRoot ? {
552
+ status: "success",
553
+ globalNotFound: true,
554
+ error: void 0
555
+ } : {
556
+ status: "notFound",
557
+ error: notFoundToThrow
558
+ },
559
+ isFetching: false
560
+ }));
561
+ headMaxIndex = renderedBoundaryIndex;
562
+ await loadRouteChunk(boundaryRoute, ["notFoundComponent"]);
563
+ } else if (!inner.preload) {
564
+ const rootMatch = inner.matches[0];
565
+ if (!rootMatch.globalNotFound) {
566
+ if (inner.router.getMatch(rootMatch.id)?.globalNotFound) inner.updateMatch(rootMatch.id, (prev) => ({
567
+ ...prev,
568
+ globalNotFound: false,
569
+ error: void 0
570
+ }));
571
+ }
572
+ }
573
+ if (inner.serialError && inner.firstBadMatchIndex !== void 0) {
574
+ const errorRoute = inner.router.looseRoutesById[inner.matches[inner.firstBadMatchIndex].routeId];
575
+ await loadRouteChunk(errorRoute, ["errorComponent"]);
576
+ }
577
+ for (let i = 0; i <= headMaxIndex; i++) {
578
+ const { id: matchId, routeId } = inner.matches[i];
579
+ const route = inner.router.looseRoutesById[routeId];
580
+ try {
581
+ const headResult = executeHead(inner, matchId, route);
582
+ if (headResult) {
583
+ const head = await headResult;
584
+ inner.updateMatch(matchId, (prev) => ({
585
+ ...prev,
586
+ ...head
587
+ }));
588
+ }
589
+ } catch (err) {
590
+ console.error(`Error executing head for route ${routeId}:`, err);
591
+ }
592
+ }
593
+ const readyPromise = triggerOnReady(inner);
594
+ if (require_utils.isPromise(readyPromise)) await readyPromise;
595
+ if (notFoundToThrow) throw notFoundToThrow;
596
+ if (inner.serialError && !inner.preload && !inner.onReady) throw inner.serialError;
597
+ return inner.matches;
735
598
  }
736
599
  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);
600
+ const preloads = componentTypesToLoad.map((type) => route.options[type]?.preload?.()).filter(Boolean);
601
+ if (preloads.length === 0) return void 0;
602
+ return Promise.all(preloads);
740
603
  }
741
604
  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();
605
+ if (!route._lazyLoaded && route._lazyPromise === void 0) if (route.lazyFn) route._lazyPromise = route.lazyFn().then((lazyRoute) => {
606
+ const { id: _id, ...options } = lazyRoute.options;
607
+ Object.assign(route.options, options);
608
+ route._lazyLoaded = true;
609
+ route._lazyPromise = void 0;
610
+ });
611
+ else route._lazyLoaded = true;
612
+ const runAfterLazy = () => route._componentsLoaded ? void 0 : componentTypesToLoad === componentTypes ? (() => {
613
+ if (route._componentsPromise === void 0) {
614
+ const componentsPromise = preloadRouteComponents(route, componentTypes);
615
+ if (componentsPromise) route._componentsPromise = componentsPromise.then(() => {
616
+ route._componentsLoaded = true;
617
+ route._componentsPromise = void 0;
618
+ });
619
+ else route._componentsLoaded = true;
620
+ }
621
+ return route._componentsPromise;
622
+ })() : preloadRouteComponents(route, componentTypesToLoad);
623
+ return route._lazyPromise ? route._lazyPromise.then(runAfterLazy) : runAfterLazy();
772
624
  }
773
625
  function makeMaybe(value, error) {
774
- if (error) {
775
- return { status: "error", error };
776
- }
777
- return { status: "success", value };
626
+ if (error) return {
627
+ status: "error",
628
+ error
629
+ };
630
+ return {
631
+ status: "success",
632
+ value
633
+ };
778
634
  }
779
635
  function routeNeedsPreload(route) {
780
- for (const componentType of componentTypes) {
781
- if (route.options[componentType]?.preload) {
782
- return true;
783
- }
784
- }
785
- return false;
636
+ for (const componentType of componentTypes) if (route.options[componentType]?.preload) return true;
637
+ return false;
786
638
  }
787
- const componentTypes = [
788
- "component",
789
- "errorComponent",
790
- "pendingComponent",
791
- "notFoundComponent"
639
+ var componentTypes = [
640
+ "component",
641
+ "errorComponent",
642
+ "pendingComponent",
643
+ "notFoundComponent"
792
644
  ];
793
- exports.componentTypes = componentTypes;
645
+ //#endregion
794
646
  exports.loadMatches = loadMatches;
795
647
  exports.loadRouteChunk = loadRouteChunk;
796
648
  exports.routeNeedsPreload = routeNeedsPreload;
797
- //# sourceMappingURL=load-matches.cjs.map
649
+
650
+ //# sourceMappingURL=load-matches.cjs.map