@tmhs/screencast-mcp 0.49.1 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +13 -8
  2. package/dist/index.js +550 -106
  3. package/dist/wgcRecorder.js +15 -139
  4. package/package.json +8 -4
  5. package/assets/.gitkeep +0 -0
  6. package/assets/icon.png +0 -0
  7. package/dist/cli.js +0 -516
  8. package/dist/context.js +0 -50
  9. package/dist/prompts.js +0 -95
  10. package/dist/resources.js +0 -93
  11. package/dist/server.js +0 -174
  12. package/dist/setup.js +0 -438
  13. package/dist/tools/addMarker.js +0 -93
  14. package/dist/tools/assembleHighlights.js +0 -69
  15. package/dist/tools/backdrop.js +0 -79
  16. package/dist/tools/bugReport.js +0 -243
  17. package/dist/tools/burnSubtitles.js +0 -56
  18. package/dist/tools/callout.js +0 -62
  19. package/dist/tools/chapters.js +0 -156
  20. package/dist/tools/clip.js +0 -52
  21. package/dist/tools/compress.js +0 -51
  22. package/dist/tools/concat.js +0 -67
  23. package/dist/tools/contactSheet.js +0 -113
  24. package/dist/tools/convert.js +0 -46
  25. package/dist/tools/crop.js +0 -43
  26. package/dist/tools/cursor.js +0 -67
  27. package/dist/tools/cutByTranscript.js +0 -86
  28. package/dist/tools/cutIdle.js +0 -84
  29. package/dist/tools/deleteRecording.js +0 -119
  30. package/dist/tools/denoise.js +0 -60
  31. package/dist/tools/doctor.js +0 -146
  32. package/dist/tools/exportGif.js +0 -57
  33. package/dist/tools/exportPreset.js +0 -48
  34. package/dist/tools/extractAudio.js +0 -65
  35. package/dist/tools/findText.js +0 -194
  36. package/dist/tools/getMediaInfo.js +0 -36
  37. package/dist/tools/getSession.js +0 -40
  38. package/dist/tools/indexRecording.js +0 -195
  39. package/dist/tools/keystrokeOverlay.js +0 -90
  40. package/dist/tools/listAudioDevices.js +0 -35
  41. package/dist/tools/listSessions.js +0 -28
  42. package/dist/tools/listTargets.js +0 -76
  43. package/dist/tools/listVideoDevices.js +0 -26
  44. package/dist/tools/musicBed.js +0 -55
  45. package/dist/tools/narrate.js +0 -86
  46. package/dist/tools/normalizeAudio.js +0 -59
  47. package/dist/tools/overlay.js +0 -62
  48. package/dist/tools/pauseRecording.js +0 -44
  49. package/dist/tools/pipeline.js +0 -397
  50. package/dist/tools/readEvents.js +0 -98
  51. package/dist/tools/redactRegion.js +0 -62
  52. package/dist/tools/reframe.js +0 -46
  53. package/dist/tools/resumeRecording.js +0 -46
  54. package/dist/tools/reviewRecording.js +0 -163
  55. package/dist/tools/sampleFrames.js +0 -200
  56. package/dist/tools/saveReplay.js +0 -90
  57. package/dist/tools/scale.js +0 -44
  58. package/dist/tools/screenDiff.js +0 -86
  59. package/dist/tools/screenshot.js +0 -76
  60. package/dist/tools/searchRecording.js +0 -79
  61. package/dist/tools/speed.js +0 -46
  62. package/dist/tools/startRecording.js +0 -398
  63. package/dist/tools/stepGuide.js +0 -249
  64. package/dist/tools/stopRecording.js +0 -132
  65. package/dist/tools/titleCard.js +0 -67
  66. package/dist/tools/transcribe.js +0 -66
  67. package/dist/tools/trim.js +0 -57
  68. package/dist/tools/waitForChange.js +0 -142
  69. package/dist/tools/xfadeTransition.js +0 -58
  70. package/dist/tools/zoom.js +0 -134
  71. package/dist/utils/anim.js +0 -54
  72. package/dist/utils/animExport.js +0 -56
  73. package/dist/utils/argPaths.js +0 -39
  74. package/dist/utils/audio.js +0 -117
  75. package/dist/utils/audioDevices.js +0 -107
  76. package/dist/utils/backdrop.js +0 -162
  77. package/dist/utils/bugReport.js +0 -195
  78. package/dist/utils/callout.js +0 -132
  79. package/dist/utils/calloutAssets.js +0 -42
  80. package/dist/utils/capabilities.js +0 -96
  81. package/dist/utils/captions.js +0 -104
  82. package/dist/utils/chapters.js +0 -227
  83. package/dist/utils/consent.js +0 -29
  84. package/dist/utils/cursor.js +0 -338
  85. package/dist/utils/diff.js +0 -186
  86. package/dist/utils/errors.js +0 -29
  87. package/dist/utils/events.js +0 -403
  88. package/dist/utils/expr.js +0 -11
  89. package/dist/utils/ffmpeg.js +0 -285
  90. package/dist/utils/fontCoverage.js +0 -177
  91. package/dist/utils/fonts.js +0 -154
  92. package/dist/utils/frameQueue.js +0 -50
  93. package/dist/utils/gpu.js +0 -219
  94. package/dist/utils/idle.js +0 -91
  95. package/dist/utils/images.js +0 -38
  96. package/dist/utils/jobs.js +0 -129
  97. package/dist/utils/keystrokes.js +0 -198
  98. package/dist/utils/lifecycle.js +0 -233
  99. package/dist/utils/logging.js +0 -75
  100. package/dist/utils/media.js +0 -584
  101. package/dist/utils/monitors.js +0 -124
  102. package/dist/utils/narrate.js +0 -233
  103. package/dist/utils/ocr.js +0 -222
  104. package/dist/utils/ocrScan.js +0 -93
  105. package/dist/utils/paths.js +0 -155
  106. package/dist/utils/pause.js +0 -190
  107. package/dist/utils/pipeline.js +0 -361
  108. package/dist/utils/player.js +0 -85
  109. package/dist/utils/pool.js +0 -29
  110. package/dist/utils/produce.js +0 -300
  111. package/dist/utils/recipes.js +0 -71
  112. package/dist/utils/recorder.js +0 -173
  113. package/dist/utils/recordingFiles.js +0 -32
  114. package/dist/utils/recordingIndex.js +0 -312
  115. package/dist/utils/replay.js +0 -283
  116. package/dist/utils/resolveTarget.js +0 -25
  117. package/dist/utils/retention.js +0 -48
  118. package/dist/utils/roots.js +0 -43
  119. package/dist/utils/sessions.js +0 -499
  120. package/dist/utils/sheet.js +0 -82
  121. package/dist/utils/stepGuide.js +0 -231
  122. package/dist/utils/steps.js +0 -88
  123. package/dist/utils/still.js +0 -38
  124. package/dist/utils/targetList.js +0 -64
  125. package/dist/utils/targets.js +0 -265
  126. package/dist/utils/timeline.js +0 -85
  127. package/dist/utils/toolSpec.js +0 -31
  128. package/dist/utils/toolsets.js +0 -134
  129. package/dist/utils/transcriptCut.js +0 -149
  130. package/dist/utils/validate.js +0 -23
  131. package/dist/utils/waitLoop.js +0 -50
  132. package/dist/utils/wgc.js +0 -84
  133. package/dist/utils/windows.js +0 -192
  134. package/dist/utils/zoom.js +0 -252
