@iksnerd/blazon 0.1.0 → 0.2.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 +14 -19
- package/dist/chunks/{site-builder-vpzUWoiA.js → site-builder-BtGOvjBC.js} +1836 -2111
- package/dist/cli/commands/tokens.d.ts +4 -0
- package/dist/cli/commands/tokens.d.ts.map +1 -1
- package/dist/cli/handlers/brand.d.ts +1 -1
- package/dist/cli/handlers/index.d.ts +2 -2
- package/dist/cli/index.js +915 -941
- package/dist/core/brand/export.d.ts +2 -9
- package/dist/core/brand/export.d.ts.map +1 -1
- package/dist/core/brand/schema.d.ts +0 -58
- package/dist/core/brand/schema.d.ts.map +1 -1
- package/dist/core/brand-theme.d.ts +0 -2
- package/dist/core/brand-theme.d.ts.map +1 -1
- package/dist/core/checker/catalogue.d.ts +18 -2
- package/dist/core/checker/catalogue.d.ts.map +1 -1
- package/dist/core/checker/contrast.d.ts +1 -1
- package/dist/core/checker/variables.d.ts +2 -2
- package/dist/core/checker/variables.d.ts.map +1 -1
- package/dist/core/config/removed-keys.d.ts +6 -0
- package/dist/core/config/removed-keys.d.ts.map +1 -0
- package/dist/core/config/validate.d.ts +1 -1
- package/dist/core/config/validate.d.ts.map +1 -1
- package/dist/core/docs/directives.d.ts +9 -0
- package/dist/core/docs/directives.d.ts.map +1 -1
- package/dist/core/docs/parser.d.ts.map +1 -1
- package/dist/core/emit.d.ts +1 -3
- package/dist/core/emit.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/operations/list.d.ts.map +1 -1
- package/dist/core/plugin-name.d.ts +1 -1
- package/dist/core/read/token.d.ts +1 -6
- package/dist/core/read/token.d.ts.map +1 -1
- package/dist/core/tokens/walk.d.ts.map +1 -1
- package/dist/index.js +33 -33
- package/dist/plugins/roles/integrate.d.ts +5 -2
- package/dist/plugins/roles/integrate.d.ts.map +1 -1
- package/dist/plugins/roles/roles.d.ts +9 -2
- package/dist/plugins/roles/roles.d.ts.map +1 -1
- package/dist/plugins/wire/profile.d.ts +5 -0
- package/dist/plugins/wire/profile.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/theme.d.ts +0 -3
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/ui/assets/{index-BdbihVvH.js → index-CLKH0m9J.js} +45 -47
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/plugins/blazon.brand-deck/bin/blazon-blazon.brand-deck./360/237/224/214 +24 -2
- package/plugins/blazon.copy/bin/blazon-blazon.copy./360/237/224/214 +25 -3
- package/plugins/blazon.favicons/bin/blazon-blazon.favicons./360/237/224/214 +26 -3
- package/plugins/blazon.logo-geometry/bin/blazon-blazon.logo-geometry./360/237/224/214 +37 -8
- package/plugins/blazon.logo-kit/bin/blazon-blazon.logo-kit./360/237/224/214 +37 -8
- package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +37 -8
- package/plugins/blazon.platform-tokens/bin/blazon-blazon.platform-tokens./360/237/224/214 +37 -9
- package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +37 -8
- package/plugins/blazon.print-book/README.md +3 -1
- package/plugins/blazon.print-book/bin/blazon-blazon.print-book./360/237/224/214 +43 -8
- package/plugins/blazon.shadcn/README.md +27 -0
- package/plugins/blazon.shadcn/bin/blazon-blazon.shadcn./360/237/224/214 +8273 -0
- package/plugins/blazon.shadcn/package.json +3 -0
- package/plugins/blazon.social-cards/bin/blazon-blazon.social-cards./360/237/224/214 +37 -8
- package/plugins/blazon.tailwind/README.md +23 -0
- package/plugins/blazon.tailwind/bin/blazon-blazon.tailwind./360/237/224/214 +420 -0
- package/plugins/blazon.tailwind/package.json +3 -0
- package/plugins/shipped.lock +24 -10
- package/template/AGENTS.md +1 -1
- package/template/blazon.json +0 -10
- package/template/docs/01-principles.md +1 -1
- package/template/docs/12-web.md +2 -2
- package/dist/core/tokens/formatters/tailwind.d.ts +0 -37
- package/dist/core/tokens/formatters/tailwind.d.ts.map +0 -1
- package/dist/core/tokens/shadcn.d.ts +0 -43
- package/dist/core/tokens/shadcn.d.ts.map +0 -1
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Brand Book</title>
|
|
7
7
|
<link rel="icon" href="data:," />
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-CLKH0m9J.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-DluSqfla.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -34,6 +34,23 @@ var findingFor = (name) => (code, severity, path, message) => ({
|
|
|
34
34
|
path,
|
|
35
35
|
message
|
|
36
36
|
});
|
|
37
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
38
|
+
var REQUEST_VERSIONS = {
|
|
39
|
+
check: 1,
|
|
40
|
+
build: 2
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
44
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
45
|
+
*/
|
|
46
|
+
var NeedsSite = class extends Cannot {};
|
|
47
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
48
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
49
|
+
code: `${name}/needs-site`,
|
|
50
|
+
severity: "info",
|
|
51
|
+
path: "site_dir",
|
|
52
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
53
|
+
}] });
|
|
37
54
|
/** The plugin's name, which blazon's config names it by, and the prefix of its finding codes */
|
|
38
55
|
var NAME = "blazon.brand-deck";
|
|
39
56
|
var MANIFEST = {
|
|
@@ -61,8 +78,9 @@ function jobFor(text) {
|
|
|
61
78
|
}
|
|
62
79
|
if (typeof request !== "object" || request === null || Array.isArray(request)) throw new Cannot("the request is not a JSON object");
|
|
63
80
|
const asked = request;
|
|
64
|
-
if (asked.v !==
|
|
81
|
+
if (asked.v !== REQUEST_VERSIONS.build) throw new Cannot(`this plugin speaks version ${REQUEST_VERSIONS.build} of the request`);
|
|
65
82
|
if (asked.type !== "build") throw new Cannot("this plugin fills the build role");
|
|
83
|
+
if (asked.site_dir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
66
84
|
for (const field of ["site_dir", "out_dir"]) if (!isFolder(asked[field])) throw new Cannot(`${field} must name a directory that exists`);
|
|
67
85
|
return {
|
|
68
86
|
siteDir: asked.site_dir,
|
|
@@ -83,7 +101,7 @@ var objects = (value) => Array.isArray(value) ? value.filter(isObject) : [];
|
|
|
83
101
|
/** The brand when the request holds a blazon brand of a version this deck reads; Cannot otherwise. `source` only names it in the message. */
|
|
84
102
|
function readBrand(raw, source = "the brand in the request") {
|
|
85
103
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`${source} is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not '${FORMAT}'`);
|
|
86
|
-
if (raw.version !==
|
|
104
|
+
if (raw.version !== 2) throw new Cannot(`${source} is version ${shown(raw.version)}; this reader understands version 2`);
|
|
87
105
|
const brand = isObject(raw.brand) ? raw.brand : {};
|
|
88
106
|
const theme = isObject(raw.theme) ? raw.theme : {};
|
|
89
107
|
return {
|
|
@@ -2685,6 +2703,10 @@ async function main(argv) {
|
|
|
2685
2703
|
process.stdout.write(`${JSON.stringify(await build(node_fs.default.readFileSync(0, "utf-8")))}\n`);
|
|
2686
2704
|
return 0;
|
|
2687
2705
|
} catch (error) {
|
|
2706
|
+
if (error instanceof NeedsSite) {
|
|
2707
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(NAME, error))}\n`);
|
|
2708
|
+
return 0;
|
|
2709
|
+
}
|
|
2688
2710
|
const reason = error instanceof Cannot || error instanceof DeckError ? error.message : `the browser could not draw the deck: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
2689
2711
|
process.stdout.write(`${reason}\n`);
|
|
2690
2712
|
return 2;
|
|
@@ -71,10 +71,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
71
71
|
function requireBrand(raw) {
|
|
72
72
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
73
73
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
74
|
-
if (raw.version !==
|
|
74
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
75
75
|
return raw;
|
|
76
76
|
}
|
|
77
|
-
/** The request
|
|
77
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
78
|
+
var REQUEST_VERSIONS = {
|
|
79
|
+
check: 1,
|
|
80
|
+
build: 2
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
84
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
85
|
+
*/
|
|
86
|
+
var NeedsSite = class extends Cannot {};
|
|
87
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
88
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
89
|
+
code: `${name}/needs-site`,
|
|
90
|
+
severity: "info",
|
|
91
|
+
path: "site_dir",
|
|
92
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
93
|
+
}] });
|
|
94
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
78
95
|
function readRequest(text) {
|
|
79
96
|
let request;
|
|
80
97
|
try {
|
|
@@ -83,7 +100,8 @@ function readRequest(text) {
|
|
|
83
100
|
throw new Cannot("the request is not JSON");
|
|
84
101
|
}
|
|
85
102
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
86
|
-
|
|
103
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
104
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
87
105
|
return request;
|
|
88
106
|
}
|
|
89
107
|
/**
|
|
@@ -105,6 +123,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
105
123
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
106
124
|
return 0;
|
|
107
125
|
} catch (error) {
|
|
126
|
+
if (error instanceof NeedsSite) {
|
|
127
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
108
130
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
109
131
|
process.stdout.write(`${reason}\n`);
|
|
110
132
|
return 2;
|
|
@@ -88,10 +88,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
88
88
|
function requireBrand(raw) {
|
|
89
89
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
90
90
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
91
|
-
if (raw.version !==
|
|
91
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
92
92
|
return raw;
|
|
93
93
|
}
|
|
94
|
-
/** The request
|
|
94
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
95
|
+
var REQUEST_VERSIONS = {
|
|
96
|
+
check: 1,
|
|
97
|
+
build: 2
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
101
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
102
|
+
*/
|
|
103
|
+
var NeedsSite = class extends Cannot {};
|
|
104
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
105
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
106
|
+
code: `${name}/needs-site`,
|
|
107
|
+
severity: "info",
|
|
108
|
+
path: "site_dir",
|
|
109
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
110
|
+
}] });
|
|
111
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
95
112
|
function readRequest(text) {
|
|
96
113
|
let request;
|
|
97
114
|
try {
|
|
@@ -100,7 +117,8 @@ function readRequest(text) {
|
|
|
100
117
|
throw new Cannot("the request is not JSON");
|
|
101
118
|
}
|
|
102
119
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
103
|
-
|
|
120
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
121
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
104
122
|
return request;
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
@@ -122,6 +140,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
122
140
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
123
141
|
return 0;
|
|
124
142
|
} catch (error) {
|
|
143
|
+
if (error instanceof NeedsSite) {
|
|
144
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
125
147
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
126
148
|
process.stdout.write(`${reason}\n`);
|
|
127
149
|
return 2;
|
|
@@ -7987,6 +8009,7 @@ function requestFrom(text) {
|
|
|
7987
8009
|
if (!isObject(options)) throw new OptionError("options must be an object");
|
|
7988
8010
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
7989
8011
|
if (request.type === "build") {
|
|
8012
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
7990
8013
|
if (typeof siteDir !== "string" || !node_fs.default.statSync(siteDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("site_dir is not a folder");
|
|
7991
8014
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
7992
8015
|
}
|
|
@@ -73,10 +73,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
73
73
|
function requireBrand(raw) {
|
|
74
74
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
75
75
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
76
|
-
if (raw.version !==
|
|
76
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
77
77
|
return raw;
|
|
78
78
|
}
|
|
79
|
-
/** The request
|
|
79
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
80
|
+
var REQUEST_VERSIONS = {
|
|
81
|
+
check: 1,
|
|
82
|
+
build: 2
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
86
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
87
|
+
*/
|
|
88
|
+
var NeedsSite = class extends Cannot {};
|
|
89
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
90
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
91
|
+
code: `${name}/needs-site`,
|
|
92
|
+
severity: "info",
|
|
93
|
+
path: "site_dir",
|
|
94
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
95
|
+
}] });
|
|
96
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
80
97
|
function readRequest(text) {
|
|
81
98
|
let request;
|
|
82
99
|
try {
|
|
@@ -85,19 +102,27 @@ function readRequest(text) {
|
|
|
85
102
|
throw new Cannot("the request is not JSON");
|
|
86
103
|
}
|
|
87
104
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
88
|
-
|
|
105
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
106
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
89
107
|
return request;
|
|
90
108
|
}
|
|
91
|
-
|
|
92
|
-
function buildJob(text) {
|
|
109
|
+
function buildRequest(text, site) {
|
|
93
110
|
const request = readRequest(text);
|
|
94
111
|
if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
|
|
95
112
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
96
|
-
if (
|
|
113
|
+
if (site === "needed") {
|
|
114
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
115
|
+
if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
|
|
116
|
+
}
|
|
97
117
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
118
|
+
return request;
|
|
119
|
+
}
|
|
120
|
+
/** The build request in `text`, or Cannot with the reason: version 2, the build role, a site_dir with an index.html and an out_dir that is a folder. With no site_dir (`blazon tokens`) it is NeedsSite. The brand and options are not checked here. */
|
|
121
|
+
function buildJob(text) {
|
|
122
|
+
const request = buildRequest(text, "needed");
|
|
98
123
|
return {
|
|
99
|
-
siteDir,
|
|
100
|
-
outDir,
|
|
124
|
+
siteDir: request.site_dir,
|
|
125
|
+
outDir: request.out_dir,
|
|
101
126
|
brand: request.brand ?? {},
|
|
102
127
|
options: request.options ?? {}
|
|
103
128
|
};
|
|
@@ -121,6 +146,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
121
146
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
122
147
|
return 0;
|
|
123
148
|
} catch (error) {
|
|
149
|
+
if (error instanceof NeedsSite) {
|
|
150
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
124
153
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
125
154
|
process.stdout.write(`${reason}\n`);
|
|
126
155
|
return 2;
|
|
@@ -73,10 +73,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
73
73
|
function requireBrand(raw) {
|
|
74
74
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
75
75
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
76
|
-
if (raw.version !==
|
|
76
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
77
77
|
return raw;
|
|
78
78
|
}
|
|
79
|
-
/** The request
|
|
79
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
80
|
+
var REQUEST_VERSIONS = {
|
|
81
|
+
check: 1,
|
|
82
|
+
build: 2
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
86
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
87
|
+
*/
|
|
88
|
+
var NeedsSite = class extends Cannot {};
|
|
89
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
90
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
91
|
+
code: `${name}/needs-site`,
|
|
92
|
+
severity: "info",
|
|
93
|
+
path: "site_dir",
|
|
94
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
95
|
+
}] });
|
|
96
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
80
97
|
function readRequest(text) {
|
|
81
98
|
let request;
|
|
82
99
|
try {
|
|
@@ -85,19 +102,27 @@ function readRequest(text) {
|
|
|
85
102
|
throw new Cannot("the request is not JSON");
|
|
86
103
|
}
|
|
87
104
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
88
|
-
|
|
105
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
106
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
89
107
|
return request;
|
|
90
108
|
}
|
|
91
|
-
|
|
92
|
-
function buildJob(text) {
|
|
109
|
+
function buildRequest(text, site) {
|
|
93
110
|
const request = readRequest(text);
|
|
94
111
|
if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
|
|
95
112
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
96
|
-
if (
|
|
113
|
+
if (site === "needed") {
|
|
114
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
115
|
+
if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
|
|
116
|
+
}
|
|
97
117
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
118
|
+
return request;
|
|
119
|
+
}
|
|
120
|
+
/** The build request in `text`, or Cannot with the reason: version 2, the build role, a site_dir with an index.html and an out_dir that is a folder. With no site_dir (`blazon tokens`) it is NeedsSite. The brand and options are not checked here. */
|
|
121
|
+
function buildJob(text) {
|
|
122
|
+
const request = buildRequest(text, "needed");
|
|
98
123
|
return {
|
|
99
|
-
siteDir,
|
|
100
|
-
outDir,
|
|
124
|
+
siteDir: request.site_dir,
|
|
125
|
+
outDir: request.out_dir,
|
|
101
126
|
brand: request.brand ?? {},
|
|
102
127
|
options: request.options ?? {}
|
|
103
128
|
};
|
|
@@ -121,6 +146,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
121
146
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
122
147
|
return 0;
|
|
123
148
|
} catch (error) {
|
|
149
|
+
if (error instanceof NeedsSite) {
|
|
150
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
124
153
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
125
154
|
process.stdout.write(`${reason}\n`);
|
|
126
155
|
return 2;
|
|
@@ -72,10 +72,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
72
72
|
function requireBrand(raw) {
|
|
73
73
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
74
74
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
75
|
-
if (raw.version !==
|
|
75
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
76
76
|
return raw;
|
|
77
77
|
}
|
|
78
|
-
/** The request
|
|
78
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
79
|
+
var REQUEST_VERSIONS = {
|
|
80
|
+
check: 1,
|
|
81
|
+
build: 2
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
85
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
86
|
+
*/
|
|
87
|
+
var NeedsSite = class extends Cannot {};
|
|
88
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
89
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
90
|
+
code: `${name}/needs-site`,
|
|
91
|
+
severity: "info",
|
|
92
|
+
path: "site_dir",
|
|
93
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
94
|
+
}] });
|
|
95
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
79
96
|
function readRequest(text) {
|
|
80
97
|
let request;
|
|
81
98
|
try {
|
|
@@ -84,19 +101,27 @@ function readRequest(text) {
|
|
|
84
101
|
throw new Cannot("the request is not JSON");
|
|
85
102
|
}
|
|
86
103
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
87
|
-
|
|
104
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
105
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
88
106
|
return request;
|
|
89
107
|
}
|
|
90
|
-
|
|
91
|
-
function buildJob(text) {
|
|
108
|
+
function buildRequest(text, site) {
|
|
92
109
|
const request = readRequest(text);
|
|
93
110
|
if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
|
|
94
111
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
95
|
-
if (
|
|
112
|
+
if (site === "needed") {
|
|
113
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
114
|
+
if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
|
|
115
|
+
}
|
|
96
116
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
117
|
+
return request;
|
|
118
|
+
}
|
|
119
|
+
/** The build request in `text`, or Cannot with the reason: version 2, the build role, a site_dir with an index.html and an out_dir that is a folder. With no site_dir (`blazon tokens`) it is NeedsSite. The brand and options are not checked here. */
|
|
120
|
+
function buildJob(text) {
|
|
121
|
+
const request = buildRequest(text, "needed");
|
|
97
122
|
return {
|
|
98
|
-
siteDir,
|
|
99
|
-
outDir,
|
|
123
|
+
siteDir: request.site_dir,
|
|
124
|
+
outDir: request.out_dir,
|
|
100
125
|
brand: request.brand ?? {},
|
|
101
126
|
options: request.options ?? {}
|
|
102
127
|
};
|
|
@@ -120,6 +145,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
120
145
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
121
146
|
return 0;
|
|
122
147
|
} catch (error) {
|
|
148
|
+
if (error instanceof NeedsSite) {
|
|
149
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
123
152
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
124
153
|
process.stdout.write(`${reason}\n`);
|
|
125
154
|
return 2;
|
|
@@ -81,10 +81,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
81
81
|
function requireBrand(raw) {
|
|
82
82
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
83
83
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
84
|
-
if (raw.version !==
|
|
84
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
85
85
|
return raw;
|
|
86
86
|
}
|
|
87
|
-
/** The request
|
|
87
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
88
|
+
var REQUEST_VERSIONS = {
|
|
89
|
+
check: 1,
|
|
90
|
+
build: 2
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
94
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
95
|
+
*/
|
|
96
|
+
var NeedsSite = class extends Cannot {};
|
|
97
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
98
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
99
|
+
code: `${name}/needs-site`,
|
|
100
|
+
severity: "info",
|
|
101
|
+
path: "site_dir",
|
|
102
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
103
|
+
}] });
|
|
104
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
88
105
|
function readRequest(text) {
|
|
89
106
|
let request;
|
|
90
107
|
try {
|
|
@@ -93,19 +110,26 @@ function readRequest(text) {
|
|
|
93
110
|
throw new Cannot("the request is not JSON");
|
|
94
111
|
}
|
|
95
112
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
96
|
-
|
|
113
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
114
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
97
115
|
return request;
|
|
98
116
|
}
|
|
99
|
-
|
|
100
|
-
function buildJob(text) {
|
|
117
|
+
function buildRequest(text, site) {
|
|
101
118
|
const request = readRequest(text);
|
|
102
119
|
if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
|
|
103
120
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
104
|
-
if (
|
|
121
|
+
if (site === "needed") {
|
|
122
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
123
|
+
if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
|
|
124
|
+
}
|
|
105
125
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
126
|
+
return request;
|
|
127
|
+
}
|
|
128
|
+
/** The build request in `text` for a plugin that reads no site, or Cannot with the reason: version 2, the build role and an out_dir that is a folder. A site_dir, when there is one, is ignored. */
|
|
129
|
+
function tokensJob(text) {
|
|
130
|
+
const request = buildRequest(text, "unused");
|
|
106
131
|
return {
|
|
107
|
-
|
|
108
|
-
outDir,
|
|
132
|
+
outDir: request.out_dir,
|
|
109
133
|
brand: request.brand ?? {},
|
|
110
134
|
options: request.options ?? {}
|
|
111
135
|
};
|
|
@@ -129,6 +153,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
129
153
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
130
154
|
return 0;
|
|
131
155
|
} catch (error) {
|
|
156
|
+
if (error instanceof NeedsSite) {
|
|
157
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
132
160
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
133
161
|
process.stdout.write(`${reason}\n`);
|
|
134
162
|
return 2;
|
|
@@ -8217,7 +8245,7 @@ var MANIFEST = {
|
|
|
8217
8245
|
};
|
|
8218
8246
|
/** The job a build request asks for, or Cannot with the reason. The options are checked later, and wrong ones are findings. */
|
|
8219
8247
|
function jobFor(text) {
|
|
8220
|
-
const { outDir, brand, options } =
|
|
8248
|
+
const { outDir, brand, options } = tokensJob(text);
|
|
8221
8249
|
return {
|
|
8222
8250
|
outDir,
|
|
8223
8251
|
brand,
|
|
@@ -74,10 +74,27 @@ var isObject = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
74
74
|
function requireBrand(raw) {
|
|
75
75
|
const shown = (value) => JSON.stringify(value) ?? "nothing";
|
|
76
76
|
if (!isObject(raw) || raw.format !== "blazon-brand") throw new Cannot(`the brand in the request is not a blazon brand: its format is ${shown(isObject(raw) ? raw.format : void 0)}, not "blazon-brand"`);
|
|
77
|
-
if (raw.version !==
|
|
77
|
+
if (raw.version !== 2) throw new Cannot(`the brand in the request is version ${shown(raw.version)}; this reader understands version 2`);
|
|
78
78
|
return raw;
|
|
79
79
|
}
|
|
80
|
-
/** The request
|
|
80
|
+
/** The version of each request a plugin may get (RFC 0005 section 8): a check request is 1, a build request is 2 and may carry no `site_dir`. */
|
|
81
|
+
var REQUEST_VERSIONS = {
|
|
82
|
+
check: 1,
|
|
83
|
+
build: 2
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
|
|
87
|
+
* answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
|
|
88
|
+
*/
|
|
89
|
+
var NeedsSite = class extends Cannot {};
|
|
90
|
+
/** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
|
|
91
|
+
var skippedForNoSite = (name, error) => ({ findings: [{
|
|
92
|
+
code: `${name}/needs-site`,
|
|
93
|
+
severity: "info",
|
|
94
|
+
path: "site_dir",
|
|
95
|
+
message: `${error.message}. Nothing was written; blazon build runs it.`
|
|
96
|
+
}] });
|
|
97
|
+
/** The request as an object of the version its role speaks, or Cannot with the reason. Its role and folders are for the plugin to check. */
|
|
81
98
|
function readRequest(text) {
|
|
82
99
|
let request;
|
|
83
100
|
try {
|
|
@@ -86,19 +103,27 @@ function readRequest(text) {
|
|
|
86
103
|
throw new Cannot("the request is not JSON");
|
|
87
104
|
}
|
|
88
105
|
if (!isObject(request)) throw new Cannot("the request is not a JSON object");
|
|
89
|
-
|
|
106
|
+
const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
|
|
107
|
+
if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
|
|
90
108
|
return request;
|
|
91
109
|
}
|
|
92
|
-
|
|
93
|
-
function buildJob(text) {
|
|
110
|
+
function buildRequest(text, site) {
|
|
94
111
|
const request = readRequest(text);
|
|
95
112
|
if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
|
|
96
113
|
const { site_dir: siteDir, out_dir: outDir } = request;
|
|
97
|
-
if (
|
|
114
|
+
if (site === "needed") {
|
|
115
|
+
if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
|
|
116
|
+
if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
|
|
117
|
+
}
|
|
98
118
|
if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
|
|
119
|
+
return request;
|
|
120
|
+
}
|
|
121
|
+
/** The build request in `text`, or Cannot with the reason: version 2, the build role, a site_dir with an index.html and an out_dir that is a folder. With no site_dir (`blazon tokens`) it is NeedsSite. The brand and options are not checked here. */
|
|
122
|
+
function buildJob(text) {
|
|
123
|
+
const request = buildRequest(text, "needed");
|
|
99
124
|
return {
|
|
100
|
-
siteDir,
|
|
101
|
-
outDir,
|
|
125
|
+
siteDir: request.site_dir,
|
|
126
|
+
outDir: request.out_dir,
|
|
102
127
|
brand: request.brand ?? {},
|
|
103
128
|
options: request.options ?? {}
|
|
104
129
|
};
|
|
@@ -122,6 +147,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
|
|
|
122
147
|
process.stdout.write(`${JSON.stringify(bounded)}\n`);
|
|
123
148
|
return 0;
|
|
124
149
|
} catch (error) {
|
|
150
|
+
if (error instanceof NeedsSite) {
|
|
151
|
+
process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
125
154
|
const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
|
|
126
155
|
process.stdout.write(`${reason}\n`);
|
|
127
156
|
return 2;
|
|
@@ -17,7 +17,9 @@ A slide whose content is taller than a slide even drawn at half size is cut off
|
|
|
17
17
|
| `{ "preset": "reference" }` | `index.html#print/reference` | `brand-book-reference.pdf`, `.pptx` |
|
|
18
18
|
| `{ "pages": ["doc/logo", "tokens/colors"] }` | `index.html#print/pages=doc/logo,tokens/colors` | `brand-book-pages.pdf`, `.pptx` |
|
|
19
19
|
|
|
20
|
-
Two optional strings go with any of these: `title` (at most 120 characters) replaces the brand title in the cover heading and in the footers, and `subtitle` (at most 200) replaces the line under the cover heading. They reach the page as `?title=...&subtitle=...` after the hash, percent-encoded.
|
|
20
|
+
Two optional strings go with any of these: `title` (at most 120 characters) replaces the brand title in the cover heading and in the footers, and `subtitle` (at most 200) replaces the line under the cover heading. They reach the page as `?title=...&subtitle=...` after the hash, percent-encoded.
|
|
21
|
+
|
|
22
|
+
One more option, `layout`, is `"compact"` (the default) or `"roomy"`. `compact` lets a figure share a slide by drawing its pictures down to 60% of their height, and sets the prose and sections tighter, so the book runs on fewer slides. `roomy` draws every picture whole and sets the text looser. Only `roomy` is put in the hash, as `layout=roomy`, and the page says which layout it used in `window.__blazonPrint.layout`. Any other value, and any other option, is refused.
|
|
21
23
|
|
|
22
24
|
It exits `2` with the reason and writes nothing when the request or its options are wrong, when `site_dir` has no `index.html`, when it finds no browser, and when the page does not say it is ready in time.
|
|
23
25
|
|