decklight 0.1.0 → 0.3.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 (139) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +105 -183
  3. package/SPEC.md +861 -74
  4. package/cli/agents.mjs +206 -0
  5. package/cli/associate.mjs +279 -0
  6. package/cli/audit.mjs +424 -0
  7. package/cli/bundle.mjs +210 -45
  8. package/cli/deckfile.mjs +233 -0
  9. package/cli/decklight.mjs +216 -5
  10. package/cli/dev.mjs +455 -0
  11. package/cli/edit.mjs +733 -63
  12. package/cli/extension.mjs +108 -0
  13. package/cli/git.mjs +141 -0
  14. package/cli/import.mjs +398 -0
  15. package/cli/init.mjs +465 -121
  16. package/cli/loader.mjs +263 -0
  17. package/cli/marketplace.mjs +730 -0
  18. package/cli/pdf.mjs +156 -0
  19. package/cli/pkg.mjs +69 -0
  20. package/cli/plugin.mjs +646 -0
  21. package/cli/port-conflict.mjs +94 -0
  22. package/cli/present.mjs +560 -0
  23. package/cli/publish.mjs +342 -0
  24. package/cli/qr.mjs +334 -0
  25. package/cli/rec.mjs +12 -8
  26. package/cli/remote.mjs +149 -0
  27. package/cli/report-bug.mjs +97 -0
  28. package/cli/restore.mjs +174 -0
  29. package/cli/serve.mjs +247 -0
  30. package/cli/sign.mjs +216 -0
  31. package/cli/skill-content.mjs +222 -0
  32. package/cli/skills.mjs +338 -0
  33. package/cli/supervise.mjs +57 -0
  34. package/cli/theme.mjs +201 -0
  35. package/cli/units.mjs +488 -0
  36. package/cli/upgrade.mjs +250 -0
  37. package/cli/util.mjs +90 -0
  38. package/cli/wizard.mjs +432 -0
  39. package/cli/zip.mjs +121 -0
  40. package/dist/decklight.css +949 -72
  41. package/dist/decklight.js +220 -103
  42. package/dist/decklight.js.map +4 -4
  43. package/docs/architecture.svg +1 -1
  44. package/package.json +9 -6
  45. package/themes/README.md +6 -4
  46. package/themes/aurora.css +4 -1
  47. package/themes/berry.css +4 -1
  48. package/themes/carbon.css +4 -1
  49. package/themes/citrus.css +4 -1
  50. package/themes/coastal.css +4 -1
  51. package/themes/cosmos.css +4 -1
  52. package/themes/dune.css +4 -1
  53. package/themes/eclipse.css +4 -1
  54. package/themes/ember.css +4 -1
  55. package/themes/fjord.css +4 -1
  56. package/themes/gallery.html +3 -11
  57. package/themes/glacier.css +4 -1
  58. package/themes/graphite.css +4 -1
  59. package/themes/harvest.css +4 -1
  60. package/themes/ibm-modern.css +4 -1
  61. package/themes/ink.css +4 -1
  62. package/themes/latte.css +4 -1
  63. package/themes/linen.css +4 -1
  64. package/themes/meadow.css +4 -1
  65. package/themes/metropolis.css +4 -1
  66. package/themes/midnight.css +4 -1
  67. package/themes/mint.css +4 -1
  68. package/themes/moss.css +4 -1
  69. package/themes/obsidian.css +4 -1
  70. package/themes/orchid.css +4 -1
  71. package/themes/packs.json +4 -31
  72. package/themes/paper.css +4 -1
  73. package/themes/peony.css +4 -1
  74. package/themes/porcelain.css +4 -1
  75. package/themes/reveal-beige.css +4 -1
  76. package/themes/reveal-black.css +4 -1
  77. package/themes/reveal-blood.css +4 -1
  78. package/themes/reveal-dracula.css +4 -1
  79. package/themes/reveal-league.css +4 -1
  80. package/themes/reveal-moon.css +4 -1
  81. package/themes/reveal-night.css +4 -1
  82. package/themes/reveal-serif.css +4 -1
  83. package/themes/reveal-simple.css +4 -1
  84. package/themes/reveal-sky.css +4 -1
  85. package/themes/reveal-solarized.css +4 -1
  86. package/themes/reveal-white.css +4 -1
  87. package/themes/sepia.css +4 -1
  88. package/themes/seriph.css +4 -1
  89. package/themes/slate.css +4 -1
  90. package/themes/storm.css +4 -1
  91. package/themes/synthwave.css +4 -1
  92. package/themes/velvet.css +4 -1
  93. package/themes/yamabuki.css +120 -0
  94. package/tools/args.mjs +32 -0
  95. package/tools/bridge.mjs +30 -0
  96. package/tools/chrome.mjs +52 -0
  97. package/tools/color.mjs +110 -0
  98. package/tools/deck-html.mjs +138 -0
  99. package/tools/elevenlabs-tts.mjs +248 -0
  100. package/tools/escape.mjs +40 -0
  101. package/tools/extension-check-runner.mjs +41 -0
  102. package/tools/extension-check.mjs +266 -0
  103. package/tools/gemini-tts.mjs +44 -4
  104. package/tools/lipsync-engines.mjs +81 -0
  105. package/tools/lipsync-server.mjs +290 -0
  106. package/tools/lipsync.mjs +181 -0
  107. package/tools/local-voice.mjs +209 -0
  108. package/tools/ooxml.mjs +151 -0
  109. package/tools/pptx.mjs +320 -0
  110. package/tools/publish-site-voices.mjs +5 -1
  111. package/tools/publish-targets.mjs +143 -0
  112. package/tools/publish-voices.mjs +230 -0
  113. package/tools/shot.mjs +129 -0
  114. package/tools/theme-check.mjs +139 -0
  115. package/tools/tts-engines.mjs +455 -0
  116. package/tools/tts-setup.mjs +257 -0
  117. package/tools/veo.mjs +204 -0
  118. package/tools/video.mjs +316 -0
  119. package/tools/visemes.mjs +26 -0
  120. package/tools/voiceover-server.mjs +0 -0
  121. package/tools/voiceover.mjs +73 -39
  122. package/tools/zip.mjs +143 -0
  123. package/docs/demo.svg +0 -124
  124. package/themes/aliens.css +0 -84
  125. package/themes/apple2.css +0 -126
  126. package/themes/blade-runner.css +0 -83
  127. package/themes/c64.css +0 -85
  128. package/themes/friends.css +0 -82
  129. package/themes/gameboy.css +0 -118
  130. package/themes/genesis.css +0 -84
  131. package/themes/godfather.css +0 -82
  132. package/themes/ibm-oldschool.css +0 -84
  133. package/themes/miami-vice.css +0 -84
  134. package/themes/pulp-fiction.css +0 -84
  135. package/themes/severance.css +0 -82
  136. package/themes/snes.css +0 -82
  137. package/themes/star-wars.css +0 -85
  138. package/themes/stranger-things.css +0 -84
  139. package/themes/terminator.css +0 -84
