@brunosouzas/design-system 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Bruno Souza
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md CHANGED
@@ -1,3 +1,211 @@
1
- # Temporary Holding Version
1
+ # brunosouzas-design-system
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/brunosouzas/brunosouzas-design-system/actions/workflows/ci.yml/badge.svg)](https://github.com/brunosouzas/brunosouzas-design-system/actions/workflows/ci.yml)
4
+ [![OpenSpec](https://github.com/brunosouzas/brunosouzas-design-system/actions/workflows/openspec.yml/badge.svg)](https://github.com/brunosouzas/brunosouzas-design-system/actions/workflows/openspec.yml)
5
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
6
+
7
+ The visual identity of [brunosouzas.com](https://brunosouzas.com): design tokens, and animated explainers made with code.
8
+
9
+ ![Four frames of the animated circuit-breaker state machine: CLOSED collecting call results, the arrow to OPEN, HALF_OPEN testing calls, and the full loop back to CLOSED.](docs/spikes/2026-10-22-motion-pilot/contact-sheet-16x9-en.png)
10
+
11
+ ## Contents
12
+
13
+ - [Status](#status)
14
+ - [What it is](#what-it-is)
15
+ - [How it works](#how-it-works)
16
+ - [Install](#install)
17
+ - [Commands](#commands)
18
+ - [How a scene is built](#how-a-scene-is-built)
19
+ - [Illustration pieces and covers](#illustration-pieces-and-covers)
20
+ - [Decisions](#decisions)
21
+ - [How this project is built](#how-this-project-is-built)
22
+ - [Security](#security)
23
+ - [Contributing](#contributing)
24
+ - [Licence](#licence)
25
+
26
+ ## Status
27
+
28
+ Early. The first change of the [roadmap](docs/roadmap.md) is implemented: the token source and its CSS, TypeScript and JSON exports, the motion components, and the circuit-breaker state machine as the first catalogue scene (16:9 and 4:5, Portuguese and English), with commands to render its stills and videos. The first variety scene, `publish-subscribe`, is implemented with independent message copies, Publish acceptance, two ACKs and a local invoice NACK. Its owner stills/video approval is pending; implementation is not visual approval. The illustration pieces (roadmap item 3) and the metro and diagram pieces (item 6) are implemented: the static drawing library that covers, banners, diagrams and scenes share, with a command that builds a blog cover from a JSON spec. The published covers are not ported to it yet (item 5).
29
+
30
+ ## What it is
31
+
32
+ The blog's articles explain how systems behave: a circuit breaker opening, a pipeline promoting a build, a message being retried. Static diagrams show the states; an animation shows the change. This repository keeps both in one visual language, so a reader recognises the site in an article, on LinkedIn and on a slide.
33
+
34
+ - **Design tokens, one source.** Colours with fixed meanings (green healthy, orange blocked, yellow transitional, red the failure path), the Lato type scale, the thick ink outline, the hard offset shadow, radii, and motion timings. Exported as CSS variables for the site, TypeScript for the animations and JSON for anything else (the SVG generators of the static diagrams).
35
+ - **Motion components.** React components for [Remotion](https://www.remotion.dev): an ink block with a hard shadow, a pill label, an arrow that draws itself, a token travelling along a transition, call-result squares, a countdown ring. Flow primitives in `src/brand/flow-components.tsx` add a white hexagonal `Exchange`, rail-ended `Queue`, yellow-tab `TaggedContainer` and persistent `PositionedToken` (stationary or path-positioned). Copy identities, splits and ACK/NACK rules belong to scenes, not to a generic message engine.
36
+ - **Illustration pieces.** The objects the blog's covers and diagrams draw again and again (pill label, sheet, code panel, robot, server stack, gear, road, the 26 EIP icons and more), each a pure TypeScript function that returns an SVG node tree from the tokens. The same tree becomes an SVG file for a cover and React elements for a scene, and a scene animates a piece by recomputing its parameters every frame. See [Illustration pieces and covers](#illustration-pieces-and-covers).
37
+ - **A catalogue of scenes.** Each scene animates something a published article already says, in 16:9 (article) and 4:5 (LinkedIn), in Portuguese and English from one text table. The first is the [circuit-breaker state machine](docs/spikes/2026-10-22-motion-pilot/README.md).
38
+
39
+ The style follows the illustration covers of the [Spotify Engineering blog](https://engineering.atspotify.com/): flat shapes, a dark ink outline, a hard shadow with no blur, saturated colours on a calm page.
40
+
41
+ ## How it works
42
+
43
+ ```text
44
+ tokens/source.json ──► tokens/generated/tokens.css ──► brunosouzas.com (site repository, planned)
45
+ ├─► tokens/generated/tokens.ts ──► src/brand (motion components) ──► src/scenes ──► MP4 per format and language
46
+ └─► tokens/generated/tokens.json ──► other scripts
47
+
48
+ src/pieces (pure functions → SVG node tree) ──► toSvg ──► covers (npm run cover), diagrams
49
+ └─► toReact ──► Remotion scenes
50
+ ```
51
+
52
+ The generated files are committed, so a consumer can read them without running Node. CSS custom properties carry the prefix `--ds-` (for example `--ds-color-ink`, `--ds-motion-pop-damping`) so they do not clash with the site's own theme names.
53
+
54
+ ## Install
55
+
56
+ The tokens and the illustration pieces are published on npm as [`@brunosouzas/design-system`](https://www.npmjs.com/package/@brunosouzas/design-system), with provenance; releases follow [docs/release.md](docs/release.md). The package has no runtime dependency: Remotion, the motion components and the scenes stay in this repository.
57
+
58
+ ```bash
59
+ npm install @brunosouzas/design-system
60
+ ```
61
+
62
+ | Import | What it gives |
63
+ |---|---|
64
+ | `@brunosouzas/design-system` | the pieces, `toSvg`, `pose`, the cover spec helpers and `tokens` |
65
+ | `@brunosouzas/design-system/react` | `toReact`, for React and Remotion (needs `react` 19) |
66
+ | `@brunosouzas/design-system/tokens` | the typed `tokens` object |
67
+ | `@brunosouzas/design-system/tokens.css` | the `--ds-*` custom properties |
68
+ | `@brunosouzas/design-system/tokens.json` | the plain values |
69
+
70
+ ```ts
71
+ import { pill, toSvg, tokens } from "@brunosouzas/design-system";
72
+ const label = pill({ x: 60, y: 30, text: "main" });
73
+ ```
74
+
75
+ The package also installs the cover command as `brunosouzas-cover <spec.json> --out <file.svg>`.
76
+
77
+ ## Commands
78
+
79
+ Requirements: Node.js 22.12 or later. Rendering also needs the network: Remotion downloads its headless browser on first use, and every render fetches Lato from Google Fonts.
80
+
81
+ ```bash
82
+ npm ci # install the pinned dependencies
83
+ npm run tokens # validate tokens/source.json and write tokens/generated/
84
+ npm run tokens:check # fail if tokens/generated/ is stale (CI runs this)
85
+ npm run typecheck # tsc over src/, scripts/ and test/
86
+ npm test # unit and integration tests (no rendering, no network)
87
+ npm run stills -- circuit-breaker-states # key-frame PNGs to out/stills/<composition>/<frame>.png
88
+ npm run render -- circuit-breaker-states # out/master/<id>.mp4 and the web copy out/web/<id>.mp4
89
+ npm run stills -- publish-subscribe # 24 phase/final PNGs (six per composition)
90
+ npm run stills -- publish-subscribe --dry-run # print 24 commands, no effects
91
+ npm run render -- publish-subscribe --dry-run # print eight commands; real video waits for owner stills approval
92
+ npm run build # compile the package into dist/ (the package test needs it)
93
+ npm run cover -- cover.json --out card.svg # build a blog cover from its spec
94
+ npm run pieces:sheet -- --out out/pieces.svg # every piece once, labelled, for review
95
+ npm run studio # Remotion Studio, for frame-by-frame review
96
+ ```
97
+
98
+ - Change a token value in `tokens/source.json` and run `npm run tokens`; never edit `tokens/generated/` by hand. An invalid source prints every problem and writes nothing.
99
+ - `stills` and `render` take one scene name and an optional `--dry-run`, which prints the commands without running them. A render writes a hardware-encoded master (about 28 MB for 33 s) and an x264 web copy (under 1 MB) made with the ffmpeg bundled with Remotion, and prints one line per composition with its time and sizes. The four circuit-breaker clips take about four to five minutes on an Apple M3.
100
+ - Everything rendered goes to `out/`, which Git ignores.
101
+
102
+ ## How a scene is built
103
+
104
+ The catalogue contains:
105
+
106
+ | Scene | Sources | Review status |
107
+ |---|---|---|
108
+ | `circuit-breaker-states` | [EN](https://brunosouzas.com/blog/circuit-breaker-in-mulesoft), [PT](https://brunosouzas.com/pt/blog/circuit-breaker-in-mulesoft) | approved pilot, unchanged |
109
+ | `publish-subscribe` | [EN](https://brunosouzas.com/wiki/publish-subscribe-in-mulesoft/), [PT](https://brunosouzas.com/pt/wiki/publish-subscribe-in-mulesoft/) and their Anypoint MQ diagrams | owner media gate pending |
110
+
111
+ Studio lists four compositions per scene in catalogue order. Pub-sub runs for 1000 frames at 30 fps, with the final 90 frames static. It depicts the article's AUTO acknowledgment case with a propagated invoice error, not every acknowledgment mode. Publish confirms exchange acceptance, not queue delivery. No redelivery is animated. After owner stills approval, `npm run render -- publish-subscribe` produces the four masters and four web copies; do not run it before that gate.
112
+
113
+ A scene lives in `src/scenes/<scene>/` with:
114
+
115
+ - `scene.ts`: the scene data, with no React: id, formats, languages, the timeline in frames, the text table per language (every string taken from the article) and the source article URL per language.
116
+ - `layout.ts`: one layout per format, in composition pixels; the 4:5 layout has its own arrow routes.
117
+ - `Scene.tsx`: the composition, which arranges the components from `src/brand/`.
118
+
119
+ `src/scenes/index.ts` lists the scenes and `src/Root.tsx` registers each one as a Studio folder with one composition per format and language (`<scene>-16x9-pt`, `-16x9-en`, `-4x5-pt`, `-4x5-en`). The tests check every registered scene: the same text keys in both languages, phases inside the composition and in order, events inside phases, and a reading hold of at least three seconds at the end.
120
+
121
+ `SceneContract<TTimeline>` supplies common metadata and phase ranges (`from`, `to`, events with `at`), duration and outro. `SceneData` remains the legacy state-machine alias with `Timeline`: states, slots, call results and transition fires retain their window checks. `CatalogueScene` also accepts `FlowSceneData` with `kind: "flow"`; it needs no active states or slots. The flow validator rejects unknown endpoints, invalid frames/ranges, trips crossing the outro, and impossible copy ownership/handoffs. There is no plug-in or graph-interpreter API.
122
+
123
+ Pub-sub separates `text.ts`, `timeline.ts` and pure `flow.ts` from its data entry. Half-open ownership intervals transfer each token atomically at split/arrival/ACK/NACK boundaries. Caption windows use phase ids internally, never as visible labels; captions and labels are frozen against source fixtures. Both media scripts consume only common phase ends and duration, without React or fonts.
124
+
125
+ The components take every colour and size from the tokens, and what is visible at a frame (arrow progress, travelling tokens, focus and dimming, captions, countdown, call results) comes from pure functions in `src/brand/motion.ts`, which the tests check without rendering.
126
+
127
+ ## Illustration pieces and covers
128
+
129
+ `src/pieces/` holds the drawing library. A piece is a function from plain parameters to `{ body, text }`: `body` holds the shapes, drawn inside the outlined group, and `text` the words and glyphs, drawn after every shape so the outline never strokes a letter. Pieces read only the generated tokens and never a file, so a Remotion scene can import them.
130
+
131
+ - `toSvg(node)` writes a tree as SVG text; `toReact(node)` turns the same tree into React elements. Both describe the same elements, attributes and text, which the tests check.
132
+ - `pose(node, { x, y, tilt, squash, hop, scale, shake, opacity })` animates any piece around its base point; a scene recomputes the numbers every frame.
133
+ - Every colour parameter is a token path (`"color.healthy"`, `"illustration.accent"`), never a hex value, except the two line fills of the map pieces below. Each piece checks its parameters before drawing and names the first wrong one.
134
+ - The 35 pieces, with their anchors, parameters and defaults, are listed in [design §4](openspec/changes/archive/2026-10-23-illustration-pieces/design.md) (the 26 cover pieces) and in [design §3](openspec/changes/archive/2026-10-23-metro-and-diagram-pieces/design.md) of `metro-and-diagram-pieces` (the nine below); the rules are in [`openspec/specs/illustration-pieces/`](openspec/specs/illustration-pieces/spec.md). `npm run pieces:sheet -- --out <file.svg>` draws them all.
135
+
136
+ ### Maps and diagrams
137
+
138
+ Nine pieces draw a metro map and its page diagrams, for [stackledger](https://github.com/brunosouzas/stackledger) and any other map in this style: `lineBadge`, `stationMarker` (stop, interchange as a capsule, deprecated), `pipe`, `countBadge`, `nodeBlock`, `pillNode`, `hexNode` (normal, focus, placeholder), `messageArrow` (curved or straight, with a head and an optional label) and `ledgerMark` (stackledger's mark). They paint what the caller lays out: positions, text measurement and truncation stay with the map engine.
139
+
140
+ - `surface: "light" | "dark"` picks the background they sit on (`surface.*` tokens); every map and diagram piece takes it except `pipe` and `ledgerMark`. On dark the hard shadow takes `surface.dark.shadow` and the outline gets a light rim ([ADR 0003](docs/adr/0003-visual-language-and-colour-meaning.md), amendment of AB#157).
141
+ - `inkScale` (0.25 to 8) thickens the outline, rim and shadow without changing the geometry, on `lineBadge`, `stationMarker`, `countBadge` and the three nodes; the map uses 1, the page diagrams 1.6. A shape's height (a marker's diameter) must be at least four outlines; a placeholder node, which draws no ink, is exempt.
142
+ - A line's colour comes from the map's data, so `pipe.fill` and `lineBadge.fill` also accept `#RRGGBB`. Every other colour is a token path, and a cover spec rejects any hex.
143
+ - The `map.*` tokens hold the measures (outline 3, shadow 3.5, line 12, casing 6, badge 20, node 46…), and `site.*` the page palette, fonts and type scale of brunosouzas.com in light and dark.
144
+
145
+ ```ts
146
+ import { lineBadge, pipe, stationMarker, toSvg } from "@brunosouzas/design-system";
147
+ const line = pipe({ d: "M20,40 L220,40", fill: "#7B3FE4" });
148
+ const stop = stationMarker({ cx: 120, cy: 40, surface: "dark" });
149
+ const badge = lineBadge({ x: 250, y: 40, text: "SH", fill: "#7B3FE4", surface: "dark" });
150
+ ```
151
+
152
+ ### A cover
153
+
154
+ A cover is a JSON spec kept with its article, outside this repository: drafts are private, and only the pieces are public. `npm run cover -- <spec.json> --out <file.svg>` validates it, reports every problem with its JSON path, and writes an 800x420 SVG; the same spec always gives the same bytes.
155
+
156
+ ```json
157
+ {
158
+ "id": "sdd",
159
+ "title": "A one-line request becomes a reviewed spec before any code",
160
+ "description": "Illustration. On the left, a small slip …",
161
+ "background": "blush",
162
+ "rings": { "cx": 400, "cy": 220, "radius": 96 },
163
+ "pieces": [
164
+ { "piece": "speechBubble", "x": 52, "y": 174, "width": 160, "height": 74 },
165
+ { "piece": "pill", "x": 132, "y": 174, "text": "request", "width": 104 }
166
+ ]
167
+ }
168
+ ```
169
+
170
+ - `background` names one of the 21 pairs in `coverBackground` (a background and its ring colour, measured from the published covers). Each pair is used by one cover only.
171
+ - `pieces` are drawn in order; their words go on top.
172
+ - `custom` (optional) is the cover's one free-form object, a JSON node tree limited to drawing tags and a fixed list of attributes, with no external references. An object that repeats becomes a piece instead.
173
+ - The three published covers that proved the pieces are the test fixtures in `test/fixtures/covers/`.
174
+
175
+ ### A new piece
176
+
177
+ Add it to `src/pieces/library.ts` (or `src/pieces/metro.ts` for a map or diagram piece) with `definePiece(name, schema, draw)`, take its colours and sizes from the tokens (a new colour goes to `tokens/source.json` first), register it in `PIECES`, and give it a sample in `scripts/pieces-sheet.ts`. The catalogue test then checks that it draws with only its required parameters and uses token colours only.
178
+
179
+ ### EIP icons
180
+
181
+ `src/pieces/eip-icons.ts` holds the 26 Enterprise Integration Patterns icons as data. They are redrawn from the icons by Gregor Hohpe and Bobby Woolf ([enterpriseintegrationpatterns.com](https://www.enterpriseintegrationpatterns.com/)), licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); each icon keeps that credit in its description.
182
+
183
+ ## Decisions
184
+
185
+ Project-wide decisions are recorded as ADRs in [`docs/adr/`](docs/adr/README.md).
186
+
187
+ - **Animations are code, made with Remotion.** A scene is React components and data, so a correction is a re-render and every format and language comes from one composition. AI video generators were rejected because their outputs are not consistent between clips. [ADR 0001](docs/adr/0001-remotion-for-motion.md)
188
+ - **One token source.** Colours, type, outline, shadow and motion timings live in one file; the site, the animations and the SVG scripts read generated exports instead of keeping their own copies. [ADR 0002](docs/adr/0002-one-token-source.md)
189
+ - **One visual language, fixed colour meanings.** Green is always healthy, orange always blocked, red always the failure path, so a reader learns the code once. Rotated text is allowed since the 2026-10-23 amendment. [ADR 0003](docs/adr/0003-visual-language-and-colour-meaning.md)
190
+ - **Scenes illustrate published articles.** Every string on screen comes from the article, so an animation never says more than the reviewed text. [ADR 0004](docs/adr/0004-scenes-illustrate-published-articles.md)
191
+
192
+ ## How this project is built
193
+
194
+ - Changes are specified first with [OpenSpec](https://github.com/Fission-AI/OpenSpec): active changes in [`openspec/changes/`](openspec/changes/), the current behaviour in [`openspec/specs/`](openspec/specs/).
195
+ - Decisions: [`docs/adr/`](docs/adr/README.md).
196
+ - Order of work: [`docs/roadmap.md`](docs/roadmap.md).
197
+ - Evidence from experiments: [`docs/spikes/`](docs/spikes/).
198
+
199
+ ## Security
200
+
201
+ No secrets, credentials or telemetry belong in this repository. Report a vulnerability privately: see [SECURITY.md](SECURITY.md).
202
+
203
+ ## Contributing
204
+
205
+ Issues and pull requests are welcome, especially corrections and ideas for the components. The scenes illustrate the author's own articles, so new scenes come from the blog.
206
+
207
+ ## Licence
208
+
209
+ Code and tokens: [Apache-2.0](LICENSE). The identity (the look of brunosouzas.com) is also the look of the author's other products, such as [stackledger](https://github.com/brunosouzas/stackledger), whose generated sites carry it. The licence does not grant use of the name or of the brunosouzas.com identity as someone else's brand: to build your own, fork it and change the token values.
210
+
211
+ The animations use [Remotion](https://www.remotion.dev), which has its own licence: free for individuals and for companies of up to three people, a company licence above that ([terms](https://www.remotion.dev/docs/license)). Check it before you render with this code at work.
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ export declare const COVER_USAGE = "usage: npm run cover -- <spec.json> --out <file.svg>";
3
+ export type CoverIo = {
4
+ cwd: string;
5
+ log: (line: string) => void;
6
+ error: (line: string) => void;
7
+ };
8
+ /** The first invocation problem, in the order of the spec, or the two paths. */
9
+ export declare const parseCoverArgs: (args: string[], cwd: string) => {
10
+ ok: true;
11
+ spec: string;
12
+ out: string;
13
+ } | {
14
+ ok: false;
15
+ problem: string;
16
+ };
17
+ /** Builds the cover text for a spec file's contents, or the problem lines. */
18
+ export declare const buildCover: (text: string, label: string) => {
19
+ ok: true;
20
+ svg: string;
21
+ } | {
22
+ ok: false;
23
+ lines: string[];
24
+ };
25
+ export declare const runCover: (args: string[], io: CoverIo) => number;
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ // `npm run cover -- <spec.json> --out <file.svg>`, installed as the bin
3
+ // `brunosouzas-cover` (spec cover-cli; design §6):
4
+ // builds one blog cover from a cover spec kept with its article in the vault.
5
+ //
6
+ // Why: covers were drawn by hand and drifted; a spec plus the shared pieces
7
+ // makes every cover reproducible, and only the pieces live in this public
8
+ // repository.
9
+ //
10
+ // What can go wrong: a bad invocation reports its first problem with the
11
+ // usage; an invalid spec reports every problem by JSON path. In both cases the
12
+ // command exits 1 and writes nothing. An existing output file is replaced.
13
+ import { closeSync, existsSync, openSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
14
+ import { randomUUID } from "node:crypto";
15
+ import { dirname, resolve } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ import { coverTree, validateCoverSpec } from "../src/pieces/cover.js";
18
+ import { toSvg } from "../src/pieces/render.js";
19
+ export const COVER_USAGE = "usage: npm run cover -- <spec.json> --out <file.svg>";
20
+ /** The first invocation problem, in the order of the spec, or the two paths. */
21
+ export const parseCoverArgs = (args, cwd) => {
22
+ const specs = [];
23
+ const outs = [];
24
+ let unknown;
25
+ let outWithoutValue = false;
26
+ for (let i = 0; i < args.length; i++) {
27
+ const arg = args[i];
28
+ if (arg === "--out") {
29
+ const value = args[i + 1];
30
+ if (value === undefined || value.startsWith("--"))
31
+ outWithoutValue = true;
32
+ else {
33
+ outs.push(value);
34
+ i++;
35
+ }
36
+ }
37
+ else if (arg.startsWith("-"))
38
+ unknown ??= arg;
39
+ else
40
+ specs.push(arg);
41
+ }
42
+ if (unknown !== undefined)
43
+ return { ok: false, problem: `unknown option ${unknown}` };
44
+ if (outWithoutValue)
45
+ return { ok: false, problem: "--out needs a value: <file.svg>" };
46
+ if (outs.length === 0)
47
+ return { ok: false, problem: "--out <file.svg> is required" };
48
+ if (outs.length > 1)
49
+ return { ok: false, problem: "--out given more than once" };
50
+ const out = outs[0];
51
+ if (!out.endsWith(".svg"))
52
+ return { ok: false, problem: `the output must be an .svg file, found ${out}` };
53
+ const folder = dirname(resolve(cwd, out));
54
+ if (!existsSync(folder) || !statSync(folder).isDirectory())
55
+ return { ok: false, problem: `the output folder does not exist: ${dirname(out)}` };
56
+ const target = resolve(cwd, out);
57
+ if (existsSync(target) && statSync(target).isDirectory())
58
+ return { ok: false, problem: `the output is a folder: ${out}` };
59
+ if (specs.length === 0)
60
+ return { ok: false, problem: "missing the cover spec: <spec.json>" };
61
+ if (specs.length > 1)
62
+ return { ok: false, problem: `one cover spec at a time, found ${specs.length}` };
63
+ return { ok: true, spec: specs[0], out };
64
+ };
65
+ /** Parses the spec text; a syntax error names the line and column. */
66
+ const parseJson = (text, label) => {
67
+ try {
68
+ return { value: JSON.parse(text) };
69
+ }
70
+ catch (error) {
71
+ const message = error instanceof Error ? error.message : String(error);
72
+ const lineColumn = /line (\d+) column (\d+)/.exec(message);
73
+ const position = /position (\d+)/.exec(message);
74
+ let where = "";
75
+ if (lineColumn)
76
+ where = ` at line ${lineColumn[1]}, column ${lineColumn[2]}`;
77
+ else if (position) {
78
+ const before = text.slice(0, Number(position[1])).split("\n");
79
+ where = ` at line ${before.length}, column ${before[before.length - 1].length + 1}`;
80
+ }
81
+ return { problem: `${label}: invalid JSON${where} (${message})` };
82
+ }
83
+ };
84
+ /** Builds the cover text for a spec file's contents, or the problem lines. */
85
+ export const buildCover = (text, label) => {
86
+ const parsed = parseJson(text, label);
87
+ if ("problem" in parsed)
88
+ return { ok: false, lines: [parsed.problem] };
89
+ const problems = validateCoverSpec(parsed.value);
90
+ if (problems.length > 0)
91
+ return { ok: false, lines: problems.map((p) => `${p.path}: ${p.message}`) };
92
+ return { ok: true, svg: `${toSvg(coverTree(parsed.value))}\n` };
93
+ };
94
+ export const runCover = (args, io) => {
95
+ const invocation = parseCoverArgs(args, io.cwd);
96
+ if (!invocation.ok) {
97
+ io.error(invocation.problem);
98
+ io.error(COVER_USAGE);
99
+ return 1;
100
+ }
101
+ const specPath = resolve(io.cwd, invocation.spec);
102
+ let text;
103
+ try {
104
+ text = readFileSync(specPath, "utf8");
105
+ }
106
+ catch (error) {
107
+ io.error(`cannot read ${invocation.spec}: ${error instanceof Error ? error.message : String(error)}`);
108
+ io.error(COVER_USAGE);
109
+ return 1;
110
+ }
111
+ const result = buildCover(text, invocation.spec);
112
+ if (!result.ok) {
113
+ for (const line of result.lines)
114
+ io.error(line);
115
+ io.error(`cover: ${result.lines.length} problem(s) in ${invocation.spec}; no file written`);
116
+ return 1;
117
+ }
118
+ // Write beside the target and rename, so a failed write never leaves half a cover.
119
+ const target = resolve(io.cwd, invocation.out);
120
+ // Unpredictable name, created exclusively ("wx"): never follows or reuses an existing path.
121
+ const temporary = `${target}.${randomUUID()}.tmp`;
122
+ let created = false;
123
+ try {
124
+ const fd = openSync(temporary, "wx");
125
+ created = true; // ours from here on: remove it on any later failure
126
+ try {
127
+ // writeFileSync on a descriptor loops until every byte is written (writeSync may write fewer).
128
+ writeFileSync(fd, result.svg);
129
+ }
130
+ finally {
131
+ closeSync(fd);
132
+ }
133
+ renameSync(temporary, target);
134
+ }
135
+ catch (error) {
136
+ if (created)
137
+ rmSync(temporary, { force: true });
138
+ io.error(`cannot write ${invocation.out}: ${error instanceof Error ? error.message : String(error)}`);
139
+ return 1;
140
+ }
141
+ io.log(`wrote ${invocation.out}`);
142
+ return 0;
143
+ };
144
+ // Real paths on both sides: an installed bin is a symlink in node_modules/.bin.
145
+ const isMain = (() => {
146
+ if (process.argv[1] === undefined)
147
+ return false;
148
+ try {
149
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
150
+ }
151
+ catch {
152
+ return false;
153
+ }
154
+ })();
155
+ if (isMain) {
156
+ process.exitCode = runCover(process.argv.slice(2), { cwd: process.env.INIT_CWD ?? process.cwd(), log: console.log, error: console.error });
157
+ }
@@ -0,0 +1,32 @@
1
+ import { type PieceName } from "./library.ts";
2
+ import { type SvgNode } from "./node.ts";
3
+ import { type Problem } from "./params.ts";
4
+ export declare const SAFE_ID: RegExp;
5
+ export type CoverPiece = {
6
+ piece: PieceName;
7
+ } & Record<string, unknown>;
8
+ export type CustomNode = {
9
+ tag: string;
10
+ attrs?: Record<string, unknown>;
11
+ children?: (CustomNode | string)[];
12
+ };
13
+ export type CoverSpec = {
14
+ id: string;
15
+ title: string;
16
+ description: string;
17
+ background: string;
18
+ rings: {
19
+ cx: number;
20
+ cy: number;
21
+ radius?: number;
22
+ };
23
+ pieces: CoverPiece[];
24
+ custom?: CustomNode;
25
+ };
26
+ export declare const backgroundNames: () => string[];
27
+ /** Compares JSON paths: segment by segment, array indexes as numbers, names by code point. */
28
+ export declare const comparePaths: (a: string, b: string) => number;
29
+ /** Every problem of a parsed spec, sorted by path; empty when the spec is valid. */
30
+ export declare const validateCoverSpec: (spec: unknown) => Problem[];
31
+ /** The cover's node tree. The spec must be valid (validateCoverSpec returned no problem). */
32
+ export declare const coverTree: (spec: CoverSpec) => SvgNode;