@brandlab-digital/site-core 3.10.0 → 3.11.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/dist/google-business-reviews.d.ts +42 -0
- package/dist/google-business-reviews.d.ts.map +1 -1
- package/dist/google-business-reviews.js +85 -7
- package/dist/google-business-reviews.js.map +1 -1
- package/dist/media.d.ts +47 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +68 -0
- package/dist/media.js.map +1 -0
- package/dist/prices.d.ts +91 -0
- package/dist/prices.d.ts.map +1 -0
- package/dist/prices.js +176 -0
- package/dist/prices.js.map +1 -0
- package/dist/section-order.d.ts +158 -0
- package/dist/section-order.d.ts.map +1 -0
- package/dist/section-order.js +498 -0
- package/dist/section-order.js.map +1 -0
- package/package.json +13 -1
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section order (v2 §3.3 matrix part A; LIB §7a for hubs and company pages). Every page family has a default order of
|
|
3
|
+
* sections, each required (R: skipped only when nothing true exists, and the manifest says why), conditional (C:
|
|
4
|
+
* renders when its data exists), recommended (Rec) or optional (O). Sections a family doesn't use (N) are not in its
|
|
5
|
+
* list. The hero or page header comes first and the CTA band last; a site may record an alternative order per family.
|
|
6
|
+
* The permit note is a line inside `LocalFacts` (permit trades), not a section of its own.
|
|
7
|
+
*
|
|
8
|
+
* `planSectionSequence` is the sequencer's logic (F15), shared by `SectionSequence` in site-next and the K8 and K12
|
|
9
|
+
* checks: skip what has nothing true to show, enforce the cap (only optional and recommended sections drop),
|
|
10
|
+
* alternate the light tones so neighbours differ (at most one `band` and one `photo`) and write the per-page manifest.
|
|
11
|
+
*/
|
|
12
|
+
export const BRANDLAB_SECTION_IDS = [
|
|
13
|
+
'hero',
|
|
14
|
+
'page-header',
|
|
15
|
+
'article-header',
|
|
16
|
+
'answer',
|
|
17
|
+
'proof-strip',
|
|
18
|
+
'emergency',
|
|
19
|
+
'services',
|
|
20
|
+
'local-facts',
|
|
21
|
+
'nearby-jobs',
|
|
22
|
+
'service-detail',
|
|
23
|
+
'price-guide',
|
|
24
|
+
'projects',
|
|
25
|
+
'before-after',
|
|
26
|
+
'gallery',
|
|
27
|
+
'reviews',
|
|
28
|
+
'comparison',
|
|
29
|
+
'about-owner',
|
|
30
|
+
'signature',
|
|
31
|
+
'process',
|
|
32
|
+
'guarantee',
|
|
33
|
+
'licences',
|
|
34
|
+
'partners',
|
|
35
|
+
'team',
|
|
36
|
+
'coverage',
|
|
37
|
+
'area-map',
|
|
38
|
+
'faqs',
|
|
39
|
+
'nearby-areas',
|
|
40
|
+
'related-services',
|
|
41
|
+
'guides',
|
|
42
|
+
'contact',
|
|
43
|
+
'cta',
|
|
44
|
+
];
|
|
45
|
+
export const BRANDLAB_PAGE_FAMILIES = [
|
|
46
|
+
'home',
|
|
47
|
+
'service',
|
|
48
|
+
'service-in-suburb',
|
|
49
|
+
'region',
|
|
50
|
+
'suburb',
|
|
51
|
+
'cost-guide',
|
|
52
|
+
'services-hub',
|
|
53
|
+
'locations-hub',
|
|
54
|
+
'projects-hub',
|
|
55
|
+
'project',
|
|
56
|
+
'gallery',
|
|
57
|
+
'reviews',
|
|
58
|
+
'about',
|
|
59
|
+
'faqs',
|
|
60
|
+
'contact',
|
|
61
|
+
'guides-hub',
|
|
62
|
+
'guide',
|
|
63
|
+
'council',
|
|
64
|
+
'emergency',
|
|
65
|
+
];
|
|
66
|
+
/** R required, C conditional, Rec recommended, O optional (N, not used, is simply absent from a family's list). */
|
|
67
|
+
export const BRANDLAB_SECTION_REQUIREMENTS = ['R', 'C', 'Rec', 'O'];
|
|
68
|
+
/** The section tones: two alternating grounds, one optional band and one optional photo ground. */
|
|
69
|
+
export const BRANDLAB_SECTION_TONES = ['canvas', 'surface', 'band', 'photo'];
|
|
70
|
+
/** 11 on home and service-in-suburb pages, 12 on service, region and suburb pages, 6 on hubs and company pages. */
|
|
71
|
+
export const SECTION_CAPS = Object.freeze({
|
|
72
|
+
home: 11,
|
|
73
|
+
service: 12,
|
|
74
|
+
'service-in-suburb': 11,
|
|
75
|
+
region: 12,
|
|
76
|
+
suburb: 12,
|
|
77
|
+
'cost-guide': 12,
|
|
78
|
+
'services-hub': 6,
|
|
79
|
+
'locations-hub': 6,
|
|
80
|
+
'projects-hub': 6,
|
|
81
|
+
project: 6,
|
|
82
|
+
gallery: 6,
|
|
83
|
+
reviews: 6,
|
|
84
|
+
about: 6,
|
|
85
|
+
faqs: 6,
|
|
86
|
+
contact: 6,
|
|
87
|
+
'guides-hub': 6,
|
|
88
|
+
guide: 6,
|
|
89
|
+
council: 6,
|
|
90
|
+
emergency: 6,
|
|
91
|
+
});
|
|
92
|
+
const PROJECTS = ['projects', 'C', ['before-after']];
|
|
93
|
+
/** The defaults, in order. `EmergencyBand` has no number in the matrix; it sits straight after the proof strip. */
|
|
94
|
+
const DEFAULT_ROWS = {
|
|
95
|
+
home: [
|
|
96
|
+
['hero', 'R'],
|
|
97
|
+
['proof-strip', 'R'],
|
|
98
|
+
['emergency', 'C'],
|
|
99
|
+
['services', 'R'],
|
|
100
|
+
PROJECTS,
|
|
101
|
+
['reviews', 'C'],
|
|
102
|
+
['price-guide', 'Rec'],
|
|
103
|
+
['about-owner', 'O'],
|
|
104
|
+
['signature', 'O'],
|
|
105
|
+
['process', 'O'],
|
|
106
|
+
['guarantee', 'O'],
|
|
107
|
+
['coverage', 'R'],
|
|
108
|
+
['faqs', 'Rec'],
|
|
109
|
+
['guides', 'C'],
|
|
110
|
+
['cta', 'R'],
|
|
111
|
+
],
|
|
112
|
+
service: [
|
|
113
|
+
['hero', 'R'],
|
|
114
|
+
['proof-strip', 'R'],
|
|
115
|
+
['emergency', 'C'],
|
|
116
|
+
['service-detail', 'R'],
|
|
117
|
+
['price-guide', 'R'],
|
|
118
|
+
PROJECTS,
|
|
119
|
+
['reviews', 'C'],
|
|
120
|
+
['about-owner', 'O'],
|
|
121
|
+
['comparison', 'O'],
|
|
122
|
+
['signature', 'O'],
|
|
123
|
+
['process', 'O'],
|
|
124
|
+
['guarantee', 'C'],
|
|
125
|
+
['faqs', 'R'],
|
|
126
|
+
['related-services', 'C'],
|
|
127
|
+
['coverage', 'C'],
|
|
128
|
+
['guides', 'C'],
|
|
129
|
+
['cta', 'R'],
|
|
130
|
+
],
|
|
131
|
+
'service-in-suburb': [
|
|
132
|
+
['hero', 'R'],
|
|
133
|
+
['proof-strip', 'R'],
|
|
134
|
+
['emergency', 'C'],
|
|
135
|
+
['local-facts', 'R'],
|
|
136
|
+
['nearby-jobs', 'R'],
|
|
137
|
+
['price-guide', 'R'],
|
|
138
|
+
['service-detail', 'R'],
|
|
139
|
+
['reviews', 'R'],
|
|
140
|
+
['faqs', 'R'],
|
|
141
|
+
['nearby-areas', 'R'],
|
|
142
|
+
['related-services', 'R', undefined, 'nearby-areas'],
|
|
143
|
+
['cta', 'R'],
|
|
144
|
+
],
|
|
145
|
+
region: [
|
|
146
|
+
['hero', 'R'],
|
|
147
|
+
['proof-strip', 'R'],
|
|
148
|
+
['service-detail', 'R'],
|
|
149
|
+
['services', 'R'],
|
|
150
|
+
PROJECTS,
|
|
151
|
+
['reviews', 'C'],
|
|
152
|
+
['price-guide', 'C'],
|
|
153
|
+
['coverage', 'R'],
|
|
154
|
+
['faqs', 'R'],
|
|
155
|
+
['area-map', 'O'],
|
|
156
|
+
['cta', 'R'],
|
|
157
|
+
],
|
|
158
|
+
suburb: [
|
|
159
|
+
['hero', 'R'],
|
|
160
|
+
['proof-strip', 'R'],
|
|
161
|
+
['local-facts', 'R'],
|
|
162
|
+
['services', 'R'],
|
|
163
|
+
['price-guide', 'C'],
|
|
164
|
+
['nearby-jobs', 'C'],
|
|
165
|
+
['reviews', 'C'],
|
|
166
|
+
['faqs', 'R'],
|
|
167
|
+
['area-map', 'R'],
|
|
168
|
+
['cta', 'R'],
|
|
169
|
+
],
|
|
170
|
+
'cost-guide': [
|
|
171
|
+
['article-header', 'R'],
|
|
172
|
+
['answer', 'R'],
|
|
173
|
+
['price-guide', 'R'],
|
|
174
|
+
['service-detail', 'R'],
|
|
175
|
+
['comparison', 'O'],
|
|
176
|
+
PROJECTS,
|
|
177
|
+
['faqs', 'Rec'],
|
|
178
|
+
['cta', 'R'],
|
|
179
|
+
],
|
|
180
|
+
'services-hub': [
|
|
181
|
+
['page-header', 'R'],
|
|
182
|
+
['services', 'R'],
|
|
183
|
+
['reviews', 'C'],
|
|
184
|
+
['cta', 'R'],
|
|
185
|
+
],
|
|
186
|
+
'locations-hub': [
|
|
187
|
+
['page-header', 'R'],
|
|
188
|
+
['coverage', 'R'],
|
|
189
|
+
['cta', 'R'],
|
|
190
|
+
],
|
|
191
|
+
'projects-hub': [
|
|
192
|
+
['page-header', 'R'],
|
|
193
|
+
['projects', 'R'],
|
|
194
|
+
['reviews', 'C'],
|
|
195
|
+
['cta', 'R'],
|
|
196
|
+
],
|
|
197
|
+
project: [
|
|
198
|
+
['hero', 'R', ['page-header']],
|
|
199
|
+
['gallery', 'R'],
|
|
200
|
+
['service-detail', 'R'],
|
|
201
|
+
['reviews', 'C'],
|
|
202
|
+
['related-services', 'R'],
|
|
203
|
+
['cta', 'R'],
|
|
204
|
+
],
|
|
205
|
+
gallery: [
|
|
206
|
+
['page-header', 'R'],
|
|
207
|
+
['gallery', 'R'],
|
|
208
|
+
['cta', 'R'],
|
|
209
|
+
],
|
|
210
|
+
reviews: [
|
|
211
|
+
['page-header', 'R'],
|
|
212
|
+
['reviews', 'R'],
|
|
213
|
+
['cta', 'R'],
|
|
214
|
+
],
|
|
215
|
+
about: [
|
|
216
|
+
['page-header', 'R'],
|
|
217
|
+
['about-owner', 'R'],
|
|
218
|
+
['licences', 'C'],
|
|
219
|
+
['partners', 'C'],
|
|
220
|
+
['reviews', 'C'],
|
|
221
|
+
['team', 'O'],
|
|
222
|
+
['cta', 'R'],
|
|
223
|
+
],
|
|
224
|
+
faqs: [
|
|
225
|
+
['page-header', 'R'],
|
|
226
|
+
['faqs', 'R'],
|
|
227
|
+
['cta', 'R'],
|
|
228
|
+
],
|
|
229
|
+
// The contact page is the page header and the contact block, and nothing else (K12-contact).
|
|
230
|
+
contact: [
|
|
231
|
+
['page-header', 'R'],
|
|
232
|
+
['contact', 'R'],
|
|
233
|
+
],
|
|
234
|
+
'guides-hub': [
|
|
235
|
+
['page-header', 'R'],
|
|
236
|
+
['guides', 'R'],
|
|
237
|
+
['cta', 'R'],
|
|
238
|
+
],
|
|
239
|
+
guide: [
|
|
240
|
+
['article-header', 'R'],
|
|
241
|
+
['service-detail', 'R'],
|
|
242
|
+
['cta', 'R'],
|
|
243
|
+
],
|
|
244
|
+
council: [
|
|
245
|
+
['page-header', 'R'],
|
|
246
|
+
['service-detail', 'R'],
|
|
247
|
+
['cta', 'R'],
|
|
248
|
+
],
|
|
249
|
+
emergency: [
|
|
250
|
+
['hero', 'R'],
|
|
251
|
+
['emergency', 'R'],
|
|
252
|
+
['service-detail', 'R'],
|
|
253
|
+
['reviews', 'C'],
|
|
254
|
+
['cta', 'R'],
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
function toEntry([id, requirement, alternatives, countsWith]) {
|
|
258
|
+
return Object.freeze({
|
|
259
|
+
id,
|
|
260
|
+
requirement,
|
|
261
|
+
...(alternatives ? { alternatives: Object.freeze([...alternatives]) } : {}),
|
|
262
|
+
...(countsWith ? { countsWith } : {}),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/** The playbook trades (v2 §5, matrix part B). */
|
|
266
|
+
export const BRANDLAB_TRADES = [
|
|
267
|
+
'building',
|
|
268
|
+
'electrical',
|
|
269
|
+
'exterior',
|
|
270
|
+
'interiors',
|
|
271
|
+
'landscaping',
|
|
272
|
+
'plumbing',
|
|
273
|
+
'pools',
|
|
274
|
+
'renovations',
|
|
275
|
+
'roofing',
|
|
276
|
+
'tiling',
|
|
277
|
+
'trees',
|
|
278
|
+
];
|
|
279
|
+
/**
|
|
280
|
+
* The trade map (matrix part B). A stub in 3.11.0: every trade uses the defaults until its playbook's rules are
|
|
281
|
+
* confirmed per client (licence classes, permit notes and emergency work are "inferred, confirm" in the matrix).
|
|
282
|
+
*/
|
|
283
|
+
export const SECTION_ORDER_TRADE_MAP = Object.freeze(Object.fromEntries(BRANDLAB_TRADES.map((trade) => [trade, Object.freeze({})])));
|
|
284
|
+
/** A family's default order, with the trade's rules applied. */
|
|
285
|
+
export function defaultSectionOrder(family, trade, tradeMap = SECTION_ORDER_TRADE_MAP) {
|
|
286
|
+
const rows = DEFAULT_ROWS[family];
|
|
287
|
+
if (!rows)
|
|
288
|
+
throw new Error(`Unknown page family "${family}".`);
|
|
289
|
+
const rules = trade ? tradeMap[trade]?.[family] : undefined;
|
|
290
|
+
const entries = rows.map((row) => {
|
|
291
|
+
const requirement = rules?.[row[0]];
|
|
292
|
+
return toEntry(requirement ? [row[0], requirement, row[2], row[3]] : row);
|
|
293
|
+
});
|
|
294
|
+
return Object.freeze({ family, cap: SECTION_CAPS[family], source: 'default', entries: Object.freeze(entries) });
|
|
295
|
+
}
|
|
296
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
297
|
+
function recordedOrder(base, recorded) {
|
|
298
|
+
const family = base.family;
|
|
299
|
+
const fail = (detail) => {
|
|
300
|
+
throw new Error(`Recorded section order for ${family}: ${detail}`);
|
|
301
|
+
};
|
|
302
|
+
if (family === 'contact')
|
|
303
|
+
fail('the contact page is the page header and the contact block, and nothing else.');
|
|
304
|
+
if (typeof recorded.decision !== 'string' || !recorded.decision.trim())
|
|
305
|
+
fail('decision must say who decided and why.');
|
|
306
|
+
if (typeof recorded.recordedOn !== 'string' || !ISO_DATE.test(recorded.recordedOn) || Number.isNaN(Date.parse(recorded.recordedOn))) {
|
|
307
|
+
fail('recordedOn must be a YYYY-MM-DD date.');
|
|
308
|
+
}
|
|
309
|
+
if (!Array.isArray(recorded.order) || recorded.order.length === 0)
|
|
310
|
+
fail('order must list the sections.');
|
|
311
|
+
const byId = new Map(base.entries.map((entry) => [entry.id, entry]));
|
|
312
|
+
const seen = new Set();
|
|
313
|
+
for (const id of recorded.order) {
|
|
314
|
+
if (!byId.has(id))
|
|
315
|
+
fail(`"${id}" is not used on ${family} pages.`);
|
|
316
|
+
if (seen.has(id))
|
|
317
|
+
fail(`"${id}" appears twice.`);
|
|
318
|
+
seen.add(id);
|
|
319
|
+
}
|
|
320
|
+
for (const entry of base.entries) {
|
|
321
|
+
if ((entry.requirement === 'R' || entry.requirement === 'C') && !seen.has(entry.id)) {
|
|
322
|
+
fail(`"${entry.id}" is ${entry.requirement === 'R' ? 'required' : 'conditional'} and must stay in the order.`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const first = base.entries[0]?.id;
|
|
326
|
+
const last = base.entries[base.entries.length - 1]?.id;
|
|
327
|
+
if (recorded.order[0] !== first)
|
|
328
|
+
fail(`"${first}" comes first.`);
|
|
329
|
+
if (last === 'cta' && recorded.order[recorded.order.length - 1] !== 'cta')
|
|
330
|
+
fail('the CTA band comes last.');
|
|
331
|
+
const proof = recorded.order.indexOf('proof-strip');
|
|
332
|
+
if (proof >= 5)
|
|
333
|
+
fail('the proof strip stays within the first five sections.');
|
|
334
|
+
return Object.freeze({
|
|
335
|
+
family,
|
|
336
|
+
cap: base.cap,
|
|
337
|
+
source: 'recorded',
|
|
338
|
+
entries: Object.freeze(recorded.order.map((id) => byId.get(id))),
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Declares a site's section orders (`src/data/strategy.ts`): the defaults for every family, the trade's rules and any
|
|
343
|
+
* recorded alternative orders. A recorded order keeps every required and conditional section, the first section
|
|
344
|
+
* first, the CTA band last and the proof strip within the first five; the contact page can't be reordered.
|
|
345
|
+
*/
|
|
346
|
+
export function defineSectionOrder(input = {}, tradeMap = SECTION_ORDER_TRADE_MAP) {
|
|
347
|
+
if (input.trade !== undefined && !BRANDLAB_TRADES.includes(input.trade)) {
|
|
348
|
+
throw new Error(`Unknown trade "${input.trade}".`);
|
|
349
|
+
}
|
|
350
|
+
for (const family of Object.keys(input.recorded ?? {})) {
|
|
351
|
+
if (!BRANDLAB_PAGE_FAMILIES.includes(family))
|
|
352
|
+
throw new Error(`Unknown page family "${family}".`);
|
|
353
|
+
}
|
|
354
|
+
const orders = Object.fromEntries(BRANDLAB_PAGE_FAMILIES.map((family) => {
|
|
355
|
+
const base = defaultSectionOrder(family, input.trade, tradeMap);
|
|
356
|
+
const recorded = input.recorded?.[family];
|
|
357
|
+
return [family, recorded ? recordedOrder(base, recorded) : base];
|
|
358
|
+
}));
|
|
359
|
+
return Object.freeze(orders);
|
|
360
|
+
}
|
|
361
|
+
/** The reasons the sequencer itself skips a section. */
|
|
362
|
+
export const SEQUENCER_SKIP_REASONS = ['not-provided', 'not-in-order', 'duplicate', 'cap'];
|
|
363
|
+
export const SECTION_READY = Object.freeze({ render: true });
|
|
364
|
+
/** Whether a skip reason says the data isn't there (as opposed to the sequencer's own reasons). */
|
|
365
|
+
export function isDataBackedSkipReason(reason) {
|
|
366
|
+
return reason === 'merge-into-hero-checklist' || /^no-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(reason);
|
|
367
|
+
}
|
|
368
|
+
/** The attribute on the manifest's `<script type="application/json">`. */
|
|
369
|
+
export const SECTION_MANIFEST_ATTRIBUTE = 'data-bl-manifest';
|
|
370
|
+
/**
|
|
371
|
+
* Page-level notes in the manifest. `cap-exceeded`: the required and conditional sections with data are more than
|
|
372
|
+
* the cap, so they all render (neither drops for the cap) and the page is over its cap.
|
|
373
|
+
*/
|
|
374
|
+
export const SECTION_MANIFEST_FLAGS = ['cap-exceeded'];
|
|
375
|
+
/**
|
|
376
|
+
* Tones for the sections that render, in order. `auto` sections alternate canvas and surface, so neighbours never
|
|
377
|
+
* share a background; after a band or photo section the next light tone is the one the last light section didn't
|
|
378
|
+
* have (Omega's `alternateTones`). Only the first `band` request and the first `photo` request are honoured, and
|
|
379
|
+
* never twice in a row; later requests fall back to the light tones.
|
|
380
|
+
*/
|
|
381
|
+
export function assignSectionTones(requests) {
|
|
382
|
+
const tones = [];
|
|
383
|
+
let previous;
|
|
384
|
+
let lastLight = 'surface';
|
|
385
|
+
let bandUsed = false;
|
|
386
|
+
let photoUsed = false;
|
|
387
|
+
for (const request of requests) {
|
|
388
|
+
let next;
|
|
389
|
+
if (request === 'band' && !bandUsed && previous !== 'band') {
|
|
390
|
+
next = 'band';
|
|
391
|
+
bandUsed = true;
|
|
392
|
+
}
|
|
393
|
+
else if (request === 'photo' && !photoUsed && previous !== 'photo') {
|
|
394
|
+
next = 'photo';
|
|
395
|
+
photoUsed = true;
|
|
396
|
+
}
|
|
397
|
+
else if (previous === 'canvas')
|
|
398
|
+
next = 'surface';
|
|
399
|
+
else if (previous === 'surface')
|
|
400
|
+
next = 'canvas';
|
|
401
|
+
else
|
|
402
|
+
next = lastLight === 'canvas' ? 'surface' : 'canvas';
|
|
403
|
+
tones.push(next);
|
|
404
|
+
previous = next;
|
|
405
|
+
if (next === 'canvas' || next === 'surface')
|
|
406
|
+
lastLight = next;
|
|
407
|
+
}
|
|
408
|
+
return tones;
|
|
409
|
+
}
|
|
410
|
+
/** Only optional, then recommended, sections drop for the cap; K12 needs every R and C section with data rendered. */
|
|
411
|
+
const CAP_DROP_ORDER = ['O', 'Rec'];
|
|
412
|
+
/**
|
|
413
|
+
* Plans one page: matches the page's candidate sections to the family order, skips what isn't ready, isn't offered or
|
|
414
|
+
* isn't in the order, enforces the cap (optional, then recommended sections drop, last first; required and
|
|
415
|
+
* conditional sections with data never drop: when they alone exceed the cap they all render and the manifest flags
|
|
416
|
+
* `cap-exceeded`), assigns tones and writes the manifest.
|
|
417
|
+
*/
|
|
418
|
+
export function planSectionSequence(order, candidates, page) {
|
|
419
|
+
const skipped = [];
|
|
420
|
+
const used = new Set();
|
|
421
|
+
const chosen = [];
|
|
422
|
+
for (const entry of order.entries) {
|
|
423
|
+
const matches = candidates
|
|
424
|
+
.map((candidate, index) => ({ candidate, index }))
|
|
425
|
+
.filter(({ candidate, index }) => !used.has(index) && (candidate.id === entry.id || entry.alternatives?.includes(candidate.id)));
|
|
426
|
+
if (matches.length === 0) {
|
|
427
|
+
skipped.push({ id: entry.id, section: entry.id, requirement: entry.requirement, reason: 'not-provided' });
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
let filled = false;
|
|
431
|
+
for (const { candidate, index } of matches) {
|
|
432
|
+
used.add(index);
|
|
433
|
+
const ready = candidate.ready ?? SECTION_READY;
|
|
434
|
+
if (filled)
|
|
435
|
+
skipped.push({ id: entry.id, section: candidate.id, requirement: entry.requirement, reason: 'duplicate' });
|
|
436
|
+
else if (!ready.render)
|
|
437
|
+
skipped.push({ id: entry.id, section: candidate.id, requirement: entry.requirement, reason: ready.reason });
|
|
438
|
+
else {
|
|
439
|
+
chosen.push({ candidate: index, entry });
|
|
440
|
+
filled = true;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
candidates.forEach((candidate, index) => {
|
|
445
|
+
if (!used.has(index))
|
|
446
|
+
skipped.push({ id: candidate.id, section: candidate.id, requirement: 'N', reason: 'not-in-order' });
|
|
447
|
+
});
|
|
448
|
+
const counted = () => {
|
|
449
|
+
const ids = new Set(chosen.map((pick) => pick.entry.id));
|
|
450
|
+
return chosen.filter((pick) => !(pick.entry.countsWith && ids.has(pick.entry.countsWith))).length;
|
|
451
|
+
};
|
|
452
|
+
// Sections sharing one matrix position drop together, so every drop lowers the count by one.
|
|
453
|
+
const position = (pick) => chosen.filter((other) => other === pick ||
|
|
454
|
+
other.entry.countsWith === pick.entry.id ||
|
|
455
|
+
pick.entry.countsWith === other.entry.id ||
|
|
456
|
+
(pick.entry.countsWith !== undefined && other.entry.countsWith === pick.entry.countsWith));
|
|
457
|
+
for (const requirement of CAP_DROP_ORDER) {
|
|
458
|
+
for (let index = chosen.length - 1; index >= 0 && counted() > order.cap; index -= 1) {
|
|
459
|
+
const pick = chosen[index];
|
|
460
|
+
if (!pick || pick.entry.requirement !== requirement)
|
|
461
|
+
continue;
|
|
462
|
+
const group = position(pick);
|
|
463
|
+
if (!group.every((member) => CAP_DROP_ORDER.includes(member.entry.requirement)))
|
|
464
|
+
continue;
|
|
465
|
+
for (const member of group) {
|
|
466
|
+
skipped.push({
|
|
467
|
+
id: member.entry.id,
|
|
468
|
+
section: candidates[member.candidate]?.id ?? member.entry.id,
|
|
469
|
+
requirement: member.entry.requirement,
|
|
470
|
+
reason: 'cap',
|
|
471
|
+
});
|
|
472
|
+
chosen.splice(chosen.indexOf(member), 1);
|
|
473
|
+
}
|
|
474
|
+
index = Math.min(index, chosen.length);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const tones = assignSectionTones(chosen.map((pick) => candidates[pick.candidate]?.tone ?? 'auto'));
|
|
478
|
+
const rendered = chosen.map((pick, index) => ({ candidate: pick.candidate, id: pick.entry.id, tone: tones[index] ?? 'canvas' }));
|
|
479
|
+
const manifest = {
|
|
480
|
+
version: 1,
|
|
481
|
+
family: order.family,
|
|
482
|
+
...(page !== undefined ? { page } : {}),
|
|
483
|
+
cap: order.cap,
|
|
484
|
+
order: order.source,
|
|
485
|
+
planned: order.entries.map((entry) => ({ id: entry.id, requirement: entry.requirement })),
|
|
486
|
+
rendered: chosen.map((pick, index) => ({
|
|
487
|
+
id: pick.entry.id,
|
|
488
|
+
section: candidates[pick.candidate]?.id ?? pick.entry.id,
|
|
489
|
+
requirement: pick.entry.requirement,
|
|
490
|
+
tone: tones[index] ?? 'canvas',
|
|
491
|
+
})),
|
|
492
|
+
skipped,
|
|
493
|
+
counted: counted(),
|
|
494
|
+
flags: counted() > order.cap ? ['cap-exceeded'] : [],
|
|
495
|
+
};
|
|
496
|
+
return { rendered, manifest };
|
|
497
|
+
}
|
|
498
|
+
//# sourceMappingURL=section-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-order.js","sourceRoot":"","sources":["../src/section-order.ts"],"names":[],"mappings":"AAAA;;;;;;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YACrC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;YACjB,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;YACxD,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;YACnC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,QAAQ;SAC/B,CAAC,CAAC;QACH,OAAO;QACP,OAAO,EAAE,OAAO,EAAE;QAClB,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE;KACrD,CAAA;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;AAC/B,CAAC","sourcesContent":["/**\n * Section order (v2 §3.3 matrix part A; LIB §7a for hubs and company pages). Every page family has a default order of\n * sections, each required (R: skipped only when nothing true exists, and the manifest says why), conditional (C:\n * renders when its data exists), recommended (Rec) or optional (O). Sections a family doesn't use (N) are not in its\n * list. The hero or page header comes first and the CTA band last; a site may record an alternative order per family.\n * The permit note is a line inside `LocalFacts` (permit trades), not a section of its own.\n *\n * `planSectionSequence` is the sequencer's logic (F15), shared by `SectionSequence` in site-next and the K8 and K12\n * checks: skip what has nothing true to show, enforce the cap (only optional and recommended sections drop),\n * alternate the light tones so neighbours differ (at most one `band` and one `photo`) and write the per-page manifest.\n */\n\nexport const BRANDLAB_SECTION_IDS = [\n 'hero',\n 'page-header',\n 'article-header',\n 'answer',\n 'proof-strip',\n 'emergency',\n 'services',\n 'local-facts',\n 'nearby-jobs',\n 'service-detail',\n 'price-guide',\n 'projects',\n 'before-after',\n 'gallery',\n 'reviews',\n 'comparison',\n 'about-owner',\n 'signature',\n 'process',\n 'guarantee',\n 'licences',\n 'partners',\n 'team',\n 'coverage',\n 'area-map',\n 'faqs',\n 'nearby-areas',\n 'related-services',\n 'guides',\n 'contact',\n 'cta',\n] as const\nexport type BrandlabSectionId = (typeof BRANDLAB_SECTION_IDS)[number]\n\nexport const BRANDLAB_PAGE_FAMILIES = [\n 'home',\n 'service',\n 'service-in-suburb',\n 'region',\n 'suburb',\n 'cost-guide',\n 'services-hub',\n 'locations-hub',\n 'projects-hub',\n 'project',\n 'gallery',\n 'reviews',\n 'about',\n 'faqs',\n 'contact',\n 'guides-hub',\n 'guide',\n 'council',\n 'emergency',\n] as const\nexport type BrandlabPageFamily = (typeof BRANDLAB_PAGE_FAMILIES)[number]\n\n/** R required, C conditional, Rec recommended, O optional (N, not used, is simply absent from a family's list). */\nexport const BRANDLAB_SECTION_REQUIREMENTS = ['R', 'C', 'Rec', 'O'] as const\nexport type BrandlabSectionRequirement = (typeof BRANDLAB_SECTION_REQUIREMENTS)[number]\n\n/** The section tones: two alternating grounds, one optional band and one optional photo ground. */\nexport const BRANDLAB_SECTION_TONES = ['canvas', 'surface', 'band', 'photo'] as const\nexport type BrandlabSectionTone = (typeof BRANDLAB_SECTION_TONES)[number]\n\n/** What a section asks for: a light tone the sequencer picks (`auto`), the page's one band or its one photo ground. */\nexport type BrandlabSectionToneRequest = 'auto' | 'band' | 'photo'\n\nexport interface BrandlabSectionOrderEntry {\n readonly id: BrandlabSectionId\n readonly requirement: BrandlabSectionRequirement\n /** Sections that may fill this place instead, for example `before-after` for `projects`. */\n readonly alternatives?: readonly BrandlabSectionId[]\n /** Shares one matrix position with that section: when both render they count once toward the cap. */\n readonly countsWith?: BrandlabSectionId\n}\n\nexport interface BrandlabFamilyOrder {\n readonly family: BrandlabPageFamily\n /** The most sections the page renders (v1 §7.1). */\n readonly cap: number\n readonly source: 'default' | 'recorded'\n readonly entries: readonly BrandlabSectionOrderEntry[]\n}\n\n/** 11 on home and service-in-suburb pages, 12 on service, region and suburb pages, 6 on hubs and company pages. */\nexport const SECTION_CAPS: Readonly<Record<BrandlabPageFamily, number>> = Object.freeze({\n home: 11,\n service: 12,\n 'service-in-suburb': 11,\n region: 12,\n suburb: 12,\n 'cost-guide': 12,\n 'services-hub': 6,\n 'locations-hub': 6,\n 'projects-hub': 6,\n project: 6,\n gallery: 6,\n reviews: 6,\n about: 6,\n faqs: 6,\n contact: 6,\n 'guides-hub': 6,\n guide: 6,\n council: 6,\n emergency: 6,\n})\n\ntype Row = readonly [\n BrandlabSectionId,\n BrandlabSectionRequirement,\n (readonly BrandlabSectionId[] | undefined)?,\n BrandlabSectionId?,\n]\n\nconst PROJECTS: Row = ['projects', 'C', ['before-after']]\n\n/** The defaults, in order. `EmergencyBand` has no number in the matrix; it sits straight after the proof strip. */\nconst DEFAULT_ROWS: Readonly<Record<BrandlabPageFamily, readonly Row[]>> = {\n home: [\n ['hero', 'R'],\n ['proof-strip', 'R'],\n ['emergency', 'C'],\n ['services', 'R'],\n PROJECTS,\n ['reviews', 'C'],\n ['price-guide', 'Rec'],\n ['about-owner', 'O'],\n ['signature', 'O'],\n ['process', 'O'],\n ['guarantee', 'O'],\n ['coverage', 'R'],\n ['faqs', 'Rec'],\n ['guides', 'C'],\n ['cta', 'R'],\n ],\n service: [\n ['hero', 'R'],\n ['proof-strip', 'R'],\n ['emergency', 'C'],\n ['service-detail', 'R'],\n ['price-guide', 'R'],\n PROJECTS,\n ['reviews', 'C'],\n ['about-owner', 'O'],\n ['comparison', 'O'],\n ['signature', 'O'],\n ['process', 'O'],\n ['guarantee', 'C'],\n ['faqs', 'R'],\n ['related-services', 'C'],\n ['coverage', 'C'],\n ['guides', 'C'],\n ['cta', 'R'],\n ],\n 'service-in-suburb': [\n ['hero', 'R'],\n ['proof-strip', 'R'],\n ['emergency', 'C'],\n ['local-facts', 'R'],\n ['nearby-jobs', 'R'],\n ['price-guide', 'R'],\n ['service-detail', 'R'],\n ['reviews', 'R'],\n ['faqs', 'R'],\n ['nearby-areas', 'R'],\n ['related-services', 'R', undefined, 'nearby-areas'],\n ['cta', 'R'],\n ],\n region: [\n ['hero', 'R'],\n ['proof-strip', 'R'],\n ['service-detail', 'R'],\n ['services', 'R'],\n PROJECTS,\n ['reviews', 'C'],\n ['price-guide', 'C'],\n ['coverage', 'R'],\n ['faqs', 'R'],\n ['area-map', 'O'],\n ['cta', 'R'],\n ],\n suburb: [\n ['hero', 'R'],\n ['proof-strip', 'R'],\n ['local-facts', 'R'],\n ['services', 'R'],\n ['price-guide', 'C'],\n ['nearby-jobs', 'C'],\n ['reviews', 'C'],\n ['faqs', 'R'],\n ['area-map', 'R'],\n ['cta', 'R'],\n ],\n 'cost-guide': [\n ['article-header', 'R'],\n ['answer', 'R'],\n ['price-guide', 'R'],\n ['service-detail', 'R'],\n ['comparison', 'O'],\n PROJECTS,\n ['faqs', 'Rec'],\n ['cta', 'R'],\n ],\n 'services-hub': [\n ['page-header', 'R'],\n ['services', 'R'],\n ['reviews', 'C'],\n ['cta', 'R'],\n ],\n 'locations-hub': [\n ['page-header', 'R'],\n ['coverage', 'R'],\n ['cta', 'R'],\n ],\n 'projects-hub': [\n ['page-header', 'R'],\n ['projects', 'R'],\n ['reviews', 'C'],\n ['cta', 'R'],\n ],\n project: [\n ['hero', 'R', ['page-header']],\n ['gallery', 'R'],\n ['service-detail', 'R'],\n ['reviews', 'C'],\n ['related-services', 'R'],\n ['cta', 'R'],\n ],\n gallery: [\n ['page-header', 'R'],\n ['gallery', 'R'],\n ['cta', 'R'],\n ],\n reviews: [\n ['page-header', 'R'],\n ['reviews', 'R'],\n ['cta', 'R'],\n ],\n about: [\n ['page-header', 'R'],\n ['about-owner', 'R'],\n ['licences', 'C'],\n ['partners', 'C'],\n ['reviews', 'C'],\n ['team', 'O'],\n ['cta', 'R'],\n ],\n faqs: [\n ['page-header', 'R'],\n ['faqs', 'R'],\n ['cta', 'R'],\n ],\n // The contact page is the page header and the contact block, and nothing else (K12-contact).\n contact: [\n ['page-header', 'R'],\n ['contact', 'R'],\n ],\n 'guides-hub': [\n ['page-header', 'R'],\n ['guides', 'R'],\n ['cta', 'R'],\n ],\n guide: [\n ['article-header', 'R'],\n ['service-detail', 'R'],\n ['cta', 'R'],\n ],\n council: [\n ['page-header', 'R'],\n ['service-detail', 'R'],\n ['cta', 'R'],\n ],\n emergency: [\n ['hero', 'R'],\n ['emergency', 'R'],\n ['service-detail', 'R'],\n ['reviews', 'C'],\n ['cta', 'R'],\n ],\n}\n\nfunction toEntry([id, requirement, alternatives, countsWith]: Row): BrandlabSectionOrderEntry {\n return Object.freeze({\n id,\n requirement,\n ...(alternatives ? { alternatives: Object.freeze([...alternatives]) } : {}),\n ...(countsWith ? { countsWith } : {}),\n })\n}\n\n/** The playbook trades (v2 §5, matrix part B). */\nexport const BRANDLAB_TRADES = [\n 'building',\n 'electrical',\n 'exterior',\n 'interiors',\n 'landscaping',\n 'plumbing',\n 'pools',\n 'renovations',\n 'roofing',\n 'tiling',\n 'trees',\n] as const\nexport type BrandlabTrade = (typeof BRANDLAB_TRADES)[number]\n\n/** A trade's changes to the defaults: a new requirement for a section already in a family's order. */\nexport type BrandlabTradeSectionRules = Readonly<\n Partial<Record<BrandlabPageFamily, Readonly<Partial<Record<BrandlabSectionId, BrandlabSectionRequirement>>>>>\n>\n\n/**\n * The trade map (matrix part B). A stub in 3.11.0: every trade uses the defaults until its playbook's rules are\n * confirmed per client (licence classes, permit notes and emergency work are \"inferred, confirm\" in the matrix).\n */\nexport const SECTION_ORDER_TRADE_MAP: Readonly<Record<BrandlabTrade, BrandlabTradeSectionRules>> = Object.freeze(\n Object.fromEntries(BRANDLAB_TRADES.map((trade) => [trade, Object.freeze({})])) as Record<BrandlabTrade, BrandlabTradeSectionRules>,\n)\n\n/** A family's default order, with the trade's rules applied. */\nexport function defaultSectionOrder(\n family: BrandlabPageFamily,\n trade?: BrandlabTrade,\n tradeMap: Readonly<Partial<Record<BrandlabTrade, BrandlabTradeSectionRules>>> = SECTION_ORDER_TRADE_MAP,\n): BrandlabFamilyOrder {\n const rows = DEFAULT_ROWS[family]\n if (!rows) throw new Error(`Unknown page family \"${family}\".`)\n const rules = trade ? tradeMap[trade]?.[family] : undefined\n const entries = rows.map((row) => {\n const requirement = rules?.[row[0]]\n return toEntry(requirement ? [row[0], requirement, row[2], row[3]] : row)\n })\n return Object.freeze({ family, cap: SECTION_CAPS[family], source: 'default', entries: Object.freeze(entries) })\n}\n\n/** A site's recorded alternative order for one family (LIB §7a), with the decision that recorded it. */\nexport interface BrandlabRecordedSectionOrder {\n readonly order: readonly BrandlabSectionId[]\n /** Who decided and why, for example \"Romie, 19 Oct 2026: reviews before prices for Superior\". */\n readonly decision: string\n /** YYYY-MM-DD. */\n readonly recordedOn: string\n}\n\nexport interface BrandlabSectionOrderInput {\n readonly trade?: BrandlabTrade\n readonly recorded?: Readonly<Partial<Record<BrandlabPageFamily, BrandlabRecordedSectionOrder>>>\n}\n\nexport type BrandlabSectionOrders = Readonly<Record<BrandlabPageFamily, BrandlabFamilyOrder>>\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}$/\n\nfunction recordedOrder(base: BrandlabFamilyOrder, recorded: BrandlabRecordedSectionOrder): BrandlabFamilyOrder {\n const family = base.family\n const fail = (detail: string): never => {\n throw new Error(`Recorded section order for ${family}: ${detail}`)\n }\n if (family === 'contact') fail('the contact page is the page header and the contact block, and nothing else.')\n if (typeof recorded.decision !== 'string' || !recorded.decision.trim()) fail('decision must say who decided and why.')\n if (typeof recorded.recordedOn !== 'string' || !ISO_DATE.test(recorded.recordedOn) || Number.isNaN(Date.parse(recorded.recordedOn))) {\n fail('recordedOn must be a YYYY-MM-DD date.')\n }\n if (!Array.isArray(recorded.order) || recorded.order.length === 0) fail('order must list the sections.')\n const byId = new Map(base.entries.map((entry) => [entry.id, entry]))\n const seen = new Set<string>()\n for (const id of recorded.order) {\n if (!byId.has(id)) fail(`\"${id}\" is not used on ${family} pages.`)\n if (seen.has(id)) fail(`\"${id}\" appears twice.`)\n seen.add(id)\n }\n for (const entry of base.entries) {\n if ((entry.requirement === 'R' || entry.requirement === 'C') && !seen.has(entry.id)) {\n fail(`\"${entry.id}\" is ${entry.requirement === 'R' ? 'required' : 'conditional'} and must stay in the order.`)\n }\n }\n const first = base.entries[0]?.id\n const last = base.entries[base.entries.length - 1]?.id\n if (recorded.order[0] !== first) fail(`\"${first}\" comes first.`)\n if (last === 'cta' && recorded.order[recorded.order.length - 1] !== 'cta') fail('the CTA band comes last.')\n const proof = recorded.order.indexOf('proof-strip')\n if (proof >= 5) fail('the proof strip stays within the first five sections.')\n return Object.freeze({\n family,\n cap: base.cap,\n source: 'recorded',\n entries: Object.freeze(recorded.order.map((id) => byId.get(id) as BrandlabSectionOrderEntry)),\n })\n}\n\n/**\n * Declares a site's section orders (`src/data/strategy.ts`): the defaults for every family, the trade's rules and any\n * recorded alternative orders. A recorded order keeps every required and conditional section, the first section\n * first, the CTA band last and the proof strip within the first five; the contact page can't be reordered.\n */\nexport function defineSectionOrder(\n input: BrandlabSectionOrderInput = {},\n tradeMap: Readonly<Partial<Record<BrandlabTrade, BrandlabTradeSectionRules>>> = SECTION_ORDER_TRADE_MAP,\n): BrandlabSectionOrders {\n if (input.trade !== undefined && !(BRANDLAB_TRADES as readonly string[]).includes(input.trade)) {\n throw new Error(`Unknown trade \"${input.trade}\".`)\n }\n for (const family of Object.keys(input.recorded ?? {})) {\n if (!(BRANDLAB_PAGE_FAMILIES as readonly string[]).includes(family)) throw new Error(`Unknown page family \"${family}\".`)\n }\n const orders = Object.fromEntries(\n BRANDLAB_PAGE_FAMILIES.map((family) => {\n const base = defaultSectionOrder(family, input.trade, tradeMap)\n const recorded = input.recorded?.[family]\n return [family, recorded ? recordedOrder(base, recorded) : base]\n }),\n ) as Record<BrandlabPageFamily, BrandlabFamilyOrder>\n return Object.freeze(orders)\n}\n\n/** The reasons the sequencer itself skips a section. */\nexport const SEQUENCER_SKIP_REASONS = ['not-provided', 'not-in-order', 'duplicate', 'cap'] as const\nexport type BrandlabSequencerSkipReason = (typeof SEQUENCER_SKIP_REASONS)[number]\n\n/**\n * A section's own, data-backed reason for rendering nothing: the data it needs isn't there (`no-feed-reviews`,\n * `no-approved-prices`, `no-jobs-nearby`, `no-faqs` and so on), or its content belongs in the hero checklist.\n */\nexport type BrandlabSectionDataReason = `no-${string}` | 'merge-into-hero-checklist'\nexport type BrandlabSectionSkipReason = BrandlabSectionDataReason | BrandlabSequencerSkipReason\n\n/** A section's guard, computed from the same data it renders: render, or render nothing and say why. */\nexport type BrandlabSectionReadiness =\n | { readonly render: true }\n | { readonly render: false; readonly reason: BrandlabSectionDataReason }\n\nexport const SECTION_READY: BrandlabSectionReadiness = Object.freeze({ render: true })\n\n/** Whether a skip reason says the data isn't there (as opposed to the sequencer's own reasons). */\nexport function isDataBackedSkipReason(reason: string): reason is BrandlabSectionDataReason {\n return reason === 'merge-into-hero-checklist' || /^no-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(reason)\n}\n\n/** The attribute on the manifest's `<script type=\"application/json\">`. */\nexport const SECTION_MANIFEST_ATTRIBUTE = 'data-bl-manifest'\n\n/**\n * Page-level notes in the manifest. `cap-exceeded`: the required and conditional sections with data are more than\n * the cap, so they all render (neither drops for the cap) and the page is over its cap.\n */\nexport const SECTION_MANIFEST_FLAGS = ['cap-exceeded'] as const\nexport type BrandlabSectionManifestFlag = (typeof SECTION_MANIFEST_FLAGS)[number]\n\n/** The per-page manifest K12 reads: what was planned, what rendered with which tone, and what was skipped and why. */\nexport interface BrandlabSectionManifest {\n readonly version: 1\n readonly family: BrandlabPageFamily\n readonly page?: string\n readonly cap: number\n readonly order: 'default' | 'recorded'\n readonly planned: readonly { readonly id: BrandlabSectionId; readonly requirement: BrandlabSectionRequirement }[]\n /** `id` is the planned place; `section` is what filled it (an alternative such as `before-after`, or the same id). */\n readonly rendered: readonly {\n readonly id: BrandlabSectionId\n readonly section: BrandlabSectionId\n readonly requirement: BrandlabSectionRequirement\n readonly tone: BrandlabSectionTone\n }[]\n readonly skipped: readonly {\n readonly id: BrandlabSectionId\n readonly section: BrandlabSectionId\n readonly requirement: BrandlabSectionRequirement | 'N'\n readonly reason: BrandlabSectionSkipReason\n }[]\n /** The rendered sections counted toward the cap (sections sharing one matrix position count once). */\n readonly counted: number\n readonly flags: readonly BrandlabSectionManifestFlag[]\n}\n\n/** One section a page offers the sequencer. */\nexport interface BrandlabSequenceCandidate {\n readonly id: BrandlabSectionId\n /** Defaults to ready. */\n readonly ready?: BrandlabSectionReadiness\n /** Defaults to `auto`. */\n readonly tone?: BrandlabSectionToneRequest\n}\n\nexport interface BrandlabSequencePlan {\n /** What renders, in order: the candidate's index, the planned place and the tone. */\n readonly rendered: readonly { readonly candidate: number; readonly id: BrandlabSectionId; readonly tone: BrandlabSectionTone }[]\n readonly manifest: BrandlabSectionManifest\n}\n\n/**\n * Tones for the sections that render, in order. `auto` sections alternate canvas and surface, so neighbours never\n * share a background; after a band or photo section the next light tone is the one the last light section didn't\n * have (Omega's `alternateTones`). Only the first `band` request and the first `photo` request are honoured, and\n * never twice in a row; later requests fall back to the light tones.\n */\nexport function assignSectionTones(requests: readonly BrandlabSectionToneRequest[]): BrandlabSectionTone[] {\n const tones: BrandlabSectionTone[] = []\n let previous: BrandlabSectionTone | undefined\n let lastLight: 'canvas' | 'surface' = 'surface'\n let bandUsed = false\n let photoUsed = false\n for (const request of requests) {\n let next: BrandlabSectionTone\n if (request === 'band' && !bandUsed && previous !== 'band') {\n next = 'band'\n bandUsed = true\n } else if (request === 'photo' && !photoUsed && previous !== 'photo') {\n next = 'photo'\n photoUsed = true\n } else if (previous === 'canvas') next = 'surface'\n else if (previous === 'surface') next = 'canvas'\n else next = lastLight === 'canvas' ? 'surface' : 'canvas'\n tones.push(next)\n previous = next\n if (next === 'canvas' || next === 'surface') lastLight = next\n }\n return tones\n}\n\n/** Only optional, then recommended, sections drop for the cap; K12 needs every R and C section with data rendered. */\nconst CAP_DROP_ORDER: readonly BrandlabSectionRequirement[] = ['O', 'Rec']\n\n/**\n * Plans one page: matches the page's candidate sections to the family order, skips what isn't ready, isn't offered or\n * isn't in the order, enforces the cap (optional, then recommended sections drop, last first; required and\n * conditional sections with data never drop: when they alone exceed the cap they all render and the manifest flags\n * `cap-exceeded`), assigns tones and writes the manifest.\n */\nexport function planSectionSequence(\n order: BrandlabFamilyOrder,\n candidates: readonly BrandlabSequenceCandidate[],\n page?: string,\n): BrandlabSequencePlan {\n const skipped: BrandlabSectionManifest['skipped'][number][] = []\n const used = new Set<number>()\n const chosen: { candidate: number; entry: BrandlabSectionOrderEntry }[] = []\n\n for (const entry of order.entries) {\n const matches = candidates\n .map((candidate, index) => ({ candidate, index }))\n .filter(\n ({ candidate, index }) =>\n !used.has(index) && (candidate.id === entry.id || entry.alternatives?.includes(candidate.id)),\n )\n if (matches.length === 0) {\n skipped.push({ id: entry.id, section: entry.id, requirement: entry.requirement, reason: 'not-provided' })\n continue\n }\n let filled = false\n for (const { candidate, index } of matches) {\n used.add(index)\n const ready = candidate.ready ?? SECTION_READY\n if (filled) skipped.push({ id: entry.id, section: candidate.id, requirement: entry.requirement, reason: 'duplicate' })\n else if (!ready.render) skipped.push({ id: entry.id, section: candidate.id, requirement: entry.requirement, reason: ready.reason })\n else {\n chosen.push({ candidate: index, entry })\n filled = true\n }\n }\n }\n\n candidates.forEach((candidate, index) => {\n if (!used.has(index)) skipped.push({ id: candidate.id, section: candidate.id, requirement: 'N', reason: 'not-in-order' })\n })\n\n const counted = () => {\n const ids = new Set(chosen.map((pick) => pick.entry.id))\n return chosen.filter((pick) => !(pick.entry.countsWith && ids.has(pick.entry.countsWith))).length\n }\n // Sections sharing one matrix position drop together, so every drop lowers the count by one.\n const position = (pick: (typeof chosen)[number]) =>\n chosen.filter(\n (other) =>\n other === pick ||\n other.entry.countsWith === pick.entry.id ||\n pick.entry.countsWith === other.entry.id ||\n (pick.entry.countsWith !== undefined && other.entry.countsWith === pick.entry.countsWith),\n )\n for (const requirement of CAP_DROP_ORDER) {\n for (let index = chosen.length - 1; index >= 0 && counted() > order.cap; index -= 1) {\n const pick = chosen[index]\n if (!pick || pick.entry.requirement !== requirement) continue\n const group = position(pick)\n if (!group.every((member) => CAP_DROP_ORDER.includes(member.entry.requirement))) continue\n for (const member of group) {\n skipped.push({\n id: member.entry.id,\n section: candidates[member.candidate]?.id ?? member.entry.id,\n requirement: member.entry.requirement,\n reason: 'cap',\n })\n chosen.splice(chosen.indexOf(member), 1)\n }\n index = Math.min(index, chosen.length)\n }\n }\n\n const tones = assignSectionTones(chosen.map((pick) => candidates[pick.candidate]?.tone ?? 'auto'))\n const rendered = chosen.map((pick, index) => ({ candidate: pick.candidate, id: pick.entry.id, tone: tones[index] ?? 'canvas' }))\n const manifest: BrandlabSectionManifest = {\n version: 1,\n family: order.family,\n ...(page !== undefined ? { page } : {}),\n cap: order.cap,\n order: order.source,\n planned: order.entries.map((entry) => ({ id: entry.id, requirement: entry.requirement })),\n rendered: chosen.map((pick, index) => ({\n id: pick.entry.id,\n section: candidates[pick.candidate]?.id ?? pick.entry.id,\n requirement: pick.entry.requirement,\n tone: tones[index] ?? 'canvas',\n })),\n skipped,\n counted: counted(),\n flags: counted() > order.cap ? ['cap-exceeded'] : [],\n }\n return { rendered, manifest }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brandlab-digital/site-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -126,6 +126,18 @@
|
|
|
126
126
|
"./strategy": {
|
|
127
127
|
"types": "./dist/strategy.d.ts",
|
|
128
128
|
"import": "./dist/strategy.js"
|
|
129
|
+
},
|
|
130
|
+
"./prices": {
|
|
131
|
+
"types": "./dist/prices.d.ts",
|
|
132
|
+
"import": "./dist/prices.js"
|
|
133
|
+
},
|
|
134
|
+
"./media": {
|
|
135
|
+
"types": "./dist/media.d.ts",
|
|
136
|
+
"import": "./dist/media.js"
|
|
137
|
+
},
|
|
138
|
+
"./section-order": {
|
|
139
|
+
"types": "./dist/section-order.d.ts",
|
|
140
|
+
"import": "./dist/section-order.js"
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
}
|