@aglyn/plugins-ai 1.13.0 → 1.14.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.
Files changed (37) hide show
  1. package/package.json +17 -17
  2. package/src/lib/jobs/ai-site-import-compile.js +23 -3
  3. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  4. package/src/lib/layout-language/ai-layout-compiler.js +90 -8
  5. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  6. package/src/lib/layout-language/ai-layout-language.d.ts +8 -2
  7. package/src/lib/layout-language/ai-layout-language.js +4 -2
  8. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  9. package/src/lib/model/ai-site-import-fidelity.d.ts +9 -0
  10. package/src/lib/model/ai-site-import-fidelity.js +64 -6
  11. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  12. package/src/lib/model/ai-site-import.d.ts +7 -0
  13. package/src/lib/model/ai-site-import.js.map +1 -1
  14. package/src/lib/runtime/site-inventory.js +2 -3
  15. package/src/lib/runtime/site-inventory.js.map +1 -1
  16. package/src/lib/server/assist-view-context.js +3 -3
  17. package/src/lib/server/assist-view-context.js.map +1 -1
  18. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +12 -1
  19. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +19 -9
  20. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  21. package/src/lib/site-import/site-import-concealed.d.ts +30 -0
  22. package/src/lib/site-import/site-import-concealed.js +231 -0
  23. package/src/lib/site-import/site-import-concealed.js.map +1 -0
  24. package/src/lib/site-import/site-import-crawl.d.ts +3 -1
  25. package/src/lib/site-import/site-import-crawl.js +8 -1
  26. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  27. package/src/lib/site-import/site-import-css.js +13 -2
  28. package/src/lib/site-import/site-import-css.js.map +1 -1
  29. package/src/lib/site-import/site-import-html.d.ts +28 -0
  30. package/src/lib/site-import/site-import-html.js +246 -49
  31. package/src/lib/site-import/site-import-html.js.map +1 -1
  32. package/src/lib/site-import/site-import-layout.js +211 -12
  33. package/src/lib/site-import/site-import-layout.js.map +1 -1
  34. package/src/lib/site-import/site-import-page.js +2 -0
  35. package/src/lib/site-import/site-import-page.js.map +1 -1
  36. package/src/lib/testing/stand-in-dataset-index.js +6 -2
  37. package/src/lib/testing/stand-in-dataset-index.js.map +1 -1
@@ -22,7 +22,7 @@ import { AI_INSTANCE_REF_PROP } from "../runtime/ai-node-tree.js";
22
22
  import { AI_TEXT_LIMITS } from "../runtime/ai-palette.js";
23
23
  import { aiPagePlayVideoInteraction, aiPageScrollInteraction } from "../runtime/ai-page-links.js";
24
24
  import { aiLayoutFitText, aiLayoutQuoteGap, aiLayoutWords } from "./ai-layout-copy.js";
25
- import { AI_LAYOUT_GROUP_KINDS, AI_LAYOUT_MAX_ITEMS } from "./ai-layout-language.js";
25
+ import { AI_LAYOUT_GROUP_KINDS, AI_LAYOUT_MAX_COLS, AI_LAYOUT_MAX_ITEMS } from "./ai-layout-language.js";
26
26
  import { AI_LAYOUT_HALF_HEROES, aiLayoutDesignChoices, aiLayoutFamily, aiLayoutGroupVariant } from "./ai-layout-design.js";
27
27
  import { AI_LAYOUT_FEATURED_RECORDS, AI_LAYOUT_LISTING_ELEMENTS, aiLayoutIsRecordImageAlt, aiLayoutListingAt, aiLayoutRecordHref, aiLayoutRecordImageAltField, aiLayoutRepeatFilterOf } from "./ai-layout-listings.js";
28
28
  import { aiStorefrontItemIcons } from "./ai-layout-storefront.js";
@@ -206,7 +206,7 @@ function formSectionOf(sections, plan, targets) {
206
206
  }
