@farm.js/core 0.1.0-beta.22 → 0.1.0-beta.23
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/agent-runtime.d.mts +2 -1
- package/dist/agent-runtime.d.ts +2 -1
- package/dist/{app-BB8GCH1g.d.ts → app-CTFnOJaI.d.ts} +5 -3
- package/dist/{app-DwsTpyNZ.d.mts → app-DA6ospIq.d.mts} +5 -3
- package/dist/app-markdown.d.mts +2 -1
- package/dist/app-markdown.d.ts +2 -1
- package/dist/chunk-4IVNW5QD.mjs +82 -0
- package/dist/chunk-4IVNW5QD.mjs.map +1 -0
- package/dist/{chunk-DAUR3WUZ.mjs → chunk-5NOVWCFL.mjs} +2 -2
- package/dist/chunk-5NOVWCFL.mjs.map +1 -0
- package/dist/chunk-D42BNPZH.mjs +79 -0
- package/dist/chunk-D42BNPZH.mjs.map +1 -0
- package/dist/{chunk-LLPN5SEZ.mjs → chunk-DVPRBMU2.mjs} +2 -2
- package/dist/{chunk-ZP73P4VR.mjs → chunk-FJGTYLCO.mjs} +67 -20
- package/dist/chunk-FJGTYLCO.mjs.map +1 -0
- package/dist/chunk-GQVQESLY.mjs +25 -0
- package/dist/chunk-GQVQESLY.mjs.map +1 -0
- package/dist/chunk-H53KVQUU.mjs +48 -0
- package/dist/chunk-H53KVQUU.mjs.map +1 -0
- package/dist/chunk-HCGQYYHI.mjs +1 -0
- package/dist/chunk-HCGQYYHI.mjs.map +1 -0
- package/dist/{chunk-UCYWGN2P.mjs → chunk-OHNSROHS.mjs} +1 -1
- package/dist/{chunk-FRPWCMMG.mjs → chunk-SBWOTAX4.mjs} +63 -2
- package/dist/chunk-SBWOTAX4.mjs.map +1 -0
- package/dist/{chunk-XBKXKJX5.mjs → chunk-TX54PXAJ.mjs} +81 -25
- package/dist/chunk-TX54PXAJ.mjs.map +1 -0
- package/dist/{chunk-CEVMYGDL.mjs → chunk-YD5IRKVS.mjs} +13 -9
- package/dist/chunk-YD5IRKVS.mjs.map +1 -0
- package/dist/{client-plugins-QQntVkrv.d.mts → client-plugins-CCilIb_G.d.mts} +6 -2
- package/dist/{client-plugins-CbRum1fj.d.ts → client-plugins-DuuleQKk.d.ts} +6 -2
- package/dist/client-plugins.d.mts +2 -1
- package/dist/client-plugins.d.ts +2 -1
- package/dist/client.cjs +122 -35
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.mts +2 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.mjs +13 -2
- package/dist/config.d.mts +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/{devtools-52FYXIEK.mjs → devtools-326RBQCN.mjs} +7 -6
- package/dist/{devtools-52FYXIEK.mjs.map → devtools-326RBQCN.mjs.map} +1 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +6 -5
- package/dist/index.cjs +431 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.mjs +66 -49
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.d.mts +2 -1
- package/dist/integrations.d.ts +2 -1
- package/dist/internal/build-runtime.cjs +337 -34
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +4 -3
- package/dist/internal/build-runtime.d.ts +4 -3
- package/dist/internal/build-runtime.mjs +15 -12
- package/dist/internal/config-runtime.cjs +41 -0
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +3 -2
- package/dist/internal/config-runtime.d.ts +3 -2
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/production-runtime.cjs +178 -0
- package/dist/internal/production-runtime.cjs.map +1 -1
- package/dist/internal/production-runtime.d.mts +20 -6
- package/dist/internal/production-runtime.d.ts +20 -6
- package/dist/internal/production-runtime.mjs +13 -1
- package/dist/internal/production-runtime.mjs.map +1 -1
- package/dist/{metadata-B5jBJHq1.d.ts → metadata-DyPRG0wX.d.ts} +1 -1
- package/dist/{metadata-BxOJ4FJl.d.mts → metadata-_GHcAySx.d.mts} +1 -1
- package/dist/middleware.d.mts +4 -3
- package/dist/middleware.d.ts +4 -3
- package/dist/plugin.cjs +219 -14
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.mjs +11 -8
- package/dist/{production-runtime-Bxua86uR.d.mts → production-runtime-C4cO3esK.d.mts} +1 -1
- package/dist/{production-runtime-CZqXjRVi.d.ts → production-runtime-DrEy8kBO.d.ts} +1 -1
- package/dist/{request-7V0GaZK_.d.mts → request-B2PpOxYK.d.mts} +1 -1
- package/dist/{request-B5XYBv5a.d.ts → request-D40lt6aN.d.ts} +1 -1
- package/dist/request.d.mts +3 -2
- package/dist/request.d.ts +3 -2
- package/dist/routes.d.mts +2 -1
- package/dist/routes.d.ts +2 -1
- package/dist/server-plugins.d.mts +3 -2
- package/dist/server-plugins.d.ts +3 -2
- package/dist/server.cjs +241 -19
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +8 -6
- package/dist/server.d.ts +8 -6
- package/dist/server.mjs +20 -11
- package/dist/server.mjs.map +1 -1
- package/dist/testing.d.mts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/theme/client.cjs +115 -0
- package/dist/theme/client.cjs.map +1 -0
- package/dist/theme/client.d.mts +17 -0
- package/dist/theme/client.d.ts +17 -0
- package/dist/theme/client.mjs +16 -0
- package/dist/theme/client.mjs.map +1 -0
- package/dist/theme/index.cjs +71 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.mts +6 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/index.mjs +9 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/theme/server.cjs +191 -0
- package/dist/theme/server.cjs.map +1 -0
- package/dist/theme/server.d.mts +8 -0
- package/dist/theme/server.d.ts +8 -0
- package/dist/theme/server.mjs +18 -0
- package/dist/theme/server.mjs.map +1 -0
- package/dist/types-CsR8fpgF.d.mts +30 -0
- package/dist/types-CsR8fpgF.d.ts +30 -0
- package/dist/{utils-xTFxzu47.d.ts → utils-3sQgfkya.d.ts} +1 -1
- package/dist/{utils-s9pN0Yep.d.mts → utils-Bop7bly-.d.mts} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +242 -15
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +11 -8
- package/package.json +25 -1
- package/dist/chunk-CEVMYGDL.mjs.map +0 -1
- package/dist/chunk-DAUR3WUZ.mjs.map +0 -1
- package/dist/chunk-FRPWCMMG.mjs.map +0 -1
- package/dist/chunk-XBKXKJX5.mjs.map +0 -1
- package/dist/chunk-ZP73P4VR.mjs.map +0 -1
- /package/dist/{chunk-LLPN5SEZ.mjs.map → chunk-DVPRBMU2.mjs.map} +0 -0
- /package/dist/{chunk-UCYWGN2P.mjs.map → chunk-OHNSROHS.mjs.map} +0 -0
package/dist/vite.cjs
CHANGED
|
@@ -4444,6 +4444,52 @@ var init_config = __esm({
|
|
|
4444
4444
|
}
|
|
4445
4445
|
});
|
|
4446
4446
|
|
|
4447
|
+
// src/theme/config.ts
|
|
4448
|
+
function resolveFarmThemeConfig(config, basePath = "/") {
|
|
4449
|
+
if (config && "enabled" in config) {
|
|
4450
|
+
return config;
|
|
4451
|
+
}
|
|
4452
|
+
if (!config) {
|
|
4453
|
+
return {
|
|
4454
|
+
enabled: false,
|
|
4455
|
+
default: "system",
|
|
4456
|
+
storageKey: DEFAULT_FARM_THEME_STORAGE_KEY,
|
|
4457
|
+
cookiePath: normalizeCookiePath(basePath)
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4460
|
+
const storageKey = config.storageKey?.trim() || DEFAULT_FARM_THEME_STORAGE_KEY;
|
|
4461
|
+
if (!STORAGE_KEY_PATTERN.test(storageKey)) {
|
|
4462
|
+
throw new Error(
|
|
4463
|
+
"theme.storageKey may only contain letters, numbers, dots, underscores, and hyphens."
|
|
4464
|
+
);
|
|
4465
|
+
}
|
|
4466
|
+
const defaultTheme = config.default ?? "system";
|
|
4467
|
+
if (defaultTheme !== "light" && defaultTheme !== "dark" && defaultTheme !== "system") {
|
|
4468
|
+
throw new Error('theme.default must be "light", "dark", or "system".');
|
|
4469
|
+
}
|
|
4470
|
+
return {
|
|
4471
|
+
enabled: true,
|
|
4472
|
+
default: defaultTheme,
|
|
4473
|
+
storageKey,
|
|
4474
|
+
cookiePath: normalizeCookiePath(basePath)
|
|
4475
|
+
};
|
|
4476
|
+
}
|
|
4477
|
+
function normalizeCookiePath(basePath) {
|
|
4478
|
+
const normalized = `/${basePath}`.replace(/\/{2,}/g, "/");
|
|
4479
|
+
if (normalized === "/") return normalized;
|
|
4480
|
+
return normalized.replace(/\/$/, "");
|
|
4481
|
+
}
|
|
4482
|
+
var DEFAULT_FARM_THEME_STORAGE_KEY, STORAGE_KEY_PATTERN;
|
|
4483
|
+
var init_config2 = __esm({
|
|
4484
|
+
"src/theme/config.ts"() {
|
|
4485
|
+
"use strict";
|
|
4486
|
+
DEFAULT_FARM_THEME_STORAGE_KEY = "farm-theme";
|
|
4487
|
+
STORAGE_KEY_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
4488
|
+
__name(resolveFarmThemeConfig, "resolveFarmThemeConfig");
|
|
4489
|
+
__name(normalizeCookiePath, "normalizeCookiePath");
|
|
4490
|
+
}
|
|
4491
|
+
});
|
|
4492
|
+
|
|
4447
4493
|
// src/devtools-config.ts
|
|
4448
4494
|
function resolveFarmDevtoolsConfig(config, mode = "development") {
|
|
4449
4495
|
if (mode !== "development" || config === false) {
|
|
@@ -9336,7 +9382,7 @@ async function resolveDocsConfig(userDocs, options = {}) {
|
|
|
9336
9382
|
};
|
|
9337
9383
|
}
|
|
9338
9384
|
var import_path9, DOCS_CONFIG_FILENAMES;
|
|
9339
|
-
var
|
|
9385
|
+
var init_config3 = __esm({
|
|
9340
9386
|
"src/config.ts"() {
|
|
9341
9387
|
"use strict";
|
|
9342
9388
|
init_integrations();
|
|
@@ -9357,6 +9403,7 @@ var init_config2 = __esm({
|
|
|
9357
9403
|
init_auth_config();
|
|
9358
9404
|
init_preload();
|
|
9359
9405
|
init_security();
|
|
9406
|
+
init_config2();
|
|
9360
9407
|
init_config_entry();
|
|
9361
9408
|
__name(getDeployTargetForPreset, "getDeployTargetForPreset");
|
|
9362
9409
|
DOCS_CONFIG_FILENAMES = [
|
|
@@ -9851,7 +9898,7 @@ var init_api = __esm({
|
|
|
9851
9898
|
"src/docs/api.ts"() {
|
|
9852
9899
|
"use strict";
|
|
9853
9900
|
import_docs2 = require("@farming-labs/docs");
|
|
9854
|
-
|
|
9901
|
+
init_config3();
|
|
9855
9902
|
init_handler();
|
|
9856
9903
|
__name(isRecord4, "isRecord");
|
|
9857
9904
|
__name(isResolvedDocsConfig2, "isResolvedDocsConfig");
|
|
@@ -10836,7 +10883,7 @@ var init_devtools = __esm({
|
|
|
10836
10883
|
"src/devtools.ts"() {
|
|
10837
10884
|
"use strict";
|
|
10838
10885
|
import_node_path14 = __toESM(require("path"));
|
|
10839
|
-
|
|
10886
|
+
init_config3();
|
|
10840
10887
|
init_cron();
|
|
10841
10888
|
init_route_runtime();
|
|
10842
10889
|
__name(normalizePath, "normalizePath");
|
|
@@ -16504,6 +16551,16 @@ async function _runWithCurrentRequest(request, fn) {
|
|
|
16504
16551
|
return requestStore.run(request, fn);
|
|
16505
16552
|
}
|
|
16506
16553
|
__name(_runWithCurrentRequest, "_runWithCurrentRequest");
|
|
16554
|
+
function getCurrentRequest() {
|
|
16555
|
+
const request = requestStore.getStore();
|
|
16556
|
+
if (!request) {
|
|
16557
|
+
throw new Error(
|
|
16558
|
+
"No current request is available. getCurrentRequest() can only be used during server rendering."
|
|
16559
|
+
);
|
|
16560
|
+
}
|
|
16561
|
+
return request;
|
|
16562
|
+
}
|
|
16563
|
+
__name(getCurrentRequest, "getCurrentRequest");
|
|
16507
16564
|
|
|
16508
16565
|
// src/client/router.ts
|
|
16509
16566
|
var import_react3 = require("react");
|
|
@@ -18910,6 +18967,125 @@ function DefaultNotFoundPage(_props) {
|
|
|
18910
18967
|
}
|
|
18911
18968
|
__name(DefaultNotFoundPage, "DefaultNotFoundPage");
|
|
18912
18969
|
|
|
18970
|
+
// src/theme/server-runtime.ts
|
|
18971
|
+
init_config2();
|
|
18972
|
+
var THEME_SCRIPT_ID = "farm-theme-script";
|
|
18973
|
+
var THEME_STYLE_ID = "farm-theme-style";
|
|
18974
|
+
function createFarmThemeDocumentParts(input, basePath = "/", serverTheme) {
|
|
18975
|
+
const config = resolveFarmThemeConfig(input, basePath);
|
|
18976
|
+
if (!config.enabled) return { attributes: "", head: "" };
|
|
18977
|
+
const hydrationTheme = serverTheme ?? config.default;
|
|
18978
|
+
const initialTheme = hydrationTheme === "system" ? "light" : hydrationTheme;
|
|
18979
|
+
const script = createFarmThemeBootstrapScript(config, hydrationTheme);
|
|
18980
|
+
return {
|
|
18981
|
+
attributes: ` data-theme="${initialTheme}"`,
|
|
18982
|
+
head: `<style id="${THEME_STYLE_ID}">:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}</style><script id="${THEME_SCRIPT_ID}">${script}</script>`
|
|
18983
|
+
};
|
|
18984
|
+
}
|
|
18985
|
+
__name(createFarmThemeDocumentParts, "createFarmThemeDocumentParts");
|
|
18986
|
+
function createFarmThemeBootstrapScript(config, serverTheme = config.default) {
|
|
18987
|
+
return `(function(config,serverTheme){
|
|
18988
|
+
var isTheme=function(value){return value==="light"||value==="dark"||value==="system";};
|
|
18989
|
+
var decode=function(value){try{return decodeURIComponent(value);}catch(_error){return value;}};
|
|
18990
|
+
var readCookie=function(){var entries=document.cookie.split(";");for(var index=0;index<entries.length;index++){var entry=entries[index];var separator=entry.indexOf("=");if(separator<0)continue;if(decode(entry.slice(0,separator).trim())===config.storageKey)return decode(entry.slice(separator+1).trim());}};
|
|
18991
|
+
var media=window.matchMedia("(prefers-color-scheme: dark)");
|
|
18992
|
+
var resolveTheme=function(theme){return theme==="system"?(media.matches?"dark":"light"):theme;};
|
|
18993
|
+
var storedTheme=readCookie();
|
|
18994
|
+
var preference=isTheme(storedTheme)?storedTheme:config.default;
|
|
18995
|
+
var serverSnapshot={theme:serverTheme,resolvedTheme:serverTheme==="system"?undefined:serverTheme,mounted:false};
|
|
18996
|
+
var apply=function(){var resolvedTheme=resolveTheme(preference);document.documentElement.dataset.theme=resolvedTheme;var snapshot={theme:preference,resolvedTheme:resolvedTheme,mounted:true};if(window.__FARM_THEME__)window.__FARM_THEME__.snapshot=snapshot;return snapshot;};
|
|
18997
|
+
var emit=function(){var snapshot=apply();window.dispatchEvent(new CustomEvent("farm:themechange",{detail:snapshot}));};
|
|
18998
|
+
var persist=function(theme){var secure=window.location.protocol==="https:"?"; Secure":"";document.cookie=encodeURIComponent(config.storageKey)+"="+encodeURIComponent(theme)+"; Path="+config.cookiePath+"; Max-Age=31536000; SameSite=Lax"+secure;try{localStorage.setItem(config.storageKey,theme);}catch(_error){}};
|
|
18999
|
+
var setTheme=function(theme){if(!isTheme(theme))throw new TypeError("Unknown FARMJS theme: "+String(theme));preference=theme;persist(theme);emit();};
|
|
19000
|
+
var initialSnapshot={theme:preference,resolvedTheme:resolveTheme(preference),mounted:true};
|
|
19001
|
+
window.__FARM_THEME__={config:config,serverSnapshot:serverSnapshot,snapshot:initialSnapshot,setTheme:setTheme};
|
|
19002
|
+
document.documentElement.dataset.theme=initialSnapshot.resolvedTheme;
|
|
19003
|
+
var handleSystemChange=function(){if(preference==="system")emit();};
|
|
19004
|
+
if(typeof media.addEventListener==="function")media.addEventListener("change",handleSystemChange);else if(typeof media.addListener==="function")media.addListener(handleSystemChange);
|
|
19005
|
+
window.addEventListener("storage",function(event){if(event.key!==config.storageKey||!isTheme(event.newValue))return;preference=event.newValue;persist(preference);emit();});
|
|
19006
|
+
})(${serializeInlineValue(config)},${serializeInlineValue(serverTheme)});`;
|
|
19007
|
+
}
|
|
19008
|
+
__name(createFarmThemeBootstrapScript, "createFarmThemeBootstrapScript");
|
|
19009
|
+
function serializeInlineValue(value) {
|
|
19010
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
19011
|
+
}
|
|
19012
|
+
__name(serializeInlineValue, "serializeInlineValue");
|
|
19013
|
+
|
|
19014
|
+
// src/theme/bridge.ts
|
|
19015
|
+
var FALLBACK_SERVER_SNAPSHOT = Object.freeze({
|
|
19016
|
+
theme: "system",
|
|
19017
|
+
resolvedTheme: void 0,
|
|
19018
|
+
mounted: false
|
|
19019
|
+
});
|
|
19020
|
+
var FARM_THEME_SERVER_SNAPSHOT_RESOLVER = /* @__PURE__ */ Symbol.for("farm.js.theme.server-snapshot-resolver");
|
|
19021
|
+
function _setFarmThemeServerSnapshotResolver(resolver) {
|
|
19022
|
+
globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER] = resolver;
|
|
19023
|
+
}
|
|
19024
|
+
__name(_setFarmThemeServerSnapshotResolver, "_setFarmThemeServerSnapshotResolver");
|
|
19025
|
+
|
|
19026
|
+
// src/theme/server.ts
|
|
19027
|
+
init_config2();
|
|
19028
|
+
var defaultThemeConfig = resolveFarmThemeConfig(void 0);
|
|
19029
|
+
function _setDefaultFarmThemeConfig(config, basePath = "/") {
|
|
19030
|
+
defaultThemeConfig = resolveFarmThemeConfig(config, basePath);
|
|
19031
|
+
}
|
|
19032
|
+
__name(_setDefaultFarmThemeConfig, "_setDefaultFarmThemeConfig");
|
|
19033
|
+
function getTheme(request = getCurrentRequest()) {
|
|
19034
|
+
return readFarmThemePreference(request, defaultThemeConfig);
|
|
19035
|
+
}
|
|
19036
|
+
__name(getTheme, "getTheme");
|
|
19037
|
+
function getThemeSnapshot(request = getCurrentRequest()) {
|
|
19038
|
+
const theme = readFarmThemePreference(request, defaultThemeConfig);
|
|
19039
|
+
return {
|
|
19040
|
+
theme,
|
|
19041
|
+
resolvedTheme: theme === "system" ? void 0 : theme,
|
|
19042
|
+
mounted: false
|
|
19043
|
+
};
|
|
19044
|
+
}
|
|
19045
|
+
__name(getThemeSnapshot, "getThemeSnapshot");
|
|
19046
|
+
function readFarmThemePreference(request, config) {
|
|
19047
|
+
if (!config.enabled) return config.default;
|
|
19048
|
+
const stored = readCookie3(request.headers.get("cookie"), config.storageKey);
|
|
19049
|
+
return isFarmThemePreference(stored) ? stored : config.default;
|
|
19050
|
+
}
|
|
19051
|
+
__name(readFarmThemePreference, "readFarmThemePreference");
|
|
19052
|
+
function readCookie3(cookieHeader, name) {
|
|
19053
|
+
if (!cookieHeader) return void 0;
|
|
19054
|
+
for (const entry of cookieHeader.split(";")) {
|
|
19055
|
+
const separator = entry.indexOf("=");
|
|
19056
|
+
if (separator < 0) continue;
|
|
19057
|
+
const key = decodeCookieValue(entry.slice(0, separator).trim());
|
|
19058
|
+
if (key !== name) continue;
|
|
19059
|
+
return decodeCookieValue(entry.slice(separator + 1).trim());
|
|
19060
|
+
}
|
|
19061
|
+
return void 0;
|
|
19062
|
+
}
|
|
19063
|
+
__name(readCookie3, "readCookie");
|
|
19064
|
+
function decodeCookieValue(value) {
|
|
19065
|
+
try {
|
|
19066
|
+
return decodeURIComponent(value);
|
|
19067
|
+
} catch {
|
|
19068
|
+
return value;
|
|
19069
|
+
}
|
|
19070
|
+
}
|
|
19071
|
+
__name(decodeCookieValue, "decodeCookieValue");
|
|
19072
|
+
function isFarmThemePreference(value) {
|
|
19073
|
+
return value === "light" || value === "dark" || value === "system";
|
|
19074
|
+
}
|
|
19075
|
+
__name(isFarmThemePreference, "isFarmThemePreference");
|
|
19076
|
+
_setFarmThemeServerSnapshotResolver(() => {
|
|
19077
|
+
try {
|
|
19078
|
+
return getThemeSnapshot();
|
|
19079
|
+
} catch {
|
|
19080
|
+
const theme = defaultThemeConfig.default;
|
|
19081
|
+
return {
|
|
19082
|
+
theme,
|
|
19083
|
+
resolvedTheme: theme === "system" ? void 0 : theme,
|
|
19084
|
+
mounted: false
|
|
19085
|
+
};
|
|
19086
|
+
}
|
|
19087
|
+
});
|
|
19088
|
+
|
|
18913
19089
|
// src/server/renderer.ts
|
|
18914
19090
|
var cachedClerkProvider = null;
|
|
18915
19091
|
var importRuntimeModule = new Function("specifier", "return import(specifier);");
|
|
@@ -18918,10 +19094,10 @@ function hasRequestHeader(req, name) {
|
|
|
18918
19094
|
return Array.isArray(value) ? value.length > 0 : Boolean(value);
|
|
18919
19095
|
}
|
|
18920
19096
|
__name(hasRequestHeader, "hasRequestHeader");
|
|
18921
|
-
function
|
|
19097
|
+
function serializeInlineValue2(value) {
|
|
18922
19098
|
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
18923
19099
|
}
|
|
18924
|
-
__name(
|
|
19100
|
+
__name(serializeInlineValue2, "serializeInlineValue");
|
|
18925
19101
|
function escapeHtmlAttribute2(value) {
|
|
18926
19102
|
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
18927
19103
|
}
|
|
@@ -19015,7 +19191,7 @@ function createDocumentFooter(options) {
|
|
|
19015
19191
|
__name(createDocumentFooter, "createDocumentFooter");
|
|
19016
19192
|
function createDeferredHydrationScript(records) {
|
|
19017
19193
|
if (records.length === 0) return "";
|
|
19018
|
-
return `<script>window.__FARM_DEFERRED_DATA__=${
|
|
19194
|
+
return `<script>window.__FARM_DEFERRED_DATA__=${serializeInlineValue2(
|
|
19019
19195
|
snapshotDeferredData(records)
|
|
19020
19196
|
)};</script>`;
|
|
19021
19197
|
}
|
|
@@ -20156,9 +20332,9 @@ var _ServerRenderer = class _ServerRenderer {
|
|
|
20156
20332
|
slots: routeSlotPayload
|
|
20157
20333
|
});
|
|
20158
20334
|
const propsScript = `<script>
|
|
20159
|
-
window.__FARM_PROPS__ = ${
|
|
20160
|
-
window.__FARM_ROUTE_SLOTS__ = ${
|
|
20161
|
-
window.__FARM_DEPLOYMENT_ID__ = ${
|
|
20335
|
+
window.__FARM_PROPS__ = ${serializeInlineValue2(deferredProps.data.page)};
|
|
20336
|
+
window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue2(deferredProps.data.slots)};
|
|
20337
|
+
window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(deploymentId)};
|
|
20162
20338
|
window.__FARM_PATH__ = ${JSON.stringify(req.__FARM_ROUTE__ || req.url || "/")};
|
|
20163
20339
|
window.__FARM_IS_CLIENT__ = ${JSON.stringify(isClientComponent)};
|
|
20164
20340
|
window.__FARM_PAGE_SHOULD_HYDRATE__ = ${JSON.stringify(
|
|
@@ -20176,7 +20352,7 @@ window.__FARM_LOADING_MODULE__ = ${JSON.stringify(
|
|
|
20176
20352
|
)};
|
|
20177
20353
|
window.__FARM_MANIFEST__ = ${JSON.stringify(clientManifest)};
|
|
20178
20354
|
window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
|
|
20179
|
-
${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${
|
|
20355
|
+
${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(getFarmI18nClientSnapshot())};` : ""}
|
|
20180
20356
|
</script>`;
|
|
20181
20357
|
const hydrationClickQueueScript = isClientComponent || req.__FARM_SHOULD_HYDRATE__ === true || req.__FARM_HAS_HYDRATABLE_ROUTE_SLOTS__ === true ? createPreHydrationClickQueueScript() : "";
|
|
20182
20358
|
const {
|
|
@@ -20187,6 +20363,11 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
|
|
|
20187
20363
|
const i18nSnapshot = getFarmI18nClientSnapshot();
|
|
20188
20364
|
const i18nAlternateTags = i18nSnapshot ? renderI18nAlternateLinks(req.__FARM_ROUTE__ || req.url || "/", i18nSnapshot) : "";
|
|
20189
20365
|
const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
|
|
20366
|
+
const themeDocument = createFarmThemeDocumentParts(
|
|
20367
|
+
this.config.theme,
|
|
20368
|
+
this.config.basePath,
|
|
20369
|
+
getTheme()
|
|
20370
|
+
);
|
|
20190
20371
|
const streamRoot = import_react5.default.createElement("div", { style: { display: "contents" } }, element);
|
|
20191
20372
|
const { pipe } = (0, import_server2.renderToPipeableStream)(streamRoot, {
|
|
20192
20373
|
onShellReady() {
|
|
@@ -20200,8 +20381,9 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
|
|
|
20200
20381
|
console.log(`[FARM STREAM] onShellReady at ${shellReadyMs}ms`);
|
|
20201
20382
|
}
|
|
20202
20383
|
const shell = `<!DOCTYPE html>
|
|
20203
|
-
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
|
|
20384
|
+
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
|
|
20204
20385
|
<head>
|
|
20386
|
+
${themeDocument.head}
|
|
20205
20387
|
<meta charset="utf-8">
|
|
20206
20388
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
20207
20389
|
<meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">
|
|
@@ -20403,15 +20585,21 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
|
|
|
20403
20585
|
const i18nSnapshot = getFarmI18nClientSnapshot();
|
|
20404
20586
|
const clientScript = isClientComponent ? ` <script type="module" src="/@farm/client.js"></script>` : "";
|
|
20405
20587
|
const integrationManifestScript = `<script>
|
|
20406
|
-
window.__FARM_DEPLOYMENT_ID__ = ${
|
|
20588
|
+
window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(this.getDeploymentId())};
|
|
20407
20589
|
window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
|
|
20408
|
-
${i18nSnapshot ? `window.__FARM_I18N__ = ${
|
|
20590
|
+
${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue2(i18nSnapshot)};` : ""}
|
|
20409
20591
|
</script>`;
|
|
20410
20592
|
const alternateLinks = i18nSnapshot ? renderI18nAlternateLinks(requestPath, i18nSnapshot) : "";
|
|
20411
20593
|
const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
|
|
20594
|
+
const themeDocument = createFarmThemeDocumentParts(
|
|
20595
|
+
this.config.theme,
|
|
20596
|
+
this.config.basePath,
|
|
20597
|
+
getTheme()
|
|
20598
|
+
);
|
|
20412
20599
|
return `<!DOCTYPE html>
|
|
20413
|
-
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
|
|
20600
|
+
<html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
|
|
20414
20601
|
<head>
|
|
20602
|
+
${themeDocument.head}
|
|
20415
20603
|
<meta charset="utf-8">
|
|
20416
20604
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
20417
20605
|
<meta name="farm-deployment-id" content="${escapeHtmlAttribute2(this.getDeploymentId())}">
|
|
@@ -20458,6 +20646,7 @@ init_config();
|
|
|
20458
20646
|
init_auth_config();
|
|
20459
20647
|
init_preload();
|
|
20460
20648
|
init_security();
|
|
20649
|
+
init_config2();
|
|
20461
20650
|
var defaultDocsConfig = {
|
|
20462
20651
|
enabled: false,
|
|
20463
20652
|
entry: "/docs",
|
|
@@ -20471,6 +20660,7 @@ var _FarmApp = class _FarmApp {
|
|
|
20471
20660
|
constructor(config = {}, viteServer) {
|
|
20472
20661
|
this.config = this.normalizeConfig(config);
|
|
20473
20662
|
configureFarmObservability(this.config.observability);
|
|
20663
|
+
_setDefaultFarmThemeConfig(this.config.theme);
|
|
20474
20664
|
this.i18nRuntime = createFarmI18nRuntime(this.config.i18n);
|
|
20475
20665
|
_setDefaultFarmI18nRuntime(this.i18nRuntime);
|
|
20476
20666
|
this.viteServer = viteServer;
|
|
@@ -20529,6 +20719,7 @@ var _FarmApp = class _FarmApp {
|
|
|
20529
20719
|
security: resolveFarmSecurityConfig(config.security),
|
|
20530
20720
|
images: resolveFarmImageConfig(config.images),
|
|
20531
20721
|
performance: resolveFarmPerformanceConfig(config.performance),
|
|
20722
|
+
theme: resolveFarmThemeConfig(config.theme, config.basePath || "/"),
|
|
20532
20723
|
i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
|
|
20533
20724
|
root,
|
|
20534
20725
|
mode: process.env.NODE_ENV === "production" ? "production" : "development"
|
|
@@ -23139,7 +23330,7 @@ function transformError(id, message) {
|
|
|
23139
23330
|
__name(transformError, "transformError");
|
|
23140
23331
|
|
|
23141
23332
|
// package.json
|
|
23142
|
-
var version = "0.1.0-beta.
|
|
23333
|
+
var version = "0.1.0-beta.23";
|
|
23143
23334
|
|
|
23144
23335
|
// src/version.ts
|
|
23145
23336
|
var FARM_VERSION = version;
|
|
@@ -23385,6 +23576,32 @@ __name(createFarmSourceAlias, "createFarmSourceAlias");
|
|
|
23385
23576
|
// src/vite.ts
|
|
23386
23577
|
init_fonts();
|
|
23387
23578
|
init_server_http();
|
|
23579
|
+
|
|
23580
|
+
// src/theme/vite.ts
|
|
23581
|
+
init_config2();
|
|
23582
|
+
var FARM_DARK_VARIANT = '@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));';
|
|
23583
|
+
function createFarmThemeCssPlugin(input, basePath = "/") {
|
|
23584
|
+
const config = resolveFarmThemeConfig(input, basePath);
|
|
23585
|
+
return {
|
|
23586
|
+
name: "farm:theme-css",
|
|
23587
|
+
enforce: "pre",
|
|
23588
|
+
transform(code, id) {
|
|
23589
|
+
if (!config.enabled || !/\.css(?:\?.*)?$/.test(id) || !/@import\s+["']tailwindcss["']/.test(code) || /@custom-variant\s+dark\b/.test(code)) {
|
|
23590
|
+
return null;
|
|
23591
|
+
}
|
|
23592
|
+
return {
|
|
23593
|
+
code: `${code.trimEnd()}
|
|
23594
|
+
|
|
23595
|
+
${FARM_DARK_VARIANT}
|
|
23596
|
+
`,
|
|
23597
|
+
map: null
|
|
23598
|
+
};
|
|
23599
|
+
}
|
|
23600
|
+
};
|
|
23601
|
+
}
|
|
23602
|
+
__name(createFarmThemeCssPlugin, "createFarmThemeCssPlugin");
|
|
23603
|
+
|
|
23604
|
+
// src/vite.ts
|
|
23388
23605
|
var ALL_TYPE_ARTIFACTS = {
|
|
23389
23606
|
routes: true,
|
|
23390
23607
|
api: true,
|
|
@@ -26771,14 +26988,22 @@ async function renderPage(pageData) {
|
|
|
26771
26988
|
if (!doc.documentElement || !doc.body) return false;
|
|
26772
26989
|
|
|
26773
26990
|
resetReactRoots();
|
|
26991
|
+
const activeFarmTheme =
|
|
26992
|
+
window.__FARM_THEME__?.snapshot?.resolvedTheme ||
|
|
26993
|
+
document.documentElement.getAttribute('data-theme');
|
|
26774
26994
|
Array.from(document.documentElement.attributes).forEach(function(attr) {
|
|
26995
|
+
if (attr.name === 'data-theme') return;
|
|
26775
26996
|
if (!doc.documentElement.hasAttribute(attr.name)) {
|
|
26776
26997
|
document.documentElement.removeAttribute(attr.name);
|
|
26777
26998
|
}
|
|
26778
26999
|
});
|
|
26779
27000
|
Array.from(doc.documentElement.attributes).forEach(function(attr) {
|
|
27001
|
+
if (attr.name === 'data-theme') return;
|
|
26780
27002
|
document.documentElement.setAttribute(attr.name, attr.value);
|
|
26781
27003
|
});
|
|
27004
|
+
if (activeFarmTheme) {
|
|
27005
|
+
document.documentElement.setAttribute('data-theme', activeFarmTheme);
|
|
27006
|
+
}
|
|
26782
27007
|
|
|
26783
27008
|
document.head.innerHTML = doc.head ? doc.head.innerHTML : '';
|
|
26784
27009
|
document.body.innerHTML = doc.body.innerHTML;
|
|
@@ -26787,6 +27012,7 @@ async function renderPage(pageData) {
|
|
|
26787
27012
|
|
|
26788
27013
|
setTimeout(function() {
|
|
26789
27014
|
Array.from(document.querySelectorAll('script')).forEach(function(script) {
|
|
27015
|
+
if (script.id === 'farm-theme-script') return;
|
|
26790
27016
|
const freshScript = document.createElement('script');
|
|
26791
27017
|
Array.from(script.attributes).forEach(function(attr) {
|
|
26792
27018
|
freshScript.setAttribute(attr.name, attr.value);
|
|
@@ -27284,6 +27510,7 @@ async function defineConfig2(config = {}) {
|
|
|
27284
27510
|
};
|
|
27285
27511
|
return {
|
|
27286
27512
|
plugins: [
|
|
27513
|
+
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
27287
27514
|
tailwindcss(),
|
|
27288
27515
|
viteBrowserExternalPlugin,
|
|
27289
27516
|
farmI18nClientBridgePlugin(),
|