@tanstack/router-core 1.171.15 → 1.171.16-pre.0

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 (134) hide show
  1. package/dist/cjs/Matches.cjs.map +1 -1
  2. package/dist/cjs/Matches.d.cts +3 -12
  3. package/dist/cjs/await-signal.cjs +21 -0
  4. package/dist/cjs/await-signal.cjs.map +1 -0
  5. package/dist/cjs/await-signal.d.cts +1 -0
  6. package/dist/cjs/index.cjs +3 -1
  7. package/dist/cjs/index.d.cts +3 -2
  8. package/dist/cjs/isServer/client.cjs +2 -0
  9. package/dist/cjs/isServer/client.cjs.map +1 -1
  10. package/dist/cjs/isServer/client.d.cts +1 -0
  11. package/dist/cjs/isServer/development.cjs +2 -0
  12. package/dist/cjs/isServer/development.cjs.map +1 -1
  13. package/dist/cjs/isServer/development.d.cts +1 -0
  14. package/dist/cjs/isServer/server.cjs +2 -0
  15. package/dist/cjs/isServer/server.cjs.map +1 -1
  16. package/dist/cjs/isServer/server.d.cts +1 -0
  17. package/dist/cjs/load-client.cjs +1470 -0
  18. package/dist/cjs/load-client.cjs.map +1 -0
  19. package/dist/cjs/load-client.d.cts +147 -0
  20. package/dist/cjs/load-server.cjs +565 -0
  21. package/dist/cjs/load-server.cjs.map +1 -0
  22. package/dist/cjs/load-server.d.cts +16 -0
  23. package/dist/cjs/redirect.cjs.map +1 -1
  24. package/dist/cjs/redirect.d.cts +0 -1
  25. package/dist/cjs/route.cjs.map +1 -1
  26. package/dist/cjs/router.cjs +187 -442
  27. package/dist/cjs/router.cjs.map +1 -1
  28. package/dist/cjs/router.d.cts +61 -51
  29. package/dist/cjs/ssr/client.cjs +2 -2
  30. package/dist/cjs/ssr/createRequestHandler.cjs +60 -9
  31. package/dist/cjs/ssr/createRequestHandler.cjs.map +1 -1
  32. package/dist/cjs/ssr/createRequestHandler.d.cts +1 -0
  33. package/dist/cjs/ssr/handlerCallback.cjs +49 -4
  34. package/dist/cjs/ssr/handlerCallback.cjs.map +1 -1
  35. package/dist/cjs/ssr/handlerCallback.d.cts +3 -0
  36. package/dist/cjs/ssr/server.cjs +4 -0
  37. package/dist/cjs/ssr/server.d.cts +2 -2
  38. package/dist/cjs/ssr/ssr-client.d.cts +1 -10
  39. package/dist/cjs/ssr/ssr-match-id.cjs +2 -2
  40. package/dist/cjs/ssr/ssr-match-id.cjs.map +1 -1
  41. package/dist/cjs/ssr/ssr-server.cjs +6 -6
  42. package/dist/cjs/ssr/ssr-server.cjs.map +1 -1
  43. package/dist/cjs/ssr/transformStreamWithRouter.cjs +27 -1
  44. package/dist/cjs/ssr/transformStreamWithRouter.cjs.map +1 -1
  45. package/dist/cjs/ssr/transformStreamWithRouter.d.cts +2 -0
  46. package/dist/cjs/ssr/types.d.cts +0 -1
  47. package/dist/cjs/stores.cjs +30 -104
  48. package/dist/cjs/stores.cjs.map +1 -1
  49. package/dist/cjs/stores.d.cts +7 -32
  50. package/dist/cjs/utils.cjs +0 -4
  51. package/dist/cjs/utils.cjs.map +1 -1
  52. package/dist/esm/Matches.d.ts +3 -12
  53. package/dist/esm/Matches.js.map +1 -1
  54. package/dist/esm/await-signal.d.ts +1 -0
  55. package/dist/esm/await-signal.js +21 -0
  56. package/dist/esm/await-signal.js.map +1 -0
  57. package/dist/esm/index.d.ts +3 -2
  58. package/dist/esm/index.js +3 -2
  59. package/dist/esm/isServer/client.d.ts +1 -0
  60. package/dist/esm/isServer/client.js +2 -1
  61. package/dist/esm/isServer/client.js.map +1 -1
  62. package/dist/esm/isServer/development.d.ts +1 -0
  63. package/dist/esm/isServer/development.js +2 -1
  64. package/dist/esm/isServer/development.js.map +1 -1
  65. package/dist/esm/isServer/server.d.ts +1 -0
  66. package/dist/esm/isServer/server.js +2 -1
  67. package/dist/esm/isServer/server.js.map +1 -1
  68. package/dist/esm/load-client.d.ts +147 -0
  69. package/dist/esm/load-client.js +1462 -0
  70. package/dist/esm/load-client.js.map +1 -0
  71. package/dist/esm/load-server.d.ts +16 -0
  72. package/dist/esm/load-server.js +565 -0
  73. package/dist/esm/load-server.js.map +1 -0
  74. package/dist/esm/redirect.d.ts +0 -1
  75. package/dist/esm/redirect.js.map +1 -1
  76. package/dist/esm/route.js.map +1 -1
  77. package/dist/esm/router.d.ts +61 -51
  78. package/dist/esm/router.js +188 -444
  79. package/dist/esm/router.js.map +1 -1
  80. package/dist/esm/ssr/client.js +1 -1
  81. package/dist/esm/ssr/createRequestHandler.d.ts +1 -0
  82. package/dist/esm/ssr/createRequestHandler.js +61 -11
  83. package/dist/esm/ssr/createRequestHandler.js.map +1 -1
  84. package/dist/esm/ssr/handlerCallback.d.ts +3 -0
  85. package/dist/esm/ssr/handlerCallback.js +47 -5
  86. package/dist/esm/ssr/handlerCallback.js.map +1 -1
  87. package/dist/esm/ssr/server.d.ts +2 -2
  88. package/dist/esm/ssr/server.js +3 -3
  89. package/dist/esm/ssr/ssr-client.d.ts +1 -10
  90. package/dist/esm/ssr/ssr-match-id.js +2 -2
  91. package/dist/esm/ssr/ssr-match-id.js.map +1 -1
  92. package/dist/esm/ssr/ssr-server.js +6 -6
  93. package/dist/esm/ssr/ssr-server.js.map +1 -1
  94. package/dist/esm/ssr/transformStreamWithRouter.d.ts +2 -0
  95. package/dist/esm/ssr/transformStreamWithRouter.js +27 -1
  96. package/dist/esm/ssr/transformStreamWithRouter.js.map +1 -1
  97. package/dist/esm/ssr/types.d.ts +0 -1
  98. package/dist/esm/stores.d.ts +7 -32
  99. package/dist/esm/stores.js +30 -104
  100. package/dist/esm/stores.js.map +1 -1
  101. package/dist/esm/utils.js +1 -4
  102. package/dist/esm/utils.js.map +1 -1
  103. package/package.json +3 -3
  104. package/src/Matches.ts +6 -21
  105. package/src/await-signal.ts +27 -0
  106. package/src/index.ts +1 -3
  107. package/src/isServer/client.ts +1 -0
  108. package/src/isServer/development.ts +1 -0
  109. package/src/isServer/server.ts +1 -0
  110. package/src/load-client.ts +2701 -0
  111. package/src/load-server.ts +849 -0
  112. package/src/redirect.ts +0 -1
  113. package/src/route.ts +2 -11
  114. package/src/router.ts +379 -769
  115. package/src/ssr/createRequestHandler.ts +109 -16
  116. package/src/ssr/handlerCallback.ts +76 -10
  117. package/src/ssr/server.ts +4 -1
  118. package/src/ssr/ssr-client.ts +1 -310
  119. package/src/ssr/ssr-match-id.ts +11 -2
  120. package/src/ssr/ssr-server.ts +9 -8
  121. package/src/ssr/transformStreamWithRouter.ts +37 -1
  122. package/src/ssr/types.ts +0 -1
  123. package/src/stores.ts +46 -208
  124. package/dist/cjs/load-matches.cjs +0 -658
  125. package/dist/cjs/load-matches.cjs.map +0 -1
  126. package/dist/cjs/load-matches.d.cts +0 -18
  127. package/dist/cjs/ssr/ssr-client.cjs +0 -183
  128. package/dist/cjs/ssr/ssr-client.cjs.map +0 -1
  129. package/dist/esm/load-matches.d.ts +0 -18
  130. package/dist/esm/load-matches.js +0 -656
  131. package/dist/esm/load-matches.js.map +0 -1
  132. package/dist/esm/ssr/ssr-client.js +0 -183
  133. package/dist/esm/ssr/ssr-client.js.map +0 -1
  134. package/src/load-matches.ts +0 -1278