@@ -1,231 +0,0 @@
1
- import { maskSecrets, DEFAULT_SECRET_PATTERN } from "./bugReport.js";
2
- import { formatTimecode } from "./sheet.js";
3
- import { ringSize, DEFAULT_RING_COLOR } from "./zoom.js";
4
- export const MAX_GUIDE_STEPS = 100;
5
- export const SHOT_LEAD_SEC = 0.1;
6
- export const SHOT_MAX_WIDTH = 1280;
7
- const LABEL_MAX = 40;
8
- const LABEL_REACH_PX = 24;
9
- export const GUIDE_FILES = {
10
- markdown: "guide.md",
11
- html: "guide.html",
12
- images: "images",
13
- image: (n) => `step-${String(n).padStart(2, "0")}.png`,
14
- };
15
- export function caption(s) {
16
- return s.label ? `${s.text} ${s.label}` : s.text;
17
- }
18
- const r3 = (n) => Math.round(n * 1000) / 1000;
19
- export function shotTime(t, durationSec, fps) {
20
- const last = Math.max(0, durationSec - 1 / (fps > 0 ? fps : 30));
21
- return r3(Math.min(Math.max(0, t - SHOT_LEAD_SEC), last));
22
- }
23
- function distance(r, x, y) {
24
- const dx = Math.max(r.x - x, 0, x - (r.x + r.width));
25
- const dy = Math.max(r.y - y, 0, y - (r.y + r.height));
26
- return Math.hypot(dx, dy);
27
- }
28
- export function labelAt(lines, x, y) {
29
- const near = lines
30
- .map((line) => ({ line, d: distance(line, x, y) }))
31
- .filter((c) => c.d <= LABEL_REACH_PX && c.line.text.trim().length > 0)
32
- .sort((a, b) => a.d - b.d || a.line.width * a.line.height - b.line.width * b.line.height);
33
- const best = near[0]?.line;
34
- if (!best)
35
- return null;
36
- let text = best.text.replace(/\s+/g, " ").trim();
37
- if (text.length > LABEL_MAX) {
38
- const word = [...best.words].sort((a, b) => distance(a, x, y) - distance(b, x, y))[0];
39
- text = word ? word.text.trim() : `${text.slice(0, LABEL_MAX - 1).trimEnd()}…`;
40
- }
41
- return text.length > 0 ? text : null;
42
- }
43
- function clickVerb(s) {
44
- const verb = s.action === "double_click" ? "double-click" : "click";
45
- const b = s.button && s.button !== "left" ? `${s.button.charAt(0).toUpperCase()}${s.button.slice(1)}-${verb}` : verb;
46
- return b.charAt(0).toUpperCase() + b.slice(1);
47
- }
48
- export function guideSteps(steps, opts) {
49
- const pattern = opts.secretPattern ?? DEFAULT_SECRET_PATTERN;
50
- const mask = (s) => maskSecrets([s], pattern)[0] ?? s;
51
- let n = 0;
52
- return steps.map((s, i) => {
53
- if (s.action === "gap")
54
- return { n: 0, t: s.t, action: s.action, text: s.text };
55
- n++;
56
- const base = { n, t: s.t, action: s.action, text: s.text, shotT: shotTime(s.t, opts.durationSec, opts.fps) };
57
- const label = opts.labels?.[i];
58
- if (s.action === "click" || s.action === "double_click") {
59
- const verb = clickVerb(s);
60
- if (s.inFrame === false)
61
- return { ...base, text: `${verb} outside the recorded area` };
62
- return {
63
- ...base,
64
- x: s.x,
65
- y: s.y,
66
- ...(label ? { text: verb, label: mask(label) } : { text: `${verb} the marked spot` }),
67
- };
68
- }
69
- if (s.action === "scroll") {
70
- return { ...base, ...(s.inFrame === false ? {} : { x: s.x, y: s.y }), ...(label ? { text: `${s.text} over`, label: mask(label) } : {}) };
71
- }
72
- if (s.action === "shortcut")
73
- return s.keys ? { ...base, text: "Press", label: s.keys } : base;
74
- return { ...base, text: "Type text" };
75
- });
76
- }
77
- export function assignSections(steps, markers) {
78
- const sorted = [...markers].sort((a, b) => a.t - b.t);
79
- return steps.map((s) => {
80
- const m = sorted.filter((k) => k.t <= s.t + 1e-6).at(-1);
81
- return m ? { ...s, section: m.label } : s;
82
- });
83
- }
84
- export function shotFilter(size, opts) {
85
- const n = (v) => String(Math.round(v));
86
- const chain = [];
87
- for (const b of opts.boxes ?? [])
88
- chain.push(`drawbox=x=${n(b.x)}:y=${n(b.y)}:w=${n(b.width)}:h=${n(b.height)}:color=black:t=fill`);
89
- const scale = `scale=w='min(iw,${SHOT_MAX_WIDTH})':h=-2:flags=lanczos`;
90
- const base = `[0:v]${chain.length ? chain.join(",") + "," : ""}format=rgba`;
91
- if (!opts.click)
92
- return `${base},${scale},format=rgb24[out]`;
93
- const D = ringSize(size.width, size.height);
94
- const c = D / 2;
95
- const th = Math.max(3, Math.round(D / 10));
96
- const r = c - th / 2 - 1;
97
- const color = opts.color ?? DEFAULT_RING_COLOR;
98
- return (`${base}[bg];` +
99
- `color=c=${color}:s=${D}x${D}:d=1,format=rgba,` +
100
- `geq=r='r(X,Y)':g='g(X,Y)':b='b(X,Y)':a='if(lt(abs(hypot(X-${c},Y-${c})-${r}),${th / 2}),255,0)'[ring];` +
101
- `[bg][ring]overlay=x=${n(opts.click.x - c)}:y=${n(opts.click.y - c)},${scale},format=rgb24[out]`);
102
- }
103
- export function buildStepFrameArgs(input, t, output) {
104
- return ["-y", "-v", "error", "-ss", String(t), "-i", input, "-frames:v", "1", output];
105
- }
106
- export const HTML_MAX_BYTES = 10_000_000;
107
- export const HTML_IMAGE_LADDER = [
108
- { width: 1280, q: 4 },
109
- { width: 960, q: 6 },
110
- { width: 800, q: 8 },
111
- { width: 640, q: 10 },
112
- { width: 480, q: 14 },
113
- { width: 360, q: 20 },
114
- ];
115
- export const htmlImageName = (file) => file.replace(/\.png$/i, ".jpg");
116
- export function buildHtmlImageArgs(png, rung, output) {
117
- return [
118
- "-y", "-v", "error", "-i", png,
119
- "-vf", `scale=w='min(iw,${rung.width})':h=-2:flags=lanczos,format=yuvj420p`,
120
- "-frames:v", "1", "-q:v", String(rung.q), output,
121
- ];
122
- }
123
- export const base64Bytes = (n) => 4 * Math.ceil(n / 3);
124
- export function nextHtmlRung(at, bytes, budget = HTML_MAX_BYTES) {
125
- const w = HTML_IMAGE_LADDER[at].width;
126
- for (let k = at + 1; k < HTML_IMAGE_LADDER.length; k++) {
127
- if (bytes * (HTML_IMAGE_LADDER[k].width / w) ** 2 <= budget)
128
- return k;
129
- }
130
- return at + 1 < HTML_IMAGE_LADDER.length ? HTML_IMAGE_LADDER.length - 1 : null;
131
- }
132
- export function buildStepShotArgs(frame, filter, output) {
133
- return ["-y", "-v", "error", "-i", frame, "-filter_complex", filter, "-map", "[out]", "-frames:v", "1", output];
134
- }
135
- const md = (s) => s.replace(/\s*\n\s*/g, " ").replace(/([\\`*_[\]<>#|])/g, "\\$1");
136
- function footer(g) {
137
- const scan = g.ocr === "read"
138
- ? `Screenshots scanned for secrets with OCR (best-effort); ${g.redactions} region${g.redactions === 1 ? "" : "s"} boxed out.`
139
- : "Screenshots were not scanned for secrets: review them before sharing.";
140
- return `${scan} Typed text is never logged, so it never appears here.`;
141
- }
142
- function intro(g) {
143
- const count = g.steps.filter((s) => s.n > 0).length;
144
- return `${count} step${count === 1 ? "" : "s"} from a ${formatTimecode(g.recording.durationSec)} recording.`;
145
- }
146
- export function buildGuideMarkdown(g) {
147
- const out = [`# ${md(g.title)}`, "", intro(g), ""];
148
- if (g.steps.length === 0)
149
- out.push(`_${g.stepsNote ?? "No steps in the recording."}_`, "");
150
- let section;
151
- for (const s of g.steps) {
152
- if (s.section !== undefined && s.section !== section) {
153
- section = s.section;
154
- out.push(`## ${md(section)}`, "");
155
- }
156
- if (s.n === 0) {
157
- out.push(`> _${md(s.text)}_`, "");
158
- continue;
159
- }
160
- const line = s.label ? `${md(s.text)} **${md(s.label)}**` : md(s.text);
161
- out.push(`${s.n}. ${line} <sub>${formatTimecode(s.t)}</sub>`, "");
162
- if (s.image)
163
- out.push(` ![Step ${s.n}](${GUIDE_FILES.images}/${s.image})`, "");
164
- }
165
- if (g.stepsOmitted)
166
- out.push(`_${g.stepsOmitted} more steps not shown._`, "");
167
- out.push("<sub>", footer(g), `Generated by screencast-mcp step_guide, ${g.createdAt}.`, "</sub>", "");
168
- return out.join("\n");
169
- }
170
- const html = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
171
- const STYLE = `:root{--bg:#f6f5f2;--card:#fff;--ink:#16161a;--dim:#6b6b74;--line:#e2e0da;--rec:#e5383b}
172
- @media (prefers-color-scheme:dark){:root{--bg:#121214;--card:#1b1b1f;--ink:#ececf1;--dim:#9a9aa6;--line:#2c2c33}}
173
- *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif}
174
- main{max-width:920px;margin:0 auto;padding:40px 16px 64px}
175
- header{border-bottom:1px solid var(--line);padding-bottom:20px;margin-bottom:28px}
176
- .rec{font:600 12px/1 ui-monospace,"Cascadia Mono",Consolas,monospace;letter-spacing:.12em;color:var(--rec);text-transform:uppercase}
177
- .rec::before{content:"";display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--rec);margin-right:8px;vertical-align:1px}
178
- h1{font-size:30px;line-height:1.2;margin:10px 0 6px}h2{font-size:20px;margin:40px 0 16px}
179
- .meta{color:var(--dim);margin:0}ol{list-style:none;margin:0;padding:0}
180
- li{background:var(--card);border:1px solid var(--line);border-radius:10px;margin:0 0 18px;overflow:hidden}
181
- .cap{display:flex;gap:14px;align-items:baseline;padding:14px 18px}
182
- .n{flex:none;font:700 14px/1 ui-monospace,Consolas,monospace;color:var(--rec);min-width:2.2em}
183
- .t{margin-left:auto;font:12px/1 ui-monospace,Consolas,monospace;color:var(--dim)}
184
- li img{display:block;width:100%;height:auto;border-top:1px solid var(--line)}
185
- .note{color:var(--dim);font-style:italic;margin:0 0 18px;padding-left:18px;border-left:3px solid var(--line)}
186
- footer{color:var(--dim);font-size:13px;margin-top:40px;border-top:1px solid var(--line);padding-top:16px}`;
187
- export function buildGuideHtml(g, imageSrc) {
188
- const body = [];
189
- let section;
190
- let open = false;
191
- const close = () => {
192
- if (open)
193
- body.push("</ol>");
194
- open = false;
195
- };
196
- for (const s of g.steps) {
197
- if (s.section !== undefined && s.section !== section) {
198
- close();
199
- section = s.section;
200
- body.push(`<h2>${html(section)}</h2>`);
201
- }
202
- if (s.n === 0) {
203
- close();
204
- body.push(`<p class="note">${html(s.text)}</p>`);
205
- continue;
206
- }
207
- if (!open)
208
- body.push("<ol>");
209
- open = true;
210
- const text = s.label ? `${html(s.text)} <strong>${html(s.label)}</strong>` : html(s.text);
211
- body.push(`<li><div class="cap"><span class="n">${String(s.n).padStart(2, "0")}</span><span>${text}</span>` +
212
- `<span class="t">${formatTimecode(s.t)}</span></div>` +
213
- (s.image ? `<img src="${html(imageSrc(s.image))}" alt="Step ${s.n}: ${html(caption(s))}" loading="lazy">` : "") +
214
- "</li>");
215
- }
216
- close();
217
- if (g.steps.length === 0)
218
- body.push(`<p class="note">${html(g.stepsNote ?? "No steps in the recording.")}</p>`);
219
- if (g.stepsOmitted)
220
- body.push(`<p class="note">${g.stepsOmitted} more steps not shown.</p>`);
221
- return [
222
- "<!doctype html>",
223
- '<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">',
224
- `<title>${html(g.title)}</title><style>${STYLE}</style></head><body><main>`,
225
- `<header><div class="rec">Step guide</div><h1>${html(g.title)}</h1><p class="meta">${html(intro(g))}</p></header>`,
226
- ...body,
227
- `<footer>${html(footer(g))}<br>Generated by screencast-mcp step_guide, ${html(g.createdAt)}.</footer>`,
228
- "</main></body></html>",
229
- "",
230
- ].join("\n");
231
- }
@@ -1,88 +0,0 @@
1
- const DOUBLE_CLICK_SEC = 0.5;
2
- const DOUBLE_CLICK_PX = 6;
3
- const SCROLL_JOIN_SEC = 1;
4
- const r3 = (n) => Math.round(n * 1000) / 1000;
5
- const GAP_WHY = {
6
- input_not_seen: "input went to an elevated window or the lock screen, or the hook was removed",
7
- helper_stalled: "the event logger paused",
8
- helper_stopped: "the event logger stopped",
9
- };
10
- function clickText(button, double, e) {
11
- const verb = double ? "double-click" : "click";
12
- const which = button && button !== "left" ? `${button.charAt(0).toUpperCase()}${button.slice(1)} ${verb}` : `${verb.charAt(0).toUpperCase()}${verb.slice(1)}`;
13
- return e.inFrame ? `${which} at (${e.x}, ${e.y})` : `${which} outside the recorded area`;
14
- }
15
- export function inputSteps(events) {
16
- const steps = [];
17
- const sorted = [...events].sort((a, b) => a.t - b.t);
18
- let lastDown = null;
19
- let scroll = null;
20
- const scrollText = (axis, notches) => {
21
- const dir = axis === "vertical" ? (notches >= 0 ? "up" : "down") : notches >= 0 ? "right" : "left";
22
- const n = Math.abs(notches);
23
- return `Scroll ${dir} ${n} notch${n === 1 ? "" : "es"}`;
24
- };
25
- for (const e of sorted) {
26
- if (e.type === "move" || e.type === "up")
27
- continue;
28
- if (e.type !== "wheel")
29
- scroll = null;
30
- if (e.type === "down") {
31
- const prev = lastDown;
32
- if (prev &&
33
- prev.e.button === e.button &&
34
- e.t - prev.e.t <= DOUBLE_CLICK_SEC &&
35
- Math.abs(e.x - prev.e.x) <= DOUBLE_CLICK_PX &&
36
- Math.abs(e.y - prev.e.y) <= DOUBLE_CLICK_PX &&
37
- prev.step.action === "click" &&
38
- steps.at(-1) === prev.step) {
39
- prev.step.action = "double_click";
40
- prev.step.text = clickText(e.button, true, prev.e);
41
- lastDown = null;
42
- continue;
43
- }
44
- const step = {
45
- t: e.t,
46
- action: "click",
47
- text: clickText(e.button, false, e),
48
- x: e.x,
49
- y: e.y,
50
- button: e.button ?? "left",
51
- inFrame: e.inFrame,
52
- };
53
- steps.push(step);
54
- lastDown = { e, step };
55
- continue;
56
- }
57
- lastDown = null;
58
- if (e.type === "wheel") {
59
- const axis = e.axis ?? "vertical";
60
- const delta = e.delta ?? 0;
61
- if (scroll && scroll.axis === axis && e.t - scroll.last <= SCROLL_JOIN_SEC && Math.sign(delta) === Math.sign(scroll.notches)) {
62
- scroll.notches += delta;
63
- scroll.last = e.t;
64
- scroll.step.text = scrollText(axis, scroll.notches);
65
- continue;
66
- }
67
- const step = { t: e.t, action: "scroll", text: scrollText(axis, delta), x: e.x, y: e.y, inFrame: e.inFrame };
68
- steps.push(step);
69
- scroll = { step, axis, notches: delta, last: e.t };
70
- }
71
- else if (e.type === "key") {
72
- steps.push({ t: e.t, action: "shortcut", text: `Press ${e.keys ?? "a shortcut"}`, ...(e.keys ? { keys: e.keys } : {}) });
73
- }
74
- else if (e.type === "typing") {
75
- const d = e.durationSec ?? 0;
76
- steps.push({ t: e.t, action: "typing", text: `Type${d > 0 ? ` for ${r3(d)} s` : ""} (keys are not logged)`, durationSec: d });
77
- }
78
- else if (e.type === "gap") {
79
- const why = GAP_WHY[e.reason ?? "input_not_seen"];
80
- const d = r3(e.durationSec ?? 0);
81
- steps.push({ t: e.t, action: "gap", text: `Input may be missing for ${d} s (${why})`, durationSec: d });
82
- }
83
- }
84
- return steps;
85
- }
86
- export function reconstructSteps(events) {
87
- return inputSteps(events).map(({ button: _b, inFrame: _i, keys: _k, durationSec: _d, ...step }) => step);
88
- }
@@ -1,38 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { ScreencastError } from "./errors.js";
3
- import { nudgeScript } from "./wgc.js";
4
- import { runFfmpeg, wgcAvailable } from "./ffmpeg.js";
5
- import { buildScreenshotArgs, buildWgcScreenshotArgs } from "./targets.js";
6
- export const WGC_STILL_TIMEOUT_MS = 15_000;
7
- export async function captureStill(resolved, output, backend = "gdigrab") {
8
- if (backend === "gdigrab") {
9
- await runFfmpeg(buildScreenshotArgs(resolved.target, output, resolved.monitors), 60_000);
10
- return;
11
- }
12
- const hwnd = resolved.window?.hwnd;
13
- if (hwnd === undefined) {
14
- throw new ScreencastError("backend 'wgc' captures a single window: use a window:<title> target.");
15
- }
16
- if (!wgcAvailable()) {
17
- throw new ScreencastError("backend 'wgc' needs FFmpeg 8 or newer with the gfxcapture filter (Windows Graphics Capture).", "Check with `ffmpeg -h filter=gfxcapture`. Recent Windows builds (e.g. `winget install Gyan.FFmpeg`) include it. " +
18
- "Or use the default backend, which captures what is visible on screen.");
19
- }
20
- const nudge = spawn("powershell", ["-NoProfile", "-NonInteractive", "-Command", nudgeScript(hwnd, 100, process.pid)], {
21
- stdio: "ignore",
22
- windowsHide: true,
23
- });
24
- nudge.on("error", () => {
25
- });
26
- try {
27
- await runFfmpeg(buildWgcScreenshotArgs(hwnd, output), WGC_STILL_TIMEOUT_MS);
28
- }
29
- catch (err) {
30
- if (err instanceof ScreencastError && /timed out/.test(err.message)) {
31
- throw new ScreencastError(`Windows Graphics Capture got no frame from the window in ${WGC_STILL_TIMEOUT_MS / 1000} s.`, "The window may be hung or protected from capture. Try the default backend with the window in front.");
32
- }
33
- throw err;
34
- }
35
- finally {
36
- nudge.kill();
37
- }
38
- }
@@ -1,64 +0,0 @@
1
- import { virtualDesktopBounds } from "./targets.js";
2
- import { parseWindowSelector, selectWindow } from "./windows.js";
3
- import { errorMessage } from "./errors.js";
4
- function windowTarget(w) {
5
- return w.hwnd !== undefined ? `window:hwnd=${w.hwnd}` : `window:${w.title}`;
6
- }
7
- function firstSentence(message) {
8
- const m = /^.*?[.!?](?=\s|$)/.exec(message);
9
- return m ? m[0] : message;
10
- }
11
- function resolves(query, w, allowCloaked) {
12
- try {
13
- selectWindow(query, windowTarget(w).slice("window:".length), { allowCloaked, exactOnly: true });
14
- return { ok: true };
15
- }
16
- catch (err) {
17
- return { ok: false, reason: firstSentence(errorMessage(err)) };
18
- }
19
- }
20
- export function buildTargetList(monitors, query, opts) {
21
- const filter = opts.filter ?? {};
22
- const exe = filter.exe ? parseWindowSelector(`exe=${filter.exe}`) : null;
23
- const wantedExe = exe?.kind === "exe" ? exe.exe : null;
24
- const needle = filter.titleContains?.trim().toLowerCase() || null;
25
- const v = virtualDesktopBounds(monitors);
26
- const desktop = monitors.length > 0 ? v : query.virtual;
27
- const windows = [];
28
- for (const w of Array.isArray(query.windows) ? query.windows : []) {
29
- if (wantedExe !== null && (w.exe ?? "").toLowerCase().replace(/\.exe$/, "") !== wantedExe)
30
- continue;
31
- if (needle !== null && !w.title.toLowerCase().includes(needle))
32
- continue;
33
- const gdi = resolves(query, w, false);
34
- const wgc = opts.wgcAvailable && w.hwnd !== undefined ? resolves(query, w, true) : { ok: false };
35
- if (filter.capturableOnly && !gdi.ok && !wgc.ok)
36
- continue;
37
- windows.push({
38
- target: windowTarget(w),
39
- title: w.title,
40
- exe: w.exe || null,
41
- pid: typeof w.pid === "number" ? w.pid : null,
42
- hwnd: w.hwnd ?? null,
43
- bounds: { x: w.left, y: w.top, width: w.right - w.left, height: w.bottom - w.top },
44
- minimized: Boolean(w.minimized),
45
- cloaked: Boolean(w.cloaked),
46
- capturable: gdi.ok,
47
- wgcCapturable: wgc.ok,
48
- ...(gdi.ok ? {} : { reason: gdi.reason }),
49
- });
50
- }
51
- return {
52
- full: { target: "full", bounds: { x: desktop.x, y: desktop.y, width: desktop.w, height: desktop.h } },
53
- monitors: monitors.map((m) => ({
54
- target: `monitor:${m.index}`,
55
- index: m.index,
56
- primary: m.primary,
57
- bounds: { x: m.x, y: m.y, width: m.width, height: m.height },
58
- dpi: m.dpi ?? null,
59
- scale: m.dpi ? Math.round((m.dpi / 96) * 100) / 100 : null,
60
- })),
61
- windows,
62
- wgcAvailable: opts.wgcAvailable,
63
- };
64
- }