decklight 0.2.0 → 0.4.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 +69 -31
- package/SPEC.md +881 -80
- package/cli/agents.mjs +116 -10
- package/cli/associate.mjs +286 -0
- package/cli/audit.mjs +424 -0
- package/cli/bundle.mjs +174 -46
- package/cli/deckfile.mjs +233 -0
- package/cli/decklight.mjs +201 -8
- package/cli/dev.mjs +244 -55
- package/cli/edit.mjs +577 -107
- package/cli/extension.mjs +108 -0
- package/cli/git.mjs +141 -0
- package/cli/import.mjs +398 -0
- package/cli/init.mjs +421 -116
- package/cli/loader.mjs +263 -0
- package/cli/marketplace.mjs +911 -0
- package/cli/pdf.mjs +156 -0
- package/cli/pkg.mjs +69 -0
- package/cli/plugin.mjs +654 -0
- package/cli/port-conflict.mjs +94 -0
- package/cli/present.mjs +564 -0
- package/cli/publish.mjs +342 -0
- package/cli/qr.mjs +334 -0
- package/cli/rec.mjs +5 -8
- package/cli/remote.mjs +149 -0
- package/cli/report-bug.mjs +97 -0
- package/cli/restore.mjs +174 -0
- package/cli/serve.mjs +247 -0
- package/cli/sign.mjs +216 -0
- package/cli/skill-content.mjs +222 -0
- package/cli/skills.mjs +338 -0
- package/cli/supervise.mjs +57 -0
- package/cli/theme.mjs +219 -0
- package/cli/units.mjs +500 -0
- package/cli/upgrade.mjs +250 -0
- package/cli/util.mjs +90 -0
- package/cli/wizard.mjs +432 -0
- package/cli/zip.mjs +121 -0
- package/dist/decklight.css +716 -29
- package/dist/decklight.js +198 -125
- package/dist/decklight.js.map +4 -4
- package/docs/architecture.svg +1 -1
- package/package.json +7 -5
- package/themes/README.md +6 -4
- package/themes/aurora.css +1 -1
- package/themes/berry.css +1 -1
- package/themes/carbon.css +1 -1
- package/themes/citrus.css +1 -1
- package/themes/coastal.css +1 -1
- package/themes/cosmos.css +1 -1
- package/themes/dune.css +1 -1
- package/themes/eclipse.css +1 -1
- package/themes/ember.css +1 -1
- package/themes/fjord.css +1 -1
- package/themes/gallery.html +3 -11
- package/themes/glacier.css +1 -1
- package/themes/graphite.css +1 -1
- package/themes/harvest.css +1 -1
- package/themes/ibm-modern.css +1 -1
- package/themes/ink.css +1 -1
- package/themes/latte.css +1 -1
- package/themes/linen.css +1 -1
- package/themes/meadow.css +1 -1
- package/themes/metropolis.css +1 -1
- package/themes/midnight.css +1 -1
- package/themes/mint.css +1 -1
- package/themes/moss.css +1 -1
- package/themes/obsidian.css +1 -1
- package/themes/orchid.css +1 -1
- package/themes/packs.json +2 -30
- package/themes/paper.css +1 -1
- package/themes/peony.css +1 -1
- package/themes/porcelain.css +1 -1
- package/themes/reveal-beige.css +1 -1
- package/themes/reveal-black.css +1 -1
- package/themes/reveal-blood.css +1 -1
- package/themes/reveal-dracula.css +1 -1
- package/themes/reveal-league.css +1 -1
- package/themes/reveal-moon.css +1 -1
- package/themes/reveal-night.css +1 -1
- package/themes/reveal-serif.css +1 -1
- package/themes/reveal-simple.css +1 -1
- package/themes/reveal-sky.css +1 -1
- package/themes/reveal-solarized.css +1 -1
- package/themes/reveal-white.css +1 -1
- package/themes/sepia.css +1 -1
- package/themes/seriph.css +1 -1
- package/themes/slate.css +1 -1
- package/themes/storm.css +1 -1
- package/themes/synthwave.css +1 -1
- package/themes/velvet.css +1 -1
- package/themes/yamabuki.css +1 -1
- package/tools/args.mjs +32 -0
- package/tools/bridge.mjs +30 -0
- package/tools/chrome.mjs +46 -11
- package/tools/color.mjs +110 -0
- package/tools/deck-html.mjs +138 -0
- package/tools/elevenlabs-tts.mjs +248 -0
- package/tools/escape.mjs +40 -0
- package/tools/extension-check-runner.mjs +41 -0
- package/tools/extension-check.mjs +266 -0
- package/tools/gemini-tts.mjs +25 -3
- package/tools/lipsync-engines.mjs +81 -0
- package/tools/lipsync-server.mjs +78 -37
- package/tools/lipsync.mjs +36 -21
- package/tools/local-voice.mjs +209 -0
- package/tools/ooxml.mjs +151 -0
- package/tools/pptx.mjs +320 -0
- package/tools/publish-site-voices.mjs +2 -1
- package/tools/publish-targets.mjs +143 -0
- package/tools/publish-voices.mjs +230 -0
- package/tools/shot.mjs +91 -47
- package/tools/theme-check.mjs +144 -0
- package/tools/tts-engines.mjs +270 -41
- package/tools/tts-setup.mjs +257 -0
- package/tools/veo.mjs +204 -0
- package/tools/video.mjs +440 -0
- package/tools/voiceover-server.mjs +163 -54
- package/tools/voiceover.mjs +24 -7
- package/tools/zip.mjs +143 -0
- package/docs/demo.svg +0 -124
- package/themes/aliens.css +0 -87
- package/themes/apple2.css +0 -129
- package/themes/blade-runner.css +0 -86
- package/themes/c64.css +0 -88
- package/themes/friends.css +0 -85
- package/themes/gameboy.css +0 -121
- package/themes/genesis.css +0 -87
- package/themes/godfather.css +0 -85
- package/themes/ibm-oldschool.css +0 -87
- package/themes/miami-vice.css +0 -87
- package/themes/pulp-fiction.css +0 -87
- package/themes/severance.css +0 -85
- package/themes/snes.css +0 -85
- package/themes/star-wars.css +0 -88
- package/themes/stranger-things.css +0 -87
- package/themes/terminator.css +0 -87
package/cli/theme.mjs
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Gilles Philippart
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
// decklight theme — install and validate themes that came from somewhere else.
|
|
6
|
+
//
|
|
7
|
+
// decklight theme check <file|url>
|
|
8
|
+
// decklight theme add <file|url> <deck.html> [--name x] [--dry-run]
|
|
9
|
+
//
|
|
10
|
+
// The distribution mechanism already half-existed: a theme is ONE portable CSS
|
|
11
|
+
// file, `⌃⇧T` already downloads a shareable one, `decklight bundle` already
|
|
12
|
+
// embeds whatever the deck carries. What was missing is the last mile in both
|
|
13
|
+
// directions — a way to prove a file satisfies the contract before sharing it,
|
|
14
|
+
// and a way to put someone else's file into a deck without hand-editing HTML.
|
|
15
|
+
//
|
|
16
|
+
// There is no registry and no version number. The distribution unit is the
|
|
17
|
+
// file — a repo, a gist, a download — and compatibility with a runtime IS
|
|
18
|
+
// passing that runtime's check. When the contract grows a token, `check` names
|
|
19
|
+
// exactly what an older theme is missing.
|
|
20
|
+
|
|
21
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import path, { resolve } from 'node:path';
|
|
23
|
+
import { argReader, isMain } from '../tools/args.mjs';
|
|
24
|
+
import { validateTheme, themeNameFrom, validThemeName, REQUIRED } from '../tools/theme-check.mjs';
|
|
25
|
+
import { checkoutPath, classifySource, configHome, MarketplaceError } from './marketplace.mjs';
|
|
26
|
+
|
|
27
|
+
const USAGE = `usage: decklight theme <check|add> …
|
|
28
|
+
|
|
29
|
+
decklight theme check <file|url>
|
|
30
|
+
run the SPEC THEMING token contract and the WCAG contrast gates on a theme file
|
|
31
|
+
EXAMPLE: decklight theme check nord-deep.css
|
|
32
|
+
|
|
33
|
+
decklight theme add <file|url> <deck.html> [--name <name>] [--dry-run]
|
|
34
|
+
validate a theme, then install it into the deck — it then behaves like a
|
|
35
|
+
shipped one: in the picker under "Added", reachable by , / . and ?theme=,
|
|
36
|
+
and carried by decklight bundle
|
|
37
|
+
EXAMPLE: decklight theme add https://gist.../nord-deep.css talk.html
|
|
38
|
+
|
|
39
|
+
--name <name> install under this name [the file's, minus .css]
|
|
40
|
+
--dry-run validate and report; touch nothing
|
|
41
|
+
|
|
42
|
+
a theme that does not pass is not installed — a deck cannot be made to carry
|
|
43
|
+
something the shipped set would not be allowed to contain`;
|
|
44
|
+
|
|
45
|
+
/** The <style> block an installed theme becomes, marked so the runtime groups it. */
|
|
46
|
+
export function themeStyleBlock(name, css) {
|
|
47
|
+
// </style> inside a theme's own comment would end the block early. Themes
|
|
48
|
+
// are CSS and have no business containing one, but a downloaded file is
|
|
49
|
+
// somebody else's, and "somebody else's" is exactly when to check.
|
|
50
|
+
const safe = css.replace(/<\/(style)/gi, '<\\/$1');
|
|
51
|
+
return `<style data-theme="${name}" data-theme-added media="not all">\n${safe.trim()}\n</style>`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Where an existing block for this name starts and ends, or null. */
|
|
55
|
+
export function findThemeBlock(html, name) {
|
|
56
|
+
const re = new RegExp(`<style[^>]*\\bdata-theme=["']${name}["'][^>]*>[\\s\\S]*?<\\/style>`, 'i');
|
|
57
|
+
const m = re.exec(html);
|
|
58
|
+
return m ? { start: m.index, end: m.index + m[0].length, text: m[0] } : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Put the block in the deck: replacing the theme's previous block if it has
|
|
63
|
+
* one (re-adding IS the update path — there is no auto-update), otherwise
|
|
64
|
+
* last in <head> so an active added theme wins the cascade over the deck's
|
|
65
|
+
* link or inline base theme.
|
|
66
|
+
*/
|
|
67
|
+
export function installTheme(html, name, css) {
|
|
68
|
+
const block = themeStyleBlock(name, css);
|
|
69
|
+
const existing = findThemeBlock(html, name);
|
|
70
|
+
if (existing) {
|
|
71
|
+
return { html: html.slice(0, existing.start) + block + html.slice(existing.end), replaced: true };
|
|
72
|
+
}
|
|
73
|
+
const head = /<\/head>/i.exec(html);
|
|
74
|
+
if (!head) return { html: null, replaced: false };
|
|
75
|
+
return {
|
|
76
|
+
html: html.slice(0, head.index) + block + '\n' + html.slice(head.index),
|
|
77
|
+
replaced: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Where a catalog entry's `source` actually lives.
|
|
83
|
+
*
|
|
84
|
+
* A manifest says `./themes/nord-deep.css`, which is relative to the
|
|
85
|
+
* MARKETPLACE — and by the time the catalog is a cached JSON file, the repo it
|
|
86
|
+
* came from is not the cwd of whoever is installing. So a relative entry
|
|
87
|
+
* resolves against what `marketplace add`/`update` left on disk for that
|
|
88
|
+
* marketplace: the CHECKOUT it cloned (MARKETPLACES#CLONE), or, for a local
|
|
89
|
+
* marketplace, the directory it was registered from.
|
|
90
|
+
*
|
|
91
|
+
* It used to build a `raw.githubusercontent.com` URL instead, and that was the
|
|
92
|
+
* private-marketplace bug in one line: the manifest could be read with the
|
|
93
|
+
* caller's git credentials while every entry's bytes were fetched with none,
|
|
94
|
+
* so a private catalog listed correctly and then 404'd on every install. It
|
|
95
|
+
* also read a moving ref — the manifest at one HEAD, each artifact at another
|
|
96
|
+
* — so an install could match no single commit of the marketplace. Resolving
|
|
97
|
+
* into the checkout closes both: same commit, same credentials, no network.
|
|
98
|
+
*
|
|
99
|
+
* An ABSOLUTE `https://` source is still fetched as written: an entry may
|
|
100
|
+
* legitimately point at a gist or a release asset outside its own repo.
|
|
101
|
+
*
|
|
102
|
+
* This lives in theme.mjs rather than in the author server on purpose. Reading
|
|
103
|
+
* an ARTIFACT on an explicit install is fine anywhere; fetching a CATALOG is
|
|
104
|
+
* what `registered, not fetched` forbids on a deck-serving path, and keeping the
|
|
105
|
+
* two in different files is what keeps the sweep in test/marketplace.test.mjs
|
|
106
|
+
* able to tell them apart.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} source the entry's `source`, as the manifest wrote it
|
|
109
|
+
* @param {{name?: string, source?: string}} marketplace registry name + registered source
|
|
110
|
+
*/
|
|
111
|
+
export function resolveSource(source, marketplace, home = configHome()) {
|
|
112
|
+
if (/^https?:\/\//i.test(source)) return source; // absolute already
|
|
113
|
+
const rel = source.replace(/^\.\//, '');
|
|
114
|
+
const { name, source: from } = marketplace ?? {};
|
|
115
|
+
if (name) {
|
|
116
|
+
const checkout = checkoutPath(home, name);
|
|
117
|
+
if (existsSync(checkout)) return path.join(checkout, rel);
|
|
118
|
+
}
|
|
119
|
+
if (!from) return source; // nothing to resolve against
|
|
120
|
+
if (classifySource(from).kind === 'local') return path.resolve(from, rel);
|
|
121
|
+
// Registered from a remote source with nothing cloned: the entry is real and
|
|
122
|
+
// its bytes are simply not here yet. Naming the one command that fixes it
|
|
123
|
+
// beats a fetch that would only work for a public repo (SPEC MARKETPLACE_REGISTRY).
|
|
124
|
+
throw new MarketplaceError(`${name ?? from} has no local checkout, so "${source}" cannot be read`
|
|
125
|
+
+ `\n its files arrive with the marketplace itself: decklight marketplace update ${name ?? ''}`.trimEnd());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Read a theme from disk or over https. */
|
|
129
|
+
export async function fetchTheme(source, { fetchImpl = fetch, read = readFileSync } = {}) {
|
|
130
|
+
if (/^https?:\/\//i.test(source)) {
|
|
131
|
+
const r = await fetchImpl(source);
|
|
132
|
+
if (!r.ok) throw new Error(`${source} — HTTP ${r.status}`);
|
|
133
|
+
return await r.text();
|
|
134
|
+
}
|
|
135
|
+
const p = resolve(source);
|
|
136
|
+
if (!existsSync(p)) throw new Error(`no such file: ${source}`);
|
|
137
|
+
return read(p, 'utf8');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The validation report, as the lines to print. */
|
|
141
|
+
export function reportLines(name, result) {
|
|
142
|
+
const out = [];
|
|
143
|
+
if (result.ok) {
|
|
144
|
+
out.push(`✔ ${name} — all ${REQUIRED.length} tokens present, contrast gates pass`);
|
|
145
|
+
const ex = Object.entries(result.exceptions ?? {});
|
|
146
|
+
for (const [rule, why] of ex) out.push(` ○ ${rule} waived — ${why}`);
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
out.push(`✘ ${name}`);
|
|
150
|
+
for (const e of result.errors) out.push(` ${e}`);
|
|
151
|
+
if (result.missing.length && !result.empty) {
|
|
152
|
+
out.push(` ${result.missing.length} of ${REQUIRED.length} tokens missing`
|
|
153
|
+
+ ' — a theme written against an older contract needs the new ones added (SPEC THEMING)');
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function checkMain(args) {
|
|
159
|
+
const [source] = args.filter((a) => !a.startsWith('-'));
|
|
160
|
+
if (!source) { console.error(`decklight theme check: needs a theme file or url\n\n${USAGE}`); return 1; }
|
|
161
|
+
let css;
|
|
162
|
+
try { css = await fetchTheme(source); } catch (e) { console.error(`decklight theme check: ${e.message}`); return 1; }
|
|
163
|
+
const name = themeNameFrom(source) || 'theme';
|
|
164
|
+
const result = validateTheme(css);
|
|
165
|
+
for (const line of reportLines(name, result)) console.log(line);
|
|
166
|
+
return result.ok ? 0 : 1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function addMain(args) {
|
|
170
|
+
const { opt } = argReader(args);
|
|
171
|
+
const positional = args.filter((a, i) => !a.startsWith('-') && args[i - 1] !== '--name');
|
|
172
|
+
const [source, deck] = positional;
|
|
173
|
+
if (!source || !deck) { console.error(`decklight theme add: needs a theme and a deck\n\n${USAGE}`); return 1; }
|
|
174
|
+
|
|
175
|
+
const name = opt('--name') ?? themeNameFrom(source);
|
|
176
|
+
if (!validThemeName(name)) {
|
|
177
|
+
console.error(`decklight theme add: "${name}" is not a usable theme name`);
|
|
178
|
+
console.error(' the runtime only resolves names matching [A-Za-z0-9_-]+ — pass --name to choose one');
|
|
179
|
+
return 1;
|
|
180
|
+
}
|
|
181
|
+
const deckPath = resolve(deck);
|
|
182
|
+
if (!existsSync(deckPath)) { console.error(`decklight theme add: no such deck: ${deck}`); return 1; }
|
|
183
|
+
|
|
184
|
+
let css;
|
|
185
|
+
try { css = await fetchTheme(source); } catch (e) { console.error(`decklight theme add: ${e.message}`); return 1; }
|
|
186
|
+
|
|
187
|
+
const result = validateTheme(css);
|
|
188
|
+
for (const line of reportLines(name, result)) console.log(line);
|
|
189
|
+
if (!result.ok) {
|
|
190
|
+
console.error(`\ndecklight theme add: ${name} was NOT installed — fix the report above and try again`);
|
|
191
|
+
return 1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const html = readFileSync(deckPath, 'utf8');
|
|
195
|
+
const { html: next, replaced } = installTheme(html, name, css);
|
|
196
|
+
if (next === null) { console.error(`decklight theme add: ${deck} has no </head> to install into`); return 1; }
|
|
197
|
+
|
|
198
|
+
if (args.includes('--dry-run')) {
|
|
199
|
+
console.log(`would ${replaced ? 'replace' : 'install'} ${name} in ${deck} (${(css.length / 1024).toFixed(1)} KB)`);
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
writeFileSync(deckPath, next);
|
|
203
|
+
console.log(`${replaced ? 'replaced' : 'installed'} ${name} in ${deck}`
|
|
204
|
+
+ ` — press T and look under "Added"${replaced ? '' : ', or open it with ?theme=' + name}`);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export async function themeMain(args = []) {
|
|
209
|
+
const sub = args[0];
|
|
210
|
+
if (!sub || sub === '--help' || sub === '-h' || sub === 'help') { console.log(USAGE); return sub ? 0 : 1; }
|
|
211
|
+
const rest = args.slice(1);
|
|
212
|
+
if (rest.includes('--help') || rest.includes('-h')) { console.log(USAGE); return 0; }
|
|
213
|
+
if (sub === 'check') return checkMain(rest);
|
|
214
|
+
if (sub === 'add') return addMain(rest);
|
|
215
|
+
console.error(`decklight theme: unknown subcommand "${sub}"\n\n${USAGE}`);
|
|
216
|
+
return 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (isMain(import.meta.url)) process.exit(await themeMain(process.argv.slice(2)));
|