@farm.js/core 0.1.0-beta.51 → 0.1.0-beta.53
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/{chunk-HSHA3H3U.mjs → chunk-3E2WRUR2.mjs} +15 -1
- package/dist/chunk-3E2WRUR2.mjs.map +1 -0
- package/dist/{chunk-QCSOE6HT.mjs → chunk-FCY7TXMA.mjs} +52 -9
- package/dist/chunk-FCY7TXMA.mjs.map +1 -0
- package/dist/{chunk-235ZOXDY.mjs → chunk-HAMMDSJM.mjs} +2 -2
- package/dist/{chunk-FRN7PNL4.mjs → chunk-LN2BAU5H.mjs} +2 -2
- package/dist/{chunk-ZAW3D2TI.mjs → chunk-M2DI67UZ.mjs} +2 -2
- package/dist/{chunk-7XJV5RZO.mjs → chunk-RPEYD7TD.mjs} +2 -2
- package/dist/{chunk-7XJV5RZO.mjs.map → chunk-RPEYD7TD.mjs.map} +1 -1
- package/dist/client/lifecycle.mjs +2 -2
- package/dist/client-plugins.cjs +1 -1
- package/dist/client-plugins.cjs.map +1 -1
- package/dist/client-plugins.mjs +2 -2
- package/dist/client.cjs +15 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +4 -4
- package/dist/index.cjs +72 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/internal/build-runtime.cjs +58 -8
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +3 -3
- package/dist/internal/client-runtime.cjs +1 -1
- package/dist/internal/client-runtime.cjs.map +1 -1
- package/dist/internal/client-runtime.mjs +2 -2
- package/dist/plugin.cjs +51 -8
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/renderer-client.cjs +14 -0
- package/dist/renderer-client.cjs.map +1 -1
- package/dist/renderer-client.mjs +1 -1
- package/dist/server-query-client.cjs +14 -0
- package/dist/server-query-client.cjs.map +1 -1
- package/dist/server-query-client.mjs +2 -2
- package/dist/server.cjs +51 -8
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +51 -8
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-HSHA3H3U.mjs.map +0 -1
- package/dist/chunk-QCSOE6HT.mjs.map +0 -1
- /package/dist/{chunk-235ZOXDY.mjs.map → chunk-HAMMDSJM.mjs.map} +0 -0
- /package/dist/{chunk-FRN7PNL4.mjs.map → chunk-LN2BAU5H.mjs.map} +0 -0
- /package/dist/{chunk-ZAW3D2TI.mjs.map → chunk-M2DI67UZ.mjs.map} +0 -0
package/dist/client.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-SALMKQXH.mjs";
|
|
10
10
|
import {
|
|
11
11
|
useServerQuery
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-M2DI67UZ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
useBlocker,
|
|
15
15
|
useNavigation,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
import {
|
|
39
39
|
fetchServerQuery,
|
|
40
40
|
prefetchServerQuery
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-3E2WRUR2.mjs";
|
|
42
42
|
import {
|
|
43
43
|
SPARouter,
|
|
44
44
|
getRouter,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
createClientPluginManager,
|
|
63
63
|
installChunkErrorRecovery,
|
|
64
64
|
isChunkLoadError
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-LN2BAU5H.mjs";
|
|
66
66
|
import "./chunk-GQVQESLY.mjs";
|
|
67
67
|
import {
|
|
68
68
|
api,
|
|
@@ -80,7 +80,7 @@ import "./chunk-RBRLLZL5.mjs";
|
|
|
80
80
|
import "./chunk-WZ5QFROO.mjs";
|
|
81
81
|
import "./chunk-7ZMKVETU.mjs";
|
|
82
82
|
import "./chunk-FXG2PS27.mjs";
|
|
83
|
-
import "./chunk-
|
|
83
|
+
import "./chunk-RPEYD7TD.mjs";
|
|
84
84
|
import "./chunk-CGILA3WO.mjs";
|
|
85
85
|
export {
|
|
86
86
|
APIClientError,
|
package/dist/index.cjs
CHANGED
|
@@ -15255,7 +15255,7 @@ var init_server3 = __esm({
|
|
|
15255
15255
|
var version;
|
|
15256
15256
|
var init_package = __esm({
|
|
15257
15257
|
"package.json"() {
|
|
15258
|
-
version = "0.1.0-beta.
|
|
15258
|
+
version = "0.1.0-beta.53";
|
|
15259
15259
|
}
|
|
15260
15260
|
});
|
|
15261
15261
|
|
|
@@ -21792,6 +21792,13 @@ var init_after = __esm({
|
|
|
21792
21792
|
});
|
|
21793
21793
|
|
|
21794
21794
|
// src/dev-static.ts
|
|
21795
|
+
function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs) {
|
|
21796
|
+
if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
|
|
21797
|
+
const matchesAppRoute = Boolean(
|
|
21798
|
+
routeManager?.matchRoute(pathname)?.route || routeManager?.matchMetadataRoute(pathname) || routeManager?.matchMetadataImage(pathname)
|
|
21799
|
+
);
|
|
21800
|
+
return !matchesAppRoute || devServableFileExists(pathname, baseDirs);
|
|
21801
|
+
}
|
|
21795
21802
|
function devServableFileExists(pathname, baseDirs) {
|
|
21796
21803
|
let decodedPathname;
|
|
21797
21804
|
try {
|
|
@@ -21821,10 +21828,45 @@ var init_dev_static = __esm({
|
|
|
21821
21828
|
"use strict";
|
|
21822
21829
|
fs9 = __toESM(require("fs"));
|
|
21823
21830
|
path20 = __toESM(require("path"));
|
|
21831
|
+
__name(shouldBypassFarmRouterForDottedPath, "shouldBypassFarmRouterForDottedPath");
|
|
21824
21832
|
__name(devServableFileExists, "devServableFileExists");
|
|
21825
21833
|
}
|
|
21826
21834
|
});
|
|
21827
21835
|
|
|
21836
|
+
// src/server-query-boundary.ts
|
|
21837
|
+
function findClientServerFnViolation(code, id) {
|
|
21838
|
+
if (id.startsWith("\0") || id.startsWith("virtual:") || id.includes("node_modules")) return null;
|
|
21839
|
+
if (!code.includes("@farm.js/core")) return null;
|
|
21840
|
+
for (const match of code.matchAll(FARM_CORE_IMPORT_RE)) {
|
|
21841
|
+
const specifiers = match[1];
|
|
21842
|
+
for (const factory of SERVER_FN_FACTORIES) {
|
|
21843
|
+
if (!new RegExp(`(?:^|[\\s{,])${factory}(?:[\\s},]|$)`).test(specifiers)) continue;
|
|
21844
|
+
if (new RegExp(`(?<![\\w$.])${factory}\\s*(?:<[^>]*>)?\\s*\\(`).test(code)) {
|
|
21845
|
+
return { factory };
|
|
21846
|
+
}
|
|
21847
|
+
}
|
|
21848
|
+
}
|
|
21849
|
+
return null;
|
|
21850
|
+
}
|
|
21851
|
+
function formatServerFnBoundaryError(violation, id) {
|
|
21852
|
+
return [
|
|
21853
|
+
`${violation.factory} handlers run only on the server, but ${id} is being bundled into the client.`,
|
|
21854
|
+
`Importing a ${violation.factory} module from client code executes the server handler (and its Node-only imports) in the browser.`,
|
|
21855
|
+
`Either enable the server-function transform (add @farm.js/plugin/rsc and set experimental.serverActions: true in farm.config.ts) so client imports become server references,`,
|
|
21856
|
+
`or keep the query on the server: call it from server components, or expose an API route and use createAPIClient from the client.`
|
|
21857
|
+
].join("\n");
|
|
21858
|
+
}
|
|
21859
|
+
var SERVER_FN_FACTORIES, FARM_CORE_IMPORT_RE;
|
|
21860
|
+
var init_server_query_boundary = __esm({
|
|
21861
|
+
"src/server-query-boundary.ts"() {
|
|
21862
|
+
"use strict";
|
|
21863
|
+
SERVER_FN_FACTORIES = ["createServerQuery", "createServerFn"];
|
|
21864
|
+
FARM_CORE_IMPORT_RE = /import\s*(?!type\b)(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*(["'])@farm\.js\/core(?:\/[\w./-]+)?\2/g;
|
|
21865
|
+
__name(findClientServerFnViolation, "findClientServerFnViolation");
|
|
21866
|
+
__name(formatServerFnBoundaryError, "formatServerFnBoundaryError");
|
|
21867
|
+
}
|
|
21868
|
+
});
|
|
21869
|
+
|
|
21828
21870
|
// src/image-vite.ts
|
|
21829
21871
|
function farmImageImportsPlugin() {
|
|
21830
21872
|
return {
|
|
@@ -29617,13 +29659,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
29617
29659
|
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
|
|
29618
29660
|
return next();
|
|
29619
29661
|
}
|
|
29620
|
-
if (requestPathname
|
|
29621
|
-
|
|
29622
|
-
|
|
29623
|
-
|
|
29624
|
-
|
|
29625
|
-
return next();
|
|
29626
|
-
}
|
|
29662
|
+
if (shouldBypassFarmRouterForDottedPath(requestPathname, farmApp?.getRouteManager(), [
|
|
29663
|
+
server.config.publicDir,
|
|
29664
|
+
server.config.root
|
|
29665
|
+
])) {
|
|
29666
|
+
return next();
|
|
29627
29667
|
}
|
|
29628
29668
|
if (req.url?.startsWith("/__farm/page-data")) {
|
|
29629
29669
|
const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
|
|
@@ -30277,6 +30317,15 @@ export const manifest = getManifest();
|
|
|
30277
30317
|
}
|
|
30278
30318
|
},
|
|
30279
30319
|
async transform(code, id, transformOptions) {
|
|
30320
|
+
if (!transformOptions?.ssr) {
|
|
30321
|
+
const currentConfig = farmApp?.getConfig() ?? options;
|
|
30322
|
+
if (currentConfig.experimental?.serverActions !== true) {
|
|
30323
|
+
const violation = findClientServerFnViolation(code, id);
|
|
30324
|
+
if (violation) {
|
|
30325
|
+
this.error(formatServerFnBoundaryError(violation, id));
|
|
30326
|
+
}
|
|
30327
|
+
}
|
|
30328
|
+
}
|
|
30280
30329
|
if (typeof imageImports.transform === "function") {
|
|
30281
30330
|
const imageModule = await imageImports.transform.call(this, code, id, transformOptions);
|
|
30282
30331
|
if (imageModule) return imageModule;
|
|
@@ -32500,6 +32549,7 @@ var init_vite2 = __esm({
|
|
|
32500
32549
|
init_deferred();
|
|
32501
32550
|
init_after();
|
|
32502
32551
|
init_dev_static();
|
|
32552
|
+
init_server_query_boundary();
|
|
32503
32553
|
init_deployment();
|
|
32504
32554
|
init_image_config();
|
|
32505
32555
|
init_image_vite();
|
|
@@ -38883,6 +38933,19 @@ var serverQueryClientState = serverQueryClientGlobal[FARM_SERVER_QUERY_CLIENT_ST
|
|
|
38883
38933
|
nextFunctionId: 0,
|
|
38884
38934
|
active: []
|
|
38885
38935
|
});
|
|
38936
|
+
var RAW_SERVER_QUERY_SYMBOL = /* @__PURE__ */ Symbol.for("farm.server-query");
|
|
38937
|
+
function assertNotRawServerQueryInBrowser(query) {
|
|
38938
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
38939
|
+
if (!query?.[RAW_SERVER_QUERY_SYMBOL]) return;
|
|
38940
|
+
throw new Error(
|
|
38941
|
+
[
|
|
38942
|
+
"useServerQuery received a raw server query implementation in the browser.",
|
|
38943
|
+
"Server query handlers run only on the server. Enable the server-function transform (add @farm.js/plugin/rsc and set experimental.serverActions: true in farm.config.ts) so client imports become server references,",
|
|
38944
|
+
"or call the query from server code / an API route (createAPIClient) instead."
|
|
38945
|
+
].join("\n")
|
|
38946
|
+
);
|
|
38947
|
+
}
|
|
38948
|
+
__name(assertNotRawServerQueryInBrowser, "assertNotRawServerQueryInBrowser");
|
|
38886
38949
|
function beginFarmServerQueryAction(actionId, args) {
|
|
38887
38950
|
const active = serverQueryClientState.active.at(-1);
|
|
38888
38951
|
return {
|
|
@@ -38939,6 +39002,7 @@ function prefetchServerQuery(query, input, options = {}) {
|
|
|
38939
39002
|
}
|
|
38940
39003
|
__name(prefetchServerQuery, "prefetchServerQuery");
|
|
38941
39004
|
async function executeServerQuery(query, input, provisionalKey, options) {
|
|
39005
|
+
assertNotRawServerQueryInBrowser(query);
|
|
38942
39006
|
const cache = getFarmClientDataCache();
|
|
38943
39007
|
const inflight = cache.getInflight(provisionalKey);
|
|
38944
39008
|
if (inflight) return inflight;
|