@aglyn/plugins-ai 1.7.0 → 1.9.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/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.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-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 +339 -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 +42 -1
- 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 +378 -56
- 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 +74 -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-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-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +205 -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/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.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-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.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +35 -6
- 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 +528 -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/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.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,38 @@ 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
|
+
// The width the source holds it to, as the theme's breakpoint nearest it; the widest is no hold at all.
|
|
424
|
+
const measure = siteImportWidthOf(fit == null ? void 0 : fit.measure);
|
|
425
|
+
if (measure && measure !== 'xl') out.measure = measure;
|
|
426
|
+
return Object.keys(out).length ? out : undefined;
|
|
427
|
+
}
|
|
428
|
+
/** 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
429
|
if (ref === undefined || scope.used.has(ref)) return null;
|
|
395
430
|
const block = scope.doc.blocks[ref];
|
|
396
431
|
if (!block || block.kind !== 'image') return null;
|
|
@@ -403,6 +438,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
403
438
|
const alt = clean(block.alt || photo.alt || '').slice(0, 200);
|
|
404
439
|
const ratio = photo.width && photo.height ? photo.width / photo.height : 0;
|
|
405
440
|
const to = linkTo(scope, href);
|
|
441
|
+
const framed = pictureFitOf(photo, fit);
|
|
406
442
|
return _extends({
|
|
407
443
|
src: photo.src,
|
|
408
444
|
alt
|
|
@@ -410,8 +446,71 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
410
446
|
ratio
|
|
411
447
|
} : {}, to ? {
|
|
412
448
|
to
|
|
449
|
+
} : {}, framed ? {
|
|
450
|
+
fit: framed
|
|
413
451
|
} : {});
|
|
414
452
|
}
|
|
453
|
+
/*------------------------------------------
|
|
454
|
+
* The source's colors as the theme's roles (AGL-4138)
|
|
455
|
+
*-----------------------------------------*/ /** How colorful a color must be to be a color, not a grey. */ const COLORFUL_CHROMA = 0.04;
|
|
456
|
+
/** How far apart two colors look, in OKLab. */ function colorGap(a, b) {
|
|
457
|
+
const [x, y] = [
|
|
458
|
+
aiHexOklch(a),
|
|
459
|
+
aiHexOklch(b)
|
|
460
|
+
];
|
|
461
|
+
const ax = x.C * Math.cos(x.h * Math.PI / 180);
|
|
462
|
+
const ay = x.C * Math.sin(x.h * Math.PI / 180);
|
|
463
|
+
const bx = y.C * Math.cos(y.h * Math.PI / 180);
|
|
464
|
+
const by = y.C * Math.sin(y.h * Math.PI / 180);
|
|
465
|
+
return Math.hypot(x.L - y.L, ax - bx, ay - by);
|
|
466
|
+
}
|
|
467
|
+
const HEX = /^#[0-9a-f]{6}$/i;
|
|
468
|
+
/** 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) {
|
|
469
|
+
const own = aiHexOklch(hex);
|
|
470
|
+
return [
|
|
471
|
+
look == null ? void 0 : look.buttonFill,
|
|
472
|
+
look == null ? void 0 : look.link
|
|
473
|
+
].some((other)=>{
|
|
474
|
+
if (!other || !HEX.test(other)) return false;
|
|
475
|
+
const them = aiHexOklch(other);
|
|
476
|
+
if (them.C < COLORFUL_CHROMA) return false;
|
|
477
|
+
const hue = Math.abs(own.h - them.h) % 360;
|
|
478
|
+
return colorGap(hex, other) <= 0.1 || Math.min(hue, 360 - hue) <= 25;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* A source's own color as the theme role a page brought in draws it in
|
|
483
|
+
* (AGL-4138), so no value is ever written onto an element: the brand's
|
|
484
|
+
* colors as `primary`, any other color as the theme's third, which the look
|
|
485
|
+
* pins to the source's eyebrows' (`aiSiteImportStyle`); a grey as the words'
|
|
486
|
+
* ink or their muted shade, or as the divider for a rule; a light fill as the
|
|
487
|
+
* theme's tint. `null` where no role is the color's: white words on a dark
|
|
488
|
+
* band take the band's own.
|
|
489
|
+
*/ export function aiSiteImportColorRole(hex, look, use) {
|
|
490
|
+
if (!hex || !HEX.test(hex)) return null;
|
|
491
|
+
const own = aiHexOklch(hex);
|
|
492
|
+
if (use === 'fill' && own.L >= 0.9) return 'action.hover';
|
|
493
|
+
if (own.C < COLORFUL_CHROMA) {
|
|
494
|
+
if (use === 'rule') return 'divider';
|
|
495
|
+
if (use === 'fill' || own.L >= 0.9) return null;
|
|
496
|
+
return own.L <= 0.35 ? 'text.primary' : 'text.secondary';
|
|
497
|
+
}
|
|
498
|
+
return brandish(hex, look) ? 'primary.main' : 'tertiary.main';
|
|
499
|
+
}
|
|
500
|
+
/** 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) {
|
|
501
|
+
const light = !!color && HEX.test(color) && aiHexOklch(color).L >= 0.9;
|
|
502
|
+
if (light && fill === 'primary.main') return 'primary.contrastText';
|
|
503
|
+
if (light && fill === 'tertiary.main') return 'tertiary.contrastText';
|
|
504
|
+
return aiSiteImportColorRole(color, look, 'ink');
|
|
505
|
+
}
|
|
506
|
+
/** 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) {
|
|
507
|
+
const width = rule.width >= 3 ? 3 : rule.width === 2 ? 2 : 1;
|
|
508
|
+
return {
|
|
509
|
+
side: rule.side,
|
|
510
|
+
width,
|
|
511
|
+
color: aiSiteImportColorRole(rule.color, look, 'rule')
|
|
512
|
+
};
|
|
513
|
+
}
|
|
415
514
|
/** Words as text blocks, a paragraph longer than a text element holds split between its sentences. */ function textBlocks(kind, text) {
|
|
416
515
|
return aiSiteImportTextParts(text).map((part)=>({
|
|
417
516
|
kind,
|
|
@@ -495,13 +594,38 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
495
594
|
}
|
|
496
595
|
];
|
|
497
596
|
default:
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
597
|
+
{
|
|
598
|
+
// A button whose words say it plays a film plays the section's film, else the page's (AGL-4140).
|
|
599
|
+
if (node.button && scope.film !== null && SITE_IMPORT_PLAY_WORDS.test(text) && text.length <= AI_SITE_IMPORT_LABEL_CHARS) {
|
|
600
|
+
return [
|
|
601
|
+
{
|
|
602
|
+
kind: 'button',
|
|
603
|
+
text,
|
|
604
|
+
style: node.button,
|
|
605
|
+
to: `video:${scope.film}`
|
|
606
|
+
}
|
|
607
|
+
];
|
|
502
608
|
}
|
|
503
|
-
|
|
504
|
-
|
|
609
|
+
if (node.role === 'eyebrow') {
|
|
610
|
+
// In its own pill and its own color, as the source sets it (AGL-4138).
|
|
611
|
+
const color = aiSiteImportColorRole(node.color, scope.layout.look, 'ink');
|
|
612
|
+
return [
|
|
613
|
+
_extends({
|
|
614
|
+
kind: 'eyebrow',
|
|
615
|
+
text
|
|
616
|
+
}, node.chip ? {
|
|
617
|
+
chip: true
|
|
618
|
+
} : {}, color ? {
|
|
619
|
+
color
|
|
620
|
+
} : {})
|
|
621
|
+
];
|
|
622
|
+
}
|
|
623
|
+
// A statement is a lede set large (AGL-4138), split as any text is between its sentences where it runs long.
|
|
624
|
+
if (node.role === 'statement') return textBlocks('lede', text).map((block)=>_extends({}, block, {
|
|
625
|
+
style: 'large'
|
|
626
|
+
}));
|
|
627
|
+
return textBlocks(node.role === 'lede' ? 'lede' : node.role === 'note' ? 'note' : 'text', text);
|
|
628
|
+
}
|
|
505
629
|
}
|
|
506
630
|
}
|
|
507
631
|
/** The icon a group item or a bullet carries, by its index into the page's icons. */ function iconAt(scope, index) {
|
|
@@ -567,7 +691,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
567
691
|
else if (ref === item.period) out.period = take(scope, ref);
|
|
568
692
|
else if (ref === item.badge && kind !== 'stats') out.badge = take(scope, ref);
|
|
569
693
|
else if (ref === item.image || block.kind === 'image' && !named.has(ref)) {
|
|
570
|
-
const picture = takePicture(scope, ref);
|
|
694
|
+
const picture = takePicture(scope, ref, undefined, ref === item.image ? item.imageFit : undefined);
|
|
571
695
|
if (picture && !out.picture) out.picture = picture;
|
|
572
696
|
} else if ((_item_list1 = item.list) == null ? void 0 : _item_list1.includes(ref)) {
|
|
573
697
|
var _out_list1;
|
|
@@ -591,16 +715,44 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
591
715
|
if (icon) out.iconPath = icon;
|
|
592
716
|
const mark = iconAt(scope, item.listIcon);
|
|
593
717
|
if (mark && ((_out_list = out.list) == null ? void 0 : _out_list.length)) out.listIconPath = mark;
|
|
718
|
+
// Its icon's square and its arrow, as the source draws them (AGL-4138).
|
|
719
|
+
const fill = icon && item.tile ? aiSiteImportColorRole(item.tile.fill, scope.layout.look, 'fill') : null;
|
|
720
|
+
if (fill && item.tile) out.tile = {
|
|
721
|
+
fill,
|
|
722
|
+
color: tileInk(fill, item.tile.color, scope.layout.look)
|
|
723
|
+
};
|
|
724
|
+
const arrow = iconAt(scope, item.mark);
|
|
725
|
+
if (arrow) out.markPath = arrow;
|
|
726
|
+
if (item.figureMuted && out.figure) out.figureMuted = true;
|
|
727
|
+
// A film the item holds plays from its poster (AGL-4140), and the item is no link around it.
|
|
728
|
+
const film = item.video !== undefined ? scope.films.get(item.video) : undefined;
|
|
729
|
+
if (film && out.picture) {
|
|
730
|
+
out.picture = _extends({}, out.picture, {
|
|
731
|
+
video: film
|
|
732
|
+
});
|
|
733
|
+
return out;
|
|
734
|
+
}
|
|
594
735
|
const to = linkTo(scope, item.to);
|
|
595
736
|
if (to) out.to = to;
|
|
596
737
|
return out;
|
|
597
738
|
}
|
|
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) {
|
|
739
|
+
/** 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
740
|
const pictured = items.length > 0 && items.every((item)=>item.picture);
|
|
600
741
|
if (pictured) return group.boxed ? 'articles' : 'pictures';
|
|
601
742
|
if (group.boxed) return 'cards';
|
|
743
|
+
// A rule along each item, a step's line over its number, is no box (AGL-4138).
|
|
744
|
+
if (group.rule) return 'ruled';
|
|
602
745
|
return items.length > 0 && items.every((item)=>item.iconPath) ? 'icons' : 'ruled';
|
|
603
746
|
}
|
|
747
|
+
/** 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) {
|
|
748
|
+
return _extends({}, group.align ? {
|
|
749
|
+
itemsAlign: group.align
|
|
750
|
+
} : {}, group.columnsSm ? {
|
|
751
|
+
columnsSm: group.columnsSm
|
|
752
|
+
} : {}, style === 'ruled' && group.rule ? {
|
|
753
|
+
rule: ruleOf(group.rule, scope.layout.look)
|
|
754
|
+
} : {});
|
|
755
|
+
}
|
|
604
756
|
/** 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
757
|
const fallback = defaultStyle(group, items);
|
|
606
758
|
if (!asked || !AI_LAYOUT_GROUP_STYLES.includes(asked)) return fallback;
|
|
@@ -721,12 +873,16 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
721
873
|
picture
|
|
722
874
|
}
|
|
723
875
|
];
|
|
876
|
+
// A strip of linked tags keeps its links (AGL-4138): a blog's categories go to their pages.
|
|
877
|
+
const to = picture ? undefined : linkTo(scope, item.to);
|
|
724
878
|
return words.length ? [
|
|
725
879
|
_extends({
|
|
726
880
|
title: words.join(' '),
|
|
727
881
|
text: ''
|
|
728
882
|
}, picture ? {
|
|
729
883
|
picture
|
|
884
|
+
} : {}, to ? {
|
|
885
|
+
to
|
|
730
886
|
} : {})
|
|
731
887
|
] : picture ? [
|
|
732
888
|
{
|
|
@@ -771,7 +927,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
771
927
|
variant: 'cards'
|
|
772
928
|
} : {
|
|
773
929
|
style: 'quiet'
|
|
774
|
-
})
|
|
930
|
+
}, drawnAs(scope, group))
|
|
775
931
|
];
|
|
776
932
|
}
|
|
777
933
|
if (kind === 'faq') return [
|
|
@@ -788,16 +944,16 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
788
944
|
columns
|
|
789
945
|
}, group.boxed ? {
|
|
790
946
|
variant: 'cards'
|
|
791
|
-
} : {})
|
|
947
|
+
} : {}, drawnAs(scope, group))
|
|
792
948
|
];
|
|
793
949
|
const style = joins ? 'ruled' : styleFor(answer == null ? void 0 : answer.style, group, items);
|
|
794
950
|
return [
|
|
795
|
-
{
|
|
951
|
+
_extends({
|
|
796
952
|
kind: kind === 'steps' ? 'steps' : 'cards',
|
|
797
953
|
items,
|
|
798
954
|
columns,
|
|
799
955
|
variant: style
|
|
800
|
-
}
|
|
956
|
+
}, drawnAs(scope, group, style))
|
|
801
957
|
];
|
|
802
958
|
}
|
|
803
959
|
/** 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 +965,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
809
965
|
break;
|
|
810
966
|
case 'picture':
|
|
811
967
|
{
|
|
812
|
-
const picture = takePicture(scope, node.line, node.button ? undefined : node.href);
|
|
968
|
+
const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
|
|
813
969
|
if (picture) out.push({
|
|
814
970
|
kind: 'image',
|
|
815
971
|
picture
|
|
@@ -818,6 +974,9 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
818
974
|
}
|
|
819
975
|
case 'icon':
|
|
820
976
|
break;
|
|
977
|
+
case 'video':
|
|
978
|
+
out.push(...videoBlocks(scope, node));
|
|
979
|
+
break;
|
|
821
980
|
case 'form':
|
|
822
981
|
{
|
|
823
982
|
var _scope_doc_forms;
|
|
@@ -920,6 +1079,93 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
920
1079
|
}
|
|
921
1080
|
return out;
|
|
922
1081
|
}
|
|
1082
|
+
/**
|
|
1083
|
+
* A video of the source, where it sat (AGL-4140): the Video element, its
|
|
1084
|
+
* poster the library's copy of the source's, where the Video element can play
|
|
1085
|
+
* the film. One on a host it cannot play is its poster, linking to where the
|
|
1086
|
+
* film plays; with no poster either, nothing of it can be shown.
|
|
1087
|
+
*/ function videoBlocks(scope, node) {
|
|
1088
|
+
var _ref;
|
|
1089
|
+
var _scope_doc_videos;
|
|
1090
|
+
const film = scope.films.get(node.video);
|
|
1091
|
+
if (film) {
|
|
1092
|
+
// A film is pressed to play from its poster: with none, the Video element has nothing to show, and it is left out.
|
|
1093
|
+
const picture = filmPlaces(scope, node.video, node.poster) ? takePicture(scope, node.poster, undefined, node.fit) : null;
|
|
1094
|
+
if (!picture) {
|
|
1095
|
+
scope.settled.push({
|
|
1096
|
+
at: scope.at,
|
|
1097
|
+
what: 'a video left out: it has no poster picture'
|
|
1098
|
+
});
|
|
1099
|
+
return [];
|
|
1100
|
+
}
|
|
1101
|
+
const video = _extends({}, film, node.shadow ? {
|
|
1102
|
+
shadow: true
|
|
1103
|
+
} : {});
|
|
1104
|
+
return [
|
|
1105
|
+
{
|
|
1106
|
+
kind: 'video',
|
|
1107
|
+
video,
|
|
1108
|
+
picture
|
|
1109
|
+
}
|
|
1110
|
+
];
|
|
1111
|
+
}
|
|
1112
|
+
const source = (_scope_doc_videos = scope.doc.videos) == null ? void 0 : _scope_doc_videos[node.video];
|
|
1113
|
+
const where = (_ref = source == null ? void 0 : source.embed) != null ? _ref : source == null ? void 0 : source.src;
|
|
1114
|
+
const picture = takePicture(scope, node.poster, where, node.fit);
|
|
1115
|
+
const host = (()=>{
|
|
1116
|
+
try {
|
|
1117
|
+
return where ? new URL(where).hostname.replace(/^www\./, '') : '';
|
|
1118
|
+
} catch (unused) {
|
|
1119
|
+
return '';
|
|
1120
|
+
}
|
|
1121
|
+
})();
|
|
1122
|
+
if (picture && source) scope.settled.push({
|
|
1123
|
+
at: scope.at,
|
|
1124
|
+
what: `a video${host ? ` on ${host}` : ''} shown as its picture${picture.to ? ', linking to it' : ''}`
|
|
1125
|
+
});
|
|
1126
|
+
return picture ? [
|
|
1127
|
+
{
|
|
1128
|
+
kind: 'image',
|
|
1129
|
+
picture
|
|
1130
|
+
}
|
|
1131
|
+
] : [];
|
|
1132
|
+
}
|
|
1133
|
+
/** 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) {
|
|
1134
|
+
var _doc_videos;
|
|
1135
|
+
const films = new Map();
|
|
1136
|
+
((_doc_videos = doc.videos) != null ? _doc_videos : []).forEach((video, index)=>{
|
|
1137
|
+
const source = siteImportFilmSource(video);
|
|
1138
|
+
if (!source) return;
|
|
1139
|
+
const title = clean(video.title).slice(0, 200);
|
|
1140
|
+
const description = clean(video.description).slice(0, 2000);
|
|
1141
|
+
films.set(index, _extends({
|
|
1142
|
+
index,
|
|
1143
|
+
src: source.src
|
|
1144
|
+
}, title ? {
|
|
1145
|
+
title
|
|
1146
|
+
} : {}, description ? {
|
|
1147
|
+
description
|
|
1148
|
+
} : {}, video.uploadDate ? {
|
|
1149
|
+
uploadDate: video.uploadDate
|
|
1150
|
+
} : {}, video.durationSeconds ? {
|
|
1151
|
+
durationSeconds: video.durationSeconds
|
|
1152
|
+
} : {}));
|
|
1153
|
+
});
|
|
1154
|
+
return films;
|
|
1155
|
+
}
|
|
1156
|
+
/** Whether a film is drawn as the Video element: one it plays, its poster a picture the library holds. */ function filmPlaces(scope, video, poster) {
|
|
1157
|
+
const block = poster === undefined ? undefined : scope.doc.blocks[poster];
|
|
1158
|
+
return scope.films.has(video) && (block == null ? void 0 : block.kind) === 'image' && scope.photos.has(block.url);
|
|
1159
|
+
}
|
|
1160
|
+
/** The first film of a list of nodes drawn as the Video element, rows, tabs and items opened. */ function firstFilm(scope, nodes) {
|
|
1161
|
+
for (const node of nodes){
|
|
1162
|
+
var _ref;
|
|
1163
|
+
var _node_items_find;
|
|
1164
|
+
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;
|
|
1165
|
+
if (found !== null) return found;
|
|
1166
|
+
}
|
|
1167
|
+
return null;
|
|
1168
|
+
}
|
|
923
1169
|
/** 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
1170
|
/**
|
|
925
1171
|
* A row that is a byline (AGL-4107): one cell a lone picture, the other a few
|
|
@@ -937,7 +1183,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
937
1183
|
}, 0);
|
|
938
1184
|
if (count === 0 || count > BYLINE_MAX_WORDS) return null;
|
|
939
1185
|
const node = cells[at].nodes[0];
|
|
940
|
-
const picture = takePicture(scope, node.line, node.button ? undefined : node.href);
|
|
1186
|
+
const picture = takePicture(scope, node.line, node.button ? undefined : node.href, node.fit);
|
|
941
1187
|
return [
|
|
942
1188
|
...picture ? [
|
|
943
1189
|
{
|
|
@@ -980,26 +1226,60 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
980
1226
|
'cover',
|
|
981
1227
|
'poster'
|
|
982
1228
|
]);
|
|
1229
|
+
/**
|
|
1230
|
+
* The heroes that keep the source's picture where it lays it (AGL-4138): under
|
|
1231
|
+
* or over its words in a column, beside them, or behind them. An answer may
|
|
1232
|
+
* choose among these alone.
|
|
1233
|
+
*/ const HEROES_AT = {
|
|
1234
|
+
below: new Set([
|
|
1235
|
+
'column',
|
|
1236
|
+
'editorial'
|
|
1237
|
+
]),
|
|
1238
|
+
above: new Set([
|
|
1239
|
+
'column',
|
|
1240
|
+
'editorial'
|
|
1241
|
+
]),
|
|
1242
|
+
beside: new Set([
|
|
1243
|
+
'split',
|
|
1244
|
+
'bleed',
|
|
1245
|
+
'panel'
|
|
1246
|
+
]),
|
|
1247
|
+
behind: new Set([
|
|
1248
|
+
'cover',
|
|
1249
|
+
'poster',
|
|
1250
|
+
'panel'
|
|
1251
|
+
])
|
|
1252
|
+
};
|
|
983
1253
|
/**
|
|
984
1254
|
* The hero a section's opening takes: the first section's, around its picture
|
|
985
1255
|
* beside, behind or under its words. Words dimmed over the picture draw the
|
|
986
1256
|
* section dark, so a section that keeps a lighter ground of its own, with its
|
|
987
1257
|
* picture anywhere but behind it, opens as its source does (AGL-4083): an
|
|
988
|
-
* answer never repaints a section's own band.
|
|
1258
|
+
* answer never repaints a section's own band. Nor does it move the picture
|
|
1259
|
+
* (AGL-4138): a picture under centered words stays under them, as a picture
|
|
1260
|
+
* beside the words stays beside them.
|
|
989
1261
|
*/ function heroOf(section, index, answer, settled) {
|
|
990
1262
|
var _ref;
|
|
991
1263
|
var _section_hero;
|
|
992
1264
|
if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
|
|
993
1265
|
// An answer of "none" keeps the opening as the source lays it out.
|
|
994
1266
|
if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
|
|
995
|
-
const
|
|
996
|
-
|
|
1267
|
+
const place = section.hero.picture;
|
|
1268
|
+
const own = HERO_FOR[place];
|
|
1269
|
+
if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && section.band !== 'dark' && place !== 'behind') {
|
|
997
1270
|
settled.push({
|
|
998
1271
|
at: 'sections[0]',
|
|
999
1272
|
what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
|
|
1000
1273
|
});
|
|
1001
1274
|
return own;
|
|
1002
1275
|
}
|
|
1276
|
+
if ((answer == null ? void 0 : answer.hero) && !HEROES_AT[place].has(answer.hero)) {
|
|
1277
|
+
settled.push({
|
|
1278
|
+
at: 'sections[0]',
|
|
1279
|
+
what: `the ${answer.hero} hero set aside: the source lays its picture ${place} its words`
|
|
1280
|
+
});
|
|
1281
|
+
return own;
|
|
1282
|
+
}
|
|
1003
1283
|
return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
|
|
1004
1284
|
}
|
|
1005
1285
|
/**
|
|
@@ -1031,19 +1311,43 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1031
1311
|
answer: null,
|
|
1032
1312
|
groupAt: 0,
|
|
1033
1313
|
settled: [],
|
|
1034
|
-
at: ''
|
|
1314
|
+
at: '',
|
|
1315
|
+
films: filmsOf(doc),
|
|
1316
|
+
film: null
|
|
1035
1317
|
};
|
|
1318
|
+
const backdropOf = (section)=>{
|
|
1319
|
+
var _section_backdrop;
|
|
1320
|
+
return ((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'video' ? section.backdrop : null;
|
|
1321
|
+
};
|
|
1322
|
+
const pageFilm = layout.sections.reduce((found, section)=>found != null ? found : firstFilm(scope, section.nodes), null);
|
|
1036
1323
|
const sections = layout.sections.map((section, index)=>{
|
|
1037
|
-
var _ref, _ref1, _siteImportWidthOf;
|
|
1324
|
+
var _ref, _firstFilm, _ref1, _siteImportWidthOf;
|
|
1038
1325
|
const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
|
|
1039
1326
|
scope.answer = given;
|
|
1040
1327
|
scope.groupAt = 0;
|
|
1041
1328
|
scope.at = `sections[${index}]`;
|
|
1329
|
+
const behind = backdropOf(section);
|
|
1330
|
+
scope.film = (_firstFilm = firstFilm(scope, section.nodes)) != null ? _firstFilm : pageFilm;
|
|
1042
1331
|
const row = {
|
|
1043
1332
|
cols: null,
|
|
1044
1333
|
allowed: true
|
|
1045
1334
|
};
|
|
1046
|
-
|
|
1335
|
+
// A film playing on its own behind the section's words is drawn as its poster there (AGL-4140): the
|
|
1336
|
+
// opening's hero lays it behind them. A film that starts on its own is one rule 16 refuses.
|
|
1337
|
+
const poster = behind ? takePicture(scope, behind.poster) : null;
|
|
1338
|
+
if (behind) scope.settled.push({
|
|
1339
|
+
at: scope.at,
|
|
1340
|
+
what: 'a film playing behind the words drawn as its poster'
|
|
1341
|
+
});
|
|
1342
|
+
const blocks = [
|
|
1343
|
+
...poster ? [
|
|
1344
|
+
{
|
|
1345
|
+
kind: 'image',
|
|
1346
|
+
picture: poster
|
|
1347
|
+
}
|
|
1348
|
+
] : [],
|
|
1349
|
+
...nodeBlocks(scope, section.nodes, row)
|
|
1350
|
+
];
|
|
1047
1351
|
// Every line the layout placed nowhere, at the section's end, as its kind says.
|
|
1048
1352
|
for (const ref of section.lines){
|
|
1049
1353
|
if (scope.used.has(ref)) continue;
|
|
@@ -1085,6 +1389,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1085
1389
|
* lays it out and drawn in the site's own theme.
|
|
1086
1390
|
*/ export function aiCompileImportedPage(input) {
|
|
1087
1391
|
var _input_answer;
|
|
1392
|
+
var _compiled_videoIds;
|
|
1088
1393
|
const { doc } = input;
|
|
1089
1394
|
const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
|
|
1090
1395
|
const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
|
|
@@ -1128,9 +1433,12 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1128
1433
|
const block = doc.blocks[ref];
|
|
1129
1434
|
return block && block.kind !== 'image' ? aiSiteImportWordsIn(clean(block.text)) : 0;
|
|
1130
1435
|
};
|
|
1131
|
-
return {
|
|
1436
|
+
return _extends({
|
|
1132
1437
|
tree: compiled.tree,
|
|
1133
|
-
sectionRoots: compiled.sectionRoots
|
|
1438
|
+
sectionRoots: compiled.sectionRoots
|
|
1439
|
+
}, ((_compiled_videoIds = compiled.videoIds) == null ? void 0 : _compiled_videoIds.length) ? {
|
|
1440
|
+
videoIds: compiled.videoIds
|
|
1441
|
+
} : {}, {
|
|
1134
1442
|
sections,
|
|
1135
1443
|
placed,
|
|
1136
1444
|
lines: lineRefs.length,
|
|
@@ -1141,7 +1449,7 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1141
1449
|
...designed.settled,
|
|
1142
1450
|
...compiled.settled
|
|
1143
1451
|
]
|
|
1144
|
-
};
|
|
1452
|
+
});
|
|
1145
1453
|
}
|
|
1146
1454
|
/*------------------------------------------
|
|
1147
1455
|
* What the design answer is shown
|
|
@@ -1154,7 +1462,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1154
1462
|
if (block.kind === 'list-item') return 'list item';
|
|
1155
1463
|
if (block.kind === 'quote') return 'quote';
|
|
1156
1464
|
if (block.kind === 'image') return 'picture';
|
|
1157
|
-
|
|
1465
|
+
// A statement is read as the lede it was before the import drew it larger (AGL-4138): the answer's text is unchanged.
|
|
1466
|
+
return node.role === 'statement' ? 'lede' : (_node_role = node.role) != null ? _node_role : 'text';
|
|
1158
1467
|
}
|
|
1159
1468
|
/** What an item of a group shows, as one phrase: "icon + title + text + link". */ function itemShape(item) {
|
|
1160
1469
|
var _item_text, _item_list, _item_link;
|
|
@@ -1186,6 +1495,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1186
1495
|
parts.push(lineKind(doc.blocks[node.line], node));
|
|
1187
1496
|
break;
|
|
1188
1497
|
case 'picture':
|
|
1498
|
+
// A film reads as the picture it opens on (AGL-4140): the design answer is asked nothing new of it.
|
|
1499
|
+
case 'video':
|
|
1189
1500
|
parts.push('picture');
|
|
1190
1501
|
break;
|
|
1191
1502
|
case 'form':
|
|
@@ -1200,7 +1511,8 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
|
|
|
1200
1511
|
const shape = [
|
|
1201
1512
|
...new Set(node.items.map((item)=>itemShape(item).join(' + ')).filter(Boolean))
|
|
1202
1513
|
].slice(0, 2).join(' or ');
|
|
1203
|
-
|
|
1514
|
+
// 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.
|
|
1515
|
+
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
1516
|
break;
|
|
1205
1517
|
}
|
|
1206
1518
|
case 'table':
|