@tmhs/screencast-mcp 0.39.0 → 0.44.2

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 (332) hide show
  1. package/README.md +58 -14
  2. package/assets/icon.png +0 -0
  3. package/assets/ui/player.html +38 -302
  4. package/assets/ui/player.js +382 -0
  5. package/dist/context.js +0 -5
  6. package/dist/index.js +5 -21
  7. package/dist/prompts.js +0 -7
  8. package/dist/resources.js +2 -14
  9. package/dist/server.js +37 -11
  10. package/dist/tools/assembleHighlights.js +12 -7
  11. package/dist/tools/burnSubtitles.js +12 -6
  12. package/dist/tools/callout.js +32 -16
  13. package/dist/tools/clip.js +12 -9
  14. package/dist/tools/compress.js +10 -5
  15. package/dist/tools/concat.js +16 -15
  16. package/dist/tools/contactSheet.js +26 -22
  17. package/dist/tools/convert.js +12 -6
  18. package/dist/tools/crop.js +12 -7
  19. package/dist/tools/cutIdle.js +15 -9
  20. package/dist/tools/denoise.js +12 -6
  21. package/dist/tools/doctor.js +133 -0
  22. package/dist/tools/exportGif.js +14 -10
  23. package/dist/tools/exportPreset.js +11 -8
  24. package/dist/tools/extractAudio.js +10 -8
  25. package/dist/tools/findText.js +69 -65
  26. package/dist/tools/getMediaInfo.js +17 -3
  27. package/dist/tools/getSession.js +15 -3
  28. package/dist/tools/listAudioDevices.js +14 -7
  29. package/dist/tools/listSessions.js +13 -3
  30. package/dist/tools/listTargets.js +76 -0
  31. package/dist/tools/musicBed.js +14 -10
  32. package/dist/tools/normalizeAudio.js +12 -8
  33. package/dist/tools/overlay.js +16 -12
  34. package/dist/tools/pipeline.js +31 -22
  35. package/dist/tools/readEvents.js +21 -12
  36. package/dist/tools/redactRegion.js +19 -17
  37. package/dist/tools/reframe.js +9 -5
  38. package/dist/tools/reviewRecording.js +63 -22
  39. package/dist/tools/sampleFrames.js +33 -40
  40. package/dist/tools/scale.js +9 -3
  41. package/dist/tools/screenDiff.js +23 -17
  42. package/dist/tools/screenshot.js +21 -17
  43. package/dist/tools/speed.js +15 -4
  44. package/dist/tools/startRecording.js +48 -52
  45. package/dist/tools/stopRecording.js +10 -9
  46. package/dist/tools/titleCard.js +19 -11
  47. package/dist/tools/transcribe.js +13 -7
  48. package/dist/tools/trim.js +11 -10
  49. package/dist/tools/waitForChange.js +37 -22
  50. package/dist/tools/xfadeTransition.js +12 -8
  51. package/dist/tools/zoom.js +26 -29
  52. package/dist/utils/anim.js +1 -21
  53. package/dist/utils/animExport.js +5 -10
  54. package/dist/utils/audio.js +4 -33
  55. package/dist/utils/audioDevices.js +1 -48
  56. package/dist/utils/callout.js +1 -19
  57. package/dist/utils/calloutAssets.js +21 -11
  58. package/dist/utils/capabilities.js +95 -0
  59. package/dist/utils/captions.js +9 -26
  60. package/dist/utils/consent.js +29 -0
  61. package/dist/utils/diff.js +0 -46
  62. package/dist/utils/errors.js +5 -13
  63. package/dist/utils/events.js +21 -77
  64. package/dist/utils/expr.js +11 -0
  65. package/dist/utils/ffmpeg.js +119 -48
  66. package/dist/utils/fontCoverage.js +177 -0
  67. package/dist/utils/fonts.js +139 -23
  68. package/dist/utils/idle.js +12 -24
  69. package/dist/utils/images.js +0 -17
  70. package/dist/utils/jobs.js +42 -41
  71. package/dist/utils/lifecycle.js +0 -29
  72. package/dist/utils/logging.js +75 -0
  73. package/dist/utils/media.js +11 -122
  74. package/dist/utils/monitors.js +7 -43
  75. package/dist/utils/ocr.js +53 -71
  76. package/dist/utils/paths.js +68 -31
  77. package/dist/utils/pipeline.js +0 -23
  78. package/dist/utils/player.js +50 -27
  79. package/dist/utils/produce.js +6 -66
  80. package/dist/utils/resolveTarget.js +0 -19
  81. package/dist/utils/retention.js +1 -15
  82. package/dist/utils/roots.js +42 -0
  83. package/dist/utils/sessions.js +195 -160
  84. package/dist/utils/sheet.js +0 -19
  85. package/dist/utils/still.js +0 -15
  86. package/dist/utils/targetList.js +63 -0
  87. package/dist/utils/targets.js +5 -70
  88. package/dist/utils/toolSpec.js +25 -0
  89. package/dist/utils/toolsets.js +102 -0
  90. package/dist/utils/validate.js +0 -22
  91. package/dist/utils/wgc.js +0 -46
  92. package/dist/utils/windows.js +5 -50
  93. package/dist/utils/zoom.js +55 -85
  94. package/dist/wgcRecorder.js +1 -30
  95. package/package.json +7 -3
  96. package/dist/context.d.ts +0 -9
  97. package/dist/context.d.ts.map +0 -1
  98. package/dist/context.js.map +0 -1
  99. package/dist/index.d.ts +0 -3
  100. package/dist/index.d.ts.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/prompts.d.ts +0 -10
  103. package/dist/prompts.d.ts.map +0 -1
  104. package/dist/prompts.js.map +0 -1
  105. package/dist/resources.d.ts +0 -3
  106. package/dist/resources.d.ts.map +0 -1
  107. package/dist/resources.js.map +0 -1
  108. package/dist/server.d.ts +0 -3
  109. package/dist/server.d.ts.map +0 -1
  110. package/dist/server.js.map +0 -1
  111. package/dist/tools/assembleHighlights.d.ts +0 -3
  112. package/dist/tools/assembleHighlights.d.ts.map +0 -1
  113. package/dist/tools/assembleHighlights.js.map +0 -1
  114. package/dist/tools/burnSubtitles.d.ts +0 -3
  115. package/dist/tools/burnSubtitles.d.ts.map +0 -1
  116. package/dist/tools/burnSubtitles.js.map +0 -1
  117. package/dist/tools/callout.d.ts +0 -37
  118. package/dist/tools/callout.d.ts.map +0 -1
  119. package/dist/tools/callout.js.map +0 -1
  120. package/dist/tools/clip.d.ts +0 -3
  121. package/dist/tools/clip.d.ts.map +0 -1
  122. package/dist/tools/clip.js.map +0 -1
  123. package/dist/tools/compress.d.ts +0 -3
  124. package/dist/tools/compress.d.ts.map +0 -1
  125. package/dist/tools/compress.js.map +0 -1
  126. package/dist/tools/concat.d.ts +0 -3
  127. package/dist/tools/concat.d.ts.map +0 -1
  128. package/dist/tools/concat.js.map +0 -1
  129. package/dist/tools/contactSheet.d.ts +0 -3
  130. package/dist/tools/contactSheet.d.ts.map +0 -1
  131. package/dist/tools/contactSheet.js.map +0 -1
  132. package/dist/tools/convert.d.ts +0 -3
  133. package/dist/tools/convert.d.ts.map +0 -1
  134. package/dist/tools/convert.js.map +0 -1
  135. package/dist/tools/crop.d.ts +0 -3
  136. package/dist/tools/crop.d.ts.map +0 -1
  137. package/dist/tools/crop.js.map +0 -1
  138. package/dist/tools/cutIdle.d.ts +0 -3
  139. package/dist/tools/cutIdle.d.ts.map +0 -1
  140. package/dist/tools/cutIdle.js.map +0 -1
  141. package/dist/tools/denoise.d.ts +0 -3
  142. package/dist/tools/denoise.d.ts.map +0 -1
  143. package/dist/tools/denoise.js.map +0 -1
  144. package/dist/tools/exportGif.d.ts +0 -3
  145. package/dist/tools/exportGif.d.ts.map +0 -1
  146. package/dist/tools/exportGif.js.map +0 -1
  147. package/dist/tools/exportPreset.d.ts +0 -3
  148. package/dist/tools/exportPreset.d.ts.map +0 -1
  149. package/dist/tools/exportPreset.js.map +0 -1
  150. package/dist/tools/extractAudio.d.ts +0 -3
  151. package/dist/tools/extractAudio.d.ts.map +0 -1
  152. package/dist/tools/extractAudio.js.map +0 -1
  153. package/dist/tools/findText.d.ts +0 -6
  154. package/dist/tools/findText.d.ts.map +0 -1
  155. package/dist/tools/findText.js.map +0 -1
  156. package/dist/tools/getMediaInfo.d.ts +0 -3
  157. package/dist/tools/getMediaInfo.d.ts.map +0 -1
  158. package/dist/tools/getMediaInfo.js.map +0 -1
  159. package/dist/tools/getSession.d.ts +0 -3
  160. package/dist/tools/getSession.d.ts.map +0 -1
  161. package/dist/tools/getSession.js.map +0 -1
  162. package/dist/tools/listAudioDevices.d.ts +0 -3
  163. package/dist/tools/listAudioDevices.d.ts.map +0 -1
  164. package/dist/tools/listAudioDevices.js.map +0 -1
  165. package/dist/tools/listSessions.d.ts +0 -3
  166. package/dist/tools/listSessions.d.ts.map +0 -1
  167. package/dist/tools/listSessions.js.map +0 -1
  168. package/dist/tools/musicBed.d.ts +0 -3
  169. package/dist/tools/musicBed.d.ts.map +0 -1
  170. package/dist/tools/musicBed.js.map +0 -1
  171. package/dist/tools/normalizeAudio.d.ts +0 -3
  172. package/dist/tools/normalizeAudio.d.ts.map +0 -1
  173. package/dist/tools/normalizeAudio.js.map +0 -1
  174. package/dist/tools/overlay.d.ts +0 -3
  175. package/dist/tools/overlay.d.ts.map +0 -1
  176. package/dist/tools/overlay.js.map +0 -1
  177. package/dist/tools/pipeline.d.ts +0 -3
  178. package/dist/tools/pipeline.d.ts.map +0 -1
  179. package/dist/tools/pipeline.js.map +0 -1
  180. package/dist/tools/readEvents.d.ts +0 -6
  181. package/dist/tools/readEvents.d.ts.map +0 -1
  182. package/dist/tools/readEvents.js.map +0 -1
  183. package/dist/tools/redactRegion.d.ts +0 -13
  184. package/dist/tools/redactRegion.d.ts.map +0 -1
  185. package/dist/tools/redactRegion.js.map +0 -1
  186. package/dist/tools/reframe.d.ts +0 -3
  187. package/dist/tools/reframe.d.ts.map +0 -1
  188. package/dist/tools/reframe.js.map +0 -1
  189. package/dist/tools/reviewRecording.d.ts +0 -5
  190. package/dist/tools/reviewRecording.d.ts.map +0 -1
  191. package/dist/tools/reviewRecording.js.map +0 -1
  192. package/dist/tools/sampleFrames.d.ts +0 -3
  193. package/dist/tools/sampleFrames.d.ts.map +0 -1
  194. package/dist/tools/sampleFrames.js.map +0 -1
  195. package/dist/tools/scale.d.ts +0 -3
  196. package/dist/tools/scale.d.ts.map +0 -1
  197. package/dist/tools/scale.js.map +0 -1
  198. package/dist/tools/screenDiff.d.ts +0 -3
  199. package/dist/tools/screenDiff.d.ts.map +0 -1
  200. package/dist/tools/screenDiff.js.map +0 -1
  201. package/dist/tools/screenshot.d.ts +0 -3
  202. package/dist/tools/screenshot.d.ts.map +0 -1
  203. package/dist/tools/screenshot.js.map +0 -1
  204. package/dist/tools/speed.d.ts +0 -3
  205. package/dist/tools/speed.d.ts.map +0 -1
  206. package/dist/tools/speed.js.map +0 -1
  207. package/dist/tools/startRecording.d.ts +0 -3
  208. package/dist/tools/startRecording.d.ts.map +0 -1
  209. package/dist/tools/startRecording.js.map +0 -1
  210. package/dist/tools/stopRecording.d.ts +0 -3
  211. package/dist/tools/stopRecording.d.ts.map +0 -1
  212. package/dist/tools/stopRecording.js.map +0 -1
  213. package/dist/tools/titleCard.d.ts +0 -3
  214. package/dist/tools/titleCard.d.ts.map +0 -1
  215. package/dist/tools/titleCard.js.map +0 -1
  216. package/dist/tools/transcribe.d.ts +0 -3
  217. package/dist/tools/transcribe.d.ts.map +0 -1
  218. package/dist/tools/transcribe.js.map +0 -1
  219. package/dist/tools/trim.d.ts +0 -3
  220. package/dist/tools/trim.d.ts.map +0 -1
  221. package/dist/tools/trim.js.map +0 -1
  222. package/dist/tools/waitForChange.d.ts +0 -3
  223. package/dist/tools/waitForChange.d.ts.map +0 -1
  224. package/dist/tools/waitForChange.js.map +0 -1
  225. package/dist/tools/xfadeTransition.d.ts +0 -3
  226. package/dist/tools/xfadeTransition.d.ts.map +0 -1
  227. package/dist/tools/xfadeTransition.js.map +0 -1
  228. package/dist/tools/zoom.d.ts +0 -15
  229. package/dist/tools/zoom.d.ts.map +0 -1
  230. package/dist/tools/zoom.js.map +0 -1
  231. package/dist/utils/anim.d.ts +0 -33
  232. package/dist/utils/anim.d.ts.map +0 -1
  233. package/dist/utils/anim.js.map +0 -1
  234. package/dist/utils/animExport.d.ts +0 -27
  235. package/dist/utils/animExport.d.ts.map +0 -1
  236. package/dist/utils/animExport.js.map +0 -1
  237. package/dist/utils/audio.d.ts +0 -49
  238. package/dist/utils/audio.d.ts.map +0 -1
  239. package/dist/utils/audio.js.map +0 -1
  240. package/dist/utils/audioDevices.d.ts +0 -33
  241. package/dist/utils/audioDevices.d.ts.map +0 -1
  242. package/dist/utils/audioDevices.js.map +0 -1
  243. package/dist/utils/callout.d.ts +0 -72
  244. package/dist/utils/callout.d.ts.map +0 -1
  245. package/dist/utils/callout.js.map +0 -1
  246. package/dist/utils/calloutAssets.d.ts +0 -3
  247. package/dist/utils/calloutAssets.d.ts.map +0 -1
  248. package/dist/utils/calloutAssets.js.map +0 -1
  249. package/dist/utils/captions.d.ts +0 -26
  250. package/dist/utils/captions.d.ts.map +0 -1
  251. package/dist/utils/captions.js.map +0 -1
  252. package/dist/utils/diff.d.ts +0 -112
  253. package/dist/utils/diff.d.ts.map +0 -1
  254. package/dist/utils/diff.js.map +0 -1
  255. package/dist/utils/errors.d.ts +0 -33
  256. package/dist/utils/errors.d.ts.map +0 -1
  257. package/dist/utils/errors.js.map +0 -1
  258. package/dist/utils/events.d.ts +0 -143
  259. package/dist/utils/events.d.ts.map +0 -1
  260. package/dist/utils/events.js.map +0 -1
  261. package/dist/utils/ffmpeg.d.ts +0 -50
  262. package/dist/utils/ffmpeg.d.ts.map +0 -1
  263. package/dist/utils/ffmpeg.js.map +0 -1
  264. package/dist/utils/fonts.d.ts +0 -17
  265. package/dist/utils/fonts.d.ts.map +0 -1
  266. package/dist/utils/fonts.js.map +0 -1
  267. package/dist/utils/idle.d.ts +0 -23
  268. package/dist/utils/idle.d.ts.map +0 -1
  269. package/dist/utils/idle.js.map +0 -1
  270. package/dist/utils/images.d.ts +0 -21
  271. package/dist/utils/images.d.ts.map +0 -1
  272. package/dist/utils/images.js.map +0 -1
  273. package/dist/utils/jobs.d.ts +0 -44
  274. package/dist/utils/jobs.d.ts.map +0 -1
  275. package/dist/utils/jobs.js.map +0 -1
  276. package/dist/utils/lifecycle.d.ts +0 -29
  277. package/dist/utils/lifecycle.d.ts.map +0 -1
  278. package/dist/utils/lifecycle.js.map +0 -1
  279. package/dist/utils/media.d.ts +0 -272
  280. package/dist/utils/media.d.ts.map +0 -1
  281. package/dist/utils/media.js.map +0 -1
  282. package/dist/utils/monitors.d.ts +0 -47
  283. package/dist/utils/monitors.d.ts.map +0 -1
  284. package/dist/utils/monitors.js.map +0 -1
  285. package/dist/utils/ocr.d.ts +0 -50
  286. package/dist/utils/ocr.d.ts.map +0 -1
  287. package/dist/utils/ocr.js.map +0 -1
  288. package/dist/utils/paths.d.ts +0 -28
  289. package/dist/utils/paths.d.ts.map +0 -1
  290. package/dist/utils/paths.js.map +0 -1
  291. package/dist/utils/pipeline.d.ts +0 -69
  292. package/dist/utils/pipeline.d.ts.map +0 -1
  293. package/dist/utils/pipeline.js.map +0 -1
  294. package/dist/utils/player.d.ts +0 -30
  295. package/dist/utils/player.d.ts.map +0 -1
  296. package/dist/utils/player.js.map +0 -1
  297. package/dist/utils/produce.d.ts +0 -126
  298. package/dist/utils/produce.d.ts.map +0 -1
  299. package/dist/utils/produce.js.map +0 -1
  300. package/dist/utils/resolveTarget.d.ts +0 -32
  301. package/dist/utils/resolveTarget.d.ts.map +0 -1
  302. package/dist/utils/resolveTarget.js.map +0 -1
  303. package/dist/utils/retention.d.ts +0 -10
  304. package/dist/utils/retention.d.ts.map +0 -1
  305. package/dist/utils/retention.js.map +0 -1
  306. package/dist/utils/sessions.d.ts +0 -154
  307. package/dist/utils/sessions.d.ts.map +0 -1
  308. package/dist/utils/sessions.js.map +0 -1
  309. package/dist/utils/sheet.d.ts +0 -26
  310. package/dist/utils/sheet.d.ts.map +0 -1
  311. package/dist/utils/sheet.js.map +0 -1
  312. package/dist/utils/still.d.ts +0 -7
  313. package/dist/utils/still.d.ts.map +0 -1
  314. package/dist/utils/still.js.map +0 -1
  315. package/dist/utils/targets.d.ts +0 -113
  316. package/dist/utils/targets.d.ts.map +0 -1
  317. package/dist/utils/targets.js.map +0 -1
  318. package/dist/utils/validate.d.ts +0 -15
  319. package/dist/utils/validate.d.ts.map +0 -1
  320. package/dist/utils/validate.js.map +0 -1
  321. package/dist/utils/wgc.d.ts +0 -46
  322. package/dist/utils/wgc.d.ts.map +0 -1
  323. package/dist/utils/wgc.js.map +0 -1
  324. package/dist/utils/windows.d.ts +0 -94
  325. package/dist/utils/windows.d.ts.map +0 -1
  326. package/dist/utils/windows.js.map +0 -1
  327. package/dist/utils/zoom.d.ts +0 -95
  328. package/dist/utils/zoom.d.ts.map +0 -1
  329. package/dist/utils/zoom.js.map +0 -1
  330. package/dist/wgcRecorder.d.ts +0 -2
  331. package/dist/wgcRecorder.d.ts.map +0 -1
  332. package/dist/wgcRecorder.js.map +0 -1
