create-ailk 0.47.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 +192 -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 +807 -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 +42 -41
- package/dist/site-chrome.js +51 -70
- package/dist/site-fonts.d.ts +14 -14
- package/dist/site-fonts.js +9 -4
- 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/look-hub.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hub design record over HTTP, for the scaffold's seed and
|
|
3
|
+
* `apply-design` (#12477 D4, D5, spec
|
|
4
|
+
* docs/specs/12477-retire-the-generated-look-files-spec.md): the member read
|
|
5
|
+
* and write `GET`/`PUT /v1/workspaces/<id>/design` (#12470), with the agent
|
|
6
|
+
* key.
|
|
7
|
+
*
|
|
8
|
+
* The transport is the importer's (#10203 D5): the key travels only as
|
|
9
|
+
* `authorization: Bearer <key>`, never across a redirect (`redirect:
|
|
10
|
+
* "manual"`, and a 3xx answer is a failure), and is never printed. Of an
|
|
11
|
+
* answer's text only its `code` and its first refused path are ever printed,
|
|
12
|
+
* each only in a fixed grammar, else `<unexpected>`.
|
|
13
|
+
*
|
|
14
|
+
* Pure module: no `import.meta.url`, so jest imports it directly.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { removeThemeBlock } from "./design-scaffold.js";
|
|
19
|
+
import { SITE_CHROME_PATH } from "./site-chrome.js";
|
|
20
|
+
import { SITE_FONTS_PATH } from "./site-fonts.js";
|
|
21
|
+
/** How long one hub request may take. */
|
|
22
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
23
|
+
/** A response `code` is printed only in this form. */
|
|
24
|
+
const PRINTABLE_CODE_RE = /^[a-z_]{1,40}$/;
|
|
25
|
+
/** A refused path is printed only in this form. */
|
|
26
|
+
const PRINTABLE_PATH_RE = /^design(\.[A-Za-z0-9_-]{1,40}){0,8}$/;
|
|
27
|
+
/** `value` when it matches `re`, else `<unexpected>`. */
|
|
28
|
+
export function printable(value, re) {
|
|
29
|
+
return typeof value === "string" && re.test(value) ? value : "<unexpected>";
|
|
30
|
+
}
|
|
31
|
+
function isPlainObject(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One request to `url` with the agent key, `redirect: "manual"`. Never
|
|
36
|
+
* throws for a network failure (status 0) or a body that is not JSON.
|
|
37
|
+
*/
|
|
38
|
+
export async function hubRequest(fetchImpl, url, apiKey, init = { method: "GET" }) {
|
|
39
|
+
let res;
|
|
40
|
+
try {
|
|
41
|
+
res = await fetchImpl(url, {
|
|
42
|
+
method: init.method,
|
|
43
|
+
headers: {
|
|
44
|
+
accept: "application/json",
|
|
45
|
+
authorization: `Bearer ${apiKey}`,
|
|
46
|
+
...(init.method === "PUT" && { "content-type": "application/json" }),
|
|
47
|
+
},
|
|
48
|
+
...(init.method === "PUT" && { body: JSON.stringify(init.body) }),
|
|
49
|
+
// A redirect would re-send the key, and the body, to another URL.
|
|
50
|
+
redirect: "manual",
|
|
51
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return { status: 0, ok: false, data: undefined, code: undefined, path: undefined };
|
|
56
|
+
}
|
|
57
|
+
let body;
|
|
58
|
+
try {
|
|
59
|
+
body = await res.json();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
body = undefined;
|
|
63
|
+
}
|
|
64
|
+
const ok = isPlainObject(body) && body["ok"] === true && res.status === 200;
|
|
65
|
+
const error = isPlainObject(body) && isPlainObject(body["error"]) ? body["error"] : undefined;
|
|
66
|
+
const details = error !== undefined && isPlainObject(error["details"]) ? error["details"] : undefined;
|
|
67
|
+
const issues = details !== undefined && Array.isArray(details["issues"]) ? details["issues"] : [];
|
|
68
|
+
const firstIssue = issues[0];
|
|
69
|
+
return {
|
|
70
|
+
status: res.status,
|
|
71
|
+
ok,
|
|
72
|
+
data: ok && isPlainObject(body) ? body["data"] : undefined,
|
|
73
|
+
code: error !== undefined ? printable(error["code"], PRINTABLE_CODE_RE) : undefined,
|
|
74
|
+
path: isPlainObject(firstIssue) ? printable(firstIssue["path"], PRINTABLE_PATH_RE) : undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** What a failed answer prints: `400 <code> at <path>`, `<status> <code>`, or the status alone ("not sent" for no answer). */
|
|
78
|
+
export function describeAnswer(answer) {
|
|
79
|
+
if (answer.status === 0)
|
|
80
|
+
return "not sent";
|
|
81
|
+
if (answer.status === 400)
|
|
82
|
+
return `400 ${answer.code ?? "<unexpected>"} at ${answer.path ?? "<unexpected>"}`;
|
|
83
|
+
return answer.code !== undefined ? `${answer.status} ${answer.code}` : String(answer.status);
|
|
84
|
+
}
|
|
85
|
+
/** The member design route for `workspaceId` at `origin`. */
|
|
86
|
+
export function designUrl(origin, workspaceId) {
|
|
87
|
+
return `${origin}/v1/workspaces/${encodeURIComponent(workspaceId)}/design`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A design or navigation answer's `version`: an integer, `null` (none
|
|
91
|
+
* stored), or `undefined` (neither — not such an answer, or not `ok`).
|
|
92
|
+
*/
|
|
93
|
+
export function storedVersion(answer) {
|
|
94
|
+
if (!answer.ok || !isPlainObject(answer.data))
|
|
95
|
+
return undefined;
|
|
96
|
+
const version = answer.data["version"];
|
|
97
|
+
if (version === null)
|
|
98
|
+
return null;
|
|
99
|
+
return Number.isInteger(version) ? version : undefined;
|
|
100
|
+
}
|
|
101
|
+
// ── The retired look files ──────────────────────────────────────────────────
|
|
102
|
+
/** The site's `_site.mdx`, where a `theme:` block once held its colours. */
|
|
103
|
+
export const SITE_MDX_PATH = "content/_site.mdx";
|
|
104
|
+
/** `text` holds a frontmatter `theme:` key, in any form. */
|
|
105
|
+
export function carriesThemeKey(text) {
|
|
106
|
+
const lines = text.split("\n");
|
|
107
|
+
if (lines[0] !== "---")
|
|
108
|
+
return false;
|
|
109
|
+
for (let i = 1; i < lines.length && lines[i] !== "---"; i += 1) {
|
|
110
|
+
if (/^theme\s*:/.test(lines[i]))
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/** `text`'s `theme:` key is the block `removeThemeBlock` removes. */
|
|
116
|
+
export function themeBlockRemovable(text, file) {
|
|
117
|
+
return removeThemeBlock(text, file) !== text;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The retired look sources `siteDir` still carries (#12477): `site-chrome.ts`,
|
|
121
|
+
* `site-fonts.ts` and a `theme:` key in `content/_site.mdx`, as site-relative
|
|
122
|
+
* paths. Empty for a site on its hub record.
|
|
123
|
+
*/
|
|
124
|
+
export function retiredLookSources(siteDir) {
|
|
125
|
+
const found = [SITE_CHROME_PATH, SITE_FONTS_PATH].filter((path) => existsSync(join(siteDir, path)));
|
|
126
|
+
const siteMdx = join(siteDir, SITE_MDX_PATH);
|
|
127
|
+
if (existsSync(siteMdx) && carriesThemeKey(readFileSync(siteMdx, "utf8")))
|
|
128
|
+
found.push(SITE_MDX_PATH);
|
|
129
|
+
return found;
|
|
130
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ResolvedDesign } from "./design-scaffold.js";
|
|
2
|
+
import { type TemplateLayout } from "./site-chrome.js";
|
|
3
|
+
/** The part of #12470's record (`siteDesignSchema`) this writer emits. */
|
|
4
|
+
export interface LookRecord {
|
|
5
|
+
version: "1";
|
|
6
|
+
from: {
|
|
7
|
+
look: string;
|
|
8
|
+
version: string;
|
|
9
|
+
} | null;
|
|
10
|
+
changes?: {
|
|
11
|
+
layout: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
settings?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/** What a look record is built from: the resolved design and the starter's own `layout` block. */
|
|
16
|
+
export interface LookInputs {
|
|
17
|
+
resolved: ResolvedDesign;
|
|
18
|
+
templateLayout: TemplateLayout | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The layout knobs `templateLayout` changes over the look's own: each key
|
|
22
|
+
* whose resolved value differs from the look's resolved value, and each key
|
|
23
|
+
* the look resolves that the starter's resolution drops, as `null` (a merge
|
|
24
|
+
* patch removal). Empty when the starter changes nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function layoutChanges(templateLayout: TemplateLayout | undefined, lookLayout: TemplateLayout): Record<string, unknown>;
|
|
27
|
+
/** The record a site wearing `resolved` under its starter's `templateLayout` starts with (D3). */
|
|
28
|
+
export declare function lookRecordFor({ resolved, templateLayout }: LookInputs): LookRecord;
|
|
29
|
+
/**
|
|
30
|
+
* A scaffolded site's look inputs: the design its manifest records and its
|
|
31
|
+
* starter's `layout` block. A shipped look resolves from `designsDir`; any
|
|
32
|
+
* other from the site's own `design.yaml`, the copy the scaffold wrote.
|
|
33
|
+
* `undefined` when the site has no manifest or the manifest records no design.
|
|
34
|
+
*/
|
|
35
|
+
export declare function readLookInputs(targetDir: string, designsDir: string): LookInputs | undefined;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The design record a site starts with (#12477 D3, spec
|
|
3
|
+
* docs/specs/12477-retire-the-generated-look-files-spec.md).
|
|
4
|
+
*
|
|
5
|
+
* A site's look lives in its hub design record (#12470), never in its own
|
|
6
|
+
* files. This module builds the record a scaffold's seed (D4) and
|
|
7
|
+
* `apply-design` (D5) write from the design and starter a site was made
|
|
8
|
+
* with:
|
|
9
|
+
*
|
|
10
|
+
* - a **library look** is named by `from` with its version, and the starter's
|
|
11
|
+
* own layout overrides ride as `changes.layout` — exactly what the starter
|
|
12
|
+
* changed, so the hub keeps it when a newer version of the look is taken;
|
|
13
|
+
* - **any other design** (a directory of its own) is a look of the
|
|
14
|
+
* workspace's own: `from: null` and its whole settings.
|
|
15
|
+
*
|
|
16
|
+
* `create-ailk` takes no `@working-theory/*` runtime dependency, so the
|
|
17
|
+
* record's shape is restated here as `LookRecord`; its suite parses every
|
|
18
|
+
* record with `@working-theory/validation`'s `siteDesignSchema`, so a drift
|
|
19
|
+
* fails there.
|
|
20
|
+
*
|
|
21
|
+
* Pure module: no `import.meta.url`, so jest can import it directly.
|
|
22
|
+
*/
|
|
23
|
+
import { isDeepStrictEqual } from "node:util";
|
|
24
|
+
import { shippedDesigns } from "./design-names.js";
|
|
25
|
+
import { readDesignSettings } from "./design-package.js";
|
|
26
|
+
import { resolveDesign } from "./design-scaffold.js";
|
|
27
|
+
import { resolveSiteChrome } from "./site-chrome.js";
|
|
28
|
+
import { readSiteRoster } from "./site-roster.js";
|
|
29
|
+
/**
|
|
30
|
+
* The layout knobs `templateLayout` changes over the look's own: each key
|
|
31
|
+
* whose resolved value differs from the look's resolved value, and each key
|
|
32
|
+
* the look resolves that the starter's resolution drops, as `null` (a merge
|
|
33
|
+
* patch removal). Empty when the starter changes nothing.
|
|
34
|
+
*/
|
|
35
|
+
export function layoutChanges(templateLayout, lookLayout) {
|
|
36
|
+
const withTemplate = { ...resolveSiteChrome(templateLayout, lookLayout) };
|
|
37
|
+
const lookOnly = { ...resolveSiteChrome(undefined, lookLayout) };
|
|
38
|
+
const changes = {};
|
|
39
|
+
for (const [key, value] of Object.entries(withTemplate)) {
|
|
40
|
+
if (!isDeepStrictEqual(value, lookOnly[key]))
|
|
41
|
+
changes[key] = value;
|
|
42
|
+
}
|
|
43
|
+
for (const key of Object.keys(lookOnly)) {
|
|
44
|
+
if (!Object.hasOwn(withTemplate, key))
|
|
45
|
+
changes[key] = null;
|
|
46
|
+
}
|
|
47
|
+
return changes;
|
|
48
|
+
}
|
|
49
|
+
/** The record a site wearing `resolved` under its starter's `templateLayout` starts with (D3). */
|
|
50
|
+
export function lookRecordFor({ resolved, templateLayout }) {
|
|
51
|
+
if (shippedDesigns().includes(resolved.recorded)) {
|
|
52
|
+
const layout = layoutChanges(templateLayout, resolved.pkg.layout);
|
|
53
|
+
return {
|
|
54
|
+
version: "1",
|
|
55
|
+
from: { look: resolved.recorded, version: String(resolved.pkg.version) },
|
|
56
|
+
...(Object.keys(layout).length > 0 && { changes: { layout } }),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
version: "1",
|
|
61
|
+
from: null,
|
|
62
|
+
settings: {
|
|
63
|
+
...readDesignSettings(resolved.dir),
|
|
64
|
+
layout: resolveSiteChrome(templateLayout, resolved.pkg.layout),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A scaffolded site's look inputs: the design its manifest records and its
|
|
70
|
+
* starter's `layout` block. A shipped look resolves from `designsDir`; any
|
|
71
|
+
* other from the site's own `design.yaml`, the copy the scaffold wrote.
|
|
72
|
+
* `undefined` when the site has no manifest or the manifest records no design.
|
|
73
|
+
*/
|
|
74
|
+
export function readLookInputs(targetDir, designsDir) {
|
|
75
|
+
const roster = readSiteRoster(targetDir);
|
|
76
|
+
if (roster === undefined)
|
|
77
|
+
return undefined;
|
|
78
|
+
const design = roster.doc["design"];
|
|
79
|
+
if (typeof design !== "string" || design === "")
|
|
80
|
+
return undefined;
|
|
81
|
+
const resolved = shippedDesigns().includes(design)
|
|
82
|
+
? resolveDesign(design, { designsDir })
|
|
83
|
+
: resolveDesign(targetDir, { designsDir });
|
|
84
|
+
return { resolved, templateLayout: roster.template.layout };
|
|
85
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** The folder a look's samples live in, and their manifest inside it. */
|
|
2
|
+
export declare const SAMPLES_DIR = "samples";
|
|
3
|
+
export declare const SAMPLES_MANIFEST = "samples.json";
|
|
4
|
+
/** The four members a fill writes (SEC-12472-7), and nothing else. */
|
|
5
|
+
export declare const SAMPLE_FILL_MEMBERS: readonly ["src", "alt", "width", "height"];
|
|
6
|
+
/** D3 — an image object is a look's sample fill when its `src` is under `/look/` and its `alt` starts `Sample picture: `. */
|
|
7
|
+
export declare function isSampleFill(src: string, alt: string): boolean;
|
|
8
|
+
/** Thrown by `readLookSamples` and `fillLookSamples` before any write, naming the file, field or sample at fault. */
|
|
9
|
+
export declare class LookSamplesError extends Error {
|
|
10
|
+
readonly subject: string;
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
constructor(subject: string, reason: string);
|
|
13
|
+
}
|
|
14
|
+
/** One checked sample: its manifest entry and the bytes `readLookSamples` read and checked. */
|
|
15
|
+
export interface LookSample {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly file: string;
|
|
18
|
+
readonly alt: string;
|
|
19
|
+
readonly width: number;
|
|
20
|
+
readonly height: number;
|
|
21
|
+
readonly style: string;
|
|
22
|
+
readonly review: string;
|
|
23
|
+
readonly bytes: Buffer;
|
|
24
|
+
}
|
|
25
|
+
export interface LookSamples {
|
|
26
|
+
/** The look's name: its LOOK.md's accepted `started_from`. */
|
|
27
|
+
readonly look: string;
|
|
28
|
+
readonly samples: readonly LookSample[];
|
|
29
|
+
}
|
|
30
|
+
/** D2 — a key's file stem: lower case, `[]` removed, every `:` or `.` a `-` (`hero:darkImage` → `hero-darkimage`). */
|
|
31
|
+
export declare function sampleStem(key: string): string;
|
|
32
|
+
/** D2 — a sample's key in a hub: `look/<look>/<stem>`, the address a LOOK.md's `asset:` tokens name. */
|
|
33
|
+
export declare function sampleAssetKey(look: string, key: string): string;
|
|
34
|
+
/** The Clarifications' rule: the design's directory has an entry named `samples`, of any type, a dangling symlink included. */
|
|
35
|
+
export declare function hasSamplesEntry(designDir: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* D3 — a design's samples, checked for form, or undefined when its directory
|
|
38
|
+
* has no `samples` entry. The look's name is its LOOK.md's `started_from`, as
|
|
39
|
+
* `acceptedStartedFrom` accepts it (`designsDir` admits a byte-identical copy
|
|
40
|
+
* of a shipped look under another folder name; without it, only the folder's
|
|
41
|
+
* own name). Every sample's bytes are read and checked here; a sample's
|
|
42
|
+
* `style` naming a LOOK.md style is the root test's to check (D7).
|
|
43
|
+
*
|
|
44
|
+
* @throws LookSamplesError naming the file, field or sample, before anything is written.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readLookSamples(designDir: string, opts?: {
|
|
47
|
+
designsDir?: string;
|
|
48
|
+
}): LookSamples | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* One page's text with every sample filled, or undefined when nothing changed.
|
|
51
|
+
* A page the preset locator cannot read is left whole, even part-filled: the
|
|
52
|
+
* design leg's box check names any slot it leaves.
|
|
53
|
+
*/
|
|
54
|
+
export declare function fillPageText(text: string, file: string, look: string, samples: readonly LookSample[]): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* D3 steps 1–3 — copy a look's checked samples into the site and fill the
|
|
57
|
+
* empty image slots of its seeded pages under `content/`. Every page edit is
|
|
58
|
+
* planned and the destination checked before the first write: the scaffold
|
|
59
|
+
* refuses, writing nothing, when `apps/web/public/look` (or a folder on the
|
|
60
|
+
* way to it) is a symlink, or `public/look` already exists (SEC-12472-5).
|
|
61
|
+
* Nothing under `public/` is removed; each sample is created with `wx`.
|
|
62
|
+
*
|
|
63
|
+
* @returns the site-relative paths written.
|
|
64
|
+
* @throws LookSamplesError before any write.
|
|
65
|
+
*/
|
|
66
|
+
export declare function fillLookSamples(siteDir: string, look: string, samples: readonly LookSample[]): string[];
|