@farm.js/core 0.1.51-beta.1 → 0.1.51-beta.3
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-handler-WWCC4GLG.mjs → agent-mcp-handler-7JSKGSOW.mjs} +4 -4
- package/dist/{agent-mcp-handler-RT3COCEL.cjs → agent-mcp-handler-YE4AGWHN.cjs} +5 -5
- package/dist/{agent-mcp.d-ZuuNgrkQ.d.ts → agent-mcp.d-BAR9njbJ.d.ts} +1 -1
- package/dist/{agent-mcp.d-BPzpKBHQ.d.mts → agent-mcp.d-BJKChOrO.d.mts} +1 -1
- package/dist/agent-runtime.d.mts +2 -2
- package/dist/agent-runtime.d.ts +2 -2
- package/dist/{analyzer-V74FTD2F.mjs → analyzer-OTPEWH5W.mjs} +82 -22
- package/dist/{analyzer-AZULAOPL.cjs → analyzer-TSQXZCZN.cjs} +82 -22
- package/dist/api/route-manager.d.mts +4 -4
- package/dist/api/route-manager.d.ts +4 -4
- package/dist/api/runtime.d.mts +3 -3
- package/dist/api/runtime.d.ts +3 -3
- package/dist/api.d.mts +4 -4
- package/dist/api.d.ts +4 -4
- package/dist/{app-manifest.d-HWhqbP2X.d.ts → app-manifest.d-BLFbaqx8.d.ts} +1 -1
- package/dist/{app-manifest.d-BJDcZn3W.d.mts → app-manifest.d-DEQNnNhV.d.mts} +1 -1
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +3 -3
- package/dist/{app.d-B5EWdob-.d.ts → app.d-CNPaUYaa.d.ts} +4 -4
- package/dist/{app.d-DOGW1KI8.d.mts → app.d-CT7xDkj2.d.mts} +4 -4
- package/dist/{chunk-YVJV7Q2X.mjs → chunk-3BLEXUGE.mjs} +1 -1
- package/dist/chunk-3HLQTOVU.cjs +6 -0
- package/dist/{chunk-KU7MBLDZ.mjs → chunk-3SMXQNFD.mjs} +2 -2
- package/dist/{chunk-EWC76P5D.mjs → chunk-3TLKUBXG.mjs} +411 -166
- package/dist/{chunk-BSEKNTMS.mjs → chunk-3WSIYBMG.mjs} +41 -19
- package/dist/{chunk-JVBNKWLV.cjs → chunk-3XQ57EFI.cjs} +16 -16
- package/dist/{chunk-GW4YUIHW.mjs → chunk-3Z63X45F.mjs} +1 -1
- package/dist/{chunk-SCRC5AMM.mjs → chunk-4353ZRE5.mjs} +1 -1
- package/dist/{chunk-SBABQKPT.cjs → chunk-46KXZBOG.cjs} +5 -5
- package/dist/{chunk-2756SHCI.cjs → chunk-4CGOMZP3.cjs} +221 -199
- package/dist/{chunk-RMPNYUGT.cjs → chunk-4SEHMBL4.cjs} +10 -10
- package/dist/{chunk-QAIAFCRZ.mjs → chunk-4TKAIO2F.mjs} +3 -3
- package/dist/{chunk-NJLTQR5P.cjs → chunk-53SACYBY.cjs} +7 -7
- package/dist/{chunk-I3EFXUAR.mjs → chunk-5FXPJIOT.mjs} +2 -2
- package/dist/chunk-7FVVQEVL.cjs +541 -0
- package/dist/{chunk-IFBINMI4.cjs → chunk-7MD37P5V.cjs} +5 -5
- package/dist/{chunk-JATTVAHA.cjs → chunk-B3GM5I6N.cjs} +4 -4
- package/dist/chunk-C3BOESDW.mjs +541 -0
- package/dist/{chunk-WJFFPXCV.cjs → chunk-D7UQC4O6.cjs} +10 -8
- package/dist/{chunk-KRRZJ77U.mjs → chunk-E5DXF5GE.mjs} +2 -2
- package/dist/chunk-EFZGB7JC.cjs +114 -0
- package/dist/{chunk-NYQSC4DX.cjs → chunk-FFE2EMF7.cjs} +5 -5
- package/dist/{chunk-KMB5BMFX.mjs → chunk-GAO7MS5O.mjs} +9 -3
- package/dist/{chunk-HIFIG6HL.cjs → chunk-H33PJEXN.cjs} +5 -5
- package/dist/{chunk-TT66CP3P.cjs → chunk-HLWOWZFX.cjs} +2 -2
- package/dist/chunk-JXEPLIXD.cjs +389 -0
- package/dist/{chunk-VITZRYW3.cjs → chunk-KLNFJDFM.cjs} +15 -9
- package/dist/{chunk-KBRZAYI7.mjs → chunk-LDNSSHEG.mjs} +2 -2
- package/dist/chunk-LLZSYFOM.mjs +6 -0
- package/dist/{chunk-N77JBPLC.mjs → chunk-LPDKG6RA.mjs} +9 -7
- package/dist/chunk-MIGFX2FN.mjs +758 -0
- package/dist/{chunk-72D2NX77.mjs → chunk-MRNDAJEV.mjs} +1 -1
- package/dist/{chunk-5A5GAZ75.mjs → chunk-NOTSHVRN.mjs} +406 -234
- package/dist/{chunk-AGR7VJH2.cjs → chunk-OAMUSC7H.cjs} +1 -1
- package/dist/chunk-P6MHI5O2.cjs +758 -0
- package/dist/{chunk-EOSFVNXZ.mjs → chunk-R4PHCZ3G.mjs} +1 -1
- package/dist/{chunk-X2M4XN4V.cjs → chunk-TQMI6BYO.cjs} +675 -430
- package/dist/{chunk-76GHW3WI.cjs → chunk-TSFMFPRU.cjs} +4 -4
- package/dist/{chunk-5N7QAGEA.cjs → chunk-TWHXBMLJ.cjs} +37 -7
- package/dist/{chunk-BOVGCUDZ.cjs → chunk-UJL4JOXV.cjs} +2 -2
- package/dist/chunk-UQF3OJVE.mjs +389 -0
- package/dist/{chunk-XY4DYGSU.cjs → chunk-WGUHDWT5.cjs} +607 -435
- package/dist/{chunk-LAZK6UV7.mjs → chunk-YAJTD3ZG.mjs} +1 -1
- package/dist/{chunk-7UPCJDB5.mjs → chunk-YUEYBL35.mjs} +2 -2
- package/dist/{chunk-EIMK7D2D.mjs → chunk-ZD2VKAUI.mjs} +34 -4
- package/dist/chunk-ZNXTU4YH.mjs +114 -0
- package/dist/{client-plugins.d-C_3CdALC.d.mts → client-plugins.d-DllmH8eM.d.mts} +31 -5
- package/dist/{client-plugins.d-C0n8Yhh-.d.ts → client-plugins.d-n3iWY1EJ.d.ts} +31 -5
- package/dist/client-plugins.d.mts +2 -2
- package/dist/client-plugins.d.ts +2 -2
- package/dist/client.d.mts +7 -7
- package/dist/client.d.ts +7 -7
- package/dist/{config.d-CnhyvvmT.d.ts → config.d-DqKaCr1r.d.mts} +14 -3
- package/dist/{config.d-CnhyvvmT.d.mts → config.d-DqKaCr1r.d.ts} +14 -3
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/desktop.d.mts +3 -3
- package/dist/desktop.d.ts +3 -3
- package/dist/{devtools-KJFUE5FO.cjs → devtools-TO6TAO32.cjs} +5 -5
- package/dist/{devtools-BU5IT2PD.mjs → devtools-UESYARTF.mjs} +4 -4
- package/dist/docs.cjs +7 -7
- package/dist/docs.d.mts +3 -3
- package/dist/docs.d.ts +3 -3
- package/dist/docs.mjs +6 -6
- package/dist/index.cjs +23 -18
- package/dist/{index.d-CsGxS-hZ.d.mts → index.d-BL7KKiwa.d.mts} +1 -1
- package/dist/{index.d-B6M_8kmo.d.ts → index.d-BXsAXm1U.d.ts} +1 -1
- package/dist/index.d.mts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.mjs +23 -18
- package/dist/integrations.d.mts +2 -2
- package/dist/integrations.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +3 -3
- package/dist/internal/app-markdown-runtime.d.ts +3 -3
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +21 -18
- package/dist/internal/build-runtime.d.mts +4 -4
- package/dist/internal/build-runtime.d.ts +4 -4
- package/dist/internal/build-runtime.mjs +20 -17
- package/dist/internal/cli-runtime.cjs +7 -7
- package/dist/internal/cli-runtime.mjs +6 -6
- 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 +5 -5
- package/dist/internal/client-runtime.d.ts +5 -5
- package/dist/internal/compression-runtime.d.mts +2 -2
- package/dist/internal/compression-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.cjs +6 -6
- package/dist/internal/config-runtime.d.mts +41 -80
- package/dist/internal/config-runtime.d.ts +41 -80
- package/dist/internal/config-runtime.mjs +5 -5
- package/dist/internal/infra-analytics-runtime.cjs +8 -8
- package/dist/internal/infra-analytics-runtime.mjs +6 -6
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +91 -9
- package/dist/internal/production-runtime.d.mts +67 -12
- package/dist/internal/production-runtime.d.ts +67 -12
- package/dist/internal/production-runtime.mjs +90 -8
- package/dist/markdown.cjs +4 -2
- package/dist/markdown.d.mts +2 -2
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.mjs +3 -1
- package/dist/middleware.d.mts +4 -4
- package/dist/middleware.d.ts +4 -4
- package/dist/mobile.d.mts +21 -5
- package/dist/mobile.d.ts +21 -5
- package/dist/native-tree-EBPDFTRW.mjs +25 -0
- package/dist/native-tree-MMZS7S6W.cjs +25 -0
- package/dist/{navigation-delegate.d-C0BbdUgN.d.mts → navigation-delegate.d-C76gXTmO.d.mts} +1 -1
- package/dist/{navigation-delegate.d-jArRF0ZP.d.ts → navigation-delegate.d-DIyDslxt.d.ts} +1 -1
- package/dist/navigation.d.mts +5 -5
- package/dist/navigation.d.ts +5 -5
- package/dist/plugin.cjs +14 -13
- package/dist/plugin.d.mts +5 -4
- package/dist/plugin.d.ts +5 -4
- package/dist/plugin.mjs +13 -12
- package/dist/{production-runtime.d-DFaQ1qaV.d.mts → production-runtime.d-CDHztggO.d.mts} +1 -1
- package/dist/{production-runtime.d-UnXmSS_S.d.ts → production-runtime.d-tyaGdbk6.d.ts} +1 -1
- package/dist/{programmatic-routes-client.d-VZ0qcbH4.d.ts → programmatic-routes-client.d-XfmIrCK1.d.ts} +2 -2
- package/dist/{programmatic-routes-client.d-BIowUXQC.d.mts → programmatic-routes-client.d-aAWiDd64.d.mts} +2 -2
- package/dist/{render-plan.d-BNeqyPyJ.d.mts → render-plan.d-Diwybxo8.d.mts} +1 -1
- package/dist/{render-plan.d-BB6KrYjP.d.ts → render-plan.d-Dr5WRjoV.d.ts} +1 -1
- package/dist/renderer-client.d.mts +5 -5
- package/dist/renderer-client.d.ts +5 -5
- package/dist/{request.d-Bxhghm76.d.ts → request.d-D01fRn--.d.ts} +1 -1
- package/dist/{request.d-BV1munmx.d.mts → request.d-Dd3AFR79.d.mts} +1 -1
- package/dist/request.d.mts +3 -3
- package/dist/request.d.ts +3 -3
- package/dist/{route-rendering.d-DShqKlgK.d.mts → route-rendering.d-BQ53lJ_D.d.mts} +1 -1
- package/dist/{route-rendering.d-BIf7zE9d.d.ts → route-rendering.d-Bhx4QoJt.d.ts} +1 -1
- package/dist/{router.d-BE7i84fb.d.mts → router.d-Bi23a6Xc.d.mts} +1 -1
- package/dist/{router.d-Bw3K3b0a.d.ts → router.d-DQ3k7EYn.d.ts} +1 -1
- package/dist/{routes.d-_5tBQexL.d.mts → routes.d-BgTd7vI4.d.mts} +91 -4
- package/dist/{routes.d-DVZQL0-H.d.ts → routes.d-C7jMJFvP.d.ts} +91 -4
- package/dist/routes.d.mts +2 -2
- package/dist/routes.d.ts +2 -2
- package/dist/{rsc-pipeline-FBM6NFYY.mjs → rsc-pipeline-K3ER3Q4N.mjs} +5 -5
- package/dist/{rsc-pipeline-IQI5XQLS.cjs → rsc-pipeline-OCZIT5OF.cjs} +6 -6
- package/dist/{runtime-DXEVFYLE.cjs → runtime-DKNSIH7V.cjs} +85 -29
- package/dist/{runtime-2JYIDUON.mjs → runtime-MKYDEUZT.mjs} +75 -19
- package/dist/{runtime.d-CQgoYR0Q.d.mts → runtime.d-B2Js6qZ2.d.mts} +1 -1
- package/dist/{runtime.d-CfhaLPl-.d.ts → runtime.d-BL-CGwoi.d.ts} +1 -1
- package/dist/server-plugins.d.mts +3 -3
- package/dist/server-plugins.d.ts +3 -3
- package/dist/server.cjs +31 -30
- package/dist/server.d.mts +11 -10
- package/dist/server.d.ts +11 -10
- package/dist/server.mjs +16 -15
- package/dist/session-AAU7RNRO.cjs +23 -0
- package/dist/session-IGEDQ5PY.mjs +23 -0
- package/dist/{spa-router.d-D63jb6nX.d.mts → spa-router.d-B2rIFGs0.d.mts} +2 -2
- package/dist/{spa-router.d-C5opIgXg.d.ts → spa-router.d-DqZ6Lfs0.d.ts} +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/{utils.d-CkpTqTsC.d.ts → utils.d-Bv2MPeLR.d.ts} +1 -1
- package/dist/{utils.d-CO-U4OVZ.d.mts → utils.d-fqXe8lNc.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +14 -13
- package/dist/vite.d.mts +12 -6
- package/dist/vite.d.ts +12 -6
- package/dist/vite.mjs +13 -12
- package/package.json +3 -3
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }// src/nitro/mobile-client.ts
|
|
2
|
+
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
|
|
3
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
4
|
+
var FARM_MOBILE_CLIENT_ENTRY_NAME = "farm-mobile-client";
|
|
5
|
+
var FARM_MOBILE_CLIENT_MANIFEST_FILE = "mobile-client.json";
|
|
6
|
+
var HASHED_FILE = /-h[0-9a-f]{8,}\.[A-Za-z0-9]+$/;
|
|
7
|
+
function isFarmContentHashedFile(file) {
|
|
8
|
+
return HASHED_FILE.test(file);
|
|
9
|
+
}
|
|
10
|
+
function manifestPath(buildDir) {
|
|
11
|
+
return _path2.default.join(buildDir, FARM_MOBILE_CLIENT_MANIFEST_FILE);
|
|
12
|
+
}
|
|
13
|
+
async function removeFarmMobileClientManifest(buildDir) {
|
|
14
|
+
await _promises2.default.rm(manifestPath(buildDir), { force: true });
|
|
15
|
+
}
|
|
16
|
+
function createFarmMobileClientManifestPlugin(options) {
|
|
17
|
+
return {
|
|
18
|
+
name: "farm-mobile-client-manifest",
|
|
19
|
+
enforce: "post",
|
|
20
|
+
async generateBundle(_output, bundle) {
|
|
21
|
+
const entry = _optionalChain([Object, 'access', _ => _.entries, 'call', _2 => _2(bundle), 'access', _3 => _3.find, 'call', _4 => _4(
|
|
22
|
+
([, output]) => output.type === "chunk" && output.isEntry && output.name === options.entryName
|
|
23
|
+
), 'optionalAccess', _5 => _5[0]]);
|
|
24
|
+
const record = entry ? {
|
|
25
|
+
entry,
|
|
26
|
+
files: Object.keys(bundle).filter((file) => !file.endsWith(".css") && !file.endsWith(".map")).sort()
|
|
27
|
+
} : null;
|
|
28
|
+
await _promises2.default.mkdir(options.buildDir, { recursive: true });
|
|
29
|
+
await _promises2.default.writeFile(manifestPath(options.buildDir), JSON.stringify(record));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function hasFarmMobileClientEntry(buildDir, clientOutputDir) {
|
|
34
|
+
let record = null;
|
|
35
|
+
try {
|
|
36
|
+
record = JSON.parse(await _promises2.default.readFile(manifestPath(buildDir), "utf8"));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (!record) return false;
|
|
41
|
+
return _promises2.default.stat(_path2.default.join(clientOutputDir, record.entry)).then(
|
|
42
|
+
(stat) => stat.isFile() && stat.size > 0,
|
|
43
|
+
() => false
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function stylesheetUrls(css) {
|
|
47
|
+
const urls = [];
|
|
48
|
+
for (const match of css.matchAll(/url\(\s*(["']?)(\/[^"')?#]+)[^"')]*\1\s*\)/g)) {
|
|
49
|
+
urls.push(match[2]);
|
|
50
|
+
}
|
|
51
|
+
return urls;
|
|
52
|
+
}
|
|
53
|
+
async function finalizeFarmMobileClient(options) {
|
|
54
|
+
let record = null;
|
|
55
|
+
try {
|
|
56
|
+
record = JSON.parse(await _promises2.default.readFile(manifestPath(options.buildDir), "utf8"));
|
|
57
|
+
} catch (e2) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (!record) return null;
|
|
61
|
+
const mobileFiles = new Set(record.files);
|
|
62
|
+
const files = new Set(record.files.filter(isFarmContentHashedFile).map((file) => `/${file}`));
|
|
63
|
+
const stylesheetFile = options.stylesheet.replace(/^\/+/, "");
|
|
64
|
+
if (isFarmContentHashedFile(stylesheetFile)) {
|
|
65
|
+
files.add(`/${stylesheetFile}`);
|
|
66
|
+
const css = await _promises2.default.readFile(_path2.default.join(options.clientOutputDir, stylesheetFile), "utf8").catch(() => "");
|
|
67
|
+
for (const url of stylesheetUrls(css)) {
|
|
68
|
+
const file = url.replace(/^\/+/, "");
|
|
69
|
+
if (!isFarmContentHashedFile(file)) continue;
|
|
70
|
+
const exists = await _promises2.default.stat(_path2.default.join(options.clientOutputDir, file)).then(
|
|
71
|
+
(stat) => stat.isFile(),
|
|
72
|
+
() => false
|
|
73
|
+
);
|
|
74
|
+
if (exists) files.add(`/${file}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const manifest = {
|
|
78
|
+
version: 1,
|
|
79
|
+
webEntry: options.webEntry,
|
|
80
|
+
entry: `/${record.entry}`,
|
|
81
|
+
stylesheet: options.stylesheet,
|
|
82
|
+
files: [...files].sort()
|
|
83
|
+
};
|
|
84
|
+
await _promises2.default.writeFile(manifestPath(options.buildDir), `${JSON.stringify(manifest, null, 2)}
|
|
85
|
+
`);
|
|
86
|
+
return {
|
|
87
|
+
webEntry: options.webEntry,
|
|
88
|
+
entry: manifest.entry,
|
|
89
|
+
webOnly: options.webFiles.filter((file) => !mobileFiles.has(file)).sort()
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function readFarmMobileClientManifest(buildDir) {
|
|
93
|
+
try {
|
|
94
|
+
const manifest = JSON.parse(await _promises2.default.readFile(manifestPath(buildDir), "utf8"));
|
|
95
|
+
return manifest && manifest.version === 1 ? manifest : null;
|
|
96
|
+
} catch (e3) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function encodeFarmMobileShellClient(client) {
|
|
101
|
+
return JSON.stringify(JSON.stringify(client)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
102
|
+
}
|
|
103
|
+
var FARM_MOBILE_SHELL_CLIENT_PLACEHOLDER = "__farm_mobile_shell_client__";
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
exports.FARM_MOBILE_CLIENT_ENTRY_NAME = FARM_MOBILE_CLIENT_ENTRY_NAME; exports.removeFarmMobileClientManifest = removeFarmMobileClientManifest; exports.createFarmMobileClientManifestPlugin = createFarmMobileClientManifestPlugin; exports.hasFarmMobileClientEntry = hasFarmMobileClientEntry; exports.finalizeFarmMobileClient = finalizeFarmMobileClient; exports.readFarmMobileClientManifest = readFarmMobileClientManifest; exports.encodeFarmMobileShellClient = encodeFarmMobileShellClient; exports.FARM_MOBILE_SHELL_CLIENT_PLACEHOLDER = FARM_MOBILE_SHELL_CLIENT_PLACEHOLDER;
|
|
@@ -1,9 +1,9 @@
|
|
|
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 _chunkH33PJEXNcjs = require('./chunk-H33PJEXN.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkD7UQC4O6cjs = require('./chunk-D7UQC4O6.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkD22BUQKWcjs = require('./chunk-D22BUQKW.cjs');
|
|
@@ -166,12 +166,12 @@ function createFarmDefaultSitemap(sources, options) {
|
|
|
166
166
|
for (const source of sources) {
|
|
167
167
|
const path = source.pattern;
|
|
168
168
|
if (path.includes("[") || path.includes("(") || entries.has(path)) continue;
|
|
169
|
-
if (include.length && !include.some((pattern) =>
|
|
169
|
+
if (include.length && !include.some((pattern) => _chunkD7UQC4O6cjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) {
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
172
|
-
if (exclude.some((pattern) =>
|
|
172
|
+
if (exclude.some((pattern) => _chunkD7UQC4O6cjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) continue;
|
|
173
173
|
const module = isRecord(source.module) ? source.module : void 0;
|
|
174
|
-
if (
|
|
174
|
+
if (_chunkH33PJEXNcjs.isFarmMetadataNoIndex.call(void 0, _optionalChain([module, 'optionalAccess', _2 => _2.metadata]))) continue;
|
|
175
175
|
if (_optionalChain([module, 'optionalAccess', _3 => _3.__farmRouteGuard])) continue;
|
|
176
176
|
entries.set(path, {
|
|
177
177
|
url: new URL(_chunkD22BUQKWcjs.applyFarmBasePath.call(void 0, path, options.basePath), base).href,
|
|
@@ -25,13 +25,13 @@ import {
|
|
|
25
25
|
resolveFarmAgentSitemap,
|
|
26
26
|
resolveFarmNoindexPreviews,
|
|
27
27
|
resolveFarmPerformanceConfig
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-LDNSSHEG.mjs";
|
|
29
29
|
import {
|
|
30
30
|
resolveFarmAppManifestConfig
|
|
31
31
|
} from "./chunk-2WZTGPK6.mjs";
|
|
32
32
|
import {
|
|
33
33
|
resolveFarmLlmsTxtConfig
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-YAJTD3ZG.mjs";
|
|
35
35
|
import {
|
|
36
36
|
farmCspBlocksFrameworkInlineScripts,
|
|
37
37
|
getFarmSecurityHeader,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
} from "./chunk-YWPNIYUP.mjs";
|
|
69
69
|
import {
|
|
70
70
|
resolveMarkdownConfig
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-LPDKG6RA.mjs";
|
|
72
72
|
import {
|
|
73
73
|
resolveIntegrationPlugins
|
|
74
74
|
} from "./chunk-Y2G5SJFB.mjs";
|
|
@@ -831,6 +831,10 @@ async function resolveConfig(userConfig, mode) {
|
|
|
831
831
|
userConfig.deploymentId || process.env.FARM_DEPLOYMENT_ID || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CF_PAGES_COMMIT_SHA || (mode === "production" ? await generateBuildId() : "development")
|
|
832
832
|
);
|
|
833
833
|
const basePath = normalizeFarmConfigBasePath(userConfig.basePath);
|
|
834
|
+
const mobileSessionPlugin = userConfig.mobile !== void 0 && userConfig.mobile !== null ? (await import("./session-IGEDQ5PY.mjs")).createFarmMobileSessionPlugin({
|
|
835
|
+
basePath,
|
|
836
|
+
integrations: () => integrations
|
|
837
|
+
}) : null;
|
|
834
838
|
const openapi = {
|
|
835
839
|
enabled: false,
|
|
836
840
|
route: "/docs/reference",
|
|
@@ -881,7 +885,9 @@ async function resolveConfig(userConfig, mode) {
|
|
|
881
885
|
},
|
|
882
886
|
agent: resolveFarmAgentConfig(userConfig.agent, { docs: docs.enabled }),
|
|
883
887
|
desktop: desktopSetup?.desktop ?? null,
|
|
888
|
+
...userConfig.mobile !== void 0 ? { mobileClient: true } : {},
|
|
884
889
|
plugins: [
|
|
890
|
+
...mobileSessionPlugin ? [mobileSessionPlugin] : [],
|
|
885
891
|
...resolveIntegrationPlugins(integrations),
|
|
886
892
|
...nativeMCPPlugin ? [nativeMCPPlugin] : [],
|
|
887
893
|
...userConfig.plugins || []
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkD7UQC4O6cjs = require('./chunk-D7UQC4O6.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkD22BUQKWcjs = require('./chunk-D22BUQKW.cjs');
|
|
@@ -59,12 +59,12 @@ function collectFarmLlmsTxtPages(sources, options) {
|
|
|
59
59
|
for (const source of sources) {
|
|
60
60
|
const path = source.pattern;
|
|
61
61
|
if (path.includes("[") || pages.has(path)) continue;
|
|
62
|
-
if (include.length && !include.some((pattern) =>
|
|
62
|
+
if (include.length && !include.some((pattern) => _chunkD7UQC4O6cjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) {
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
if (exclude.some((pattern) =>
|
|
65
|
+
if (exclude.some((pattern) => _chunkD7UQC4O6cjs.matchesFarmMarkdownRoutePattern.call(void 0, pattern, path))) continue;
|
|
66
66
|
if (isFarmMetadataNoIndex(source.metadata)) continue;
|
|
67
|
-
const target =
|
|
67
|
+
const target = _chunkD7UQC4O6cjs.isFarmMarkdownMirrorExposed.call(void 0, options.markdown, path) ? _chunkD7UQC4O6cjs.getFarmMarkdownMirrorPath.call(void 0, path) : path;
|
|
68
68
|
const description = readMetadataString(source.metadata, "description");
|
|
69
69
|
pages.set(path, {
|
|
70
70
|
path,
|
|
@@ -155,7 +155,7 @@ function createFarmLlmsMarkdownReader(fetchMarkdown) {
|
|
|
155
155
|
try {
|
|
156
156
|
const response = await fetchMarkdown(
|
|
157
157
|
new Request(url, {
|
|
158
|
-
headers: { accept: "text/markdown", [
|
|
158
|
+
headers: { accept: "text/markdown", [_chunkD7UQC4O6cjs.FARM_INTERNAL_READ_HEADER]: "llms-full" }
|
|
159
159
|
})
|
|
160
160
|
);
|
|
161
161
|
const type = _nullishCoalesce(response.headers.get("content-type"), () => ( ""));
|
|
@@ -7,7 +7,7 @@ var _chunkSJ23LJ3Ncjs = require('./chunk-SJ23LJ3N.cjs');
|
|
|
7
7
|
var _chunkXPMC4E2Gcjs = require('./chunk-XPMC4E2G.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkKLNFJDFMcjs = require('./chunk-KLNFJDFM.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -111,7 +111,7 @@ async function createFarmRscViteConfig(userConfig, options) {
|
|
|
111
111
|
server: { environmentName: "rsc" },
|
|
112
112
|
config: {
|
|
113
113
|
preset: options.preset,
|
|
114
|
-
outputDir: options.outputDir &&
|
|
114
|
+
outputDir: options.outputDir && _chunkKLNFJDFMcjs.resolveDeployOutputPath.call(void 0, root, options.outputDir)
|
|
115
115
|
}
|
|
116
116
|
})
|
|
117
117
|
]
|
|
@@ -0,0 +1,389 @@
|
|
|
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
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkP6MHI5O2cjs = require('./chunk-P6MHI5O2.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkD7UQC4O6cjs = require('./chunk-D7UQC4O6.cjs');
|
|
12
|
+
|
|
13
|
+
// src/mobile/native-tree.ts
|
|
14
|
+
var VIEW_TAGS = new Set(
|
|
15
|
+
"div section main article header footer nav aside figure ul ol li hr".split(" ")
|
|
16
|
+
);
|
|
17
|
+
var BLOCK_TEXT_TAGS = new Set("p h1 h2 h3 h4 h5 h6".split(" "));
|
|
18
|
+
var INLINE_TAGS = new Set("span strong em b i small label code br a".split(" "));
|
|
19
|
+
var VOID_TAGS = new Set(
|
|
20
|
+
"area base br col embed hr img input link meta source track wbr".split(" ")
|
|
21
|
+
);
|
|
22
|
+
var SKIPPED_TAGS = new Set("link meta template title".split(" "));
|
|
23
|
+
var INLINE_DEFAULTS = {
|
|
24
|
+
strong: { fontWeight: 700 },
|
|
25
|
+
b: { fontWeight: 700 },
|
|
26
|
+
em: { fontStyle: "italic" },
|
|
27
|
+
i: { fontStyle: "italic" },
|
|
28
|
+
code: { fontFamily: "mono" }
|
|
29
|
+
};
|
|
30
|
+
var ENTITIES = {
|
|
31
|
+
amp: "&",
|
|
32
|
+
lt: "<",
|
|
33
|
+
gt: ">",
|
|
34
|
+
quot: '"',
|
|
35
|
+
apos: "'",
|
|
36
|
+
nbsp: "\xA0"
|
|
37
|
+
};
|
|
38
|
+
function decode(text) {
|
|
39
|
+
return text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (entity, name) => {
|
|
40
|
+
if (name[0] === "#") {
|
|
41
|
+
const code = name[1] === "x" || name[1] === "X" ? parseInt(name.slice(2), 16) : Number(name.slice(1));
|
|
42
|
+
return Number.isFinite(code) ? String.fromCodePoint(code) : entity;
|
|
43
|
+
}
|
|
44
|
+
return _nullishCoalesce(ENTITIES[name.toLowerCase()], () => ( entity));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function parseHtml(html) {
|
|
48
|
+
const root = { tag: "#root", attributes: {}, children: [] };
|
|
49
|
+
const stack = [root];
|
|
50
|
+
const tag = /<(\/?)([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
|
|
51
|
+
let cursor = 0;
|
|
52
|
+
let match;
|
|
53
|
+
while (match = tag.exec(html)) {
|
|
54
|
+
if (match.index > cursor) stack.at(-1).children.push(decode(html.slice(cursor, match.index)));
|
|
55
|
+
cursor = tag.lastIndex;
|
|
56
|
+
const name = match[2].toLowerCase();
|
|
57
|
+
if (match[1]) {
|
|
58
|
+
let open = stack.length - 1;
|
|
59
|
+
while (open > 0 && stack[open].tag !== name) open -= 1;
|
|
60
|
+
if (open > 0) stack.length = open;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const attributes = {};
|
|
64
|
+
for (const attribute of match[3].matchAll(
|
|
65
|
+
/([^\s=/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g
|
|
66
|
+
)) {
|
|
67
|
+
attributes[attribute[1].toLowerCase()] = decode(
|
|
68
|
+
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(attribute[2], () => ( attribute[3])), () => ( attribute[4])), () => ( ""))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const element = { tag: name, attributes, children: [] };
|
|
72
|
+
stack.at(-1).children.push(element);
|
|
73
|
+
if (!match[4] && !VOID_TAGS.has(name)) stack.push(element);
|
|
74
|
+
}
|
|
75
|
+
if (cursor < html.length) stack.at(-1).children.push(decode(html.slice(cursor)));
|
|
76
|
+
return root;
|
|
77
|
+
}
|
|
78
|
+
function find(element, test) {
|
|
79
|
+
if (test(element)) return element;
|
|
80
|
+
for (const child of element.children) {
|
|
81
|
+
if (typeof child === "string") continue;
|
|
82
|
+
const found = find(child, test);
|
|
83
|
+
if (found) return found;
|
|
84
|
+
}
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
function textOnly(style) {
|
|
88
|
+
return Object.fromEntries(
|
|
89
|
+
Object.entries(style).filter(([key]) => _chunkP6MHI5O2cjs.FARM_NATIVE_TEXT_KEYS.has(key))
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
function withoutText(style) {
|
|
93
|
+
const rest = Object.entries(style).filter(([key]) => !_chunkP6MHI5O2cjs.FARM_NATIVE_TEXT_KEYS.has(key));
|
|
94
|
+
return rest.length > 0 ? Object.fromEntries(rest) : void 0;
|
|
95
|
+
}
|
|
96
|
+
function settleLineHeight(style) {
|
|
97
|
+
const { lineHeightScale, lineHeightPx, ...rest } = style;
|
|
98
|
+
if (lineHeightPx !== void 0) rest.lineHeight = lineHeightPx;
|
|
99
|
+
else if (typeof lineHeightScale === "number") {
|
|
100
|
+
rest.lineHeight = Math.round(lineHeightScale * Number(_nullishCoalesce(rest.fontSize, () => ( 16))) * 100) / 100;
|
|
101
|
+
}
|
|
102
|
+
return rest;
|
|
103
|
+
}
|
|
104
|
+
var Converter = class {
|
|
105
|
+
constructor(pageUrl) {
|
|
106
|
+
this.pageUrl = pageUrl;
|
|
107
|
+
this.unsupported = [];
|
|
108
|
+
}
|
|
109
|
+
problem(message) {
|
|
110
|
+
if (!this.unsupported.includes(message)) this.unsupported.push(message);
|
|
111
|
+
}
|
|
112
|
+
stylesOf(element) {
|
|
113
|
+
const classes = _chunkP6MHI5O2cjs.resolveFarmNativeClasses.call(void 0, _nullishCoalesce(element.attributes.class, () => ( "")));
|
|
114
|
+
for (const token of classes.unsupported) this.problem(`<${element.tag}> class "${token}"`);
|
|
115
|
+
const inline = _chunkP6MHI5O2cjs.resolveFarmNativeInlineStyle.call(void 0, _nullishCoalesce(element.attributes.style, () => ( "")));
|
|
116
|
+
for (const declaration of inline.unsupported) {
|
|
117
|
+
this.problem(`<${element.tag}> style "${declaration}"`);
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
style: { ...INLINE_DEFAULTS[element.tag], ...classes.style, ...inline.style },
|
|
121
|
+
dark: _nullishCoalesce(classes.dark, () => ( {}))
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
url(value) {
|
|
125
|
+
if (!value) return void 0;
|
|
126
|
+
try {
|
|
127
|
+
return new URL(value, this.pageUrl).href;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
this.problem(`URL "${value}"`);
|
|
130
|
+
return void 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
node(type, element, style, dark) {
|
|
134
|
+
return {
|
|
135
|
+
type,
|
|
136
|
+
tag: element.tag,
|
|
137
|
+
...style && Object.keys(style).length > 0 ? { style } : {},
|
|
138
|
+
...dark && Object.keys(dark).length > 0 ? { dark } : {}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** Inline content: runs of text, nested inline elements, and line breaks. */
|
|
142
|
+
inline(content, inherited) {
|
|
143
|
+
const runs = [];
|
|
144
|
+
for (const child of content) {
|
|
145
|
+
if (typeof child === "string") {
|
|
146
|
+
runs.push(child);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (SKIPPED_TAGS.has(child.tag)) continue;
|
|
150
|
+
if (child.tag === "br") {
|
|
151
|
+
runs.push("\n");
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (!INLINE_TAGS.has(child.tag)) {
|
|
155
|
+
this.problem(`<${child.tag}> inside text`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const own = this.stylesOf(child);
|
|
159
|
+
if (own.style.display === "none") continue;
|
|
160
|
+
const run = this.node(
|
|
161
|
+
"Text",
|
|
162
|
+
child,
|
|
163
|
+
settleLineHeight(textOnly(own.style)),
|
|
164
|
+
textOnly(own.dark)
|
|
165
|
+
);
|
|
166
|
+
if (withoutText(own.style)) this.problem(`<${child.tag}> inside text has box styles`);
|
|
167
|
+
if (child.tag === "a") run.href = this.url(child.attributes.href);
|
|
168
|
+
const children = this.inline(child.children, inherited);
|
|
169
|
+
if (children.length > 0) run.children = children;
|
|
170
|
+
runs.push(run);
|
|
171
|
+
}
|
|
172
|
+
return runs;
|
|
173
|
+
}
|
|
174
|
+
/** A text block: its runs, with the text style its ancestors pass down. */
|
|
175
|
+
text(element, content, inherited, box) {
|
|
176
|
+
const runs = this.inline(content, inherited);
|
|
177
|
+
const trimmed = collapse(runs);
|
|
178
|
+
if (trimmed.length === 0) return void 0;
|
|
179
|
+
const style = settleLineHeight({ ...inherited.style, ..._optionalChain([box, 'optionalAccess', _ => _.style]) });
|
|
180
|
+
const dark = { ...inherited.dark, ..._optionalChain([box, 'optionalAccess', _2 => _2.dark]) };
|
|
181
|
+
const node = this.node("Text", element, style, dark);
|
|
182
|
+
node.children = trimmed;
|
|
183
|
+
return node;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Block content: each element a view, and each run of inline content a text block. In a flex
|
|
187
|
+
* container every child is its own item, as CSS blockifies them: a `<span>` pill there is a box.
|
|
188
|
+
*/
|
|
189
|
+
blocks(content, inherited, flex = false) {
|
|
190
|
+
if (flex) {
|
|
191
|
+
const items = [];
|
|
192
|
+
for (const child of content) {
|
|
193
|
+
const item = typeof child === "string" ? this.text({ tag: "#text", attributes: {}, children: [] }, [child], inherited) : this.element(child, inherited, true);
|
|
194
|
+
if (item) items.push(item);
|
|
195
|
+
}
|
|
196
|
+
return items;
|
|
197
|
+
}
|
|
198
|
+
const nodes = [];
|
|
199
|
+
let pending = [];
|
|
200
|
+
const flush = () => {
|
|
201
|
+
const block = this.text({ tag: "#text", attributes: {}, children: [] }, pending, inherited);
|
|
202
|
+
if (block) nodes.push(block);
|
|
203
|
+
pending = [];
|
|
204
|
+
};
|
|
205
|
+
for (const child of content) {
|
|
206
|
+
if (typeof child === "string" || INLINE_TAGS.has(child.tag) && !isBlockLink(child)) {
|
|
207
|
+
pending.push(child);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
flush();
|
|
211
|
+
const node = this.element(child, inherited);
|
|
212
|
+
if (node) nodes.push(node);
|
|
213
|
+
}
|
|
214
|
+
flush();
|
|
215
|
+
return nodes;
|
|
216
|
+
}
|
|
217
|
+
element(element, inherited, flexItem = false) {
|
|
218
|
+
if (SKIPPED_TAGS.has(element.tag)) return void 0;
|
|
219
|
+
const own = this.stylesOf(element);
|
|
220
|
+
if (own.style.display === "none") return void 0;
|
|
221
|
+
const passed = {
|
|
222
|
+
style: { ...inherited.style, ...textOnly(own.style) },
|
|
223
|
+
dark: { ...inherited.dark, ...textOnly(own.dark) }
|
|
224
|
+
};
|
|
225
|
+
const current = (style, color) => style && Object.fromEntries(
|
|
226
|
+
Object.entries(style).map(([key, value]) => [
|
|
227
|
+
key,
|
|
228
|
+
value === "currentColor" && typeof color === "string" ? color : value
|
|
229
|
+
])
|
|
230
|
+
);
|
|
231
|
+
const box = current(withoutText(own.style), passed.style.color);
|
|
232
|
+
const boxDark = current(withoutText(own.dark), _nullishCoalesce(passed.dark.color, () => ( passed.style.color)));
|
|
233
|
+
const flex = own.style.display === "flex";
|
|
234
|
+
const textBox = flexItem && INLINE_TAGS.has(element.tag) && element.tag !== "a" && element.tag !== "br";
|
|
235
|
+
if (BLOCK_TEXT_TAGS.has(element.tag) || textBox) {
|
|
236
|
+
if (element.children.some((child) => typeof child !== "string" && !INLINE_TAGS.has(child.tag))) {
|
|
237
|
+
this.problem(`<${element.tag}> holds block elements`);
|
|
238
|
+
}
|
|
239
|
+
const node = this.text(element, element.children, inherited, own);
|
|
240
|
+
return _nullishCoalesce(node, () => ( this.node("View", element, box, boxDark)));
|
|
241
|
+
}
|
|
242
|
+
if (element.tag === "img") {
|
|
243
|
+
const node = this.node("Image", element, box, boxDark);
|
|
244
|
+
node.src = this.url(element.attributes.src);
|
|
245
|
+
if (element.attributes.alt) node.alt = element.attributes.alt;
|
|
246
|
+
if (!node.src) this.problem("<img> without src");
|
|
247
|
+
return node;
|
|
248
|
+
}
|
|
249
|
+
if (element.tag === "input" || element.tag === "textarea") {
|
|
250
|
+
const node = this.node(
|
|
251
|
+
"TextInput",
|
|
252
|
+
element,
|
|
253
|
+
settleLineHeight({ ...passed.style, ...box }),
|
|
254
|
+
boxDark
|
|
255
|
+
);
|
|
256
|
+
if (element.attributes.placeholder) node.placeholder = element.attributes.placeholder;
|
|
257
|
+
const value = element.tag === "textarea" ? textContent(element) : element.attributes.value;
|
|
258
|
+
if (value) node.value = value;
|
|
259
|
+
return node;
|
|
260
|
+
}
|
|
261
|
+
if (element.tag === "a" || element.tag === "button") {
|
|
262
|
+
const node = this.node("Pressable", element, box, boxDark);
|
|
263
|
+
if (element.tag === "a") node.href = this.url(element.attributes.href);
|
|
264
|
+
node.children = this.blocks(element.children, passed, flex);
|
|
265
|
+
return node;
|
|
266
|
+
}
|
|
267
|
+
if (element.tag === "hr") {
|
|
268
|
+
return this.node(
|
|
269
|
+
"View",
|
|
270
|
+
element,
|
|
271
|
+
{
|
|
272
|
+
borderTopWidth: 1,
|
|
273
|
+
borderTopColor: String(_nullishCoalesce(passed.style.color, () => ( "currentColor"))),
|
|
274
|
+
...box
|
|
275
|
+
},
|
|
276
|
+
boxDark
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
if (VIEW_TAGS.has(element.tag)) {
|
|
280
|
+
const node = this.node("View", element, box, boxDark);
|
|
281
|
+
const children = this.blocks(element.children, passed, flex);
|
|
282
|
+
if (children.length > 0) node.children = children;
|
|
283
|
+
return node;
|
|
284
|
+
}
|
|
285
|
+
if (INLINE_TAGS.has(element.tag)) {
|
|
286
|
+
return this.text(element, [element], inherited);
|
|
287
|
+
}
|
|
288
|
+
this.problem(`<${element.tag}>`);
|
|
289
|
+
return void 0;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
function isBlockLink(element) {
|
|
293
|
+
if (element.tag !== "a") return false;
|
|
294
|
+
if (element.children.some((child) => typeof child !== "string" && !INLINE_TAGS.has(child.tag))) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
const classes = _chunkP6MHI5O2cjs.resolveFarmNativeClasses.call(void 0, _nullishCoalesce(element.attributes.class, () => ( ""))).style;
|
|
298
|
+
const inline = _chunkP6MHI5O2cjs.resolveFarmNativeInlineStyle.call(void 0, _nullishCoalesce(element.attributes.style, () => ( ""))).style;
|
|
299
|
+
return withoutText({ ...classes, ...inline }) !== void 0;
|
|
300
|
+
}
|
|
301
|
+
function textContent(element) {
|
|
302
|
+
return element.children.map((child) => typeof child === "string" ? child : textContent(child)).join("");
|
|
303
|
+
}
|
|
304
|
+
function collapse(runs) {
|
|
305
|
+
let previousSpace = true;
|
|
306
|
+
const walk = (items) => {
|
|
307
|
+
const out2 = [];
|
|
308
|
+
for (const item of items) {
|
|
309
|
+
if (typeof item === "string") {
|
|
310
|
+
if (item === "\n") {
|
|
311
|
+
out2.push(item);
|
|
312
|
+
previousSpace = true;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
let text = item.replace(/[ \t\r\n\f]+/g, " ");
|
|
316
|
+
if (previousSpace) text = text.replace(/^ /, "");
|
|
317
|
+
if (text) {
|
|
318
|
+
previousSpace = text.endsWith(" ");
|
|
319
|
+
out2.push(text);
|
|
320
|
+
}
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const children = item.children ? walk(item.children) : [];
|
|
324
|
+
if (children.length > 0 || item.href) out2.push({ ...item, children });
|
|
325
|
+
}
|
|
326
|
+
return out2;
|
|
327
|
+
};
|
|
328
|
+
const out = walk(runs);
|
|
329
|
+
for (let index = out.length - 1; index >= 0; index -= 1) {
|
|
330
|
+
const item = out[index];
|
|
331
|
+
if (typeof item !== "string") break;
|
|
332
|
+
const trimmed = item.replace(/ $/, "");
|
|
333
|
+
if (trimmed) {
|
|
334
|
+
out[index] = trimmed;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
out.splice(index, 1);
|
|
338
|
+
}
|
|
339
|
+
return out;
|
|
340
|
+
}
|
|
341
|
+
function createFarmNativeTree(html, pageUrl) {
|
|
342
|
+
const title = _optionalChain([/<title\b[^>]*>([\s\S]*?)<\/title>/i, 'access', _3 => _3.exec, 'call', _4 => _4(html), 'optionalAccess', _5 => _5[1]]);
|
|
343
|
+
const document = parseHtml(_chunkD7UQC4O6cjs._readFarmRenderedHtml.call(void 0, html));
|
|
344
|
+
const page = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(find(document, (element) => element.attributes.id === "__farm_page__"), () => ( find(document, (element) => element.attributes.id === "root"))), () => ( find(document, (element) => element.tag === "body"))), () => ( document));
|
|
345
|
+
const converter = new Converter(pageUrl);
|
|
346
|
+
const root = { type: "View", tag: page.tag };
|
|
347
|
+
const children = converter.blocks(page.children, { style: {}, dark: {} });
|
|
348
|
+
if (children.length > 0) root.children = children;
|
|
349
|
+
return {
|
|
350
|
+
version: 1,
|
|
351
|
+
...title ? { title: decode(title.trim()) } : {},
|
|
352
|
+
root,
|
|
353
|
+
unsupported: converter.unsupported
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function farmRequestWantsNativeTree(request) {
|
|
357
|
+
return (_nullishCoalesce(request.headers.get("accept"), () => ( ""))).includes(_chunk3HLQTOVUcjs.FARM_NATIVE_TREE_CONTENT_TYPE);
|
|
358
|
+
}
|
|
359
|
+
async function createFarmNativeTreeResponse(options) {
|
|
360
|
+
const headers = new Headers(options.request.headers);
|
|
361
|
+
headers.set("accept", "text/html");
|
|
362
|
+
headers.delete("accept-encoding");
|
|
363
|
+
const page = await options.renderPage(
|
|
364
|
+
new Request(options.request.url, {
|
|
365
|
+
method: "GET",
|
|
366
|
+
headers,
|
|
367
|
+
signal: options.request.signal
|
|
368
|
+
})
|
|
369
|
+
);
|
|
370
|
+
const type = _nullishCoalesce(page.headers.get("content-type"), () => ( ""));
|
|
371
|
+
if (page.status !== 200 || !type.includes("text/html")) return page;
|
|
372
|
+
const tree = createFarmNativeTree(await page.text(), new URL(options.request.url));
|
|
373
|
+
const out = new Headers({
|
|
374
|
+
"Content-Type": `${_chunk3HLQTOVUcjs.FARM_NATIVE_TREE_CONTENT_TYPE}; charset=utf-8`,
|
|
375
|
+
Vary: "Accept",
|
|
376
|
+
"Cache-Control": _nullishCoalesce(page.headers.get("cache-control"), () => ( "no-store"))
|
|
377
|
+
});
|
|
378
|
+
for (const cookie of _nullishCoalesce(_optionalChain([page, 'access', _6 => _6.headers, 'access', _7 => _7.getSetCookie, 'optionalCall', _8 => _8()]), () => ( []))) out.append("Set-Cookie", cookie);
|
|
379
|
+
return new Response(options.request.method === "HEAD" ? null : JSON.stringify(tree), {
|
|
380
|
+
status: 200,
|
|
381
|
+
headers: out
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
exports.createFarmNativeTree = createFarmNativeTree; exports.farmRequestWantsNativeTree = farmRequestWantsNativeTree; exports.createFarmNativeTreeResponse = createFarmNativeTreeResponse;
|