@@ -1,14 +1,10 @@
1
- /**
2
- * ffmpeg / ffprobe discovery and invocation.
3
- *
4
- * ffmpeg and ffprobe are EXTERNAL dependencies. They are detected on PATH (or
5
- * via the FFMPEG_PATH / FFPROBE_PATH env overrides) and a missing binary
6
- * produces a clear ScreencastError with an install hint, rather than a cryptic
7
- * spawn failure deep inside a tool call.
8
- */
9
1
  import { spawn, spawnSync } from "node:child_process";
2
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
10
5
  import { ScreencastError } from "./errors.js";
11
6
  import { buildProbeArgs, parseMediaInfo } from "./media.js";
7
+ import { logFfmpegWarnings } from "./logging.js";
12
8
  const INSTALL_HINT = "ffmpeg and ffprobe must be installed and on PATH (or set FFMPEG_PATH / " +
13
9
  "FFPROBE_PATH). Windows: `winget install Gyan.FFmpeg` or `choco install " +
14
10
  "ffmpeg`. macOS: `brew install ffmpeg`. Linux: `apt install ffmpeg`.";
@@ -16,7 +12,6 @@ function resolveBinary(envVar, fallback) {
16
12
  const override = process.env[envVar];
17
13
  return override && override.trim().length > 0 ? override : fallback;
18
14
  }
