@cameronsjo/artificer 0.27.0 → 0.28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # Artificer · Design System Handoff
2
2
 
3
3
  Cameron's personal design system, packaged for use in real codebases.
4
- **v0.27.0 · 2026** — new layout and doc-chrome primitives: `.container--page` for page padding, `.eyebrow`, `.subsection-title`, `.callout`, a `.kv--props` properties block, and an embed card on `.figure`. The shipped skills and reference drop stale guidance (AA contrast floor, current colour names, a boilerplate that follows the Hard rules), and every live-spec page now uses the system classes and tokens it used to hand-roll. See `CHANGELOG.md` for what changed.
4
+ **v0.28.0 · 2026** — new type: Recursive for interface chrome and Bricolage Grotesque for body prose, both variable so every weight is real, and the Obsidian theme follows. Sploot the corgi joins as the system's critter, drawn in block glyphs. A generated theme for the herdr desktop app, a first-class Obsidian mobile layer, and Obsidian callouts that match the system `.callout`. See `CHANGELOG.md` for what changed.
5
5
 
6
6
  ---
7
7
 
@@ -136,6 +136,7 @@ import 'artificer/artificer-icons.js' // only if using <i data-icon>
136
136
  import 'artificer/artificer-tabs.js' // only if using .tabs (ships the APG keyboard model)
137
137
  import 'artificer/artificer-options.js' // only if using .menu/.listbox/.palette (option navigation)
138
138
  import 'artificer/artificer-tree.js' // only if using .tree (ships the APG tree keyboard)
