@aglyn/plugins-ai 1.0.0-beta.247 → 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,34 @@ 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'>;
450
+ /**
451
+ * The subject a plan's photo words lead with (AGL-3769): its first word that
452
+ * is not filler, with the place or person words that follow it — "bakery" of
453
+ * "bakery pan dulce conchas", "candle shop" of "candle shop soy candles",
454
+ * "ceramic artist" of "ceramic artist stoneware bowls". The words are subject
455
+ * first, never an English noun phrase with its head last, and what follows
456
+ * the subject may be the brief's own names in English letters: Panaderia La
457
+ * Espiga Dorada's "pan dulce conchas" read as the business, made "concha" its
458
+ * craft, and placed purple ceanothus flowers, tagged "ceanothus concha", as
459
+ * its hero. Empty when every word is filler.
460
+ */
461
+ export declare function aiStockPhotoWordsSubject(photoWords: string): string;
462
+ /**
463
+ * What a source's photos are searched and judged by (AGL-3760, AGL-3769): a
464
+ * site in another language by the subject of its plan's English photo words,
465
+ * every other site by its business type. One reading for every slot of every
466
+ * source — hero, background, gallery, card, product, post — so no slot
467
+ * searches by words another slot is held against.
468
+ */
469
+ export declare function aiStockSourceTerms(input: Pick<AiLayoutStockPhotoSourceInput, 'business' | 'language' | 'photoWords' | 'kindWords'>): AiStockSiteTerms;
440
470
  /**
441
471
  * The source for one page, or `null` when this deployment has no stock
442
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,19 +1770,65 @@ 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
  }
1789
+ /**
1790
+ * The subject a plan's photo words lead with (AGL-3769): its first word that
1791
+ * is not filler, with the place or person words that follow it — "bakery" of
1792
+ * "bakery pan dulce conchas", "candle shop" of "candle shop soy candles",
1793
+ * "ceramic artist" of "ceramic artist stoneware bowls". The words are subject
1794
+ * first, never an English noun phrase with its head last, and what follows
1795
+ * the subject may be the brief's own names in English letters: Panaderia La
1796
+ * Espiga Dorada's "pan dulce conchas" read as the business, made "concha" its
1797
+ * craft, and placed purple ceanothus flowers, tagged "ceanothus concha", as
1798
+ * its hero. Empty when every word is filler.
1799
+ */ export function aiStockPhotoWordsSubject(photoWords) {
1800
+ const list = contentWords(photoWords);
1801
+ const start = list.findIndex((word)=>!FILLER.has(word) && !SITE_KINDS.has(word));
1802
+ if (start < 0) return '';
1803
+ let end = start + 1;
1804
+ while(end < list.length && (VENUES.has(list[end]) || ROLES.has(list[end])))end += 1;
1805
+ return list.slice(start, end).join(' ');
1806
+ }
1807
+ /**
1808
+ * What a source's photos are searched and judged by (AGL-3760, AGL-3769): a
1809
+ * site in another language by the subject of its plan's English photo words,
1810
+ * every other site by its business type. One reading for every slot of every
1811
+ * source — hero, background, gallery, card, product, post — so no slot
1812
+ * searches by words another slot is held against.
1813
+ */ export function aiStockSourceTerms(input) {
1814
+ return aiStockSiteTerms(aiStockSourceSubject(input) || input.business);
1815
+ }
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();
1826
+ }
1780
1827
  /**
1781
1828
  * The source for one page, or `null` when this deployment has no stock
1782
1829
  * photo library or no media door, which leaves every slot to the starters.
1783
1830
  */ export function aiLayoutStockPhotoSource(input, deps = {}) {
1784
- var _deps_provider, _deps_ingest, _input_photoWords;
1831
+ var _deps_provider, _deps_ingest;
1785
1832
  const provider = ((_deps_provider = deps.provider) != null ? _deps_provider : stockPhotoProvider)();
1786
1833
  const ingest = ((_deps_ingest = deps.ingest) != null ? _deps_ingest : pluginMediaIngest)();
1787
1834
  if (!provider || !ingest || !input.hostId || !input.uid) return null;
@@ -1789,10 +1836,10 @@ const EXTENSIONS = {
1789
1836
  // "Una panadería familiar de San Antonio con pan dulce…", read as the
1790
1837
  // business "con pan dulce", and its hero searched that and placed the Río
1791
1838
  // Dulce at dusk; a site in another language is searched by its plan's
1792
- // English photo words, and its slots' alt texts, in its own language, name
1793
- // no subject a search could use.
1794
- const english = aiLayoutSpeaksOtherThanEnglish(input.language) ? ((_input_photoWords = input.photoWords) != null ? _input_photoWords : '').trim() : '';
1795
- const terms = aiStockSiteTerms(english || input.business);
1839
+ // English photo words' subject ({@link aiStockSourceTerms}), and its slots'
1840
+ // alt texts, in its own language, name no subject a search could use.
1841
+ const english = aiStockSourceSubject(input);
1842
+ const terms = aiStockSourceTerms(input);
1796
1843
  return async (slots)=>{
1797
1844
  var _deps_budgetMs, _input_avoid;
1798
1845
  const timeout = AbortSignal.timeout((_deps_budgetMs = deps.budgetMs) != null ? _deps_budgetMs : AI_LAYOUT_STOCK_PHOTOS_BUDGET_MS);