create-ailk 0.47.0 → 0.48.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.
Files changed (137) hide show
  1. package/README.md +180 -43
  2. package/component-catalog.json +223 -285
  3. package/component-catalog.md +1 -1
  4. package/dist/apply-design.d.ts +26 -68
  5. package/dist/apply-design.js +150 -322
  6. package/dist/cli.js +152 -17
  7. package/dist/compare-chrome.d.ts +108 -0
  8. package/dist/compare-chrome.js +481 -0
  9. package/dist/compare-look.d.ts +94 -0
  10. package/dist/compare-look.js +378 -0
  11. package/dist/copy.js +1 -1
  12. package/dist/design-compile.d.ts +17 -21
  13. package/dist/design-compile.js +32 -56
  14. package/dist/design-files.d.ts +93 -0
  15. package/dist/design-files.js +312 -0
  16. package/dist/design-home.d.ts +4 -2
  17. package/dist/design-home.js +88 -6
  18. package/dist/design-names.d.ts +13 -0
  19. package/dist/design-names.js +76 -0
  20. package/dist/design-package.d.ts +46 -56
  21. package/dist/design-package.js +285 -288
  22. package/dist/design-presets.d.ts +41 -0
  23. package/dist/design-presets.js +83 -4
  24. package/dist/design-scaffold.d.ts +12 -2
  25. package/dist/design-scaffold.js +72 -34
  26. package/dist/generated/design-settings.d.ts +56 -0
  27. package/dist/generated/design-settings.js +237 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/inventory.d.ts +3 -2
  31. package/dist/inventory.js +10 -4
  32. package/dist/lib/design-checks.d.ts +46 -0
  33. package/dist/lib/design-checks.js +79 -1
  34. package/dist/lib/env-catalog.js +1 -1
  35. package/dist/lib/module-license-gate.d.ts +1 -1
  36. package/dist/lib/module-license-gate.js +1 -1
  37. package/dist/lib/render-verdict.d.ts +13 -1
  38. package/dist/lib/render-verdict.js +41 -1
  39. package/dist/look-hub.d.ts +44 -0
  40. package/dist/look-hub.js +130 -0
  41. package/dist/look-record.d.ts +35 -0
  42. package/dist/look-record.js +85 -0
  43. package/dist/look-samples.d.ts +66 -0
  44. package/dist/look-samples.js +456 -0
  45. package/dist/look-settings.d.ts +53 -0
  46. package/dist/look-settings.js +363 -0
  47. package/dist/module-architecture.js +12 -0
  48. package/dist/parse-args.d.ts +10 -6
  49. package/dist/parse-args.js +26 -13
  50. package/dist/programmatic.d.ts +1 -19
  51. package/dist/programmatic.js +65 -103
  52. package/dist/retired-design-bodies.d.ts +29 -0
  53. package/dist/retired-design-bodies.js +51 -0
  54. package/dist/seed-flows.d.ts +1 -1
  55. package/dist/seed-flows.js +12 -14
  56. package/dist/seed-workspace.d.ts +4 -1
  57. package/dist/seed-workspace.js +139 -17
  58. package/dist/site-chrome.d.ts +41 -41
  59. package/dist/site-chrome.js +50 -70
  60. package/dist/site-fonts.d.ts +10 -14
  61. package/dist/site-fonts.js +5 -1
  62. package/dist/starter-grid.d.ts +2 -2
  63. package/dist/strip-look-copies.d.ts +67 -0
  64. package/dist/strip-look-copies.js +591 -0
  65. package/dist/template-manifest.d.ts +6 -14
  66. package/dist/template-manifest.js +0 -9
  67. package/dist/template-record.d.ts +3 -1
  68. package/dist/template-record.js +3 -1
  69. package/dist/topology.d.ts +15 -0
  70. package/dist/topology.js +60 -0
  71. package/dist/update.d.ts +57 -1
  72. package/dist/update.js +742 -13
  73. package/package.json +3 -4
  74. package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
  75. package/site-templates/designs/minimalism/DESIGN.md +163 -297
  76. package/site-templates/designs/minimalism/LOOK.md +42 -0
  77. package/site-templates/designs/minimalism/design.yaml +167 -0
  78. package/site-templates/designs/standard/DESIGN.md +145 -149
  79. package/site-templates/designs/standard/LOOK.md +42 -0
  80. package/site-templates/designs/standard/design.yaml +72 -0
  81. package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
  82. package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
  83. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
  84. package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
  85. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
  86. package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
  87. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
  88. package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
  89. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
  90. package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
  91. package/site-templates/shapes/person-service/content/_site.mdx +0 -26
  92. package/templates/.claude/rules/extending.md +3 -2
  93. package/templates/.env.example +11 -4
  94. package/templates/CLAUDE.md +1 -1
  95. package/templates/DESIGN.md +145 -149
  96. package/templates/README.md +15 -16
  97. package/templates/apps/api/.env.example +11 -4
  98. package/templates/apps/api/CLAUDE.md +6 -4
  99. package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -5
  100. package/templates/apps/mcp/CLAUDE.md +4 -2
  101. package/templates/apps/web/.env.example +10 -3
  102. package/templates/apps/web/CLAUDE.md +14 -3
  103. package/templates/apps/web/app/[locale]/layout.tsx +53 -50
  104. package/templates/apps/web/app/not-found.tsx +11 -11
  105. package/templates/apps/web/auth.ts +48 -35
  106. package/templates/apps/web/jest.config.cjs +5 -0
  107. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +179 -31
  108. package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
  109. package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +71 -32
  110. package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
  111. package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
  112. package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
  113. package/templates/apps/web/lib/deck-page.ts +3 -10
  114. package/templates/apps/web/lib/deploy-fonts.ts +12 -0
  115. package/templates/apps/web/lib/hub-site-config.ts +97 -14
  116. package/templates/apps/web/lib/library-fonts.ts +41 -0
  117. package/templates/apps/web/lib/mcp-oauth.ts +11 -4
  118. package/templates/apps/web/lib/page-chrome.ts +52 -34
  119. package/templates/apps/web/lib/section-look.ts +28 -0
  120. package/templates/apps/web/lib/site-design.ts +205 -0
  121. package/templates/apps/web/lib/site-theme-head.ts +98 -13
  122. package/templates/apps/web/lib/site-theme.ts +40 -62
  123. package/templates/apps/web/messages/en.json +0 -6
  124. package/templates/apps/web/next.config.mjs +195 -6
  125. package/templates/apps/web/package.json +2 -0
  126. package/templates/apps/web/site-pages.config.tsx +4 -2
  127. package/templates/content/_site.mdx +0 -26
  128. package/templates/design.yaml +75 -0
  129. package/templates/project.yaml +14 -0
  130. package/versions.json +52 -51
  131. package/site-templates/marketing-site/DESIGN.md +0 -259
  132. package/site-templates/marketing-site-free/DESIGN.md +0 -259
  133. package/site-templates/saas-product/DESIGN.md +0 -259
  134. package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
  135. package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
  136. package/templates/apps/web/lib/site-chrome.ts +0 -46
  137. package/templates/apps/web/lib/site-fonts.ts +0 -15