139
+ import 'artificer/artificer-sploot.js' // only if drawing Sploot (<span data-sploot>)
139
140
  ```
140
141
 
141
142
  The CSS uses CSS custom properties (variables) and `data-theme` attribute — no preprocessing needed.
@@ -221,19 +222,19 @@ These are starters, not the whole system. They cover the 80% case; for new patte
221
222
 
222
223
  ## Fonts
223
224
 
224
- Artificer ships three SIL OFL font faces (two typeface families), self-hosted as WOFF2 in `src/assets/fonts/`. **Pick the face by role** (see CLAUDE.md → "First decision — what surface is this?"):
225
+ Artificer ships three SIL OFL font families, self-hosted as WOFF2 in `src/assets/fonts/`. **Pick the face by role** (see CLAUDE.md → "First decision — what surface is this?"):
225
226
 
226
227
  - **JetBrains Mono** (weights 400 / 500 / 700) — body face on **tool surfaces** (dashboards, consoles, terminals, settings panels, data tables). Always used for code, identifiers, file paths, and numerals — even in document surfaces.
227
- - **iA Writer Quattro V** — `--font-body`, the prose face on **document surfaces** (writeups, READMEs, reports, design docs). Ships 400 only (plus italic), so bold headlines synthesize faux-bold.
228
- - **iA Writer Quattro S** — `--font-interface`, the chrome face: labels, controls, badges, form fields, nav, tabular UI numerals — on **both** tool and document surfaces. Ships 400 / 700 with italics.
228
+ - **Bricolage Grotesque** — `--font-body`, the prose face on **document surfaces** (writeups, READMEs, reports, design docs). One variable file, weights 200–800, with an optical-size axis that tightens headlines automatically.
229
+ - **Recursive** — `--font-interface`, the chrome face: labels, controls, badges, form fields, nav, tabular UI numerals — on **both** tool and document surfaces. One variable file, weights 300–1000, with a slant axis for italics; its digits are fixed-width by default.
229
230
 
230
- Both Quattro faces were designed by Bold Monday for iA Writer; humanist sans tuned to share rhythm with monospace. `--font-sans` remains resolvable as a legacy alias of `--font-body`.
231
+ Both replaced iA Writer Quattro S/V (ADR 0046). `--font-sans` remains resolvable as a legacy alias of `--font-body`.
231
232
 
232
- A useful rule of thumb: if the page has more than ~3 paragraphs of running prose, it's a document — set body in Quattro V. If it's mostly chrome around data, it's a tool — set body in JetBrains Mono. Mixing within a project is normal: the settings page is a tool, the README explaining it is a document.
233
+ A useful rule of thumb: if the page has more than ~3 paragraphs of running prose, it's a document — set body in `--font-body`. If it's mostly chrome around data, it's a tool — set body in JetBrains Mono. Mixing within a project is normal: the settings page is a tool, the README explaining it is a document.
233
234
 
234
- JetBrains Mono is on Google Fonts; Quattro is **not** — that's why we self-host. Each `@font-face` chain points at the bundled WOFF2 files and falls back through Iowan Old Style → Charter → Source Sans 3 → system-ui, so the page still renders if fonts haven't loaded yet.
235
+ All three are self-hosted from the bundled WOFF2 files (they are also on Google Fonts and Fontsource). The stacks fall back through Source Sans 3 → system-ui, so the page still renders if fonts haven't loaded yet.
235
236
 
236
- Full loading recipes, the weight-coverage table, and the Windows faux-bold disposition: **[`FONTS.md`](FONTS.md)**. Upstream source for both Quattro faces is [iaolo/iA-Fonts](https://github.com/iaolo/iA-Fonts).
237
+ Full loading recipes and the axis notes: **[`FONTS.md`](FONTS.md)**. Upstream sources: [arrowtype/recursive](https://github.com/arrowtype/recursive) and [ateliertriay/bricolage](https://github.com/ateliertriay/bricolage).
237
238
 
238
239
  ---
239
240
 
@@ -312,8 +313,8 @@ And the browser:
312
313
  directory without packing at all.
313
314
 
314
315
  Plus the terminal and TUI surfaces around them — Ghostty, WezTerm, tmux, gitmux, cmux,
315
- bat/delta, glamour, gum, fzf, eza, starship, yazi, lazygit, gh-dash, herdr, and
316
- flux. **`themes/README.md` carries the full list**; it is the one place that
316
+ bat/delta, glamour, gum, fzf, eza, starship, yazi, lazygit, gh-dash, herdr, the
317
+ herdr desktop app, and flux. **`themes/README.md` carries the full list**; it is the one place that
317
318
  enumerates them, so this section never has to be counted again.
318
319
 
319
320
  Everything except Obsidian is generated from `themes/_palette.json`. To re-tune
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cameronsjo/artificer",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Cameron's personal design system — AuDHD-friendly, dark-first, for tools and dashboards. Apache-2.0 but Cameron-first: published for my own reuse, unsupported, no stability guarantees implied.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Cameron Sjo",
@@ -51,6 +51,10 @@
51
51
  "types": "./types/whimsy.d.ts",
52
52
  "default": "./src/artificer-whimsy.js"
53
53
  },
54
+ "./sploot.js": {
55
+ "types": "./types/sploot.d.ts",
56
+ "default": "./src/artificer-sploot.js"
57
+ },
54
58
  "./react": {
55
59
  "types": "./dist/react/index.d.ts",
56
60
  "default": "./dist/react/index.js"
@@ -3,7 +3,7 @@ name: Artificer
3
3
  description: Cameron's personal design system. AuDHD-optimized, Ghostty-rooted, dark-first with a paper-stock light mode and a Jazz Age Deco palette (burnished gold + royal purple). Use for tools, dashboards, agent UIs, terminals, settings panels — anything that must stay calm until something demands action. Do NOT use for marketing sites, kid-facing UI, or anywhere the goal is delight-via-stimulation.
4
4
  ---
5
5
 
6
- # Artificer · v0.27.0
6
+ # Artificer · v0.28.0
7
7
 
8
8
  A neurodivergent-first design system for Cameron. Every token and rule here exists to reduce cognitive load for an AuDHD brain that **scans instead of reads** and holds **3–4 items** in working memory.
9
9
 
@@ -122,7 +122,7 @@ If you have **no file system** (chat-only artifact), inline the contents of `art
122
122
  | Pagination | `.pagination` + `.pagination__gap`; `[aria-current=page]` marks the page; prev/next disable at ends; counted ranges only — `components-extended.html` |
123
123
  | Persistent page banner | `.banner` + `--info/attention/urgent/success` + `.banner__body`/`.banner__actions` — a standing layout band, NOT the transient `.notif` — `components-extended.html` |
124
124
  | Footer / colophon / fine print / attribution | **Three zones, in order — 1 and 3 optional, the spine always present.** (1) a `.grid-auto` of `.colophon__label` sections; (2) `.colophon__spine` — three POSITIONAL slots: **identity · sign-off · links**, first child starts, last ends, middle centres on the page; (3) `.colophon__fine` for the legal tier. A site with only a sign-off and a site with a full disclosure grid use the same primitive and differ only in which zones they fill. Any slot may be empty — keep the element to hold its column. Links slot: `<a>` for navigation, `<button class="btn btn--link">` for a control that ACTS (an SPA switching views) — never an `<a>` with a click handler. Prose auto-sans even inside `.surface-tool`; `.surface-document` flips any other prose island back — `layout.html` |
