@vectoriox/iox-ui 5.180.0 → 5.182.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.
@@ -4,6 +4,7 @@ import { layoutColumnPx, layoutGutterPx } from './layout-column';
4
4
  import { layoutRoomPx, screenFontSize, screenWordOverflowPx } from './layout-language';
5
5
  import { PatternGlobalPosition, PatternNode, SITE_PATTERNS, SitePattern } from './patterns';
6
6
  import { SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
7
+ import type { GenerationTier } from './site-plan.model';
7
8
 
8
9
  /**
9
10
  * FOOTER INGREDIENTS (list-ingredients-plan.md LI5): a site's footer is a MIX — an arrangement, the blocks it holds, how
@@ -244,6 +245,31 @@ export function footerTokenOf(mix: FooterMix): string {
244
245
  return `${FOOTER_TOKEN}:${(F.fingerprint as ReadonlyArray<string>).map(k => mix[k as keyof FooterMix]).join('/')}`;
245
246
  }
246
247
 
248
+ /**
249
+ * What a visitor READS a footer by (the J10 re-score of 2026-11-25): how it is arranged and how it closes,
250
+ * `footer:<arrange>/<closing>` — its ground alone does not make it another footer ("Let's talk." over three columns reads
251
+ * the same on a dark band and on a soft one; four J10 footers did, each "unlike" by its ground). A mix or its token.
252
+ */
253
+ export function footerFaceOf(footer: FooterMix | string): string {
254
+ const keys = F.fingerprint as ReadonlyArray<string>;
255
+ const words = typeof footer === 'string' ? footer.replace(`${FOOTER_TOKEN}:`, '').split('/') : keys.map(k => String(footer[k as keyof FooterMix]));
256
+ const at = (k: string) => words[keys.indexOf(k)] ?? '';
257
+ return `${FOOTER_TOKEN}:${at(FooterIngredient.Arrange)}/${at(FooterIngredient.Closing)}`;
258
+ }
259
+
260
+ /** AW-D23 / AW12-D13: a word every plan wears (`all`) or one the award tier alone is offered (`pro`). */
261
+ export function footerWordTier(ingredient: `${FooterIngredient}`, word: string): 'all' | 'pro' {
262
+ return (F.tiers as Readonly<Record<string, string>>)[`${ingredient}.${word}`] === 'pro' ? 'pro' : 'all';
263
+ }
264
+
265
+ /** The award tier (a value import of site-plan.model here reorders the generation-core load). */
266
+ const AWARD = 'award' as `${GenerationTier}`;
267
+
268
+ /** May a footer at `tier` wear this word? No tier named: every drawn word (as before the tier was asked). */
269
+ export function footerWordOffered(ingredient: `${FooterIngredient}`, word: string, tier?: `${GenerationTier}`): boolean {
270
+ return !tier || tier === AWARD || footerWordTier(ingredient, word) === 'all';
271
+ }
272
+
247
273
  /** A footer token in words: `footer:columns/none/inverse` → "columns · none · inverse". */
248
274
  export const footerTokenWords = (token: string): string => token.replace(`${FOOTER_TOKEN}:`, '').split('/').join(' · ');
249
275
 
@@ -345,11 +371,26 @@ const holdsBrand = (mix: FooterMix): boolean => mix.arrange !== FooterArrange.Li
345
371
  /** AW12-D15: the call word for a kind of business — closed copy (the contract's `FOOTER.callWords`), in the site's
346
372
  * language. */
347
373
  export function footerCallWord(type?: string, locale?: string): string {
348
- const rows = F.callWords as unknown as ReadonlyArray<{ text: string; he: string; types: ReadonlyArray<string> }>;
349
- const row = rows.find(r => type && r.types.includes(type)) ?? rows[rows.length - 1];
374
+ const row = callWordRow(type);
350
375
  return locale === 'he' ? row.he : row.text;
351
376
  }
352
377
 
378
+ /** A row of the contract's `FOOTER.callWords` (`line` / `lineHe` since the J10 re-score). */
379
+ interface CallWordRow { text: string; he: string; line?: string; lineHe?: string; types: ReadonlyArray<string> }
380
+
381
+ /** The first row naming the kind of business, else everyone's (the last). */
382
+ function callWordRow(type?: string): CallWordRow {
383
+ const rows = F.callWords as unknown as ReadonlyArray<CallWordRow>;
384
+ return rows.find(r => type && r.types.includes(type)) ?? rows[rows.length - 1];
385
+ }
386
+
387
+ /** The J10 re-score (2026-11-25): the call closing's line above its button — closed copy for the kind of business (the
388
+ * contract's `FOOTER.callWords` row), in the site's language; null when the row has none (the part keeps its own). */
389
+ export function footerCallLine(type?: string, locale?: string): string | null {
390
+ const row = callWordRow(type);
391
+ return (locale === 'he' ? row.lineHe : row.line) ?? null;
392
+ }
393
+
353
394
  /** The smallest px a token's size reaches (`clamp(28px, …)` → 28, `40px` → 40), or null. */
354
395
  function smallestPx(value: string | undefined): number | null {
355
396
  const m = /^\s*(?:clamp\(\s*)?([\d.]+)px/.exec(value ?? '');
@@ -514,6 +555,15 @@ function callWord(ctx: FooterContext): PatternNode {
514
555
  return { ...laid(node, { fontSize: columnSize(widthEm(text, ctx, 'link-display'), ctx) }), text, textHe: footerCallWord(ctx.type, 'he') };
515
556
  }
516
557
 
558
+ /** The call closing (`closing:call`): its line is the kind of business's (`footerCallLine`), its button the part's. */
559
+ function callPart(ctx: FooterContext): PatternNode {
560
+ const node = part('call');
561
+ const line = footerCallLine(ctx.type);
562
+ const lineHe = footerCallLine(ctx.type, 'he');
563
+ if (!line) return node;
564
+ return { ...node, c: (node.c ?? []).map(n => (n.slot === 'closing' ? { ...n, text: line, ...(lineHe ? { textHe: lineHe } : {}) } : n)) };
565
+ }
566
+
517
567
  /** A block it holds: how to reach the business leaves its city to the visit block when the footer holds both. */
518
568
  function holdPart(hold: string, mix: FooterMix): PatternNode {
519
569
  const node = part(hold);
@@ -598,7 +648,7 @@ export function footerPattern(given: FooterMix, ctx: FooterContext): SitePattern
598
648
  const mix = drawnFooterMix(given).mix;
599
649
  const plain = mix.ground === FooterGround.Plain;
600
650
  const opens = {
601
- [FooterClosing.Call]: () => [mix.arrange === FooterArrange.Columns ? part('call') : centred(part('call'))],
651
+ [FooterClosing.Call]: () => [mix.arrange === FooterArrange.Columns ? callPart(ctx) : centred(callPart(ctx))],
602
652
  [FooterClosing.Statement]: () => [part('statement')],
603
653
  [FooterClosing.Word]: () => [callWord(ctx)],
604
654
  } as Readonly<Record<string, () => PatternNode[]>>;
@@ -650,22 +700,36 @@ const MEND_ORDER: ReadonlyArray<FooterIngredient.Closing | FooterIngredient.Grou
650
700
  ];
651
701
 
652
702
  /**
653
- * A footer no other site wears (R-H10): the mix when its token is free, else the nearest mix whose token is — one changed
654
- * ingredient before two, in `MEND_ORDER`, each word in the table's order — checked again (`checkFooter`), and said. When
655
- * every footer is worn, the mix as it is. Pure, deterministic.
703
+ * A footer no other site wears (R-H10): the mix when no other site's footer READS like it (`footerFaceOf` — the same
704
+ * arrangement and closing, whatever the ground), else the nearest mix that reads otherwise — one changed ingredient before
705
+ * two, in `MEND_ORDER`, each word in the table's order and offered at `tier` (AW12-D13: a Basic site is never given an
706
+ * award word) — checked again (`checkFooter`), and said. When every face is worn, a free token is enough (the plan's own,
707
+ * else the nearest); when every footer is worn, the mix as it is. Pure, deterministic.
656
708
  */
657
- export function distinctFooter(mix: FooterMix, taken: ReadonlyArray<string>, ctx: FooterContext): { mix: FooterMix; repairs: FooterRepair[] } {
709
+ export function distinctFooter(mix: FooterMix, taken: ReadonlyArray<string>, ctx: FooterContext, tier?: `${GenerationTier}`): { mix: FooterMix; repairs: FooterRepair[] } {
658
710
  const used = new Set(taken);
659
- if (!used.has(footerTokenOf(mix))) return { mix, repairs: [] };
711
+ const faces = new Set(taken.map(footerFaceOf));
712
+ const free = (m: FooterMix, byFace: boolean) => !used.has(footerTokenOf(m)) && (!byFace || !faces.has(footerFaceOf(m)));
713
+ if (free(mix, true)) return { mix, repairs: [] };
714
+ const words = (k: FooterIngredient) => footerWords(k).filter(w => footerWordOffered(k, w, tier));
660
715
  const tries: FooterMix[] = [];
661
- for (const k of MEND_ORDER) for (const w of footerWords(k)) tries.push({ ...mix, [k]: w });
716
+ for (const k of MEND_ORDER) for (const w of words(k)) tries.push({ ...mix, [k]: w });
662
717
  for (const [i, a] of MEND_ORDER.entries()) for (const b of MEND_ORDER.slice(i + 1)) {
663
- for (const wa of footerWords(a)) for (const wb of footerWords(b)) tries.push({ ...mix, [a]: wa, [b]: wb });
718
+ for (const wa of words(a)) for (const wb of words(b)) tries.push({ ...mix, [a]: wa, [b]: wb });
664
719
  }
665
- for (const t of tries) {
666
- const checked = checkFooter(t, ctx);
667
- if (checked.repairs.length || used.has(footerTokenOf(checked.mix))) continue;
668
- return { mix: checked.mix, repairs: [{ code: FooterRepairCode.Worn, said: `another site wears ${footerTokenWords(footerTokenOf(mix))}: this one is ${footerTokenWords(footerTokenOf(checked.mix))}` }] };
720
+ const said = (to: FooterMix): FooterRepair[] => [{
721
+ code: FooterRepairCode.Worn,
722
+ said: used.has(footerTokenOf(mix))
723
+ ? `another site wears ${footerTokenWords(footerTokenOf(mix))}: this one is ${footerTokenWords(footerTokenOf(to))}`
724
+ : `another site's footer already reads ${footerTokenWords(footerFaceOf(mix))}: this one is ${footerTokenWords(footerTokenOf(to))}`,
725
+ }];
726
+ for (const byFace of [true, false]) {
727
+ if (!byFace && free(mix, false)) return { mix, repairs: [] };
728
+ for (const t of tries) {
729
+ const checked = checkFooter(t, ctx);
730
+ if (checked.repairs.length || !free(checked.mix, byFace)) continue;
731
+ return { mix: checked.mix, repairs: said(checked.mix) };
732
+ }
669
733
  }
670
734
  return { mix, repairs: [] };
671
735
  }
@@ -673,9 +737,9 @@ export function distinctFooter(mix: FooterMix, taken: ReadonlyArray<string>, ctx
673
737
  /** A plan's footer made distinct (R-H10): `distinctFooter` over the plan's own mix, the name and the look it wears; the
674
738
  * plan unchanged when nothing was mended, else with the new mix in `mixes.footer`. Pure. */
675
739
  export function withDistinctFooter<P extends { readonly business: { readonly name: string }; readonly design: Readonly<Partial<DesignChoices>>; readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string>; readonly footer?: ReadonlyArray<string> } }>(
676
- plan: P, taken: ReadonlyArray<string>,
740
+ plan: P, taken: ReadonlyArray<string>, tier?: `${GenerationTier}`,
677
741
  ): { plan: P; repairs: FooterRepair[] } {
678
- const done = distinctFooter(footerMixOfPlan(plan), taken, { name: plan.business.name, design: resolveDesignChoices(JSON.parse(JSON.stringify(plan.design))) });
742
+ const done = distinctFooter(footerMixOfPlan(plan), taken, { name: plan.business.name, design: resolveDesignChoices(JSON.parse(JSON.stringify(plan.design))) }, tier);
679
743
  if (!done.repairs.length) return { plan, repairs: [] };
680
744
  return { plan: { ...plan, mixes: { ...(plan.mixes ?? {}), footer: footerMixWords(done.mix) } }, repairs: done.repairs };
681
745
  }
@@ -1,8 +1,9 @@
1
1
  import type { DesignChoices } from '@vectoriox/iox-ui/design-core';
2
+ import { fitSeoText, redirectPath, SEO_DESCRIPTION_MAX, SEO_ROBOTS_NOINDEX, SEO_TITLE_MAX } from '@vectoriox/iox-ui/seo-core';
2
3
 
3
4
  import {
4
5
  ContentFieldControl, ContentFieldPlan, ContentRole, ContentRoles, ContentTypePlan, DataSourcePlan, FIELD_TYPE_OF_CONTROL, PagePlan, PageSectionPlan,
5
- PlanDataSourceMode, PlanDataSourceType, RelativeOp, roleField, SiteBusiness, SiteLocale, SitePlan, SitePlanSourceKind, SITE_PLAN_VERSION,
6
+ PageSeoPlan, PlanDataSourceMode, PlanDataSourceType, RelativeOp, roleField, SiteBusiness, SiteLocale, SitePlan, SitePlanSourceKind, SITE_PLAN_VERSION,
6
7
  } from './site-plan.model';
7
8
  import { SiteTemplate, STUDIO_TEMPLATE } from './templates';
8
9
 
@@ -14,6 +15,11 @@ import { SiteTemplate, STUDIO_TEMPLATE } from './templates';
14
15
  * `story.long-form` section holding the owner's own words, paragraphs kept. The home page, the contact page and the
15
16
  * header and footer come from the template (the Studio's by default), the look from the owner's pick. Pure: iox-cms
16
17
  * reads its scan into an `ImportReading` and builds the plan here, and so may any screen that shows it.
18
+ *
19
+ * X6: what search knew of each page moves with it — its old title and line become the page's `seo` words (the home
20
+ * page's too), and a page the old site kept out of search moves kept out (`'noindex, follow'`, out of the menu).
21
+ * X7: every moved page and item keeps the old address it was read from, and `importRedirects` lists the redirects from
22
+ * those addresses to the new ones.
17
23
  */
18
24
 
19
25
  /** One item of a list the scan found, in the owner's own words. */
@@ -57,7 +63,17 @@ export interface ImportedPage {
57
63
  readonly title: string;
58
64
  /** Its own text: paragraphs, a blank line between them. A page with none is not moved. */
59
65
  readonly text: string;
60
- /** Its meta description — the line under its name. */
66
+ /** Its meta description — the line under its name in a search result (X6: the page's `seo.description`). */
67
+ readonly description?: string;
68
+ /** X6: its `<title>` — what a search result named it, when the page said (else its name stands). */
69
+ readonly seoTitle?: string;
70
+ /** X6: the old site kept it out of search (`robots: noindex`) — it moves kept out, and out of the menu. */
71
+ readonly noindex?: boolean;
72
+ }
73
+
74
+ /** X6: what search knew of the old home page — the new home page carries its words. */
75
+ export interface ImportedHome {
76
+ readonly seoTitle?: string;
61
77
  readonly description?: string;
62
78
  }
63
79
 
@@ -68,6 +84,8 @@ export interface ImportReading {
68
84
  readonly locale?: `${SiteLocale}`;
69
85
  readonly lists: ReadonlyArray<ImportedList>;
70
86
  readonly pages: ReadonlyArray<ImportedPage>;
87
+ /** X6: the old home page's search words, when it had some. */
88
+ readonly home?: ImportedHome;
71
89
  }
72
90
 
73
91
  export interface ImportPlanInput {
@@ -107,6 +125,66 @@ export function importedPicturesOf(plan: Pick<SitePlan, 'source' | 'contentTypes
107
125
  return [...found];
108
126
  }
109
127
 
128
+ /** X6: a moved page's search words — its old title and line within seo-core's limits, kept out of search when it was. */
129
+ function seoOfImported(title: string | undefined, description: string | undefined, noindex = false): PageSeoPlan | undefined {
130
+ const t = title?.trim() ? fitSeoText(title, SEO_TITLE_MAX) : '';
131
+ const d = description?.trim() ? fitSeoText(description, SEO_DESCRIPTION_MAX) : '';
132
+ const seo: PageSeoPlan = { ...(t ? { title: t } : {}), ...(d ? { description: d } : {}), ...(noindex ? { robots: SEO_ROBOTS_NOINDEX } : {}) };
133
+ return Object.keys(seo).length ? seo : undefined;
134
+ }
135
+
136
+ /** The old address of a list's own page — its items' site and their common path (`https://old.site/blog`), or none. */
137
+ function listAddressOf(list: ImportedList): string | undefined {
138
+ if (!list.path) return undefined;
139
+ try {
140
+ return new URL(list.path, list.items[0].from).href;
141
+ } catch {
142
+ return undefined;
143
+ }
144
+ }
145
+
146
+ /** One redirect an import makes: the old address's path → the page that now holds what it held. */
147
+ export interface ImportRedirect {
148
+ /** The old path (`redirectPath` of the address it was read from). */
149
+ readonly from: string;
150
+ /** The new path — a page's route, or an item's (`/work/blue-bowl`). */
151
+ readonly to: string;
152
+ }
153
+
154
+ /**
155
+ * Bring my site X7: the redirects an import plan makes — every moved page's and real item's old address (its path) to
156
+ * where it now lives, each old path once, in plan order. An address that already IS its new path needs none and is not
157
+ * listed. Whether each may be written (a page that answers there, a chain) is the CMS's question at build time, against
158
+ * the studio as it is (seo-core `redirectRefusal`). A plan read from no site makes none.
159
+ */
160
+ export function importRedirects(plan: Pick<SitePlan, 'source' | 'contentTypes' | 'dataSources' | 'pages'> | null | undefined): ImportRedirect[] {
161
+ if (plan?.source?.kind !== SitePlanSourceKind.Import) return [];
162
+ const out: ImportRedirect[] = [];
163
+ const seen = new Set<string>();
164
+ const add = (address: string | undefined, to: string): void => {
165
+ const from = redirectPath(address);
166
+ const target = redirectPath(to);
167
+ if (!from || !target || from === '/' || from === target || seen.has(from)) return;
168
+ seen.add(from);
169
+ out.push({ from, to: target });
170
+ };
171
+ for (const page of plan.pages ?? []) if (page.importedFrom && !page.routeSource) add(page.importedFrom, page.route);
172
+ for (const type of plan.contentTypes ?? []) {
173
+ const from = type.seed?.importedFrom;
174
+ if (!from?.length) continue;
175
+ const page = (plan.pages ?? []).find(p => p.template === type.name && p.routeSource);
176
+ const source = page && (plan.dataSources ?? []).find(d => d.alias === page.routeSource);
177
+ const lookup = source && 'filterByRouteParam' in source ? source.filterByRouteParam : undefined;
178
+ const values = lookup ? type.seed?.perItem?.[lookup.field] : undefined;
179
+ if (!page || !lookup || !values) continue;
180
+ from.forEach((address, i) => {
181
+ const value = values[i];
182
+ if (typeof value === 'string' && value) add(address, page.route.replace(`:${lookup.routeParam}`, encodeURIComponent(value)));
183
+ });
184
+ }
185
+ return out;
186
+ }
187
+
110
188
  /** The patterns an import places (contract `site.patterns`). */
111
189
  export enum ImportPattern {
112
190
  PageHeader = 'page-header.simple',
@@ -354,8 +432,9 @@ export function planImport(reading: ImportReading, input: ImportPlanInput): Impo
354
432
  const route = routes.claim(base && !routes.has(base) && base !== HOME_ROUTE ? base : `/${importSlug(list.label) || name.toLowerCase()}`);
355
433
  routes.claim(`${route}/:${ITEM_PARAM}`);
356
434
  const key = keys.claim(importSlug(list.label) || name.toLowerCase());
435
+ const listAddress = listAddressOf(list);
357
436
  listPages.push({
358
- key, name: list.label, route, inNav: true, archetype: COLLECTION_ARCHETYPE,
437
+ key, name: list.label, route, inNav: true, archetype: COLLECTION_ARCHETYPE, ...(listAddress ? { importedFrom: listAddress } : {}),
359
438
  sections: [pageHeader(list.label), { pattern: ImportPattern.CardGrid, binding: own.list, without: [...WITHOUT.cardGridHeader] }],
360
439
  });
361
440
  listPages.push({
@@ -378,7 +457,11 @@ export function planImport(reading: ImportReading, input: ImportPlanInput): Impo
378
457
  const body = page.template && typeOfMatched && page.template === typeOfMatched.name && roleField(typeOfMatched, ContentRole.Body)
379
458
  && !sections.some(s => s.pattern === ImportPattern.ItemBody);
380
459
  if (body) sections.splice(Math.max(1, sections.findIndex(s => s.pattern === ImportPattern.ItemHero) + 1), 0, { pattern: ImportPattern.ItemBody });
381
- frame.push({ ...page, sections });
460
+ // X6: the home page carries what search knew of the old one.
461
+ const seo = page.isHome ? seoOfImported(reading.home?.seoTitle, reading.home?.description) : undefined;
462
+ // X7: the template's list page holds the list that took its type's place — its old address redirects here.
463
+ const listAddress = matched && !page.template && templateParts.get(matched.type.name)!.pages.has(page.key) ? listAddressOf(matched.list) : undefined;
464
+ frame.push({ ...page, ...(seo ? { seo } : {}), ...(listAddress ? { importedFrom: listAddress } : {}), sections });
382
465
  }
383
466
 
384
467
  // The owner's pages of words.
@@ -391,9 +474,10 @@ export function planImport(reading: ImportReading, input: ImportPlanInput): Impo
391
474
  if (!base || base === HOME_ROUTE) continue; // the home page is rebuilt from the template
392
475
  if (routes.has(base) && frame.some(p => p.route === base)) continue; // the template's contact page stands for it
393
476
  const route = routes.claim(base);
477
+ const seo = seoOfImported(page.seoTitle || title, page.description, page.noindex);
394
478
  textPages.push({
395
- key: keys.claim(importSlug(base.slice(1)) || importSlug(title) || 'page'), name: title, route, inNav: route.split('/').length === 2,
396
- archetype: ABOUT_ARCHETYPE,
479
+ key: keys.claim(importSlug(base.slice(1)) || importSlug(title) || 'page'), name: title, route, inNav: !page.noindex && route.split('/').length === 2,
480
+ archetype: ABOUT_ARCHETYPE, ...(seo ? { seo } : {}), importedFrom: page.from,
397
481
  sections: [pageHeader(title, page.description?.trim() || undefined), { pattern: ImportPattern.LongForm, slots: { body1: text }, without: [...WITHOUT.longForm] }],
398
482
  });
399
483
  }
@@ -292,6 +292,8 @@ export const PLAN_WIRE_DERIVED: Readonly<Record<string, string>> = {
292
292
  sourceImport: 'the AI never writes an import plan (Bring my site X4 — planImport)',
293
293
  'roles.body': "an imported item's own text (Bring my site X4) — never the model's",
294
294
  'seed.importedFrom': 'the old addresses of real items read from a site (Bring my site X4) — never the model\'s',
295
+ 'page.importedFrom': "the old address a page of the owner's words was read from (Bring my site X7) — never the model's",
296
+ 'pageSeo.robots': "an old page kept out of search (Bring my site X6) — never the model's",
295
297
  design: "the owner's pick (the context)",
296
298
  'plan.film': "the owner's film, set by the build (SC6b)",
297
299
  film: "the owner's film, set by the build (SC6b)",
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  buildPopupRecipe, CompositeNode, CompositeNodeFactory, findByRole, POPUP_BODY_MAX_CHARS, POPUP_KIND_MIX, POPUP_TITLE_MAX_WORDS, PopupAgain, PopupArrive,
3
- PopupArt, PopupForm, PopupKind, PopupRole, popupWords, removeFromComposite,
3
+ PopupArt, PopupForm, PopupKind, PopupRole, PopupTrait, popupWords, removeFromComposite,
4
4
  } from '@vectoriox/iox-ui/composite-core';
5
5
 
6
6
  import { SPEC_SITE_LAYOUT } from './site-spec.generated';
7
7
  import { DEFAULT_SITE_LOCALE, PlanStatedFact, SitePlan } from './site-plan.model';
8
+ import type { SerializedNode } from './serialized-node';
8
9
 
9
10
  /**
10
11
  * THE GENERATED POPUP (popups-plan.md §10, PU3; R-H1, R-H6). A generated site gets a popup ONLY from the owner's popup lines
@@ -39,6 +40,15 @@ export const POPUP_LINK_WORD = P.wire.link;
39
40
  /** The global's id — one popup per site. */
40
41
  export const POPUP_GLOBAL_ID = 'popup';
41
42
 
43
+ /** The type a popup is (PU-D1: a Dialog, never a new node type). */
44
+ const POPUP_NODE_TYPE = 'Dialog';
45
+
46
+ /** A popup: a Dialog carrying a popup kind (composite-core `PopupTrait.Kind`) — any other Dialog (a consent banner, a
47
+ * lightbox, a cart drawer) is not one. ONE test for the gate, the run's notices and iox-cms's slots. */
48
+ export function isPopupNode(node: Pick<SerializedNode, 'type' | 'props'> | null | undefined): boolean {
49
+ return node?.type === POPUP_NODE_TYPE && (Object.values(PopupKind) as unknown[]).includes(node.props?.[PopupTrait.Kind]);
50
+ }
51
+
42
52
  export class PopupMixError extends Error {}
43
53
 
44
54
  /** The words on the wire: `<ingredient>:<word>` for every word of the wire's ingredients but the `never` ones, then the
@@ -1,11 +1,15 @@
1
+ import { PopupRole } from '@vectoriox/iox-ui/composite-core';
2
+
1
3
  import { ComposedPlaceholder, ComposeIssue, ComposeIssueCode } from './compose-site';
2
4
  import type { LayoutPhotoAddress } from './compose-site';
3
5
  import type { LegalContext } from './legal';
4
6
  import { GenerationTier, SitePlan, SitePlanSource } from './site-plan.model';
5
7
  import { SitePlanIssueCode } from './validate-site-plan';
6
8
  import { planSells } from './shop-plan';
7
- import { importedPicturesOf } from './import-plan';
9
+ import { importedPicturesOf, importRedirects } from './import-plan';
8
10
  import type { PictureSupply, TypeLed } from './type-led';
11
+ import { isPopupNode, POPUP_GLOBAL_ID } from './popup-plan';
12
+ import { SerializedNode, walkSerialized } from './serialized-node';
9
13
 
10
14
  /**
11
15
  * A site build's WIRE vocabulary (AI plan §3b, W2): what iox-cms's `site-builds` API answers and what every
@@ -59,6 +63,9 @@ export enum BuildStep {
59
63
  Shop = 'shop',
60
64
  DataSources = 'data-sources',
61
65
  Pages = 'pages',
66
+ /** Bring my site X7: the owner's old addresses answer with a 301 to where each page and item now lives — only in a run
67
+ * whose plan was read from a site and moved something to a new address (`importRedirects`). */
68
+ Redirects = 'redirects',
62
69
  Globals = 'globals',
63
70
  Look = 'look',
64
71
  }
@@ -66,11 +73,14 @@ export enum BuildStep {
66
73
  export const BUILD_STEPS: ReadonlyArray<BuildStep> = Object.values(BuildStep);
67
74
 
68
75
  /** The steps a build of `plan` takes, in order: every one, the shop's only when the plan sells (commerce G1), the imported
69
- * pictures' only when the plan was read from a site that has some (X5). */
76
+ * pictures' only when the plan was read from a site that has some (X5), the redirects' only when it moved an old address
77
+ * (X7). */
70
78
  export function buildStepsOf(plan: unknown): BuildStep[] {
71
79
  const sells = planSells(plan);
72
80
  const pictures = importedPicturesOf(plan as SitePlan).length > 0;
73
- return BUILD_STEPS.filter(step => (step !== BuildStep.Shop || sells) && (step !== BuildStep.ImportPictures || pictures));
81
+ const redirects = importRedirects(plan as SitePlan).length > 0;
82
+ return BUILD_STEPS.filter(step => (step !== BuildStep.Shop || sells) && (step !== BuildStep.ImportPictures || pictures)
83
+ && (step !== BuildStep.Redirects || redirects));
74
84
  }
75
85
 
76
86
  export enum StepState {
@@ -101,6 +111,9 @@ export enum CreatedKind {
101
111
  /** RD3-D3 (a) Replace: a page an earlier Undo kept, moved aside (`/<route>-previous`, a draft) so the plan's page takes
102
112
  * its address — Undo puts it back while it is as the move left it and its address is free (`CreatedRecord.from`). */
103
113
  PageMoved = 'page-moved',
114
+ /** Bring my site X7: a redirect from one of the owner's old addresses (`source: 'import'`) — removed by Undo while it is
115
+ * as the build wrote it. */
116
+ Redirect = 'redirect',
104
117
  Global = 'global',
105
118
  Look = 'look',
106
119
  }
@@ -213,6 +226,14 @@ export enum BuildNoticeCode {
213
226
  * or past the plan's picture or size limit) — the items show none in their place (never the old site's), said once,
214
227
  * so the owner adds them in the builder. */
215
228
  ImportPicturesLeft = 'import-pictures-left',
229
+ /** iox-ui#155 (popups PU3): Keep mine left the studio's own popup in the popup's place, so the popup the build made
230
+ * from the owner's news was not written — said once, so the owner knows the news is not on the site and where to
231
+ * show it (Replace, or the builder). */
232
+ PopupKept = 'popup-kept',
233
+ /** Bring my site X7: some old addresses were not redirected — a page of the site answers there, or it would chain to
234
+ * another redirect (seo-core `redirectRefusal`); said once with how many, so the owner knows those links land on the
235
+ * page that now stands there (or adds a redirect of their own). */
236
+ RedirectsRefused = 'redirects-refused',
216
237
  }
217
238
 
218
239
  /** RD3-D3 (a): what a build does with a page an earlier Undo kept at an address its plan builds — the header and footer's
@@ -282,6 +303,29 @@ export interface BuildNotice {
282
303
  detail: string;
283
304
  }
284
305
 
306
+ /** The popup's words the owner reads (its title and body — never the mechanism's), for a notice's detail. */
307
+ function popupWordsOf(popup: SerializedNode): string {
308
+ const words: string[] = [];
309
+ walkSerialized(popup.children ?? [], n => {
310
+ const said = typeof n.props?.['content'] === 'string' ? n.props['content'].trim() : '';
311
+ if (said && (n.role === PopupRole.Title || n.role === PopupRole.Body)) words.push(said);
312
+ });
313
+ return words.join(' — ');
314
+ }
315
+
316
+ /**
317
+ * iox-ui#155: the build composed a popup (`POPUP_GLOBAL_ID`) and the owner chose Keep mine over the studio's own popup at
318
+ * that id — the composed one is not written (iox-cms `keptInPlace`), so the news it carried is not on the site. Said once
319
+ * (`BuildNoticeCode.PopupKept`) with the words that were not shown; the screen shows the code's own sentence. No composed
320
+ * popup, or nothing kept at its id (Replace, a first build): nothing said. Pure — the dry run and the run say the same.
321
+ */
322
+ export function popupKeptNotices(composedGlobals: ReadonlyArray<SerializedNode>, keptInPlace: ReadonlyArray<Pick<SerializedNode, 'id'>>): BuildNotice[] {
323
+ const composed = composedGlobals.find(g => g.id === POPUP_GLOBAL_ID && isPopupNode(g));
324
+ if (!composed || !keptInPlace.some(g => g.id === POPUP_GLOBAL_ID)) return [];
325
+ const words = popupWordsOf(composed);
326
+ return [{ code: BuildNoticeCode.PopupKept, detail: `the studio's own popup stays${words ? `, so "${words}" is not shown` : ''} — Replace puts the build's popup in its place` }];
327
+ }
328
+
285
329
  /**
286
330
  * What a run's decisions hold that its pages are composed with (the server's `BuildDecisions` carries more) — read by
287
331
  * harness-core `runComposeContext`, the ONE context every compose of a run's plan takes: its steps, its checks, a
@@ -399,6 +443,7 @@ export const buildKeys = {
399
443
  global: (nodeId: string) => `global:${nodeId}`,
400
444
  look: () => 'look',
401
445
  pageMoved: (pageId: string) => `page-moved:${pageId}`,
446
+ redirect: (from: string) => `redirect:${from}`,
402
447
  } as const;
403
448
 
404
449
  /** The id of the page a run made for the plan's home page, or null (not made yet, or no home page). */
@@ -438,6 +483,8 @@ export interface BuildStepFacts {
438
483
  items: number;
439
484
  /** X5: the pictures an import copies from the owner's site (0 = not an import). */
440
485
  pictures: number;
486
+ /** X7: the old addresses an import redirects (0 = not an import, or nothing moved). */
487
+ redirects: number;
441
488
  /** Commerce G1: sample products for the shop (0 = the plan sells nothing) and their categories. */
442
489
  products: number;
443
490
  categories: number;
@@ -461,6 +508,7 @@ export function buildStepFacts(plan: SitePlan, actions: Readonly<Record<string,
461
508
  contentTypeActions,
462
509
  items: plan.contentTypes.reduce((n, t) => n + (t.seed?.count ?? 0), 0),
463
510
  pictures: importedPicturesOf(plan).length,
511
+ redirects: importRedirects(plan).length,
464
512
  products: plan.shop?.products.length ?? 0,
465
513
  categories: plan.shop?.categories.length ?? 0,
466
514
  pages: plan.pages.length,
@@ -266,6 +266,9 @@ export interface PageSectionPlan {
266
266
  export interface PageSeoPlan {
267
267
  readonly title?: string;
268
268
  readonly description?: string;
269
+ /** Bring my site X6: a page the owner's old site kept out of search moves with `'noindex, follow'` (seo-core
270
+ * `SEO_ROBOTS_OPTIONS`). Only on an import plan; never a model's. */
271
+ readonly robots?: string;
269
272
  }
270
273
 
271
274
  /** The kinds of page a plan is made of (contract `site.archetypes`, L0-2). */
@@ -304,6 +307,9 @@ export interface PagePlan {
304
307
  /** The inferred need this page answers (the Plan screen tags it "we added") — a harness-core need id. */
305
308
  readonly need?: SiteNeedId;
306
309
  readonly seo?: PageSeoPlan;
310
+ /** Bring my site X7: the old address (absolute) this page's words were read from — its redirect starts there
311
+ * (`importRedirects`). Only on an import plan; never a model's. */
312
+ readonly importedFrom?: string;
307
313
  /** The page from patterns — a composed page keeps them as its fallback. */
308
314
  readonly sections: ReadonlyArray<PageSectionPlan>;
309
315
  /** M8 gate 2: the page is composed in the layout language (written with the pages; the layout step fills `layout`). */
@@ -182,6 +182,7 @@ export const SPEC_SITE_PLAN_SHAPE = {
182
182
  "template?": "string — the content type a template page renders one item of",
183
183
  "routeSource?": "string — the single source read by the route param (route.* binds it)",
184
184
  "seo?": "pageSeo",
185
+ "importedFrom?": "string — Bring my site X7: the old address (absolute) a page of the owner's words was read from (generation-core planImport) — its redirect starts there. Only on an import plan; never a model's",
185
186
  "sections": "section[] — the page from patterns; a composed page keeps them as its fallback",
186
187
  "compose?": "boolean — the page is composed in the layout language (M8 gate 2): which pages is the generation’s tier (AW-D23/24) — Basic the home page and at most one other, Award every page that is no per-item or legal page; written with the pages, the layout step fills `layout`",
187
188
  "layout?": "layoutPage — the composed page (the layout step's, never the Pages request's): when present the page is stamped from it and `sections` is not",
@@ -219,7 +220,8 @@ export const SPEC_SITE_PLAN_SHAPE = {
219
220
  },
220
221
  "pageSeo": {
221
222
  "title?": "string ≤ 60 — the page title in search results (absent = the page name · the business)",
222
- "description?": "string ≤ 160 — the line under it (absent = the tagline, else the page and the business)"
223
+ "description?": "string ≤ 160 — the line under it (absent = the tagline, else the page and the business)",
224
+ "robots?": "string — seo-core SEO_ROBOTS_OPTIONS: Bring my site X6, a page the owner's old site kept out of search ('noindex, follow'). Only on an import plan; never a model's"
223
225
  },
224
226
  "section": {
225
227
  "pattern": "string — a non-global pattern id",
@@ -8971,26 +8973,52 @@ export const SPEC_SITE_LAYOUT = {
8971
8973
  {
8972
8974
  "text": "Book a table",
8973
8975
  "he": "הזמינו שולחן",
8976
+ "line": "Come hungry.",
8977
+ "lineHe": "בואו רעבים.",
8974
8978
  "types": [
8975
8979
  "restaurant",
8976
8980
  "bar-winery"
8977
8981
  ]
8978
8982
  },
8983
+ {
8984
+ "text": "Book a stay",
8985
+ "he": "הזמינו חדר",
8986
+ "line": "Stay a while.",
8987
+ "lineHe": "בואו להתארח אצלנו.",
8988
+ "types": [
8989
+ "hotel-bnb"
8990
+ ]
8991
+ },
8992
+ {
8993
+ "text": "Book a visit",
8994
+ "he": "קבעו תור",
8995
+ "line": "Make time for yourself.",
8996
+ "lineHe": "זמן לעצמך.",
8997
+ "types": [
8998
+ "salon",
8999
+ "spa",
9000
+ "yoga",
9001
+ "fitness"
9002
+ ]
9003
+ },
8979
9004
  {
8980
9005
  "text": "Visit us",
8981
9006
  "he": "בואו לבקר",
9007
+ "line": "Come and see us.",
9008
+ "lineHe": "נשמח לראות אתכם.",
8982
9009
  "types": [
8983
9010
  "cafe-bakery",
8984
9011
  "boutique",
8985
9012
  "florist",
8986
9013
  "home-goods",
8987
- "venue-events",
8988
- "hotel-bnb"
9014
+ "venue-events"
8989
9015
  ]
8990
9016
  },
8991
9017
  {
8992
9018
  "text": "Say hello",
8993
9019
  "he": "בואו נדבר",
9020
+ "line": "Let's make something.",
9021
+ "lineHe": "בואו ניצור משהו יחד.",
8994
9022
  "types": [
8995
9023
  "photographer",
8996
9024
  "interior-design",
@@ -9005,6 +9033,8 @@ export const SPEC_SITE_LAYOUT = {
9005
9033
  {
9006
9034
  "text": "Get in touch",
9007
9035
  "he": "צרו קשר",
9036
+ "line": "Let's talk.",
9037
+ "lineHe": "בואו נדבר.",
9008
9038
  "types": []
9009
9039
  }
9010
9040
  ],
@@ -1,7 +1,7 @@
1
1
  import { ARRIVE_IDS, flavorPackById, MOVE_IDS, parseHexColor, PRELOADER_IDS, SCRUB_IDS, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
2
2
  import { formPresetById } from '@vectoriox/iox-ui/forms-core';
3
3
  import { filmScreensFor, normalizeFrameSequence } from '@vectoriox/iox-ui/media-core';
4
- import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX } from '@vectoriox/iox-ui/seo-core';
4
+ import { SEO_DESCRIPTION_MAX, SEO_ROBOTS_OPTIONS, SEO_TITLE_MAX } from '@vectoriox/iox-ui/seo-core';
5
5
 
6
6
  import {
7
7
  BindScope, patternById, patternHasForm, patternLinkSlots, patternNeedsBinding, patternOptionalParts, patternRoleNeeds, patternTakesBinding, patternScopes,
@@ -152,6 +152,7 @@ const DESIGN_KEYS = shapeKeys(SHAPE['design']);
152
152
  const CONTENT_TYPE_KEYS = shapeKeys(SHAPE['contentType']);
153
153
  const ROLE_KEYS = shapeKeys(SHAPE['roles']);
154
154
  const PAGE_SEO_KEYS = shapeKeys(SHAPE['pageSeo']);
155
+ const SEO_ROBOTS_KEY = 'robots';
155
156
  const ARRAY_TYPE = 'array';
156
157
  const FIELD_KEYS = shapeKeys(SHAPE['field']);
157
158
  const SLUG_FIELD = 'slug';
@@ -586,6 +587,7 @@ function validatePages(c: Collector, list: unknown[], types: Map<string, Content
586
587
  const archetype = c.string(raw, 'archetype', path, false);
587
588
  if (archetype && !has(PAGE_ARCHETYPES, archetype)) c.add(SitePlanIssueCode.Archetype, `${path}.archetype`, `"${archetype}" is not a page type (${Object.keys(PAGE_ARCHETYPES).join(', ')})`);
588
589
  validatePageSeo(c, raw['seo'], `${path}.seo`);
590
+ c.string(raw, IMPORTED_FROM, path, false);
589
591
  const need = c.string(raw, 'need', path, false);
590
592
  if (need && !(SITE_NEED_IDS as ReadonlyArray<string>).includes(need)) c.add(SitePlanIssueCode.UnknownNeed, `${path}.need`, `"${need}" is not a need (${SITE_NEED_IDS.join(', ')})`);
591
593
 
@@ -753,7 +755,9 @@ function validatePageSeo(c: Collector, seo: unknown, path: string): void {
753
755
  const limits: Readonly<Record<string, number>> = { title: SEO_TITLE_MAX, description: SEO_DESCRIPTION_MAX };
754
756
  for (const key of PAGE_SEO_KEYS) {
755
757
  const value = c.string(seo, key, path, false);
756
- if (value && value.length > limits[key]) c.add(SitePlanIssueCode.InvalidSeo, `${path}.${key}`, `${value.length} characters — a search result shows ${limits[key]}`);
758
+ if (!value) continue;
759
+ if (key in limits && value.length > limits[key]) c.add(SitePlanIssueCode.InvalidSeo, `${path}.${key}`, `${value.length} characters — a search result shows ${limits[key]}`);
760
+ if (key === SEO_ROBOTS_KEY && !SEO_ROBOTS_OPTIONS.some(o => o.value === value)) c.add(SitePlanIssueCode.InvalidSeo, `${path}.${key}`, `"${value}" is not a robots choice`);
757
761
  }
758
762
  }
759
763
 
@@ -124,3 +124,16 @@ function compact<T extends object>(value: Record<string, unknown>): T | undefine
124
124
  }
125
125
  return (Object.keys(out).length ? out : undefined) as T | undefined;
126
126
  }
127
+
128
+ /**
129
+ * Words cut to `max` characters on a word boundary, with an ellipsis only when something was cut — a search result's
130
+ * title (`SEO_TITLE_MAX`) or line (`SEO_DESCRIPTION_MAX`). White space collapses. Shared by the composer (a composed
131
+ * page's words) and Bring my site (an old page's own title and line, X6).
132
+ */
133
+ export function fitSeoText(text: string, max: number): string {
134
+ const clean = text.replace(/\s+/g, ' ').trim();
135
+ if (clean.length <= max) return clean;
136
+ const cut = clean.slice(0, max - 1);
137
+ const at = cut.lastIndexOf(' ');
138
+ return `${(at > max / 2 ? cut.slice(0, at) : cut).trimEnd()}…`;
139
+ }
@@ -14,3 +14,4 @@ export * from './seo.model';
14
14
  export * from './normalize';
15
15
  export * from './tags';
16
16
  export * from './schema';
17
+ export * from './redirects';