@@ -53,6 +53,23 @@
53
53
  * and a link (`localeHref` passes any scheme through), so only its parsed
54
54
  * output is kept. `identity` and `seo` are parsed as before in every case.
55
55
  *
56
+ * Words and links only (#12470 D7): before the parse, the three style keys
57
+ * the record held before — `header.style`, `footer.style`, `families` — are
58
+ * removed (`withoutLegacyNavigationStyles`), so a site ahead of its hub
59
+ * still renders that hub's links.
60
+ *
61
+ * The workspace's design record rides the same read too (#12470 D7, D8):
62
+ * `design` is `{ version, record, settings, look }` when the body carries one
63
+ * that parses, else `null`, with the navigation's warning rule. `record` is
64
+ * checked with `siteDesignSchema` — the one schema the route and the tools
65
+ * use — after every top-level member the site does not render is removed (so
66
+ * a hub that adds one, as #12503 will, does not blank an older site's
67
+ * design); `settings` with `designSettingsSchema` and `look` with
68
+ * `siteDesignLookSchema`, each nullable; every level stays strict. Its
69
+ * grammars are what hold a hub value inside its CSS declaration where #12473
70
+ * writes one (SEC-12470-15). Today the site reads only `record.chrome`
71
+ * (`page-chrome.ts`'s `withDesignChrome`).
72
+ *
56
73
  * `site-brand.tsx`, `site-identity.ts`, `site-contact-email.ts` and
57
74
  * `site-contact-lines.ts` import this module; it imports none of them.
58
75
  */
@@ -77,8 +94,16 @@ import {
77
94
  type SiteIdentity,
78
95
  } from "@working-theory/site-config/schema";
79
96
  import {
97
+ designSettingsSchema,
98
+ siteDesignLookSchema,
99
+ siteDesignSchema,
100
+ siteDesignVersionSchema,
80
101
  siteNavigationSchema,
81
102
  siteNavigationVersionSchema,
103
+ withoutLegacyNavigationStyles,
104
+ type DesignSettings,
105
+ type SiteDesign,
106
+ type SiteDesignLook,
82
107
  type SiteNavigation,
83
108
  } from "@working-theory/validation";
84
109
  import { cache } from "react";
@@ -90,11 +115,20 @@ export interface HubNavigation {
90
115
  record: SiteNavigation;
91
116
  }
92
117
 
93
- /** The workspace's identity, seo and navigation rows as the site reads them; each `null` when absent or unreadable. */
118
+ /** The workspace's design record, the version it was saved at, and the settings and look the hub worked out from it (#12470 D8). */
119
+ export interface HubDesign {
120
+ version: number;
121
+ record: SiteDesign;
122
+ settings: DesignSettings | null;
123
+ look: SiteDesignLook | null;
124
+ }
125
+
126
+ /** The workspace's identity, seo, navigation and design rows as the site reads them; each `null` when absent or unreadable. */
94
127
  export interface HubSite {
95
128
  identity: SiteIdentity | null;
96
129
  seo: SEO | null;
97
130
  navigation: HubNavigation | null;
131
+ design: HubDesign | null;
98
132
  }
99
133
 
100
134
  /**
@@ -102,7 +136,7 @@ export interface HubSite {
102
136
  * the schema it is checked with changes, so an entry written by older site
103
137
  * code is never served as this shape (#12401 D1).
104
138
  */
105
- const HUB_SITE_SHAPE = "nav1";
139
+ const HUB_SITE_SHAPE = "design1";
106
140
 
107
141
  /** How long one hub read is served before it is read again. */
108
142
  export const HUB_SITE_REVALIDATE_SECONDS = 300;
@@ -132,8 +166,8 @@ function parsedOrNull<T>(schema: ZodType<T>, value: unknown): T | null {
132
166
  return parsed.success ? parsed.data : null;
133
167
  }
134
168
 
135
- /** The refused navigation field paths this process has warned about. */
136
- const warnedNavigationPaths = new Set<string>();
169
+ /** The refused navigation and design field paths this process has warned about. */
170
+ const warnedPaths = new Set<string>();
137
171
 
138
172
  /**
139
173
  * A refused field's path, with every segment a hub value chose masked — a
@@ -150,11 +184,12 @@ function fieldPath(path: readonly PropertyKey[]): string {
150
184
  return parts.length > 0 ? parts.join(".") : "(record)";
151
185
  }
152
186
 
153
- function navigationUnreadable(path: string): null {
154
- if (!warnedNavigationPaths.has(path)) {
155
- warnedNavigationPaths.add(path);
187
+ function unreadable(member: "navigation" | "design", path: string): null {
188
+ const key = `${member}:${path}`;
189
+ if (!warnedPaths.has(key)) {
190
+ warnedPaths.add(key);
156
191
  console.warn(
157
- `[hub-site-config] navigation unreadable at ${path}; rendering the site's own navigation`,
192
+ `[hub-site-config] ${member} unreadable at ${path}; rendering the site's own ${member === "navigation" ? "navigation" : "look"}`,
158
193
  );
159
194
  }
160
195
  return null;
@@ -164,18 +199,65 @@ function navigationUnreadable(path: string): null {
164
199
  function navigationOrNull(value: unknown): HubNavigation | null {
165
200
  if (value === undefined || value === null) return null;
166
201
  if (typeof value !== "object" || Array.isArray(value)) {
167
- return navigationUnreadable("navigation");
202
+ return unreadable("navigation", "navigation");
168
203
  }
169
204
  const { version, record } = value as { version?: unknown; record?: unknown };
170
205
  const parsedVersion = siteNavigationVersionSchema.safeParse(version);
171
- if (!parsedVersion.success) return navigationUnreadable("version");
172
- const parsedRecord = siteNavigationSchema.safeParse(record);
206
+ if (!parsedVersion.success) return unreadable("navigation", "version");
207
+ // #12470 D7 — an older hub's record may still carry the three style keys.
208
+ const parsedRecord = siteNavigationSchema.safeParse(withoutLegacyNavigationStyles(record));
173
209
  if (!parsedRecord.success) {
174
- return navigationUnreadable(fieldPath(parsedRecord.error.issues[0]?.path ?? []));
210
+ return unreadable("navigation", fieldPath(parsedRecord.error.issues[0]?.path ?? []));
175
211
  }
176
212
  return { version: parsedVersion.data, record: parsedRecord.data };
177
213
  }
178
214
 
215
+ /** The design record's top-level members this site renders; any other is removed before the strict parse (#12470 D7). */
216
+ const RENDERED_DESIGN_MEMBERS = ["version", "from", "changes", "settings", "chrome", "brand"] as const;
217
+
218
+ /** `record` with only the top-level members the site renders; any other value passes through to the parse. */
219
+ function renderedDesignMembers(record: unknown): unknown {
220
+ if (typeof record !== "object" || record === null || Array.isArray(record)) return record;
221
+ return Object.fromEntries(
222
+ RENDERED_DESIGN_MEMBERS.filter((key) => Object.hasOwn(record, key)).map((key) => [
223
+ key,
224
+ (record as Record<string, unknown>)[key],
225
+ ]),
226
+ );
227
+ }
228
+
229
+ /** The body's `design`, parsed, else `null` (#12470 D8). */
230
+ function designOrNull(value: unknown): HubDesign | null {
231
+ if (value === undefined || value === null) return null;
232
+ if (typeof value !== "object" || Array.isArray(value)) return unreadable("design", "design");
233
+ const { version, record, settings, look } = value as {
234
+ version?: unknown;
235
+ record?: unknown;
236
+ settings?: unknown;
237
+ look?: unknown;
238
+ };
239
+ const parsedVersion = siteDesignVersionSchema.safeParse(version);
240
+ if (!parsedVersion.success) return unreadable("design", "version");
241
+ const parsedRecord = siteDesignSchema.safeParse(renderedDesignMembers(record));
242
+ if (!parsedRecord.success) {
243
+ return unreadable("design", `record.${fieldPath(parsedRecord.error.issues[0]?.path ?? [])}`);
244
+ }
245
+ const parsedSettings = designSettingsSchema.nullable().safeParse(settings ?? null);
246
+ if (!parsedSettings.success) {
247
+ return unreadable("design", `settings.${fieldPath(parsedSettings.error.issues[0]?.path ?? [])}`);
248
+ }
249
+ const parsedLook = siteDesignLookSchema.nullable().safeParse(look ?? null);
250
+ if (!parsedLook.success) {
251
+ return unreadable("design", `look.${fieldPath(parsedLook.error.issues[0]?.path ?? [])}`);
252
+ }
253
+ return {
254
+ version: parsedVersion.data,
255
+ record: parsedRecord.data,
256
+ settings: parsedSettings.data,
257
+ look: parsedLook.data,
258
+ };
259
+ }
260
+
179
261
  /**
180
262
  * One hub read. Throws on any failure, so the cache writes nothing — except
181
263
  * a keyless read's 401, which resolves no rows (#12390 D3).
@@ -195,7 +277,7 @@ async function fetchHubSite(keyed: boolean): Promise<HubSite> {
195
277
  console.warn(
196
278
  "[hub-site-config] the API refused a keyless read (401); rendering from content/_site.mdx",
197
279
  );
198
- return { identity: null, seo: null, navigation: null };
280
+ return { identity: null, seo: null, navigation: null, design: null };
199
281
  }
200
282
  if (!res.ok) throw new Error(`hub site-config read answered ${res.status}`);
201
283
  const body: unknown = res.body;
@@ -211,6 +293,7 @@ async function fetchHubSite(keyed: boolean): Promise<HubSite> {
211
293
  identity: parsedOrNull(SiteIdentitySchema, body.identity),
212
294
  seo: parsedOrNull(SEOSchema, body.seo),
213
295
  navigation: navigationOrNull("navigation" in body ? body.navigation : undefined),
296
+ design: designOrNull("design" in body ? body.design : undefined),
214
297
  };
215
298
  } finally {
216
299
  clearTimeout(timer);
@@ -275,5 +358,5 @@ export function heldHubSite(): HubSite | undefined {
275
358
  export function __resetHubSiteForTests(): void {
276
359
  held = undefined;
277
360
  keylessRetryAt = 0;
278
- warnedNavigationPaths.clear();
361
+ warnedPaths.clear();
279
362
  }
@@ -0,0 +1,41 @@
1
+ // library-fonts.ts — the design library's faces, built into every site
2
+ // (#12473 D6, spec docs/specs/12473-a-site-renders-its-colours-spec.md).
3
+ //
4
+ // Hand-written, not generated: one `next/font/local` call per entry of
5
+ // `LIBRARY_FONTS` (@working-theory/theme), each a literal `src` into the
6
+ // face's installed `@fontsource-variable/<slug>` latin variable file, so a
7
+ // build never reaches Google. Every face's `@font-face` rule is in the built
8
+ // stylesheet; none is preloaded, so a browser downloads one only when an
9
+ // element uses its family. The hub design record chooses which face
10
+ // `--font-display` / `--font-body` name, per request, with no build.
11
+ //
12
+ // The locale layout imports this module, so every page's stylesheet carries
13
+ // the rules. A test holds `LIBRARY_FACES`' families equal to `LIBRARY_FONTS`'.
14
+
15
+ import localFont from "next/font/local";
16
+
17
+ /** A built face: the CSS variable its family is read through, and the class that declares it. */
18
+ export interface BuiltFace {
19
+ variable: string;
20
+ className: string;
21
+ }
22
+
23
+ const figtree = localFont({
24
+ src: "../node_modules/@fontsource-variable/figtree/files/figtree-latin-wght-normal.woff2",
25
+ variable: "--font-lib-figtree",
26
+ display: "swap",
27
+ preload: false,
28
+ });
29
+
30
+ const newsreader = localFont({
31
+ src: "../node_modules/@fontsource-variable/newsreader/files/newsreader-latin-wght-normal.woff2",
32
+ variable: "--font-lib-newsreader",
33
+ display: "swap",
34
+ preload: false,
35
+ });
36
+
37
+ /** The library's built faces, by family. */
38
+ export const LIBRARY_FACES: ReadonlyMap<string, BuiltFace> = new Map([
39
+ ["Figtree", { variable: "--font-lib-figtree", className: figtree.variable }],
40
+ ["Newsreader", { variable: "--font-lib-newsreader", className: newsreader.variable }],
41
+ ]);
@@ -35,12 +35,14 @@ import { createHash, timingSafeEqual } from "node:crypto";
35
35
 
36
36
  import {
37
37
  ALL_WORKSPACES_SCOPE,
38
+ DEFAULT_MCP_SCOPES,
38
39
  ISSUER_SCOPE_PREFIX,
39
40
  lowerRole,
40
41
  MCP_SCOPES,
41
42
  type McpScope,
42
43
  type MembershipRole,
43
44
  grantsForWorkspace,
45
+ offerableScopes,
44
46
  parseGrantedScopes,
45
47
  scopesForRole,
46
48
  tokenIssuedBy,
@@ -310,10 +312,14 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
310
312
  return value;
311
313
  }
312
314
 
313
- /** Each workspace with the scopes the request may approve there. */
315
+ /**
316
+ * Each workspace with the scopes the request may approve there: the scopes
317
+ * the client named, else `DEFAULT_MCP_SCOPES`, so an opt-in scope is offered
318
+ * only to a client that asks for it by name (#12470 D3, SEC-12470-1).
319
+ */
314
320
  async function offeredWorkspaces(userId: string, requested: string[]) {
315
321
  const asked = requested.filter((s): s is McpScope => (MCP_SCOPES as readonly string[]).includes(s));
316
- const pool = asked.length > 0 ? asked : [...MCP_SCOPES];
322
+ const pool = offerableScopes(asked);
317
323
  const memberships = await deps.readMemberships(userId);
318
324
  return memberships.map((m) => {
319
325
  const allowed = new Set(scopesForRole(m.role));
@@ -379,14 +385,15 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
379
385
 
380
386
  /**
381
387
  * The all-workspaces consent's union (#11607 D1a): every workspace, and the
382
- * requested scopes any of the person's roles may approve, in `MCP_SCOPES` order.
388
+ * requested scopes any of the person's roles may approve, in `MCP_SCOPES`
389
+ * order — never an opt-in one, even when named (#12470 D3).
383
390
  */
384
391
  async function offeredReach(userId: string, requested: string[]) {
385
392
  const workspaces = await offeredWorkspaces(userId, requested);
386
393
  const union = new Set(workspaces.flatMap((w) => w.offered));
387
394
  return {
388
395
  workspaces: workspaces.map(({ id, name, organizationName, role }) => ({ id, name, organizationName, role })),
389
- offered: MCP_SCOPES.filter((s) => union.has(s)),
396
+ offered: DEFAULT_MCP_SCOPES.filter((s) => union.has(s)),
390
397
  };
391
398
  }
392
399
 
@@ -5,9 +5,9 @@
5
5
  * Four levels, most specific first: the page's own frontmatter (`header:`,
6
6
  * `footer:`, `layout:`), its route family's key in `_site.mdx` (`blog:`,
7
7
  * `docs:`, …), the site defaults in `_site.mdx` (`header.style`,
8
- * `footer.style`, `layout`), and last the design's own knobs in the
9
- * generated `site-chrome.ts`. A site that sets nothing resolves to exactly
10
- * the chrome the design gave it before this file existed.
8
+ * `footer.style`, `layout`), and last the design's own knobs — the hub design
9
+ * record's layout, else `BASE_SITE_LAYOUT` (#12477 D1). A site that sets
10
+ * nothing resolves to exactly the chrome its look gives it.
11
11
  *
12
12
  * Blog posts and docs pages are served by the docs-blog slice, which this
13
13
  * base file must never import, so they take their `blog:` / `docs:` family
@@ -38,7 +38,7 @@ import {
38
38
  type SiteLayout,
39
39
  } from "@working-theory/site-config/schema";
40
40
  import { conventionPath, ROUTES } from "@working-theory/templates/routes";
41
- import type { SiteNavigation } from "@working-theory/validation";
41
+ import type { SiteDesignChrome, SiteNavigation } from "@working-theory/validation";
42
42
  import { readLocales } from "@working-theory/web-i18n";
43
43
  import { cache } from "react";
44
44
  import { parse as parseYaml } from "yaml";
@@ -55,6 +55,7 @@ import { toInternalDocsPath } from "./docs-path";
55
55
  import { readHubSite } from "./hub-site-config";
56
56
  import { SERVICES_ROUTE, toInternalServicesPath } from "./services-path";
57
57
  import { resolveContentRoot } from "./site-brand";
58
+ import { readSiteDesign, type SiteLayoutKnobs } from "./site-design";
58
59
  import { safeNavigationChrome, type NavigationChrome } from "./site-navigation";
59
60
 
60
61
  /** The chrome settings a site sets in `_site.mdx`. */
@@ -73,13 +74,13 @@ export interface PageChromeFields {
73
74
  }
74
75
 
75
76
  /**
76
- * The design knobs the template level reads — a structural slice of the
77
- * generated `SiteChrome`, so a scaffold generated before `innerPages` or
78
- * `chromeStyle` existed still compiles.
77
+ * The design knobs the template level reads — a structural slice of
78
+ * `SiteLayoutKnobs` (`lib/site-design.ts`).
79
79
  */
80
80
  export interface ChromeKnobs {
81
+ nav: HeaderStyle;
81
82
  home: SiteLayout;
82
- footer: "columns" | "centered";
83
+ footer: FooterStyle;
83
84
  innerPages?: "bare";
84
85
  chromeStyle?: "minimal";
85
86
  }
@@ -171,20 +172,21 @@ export const readSiteChromeSettings = cache(
171
172
  );
172
173
 
173
174
  /**
174
- * The file settings with the hub navigation record's styles laid over them
175
- * (#12401 D4): the record's header and footer style, and each route family's
176
- * `header` and `footer`, win where the record sets them; every other value —
177
- * the layout, a family's `path` — is the file's. Returns new objects and never
178
- * changes `site`, which `readSiteChromeSettings` shares across the request.
175
+ * The file settings with the hub design record's `chrome` laid over them
176
+ * (#12470 D7, after #12401 D4): the record's header and footer style, and each
177
+ * route family's `header` and `footer`, win where the record sets them; every
178
+ * other value — the layout, a family's `path` — is the file's. Returns new
179
+ * objects and never changes `site`, which `readSiteChromeSettings` shares
180
+ * across the request.
179
181
  */
180
- export function withNavigationStyles(
182
+ export function withDesignChrome(
181
183
  site: SiteChromeSettings,
182
- record: SiteNavigation | null,
184
+ chrome: SiteDesignChrome | undefined,
183
185
  ): SiteChromeSettings {
184
- if (record === null) return site;
186
+ if (chrome === undefined) return site;
185
187
  const families: SiteChromeSettings["families"] = { ...site.families };
186
188
  for (const key of ROUTE_FAMILY_KEYS) {
187
- const styles = record.families?.[key];
189
+ const styles = chrome.families?.[key];
188
190
  if (styles?.header === undefined && styles?.footer === undefined) continue;
189
191
  families[key] = {
190
192
  ...site.families[key],
@@ -192,8 +194,8 @@ export function withNavigationStyles(
192
194
  ...(styles.footer !== undefined ? { footer: styles.footer } : {}),
193
195
  };
194
196
  }
195
- const headerStyle = record.header.style ?? site.headerStyle;
196
- const footerStyle = record.footer.style ?? site.footerStyle;
197
+ const headerStyle = chrome.header ?? site.headerStyle;
198
+ const footerStyle = chrome.footer ?? site.footerStyle;
197
199
  return {
198
200
  ...site,
199
201
  ...(headerStyle !== undefined ? { headerStyle } : {}),
@@ -419,16 +421,19 @@ export interface PageChromeInput {
419
421
 
420
422
  export interface ResolvedChrome {
421
423
  header: HeaderStyle;
422
- /** No page, family or site value set the header — the design's own treatment applies. */
423
- headerFromTemplate: boolean;
424
424
  /** `line` is the design's one-bar footer on a bare inner page; never a site value. */
425
425
  footer: FooterStyle | "line";
426
426
  }
427
427
 
428
- /** The design's own header and footer for a page (#10049 D3's template table). */
428
+ /**
429
+ * The design's own header and footer for a page (#10049 D3's template table).
430
+ * Where the table gives the design's own bar, it is the look's `nav` (#12470
431
+ * D7), so `mark-only` means the same whether a look, a site, a page or the
432
+ * design record sets it.
433
+ */
429
434
  function templateChrome(
430
435
  input: PageChromeInput,
431
- ): Pick<ResolvedChrome, "header" | "footer"> {
436
+ ): ResolvedChrome {
432
437
  const { chrome } = input;
433
438
  if (input.isHome) {
434
439
  if (input.homeIsDeck && chrome.home === "deck") {
@@ -437,24 +442,30 @@ function templateChrome(
437
442
  footer: chrome.chromeStyle === "minimal" ? "closing" : chrome.footer,
438
443
  };
439
444
  }
440
- return { header: "full", footer: chrome.footer };
445
+ return { header: chrome.nav, footer: chrome.footer };
441
446
  }
442
447
  if (input.closingListed) {
443
448
  return {
444
- header: chrome.innerPages === "bare" ? "bare" : "full",
449
+ header: chrome.innerPages === "bare" ? "bare" : chrome.nav,
445
450
  footer: "closing",
446
451
  };
447
452
  }
448
453
  if (chrome.innerPages === "bare") return { header: "bare", footer: "line" };
449
- return { header: "full", footer: chrome.footer };
454
+ return { header: chrome.nav, footer: chrome.footer };
450
455
  }
451
456
 
452
457
  /**
453
458
  * The home's layout and chrome — the one resolution both the layout and the
454
459
  * home page read, so the bar and the landing can never disagree. The site
455
- * settings are `_site.mdx`'s with the hub navigation record's styles over
456
- * them (#12401 D4) — only when the record renders, so a refused record's
457
- * files keep the files' styles. `navigation` is that record, for the layout.
460
+ * settings are `_site.mdx`'s with the hub design record's `chrome` over them
461
+ * (#12470 D7) — whenever the hub read carries a design record, whether or not
462
+ * a navigation record renders: style no longer belongs to the navigation.
463
+ * `navigation` is the rendered navigation record, for the layout.
464
+ *
465
+ * #12473 D4 — the design knobs are the hub design record's layout when it
466
+ * carries one, else `chrome` — the callers' `BASE_SITE_LAYOUT` (#12477 D1);
467
+ * `knobs` answers the record's alone, absent with no record, for the home
468
+ * page's deck knobs.
458
469
  */
459
470
  export async function resolveHomeChrome(
460
471
  locale: string,
@@ -464,22 +475,30 @@ export async function resolveHomeChrome(
464
475
  chrome: ResolvedChrome;
465
476
  site: SiteChromeSettings;
466
477
  navigation: RecordNavigation | null;
478
+ knobs?: SiteLayoutKnobs;
467
479
  }> {
468
- const navigation = await readRecordNavigation(locale);
469
- const site = withNavigationStyles(readSiteChromeSettings(), navigation?.record ?? null);
480
+ const [navigation, hub, design] = await Promise.all([
481
+ readRecordNavigation(locale),
482
+ readHubSite(),
483
+ readSiteDesign(),
484
+ ]);
485
+ const knobs = design?.layout;
486
+ const designKnobs = knobs ?? chrome;
487
+ const site = withDesignChrome(readSiteChromeSettings(), hub?.design?.record.chrome);
470
488
  const page = await resolveChromePage("/", locale);
471
- const layout = resolveHomeLayout(site, page, chrome);
489
+ const layout = resolveHomeLayout(site, page, designKnobs);
472
490
  return {
473
491
  layout,
474
492
  site,
475
493
  navigation,
494
+ ...(knobs !== undefined && { knobs }),
476
495
  chrome: resolvePageChrome({
477
496
  isHome: true,
478
497
  homeIsDeck: layout === "deck",
479
498
  family: null,
480
499
  page,
481
500
  site,
482
- chrome,
501
+ chrome: designKnobs,
483
502
  closingListed: false,
484
503
  }),
485
504
  };
@@ -494,7 +513,6 @@ export function resolvePageChrome(input: PageChromeInput): ResolvedChrome {
494
513
  const footer = input.page.footer ?? family?.footer ?? input.site.footerStyle;
495
514
  return {
496
515
  header: header ?? template.header,
497
- headerFromTemplate: header === undefined,
498
516
  footer: footer ?? template.footer,
499
517
  };
500
518
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Section look — registers the site's look for its sections with
3
+ * `@working-theory/page-renderer` (#12474 D3), so a section a page does not
4
+ * set a look field for takes the look's value for its page type, and a change
5
+ * of look in the hub reaches every such page with no page written and no
6
+ * deploy.
7
+ *
8
+ * The reader answers the hub's worked-out `settings.sections` of the site's
9
+ * design record (#12470 D7, D8) — never `design.record`, whose `settings` a
10
+ * library-look record does not hold. It is `undefined` when the hub read has
11
+ * no design, or no worked-out settings, or no `sections`: the pages then
12
+ * render as stored. `readHubSite()` is `cache()`-shared within a request and
13
+ * refreshed by the `site-config` purge every design save sends, so the reader
14
+ * adds no read.
15
+ *
16
+ * Registration happens at module load, and only on a hub-connected site
17
+ * (`hubConnected()`); a site that is not registers nothing and makes no call.
18
+ * `app/[locale]/layout.tsx` imports this module beside the other
19
+ * registrations.
20
+ */
21
+
22
+ import { setSectionLookReader } from "@working-theory/page-renderer";
23
+
24
+ import { hubConnected, readHubSite } from "./hub-site-config";
25
+
26
+ if (hubConnected()) {
27
+ setSectionLookReader(async () => (await readHubSite())?.design?.settings?.sections ?? undefined);
28
+ }