@aglyn/plugins-ai 1.12.0 → 1.13.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/components/ai-media-create.component.js +1 -1
  3. package/src/lib/components/ai-media-create.component.js.map +1 -1
  4. package/src/lib/components/ai-upsell-dialog.component.js +1 -1
  5. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
  6. package/src/lib/jobs/ai-job-import-step.js +11 -1
  7. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  8. package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
  9. package/src/lib/jobs/ai-site-import-look.js +142 -45
  10. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  11. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
  12. package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
  13. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  14. package/src/lib/model/ai-site-import.d.ts +29 -1
  15. package/src/lib/model/ai-site-import.js.map +1 -1
  16. package/src/lib/model/ai-upsell-copy.js +1 -1
  17. package/src/lib/model/ai-upsell-copy.js.map +1 -1
  18. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
  19. package/src/lib/site-import/fixtures/site-layout-recordings.js +55 -0
  20. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  21. package/src/lib/site-import/site-import-crawl.d.ts +2 -0
  22. package/src/lib/site-import/site-import-crawl.js +27 -17
  23. package/src/lib/site-import/site-import-crawl.js.map +1 -1
  24. package/src/lib/site-import/site-import-css.d.ts +81 -0
  25. package/src/lib/site-import/site-import-css.js +443 -25
  26. package/src/lib/site-import/site-import-css.js.map +1 -1
  27. package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
  28. package/src/lib/site-import/site-import-data-forms.js +531 -0
  29. package/src/lib/site-import/site-import-data-forms.js.map +1 -0
  30. package/src/lib/site-import/site-import-html.d.ts +8 -1
  31. package/src/lib/site-import/site-import-html.js +18 -5
  32. package/src/lib/site-import/site-import-html.js.map +1 -1
  33. package/src/lib/site-import/site-import-layout.d.ts +1 -1
  34. package/src/lib/site-import/site-import-layout.js +283 -36
  35. package/src/lib/site-import/site-import-layout.js.map +1 -1
  36. package/src/lib/site-import/site-import-nav.js +17 -3
  37. package/src/lib/site-import/site-import-nav.js.map +1 -1
@@ -49,6 +49,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
49
49
  * with its poster as the picture inside it. Its attributes and its data are
50
50
  * read; nothing of it is run.
51
51
  *=========================================*/ import { videoEmbedOf } from "@aglyn/aglyn/plugin-manager/video-embed-provider";
52
+ import { siteImportDataForms } from "./site-import-data-forms.js";
52
53
  /** Ceilings that keep one odd page from becoming the whole inventory. */ export const SITE_IMPORT_PAGE_LIMITS = {
53
54
  /** A pricing page's plan table runs past 400 (AGL-4083); a wave's read keeps fewer, under its own budget. */ blocks: 2000,
54
55
  /** A legal page's paragraph runs past 2,000 characters. */ blockChars: 10000,
@@ -62,7 +63,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
62
63
  svgIcons: 200,
63
64
  anchors: 800,
64
65
  styleChars: 1500000,
65
- stylesheets: 4,
66
+ /** The links listed (AGL-4152); how much of them is read is a byte budget's to say (`SITE_IMPORT_SHEET_LIMITS`). */ stylesheets: 24,
66
67
  /** A page's videos (AGL-4140). */ videos: 10
67
68
  };
68
69
  /** Elements removed with everything inside them. */ const REMOVED_WITH_CONTENT = [
@@ -414,8 +415,10 @@ function removeElements(html, tags) {
414
415
  leftOut
415
416
  } : {});
416
417
  }
417
- /** Forms with a payment field go whole; the rest are summarized, then go. */ function takeForms(html) {
418
- const kept = [];
418
+ /** Forms with a payment field go whole; the rest are summarized, then go. `first` are the forms the page's data held, whose markers are in place. */ function takeForms(html, first = []) {
419
+ const kept = [
420
+ ...first
421
+ ];
419
422
  let removed = 0;
420
423
  const out = html.replace(/<form\b(?:[^>"']|"[^"]*"|'[^']*')*>[\s\S]*?(?:<\/form\s*>|$)/gi, (form)=>{
421
424
  if (PAYMENT_FIELD.test(form)) {
@@ -1168,6 +1171,13 @@ const VIEW_BOX = /^-?[\d.]+(?:[\s,]+-?[\d.]+){3}$/;
1168
1171
  stylesheets
1169
1172
  };
1170
1173
  }
1174
+ /**
1175
+ * The stylesheets a page links (AGL-4152), to read: every one, on its own host
1176
+ * or a CDN's, print ones and comments left out, Google Fonts' read by its
1177
+ * address alone (`siteImportGoogleFamilies`).
1178
+ */ export function siteImportStylesheetLinks(html, pageUrl) {
1179
+ return readStyleSheets(html.replace(/<!--[\s\S]*?(?:-->|$)/g, ' '), pageUrl).stylesheets.filter((url)=>!/fonts\.googleapis\.com/i.test(url));
1180
+ }
1171
1181
  /** Elements with no content and no end tag. */ const VOID_TAGS = new Set([
1172
1182
  'area',
1173
1183
  'base',
@@ -1414,6 +1424,9 @@ const P_WALLS = new Set([
1414
1424
  styles: [],
1415
1425
  stylesheets: []
1416
1426
  };
1427
+ // A form defined in data (AGL-4152), read before scripts go: a marker at its place, its fields from the data.
1428
+ const dataForms = siteImportDataForms(source, formWords, SITE_IMPORT_PAGE_LIMITS);
1429
+ source = dataForms.html;
1417
1430
  // A video is a marker at its place (AGL-4140), read before scripts and
1418
1431
  // players go: its structured data is a script's body.
1419
1432
  const film = readVideos(source, pageUrl, isSameSite);
@@ -1424,7 +1437,7 @@ const P_WALLS = new Set([
1424
1437
  source = readSvgIcons(source, svgIcons);
1425
1438
  source = removeElements(readPictures(source), REMOVED_WITH_CONTENT).replace(REMOVED_VOID, ' ');
1426
1439
  // Forms next, so a field list is read before the controls go.
1427
- const forms = takeForms(source);
1440
+ const forms = takeForms(source, dataForms.kept);
1428
1441
  source = removeElements(forms.html, FORM_CONTROLS);
1429
1442
  const metas = metaTags(source);
1430
1443
  const metaContent = (key, attribute)=>{
@@ -1858,7 +1871,7 @@ const P_WALLS = new Set([
1858
1871
  links,
1859
1872
  forms: {
1860
1873
  kept: forms.kept,
1861
- removed: forms.removed
1874
+ removed: forms.removed + dataForms.removed
1862
1875
  }
1863
1876
  }, videos.length ? {
1864
1877
  videos