@farm.js/plugin 0.1.14 → 0.1.16

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.14";
42
+ export declare const version = "0.1.16";
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.14";
42
+ export const version = "0.1.16";
43
43
  // Note: Import plugins from their respective subpaths:
44
44
  // - @farm.js/plugin/rsc
45
45
  // - @farm.js/plugin/middleware
@@ -227,7 +227,7 @@ function findServerFnExportReplacements(code, factoryNames) {
227
227
  start: match.index ?? 0,
228
228
  end: declarationEnd,
229
229
  exportName,
230
- code: `const ${privateName} = ${callExpression};\nexport async function ${exportName}(input) {\n return ${privateName}(input);\n}`,
230
+ code: `const ${privateName} = ${callExpression};\nexport async function ${exportName}(input) {\n return ${privateName}(input);\n}\n${copyServerFunctionDescriptor(exportName, privateName)}`,
231
231
  });
232
232
  }
233
233
  // `export default createServerFn(...)` needs the same treatment. Without it the
@@ -253,11 +253,20 @@ function findServerFnExportReplacements(code, factoryNames) {
253
253
  start: match.index ?? 0,
254
254
  end: declarationEnd,
255
255
  exportName: "default",
256
- code: `const ${privateName} = ${callExpression};\nexport default async function (input) {\n return ${privateName}(input);\n}`,
256
+ code: `const ${privateName} = ${callExpression};\nexport default async function ${privateName}_export(input) {\n return ${privateName}(input);\n}\n${copyServerFunctionDescriptor(`${privateName}_export`, privateName)}`,
257
257
  });
258
258
  }
259
259
  return replacements;
260
260
  }
261
+ /**
262
+ * The exported wrapper replaces the factory's function, so it would lose the internal descriptor
263
+ * that MCP and other non-browser callers read. Copy only that descriptor: the other server
264
+ * function markers stay on the private binding, as before.
265
+ */
266
+ function copyServerFunctionDescriptor(target, source) {
267
+ const key = 'Symbol.for("farm.server-function.descriptor")';
268
+ return `Object.defineProperty(${target}, ${key}, { value: ${source}[${key}] });`;
269
+ }
261
270
  function hasModuleDirective(code, directive) {
262
271
  for (const match of code.matchAll(DECLARATION_RE)) {
263
272
  const value = match[2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/plugin",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
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.14"
65
+ "@farm.js/core": "0.1.16"
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.14"
86
+ "@farm.js/core": "0.1.16"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@vitejs/plugin-rsc": {