125
- | Selected card / selected row / active choice | `.card--active` (`background: var(--bg)` + accent left border) for a card, `.is-active` (`background: var(--bg-raised)`) for a list row — never `--accent-fill` as a large surface bg, its only rated text color is `--on-accent` — `components.html` |
125
+ | Selected card / selected row / active choice | `.card--active` (`background: var(--bg)` + a full 1px accent ring) for a card, `.is-active` (`background: var(--bg-raised)`) for a list row — never `--accent-fill` as a large surface bg, its only rated text color is `--on-accent` — `components.html` |
126
126
  | Split pane / master-detail | `.split-pane` + `.pane--active`/`.pane--inactive`; recession marks the unfocused pane — `composition.html` |
127
127
  | Text workbench / editor panes / paste target | `.workbench` + `.workbench__pane` (`.workbench__header` + `.workbench__editor`); label lives in `.workbench__header` as a real `<label for>`, not a placeholder — a `.dash` BODY, not a sixth dash recipe — `composition.html` |
128
128
  | Status pill | `.badge--{tier}` with a `.dot--{tier}` inside — dot AND text, never color alone |
@@ -145,17 +145,18 @@ If you have **no file system** (chat-only artifact), inline the contents of `art
145
145
  | Architecture / flow diagram | `.dia-node`/`.dia-edge` on inline SVG — `diagrams.html` |
146
146
  | Syntax-highlighted code block | `.code-block` + the `.tok-*` roles — `components-extended.html` |
147
147
  | Brand wordmark | `.wordmark` (renders `artificer.`) — `README.html` |
148
+ | Brand critter / mascot / Sploot | `<span data-sploot="pose">` + `artificer-sploot.js` — the corgi in block glyphs; stand/droopy/sleep/sniff/mini, `.sploot--sm`/`--lg`, `data-sploot-helmet`; one per view — `sploot.html` |
148
149
  | Theme toggle | empty `<button class="theme-toggle" data-theme-toggle aria-label="Toggle theme">` — the module injects the glyph |
149
150
  | Tabular number | `.num` utility — sets `font-variant-numeric: tabular-nums`; drop on the cell, or the parent for a whole table — `data-display.html` |
150
151
  | Short hint paragraph under a figure or field | `.note` — sister of `.meta`, smaller (label-sm); inherits the body face, mono on tool surfaces / sans on document surfaces |
151
152
  | Eyebrow / overline label | `.eyebrow` (+ `.eyebrow--accent`) — uppercase label over a heading, block, or demo — `typography.html#doc-chrome` |
152
153
  | Doc-page subsection header | `<h3 class="subsection-title">` — mono 700 body-md; sibling under `.section-title` — `typography.html#doc-chrome` |
153
- | Callout / standing note | `.callout` + `.callout__title` (+ `--steel`/`--attention`/`--urgent`); the title names the tier in text — `typography.html#doc-chrome` |
154
- | Doc-page section header | `<h2 class="section-title">` — mono, uppercase, `--fg-secondary`, border-bottom rule; doc/spec chrome — `data-display.html` |
154
+ | Callout / standing note | `.callout` + `.callout__title` (+ `--steel`/`--attention`/`--urgent`) — an inset tier rule inside a bordered raised box (never a `border-left` on a rounded box); the title names the tier in text — `typography.html#doc-chrome` |
155
+ | Doc-page section header | `<h2 class="section-title">` — mono 500, mixed case, `--fg`, border-bottom rule; doc/spec chrome (uppercase tracking is for small labels only) — `data-display.html` |
155
156
  | Live-spec / doc-page example container | `<figure class="figure">` + `<figcaption class="meta">…</figcaption>` — `.figure--frame`/`--flush` modifiers — `data-display.html` |