@@ -0,0 +1,565 @@
1
+ import { isNotFound } from "./not-found.js";
2
+ import { rootRouteId } from "./root.js";
3
+ import { isRedirect, redirect } from "./redirect.js";
4
+ import { loadRouteChunk } from "./load-client.js";
5
+ import { getLocationChangeInfo, runRouteLifecycle } from "./router.js";
6
+ import { waitForReason } from "./await-signal.js";
7
+ //#region src/load-server.ts
8
+ const SUCCESS = 0;
9
+ const ERROR = 1;
10
+ const NOT_FOUND = 2;
11
+ const REDIRECTED = 3;
12
+ const SKIPPED = 4;
13
+ function getRoute(router, match) {
14
+ return router.routesById[match.routeId];
15
+ }
16
+ function normalize(value, rejected) {
17
+ if (isRedirect(value)) return [REDIRECTED, value];
18
+ if (isNotFound(value)) return [NOT_FOUND, value];
19
+ if (rejected && typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
20
+ return rejected ? [ERROR, value] : [SUCCESS, value];
21
+ }
22
+ function normalizeError(route, cause) {
23
+ let outcome = normalize(cause, true);
24
+ if (outcome[0] !== ERROR) return outcome;
25
+ try {
26
+ route.options.onError?.(outcome[1]);
27
+ } catch (onErrorCause) {
28
+ outcome = normalize(onErrorCause, true);
29
+ }
30
+ return outcome;
31
+ }
32
+ function maybe(value, cause) {
33
+ if (cause !== void 0) return {
34
+ status: "error",
35
+ error: cause
36
+ };
37
+ return {
38
+ status: "success",
39
+ value
40
+ };
41
+ }
42
+ function navigateFrom(router, location) {
43
+ return (options) => router.navigate({
44
+ ...options,
45
+ _fromLocation: location
46
+ });
47
+ }
48
+ function waitFor(value, signal) {
49
+ return signal ? waitForReason(value, signal) : value;
50
+ }
51
+ async function resolveSsr(router, lane, index) {
52
+ const match = lane.matches[index];
53
+ const route = getRoute(router, match);
54
+ const parentSsr = lane.matches[index - 1]?.ssr;
55
+ if (router.isShell()) return route.id === rootRouteId;
56
+ if (parentSsr === false) return false;
57
+ const inherit = (value) => {
58
+ return value === true && parentSsr === "data-only" ? "data-only" : value;
59
+ };
60
+ const defaultSsr = router.options.defaultSsr ?? true;
61
+ const inheritedDefault = inherit(defaultSsr);
62
+ match.ssr = inheritedDefault;
63
+ const option = route.options.ssr;
64
+ if (option === void 0) return inheritedDefault;
65
+ if (typeof option !== "function") return inherit(option);
66
+ return inherit(await option({
67
+ search: maybe(match.search, match.searchError),
68
+ params: maybe(match.params, match.paramsError),
69
+ location: lane.location,
70
+ matches: lane.matches.map((candidate) => ({
71
+ index: candidate.index,
72
+ pathname: candidate.pathname,
73
+ fullPath: candidate.fullPath,
74
+ staticData: candidate.staticData,
75
+ id: candidate.id,
76
+ routeId: candidate.routeId,
77
+ search: maybe(candidate.search, candidate.searchError),
78
+ params: maybe(candidate.params, candidate.paramsError),
79
+ ssr: candidate.ssr
80
+ }))
81
+ }) ?? defaultSsr);
82
+ }
83
+ function stampNotFound(match, outcome) {
84
+ if (outcome[0] === NOT_FOUND && !outcome[1].routeId) outcome[1].routeId = match.routeId;
85
+ return outcome;
86
+ }
87
+ async function contextualize(router, lane, signal) {
88
+ const globalBoundary = lane.matches.findIndex((match) => match._notFound);
89
+ let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1;
90
+ let failure;
91
+ let parentContext = { ...router.options.context ?? {} };
92
+ for (let index = 0; index < end; index++) {
93
+ const match = lane.matches[index];
94
+ const route = getRoute(router, match);
95
+ try {
96
+ match.ssr = await resolveSsr(router, lane, index);
97
+ } catch (cause) {
98
+ signal?.throwIfAborted();
99
+ failure = [index, stampNotFound(match, normalizeError(route, cause))];
100
+ end = index;
101
+ }
102
+ signal?.throwIfAborted();
103
+ if (failure?.[1][0] === REDIRECTED) break;
104
+ match.__beforeLoadContext = void 0;
105
+ let context = parentContext;
106
+ try {
107
+ let routeContext;
108
+ if (route.options.context) {
109
+ const routeContextOptions = {
110
+ deps: match.loaderDeps,
111
+ params: match.params,
112
+ context: parentContext,
113
+ location: lane.location,
114
+ navigate: navigateFrom(router, lane.location),
115
+ buildLocation: router.buildLocation,
116
+ cause: match.cause,
117
+ abortController: match.abortController,
118
+ preload: false,
119
+ matches: lane.matches,
120
+ routeId: route.id
121
+ };
122
+ routeContext = route.options.context(routeContextOptions) ?? void 0;
123
+ }
124
+ context = {
125
+ ...parentContext,
126
+ ...routeContext
127
+ };
128
+ match.context = context;
129
+ } catch (cause) {
130
+ signal?.throwIfAborted();
131
+ if (!failure) failure = [index, stampNotFound(match, normalizeError(route, cause))];
132
+ end = index;
133
+ break;
134
+ }
135
+ signal?.throwIfAborted();
136
+ if (failure) break;
137
+ const validationError = match.paramsError ?? match.searchError;
138
+ if (validationError !== void 0) {
139
+ failure = [index, stampNotFound(match, normalizeError(route, validationError))];
140
+ end = index;
141
+ break;
142
+ }
143
+ signal?.throwIfAborted();
144
+ if (match.ssr === false || !route.options.beforeLoad) {
145
+ parentContext = context;
146
+ continue;
147
+ }
148
+ const abortController = match.abortController;
149
+ const options = {
150
+ search: match.search,
151
+ abortController,
152
+ params: match.params,
153
+ preload: false,
154
+ context,
155
+ location: lane.location,
156
+ navigate: navigateFrom(router, lane.location),
157
+ buildLocation: router.buildLocation,
158
+ cause: match.cause,
159
+ matches: lane.matches,
160
+ routeId: route.id,
161
+ ...router.options.additionalContext
162
+ };
163
+ try {
164
+ const beforeLoadContext = await route.options.beforeLoad(options);
165
+ signal?.throwIfAborted();
166
+ const outcome = stampNotFound(match, normalize(beforeLoadContext, false));
167
+ if (outcome[0] !== SUCCESS) {
168
+ failure = [index, outcome];
169
+ end = index;
170
+ break;
171
+ }
172
+ match.__beforeLoadContext = beforeLoadContext;
173
+ match.context = {
174
+ ...context,
175
+ ...beforeLoadContext
176
+ };
177
+ parentContext = match.context;
178
+ } catch (cause) {
179
+ signal?.throwIfAborted();
180
+ failure = [index, stampNotFound(match, normalizeError(route, cause))];
181
+ end = index;
182
+ break;
183
+ }
184
+ }
185
+ return {
186
+ location: lane.location,
187
+ matches: lane.matches,
188
+ end,
189
+ failure
190
+ };
191
+ }
192
+ function getLoaderContext(router, lane, match, route, index, tasks) {
193
+ return {
194
+ params: match.params,
195
+ deps: match.loaderDeps,
196
+ preload: false,
197
+ parentMatchPromise: tasks[index - 1]?.match,
198
+ abortController: match.abortController,
199
+ context: match.context,
200
+ location: lane.location,
201
+ navigate: navigateFrom(router, lane.location),
202
+ cause: match.cause,
203
+ route,
204
+ ...router.options.additionalContext
205
+ };
206
+ }
207
+ function createLoaderTask(router, lane, index, tasks, signal) {
208
+ const match = lane.matches[index];
209
+ const route = getRoute(router, match);
210
+ let outcome;
211
+ if (match.ssr === false) outcome = Promise.resolve([SKIPPED]);
212
+ else {
213
+ const routeLoader = route.options.loader;
214
+ const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
215
+ if (!loader) outcome = Promise.resolve([SUCCESS, void 0]);
216
+ else outcome = Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, index, tasks))).then((result) => normalize(result, false), (cause) => normalize(cause, true)).then((result) => {
217
+ if (result[0] !== REDIRECTED && (signal?.aborted || match.abortController.signal.reason === lane)) return [SKIPPED];
218
+ if (result[0] === ERROR) result = normalizeError(route, result[1]);
219
+ return stampNotFound(match, result);
220
+ });
221
+ }
222
+ const parentMatch = outcome.then((result) => {
223
+ const snapshot = { ...match };
224
+ if (result[0] === SUCCESS) {
225
+ snapshot.loaderData = result[1];
226
+ snapshot.status = "success";
227
+ snapshot.error = void 0;
228
+ snapshot.invalid = false;
229
+ snapshot.isFetching = false;
230
+ } else if (result[0] === ERROR) {
231
+ snapshot.status = "error";
232
+ snapshot.error = result[1];
233
+ } else if (result[0] === NOT_FOUND) {
234
+ snapshot.status = "notFound";
235
+ snapshot.error = result[1];
236
+ }
237
+ return snapshot;
238
+ });
239
+ return {
240
+ index,
241
+ outcome,
242
+ match: parentMatch
243
+ };
244
+ }
245
+ async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
246
+ const cause = indexed?.[1][1];
247
+ let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
248
+ if (index < 0) index = 0;
249
+ for (let candidate = index; candidate >= 0; candidate--) {
250
+ const route = getRoute(router, matches[candidate]);
251
+ const loading = loadRouteChunk(route, false);
252
+ if (loading) try {
253
+ await loading;
254
+ } catch {
255
+ signal?.throwIfAborted();
256
+ }
257
+ signal?.throwIfAborted();
258
+ if (route.options.notFoundComponent) return candidate;
259
+ }
260
+ return cause?.routeId ? index : fallback;
261
+ }
262
+ function abortMatches(matches, start = 0, reason) {
263
+ for (let index = start; index < matches.length; index++) matches[index].abortController.abort(reason);
264
+ }
265
+ function resolveServerRedirect(router, location, value) {
266
+ value.options._fromLocation = location;
267
+ return {
268
+ type: "redirect",
269
+ redirect: router.resolveRedirect(value)
270
+ };
271
+ }
272
+ async function applyFailure(router, lane, indexed, signal) {
273
+ if (!indexed) {
274
+ const boundary = lane.matches.findIndex((match) => match._notFound);
275
+ if (boundary >= 0) {
276
+ abortMatches(lane.matches, boundary + 1);
277
+ return {
278
+ status: 404,
279
+ boundary,
280
+ kind: NOT_FOUND
281
+ };
282
+ }
283
+ return { status: 200 };
284
+ }
285
+ const [index, outcome] = indexed;
286
+ if (outcome[0] === ERROR) {
287
+ const match = lane.matches[index];
288
+ match._notFound = void 0;
289
+ match.status = "error";
290
+ match.error = outcome[1];
291
+ match.isFetching = false;
292
+ abortMatches(lane.matches, index + 1);
293
+ return {
294
+ status: 500,
295
+ boundary: index,
296
+ kind: ERROR
297
+ };
298
+ }
299
+ const boundary = indexed[2] ?? await getNotFoundBoundary(router, lane.matches, indexed, signal);
300
+ const match = lane.matches[boundary];
301
+ const cause = outcome[1];
302
+ cause.routeId = match.routeId;
303
+ match._notFound = void 0;
304
+ if (match.routeId === router.routeTree.id) {
305
+ match.status = "success";
306
+ match._notFound = true;
307
+ match.error = cause;
308
+ } else {
309
+ match.status = "notFound";
310
+ match.error = cause;
311
+ }
312
+ match.isFetching = false;
313
+ abortMatches(lane.matches, boundary + 1);
314
+ return {
315
+ status: 404,
316
+ boundary,
317
+ kind: NOT_FOUND
318
+ };
319
+ }
320
+ async function loadNormalChunks(router, lane, end, signal) {
321
+ const chunks = [];
322
+ for (let index = 0; index < lane.matches.length; index++) {
323
+ const match = lane.matches[index];
324
+ if (index >= end || match.ssr !== true || match.status !== "success") continue;
325
+ const route = getRoute(router, match);
326
+ try {
327
+ const loading = loadRouteChunk(route);
328
+ if (loading) {
329
+ const chunk = loading.then(() => {
330
+ signal?.throwIfAborted();
331
+ }, (cause) => {
332
+ signal?.throwIfAborted();
333
+ return [index, stampNotFound(match, normalizeError(route, cause))];
334
+ });
335
+ chunk.catch(() => {});
336
+ chunks.push(chunk);
337
+ }
338
+ } catch (cause) {
339
+ signal?.throwIfAborted();
340
+ chunks.push([index, stampNotFound(match, normalizeError(route, cause))]);
341
+ }
342
+ }
343
+ for (const chunk of chunks) {
344
+ const indexed = Array.isArray(chunk) ? chunk : await chunk;
345
+ if (indexed) return indexed;
346
+ }
347
+ }
348
+ async function projectLane(router, lane, signal) {
349
+ for (const match of lane.matches) {
350
+ const routeOptions = getRoute(router, match).options;
351
+ if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {
352
+ const context = {
353
+ ssr: router.options.ssr,
354
+ matches: lane.matches,
355
+ match,
356
+ params: match.params,
357
+ loaderData: match.loaderData
358
+ };
359
+ try {
360
+ const [head, scripts, headers] = await Promise.all([
361
+ routeOptions.head?.(context),
362
+ routeOptions.scripts?.(context),
363
+ routeOptions.headers?.(context)
364
+ ]);
365
+ signal?.throwIfAborted();
366
+ match.meta = head?.meta;
367
+ match.links = head?.links;
368
+ match.headScripts = head?.scripts;
369
+ match.styles = head?.styles;
370
+ match.scripts = scripts;
371
+ match.headers = headers;
372
+ } catch (cause) {
373
+ signal?.throwIfAborted();
374
+ console.error(cause);
375
+ }
376
+ }
377
+ if (match.ssr === false || match.status !== "success" || match._notFound) break;
378
+ }
379
+ }
380
+ async function executeServerLane(router, location, matchedMatches, signal) {
381
+ const matched = {
382
+ location,
383
+ matches: matchedMatches.map((match) => ({
384
+ ...match,
385
+ __beforeLoadContext: void 0,
386
+ context: {},
387
+ isFetching: false,
388
+ abortController: new AbortController()
389
+ }))
390
+ };
391
+ const abortLane = () => abortMatches(matched.matches, 0, signal?.reason);
392
+ if (signal?.aborted) {
393
+ abortLane();
394
+ signal.throwIfAborted();
395
+ }
396
+ signal?.addEventListener("abort", abortLane, { once: true });
397
+ try {
398
+ const plannedGlobalBoundary = matched.matches.findIndex((match) => match._notFound);
399
+ if (router.options.notFoundMode !== "root" && plannedGlobalBoundary >= 0) {
400
+ const boundary = await getNotFoundBoundary(router, matched.matches, void 0, signal, plannedGlobalBoundary);
401
+ if (boundary !== plannedGlobalBoundary) {
402
+ matched.matches[plannedGlobalBoundary]._notFound = void 0;
403
+ matched.matches[boundary]._notFound = true;
404
+ }
405
+ }
406
+ const lane = await contextualize(router, matched, signal);
407
+ signal?.throwIfAborted();
408
+ let loaderEnd = lane.end;
409
+ if (lane.failure?.[1][0] === REDIRECTED) loaderEnd = 0;
410
+ else if (lane.failure?.[1][0] === NOT_FOUND) {
411
+ lane.failure[2] = await getNotFoundBoundary(router, lane.matches, lane.failure, signal);
412
+ loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1);
413
+ }
414
+ const tasks = [];
415
+ for (let index = 0; index < loaderEnd; index++) {
416
+ const task = createLoaderTask(router, lane, index, tasks, signal);
417
+ tasks.push(task);
418
+ }
419
+ let loaderFailure;
420
+ let control = lane.failure?.[1][0] === REDIRECTED ? lane.failure : void 0;
421
+ try {
422
+ await Promise.all(tasks.map((task) => task.outcome.then((loadedOutcome) => {
423
+ const match = lane.matches[task.index];
424
+ const outcome = loadedOutcome;
425
+ if (outcome[0] === SUCCESS) {
426
+ match.loaderData = outcome[1];
427
+ match.status = "success";
428
+ match.error = void 0;
429
+ match.invalid = false;
430
+ match.isFetching = false;
431
+ match.updatedAt = Date.now();
432
+ } else if (outcome[0] === REDIRECTED) {
433
+ control = [task.index, outcome];
434
+ throw control;
435
+ } else {
436
+ if (match.ssr !== false) {
437
+ match.status = "success";
438
+ match.error = void 0;
439
+ match.invalid = true;
440
+ match.isFetching = false;
441
+ }
442
+ if (!loaderFailure && outcome[0] !== SKIPPED) loaderFailure = [task.index, outcome];
443
+ }
444
+ })));
445
+ } catch (cause) {
446
+ if (!Array.isArray(cause)) throw cause;
447
+ control = cause;
448
+ }
449
+ signal?.throwIfAborted();
450
+ if (control?.[1][0] === REDIRECTED) {
451
+ abortMatches(lane.matches, 0, lane);
452
+ return resolveServerRedirect(router, location, control[1][1]);
453
+ }
454
+ let failure = lane.failure ?? loaderFailure;
455
+ const plannedBoundary = lane.matches.findIndex((match) => match._notFound);
456
+ let readinessEnd;
457
+ if (failure) {
458
+ const outcomeEnd = failure[2] ??= failure[1][0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : failure[0];
459
+ for (const task of tasks) {
460
+ if (task.index >= outcomeEnd) break;
461
+ const outcome = await task.outcome;
462
+ if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in lane.matches[task.index])) {
463
+ failure = [task.index, outcome];
464
+ failure[2] = outcome[0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : task.index;
465
+ break;
466
+ }
467
+ }
468
+ readinessEnd = failure[2];
469
+ } else readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary;
470
+ const requiredFailure = await loadNormalChunks(router, lane, readinessEnd, signal);
471
+ signal?.throwIfAborted();
472
+ if (requiredFailure) {
473
+ if (requiredFailure[1][0] === REDIRECTED) {
474
+ abortMatches(lane.matches);
475
+ return resolveServerRedirect(router, location, requiredFailure[1][1]);
476
+ }
477
+ failure = requiredFailure;
478
+ }
479
+ const terminal = await applyFailure(router, lane, failure, signal);
480
+ if (terminal.boundary !== void 0) {
481
+ const match = lane.matches[terminal.boundary];
482
+ if (match.ssr === true) {
483
+ const route = getRoute(router, match);
484
+ try {
485
+ if (terminal.kind === ERROR) await loadRouteChunk(route, "errorComponent");
486
+ else if (match._notFound) await Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]);
487
+ else await loadRouteChunk(route, "notFoundComponent");
488
+ } catch {}
489
+ signal?.throwIfAborted();
490
+ }
491
+ }
492
+ signal?.throwIfAborted();
493
+ await projectLane(router, {
494
+ location: lane.location,
495
+ matches: lane.matches
496
+ }, signal);
497
+ signal?.throwIfAborted();
498
+ router.serverSsr?.onCleanup(abortLane);
499
+ return {
500
+ type: "render",
501
+ status: terminal.status,
502
+ matches: lane.matches
503
+ };
504
+ } finally {
505
+ signal?.removeEventListener("abort", abortLane);
506
+ }
507
+ }
508
+ async function loadServerRoute(router, opts) {
509
+ router.updateLatestLocation();
510
+ const next = router.latestLocation;
511
+ const previous = router._committed;
512
+ let result;
513
+ try {
514
+ const canonical = router.buildLocation({
515
+ to: next.pathname,
516
+ search: true,
517
+ params: true,
518
+ hash: true,
519
+ state: true,
520
+ _includeValidateSearch: true
521
+ });
522
+ if (next.publicHref !== canonical.publicHref) {
523
+ const href = canonical.publicHref || "/";
524
+ throw canonical.external ? redirect({ href }) : redirect({
525
+ href,
526
+ _builtLocation: canonical
527
+ });
528
+ }
529
+ const changeInfo = getLocationChangeInfo(next, router.stores.resolvedLocation.get());
530
+ router.emit({
531
+ type: "onBeforeNavigate",
532
+ ...changeInfo
533
+ });
534
+ router.emit({
535
+ type: "onBeforeLoad",
536
+ ...changeInfo
537
+ });
538
+ opts?._signal?.throwIfAborted();
539
+ result = await waitFor(executeServerLane(router, next, router.matchRoutes(next), opts?._signal), opts?._signal);
540
+ opts?._signal?.throwIfAborted();
541
+ } catch (cause) {
542
+ opts?._signal?.throwIfAborted();
543
+ if (!isRedirect(cause)) throw cause;
544
+ result = resolveServerRedirect(router, next, cause);
545
+ }
546
+ router._serverResult = result;
547
+ router.batch(() => {
548
+ router.stores.location.set(next);
549
+ router.stores.status.set("idle");
550
+ if (result.type === "render") {
551
+ router.stores.setMatches(result.matches);
552
+ router.stores.resolvedLocation.set(next);
553
+ }
554
+ });
555
+ if (result.type === "render") {
556
+ router._committed = result.matches;
557
+ runRouteLifecycle(router, previous, result.matches);
558
+ }
559
+ router._commitPromise?.resolve();
560
+ router._commitPromise = void 0;
561
+ }
562
+ //#endregion
563
+ export { loadServerRoute };
564
+
565
+ //# sourceMappingURL=load-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-server.js","names":[],"sources":["../../src/load-server.ts"],"sourcesContent":["// Keep this filename free of a secondary extension so declaration generation\n// can rewrite relative imports for both ESM and CJS.\nimport { isNotFound } from './not-found'\nimport { isRedirect, redirect } from './redirect'\nimport { rootRouteId } from './root'\nimport { loadRouteChunk } from './load-client'\nimport { waitForReason } from './await-signal'\nimport { getLocationChangeInfo, runRouteLifecycle } from './router'\nimport type { ParsedLocation } from './location'\nimport type { AnyRouteMatch } from './Matches'\nimport type { NotFoundError } from './not-found'\nimport type {\n AnyRoute,\n BeforeLoadContextOptions,\n LoaderFnContext,\n RouteContextOptions,\n SsrContextOptions,\n} from './route'\nimport type { AnyRedirect } from './redirect'\nimport type { AnyRouter, SSROption } from './router'\n\ndeclare const serverLanePhase: unique symbol\n\ntype ServerLane<TPhase extends 'matched' | 'contextualized' | 'reduced'> = {\n readonly [serverLanePhase]: TPhase\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n}\n\ntype MatchedLane = ServerLane<'matched'>\n\ntype IndexedOutcome = [index: number, outcome: LoaderOutcome, boundary?: number]\n\ntype ContextualizedLane = ServerLane<'contextualized'> & {\n end: number\n failure?: IndexedOutcome\n}\n\ntype ReducedLane = ServerLane<'reduced'>\n\nconst SUCCESS = 0\nconst ERROR = 1\nconst NOT_FOUND = 2\nconst REDIRECTED = 3\nconst SKIPPED = 4\n\ntype LoaderOutcome =\n | [typeof SUCCESS, data: unknown]\n | [typeof ERROR, error: unknown]\n | [typeof NOT_FOUND, error: NotFoundError]\n | [typeof REDIRECTED, redirect: AnyRedirect]\n | [typeof SKIPPED]\n\ntype LoaderTask = {\n index: number\n outcome: Promise<LoaderOutcome>\n match: Promise<AnyRouteMatch>\n}\n\nexport type ServerLoadResult =\n | {\n type: 'render'\n status: 200 | 404 | 500\n matches: Array<AnyRouteMatch>\n }\n | { type: 'redirect'; redirect: AnyRedirect }\n\nfunction getRoute(router: AnyRouter, match: AnyRouteMatch): AnyRoute {\n return router.routesById[match.routeId]\n}\n\nfunction normalize(value: unknown, rejected: boolean): LoaderOutcome {\n if (isRedirect(value)) {\n return [REDIRECTED, value]\n }\n if (isNotFound(value)) {\n return [NOT_FOUND, value]\n }\n if (rejected && typeof (value as any)?.then === 'function') {\n value = new Error('A Promise was thrown', { cause: value })\n }\n return rejected ? [ERROR, value] : [SUCCESS, value]\n}\n\nfunction normalizeError(route: AnyRoute, cause: unknown): LoaderOutcome {\n let outcome = normalize(cause, true)\n if (outcome[0] !== ERROR) {\n return outcome\n }\n try {\n route.options.onError?.(outcome[1])\n } catch (onErrorCause) {\n outcome = normalize(onErrorCause, true)\n }\n return outcome\n}\n\nfunction maybe<TValue>(\n value: TValue,\n cause: unknown,\n): { status: 'success'; value: TValue } | { status: 'error'; error: unknown } {\n if (cause !== undefined) {\n return { status: 'error', error: cause }\n }\n return { status: 'success', value }\n}\n\nfunction navigateFrom(router: AnyRouter, location: ParsedLocation) {\n return (options: any) =>\n router.navigate({\n ...options,\n _fromLocation: location,\n })\n}\n\nfunction waitFor<T>(value: Promise<T>, signal?: AbortSignal): Promise<T> {\n return signal ? waitForReason(value, signal) : value\n}\n\nasync function resolveSsr(\n router: AnyRouter,\n lane: MatchedLane,\n index: number,\n): Promise<SSROption> {\n const match = lane.matches[index]!\n const route = getRoute(router, match)\n const parentSsr = lane.matches[index - 1]?.ssr\n\n if (router.isShell()) {\n return route.id === rootRouteId\n }\n if (parentSsr === false) {\n return false\n }\n\n const inherit = (value: SSROption): SSROption => {\n return value === true && parentSsr === 'data-only' ? 'data-only' : value\n }\n const defaultSsr = router.options.defaultSsr ?? true\n const inheritedDefault = inherit(defaultSsr)\n // A functional override can fail. Establish the inherited policy first so\n // the selected error boundary retains the route's actual renderability.\n match.ssr = inheritedDefault\n const option = route.options.ssr\n if (option === undefined) {\n return inheritedDefault\n }\n if (typeof option !== 'function') {\n return inherit(option)\n }\n\n const context: SsrContextOptions<any, any, any> = {\n search: maybe(match.search, match.searchError),\n params: maybe(match.params, match.paramsError),\n location: lane.location,\n matches: lane.matches.map((candidate) => ({\n index: candidate.index,\n pathname: candidate.pathname,\n fullPath: candidate.fullPath,\n staticData: candidate.staticData,\n id: candidate.id,\n routeId: candidate.routeId,\n search: maybe(candidate.search, candidate.searchError),\n params: maybe(candidate.params, candidate.paramsError),\n ssr: candidate.ssr,\n })),\n }\n return inherit((await option(context)) ?? defaultSsr)\n}\n\nfunction stampNotFound(\n match: AnyRouteMatch,\n outcome: LoaderOutcome,\n): LoaderOutcome {\n if (outcome[0] === NOT_FOUND && !outcome[1].routeId) {\n outcome[1].routeId = match.routeId\n }\n return outcome\n}\n\nasync function contextualize(\n router: AnyRouter,\n lane: MatchedLane,\n signal?: AbortSignal,\n): Promise<ContextualizedLane> {\n const globalBoundary = lane.matches.findIndex((match) => match._notFound)\n let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1\n let failure: IndexedOutcome | undefined\n let parentContext: Record<string, unknown> = {\n ...(router.options.context ?? {}),\n }\n\n for (let index = 0; index < end; index++) {\n const match = lane.matches[index]!\n const route = getRoute(router, match)\n try {\n match.ssr = await resolveSsr(router, lane, index)\n } catch (cause) {\n signal?.throwIfAborted()\n failure = [index, stampNotFound(match, normalizeError(route, cause))]\n end = index\n }\n signal?.throwIfAborted()\n if (failure?.[1][0] === REDIRECTED) {\n break\n }\n\n match.__beforeLoadContext = undefined\n let context = parentContext\n try {\n let routeContext\n if (route.options.context) {\n const routeContextOptions: RouteContextOptions<\n any,\n any,\n any,\n any,\n any\n > = {\n deps: match.loaderDeps,\n params: match.params,\n context: parentContext,\n location: lane.location,\n navigate: navigateFrom(router, lane.location),\n buildLocation: router.buildLocation,\n cause: match.cause,\n abortController: match.abortController,\n preload: false,\n matches: lane.matches,\n routeId: route.id,\n }\n routeContext = route.options.context(routeContextOptions) ?? undefined\n }\n context = {\n ...parentContext,\n ...routeContext,\n }\n match.context = context\n } catch (cause) {\n signal?.throwIfAborted()\n if (!failure) {\n failure = [index, stampNotFound(match, normalizeError(route, cause))]\n }\n end = index\n break\n }\n signal?.throwIfAborted()\n if (failure) {\n break\n }\n const validationError = match.paramsError ?? match.searchError\n if (validationError !== undefined) {\n failure = [\n index,\n stampNotFound(match, normalizeError(route, validationError)),\n ]\n end = index\n break\n }\n signal?.throwIfAborted()\n\n if (match.ssr === false || !route.options.beforeLoad) {\n parentContext = context\n continue\n }\n\n const abortController = match.abortController\n const options: BeforeLoadContextOptions<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > = {\n search: match.search,\n abortController,\n params: match.params,\n preload: false,\n context,\n location: lane.location,\n navigate: navigateFrom(router, lane.location),\n buildLocation: router.buildLocation,\n cause: match.cause,\n matches: lane.matches,\n routeId: route.id,\n ...router.options.additionalContext,\n }\n\n try {\n const beforeLoadContext = await route.options.beforeLoad(options)\n signal?.throwIfAborted()\n const outcome = stampNotFound(match, normalize(beforeLoadContext, false))\n if (outcome[0] !== SUCCESS) {\n failure = [index, outcome]\n end = index\n break\n }\n match.__beforeLoadContext = beforeLoadContext\n match.context = {\n ...context,\n ...beforeLoadContext,\n }\n parentContext = match.context\n } catch (cause) {\n signal?.throwIfAborted()\n failure = [index, stampNotFound(match, normalizeError(route, cause))]\n end = index\n break\n }\n }\n\n return {\n location: lane.location,\n matches: lane.matches,\n end,\n failure,\n } as ContextualizedLane\n}\n\nfunction getLoaderContext(\n router: AnyRouter,\n lane: ContextualizedLane,\n match: AnyRouteMatch,\n route: AnyRoute,\n index: number,\n tasks: Array<LoaderTask>,\n): LoaderFnContext {\n return {\n params: match.params,\n deps: match.loaderDeps,\n preload: false,\n parentMatchPromise: tasks[index - 1]?.match,\n abortController: match.abortController,\n context: match.context,\n location: lane.location,\n navigate: navigateFrom(router, lane.location),\n cause: match.cause,\n route,\n ...router.options.additionalContext,\n }\n}\n\nfunction createLoaderTask(\n router: AnyRouter,\n lane: ContextualizedLane,\n index: number,\n tasks: Array<LoaderTask>,\n signal?: AbortSignal,\n): LoaderTask {\n const match = lane.matches[index]!\n const route = getRoute(router, match)\n let outcome: Promise<LoaderOutcome>\n\n if (match.ssr === false) {\n outcome = Promise.resolve<LoaderOutcome>([SKIPPED])\n } else {\n const routeLoader = route.options.loader\n const loader =\n typeof routeLoader === 'function' ? routeLoader : routeLoader?.handler\n if (!loader) {\n outcome = Promise.resolve<LoaderOutcome>([SUCCESS, undefined])\n } else {\n outcome = Promise.resolve()\n .then(() =>\n loader(getLoaderContext(router, lane, match, route, index, tasks)),\n )\n .then(\n (result) => normalize(result, false),\n (cause) => normalize(cause, true),\n )\n .then((result): LoaderOutcome => {\n if (\n result[0] !== REDIRECTED &&\n (signal?.aborted || match.abortController.signal.reason === lane)\n ) {\n return [SKIPPED]\n }\n if (result[0] === ERROR) {\n result = normalizeError(route, result[1])\n }\n return stampNotFound(match, result)\n })\n }\n }\n\n const parentMatch = outcome.then((result) => {\n const snapshot = { ...match }\n if (result[0] === SUCCESS) {\n snapshot.loaderData = result[1]\n snapshot.status = 'success'\n snapshot.error = undefined\n snapshot.invalid = false\n snapshot.isFetching = false\n } else if (result[0] === ERROR) {\n snapshot.status = 'error'\n snapshot.error = result[1]\n } else if (result[0] === NOT_FOUND) {\n snapshot.status = 'notFound'\n snapshot.error = result[1]\n }\n return snapshot\n })\n\n return { index, outcome, match: parentMatch }\n}\n\nasync function getNotFoundBoundary(\n router: AnyRouter,\n matches: Array<AnyRouteMatch>,\n indexed: IndexedOutcome | undefined,\n signal?: AbortSignal,\n fallback = 0,\n): Promise<number> {\n const cause = indexed?.[1][1] as NotFoundError | undefined\n let index = cause?.routeId\n ? matches.findIndex((match) => match.routeId === cause.routeId)\n : (indexed?.[0] ?? matches.length - 1)\n if (index < 0) {\n index = 0\n }\n for (let candidate = index; candidate >= 0; candidate--) {\n const route = getRoute(router, matches[candidate]!)\n const loading = loadRouteChunk(route, false)\n if (loading) {\n try {\n await loading\n } catch {\n signal?.throwIfAborted()\n }\n }\n signal?.throwIfAborted()\n if (route.options.notFoundComponent) {\n return candidate\n }\n }\n return cause?.routeId ? index : fallback\n}\n\nfunction abortMatches(\n matches: Array<AnyRouteMatch>,\n start = 0,\n reason?: unknown,\n): void {\n for (let index = start; index < matches.length; index++) {\n matches[index]!.abortController.abort(reason)\n }\n}\n\nfunction resolveServerRedirect(\n router: AnyRouter,\n location: ParsedLocation,\n value: AnyRedirect,\n): ServerLoadResult {\n value.options._fromLocation = location\n return { type: 'redirect', redirect: router.resolveRedirect(value) }\n}\n\nasync function applyFailure(\n router: AnyRouter,\n lane: ContextualizedLane,\n indexed: IndexedOutcome | undefined,\n signal?: AbortSignal,\n): Promise<{ status: 200 | 404 | 500; boundary?: number; kind?: number }> {\n if (!indexed) {\n const boundary = lane.matches.findIndex((match) => match._notFound)\n if (boundary >= 0) {\n abortMatches(lane.matches, boundary + 1)\n return { status: 404, boundary, kind: NOT_FOUND }\n }\n return { status: 200 }\n }\n\n const [index, outcome] = indexed\n if (outcome[0] === ERROR) {\n const match = lane.matches[index]!\n match._notFound = undefined\n match.status = 'error'\n match.error = outcome[1]\n match.isFetching = false\n abortMatches(lane.matches, index + 1)\n return { status: 500, boundary: index, kind: ERROR }\n }\n\n const boundary =\n indexed[2] ??\n (await getNotFoundBoundary(router, lane.matches, indexed, signal))\n const match = lane.matches[boundary]!\n const cause = outcome[1] as NotFoundError\n cause.routeId = match.routeId\n match._notFound = undefined\n if (match.routeId === router.routeTree.id) {\n match.status = 'success'\n match._notFound = true\n match.error = cause\n } else {\n match.status = 'notFound'\n match.error = cause\n }\n match.isFetching = false\n abortMatches(lane.matches, boundary + 1)\n return { status: 404, boundary, kind: NOT_FOUND }\n}\n\nasync function loadNormalChunks(\n router: AnyRouter,\n lane: ContextualizedLane,\n end: number,\n signal?: AbortSignal,\n): Promise<IndexedOutcome | undefined> {\n const chunks: Array<IndexedOutcome | Promise<IndexedOutcome | undefined>> = []\n for (let index = 0; index < lane.matches.length; index++) {\n const match = lane.matches[index]!\n if (index >= end || match.ssr !== true || match.status !== 'success') {\n continue\n }\n const route = getRoute(router, match)\n try {\n const loading = loadRouteChunk(route)\n if (loading) {\n const chunk = loading.then(\n () => {\n signal?.throwIfAborted()\n return undefined\n },\n (cause) => {\n signal?.throwIfAborted()\n return [\n index,\n stampNotFound(match, normalizeError(route, cause)),\n ] as IndexedOutcome\n },\n )\n // Route-order reduction can return before later chunks settle.\n void chunk.catch(() => {})\n chunks.push(chunk)\n }\n } catch (cause) {\n signal?.throwIfAborted()\n chunks.push([index, stampNotFound(match, normalizeError(route, cause))])\n }\n }\n for (const chunk of chunks) {\n const indexed = Array.isArray(chunk) ? chunk : await chunk\n if (indexed) {\n return indexed\n }\n }\n return undefined\n}\n\nasync function projectLane(\n router: AnyRouter,\n lane: ReducedLane,\n signal?: AbortSignal,\n): Promise<void> {\n for (const match of lane.matches) {\n const routeOptions = getRoute(router, match).options\n if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {\n const context = {\n ssr: router.options.ssr,\n matches: lane.matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n try {\n const [head, scripts, headers] = await Promise.all([\n routeOptions.head?.(context),\n routeOptions.scripts?.(context),\n routeOptions.headers?.(context),\n ])\n signal?.throwIfAborted()\n match.meta = head?.meta\n match.links = head?.links\n match.headScripts = head?.scripts\n match.styles = head?.styles\n match.scripts = scripts\n match.headers = headers\n } catch (cause) {\n signal?.throwIfAborted()\n console.error(cause)\n }\n }\n if (match.ssr === false || match.status !== 'success' || match._notFound) {\n break\n }\n }\n}\n\nasync function executeServerLane(\n router: AnyRouter,\n location: ParsedLocation,\n matchedMatches: Array<AnyRouteMatch>,\n signal?: AbortSignal,\n): Promise<ServerLoadResult> {\n const matched = {\n location,\n matches: matchedMatches.map((match) => ({\n ...match,\n __beforeLoadContext: undefined,\n context: {},\n isFetching: false,\n abortController: new AbortController(),\n })),\n } as MatchedLane\n const abortLane = () => abortMatches(matched.matches, 0, signal?.reason)\n if (signal?.aborted) {\n abortLane()\n signal.throwIfAborted()\n }\n signal?.addEventListener('abort', abortLane, { once: true })\n\n try {\n const plannedGlobalBoundary = matched.matches.findIndex(\n (match) => match._notFound,\n )\n if (router.options.notFoundMode !== 'root' && plannedGlobalBoundary >= 0) {\n const boundary = await getNotFoundBoundary(\n router,\n matched.matches,\n undefined,\n signal,\n plannedGlobalBoundary,\n )\n if (boundary !== plannedGlobalBoundary) {\n matched.matches[plannedGlobalBoundary]!._notFound = undefined\n matched.matches[boundary]!._notFound = true\n }\n }\n const lane = await contextualize(router, matched, signal)\n signal?.throwIfAborted()\n\n let loaderEnd = lane.end\n if (lane.failure?.[1][0] === REDIRECTED) {\n loaderEnd = 0\n } else if (lane.failure?.[1][0] === NOT_FOUND) {\n lane.failure[2] = await getNotFoundBoundary(\n router,\n lane.matches,\n lane.failure,\n signal,\n )\n loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1)\n }\n\n const tasks: Array<LoaderTask> = []\n for (let index = 0; index < loaderEnd; index++) {\n const task = createLoaderTask(router, lane, index, tasks, signal)\n tasks.push(task)\n }\n\n let loaderFailure: IndexedOutcome | undefined\n let control = lane.failure?.[1][0] === REDIRECTED ? lane.failure : undefined\n try {\n await Promise.all(\n tasks.map((task) =>\n task.outcome.then((loadedOutcome) => {\n const match = lane.matches[task.index]!\n const outcome = loadedOutcome\n if (outcome[0] === SUCCESS) {\n match.loaderData = outcome[1]\n match.status = 'success'\n match.error = undefined\n match.invalid = false\n match.isFetching = false\n match.updatedAt = Date.now()\n } else if (outcome[0] === REDIRECTED) {\n control = [task.index, outcome]\n throw control\n } else {\n // A selective-SSR skip must stay pending for hydration. Every\n // settled server attempt is otherwise renderable unless\n // reduction selects it as the lane's terminal failure.\n if (match.ssr !== false) {\n match.status = 'success'\n match.error = undefined\n match.invalid = true\n match.isFetching = false\n }\n if (!loaderFailure && outcome[0] !== SKIPPED) {\n loaderFailure = [task.index, outcome]\n }\n }\n }),\n ),\n )\n } catch (cause) {\n if (!Array.isArray(cause)) {\n throw cause\n }\n control = cause as IndexedOutcome\n }\n signal?.throwIfAborted()\n\n if (control?.[1][0] === REDIRECTED) {\n abortMatches(lane.matches, 0, lane)\n return resolveServerRedirect(router, location, control[1][1])\n }\n\n let failure = lane.failure ?? loaderFailure\n const plannedBoundary = lane.matches.findIndex((match) => match._notFound)\n let readinessEnd: number\n if (failure) {\n const outcomeEnd = (failure[2] ??=\n failure[1][0] === NOT_FOUND\n ? await getNotFoundBoundary(router, lane.matches, failure, signal)\n : failure[0])\n for (const task of tasks) {\n if (task.index >= outcomeEnd) {\n break\n }\n const outcome = await task.outcome\n // Presence means a loader previously succeeded, even with `undefined`.\n if (\n outcome[0] !== SUCCESS &&\n outcome[0] < REDIRECTED &&\n !('loaderData' in lane.matches[task.index]!)\n ) {\n failure = [task.index, outcome]\n failure[2] =\n outcome[0] === NOT_FOUND\n ? await getNotFoundBoundary(router, lane.matches, failure, signal)\n : task.index\n break\n }\n }\n readinessEnd = failure[2]\n } else {\n readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary\n }\n const requiredFailure = await loadNormalChunks(\n router,\n lane,\n readinessEnd,\n signal,\n )\n signal?.throwIfAborted()\n if (requiredFailure) {\n if (requiredFailure[1][0] === REDIRECTED) {\n abortMatches(lane.matches)\n return resolveServerRedirect(router, location, requiredFailure[1][1])\n }\n failure = requiredFailure\n }\n\n const terminal = await applyFailure(router, lane, failure, signal)\n if (terminal.boundary !== undefined) {\n const match = lane.matches[terminal.boundary]!\n if (match.ssr === true) {\n const route = getRoute(router, match)\n try {\n if (terminal.kind === ERROR) {\n await loadRouteChunk(route, 'errorComponent')\n } else if (match._notFound) {\n await Promise.all([\n loadRouteChunk(route),\n loadRouteChunk(route, 'notFoundComponent'),\n ])\n } else {\n await loadRouteChunk(route, 'notFoundComponent')\n }\n } catch {}\n signal?.throwIfAborted()\n }\n }\n\n signal?.throwIfAborted()\n await projectLane(\n router,\n {\n location: lane.location,\n matches: lane.matches,\n } as ReducedLane,\n signal,\n )\n signal?.throwIfAborted()\n router.serverSsr?.onCleanup(abortLane)\n return { type: 'render', status: terminal.status, matches: lane.matches }\n } finally {\n signal?.removeEventListener('abort', abortLane)\n }\n}\n\ntype ServerLoadOptions = NonNullable<Parameters<AnyRouter['load']>[0]> & {\n _signal?: AbortSignal\n}\n\nexport async function loadServerRoute(\n router: AnyRouter,\n opts?: ServerLoadOptions,\n): Promise<void> {\n router.updateLatestLocation()\n const next = router.latestLocation\n const previous = router._committed\n let result: ServerLoadResult\n try {\n const canonical = router.buildLocation({\n to: next.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n if (next.publicHref !== canonical.publicHref) {\n const href = canonical.publicHref || '/'\n throw canonical.external\n ? redirect({ href })\n : redirect({ href, _builtLocation: canonical })\n }\n\n const fromLocation = router.stores.resolvedLocation.get()\n const changeInfo = getLocationChangeInfo(next, fromLocation)\n router.emit({ type: 'onBeforeNavigate', ...changeInfo })\n router.emit({ type: 'onBeforeLoad', ...changeInfo })\n opts?._signal?.throwIfAborted()\n result = await waitFor(\n executeServerLane(router, next, router.matchRoutes(next), opts?._signal),\n opts?._signal,\n )\n opts?._signal?.throwIfAborted()\n } catch (cause) {\n opts?._signal?.throwIfAborted()\n if (!isRedirect(cause)) {\n throw cause\n }\n result = resolveServerRedirect(router, next, cause)\n }\n\n router._serverResult = result\n router.batch(() => {\n router.stores.location.set(next)\n router.stores.status.set('idle')\n if (result.type === 'render') {\n router.stores.setMatches(result.matches)\n router.stores.resolvedLocation.set(next)\n }\n })\n if (result.type === 'render') {\n router._committed = result.matches\n runRouteLifecycle(router, previous, result.matches)\n }\n router._commitPromise?.resolve()\n router._commitPromise = undefined\n}\n"],"mappings":";;;;;;;AAwCA,MAAM,UAAU;AAChB,MAAM,QAAQ;AACd,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,UAAU;AAuBhB,SAAS,SAAS,QAAmB,OAAgC;CACnE,OAAO,OAAO,WAAW,MAAM;AACjC;AAEA,SAAS,UAAU,OAAgB,UAAkC;CACnE,IAAI,WAAW,KAAK,GAClB,OAAO,CAAC,YAAY,KAAK;CAE3B,IAAI,WAAW,KAAK,GAClB,OAAO,CAAC,WAAW,KAAK;CAE1B,IAAI,YAAY,OAAQ,OAAe,SAAS,YAC9C,QAAQ,IAAI,MAAM,wBAAwB,EAAE,OAAO,MAAM,CAAC;CAE5D,OAAO,WAAW,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,KAAK;AACpD;AAEA,SAAS,eAAe,OAAiB,OAA+B;CACtE,IAAI,UAAU,UAAU,OAAO,IAAI;CACnC,IAAI,QAAQ,OAAO,OACjB,OAAO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O,cAAc;GACrC,IAAI,KAAK;GACT,QAAQ;GACR,QAAQ;GACR,MAAM;GACN,OAAO;GACP,wBAAwB;EAC1B,CAAC;EACD,IAAI,KAAK,eAAe,UAAU,YAAY;GAC5C,MAAM,OAAO,UAAU,cAAc;GACrC,MAAM,UAAU,WACZ,SAAS,EAAE,KAAK,CAAC,IACjB,SAAS;IAAE;IAAM,gBAAgB;GAAU,CAAC;EAClD;EAGA,MAAM,aAAa,sBAAsB,MADpB,OAAO,OAAO,iBAAiB,IACL,CAAY;EAC3D,OAAO,KAAK;GAAE,MAAM;GAAoB,GAAG;EAAW,CAAC;EACvD,OAAO,KAAK;GAAE,MAAM;GAAgB,GAAG;EAAW,CAAC;EACnD,MAAM,SAAS,eAAe;EAC9B,SAAS,MAAM,QACb,kBAAkB,QAAQ,MAAM,OAAO,YAAY,IAAI,GAAG,MAAM,OAAO,GACvE,MAAM,OACR;EACA,MAAM,SAAS,eAAe;CAChC,SAAS,OAAO;EACd,MAAM,SAAS,eAAe;EAC9B,IAAI,CAAC,WAAW,KAAK,GACnB,MAAM;EAER,SAAS,sBAAsB,QAAQ,MAAM,KAAK;CACpD;CAEA,OAAO,gBAAgB;CACvB,OAAO,YAAY;EACjB,OAAO,OAAO,SAAS,IAAI,IAAI;EAC/B,OAAO,OAAO,OAAO,IAAI,MAAM;EAC/B,IAAI,OAAO,SAAS,UAAU;GAC5B,OAAO,OAAO,WAAW,OAAO,OAAO;GACvC,OAAO,OAAO,iBAAiB,IAAI,IAAI;EACzC;CACF,CAAC;CACD,IAAI,OAAO,SAAS,UAAU;EAC5B,OAAO,aAAa,OAAO;EAC3B,kBAAkB,QAAQ,UAAU,OAAO,OAAO;CACpD;CACA,OAAO,gBAAgB,QAAQ;CAC/B,OAAO,iBAAiB,KAAA;AAC1B"}
@@ -6,7 +6,6 @@ export type AnyRedirect = Redirect<any, any, any, any, any>;
6
6
  */
7
7
  export type Redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = Response & {
8
8
  options: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {};
9
- redirectHandled?: boolean;
10
9
  };
11
10
  export type RedirectOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = {
12
11
  href?: string;