@aglyn/plugins-ai 1.6.0 → 1.8.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/README.md +2 -2
- package/package.json +17 -17
- package/src/lib/components/ai-insight-dialog.component.js +14 -0
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/insights/ai-figure-readers.d.ts +13 -0
- package/src/lib/insights/ai-figure-readers.js +158 -11
- package/src/lib/insights/ai-figure-readers.js.map +1 -1
- package/src/lib/insights/ai-figure-summaries.js +4 -2
- package/src/lib/insights/ai-figure-summaries.js.map +1 -1
- package/src/lib/insights/ai-insight-digest.d.ts +27 -17
- package/src/lib/insights/ai-insight-digest.js +96 -107
- package/src/lib/insights/ai-insight-digest.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
- package/src/lib/jobs/ai-job-import-step.js +170 -14
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-insight-budget.d.ts +19 -3
- package/src/lib/jobs/ai-job-insight-budget.js +18 -4
- package/src/lib/jobs/ai-job-insight-budget.js.map +1 -1
- package/src/lib/jobs/ai-job-insight-step.d.ts +2 -2
- package/src/lib/jobs/ai-job-insight-step.js +17 -7
- package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +2 -0
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.js +6 -2
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
- package/src/lib/jobs/ai-site-import-compile.js +336 -27
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
- package/src/lib/jobs/ai-site-import-document.js +36 -0
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
- package/src/lib/jobs/ai-site-import-look.js +89 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
- package/src/lib/layout-language/ai-layout-compiler.js +351 -54
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
- package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +30 -18
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +72 -3
- package/src/lib/layout-language/ai-layout-language.js +5 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-store.js +32 -6
- package/src/lib/layout-language/ai-layout-store.js.map +1 -1
- package/src/lib/model/ai-insight.d.ts +23 -3
- package/src/lib/model/ai-insight.js +17 -3
- package/src/lib/model/ai-insight.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
- package/src/lib/model/ai-site-import-fidelity.js +347 -25
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +203 -6
- package/src/lib/model/ai-site-import.js +161 -5
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +8 -1
- package/src/lib/model/ai-site-look.js +8 -5
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/providers/routing.js +3 -1
- package/src/lib/providers/routing.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
- package/src/lib/runtime/ai-doctrine-validators.js +25 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-insight-check.d.ts +7 -0
- package/src/lib/runtime/ai-insight-check.js +111 -27
- package/src/lib/runtime/ai-insight-check.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +19 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-page-links.d.ts +15 -0
- package/src/lib/runtime/ai-page-links.js +48 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +30 -5
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +3 -1
- package/src/lib/site-import/site-import-crawl.js +8 -3
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +20 -0
- package/src/lib/site-import/site-import-css.js +106 -0
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +39 -0
- package/src/lib/site-import/site-import-html.js +515 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +16 -6
- package/src/lib/site-import/site-import-layout.js +524 -52
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +286 -24
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +3 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/tools/ai-insight-tool.js +45 -2
- package/src/lib/tools/ai-insight-tool.js.map +1 -1
|
@@ -35,6 +35,9 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
35
35
|
* the palette's own elements and the theme's tokens: the Card, the
|
|
36
36
|
* Accordion, the Table, the Tabs, the hero around the source's picture.
|
|
37
37
|
* Every word is the source's, as written.
|
|
38
|
+
* A video is the Video element where the source's film sat (AGL-4140),
|
|
39
|
+
* poster first, playing from where the old page played it, and a button
|
|
40
|
+
* whose words say it plays the film scrolls to it and presses play.
|
|
38
41
|
* 3. A main page's DESIGN is the one question a model answers
|
|
39
42
|
* (`submit_design`, `aiSiteImportDesignText`): which hero the opening
|
|
40
43
|
* becomes, how each group is drawn, a band where the source gave none,
|
|
@@ -46,7 +49,8 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
46
49
|
* here, from its lines, one section at each second-level heading.
|
|
47
50
|
*=========================================*/ import { aiCompileLayoutPage } from "../layout-language/ai-layout-compiler.js";
|
|
48
51
|
import { AI_LAYOUT_GROUP_STYLES, AI_LAYOUT_MAX_COLS } from "../layout-language/ai-layout-language.js";
|
|
49
|
-
import { AI_SITE_IMPORT_LABEL_MAX_CHARS, siteImportWidthOf } from "../model/ai-site-import.js";
|
|
52
|
+
import { AI_SITE_IMPORT_LABEL_MAX_CHARS, SITE_IMPORT_PLAY_WORDS, siteImportFilmSource, siteImportWidthOf } from "../model/ai-site-import.js";
|
|
53
|
+
import { aiHexOklch } from "../model/ai-site-look.js";
|
|
50
54
|
import { aiModelAtLeastStepTier } from "../providers/routing.js";
|
|
51
55
|
import { AI_SITE_IMPORT_DOC_MAX_NODES, AI_SITE_IMPORT_LABEL_CHARS, aiSiteImportDocLines, aiSiteImportTextParts, aiSiteImportWordsIn } from "./ai-site-import-document.js";
|
|
52
56
|
const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim() : '';
|
|
@@ -390,7 +394,35 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
390
394
|
scope.used.add(ref);
|
|
391
395
|
return block.kind === 'image' ? '' : clean(block.text);
|
|
392
396
|
}
|
|
393
|
-
/** A
|
|
397
|
+
/** A width over a height as `aspect-ratio` writes it: "1600 / 900", or "1.7778" for a ratio alone. */ function ratioText(width, height = 1) {
|
|
398
|
+
const round = (value)=>String(Math.round(value * 10000) / 10000);
|
|
399
|
+
return height === 1 ? round(width) : `${round(width)} / ${round(height)}`;
|
|
400
|
+
}
|
|
401
|
+
/** The radius past which a source's picture reads as rounded (AGL-4138), not merely softened: 10 px. */ const ROUNDED_PX = 10;
|
|
402
|
+
/**
|
|
403
|
+
* How a picture of a page brought in is framed (AGL-4138): at the box the
|
|
404
|
+
* source crops it to, where it sets one, else at the picture's own shape —
|
|
405
|
+
* the library's copy's size first, its `width` and `height` second — so a
|
|
406
|
+
* frame of its own shape, filled, cuts nothing off; its fit, and the
|
|
407
|
+
* source's rounded corners and shadow. A round portrait is the byline's.
|
|
408
|
+
*/ function pictureFitOf(photo, fit) {
|
|
409
|
+
const out = {};
|
|
410
|
+
if (fit == null ? void 0 : fit.box) Object.assign(out, {
|
|
411
|
+
ratio: ratioText(fit.box),
|
|
412
|
+
cropped: true
|
|
413
|
+
});
|
|
414
|
+
else if (fit == null ? void 0 : fit.height) Object.assign(out, {
|
|
415
|
+
height: Math.round(fit.height),
|
|
416
|
+
cropped: true
|
|
417
|
+
});
|
|
418
|
+
else if (photo.width && photo.height) out.ratio = ratioText(photo.width, photo.height);
|
|
419
|
+
else if (fit == null ? void 0 : fit.ratio) out.ratio = ratioText(fit.ratio);
|
|
420
|
+
if (fit == null ? void 0 : fit.objectFit) out.objectFit = fit.objectFit;
|
|
421
|
+
if ((fit == null ? void 0 : fit.radius) !== undefined && fit.radius >= ROUNDED_PX && fit.radius < 999) out.rounded = true;
|
|
422
|
+
if (fit == null ? void 0 : fit.shadow) out.shadow = true;
|
|
423
|
+
return Object.keys(out).length ? out : undefined;
|
|
424
|
+
}
|
|
425
|
+
/** A picture line as the library holds it; marks it taken, and missing where the library holds none. */ function takePicture(scope, ref, href, fit) {
|
|
394
426
|
if (ref === undefined || scope.used.has(ref)) return null;
|
|
395
427
|
const block = scope.doc.blocks[ref];
|
|
396
428
|
if (!block || block.kind !== 'image') return null;
|
|
@@ -403,6 +435,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
403
435
|
const alt = clean(block.alt || photo.alt || '').slice(0, 200);
|
|
404
436
|
const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
|
|
405
437
|
const to = linkTo(scope, href);
|
|
438
|
+
const framed = pictureFitOf(photo, fit);
|
|
406
439
|
return _extends({
|
|
407
440
|
src: photo.src,
|
|
408
441
|
alt
|
|
@@ -410,8 +443,71 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
410
443
|
ratio
|
|
411
444
|
} : {}, to ? {
|
|
412
445
|
to
|
|
446
|
+
} : {}, framed ? {
|
|
447
|
+
fit: framed
|
|
413
448
|
} : {});
|
|
414
449
|
}
|
|
450
|
+
/*------------------------------------------
|
|
451
|
+
* The source's colors as the theme's roles (AGL-4138)
|
|
452
|
+
*-----------------------------------------*/ /** How colorful a color must be to be a color, not a grey. */ const COLORFUL_CHROMA = 0.04;
|
|
453
|
+
/** How far apart two colors look, in OKLab. */ function colorGap(a, b) {
|
|
454
|
+
const [x, y] = [
|
|
455
|
+
aiHexOklch(a),
|
|
456
|
+
aiHexOklch(b)
|
|
457
|
+
];
|
|
458
|
+
const ax = x.C * Math.cos(x.h * Math.PI / 180);
|
|
459
|
+
const ay = x.C * Math.sin(x.h * Math.PI / 180);
|
|
460
|
+
const bx = y.C * Math.cos(y.h * Math.PI / 180);
|
|
461
|
+
const by = y.C * Math.sin(y.h * Math.PI / 180);
|
|
462
|
+
return Math.hypot(x.L - y.L, ax - bx, ay - by);
|
|
463
|
+
}
|
|
464
|
+
const HEX = /^#[0-9a-f]{6}$/i;
|
|
465
|
+
/** Whether a colorful color is the brand's: the source's buttons' fill or its links' color, by its look or its hue. */ function brandish(hex, look) {
|
|
466
|
+
const own = aiHexOklch(hex);
|
|
467
|
+
return [
|
|
468
|
+
look == null ? void 0 : look.buttonFill,
|
|
469
|
+
look == null ? void 0 : look.link
|
|
470
|
+
].some((other)=>{
|
|
471
|
+
if (!other || !HEX.test(other)) return false;
|
|
472
|
+
const them = aiHexOklch(other);
|
|
473
|
+
if (them.C < COLORFUL_CHROMA) return false;
|
|
474
|
+
const hue = Math.abs(own.h - them.h) % 360;
|
|
475
|
+
return colorGap(hex, other) <= 0.1 || Math.min(hue, 360 - hue) <= 25;
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* A source's own color as the theme role a page brought in draws it in
|
|
480
|
+
* (AGL-4138), so no value is ever written onto an element: the brand's
|
|
481
|
+
* colors as `primary`, any other color as the theme's third, which the look
|
|
482
|
+
* pins to the source's eyebrows' (`aiSiteImportStyle`); a grey as the words'
|
|
483
|
+
* ink or their muted shade, or as the divider for a rule; a light fill as the
|
|
484
|
+
* theme's tint. `null` where no role is the color's: white words on a dark
|
|
485
|
+
* band take the band's own.
|
|
486
|
+
*/ export function aiSiteImportColorRole(hex, look, use) {
|
|
487
|
+
if (!hex || !HEX.test(hex)) return null;
|
|
488
|
+
const own = aiHexOklch(hex);
|
|
489
|
+
if (use === 'fill' && own.L >= 0.9) return 'action.hover';
|
|
490
|
+
if (own.C < COLORFUL_CHROMA) {
|
|
491
|
+
if (use === 'rule') return 'divider';
|
|
492
|
+
if (use === 'fill' || own.L >= 0.9) return null;
|
|
493
|
+
return own.L <= 0.35 ? 'text.primary' : 'text.secondary';
|
|
494
|
+
}
|
|
495
|
+
return brandish(hex, look) ? 'primary.main' : 'tertiary.main';
|
|
496
|
+
}
|
|
497
|
+
/** An icon's color in a tile: the fill's own contrast where the icon is a light one on a strong fill. */ function tileInk(fill, color, look) {
|
|
498
|
+
const light = !!color && HEX.test(color) && aiHexOklch(color).L >= 0.9;
|
|
499
|
+
if (light && fill === 'primary.main') return 'primary.contrastText';
|
|
500
|
+
if (light && fill === 'tertiary.main') return 'tertiary.contrastText';
|
|
501
|
+
return aiSiteImportColorRole(color, look, 'ink');
|
|
502
|
+
}
|
|
503
|
+
/** A group's rule as the compiler draws it: its side, its width in the theme's border steps, its color's role. */ function ruleOf(rule, look) {
|
|
504
|
+
const width = rule.width >= 3 ? 3 : rule.width === 2 ? 2 : 1;
|
|
505
|
+
return {
|
|
506
|
+
side: rule.side,
|
|
507
|
+
width,
|
|
508
|
+
color: aiSiteImportColorRole(rule.color, look, 'rule')
|
|
509
|
+
};
|
|
510
|
+
}
|
|
415
511
|
/** Words as text blocks, a paragraph longer than a text element holds split between its sentences. */ function textBlocks(kind, text) {
|
|
416
512
|
return aiSiteImportTextParts(text).map((part)=>({
|
|
417
513
|
kind,
|
|
@@ -495,13 +591,38 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
495
591
|
}
|
|
496
592
|
];
|
|
497
593
|
default:
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
594
|
+
{
|
|
595
|
+
// A button whose words say it plays a film plays the section's film, else the page's (AGL-4140).
|
|
596
|
+
if (node.button && scope.film !== null && SITE_IMPORT_PLAY_WORDS.test(text) && text.length <= AI_SITE_IMPORT_LABEL_CHARS) {
|
|
597
|
+
return [
|
|
598
|
+
{
|
|
599
|
+
kind: 'button',
|
|
600
|
+
text,
|
|
601
|
+
style: node.button,
|
|
602
|
+
to: `video:${scope.film}`
|
|
603
|
+
}
|
|
604
|
+
];
|
|
502
605
|
}
|
|
503
|
-
|
|
504
|
-
|
|
606
|
+
if (node.role === 'eyebrow') {
|
|
607
|
+
// In its own pill and its own color, as the source sets it (AGL-4138).
|
|
608
|
+
const color = aiSiteImportColorRole(node.color, scope.layout.look, 'ink');
|
|
609
|
+
return [
|
|
610
|
+
_extends({
|
|
611
|
+
kind: 'eyebrow',
|
|
612
|
+
text
|
|
613
|
+
}, node.chip ? {
|
|
614
|
+
chip: true
|
|
615
|
+
} : {}, color ? {
|
|
616
|
+
color
|
|
617
|
+
} : {})
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
// A statement is a lede set large (AGL-4138), split as any text is between its sentences where it runs long.
|
|
621
|
+
if (node.role === 'statement') return textBlocks('lede', text).map((block)=>_extends({}, block, {
|
|
622
|
+
style: 'large'
|
|
623
|
+
}));
|
|
624
|
+
return textBlocks(node.role === 'lede' ? 'lede' : node.role === 'note' ? 'note' : 'text', text);
|
|
625
|
+
}
|
|
505
626
|
}
|
|
506
627
|
}
|
|
507
628
|
/** The icon a group item or a bullet carries, by its index into the page's icons. */ function iconAt(scope, index) {
|
|
@@ -567,7 +688,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
567
688
|
else if (ref === item.period) out.period = take(scope, ref);
|
|
568
689
|
else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
|
|
569
690
|
else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
|
|
570
|
-
const picture = takePicture(scope, ref);
|
|
691
|
+
const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
|
|
571
692
|
if (picture && !out.picture) out.picture = picture;
|
|
572
693
|
} else if ((_item_list1 = item.list) == null ? void 0 : _item_list1.includes(ref)) {
|
|
573
694
|
var _out_list1;
|
|
@@ -591,16 +712,44 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
591
712
|
if (icon) out.iconPath = icon;
|
|
592
713
|
const mark = iconAt(scope, item.listIcon);
|
|
593
714
|
if (mark && ((_out_list = out.list) == null ? void 0 : _out_list.length)) out.listIconPath = mark;
|
|
715
|
+
// Its icon's square and its arrow, as the source draws them (AGL-4138).
|
|
716
|
+
const fill = icon && item.tile ? aiSiteImportColorRole(item.tile.fill, scope.layout.look, 'fill') : null;
|
|
717
|
+
if (fill && item.tile) out.tile = {
|
|
718
|
+
fill,
|
|
719
|
+
color: tileInk(fill, item.tile.color, scope.layout.look)
|
|
720
|
+
};
|
|
721
|
+
const arrow = iconAt(scope, item.mark);
|
|
722
|
+
if (arrow) out.markPath = arrow;
|
|
723
|
+
if (item.figureMuted && out.figure) out.figureMuted = true;
|
|
724
|
+
// A film the item holds plays from its poster (AGL-4140), and the item is no link around it.
|
|
725
|
+
const film = item.video !== undefined ? scope.films.get(item.video) : undefined;
|
|
726
|
+
if (film && out.picture) {
|
|
727
|
+
out.picture = _extends({}, out.picture, {
|
|
728
|
+
video: film
|
|
729
|
+
});
|
|
730
|
+
return out;
|
|
731
|
+
}
|
|
594
732
|
const to = linkTo(scope, item.to);
|
|
595
733
|
if (to) out.to = to;
|
|
596
734
|
return out;
|
|
597
735
|
}
|
|
598
|
-
/** The style a group of cards is drawn in where its design answer chose none: the source's own box, icons or pictures. */ function defaultStyle(group, items) {
|
|
736
|
+
/** The style a group of cards is drawn in where its design answer chose none: the source's own box, its rule, icons or pictures. */ function defaultStyle(group, items) {
|
|
599
737
|
const pictured = items.length > 0 && items.every((item)=>item.picture);
|
|
600
738
|
if (pictured) return group.boxed ? 'articles' : 'pictures';
|
|
601
739
|
if (group.boxed) return 'cards';
|
|
740
|
+
// A rule along each item, a step's line over its number, is no box (AGL-4138).
|
|
741
|
+
if (group.rule) return 'ruled';
|
|
602
742
|
return items.length > 0 && items.every((item)=>item.iconPath) ? 'icons' : 'ruled';
|
|
603
743
|
}
|
|
744
|
+
/** What a group of a page brought in carries of how its source draws it (AGL-4138): its items' own alignment, its tablet columns, its rule when it is drawn ruled. */ function drawnAs(scope, group, style) {
|
|
745
|
+
return _extends({}, group.align ? {
|
|
746
|
+
itemsAlign: group.align
|
|
747
|
+
} : {}, group.columnsSm ? {
|
|
748
|
+
columnsSm: group.columnsSm
|
|
749
|
+
} : {}, style === 'ruled' && group.rule ? {
|
|
750
|
+
rule: ruleOf(group.rule, scope.layout.look)
|
|
751
|
+
} : {});
|
|
752
|
+
}
|
|
604
753
|
/** The style an answer chose, where the group can be drawn so: pictures need a picture on every item, icons an icon. */ function styleFor(asked, group, items) {
|
|
605
754
|
const fallback = defaultStyle(group, items);
|
|
606
755
|
if (!asked || !AI_LAYOUT_GROUP_STYLES.includes(asked)) return fallback;
|
|
@@ -721,12 +870,16 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
721
870
|
picture
|
|
722
871
|
}
|
|
723
872
|
];
|
|
873
|
+
// A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.
|
|
874
|
+
const to = picture ? undefined : linkTo(scope, item.to);
|
|
724
875
|
return words.length ? [
|
|
725
876
|
_extends({
|
|
726
877
|
title: words.join(' '),
|
|
727
878
|
text: ''
|
|
728
879
|
}, picture ? {
|
|
729
880
|
picture
|
|
881
|
+
} : {}, to ? {
|
|
882
|
+
to
|
|
730
883
|
} : {})
|
|
731
884
|
] : picture ? [
|
|
732
885
|
{
|
|
@@ -771,7 +924,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
771
924
|
variant: 'cards'
|
|
772
925
|
} : {
|
|
773
926
|
style: 'quiet'
|
|
774
|
-
})
|
|
927
|
+
}, drawnAs(scope, group))
|
|
775
928
|
];
|
|
776
929
|
}
|
|
777
930
|
if (kind === 'faq') return [
|
|
@@ -788,16 +941,16 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
788
941
|
columns
|
|
789
942
|
}, group.boxed ? {
|
|
790
943
|
variant: 'cards'
|
|
791
|
-
} : {})
|
|
944
|
+
} : {}, drawnAs(scope, group))
|
|
792
945
|
];
|
|
793
946
|
const style = joins ? 'ruled' : styleFor(answer == null ? void 0 : answer.style, group, items);
|
|
794
947
|
return [
|
|
795
|
-
{
|
|
948
|
+
_extends({
|
|
796
949
|
kind: kind === 'steps' ? 'steps' : 'cards',
|
|
797
950
|
items,
|
|
798
951
|
columns,
|
|
799
952
|
variant: style
|
|
800
|
-
}
|
|
953
|
+
}, drawnAs(scope, group, style))
|
|
801
954
|
];
|
|
802
955
|
}
|
|
803
956
|
/** A section's nodes in the layout language, a row of columns placed by `col` where the section may still take one. */ function nodeBlocks(scope, nodes, row) {
|
|
@@ -809,7 +962,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
809
962
|
break;
|
|
810
963
|
case 'picture':
|
|
811
964
|
{
|
|
812
|
-
const picture = takePicture(scope, node.line, node.button ? undefined : node.href);
|
|
965
|
+
const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
|
|
813
966
|
if (picture) out.push({
|
|
814
967
|
kind: 'image',
|
|
815
968
|
picture
|
|
@@ -818,6 +971,9 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
818
971
|
}
|
|
819
972
|
case 'icon':
|
|
820
973
|
break;
|
|
974
|
+
case 'video':
|
|
975
|
+
out.push(...videoBlocks(scope, node));
|
|
976
|
+
break;
|
|
821
977
|
case 'form':
|
|
822
978
|
{
|
|
823
979
|
var _scope_doc_forms;
|
|
@@ -920,6 +1076,93 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
920
1076
|
}
|
|
921
1077
|
return out;
|
|
922
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* A video of the source, where it sat (AGL-4140): the Video element, its
|
|
1081
|
+
* poster the library's copy of the source's, where the Video element can play
|
|
1082
|
+
* the film. One on a host it cannot play is its poster, linking to where the
|
|
1083
|
+
* film plays; with no poster either, nothing of it can be shown.
|
|
1084
|
+
*/ function videoBlocks(scope, node) {
|
|
1085
|
+
var _ref;
|
|
1086
|
+
var _scope_doc_videos;
|
|
1087
|
+
const film = scope.films.get(node.video);
|
|
1088
|
+
if (film) {
|
|
1089
|
+
// A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.
|
|
1090
|
+
const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null;
|
|
1091
|
+
if (!picture) {
|
|
1092
|
+
scope.settled.push({
|
|
1093
|
+
at: scope.at,
|
|
1094
|
+
what: 'a video left out: it has no poster picture'
|
|
1095
|
+
});
|
|
1096
|
+
return [];
|
|
1097
|
+
}
|
|
1098
|
+
const video = _extends({}, film, node.shadow ? {
|
|
1099
|
+
shadow: true
|
|
1100
|
+
} : {});
|
|
1101
|
+
return [
|
|
1102
|
+
{
|
|
1103
|
+
kind: 'video',
|
|
1104
|
+
video,
|
|
1105
|
+
picture
|
|
1106
|
+
}
|
|
1107
|
+
];
|
|
1108
|
+
}
|
|
1109
|
+
const source = (_scope_doc_videos = scope.doc.videos) == null ? void 0 : _scope_doc_videos[node.video];
|
|
1110
|
+
const where = (_ref = source == null ? void 0 : source.embed) != null ? _ref : source == null ? void 0 : source.src;
|
|
1111
|
+
const picture = takePicture(scope, node.poster, where, node.fit);
|
|
1112
|
+
const host = (()=>{
|
|
1113
|
+
try {
|
|
1114
|
+
return where ? new URL(where).hostname.replace(/^www\./, '') : '';
|
|
1115
|
+
} catch (unused) {
|
|
1116
|
+
return '';
|
|
1117
|
+
}
|
|
1118
|
+
})();
|
|
1119
|
+
if (picture && source) scope.settled.push({
|
|
1120
|
+
at: scope.at,
|
|
1121
|
+
what: `a video${host ? ` on ${host}` : ''} shown as its picture${picture.to ? ', linking to it' : ''}`
|
|
1122
|
+
});
|
|
1123
|
+
return picture ? [
|
|
1124
|
+
{
|
|
1125
|
+
kind: 'image',
|
|
1126
|
+
picture
|
|
1127
|
+
}
|
|
1128
|
+
] : [];
|
|
1129
|
+
}
|
|
1130
|
+
/** The page's films the Video element plays, by index (AGL-4140): each read's video that plays from a host it knows, or from the old site's https address. */ function filmsOf(doc) {
|
|
1131
|
+
var _doc_videos;
|
|
1132
|
+
const films = new Map();
|
|
1133
|
+
((_doc_videos = doc.videos) != null ? _doc_videos : []).forEach((video, index)=>{
|
|
1134
|
+
const source = siteImportFilmSource(video);
|
|
1135
|
+
if (!source) return;
|
|
1136
|
+
const title = clean(video.title).slice(0, 200);
|
|
1137
|
+
const description = clean(video.description).slice(0, 2000);
|
|
1138
|
+
films.set(index, _extends({
|
|
1139
|
+
index,
|
|
1140
|
+
src: source.src
|
|
1141
|
+
}, title ? {
|
|
1142
|
+
title
|
|
1143
|
+
} : {}, description ? {
|
|
1144
|
+
description
|
|
1145
|
+
} : {}, video.uploadDate ? {
|
|
1146
|
+
uploadDate: video.uploadDate
|
|
1147
|
+
} : {}, video.durationSeconds ? {
|
|
1148
|
+
durationSeconds: video.durationSeconds
|
|
1149
|
+
} : {}));
|
|
1150
|
+
});
|
|
1151
|
+
return films;
|
|
1152
|
+
}
|
|
1153
|
+
/** Whether a film is drawn as the Video element: one it plays, its poster a picture the library holds. */ function filmPlaces(scope, video, poster) {
|
|
1154
|
+
const block = poster === undefined ? undefined : scope.doc.blocks[poster];
|
|
1155
|
+
return scope.films.has(video) && (block == null ? void 0 : block.kind) === 'image' && scope.photos.has(block.url);
|
|
1156
|
+
}
|
|
1157
|
+
/** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */ function firstFilm(scope, nodes) {
|
|
1158
|
+
for (const node of nodes){
|
|
1159
|
+
var _ref;
|
|
1160
|
+
var _node_items_find;
|
|
1161
|
+
const found = node.kind === 'video' ? filmPlaces(scope, node.video, node.poster) ? node.video : null : node.kind === 'row' ? firstFilm(scope, node.cells.flatMap((cell)=>cell.nodes)) : node.kind === 'tabs' ? firstFilm(scope, node.tabs.flatMap((tab)=>tab.panel)) : node.kind === 'group' ? (_ref = (_node_items_find = node.items.find((item)=>item.video !== undefined && filmPlaces(scope, item.video, item.image))) == null ? void 0 : _node_items_find.video) != null ? _ref : null : null;
|
|
1162
|
+
if (found !== null) return found;
|
|
1163
|
+
}
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
923
1166
|
/** The most words beside a lone picture that make a row a byline: a name, a date, a role. */ const BYLINE_MAX_WORDS = 12;
|
|
924
1167
|
/**
|
|
925
1168
|
* A row that is a byline (AGL-4107): one cell a lone picture, the other a few
|
|
@@ -937,7 +1180,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
937
1180
|
}, 0);
|
|
938
1181
|
if (count === 0 || count > BYLINE_MAX_WORDS) return null;
|
|
939
1182
|
const node = cells[at].nodes[0];
|
|
940
|
-
const picture = takePicture(scope, node.line, node.button ? undefined : node.href);
|
|
1183
|
+
const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
|
|
941
1184
|
return [
|
|
942
1185
|
...picture ? [
|
|
943
1186
|
{
|
|
@@ -980,26 +1223,60 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
980
1223
|
'cover',
|
|
981
1224
|
'poster'
|
|
982
1225
|
]);
|
|
1226
|
+
/**
|
|
1227
|
+
* The heroes that keep the source's picture where it lays it (AGL-4138): under
|
|
1228
|
+
* or over its words in a column, beside them, or behind them. An answer may
|
|
1229
|
+
* choose among these alone.
|
|
1230
|
+
*/ const HEROES_AT = {
|
|
1231
|
+
below: new Set([
|
|
1232
|
+
'column',
|
|
1233
|
+
'editorial'
|
|
1234
|
+
]),
|
|
1235
|
+
above: new Set([
|
|
1236
|
+
'column',
|
|
1237
|
+
'editorial'
|
|
1238
|
+
]),
|
|
1239
|
+
beside: new Set([
|
|
1240
|
+
'split',
|
|
1241
|
+
'bleed',
|
|
1242
|
+
'panel'
|
|
1243
|
+
]),
|
|
1244
|
+
behind: new Set([
|
|
1245
|
+
'cover',
|
|
1246
|
+
'poster',
|
|
1247
|
+
'panel'
|
|
1248
|
+
])
|
|
1249
|
+
};
|
|
983
1250
|
/**
|
|
984
1251
|
* The hero a section's opening takes: the first section's, around its picture
|
|
985
1252
|
* beside, behind or under its words. Words dimmed over the picture draw the
|
|
986
1253
|
* section dark, so a section that keeps a lighter ground of its own, with its
|
|
987
1254
|
* picture anywhere but behind it, opens as its source does (AGL-4083): an
|
|
988
|
-
* answer never repaints a section's own band.
|
|
1255
|
+
* answer never repaints a section's own band. Nor does it move the picture
|
|
1256
|
+
* (AGL-4138): a picture under centered words stays under them, as a picture
|
|
1257
|
+
* beside the words stays beside them.
|
|
989
1258
|
*/ function heroOf(section, index, answer, settled) {
|
|
990
1259
|
var _ref;
|
|
991
1260
|
var _section_hero;
|
|
992
1261
|
if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
|
|
993
1262
|
// An answer of "none" keeps the opening as the source lays it out.
|
|
994
1263
|
if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
|
|
995
|
-
const
|
|
996
|
-
|
|
1264
|
+
const place = section.hero.picture;
|
|
1265
|
+
const own = HERO_FOR[place];
|
|
1266
|
+
if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && section.band !== 'dark' && place !== 'behind') {
|
|
997
1267
|
settled.push({
|
|
998
1268
|
at: 'sections[0]',
|
|
999
1269
|
what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
|
|
1000
1270
|
});
|
|
1001
1271
|
return own;
|
|
1002
1272
|
}
|
|
1273
|
+
if ((answer == null ? void 0 : answer.hero) && !HEROES_AT[place].has(answer.hero)) {
|
|
1274
|
+
settled.push({
|
|
1275
|
+
at: 'sections[0]',
|
|
1276
|
+
what: `the ${answer.hero} hero set aside: the source lays its picture ${place} its words`
|
|
1277
|
+
});
|
|
1278
|
+
return own;
|
|
1279
|
+
}
|
|
1003
1280
|
return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
|
|
1004
1281
|
}
|
|
1005
1282
|
/**
|
|
@@ -1031,19 +1308,43 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1031
1308
|
answer: null,
|
|
1032
1309
|
groupAt: 0,
|
|
1033
1310
|
settled: [],
|
|
1034
|
-
at: ''
|
|
1311
|
+
at: '',
|
|
1312
|
+
films: filmsOf(doc),
|
|
1313
|
+
film: null
|
|
1035
1314
|
};
|
|
1315
|
+
const backdropOf = (section)=>{
|
|
1316
|
+
var _section_backdrop;
|
|
1317
|
+
return ((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'video' ? section.backdrop : null;
|
|
1318
|
+
};
|
|
1319
|
+
const pageFilm = layout.sections.reduce((found, section)=>found != null ? found : firstFilm(scope, section.nodes), null);
|
|
1036
1320
|
const sections = layout.sections.map((section, index)=>{
|
|
1037
|
-
var _ref, _ref1, _siteImportWidthOf;
|
|
1321
|
+
var _ref, _firstFilm, _ref1, _siteImportWidthOf;
|
|
1038
1322
|
const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
|
|
1039
1323
|
scope.answer = given;
|
|
1040
1324
|
scope.groupAt = 0;
|
|
1041
1325
|
scope.at = `sections[${index}]`;
|
|
1326
|
+
const behind = backdropOf(section);
|
|
1327
|
+
scope.film = (_firstFilm = firstFilm(scope, section.nodes)) != null ? _firstFilm : pageFilm;
|
|
1042
1328
|
const row = {
|
|
1043
1329
|
cols: null,
|
|
1044
1330
|
allowed: true
|
|
1045
1331
|
};
|
|
1046
|
-
|
|
1332
|
+
// A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the
|
|
1333
|
+
// opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.
|
|
1334
|
+
const poster = behind ? takePicture(scope, behind.poster) : null;
|
|
1335
|
+
if (behind) scope.settled.push({
|
|
1336
|
+
at: scope.at,
|
|
1337
|
+
what: 'a film playing behind the words drawn as its poster'
|
|
1338
|
+
});
|
|
1339
|
+
const blocks = [
|
|
1340
|
+
...poster ? [
|
|
1341
|
+
{
|
|
1342
|
+
kind: 'image',
|
|
1343
|
+
picture: poster
|
|
1344
|
+
}
|
|
1345
|
+
] : [],
|
|
1346
|
+
...nodeBlocks(scope, section.nodes, row)
|
|
1347
|
+
];
|
|
1047
1348
|
// Every line the layout placed nowhere, at the section's end, as its kind says.
|
|
1048
1349
|
for (const ref of section.lines){
|
|
1049
1350
|
if (scope.used.has(ref)) continue;
|
|
@@ -1085,6 +1386,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1085
1386
|
* lays it out and drawn in the site's own theme.
|
|
1086
1387
|
*/ export function aiCompileImportedPage(input) {
|
|
1087
1388
|
var _input_answer;
|
|
1389
|
+
var _compiled_videoIds;
|
|
1088
1390
|
const { doc } = input;
|
|
1089
1391
|
const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
|
|
1090
1392
|
const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
|
|
@@ -1128,9 +1430,12 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1128
1430
|
const block = doc.blocks[ref];
|
|
1129
1431
|
return block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0;
|
|
1130
1432
|
};
|
|
1131
|
-
return {
|
|
1433
|
+
return _extends({
|
|
1132
1434
|
tree: compiled.tree,
|
|
1133
|
-
sectionRoots: compiled.sectionRoots
|
|
1435
|
+
sectionRoots: compiled.sectionRoots
|
|
1436
|
+
}, ((_compiled_videoIds = compiled.videoIds) == null ? void 0 : _compiled_videoIds.length) ? {
|
|
1437
|
+
videoIds: compiled.videoIds
|
|
1438
|
+
} : {}, {
|
|
1134
1439
|
sections,
|
|
1135
1440
|
placed,
|
|
1136
1441
|
lines: lineRefs.length,
|
|
@@ -1141,7 +1446,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1141
1446
|
...designed.settled,
|
|
1142
1447
|
...compiled.settled
|
|
1143
1448
|
]
|
|
1144
|
-
};
|
|
1449
|
+
});
|
|
1145
1450
|
}
|
|
1146
1451
|
/*------------------------------------------
|
|
1147
1452
|
* What the design answer is shown
|
|
@@ -1154,7 +1459,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1154
1459
|
if (block.kind === 'list-item') return 'list item';
|
|
1155
1460
|
if (block.kind === 'quote') return 'quote';
|
|
1156
1461
|
if (block.kind === 'image') return 'picture';
|
|
1157
|
-
|
|
1462
|
+
// A statement is read as the lede it was before the import drew it larger (AGL-4138): the answer's text is unchanged.
|
|
1463
|
+
return node.role === 'statement' ? 'lede' : (_node_role = node.role) != null ? _node_role : 'text';
|
|
1158
1464
|
}
|
|
1159
1465
|
/** What an item of a group shows, as one phrase: "icon + title + text + link". */ function itemShape(item) {
|
|
1160
1466
|
var _item_text, _item_list, _item_link;
|
|
@@ -1186,6 +1492,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1186
1492
|
parts.push(lineKind(doc.blocks[node.line], node));
|
|
1187
1493
|
break;
|
|
1188
1494
|
case 'picture':
|
|
1495
|
+
// A film reads as the picture it opens on (AGL-4140): the design answer is asked nothing new of it.
|
|
1496
|
+
case 'video':
|
|
1189
1497
|
parts.push('picture');
|
|
1190
1498
|
break;
|
|
1191
1499
|
case 'form':
|
|
@@ -1200,7 +1508,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1200
1508
|
const shape = [
|
|
1201
1509
|
...new Set(node.items.map((item)=>itemShape(item).join(' + ')).filter(Boolean))
|
|
1202
1510
|
].slice(0, 2).join(' or ');
|
|
1203
|
-
|
|
1511
|
+
// A group set apart by a rule reads "boxed", as it did before the rule was kept (AGL-4138): the answer's text is unchanged.
|
|
1512
|
+
parts.push(`group ${groups.count}: ${node.items.length} ${node.group} in ${node.columns} column${node.columns === 1 ? '' : 's'}${node.boxed || node.rule ? ', boxed' : ''}${shape ? `, each ${shape}` : ''}`);
|
|
1204
1513
|
break;
|
|
1205
1514
|
}
|
|
1206
1515
|
case 'table':
|