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.
- package/README.md +180 -43
- package/component-catalog.json +223 -285
- package/component-catalog.md +1 -1
- package/dist/apply-design.d.ts +26 -68
- package/dist/apply-design.js +150 -322
- package/dist/cli.js +152 -17
- package/dist/compare-chrome.d.ts +108 -0
- package/dist/compare-chrome.js +481 -0
- package/dist/compare-look.d.ts +94 -0
- package/dist/compare-look.js +378 -0
- package/dist/copy.js +1 -1
- package/dist/design-compile.d.ts +17 -21
- package/dist/design-compile.js +32 -56
- package/dist/design-files.d.ts +93 -0
- package/dist/design-files.js +312 -0
- package/dist/design-home.d.ts +4 -2
- package/dist/design-home.js +88 -6
- package/dist/design-names.d.ts +13 -0
- package/dist/design-names.js +76 -0
- package/dist/design-package.d.ts +46 -56
- package/dist/design-package.js +285 -288
- package/dist/design-presets.d.ts +41 -0
- package/dist/design-presets.js +83 -4
- package/dist/design-scaffold.d.ts +12 -2
- package/dist/design-scaffold.js +72 -34
- package/dist/generated/design-settings.d.ts +56 -0
- package/dist/generated/design-settings.js +237 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/inventory.d.ts +3 -2
- package/dist/inventory.js +10 -4
- package/dist/lib/design-checks.d.ts +46 -0
- package/dist/lib/design-checks.js +79 -1
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/module-license-gate.d.ts +1 -1
- package/dist/lib/module-license-gate.js +1 -1
- package/dist/lib/render-verdict.d.ts +13 -1
- package/dist/lib/render-verdict.js +41 -1
- package/dist/look-hub.d.ts +44 -0
- package/dist/look-hub.js +130 -0
- package/dist/look-record.d.ts +35 -0
- package/dist/look-record.js +85 -0
- package/dist/look-samples.d.ts +66 -0
- package/dist/look-samples.js +456 -0
- package/dist/look-settings.d.ts +53 -0
- package/dist/look-settings.js +363 -0
- package/dist/module-architecture.js +12 -0
- package/dist/parse-args.d.ts +10 -6
- package/dist/parse-args.js +26 -13
- package/dist/programmatic.d.ts +1 -19
- package/dist/programmatic.js +65 -103
- package/dist/retired-design-bodies.d.ts +29 -0
- package/dist/retired-design-bodies.js +51 -0
- package/dist/seed-flows.d.ts +1 -1
- package/dist/seed-flows.js +12 -14
- package/dist/seed-workspace.d.ts +4 -1
- package/dist/seed-workspace.js +139 -17
- package/dist/site-chrome.d.ts +41 -41
- package/dist/site-chrome.js +50 -70
- package/dist/site-fonts.d.ts +10 -14
- package/dist/site-fonts.js +5 -1
- package/dist/starter-grid.d.ts +2 -2
- package/dist/strip-look-copies.d.ts +67 -0
- package/dist/strip-look-copies.js +591 -0
- package/dist/template-manifest.d.ts +6 -14
- package/dist/template-manifest.js +0 -9
- package/dist/template-record.d.ts +3 -1
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +15 -0
- package/dist/topology.js +60 -0
- package/dist/update.d.ts +57 -1
- package/dist/update.js +742 -13
- package/package.json +3 -4
- package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/designs/minimalism/DESIGN.md +163 -297
- package/site-templates/designs/minimalism/LOOK.md +42 -0
- package/site-templates/designs/minimalism/design.yaml +167 -0
- package/site-templates/designs/standard/DESIGN.md +145 -149
- package/site-templates/designs/standard/LOOK.md +42 -0
- package/site-templates/designs/standard/design.yaml +72 -0
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/content/_site.mdx +0 -26
- package/templates/.claude/rules/extending.md +3 -2
- package/templates/.env.example +11 -4
- package/templates/CLAUDE.md +1 -1
- package/templates/DESIGN.md +145 -149
- package/templates/README.md +15 -16
- package/templates/apps/api/.env.example +11 -4
- package/templates/apps/api/CLAUDE.md +6 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -5
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +10 -3
- package/templates/apps/web/CLAUDE.md +14 -3
- package/templates/apps/web/app/[locale]/layout.tsx +53 -50
- package/templates/apps/web/app/not-found.tsx +11 -11
- package/templates/apps/web/auth.ts +48 -35
- package/templates/apps/web/jest.config.cjs +5 -0
- package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +179 -31
- package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
- package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +71 -32
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
- package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
- package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
- package/templates/apps/web/lib/deck-page.ts +3 -10
- package/templates/apps/web/lib/deploy-fonts.ts +12 -0
- package/templates/apps/web/lib/hub-site-config.ts +97 -14
- package/templates/apps/web/lib/library-fonts.ts +41 -0
- package/templates/apps/web/lib/mcp-oauth.ts +11 -4
- package/templates/apps/web/lib/page-chrome.ts +52 -34
- package/templates/apps/web/lib/section-look.ts +28 -0
- package/templates/apps/web/lib/site-design.ts +205 -0
- package/templates/apps/web/lib/site-theme-head.ts +98 -13
- package/templates/apps/web/lib/site-theme.ts +40 -62
- package/templates/apps/web/messages/en.json +0 -6
- package/templates/apps/web/next.config.mjs +195 -6
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +4 -2
- package/templates/content/_site.mdx +0 -26
- package/templates/design.yaml +75 -0
- package/templates/project.yaml +14 -0
- package/versions.json +52 -51
- package/site-templates/marketing-site/DESIGN.md +0 -259
- package/site-templates/marketing-site-free/DESIGN.md +0 -259
- package/site-templates/saas-product/DESIGN.md +0 -259
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
- package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
- package/templates/apps/web/lib/site-chrome.ts +0 -46
- package/templates/apps/web/lib/site-fonts.ts +0 -15
package/dist/design-presets.d.ts
CHANGED
|
@@ -50,6 +50,34 @@ export interface LocatedSection {
|
|
|
50
50
|
readonly entryColumn: number;
|
|
51
51
|
readonly entries: readonly LocatedDataEntry[];
|
|
52
52
|
}
|
|
53
|
+
/** The first non-blank index at or after `i`, before `end`. */
|
|
54
|
+
export declare function skipSpace(text: string, i: number, end: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* A YAML scalar's string value — quoted (a trailing `# comment` allowed) or
|
|
57
|
+
* plain (a whitespace-preceded `# comment` stripped) — or undefined when it
|
|
58
|
+
* cannot be read (an unterminated quote, an escape JSON does not share).
|
|
59
|
+
*/
|
|
60
|
+
export declare function scalarText(raw: string): string | undefined;
|
|
61
|
+
export interface FlowMapping {
|
|
62
|
+
open: number;
|
|
63
|
+
close: number;
|
|
64
|
+
entries: LocatedDataEntry[];
|
|
65
|
+
}
|
|
66
|
+
/** Parse the flow mapping whose `{` is at `open`; undefined when it is not one. Exported for the sample fill's splice (#12472 D3). */
|
|
67
|
+
export declare function parseFlowMapping(text: string, open: number, end: number): FlowMapping | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* #12472 D3 — the items of the flow sequence whose `[` is at `open`, each as
|
|
70
|
+
* its `[start, end)` span, read as `parseFlowMapping` reads entries;
|
|
71
|
+
* undefined when it is not one.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseFlowSequence(text: string, open: number, end: number): {
|
|
74
|
+
open: number;
|
|
75
|
+
close: number;
|
|
76
|
+
items: {
|
|
77
|
+
start: number;
|
|
78
|
+
end: number;
|
|
79
|
+
}[];
|
|
80
|
+
} | undefined;
|
|
53
81
|
/**
|
|
54
82
|
* A page's located sections, with the `[valueStart, valueEnd)` span of the
|
|
55
83
|
* whole `sections:` value (#7743 D3): from just after `sections:` (and the
|
|
@@ -67,6 +95,8 @@ export type LocatedSections = LocatedSection[] & {
|
|
|
67
95
|
* Any other shape throws `TemplateError` naming the element (D5).
|
|
68
96
|
*/
|
|
69
97
|
export declare function locatePageSections(text: string, file: string): LocatedSections | undefined;
|
|
98
|
+
/** Every `.mdx` file under `dir`, recursively, sorted (#6816 D6): the pages a preset, a seed or a sample fill reads. */
|
|
99
|
+
export declare function listMdxFiles(dir: string): string[];
|
|
70
100
|
export interface PresetPage {
|
|
71
101
|
readonly path: string;
|
|
72
102
|
readonly text: string;
|
|
@@ -86,6 +116,17 @@ export declare function pageTypeOf(text: string, file: string): string | undefin
|
|
|
86
116
|
* `data`'s first entry. Throws `TemplateError` when the page cannot be located.
|
|
87
117
|
*/
|
|
88
118
|
export declare function setSectionLookField(text: string, file: string, index: number, field: string, value: unknown): string;
|
|
119
|
+
/**
|
|
120
|
+
* Remove one `data` entry from section `index` of a page — the inverse of
|
|
121
|
+
* `setSectionLookField` (#12474 D10): the entry and one separator go, and no
|
|
122
|
+
* other byte. Flow: a first entry takes the `,` and the whitespace after it
|
|
123
|
+
* (the separator `setSectionLookField` inserts), a later entry the `,` and
|
|
124
|
+
* whitespace before it, and a sole entry leaves `{}`. Block: the entry's
|
|
125
|
+
* line(s), a trailing comment included, and the newline before them. Returns
|
|
126
|
+
* `text` unchanged when the section has no such entry. Throws
|
|
127
|
+
* `TemplateError` when the page cannot be located.
|
|
128
|
+
*/
|
|
129
|
+
export declare function removeSectionLookField(text: string, file: string, index: number, field: string): string;
|
|
89
130
|
/**
|
|
90
131
|
* Write a validated preset block's look fields onto the sections a page
|
|
91
132
|
* already places, for the pages whose `type:` is in `opts.pageTypes` (the
|
package/dist/design-presets.js
CHANGED
|
@@ -256,7 +256,8 @@ function cannotLocate(file, index, what) {
|
|
|
256
256
|
const where = index === undefined ? "sections" : `sections[${index}]`;
|
|
257
257
|
throw new TemplateError(`${file}: ${where} — cannot locate ${what} for a design preset`);
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
/** The first non-blank index at or after `i`, before `end`. */
|
|
260
|
+
export function skipSpace(text, i, end) {
|
|
260
261
|
while (i < end && /\s/.test(text[i]))
|
|
261
262
|
i++;
|
|
262
263
|
return i;
|
|
@@ -317,7 +318,7 @@ function endOfFlowValue(text, i, end) {
|
|
|
317
318
|
* plain (a whitespace-preceded `# comment` stripped) — or undefined when it
|
|
318
319
|
* cannot be read (an unterminated quote, an escape JSON does not share).
|
|
319
320
|
*/
|
|
320
|
-
function scalarText(raw) {
|
|
321
|
+
export function scalarText(raw) {
|
|
321
322
|
const text = raw.trim();
|
|
322
323
|
if (text.startsWith('"') || text.startsWith("'")) {
|
|
323
324
|
const close = endOfQuoted(text, 0, text.length);
|
|
@@ -348,8 +349,8 @@ function endOfInlineScalar(text, i, lineEnd) {
|
|
|
348
349
|
end--;
|
|
349
350
|
return end;
|
|
350
351
|
}
|
|
351
|
-
/** Parse the flow mapping whose `{` is at `open`; undefined when it is not one. */
|
|
352
|
-
function parseFlowMapping(text, open, end) {
|
|
352
|
+
/** Parse the flow mapping whose `{` is at `open`; undefined when it is not one. Exported for the sample fill's splice (#12472 D3). */
|
|
353
|
+
export function parseFlowMapping(text, open, end) {
|
|
353
354
|
if (text[open] !== "{")
|
|
354
355
|
return undefined;
|
|
355
356
|
const entries = [];
|
|
@@ -391,6 +392,31 @@ function parseFlowMapping(text, open, end) {
|
|
|
391
392
|
return undefined;
|
|
392
393
|
return { open, close: i, entries };
|
|
393
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* #12472 D3 — the items of the flow sequence whose `[` is at `open`, each as
|
|
397
|
+
* its `[start, end)` span, read as `parseFlowMapping` reads entries;
|
|
398
|
+
* undefined when it is not one.
|
|
399
|
+
*/
|
|
400
|
+
export function parseFlowSequence(text, open, end) {
|
|
401
|
+
if (text[open] !== "[")
|
|
402
|
+
return undefined;
|
|
403
|
+
const items = [];
|
|
404
|
+
let i = skipSpace(text, open + 1, end);
|
|
405
|
+
while (i < end && text[i] !== "]") {
|
|
406
|
+
const itemEnd = endOfFlowValue(text, i, end);
|
|
407
|
+
if (itemEnd < 0)
|
|
408
|
+
return undefined;
|
|
409
|
+
items.push({ start: i, end: itemEnd });
|
|
410
|
+
i = skipSpace(text, itemEnd, end);
|
|
411
|
+
if (text[i] === ",")
|
|
412
|
+
i = skipSpace(text, i + 1, end);
|
|
413
|
+
else if (text[i] !== "]")
|
|
414
|
+
return undefined;
|
|
415
|
+
}
|
|
416
|
+
if (text[i] !== "]")
|
|
417
|
+
return undefined;
|
|
418
|
+
return { open, close: i, items };
|
|
419
|
+
}
|
|
394
420
|
function locateFlow(text, open, end, file) {
|
|
395
421
|
const out = [];
|
|
396
422
|
let i = skipSpace(text, open + 1, end);
|
|
@@ -585,6 +611,25 @@ export function locatePageSections(text, file) {
|
|
|
585
611
|
}
|
|
586
612
|
return cannotLocate(file, undefined, "a flow or block sequence");
|
|
587
613
|
}
|
|
614
|
+
// ── D4: applyDesignPresets ─────────────────────────────────────────────────
|
|
615
|
+
/** Every `.mdx` file under `dir`, recursively, sorted (#6816 D6): the pages a preset, a seed or a sample fill reads. */
|
|
616
|
+
export function listMdxFiles(dir) {
|
|
617
|
+
if (!existsSync(dir))
|
|
618
|
+
return [];
|
|
619
|
+
const out = [];
|
|
620
|
+
const stack = [dir];
|
|
621
|
+
while (stack.length > 0) {
|
|
622
|
+
const current = stack.pop();
|
|
623
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
624
|
+
const abs = join(current, entry.name);
|
|
625
|
+
if (entry.isDirectory())
|
|
626
|
+
stack.push(abs);
|
|
627
|
+
else if (entry.name.endsWith(".mdx"))
|
|
628
|
+
out.push(abs);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return out.sort();
|
|
632
|
+
}
|
|
588
633
|
/** The frontmatter's column-0 `type:` value, or undefined when it has none. */
|
|
589
634
|
export function pageTypeOf(text, file) {
|
|
590
635
|
const fm = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?$/m.exec(text);
|
|
@@ -632,6 +677,40 @@ export function setSectionLookField(text, file, index, field, value) {
|
|
|
632
677
|
const line = `\n${" ".repeat(section.entryColumn)}${field}: ${rendered}`;
|
|
633
678
|
return text.slice(0, section.dataOpen) + line + text.slice(section.dataOpen);
|
|
634
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Remove one `data` entry from section `index` of a page — the inverse of
|
|
682
|
+
* `setSectionLookField` (#12474 D10): the entry and one separator go, and no
|
|
683
|
+
* other byte. Flow: a first entry takes the `,` and the whitespace after it
|
|
684
|
+
* (the separator `setSectionLookField` inserts), a later entry the `,` and
|
|
685
|
+
* whitespace before it, and a sole entry leaves `{}`. Block: the entry's
|
|
686
|
+
* line(s), a trailing comment included, and the newline before them. Returns
|
|
687
|
+
* `text` unchanged when the section has no such entry. Throws
|
|
688
|
+
* `TemplateError` when the page cannot be located.
|
|
689
|
+
*/
|
|
690
|
+
export function removeSectionLookField(text, file, index, field) {
|
|
691
|
+
const section = locatePageSections(text, file)?.[index];
|
|
692
|
+
if (section === undefined)
|
|
693
|
+
cannotLocate(file, index, "the section");
|
|
694
|
+
const at = section.entries.findIndex((e) => e.key === field);
|
|
695
|
+
if (at < 0)
|
|
696
|
+
return text;
|
|
697
|
+
const entry = section.entries[at];
|
|
698
|
+
if (section.form === "flow") {
|
|
699
|
+
if (section.entries.length === 1) {
|
|
700
|
+
return `${text.slice(0, section.dataOpen)}{}${text.slice(section.dataClose + 1)}`;
|
|
701
|
+
}
|
|
702
|
+
if (at > 0) {
|
|
703
|
+
return text.slice(0, section.entries[at - 1].valueEnd) + text.slice(entry.valueEnd);
|
|
704
|
+
}
|
|
705
|
+
const keyStart = skipSpace(text, section.dataOpen + 1, entry.valueStart);
|
|
706
|
+
const next = section.entries[1];
|
|
707
|
+
const comma = skipSpace(text, entry.valueEnd, next.valueStart);
|
|
708
|
+
return text.slice(0, keyStart) + text.slice(skipSpace(text, comma + 1, next.valueStart));
|
|
709
|
+
}
|
|
710
|
+
const lineBreak = text.lastIndexOf("\n", entry.valueStart - 1);
|
|
711
|
+
const nl = text.indexOf("\n", entry.valueEnd);
|
|
712
|
+
return text.slice(0, lineBreak) + text.slice(nl < 0 ? text.length : nl);
|
|
713
|
+
}
|
|
635
714
|
/**
|
|
636
715
|
* Write a validated preset block's look fields onto the sections a page
|
|
637
716
|
* already places, for the pages whose `type:` is in `opts.pageTypes` (the
|
|
@@ -4,7 +4,7 @@ import { type DesignPackage } from "./design-package.js";
|
|
|
4
4
|
export interface ResolvedDesign {
|
|
5
5
|
/** "name" when the reference was a registry name, "path" when a directory. */
|
|
6
6
|
kind: "name" | "path";
|
|
7
|
-
/** Absolute directory holding the
|
|
7
|
+
/** Absolute directory holding the design.yaml. */
|
|
8
8
|
dir: string;
|
|
9
9
|
pkg: DesignPackage;
|
|
10
10
|
/** What the site records: the registry name when `pkg` deep-equals a shipped design's package, else `pkg.name`. */
|
|
@@ -42,7 +42,8 @@ export declare function resolveDesign(ref: string, opts: {
|
|
|
42
42
|
* in the compile's order, role keys unquoted, sizes as plain scalars (#7720
|
|
43
43
|
* D2, #7739 D2.5) — then `colors:` with `light:`/`dark:` sub-blocks, each
|
|
44
44
|
* colour slot as `slot: <JSON.stringify(value)>` in `DESIGN_COLOR_MAP`'s
|
|
45
|
-
* order
|
|
45
|
+
* order, and a `band:` sub-block after `dark:` when the theme carries one
|
|
46
|
+
* (#12500 D2). Ends with a trailing newline.
|
|
46
47
|
*/
|
|
47
48
|
export declare function renderThemeBlock(theme: CompiledDesignTheme): string;
|
|
48
49
|
/**
|
|
@@ -55,3 +56,12 @@ export declare function renderThemeBlock(theme: CompiledDesignTheme): string;
|
|
|
55
56
|
* @throws TemplateError when `text` carries no frontmatter to write into.
|
|
56
57
|
*/
|
|
57
58
|
export declare function spliceThemeBlock(text: string, theme: CompiledDesignTheme, file: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* `text` with its frontmatter `theme:` block removed (#12477 D6) — the line
|
|
61
|
+
* `theme:` and every following line that is empty or begins with a space, up
|
|
62
|
+
* to the closing `---`, by `spliceThemeBlock`'s block rule; every other byte
|
|
63
|
+
* kept. `text` unchanged when it carries no block.
|
|
64
|
+
*
|
|
65
|
+
* @throws TemplateError when `text` carries no frontmatter.
|
|
66
|
+
*/
|
|
67
|
+
export declare function removeThemeBlock(text: string, file: string): string;
|
package/dist/design-scaffold.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolve a `--design` reference (a shipped name, or a directory holding a
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* `design.yaml`) to its design package (#6813, spec
|
|
4
|
+
* docs/specs/6813-design-accepts-a-package-path-spec.md D2), and read or
|
|
5
|
+
* remove a `content/_site.mdx` `theme:` block. No scaffold or `apply-design`
|
|
6
|
+
* writes that block since #12477 — the site's look is its hub design record;
|
|
7
|
+
* `update` moves an old site's block (#12500 D7) and removes it once the
|
|
8
|
+
* hub's read carries the look (#12477 D6).
|
|
6
9
|
*
|
|
7
10
|
* `resolveDesign` is the one resolver every front door (the CLI, `scaffold()`,
|
|
8
11
|
* `verify-scaffold.mjs`) passes a design reference through, before any
|
|
@@ -14,9 +17,10 @@ import { statSync } from "node:fs";
|
|
|
14
17
|
import { join, resolve } from "node:path";
|
|
15
18
|
import { isDeepStrictEqual } from "node:util";
|
|
16
19
|
import { DESIGN_COLOR_MAP } from "./design-compile.js";
|
|
20
|
+
import { shippedDesigns } from "./design-names.js";
|
|
17
21
|
import { readDesignPackage } from "./design-package.js";
|
|
18
22
|
import { FREE_DESIGNS } from "./lib/module-license-gate.js";
|
|
19
|
-
import {
|
|
23
|
+
import { TemplateError } from "./template-manifest.js";
|
|
20
24
|
/** `path` is an existing DIRECTORY — a file at `path` is not (mirrors `parse-args.ts`'s own helper). */
|
|
21
25
|
function isExistingDir(path) {
|
|
22
26
|
try {
|
|
@@ -46,7 +50,8 @@ function isExistingDir(path) {
|
|
|
46
50
|
export function resolveDesign(ref, opts) {
|
|
47
51
|
const cwd = opts.cwd ?? process.cwd();
|
|
48
52
|
const hasSeparator = ref.includes("/") || ref.includes("\\");
|
|
49
|
-
|
|
53
|
+
const shipped = shippedDesigns();
|
|
54
|
+
if (!hasSeparator && shipped.includes(ref)) {
|
|
50
55
|
const dir = join(opts.designsDir, ref);
|
|
51
56
|
return {
|
|
52
57
|
kind: "name",
|
|
@@ -61,10 +66,10 @@ export function resolveDesign(ref, opts) {
|
|
|
61
66
|
if (!isExistingDir(dir)) {
|
|
62
67
|
throw new TemplateError(hasSeparator
|
|
63
68
|
? `design directory "${ref}" does not exist`
|
|
64
|
-
: `unknown design "${ref}". Declared: ${
|
|
69
|
+
: `unknown design "${ref}". Declared: ${shipped.join(", ")}`);
|
|
65
70
|
}
|
|
66
71
|
const pkg = readDesignPackage(dir);
|
|
67
|
-
for (const name of
|
|
72
|
+
for (const name of shipped) {
|
|
68
73
|
if (isDeepStrictEqual(pkg, readDesignPackage(join(opts.designsDir, name)))) {
|
|
69
74
|
return {
|
|
70
75
|
kind: "path",
|
|
@@ -76,6 +81,12 @@ export function resolveDesign(ref, opts) {
|
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
83
|
}
|
|
84
|
+
// SEC-12500-8 — a package that differs from every shipped look may not take
|
|
85
|
+
// one's name, so a third party's `name: standard` never lands as `standard`.
|
|
86
|
+
const borrowed = shipped.find((name) => name === pkg.name.trim().toLowerCase());
|
|
87
|
+
if (borrowed !== undefined) {
|
|
88
|
+
throw new TemplateError(`design "${dir}": name "${pkg.name}" is a shipped look's name, and its settings differ from that look's — give it a name of its own`);
|
|
89
|
+
}
|
|
79
90
|
return { kind: "path", dir, pkg, recorded: pkg.name, display: dir, free: false };
|
|
80
91
|
}
|
|
81
92
|
/** The runtime colour slots, in `DESIGN_COLOR_MAP`'s light-mode row order — the order every committed `theme:` block uses. */
|
|
@@ -87,7 +98,8 @@ const RUNTIME_COLOR_SLOT_ORDER = DESIGN_COLOR_MAP.filter((row) => row.mode === "
|
|
|
87
98
|
* in the compile's order, role keys unquoted, sizes as plain scalars (#7720
|
|
88
99
|
* D2, #7739 D2.5) — then `colors:` with `light:`/`dark:` sub-blocks, each
|
|
89
100
|
* colour slot as `slot: <JSON.stringify(value)>` in `DESIGN_COLOR_MAP`'s
|
|
90
|
-
* order
|
|
101
|
+
* order, and a `band:` sub-block after `dark:` when the theme carries one
|
|
102
|
+
* (#12500 D2). Ends with a trailing newline.
|
|
91
103
|
*/
|
|
92
104
|
export function renderThemeBlock(theme) {
|
|
93
105
|
const lines = ["theme:"];
|
|
@@ -118,9 +130,12 @@ export function renderThemeBlock(theme) {
|
|
|
118
130
|
if (theme.darkBands !== undefined)
|
|
119
131
|
lines.push(` darkBands: ${theme.darkBands}`);
|
|
120
132
|
lines.push(" colors:");
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
// #12500 D2 — the band palette, after `dark`, only when the design carries one.
|
|
134
|
+
for (const mode of ["light", "dark", "band"]) {
|
|
123
135
|
const palette = theme.colors[mode];
|
|
136
|
+
if (palette === undefined)
|
|
137
|
+
continue;
|
|
138
|
+
lines.push(` ${mode}:`);
|
|
124
139
|
for (const slot of RUNTIME_COLOR_SLOT_ORDER) {
|
|
125
140
|
lines.push(` ${slot}: ${JSON.stringify(palette[slot])}`);
|
|
126
141
|
}
|
|
@@ -128,16 +143,14 @@ export function renderThemeBlock(theme) {
|
|
|
128
143
|
return `${lines.join("\n")}\n`;
|
|
129
144
|
}
|
|
130
145
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* design, this is the identity function (byte-identity floor, AC-4).
|
|
146
|
+
* The frontmatter's closing `---` line and its `theme:` block — the line
|
|
147
|
+
* `theme:` and every following line that is empty or begins with a space, up
|
|
148
|
+
* to the close (`start` is -1 when there is none). Shared by
|
|
149
|
+
* `spliceThemeBlock` and `removeThemeBlock`, so both read one block rule.
|
|
136
150
|
*
|
|
137
|
-
* @throws TemplateError when `
|
|
151
|
+
* @throws TemplateError when `lines` carry no frontmatter.
|
|
138
152
|
*/
|
|
139
|
-
|
|
140
|
-
const lines = text.split("\n");
|
|
153
|
+
function locateThemeBlock(lines, file, action) {
|
|
141
154
|
let closeIdx = -1;
|
|
142
155
|
if (lines[0] === "---") {
|
|
143
156
|
for (let i = 1; i < lines.length; i += 1) {
|
|
@@ -148,25 +161,50 @@ export function spliceThemeBlock(text, theme, file) {
|
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
163
|
if (closeIdx === -1) {
|
|
151
|
-
throw new TemplateError(`${file}: no frontmatter to
|
|
164
|
+
throw new TemplateError(`${file}: no frontmatter to ${action}`);
|
|
152
165
|
}
|
|
153
|
-
const rendered = renderThemeBlock(theme).split("\n");
|
|
154
|
-
rendered.pop(); // drop the trailing "" the render's final "\n" split off
|
|
155
|
-
let themeStart = -1;
|
|
156
|
-
let themeEnd = -1;
|
|
157
166
|
for (let i = 1; i < closeIdx; i += 1) {
|
|
158
|
-
if (lines[i]
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
themeEnd = j;
|
|
165
|
-
break;
|
|
167
|
+
if (lines[i] !== "theme:")
|
|
168
|
+
continue;
|
|
169
|
+
let j = i + 1;
|
|
170
|
+
while (j < closeIdx && (lines[j] === "" || lines[j].startsWith(" "))) {
|
|
171
|
+
j += 1;
|
|
166
172
|
}
|
|
173
|
+
return { closeIdx, start: i, end: j };
|
|
167
174
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
return { closeIdx, start: -1, end: -1 };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Splice a compiled theme into `text`'s frontmatter `theme:` block (D5),
|
|
179
|
+
* replacing an existing one in place or inserting a fresh one immediately
|
|
180
|
+
* before the closing `---` when the frontmatter carries none. Nothing
|
|
181
|
+
* outside the block moves — for every committed `_site.mdx` and its own
|
|
182
|
+
* design, this is the identity function (byte-identity floor, AC-4).
|
|
183
|
+
*
|
|
184
|
+
* @throws TemplateError when `text` carries no frontmatter to write into.
|
|
185
|
+
*/
|
|
186
|
+
export function spliceThemeBlock(text, theme, file) {
|
|
187
|
+
const lines = text.split("\n");
|
|
188
|
+
const block = locateThemeBlock(lines, file, "write the theme into");
|
|
189
|
+
const rendered = renderThemeBlock(theme).split("\n");
|
|
190
|
+
rendered.pop(); // drop the trailing "" the render's final "\n" split off
|
|
191
|
+
const next = block.start === -1
|
|
192
|
+
? [...lines.slice(0, block.closeIdx), ...rendered, ...lines.slice(block.closeIdx)]
|
|
193
|
+
: [...lines.slice(0, block.start), ...rendered, ...lines.slice(block.end)];
|
|
171
194
|
return next.join("\n");
|
|
172
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* `text` with its frontmatter `theme:` block removed (#12477 D6) — the line
|
|
198
|
+
* `theme:` and every following line that is empty or begins with a space, up
|
|
199
|
+
* to the closing `---`, by `spliceThemeBlock`'s block rule; every other byte
|
|
200
|
+
* kept. `text` unchanged when it carries no block.
|
|
201
|
+
*
|
|
202
|
+
* @throws TemplateError when `text` carries no frontmatter.
|
|
203
|
+
*/
|
|
204
|
+
export function removeThemeBlock(text, file) {
|
|
205
|
+
const lines = text.split("\n");
|
|
206
|
+
const block = locateThemeBlock(lines, file, "remove the theme from");
|
|
207
|
+
if (block.start === -1)
|
|
208
|
+
return text;
|
|
209
|
+
return [...lines.slice(0, block.start), ...lines.slice(block.end)].join("\n");
|
|
210
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const BREAK_OR_CONTROL_REGEX: RegExp;
|
|
2
|
+
export declare const BUTTON_SHAPE_VALUES: readonly ["control", "pill"];
|
|
3
|
+
export declare const CHECKMARKS_VALUES: readonly ["circle", "plain"];
|
|
4
|
+
export declare const CHROME_STYLE_VALUES: readonly ["default", "minimal"];
|
|
5
|
+
export declare const CLOSING_FOOTER_PATHS_MAX = 20;
|
|
6
|
+
export declare const CLOSING_FOOTER_PATH_MAX = 200;
|
|
7
|
+
export declare const CLOSING_FOOTER_PATH_REGEX: RegExp;
|
|
8
|
+
export declare const CLOSING_FOOTER_PATH_SEGMENTS_MAX = 20;
|
|
9
|
+
export declare const COLOR_KEYS_BAND: readonly ["bg-band", "fg-band", "surface-band", "surface-secondary-band", "border-band", "text-muted-band", "brand-band", "fg-on-brand-band", "accent-band"];
|
|
10
|
+
export declare const COLOR_KEYS_DARK: readonly ["bg-dark", "fg-dark", "surface-dark", "surface-secondary-dark", "border-dark", "text-muted-dark", "brand-dark", "fg-on-brand-dark", "accent-dark"];
|
|
11
|
+
export declare const COLOR_KEYS_LIGHT: readonly ["bg", "fg", "surface", "surface-secondary", "border", "text-muted", "brand", "fg-on-brand", "accent"];
|
|
12
|
+
export declare const COLOR_VALUE_REGEX: RegExp;
|
|
13
|
+
export declare const COMPILED_PALETTE_KEYS: readonly ["bg", "bgMuted", "surface", "border", "text", "textMuted", "primary", "primaryFg", "accent", "accentFg", "destructive", "destructiveFg"];
|
|
14
|
+
export declare const COMPILED_TYPE_ROLES: readonly ["display", "heading-section", "heading-item", "body", "eyebrow"];
|
|
15
|
+
export declare const COPY_DENSITY_VALUES: readonly ["standard", "sparse"];
|
|
16
|
+
export declare const CORNERS_VALUES: readonly ["rounded", "square"];
|
|
17
|
+
export declare const CSS_LENGTH_REGEX: RegExp;
|
|
18
|
+
export declare const DARK_INK_VALUES: readonly ["fg", "accent"];
|
|
19
|
+
export declare const DECK_ANCHORS_VALUES: readonly ["prefixed", "bare"];
|
|
20
|
+
export declare const DECK_GROUNDS_MAX = 20;
|
|
21
|
+
export declare const DECK_GROUND_VALUES: readonly ["none", "gray-100", "wash", "wash-secondary", "gradient-brand", "gradient-dark", "solid-dark"];
|
|
22
|
+
export declare const DESCRIPTION_MAX = 400;
|
|
23
|
+
export declare const DIAL_MAP_MAX = 24;
|
|
24
|
+
export declare const DIAL_NAME_REGEX: RegExp;
|
|
25
|
+
export declare const EYEBROW_CASE_VALUES: readonly ["upper", "sentence"];
|
|
26
|
+
export declare const FIGURES_VALUES: readonly ["platform", "display"];
|
|
27
|
+
export declare const FONT_FAMILY_REGEX: RegExp;
|
|
28
|
+
export declare const FONT_SIZE_MOBILE_ROLES: readonly ["display", "heading-section", "heading-item"];
|
|
29
|
+
export declare const FONT_SOURCE_ROLES: readonly ["display", "body"];
|
|
30
|
+
export declare const FONT_SOURCE_VALUES: readonly ["google"];
|
|
31
|
+
export declare const FONT_STACK_LENGTH_MAX = 512;
|
|
32
|
+
export declare const FONT_STACK_MAX = 8;
|
|
33
|
+
export declare const FOOTER_STYLES: readonly ["columns", "centered", "closing", "none"];
|
|
34
|
+
export declare const GOOGLE_FAMILY_REGEX: RegExp;
|
|
35
|
+
export declare const GROUND_HEX_REGEX: RegExp;
|
|
36
|
+
export declare const HEADER_STYLES: readonly ["full", "mark-only", "bare", "none"];
|
|
37
|
+
export declare const HOME_VALUES: readonly ["default", "deck"];
|
|
38
|
+
export declare const INNER_PAGES_VALUES: readonly ["default", "bare"];
|
|
39
|
+
export declare const LAYOUT_OPTIONAL_KEYS: readonly ["deckGrounds", "innerPages", "deckPresentation", "deckAnchors", "chromeStyle", "closingFooterPaths"];
|
|
40
|
+
export declare const LAYOUT_REQUIRED_KEYS: readonly ["nav", "footer", "announcementBanner", "home"];
|
|
41
|
+
export declare const LINE_HEIGHT_MOBILE_ROLES: readonly ["display"];
|
|
42
|
+
export declare const LOOK_FIELDS_PER_SECTION_MAX = 20;
|
|
43
|
+
export declare const NAME_MAX = 80;
|
|
44
|
+
export declare const PLACEHOLDERS_VALUES: readonly ["outline", "fill"];
|
|
45
|
+
export declare const SECTIONS_PER_PAGE_MAX = 20;
|
|
46
|
+
export declare const SECTION_NAME_REGEX: RegExp;
|
|
47
|
+
export declare const SECTION_PAGE_TYPES: readonly ["HomePage", "AboutPage", "Product", "Service", "ContactPage", "FAQPage", "ProductsList", "ServicesList", "ProjectsList", "Project", "TermsPage", "PrivacyPage", "WorkingAgreementPage", "GlossaryList", "TeamList", "TeamMember", "Person", "Partner", "PartnersList", "UseCasesList", "FeaturesList", "PortfolioList", "ResourceDetail", "ResourcesHub", "DownloadsList", "Integration", "IntegrationsList", "ClientsList", "TestimonialsList", "HowTo", "TechArticle", "Whitepaper", "SoftwareProduct", "JobPosting", "CareersList", "CaseStudy", "CaseStudiesList", "Course", "CoursesList", "Event", "EventsList", "BlogPosting", "BlogList", "BookCall", "NewsletterSignup", "DemoRequest", "TrialSignup", "Waitlist", "Assessment", "Calculator", "CampaignLP", "LocationsList", "Location", "ServiceAreaPage", "DocsList", "DocsDetail", "LandingPage", "UseCase", "Feature", "PortfolioItem", "Pricing", "ThankYouPage", "ReportPage", "PurchasePolicyPage", "ComparisonPage", "ComparisonsList", "ReportsList", "TemplatePage", "TemplatesList"];
|
|
48
|
+
export declare const SECTION_PAGE_TYPES_MAX = 40;
|
|
49
|
+
export declare const SECTION_TOKEN_REGEX: RegExp;
|
|
50
|
+
export declare const SETTINGS_KEYS: readonly ["name", "version", "description", "colors", "typography", "rounded", "spacing", "layout", "treatments", "sections", "copy"];
|
|
51
|
+
export declare const SETTINGS_REQUIRED_KEYS: readonly ["name", "version", "description", "colors", "typography", "rounded", "spacing", "layout"];
|
|
52
|
+
export declare const SETTINGS_VERSION_MAX = 2147483647;
|
|
53
|
+
export declare const TYPE_SCALE_VALUES: readonly ["platform", "design"];
|
|
54
|
+
export declare const TYPE_SIZE_REGEX: RegExp;
|
|
55
|
+
export declare const TYPOGRAPHY_ROLES_MAX = 12;
|
|
56
|
+
export declare const TYPOGRAPHY_ROLE_KEYS: readonly ["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "fontSource", "lineHeightMobile", "fontSizeMobile"];
|