@farm.js/plugin 0.1.34 → 0.1.35

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/index.d.ts CHANGED
@@ -39,5 +39,5 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export declare const version = "0.1.34";
42
+ export declare const version = "0.1.35";
43
43
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@
39
39
  * })
40
40
  * ```
41
41
  */
42
- export const version = "0.1.34";
42
+ export const version = "0.1.35";
43
43
  // Note: Import plugins from their respective subpaths:
44
44
  // - @farm.js/plugin/rsc
45
45
  // - @farm.js/plugin/middleware
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAovC1D"}
1
+ {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAowC1D"}
@@ -476,25 +476,36 @@ debug('Discovered API routes:', Array.from(apiRouteMap.keys()));
476
476
  * Convert an app-relative middleware file path to the route it guards, with the
477
477
  * same rules as core's middleware discovery: a route group such as
478
478
  * '(protected)' or a parallel route slot such as '@team' adds no URL segment,
479
- * and a '_private' or dot-prefixed folder holds no routes, so its middleware
480
- * never runs (null).
479
+ * an intercepting folder guards the URL it intercepts, a '_private' folder
480
+ * routes its pages so its middleware guards them, and a dot-prefixed folder
481
+ * holds no routes, so its middleware never runs (null).
481
482
  * e.g., '/middleware.ts' -> '/'
482
483
  * e.g., '/(protected)/dashboard/middleware.ts' -> '/dashboard'
483
484
  * e.g., '/dashboard/@team/middleware.ts' -> '/dashboard'
485
+ * e.g., '/feed/@modal/(.)photo/middleware.ts' -> '/feed/photo'
484
486
  */
485
487
  function middlewarePathToRoute(filePath) {
486
488
  const segments = filePath
487
489
  .replace(/\\/middleware\\.[tj]sx?$/, '')
488
490
  .split('/')
489
491
  .filter(Boolean);
490
- if (segments.some((segment) => segment.startsWith('_') || segment.startsWith('.'))) {
492
+ if (segments.some((segment) => segment.startsWith('.'))) {
491
493
  return null;
492
494
  }
493
- const routeSegments = segments.filter(
494
- (segment) =>
495
- !(segment.startsWith('(') && segment.endsWith(')')) &&
496
- !/^@[A-Za-z][A-Za-z0-9_-]*$/.test(segment),
497
- );
495
+ const routeSegments = [];
496
+ for (const segment of segments) {
497
+ const marker = /^((?:\\(\\.\\.\\))+|\\(\\.\\.\\.\\)|\\(\\.\\))(.*)$/.exec(segment);
498
+ if (marker) {
499
+ if (marker[1] === '(...)') routeSegments.length = 0;
500
+ else if (marker[1] !== '(.)') routeSegments.splice(-(marker[1].length / 4));
501
+ if (marker[2]) routeSegments.push(marker[2]);
502
+ continue;
503
+ }
504
+ if ((segment.startsWith('(') && segment.endsWith(')')) || /^@[A-Za-z][A-Za-z0-9_-]*$/.test(segment)) {
505
+ continue;
506
+ }
507
+ routeSegments.push(segment);
508
+ }
498
509
  return routeSegments.length === 0 ? '/' : '/' + routeSegments.join('/');
499
510
  }
500
511
 
@@ -553,7 +564,12 @@ const RouteErrorBoundary = React.Component
553
564
 
554
565
  // Parse and rank once per entry initialization, not on every request. Use the
555
566
  // same validation, decoding and specificity rules as Farm's ordinary router.
556
- const pageRoutes = Object.entries(pages).map(([filePath, module]) => ({
567
+ // RSC renders no parallel route slots, so a page inside '@modal/...' would otherwise
568
+ // answer at its literal folder path ('/feed/@modal/(.)photo/1'), past the middleware
569
+ // that guards the URL it intercepts.
570
+ const pageRoutes = Object.entries(pages)
571
+ .filter(([filePath]) => !filePath.split('/').some((segment) => /^@[A-Za-z][A-Za-z0-9_-]*$/.test(segment)))
572
+ .map(([filePath, module]) => ({
557
573
  filePath,
558
574
  module,
559
575
  segments: parseRoutePath(filePath).segments,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Official plugins for Farm.js framework",
5
5
  "license": "MIT",
6
6
  "author": "Farm.js Team",
@@ -62,7 +62,7 @@
62
62
  "nitro": "3.0.260903-beta",
63
63
  "picocolors": "^1.0.0",
64
64
  "rsc-html-stream": "^0.0.4",
65
- "@farm.js/core": "0.1.34"
65
+ "@farm.js/core": "0.1.35"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^22.20.5",
@@ -83,7 +83,7 @@
83
83
  "react-dom": "19.2.8",
84
84
  "react-server-dom-webpack": "19.2.8",
85
85
  "vite": ">=6.0.0",
86
- "@farm.js/core": "0.1.34"
86
+ "@farm.js/core": "0.1.35"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@vitejs/plugin-rsc": {