@vectoriox/iox-ui 5.154.0 → 5.156.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/assist-core/index.d.ts +54 -4
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +22 -1
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1215 -607
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +4946 -4735
- package/package.json +1 -1
- package/src/assist-core/assist-turn.ts +9 -0
- package/src/assist-core/media-generate.ts +51 -0
- package/src/generation-core/compose-site.ts +89 -22
- package/src/generation-core/fallback-memory.ts +2 -2
- package/src/generation-core/layout-fingerprint.ts +15 -1
- package/src/generation-core/opening-mix.ts +162 -5
- package/src/generation-core/plan-wire.ts +2 -2
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/site-spec.generated.ts +47 -1
- package/src/generation-core/type-led.ts +435 -0
package/package.json
CHANGED
|
@@ -204,6 +204,12 @@ export enum AssistRouteKey {
|
|
|
204
204
|
Photos = 'photos',
|
|
205
205
|
Run = 'run',
|
|
206
206
|
Undo = 'undo',
|
|
207
|
+
/** S7 Files box ▸ Generate: the cost before the button (and why it may not run). */
|
|
208
|
+
GenerateQuote = 'generateQuote',
|
|
209
|
+
/** S7: a press — candidates are made by a run. */
|
|
210
|
+
Generate = 'generate',
|
|
211
|
+
/** S7: the asker's run, polled until every candidate has settled. */
|
|
212
|
+
GenerateRun = 'generateRun',
|
|
207
213
|
}
|
|
208
214
|
|
|
209
215
|
/** The path templates, `:param` filled by `assistPath` — neither side hand-types a URL. */
|
|
@@ -214,6 +220,9 @@ export const ASSIST_ROUTES: Readonly<Record<AssistRouteKey, string>> = {
|
|
|
214
220
|
[AssistRouteKey.Photos]: 'admin/api/org/:orgId/ai/assist/photos',
|
|
215
221
|
[AssistRouteKey.Run]: 'admin/api/org/:orgId/ai/assist/turns/:turnId/run',
|
|
216
222
|
[AssistRouteKey.Undo]: 'admin/api/org/:orgId/ai/assist/turns/:turnId/undo',
|
|
223
|
+
[AssistRouteKey.GenerateQuote]: 'admin/api/org/:orgId/ai/assist/generate/quote',
|
|
224
|
+
[AssistRouteKey.Generate]: 'admin/api/org/:orgId/ai/assist/generate',
|
|
225
|
+
[AssistRouteKey.GenerateRun]: 'admin/api/org/:orgId/ai/assist/generate/:runId',
|
|
217
226
|
};
|
|
218
227
|
|
|
219
228
|
export class AssistPathError extends Error {}
|
|
@@ -328,3 +328,54 @@ export function generateOutcome(candidates: ReadonlyArray<GenerateCandidate>): G
|
|
|
328
328
|
done: candidates.length > 0 && candidates.every(c => FINAL.includes(c.state)),
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
+
|
|
332
|
+
// ── The wire: what the Files box asks and reads (the paths are `ASSIST_ROUTES` generateQuote · generate · generateRun) ──
|
|
333
|
+
|
|
334
|
+
/** Where a press stands. */
|
|
335
|
+
export enum GenerateRunStatus {
|
|
336
|
+
Queued = 'queued',
|
|
337
|
+
Making = 'making',
|
|
338
|
+
/** Every candidate settled (made, flagged or failed). */
|
|
339
|
+
Done = 'done',
|
|
340
|
+
/** The run itself could not go on (refused mid-way, or the server gave up) — what was made is still kept. */
|
|
341
|
+
Failed = 'failed',
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export const FINAL_GENERATE_STATUSES: ReadonlyArray<GenerateRunStatus> = [GenerateRunStatus.Done, GenerateRunStatus.Failed];
|
|
345
|
+
|
|
346
|
+
/** `GET …/generate/quote?count=&model=` — the cost before the button, from the SERVER's prices and meter. */
|
|
347
|
+
export interface GenerateQuoteView {
|
|
348
|
+
/** Null when no model can make a picture on this studio's key (then `refusal` or `models: []` says why). */
|
|
349
|
+
readonly estimate: GenerateEstimate | null;
|
|
350
|
+
/** The model a press would run on (the asked one, else the studio's default). */
|
|
351
|
+
readonly model: string | null;
|
|
352
|
+
readonly models: ReadonlyArray<GenerateModelChoice>;
|
|
353
|
+
/** Why a press would be refused right now — the button is off and says this. Null = it may run. */
|
|
354
|
+
readonly refusal: AiRefusal | null;
|
|
355
|
+
/** Credits left this period; null on an own key. */
|
|
356
|
+
readonly remaining: number | null;
|
|
357
|
+
/** "Your look": the site's art direction in a few words, or null when the studio has no look to wear yet. */
|
|
358
|
+
readonly look: string | null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** `POST …/generate` → 202. */
|
|
362
|
+
export interface GenerateAccepted {
|
|
363
|
+
readonly runId: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** `GET …/generate/:runId` — the asker's run. */
|
|
367
|
+
export interface GenerateRunView {
|
|
368
|
+
readonly runId: string;
|
|
369
|
+
readonly status: `${GenerateRunStatus}`;
|
|
370
|
+
readonly prompt: string;
|
|
371
|
+
readonly shape: string;
|
|
372
|
+
readonly count: number;
|
|
373
|
+
readonly look: boolean;
|
|
374
|
+
readonly model: string;
|
|
375
|
+
/** The cost shown and agreed to — the most the run may spend. */
|
|
376
|
+
readonly shown: number;
|
|
377
|
+
readonly candidates: ReadonlyArray<GenerateCandidate>;
|
|
378
|
+
readonly outcome: GenerateOutcome;
|
|
379
|
+
/** `Failed`: why, in a refusal code or a short reason — never a stack. */
|
|
380
|
+
readonly error?: string;
|
|
381
|
+
}
|
|
@@ -24,7 +24,10 @@ import {
|
|
|
24
24
|
countryLegalFacts, FOOTER_LEGAL_ROLE, FORM_LEGAL_ROLE, formAsksPersonalData, formLegalFacts, LEGAL_PAGE_SETTING, LegalContext, LegalFact, LegalFacts,
|
|
25
25
|
legalFormLine, LegalKind, legalKindsFor, legalLabel, legalRoute, legalTitle,
|
|
26
26
|
} from './legal';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
checkOpening, drawnOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
|
|
29
|
+
stampOpeningMotion, TYPE_LED_OPTIONAL_PARTS, typeLedOpeningSection,
|
|
30
|
+
} from './opening-mix';
|
|
28
31
|
import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderIngredient, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
|
|
29
32
|
import { bodyMixOfPlan, checkBody, drawnBodyMix, wearBodyMix } from './body-mix';
|
|
30
33
|
import { NODE_BASELINES } from './node-baselines.generated';
|
|
@@ -42,6 +45,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
|
|
|
42
45
|
PlanDataSourceType, RelativeOp, roleField, SiteLocale, SitePlan, SitePlanSource, siteFactLabel, SiteBusiness, GenerationTier,
|
|
43
46
|
} from './site-plan.model';
|
|
44
47
|
import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
|
|
48
|
+
import { PictureSupply, TypeLed, TypeLedChange, TypeLedChangeKind, typeLedRound } from './type-led';
|
|
45
49
|
import { MenuSide, NavRole, NavShape, planNavShape } from './nav-shape';
|
|
46
50
|
import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding } from './compose-layout';
|
|
47
51
|
import { LayoutGalleryList, LayoutListShape, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
|
|
@@ -164,6 +168,9 @@ export interface ComposeContext {
|
|
|
164
168
|
/** A redesign (site-redesign RD1): each composed page's carry by page key (`harvestPage`) — its layout's layers and
|
|
165
169
|
* sections naming a handle show the owner's part. */
|
|
166
170
|
carry?: Readonly<Record<string, PageCarry>>;
|
|
171
|
+
/** #129: which picture slots a picture fills (the owner's, a made one, a stock one). Given, a section whose picture
|
|
172
|
+
* nothing fills is composed type-led (`type-led.ts`); absent, the plan composes exactly as it says. */
|
|
173
|
+
pictures?: PictureSupply;
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
/** Where a composed layout's photos are, as the server keeps them and the screens read them (M8 gate 2): id → address. */
|
|
@@ -240,6 +247,8 @@ export interface ComposedSite {
|
|
|
240
247
|
issues: ComposeIssue[];
|
|
241
248
|
/** Commerce C-D21: what the build writes into the studio's SHOP (never a content type) — null when it sells nothing. */
|
|
242
249
|
shop: ComposedShop | null;
|
|
250
|
+
/** #129: set when the caller said what fills the pictures — what the composition wore instead of empty pictures. */
|
|
251
|
+
typeLed?: TypeLed;
|
|
243
252
|
}
|
|
244
253
|
|
|
245
254
|
/** A sample product as the build writes it through the shop's own write path (its slug made there, from its title). */
|
|
@@ -387,6 +396,8 @@ interface Ctx {
|
|
|
387
396
|
keepButtons?: boolean;
|
|
388
397
|
/** M1-6b: the pattern's entrance parts as stamped, for `planEntrances` once the pattern is whole. */
|
|
389
398
|
entrances?: Array<Omit<EntranceMark, 'index'>>;
|
|
399
|
+
/** #129: the content types whose items have no picture at all — an optional `@image?` of theirs is left out. */
|
|
400
|
+
pictureless?: ReadonlySet<string>;
|
|
390
401
|
}
|
|
391
402
|
|
|
392
403
|
interface ShownWhen {
|
|
@@ -476,7 +487,10 @@ function resolveScopedPath(path: string, repeater: RepeaterScope | null, ctx: Ct
|
|
|
476
487
|
const parsed = parsePatternPath(path);
|
|
477
488
|
const { source, typeSource } = scopeOf(parsed.scope, path, repeater, ctx, nodeId);
|
|
478
489
|
if (!parsed.role) return { source, path: parsed.field || ITEM_VALUE_PATH };
|
|
479
|
-
const
|
|
490
|
+
const type = typeSource ? contentTypeOfSource(typeSource, ctx.plan) : undefined;
|
|
491
|
+
// #129: a list whose items have no picture shows its cards without one, never an empty box per card.
|
|
492
|
+
if (parsed.optional && parsed.role === ContentRole.Image && type && ctx.pictureless?.has(type.name)) return null;
|
|
493
|
+
const field = roleField(type, parsed.role);
|
|
480
494
|
if (field) return { source, path: field };
|
|
481
495
|
if (parsed.optional) return null;
|
|
482
496
|
throw new ComposeError(`${nodeId}: "${path}" — the item's content type names no ${parsed.role} field`);
|
|
@@ -1643,7 +1657,7 @@ const LAYOUT_TEXT_PROPS: ReadonlyArray<string> = ['content', 'caption', 'alt', '
|
|
|
1643
1657
|
*/
|
|
1644
1658
|
function composeLayoutPage(
|
|
1645
1659
|
page: PagePlan, layout: LayoutPage, plan: SitePlan, context: ComposeContext, design: DesignChoices, placeholders: ComposedPlaceholder[],
|
|
1646
|
-
readyMade: (section: PageSectionPlan, id: string) => SerializedNode,
|
|
1660
|
+
readyMade: (section: PageSectionPlan, id: string) => SerializedNode, pictureless: ReadonlySet<string>,
|
|
1647
1661
|
): SerializedNode[] {
|
|
1648
1662
|
const preset = layoutPresetOf(plan.design);
|
|
1649
1663
|
const site: LayoutSite = {
|
|
@@ -1673,10 +1687,17 @@ function composeLayoutPage(
|
|
|
1673
1687
|
photoShape: id => boxShape(id) ?? context.photoShape?.(id),
|
|
1674
1688
|
sourceFields: alias => {
|
|
1675
1689
|
const type = contentTypeOfSource(alias, plan);
|
|
1676
|
-
const image = roleField(type, 'image');
|
|
1690
|
+
const image = type && pictureless.has(type.name) ? undefined : roleField(type, 'image');
|
|
1677
1691
|
return image ? { image, ...(roleField(type, 'title') ? { title: roleField(type, 'title')! } : {}) } : null;
|
|
1678
1692
|
},
|
|
1679
|
-
listOf: alias =>
|
|
1693
|
+
listOf: alias => {
|
|
1694
|
+
const binding = layoutListBinding(alias, plan);
|
|
1695
|
+
const type = contentTypeOfSource(alias, plan);
|
|
1696
|
+
// #129: a list whose items have no picture is read as a list without one (its cards draw no picture part).
|
|
1697
|
+
if (!binding || !type || !pictureless.has(type.name) || !binding.roles[ContentRole.Image]) return binding;
|
|
1698
|
+
const { [ContentRole.Image]: _none, ...roles } = binding.roles;
|
|
1699
|
+
return { ...binding, roles };
|
|
1700
|
+
},
|
|
1680
1701
|
...(context.carry?.[page.key] ? { carry: context.carry[page.key] } : {}),
|
|
1681
1702
|
});
|
|
1682
1703
|
const facts = plan.business.facts ?? {};
|
|
@@ -1716,6 +1737,36 @@ function stampLayoutSections(page: PagePlan, layout: LayoutPage, nodes: Serializ
|
|
|
1716
1737
|
* composer never repairs a plan. `context` carries what the composer may not read for itself (the year).
|
|
1717
1738
|
*/
|
|
1718
1739
|
export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSite {
|
|
1740
|
+
if (!context?.pictures) return composeSiteOnce(plan, context, NO_TYPES);
|
|
1741
|
+
// #129: compose, find the pictures nothing fills, compose again type-led — until a round changes nothing (an opening
|
|
1742
|
+
// left out shows its first section's own picture, judged in the next round). Monotone: a type-led section has no
|
|
1743
|
+
// picture to lose, so it ends.
|
|
1744
|
+
const filled = new Set(context.pictures.filled);
|
|
1745
|
+
const changes: TypeLedChange[] = [];
|
|
1746
|
+
let current = plan;
|
|
1747
|
+
let pictureless: ReadonlySet<string> = NO_TYPES;
|
|
1748
|
+
let site = composeSiteOnce(current, context, pictureless);
|
|
1749
|
+
let opening: TypeLed['opening'];
|
|
1750
|
+
const roundContext = { tier: context.tier, studio: context.pictures.studio };
|
|
1751
|
+
for (let round = 0; round < TYPE_LED_ROUNDS; round++) {
|
|
1752
|
+
const next = typeLedRound(current, site, filled, roundContext);
|
|
1753
|
+
if (next.opening) opening = next.opening;
|
|
1754
|
+
const newly = next.pictureless.filter(t => !pictureless.has(t));
|
|
1755
|
+
if (!next.changes.length && !newly.length) break;
|
|
1756
|
+
changes.push(...next.changes);
|
|
1757
|
+
for (const type of newly) changes.push({ kind: TypeLedChangeKind.List, contentType: type, said: `the ${type} have no pictures yet — their cards show their words` });
|
|
1758
|
+
current = next.plan;
|
|
1759
|
+
pictureless = new Set([...pictureless, ...newly]);
|
|
1760
|
+
site = composeSiteOnce(current, context, pictureless);
|
|
1761
|
+
}
|
|
1762
|
+
return { ...site, typeLed: { plan: current, changes, pictureless: [...pictureless], ...(opening ? { opening } : {}) } };
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
const NO_TYPES: ReadonlySet<string> = new Set();
|
|
1766
|
+
/** The most rounds a composition takes to wear no empty picture: the opening, then its first section, then a margin. */
|
|
1767
|
+
const TYPE_LED_ROUNDS = 4;
|
|
1768
|
+
|
|
1769
|
+
function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: ReadonlySet<string>): ComposedSite {
|
|
1719
1770
|
assertValidSitePlan(plan, context?.tier ? { tier: context.tier } : {});
|
|
1720
1771
|
if (!Number.isInteger(context?.year)) throw new ComposeError('composeSite needs the year (ComposeContext.year) — the composer reads no clock');
|
|
1721
1772
|
const placeholders: ComposedPlaceholder[] = [];
|
|
@@ -1723,7 +1774,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1723
1774
|
const routes = new Set(plan.pages.map(p => p.route));
|
|
1724
1775
|
const relatives = new Map(plan.dataSources.map(d => [d.alias, d.type === PlanDataSourceType.Relative ? { type: d.type, of: d.of, op: d.op } : { type: d.type }]));
|
|
1725
1776
|
const email = nonEmpty(plan.business.facts?.email) ? plan.business.facts!.email!.trim() : null;
|
|
1726
|
-
const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null };
|
|
1777
|
+
const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null, pictureless };
|
|
1727
1778
|
|
|
1728
1779
|
// AW-D23 / MB-D6: a lower plan wears its own words of the look's motion language (a Pro Feel arrives on today's
|
|
1729
1780
|
// curve, a Pro move fades) — in the tokens the build applies AND the entrances it stamps.
|
|
@@ -1742,10 +1793,11 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1742
1793
|
const layout = withShownList(page.layout, layoutListsContext(page, plan)) ?? page.layout;
|
|
1743
1794
|
const stamped = stampLayoutSections(page, layout, composeLayoutPage(page, layout, plan, context, design, placeholders, (section, id) =>
|
|
1744
1795
|
composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
|
|
1745
|
-
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null })));
|
|
1796
|
+
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null }), pictureless));
|
|
1746
1797
|
// AW8: the plan's opening is the home page's first screen; a pinned or kept first place is never replaced.
|
|
1747
1798
|
const first = layout.sections[0];
|
|
1748
|
-
const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry)
|
|
1799
|
+
const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry),
|
|
1800
|
+
first?.readyMade ? page.sections[first.readyMade.at] : undefined);
|
|
1749
1801
|
const opening = worn === stamped ? layoutBandScheme(first?.ground) : schemeOfFirst(worn);
|
|
1750
1802
|
// Award §0c CW2 (AW-D34): the column the model chose for this page is the page's own word (absent: the site's).
|
|
1751
1803
|
const column = columnWordOf(layout.column);
|
|
@@ -1759,7 +1811,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1759
1811
|
const pattern = patternById(section.pattern) as SitePattern;
|
|
1760
1812
|
const motion: SectionMotion = { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: i === 0 };
|
|
1761
1813
|
return stampSection(composePattern(pattern, `${page.key}-${i}`, { ...base, owner: page.key, page, section, nextAlias }, motion), { pattern: section.pattern });
|
|
1762
|
-
}), plan, context, design, placeholders, issues, false);
|
|
1814
|
+
}), plan, context, design, placeholders, issues, false, page.sections[0]);
|
|
1763
1815
|
const opening = schemeOfFirst(layout);
|
|
1764
1816
|
return {
|
|
1765
1817
|
key: page.key,
|
|
@@ -2300,20 +2352,22 @@ function shownWords(root: SerializedNode | undefined): string {
|
|
|
2300
2352
|
*/
|
|
2301
2353
|
function wearPlanOpening(
|
|
2302
2354
|
page: PagePlan, layout: SerializedNode[], plan: SitePlan, context: ComposeContext, design: DesignChoices,
|
|
2303
|
-
placeholders: ComposedPlaceholder[], issues: ComposeIssue[], keep: boolean,
|
|
2355
|
+
placeholders: ComposedPlaceholder[], issues: ComposeIssue[], keep: boolean, source?: PageSectionPlan,
|
|
2304
2356
|
): SerializedNode[] {
|
|
2305
2357
|
const mix = openingMixOfPlan(plan);
|
|
2306
2358
|
if (!mix || !(page.isHome === true || page.route === HOME_PATH)) return layout;
|
|
2307
2359
|
const first = layout[0];
|
|
2308
2360
|
const replace = !!first && !keep && openingMayReplace(first);
|
|
2309
2361
|
const id = replace ? first.id : `${page.key}-opening`;
|
|
2310
|
-
const
|
|
2362
|
+
const tier = context.tier ?? GenerationTier.Basic;
|
|
2363
|
+
const site = { pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })), locale: plan.locale, design, badge: null, cutOut: false, tier };
|
|
2364
|
+
// #129: a type-led first screen takes the type-led hero's words slot by slot (nothing it said is lost); the name is
|
|
2365
|
+
// the business's, as every display-size opening's is.
|
|
2366
|
+
const checked = replace && source ? checkOpening(drawnOpeningMix(mix).drawn, openingContextOf({ ...site, business: plan.business })).mix : null;
|
|
2367
|
+
const parts = checked && source ? typeLedOpeningSection(checked, source) : null;
|
|
2368
|
+
const heading = replace && !parts ? swapParts(first)['heading'][0] : undefined;
|
|
2311
2369
|
const title = shownWords(heading);
|
|
2312
|
-
const composed = composeOpening({
|
|
2313
|
-
business: { ...plan.business, name: title || plan.business.name },
|
|
2314
|
-
pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })),
|
|
2315
|
-
mix, locale: plan.locale, design, badge: null, cutOut: false, tier: context.tier ?? GenerationTier.Basic,
|
|
2316
|
-
}, { id });
|
|
2370
|
+
const composed = composeOpening({ ...site, business: { ...plan.business, name: title || plan.business.name }, mix, ...(parts ? { parts } : {}) }, { id });
|
|
2317
2371
|
const section = composed.section;
|
|
2318
2372
|
const said = composed.issues.map(i => i.detail);
|
|
2319
2373
|
let own: ComposedPlaceholder[] = composed.placeholders.map(p => ({ ...p, owner: page.key }));
|
|
@@ -2322,6 +2376,13 @@ function wearPlanOpening(
|
|
|
2322
2376
|
walkSerialized([first], n => { gone.add(n.id); });
|
|
2323
2377
|
const carried = placeholders.filter(p => gone.has(p.nodeId));
|
|
2324
2378
|
for (let i = placeholders.length - 1; i >= 0; i--) if (gone.has(placeholders[i].nodeId)) placeholders.splice(i, 1);
|
|
2379
|
+
if (parts) {
|
|
2380
|
+
// The words came slot by slot: nothing to carry, the composer's placeholders stand.
|
|
2381
|
+
placeholders.push(...own);
|
|
2382
|
+
for (const detail of said) issues.push({ code: ComposeIssueCode.OpeningMended, nodeId: id, owner: page.key, detail });
|
|
2383
|
+
stampSection(section, first.composed?.pattern ? { pattern: first.composed.pattern } : { layout: first.composed?.layout ?? OPENING_ORIGIN });
|
|
2384
|
+
return [section, ...layout.slice(1)];
|
|
2385
|
+
}
|
|
2325
2386
|
// The hero's title is already the opening's display words (composed above — split apart, set as a wordmark); the
|
|
2326
2387
|
// carry places everything else, never over those words.
|
|
2327
2388
|
const fromRest = withoutNodes(first, n => n === heading);
|
|
@@ -2383,6 +2444,10 @@ export interface OpeningInput extends SectionInput {
|
|
|
2383
2444
|
readonly tier?: OpeningContext['tier'];
|
|
2384
2445
|
/** Draw the mix as asked, never mended — the Opening studio (it ADVISES the check's mends, OB-2). */
|
|
2385
2446
|
readonly asAsked?: boolean;
|
|
2447
|
+
/** #129: a type-led first screen's words, slot by slot, from the hero it takes the place of (`typeLedOpeningSection`).
|
|
2448
|
+
* Absent on a type-led mix: its optional parts (the line above, the line beside the name, a second action) are left
|
|
2449
|
+
* out, so nothing is invented. */
|
|
2450
|
+
readonly parts?: { readonly slots: Readonly<Record<string, string>>; readonly links: Readonly<Record<string, string>>; readonly without: ReadonlyArray<string> };
|
|
2386
2451
|
}
|
|
2387
2452
|
|
|
2388
2453
|
export interface ComposedOpening extends ComposedSection {
|
|
@@ -2422,17 +2487,19 @@ export function composeOpening(input: OpeningInput, options: SectionOptions): Co
|
|
|
2422
2487
|
for (const said of [...gaps.map(g => `the opening's ${g.ingredient} "${g.word}" is drawn as ${g.drawnAs ? `"${g.drawnAs}"` : 'nothing'} until ${g.phase}`), ...checked.repairs.map(r => r.said)]) {
|
|
2423
2488
|
issues.push({ code: ComposeIssueCode.OpeningMended, nodeId: options.id, owner: options.id, detail: said });
|
|
2424
2489
|
}
|
|
2490
|
+
const parts = input.parts ?? (openingIsTypeLed(checked.mix) ? { slots: {}, links: {}, without: TYPE_LED_OPTIONAL_PARTS } : null);
|
|
2491
|
+
const section = parts ? { pattern: OPENING_ORIGIN, slots: parts.slots, links: parts.links, without: [...parts.without] } as PageSectionPlan : null;
|
|
2425
2492
|
const ctx: Ctx = {
|
|
2426
|
-
owner: options.id, page: null, section
|
|
2493
|
+
owner: options.id, page: null, section, plan, year: 0, email, navPage: null, nextAlias: null,
|
|
2427
2494
|
placeholders, issues, routes: new Set(pages.map(p => p.route)), keepButtons: true,
|
|
2428
2495
|
};
|
|
2429
2496
|
const recipe = openingRecipe(checked.mix, context);
|
|
2430
|
-
const
|
|
2431
|
-
stampOpeningMix(
|
|
2432
|
-
stampOpeningMotion(
|
|
2497
|
+
const root = composePattern(recipe.pattern, options.id, ctx);
|
|
2498
|
+
stampOpeningMix(root, recipe.mix);
|
|
2499
|
+
stampOpeningMotion(root, recipe.mix);
|
|
2433
2500
|
const badge = typeof input.badge === 'string' && input.badge.trim() ? input.badge.trim() : null;
|
|
2434
2501
|
if (badge) {
|
|
2435
|
-
walkSerialized([
|
|
2502
|
+
walkSerialized([root], n => {
|
|
2436
2503
|
const holder = n.role === OpeningRole.Badge ? n : null;
|
|
2437
2504
|
for (const words of holder?.children ?? []) {
|
|
2438
2505
|
words.props = { ...words.props, content: badge };
|
|
@@ -2441,6 +2508,6 @@ export function composeOpening(input: OpeningInput, options: SectionOptions): Co
|
|
|
2441
2508
|
}
|
|
2442
2509
|
});
|
|
2443
2510
|
}
|
|
2444
|
-
return { section, placeholders, issues, mix: recipe.mix };
|
|
2511
|
+
return { section: root, placeholders, issues, mix: recipe.mix };
|
|
2445
2512
|
}
|
|
2446
2513
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LayoutPage, LayoutSection, LayoutSectionKind } from './layout-language';
|
|
2
|
-
import { FingerprintedPage, fingerprintOf, LAYOUT_READY_MADE_TOKEN, LayoutFingerprint } from './layout-fingerprint';
|
|
2
|
+
import { FingerprintedPage, fingerprintOf, LAYOUT_READY_MADE_TOKEN, LayoutFingerprint, wornOpenings } from './layout-fingerprint';
|
|
3
3
|
import { footerMixOfPlan } from './footer-mix';
|
|
4
4
|
import { wornHeaderOfPlan } from './header-mix';
|
|
5
5
|
import { PatternNode, patternById, patternNeedsBinding, patternNodes, SITE_LIBRARY, SitePattern } from './patterns';
|
|
@@ -129,7 +129,7 @@ export interface DistinctFallback {
|
|
|
129
129
|
export function distinctFallbackSections(sections: ReadonlyArray<PageSectionPlan>, others: ReadonlyArray<FingerprintedPage>): DistinctFallback {
|
|
130
130
|
const all = [...sections];
|
|
131
131
|
const first = all[0];
|
|
132
|
-
const worn =
|
|
132
|
+
const worn = wornOpenings(others);
|
|
133
133
|
if (!first || !worn.has(readyMadeToken(first.pattern))) return { sections: all, kept: FallbackOpeningKept.Free };
|
|
134
134
|
const family = patternById(first.pattern)?.family;
|
|
135
135
|
if (!family) return { sections: all, kept: FallbackOpeningKept.NoneFree };
|
|
@@ -210,8 +210,12 @@ export function sequenceShare(a: ReadonlyArray<string>, b: ReadonlyArray<string>
|
|
|
210
210
|
return lcs(a, b) / Math.max(1, a.length, b.length);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
/** #129: an opening mix's token (`opening:<frame>/<media>/<words>`, opening-mix `openingTokenOf`) — a type-led first
|
|
214
|
+
* screen's. Literal here: importing opening-mix from this module reorders the generation-core load (a cycle). */
|
|
215
|
+
const MIX_OPENING = 'opening:';
|
|
213
216
|
const openingWords = (opening: string) =>
|
|
214
|
-
opening.startsWith(
|
|
217
|
+
opening.startsWith(MIX_OPENING) ? `an opening of ${opening.slice(MIX_OPENING.length).split('/').join(' · ')}`
|
|
218
|
+
: opening.startsWith(READY_MADE_OPENING) ? `the ready-made ${opening.slice(READY_MADE_OPENING.length)}` : opening === OPENING_SCREEN_WORD ? 'a screen-size word' : opening === 'photo' || opening === 'gallery' ? `a ${opening}` : `a ${opening.replace('-', ' ')}`;
|
|
215
219
|
/** A list token in words: `list:row/middle-raised/arrows` → "row · middle raised · arrows". */
|
|
216
220
|
export const listWords = (token: string) => token.replace(`${LAYOUT_LIST_TOKEN}:`, '').split('/').map(p => p.replace(/[-+]/g, ' ')).join(' · ');
|
|
217
221
|
const signatureWords = (id: string) => SPEC_SITE_LAYOUT.signatures.find(s => s.id === id)?.label ?? id;
|
|
@@ -246,6 +250,16 @@ export function samenessIssues(me: LayoutFingerprint, others: ReadonlyArray<Fing
|
|
|
246
250
|
return issues;
|
|
247
251
|
}
|
|
248
252
|
|
|
253
|
+
/**
|
|
254
|
+
* The openings the studio's OTHER sites already wear, as the memory holds them (`LayoutFingerprint.opening`). This site's
|
|
255
|
+
* own pages (`sameSite`) and the demos are never a reason: every page of a site may open alike, and a demo is not a site.
|
|
256
|
+
* The ONE reading of the memory for an opening — a fallen page's (`distinctFallbackSections`) and a type-led first
|
|
257
|
+
* screen's (#129, `typeLedRound`).
|
|
258
|
+
*/
|
|
259
|
+
export function wornOpenings(others: ReadonlyArray<FingerprintedPage>): Set<string> {
|
|
260
|
+
return new Set(others.filter(o => !o.sameSite && !o.demo).map(o => o.fingerprint.opening));
|
|
261
|
+
}
|
|
262
|
+
|
|
249
263
|
/** The three proof sites' fingerprints (premium M8): every new page's opening and signature are compared with them, never
|
|
250
264
|
* its order of sections (`demo`). layout-fingerprint.spec holds them equal to `fingerprintOf` of the proof layouts. */
|
|
251
265
|
export const PROOF_FINGERPRINTS: ReadonlyArray<FingerprintedPage> = [
|
|
@@ -43,6 +43,12 @@ interface OpeningTable {
|
|
|
43
43
|
rules: { wordsNeverCut: boolean; phoneInsetPx: readonly [number, number]; slowZoomMinS: number; badgeOwnersOnly: boolean; neverHoldsScroll: boolean };
|
|
44
44
|
tiers: Readonly<Record<string, 'all' | 'pro'>>;
|
|
45
45
|
references: ReadonlyArray<{ id: string; after: string; added: string; mix: Partial<Record<string, string | ReadonlyArray<string>>> }>;
|
|
46
|
+
/** #129: `<ingredient>.<word>` the harness alone chooses — never on the model's wire. */
|
|
47
|
+
harness?: ReadonlyArray<string>;
|
|
48
|
+
/** #129: the ways a type-led first screen (`media.none`) may open, best first. */
|
|
49
|
+
typeLed?: ReadonlyArray<{ frame: string; words: string }>;
|
|
50
|
+
/** AW-D23 amended (2026-11-24): a type-led way is worn at every tier. */
|
|
51
|
+
typeLedEveryTier?: boolean;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
/** The ingredients, by the contract's keys (held equal to it by opening-mix.spec). */
|
|
@@ -55,7 +61,7 @@ export enum OpeningIngredient {
|
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export enum OpeningFrame { Full = 'full', Inset = 'inset', Shrinks = 'shrinks', Grows = 'grows' }
|
|
58
|
-
export enum OpeningMedia { Photo = 'photo', Film = 'film', Slideshow = 'slideshow', Object = 'object', Diptych = 'diptych', Material = 'material', Live = 'live' }
|
|
64
|
+
export enum OpeningMedia { Photo = 'photo', Film = 'film', Slideshow = 'slideshow', Object = 'object', Diptych = 'diptych', Material = 'material', Live = 'live', None = 'none' }
|
|
59
65
|
export enum OpeningWords { Headline = 'headline', OnEdge = 'on-edge', Apart = 'apart', Wordmark = 'wordmark', Behind = 'behind', None = 'none' }
|
|
60
66
|
export enum OpeningExtra { Card = 'card', Badge = 'badge', Cue = 'cue' }
|
|
61
67
|
export enum OpeningMotion { SlowZoom = 'slow-zoom', CopyOut = 'copy-out', PinnedCovered = 'pinned-covered' }
|
|
@@ -90,6 +96,12 @@ export enum OpeningRole {
|
|
|
90
96
|
Title = 'opening.title',
|
|
91
97
|
Lead = 'opening.lead',
|
|
92
98
|
Action = 'opening.action',
|
|
99
|
+
/** #129, a type-led first screen only: the line above the title, the hero's headline beside a display-size name, the
|
|
100
|
+
* second action and the row that holds the actions — every part the hero it replaces says, so no word is lost. */
|
|
101
|
+
Eyebrow = 'opening.eyebrow',
|
|
102
|
+
Line = 'opening.line',
|
|
103
|
+
SecondAction = 'opening.action-2',
|
|
104
|
+
Actions = 'opening.actions',
|
|
93
105
|
Apart = 'opening.apart',
|
|
94
106
|
/** The second and third of the words placed apart. */
|
|
95
107
|
ApartWord = 'opening.apart-word',
|
|
@@ -330,6 +342,26 @@ export function openingWireWords(tier: `${GenerationTier}` = GenerationTier.Basi
|
|
|
330
342
|
return ORDER.flatMap(k => openingWords(k).filter(w => openingWordDrawn(k, w) && openingWordOffered(k, w, tier)).map(w => `${k}:${w}`));
|
|
331
343
|
}
|
|
332
344
|
|
|
345
|
+
/** #129: a word the harness alone chooses (`media:none` — no picture fills the first screen), never offered to a model. */
|
|
346
|
+
export function openingHarnessWord(ingredient: `${OpeningIngredient}`, word: string): boolean {
|
|
347
|
+
return (O.harness ?? []).includes(`${ingredient}.${word}`);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** #129: the ways a type-led first screen may open, best first, each a whole mix on no picture (the contract's
|
|
351
|
+
* `opening.typeLed`). */
|
|
352
|
+
export function typeLedOpeningWays(): OpeningMix[] {
|
|
353
|
+
return (O.typeLed ?? []).map(w => openingMix({ frame: w.frame, words: w.words, media: OpeningMedia.None }));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** AW-D23 amended (2026-11-24): a type-led first screen's frame and words are worn at every tier when they are one of
|
|
357
|
+
* the contract's type-led ways — with no picture they are all the screen has. */
|
|
358
|
+
function typeLedWayEveryTier(mix: OpeningMix): boolean {
|
|
359
|
+
return !!O.typeLedEveryTier && mix.media === OpeningMedia.None && (O.typeLed ?? []).some(w => w.frame === mix.frame && w.words === mix.words);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** #129: is the mix a type-led first screen (nothing to show but its words)? */
|
|
363
|
+
export const openingIsTypeLed = (mix: Pick<OpeningMix, 'media'>): boolean => mix.media === OpeningMedia.None;
|
|
364
|
+
|
|
333
365
|
// ── The check: a mix judged against the site, mended where the site cannot carry it, each mend said ──────────────────
|
|
334
366
|
|
|
335
367
|
export enum OpeningRepairCode {
|
|
@@ -414,7 +446,9 @@ export function checkOpening(mix: OpeningMix, ctx: OpeningContext): { mix: Openi
|
|
|
414
446
|
const repairs: OpeningRepair[] = [];
|
|
415
447
|
const say = (code: OpeningRepairCode, said: string) => repairs.push({ code, said });
|
|
416
448
|
if (ctx.tier && ctx.tier !== GenerationTier.Award) {
|
|
449
|
+
const everyTier = typeLedWayEveryTier(m);
|
|
417
450
|
for (const k of ORDER) {
|
|
451
|
+
if (everyTier && (k === OpeningIngredient.Frame || k === OpeningIngredient.Words)) continue;
|
|
418
452
|
if (isMany(k)) {
|
|
419
453
|
const kept = m[k].filter(w => openingWordTier(k, w) === 'all');
|
|
420
454
|
for (const w of m[k].filter(x => !kept.includes(x))) say(OpeningRepairCode.ProOnly, `"${openingMeaning(k, w)}" comes with the award plan: left out`);
|
|
@@ -462,7 +496,8 @@ export function checkOpening(mix: OpeningMix, ctx: OpeningContext): { mix: Openi
|
|
|
462
496
|
const still = m.media === OpeningMedia.Photo || m.media === OpeningMedia.Diptych || m.media === OpeningMedia.Live;
|
|
463
497
|
if (m.motion.includes(OpeningMotion.SlowZoom) && !still) {
|
|
464
498
|
m.motion = m.motion.filter(w => w !== OpeningMotion.SlowZoom);
|
|
465
|
-
say(OpeningRepairCode.ZoomOnAPicture, 'a slow zoom moves a
|
|
499
|
+
say(OpeningRepairCode.ZoomOnAPicture, m.media === OpeningMedia.None ? 'a slow zoom moves a picture, and this first screen has none: left out'
|
|
500
|
+
: 'a slow zoom moves a still picture: left out on moving pictures');
|
|
466
501
|
}
|
|
467
502
|
return { mix: m, repairs };
|
|
468
503
|
}
|
|
@@ -475,6 +510,12 @@ export function checkOpening(mix: OpeningMix, ctx: OpeningContext): { mix: Openi
|
|
|
475
510
|
|
|
476
511
|
/** How tall the first screen stands: a little less than the window, so the next section's edge says "there is more". */
|
|
477
512
|
export const OPENING_HEIGHT = '88svh';
|
|
513
|
+
/** #129: a type-led first screen holds only words, so it is as tall as they need — a picture's 88svh left a dark field
|
|
514
|
+
* above them (the proof's shots: law, ceramics, the salon's phone). Words apart keep the full height: they spread over it.
|
|
515
|
+
* On a phone the frame hugs its words; the name on the edge then follows them in flow. */
|
|
516
|
+
const TYPE_LED_HEIGHT = 'min(64svh, 600px)';
|
|
517
|
+
const typeLedHeights = (mix: OpeningMix): { laptop: string; phone?: string } =>
|
|
518
|
+
mix.words === OpeningWords.Apart ? { laptop: OPENING_HEIGHT } : { laptop: TYPE_LED_HEIGHT, phone: '0px' };
|
|
478
519
|
const INSET_LAPTOP = '24px';
|
|
479
520
|
const ABS_FILL: Readonly<Record<string, string>> = { position: 'absolute', top: '0px', left: '0px', width: '100%', height: '100%', zIndex: '0' };
|
|
480
521
|
const MEDIA_FILL: Readonly<Record<string, string>> = { ...ABS_FILL, aspectRatio: 'auto', borderRadius: '0px', objectFit: 'cover' };
|
|
@@ -492,20 +533,31 @@ export function openingPhoneInset(): string {
|
|
|
492
533
|
const insetClip = (inset: string): string => `inset(${inset} round var(--iox-card-radius))`;
|
|
493
534
|
|
|
494
535
|
/** A display size that keeps `em` of text within the width (`side` px kept per side), never above `cap`. */
|
|
536
|
+
/** The frame's padding on a phone: an inset frame adds its inset. */
|
|
537
|
+
const phoneFramePad = (mix: OpeningMix): string =>
|
|
538
|
+
(mix.frame === OpeningFrame.Inset || mix.frame === OpeningFrame.Shrinks ? `calc(${openingPhoneInset()} + 20px)` : FRAME_PAD);
|
|
539
|
+
|
|
495
540
|
const sizedPx = (em: number, side: number, cap: string): string =>
|
|
496
541
|
`min(calc((100vw - ${2 * side}px) * ${FIT} / ${Math.max(em, 1).toFixed(3)}), ${cap})`;
|
|
497
542
|
|
|
498
543
|
function frameNode(mix: OpeningMix, children: PatternNode[]): PatternNode {
|
|
499
544
|
const inset = mix.frame === OpeningFrame.Inset || mix.frame === OpeningFrame.Shrinks;
|
|
545
|
+
const height = mix.media === OpeningMedia.None ? typeLedHeights(mix) : { laptop: OPENING_HEIGHT };
|
|
546
|
+
const phone = {
|
|
547
|
+
...(inset ? { clipPath: insetClip(openingPhoneInset()), padding: phoneFramePad(mix) } : {}),
|
|
548
|
+
...(height.phone ? { minHeight: height.phone } : {}),
|
|
549
|
+
};
|
|
500
550
|
return {
|
|
501
|
-
|
|
551
|
+
// A pictured frame is a box its picture fills; a type-led one (no picture) paints its scheme's own ground — a
|
|
552
|
+
// box paints nothing, and the scheme's light words stood on the page's light ground (the #129 proof's shots).
|
|
553
|
+
t: 'Container', es: mix.media === OpeningMedia.None ? 'section' : 'box', scheme: 'inverse',
|
|
502
554
|
role: mix.frame === OpeningFrame.Shrinks ? OpeningRole.FrameSettles : OpeningRole.Frame,
|
|
503
555
|
lay: {
|
|
504
556
|
position: 'relative', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', gap: 'var(--iox-space-gap)',
|
|
505
|
-
minHeight:
|
|
557
|
+
minHeight: height.laptop, padding: inset ? `calc(${INSET_LAPTOP} + ${FRAME_PAD})` : FRAME_PAD, borderRadius: '0px',
|
|
506
558
|
...(inset ? { clipPath: insetClip(INSET_LAPTOP) } : {}),
|
|
507
559
|
},
|
|
508
|
-
...(
|
|
560
|
+
...(Object.keys(phone).length ? { resp: { mobile: phone } } : {}),
|
|
509
561
|
c: children,
|
|
510
562
|
};
|
|
511
563
|
}
|
|
@@ -532,6 +584,8 @@ function mediaNodes(mix: OpeningMix): PatternNode[] {
|
|
|
532
584
|
{ ...picture(OpeningRole.Second, CELL_PICTURE), resp: { mobile: { display: 'none' } } },
|
|
533
585
|
],
|
|
534
586
|
}];
|
|
587
|
+
case OpeningMedia.None:
|
|
588
|
+
return [];
|
|
535
589
|
default:
|
|
536
590
|
return [picture(zooms ? OpeningRole.MediaZooms : OpeningRole.Media)];
|
|
537
591
|
}
|
|
@@ -554,9 +608,112 @@ const aside = (at: 'top' | 'bottom' = 'top'): PatternNode => ({
|
|
|
554
608
|
c: [lead(), action()],
|
|
555
609
|
});
|
|
556
610
|
|
|
611
|
+
// ── #129: a type-led first screen — no picture, the words carry it. It holds every part a hero says (the line above,
|
|
612
|
+
// the headline, the lead, two actions), each optional but the title, so the hero it replaces gives it its words slot by
|
|
613
|
+
// slot (`TYPE_LED_OPENING_SLOTS`) and nothing it said is lost; a part the hero did not say is left out (`without`).
|
|
614
|
+
|
|
615
|
+
/** The type-led parts a page may leave out, and what a composition with no hero to carry leaves out (the builder). */
|
|
616
|
+
export const TYPE_LED_OPTIONAL_PARTS: ReadonlyArray<string> = ['eyebrow', 'line', 'cta2'];
|
|
617
|
+
|
|
618
|
+
const eyebrowPart = (lay: Readonly<Record<string, string>> = {}): PatternNode => ({
|
|
619
|
+
t: 'Text', es: 'eyebrow', slot: 'eyebrow', optional: 'eyebrow', max: 32, ph: PatternPlaceholder.Copy, text: 'What you do · where', textHe: 'מה אתם עושים · איפה',
|
|
620
|
+
role: OpeningRole.Eyebrow, lay,
|
|
621
|
+
});
|
|
622
|
+
/** The hero's headline beside a display-size name (an h2: the name is the page's h1). */
|
|
623
|
+
const linePart = (lay: Readonly<Record<string, string>> = {}): PatternNode => ({
|
|
624
|
+
t: 'Heading', es: 'h2', level: 'h2', slot: 'line', optional: 'line', max: 56, ph: PatternPlaceholder.Copy, text: 'What you do, in a few words',
|
|
625
|
+
textHe: 'מה אתם עושים, בכמה מילים', role: OpeningRole.Line, lay: { margin: '0px', ...lay },
|
|
626
|
+
});
|
|
627
|
+
const actionsPart = (centred = false): PatternNode => ({
|
|
628
|
+
t: 'Container', es: 'box', role: OpeningRole.Actions,
|
|
629
|
+
lay: { display: 'flex', flexWrap: 'wrap', gap: '12px', alignItems: 'center', ...(centred ? { justifyContent: 'center' } : {}) },
|
|
630
|
+
c: [action(), { t: 'ButtonBlock', es: 'button-secondary', href: '/contact', slot: 'cta2', optional: 'cta2', max: 24, text: 'Learn more', textHe: 'למידע נוסף', role: OpeningRole.SecondAction }],
|
|
631
|
+
});
|
|
632
|
+
/** A hero's lead, as long as the hero's own (hero.centered: 180). */
|
|
633
|
+
const TYPE_LED_LEAD_MAX = 180;
|
|
634
|
+
const typeLedLead = (lay: Readonly<Record<string, string>> = {}): PatternNode => ({ ...lead(lay), max: TYPE_LED_LEAD_MAX });
|
|
635
|
+
/** What sits beside a display-size name: the line above, the headline, the lead and the actions. */
|
|
636
|
+
const typeLedAside = (at: 'top' | 'bottom'): PatternNode => ({
|
|
637
|
+
t: 'Container', es: 'box', role: OpeningRole.Aside,
|
|
638
|
+
lay: { ...OVER(1), display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: '14px', maxWidth: '560px', margin: at === 'top' ? '0px 0px auto 0px' : 'auto 0px 0px 0px' },
|
|
639
|
+
c: [eyebrowPart(), linePart(), typeLedLead(), actionsPart()],
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
/** Where each slot of a type-led hero goes in a type-led first screen; `headline` is the title, or the line beside a
|
|
643
|
+
* display-size name (the name is then the title). Only patterns every one of whose slots has a place. */
|
|
644
|
+
const TYPE_LED_OPENING_FROM: Readonly<Record<string, Readonly<Record<string, string>>>> = {
|
|
645
|
+
'hero.centered': { eyebrow: 'eyebrow', headline: 'headline', lead: 'lead', primary: 'cta', secondary: 'cta2' },
|
|
646
|
+
};
|
|
647
|
+
const DISPLAY_WORDS: ReadonlySet<string> = new Set([OpeningWords.OnEdge, OpeningWords.Wordmark, OpeningWords.Behind, OpeningWords.Apart]);
|
|
648
|
+
|
|
649
|
+
/** What a type-led first screen is composed from, given the hero section it takes the place of: the hero's words and
|
|
650
|
+
* links slot by slot, and every optional part the hero did not say left out — or null when the hero is not one whose
|
|
651
|
+
* every slot has a place (it is then carried part by part, as any opening). Pure. */
|
|
652
|
+
export function typeLedOpeningSection(
|
|
653
|
+
mix: OpeningMix, hero: { readonly pattern: string; readonly slots?: Readonly<Record<string, string>>; readonly links?: Readonly<Record<string, string>> },
|
|
654
|
+
): { slots: Record<string, string>; links: Record<string, string>; without: string[] } | null {
|
|
655
|
+
const from = TYPE_LED_OPENING_FROM[hero.pattern];
|
|
656
|
+
if (!from || mix.media !== OpeningMedia.None) return null;
|
|
657
|
+
const display = DISPLAY_WORDS.has(mix.words);
|
|
658
|
+
const to = (slot: string): string | undefined => (from[slot] === 'headline' ? (display ? 'line' : 'title') : from[slot]);
|
|
659
|
+
const slots: Record<string, string> = {};
|
|
660
|
+
const links: Record<string, string> = {};
|
|
661
|
+
for (const [slot, value] of Object.entries(hero.slots ?? {})) {
|
|
662
|
+
const at = to(slot);
|
|
663
|
+
if (!at) return null;
|
|
664
|
+
if (value.trim()) slots[at] = value;
|
|
665
|
+
}
|
|
666
|
+
for (const [slot, route] of Object.entries(hero.links ?? {})) {
|
|
667
|
+
const at = to(slot);
|
|
668
|
+
if (at) links[at] = route;
|
|
669
|
+
}
|
|
670
|
+
return { slots, links, without: TYPE_LED_OPTIONAL_PARTS.filter(part => !slots[part]) };
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** The words of a type-led first screen, as the mix places them — the same measured display sizes as a pictured one
|
|
674
|
+
* (R-H6), no scrim (nothing is under the words). */
|
|
675
|
+
function typeLedWordsNodes(mix: OpeningMix, ctx: OpeningContext): PatternNode[] {
|
|
676
|
+
const { line, longest } = nameEm(ctx);
|
|
677
|
+
const phoneSize = sizedPx(longest, PHONE_SIDE_PX, '22vw');
|
|
678
|
+
switch (mix.words) {
|
|
679
|
+
case OpeningWords.OnEdge:
|
|
680
|
+
// On a phone the frame hugs its words, so the name follows them in flow and sits on the edge by a margin as
|
|
681
|
+
// deep as the frame's padding (an absolute name would overlap them).
|
|
682
|
+
return [typeLedAside('top'), {
|
|
683
|
+
t: 'Container', es: 'box', role: OpeningRole.Words,
|
|
684
|
+
lay: { position: 'absolute', left: '0px', bottom: '0px', width: '100%', zIndex: '1', padding: `0px ${LAPTOP_SIDE_PX}px`, overflow: 'visible' },
|
|
685
|
+
resp: { mobile: { position: 'relative', left: 'auto', bottom: 'auto', padding: '0px', margin: `auto 0px calc(-1 * ${phoneFramePad(mix)}) 0px` } },
|
|
686
|
+
c: [title({ fontSize: sizedPx(line, LAPTOP_SIDE_PX, '50svh'), lineHeight: '0.82', margin: '0px', translateY: '0.16em' }, { resp: { mobile: { fontSize: phoneSize } } })],
|
|
687
|
+
}];
|
|
688
|
+
case OpeningWords.Wordmark:
|
|
689
|
+
case OpeningWords.Behind:
|
|
690
|
+
return [{
|
|
691
|
+
t: 'Container', es: 'box', role: OpeningRole.Words,
|
|
692
|
+
lay: { ...OVER(1), display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '18px', textAlign: 'center', margin: 'auto 0px auto 0px', width: '100%' },
|
|
693
|
+
c: [
|
|
694
|
+
eyebrowPart({ textAlign: 'center' }),
|
|
695
|
+
title({ fontSize: sizedPx(line, LAPTOP_SIDE_PX + 24, '40svh'), lineHeight: '0.9', margin: '0px', textAlign: 'center' }, { resp: { mobile: { fontSize: phoneSize } } }),
|
|
696
|
+
linePart({ textAlign: 'center' }), typeLedLead({ textAlign: 'center' }), actionsPart(true),
|
|
697
|
+
],
|
|
698
|
+
}];
|
|
699
|
+
case OpeningWords.Apart: {
|
|
700
|
+
const [apart] = wordsNodes({ ...mix, media: OpeningMedia.Photo }, ctx).filter(n => n.role === OpeningRole.Apart);
|
|
701
|
+
return [apart, typeLedAside('bottom')];
|
|
702
|
+
}
|
|
703
|
+
default:
|
|
704
|
+
return [{
|
|
705
|
+
t: 'Container', es: 'box', role: OpeningRole.Words,
|
|
706
|
+
lay: { ...OVER(1), display: 'flex', flexDirection: 'column', gap: '14px', maxWidth: '760px' },
|
|
707
|
+
enter: 'heroText',
|
|
708
|
+
c: [eyebrowPart(), title({}), typeLedLead(), actionsPart()],
|
|
709
|
+
}];
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
557
713
|
/** The words, as the mix places them. Display sizes are measured on the look's own face (never a guess — R-H6): a laptop
|
|
558
714
|
* line by the whole name, a phone by its longest word, so a word is never cut by the screen. */
|
|
559
715
|
function wordsNodes(mix: OpeningMix, ctx: OpeningContext): PatternNode[] {
|
|
716
|
+
if (mix.media === OpeningMedia.None) return typeLedWordsNodes(mix, ctx);
|
|
560
717
|
const { line, longest } = nameEm(ctx);
|
|
561
718
|
const phoneSize = sizedPx(longest, PHONE_SIDE_PX, '22vw');
|
|
562
719
|
switch (mix.words) {
|