@@ -1,3 +1,6 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500&display=swap');
2
5
 
3
6
  /* ═══════════════════════════════════════════════════════════════
@@ -7,7 +10,7 @@
7
10
  every gated pair fitted to the WCAG contract.
8
11
  rule-exception: R3 the canonical league cyan (#13daec) is the identity
9
12
  rule-exception: R2 the canonical gunmetal wash canvas
10
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
13
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
11
14
  ═══════════════════════════════════════════════════════════════ */
12
15
 
13
16
  .decklight {
@@ -1,10 +1,13 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · reveal-moon
3
6
  dark · base03 deep teal, cream headings, the eight canonical accents
4
7
  Inspired by Reveal.js 'moon' / Solarized Dark — palette kept canonical where possible,
5
8
  every gated pair fitted to the WCAG contract.
6
9
  rule-exception: R2 the canonical Solarized base03 deep-teal canvas
7
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
10
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
8
11
  ═══════════════════════════════════════════════════════════════ */
9
12
 
10
13
  .decklight {
@@ -1,3 +1,6 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&display=swap');
2
5
 
3
6
  /* ═══════════════════════════════════════════════════════════════
@@ -5,7 +8,7 @@
5
8
  dark · true dark, Montserrat caps, amber links
6
9
  Inspired by Reveal.js 'night' — palette kept canonical where possible,
7
10
  every gated pair fitted to the WCAG contract.
8
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
11
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
9
12
  ═══════════════════════════════════════════════════════════════ */
10
13
 
11
14
  .decklight {
@@ -1,9 +1,12 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · reveal-serif
3
6
  light · ivory, Palatino headings, browns and quiet inks
4
7
  Inspired by Reveal.js 'serif' — palette kept canonical where possible,
5
8
  every gated pair fitted to the WCAG contract.
6
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
9
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
7
10
  ═══════════════════════════════════════════════════════════════ */
8
11
 
9
12
  .decklight {
@@ -1,3 +1,6 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  @import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&display=swap');
2
5
 
3
6
  /* ═══════════════════════════════════════════════════════════════
@@ -5,7 +8,7 @@
5
8
  light · bare white, black Lato, one blue
6
9
  Inspired by Reveal.js 'simple' — palette kept canonical where possible,
7
10
  every gated pair fitted to the WCAG contract.
8
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
11
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
9
12
  ═══════════════════════════════════════════════════════════════ */
10
13
 
11
14
  .decklight {
@@ -1,3 +1,6 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  @import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600&display=swap');
2
5
 
3
6
  /* ═══════════════════════════════════════════════════════════════
@@ -6,7 +9,7 @@
6
9
  Inspired by Reveal.js 'sky' — palette kept canonical where possible,
7
10
  every gated pair fitted to the WCAG contract.
8
11
  rule-exception: R2 the canonical sky wash canvas
9
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
12
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
10
13
  ═══════════════════════════════════════════════════════════════ */
11
14
 
12
15
  .decklight {
@@ -1,10 +1,13 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · reveal-solarized
3
6
  light · the canonical base3 cream, equal-lightness accents
4
7
  Inspired by Reveal.js 'solarized' / Ethan Schoonover's Solarized Light — palette kept canonical where possible,
5
8
  every gated pair fitted to the WCAG contract.
6
9
  rule-exception: R2 the canonical Solarized base3 cream canvas
7
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
10
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
8
11
  ═══════════════════════════════════════════════════════════════ */
9
12
 
10
13
  .decklight {
@@ -1,9 +1,12 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · reveal-white
3
6
  light · plain white, dark ink, Reveal blue links, monokai code
4
7
  Inspired by Reveal.js 'white' — palette kept canonical where possible,
5
8
  every gated pair fitted to the WCAG contract.
6
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
9
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
7
10
  ═══════════════════════════════════════════════════════════════ */
8
11
 
9
12
  .decklight {
package/themes/sepia.css CHANGED
@@ -1,7 +1,10 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · sepia
3
6
  light · Antique folio — old-book paper, oxblood ink, light terminal
4
- Token contract: SPEC.md §5 — all values validated by test/contrast.mjs
7
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
5
8
  ═══════════════════════════════════════════════════════════════ */
6
9
 
7
10
  .decklight {
package/themes/seriph.css CHANGED
@@ -1,9 +1,12 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · seriph
3
6
  light · warm white, quiet serif display, a single restrained gold
4
7
  Inspired by Slidev's 'seriph' aesthetic — palette kept canonical where possible,
5
8
  every gated pair fitted to the WCAG contract.
6
- Token contract: SPEC.md §5 — validated by test/contrast.mjs
9
+ Token contract: SPEC.md THEMING — validated by test/contrast.mjs
7
10
  ═══════════════════════════════════════════════════════════════ */
8
11
 
9
12
  .decklight {
package/themes/slate.css CHANGED
@@ -1,7 +1,10 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · slate
3
6
  light · Boardroom neutral — deliberately safe, steel-blue accent
4
- Token contract: SPEC.md §5 — all values validated by test/contrast.mjs
7
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
5
8
  ═══════════════════════════════════════════════════════════════ */
6
9
 
7
10
  .decklight {
package/themes/storm.css CHANGED
@@ -1,7 +1,10 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · storm
3
6
  dark · Squall-line slate with one bolt of electric yellow
4
- Token contract: SPEC.md §5 — all values validated by test/contrast.mjs
7
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
5
8
  ═══════════════════════════════════════════════════════════════ */
6
9
 
7
10
  .decklight {
@@ -1,9 +1,12 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;800&display=swap');
2
5
 
3
6
  /* ═══════════════════════════════════════════════════════════════
4
7
  Decklight theme · synthwave
5
8
  dark · Retro-future horizon — neon pink and cyan over violet dusk
6
- Token contract: SPEC.md §5 — all values validated by test/contrast.mjs
9
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
7
10
  ═══════════════════════════════════════════════════════════════ */
8
11
 
9
12
  /* palette-rule exceptions (test/palette-rules.mjs):
package/themes/velvet.css CHANGED
@@ -1,7 +1,10 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
1
4
  /* ═══════════════════════════════════════════════════════════════
2
5
  Decklight theme · velvet
3
6
  dark · Plum velvet and rose gold — an opera box after dark
4
- Token contract: SPEC.md §5 — all values validated by test/contrast.mjs
7
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
5
8
  ═══════════════════════════════════════════════════════════════ */
6
9
 
7
10
  .decklight {
@@ -0,0 +1,120 @@
1
+ /* Copyright 2026 Gilles Philippart
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
4
+ /* ═══════════════════════════════════════════════════════════════
5
+ Decklight theme · yamabuki
6
+ dark · 山吹 — the Japanese golden-yellow, on cool ink
7
+ Named for 山吹色, the gold of the kerria flower. One warm accent on a
8
+ near-neutral cool ground; the red is reserved for things that fail.
9
+ Mono headings — the type is machine-set, like the subject.
10
+ Token contract: SPEC.md THEMING — all values validated by test/contrast.mjs
11
+ ═══════════════════════════════════════════════════════════════ */
12
+
13
+ .decklight {
14
+ /* ── canvas ─────────────────────────────── */
15
+ --bg: #14171c;
16
+ --bg-accent: #1b1f26;
17
+ --fg: #edece7;
18
+ --muted: #a0a4ab;
19
+
20
+ /* ── type ───────────────────────────────── */
21
+ --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
22
+ --font-heading: "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
23
+ --font-mono: "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
24
+ --heading-color: #f2b32c;
25
+ --heading-weight: 600;
26
+ --link: #f5c25c;
27
+
28
+ /* ── accent ─────────────────────────────── */
29
+ /* 山吹 proper is #f2b32c, which is s88 — over R3's saturation cap of 75. It
30
+ stays as the *displayed* gold (headings, diagram accent, prompt, keyword),
31
+ none of which R3 gates. --accent drives chrome, so it sits three points
32
+ under the cap at s74: the same gold, dimmed just enough to obey the rule
33
+ rather than claim an exception from it. */
34
+ --accent: #e3b445;
35
+ --accent-contrast: #171309;
36
+
37
+ /* ── blocks ─────────────────────────────── */
38
+ --block-bg: #1b1f26;
39
+ --block-border: 1px solid #2c313a;
40
+ --block-radius: 2px;
41
+ --shadow: 0 10px 30px rgba(6, 8, 11, 0.7);
42
+
43
+ /* ── code ───────────────────────────────── */
44
+ --code-bg: #1a1d23;
45
+ --code-fg: #edece7;
46
+ --hl-keyword: #f2b32c;
47
+ --hl-string: #b9cc72;
48
+ --hl-number: #e8a45e;
49
+ --hl-comment: #7c828c;
50
+ --hl-function: #85b4e3;
51
+ --hl-type: #cb9ada;
52
+ --hl-punct: #a0a4ab;
53
+
54
+ /* ── diagram ────────────────────────────── */
55
+ /* The fills stay dark: --d-muted is the binding gate (2.6 against every one
56
+ of them), and a light box would fail it long before the canvas noticed. */
57
+ --d-stroke: #7f858f;
58
+ --d-text: #edece7;
59
+ --d-muted: #a0a4ab;
60
+ --d-accent: #f2b32c;
61
+ --d-fill-1: #232830;
62
+ --d-fill-2: #2b2519;
63
+ --d-fill-3: #1e2730;
64
+ --d-fill-4: #2a2430;
65
+ --d-fill-5: #1f2c28;
66
+ --d-fill-6: #302422;
67
+
68
+ /* ── terminal ───────────────────────────── */
69
+ --term-bg: #0f1216;
70
+ --term-fg: #e2e0da;
71
+ --term-prompt: #f2b32c;
72
+ --term-cursor: #f2b32c;
73
+ --term-selection: rgba(242, 179, 44, 0.28);
74
+ --ansi-black: #8a8e96;
75
+ --ansi-red: #e0574b;
76
+ --ansi-green: #9cc474;
77
+ --ansi-yellow: #f2b32c;
78
+ --ansi-blue: #7fa8d8;
79
+ --ansi-magenta: #c99ad6;
80
+ --ansi-cyan: #79c6c0;
81
+ --ansi-white: #e2e0da;
82
+ --ansi-bright-black: #a8acb4;
83
+ --ansi-bright-red: #ef7f74;
84
+ --ansi-bright-green: #b7d996;
85
+ --ansi-bright-yellow: #f8cc6a;
86
+ --ansi-bright-blue: #a3c3e8;
87
+ --ansi-bright-magenta: #dcb6e5;
88
+ --ansi-bright-cyan: #9adcd7;
89
+ --ansi-bright-white: #f4f2ed;
90
+
91
+ /* ── builds ─────────────────────────────── */
92
+ --dim-opacity: 0.3;
93
+ }
94
+
95
+ /* Uppercase, tightly tracked eyebrows are part of the identity; the mono
96
+ heading face carries it without needing a webfont. */
97
+ .decklight h1,
98
+ .decklight h2 {
99
+ letter-spacing: -0.01em;
100
+ }
101
+
102
+ /* The subject renders one scanline at a time, so the canvas does too — a
103
+ 1-in-3 line at ~2% opacity. Screen only, never in print, and it steps aside
104
+ for anyone who asked for less motion-and-texture. */
105
+ @media screen {
106
+ .decklight::after {
107
+ content: "";
108
+ position: absolute;
109
+ inset: 0;
110
+ pointer-events: none;
111
+ z-index: 3;
112
+ background: repeating-linear-gradient(
113
+ to bottom,
114
+ rgba(255, 255, 255, 0.022) 0px,
115
+ rgba(255, 255, 255, 0.022) 1px,
116
+ transparent 1px,
117
+ transparent 3px
118
+ );
119
+ }
120
+ }
package/tools/args.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The small argv/entry-point helpers every Node script here reached for and
5
+ // re-rolled — nine byte-identical copies of `opt` alone. Lives under tools/
6
+ // because both the CLI and the tools are Node-only and the CLI already imports
7
+ // from tools/, so the dependency only ever flows one way.
8
+
9
+ import path from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ /**
13
+ * A reader over one argv array. Keeps the familiar call shape so a site swaps
14
+ * its hand-rolled one-liner for `const { opt } = argReader(args)` and every
15
+ * `opt('--flag', dflt)` below it stays exactly as written.
16
+ *
17
+ * opt('--flag', dflt) → the token after the first --flag, or dflt
18
+ * opts('--flag') → the token after every --flag (a repeatable flag)
19
+ */
20
+ export function argReader(argv) {
21
+ const opt = (flag, dflt) => { const i = argv.indexOf(flag); return i >= 0 ? argv[i + 1] : dflt; };
22
+ const opts = (flag) => argv.flatMap((a, i) => (a === flag ? [argv[i + 1]] : []));
23
+ return { opt, opts };
24
+ }
25
+
26
+ /**
27
+ * True when this module file was run directly (`node tools/x.mjs`), false when
28
+ * imported. Path-resolved so it survives relative paths, symlinks and Windows —
29
+ * the bare `import.meta.url === \`file://${process.argv[1]}\`` form does not.
30
+ */
31
+ export const isMain = (metaUrl) =>
32
+ !!process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(metaUrl);
@@ -0,0 +1,30 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The bits every localhost bridge repeats. A file://-opened deck probes these
5
+ // servers directly (origin "null"), so they answer wide-open CORS — but bind
6
+ // 127.0.0.1 only, so "open" means "open to this machine". The tts bridge, the
7
+ // lipsync bridge, and the edit live-reload server each carried their own copy.
8
+
9
+ /**
10
+ * CORS headers for a bridge. `expose` is the comma-list of response headers the
11
+ * player is allowed to read (cost estimates, cache flags); omit it when there
12
+ * are none.
13
+ */
14
+ export const corsHeaders = (expose = '') => ({
15
+ 'access-control-allow-origin': '*',
16
+ 'access-control-allow-methods': 'GET, POST, OPTIONS',
17
+ 'access-control-allow-headers': 'content-type',
18
+ ...(expose ? { 'access-control-expose-headers': expose } : {}),
19
+ });
20
+
21
+ /**
22
+ * Read a request body to a Buffer. Call it INSIDE the route's try: a client
23
+ * abort mid-request rejects the stream, and unguarded that would crash the
24
+ * whole bridge. Callers that want text `.toString()` the result.
25
+ */
26
+ export async function readBody(req) {
27
+ const chunks = [];
28
+ for await (const c of req) chunks.push(c);
29
+ return Buffer.concat(chunks);
30
+ }
@@ -0,0 +1,52 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // One place that knows how to start a headless Chrome. Four files were each
5
+ // carrying their own copy of this list, and each one was a chance to get it
6
+ // wrong — the character harness still had only the macOS path, so it could never
7
+ // have run in CI at all.
8
+
9
+ import { existsSync } from 'node:fs';
10
+
11
+ const CANDIDATES = [
12
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
13
+ '/usr/bin/google-chrome', '/usr/bin/google-chrome-stable',
14
+ '/usr/bin/chromium', '/usr/bin/chromium-browser',
15
+ '/snap/bin/chromium',
16
+ `${process.env.HOME}/.nix-profile/bin/chromium`,
17
+ ];
18
+
19
+ /** The browser to drive: $CHROME wins, else the first one installed. */
20
+ /**
21
+ * Where Chrome is, or null — the non-fatal half. `decklight report-bug` needs
22
+ * to REPORT that a machine has no Chrome, which it cannot do if merely asking
23
+ * exits the process.
24
+ */
25
+ export function findChrome() {
26
+ return process.env.CHROME || process.env.DECKLIGHT_CHROME
27
+ || CANDIDATES.find((p) => existsSync(p)) || null;
28
+ }
29
+
30
+ export function chromeBin(who = 'chrome') {
31
+ const bin = findChrome();
32
+ if (!bin) {
33
+ console.error(`${who}: no Chrome found — install one, or point $CHROME at it`);
34
+ process.exit(1);
35
+ }
36
+ return bin;
37
+ }
38
+
39
+ /**
40
+ * Flags every headless run needs.
41
+ *
42
+ * --no-sandbox ONLY under CI: GitHub's Ubuntu runners restrict unprivileged user
43
+ * namespaces (AppArmor), so Chrome's zygote cannot start there and dies with
44
+ * "No usable sandbox!". The container is ephemeral and the pages are our own test
45
+ * files, so dropping it there is fine — but a developer's machine keeps its
46
+ * sandbox, because that is where a real browser would open a real page.
47
+ */
48
+ export const chromeArgs = (...extra) => [
49
+ '--headless', '--disable-gpu',
50
+ ...(process.env.CI ? ['--no-sandbox'] : []),
51
+ ...extra,
52
+ ];
@@ -0,0 +1,110 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The color math the two theme graders (contrast.mjs, palette-rules.mjs) each
5
+ // carried a copy of — and the copies had drifted: only one parsed hsl(), only
6
+ // one saw the `white`/`black` keywords, and only one resolved var() references
7
+ // (so a token written `--accent: var(--brand)` was graded by one grader and
8
+ // silently skipped by the other). This is the single, superset implementation.
9
+ //
10
+ // NOT imported by test/themegen.test.mjs on purpose: that file keeps an
11
+ // independent copy of the contrast math so the theme GENERATOR can't grade its
12
+ // own homework. The constraint is "not the same code as src/core/themegen.js",
13
+ // which sharing this test-only module does not violate — but it is left alone
14
+ // to avoid the churn, and its independence is by design.
15
+
16
+ const NAMED = { white: [255, 255, 255], black: [0, 0, 0] };
17
+
18
+ /** A CSS color literal → [r,g,b] (0–255), or null. Handles #hex (3/4/6/8),
19
+ * rgb()/rgba(), hsl()/hsla(), and the white/black keywords. */
20
+ export function parseColor(str) {
21
+ str = str.trim();
22
+ if (NAMED[str.toLowerCase()]) return NAMED[str.toLowerCase()];
23
+ let m = str.match(/^#([0-9a-f]{3,8})$/i);
24
+ if (m) {
25
+ let h = m[1];
26
+ if (h.length === 3 || h.length === 4) h = [...h].map((c) => c + c).join('');
27
+ return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
28
+ }
29
+ m = str.match(/^rgba?\(([^)]*)\)$/i);
30
+ if (m) return m[1].split(/[\s,\/]+/).filter(Boolean).map(parseFloat).slice(0, 3);
31
+ m = str.match(/^hsla?\(([^)]*)\)$/i);
32
+ if (m) {
33
+ const p = m[1].split(/[\s,\/]+/).filter(Boolean);
34
+ const h = parseFloat(p[0]), s = parseFloat(p[1]) / 100, l = parseFloat(p[2]) / 100;
35
+ const c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(((h / 60) % 2) - 1)), mm = l - c / 2;
36
+ const seg = Math.floor(h / 60) % 6;
37
+ const rgb = [[c, x, 0], [x, c, 0], [0, c, x], [0, x, c], [x, 0, c], [c, 0, x]][seg];
38
+ return rgb.map((v) => Math.round((v + mm) * 255));
39
+ }
40
+ return null;
41
+ }
42
+
43
+ /** Every color literal in a value — handles a gradient's every stop, and the
44
+ * white/black keywords (R6 forbids a pure one). */
45
+ export function colorsIn(value) {
46
+ const out = [];
47
+ const re = /#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)|\b(?:white|black)\b/gi;
48
+ for (const m of value.match(re) ?? []) {
49
+ const c = parseColor(m);
50
+ if (c) out.push(c);
51
+ }
52
+ return out;
53
+ }
54
+
55
+ /** WCAG relative luminance of an [r,g,b]. */
56
+ export function luminance([r, g, b]) {
57
+ const lin = [r, g, b].map((v) => {
58
+ v /= 255;
59
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
60
+ });
61
+ return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2];
62
+ }
63
+
64
+ /** WCAG contrast ratio between two [r,g,b]. */
65
+ export function contrast(c1, c2) {
66
+ const [l1, l2] = [luminance(c1), luminance(c2)].sort((a, b) => b - a);
67
+ return (l1 + 0.05) / (l2 + 0.05);
68
+ }
69
+
70
+ /** [r,g,b] → { h(0–360), s(0–100), l(0–100), chroma(0–1) }. */
71
+ export function rgbToHsl([r, g, b]) {
72
+ r /= 255; g /= 255; b /= 255;
73
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
74
+ const l = (max + min) / 2;
75
+ const c = max - min;
76
+ let h = 0;
77
+ if (c) {
78
+ if (max === r) h = ((g - b) / c) % 6;
79
+ else if (max === g) h = (b - r) / c + 2;
80
+ else h = (r - g) / c + 4;
81
+ h = (h * 60 + 360) % 360;
82
+ }
83
+ const s = c === 0 ? 0 : c / (1 - Math.abs(2 * l - 1));
84
+ return { h, s: s * 100, l: l * 100, chroma: c };
85
+ }
86
+
87
+ /**
88
+ * Parse a theme's CSS custom properties into { tokens, exceptions }. var()
89
+ * references are resolved (depth-limited) so `--accent: var(--brand)` grades as
90
+ * its target. `exceptions` maps a rule id (R2, …) to the reason a theme file
91
+ * declared with `rule-exception:`.
92
+ */
93
+ export function parseTheme(css) {
94
+ const tokens = {};
95
+ const noComments = css.replace(/\/\*[\s\S]*?\*\//g, '');
96
+ for (const m of noComments.matchAll(/--([a-z0-9-]+)\s*:\s*([^;]+);/gi)) {
97
+ tokens[m[1].toLowerCase()] = m[2].trim();
98
+ }
99
+ const resolve = (v, depth = 0) => {
100
+ if (depth > 5) return v;
101
+ return v.replace(/var\(--([a-z0-9-]+)\)/gi, (_, name) =>
102
+ tokens[name.toLowerCase()] !== undefined ? resolve(tokens[name.toLowerCase()], depth + 1) : _);
103
+ };
104
+ for (const k of Object.keys(tokens)) tokens[k] = resolve(tokens[k]);
105
+ const exceptions = {};
106
+ for (const m of css.matchAll(/rule-exception:\s*(R\d)\s+([^\n*]+)/g)) {
107
+ exceptions[m[1]] = m[2].trim();
108
+ }
109
+ return { tokens, exceptions };
110
+ }