@aglyn/plugins-ai 1.1.0 → 1.3.0
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/package.json +17 -17
- package/src/lib/components/ai-site-import-job.component.js +2 -2
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
- package/src/lib/jobs/ai-job-import-step.js +124 -12
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +6 -0
- package/src/lib/jobs/ai-jobs.js +43 -6
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
- package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +110 -23
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
- package/src/lib/jobs/ai-site-import-forms.js +376 -0
- package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-compiler.js +215 -30
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +25 -22
- package/src/lib/model/ai-credit-estimate.js +24 -22
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
- package/src/lib/model/ai-site-import-fidelity.js +41 -5
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +60 -0
- package/src/lib/model/ai-site-import-report.js +116 -0
- package/src/lib/model/ai-site-import-report.js.map +1 -0
- package/src/lib/model/ai-site-import-view.d.ts +7 -1
- package/src/lib/model/ai-site-import-view.js +14 -2
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +49 -2
- package/src/lib/model/ai-site-import.js +81 -23
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +10 -1
- package/src/lib/site-import/site-import-css.js +19 -12
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +17 -4
- package/src/lib/site-import/site-import-html.js +146 -17
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.js +194 -32
- package/src/lib/site-import/site-import-layout.js.map +1 -1
|
@@ -53,7 +53,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
53
53
|
* never the rule: the reader reads what an element draws, through the page's
|
|
54
54
|
* own stylesheets (`site-import-css.ts`). Nothing a page wrote runs.
|
|
55
55
|
*=========================================*/ import { AI_SITE_IMPORT_MAX_SECTIONS, siteImportFilterNodes, siteImportLayoutLines } from "../model/ai-site-import.js";
|
|
56
|
-
import { siteImportBackgroundOf, siteImportColorOf, siteImportCssOf, siteImportFontFamilies, siteImportFontSizePx, siteImportGridColumns, siteImportHasBorder, siteImportHasShadow, siteImportHex, siteImportLuminance, siteImportRadiusPx, siteImportSaturation, siteImportStylesOf, siteImportTwelfths } from "./site-import-css.js";
|
|
56
|
+
import { SITE_IMPORT_CSS_WIDE_WIDTH, siteImportBackgroundOf, siteImportColorOf, siteImportCssOf, siteImportFontFamilies, siteImportFontSizePx, siteImportGridColumns, siteImportHasBorder, siteImportHasShadow, siteImportHex, siteImportLengthPx, siteImportLuminance, siteImportRadiusPx, siteImportSaturation, siteImportStylesOf, siteImportTwelfths } from "./site-import-css.js";
|
|
57
57
|
import { extractSiteImportPage } from "./site-import-html.js";
|
|
58
58
|
import { siteImportLabel } from "./site-import-page.js";
|
|
59
59
|
const isElementPart = (part)=>'element' in part;
|
|
@@ -83,6 +83,40 @@ const BREAKPOINT_RANK = {
|
|
|
83
83
|
};
|
|
84
84
|
const PRICE = /(?:[$€£¥₹]\s?\d|\d+(?:[.,]\d+)?\s?(?:USD|EUR|GBP|CAD|AUD)\b)/;
|
|
85
85
|
const PERIOD = /\/\s?(?:mo|month|yr|year|user|seat|site)\b|\bper (?:month|year|user|seat)\b|\bmonthly\b|\bannual(?:ly)?\b|\bbilled\b|\ba month\b|\ba year\b/i;
|
|
86
|
+
/** A tag on an item: its longest words, and the corners a pill is drawn with. */ const BADGE_MAX_CHARS = 20;
|
|
87
|
+
const BADGE_MAX_WORDS = 2;
|
|
88
|
+
const BADGE_MIN_RADIUS = 12;
|
|
89
|
+
/** The longest line a price's period is: "/mo", "per seat". */ const PERIOD_MAX_CHARS = 12;
|
|
90
|
+
/** The columns a framework's own class caps itself at, where the page's sheets do not say. */ const WIDTH_CLASSES = [
|
|
91
|
+
[
|
|
92
|
+
/\bMuiContainer-maxWidthXl\b/,
|
|
93
|
+
1536
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
/\bMuiContainer-maxWidthLg\b/,
|
|
97
|
+
1200
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
/\bMuiContainer-maxWidthMd\b/,
|
|
101
|
+
900
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
/\bMuiContainer-maxWidthSm\b/,
|
|
105
|
+
600
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
/\balignfull\b/,
|
|
109
|
+
1536
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
/\balignwide\b/,
|
|
113
|
+
1200
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
/(?:^|\s)container(?:\s|$)/,
|
|
117
|
+
1320
|
|
118
|
+
]
|
|
119
|
+
];
|
|
86
120
|
const STEP_NUMBER = /^(?:step\s*)?(?:0?\d{1,2}|[ivx]{1,4})[.):]?$/i;
|
|
87
121
|
const FIGURE = /^[^\s]{0,3}[\d][\d.,:/x×+%kmb$€£-]*\s?[^\s]{0,12}$|^\d+-[a-z]+$/i;
|
|
88
122
|
/**
|
|
@@ -92,12 +126,13 @@ const FIGURE = /^[^\s]{0,3}[\d][\d.,:/x×+%kmb$€£-]*\s?[^\s]{0,12}$|^\d+-[a-z
|
|
|
92
126
|
*/ export function siteImportLayout(page, stylesheets = []) {
|
|
93
127
|
const { structure, blocks } = page;
|
|
94
128
|
if (!structure) return null;
|
|
95
|
-
const
|
|
129
|
+
const sheets = [
|
|
96
130
|
...structure.styles,
|
|
97
131
|
...stylesheets
|
|
98
|
-
]
|
|
132
|
+
];
|
|
133
|
+
const css = siteImportCssOf(sheets);
|
|
99
134
|
const styles = siteImportStylesOf(structure, css);
|
|
100
|
-
const reader = new LayoutReader(structure, blocks, styles);
|
|
135
|
+
const reader = new LayoutReader(structure, blocks, styles, ()=>siteImportStylesOf(structure, siteImportCssOf(sheets, SITE_IMPORT_CSS_WIDE_WIDTH)));
|
|
101
136
|
const sections = reader.sections();
|
|
102
137
|
if (!sections.length) return null;
|
|
103
138
|
return {
|
|
@@ -297,6 +332,7 @@ let LayoutReader = class LayoutReader {
|
|
|
297
332
|
});
|
|
298
333
|
}
|
|
299
334
|
section(cut, container, index) {
|
|
335
|
+
var _cut_anchor;
|
|
300
336
|
const { element, range, from } = cut;
|
|
301
337
|
const scope = element != null ? element : container;
|
|
302
338
|
const nodes = scope >= 0 ? this.read(scope, range) : this.readLeaves(range);
|
|
@@ -304,6 +340,7 @@ let LayoutReader = class LayoutReader {
|
|
|
304
340
|
if (!lines.length && !nodes.some((node)=>node.kind === 'icon' || node.kind === 'form')) return null;
|
|
305
341
|
const name = this.nameOf(cut.anchor, lines, index);
|
|
306
342
|
const band = cut.anchor !== null ? this.bandOf(cut.anchor, false) : this.bandOf(container, true);
|
|
343
|
+
const width = this.widthOf((_cut_anchor = cut.anchor) != null ? _cut_anchor : container);
|
|
307
344
|
return _extends({
|
|
308
345
|
name,
|
|
309
346
|
from,
|
|
@@ -312,7 +349,10 @@ let LayoutReader = class LayoutReader {
|
|
|
312
349
|
}, band.backdrop ? {
|
|
313
350
|
backdrop: band.backdrop
|
|
314
351
|
} : {}, {
|
|
315
|
-
align: this.alignOf(scope, lines)
|
|
352
|
+
align: this.alignOf(scope, lines)
|
|
353
|
+
}, width !== null ? {
|
|
354
|
+
width
|
|
355
|
+
} : {}, {
|
|
316
356
|
nodes,
|
|
317
357
|
lines
|
|
318
358
|
});
|
|
@@ -339,22 +379,24 @@ let LayoutReader = class LayoutReader {
|
|
|
339
379
|
(_this_mainBlocksMemo = this.mainBlocksMemo) != null ? _this_mainBlocksMemo : this.mainBlocksMemo = this.blocks.filter((block)=>block.region === 'main');
|
|
340
380
|
return this.mainBlocksMemo;
|
|
341
381
|
}
|
|
342
|
-
/*---------------- bands ----------------*/
|
|
382
|
+
/*---------------- bands ----------------*/ /** An element and the wrappers inside it that hold all it holds, one in another. */ wrappersOf(element) {
|
|
383
|
+
const chain = [];
|
|
384
|
+
let at = element;
|
|
385
|
+
for(let depth = 0; depth < 4 && at >= 0; depth += 1){
|
|
386
|
+
var _ref;
|
|
387
|
+
var _this_elements_at;
|
|
388
|
+
chain.push(at);
|
|
389
|
+
const children = ((_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.children) != null ? _ref : []).filter((child)=>this.leaves(child).length);
|
|
390
|
+
if (children.length !== 1) break;
|
|
391
|
+
at = children[0];
|
|
392
|
+
}
|
|
393
|
+
return chain;
|
|
394
|
+
}
|
|
395
|
+
bandOf(element, inherited) {
|
|
343
396
|
var _ref, _ref1, _this_backgroundBand;
|
|
344
397
|
var _this_elements_element, _this_elements_at;
|
|
345
398
|
// The section's own background, else the one wrapper inside it that covers it.
|
|
346
|
-
const chain = [];
|
|
347
|
-
if (!inherited) {
|
|
348
|
-
let at = element;
|
|
349
|
-
for(let depth = 0; depth < 4 && at >= 0; depth += 1){
|
|
350
|
-
var _ref2;
|
|
351
|
-
var _this_elements_at1;
|
|
352
|
-
chain.push(at);
|
|
353
|
-
const children = ((_ref2 = (_this_elements_at1 = this.elements[at]) == null ? void 0 : _this_elements_at1.children) != null ? _ref2 : []).filter((child)=>this.leaves(child).length);
|
|
354
|
-
if (children.length !== 1) break;
|
|
355
|
-
at = children[0];
|
|
356
|
-
}
|
|
357
|
-
}
|
|
399
|
+
const chain = inherited ? [] : this.wrappersOf(element);
|
|
358
400
|
for (const at of chain){
|
|
359
401
|
const found = this.backgroundBand(at);
|
|
360
402
|
if (found) return found;
|
|
@@ -420,6 +462,37 @@ let LayoutReader = class LayoutReader {
|
|
|
420
462
|
}
|
|
421
463
|
return null;
|
|
422
464
|
}
|
|
465
|
+
/*---------------- widths ----------------*/ /** The cap one element sets, in px: its own rule on a wide screen, else what its framework's class says. */ capOf(element) {
|
|
466
|
+
var _this_wideStyles, _ref, _ref1;
|
|
467
|
+
var _this_elements_element, _WIDTH_CLASSES_find;
|
|
468
|
+
(_this_wideStyles = this.wideStyles) != null ? _this_wideStyles : this.wideStyles = this.wideStylesOf();
|
|
469
|
+
const style = this.wideStyles.of(element);
|
|
470
|
+
for (const property of [
|
|
471
|
+
'max-width',
|
|
472
|
+
'width'
|
|
473
|
+
]){
|
|
474
|
+
const value = style.get(property);
|
|
475
|
+
const px = value ? siteImportLengthPx(value) : null;
|
|
476
|
+
if (px !== null && px > 0) return px;
|
|
477
|
+
}
|
|
478
|
+
const classes = (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.attrs.class) != null ? _ref : '';
|
|
479
|
+
return (_ref1 = (_WIDTH_CLASSES_find = WIDTH_CLASSES.find(([pattern])=>pattern.test(classes))) == null ? void 0 : _WIDTH_CLASSES_find[1]) != null ? _ref1 : null;
|
|
480
|
+
}
|
|
481
|
+
/** The narrowest cap a section's content sits under: on it, around it, or on the wrappers inside it. */ widthOf(element) {
|
|
482
|
+
var _ref, _ref1;
|
|
483
|
+
var _this_elements_element, _this_elements_at;
|
|
484
|
+
if (element < 0) return null;
|
|
485
|
+
const around = [];
|
|
486
|
+
for(let at = (_ref = (_this_elements_element = this.elements[element]) == null ? void 0 : _this_elements_element.parent) != null ? _ref : -1; at >= 0; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1)around.push(at);
|
|
487
|
+
const caps = [
|
|
488
|
+
...around,
|
|
489
|
+
...this.wrappersOf(element)
|
|
490
|
+
].flatMap((at)=>{
|
|
491
|
+
var _this_capOf;
|
|
492
|
+
return (_this_capOf = this.capOf(at)) != null ? _this_capOf : [];
|
|
493
|
+
});
|
|
494
|
+
return caps.length ? Math.min(...caps) : null;
|
|
495
|
+
}
|
|
423
496
|
alignOf(scope, lines) {
|
|
424
497
|
const mainBlocks = this.mainBlocks();
|
|
425
498
|
const heading = lines.find((ref)=>{
|
|
@@ -611,7 +684,7 @@ let LayoutReader = class LayoutReader {
|
|
|
611
684
|
});
|
|
612
685
|
if (cells.length >= 2 && groups.every((group)=>{
|
|
613
686
|
var _groups_;
|
|
614
|
-
return group && group.group === ((_groups_ = groups[0]) == null ? void 0 : _groups_.group) && group.columns === 1;
|
|
687
|
+
return group && !group.inline && group.group === ((_groups_ = groups[0]) == null ? void 0 : _groups_.group) && group.columns === 1;
|
|
615
688
|
})) {
|
|
616
689
|
const first = groups[0];
|
|
617
690
|
return {
|
|
@@ -833,14 +906,84 @@ let LayoutReader = class LayoutReader {
|
|
|
833
906
|
if (item.text && !item.text.length) delete item.text;
|
|
834
907
|
if (item.list && !item.list.length) delete item.list;
|
|
835
908
|
}
|
|
909
|
+
items.forEach((item, at)=>{
|
|
910
|
+
var _parts_at;
|
|
911
|
+
return this.takePeriod(item, (_parts_at = parts[at]) == null ? void 0 : _parts_at.element, range);
|
|
912
|
+
});
|
|
836
913
|
}
|
|
837
|
-
|
|
914
|
+
if (kind === 'cards' || kind === 'pricing') items.forEach((item, at)=>{
|
|
915
|
+
var _parts_at;
|
|
916
|
+
return this.takeBadge(item, (_parts_at = parts[at]) == null ? void 0 : _parts_at.element, range);
|
|
917
|
+
});
|
|
918
|
+
const inline = columns === 1 && (kind === 'cards' || kind === 'pricing') && parts.every((part)=>this.isWordRow(part.element, range));
|
|
919
|
+
return _extends({
|
|
838
920
|
kind: 'group',
|
|
839
921
|
group: kind,
|
|
840
922
|
columns,
|
|
841
|
-
boxed
|
|
923
|
+
boxed
|
|
924
|
+
}, inline ? {
|
|
925
|
+
inline: true
|
|
926
|
+
} : {}, {
|
|
842
927
|
items
|
|
843
|
-
};
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
/** The line of an item that says what its price is for, beside the price: taken out of its words. */ takePeriod(item, element, range) {
|
|
931
|
+
var _item_text;
|
|
932
|
+
if (item.figure === undefined) return;
|
|
933
|
+
const leaves = this.leaves(element).filter((leaf)=>leaf.kind === 'line' && this.inRange(leaf, range));
|
|
934
|
+
const price = leaves.find((leaf)=>leaf.ref === item.figure);
|
|
935
|
+
const next = item.lines[item.lines.indexOf(item.figure) + 1];
|
|
936
|
+
const period = ((_item_text = item.text) != null ? _item_text : []).find((ref)=>{
|
|
937
|
+
var _this_elements_leaf_element, _this_elements_price_element;
|
|
938
|
+
const text = this.lineText(ref).trim();
|
|
939
|
+
if (text.length > PERIOD_MAX_CHARS || !PERIOD.test(text)) return false;
|
|
940
|
+
const leaf = leaves.find((entry)=>entry.ref === ref);
|
|
941
|
+
return ref === next || !!leaf && !!price && ((_this_elements_leaf_element = this.elements[leaf.element]) == null ? void 0 : _this_elements_leaf_element.parent) === ((_this_elements_price_element = this.elements[price.element]) == null ? void 0 : _this_elements_price_element.parent);
|
|
942
|
+
});
|
|
943
|
+
if (period === undefined) return;
|
|
944
|
+
item.period = period;
|
|
945
|
+
dropLine(item, 'text', period);
|
|
946
|
+
}
|
|
947
|
+
/** The line of an item drawn as a tag on it, a short line in a filled pill: taken out of its words. */ takeBadge(item, element, range) {
|
|
948
|
+
var _item_text;
|
|
949
|
+
const leaves = this.leaves(element).filter((leaf)=>leaf.kind === 'line' && this.inRange(leaf, range));
|
|
950
|
+
const badge = ((_item_text = item.text) != null ? _item_text : []).find((ref)=>{
|
|
951
|
+
const leaf = leaves.find((entry)=>entry.ref === ref);
|
|
952
|
+
return !!leaf && this.isBadge(leaf);
|
|
953
|
+
});
|
|
954
|
+
if (badge === undefined) return;
|
|
955
|
+
item.badge = badge;
|
|
956
|
+
dropLine(item, 'text', badge);
|
|
957
|
+
}
|
|
958
|
+
/** Whether a line is a tag: a word or two on a fill of its own, its corners rounded to a pill. */ isBadge(leaf) {
|
|
959
|
+
var _ref;
|
|
960
|
+
var _this_elements_at;
|
|
961
|
+
const block = this.block(leaf);
|
|
962
|
+
if ((block == null ? void 0 : block.kind) !== 'paragraph') return false;
|
|
963
|
+
const words = block.text.trim().split(/\s+/);
|
|
964
|
+
if (block.text.trim().length > BADGE_MAX_CHARS || words.length > BADGE_MAX_WORDS) return false;
|
|
965
|
+
// The pill may be the line's own element, or the wrapper that holds only it.
|
|
966
|
+
for(let at = leaf.element, depth = 0; at >= 0 && depth < 2; at = (_ref = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref : -1, depth += 1){
|
|
967
|
+
var _siteImportRadiusPx;
|
|
968
|
+
if (this.leaves(at).length !== 1) return false;
|
|
969
|
+
const style = this.style(at);
|
|
970
|
+
const fill = siteImportBackgroundOf(style).color;
|
|
971
|
+
if (fill && fill.a >= 0.5 && siteImportHex(fill) !== this.backgroundUnder(at) && ((_siteImportRadiusPx = siteImportRadiusPx(style)) != null ? _siteImportRadiusPx : 0) >= BADGE_MIN_RADIUS) return true;
|
|
972
|
+
}
|
|
973
|
+
return false;
|
|
974
|
+
}
|
|
975
|
+
/** Whether an item is a row of its own, its parts side by side and two of them words: a plan's row, a label and its value. */ isWordRow(element, range) {
|
|
976
|
+
const row = this.unwrap(element, range);
|
|
977
|
+
if (!this.isRow(row)) return false;
|
|
978
|
+
const cells = this.parts(row, range).filter((part)=>{
|
|
979
|
+
var _this_block;
|
|
980
|
+
if (!isElementPart(part)) return part.leaf.kind === 'line' && ((_this_block = this.block(part.leaf)) == null ? void 0 : _this_block.kind) !== 'image';
|
|
981
|
+
return this.leaves(part.element).some((leaf)=>{
|
|
982
|
+
var _this_block;
|
|
983
|
+
return leaf.kind === 'line' && this.inRange(leaf, range) && ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) !== 'image';
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
return cells.length >= 2;
|
|
844
987
|
}
|
|
845
988
|
lineText(ref) {
|
|
846
989
|
const block = this.mainBlocks()[ref];
|
|
@@ -882,15 +1025,22 @@ let LayoutReader = class LayoutReader {
|
|
|
882
1025
|
});
|
|
883
1026
|
if (image) item.image = image.ref;
|
|
884
1027
|
const words = rest.filter((leaf)=>leaf !== image);
|
|
885
|
-
// Its own
|
|
1028
|
+
// Its own calls to action: every link it draws as a button, wherever it
|
|
1029
|
+
// sits (a plan's button sits above its features), and the links and
|
|
1030
|
+
// buttons that close it.
|
|
1031
|
+
let drawn = words.filter((leaf)=>{
|
|
1032
|
+
var _this_block;
|
|
1033
|
+
return ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'link' && !!this.buttonStyle(leaf);
|
|
1034
|
+
});
|
|
1035
|
+
const loose = words.filter((leaf)=>!drawn.includes(leaf));
|
|
886
1036
|
const trailing = [];
|
|
887
|
-
for(let index =
|
|
888
|
-
const leaf =
|
|
1037
|
+
for(let index = loose.length - 1; index >= 0; index -= 1){
|
|
1038
|
+
const leaf = loose[index];
|
|
889
1039
|
const block = this.block(leaf);
|
|
890
1040
|
if ((block == null ? void 0 : block.kind) === 'link' || this.buttonStyle(leaf)) trailing.unshift(leaf);
|
|
891
1041
|
else break;
|
|
892
1042
|
}
|
|
893
|
-
const body =
|
|
1043
|
+
const body = loose.slice(0, loose.length - trailing.length);
|
|
894
1044
|
let title = body.find((leaf)=>{
|
|
895
1045
|
var _this_block;
|
|
896
1046
|
return ((_this_block = this.block(leaf)) == null ? void 0 : _this_block.kind) === 'heading';
|
|
@@ -901,19 +1051,29 @@ let LayoutReader = class LayoutReader {
|
|
|
901
1051
|
if (first && (block == null ? void 0 : block.kind) === 'link' && body.length >= 2) title = first;
|
|
902
1052
|
else if (first && block && block.kind !== 'image' && block.text.length <= 80 && block.text.split(/\s+/).length <= 12 && body.length >= 2) title = first;
|
|
903
1053
|
}
|
|
904
|
-
|
|
1054
|
+
let closing = [
|
|
1055
|
+
...drawn,
|
|
1056
|
+
...trailing
|
|
1057
|
+
].sort((a, b)=>a.order - b.order);
|
|
1058
|
+
if (!title && closing.length === words.length && closing.length >= 1 && words.length >= 2) {
|
|
905
1059
|
// Only links: the first names the item.
|
|
906
|
-
title =
|
|
1060
|
+
title = closing[0];
|
|
1061
|
+
closing = closing.slice(1);
|
|
1062
|
+
drawn = drawn.filter((leaf)=>leaf !== title);
|
|
907
1063
|
}
|
|
908
1064
|
if (title) item.title = title.ref;
|
|
909
1065
|
const text = body.filter((leaf)=>leaf !== title).map((leaf)=>leaf.ref);
|
|
910
1066
|
if (text.length) item.text = text;
|
|
911
1067
|
if (listed.size) item.list = lines.filter((leaf)=>listed.has(leaf.ref)).map((leaf)=>leaf.ref);
|
|
912
|
-
if (
|
|
1068
|
+
if (closing.length) item.link = closing.map((leaf)=>leaf.ref);
|
|
1069
|
+
if (drawn.length) item.ctas = drawn.map((leaf)=>({
|
|
1070
|
+
line: leaf.ref,
|
|
1071
|
+
style: this.buttonStyle(leaf)
|
|
1072
|
+
}));
|
|
913
1073
|
const titleBlock = title ? this.block(title) : undefined;
|
|
914
1074
|
if ((titleBlock == null ? void 0 : titleBlock.kind) === 'link') item.to = titleBlock.href;
|
|
915
|
-
else if (
|
|
916
|
-
const only = this.block(
|
|
1075
|
+
else if (closing.length === 1) {
|
|
1076
|
+
const only = this.block(closing[0]);
|
|
917
1077
|
if ((only == null ? void 0 : only.kind) === 'link') item.to = only.href;
|
|
918
1078
|
} else {
|
|
919
1079
|
const wrap = this.wrapperOf(element, [
|
|
@@ -1283,14 +1443,16 @@ let LayoutReader = class LayoutReader {
|
|
|
1283
1443
|
linesOf(nodes) {
|
|
1284
1444
|
return siteImportLayoutLines(nodes);
|
|
1285
1445
|
}
|
|
1286
|
-
constructor(structure, blocks, styles){
|
|
1446
|
+
constructor(structure, blocks, styles, wideStylesOf){
|
|
1287
1447
|
var _siteImportFontSizePx;
|
|
1288
1448
|
this.structure = structure;
|
|
1289
1449
|
this.blocks = blocks;
|
|
1290
1450
|
this.styles = styles;
|
|
1451
|
+
this.wideStylesOf = wideStylesOf;
|
|
1291
1452
|
/** Each element's leaves, its subtree's, in order (memoized). */ this.leafMemo = new Map();
|
|
1292
1453
|
/** Tab panels a tab strip has read already. */ this.usedPanels = new Set();
|
|
1293
1454
|
this.bodySize = 16;
|
|
1455
|
+
this.wideStyles = null;
|
|
1294
1456
|
this.mainBlocksMemo = null;
|
|
1295
1457
|
this.tabsMemo = null;
|
|
1296
1458
|
this.elements = structure.elements;
|