@farm.js/core 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime.d.mts +3 -2
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/api/client.cjs +4 -6
- package/dist/api/client.d.mts +1 -0
- package/dist/api/client.d.ts +1 -0
- package/dist/api/client.mjs +3 -5
- package/dist/api/route-manager.cjs +9 -8
- package/dist/api/route-manager.d.mts +2 -1
- package/dist/api/route-manager.d.ts +2 -1
- package/dist/api/route-manager.mjs +8 -7
- package/dist/api/runtime.cjs +7 -6
- package/dist/api/runtime.d.mts +3 -2
- package/dist/api/runtime.d.ts +3 -2
- package/dist/api/runtime.mjs +6 -5
- package/dist/api.cjs +12 -11
- package/dist/api.d.mts +19 -4
- package/dist/api.d.ts +19 -4
- package/dist/api.mjs +11 -10
- package/dist/{app-BfzZdjgX.d.mts → app-DAuUTIZf.d.mts} +3 -3
- package/dist/app-markdown.cjs +6 -5
- package/dist/app-markdown.d.mts +4 -3
- package/dist/app-markdown.d.ts +4 -3
- package/dist/app-markdown.mjs +5 -4
- package/dist/{app-CXK7Prrt.d.ts → app-sUJ3jnTZ.d.ts} +3 -3
- package/dist/cache-invalidation-BD0z_lfu.d.mts +4 -0
- package/dist/cache-invalidation-BD0z_lfu.d.ts +4 -0
- package/dist/cache.cjs +6 -4
- package/dist/cache.d.mts +11 -6
- package/dist/cache.d.ts +11 -6
- package/dist/cache.mjs +7 -5
- package/dist/{chunk-N6UROPT7.mjs → chunk-2FQHH5SC.mjs} +12 -13
- package/dist/{chunk-UUYF3CHN.mjs → chunk-2N5PX3LS.mjs} +2 -2
- package/dist/{chunk-H6G5INWM.cjs → chunk-2SDO73HK.cjs} +14 -156
- package/dist/{chunk-4FHDV7VM.mjs → chunk-2UABTL3Y.mjs} +2 -2
- package/dist/{chunk-LAHZ7LZA.cjs → chunk-3FCFQP5V.cjs} +32 -20
- package/dist/{chunk-3TQWUUNP.cjs → chunk-3LUF2PE2.cjs} +10 -5
- package/dist/{chunk-SYGGPS4A.mjs → chunk-4IEPYMHF.mjs} +3 -3
- package/dist/{chunk-WD5PNSOB.mjs → chunk-4V7GIE2U.mjs} +6 -4
- package/dist/{chunk-UWTQTZFN.mjs → chunk-5KDPVSS3.mjs} +271 -155
- package/dist/{chunk-I7PUUDGY.cjs → chunk-63H6BKXG.cjs} +2 -2
- package/dist/{chunk-ZSO5GWGD.cjs → chunk-6CNX6Q3K.cjs} +168 -51
- package/dist/{chunk-3PTVHMLD.mjs → chunk-6G3ZZ2IE.mjs} +1 -1
- package/dist/{chunk-QBPXNZGV.cjs → chunk-6MVFL3R5.cjs} +25 -6
- package/dist/{chunk-FG5H2VCJ.mjs → chunk-6ZCMSZ5U.mjs} +2 -2
- package/dist/{chunk-YZBV7733.cjs → chunk-74T3CEA7.cjs} +397 -281
- package/dist/{chunk-ZMN3H73H.cjs → chunk-75DYEVXI.cjs} +13 -11
- package/dist/{chunk-WIVTGKLY.mjs → chunk-7CXKSRKL.mjs} +18 -11
- package/dist/{chunk-POXI72VV.mjs → chunk-ATXI6LGT.mjs} +148 -31
- package/dist/{chunk-NL3ZSMZB.cjs → chunk-BJPBQNIE.cjs} +12 -12
- package/dist/{chunk-Q4BHBO6V.mjs → chunk-BXFWA23T.mjs} +2 -2
- package/dist/{chunk-MBFURXAC.mjs → chunk-BZ3CHOFX.mjs} +1 -1
- package/dist/{chunk-TDWFCC2T.cjs → chunk-BZAGKCKB.cjs} +2 -2
- package/dist/chunk-CNOQY6Z7.mjs +156 -0
- package/dist/{chunk-DW34V5SM.cjs → chunk-CTV2TTNP.cjs} +4 -4
- package/dist/{chunk-HG237IEY.mjs → chunk-D234YWNA.mjs} +1 -1
- package/dist/{chunk-YXM74XOW.cjs → chunk-D4JE5NNV.cjs} +12 -12
- package/dist/{chunk-O2LV5XDG.mjs → chunk-DGXN3L4D.mjs} +20 -8
- package/dist/{chunk-4UNKCNSL.mjs → chunk-E76XC6ZG.mjs} +2 -2
- package/dist/{chunk-QQQNJS2E.mjs → chunk-E7UN576T.mjs} +1 -1
- package/dist/{chunk-G3HRIVEY.cjs → chunk-ES4B2IXW.cjs} +2 -2
- package/dist/{chunk-JQGDQO2I.cjs → chunk-EXLKRR4U.cjs} +10 -10
- package/dist/chunk-FJ3M4CUX.cjs +46 -0
- package/dist/chunk-FXEF4PPL.mjs +47 -0
- package/dist/{chunk-WD4YXVLV.mjs → chunk-GZYH4OER.mjs} +1 -1
- package/dist/{chunk-DX4VKYAJ.cjs → chunk-I26CZYPV.cjs} +6 -4
- package/dist/{chunk-F6SJAKFJ.mjs → chunk-IV6CQY7O.mjs} +12 -154
- package/dist/{chunk-6D242YGO.mjs → chunk-JATSG2ZO.mjs} +1 -1
- package/dist/{chunk-KAERLFD3.cjs → chunk-JFHKNFEO.cjs} +30 -23
- package/dist/{chunk-U74A3P2P.cjs → chunk-JLRDISQL.cjs} +7 -7
- package/dist/{chunk-BYODCJD6.cjs → chunk-K7CELQLK.cjs} +12 -13
- package/dist/{chunk-Y4YWHNKU.cjs → chunk-KH7BN726.cjs} +9 -9
- package/dist/{chunk-3IL5UC5I.cjs → chunk-KZLND3D2.cjs} +2 -2
- package/dist/{chunk-TKDY6AJP.mjs → chunk-MKMBQSNQ.mjs} +1 -1
- package/dist/{chunk-OCE65DDM.mjs → chunk-MNUGPHLN.mjs} +1 -1
- package/dist/{chunk-WJKVTJJR.cjs → chunk-NPPL5YDT.cjs} +2 -2
- package/dist/{chunk-HF5SIACK.cjs → chunk-NXG66MR7.cjs} +3 -3
- package/dist/chunk-NYJMY3JA.cjs +156 -0
- package/dist/{chunk-VVJCWBIE.mjs → chunk-O3DTUAX2.mjs} +2 -2
- package/dist/{chunk-R6AIILII.cjs → chunk-OZVEHHMA.cjs} +15 -14
- package/dist/{chunk-FPW4W3VW.mjs → chunk-PQD2AI3B.mjs} +1 -1
- package/dist/{chunk-C7OUJ6JI.cjs → chunk-PZNCMPJF.cjs} +3 -3
- package/dist/{chunk-QI7WQSMI.cjs → chunk-Q5JFU33Q.cjs} +4 -4
- package/dist/{chunk-52SH7TKB.mjs → chunk-QG5HNS7P.mjs} +2 -2
- package/dist/{chunk-CEYUWDWA.mjs → chunk-QZCT2CQ4.mjs} +10 -5
- package/dist/{chunk-FZC7EEPM.mjs → chunk-RSOJ7DRT.mjs} +26 -7
- package/dist/{chunk-QMV4QELL.mjs → chunk-S5GDHOE4.mjs} +4 -2
- package/dist/{chunk-CRQPYWLK.cjs → chunk-SORB3MAR.cjs} +14 -14
- package/dist/{chunk-I4J452B7.cjs → chunk-VHJGDMCG.cjs} +3 -3
- package/dist/{chunk-B6ZCT36X.cjs → chunk-WNLBF77X.cjs} +4 -4
- package/dist/{chunk-FOT7LZEO.cjs → chunk-WPPX4G7Q.cjs} +1 -1
- package/dist/{chunk-UNSKL6BI.cjs → chunk-X4ZV4QC5.cjs} +266 -228
- package/dist/{chunk-6EG7U4NF.mjs → chunk-X7WVQMIB.mjs} +1 -1
- package/dist/chunk-XD32KALF.cjs +47 -0
- package/dist/{chunk-RDV44SED.mjs → chunk-XJJVLDM6.mjs} +15 -14
- package/dist/{chunk-DQMTHWPI.cjs → chunk-XLTV4VOG.cjs} +21 -16
- package/dist/{chunk-5SPPCN5J.mjs → chunk-XNPDONUH.mjs} +1 -1
- package/dist/{chunk-UOXGA6TO.mjs → chunk-YDQZGSDS.mjs} +1 -1
- package/dist/{chunk-JT25KHDI.mjs → chunk-YMUE7L3D.mjs} +18 -13
- package/dist/chunk-Z3HATSKO.mjs +46 -0
- package/dist/{chunk-C3VRMB6H.cjs → chunk-ZCU4NZ3M.cjs} +6 -6
- package/dist/{chunk-NPFGGBM5.cjs → chunk-ZDILFMWN.cjs} +13 -13
- package/dist/{chunk-OGHTEYXS.mjs → chunk-ZYVFAOBT.mjs} +72 -34
- package/dist/{client-plugins-1GS4zubE.d.mts → client-plugins-BX2ptm4H.d.mts} +42 -34
- package/dist/{client-plugins-B1Za6F5x.d.ts → client-plugins-BmxM5KW_.d.ts} +42 -34
- package/dist/client-plugins.d.mts +3 -2
- package/dist/client-plugins.d.ts +3 -2
- package/dist/client.cjs +11 -12
- package/dist/client.d.mts +6 -5
- package/dist/client.d.ts +6 -5
- package/dist/client.mjs +10 -11
- package/dist/config.d.mts +3 -2
- package/dist/config.d.ts +3 -2
- package/dist/{devtools-CQJ3H6MX.cjs → devtools-GGVPZHJX.cjs} +96 -21
- package/dist/{devtools-6RN6KHTW.mjs → devtools-THVNPI2M.mjs} +80 -5
- package/dist/{devtools-client-4WAPJY5L.cjs → devtools-client-CXQ6PXI6.cjs} +1 -1
- package/dist/{devtools-client-LEUIHHAS.mjs → devtools-client-HJS2T34Y.mjs} +1 -1
- package/dist/docs.cjs +9 -8
- package/dist/docs.mjs +8 -7
- package/dist/index.cjs +61 -57
- package/dist/index.d.mts +26 -15
- package/dist/index.d.ts +26 -15
- package/dist/index.mjs +69 -65
- package/dist/integrations.d.mts +3 -2
- package/dist/integrations.d.ts +3 -2
- package/dist/internal/app-markdown-runtime.cjs +5 -4
- package/dist/internal/app-markdown-runtime.d.mts +4 -3
- package/dist/internal/app-markdown-runtime.d.ts +4 -3
- package/dist/internal/app-markdown-runtime.mjs +4 -3
- package/dist/internal/build-runtime.cjs +26 -23
- package/dist/internal/build-runtime.d.mts +5 -4
- package/dist/internal/build-runtime.d.ts +5 -4
- package/dist/internal/build-runtime.mjs +25 -22
- package/dist/internal/cli-runtime.cjs +15 -13
- package/dist/internal/cli-runtime.mjs +14 -12
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +5 -1
- package/dist/internal/client-runtime.d.mts +1 -0
- package/dist/internal/client-runtime.d.ts +1 -0
- package/dist/internal/client-runtime.mjs +4 -0
- package/dist/internal/compression-runtime.cjs +3 -2
- package/dist/internal/compression-runtime.d.mts +6 -3
- package/dist/internal/compression-runtime.d.ts +6 -3
- package/dist/internal/compression-runtime.mjs +2 -1
- package/dist/internal/config-runtime.cjs +7 -6
- package/dist/internal/config-runtime.d.mts +4 -3
- package/dist/internal/config-runtime.d.ts +4 -3
- package/dist/internal/config-runtime.mjs +6 -5
- package/dist/internal/product-telemetry-runtime.cjs +10 -6
- package/dist/internal/product-telemetry-runtime.mjs +9 -5
- package/dist/internal/production-runtime.cjs +29 -13
- package/dist/internal/production-runtime.d.mts +36 -8
- package/dist/internal/production-runtime.d.ts +36 -8
- package/dist/internal/production-runtime.mjs +32 -16
- package/dist/markdown.cjs +4 -3
- package/dist/markdown.d.mts +3 -2
- package/dist/markdown.d.ts +3 -2
- package/dist/markdown.mjs +3 -2
- package/dist/{metadata-B9mCxKgp.d.mts → metadata-DsEaK7mQ.d.mts} +1 -1
- package/dist/{metadata-7LKgQEWF.d.ts → metadata-fwZ3gfG6.d.ts} +1 -1
- package/dist/middleware.cjs +6 -5
- package/dist/middleware.d.mts +4 -3
- package/dist/middleware.d.ts +4 -3
- package/dist/middleware.mjs +5 -4
- package/dist/navigation.cjs +5 -5
- package/dist/navigation.d.mts +5 -4
- package/dist/navigation.d.ts +5 -4
- package/dist/navigation.mjs +4 -4
- package/dist/plugin.cjs +25 -20
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.mjs +25 -20
- package/dist/{production-runtime-DramhI0c.d.mts → production-runtime-Baqgwtvc.d.mts} +1 -1
- package/dist/{production-runtime-B3xnY6fI.d.ts → production-runtime-DNkpFnmg.d.ts} +1 -1
- package/dist/query/client.cjs +6 -6
- package/dist/query/client.mjs +2 -2
- package/dist/{render-plan-CtQB-zHS.d.mts → render-plan-DhwQnmmX.d.mts} +1 -1
- package/dist/{render-plan-CpW32tOL.d.ts → render-plan-rkIK9wd9.d.ts} +1 -1
- package/dist/renderer-client.cjs +13 -14
- package/dist/renderer-client.d.mts +4 -3
- package/dist/renderer-client.d.ts +4 -3
- package/dist/renderer-client.mjs +6 -7
- package/dist/{request-BVGGeQv4.d.ts → request-BcY4RYPC.d.ts} +1 -1
- package/dist/{request-DlLVBKe3.d.mts → request-CFy1BltJ.d.mts} +1 -1
- package/dist/request.d.mts +4 -3
- package/dist/request.d.ts +4 -3
- package/dist/{route-rendering-DChYLNdh.d.mts → route-rendering-BkS0TBlB.d.mts} +1 -1
- package/dist/{route-rendering-BdEldajn.d.ts → route-rendering-D4XpMjam.d.ts} +1 -1
- package/dist/{router-D5htHn_M.d.mts → router-C4zPlC3V.d.mts} +1 -1
- package/dist/{router-D0Az-1Nu.d.ts → router-Cq7BcZxg.d.ts} +1 -1
- package/dist/routes.cjs +6 -5
- package/dist/routes.d.mts +3 -2
- package/dist/routes.d.ts +3 -2
- package/dist/routes.mjs +5 -4
- package/dist/server-fn-client.d.mts +1 -0
- package/dist/server-fn-client.d.ts +1 -0
- package/dist/server-fn.cjs +6 -5
- package/dist/server-fn.d.mts +1 -0
- package/dist/server-fn.d.ts +1 -0
- package/dist/server-fn.mjs +5 -4
- package/dist/server-plugins.cjs +3 -2
- package/dist/server-plugins.d.mts +3 -2
- package/dist/server-plugins.d.ts +3 -2
- package/dist/server-plugins.mjs +2 -1
- package/dist/server-query-client.cjs +5 -7
- package/dist/server-query-client.d.mts +1 -0
- package/dist/server-query-client.d.ts +1 -0
- package/dist/server-query-client.mjs +4 -6
- package/dist/server-query.cjs +7 -6
- package/dist/server-query.d.mts +1 -0
- package/dist/server-query.d.ts +1 -0
- package/dist/server-query.mjs +6 -5
- package/dist/server.cjs +72 -57
- package/dist/server.d.mts +10 -9
- package/dist/server.d.ts +10 -9
- package/dist/server.mjs +56 -41
- package/dist/{spa-router-DmwP_7QL.d.ts → spa-router-B1HI3X9k.d.ts} +2 -2
- package/dist/{spa-router-DVfSJZ5o.d.mts → spa-router-DzPZH-AO.d.mts} +2 -2
- package/dist/testing.cjs +14 -13
- package/dist/testing.d.mts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.mjs +11 -10
- package/dist/{utils-B_Rmr0-n.d.mts → utils-CEBktlBG.d.mts} +1 -1
- package/dist/{utils-Dv0OuLtF.d.ts → utils-DMD1Hzta.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +21 -19
- package/dist/vite.d.mts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.mjs +20 -18
- package/package.json +1 -1
- package/dist/{chunk-YOYF2E4U.mjs → chunk-LNZ7JZUS.mjs} +0 -0
- package/dist/{chunk-N4RLRSWW.cjs → chunk-SUIBNSNO.cjs} +0 -0
- package/dist/{chunk-TIKNUAU7.mjs → chunk-VUMAE7NC.mjs} +3 -3
- package/dist/{chunk-WM6HL7E7.cjs → chunk-ZHVYQL3H.cjs} +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNYJMY3JAcjs = require('./chunk-NYJMY3JA.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkZEG3OPIBcjs = require('./chunk-ZEG3OPIB.cjs');
|
|
@@ -377,7 +377,7 @@ function getFarmClientDataCache() {
|
|
|
377
377
|
}
|
|
378
378
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmClientDataCache, "getFarmClientDataCache");
|
|
379
379
|
function normalizeFarmClientCacheKey(key) {
|
|
380
|
-
return typeof key === "string" ? key :
|
|
380
|
+
return typeof key === "string" ? key : _chunkNYJMY3JAcjs.createRouteDataCacheKey.call(void 0, key);
|
|
381
381
|
}
|
|
382
382
|
_chunkS3JO3N4Hcjs.__name.call(void 0, normalizeFarmClientCacheKey, "normalizeFarmClientCacheKey");
|
|
383
383
|
|
|
@@ -6,6 +6,9 @@ var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
|
6
6
|
var _chunk5MKEDGLDcjs = require('./chunk-5MKEDGLD.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunkFJ3M4CUXcjs = require('./chunk-FJ3M4CUX.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
9
12
|
var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
10
13
|
|
|
11
14
|
|
|
@@ -14,8 +17,7 @@ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
|
14
17
|
// src/markdown-view.ts
|
|
15
18
|
var FENCE = /^\s{0,3}(`{3,}|~{3,})/;
|
|
16
19
|
var ATX_HEADING = /^\s{0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/;
|
|
17
|
-
function
|
|
18
|
-
const lines = markdown.split("\n");
|
|
20
|
+
function parseMarkdownHeadingsFromLines(lines) {
|
|
19
21
|
const headings = [];
|
|
20
22
|
const used = /* @__PURE__ */ new Map();
|
|
21
23
|
let index = 0;
|
|
@@ -57,7 +59,7 @@ function parseFarmMarkdownHeadings(markdown) {
|
|
|
57
59
|
}
|
|
58
60
|
return headings;
|
|
59
61
|
}
|
|
60
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
62
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parseMarkdownHeadingsFromLines, "parseMarkdownHeadingsFromLines");
|
|
61
63
|
function slugifyHeading(text) {
|
|
62
64
|
return text.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[`*_~]/g, "").toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").trim().replace(/\s/g, "-");
|
|
63
65
|
}
|
|
@@ -97,7 +99,7 @@ function selectFarmMarkdownView(markdown, searchParams, markdownPath) {
|
|
|
97
99
|
), "withinBudget");
|
|
98
100
|
if (!wantsOutline && sectionId === null) return withinBudget(markdown);
|
|
99
101
|
const lines = markdown.split("\n");
|
|
100
|
-
const headings =
|
|
102
|
+
const headings = parseMarkdownHeadingsFromLines(lines);
|
|
101
103
|
const sectionText = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (heading) => lines.slice(heading.start, heading.end).join("\n").trim(), "sectionText");
|
|
102
104
|
if (sectionId !== null) {
|
|
103
105
|
const heading = headings.find((candidate) => candidate.id === sectionId);
|
|
@@ -116,10 +118,20 @@ ${available}
|
|
|
116
118
|
` : "This page has no sections.\n")
|
|
117
119
|
};
|
|
118
120
|
}
|
|
121
|
+
const offsets = [];
|
|
122
|
+
let offset = 0;
|
|
123
|
+
for (const line of lines) {
|
|
124
|
+
offsets.push(offset);
|
|
125
|
+
offset += line.length + 1;
|
|
126
|
+
}
|
|
119
127
|
const minLevel = headings.reduce((min, heading) => Math.min(min, heading.level), 6);
|
|
120
128
|
const entries = headings.map((heading) => {
|
|
121
129
|
const indent = " ".repeat(heading.level - minLevel);
|
|
122
|
-
|
|
130
|
+
let last = heading.end - 1;
|
|
131
|
+
while (last > heading.start && lines[last].trim().length === 0) last--;
|
|
132
|
+
const first = lines[heading.start];
|
|
133
|
+
const length = offsets[last] + lines[last].trimEnd().length - offsets[heading.start] - (first.length - first.trimStart().length);
|
|
134
|
+
const tokens = Math.ceil(length / 4);
|
|
123
135
|
return `${indent}- [${heading.text}](${viewUrl({ section: heading.id })}) ~${tokens} tokens`;
|
|
124
136
|
});
|
|
125
137
|
return {
|
|
@@ -211,7 +223,9 @@ The page changed after this cursor was issued. Start again at ${partUrl()}.
|
|
|
211
223
|
const part = `${head}${lines.slice(start, end).join("\n").replace(/\n+$/, "")}${open ? `
|
|
212
224
|
${open.closer}` : ""}`;
|
|
213
225
|
const next = partUrl(`${end}.${version}`);
|
|
214
|
-
|
|
226
|
+
let remainingLength = lines.length - end - 1;
|
|
227
|
+
for (let index = end; index < lines.length; index++) remainingLength += lines[index].length;
|
|
228
|
+
const remaining = Math.ceil(remainingLength / 4);
|
|
215
229
|
return {
|
|
216
230
|
status: 200,
|
|
217
231
|
body: `${part}
|
|
@@ -282,8 +296,14 @@ function ifNoneMatchIncludes(header, etag) {
|
|
|
282
296
|
_chunkS3JO3N4Hcjs.__name.call(void 0, ifNoneMatchIncludes, "ifNoneMatchIncludes");
|
|
283
297
|
function createFarmMarkdownViewResponse(options) {
|
|
284
298
|
const url = _nullishCoalesce(options.requestUrl, () => ( new URL(options.request.url)));
|
|
285
|
-
const view = url.searchParams.has("actions") ? selectFarmPageActionsView(options.markdownPath, _nullishCoalesce(options.actions, () => ( [])), options.headers) : selectFarmMarkdownView(options.markdown, url.searchParams, options.markdownPath);
|
|
286
|
-
|
|
299
|
+
const view = options.status >= 400 ? { status: options.status, body: options.markdown } : url.searchParams.has("actions") ? selectFarmPageActionsView(options.markdownPath, _nullishCoalesce(options.actions, () => ( [])), options.headers) : selectFarmMarkdownView(options.markdown, url.searchParams, options.markdownPath);
|
|
300
|
+
let status = view.status === 200 ? options.status : view.status;
|
|
301
|
+
const ifMatch = options.request.headers.get("if-match");
|
|
302
|
+
const preconditionFailed = status >= 200 && status < 300 && ifMatch !== null && ifMatch.trim() !== "*";
|
|
303
|
+
if (preconditionFailed) {
|
|
304
|
+
status = 412;
|
|
305
|
+
options.headers.set("Cache-Control", "no-store");
|
|
306
|
+
}
|
|
287
307
|
_chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, options.request, "markdown", status, readMarkdownViewName(url.searchParams));
|
|
288
308
|
for (const [name, value] of Object.entries(_nullishCoalesce(view.headers, () => ( {}))))
|
|
289
309
|
options.headers.append(name, value);
|
|
@@ -292,7 +312,7 @@ function createFarmMarkdownViewResponse(options) {
|
|
|
292
312
|
if (status === 200 && ifNoneMatchIncludes(options.request.headers.get("if-none-match"), etag)) {
|
|
293
313
|
return new Response(null, { status: 304, headers: options.headers });
|
|
294
314
|
}
|
|
295
|
-
return new Response(options.request.method === "HEAD" ? null : view.body, {
|
|
315
|
+
return new Response(preconditionFailed || options.request.method === "HEAD" ? null : view.body, {
|
|
296
316
|
status,
|
|
297
317
|
headers: options.headers
|
|
298
318
|
});
|
|
@@ -380,36 +400,61 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
380
400
|
for (const name of FARM_MARKDOWN_VIEW_PARAMS) pageUrl.searchParams.delete(name);
|
|
381
401
|
const headers = new Headers(options.request.headers);
|
|
382
402
|
headers.set("accept", "text/html");
|
|
403
|
+
headers.delete("if-match");
|
|
404
|
+
headers.delete("if-unmodified-since");
|
|
405
|
+
headers.delete("if-none-match");
|
|
406
|
+
headers.delete("if-modified-since");
|
|
407
|
+
headers.delete("range");
|
|
408
|
+
headers.delete("if-range");
|
|
383
409
|
const pageResponse = await options.renderPage(
|
|
384
410
|
new Request(pageUrl, {
|
|
385
411
|
method: "GET",
|
|
386
|
-
headers
|
|
412
|
+
headers,
|
|
413
|
+
signal: options.request.signal
|
|
387
414
|
})
|
|
388
415
|
);
|
|
416
|
+
if (pageResponse.status === 204 || pageResponse.status === 205 || pageResponse.status === 304) {
|
|
417
|
+
return pageResponse;
|
|
418
|
+
}
|
|
389
419
|
const redirects = pageResponse.status >= 300 && pageResponse.status < 400 && pageResponse.headers.has("location");
|
|
390
420
|
if (redirects || !isHtmlResponse(pageResponse)) {
|
|
391
|
-
|
|
421
|
+
const accessResponse = createMarkdownAccessResponse(
|
|
392
422
|
pageResponse,
|
|
393
423
|
target.pathname,
|
|
394
424
|
pageUrl,
|
|
395
425
|
options.request.method === "HEAD"
|
|
396
426
|
);
|
|
427
|
+
if (accessResponse || options.request.method === "HEAD") {
|
|
428
|
+
void _optionalChain([pageResponse, 'access', _11 => _11.body, 'optionalAccess', _12 => _12.cancel, 'call', _13 => _13(), 'access', _14 => _14.catch, 'call', _15 => _15(() => {
|
|
429
|
+
})]);
|
|
430
|
+
return _nullishCoalesce(accessResponse, () => ( new Response(null, {
|
|
431
|
+
status: pageResponse.status,
|
|
432
|
+
statusText: pageResponse.statusText,
|
|
433
|
+
headers: pageResponse.headers
|
|
434
|
+
})));
|
|
435
|
+
}
|
|
436
|
+
return pageResponse;
|
|
397
437
|
}
|
|
398
438
|
const html = await pageResponse.text();
|
|
399
439
|
const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
|
|
400
|
-
const
|
|
440
|
+
const region = pageResponse.status < 400 && /<form\b/i.test(html) ? readHtmlContentRegion(html) : void 0;
|
|
441
|
+
const actions = region === void 0 ? [] : extractPageActionsFromRegion(region, pageUrl);
|
|
401
442
|
for (const form of actions) {
|
|
402
|
-
if (!_optionalChain([form, 'access',
|
|
443
|
+
if (!_optionalChain([form, 'access', _16 => _16.action, 'optionalAccess', _17 => _17.startsWith, 'call', _18 => _18("/")])) continue;
|
|
403
444
|
const pathname = new URL(form.action, pageUrl.origin).pathname;
|
|
404
445
|
const tool = _nullishCoalesce(_chunk5MKEDGLDcjs._findFarmMCPEndpointTool.call(void 0, form.method, pathname, options.apiServerBasePath), () => ( _chunk5MKEDGLDcjs._findFarmMCPEndpointTool.call(void 0, form.method, _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, pathname), options.apiServerBasePath)));
|
|
405
446
|
if (tool) form.tool = tool;
|
|
406
447
|
}
|
|
407
|
-
const markdown =
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
448
|
+
const markdown = pageResponse.status < 400 && requestUrl.searchParams.has("actions") ? "" : convertHtmlToMarkdown(
|
|
449
|
+
html,
|
|
450
|
+
{
|
|
451
|
+
title: _optionalChain([target, 'access', _19 => _19.route, 'optionalAccess', _20 => _20.title]),
|
|
452
|
+
includeMetadata: _nullishCoalesce(_optionalChain([options, 'access', _21 => _21.config, 'optionalAccess', _22 => _22.includeMetadata]), () => ( true)),
|
|
453
|
+
sourcePath: target.pathname,
|
|
454
|
+
actionsPath: actions.length > 0 ? `${markdownPath}?actions` : void 0
|
|
455
|
+
},
|
|
456
|
+
region
|
|
457
|
+
);
|
|
413
458
|
const headersOut = new Headers({
|
|
414
459
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
415
460
|
"Content-Location": markdownPath,
|
|
@@ -418,17 +463,21 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
418
463
|
if (!hasMarkdownExtension) {
|
|
419
464
|
headersOut.set("Vary", "Accept");
|
|
420
465
|
}
|
|
421
|
-
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access',
|
|
466
|
+
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access', _23 => _23.headers, 'access', _24 => _24.get, 'call', _25 => _25("vary"), 'optionalAccess', _26 => _26.split, 'call', _27 => _27(",")]), () => ( []))) {
|
|
422
467
|
const name = token.trim();
|
|
423
468
|
if (name && name.toLowerCase() !== "accept") appendHeaderToken(headersOut, "Vary", name);
|
|
424
469
|
}
|
|
425
470
|
const pageCacheControl = pageResponse.headers.get("cache-control");
|
|
426
|
-
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access',
|
|
471
|
+
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access', _28 => _28.route, 'optionalAccess', _29 => _29.cache]), () => ( _optionalChain([options, 'access', _30 => _30.config, 'optionalAccess', _31 => _31.cache]))), () => ( false));
|
|
427
472
|
headersOut.set(
|
|
428
473
|
"Cache-Control",
|
|
429
474
|
pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : createMarkdownCacheHeader(cache)
|
|
430
475
|
);
|
|
431
|
-
|
|
476
|
+
preserveMarkdownResponseCookies(pageResponse.headers, headersOut);
|
|
477
|
+
if (pageResponse.status >= 400) {
|
|
478
|
+
preserveMarkdownResponseControlHeaders(pageResponse.headers, headersOut);
|
|
479
|
+
}
|
|
480
|
+
const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]))).join(", ");
|
|
432
481
|
if (robots) headersOut.set("X-Robots-Tag", robots);
|
|
433
482
|
const canonical = readHtmlCanonicalHref(html);
|
|
434
483
|
if (canonical) {
|
|
@@ -457,6 +506,8 @@ function createMarkdownAccessResponse(pageResponse, pathname, pageUrl, head) {
|
|
|
457
506
|
"Cache-Control": "no-store",
|
|
458
507
|
"X-Farm-Markdown-Route": pathname
|
|
459
508
|
});
|
|
509
|
+
preserveMarkdownResponseCookies(pageResponse.headers, headers);
|
|
510
|
+
preserveMarkdownResponseControlHeaders(pageResponse.headers, headers);
|
|
460
511
|
let body;
|
|
461
512
|
if (redirect) {
|
|
462
513
|
let target;
|
|
@@ -471,8 +522,6 @@ function createMarkdownAccessResponse(pageResponse, pathname, pageUrl, head) {
|
|
|
471
522
|
\`${pathname}\` redirects to [${target}](${target}). The page may require signing in.
|
|
472
523
|
`;
|
|
473
524
|
} else {
|
|
474
|
-
const authenticate = pageResponse.headers.get("www-authenticate");
|
|
475
|
-
if (authenticate) headers.set("WWW-Authenticate", authenticate);
|
|
476
525
|
body = pageResponse.status === 401 ? `# Sign-in required
|
|
477
526
|
|
|
478
527
|
\`${pathname}\` requires signing in.
|
|
@@ -484,6 +533,21 @@ This account cannot read \`${pathname}\`.
|
|
|
484
533
|
return new Response(head ? null : body, { status: pageResponse.status, headers });
|
|
485
534
|
}
|
|
486
535
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createMarkdownAccessResponse, "createMarkdownAccessResponse");
|
|
536
|
+
function preserveMarkdownResponseControlHeaders(source, target) {
|
|
537
|
+
for (const name of ["WWW-Authenticate", "Proxy-Authenticate", "Retry-After", "Allow"]) {
|
|
538
|
+
const value = source.get(name);
|
|
539
|
+
if (value !== null) target.set(name, value);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, preserveMarkdownResponseControlHeaders, "preserveMarkdownResponseControlHeaders");
|
|
543
|
+
function preserveMarkdownResponseCookies(source, target) {
|
|
544
|
+
const getSetCookie = source.getSetCookie;
|
|
545
|
+
const cookies = typeof getSetCookie === "function" ? getSetCookie.call(source) : source.has("set-cookie") ? [source.get("set-cookie")] : [];
|
|
546
|
+
if (cookies.length === 0) return;
|
|
547
|
+
for (const cookie of cookies) target.append("Set-Cookie", cookie);
|
|
548
|
+
target.set("Cache-Control", "private, no-store");
|
|
549
|
+
}
|
|
550
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, preserveMarkdownResponseCookies, "preserveMarkdownResponseCookies");
|
|
487
551
|
function applyMarkdownNegotiationHeaders(response, options) {
|
|
488
552
|
if (!isHtmlResponse(response)) {
|
|
489
553
|
return response;
|
|
@@ -492,13 +556,9 @@ function applyMarkdownNegotiationHeaders(response, options) {
|
|
|
492
556
|
if (!alternatePath) {
|
|
493
557
|
return response;
|
|
494
558
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return new Response(response.body, {
|
|
499
|
-
status: response.status,
|
|
500
|
-
statusText: response.statusText,
|
|
501
|
-
headers
|
|
559
|
+
return _chunkFJ3M4CUXcjs._withFarmResponseHeaders.call(void 0, response, (headers) => {
|
|
560
|
+
appendHeaderToken(headers, "Vary", "Accept");
|
|
561
|
+
headers.append("Link", `<${alternatePath}>; rel="alternate"; type="text/markdown"`);
|
|
502
562
|
});
|
|
503
563
|
}
|
|
504
564
|
_chunkS3JO3N4Hcjs.__name.call(void 0, applyMarkdownNegotiationHeaders, "applyMarkdownNegotiationHeaders");
|
|
@@ -506,9 +566,61 @@ var CODE_BLOCK_MARK = "\0";
|
|
|
506
566
|
var CODE_BLOCK_PLACEHOLDER = /\u0000(\d+)\u0000/g;
|
|
507
567
|
var BLOCK_TAGS = /<\/?(ul|ol|main|section|article|header|footer|nav|aside|div|form|fieldset|legend|figure|figcaption|table|thead|tbody|tfoot|tr|dl|dt|dd|details|summary|address)\b[^>]*>/gi;
|
|
508
568
|
var BOX_TAGS = /<\/?(label|button|input|select|textarea|option|output|meter|progress|td|th)\b[^>]*>/gi;
|
|
569
|
+
var LAYOUT_ROW = /<(div|nav|section|header|footer|aside|main|article|figure|figcaption|dt|dd)\b([^>]*)>((?:(?!<\/?(?:div|nav|section|header|footer|aside|main|article|figure|figcaption|dt|dd|p|h[1-6]|ul|ol|li|table|pre|blockquote)\b)[\s\S])*?)<\/\1>/gi;
|
|
570
|
+
var HTML_TOKEN = /<\/?([a-zA-Z][\w:-]*)\b[^>]*?(\/?)>|[^<]+/g;
|
|
571
|
+
function separateLayoutRowItems(source) {
|
|
572
|
+
return source.replace(
|
|
573
|
+
LAYOUT_ROW,
|
|
574
|
+
(container, tag, attributes, content) => {
|
|
575
|
+
const boundaries = [];
|
|
576
|
+
const items = [];
|
|
577
|
+
let depth = 0;
|
|
578
|
+
let previousEnd = -1;
|
|
579
|
+
let item = "";
|
|
580
|
+
for (const match of content.matchAll(HTML_TOKEN)) {
|
|
581
|
+
const [token, name, selfClosing] = match;
|
|
582
|
+
const index = _nullishCoalesce(match.index, () => ( 0));
|
|
583
|
+
if (name === void 0) {
|
|
584
|
+
if (depth === 0) {
|
|
585
|
+
if (token.trim()) return container;
|
|
586
|
+
previousEnd = -1;
|
|
587
|
+
} else {
|
|
588
|
+
item += token;
|
|
589
|
+
}
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
const closing = token.startsWith("</");
|
|
593
|
+
const isVoid = selfClosing === "/" || VOID_TAGS.has(name.toLowerCase());
|
|
594
|
+
if (closing) {
|
|
595
|
+
depth = Math.max(0, depth - 1);
|
|
596
|
+
} else {
|
|
597
|
+
if (depth === 0 && previousEnd === index) boundaries.push(index);
|
|
598
|
+
if (!isVoid) depth += 1;
|
|
599
|
+
}
|
|
600
|
+
if (depth === 0) {
|
|
601
|
+
previousEnd = index + token.length;
|
|
602
|
+
items.push(decodeHtml(item).trim());
|
|
603
|
+
item = "";
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (boundaries.length === 0) return container;
|
|
607
|
+
if (items.filter(Boolean).every((text) => text.length === 1)) return container;
|
|
608
|
+
let separated = content;
|
|
609
|
+
for (const boundary of boundaries.reverse()) {
|
|
610
|
+
separated = `${separated.slice(0, boundary)} ${separated.slice(boundary)}`;
|
|
611
|
+
}
|
|
612
|
+
return `<${tag}${attributes}>${separated}</${tag}>`;
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, separateLayoutRowItems, "separateLayoutRowItems");
|
|
509
617
|
function htmlToMarkdown(html, options = {}) {
|
|
618
|
+
return convertHtmlToMarkdown(html, options);
|
|
619
|
+
}
|
|
620
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, htmlToMarkdown, "htmlToMarkdown");
|
|
621
|
+
function convertHtmlToMarkdown(html, options, region) {
|
|
510
622
|
const title = _nullishCoalesce(options.title, () => ( extractHtmlTitle(html)));
|
|
511
|
-
let source = readHtmlContentRegion(html);
|
|
623
|
+
let source = _nullishCoalesce(region, () => ( readHtmlContentRegion(html)));
|
|
512
624
|
const codeBlocks = [];
|
|
513
625
|
const setAsideCodeBlock = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (code, attributes) => {
|
|
514
626
|
const content = decodeHtml(stripTags(code)).trim();
|
|
@@ -549,6 +661,7 @@ ${CODE_BLOCK_MARK}${codeBlocks.length - 1}${CODE_BLOCK_MARK}
|
|
|
549
661
|
`;
|
|
550
662
|
}
|
|
551
663
|
);
|
|
664
|
+
source = separateLayoutRowItems(source);
|
|
552
665
|
source = source.replace(/<h([1-6])\b[^>]*>([\s\S]*?)<\/h\1>/gi, (_, level, content) => {
|
|
553
666
|
return `
|
|
554
667
|
|
|
@@ -619,7 +732,7 @@ ${markdown}` : ""}`;
|
|
|
619
732
|
return `${markdown}
|
|
620
733
|
`;
|
|
621
734
|
}
|
|
622
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
735
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, convertHtmlToMarkdown, "convertHtmlToMarkdown");
|
|
623
736
|
function normalizeMarkdownRouteInput(input) {
|
|
624
737
|
if (typeof input === "string") {
|
|
625
738
|
return {
|
|
@@ -685,7 +798,7 @@ function getFarmMarkdownAlternatePath(config, pathname) {
|
|
|
685
798
|
}
|
|
686
799
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmMarkdownAlternatePath, "getFarmMarkdownAlternatePath");
|
|
687
800
|
function isFarmMarkdownMirrorExposed(config, pathname) {
|
|
688
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
801
|
+
if (!_optionalChain([config, 'optionalAccess', _34 => _34.enabled])) return false;
|
|
689
802
|
return config.expose === true || findExposedMarkdownRoute(config, pathname) !== null;
|
|
690
803
|
}
|
|
691
804
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isFarmMarkdownMirrorExposed, "isFarmMarkdownMirrorExposed");
|
|
@@ -778,7 +891,7 @@ function extractHtmlBody(html) {
|
|
|
778
891
|
const body = rootMatch ? rootMatch[1] : bodyMatch ? bodyMatch[1] : html;
|
|
779
892
|
const main = extractFirstElementContent(body, ["main"]);
|
|
780
893
|
if (main !== void 0) return main;
|
|
781
|
-
const articles = _nullishCoalesce(_optionalChain([body, 'access',
|
|
894
|
+
const articles = _nullishCoalesce(_optionalChain([body, 'access', _35 => _35.match, 'call', _36 => _36(/<article\b/gi), 'optionalAccess', _37 => _37.length]), () => ( 0));
|
|
782
895
|
return articles === 1 ? _nullishCoalesce(extractFirstElementContent(body, ["article"]), () => ( body)) : body;
|
|
783
896
|
}
|
|
784
897
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractHtmlBody, "extractHtmlBody");
|
|
@@ -794,7 +907,7 @@ function extractFirstElementContent(html, tagNames) {
|
|
|
794
907
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFirstElementContent, "extractFirstElementContent");
|
|
795
908
|
function readHtmlMetaContent(html, name) {
|
|
796
909
|
for (const match of html.matchAll(/<meta\b([^>]*)>/gi)) {
|
|
797
|
-
if (_optionalChain([readHtmlAttribute, 'call',
|
|
910
|
+
if (_optionalChain([readHtmlAttribute, 'call', _38 => _38(match[1], "name"), 'optionalAccess', _39 => _39.toLowerCase, 'call', _40 => _40()]) === name) {
|
|
798
911
|
return readHtmlAttribute(match[1], "content");
|
|
799
912
|
}
|
|
800
913
|
}
|
|
@@ -803,8 +916,8 @@ function readHtmlMetaContent(html, name) {
|
|
|
803
916
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlMetaContent, "readHtmlMetaContent");
|
|
804
917
|
function readHtmlCanonicalHref(html) {
|
|
805
918
|
for (const match of html.matchAll(/<link\b([^>]*)>/gi)) {
|
|
806
|
-
const rel = _optionalChain([readHtmlAttribute, 'call',
|
|
807
|
-
if (_optionalChain([rel, 'optionalAccess',
|
|
919
|
+
const rel = _optionalChain([readHtmlAttribute, 'call', _41 => _41(match[1], "rel"), 'optionalAccess', _42 => _42.toLowerCase, 'call', _43 => _43(), 'access', _44 => _44.split, 'call', _45 => _45(/\s+/)]);
|
|
920
|
+
if (_optionalChain([rel, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47("canonical")])) return readHtmlAttribute(match[1], "href");
|
|
808
921
|
}
|
|
809
922
|
return void 0;
|
|
810
923
|
}
|
|
@@ -816,7 +929,10 @@ var FORM_ENCTYPES = /* @__PURE__ */ new Set([
|
|
|
816
929
|
]);
|
|
817
930
|
function extractFarmPageActions(html, pageUrl) {
|
|
818
931
|
if (!/<form\b/i.test(html)) return [];
|
|
819
|
-
|
|
932
|
+
return extractPageActionsFromRegion(readHtmlContentRegion(html), pageUrl);
|
|
933
|
+
}
|
|
934
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFarmPageActions, "extractFarmPageActions");
|
|
935
|
+
function extractPageActionsFromRegion(region, pageUrl) {
|
|
820
936
|
const labelsFor = /* @__PURE__ */ new Map();
|
|
821
937
|
for (const match of region.matchAll(/<label\b([^>]*)>([\s\S]*?)<\/label>/gi)) {
|
|
822
938
|
const target = readDecodedAttribute(match[1], "for");
|
|
@@ -829,9 +945,9 @@ function extractFarmPageActions(html, pageUrl) {
|
|
|
829
945
|
}
|
|
830
946
|
return actions;
|
|
831
947
|
}
|
|
832
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
948
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, extractPageActionsFromRegion, "extractPageActionsFromRegion");
|
|
833
949
|
function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
834
|
-
const method = _optionalChain([readDecodedAttribute, 'call',
|
|
950
|
+
const method = _optionalChain([readDecodedAttribute, 'call', _48 => _48(attributes, "method"), 'optionalAccess', _49 => _49.trim, 'call', _50 => _50(), 'access', _51 => _51.toLowerCase, 'call', _52 => _52()]);
|
|
835
951
|
if (method === "dialog") return void 0;
|
|
836
952
|
const target = resolveFormTarget(readDecodedAttribute(attributes, "action"), pageUrl);
|
|
837
953
|
const form = {
|
|
@@ -841,11 +957,11 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
841
957
|
submit: []
|
|
842
958
|
};
|
|
843
959
|
const name = _nullishCoalesce(_nullishCoalesce(readDecodedAttribute(attributes, "aria-label"), () => ( readDecodedAttribute(attributes, "name"))), () => ( readDecodedAttribute(attributes, "id")));
|
|
844
|
-
if (_optionalChain([name, 'optionalAccess',
|
|
960
|
+
if (_optionalChain([name, 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()])) form.name = name.trim();
|
|
845
961
|
if (target) form.action = target;
|
|
846
962
|
else form.requiresJavaScript = true;
|
|
847
963
|
if (form.method === "POST") {
|
|
848
|
-
const enctype = _optionalChain([readDecodedAttribute, 'call',
|
|
964
|
+
const enctype = _optionalChain([readDecodedAttribute, 'call', _55 => _55(attributes, "enctype"), 'optionalAccess', _56 => _56.trim, 'call', _57 => _57(), 'access', _58 => _58.toLowerCase, 'call', _59 => _59()]);
|
|
849
965
|
form.enctype = enctype && FORM_ENCTYPES.has(enctype) ? enctype : "application/x-www-form-urlencoded";
|
|
850
966
|
}
|
|
851
967
|
const wrappingLabels = [...content.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/gi)].map(
|
|
@@ -856,13 +972,13 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
856
972
|
})
|
|
857
973
|
);
|
|
858
974
|
const labelOf = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (controlAttributes, index) => {
|
|
859
|
-
const aria = _optionalChain([readDecodedAttribute, 'call',
|
|
975
|
+
const aria = _optionalChain([readDecodedAttribute, 'call', _60 => _60(controlAttributes, "aria-label"), 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()]);
|
|
860
976
|
if (aria) return aria;
|
|
861
977
|
const id = readDecodedAttribute(controlAttributes, "id");
|
|
862
978
|
const forLabel = id ? labelsFor.get(id) : void 0;
|
|
863
979
|
if (forLabel) return forLabel;
|
|
864
980
|
const wrapping = wrappingLabels.find((label) => label.start < index && index < label.end);
|
|
865
|
-
return _optionalChain([wrapping, 'optionalAccess',
|
|
981
|
+
return _optionalChain([wrapping, 'optionalAccess', _63 => _63.text]) || void 0;
|
|
866
982
|
}, "labelOf");
|
|
867
983
|
const groups = /* @__PURE__ */ new Map();
|
|
868
984
|
const controls = /<(input)\b([^>]*)>|<(select|textarea|button)\b([^>]*)>([\s\S]*?)<\/\3>/gi;
|
|
@@ -873,7 +989,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
873
989
|
if (hasHtmlAttribute(controlAttributes, "disabled")) continue;
|
|
874
990
|
const label = labelOf(controlAttributes, match.index);
|
|
875
991
|
const fieldName = readDecodedAttribute(controlAttributes, "name");
|
|
876
|
-
const typeAttribute = _optionalChain([readDecodedAttribute, 'call',
|
|
992
|
+
const typeAttribute = _optionalChain([readDecodedAttribute, 'call', _64 => _64(controlAttributes, "type"), 'optionalAccess', _65 => _65.trim, 'call', _66 => _66(), 'access', _67 => _67.toLowerCase, 'call', _68 => _68()]);
|
|
877
993
|
const type = tag === "input" ? _nullishCoalesce(typeAttribute, () => ( "text")) : tag === "button" ? _nullishCoalesce(typeAttribute, () => ( "submit")) : tag;
|
|
878
994
|
if (tag === "button" && !["button", "reset"].includes(type) || tag === "input" && (type === "submit" || type === "image")) {
|
|
879
995
|
const submit = {
|
|
@@ -887,7 +1003,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
887
1003
|
const resolved = resolveFormTarget(formAction, pageUrl);
|
|
888
1004
|
if (resolved) submit.action = resolved;
|
|
889
1005
|
}
|
|
890
|
-
const formMethod = _optionalChain([readDecodedAttribute, 'call',
|
|
1006
|
+
const formMethod = _optionalChain([readDecodedAttribute, 'call', _69 => _69(controlAttributes, "formmethod"), 'optionalAccess', _70 => _70.toLowerCase, 'call', _71 => _71()]);
|
|
891
1007
|
if (formMethod === "get" || formMethod === "post") submit.method = formMethod.toUpperCase();
|
|
892
1008
|
form.submit.push(submit);
|
|
893
1009
|
continue;
|
|
@@ -966,7 +1082,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, readPageForm, "readPageForm");
|
|
|
966
1082
|
function resolveFormTarget(action, pageUrl) {
|
|
967
1083
|
let target;
|
|
968
1084
|
try {
|
|
969
|
-
target = new URL(_optionalChain([action, 'optionalAccess',
|
|
1085
|
+
target = new URL(_optionalChain([action, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()]) || pageUrl.href, pageUrl);
|
|
970
1086
|
} catch (e4) {
|
|
971
1087
|
return void 0;
|
|
972
1088
|
}
|
|
@@ -998,7 +1114,7 @@ function readHtmlAttribute(attributes, name) {
|
|
|
998
1114
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlAttribute, "readHtmlAttribute");
|
|
999
1115
|
function readCodeLanguage(attributesList) {
|
|
1000
1116
|
for (const attributes of attributesList) {
|
|
1001
|
-
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call',
|
|
1117
|
+
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call', _74 => _74(attributes, "class"), 'optionalAccess', _75 => _75.match, 'call', _76 => _76(/(?:^|\s)lang(?:uage)?-(\S+)/), 'optionalAccess', _77 => _77[1]])));
|
|
1002
1118
|
if (language && /^[\w#+.-]+$/.test(language)) return language;
|
|
1003
1119
|
}
|
|
1004
1120
|
return void 0;
|
|
@@ -1064,6 +1180,7 @@ var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
|
1064
1180
|
"wbr"
|
|
1065
1181
|
]);
|
|
1066
1182
|
function removeHiddenElements(html) {
|
|
1183
|
+
if (!/hidden/i.test(html)) return html;
|
|
1067
1184
|
const openingTag = /<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
1068
1185
|
let closingTags;
|
|
1069
1186
|
let result = "";
|
|
@@ -1111,7 +1228,7 @@ function matchClosingTags(html) {
|
|
|
1111
1228
|
while (match = tags.exec(html)) {
|
|
1112
1229
|
const name = match[2].toLowerCase();
|
|
1113
1230
|
if (match[1]) {
|
|
1114
|
-
const start = _optionalChain([open, 'access',
|
|
1231
|
+
const start = _optionalChain([open, 'access', _78 => _78.get, 'call', _79 => _79(name), 'optionalAccess', _80 => _80.pop, 'call', _81 => _81()]);
|
|
1115
1232
|
if (start !== void 0) closes.set(start, match.index + match[0].length);
|
|
1116
1233
|
} else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
|
|
1117
1234
|
let starts = open.get(name);
|
|
@@ -1146,7 +1263,7 @@ function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
|
|
|
1146
1263
|
let cursor = 0;
|
|
1147
1264
|
let match;
|
|
1148
1265
|
while (match = openingTag.exec(html)) {
|
|
1149
|
-
const id = _optionalChain([/\sid="([^"]*)"/, 'access',
|
|
1266
|
+
const id = _optionalChain([/\sid="([^"]*)"/, 'access', _82 => _82.exec, 'call', _83 => _83(match[2]), 'optionalAccess', _84 => _84[1]]);
|
|
1150
1267
|
if (!id || !wanted.has(id) || segments.has(id)) continue;
|
|
1151
1268
|
const close = closingTags.get(match.index);
|
|
1152
1269
|
if (close === void 0) continue;
|
|
@@ -336,32 +336,49 @@ function assertPluginDependencies(plugins, integrations) {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
const state = /* @__PURE__ */ new Map();
|
|
339
|
-
const
|
|
339
|
+
const path3 = [];
|
|
340
340
|
const visit = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (plugin) => {
|
|
341
341
|
if (state.get(plugin) === "done") return;
|
|
342
342
|
if (state.get(plugin) === "visiting") {
|
|
343
|
-
const cycle = [...
|
|
343
|
+
const cycle = [...path3.slice(path3.indexOf(plugin)), plugin].map(
|
|
344
344
|
(entry) => pluginShortName(entry.name)
|
|
345
345
|
);
|
|
346
346
|
throw new Error(`Plugins depend on each other in a cycle: ${cycle.join(" \u2192 ")}.`);
|
|
347
347
|
}
|
|
348
348
|
state.set(plugin, "visiting");
|
|
349
|
-
|
|
349
|
+
path3.push(plugin);
|
|
350
350
|
for (const dependency of _nullishCoalesce(plugin.dependsOn, () => ( []))) {
|
|
351
351
|
for (const candidate of plugins) {
|
|
352
352
|
if (candidate !== plugin && matches(candidate, dependency)) visit(candidate);
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
path3.pop();
|
|
356
356
|
state.set(plugin, "done");
|
|
357
357
|
}, "visit");
|
|
358
358
|
for (const plugin of plugins) visit(plugin);
|
|
359
359
|
}
|
|
360
360
|
_chunkS3JO3N4Hcjs.__name.call(void 0, assertPluginDependencies, "assertPluginDependencies");
|
|
361
361
|
|
|
362
|
+
// src/utils/source-dir.ts
|
|
363
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
364
|
+
var FARM_PROJECT_SOURCE_DIRS = /* @__PURE__ */ Symbol.for("farm.projectSourceDirs");
|
|
365
|
+
function getProjectSourceDirs() {
|
|
366
|
+
const globalState = globalThis;
|
|
367
|
+
return _nullishCoalesce(globalState[FARM_PROJECT_SOURCE_DIRS], () => ( (globalState[FARM_PROJECT_SOURCE_DIRS] = /* @__PURE__ */ new Map())));
|
|
368
|
+
}
|
|
369
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getProjectSourceDirs, "getProjectSourceDirs");
|
|
370
|
+
function setFarmProjectSourceDir(root, srcDir) {
|
|
371
|
+
getProjectSourceDirs().set(_path2.default.resolve(root), srcDir);
|
|
372
|
+
}
|
|
373
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, setFarmProjectSourceDir, "setFarmProjectSourceDir");
|
|
374
|
+
function getFarmProjectSourceDir(root) {
|
|
375
|
+
return _nullishCoalesce(getProjectSourceDirs().get(_path2.default.resolve(root)), () => ( "src"));
|
|
376
|
+
}
|
|
377
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmProjectSourceDir, "getFarmProjectSourceDir");
|
|
378
|
+
|
|
362
379
|
// src/auth-config.ts
|
|
363
380
|
var _module = require('module');
|
|
364
|
-
|
|
381
|
+
|
|
365
382
|
var _url = require('url');
|
|
366
383
|
function resolveFarmAuthConfig(input) {
|
|
367
384
|
const config = input === true ? {} : input && typeof input === "object" ? input : {};
|
|
@@ -484,4 +501,6 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, validateFarmAuthConfig, "validateFarmAuthC
|
|
|
484
501
|
|
|
485
502
|
|
|
486
503
|
|
|
487
|
-
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
exports.setFarmProjectSourceDir = setFarmProjectSourceDir; exports.getFarmProjectSourceDir = getFarmProjectSourceDir; exports.resolveFarmDevIndicatorsConfig = resolveFarmDevIndicatorsConfig; exports.generateFarmDevIndicatorsClientRuntime = generateFarmDevIndicatorsClientRuntime; exports.resolveFarmAuthConfig = resolveFarmAuthConfig; exports.resolveFarmAuthIntegration = resolveFarmAuthIntegration; exports.pluginShortName = pluginShortName; exports.assertPluginDependencies = assertPluginDependencies;
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
attachRevalidationListeners,
|
|
3
3
|
createServerQueryCallKey,
|
|
4
4
|
fetchServerQuery
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2N5PX3LS.mjs";
|
|
6
6
|
import {
|
|
7
7
|
getFarmClientDataCache
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XNPDONUH.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-LPEX4YW6.mjs";
|