156
- | Make it fun / playful / celebratory / rainbow | The sanctioned `.whimsy` layer, opt-in, one per view; never on chrome/status/data/errors — `whimsy.html` |
157
+ | Make it fun / playful / celebratory / rainbow | The sanctioned `.whimsy` layer, opt-in, one per view; never on chrome/status/data/errors. Palettes: spectrum (default), `.whimsy--brand`, `.whimsy--signature` (gold + purple), `.whimsy--silver`, `.whimsy--gold`. Pick by the "Which one?" table — `whimsy.html` |
157
158
  | Night sky behind a hero or header band | `data-whimsy="sky"` / `.whimsy-sky` + `Whimsy.starfield()` — flowing brand field + seeded stars, dark only, rests with its wordmark on one timer; never behind data/status/errors/body copy — `whimsy.html` pattern 10 |
158
- | Make it feel like paper / give it grain / material / texture / depth | `.tex-grain` / `.tex-dots` / `.tex-line` / `.tex-paper` / `.tex-raised`; hueless + motionless, never on data/status/errors — `texture.html` |
159
+ | Make it feel like paper / give it grain / material / texture / depth | `.tex-grain` / `.tex-dots` / `.tex-line` (`--hatch`/`--cross`/`--flute`/`--pinstripe`/`--arc`/`--ray`) / `.tex-paper` / `.tex-raised`, plus the drafting set `.tex-grid` (tool canvas), `.tex-ruled` (notes), `.tex-perf` (receipt card), `.tex-deboss` (decorative only); hueless + motionless, never on data/status/errors — `texture.html` |
159
160
  | Empty state / error / loading copy | `voice-and-tone.html` — never improvise microcopy |
160
161
  | Loading state / UI | `states.html` — pick by *duration*: nothing → disabled label → skeleton → progress → background |
161
162
  | Long wait, nothing to count | `.progress--indeterminate` + `role="progressbar"` + `aria-label` with concrete copy, NO `aria-valuenow/min/max` — `states.html` |
@@ -259,10 +260,10 @@ TYPE --font-mono JetBrains Mono
259
260
  terminals, data tables, settings panels)
260
261
  · ALWAYS for code, identifiers, file paths,
261
262
  numerals — including inside documents
262
- --font-body iA Writer Quattro V
263
+ --font-body Bricolage Grotesque
263
264
  · BODY FACE for document surfaces (writeups,
264
265
  READMEs, reports, design docs)
265
- --font-interface iA Writer Quattro S
266
+ --font-interface Recursive
266
267
  · Labels, controls, badges, form fields, nav
267
268
  — on both tool AND document surfaces
268
269
  · --font-sans is a legacy alias of --font-body
@@ -303,7 +304,7 @@ BADGES .badge + .badge--accent | --attention | --urgent | --success | --ghost
303
304
  tint, never a solid steel fill; no text clears AA on solid steel)
304
305
  DOTS .dot + .dot--accent | --attention | --urgent | --success
305
306
 
306
- PANES .pane--active (gold left border) · .pane--inactive (55% opacity, desaturated)
307
+ PANES .pane--active (inset 1px accent outline) · .pane--inactive (55% opacity, desaturated)
307
308
 
308
309
  KBD <kbd>⌘ ↵</kbd>
309
310
  THEME <button class="theme-toggle" data-theme-toggle aria-label="Toggle theme"></button>
