@vectoriox/iox-ui 5.128.1 → 5.130.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/commerce-core/index.d.ts +29 -2
- package/composite-core/index.d.ts +130 -2
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +39 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +328 -141
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs +21 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +680 -61
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +20 -0
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +16 -1
- package/generation-core/index.d.ts +251 -13
- package/package.json +1 -1
- package/src/commerce-core/site-checkout.ts +49 -0
- package/src/composite-core/consent.ts +235 -0
- package/src/composite-core/public-api.ts +1 -0
- package/src/forms-core/form-presets.ts +28 -0
- package/src/generation-core/audit-site.ts +167 -17
- package/src/generation-core/compose-site.ts +208 -11
- package/src/generation-core/legal.ts +213 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/section-stamp.ts +145 -0
- package/src/generation-core/serialized-node.ts +15 -0
- package/src/generation-core/site-spec.generated.ts +41 -8
- package/src/generation-core/site-tree.ts +5 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { patternById, SITE_PATTERNS } from './patterns';
|
|
2
|
+
import { SectionStamp, SerializedNode } from './serialized-node';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SECTION STAMPS (M2-1, site-redesign RD1): every section root a build composes says where it came from and how the
|
|
6
|
+
* build left it, so a redesign (and Ask) can tell the owner's sections from the build's, section by section — before
|
|
7
|
+
* this, "edited" was judged per page only.
|
|
8
|
+
*
|
|
9
|
+
* - `stampSection` writes `composed: { pattern | layout, buildKey, fingerprint }` on a root;
|
|
10
|
+
* - `sectionFingerprint` is the root's content (its stamp aside) as a sync, framework-free 53-bit hash — the same in
|
|
11
|
+
* the browser, the server and a spec, and unchanged by a builder save that changes nothing;
|
|
12
|
+
* - `refreshSectionStamps` re-takes the fingerprints after a later step dresses the layout (the build's stock photos);
|
|
13
|
+
* - `sectionOrigin` answers "composed or the owner's?" for any root, stamped or not (RD1 Q2: a stamp wins; else a
|
|
14
|
+
* library pattern's label, or a section id of the layout the page was composed from, means composed).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Where a composed section came from: a library pattern, or a section a model laid out. */
|
|
18
|
+
export type SectionStampOrigin = { pattern: string; layout?: never } | { layout: string; pattern?: never };
|
|
19
|
+
|
|
20
|
+
/** The key a section's stamp carries (beside `buildKeys` in `site-build-run.ts`): the root's own id. */
|
|
21
|
+
export const sectionBuildKey = (rootId: string): string => `section:${rootId}`;
|
|
22
|
+
|
|
23
|
+
/** The stamp field: never part of a fingerprint (a stamp cannot describe itself). */
|
|
24
|
+
const STAMP_FIELD = 'composed';
|
|
25
|
+
|
|
26
|
+
const isEmpty = (value: unknown): boolean =>
|
|
27
|
+
value === undefined || value === null || value === ''
|
|
28
|
+
|| (Array.isArray(value) && value.length === 0)
|
|
29
|
+
|| (typeof value === 'object' && !Array.isArray(value) && Object.keys(value as object).length === 0);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A value's canonical form: keys sorted, an EMPTY value is no value (`undefined`, `null`, `''`, `[]`, `{}` drop), the
|
|
33
|
+
* stamp field gone at every depth — so a saved node and a composed one compare equal however their empties were written
|
|
34
|
+
* (iox-cms's `canonical` rule, the server's fingerprints).
|
|
35
|
+
*/
|
|
36
|
+
function canonical(value: unknown): unknown {
|
|
37
|
+
if (Array.isArray(value)) return value.map(canonical).filter(v => !isEmpty(v));
|
|
38
|
+
if (value && typeof value === 'object') {
|
|
39
|
+
const out: Record<string, unknown> = {};
|
|
40
|
+
for (const key of Object.keys(value as object).sort()) {
|
|
41
|
+
if (key === STAMP_FIELD) continue;
|
|
42
|
+
const v = canonical((value as Record<string, unknown>)[key]);
|
|
43
|
+
if (!isEmpty(v)) out[key] = v;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A node's canonical JSON, its stamp aside. */
|
|
51
|
+
export function canonicalNodeJson(node: SerializedNode): string {
|
|
52
|
+
return JSON.stringify(canonical(node)) ?? '';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* cyrb53: a sync 53-bit string hash, 14 base-36 characters. Not a security hash — it tells "as the build left it" from
|
|
57
|
+
* "changed" for one section, where a collision costs one section judged unchanged.
|
|
58
|
+
*/
|
|
59
|
+
export function hash53(text: string): string {
|
|
60
|
+
let h1 = 0xdeadbeef;
|
|
61
|
+
let h2 = 0x41c6ce57;
|
|
62
|
+
for (let i = 0; i < text.length; i++) {
|
|
63
|
+
const ch = text.charCodeAt(i);
|
|
64
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
65
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
66
|
+
}
|
|
67
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
68
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
69
|
+
const n = 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
70
|
+
return n.toString(36).padStart(11, '0');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A section's fingerprint: its canonical content (stamp aside), hashed. */
|
|
74
|
+
export function sectionFingerprint(root: SerializedNode): string {
|
|
75
|
+
return hash53(canonicalNodeJson(root));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Stamp a composed section root (in place) and return it. */
|
|
79
|
+
export function stampSection(root: SerializedNode, origin: SectionStampOrigin): SerializedNode {
|
|
80
|
+
const from = 'pattern' in origin && origin.pattern ? { pattern: origin.pattern } : { layout: (origin as { layout: string }).layout };
|
|
81
|
+
root.composed = { ...from, buildKey: sectionBuildKey(root.id), fingerprint: sectionFingerprint(root) };
|
|
82
|
+
return root;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Re-take every stamped root's fingerprint (in place) — after a step that dresses a composed layout (stock photos). */
|
|
86
|
+
export function refreshSectionStamps(layout: ReadonlyArray<SerializedNode>): void {
|
|
87
|
+
for (const root of layout) if (root.composed) root.composed = { ...root.composed, fingerprint: sectionFingerprint(root) };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A stamp's shape is whole: exactly one origin, a build key and a fingerprint. */
|
|
91
|
+
export function isSectionStamp(value: unknown): value is SectionStamp {
|
|
92
|
+
if (!value || typeof value !== 'object') return false;
|
|
93
|
+
const s = value as Record<string, unknown>;
|
|
94
|
+
const origins = [s['pattern'], s['layout']].filter(v => typeof v === 'string' && v !== '').length;
|
|
95
|
+
return origins === 1 && typeof s['buildKey'] === 'string' && !!s['buildKey'] && typeof s['fingerprint'] === 'string' && !!s['fingerprint'];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Whether a stamped section is still as the build left it. Null when the root carries no (whole) stamp. */
|
|
99
|
+
export function sectionUnchanged(root: SerializedNode): boolean | null {
|
|
100
|
+
return isSectionStamp(root.composed) ? root.composed.fingerprint === sectionFingerprint(root) : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Who a page's section is: the build's (and whether the owner changed it since, when the stamp can tell) or the owner's. */
|
|
104
|
+
export enum SectionMaker {
|
|
105
|
+
Composed = 'composed',
|
|
106
|
+
Owner = 'owner',
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface SectionOrigin {
|
|
110
|
+
maker: SectionMaker;
|
|
111
|
+
/** The library pattern or the layout section it came from, when composed. */
|
|
112
|
+
pattern?: string;
|
|
113
|
+
layout?: string;
|
|
114
|
+
/** A stamped section: false once the owner changed it. Absent when no stamp tells. */
|
|
115
|
+
unchanged?: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The library pattern whose label a root wears (`composePattern` names a root by its pattern's label). */
|
|
119
|
+
function patternOfLabel(label: string | undefined, patternIds: ReadonlyArray<string>): string | undefined {
|
|
120
|
+
const name = (label ?? '').split(' · ')[0].trim();
|
|
121
|
+
return name ? patternIds.find(id => patternById(id)?.label === name) : undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SectionOriginContext {
|
|
125
|
+
/** The library pattern ids a root's label may name (default: the whole library). */
|
|
126
|
+
patternIds?: ReadonlyArray<string>;
|
|
127
|
+
/** The section ids of the layout the page was composed from (its run plan's `page.layout`), when it was. */
|
|
128
|
+
layoutSectionIds?: ReadonlyArray<string>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Who made a page's section (RD1 Q2): a stamp wins; else a root labelled with a library pattern's name, or with a section
|
|
133
|
+
* id of the layout the page was composed from, is the build's; anything else is the owner's.
|
|
134
|
+
*/
|
|
135
|
+
export function sectionOrigin(root: SerializedNode, ctx: SectionOriginContext = {}): SectionOrigin {
|
|
136
|
+
if (isSectionStamp(root.composed)) {
|
|
137
|
+
const { pattern, layout } = root.composed;
|
|
138
|
+
return { maker: SectionMaker.Composed, ...(pattern ? { pattern } : { layout }), unchanged: root.composed.fingerprint === sectionFingerprint(root) };
|
|
139
|
+
}
|
|
140
|
+
const pattern = patternOfLabel(root.label, ctx.patternIds ?? Object.keys(SITE_PATTERNS));
|
|
141
|
+
if (pattern) return { maker: SectionMaker.Composed, pattern };
|
|
142
|
+
const layout = ctx.layoutSectionIds?.find(id => id === (root.label ?? '').trim());
|
|
143
|
+
if (layout) return { maker: SectionMaker.Composed, layout };
|
|
144
|
+
return { maker: SectionMaker.Owner };
|
|
145
|
+
}
|
|
@@ -43,9 +43,24 @@ export interface SerializedNode {
|
|
|
43
43
|
interactions: unknown[];
|
|
44
44
|
isGlobal?: boolean;
|
|
45
45
|
globalPosition?: `${PatternGlobalPosition}`;
|
|
46
|
+
/** A section root the build composed (site-redesign RD1 / M2-1): where it came from and how it was left, so a
|
|
47
|
+
* redesign knows what is the owner's (`section-stamp.ts`). Additive; no renderer reads it; a copy drops it. */
|
|
48
|
+
composed?: SectionStamp;
|
|
46
49
|
children?: SerializedNode[];
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A composed section's stamp (M2-1, site-redesign RD1): EXACTLY ONE of `pattern` (a library pattern — `composeSite`,
|
|
54
|
+
* or a section a layout fell back to) and `layout` (the id of a section a model laid out, M8); the section's build key
|
|
55
|
+
* (`section:<root id>`); and its fingerprint as the build left it (`sectionFingerprint`).
|
|
56
|
+
*/
|
|
57
|
+
export interface SectionStamp {
|
|
58
|
+
pattern?: string;
|
|
59
|
+
layout?: string;
|
|
60
|
+
buildKey: string;
|
|
61
|
+
fingerprint: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
/** A pattern the composer cannot stamp as the builder would (an unregistered type, a trait the type has
|
|
50
65
|
* no slot for, a style that does not apply). The plan is validated first, so this means the CONTRACT is
|
|
51
66
|
* wrong — never something to work around. */
|
|
@@ -9216,10 +9216,6 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9216
9216
|
"phase": "AW2",
|
|
9217
9217
|
"drawnAs": "none"
|
|
9218
9218
|
},
|
|
9219
|
-
"reopen.footer": {
|
|
9220
|
-
"phase": "AW1",
|
|
9221
|
-
"drawnAs": "settings"
|
|
9222
|
-
},
|
|
9223
9219
|
"reopen.pill": {
|
|
9224
9220
|
"phase": "AW2",
|
|
9225
9221
|
"drawnAs": "settings"
|
|
@@ -9401,12 +9397,12 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9401
9397
|
"how": "the site is in Hebrew"
|
|
9402
9398
|
},
|
|
9403
9399
|
"israel": {
|
|
9404
|
-
"read": "
|
|
9405
|
-
"how": "the studio's country is Israel (a
|
|
9400
|
+
"read": "built",
|
|
9401
|
+
"how": "the studio's country is Israel (Shop ▸ Settings ▸ country; a shekel studio starts in Israel)"
|
|
9406
9402
|
},
|
|
9407
9403
|
"eu-business": {
|
|
9408
|
-
"read": "
|
|
9409
|
-
"how": "the
|
|
9404
|
+
"read": "built",
|
|
9405
|
+
"how": "the studio's country asks for an imprint (`imprintCountries`: the EU, the EEA and Switzerland)"
|
|
9410
9406
|
},
|
|
9411
9407
|
"us-business": {
|
|
9412
9408
|
"read": "deferred",
|
|
@@ -9583,6 +9579,43 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9583
9579
|
"en": "By sending, you agree to the {terms} and {privacy}.",
|
|
9584
9580
|
"he": "בשליחה, את/ה מסכים/ה ל{terms} ול{privacy}."
|
|
9585
9581
|
},
|
|
9582
|
+
"formLinePrivacy": {
|
|
9583
|
+
"en": "By sending, you agree to the {privacy}.",
|
|
9584
|
+
"he": "בשליחה, את/ה מסכים/ה ל{privacy}."
|
|
9585
|
+
},
|
|
9586
|
+
"imprintCountries": [
|
|
9587
|
+
"AT",
|
|
9588
|
+
"BE",
|
|
9589
|
+
"BG",
|
|
9590
|
+
"HR",
|
|
9591
|
+
"CY",
|
|
9592
|
+
"CZ",
|
|
9593
|
+
"DK",
|
|
9594
|
+
"EE",
|
|
9595
|
+
"FI",
|
|
9596
|
+
"FR",
|
|
9597
|
+
"DE",
|
|
9598
|
+
"GR",
|
|
9599
|
+
"HU",
|
|
9600
|
+
"IE",
|
|
9601
|
+
"IT",
|
|
9602
|
+
"LV",
|
|
9603
|
+
"LT",
|
|
9604
|
+
"LU",
|
|
9605
|
+
"MT",
|
|
9606
|
+
"NL",
|
|
9607
|
+
"PL",
|
|
9608
|
+
"PT",
|
|
9609
|
+
"RO",
|
|
9610
|
+
"SK",
|
|
9611
|
+
"SI",
|
|
9612
|
+
"ES",
|
|
9613
|
+
"SE",
|
|
9614
|
+
"IS",
|
|
9615
|
+
"LI",
|
|
9616
|
+
"NO",
|
|
9617
|
+
"CH"
|
|
9618
|
+
],
|
|
9586
9619
|
"rules": {
|
|
9587
9620
|
"neverWritesPolicy": true,
|
|
9588
9621
|
"editedPageKept": true,
|
|
@@ -279,9 +279,13 @@ export function siteTreeOf(studio: SiteStudio): SiteTree {
|
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
const layout = page.layout ?? [];
|
|
282
|
+
// A page the build made that is not one of its plan's pages (AW1's stamped legal pages) is still the build's:
|
|
283
|
+
// drawn from its layout, Built — or Edited, by the same fingerprints (an edited legal page is kept by Undo).
|
|
284
|
+
const known = !!run && Array.isArray(run.edited);
|
|
282
285
|
return {
|
|
283
286
|
...base, sections: layout.map(handSection), data: handData(layout, studio, label),
|
|
284
|
-
maker: source?.runId ? SitePageMaker.
|
|
287
|
+
maker: !source?.runId ? SitePageMaker.Owner : known && run!.edited!.includes(page._id) ? SitePageMaker.Edited : SitePageMaker.Built,
|
|
288
|
+
...(run ? { editsKnown: known, builtAt: run.finishedAt ?? null } : {}), items: null,
|
|
285
289
|
};
|
|
286
290
|
});
|
|
287
291
|
const nested = nestSitePages(nodes);
|