@vectoriox/iox-ui 5.89.0 → 5.90.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/design-core/index.d.ts +523 -2
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +581 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +8403 -4898
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +12 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +33 -6
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +3 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +1735 -507
- package/harness-core/index.d.ts +52 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +19 -2
- package/src/design-core/flavor-spec.generated.ts +500 -0
- package/src/design-core/font-metrics.ts +105 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/ai-run.ts +11 -0
- package/src/generation-core/audit-site.ts +5 -0
- package/src/generation-core/check-layout.ts +940 -0
- package/src/generation-core/compose-layout.ts +120 -34
- package/src/generation-core/compose-site.ts +122 -3
- package/src/generation-core/layout-drift.ts +78 -0
- package/src/generation-core/layout-edits.ts +122 -0
- package/src/generation-core/layout-fingerprint.ts +203 -0
- package/src/generation-core/layout-language.ts +195 -12
- package/src/generation-core/layout-look.ts +57 -0
- package/src/generation-core/layout-photos.ts +19 -0
- package/src/generation-core/layout-render-check.ts +275 -0
- package/src/generation-core/layout-section-fallback.ts +156 -0
- package/src/generation-core/layout-type.ts +48 -0
- package/src/generation-core/layout-wire.ts +282 -0
- package/src/generation-core/nav-shape.ts +23 -1
- package/src/generation-core/photo-inventory.ts +250 -0
- package/src/generation-core/plan-edits.ts +25 -2
- package/src/generation-core/plan-wire.ts +19 -2
- package/src/generation-core/public-api.ts +11 -0
- package/src/generation-core/site-plan.model.ts +16 -0
- package/src/generation-core/site-spec.generated.ts +759 -2
- package/src/generation-core/validate-site-plan.ts +55 -1
- package/src/harness-core/generation-view.ts +52 -1
- package/src/scene-core/scroll-driver.ts +14 -2
- package/src/scene-core/scroll-range.ts +23 -3
- package/styles/iox-forms.css +4 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsonClosedObject, jsonListOf, jsonOneOf, JsonSchema, jsonText } from './json-schema';
|
|
2
|
+
import { LayoutIssue, LayoutIssueCode, LayoutPage } from './layout-language';
|
|
3
|
+
import { derivedBeats } from './layout-wire';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* THE LAYOUT REPAIR (premium components M8 gate 2, §4.1; the prototype's `applyEdits`, `code/cl2.mjs`): a refused page
|
|
7
|
+
* comes back as a few path edits instead of the whole page — the paths `checkLayout` names (`sections[2].layers[1].col`).
|
|
8
|
+
* The strict format carries every value as JSON text (one string type, no unions); a value that is not JSON is a plain
|
|
9
|
+
* string. Pure: the page given is never changed.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export enum LayoutEditOp {
|
|
13
|
+
Set = 'set',
|
|
14
|
+
Remove = 'remove',
|
|
15
|
+
Insert = 'insert',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LayoutEdit {
|
|
19
|
+
op: `${LayoutEditOp}`;
|
|
20
|
+
/** Relative to the page: `sections[2].layers[1].col`. */
|
|
21
|
+
path: string;
|
|
22
|
+
/** The new value as JSON text (`[3, 7]`, `"xl"`, `{"kind": "label", …}`); '' for a remove. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A layer's keys the strict layout format always carries and writes `"none"` when absent (`layout-wire.ts`): the model
|
|
28
|
+
* that wrote the page in that format repairs it in the same words, so setting one to "none", "" or null removes it — on
|
|
29
|
+
* the page as expanded, "none" is no value (the live run's Opus repairs set `depth: "none"` in a held section and failed).
|
|
30
|
+
*/
|
|
31
|
+
const ABSENT_AS_NONE: ReadonlySet<string> = new Set(['size', 'bleed', 'depth', 'variant', 'color']);
|
|
32
|
+
const meansAbsent = (value: unknown): boolean => value === null || value === '' || value === 'none';
|
|
33
|
+
|
|
34
|
+
/** Keys no path may walk through. */
|
|
35
|
+
const UNSAFE_KEYS: ReadonlySet<string> = new Set(['__proto__', 'prototype', 'constructor']);
|
|
36
|
+
|
|
37
|
+
/** A path's steps: object keys and array indexes (`sections[2].phone` → ['sections', 2, 'phone']). */
|
|
38
|
+
export function layoutPathSteps(path: string): Array<string | number> {
|
|
39
|
+
const out: Array<string | number> = [];
|
|
40
|
+
for (const part of String(path ?? '').split('.')) {
|
|
41
|
+
for (const m of part.matchAll(/([^[\]]+)|\[(\d+)\]/g)) out.push(m[1] !== undefined ? m[1] : Number(m[2]));
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseValue(text: string): unknown {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(text);
|
|
49
|
+
} catch {
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type Container = Record<string | number, unknown> | unknown[];
|
|
55
|
+
const isContainer = (v: unknown): v is Container => !!v && typeof v === 'object';
|
|
56
|
+
|
|
57
|
+
/** Applies the edits in order. An edit that cannot apply is skipped and named (`edits[3]`); the rest still apply. */
|
|
58
|
+
export function applyLayoutEdits(page: LayoutPage, edits: ReadonlyArray<LayoutEdit>): { page: LayoutPage; issues: LayoutIssue[] } {
|
|
59
|
+
const out = structuredClone(page) as unknown as Record<string, unknown>;
|
|
60
|
+
const issues: LayoutIssue[] = [];
|
|
61
|
+
const refuse = (n: number, message: string): void => {
|
|
62
|
+
issues.push({ code: LayoutIssueCode.Shape, path: `edits[${n}]`, message });
|
|
63
|
+
};
|
|
64
|
+
(edits ?? []).forEach((e, n) => {
|
|
65
|
+
const steps = layoutPathSteps(e?.path);
|
|
66
|
+
if (!steps.length) return refuse(n, 'no path');
|
|
67
|
+
if (steps.some(s => typeof s === 'string' && UNSAFE_KEYS.has(s))) return refuse(n, `${e.path}: not a path of the page`);
|
|
68
|
+
let parent: unknown = out;
|
|
69
|
+
for (const [k, step] of steps.slice(0, -1).entries()) {
|
|
70
|
+
if (!isContainer(parent)) return refuse(n, `${e.path}: nothing at ${steps.slice(0, k).join('.')}`);
|
|
71
|
+
const next = (parent as Record<string | number, unknown>)[step];
|
|
72
|
+
if (next === undefined && typeof step === 'string' && !Array.isArray(parent)) (parent as Record<string, unknown>)[step] = {};
|
|
73
|
+
else if (!isContainer(next)) return refuse(n, `${e.path}: nothing at ${String(step)}`);
|
|
74
|
+
parent = (parent as Record<string | number, unknown>)[step];
|
|
75
|
+
}
|
|
76
|
+
const last = steps[steps.length - 1];
|
|
77
|
+
if (!isContainer(parent)) return refuse(n, `${e.path}: nothing to edit`);
|
|
78
|
+
switch (e.op) {
|
|
79
|
+
case LayoutEditOp.Remove:
|
|
80
|
+
if (Array.isArray(parent) && typeof last === 'number' && last < parent.length) parent.splice(last, 1);
|
|
81
|
+
else if (!Array.isArray(parent) && typeof last === 'string' && last in parent) delete (parent as Record<string, unknown>)[last];
|
|
82
|
+
else refuse(n, `nothing at ${e.path}`);
|
|
83
|
+
return;
|
|
84
|
+
case LayoutEditOp.Insert:
|
|
85
|
+
if (Array.isArray(parent) && typeof last === 'number') parent.splice(Math.min(last, parent.length), 0, parseValue(e.value));
|
|
86
|
+
else refuse(n, 'insert needs an array index');
|
|
87
|
+
return;
|
|
88
|
+
case LayoutEditOp.Set:
|
|
89
|
+
if (Array.isArray(parent) && (typeof last !== 'number' || last > parent.length)) return refuse(n, `${e.path}: an index of the list (0..${parent.length})`);
|
|
90
|
+
if (!Array.isArray(parent) && typeof last === 'string' && ABSENT_AS_NONE.has(last) && meansAbsent(parseValue(e.value))) {
|
|
91
|
+
delete (parent as Record<string, unknown>)[last];
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
(parent as Record<string | number, unknown>)[last] = parseValue(e.value);
|
|
95
|
+
return;
|
|
96
|
+
default:
|
|
97
|
+
refuse(n, `op is ${Object.values(LayoutEditOp).join(' | ')}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// A layer's beat is derived, never written (the strict format has none): a repair that adds, moves, re-roles or stops an
|
|
101
|
+
// entrance gets its beats again (the live run's Opus repair made layer 2 the lead and kept its old beat).
|
|
102
|
+
for (const section of (out['sections'] as LayoutPage['sections'] | undefined) ?? []) {
|
|
103
|
+
if (!Array.isArray(section?.layers)) continue;
|
|
104
|
+
const beats = derivedBeats(section.layers);
|
|
105
|
+
section.layers.forEach((l, i) => {
|
|
106
|
+
if (!l || typeof l !== 'object') return;
|
|
107
|
+
if (l.enter && l.enter !== 'none') l.beat = beats[i];
|
|
108
|
+
else delete l.beat;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return { page: out as unknown as LayoutPage, issues };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The strict format a repair is asked in: `{ edits: [{ op, path, value }] }`, every key required. */
|
|
115
|
+
export function layoutRepairJsonSchema(): JsonSchema {
|
|
116
|
+
const edit = jsonClosedObject({
|
|
117
|
+
op: { ...jsonOneOf(Object.values(LayoutEditOp)), description: 'set a value, remove it, or insert into a list at the index' },
|
|
118
|
+
path: { ...jsonText(), description: 'the path the check named, relative to the page: sections[2].layers[1].col' },
|
|
119
|
+
value: { ...jsonText(), description: 'the new value as JSON text ([3, 7], "xl", {"kind": "label", …}); "" for a remove' },
|
|
120
|
+
}, ['op', 'path', 'value']);
|
|
121
|
+
return jsonClosedObject({ edits: { ...jsonListOf(edit), description: 'the fewest edits that answer every issue' } }, ['edits']);
|
|
122
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { parseCssColour, relativeLuminance } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { layoutPresetColours, splitSide } from './check-layout';
|
|
4
|
+
import { LayoutColour, LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutPage, LayoutRole, LayoutSection, LayoutSectionKind, LayoutSize, LayoutTrackProp } from './layout-language';
|
|
5
|
+
import { PHOTO_LIGHT_LUMINANCE, PhotoTone } from './photo-inventory';
|
|
6
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* THE CROSS-SITE FINGERPRINT (premium components M8 gate 2, M8-G2-D7; the prototype's `fingerprint` + `sameness`,
|
|
10
|
+
* `code/cl2.mjs`): what makes two composed pages read as the same — how the page opens, the sequence of its sections, the
|
|
11
|
+
* mechanism of its signature, whether it opens light or dark, and the preset it wears. Structure only: no words, no
|
|
12
|
+
* business data. Round three found that pages composed alone converge on one skeleton, and that telling the model what
|
|
13
|
+
* already exists is what broke it. Pure.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** How a section reads in the page's sequence (the contract's `sequenceTokens`). */
|
|
17
|
+
export enum LayoutSequenceToken {
|
|
18
|
+
Inhale = 'inhale',
|
|
19
|
+
Sideways = 'sideways',
|
|
20
|
+
HeldWords = 'held-words',
|
|
21
|
+
HeldReel = 'held-reel',
|
|
22
|
+
Held = 'held',
|
|
23
|
+
PhotoGround = 'photo-ground',
|
|
24
|
+
Gallery = 'gallery',
|
|
25
|
+
Split = 'split',
|
|
26
|
+
Composition = 'composition',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The signature mechanisms (the contract's `signatures`); `held-screen` is the fallback, never the aim. */
|
|
30
|
+
export enum LayoutSignatureId {
|
|
31
|
+
WordsLit = 'words-lit',
|
|
32
|
+
PhotoUnveiled = 'photo-unveiled',
|
|
33
|
+
ZoomThrough = 'zoom-through',
|
|
34
|
+
ScrollReel = 'scroll-reel',
|
|
35
|
+
PicturesStacking = 'pictures-stacking',
|
|
36
|
+
HalvesApart = 'halves-apart',
|
|
37
|
+
SidewaysWalk = 'sideways-walk',
|
|
38
|
+
ObjectTurning = 'object-turning',
|
|
39
|
+
HeldScreen = 'held-screen',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface LayoutFingerprint {
|
|
43
|
+
/** What the lead of the first section is: `screen-word`, `photo`, `gallery`, or `<size>-<kind>` (`xl-heading`). */
|
|
44
|
+
opening: string;
|
|
45
|
+
sequence: string[];
|
|
46
|
+
signature: string;
|
|
47
|
+
ground: `${PhotoTone}`;
|
|
48
|
+
preset: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FingerprintedPage {
|
|
52
|
+
name: string;
|
|
53
|
+
fingerprint: LayoutFingerprint;
|
|
54
|
+
businessType?: string;
|
|
55
|
+
/** A demo (the proof sites): its opening and signature are not to be repeated, its order of sections may be. */
|
|
56
|
+
demo?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const OPENING_SCREEN_WORD = 'screen-word';
|
|
60
|
+
|
|
61
|
+
/** A section's token in the page's sequence. */
|
|
62
|
+
export function sequenceTokenOf(s: LayoutSection): LayoutSequenceToken {
|
|
63
|
+
if (s.kind === LayoutSectionKind.Inhale) return LayoutSequenceToken.Inhale;
|
|
64
|
+
if ((s.track ?? 1) > 1) return LayoutSequenceToken.Sideways;
|
|
65
|
+
const layers = s.layers ?? [];
|
|
66
|
+
if (s.pin) {
|
|
67
|
+
if (layers.some(l => l.kinetic)) return LayoutSequenceToken.HeldWords;
|
|
68
|
+
return layers.some(l => l.gallery?.scroll) ? LayoutSequenceToken.HeldReel : LayoutSequenceToken.Held;
|
|
69
|
+
}
|
|
70
|
+
if (String(s.ground ?? '').startsWith('photo:')) return LayoutSequenceToken.PhotoGround;
|
|
71
|
+
if (layers.some(l => l.kind === LayoutLayerKind.Gallery)) return LayoutSequenceToken.Gallery;
|
|
72
|
+
return splitSide(s) ? LayoutSequenceToken.Split : LayoutSequenceToken.Composition;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The mechanism of the signature section, by what moves in it (first match wins, as the prototype's). */
|
|
76
|
+
const SIGNATURE_BY_TRACK: ReadonlyArray<[LayoutTrackProp, LayoutSignatureId]> = [
|
|
77
|
+
[LayoutTrackProp.Clip, LayoutSignatureId.PhotoUnveiled],
|
|
78
|
+
[LayoutTrackProp.Rotate, LayoutSignatureId.ObjectTurning],
|
|
79
|
+
[LayoutTrackProp.X, LayoutSignatureId.HalvesApart],
|
|
80
|
+
[LayoutTrackProp.Y, LayoutSignatureId.PicturesStacking],
|
|
81
|
+
[LayoutTrackProp.Scale, LayoutSignatureId.ZoomThrough],
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
export function signatureOf(s: LayoutSection | undefined): LayoutSignatureId {
|
|
85
|
+
if (!s) return LayoutSignatureId.HeldScreen;
|
|
86
|
+
const layers = s.layers ?? [];
|
|
87
|
+
if (layers.some(l => l.kinetic)) return LayoutSignatureId.WordsLit;
|
|
88
|
+
if (layers.some(l => l.gallery?.scroll)) return LayoutSignatureId.ScrollReel;
|
|
89
|
+
if ((s.track ?? 1) > 1) return LayoutSignatureId.SidewaysWalk;
|
|
90
|
+
const props = new Set(layers.flatMap(l => (l.motion ?? []).map(m => m.prop)));
|
|
91
|
+
return SIGNATURE_BY_TRACK.find(([prop]) => props.has(prop))?.[1] ?? LayoutSignatureId.HeldScreen;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A place given to the plan's ready-made section (silent section fallback): its token in the sequence and the opening. */
|
|
95
|
+
export const LAYOUT_READY_MADE_TOKEN = 'ready-made';
|
|
96
|
+
const READY_MADE_OPENING = `${LAYOUT_READY_MADE_TOKEN}:`;
|
|
97
|
+
|
|
98
|
+
function openingOf(s: LayoutSection | undefined): string {
|
|
99
|
+
if (s?.readyMade) return `${READY_MADE_OPENING}${s.readyMade.pattern}`;
|
|
100
|
+
const layers = s?.layers ?? [];
|
|
101
|
+
const lead = layers.find(l => l.role === LayoutRole.Lead) ?? layers[0];
|
|
102
|
+
if (!lead) return 'none';
|
|
103
|
+
if (lead.size === LayoutSize.Screen) return OPENING_SCREEN_WORD;
|
|
104
|
+
if (lead.kind === LayoutLayerKind.Photo || lead.kind === LayoutLayerKind.Gallery) return lead.kind;
|
|
105
|
+
return lead.size ? `${lead.size}-${lead.kind}` : lead.kind;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A page's fingerprint, worn in `preset` and `mode`. A photo ground opens on the page's own ground colour. */
|
|
109
|
+
export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' | 'dark'): LayoutFingerprint {
|
|
110
|
+
const sections = page.sections ?? [];
|
|
111
|
+
const first = sections[0];
|
|
112
|
+
const ground = String(first?.ground ?? LayoutColour.Ground);
|
|
113
|
+
const name = (Object.values(LayoutColour) as string[]).includes(ground) ? (ground as LayoutColour) : LayoutColour.Ground;
|
|
114
|
+
const colour = parseCssColour(layoutPresetColours(preset, mode)?.[name]);
|
|
115
|
+
const light = colour ? relativeLuminance(colour) > PHOTO_LIGHT_LUMINANCE : mode === 'light';
|
|
116
|
+
return {
|
|
117
|
+
opening: openingOf(first),
|
|
118
|
+
sequence: sections.map(s => (s.readyMade ? LAYOUT_READY_MADE_TOKEN : sequenceTokenOf(s))),
|
|
119
|
+
signature: signatureOf(sections.find(s => s.signature)),
|
|
120
|
+
ground: light ? PhotoTone.Light : PhotoTone.Dark,
|
|
121
|
+
preset,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The longest common subsequence of two sequences. */
|
|
126
|
+
function lcs(a: ReadonlyArray<string>, b: ReadonlyArray<string>): number {
|
|
127
|
+
const d = Array.from({ length: a.length + 1 }, () => new Array<number>(b.length + 1).fill(0));
|
|
128
|
+
for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) d[i][j] = a[i - 1] === b[j - 1] ? d[i - 1][j - 1] + 1 : Math.max(d[i - 1][j], d[i][j - 1]);
|
|
129
|
+
return d[a.length][b.length];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The share of the longer sequence two pages have in common. */
|
|
133
|
+
export function sequenceShare(a: ReadonlyArray<string>, b: ReadonlyArray<string>): number {
|
|
134
|
+
return lcs(a, b) / Math.max(1, a.length, b.length);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const openingWords = (opening: string) =>
|
|
138
|
+
opening.startsWith(READY_MADE_OPENING) ? `the ready-made ${opening.slice(READY_MADE_OPENING.length)}` : opening === OPENING_SCREEN_WORD ? 'a screen-size word' : opening === 'photo' || opening === 'gallery' ? `a ${opening}` : `a ${opening.replace('-', ' ')}`;
|
|
139
|
+
const signatureWords = (id: string) => SPEC_SITE_LAYOUT.signatures.find(s => s.id === id)?.label ?? id;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Refuses a page that repeats one already made (M8-G2-D7): most of the same sequence (`SPEC_SITE_LAYOUT.sameness.sequence`,
|
|
143
|
+
* 6 of 7), or the same opening AND signature; against a page of the same business type, the same opening or the same
|
|
144
|
+
* signature alone. The sequence is compared with real pages only — this studio's, other studios', this site's — never a
|
|
145
|
+
* demo's (Doron, 2026-11-09: the proof sites' order is the product's grammar, not someone's site). The look is the
|
|
146
|
+
* owner's pick and is never a reason.
|
|
147
|
+
*/
|
|
148
|
+
export function samenessIssues(me: LayoutFingerprint, others: ReadonlyArray<FingerprintedPage>, businessType?: string): LayoutIssue[] {
|
|
149
|
+
const issues: LayoutIssue[] = [];
|
|
150
|
+
const add = (path: string, message: string): void => {
|
|
151
|
+
issues.push({ code: LayoutIssueCode.Sameness, path, message });
|
|
152
|
+
};
|
|
153
|
+
for (const o of others) {
|
|
154
|
+
const them = o.fingerprint;
|
|
155
|
+
const sameType = !!businessType && o.businessType === businessType;
|
|
156
|
+
const opening = me.opening === them.opening;
|
|
157
|
+
const signature = me.signature === them.signature;
|
|
158
|
+
if (opening && (signature || sameType)) add('sections[0]', `"${o.name}" already opens on ${openingWords(them.opening)}${sameType ? ', and it is the same kind of business' : ` with ${signatureWords(them.signature)}`} — open another way`);
|
|
159
|
+
if (signature && (opening || sameType)) add('sections', `"${o.name}"'s signature is already ${signatureWords(them.signature)} — find another mechanism`);
|
|
160
|
+
if (!o.demo && sequenceShare(me.sequence, them.sequence) >= SPEC_SITE_LAYOUT.sameness.sequence) {
|
|
161
|
+
add('sections', `your sequence (${me.sequence.join(' → ')}) repeats "${o.name}"'s (${them.sequence.join(' → ')}) — change the order and the kinds of sections`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return issues;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The three proof sites' fingerprints (premium M8): every new page's opening and signature are compared with them, never
|
|
168
|
+
* its order of sections (`demo`). layout-fingerprint.spec holds them equal to `fingerprintOf` of the proof layouts. */
|
|
169
|
+
export const PROOF_FINGERPRINTS: ReadonlyArray<FingerprintedPage> = [
|
|
170
|
+
{
|
|
171
|
+
name: 'bar-daring',
|
|
172
|
+
demo: true,
|
|
173
|
+
fingerprint: {
|
|
174
|
+
opening: OPENING_SCREEN_WORD,
|
|
175
|
+
sequence: [LayoutSequenceToken.Composition, LayoutSequenceToken.Gallery, LayoutSequenceToken.Inhale, LayoutSequenceToken.HeldWords, LayoutSequenceToken.Sideways, LayoutSequenceToken.Gallery, LayoutSequenceToken.Composition],
|
|
176
|
+
signature: LayoutSignatureId.WordsLit,
|
|
177
|
+
ground: PhotoTone.Dark,
|
|
178
|
+
preset: 'after-dark',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'makers-daring',
|
|
183
|
+
demo: true,
|
|
184
|
+
fingerprint: {
|
|
185
|
+
opening: OPENING_SCREEN_WORD,
|
|
186
|
+
sequence: [LayoutSequenceToken.Composition, LayoutSequenceToken.Sideways, LayoutSequenceToken.Gallery, LayoutSequenceToken.Gallery, LayoutSequenceToken.Inhale, LayoutSequenceToken.HeldWords, LayoutSequenceToken.PhotoGround],
|
|
187
|
+
signature: LayoutSignatureId.WordsLit,
|
|
188
|
+
ground: PhotoTone.Light,
|
|
189
|
+
preset: 'warm-editorial',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'cafe-he-daring',
|
|
194
|
+
demo: true,
|
|
195
|
+
fingerprint: {
|
|
196
|
+
opening: 'xxl-heading',
|
|
197
|
+
sequence: [LayoutSequenceToken.Composition, LayoutSequenceToken.Composition, LayoutSequenceToken.Inhale, LayoutSequenceToken.Held, LayoutSequenceToken.HeldReel, LayoutSequenceToken.Gallery, LayoutSequenceToken.Composition],
|
|
198
|
+
signature: LayoutSignatureId.PhotoUnveiled,
|
|
199
|
+
ground: PhotoTone.Light,
|
|
200
|
+
preset: 'warm-editorial',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
];
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* entrances, a parallax depth, held sections whose layers move by tracks, sideways sections, galleries, forms and a phone
|
|
5
5
|
* reading order. The model writes no CSS and no node tree; `composeLayout` stamps ordinary builder nodes from it.
|
|
6
6
|
*
|
|
7
|
-
* Gate 1
|
|
8
|
-
*
|
|
7
|
+
* Gate 1 typed the shape the three proof sites were saved in (iox-ai-guidance `prototypes/breaking-limits/round4|round3`).
|
|
8
|
+
* Gate 2 moved the closed lists into the contract (`site.layout`, SPEC_SITE_LAYOUT): these enums are held equal to it by
|
|
9
|
+
* layout-language.spec, and a generated page carries one in `PagePlan.layout` (a `LayoutPage`).
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
export enum LayoutLayerKind {
|
|
@@ -187,6 +188,8 @@ export interface LayoutGallery {
|
|
|
187
188
|
drift?: boolean;
|
|
188
189
|
/** Only in a held section: the page's scroll turns the slides. */
|
|
189
190
|
scroll?: boolean;
|
|
191
|
+
/** Gate 2: a list data source of the plan whose items the slides show (their image role) instead of fixed photos. */
|
|
192
|
+
source?: string;
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
export interface LayoutForm {
|
|
@@ -246,6 +249,125 @@ export interface LayoutSection {
|
|
|
246
249
|
layers: LayoutLayer[];
|
|
247
250
|
/** Every layer's index once, in a phone's reading order. */
|
|
248
251
|
phone?: number[];
|
|
252
|
+
/** Silent section fallback (Doron, 2026-11-09): this place is the plan's ready-made section `PagePlan.sections[at]`,
|
|
253
|
+
* stamped from its pattern in the look; it has no layers of its own. Set only by `fallBackBySection`, never by a model. */
|
|
254
|
+
readyMade?: LayoutReadyMade;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The plan section a place of a composed page was given to: its index in `PagePlan.sections` and its pattern. */
|
|
258
|
+
export interface LayoutReadyMade {
|
|
259
|
+
at: number;
|
|
260
|
+
pattern: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** How far a composed page breaks the usual layout (M8-G2-D5: follows How animated and the type's ceiling). */
|
|
264
|
+
export enum LayoutDial {
|
|
265
|
+
Distinct = 'distinct',
|
|
266
|
+
Daring = 'daring',
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** One composed page of a Site Plan (`PagePlan.layout`): the sections, and how far they dare. */
|
|
270
|
+
export interface LayoutPage {
|
|
271
|
+
dial: `${LayoutDial}`;
|
|
272
|
+
sections: LayoutSection[];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Where a layout's photo comes from (M8-G2-D10): `own:<assetId>` · `stock:<libraryKey>` · `box:<shape>`. */
|
|
276
|
+
export enum LayoutPhotoSource {
|
|
277
|
+
Own = 'own',
|
|
278
|
+
Stock = 'stock',
|
|
279
|
+
Box = 'box',
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** A photo id read: its source and key (`box:portrait` → box, portrait). Null when it names no source. */
|
|
283
|
+
export function parseLayoutPhotoId(id: string): { source: LayoutPhotoSource; key: string } | null {
|
|
284
|
+
const m = /^(own|stock|box):(.+)$/.exec(String(id ?? '').trim());
|
|
285
|
+
if (!m) return null;
|
|
286
|
+
if (m[1] === LayoutPhotoSource.Box && !Object.values(LayoutPhotoShape).includes(m[2] as LayoutPhotoShape)) return null;
|
|
287
|
+
return { source: m[1] as LayoutPhotoSource, key: m[2] };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** What can be wrong with a composed page, each refused with a path (`checkLayout`, `expandLayoutWire`). */
|
|
291
|
+
export enum LayoutIssueCode {
|
|
292
|
+
/** The answer cannot be read (not an object, no sections). */
|
|
293
|
+
Shape = 'shape',
|
|
294
|
+
/** A value outside its closed list or range. */
|
|
295
|
+
Value = 'value',
|
|
296
|
+
/** The page's structure (sections, leads, signature, phone order). */
|
|
297
|
+
Structure = 'structure',
|
|
298
|
+
/** The look's composition notes (space, type contrast, rotation, accent, what it avoids). */
|
|
299
|
+
Look = 'look',
|
|
300
|
+
/** How things move (Emil). */
|
|
301
|
+
Motion = 'motion',
|
|
302
|
+
/** Words that would not read: on a photo's busy part, too faint, too long for their box. */
|
|
303
|
+
Reading = 'reading',
|
|
304
|
+
/** A photo, a source, a fact or a form that is not the business's. */
|
|
305
|
+
Content = 'content',
|
|
306
|
+
/** What daring asks for and the page does not do. */
|
|
307
|
+
Daring = 'daring',
|
|
308
|
+
/** It repeats a page already made (the fingerprint). */
|
|
309
|
+
Sameness = 'sameness',
|
|
310
|
+
/** The rendered page (the render check): overlap, overflow, a first screen without its lead. */
|
|
311
|
+
Render = 'render',
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** What the composer may settle by itself, with no word or place changed (`mendLayout`). */
|
|
315
|
+
export enum LayoutMendKind {
|
|
316
|
+
/** Words over a busy or too-light part of a photo, in a look that allows scrims: the layer gets one. */
|
|
317
|
+
Scrim = 'scrim',
|
|
318
|
+
/** The accent on more layers than the look allows: the least important words go back to the ink, then — where words
|
|
319
|
+
* cannot give enough back — the least important accent bands take the ground nearest the accent their words read on. */
|
|
320
|
+
Accent = 'accent',
|
|
321
|
+
/** Words too faint on their ground, where the ink holds there: they go back to the ink. */
|
|
322
|
+
Ink = 'ink',
|
|
323
|
+
/** Decoration that enters with a move: it fades instead. */
|
|
324
|
+
Fade = 'fade',
|
|
325
|
+
/** Fewer layers glide than the look asks (iox-ui#63): the layers that may glide and do not get a depth, most important
|
|
326
|
+
* first — exactly as many as are missing. */
|
|
327
|
+
Depth = 'depth',
|
|
328
|
+
/** A gallery naming a list with no pictures (iox-ui#64): it shows a list that has them — the only one, else the one
|
|
329
|
+
* the section's words name, else the first in plan order. None, or the section's words name the list it named
|
|
330
|
+
* (iox-ui#66): left to the model. */
|
|
331
|
+
Source = 'source',
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Which rule chose a mended gallery's list. */
|
|
335
|
+
export enum LayoutSourceChoice {
|
|
336
|
+
/** The plan has exactly one list with pictures. */
|
|
337
|
+
Only = 'only',
|
|
338
|
+
/** Several: the first whose name or type the section's own words name. */
|
|
339
|
+
Intent = 'intent',
|
|
340
|
+
/** Several, none named: the first in plan order. */
|
|
341
|
+
Order = 'order',
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** A list a composed gallery could name: its alias, the words it is known by (the alias, its type's name and label), and
|
|
345
|
+
* whether its items carry a picture. Plan order. */
|
|
346
|
+
export interface LayoutGalleryList {
|
|
347
|
+
alias: string;
|
|
348
|
+
words: ReadonlyArray<string>;
|
|
349
|
+
pictures: boolean;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** An accent band the accent mend may move, and the ground it takes. */
|
|
353
|
+
export interface LayoutBandMove {
|
|
354
|
+
section: number;
|
|
355
|
+
ground: `${LayoutColour}`;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export type LayoutMend =
|
|
359
|
+
| { kind: LayoutMendKind.Scrim | LayoutMendKind.Ink | LayoutMendKind.Fade; layer: string }
|
|
360
|
+
| { kind: LayoutMendKind.Accent; over: number; bands?: ReadonlyArray<LayoutBandMove> }
|
|
361
|
+
| { kind: LayoutMendKind.Depth; layers: ReadonlyArray<string> }
|
|
362
|
+
| { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` };
|
|
363
|
+
|
|
364
|
+
export interface LayoutIssue {
|
|
365
|
+
code: `${LayoutIssueCode}`;
|
|
366
|
+
/** `sections[2].layers[1].box`, or `sections` for the page. */
|
|
367
|
+
path: string;
|
|
368
|
+
message: string;
|
|
369
|
+
/** Set when the composer can settle it alone (`mendLayout`); the model is asked only for what is left. */
|
|
370
|
+
mend?: LayoutMend;
|
|
249
371
|
}
|
|
250
372
|
|
|
251
373
|
export interface LayoutSite {
|
|
@@ -320,6 +442,40 @@ export const LAYOUT_COLUMN_GAP = '1.2vw';
|
|
|
320
442
|
* Stamped verbatim and read where it plays (not imported, as `PatternTrack`); compose-layout.spec holds the two equal. */
|
|
321
443
|
export const LAYOUT_DEPTH_ON_PHONE = 'rest';
|
|
322
444
|
|
|
445
|
+
/** Below this opacity a layer counts as hidden: the static check's rule for an entrance or an exit that hides, and the
|
|
446
|
+
* render check's for words a held section never shows together. */
|
|
447
|
+
export const LAYOUT_HIDDEN_OPACITY = 0.3;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* The stretches of a held section's play (0..1) in which a layer's opacity tracks show it — above
|
|
451
|
+
* `LAYOUT_HIDDEN_OPACITY`, each fade taken as linear. A layer with no opacity track shows throughout. Captions that take
|
|
452
|
+
* turns in one cell (the live café's four, M8 gate 2 fix first part 3) never show together, so they never overlap.
|
|
453
|
+
*/
|
|
454
|
+
export function layerShownSpans(l: Pick<LayoutLayer, 'motion'>): Array<[number, number]> {
|
|
455
|
+
const fades = (l.motion ?? []).filter(m => m.prop === LayoutTrackProp.Opacity && Array.isArray(m.at) && m.at[1] > m.at[0]).sort((a, b) => a.at[0] - b.at[0]);
|
|
456
|
+
if (!fades.length) return [[0, 1]];
|
|
457
|
+
const shows = (v: number) => v > LAYOUT_HIDDEN_OPACITY;
|
|
458
|
+
const spans: Array<[number, number]> = [];
|
|
459
|
+
let from: number | null = shows(fades[0].from) ? 0 : null;
|
|
460
|
+
for (const m of fades) {
|
|
461
|
+
if (shows(m.from) === shows(m.to)) continue;
|
|
462
|
+
const at = Math.round(Math.min(1, Math.max(0, m.at[0] + ((LAYOUT_HIDDEN_OPACITY - m.from) / (m.to - m.from)) * (m.at[1] - m.at[0]))) * 1000) / 1000;
|
|
463
|
+
if (shows(m.to) && from === null) from = at;
|
|
464
|
+
else if (!shows(m.to) && from !== null) {
|
|
465
|
+
if (at > from) spans.push([from, at]);
|
|
466
|
+
from = null;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (from !== null && from < 1) spans.push([from, 1]);
|
|
470
|
+
return spans;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Whether two layers' shown stretches meet for any length (no spans: shown throughout). */
|
|
474
|
+
export function shownTogether(a: ReadonlyArray<[number, number]> | undefined, b: ReadonlyArray<[number, number]> | undefined): boolean {
|
|
475
|
+
const A = a ?? [[0, 1]], B = b ?? [[0, 1]];
|
|
476
|
+
return A.some(([a0, a1]) => B.some(([b0, b1]) => Math.min(a1, b1) > Math.max(a0, b0)));
|
|
477
|
+
}
|
|
478
|
+
|
|
323
479
|
/** A control's tooltip words: the main entry's `A11yTrait.Tooltip` (premium M5), held equal by compose-layout.spec. */
|
|
324
480
|
export const LAYOUT_TOOLTIP_TRAIT = 'tooltip';
|
|
325
481
|
|
|
@@ -339,16 +495,43 @@ export function phoneGapBefore(prev: LayoutLayer | null, next: LayoutLayer): num
|
|
|
339
495
|
return 20;
|
|
340
496
|
}
|
|
341
497
|
|
|
498
|
+
/** The grid a laptop page is laid on, in vw: its width inside the gutters (`LAYOUT_GUTTER` 4vw a side), the gap between
|
|
499
|
+
* columns (`LAYOUT_COLUMN_GAP`), and 12 columns. */
|
|
500
|
+
const GRID_VW = 92;
|
|
501
|
+
const COLUMN_GAP_VW = 1.2;
|
|
502
|
+
const GRID_COLUMNS = 12;
|
|
503
|
+
/** A `screen` word's smallest and largest size (px), and the share of its room it fills (the renderer's margin). */
|
|
504
|
+
export const LAYOUT_SCREEN_PX: readonly [number, number] = [36, 560];
|
|
505
|
+
const SCREEN_FILL = 0.98;
|
|
506
|
+
const round2 = (n: number) => Math.round(n * 100) / 100;
|
|
507
|
+
|
|
508
|
+
/** How wide `cols` columns of the laptop grid stand, in vw (12 columns: 92vw). */
|
|
509
|
+
export function layoutColumnsVw(cols: number): number {
|
|
510
|
+
const column = (GRID_VW - (GRID_COLUMNS - 1) * COLUMN_GAP_VW) / GRID_COLUMNS;
|
|
511
|
+
return cols * column + Math.max(0, cols - 1) * COLUMN_GAP_VW;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** The room a layer of `cols` columns has on a screen `width` px wide, in px — a phone stacks every layer full width
|
|
515
|
+
* inside its gutters (`max(4vw, 16px)` a side). */
|
|
516
|
+
export function layoutRoomPx(cols: number, width: number, phone: boolean): number {
|
|
517
|
+
return phone ? width - 2 * Math.max(0.04 * width, 16) : (layoutColumnsVw(cols) * width) / 100;
|
|
518
|
+
}
|
|
519
|
+
|
|
342
520
|
/**
|
|
343
|
-
* A `screen` word's size:
|
|
344
|
-
*
|
|
345
|
-
*
|
|
521
|
+
* A `screen` word's size (iox-ui#46): the word fills its columns' width — `widthEm` is how wide it stands at 1em in its
|
|
522
|
+
* own face (design-core `textWidthEm`, from the face's measured letters) — and never stands taller than its rows; never
|
|
523
|
+
* under 36px or over 560px. `rows` 0 sizes by width alone (a phone's stacked word). Held sections are one screen tall.
|
|
346
524
|
*/
|
|
347
|
-
export function screenFontSize(
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
525
|
+
export function screenFontSize(widthEm: number, cols: number, rows: number, sectionRows: number, screens: number): string {
|
|
526
|
+
const [min, max] = LAYOUT_SCREEN_PX;
|
|
527
|
+
const widthVw = round2((layoutColumnsVw(cols) / Math.max(widthEm, 0.01)) * SCREEN_FILL);
|
|
528
|
+
if (!rows || !sectionRows) return `clamp(${min}px, ${widthVw}vw, ${max}px)`;
|
|
529
|
+
const heightSvh = round2((((rows / sectionRows) * screens * 100) / 0.92) * SCREEN_FILL);
|
|
530
|
+
return `clamp(${min}px, min(${widthVw}vw, ${heightSvh}svh), ${max}px)`;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** How many px a `screen` word `widthEm` wide runs past its room at its smallest size, on a screen `width` px wide — 0
|
|
534
|
+
* when it fits. The one thing sizing cannot mend: the static check refuses it (a browser would show it cut). */
|
|
535
|
+
export function screenWordOverflowPx(widthEm: number, cols: number, width: number, phone: boolean): number {
|
|
536
|
+
return Math.max(0, Math.round(LAYOUT_SCREEN_PX[0] * widthEm - layoutRoomPx(cols, width, phone)));
|
|
354
537
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DesignChoices, presetModes, resolveDesignChoices, STYLE_PRESETS, StylePreset, stylePresetOfChoices } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { LayoutDial, LayoutEase, LayoutPace } from './layout-language';
|
|
4
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
5
|
+
|
|
6
|
+
/** A look's composition notes (contract `site.layout.looks`): what a composed page in that look keeps to. */
|
|
7
|
+
export type LayoutLook = (typeof SPEC_SITE_LAYOUT.looks)[number];
|
|
8
|
+
|
|
9
|
+
const LOOKS: ReadonlyArray<LayoutLook> = SPEC_SITE_LAYOUT.looks;
|
|
10
|
+
const PRESET_LOOK: Readonly<Record<string, string>> = SPEC_SITE_LAYOUT.presetLook;
|
|
11
|
+
const DARING_LEVELS: ReadonlyArray<string> = SPEC_SITE_LAYOUT.daringLevels;
|
|
12
|
+
|
|
13
|
+
/** How far two brand colours are apart (RGB) — the last word between two presets that differ by their colour alone. */
|
|
14
|
+
function seedDistance(a: string, b: string): number {
|
|
15
|
+
const rgb = (hex: string) => [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16) || 0);
|
|
16
|
+
const [x, y] = [rgb(a), rgb(b)];
|
|
17
|
+
return x.reduce((sum, v, i) => sum + (v - y[i]) ** 2, 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The style preset a design wears (M8 gate 2): the preset it IS, else the closest of its flavor — same font pairing,
|
|
22
|
+
* then the most of shape · density · pill buttons · tint · mode in common, then the nearer brand colour (six pairings
|
|
23
|
+
* carry two presets each: Quiet luxury and Soft spa are both Linen + Cormorant; Morning glass and Coral studio differ by
|
|
24
|
+
* their colour alone) — so an owner whose brand became a reference colour still wears THEIR preset's composition notes.
|
|
25
|
+
* Never null: a design with no preset of its flavor reads the first preset's.
|
|
26
|
+
*/
|
|
27
|
+
export function layoutPresetOf(choices: DesignChoices): StylePreset {
|
|
28
|
+
const exact = stylePresetOfChoices(choices);
|
|
29
|
+
if (exact) return exact;
|
|
30
|
+
const c = resolveDesignChoices(choices);
|
|
31
|
+
const kept = (p: StylePreset) => [p.shape === c.shape, p.density === c.density, p.pillButtons === c.pillButtons, p.tint === c.tint,
|
|
32
|
+
presetModes(p).includes(c.mode)].filter(Boolean).length;
|
|
33
|
+
const nearer = (a: StylePreset, b: StylePreset) => kept(a) - kept(b) || seedDistance(b.seed, c.seed) - seedDistance(a.seed, c.seed);
|
|
34
|
+
const paired = STYLE_PRESETS.filter(p => p.flavorId === c.flavorId && p.pairId === c.pairId);
|
|
35
|
+
if (paired.length) return paired.reduce((best, p) => (nearer(p, best) > 0 ? p : best));
|
|
36
|
+
return STYLE_PRESETS.find(p => p.flavorId === c.flavorId) ?? STYLE_PRESETS[0];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A preset's look (the round-three composition notes it carries). */
|
|
40
|
+
export function layoutLookOf(presetId: string): LayoutLook {
|
|
41
|
+
return LOOKS.find(l => l.id === PRESET_LOOK[presetId]) ?? LOOKS[0];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The pace and ease a composed page moves with: its look's. */
|
|
45
|
+
export function layoutMotionOf(presetId: string): { pace: `${LayoutPace}`; ease: `${LayoutEase}` } {
|
|
46
|
+
const look = layoutLookOf(presetId);
|
|
47
|
+
return { pace: look.pace as `${LayoutPace}`, ease: look.ease as `${LayoutEase}` };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* How far a composed page dares (M8-G2-D5): daring when the look moves Lively or Expressive and the business type's
|
|
52
|
+
* ceiling allows it (a trust or care type never dares), else distinct. `ceiling` is harness-core's for the type.
|
|
53
|
+
*/
|
|
54
|
+
export function layoutDialOf(animate: string | null | undefined, ceiling: string | null | undefined): `${LayoutDial}` {
|
|
55
|
+
const daring = !!animate && DARING_LEVELS.includes(animate) && (!ceiling || DARING_LEVELS.includes(ceiling));
|
|
56
|
+
return daring ? LayoutDial.Daring : LayoutDial.Distinct;
|
|
57
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { layoutPhotoIds } from './check-layout';
|
|
2
|
+
import { LayoutPhotoSource, parseLayoutPhotoId } from './layout-language';
|
|
3
|
+
import { SitePlan } from './site-plan.model';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where the composed pages' photos come from (M8-G2-D10 — the Plan step's Pictures line: "Your 4 photos go first · 8 from
|
|
7
|
+
* your photo library · 0 empty boxes"): every distinct photo id the plan's composed layouts name, by source. Pure.
|
|
8
|
+
*/
|
|
9
|
+
export function planLayoutPhotos(plan: Pick<SitePlan, 'pages'>): Record<LayoutPhotoSource, string[]> {
|
|
10
|
+
const out: Record<LayoutPhotoSource, Set<string>> = { [LayoutPhotoSource.Own]: new Set(), [LayoutPhotoSource.Stock]: new Set(), [LayoutPhotoSource.Box]: new Set() };
|
|
11
|
+
for (const page of plan.pages) {
|
|
12
|
+
if (!page.layout) continue;
|
|
13
|
+
for (const id of layoutPhotoIds(page.layout)) {
|
|
14
|
+
const read = parseLayoutPhotoId(id);
|
|
15
|
+
if (read) out[read.source].add(id);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { [LayoutPhotoSource.Own]: [...out.own], [LayoutPhotoSource.Stock]: [...out.stock], [LayoutPhotoSource.Box]: [...out.box] };
|
|
19
|
+
}
|