@farm.js/core 0.1.51-beta.2 → 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.
Files changed (183) hide show
  1. package/dist/{agent-mcp-handler-WWCC4GLG.mjs → agent-mcp-handler-7JSKGSOW.mjs} +4 -4
  2. package/dist/{agent-mcp-handler-RT3COCEL.cjs → agent-mcp-handler-YE4AGWHN.cjs} +5 -5
  3. package/dist/{agent-mcp.d-CR5Ov83o.d.ts → agent-mcp.d-BAR9njbJ.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-Z5DuwrqW.d.mts → agent-mcp.d-BJKChOrO.d.mts} +1 -1
  5. package/dist/agent-runtime.d.mts +2 -2
  6. package/dist/agent-runtime.d.ts +2 -2
  7. package/dist/{analyzer-Z6TNEAET.mjs → analyzer-OTPEWH5W.mjs} +14 -3
  8. package/dist/{analyzer-T76CN3S7.cjs → analyzer-TSQXZCZN.cjs} +14 -3
  9. package/dist/api/route-manager.d.mts +4 -4
  10. package/dist/api/route-manager.d.ts +4 -4
  11. package/dist/api/runtime.d.mts +3 -3
  12. package/dist/api/runtime.d.ts +3 -3
  13. package/dist/api.d.mts +4 -4
  14. package/dist/api.d.ts +4 -4
  15. package/dist/{app-manifest.d-DiWr_Jfx.d.ts → app-manifest.d-BLFbaqx8.d.ts} +1 -1
  16. package/dist/{app-manifest.d-CAHkOBFa.d.mts → app-manifest.d-DEQNnNhV.d.mts} +1 -1
  17. package/dist/app-markdown.cjs +4 -4
  18. package/dist/app-markdown.d.mts +3 -3
  19. package/dist/app-markdown.d.ts +3 -3
  20. package/dist/app-markdown.mjs +3 -3
  21. package/dist/{app.d-DmapqkbV.d.ts → app.d-CNPaUYaa.d.ts} +4 -4
  22. package/dist/{app.d-BfgJCsTQ.d.mts → app.d-CT7xDkj2.d.mts} +4 -4
  23. package/dist/{chunk-YVJV7Q2X.mjs → chunk-3BLEXUGE.mjs} +1 -1
  24. package/dist/chunk-3HLQTOVU.cjs +6 -0
  25. package/dist/{chunk-E6LTONL4.mjs → chunk-3SMXQNFD.mjs} +2 -2
  26. package/dist/{chunk-PMKUU273.mjs → chunk-3TLKUBXG.mjs} +411 -166
  27. package/dist/{chunk-74Z5KX4A.mjs → chunk-3WSIYBMG.mjs} +41 -19
  28. package/dist/{chunk-GNJIYJMS.cjs → chunk-3XQ57EFI.cjs} +16 -16
  29. package/dist/{chunk-GW4YUIHW.mjs → chunk-3Z63X45F.mjs} +1 -1
  30. package/dist/{chunk-IBSAYAWB.mjs → chunk-4353ZRE5.mjs} +1 -1
  31. package/dist/{chunk-SBABQKPT.cjs → chunk-46KXZBOG.cjs} +5 -5
  32. package/dist/{chunk-YU42A5MA.cjs → chunk-4CGOMZP3.cjs} +221 -199
  33. package/dist/{chunk-J3LBO2O4.cjs → chunk-4SEHMBL4.cjs} +10 -10
  34. package/dist/{chunk-E73PGHSR.mjs → chunk-4TKAIO2F.mjs} +3 -3
  35. package/dist/{chunk-NJLTQR5P.cjs → chunk-53SACYBY.cjs} +7 -7
  36. package/dist/{chunk-FM2UEKS2.mjs → chunk-5FXPJIOT.mjs} +2 -2
  37. package/dist/{chunk-QXPSWMUD.cjs → chunk-7MD37P5V.cjs} +5 -5
  38. package/dist/{chunk-JATTVAHA.cjs → chunk-B3GM5I6N.cjs} +4 -4
  39. package/dist/{chunk-WJFFPXCV.cjs → chunk-D7UQC4O6.cjs} +10 -8
  40. package/dist/{chunk-KRRZJ77U.mjs → chunk-E5DXF5GE.mjs} +2 -2
  41. package/dist/chunk-EFZGB7JC.cjs +114 -0
  42. package/dist/{chunk-NYQSC4DX.cjs → chunk-FFE2EMF7.cjs} +5 -5
  43. package/dist/{chunk-CTM4SPB3.mjs → chunk-GAO7MS5O.mjs} +4 -3
  44. package/dist/{chunk-HIFIG6HL.cjs → chunk-H33PJEXN.cjs} +5 -5
  45. package/dist/{chunk-NXBHYO7S.cjs → chunk-HLWOWZFX.cjs} +2 -2
  46. package/dist/chunk-JXEPLIXD.cjs +389 -0
  47. package/dist/{chunk-NPQLMP7M.cjs → chunk-KLNFJDFM.cjs} +10 -9
  48. package/dist/{chunk-KBRZAYI7.mjs → chunk-LDNSSHEG.mjs} +2 -2
  49. package/dist/chunk-LLZSYFOM.mjs +6 -0
  50. package/dist/{chunk-N77JBPLC.mjs → chunk-LPDKG6RA.mjs} +9 -7
  51. package/dist/chunk-MIGFX2FN.mjs +758 -0
  52. package/dist/{chunk-72D2NX77.mjs → chunk-MRNDAJEV.mjs} +1 -1
  53. package/dist/{chunk-4SSRBCBR.mjs → chunk-NOTSHVRN.mjs} +355 -218
  54. package/dist/{chunk-GUJTVM36.cjs → chunk-OAMUSC7H.cjs} +1 -1
  55. package/dist/chunk-P6MHI5O2.cjs +758 -0
  56. package/dist/{chunk-6CYQQQGR.mjs → chunk-R4PHCZ3G.mjs} +1 -1
  57. package/dist/{chunk-WZW6LEHM.cjs → chunk-TQMI6BYO.cjs} +675 -430
  58. package/dist/{chunk-76GHW3WI.cjs → chunk-TSFMFPRU.cjs} +4 -4
  59. package/dist/{chunk-5N7QAGEA.cjs → chunk-TWHXBMLJ.cjs} +37 -7
  60. package/dist/{chunk-BOVGCUDZ.cjs → chunk-UJL4JOXV.cjs} +2 -2
  61. package/dist/chunk-UQF3OJVE.mjs +389 -0
  62. package/dist/{chunk-DTU4PX7V.cjs → chunk-WGUHDWT5.cjs} +557 -420
  63. package/dist/{chunk-LAZK6UV7.mjs → chunk-YAJTD3ZG.mjs} +1 -1
  64. package/dist/{chunk-7UPCJDB5.mjs → chunk-YUEYBL35.mjs} +2 -2
  65. package/dist/{chunk-EIMK7D2D.mjs → chunk-ZD2VKAUI.mjs} +34 -4
  66. package/dist/chunk-ZNXTU4YH.mjs +114 -0
  67. package/dist/{client-plugins.d-Bx3FXpqm.d.mts → client-plugins.d-DllmH8eM.d.mts} +17 -4
  68. package/dist/{client-plugins.d-TiLbS5j4.d.ts → client-plugins.d-n3iWY1EJ.d.ts} +17 -4
  69. package/dist/client-plugins.d.mts +2 -2
  70. package/dist/client-plugins.d.ts +2 -2
  71. package/dist/client.d.mts +7 -7
  72. package/dist/client.d.ts +7 -7
  73. package/dist/{config.d-iRPI16ku.d.ts → config.d-DqKaCr1r.d.mts} +8 -1
  74. package/dist/{config.d-iRPI16ku.d.mts → config.d-DqKaCr1r.d.ts} +8 -1
  75. package/dist/config.d.mts +2 -2
  76. package/dist/config.d.ts +2 -2
  77. package/dist/desktop.d.mts +3 -3
  78. package/dist/desktop.d.ts +3 -3
  79. package/dist/{devtools-6XWCZIGO.cjs → devtools-TO6TAO32.cjs} +5 -5
  80. package/dist/{devtools-UQLDAOEI.mjs → devtools-UESYARTF.mjs} +4 -4
  81. package/dist/docs.cjs +7 -7
  82. package/dist/docs.d.mts +3 -3
  83. package/dist/docs.d.ts +3 -3
  84. package/dist/docs.mjs +6 -6
  85. package/dist/index.cjs +22 -18
  86. package/dist/{index.d-YxJ2AiDF.d.mts → index.d-BL7KKiwa.d.mts} +1 -1
  87. package/dist/{index.d-yueUNipJ.d.ts → index.d-BXsAXm1U.d.ts} +1 -1
  88. package/dist/index.d.mts +17 -17
  89. package/dist/index.d.ts +17 -17
  90. package/dist/index.mjs +22 -18
  91. package/dist/integrations.d.mts +2 -2
  92. package/dist/integrations.d.ts +2 -2
  93. package/dist/internal/app-markdown-runtime.cjs +3 -3
  94. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  95. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  96. package/dist/internal/app-markdown-runtime.mjs +2 -2
  97. package/dist/internal/build-runtime.cjs +20 -18
  98. package/dist/internal/build-runtime.d.mts +4 -4
  99. package/dist/internal/build-runtime.d.ts +4 -4
  100. package/dist/internal/build-runtime.mjs +19 -17
  101. package/dist/internal/cli-runtime.cjs +7 -7
  102. package/dist/internal/cli-runtime.mjs +6 -6
  103. package/dist/internal/client-error-overlay.cjs +4 -4
  104. package/dist/internal/client-error-overlay.mjs +1 -1
  105. package/dist/internal/client-runtime.d.mts +5 -5
  106. package/dist/internal/client-runtime.d.ts +5 -5
  107. package/dist/internal/compression-runtime.d.mts +2 -2
  108. package/dist/internal/compression-runtime.d.ts +2 -2
  109. package/dist/internal/config-runtime.cjs +6 -6
  110. package/dist/internal/config-runtime.d.mts +31 -7
  111. package/dist/internal/config-runtime.d.ts +31 -7
  112. package/dist/internal/config-runtime.mjs +5 -5
  113. package/dist/internal/infra-analytics-runtime.cjs +8 -8
  114. package/dist/internal/infra-analytics-runtime.mjs +6 -6
  115. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  116. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  117. package/dist/internal/production-runtime.cjs +87 -9
  118. package/dist/internal/production-runtime.d.mts +44 -12
  119. package/dist/internal/production-runtime.d.ts +44 -12
  120. package/dist/internal/production-runtime.mjs +86 -8
  121. package/dist/markdown.cjs +4 -2
  122. package/dist/markdown.d.mts +2 -2
  123. package/dist/markdown.d.ts +2 -2
  124. package/dist/markdown.mjs +3 -1
  125. package/dist/middleware.d.mts +4 -4
  126. package/dist/middleware.d.ts +4 -4
  127. package/dist/mobile.d.mts +21 -5
  128. package/dist/mobile.d.ts +21 -5
  129. package/dist/native-tree-EBPDFTRW.mjs +25 -0
  130. package/dist/native-tree-MMZS7S6W.cjs +25 -0
  131. package/dist/{navigation-delegate.d-HnDXhlyP.d.mts → navigation-delegate.d-C76gXTmO.d.mts} +1 -1
  132. package/dist/{navigation-delegate.d-BY1e_Xrh.d.ts → navigation-delegate.d-DIyDslxt.d.ts} +1 -1
  133. package/dist/navigation.d.mts +5 -5
  134. package/dist/navigation.d.ts +5 -5
  135. package/dist/plugin.cjs +14 -13
  136. package/dist/plugin.d.mts +5 -4
  137. package/dist/plugin.d.ts +5 -4
  138. package/dist/plugin.mjs +13 -12
  139. package/dist/{production-runtime.d-BpJUDzP8.d.mts → production-runtime.d-CDHztggO.d.mts} +1 -1
  140. package/dist/{production-runtime.d-lMjvE9cf.d.ts → production-runtime.d-tyaGdbk6.d.ts} +1 -1
  141. package/dist/{programmatic-routes-client.d-BlFp5hv4.d.ts → programmatic-routes-client.d-XfmIrCK1.d.ts} +2 -2
  142. package/dist/{programmatic-routes-client.d-6CGQ3TCk.d.mts → programmatic-routes-client.d-aAWiDd64.d.mts} +2 -2
  143. package/dist/{render-plan.d-BH9edqKs.d.mts → render-plan.d-Diwybxo8.d.mts} +1 -1
  144. package/dist/{render-plan.d-DhP0mTHF.d.ts → render-plan.d-Dr5WRjoV.d.ts} +1 -1
  145. package/dist/renderer-client.d.mts +5 -5
  146. package/dist/renderer-client.d.ts +5 -5
  147. package/dist/{request.d-BVZrsR1v.d.ts → request.d-D01fRn--.d.ts} +1 -1
  148. package/dist/{request.d-DJFRdKi8.d.mts → request.d-Dd3AFR79.d.mts} +1 -1
  149. package/dist/request.d.mts +3 -3
  150. package/dist/request.d.ts +3 -3
  151. package/dist/{route-rendering.d-Bpmw7PED.d.mts → route-rendering.d-BQ53lJ_D.d.mts} +1 -1
  152. package/dist/{route-rendering.d-B00JtK_-.d.ts → route-rendering.d-Bhx4QoJt.d.ts} +1 -1
  153. package/dist/{router.d-e0jQ3jQ-.d.mts → router.d-Bi23a6Xc.d.mts} +1 -1
  154. package/dist/{router.d-Bd1x9XxQ.d.ts → router.d-DQ3k7EYn.d.ts} +1 -1
  155. package/dist/{routes.d-Cmv8TgVq.d.mts → routes.d-BgTd7vI4.d.mts} +3 -3
  156. package/dist/{routes.d-D96Dq9lz.d.ts → routes.d-C7jMJFvP.d.ts} +3 -3
  157. package/dist/routes.d.mts +2 -2
  158. package/dist/routes.d.ts +2 -2
  159. package/dist/{rsc-pipeline-ZQ4CTVEG.mjs → rsc-pipeline-K3ER3Q4N.mjs} +5 -5
  160. package/dist/{rsc-pipeline-DX4OC5FN.cjs → rsc-pipeline-OCZIT5OF.cjs} +6 -6
  161. package/dist/{runtime-NQ3EDSA7.cjs → runtime-DKNSIH7V.cjs} +30 -23
  162. package/dist/{runtime-NPDRDV6R.mjs → runtime-MKYDEUZT.mjs} +20 -13
  163. package/dist/{runtime.d-CgB3IJDq.d.mts → runtime.d-B2Js6qZ2.d.mts} +1 -1
  164. package/dist/{runtime.d-D-td-RR3.d.ts → runtime.d-BL-CGwoi.d.ts} +1 -1
  165. package/dist/server-plugins.d.mts +3 -3
  166. package/dist/server-plugins.d.ts +3 -3
  167. package/dist/server.cjs +31 -30
  168. package/dist/server.d.mts +11 -10
  169. package/dist/server.d.ts +11 -10
  170. package/dist/server.mjs +16 -15
  171. package/dist/{spa-router.d-BWDhS0FK.d.mts → spa-router.d-B2rIFGs0.d.mts} +2 -2
  172. package/dist/{spa-router.d-CO01mVOM.d.ts → spa-router.d-DqZ6Lfs0.d.ts} +2 -2
  173. package/dist/testing.d.mts +2 -2
  174. package/dist/testing.d.ts +2 -2
  175. package/dist/{utils.d-B77__yh8.d.ts → utils.d-Bv2MPeLR.d.ts} +1 -1
  176. package/dist/{utils.d-DRDazhCA.d.mts → utils.d-fqXe8lNc.d.mts} +1 -1
  177. package/dist/version.cjs +2 -2
  178. package/dist/version.mjs +1 -1
  179. package/dist/vite.cjs +14 -13
  180. package/dist/vite.d.mts +12 -6
  181. package/dist/vite.d.ts +12 -6
  182. package/dist/vite.mjs +13 -12
  183. package/package.json +1 -1
