@vectoriox/iox-ui 5.194.0 → 5.196.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/actions-core/index.d.ts +1 -0
- package/commerce-core/index.d.ts +0 -1
- package/composite-core/index.d.ts +39 -12
- package/design-core/index.d.ts +396 -9
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +1 -0
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +0 -2
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +89 -36
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +864 -335
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +885 -513
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +221 -2
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs +11 -5
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +83 -31
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +322 -95
- package/harness-core/index.d.ts +165 -3
- package/identity-core/index.d.ts +8 -1
- package/index.d.ts +30 -8
- package/package.json +1 -1
- package/src/actions-core/public-api.ts +3 -0
- package/src/commerce-core/shop-display.ts +0 -2
- package/src/composite-core/account-runtime.ts +2 -2
- package/src/composite-core/header.ts +23 -1
- package/src/composite-core/lightbox.ts +27 -8
- package/src/composite-core/shop.ts +45 -28
- package/src/design-core/close-word.ts +18 -0
- package/src/design-core/contrast-audit.ts +62 -14
- package/src/design-core/flavor-spec.generated.ts +275 -1
- package/src/design-core/header-behaviour.ts +172 -3
- package/src/design-core/locale-direction.ts +17 -0
- package/src/design-core/node-classes.ts +9 -2
- package/src/design-core/public-api.ts +1 -0
- package/src/design-core/token-css.ts +62 -3
- package/src/generation-core/audit-site.ts +26 -5
- package/src/generation-core/audit-words.ts +8 -0
- package/src/generation-core/compose-site.ts +28 -10
- package/src/generation-core/header-mix.ts +165 -12
- package/src/generation-core/import-plan.ts +41 -0
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/site-spec.generated.ts +41 -9
- package/src/generation-core/stock-photos.ts +23 -4
- package/src/generation-core/stock-search.ts +235 -0
- package/src/harness-core/business-types.ts +11 -0
- package/src/harness-core/harness-spec.generated.ts +213 -0
- package/src/harness-core/run-compose-context.ts +9 -3
- package/src/identity-core/site-auth-transport.ts +11 -4
- package/styles/iox-design.css +148 -6
|
@@ -8356,6 +8356,7 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8356
8356
|
"solid",
|
|
8357
8357
|
"over",
|
|
8358
8358
|
"glass",
|
|
8359
|
+
"over-glass",
|
|
8359
8360
|
"blend"
|
|
8360
8361
|
],
|
|
8361
8362
|
"shape": [
|
|
@@ -8444,6 +8445,7 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8444
8445
|
"ground.solid": "its own ground",
|
|
8445
8446
|
"ground.over": "over the opening, transparent until the page moves",
|
|
8446
8447
|
"ground.glass": "frosted glass (a look with a blur)",
|
|
8448
|
+
"ground.over-glass": "over the opening and clear at first; frosted glass once the page moves",
|
|
8447
8449
|
"ground.blend": "blends with what is under it, readable over any picture",
|
|
8448
8450
|
"shape.bar": "a full-width bar",
|
|
8449
8451
|
"shape.pill": "one floating rounded bar",
|
|
@@ -8509,6 +8511,7 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8509
8511
|
"ground.solid": "רקע משלו",
|
|
8510
8512
|
"ground.over": "מעל הפתיחה, שקוף עד שהדף זז",
|
|
8511
8513
|
"ground.glass": "זכוכית חלבית (מראה עם טשטוש)",
|
|
8514
|
+
"ground.over-glass": "מעל הפתיחה ושקופה בהתחלה; זכוכית חלבית ברגע שהדף זז",
|
|
8512
8515
|
"ground.blend": "נבלע במה שמתחתיו, קריא מעל כל תמונה",
|
|
8513
8516
|
"shape.bar": "פס ברוחב מלא",
|
|
8514
8517
|
"shape.pill": "פס מעוגל אחד שמרחף",
|
|
@@ -8564,14 +8567,6 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8564
8567
|
"phase": "HI6",
|
|
8565
8568
|
"drawnAs": "links"
|
|
8566
8569
|
},
|
|
8567
|
-
"ground.over": {
|
|
8568
|
-
"phase": "HI3",
|
|
8569
|
-
"drawnAs": "solid"
|
|
8570
|
-
},
|
|
8571
|
-
"ground.glass": {
|
|
8572
|
-
"phase": "HI3",
|
|
8573
|
-
"drawnAs": "solid"
|
|
8574
|
-
},
|
|
8575
8570
|
"ground.blend": {
|
|
8576
8571
|
"phase": "HI3",
|
|
8577
8572
|
"drawnAs": "solid"
|
|
@@ -8644,6 +8639,17 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8644
8639
|
"wordsHe": "שם ודפים · כפתור אחד · מגירה בטלפון",
|
|
8645
8640
|
"mix": {}
|
|
8646
8641
|
},
|
|
8642
|
+
{
|
|
8643
|
+
"id": "over-picture",
|
|
8644
|
+
"name": "Over the picture",
|
|
8645
|
+
"nameHe": "מעל התמונה",
|
|
8646
|
+
"words": "Over the opening, then glass · one button",
|
|
8647
|
+
"wordsHe": "מעל הפתיחה, ואז זכוכית · כפתור אחד",
|
|
8648
|
+
"mix": {
|
|
8649
|
+
"ground": "over-glass",
|
|
8650
|
+
"edge": "none"
|
|
8651
|
+
}
|
|
8652
|
+
},
|
|
8647
8653
|
{
|
|
8648
8654
|
"id": "card",
|
|
8649
8655
|
"name": "Card from the button",
|
|
@@ -8742,7 +8748,33 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
8742
8748
|
"pinnedMax": 1,
|
|
8743
8749
|
"inlineRoomPx": 1100,
|
|
8744
8750
|
"betweenNameEm": 7,
|
|
8745
|
-
"betweenMinPages": 2
|
|
8751
|
+
"betweenMinPages": 2,
|
|
8752
|
+
"overFrames": [
|
|
8753
|
+
"full",
|
|
8754
|
+
"shrinks",
|
|
8755
|
+
"grows"
|
|
8756
|
+
],
|
|
8757
|
+
"overMedia": [
|
|
8758
|
+
"photo",
|
|
8759
|
+
"film",
|
|
8760
|
+
"slideshow",
|
|
8761
|
+
"object",
|
|
8762
|
+
"material"
|
|
8763
|
+
],
|
|
8764
|
+
"glassFlavors": [
|
|
8765
|
+
"crisp",
|
|
8766
|
+
"linen",
|
|
8767
|
+
"midnight",
|
|
8768
|
+
"glass",
|
|
8769
|
+
"bloom"
|
|
8770
|
+
],
|
|
8771
|
+
"glassIsOwnBar": [
|
|
8772
|
+
"glass"
|
|
8773
|
+
],
|
|
8774
|
+
"noEdgeGrounds": [
|
|
8775
|
+
"glass",
|
|
8776
|
+
"over-glass"
|
|
8777
|
+
]
|
|
8746
8778
|
},
|
|
8747
8779
|
"references": [
|
|
8748
8780
|
{
|
|
@@ -7,12 +7,14 @@ import {
|
|
|
7
7
|
aspectRatioOf, scoreStockPhoto, STOCK_FAMILY_INTENTS, STOCK_INTENT_ORDER, StockIntent, StockNeed, stockFits, StockPhotoTraits, stockPhotoUsable,
|
|
8
8
|
stockWords,
|
|
9
9
|
} from './stock-match';
|
|
10
|
+
import { isPeopleContentType, StockFit, stockMayFill, stockPhotoFits } from './stock-search';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Stock photos in a built site (AI plan §3g / §3m, I2 + I2.1): a FREE picture from the platform's curated library, copied
|
|
13
14
|
* into the studio's own storage (never hot-linked), placed only in an EMPTY picture slot of a section that may show
|
|
14
15
|
* one — never the owner's work (a collection, a detail page, a gallery: what the nine portfolio types sell is theirs),
|
|
15
|
-
* never a person (testimonials, the team
|
|
16
|
+
* never a person (testimonials, the team — nor a sample item of a type that lists people, iox-ui#172: `stockMayFill`),
|
|
17
|
+
* never anywhere when the business type says `stock: false` — and, since I2.1
|
|
16
18
|
* (Doron, 2026-10-28), in the picture of a MARKED sample item (a product, a service, a dish) of a type that may show
|
|
17
19
|
* stock. Which photo goes where is chosen by what the slot is about (`stock-match.ts`). Its alt text is
|
|
18
20
|
* the provider's description of what it shows (never a claim), and the credit line its licence requires — when it
|
|
@@ -131,6 +133,11 @@ export interface StockItemSlot extends StockNeed {
|
|
|
131
133
|
field: string;
|
|
132
134
|
/** The item's own name, as words (its `title`): an owner's photo stands under it only when it shows that. */
|
|
133
135
|
subject?: string[];
|
|
136
|
+
/**
|
|
137
|
+
* iox-ui#172: the item is a PERSON (its type lists people — `isPeopleContentType`): only the owner's photo of them may
|
|
138
|
+
* stand here, never stock (`stockMayFill`) — a stranger under a team member's name is a made-up fact.
|
|
139
|
+
*/
|
|
140
|
+
person?: boolean;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
export type StockTarget = StockSlot | StockItemSlot;
|
|
@@ -358,10 +365,14 @@ export function stockItemSlots(plan: Pick<SitePlan, 'contentTypes'>, composed: P
|
|
|
358
365
|
for (const type of plan.contentTypes) {
|
|
359
366
|
const field = roleField(type, ContentRole.Image);
|
|
360
367
|
if (!field) continue;
|
|
368
|
+
const person = isPeopleContentType(type);
|
|
361
369
|
(composed.items[type.name] ?? []).forEach((item, index) => {
|
|
362
370
|
if (!item.isSample || parseSampleImageRef(item[field]) === null) return;
|
|
363
371
|
const { subject, words } = itemWords(type, item);
|
|
364
|
-
out.push({
|
|
372
|
+
out.push({
|
|
373
|
+
kind: StockSlotKind.Item, contentType: type.name, index, field, intent: StockIntent.Product, aspect: STOCK_ITEM_ASPECT, words, subject,
|
|
374
|
+
...(person ? { person: true } : {}),
|
|
375
|
+
});
|
|
365
376
|
});
|
|
366
377
|
}
|
|
367
378
|
return out;
|
|
@@ -383,6 +394,11 @@ export interface StockPlanOptions {
|
|
|
383
394
|
seed?: string;
|
|
384
395
|
/** M7: library keys other sites of this studio already show — chosen only when no photo they do not show fits. */
|
|
385
396
|
avoid?: ReadonlyArray<string>;
|
|
397
|
+
/**
|
|
398
|
+
* iox-cms#123: what every photo is held to on this site (`planStockSearch(type, …).fit` / `stockFitFor(type)`): the
|
|
399
|
+
* never-words of every site and of the trade, and an opening's second word of the business. Absent: the never-words only.
|
|
400
|
+
*/
|
|
401
|
+
fit?: StockFit;
|
|
386
402
|
}
|
|
387
403
|
|
|
388
404
|
/** How far below the best score a photo may be and still be the seed's choice (one word of the plan's, about). */
|
|
@@ -419,7 +435,9 @@ const intentRank = (intent: string) => STOCK_INTENT_ORDER.indexOf(intent as Stoc
|
|
|
419
435
|
* type's samples) — a photo no slot has taken yet always before one another page shows. Ties go to the library's
|
|
420
436
|
* order — or, with a `seed` (M7), the site's own pick among those nearly as good, and another site's photos (`avoid`) only
|
|
421
437
|
* when nothing fresh fits. A slot nothing fits keeps its empty box (a sample its abstract picture). None at all when the
|
|
422
|
-
* type says no stock,
|
|
438
|
+
* type says no stock, never a person's place (`stockMayFill`), never a photo the review rejected or flagged, and never
|
|
439
|
+
* one the site's fit refuses (`stockPhotoFits`: crime, ruin, a joke; an opening that does not name the business twice).
|
|
440
|
+
* Returned in the slots' order.
|
|
423
441
|
*/
|
|
424
442
|
export function planStockPhotos<T extends StockTarget>(slots: ReadonlyArray<T>, photos: ReadonlyArray<StockPhoto>, stockAllowed: boolean, opts: StockPlanOptions = {}): Array<StockPlacement<T>> {
|
|
425
443
|
if (!stockAllowed) return [];
|
|
@@ -431,9 +449,10 @@ export function planStockPhotos<T extends StockTarget>(slots: ReadonlyArray<T>,
|
|
|
431
449
|
const shownIn = new Map<string, Set<string>>();
|
|
432
450
|
const placed = new Map<number, StockPlacement<T>>();
|
|
433
451
|
for (const { slot, i } of order) {
|
|
452
|
+
if (!stockMayFill(slot)) continue;
|
|
434
453
|
const group = stockGroupOf(slot);
|
|
435
454
|
const here = shownIn.get(group) ?? new Set<string>();
|
|
436
|
-
const candidates = usable.filter(p => !here.has(p.key) && stockFits(p, slot));
|
|
455
|
+
const candidates = usable.filter(p => !here.has(p.key) && stockFits(p, slot) && stockPhotoFits(p, slot, opts.fit));
|
|
437
456
|
const fresh = candidates.filter(p => !used.has(p.key));
|
|
438
457
|
const best = bestFor(fresh.length ? fresh : candidates, slot, imagery, opts.seed);
|
|
439
458
|
if (!best) continue;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ContentRole, ContentTypePlan } from './site-plan.model';
|
|
2
|
+
import {
|
|
3
|
+
STOCK_INTENT_ORDER, STOCK_INTENT_SUBJECTS, STOCK_SUBJECT_WORDS, StockIntent, StockPhotoTraits, stockPhotoWords, StockReviewVerdict, StockSubject,
|
|
4
|
+
stockWord, stockWords,
|
|
5
|
+
} from './stock-match';
|
|
6
|
+
import type { StockTarget } from './stock-photos';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What a build may ask a stock provider, and what it may take from the answer (AI plan §3g-live; iox-cms#123,
|
|
10
|
+
* iox-ui#172) — ONE pure decision every asker shares (the build's stock step, its live search, the placement rule):
|
|
11
|
+
*
|
|
12
|
+
* - WHICH places may take stock (`stockMayFill`): never a person. A sample item of a content type that stands for people
|
|
13
|
+
* — a team member, a testimonial, an author (`isPeopleContentType`) — keeps the owner's photo or its empty-by-design
|
|
14
|
+
* picture; a stranger, or a street at night, under a person's name is a made-up fact about the business.
|
|
15
|
+
* - WHAT is asked (`stockSearchQuery`): closed English words only (LS-D3) — the business type's own keyword and at most one
|
|
16
|
+
* subject word for the place. Nothing the owner typed (a name, a phone, an address) ever reaches the provider.
|
|
17
|
+
* - WHAT is never taken (`stockPhotoFits`): a photo whose words speak of crime, injury, ruin or a joke (`STOCK_NEVER_WORDS`,
|
|
18
|
+
* `STOCK_NEVER_PHRASES`), or — for a trade people trust with their money, health or rights — of what that trade fears
|
|
19
|
+
* (`STOCK_TRADE_NEVER_WORDS`); and an OPENING (an atmosphere place: a hero, a page header, a call to action) takes an
|
|
20
|
+
* unreviewed photo only when its words name the business twice (`STOCK_OPENING_TYPE_WORDS` of the type's vocabulary):
|
|
21
|
+
* "salon" alone is a drawing room, "salon" + "hair" is a hair salon.
|
|
22
|
+
*
|
|
23
|
+
* The provider side (Pixabay) already asks `image_type=photo` and `safesearch=true` and drops people, brands and generated
|
|
24
|
+
* pictures by their tags; this is what the PLATFORM decides on top, the same for every provider.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** A business type as the stock search reads it (harness-core `BusinessType`'s fields). */
|
|
28
|
+
export interface StockSearchType {
|
|
29
|
+
readonly id?: string;
|
|
30
|
+
readonly label: string;
|
|
31
|
+
/** Its keywords (English + Hebrew) — only the Latin ones are asked. */
|
|
32
|
+
readonly match?: ReadonlyArray<string>;
|
|
33
|
+
/** Its imagery line ("Rooms, textures, hands") — its words count as the type's own. */
|
|
34
|
+
readonly imagery?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** LS-D4: the most searches one build asks — the type's base query first, then the places' own. */
|
|
38
|
+
export const STOCK_MAX_SEARCHES = 4;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Words that never stand on a business's site, whatever it is (compared as `stockWord`s): crime and the law's force,
|
|
42
|
+
* violence and injury, death, ruin and decay ("lost places"), and a picture that is a joke or a drawing rather than a photo.
|
|
43
|
+
*/
|
|
44
|
+
export const STOCK_NEVER_WORDS: ReadonlySet<string> = new Set([
|
|
45
|
+
'police', 'policeman', 'policewoman', 'cop', 'handcuff', 'arrest', 'prison', 'jail', 'prisoner', 'crime', 'criminal', 'fraud',
|
|
46
|
+
'evasion', 'thief', 'theft', 'robbery', 'burglar', 'burglary', 'scam', 'bribe', 'bribery', 'corruption', 'mafia', 'gangster',
|
|
47
|
+
'gun', 'pistol', 'rifle', 'weapon', 'bullet', 'blood', 'bloody', 'injury', 'injured', 'wound', 'accident', 'crash', 'death',
|
|
48
|
+
'corpse', 'skull', 'grave', 'cemetery', 'funeral', 'war', 'soldier', 'bomb', 'explosion', 'terror', 'terrorism', 'drug',
|
|
49
|
+
'cocaine', 'abandoned', 'derelict', 'ruin', 'decay', 'decayed', 'dilapidated', 'demolition', 'rotten', 'trash',
|
|
50
|
+
'garbage', 'rubbish', 'dirty', 'homeless', 'riot', 'caricature', 'cartoon', 'figurine', 'clipart', 'illustration', 'vector',
|
|
51
|
+
'meme', 'joke', 'funny', 'humor', 'humour', 'halloween', 'horror', 'creepy', 'zombie',
|
|
52
|
+
].map(stockWord));
|
|
53
|
+
|
|
54
|
+
/** Phrases that say the same where no one word does ("lost places" — the photography of abandoned buildings). */
|
|
55
|
+
export const STOCK_NEVER_PHRASES: ReadonlyArray<string> = ['lost place', 'lost places', 'tax evasion', 'urban exploration', 'urbex'];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Per business type (harness-core id), what a trade people trust with their rights, money or health never shows on its
|
|
59
|
+
* site: a law firm no debt or bankruptcy, a clinic no sickness, a needle or a hospital. Never a word the trade itself
|
|
60
|
+
* sells by (an accountant's tax, a lawyer's court) — the universal list already keeps the joke about it out.
|
|
61
|
+
*/
|
|
62
|
+
export const STOCK_TRADE_NEVER_WORDS: Readonly<Record<string, ReadonlyArray<string>>> = {
|
|
63
|
+
'law-accounting': ['debt', 'bankruptcy', 'bankrupt', 'guilty', 'crisis', 'stress', 'eviction', 'divorce'],
|
|
64
|
+
consultant: ['debt', 'bankruptcy', 'bankrupt', 'crisis', 'stress'],
|
|
65
|
+
coach: ['crisis', 'stress', 'depression', 'sad', 'lonely'],
|
|
66
|
+
therapist: ['depression', 'sad', 'lonely', 'suicide', 'crying', 'tear', 'anxiety', 'stress'],
|
|
67
|
+
clinic: ['sick', 'sickness', 'illness', 'disease', 'virus', 'covid', 'pain', 'syringe', 'needle', 'injection', 'surgery', 'hospital', 'emergency', 'ambulance', 'patient'],
|
|
68
|
+
dental: ['pain', 'toothache', 'decay', 'cavity', 'syringe', 'needle', 'injection', 'surgery', 'drill', 'blood'],
|
|
69
|
+
vet: ['sick', 'injured', 'pain', 'syringe', 'needle', 'injection', 'surgery', 'stray', 'cage'],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** An opening's unreviewed photo names the business this many times (distinct words of the type's vocabulary). */
|
|
73
|
+
export const STOCK_OPENING_TYPE_WORDS = 2;
|
|
74
|
+
|
|
75
|
+
/** The intents an opening stands as — wide places the visitor reads as "this is the business". */
|
|
76
|
+
const OPENING_INTENTS: ReadonlySet<string> = new Set([StockIntent.Atmosphere]);
|
|
77
|
+
|
|
78
|
+
/** The roles that make a content type a list of people: someone's words, or who said or made it. */
|
|
79
|
+
const PEOPLE_ROLES: ReadonlyArray<`${ContentRole}`> = [ContentRole.Person, ContentRole.Quote];
|
|
80
|
+
/** Words in a type's name or label that say its items are people (English, `stockWord`s; a camelCase name is split). */
|
|
81
|
+
const PEOPLE_TYPE_WORDS: ReadonlySet<string> = new Set([
|
|
82
|
+
'team', 'member', 'staff', 'people', 'person', 'crew', 'employee', 'testimonial', 'review', 'reviewer', 'author', 'founder',
|
|
83
|
+
'speaker', 'instructor', 'trainer', 'teacher', 'tutor', 'coach', 'stylist', 'therapist', 'doctor', 'lawyer', 'attorney', 'chef',
|
|
84
|
+
'artist', 'volunteer', 'patient', 'biography',
|
|
85
|
+
].map(stockWord));
|
|
86
|
+
/** The same in Hebrew, compared whole (a label is the owner's language). */
|
|
87
|
+
const PEOPLE_TYPE_WORDS_HE: ReadonlySet<string> = new Set([
|
|
88
|
+
'צוות', 'הצוות', 'אנשי', 'עובדים', 'העובדים', 'המלצות', 'ממליצים', 'ביקורות', 'לקוחות', 'מטפלים', 'מטפלות', 'מאמנים', 'מאמנות',
|
|
89
|
+
'מורים', 'מורות', 'מדריכים', 'מדריכות', 'מייסדים', 'מייסדות', 'שפים', 'רופאים', 'עורכי', 'מעצבים', 'מעצבות', 'אמנים',
|
|
90
|
+
]);
|
|
91
|
+
/** Field names only a person has (a bio, a job title, a headshot). */
|
|
92
|
+
const PEOPLE_FIELD_WORDS: ReadonlySet<string> = new Set(['bio', 'biography', 'position', 'jobtitle', 'headshot', 'portrait', 'avatar', 'testimonial', 'quote', 'pronoun']);
|
|
93
|
+
|
|
94
|
+
const CAMEL = /([a-z0-9])([A-Z])/g;
|
|
95
|
+
const LATIN_KEYWORD = /^[a-z]+( [a-z]+)?$/;
|
|
96
|
+
const DIACRITICS = /\p{M}+/gu;
|
|
97
|
+
|
|
98
|
+
/** A word as a query carries it: lower case, accents gone (`café` → `cafe`). */
|
|
99
|
+
const plain = (text: string) => text.normalize('NFD').replace(DIACRITICS, '').toLowerCase().trim();
|
|
100
|
+
/** A code name's words: `teamMember` → `team member`, `gallery-photo` → `gallery photo`. */
|
|
101
|
+
const nameWords = (name: unknown) => (typeof name === 'string' ? name.replace(CAMEL, '$1 $2').replace(/[-_]+/g, ' ') : '');
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A content type whose items are people (iox-ui#172): it has a person's part (`person` or `quote` role — a testimonial,
|
|
105
|
+
* a byline), or its name, label or fields say so (`teamMember`, "Our team", "הצוות", a `bio` or a `position` field).
|
|
106
|
+
*/
|
|
107
|
+
export function isPeopleContentType(type: Pick<ContentTypePlan, 'name' | 'label' | 'roles' | 'fields'> | null | undefined): boolean {
|
|
108
|
+
if (!type) return false;
|
|
109
|
+
const roles = (type.roles ?? {}) as Readonly<Record<string, string>>;
|
|
110
|
+
if (PEOPLE_ROLES.some(role => !!roles[role])) return true;
|
|
111
|
+
const words = stockWords(nameWords(type.name), type.label);
|
|
112
|
+
if (words.some(w => PEOPLE_TYPE_WORDS.has(w))) return true;
|
|
113
|
+
const raw = String(type.label ?? '').split(/\s+/).map(w => w.replace(/[^\p{L}]/gu, ''));
|
|
114
|
+
if (raw.some(w => PEOPLE_TYPE_WORDS_HE.has(w))) return true;
|
|
115
|
+
return (type.fields ?? []).some(f => PEOPLE_FIELD_WORDS.has(String(f?.name ?? '').toLowerCase()));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A place stock may fill: anything but a person (`StockItemSlot.person`, set by `stockItemSlots`). */
|
|
119
|
+
export function stockMayFill(target: StockTarget): boolean {
|
|
120
|
+
return !(target.kind === 'item' && target.person);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The type's search word: the first of its own keywords that its English label names — `spa` for "Spa and massage",
|
|
125
|
+
* `gym` for "Trainer, gym or dance", `consultant` (never the stem `consult`) — else its first Latin keyword, else none.
|
|
126
|
+
*/
|
|
127
|
+
export function stockSearchTerm(type: Pick<StockSearchType, 'label' | 'match'>): string | null {
|
|
128
|
+
const latin = (type.match ?? []).map(plain).filter(k => LATIN_KEYWORD.test(k));
|
|
129
|
+
const label = ` ${plain(type.label).replace(/[^a-z]+/g, ' ')} `;
|
|
130
|
+
return latin.find(k => label.includes(` ${k} `)) ?? latin[0] ?? null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Per subject, its vocabulary as compared (`stockWord`) → as asked (the vocabulary's own spelling). */
|
|
134
|
+
const SUBJECT_VOCABULARY: ReadonlyMap<StockSubject, ReadonlyMap<string, string>> = new Map(
|
|
135
|
+
(Object.values(StockSubject) as StockSubject[]).map(subject => [subject, new Map(STOCK_SUBJECT_WORDS[subject].map(w => [stockWord(w), w]))]),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The one subject word a place adds to its query: among the words that say what it is about — a sample item's own name
|
|
140
|
+
* first, then the words around the place, then the type's imagery line — the first that names a subject its intent takes,
|
|
141
|
+
* its best subject first. None: the base query.
|
|
142
|
+
*/
|
|
143
|
+
export function stockSearchFocus(slot: StockTarget, type: Pick<StockSearchType, 'imagery'>, term: string): string | null {
|
|
144
|
+
const words = [...(slot.kind === 'item' ? slot.subject ?? [] : []), ...slot.words, ...stockWords(type.imagery)];
|
|
145
|
+
const asked = new Set(term.split(' ').map(stockWord));
|
|
146
|
+
for (const subject of STOCK_INTENT_SUBJECTS[slot.intent as StockIntent] ?? []) {
|
|
147
|
+
const vocabulary = SUBJECT_VOCABULARY.get(subject)!;
|
|
148
|
+
const hit = words.find(w => vocabulary.has(w) && !asked.has(w));
|
|
149
|
+
if (hit) return vocabulary.get(hit)!;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** A place's query: the type's word and its focus word, or the type's word alone; none without a type word. */
|
|
155
|
+
export function stockSearchQuery(slot: StockTarget, type: StockSearchType): string | null {
|
|
156
|
+
const term = stockSearchTerm(type);
|
|
157
|
+
if (!term) return null;
|
|
158
|
+
const focus = stockSearchFocus(slot, type, term);
|
|
159
|
+
return focus ? `${term} ${focus}` : term;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** What a photo is held to for one business type (`stockFitFor`). */
|
|
163
|
+
export interface StockFit {
|
|
164
|
+
/** Words (as `stockWord`s) no photo may carry: the universal list and the trade's own. */
|
|
165
|
+
readonly never: ReadonlySet<string>;
|
|
166
|
+
/** The type's own words (label, Latin keywords, imagery) — an opening's photo names it `STOCK_OPENING_TYPE_WORDS` times. */
|
|
167
|
+
readonly vocabulary: ReadonlySet<string>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The universal fit — no type known: only the never-words. */
|
|
171
|
+
export const STOCK_FIT_ANY: StockFit = { never: STOCK_NEVER_WORDS, vocabulary: new Set() };
|
|
172
|
+
|
|
173
|
+
/** What a photo is held to on a site of `type`. */
|
|
174
|
+
export function stockFitFor(type: StockSearchType | null | undefined): StockFit {
|
|
175
|
+
if (!type) return STOCK_FIT_ANY;
|
|
176
|
+
const trade = (type.id ? STOCK_TRADE_NEVER_WORDS[type.id] : undefined) ?? [];
|
|
177
|
+
const latin = (type.match ?? []).map(plain).filter(k => LATIN_KEYWORD.test(k));
|
|
178
|
+
return {
|
|
179
|
+
never: new Set([...STOCK_NEVER_WORDS, ...trade.map(stockWord)]),
|
|
180
|
+
vocabulary: new Set(stockWords(type.label, ...latin, type.imagery)),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A photo's tags (else its alt, split at commas) and the reviewer's notes, each as plain words between spaces. */
|
|
185
|
+
function photoPhrases(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>): string[] {
|
|
186
|
+
const tags = photo.tags?.length ? photo.tags : String(photo.alt ?? '').split(',');
|
|
187
|
+
return [...tags, photo.review?.notes ?? ''].map(t => ` ${plain(String(t ?? '')).replace(/[^\p{L}\p{N}]+/gu, ' ').trim()} `);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Whether a photo may stand in a place on a site held to `fit`: none of its words is a never-word or phrase, and — in an
|
|
192
|
+
* opening — a photo no operator approved names the business at least `STOCK_OPENING_TYPE_WORDS` times. An approved library
|
|
193
|
+
* photo was seen for its type and needs no second word.
|
|
194
|
+
*/
|
|
195
|
+
export function stockPhotoFits(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>, slot: { readonly intent: string }, fit: StockFit = STOCK_FIT_ANY): boolean {
|
|
196
|
+
const words = stockPhotoWords(photo);
|
|
197
|
+
if (words.some(w => fit.never.has(w))) return false;
|
|
198
|
+
const phrases = photoPhrases(photo);
|
|
199
|
+
if (STOCK_NEVER_PHRASES.some(phrase => phrases.some(p => p.includes(` ${phrase} `)))) return false;
|
|
200
|
+
if (!OPENING_INTENTS.has(slot.intent) || photo.review?.verdict === StockReviewVerdict.Approved || !fit.vocabulary.size) return true;
|
|
201
|
+
return words.filter(w => fit.vocabulary.has(w)).length >= STOCK_OPENING_TYPE_WORDS;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const intentRank = (intent: string) => STOCK_INTENT_ORDER.indexOf(intent as StockIntent);
|
|
205
|
+
|
|
206
|
+
/** What a build asks a provider for its open places, and holds the answer to. */
|
|
207
|
+
export interface StockSearch<T extends StockTarget = StockTarget> {
|
|
208
|
+
/** The places stock may fill (`stockMayFill`), in the given order. */
|
|
209
|
+
readonly slots: T[];
|
|
210
|
+
/** The searches, base query first, each once, at most `max`. */
|
|
211
|
+
readonly queries: string[];
|
|
212
|
+
/** What every photo is held to (`stockPhotoFits`) — hand it to `planStockPhotos` as `fit`. */
|
|
213
|
+
readonly fit: StockFit;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* THE decision before any stock search (LS-D3/LS-D4, iox-cms#123, iox-ui#172): of the open places, those stock may fill
|
|
218
|
+
* (never a person); the searches for them — the type's base query first (every place may take its hits), then each
|
|
219
|
+
* place's own in the planner's order (the hero first, list items last), places that share one sharing the search, at most
|
|
220
|
+
* `max`; and the fit every hit is held to. No type word: no search.
|
|
221
|
+
*/
|
|
222
|
+
export function planStockSearch<T extends StockTarget>(type: StockSearchType, targets: ReadonlyArray<T>, max = STOCK_MAX_SEARCHES): StockSearch<T> {
|
|
223
|
+
const slots = targets.filter(stockMayFill);
|
|
224
|
+
const fit = stockFitFor(type);
|
|
225
|
+
const term = stockSearchTerm(type);
|
|
226
|
+
if (!term || max < 1 || !slots.length) return { slots, queries: [], fit };
|
|
227
|
+
const queries = [term];
|
|
228
|
+
const ordered = slots.map((slot, i) => ({ slot, i })).sort((a, b) => intentRank(a.slot.intent) - intentRank(b.slot.intent) || a.i - b.i);
|
|
229
|
+
for (const { slot } of ordered) {
|
|
230
|
+
if (queries.length >= max) break;
|
|
231
|
+
const query = stockSearchQuery(slot, type)!;
|
|
232
|
+
if (!queries.includes(query)) queries.push(query);
|
|
233
|
+
}
|
|
234
|
+
return { slots, queries, fit };
|
|
235
|
+
}
|
|
@@ -136,6 +136,15 @@ export interface BusinessTypeFooter {
|
|
|
136
136
|
readonly sayHe: ReadonlyArray<string>;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/** HI3-D12 (header-ingredients-plan §8): what a type's header never stands on (contract harness `businessTypes[].header`,
|
|
140
|
+
* from harness.mjs HEADER_NEVER) — handed to generation-core `composeSite` as `headerNever`, where `checkHeader` mends it
|
|
141
|
+
* to its own ground (`type-never`). Shaped as generation-core `HeaderNever`. */
|
|
142
|
+
export interface BusinessTypeHeader {
|
|
143
|
+
readonly grounds: ReadonlyArray<string>;
|
|
144
|
+
readonly say: ReadonlyArray<string>;
|
|
145
|
+
readonly sayHe: ReadonlyArray<string>;
|
|
146
|
+
}
|
|
147
|
+
|
|
139
148
|
/** Award §0b + §0b.7 (AW-D26, AW-D32): how a type's opening film is suggested, and what it may show (`filmIdeaFor`). */
|
|
140
149
|
export interface BusinessTypeFilm {
|
|
141
150
|
/** offer · ifAsked · never — the default the owner's words move one step. */
|
|
@@ -172,6 +181,8 @@ export interface BusinessType {
|
|
|
172
181
|
readonly column: BusinessTypeColumn;
|
|
173
182
|
/** AW12-D10: what its footer never closes with or stands on — trust and care never a call word, a scene or a film. */
|
|
174
183
|
readonly footer: BusinessTypeFooter;
|
|
184
|
+
/** HI3-D12: what its header never stands on — care and advice never over the opening's picture. */
|
|
185
|
+
readonly header: BusinessTypeHeader;
|
|
175
186
|
/** Award §0b + §0b.7 (AW-D26…D32): how a film is suggested to this type, and what it may show (`filmIdeaFor`). */
|
|
176
187
|
readonly film: BusinessTypeFilm;
|
|
177
188
|
/** Popups PU0 (popups-plan §10, PU-D11/PU-D12): offer · ifAsked · never — how a popup is suggested (`popupSuggestion`). */
|