@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.
Files changed (73) hide show
  1. package/README.md +14 -19
  2. package/dist/chunks/{site-builder-vpzUWoiA.js → site-builder-BtGOvjBC.js} +1836 -2111
  3. package/dist/cli/commands/tokens.d.ts +4 -0
  4. package/dist/cli/commands/tokens.d.ts.map +1 -1
  5. package/dist/cli/handlers/brand.d.ts +1 -1
  6. package/dist/cli/handlers/index.d.ts +2 -2
  7. package/dist/cli/index.js +915 -941
  8. package/dist/core/brand/export.d.ts +2 -9
  9. package/dist/core/brand/export.d.ts.map +1 -1
  10. package/dist/core/brand/schema.d.ts +0 -58
  11. package/dist/core/brand/schema.d.ts.map +1 -1
  12. package/dist/core/brand-theme.d.ts +0 -2
  13. package/dist/core/brand-theme.d.ts.map +1 -1
  14. package/dist/core/checker/catalogue.d.ts +18 -2
  15. package/dist/core/checker/catalogue.d.ts.map +1 -1
  16. package/dist/core/checker/contrast.d.ts +1 -1
  17. package/dist/core/checker/variables.d.ts +2 -2
  18. package/dist/core/checker/variables.d.ts.map +1 -1
  19. package/dist/core/config/removed-keys.d.ts +6 -0
  20. package/dist/core/config/removed-keys.d.ts.map +1 -0
  21. package/dist/core/config/validate.d.ts +1 -1
  22. package/dist/core/config/validate.d.ts.map +1 -1
  23. package/dist/core/docs/directives.d.ts +9 -0
  24. package/dist/core/docs/directives.d.ts.map +1 -1
  25. package/dist/core/docs/parser.d.ts.map +1 -1
  26. package/dist/core/emit.d.ts +1 -3
  27. package/dist/core/emit.d.ts.map +1 -1
  28. package/dist/core/index.d.ts.map +1 -1
  29. package/dist/core/operations/list.d.ts.map +1 -1
  30. package/dist/core/plugin-name.d.ts +1 -1
  31. package/dist/core/read/token.d.ts +1 -6
  32. package/dist/core/read/token.d.ts.map +1 -1
  33. package/dist/core/tokens/walk.d.ts.map +1 -1
  34. package/dist/index.js +33 -33
  35. package/dist/plugins/roles/integrate.d.ts +5 -2
  36. package/dist/plugins/roles/integrate.d.ts.map +1 -1
  37. package/dist/plugins/roles/roles.d.ts +9 -2
  38. package/dist/plugins/roles/roles.d.ts.map +1 -1
  39. package/dist/plugins/wire/profile.d.ts +5 -0
  40. package/dist/plugins/wire/profile.d.ts.map +1 -1
  41. package/dist/types/config.d.ts +1 -3
  42. package/dist/types/config.d.ts.map +1 -1
  43. package/dist/types/theme.d.ts +0 -3
  44. package/dist/types/theme.d.ts.map +1 -1
  45. package/dist/ui/assets/{index-BdbihVvH.js → index-CLKH0m9J.js} +45 -47
  46. package/dist/ui/index.html +1 -1
  47. package/package.json +1 -1
  48. package/plugins/blazon.brand-deck/bin/blazon-blazon.brand-deck./360/237/224/214 +24 -2
  49. package/plugins/blazon.copy/bin/blazon-blazon.copy./360/237/224/214 +25 -3
  50. package/plugins/blazon.favicons/bin/blazon-blazon.favicons./360/237/224/214 +26 -3
  51. package/plugins/blazon.logo-geometry/bin/blazon-blazon.logo-geometry./360/237/224/214 +37 -8
  52. package/plugins/blazon.logo-kit/bin/blazon-blazon.logo-kit./360/237/224/214 +37 -8
  53. package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +37 -8
  54. package/plugins/blazon.platform-tokens/bin/blazon-blazon.platform-tokens./360/237/224/214 +37 -9
  55. package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +37 -8
  56. package/plugins/blazon.print-book/README.md +3 -1
  57. package/plugins/blazon.print-book/bin/blazon-blazon.print-book./360/237/224/214 +43 -8
  58. package/plugins/blazon.shadcn/README.md +27 -0
  59. package/plugins/blazon.shadcn/bin/blazon-blazon.shadcn./360/237/224/214 +8273 -0
  60. package/plugins/blazon.shadcn/package.json +3 -0
  61. package/plugins/blazon.social-cards/bin/blazon-blazon.social-cards./360/237/224/214 +37 -8
  62. package/plugins/blazon.tailwind/README.md +23 -0
  63. package/plugins/blazon.tailwind/bin/blazon-blazon.tailwind./360/237/224/214 +420 -0
  64. package/plugins/blazon.tailwind/package.json +3 -0
  65. package/plugins/shipped.lock +24 -10
  66. package/template/AGENTS.md +1 -1
  67. package/template/blazon.json +0 -10
  68. package/template/docs/01-principles.md +1 -1
  69. package/template/docs/12-web.md +2 -2
  70. package/dist/core/tokens/formatters/tailwind.d.ts +0 -37
  71. package/dist/core/tokens/formatters/tailwind.d.ts.map +0 -1
  72. package/dist/core/tokens/shadcn.d.ts +0 -43
  73. package/dist/core/tokens/shadcn.d.ts.map +0 -1
