@farm.js/core 0.1.64 → 0.1.66
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/{analyzer-Q3QXC6PD.mjs → analyzer-4UFP4HVP.mjs} +3 -3
- package/dist/analyzer-H7SIX6BJ.cjs +16 -0
- package/dist/{chunk-XVWSDSUM.mjs → chunk-27FPUFWR.mjs} +60 -5
- package/dist/{chunk-JCEFKP5M.mjs → chunk-423SSBYQ.mjs} +6 -0
- package/dist/{chunk-SLYDIHLW.mjs → chunk-435QJNC2.mjs} +2 -2
- package/dist/{chunk-XZLZ6YPP.cjs → chunk-4OSOLDPL.cjs} +118 -50
- package/dist/{chunk-MG356ROI.cjs → chunk-4TVPYN32.cjs} +3 -3
- package/dist/chunk-672ISQIG.mjs +3704 -0
- package/dist/{chunk-NXFA7G3Y.cjs → chunk-752IHQTD.cjs} +4 -4
- package/dist/chunk-7ONGIFYX.cjs +3704 -0
- package/dist/{chunk-RAH5MT53.mjs → chunk-AZUUKA66.mjs} +153 -42
- package/dist/{chunk-O2XFIPNL.cjs → chunk-BIF5MLTH.cjs} +1 -1
- package/dist/{chunk-FH45OB37.mjs → chunk-BYRZ5VTH.mjs} +1 -1
- package/dist/{chunk-V727H3RI.cjs → chunk-CCAUIBIS.cjs} +6 -0
- package/dist/{chunk-DUSHDZQL.cjs → chunk-CHYTADNK.cjs} +15 -13
- package/dist/chunk-CJNAUEVC.mjs +34 -0
- package/dist/{chunk-S25BQIFW.cjs → chunk-DVKH2RVN.cjs} +2 -2
- package/dist/{chunk-FAP7CX7C.cjs → chunk-E4UDLFWR.cjs} +527 -3019
- package/dist/{chunk-EFZGB7JC.cjs → chunk-E5UN4OWX.cjs} +1 -0
- package/dist/{chunk-WNYRYI4D.mjs → chunk-EMNKZGF4.mjs} +380 -2872
- package/dist/{chunk-VVTJTMGQ.cjs → chunk-GL7N5UHF.cjs} +4 -4
- package/dist/{chunk-UR25Z5Z6.mjs → chunk-HCGWDRZO.mjs} +1 -1
- package/dist/{chunk-EL4364S2.cjs → chunk-HZPKJRYA.cjs} +74 -19
- package/dist/{chunk-3EBHJET2.cjs → chunk-IT6WRNGB.cjs} +380 -269
- package/dist/{chunk-LQDLEWPO.mjs → chunk-MPIGW42F.mjs} +1 -1
- package/dist/{chunk-S7ZW72JH.cjs → chunk-MPJEIHW2.cjs} +2 -2
- package/dist/{chunk-53ZCZ46B.cjs → chunk-NHQM2Q4I.cjs} +2 -1
- package/dist/{chunk-UYRI6U3P.mjs → chunk-O75GQVUK.mjs} +2 -1
- package/dist/{chunk-OYF23QLG.mjs → chunk-OB7VKCUZ.mjs} +38 -33
- package/dist/{chunk-JCPSA4X5.cjs → chunk-OP7LHY4Y.cjs} +128 -123
- package/dist/{chunk-O7IEMY55.cjs → chunk-RY4ABNPE.cjs} +3 -3
- package/dist/{chunk-6NHSGVVA.mjs → chunk-SK7QSNWE.mjs} +1 -1
- package/dist/{chunk-NNLFW3P4.mjs → chunk-TKK5QHKZ.mjs} +1 -1
- package/dist/{chunk-ZNXTU4YH.mjs → chunk-TM2E623I.mjs} +1 -0
- package/dist/{chunk-PAKCHVUS.mjs → chunk-TPA2PV5J.mjs} +3 -35
- package/dist/{chunk-6NNYPY5W.mjs → chunk-UBMHQVWN.mjs} +78 -10
- package/dist/{chunk-BPNOYILC.cjs → chunk-UVV3I5QA.cjs} +3 -35
- package/dist/{chunk-N3Z3PLHC.cjs → chunk-VBCQ5WOI.cjs} +6 -6
- package/dist/{chunk-WFNAOWH4.mjs → chunk-WFWFECDW.mjs} +2 -2
- package/dist/{chunk-SNFTMSHX.mjs → chunk-WVYRLP5E.mjs} +1 -1
- package/dist/{chunk-O4FWNLQK.mjs → chunk-XBSLKXBL.mjs} +10 -8
- package/dist/chunk-ZIHWAN55.cjs +34 -0
- package/dist/{devtools-WET5NAKO.cjs → devtools-N2JQCMXB.cjs} +5 -4
- package/dist/{devtools-MX3FE733.mjs → devtools-NZUVNUP3.mjs} +4 -3
- package/dist/docs.cjs +6 -5
- package/dist/docs.mjs +5 -4
- package/dist/environment/vite.cjs +9 -2
- package/dist/environment/vite.d.mts +3 -0
- package/dist/environment/vite.d.ts +3 -0
- package/dist/environment/vite.mjs +8 -1
- package/dist/index.cjs +22 -21
- package/dist/index.mjs +21 -20
- package/dist/internal/build-runtime.cjs +20 -19
- package/dist/internal/build-runtime.mjs +19 -18
- package/dist/internal/cli-runtime.cjs +6 -5
- package/dist/internal/cli-runtime.mjs +5 -4
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/config-runtime.cjs +6 -5
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/infra-analytics-runtime.cjs +6 -6
- package/dist/internal/infra-analytics-runtime.mjs +4 -4
- package/dist/internal/native-server-fns.cjs +5 -5
- package/dist/internal/native-server-fns.mjs +4 -4
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +7 -7
- package/dist/internal/production-runtime.d.mts +14 -0
- package/dist/internal/production-runtime.d.ts +14 -0
- package/dist/internal/production-runtime.mjs +6 -6
- package/dist/{native-tree-WOX3JMBG.cjs → native-tree-7LPH57Z4.cjs} +3 -3
- package/dist/{native-tree-BPEE2LAL.mjs → native-tree-VV6WN3GX.mjs} +2 -2
- package/dist/plugin.cjs +11 -10
- package/dist/plugin.mjs +10 -9
- package/dist/{port-UFUZL6RI.mjs → port-CLL4BC4O.mjs} +1 -1
- package/dist/{port-VTLHPZOI.cjs → port-HASZTQGY.cjs} +9 -9
- package/dist/{rsc-pipeline-3LNVP2OO.mjs → rsc-pipeline-7PNVJSTR.mjs} +6 -5
- package/dist/{rsc-pipeline-G5WELVW3.cjs → rsc-pipeline-Z7QBZOIJ.cjs} +7 -6
- package/dist/{runtime-DMEULPE7.cjs → runtime-FKFCUHSK.cjs} +21 -20
- package/dist/{runtime-HQJ2LLQL.mjs → runtime-QQHX4BP3.mjs} +12 -11
- package/dist/server.cjs +36 -35
- package/dist/server.mjs +19 -18
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +14 -12
- package/dist/vite.mjs +13 -11
- package/package.json +1 -1
- package/dist/analyzer-ODLF2Z6O.cjs +0 -16
- package/dist/chunk-NK2VWS7P.cjs +0 -954
- package/dist/chunk-ZQ5BDNKW.mjs +0 -954
|
@@ -1,7 +1,7 @@
|
|
|
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
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkZIHWAN55cjs = require('./chunk-ZIHWAN55.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkQMNWKQL4cjs = require('./chunk-QMNWKQL4.cjs');
|
|
@@ -37,7 +37,7 @@ var FARM_RSC_IGNORED_KEYS = [
|
|
|
37
37
|
"observability"
|
|
38
38
|
];
|
|
39
39
|
function farmConfigUsesServerComponents(config) {
|
|
40
|
-
return
|
|
40
|
+
return _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'optionalAccess', _ => _.experimental, 'optionalAccess', _2 => _2.serverComponents])) === "rsc";
|
|
41
41
|
}
|
|
42
42
|
function findFarmAppPackageDir(root, packageName) {
|
|
43
43
|
for (let dir = _path2.default.resolve(root); ; dir = _path2.default.dirname(dir)) {
|
|
@@ -57,9 +57,9 @@ function isSet(value, key) {
|
|
|
57
57
|
}
|
|
58
58
|
function inspectFarmServerComponents(config, root) {
|
|
59
59
|
const value = _optionalChain([config, 'optionalAccess', _4 => _4.experimental, 'optionalAccess', _5 => _5.serverComponents]);
|
|
60
|
-
const mode =
|
|
60
|
+
const mode = _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, value);
|
|
61
61
|
const enabled = mode === "rsc";
|
|
62
|
-
const explicit = enabled &&
|
|
62
|
+
const explicit = enabled && _chunkZIHWAN55cjs.isExplicitFarmServerComponentsMode.call(void 0, value);
|
|
63
63
|
const missingPackages = enabled ? FARM_RSC_PACKAGES.filter((name) => !findFarmAppPackageDir(root, name)) : [];
|
|
64
64
|
return {
|
|
65
65
|
mode,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkCCAUIBIScjs = require('./chunk-CCAUIBIS.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
|
|
@@ -26,12 +26,16 @@ var VOID_TAGS = new Set(
|
|
|
26
26
|
"area base br col embed hr img input link meta source track wbr".split(" ")
|
|
27
27
|
);
|
|
28
28
|
var SKIPPED_TAGS = new Set("link meta template title".split(" "));
|
|
29
|
+
var TABLE_GROUP_TAGS = new Set("table thead tbody tfoot".split(" "));
|
|
30
|
+
var TABLE_CELL_TAGS = new Set("th td".split(" "));
|
|
29
31
|
var INLINE_DEFAULTS = {
|
|
30
32
|
strong: { fontWeight: 700 },
|
|
31
33
|
b: { fontWeight: 700 },
|
|
32
34
|
em: { fontStyle: "italic" },
|
|
33
35
|
i: { fontStyle: "italic" },
|
|
34
|
-
code: { fontFamily: "mono" }
|
|
36
|
+
code: { fontFamily: "mono" },
|
|
37
|
+
th: { fontWeight: 700, textAlign: "center" },
|
|
38
|
+
caption: { textAlign: "center" }
|
|
35
39
|
};
|
|
36
40
|
var ENTITIES = {
|
|
37
41
|
amp: "&",
|
|
@@ -107,11 +111,11 @@ function find(element, test) {
|
|
|
107
111
|
}
|
|
108
112
|
function textOnly(style) {
|
|
109
113
|
return Object.fromEntries(
|
|
110
|
-
Object.entries(style).filter(([key]) =>
|
|
114
|
+
Object.entries(style).filter(([key]) => _chunkCCAUIBIScjs.FARM_NATIVE_TEXT_KEYS.has(key))
|
|
111
115
|
);
|
|
112
116
|
}
|
|
113
117
|
function withoutText(style) {
|
|
114
|
-
const rest = Object.entries(style).filter(([key]) => !
|
|
118
|
+
const rest = Object.entries(style).filter(([key]) => !_chunkCCAUIBIScjs.FARM_NATIVE_TEXT_KEYS.has(key));
|
|
115
119
|
return rest.length > 0 ? Object.fromEntries(rest) : void 0;
|
|
116
120
|
}
|
|
117
121
|
function settleLineHeight(style) {
|
|
@@ -157,8 +161,8 @@ var Converter = class {
|
|
|
157
161
|
if (this.reporting && !this.unsupported.includes(message)) this.unsupported.push(message);
|
|
158
162
|
}
|
|
159
163
|
stylesOf(element) {
|
|
160
|
-
const classes =
|
|
161
|
-
const cascade = this.sheets ?
|
|
164
|
+
const classes = _chunkCCAUIBIScjs.resolveFarmNativeClasses.call(void 0, _nullishCoalesce(element.attributes.class, () => ( "")));
|
|
165
|
+
const cascade = this.sheets ? _chunkCCAUIBIScjs.cascadeFarmNativeStylesheets.call(void 0, this.sheets, element) : void 0;
|
|
162
166
|
for (const token of classes.unsupported) {
|
|
163
167
|
if (!cascade || cascade.layered.includes(token.split(":").pop())) {
|
|
164
168
|
this.problem(`<${element.tag}> class "${token}"`);
|
|
@@ -167,7 +171,7 @@ var Converter = class {
|
|
|
167
171
|
for (const problem of _nullishCoalesce(_optionalChain([cascade, 'optionalAccess', _ => _.unsupported]), () => ( []))) {
|
|
168
172
|
this.problem(`<${element.tag}> ${problem}`);
|
|
169
173
|
}
|
|
170
|
-
const inline =
|
|
174
|
+
const inline = _chunkCCAUIBIScjs.resolveFarmNativeInlineStyle.call(void 0, _nullishCoalesce(element.attributes.style, () => ( "")), this.vars);
|
|
171
175
|
for (const declaration of inline.unsupported) {
|
|
172
176
|
this.problem(`<${element.tag}> style "${declaration}"`);
|
|
173
177
|
}
|
|
@@ -369,12 +373,58 @@ var Converter = class {
|
|
|
369
373
|
else node.submit = this.submitter(element);
|
|
370
374
|
return node;
|
|
371
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* A table as native views: the table and its row groups are columns, a row is a row, and its
|
|
378
|
+
* cells share the row's width, `colspan` cells a wider share, so columns line up from row to row
|
|
379
|
+
* (as `table-layout: fixed` lays them out). A cell's content draws as any block content does.
|
|
380
|
+
*/
|
|
381
|
+
tablePart(element, passed, box, boxDark, flex) {
|
|
382
|
+
const { tag } = element;
|
|
383
|
+
if (TABLE_CELL_TAGS.has(tag)) {
|
|
384
|
+
if (_optionalChain([element, 'access', _18 => _18.parent, 'optionalAccess', _19 => _19.tag]) !== "tr") this.problem(`<${tag}> outside a row`);
|
|
385
|
+
const rowspan = Number(_nullishCoalesce(element.attributes.rowspan, () => ( 1)));
|
|
386
|
+
if (rowspan !== 1) this.problem(`<${tag}> rowspan="${element.attributes.rowspan}"`);
|
|
387
|
+
const colspan = Number(_nullishCoalesce(element.attributes.colspan, () => ( 1)));
|
|
388
|
+
const share = Number.isInteger(colspan) && colspan >= 1 ? colspan : 1;
|
|
389
|
+
const cell = _optionalChain([box, 'optionalAccess', _20 => _20.width]) !== void 0 ? { flexGrow: 0, flexShrink: 0, ...box } : { flexGrow: share, flexShrink: 1, flexBasis: 0, ...box };
|
|
390
|
+
const node2 = this.node("View", element, cell, boxDark);
|
|
391
|
+
const children2 = this.blocks(element.children, passed, flex);
|
|
392
|
+
if (children2.length > 0) node2.children = children2;
|
|
393
|
+
return node2;
|
|
394
|
+
}
|
|
395
|
+
const row = tag === "tr";
|
|
396
|
+
const node = this.node("View", element, row ? { ...box, flexDirection: "row" } : box, boxDark);
|
|
397
|
+
const children = [];
|
|
398
|
+
for (const child of element.children) {
|
|
399
|
+
if (typeof child === "string") {
|
|
400
|
+
if (child.trim()) this.problem(`text directly inside <${tag}>`);
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
if (child.tag === "colgroup" || child.tag === "col") {
|
|
404
|
+
for (const column of [child, ...child.children]) {
|
|
405
|
+
if (typeof column === "string") continue;
|
|
406
|
+
const { width, style, class: className } = column.attributes;
|
|
407
|
+
if (width || style || className) this.problem(`<${column.tag}> sets column styles`);
|
|
408
|
+
}
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const allowed = row ? TABLE_CELL_TAGS.has(child.tag) : child.tag === "tr" || tag === "table" && (TABLE_GROUP_TAGS.has(child.tag) || child.tag === "caption");
|
|
412
|
+
if (!allowed && !SKIPPED_TAGS.has(child.tag)) {
|
|
413
|
+
this.problem(`<${child.tag}> inside <${tag}>`);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
const part = this.element(child, passed);
|
|
417
|
+
if (part) children.push(part);
|
|
418
|
+
}
|
|
419
|
+
if (children.length > 0) node.children = children;
|
|
420
|
+
return node;
|
|
421
|
+
}
|
|
372
422
|
element(element, inherited, flexItem = false) {
|
|
373
423
|
if (SKIPPED_TAGS.has(element.tag)) return void 0;
|
|
374
424
|
if (element.attributes.form !== void 0 && CONTROL_TAGS.has(element.tag)) {
|
|
375
425
|
this.problem(`<${element.tag}> form="${element.attributes.form}"`);
|
|
376
426
|
}
|
|
377
|
-
if (element.tag === "input" && _optionalChain([element, 'access',
|
|
427
|
+
if (element.tag === "input" && _optionalChain([element, 'access', _21 => _21.attributes, 'access', _22 => _22.type, 'optionalAccess', _23 => _23.toLowerCase, 'call', _24 => _24()]) === "hidden") {
|
|
378
428
|
const { name, value, disabled } = element.attributes;
|
|
379
429
|
if (this.form && name && disabled === void 0) {
|
|
380
430
|
this.form.fields.push({ name, value: _nullishCoalesce(value, () => ( "")) });
|
|
@@ -408,7 +458,7 @@ var Converter = class {
|
|
|
408
458
|
return node;
|
|
409
459
|
}
|
|
410
460
|
const textBox = flexItem && INLINE_TAGS.has(element.tag) && element.tag !== "a" && element.tag !== "br";
|
|
411
|
-
if (BLOCK_TEXT_TAGS.has(element.tag) || textBox) {
|
|
461
|
+
if (BLOCK_TEXT_TAGS.has(element.tag) || element.tag === "caption" || textBox) {
|
|
412
462
|
if (element.children.some((child) => typeof child !== "string" && !INLINE_TAGS.has(child.tag))) {
|
|
413
463
|
this.problem(`<${element.tag}> holds block elements`);
|
|
414
464
|
}
|
|
@@ -507,6 +557,9 @@ var Converter = class {
|
|
|
507
557
|
boxDark
|
|
508
558
|
);
|
|
509
559
|
}
|
|
560
|
+
if (TABLE_GROUP_TAGS.has(element.tag) || element.tag === "tr" || TABLE_CELL_TAGS.has(element.tag)) {
|
|
561
|
+
return this.tablePart(element, passed, box, boxDark, flex);
|
|
562
|
+
}
|
|
510
563
|
if (VIEW_TAGS.has(element.tag)) {
|
|
511
564
|
const node = this.node("View", element, box, boxDark);
|
|
512
565
|
const children = this.blocks(element.children, passed, flex);
|
|
@@ -578,14 +631,14 @@ var parsedSheets = /* @__PURE__ */ new Map();
|
|
|
578
631
|
function parsedStylesheet(css) {
|
|
579
632
|
let sheet = parsedSheets.get(css);
|
|
580
633
|
if (!sheet) {
|
|
581
|
-
sheet =
|
|
634
|
+
sheet = _chunkCCAUIBIScjs.parseFarmNativeStylesheet.call(void 0, css);
|
|
582
635
|
if (parsedSheets.size >= 16) parsedSheets.delete(parsedSheets.keys().next().value);
|
|
583
636
|
parsedSheets.set(css, sheet);
|
|
584
637
|
}
|
|
585
638
|
return sheet;
|
|
586
639
|
}
|
|
587
640
|
function createFarmNativeTree(html, pageUrl, stylesheets) {
|
|
588
|
-
const title = _optionalChain([/<title\b[^>]*>([\s\S]*?)<\/title>/i, 'access',
|
|
641
|
+
const title = _optionalChain([/<title\b[^>]*>([\s\S]*?)<\/title>/i, 'access', _25 => _25.exec, 'call', _26 => _26(html), 'optionalAccess', _27 => _27[1]]);
|
|
589
642
|
const document = parseHtml(_chunk2C5L5RPMcjs._readFarmRenderedHtml.call(void 0, html, { keepAriaHidden: true }));
|
|
590
643
|
const page = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(find(document, (element) => element.attributes.id === "__farm_page__"), () => ( find(document, (element) => element.attributes.id === "root"))), () => ( find(document, (element) => element.tag === "body"))), () => ( document));
|
|
591
644
|
const labels = /* @__PURE__ */ new Map();
|
|
@@ -597,7 +650,7 @@ function createFarmNativeTree(html, pageUrl, stylesheets) {
|
|
|
597
650
|
for (const child of element.children) if (typeof child !== "string") collectLabels(child);
|
|
598
651
|
};
|
|
599
652
|
collectLabels(page);
|
|
600
|
-
const converter = new Converter(pageUrl, _optionalChain([stylesheets, 'optionalAccess',
|
|
653
|
+
const converter = new Converter(pageUrl, _optionalChain([stylesheets, 'optionalAccess', _28 => _28.map, 'call', _29 => _29(parsedStylesheet)]), labels);
|
|
601
654
|
const ancestors = [];
|
|
602
655
|
for (let element = page.parent; element; element = element.parent) ancestors.unshift(element);
|
|
603
656
|
const inherited = { style: {}, dark: {} };
|
|
@@ -624,14 +677,14 @@ function createFarmNativeTree(html, pageUrl, stylesheets) {
|
|
|
624
677
|
if (children.length > 0) root.children = children;
|
|
625
678
|
return {
|
|
626
679
|
version: 1,
|
|
627
|
-
..._optionalChain([title, 'optionalAccess',
|
|
680
|
+
..._optionalChain([title, 'optionalAccess', _30 => _30.trim, 'call', _31 => _31()]) ? { title: decode(title.trim()) } : firstHeading(root) ? { title: firstHeading(root) } : {},
|
|
628
681
|
root,
|
|
629
682
|
unsupported: converter.unsupported
|
|
630
683
|
};
|
|
631
684
|
}
|
|
632
685
|
function readFarmPageStylesheets(html, pageUrl) {
|
|
633
686
|
const out = [];
|
|
634
|
-
const head = _nullishCoalesce(_optionalChain([/<head\b[^>]*>([\s\S]*?)<\/head>/i, 'access',
|
|
687
|
+
const head = _nullishCoalesce(_optionalChain([/<head\b[^>]*>([\s\S]*?)<\/head>/i, 'access', _32 => _32.exec, 'call', _33 => _33(html), 'optionalAccess', _34 => _34[1]]), () => ( html));
|
|
635
688
|
for (const match of head.matchAll(/<link\b([^>]*)>|<style\b[^>]*>([\s\S]*?)<\/style>/gi)) {
|
|
636
689
|
if (match[2] !== void 0) {
|
|
637
690
|
out.push({ inline: match[2] });
|
|
@@ -639,7 +692,7 @@ function readFarmPageStylesheets(html, pageUrl) {
|
|
|
639
692
|
}
|
|
640
693
|
const attributes = match[1];
|
|
641
694
|
if (!/\brel\s*=\s*["']?stylesheet\b/i.test(attributes)) continue;
|
|
642
|
-
const href = _optionalChain([/\bhref\s*=\s*["']([^"']+)["']/i, 'access',
|
|
695
|
+
const href = _optionalChain([/\bhref\s*=\s*["']([^"']+)["']/i, 'access', _35 => _35.exec, 'call', _36 => _36(attributes), 'optionalAccess', _37 => _37[1]]);
|
|
643
696
|
if (!href) continue;
|
|
644
697
|
const resolved = new URL(decode(href), pageUrl);
|
|
645
698
|
if (resolved.origin === pageUrl.origin) out.push({ href: resolved.pathname + resolved.search });
|
|
@@ -653,25 +706,27 @@ async function createFarmNativeTreeResponse(options) {
|
|
|
653
706
|
const headers = new Headers(options.request.headers);
|
|
654
707
|
headers.set("accept", "text/html");
|
|
655
708
|
headers.delete("accept-encoding");
|
|
709
|
+
headers.set("x-farm-native-tree", "1");
|
|
656
710
|
const submitted = options.request.method === "POST";
|
|
657
711
|
const init = submitted ? { method: "POST", headers, body: options.request.body, duplex: "half" } : { method: "GET", headers };
|
|
658
712
|
const page = await options.renderPage(
|
|
659
713
|
new Request(options.request.url, { ...init, signal: options.request.signal })
|
|
660
714
|
);
|
|
661
|
-
const cookies = _nullishCoalesce(_optionalChain([page, 'access',
|
|
715
|
+
const cookies = _nullishCoalesce(_optionalChain([page, 'access', _38 => _38.headers, 'access', _39 => _39.getSetCookie, 'optionalCall', _40 => _40()]), () => ( []));
|
|
662
716
|
const type = _nullishCoalesce(page.headers.get("content-type"), () => ( ""));
|
|
663
717
|
const drawn = page.status === 200 || submitted && page.status >= 400 && page.status < 500;
|
|
664
718
|
if (!drawn || !type.includes("text/html")) return page;
|
|
665
719
|
const html = await page.text();
|
|
666
|
-
const
|
|
720
|
+
const requestUrl = new URL(options.request.url);
|
|
721
|
+
const pageUrl = options.origin ? new URL(requestUrl.pathname + requestUrl.search, options.origin) : requestUrl;
|
|
667
722
|
const load = _nullishCoalesce(options.loadStylesheet, () => ( (async (href) => {
|
|
668
723
|
const response = await options.renderPage(
|
|
669
|
-
new Request(new URL(href,
|
|
724
|
+
new Request(new URL(href, requestUrl), {
|
|
670
725
|
headers: { accept: "text/css,*/*;q=0.1", cookie: _nullishCoalesce(headers.get("cookie"), () => ( "")) },
|
|
671
726
|
signal: options.request.signal
|
|
672
727
|
})
|
|
673
728
|
);
|
|
674
|
-
return response.status === 200 && _optionalChain([response, 'access',
|
|
729
|
+
return response.status === 200 && _optionalChain([response, 'access', _41 => _41.headers, 'access', _42 => _42.get, 'call', _43 => _43("content-type"), 'optionalAccess', _44 => _44.includes, 'call', _45 => _45("text/css")]) ? response.text() : void 0;
|
|
675
730
|
})));
|
|
676
731
|
const stylesheets = [];
|
|
677
732
|
for (const source of readFarmPageStylesheets(html, pageUrl)) {
|