@vectoriox/iox-ui 5.126.0 → 5.128.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/actions-core/index.d.ts +95 -2
- package/design-core/index.d.ts +148 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +93 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +191 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +426 -28
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +46 -45
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +248 -17
- package/index.d.ts +32 -38
- package/package.json +1 -1
- package/src/actions-core/public-api.ts +1 -0
- package/src/actions-core/reveal-origin.ts +141 -0
- package/src/design-core/flavor-spec.generated.ts +47 -0
- package/src/design-core/menu-look.ts +157 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/compose-site.ts +10 -5
- package/src/generation-core/header-mix.ts +38 -4
- package/src/generation-core/nav-shape.ts +80 -1
- package/src/generation-core/node-baselines.generated.ts +7 -2
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/site-spec.generated.ts +101 -15
- package/src/generation-core/site-tree.ts +313 -0
- package/styles/iox-design.css +381 -2
|
@@ -7796,11 +7796,16 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7796
7796
|
"menu": [
|
|
7797
7797
|
"drawer",
|
|
7798
7798
|
"full",
|
|
7799
|
-
"panel"
|
|
7799
|
+
"panel",
|
|
7800
|
+
"card",
|
|
7801
|
+
"mega"
|
|
7800
7802
|
],
|
|
7801
7803
|
"menuShows": [
|
|
7802
7804
|
"links",
|
|
7803
|
-
"pictures"
|
|
7805
|
+
"pictures",
|
|
7806
|
+
"big",
|
|
7807
|
+
"two-levels",
|
|
7808
|
+
"words-card"
|
|
7804
7809
|
],
|
|
7805
7810
|
"action": [
|
|
7806
7811
|
"none",
|
|
@@ -7811,7 +7816,8 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7811
7816
|
"ground": [
|
|
7812
7817
|
"solid",
|
|
7813
7818
|
"over",
|
|
7814
|
-
"glass"
|
|
7819
|
+
"glass",
|
|
7820
|
+
"blend"
|
|
7815
7821
|
],
|
|
7816
7822
|
"shape": [
|
|
7817
7823
|
"bar",
|
|
@@ -7838,6 +7844,34 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7838
7844
|
"bar",
|
|
7839
7845
|
"both",
|
|
7840
7846
|
"full"
|
|
7847
|
+
],
|
|
7848
|
+
"reveal": [
|
|
7849
|
+
"slide",
|
|
7850
|
+
"fade",
|
|
7851
|
+
"zoom",
|
|
7852
|
+
"circle",
|
|
7853
|
+
"torn"
|
|
7854
|
+
],
|
|
7855
|
+
"button": [
|
|
7856
|
+
"lines",
|
|
7857
|
+
"word",
|
|
7858
|
+
"dots"
|
|
7859
|
+
],
|
|
7860
|
+
"menuHover": [
|
|
7861
|
+
"line",
|
|
7862
|
+
"dim",
|
|
7863
|
+
"row",
|
|
7864
|
+
"none"
|
|
7865
|
+
],
|
|
7866
|
+
"above": [
|
|
7867
|
+
"none",
|
|
7868
|
+
"announcement",
|
|
7869
|
+
"marquee"
|
|
7870
|
+
],
|
|
7871
|
+
"inBar": [
|
|
7872
|
+
"none",
|
|
7873
|
+
"icons",
|
|
7874
|
+
"search"
|
|
7841
7875
|
]
|
|
7842
7876
|
},
|
|
7843
7877
|
"meanings": {
|
|
@@ -7850,11 +7884,16 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7850
7884
|
"pages.inline": "every page in the bar",
|
|
7851
7885
|
"pages.menu": "the pages behind the menu",
|
|
7852
7886
|
"pages.menu-pinned": "the pages behind the menu, one or two key pages kept in the bar",
|
|
7853
|
-
"menu.drawer": "a sheet from the
|
|
7887
|
+
"menu.drawer": "a sheet from the menu button's edge",
|
|
7854
7888
|
"menu.full": "a full-screen index of the page names, large",
|
|
7855
7889
|
"menu.panel": "a panel that drops from the top, as tall as its content",
|
|
7890
|
+
"menu.card": "a card that opens from the menu button's corner",
|
|
7891
|
+
"menu.mega": "a wide panel under the bar, its pages in columns",
|
|
7856
7892
|
"menuShows.links": "the page names",
|
|
7857
7893
|
"menuShows.pictures": "pictured cards for the main collections beside the page names",
|
|
7894
|
+
"menuShows.big": "the page names, large",
|
|
7895
|
+
"menuShows.two-levels": "sections, and the items of the one under the mouse with their counts",
|
|
7896
|
+
"menuShows.words-card": "the page names large, with a card (a picture or a reel) beside them",
|
|
7858
7897
|
"action.none": "no call to action",
|
|
7859
7898
|
"action.button": "one button",
|
|
7860
7899
|
"action.link": "one quiet link",
|
|
@@ -7862,6 +7901,7 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7862
7901
|
"ground.solid": "its own ground",
|
|
7863
7902
|
"ground.over": "over the opening, transparent until the page moves",
|
|
7864
7903
|
"ground.glass": "frosted glass (a look with a blur)",
|
|
7904
|
+
"ground.blend": "blends with what is under it, readable over any picture",
|
|
7865
7905
|
"shape.bar": "a full-width bar",
|
|
7866
7906
|
"shape.pill": "one floating rounded bar",
|
|
7867
7907
|
"shape.islands": "separate floating pills",
|
|
@@ -7877,24 +7917,42 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7877
7917
|
"phone.drawer": "a drawer on a phone",
|
|
7878
7918
|
"phone.bar": "a bottom bar on a phone",
|
|
7879
7919
|
"phone.both": "a bottom bar and a drawer on a phone",
|
|
7880
|
-
"phone.full": "a full-screen index on a phone"
|
|
7920
|
+
"phone.full": "a full-screen index on a phone",
|
|
7921
|
+
"reveal.slide": "slides in: a drawer from its edge, any other menu a short drop",
|
|
7922
|
+
"reveal.fade": "fades in",
|
|
7923
|
+
"reveal.zoom": "grows from the menu button's corner",
|
|
7924
|
+
"reveal.circle": "a circle that opens from the menu button",
|
|
7925
|
+
"reveal.torn": "a torn edge that opens from the menu button, rimmed in the accent",
|
|
7926
|
+
"button.lines": "three lines that become a cross",
|
|
7927
|
+
"button.word": "the word Menu, which becomes Close",
|
|
7928
|
+
"button.dots": "nine dots that spread under the mouse and become a cross",
|
|
7929
|
+
"menuHover.line": "a line draws under the page name",
|
|
7930
|
+
"menuHover.dim": "the other page names dim",
|
|
7931
|
+
"menuHover.row": "the row under the mouse lights up",
|
|
7932
|
+
"menuHover.none": "nothing moves under the mouse",
|
|
7933
|
+
"above.none": "nothing above the bar",
|
|
7934
|
+
"above.announcement": "one line of the owner's news above the bar",
|
|
7935
|
+
"above.marquee": "a moving band of the owner's words above the bar",
|
|
7936
|
+
"inBar.none": "nothing more in the bar",
|
|
7937
|
+
"inBar.icons": "small icons (sound, theme, chat) in the bar",
|
|
7938
|
+
"inBar.search": "a search field in the bar"
|
|
7881
7939
|
},
|
|
7882
7940
|
"waits": {
|
|
7883
|
-
"
|
|
7941
|
+
"menuShows.pictures": {
|
|
7884
7942
|
"phase": "HI2",
|
|
7885
|
-
"drawnAs": "
|
|
7943
|
+
"drawnAs": "links"
|
|
7886
7944
|
},
|
|
7887
|
-
"
|
|
7945
|
+
"menuShows.big": {
|
|
7888
7946
|
"phase": "HI2",
|
|
7889
|
-
"drawnAs": "
|
|
7947
|
+
"drawnAs": "links"
|
|
7890
7948
|
},
|
|
7891
|
-
"menuShows.
|
|
7949
|
+
"menuShows.words-card": {
|
|
7892
7950
|
"phase": "HI2",
|
|
7893
7951
|
"drawnAs": "links"
|
|
7894
7952
|
},
|
|
7895
|
-
"
|
|
7896
|
-
"phase": "
|
|
7897
|
-
"drawnAs": "
|
|
7953
|
+
"menuShows.two-levels": {
|
|
7954
|
+
"phase": "HI6",
|
|
7955
|
+
"drawnAs": "links"
|
|
7898
7956
|
},
|
|
7899
7957
|
"ground.over": {
|
|
7900
7958
|
"phase": "HI3",
|
|
@@ -7904,6 +7962,26 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7904
7962
|
"phase": "HI3",
|
|
7905
7963
|
"drawnAs": "solid"
|
|
7906
7964
|
},
|
|
7965
|
+
"ground.blend": {
|
|
7966
|
+
"phase": "HI3",
|
|
7967
|
+
"drawnAs": "solid"
|
|
7968
|
+
},
|
|
7969
|
+
"above.announcement": {
|
|
7970
|
+
"phase": "HI3",
|
|
7971
|
+
"drawnAs": "none"
|
|
7972
|
+
},
|
|
7973
|
+
"above.marquee": {
|
|
7974
|
+
"phase": "HI3",
|
|
7975
|
+
"drawnAs": "none"
|
|
7976
|
+
},
|
|
7977
|
+
"inBar.icons": {
|
|
7978
|
+
"phase": "HI3",
|
|
7979
|
+
"drawnAs": "none"
|
|
7980
|
+
},
|
|
7981
|
+
"inBar.search": {
|
|
7982
|
+
"phase": "HI6",
|
|
7983
|
+
"drawnAs": "none"
|
|
7984
|
+
},
|
|
7907
7985
|
"shape.pill": {
|
|
7908
7986
|
"phase": "HI3",
|
|
7909
7987
|
"drawnAs": "bar"
|
|
@@ -7933,7 +8011,12 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7933
8011
|
"brand": "fits",
|
|
7934
8012
|
"scroll": "hides",
|
|
7935
8013
|
"edge": "fade",
|
|
7936
|
-
"phone": "drawer"
|
|
8014
|
+
"phone": "drawer",
|
|
8015
|
+
"reveal": "slide",
|
|
8016
|
+
"button": "lines",
|
|
8017
|
+
"menuHover": "line",
|
|
8018
|
+
"above": "none",
|
|
8019
|
+
"inBar": "none"
|
|
7937
8020
|
},
|
|
7938
8021
|
"named": {
|
|
7939
8022
|
"nav.inline-cta": {},
|
|
@@ -7968,7 +8051,10 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
7968
8051
|
"pages",
|
|
7969
8052
|
"menu",
|
|
7970
8053
|
"ground",
|
|
7971
|
-
"shape"
|
|
8054
|
+
"shape",
|
|
8055
|
+
"reveal",
|
|
8056
|
+
"button",
|
|
8057
|
+
"above"
|
|
7972
8058
|
],
|
|
7973
8059
|
"rules": {
|
|
7974
8060
|
"menuMinLinks": 3,
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { LayoutPage } from './layout-language';
|
|
2
|
+
import { NavRole, NavShape, navShapeOf } from './nav-shape';
|
|
3
|
+
import { PageDataKind, PageDataLine, describePlanData } from './plan-data';
|
|
4
|
+
import { PatternGlobalPosition, patternById } from './patterns';
|
|
5
|
+
import { SerializedNode, walkSerialized } from './serialized-node';
|
|
6
|
+
import { CreatedKind, KeptReason, UndoPreview } from './site-build-run';
|
|
7
|
+
import { PagePlan, SitePlan } from './site-plan.model';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* THE SITE TREE (site-redesign-plan.md §3a, RD0, RD-D1): the site as a map — Home on top, the other pages below, a page
|
|
11
|
+
* per item under the page that lists them. DERIVED on read, never stored: from a plan (the wizard's Plan step) and from a
|
|
12
|
+
* studio (Pages ▸ Site map) in ONE shape, so both screens draw ONE view model with ONE component (R-H6). Pages have no
|
|
13
|
+
* parent field: a page's parent is the page whose route is the longest prefix of its own (`/work/:slug` → `/work`); a
|
|
14
|
+
* page with none sits in the row under Home. Pure.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Who made a page, as the Site map says it (its edge tag and footer row). */
|
|
18
|
+
export enum SitePageMaker {
|
|
19
|
+
/** A build made it and nobody changed it since (the build's fingerprints say so). */
|
|
20
|
+
Built = 'built',
|
|
21
|
+
/** A build made it and the owner changed it since — "Edited by you". */
|
|
22
|
+
Edited = 'edited',
|
|
23
|
+
/** No build made it — "Made by you". */
|
|
24
|
+
Owner = 'owner',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A section as the map draws it: a strip of its family's glyph. `pattern` is null on a hand-made page. */
|
|
28
|
+
export interface SiteTreeSection {
|
|
29
|
+
readonly pattern: string | null;
|
|
30
|
+
/** The section family (`hero`, `collection`, `contact`…) — what the strip is drawn as. */
|
|
31
|
+
readonly family: string;
|
|
32
|
+
readonly label: string;
|
|
33
|
+
/** It holds the page and moves as the visitor scrolls (SC6). */
|
|
34
|
+
readonly scene?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SiteTreePage {
|
|
38
|
+
/** The plan page key (a plan), or the page `_id` (a studio). */
|
|
39
|
+
readonly key: string;
|
|
40
|
+
/** The page document's `_id` — a studio's page only. */
|
|
41
|
+
readonly id?: string;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly route: string;
|
|
44
|
+
readonly isHome: boolean;
|
|
45
|
+
/** A page per item (its route holds a parameter). */
|
|
46
|
+
readonly template: boolean;
|
|
47
|
+
readonly sections: ReadonlyArray<SiteTreeSection>;
|
|
48
|
+
/** What it shows and where its data comes from (`describePlanData`'s lines; a hand-made page's read from its nodes). */
|
|
49
|
+
readonly data: ReadonlyArray<PageDataLine>;
|
|
50
|
+
/** A page the model composed: its layout, drawn as its own map instead of section strips. */
|
|
51
|
+
readonly layout?: LayoutPage;
|
|
52
|
+
/** A plan page answering an inferred need (the Plan step's "we added"). */
|
|
53
|
+
readonly need?: boolean;
|
|
54
|
+
/** A studio's page: who made it, its status and when it last changed. */
|
|
55
|
+
readonly maker?: SitePageMaker;
|
|
56
|
+
/** The build's fingerprints were read (else "Built" is all that is known — never "not changed since"). */
|
|
57
|
+
readonly editsKnown?: boolean;
|
|
58
|
+
readonly status?: string;
|
|
59
|
+
readonly changedAt?: string | null;
|
|
60
|
+
/** When the build that made it finished. */
|
|
61
|
+
readonly builtAt?: string | null;
|
|
62
|
+
/** A page per item: how many pages that is (its content type's item count), when known. */
|
|
63
|
+
readonly items?: number | null;
|
|
64
|
+
readonly children: ReadonlyArray<SiteTreePage>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SiteTreeType {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly label: string;
|
|
70
|
+
readonly fields: ReadonlyArray<string>;
|
|
71
|
+
/** A studio: its items. A plan: the samples the build will make. */
|
|
72
|
+
readonly count: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The header and footer every page wears, as the Content strip says them. */
|
|
76
|
+
export interface SiteTreeGlobals {
|
|
77
|
+
/** Links the header carries. */
|
|
78
|
+
readonly links: number;
|
|
79
|
+
readonly phoneMenu: `${NavShape}` | null;
|
|
80
|
+
/** The footer's copyright line, as written. */
|
|
81
|
+
readonly copyright: string | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SiteTree {
|
|
85
|
+
readonly home: SiteTreePage | null;
|
|
86
|
+
/** The row under Home, each with the pages under it (depth-first, nested by route). */
|
|
87
|
+
readonly pages: ReadonlyArray<SiteTreePage>;
|
|
88
|
+
readonly types: ReadonlyArray<SiteTreeType>;
|
|
89
|
+
readonly globals: SiteTreeGlobals | null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ── The parent rule ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
const segmentsOf = (route: string): string[] => String(route ?? '').split('/').filter(Boolean);
|
|
95
|
+
|
|
96
|
+
/** A route holding a parameter (`/work/:slug`) — a page per item. */
|
|
97
|
+
export const isTemplateRoute = (route: string): boolean => segmentsOf(route).some(s => s.startsWith(':'));
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The route of a page's parent among `routes`: the longest route that is a whole-segment prefix of it (`/work` for
|
|
101
|
+
* `/work/:slug`, never `/wor`), or null — then the page sits in the row under Home. Home (`/`) is never a parent here:
|
|
102
|
+
* every page is under it.
|
|
103
|
+
*/
|
|
104
|
+
export function siteParentRoute(route: string, routes: ReadonlyArray<string>): string | null {
|
|
105
|
+
const own = segmentsOf(route);
|
|
106
|
+
let best: string | null = null;
|
|
107
|
+
let bestLength = 0;
|
|
108
|
+
for (const candidate of routes) {
|
|
109
|
+
const segs = segmentsOf(candidate);
|
|
110
|
+
if (!segs.length || segs.length >= own.length || segs.length <= bestLength) continue;
|
|
111
|
+
if (segs.every((s, i) => s === own[i])) { best = candidate; bestLength = segs.length; }
|
|
112
|
+
}
|
|
113
|
+
return best;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type Draft = Omit<SiteTreePage, 'children'> & { children: Draft[] };
|
|
117
|
+
|
|
118
|
+
/** Pages into the tree: Home apart, every other page under its parent (`siteParentRoute`), in the given order. */
|
|
119
|
+
export function nestSitePages(pages: ReadonlyArray<Omit<SiteTreePage, 'children'>>): { home: SiteTreePage | null; pages: SiteTreePage[] } {
|
|
120
|
+
const homePage = pages.find(p => p.isHome) ?? null;
|
|
121
|
+
const rest = pages.filter(p => p !== homePage);
|
|
122
|
+
const drafts: Draft[] = rest.map(p => ({ ...p, children: [] }));
|
|
123
|
+
const byRoute = new Map(drafts.map(d => [d.route, d]));
|
|
124
|
+
const routes = drafts.map(d => d.route);
|
|
125
|
+
const top: Draft[] = [];
|
|
126
|
+
for (const d of drafts) {
|
|
127
|
+
const parent = siteParentRoute(d.route, routes);
|
|
128
|
+
const holder = parent ? byRoute.get(parent) : undefined;
|
|
129
|
+
if (holder && holder !== d) holder.children.push(d); else top.push(d);
|
|
130
|
+
}
|
|
131
|
+
return { home: homePage ? { ...homePage, children: [] } : null, pages: top };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Every page of the tree, depth-first (Home first). */
|
|
135
|
+
export function sitePagesOf(tree: Pick<SiteTree, 'home' | 'pages'>): SiteTreePage[] {
|
|
136
|
+
const out: SiteTreePage[] = tree.home ? [tree.home] : [];
|
|
137
|
+
const walk = (p: SiteTreePage) => { out.push(p); p.children.forEach(walk); };
|
|
138
|
+
tree.pages.forEach(walk);
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ── From a plan (the wizard's Plan step) ─────────────────────────────────────────────────────────────────────────
|
|
143
|
+
|
|
144
|
+
const sectionOfPattern = (id: string): SiteTreeSection => {
|
|
145
|
+
const pattern = patternById(id);
|
|
146
|
+
return { pattern: id, family: id.split('.')[0], label: pattern?.label ?? id, ...(pattern?.scene ? { scene: true } : {}) };
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
function planPage(p: PagePlan, data: ReadonlyArray<PageDataLine>): Omit<SiteTreePage, 'children'> {
|
|
150
|
+
return {
|
|
151
|
+
key: p.key, name: p.name, route: p.route, isHome: !!p.isHome, template: !!p.template,
|
|
152
|
+
sections: p.sections.map(s => sectionOfPattern(s.pattern)), data,
|
|
153
|
+
...(p.layout ? { layout: p.layout } : {}), ...(p.need ? { need: true } : {}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** A plan as the site tree: the map the Plan step draws (the samples each content type will have). */
|
|
158
|
+
export function siteTreeOfPlan(plan: SitePlan): SiteTree {
|
|
159
|
+
const data = new Map(describePlanData(plan).map(d => [d.pageKey, d.lines]));
|
|
160
|
+
const nested = nestSitePages(plan.pages.map(p => planPage(p, data.get(p.key) ?? [])));
|
|
161
|
+
return {
|
|
162
|
+
...nested,
|
|
163
|
+
types: plan.contentTypes.map(t => ({ name: t.name, label: t.label, fields: t.fields.map(f => f.name), count: t.seed?.count ?? 0 })),
|
|
164
|
+
globals: null,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ── From a studio (Pages ▸ Site map) ─────────────────────────────────────────────────────────────────────────────
|
|
169
|
+
|
|
170
|
+
/** A page document as the Pages list reads it. */
|
|
171
|
+
export interface SiteStudioPage {
|
|
172
|
+
readonly _id: string;
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly route: { readonly path: string } | string;
|
|
175
|
+
readonly isHome?: boolean;
|
|
176
|
+
readonly status?: string;
|
|
177
|
+
readonly updatedAt?: string | null;
|
|
178
|
+
readonly layout?: ReadonlyArray<SerializedNode> | null;
|
|
179
|
+
readonly pageSettings?: { readonly layoutSource?: { readonly runId?: string; readonly pageKey?: string } | null } | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** A build run the studio's pages name (`layoutSource.runId`): its plan, when it finished, and the pages its fingerprints
|
|
183
|
+
* say were changed since (`editedPageIds` of its undo preview; null when it could not be read). */
|
|
184
|
+
export interface SiteStudioRun {
|
|
185
|
+
readonly id: string;
|
|
186
|
+
readonly plan: SitePlan;
|
|
187
|
+
readonly finishedAt?: string | null;
|
|
188
|
+
readonly edited?: ReadonlyArray<string> | null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface SiteStudio {
|
|
192
|
+
readonly pages: ReadonlyArray<SiteStudioPage>;
|
|
193
|
+
readonly runs?: ReadonlyArray<SiteStudioRun>;
|
|
194
|
+
/** The studio's content types with their item counts. */
|
|
195
|
+
readonly contentTypes?: ReadonlyArray<{ readonly name: string; readonly label?: string; readonly fields?: ReadonlyArray<string>; readonly count?: number | null }>;
|
|
196
|
+
/** The org's data sources (alias → content type), to say what a hand-made page lists. */
|
|
197
|
+
readonly dataSources?: ReadonlyArray<{ readonly alias: string; readonly contentType?: string | null }>;
|
|
198
|
+
/** The global elements (header, footer, dialogs). */
|
|
199
|
+
readonly globals?: ReadonlyArray<SerializedNode> | null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** The page ids a build's undo preview keeps because the owner changed them — the W2 fingerprints, the one judge. */
|
|
203
|
+
export function editedPageIds(preview: Pick<UndoPreview, 'kept'> | null | undefined): string[] | null {
|
|
204
|
+
if (!preview) return null;
|
|
205
|
+
return preview.kept.filter(k => k.kind === CreatedKind.Page && k.reason === KeptReason.Edited).map(k => k.id);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const routeOf = (route: SiteStudioPage['route']): string => (typeof route === 'string' ? route : route?.path ?? '');
|
|
209
|
+
|
|
210
|
+
/** A hand-made section's family, by what it holds: first match wins (the map's strips are a sketch, never a claim). */
|
|
211
|
+
const FAMILY_BY_CONTENT: ReadonlyArray<{ family: string; types: ReadonlyArray<string> }> = [
|
|
212
|
+
{ family: 'contact', types: ['Form'] },
|
|
213
|
+
{ family: 'collection', types: ['Repeater', 'SliderContainer', 'List', 'Gallery'] },
|
|
214
|
+
{ family: 'project', types: ['Image', 'Video'] },
|
|
215
|
+
];
|
|
216
|
+
const FIRST_FAMILY = 'hero';
|
|
217
|
+
const PLAIN_FAMILY = 'feature';
|
|
218
|
+
const SOURCE_PROP = 'source';
|
|
219
|
+
|
|
220
|
+
function typesUnder(node: SerializedNode): Set<string> {
|
|
221
|
+
const types = new Set<string>();
|
|
222
|
+
walkSerialized([node], n => { types.add(n.type); });
|
|
223
|
+
return types;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** A top-level node of a hand-made page as a strip: the first one with a picture opens the page. */
|
|
227
|
+
function handSection(node: SerializedNode, index: number): SiteTreeSection {
|
|
228
|
+
const types = typesUnder(node);
|
|
229
|
+
const found = FAMILY_BY_CONTENT.find(f => f.types.some(t => types.has(t)))?.family;
|
|
230
|
+
const family = index === 0 && found === 'project' ? FIRST_FAMILY : found ?? PLAIN_FAMILY;
|
|
231
|
+
return { pattern: null, family, label: node.label || node.type };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** What a hand-made page shows: each list it repeats (by its data source's content type), each form, else words. */
|
|
235
|
+
function handData(layout: ReadonlyArray<SerializedNode>, studio: SiteStudio, label: (type: string) => string): PageDataLine[] {
|
|
236
|
+
const lines: PageDataLine[] = [];
|
|
237
|
+
const add = (line: PageDataLine) => { if (!lines.some(l => JSON.stringify(l) === JSON.stringify(line))) lines.push(line); };
|
|
238
|
+
const typeOfAlias = new Map((studio.dataSources ?? []).map(d => [d.alias, d.contentType ?? null]));
|
|
239
|
+
walkSerialized(layout as SerializedNode[], n => {
|
|
240
|
+
if (n.type === 'Form') add({ kind: PageDataKind.Form });
|
|
241
|
+
const source = n.bindings?.find(b => b.prop === SOURCE_PROP)?.source;
|
|
242
|
+
const type = source ? typeOfAlias.get(source) : null;
|
|
243
|
+
if (type) add({ kind: PageDataKind.List, contentType: label(type) });
|
|
244
|
+
});
|
|
245
|
+
return lines.length ? lines : [{ kind: PageDataKind.Static }];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A studio as the site tree: each page drawn from the build that made it (its plan page — sections, data lines, the
|
|
250
|
+
* composed layout) when it has one, else from its own top-level nodes; who made it (`SitePageMaker`), its status, when
|
|
251
|
+
* it changed; a page per item counted from its content type; the header and footer in words. Pure.
|
|
252
|
+
*/
|
|
253
|
+
export function siteTreeOf(studio: SiteStudio): SiteTree {
|
|
254
|
+
const runs = new Map((studio.runs ?? []).map(r => [r.id, r]));
|
|
255
|
+
const types = studio.contentTypes ?? [];
|
|
256
|
+
const label = (name: string) => types.find(t => t.name === name)?.label || name;
|
|
257
|
+
const countOf = (name: string | undefined) => (name ? types.find(t => t.name === name)?.count ?? null : null);
|
|
258
|
+
const planData = new Map<string, Map<string, PageDataLine[]>>();
|
|
259
|
+
const dataOf = (run: SiteStudioRun, key: string): PageDataLine[] => {
|
|
260
|
+
if (!planData.has(run.id)) planData.set(run.id, new Map(describePlanData(run.plan).map(d => [d.pageKey, d.lines])));
|
|
261
|
+
return planData.get(run.id)!.get(key) ?? [];
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const nodes = studio.pages.map((page): Omit<SiteTreePage, 'children'> => {
|
|
265
|
+
const route = routeOf(page.route);
|
|
266
|
+
const base = {
|
|
267
|
+
key: page._id, id: page._id, name: page.name, route, isHome: !!page.isHome, template: isTemplateRoute(route),
|
|
268
|
+
status: page.status, changedAt: page.updatedAt ?? null,
|
|
269
|
+
};
|
|
270
|
+
const source = page.pageSettings?.layoutSource;
|
|
271
|
+
const run = source?.runId ? runs.get(source.runId) : undefined;
|
|
272
|
+
const planned = run && source?.pageKey ? run.plan.pages.find(p => p.key === source.pageKey) : undefined;
|
|
273
|
+
if (run && planned) {
|
|
274
|
+
const known = Array.isArray(run.edited);
|
|
275
|
+
return {
|
|
276
|
+
...planPage(planned, dataOf(run, planned.key)), ...base,
|
|
277
|
+
maker: known && run.edited!.includes(page._id) ? SitePageMaker.Edited : SitePageMaker.Built, editsKnown: known,
|
|
278
|
+
builtAt: run.finishedAt ?? null, items: planned.template ? countOf(planned.template) : null,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
const layout = page.layout ?? [];
|
|
282
|
+
return {
|
|
283
|
+
...base, sections: layout.map(handSection), data: handData(layout, studio, label),
|
|
284
|
+
maker: source?.runId ? SitePageMaker.Built : SitePageMaker.Owner, items: null,
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
const nested = nestSitePages(nodes);
|
|
288
|
+
return {
|
|
289
|
+
...nested,
|
|
290
|
+
types: types.map(t => ({ name: t.name, label: t.label || t.name, fields: [...(t.fields ?? [])], count: t.count ?? 0 })),
|
|
291
|
+
globals: studio.globals ? siteGlobalsOf(studio.globals) : null,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const LINK_TYPES: ReadonlySet<string> = new Set(['Link', 'ButtonBlock']);
|
|
296
|
+
const COPYRIGHT = '©';
|
|
297
|
+
|
|
298
|
+
/** The header and footer in words: the header's links (its navigation's own when it has one — the drawer repeats them),
|
|
299
|
+
* its phone menu, the footer's copyright line. */
|
|
300
|
+
export function siteGlobalsOf(globals: ReadonlyArray<SerializedNode>): SiteTreeGlobals | null {
|
|
301
|
+
if (!globals.length) return null;
|
|
302
|
+
const header: SerializedNode[] = [];
|
|
303
|
+
let copyright: string | null = null;
|
|
304
|
+
for (const g of globals) {
|
|
305
|
+
walkSerialized([g], n => {
|
|
306
|
+
if (g.globalPosition !== PatternGlobalPosition.After) header.push(n);
|
|
307
|
+
const text = String(n.props?.['content'] ?? n.props?.['text'] ?? '');
|
|
308
|
+
if (!copyright && g.globalPosition === PatternGlobalPosition.After && text.includes(COPYRIGHT)) copyright = text.replace(/<[^>]*>/g, '').trim();
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
const navLinks = header.filter(n => n.role === NavRole.Link).length;
|
|
312
|
+
return { links: navLinks || header.filter(n => LINK_TYPES.has(n.type)).length, phoneMenu: navShapeOf(globals), copyright };
|
|
313
|
+
}
|