next-ws 0.0.0-beta-20251223134748 → 0.0.0-beta-20260111002257

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.
package/dist/cli.cjs CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_minimist = __toESM(require("minimist"));
28
28
 
29
29
  // package.json
30
- var version = "0.0.0-beta-20251223134748";
30
+ var version = "0.0.0-beta-20260111002257";
31
31
 
32
32
  // src/commands/helpers/define.ts
33
33
  function defineCommandGroup(definition) {
@@ -112,14 +112,28 @@ function findMatchingRoute(nextServer, requestPathname) {
112
112
  // @ts-expect-error - getAppPathRoutes is protected
113
113
  ...nextServer.getAppPathRoutes()
114
114
  };
115
- let matchedRoute = void 0;
116
- for (const [routePath, [filePath]] of Object.entries(appPathRoutes)) {
117
- if (!routePath || !filePath) continue;
115
+ const sortedRoutes = Object.entries(appPathRoutes).filter(([routePath, file]) => routePath && file?.length).sort(([a], [b]) => scoreRoute(b) - scoreRoute(a));
116
+ for (const [routePath, [filePath]] of sortedRoutes) {
117
+ if (!filePath) continue;
118
118
  const realPath = `${basePath}${routePath}`;
119
119
  const routeParams = getRouteParams(realPath, requestPathname);
120
- if (routeParams) matchedRoute = { filename: filePath, params: routeParams };
120
+ if (routeParams) {
121
+ return { filename: filePath, params: routeParams };
122
+ }
123
+ }
124
+ return void 0;
125
+ }
126
+ function scoreRoute(routePath) {
127
+ const parts = routePath.split("/").filter(Boolean);
128
+ let score = 0;
129
+ if (parts.length === 0) score = Infinity;
130
+ for (const part of parts) {
131
+ if (part.startsWith("[[...")) score += -1;
132
+ else if (part.startsWith("[...")) score += 0;
133
+ else if (part.startsWith("[")) score += 2;
134
+ else score += 3;
121
135
  }
122
- return matchedRoute;
136
+ return score + parts.length;
123
137
  }
124
138
 
125
139
  // src/server/helpers/module.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-ws",
3
- "version": "0.0.0-beta-20251223134748",
3
+ "version": "0.0.0-beta-20260111002257",
4
4
  "description": "Add support for WebSockets in the Next.js app directory",
5
5
  "license": "MIT",
6
6
  "keywords": [