@farm.js/plugin 0.1.0-beta.10 → 0.1.0-beta.13

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.
Files changed (52) hide show
  1. package/dist/api/index.d.ts +42 -0
  2. package/dist/api/index.d.ts.map +1 -0
  3. package/dist/api/index.js +493 -0
  4. package/dist/context/index.d.ts +61 -0
  5. package/dist/context/index.d.ts.map +1 -0
  6. package/dist/context/index.js +75 -0
  7. package/dist/index.d.ts +43 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +49 -0
  10. package/dist/middleware/index.d.ts +97 -0
  11. package/dist/middleware/index.d.ts.map +1 -0
  12. package/dist/middleware/index.js +469 -0
  13. package/dist/observability/index.d.ts +190 -0
  14. package/dist/observability/index.d.ts.map +1 -0
  15. package/dist/observability/index.js +399 -0
  16. package/dist/rsc/automatic-optimized-boundary.d.ts +11 -0
  17. package/dist/rsc/automatic-optimized-boundary.d.ts.map +1 -0
  18. package/dist/rsc/automatic-optimized-boundary.js +162 -0
  19. package/dist/rsc/build-paths.d.ts +3 -0
  20. package/dist/rsc/build-paths.d.ts.map +1 -0
  21. package/dist/rsc/build-paths.js +8 -0
  22. package/dist/rsc/compatibility.d.ts +8 -0
  23. package/dist/rsc/compatibility.d.ts.map +1 -0
  24. package/dist/rsc/compatibility.js +46 -0
  25. package/dist/rsc/entries/client.d.ts +14 -0
  26. package/dist/rsc/entries/client.d.ts.map +1 -0
  27. package/dist/rsc/entries/client.js +283 -0
  28. package/dist/rsc/entries/rsc.d.ts +13 -0
  29. package/dist/rsc/entries/rsc.d.ts.map +1 -0
  30. package/dist/rsc/entries/rsc.js +932 -0
  31. package/dist/rsc/entries/ssr.d.ts +13 -0
  32. package/dist/rsc/entries/ssr.d.ts.map +1 -0
  33. package/dist/rsc/entries/ssr.js +245 -0
  34. package/dist/rsc/index.d.ts +87 -0
  35. package/dist/rsc/index.d.ts.map +1 -0
  36. package/dist/rsc/index.js +1389 -0
  37. package/dist/rsc/nitro-build.d.ts +36 -0
  38. package/dist/rsc/nitro-build.d.ts.map +1 -0
  39. package/dist/rsc/nitro-build.js +396 -0
  40. package/dist/rsc/optimized-boundary.d.ts +29 -0
  41. package/dist/rsc/optimized-boundary.d.ts.map +1 -0
  42. package/dist/rsc/optimized-boundary.js +243 -0
  43. package/dist/rsc/server-fn-transform.d.ts +6 -0
  44. package/dist/rsc/server-fn-transform.d.ts.map +1 -0
  45. package/dist/rsc/server-fn-transform.js +152 -0
  46. package/dist/rsc/types.d.ts +123 -0
  47. package/dist/rsc/types.d.ts.map +1 -0
  48. package/dist/rsc/types.js +1 -0
  49. package/dist/rsc/vite-plugin-nitro.d.ts +33 -0
  50. package/dist/rsc/vite-plugin-nitro.d.ts.map +1 -0
  51. package/dist/rsc/vite-plugin-nitro.js +163 -0
  52. package/package.json +3 -3
