@farm.js/plugin 0.1.61 → 0.1.62
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.js +1 -1
- package/dist/middleware/index.d.ts +8 -1
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +16 -10
- package/dist/middleware/matching.d.ts +4 -2
- package/dist/middleware/matching.d.ts.map +1 -1
- package/dist/middleware/matching.js +7 -47
- package/dist/rsc/client-sourcemaps.d.ts +13 -0
- package/dist/rsc/client-sourcemaps.d.ts.map +1 -0
- package/dist/rsc/client-sourcemaps.js +52 -0
- package/dist/rsc/document-layouts.d.ts +16 -0
- package/dist/rsc/document-layouts.d.ts.map +1 -0
- package/dist/rsc/document-layouts.js +82 -0
- package/dist/rsc/entries/client.d.ts.map +1 -1
- package/dist/rsc/entries/client.js +92 -16
- package/dist/rsc/entries/rsc.d.ts.map +1 -1
- package/dist/rsc/entries/rsc.js +563 -45
- package/dist/rsc/entries/ssr.d.ts.map +1 -1
- package/dist/rsc/entries/ssr.js +7 -6
- package/dist/rsc/index.d.ts +38 -3
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/index.js +282 -292
- package/dist/rsc/middleware-config-module.d.ts +3 -0
- package/dist/rsc/middleware-config-module.d.ts.map +1 -1
- package/dist/rsc/middleware-config-module.js +41 -28
- package/dist/rsc/mobile-client.d.ts +67 -0
- package/dist/rsc/mobile-client.d.ts.map +1 -0
- package/dist/rsc/mobile-client.js +148 -0
- package/dist/rsc/nitro-build.d.ts.map +1 -1
- package/dist/rsc/nitro-build.js +268 -81
- package/dist/rsc/server-fn-transform.d.ts +1 -5
- package/dist/rsc/server-fn-transform.d.ts.map +1 -1
- package/dist/rsc/server-fn-transform.js +3 -338
- package/dist/rsc/types.d.ts +39 -0
- package/dist/rsc/types.d.ts.map +1 -1
- package/dist/rsc/vite-plugin-nitro.d.ts +2 -0
- package/dist/rsc/vite-plugin-nitro.d.ts.map +1 -1
- package/dist/rsc/vite-plugin-nitro.js +12 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/ssr.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":"ssr.d.ts","sourceRoot":"","sources":["../../../src/rsc/entries/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAgN1D"}
|
package/dist/rsc/entries/ssr.js
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export function generateSsrEntry(ctx) {
|
|
12
12
|
const debugLog = `// Debug disabled`;
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const globalsCssPath = ctx.globalCssPath ?? `/${ctx.srcDir}${routesPath}/globals.css`;
|
|
13
|
+
// Only a global stylesheet the build found: a guessed path 404s in apps that import their CSS.
|
|
14
|
+
const globalsCssPath = ctx.globalCssPath ?? "";
|
|
16
15
|
return `
|
|
17
16
|
import React from 'react';
|
|
18
17
|
import { createFromReadableStream } from '@vitejs/plugin-rsc/ssr';
|
|
@@ -117,6 +116,8 @@ export async function renderHTML(firstArg, options = {}) {
|
|
|
117
116
|
// calls client references on the server (for example, a "use client" Counter).
|
|
118
117
|
const payload = await createFromReadableStream(s1);
|
|
119
118
|
const rootElement = payload.root;
|
|
119
|
+
// The route's resolved metadata as head tags (core's renderMetadataHead), then the stylesheet.
|
|
120
|
+
const headTags = (typeof payload.metadataHead === 'string' ? payload.metadataHead : '') + cssLinkTag;
|
|
120
121
|
|
|
121
122
|
function Root() {
|
|
122
123
|
return rootElement;
|
|
@@ -171,7 +172,7 @@ export async function renderHTML(firstArg, options = {}) {
|
|
|
171
172
|
passThrough.on('error', (e) => controller.error(e));
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
|
-
let out = webStream.pipeThrough(injectIntoHeadStream(
|
|
175
|
+
let out = webStream.pipeThrough(injectIntoHeadStream(headTags));
|
|
175
176
|
out = out.pipeThrough(injectRSCPayload(s2));
|
|
176
177
|
out = out.pipeThrough(streamingClientScriptInjector);
|
|
177
178
|
return out;
|
|
@@ -181,8 +182,8 @@ export async function renderHTML(firstArg, options = {}) {
|
|
|
181
182
|
debug('Rendering to HTML stream (then buffering)');
|
|
182
183
|
const fullHtmlRaw = await pipeableStreamToString(passThrough);
|
|
183
184
|
let fullHtml = fullHtmlRaw;
|
|
184
|
-
if (
|
|
185
|
-
fullHtml = fullHtml.replace("</head>",
|
|
185
|
+
if (headTags && fullHtml.includes("</head>")) {
|
|
186
|
+
fullHtml = fullHtml.replace("</head>", () => headTags + "</head>");
|
|
186
187
|
}
|
|
187
188
|
${ctx.actionsEnabled
|
|
188
189
|
? `// Ensure __viteRscCallServer is set before any module runs (fixes "is not a function" when form submits)
|
package/dist/rsc/index.d.ts
CHANGED
|
@@ -22,17 +22,22 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
import { type Plugin, type UserConfig } from "vite";
|
|
25
|
-
import type { FarmRscPluginOptions, EntryContext } from "./types.js";
|
|
25
|
+
import type { FarmRscPluginOptions, EntryContext, FarmRscMobileClient } from "./types.js";
|
|
26
26
|
import type { FarmServerActionsConfig } from "@farm.js/core/server-action-security";
|
|
27
27
|
import type { FarmAPIConfig } from "@farm.js/core/api";
|
|
28
28
|
import type { FarmMiddlewareConfig } from "@farm.js/core/middleware";
|
|
29
29
|
import type { FarmServerConfig } from "@farm.js/core/internal/production-runtime";
|
|
30
30
|
import type { FarmLayerEntry, ResolvedFarmLayer } from "@farm.js/core/server";
|
|
31
|
+
import { resolveFarmImageConfig } from "@farm.js/core/vite";
|
|
32
|
+
import { type FarmMarkdownUserConfig } from "@farm.js/core/markdown";
|
|
33
|
+
import type { FarmLlmsTxtUserConfig } from "@farm.js/core/internal/production-runtime";
|
|
34
|
+
import type { FarmMCPUserConfig } from "@farm.js/core/server";
|
|
31
35
|
export type { FarmRscPluginOptions, EntryContext };
|
|
32
36
|
export { buildRscNitro, waitForRscManifest, waitForRscOutputs } from "./nitro-build.js";
|
|
33
37
|
export type { BuildRscNitroOptions } from "./nitro-build.js";
|
|
34
38
|
export { default as nitro } from "./vite-plugin-nitro.js";
|
|
35
39
|
export type { NitroPluginOptions } from "./vite-plugin-nitro.js";
|
|
40
|
+
type FarmImageConfig = NonNullable<Parameters<typeof resolveFarmImageConfig>[0]>;
|
|
36
41
|
export interface FarmRscConfig {
|
|
37
42
|
srcDir?: string;
|
|
38
43
|
extends?: readonly FarmLayerEntry[];
|
|
@@ -42,13 +47,18 @@ export interface FarmRscConfig {
|
|
|
42
47
|
api?: FarmAPIConfig;
|
|
43
48
|
server?: FarmServerConfig;
|
|
44
49
|
middleware?: FarmMiddlewareConfig;
|
|
50
|
+
/** Same options as core's `images`: `<Image>` URLs and the optimizer at `images.path`. */
|
|
51
|
+
images?: FarmImageConfig;
|
|
45
52
|
port?: number;
|
|
46
53
|
experimental?: {
|
|
47
54
|
/**
|
|
48
|
-
* Enable React Server Components rendering.
|
|
55
|
+
* Enable React Server Components rendering. `{ mode: "rsc" }` is the same as `true`; this
|
|
56
|
+
* pipeline is the `"rsc"` engine of core's `experimental.serverComponents`.
|
|
49
57
|
* @default true
|
|
50
58
|
*/
|
|
51
|
-
serverComponents?: boolean
|
|
59
|
+
serverComponents?: boolean | {
|
|
60
|
+
mode: "rsc";
|
|
61
|
+
};
|
|
52
62
|
/**
|
|
53
63
|
* Enable React Server Actions and their public POST decoder.
|
|
54
64
|
* @default false
|
|
@@ -77,6 +87,31 @@ export interface FarmRscConfig {
|
|
|
77
87
|
};
|
|
78
88
|
/** Extra Vite plugins (e.g. rsc() with entries so client build resolves virtual:vite-rsc/client-references). */
|
|
79
89
|
plugins?: any[];
|
|
90
|
+
/**
|
|
91
|
+
* Markdown mirrors for agents: `/page.md` and `Accept: text/markdown`, with
|
|
92
|
+
* `?outline`, `?section`, `?max_tokens`, and `?actions`. Same options as core's `md`.
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
md?: FarmMarkdownUserConfig | boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Agent-facing files. `llmsTxt` serves `/llms.txt`, an index of the app's
|
|
98
|
+
* static pages that links to their Markdown mirrors, and with `full: true`
|
|
99
|
+
* also `/llms-full.txt`, which inlines them. Same options as core's
|
|
100
|
+
* `agent.llmsTxt`; `false` turns it off.
|
|
101
|
+
* @default { llmsTxt: { full: false } }
|
|
102
|
+
*/
|
|
103
|
+
agent?: {
|
|
104
|
+
llmsTxt?: boolean | FarmLlmsTxtUserConfig;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* An MCP endpoint for agents, with the same options as core's top-level
|
|
108
|
+
* `mcp`. Requires `@farm.js/mcp`. Declare it directly in this config object:
|
|
109
|
+
* the server reads it, and only the bindings it uses, from this file.
|
|
110
|
+
* `oauth` is not supported in RSC apps yet.
|
|
111
|
+
*/
|
|
112
|
+
mcp?: FarmMCPUserConfig;
|
|
113
|
+
/** @internal See `FarmRscPluginOptions.mobileClient`; set by `farm dev` and `farm build`. */
|
|
114
|
+
mobileClient?: FarmRscMobileClient;
|
|
80
115
|
}
|
|
81
116
|
/**
|
|
82
117
|
* Define a Farm.js RSC configuration
|
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":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,MAAM,E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