@farm.js/core 0.1.75 → 0.1.76
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-mcp.d-Djvao5eV.d.ts → agent-mcp.d-Cftp2kFv.d.ts} +1 -1
- package/dist/{agent-mcp.d-wA13pwmS.d.mts → agent-mcp.d-D0FMmqi0.d.mts} +1 -1
- package/dist/agent-runtime.cjs +2 -2
- package/dist/agent-runtime.d.mts +7 -5
- package/dist/agent-runtime.d.ts +7 -5
- package/dist/agent-runtime.mjs +1 -1
- package/dist/analyzer-KFJGYJS7.cjs +16 -0
- package/dist/{analyzer-LJHMFCDW.mjs → analyzer-NLQKPN74.mjs} +2 -2
- package/dist/api/node.d.mts +9 -7
- package/dist/api/node.d.ts +9 -7
- package/dist/api/route-manager.d.mts +9 -7
- package/dist/api/route-manager.d.ts +9 -7
- package/dist/api/runtime.d.mts +8 -6
- package/dist/api/runtime.d.ts +8 -6
- package/dist/api.d.mts +10 -8
- package/dist/api.d.ts +10 -8
- package/dist/{app-manifest.d-BukcP_EV.d.ts → app-manifest.d-7PmA_9hm.d.ts} +1 -1
- package/dist/{app-manifest.d-DIuqSi9k.d.mts → app-manifest.d-cpOw_sV5.d.mts} +1 -1
- package/dist/app-markdown.d.mts +8 -6
- package/dist/app-markdown.d.ts +8 -6
- package/dist/{app.d-YVuFb10p.d.mts → app.d-DUZvwnFF.d.mts} +5 -4
- package/dist/{app.d-BQqmM6Gy.d.ts → app.d-wOkxXre8.d.ts} +5 -4
- package/dist/{chunk-A5F55ZFA.mjs → chunk-2GZZVIXY.mjs} +1 -1
- package/dist/{chunk-4BS3HSY7.cjs → chunk-2JEXQAIR.cjs} +2 -2
- package/dist/{chunk-OZARLCYQ.cjs → chunk-2WKGQCAV.cjs} +162 -162
- package/dist/{chunk-B4CWYGCG.mjs → chunk-3OYFMOBY.mjs} +1 -1
- package/dist/{chunk-GNY7BO7R.mjs → chunk-5EEQNZLU.mjs} +2 -2
- package/dist/{chunk-XGDI4OUB.cjs → chunk-6ZFGWB75.cjs} +13 -1
- package/dist/{chunk-6MATGOEF.mjs → chunk-A2VFKOQL.mjs} +1 -1
- package/dist/{chunk-YL7BKHYE.cjs → chunk-BBRSPKFI.cjs} +277 -265
- package/dist/{chunk-BNTRXJL4.cjs → chunk-BYJPBJ4E.cjs} +3 -3
- package/dist/{chunk-4ZSZI6XL.cjs → chunk-CCQZDOQR.cjs} +8 -8
- package/dist/{chunk-OFIFRB62.mjs → chunk-CKBBKRBO.mjs} +34 -18
- package/dist/{chunk-IK33N2AN.cjs → chunk-DTNWLRRF.cjs} +144 -128
- package/dist/{chunk-BUC3FDYC.cjs → chunk-DVW6SKHA.cjs} +2 -2
- package/dist/{chunk-MFU7SXAB.mjs → chunk-E77ZKNPN.mjs} +1 -1
- package/dist/{chunk-YCNKS6SD.mjs → chunk-GP5BWTO7.mjs} +2 -2
- package/dist/{chunk-HT2SZKXG.mjs → chunk-H76C5AOU.mjs} +12 -0
- package/dist/{chunk-ZV76IQG7.cjs → chunk-HKGU2X4I.cjs} +2 -2
- package/dist/{chunk-4T2RB4JA.mjs → chunk-JL6XHQZF.mjs} +3 -3
- package/dist/{chunk-HV2WZFUW.mjs → chunk-MOS2N377.mjs} +1 -1
- package/dist/{chunk-IDOUCM2X.mjs → chunk-O225GNEU.mjs} +53 -41
- package/dist/{chunk-NPGXX7HN.cjs → chunk-PSNYVBWC.cjs} +3 -3
- package/dist/{chunk-WHCNJVYU.cjs → chunk-PXXG5BID.cjs} +3 -3
- package/dist/{chunk-TJVUTGED.mjs → chunk-Q4X3MX4J.mjs} +201 -3
- package/dist/{chunk-TFEODQLG.mjs → chunk-Q7JMHO5U.mjs} +2 -2
- package/dist/{chunk-JNZDTE75.cjs → chunk-QP4GYVRR.cjs} +6 -6
- package/dist/{chunk-HVJ7IACB.cjs → chunk-QTDIOZV6.cjs} +2 -2
- package/dist/{chunk-YSTKSZD2.mjs → chunk-SGQXJVFX.mjs} +1 -1
- package/dist/{chunk-KPYQ32BA.cjs → chunk-TMVVBK5S.cjs} +2 -2
- package/dist/{chunk-JMYXO572.cjs → chunk-UBXNTZCY.cjs} +205 -7
- package/dist/{chunk-2NQ3S2SJ.mjs → chunk-VDJ3CLBR.mjs} +1 -1
- package/dist/{chunk-WJ5CCQBM.cjs → chunk-WILPJVQE.cjs} +4 -4
- package/dist/{chunk-PBQGIA27.cjs → chunk-WJDMH3E7.cjs} +4 -4
- package/dist/{chunk-ZPCZWEU3.cjs → chunk-WMJQNVKX.cjs} +2 -2
- package/dist/{chunk-H7QY7ZE4.mjs → chunk-X3HUT4JU.mjs} +1 -1
- package/dist/{chunk-IVBDRAOR.cjs → chunk-XLOORES5.cjs} +1 -1
- package/dist/{chunk-QGYHE6VJ.mjs → chunk-YHE7HH2I.mjs} +19 -19
- package/dist/{chunk-4MU4QCX4.mjs → chunk-YONTMPZ6.mjs} +1 -1
- package/dist/{chunk-GLF44JKY.mjs → chunk-YQXJY7E7.mjs} +1 -1
- package/dist/cli-runtime.d-D84CwyPI.d.ts +535 -0
- package/dist/cli-runtime.d-OQY2pgwK.d.mts +535 -0
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-component.d-CZ1NpHAY.d.ts → client-component.d-Bf8jZqW7.d.ts} +2 -137
- package/dist/{client-component.d-BeqVuqy2.d.mts → client-component.d-Bh6CfC5z.d.mts} +2 -137
- package/dist/{client-plugins.d-D9kWC0QB.d.ts → client-plugins.d-DuujrC8d.d.ts} +4 -4
- package/dist/{client-plugins.d-ChceYO9t.d.mts → client-plugins.d-r3K2oQ6w.d.mts} +4 -4
- package/dist/client-plugins.d.mts +7 -5
- package/dist/client-plugins.d.ts +7 -5
- package/dist/client.d.mts +12 -10
- package/dist/client.d.ts +12 -10
- package/dist/config.d.mts +7 -5
- package/dist/config.d.ts +7 -5
- package/dist/desktop.d.mts +8 -6
- package/dist/desktop.d.ts +8 -6
- package/dist/{devtools-T5I2WHRX.cjs → devtools-3WZIZ7KK.cjs} +3 -3
- package/dist/{devtools-B3W3DLPG.mjs → devtools-MBZPUH3U.mjs} +2 -2
- package/dist/docs.cjs +4 -4
- package/dist/docs.d.mts +10 -65
- package/dist/docs.d.ts +10 -65
- package/dist/docs.mjs +3 -3
- package/dist/environment/vite.cjs +3 -3
- package/dist/environment/vite.mjs +2 -2
- package/dist/handler.d-Bd5lRSvb.d.ts +62 -0
- package/dist/handler.d-SRH-AKzf.d.mts +62 -0
- package/dist/{headers.d-BawakaPv.d.mts → headers.d-CHHvyaIG.d.mts} +1 -1
- package/dist/{headers.d-Aux4JVnm.d.ts → headers.d-D-OvGikv.d.ts} +1 -1
- package/dist/index.cjs +22 -20
- package/dist/index.d-BOPsgMlI.d.mts +16 -0
- package/dist/index.d-BiUtYJUG.d.ts +16 -0
- package/dist/index.d.mts +39 -556
- package/dist/index.d.ts +39 -556
- package/dist/index.mjs +21 -19
- package/dist/integrations/orm.cjs +3 -3
- package/dist/integrations/orm.d.mts +6 -4
- package/dist/integrations/orm.d.ts +6 -4
- package/dist/integrations/orm.mjs +2 -2
- package/dist/integrations.cjs +2 -2
- package/dist/integrations.d.mts +7 -5
- package/dist/integrations.d.ts +7 -5
- package/dist/integrations.mjs +1 -1
- package/dist/internal/app-markdown-runtime.d.mts +8 -6
- package/dist/internal/app-markdown-runtime.d.ts +8 -6
- package/dist/internal/build-runtime.cjs +19 -19
- package/dist/internal/build-runtime.d.mts +10 -7
- package/dist/internal/build-runtime.d.ts +10 -7
- package/dist/internal/build-runtime.mjs +18 -18
- package/dist/internal/cli-runtime.cjs +11 -6
- package/dist/internal/cli-runtime.d.mts +45 -0
- package/dist/internal/cli-runtime.d.ts +45 -0
- package/dist/internal/cli-runtime.mjs +10 -5
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.d.mts +11 -9
- package/dist/internal/client-runtime.d.ts +11 -9
- package/dist/internal/compression-runtime.d.mts +7 -5
- package/dist/internal/compression-runtime.d.ts +7 -5
- package/dist/internal/config-runtime.cjs +4 -4
- package/dist/internal/config-runtime.d.mts +9 -7
- package/dist/internal/config-runtime.d.ts +9 -7
- package/dist/internal/config-runtime.mjs +3 -3
- package/dist/internal/infra-analytics-runtime.cjs +6 -6
- package/dist/internal/infra-analytics-runtime.mjs +4 -4
- package/dist/internal/native-server-fns.cjs +4 -4
- package/dist/internal/native-server-fns.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +7 -7
- package/dist/internal/production-runtime.d.mts +16 -14
- package/dist/internal/production-runtime.d.ts +16 -14
- package/dist/internal/production-runtime.mjs +6 -6
- package/dist/internal/start-manifest.d.mts +7 -5
- package/dist/internal/start-manifest.d.ts +7 -5
- package/dist/{lifecycle.d-OtGWAvJT.d.mts → lifecycle.d-VzcXyEyn.d.mts} +1 -1
- package/dist/{lifecycle.d-OtGWAvJT.d.ts → lifecycle.d-VzcXyEyn.d.ts} +1 -1
- package/dist/markdown.d.mts +7 -5
- package/dist/markdown.d.ts +7 -5
- package/dist/middleware.d.mts +7 -5
- package/dist/middleware.d.ts +7 -5
- package/dist/{mount.d-Ca8eb9GB.d.ts → mount.d-C2yq0Zzz.d.ts} +1 -1
- package/dist/{mount.d-BomEt2kV.d.mts → mount.d-vq1HTq5u.d.mts} +1 -1
- package/dist/{navigation-delegate.d-DJCC2jXF.d.ts → navigation-delegate.d-D7xIin3i.d.ts} +1 -1
- package/dist/{navigation-delegate.d-B1ujRkYo.d.mts → navigation-delegate.d-DS2Sqm7E.d.mts} +1 -1
- package/dist/navigation.d.mts +10 -8
- package/dist/navigation.d.ts +10 -8
- package/dist/{plugin-FD4S2QEJ.mjs → plugin-6CHZBFJD.mjs} +1 -1
- package/dist/{plugin-5BNPYCER.cjs → plugin-YXPIS3XX.cjs} +2 -2
- package/dist/plugin.cjs +12 -12
- package/dist/plugin.d.mts +11 -8
- package/dist/plugin.d.ts +11 -8
- package/dist/plugin.mjs +11 -11
- package/dist/{render-plan.d-BxRbaxYA.d.ts → render-plan.d-BCq0nfdw.d.ts} +1 -1
- package/dist/{render-plan.d-CFod_Zf-.d.mts → render-plan.d-X6KqerAM.d.mts} +1 -1
- package/dist/renderer-client.d.mts +10 -8
- package/dist/renderer-client.d.ts +10 -8
- package/dist/{request.d-DG4TeXMM.d.mts → request.d-Be9rWboC.d.mts} +1 -1
- package/dist/{request.d-DRQgaXGG.d.ts → request.d-CPdq2_kC.d.ts} +1 -1
- package/dist/request.d.mts +8 -6
- package/dist/request.d.ts +8 -6
- package/dist/{route-rendering.d-BXtZKgqu.d.mts → route-rendering.d-CIPli7Ve.d.mts} +1 -1
- package/dist/{route-rendering.d-Db07UNVG.d.ts → route-rendering.d-CKB5GhQr.d.ts} +1 -1
- package/dist/{router.d-BC3hyjf0.d.ts → router.d-CvrbOXzF.d.ts} +1 -1
- package/dist/{router.d-B61kXqxJ.d.mts → router.d-VxTgLGxN.d.mts} +1 -1
- package/dist/routes.d.mts +7 -5
- package/dist/routes.d.ts +7 -5
- package/dist/{rsc-pipeline-LJ7YCGY6.mjs → rsc-pipeline-FPE4OL57.mjs} +4 -4
- package/dist/{rsc-pipeline-VENBFYXW.cjs → rsc-pipeline-TPHK74VE.cjs} +5 -5
- package/dist/{runtime-4DWUXZHS.mjs → runtime-45BD33OJ.mjs} +3 -3
- package/dist/{runtime-UNDTYGQS.cjs → runtime-UBG657UC.cjs} +5 -5
- package/dist/{runtime.d-Cl6EBGmC.d.mts → runtime.d-Cn1jiDNI.d.mts} +1 -1
- package/dist/{runtime.d-SC95yDzr.d.ts → runtime.d-Ps54JWpo.d.ts} +1 -1
- package/dist/{schema.d-Dny9pnrm.d.mts → schema.d-BM-uVGpx.d.mts} +1 -1
- package/dist/{schema.d-Dny9pnrm.d.ts → schema.d-BM-uVGpx.d.ts} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/{index.d-r1MLpgeE.d.ts → server-components-status.d-Dhtbs5lC.d.ts} +2 -15
- package/dist/{index.d-Ccq42CPU.d.mts → server-components-status.d-DnmipSb3.d.mts} +2 -15
- package/dist/server-plugins.d.mts +9 -7
- package/dist/server-plugins.d.ts +9 -7
- package/dist/server.cjs +37 -35
- package/dist/server.d.mts +17 -14
- package/dist/server.d.ts +17 -14
- package/dist/server.mjs +16 -14
- package/dist/session-ACVUJ5XV.cjs +23 -0
- package/dist/{session-QZXZOPR2.mjs → session-ASQTJNBK.mjs} +2 -2
- package/dist/{spa-router.d-DrlXgDqY.d.mts → spa-router.d-DXm5J9rM.d.mts} +4 -4
- package/dist/{spa-router.d-DwM02Mwd.d.ts → spa-router.d-cppVufl2.d.ts} +4 -4
- package/dist/ssg.d-CI5OFl8H.d.ts +138 -0
- package/dist/ssg.d-Duzy1wQc.d.mts +138 -0
- package/dist/storage.cjs +4 -2
- package/dist/storage.d.mts +14 -4
- package/dist/storage.d.ts +14 -4
- package/dist/storage.mjs +3 -1
- package/dist/testing.d.mts +7 -5
- package/dist/testing.d.ts +7 -5
- package/dist/{types.d-BnIqOn9w.d.mts → types.d-D5cY6XjK.d.mts} +43 -2
- package/dist/{types.d-BnIqOn9w.d.ts → types.d-D5cY6XjK.d.ts} +43 -2
- package/dist/{utils.d-CHzxAshz.d.mts → utils.d-CNI-I8ZV.d.mts} +1 -1
- package/dist/{utils.d-C6KXz3uB.d.ts → utils.d-D3dfy8zh.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +12 -12
- package/dist/vite.d.mts +12 -9
- package/dist/vite.d.ts +12 -9
- package/dist/vite.mjs +11 -11
- package/package.json +10 -3
- package/dist/analyzer-23GCBYFI.cjs +0 -16
- package/dist/session-2Q72D4QV.cjs +0 -23
- /package/dist/{chunk-PMU4U2W2.cjs → chunk-22T75EML.cjs} +0 -0
- /package/dist/{chunk-5O3SK3ZC.mjs → chunk-6MNDFNZW.mjs} +0 -0
- /package/dist/{chunk-Z5ZZAGIH.mjs → chunk-LSHUCNIF.mjs} +0 -0
- /package/dist/{chunk-6DBBMQWT.cjs → chunk-OWO7KDZ3.cjs} +0 -0
|
@@ -8,7 +8,7 @@ var _chunkSHD265HWcjs = require('./chunk-SHD265HW.cjs');
|
|
|
8
8
|
var _chunkGBMWLDCCcjs = require('./chunk-GBMWLDCC.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkUBXNTZCYcjs = require('./chunk-UBXNTZCY.cjs');
|
|
12
12
|
|
|
13
13
|
// src/integration-orm.ts
|
|
14
14
|
async function createIntegrationOrm(options) {
|
|
@@ -31,7 +31,7 @@ async function resolveIntegrationOrmRuntimeClient(options) {
|
|
|
31
31
|
if (options.client !== void 0) {
|
|
32
32
|
return typeof options.client === "function" ? await options.client() : options.client;
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return _chunkUBXNTZCYcjs.resolveStorageRuntimeClient.call(void 0, _nullishCoalesce(options.storage, () => ( _optionalChain([options, 'access', _ => _.config, 'optionalAccess', _2 => _2.storage]))));
|
|
35
35
|
}
|
|
36
36
|
async function farmIntegrationSchemaToOrmSchema(schema) {
|
|
37
37
|
for (const [modelKey, modelSchema] of Object.entries(schema.models)) {
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
} from "./chunk-YWPNIYUP.mjs";
|
|
77
77
|
import {
|
|
78
78
|
resolveIntegrationPlugins
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-6MNDFNZW.mjs";
|
|
80
80
|
import {
|
|
81
81
|
compileMiddlewareConfig
|
|
82
82
|
} from "./chunk-EDPENAVO.mjs";
|
|
@@ -1120,7 +1120,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
1120
1120
|
userConfig.deploymentId || process.env.FARM_DEPLOYMENT_ID || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CF_PAGES_COMMIT_SHA || (mode === "production" ? await generateBuildId() : "development")
|
|
1121
1121
|
);
|
|
1122
1122
|
const basePath = normalizeFarmConfigBasePath(userConfig.basePath);
|
|
1123
|
-
const mobileSessionPlugin = userConfig.mobile !== void 0 && userConfig.mobile !== null ? (await import("./session-
|
|
1123
|
+
const mobileSessionPlugin = userConfig.mobile !== void 0 && userConfig.mobile !== null ? (await import("./session-ASQTJNBK.mjs")).createFarmMobileSessionPlugin({
|
|
1124
1124
|
basePath,
|
|
1125
1125
|
integrations: () => integrations
|
|
1126
1126
|
}) : null;
|
|
@@ -212,6 +212,17 @@ function peelDocumentPrefix(markup) {
|
|
|
212
212
|
}
|
|
213
213
|
return { inner, hoisted, layoutPatterns };
|
|
214
214
|
}
|
|
215
|
+
function takeFarmNavigationOutlet(markup, tag) {
|
|
216
|
+
const open = `<${tag}>`;
|
|
217
|
+
const close = `</${tag}>`;
|
|
218
|
+
const start = markup.indexOf(open);
|
|
219
|
+
if (start === -1) return markup;
|
|
220
|
+
const end = markup.indexOf(close, start + open.length);
|
|
221
|
+
if (end === -1 || markup.includes(open, end + close.length)) {
|
|
222
|
+
return markup.split(open).join("").split(close).join("");
|
|
223
|
+
}
|
|
224
|
+
return peelDocumentPrefix(markup).hoisted + markup.slice(start + open.length, end);
|
|
225
|
+
}
|
|
215
226
|
function markFarmDocumentLayouts(markup) {
|
|
216
227
|
const { inner, layoutPatterns } = peelDocumentPrefix(markup);
|
|
217
228
|
if (layoutPatterns.length === 0) return markup;
|
|
@@ -978,6 +989,7 @@ export {
|
|
|
978
989
|
parseFarmLayoutChainHeader,
|
|
979
990
|
getSharedLayoutPrefixLength,
|
|
980
991
|
HOISTED_HEAD_ELEMENT,
|
|
992
|
+
takeFarmNavigationOutlet,
|
|
981
993
|
markFarmDocumentLayouts,
|
|
982
994
|
extractFarmFullDocument,
|
|
983
995
|
classifyFarmDocumentPrefix,
|
|
@@ -15,14 +15,14 @@ var _chunkWBTHHTBOcjs = require('./chunk-WBTHHTBO.cjs');
|
|
|
15
15
|
var _chunkCCAUIBIScjs = require('./chunk-CCAUIBIS.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkXLOORES5cjs = require('./chunk-XLOORES5.cjs');
|
|
19
19
|
|
|
20
20
|
// src/mobile/analyzer.ts
|
|
21
21
|
var _crypto = require('crypto');
|
|
22
22
|
var _fs = require('fs');
|
|
23
23
|
var _promises = require('fs/promises');
|
|
24
24
|
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
25
|
-
var ANALYZER_VERSION = `7:${
|
|
25
|
+
var ANALYZER_VERSION = `7:${_chunkXLOORES5cjs.FARM_VERSION}`;
|
|
26
26
|
var INTRINSIC_KINDS = {};
|
|
27
27
|
for (const tag of "div section main article header footer nav aside figure hr li".split(" ")) {
|
|
28
28
|
INTRINSIC_KINDS[tag] = "View";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-IG2JE6WJ.mjs";
|
|
11
11
|
import {
|
|
12
12
|
resolveDeployOutputPath
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GP5BWTO7.mjs";
|
|
14
14
|
import {
|
|
15
15
|
farmDesktopDevGuardPlugin,
|
|
16
16
|
loadFarmReactPlugin
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
generateFarmClientPluginEntryCode,
|
|
20
20
|
hasFarmServerRuntimePlugins,
|
|
21
21
|
loadTailwindVitePlugin
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-E77ZKNPN.mjs";
|
|
23
23
|
import {
|
|
24
24
|
resolveFarmPlatform
|
|
25
25
|
} from "./chunk-SMUW7UST.mjs";
|
|
@@ -210,7 +210,7 @@ async function resolveFarmRscServerPlugins(userConfig, config, root) {
|
|
|
210
210
|
}
|
|
211
211
|
async function configureFarmRscPlugins(config, command) {
|
|
212
212
|
if (config.plugins.length === 0) return config;
|
|
213
|
-
const { PluginManager } = await import("./plugin-
|
|
213
|
+
const { PluginManager } = await import("./plugin-6CHZBFJD.mjs");
|
|
214
214
|
const manager = new PluginManager({
|
|
215
215
|
config,
|
|
216
216
|
isDev: command === "serve",
|
|
@@ -40,15 +40,15 @@ import {
|
|
|
40
40
|
resolveFarmImageProviderForRuntime,
|
|
41
41
|
resolveFarmRouteRootStrategy,
|
|
42
42
|
toBakedMarkdownSourcePath
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-CKBBKRBO.mjs";
|
|
44
44
|
import {
|
|
45
45
|
generateFarmClientPluginEntryCode,
|
|
46
46
|
hasFarmServerRuntimePlugins,
|
|
47
47
|
loadTailwindVitePlugin
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-E77ZKNPN.mjs";
|
|
49
49
|
import {
|
|
50
50
|
FARM_NODE_RESPONSE_END_PENDING
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-LSHUCNIF.mjs";
|
|
52
52
|
import {
|
|
53
53
|
resolveFarmPlatform
|
|
54
54
|
} from "./chunk-SMUW7UST.mjs";
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
getSharedLayoutPrefixLength,
|
|
65
65
|
parseFarmLayoutChainHeader,
|
|
66
66
|
renderFarmLocaleAlternateLinks
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-H76C5AOU.mjs";
|
|
68
68
|
import {
|
|
69
69
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
70
70
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -82,13 +82,13 @@ import {
|
|
|
82
82
|
resolveFarmMCPRouteLabel,
|
|
83
83
|
resolveFarmMarkdownRouteLabel,
|
|
84
84
|
setFarmRouteLabel
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-5EEQNZLU.mjs";
|
|
86
86
|
import {
|
|
87
87
|
FARM_DEFAULT_MCP_PATH
|
|
88
88
|
} from "./chunk-JA6RML7C.mjs";
|
|
89
89
|
import {
|
|
90
90
|
isFarmPreviewDeploymentEnvironment
|
|
91
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-SGQXJVFX.mjs";
|
|
92
92
|
import {
|
|
93
93
|
createFarmServerFnBoundaryModule,
|
|
94
94
|
isFarmServerFnBoundaryId,
|
|
@@ -139,7 +139,7 @@ import {
|
|
|
139
139
|
usePackageScanCacheFile,
|
|
140
140
|
withFarmSourceSnapshotOf,
|
|
141
141
|
wrapFarmIslandContainers
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-2GZZVIXY.mjs";
|
|
143
143
|
import {
|
|
144
144
|
generateFarmDocsAdapterClientRuntime,
|
|
145
145
|
getFarmDocsAdapterConfigModule
|
|
@@ -215,7 +215,7 @@ import {
|
|
|
215
215
|
getIntegrationDocumentNavigationMatchers,
|
|
216
216
|
getIntegrationProviders,
|
|
217
217
|
matchIntegrationRoute
|
|
218
|
-
} from "./chunk-
|
|
218
|
+
} from "./chunk-6MNDFNZW.mjs";
|
|
219
219
|
import {
|
|
220
220
|
resolveFarmRouteContext,
|
|
221
221
|
withFarmRouteContext
|
|
@@ -301,7 +301,7 @@ import {
|
|
|
301
301
|
} from "./chunk-2DA7CLY7.mjs";
|
|
302
302
|
import {
|
|
303
303
|
FARM_VERSION
|
|
304
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-X3HUT4JU.mjs";
|
|
305
305
|
import {
|
|
306
306
|
DEFAULT_FARM_API_BASE_PATH
|
|
307
307
|
} from "./chunk-W6QLRQ3V.mjs";
|
|
@@ -1273,7 +1273,7 @@ function loadFarmWorkflowsDevRuntime() {
|
|
|
1273
1273
|
return import("./workflows.mjs");
|
|
1274
1274
|
}
|
|
1275
1275
|
function loadFarmDevtoolsSnapshotRuntime() {
|
|
1276
|
-
return import("./devtools-
|
|
1276
|
+
return import("./devtools-MBZPUH3U.mjs");
|
|
1277
1277
|
}
|
|
1278
1278
|
function loadFarmDevtoolsUIRuntime() {
|
|
1279
1279
|
return import("./devtools-ui-CYBVFLPH.mjs");
|
|
@@ -2324,6 +2324,7 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
|
|
|
2324
2324
|
let openAPIManager = null;
|
|
2325
2325
|
let middlewareManager;
|
|
2326
2326
|
let refreshRouteDiscovery = null;
|
|
2327
|
+
const pendingRouteReloads = /* @__PURE__ */ new Set();
|
|
2327
2328
|
let workflowHandler = null;
|
|
2328
2329
|
let isBuild = false;
|
|
2329
2330
|
let farmOwnsDevCors = false;
|
|
@@ -2590,8 +2591,7 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
|
|
|
2590
2591
|
let typeArtifactGenScheduled = null;
|
|
2591
2592
|
let pendingTypeArtifacts = createEmptyTypeArtifactSelection();
|
|
2592
2593
|
let pendingTypeArtifactReason = "";
|
|
2593
|
-
let
|
|
2594
|
-
let pendingRouteRefreshIncludesMiddleware = false;
|
|
2594
|
+
let queuedRouteFiles;
|
|
2595
2595
|
const scheduleTypeArtifactGen = (file, event, selection) => {
|
|
2596
2596
|
const normalizedFile = toPosixPath(file);
|
|
2597
2597
|
for (const [artifact, enabled] of Object.entries(selection)) {
|
|
@@ -2634,20 +2634,29 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
|
|
|
2634
2634
|
}
|
|
2635
2635
|
const isRouteRefreshEvent = (ev !== "change" || isStaticMetadataImageFile(file)) && (isAppRuntimeFile(file) || isProgrammaticRouteFile(file) || isProgrammaticRouteSourceFile(file) && (ev === "unlink" || fileContainsProgrammaticPageRoute(file)));
|
|
2636
2636
|
if (isRouteRefreshEvent) {
|
|
2637
|
-
if (
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2637
|
+
if (!queuedRouteFiles) {
|
|
2638
|
+
const files = /* @__PURE__ */ new Set();
|
|
2639
|
+
queuedRouteFiles = files;
|
|
2640
|
+
pendingRouteReloads.add(files);
|
|
2641
|
+
setTimeout(async () => {
|
|
2642
|
+
queuedRouteFiles = void 0;
|
|
2643
|
+
try {
|
|
2644
|
+
await Promise.all([
|
|
2645
|
+
refreshRouteDiscovery?.(`${ev} ${file}`),
|
|
2646
|
+
[...files].some((path7) => path7.includes("middleware.")) ? middlewareManager?.reload() : void 0
|
|
2647
|
+
]);
|
|
2648
|
+
if (pendingRouteReloads.size === 1)
|
|
2649
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
logger.warn(
|
|
2652
|
+
`Route refresh failed: ${error instanceof Error ? error.message : String(error)}`
|
|
2653
|
+
);
|
|
2654
|
+
} finally {
|
|
2655
|
+
pendingRouteReloads.delete(files);
|
|
2656
|
+
}
|
|
2649
2657
|
}, 50);
|
|
2650
2658
|
}
|
|
2659
|
+
queuedRouteFiles.add(normalizedFile);
|
|
2651
2660
|
}
|
|
2652
2661
|
});
|
|
2653
2662
|
});
|
|
@@ -4274,7 +4283,12 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
|
|
|
4274
4283
|
layouts.map((layout) => routeManager3.loadLayoutModule(layout.modulePath))
|
|
4275
4284
|
);
|
|
4276
4285
|
const layoutHydrationMetadata = layouts.map(
|
|
4277
|
-
(layout) => navigationManifest.layouts.find(
|
|
4286
|
+
(layout) => navigationManifest.layouts.find(
|
|
4287
|
+
(entry) => entry.pattern === layout.pattern
|
|
4288
|
+
) ?? {
|
|
4289
|
+
...getClientModuleMetadata(layout.modulePath, server.config.root),
|
|
4290
|
+
serverTree: false
|
|
4291
|
+
}
|
|
4278
4292
|
);
|
|
4279
4293
|
const shouldHydrateLayout = layoutHydrationMetadata.some(
|
|
4280
4294
|
(metadata) => metadata.shouldHydrate
|
|
@@ -4422,7 +4436,8 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
|
|
|
4422
4436
|
params,
|
|
4423
4437
|
layouts: layouts.map((layout, index) => ({
|
|
4424
4438
|
pattern: layout.pattern,
|
|
4425
|
-
module: layoutModules[index]
|
|
4439
|
+
module: layoutModules[index],
|
|
4440
|
+
serverTree: layoutHydrationMetadata[index]?.serverTree
|
|
4426
4441
|
})),
|
|
4427
4442
|
layoutStartIndex,
|
|
4428
4443
|
slots: routeSlots.map((slot) => ({
|
|
@@ -5262,6 +5277,12 @@ if (import.meta.hot) {
|
|
|
5262
5277
|
}
|
|
5263
5278
|
const currentFarmConfig = farmApp?.getConfig();
|
|
5264
5279
|
const normalizedFile = file.replace(/\\/g, "/");
|
|
5280
|
+
const reloadAfterEdit = () => {
|
|
5281
|
+
for (const files of pendingRouteReloads) {
|
|
5282
|
+
if (files.has(normalizedFile)) return;
|
|
5283
|
+
}
|
|
5284
|
+
server2.ws.send({ type: "full-reload", path: "*" });
|
|
5285
|
+
};
|
|
5265
5286
|
if (normalizedFile.includes(FARM_CLIENT_REFERENCE_DIRECTORY) && normalizedFile.startsWith(
|
|
5266
5287
|
path6.posix.join(
|
|
5267
5288
|
toPosixPath(currentFarmConfig?.root || options.root || server2.config.root),
|
|
@@ -5274,7 +5295,7 @@ if (import.meta.hot) {
|
|
|
5274
5295
|
)) {
|
|
5275
5296
|
for (const mod of modules) server2.moduleGraph.invalidateModule(mod);
|
|
5276
5297
|
await refreshRouteDiscovery?.(`updated ${file}`);
|
|
5277
|
-
|
|
5298
|
+
reloadAfterEdit();
|
|
5278
5299
|
return [];
|
|
5279
5300
|
}
|
|
5280
5301
|
const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path6.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
|
|
@@ -5284,10 +5305,7 @@ if (import.meta.hot) {
|
|
|
5284
5305
|
server2.moduleGraph.invalidateModule(mod);
|
|
5285
5306
|
}
|
|
5286
5307
|
await refreshRouteDiscovery?.(`updated ${file}`);
|
|
5287
|
-
|
|
5288
|
-
type: "full-reload",
|
|
5289
|
-
path: "*"
|
|
5290
|
-
});
|
|
5308
|
+
reloadAfterEdit();
|
|
5291
5309
|
return [];
|
|
5292
5310
|
}
|
|
5293
5311
|
if (currentSrcRoot && isPotentialProgrammaticRouteSourceFile(normalizedFile, currentSrcRoot) && fileContainsProgrammaticPageRoute(file)) {
|
|
@@ -5297,10 +5315,7 @@ if (import.meta.hot) {
|
|
|
5297
5315
|
server2.moduleGraph.invalidateModule(mod);
|
|
5298
5316
|
}
|
|
5299
5317
|
await refreshRouteDiscovery?.(`updated ${file}`);
|
|
5300
|
-
|
|
5301
|
-
type: "full-reload",
|
|
5302
|
-
path: "*"
|
|
5303
|
-
});
|
|
5318
|
+
reloadAfterEdit();
|
|
5304
5319
|
return [];
|
|
5305
5320
|
}
|
|
5306
5321
|
if (apiRouteManager && invalidateFarmDevDependents(server2, file, apiRouteManager.getSourceFiles()).length > 0) {
|
|
@@ -5345,7 +5360,7 @@ if (import.meta.hot) {
|
|
|
5345
5360
|
const clientModule = server2.moduleGraph.getModuleById(clientId);
|
|
5346
5361
|
if (clientModule) server2.moduleGraph.invalidateModule(clientModule);
|
|
5347
5362
|
}
|
|
5348
|
-
|
|
5363
|
+
reloadAfterEdit();
|
|
5349
5364
|
return [];
|
|
5350
5365
|
}
|
|
5351
5366
|
clientPlanCurrent = true;
|
|
@@ -5385,16 +5400,13 @@ if (import.meta.hot) {
|
|
|
5385
5400
|
for (const mod of modules) {
|
|
5386
5401
|
server2.moduleGraph.invalidateModule(mod);
|
|
5387
5402
|
}
|
|
5388
|
-
|
|
5389
|
-
type: "full-reload",
|
|
5390
|
-
path: "*"
|
|
5391
|
-
});
|
|
5403
|
+
reloadAfterEdit();
|
|
5392
5404
|
return [];
|
|
5393
5405
|
}
|
|
5394
5406
|
}
|
|
5395
5407
|
if (/\.[cm]?[jt]sx?$/.test(normalizedFile) && !server2.environments.client?.moduleGraph.getModulesByFile(normalizedFile)?.size && invalidateFarmDevDependents(server2, file, getFarmRenderedServerModules()).length > 0) {
|
|
5396
5408
|
logUpdate("PAGE", `updated ${path6.basename(file)}`);
|
|
5397
|
-
|
|
5409
|
+
reloadAfterEdit();
|
|
5398
5410
|
return [];
|
|
5399
5411
|
}
|
|
5400
5412
|
return modules;
|
|
@@ -76,7 +76,7 @@ var _chunkQUEYL2WMcjs = require('./chunk-QUEYL2WM.cjs');
|
|
|
76
76
|
var _chunkWT6RAN2Icjs = require('./chunk-WT6RAN2I.cjs');
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var
|
|
79
|
+
var _chunkOWO7KDZ3cjs = require('./chunk-OWO7KDZ3.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
var _chunk5DX3O6TTcjs = require('./chunk-5DX3O6TT.cjs');
|
|
@@ -1123,7 +1123,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
1123
1123
|
userConfig.deploymentId || process.env.FARM_DEPLOYMENT_ID || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CF_PAGES_COMMIT_SHA || (mode === "production" ? await generateBuildId() : "development")
|
|
1124
1124
|
);
|
|
1125
1125
|
const basePath = _chunkD22BUQKWcjs.normalizeFarmConfigBasePath.call(void 0, userConfig.basePath);
|
|
1126
|
-
const mobileSessionPlugin = userConfig.mobile !== void 0 && userConfig.mobile !== null ? (await import("./session-
|
|
1126
|
+
const mobileSessionPlugin = userConfig.mobile !== void 0 && userConfig.mobile !== null ? (await import("./session-ACVUJ5XV.cjs")).createFarmMobileSessionPlugin({
|
|
1127
1127
|
basePath,
|
|
1128
1128
|
integrations: () => integrations
|
|
1129
1129
|
}) : null;
|
|
@@ -1190,7 +1190,7 @@ async function resolveConfig(userConfig, mode) {
|
|
|
1190
1190
|
plugins: [
|
|
1191
1191
|
...mobileSessionPlugin ? [mobileSessionPlugin] : [],
|
|
1192
1192
|
...nativeServerFnPlugin ? [nativeServerFnPlugin] : [],
|
|
1193
|
-
...
|
|
1193
|
+
..._chunkOWO7KDZ3cjs.resolveIntegrationPlugins.call(void 0, integrations),
|
|
1194
1194
|
...nativeMCPPlugin ? [nativeMCPPlugin] : [],
|
|
1195
1195
|
...userConfig.plugins || []
|
|
1196
1196
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWILPJVQEcjs = require('./chunk-WILPJVQE.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -329,7 +329,7 @@ function requestEvent(metadata, method, status, durationMs) {
|
|
|
329
329
|
id: uuid(),
|
|
330
330
|
requestId: metadata.id,
|
|
331
331
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
332
|
-
route: routeTemplate(
|
|
332
|
+
route: routeTemplate(_chunkWILPJVQEcjs.getFarmRouteLabel.call(void 0, metadata.route)),
|
|
333
333
|
...metadata.path ? { path: metadata.path } : {},
|
|
334
334
|
agent: metadata.agent,
|
|
335
335
|
kind: "request",
|
|
@@ -343,7 +343,7 @@ function toolEvent(metadata, event) {
|
|
|
343
343
|
id: uuid(),
|
|
344
344
|
requestId: metadata.id,
|
|
345
345
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
346
|
-
route: routeTemplate(
|
|
346
|
+
route: routeTemplate(_chunkWILPJVQEcjs.getFarmRouteLabel.call(void 0, metadata.route)),
|
|
347
347
|
...metadata.path ? { path: metadata.path } : {},
|
|
348
348
|
agent: metadata.agent,
|
|
349
349
|
kind: "mcp.tool",
|
|
@@ -1,3 +1,172 @@
|
|
|
1
|
+
// src/storage/managed-sqlite.ts
|
|
2
|
+
function managedSqliteName(mount, managed) {
|
|
3
|
+
const name = managed === true ? mount : managed && typeof managed === "object" && "name" in managed ? managed.name : void 0;
|
|
4
|
+
if (typeof name !== "string" || !/^[a-z][a-z0-9-]{0,62}$/.test(name))
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
"Use a managed SQLite name of 1\u201363 lowercase letters, digits, or hyphens starting with a letter."
|
|
7
|
+
);
|
|
8
|
+
return name;
|
|
9
|
+
}
|
|
10
|
+
function secureUrl(value) {
|
|
11
|
+
const url = new URL(value);
|
|
12
|
+
const local = url.hostname === "localhost" || url.hostname.endsWith(".localhost") || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
|
|
13
|
+
if (!(url.protocol === "https:" || local && url.protocol === "http:") || url.username || url.password || url.search || url.hash)
|
|
14
|
+
throw new Error("Use HTTPS or a loopback URL for Farm managed SQLite.");
|
|
15
|
+
return url;
|
|
16
|
+
}
|
|
17
|
+
async function requestSqliteResource(name, operation) {
|
|
18
|
+
const key = process.env.FARMJS_API_KEY;
|
|
19
|
+
if (!key) throw new Error("Set FARMJS_API_KEY on the server to access managed SQLite.");
|
|
20
|
+
const base = secureUrl(process.env.FARMJS_API_URL || "https://app.farmjs.dev");
|
|
21
|
+
const headers = new Headers({
|
|
22
|
+
authorization: "Bearer " + key,
|
|
23
|
+
"content-type": "application/json"
|
|
24
|
+
});
|
|
25
|
+
if (process.env.FARMJS_PROJECT_ID) headers.set("x-farm-project", process.env.FARMJS_PROJECT_ID);
|
|
26
|
+
const environment = process.env.FARMJS_ENVIRONMENT;
|
|
27
|
+
if (environment)
|
|
28
|
+
headers.set("x-farm-environment", environment === "preview" ? "staging" : environment);
|
|
29
|
+
const response = await fetch(new URL("/api/storage/sqlite/" + operation, base), {
|
|
30
|
+
method: operation === "token" ? "POST" : "PUT",
|
|
31
|
+
headers,
|
|
32
|
+
body: JSON.stringify({ name }),
|
|
33
|
+
redirect: "error",
|
|
34
|
+
signal: AbortSignal.timeout(15e3)
|
|
35
|
+
});
|
|
36
|
+
const result = await response.json();
|
|
37
|
+
if (!response.ok)
|
|
38
|
+
throw new Error(
|
|
39
|
+
typeof result?.message === "string" ? result.message : "Farm SQLite request failed (HTTP " + response.status + ")."
|
|
40
|
+
);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
async function credential(name) {
|
|
44
|
+
const result = await requestSqliteResource(name, "token");
|
|
45
|
+
if (!result || typeof result.url !== "string" || typeof result.token !== "string" || !result.token || !Number.isFinite(Date.parse(result.expiresAt)) || Date.parse(result.expiresAt) <= Date.now())
|
|
46
|
+
throw new Error("Farm returned an invalid SQLite credential. Check the Infra service.");
|
|
47
|
+
return {
|
|
48
|
+
url: secureUrl(result.url).href,
|
|
49
|
+
token: result.token,
|
|
50
|
+
expires: Date.parse(result.expiresAt)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function connect(name, loadClient) {
|
|
54
|
+
const [{ createClient }, initial] = await Promise.all([loadClient(), credential(name)]);
|
|
55
|
+
let current = initial;
|
|
56
|
+
let refreshing;
|
|
57
|
+
return createClient({
|
|
58
|
+
url: current.url,
|
|
59
|
+
fetch: async (request) => {
|
|
60
|
+
if (new URL(request.url).origin !== new URL(initial.url).origin)
|
|
61
|
+
throw new Error("The database endpoint changed. Reconnect the managed SQLite mount.");
|
|
62
|
+
if (current.expires - Date.now() < 3e4) {
|
|
63
|
+
refreshing ?? (refreshing = credential(name).finally(() => {
|
|
64
|
+
refreshing = void 0;
|
|
65
|
+
}));
|
|
66
|
+
const renewed = await refreshing;
|
|
67
|
+
if (renewed.url !== initial.url)
|
|
68
|
+
throw new Error("The SQLite resource changed. Reconnect the mount.");
|
|
69
|
+
current = renewed;
|
|
70
|
+
}
|
|
71
|
+
const headers = new Headers(request.headers);
|
|
72
|
+
headers.set("authorization", "Bearer " + current.token);
|
|
73
|
+
return fetch(request, { headers, redirect: "error" });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
var databaseAccessor = /* @__PURE__ */ Symbol.for("farmjs.storage.managedDatabase");
|
|
78
|
+
function managedSqliteDriver(name, loadClient) {
|
|
79
|
+
let pending;
|
|
80
|
+
let initialized;
|
|
81
|
+
let closed = false;
|
|
82
|
+
function client() {
|
|
83
|
+
if (closed) throw new Error("The managed SQLite mount has been disposed.");
|
|
84
|
+
return pending ?? (pending = connect(name, loadClient).catch((error) => {
|
|
85
|
+
pending = void 0;
|
|
86
|
+
throw error;
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
function kv() {
|
|
90
|
+
return initialized ?? (initialized = client().then(async (db) => {
|
|
91
|
+
await db.execute(
|
|
92
|
+
"CREATE TABLE IF NOT EXISTS _farm_kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)"
|
|
93
|
+
);
|
|
94
|
+
return db;
|
|
95
|
+
}).catch((error) => {
|
|
96
|
+
initialized = void 0;
|
|
97
|
+
throw error;
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
name: "farm-managed-sqlite",
|
|
102
|
+
[databaseAccessor]: client,
|
|
103
|
+
async hasItem(key) {
|
|
104
|
+
return (await (await kv()).execute({ sql: "SELECT 1 FROM _farm_kv WHERE key=?", args: [key] })).rows.length > 0;
|
|
105
|
+
},
|
|
106
|
+
async getItem(key) {
|
|
107
|
+
const { rows } = await (await kv()).execute({ sql: "SELECT value FROM _farm_kv WHERE key=?", args: [key] });
|
|
108
|
+
return rows[0]?.value ?? null;
|
|
109
|
+
},
|
|
110
|
+
async getKeys(base = "") {
|
|
111
|
+
const { rows } = await (await kv()).execute({
|
|
112
|
+
sql: "SELECT key FROM _farm_kv WHERE instr(key,?)=1 ORDER BY key",
|
|
113
|
+
args: [base]
|
|
114
|
+
});
|
|
115
|
+
return rows.map((row) => String(row.key));
|
|
116
|
+
},
|
|
117
|
+
async setItem(key, value) {
|
|
118
|
+
await (await kv()).execute({
|
|
119
|
+
sql: "INSERT INTO _farm_kv(key,value) VALUES (?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
|
120
|
+
args: [key, value]
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
async removeItem(key) {
|
|
124
|
+
await (await kv()).execute({ sql: "DELETE FROM _farm_kv WHERE key=?", args: [key] });
|
|
125
|
+
},
|
|
126
|
+
async clear(base = "") {
|
|
127
|
+
await (await kv()).execute({ sql: "DELETE FROM _farm_kv WHERE instr(key,?)=1", args: [base] });
|
|
128
|
+
},
|
|
129
|
+
async dispose() {
|
|
130
|
+
closed = true;
|
|
131
|
+
(await pending)?.close();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function sqlAdapter(client, tx) {
|
|
136
|
+
return {
|
|
137
|
+
dialect: "sqlite",
|
|
138
|
+
async query(sql, params) {
|
|
139
|
+
const result = await (tx ?? client).execute({ sql, args: params });
|
|
140
|
+
return {
|
|
141
|
+
rows: result.rows,
|
|
142
|
+
affectedRows: result.rowsAffected,
|
|
143
|
+
insertId: result.lastInsertRowid
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
async transaction(run) {
|
|
147
|
+
if (tx) throw new Error("Nested managed SQLite transactions are unsupported.");
|
|
148
|
+
const transaction = await client.transaction("write");
|
|
149
|
+
try {
|
|
150
|
+
const value = await run(sqlAdapter(client, transaction));
|
|
151
|
+
await transaction.commit();
|
|
152
|
+
return value;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (!transaction.closed) await transaction.rollback();
|
|
155
|
+
throw error;
|
|
156
|
+
} finally {
|
|
157
|
+
transaction.close();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async function managedOrm(client, schema) {
|
|
163
|
+
const [{ createOrm }, { createSqlDriverFromAdapter }] = await Promise.all([
|
|
164
|
+
import("@farming-labs/orm"),
|
|
165
|
+
import("@farming-labs/orm-sql")
|
|
166
|
+
]);
|
|
167
|
+
return createOrm({ schema, driver: createSqlDriverFromAdapter(sqlAdapter(client)) });
|
|
168
|
+
}
|
|
169
|
+
|
|
1
170
|
// src/storage/index.ts
|
|
2
171
|
import { createStorage, prefixStorage, builtinDrivers } from "unstorage";
|
|
3
172
|
import memoryDriver from "unstorage/drivers/memory";
|
|
@@ -159,10 +328,17 @@ async function loadDatabaseDriver(config) {
|
|
|
159
328
|
}
|
|
160
329
|
};
|
|
161
330
|
}
|
|
162
|
-
async function resolveDriver(config) {
|
|
331
|
+
async function resolveDriver(config, mount) {
|
|
163
332
|
if (config && isStorageClient(config)) {
|
|
164
333
|
return config.resolveDriver();
|
|
165
334
|
}
|
|
335
|
+
if (config?.driver === "farm-managed-sqlite") {
|
|
336
|
+
if (!mount) throw new TypeError("Register managed SQLite in storage.mounts.");
|
|
337
|
+
return managedSqliteDriver(
|
|
338
|
+
managedSqliteName(mount, config.managed),
|
|
339
|
+
() => loadModule("@libsql/client/http")
|
|
340
|
+
);
|
|
341
|
+
}
|
|
166
342
|
const driverInput = config?.driver ?? "memory";
|
|
167
343
|
if (typeof driverInput === "function") {
|
|
168
344
|
return await driverInput();
|
|
@@ -274,6 +450,12 @@ function localStorage(options = {}) {
|
|
|
274
450
|
});
|
|
275
451
|
}
|
|
276
452
|
function sqliteStorage(options) {
|
|
453
|
+
if ("managed" in options) {
|
|
454
|
+
if (Object.keys(options).some((key) => key !== "managed"))
|
|
455
|
+
throw new TypeError("Supply only managed when Farm provisions SQLite.");
|
|
456
|
+
if (options.managed !== true) managedSqliteName("", options.managed);
|
|
457
|
+
return { driver: "farm-managed-sqlite", managed: options.managed };
|
|
458
|
+
}
|
|
277
459
|
return createStorageClient({
|
|
278
460
|
driver: "sqlite",
|
|
279
461
|
...options
|
|
@@ -368,7 +550,9 @@ function collectDriverModules(config, modules) {
|
|
|
368
550
|
const source = config;
|
|
369
551
|
const driver = source.driver;
|
|
370
552
|
if (typeof driver === "string") {
|
|
371
|
-
if (
|
|
553
|
+
if (driver === "farm-managed-sqlite") {
|
|
554
|
+
modules.add("@libsql/client/http");
|
|
555
|
+
} else if (isDatabaseDriverName(driver)) {
|
|
372
556
|
modules.add("db0");
|
|
373
557
|
modules.add(DATABASE_CONNECTORS[driver].module);
|
|
374
558
|
modules.add("unstorage/drivers/db0");
|
|
@@ -392,7 +576,7 @@ async function mountNamespaces(storage, mounts) {
|
|
|
392
576
|
return;
|
|
393
577
|
}
|
|
394
578
|
for (const [base, config] of Object.entries(mounts)) {
|
|
395
|
-
storage.mount(normalizeMountKey(base), await resolveDriver(config));
|
|
579
|
+
storage.mount(normalizeMountKey(base), await resolveDriver(config, base));
|
|
396
580
|
}
|
|
397
581
|
}
|
|
398
582
|
async function createFarmStorage(config = {}) {
|
|
@@ -436,6 +620,17 @@ async function initStorage(config = {}) {
|
|
|
436
620
|
}
|
|
437
621
|
return globalStorage;
|
|
438
622
|
}
|
|
623
|
+
async function getDatabase(name, options) {
|
|
624
|
+
const key = normalizeMountKey(name);
|
|
625
|
+
const mount = getActiveGlobalStorage().getMount(key);
|
|
626
|
+
const driver = mount.driver;
|
|
627
|
+
if (!key || normalizeMountKey(mount.base) !== key || !driver[databaseAccessor])
|
|
628
|
+
throw new TypeError(
|
|
629
|
+
"Configure a managed SQLite mount named " + JSON.stringify(name) + " before calling getDatabase()."
|
|
630
|
+
);
|
|
631
|
+
const client = await driver[databaseAccessor]();
|
|
632
|
+
return options ? managedOrm(client, options.schema) : client;
|
|
633
|
+
}
|
|
439
634
|
function getStorage(namespace) {
|
|
440
635
|
globalStorage = getActiveGlobalStorage();
|
|
441
636
|
const base = normalizeMountKey(namespace);
|
|
@@ -500,6 +695,8 @@ async function disposeStorage() {
|
|
|
500
695
|
}
|
|
501
696
|
|
|
502
697
|
export {
|
|
698
|
+
managedSqliteName,
|
|
699
|
+
requestSqliteResource,
|
|
503
700
|
_registerFarmStorageModules,
|
|
504
701
|
defineStorageClient,
|
|
505
702
|
createStorageClient,
|
|
@@ -526,6 +723,7 @@ export {
|
|
|
526
723
|
createFarmStorage,
|
|
527
724
|
resolveStorageRuntimeClient,
|
|
528
725
|
initStorage,
|
|
726
|
+
getDatabase,
|
|
529
727
|
getStorage,
|
|
530
728
|
disposeStorage
|
|
531
729
|
};
|