@@ -0,0 +1,243 @@
1
+ import { render, } from "@farming-labs/strata";
2
+ import { StaticFragment, } from "@farming-labs/strata/react-server";
3
+ import { createElement, Fragment, isValidElement } from "react";
4
+ const AUTOMATIC_MIN_NODES = 8;
5
+ const AUTOMATIC_MIN_BYTES = 256;
6
+ const AUTOMATIC_BOUNDARIES = new Set([
7
+ "article",
8
+ "aside",
9
+ "div",
10
+ "footer",
11
+ "header",
12
+ "main",
13
+ "nav",
14
+ "section",
15
+ "span",
16
+ ]);
17
+ const STRATA_TAGS = new Set([
18
+ "a",
19
+ "abbr",
20
+ "address",
21
+ "article",
22
+ "aside",
23
+ "b",
24
+ "blockquote",
25
+ "br",
26
+ "caption",
27
+ "cite",
28
+ "code",
29
+ "col",
30
+ "colgroup",
31
+ "dd",
32
+ "del",
33
+ "details",
34
+ "dfn",
35
+ "div",
36
+ "dl",
37
+ "dt",
38
+ "em",
39
+ "figcaption",
40
+ "figure",
41
+ "footer",
42
+ "h1",
43
+ "h2",
44
+ "h3",
45
+ "h4",
46
+ "h5",
47
+ "h6",
48
+ "header",
49
+ "hr",
50
+ "i",
51
+ "img",
52
+ "ins",
53
+ "kbd",
54
+ "li",
55
+ "main",
56
+ "mark",
57
+ "nav",
58
+ "ol",
59
+ "p",
60
+ "pre",
61
+ "q",
62
+ "s",
63
+ "samp",
64
+ "section",
65
+ "small",
66
+ "span",
67
+ "strong",
68
+ "sub",
69
+ "summary",
70
+ "sup",
71
+ "table",
72
+ "tbody",
73
+ "td",
74
+ "tfoot",
75
+ "th",
76
+ "thead",
77
+ "time",
78
+ "tr",
79
+ "u",
80
+ "ul",
81
+ "var",
82
+ "wbr",
83
+ ]);
84
+ const BOOLEAN_ATTRIBUTES = new Set(["hidden", "reversed"]);
85
+ const ATTRIBUTE_NAMES = {
86
+ className: "class",
87
+ colSpan: "colspan",
88
+ dateTime: "datetime",
89
+ rowSpan: "rowspan",
90
+ };
91
+ function AutomaticOptimizedBoundary({ document, fallback, ...props }) {
92
+ let content;
93
+ try {
94
+ content = render(document);
95
+ }
96
+ catch {
97
+ return fallback;
98
+ }
99
+ if (content.nodeCount < AUTOMATIC_MIN_NODES && content.bytes < AUTOMATIC_MIN_BYTES) {
100
+ return fallback;
101
+ }
102
+ return StaticFragment({ ...props, content });
103
+ }
104
+ function attributeValue(name, value) {
105
+ if (value === null || value === undefined)
106
+ return undefined;
107
+ if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
108
+ return String(value);
109
+ }
110
+ if (typeof value !== "boolean")
111
+ return null;
112
+ if (name.startsWith("aria-") || name.startsWith("data-"))
113
+ return String(value);
114
+ if (BOOLEAN_ATTRIBUTES.has(name))
115
+ return value ? "" : undefined;
116
+ return null;
117
+ }
118
+ function convertAttributes(tag, props) {
119
+ const attributes = {};
120
+ for (const [reactName, rawValue] of Object.entries(props)) {
121
+ if (reactName === "children")
122
+ continue;
123
+ if (reactName === "dangerouslySetInnerHTML" ||
124
+ reactName === "ref" ||
125
+ reactName === "style" ||
126
+ reactName === "suppressHydrationWarning" ||
127
+ /^on[A-Z]/.test(reactName)) {
128
+ return null;
129
+ }
130
+ const name = ATTRIBUTE_NAMES[reactName] || reactName;
131
+ const value = attributeValue(name, rawValue);
132
+ if (value === null)
133
+ return null;
134
+ if (value !== undefined)
135
+ attributes[name] = value;
136
+ }
137
+ return Object.keys(attributes).length > 0 ? attributes : {};
138
+ }
139
+ function automaticDocumentFromElement(element) {
140
+ const rootProps = element.props;
141
+ const children = [];
142
+ if (!appendStrataNodes(rootProps.children, children))
143
+ return null;
144
+ return { type: "document", ...(children.length > 0 ? { children } : {}) };
145
+ }
146
+ function appendStrataNodes(value, output) {
147
+ if (value === null || value === undefined || typeof value === "boolean")
148
+ return true;
149
+ if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
150
+ output.push({ type: "text", value: String(value) });
151
+ return true;
152
+ }
153
+ if (Array.isArray(value)) {
154
+ for (const child of value) {
155
+ if (!appendStrataNodes(child, output))
156
+ return false;
157
+ }
158
+ return true;
159
+ }
160
+ if (!isValidElement(value))
161
+ return false;
162
+ const element = value;
163
+ const props = element.props;
164
+ if (element.type === Fragment)
165
+ return appendStrataNodes(props.children, output);
166
+ if (element.type === OptimizedBoundary || element.type === AutomaticOptimizedBoundary) {
167
+ const boundary = props.as ?? "div";
168
+ if (typeof boundary !== "string" || !STRATA_TAGS.has(boundary))
169
+ return false;
170
+ const { as: _as, document: _document, fallback: _fallback, ...boundaryProps } = props;
171
+ const attributes = convertAttributes(boundary, boundaryProps);
172
+ if (!attributes)
173
+ return false;
174
+ const document = props.document;
175
+ if (!document || document.type !== "document")
176
+ return false;
177
+ output.push({
178
+ type: "element",
179
+ tag: boundary,
180
+ ...(Object.keys(attributes).length > 0 ? { attributes } : {}),
181
+ ...(document.children?.length ? { children: document.children } : {}),
182
+ });
183
+ return true;
184
+ }
185
+ if (typeof element.type !== "string" || !STRATA_TAGS.has(element.type)) {
186
+ return false;
187
+ }
188
+ const tag = element.type;
189
+ const attributes = convertAttributes(tag, props);
190
+ if (!attributes)
191
+ return false;
192
+ const children = [];
193
+ if (!appendStrataNodes(props.children, children))
194
+ return false;
195
+ output.push({
196
+ type: "element",
197
+ tag,
198
+ ...(Object.keys(attributes).length > 0 ? { attributes } : {}),
199
+ ...(children.length > 0 ? { children } : {}),
200
+ });
201
+ return true;
202
+ }
203
+ /**
204
+ * Internal compiler target for automatic optimized boundaries. This helper is
205
+ * deliberately fail-open: any unsupported or unsafe tree returns the original
206
+ * React element unchanged.
207
+ *
208
+ * @internal
209
+ */
210
+ export function _optimizeBoundary(element) {
211
+ if (!isValidElement(element) ||
212
+ typeof element.type !== "string" ||
213
+ !AUTOMATIC_BOUNDARIES.has(element.type)) {
214
+ return element;
215
+ }
216
+ const props = element.props;
217
+ if (props.dangerouslySetInnerHTML !== undefined || props.ref !== undefined)
218
+ return element;
219
+ const document = automaticDocumentFromElement(element);
220
+ if (!document)
221
+ return element;
222
+ const { children: _children, ...boundaryProps } = props;
223
+ return createElement(AutomaticOptimizedBoundary, {
224
+ ...boundaryProps,
225
+ ...(element.key !== null ? { key: element.key } : {}),
226
+ as: element.type,
227
+ document,
228
+ fallback: element,
229
+ });
230
+ }
231
+ /**
232
+ * Render a typed host-only document with the optimized native runtime and
233
+ * place it inside an opaque React-owned boundary.
234
+ *
235
+ * Enable `experimental.optimizedBoundary` before importing this component.
236
+ */
237
+ export function OptimizedBoundary({ document, renderOptions, ...props }) {
238
+ const content = render(document, renderOptions);
239
+ return StaticFragment({
240
+ ...props,
241
+ content,
242
+ });
243
+ }
@@ -0,0 +1,6 @@
1
+ export type FarmServerFnTransformResult = {
2
+ code: string;
3
+ exports: string[];
4
+ };
5
+ export declare function transformFarmServerFns(code: string, id: string): FarmServerFnTransformResult | null;
6
+ //# sourceMappingURL=server-fn-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-fn-transform.d.ts","sourceRoot":"","sources":["../../src/rsc/server-fn-transform.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,2BAA2B,GAAG,IAAI,CAiCpC"}
@@ -0,0 +1,152 @@
1
+ const SERVER_FUNCTION_FACTORY_IMPORT_RE = /\bimport\s+(?:type\s+)?(?:[A-Za-z_$][\w$]*\s*,\s*)?(\{[^}]*\})\s+from\s*["']@farm.js\/core(?:\/(?:server-fn|server-query))?["']\s*;?/g;
2
+ const EXPORT_SERVER_FUNCTION_FACTORY_RE = /\bexport\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*)\s*\(/g;
3
+ const MODULE_EXT_RE = /\.[cm]?[jt]sx?$/;
4
+ const DECLARATION_RE = /(^|\n)\s*["']([^"']+)["']\s*;?/g;
5
+ export function transformFarmServerFns(code, id) {
6
+ if (!isTransformableModule(id) ||
7
+ (!code.includes("createServerFn") && !code.includes("createServerQuery"))) {
8
+ return null;
9
+ }
10
+ const factoryNames = findServerFunctionFactoryImportNames(code);
11
+ if (factoryNames.size === 0)
12
+ return null;
13
+ const replacements = findServerFnExportReplacements(code, factoryNames);
14
+ if (replacements.length === 0)
15
+ return null;
16
+ if (hasModuleDirective(code, "use client")) {
17
+ throw new Error("createServerFn and createServerQuery exports must live in a server module. Move them out of the 'use client' file.");
18
+ }
19
+ let output = code;
20
+ for (const replacement of [...replacements].sort((a, b) => b.start - a.start)) {
21
+ output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
22
+ }
23
+ if (!hasModuleDirective(output, "use server")) {
24
+ output = `"use server";\n${output}`;
25
+ }
26
+ return {
27
+ code: output,
28
+ exports: replacements.map((replacement) => replacement.exportName),
29
+ };
30
+ }
31
+ function isTransformableModule(id) {
32
+ const cleanId = id.split("?", 1)[0];
33
+ return MODULE_EXT_RE.test(cleanId) && !/\.d\.[cm]?ts$/.test(cleanId);
34
+ }
35
+ function findServerFunctionFactoryImportNames(code) {
36
+ const names = new Map();
37
+ for (const match of code.matchAll(SERVER_FUNCTION_FACTORY_IMPORT_RE)) {
38
+ const importClause = match[1] ?? "";
39
+ const namedStart = importClause.indexOf("{");
40
+ const namedEnd = importClause.lastIndexOf("}");
41
+ if (namedStart === -1 || namedEnd === -1 || namedEnd <= namedStart)
42
+ continue;
43
+ const namedImports = importClause.slice(namedStart + 1, namedEnd).split(",");
44
+ for (const specifier of namedImports) {
45
+ const normalized = specifier.trim().replace(/^type\s+/, "");
46
+ const specifierMatch = normalized.match(/^(createServerFn|createServerQuery)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);
47
+ if (specifierMatch) {
48
+ const factory = specifierMatch[1];
49
+ names.set(specifierMatch[2] ?? factory, factory === "createServerFn" ? "fn" : "query");
50
+ }
51
+ }
52
+ }
53
+ return names;
54
+ }
55
+ function findServerFnExportReplacements(code, factoryNames) {
56
+ const replacements = [];
57
+ for (const match of code.matchAll(EXPORT_SERVER_FUNCTION_FACTORY_RE)) {
58
+ const exportName = match[1];
59
+ const calleeName = match[2];
60
+ const factory = calleeName ? factoryNames.get(calleeName) : undefined;
61
+ if (!exportName || !calleeName || !factory)
62
+ continue;
63
+ const openParenIndex = (match.index ?? 0) + match[0].length - 1;
64
+ const callEnd = findMatchingParen(code, openParenIndex);
65
+ if (callEnd === -1)
66
+ continue;
67
+ let declarationEnd = callEnd + 1;
68
+ while (/\s/.test(code[declarationEnd] ?? ""))
69
+ declarationEnd++;
70
+ if (code[declarationEnd] === ";")
71
+ declarationEnd++;
72
+ const calleeIndex = code.indexOf(calleeName, match.index);
73
+ const callExpression = code.slice(calleeIndex, callEnd + 1);
74
+ const privateName = `$$farm_server_${factory}_${exportName}`;
75
+ replacements.push({
76
+ start: match.index ?? 0,
77
+ end: declarationEnd,
78
+ exportName,
79
+ code: `const ${privateName} = ${callExpression};\nexport async function ${exportName}(input) {\n return ${privateName}(input);\n}`,
80
+ });
81
+ }
82
+ return replacements;
83
+ }
84
+ function hasModuleDirective(code, directive) {
85
+ for (const match of code.matchAll(DECLARATION_RE)) {
86
+ const value = match[2];
87
+ if (value === directive)
88
+ return true;
89
+ if (value !== "use strict" && value !== "use client" && value !== "use server")
90
+ return false;
91
+ }
92
+ return false;
93
+ }
94
+ function findMatchingParen(code, openParenIndex) {
95
+ let depth = 0;
96
+ let quote = null;
97
+ let lineComment = false;
98
+ let blockComment = false;
99
+ let escaped = false;
100
+ for (let index = openParenIndex; index < code.length; index++) {
101
+ const char = code[index];
102
+ const next = code[index + 1];
103
+ if (lineComment) {
104
+ if (char === "\n" || char === "\r")
105
+ lineComment = false;
106
+ continue;
107
+ }
108
+ if (blockComment) {
109
+ if (char === "*" && next === "/") {
110
+ blockComment = false;
111
+ index++;
112
+ }
113
+ continue;
114
+ }
115
+ if (quote) {
116
+ if (escaped) {
117
+ escaped = false;
118
+ continue;
119
+ }
120
+ if (char === "\\") {
121
+ escaped = true;
122
+ continue;
123
+ }
124
+ if (char === quote) {
125
+ quote = null;
126
+ }
127
+ continue;
128
+ }
129
+ if (char === "/" && next === "/") {
130
+ lineComment = true;
131
+ index++;
132
+ continue;
133
+ }
134
+ if (char === "/" && next === "*") {
135
+ blockComment = true;
136
+ index++;
137
+ continue;
138
+ }
139
+ if (char === "'" || char === '"' || char === "`") {
140
+ quote = char;
141
+ continue;
142
+ }
143
+ if (char === "(")
144
+ depth++;
145
+ if (char === ")") {
146
+ depth--;
147
+ if (depth === 0)
148
+ return index;
149
+ }
150
+ }
151
+ return -1;
152
+ }
@@ -0,0 +1,123 @@
1
+ import type { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from "@farm.js/core/server-action-security";
2
+ /**
3
+ * Configuration options for the Farm.js RSC plugin.
4
+ */
5
+ export interface FarmRscPluginOptions {
6
+ /** Security policy applied to server action requests. */
7
+ serverActions?: FarmServerActionsConfig;
8
+ /** Build identifier used to reject requests from stale browser deployments. */
9
+ deploymentId?: string;
10
+ /**
11
+ * Override the auto-generated virtual entries with custom files.
12
+ * If not provided, virtual entries are generated automatically based on
13
+ * the user's project structure.
14
+ */
15
+ entries?: {
16
+ /** Custom RSC environment entry file */
17
+ rsc?: string;
18
+ /** Custom SSR environment entry file */
19
+ ssr?: string;
20
+ /** Custom client environment entry file */
21
+ client?: string;
22
+ };
23
+ /**
24
+ * Enable encryption for server action bound arguments.
25
+ * This prevents exposing sensitive closure data in the client bundle.
26
+ * @default true
27
+ */
28
+ encryptActions?: boolean;
29
+ /**
30
+ * Subdirectory within srcDir containing route files.
31
+ * If empty, routes are discovered directly in srcDir.
32
+ * @default 'app'
33
+ */
34
+ routesDir?: string;
35
+ /**
36
+ * Custom CSS injection function.
37
+ * If not provided, uses import.meta.viteRsc.loadCss().
38
+ */
39
+ cssLoader?: string;
40
+ /**
41
+ * Enable verbose logging for debugging.
42
+ * @default false
43
+ */
44
+ debug?: boolean;
45
+ }
46
+ /**
47
+ * Internal context passed to entry generators.
48
+ * Contains resolved configuration values needed to generate entry files.
49
+ */
50
+ export interface EntryContext {
51
+ /** User's source directory, e.g. 'src' */
52
+ srcDir: string;
53
+ /** Build output directory, e.g. 'dist' */
54
+ outDir: string;
55
+ /** Base URL path, e.g. '/' */
56
+ basePath: string;
57
+ /** Route files subdirectory within srcDir */
58
+ routesDir?: string;
59
+ /** Root-relative Vite URL for an existing global stylesheet. */
60
+ globalCssPath?: string;
61
+ /** Ordered route roots. Modules from later roots override matching earlier modules. */
62
+ routeRoots?: Array<{
63
+ name: string;
64
+ base: string;
65
+ glob: string;
66
+ }>;
67
+ /** Whether server actions are enabled */
68
+ actionsEnabled: boolean;
69
+ /** Normalized server action request security policy. */
70
+ serverActions: ResolvedFarmServerActionsConfig;
71
+ /** Resolved build identifier embedded into the server and browser entries. */
72
+ deploymentId: string;
73
+ /** Whether debug mode is enabled */
74
+ debug: boolean;
75
+ }
76
+ /**
77
+ * Matched route information from the file-based router.
78
+ */
79
+ export interface MatchedRoute {
80
+ /** The page component's default export */
81
+ Page: React.ComponentType<any>;
82
+ /** The file pattern that matched, e.g. '/src/about/page.tsx' */
83
+ pattern: string;
84
+ /** Dynamic route parameters, e.g. { slug: 'my-post' } */
85
+ params: Record<string, string>;
86
+ }
87
+ /**
88
+ * RSC payload structure sent from server to client.
89
+ */
90
+ export interface RscPayload {
91
+ /** The root React element tree (full document for SSR) */
92
+ root: React.ReactElement;
93
+ /** Content for div#root only (for client hydration to avoid double/repeated content) */
94
+ rootContent?: React.ReactElement;
95
+ /** Serializable document metadata used during client-side navigation. */
96
+ metadata?: {
97
+ title?: string;
98
+ description?: string;
99
+ };
100
+ /** Server action return value (if action was executed) */
101
+ returnValue?: {
102
+ ok: boolean;
103
+ data: unknown;
104
+ };
105
+ /** Form state for progressive enhancement */
106
+ formState?: unknown;
107
+ }
108
+ /**
109
+ * Vite RSC module augmentation for import.meta.
110
+ */
111
+ declare global {
112
+ interface ImportMeta {
113
+ readonly viteRsc: {
114
+ /** Load CSS for server components */
115
+ loadCss(): React.ReactElement[];
116
+ /** Load a module from another environment */
117
+ loadModule<T = unknown>(env: string, entry: string): Promise<T>;
118
+ /** Load bootstrap script content for hydration */
119
+ loadBootstrapScriptContent(entry: string): Promise<string>;
120
+ };
121
+ }
122
+ }
123
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rsc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,aAAa,CAAC,EAAE,uBAAuB,CAAC;IAExC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,OAAO,CAAC,EAAE;QACR,wCAAwC;QACxC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,wCAAwC;QACxC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,2CAA2C;QAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IAEjB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,uFAAuF;IACvF,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IAEH,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;IAExB,wDAAwD;IACxD,aAAa,EAAE,+BAA+B,CAAC;IAE/C,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IAErB,oCAAoC;IACpC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAE/B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAEhB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IAEzB,wFAAwF;IACxF,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAEjC,yEAAyE;IACzE,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IAEF,0DAA0D;IAC1D,WAAW,CAAC,EAAE;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IAEF,6CAA6C;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,QAAQ,CAAC,OAAO,EAAE;YAChB,qCAAqC;YACrC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YAEhC,6CAA6C;YAC7C,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAEhE,kDAAkD;YAClD,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;SAC5D,CAAC;KACH;CACF"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Vite plugin to run Nitro after RSC build (single "vite build", no post script).
3
+ * Implements the Nitro RSC deployment pipeline:
4
+ * - Step 1: Force per-environment output dirs to .nitro/vite/dist/${name} so Nitro can locate artifacts.
5
+ * - Step 2: Capture the server (RSC) Rollup bundle in writeBundle.
6
+ * - Step 3: Find the SSR entry chunk from the bundle.
7
+ * - Step 4: Compute renderer path and pass to Nitro with client publicDir.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import nitro from '@farm.js/plugin/rsc/vite-plugin-nitro'
12
+ * export default defineConfig({
13
+ * plugins: [rsc(), react(), nitro({ server: { environmentName: 'rsc' }, config: { preset: 'vercel' } })],
14
+ * })
15
+ * ```
16
+ */
17
+ import type { Plugin } from "vite";
18
+ export interface NitroPluginOptions {
19
+ server?: {
20
+ environmentName?: string;
21
+ /** Entry name in rollupOptions.input (default: 'index'). */
22
+ entryName?: string;
23
+ };
24
+ config?: {
25
+ preset?: string;
26
+ };
27
+ /** Base output dir when not using .nitro/vite/dist (fallback). */
28
+ outDir?: string;
29
+ }
30
+ export default function nitro(options?: NitroPluginOptions): Plugin;
31
+ /** Called by RSC plugin buildApp (post) to run Nitro with the captured bundle. */
32
+ export declare function runNitroFromBuildApp(): Promise<void>;
33
+ //# sourceMappingURL=vite-plugin-nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-nitro.d.ts","sourceRoot":"","sources":["../../src/rsc/vite-plugin-nitro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAenC,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE;QACP,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,4DAA4D;QAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAWD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAoHtE;AAED,kFAAkF;AAClF,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CA+C1D"}