decklight 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "decklight",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "A presentation library designed to be authored by AI agents and humans alike: single-file decks, Keynote-style builds, theme-aware SVG diagrams, and truthful terminal recordings.",
5
5
  "type": "module",
6
6
  "main": "dist/decklight.js",
package/tools/exec.mjs CHANGED
@@ -28,9 +28,17 @@
28
28
  *
29
29
  * Budgets, named for what they are rather than how long: a probe answers in
30
30
  * milliseconds, the network in seconds, a codec in as long as the audio is.
31
+ *
32
+ * `runAsync` is the same contract without blocking the event loop, and it
33
+ * exists because one caller must not: a command that renders through
34
+ * `serveForRender` (PRESENTING) launches Chrome and then has to ANSWER it from
35
+ * this same process. `run` there is a deadlock — the browser waits for a
36
+ * server that cannot run until the browser exits — and it looks exactly like a
37
+ * hang, right down to this module's own timeout message. `decklight pptx`
38
+ * shipped that way in 0.8.0.
31
39
  */
32
40
 
33
- import { execFileSync } from 'node:child_process';
41
+ import { execFile, execFileSync } from 'node:child_process';
34
42
 
35
43
  /** `--version` and its kin. Anything slower than this is not answering. */
36
44
  export const PROBE_MS = 15_000;
@@ -52,3 +60,28 @@ export function run(bin, args, { timeout = NETWORK_MS, why = '', ...opts } = {})
52
60
  throw e;
53
61
  }
54
62
  }
63
+
64
+ /**
65
+ * `run`, awaited rather than blocking. Same timeout, same SIGKILL, same
66
+ * ETIMEDOUT error naming the binary and WHY; every other failure rejects with
67
+ * the untouched child_process error, so callers keep reading `.status`,
68
+ * `.stderr` and `.code === 'ENOENT'`.
69
+ *
70
+ * Use this — never `run` — whenever the process that spawns the child is also
71
+ * serving it (tools/shot.mjs, tools/video.mjs, cli/pptx-export.mjs).
72
+ */
73
+ export function runAsync(bin, args, { timeout = NETWORK_MS, why = '', ...opts } = {}) {
74
+ return new Promise((resolve, reject) => {
75
+ execFile(bin, args, { ...opts, timeout, killSignal: 'SIGKILL' }, (e, stdout, stderr) => {
76
+ if (!e) return resolve(stdout);
77
+ if (e.killed || e.code === 'ETIMEDOUT' || (e.signal === 'SIGKILL' && e.status == null)) {
78
+ const err = new Error(`${bin} hung for ${Math.round(timeout / 1000)}s and was killed`
79
+ + (why ? ` — ${why}` : ''));
80
+ err.code = 'ETIMEDOUT'; err.bin = bin; err.cause = e;
81
+ return reject(err);
82
+ }
83
+ e.stdout = stdout; e.stderr = stderr;
84
+ reject(e);
85
+ });
86
+ });
87
+ }
@@ -50,7 +50,7 @@ export const ALL = [
50
50
  'record-render', 'review-render',
51
51
  'character-render', 'engine-render', 'pin-render', 'overflow-render', 'split-render',
52
52
  'strict-render', 'shot-render', 'plugin-render', 'extension-check-render',
53
- 'deckfile-render', 'pdf-render', 'import-render', 'contrast', 'palette-rules',
53
+ 'deckfile-render', 'pdf-render', 'pptx-render', 'import-render', 'contrast', 'palette-rules',
54
54
  ];
55
55
 
56
56
  /**
@@ -103,6 +103,8 @@ const RULES = [
103
103
  [/^cli\/import\.mjs$/, ['import-render'], 'deck import'],
104
104
  [/^cli\/deckfile\.mjs$/, ['deckfile-render'], 'the .decklight container'],
105
105
  [/^cli\/pdf\.mjs$/, ['pdf-render'], 'PDF export'],
106
+ [/^cli\/pptx-export\.mjs$/, ['pptx-render'], 'PowerPoint export'],
107
+ [/^tools\/pptx-write\.mjs$/, ['pptx-render'], 'the file the PowerPoint export writes'],
106
108
  [/^cli\/(present|shot)\.mjs$/, ['shot-render'], 'present, and the screenshot containment it asserts'],
107
109
  [/^cli\/(comments|review-anchor|review-store|review-remote|review-submit)\.mjs$/, ['review-render'],
108
110
  'the CLI half of review — the harness cross-checks the browser against it'],
@@ -220,7 +222,7 @@ const COST = {
220
222
  'narration-render:segments': 12, 'narration-render:record': 40, 'extension-check-render': 23, 'engine-render': 17, render: 20,
221
223
  'pdf-render': 10, 'split-render': 9, 'review-render': 8, 'pin-render': 7, 'record-render': 7,
222
224
  'strict-render': 6, 'overflow-render': 6, 'plugin-render': 6, 'deckfile-render': 4,
223
- 'shot-render': 4, 'player-render': 3, 'character-render': 2, 'import-render': 2,
225
+ 'shot-render': 4, 'pptx-render': 6, 'player-render': 3, 'character-render': 2, 'import-render': 2,
224
226
  contrast: 1, 'palette-rules': 1,
225
227
  };
226
228
  const cost = (list) => list.reduce((n, h) => n + (COST[h] ?? 10), 0);