19
- /** Return true if `bin -version` runs and exits 0. */
20
15
  export function binaryWorks(bin) {
21
16
  try {
22
17
  const res = spawnSync(bin, ["-version"], {
@@ -29,10 +24,6 @@ export function binaryWorks(bin) {
29
24
  return false;
30
25
  }
31
26
  }
32
- /**
33
- * Detect ffmpeg + ffprobe. Returns the resolved binary names/paths, or throws a
34
- * ScreencastError with an install hint naming whichever binary is missing.
35
- */
36
27
  export function detectFfmpeg() {
37
28
  const ffmpeg = resolveBinary("FFMPEG_PATH", "ffmpeg");
38
29
  const ffprobe = resolveBinary("FFPROBE_PATH", "ffprobe");
@@ -47,7 +38,6 @@ export function detectFfmpeg() {
47
38
  return { ffmpeg, ffprobe };
48
39
  }
49
40
  let cached = null;
50
- /** Cached variant for per-call guards. Re-detects only after a failure. */
51
41
  export function requireFfmpeg() {
52
42
  if (cached)
53
43
  return cached;
@@ -55,8 +45,6 @@ export function requireFfmpeg() {
55
45
  return cached;
56
46
  }
57
47
  let wgc = null;
58
- /** True when this ffmpeg has the gfxcapture source (Windows Graphics Capture,
59
- * FFmpeg 8+ on Windows). Probed once. */
60
48
  export function wgcAvailable() {
61
49
  if (wgc !== null)
62
50
  return wgc;
@@ -76,8 +64,6 @@ export function wgcAvailable() {
76
64
  return wgc;
77
65
  }
78
66
  const filterCache = new Map();
79
- /** True when this ffmpeg build has the named filter (e.g. whisper needs
80
- * --enable-whisper, subtitles needs libass). Probed once per name. */
81
67
  export function hasFilter(name) {
82
68
  const cached = filterCache.get(name);
83
69
  if (cached !== undefined)
@@ -97,8 +83,6 @@ export function hasFilter(name) {
97
83
  filterCache.set(name, found);
98
84
  return found;
99
85
  }
100
- /** Run a binary to completion, capturing stdout/stderr. Used for ffprobe and
101
- * short ffmpeg edit jobs (not for long-running captures). */
102
86
  export function runCapture(bin, args, timeoutMs = 5 * 60 * 1000, opts = {}) {
103
87
  return new Promise((resolve, reject) => {
104
88
  const child = spawn(bin, args, { windowsHide: true });
@@ -106,10 +90,6 @@ export function runCapture(bin, args, timeoutMs = 5 * 60 * 1000, opts = {}) {
106
90
  child.stdin?.end();
107
91
  let stdout = "";
108
92
  let stderr = "";
109
- // On a timeout or cancel, settle only once the child has actually exited:
110
- // on Windows a file the dying process still holds open cannot be deleted
111
- // yet, so a caller cleaning up its output would hit EPERM. A short grace
112
- // timer still settles if 'close' never arrives.
113
93
  let killError = null;
114
94
  let graceTimer;
115
95
  const kill = (error) => {
@@ -149,47 +129,139 @@ export function runCapture(bin, args, timeoutMs = 5 * 60 * 1000, opts = {}) {
149
129
  });
150
130
  });
151
131
  }
152
- /** Run ffmpeg and return its stdout as raw bytes (e.g. `-f rawvideo -`), which
153
- * runCapture's text decoding would corrupt. Rejects on a non-zero exit. */
154
- export function runFfmpegBuffer(args, timeoutMs = 30_000) {
132
+ const SCRIPTABLE_OPTS = new Set(["-vf", "-af", "-filter_complex", "-lavfi", "-filter:v", "-filter:a"]);
133
+ export const MAX_INLINE_FILTER = 8_000;
134
+ const LEGACY_SCRIPT_OPTS = {
135
+ "-vf": "-filter_script:v",
136
+ "-filter:v": "-filter_script:v",
137
+ "-af": "-filter_script:a",
138
+ "-filter:a": "-filter_script:a",
139
+ "-filter_complex": "-filter_complex_script",
140
+ "-lavfi": "-filter_complex_script",
141
+ };
142
+ let modernScripts = null;
143
+ function supportsOptionFiles() {
144
+ if (modernScripts !== null)
145
+ return modernScripts;
146
+ try {
147
+ const res = spawnSync(requireFfmpeg().ffmpeg, ["-hide_banner", "-version"], {
148
+ encoding: "utf8",
149
+ windowsHide: true,
150
+ timeout: 10_000,
151
+ });
152
+ const avutil = /^\s*libavutil\s+(\d+)\./m.exec(res.stdout ?? "");
153
+ modernScripts = avutil?.[1] === undefined || Number(avutil[1]) >= 59;
154
+ }
155
+ catch {
156
+ modernScripts = true;
157
+ }
158
+ return modernScripts;
159
+ }
160
+ export function scriptLongFilters(args, modern) {
161
+ let dir = null;
162
+ const out = [...args];
163
+ for (const [i, a] of args.entries()) {
164
+ const opt = args[i - 1];
165
+ if (opt === undefined || !SCRIPTABLE_OPTS.has(opt) || a.length <= MAX_INLINE_FILTER)
166
+ continue;
167
+ dir ??= mkdtempSync(join(tmpdir(), "screencast-filter-"));
168
+ const file = join(dir, `filter${i}.txt`);
169
+ writeFileSync(file, a);
170
+ modern ??= supportsOptionFiles();
171
+ out[i - 1] = modern ? `-/${opt.slice(1)}` : (LEGACY_SCRIPT_OPTS[opt] ?? opt);
172
+ out[i] = file;
173
+ }
174
+ const d = dir;
175
+ return { args: out, cleanup: () => d && rmSync(d, { recursive: true, force: true }) };
176
+ }
177
+ export async function runFfmpegBuffer(args, timeoutMs = 30_000, opts = {}) {
178
+ const chunks = [];
179
+ await streamFfmpeg(args, timeoutMs, (d) => chunks.push(d), opts);
180
+ return Buffer.concat(chunks);
181
+ }
182
+ export async function runFfmpegFrames(args, frameBytes, onFrame, timeoutMs = 30_000, opts = {}) {
183
+ if (!(frameBytes > 0))
184
+ throw new ScreencastError("frameBytes must be positive.");
185
+ let pending = Buffer.alloc(0);
186
+ let count = 0;
187
+ await streamFfmpeg(args, timeoutMs, (d) => {
188
+ pending = pending.length ? Buffer.concat([pending, d]) : d;
189
+ let o = 0;
190
+ for (; o + frameBytes <= pending.length; o += frameBytes) {
191
+ onFrame(Buffer.from(pending.subarray(o, o + frameBytes)));
192
+ count++;
193
+ }
194
+ pending = pending.subarray(o);
195
+ }, opts);
196
+ return count;
197
+ }
198
+ function streamFfmpeg(rawArgs, timeoutMs, onData, opts) {
155
199
  const { ffmpeg } = requireFfmpeg();
200
+ const { args, cleanup } = scriptLongFilters(rawArgs);
156
201
  return new Promise((resolve, reject) => {
157
202
  const child = spawn(ffmpeg, args, { windowsHide: true });
158
- const chunks = [];
159
203
  let stderr = "";
160
- let timedOut = false;
161
- const timer = setTimeout(() => {
162
- timedOut = true;
204
+ let killError = null;
205
+ let graceTimer;
206
+ const kill = (error) => {
207
+ if (killError)
208
+ return;
209
+ killError = error;
163
210
  child.kill("SIGKILL");
164
- }, timeoutMs);
165
- child.stdout?.on("data", (d) => chunks.push(d));
211
+ graceTimer = setTimeout(() => reject(error), 5_000);
212
+ };
213
+ const onAbort = () => kill(new ScreencastError("ffmpeg was cancelled."));
214
+ const timer = setTimeout(() => kill(new ScreencastError(`ffmpeg timed out after ${Math.round(timeoutMs / 1000)}s.`)), timeoutMs);
215
+ const settle = () => {
216
+ clearTimeout(timer);
217
+ clearTimeout(graceTimer);
218
+ opts.signal?.removeEventListener("abort", onAbort);
219
+ };
220
+ if (opts.signal?.aborted)
221
+ onAbort();
222
+ else
223
+ opts.signal?.addEventListener("abort", onAbort, { once: true });
224
+ child.stdout?.on("data", (d) => {
225
+ if (killError)
226
+ return;
227
+ try {
228
+ onData(d);
229
+ }
230
+ catch (error) {
231
+ kill(error);
232
+ }
233
+ });
166
234
  child.stderr?.on("data", (d) => (stderr += d.toString()));
167
235
  child.on("error", (err) => {
168
- clearTimeout(timer);
236
+ settle();
169
237
  reject(err);
170
238
  });
171
239
  child.on("close", (code) => {
172
- clearTimeout(timer);
173
- if (code === 0)
174
- resolve(Buffer.concat(chunks));
175
- else if (timedOut)
176
- reject(new ScreencastError(`ffmpeg timed out after ${Math.round(timeoutMs / 1000)}s.`));
240
+ settle();
241
+ if (killError)
242
+ reject(killError);
243
+ else if (code === 0)
244
+ resolve();
177
245
  else
178
246
  reject(new ScreencastError(`ffmpeg failed (exit ${code}):\n${stderr.trim().split("\n").slice(-6).join("\n")}`));
179
247
  });
180
- });
248
+ }).finally(cleanup);
181
249
  }
182
- /** Run an ffmpeg edit job and reject with the tail of stderr on non-zero exit. */
183
250
  export async function runFfmpeg(args, timeoutMs, opts = {}) {
184
251
  const { ffmpeg } = requireFfmpeg();
185
- const res = await runCapture(ffmpeg, args, timeoutMs, opts);
186
- if (res.code !== 0) {
187
- const tail = res.stderr.trim().split("\n").slice(-6).join("\n");
188
- throw new ScreencastError(`ffmpeg failed (exit ${res.code}):\n${tail}`);
252
+ const scripted = scriptLongFilters(args);
253
+ try {
254
+ const res = await runCapture(ffmpeg, scripted.args, timeoutMs, opts);
255
+ if (res.code !== 0) {
256
+ const tail = res.stderr.trim().split("\n").slice(-6).join("\n");
257
+ throw new ScreencastError(`ffmpeg failed (exit ${res.code}):\n${tail}`);
258
+ }
259
+ logFfmpegWarnings(res.stderr);
260
+ }
261
+ finally {
262
+ scripted.cleanup();
189
263
  }
190
264
  }
191
- /** Probe a media file with ffprobe and return its flattened MediaInfo. Shared by
192
- * tools that need source dimensions or stream presence before building an edit. */
193
265
  export async function probeMedia(input) {
194
266
  const { ffprobe } = requireFfmpeg();
195
267
  const res = await runCapture(ffprobe, buildProbeArgs(input), 30_000);
@@ -198,4 +270,3 @@ export async function probeMedia(input) {
198
270
  }
199
271
  return parseMediaInfo(JSON.parse(res.stdout));
200
272
  }
201
- //# sourceMappingURL=ffmpeg.js.map
@@ -0,0 +1,177 @@
1
+ export function bufferReader(buf) {
2
+ return (offset, length) => buf.subarray(offset, offset + length);
3
+ }
4
+ function need(b, n, what) {
5
+ if (b.length < n)
6
+ throw new Error(`Truncated font: ${what}.`);
7
+ return b;
8
+ }
9
+ function faceOffset(read, faceIndex) {
10
+ const head = need(read(0, 12), 12, "header");
11
+ if (head.toString("latin1", 0, 4) !== "ttcf") {
12
+ if (faceIndex !== 0)
13
+ throw new Error("Not a font collection; only face 0 exists.");
14
+ return 0;
15
+ }
16
+ const count = head.readUInt32BE(8);
17
+ if (faceIndex < 0 || faceIndex >= count)
18
+ throw new Error(`Face ${faceIndex} is out of range (collection has ${count}).`);
19
+ return need(read(12 + faceIndex * 4, 4), 4, "collection offsets").readUInt32BE(0);
20
+ }
21
+ class RangeBuilder {
22
+ ranges = [];
23
+ add(first, last) {
24
+ const prev = this.ranges[this.ranges.length - 1];
25
+ if (prev && first <= prev[1] + 1)
26
+ prev[1] = Math.max(prev[1], last);
27
+ else
28
+ this.ranges.push([first, last]);
29
+ }
30
+ }
31
+ function parseFormat4(t) {
32
+ const segX2 = need(t, 14, "cmap format 4").readUInt16BE(6);
33
+ const ends = 14;
34
+ const starts = ends + segX2 + 2;
35
+ const deltas = starts + segX2;
36
+ const rangeOffsets = deltas + segX2;
37
+ need(t, rangeOffsets + segX2, "cmap format 4 segments");
38
+ const out = new RangeBuilder();
39
+ for (let s = 0; s < segX2 / 2; s++) {
40
+ const end = t.readUInt16BE(ends + s * 2);
41
+ const start = t.readUInt16BE(starts + s * 2);
42
+ const delta = t.readUInt16BE(deltas + s * 2);
43
+ const ro = t.readUInt16BE(rangeOffsets + s * 2);
44
+ if (start > end)
45
+ continue;
46
+ for (let c = start; c <= end && c !== 0xffff; c++) {
47
+ let glyph;
48
+ if (ro === 0)
49
+ glyph = (c + delta) & 0xffff;
50
+ else {
51
+ const at = rangeOffsets + s * 2 + ro + (c - start) * 2;
52
+ glyph = at + 2 <= t.length ? t.readUInt16BE(at) : 0;
53
+ if (glyph !== 0)
54
+ glyph = (glyph + delta) & 0xffff;
55
+ }
56
+ if (glyph !== 0)
57
+ out.add(c, c);
58
+ }
59
+ }
60
+ return out.ranges;
61
+ }
62
+ function parseGroups(t, format) {
63
+ const n = need(t, 16, `cmap format ${format}`).readUInt32BE(12);
64
+ need(t, 16 + n * 12, `cmap format ${format} groups`);
65
+ const groups = [];
66
+ for (let i = 0; i < n; i++) {
67
+ let first = t.readUInt32BE(16 + i * 12);
68
+ const last = Math.min(t.readUInt32BE(20 + i * 12), 0x10ffff);
69
+ const glyph = t.readUInt32BE(24 + i * 12);
70
+ if (glyph === 0) {
71
+ if (format === 13)
72
+ continue;
73
+ first++;
74
+ }
75
+ if (first <= last)
76
+ groups.push([first, last]);
77
+ }
78
+ groups.sort((a, b) => a[0] - b[0]);
79
+ const out = new RangeBuilder();
80
+ for (const [a, b] of groups)
81
+ out.add(a, b);
82
+ return out.ranges;
83
+ }
84
+ function subtableRank(platform, encoding) {
85
+ if (platform === 3 && encoding === 10)
86
+ return 0;
87
+ if (platform === 0 && (encoding === 4 || encoding === 6))
88
+ return 1;
89
+ if (platform === 3 && encoding === 1)
90
+ return 2;
91
+ if (platform === 0 && encoding <= 3)
92
+ return 3;
93
+ return -1;
94
+ }
95
+ export function parseCoverage(read, faceIndex = 0) {
96
+ const base = faceOffset(read, faceIndex);
97
+ const sfnt = need(read(base, 12), 12, "sfnt header");
98
+ const tag = sfnt.toString("latin1", 0, 4);
99
+ if (tag !== "\u0000\u0001\u0000\u0000" && tag !== "OTTO" && tag !== "true") {
100
+ throw new Error("Not a TrueType/OpenType font.");
101
+ }
102
+ const numTables = sfnt.readUInt16BE(4);
103
+ const dir = need(read(base + 12, numTables * 16), numTables * 16, "table directory");
104
+ let cmapAt = -1;
105
+ for (let i = 0; i < numTables; i++) {
106
+ if (dir.toString("latin1", i * 16, i * 16 + 4) === "cmap")
107
+ cmapAt = dir.readUInt32BE(i * 16 + 8);
108
+ }
109
+ if (cmapAt < 0)
110
+ throw new Error("Font has no cmap table.");
111
+ const cmapHead = need(read(cmapAt, 4), 4, "cmap header");
112
+ const n = cmapHead.readUInt16BE(2);
113
+ const recs = need(read(cmapAt + 4, n * 8), n * 8, "cmap records");
114
+ const candidates = [];
115
+ for (let i = 0; i < n; i++) {
116
+ const rank = subtableRank(recs.readUInt16BE(i * 8), recs.readUInt16BE(i * 8 + 2));
117
+ if (rank >= 0)
118
+ candidates.push({ rank, offset: cmapAt + recs.readUInt32BE(i * 8 + 4) });
119
+ }
120
+ candidates.sort((a, b) => a.rank - b.rank);
121
+ for (const { offset } of candidates) {
122
+ const fmtHead = read(offset, 8);
123
+ if (fmtHead.length < 8)
124
+ continue;
125
+ const format = fmtHead.readUInt16BE(0);
126
+ if (format === 4)
127
+ return parseFormat4(read(offset, fmtHead.readUInt16BE(2)));
128
+ if (format === 12 || format === 13)
129
+ return parseGroups(read(offset, fmtHead.readUInt32BE(4)), format);
130
+ }
131
+ throw new Error("Font has no Unicode cmap subtable this reader understands (formats 4, 12, 13).");
132
+ }
133
+ export function covers(cov, cp) {
134
+ let lo = 0;
135
+ let hi = cov.length - 1;
136
+ while (lo <= hi) {
137
+ const mid = (lo + hi) >> 1;
138
+ const [first, last] = cov[mid];
139
+ if (cp < first)
140
+ hi = mid - 1;
141
+ else if (cp > last)
142
+ lo = mid + 1;
143
+ else
144
+ return true;
145
+ }
146
+ return false;
147
+ }
148
+ export function needsGlyph(cp) {
149
+ if (cp < 0x20 || (cp >= 0x7f && cp < 0xa0))
150
+ return false;
151
+ if (cp === 0xad || cp === 0x34f || cp === 0x61c || cp === 0xfeff)
152
+ return false;
153
+ if (cp >= 0x200b && cp <= 0x200f)
154
+ return false;
155
+ if (cp >= 0x202a && cp <= 0x202e)
156
+ return false;
157
+ if (cp >= 0x2060 && cp <= 0x206f)
158
+ return false;
159
+ if (cp >= 0xfe00 && cp <= 0xfe0f)
160
+ return false;
161
+ if (cp >= 0xe0000 && cp <= 0xe0fff)
162
+ return false;
163
+ return true;
164
+ }
165
+ export function missingChars(text, cov) {
166
+ const seen = new Set();
167
+ const out = [];
168
+ for (const ch of text) {
169
+ const cp = ch.codePointAt(0);
170
+ if (seen.has(cp))
171
+ continue;
172
+ seen.add(cp);
173
+ if (needsGlyph(cp) && !covers(cov, cp))
174
+ out.push(ch);
175
+ }
176
+ return out;
177
+ }
@@ -1,33 +1,15 @@
1
- /**
2
- * Bundled font resolution and filtergraph path escaping.
3
- *
4
- * title_card renders text with ffmpeg's drawtext, which needs a real font file.
5
- * Rather than guess at a system font, the package ships two static Inter weights
6
- * (SIL Open Font License) under assets/fonts/. The path is resolved relative to
7
- * the package root so it works the same from dist/ at runtime and from src/
8
- * under tests, and is escaped for ffmpeg's filtergraph parser.
9
- */
1
+ import { closeSync, existsSync, openSync, readSync, statSync } from "node:fs";
2
+ import { basename, isAbsolute, join } from "node:path";
10
3
  import { fileURLToPath } from "node:url";
4
+ import { ScreencastError } from "./errors.js";
5
+ import { missingChars, parseCoverage } from "./fontCoverage.js";
11
6
  const FONT_FILES = {
12
7
  regular: "Inter-Regular.ttf",
13
8
  bold: "Inter-Bold.ttf",
14
9
  };
15
- /** Absolute path to a bundled Inter weight. The compiled file lives at
16
- * dist/utils/fonts.js, so ../../assets/fonts is the package root. */
17
10
  export function bundledFontPath(weight = "bold") {
18
11
  return fileURLToPath(new URL(`../../assets/fonts/${FONT_FILES[weight]}`, import.meta.url));
19
12
  }
20
- /** Escape a filesystem path for an ffmpeg filtergraph option value (e.g. a
21
- * drawtext fontfile / textfile). The value passes through two unescaping
22
- * stages, so on Windows the drive colon must be double-escaped: forward slashes
23
- * and `\\:`, turning `C:\Fonts\x.ttf` into `C\\:/Fonts/x.ttf`. This is the
24
- * documented Windows incantation and is verified against ffmpeg.
25
- *
26
- * The same two stages apply to the other specials a real path can contain
27
- * (#87): a quote needs `\\\'` (option-level `\'`, whose backslash the graph
28
- * level also escapes), and the graph delimiters `, ; [ ]` need one backslash.
29
- * Without this, a Windows username like O'Brien (temp dir, npx cache) broke
30
- * title_card. */
31
13
  export function escapeFilterPath(p) {
32
14
  return p
33
15
  .replace(/\\/g, "/")
@@ -35,4 +17,138 @@ export function escapeFilterPath(p) {
35
17
  .replace(/'/g, "\\\\\\'")
36
18
  .replace(/([,;[\]])/g, "\\$1");
37
19
  }
38
- //# sourceMappingURL=fonts.js.map
20
+ export const FALLBACK_FAMILIES = {
21
+ segoe: { name: "Segoe UI", regular: ["segoeui.ttf"], bold: ["segoeuib.ttf", "segoeui.ttf"] },
22
+ japanese: {
23
+ name: "Yu Gothic",
24
+ regular: ["YuGothM.ttc", "meiryo.ttc", "msgothic.ttc"],
25
+ bold: ["YuGothB.ttc", "meiryob.ttc", "YuGothM.ttc", "msgothic.ttc"],
26
+ },
27
+ chineseSimplified: { name: "Microsoft YaHei", regular: ["msyh.ttc", "simsun.ttc"], bold: ["msyhbd.ttc", "msyh.ttc", "simsun.ttc"] },
28
+ chineseTraditional: { name: "Microsoft JhengHei", regular: ["msjh.ttc", "mingliub.ttc"], bold: ["msjhbd.ttc", "msjh.ttc"] },
29
+ korean: { name: "Malgun Gothic", regular: ["malgun.ttf"], bold: ["malgunbd.ttf", "malgun.ttf"] },
30
+ indic: { name: "Nirmala UI", regular: ["Nirmala.ttc", "Nirmala.ttf"], bold: ["NirmalaB.ttf", "Nirmala.ttc", "Nirmala.ttf"] },
31
+ thai: { name: "Leelawadee UI", regular: ["LeelawUI.ttf", "tahoma.ttf"], bold: ["LeelaUIb.ttf", "LeelawUI.ttf", "tahomabd.ttf"] },
32
+ ethiopic: { name: "Ebrima", regular: ["ebrima.ttf"], bold: ["ebrimabd.ttf", "ebrima.ttf"] },
33
+ emoji: { name: "Segoe UI Emoji", regular: ["seguiemj.ttf"], bold: ["seguiemj.ttf"] },
34
+ symbol: { name: "Segoe UI Symbol", regular: ["seguisym.ttf"], bold: ["seguisym.ttf"] },
35
+ };
36
+ const DEFAULT_ORDER = [
37
+ "segoe", "japanese", "chineseSimplified", "chineseTraditional", "korean",
38
+ "indic", "thai", "ethiopic", "emoji", "symbol",
39
+ ];
40
+ export function fallbackOrder(text) {
41
+ const front = [];
42
+ if (/[\u3040-\u30ff\u31f0-\u31ff\uff66-\uff9f]/u.test(text))
43
+ front.push("japanese");
44
+ if (/[\u1100-\u11ff\u3130-\u318f\uac00-\ud7af]/u.test(text))
45
+ front.push("korean");
46
+ if (/\p{Script=Han}/u.test(text))
47
+ front.push("chineseSimplified");
48
+ return [...front, ...DEFAULT_ORDER.filter((k) => !front.includes(k))].map((k) => FALLBACK_FAMILIES[k]);
49
+ }
50
+ export function chooseFont(text, candidates) {
51
+ let best = null;
52
+ for (const c of candidates) {
53
+ const missing = missingChars(text, c.coverage);
54
+ if (missing.length === 0)
55
+ return { fontFile: c.path, missing };
56
+ if (!best || missing.length < best.missing.length)
57
+ best = { fontFile: c.path, missing };
58
+ }
59
+ return best;
60
+ }
61
+ export function systemFontsDir() {
62
+ return join(process.env.WINDIR ?? process.env.SystemRoot ?? "C:\\Windows", "Fonts");
63
+ }
64
+ const coverageCache = new Map();
65
+ export function fontCoverage(path) {
66
+ const cached = coverageCache.get(path);
67
+ if (cached !== undefined)
68
+ return cached;
69
+ let cov;
70
+ let fd = null;
71
+ try {
72
+ fd = openSync(path, "r");
73
+ const handle = fd;
74
+ const read = (offset, length) => {
75
+ const b = Buffer.alloc(length);
76
+ return b.subarray(0, readSync(handle, b, 0, length, offset));
77
+ };
78
+ cov = parseCoverage(read);
79
+ }
80
+ catch {
81
+ cov = null;
82
+ }
83
+ finally {
84
+ if (fd !== null)
85
+ closeSync(fd);
86
+ }
87
+ coverageCache.set(path, cov);
88
+ return cov;
89
+ }
90
+ export function resolveFontFileArg(fontFile) {
91
+ if (existsSync(fontFile) && statSync(fontFile).isFile())
92
+ return fontFile;
93
+ if (!isAbsolute(fontFile) && basename(fontFile) === fontFile) {
94
+ const sys = join(systemFontsDir(), fontFile);
95
+ if (existsSync(sys))
96
+ return sys;
97
+ }
98
+ throw new ScreencastError(`Font file not found: ${fontFile}`, "Pass a path to a .ttf, .otf or .ttc file, or the file name of a font in C:\\Windows\\Fonts.");
99
+ }
100
+ function excerpt(text) {
101
+ const one = text.replace(/\s+/g, " ").trim();
102
+ return `"${one.length > 40 ? `${one.slice(0, 39)}…` : one}"`;
103
+ }
104
+ export function resolveTextFont(text, opts = {}) {
105
+ if (opts.fontFile) {
106
+ const fontFile = resolveFontFileArg(opts.fontFile);
107
+ const cov = fontCoverage(fontFile);
108
+ if (!cov) {
109
+ return {
110
+ fontFile,
111
+ missing: [],
112
+ fallback: false,
113
+ warning: `Could not read the character map of ${basename(fontFile)}; glyph coverage of ${excerpt(text)} was not checked.`,
114
+ };
115
+ }
116
+ const missing = missingChars(text, cov);
117
+ if (missing.length === 0)
118
+ return { fontFile, missing, fallback: false };
119
+ return {
120
+ fontFile,
121
+ missing,
122
+ fallback: false,
123
+ warning: `${basename(fontFile)} has no glyph for ${missing.join(" ")} in ${excerpt(text)}; they render as empty boxes.`,
124
+ };
125
+ }
126
+ const weight = opts.weight ?? "bold";
127
+ const bundled = bundledFontPath(weight);
128
+ const inter = fontCoverage(bundled);
129
+ if (inter && missingChars(text, inter).length === 0)
130
+ return { fontFile: bundled, missing: [], fallback: false };
131
+ const dir = opts.fontsDir ?? systemFontsDir();
132
+ const candidates = inter ? [{ path: bundled, coverage: inter }] : [];
133
+ for (const fam of fallbackOrder(text)) {
134
+ for (const file of fam[weight]) {
135
+ const path = join(dir, file);
136
+ const coverage = existsSync(path) ? fontCoverage(path) : null;
137
+ if (!coverage)
138
+ continue;
139
+ if (missingChars(text, coverage).length === 0)
140
+ return { fontFile: path, missing: [], fallback: true };
141
+ candidates.push({ path, coverage });
142
+ break;
143
+ }
144
+ }
145
+ const pick = chooseFont(text, candidates) ?? { fontFile: bundled, missing: [] };
146
+ if (pick.missing.length === 0)
147
+ return { ...pick, fallback: pick.fontFile !== bundled };
148
+ return {
149
+ ...pick,
150
+ fallback: pick.fontFile !== bundled,
151
+ warning: `No available font draws ${pick.missing.join(" ")} in ${excerpt(text)}; they render as empty boxes ` +
152
+ `(drawn with ${basename(pick.fontFile)}). Pass fontFile with a font that covers them.`,
153
+ };
154
+ }