@@ -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;
@@ -25,13 +25,13 @@ var _chunkRD623KW4cjs = require('./chunk-RD623KW4.cjs');
25
25
 
26
26
 
27
27
 
28
- var _chunkNYQSC4DXcjs = require('./chunk-NYQSC4DX.cjs');
28
+ var _chunkFFE2EMF7cjs = require('./chunk-FFE2EMF7.cjs');
29
29
 
30
30
 
31
31
  var _chunkSG57PX7Kcjs = require('./chunk-SG57PX7K.cjs');
32
32
 
33
33
 
34
- var _chunkHIFIG6HLcjs = require('./chunk-HIFIG6HL.cjs');
34
+ var _chunkH33PJEXNcjs = require('./chunk-H33PJEXN.cjs');
35
35
 
36
36
 
37
37
 
@@ -68,7 +68,7 @@ var _chunkFK25QSVCcjs = require('./chunk-FK25QSVC.cjs');
68
68
  var _chunkWT6RAN2Icjs = require('./chunk-WT6RAN2I.cjs');
69
69
 
70
70
 
71
- var _chunkWJFFPXCVcjs = require('./chunk-WJFFPXCV.cjs');
71
+ var _chunkD7UQC4O6cjs = require('./chunk-D7UQC4O6.cjs');
72
72
 
