@farm.js/core 0.1.25 → 0.1.27
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 +8 -10
- package/dist/agent-runtime.d.ts +8 -10
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.d.mts +4 -5
- package/dist/api/client.d.ts +4 -5
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +6 -5
- package/dist/api/route-manager.d.mts +7 -9
- package/dist/api/route-manager.d.ts +7 -9
- package/dist/api/route-manager.mjs +5 -4
- package/dist/api/runtime.cjs +10 -4
- package/dist/api/runtime.d.mts +35 -3
- package/dist/api/runtime.d.ts +35 -3
- package/dist/api/runtime.mjs +9 -3
- package/dist/{api-client-Cx54IR5g.d.mts → api-client-BjMmY8OD.d.mts} +2 -3
- package/dist/{api-client-DykpaKcY.d.ts → api-client-CyFtZFJ4.d.ts} +2 -3
- package/dist/api.cjs +9 -8
- package/dist/api.d.mts +9 -11
- package/dist/api.d.ts +9 -11
- package/dist/api.mjs +9 -8
- package/dist/{app-ZuWrAMc_.d.mts → app-BfzZdjgX.d.mts} +3 -4
- package/dist/{app-BF-ctoxh.d.ts → app-CXK7Prrt.d.ts} +3 -4
- package/dist/app-markdown.cjs +12 -4
- package/dist/app-markdown.d.mts +9 -11
- package/dist/app-markdown.d.ts +9 -11
- package/dist/app-markdown.mjs +11 -3
- package/dist/{chunk-2BIJGZR3.mjs → chunk-3PTVHMLD.mjs} +1 -1
- package/dist/{chunk-XME4TCLB.mjs → chunk-4FHDV7VM.mjs} +2 -2
- package/dist/{chunk-KLSSO6YD.mjs → chunk-4UNKCNSL.mjs} +1 -1
- package/dist/chunk-5MKEDGLD.cjs +53 -0
- package/dist/{chunk-E3RDL2DA.cjs → chunk-DQMTHWPI.cjs} +61 -31
- package/dist/{chunk-TTVHACQV.cjs → chunk-FOT7LZEO.cjs} +1 -1
- package/dist/{chunk-2KI3CL3N.mjs → chunk-FPW4W3VW.mjs} +1 -1
- package/dist/{chunk-6K4SPQWL.cjs → chunk-HF5SIACK.cjs} +3 -3
- package/dist/{chunk-T2OPSH6S.mjs → chunk-HG237IEY.mjs} +12 -5
- package/dist/chunk-J63ZH5OQ.cjs +62 -0
- package/dist/{chunk-BD2U4ZL6.cjs → chunk-JQGDQO2I.cjs} +8 -8
- package/dist/{chunk-RR6UGYUT.mjs → chunk-JT25KHDI.mjs} +39 -9
- package/dist/{chunk-O5DVPF3R.cjs → chunk-KAERLFD3.cjs} +16 -11
- package/dist/{chunk-H7CJRJ4L.cjs → chunk-LAHZ7LZA.cjs} +16 -16
- package/dist/{chunk-XM4ZDVD7.mjs → chunk-MBFURXAC.mjs} +1 -1
- package/dist/{chunk-6VEHUKZ2.mjs → chunk-MM5D6VLP.mjs} +4 -20
- package/dist/chunk-MVL2RAJW.mjs +62 -0
- package/dist/{chunk-YA6LLTIJ.cjs → chunk-ND224OE2.cjs} +4 -20
- package/dist/{chunk-RYDW7GPR.cjs → chunk-NPFGGBM5.cjs} +13 -13
- package/dist/{chunk-VZWO3XVL.mjs → chunk-O2LV5XDG.mjs} +2 -2
- package/dist/chunk-O6XNAMBV.mjs +53 -0
- package/dist/{chunk-N2Z4ZFDE.mjs → chunk-OGHTEYXS.mjs} +22 -14
- package/dist/{chunk-U4MP7XTD.mjs → chunk-POXI72VV.mjs} +180 -16
- package/dist/{chunk-QGG336NI.mjs → chunk-Q4BHBO6V.mjs} +1 -1
- package/dist/{chunk-AXYTGLF3.cjs → chunk-QI7WQSMI.cjs} +4 -4
- package/dist/{chunk-WOI2HOGA.mjs → chunk-QQQNJS2E.mjs} +1 -1
- package/dist/{chunk-CFNOGDUS.cjs → chunk-TDWFCC2T.cjs} +2 -2
- package/dist/{chunk-R7LCG3BT.cjs → chunk-UNSKL6BI.cjs} +89 -81
- package/dist/{chunk-WJYCI56T.mjs → chunk-UWTQTZFN.mjs} +52 -33
- package/dist/{chunk-5YYJ6Q2L.mjs → chunk-WIVTGKLY.mjs} +7 -2
- package/dist/{chunk-65P6OGYN.cjs → chunk-WJKVTJJR.cjs} +12 -5
- package/dist/{chunk-OAVTUMJP.cjs → chunk-YXM74XOW.cjs} +9 -9
- package/dist/{chunk-QYMRIVG6.cjs → chunk-YZBV7733.cjs} +120 -101
- package/dist/{chunk-2ITKVAIF.cjs → chunk-ZSO5GWGD.cjs} +203 -39
- package/dist/{client-plugins-DPG0NeZN.d.mts → client-plugins-1GS4zubE.d.mts} +1940 -1677
- package/dist/{client-plugins-Fgni-_25.d.ts → client-plugins-B1Za6F5x.d.ts} +1940 -1677
- package/dist/client-plugins.d.mts +8 -10
- package/dist/client-plugins.d.ts +8 -10
- package/dist/client.cjs +4 -4
- package/dist/client.d.mts +10 -12
- package/dist/client.d.ts +10 -12
- package/dist/client.mjs +3 -3
- package/dist/config.d.mts +8 -10
- package/dist/config.d.ts +8 -10
- package/dist/{devtools-I7TBFOKD.mjs → devtools-6RN6KHTW.mjs} +8 -3
- package/dist/{devtools-6OA7FEF6.cjs → devtools-CQJ3H6MX.cjs} +9 -4
- package/dist/docs.cjs +11 -6
- package/dist/docs.mjs +10 -5
- package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
- package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
- package/dist/index.cjs +26 -21
- package/dist/index.d.mts +16 -18
- package/dist/index.d.ts +16 -18
- package/dist/index.mjs +26 -21
- package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
- package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
- package/dist/integrations.d.mts +8 -10
- package/dist/integrations.d.ts +8 -10
- package/dist/internal/app-markdown-runtime.cjs +11 -3
- package/dist/internal/app-markdown-runtime.d.mts +9 -10
- package/dist/internal/app-markdown-runtime.d.ts +9 -10
- package/dist/internal/app-markdown-runtime.mjs +10 -2
- package/dist/internal/build-runtime.cjs +19 -17
- package/dist/internal/build-runtime.d.mts +10 -12
- package/dist/internal/build-runtime.d.ts +10 -12
- package/dist/internal/build-runtime.mjs +18 -16
- package/dist/internal/cli-runtime.cjs +9 -5
- package/dist/internal/cli-runtime.mjs +8 -4
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +8 -10
- package/dist/internal/compression-runtime.d.ts +8 -10
- package/dist/internal/config-runtime.cjs +9 -4
- package/dist/internal/config-runtime.d.mts +9 -11
- package/dist/internal/config-runtime.d.ts +9 -11
- package/dist/internal/config-runtime.mjs +8 -3
- package/dist/internal/infra-analytics-runtime.cjs +4 -3
- package/dist/internal/infra-analytics-runtime.mjs +2 -1
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +8 -5
- package/dist/internal/production-runtime.d.mts +16 -16
- package/dist/internal/production-runtime.d.ts +16 -16
- package/dist/internal/production-runtime.mjs +7 -4
- package/dist/markdown.cjs +10 -2
- package/dist/markdown.d.mts +35 -153
- package/dist/markdown.d.ts +35 -153
- package/dist/markdown.mjs +9 -1
- package/dist/{metadata-CDnRHKVq.d.ts → metadata-7LKgQEWF.d.ts} +1 -1
- package/dist/{metadata-D0EF7esB.d.mts → metadata-B9mCxKgp.d.mts} +1 -1
- package/dist/middleware.d.mts +9 -11
- package/dist/middleware.d.ts +9 -11
- package/dist/navigation.d.mts +10 -12
- package/dist/navigation.d.ts +10 -12
- package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
- package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
- package/dist/observability-BupkiN0m.d.mts +447 -0
- package/dist/observability-BupkiN0m.d.ts +447 -0
- package/dist/observability.d.mts +2 -417
- package/dist/observability.d.ts +2 -417
- package/dist/plugin.cjs +14 -12
- package/dist/plugin.d.mts +9 -11
- package/dist/plugin.d.ts +9 -11
- package/dist/plugin.mjs +13 -11
- package/dist/{production-runtime-DpCt0opU.d.ts → production-runtime-B3xnY6fI.d.ts} +1 -1
- package/dist/{production-runtime-x3W4wVqx.d.mts → production-runtime-DramhI0c.d.mts} +1 -1
- package/dist/{render-plan-D5oFRVBV.d.ts → render-plan-CpW32tOL.d.ts} +1 -1
- package/dist/{render-plan-tazUJalK.d.mts → render-plan-CtQB-zHS.d.mts} +1 -1
- package/dist/renderer-client.d.mts +6 -8
- package/dist/renderer-client.d.ts +6 -8
- package/dist/{request-CzZX0Aew.d.ts → request-BVGGeQv4.d.ts} +1 -1
- package/dist/{request-CXmQy5ks.d.mts → request-DlLVBKe3.d.mts} +1 -1
- package/dist/request.d.mts +9 -11
- package/dist/request.d.ts +9 -11
- package/dist/{route-rendering-Dw3C362T.d.ts → route-rendering-BdEldajn.d.ts} +1 -1
- package/dist/{route-rendering-B-qpe32B.d.mts → route-rendering-DChYLNdh.d.mts} +1 -1
- package/dist/{router-CLl3xHwl.d.ts → router-D0Az-1Nu.d.ts} +1 -1
- package/dist/{router-CafM2jlw.d.mts → router-D5htHn_M.d.mts} +1 -1
- package/dist/routes.d.mts +6 -8
- package/dist/routes.d.ts +6 -8
- package/dist/server-fn-client.d.mts +3 -4
- package/dist/server-fn-client.d.ts +3 -4
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-plugins.d.mts +8 -10
- package/dist/server-plugins.d.ts +8 -10
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server.cjs +292 -141
- package/dist/server.d.mts +13 -15
- package/dist/server.d.ts +13 -15
- package/dist/server.mjs +278 -127
- package/dist/{spa-router-6sJfsMlQ.d.mts → spa-router-DVfSJZ5o.d.mts} +2 -2
- package/dist/{spa-router-DePr2aZ6.d.ts → spa-router-DmwP_7QL.d.ts} +2 -2
- package/dist/testing.cjs +6 -5
- package/dist/testing.d.mts +7 -9
- package/dist/testing.d.ts +7 -9
- package/dist/testing.mjs +5 -4
- package/dist/{utils-BPHr-1mP.d.mts → utils-B_Rmr0-n.d.mts} +1 -1
- package/dist/{utils-BBKC3cf3.d.ts → utils-Dv0OuLtF.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +14 -12
- package/dist/vite.d.mts +8 -10
- package/dist/vite.d.ts +8 -10
- package/dist/vite.mjs +13 -11
- package/package.json +1 -1
- package/dist/route-B0XrsrFk.d.mts +0 -128
- package/dist/route-DOEpbyWZ.d.ts +0 -128
- package/dist/{chunk-GDUYXFIS.mjs → chunk-6EG7U4NF.mjs} +3 -3
- package/dist/{chunk-YAOX43YI.cjs → chunk-C7OUJ6JI.cjs} +2 -2
- package/dist/{chunk-IXTFU4PL.cjs → chunk-NL3ZSMZB.cjs} +2 -2
- package/dist/{chunk-L6V3P73N.mjs → chunk-UOXGA6TO.mjs} +4 -4
|
@@ -1,5 +1,14 @@
|
|
|
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 _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk5MKEDGLDcjs = require('./chunk-5MKEDGLD.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
4
13
|
|
|
5
14
|
// src/markdown-view.ts
|
|
@@ -39,10 +48,12 @@ function parseFarmMarkdownHeadings(markdown) {
|
|
|
39
48
|
end: lines.length
|
|
40
49
|
});
|
|
41
50
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const open = [];
|
|
52
|
+
for (const heading of headings) {
|
|
53
|
+
while (open.length > 0 && open[open.length - 1].level >= heading.level) {
|
|
54
|
+
open.pop().end = heading.start;
|
|
55
|
+
}
|
|
56
|
+
open.push(heading);
|
|
46
57
|
}
|
|
47
58
|
return headings;
|
|
48
59
|
}
|
|
@@ -55,23 +66,49 @@ function estimateFarmMarkdownTokens(text) {
|
|
|
55
66
|
return Math.ceil(text.length / 4);
|
|
56
67
|
}
|
|
57
68
|
_chunkS3JO3N4Hcjs.__name.call(void 0, estimateFarmMarkdownTokens, "estimateFarmMarkdownTokens");
|
|
69
|
+
var FARM_MARKDOWN_MIN_TOKEN_BUDGET = 100;
|
|
70
|
+
var FARM_MARKDOWN_VIEW_PARAMS = [
|
|
71
|
+
"outline",
|
|
72
|
+
"section",
|
|
73
|
+
"actions",
|
|
74
|
+
"max_tokens",
|
|
75
|
+
"cursor"
|
|
76
|
+
];
|
|
58
77
|
function selectFarmMarkdownView(markdown, searchParams, markdownPath) {
|
|
59
78
|
const wantsOutline = searchParams.has("outline");
|
|
60
79
|
const sectionId = searchParams.get("section");
|
|
61
|
-
|
|
80
|
+
const budget = searchParams.get("max_tokens");
|
|
81
|
+
if (!wantsOutline && sectionId === null && budget === null)
|
|
82
|
+
return { status: 200, body: markdown };
|
|
83
|
+
const viewUrl = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (view) => {
|
|
84
|
+
const query = new URLSearchParams(searchParams);
|
|
85
|
+
for (const name of FARM_MARKDOWN_VIEW_PARAMS) query.delete(name);
|
|
86
|
+
for (const [name, value] of Object.entries(view)) {
|
|
87
|
+
if (value !== null && value !== void 0) query.set(name, value);
|
|
88
|
+
}
|
|
89
|
+
const search = query.toString();
|
|
90
|
+
return search ? `${markdownPath}?${search}` : markdownPath;
|
|
91
|
+
}, "viewUrl");
|
|
92
|
+
const withinBudget = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (document) => budget === null ? { status: 200, body: document } : selectFarmMarkdownPart(
|
|
93
|
+
document,
|
|
94
|
+
budget,
|
|
95
|
+
searchParams.get("cursor"),
|
|
96
|
+
(cursor) => viewUrl({ section: sectionId, max_tokens: budget, cursor })
|
|
97
|
+
), "withinBudget");
|
|
98
|
+
if (!wantsOutline && sectionId === null) return withinBudget(markdown);
|
|
62
99
|
const lines = markdown.split("\n");
|
|
63
100
|
const headings = parseFarmMarkdownHeadings(markdown);
|
|
64
101
|
const sectionText = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (heading) => lines.slice(heading.start, heading.end).join("\n").trim(), "sectionText");
|
|
65
102
|
if (sectionId !== null) {
|
|
66
103
|
const heading = headings.find((candidate) => candidate.id === sectionId);
|
|
67
|
-
if (heading) return
|
|
68
|
-
`
|
|
104
|
+
if (heading) return withinBudget(`${sectionText(heading)}
|
|
105
|
+
`);
|
|
69
106
|
const available = headings.map((candidate) => `- \`${candidate.id}\``).join("\n");
|
|
70
107
|
return {
|
|
71
108
|
status: 404,
|
|
72
109
|
body: `# Section not found
|
|
73
110
|
|
|
74
|
-
|
|
111
|
+
${markdownCodeSpan(sectionId)} is not a section of ${markdownPath}.
|
|
75
112
|
|
|
76
113
|
` + (available ? `Available sections:
|
|
77
114
|
|
|
@@ -79,23 +116,31 @@ ${available}
|
|
|
79
116
|
` : "This page has no sections.\n")
|
|
80
117
|
};
|
|
81
118
|
}
|
|
82
|
-
const minLevel =
|
|
119
|
+
const minLevel = headings.reduce((min, heading) => Math.min(min, heading.level), 6);
|
|
83
120
|
const entries = headings.map((heading) => {
|
|
84
121
|
const indent = " ".repeat(heading.level - minLevel);
|
|
85
122
|
const tokens = estimateFarmMarkdownTokens(sectionText(heading));
|
|
86
|
-
return `${indent}- [${heading.text}](${
|
|
123
|
+
return `${indent}- [${heading.text}](${viewUrl({ section: heading.id })}) ~${tokens} tokens`;
|
|
87
124
|
});
|
|
88
125
|
return {
|
|
89
126
|
status: 200,
|
|
90
127
|
body: `# Outline of ${markdownPath}
|
|
91
128
|
|
|
92
|
-
About ${estimateFarmMarkdownTokens(markdown)} tokens in total. Request one section with \`?section=<id>\`.
|
|
129
|
+
About ${estimateFarmMarkdownTokens(markdown)} tokens in total. Request one section with \`?section=<id>\`, or read in parts with \`?max_tokens=<n>\`.
|
|
93
130
|
|
|
94
131
|
` + (entries.length > 0 ? `${entries.join("\n")}
|
|
95
132
|
` : "This page has no headings.\n")
|
|
96
133
|
};
|
|
97
134
|
}
|
|
98
135
|
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmMarkdownView, "selectFarmMarkdownView");
|
|
136
|
+
function markdownCodeSpan(value) {
|
|
137
|
+
const text = value.replace(/[\p{Cc}\u2028\u2029]+/gu, " ");
|
|
138
|
+
const longestRun = (_nullishCoalesce(text.match(/`+/g), () => ( []))).reduce((max, run) => Math.max(max, run.length), 0);
|
|
139
|
+
const fence = "`".repeat(longestRun + 1);
|
|
140
|
+
const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
|
|
141
|
+
return `${fence}${pad}${text}${pad}${fence}`;
|
|
142
|
+
}
|
|
143
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, markdownCodeSpan, "markdownCodeSpan");
|
|
99
144
|
function selectFarmPageActionsView(markdownPath, actions, headers) {
|
|
100
145
|
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
101
146
|
const page = markdownPath === "/index.md" ? "/" : markdownPath.replace(/\.md$/, "");
|
|
@@ -106,7 +151,117 @@ function selectFarmPageActionsView(markdownPath, actions, headers) {
|
|
|
106
151
|
};
|
|
107
152
|
}
|
|
108
153
|
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmPageActionsView, "selectFarmPageActionsView");
|
|
154
|
+
function selectFarmMarkdownPart(document, rawBudget, rawCursor, partUrl) {
|
|
155
|
+
const budget = /^\d{1,9}$/.test(rawBudget) ? Number(rawBudget) : Number.NaN;
|
|
156
|
+
if (!(budget >= FARM_MARKDOWN_MIN_TOKEN_BUDGET)) {
|
|
157
|
+
return {
|
|
158
|
+
status: 400,
|
|
159
|
+
body: `# Invalid max_tokens
|
|
160
|
+
|
|
161
|
+
\`max_tokens\` must be a whole number of at least ${FARM_MARKDOWN_MIN_TOKEN_BUDGET}.
|
|
162
|
+
`
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const lines = document.replace(/\n$/, "").split("\n");
|
|
166
|
+
const version = hashFarmMarkdown(document).slice(0, 8);
|
|
167
|
+
let start = 0;
|
|
168
|
+
if (rawCursor !== null) {
|
|
169
|
+
const match = /^(\d{1,9})\.([0-9a-z]+)$/.exec(rawCursor);
|
|
170
|
+
if (!match || Number(match[1]) <= 0 || Number(match[1]) >= lines.length) {
|
|
171
|
+
return {
|
|
172
|
+
status: 400,
|
|
173
|
+
body: `# Invalid cursor
|
|
174
|
+
|
|
175
|
+
Start again at ${partUrl()}.
|
|
176
|
+
`
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (match[2] !== version) {
|
|
180
|
+
return {
|
|
181
|
+
status: 409,
|
|
182
|
+
body: `# Page changed
|
|
183
|
+
|
|
184
|
+
The page changed after this cursor was issued. Start again at ${partUrl()}.
|
|
185
|
+
`
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
start = Number(match[1]);
|
|
189
|
+
}
|
|
190
|
+
const fences = readOpenFences(lines);
|
|
191
|
+
const reopen = fences[start];
|
|
192
|
+
const room = budget * 4 - 200;
|
|
193
|
+
let size = reopen ? reopen.opener.length + 1 : 0;
|
|
194
|
+
let end = start;
|
|
195
|
+
let lastBreak = -1;
|
|
196
|
+
while (end < lines.length) {
|
|
197
|
+
const length = lines[end].length + 1;
|
|
198
|
+
if (end > start && size + length > room) break;
|
|
199
|
+
size += length;
|
|
200
|
+
end++;
|
|
201
|
+
if (end < lines.length && isPartBreak(lines, fences, end)) lastBreak = end;
|
|
202
|
+
}
|
|
203
|
+
const head = reopen ? `${reopen.opener}
|
|
204
|
+
` : "";
|
|
205
|
+
if (end >= lines.length) {
|
|
206
|
+
return { status: 200, body: `${head}${lines.slice(start).join("\n")}
|
|
207
|
+
` };
|
|
208
|
+
}
|
|
209
|
+
if (lastBreak > start) end = lastBreak;
|
|
210
|
+
const open = fences[end];
|
|
211
|
+
const part = `${head}${lines.slice(start, end).join("\n").replace(/\n+$/, "")}${open ? `
|
|
212
|
+
${open.closer}` : ""}`;
|
|
213
|
+
const next = partUrl(`${end}.${version}`);
|
|
214
|
+
const remaining = estimateFarmMarkdownTokens(lines.slice(end).join("\n"));
|
|
215
|
+
return {
|
|
216
|
+
status: 200,
|
|
217
|
+
body: `${part}
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
Continue: ${next} (about ${remaining} more tokens)
|
|
222
|
+
`,
|
|
223
|
+
headers: { Link: `<${next}>; rel="next"` }
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmMarkdownPart, "selectFarmMarkdownPart");
|
|
227
|
+
function readOpenFences(lines) {
|
|
228
|
+
const open = [];
|
|
229
|
+
let fence;
|
|
230
|
+
let frontMatter = _optionalChain([lines, 'access', _5 => _5[0], 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]) === "---";
|
|
231
|
+
for (let index = 0; index < lines.length; index++) {
|
|
232
|
+
open.push(frontMatter && index > 0 ? { opener: "", closer: "" } : fence);
|
|
233
|
+
const line = lines[index];
|
|
234
|
+
if (frontMatter) {
|
|
235
|
+
if (index > 0 && line.trim() === "---") frontMatter = false;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const match = FENCE.exec(line);
|
|
239
|
+
if (!match) continue;
|
|
240
|
+
const marker = match[1];
|
|
241
|
+
if (!fence) fence = { opener: line.trim(), closer: marker, marker };
|
|
242
|
+
else if (marker[0] === fence.marker[0] && marker.length >= fence.marker.length)
|
|
243
|
+
fence = void 0;
|
|
244
|
+
}
|
|
245
|
+
return open;
|
|
246
|
+
}
|
|
247
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readOpenFences, "readOpenFences");
|
|
248
|
+
function isPartBreak(lines, fences, index) {
|
|
249
|
+
if (fences[index]) return false;
|
|
250
|
+
return lines[index - 1].trim() === "" || ATX_HEADING.test(lines[index]);
|
|
251
|
+
}
|
|
252
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPartBreak, "isPartBreak");
|
|
253
|
+
function readMarkdownViewName(searchParams) {
|
|
254
|
+
if (searchParams.has("actions")) return "actions";
|
|
255
|
+
if (searchParams.has("outline")) return "outline";
|
|
256
|
+
if (searchParams.has("max_tokens")) return "parts";
|
|
257
|
+
return searchParams.has("section") ? "section" : void 0;
|
|
258
|
+
}
|
|
259
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readMarkdownViewName, "readMarkdownViewName");
|
|
109
260
|
function createFarmMarkdownETag(body) {
|
|
261
|
+
return `W/"${hashFarmMarkdown(body)}-${body.length.toString(36)}"`;
|
|
262
|
+
}
|
|
263
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmMarkdownETag, "createFarmMarkdownETag");
|
|
264
|
+
function hashFarmMarkdown(body) {
|
|
110
265
|
let h1 = 3735928559;
|
|
111
266
|
let h2 = 1103547991;
|
|
112
267
|
for (let index = 0; index < body.length; index++) {
|
|
@@ -116,10 +271,9 @@ function createFarmMarkdownETag(body) {
|
|
|
116
271
|
}
|
|
117
272
|
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
118
273
|
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
119
|
-
|
|
120
|
-
return `W/"${hash}-${body.length.toString(36)}"`;
|
|
274
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
|
|
121
275
|
}
|
|
122
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0,
|
|
276
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, hashFarmMarkdown, "hashFarmMarkdown");
|
|
123
277
|
function ifNoneMatchIncludes(header, etag) {
|
|
124
278
|
if (!header) return false;
|
|
125
279
|
const opaque = etag.replace(/^W\//, "");
|
|
@@ -130,6 +284,9 @@ function createFarmMarkdownViewResponse(options) {
|
|
|
130
284
|
const url = _nullishCoalesce(options.requestUrl, () => ( new URL(options.request.url)));
|
|
131
285
|
const view = url.searchParams.has("actions") ? selectFarmPageActionsView(options.markdownPath, _nullishCoalesce(options.actions, () => ( [])), options.headers) : selectFarmMarkdownView(options.markdown, url.searchParams, options.markdownPath);
|
|
132
286
|
const status = view.status === 200 ? options.status : view.status;
|
|
287
|
+
_chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, options.request, "markdown", status, readMarkdownViewName(url.searchParams));
|
|
288
|
+
for (const [name, value] of Object.entries(_nullishCoalesce(view.headers, () => ( {}))))
|
|
289
|
+
options.headers.append(name, value);
|
|
133
290
|
const etag = createFarmMarkdownETag(view.body);
|
|
134
291
|
options.headers.set("ETag", etag);
|
|
135
292
|
if (status === 200 && ifNoneMatchIncludes(options.request.headers.get("if-none-match"), etag)) {
|
|
@@ -187,7 +344,7 @@ function resolveMarkdownConfig(config) {
|
|
|
187
344
|
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveMarkdownConfig, "resolveMarkdownConfig");
|
|
188
345
|
function resolveMarkdownMirrorTarget(config, pathname, options = {}) {
|
|
189
346
|
const hasMarkdownExtension = pathname.toLowerCase().endsWith(".md");
|
|
190
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
347
|
+
if (!_optionalChain([config, 'optionalAccess', _8 => _8.enabled]) || !hasMarkdownExtension && !requestAcceptsMarkdown(options.accept)) {
|
|
191
348
|
return null;
|
|
192
349
|
}
|
|
193
350
|
const targetPathname = normalizeMarkdownRoute(
|
|
@@ -207,7 +364,7 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
207
364
|
if (options.request.method !== "GET" && options.request.method !== "HEAD") {
|
|
208
365
|
return null;
|
|
209
366
|
}
|
|
210
|
-
const requestUrl = _optionalChain([options, 'access',
|
|
367
|
+
const requestUrl = _optionalChain([options, 'access', _9 => _9.requestUrl, 'optionalAccess', _10 => _10.href]) === options.request.url ? options.requestUrl : new URL(options.request.url);
|
|
211
368
|
const hasMarkdownExtension = requestUrl.pathname.toLowerCase().endsWith(".md");
|
|
212
369
|
const target = resolveMarkdownMirrorTarget(options.config, requestUrl.pathname, {
|
|
213
370
|
accept: options.request.headers.get("accept")
|
|
@@ -220,7 +377,7 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
220
377
|
}
|
|
221
378
|
const pageUrl = new URL(options.request.url);
|
|
222
379
|
pageUrl.pathname = target.pathname;
|
|
223
|
-
for (const name of
|
|
380
|
+
for (const name of FARM_MARKDOWN_VIEW_PARAMS) pageUrl.searchParams.delete(name);
|
|
224
381
|
const headers = new Headers(options.request.headers);
|
|
225
382
|
headers.set("accept", "text/html");
|
|
226
383
|
const pageResponse = await options.renderPage(
|
|
@@ -229,7 +386,8 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
229
386
|
headers
|
|
230
387
|
})
|
|
231
388
|
);
|
|
232
|
-
|
|
389
|
+
const redirects = pageResponse.status >= 300 && pageResponse.status < 400 && pageResponse.headers.has("location");
|
|
390
|
+
if (redirects || !isHtmlResponse(pageResponse)) {
|
|
233
391
|
return createMarkdownAccessResponse(
|
|
234
392
|
pageResponse,
|
|
235
393
|
target.pathname,
|
|
@@ -240,9 +398,15 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
240
398
|
const html = await pageResponse.text();
|
|
241
399
|
const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
|
|
242
400
|
const actions = extractFarmPageActions(html, pageUrl);
|
|
401
|
+
for (const form of actions) {
|
|
402
|
+
if (!_optionalChain([form, 'access', _11 => _11.action, 'optionalAccess', _12 => _12.startsWith, 'call', _13 => _13("/")])) continue;
|
|
403
|
+
const pathname = new URL(form.action, pageUrl.origin).pathname;
|
|
404
|
+
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
|
+
if (tool) form.tool = tool;
|
|
406
|
+
}
|
|
243
407
|
const markdown = htmlToMarkdown(html, {
|
|
244
|
-
title: _optionalChain([target, 'access',
|
|
245
|
-
includeMetadata: _nullishCoalesce(_optionalChain([options, 'access',
|
|
408
|
+
title: _optionalChain([target, 'access', _14 => _14.route, 'optionalAccess', _15 => _15.title]),
|
|
409
|
+
includeMetadata: _nullishCoalesce(_optionalChain([options, 'access', _16 => _16.config, 'optionalAccess', _17 => _17.includeMetadata]), () => ( true)),
|
|
246
410
|
sourcePath: target.pathname,
|
|
247
411
|
actionsPath: actions.length > 0 ? `${markdownPath}?actions` : void 0
|
|
248
412
|
});
|
|
@@ -254,17 +418,17 @@ async function createMarkdownMirrorResponse(options) {
|
|
|
254
418
|
if (!hasMarkdownExtension) {
|
|
255
419
|
headersOut.set("Vary", "Accept");
|
|
256
420
|
}
|
|
257
|
-
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access',
|
|
421
|
+
for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access', _18 => _18.headers, 'access', _19 => _19.get, 'call', _20 => _20("vary"), 'optionalAccess', _21 => _21.split, 'call', _22 => _22(",")]), () => ( []))) {
|
|
258
422
|
const name = token.trim();
|
|
259
423
|
if (name && name.toLowerCase() !== "accept") appendHeaderToken(headersOut, "Vary", name);
|
|
260
424
|
}
|
|
261
425
|
const pageCacheControl = pageResponse.headers.get("cache-control");
|
|
262
|
-
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access',
|
|
426
|
+
const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access', _23 => _23.route, 'optionalAccess', _24 => _24.cache]), () => ( _optionalChain([options, 'access', _25 => _25.config, 'optionalAccess', _26 => _26.cache]))), () => ( false));
|
|
263
427
|
headersOut.set(
|
|
264
428
|
"Cache-Control",
|
|
265
429
|
pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : createMarkdownCacheHeader(cache)
|
|
266
430
|
);
|
|
267
|
-
const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess',
|
|
431
|
+
const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess', _27 => _27.trim, 'call', _28 => _28()]))).join(", ");
|
|
268
432
|
if (robots) headersOut.set("X-Robots-Tag", robots);
|
|
269
433
|
const canonical = readHtmlCanonicalHref(html);
|
|
270
434
|
if (canonical) {
|
|
@@ -521,7 +685,7 @@ function getFarmMarkdownAlternatePath(config, pathname) {
|
|
|
521
685
|
}
|
|
522
686
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmMarkdownAlternatePath, "getFarmMarkdownAlternatePath");
|
|
523
687
|
function isFarmMarkdownMirrorExposed(config, pathname) {
|
|
524
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
688
|
+
if (!_optionalChain([config, 'optionalAccess', _29 => _29.enabled])) return false;
|
|
525
689
|
return config.expose === true || findExposedMarkdownRoute(config, pathname) !== null;
|
|
526
690
|
}
|
|
527
691
|
_chunkS3JO3N4Hcjs.__name.call(void 0, isFarmMarkdownMirrorExposed, "isFarmMarkdownMirrorExposed");
|
|
@@ -614,7 +778,7 @@ function extractHtmlBody(html) {
|
|
|
614
778
|
const body = rootMatch ? rootMatch[1] : bodyMatch ? bodyMatch[1] : html;
|
|
615
779
|
const main = extractFirstElementContent(body, ["main"]);
|
|
616
780
|
if (main !== void 0) return main;
|
|
617
|
-
const articles = _nullishCoalesce(_optionalChain([body, 'access',
|
|
781
|
+
const articles = _nullishCoalesce(_optionalChain([body, 'access', _30 => _30.match, 'call', _31 => _31(/<article\b/gi), 'optionalAccess', _32 => _32.length]), () => ( 0));
|
|
618
782
|
return articles === 1 ? _nullishCoalesce(extractFirstElementContent(body, ["article"]), () => ( body)) : body;
|
|
619
783
|
}
|
|
620
784
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractHtmlBody, "extractHtmlBody");
|
|
@@ -630,7 +794,7 @@ function extractFirstElementContent(html, tagNames) {
|
|
|
630
794
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFirstElementContent, "extractFirstElementContent");
|
|
631
795
|
function readHtmlMetaContent(html, name) {
|
|
632
796
|
for (const match of html.matchAll(/<meta\b([^>]*)>/gi)) {
|
|
633
|
-
if (_optionalChain([readHtmlAttribute, 'call',
|
|
797
|
+
if (_optionalChain([readHtmlAttribute, 'call', _33 => _33(match[1], "name"), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()]) === name) {
|
|
634
798
|
return readHtmlAttribute(match[1], "content");
|
|
635
799
|
}
|
|
636
800
|
}
|
|
@@ -639,8 +803,8 @@ function readHtmlMetaContent(html, name) {
|
|
|
639
803
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlMetaContent, "readHtmlMetaContent");
|
|
640
804
|
function readHtmlCanonicalHref(html) {
|
|
641
805
|
for (const match of html.matchAll(/<link\b([^>]*)>/gi)) {
|
|
642
|
-
const rel = _optionalChain([readHtmlAttribute, 'call',
|
|
643
|
-
if (_optionalChain([rel, 'optionalAccess',
|
|
806
|
+
const rel = _optionalChain([readHtmlAttribute, 'call', _36 => _36(match[1], "rel"), 'optionalAccess', _37 => _37.toLowerCase, 'call', _38 => _38(), 'access', _39 => _39.split, 'call', _40 => _40(/\s+/)]);
|
|
807
|
+
if (_optionalChain([rel, 'optionalAccess', _41 => _41.includes, 'call', _42 => _42("canonical")])) return readHtmlAttribute(match[1], "href");
|
|
644
808
|
}
|
|
645
809
|
return void 0;
|
|
646
810
|
}
|
|
@@ -667,7 +831,7 @@ function extractFarmPageActions(html, pageUrl) {
|
|
|
667
831
|
}
|
|
668
832
|
_chunkS3JO3N4Hcjs.__name.call(void 0, extractFarmPageActions, "extractFarmPageActions");
|
|
669
833
|
function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
670
|
-
const method = _optionalChain([readDecodedAttribute, 'call',
|
|
834
|
+
const method = _optionalChain([readDecodedAttribute, 'call', _43 => _43(attributes, "method"), 'optionalAccess', _44 => _44.trim, 'call', _45 => _45(), 'access', _46 => _46.toLowerCase, 'call', _47 => _47()]);
|
|
671
835
|
if (method === "dialog") return void 0;
|
|
672
836
|
const target = resolveFormTarget(readDecodedAttribute(attributes, "action"), pageUrl);
|
|
673
837
|
const form = {
|
|
@@ -677,11 +841,11 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
677
841
|
submit: []
|
|
678
842
|
};
|
|
679
843
|
const name = _nullishCoalesce(_nullishCoalesce(readDecodedAttribute(attributes, "aria-label"), () => ( readDecodedAttribute(attributes, "name"))), () => ( readDecodedAttribute(attributes, "id")));
|
|
680
|
-
if (_optionalChain([name, 'optionalAccess',
|
|
844
|
+
if (_optionalChain([name, 'optionalAccess', _48 => _48.trim, 'call', _49 => _49()])) form.name = name.trim();
|
|
681
845
|
if (target) form.action = target;
|
|
682
846
|
else form.requiresJavaScript = true;
|
|
683
847
|
if (form.method === "POST") {
|
|
684
|
-
const enctype = _optionalChain([readDecodedAttribute, 'call',
|
|
848
|
+
const enctype = _optionalChain([readDecodedAttribute, 'call', _50 => _50(attributes, "enctype"), 'optionalAccess', _51 => _51.trim, 'call', _52 => _52(), 'access', _53 => _53.toLowerCase, 'call', _54 => _54()]);
|
|
685
849
|
form.enctype = enctype && FORM_ENCTYPES.has(enctype) ? enctype : "application/x-www-form-urlencoded";
|
|
686
850
|
}
|
|
687
851
|
const wrappingLabels = [...content.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/gi)].map(
|
|
@@ -692,13 +856,13 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
692
856
|
})
|
|
693
857
|
);
|
|
694
858
|
const labelOf = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (controlAttributes, index) => {
|
|
695
|
-
const aria = _optionalChain([readDecodedAttribute, 'call',
|
|
859
|
+
const aria = _optionalChain([readDecodedAttribute, 'call', _55 => _55(controlAttributes, "aria-label"), 'optionalAccess', _56 => _56.trim, 'call', _57 => _57()]);
|
|
696
860
|
if (aria) return aria;
|
|
697
861
|
const id = readDecodedAttribute(controlAttributes, "id");
|
|
698
862
|
const forLabel = id ? labelsFor.get(id) : void 0;
|
|
699
863
|
if (forLabel) return forLabel;
|
|
700
864
|
const wrapping = wrappingLabels.find((label) => label.start < index && index < label.end);
|
|
701
|
-
return _optionalChain([wrapping, 'optionalAccess',
|
|
865
|
+
return _optionalChain([wrapping, 'optionalAccess', _58 => _58.text]) || void 0;
|
|
702
866
|
}, "labelOf");
|
|
703
867
|
const groups = /* @__PURE__ */ new Map();
|
|
704
868
|
const controls = /<(input)\b([^>]*)>|<(select|textarea|button)\b([^>]*)>([\s\S]*?)<\/\3>/gi;
|
|
@@ -709,7 +873,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
709
873
|
if (hasHtmlAttribute(controlAttributes, "disabled")) continue;
|
|
710
874
|
const label = labelOf(controlAttributes, match.index);
|
|
711
875
|
const fieldName = readDecodedAttribute(controlAttributes, "name");
|
|
712
|
-
const typeAttribute = _optionalChain([readDecodedAttribute, 'call',
|
|
876
|
+
const typeAttribute = _optionalChain([readDecodedAttribute, 'call', _59 => _59(controlAttributes, "type"), 'optionalAccess', _60 => _60.trim, 'call', _61 => _61(), 'access', _62 => _62.toLowerCase, 'call', _63 => _63()]);
|
|
713
877
|
const type = tag === "input" ? _nullishCoalesce(typeAttribute, () => ( "text")) : tag === "button" ? _nullishCoalesce(typeAttribute, () => ( "submit")) : tag;
|
|
714
878
|
if (tag === "button" && !["button", "reset"].includes(type) || tag === "input" && (type === "submit" || type === "image")) {
|
|
715
879
|
const submit = {
|
|
@@ -723,7 +887,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
|
|
|
723
887
|
const resolved = resolveFormTarget(formAction, pageUrl);
|
|
724
888
|
if (resolved) submit.action = resolved;
|
|
725
889
|
}
|
|
726
|
-
const formMethod = _optionalChain([readDecodedAttribute, 'call',
|
|
890
|
+
const formMethod = _optionalChain([readDecodedAttribute, 'call', _64 => _64(controlAttributes, "formmethod"), 'optionalAccess', _65 => _65.toLowerCase, 'call', _66 => _66()]);
|
|
727
891
|
if (formMethod === "get" || formMethod === "post") submit.method = formMethod.toUpperCase();
|
|
728
892
|
form.submit.push(submit);
|
|
729
893
|
continue;
|
|
@@ -802,7 +966,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, readPageForm, "readPageForm");
|
|
|
802
966
|
function resolveFormTarget(action, pageUrl) {
|
|
803
967
|
let target;
|
|
804
968
|
try {
|
|
805
|
-
target = new URL(_optionalChain([action, 'optionalAccess',
|
|
969
|
+
target = new URL(_optionalChain([action, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]) || pageUrl.href, pageUrl);
|
|
806
970
|
} catch (e4) {
|
|
807
971
|
return void 0;
|
|
808
972
|
}
|
|
@@ -834,7 +998,7 @@ function readHtmlAttribute(attributes, name) {
|
|
|
834
998
|
_chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlAttribute, "readHtmlAttribute");
|
|
835
999
|
function readCodeLanguage(attributesList) {
|
|
836
1000
|
for (const attributes of attributesList) {
|
|
837
|
-
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call',
|
|
1001
|
+
const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call', _69 => _69(attributes, "class"), 'optionalAccess', _70 => _70.match, 'call', _71 => _71(/(?:^|\s)lang(?:uage)?-(\S+)/), 'optionalAccess', _72 => _72[1]])));
|
|
838
1002
|
if (language && /^[\w#+.-]+$/.test(language)) return language;
|
|
839
1003
|
}
|
|
840
1004
|
return void 0;
|
|
@@ -947,7 +1111,7 @@ function matchClosingTags(html) {
|
|
|
947
1111
|
while (match = tags.exec(html)) {
|
|
948
1112
|
const name = match[2].toLowerCase();
|
|
949
1113
|
if (match[1]) {
|
|
950
|
-
const start = _optionalChain([open, 'access',
|
|
1114
|
+
const start = _optionalChain([open, 'access', _73 => _73.get, 'call', _74 => _74(name), 'optionalAccess', _75 => _75.pop, 'call', _76 => _76()]);
|
|
951
1115
|
if (start !== void 0) closes.set(start, match.index + match[0].length);
|
|
952
1116
|
} else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
|
|
953
1117
|
let starts = open.get(name);
|
|
@@ -982,7 +1146,7 @@ function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
|
|
|
982
1146
|
let cursor = 0;
|
|
983
1147
|
let match;
|
|
984
1148
|
while (match = openingTag.exec(html)) {
|
|
985
|
-
const id = _optionalChain([/\sid="([^"]*)"/, 'access',
|
|
1149
|
+
const id = _optionalChain([/\sid="([^"]*)"/, 'access', _77 => _77.exec, 'call', _78 => _78(match[2]), 'optionalAccess', _79 => _79[1]]);
|
|
986
1150
|
if (!id || !wanted.has(id) || segments.has(id)) continue;
|
|
987
1151
|
const close = closingTags.get(match.index);
|
|
988
1152
|
if (close === void 0) continue;
|