@@ -86,7 +86,24 @@ var findingFor = (name) => (code, severity, path, message) => ({
86
86
  message
87
87
  });
88
88
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
89
- /** The request as an object of version 1, or Cannot with the reason. Its role and folders are for the plugin to check. */
89
+ /** 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`. */
90
+ var REQUEST_VERSIONS = {
91
+ check: 1,
92
+ build: 2
93
+ };
94
+ /**
95
+ * The plugin needs the built site and this request has none: `blazon tokens` runs the build plugins before a site exists. The entry
96
+ * answers it as a skipped call (one info finding, nothing written), not as a plugin that could not answer.
97
+ */
98
+ var NeedsSite = class extends Cannot {};
99
+ /** The answer to a call that needed the site and had none: one `info` finding, as the entry prints it, and nothing written. */
100
+ var skippedForNoSite = (name, error) => ({ findings: [{
101
+ code: `${name}/needs-site`,
102
+ severity: "info",
103
+ path: "site_dir",
104
+ message: `${error.message}. Nothing was written; blazon build runs it.`
105
+ }] });
106
+ /** 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. */
90
107
  function readRequest(text) {
91
108
  let request;
92
109
  try {
@@ -95,19 +112,27 @@ function readRequest(text) {
95
112
  throw new Cannot("the request is not JSON");
96
113
  }
97
114
  if (!isObject(request)) throw new Cannot("the request is not a JSON object");
98
- if (request.v !== 1) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version 1`);
115
+ const speaks = (typeof request.type === "string" ? REQUEST_VERSIONS[request.type] : void 0) ?? 1;
116
+ if (request.v !== speaks) throw new Cannot(`the request is version ${JSON.stringify(request.v)}; this plugin speaks version ${speaks}`);
99
117
  return request;
100
118
  }
101
- /** The build request in `text`, or Cannot with the reason: version 1, the build role, a site_dir with an index.html and an out_dir that is a folder. The brand and options are not checked here. */
102
- function buildJob(text) {
119
+ function buildRequest(text, site) {
103
120
  const request = readRequest(text);
104
121
  if (request.type !== "build") throw new Cannot(`the request is for the ${String(request.type)} role; this plugin is a build plugin`);
105
122
  const { site_dir: siteDir, out_dir: outDir } = request;
106
- if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
123
+ if (site === "needed") {
124
+ if (siteDir === void 0) throw new NeedsSite("site_dir is absent: this plugin reads the built site, which blazon tokens does not make");
125
+ if (typeof siteDir !== "string" || !node_fs.default.existsSync(node_path.default.join(siteDir, "index.html"))) throw new Cannot("site_dir has no index.html");
126
+ }
107
127
  if (typeof outDir !== "string" || !node_fs.default.statSync(outDir, { throwIfNoEntry: false })?.isDirectory()) throw new Cannot("out_dir is not a folder");
128
+ return request;
129
+ }
130
+ /** 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. */
131
+ function buildJob(text) {
132
+ const request = buildRequest(text, "needed");
108
133
  return {
109
- siteDir,
110
- outDir,
134
+ siteDir: request.site_dir,
135
+ outDir: request.out_dir,
111
136
  brand: request.brand ?? {},
112
137
  options: request.options ?? {}
113
138
  };
@@ -131,6 +156,10 @@ async function runPlugin(argv, manifest, build, failure, name) {
131
156
  process.stdout.write(`${JSON.stringify(bounded)}\n`);
132
157
  return 0;
133
158
  } catch (error) {
159
+ if (error instanceof NeedsSite) {
160
+ process.stdout.write(`${JSON.stringify(skippedForNoSite(name, error))}\n`);
161
+ return 0;
162
+ }
134
163
  const reason = error instanceof Cannot ? error.message : `${failure}: ${String(error.message ?? error).split("\n")[0].slice(0, 500)}`;
135
164
  process.stdout.write(`${reason}\n`);
136
165
  return 2;
@@ -9007,8 +9036,11 @@ var OPTIONS = [
9007
9036
  "preset",
9008
9037
  "pages",
9009
9038
  "title",
9010
- "subtitle"
9039
+ "subtitle",
9040
+ "layout"
9011
9041
  ];
9042
+ /** The layouts the viewer's print page spaces a book in; the first is the default and is not put in the hash */
9043
+ var LAYOUTS = ["compact", "roomy"];
9012
9044
  /** The longest title and subtitle: the cover sets the title at 96 px and the footer has one line */
9013
9045
  var LIMITS = {
9014
9046
  title: 120,
@@ -9033,6 +9065,9 @@ function page(options) {
9033
9065
  const value = text(options, key);
9034
9066
  return value === void 0 ? [] : [`${key}=${encodeURIComponent(value)}`];
9035
9067
  });
9068
+ const layout = options.layout;
9069
+ if (layout !== void 0 && (typeof layout !== "string" || !LAYOUTS.includes(layout))) throw new OptionError(`layout must be ${LAYOUTS.join(" or ")}`);
9070
+ if (layout !== void 0 && layout !== LAYOUTS[0]) query.push(`layout=${layout}`);
9036
9071
  return query.length === 0 ? chosen : {
9037
9072
  ...chosen,
9038
9073
  hash: `${chosen.hash}?${query.join("&")}`
@@ -0,0 +1,27 @@
1
+ # blazon.shadcn
2
+
3
+ The plugin blazon ships to write which token each shadcn/ui variable takes, and those variables as CSS. It fills the `build` role and needs only Node: no browser. It reads `brand.json` through the plugin protocol and nothing else, and it reads no site, so `blazon tokens` runs it as well as `blazon build`. Blazon's core knows no UI library by name.
4
+
5
+ The source is `src/shipped/shadcn/`, and `npm run build:plugins` bundles it, with the blazon code it uses, into `bin/blazon-blazon.shadcn.🔌`, the one file that holds the plugin's code and that `plugins/shipped.lock` pins. It loads nothing from `node_modules`. The manual's plugins chapter says what to put in the config, and chapter 19 how to use the files.
6
+
7
+ ## What it writes
8
+
9
+ To `<tokensOutDir>/blazon.shadcn/` (`dist/tokens/blazon.shadcn/`):
10
+
11
+ | File | Holds |
12
+ |---|---|
13
+ | `shadcn.json` | For each shadcn variable blazon supplies, the token it takes, its value in the default context and where the pick came from (`theme` or `config`); `unsupplied`, the variables nothing supplies; and, when the brand declares contrast `pairs`, `pairs`, each shadcn text-on-surface pair with whether a rule covers its two tokens |
14
+ | `shadcn.css` | A `:root` block with each supplied variable, and a block under the selector of each other context for the variables that context changes |
15
+
16
+ A variable takes its value from the theme role it reads (`background` for `--background`, `accent` for `--primary`, and so on, the same picks the brand book's own components use), or from the token the `variables` option names for it. `destructive` and `chart-1` to `chart-5` have no role, so only the option fills them.
17
+
18
+ ## Options
19
+
20
+ `variables`: an object of shadcn variable names (without the leading dashes) to token paths. A pick wins over the role.
21
+
22
+ ## Findings
23
+
24
+ | Code | Severity | When |
25
+ |---|---|---|
26
+ | `blazon.shadcn/token-missing` | error | A pick in `variables` names a path that is not a token; the variable falls back to its role |
27
+ | `blazon.shadcn/option-invalid` | error | An option is not one of the above, or `variables` names a variable shadcn does not have |