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/agents.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2026 Gilles Philippart
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
// The AI-agent roster for `decklight
|
|
4
|
+
// The AI-agent roster for `decklight author` — which coding agents this machine
|
|
5
5
|
// can run, and how to hand one a single editing task without a TTY.
|
|
6
6
|
//
|
|
7
7
|
// Every entry is a one-shot, non-interactive invocation: the agent gets the
|
|
@@ -14,8 +14,17 @@
|
|
|
14
14
|
// of its headless mode). Order is preference order — the first detected
|
|
15
15
|
// agent is the default when the player doesn't name one.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// The roster is EXTENSIBLE the same way (SPEC AGENT_UNITS): an agent unit is a
|
|
18
|
+
// reference — a JSON descriptor naming a binary you already installed and the
|
|
19
|
+
// argv of its headless mode — never code decklight downloads and runs. That is
|
|
20
|
+
// what keeps this list open without putting it in UNIT_PINNING's risk class:
|
|
21
|
+
// the three shapes below (`-p …`, `exec --full-auto …`, `run -t …`) are a
|
|
22
|
+
// small, closed vocabulary, and a template expresses all of them.
|
|
23
|
+
|
|
24
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
25
|
+
import { delimiter, dirname, join } from 'node:path';
|
|
26
|
+
import { configHome } from './marketplace.mjs';
|
|
27
|
+
import { listUnits } from './units.mjs';
|
|
19
28
|
|
|
20
29
|
export const AGENTS = [
|
|
21
30
|
{
|
|
@@ -68,10 +77,52 @@ export const AGENTS = [
|
|
|
68
77
|
},
|
|
69
78
|
];
|
|
70
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Fill an installed agent's argv template (SPEC `AGENT_UNITS`).
|
|
82
|
+
*
|
|
83
|
+
* The whole vocabulary: `{prompt}` and `{deck}`, each substituted into ONE
|
|
84
|
+
* argv element. Never a shell string — the result is spawned as an argv
|
|
85
|
+
* array, so an agent name or a deck path containing a space, a quote or a
|
|
86
|
+
* semicolon is an argument and can never become a command.
|
|
87
|
+
*/
|
|
88
|
+
export function expandArgs(template, prompt, deck) {
|
|
89
|
+
return template.map((a) => String(a)
|
|
90
|
+
.replaceAll('{prompt}', prompt)
|
|
91
|
+
.replaceAll('{deck}', deck ?? ''));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Agents installed as units, as roster entries shaped like the built-ins.
|
|
96
|
+
*
|
|
97
|
+
* Read from the library, never the network — the same offline guarantee every
|
|
98
|
+
* other `findUnit`/`listUnits` lookup keeps. An installed descriptor that is
|
|
99
|
+
* malformed is SKIPPED rather than thrown on: a broken third-party entry must
|
|
100
|
+
* not take `A` down for the built-in agents beside it.
|
|
101
|
+
*/
|
|
102
|
+
export function installedAgents(home = configHome()) {
|
|
103
|
+
const out = [];
|
|
104
|
+
for (const unit of listUnits('agent', home)) {
|
|
105
|
+
try {
|
|
106
|
+
const d = JSON.parse(readFileSync(unit.path, 'utf8'));
|
|
107
|
+
if (typeof d.bin !== 'string' || !Array.isArray(d.args)) continue;
|
|
108
|
+
out.push({
|
|
109
|
+
name: unit.name,
|
|
110
|
+
label: typeof d.label === 'string' && d.label ? d.label : unit.name,
|
|
111
|
+
bin: d.bin,
|
|
112
|
+
installed: true,
|
|
113
|
+
args: (prompt, deck) => expandArgs(d.args, prompt, deck),
|
|
114
|
+
});
|
|
115
|
+
} catch { /* a descriptor we cannot read is one agent, not the roster */ }
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
71
120
|
/** Is `bin` runnable — an explicit path that exists, or a name on $PATH? */
|
|
72
121
|
export function onPath(bin, env = process.env) {
|
|
73
122
|
if (!bin) return false;
|
|
74
|
-
|
|
123
|
+
// An explicit path, spelled either way — a Windows one carries backslashes,
|
|
124
|
+
// and treating it as a bare name would send it looking down $PATH instead.
|
|
125
|
+
if (bin.includes('/') || bin.includes('\\')) return existsSync(bin);
|
|
75
126
|
const exts = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
76
127
|
for (const dir of (env.PATH || '').split(delimiter)) {
|
|
77
128
|
if (!dir) continue;
|
|
@@ -80,9 +131,58 @@ export function onPath(bin, env = process.env) {
|
|
|
80
131
|
return false;
|
|
81
132
|
}
|
|
82
133
|
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Every agent this machine can actually run, in preference order.
|
|
136
|
+
*
|
|
137
|
+
* Built-ins first, then installed units (SPEC `AGENT_UNITS`) — a unit whose
|
|
138
|
+
* name collides with a built-in is dropped rather than shadowing it, because
|
|
139
|
+
* silently replacing how `claude` is invoked is not something a catalog
|
|
140
|
+
* should be able to do to a machine.
|
|
141
|
+
*/
|
|
142
|
+
export function detectAgents({ env = process.env, hasBin = onPath, home } = {}) {
|
|
143
|
+
const builtIn = AGENTS.filter((a) => hasBin(a.bin, env));
|
|
144
|
+
const known = new Set(AGENTS.map((a) => a.name));
|
|
145
|
+
const extra = installedAgents(home).filter((a) => !known.has(a.name) && hasBin(a.bin, env));
|
|
146
|
+
return [...builtIn, ...extra];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ── the remembered preference (#125) ───────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
/** Where the preferred agent is remembered — beside the unit library. */
|
|
152
|
+
export const agentConfigPath = (home = configHome()) => join(home, 'agent.json');
|
|
153
|
+
|
|
154
|
+
/** The remembered agent's name, or null. A missing file is first-run. */
|
|
155
|
+
export function preferredAgent(home = configHome()) {
|
|
156
|
+
try {
|
|
157
|
+
const saved = JSON.parse(readFileSync(agentConfigPath(home), 'utf8'));
|
|
158
|
+
return typeof saved?.preferred === 'string' ? saved.preferred : null;
|
|
159
|
+
} catch { return null; }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Remember `name` as the agent `A` reaches for; `null` forgets it. */
|
|
163
|
+
export function setPreferredAgent(name, home = configHome()) {
|
|
164
|
+
const file = agentConfigPath(home);
|
|
165
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
166
|
+
writeFileSync(file, `${JSON.stringify({ preferred: name ?? null }, null, 2)}\n`);
|
|
167
|
+
return file;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Why `name` cannot be run, as a line naming the way out (#125).
|
|
172
|
+
*
|
|
173
|
+
* Never a silent fallback to a different agent: which agent edits your deck
|
|
174
|
+
* is not a substitutable detail, and one that quietly changed under a
|
|
175
|
+
* remembered preference would be the worst version of this feature.
|
|
176
|
+
*/
|
|
177
|
+
export function agentUnavailable(name, roster, home = configHome()) {
|
|
178
|
+
const have = roster.length
|
|
179
|
+
? `available here: ${roster.map((a) => a.name).join(', ')}`
|
|
180
|
+
: 'no agent CLI is detected on this machine';
|
|
181
|
+
if (!name) return `${have} — install one (claude, codex, bob, …), or: decklight agent add <name>`;
|
|
182
|
+
const known = AGENTS.some((a) => a.name === name) || installedAgents(home).some((a) => a.name === name);
|
|
183
|
+
return known
|
|
184
|
+
? `"${name}" is known but its command is not on PATH — install it, or pick another (${have})`
|
|
185
|
+
: `no agent named "${name}" — ${have}; a marketplace can teach decklight a new one: decklight agent add ${name}`;
|
|
86
186
|
}
|
|
87
187
|
|
|
88
188
|
/**
|
|
@@ -91,9 +191,15 @@ export function detectAgents({ env = process.env, hasBin = onPath } = {}) {
|
|
|
91
191
|
* file it should edit. Returns { bin, args, label } or null when the agent
|
|
92
192
|
* isn't available.
|
|
93
193
|
*/
|
|
94
|
-
export function agentCommand(name, instruction, deck, { env = process.env, hasBin = onPath } = {}) {
|
|
95
|
-
const roster = detectAgents({ env, hasBin });
|
|
96
|
-
|
|
194
|
+
export function agentCommand(name, instruction, deck, { env = process.env, hasBin = onPath, home } = {}) {
|
|
195
|
+
const roster = detectAgents({ env, hasBin, home });
|
|
196
|
+
// Precedence, matching how every other saved choice resolves (PRESENTING):
|
|
197
|
+
// an explicit name > the remembered preference > the first detected agent.
|
|
198
|
+
// A remembered agent that is NOT available falls through to null rather
|
|
199
|
+
// than to roster[0] — `agentUnavailable` then says which one is missing,
|
|
200
|
+
// because a different agent silently editing your deck is worse than none.
|
|
201
|
+
const wanted = name ?? preferredAgent(home);
|
|
202
|
+
const agent = wanted ? roster.find((a) => a.name === wanted) : roster[0];
|
|
97
203
|
if (!agent) return null;
|
|
98
204
|
const prompt = `Edit the Decklight deck file "${deck}" — a single-file HTML presentation ` +
|
|
99
205
|
'(one top-level <section> per slide; see SPEC.md or the decklight skill if present). ' +
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Gilles Philippart
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `decklight associate` — make a double-clicked `.decklight` open in `present`
|
|
7
|
+
* (MARKETPLACE.md DECK_FILE#ASSOC).
|
|
8
|
+
*
|
|
9
|
+
* Without this, the container's whole point leaks away: the person who receives
|
|
10
|
+
* a deck double-clicks it, the OS has no idea what it is, and they end up
|
|
11
|
+
* either renaming it to `.html` (which works — the container degrades on
|
|
12
|
+
* purpose — but skips every check) or looking at a download dialog. The file
|
|
13
|
+
* association is what makes `present` the default way in rather than the way in
|
|
14
|
+
* for people who already read the docs.
|
|
15
|
+
*
|
|
16
|
+
* Three platforms, three unrelated mechanisms, and the honest summary is that
|
|
17
|
+
* they are the fiddly part of this feature:
|
|
18
|
+
*
|
|
19
|
+
* - **Linux** — a `.desktop` entry plus a shared-MIME-info XML declaring
|
|
20
|
+
* `application/vnd.decklight`, both under `~/.local/share`, then the two
|
|
21
|
+
* database refreshers if they exist. Fully wired here.
|
|
22
|
+
* - **macOS** — a UTI has to be *exported by an application bundle*; there is
|
|
23
|
+
* no per-user "declare a type" file. So a minimal `Decklight.app` is written
|
|
24
|
+
* (a directory with an `Info.plist` and a shell launcher) whose plist exports
|
|
25
|
+
* `io.decklight.deck` and claims the extension. `lsregister` is asked to
|
|
26
|
+
* notice it.
|
|
27
|
+
* - **Windows** — `reg add` under `HKCU\\Software\\Classes`, which needs no
|
|
28
|
+
* administrator and is what per-user file associations actually are.
|
|
29
|
+
*
|
|
30
|
+
* Every writer prints the paths it touched, and `--uninstall` removes exactly
|
|
31
|
+
* those. Nothing is written outside the user's own home.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { writeFileSync, mkdirSync, rmSync, existsSync, chmodSync } from 'node:fs';
|
|
35
|
+
import { execFileSync } from 'node:child_process';
|
|
36
|
+
import { homedir, platform } from 'node:os';
|
|
37
|
+
import path from 'node:path';
|
|
38
|
+
import { fileURLToPath } from 'node:url';
|
|
39
|
+
import { isMain } from '../tools/args.mjs';
|
|
40
|
+
import { DECK_EXT } from './deckfile.mjs';
|
|
41
|
+
|
|
42
|
+
export const MIME_TYPE = 'application/vnd.decklight';
|
|
43
|
+
export const UTI = 'io.decklight.deck';
|
|
44
|
+
|
|
45
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
46
|
+
const CLI = path.join(HERE, 'decklight.mjs');
|
|
47
|
+
|
|
48
|
+
const USAGE = `usage: decklight associate [--uninstall] [--print]
|
|
49
|
+
|
|
50
|
+
wires a double-clicked ${DECK_EXT} file to \`decklight present\`, so a deck
|
|
51
|
+
someone sent you opens verified instead of raw in a browser.
|
|
52
|
+
|
|
53
|
+
--uninstall remove what this command installed
|
|
54
|
+
--print show what would be written, and where; write nothing
|
|
55
|
+
|
|
56
|
+
Per-user only: everything lands under your home directory and no step needs
|
|
57
|
+
administrator rights. What gets written depends on the platform —
|
|
58
|
+
linux ~/.local/share/applications/decklight.desktop
|
|
59
|
+
~/.local/share/mime/packages/decklight.xml
|
|
60
|
+
darwin ~/Applications/Decklight.app (a minimal bundle: a UTI can only be
|
|
61
|
+
exported by an application, so there has to be one)
|
|
62
|
+
win32 HKCU\\Software\\Classes\\${DECK_EXT} and \\Decklight.Deck
|
|
63
|
+
|
|
64
|
+
A ${DECK_EXT} renamed to .html still opens in a plain browser whether or not
|
|
65
|
+
this ran — the container degrades to the deck it wraps by design. The
|
|
66
|
+
association buys the verified path, not the only path.`;
|
|
67
|
+
|
|
68
|
+
// ── linux ──────────────────────────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The launcher runs the CLI through the same node that is running now.
|
|
72
|
+
* `%f` (single local file) rather than `%F`: present takes one deck, and a
|
|
73
|
+
* multi-select that silently presented the first would be worse than one that
|
|
74
|
+
* opens two windows.
|
|
75
|
+
*/
|
|
76
|
+
export function linuxFiles(home = homedir(), node = process.execPath, cli = CLI) {
|
|
77
|
+
// posix.join, not join: these are LINUX filesystem paths. Built with the
|
|
78
|
+
// host's separator they come out as `C:\Users\x\.local\share\…` when the
|
|
79
|
+
// host is Windows — a path no Linux desktop would ever read, produced by a
|
|
80
|
+
// function whose whole job is to describe one. The same argument as
|
|
81
|
+
// `darwinFiles` below; both are pure text about somebody else's OS.
|
|
82
|
+
const join = path.posix.join;
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
path: join(home, '.local/share/applications/decklight.desktop'),
|
|
86
|
+
text: `[Desktop Entry]
|
|
87
|
+
Type=Application
|
|
88
|
+
Name=Decklight
|
|
89
|
+
Comment=Play a Decklight deck, verified and read-only
|
|
90
|
+
Exec=${node} ${cli} present %f
|
|
91
|
+
Terminal=true
|
|
92
|
+
NoDisplay=true
|
|
93
|
+
MimeType=${MIME_TYPE};
|
|
94
|
+
Categories=Office;Presentation;
|
|
95
|
+
`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
path: join(home, '.local/share/mime/packages/decklight.xml'),
|
|
99
|
+
text: `<?xml version="1.0" encoding="UTF-8"?>
|
|
100
|
+
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
|
101
|
+
<mime-type type="${MIME_TYPE}">
|
|
102
|
+
<comment>Decklight presentation</comment>
|
|
103
|
+
<glob pattern="*${DECK_EXT}"/>
|
|
104
|
+
<!-- The payload is HTML, so a magic match would collide with text/html;
|
|
105
|
+
the extension is the only unambiguous signal a container has. -->
|
|
106
|
+
<sub-class-of type="text/html"/>
|
|
107
|
+
</mime-type>
|
|
108
|
+
</mime-info>
|
|
109
|
+
`,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ── macOS ──────────────────────────────────────────────────────────────────
|
|
115
|
+
|
|
116
|
+
export function darwinFiles(home = homedir(), node = process.execPath, cli = CLI) {
|
|
117
|
+
const join = path.posix.join; // macOS paths, whatever host is spelling them
|
|
118
|
+
const app = join(home, 'Applications/Decklight.app');
|
|
119
|
+
return [
|
|
120
|
+
{
|
|
121
|
+
path: join(app, 'Contents/Info.plist'),
|
|
122
|
+
text: `<?xml version="1.0" encoding="UTF-8"?>
|
|
123
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
124
|
+
<plist version="1.0">
|
|
125
|
+
<dict>
|
|
126
|
+
<key>CFBundleIdentifier</key><string>${UTI}.app</string>
|
|
127
|
+
<key>CFBundleName</key><string>Decklight</string>
|
|
128
|
+
<key>CFBundleExecutable</key><string>decklight</string>
|
|
129
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
130
|
+
<key>LSMinimumSystemVersion</key><string>10.13</string>
|
|
131
|
+
<key>UTExportedTypeDeclarations</key>
|
|
132
|
+
<array><dict>
|
|
133
|
+
<key>UTTypeIdentifier</key><string>${UTI}</string>
|
|
134
|
+
<key>UTTypeDescription</key><string>Decklight presentation</string>
|
|
135
|
+
<key>UTTypeConformsTo</key><array><string>public.html</string></array>
|
|
136
|
+
<key>UTTypeTagSpecification</key>
|
|
137
|
+
<dict>
|
|
138
|
+
<key>public.filename-extension</key><array><string>${DECK_EXT.slice(1)}</string></array>
|
|
139
|
+
<key>public.mime-type</key><array><string>${MIME_TYPE}</string></array>
|
|
140
|
+
</dict>
|
|
141
|
+
</dict></array>
|
|
142
|
+
<key>CFBundleDocumentTypes</key>
|
|
143
|
+
<array><dict>
|
|
144
|
+
<key>CFBundleTypeName</key><string>Decklight presentation</string>
|
|
145
|
+
<key>CFBundleTypeRole</key><string>Viewer</string>
|
|
146
|
+
<key>LSHandlerRank</key><string>Owner</string>
|
|
147
|
+
<key>LSItemContentTypes</key><array><string>${UTI}</string></array>
|
|
148
|
+
</dict></array>
|
|
149
|
+
</dict>
|
|
150
|
+
</plist>
|
|
151
|
+
`,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
path: join(app, 'Contents/MacOS/decklight'),
|
|
155
|
+
mode: 0o755,
|
|
156
|
+
// Through Terminal, because present is a server that prints the label and
|
|
157
|
+
// then keeps running: launching it with no visible output would leave
|
|
158
|
+
// someone staring at a bouncing icon while the thing they need to read
|
|
159
|
+
// scrolls past in a log nobody opens.
|
|
160
|
+
//
|
|
161
|
+
// The deck path is the filename of a file someone *sent*, and this
|
|
162
|
+
// script runs before `present` checks a byte — so it must never be
|
|
163
|
+
// spliced into the `do script` text, where a quote in the name becomes
|
|
164
|
+
// shell. It rides as an osascript argument the whole way and is quoted
|
|
165
|
+
// by AppleScript's `quoted form of` at the last moment. The install
|
|
166
|
+
// paths are ours, baked as AppleScript string literals via
|
|
167
|
+
// JSON.stringify, the same escaping the Keynote import script uses.
|
|
168
|
+
text: `#!/bin/sh
|
|
169
|
+
# Generated by \`decklight associate\`. Opens the double-clicked deck in
|
|
170
|
+
# \`decklight present\`, in a Terminal window so its output is readable.
|
|
171
|
+
# The deck path stays an argument the whole way down (Finder → $1 →
|
|
172
|
+
# osascript argv → quoted form of): a filename is data, never code.
|
|
173
|
+
deck="$1"
|
|
174
|
+
[ -n "$deck" ] || exit 0
|
|
175
|
+
dir=$(dirname "$deck")
|
|
176
|
+
osascript - "$dir" "$deck" <<'DECKLIGHT_LAUNCH'
|
|
177
|
+
on run argv
|
|
178
|
+
set cmd to "cd " & quoted form of item 1 of argv & " && " & quoted form of ${JSON.stringify(node)} & " " & quoted form of ${JSON.stringify(cli)} & " present " & quoted form of item 2 of argv
|
|
179
|
+
tell application "Terminal" to do script cmd
|
|
180
|
+
tell application "Terminal" to activate
|
|
181
|
+
end run
|
|
182
|
+
DECKLIGHT_LAUNCH
|
|
183
|
+
`,
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ── windows ────────────────────────────────────────────────────────────────
|
|
189
|
+
|
|
190
|
+
/** The registry writes, as argv arrays — printable, and testable without a registry. */
|
|
191
|
+
export function windowsCommands(node = process.execPath, cli = CLI) {
|
|
192
|
+
const key = 'HKCU\\Software\\Classes';
|
|
193
|
+
return [
|
|
194
|
+
['reg', 'add', `${key}\\${DECK_EXT}`, '/ve', '/d', 'Decklight.Deck', '/f'],
|
|
195
|
+
['reg', 'add', `${key}\\${DECK_EXT}`, '/v', 'Content Type', '/d', MIME_TYPE, '/f'],
|
|
196
|
+
['reg', 'add', `${key}\\Decklight.Deck`, '/ve', '/d', 'Decklight presentation', '/f'],
|
|
197
|
+
['reg', 'add', `${key}\\Decklight.Deck\\shell\\open\\command`, '/ve', '/d',
|
|
198
|
+
`"${node}" "${cli}" present "%1"`, '/f'],
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const windowsUninstall = () => [
|
|
203
|
+
['reg', 'delete', `HKCU\\Software\\Classes\\${DECK_EXT}`, '/f'],
|
|
204
|
+
['reg', 'delete', 'HKCU\\Software\\Classes\\Decklight.Deck', '/f'],
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
// ── the command ────────────────────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
/** Refresh a desktop database if the tool is there; never fail over its absence. */
|
|
210
|
+
function refresh(argv) {
|
|
211
|
+
try { execFileSync(argv[0], argv.slice(1), { stdio: 'ignore' }); return true; }
|
|
212
|
+
catch { return false; }
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function planFor(os = platform()) {
|
|
216
|
+
if (os === 'linux') return { files: linuxFiles(), commands: [], os };
|
|
217
|
+
if (os === 'darwin') return { files: darwinFiles(), commands: [], os };
|
|
218
|
+
if (os === 'win32') return { files: [], commands: windowsCommands(), os };
|
|
219
|
+
return { files: [], commands: [], os, unsupported: true };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function associateMain(args = process.argv.slice(2)) {
|
|
223
|
+
if (args.includes('--help') || args.includes('-h')) { console.log(USAGE); return 0; }
|
|
224
|
+
const uninstall = args.includes('--uninstall');
|
|
225
|
+
const dryRun = args.includes('--print');
|
|
226
|
+
const plan = planFor();
|
|
227
|
+
|
|
228
|
+
if (plan.unsupported) {
|
|
229
|
+
console.error(`decklight associate: no file-association mechanism is wired for ${plan.os}`);
|
|
230
|
+
return 1;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (dryRun) {
|
|
234
|
+
for (const f of plan.files) console.log(`would write ${f.path}`);
|
|
235
|
+
for (const c of plan.commands) console.log(`would run ${c.join(' ')}`);
|
|
236
|
+
return 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (uninstall) {
|
|
240
|
+
for (const f of plan.files) {
|
|
241
|
+
// The macOS bundle is a directory this command created wholesale, so it
|
|
242
|
+
// goes wholesale; the two Linux files go individually.
|
|
243
|
+
const target = f.path.includes('Decklight.app') ? f.path.replace(/(Decklight\.app).*/, '$1') : f.path;
|
|
244
|
+
if (existsSync(target)) { rmSync(target, { recursive: true, force: true }); console.log(`removed ${target}`); }
|
|
245
|
+
}
|
|
246
|
+
for (const c of (plan.os === 'win32' ? windowsUninstall() : [])) refresh(c);
|
|
247
|
+
if (plan.os === 'linux') {
|
|
248
|
+
refresh(['update-mime-database', path.join(homedir(), '.local/share/mime')]);
|
|
249
|
+
refresh(['update-desktop-database', path.join(homedir(), '.local/share/applications')]);
|
|
250
|
+
}
|
|
251
|
+
console.log('the association is gone; a .decklight is an unknown file again');
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
for (const f of plan.files) {
|
|
256
|
+
mkdirSync(path.dirname(f.path), { recursive: true });
|
|
257
|
+
writeFileSync(f.path, f.text);
|
|
258
|
+
if (f.mode) chmodSync(f.path, f.mode);
|
|
259
|
+
console.log(`wrote ${f.path}`);
|
|
260
|
+
}
|
|
261
|
+
for (const c of plan.commands) {
|
|
262
|
+
if (!refresh(c)) { console.error(`failed: ${c.join(' ')}`); return 1; }
|
|
263
|
+
console.log(`ran ${c.join(' ')}`);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (plan.os === 'linux') {
|
|
267
|
+
const mime = refresh(['update-mime-database', path.join(homedir(), '.local/share/mime')]);
|
|
268
|
+
const desk = refresh(['update-desktop-database', path.join(homedir(), '.local/share/applications')]);
|
|
269
|
+
// Said plainly rather than swallowed: the files are correct either way, but
|
|
270
|
+
// without the refresh the desktop will not notice them until it is
|
|
271
|
+
// restarted, and a silent no-op here reads as a broken feature.
|
|
272
|
+
if (!mime || !desk) {
|
|
273
|
+
console.log('note: update-mime-database/update-desktop-database not found — the files are in place, '
|
|
274
|
+
+ 'but your desktop may not pick them up until it restarts');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (plan.os === 'darwin') {
|
|
278
|
+
refresh(['/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister',
|
|
279
|
+
'-f', path.join(homedir(), 'Applications/Decklight.app')]);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
console.log(`double-clicking a ${DECK_EXT} now opens: decklight present`);
|
|
283
|
+
return 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (isMain(import.meta.url)) process.exitCode = await associateMain();
|