| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/server/ |
Upload File : |
import { normalizePathnameForRouteMatch } from "../routing/utils.js";
import { buildRouteTrie, trieMatch } from "../routing/route-trie.js";
import { matchRoutePattern } from "../routing/route-pattern.js";
//#region src/server/app-rsc-route-matching.ts
function createRouteParams() {
return Object.create(null);
}
function appRscPathnameParts(pathname) {
const pathOnly = pathname.split("?")[0];
return normalizePathnameForRouteMatch(pathOnly === "/" ? "/" : pathOnly.replace(/\/$/, "")).split("/").filter(Boolean);
}
function createAppRscRouteMatcher(routes) {
const routeTrie = buildRouteTrie(routes);
const interceptLookup = createInterceptLookup(routes);
return {
matchRoute(url) {
return trieMatch(routeTrie, appRscPathnameParts(url));
},
findIntercept(pathname, sourcePathname = null) {
const urlParts = appRscPathnameParts(pathname);
for (const entry of interceptLookup) {
const params = matchAppRscRoutePattern(urlParts, entry.targetPatternParts);
if (params !== null) {
let sourceParams = createRouteParams();
if (sourcePathname !== null) {
const sourceRoute = routes[entry.sourceRouteIndex];
const sourceParts = appRscPathnameParts(sourcePathname);
const matchedSourceParams = sourceRoute ? matchAppRscRoutePattern(sourceParts, sourceRoute.patternParts) : null;
if (matchedSourceParams !== null) sourceParams = matchedSourceParams;
}
return {
...entry,
matchedParams: mergeMatchedParams(sourceParams, params)
};
}
}
return null;
}
};
}
function createInterceptLookup(routes) {
const interceptLookup = [];
for (let routeIndex = 0; routeIndex < routes.length; routeIndex++) {
const route = routes[routeIndex];
if (!route.slots) continue;
for (const [slotKey, slotModule] of Object.entries(route.slots)) {
if (!slotModule.intercepts) continue;
for (const intercept of slotModule.intercepts) interceptLookup.push({
sourceRouteIndex: routeIndex,
slotKey,
targetPattern: intercept.targetPattern,
targetPatternParts: intercept.targetPattern.split("/").filter(Boolean),
interceptLayouts: intercept.interceptLayouts,
page: intercept.page,
params: intercept.params
});
}
}
return interceptLookup;
}
function matchAppRscRoutePattern(urlParts, patternParts) {
return matchRoutePattern(urlParts, patternParts);
}
function mergeMatchedParams(sourceParams, targetParams) {
return Object.assign(createRouteParams(), sourceParams, targetParams);
}
//#endregion
export { createAppRscRouteMatcher, matchAppRscRoutePattern };
//# sourceMappingURL=app-rsc-route-matching.js.map