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