@farm.js/core 0.1.62 → 0.1.64
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-OV4WRFBL.cjs → agent-mcp-handler-OXT73ZBY.cjs} +5 -5
- package/dist/{agent-mcp-handler-7QMX2LUY.mjs → agent-mcp-handler-QLFDDTYN.mjs} +4 -4
- package/dist/{agent-mcp.d-BKZ3UNbt.d.mts → agent-mcp.d-CO_ABmNK.d.mts} +1 -1
- package/dist/{agent-mcp.d-C1zr_nGS.d.ts → agent-mcp.d-QD2WZ9BS.d.ts} +1 -1
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/analyzer-ODLF2Z6O.cjs +16 -0
- package/dist/{analyzer-YESYU3GK.mjs → analyzer-Q3QXC6PD.mjs} +3 -2
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/{app-manifest.d-ntch_bvA.d.ts → app-manifest.d-BpKxiU_E.d.mts} +9 -1
- package/dist/{app-manifest.d-BpvhfKRH.d.mts → app-manifest.d-DDmNkYQQ.d.ts} +9 -1
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/{app.d-CysWA_8v.d.mts → app.d-kuoVWhWM.d.mts} +4 -4
- package/dist/{app.d-AE8_v3Db.d.ts → app.d-x68Cwr0_.d.ts} +4 -4
- package/dist/{chunk-LT4VAF5Z.cjs → chunk-2C5L5RPM.cjs} +7 -6
- package/dist/{chunk-RMUD75WT.cjs → chunk-3EBHJET2.cjs} +355 -270
- package/dist/{chunk-RZNCMRD3.mjs → chunk-6NHSGVVA.mjs} +1 -1
- package/dist/{chunk-LVWGURLD.mjs → chunk-6NNYPY5W.mjs} +327 -13
- package/dist/{chunk-PRFNLQSP.cjs → chunk-7XGWBPQQ.cjs} +4 -4
- package/dist/{chunk-SG57PX7K.cjs → chunk-BTVDYS4B.cjs} +7 -2
- package/dist/{chunk-545WJ5UG.cjs → chunk-DUSHDZQL.cjs} +11 -11
- package/dist/{chunk-GVOMPU3Y.cjs → chunk-EL4364S2.cjs} +209 -32
- package/dist/{chunk-GGNJAGGE.cjs → chunk-FAP7CX7C.cjs} +1056 -529
- package/dist/{chunk-T46NNU4D.mjs → chunk-FH45OB37.mjs} +2 -2
- package/dist/{chunk-55U5QIXQ.mjs → chunk-FIR62CR3.mjs} +1 -1
- package/dist/{chunk-MEQN6DDA.cjs → chunk-FJWN7RV4.cjs} +5 -5
- package/dist/chunk-IOEXXZK3.mjs +88 -0
- package/dist/{chunk-EXXFSZOC.cjs → chunk-JCPSA4X5.cjs} +135 -134
- package/dist/{chunk-YSXTNSXS.mjs → chunk-K7OZAVOI.mjs} +7 -6
- package/dist/{chunk-KVW2M6PI.mjs → chunk-KL7SHLQB.mjs} +1 -1
- package/dist/{chunk-NT3QDN2E.mjs → chunk-LQDLEWPO.mjs} +1 -1
- package/dist/{chunk-UZZ6IEQP.mjs → chunk-MESQF2JC.mjs} +2 -2
- package/dist/{chunk-WKJQ2FJA.cjs → chunk-MG356ROI.cjs} +5 -5
- package/dist/{chunk-AJB3DHN6.cjs → chunk-N3Z3PLHC.cjs} +2 -2
- package/dist/{chunk-2CNKQC3G.mjs → chunk-NNLFW3P4.mjs} +2 -2
- package/dist/{chunk-XX32BOMM.cjs → chunk-NXFA7G3Y.cjs} +52 -26
- package/dist/{chunk-SM25ZC4S.cjs → chunk-O2XFIPNL.cjs} +1 -1
- package/dist/{chunk-VWW4Q3BJ.mjs → chunk-O4FWNLQK.mjs} +4 -4
- package/dist/{chunk-DZPR2W6U.cjs → chunk-O6L3YYPM.cjs} +5 -5
- package/dist/{chunk-UWI3SJAK.cjs → chunk-O7IEMY55.cjs} +3 -3
- package/dist/{chunk-6BJJYOFL.cjs → chunk-OLIGNTWU.cjs} +7 -7
- package/dist/{chunk-OUWRNHTV.mjs → chunk-OYF23QLG.mjs} +17 -16
- package/dist/{chunk-IQIKPKFP.mjs → chunk-RAH5MT53.mjs} +110 -25
- package/dist/{chunk-E72UD6ME.mjs → chunk-RVGSVQWT.mjs} +1 -1
- package/dist/{chunk-ZVIEFTUA.cjs → chunk-S25BQIFW.cjs} +16 -16
- package/dist/chunk-S7ZW72JH.cjs +254 -0
- package/dist/{chunk-VM7X5CKC.mjs → chunk-SLYDIHLW.mjs} +31 -5
- package/dist/chunk-SNFTMSHX.mjs +254 -0
- package/dist/{chunk-2WZTGPK6.mjs → chunk-SQ5O7I3L.mjs} +7 -2
- package/dist/{chunk-PCXIJKPM.mjs → chunk-TNBJ4LZG.mjs} +2 -2
- package/dist/{chunk-O27PLNQZ.cjs → chunk-UJ3R2AH2.cjs} +4 -4
- package/dist/{chunk-T4TBK5NY.mjs → chunk-VQ4NWOWO.mjs} +2 -2
- package/dist/{chunk-ZZ2QKCKW.mjs → chunk-WAY6LOQH.mjs} +1 -1
- package/dist/chunk-WBTHHTBO.cjs +88 -0
- package/dist/{chunk-ZBUAOGMY.mjs → chunk-WFNAOWH4.mjs} +1 -1
- package/dist/{chunk-IWRLV46X.cjs → chunk-WMTBBQHY.cjs} +4 -4
- package/dist/{chunk-2JYBLE63.mjs → chunk-WNYRYI4D.mjs} +770 -243
- package/dist/{chunk-CI4UNQHO.cjs → chunk-XBSKPLHF.cjs} +2 -2
- package/dist/{chunk-IOF4KXMP.mjs → chunk-XVWSDSUM.mjs} +201 -24
- package/dist/{chunk-JEJQGZI7.cjs → chunk-XZLZ6YPP.cjs} +346 -32
- package/dist/{chunk-QAS7KE7J.cjs → chunk-Y5TOT5F6.cjs} +5 -5
- package/dist/{chunk-DPE53XWL.mjs → chunk-ZEXE4TGY.mjs} +1 -1
- package/dist/{client-component.d-BoqC2MLC.d.mts → client-component.d-D74pqdea.d.mts} +14 -3
- package/dist/{client-component.d-Bgt3x5Fu.d.ts → client-component.d-D8VcypQA.d.ts} +14 -3
- package/dist/{client-plugins.d-BcqIy4au.d.ts → client-plugins.d-CXElzotB.d.ts} +18 -2
- package/dist/{client-plugins.d-CWyYBxXf.d.mts → client-plugins.d-D4-6hNx7.d.mts} +18 -2
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.d.mts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/desktop.d.mts +2 -2
- package/dist/desktop.d.ts +2 -2
- package/dist/{devtools-NUVXYG7I.mjs → devtools-MX3FE733.mjs} +5 -5
- package/dist/{devtools-SVRSGPNC.cjs → devtools-WET5NAKO.cjs} +6 -6
- package/dist/docs.cjs +8 -8
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +7 -7
- package/dist/index.cjs +21 -20
- package/dist/{index.d-nAncqTXz.d.ts → index.d-A_x10zGS.d.ts} +1 -1
- package/dist/{index.d-BDaiu2i5.d.mts → index.d-SSgYDv4D.d.mts} +1 -1
- package/dist/index.d.mts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.mjs +20 -19
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +22 -21
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +21 -20
- 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 +4 -4
- package/dist/internal/client-runtime.d.ts +4 -4
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +7 -7
- package/dist/internal/config-runtime.d.mts +4 -4
- package/dist/internal/config-runtime.d.ts +4 -4
- package/dist/internal/config-runtime.mjs +6 -6
- package/dist/internal/infra-analytics-runtime.cjs +11 -9
- package/dist/internal/infra-analytics-runtime.mjs +9 -7
- package/dist/internal/native-server-fns.cjs +5 -4
- package/dist/internal/native-server-fns.mjs +4 -3
- package/dist/internal/product-telemetry-runtime.cjs +17 -211
- package/dist/internal/product-telemetry-runtime.mjs +10 -204
- package/dist/internal/production-runtime.cjs +13 -12
- package/dist/internal/production-runtime.d.mts +13 -12
- package/dist/internal/production-runtime.d.ts +13 -12
- package/dist/internal/production-runtime.mjs +14 -13
- package/dist/internal/react-cache.cjs +21 -1
- package/dist/internal/react-cache.d.mts +8 -1
- package/dist/internal/react-cache.d.ts +8 -1
- package/dist/internal/react-cache.mjs +21 -1
- package/dist/markdown.cjs +2 -2
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/mobile.d.mts +2 -2
- package/dist/mobile.d.ts +2 -2
- package/dist/{native-tree-AS5L3ID3.mjs → native-tree-BPEE2LAL.mjs} +2 -2
- package/dist/{native-tree-Z2WYUJEV.cjs → native-tree-WOX3JMBG.cjs} +3 -3
- package/dist/{navigation-delegate.d-CSCm8ZxL.d.mts → navigation-delegate.d-DQVYKoaZ.d.mts} +1 -1
- package/dist/{navigation-delegate.d-BbUHRXxG.d.ts → navigation-delegate.d-GghbHJuK.d.ts} +1 -1
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/plugin.cjs +14 -14
- package/dist/plugin.d.mts +3 -3
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.mjs +13 -13
- package/dist/{production-runtime.d-DgT24A0f.d.ts → production-runtime.d-Bzns3NW9.d.ts} +1 -1
- package/dist/{production-runtime.d-CcQiDko5.d.mts → production-runtime.d-DiFa5vHW.d.mts} +1 -1
- package/dist/{render-plan.d-CyrX6MDs.d.ts → render-plan.d-CL_Ikfg_.d.ts} +1 -1
- package/dist/{render-plan.d-BH9WF-JZ.d.mts → render-plan.d-CcF0MeCf.d.mts} +1 -1
- package/dist/renderer-client.d.mts +4 -4
- package/dist/renderer-client.d.ts +4 -4
- package/dist/{request.d-BB8M8bcD.d.ts → request.d-B1RnTLri.d.ts} +1 -1
- package/dist/{request.d-CUrPnCW7.d.mts → request.d-DarDOCk9.d.mts} +1 -1
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/{route-rendering.d-DYqZMIf4.d.ts → route-rendering.d-BTUYCIj4.d.ts} +1 -1
- package/dist/{route-rendering.d-CYxlzaFm.d.mts → route-rendering.d-D_2Ual0-.d.mts} +1 -1
- package/dist/{router.d-DaKo507j.d.ts → router.d-CMANF6da.d.ts} +1 -1
- package/dist/{router.d-7o24CD8u.d.mts → router.d-Cuv1jntg.d.mts} +1 -1
- package/dist/{routes.d-BknKQcTu.d.ts → routes.d-B6yFe6jm.d.ts} +1 -1
- package/dist/{routes.d-D1IrO9KK.d.mts → routes.d-c2HKfrfL.d.mts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/{rsc-pipeline-RFLHDAKD.mjs → rsc-pipeline-3LNVP2OO.mjs} +6 -6
- package/dist/{rsc-pipeline-OF2I7PCX.cjs → rsc-pipeline-G5WELVW3.cjs} +7 -7
- package/dist/{runtime-LBTK62AD.cjs → runtime-DMEULPE7.cjs} +22 -11
- package/dist/{runtime-M6UJCSLA.mjs → runtime-HQJ2LLQL.mjs} +20 -9
- package/dist/{runtime.d-CN73a-IL.d.ts → runtime.d-C3RQUj6_.d.ts} +1 -1
- package/dist/{runtime.d-CcNuzhX6.d.mts → runtime.d-wvh4ngU0.d.mts} +1 -1
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server.cjs +31 -31
- package/dist/server.d.mts +9 -9
- package/dist/server.d.ts +9 -9
- package/dist/server.mjs +16 -16
- package/dist/{spa-router.d-CNi77LZm.d.mts → spa-router.d-WU_qS5gJ.d.mts} +2 -2
- package/dist/{spa-router.d-Cvgf5QP4.d.ts → spa-router.d-m8H_Kl_B.d.ts} +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{utils.d-C3H-14_Y.d.ts → utils.d-C9dQD5Zg.d.ts} +1 -1
- package/dist/{utils.d-D8VfzZYn.d.mts → utils.d-W9IiEqmW.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +18 -14
- package/dist/vite.d.mts +23 -5
- package/dist/vite.d.ts +23 -5
- package/dist/vite.mjs +17 -13
- package/package.json +1 -1
- package/dist/analyzer-2AHWJJR7.cjs +0 -15
- package/dist/chunk-CSLUBKGG.mjs +0 -44
- package/dist/chunk-SGBNF56S.cjs +0 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7XGWBPQQcjs = require('./chunk-7XGWBPQQ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/app-markdown.ts
|
|
6
6
|
var _promises = require('fs/promises');
|
|
@@ -8,7 +8,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
8
8
|
var _url = require('url');
|
|
9
9
|
async function createFarmMarkdownRouteModuleFromFile(filePath, options = {}) {
|
|
10
10
|
const source = await _promises.readFile.call(void 0, filePath, "utf8");
|
|
11
|
-
return
|
|
11
|
+
return _chunk7XGWBPQQcjs.createFarmMarkdownRouteModule.call(void 0, {
|
|
12
12
|
source,
|
|
13
13
|
filePath,
|
|
14
14
|
components: options.components,
|
|
@@ -10,9 +10,13 @@ import {
|
|
|
10
10
|
} from "./chunk-LLZSYFOM.mjs";
|
|
11
11
|
import {
|
|
12
12
|
_readFarmRenderedHtml
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-K7OZAVOI.mjs";
|
|
14
14
|
|
|
15
15
|
// src/mobile/native-tree.ts
|
|
16
|
+
var URLENCODED = "application/x-www-form-urlencoded";
|
|
17
|
+
var MULTIPART = "multipart/form-data";
|
|
18
|
+
var TEXT_INPUT_TYPES = /* @__PURE__ */ new Set(["text", "email", "password", "number", "search", "tel", "url"]);
|
|
19
|
+
var CONTROL_TAGS = /* @__PURE__ */ new Set(["input", "textarea", "select", "button"]);
|
|
16
20
|
var VIEW_TAGS = new Set(
|
|
17
21
|
"div section main article header footer nav aside figure ul ol li hr".split(" ")
|
|
18
22
|
);
|
|
@@ -118,15 +122,29 @@ function settleLineHeight(style) {
|
|
|
118
122
|
}
|
|
119
123
|
return rest;
|
|
120
124
|
}
|
|
125
|
+
function labelText(element) {
|
|
126
|
+
const text = (node) => typeof node === "string" ? node : CONTROL_TAGS.has(node.tag) || node.tag === "option" ? " " : node.children.map(text).join("");
|
|
127
|
+
return text(element).replace(/\s+/g, " ").trim();
|
|
128
|
+
}
|
|
129
|
+
function findNode(node, test) {
|
|
130
|
+
for (const child of node.children ?? []) {
|
|
131
|
+
if (typeof child === "string") continue;
|
|
132
|
+
if (test(child)) return child;
|
|
133
|
+
const found = findNode(child, test);
|
|
134
|
+
if (found) return found;
|
|
135
|
+
}
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
121
138
|
var Converter = class {
|
|
122
139
|
/**
|
|
123
140
|
* `sheets`: the page's stylesheets. Without them, a class the Tailwind table does not know is
|
|
124
141
|
* reported; with them, only one a layered (Tailwind) rule styles is, since a class no rule
|
|
125
142
|
* styles has no effect in a browser either.
|
|
126
143
|
*/
|
|
127
|
-
constructor(pageUrl, sheets) {
|
|
144
|
+
constructor(pageUrl, sheets, labels = /* @__PURE__ */ new Map()) {
|
|
128
145
|
this.pageUrl = pageUrl;
|
|
129
146
|
this.sheets = sheets;
|
|
147
|
+
this.labels = labels;
|
|
130
148
|
this.unsupported = [];
|
|
131
149
|
/** Off while reading the ancestors above the page, which pass down text styles only. */
|
|
132
150
|
this.reporting = true;
|
|
@@ -176,14 +194,75 @@ var Converter = class {
|
|
|
176
194
|
return void 0;
|
|
177
195
|
}
|
|
178
196
|
}
|
|
197
|
+
/** A form's or button's action: absolute http(s), without a fragment; empty means this page. */
|
|
198
|
+
formUrl(value, what) {
|
|
199
|
+
let url;
|
|
200
|
+
try {
|
|
201
|
+
url = new URL(value ?? "", this.pageUrl);
|
|
202
|
+
} catch {
|
|
203
|
+
this.problem(`${what} "${value}"`);
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
207
|
+
this.problem(`${what} "${value}"`);
|
|
208
|
+
return void 0;
|
|
209
|
+
}
|
|
210
|
+
url.hash = "";
|
|
211
|
+
return url.href;
|
|
212
|
+
}
|
|
213
|
+
method(value, what) {
|
|
214
|
+
const method = value?.toLowerCase();
|
|
215
|
+
if (method === void 0 || method === "") return void 0;
|
|
216
|
+
if (method === "get" || method === "post") return method;
|
|
217
|
+
this.problem(`${what} method "${value}"`);
|
|
218
|
+
return void 0;
|
|
219
|
+
}
|
|
220
|
+
enctype(value, what) {
|
|
221
|
+
const enctype = value?.toLowerCase();
|
|
222
|
+
if (enctype === void 0 || enctype === "") return void 0;
|
|
223
|
+
if (enctype === URLENCODED || enctype === MULTIPART) return enctype;
|
|
224
|
+
this.problem(`${what} enctype "${value}"`);
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
/** What a submit button sends besides its form's fields, and where. */
|
|
228
|
+
submitter(element) {
|
|
229
|
+
const { name, value, formaction, formmethod, formenctype, formtarget } = element.attributes;
|
|
230
|
+
if (formtarget && formtarget !== "_self") this.problem(`<${element.tag}> formtarget`);
|
|
231
|
+
const action = formaction === void 0 ? void 0 : this.formUrl(formaction, `<${element.tag}> formaction`);
|
|
232
|
+
const method = this.method(formmethod, `<${element.tag}>`);
|
|
233
|
+
const enctype = this.enctype(formenctype, `<${element.tag}>`);
|
|
234
|
+
return {
|
|
235
|
+
...name ? { name, value: value ?? "" } : {},
|
|
236
|
+
...action ? { action } : {},
|
|
237
|
+
...method ? { method } : {},
|
|
238
|
+
...enctype ? { enctype } : {}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/** A `<label>` that wraps a field draws as a box: its text, then the field. */
|
|
242
|
+
holdsControl(element) {
|
|
243
|
+
return element.children.some(
|
|
244
|
+
(child) => typeof child !== "string" && (CONTROL_TAGS.has(child.tag) || this.holdsControl(child))
|
|
245
|
+
);
|
|
246
|
+
}
|
|
179
247
|
node(type, element, style, dark) {
|
|
180
248
|
const changed = dark && Object.fromEntries(Object.entries(dark).filter(([key, value]) => style?.[key] !== value));
|
|
181
|
-
|
|
249
|
+
const node = {
|
|
182
250
|
type,
|
|
183
251
|
tag: element.tag,
|
|
184
252
|
...style && Object.keys(style).length > 0 ? { style } : {},
|
|
185
253
|
...changed && Object.keys(changed).length > 0 ? { dark: changed } : {}
|
|
186
254
|
};
|
|
255
|
+
const { role } = element.attributes;
|
|
256
|
+
const level = /^h([1-6])$/.exec(element.tag)?.[1] ?? (role === "heading" ? element.attributes["aria-level"] ?? "2" : void 0);
|
|
257
|
+
if (type === "Text" && level && Number(level) >= 1 && Number(level) <= 6) {
|
|
258
|
+
node.heading = Number(level);
|
|
259
|
+
}
|
|
260
|
+
const label = element.attributes["aria-label"]?.trim();
|
|
261
|
+
if (label) node.label = label;
|
|
262
|
+
if (element.attributes["aria-hidden"] === "true" || role === "presentation" || role === "none" || element.tag === "img" && element.attributes.alt === "") {
|
|
263
|
+
node.hidden = true;
|
|
264
|
+
}
|
|
265
|
+
return node;
|
|
187
266
|
}
|
|
188
267
|
/** Inline content: runs of text, nested inline elements, and line breaks. */
|
|
189
268
|
inline(content, inherited) {
|
|
@@ -266,7 +345,7 @@ var Converter = class {
|
|
|
266
345
|
pending = [];
|
|
267
346
|
};
|
|
268
347
|
for (const child of content) {
|
|
269
|
-
if (typeof child === "string" || INLINE_TAGS.has(child.tag) && !this.isBlockLink(child)) {
|
|
348
|
+
if (typeof child === "string" || INLINE_TAGS.has(child.tag) && !this.isBlockLink(child) && !(child.tag === "label" && this.holdsControl(child))) {
|
|
270
349
|
pending.push(child);
|
|
271
350
|
continue;
|
|
272
351
|
}
|
|
@@ -277,8 +356,31 @@ var Converter = class {
|
|
|
277
356
|
flush();
|
|
278
357
|
return nodes;
|
|
279
358
|
}
|
|
359
|
+
/** `<input type="submit">`: a button whose label is its value. */
|
|
360
|
+
submitButton(element, passed, box, boxDark) {
|
|
361
|
+
const node = this.node("Pressable", element, box, boxDark);
|
|
362
|
+
const label = this.text(
|
|
363
|
+
{ tag: "#text", attributes: {}, children: [] },
|
|
364
|
+
[element.attributes.value ?? "Submit"],
|
|
365
|
+
passed
|
|
366
|
+
);
|
|
367
|
+
if (label) node.children = [label];
|
|
368
|
+
if (element.attributes.disabled !== void 0) node.disabled = true;
|
|
369
|
+
else node.submit = this.submitter(element);
|
|
370
|
+
return node;
|
|
371
|
+
}
|
|
280
372
|
element(element, inherited, flexItem = false) {
|
|
281
373
|
if (SKIPPED_TAGS.has(element.tag)) return void 0;
|
|
374
|
+
if (element.attributes.form !== void 0 && CONTROL_TAGS.has(element.tag)) {
|
|
375
|
+
this.problem(`<${element.tag}> form="${element.attributes.form}"`);
|
|
376
|
+
}
|
|
377
|
+
if (element.tag === "input" && element.attributes.type?.toLowerCase() === "hidden") {
|
|
378
|
+
const { name, value, disabled } = element.attributes;
|
|
379
|
+
if (this.form && name && disabled === void 0) {
|
|
380
|
+
this.form.fields.push({ name, value: value ?? "" });
|
|
381
|
+
}
|
|
382
|
+
return void 0;
|
|
383
|
+
}
|
|
282
384
|
const own = this.stylesOf(element);
|
|
283
385
|
if (own.style.display === "none") return void 0;
|
|
284
386
|
const passed = {
|
|
@@ -296,6 +398,15 @@ var Converter = class {
|
|
|
296
398
|
const box = current(withoutText(own.style), passed.style.color);
|
|
297
399
|
const boxDark = current(withoutText(own.dark), passed.dark.color ?? passed.style.color);
|
|
298
400
|
const flex = own.style.display === "flex";
|
|
401
|
+
if (element.tag === "label" && this.holdsControl(element)) {
|
|
402
|
+
const node = this.node("View", element, box, boxDark);
|
|
403
|
+
const children = this.blocks(element.children, passed, flex);
|
|
404
|
+
if (children.length > 0) node.children = children;
|
|
405
|
+
const text = labelText(element);
|
|
406
|
+
const field = findNode(node, (child) => child.type === "TextInput");
|
|
407
|
+
if (text && field && !field.label) field.label = text;
|
|
408
|
+
return node;
|
|
409
|
+
}
|
|
299
410
|
const textBox = flexItem && INLINE_TAGS.has(element.tag) && element.tag !== "a" && element.tag !== "br";
|
|
300
411
|
if (BLOCK_TEXT_TAGS.has(element.tag) || textBox) {
|
|
301
412
|
if (element.children.some((child) => typeof child !== "string" && !INLINE_TAGS.has(child.tag))) {
|
|
@@ -311,21 +422,76 @@ var Converter = class {
|
|
|
311
422
|
if (!node.src) this.problem("<img> without src");
|
|
312
423
|
return node;
|
|
313
424
|
}
|
|
425
|
+
if (element.tag === "form") {
|
|
426
|
+
if (this.form) {
|
|
427
|
+
this.problem("<form> inside a form");
|
|
428
|
+
return void 0;
|
|
429
|
+
}
|
|
430
|
+
const { action, method, enctype, target } = element.attributes;
|
|
431
|
+
if (target && target !== "_self") this.problem(`<form> target="${target}"`);
|
|
432
|
+
const node = this.node("View", element, box, boxDark);
|
|
433
|
+
const form = {
|
|
434
|
+
action: this.formUrl(action, "<form> action") ?? "",
|
|
435
|
+
method: this.method(method, "<form>") ?? "get"
|
|
436
|
+
};
|
|
437
|
+
if (this.enctype(enctype, "<form>") === MULTIPART) form.enctype = MULTIPART;
|
|
438
|
+
this.form = { fields: [] };
|
|
439
|
+
try {
|
|
440
|
+
const children = this.blocks(element.children, passed, flex);
|
|
441
|
+
if (children.length > 0) node.children = children;
|
|
442
|
+
if (this.form.fields.length > 0) form.fields = this.form.fields;
|
|
443
|
+
} finally {
|
|
444
|
+
this.form = void 0;
|
|
445
|
+
}
|
|
446
|
+
node.form = form;
|
|
447
|
+
return node;
|
|
448
|
+
}
|
|
314
449
|
if (element.tag === "input" || element.tag === "textarea") {
|
|
450
|
+
const { attributes } = element;
|
|
451
|
+
const type = element.tag === "input" ? (attributes.type ?? "text").toLowerCase() : "text";
|
|
452
|
+
if (!this.form) this.problem(`<${element.tag}> has no form to submit it`);
|
|
453
|
+
if (type === "submit") return this.submitButton(element, passed, box, boxDark);
|
|
454
|
+
if (!TEXT_INPUT_TYPES.has(type)) this.problem(`<input type="${type}">`);
|
|
315
455
|
const node = this.node(
|
|
316
456
|
"TextInput",
|
|
317
457
|
element,
|
|
318
458
|
settleLineHeight({ ...passed.style, ...box }),
|
|
319
459
|
boxDark
|
|
320
460
|
);
|
|
321
|
-
if (
|
|
322
|
-
|
|
461
|
+
if (attributes.name) node.name = attributes.name;
|
|
462
|
+
if (!node.label && attributes.id && this.labels.has(attributes.id)) {
|
|
463
|
+
node.label = this.labels.get(attributes.id);
|
|
464
|
+
}
|
|
465
|
+
if (type !== "text") node.inputType = type;
|
|
466
|
+
if (element.tag === "textarea") node.multiline = true;
|
|
467
|
+
if (attributes.placeholder) node.placeholder = attributes.placeholder;
|
|
468
|
+
const value = element.tag === "textarea" ? textContent(element) : attributes.value;
|
|
323
469
|
if (value) node.value = value;
|
|
470
|
+
if (attributes.required !== void 0) node.required = true;
|
|
471
|
+
if (attributes.disabled !== void 0) node.disabled = true;
|
|
472
|
+
if (attributes.readonly !== void 0) node.readOnly = true;
|
|
473
|
+
const maxLength = Number(attributes.maxlength);
|
|
474
|
+
if (attributes.maxlength && Number.isInteger(maxLength) && maxLength >= 0) {
|
|
475
|
+
node.maxLength = maxLength;
|
|
476
|
+
}
|
|
324
477
|
return node;
|
|
325
478
|
}
|
|
326
|
-
if (element.tag === "
|
|
479
|
+
if (element.tag === "button") {
|
|
480
|
+
const type = (element.attributes.type ?? "submit").toLowerCase();
|
|
481
|
+
if (!this.form) {
|
|
482
|
+
this.problem("<button> has no link or form to submit");
|
|
483
|
+
} else if (type !== "submit") {
|
|
484
|
+
this.problem(`<button type="${type}">`);
|
|
485
|
+
}
|
|
327
486
|
const node = this.node("Pressable", element, box, boxDark);
|
|
328
|
-
|
|
487
|
+
node.children = this.blocks(element.children, passed, flex);
|
|
488
|
+
if (element.attributes.disabled !== void 0) node.disabled = true;
|
|
489
|
+
else node.submit = this.submitter(element);
|
|
490
|
+
return node;
|
|
491
|
+
}
|
|
492
|
+
if (element.tag === "a") {
|
|
493
|
+
const node = this.node("Pressable", element, box, boxDark);
|
|
494
|
+
node.href = this.url(element.attributes.href);
|
|
329
495
|
node.children = this.blocks(element.children, passed, flex);
|
|
330
496
|
return node;
|
|
331
497
|
}
|
|
@@ -420,9 +586,18 @@ function parsedStylesheet(css) {
|
|
|
420
586
|
}
|
|
421
587
|
function createFarmNativeTree(html, pageUrl, stylesheets) {
|
|
422
588
|
const title = /<title\b[^>]*>([\s\S]*?)<\/title>/i.exec(html)?.[1];
|
|
423
|
-
const document = parseHtml(_readFarmRenderedHtml(html));
|
|
589
|
+
const document = parseHtml(_readFarmRenderedHtml(html, { keepAriaHidden: true }));
|
|
424
590
|
const page = find(document, (element) => element.attributes.id === "__farm_page__") ?? find(document, (element) => element.attributes.id === "root") ?? find(document, (element) => element.tag === "body") ?? document;
|
|
425
|
-
const
|
|
591
|
+
const labels = /* @__PURE__ */ new Map();
|
|
592
|
+
const collectLabels = (element) => {
|
|
593
|
+
if (element.tag === "label" && element.attributes.for) {
|
|
594
|
+
const text = labelText(element);
|
|
595
|
+
if (text) labels.set(element.attributes.for, text);
|
|
596
|
+
}
|
|
597
|
+
for (const child of element.children) if (typeof child !== "string") collectLabels(child);
|
|
598
|
+
};
|
|
599
|
+
collectLabels(page);
|
|
600
|
+
const converter = new Converter(pageUrl, stylesheets?.map(parsedStylesheet), labels);
|
|
426
601
|
const ancestors = [];
|
|
427
602
|
for (let element = page.parent; element; element = element.parent) ancestors.unshift(element);
|
|
428
603
|
const inherited = { style: {}, dark: {} };
|
|
@@ -478,15 +653,15 @@ async function createFarmNativeTreeResponse(options) {
|
|
|
478
653
|
const headers = new Headers(options.request.headers);
|
|
479
654
|
headers.set("accept", "text/html");
|
|
480
655
|
headers.delete("accept-encoding");
|
|
656
|
+
const submitted = options.request.method === "POST";
|
|
657
|
+
const init = submitted ? { method: "POST", headers, body: options.request.body, duplex: "half" } : { method: "GET", headers };
|
|
481
658
|
const page = await options.renderPage(
|
|
482
|
-
new Request(options.request.url, {
|
|
483
|
-
method: "GET",
|
|
484
|
-
headers,
|
|
485
|
-
signal: options.request.signal
|
|
486
|
-
})
|
|
659
|
+
new Request(options.request.url, { ...init, signal: options.request.signal })
|
|
487
660
|
);
|
|
661
|
+
const cookies = page.headers.getSetCookie?.() ?? [];
|
|
488
662
|
const type = page.headers.get("content-type") ?? "";
|
|
489
|
-
|
|
663
|
+
const drawn = page.status === 200 || submitted && page.status >= 400 && page.status < 500;
|
|
664
|
+
if (!drawn || !type.includes("text/html")) return page;
|
|
490
665
|
const html = await page.text();
|
|
491
666
|
const pageUrl = new URL(options.request.url);
|
|
492
667
|
const load = options.loadStylesheet ?? (async (href) => {
|
|
@@ -507,12 +682,13 @@ async function createFarmNativeTreeResponse(options) {
|
|
|
507
682
|
root: { type: "View", tag: "#root" },
|
|
508
683
|
unsupported: [`stylesheet "${source.href}" could not be read`]
|
|
509
684
|
};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
685
|
+
const out2 = new Headers({
|
|
686
|
+
"Content-Type": `${FARM_NATIVE_TREE_CONTENT_TYPE}; charset=utf-8`,
|
|
687
|
+
Vary: "Accept",
|
|
688
|
+
"Cache-Control": "no-store"
|
|
515
689
|
});
|
|
690
|
+
for (const cookie of cookies) out2.append("Set-Cookie", cookie);
|
|
691
|
+
return new Response(JSON.stringify(tree2), { headers: out2 });
|
|
516
692
|
}
|
|
517
693
|
stylesheets.push(css);
|
|
518
694
|
}
|
|
@@ -520,11 +696,12 @@ async function createFarmNativeTreeResponse(options) {
|
|
|
520
696
|
const out = new Headers({
|
|
521
697
|
"Content-Type": `${FARM_NATIVE_TREE_CONTENT_TYPE}; charset=utf-8`,
|
|
522
698
|
Vary: "Accept",
|
|
523
|
-
|
|
699
|
+
// The answer to a POST is that submission's result, never a cacheable page.
|
|
700
|
+
"Cache-Control": (submitted ? void 0 : page.headers.get("cache-control")) ?? "no-store"
|
|
524
701
|
});
|
|
525
|
-
for (const cookie of
|
|
702
|
+
for (const cookie of cookies) out.append("Set-Cookie", cookie);
|
|
526
703
|
return new Response(options.request.method === "HEAD" ? null : JSON.stringify(tree), {
|
|
527
|
-
status:
|
|
704
|
+
status: page.status,
|
|
528
705
|
headers: out
|
|
529
706
|
});
|
|
530
707
|
}
|