react-router 0.0.0-experimental-e613d4238 → 0.0.0-experimental-4e44d47

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 (65) hide show
  1. package/dist/development/{chunk-YJ6T7YSE.js → chunk-7B7CUJYE.js} +345 -66
  2. package/dist/development/{chunk-XXC4LMW2.js → chunk-MTLWRICG.js} +164 -161
  3. package/dist/development/{chunk-2YVPYFDJ.mjs → chunk-PSQFTIPQ.mjs} +67 -51
  4. package/dist/development/{chunk-5P3HEZQU.mjs → chunk-XVVWTPHF.mjs} +307 -25
  5. package/dist/development/dom-export.d.mts +59 -4
  6. package/dist/development/dom-export.d.ts +59 -3
  7. package/dist/development/dom-export.js +8 -5
  8. package/dist/development/dom-export.mjs +8 -5
  9. package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-83aVZHgI.d.ts} +198 -134
  10. package/dist/{production/index-react-server-client-2EDmGlsZ.d.mts → development/index-react-server-client-BDG19ZQl.d.mts} +140 -77
  11. package/dist/development/index-react-server-client.d.mts +3 -3
  12. package/dist/development/index-react-server-client.d.ts +3 -2
  13. package/dist/development/index-react-server-client.js +4 -4
  14. package/dist/development/index-react-server-client.mjs +2 -2
  15. package/dist/development/index-react-server.d.mts +106 -1
  16. package/dist/development/index-react-server.d.ts +106 -1
  17. package/dist/development/index-react-server.js +181 -8
  18. package/dist/development/index-react-server.mjs +181 -8
  19. package/dist/development/index.d.mts +13 -18
  20. package/dist/development/index.d.ts +13 -16
  21. package/dist/development/index.js +161 -147
  22. package/dist/development/index.mjs +3 -5
  23. package/dist/development/instrumentation-XYmrzhe3.d.ts +1138 -0
  24. package/dist/development/lib/types/internal.d.mts +3 -3
  25. package/dist/development/lib/types/internal.d.ts +3 -2
  26. package/dist/development/lib/types/internal.js +1 -1
  27. package/dist/development/lib/types/internal.mjs +1 -1
  28. package/dist/development/{register-BrVEYTED.d.mts → register-DiOIlEq5.d.mts} +1 -7
  29. package/dist/{production/register-BrVEYTED.d.mts → development/register-DiOIlEq5.d.ts} +1 -7
  30. package/dist/development/{routeModules-BmVo7q9e.d.ts → routeModules-Bu1JamQV.d.ts} +73 -1046
  31. package/dist/development/{route-data-CDwqkzPE.d.mts → routeModules-CtCOLGtG.d.mts} +157 -147
  32. package/dist/development/{context-BqL5Eckq.d.mts → router-2BoB34m1.d.mts} +1403 -1250
  33. package/dist/production/{chunk-VNGQS422.mjs → chunk-GSSVRQ6M.mjs} +307 -25
  34. package/dist/production/{chunk-5MHETEIL.mjs → chunk-IZVJSKMU.mjs} +67 -51
  35. package/dist/production/{chunk-QBUHFRYZ.js → chunk-OXRQQZPR.js} +345 -66
  36. package/dist/production/{chunk-E4G6PZCJ.js → chunk-UNIYMJFU.js} +164 -161
  37. package/dist/production/dom-export.d.mts +59 -4
  38. package/dist/production/dom-export.d.ts +59 -3
  39. package/dist/production/dom-export.js +8 -5
  40. package/dist/production/dom-export.mjs +8 -5
  41. package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-83aVZHgI.d.ts} +140 -77
  42. package/dist/production/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BDG19ZQl.d.mts} +198 -134
  43. package/dist/production/index-react-server-client.d.mts +3 -3
  44. package/dist/production/index-react-server-client.d.ts +3 -2
  45. package/dist/production/index-react-server-client.js +4 -4
  46. package/dist/production/index-react-server-client.mjs +2 -2
  47. package/dist/production/index-react-server.d.mts +106 -1
  48. package/dist/production/index-react-server.d.ts +106 -1
  49. package/dist/production/index-react-server.js +181 -8
  50. package/dist/production/index-react-server.mjs +181 -8
  51. package/dist/production/index.d.mts +13 -18
  52. package/dist/production/index.d.ts +13 -16
  53. package/dist/production/index.js +161 -147
  54. package/dist/production/index.mjs +3 -5
  55. package/dist/production/instrumentation-XYmrzhe3.d.ts +1138 -0
  56. package/dist/production/lib/types/internal.d.mts +3 -3
  57. package/dist/production/lib/types/internal.d.ts +3 -2
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/register-D8NQoPsO.d.ts → production/register-DiOIlEq5.d.mts} +1 -7
  61. package/dist/production/{register-D8NQoPsO.d.ts → register-DiOIlEq5.d.ts} +1 -7
  62. package/dist/production/{routeModules-BmVo7q9e.d.ts → routeModules-Bu1JamQV.d.ts} +73 -1046
  63. package/dist/production/{route-data-CDwqkzPE.d.mts → routeModules-CtCOLGtG.d.mts} +157 -147
  64. package/dist/production/{context-BqL5Eckq.d.mts → router-2BoB34m1.d.mts} +1403 -1250
  65. package/package.json +1 -1
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
28
28
 