73
73
 
74
74
  var _chunkCECUDGXQcjs = require('./chunk-CECUDGXQ.cjs');
@@ -144,13 +144,13 @@ function resolveFarmAgentConfig(input, context = {}) {
144
144
  const jsonLd = _optionalChain([input, 'optionalAccess', _ => _.jsonLd]);
145
145
  return {
146
146
  jsonLd: jsonLd === void 0 ? { ...DEFAULT_JSON_LD } : !jsonLd ? false : jsonLd === true ? {} : jsonLd,
147
- noindexPreviews: _chunkNYQSC4DXcjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
147
+ noindexPreviews: _chunkFFE2EMF7cjs.resolveFarmNoindexPreviews.call(void 0, _optionalChain([input, 'optionalAccess', _2 => _2.noindexPreviews])),
148
148
  // The docs engine answers /llms.txt with its own pages; a default here would replace it.
149
149
  // llms-full.txt renders every listed page, so it stays opt-in.
150
- llmsTxt: _chunkHIFIG6HLcjs.resolveFarmLlmsTxtConfig.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt]), () => ( (context.docs ? false : { full: false })))),
150
+ llmsTxt: _chunkH33PJEXNcjs.resolveFarmLlmsTxtConfig.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _3 => _3.llmsTxt]), () => ( (context.docs ? false : { full: false })))),
151
151
  // Same rule as llms.txt: the docs engine answers /sitemap.xml with its own pages.
