decklight 0.2.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.
- package/README.md +69 -31
- package/SPEC.md +855 -80
- package/cli/agents.mjs +113 -9
- package/cli/associate.mjs +279 -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 +564 -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 +730 -0
- package/cli/pdf.mjs +156 -0
- package/cli/pkg.mjs +69 -0
- package/cli/plugin.mjs +646 -0
- package/cli/port-conflict.mjs +94 -0
- package/cli/present.mjs +560 -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 +201 -0
- package/cli/units.mjs +488 -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 +5 -4
- 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 +11 -2
- 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 +139 -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 +316 -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/plugin.mjs
ADDED
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Gilles Philippart
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `decklight plugin` — the presenter's own chrome, installed from a
|
|
7
|
+
* marketplace and loaded by `present` (MARKETPLACE.md PRESENT#PLUGINS).
|
|
8
|
+
*
|
|
9
|
+
* decklight plugin add <name[@marketplace]>
|
|
10
|
+
* decklight plugin list
|
|
11
|
+
* decklight plugin check <name | directory>
|
|
12
|
+
* decklight plugin remove <name>
|
|
13
|
+
*
|
|
14
|
+
* WHY THIS IS ALLOWED TO EXIST AT ALL. The asymmetry MARKETPLACE.md WHY is
|
|
15
|
+
* built on: a plugin is safe when the installer is the risk-bearer, and unsafe
|
|
16
|
+
* when it travels to an audience that consented to nothing. A presenter plugin
|
|
17
|
+
* never travels. It lives here, under the config home, and `bundle` cannot see
|
|
18
|
+
* it — nothing in this file is imported by the build.
|
|
19
|
+
*
|
|
20
|
+
* THE SCOPE RULE, AND WHERE IT IS ACTUALLY ENFORCED. Scope is **chrome only**:
|
|
21
|
+
* a plugin may add a timer, a teleprompter, a confidence monitor, and may not
|
|
22
|
+
* touch slide content. Otherwise a deck stops being a deterministic artifact
|
|
23
|
+
* and two people presenting the same file are presenting different decks.
|
|
24
|
+
*
|
|
25
|
+
* That rule is kept by the browser, not by this module:
|
|
26
|
+
*
|
|
27
|
+
* 1. STRUCTURE (the boundary). A plugin's code runs inside
|
|
28
|
+
* `<iframe sandbox="allow-scripts" srcdoc=…>`. No `allow-same-origin`, so
|
|
29
|
+
* the frame gets an **opaque origin** and `parent.document` throws
|
|
30
|
+
* `SecurityError`. There is no handle to a slide to misuse — not a rule
|
|
31
|
+
* about reaching for one, an inability to.
|
|
32
|
+
* 2. DECLARATION (the named refusal). `plugin.json` is checked against a
|
|
33
|
+
* CLOSED vocabulary, the way the wizard's field types are closed (SPEC
|
|
34
|
+
* ENGINES#WIZARD: core renders, a plugin only declares). A manifest that
|
|
35
|
+
* asks for slide content is refused out loud, before anything loads.
|
|
36
|
+
* 3. LINT (a courtesy, and labelled as one below). `pluginLint` greps for
|
|
37
|
+
* the reaches that only make sense against the deck's document. Those
|
|
38
|
+
* already fail at run time under (1); catching them here turns a silent
|
|
39
|
+
* `SecurityError` in someone's console into a message at install time.
|
|
40
|
+
* This layer carries **none** of the safety. Deleting it would not widen
|
|
41
|
+
* what a plugin can do, and it should never be described as if it would.
|
|
42
|
+
*
|
|
43
|
+
* WHAT IT COSTS THE DECK: nothing. The chrome is injected on the way OUT of
|
|
44
|
+
* the presenting server, after the ingredients label has already read the
|
|
45
|
+
* bytes on disk (PRESENT#AUDIT) and after strict mode has stripped what it
|
|
46
|
+
* could not account for (PRESENT#STRICT) — so a plugin is never audited as if
|
|
47
|
+
* it came from the deck, and never stripped as if it were unaccounted. The
|
|
48
|
+
* srcdoc frame needs no route and no CSP change (see `chromeMarkup`).
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
import {
|
|
52
|
+
existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync,
|
|
53
|
+
} from 'node:fs';
|
|
54
|
+
import { join, resolve, basename } from 'node:path';
|
|
55
|
+
import { isMain } from '../tools/args.mjs';
|
|
56
|
+
import { injectBeforeBodyEnd } from '../tools/deck-html.mjs';
|
|
57
|
+
// Cache reads only. `loadCatalog` and `resolveEntry` read JSON already on
|
|
58
|
+
// disk; the fetching half of marketplace.mjs is deliberately not imported
|
|
59
|
+
// here, because `present` imports this file and a presenting path that COULD
|
|
60
|
+
// fetch a catalog breaks registered-not-fetched (SPEC MARKETPLACE_REGISTRY) —
|
|
61
|
+
// a deck on a plane has to behave exactly like a deck at a desk. The one
|
|
62
|
+
// network call in this module is `fetchPlugin`, which is an ARTIFACT fetch on
|
|
63
|
+
// an explicit `plugin add`; `resolveSource` is imported dynamically there so
|
|
64
|
+
// it is not even resolved on the serving path.
|
|
65
|
+
import {
|
|
66
|
+
configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, NAME_RE,
|
|
67
|
+
} from './marketplace.mjs';
|
|
68
|
+
|
|
69
|
+
/** A failure with a message for a human — the mains print it, never a stack. */
|
|
70
|
+
export class PluginError extends Error {}
|
|
71
|
+
|
|
72
|
+
/** Where a presenter's own library lives (OPEN 3 resolved: `~/.decklight/`). */
|
|
73
|
+
export const pluginsDir = (home = configHome()) => join(home, 'plugins');
|
|
74
|
+
|
|
75
|
+
// ── the manifest vocabulary, closed on purpose ─────────────────────────────
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Where a plugin's frame may sit. A closed list rather than free CSS, for the
|
|
79
|
+
* reason the wizard's field types are closed: "chrome only" is enforceable
|
|
80
|
+
* exactly as long as a plugin cannot place its own markup over a slide. An
|
|
81
|
+
* arbitrary `top`/`left`/`width` would let a plugin cover the stage, which is
|
|
82
|
+
* not transforming content but is indistinguishable from it to the room.
|
|
83
|
+
*/
|
|
84
|
+
export const SLOTS = ['corner-tl', 'corner-tr', 'corner-bl', 'corner-br', 'edge-top', 'edge-bottom'];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* What a plugin may be told. `position` is the deck's place in itself;
|
|
88
|
+
* `notes` is the current slide's speaker notes.
|
|
89
|
+
*
|
|
90
|
+
* Notes ARE deck text, and letting them cross is a deliberate call rather than
|
|
91
|
+
* an oversight: a teleprompter is named in-scope chrome and a teleprompter
|
|
92
|
+
* without the deck's notes is a text box. Reading is not transforming — the
|
|
93
|
+
* determinism rule is about mutation, and the speaker view already puts these
|
|
94
|
+
* exact words on this exact machine. What keeps it honest is that it is
|
|
95
|
+
* DECLARED: a plugin gets notes only by asking for them in its manifest, and
|
|
96
|
+
* both `plugin list` and the `present` startup line say which plugins read
|
|
97
|
+
* them. A timer never sees a word of the talk.
|
|
98
|
+
*/
|
|
99
|
+
export const NEEDS = ['position', 'notes'];
|
|
100
|
+
|
|
101
|
+
/** Every key a manifest may carry. Anything else is refused, never ignored. */
|
|
102
|
+
export const MANIFEST_KEYS = ['name', 'title', 'slot', 'needs', 'version', 'description', 'width', 'height'];
|
|
103
|
+
|
|
104
|
+
// A frame big enough to be a teleprompter and too small to be a slide. The
|
|
105
|
+
// clamp is the same argument as the slot list: chrome that can fill the
|
|
106
|
+
// viewport is a cover, whatever its manifest calls it.
|
|
107
|
+
export const SIZE_LIMITS = { width: [40, 640], height: [24, 480] };
|
|
108
|
+
const DEFAULT_SIZE = { width: 200, height: 96 };
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Validate a manifest object. Returns `{ ok, manifest, errors }`, where every
|
|
112
|
+
* error is a `{ field, msg }` a human can act on — the refusal has to NAME the
|
|
113
|
+
* reason, or the scope rule is back to being documentation.
|
|
114
|
+
*/
|
|
115
|
+
export function validateManifest(data, { name: dirName } = {}) {
|
|
116
|
+
const errors = [];
|
|
117
|
+
const err = (field, msg) => errors.push({ field, msg });
|
|
118
|
+
if (typeof data !== 'object' || data === null || Array.isArray(data)) {
|
|
119
|
+
return { ok: false, manifest: null, errors: [{ field: '(top level)', msg: 'must be a JSON object' }] };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const key of Object.keys(data)) {
|
|
123
|
+
if (!MANIFEST_KEYS.includes(key)) {
|
|
124
|
+
// Refused rather than ignored, for the wizard's reason (ENGINES#WIZARD):
|
|
125
|
+
// a silently dropped key is a plugin asking for less than its author
|
|
126
|
+
// believed it was asking for.
|
|
127
|
+
err(key, `unknown key — a plugin manifest carries only: ${MANIFEST_KEYS.join(', ')}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (data.name === undefined) err('name', 'missing — the name the library files it under');
|
|
132
|
+
else if (typeof data.name !== 'string' || !NAME_RE.test(data.name)) {
|
|
133
|
+
err('name', `${JSON.stringify(data.name)} — letters, digits, - and _ only`);
|
|
134
|
+
} else if (dirName && data.name !== dirName) {
|
|
135
|
+
err('name', `"${data.name}" does not match the directory it lives in ("${dirName}")`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (data.slot === undefined) err('slot', `missing — where the chrome sits: ${SLOTS.join(', ')}`);
|
|
139
|
+
else if (!SLOTS.includes(data.slot)) {
|
|
140
|
+
err('slot', `${JSON.stringify(data.slot)} — not a slot. Chrome sits in one of: ${SLOTS.join(', ')}.`
|
|
141
|
+
+ ' The list is closed so that a plugin cannot place itself over the slides');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (data.needs !== undefined) {
|
|
145
|
+
if (!Array.isArray(data.needs)) err('needs', `must be an array of: ${NEEDS.join(', ')}`);
|
|
146
|
+
else {
|
|
147
|
+
for (const n of data.needs) {
|
|
148
|
+
if (NEEDS.includes(n)) continue;
|
|
149
|
+
// The refusal the ticket is actually about. It has to say WHY, because
|
|
150
|
+
// the author of a refused plugin is the only person who can fix it.
|
|
151
|
+
err('needs', `${JSON.stringify(n)} — a presenter plugin is chrome only, and may ask for: ${NEEDS.join(', ')}.`
|
|
152
|
+
+ ' It cannot reach slide content: a deck has to stay a deterministic artifact,'
|
|
153
|
+
+ ' or two people presenting the same file are presenting different decks.'
|
|
154
|
+
+ ' (Its code runs in a sandboxed frame with an opaque origin, so this would'
|
|
155
|
+
+ ' fail at run time regardless — refused here so it fails where you can read it.)');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
for (const dim of ['width', 'height']) {
|
|
161
|
+
if (data[dim] === undefined) continue;
|
|
162
|
+
const [lo, hi] = SIZE_LIMITS[dim];
|
|
163
|
+
if (typeof data[dim] !== 'number' || !Number.isFinite(data[dim])) err(dim, 'must be a number of CSS pixels');
|
|
164
|
+
else if (data[dim] < lo || data[dim] > hi) {
|
|
165
|
+
err(dim, `${data[dim]} — outside ${lo}–${hi}px. Chrome that can fill the viewport is a cover over the slides`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (const s of ['title', 'version', 'description']) {
|
|
170
|
+
if (data[s] !== undefined && typeof data[s] !== 'string') err(s, 'must be a string');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return { ok: errors.length === 0, manifest: errors.length ? null : normalize(data), errors };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const normalize = (data) => ({
|
|
177
|
+
...DEFAULT_SIZE,
|
|
178
|
+
needs: ['position'],
|
|
179
|
+
title: data.name,
|
|
180
|
+
...data,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
/** Parse + validate a `plugin.json` text. */
|
|
184
|
+
export function readManifest(raw, opts) {
|
|
185
|
+
let data;
|
|
186
|
+
try { data = JSON.parse(raw); } catch (e) {
|
|
187
|
+
return { ok: false, manifest: null, errors: [{ field: '(json)', msg: String(e.message).replace(/ in JSON.*$/, '') }] };
|
|
188
|
+
}
|
|
189
|
+
return validateManifest(data, opts);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ── the lint, which is a courtesy and not the boundary ─────────────────────
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Reaches that only make sense against the DECK's document, and therefore
|
|
196
|
+
* only make sense from a plugin that misunderstood where it runs.
|
|
197
|
+
*
|
|
198
|
+
* Say it plainly: every one of these already throws `SecurityError` inside the
|
|
199
|
+
* sandbox. This list exists so the author sees a sentence instead of a console
|
|
200
|
+
* they are not looking at during a talk. It is not a security control, it is
|
|
201
|
+
* not exhaustive, and no amount of adding to it would make it one — the
|
|
202
|
+
* opaque origin is what does the work.
|
|
203
|
+
*/
|
|
204
|
+
const LINT = [
|
|
205
|
+
[/\bparent\s*\.\s*(document|location|frames|Decklight)/, 'reaches into the parent document'],
|
|
206
|
+
[/\btop\s*\.\s*(document|location)/, 'reaches into the top-level document'],
|
|
207
|
+
[/\.decklight-stage\b/, 'names the slide stage'],
|
|
208
|
+
[/\baside\.notes\b/, 'reads notes out of the DOM (declare `needs: ["notes"]` instead)'],
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
/** `[{ line, why, text }]` for a plugin source — empty when nothing matched. */
|
|
212
|
+
export function pluginLint(js) {
|
|
213
|
+
const out = [];
|
|
214
|
+
js.split('\n').forEach((text, i) => {
|
|
215
|
+
for (const [re, why] of LINT) {
|
|
216
|
+
if (re.test(text)) out.push({ line: i + 1, why, text: text.trim().slice(0, 90) });
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ── loading a presenter's library ──────────────────────────────────────────
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* One installed plugin, or a `PluginError` naming what is wrong with it.
|
|
226
|
+
* `dir` may be anywhere — `plugin check` points it at a working copy.
|
|
227
|
+
*/
|
|
228
|
+
export function loadPlugin(dir) {
|
|
229
|
+
const name = basename(dir);
|
|
230
|
+
const manifestPath = join(dir, 'plugin.json');
|
|
231
|
+
const sourcePath = join(dir, 'plugin.js');
|
|
232
|
+
if (!existsSync(manifestPath)) throw new PluginError(`${name}: no plugin.json in ${dir}`);
|
|
233
|
+
if (!existsSync(sourcePath)) throw new PluginError(`${name}: no plugin.js in ${dir}`);
|
|
234
|
+
|
|
235
|
+
const v = readManifest(readFileSync(manifestPath, 'utf8'), { name });
|
|
236
|
+
if (!v.ok) {
|
|
237
|
+
throw new PluginError(`${name}: plugin.json is not a usable manifest:\n`
|
|
238
|
+
+ v.errors.map((e) => ` ${e.field} — ${e.msg}`).join('\n'));
|
|
239
|
+
}
|
|
240
|
+
const source = readFileSync(sourcePath, 'utf8');
|
|
241
|
+
const lint = pluginLint(source);
|
|
242
|
+
if (lint.length) {
|
|
243
|
+
throw new PluginError(`${name}: plugin.js reaches outside its frame:\n`
|
|
244
|
+
+ lint.map((l) => ` line ${l.line}: ${l.why}\n ${l.text}`).join('\n')
|
|
245
|
+
+ '\n A presenter plugin renders chrome in a sandboxed frame with an opaque origin;'
|
|
246
|
+
+ '\n the deck\'s document is not reachable from it, so this cannot work. Ask for what'
|
|
247
|
+
+ `\n you need in plugin.json instead: needs: [${NEEDS.map((n) => `"${n}"`).join(', ')}].`);
|
|
248
|
+
}
|
|
249
|
+
return { ...v.manifest, dir, source };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Every plugin in the presenter's library, and every one that could not be
|
|
254
|
+
* loaded with the reason why.
|
|
255
|
+
*
|
|
256
|
+
* A bad plugin is skipped, never fatal: the alternative is a command that
|
|
257
|
+
* refuses to present a talk because of a timer, ten minutes before the talk —
|
|
258
|
+
* the same argument PRESENT#STRICT settles the same way.
|
|
259
|
+
*/
|
|
260
|
+
export function loadLibrary(home = configHome()) {
|
|
261
|
+
const dir = pluginsDir(home);
|
|
262
|
+
if (!existsSync(dir)) return { plugins: [], refused: [] };
|
|
263
|
+
const plugins = [];
|
|
264
|
+
const refused = [];
|
|
265
|
+
for (const name of readdirSync(dir).sort()) {
|
|
266
|
+
const p = join(dir, name);
|
|
267
|
+
if (!statSync(p).isDirectory()) continue;
|
|
268
|
+
try { plugins.push(loadPlugin(p)); } catch (e) {
|
|
269
|
+
if (!(e instanceof PluginError)) throw e;
|
|
270
|
+
refused.push({ name, reason: e.message });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return { plugins, refused };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ── the chrome, as markup ──────────────────────────────────────────────────
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Escape for an attribute value. `&` and `"` are the two that matter — with
|
|
280
|
+
* every quote escaped the attribute cannot be closed early, which is what
|
|
281
|
+
* keeps a plugin's source from breaking out into the deck's document.
|
|
282
|
+
*
|
|
283
|
+
* `<` and `>` go too, though an HTML5 attribute value does not require it: a
|
|
284
|
+
* plugin is a whole document quoted inside one attribute, so its text is full
|
|
285
|
+
* of tags, and leaving them raw means anything that ever looks at this file
|
|
286
|
+
* with a regex sees markup that is not markup. Browsers decode the entities
|
|
287
|
+
* before parsing the srcdoc, so the frame gets exactly the document intended.
|
|
288
|
+
*/
|
|
289
|
+
const attr = (s) => String(s)
|
|
290
|
+
.replace(/&/g, '&').replace(/"/g, '"')
|
|
291
|
+
.replace(/</g, '<').replace(/>/g, '>');
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The document a plugin actually runs in.
|
|
295
|
+
*
|
|
296
|
+
* Two script blocks: a fixed preamble that gives the plugin its only API, and
|
|
297
|
+
* the plugin. The API is deliberately one-way — `decklight.on(fn)` receives
|
|
298
|
+
* state, and there is nothing to call to ASK the host for anything. A request
|
|
299
|
+
* channel is how a chrome-only surface acquires a second capability later; a
|
|
300
|
+
* relay that only ever pushes has nowhere to grow one.
|
|
301
|
+
*/
|
|
302
|
+
function frameDoc(plugin) {
|
|
303
|
+
return `<!doctype html><meta charset="utf-8"><style>
|
|
304
|
+
html,body{margin:0;padding:0;height:100%;overflow:hidden;
|
|
305
|
+
font:13px/1.35 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
306
|
+
color:#fff;background:transparent}
|
|
307
|
+
</style><body><script>
|
|
308
|
+
(function(){var fns=[],last=null;
|
|
309
|
+
window.decklight={slot:${JSON.stringify(plugin.slot)},name:${JSON.stringify(plugin.name)},
|
|
310
|
+
on:function(fn){fns.push(fn);if(last)try{fn(last)}catch(e){}}};
|
|
311
|
+
window.addEventListener("message",function(e){
|
|
312
|
+
var d=e.data;if(!d||d.__decklight!==1)return;last=d.state;
|
|
313
|
+
for(var i=0;i<fns.length;i++){try{fns[i](d.state)}catch(err){}}});
|
|
314
|
+
})();
|
|
315
|
+
</script><script>
|
|
316
|
+
${plugin.source}
|
|
317
|
+
</script>`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The host side: one capture-phase listener set, and a push to every frame.
|
|
322
|
+
*
|
|
323
|
+
* Capture on `document` rather than a listener on `.decklight`, because the
|
|
324
|
+
* engine's events are `CustomEvent`s with the default `bubbles: false`
|
|
325
|
+
* (src/core/engine.js `_emit`) — a capture listener on an ancestor still sees
|
|
326
|
+
* them, and this way the shim needs no handle on a root that may not exist
|
|
327
|
+
* yet when it runs.
|
|
328
|
+
*
|
|
329
|
+
* Nothing here is added to the runtime: `present` injects this, `bundle` never
|
|
330
|
+
* does, and a deck opened any other way has never heard of it.
|
|
331
|
+
*/
|
|
332
|
+
function hostShim(plugins) {
|
|
333
|
+
const wantsNotes = plugins.filter((p) => p.needs.includes('notes')).map((p) => p.name);
|
|
334
|
+
return `<script>
|
|
335
|
+
(function(){
|
|
336
|
+
// Presenter chrome belongs to the one document a presenter is looking at.
|
|
337
|
+
// The deck boots itself into same-origin iframes for the theme picker, the
|
|
338
|
+
// slide finder and the speaker view, and ?print is a page being exported —
|
|
339
|
+
// the same rule the HUD keeps for the clock and the hairline.
|
|
340
|
+
var host=document.querySelector(".decklight-chrome");
|
|
341
|
+
if(!host)return;
|
|
342
|
+
if(window.top!==window.self||/[?&](embedded|print)\\b/.test(location.search)){host.remove();return;}
|
|
343
|
+
var notes=${JSON.stringify(wantsNotes)};
|
|
344
|
+
var frames=[].slice.call(host.querySelectorAll("iframe[data-plugin]"));
|
|
345
|
+
var state={slide:1,step:0,totalSlides:0,elapsed:0};
|
|
346
|
+
var started=null;
|
|
347
|
+
function notesFor(i){
|
|
348
|
+
var secs=document.querySelectorAll(".decklight-stage > section");
|
|
349
|
+
var el=secs[i-1]&&secs[i-1].querySelector("aside.notes");
|
|
350
|
+
return el?el.textContent.trim():"";
|
|
351
|
+
}
|
|
352
|
+
function push(){
|
|
353
|
+
state.elapsed=started==null?0:Date.now()-started;
|
|
354
|
+
for(var i=0;i<frames.length;i++){
|
|
355
|
+
var f=frames[i],w=f.contentWindow;
|
|
356
|
+
if(!w)continue;
|
|
357
|
+
var s=state;
|
|
358
|
+
if(notes.indexOf(f.getAttribute("data-plugin"))>=0){
|
|
359
|
+
s={};for(var k in state)s[k]=state[k];
|
|
360
|
+
s.notes=notesFor(state.slide);
|
|
361
|
+
}
|
|
362
|
+
// "*" is the only possible target: the frame's origin is opaque, so
|
|
363
|
+
// there is no origin string that would ever match it.
|
|
364
|
+
w.postMessage({__decklight:1,state:s},"*");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
document.addEventListener("decklight:ready",function(e){
|
|
368
|
+
state.totalSlides=(e.detail&&e.detail.slides)||0;push();
|
|
369
|
+
},true);
|
|
370
|
+
document.addEventListener("decklight:slide",function(e){
|
|
371
|
+
var d=e.detail||{};
|
|
372
|
+
// Elapsed counts from the FIRST advance, not page load — a deck idling on
|
|
373
|
+
// its title slide while the room fills is not a talk yet (HUD's rule).
|
|
374
|
+
if(started==null)started=Date.now();
|
|
375
|
+
state.slide=d.slide||1;state.totalSlides=d.total||state.totalSlides;state.step=0;push();
|
|
376
|
+
},true);
|
|
377
|
+
document.addEventListener("decklight:build",function(e){
|
|
378
|
+
var d=e.detail||{};state.step=d.index||0;push();
|
|
379
|
+
},true);
|
|
380
|
+
setInterval(push,1000);
|
|
381
|
+
push();
|
|
382
|
+
})();
|
|
383
|
+
</script>`;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** The stylesheet for the slots. Inline, which `style-src 'unsafe-inline'` already allows. */
|
|
387
|
+
const CHROME_CSS = `<style>
|
|
388
|
+
.decklight-chrome{position:fixed;inset:0;pointer-events:none;z-index:55}
|
|
389
|
+
.decklight-chrome > div{position:absolute;pointer-events:auto}
|
|
390
|
+
.decklight-chrome iframe{display:block;width:100%;height:100%;border:0;background:transparent;color-scheme:normal}
|
|
391
|
+
.decklight-chrome .corner-tl{top:16px;left:16px}
|
|
392
|
+
.decklight-chrome .corner-tr{top:16px;right:16px}
|
|
393
|
+
.decklight-chrome .corner-bl{bottom:16px;left:16px}
|
|
394
|
+
.decklight-chrome .corner-br{bottom:16px;right:16px}
|
|
395
|
+
.decklight-chrome .edge-top{top:0;left:50%;transform:translateX(-50%)}
|
|
396
|
+
.decklight-chrome .edge-bottom{bottom:0;left:50%;transform:translateX(-50%)}
|
|
397
|
+
@media print{.decklight-chrome{display:none}}
|
|
398
|
+
</style>`;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* The whole injection: the slot styles, one sandboxed frame per plugin, and
|
|
402
|
+
* the host shim.
|
|
403
|
+
*
|
|
404
|
+
* WHY THIS NEEDS NO CSP CHANGE, WHICH LOOKS WRONG UNTIL YOU CHECK IT. A
|
|
405
|
+
* `srcdoc` frame is not fetched, so `frame-src` never gets a URL to judge — it
|
|
406
|
+
* runs even under `frame-src 'none'`, verified in headless Chrome
|
|
407
|
+
* (test/plugin-render.mjs). It INHERITS the embedding document's policy
|
|
408
|
+
* instead, and the presenting CSP already carries `script-src 'unsafe-inline'`
|
|
409
|
+
* because a bundled deck IS inline script. So the chrome loads under exactly
|
|
410
|
+
* the header the deck is served with, no route is registered for it, and
|
|
411
|
+
* `present`'s policy string is untouched by a plugin being installed.
|
|
412
|
+
*
|
|
413
|
+
* `sandbox="allow-scripts"` without `allow-same-origin` is the load-bearing
|
|
414
|
+
* attribute: it hands the frame an opaque origin, so `parent.document` throws.
|
|
415
|
+
* Adding `allow-same-origin` here would silently undo the entire ticket.
|
|
416
|
+
*/
|
|
417
|
+
export function chromeMarkup(plugins) {
|
|
418
|
+
if (!plugins.length) return '';
|
|
419
|
+
const frames = plugins.map((p) => `<div class="${p.slot}" style="width:${p.width}px;height:${p.height}px">`
|
|
420
|
+
+ `<iframe data-plugin="${attr(p.name)}" title="${attr(p.title)}"`
|
|
421
|
+
+ ` sandbox="allow-scripts" srcdoc="${attr(frameDoc(p))}"></iframe></div>`).join('\n');
|
|
422
|
+
return `\n<!-- decklight presenter chrome — the presenter's own, not part of this deck -->\n`
|
|
423
|
+
+ `${CHROME_CSS}\n<div class="decklight-chrome">\n${frames}\n</div>\n${hostShim(plugins)}\n`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Put the chrome into a served document, immediately before `</body>`.
|
|
428
|
+
*
|
|
429
|
+
* Called by `present` AFTER the audit has read the file and AFTER strict mode
|
|
430
|
+
* has run, which is the whole reason the ingredients label stays honest: the
|
|
431
|
+
* label describes the bytes on disk, and these bytes were never on disk.
|
|
432
|
+
* With no plugins installed this returns its input unchanged — byte for byte,
|
|
433
|
+
* which is what keeps `present` on a machine with an empty library exactly the
|
|
434
|
+
* command it was before this existed.
|
|
435
|
+
*/
|
|
436
|
+
export function injectChrome(html, plugins) {
|
|
437
|
+
const markup = chromeMarkup(plugins);
|
|
438
|
+
if (!markup) return html;
|
|
439
|
+
// The shared injector, not a second `lastIndexOf('</body>')`: it matches
|
|
440
|
+
// case-insensitively (a deck may close `</BODY>`) and its docblock carries
|
|
441
|
+
// the reason the search runs from the END — a bundled deck inlines the
|
|
442
|
+
// runtime, whose speaker-view template holds a literal `</body>` that a
|
|
443
|
+
// first-match search would splice the chrome into the middle of.
|
|
444
|
+
return injectBeforeBodyEnd(html, markup) ?? html + markup;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// ── the command ────────────────────────────────────────────────────────────
|
|
448
|
+
|
|
449
|
+
const USAGE = `usage: decklight plugin <add|list|check|remove> …
|
|
450
|
+
|
|
451
|
+
decklight plugin add <name[@marketplace]>
|
|
452
|
+
install a presenter plugin from a registered marketplace into your own
|
|
453
|
+
library under ~/.decklight/plugins/. It is yours: it never enters a deck,
|
|
454
|
+
never travels with one, and bundle cannot see it
|
|
455
|
+
EXAMPLE: decklight plugin add timer
|
|
456
|
+
EXAMPLE: decklight plugin add teleprompter@decklight
|
|
457
|
+
|
|
458
|
+
decklight plugin list
|
|
459
|
+
what is installed, where each sits, and which ones read your speaker notes
|
|
460
|
+
|
|
461
|
+
decklight plugin check <name | directory>
|
|
462
|
+
validate a plugin without installing it — the same manifest vocabulary and
|
|
463
|
+
the same lint the loader applies. Exits non-zero on a refusal, so a
|
|
464
|
+
plugin's own CI can gate on it
|
|
465
|
+
|
|
466
|
+
decklight plugin remove <name>
|
|
467
|
+
delete it from your library
|
|
468
|
+
|
|
469
|
+
A plugin is two files. Its code runs in a sandboxed frame with an opaque
|
|
470
|
+
origin, so it can render chrome — a timer, a teleprompter, a confidence
|
|
471
|
+
monitor — and cannot reach the slides. That is structural, not a promise:
|
|
472
|
+
parent.document throws there.
|
|
473
|
+
|
|
474
|
+
plugin.json { "name": "timer", "slot": "corner-br",
|
|
475
|
+
"needs": ["position"], "width": 150, "height": 44 }
|
|
476
|
+
|
|
477
|
+
plugin.js decklight.on(function (s) {
|
|
478
|
+
var m = Math.floor(s.elapsed / 60000);
|
|
479
|
+
document.body.textContent =
|
|
480
|
+
m + ':' + ('0' + Math.floor(s.elapsed / 1000) % 60).slice(-2)
|
|
481
|
+
+ ' ' + s.slide + '/' + s.totalSlides;
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
decklight.on is the whole API, and it only ever receives: the state comes to
|
|
485
|
+
you and there is nothing to call to ask for more. A plugin that declared
|
|
486
|
+
"notes" also gets s.notes for the current slide.
|
|
487
|
+
|
|
488
|
+
Scope is chrome only. A manifest that asks for slide content is refused by
|
|
489
|
+
name, because a deck has to stay a deterministic artifact — otherwise two
|
|
490
|
+
people presenting the same file are presenting different decks.
|
|
491
|
+
|
|
492
|
+
slots: ${SLOTS.join(', ')}
|
|
493
|
+
needs: ${NEEDS.join(', ')} — "notes" must be declared, and is named in
|
|
494
|
+
plugin list and at present startup so you know who is reading them
|
|
495
|
+
|
|
496
|
+
present loads the library; bundle never does. With nothing installed,
|
|
497
|
+
present behaves exactly as it does with this command absent.
|
|
498
|
+
DECKLIGHT_HOME overrides ~/.decklight/.`;
|
|
499
|
+
|
|
500
|
+
/** Read a plugin's two files from a resolved source (a URL or a local dir). */
|
|
501
|
+
async function fetchPlugin(source, { fetchImpl = fetch } = {}) {
|
|
502
|
+
const one = async (file) => {
|
|
503
|
+
const at = /^https?:\/\//i.test(source) ? `${source.replace(/\/$/, '')}/${file}` : join(resolve(source), file);
|
|
504
|
+
if (/^https?:\/\//i.test(at)) {
|
|
505
|
+
let r;
|
|
506
|
+
try { r = await fetchImpl(at); } catch (e) { throw new PluginError(`could not fetch ${at} — ${e.cause?.code ?? e.message}`); }
|
|
507
|
+
if (!r.ok) throw new PluginError(`${at} — HTTP ${r.status}`);
|
|
508
|
+
return await r.text();
|
|
509
|
+
}
|
|
510
|
+
if (!existsSync(at)) throw new PluginError(`no such file: ${at}`);
|
|
511
|
+
return readFileSync(at, 'utf8');
|
|
512
|
+
};
|
|
513
|
+
return { manifest: await one('plugin.json'), source: await one('plugin.js') };
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** Validate a fetched pair the way the loader will, before anything is written. */
|
|
517
|
+
function vet(name, files) {
|
|
518
|
+
const v = readManifest(files.manifest, { name });
|
|
519
|
+
if (!v.ok) {
|
|
520
|
+
throw new PluginError(`${name}: plugin.json is not a usable manifest:\n`
|
|
521
|
+
+ v.errors.map((e) => ` ${e.field} — ${e.msg}`).join('\n'));
|
|
522
|
+
}
|
|
523
|
+
const lint = pluginLint(files.source);
|
|
524
|
+
if (lint.length) {
|
|
525
|
+
throw new PluginError(`${name}: plugin.js reaches outside its frame:\n`
|
|
526
|
+
+ lint.map((l) => ` line ${l.line}: ${l.why}\n ${l.text}`).join('\n'));
|
|
527
|
+
}
|
|
528
|
+
return v.manifest;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async function addMain(args, home) {
|
|
532
|
+
const [ref] = args.filter((a) => !a.startsWith('-'));
|
|
533
|
+
if (!ref) { console.error(`decklight plugin add: needs a plugin name\n\n${USAGE}`); return 1; }
|
|
534
|
+
|
|
535
|
+
const reg = loadRegistry(home);
|
|
536
|
+
const catalogs = {};
|
|
537
|
+
for (const name of Object.keys(reg.marketplaces)) {
|
|
538
|
+
const c = loadCatalog(name, home);
|
|
539
|
+
if (c?.ok) catalogs[name] = c.manifest;
|
|
540
|
+
}
|
|
541
|
+
if (!Object.keys(catalogs).length) {
|
|
542
|
+
console.error('decklight plugin add: no marketplace has been fetched yet'
|
|
543
|
+
+ ' — decklight marketplace update <name> (registered is not fetched)');
|
|
544
|
+
return 1;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
let hit;
|
|
548
|
+
try { hit = resolveEntry(ref, catalogs); } catch (e) {
|
|
549
|
+
console.error(`decklight plugin add: ${e.message}`);
|
|
550
|
+
return 1;
|
|
551
|
+
}
|
|
552
|
+
if (hit.entry.type !== 'plugin') {
|
|
553
|
+
console.error(`decklight plugin add: ${hit.qualified} is a ${hit.entry.type}, not a plugin`);
|
|
554
|
+
return 1;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const { resolveSource } = await import('./theme.mjs');
|
|
558
|
+
const src = resolveSource(hit.entry.source, reg.marketplaces[hit.marketplace]?.source);
|
|
559
|
+
let manifest;
|
|
560
|
+
let files;
|
|
561
|
+
try {
|
|
562
|
+
files = await fetchPlugin(src);
|
|
563
|
+
manifest = vet(hit.entry.name, files);
|
|
564
|
+
} catch (e) {
|
|
565
|
+
if (!(e instanceof PluginError)) throw e;
|
|
566
|
+
console.error(`decklight plugin add: ${e.message}`);
|
|
567
|
+
console.error(`\n ${hit.qualified} was NOT installed`);
|
|
568
|
+
return 1;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const dir = join(pluginsDir(home), manifest.name);
|
|
572
|
+
mkdirSync(dir, { recursive: true });
|
|
573
|
+
writeFileSync(join(dir, 'plugin.json'), files.manifest);
|
|
574
|
+
writeFileSync(join(dir, 'plugin.js'), files.source);
|
|
575
|
+
console.log(`installed ${manifest.name} from ${hit.qualified} — ${manifest.slot}, reads ${manifest.needs.join(' + ')}`);
|
|
576
|
+
console.log(` it is yours, not the deck's: decklight present loads it, bundle never will`);
|
|
577
|
+
if (manifest.needs.includes('notes')) console.log(' it reads your speaker notes — it asked, and plugin list says so');
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function listMain(home) {
|
|
582
|
+
const { plugins, refused } = loadLibrary(home);
|
|
583
|
+
if (!plugins.length && !refused.length) {
|
|
584
|
+
console.log('no presenter plugins installed — decklight plugin add <name>');
|
|
585
|
+
console.log(` (a plugin is your own chrome: a timer, a teleprompter. It never enters a deck.)`);
|
|
586
|
+
return 0;
|
|
587
|
+
}
|
|
588
|
+
for (const p of plugins) {
|
|
589
|
+
console.log(`${p.name}${p.version ? ` ${p.version}` : ''} ${p.slot} ${p.width}×${p.height}`
|
|
590
|
+
+ ` reads ${p.needs.join(' + ')}${p.needs.includes('notes') ? ' ← your speaker notes' : ''}`);
|
|
591
|
+
if (p.description) console.log(` ${p.description}`);
|
|
592
|
+
}
|
|
593
|
+
for (const r of refused) console.log(`${r.name} — REFUSED\n ${r.reason.replace(/\n/g, '\n ')}`);
|
|
594
|
+
return refused.length ? 1 : 0;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function checkMain(args, home) {
|
|
598
|
+
const [target] = args.filter((a) => !a.startsWith('-'));
|
|
599
|
+
if (!target) { console.error(`decklight plugin check: needs a plugin name or directory\n\n${USAGE}`); return 1; }
|
|
600
|
+
const dir = existsSync(target) ? resolve(target) : join(pluginsDir(home), target);
|
|
601
|
+
if (!existsSync(dir)) { console.error(`decklight plugin check: no such plugin or directory: ${target}`); return 1; }
|
|
602
|
+
let p;
|
|
603
|
+
try { p = loadPlugin(dir); } catch (e) {
|
|
604
|
+
if (!(e instanceof PluginError)) throw e;
|
|
605
|
+
console.error(`✘ ${e.message}`);
|
|
606
|
+
return 1;
|
|
607
|
+
}
|
|
608
|
+
console.log(`✔ ${p.name} — ${p.slot}, ${p.width}×${p.height}, reads ${p.needs.join(' + ')}`);
|
|
609
|
+
console.log(` its code runs in a sandboxed frame with an opaque origin: it renders chrome, and`);
|
|
610
|
+
console.log(` cannot reach the slides. present will load it; bundle will not.`);
|
|
611
|
+
return 0;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function removeMain(args, home) {
|
|
615
|
+
const [name] = args.filter((a) => !a.startsWith('-'));
|
|
616
|
+
if (!name) { console.error(`decklight plugin remove: which one?\n\n${USAGE}`); return 1; }
|
|
617
|
+
const dir = join(pluginsDir(home), name);
|
|
618
|
+
if (!existsSync(dir)) { console.error(`decklight plugin remove: no plugin "${name}" installed (decklight plugin list)`); return 1; }
|
|
619
|
+
rmSync(dir, { recursive: true, force: true });
|
|
620
|
+
console.log(`removed ${name}`);
|
|
621
|
+
return 0;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
export async function pluginMain(args = []) {
|
|
625
|
+
const sub = args[0];
|
|
626
|
+
if (!sub || sub === '--help' || sub === '-h' || sub === 'help') { console.log(USAGE); return sub ? 0 : 1; }
|
|
627
|
+
const rest = args.slice(1);
|
|
628
|
+
if (rest.includes('--help') || rest.includes('-h')) { console.log(USAGE); return 0; }
|
|
629
|
+
const home = configHome();
|
|
630
|
+
try {
|
|
631
|
+
if (sub === 'add') return await addMain(rest, home);
|
|
632
|
+
if (sub === 'list') return listMain(home);
|
|
633
|
+
if (sub === 'check') return checkMain(rest, home);
|
|
634
|
+
if (sub === 'remove') return removeMain(rest, home);
|
|
635
|
+
} catch (e) {
|
|
636
|
+
if (e instanceof PluginError || e instanceof MarketplaceError) {
|
|
637
|
+
console.error(`decklight plugin ${sub}: ${e.message}`);
|
|
638
|
+
return 1;
|
|
639
|
+
}
|
|
640
|
+
throw e;
|
|
641
|
+
}
|
|
642
|
+
console.error(`decklight plugin: unknown subcommand "${sub}"\n\n${USAGE}`);
|
|
643
|
+
return 1;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (isMain(import.meta.url)) process.exit(await pluginMain(process.argv.slice(2)));
|