@@ -0,0 +1,303 @@
1
+ /* ═══════════════════════════════════════════════════════════════════════════
2
+ ARTIFICER · Sploot
3
+ The system's critter: a Pembroke corgi, named for the flat-out,
4
+ back-legs-behind lounge corgis are known for. Drawn as real text — quadrant
5
+ block glyphs, 2×2 pixels per character — so it renders in JetBrains Mono
6
+ and copy-pastes into a terminal intact. Gold (--accent), single-tone,
7
+ static. Styles live in artificer.css (.sploot); doctrine in CLAUDE.md
8
+ § Brand; reference page live-spec/sploot.html.
9
+
10
+ The pixel grids below are the ONE source for every pose. Everything else
11
+ (text layers here, SVG rects on a stats card, a favicon) derives from them.
12
+ Quadrant pixels render tall (about 0.3 × 0.65 em), so a grid reads about
13
+ twice as wide as it looks in source: keep the body ~3× longer than tall,
14
+ the ears wide-based triangles, the legs one row.
15
+
16
+ Hook: <span data-sploot="stand"></span>
17
+ data-sploot stand | droopy | sleep | sniff | mini
18
+ data-sploot-helmet fishbowl space helmet over the head
19
+ data-sploot-decorative aria-hidden (another element carries the meaning)
20
+ class="sploot--sm" size (--mini / --sm / default / --lg)
21
+ API: window.ArtificerSploot = { POSES, SCARF, toGlyphs, markup, build,
22
+ hydrate, observe, season }
23
+ ═══════════════════════════════════════════════════════════════════════════ */
24
+
25
+ (function () {
26
+ 'use strict';
27
+
28
+ // `#` is a pixel; anything else is empty. Every pose but `mini` is 30×8, so
29
+ // poses swap in place without the layout moving.
30
+ var POSES = {
31
+ // Ears up, fox snout, eye, long loaf, fluffy rump, four stubby legs.
32
+ stand: [
33
+ '....................#...#.....',
34
+ '...................###.###....',
35
+ '...................#######....',
36
+ '.####################.######..',
37
+ '##############################',
38
+ '##########################....',
39
+ '.#######################......',
40
+ '...##..##..........##..##.....',
41
+ ],
42
+ // Ears flopped forward, a little lower in the shoulders.
43
+ droopy: [
44
+ '..............................',
45
+ '..............................',
46
+ '....................##..##....',
47
+ '...................#######....',
48
+ '.####################.######..',
49
+ '##############################',
50
+ '#########################.....',
51
+ '...##..##..........##..##.....',
52
+ ],
53
+ // The namesake: belly down, eyes shut, back legs stretched out behind.
54
+ sleep: [
55
+ '..............................',
56
+ '..............................',
57
+ '....................#...#.....',
58
+ '...................###.###....',
59
+ '...########################...',
60
+ '..##########################..',
61
+ '..#########################...',
62
+ '############################..',
63
+ ],
64
+ // Nose down: the standing body with the head lowered two rows, tail up.
65
+ sniff: [
66
+ '..............................',
67
+ '..............................',
68
+ '.##.................#...#.....',
69
+ '.#####################.###....',
70
+ '##########################....',
71
+ '#####################.######..',
72
+ '.#############################',
73
+ '...##..##...........##..##....',
74
+ ],
75
+ // Two text rows — a marker (e.g. beside the current table-of-contents
76
+ // entry). Pair with .sploot--mini.
77
+ mini: [
78
+ '...........#.#..',
79
+ '..........#####.',
80
+ '.###########.###',
81
+ '..#..#.....#..#.',
82
+ ],
83
+ };
84
+
85
+ // Winter scarf for `stand`: a band around the neck, the end flying back
86
+ // over the shoulders. Its own layer so it can take --brand-purple.
87
+ var SCARF = [
88
+ '..............................',
89
+ '..............................',
90
+ '............#######...........',
91
+ '..................###.........',
92
+ '..................###.........',
93
+ '..................###.........',
94
+ '..............................',
95
+ '..............................',
96
+ ];
97
+
98
+ // Text overlays, already in glyph rows (they're characters, not pixels).
99
+ var TEXT_OVERLAYS = {
100
+ sleep: { cls: 'sploot__zzz', rows: [' z', ' z'] },
101
+ sniff: { cls: 'sploot__scent', rows: [' ', ' ', ' ', ' · ·'] },
102
+ };
103
+
104
+ var HELMET = [
105
+ ' ╭──────╮',
106
+ ' │ │',
107
+ ' │ │',
108
+ ' ╰──────╯',
109
+ ];
110
+
111
+ var DESCRIBE = {
112
+ stand: 'Sploot the corgi',
113
+ droopy: 'Sploot the corgi, ears drooping',
114
+ sleep: 'Sploot the corgi, asleep',
115
+ sniff: 'Sploot the corgi, sniffing the ground',
116
+ mini: 'Sploot the corgi',
117
+ };
118
+
119
+ // Index = TL | TR<<1 | BL<<2 | BR<<3 over each 2×2 pixel block.
120
+ var GLYPH = [' ', '▘', '▝', '▀', '▖', '▌', '▞', '▛',
121
+ '▗', '▚', '▐', '▜', '▄', '▙', '▟', '█'];
122
+
123
+ // Pixel grid → rows of quadrant glyphs. Trailing blanks are trimmed; an
124
+ // all-blank row becomes one space so the row keeps its line box.
125
+ function toGlyphs(grid) {
126
+ var width = 0;
127
+ grid.forEach(function (row) { if (row.length > width) width = row.length; });
128
+ var at = function (x, y) { return grid[y] && grid[y].charAt(x) === '#' ? 1 : 0; };
129
+ var rows = [];
130
+ for (var y = 0; y < grid.length; y += 2) {
131
+ var line = '';
132
+ for (var x = 0; x < width; x += 2) {
133
+ line += GLYPH[at(x, y) | (at(x + 1, y) << 1) | (at(x, y + 1) << 2) | (at(x + 1, y + 1) << 3)];
134
+ }
135
+ rows.push(line.replace(/\s+$/, '') || ' ');
136
+ }
137
+ return rows;
138
+ }
139
+
140
+ // Northern-hemisphere meteorological seasons, from a Date (default: now).
141
+ function season(date) {
142
+ var m = (date || new Date()).getMonth();
143
+ if (m === 11 || m <= 1) return 'winter';
144
+ if (m <= 4) return 'spring';
145
+ if (m <= 7) return 'summer';
146
+ return 'autumn';
147
+ }
148
+
149
+ var warned = {};
150
+ function resolvePose(pose) {
151
+ if (pose && Object.prototype.hasOwnProperty.call(POSES, pose)) return pose;
152
+ if (pose && !warned[pose] && typeof console !== 'undefined') {
153
+ warned[pose] = true;
154
+ console.warn('[ArtificerSploot] unknown pose "' + pose + '"; drawing "stand"');
155
+ }
156
+ return 'stand';
157
+ }
158
+
159
+ // The layers for a pose, in paint order: body, then pose overlay, then
160
+ // helmet. With a helmet every layer drops one row to make room for the dome.
161
+ function layers(pose, opts) {
162
+ var helmet = !!(opts && opts.helmet);
163
+ var lift = function (rows) { return helmet ? [' '].concat(rows) : rows; };
164
+ var out = [{ cls: 'sploot__body', rows: lift(toGlyphs(POSES[pose])) }];
165
+ if (pose === 'stand') out.push({ cls: 'sploot__scarf', rows: lift(toGlyphs(SCARF)) });
166
+ if (TEXT_OVERLAYS[pose]) out.push({ cls: TEXT_OVERLAYS[pose].cls, rows: lift(TEXT_OVERLAYS[pose].rows) });
167
+ if (helmet) out.push({ cls: 'sploot__helmet', rows: HELMET });
168
+ return out;
169
+ }
170
+
171
+ function describe(pose, opts) {
172
+ return DESCRIBE[pose] + (opts && opts.helmet ? ', in a fishbowl space helmet' : '') + ', drawn in block characters';
173
+ }
174
+
175
+ function escapeHtml(s) {
176
+ return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
177
+ }
178
+
179
+ // Server-side / build-time rendering: the same element build() makes, as an
180
+ // HTML string. Needs no DOM, so a static-site build can import this module
181
+ // for effect and render Sploot with JavaScript off in the browser.
182
+ function markup(pose, opts) {
183
+ opts = opts || {};
184
+ var p = resolvePose(pose);
185
+ var cls = ['sploot'];
186
+ if (opts.size) cls.push('sploot--' + escapeHtml(opts.size));
187
+ else if (p === 'mini') cls.push('sploot--mini');
188
+ if (opts.className) cls.push(escapeHtml(opts.className));
189
+ var a11y = opts.decorative
190
+ ? ' aria-hidden="true"'
191
+ : ' role="img" aria-label="' + escapeHtml(opts.label || describe(p, opts)) + '"';
192
+ var inner = layers(p, opts).map(function (l) {
193
+ return '<span class="sploot__layer ' + l.cls + '">' + escapeHtml(l.rows.join('\n')) + '</span>';
194
+ }).join('');
195
+ return '<span class="' + cls.join(' ') + '"' + a11y + '>' + inner + '</span>';
196
+ }
197
+
198
+ // Fill an existing host element (the data-sploot hook) or a fresh span.
199
+ function build(pose, opts, host) {
200
+ opts = opts || {};
201
+ var p = resolvePose(pose);
202
+ var el = host || document.createElement('span');
203
+ el.classList.add('sploot');
204
+ if (opts.size) el.classList.add('sploot--' + opts.size);
205
+ else if (p === 'mini' && !/\bsploot--/.test(el.className)) el.classList.add('sploot--mini');
206
+ if (opts.decorative) {
207
+ el.setAttribute('aria-hidden', 'true');
208
+ el.removeAttribute('role');
209
+ } else {
210
+ el.removeAttribute('aria-hidden');
211
+ el.setAttribute('role', 'img');
212
+ // Keep an author's label; refresh one we generated, so a re-posed
213
+ // Sploot never announces its previous pose.
214
+ if (opts.label) {
215
+ el.setAttribute('aria-label', opts.label);
216
+ el.removeAttribute('data-sploot-auto-label');
217
+ } else if (!el.hasAttribute('aria-label') || el.hasAttribute('data-sploot-auto-label')) {
218
+ el.setAttribute('aria-label', describe(p, opts));
219
+ el.setAttribute('data-sploot-auto-label', '');
220
+ }
221
+ }
222
+ while (el.firstChild) el.removeChild(el.firstChild);
223
+ layers(p, opts).forEach(function (l) {
224
+ var span = document.createElement('span');
225
+ span.className = 'sploot__layer ' + l.cls;
226
+ span.textContent = l.rows.join('\n');
227
+ el.appendChild(span);
228
+ });
229
+ return el;
230
+ }
231
+
232
+ function hydrate(root) {
233
+ var scope = root || document;
234
+ if (!scope.querySelectorAll) return;
235
+ var hosts = scope.querySelectorAll('[data-sploot]:not([data-sploot-hydrated])');
236
+ Array.prototype.forEach.call(hosts, function (el) {
237
+ build(el.getAttribute('data-sploot'), {
238
+ helmet: el.hasAttribute('data-sploot-helmet'),
239
+ decorative: el.hasAttribute('data-sploot-decorative'),
240
+ }, el);
241
+ el.setAttribute('data-sploot-hydrated', '');
242
+ });
243
+ }
244
+
245
+ // Hydrate now, then watch for inserted or re-posed hosts (SPA). Returns a
246
+ // disconnect fn.
247
+ function observe(root) {
248
+ var target = root || document.body;
249
+ hydrate(target);
250
+ if (typeof MutationObserver === 'undefined') return function () {};
251
+ var scheduled = false;
252
+ // rAF must be called as a method — a detached reference throws "Illegal
253
+ // invocation" — so wrap it rather than pick the function by ||.
254
+ var schedule = typeof window.requestAnimationFrame === 'function'
255
+ ? function (fn) { window.requestAnimationFrame(fn); }
256
+ : function (fn) { setTimeout(fn, 16); };
257
+ var mo = new MutationObserver(function (mutations) {
258
+ mutations.forEach(function (m) {
259
+ if (m.type === 'attributes') m.target.removeAttribute('data-sploot-hydrated');
260
+ });
261
+ if (scheduled) return;
262
+ scheduled = true;
263
+ schedule(function () { scheduled = false; hydrate(target); });
264
+ });
265
+ mo.observe(target, {
266
+ childList: true,
267
+ subtree: true,
268
+ attributes: true,
269
+ attributeFilter: ['data-sploot', 'data-sploot-helmet', 'data-sploot-decorative'],
270
+ });
271
+ return function () { mo.disconnect(); };
272
+ }
273
+
274
+ var api = {
275
+ POSES: POSES,
276
+ SCARF: SCARF,
277
+ toGlyphs: toGlyphs,
278
+ markup: markup,
279
+ build: build,
280
+ hydrate: hydrate,
281
+ observe: observe,
282
+ season: season,
283
+ };
284
+ // globalThis === window in a browser; in Node it lets a unit test or a
285
+ // static-site build import this file and call toGlyphs()/markup().
286
+ if (typeof window !== 'undefined') window.ArtificerSploot = api;
287
+ else if (typeof globalThis !== 'undefined') globalThis.ArtificerSploot = api;
288
+
289
+ if (typeof document === 'undefined') return;
290
+
291
+ // Stamp the season once, unless the page already did (a pre-paint script
292
+ // can set it to avoid any flash; Sploot itself hydrates after load anyway).
293
+ function autoInit() {
294
+ var html = document.documentElement;
295
+ if (!html.hasAttribute('data-season')) html.setAttribute('data-season', season());
296
+ observe(document.body);
297
+ }
298
+ if (document.readyState === 'loading') {
299
+ document.addEventListener('DOMContentLoaded', autoInit);
300
+ } else {
301
+ autoInit();
302
+ }
303
+ })();