@iksnerd/blazon 0.3.1 → 0.3.2
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/dist/chunks/{site-builder-CH6OcFSE.js → site-builder-NRN9UNyn.js} +2481 -2396
- package/dist/cli/index.js +3 -3
- package/dist/core/brand/export.d.ts +3 -1
- package/dist/core/brand/export.d.ts.map +1 -1
- package/dist/core/brand/schema.d.ts +21 -0
- package/dist/core/brand/schema.d.ts.map +1 -1
- package/dist/core/checker/catalogue.d.ts +8 -0
- package/dist/core/checker/catalogue.d.ts.map +1 -1
- package/dist/core/fonts.d.ts +10 -1
- package/dist/core/fonts.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/inputs.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/data.d.ts +10 -0
- package/dist/types/data.d.ts.map +1 -1
- package/dist/ui/assets/index-Biy1hkeq.css +2 -0
- package/dist/ui/assets/{index-CLKH0m9J.js → index-BpdgjM9E.js} +7 -0
- package/dist/ui/index.html +2 -2
- package/mcp/dist/index.js +8 -5
- package/package.json +1 -1
- package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +1 -1
- package/plugins/blazon.platform-tokens/README.md +58 -2
- package/plugins/blazon.platform-tokens/bin/blazon-blazon.platform-tokens./360/237/224/214 +57 -12
- package/plugins/blazon.press-kit/README.md +54 -3
- package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +247 -49
- package/plugins/blazon.print-book/README.md +6 -0
- package/plugins/shipped.lock +4 -4
- package/dist/ui/assets/index-DluSqfla.css +0 -2
|
@@ -305,6 +305,11 @@ function readBrand(brand) {
|
|
|
305
305
|
colors,
|
|
306
306
|
fontTokens,
|
|
307
307
|
stylesheets: (Array.isArray(theme.fonts) ? theme.fonts : []).filter((sheet) => typeof sheet === "string"),
|
|
308
|
+
fontLicenses: (Array.isArray(theme.fontLicenses) ? theme.fontLicenses : []).flatMap((raw) => isObject(raw) && text(raw.family) && text(raw.licenseFile) && typeof raw.licenseText === "string" && raw.licenseText.trim() !== "" ? [{
|
|
309
|
+
family: raw.family,
|
|
310
|
+
licenseFile: raw.licenseFile,
|
|
311
|
+
licenseText: raw.licenseText
|
|
312
|
+
}] : []),
|
|
308
313
|
assets,
|
|
309
314
|
logo: readLogo(root)
|
|
310
315
|
};
|
|
@@ -366,14 +371,38 @@ var MANIFEST = {
|
|
|
366
371
|
function jobFor(text) {
|
|
367
372
|
return buildJob(text);
|
|
368
373
|
}
|
|
374
|
+
/** What each text may hold, in characters, and how many facts there may be */
|
|
375
|
+
var LIMITS = {
|
|
376
|
+
description: 1e3,
|
|
377
|
+
boilerplate: 2e3,
|
|
378
|
+
facts: 20,
|
|
379
|
+
label: 60,
|
|
380
|
+
value: 300,
|
|
381
|
+
note: 280
|
|
382
|
+
};
|
|
369
383
|
var KEYS = [
|
|
370
384
|
"name",
|
|
371
385
|
"pdf",
|
|
372
386
|
"unreviewed",
|
|
373
|
-
"logos"
|
|
387
|
+
"logos",
|
|
388
|
+
"company",
|
|
389
|
+
"note"
|
|
390
|
+
];
|
|
391
|
+
var COMPANY_KEYS = [
|
|
392
|
+
"description",
|
|
393
|
+
"boilerplate",
|
|
394
|
+
"facts"
|
|
374
395
|
];
|
|
396
|
+
var FACT_KEYS = ["label", "value"];
|
|
375
397
|
var finding = findingFor(NAME);
|
|
376
|
-
var invalid = (message) => finding("option-invalid", "error",
|
|
398
|
+
var invalid = (message, at = "options") => finding("option-invalid", "error", at, message);
|
|
399
|
+
/** A text the person wrote: a string with something in it, up to `max` characters, and on one line when `oneLine`. Otherwise the reason it is not. */
|
|
400
|
+
function textProblem(value, max, oneLine) {
|
|
401
|
+
if (typeof value !== "string") return "must be a string";
|
|
402
|
+
if (value.trim() === "") return "must not be empty";
|
|
403
|
+
if (value.length > max) return `must be at most ${max} characters, not ${value.length}`;
|
|
404
|
+
if (oneLine && /[\r\n]/.test(value)) return "must be on one line";
|
|
405
|
+
}
|
|
377
406
|
/** A text as a file name: letters, digits, dots, hyphens and underscores, so it is plain ASCII and cannot leave the folder. */
|
|
378
407
|
var fileName = (text) => text.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[-.]+/, "") || "file";
|
|
379
408
|
/**
|
|
@@ -414,11 +443,54 @@ function parseOptions(raw, logoIds) {
|
|
|
414
443
|
if (known.length > 0) options.logos = known;
|
|
415
444
|
}
|
|
416
445
|
}
|
|
446
|
+
if (raw.company !== void 0) readCompany(raw.company, options, findings);
|
|
447
|
+
if (raw.note !== void 0) {
|
|
448
|
+
const problem = textProblem(raw.note, LIMITS.note, true);
|
|
449
|
+
if (problem) findings.push(invalid(`note ${problem}`, "options.note"));
|
|
450
|
+
else options.note = raw.note.trim();
|
|
451
|
+
}
|
|
417
452
|
return {
|
|
418
453
|
options,
|
|
419
454
|
findings
|
|
420
455
|
};
|
|
421
456
|
}
|
|
457
|
+
/** The company option: every key optional, each value checked on its own so one wrong text does not cost the others */
|
|
458
|
+
function readCompany(raw, options, findings) {
|
|
459
|
+
if (!isObject(raw)) {
|
|
460
|
+
findings.push(invalid("company must be an object with description, boilerplate and facts", "options.company"));
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
for (const key of Object.keys(raw)) if (!COMPANY_KEYS.includes(key)) findings.push(invalid(`unknown key "company.${key}"; company takes ${COMPANY_KEYS.join(", ")}`, "options.company"));
|
|
464
|
+
const company = {};
|
|
465
|
+
for (const key of ["description", "boilerplate"]) {
|
|
466
|
+
if (raw[key] === void 0) continue;
|
|
467
|
+
const problem = textProblem(raw[key], LIMITS[key], false);
|
|
468
|
+
if (problem) findings.push(invalid(`company.${key} ${problem}`, `options.company.${key}`));
|
|
469
|
+
else company[key] = raw[key].trim();
|
|
470
|
+
}
|
|
471
|
+
if (raw.facts !== void 0) {
|
|
472
|
+
if (!Array.isArray(raw.facts) || raw.facts.length === 0) findings.push(invalid("company.facts must be a non-empty list of {\"label\": ..., \"value\": ...}", "options.company.facts"));
|
|
473
|
+
else if (raw.facts.length > LIMITS.facts) findings.push(invalid(`company.facts holds ${raw.facts.length} facts, at most ${LIMITS.facts}`, "options.company.facts"));
|
|
474
|
+
else {
|
|
475
|
+
const facts = [];
|
|
476
|
+
raw.facts.forEach((item, index) => {
|
|
477
|
+
const at = `options.company.facts[${index}]`;
|
|
478
|
+
if (!isObject(item)) return void findings.push(invalid(`company.facts[${index}] must be an object with a label and a value`, at));
|
|
479
|
+
const unknown = Object.keys(item).filter((key) => !FACT_KEYS.includes(key));
|
|
480
|
+
for (const key of unknown) findings.push(invalid(`unknown key "company.facts[${index}].${key}"; a fact takes label and value`, at));
|
|
481
|
+
const [label, value] = [textProblem(item.label, LIMITS.label, true), textProblem(item.value, LIMITS.value, true)];
|
|
482
|
+
if (label) findings.push(invalid(`company.facts[${index}].label ${label}`, `${at}.label`));
|
|
483
|
+
if (value) findings.push(invalid(`company.facts[${index}].value ${value}`, `${at}.value`));
|
|
484
|
+
if (!label && !value && unknown.length === 0) facts.push({
|
|
485
|
+
label: item.label.trim(),
|
|
486
|
+
value: item.value.trim()
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
if (facts.length > 0) company.facts = facts;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (Object.keys(company).length > 0) options.company = company;
|
|
493
|
+
}
|
|
422
494
|
var PLAIN = /^(#([0-9a-f]{3}|[0-9a-f]{6})|rgb\(\s*[\d.]+%?[\s,]+[\d.]+%?[\s,]+[\d.]+%?\s*\))$/i;
|
|
423
495
|
var cssName = (path) => `--${path.replace(/[^A-Za-z0-9_-]+/g, "-").toLowerCase()}`;
|
|
424
496
|
function planColors(brand, options = {}) {
|
|
@@ -477,8 +549,13 @@ function colorsCss(colors) {
|
|
|
477
549
|
lines.push("}");
|
|
478
550
|
return `${lines.join("\n")}\n`;
|
|
479
551
|
}
|
|
480
|
-
function colorsText(colors) {
|
|
481
|
-
const lines = [
|
|
552
|
+
function colorsText(colors, note) {
|
|
553
|
+
const lines = note ? [
|
|
554
|
+
"Colors",
|
|
555
|
+
"",
|
|
556
|
+
`Note: ${note}`,
|
|
557
|
+
""
|
|
558
|
+
] : ["Colors", ""];
|
|
482
559
|
for (const color of colors) {
|
|
483
560
|
const name = color.description && color.description.length <= 60 ? `${color.description} (${color.path})` : color.path;
|
|
484
561
|
lines.push(color.review ? `${name} (unreviewed)` : name);
|
|
@@ -492,6 +569,45 @@ function colorsText(colors) {
|
|
|
492
569
|
}
|
|
493
570
|
return `${lines.join("\n").trimEnd()}\n`;
|
|
494
571
|
}
|
|
572
|
+
/** Names a browser has without a download, or that a keyword stands for. A token naming one needs no `fonts` entry. */
|
|
573
|
+
var SYSTEM_FAMILIES = /* @__PURE__ */ new Set([
|
|
574
|
+
"serif",
|
|
575
|
+
"sans-serif",
|
|
576
|
+
"monospace",
|
|
577
|
+
"cursive",
|
|
578
|
+
"fantasy",
|
|
579
|
+
"system-ui",
|
|
580
|
+
"ui-sans-serif",
|
|
581
|
+
"ui-serif",
|
|
582
|
+
"ui-monospace",
|
|
583
|
+
"ui-rounded",
|
|
584
|
+
"emoji",
|
|
585
|
+
"math",
|
|
586
|
+
"fangsong",
|
|
587
|
+
"-apple-system",
|
|
588
|
+
"blinkmacsystemfont",
|
|
589
|
+
"segoe ui",
|
|
590
|
+
"roboto",
|
|
591
|
+
"helvetica",
|
|
592
|
+
"helvetica neue",
|
|
593
|
+
"arial",
|
|
594
|
+
"verdana",
|
|
595
|
+
"tahoma",
|
|
596
|
+
"trebuchet ms",
|
|
597
|
+
"georgia",
|
|
598
|
+
"times",
|
|
599
|
+
"times new roman",
|
|
600
|
+
"courier",
|
|
601
|
+
"courier new",
|
|
602
|
+
"menlo",
|
|
603
|
+
"monaco",
|
|
604
|
+
"consolas",
|
|
605
|
+
"sfmono-regular",
|
|
606
|
+
"liberation mono",
|
|
607
|
+
"sf pro",
|
|
608
|
+
"sf pro text",
|
|
609
|
+
"sf pro display"
|
|
610
|
+
]);
|
|
495
611
|
var GENERIC = /* @__PURE__ */ new Set([
|
|
496
612
|
"serif",
|
|
497
613
|
"sans-serif",
|
|
@@ -509,7 +625,7 @@ var GENERIC = /* @__PURE__ */ new Set([
|
|
|
509
625
|
]);
|
|
510
626
|
/** The families of a CSS font stack, unquoted, in order */
|
|
511
627
|
function families(stack) {
|
|
512
|
-
return [...stack.matchAll(
|
|
628
|
+
return [...stack.matchAll(/\s*"([^"]+)"|\s*'([^']+)'|([^,]+)/g)].map((match) => (match[1] ?? match[2] ?? match[3]).trim()).filter((name) => name !== "");
|
|
513
629
|
}
|
|
514
630
|
/** The first family of the stack that names a font: not a generic, not a var(). */
|
|
515
631
|
var fontOf = (stack) => stack ? families(stack).find((name) => !GENERIC.has(name.toLowerCase()) && !/[()]/.test(name)) : void 0;
|
|
@@ -541,10 +657,20 @@ function stylesheetFamilies(sheet) {
|
|
|
541
657
|
return;
|
|
542
658
|
}
|
|
543
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* What a license file's text says it is: an `SPDX-License-Identifier:` line, else the first line that is short and is not a copyright notice
|
|
662
|
+
* (the OFL starts with a copyright line, often a long one, and names itself on the next). Nothing is guessed from the family or the words.
|
|
663
|
+
*/
|
|
664
|
+
function licenseHeadline(text) {
|
|
665
|
+
const lines = text.split("\n").map((line) => line.trim());
|
|
666
|
+
const spdx = lines.map((line) => /^(?:[#*/;\s]*)SPDX-License-Identifier:\s*(.+)$/i.exec(line)?.[1]?.trim()).find(Boolean);
|
|
667
|
+
if (spdx) return spdx;
|
|
668
|
+
return lines.find((line) => line !== "" && line.length <= 100 && !/^(copyright\b|\(c\)|©)/i.test(line));
|
|
669
|
+
}
|
|
544
670
|
function planFonts(brand) {
|
|
545
|
-
const families = /* @__PURE__ */ new Map();
|
|
671
|
+
const families$1 = /* @__PURE__ */ new Map();
|
|
546
672
|
const add = (name, usedFor, stated) => {
|
|
547
|
-
const family = families.get(name.toLowerCase()) ?? {
|
|
673
|
+
const family = families$1.get(name.toLowerCase()) ?? {
|
|
548
674
|
name,
|
|
549
675
|
usedFor: []
|
|
550
676
|
};
|
|
@@ -552,16 +678,22 @@ function planFonts(brand) {
|
|
|
552
678
|
family.license ??= stated?.license;
|
|
553
679
|
family.licenseUrl ??= stated?.licenseUrl;
|
|
554
680
|
family.source ??= stated?.source;
|
|
555
|
-
families.set(name.toLowerCase(), family);
|
|
681
|
+
families$1.set(name.toLowerCase(), family);
|
|
556
682
|
};
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
683
|
+
const sheetNames = /* @__PURE__ */ new Set();
|
|
684
|
+
for (const sheet of brand.stylesheets) for (const name of stylesheetFamilies(sheet)?.names ?? []) sheetNames.add(name.toLowerCase());
|
|
685
|
+
const fallbacks = /* @__PURE__ */ new Map();
|
|
686
|
+
const fallback = (name) => {
|
|
687
|
+
if (!/[()]/.test(name) && !sheetNames.has(name.toLowerCase())) fallbacks.set(name.toLowerCase(), fallbacks.get(name.toLowerCase()) ?? name);
|
|
688
|
+
};
|
|
689
|
+
/** The front family of a stack is a brand font unless it is a system one nothing loads and nothing states a source or license for; the rest of the stack is fallback */
|
|
690
|
+
const take = (stack, usedFor, stated) => {
|
|
691
|
+
const name = fontOf(stack);
|
|
692
|
+
for (const family of stack ? families(stack) : []) if (family === name && (!SYSTEM_FAMILIES.has(family.toLowerCase()) || sheetNames.has(family.toLowerCase()) || !!(stated?.license || stated?.licenseUrl || stated?.source))) add(family, usedFor, stated);
|
|
693
|
+
else fallback(family);
|
|
694
|
+
};
|
|
695
|
+
for (const [role, label] of ROLES) take(brand.roles[role], label);
|
|
696
|
+
for (const token of brand.fontTokens) take(token.stack, token.path, token);
|
|
565
697
|
const sources = /* @__PURE__ */ new Map();
|
|
566
698
|
for (const sheet of brand.stylesheets) {
|
|
567
699
|
const read = stylesheetFamilies(sheet);
|
|
@@ -571,14 +703,21 @@ function planFonts(brand) {
|
|
|
571
703
|
sources.set(name.toLowerCase(), read.source(name));
|
|
572
704
|
}
|
|
573
705
|
}
|
|
706
|
+
for (const found of brand.fontLicenses ?? []) {
|
|
707
|
+
const family = families$1.get(found.family.toLowerCase());
|
|
708
|
+
if (family && !family.license && !family.licenseUrl) family.fileLicense = {
|
|
709
|
+
headline: licenseHeadline(found.licenseText),
|
|
710
|
+
file: found.licenseFile
|
|
711
|
+
};
|
|
712
|
+
}
|
|
574
713
|
const findings = [];
|
|
575
|
-
if (families.size === 0) {
|
|
576
|
-
findings.push(finding("font-none", "warning", "theme.roles", "the brand names no font, so the kit has no fonts.txt"));
|
|
714
|
+
if (families$1.size === 0) {
|
|
715
|
+
findings.push(finding("font-none", "warning", "theme.roles", "the brand names no font it ships or loads (system fonts and generic families are fallbacks, not brand fonts), so the kit has no fonts.txt"));
|
|
577
716
|
return { findings };
|
|
578
717
|
}
|
|
579
718
|
const lines = ["Fonts", ""];
|
|
580
719
|
const unlicensed = [];
|
|
581
|
-
for (const family of families.values()) {
|
|
720
|
+
for (const family of families$1.values()) {
|
|
582
721
|
lines.push(family.name);
|
|
583
722
|
if (family.usedFor.length > 0) lines.push(` Used for: ${family.usedFor.join(", ")}`);
|
|
584
723
|
lines.push(` Source: ${family.source ?? sources.get(family.name.toLowerCase()) ?? NOT_STATED}`);
|
|
@@ -586,12 +725,17 @@ function planFonts(brand) {
|
|
|
586
725
|
lines.push(" License:", ...family.license.split("\n").map((line) => ` ${line}`.trimEnd()));
|
|
587
726
|
if (family.licenseUrl) lines.push(` License text: ${family.licenseUrl}`);
|
|
588
727
|
} else if (family.licenseUrl) lines.push(` License: see ${family.licenseUrl}`);
|
|
589
|
-
else {
|
|
728
|
+
else if (family.fileLicense) {
|
|
729
|
+
const { headline, file } = family.fileLicense;
|
|
730
|
+
lines.push(` License: ${headline ?? `see ${file}`}`, ` License file: ${file} (in the brand project, not in this kit)`);
|
|
731
|
+
} else {
|
|
590
732
|
lines.push(` License: ${NOT_STATED}`);
|
|
591
733
|
unlicensed.push(family.name);
|
|
592
734
|
}
|
|
593
735
|
lines.push("");
|
|
594
736
|
}
|
|
737
|
+
const left = [...fallbacks].filter(([key]) => !families$1.has(key)).map(([, name]) => name);
|
|
738
|
+
if (left.length > 0) lines.push(`Fallback fonts, not shipped: ${left.join(", ")}`);
|
|
595
739
|
if (unlicensed.length > 0) findings.push(finding("font-license-unstated", "warning", "fonts", `${unlicensed.length} ${unlicensed.length === 1 ? "font has" : "fonts have"} no license stated: ${unlicensed.join(", ")}; fonts.txt says "license not stated" for each`));
|
|
596
740
|
return {
|
|
597
741
|
text: `${lines.join("\n").trimEnd()}\n`,
|
|
@@ -743,19 +887,55 @@ var MEDIA = {
|
|
|
743
887
|
var escape = (text) => text.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
|
|
744
888
|
/** A family name as a CSS string: nothing in a name can end it */
|
|
745
889
|
var quoted = (name) => `"${name.replace(/[^A-Za-z0-9 _.-]+/g, "")}"`;
|
|
746
|
-
|
|
890
|
+
/**
|
|
891
|
+
* The colors the page draws, and how many more the kit holds. A color is in a group by the path before its last segment (`color.blue.500` is
|
|
892
|
+
* step 500 of `color.blue`). Groups run in the order their first token appears in the brand, each group's steps together in their own order,
|
|
893
|
+
* and a group goes in whole: the first one is cut at ten when it is longer, and the walk stops at the first later group that does not fit
|
|
894
|
+
* in the places left. A grouped color is labelled with its group and step (`blue 500`); a color straight under the top (`color.ink`) keeps its
|
|
895
|
+
* short description, else its last segment. A color with no hex is not drawn.
|
|
896
|
+
*/
|
|
897
|
+
function pickSwatches(colors) {
|
|
898
|
+
const groups = /* @__PURE__ */ new Map();
|
|
899
|
+
for (const color of colors.filter((item) => item.hex)) {
|
|
900
|
+
const group = color.path.split(".").slice(0, -1).join(".");
|
|
901
|
+
groups.set(group, [...groups.get(group) ?? [], color]);
|
|
902
|
+
}
|
|
903
|
+
const swatches = [];
|
|
904
|
+
for (const [group, members] of groups) {
|
|
905
|
+
if (swatches.length > 0 && swatches.length + members.length > MAX_SWATCHES) break;
|
|
906
|
+
const parts = group.split(".");
|
|
907
|
+
for (const color of members.slice(0, MAX_SWATCHES - swatches.length)) {
|
|
908
|
+
const step = color.path.split(".").pop() ?? color.path;
|
|
909
|
+
const label = parts.length >= 2 ? `${parts[parts.length - 1]} ${step}` : color.description && color.description.length <= 30 ? color.description : step;
|
|
910
|
+
swatches.push({
|
|
911
|
+
color,
|
|
912
|
+
label
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return {
|
|
917
|
+
swatches,
|
|
918
|
+
more: colors.length - swatches.length
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
function pageHtml({ brand, colors, logo, company, note }) {
|
|
747
922
|
const display = fontOf(brand.roles.fontDisplay);
|
|
748
923
|
const body = fontOf(brand.roles.fontBody);
|
|
749
924
|
const stack = (name, generic) => [name && quoted(name), generic].filter(Boolean).join(", ");
|
|
750
|
-
const swatches
|
|
751
|
-
const more = colors.length - swatches.length;
|
|
925
|
+
const { swatches, more } = pickSwatches(colors);
|
|
752
926
|
const sheets = brand.stylesheets.filter((sheet) => sheet.startsWith("data:text/css")).map((sheet) => `<link rel="stylesheet" href="${escape(sheet)}">`);
|
|
753
927
|
const dark = logo?.surface === "dark";
|
|
754
928
|
const image = logo ? `<img alt="" src="data:${MEDIA[logo.format] ?? "application/octet-stream"};base64,${logo.data.toString("base64")}">` : "";
|
|
755
|
-
const chips = swatches.map((color) => {
|
|
929
|
+
const chips = swatches.map(({ color, label }) => {
|
|
756
930
|
const ink = luminance(parseColor(color.hex)) > .4 ? "#111" : "#fff";
|
|
757
|
-
return `<li style="background:${color.hex};color:${ink}"><b>${escape(
|
|
931
|
+
return `<li style="background:${color.hex};color:${ink}"><b>${escape(label)}</b><span>${color.hex}</span></li>`;
|
|
758
932
|
});
|
|
933
|
+
const description = company?.description ?? brand.description;
|
|
934
|
+
const about = [
|
|
935
|
+
description ? `<p>${escape(description)}</p>` : "",
|
|
936
|
+
company?.boilerplate ? `<p class="boiler">${escape(company.boilerplate)}</p>` : "",
|
|
937
|
+
company?.facts ? `<dl class="facts">${company.facts.map((fact) => `<dt>${escape(fact.label)}</dt><dd>${escape(fact.value)}</dd>`).join("")}</dl>` : ""
|
|
938
|
+
].join("");
|
|
759
939
|
return `<!doctype html><meta charset="utf-8"><title>${escape(brand.title)}</title>${sheets.join("")}<style>
|
|
760
940
|
@page{size:${PAGE.width}px ${PAGE.height}px;margin:0}
|
|
761
941
|
*{box-sizing:border-box}html,body{margin:0}
|
|
@@ -769,7 +949,10 @@ ul{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(
|
|
|
769
949
|
li{height:96px;padding:10px 12px;display:flex;flex-direction:column;justify-content:flex-end;font-size:13px;line-height:1.3;border:1px solid #0002}
|
|
770
950
|
li b{font-weight:600}
|
|
771
951
|
small{display:block;margin-top:12px;color:#666;font-size:13px}
|
|
772
|
-
|
|
952
|
+
p+p{margin-top:12px}.boiler{font-size:14px}
|
|
953
|
+
.facts{margin:16px 0 0;display:grid;grid-template-columns:max-content 1fr;gap:4px 16px;font-size:13px;line-height:1.4}.facts dt{color:#666}.facts dd{margin:0}
|
|
954
|
+
.note{margin-top:16px;padding:8px 12px;border-left:3px solid #999;background:#f4f4f2;font-size:13px}
|
|
955
|
+
</style><body><section class="logo">${image}</section><main><div><h1>${escape(brand.title)}</h1>${about}</div><div><ul>${chips.join("")}</ul>${more > 0 ? `<small>${more} more in colors/colors.txt</small>` : ""}${note ? `<p class="note">${escape(note)}</p>` : ""}</div></main>`;
|
|
773
956
|
}
|
|
774
957
|
/** The page as a PDF, with the dates and the producer fixed so the same brand gives the same bytes */
|
|
775
958
|
async function drawPdf(input, env) {
|
|
@@ -807,16 +990,24 @@ function siteFile(siteDir, file) {
|
|
|
807
990
|
const real = node_fs.default.realpathSync(full);
|
|
808
991
|
return real.startsWith(root + node_path.default.sep) ? node_fs.default.readFileSync(real) : void 0;
|
|
809
992
|
}
|
|
810
|
-
/**
|
|
811
|
-
|
|
993
|
+
/**
|
|
994
|
+
* about.txt: the name, then the description to quote: the company's when the `company` option gives one, else the brand's. After it come the
|
|
995
|
+
* company's boilerplate, its facts as `Label: value` lines in the order given, and the note. Without any description it says so in one
|
|
996
|
+
* line, and a brand with no name has no file.
|
|
997
|
+
*/
|
|
998
|
+
function aboutText(brand, extras = {}) {
|
|
812
999
|
if (!brand.named) return { findings: [] };
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
1000
|
+
const { company, note } = extras;
|
|
1001
|
+
const description = company?.description ?? brand.description;
|
|
1002
|
+
const findings = [];
|
|
1003
|
+
const blocks = [brand.title, description ?? "No description is set in blazon.json."];
|
|
1004
|
+
if (!description) findings.push(finding("about-no-description", "warning", "brand.description", "the brand has no description, so about.txt says none is set"));
|
|
1005
|
+
if (company?.boilerplate) blocks.push(company.boilerplate);
|
|
1006
|
+
if (company?.facts) blocks.push(company.facts.map((fact) => `${fact.label}: ${fact.value}`).join("\n"));
|
|
1007
|
+
if (note) blocks.push(`Note: ${note}`);
|
|
817
1008
|
return {
|
|
818
|
-
text: `${
|
|
819
|
-
findings
|
|
1009
|
+
text: `${blocks.join("\n\n")}\n`,
|
|
1010
|
+
findings
|
|
820
1011
|
};
|
|
821
1012
|
}
|
|
822
1013
|
/** What each part of the kit is for, in the order the README lists them; a part is listed when a file of the kit starts or ends as `match` says */
|
|
@@ -839,21 +1030,23 @@ var PARTS = [
|
|
|
839
1030
|
},
|
|
840
1031
|
{
|
|
841
1032
|
match: (path) => path.endsWith(".pdf"),
|
|
842
|
-
says: "One page with the name, the description,
|
|
1033
|
+
says: "One page with the name, the description, up to ten colors (whole color groups, in the order of the brand's groups, each labelled with its group and step) and a logo."
|
|
843
1034
|
}
|
|
844
1035
|
];
|
|
845
1036
|
/** README.txt: what is in the kit, in plain words. It names only the parts that are there, and holds no date. */
|
|
846
|
-
function readmeText(title, paths, name) {
|
|
847
|
-
const lines = [
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
""
|
|
852
|
-
];
|
|
853
|
-
for (const { match, says } of PARTS) {
|
|
1037
|
+
function readmeText(title, paths, name, note) {
|
|
1038
|
+
const lines = [`${title}: press kit`, ""];
|
|
1039
|
+
if (note) lines.push(`Note: ${note}`, "");
|
|
1040
|
+
lines.push("What is in this folder", "");
|
|
1041
|
+
const listed = PARTS.flatMap(({ match, says }) => {
|
|
854
1042
|
const hit = paths.find(match);
|
|
855
|
-
|
|
856
|
-
|
|
1043
|
+
return hit ? [{
|
|
1044
|
+
shown: hit.startsWith("logos/") || hit.startsWith("colors/") ? `${hit.split("/")[0]}/` : hit,
|
|
1045
|
+
says
|
|
1046
|
+
}] : [];
|
|
1047
|
+
});
|
|
1048
|
+
const width = Math.max(16, ...listed.map(({ shown }) => shown.length + 2));
|
|
1049
|
+
for (const { shown, says } of listed) lines.push(` ${shown.padEnd(width)}${says}`);
|
|
857
1050
|
lines.push("", `${name}.zip holds the same files.`, "", "The logos are the brand's own files, not redrawn.");
|
|
858
1051
|
return `${lines.join("\n")}\n`;
|
|
859
1052
|
}
|
|
@@ -879,12 +1072,15 @@ async function build(text) {
|
|
|
879
1072
|
if (colors.colors.length > 0) {
|
|
880
1073
|
files.set("colors/colors.json", colorsJson(colors.colors));
|
|
881
1074
|
files.set("colors/colors.css", colorsCss(colors.colors));
|
|
882
|
-
files.set("colors/colors.txt", colorsText(colors.colors));
|
|
1075
|
+
files.set("colors/colors.txt", colorsText(colors.colors, options.note));
|
|
883
1076
|
}
|
|
884
1077
|
const fonts = planFonts(brand);
|
|
885
1078
|
findings.push(...fonts.findings);
|
|
886
1079
|
if (fonts.text) files.set("fonts.txt", fonts.text);
|
|
887
|
-
const about = aboutText(brand
|
|
1080
|
+
const about = aboutText(brand, {
|
|
1081
|
+
company: options.company,
|
|
1082
|
+
note: options.note
|
|
1083
|
+
});
|
|
888
1084
|
findings.push(...about.findings);
|
|
889
1085
|
if (about.text) files.set("about.txt", about.text);
|
|
890
1086
|
if (options.pdf) {
|
|
@@ -897,7 +1093,9 @@ async function build(text) {
|
|
|
897
1093
|
data: data.get(shown.asset.id),
|
|
898
1094
|
format: shown.asset.format,
|
|
899
1095
|
surface: shown.surface
|
|
900
|
-
}
|
|
1096
|
+
},
|
|
1097
|
+
company: options.company,
|
|
1098
|
+
note: options.note
|
|
901
1099
|
}, process.env);
|
|
902
1100
|
files.set(`${options.name}.pdf`, pdf);
|
|
903
1101
|
const fallen = pdfFallbacks(brand);
|
|
@@ -907,7 +1105,7 @@ async function build(text) {
|
|
|
907
1105
|
findings.push(finding("pdf-skipped", "warning", "options.pdf", `${options.name}.pdf is not in the kit: ${reason}`));
|
|
908
1106
|
}
|
|
909
1107
|
}
|
|
910
|
-
files.set("README.txt", readmeText(brand.title, [...files.keys()], options.name));
|
|
1108
|
+
files.set("README.txt", readmeText(brand.title, [...files.keys()], options.name, options.note));
|
|
911
1109
|
const entries = [...files].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
912
1110
|
const folder = node_path.default.join(job.outDir, options.name);
|
|
913
1111
|
node_fs.default.rmSync(folder, {
|
|
@@ -21,6 +21,12 @@ Two optional strings go with any of these: `title` (at most 120 characters) repl
|
|
|
21
21
|
|
|
22
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.
|
|
23
23
|
|
|
24
|
+
## Output size
|
|
25
|
+
|
|
26
|
+
The PDF is Chrome's own output, with lossless images, so it is large: a book can be 3 to 4 times the size of a compressed one. The plugin has no option to compress it and does not call another program. To shrink it, run a post-processing step such as Ghostscript on the file. Ghostscript's `-dJPEGQ` is ignored by its `pdfwrite` device; image quality changes only through `setdistillerparams` (a `QFactor` in the color image dictionary). That recipe has not been run against this plugin's output here, so it is not given.
|
|
27
|
+
|
|
28
|
+
A Markdown task list (`- [ ]`, `- [x]`) prints without a bullet, as a box with a border in the text color; a checked box is filled.
|
|
29
|
+
|
|
24
30
|
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.
|
|
25
31
|
|
|
26
32
|
## Use it
|
package/plugins/shipped.lock
CHANGED
|
@@ -40,28 +40,28 @@
|
|
|
40
40
|
"kind": "tree",
|
|
41
41
|
"path": "blazon.office-template",
|
|
42
42
|
"entry": "bin/blazon-blazon.office-template.🔌",
|
|
43
|
-
"digest": "t1:
|
|
43
|
+
"digest": "t1:d8174375af029263fb97505b81edb140b664d0cc0727db0adc3f32a954c91e63",
|
|
44
44
|
"source": "computed"
|
|
45
45
|
},
|
|
46
46
|
"blazon.platform-tokens": {
|
|
47
47
|
"kind": "tree",
|
|
48
48
|
"path": "blazon.platform-tokens",
|
|
49
49
|
"entry": "bin/blazon-blazon.platform-tokens.🔌",
|
|
50
|
-
"digest": "t1:
|
|
50
|
+
"digest": "t1:e2c6623136ffafa7e2b17cf0439c7eb10633f13e2d45490644931994b514712e",
|
|
51
51
|
"source": "computed"
|
|
52
52
|
},
|
|
53
53
|
"blazon.press-kit": {
|
|
54
54
|
"kind": "tree",
|
|
55
55
|
"path": "blazon.press-kit",
|
|
56
56
|
"entry": "bin/blazon-blazon.press-kit.🔌",
|
|
57
|
-
"digest": "t1:
|
|
57
|
+
"digest": "t1:a55097bb498706cf35e2d1ebffa5d225f8171874a82c1ecbc11dac51f6e5ec6b",
|
|
58
58
|
"source": "computed"
|
|
59
59
|
},
|
|
60
60
|
"blazon.print-book": {
|
|
61
61
|
"kind": "tree",
|
|
62
62
|
"path": "blazon.print-book",
|
|
63
63
|
"entry": "bin/blazon-blazon.print-book.🔌",
|
|
64
|
-
"digest": "t1:
|
|
64
|
+
"digest": "t1:118a7cbfef86586c852de0c8099dd5acb7f91a9fca7a37f9c4b5f8cf6a2dc8be",
|
|
65
65
|
"source": "computed"
|
|
66
66
|
},
|
|
67
67
|
"blazon.shadcn": {
|