@vectoriox/iox-ui 5.173.0 → 5.174.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/fesm2022/vectoriox-iox-ui-generation-core.mjs +870 -77
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +171 -143
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +306 -17
- package/harness-core/index.d.ts +86 -82
- package/package.json +1 -1
- package/src/generation-core/audit-site.ts +71 -2
- package/src/generation-core/audit-words.ts +20 -0
- package/src/generation-core/check-layout.ts +1 -1
- package/src/generation-core/check-list.ts +8 -0
- package/src/generation-core/compose-site.ts +50 -9
- package/src/generation-core/fallback-memory.ts +1 -1
- package/src/generation-core/import-plan.ts +400 -0
- package/src/generation-core/layout-fingerprint.ts +10 -2
- package/src/generation-core/list-words.ts +6 -0
- package/src/generation-core/patterns.ts +3 -1
- package/src/generation-core/plan-wire.ts +37 -8
- package/src/generation-core/plan-words.ts +7 -3
- package/src/generation-core/popup-plan.ts +232 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/showcase.ts +17 -2
- package/src/generation-core/site-build-run.ts +3 -0
- package/src/generation-core/site-plan.model.ts +35 -3
- package/src/generation-core/site-spec.generated.ts +74 -6
- package/src/generation-core/validate-site-plan.ts +46 -6
- package/src/harness-core/harness-spec.generated.ts +1 -0
- package/src/harness-core/site-analysis.ts +34 -9
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import type { DesignChoices } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
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
|
+
} from './site-plan.model';
|
|
7
|
+
import { SiteTemplate, STUDIO_TEMPLATE } from './templates';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Bring my site X4 (site-build plan §3l): what a scan of the owner's own site found → an `ImportPlan` — a Site Plan with
|
|
11
|
+
* `source: { kind: 'import', scanId }`. We rebuild, we never copy the old layout: the lists the site holds become content
|
|
12
|
+
* types with their REAL items (`sample: false`, each keeping its old address as `importedFrom`), each list gets a page of
|
|
13
|
+
* its items and a page per item rebuilt from the archetypes, and every text page becomes a page header over a
|
|
14
|
+
* `story.long-form` section holding the owner's own words, paragraphs kept. The home page, the contact page and the
|
|
15
|
+
* header and footer come from the template (the Studio's by default), the look from the owner's pick. Pure: iox-cms
|
|
16
|
+
* reads its scan into an `ImportReading` and builds the plan here, and so may any screen that shows it.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** One item of a list the scan found, in the owner's own words. */
|
|
20
|
+
export interface ImportedItem {
|
|
21
|
+
/** The old address it was read from (absolute) — kept on the item as `importedFrom` (X7 redirects it). */
|
|
22
|
+
readonly from: string;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
/** Its old slug; absent → made from the title. */
|
|
25
|
+
readonly slug?: string;
|
|
26
|
+
/** A sentence or two (an excerpt). */
|
|
27
|
+
readonly summary?: string;
|
|
28
|
+
/** Its own text at length: paragraphs, a blank line between them. */
|
|
29
|
+
readonly text?: string;
|
|
30
|
+
/** Its picture's address (the featured image). Old addresses until X5 copies them. */
|
|
31
|
+
readonly picture?: string;
|
|
32
|
+
/** Its other pictures, in order. */
|
|
33
|
+
readonly pictures?: ReadonlyArray<string>;
|
|
34
|
+
/** When — as the site gave it (a date or a year). */
|
|
35
|
+
readonly date?: string;
|
|
36
|
+
/** A short line beside its name — the first category. */
|
|
37
|
+
readonly meta?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A list the scan found: a WordPress post type, or pages sharing a URL shape. */
|
|
41
|
+
export interface ImportedList {
|
|
42
|
+
/** Where it came from — a REST base (`posts`, `projects`) or a URL shape. */
|
|
43
|
+
readonly key: string;
|
|
44
|
+
/** The site's own name for it (`Posts`, `Projects`). */
|
|
45
|
+
readonly label: string;
|
|
46
|
+
/** Its items' common address prefix (`/projects`, `/blog`), when they share one — names its route. */
|
|
47
|
+
readonly path?: string;
|
|
48
|
+
readonly items: ReadonlyArray<ImportedItem>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A page of words the scan found (not a list's item). */
|
|
52
|
+
export interface ImportedPage {
|
|
53
|
+
readonly from: string;
|
|
54
|
+
/** Its old path (`/about`, `/about/team`). */
|
|
55
|
+
readonly path: string;
|
|
56
|
+
readonly title: string;
|
|
57
|
+
/** Its own text: paragraphs, a blank line between them. A page with none is not moved. */
|
|
58
|
+
readonly text: string;
|
|
59
|
+
/** Its meta description — the line under its name. */
|
|
60
|
+
readonly description?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What iox-cms read from a scan and its items. */
|
|
64
|
+
export interface ImportReading {
|
|
65
|
+
readonly scanId: string;
|
|
66
|
+
readonly business: SiteBusiness;
|
|
67
|
+
readonly locale?: `${SiteLocale}`;
|
|
68
|
+
readonly lists: ReadonlyArray<ImportedList>;
|
|
69
|
+
readonly pages: ReadonlyArray<ImportedPage>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ImportPlanInput {
|
|
73
|
+
/** The owner's pick (the Design step). */
|
|
74
|
+
readonly design: DesignChoices;
|
|
75
|
+
/** The structure the home page, the contact page and the globals come from; absent = the Studio. */
|
|
76
|
+
readonly template?: SiteTemplate;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A Site Plan read from the owner's own site. */
|
|
80
|
+
export type ImportPlan = SitePlan & { readonly source: { readonly kind: `${SitePlanSourceKind.Import}`; readonly scanId: string } };
|
|
81
|
+
|
|
82
|
+
export function isImportPlan(plan: SitePlan): plan is ImportPlan {
|
|
83
|
+
return plan.source.kind === SitePlanSourceKind.Import;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The patterns an import places (contract `site.patterns`). */
|
|
87
|
+
export enum ImportPattern {
|
|
88
|
+
PageHeader = 'page-header.simple',
|
|
89
|
+
LongForm = 'story.long-form',
|
|
90
|
+
CardGrid = 'collection.card-grid',
|
|
91
|
+
ItemHero = 'project.hero',
|
|
92
|
+
ItemBody = 'item.body',
|
|
93
|
+
ItemGallery = 'project.gallery',
|
|
94
|
+
ItemNext = 'project.next',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The optional parts an import leaves out (each pattern's `optional`). */
|
|
98
|
+
const WITHOUT = {
|
|
99
|
+
pageHeader: ['eyebrow', 'lead'],
|
|
100
|
+
longForm: ['heading', 'lead', 'more'],
|
|
101
|
+
cardGridHeader: ['header'],
|
|
102
|
+
} as const;
|
|
103
|
+
|
|
104
|
+
/** How many pages the header lists — the rest stay reachable from their lists and links. */
|
|
105
|
+
export const IMPORT_NAV_MAX = 6;
|
|
106
|
+
/** A list's "latest" source on the home page. */
|
|
107
|
+
const LATEST_LIMIT = 3;
|
|
108
|
+
const ITEM_PARAM = 'slug';
|
|
109
|
+
const SLUG_FIELD = 'slug';
|
|
110
|
+
const HOME_ROUTE = '/';
|
|
111
|
+
const CONTACT_ARCHETYPE = 'contact';
|
|
112
|
+
const ABOUT_ARCHETYPE = 'about';
|
|
113
|
+
const COLLECTION_ARCHETYPE = 'collection';
|
|
114
|
+
const DETAIL_ARCHETYPE = 'detail';
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The words that say a list is the template's own type (the Studio's projects are a portfolio, the Practice's services,
|
|
118
|
+
* the Place's menu) — its items take the template type's place, pages and all (`/work/:slug`). One table, by type name.
|
|
119
|
+
*/
|
|
120
|
+
export const TEMPLATE_TYPE_WORDS: Readonly<Record<string, RegExp>> = {
|
|
121
|
+
projects: /\b(projects?|portfolios?|works?|case[\s-]?stud(?:y|ies)|showcase)\b/i,
|
|
122
|
+
services: /\b(services?|treatments?|offers?)\b/i,
|
|
123
|
+
menu: /\b(menus?|dishes|drinks)\b/i,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** The field each role of a list's own type is written to, in field order, and how it is edited. */
|
|
127
|
+
const OWN_FIELDS: ReadonlyArray<{ readonly role: `${ContentRole}` | null; readonly name: string; readonly control: ContentFieldControl; readonly required?: boolean }> = [
|
|
128
|
+
{ role: ContentRole.Title, name: 'title', control: ContentFieldControl.Text, required: true },
|
|
129
|
+
{ role: null, name: SLUG_FIELD, control: ContentFieldControl.Text, required: true },
|
|
130
|
+
{ role: ContentRole.Summary, name: 'summary', control: ContentFieldControl.Textarea },
|
|
131
|
+
{ role: ContentRole.Image, name: 'cover', control: ContentFieldControl.Media },
|
|
132
|
+
{ role: ContentRole.Gallery, name: 'gallery', control: ContentFieldControl.Gallery },
|
|
133
|
+
{ role: ContentRole.Date, name: 'date', control: ContentFieldControl.Text },
|
|
134
|
+
{ role: ContentRole.Meta, name: 'category', control: ContentFieldControl.Text },
|
|
135
|
+
{ role: ContentRole.Body, name: 'body', control: ContentFieldControl.Textarea },
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
/** What an item gives each role (null: nothing). */
|
|
139
|
+
function itemValue(item: ImportedItem, role: `${ContentRole}`): string | ReadonlyArray<string> | null {
|
|
140
|
+
switch (role) {
|
|
141
|
+
case ContentRole.Title: return item.title;
|
|
142
|
+
case ContentRole.Summary: return item.summary || null;
|
|
143
|
+
case ContentRole.Image: return item.picture || null;
|
|
144
|
+
case ContentRole.Gallery: return item.pictures?.length ? item.pictures : null;
|
|
145
|
+
case ContentRole.Date: return item.date || null;
|
|
146
|
+
case ContentRole.Meta: return item.meta || null;
|
|
147
|
+
case ContentRole.Body: return item.text?.trim() ? item.text.trim() : null;
|
|
148
|
+
default: return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const has = (items: ReadonlyArray<ImportedItem>, role: `${ContentRole}`) => items.some(item => itemValue(item, role) !== null);
|
|
153
|
+
|
|
154
|
+
/** Lowercase words joined by hyphens — a route segment or a slug. */
|
|
155
|
+
export function importSlug(text: string): string {
|
|
156
|
+
return text.normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Makes names unique in order: the second `a` is `a-2`. */
|
|
160
|
+
class Names {
|
|
161
|
+
private readonly taken = new Set<string>();
|
|
162
|
+
constructor(taken: Iterable<string> = []) { for (const t of taken) this.taken.add(t); }
|
|
163
|
+
has(name: string): boolean { return this.taken.has(name); }
|
|
164
|
+
claim(name: string, join = '-'): string {
|
|
165
|
+
let out = name;
|
|
166
|
+
for (let n = 2; this.taken.has(out); n++) out = `${name}${join}${n}`;
|
|
167
|
+
this.taken.add(out);
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const camel = (slug: string) => slug.replace(/-([a-z0-9])/g, (_m, c: string) => c.toUpperCase());
|
|
173
|
+
|
|
174
|
+
/** A route the plan accepts from an old path: each segment as lowercase words; null when nothing is left. */
|
|
175
|
+
function routeOfPath(path: string | undefined): string | null {
|
|
176
|
+
if (!path) return null;
|
|
177
|
+
const segments = path.split(/[?#]/)[0].split('/').map(importSlug).filter(Boolean);
|
|
178
|
+
return segments.length ? `/${segments.join('/')}` : null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The template's pages and sources that show its content type (a list or an item of it). */
|
|
182
|
+
function templateTypeParts(template: SiteTemplate, typeName: string): { aliases: Set<string>; pages: Set<string> } {
|
|
183
|
+
const aliases = new Set(template.dataSources.filter(d => d.type === PlanDataSourceType.Relative ? false : 'contentType' in d && d.contentType === typeName).map(d => d.alias));
|
|
184
|
+
for (const d of template.dataSources) if (d.type === PlanDataSourceType.Relative && (aliases.has(d.of) || aliases.has(d.within))) aliases.add(d.alias);
|
|
185
|
+
const pages = new Set(template.pages.filter(p => p.template === typeName || (!p.isHome && p.sections.some(s => s.binding && aliases.has(s.binding)))).map(p => p.key));
|
|
186
|
+
return { aliases, pages };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** The list that takes the template type's place, if one reads as it. */
|
|
190
|
+
function templateListOf(template: SiteTemplate, lists: ReadonlyArray<ImportedList>): { type: ContentTypePlan; list: ImportedList } | null {
|
|
191
|
+
for (const type of template.contentTypes) {
|
|
192
|
+
const words = TEMPLATE_TYPE_WORDS[type.name];
|
|
193
|
+
const list = words ? lists.find(l => l.items.length && [l.key, l.label, l.path ?? ''].some(w => words.test(w.replace(/[-_/]+/g, ' ')))) : undefined;
|
|
194
|
+
if (list) return { type, list };
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** The items' slugs: their own where the site gave one, else from the title; unique within the list. */
|
|
200
|
+
function slugsOf(items: ReadonlyArray<ImportedItem>): string[] {
|
|
201
|
+
const names = new Names();
|
|
202
|
+
return items.map((item, i) => names.claim(importSlug(item.slug ?? '') || importSlug(item.title) || `item-${i + 1}`));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The real items as a seed: one value per item for each role the type plays, the slug, and each item's old address. */
|
|
206
|
+
function seedOf(type: Pick<ContentTypePlan, 'roles' | 'fields'>, items: ReadonlyArray<ImportedItem>): ContentTypePlan['seed'] {
|
|
207
|
+
const perItem: Record<string, ReadonlyArray<string | ReadonlyArray<string>>> = {};
|
|
208
|
+
const slugField = type.fields.some(f => f.name === SLUG_FIELD) ? SLUG_FIELD : null;
|
|
209
|
+
if (slugField) perItem[slugField] = slugsOf(items);
|
|
210
|
+
for (const [role, field] of Object.entries(type.roles) as Array<[`${ContentRole}`, string]>) {
|
|
211
|
+
const list = type.fields.find(f => f.name === field)?.controller === ContentFieldControl.Gallery;
|
|
212
|
+
perItem[field] = items.map(item => {
|
|
213
|
+
const value = itemValue(item, role);
|
|
214
|
+
if (list) return Array.isArray(value) ? [...value] : [];
|
|
215
|
+
return typeof value === 'string' ? value : '';
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return { count: items.length, sample: false, isPublished: true, perItem, importedFrom: items.map(i => i.from) };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const fieldOf = (name: string, control: ContentFieldControl, required?: boolean): ContentFieldPlan =>
|
|
222
|
+
({ name, type: FIELD_TYPE_OF_CONTROL[control], controller: control, ...(required ? { required: true } : {}) });
|
|
223
|
+
|
|
224
|
+
/** A list's own type: the roles its items fill, each its field (`OWN_FIELDS`). */
|
|
225
|
+
function ownType(name: string, list: ImportedList): ContentTypePlan {
|
|
226
|
+
const fields: ContentFieldPlan[] = [];
|
|
227
|
+
const roles: Record<string, string> = {};
|
|
228
|
+
for (const f of OWN_FIELDS) {
|
|
229
|
+
if (f.role && f.role !== ContentRole.Title && !has(list.items, f.role)) continue;
|
|
230
|
+
fields.push(fieldOf(f.name, f.control, f.required));
|
|
231
|
+
if (f.role) roles[f.role] = f.name;
|
|
232
|
+
}
|
|
233
|
+
const type = { name, label: list.label, roles: roles as ContentRoles, fields };
|
|
234
|
+
return { ...type, seed: seedOf(type, list.items) };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** The template's type with the list's items: its own fields, and its `body` (the items' own text) when they have one.
|
|
238
|
+
* A role the template gives a field of its own meaning (the Studio's `meta` is a location) is not filled from the site. */
|
|
239
|
+
const TEMPLATE_ROLES_FILLED: ReadonlyArray<`${ContentRole}`> = [ContentRole.Title, ContentRole.Summary, ContentRole.Image, ContentRole.Gallery, ContentRole.Date, ContentRole.Body];
|
|
240
|
+
function templateType(type: ContentTypePlan, list: ImportedList): ContentTypePlan {
|
|
241
|
+
const withBody = has(list.items, ContentRole.Body) && !roleField(type, ContentRole.Body);
|
|
242
|
+
const bodyName = new Names(type.fields.map(f => f.name)).claim('body');
|
|
243
|
+
const fields = withBody ? [...type.fields, fieldOf(bodyName, ContentFieldControl.Textarea)] : [...type.fields];
|
|
244
|
+
const roles = (withBody ? { ...type.roles, [ContentRole.Body]: bodyName } : { ...type.roles }) as ContentRoles;
|
|
245
|
+
const filled = Object.fromEntries(Object.entries(roles).filter(([role]) => TEMPLATE_ROLES_FILLED.includes(role as `${ContentRole}`))) as ContentRoles;
|
|
246
|
+
const seed = seedOf({ roles: filled, fields }, list.items)!;
|
|
247
|
+
// A field the site does not fill is written empty (never the template's sample words).
|
|
248
|
+
const empty = Object.fromEntries(fields.filter(f => !(f.name in (seed.perItem ?? {}))).map(f => [f.name, f.controller === ContentFieldControl.Gallery ? [] : '']));
|
|
249
|
+
return { name: type.name, label: list.label || type.label, roles, fields, seed: { ...seed, ...empty } };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** The sources of a list's own type: all of it, the latest few, one by its slug, and the next one. */
|
|
253
|
+
function ownSources(name: string): { list: string; latest: string; item: string; sources: DataSourcePlan[] } {
|
|
254
|
+
const list = name, latest = `${name}Latest`, item = `${name}Item`, next = `${name}Next`;
|
|
255
|
+
return {
|
|
256
|
+
list, latest, item,
|
|
257
|
+
sources: [
|
|
258
|
+
{ alias: list, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name },
|
|
259
|
+
{ alias: latest, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Query, contentType: name, limit: LATEST_LIMIT },
|
|
260
|
+
{ alias: item, type: PlanDataSourceType.Cms, mode: PlanDataSourceMode.Single, contentType: name, filterByRouteParam: { field: SLUG_FIELD, routeParam: ITEM_PARAM } },
|
|
261
|
+
{ alias: next, type: PlanDataSourceType.Relative, of: item, op: RelativeOp.SiblingsNext, within: list },
|
|
262
|
+
],
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The page of one item: its hero, its own text, its pictures, the next one (each only when the items have it). */
|
|
267
|
+
function itemSections(type: ContentTypePlan, nextLabel?: string): PageSectionPlan[] {
|
|
268
|
+
const sections: PageSectionPlan[] = [{ pattern: ImportPattern.ItemHero }];
|
|
269
|
+
if (roleField(type, ContentRole.Body)) sections.push({ pattern: ImportPattern.ItemBody });
|
|
270
|
+
if (roleField(type, ContentRole.Gallery)) sections.push({ pattern: ImportPattern.ItemGallery });
|
|
271
|
+
sections.push(nextLabel ? { pattern: ImportPattern.ItemNext, slots: { label: nextLabel } } : { pattern: ImportPattern.ItemNext });
|
|
272
|
+
return sections;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const pageHeader = (title: string, lead?: string): PageSectionPlan => lead
|
|
276
|
+
? { pattern: ImportPattern.PageHeader, slots: { title, lead }, without: ['eyebrow'] }
|
|
277
|
+
: { pattern: ImportPattern.PageHeader, slots: { title }, without: [...WITHOUT.pageHeader] };
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The scan's reading → the plan. Every list with items becomes a content type (the one that reads as the template's own
|
|
281
|
+
* takes its place, routes and all); every page with words becomes a page; nothing is invented — a page or a list the
|
|
282
|
+
* site did not have is not added, and the template's own pages are kept only where they are the site's frame (the home
|
|
283
|
+
* page, the contact page).
|
|
284
|
+
*/
|
|
285
|
+
export function planImport(reading: ImportReading, input: ImportPlanInput): ImportPlan {
|
|
286
|
+
const template = input.template ?? STUDIO_TEMPLATE;
|
|
287
|
+
const lists = reading.lists.filter(l => l.items.length > 0);
|
|
288
|
+
const matched = templateListOf(template, lists);
|
|
289
|
+
const dropped = new Set<string>(); // the template types no list fills
|
|
290
|
+
const contentTypes: ContentTypePlan[] = [];
|
|
291
|
+
const dataSources: DataSourcePlan[] = [];
|
|
292
|
+
const templateParts = new Map<string, { aliases: Set<string>; pages: Set<string> }>();
|
|
293
|
+
for (const type of template.contentTypes) {
|
|
294
|
+
const parts = templateTypeParts(template, type.name);
|
|
295
|
+
templateParts.set(type.name, parts);
|
|
296
|
+
if (matched?.type.name === type.name) {
|
|
297
|
+
contentTypes.push(templateType(type, matched.list));
|
|
298
|
+
dataSources.push(...template.dataSources.filter(d => parts.aliases.has(d.alias)));
|
|
299
|
+
} else dropped.add(type.name);
|
|
300
|
+
}
|
|
301
|
+
const droppedAliases = new Set([...dropped].flatMap(t => [...templateParts.get(t)!.aliases]));
|
|
302
|
+
const droppedPages = new Set([...dropped].flatMap(t => [...templateParts.get(t)!.pages]));
|
|
303
|
+
|
|
304
|
+
// Routes and names: the template's frame first, then the lists, then the pages.
|
|
305
|
+
const kept = template.pages.filter(p => p.isHome || p.archetype === CONTACT_ARCHETYPE || (!droppedPages.has(p.key) && matched && templateParts.get(matched.type.name)!.pages.has(p.key)));
|
|
306
|
+
const routes = new Names(kept.map(p => p.route));
|
|
307
|
+
const keys = new Names(kept.map(p => p.key));
|
|
308
|
+
const typeNames = new Names(template.contentTypes.map(t => t.name));
|
|
309
|
+
const aliases = new Names(template.dataSources.map(d => d.alias));
|
|
310
|
+
|
|
311
|
+
const listPages: PagePlan[] = [];
|
|
312
|
+
const firstLatest: { alias: string; route: string }[] = [];
|
|
313
|
+
if (matched) {
|
|
314
|
+
const listPage = template.pages.find(p => templateParts.get(matched.type.name)!.pages.has(p.key) && !p.template);
|
|
315
|
+
const latest = template.dataSources.find(d => templateParts.get(matched.type.name)!.aliases.has(d.alias) && d.type === PlanDataSourceType.Cms && d.mode === PlanDataSourceMode.Query && d.limit);
|
|
316
|
+
if (listPage && latest) firstLatest.push({ alias: latest.alias, route: listPage.route });
|
|
317
|
+
}
|
|
318
|
+
const typeOfMatched = matched ? contentTypes[0] : null;
|
|
319
|
+
|
|
320
|
+
for (const list of lists) {
|
|
321
|
+
if (list === matched?.list) continue;
|
|
322
|
+
const name = typeNames.claim(camel(importSlug(list.key) || importSlug(list.label) || 'items'), '');
|
|
323
|
+
const type = ownType(name, list);
|
|
324
|
+
const own = ownSources(name);
|
|
325
|
+
if ([own.list, own.latest, own.item, `${name}Next`].some(a => aliases.has(a))) continue; // never shadow a source
|
|
326
|
+
own.sources.forEach(s => aliases.claim(s.alias));
|
|
327
|
+
contentTypes.push(type);
|
|
328
|
+
dataSources.push(...own.sources);
|
|
329
|
+
const base = routeOfPath(list.path);
|
|
330
|
+
const route = routes.claim(base && !routes.has(base) && base !== HOME_ROUTE ? base : `/${importSlug(list.label) || name.toLowerCase()}`);
|
|
331
|
+
routes.claim(`${route}/:${ITEM_PARAM}`);
|
|
332
|
+
const key = keys.claim(importSlug(list.label) || name.toLowerCase());
|
|
333
|
+
listPages.push({
|
|
334
|
+
key, name: list.label, route, inNav: true, archetype: COLLECTION_ARCHETYPE,
|
|
335
|
+
sections: [pageHeader(list.label), { pattern: ImportPattern.CardGrid, binding: own.list, without: [...WITHOUT.cardGridHeader] }],
|
|
336
|
+
});
|
|
337
|
+
listPages.push({
|
|
338
|
+
key: keys.claim(`${key}-item`), name: list.label, route: `${route}/:${ITEM_PARAM}`, inNav: false,
|
|
339
|
+
template: name, routeSource: own.item, archetype: DETAIL_ARCHETYPE, sections: itemSections(type, list.label),
|
|
340
|
+
});
|
|
341
|
+
firstLatest.push({ alias: own.latest, route });
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// The template's frame: a section that showed a dropped type shows the first list instead, or goes.
|
|
345
|
+
const frame: PagePlan[] = [];
|
|
346
|
+
for (const page of kept) {
|
|
347
|
+
const sections: PageSectionPlan[] = [];
|
|
348
|
+
for (const section of page.sections) {
|
|
349
|
+
if (!section.binding || !droppedAliases.has(section.binding)) { sections.push(section); continue; }
|
|
350
|
+
const first = firstLatest[0];
|
|
351
|
+
if (first) sections.push({ ...section, binding: first.alias, links: { ...(section.links ?? {}), more: first.route } });
|
|
352
|
+
}
|
|
353
|
+
// The template type's item page shows the items' own text after its hero.
|
|
354
|
+
const body = page.template && typeOfMatched && page.template === typeOfMatched.name && roleField(typeOfMatched, ContentRole.Body)
|
|
355
|
+
&& !sections.some(s => s.pattern === ImportPattern.ItemBody);
|
|
356
|
+
if (body) sections.splice(Math.max(1, sections.findIndex(s => s.pattern === ImportPattern.ItemHero) + 1), 0, { pattern: ImportPattern.ItemBody });
|
|
357
|
+
frame.push({ ...page, sections });
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// The owner's pages of words.
|
|
361
|
+
const textPages: PagePlan[] = [];
|
|
362
|
+
for (const page of reading.pages) {
|
|
363
|
+
const text = page.text.trim();
|
|
364
|
+
const title = page.title.trim();
|
|
365
|
+
if (!text || !title) continue;
|
|
366
|
+
const base = routeOfPath(page.path);
|
|
367
|
+
if (!base || base === HOME_ROUTE) continue; // the home page is rebuilt from the template
|
|
368
|
+
if (routes.has(base) && frame.some(p => p.route === base)) continue; // the template's contact page stands for it
|
|
369
|
+
const route = routes.claim(base);
|
|
370
|
+
textPages.push({
|
|
371
|
+
key: keys.claim(importSlug(base.slice(1)) || importSlug(title) || 'page'), name: title, route, inNav: route.split('/').length === 2,
|
|
372
|
+
archetype: ABOUT_ARCHETYPE,
|
|
373
|
+
sections: [pageHeader(title, page.description?.trim() || undefined), { pattern: ImportPattern.LongForm, slots: { body1: text }, without: [...WITHOUT.longForm] }],
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// The header lists the lists first, then the pages, the contact page last — at most IMPORT_NAV_MAX.
|
|
378
|
+
const home = frame.filter(p => p.isHome);
|
|
379
|
+
const contact = frame.filter(p => !p.isHome && p.archetype === CONTACT_ARCHETYPE);
|
|
380
|
+
const rest = frame.filter(p => !p.isHome && p.archetype !== CONTACT_ARCHETYPE);
|
|
381
|
+
let room = IMPORT_NAV_MAX - contact.filter(p => p.inNav).length;
|
|
382
|
+
const nav = (page: PagePlan): PagePlan => {
|
|
383
|
+
if (!page.inNav) return page;
|
|
384
|
+
if (room > 0) { room--; return page; }
|
|
385
|
+
return { ...page, inNav: false };
|
|
386
|
+
};
|
|
387
|
+
const pages = [...home, ...rest.map(nav), ...listPages.map(nav), ...textPages.map(nav), ...contact];
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
version: SITE_PLAN_VERSION,
|
|
391
|
+
source: { kind: SitePlanSourceKind.Import, scanId: reading.scanId },
|
|
392
|
+
business: JSON.parse(JSON.stringify(reading.business)),
|
|
393
|
+
...(reading.locale ? { locale: reading.locale } : {}),
|
|
394
|
+
design: JSON.parse(JSON.stringify(input.design)),
|
|
395
|
+
contentTypes,
|
|
396
|
+
dataSources: JSON.parse(JSON.stringify(dataSources)),
|
|
397
|
+
pages: JSON.parse(JSON.stringify(pages)),
|
|
398
|
+
globals: JSON.parse(JSON.stringify(template.globals)),
|
|
399
|
+
};
|
|
400
|
+
}
|
|
@@ -4,6 +4,8 @@ import { layoutPresetColours, splitSide } from './check-layout';
|
|
|
4
4
|
import { LayoutColour, LayoutEnter, LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutListMix, LayoutListWho, LayoutPage, LayoutRole, LayoutSection, LayoutSectionKind, LayoutSize, LayoutTrackProp } from './layout-language';
|
|
5
5
|
import { FooterMix, footerMixOfPlan, footerTokenOf } from './footer-mix';
|
|
6
6
|
import { HeaderMix, headerTokenOf, wornHeaderOfPlan } from './header-mix';
|
|
7
|
+
import { checkPopup, popupTokenOf } from './popup-plan';
|
|
8
|
+
import { SitePlan } from './site-plan.model';
|
|
7
9
|
import { listWordTier } from './list-table';
|
|
8
10
|
import { PHOTO_LIGHT_LUMINANCE, PhotoTone } from './photo-inventory';
|
|
9
11
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
@@ -63,6 +65,9 @@ export interface LayoutFingerprint {
|
|
|
63
65
|
/** How the page's text moves by the scroll (AW10, `scrubTokenOf`): `letters`, `scrub` or `letters+scrub`; absent when
|
|
64
66
|
* neither (and on a fingerprint stored before AW10). Recorded and named in the brief, never a refusal yet (T8). */
|
|
65
67
|
scrub?: string;
|
|
68
|
+
/** The site's popup (`popupTokenOf`, popups PU3: `popup:corner`); absent when it has none. Recorded at low weight, like
|
|
69
|
+
* the consent banner's — a site is never refused for its popup. */
|
|
70
|
+
popup?: string;
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
export interface FingerprintedPage {
|
|
@@ -177,7 +182,7 @@ export function scrubTokenOf(page: LayoutPage): string | null {
|
|
|
177
182
|
|
|
178
183
|
/** A page's fingerprint, worn in `preset` and `mode`, under the site's `header` and `footer` when they are known. A photo ground opens on
|
|
179
184
|
* the page's own ground colour. */
|
|
180
|
-
export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' | 'dark', header?: HeaderMix, footer?: FooterMix): LayoutFingerprint {
|
|
185
|
+
export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' | 'dark', header?: HeaderMix, footer?: FooterMix, popup?: string | null): LayoutFingerprint {
|
|
181
186
|
const sections = page.sections ?? [];
|
|
182
187
|
const lists = listTokensOf(page);
|
|
183
188
|
const scrub = scrubTokenOf(page);
|
|
@@ -196,12 +201,15 @@ export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' |
|
|
|
196
201
|
...(header ? { header: headerTokenOf(header) } : {}),
|
|
197
202
|
...(footer ? { footer: footerTokenOf(footer) } : {}),
|
|
198
203
|
...(scrub ? { scrub } : {}),
|
|
204
|
+
...(popup ? { popup } : {}),
|
|
199
205
|
};
|
|
200
206
|
}
|
|
201
207
|
|
|
202
208
|
/** A composed page's fingerprint under its site plan's header and footer — the ONE call every reader of a plan makes. */
|
|
203
209
|
export function fingerprintOfPlanPage(page: LayoutPage, preset: string, mode: 'light' | 'dark', plan: Parameters<typeof wornHeaderOfPlan>[0] & Parameters<typeof footerMixOfPlan>[0]): LayoutFingerprint {
|
|
204
|
-
|
|
210
|
+
// PU3: the popup the plan makes (`checkPopup` reads a whole plan; a part-plan a caller builds has no popup lines).
|
|
211
|
+
const popup = 'pages' in plan && Array.isArray((plan as SitePlan).pages) ? popupTokenOf(checkPopup(plan as SitePlan).popup) : null;
|
|
212
|
+
return fingerprintOf(page, preset, mode, wornHeaderOfPlan(plan).mix, footerMixOfPlan(plan), popup);
|
|
205
213
|
}
|
|
206
214
|
|
|
207
215
|
/** The longest common subsequence of two sequences. */
|
|
@@ -28,6 +28,8 @@ export enum ListSayCode {
|
|
|
28
28
|
PackshotNotPlain = 'list-packshot-not-plain',
|
|
29
29
|
TitleOnPhotoParts = 'list-title-on-photo-parts',
|
|
30
30
|
StripsNeedPictures = 'list-strips-need-pictures',
|
|
31
|
+
/** vectoriox/iox-ui#128: a deck in a held Scene is turned by the scroll and rests mid-turn — a row instead. */
|
|
32
|
+
DeckHeld = 'list-deck-held',
|
|
31
33
|
StripsAtMost = 'list-strips-at-most',
|
|
32
34
|
/** The business type's lists never take this arrangement (L-D12). */
|
|
33
35
|
NeverArrange = 'list-never-arrange',
|
|
@@ -149,6 +151,10 @@ export const LIST_SAY_WORDS: Readonly<Record<`${ListSayCode}`, ListWordsEntry>>
|
|
|
149
151
|
en: () => 'strips need a picture in every item — a still grid instead',
|
|
150
152
|
he: () => 'רצועות צריכות תמונה בכל פריט — במקומן רשת שעומדת במקום',
|
|
151
153
|
},
|
|
154
|
+
'list-deck-held': {
|
|
155
|
+
en: r => `a deck the scroll turns in a held section rests between two cards when the scroll stops — ${r.m('instead')}`,
|
|
156
|
+
he: r => `חפיסה שהגלילה מסובבת בקטע מוחזק נעצרת בין שני קלפים כשהגלילה נעצרת — ${r.m('instead')}`,
|
|
157
|
+
},
|
|
152
158
|
'list-strips-at-most': {
|
|
153
159
|
en: r => `${r.v('max')} strips fit at most — "${r.v('alias')}" has ${r.v('items')}: ${r.m('instead')}`,
|
|
154
160
|
he: r => `נכנסות לכל היותר ${r.v('max')} רצועות — ב־"${r.v('alias')}" יש ${r.v('items')}: ${r.m('instead')}`,
|
|
@@ -194,6 +194,8 @@ export interface SitePattern {
|
|
|
194
194
|
/** Commerce G1: a store section — it reads the shop (its products, a product's price and variants). Listed only to
|
|
195
195
|
* a business that sells. */
|
|
196
196
|
readonly shop?: boolean;
|
|
197
|
+
/** X4 (Bring my site): placed only by a plan read from the owner's site (`planImport`) — no manifest or wire lists it. */
|
|
198
|
+
readonly imported?: boolean;
|
|
197
199
|
readonly node: PatternNode;
|
|
198
200
|
}
|
|
199
201
|
|
|
@@ -400,7 +402,7 @@ export interface PatternManifestOptions {
|
|
|
400
402
|
export function patternManifest(density?: string | null, options: PatternManifestOptions = {}): PatternManifestEntry[] {
|
|
401
403
|
const scenes = !('animate' in options) || options.animate === SCENE_LEVEL;
|
|
402
404
|
const store = options.sells !== false;
|
|
403
|
-
return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.film && (scenes || !p.scene) && (store || !p.shop)).map(([id, p]) => ({
|
|
405
|
+
return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.film && !p.imported && (scenes || !p.scene) && (store || !p.shop)).map(([id, p]) => ({
|
|
404
406
|
id, family: p.family, label: p.label, intent: p.intent, ...(p.global ? { global: p.global } : {}),
|
|
405
407
|
slots: Object.fromEntries(Object.keys(patternSlotBudgets(p)).map(slot => [slot, slotBudget(p, slot, density) as number])),
|
|
406
408
|
links: patternLinkSlots(p),
|
|
@@ -8,10 +8,11 @@ import { DEFAULT_HEADER_PATTERN, HeaderIngredient, headerMeaning, headerMix, hea
|
|
|
8
8
|
import { DEFAULT_FOOTER_PATTERN, FooterIngredient, footerMeaning, footerMix, footerMixFromWords, footerMixOfPlan, footerMixWords, footerPatternIdOf, footerWireWords, footerWords } from './footer-mix';
|
|
9
9
|
import { openingHarnessWord, OpeningIngredient, openingMeaning, openingWireWords, openingWordTier } from './opening-mix';
|
|
10
10
|
import { BodyIngredient, bodyMeaning, bodyMix, bodyMixWords, bodyWireWords } from './body-mix';
|
|
11
|
+
import { POPUP_LINK_WORD, POPUP_WIRE_INGREDIENTS, popupMeaning, popupWireWords } from './popup-plan';
|
|
11
12
|
import { shopCategoriesOf } from './shop-plan';
|
|
12
13
|
import { ContentFieldControl, FIELD_TYPE_OF_CONTROL,
|
|
13
|
-
ContentFieldPlan, ContentTypePlan, DataSourcePlan, FactKey, GenerationTier, GlobalSlot, PAGE_ARCHETYPES, PagePlan, PageSectionPlan, PlanDataSourceMode, PlanDataSourceType,
|
|
14
|
-
RelativeOp, ShopProductPlan, SITE_NEED_IDS, SITE_PLAN_VERSION, SitePlan, SitePlanSource, SiteLocale,
|
|
14
|
+
ContentFieldPlan, ContentTypePlan, DataSourcePlan, FactKey, GenerationTier, GlobalSlot, ITEM_PAGE_ONLY_ROLES, PAGE_ARCHETYPES, PagePlan, PageSectionPlan, PlanDataSourceMode, PlanDataSourceType,
|
|
15
|
+
PlanPopupLines, RelativeOp, ShopProductPlan, SITE_NEED_IDS, SITE_PLAN_VERSION, SitePlan, SitePlanSource, SiteLocale,
|
|
15
16
|
} from './site-plan.model';
|
|
16
17
|
import { SPEC_SITE_PLAN_SHAPE } from './site-spec.generated';
|
|
17
18
|
import { isPlainObject, PlainObject, ShapeEntry, shapeKeys } from './shape-check';
|
|
@@ -99,8 +100,9 @@ interface WireKey {
|
|
|
99
100
|
const PLAN_SHAPE = SPEC_SITE_PLAN_SHAPE as unknown as Readonly<Record<string, ShapeEntry>>;
|
|
100
101
|
const key = (ref: string, none?: string): WireKey => ({ refs: [ref], ...(none !== undefined ? { none } : {}) });
|
|
101
102
|
const inPart = (part: PlanPart, spec: WireKey): WireKey => ({ ...spec, part });
|
|
102
|
-
/** The roles a content type's fields play (`roles` of the plan shape), in the plan shape's order
|
|
103
|
-
|
|
103
|
+
/** The roles a content type's fields play (`roles` of the plan shape), in the plan shape's order — less the item page's
|
|
104
|
+
* own (X4 `ITEM_PAGE_ONLY_ROLES`: an imported item's text is never the model's to write). */
|
|
105
|
+
const ROLE_KEYS: ReadonlyArray<string> = shapeKeys(PLAN_SHAPE['roles']).filter(role => !(ITEM_PAGE_ONLY_ROLES as ReadonlyArray<string>).includes(role));
|
|
104
106
|
const roleWords = ROLE_KEYS.map(role => `${role}: ${describeShapeKey(PLAN_SHAPE['roles'], role).replace(/^string — /, '')}`).join('; ');
|
|
105
107
|
|
|
106
108
|
/** The footer's words as the model reads them (LI5): each ingredient, its words and their meanings, from the contract. */
|
|
@@ -140,6 +142,18 @@ const BODY_WIRE_TEXT = "string[] — the site's body as ONE list of <ingredient>
|
|
|
140
142
|
.filter(([, words]) => words.length)
|
|
141
143
|
.map(([k, words]) => `${k}: ${words.map(w => `${w} (${bodyMeaning(k, w)})`).join(' | ')}`).join('; ');
|
|
142
144
|
|
|
145
|
+
/** The wire's `globals` key the site's popup travels in (popups PU3) — a mix beside the others; [] = no popup. */
|
|
146
|
+
const POPUP_WIRE_KEY = 'popup';
|
|
147
|
+
|
|
148
|
+
/** The popup's words as the model reads them (PU3): each ingredient the wire carries, its words and their meanings, from the
|
|
149
|
+
* contract's popup table; the link names a page of this plan. Text items: a page key is the plan's own word, never a list. */
|
|
150
|
+
const POPUP_WIRE_TEXT = "string[] — the site's popup as ONE list of <ingredient>:<word> words, ONLY when the owner's popup lines ask for one "
|
|
151
|
+
+ "(the context says so): [] otherwise. Never a word of copy — the popup says the owner's news as stated. One word per ingredient; "
|
|
152
|
+
+ 'an ingredient left out is the kind\'s own. '
|
|
153
|
+
+ POPUP_WIRE_INGREDIENTS.map(k => `${k}: ${popupWireWords().filter(w => w.startsWith(`${k}:`)).map(w => w.slice(k.length + 1))
|
|
154
|
+
.map(w => `${w} (${popupMeaning(k, w)})`).join(' | ')}`).join('; ')
|
|
155
|
+
+ `; ${POPUP_LINK_WORD}:<page key> — the page of this plan the popup's one action opens (the offer's page if there is one; never the home page).`;
|
|
156
|
+
|
|
143
157
|
const WIRE_KEYS: Readonly<Record<`${PlanWireEntry}`, Readonly<Record<string, WireKey>>>> = {
|
|
144
158
|
plan: {
|
|
145
159
|
business: inPart(PlanPart.Structure, key('plan.business')),
|
|
@@ -248,6 +262,8 @@ const WIRE_KEYS: Readonly<Record<`${PlanWireEntry}`, Readonly<Record<string, Wir
|
|
|
248
262
|
// AW6: the site's body travels as its MIX, ONE list of `<ingredient>:<word>` words (body-mix.ts); [] = none. The award
|
|
249
263
|
// tier's request alone carries it (AW-D23…D25): a Basic wire is without the key, so its grammar is the one it was.
|
|
250
264
|
body: { refs: ['plan.mixes', 'mixes.body'], text: BODY_WIRE_TEXT, tier: GenerationTier.Award },
|
|
265
|
+
// PU3: the popup travels as its words, ONE list (popup-plan.ts); [] = none. Stamped only from the owner's lines (plan.popup).
|
|
266
|
+
popup: { refs: ['plan.mixes', 'mixes.popup'], text: POPUP_WIRE_TEXT },
|
|
251
267
|
},
|
|
252
268
|
shopProduct: {
|
|
253
269
|
name: key('shopProduct.name'),
|
|
@@ -273,6 +289,9 @@ export const PLAN_WIRE_DERIVED: Readonly<Record<string, string>> = {
|
|
|
273
289
|
'page.required': "a template page's (the wizard's Pages step), never the AI's",
|
|
274
290
|
sourceTemplate: 'the AI never writes a template plan',
|
|
275
291
|
sourceAi: 'this run (the context)',
|
|
292
|
+
sourceImport: 'the AI never writes an import plan (Bring my site X4 — planImport)',
|
|
293
|
+
'roles.body': "an imported item's own text (Bring my site X4) — never the model's",
|
|
294
|
+
'seed.importedFrom': 'the old addresses of real items read from a site (Bring my site X4) — never the model\'s',
|
|
276
295
|
design: "the owner's pick (the context)",
|
|
277
296
|
'plan.film': "the owner's film, set by the build (SC6b)",
|
|
278
297
|
film: "the owner's film, set by the build (SC6b)",
|
|
@@ -286,6 +305,9 @@ export const PLAN_WIRE_DERIVED: Readonly<Record<string, string>> = {
|
|
|
286
305
|
freePage: 'the free step: a page the model writes free, on its own wire, set by the server (FS3)',
|
|
287
306
|
freeRead: 'the free step (FS3)',
|
|
288
307
|
freeNode: 'the free step (FS3)',
|
|
308
|
+
'plan.popup': "the owner's popup lines: the reading's stated news and the Plan step's ticks (the context, popups PU3)",
|
|
309
|
+
popupLines: "the owner's popup lines (the context, popups PU3)",
|
|
310
|
+
statedFact: "the reading's stated fact (the context, popups PU3)",
|
|
289
311
|
};
|
|
290
312
|
|
|
291
313
|
const wireText = (spec: WireKey): string => {
|
|
@@ -363,7 +385,7 @@ const shaped = (entry: `${PlanWireEntry}`, properties: Record<string, JsonSchema
|
|
|
363
385
|
|
|
364
386
|
/** The patterns a page section may use (every non-global one but a film's, which `placeFilm` places), in library order. */
|
|
365
387
|
export function sectionPatternIds(): string[] {
|
|
366
|
-
return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.global && !p.film).map(([id]) => id);
|
|
388
|
+
return Object.entries(SITE_PATTERNS).filter(([, p]) => !p.global && !p.film && !p.imported).map(([id]) => id);
|
|
367
389
|
}
|
|
368
390
|
|
|
369
391
|
const sectionPatterns = () => sectionPatternIds().map(id => SITE_PATTERNS[id]);
|
|
@@ -457,6 +479,7 @@ const PLAN_TOP_SCHEMAS: Readonly<Record<string, (options: PlanWireOptions) => Js
|
|
|
457
479
|
[GlobalSlot.Footer]: jsonListOf(jsonOneOf(footerWireWords())),
|
|
458
480
|
[OPENING_WIRE_KEY]: jsonListOf(jsonOneOf(openingWireWords(GenerationTier.Award))),
|
|
459
481
|
...(isAward(options) ? { [BODY_WIRE_KEY]: jsonListOf(jsonOneOf(bodyWireWords(GenerationTier.Award))) } : {}),
|
|
482
|
+
[POPUP_WIRE_KEY]: jsonListOf(jsonText()),
|
|
460
483
|
}, `wire ${PlanWireEntry.Globals}`),
|
|
461
484
|
direction: () => shaped(PlanWireEntry.Direction, { idea: jsonText(), cliche: jsonText(), flip: jsonText(), rules: jsonListOf(jsonText()) }),
|
|
462
485
|
shop: () => jsonListOf(wireShopProductJsonSchema()),
|
|
@@ -497,6 +520,8 @@ export interface PlanWireContext {
|
|
|
497
520
|
/** The owner's own facts (the analysis's, as corrected), verbatim. */
|
|
498
521
|
facts?: Readonly<Partial<Record<FactKey, string>>>;
|
|
499
522
|
locale?: `${SiteLocale}`;
|
|
523
|
+
/** Popups PU3: the owner's popup lines (the reading's stated news, the Plan step's ticks) — the plan's `popup`, never the model's. */
|
|
524
|
+
popup?: PlanPopupLines;
|
|
500
525
|
}
|
|
501
526
|
|
|
502
527
|
/** A value standing for "absent": `''` (or nothing at all). */
|
|
@@ -633,6 +658,7 @@ export function expandPlanWire(parts: PlanWireParts, context: PlanWireContext):
|
|
|
633
658
|
source: { ...context.source },
|
|
634
659
|
business: expandWireBusiness(business, context.facts),
|
|
635
660
|
...(context.locale ? { locale: context.locale } : {}),
|
|
661
|
+
...(context.popup ? { popup: JSON.parse(JSON.stringify(context.popup)) as PlanPopupLines } : {}),
|
|
636
662
|
design: { ...context.design },
|
|
637
663
|
contentTypes: each(contentTypes, expandWireContentType),
|
|
638
664
|
dataSources: each(dataSources, expandWireDataSource),
|
|
@@ -645,12 +671,13 @@ export function expandPlanWire(parts: PlanWireParts, context: PlanWireContext):
|
|
|
645
671
|
function expandWireGlobals(globals: unknown): PlainObject {
|
|
646
672
|
if (globals === undefined) return {};
|
|
647
673
|
if (!isPlainObject(globals)) return { globals };
|
|
648
|
-
const { [OPENING_WIRE_KEY]: opening, [BODY_WIRE_KEY]: body, ...rest } = globals;
|
|
674
|
+
const { [OPENING_WIRE_KEY]: opening, [BODY_WIRE_KEY]: body, [POPUP_WIRE_KEY]: popup, ...rest } = globals;
|
|
649
675
|
const out: PlainObject = { ...rest };
|
|
650
676
|
const mixes: Record<string, unknown> = {};
|
|
651
677
|
// AW8: the opening is a mix only (no stored pattern stands for it on the wire); [] = none. Not a list: the validator says so.
|
|
652
678
|
// AW6: so is the body (the award tier's wire alone writes it); [] = none.
|
|
653
|
-
|
|
679
|
+
// PU3: so is the popup ([] = none).
|
|
680
|
+
for (const [name, words] of [[OPENING_WIRE_KEY, opening], [BODY_WIRE_KEY, body], [POPUP_WIRE_KEY, popup]] as const) {
|
|
654
681
|
if (words !== undefined && (!Array.isArray(words) || words.length)) mixes[name] = Array.isArray(words) ? [...words] : words;
|
|
655
682
|
}
|
|
656
683
|
for (const [slot, readId, fallback] of [
|
|
@@ -677,7 +704,8 @@ export function fieldToWire(field: ContentFieldPlan): PlainObject {
|
|
|
677
704
|
export function contentTypeToWire(type: ContentTypePlan, options: WireOptions = {}): PlainObject {
|
|
678
705
|
const played = type.roles as Readonly<Record<string, string | undefined>>;
|
|
679
706
|
const roles = ROLE_KEYS.filter(role => played[role]).map(role => ({ role, field: played[role] }));
|
|
680
|
-
|
|
707
|
+
// X4: an imported item's old address is never on the wire (`importedFrom` stays with the plan).
|
|
708
|
+
const { count = 0, sample = false, isPublished = false, perItem = {}, importedFrom: _from, ...values } = type.seed ?? {};
|
|
681
709
|
return {
|
|
682
710
|
name: type.name, label: type.label, roles, ...(options.children === false ? {} : { fields: type.fields.map(fieldToWire) }),
|
|
683
711
|
seed: { count, sample, isPublished, values: mapToList(values, 'field', 'value').map(row => ({ ...row, each: perItem[String(row['field'])] ?? [] })) },
|
|
@@ -726,6 +754,7 @@ const PLAN_TO_WIRE: Readonly<Record<string, (plan: SitePlan, options: PlanWireOp
|
|
|
726
754
|
[OPENING_WIRE_KEY]: [...(plan.mixes?.opening ?? [])],
|
|
727
755
|
// AW6: the award tier's wire writes the body ([] = none); every other tier's has no such key (its plan wears none).
|
|
728
756
|
...(isAward(options) ? { [BODY_WIRE_KEY]: [...(plan.mixes?.body ?? [])] } : {}),
|
|
757
|
+
[POPUP_WIRE_KEY]: [...(plan.mixes?.popup ?? [])],
|
|
729
758
|
}),
|
|
730
759
|
direction: plan => ({ idea: plan.direction?.idea ?? NONE, cliche: plan.direction?.cliche ?? NONE, flip: plan.direction?.flip ?? NONE, rules: [...(plan.direction?.rules ?? [])] }),
|
|
731
760
|
shop: plan => (plan.shop?.products ?? []).map(p => ({ name: p.name, category: p.category, description: p.description, options: p.options.map(o => ({ name: o.name, values: [...o.values] })) })),
|