@aglyn/plugins-ai 1.0.0-beta.249 → 1.0.0-beta.250

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.
@@ -415,6 +415,12 @@ export interface AiLayoutStockPhotoSourceInput {
415
415
  * language is searched by, in place of its business type and its alt texts.
416
416
  */
417
417
  photoWords?: string;
418
+ /**
419
+ * The English name of the kind of site the person picked (AGL-3771): what a
420
+ * site in another language whose plan gave no photo words is searched by,
421
+ * rather than its business type in its own language.
422
+ */
423
+ kindWords?: string;
418
424
  /** The page's section names, by plan index. */
419
425
  sectionNames: readonly string[];
420
426
  /**
@@ -433,10 +439,14 @@ export interface AiLayoutStockPhotoDeps {
433
439
  ingest?: () => PluginMediaIngest | null;
434
440
  budgetMs?: number;
435
441
  }
436
- /** A job's language and English photo words (AGL-3760), as a stock photo source takes them. */
442
+ /**
443
+ * A job's language and English photo words (AGL-3760), and the English name
444
+ * of its kind of site (AGL-3771), as a stock photo source takes them.
445
+ */
437
446
  export declare function aiStockPhotoWordsOf(job: {
438
447
  plan?: Pick<AiBuildPlan, 'language' | 'photoWords'> | null;
439
- }): Pick<AiLayoutStockPhotoSourceInput, 'language' | 'photoWords'>;
448
+ inputs?: Readonly<Record<string, unknown>> | null;
449
+ }): Pick<AiLayoutStockPhotoSourceInput, 'language' | 'photoWords' | 'kindWords'>;
440
450
  /**
441
451
  * The subject a plan's photo words lead with (AGL-3769): its first word that
442
452
  * is not filler, with the place or person words that follow it — "bakery" of
@@ -456,7 +466,7 @@ export declare function aiStockPhotoWordsSubject(photoWords: string): string;
456
466
  * source — hero, background, gallery, card, product, post — so no slot
457
467
  * searches by words another slot is held against.
458
468
  */
459
- export declare function aiStockSourceTerms(input: Pick<AiLayoutStockPhotoSourceInput, 'business' | 'language' | 'photoWords'>): AiStockSiteTerms;
469
+ export declare function aiStockSourceTerms(input: Pick<AiLayoutStockPhotoSourceInput, 'business' | 'language' | 'photoWords' | 'kindWords'>): AiStockSiteTerms;
460
470
  /**
461
471
  * The source for one page, or `null` when this deployment has no stock
462
472
  * photo library or no media door, which leaves every slot to the starters.
@@ -19,6 +19,7 @@ import { STOCK_PHOTO_QUERY_MAX_CHARS, stockPhotoProvider, stockPhotoSourceKey }
19
19
  import { aiLayoutSeedNumber } from "../layout-language/ai-layout-pictures.js";
20
20
  import { aiStorefrontSays } from "../layout-language/ai-layout-storefront.js";
21
21
  import { aiLayoutSpeaksOtherThanEnglish } from "../layout-language/ai-layout-labels.js";
22
+ import { aiSiteKindOfInputs } from "../model/ai-site-kinds.js";
22
23
  /**
23
24
  * STOCK PHOTOS FOR A LANGUAGE PAGE'S PICTURE SLOTS (AGL-3660).
24
25
  *
@@ -1769,12 +1770,20 @@ const EXTENSIONS = {
1769
1770
  'image/png': 'png',
1770
1771
  'image/webp': 'webp'
1771
1772
  };
1772
- /** A job's language and English photo words (AGL-3760), as a stock photo source takes them. */ export function aiStockPhotoWordsOf(job) {
1773
+ /**
1774
+ * A job's language and English photo words (AGL-3760), and the English name
1775
+ * of its kind of site (AGL-3771), as a stock photo source takes them.
1776
+ */ export function aiStockPhotoWordsOf(job) {
1773
1777
  const plan = job.plan;
1778
+ const kind = job.inputs ? aiSiteKindOfInputs(job.inputs) : null;
1779
+ // "Restaurant & café" searches as "restaurant cafe".
1780
+ const kindWords = kind ? kind.label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/&/g, ' ').replace(/\s+/g, ' ').trim().toLowerCase() : '';
1774
1781
  return _extends({}, (plan == null ? void 0 : plan.language) ? {
1775
1782
  language: plan.language
1776
1783
  } : {}, (plan == null ? void 0 : plan.photoWords) ? {
1777
1784
  photoWords: plan.photoWords
1785
+ } : {}, kindWords ? {
1786
+ kindWords
1778
1787
  } : {});
1779
1788
  }
1780
1789
  /**
@@ -1804,9 +1813,16 @@ const EXTENSIONS = {
1804
1813
  */ export function aiStockSourceTerms(input) {
1805
1814
  return aiStockSiteTerms(aiStockSourceSubject(input) || input.business);
1806
1815
  }
1807
- /** The photo words' subject a site in another language is searched by ({@link aiStockSourceTerms}); empty for every other site. */ function aiStockSourceSubject(input) {
1808
- var _input_photoWords;
1809
- return aiLayoutSpeaksOtherThanEnglish(input.language) ? aiStockPhotoWordsSubject((_input_photoWords = input.photoWords) != null ? _input_photoWords : '') : '';
1816
+ /**
1817
+ * What a site in another language is searched by ({@link aiStockSourceTerms}):
1818
+ * its photo words' subject, else, where its plan gave none, the English name
1819
+ * of its kind of site (AGL-3771) — Panaderia El Trigal's plan gave no photo
1820
+ * words, and its pages searched "con pan dulce" again and placed the Río
1821
+ * Dulce beside its story. Empty for every other site.
1822
+ */ function aiStockSourceSubject(input) {
1823
+ var _input_photoWords, _input_kindWords;
1824
+ if (!aiLayoutSpeaksOtherThanEnglish(input.language)) return '';
1825
+ return aiStockPhotoWordsSubject((_input_photoWords = input.photoWords) != null ? _input_photoWords : '') || ((_input_kindWords = input.kindWords) != null ? _input_kindWords : '').trim();
1810
1826
  }
1811
1827
  /**
1812
1828
  * The source for one page, or `null` when this deployment has no stock