152
- sitemap: _chunkNYQSC4DXcjs.resolveFarmAgentSitemap.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _4 => _4.sitemap]), () => ( !context.docs))),
153
- crawlers: _chunkNYQSC4DXcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _5 => _5.crawlers])),
152
+ sitemap: _chunkFFE2EMF7cjs.resolveFarmAgentSitemap.call(void 0, _nullishCoalesce(_optionalChain([input, 'optionalAccess', _4 => _4.sitemap]), () => ( !context.docs))),
153
+ crawlers: _chunkFFE2EMF7cjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([input, 'optionalAccess', _5 => _5.crawlers])),
154
154
  apiCatalog: resolveFarmAgentBoolean(_optionalChain([input, 'optionalAccess', _6 => _6.apiCatalog]), "apiCatalog", false),
155
155
  aiCatalog: resolveFarmAgentBoolean(_optionalChain([input, 'optionalAccess', _7 => _7.aiCatalog]), "aiCatalog", true),
156
156
  manifest: _chunkSG57PX7Kcjs.resolveFarmAppManifestConfig.call(void 0, _optionalChain([input, 'optionalAccess', _8 => _8.manifest])),
@@ -803,7 +803,7 @@ async function resolveConfig(userConfig, mode) {
803
803
  const srcDir = userConfig.srcDir || "src";
804
804
  _chunkBPNOYILCcjs.setFarmProjectSourceDir.call(void 0, root, srcDir);
805
805
  const docs = await resolveDocsConfig(userConfig.docs, { root, srcDir });
806
- const md = _chunkWJFFPXCVcjs.resolveMarkdownConfig.call(void 0, userConfig.md);
806
+ const md = _chunkD7UQC4O6cjs.resolveMarkdownConfig.call(void 0, userConfig.md);
807
807
  const mdx = _chunk2HW5LWAHcjs.resolveMdxConfig.call(void 0, userConfig.mdx);
808
808
  const env = _chunk3EIPOTZVcjs.resolveEnv.call(void 0, userConfig.env, process.env);
809
809
  _chunk3EIPOTZVcjs.setEnv.call(void 0, env);
@@ -885,6 +885,7 @@ async function resolveConfig(userConfig, mode) {
885
885
  },
886
886
  agent: resolveFarmAgentConfig(userConfig.agent, { docs: docs.enabled }),
887
887
  desktop: _nullishCoalesce(_optionalChain([desktopSetup, 'optionalAccess', _40 => _40.desktop]), () => ( null)),
888
+ ...userConfig.mobile !== void 0 ? { mobileClient: true } : {},
888
889
  plugins: [
889
890
  ...mobileSessionPlugin ? [mobileSessionPlugin] : [],
890
891
  ..._chunkCECUDGXQcjs.resolveIntegrationPlugins.call(void 0, integrations),
@@ -902,7 +903,7 @@ async function resolveConfig(userConfig, mode) {
902
903
  ],
903
904
  routeRules,
904
905
  images: _chunkHEPJIKKQcjs.resolveFarmImageConfig.call(void 0, userConfig.images),
905
- performance: _chunkNYQSC4DXcjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
906
+ performance: _chunkFFE2EMF7cjs.resolveFarmPerformanceConfig.call(void 0, userConfig.performance),
906
907
  theme: _chunkWT6RAN2Icjs.resolveFarmThemeConfig.call(void 0, userConfig.theme, basePath),
907
908
  publicDir: userConfig.publicDir || "public",
908
909
  i18n: _chunkLNVGXUL3cjs.resolveFarmI18nConfig.call(void 0, userConfig.i18n, { root, mode, basePath }),
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isFarmMetadataNoIndex
3
- } from "./chunk-LAZK6UV7.mjs";
3
+ } from "./chunk-YAJTD3ZG.mjs";
4
4
  import {
5
5
  matchesFarmMarkdownRoutePattern
6
- } from "./chunk-N77JBPLC.mjs";
6
+ } from "./chunk-LPDKG6RA.mjs";
7
7
  import {
8
8
  applyFarmBasePath
9
9
  } from "./chunk-SF3JB56B.mjs";
