@farm.js/core 0.1.0-beta.51 → 0.1.0-beta.52
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-235ZOXDY.mjs → chunk-BTFOMBWK.mjs} +2 -2
- package/dist/{chunk-QCSOE6HT.mjs → chunk-JK6YAQ3E.mjs} +52 -9
- package/dist/chunk-JK6YAQ3E.mjs.map +1 -0
- package/dist/{chunk-ZAW3D2TI.mjs → chunk-M2DI67UZ.mjs} +2 -2
- package/dist/{chunk-7XJV5RZO.mjs → chunk-TW74WBSB.mjs} +2 -2
- package/dist/{chunk-7XJV5RZO.mjs.map → chunk-TW74WBSB.mjs.map} +1 -1
- package/dist/{chunk-FRN7PNL4.mjs → chunk-XMUPYG2D.mjs} +2 -2
- 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 +1 -1
- package/dist/chunk-HSHA3H3U.mjs.map +0 -1
- package/dist/chunk-QCSOE6HT.mjs.map +0 -1
- /package/dist/{chunk-235ZOXDY.mjs.map → chunk-BTFOMBWK.mjs.map} +0 -0
- /package/dist/{chunk-ZAW3D2TI.mjs.map → chunk-M2DI67UZ.mjs.map} +0 -0
- /package/dist/{chunk-FRN7PNL4.mjs.map → chunk-XMUPYG2D.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-5ZGPRGWV.mjs";
|
|
10
10
|
import {
|
|
11
11
|
build
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BTFOMBWK.mjs";
|
|
13
13
|
import "./chunk-SL6HTIOK.mjs";
|
|
14
14
|
import "./chunk-4S3ORGFA.mjs";
|
|
15
15
|
import {
|
|
@@ -144,7 +144,7 @@ import {
|
|
|
144
144
|
} from "./chunk-SALMKQXH.mjs";
|
|
145
145
|
import {
|
|
146
146
|
useServerQuery
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-M2DI67UZ.mjs";
|
|
148
148
|
import {
|
|
149
149
|
useBlocker,
|
|
150
150
|
useNavigation,
|
|
@@ -179,7 +179,7 @@ import {
|
|
|
179
179
|
completeFarmServerQueryAction,
|
|
180
180
|
fetchServerQuery,
|
|
181
181
|
prefetchServerQuery
|
|
182
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-3E2WRUR2.mjs";
|
|
183
183
|
import {
|
|
184
184
|
SPARouter,
|
|
185
185
|
getRouter,
|
|
@@ -208,7 +208,7 @@ import {
|
|
|
208
208
|
createClientPluginManager,
|
|
209
209
|
installChunkErrorRecovery,
|
|
210
210
|
isChunkLoadError
|
|
211
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-XMUPYG2D.mjs";
|
|
212
212
|
import {
|
|
213
213
|
analyzeStaticRouteCandidate,
|
|
214
214
|
collectSSGPages,
|
|
@@ -227,7 +227,7 @@ import {
|
|
|
227
227
|
parseRouteRenderingDirective,
|
|
228
228
|
resolveRouteRenderingConfig,
|
|
229
229
|
resolveRouteRenderingConfigFromFile
|
|
230
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-JK6YAQ3E.mjs";
|
|
231
231
|
import {
|
|
232
232
|
APITypeGenerator
|
|
233
233
|
} from "./chunk-XJTDE4L4.mjs";
|
|
@@ -568,7 +568,7 @@ import {
|
|
|
568
568
|
runWithFarmSpan
|
|
569
569
|
} from "./chunk-7ZMKVETU.mjs";
|
|
570
570
|
import "./chunk-FXG2PS27.mjs";
|
|
571
|
-
import "./chunk-
|
|
571
|
+
import "./chunk-TW74WBSB.mjs";
|
|
572
572
|
import {
|
|
573
573
|
createCompressionPlugin,
|
|
574
574
|
createEnvPlugin,
|
|
@@ -14918,7 +14918,7 @@ var init_server3 = __esm({
|
|
|
14918
14918
|
var version;
|
|
14919
14919
|
var init_package = __esm({
|
|
14920
14920
|
"package.json"() {
|
|
14921
|
-
version = "0.1.0-beta.
|
|
14921
|
+
version = "0.1.0-beta.52";
|
|
14922
14922
|
}
|
|
14923
14923
|
});
|
|
14924
14924
|
|
|
@@ -20856,6 +20856,13 @@ var init_after = __esm({
|
|
|
20856
20856
|
});
|
|
20857
20857
|
|
|
20858
20858
|
// src/dev-static.ts
|
|
20859
|
+
function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs) {
|
|
20860
|
+
if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
|
|
20861
|
+
const matchesAppRoute = Boolean(
|
|
20862
|
+
routeManager?.matchRoute(pathname)?.route || routeManager?.matchMetadataRoute(pathname) || routeManager?.matchMetadataImage(pathname)
|
|
20863
|
+
);
|
|
20864
|
+
return !matchesAppRoute || devServableFileExists(pathname, baseDirs);
|
|
20865
|
+
}
|
|
20859
20866
|
function devServableFileExists(pathname, baseDirs) {
|
|
20860
20867
|
let decodedPathname;
|
|
20861
20868
|
try {
|
|
@@ -20885,10 +20892,45 @@ var init_dev_static = __esm({
|
|
|
20885
20892
|
"use strict";
|
|
20886
20893
|
fs10 = __toESM(require("fs"));
|
|
20887
20894
|
path29 = __toESM(require("path"));
|
|
20895
|
+
__name(shouldBypassFarmRouterForDottedPath, "shouldBypassFarmRouterForDottedPath");
|
|
20888
20896
|
__name(devServableFileExists, "devServableFileExists");
|
|
20889
20897
|
}
|
|
20890
20898
|
});
|
|
20891
20899
|
|
|
20900
|
+
// src/server-query-boundary.ts
|
|
20901
|
+
function findClientServerFnViolation(code, id) {
|
|
20902
|
+
if (id.startsWith("\0") || id.startsWith("virtual:") || id.includes("node_modules")) return null;
|
|
20903
|
+
if (!code.includes("@farm.js/core")) return null;
|
|
20904
|
+
for (const match of code.matchAll(FARM_CORE_IMPORT_RE)) {
|
|
20905
|
+
const specifiers = match[1];
|
|
20906
|
+
for (const factory of SERVER_FN_FACTORIES) {
|
|
20907
|
+
if (!new RegExp(`(?:^|[\\s{,])${factory}(?:[\\s},]|$)`).test(specifiers)) continue;
|
|
20908
|
+
if (new RegExp(`(?<![\\w$.])${factory}\\s*(?:<[^>]*>)?\\s*\\(`).test(code)) {
|
|
20909
|
+
return { factory };
|
|
20910
|
+
}
|
|
20911
|
+
}
|
|
20912
|
+
}
|
|
20913
|
+
return null;
|
|
20914
|
+
}
|
|
20915
|
+
function formatServerFnBoundaryError(violation, id) {
|
|
20916
|
+
return [
|
|
20917
|
+
`${violation.factory} handlers run only on the server, but ${id} is being bundled into the client.`,
|
|
20918
|
+
`Importing a ${violation.factory} module from client code executes the server handler (and its Node-only imports) in the browser.`,
|
|
20919
|
+
`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,`,
|
|
20920
|
+
`or keep the query on the server: call it from server components, or expose an API route and use createAPIClient from the client.`
|
|
20921
|
+
].join("\n");
|
|
20922
|
+
}
|
|
20923
|
+
var SERVER_FN_FACTORIES, FARM_CORE_IMPORT_RE;
|
|
20924
|
+
var init_server_query_boundary = __esm({
|
|
20925
|
+
"src/server-query-boundary.ts"() {
|
|
20926
|
+
"use strict";
|
|
20927
|
+
SERVER_FN_FACTORIES = ["createServerQuery", "createServerFn"];
|
|
20928
|
+
FARM_CORE_IMPORT_RE = /import\s*(?!type\b)(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*(["'])@farm\.js\/core(?:\/[\w./-]+)?\2/g;
|
|
20929
|
+
__name(findClientServerFnViolation, "findClientServerFnViolation");
|
|
20930
|
+
__name(formatServerFnBoundaryError, "formatServerFnBoundaryError");
|
|
20931
|
+
}
|
|
20932
|
+
});
|
|
20933
|
+
|
|
20892
20934
|
// src/image-vite.ts
|
|
20893
20935
|
function farmImageImportsPlugin() {
|
|
20894
20936
|
return {
|
|
@@ -27648,13 +27690,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
27648
27690
|
if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
|
|
27649
27691
|
return next();
|
|
27650
27692
|
}
|
|
27651
|
-
if (requestPathname
|
|
27652
|
-
|
|
27653
|
-
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
return next();
|
|
27657
|
-
}
|
|
27693
|
+
if (shouldBypassFarmRouterForDottedPath(requestPathname, farmApp?.getRouteManager(), [
|
|
27694
|
+
server.config.publicDir,
|
|
27695
|
+
server.config.root
|
|
27696
|
+
])) {
|
|
27697
|
+
return next();
|
|
27658
27698
|
}
|
|
27659
27699
|
if (req.url?.startsWith("/__farm/page-data")) {
|
|
27660
27700
|
const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
|
|
@@ -28308,6 +28348,15 @@ export const manifest = getManifest();
|
|
|
28308
28348
|
}
|
|
28309
28349
|
},
|
|
28310
28350
|
async transform(code, id, transformOptions) {
|
|
28351
|
+
if (!transformOptions?.ssr) {
|
|
28352
|
+
const currentConfig = farmApp?.getConfig() ?? options;
|
|
28353
|
+
if (currentConfig.experimental?.serverActions !== true) {
|
|
28354
|
+
const violation = findClientServerFnViolation(code, id);
|
|
28355
|
+
if (violation) {
|
|
28356
|
+
this.error(formatServerFnBoundaryError(violation, id));
|
|
28357
|
+
}
|
|
28358
|
+
}
|
|
28359
|
+
}
|
|
28311
28360
|
if (typeof imageImports.transform === "function") {
|
|
28312
28361
|
const imageModule = await imageImports.transform.call(this, code, id, transformOptions);
|
|
28313
28362
|
if (imageModule) return imageModule;
|
|
@@ -30531,6 +30580,7 @@ var init_vite2 = __esm({
|
|
|
30531
30580
|
init_deferred();
|
|
30532
30581
|
init_after();
|
|
30533
30582
|
init_dev_static();
|
|
30583
|
+
init_server_query_boundary();
|
|
30534
30584
|
init_deployment();
|
|
30535
30585
|
init_image_config();
|
|
30536
30586
|
init_image_vite();
|