@farm.js/core 0.1.0-beta.46 → 0.1.0-beta.47
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-V7VDW7IY.mjs → chunk-IHYFDXKQ.mjs} +2 -2
- package/dist/{chunk-LGCIIMFR.mjs → chunk-KTV3UWGE.mjs} +2 -2
- package/dist/{chunk-LGCIIMFR.mjs.map → chunk-KTV3UWGE.mjs.map} +1 -1
- package/dist/{chunk-TQJMU5BP.mjs → chunk-MWYVMV3T.mjs} +113 -4
- package/dist/chunk-MWYVMV3T.mjs.map +1 -0
- package/dist/{chunk-W2O6SKJU.mjs → chunk-SHZF3DEB.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 +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +2 -2
- package/dist/index.cjs +117 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/internal/build-runtime.cjs +117 -4
- 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 +112 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +2 -2
- package/dist/server.cjs +112 -3
- 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 +112 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-TQJMU5BP.mjs.map +0 -1
- /package/dist/{chunk-V7VDW7IY.mjs.map → chunk-IHYFDXKQ.mjs.map} +0 -0
- /package/dist/{chunk-W2O6SKJU.mjs.map → chunk-SHZF3DEB.mjs.map} +0 -0
package/dist/client.mjs
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
createClientPluginManager,
|
|
63
63
|
installChunkErrorRecovery,
|
|
64
64
|
isChunkLoadError
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-SHZF3DEB.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-KTV3UWGE.mjs";
|
|
84
84
|
import "./chunk-CGILA3WO.mjs";
|
|
85
85
|
export {
|
|
86
86
|
APIClientError,
|
package/dist/index.cjs
CHANGED
|
@@ -11179,6 +11179,60 @@ var init_route_manager = __esm({
|
|
|
11179
11179
|
}
|
|
11180
11180
|
});
|
|
11181
11181
|
|
|
11182
|
+
// src/server/full-document.ts
|
|
11183
|
+
function stripContentsWrappers(markup) {
|
|
11184
|
+
let out = markup.replace(/^\s+/, "");
|
|
11185
|
+
const opener = /^<div\b[^>]*style="display\s*:\s*contents"[^>]*>/i;
|
|
11186
|
+
let match;
|
|
11187
|
+
while (match = opener.exec(out)) {
|
|
11188
|
+
out = out.slice(match[0].length).replace(/^\s+/, "");
|
|
11189
|
+
}
|
|
11190
|
+
return out;
|
|
11191
|
+
}
|
|
11192
|
+
function extractFarmFullDocument(markup) {
|
|
11193
|
+
const inner = stripContentsWrappers(markup);
|
|
11194
|
+
if (!/^<!doctype/i.test(inner) && !/^<html[\s>]/i.test(inner)) return null;
|
|
11195
|
+
const start = markup.search(/<!doctype|<html[\s>]/i);
|
|
11196
|
+
const closeIndex = markup.toLowerCase().lastIndexOf("</html>");
|
|
11197
|
+
if (start < 0 || closeIndex < 0) return null;
|
|
11198
|
+
return markup.slice(start, closeIndex + "</html>".length);
|
|
11199
|
+
}
|
|
11200
|
+
function opensFarmFullDocument(markup) {
|
|
11201
|
+
const inner = stripContentsWrappers(markup);
|
|
11202
|
+
return /^<!doctype/i.test(inner) || /^<html[\s>]/i.test(inner);
|
|
11203
|
+
}
|
|
11204
|
+
function composeFarmFullDocument(documentHtml, assets) {
|
|
11205
|
+
let html = documentHtml;
|
|
11206
|
+
if (assets.htmlAttributes) {
|
|
11207
|
+
html = html.replace(
|
|
11208
|
+
/<html\b([^>]*)>/i,
|
|
11209
|
+
(_match, attrs) => `<html${attrs}${assets.htmlAttributes}>`
|
|
11210
|
+
);
|
|
11211
|
+
}
|
|
11212
|
+
if (!/\sid=["']root["']/i.test(html)) {
|
|
11213
|
+
html = html.replace(/<body\b([^>]*)>/i, '<body$1><div id="root">').replace(/<\/body>/i, "</div></body>");
|
|
11214
|
+
}
|
|
11215
|
+
if (assets.headAssets) {
|
|
11216
|
+
html = html.replace(/<\/head>/i, () => ` ${assets.headAssets}
|
|
11217
|
+
</head>`);
|
|
11218
|
+
}
|
|
11219
|
+
if (assets.bodyFooter) {
|
|
11220
|
+
html = html.replace(/<\/body>/i, () => ` ${assets.bodyFooter}
|
|
11221
|
+
</body>`);
|
|
11222
|
+
}
|
|
11223
|
+
return /^\s*<!doctype/i.test(html) ? html : `<!DOCTYPE html>
|
|
11224
|
+
${html}`;
|
|
11225
|
+
}
|
|
11226
|
+
var init_full_document = __esm({
|
|
11227
|
+
"src/server/full-document.ts"() {
|
|
11228
|
+
"use strict";
|
|
11229
|
+
__name(stripContentsWrappers, "stripContentsWrappers");
|
|
11230
|
+
__name(extractFarmFullDocument, "extractFarmFullDocument");
|
|
11231
|
+
__name(opensFarmFullDocument, "opensFarmFullDocument");
|
|
11232
|
+
__name(composeFarmFullDocument, "composeFarmFullDocument");
|
|
11233
|
+
}
|
|
11234
|
+
});
|
|
11235
|
+
|
|
11182
11236
|
// src/middleware/server.ts
|
|
11183
11237
|
function getGlobalMiddlewareStore(key) {
|
|
11184
11238
|
const state = globalThis;
|
|
@@ -15195,7 +15249,7 @@ var init_server3 = __esm({
|
|
|
15195
15249
|
var version;
|
|
15196
15250
|
var init_package = __esm({
|
|
15197
15251
|
"package.json"() {
|
|
15198
|
-
version = "0.1.0-beta.
|
|
15252
|
+
version = "0.1.0-beta.47";
|
|
15199
15253
|
}
|
|
15200
15254
|
});
|
|
15201
15255
|
|
|
@@ -15367,6 +15421,13 @@ function warnSuppressedAsyncHydrationOnce(modulePath) {
|
|
|
15367
15421
|
`${modulePath} is an async server component that imports client components. React cannot hydrate async components in the browser, so this route stays server-rendered and its client imports are not interactive. Move the interactive UI into a "use client" child rendered by a synchronous page, or enable experimental server components support.`
|
|
15368
15422
|
);
|
|
15369
15423
|
}
|
|
15424
|
+
function warnFarmFullDocumentLayout() {
|
|
15425
|
+
if (warnedFullDocumentLayout) return;
|
|
15426
|
+
warnedFullDocumentLayout = true;
|
|
15427
|
+
logger.warn(
|
|
15428
|
+
`A root layout returned a full <html> document. Farm.js owns the document shell, so a layout should return a fragment (its children) \u2014 like the docs example \u2014 and let the framework provide <html>/<head>/<body>. The document has been composed into the response, but returning a fragment avoids the ambiguity and keeps dev and production identical.`
|
|
15429
|
+
);
|
|
15430
|
+
}
|
|
15370
15431
|
function hasRequestHeader(req, name2) {
|
|
15371
15432
|
const value = req.headers[name2.toLowerCase()];
|
|
15372
15433
|
return Array.isArray(value) ? value.length > 0 : Boolean(value);
|
|
@@ -15505,13 +15566,14 @@ function createRouteStateProps(input) {
|
|
|
15505
15566
|
context: input.pluginExposedContext.size > 0 ? { data: input.pluginExposedContext } : void 0
|
|
15506
15567
|
};
|
|
15507
15568
|
}
|
|
15508
|
-
var fs3, path11, import_stream, import_node_url5, cachedClerkProvider, importRuntimeModule, warnedSuppressedAsyncHydrationModules, _ServerRenderer, ServerRenderer;
|
|
15569
|
+
var fs3, path11, import_stream, import_node_url5, cachedClerkProvider, importRuntimeModule, warnedSuppressedAsyncHydrationModules, fullDocumentRoutes, warnedFullDocumentLayout, _ServerRenderer, ServerRenderer;
|
|
15509
15570
|
var init_renderer2 = __esm({
|
|
15510
15571
|
"src/server/renderer.ts"() {
|
|
15511
15572
|
"use strict";
|
|
15512
15573
|
fs3 = __toESM(require("fs"));
|
|
15513
15574
|
path11 = __toESM(require("path"));
|
|
15514
15575
|
init_utils();
|
|
15576
|
+
init_full_document();
|
|
15515
15577
|
init_client_component();
|
|
15516
15578
|
import_stream = require("stream");
|
|
15517
15579
|
init_server();
|
|
@@ -15546,6 +15608,9 @@ var init_renderer2 = __esm({
|
|
|
15546
15608
|
importRuntimeModule = new Function("specifier", "return import(specifier);");
|
|
15547
15609
|
warnedSuppressedAsyncHydrationModules = /* @__PURE__ */ new Set();
|
|
15548
15610
|
__name(warnSuppressedAsyncHydrationOnce, "warnSuppressedAsyncHydrationOnce");
|
|
15611
|
+
fullDocumentRoutes = /* @__PURE__ */ new Set();
|
|
15612
|
+
warnedFullDocumentLayout = false;
|
|
15613
|
+
__name(warnFarmFullDocumentLayout, "warnFarmFullDocumentLayout");
|
|
15549
15614
|
__name(hasRequestHeader, "hasRequestHeader");
|
|
15550
15615
|
__name(serializeInlineValue2, "serializeInlineValue");
|
|
15551
15616
|
__name(escapeHtmlAttribute2, "escapeHtmlAttribute");
|
|
@@ -16861,7 +16926,27 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
16861
16926
|
this.config.basePath,
|
|
16862
16927
|
getTheme()
|
|
16863
16928
|
);
|
|
16864
|
-
const
|
|
16929
|
+
const fullDocument = extractFarmFullDocument(content);
|
|
16930
|
+
let html;
|
|
16931
|
+
if (fullDocument) {
|
|
16932
|
+
warnFarmFullDocumentLayout();
|
|
16933
|
+
html = composeFarmFullDocument(fullDocument, {
|
|
16934
|
+
htmlAttributes: `${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}`,
|
|
16935
|
+
headAssets: [
|
|
16936
|
+
themeDocument.head,
|
|
16937
|
+
`<meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">`,
|
|
16938
|
+
metaTags,
|
|
16939
|
+
alternateTags,
|
|
16940
|
+
renderFarmFontDevHead(this.config.root || process.cwd()),
|
|
16941
|
+
`<link rel="stylesheet" href="/src/app/globals.css">`,
|
|
16942
|
+
`<script type="module" src="/@vite/client"></script>`,
|
|
16943
|
+
rendererHydrationScript,
|
|
16944
|
+
bootstrapScript
|
|
16945
|
+
].filter(Boolean).join("\n "),
|
|
16946
|
+
bodyFooter: [deferredScript, `<script type="module" src="/@farm/client.js"></script>`].filter(Boolean).join("\n ")
|
|
16947
|
+
});
|
|
16948
|
+
} else {
|
|
16949
|
+
html = `<!DOCTYPE html>
|
|
16865
16950
|
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
|
|
16866
16951
|
<head>
|
|
16867
16952
|
${themeDocument.head}
|
|
@@ -16882,6 +16967,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
16882
16967
|
<script type="module" src="/@farm/client.js"></script>
|
|
16883
16968
|
</body>
|
|
16884
16969
|
</html>`;
|
|
16970
|
+
}
|
|
16885
16971
|
emitFarmEvent({
|
|
16886
16972
|
type: "render.stream.shellReady",
|
|
16887
16973
|
route: route2,
|
|
@@ -16904,7 +16990,8 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
16904
16990
|
}
|
|
16905
16991
|
async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
|
|
16906
16992
|
const renderToPipeableStream2 = this.rendererRuntime.renderToPipeableStream;
|
|
16907
|
-
|
|
16993
|
+
const fullDocumentRouteKey = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
|
|
16994
|
+
if (!renderToPipeableStream2 || fullDocumentRoutes.has(fullDocumentRouteKey)) {
|
|
16908
16995
|
return this.renderBufferedSSR(element, req, res, clearMiddlewareData, options);
|
|
16909
16996
|
}
|
|
16910
16997
|
return new Promise((resolve8, reject) => {
|
|
@@ -17051,6 +17138,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
17051
17138
|
htmlParts.push(shell);
|
|
17052
17139
|
staticShellParts?.push(shell);
|
|
17053
17140
|
let firstChunk = true;
|
|
17141
|
+
let checkedFullDocument = false;
|
|
17054
17142
|
const writableStream = new import_stream.Writable({
|
|
17055
17143
|
write(chunk, encoding, callback) {
|
|
17056
17144
|
if (firstChunk && process.env.FARM_VERBOSE) {
|
|
@@ -17058,6 +17146,13 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(
|
|
|
17058
17146
|
firstChunk = false;
|
|
17059
17147
|
}
|
|
17060
17148
|
const chunkText = Buffer.isBuffer(chunk) ? chunk.toString() : String(chunk);
|
|
17149
|
+
if (!checkedFullDocument) {
|
|
17150
|
+
checkedFullDocument = true;
|
|
17151
|
+
if (opensFarmFullDocument(chunkText)) {
|
|
17152
|
+
fullDocumentRoutes.add(fullDocumentRouteKey);
|
|
17153
|
+
warnFarmFullDocumentLayout();
|
|
17154
|
+
}
|
|
17155
|
+
}
|
|
17061
17156
|
htmlParts.push(chunkText);
|
|
17062
17157
|
if (staticShellParts && !staticShellClosed) {
|
|
17063
17158
|
const dynamicIndex = findPPRDynamicChunkIndex(chunkText);
|
|
@@ -17256,6 +17351,24 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue2(i18nSnapshot)};
|
|
|
17256
17351
|
getTheme()
|
|
17257
17352
|
);
|
|
17258
17353
|
const rendererHydrationScript = this.rendererRuntime.generateHydrationScript?.() || "";
|
|
17354
|
+
const fullDocument = extractFarmFullDocument(content);
|
|
17355
|
+
if (fullDocument) {
|
|
17356
|
+
warnFarmFullDocumentLayout();
|
|
17357
|
+
return composeFarmFullDocument(fullDocument, {
|
|
17358
|
+
htmlAttributes: `${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}`,
|
|
17359
|
+
headAssets: [
|
|
17360
|
+
themeDocument.head,
|
|
17361
|
+
`<meta name="farm-deployment-id" content="${escapeHtmlAttribute2(this.getDeploymentId())}">`,
|
|
17362
|
+
alternateLinks,
|
|
17363
|
+
fontHead,
|
|
17364
|
+
`<link rel="stylesheet" href="/src/app/globals.css" />`,
|
|
17365
|
+
`<script type="module" src="/@vite/client"></script>`,
|
|
17366
|
+
rendererHydrationScript,
|
|
17367
|
+
integrationManifestScript
|
|
17368
|
+
].filter(Boolean).join("\n "),
|
|
17369
|
+
bodyFooter: clientScript.trim()
|
|
17370
|
+
});
|
|
17371
|
+
}
|
|
17259
17372
|
return `<!DOCTYPE html>
|
|
17260
17373
|
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
|
|
17261
17374
|
<head>
|