29
29
  /**
30
- * react-router v0.0.0-experimental-e613d4238
30
+ * react-router v0.0.0-experimental-4e44d47
31
31
  *
32
32
  * Copyright (c) Remix Software Inc.
33
33
  *
@@ -107,6 +107,134 @@ function parsePath(path) {
107
107
  return parsedPath;
108
108
  }
109
109
 
110
+ // lib/router/instrumentation.ts
111
+ var UninstrumentedSymbol = Symbol("Uninstrumented");
112
+ function getInstrumentedImplementation(impls, handler, getInfo = () => void 0) {
113
+ if (impls.length === 0) {
114
+ return null;
115
+ }
116
+ return async (...args) => {
117
+ let value;
118
+ let info = getInfo(...args);
119
+ await recurseRight(
120
+ impls,
121
+ info,
122
+ async () => {
123
+ value = await handler(...args);
124
+ },
125
+ impls.length - 1
126
+ );
127
+ return value;
128
+ };
129
+ }
130
+ async function recurseRight(impls, info, handler, index) {
131
+ let impl = impls[index];
132
+ if (!impl) {
133
+ await handler();
134
+ } else {
135
+ await impl(async () => {
136
+ await recurseRight(impls, info, handler, index - 1);
137
+ }, info);
138
+ }
139
+ }
140
+ function getInstrumentationInfo(args) {
141
+ let { request, context, params, pattern } = args;
142
+ return {
143
+ // pseudo "Request" with the info they may want to read from
144
+ request: {
145
+ method: request.method,
146
+ url: request.url,
147
+ // Maybe make this a proxy that only supports `get`?
148
+ headers: {
149
+ get: (...args2) => request.headers.get(...args2)
150
+ }
151
+ },
152
+ params: { ...params },
153
+ pattern,
154
+ context: {
155
+ get: (...args2) => context.get(...args2)
156
+ }
157
+ };
158
+ }
159
+ function getInstrumentationsByType(instrumentations, key) {
160
+ let value = [];
161
+ for (let i in instrumentations) {
162
+ let instrumentation = instrumentations[i];
163
+ if (key in instrumentation && instrumentation[key] != null) {
164
+ value.push(instrumentation[key]);
165
+ }
166
+ }
167
+ return value;
168
+ }
169
+ function getInstrumentationUpdates(fns, route) {
170
+ let instrumentations = [];
171
+ fns.forEach(
172
+ (fn) => fn({
173
+ id: route.id,
174
+ index: route.index,
175
+ path: route.path,
176
+ instrument(i) {
177
+ instrumentations.push(i);
178
+ }
179
+ })
180
+ );
181
+ let updates = {};
182
+ if (instrumentations.length > 0) {
183
+ ["lazy", "loader", "action"].forEach((key) => {
184
+ let func = route[key];
185
+ if (typeof func === "function") {
186
+ let original = func[UninstrumentedSymbol] ?? func;
187
+ let instrumented = getInstrumentedImplementation(
188
+ getInstrumentationsByType(instrumentations, key),
189
+ original,
190
+ key === "lazy" ? () => void 0 : (...args) => getInstrumentationInfo(
191
+ args[0]
192
+ )
193
+ );
194
+ if (instrumented) {
195
+ instrumented[UninstrumentedSymbol] = original;
196
+ updates[key] = instrumented;
197
+ }
198
+ }
199
+ });
200
+ if (route.middleware && route.middleware.length > 0) {
201
+ updates.middleware = route.middleware.map((middleware) => {
202
+ let original = middleware[UninstrumentedSymbol] ?? middleware;
203
+ let instrumented = getInstrumentedImplementation(
204
+ getInstrumentationsByType(instrumentations, "middleware"),
205
+ original,
206
+ (...args) => getInstrumentationInfo(
207
+ args[0]
208
+ )
209
+ );
210
+ if (instrumented) {
211
+ instrumented[UninstrumentedSymbol] = original;
212
+ return instrumented;
213
+ }
214
+ return middleware;
215
+ });
216
+ }
217
+ if (typeof route.lazy === "object") {
218
+ let lazyObject = route.lazy;
219
+ ["middleware", "loader", "action"].forEach((key) => {
220
+ let func = lazyObject[key];
221
+ if (typeof func === "function") {
222
+ let instrumented = getInstrumentedImplementation(
223
+ getInstrumentationsByType(instrumentations, `lazy.${key}`),
224
+ func
225
+ );
226
+ if (instrumented) {
227
+ updates.lazy = Object.assign(updates.lazy || {}, {
228
+ [key]: instrumented
229
+ });
230
+ }
231
+ }
232
+ });
233
+ }
234
+ }
235
+ return updates;
236
+ }
237
+
110
238
  // lib/router/utils.ts
111
239
  function createContext(defaultValue) {
112
240
  return { defaultValue };
@@ -200,19 +328,23 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
200
328
  if (isIndexRoute(route)) {
201
329
  let indexRoute = {
202
330
  ...route,
203
- ...mapRouteProperties(route),
204
331
  id
205
332
  };
206
- manifest[id] = indexRoute;
333
+ manifest[id] = mergeRouteUpdates(
334
+ indexRoute,
335
+ mapRouteProperties(indexRoute)
336
+ );
207
337
  return indexRoute;
208
338
  } else {
209
339
  let pathOrLayoutRoute = {
210
340
  ...route,
211
- ...mapRouteProperties(route),
212
341
  id,
213
342
  children: void 0
214
343
  };
215
- manifest[id] = pathOrLayoutRoute;
344
+ manifest[id] = mergeRouteUpdates(
345
+ pathOrLayoutRoute,
346
+ mapRouteProperties(pathOrLayoutRoute)
347
+ );
216
348
  if (route.children) {
217
349
  pathOrLayoutRoute.children = convertRoutesToDataRoutes(
218
350
  route.children,
@@ -226,6 +358,17 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
226
358
  }
227
359
  });
228
360
  }
361
+ function mergeRouteUpdates(route, updates) {
362
+ return Object.assign(route, {
363
+ ...updates,
364
+ ...typeof updates.lazy === "object" && updates.lazy != null ? {
365
+ lazy: {
366
+ ...route.lazy,
367
+ ...updates.lazy
368
+ }
369
+ } : {}
370
+ });
371
+ }
229
372
  function matchRoutes(routes, locationArg, basename = "/") {
230
373
  return matchRoutesImpl(routes, locationArg, basename, false);
231
374
  }
@@ -652,6 +795,9 @@ var ErrorResponseImpl = class {
652
795
  function isRouteErrorResponse(error) {
653
796
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
654
797
  }
798
+ function getRoutePattern(paths) {
799
+ return paths.filter(Boolean).join("/").replace(/\/\/*/g, "/");
800
+ }
655
801
 
