@farm.js/plugin 0.1.38 → 0.1.39

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.38";
42
+ export declare const version = "0.1.39";
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.38";
42
+ export const version = "0.1.39";
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,CAuwC1D"}
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,CA8xC1D"}
@@ -124,8 +124,10 @@ const farmMarkdownConfig = ${JSON.stringify(ctx.markdown ?? { enabled: false, ex
124
124
  createFarmLlmsFullRenderer,
125
125
  createFarmLlmsMarkdownReader,
126
126
  createFarmMetadataRouteResponse,
127
+ farmPathGuardCoversPage,
127
128
  renderFarmLlmsFullTxt,
128
129
  } from '@farm.js/core/internal/production-runtime';
130
+ import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS } from '@farm.js/core/internal/app-markdown-runtime';
129
131
 
130
132
  const farmLlmsTxtConfig = ${JSON.stringify(ctx.llmsTxt)};
131
133
  const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });
@@ -218,6 +220,10 @@ function applyActionResponseHeaders(headers, request) {
218
220
  headers.set('cache-control', 'no-store');
219
221
  headers.set('x-content-type-options', 'nosniff');
220
222
  }
223
+ // A page renders per request (cookies, headers, client address), so a shared
224
+ // cache must not keep its HTML or Flight payload unless middleware chose a
225
+ // policy. Core's server defaults pages the same way.
226
+ if (!headers.has('cache-control')) headers.set('cache-control', 'private, no-store');
221
227
  }
222
228
 
223
229
  // Auto-discover all route modules. Every glob remains a literal so Vite can analyze it.
@@ -1164,14 +1170,24 @@ ${ctx.llmsTxt?.enabled
1164
1170
  */
1165
1171
  function createFarmLlmsTxtContext(request, context, full) {
1166
1172
  const origin = new URL(request.url).origin;
1173
+ // A page a path-specific guard covers (a non-root middleware.ts, a config
1174
+ // middleware matcher naming the path) is left out, as core's server does.
1175
+ const guard = {
1176
+ config: { middleware: farmConfigMiddleware },
1177
+ middlewareRoutes: Object.keys(middlewares)
1178
+ .map((filePath) => ({ path: middlewarePathToRoute(filePath) }))
1179
+ .filter((route) => route.path !== null),
1180
+ };
1167
1181
  const pages = collectFarmLlmsTxtPages(
1168
- pageRoutes.map(({ module, segments }) => ({
1169
- // Dynamic routes have no single URL, so the collector skips them.
1170
- pattern: '/' + segments
1171
- .map((part) => (part.isDynamic ? '[' + part.segment + ']' : part.segment))
1172
- .join('/'),
1173
- metadata: module && module.metadata,
1174
- })),
1182
+ pageRoutes
1183
+ .map(({ module, segments }) => ({
1184
+ // Dynamic routes have no single URL, so the collector skips them.
1185
+ pattern: '/' + segments
1186
+ .map((part) => (part.isDynamic ? '[' + part.segment + ']' : part.segment))
1187
+ .join('/'),
1188
+ metadata: module && module.metadata,
1189
+ }))
1190
+ .filter((page) => page.pattern.includes('[') || !farmPathGuardCoversPage(guard, page.pattern)),
1175
1191
  {
1176
1192
  origin,
1177
1193
  markdown: farmMarkdownConfig,
@@ -1187,10 +1203,17 @@ function createFarmLlmsTxtContext(request, context, full) {
1187
1203
  config: farmLlmsTxtConfig,
1188
1204
  rootMetadata: rootLayout && rootLayout.metadata,
1189
1205
  }),
1190
- // Pages are read in-process through the full handler with a fresh request,
1191
- // so the caller's cookies never shape the file. HEAD reads nothing.
1206
+ // Pages are read in-process through the full handler as an anonymous
1207
+ // visitor: a fresh request, so the caller's cookies never shape the file,
1208
+ // and a neutral client address, so an IP allowlist never admits the read.
1209
+ // The body is shared across callers. HEAD reads nothing.
1192
1210
  markdown: full && request.method.toUpperCase() !== 'HEAD'
1193
- ? createFarmLlmsMarkdownReader((page) => handler(page, context))
1211
+ ? createFarmLlmsMarkdownReader((page) =>
1212
+ handler(page, {
1213
+ waitUntil: context && context.waitUntil,
1214
+ clientAddress: FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS,
1215
+ }),
1216
+ )
1194
1217
  : async () => null,
1195
1218
  };
1196
1219
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
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.38"
65
+ "@farm.js/core": "0.1.39"
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.38"
86
+ "@farm.js/core": "0.1.39"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@vitejs/plugin-rsc": {