@@ -0,0 +1,6 @@
1
+ // src/mobile/native-tree-type.ts
2
+ var FARM_NATIVE_TREE_CONTENT_TYPE = "application/vnd.farm.native+json";
3
+
4
+ export {
5
+ FARM_NATIVE_TREE_CONTENT_TYPE
6
+ };
@@ -890,14 +890,15 @@ function extractHtmlTitle(html) {
890
890
  return match ? decodeHtml(stripTags(match[1])).trim() : void 0;
891
891
  }
892
892
  function readHtmlContentRegion(html) {
893
+ return extractHtmlBody(_readFarmRenderedHtml(html));
894
+ }
895
+ function _readFarmRenderedHtml(html) {
893
896
  const streamed = readStreamedBoundaryInstructions(html);
894
- return extractHtmlBody(
895
- removeHiddenElements(
896
- resolveStreamedBoundaries(
897
- html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ""),
898
- streamed
899
- ).replace(/<!--[\s\S]*?-->/g, "")
900
- )
897
+ return removeHiddenElements(
898
+ resolveStreamedBoundaries(
899
+ html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ""),
900
+ streamed
901
+ ).replace(/<!--[\s\S]*?-->/g, "")
901
902
  );
902
903
  }
903
904
  function extractHtmlBody(html) {
@@ -1353,5 +1354,6 @@ export {
1353
1354
  getFarmMarkdownAlternatePath,
1354
1355
  isFarmMarkdownMirrorExposed,
1355
1356
  matchesFarmMarkdownRoutePattern,
1357
+ _readFarmRenderedHtml,
1356
1358
  extractFarmPageActions
1357
1359
  };