@vectoriox/iox-ui 5.204.0 → 5.206.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/data-core/index.d.ts +13 -4
- package/design-core/index.d.ts +277 -6
- package/fesm2022/vectoriox-iox-ui-data-core.mjs +23 -4
- package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +3065 -2673
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1313 -197
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +71 -19
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +32 -4
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +145 -82
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +462 -41
- package/harness-core/index.d.ts +52 -12
- package/index.d.ts +44 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +16 -2
- package/src/data-core/placeholder-rows.ts +24 -3
- package/src/design-core/colour-eval.ts +22 -0
- package/src/design-core/contrast-audit.ts +96 -2
- package/src/design-core/design-token.model.ts +2 -0
- package/src/design-core/flavor-spec.generated.ts +184 -0
- package/src/design-core/font-metrics.ts +14 -1
- package/src/design-core/font-vertical.ts +80 -0
- package/src/design-core/node-links.ts +12 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/design-core/style-presets.ts +20 -1
- package/src/design-core/token-css.ts +3 -1
- package/src/generation-core/ai-run.ts +31 -0
- package/src/generation-core/audit-site.ts +5 -3
- package/src/generation-core/compose-free.ts +1 -1
- package/src/generation-core/compose-layout.ts +172 -22
- package/src/generation-core/critic-calibration.ts +30 -10
- package/src/generation-core/critic-numbers.ts +259 -0
- package/src/generation-core/critic-prompt.ts +74 -6
- package/src/generation-core/critic-rubric.generated.ts +7 -7
- package/src/generation-core/critic-sheet.ts +184 -6
- package/src/generation-core/critic.ts +27 -13
- package/src/generation-core/designer-brief.ts +4 -3
- package/src/generation-core/designer-estimate.ts +3 -3
- package/src/generation-core/layout-render-check.ts +35 -2
- package/src/generation-core/nav-shape.ts +67 -8
- package/src/generation-core/opening-mix.ts +61 -17
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/social-links.ts +47 -8
- package/src/generation-core/stock-photos.ts +149 -14
- package/src/generation-core/stock-search.ts +108 -19
- package/src/generation-core/stock-subjects.ts +204 -0
- package/src/harness-core/business-types.ts +3 -0
- package/src/harness-core/harness-spec.generated.ts +54 -15
- package/src/harness-core/intake.ts +18 -5
- package/src/scene-core/scene.ts +34 -3
- package/styles/iox-design.css +41 -2
- package/styles/iox-forms.css +7 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DesignChoices, designTokenRows, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
|
|
1
|
+
import { DesignChoices, designTokenRows, elementStyleDropCss, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
|
|
3
3
|
import { LAYOUT_INSET } from './layout-column';
|
|
4
4
|
import { GenerationTier } from './site-plan.model';
|
|
@@ -561,7 +561,9 @@ const MIN_PHONE_DISPLAY_PX = 36;
|
|
|
561
561
|
const LAPTOP_SIDE_PX = 32;
|
|
562
562
|
const PHONE_SIDE_PX = 24;
|
|
563
563
|
|
|
564
|
-
|
|
564
|
+
/** The element style the opening's display line wears (`title`'s). */
|
|
565
|
+
const EDGE_STYLE = 'display';
|
|
566
|
+
const faceOf = (ctx: OpeningContext) => elementStyleFace(ctx.design ?? resolveDesignChoices({}), EDGE_STYLE);
|
|
565
567
|
const nameWords = (name: string): string[] => name.trim().split(/\s+/).filter(Boolean);
|
|
566
568
|
|
|
567
569
|
/** How wide the name stands, in em of the display face: the whole line, and its longest word. */
|
|
@@ -574,6 +576,23 @@ function nameEm(ctx: OpeningContext): { line: number; longest: number } {
|
|
|
574
576
|
};
|
|
575
577
|
}
|
|
576
578
|
|
|
579
|
+
/** How many lines the name wraps into at `size` px across `room` px — word by word on the display face's own widths, as a
|
|
580
|
+
* browser breaks it (`text-wrap: balance` evens the lines, never adds one). */
|
|
581
|
+
function wordWrapper(ctx: OpeningContext): (size: number, room: number) => number {
|
|
582
|
+
const face = faceOf(ctx);
|
|
583
|
+
const widths = nameWords(ctx.name).map(w => textWidthEm(w, face));
|
|
584
|
+
const space = textWidthEm(' ', face);
|
|
585
|
+
return (size, room) => {
|
|
586
|
+
let lines = 1;
|
|
587
|
+
let run = 0;
|
|
588
|
+
for (const w of widths) {
|
|
589
|
+
const next = run ? run + (space + w) * size : w * size;
|
|
590
|
+
if (run && next > room) { lines++; run = w * size; } else run = next;
|
|
591
|
+
}
|
|
592
|
+
return lines;
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
|
|
577
596
|
/** A display-size name fits: one line across a laptop at a size that reads, and every word across a phone (R-H6). */
|
|
578
597
|
function nameFits(ctx: OpeningContext, oneLine: boolean): boolean {
|
|
579
598
|
const { line, longest } = nameEm(ctx);
|
|
@@ -618,15 +637,17 @@ export function openingDisplaySize(ctx: OpeningContext, panel: boolean): Opening
|
|
|
618
637
|
if (!token) return null;
|
|
619
638
|
const [tokenPhone, tokenLaptop] = [Number(token[1]), Number(token[2])];
|
|
620
639
|
const pad = panel ? Number(PX.exec(rows.get('space-pad') ?? '')?.[1] ?? PANEL_PAD_PX) : 0;
|
|
621
|
-
|
|
622
|
-
|
|
640
|
+
const leading = Number(rows.get('leading-display')) > 0 ? Number(rows.get('leading-display')) : 1;
|
|
641
|
+
const wrap = wordWrapper(ctx);
|
|
642
|
+
/** The largest size that keeps the words within `lines` lines of `room` AS THEY WRAP (word by word, on the face's own
|
|
643
|
+
* widths — pro-law: a filled-to-82% guess said three lines where its words broke into four and pushed the button
|
|
644
|
+
* under the first screen), their longest word on one, the lines' height within `screen` px — never above the cap. */
|
|
623
645
|
const fitted = (room: number, lines: number, screen: number): number => {
|
|
624
|
-
let size = 0;
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
size = Math.max(size, Math.min(R.capBody * body, across, (room * FIT) / longest, screen / n));
|
|
646
|
+
for (let size = Math.floor(Math.min(R.capBody * body, (room * FIT) / longest)); size > 0; size--) {
|
|
647
|
+
const n = wrap(size, room * FIT);
|
|
648
|
+
if (n <= lines && n * size * leading <= screen) return size;
|
|
628
649
|
}
|
|
629
|
-
return
|
|
650
|
+
return 0;
|
|
630
651
|
};
|
|
631
652
|
const laptop = fitted(Math.min(R.roomPx, LAPTOP_PX - 2 * LAPTOP_SIDE_PX) - 2 * pad, R.lines, R.screenShare * LAPTOP_SCREEN_H);
|
|
632
653
|
const phone = Math.min(laptop, fitted(PHONE_PX - 2 * PHONE_FRAME_PX - 2 * pad, R.phoneLines, R.phoneScreenShare * PHONE_SCREEN_H));
|
|
@@ -723,6 +744,9 @@ const TYPE_LED_HEIGHT = 'min(64svh, 600px)';
|
|
|
723
744
|
const typeLedHeights = (mix: OpeningMix): { laptop: string; phone?: string } =>
|
|
724
745
|
mix.words === OpeningWords.Apart ? { laptop: OPENING_HEIGHT } : { laptop: TYPE_LED_HEIGHT, phone: '0px' };
|
|
725
746
|
const INSET_LAPTOP = '24px';
|
|
747
|
+
/** iox-ui#196: the cue stands at the end inset (`inset-inline-end: 4%`, iox-design.css) and keeps the same inset on its
|
|
748
|
+
* start side — every word inside the screen, at 1440 and 390, in both directions. */
|
|
749
|
+
export const OPENING_CUE_MAX_WIDTH = '92%';
|
|
726
750
|
const ABS_FILL: Readonly<Record<string, string>> = { position: 'absolute', top: '0px', left: '0px', width: '100%', height: '100%', zIndex: '0' };
|
|
727
751
|
const MEDIA_FILL: Readonly<Record<string, string>> = { ...ABS_FILL, aspectRatio: 'auto', borderRadius: '0px', objectFit: 'cover' };
|
|
728
752
|
const OVER = (z: number): Readonly<Record<string, string>> => ({ position: 'relative', zIndex: String(z) });
|
|
@@ -754,15 +778,33 @@ const phoneFramePad = (mix: OpeningMix): string =>
|
|
|
754
778
|
const sizedPx = (em: number, side: number | string, cap: string): string =>
|
|
755
779
|
`min(calc((100vw - ${typeof side === 'number' ? `${2 * side}px` : `2 * ${side}`}) * ${FIT} / ${Math.max(em, 1).toFixed(3)}), ${cap})`;
|
|
756
780
|
|
|
781
|
+
/** The name on the edge is set tight on a laptop; a phone's line leaves room should a face still break it. */
|
|
782
|
+
const EDGE_LINE_HEIGHT = 0.82;
|
|
783
|
+
const EDGE_PHONE_LINE_HEIGHT = 0.9;
|
|
784
|
+
|
|
757
785
|
/**
|
|
758
786
|
* The name standing on the bottom edge (`words:on-edge`): ONE display line on a laptop AND on a phone (iox-ui#150) — a
|
|
759
787
|
* phone sizes it by the whole name across the room beside it (`phoneSide`), never by its longest word: sized by a word,
|
|
760
|
-
* a long name wrapped to four lines at 80 px, its lines touching, and pushed the page a screen down.
|
|
761
|
-
*
|
|
788
|
+
* a long name wrapped to four lines at 80 px, its lines touching, and pushed the page a screen down.
|
|
789
|
+
* iox-ui#206: the frame crops the name at its BASELINE — the line drops by the display face's own amount at each line
|
|
790
|
+
* height (design-core `baselineDropEm`), so its descenders go under the edge and its letters stand whole on it. A fixed
|
|
791
|
+
* 0.16em put Fraunces' baseline 0.11em under the edge: the store's capitals were cut through.
|
|
792
|
+
* iox-ui#215: the drop is CSS that reads the display family's derived metric tokens (design-core `elementStyleDropCss`),
|
|
793
|
+
* so a font changed in Design moves the line with it, in the builder and on the live site; it falls back to the face
|
|
794
|
+
* composed with.
|
|
762
795
|
*/
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
796
|
+
function edgeTitle(line: number, phoneSide: number | string, ctx: OpeningContext): PatternNode {
|
|
797
|
+
const design = ctx.design ?? resolveDesignChoices({});
|
|
798
|
+
return title({
|
|
799
|
+
fontSize: sizedPx(line, LAPTOP_SIDE_PX, '50svh'), lineHeight: String(EDGE_LINE_HEIGHT), margin: '0px',
|
|
800
|
+
translateY: elementStyleDropCss(design, EDGE_STYLE, EDGE_LINE_HEIGHT),
|
|
801
|
+
}, {
|
|
802
|
+
resp: { mobile: {
|
|
803
|
+
fontSize: sizedPx(line, phoneSide, '22vw'), lineHeight: String(EDGE_PHONE_LINE_HEIGHT),
|
|
804
|
+
translateY: elementStyleDropCss(design, EDGE_STYLE, EDGE_PHONE_LINE_HEIGHT),
|
|
805
|
+
} },
|
|
806
|
+
});
|
|
807
|
+
}
|
|
766
808
|
|
|
767
809
|
function frameNode(mix: OpeningMix, children: PatternNode[]): PatternNode {
|
|
768
810
|
const inset = mix.frame === OpeningFrame.Inset || mix.frame === OpeningFrame.Shrinks;
|
|
@@ -908,7 +950,7 @@ function typeLedWordsNodes(mix: OpeningMix, ctx: OpeningContext): PatternNode[]
|
|
|
908
950
|
lay: { position: 'absolute', left: '0px', bottom: '0px', width: '100%', zIndex: '1', padding: `0px ${LAPTOP_SIDE_PX}px`, overflow: 'visible' },
|
|
909
951
|
resp: { mobile: { position: 'relative', left: 'auto', bottom: 'auto', padding: '0px', margin: `auto 0px calc(-1 * ${phoneFramePad(mix)}) 0px` } },
|
|
910
952
|
// The words sit inside the frame's own padding on a phone: the line is sized across what it leaves.
|
|
911
|
-
c: [edgeTitle(line, `max(${phoneFramePad(mix)}, ${LAYOUT_INSET})
|
|
953
|
+
c: [edgeTitle(line, `max(${phoneFramePad(mix)}, ${LAYOUT_INSET})`, ctx)],
|
|
912
954
|
}];
|
|
913
955
|
case OpeningWords.Wordmark:
|
|
914
956
|
case OpeningWords.Behind:
|
|
@@ -948,7 +990,7 @@ function wordsNodes(mix: OpeningMix, ctx: OpeningContext): PatternNode[] {
|
|
|
948
990
|
t: 'Container', es: 'box', role: OpeningRole.Words,
|
|
949
991
|
lay: { position: 'absolute', left: '0px', bottom: '0px', width: '100%', zIndex: '1', padding: `0px ${LAPTOP_SIDE_PX}px`, overflow: 'visible' },
|
|
950
992
|
resp: { mobile: { padding: `0px ${PHONE_SIDE_PX}px` } },
|
|
951
|
-
c: [edgeTitle(line, PHONE_SIDE_PX)],
|
|
993
|
+
c: [edgeTitle(line, PHONE_SIDE_PX, ctx)],
|
|
952
994
|
}];
|
|
953
995
|
case OpeningWords.Wordmark:
|
|
954
996
|
case OpeningWords.Behind:
|
|
@@ -1020,7 +1062,9 @@ function extrasNodes(mix: OpeningMix): PatternNode[] {
|
|
|
1020
1062
|
});
|
|
1021
1063
|
}
|
|
1022
1064
|
if (mix.extras.includes(OpeningExtra.Cue)) {
|
|
1023
|
-
|
|
1065
|
+
// iox-ui#196: as wide as its words (a Text is 100% by default — at the end inset it started 4% off the screen), and
|
|
1066
|
+
// never wider than the room between the two insets (the shared CSS holds that for a cue saved before).
|
|
1067
|
+
out.push({ t: 'Text', es: 'eyebrow', role: OpeningRole.Cue, text: 'Scroll', textHe: 'גללו', lay: { position: 'absolute', bottom: '20px', zIndex: '2', margin: '0px', width: 'auto', maxWidth: OPENING_CUE_MAX_WIDTH } });
|
|
1024
1068
|
}
|
|
1025
1069
|
return out;
|
|
1026
1070
|
}
|
|
@@ -54,6 +54,7 @@ export * from './audit-words';
|
|
|
54
54
|
export * from './stock-match';
|
|
55
55
|
export * from './stock-photos';
|
|
56
56
|
export * from './stock-search';
|
|
57
|
+
export * from './stock-subjects';
|
|
57
58
|
export * from './film';
|
|
58
59
|
export * from './art-direction';
|
|
59
60
|
export * from './pictures';
|
|
@@ -114,6 +115,7 @@ export * from './design-ops-of';
|
|
|
114
115
|
export * from './critic-rubric.generated';
|
|
115
116
|
export * from './critic';
|
|
116
117
|
export * from './critic-sheet';
|
|
118
|
+
export * from './critic-numbers';
|
|
117
119
|
export * from './critic-prompt';
|
|
118
120
|
export * from './critic-calibration';
|
|
119
121
|
export * from './structure-fingerprint';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LinkType } from '@vectoriox/iox-ui/design-core';
|
|
2
|
-
import { channelHref, ChannelKind } from '@vectoriox/iox-ui/forms-core';
|
|
2
|
+
import { channelHref, ChannelKind, FORM_CHANNEL_ROLE, parseChannelHref } from '@vectoriox/iox-ui/forms-core';
|
|
3
3
|
|
|
4
4
|
import { FOOTER_SOCIAL_NETWORKS, FooterRole, footerSocialLinks, FooterSocialLink, recognisedSocialLinks, socialLinkOf, socialLinksPart } from './footer-mix';
|
|
5
5
|
import { PatternNode } from './patterns';
|
|
@@ -18,8 +18,9 @@ import { FACT_KEYS } from './site-plan.model';
|
|
|
18
18
|
* - `SITE_SOCIAL_FIELDS`, `siteSocialLinks`, `siteSocialPatch` — the Site settings record's fields, read and written;
|
|
19
19
|
* - `statedWhatsAppHref` — a stated WhatsApp link as the contact form's WhatsApp channel (forms-core `channelHref`);
|
|
20
20
|
* - `withFollowRow` — a contact section with the footer's social part ("Follow" and the links) beside its contact facts;
|
|
21
|
-
* - `followSiteSocials` — every follow row a saved layout holds, drawn from Site settings ▸ Socials AT RENDER (iox-ui#201)
|
|
22
|
-
* the engine and the builder both apply it, so a link changed in
|
|
21
|
+
* - `followSiteSocials` — every follow row a saved layout holds, drawn from Site settings ▸ Socials AT RENDER (iox-ui#201),
|
|
22
|
+
* and every form's WhatsApp channel with them (iox-ui#205): the engine and the builder both apply it, so a link changed in
|
|
23
|
+
* Site settings reaches every site, old builds included.
|
|
23
24
|
*
|
|
24
25
|
* Pure and framework-free (iox-cms imports it).
|
|
25
26
|
*/
|
|
@@ -198,6 +199,13 @@ export function withFollowRow(node: PatternNode, social: ReadonlyArray<string> |
|
|
|
198
199
|
* the links will show and the template survives the next save.
|
|
199
200
|
* - Site settings unread (`null` — the read failed or the studio has no record yet): the layout as saved.
|
|
200
201
|
*
|
|
202
|
+
* A form's WhatsApp channel (iox-ui#205) is the same fact in another place: the "Message us on WhatsApp" button beside a
|
|
203
|
+
* form (role `form.channel`) whose address is a WhatsApp chat. Its number is Site settings' WhatsApp, read when the page is
|
|
204
|
+
* drawn — a changed number reaches it as it reaches the follow row. Site settings without a WhatsApp: on the LIVE site the
|
|
205
|
+
* button goes (a chat with a number the studio dropped is worse than none — the submit stays); in the BUILDER it stays as
|
|
206
|
+
* saved. Its words, look and the rest of the form are the owner's and are never touched. A channel the owner pointed
|
|
207
|
+
* elsewhere (a call, an email, a link) is not a WhatsApp channel and is never touched either.
|
|
208
|
+
*
|
|
201
209
|
* Pure: a new tree where something changed, the same node objects where nothing did; ids of the copies are derived from the
|
|
202
210
|
* template's (`<template>-<network>`), so a builder save and the next render agree.
|
|
203
211
|
*/
|
|
@@ -239,9 +247,23 @@ const PH_WEIGHT = /^ph(-(thin|light|regular|bold|fill|duotone))?$/;
|
|
|
239
247
|
/** The suffix a copy's id carries — stripped to find the template's own id on the next pass. */
|
|
240
248
|
const NETWORK_SUFFIX = new RegExp(`-(${FOOTER_SOCIAL_NETWORKS.map(n => n.id).join('|')})$`);
|
|
241
249
|
|
|
242
|
-
/**
|
|
250
|
+
/** Where a channel (a ButtonBlock that links) writes its address. */
|
|
251
|
+
const CHANNEL_URL_SLOT = 'href';
|
|
252
|
+
|
|
253
|
+
/** A form's WhatsApp channel (iox-ui#205): role `form.channel`, its address a WhatsApp chat (forms-core `parseChannelHref`). */
|
|
254
|
+
function isWhatsAppChannel(n: FollowRowNode | null | undefined): boolean {
|
|
255
|
+
if (n?.role !== FORM_CHANNEL_ROLE) return false;
|
|
256
|
+
const { kind, value } = parseChannelHref(n.props?.[CHANNEL_URL_SLOT]);
|
|
257
|
+
return kind === ChannelKind.WhatsApp && !!value;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** A node Site settings ▸ Socials draws: a follow row, or a form's WhatsApp channel. */
|
|
261
|
+
const isFollowed = (n: FollowRowNode): boolean => isFollowRow(n) || isWhatsAppChannel(n);
|
|
262
|
+
|
|
263
|
+
/** True when the tree holds a follow row (a stamped follow link) or a form's WhatsApp channel — a renderer reads Site
|
|
264
|
+
* settings only then. */
|
|
243
265
|
export function holdsFollowRow(nodes: ReadonlyArray<FollowRowNode> | null | undefined): boolean {
|
|
244
|
-
return (nodes ?? []).some(n => n?.role === FOLLOW_LINK_ROLE || holdsFollowRow(n?.children));
|
|
266
|
+
return (nodes ?? []).some(n => n?.role === FOLLOW_LINK_ROLE || isWhatsAppChannel(n) || holdsFollowRow(n?.children));
|
|
245
267
|
}
|
|
246
268
|
|
|
247
269
|
/** Every follow row of `roots` drawn from Site settings' links (`siteSocialLinks` of the record) — see above. Pure. */
|
|
@@ -252,7 +274,12 @@ export function followSiteSocials<T extends FollowRowNode>(
|
|
|
252
274
|
): T[] {
|
|
253
275
|
if (site == null || !holdsFollowRow(roots)) return roots as T[];
|
|
254
276
|
const links = footerSocialLinks(site).links;
|
|
277
|
+
const whatsApp = statedWhatsAppHref(site);
|
|
255
278
|
return splice(roots as ReadonlyArray<FollowRowNode>, n => {
|
|
279
|
+
if (isWhatsAppChannel(n)) {
|
|
280
|
+
const channel = followChannel(n, whatsApp, view);
|
|
281
|
+
return channel ? [channel] : [];
|
|
282
|
+
}
|
|
256
283
|
if (!isFollowRow(n)) return undefined;
|
|
257
284
|
const row = followRow(n, links, view);
|
|
258
285
|
return row ? [row] : [];
|
|
@@ -290,10 +317,10 @@ const holdsLink = (n: FollowRowNode): boolean => (n.children ?? []).some(k => k.
|
|
|
290
317
|
/** A row: the `footer.social` block, or (a one-line footer) the bare box its stamped links sit in. */
|
|
291
318
|
const isFollowRow = (n: FollowRowNode): boolean => n.role === FOLLOW_ROW_ROLE || (n.children ?? []).some(k => k.role === FOLLOW_LINK_ROLE);
|
|
292
319
|
|
|
293
|
-
/** Every follow row
|
|
320
|
+
/** Every node Site settings draws (a follow row, a WhatsApp channel) by its id — the outermost, never looked inside. */
|
|
294
321
|
function followRowsById(nodes: ReadonlyArray<FollowRowNode>, out = new Map<string, FollowRowNode>()): Map<string, FollowRowNode> {
|
|
295
322
|
for (const n of nodes) {
|
|
296
|
-
if (
|
|
323
|
+
if (isFollowed(n)) out.set(n.id, n);
|
|
297
324
|
else if (n.children) followRowsById(n.children, out);
|
|
298
325
|
}
|
|
299
326
|
return out;
|
|
@@ -317,7 +344,7 @@ export function keepSavedFollowRows<T extends FollowRowNode>(
|
|
|
317
344
|
if (!storedRows.size) return serialized as T[];
|
|
318
345
|
const drawnRows = followRowsById(drawn);
|
|
319
346
|
return splice(serialized as ReadonlyArray<FollowRowNode>, n => {
|
|
320
|
-
if (!
|
|
347
|
+
if (!isFollowed(n)) return undefined;
|
|
321
348
|
const stored = storedRows.get(n.id);
|
|
322
349
|
const asDrawn = drawnRows.get(n.id);
|
|
323
350
|
return stored && asDrawn && JSON.stringify(n) === JSON.stringify(asDrawn) ? [stored] : [n];
|
|
@@ -334,6 +361,18 @@ function followRow(row: FollowRowNode, links: ReadonlyArray<FooterSocialLink>, v
|
|
|
334
361
|
return links.length || holdsLink(next) ? next : null;
|
|
335
362
|
}
|
|
336
363
|
|
|
364
|
+
/**
|
|
365
|
+
* A form's WhatsApp channel drawn: Site settings' WhatsApp as its address (any `?text=` the owner added kept), the same node
|
|
366
|
+
* when it already is; no WhatsApp in Site settings — gone on the live site, as saved in the builder.
|
|
367
|
+
*/
|
|
368
|
+
function followChannel(channel: FollowRowNode, whatsApp: string, view: FollowRowView): FollowRowNode | null {
|
|
369
|
+
if (!whatsApp) return view === FollowRowView.Edit ? channel : null;
|
|
370
|
+
const current = String(channel.props?.[CHANNEL_URL_SLOT] ?? '').trim();
|
|
371
|
+
const suffix = current.match(/[?#].*$/)?.[0] ?? '';
|
|
372
|
+
const href = `${whatsApp}${suffix}`;
|
|
373
|
+
return href === current ? channel : { ...channel, props: { ...channel.props, [CHANNEL_URL_SLOT]: href } };
|
|
374
|
+
}
|
|
375
|
+
|
|
337
376
|
/** The template drawn for one network: its address (external), its words, its glyph, ids derived. */
|
|
338
377
|
function followLink(template: FollowRowNode, link: FooterSocialLink): FollowRowNode {
|
|
339
378
|
const glyph = FOOTER_SOCIAL_NETWORKS.find(n => n.id === link.network)?.icon;
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
stockWords,
|
|
9
9
|
} from './stock-match';
|
|
10
10
|
import { isPeopleContentType, StockFit, stockMayFill, stockPhotoFits } from './stock-search';
|
|
11
|
+
import { stockNearWords } from './stock-subjects';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Stock photos in a built site (AI plan §3g / §3m, I2 + I2.1): a FREE picture from the platform's curated library, copied
|
|
@@ -16,9 +17,9 @@ import { isPeopleContentType, StockFit, stockMayFill, stockPhotoFits } from './s
|
|
|
16
17
|
* never a person (testimonials, the team — nor a sample item of a type that lists people, iox-ui#172: `stockMayFill`),
|
|
17
18
|
* never anywhere when the business type says `stock: false` — and, since I2.1
|
|
18
19
|
* (Doron, 2026-10-28), in the picture of a MARKED sample item (a product, a service, a dish) of a type that may show
|
|
19
|
-
* stock. Which photo goes where is chosen by what the slot is about (`stock-match.ts`). Its alt text is
|
|
20
|
-
* the
|
|
21
|
-
* requires one — is placed in the footer. Pure: the build step does the copying.
|
|
20
|
+
* stock. Which photo goes where is chosen by what the slot is about (`stock-match.ts`, `stockRelevance`). Its alt text is
|
|
21
|
+
* the place's own words (`stockPhotoAlt`, iox-cms#130 — never the provider's tags), and the credit line its licence
|
|
22
|
+
* requires — when it requires one — is placed in the footer. Pure: the build step does the copying.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
/** Where a stock photo comes from (the library's provider). */
|
|
@@ -85,7 +86,10 @@ export interface StockPhoto extends StockPhotoTraits {
|
|
|
85
86
|
key: string;
|
|
86
87
|
/** Where the operator's run wrote it (kept for older readers; a build resolves `key` against the library's address). */
|
|
87
88
|
url: string;
|
|
88
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* What it shows, in the provider's words, as the library or the search holds it. A PLACED photo (`planStockPhotos`)
|
|
91
|
+
* carries its place's alt instead (`stockPhotoAlt`, iox-cms#130); the provider's words stay on `credit.title`.
|
|
92
|
+
*/
|
|
89
93
|
alt: string;
|
|
90
94
|
credit: StockCredit;
|
|
91
95
|
}
|
|
@@ -121,6 +125,10 @@ export interface StockSlot extends StockNeed {
|
|
|
121
125
|
layout?: string;
|
|
122
126
|
/** What the section says — its plan section's slots, or a laid section's own words — cut to a prompt's length. */
|
|
123
127
|
about?: string;
|
|
128
|
+
/** iox-cms#130: the words of the text beside it (its row), in order — what the picture itself is about (`stockNearWords`). */
|
|
129
|
+
near?: string[];
|
|
130
|
+
/** iox-cms#130: the words beside it as written (the row's heading, else its first text) — the photo's alt (`stockPhotoAlt`). */
|
|
131
|
+
caption?: string;
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
/** The image field of a sample item (a product, a service, a dish) a stock photo may fill. */
|
|
@@ -133,6 +141,10 @@ export interface StockItemSlot extends StockNeed {
|
|
|
133
141
|
field: string;
|
|
134
142
|
/** The item's own name, as words (its `title`): an owner's photo stands under it only when it shows that. */
|
|
135
143
|
subject?: string[];
|
|
144
|
+
/** iox-cms#130: its name's words and (Hebrew) the subjects it names (`stockNearWords`) — the part of the business it shows. */
|
|
145
|
+
near?: string[];
|
|
146
|
+
/** iox-cms#130: its name as written — the photo's alt (`stockPhotoAlt`). */
|
|
147
|
+
caption?: string;
|
|
136
148
|
/**
|
|
137
149
|
* iox-ui#172: the item is a PERSON (its type lists people — `isPeopleContentType`): only the owner's photo of them may
|
|
138
150
|
* stand here, never stock (`stockMayFill`) — a stranger under a team member's name is a made-up fact.
|
|
@@ -183,13 +195,17 @@ function ownPhotosFor(photos: ReadonlyArray<OwnPhoto>, subject: ReadonlyArray<st
|
|
|
183
195
|
* The owner's photos come before any stock or sample picture. A composed section's empty picture takes them in order and
|
|
184
196
|
* never repeats one. A sample item takes only one that shows it (`ownPhotoFit`), never twice in one type's samples; an
|
|
185
197
|
* item none fits keeps its sample picture or goes on to the library (`rest`) — never an unrelated photo under its name.
|
|
198
|
+
*
|
|
199
|
+
* iox-cms#133 (Pro ceramics, 2026-11-29: "Handled Cup" kept the placeholder art between two real photos): a type's samples
|
|
200
|
+
* share its photos by ONE assignment (`matchOwnPhotos`) — the most samples that a photo fits get one, then the best fits —
|
|
201
|
+
* never first come, first served, where an early sample took the only photo a later one could wear.
|
|
186
202
|
*/
|
|
187
203
|
export function planOwnPhotos(slots: ReadonlyArray<StockTarget>, photos: ReadonlyArray<string | OwnPhoto>): { placements: OwnPhotoPlacement[]; rest: StockTarget[] } {
|
|
188
204
|
const own = photos.map(ownPhotoOf).filter(p => !!p.url);
|
|
189
205
|
if (!own.length) return { placements: [], rest: [...slots] };
|
|
190
206
|
const placements: OwnPhotoPlacement[] = [];
|
|
191
207
|
const rest: StockTarget[] = [];
|
|
192
|
-
const
|
|
208
|
+
const matched = matchOwnPhotos(slots.filter((s): s is StockItemSlot => s.kind === StockSlotKind.Item), own);
|
|
193
209
|
let next = 0;
|
|
194
210
|
for (const slot of slots) {
|
|
195
211
|
if (slot.kind === StockSlotKind.Section) {
|
|
@@ -197,19 +213,90 @@ export function planOwnPhotos(slots: ReadonlyArray<StockTarget>, photos: Readonl
|
|
|
197
213
|
else rest.push(slot);
|
|
198
214
|
continue;
|
|
199
215
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
if (!best) {
|
|
216
|
+
const photo = matched.get(slot);
|
|
217
|
+
if (!photo) {
|
|
203
218
|
rest.push(slot);
|
|
204
219
|
continue;
|
|
205
220
|
}
|
|
206
|
-
|
|
207
|
-
shown.set(slot.contentType, group);
|
|
208
|
-
placements.push({ item: { contentType: slot.contentType, index: slot.index, field: slot.field }, url: best.url });
|
|
221
|
+
placements.push({ item: { contentType: slot.contentType, index: slot.index, field: slot.field }, url: photo.url });
|
|
209
222
|
}
|
|
210
223
|
return { placements, rest };
|
|
211
224
|
}
|
|
212
225
|
|
|
226
|
+
/** Per content type (a list shows its samples together, so a photo stands under one of them only): which of the owner's
|
|
227
|
+
* photos each sample wears — the assignment that dresses the most samples, then fits them best (`bestAssignment`). */
|
|
228
|
+
function matchOwnPhotos(slots: ReadonlyArray<StockItemSlot>, own: ReadonlyArray<OwnPhoto>): Map<StockItemSlot, OwnPhoto> {
|
|
229
|
+
const byType = new Map<string, StockItemSlot[]>();
|
|
230
|
+
for (const slot of slots) byType.set(slot.contentType, [...(byType.get(slot.contentType) ?? []), slot]);
|
|
231
|
+
const out = new Map<StockItemSlot, OwnPhoto>();
|
|
232
|
+
for (const group of byType.values()) {
|
|
233
|
+
const fits = group.map(slot => own.map(photo => ownPhotoFit(photo, slot.subject ?? [], slot.words)));
|
|
234
|
+
bestAssignment(fits).forEach((column, row) => { if (column >= 0) out.set(group[row], own[column]); });
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Above any total fit: a sample dressed always outweighs a better fit elsewhere. */
|
|
240
|
+
const ASSIGN_FILLED = 1e6;
|
|
241
|
+
/** Tie-breaks far below a fit point (fits are whole numbers): the earlier sample, then the owner's earlier photo. */
|
|
242
|
+
const ASSIGN_ROW_TIE = 1e-3;
|
|
243
|
+
const ASSIGN_COLUMN_TIE = 1e-6;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Rows (samples) to distinct columns (photos) by their scores (`ownPhotoFit`; 0 = does not fit): the most rows on a column
|
|
247
|
+
* that fits, then the highest total score; a tie goes to the earlier row, then the earlier column. The row's column, or -1.
|
|
248
|
+
* Kuhn–Munkres (the Hungarian method) on a square matrix padded with "takes nothing" columns, O(n²·m) — a type holds a
|
|
249
|
+
* handful of samples and the owner a handful of photos. Exported for its spec.
|
|
250
|
+
*/
|
|
251
|
+
export function bestAssignment(scores: ReadonlyArray<ReadonlyArray<number>>): number[] {
|
|
252
|
+
const n = scores.length;
|
|
253
|
+
if (!n) return [];
|
|
254
|
+
const columns = Math.max(0, ...scores.map(r => r.length));
|
|
255
|
+
const m = columns + n;
|
|
256
|
+
const weight = (i: number, j: number): number => {
|
|
257
|
+
const fit = j < columns ? scores[i][j] ?? 0 : 0;
|
|
258
|
+
return fit > 0 ? ASSIGN_FILLED + fit - ASSIGN_ROW_TIE * i - ASSIGN_COLUMN_TIE * j : 0;
|
|
259
|
+
};
|
|
260
|
+
// Minimum cost = maximum weight; 1-based potentials as in the classic formulation (row 0 / column 0 are the sentinels).
|
|
261
|
+
const u = new Array<number>(n + 1).fill(0);
|
|
262
|
+
const v = new Array<number>(m + 1).fill(0);
|
|
263
|
+
const p = new Array<number>(m + 1).fill(0);
|
|
264
|
+
const way = new Array<number>(m + 1).fill(0);
|
|
265
|
+
for (let i = 1; i <= n; i++) {
|
|
266
|
+
p[0] = i;
|
|
267
|
+
let j0 = 0;
|
|
268
|
+
const minv = new Array<number>(m + 1).fill(Infinity);
|
|
269
|
+
const used = new Array<boolean>(m + 1).fill(false);
|
|
270
|
+
do {
|
|
271
|
+
used[j0] = true;
|
|
272
|
+
const i0 = p[j0];
|
|
273
|
+
let delta = Infinity;
|
|
274
|
+
let j1 = 0;
|
|
275
|
+
for (let j = 1; j <= m; j++) {
|
|
276
|
+
if (used[j]) continue;
|
|
277
|
+
const cur = -weight(i0 - 1, j - 1) - u[i0] - v[j];
|
|
278
|
+
if (cur < minv[j]) { minv[j] = cur; way[j] = j0; }
|
|
279
|
+
if (minv[j] < delta) { delta = minv[j]; j1 = j; }
|
|
280
|
+
}
|
|
281
|
+
for (let j = 0; j <= m; j++) {
|
|
282
|
+
if (used[j]) { u[p[j]] += delta; v[j] -= delta; } else minv[j] -= delta;
|
|
283
|
+
}
|
|
284
|
+
j0 = j1;
|
|
285
|
+
} while (p[j0] !== 0);
|
|
286
|
+
do {
|
|
287
|
+
const j1 = way[j0];
|
|
288
|
+
p[j0] = p[j1];
|
|
289
|
+
j0 = j1;
|
|
290
|
+
} while (j0);
|
|
291
|
+
}
|
|
292
|
+
const out = new Array<number>(n).fill(-1);
|
|
293
|
+
for (let j = 1; j <= columns; j++) {
|
|
294
|
+
const row = p[j] - 1;
|
|
295
|
+
if (row >= 0 && (scores[row][j - 1] ?? 0) > 0) out[row] = j - 1;
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
|
|
213
300
|
/**
|
|
214
301
|
* Each marked sample's gallery shows the owner's photos that fit the item (`ownPhotoFit`) instead of bundled samples; an
|
|
215
302
|
* item none fits keeps its samples.
|
|
@@ -241,12 +328,53 @@ function itemWords(type: SitePlan['contentTypes'][number], item: Record<string,
|
|
|
241
328
|
return { subject: stockWords(title), words: stockWords(type.label, type.name, title, item[roleField(type, ContentRole.Summary) ?? '']) };
|
|
242
329
|
}
|
|
243
330
|
|
|
331
|
+
/** The longest alt a stock photo is given (a screen reader's sentence, not a paragraph). */
|
|
332
|
+
export const STOCK_ALT_MAX = 125;
|
|
333
|
+
|
|
334
|
+
/** Text as an alt carries it: markup gone, one line, cut at a word to `STOCK_ALT_MAX`. */
|
|
335
|
+
function altText(value: unknown): string {
|
|
336
|
+
if (typeof value !== 'string') return '';
|
|
337
|
+
const text = value.replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/\s+/g, ' ').trim();
|
|
338
|
+
if (text.length <= STOCK_ALT_MAX) return text;
|
|
339
|
+
const cut = text.slice(0, STOCK_ALT_MAX + 1);
|
|
340
|
+
const space = cut.lastIndexOf(' ');
|
|
341
|
+
return (space > STOCK_ALT_MAX / 2 ? cut.slice(0, space) : cut.slice(0, STOCK_ALT_MAX)).replace(/[\s,;:–—-]+$/u, '');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** A place's words as written, for its alt: an item's name; a section picture's heading beside it (`caption`). */
|
|
345
|
+
function captionOf(row: SerializedNode | undefined, skip: string): string {
|
|
346
|
+
if (!row) return '';
|
|
347
|
+
let heading = '';
|
|
348
|
+
let text = '';
|
|
349
|
+
walkSerialized([row], n => {
|
|
350
|
+
if (n.id === skip || typeof n.props['content'] !== 'string') return;
|
|
351
|
+
if (n.type === HEADING && !heading) heading = altText(n.props['content']);
|
|
352
|
+
else if (n.type === TEXT && !text) text = altText(n.props['content']);
|
|
353
|
+
});
|
|
354
|
+
return heading || text;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* The alt of a stock photo in a place (iox-cms#130): the place's OWN words, in the site's language — a sample item's name,
|
|
359
|
+
* the heading (else the text) beside a section's picture, else the first thing its section says. Never the provider's tags
|
|
360
|
+
* (a tag list read aloud is noise, and an English one on a Hebrew site). Nothing written there: '' (a picture that only
|
|
361
|
+
* sets the mood, which a screen reader passes).
|
|
362
|
+
*/
|
|
363
|
+
export function stockPhotoAlt(target: Pick<StockSlot, 'caption' | 'about'> | Pick<StockItemSlot, 'caption'>): string {
|
|
364
|
+
const caption = altText(target.caption);
|
|
365
|
+
if (caption) return caption;
|
|
366
|
+
const about = 'about' in target ? target.about ?? '' : '';
|
|
367
|
+
return altText(about.split(' — ')[0].replace(/…$/, ''));
|
|
368
|
+
}
|
|
369
|
+
|
|
244
370
|
/** Where a photo may not appear twice: one page; one content type's samples (a list shows them together). */
|
|
245
371
|
export function stockGroupOf(target: StockTarget): string {
|
|
246
372
|
return target.kind === StockSlotKind.Section ? `page:${target.owner}` : `items:${target.contentType}`;
|
|
247
373
|
}
|
|
248
374
|
|
|
249
375
|
const TEXT_PROPS: ReadonlyArray<string> = ['content', 'label'];
|
|
376
|
+
const HEADING = 'Heading';
|
|
377
|
+
const TEXT = 'Text';
|
|
250
378
|
|
|
251
379
|
/** The words of a subtree's text (Headings, Text, Links), the given node left out. */
|
|
252
380
|
function textOf(nodes: ReadonlyArray<SerializedNode>, skip: string): string[] {
|
|
@@ -332,10 +460,13 @@ export function stockSlots(plan: SitePlan, composed: Pick<ComposedSite, 'pages'
|
|
|
332
460
|
walkSerialized([root], (n, ancestors) => {
|
|
333
461
|
if (n.type !== 'Image' || !empty.has(n.id) || n.bindings.length) return;
|
|
334
462
|
const row = ancestors[ancestors.length - 1];
|
|
463
|
+
const beside = row ? textOf([row], n.id) : [];
|
|
464
|
+
const caption = captionOf(row, n.id);
|
|
335
465
|
out.push({
|
|
336
466
|
kind: StockSlotKind.Section, nodeId: n.id, owner: page.key, ...read, intent, about,
|
|
337
467
|
aspect: aspectRatioOf(n.styleProps['aspectRatio']),
|
|
338
|
-
words: stockWords(...
|
|
468
|
+
words: stockWords(...beside, ...sectionWords),
|
|
469
|
+
near: stockNearWords(...beside), ...(caption ? { caption } : {}),
|
|
339
470
|
});
|
|
340
471
|
});
|
|
341
472
|
});
|
|
@@ -360,6 +491,7 @@ export function stockItemSlots(plan: Pick<SitePlan, 'contentTypes'>, composed: P
|
|
|
360
491
|
out.push({
|
|
361
492
|
kind: StockSlotKind.Item, contentType: ShopResource.Products, index, field: SHOP_IMAGE_FIELD, intent: StockIntent.Product, aspect: STOCK_ITEM_ASPECT,
|
|
362
493
|
words: stockWords(product.title, product.category, product.description), subject: stockWords(product.title),
|
|
494
|
+
near: stockNearWords(product.title), ...(altText(product.title) ? { caption: altText(product.title) } : {}),
|
|
363
495
|
});
|
|
364
496
|
});
|
|
365
497
|
for (const type of plan.contentTypes) {
|
|
@@ -369,8 +501,10 @@ export function stockItemSlots(plan: Pick<SitePlan, 'contentTypes'>, composed: P
|
|
|
369
501
|
(composed.items[type.name] ?? []).forEach((item, index) => {
|
|
370
502
|
if (!item.isSample || parseSampleImageRef(item[field]) === null) return;
|
|
371
503
|
const { subject, words } = itemWords(type, item);
|
|
504
|
+
const title = item[roleField(type, ContentRole.Title) ?? ''];
|
|
372
505
|
out.push({
|
|
373
506
|
kind: StockSlotKind.Item, contentType: type.name, index, field, intent: StockIntent.Product, aspect: STOCK_ITEM_ASPECT, words, subject,
|
|
507
|
+
near: stockNearWords(title), ...(altText(title) ? { caption: altText(title) } : {}),
|
|
374
508
|
...(person ? { person: true } : {}),
|
|
375
509
|
});
|
|
376
510
|
});
|
|
@@ -459,7 +593,8 @@ export function planStockPhotos<T extends StockTarget>(slots: ReadonlyArray<T>,
|
|
|
459
593
|
used.add(best.key);
|
|
460
594
|
here.add(best.key);
|
|
461
595
|
shownIn.set(group, here);
|
|
462
|
-
|
|
596
|
+
// iox-cms#130: the photo as placed HERE carries this place's alt — the provider's words stay on `credit.title`.
|
|
597
|
+
placed.set(i, { ...slot, photo: { ...best, alt: stockPhotoAlt(slot) } });
|
|
463
598
|
}
|
|
464
599
|
return slots.map((_, i) => placed.get(i)).filter((p): p is StockPlacement<T> => !!p);
|
|
465
600
|
}
|
|
@@ -469,7 +604,7 @@ export function stockCopyKey(photo: Pick<StockPhoto, 'key'>): string {
|
|
|
469
604
|
return `media/stock/${photo.key.replace(/[^a-zA-Z0-9._-]+/g, '-')}`;
|
|
470
605
|
}
|
|
471
606
|
|
|
472
|
-
/** Put the studio's copy of each photo into its slot (src + the
|
|
607
|
+
/** Put the studio's copy of each photo into its slot (src + its alt: the place's words, `stockPhotoAlt`). Returns the nodes changed. */
|
|
473
608
|
export function applyStockPhotos(trees: ReadonlyArray<SerializedNode>, placed: ReadonlyArray<{ nodeId: string; url: string; alt: string }>): number {
|
|
474
609
|
const byId = new Map(placed.map(p => [p.nodeId, p]));
|
|
475
610
|
let changed = 0;
|