@farm.js/plugin 0.1.1-beta.2 → 0.1.1
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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/rsc/entries/rsc.d.ts +5 -0
- package/dist/rsc/entries/rsc.d.ts.map +1 -1
- package/dist/rsc/entries/rsc.js +21 -5
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/index.js +7 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { EntryContext } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates the terminal middleware-result handling shared by the RSC entry
|
|
4
|
+
* and its executable contract tests.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateRscMiddlewareResultHandling(): string;
|
|
2
7
|
/**
|
|
3
8
|
* Generates the RSC environment entry file.
|
|
4
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAe5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAy+B1D"}
|
package/dist/rsc/entries/rsc.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the terminal middleware-result handling shared by the RSC entry
|
|
3
|
+
* and its executable contract tests.
|
|
4
|
+
*/
|
|
5
|
+
export function generateRscMiddlewareResultHandling() {
|
|
6
|
+
return `
|
|
7
|
+
// If middleware handled the request (e.g., redirect, auth), return the response
|
|
8
|
+
if (middlewareResult.response) {
|
|
9
|
+
return middlewareResult.response;
|
|
10
|
+
}
|
|
11
|
+
// notFound() in middleware stops the request before any route runs. It gets
|
|
12
|
+
// the same 404 as a page-level notFound(), plus headers middleware set.
|
|
13
|
+
if (middlewareResult.notFound) {
|
|
14
|
+
return applyProductionMiddlewareHeaders(
|
|
15
|
+
new Response('Not Found', { status: 404, headers: { 'cache-control': 'no-store' } }),
|
|
16
|
+
middlewareResult.headers,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* Generates the RSC environment entry file.
|
|
3
23
|
*
|
|
@@ -529,11 +549,7 @@ async function handleFarmRequest(request, context) {
|
|
|
529
549
|
|
|
530
550
|
// Execute middleware first
|
|
531
551
|
const middlewareResult = await executeMiddleware(request, context);
|
|
532
|
-
|
|
533
|
-
// If middleware handled the request (e.g., redirect, auth), return the response
|
|
534
|
-
if (middlewareResult.response) {
|
|
535
|
-
return middlewareResult.response;
|
|
536
|
-
}
|
|
552
|
+
${generateRscMiddlewareResultHandling()}
|
|
537
553
|
|
|
538
554
|
request = middlewareResult.request;
|
|
539
555
|
url = new URL(request.url);
|
package/dist/rsc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,E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AAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,gHAAgH;IAChH,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,aAAkB,GAAG,UAAU,CA2DnE;AAuXD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CA8yC5E"}
|
package/dist/rsc/index.js
CHANGED
|
@@ -43,7 +43,8 @@ import { pathToFileURL } from "node:url";
|
|
|
43
43
|
import { createRequire } from "node:module";
|
|
44
44
|
// Use API and middleware plugins from @farm.js/core (require so CJS build resolves when ESM .mjs is missing)
|
|
45
45
|
const require_ = createRequire(import.meta.url);
|
|
46
|
-
const { farmApiPlugin
|
|
46
|
+
const { farmApiPlugin } = require_("@farm.js/core");
|
|
47
|
+
const { farmMiddlewarePlugin } = require_("@farm.js/core/middleware");
|
|
47
48
|
const { resolveServerActionsConfig, validateServerActionRequest, createServerActionRequestErrorResponse, } = require_("@farm.js/core/server-action-security");
|
|
48
49
|
const { normalizeFarmDeploymentId } = require_("@farm.js/core/deployment");
|
|
49
50
|
const { getFarmLayerAliases, getFarmSourceRoots, resolveFarmLayers } = require_("@farm.js/core/server");
|
|
@@ -91,7 +92,11 @@ export function defineConfig(config = {}) {
|
|
|
91
92
|
jsxImportSource: "react",
|
|
92
93
|
},
|
|
93
94
|
plugins: [
|
|
94
|
-
farmMiddlewarePlugin({
|
|
95
|
+
farmMiddlewarePlugin({
|
|
96
|
+
srcDir: config.srcDir ?? "src",
|
|
97
|
+
basePath: config.basePath ?? "/",
|
|
98
|
+
debug,
|
|
99
|
+
}),
|
|
95
100
|
farmApiPlugin({
|
|
96
101
|
srcDir: config.srcDir ?? "src",
|
|
97
102
|
debug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farm.js/plugin",
|
|
3
|
-
"version": "0.1.1
|
|
3
|
+
"version": "0.1.1",
|
|
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.1
|
|
65
|
+
"@farm.js/core": "0.1.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/node": "^20.19.21",
|
|
@@ -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.1
|
|
86
|
+
"@farm.js/core": "0.1.1"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@vitejs/plugin-rsc": {
|