656
802
  // lib/router/router.ts
657
803
  var validMutationMethodsArr = [
@@ -682,7 +828,20 @@ function createStaticHandler(routes, opts) {
682
828
  );
683
829
  let manifest = {};
684
830
  let basename = (opts ? opts.basename : null) || "/";
685
- let mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
831
+ let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
832
+ let mapRouteProperties = _mapRouteProperties;
833
+ if (opts?.unstable_instrumentations) {
834
+ let instrumentations = opts.unstable_instrumentations;
835
+ mapRouteProperties = (route) => {
836
+ return {
837
+ ..._mapRouteProperties(route),
838
+ ...getInstrumentationUpdates(
839
+ instrumentations.map((i) => i.route).filter(Boolean),
840
+ route
841
+ )
842
+ };
843
+ };
844
+ }
686
845
  let dataRoutes = convertRoutesToDataRoutes(
687
846
  routes,
688
847
  mapRouteProperties,
@@ -752,6 +911,7 @@ function createStaticHandler(routes, opts) {
752
911
  let response = await runServerMiddlewarePipeline(
753
912
  {
754
913
  request,
914
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
755
915
  matches,
756
916
  params: matches[0].params,
757
917
  // If we're calling middleware then it must be enabled so we can cast
@@ -897,6 +1057,7 @@ function createStaticHandler(routes, opts) {
897
1057
  let response = await runServerMiddlewarePipeline(
898
1058
  {
899
1059
  request,
1060
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
900
1061
  matches,
901
1062
  params: matches[0].params,
902
1063
  // If we're calling middleware then it must be enabled so we can cast
@@ -1178,6 +1339,7 @@ function createStaticHandler(routes, opts) {
1178
1339
  mapRouteProperties,
1179
1340
  manifest,
1180
1341
  request,
1342
+ getRoutePattern(matches.map((m) => m.route.path)),
1181
1343
  match,
1182
1344
  [],
1183
1345
  requestContext,
@@ -1188,6 +1350,7 @@ function createStaticHandler(routes, opts) {
1188
1350
  mapRouteProperties,
1189
1351
  manifest,
1190
1352
  request,
1353
+ getRoutePattern(matches.map((m) => m.route.path)),
1191
1354
  match,
1192
1355
  [],
1193
1356
  requestContext,
@@ -1531,7 +1694,12 @@ async function runMiddlewarePipeline(args, handler, processResult, isResult, err
1531
1694
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
1532
1695
  );
1533
1696
  let result = await callRouteMiddleware(
1534
- { request, params, context },
1697
+ {
1698
+ request,
1699
+ params,
1700
+ context,
1701
+ pattern: getRoutePattern(matches.map((m) => m.route.path))
1702
+ },
1535
1703
  tuples,
1536
1704
  handler,
1537
1705
  processResult,
@@ -1609,7 +1777,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request,
1609
1777
  handler: lazyRoutePromises.lazyHandlerPromise
1610
1778
  };
1611
1779
  }
1612
- function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
1780
+ function getDataStrategyMatch(mapRouteProperties, manifest, request, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
1613
1781
  let isUsingNewApi = false;
1614
1782
  let _lazyPromises = getDataStrategyMatchLazyPromises(
1615
1783
  mapRouteProperties,
@@ -1643,6 +1811,7 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazy
1643
1811
  if (callHandler && !isMiddlewareOnlyRoute) {
1644
1812
  return callLoaderOrAction({
1645
1813
  request,
1814
+ pattern,
1646
1815
  match,
1647
1816
  lazyHandlerPromise: _lazyPromises?.handler,
1648
1817
  lazyRoutePromise: _lazyPromises?.route,
@@ -1676,6 +1845,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
1676
1845
  mapRouteProperties,
1677
1846
  manifest,
1678
1847
  request,
1848
+ getRoutePattern(matches.map((m) => m.route.path)),
1679
1849
  match,
1680
1850
  lazyRoutePropertiesToSkip,
1681
1851
  scopedContext,
@@ -1690,6 +1860,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
1690
1860
  }
1691
1861
  let dataStrategyArgs = {
1692
1862
  request,
1863
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
1693
1864
  params: matches[0].params,
1694
1865
  context: scopedContext,
1695
1866
  matches
@@ -1717,6 +1888,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
1717
1888
  }
1718
1889
  async function callLoaderOrAction({
1719
1890
  request,
1891
+ pattern,
1720
1892
  match,
1721
1893
  lazyHandlerPromise,
1722
1894
  lazyRoutePromise,
@@ -1743,6 +1915,7 @@ async function callLoaderOrAction({
1743
1915
  return handler(
1744
1916
  {
1745
1917
  request,
1918
+ pattern,
1746
1919
  params: match.params,
1747
1920
  context: scopedContext
1748
1921
  },
@@ -6,7 +6,7 @@ export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLi
6
6
  import { serialize, parse } from 'cookie';
7
7
 
8
8
  /**
9
- * react-router v0.0.0-experimental-e613d4238
9
+ * react-router v0.0.0-experimental-4e44d47
10
10
  *
11
11
  * Copyright (c) Remix Software Inc.
12
12
  *
@@ -86,6 +86,134 @@ function parsePath(path) {
86
86
  return parsedPath;
87
87
  }
88
88
 
89
+ // lib/router/instrumentation.ts
90
+ var UninstrumentedSymbol = Symbol("Uninstrumented");
91
+ function getInstrumentedImplementation(impls, handler, getInfo = () => void 0) {
92
+ if (impls.length === 0) {
93
+ return null;
94
+ }
95
+ return async (...args) => {
96
+ let value;
97
+ let info = getInfo(...args);
98
+ await recurseRight(
99
+ impls,
100
+ info,
101
+ async () => {
102
+ value = await handler(...args);
103
+ },
104
+ impls.length - 1
105
+ );
106
+ return value;
107
+ };
108
+ }
109
+ async function recurseRight(impls, info, handler, index) {
110
+ let impl = impls[index];
111
+ if (!impl) {
112
+ await handler();
113
+ } else {
114
+ await impl(async () => {
115
+ await recurseRight(impls, info, handler, index - 1);
116
+ }, info);
117
+ }
118
+ }
119
+ function getInstrumentationInfo(args) {
120
+ let { request, context, params, pattern } = args;
121
+ return {
122
+ // pseudo "Request" with the info they may want to read from
123
+ request: {
124
+ method: request.method,
125
+ url: request.url,
126
+ // Maybe make this a proxy that only supports `get`?
127
+ headers: {
128
+ get: (...args2) => request.headers.get(...args2)
129
+ }
130
+ },
131
+ params: { ...params },
132
+ pattern,
133
+ context: {
134
+ get: (...args2) => context.get(...args2)
135
+ }
136
+ };
137
+ }
138
+ function getInstrumentationsByType(instrumentations, key) {
139
+ let value = [];
140
+ for (let i in instrumentations) {
141
+ let instrumentation = instrumentations[i];
142
+ if (key in instrumentation && instrumentation[key] != null) {
143
+ value.push(instrumentation[key]);
144
+ }
145
+ }
146
+ return value;
147
+ }
148
+ function getInstrumentationUpdates(fns, route) {
149
+ let instrumentations = [];
150
+ fns.forEach(
151
+ (fn) => fn({
152
+ id: route.id,
153
+ index: route.index,
154
+ path: route.path,
155
+ instrument(i) {
156
+ instrumentations.push(i);
157
+ }
158
+ })
159
+ );
160
+ let updates = {};
161
+ if (instrumentations.length > 0) {
162
+ ["lazy", "loader", "action"].forEach((key) => {
163
+ let func = route[key];
164
+ if (typeof func === "function") {
165
+ let original = func[UninstrumentedSymbol] ?? func;
166
+ let instrumented = getInstrumentedImplementation(
167
+ getInstrumentationsByType(instrumentations, key),
168
+ original,
169
+ key === "lazy" ? () => void 0 : (...args) => getInstrumentationInfo(
170
+ args[0]
171
+ )
172
+ );
173
+ if (instrumented) {
174
+ instrumented[UninstrumentedSymbol] = original;
175
+ updates[key] = instrumented;
176
+ }
177
+ }
178
+ });
179
+ if (route.middleware && route.middleware.length > 0) {
180
+ updates.middleware = route.middleware.map((middleware) => {
181
+ let original = middleware[UninstrumentedSymbol] ?? middleware;
182
+ let instrumented = getInstrumentedImplementation(
183
+ getInstrumentationsByType(instrumentations, "middleware"),
184
+ original,
185
+ (...args) => getInstrumentationInfo(
186
+ args[0]
187
+ )
188
+ );
189
+ if (instrumented) {
190
+ instrumented[UninstrumentedSymbol] = original;
191
+ return instrumented;
192
+ }
193
+ return middleware;
194
+ });
195
+ }
196
+ if (typeof route.lazy === "object") {
197
+ let lazyObject = route.lazy;
198
+ ["middleware", "loader", "action"].forEach((key) => {
199
+ let func = lazyObject[key];
200
+ if (typeof func === "function") {
201
+ let instrumented = getInstrumentedImplementation(
202
+ getInstrumentationsByType(instrumentations, `lazy.${key}`),
203
+ func
204
+ );
205
+ if (instrumented) {
206
+ updates.lazy = Object.assign(updates.lazy || {}, {
207
+ [key]: instrumented
208
+ });
209
+ }
210
+ }
211
+ });
212
+ }
213
+ }
214
+ return updates;
215
+ }
216
+
89
217
  // lib/router/utils.ts
90
218
  function createContext(defaultValue) {
91
219
  return { defaultValue };
@@ -179,19 +307,23 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
179
307
  if (isIndexRoute(route)) {
180
308
  let indexRoute = {
181
309
  ...route,
182
- ...mapRouteProperties(route),
183
310
  id
184
311
  };
185
- manifest[id] = indexRoute;
312
+ manifest[id] = mergeRouteUpdates(
313
+ indexRoute,
314
+ mapRouteProperties(indexRoute)
315
+ );
186
316
  return indexRoute;
187
317
  } else {
188
318
  let pathOrLayoutRoute = {
189
319
  ...route,
190
- ...mapRouteProperties(route),
191
320
  id,
192
321
  children: void 0
193
322
  };
194
- manifest[id] = pathOrLayoutRoute;
323
+ manifest[id] = mergeRouteUpdates(
324
+ pathOrLayoutRoute,
325
+ mapRouteProperties(pathOrLayoutRoute)
326
+ );
195
327
  if (route.children) {
196
328
  pathOrLayoutRoute.children = convertRoutesToDataRoutes(
197
329
  route.children,
@@ -205,6 +337,17 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
205
337
  }
206
338
  });
207
339
  }
340
+ function mergeRouteUpdates(route, updates) {
341
+ return Object.assign(route, {
342
+ ...updates,
343
+ ...typeof updates.lazy === "object" && updates.lazy != null ? {
344
+ lazy: {
345
+ ...route.lazy,
346
+ ...updates.lazy
347
+ }
348
+ } : {}
349
+ });
350
+ }
208
351
  function matchRoutes(routes, locationArg, basename = "/") {
209
352
  return matchRoutesImpl(routes, locationArg, basename, false);
210
353
  }
@@ -631,6 +774,9 @@ var ErrorResponseImpl = class {
631
774
  function isRouteErrorResponse(error) {
632
775
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
633
776
  }
777
+ function getRoutePattern(paths) {
778
+ return paths.filter(Boolean).join("/").replace(/\/\/*/g, "/");
779
+ }
634
780
 
635
781
  // lib/router/router.ts
636
782
  var validMutationMethodsArr = [
@@ -661,7 +807,20 @@ function createStaticHandler(routes, opts) {
661
807
  );
662
808
  let manifest = {};
663
809
  let basename = (opts ? opts.basename : null) || "/";
664
- let mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
810
+ let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
811
+ let mapRouteProperties = _mapRouteProperties;
812
+ if (opts?.unstable_instrumentations) {
813
+ let instrumentations = opts.unstable_instrumentations;
814
+ mapRouteProperties = (route) => {
815
+ return {
816
+ ..._mapRouteProperties(route),
817
+ ...getInstrumentationUpdates(
818
+ instrumentations.map((i) => i.route).filter(Boolean),
819
+ route
820
+ )
821
+ };
822
+ };
823
+ }
665
824
  let dataRoutes = convertRoutesToDataRoutes(
666
825
  routes,
667
826
  mapRouteProperties,
@@ -731,6 +890,7 @@ function createStaticHandler(routes, opts) {
731
890
  let response = await runServerMiddlewarePipeline(
732
891
  {
733
892
  request,
893
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
734
894
  matches,
735
895
  params: matches[0].params,
736
896
  // If we're calling middleware then it must be enabled so we can cast
@@ -876,6 +1036,7 @@ function createStaticHandler(routes, opts) {
876
1036
  let response = await runServerMiddlewarePipeline(
877
1037
  {
878
1038
  request,
1039
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
879
1040
  matches,
880
1041
  params: matches[0].params,
881
1042
  // If we're calling middleware then it must be enabled so we can cast
@@ -1157,6 +1318,7 @@ function createStaticHandler(routes, opts) {
1157
1318
  mapRouteProperties,
1158
1319
  manifest,
1159
1320
  request,
1321
+ getRoutePattern(matches.map((m) => m.route.path)),
1160
1322
  match,
1161
1323
  [],
1162
1324
  requestContext,
@@ -1167,6 +1329,7 @@ function createStaticHandler(routes, opts) {
1167
1329
  mapRouteProperties,
1168
1330
  manifest,
1169
1331
  request,
1332
+ getRoutePattern(matches.map((m) => m.route.path)),
1170
1333
  match,
1171
1334
  [],
1172
1335
  requestContext,
@@ -1510,7 +1673,12 @@ async function runMiddlewarePipeline(args, handler, processResult, isResult, err
1510
1673
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
1511
1674
  );
1512
1675
  let result = await callRouteMiddleware(
1513
- { request, params, context },
1676
+ {
1677
+ request,
1678
+ params,
1679
+ context,
1680
+ pattern: getRoutePattern(matches.map((m) => m.route.path))
1681
+ },
1514
1682
  tuples,
1515
1683
  handler,
1516
1684
  processResult,
@@ -1588,7 +1756,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request,
1588
1756
  handler: lazyRoutePromises.lazyHandlerPromise
1589
1757
  };
1590
1758
  }
1591
- function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
1759
+ function getDataStrategyMatch(mapRouteProperties, manifest, request, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
1592
1760
  let isUsingNewApi = false;
1593
1761
  let _lazyPromises = getDataStrategyMatchLazyPromises(
1594
1762
  mapRouteProperties,
@@ -1622,6 +1790,7 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazy
1622
1790
  if (callHandler && !isMiddlewareOnlyRoute) {
1623
1791
  return callLoaderOrAction({
1624
1792
  request,
1793
+ pattern,
1625
1794
  match,
1626
1795
  lazyHandlerPromise: _lazyPromises?.handler,
1627
1796
  lazyRoutePromise: _lazyPromises?.route,
@@ -1655,6 +1824,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
1655
1824
  mapRouteProperties,
1656
1825
  manifest,
1657
1826
  request,
1827
+ getRoutePattern(matches.map((m) => m.route.path)),
1658
1828
  match,
1659
1829
  lazyRoutePropertiesToSkip,
1660
1830
  scopedContext,
@@ -1669,6 +1839,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
1669
1839
  }
1670
1840
  let dataStrategyArgs = {
1671
1841
  request,
1842
+ pattern: getRoutePattern(matches.map((m) => m.route.path)),
1672
1843
  params: matches[0].params,
1673
1844
  context: scopedContext,
1674
1845
  matches
@@ -1696,6 +1867,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
1696
1867
  }
1697
1868
  async function callLoaderOrAction({
1698
1869
  request,
1870
+ pattern,
1699
1871
  match,
1700
1872
  lazyHandlerPromise,
1701
1873
  lazyRoutePromise,
@@ -1722,6 +1894,7 @@ async function callLoaderOrAction({
1722
1894
  return handler(
1723
1895
  {
1724
1896
  request,
1897
+ pattern,
1725
1898
  params: match.params,
1726
1899
  context: scopedContext
1727
1900
  },