207
207
  function sectionScope(page, raw, index) {
208
208
  var _raw_band, _ref;
209
- var _page_design, _raw_blocks_find, _page_plan_sections_index;
209
+ var _page_design, _inRows_find, _page_plan_sections_index;
210
210
  const at = `sections[${index}]`;
211
211
  const asked = (_raw_band = raw.band) != null ? _raw_band : 'plain';
212
212
  // A page brought in keeps the source's bands, every one (AGL-4107), unless
@@ -236,10 +236,10 @@ function sectionScope(page, raw, index) {
236
236
  from: index,
237
237
  formSection: page.formSection
238
238
  },
239
- heading: (_raw_blocks_find = raw.blocks.find((block)=>block.kind === 'heading')) == null ? void 0 : _raw_blocks_find.text,
239
+ heading: (_inRows_find = inRows(raw.blocks).find((block)=>block.kind === 'heading')) == null ? void 0 : _inRows_find.text,
240
240
  words: [
241
241
  (_ref = (_page_plan_sections_index = page.plan.sections[index]) == null ? void 0 : _page_plan_sections_index.name) != null ? _ref : '',
242
- ...raw.blocks.filter((block)=>block.kind === 'heading' || block.kind === 'eyebrow').map((block)=>{
242
+ ...inRows(raw.blocks).filter((block)=>block.kind === 'heading' || block.kind === 'eyebrow').map((block)=>{
243
243
  var _block_text;
244
244
  return (_block_text = block.text) != null ? _block_text : '';
245
245
  })
@@ -375,7 +375,7 @@ function drawSection(page, raw, index, scope) {
375
375
  ]){
376
376
  for(let at = list.length - 1; at >= 0; at -= 1)if (list[at].kind === 'heading' && !speaks(list[at])) list.splice(at, 1);
377
377
  }
378
- if (index === 0 && !inOrder().some(speaks)) {
378
+ if (index === 0 && !inRows(inOrder()).some(speaks)) {
379
379
  head.unshift({
380
380
  kind: 'heading',
381
381
  text: page.plan.title
@@ -528,7 +528,7 @@ function drawSection(page, raw, index, scope) {
528
528
  /** Whether a block spans more than a reading column: a row of several items, or a table, tabs or logos of a page brought in. */ function isWideGroup(block) {
529
529
  var _ref;
530
530
  var _block_items;
531
- if (block.kind === 'table' || block.kind === 'tabs' || block.kind === 'logos') return true;
531
+ if (block.kind === 'table' || block.kind === 'tabs' || block.kind === 'logos' || block.kind === 'row') return true;
532
532
  return (block.kind === 'cards' || block.kind === 'steps' || block.kind === 'stats' || block.kind === 'quotes') && ((_ref = (_block_items = block.items) == null ? void 0 : _block_items.length) != null ? _ref : 0) >= 2 && // A page brought in lays a group out as its source does: one to a row reads at a reading width.
533
533
  block.columns !== 1;
534
534
  }
@@ -891,10 +891,33 @@ function compileBlock(scope, block, room) {
891
891
  return logos(scope, block);
892
892
  case 'video':
893
893
  return block.video ? video(scope, block.video, block.picture) : null;
894
+ case 'row':
895
+ return columnsRow(scope, block, room);
894
896
  default:
895
897
  return null;
896
898
  }
897
899
  }
900
+ /** Blocks and the blocks of the rows among them (AGL-4152), top to bottom: what a section says, whichever row says it. */ function inRows(blocks) {
901
+ return blocks.flatMap((block)=>{
902
+ var _block_row;
903
+ return block.kind === 'row' ? inRows(((_block_row = block.row) != null ? _block_row : []).flatMap((column)=>column.blocks)) : [
904
+ block
905
+ ];
906
+ });
907
+ }
908
+ /**
909
+ * A row of a page brought in past its section's first (AGL-4152), in its
910
+ * columns as `compileRow` sets them. Where the room is a column too narrow to
911
+ * split, or only one column has anything in it, one under another.
912
+ */ function columnsRow(scope, block, room) {
913
+ var _block_row;
914
+ const filled = ((_block_row = block.row) != null ? _block_row : []).filter((column)=>column.blocks.length);
915
+ if (filled.length < 2 || room === 'narrow') return compileFlow(scope, filled.flatMap((column)=>column.blocks), room);
916
+ return compileRow(scope, filled.map((column)=>({
917
+ column: column.blocks,
918
+ weight: column.weight
919
+ })));
920
+ }
898
921
  /** Secondary words' color: muted text, or the band's own on a brand band. */ function muted(scope) {
899
922
  return scope.band === 'brand' || scope.overPhoto ? null : {
900
923
  color: 'text.secondary'
@@ -1885,8 +1908,11 @@ function instances(scope, placed, items, perRow) {
1885
1908
  if (variant === 'panel') return panelHero(scope, flow, picture, home);
1886
1909
  if (variant === 'portrait') return portraitHero(scope, flow, picture);
1887
1910
  const band = scope.band;
1911
+ // A page kept as it is (AGL-4152) keeps a centered opening's words centered beside its picture.
1912
+ const keptCentered = scope.page.options.verbatim === true && scope.page.options.finish !== 'improve' && scope.centered;
1888
1913
  scope.centered = false;
1889
1914
  if (variant === 'split') {
1915
+ scope.centered = keptCentered;
1890
1916
  const words = compileFlow(scope, flow, 'half');
1891
1917
  const photo = designPicture(scope, picture, ownFrame(scope, picture, {
1892
1918
  aspectRatio: home ? {
@@ -4024,6 +4050,7 @@ function listingSection(scope, blocks, placed) {
4024
4050
  }, align(scope)), null, null, 'title') : null;
4025
4051
  if (kind === 'quotes') {
4026
4052
  var _item_more;
4053
+ var _item_links;
4027
4054
  parts.push(tree.add(AI_ICON_COMPONENT_ID, {
4028
4055
  iconId: AI_ICON_LIBRARY.quote.id,
4029
4056
  size: '32'
@@ -4039,8 +4066,10 @@ function listingSection(scope, blocks, placed) {
4039
4066
  variant: 'subtitle2',
4040
4067
  component: 'p'
4041
4068
  }, align(scope)), null, null, 'attribution'));
4069
+ if ((_item_links = item.links) == null ? void 0 : _item_links.length) parts.push(itemLinks(scope, item.links));
4042
4070
  } else if (kind === 'stats') {
4043
4071
  var _item_more1;
4072
+ var _item_links1;
4044
4073
  const lead = figure || title;
4045
4074
  if (lead) parts.push(tree.add('muiTypography', _extends({
4046
4075
  children: lead,
@@ -4052,9 +4081,10 @@ function listingSection(scope, blocks, placed) {
4052
4081
  item.text,
4053
4082
  ...(_item_more1 = item.more) != null ? _item_more1 : []
4054
4083
  ], 'body2', muted(scope), 'label'));
4084
+ if ((_item_links1 = item.links) == null ? void 0 : _item_links1.length) parts.push(itemLinks(scope, item.links));
4055
4085
  } else {
4056
4086
  var _item_more2;
4057
- var _item_list, _item_links;
4087
+ var _item_list, _item_links2;
4058
4088
  if (item.picture) parts.push(itemPicture(scope, item.picture));
4059
4089
  const { lead, mark } = leadRow(scope, item, style);
4060
4090
  // The arrow sits at the end of the icon's row, or of the title's where the item has no icon (AGL-4138);
@@ -4087,7 +4117,7 @@ function listingSection(scope, blocks, placed) {
4087
4117
  ...(_item_more2 = item.more) != null ? _item_more2 : []
4088
4118
  ], 'body1', muted(scope)));
4089
4119
  if ((_item_list = item.list) == null ? void 0 : _item_list.length) parts.push(bullets(scope, item.list, item.listIconPath));
4090
- if ((_item_links = item.links) == null ? void 0 : _item_links.length) parts.push(itemLinks(scope, item.links));
4120
+ if ((_item_links2 = item.links) == null ? void 0 : _item_links2.length) parts.push(itemLinks(scope, item.links));
4091
4121
  }
4092
4122
  const shown = parts.filter((id)=>!!id);
4093
4123
  // The picture of a card is its top, edge to edge; the rest sit in its padding.
@@ -4414,6 +4444,7 @@ function listingSection(scope, blocks, placed) {
4414
4444
  var _block_items;
4415
4445
  var _block_items1;
4416
4446
  const tree = scope.page.tree;
4447
+ if (block.variant === 'pictures') return gallery(scope, block);
4417
4448
  const ids = ((_block_items = block.items) != null ? _block_items : []).flatMap((item)=>{
4418
4449
  if (item.picture) {
4419
4450
  scope.page.images += 1;
@@ -4469,6 +4500,57 @@ function listingSection(scope, blocks, placed) {
4469
4500
  justifyContent: 'center'
4470
4501
  } : {}), null, noted(scope, ids), 'logos');
4471
4502
  }
4503
+ /**
4504
+ * A gallery of a page brought in (AGL-4152): its photos in the source's
4505
+ * columns, two to a row on a tablet and one on a phone, each cropped to one
4506
+ * shape so the rows line up: their own where they all share one, else the
4507
+ * source's crop where all share one, else 4:3.
4508
+ */ function gallery(scope, block) {
4509
+ var _block_items, _block_columns, _;
4510
+ var _pictures_;
4511
+ const tree = scope.page.tree;
4512
+ const pictures = ((_block_items = block.items) != null ? _block_items : []).flatMap((item)=>item.picture ? [
4513
+ item.picture
4514
+ ] : []);
4515
+ if (!pictures.length) return null;
4516
+ const columns = Math.max(1, Math.min(AI_LAYOUT_MAX_COLS, (_block_columns = block.columns) != null ? _block_columns : 3, pictures.length));
4517
+ const first = (_pictures_ = pictures[0]) == null ? void 0 : _pictures_.ratio;
4518
+ const alike = !!first && pictures.every((picture)=>!!picture.ratio && Math.abs(picture.ratio / first - 1) <= 0.05);
4519
+ const crops = new Set(pictures.map((picture)=>{
4520
+ var _picture_fit;
4521
+ return ((_picture_fit = picture.fit) == null ? void 0 : _picture_fit.cropped) ? picture.fit.ratio : undefined;
4522
+ }));
4523
+ const shape = alike ? String(Math.round(first * 10000) / 10000) : crops.size === 1 ? (_ = [
4524
+ ...crops
4525
+ ][0]) != null ? _ : '4 / 3' : '4 / 3';
4526
+ const span = Math.max(1, Math.round(12 / columns));
4527
+ const size = columns >= 3 ? `xs:12 sm:6 md:${span}` : `xs:12 md:${span}`;
4528
+ const cells = pictures.map((picture)=>{
4529
+ scope.page.images += 1;
4530
+ const image = tree.add('image', _extends({
4531
+ src: picture.src
4532
+ }, picture.alt ? {
4533
+ alt: picture.alt
4534
+ } : {
4535
+ decorative: true
4536
+ }, {
4537
+ objectFit: 'cover'
4538
+ }, scope.page.images > 1 ? {
4539
+ loading: 'lazy'
4540
+ } : {}), {
4541
+ aspectRatio: shape
4542
+ }, null, 'galleryPicture');
4543
+ return tree.add('muiGrid', {
4544
+ size
4545
+ }, null, [
4546
+ image
4547
+ ], 'galleryCell');
4548
+ });
4549
+ return tree.add('muiGrid', {
4550
+ container: true,
4551
+ spacing: '2'
4552
+ }, null, cells, 'gallery');
4553
+ }
4472
4554
  /**
4473
4555
  * The opening of a page brought in, as the hero its design answer chose
4474
4556
  * around the source's own picture (AGL-4107): its words and one picture of