vinext 0.0.42 → 0.0.43

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.
@@ -785,6 +785,10 @@ function matchPattern(urlParts, patternParts) {
785
785
  return params;
786
786
  }
787
787
 
788
+ function mergeMatchedParams(sourceParams, targetParams) {
789
+ return Object.assign(Object.create(null), sourceParams, targetParams);
790
+ }
791
+
788
792
  // Build a global intercepting route lookup for RSC navigation.
789
793
  // Maps target URL patterns to { sourceRouteIndex, slotKey, interceptPage, params }.
790
794
  const interceptLookup = [];
@@ -810,12 +814,23 @@ for (let ri = 0; ri < routes.length; ri++) {
810
814
  * Check if a pathname matches any intercepting route.
811
815
  * Returns the match info or null.
812
816
  */
813
- function findIntercept(pathname) {
817
+ function findIntercept(pathname, sourcePathname = null) {
814
818
  const urlParts = pathname.split("/").filter(Boolean);
815
819
  for (const entry of interceptLookup) {
816
820
  const params = matchPattern(urlParts, entry.targetPatternParts);
817
821
  if (params !== null) {
818
- return { ...entry, matchedParams: params };
822
+ let sourceParams = Object.create(null);
823
+ if (sourcePathname !== null) {
824
+ const sourceRoute = routes[entry.sourceRouteIndex];
825
+ const sourceParts = sourcePathname.split("/").filter(Boolean);
826
+ const matchedSourceParams = sourceRoute
827
+ ? matchPattern(sourceParts, sourceRoute.patternParts)
828
+ : null;
829
+ if (matchedSourceParams !== null) {
830
+ sourceParams = matchedSourceParams;
831
+ }
832
+ }
833
+ return { ...entry, matchedParams: mergeMatchedParams(sourceParams, params) };
819
834
  }
820
835
  }
821
836
  return null;
@@ -829,8 +844,9 @@ async function buildPageElements(route, params, routePath, pageRequest) {
829
844
  request,
830
845
  mountedSlotsHeader,
831
846
  } = pageRequest;
847
+ const hasPageModule = !!route.page;
832
848
  const PageComponent = route.page?.default;
833
- if (!PageComponent) {
849
+ if (hasPageModule && !PageComponent) {
834
850
  const _interceptionContext = opts?.interceptionContext ?? null;
835
851
  const _noExportRouteId = __createAppPayloadRouteId(routePath, _interceptionContext);
836
852
  let _noExportRootLayout = null;
@@ -954,7 +970,7 @@ async function buildPageElements(route, params, routePath, pageRequest) {
954
970
  : null;
955
971
 
956
972
  return __buildAppPageElements({
957
- element: createElement(PageComponent, pageProps),
973
+ element: PageComponent ? createElement(PageComponent, pageProps) : null,
958
974
  globalErrorModule: ${globalErrorVar ? globalErrorVar : "null"},
959
975
  isRscRequest,
960
976
  mountedSlotIds,
@@ -1696,7 +1712,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1696
1712
  cleanPathname,
1697
1713
  currentParams: actionParams,
1698
1714
  currentRoute: actionRoute,
1699
- findIntercept,
1715
+ findIntercept(pathname) {
1716
+ return findIntercept(pathname, interceptionContextHeader);
1717
+ },
1700
1718
  getRouteParamNames(sourceRoute) {
1701
1719
  return sourceRoute.params;
1702
1720
  },
@@ -2015,8 +2033,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2015
2033
  }
2016
2034
 
2017
2035
  // Build the component tree: layouts wrapping the page
2036
+ const hasPageModule = !!route.page;
2018
2037
  const PageComponent = route.page?.default;
2019
- if (!PageComponent) {
2038
+ if (hasPageModule && !PageComponent) {
2020
2039
  setHeadersContext(null);
2021
2040
  setNavigationContext(null);
2022
2041
  return new Response("Page has no default export", { status: 500 });
@@ -2188,7 +2207,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2188
2207
  },
2189
2208
  cleanPathname,
2190
2209
  currentRoute: route,
2191
- findIntercept,
2210
+ findIntercept(pathname) {
2211
+ return findIntercept(pathname, interceptionContextHeader);
2212
+ },
2192
2213
  getRouteParamNames(sourceRoute) {
2193
2214
  return sourceRoute.params;
2194
2215
  },
@@ -2326,6 +2347,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2326
2347
  return LayoutComp({ params: _asyncLayoutParams, children: null });
2327
2348
  },
2328
2349
  probePage() {
2350
+ if (!PageComponent) return null;
2329
2351
  const _probeSearchObj = {};
2330
2352
  url.searchParams.forEach(function(v, k) {
2331
2353
  if (k in _probeSearchObj) {