@vectoriox/iox-ui 5.152.0 → 5.153.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 +196 -3
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +257 -11
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +124 -4
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +53 -2
- package/package.json +1 -1
- package/src/assist-core/media-generate.ts +325 -0
- package/src/assist-core/public-api.ts +1 -0
- package/src/assist-core/surfaces.ts +3 -0
- package/src/generation-core/fallback-memory.ts +142 -0
- package/src/generation-core/public-api.ts +1 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { LayoutPage, LayoutSection, LayoutSectionKind } from './layout-language';
|
|
2
|
+
import { FingerprintedPage, fingerprintOf, LAYOUT_READY_MADE_TOKEN, LayoutFingerprint } from './layout-fingerprint';
|
|
3
|
+
import { footerMixOfPlan } from './footer-mix';
|
|
4
|
+
import { wornHeaderOfPlan } from './header-mix';
|
|
5
|
+
import { PatternNode, patternById, patternNeedsBinding, patternNodes, SITE_LIBRARY, SitePattern } from './patterns';
|
|
6
|
+
import { PagePlan, PageSectionPlan } from './site-plan.model';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A PAGE BUILT FROM ITS SECTIONS IN THE STUDIO'S MEMORY (vectoriox/iox-ui#119, option C — Doron, 2026-11-23). A composed
|
|
10
|
+
* page that falls back whole is stamped from the plan's ready-made sections, and four of six J10 Homes did — two hero
|
|
11
|
+
* patterns between them, so six businesses wore two skeletons while the memory held none of them (only a model's layout
|
|
12
|
+
* was fingerprinted). Here a fallen page is fingerprinted too, by the sections it is built from, and before it is built
|
|
13
|
+
* its opening is moved away from the ready-made openings the studio's other sites already wear, when another hero of the
|
|
14
|
+
* library can carry every word the plan wrote for it. The closed layout language only: free sections get no sameness
|
|
15
|
+
* gate (Doron). Pure.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** A ready-made section's token in a fallen page's sequence: `ready-made:<pattern>`. A composed page's swapped section stays
|
|
19
|
+
* `ready-made` (its place in the model's order); a whole page of them is told apart by which sections they are. */
|
|
20
|
+
export function readyMadeToken(pattern: string): string {
|
|
21
|
+
return `${LAYOUT_READY_MADE_TOKEN}:${pattern}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The sections as the fingerprint reads them: a ready-made stub per place (as `fallBackBySection` writes one). */
|
|
25
|
+
function readyMadePage(sections: ReadonlyArray<Pick<PageSectionPlan, 'pattern'>>): LayoutPage {
|
|
26
|
+
return {
|
|
27
|
+
sections: sections.map((s, at): LayoutSection => ({
|
|
28
|
+
id: `ready-made-${at}`, kind: LayoutSectionKind.Content, screens: 1, rows: 1, layers: [], phone: [], readyMade: { at, pattern: s.pattern },
|
|
29
|
+
})),
|
|
30
|
+
} as LayoutPage;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A page built from its sections, as the studio remembers it: it opens on its first section's pattern
|
|
35
|
+
* (`ready-made:hero.split`), its sequence is its patterns in order, its signature holds the screen (a ready-made page has
|
|
36
|
+
* no signature section). The rest — ground, preset, header, footer — as `fingerprintOf`.
|
|
37
|
+
*/
|
|
38
|
+
export function fallbackFingerprintOf(sections: ReadonlyArray<Pick<PageSectionPlan, 'pattern'>>, preset: string, mode: 'light' | 'dark', plan?: Parameters<typeof wornHeaderOfPlan>[0] & Parameters<typeof footerMixOfPlan>[0]): LayoutFingerprint {
|
|
39
|
+
const base = fingerprintOf(readyMadePage(sections), preset, mode, plan ? wornHeaderOfPlan(plan).mix : undefined, plan ? footerMixOfPlan(plan) : undefined);
|
|
40
|
+
return { ...base, sequence: sections.map(s => readyMadeToken(s.pattern)) };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A plan page built from its sections (it fell back whole, or was never asked) — the ONE call a reader of a plan makes. */
|
|
44
|
+
export function fallbackFingerprintOfPlanPage(page: Pick<PagePlan, 'sections'>, preset: string, mode: 'light' | 'dark', plan: Parameters<typeof wornHeaderOfPlan>[0] & Parameters<typeof footerMixOfPlan>[0]): LayoutFingerprint {
|
|
45
|
+
return fallbackFingerprintOf(page.sections, preset, mode, plan);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** What a slot is, by the element style its node wears (`display`, `lead`, `button-primary`…), else its type. */
|
|
49
|
+
interface SlotKind {
|
|
50
|
+
slot: string;
|
|
51
|
+
kind: string;
|
|
52
|
+
/** It reads well left empty: it takes the business's own value, or it shows its own words and links nowhere. */
|
|
53
|
+
fillsItself: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function slotKinds(pattern: SitePattern): SlotKind[] {
|
|
57
|
+
const out = new Map<string, SlotKind>();
|
|
58
|
+
for (const n of patternNodes(pattern)) {
|
|
59
|
+
if (!n.slot || out.has(n.slot)) continue;
|
|
60
|
+
out.set(n.slot, { slot: n.slot, kind: n.es ?? n.t, fillsItself: fillsItself(n) });
|
|
61
|
+
}
|
|
62
|
+
return [...out.values()];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const fillsItself = (n: PatternNode): boolean => !!n.fromBusiness || (n.ph === undefined && n.href === undefined && n.text !== undefined);
|
|
66
|
+
|
|
67
|
+
const filled = (value: string | undefined): boolean => typeof value === 'string' && value.trim() !== '';
|
|
68
|
+
|
|
69
|
+
/** May the pattern stand in for another at a fallen page's opening — a plain section of the same family. */
|
|
70
|
+
function mayStandIn(id: string, family: string): boolean {
|
|
71
|
+
const p = patternById(id);
|
|
72
|
+
return !!p && p.family === family && !p.scene && !p.film && !p.shop && !p.global && !patternNeedsBinding(p);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The plan section moved onto `to`, every word and link it holds carried to `to`'s slot of the same kind — or null when
|
|
77
|
+
* one of them has nowhere to go, `to` would show a placeholder or a link to nowhere where the section said nothing, or the
|
|
78
|
+
* section holds what only its own pattern knows (a list, a form, parts left out).
|
|
79
|
+
*/
|
|
80
|
+
export function carrySection(section: PageSectionPlan, to: string): PageSectionPlan | null {
|
|
81
|
+
const from = patternById(section.pattern);
|
|
82
|
+
const target = patternById(to);
|
|
83
|
+
if (!from || !target || section.binding || section.form || section.without?.length) return null;
|
|
84
|
+
const theirs = slotKinds(target);
|
|
85
|
+
const taken = new Set<string>();
|
|
86
|
+
const slots: Record<string, string> = {};
|
|
87
|
+
const links: Record<string, string> = {};
|
|
88
|
+
for (const mine of slotKinds(from)) {
|
|
89
|
+
const value = section.slots?.[mine.slot];
|
|
90
|
+
if (!filled(value)) continue;
|
|
91
|
+
const home = theirs.find(t => t.kind === mine.kind && !taken.has(t.slot));
|
|
92
|
+
if (!home) return null;
|
|
93
|
+
taken.add(home.slot);
|
|
94
|
+
slots[home.slot] = value!;
|
|
95
|
+
const link = section.links?.[mine.slot];
|
|
96
|
+
if (link) links[home.slot] = link;
|
|
97
|
+
}
|
|
98
|
+
if (theirs.some(t => !taken.has(t.slot) && !t.fillsItself)) return null;
|
|
99
|
+
return {
|
|
100
|
+
pattern: to,
|
|
101
|
+
...(Object.keys(slots).length ? { slots } : {}),
|
|
102
|
+
...(Object.keys(links).length ? { links } : {}),
|
|
103
|
+
...(section.enter ? { enter: section.enter } : {}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Why a fallen page's opening stayed as the plan wrote it. */
|
|
108
|
+
export enum FallbackOpeningKept {
|
|
109
|
+
/** No other site of the studio opens on it. */
|
|
110
|
+
Free = 'free',
|
|
111
|
+
/** Every hero that could carry the plan's words is already worn as another site's opening (or none can carry them). */
|
|
112
|
+
NoneFree = 'none-free',
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface DistinctFallback {
|
|
116
|
+
sections: PageSectionPlan[];
|
|
117
|
+
/** Set when the opening moved: the pattern the plan wrote and the one it is built from now. */
|
|
118
|
+
moved?: { from: string; to: string };
|
|
119
|
+
/** Set when it did not move. */
|
|
120
|
+
kept?: `${FallbackOpeningKept}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A page about to be built from its sections, opened away from what the studio's other sites open on (option C). Only the
|
|
125
|
+
* opening moves — the first screen is what makes two sites read as one — and only to a library pattern of the same family
|
|
126
|
+
* that carries every word and link the plan wrote (`carrySection`), in the library's order. This site's own pages
|
|
127
|
+
* (`sameSite`) and the demos are never a reason: every page of a site may open alike, and a demo is not a site.
|
|
128
|
+
*/
|
|
129
|
+
export function distinctFallbackSections(sections: ReadonlyArray<PageSectionPlan>, others: ReadonlyArray<FingerprintedPage>): DistinctFallback {
|
|
130
|
+
const all = [...sections];
|
|
131
|
+
const first = all[0];
|
|
132
|
+
const worn = new Set(others.filter(o => !o.sameSite && !o.demo).map(o => o.fingerprint.opening));
|
|
133
|
+
if (!first || !worn.has(readyMadeToken(first.pattern))) return { sections: all, kept: FallbackOpeningKept.Free };
|
|
134
|
+
const family = patternById(first.pattern)?.family;
|
|
135
|
+
if (!family) return { sections: all, kept: FallbackOpeningKept.NoneFree };
|
|
136
|
+
for (const { id } of SITE_LIBRARY) {
|
|
137
|
+
if (id === first.pattern || worn.has(readyMadeToken(id)) || !mayStandIn(id, family)) continue;
|
|
138
|
+
const moved = carrySection(first, id);
|
|
139
|
+
if (moved) return { sections: [moved, ...all.slice(1)], moved: { from: first.pattern, to: id } };
|
|
140
|
+
}
|
|
141
|
+
return { sections: all, kept: FallbackOpeningKept.NoneFree };
|
|
142
|
+
}
|
|
@@ -70,6 +70,7 @@ export * from './layout-space';
|
|
|
70
70
|
export * from './list-space';
|
|
71
71
|
export * from './list-panel';
|
|
72
72
|
export * from './layout-fingerprint';
|
|
73
|
+
export * from './fallback-memory';
|
|
73
74
|
export * from './header-mix';
|
|
74
75
|
export * from './header-edit';
|
|
75
76
|
export * from './opening-mix';
|