create-ailk 0.48.0 → 0.48.1
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/README.md +18 -6
- package/dist/look-settings.d.ts +1 -1
- package/dist/look-settings.js +476 -32
- package/dist/site-chrome.d.ts +7 -6
- package/dist/site-chrome.js +7 -6
- package/dist/site-fonts.d.ts +7 -3
- package/dist/site-fonts.js +4 -3
- package/package.json +3 -3
- package/versions.json +51 -51
package/README.md
CHANGED
|
@@ -1137,9 +1137,14 @@ a shot differs or a page does not load, and 2 on a refusal.
|
|
|
1137
1137
|
`content/_site.mdx`, `apps/web/lib/site-chrome.ts` and
|
|
1138
1138
|
`apps/web/lib/site-fonts.ts` — each once, as text; no site code runs and no
|
|
1139
1139
|
credential is needed. The settings are `design.yaml` with its `layout` replaced
|
|
1140
|
-
by the layout `site-chrome.ts`
|
|
1141
|
-
|
|
1142
|
-
|
|
1140
|
+
by the layout `site-chrome.ts` declares, so a site edited after its scaffold
|
|
1141
|
+
imports what it renders. They are handed over only when they compile, by
|
|
1142
|
+
create-ailk's own compile, to the `theme:` block byte for byte and to the values
|
|
1143
|
+
`site-chrome.ts` and `site-fonts.ts` declare. Those two files are compared by
|
|
1144
|
+
their `siteChrome` and `siteFonts` values, read as data, never by their text, so
|
|
1145
|
+
a file an older create-ailk wrote, under an older type header, passes (#12635).
|
|
1146
|
+
`colorMode: "light"`, which #12500 retired, passes when the settings' dark
|
|
1147
|
+
colours equal their light ones:
|
|
1143
1148
|
|
|
1144
1149
|
```bash
|
|
1145
1150
|
create-ailk look-settings ~/sites/example --out ~/look-example.json
|
|
@@ -1149,9 +1154,16 @@ create-ailk look-settings ~/sites/example --out ~/look-example.json
|
|
|
1149
1154
|
`--out` must be a new file outside the checkout; it is created mode 0600 and
|
|
1150
1155
|
holds the settings, their digest (the SHA-256 of their canonical JSON) and the
|
|
1151
1156
|
SHA-256 of every file read. The hub CLI `import-site-design` reads it and
|
|
1152
|
-
re-checks every digest. A generated file that differs
|
|
1153
|
-
|
|
1154
|
-
|
|
1157
|
+
re-checks every digest. A generated file that differs exits 3: the `theme:`
|
|
1158
|
+
block is named with its first differing line, and a `siteChrome` or `siteFonts`
|
|
1159
|
+
value with its own name and line (a layout value the layout does not take, a key
|
|
1160
|
+
it does not carry, a required value left out, a face the settings do not
|
|
1161
|
+
source, a `className` missing a loader). A file missing, outside the checkout
|
|
1162
|
+
or over 1 MB, a `design.yaml` refused by the reader, or a `siteChrome` or
|
|
1163
|
+
`siteFonts` it cannot read as data — or that the file names again, lets the
|
|
1164
|
+
next line continue, or breaks with a line ending other than `\n` or `\r\n`, or
|
|
1165
|
+
that holds `export *`, `export {`, or a `/` or `\` outside a comment or string —
|
|
1166
|
+
exits 1; a bad flag or `--out` exits 2.
|
|
1155
1167
|
|
|
1156
1168
|
### A spoke's declared environment
|
|
1157
1169
|
|
package/dist/look-settings.d.ts
CHANGED
|
@@ -49,5 +49,5 @@ export interface LookSettingsArgs {
|
|
|
49
49
|
out: string | undefined;
|
|
50
50
|
help: boolean;
|
|
51
51
|
}
|
|
52
|
-
export declare const LOOK_SETTINGS_HELP = "create-ailk look-settings \u2014 the design settings a site's hub design record will hold.\n\nUsage:\n create-ailk look-settings [<dir>] --out <file>\n\nArguments:\n <dir> The site checkout. Defaults to the current dir.\n\nOptions:\n --out <file> Where the settings are handed over: a new file outside the checkout.\n -h, --help Show this help.\n\nReads design.yaml, the site roster, content/_site.mdx, apps/web/lib/site-chrome.ts and\napps/web/lib/site-fonts.ts as text
|
|
52
|
+
export declare const LOOK_SETTINGS_HELP = "create-ailk look-settings \u2014 the design settings a site's hub design record will hold.\n\nUsage:\n create-ailk look-settings [<dir>] --out <file>\n\nArguments:\n <dir> The site checkout. Defaults to the current dir.\n\nOptions:\n --out <file> Where the settings are handed over: a new file outside the checkout.\n -h, --help Show this help.\n\nReads design.yaml, the site roster, content/_site.mdx, apps/web/lib/site-chrome.ts and\napps/web/lib/site-fonts.ts as text. The settings take their layout from site-chrome.ts,\nand are handed over only when they compile to the theme: block byte for byte and to the\nvalues site-chrome.ts and site-fonts.ts declare. Runs no site code and needs no credential.\nThe runbook is docs/internal/runbooks/site-design-import.md.\nExit 0 handed over, 1 a failure, 2 a bad flag or --out, 3 a generated file that differs.\n";
|
|
53
53
|
export declare function parseLookSettingsArgs(argv: string[]): LookSettingsArgs;
|
package/dist/look-settings.js
CHANGED
|
@@ -8,17 +8,20 @@
|
|
|
8
8
|
* else the legacy `TEMPLATE-MANIFEST.json`), `content/_site.mdx`,
|
|
9
9
|
* `apps/web/lib/site-chrome.ts` and `apps/web/lib/site-fonts.ts` — each once,
|
|
10
10
|
* as text, never run. The settings are the design package with its layout
|
|
11
|
-
* replaced by the one
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* replaced by the one `site-chrome.ts` declares (#12635); the run hands them
|
|
12
|
+
* over only when they compile, by create-ailk's own compile, to what each
|
|
13
|
+
* generated file holds: the `theme:` block byte for byte, and the values
|
|
14
|
+
* `site-chrome.ts` and `site-fonts.ts` declare — read as data, so a file an
|
|
15
|
+
* older create-ailk wrote, with an older type header, passes. It writes one file outside the
|
|
14
16
|
* checkout (`--out`, created mode 0600, never overwritten) binding the
|
|
15
17
|
* settings to the checkout by the digest of every file it read, and records
|
|
16
18
|
* the settings' own digest, which it also prints. The hub CLI
|
|
17
19
|
* `import-site-design` reads that file.
|
|
18
20
|
*
|
|
19
21
|
* Exit codes: 0 handed over · 1 a failure (a file missing, outside the site,
|
|
20
|
-
* not a regular file, over 1 MB, or refused by the reader
|
|
21
|
-
*
|
|
22
|
+
* not a regular file, over 1 MB, or refused by the reader — among them a
|
|
23
|
+
* `siteChrome` or `siteFonts` the reader cannot read as data) · 2 a bad flag,
|
|
24
|
+
* or an `--out` that exists or sits in the checkout · 3 a generated file that
|
|
22
25
|
* differs from what `design.yaml` compiles to.
|
|
23
26
|
*
|
|
24
27
|
* Pure module: no `import.meta.url`, so jest imports it directly.
|
|
@@ -29,12 +32,13 @@ import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
|
29
32
|
import { parseArgs } from "node:util";
|
|
30
33
|
import { compileDesignFonts, compileDesignTheme } from "./design-compile.js";
|
|
31
34
|
import { DESIGN_SETTINGS_FILE } from "./design-files.js";
|
|
32
|
-
import { DesignPackageError, readDesignPackageText } from "./design-package.js";
|
|
35
|
+
import { DESIGN_COLOR_KEYS_LIGHT, DesignPackageError, readDesignPackageText, } from "./design-package.js";
|
|
33
36
|
import { spliceThemeBlock } from "./design-scaffold.js";
|
|
37
|
+
import { LAYOUT_OPTIONAL_KEYS, LAYOUT_REQUIRED_KEYS } from "./generated/design-settings.js";
|
|
34
38
|
import { SITE_MDX_PATH } from "./look-hub.js";
|
|
35
39
|
import { ParseError } from "./parse-args.js";
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
40
|
+
import { resolveSiteChrome, SITE_CHROME_PATH, TemplateLayoutError, validateTemplateLayout, } from "./site-chrome.js";
|
|
41
|
+
import { fontExportName, SITE_FONTS_PATH } from "./site-fonts.js";
|
|
38
42
|
import { LEGACY_SITE_ROSTER_PATH, parseSiteRoster, SITE_ROSTER_PATH } from "./site-roster.js";
|
|
39
43
|
const TAG = "[look:settings]";
|
|
40
44
|
/** A site file larger than this is refused (D2). */
|
|
@@ -154,11 +158,447 @@ function firstDifferingLine(a, b) {
|
|
|
154
158
|
}
|
|
155
159
|
return 1;
|
|
156
160
|
}
|
|
157
|
-
|
|
161
|
+
/** A generated file that differs; `what` names the declared value, never with the site's own text. */
|
|
162
|
+
const differs = (file, line, what) => `${TAG} ${file}: ${what === undefined ? "" : `${what} `}differs from what ${DESIGN_SETTINGS_FILE} compiles to at line ${line} — not imported`;
|
|
158
163
|
/** The roster name `readSiteRoster` would read: the current name when present, else the legacy one, else none. */
|
|
159
164
|
function rosterNameIn(root) {
|
|
160
165
|
return [SITE_ROSTER_PATH, LEGACY_SITE_ROSTER_PATH].find((name) => present(join(root, name)));
|
|
161
166
|
}
|
|
167
|
+
// ── Reading a declared value (#12635) ────────────────────────────────────────
|
|
168
|
+
/**
|
|
169
|
+
* A value the reader does not take as data — a name, a call, an operator. It
|
|
170
|
+
* is `{}` in canonical JSON, which no layout or face value equals. Only where
|
|
171
|
+
* it sits is read; it is never run.
|
|
172
|
+
*/
|
|
173
|
+
const CODE = Object.freeze({});
|
|
174
|
+
/** How deep a declared value may nest: deeper is refused, so no file can exhaust the stack. */
|
|
175
|
+
const DECLARED_DEPTH_MAX = 8;
|
|
176
|
+
/**
|
|
177
|
+
* Read the object literal at `start` of a site file's `text` as data, never
|
|
178
|
+
* as code (#12635): strings in either quote, numbers, `true` / `false` /
|
|
179
|
+
* `null`, arrays and objects of them. A member value that is anything else —
|
|
180
|
+
* a name, a call, an array spread, or a literal followed by more code, such
|
|
181
|
+
* as `[…].join(" ")` — is `CODE`. Comments are skipped. Each object key's
|
|
182
|
+
* 1-based line goes into `lines`, and each member value's text span (start,
|
|
183
|
+
* end) into `spans`, by dotted path. Throws `refused` on what
|
|
184
|
+
* the reader does not read: an unclosed string, comment or bracket, an escape
|
|
185
|
+
* outside `\n \r \t \0 \\ \' \" \uXXXX`, a key that is not a plain name or
|
|
186
|
+
* string (a spread, a getter, a computed key), and a duplicate key.
|
|
187
|
+
*/
|
|
188
|
+
function scanValue(text, start, lines, refused, spans = new Map()) {
|
|
189
|
+
let pos = start;
|
|
190
|
+
// Lines are counted once, as the scan moves forward, so a long file is never re-read per key.
|
|
191
|
+
let counted = 0;
|
|
192
|
+
let line = 1;
|
|
193
|
+
const lineAt = (at) => {
|
|
194
|
+
for (; counted < at; counted += 1)
|
|
195
|
+
if (text[counted] === "\n")
|
|
196
|
+
line += 1;
|
|
197
|
+
return line;
|
|
198
|
+
};
|
|
199
|
+
const skip = () => {
|
|
200
|
+
for (;;) {
|
|
201
|
+
const ws = /\s*/y;
|
|
202
|
+
ws.lastIndex = pos;
|
|
203
|
+
ws.exec(text);
|
|
204
|
+
pos = ws.lastIndex;
|
|
205
|
+
if (text.startsWith("//", pos)) {
|
|
206
|
+
const eol = text.indexOf("\n", pos);
|
|
207
|
+
pos = eol === -1 ? text.length : eol;
|
|
208
|
+
}
|
|
209
|
+
else if (text.startsWith("/*", pos)) {
|
|
210
|
+
const close = text.indexOf("*/", pos + 2);
|
|
211
|
+
if (close === -1)
|
|
212
|
+
throw refused();
|
|
213
|
+
pos = close + 2;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const ESCAPES = { n: "\n", r: "\r", t: "\t", "\\": "\\", "'": "'", '"': '"', "0": "\0" };
|
|
221
|
+
const readString = () => {
|
|
222
|
+
const quote = text[pos];
|
|
223
|
+
pos += 1;
|
|
224
|
+
let out = "";
|
|
225
|
+
for (;;) {
|
|
226
|
+
const ch = text[pos];
|
|
227
|
+
if (ch === undefined || ch === "\n")
|
|
228
|
+
throw refused();
|
|
229
|
+
pos += 1;
|
|
230
|
+
if (ch === quote)
|
|
231
|
+
return out;
|
|
232
|
+
if (ch !== "\\") {
|
|
233
|
+
out += ch;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const esc = text[pos] ?? "";
|
|
237
|
+
const hex = /^u([0-9a-fA-F]{4})/.exec(text.slice(pos, pos + 5));
|
|
238
|
+
if (hex !== null) {
|
|
239
|
+
out += String.fromCharCode(parseInt(hex[1], 16));
|
|
240
|
+
pos += 5;
|
|
241
|
+
}
|
|
242
|
+
else if (Object.hasOwn(ESCAPES, esc)) {
|
|
243
|
+
out += ESCAPES[esc];
|
|
244
|
+
pos += 1;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
throw refused();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
/** Skip one value that is code, to the `,` `}` or `]` that ends it at its own depth. */
|
|
252
|
+
const skipCode = () => {
|
|
253
|
+
let depth = 0;
|
|
254
|
+
for (;;) {
|
|
255
|
+
skip();
|
|
256
|
+
const ch = text[pos];
|
|
257
|
+
if (ch === undefined)
|
|
258
|
+
throw refused();
|
|
259
|
+
if (depth === 0 && (ch === "," || ch === "}" || ch === "]"))
|
|
260
|
+
return;
|
|
261
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
262
|
+
const close = new RegExp(`(?:[^${ch}\\\\]|\\\\[\\s\\S])*${ch}`, "y");
|
|
263
|
+
close.lastIndex = pos + 1;
|
|
264
|
+
if (close.exec(text) === null)
|
|
265
|
+
throw refused();
|
|
266
|
+
pos = close.lastIndex;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (ch === "(" || ch === "[" || ch === "{")
|
|
270
|
+
depth += 1;
|
|
271
|
+
if (ch === ")" || ch === "]" || ch === "}")
|
|
272
|
+
depth -= 1;
|
|
273
|
+
if (depth < 0)
|
|
274
|
+
throw refused();
|
|
275
|
+
pos += 1;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const NOT_LITERAL = Symbol("not a literal");
|
|
279
|
+
const readLiteral = (path, depth) => {
|
|
280
|
+
if (depth > DECLARED_DEPTH_MAX)
|
|
281
|
+
throw refused();
|
|
282
|
+
const ch = text[pos];
|
|
283
|
+
if (ch === '"' || ch === "'")
|
|
284
|
+
return readString();
|
|
285
|
+
const word = /(?:true|false|null|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)(?![\w$])/y;
|
|
286
|
+
word.lastIndex = pos;
|
|
287
|
+
const m = word.exec(text);
|
|
288
|
+
if (m !== null) {
|
|
289
|
+
pos = word.lastIndex;
|
|
290
|
+
return m[0] === "true" ? true : m[0] === "false" ? false : m[0] === "null" ? null : Number(m[0]);
|
|
291
|
+
}
|
|
292
|
+
if (ch === "[") {
|
|
293
|
+
pos += 1;
|
|
294
|
+
const items = [];
|
|
295
|
+
for (;;) {
|
|
296
|
+
skip();
|
|
297
|
+
if (text[pos] === "]")
|
|
298
|
+
break;
|
|
299
|
+
items.push(readValue(`${path}.${items.length}`, depth + 1));
|
|
300
|
+
if (text[pos] === ",")
|
|
301
|
+
pos += 1;
|
|
302
|
+
else if (text[pos] !== "]")
|
|
303
|
+
throw refused();
|
|
304
|
+
}
|
|
305
|
+
pos += 1;
|
|
306
|
+
return items;
|
|
307
|
+
}
|
|
308
|
+
if (ch === "{") {
|
|
309
|
+
pos += 1;
|
|
310
|
+
const obj = {};
|
|
311
|
+
for (;;) {
|
|
312
|
+
skip();
|
|
313
|
+
if (text[pos] === "}")
|
|
314
|
+
break;
|
|
315
|
+
const keyAt = pos;
|
|
316
|
+
let key;
|
|
317
|
+
if (text[pos] === '"' || text[pos] === "'") {
|
|
318
|
+
key = readString();
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
const ident = /[A-Za-z_$][\w$]*/y;
|
|
322
|
+
ident.lastIndex = pos;
|
|
323
|
+
const id = ident.exec(text);
|
|
324
|
+
if (id === null)
|
|
325
|
+
throw refused();
|
|
326
|
+
key = id[0];
|
|
327
|
+
pos = ident.lastIndex;
|
|
328
|
+
}
|
|
329
|
+
if (key === "__proto__" || Object.hasOwn(obj, key))
|
|
330
|
+
throw refused();
|
|
331
|
+
skip();
|
|
332
|
+
if (text[pos] !== ":")
|
|
333
|
+
throw refused();
|
|
334
|
+
pos += 1;
|
|
335
|
+
const keyPath = path === "" ? key : `${path}.${key}`;
|
|
336
|
+
lines.set(keyPath, lineAt(keyAt));
|
|
337
|
+
obj[key] = readValue(keyPath, depth + 1);
|
|
338
|
+
if (text[pos] === ",")
|
|
339
|
+
pos += 1;
|
|
340
|
+
else if (text[pos] !== "}")
|
|
341
|
+
throw refused();
|
|
342
|
+
}
|
|
343
|
+
pos += 1;
|
|
344
|
+
return obj;
|
|
345
|
+
}
|
|
346
|
+
return NOT_LITERAL;
|
|
347
|
+
};
|
|
348
|
+
/** A member's value: its literal when it is all literal, else `CODE`; leaves `pos` on the `,` `}` or `]` after it. */
|
|
349
|
+
const readValue = (path, depth) => {
|
|
350
|
+
skip();
|
|
351
|
+
const at = pos;
|
|
352
|
+
const value = readLiteral(path, depth);
|
|
353
|
+
skip();
|
|
354
|
+
if (value !== NOT_LITERAL && [",", "}", "]"].includes(text[pos] ?? "")) {
|
|
355
|
+
spans.set(path, [at, pos]);
|
|
356
|
+
return value;
|
|
357
|
+
}
|
|
358
|
+
pos = at;
|
|
359
|
+
skipCode();
|
|
360
|
+
spans.set(path, [at, pos]);
|
|
361
|
+
return CODE;
|
|
362
|
+
};
|
|
363
|
+
skip();
|
|
364
|
+
if (text[pos] !== "{")
|
|
365
|
+
throw refused();
|
|
366
|
+
const value = readLiteral("", 0);
|
|
367
|
+
return { value, end: pos };
|
|
368
|
+
}
|
|
369
|
+
/** Whitespace and comments, as a regular-expression source. */
|
|
370
|
+
const TRIVIA = String.raw `(?:\s|//[^\n]*|/\*[\s\S]*?\*/)*`;
|
|
371
|
+
/**
|
|
372
|
+
* The offset after each `export const <name> … =` in `text`, found the way
|
|
373
|
+
* `readExportedData` finds one: by walking the file token by token, past
|
|
374
|
+
* comments and strings, so a declaration inside a template literal or a
|
|
375
|
+
* comment never counts. It refuses (throws `refused`) what would let the
|
|
376
|
+
* walk read the file differently from JavaScript, or let `<name>` be
|
|
377
|
+
* exported without being spelled: a `/` outside a comment (a regular
|
|
378
|
+
* expression can hold a quote), a `\` outside a string (`\u0073iteChrome`
|
|
379
|
+
* is a name), a template that computes a value (`${`), an
|
|
380
|
+
* unclosed string or comment, and `export *` or `export {`.
|
|
381
|
+
*/
|
|
382
|
+
function declarationHeads(text, name, refused) {
|
|
383
|
+
const heads = [];
|
|
384
|
+
const head = new RegExp(`export\\s+(?:(const\\s+${name}(?![\\w$])[^=\\n]*=)|\\*|\\{)`, "y");
|
|
385
|
+
const token = /[A-Za-z_$][\w$]*|\s+/y;
|
|
386
|
+
let i = 0;
|
|
387
|
+
while (i < text.length) {
|
|
388
|
+
const ch = text[i];
|
|
389
|
+
if (text.startsWith("//", i)) {
|
|
390
|
+
const eol = text.indexOf("\n", i);
|
|
391
|
+
i = eol === -1 ? text.length : eol;
|
|
392
|
+
}
|
|
393
|
+
else if (text.startsWith("/*", i)) {
|
|
394
|
+
const close = text.indexOf("*/", i + 2);
|
|
395
|
+
if (close === -1)
|
|
396
|
+
throw refused();
|
|
397
|
+
i = close + 2;
|
|
398
|
+
}
|
|
399
|
+
else if (ch === "/" || ch === "\\") {
|
|
400
|
+
throw refused();
|
|
401
|
+
}
|
|
402
|
+
else if (ch === '"' || ch === "'" || ch === "`") {
|
|
403
|
+
const close = new RegExp(`(?:[^${ch}\\\\\\n]|\\\\[\\s\\S]${ch === "`" ? "|\\n" : ""})*${ch}`, "y");
|
|
404
|
+
close.lastIndex = i + 1;
|
|
405
|
+
const m = close.exec(text);
|
|
406
|
+
if (m === null || (ch === "`" && /(?<!\\)\$\{/.test(m[0])))
|
|
407
|
+
throw refused();
|
|
408
|
+
i = close.lastIndex;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
head.lastIndex = i;
|
|
412
|
+
const found = head.exec(text);
|
|
413
|
+
if (found !== null) {
|
|
414
|
+
if (found[1] === undefined)
|
|
415
|
+
throw refused();
|
|
416
|
+
heads.push(head.lastIndex);
|
|
417
|
+
i = head.lastIndex;
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
token.lastIndex = i;
|
|
421
|
+
i = token.exec(text) === null ? i + 1 : token.lastIndex;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return heads;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* The one `export const <name>` a site file declares, read by `scanValue`
|
|
428
|
+
* (#12635). The declaration may carry a type (`: SiteChrome`) and end with
|
|
429
|
+
* `as const` or `satisfies <Type>`; anything else — none, two, or a value that
|
|
430
|
+
* is not an object literal — is refused by the reader (exit 1). So is a file
|
|
431
|
+
* that names `<name>` anywhere else, where code could change the value after
|
|
432
|
+
* it is declared (`siteChrome.nav = …`); what `declarationHeads` refuses, so
|
|
433
|
+
* a decoy in a string or comment never stands in for it; a declaration that does not end at a `;` or the end of the file,
|
|
434
|
+
* where the next line could continue it (`} && { … }`); and a line break
|
|
435
|
+
* other than `\n` or `\r\n`, which ends a `//` comment for JavaScript but not
|
|
436
|
+
* for the reader — the same refusal `readExportedData` makes in
|
|
437
|
+
* `packages-paid/api-workspace/src/bin/site-file-data.ts`.
|
|
438
|
+
*/
|
|
439
|
+
function readDeclared(text, name, file) {
|
|
440
|
+
const refused = () => fail(`${file}: ${name} refused by the reader`);
|
|
441
|
+
if (/\r(?!\n)|\u2028|\u2029/.test(text))
|
|
442
|
+
throw refused();
|
|
443
|
+
const heads = declarationHeads(text, name, refused);
|
|
444
|
+
const head = heads[0];
|
|
445
|
+
const named = text.match(new RegExp(`(?<![\\w$])${name}(?![\\w$])`, "g"))?.length ?? 0;
|
|
446
|
+
if (heads.length !== 1 || named !== 1 || head === undefined)
|
|
447
|
+
throw refused();
|
|
448
|
+
const lines = new Map();
|
|
449
|
+
const spans = new Map();
|
|
450
|
+
const { value, end } = scanValue(text, head, lines, refused, spans);
|
|
451
|
+
const tail = new RegExp(`${TRIVIA}(?:(?:as\\s+const|satisfies\\s+[A-Za-z_$][\\w$.]*)${TRIVIA})?(?:;|$)`, "y");
|
|
452
|
+
tail.lastIndex = end;
|
|
453
|
+
if (tail.exec(text) === null)
|
|
454
|
+
throw refused();
|
|
455
|
+
return { value, lines, spans, line: text.slice(0, text.lastIndexOf("export", head)).split("\n").length };
|
|
456
|
+
}
|
|
457
|
+
/** Every key a layout carries — the generated lists, the same `design-package.ts` reads. */
|
|
458
|
+
const LAYOUT_KEYS = [...LAYOUT_REQUIRED_KEYS, ...LAYOUT_OPTIONAL_KEYS];
|
|
459
|
+
/**
|
|
460
|
+
* (#12635 c) The layout a `site-chrome.ts` declares: each layout key whose
|
|
461
|
+
* declared value the layout takes, so a site edited after its scaffold
|
|
462
|
+
* imports what it renders. A value it does not take is left out, and
|
|
463
|
+
* `chromeDifferences` names it.
|
|
464
|
+
*/
|
|
465
|
+
function declaredLayout(chrome) {
|
|
466
|
+
const layout = {};
|
|
467
|
+
for (const key of LAYOUT_KEYS) {
|
|
468
|
+
if (!Object.hasOwn(chrome.value, key))
|
|
469
|
+
continue;
|
|
470
|
+
try {
|
|
471
|
+
Object.assign(layout, validateTemplateLayout({ [key]: chrome.value[key] }, SITE_CHROME_PATH));
|
|
472
|
+
}
|
|
473
|
+
catch (err) {
|
|
474
|
+
if (!(err instanceof TemplateLayoutError))
|
|
475
|
+
throw err;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return layout;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Whether a look is the same in both modes: every dark colour equals its
|
|
482
|
+
* light one — `design-package.ts`'s own test for a matching pair of sets,
|
|
483
|
+
* and the form `update` gives a site pinned light (#12500).
|
|
484
|
+
*/
|
|
485
|
+
const sameInBothModes = (settings) => DESIGN_COLOR_KEYS_LIGHT.every((key) => settings.colors[key] === settings.colors[`${key}-dark`]);
|
|
486
|
+
/**
|
|
487
|
+
* (#12635 a) The `siteChrome` values that differ from `settings.layout`, in
|
|
488
|
+
* the file's order: a key the layout does not carry, a value it does not
|
|
489
|
+
* take or that the layout drops (a `deckGrounds` on a non-deck home), and a
|
|
490
|
+
* value left out. `colorMode: "light"` is equal when the settings are the
|
|
491
|
+
* same in both modes (#12500 retired the field).
|
|
492
|
+
*/
|
|
493
|
+
function chromeDifferences(chrome, settings) {
|
|
494
|
+
const expected = { ...settings.layout };
|
|
495
|
+
const at = (key) => chrome.lines.get(key) ?? chrome.line;
|
|
496
|
+
const lines = [];
|
|
497
|
+
const keys = [...Object.keys(chrome.value), ...LAYOUT_KEYS.filter((key) => !Object.hasOwn(chrome.value, key))];
|
|
498
|
+
for (const key of keys) {
|
|
499
|
+
if (key === "colorMode") {
|
|
500
|
+
if (chrome.value[key] !== "light" || !sameInBothModes(settings)) {
|
|
501
|
+
lines.push(differs(SITE_CHROME_PATH, at(key), "siteChrome.colorMode"));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
else if (!LAYOUT_KEYS.includes(key)) {
|
|
505
|
+
lines.push(`${TAG} ${SITE_CHROME_PATH}: siteChrome holds a key the layout does not carry at line ${at(key)} — not imported`);
|
|
506
|
+
}
|
|
507
|
+
else if (canonicalJson(chrome.value[key]) !== canonicalJson(expected[key])) {
|
|
508
|
+
// An absent key on either side is `undefined`, which equals only another absent key.
|
|
509
|
+
lines.push(differs(SITE_CHROME_PATH, at(key), `siteChrome.${key}`));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return lines;
|
|
513
|
+
}
|
|
514
|
+
/** The `className` the renderer writes, as its whole value: `[<slot>Face.variable, …].join(" ")`. */
|
|
515
|
+
const CLASS_NAME_VALUE = /^\[([^\]]*)\]\.join\(\s*(["'])\s\2\s*\)$/;
|
|
516
|
+
/**
|
|
517
|
+
* (#12635 b) The `siteFonts` values that differ from the faces the settings
|
|
518
|
+
* compile to. A role's face is read from what the file declares: its
|
|
519
|
+
* `families.<role>` (`var(--font-design-<slot>)` and the fallback after it)
|
|
520
|
+
* and the `<slot>Face` loader — a `next/font/google` export called with
|
|
521
|
+
* exactly `{ subsets: ["latin"], variable: "--font-design-<slot>" }`.
|
|
522
|
+
* `className` must name each loader the faces need (`<slot>Face.variable`),
|
|
523
|
+
* or the page never defines the face's variable.
|
|
524
|
+
*/
|
|
525
|
+
function fontsDifferences(fonts, settings) {
|
|
526
|
+
const { text, declared } = fonts;
|
|
527
|
+
const refused = () => fail(`${SITE_FONTS_PATH}: siteFonts refused by the reader`);
|
|
528
|
+
const google = new Set();
|
|
529
|
+
for (const m of text.matchAll(/^import\s*\{([^}]*)\}\s*from\s*["']next\/font\/google["']/gm)) {
|
|
530
|
+
for (const name of m[1].split(","))
|
|
531
|
+
google.add(name.trim());
|
|
532
|
+
}
|
|
533
|
+
const loaders = new Map();
|
|
534
|
+
for (const m of text.matchAll(/^const\s+(display|body)Face\s*=\s*([A-Za-z_$][\w$]*)\s*\(/gm)) {
|
|
535
|
+
const slot = m[1];
|
|
536
|
+
let options = CODE;
|
|
537
|
+
try {
|
|
538
|
+
options = scanValue(text, m.index + m[0].length, new Map(), refused).value;
|
|
539
|
+
}
|
|
540
|
+
catch (err) {
|
|
541
|
+
if (!(err instanceof Stop))
|
|
542
|
+
throw err;
|
|
543
|
+
}
|
|
544
|
+
const loads = !loaders.has(slot) &&
|
|
545
|
+
google.has(m[2]) &&
|
|
546
|
+
canonicalJson(options) === canonicalJson({ subsets: ["latin"], variable: `--font-design-${slot}` });
|
|
547
|
+
loaders.set(slot, loads ? m[2] : CODE);
|
|
548
|
+
}
|
|
549
|
+
const at = (path) => declared.lines.get(path) ?? declared.line;
|
|
550
|
+
const lines = [];
|
|
551
|
+
for (const key of Object.keys(declared.value)) {
|
|
552
|
+
if (key !== "className" && key !== "families") {
|
|
553
|
+
lines.push(`${TAG} ${SITE_FONTS_PATH}: siteFonts holds a key the faces do not carry at line ${at(key)} — not imported`);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const faces = compileDesignFonts(settings);
|
|
557
|
+
// The loaders the faces need: one per distinct family, named for the first role using it (the renderer's rule).
|
|
558
|
+
const needed = new Map();
|
|
559
|
+
for (const role of ["display", "body"]) {
|
|
560
|
+
const face = faces?.[role];
|
|
561
|
+
if (face !== undefined && !needed.has(face.family))
|
|
562
|
+
needed.set(face.family, role);
|
|
563
|
+
}
|
|
564
|
+
const className = declared.value["className"];
|
|
565
|
+
const span = declared.spans.get("className");
|
|
566
|
+
const classValue = span === undefined ? null : CLASS_NAME_VALUE.exec(text.slice(span[0], span[1]).trim());
|
|
567
|
+
const classSlots = className === ""
|
|
568
|
+
? []
|
|
569
|
+
: className === CODE && classValue !== null
|
|
570
|
+
? classValue[1].split(",").map((item) => /^\s*(display|body)Face\.variable\s*$/.exec(item)?.[1] ?? CODE)
|
|
571
|
+
: [CODE];
|
|
572
|
+
if (canonicalJson([...classSlots].sort()) !== canonicalJson([...needed.values()].sort())) {
|
|
573
|
+
lines.push(differs(SITE_FONTS_PATH, at("className"), "siteFonts.className"));
|
|
574
|
+
}
|
|
575
|
+
const families = declared.value["families"];
|
|
576
|
+
if (typeof families !== "object" || families === null || Array.isArray(families) || families === CODE) {
|
|
577
|
+
return [...lines, differs(SITE_FONTS_PATH, at("families"), "siteFonts.families")];
|
|
578
|
+
}
|
|
579
|
+
const declaredFamilies = families;
|
|
580
|
+
for (const key of Object.keys(declaredFamilies)) {
|
|
581
|
+
if (key !== "display" && key !== "body") {
|
|
582
|
+
lines.push(`${TAG} ${SITE_FONTS_PATH}: siteFonts.families holds a key the faces do not carry at line ${at(`families.${key}`)} — not imported`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
for (const role of ["display", "body"]) {
|
|
586
|
+
const want = faces?.[role];
|
|
587
|
+
const value = declaredFamilies[role];
|
|
588
|
+
const ref = typeof value === "string" ? /^var\(--font-design-(display|body)\)(?:, (.+))?$/.exec(value) : null;
|
|
589
|
+
const got = value === undefined
|
|
590
|
+
? undefined
|
|
591
|
+
: ref === null
|
|
592
|
+
? CODE
|
|
593
|
+
: { source: "google", family: loaders.get(ref[1]) ?? CODE, fallback: ref[2] ?? "" };
|
|
594
|
+
const wanted = want === undefined ? undefined : { source: want.source, family: fontExportName(want.family), fallback: want.fallback };
|
|
595
|
+
// `CODE` is `{}` in canonical JSON, which no face and no family name equals; an absent side is `undefined`.
|
|
596
|
+
if (canonicalJson(got) !== canonicalJson(wanted)) {
|
|
597
|
+
lines.push(differs(SITE_FONTS_PATH, at(`families.${role}`), `siteFonts.families.${role}`));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return lines;
|
|
601
|
+
}
|
|
162
602
|
/** `--out`'s checks before anything is read (exit 2): it must not exist, and its directory must sit outside the site. */
|
|
163
603
|
function checkOut(root, out) {
|
|
164
604
|
const path = resolve(out);
|
|
@@ -190,26 +630,30 @@ function differences(pkg, settings, siteMdx, chrome, fonts) {
|
|
|
190
630
|
? `${TAG} ${SITE_MDX_PATH}: compiled with the design's own deck grounds, which a non-deck home drops — this piece cannot import it`
|
|
191
631
|
: differs(SITE_MDX_PATH, firstDifferingLine(siteMdx, theme)));
|
|
192
632
|
}
|
|
193
|
-
// Step 3 — the layout.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
lines.push(differs(SITE_CHROME_PATH, firstDifferingLine(chrome, chromeNext)));
|
|
197
|
-
// Step 4 — the faces; an absent file is equal only when the settings source none.
|
|
198
|
-
const faces = compileDesignFonts(settings);
|
|
633
|
+
// Step 3 — the layout: the values `site-chrome.ts` declares (#12635).
|
|
634
|
+
lines.push(...chromeDifferences(chrome, settings));
|
|
635
|
+
// Step 4 — the faces `site-fonts.ts` declares; an absent file is equal only when the settings source none.
|
|
199
636
|
if (fonts === undefined) {
|
|
200
|
-
if (
|
|
637
|
+
if (compileDesignFonts(settings) !== undefined) {
|
|
201
638
|
lines.push(`${TAG} ${SITE_FONTS_PATH}: missing, but ${DESIGN_SETTINGS_FILE} sources faces — not imported`);
|
|
202
639
|
}
|
|
203
640
|
}
|
|
204
641
|
else {
|
|
205
|
-
|
|
206
|
-
if (fontsNext !== fonts)
|
|
207
|
-
lines.push(differs(SITE_FONTS_PATH, firstDifferingLine(fonts, fontsNext)));
|
|
642
|
+
lines.push(...fontsDifferences(fonts, settings));
|
|
208
643
|
}
|
|
209
644
|
return lines;
|
|
210
645
|
}
|
|
646
|
+
/** Where the settings' layout came from, as the `layout:` line names it (#12635). */
|
|
647
|
+
function layoutSource(pkg, settings, template) {
|
|
648
|
+
const layout = canonicalJson(settings.layout);
|
|
649
|
+
if (layout === canonicalJson(resolveSiteChrome(undefined, pkg.layout)))
|
|
650
|
+
return DESIGN_SETTINGS_FILE;
|
|
651
|
+
if (layout === canonicalJson(resolveSiteChrome(template, pkg.layout)))
|
|
652
|
+
return `the template's layout over ${DESIGN_SETTINGS_FILE}`;
|
|
653
|
+
return `${basename(SITE_CHROME_PATH)}'s layout over ${DESIGN_SETTINGS_FILE}`;
|
|
654
|
+
}
|
|
211
655
|
/** The summary lines printed after the settings (D2 "On success"). */
|
|
212
|
-
function summary(
|
|
656
|
+
function summary(settings, layout, digest, siteMdx) {
|
|
213
657
|
const faces = compileDesignFonts(settings);
|
|
214
658
|
const faceList = ["display", "body"].flatMap((role) => {
|
|
215
659
|
const face = faces?.[role];
|
|
@@ -219,7 +663,7 @@ function summary(pkg, settings, digest, siteMdx) {
|
|
|
219
663
|
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(siteMdx)?.[1] ?? "";
|
|
220
664
|
return [
|
|
221
665
|
`settings sha256: ${digest}`,
|
|
222
|
-
`layout: ${
|
|
666
|
+
`layout: ${layout}`,
|
|
223
667
|
`faces: ${faceList.length === 0 ? "none" : faceList.join(" ")}`,
|
|
224
668
|
`sections: ${pageTypes.length === 0 ? "none" : pageTypes.join(", ")}`,
|
|
225
669
|
...(/^brand:/m.test(frontmatter) ? ["brand: set in _site.mdx — stays there"] : []),
|
|
@@ -268,14 +712,11 @@ export function lookSettings(o) {
|
|
|
268
712
|
}
|
|
269
713
|
}
|
|
270
714
|
const siteMdx = read(SITE_MDX_PATH);
|
|
271
|
-
const chrome = read(SITE_CHROME_PATH);
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const settings = {
|
|
276
|
-
...pkg,
|
|
277
|
-
layout: resolveSiteChrome(roster === undefined ? undefined : templateLayoutOf(roster), pkg.layout),
|
|
278
|
-
};
|
|
715
|
+
const chrome = readDeclared(read(SITE_CHROME_PATH), "siteChrome", SITE_CHROME_PATH);
|
|
716
|
+
const fontsText = present(join(root, SITE_FONTS_PATH)) ? read(SITE_FONTS_PATH) : undefined;
|
|
717
|
+
const fonts = fontsText === undefined ? undefined : { text: fontsText, declared: readDeclared(fontsText, "siteFonts", SITE_FONTS_PATH) };
|
|
718
|
+
// Step 1 — the settings: the package with the layout `site-chrome.ts` declares (#12635).
|
|
719
|
+
const settings = { ...pkg, layout: resolveSiteChrome(declaredLayout(chrome)) };
|
|
279
720
|
const refused = differences(pkg, settings, siteMdx, chrome, fonts);
|
|
280
721
|
if (refused.length > 0)
|
|
281
722
|
throw new Stop(3, refused);
|
|
@@ -306,7 +747,9 @@ export function lookSettings(o) {
|
|
|
306
747
|
}
|
|
307
748
|
closeSync(fd);
|
|
308
749
|
line(JSON.stringify(settings, null, 2));
|
|
309
|
-
|
|
750
|
+
const templateLayoutOf = o.templateLayoutOf ?? ((r) => r.template.layout);
|
|
751
|
+
const layout = layoutSource(pkg, settings, roster === undefined ? undefined : templateLayoutOf(roster));
|
|
752
|
+
for (const entry of summary(settings, layout, digest, siteMdx))
|
|
310
753
|
line(entry);
|
|
311
754
|
return { exitCode: 0 };
|
|
312
755
|
}
|
|
@@ -331,8 +774,9 @@ Options:
|
|
|
331
774
|
-h, --help Show this help.
|
|
332
775
|
|
|
333
776
|
Reads design.yaml, the site roster, content/_site.mdx, apps/web/lib/site-chrome.ts and
|
|
334
|
-
apps/web/lib/site-fonts.ts as text
|
|
335
|
-
|
|
777
|
+
apps/web/lib/site-fonts.ts as text. The settings take their layout from site-chrome.ts,
|
|
778
|
+
and are handed over only when they compile to the theme: block byte for byte and to the
|
|
779
|
+
values site-chrome.ts and site-fonts.ts declare. Runs no site code and needs no credential.
|
|
336
780
|
The runbook is docs/internal/runbooks/site-design-import.md.
|
|
337
781
|
Exit 0 handed over, 1 a failure, 2 a bad flag or --out, 3 a generated file that differs.
|
|
338
782
|
`;
|
package/dist/site-chrome.d.ts
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* an untrusted (bundle-sourced) value. The resolved knobs reach a site as its
|
|
15
15
|
* hub design record's layout (`look-record.ts`, #12477): no scaffold or
|
|
16
16
|
* `apply-design` writes `apps/web/lib/site-chrome.ts` any more.
|
|
17
|
-
* `renderSiteChrome` stays
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `renderSiteChrome` stays as the record of what create-ailk wrote there;
|
|
18
|
+
* `look-settings` (#12476, #12635) reads the values a live site's retired
|
|
19
|
+
* file declares, takes its layout from them and refuses one the layout does
|
|
20
|
+
* not take, before the look is imported.
|
|
20
21
|
*
|
|
21
22
|
* Every field is optional and DEFAULTS to `full` / `columns` / `false` /
|
|
22
23
|
* `default` — the announcement banner is off unless a template turns it on
|
|
@@ -144,8 +145,8 @@ export declare function validateTemplateLayout(value: unknown, subject: string):
|
|
|
144
145
|
export declare function resolveSiteChrome(layout?: TemplateLayout, designLayout?: TemplateLayout): ResolvedSiteChrome;
|
|
145
146
|
/**
|
|
146
147
|
* The text create-ailk wrote to `apps/web/lib/site-chrome.ts` for a resolved
|
|
147
|
-
* layout, before #12477 retired the file
|
|
148
|
-
*
|
|
149
|
-
*
|
|
148
|
+
* layout, before #12477 retired the file; nothing writes it. `look-settings`
|
|
149
|
+
* compares the values a site's file declares, never its text (#12635): each
|
|
150
|
+
* release changed the `SiteChrome` type header above them.
|
|
150
151
|
*/
|
|
151
152
|
export declare function renderSiteChrome(resolved: ResolvedSiteChrome): string;
|
package/dist/site-chrome.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* an untrusted (bundle-sourced) value. The resolved knobs reach a site as its
|
|
15
15
|
* hub design record's layout (`look-record.ts`, #12477): no scaffold or
|
|
16
16
|
* `apply-design` writes `apps/web/lib/site-chrome.ts` any more.
|
|
17
|
-
* `renderSiteChrome` stays
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `renderSiteChrome` stays as the record of what create-ailk wrote there;
|
|
18
|
+
* `look-settings` (#12476, #12635) reads the values a live site's retired
|
|
19
|
+
* file declares, takes its layout from them and refuses one the layout does
|
|
20
|
+
* not take, before the look is imported.
|
|
20
21
|
*
|
|
21
22
|
* Every field is optional and DEFAULTS to `full` / `columns` / `false` /
|
|
22
23
|
* `default` — the announcement banner is off unless a template turns it on
|
|
@@ -220,9 +221,9 @@ export function resolveSiteChrome(layout, designLayout) {
|
|
|
220
221
|
}
|
|
221
222
|
/**
|
|
222
223
|
* The text create-ailk wrote to `apps/web/lib/site-chrome.ts` for a resolved
|
|
223
|
-
* layout, before #12477 retired the file
|
|
224
|
-
*
|
|
225
|
-
*
|
|
224
|
+
* layout, before #12477 retired the file; nothing writes it. `look-settings`
|
|
225
|
+
* compares the values a site's file declares, never its text (#12635): each
|
|
226
|
+
* release changed the `SiteChrome` type header above them.
|
|
226
227
|
*/
|
|
227
228
|
export function renderSiteChrome(resolved) {
|
|
228
229
|
// #7719 D3 — each `deckGrounds` line is emitted only when the chrome has one,
|
package/dist/site-fonts.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* The web faces a design's typography sources (#7720, spec
|
|
3
3
|
* docs/specs/7720-a-web-font-source-and-spec.md D3.2), as create-ailk wrote
|
|
4
4
|
* them to `apps/web/lib/site-fonts.ts` before #12477 retired the file: a
|
|
5
|
-
* site's faces now come from its hub design record.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* site's faces now come from its hub design record. Nothing writes the file:
|
|
6
|
+
* `renderSiteFonts` is the record of what create-ailk wrote, and
|
|
7
|
+
* `look-settings` (#12476, #12635) reads the faces a live site's file
|
|
8
|
+
* declares, by `fontExportName`, and compares them with the faces its
|
|
9
|
+
* settings compile to before the site's look is imported.
|
|
8
10
|
*/
|
|
9
11
|
import type { CompiledDesignFonts } from "./design-compile.js";
|
|
10
12
|
/**
|
|
@@ -13,5 +15,7 @@ import type { CompiledDesignFonts } from "./design-compile.js";
|
|
|
13
15
|
* once the hub's read for the site carries its look (D6).
|
|
14
16
|
*/
|
|
15
17
|
export declare const SITE_FONTS_PATH = "apps/web/lib/site-fonts.ts";
|
|
18
|
+
/** The `next/font/google` export that loads `family`: its spaces become underscores. */
|
|
19
|
+
export declare const fontExportName: (family: string) => string;
|
|
16
20
|
/** Render `apps/web/lib/site-fonts.ts` for `fonts` (D3.2). Ends with a trailing newline. */
|
|
17
21
|
export declare function renderSiteFonts(fonts: CompiledDesignFonts | undefined): string;
|
package/dist/site-fonts.js
CHANGED
|
@@ -18,6 +18,8 @@ const INTERFACE = `export interface SiteFonts {
|
|
|
18
18
|
families: { display?: string | undefined; body?: string | undefined };
|
|
19
19
|
}
|
|
20
20
|
`;
|
|
21
|
+
/** The `next/font/google` export that loads `family`: its spaces become underscores. */
|
|
22
|
+
export const fontExportName = (family) => family.replace(/ /g, "_");
|
|
21
23
|
/** Render `apps/web/lib/site-fonts.ts` for `fonts` (D3.2). Ends with a trailing newline. */
|
|
22
24
|
export function renderSiteFonts(fonts) {
|
|
23
25
|
const faces = ["display", "body"].flatMap((role) => {
|
|
@@ -33,9 +35,8 @@ export function renderSiteFonts(fonts) {
|
|
|
33
35
|
if (!slotOf.has(face.family))
|
|
34
36
|
slotOf.set(face.family, role);
|
|
35
37
|
}
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const loaders = [...slotOf].map(([family, slot]) => `const ${slot}Face = ${exportName(family)}({ subsets: ${JSON.stringify(["latin"])}, variable: ${JSON.stringify(`--font-design-${slot}`)} });`);
|
|
38
|
+
const imports = [...slotOf.keys()].map(fontExportName).sort();
|
|
39
|
+
const loaders = [...slotOf].map(([family, slot]) => `const ${slot}Face = ${fontExportName(family)}({ subsets: ${JSON.stringify(["latin"])}, variable: ${JSON.stringify(`--font-design-${slot}`)} });`);
|
|
39
40
|
const className = [...slotOf.values()].map((slot) => `${slot}Face.variable`).join(", ");
|
|
40
41
|
const families = faces.map(({ role, face }) => {
|
|
41
42
|
const slot = slotOf.get(face.family) ?? role;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.1",
|
|
4
4
|
"description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tar": "^7.5.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@working-theory/
|
|
32
|
-
"@working-theory/
|
|
31
|
+
"@working-theory/schema": "0.83.0",
|
|
32
|
+
"@working-theory/templates": "0.83.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
package/versions.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@working-theory/account": "0.
|
|
3
|
-
"@working-theory/admin-ui": "0.
|
|
4
|
-
"@working-theory/aeo": "0.
|
|
5
|
-
"@working-theory/agent-context": "0.
|
|
2
|
+
"@working-theory/account": "0.83.0",
|
|
3
|
+
"@working-theory/admin-ui": "0.83.0",
|
|
4
|
+
"@working-theory/aeo": "0.83.0",
|
|
5
|
+
"@working-theory/agent-context": "0.83.0",
|
|
6
6
|
"@working-theory/agent-contract": "0.1.0",
|
|
7
7
|
"@working-theory/agent-memory": "0.0.0",
|
|
8
8
|
"@working-theory/ai": "0.1.0",
|
|
9
|
-
"@working-theory/analytics": "0.
|
|
10
|
-
"@working-theory/api": "0.
|
|
11
|
-
"@working-theory/api-client": "0.
|
|
12
|
-
"@working-theory/auth": "0.
|
|
9
|
+
"@working-theory/analytics": "0.83.0",
|
|
10
|
+
"@working-theory/api": "0.83.0",
|
|
11
|
+
"@working-theory/api-client": "0.83.0",
|
|
12
|
+
"@working-theory/auth": "0.83.0",
|
|
13
13
|
"@working-theory/cda-filesystem": "0.0.0",
|
|
14
|
-
"@working-theory/cli": "0.
|
|
15
|
-
"@working-theory/common": "0.
|
|
14
|
+
"@working-theory/cli": "0.83.0",
|
|
15
|
+
"@working-theory/common": "0.83.0",
|
|
16
16
|
"@working-theory/consent": "0.1.0",
|
|
17
|
-
"@working-theory/content-adapters": "0.
|
|
18
|
-
"@working-theory/content-projection": "0.
|
|
19
|
-
"@working-theory/email": "0.
|
|
17
|
+
"@working-theory/content-adapters": "0.83.0",
|
|
18
|
+
"@working-theory/content-projection": "0.83.0",
|
|
19
|
+
"@working-theory/email": "0.83.0",
|
|
20
20
|
"@working-theory/env": "0.0.0",
|
|
21
|
-
"@working-theory/eslint-config": "0.
|
|
22
|
-
"@working-theory/fumadocs-schema": "0.
|
|
21
|
+
"@working-theory/eslint-config": "0.83.0",
|
|
22
|
+
"@working-theory/fumadocs-schema": "0.83.0",
|
|
23
23
|
"@working-theory/ids": "0.25.0",
|
|
24
|
-
"@working-theory/jsonld": "0.
|
|
25
|
-
"@working-theory/license": "0.
|
|
26
|
-
"@working-theory/mcp-server": "0.
|
|
27
|
-
"@working-theory/metadata": "0.
|
|
28
|
-
"@working-theory/observability": "0.
|
|
29
|
-
"@working-theory/page-renderer": "0.
|
|
24
|
+
"@working-theory/jsonld": "0.83.0",
|
|
25
|
+
"@working-theory/license": "0.83.0",
|
|
26
|
+
"@working-theory/mcp-server": "0.83.0",
|
|
27
|
+
"@working-theory/metadata": "0.83.0",
|
|
28
|
+
"@working-theory/observability": "0.83.0",
|
|
29
|
+
"@working-theory/page-renderer": "0.83.0",
|
|
30
30
|
"@working-theory/plugin-mcp": "0.1.3",
|
|
31
|
-
"@working-theory/schema": "0.
|
|
32
|
-
"@working-theory/schema-pack-registry": "0.
|
|
33
|
-
"@working-theory/schema-validator": "0.
|
|
34
|
-
"@working-theory/sections-registry": "0.
|
|
35
|
-
"@working-theory/site-config": "0.
|
|
36
|
-
"@working-theory/site-pages": "0.
|
|
37
|
-
"@working-theory/spoke-checkout": "0.7.
|
|
38
|
-
"@working-theory/stripe-client": "0.
|
|
39
|
-
"@working-theory/templates": "0.
|
|
40
|
-
"@working-theory/theme": "0.
|
|
41
|
-
"@working-theory/ui": "0.
|
|
42
|
-
"@working-theory/validation": "0.
|
|
43
|
-
"@working-theory/web-i18n": "0.
|
|
44
|
-
"@working-theory/admin": "0.
|
|
45
|
-
"@working-theory/api-commerce": "0.2.
|
|
46
|
-
"@working-theory/api-content-write": "0.20.
|
|
47
|
-
"@working-theory/api-hub": "0.10.
|
|
48
|
-
"@working-theory/api-multi-tenant": "0.7.
|
|
49
|
-
"@working-theory/api-scheduling": "0.6.
|
|
50
|
-
"@working-theory/api-signal-collectors": "0.10.
|
|
51
|
-
"@working-theory/api-workspace": "0.
|
|
31
|
+
"@working-theory/schema": "0.83.0",
|
|
32
|
+
"@working-theory/schema-pack-registry": "0.83.0",
|
|
33
|
+
"@working-theory/schema-validator": "0.83.0",
|
|
34
|
+
"@working-theory/sections-registry": "0.83.0",
|
|
35
|
+
"@working-theory/site-config": "0.83.0",
|
|
36
|
+
"@working-theory/site-pages": "0.83.0",
|
|
37
|
+
"@working-theory/spoke-checkout": "0.7.40",
|
|
38
|
+
"@working-theory/stripe-client": "0.83.0",
|
|
39
|
+
"@working-theory/templates": "0.83.0",
|
|
40
|
+
"@working-theory/theme": "0.83.0",
|
|
41
|
+
"@working-theory/ui": "0.83.0",
|
|
42
|
+
"@working-theory/validation": "0.83.0",
|
|
43
|
+
"@working-theory/web-i18n": "0.83.0",
|
|
44
|
+
"@working-theory/admin": "0.31.0",
|
|
45
|
+
"@working-theory/api-commerce": "0.2.18",
|
|
46
|
+
"@working-theory/api-content-write": "0.20.1",
|
|
47
|
+
"@working-theory/api-hub": "0.10.3",
|
|
48
|
+
"@working-theory/api-multi-tenant": "0.7.1",
|
|
49
|
+
"@working-theory/api-scheduling": "0.6.23",
|
|
50
|
+
"@working-theory/api-signal-collectors": "0.10.2",
|
|
51
|
+
"@working-theory/api-workspace": "0.23.0",
|
|
52
52
|
"@working-theory/billing-client": "0.0.0",
|
|
53
53
|
"@working-theory/branding": "0.0.0",
|
|
54
54
|
"@working-theory/license-client": "0.0.0",
|
|
55
55
|
"@working-theory/license-manifest": "0.0.0",
|
|
56
|
-
"@working-theory/look-catalogue": "0.1.
|
|
57
|
-
"@working-theory/mcp-scheduling": "0.4.
|
|
58
|
-
"@working-theory/mcp-signal-collectors": "0.2.
|
|
59
|
-
"@working-theory/mcp-workspace": "0.
|
|
56
|
+
"@working-theory/look-catalogue": "0.1.1",
|
|
57
|
+
"@working-theory/mcp-scheduling": "0.4.25",
|
|
58
|
+
"@working-theory/mcp-signal-collectors": "0.2.38",
|
|
59
|
+
"@working-theory/mcp-workspace": "0.20.0",
|
|
60
60
|
"@working-theory/partner-session": "0.0.0",
|
|
61
61
|
"@working-theory/preview-protocol": "0.0.0",
|
|
62
|
-
"@working-theory/ui-commerce": "0.
|
|
63
|
-
"@working-theory/ui-docs-blog": "0.
|
|
64
|
-
"@working-theory/ui-scheduling": "0.
|
|
65
|
-
"@working-theory/ui-signal-collectors": "0.
|
|
62
|
+
"@working-theory/ui-commerce": "0.83.0",
|
|
63
|
+
"@working-theory/ui-docs-blog": "0.83.0",
|
|
64
|
+
"@working-theory/ui-scheduling": "0.83.0",
|
|
65
|
+
"@working-theory/ui-signal-collectors": "0.83.0",
|
|
66
66
|
"@working-theory/web": "0.0.0",
|
|
67
67
|
"@working-theory/app-api": "1.0.0",
|
|
68
68
|
"@working-theory/mcp": "0.0.0",
|
|
69
|
-
"@working-theory/database": "0.
|
|
69
|
+
"@working-theory/database": "0.83.0"
|
|
70
70
|
}
|