prismcast 1.10.3 → 1.11.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 (674) hide show
  1. package/dist/app.d.ts +1 -0
  2. package/dist/app.d.ts.map +1 -0
  3. package/dist/app.js +103 -50
  4. package/dist/app.js.map +1 -1
  5. package/dist/browser/blockedPage.d.ts +80 -0
  6. package/dist/browser/blockedPage.d.ts.map +1 -0
  7. package/dist/browser/blockedPage.js +209 -0
  8. package/dist/browser/blockedPage.js.map +1 -0
  9. package/dist/browser/browserSupervisor.d.ts +80 -0
  10. package/dist/browser/browserSupervisor.d.ts.map +1 -0
  11. package/dist/browser/browserSupervisor.js +186 -0
  12. package/dist/browser/browserSupervisor.js.map +1 -0
  13. package/dist/browser/cdp.d.ts +1 -0
  14. package/dist/browser/cdp.d.ts.map +1 -0
  15. package/dist/browser/cdp.js +6 -5
  16. package/dist/browser/cdp.js.map +1 -1
  17. package/dist/browser/channelSelection.d.ts +45 -14
  18. package/dist/browser/channelSelection.d.ts.map +1 -0
  19. package/dist/browser/channelSelection.js +81 -18
  20. package/dist/browser/channelSelection.js.map +1 -1
  21. package/dist/browser/consent.d.ts +152 -0
  22. package/dist/browser/consent.d.ts.map +1 -0
  23. package/dist/browser/consent.js +418 -0
  24. package/dist/browser/consent.js.map +1 -0
  25. package/dist/browser/display.d.ts +1 -0
  26. package/dist/browser/display.d.ts.map +1 -0
  27. package/dist/browser/hlsPlaylistObserver.d.ts +23 -6
  28. package/dist/browser/hlsPlaylistObserver.d.ts.map +1 -0
  29. package/dist/browser/hlsPlaylistObserver.js +27 -8
  30. package/dist/browser/hlsPlaylistObserver.js.map +1 -1
  31. package/dist/browser/index.d.ts +44 -27
  32. package/dist/browser/index.d.ts.map +1 -0
  33. package/dist/browser/index.js +427 -244
  34. package/dist/browser/index.js.map +1 -1
  35. package/dist/browser/launchGovernor.d.ts +89 -0
  36. package/dist/browser/launchGovernor.d.ts.map +1 -0
  37. package/dist/browser/launchGovernor.js +96 -0
  38. package/dist/browser/launchGovernor.js.map +1 -0
  39. package/dist/browser/login.d.ts +10 -2
  40. package/dist/browser/login.d.ts.map +1 -0
  41. package/dist/browser/login.js +36 -5
  42. package/dist/browser/login.js.map +1 -1
  43. package/dist/browser/manifestInterceptor.d.ts +88 -35
  44. package/dist/browser/manifestInterceptor.d.ts.map +1 -0
  45. package/dist/browser/manifestInterceptor.js +165 -77
  46. package/dist/browser/manifestInterceptor.js.map +1 -1
  47. package/dist/browser/pageStaleness.d.ts +30 -0
  48. package/dist/browser/pageStaleness.d.ts.map +1 -0
  49. package/dist/browser/pageStaleness.js +76 -0
  50. package/dist/browser/pageStaleness.js.map +1 -0
  51. package/dist/browser/precaching.d.ts +95 -3
  52. package/dist/browser/precaching.d.ts.map +1 -0
  53. package/dist/browser/precaching.js +499 -65
  54. package/dist/browser/precaching.js.map +1 -1
  55. package/dist/browser/tabNetworkObserver.d.ts +2 -1
  56. package/dist/browser/tabNetworkObserver.d.ts.map +1 -0
  57. package/dist/browser/tabNetworkObserver.js +7 -3
  58. package/dist/browser/tabNetworkObserver.js.map +1 -1
  59. package/dist/browser/tuning/cache.d.ts +61 -0
  60. package/dist/browser/tuning/cache.d.ts.map +1 -0
  61. package/dist/browser/tuning/cache.js +62 -0
  62. package/dist/browser/tuning/cache.js.map +1 -0
  63. package/dist/browser/tuning/comcastPolymer.d.ts +3 -2
  64. package/dist/browser/tuning/comcastPolymer.d.ts.map +1 -0
  65. package/dist/browser/tuning/comcastPolymer.js +79 -102
  66. package/dist/browser/tuning/comcastPolymer.js.map +1 -1
  67. package/dist/browser/tuning/cox.d.ts +1 -0
  68. package/dist/browser/tuning/cox.d.ts.map +1 -0
  69. package/dist/browser/tuning/directv.d.ts +1 -0
  70. package/dist/browser/tuning/directv.d.ts.map +1 -0
  71. package/dist/browser/tuning/directv.js +52 -46
  72. package/dist/browser/tuning/directv.js.map +1 -1
  73. package/dist/browser/tuning/fox.d.ts +1 -0
  74. package/dist/browser/tuning/fox.d.ts.map +1 -0
  75. package/dist/browser/tuning/fox.js +13 -12
  76. package/dist/browser/tuning/fox.js.map +1 -1
  77. package/dist/browser/tuning/gridSearch.d.ts +68 -0
  78. package/dist/browser/tuning/gridSearch.d.ts.map +1 -0
  79. package/dist/browser/tuning/gridSearch.js +85 -0
  80. package/dist/browser/tuning/gridSearch.js.map +1 -0
  81. package/dist/browser/tuning/hbo.d.ts +1 -0
  82. package/dist/browser/tuning/hbo.d.ts.map +1 -0
  83. package/dist/browser/tuning/hbo.js +73 -45
  84. package/dist/browser/tuning/hbo.js.map +1 -1
  85. package/dist/browser/tuning/hulu.d.ts +1 -0
  86. package/dist/browser/tuning/hulu.d.ts.map +1 -0
  87. package/dist/browser/tuning/hulu.js +128 -173
  88. package/dist/browser/tuning/hulu.js.map +1 -1
  89. package/dist/browser/tuning/shared.d.ts +75 -5
  90. package/dist/browser/tuning/shared.d.ts.map +1 -0
  91. package/dist/browser/tuning/shared.js +216 -6
  92. package/dist/browser/tuning/shared.js.map +1 -1
  93. package/dist/browser/tuning/sling.d.ts +1 -0
  94. package/dist/browser/tuning/sling.d.ts.map +1 -0
  95. package/dist/browser/tuning/sling.js +105 -126
  96. package/dist/browser/tuning/sling.js.map +1 -1
  97. package/dist/browser/tuning/spectrum.d.ts +1 -0
  98. package/dist/browser/tuning/spectrum.d.ts.map +1 -0
  99. package/dist/browser/tuning/spectrum.js +80 -125
  100. package/dist/browser/tuning/spectrum.js.map +1 -1
  101. package/dist/browser/tuning/thumbnailRow.d.ts +1 -0
  102. package/dist/browser/tuning/thumbnailRow.d.ts.map +1 -0
  103. package/dist/browser/tuning/thumbnailRow.js +8 -2
  104. package/dist/browser/tuning/thumbnailRow.js.map +1 -1
  105. package/dist/browser/tuning/tileClick.d.ts +1 -0
  106. package/dist/browser/tuning/tileClick.d.ts.map +1 -0
  107. package/dist/browser/tuning/tileClick.js +3 -2
  108. package/dist/browser/tuning/tileClick.js.map +1 -1
  109. package/dist/browser/tuning/xfinity.d.ts +1 -0
  110. package/dist/browser/tuning/xfinity.d.ts.map +1 -0
  111. package/dist/browser/tuning/youtubeTv.d.ts +1 -0
  112. package/dist/browser/tuning/youtubeTv.d.ts.map +1 -0
  113. package/dist/browser/tuning/youtubeTv.js +74 -127
  114. package/dist/browser/tuning/youtubeTv.js.map +1 -1
  115. package/dist/browser/video.d.ts +54 -14
  116. package/dist/browser/video.d.ts.map +1 -0
  117. package/dist/browser/video.js +296 -138
  118. package/dist/browser/video.js.map +1 -1
  119. package/dist/channels/index.d.ts +1 -0
  120. package/dist/channels/index.d.ts.map +1 -0
  121. package/dist/channels/index.js +12 -9
  122. package/dist/channels/index.js.map +1 -1
  123. package/dist/config/channelForm.d.ts +15 -1
  124. package/dist/config/channelForm.d.ts.map +1 -0
  125. package/dist/config/channelForm.js +28 -12
  126. package/dist/config/channelForm.js.map +1 -1
  127. package/dist/config/consistencyProbe.d.ts +1 -0
  128. package/dist/config/consistencyProbe.d.ts.map +1 -0
  129. package/dist/config/consistencyProbe.js +15 -11
  130. package/dist/config/consistencyProbe.js.map +1 -1
  131. package/dist/config/health.d.ts +41 -8
  132. package/dist/config/health.d.ts.map +1 -0
  133. package/dist/config/health.js +189 -38
  134. package/dist/config/health.js.map +1 -1
  135. package/dist/config/index.d.ts +55 -3
  136. package/dist/config/index.d.ts.map +1 -0
  137. package/dist/config/index.js +320 -69
  138. package/dist/config/index.js.map +1 -1
  139. package/dist/config/paths.d.ts +7 -1
  140. package/dist/config/paths.d.ts.map +1 -0
  141. package/dist/config/paths.js +8 -1
  142. package/dist/config/paths.js.map +1 -1
  143. package/dist/config/persistence.context.d.ts +1 -0
  144. package/dist/config/persistence.context.d.ts.map +1 -0
  145. package/dist/config/persistence.d.ts +13 -10
  146. package/dist/config/persistence.d.ts.map +1 -0
  147. package/dist/config/persistence.js +40 -21
  148. package/dist/config/persistence.js.map +1 -1
  149. package/dist/config/presets.d.ts +1 -0
  150. package/dist/config/presets.d.ts.map +1 -0
  151. package/dist/config/profiles.d.ts +21 -14
  152. package/dist/config/profiles.d.ts.map +1 -0
  153. package/dist/config/profiles.js +77 -43
  154. package/dist/config/profiles.js.map +1 -1
  155. package/dist/config/providerLineups.d.ts +47 -0
  156. package/dist/config/providerLineups.d.ts.map +1 -0
  157. package/dist/config/providerLineups.js +137 -0
  158. package/dist/config/providerLineups.js.map +1 -0
  159. package/dist/config/reactivity.d.ts +84 -0
  160. package/dist/config/reactivity.d.ts.map +1 -0
  161. package/dist/config/reactivity.js +226 -0
  162. package/dist/config/reactivity.js.map +1 -0
  163. package/dist/config/servicePacks.d.ts +18 -2
  164. package/dist/config/servicePacks.d.ts.map +1 -0
  165. package/dist/config/servicePacks.js +53 -11
  166. package/dist/config/servicePacks.js.map +1 -1
  167. package/dist/config/services.d.ts +16 -10
  168. package/dist/config/services.d.ts.map +1 -0
  169. package/dist/config/services.js +27 -16
  170. package/dist/config/services.js.map +1 -1
  171. package/dist/config/sites.d.ts +4 -2
  172. package/dist/config/sites.d.ts.map +1 -0
  173. package/dist/config/sites.js +9 -5
  174. package/dist/config/sites.js.map +1 -1
  175. package/dist/config/userChannels.d.ts +23 -18
  176. package/dist/config/userChannels.d.ts.map +1 -0
  177. package/dist/config/userChannels.js +45 -34
  178. package/dist/config/userChannels.js.map +1 -1
  179. package/dist/config/userConfig.d.ts +14 -9
  180. package/dist/config/userConfig.d.ts.map +1 -0
  181. package/dist/config/userConfig.js +87 -25
  182. package/dist/config/userConfig.js.map +1 -1
  183. package/dist/config/userProfiles.d.ts +8 -4
  184. package/dist/config/userProfiles.d.ts.map +1 -0
  185. package/dist/config/userProfiles.js +48 -23
  186. package/dist/config/userProfiles.js.map +1 -1
  187. package/dist/hdhr/channelMap.d.ts +1 -0
  188. package/dist/hdhr/channelMap.d.ts.map +1 -0
  189. package/dist/hdhr/deviceId.d.ts +1 -0
  190. package/dist/hdhr/deviceId.d.ts.map +1 -0
  191. package/dist/hdhr/discover.d.ts +1 -0
  192. package/dist/hdhr/discover.d.ts.map +1 -0
  193. package/dist/hdhr/discover.js +48 -47
  194. package/dist/hdhr/discover.js.map +1 -1
  195. package/dist/hdhr/getHandlers.d.ts +29 -0
  196. package/dist/hdhr/getHandlers.d.ts.map +1 -0
  197. package/dist/hdhr/getHandlers.js +196 -0
  198. package/dist/hdhr/getHandlers.js.map +1 -0
  199. package/dist/hdhr/identity.d.ts +36 -0
  200. package/dist/hdhr/identity.d.ts.map +1 -0
  201. package/dist/hdhr/identity.js +51 -0
  202. package/dist/hdhr/identity.js.map +1 -0
  203. package/dist/hdhr/index.d.ts +22 -4
  204. package/dist/hdhr/index.d.ts.map +1 -0
  205. package/dist/hdhr/index.js +229 -54
  206. package/dist/hdhr/index.js.map +1 -1
  207. package/dist/hdhr/protocol.d.ts +75 -0
  208. package/dist/hdhr/protocol.d.ts.map +1 -0
  209. package/dist/hdhr/protocol.js +264 -0
  210. package/dist/hdhr/protocol.js.map +1 -0
  211. package/dist/hdhr/tunerState.d.ts +24 -0
  212. package/dist/hdhr/tunerState.d.ts.map +1 -0
  213. package/dist/hdhr/tunerState.js +67 -0
  214. package/dist/hdhr/tunerState.js.map +1 -0
  215. package/dist/hdhr/udp.d.ts +43 -0
  216. package/dist/hdhr/udp.d.ts.map +1 -0
  217. package/dist/hdhr/udp.js +277 -0
  218. package/dist/hdhr/udp.js.map +1 -0
  219. package/dist/identity.d.ts +1 -0
  220. package/dist/identity.d.ts.map +1 -0
  221. package/dist/identity.js +13 -11
  222. package/dist/identity.js.map +1 -1
  223. package/dist/index.d.ts +1 -0
  224. package/dist/index.d.ts.map +1 -0
  225. package/dist/index.js +4 -3
  226. package/dist/index.js.map +1 -1
  227. package/dist/native/codecInference.d.ts +1 -0
  228. package/dist/native/codecInference.d.ts.map +1 -0
  229. package/dist/native/codecInference.js +50 -5
  230. package/dist/native/codecInference.js.map +1 -1
  231. package/dist/native/decrypt.d.ts +6 -2
  232. package/dist/native/decrypt.d.ts.map +1 -0
  233. package/dist/native/decrypt.js +15 -8
  234. package/dist/native/decrypt.js.map +1 -1
  235. package/dist/native/index.d.ts +39 -16
  236. package/dist/native/index.d.ts.map +1 -0
  237. package/dist/native/index.js +273 -103
  238. package/dist/native/index.js.map +1 -1
  239. package/dist/native/probe.d.ts +114 -18
  240. package/dist/native/probe.d.ts.map +1 -0
  241. package/dist/native/probe.js +452 -115
  242. package/dist/native/probe.js.map +1 -1
  243. package/dist/native/proxy.d.ts +56 -1
  244. package/dist/native/proxy.d.ts.map +1 -0
  245. package/dist/native/proxy.js +604 -161
  246. package/dist/native/proxy.js.map +1 -1
  247. package/dist/native/tokenExpiry.d.ts +1 -0
  248. package/dist/native/tokenExpiry.d.ts.map +1 -0
  249. package/dist/native/tokenExpiry.js +1 -1
  250. package/dist/routes/assets.d.ts +1 -0
  251. package/dist/routes/assets.d.ts.map +1 -0
  252. package/dist/routes/assets.js +4 -2
  253. package/dist/routes/assets.js.map +1 -1
  254. package/dist/routes/auth.d.ts +1 -0
  255. package/dist/routes/auth.d.ts.map +1 -0
  256. package/dist/routes/auth.js +0 -1
  257. package/dist/routes/auth.js.map +1 -1
  258. package/dist/routes/cdp.d.ts +5 -5
  259. package/dist/routes/cdp.d.ts.map +1 -0
  260. package/dist/routes/cdp.js +59 -20
  261. package/dist/routes/cdp.js.map +1 -1
  262. package/dist/routes/channels.d.ts +1 -0
  263. package/dist/routes/channels.d.ts.map +1 -0
  264. package/dist/routes/channels.js +2 -1
  265. package/dist/routes/channels.js.map +1 -1
  266. package/dist/routes/clientActions.d.ts +4 -3
  267. package/dist/routes/clientActions.d.ts.map +1 -0
  268. package/dist/routes/components.d.ts +1 -0
  269. package/dist/routes/components.d.ts.map +1 -0
  270. package/dist/routes/components.js +2 -2
  271. package/dist/routes/components.js.map +1 -1
  272. package/dist/routes/config/channels/endpoints/browse.d.ts +1 -0
  273. package/dist/routes/config/channels/endpoints/browse.d.ts.map +1 -0
  274. package/dist/routes/config/channels/endpoints/browse.js +23 -10
  275. package/dist/routes/config/channels/endpoints/browse.js.map +1 -1
  276. package/dist/routes/config/channels/endpoints/bulk.d.ts +1 -0
  277. package/dist/routes/config/channels/endpoints/bulk.d.ts.map +1 -0
  278. package/dist/routes/config/channels/endpoints/bulk.js +5 -3
  279. package/dist/routes/config/channels/endpoints/bulk.js.map +1 -1
  280. package/dist/routes/config/channels/endpoints/crud.d.ts +1 -0
  281. package/dist/routes/config/channels/endpoints/crud.d.ts.map +1 -0
  282. package/dist/routes/config/channels/endpoints/crud.js +49 -22
  283. package/dist/routes/config/channels/endpoints/crud.js.map +1 -1
  284. package/dist/routes/config/channels/endpoints/importExport.d.ts +1 -0
  285. package/dist/routes/config/channels/endpoints/importExport.d.ts.map +1 -0
  286. package/dist/routes/config/channels/endpoints/importExport.js +6 -3
  287. package/dist/routes/config/channels/endpoints/importExport.js.map +1 -1
  288. package/dist/routes/config/channels/endpoints/predefined.d.ts +1 -0
  289. package/dist/routes/config/channels/endpoints/predefined.d.ts.map +1 -0
  290. package/dist/routes/config/channels/endpoints/prefs.d.ts +1 -0
  291. package/dist/routes/config/channels/endpoints/prefs.d.ts.map +1 -0
  292. package/dist/routes/config/channels/endpoints/prefs.js +2 -1
  293. package/dist/routes/config/channels/endpoints/prefs.js.map +1 -1
  294. package/dist/routes/config/channels/endpoints/service.d.ts +2 -1
  295. package/dist/routes/config/channels/endpoints/service.d.ts.map +1 -0
  296. package/dist/routes/config/channels/endpoints/service.js +3 -1
  297. package/dist/routes/config/channels/endpoints/service.js.map +1 -1
  298. package/dist/routes/config/channels/endpoints/tags.d.ts +1 -0
  299. package/dist/routes/config/channels/endpoints/tags.d.ts.map +1 -0
  300. package/dist/routes/config/channels/endpoints/tags.js +13 -7
  301. package/dist/routes/config/channels/endpoints/tags.js.map +1 -1
  302. package/dist/routes/config/channels/healthBridge.d.ts +1 -0
  303. package/dist/routes/config/channels/healthBridge.d.ts.map +1 -0
  304. package/dist/routes/config/channels/healthBridge.js +2 -2
  305. package/dist/routes/config/channels/http/handler.d.ts +1 -0
  306. package/dist/routes/config/channels/http/handler.d.ts.map +1 -0
  307. package/dist/routes/config/channels/http/playlistHint.d.ts +2 -1
  308. package/dist/routes/config/channels/http/playlistHint.d.ts.map +1 -0
  309. package/dist/routes/config/channels/http/playlistHint.js +16 -2
  310. package/dist/routes/config/channels/http/playlistHint.js.map +1 -1
  311. package/dist/routes/config/channels/http/serviceWarning.d.ts +4 -2
  312. package/dist/routes/config/channels/http/serviceWarning.d.ts.map +1 -0
  313. package/dist/routes/config/channels/http/serviceWarning.js +3 -2
  314. package/dist/routes/config/channels/http/serviceWarning.js.map +1 -1
  315. package/dist/routes/config/channels/index.d.ts +1 -0
  316. package/dist/routes/config/channels/index.d.ts.map +1 -0
  317. package/dist/routes/config/channels/setup.d.ts +1 -0
  318. package/dist/routes/config/channels/setup.d.ts.map +1 -0
  319. package/dist/routes/config/channels/table.d.ts +3 -3
  320. package/dist/routes/config/channels/table.d.ts.map +1 -0
  321. package/dist/routes/config/channels/table.js +55 -27
  322. package/dist/routes/config/channels/table.js.map +1 -1
  323. package/dist/routes/config/http/envelope.d.ts +1 -0
  324. package/dist/routes/config/http/envelope.d.ts.map +1 -0
  325. package/dist/routes/config/index.d.ts +35 -3
  326. package/dist/routes/config/index.d.ts.map +1 -0
  327. package/dist/routes/config/index.js +51 -2
  328. package/dist/routes/config/index.js.map +1 -1
  329. package/dist/routes/config/services.d.ts +5 -4
  330. package/dist/routes/config/services.d.ts.map +1 -0
  331. package/dist/routes/config/services.js +35 -24
  332. package/dist/routes/config/services.js.map +1 -1
  333. package/dist/routes/config/settings.d.ts +1 -0
  334. package/dist/routes/config/settings.d.ts.map +1 -0
  335. package/dist/routes/config/settings.js +89 -43
  336. package/dist/routes/config/settings.js.map +1 -1
  337. package/dist/routes/debug.d.ts +1 -0
  338. package/dist/routes/debug.d.ts.map +1 -0
  339. package/dist/routes/debug.js +2 -2
  340. package/dist/routes/debug.js.map +1 -1
  341. package/dist/routes/health.d.ts +39 -1
  342. package/dist/routes/health.d.ts.map +1 -0
  343. package/dist/routes/health.js +33 -27
  344. package/dist/routes/health.js.map +1 -1
  345. package/dist/routes/hls.d.ts +1 -0
  346. package/dist/routes/hls.d.ts.map +1 -0
  347. package/dist/routes/icons.d.ts +1 -0
  348. package/dist/routes/icons.d.ts.map +1 -0
  349. package/dist/routes/icons.js +1 -1
  350. package/dist/routes/index.d.ts +1 -0
  351. package/dist/routes/index.d.ts.map +1 -0
  352. package/dist/routes/logs.d.ts +1 -0
  353. package/dist/routes/logs.d.ts.map +1 -0
  354. package/dist/routes/logs.js +13 -3
  355. package/dist/routes/logs.js.map +1 -1
  356. package/dist/routes/mpegts.d.ts +1 -0
  357. package/dist/routes/mpegts.d.ts.map +1 -0
  358. package/dist/routes/play.d.ts +1 -0
  359. package/dist/routes/play.d.ts.map +1 -0
  360. package/dist/routes/playlist.d.ts +1 -0
  361. package/dist/routes/playlist.d.ts.map +1 -0
  362. package/dist/routes/playlist.js +7 -2
  363. package/dist/routes/playlist.js.map +1 -1
  364. package/dist/routes/root/content.d.ts +8 -5
  365. package/dist/routes/root/content.d.ts.map +1 -0
  366. package/dist/routes/root/content.js +11 -12
  367. package/dist/routes/root/content.js.map +1 -1
  368. package/dist/routes/root/index.d.ts +2 -1
  369. package/dist/routes/root/index.d.ts.map +1 -0
  370. package/dist/routes/root/index.js +10 -8
  371. package/dist/routes/root/index.js.map +1 -1
  372. package/dist/routes/root/scripts/channels.d.ts +6 -0
  373. package/dist/routes/root/scripts/channels.d.ts.map +1 -0
  374. package/dist/routes/root/scripts/channels.js +147 -97
  375. package/dist/routes/root/scripts/channels.js.map +1 -1
  376. package/dist/routes/root/scripts/clientEscape.d.ts +22 -0
  377. package/dist/routes/root/scripts/clientEscape.d.ts.map +1 -0
  378. package/dist/routes/root/scripts/clientEscape.js +41 -0
  379. package/dist/routes/root/scripts/clientEscape.js.map +1 -0
  380. package/dist/routes/root/scripts/clientUrl.d.ts +23 -0
  381. package/dist/routes/root/scripts/clientUrl.d.ts.map +1 -0
  382. package/dist/routes/root/scripts/clientUrl.js +44 -0
  383. package/dist/routes/root/scripts/clientUrl.js.map +1 -0
  384. package/dist/routes/root/scripts/config.d.ts +6 -0
  385. package/dist/routes/root/scripts/config.d.ts.map +1 -0
  386. package/dist/routes/root/scripts/config.js +39 -22
  387. package/dist/routes/root/scripts/config.js.map +1 -1
  388. package/dist/routes/root/scripts/index.d.ts +1 -0
  389. package/dist/routes/root/scripts/index.d.ts.map +1 -0
  390. package/dist/routes/root/scripts/shared.d.ts +1 -0
  391. package/dist/routes/root/scripts/shared.d.ts.map +1 -0
  392. package/dist/routes/root/scripts/shared.js +52 -26
  393. package/dist/routes/root/scripts/shared.js.map +1 -1
  394. package/dist/routes/root/scripts/status.d.ts +1 -0
  395. package/dist/routes/root/scripts/status.d.ts.map +1 -0
  396. package/dist/routes/root/scripts/status.handlers.d.ts +18 -6
  397. package/dist/routes/root/scripts/status.handlers.d.ts.map +1 -0
  398. package/dist/routes/root/scripts/status.handlers.js +38 -32
  399. package/dist/routes/root/scripts/status.handlers.js.map +1 -1
  400. package/dist/routes/root/scripts/status.js +15 -7
  401. package/dist/routes/root/scripts/status.js.map +1 -1
  402. package/dist/routes/root/styles.d.ts +1 -0
  403. package/dist/routes/root/styles.d.ts.map +1 -0
  404. package/dist/routes/root/styles.js +7 -4
  405. package/dist/routes/root/styles.js.map +1 -1
  406. package/dist/routes/services.d.ts +13 -1
  407. package/dist/routes/services.d.ts.map +1 -0
  408. package/dist/routes/services.js +81 -68
  409. package/dist/routes/services.js.map +1 -1
  410. package/dist/routes/sse.d.ts +1 -0
  411. package/dist/routes/sse.d.ts.map +1 -0
  412. package/dist/routes/sse.js +1 -1
  413. package/dist/routes/sse.js.map +1 -1
  414. package/dist/routes/streams.d.ts +2 -1
  415. package/dist/routes/streams.d.ts.map +1 -0
  416. package/dist/routes/streams.js +1 -1
  417. package/dist/routes/theme.d.ts +3 -2
  418. package/dist/routes/theme.d.ts.map +1 -0
  419. package/dist/routes/theme.js +6 -5
  420. package/dist/routes/theme.js.map +1 -1
  421. package/dist/routes/ui.d.ts +3 -1
  422. package/dist/routes/ui.d.ts.map +1 -0
  423. package/dist/routes/ui.js +16 -4
  424. package/dist/routes/ui.js.map +1 -1
  425. package/dist/routes/upgrade.d.ts +1 -0
  426. package/dist/routes/upgrade.d.ts.map +1 -0
  427. package/dist/routes/upgrade.js +6 -2
  428. package/dist/routes/upgrade.js.map +1 -1
  429. package/dist/service/commands.context.d.ts +1 -0
  430. package/dist/service/commands.context.d.ts.map +1 -0
  431. package/dist/service/commands.context.js +3 -2
  432. package/dist/service/commands.context.js.map +1 -1
  433. package/dist/service/commands.d.ts +1 -0
  434. package/dist/service/commands.d.ts.map +1 -0
  435. package/dist/service/commands.js +10 -13
  436. package/dist/service/commands.js.map +1 -1
  437. package/dist/service/generators.context.d.ts +1 -0
  438. package/dist/service/generators.context.d.ts.map +1 -0
  439. package/dist/service/generators.d.ts +3 -2
  440. package/dist/service/generators.d.ts.map +1 -0
  441. package/dist/service/generators.js +108 -20
  442. package/dist/service/generators.js.map +1 -1
  443. package/dist/service/index.d.ts +1 -0
  444. package/dist/service/index.d.ts.map +1 -0
  445. package/dist/streaming/captureLock.d.ts +44 -0
  446. package/dist/streaming/captureLock.d.ts.map +1 -0
  447. package/dist/streaming/captureLock.js +95 -0
  448. package/dist/streaming/captureLock.js.map +1 -0
  449. package/dist/streaming/captureSession.d.ts +31 -0
  450. package/dist/streaming/captureSession.d.ts.map +1 -0
  451. package/dist/streaming/captureSession.js +54 -0
  452. package/dist/streaming/captureSession.js.map +1 -0
  453. package/dist/streaming/clients.d.ts +1 -0
  454. package/dist/streaming/clients.d.ts.map +1 -0
  455. package/dist/streaming/codec.d.ts +1 -0
  456. package/dist/streaming/codec.d.ts.map +1 -0
  457. package/dist/streaming/fmp4Segmenter.d.ts +29 -2
  458. package/dist/streaming/fmp4Segmenter.d.ts.map +1 -0
  459. package/dist/streaming/fmp4Segmenter.js +79 -26
  460. package/dist/streaming/fmp4Segmenter.js.map +1 -1
  461. package/dist/streaming/hls.d.ts +18 -7
  462. package/dist/streaming/hls.d.ts.map +1 -0
  463. package/dist/streaming/hls.js +219 -115
  464. package/dist/streaming/hls.js.map +1 -1
  465. package/dist/streaming/hlsResume.d.ts +1 -0
  466. package/dist/streaming/hlsResume.d.ts.map +1 -0
  467. package/dist/streaming/hlsResume.js +1 -1
  468. package/dist/streaming/hlsResume.js.map +1 -1
  469. package/dist/streaming/hlsSegments.d.ts +58 -1
  470. package/dist/streaming/hlsSegments.d.ts.map +1 -0
  471. package/dist/streaming/hlsSegments.js +147 -17
  472. package/dist/streaming/hlsSegments.js.map +1 -1
  473. package/dist/streaming/lifecycle.d.ts +4 -1
  474. package/dist/streaming/lifecycle.d.ts.map +1 -0
  475. package/dist/streaming/lifecycle.js +65 -85
  476. package/dist/streaming/lifecycle.js.map +1 -1
  477. package/dist/streaming/monitor.d.ts +6 -4
  478. package/dist/streaming/monitor.d.ts.map +1 -0
  479. package/dist/streaming/monitor.js +343 -145
  480. package/dist/streaming/monitor.js.map +1 -1
  481. package/dist/streaming/mp4Parser.d.ts +5 -4
  482. package/dist/streaming/mp4Parser.d.ts.map +1 -0
  483. package/dist/streaming/mp4Parser.js +36 -13
  484. package/dist/streaming/mp4Parser.js.map +1 -1
  485. package/dist/streaming/mpegts.d.ts +16 -0
  486. package/dist/streaming/mpegts.d.ts.map +1 -0
  487. package/dist/streaming/mpegts.js +61 -17
  488. package/dist/streaming/mpegts.js.map +1 -1
  489. package/dist/streaming/playlistBuilder.d.ts +1 -0
  490. package/dist/streaming/playlistBuilder.d.ts.map +1 -0
  491. package/dist/streaming/preroll.d.ts +31 -4
  492. package/dist/streaming/preroll.d.ts.map +1 -0
  493. package/dist/streaming/preroll.js +69 -27
  494. package/dist/streaming/preroll.js.map +1 -1
  495. package/dist/streaming/pretune.d.ts +26 -1
  496. package/dist/streaming/pretune.d.ts.map +1 -0
  497. package/dist/streaming/pretune.js +22 -24
  498. package/dist/streaming/pretune.js.map +1 -1
  499. package/dist/streaming/pretuneTimers.d.ts +24 -0
  500. package/dist/streaming/pretuneTimers.d.ts.map +1 -0
  501. package/dist/streaming/pretuneTimers.js +56 -0
  502. package/dist/streaming/pretuneTimers.js.map +1 -0
  503. package/dist/streaming/recovery.d.ts +139 -5
  504. package/dist/streaming/recovery.d.ts.map +1 -0
  505. package/dist/streaming/recovery.js +160 -16
  506. package/dist/streaming/recovery.js.map +1 -1
  507. package/dist/streaming/registry.d.ts +27 -9
  508. package/dist/streaming/registry.d.ts.map +1 -0
  509. package/dist/streaming/registry.js +21 -3
  510. package/dist/streaming/registry.js.map +1 -1
  511. package/dist/streaming/setup.d.ts +157 -29
  512. package/dist/streaming/setup.d.ts.map +1 -0
  513. package/dist/streaming/setup.js +1034 -458
  514. package/dist/streaming/setup.js.map +1 -1
  515. package/dist/streaming/showInfo.d.ts +21 -1
  516. package/dist/streaming/showInfo.d.ts.map +1 -0
  517. package/dist/streaming/showInfo.js +31 -16
  518. package/dist/streaming/showInfo.js.map +1 -1
  519. package/dist/streaming/statusEmitter.d.ts +5 -2
  520. package/dist/streaming/statusEmitter.d.ts.map +1 -0
  521. package/dist/streaming/statusEmitter.js +5 -3
  522. package/dist/streaming/statusEmitter.js.map +1 -1
  523. package/dist/types/channels.d.ts +15 -12
  524. package/dist/types/channels.d.ts.map +1 -0
  525. package/dist/types/channels.js +4 -2
  526. package/dist/types/channels.js.map +1 -1
  527. package/dist/types/config.d.ts +16 -5
  528. package/dist/types/config.d.ts.map +1 -0
  529. package/dist/types/index.d.ts +3 -2
  530. package/dist/types/index.d.ts.map +1 -0
  531. package/dist/types/profiles.d.ts +4 -2
  532. package/dist/types/profiles.d.ts.map +1 -0
  533. package/dist/types/selection.d.ts +31 -3
  534. package/dist/types/selection.d.ts.map +1 -0
  535. package/dist/types/selection.js +4 -2
  536. package/dist/types/selection.js.map +1 -1
  537. package/dist/types/shared.d.ts +1 -0
  538. package/dist/types/shared.d.ts.map +1 -0
  539. package/dist/types/streaming.d.ts +8 -0
  540. package/dist/types/streaming.d.ts.map +1 -0
  541. package/dist/upgrade/commands.context.d.ts +1 -0
  542. package/dist/upgrade/commands.context.d.ts.map +1 -0
  543. package/dist/upgrade/commands.d.ts +1 -0
  544. package/dist/upgrade/commands.d.ts.map +1 -0
  545. package/dist/upgrade/commands.js +1 -1
  546. package/dist/upgrade/commands.js.map +1 -1
  547. package/dist/upgrade/detection.context.d.ts +1 -0
  548. package/dist/upgrade/detection.context.d.ts.map +1 -0
  549. package/dist/upgrade/detection.context.js +2 -0
  550. package/dist/upgrade/detection.context.js.map +1 -1
  551. package/dist/upgrade/detection.d.ts +7 -6
  552. package/dist/upgrade/detection.d.ts.map +1 -0
  553. package/dist/upgrade/detection.js +4 -4
  554. package/dist/upgrade/index.d.ts +1 -0
  555. package/dist/upgrade/index.d.ts.map +1 -0
  556. package/dist/upgrade/lifecycle.context.d.ts +1 -0
  557. package/dist/upgrade/lifecycle.context.d.ts.map +1 -0
  558. package/dist/upgrade/lifecycle.d.ts +7 -7
  559. package/dist/upgrade/lifecycle.d.ts.map +1 -0
  560. package/dist/upgrade/lifecycle.js +9 -10
  561. package/dist/upgrade/lifecycle.js.map +1 -1
  562. package/dist/upgrade/pathHandle.d.ts +5 -3
  563. package/dist/upgrade/pathHandle.d.ts.map +1 -0
  564. package/dist/upgrade/pathHandle.js +3 -2
  565. package/dist/upgrade/pathHandle.js.map +1 -1
  566. package/dist/utils/bootSession.context.d.ts +1 -0
  567. package/dist/utils/bootSession.context.d.ts.map +1 -0
  568. package/dist/utils/bootSession.context.js +6 -5
  569. package/dist/utils/bootSession.context.js.map +1 -1
  570. package/dist/utils/bootSession.d.ts +1 -0
  571. package/dist/utils/bootSession.d.ts.map +1 -0
  572. package/dist/utils/bootSession.js.map +1 -1
  573. package/dist/utils/chromeFetch.d.ts +1 -0
  574. package/dist/utils/chromeFetch.d.ts.map +1 -0
  575. package/dist/utils/cliOutput.d.ts +1 -0
  576. package/dist/utils/cliOutput.d.ts.map +1 -0
  577. package/dist/utils/clock.d.ts +5 -4
  578. package/dist/utils/clock.d.ts.map +1 -0
  579. package/dist/utils/clock.js +19 -16
  580. package/dist/utils/clock.js.map +1 -1
  581. package/dist/utils/debugFilter.d.ts +9 -1
  582. package/dist/utils/debugFilter.d.ts.map +1 -0
  583. package/dist/utils/debugFilter.js +60 -33
  584. package/dist/utils/debugFilter.js.map +1 -1
  585. package/dist/utils/delay.d.ts +48 -15
  586. package/dist/utils/delay.d.ts.map +1 -0
  587. package/dist/utils/delay.js +73 -20
  588. package/dist/utils/delay.js.map +1 -1
  589. package/dist/utils/errors.d.ts +32 -0
  590. package/dist/utils/errors.d.ts.map +1 -0
  591. package/dist/utils/errors.js +45 -4
  592. package/dist/utils/errors.js.map +1 -1
  593. package/dist/utils/evaluate.d.ts +1 -0
  594. package/dist/utils/evaluate.d.ts.map +1 -0
  595. package/dist/utils/evaluate.js +29 -23
  596. package/dist/utils/evaluate.js.map +1 -1
  597. package/dist/utils/ffmpeg.context.d.ts +1 -0
  598. package/dist/utils/ffmpeg.context.d.ts.map +1 -0
  599. package/dist/utils/ffmpeg.context.js.map +1 -1
  600. package/dist/utils/ffmpeg.d.ts +29 -7
  601. package/dist/utils/ffmpeg.d.ts.map +1 -0
  602. package/dist/utils/ffmpeg.js +31 -13
  603. package/dist/utils/ffmpeg.js.map +1 -1
  604. package/dist/utils/fileLogger.d.ts +3 -1
  605. package/dist/utils/fileLogger.d.ts.map +1 -0
  606. package/dist/utils/fileLogger.js +64 -29
  607. package/dist/utils/fileLogger.js.map +1 -1
  608. package/dist/utils/format.d.ts +14 -1
  609. package/dist/utils/format.d.ts.map +1 -0
  610. package/dist/utils/format.js +19 -5
  611. package/dist/utils/format.js.map +1 -1
  612. package/dist/utils/index.d.ts +1 -0
  613. package/dist/utils/index.d.ts.map +1 -0
  614. package/dist/utils/logEmitter.d.ts +1 -0
  615. package/dist/utils/logEmitter.d.ts.map +1 -0
  616. package/dist/utils/logger.d.ts +1 -0
  617. package/dist/utils/logger.d.ts.map +1 -0
  618. package/dist/utils/logger.js +10 -6
  619. package/dist/utils/logger.js.map +1 -1
  620. package/dist/utils/m3u.d.ts +3 -2
  621. package/dist/utils/m3u.d.ts.map +1 -0
  622. package/dist/utils/m3u.js +4 -3
  623. package/dist/utils/m3u.js.map +1 -1
  624. package/dist/utils/markup.d.ts +4 -2
  625. package/dist/utils/markup.d.ts.map +1 -0
  626. package/dist/utils/markup.js +6 -5
  627. package/dist/utils/markup.js.map +1 -1
  628. package/dist/utils/memo.d.ts +3 -2
  629. package/dist/utils/memo.d.ts.map +1 -0
  630. package/dist/utils/memo.js +3 -3
  631. package/dist/utils/morganStream.d.ts +1 -0
  632. package/dist/utils/morganStream.d.ts.map +1 -0
  633. package/dist/utils/network.d.ts +1 -0
  634. package/dist/utils/network.d.ts.map +1 -0
  635. package/dist/utils/network.js +2 -2
  636. package/dist/utils/pid.d.ts +1 -0
  637. package/dist/utils/pid.d.ts.map +1 -0
  638. package/dist/utils/pid.js +3 -3
  639. package/dist/utils/platform.d.ts +3 -1
  640. package/dist/utils/platform.d.ts.map +1 -0
  641. package/dist/utils/platform.js +2 -1
  642. package/dist/utils/platform.js.map +1 -1
  643. package/dist/utils/processInspector.context.d.ts +1 -0
  644. package/dist/utils/processInspector.context.d.ts.map +1 -0
  645. package/dist/utils/processInspector.context.js +3 -1
  646. package/dist/utils/processInspector.context.js.map +1 -1
  647. package/dist/utils/processInspector.d.ts +4 -3
  648. package/dist/utils/processInspector.d.ts.map +1 -0
  649. package/dist/utils/processInspector.js +2 -0
  650. package/dist/utils/processInspector.js.map +1 -1
  651. package/dist/utils/retry.d.ts +24 -1
  652. package/dist/utils/retry.d.ts.map +1 -0
  653. package/dist/utils/retry.js +32 -5
  654. package/dist/utils/retry.js.map +1 -1
  655. package/dist/utils/runtimeIdentity.context.d.ts +1 -0
  656. package/dist/utils/runtimeIdentity.context.d.ts.map +1 -0
  657. package/dist/utils/runtimeIdentity.context.js +30 -0
  658. package/dist/utils/runtimeIdentity.context.js.map +1 -1
  659. package/dist/utils/runtimeIdentity.d.ts +6 -4
  660. package/dist/utils/runtimeIdentity.d.ts.map +1 -0
  661. package/dist/utils/runtimeIdentity.js +15 -5
  662. package/dist/utils/runtimeIdentity.js.map +1 -1
  663. package/dist/utils/sanitize.d.ts +1 -0
  664. package/dist/utils/sanitize.d.ts.map +1 -0
  665. package/dist/utils/streamContext.d.ts +2 -1
  666. package/dist/utils/streamContext.d.ts.map +1 -0
  667. package/dist/utils/streamContext.js +1 -1
  668. package/dist/utils/timing.d.ts +1 -0
  669. package/dist/utils/timing.d.ts.map +1 -0
  670. package/dist/utils/version.d.ts +1 -0
  671. package/dist/utils/version.d.ts.map +1 -0
  672. package/dist/utils/version.js +7 -3
  673. package/dist/utils/version.js.map +1 -1
  674. package/package.json +26 -20
@@ -2,8 +2,8 @@
2
2
  *
3
3
  * errors.ts: Error formatting and handling utilities for PrismCast.
4
4
  */
5
- /* These utilities provide consistent error handling and formatting throughout the application. The formatError function extracts meaningful messages from various
6
- * error types, while isSessionClosedError helps identify unrecoverable browser state errors that should abort retry loops.
5
+ /* These helpers group the error-handling primitives shared across the application: one normalizes arbitrary errors into log-ready text, the others classify
6
+ * browser-state failures so callers can abort a retry loop early, tell a dead page apart from a bad subject, or escalate an unrecoverable capture.
7
7
  */
8
8
  /**
9
9
  * Formats an error for logging by extracting the message if available, falling back to string conversion for non-Error objects. Trailing punctuation is stripped
@@ -29,12 +29,53 @@ export function formatError(error) {
29
29
  * Checks whether an error indicates that the browser page or session has been closed or is otherwise unrecoverable. These errors should cause immediate abort of
30
30
  * any retry loops rather than continuing to retry an operation that will never succeed. Common unrecoverable errors include closed targets, closed sessions, and
31
31
  * detached frames (which occur when the page has been closed mid-operation).
32
+ *
33
+ * Matching ignores case. The same dead state reaches callers with different capitalization depending on which Puppeteer or CDP surface raised it, and a
34
+ * differently-capitalized closed target is the same closed target.
32
35
  * @param error - The error to check.
33
36
  * @returns True if the error indicates a closed or unrecoverable state.
34
37
  */
35
38
  export function isSessionClosedError(error) {
36
- const message = formatError(error);
37
- const unrecoverablePatterns = ["Target closed", "Session closed", "detached Frame"];
39
+ const message = formatError(error).toLowerCase();
40
+ const unrecoverablePatterns = ["target closed", "session closed", "detached frame"];
38
41
  return unrecoverablePatterns.some((pattern) => message.includes(pattern));
39
42
  }
43
+ /**
44
+ * Checks whether an error means the DOM world an operation ran in ceased to exist. Two failure families union here: the page, target, or session is gone (what
45
+ * isSessionClosedError already covers), and the execution context or frame was torn down by a navigation or a teardown while the page itself may live on.
46
+ *
47
+ * The question this answers is about the world, not the work. An operation that failed this way reached no verdict on its own subject, so a caller deciding
48
+ * whether to discard cached state about that subject learns nothing from it and must keep the state.
49
+ *
50
+ * The context and frame wordings are matched as exact phrases rather than single words. A lone "destroyed" or "detached" turns up in errors that have nothing to
51
+ * do with page death - a DOM node detached from its document, an object destroyed by an unrelated teardown - and matching those would route ordinary failures
52
+ * into page-death handling. The phrases are the CDP error family; each one does not reach every call surface, since the evaluate wrapper rewrites the
53
+ * cannot-find-context wording into the context-destroyed one, but other Puppeteer surfaces still emit it directly.
54
+ *
55
+ * Composing isSessionClosedError formats the message twice on a call that matches neither family. That trade is deliberate: the session-closed patterns stay
56
+ * stated in exactly one place, and this runs only on an error path.
57
+ * @param error - The error to check.
58
+ * @returns True if the error indicates the page, execution context, or frame the operation ran in is gone.
59
+ */
60
+ export function isPageDeathError(error) {
61
+ if (isSessionClosedError(error)) {
62
+ return true;
63
+ }
64
+ const message = formatError(error).toLowerCase();
65
+ const contextDeathPatterns = ["cannot find context with specified id", "execution context is not available", "execution context was destroyed",
66
+ "frame got detached", "frame was detached"];
67
+ return contextDeathPatterns.some((pattern) => message.includes(pattern));
68
+ }
69
+ /**
70
+ * Checks whether an error is the stale-capture-mutex signal: Chrome's tabCapture extension rejects a second concurrent getStream() with "Cannot capture a tab with
71
+ * an active stream", and that rejection leaks puppeteer-stream's module-level mutex permanently, so the only recovery is a full process restart. This is the single
72
+ * home for that one literal - every site that must decide the process-exit escalation reads it from here. The predicate is deliberately narrow: session-closed-shaped
73
+ * rejections are common and benign, so widening it would exit the process on ordinary browser crashes. The related, broader capture-infrastructure classifier
74
+ * (isCaptureInfrastructureError in recovery.ts) matches this message too, but the process-exit decision this predicate gates stays its own distinct check.
75
+ * @param error - The error or message to check.
76
+ * @returns True if the error carries the stale-capture-mutex signature.
77
+ */
78
+ export function isStaleCaptureMutexError(error) {
79
+ return formatError(error).includes("Cannot capture a tab with an active stream");
80
+ }
40
81
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IAExC,IAAI,OAAe,CAAC;IAEpB,IAAG,KAAK,YAAY,KAAK,EAAE,CAAC;QAE1B,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1B,CAAC;SAAM,IAAG,KAAK,IAAI,CAAC,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC;QAElF,OAAO,GAAI,KAA6B,CAAC,OAAO,CAAC;IACnD,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,uFAAuF;IACvF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAEjD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAEnC,MAAM,qBAAqB,GAAG,CAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,CAAE,CAAC;IAEtF,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAA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CAAE,uCAAuC,EAAE,oCAAoC,EAAE,iCAAiC;QAC7I,oBAAoB,EAAE,oBAAoB,CAAE,CAAC;IAE/C,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAc;IAErD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,4CAA4C,CAAC,CAAC;AACnF,CAAC"}
@@ -49,3 +49,4 @@ export declare class EvaluateAbortError extends Error {
49
49
  * @throws Any error from the underlying evaluate call.
50
50
  */
51
51
  export declare function evaluateWithAbort<T, Args extends unknown[]>(context: Frame | Page, pageFunction: (...args: Args) => T, args?: Args, timeoutMs?: number): Promise<T>;
52
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/utils/evaluate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA8BlD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAG9F;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAG3E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAGnF;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBAEjC,SAAS,EAAE,MAAM;CAM9B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;;CAQ5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,EAC/D,OAAO,EAAE,KAAK,GAAG,IAAI,EACrB,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,EAClC,IAAI,CAAC,EAAE,IAAI,EACX,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CA2CZ"}
@@ -1,6 +1,7 @@
1
+ import { composeSignals, waitWithSignal } from "homebridge-plugin-utils";
1
2
  import { getStreamId } from "./streamContext.js";
2
- import { raceWithTimeout } from "./delay.js";
3
- /* This module provides a wrapper around Puppeteer's page.evaluate() and frame.evaluate() that adds two critical safety mechanisms:
3
+ import { timeoutSignal } from "./delay.js";
4
+ /* This module provides a wrapper around Puppeteer's page.evaluate() and frame.evaluate() that adds two safety mechanisms:
4
5
  *
5
6
  * 1. Abort signal: When a stream is terminated, its AbortController is triggered, immediately rejecting all pending evaluate calls for that stream. This prevents zombie
6
7
  * CDP calls from hanging for 180 seconds (Puppeteer's default protocolTimeout) when the browser becomes unresponsive.
@@ -11,8 +12,12 @@ import { raceWithTimeout } from "./delay.js";
11
12
  * The wrapper automatically retrieves the abort signal from this module's local AbortController map using the stream context from AsyncLocalStorage. If no
12
13
  * stream context is available (e.g., during browser initialization), it falls back to timeout-only behavior.
13
14
  *
14
- * When aborting or timing out, the underlying CDP call is still pending in Puppeteer - we just stop waiting for it locally. We attach a no-op .catch() to the
15
- * evaluate promise to suppress unhandled rejection warnings when the CDP call eventually completes or times out.
15
+ * Both interrupts are one kind of thing - an abort signal - so they compose into a single signal and the wait is one race rather than a race of races. That
16
+ * composition is also what keeps the long-lived per-stream signal clean: the composed signal is built per call and registers its dependency internally, so no
17
+ * user-visible listener ever accumulates on the stream's own signal no matter how many evaluate calls a stream makes.
18
+ *
19
+ * When aborting or timing out, the underlying CDP call is still pending in Puppeteer - we just stop waiting for it locally. Waiting through waitWithSignal
20
+ * observes the evaluate promise on every path, which marks it handled so a CDP call that rejects after we have moved on raises no unhandled rejection.
16
21
  */
17
22
  // Default timeout for evaluate calls in milliseconds.
18
23
  const DEFAULT_EVALUATE_TIMEOUT = 15000;
@@ -85,9 +90,9 @@ export async function evaluateWithAbort(context, pageFunction, args, timeoutMs)
85
90
  const timeout = timeoutMs ?? DEFAULT_EVALUATE_TIMEOUT;
86
91
  // Get stream context to find the abort signal.
87
92
  const streamIdStr = getStreamId();
88
- const signal = streamIdStr !== undefined ? getAbortSignal(streamIdStr) : undefined;
89
- // Check if already aborted before starting.
90
- if (signal?.aborted) {
93
+ const streamSignal = streamIdStr !== undefined ? getAbortSignal(streamIdStr) : undefined;
94
+ // Check if already aborted before starting, so a stream that is already gone never issues a CDP call at all.
95
+ if (streamSignal?.aborted) {
91
96
  throw new EvaluateAbortError();
92
97
  }
93
98
  // Start the evaluate call. We use 'as unknown as' to bypass TypeScript's strict function signature checking since Puppeteer's evaluate accepts various function
@@ -95,23 +100,24 @@ export async function evaluateWithAbort(context, pageFunction, args, timeoutMs)
95
100
  const evaluatePromise = args ?
96
101
  context.evaluate(pageFunction, ...args) :
97
102
  context.evaluate(pageFunction);
98
- // Attach a no-op catch to suppress unhandled rejection warnings. When we abort or timeout, the underlying CDP call is still pending and will eventually resolve or
99
- // reject. Without this, we'd get unhandled rejection warnings when the CDP call completes after we've moved on.
100
- evaluatePromise.catch(() => { });
101
- // Race evaluate against timeout using the shared utility. Timer cleanup is handled by raceWithTimeout's .finally().
102
- const timeoutRace = raceWithTimeout(evaluatePromise, timeout, new EvaluateTimeoutError(timeout));
103
- // If we have an abort signal, add a third racer that rejects when the abort fires.
104
- if (signal) {
105
- const { promise: abortPromise, reject: rejectAbort } = Promise.withResolvers();
106
- // Check if already aborted (race condition protection).
107
- if (signal.aborted) {
108
- rejectAbort(new EvaluateAbortError());
109
- }
110
- else {
111
- signal.addEventListener("abort", () => { rejectAbort(new EvaluateAbortError()); }, { once: true });
103
+ // Hold the timeout's reason in a local so the translation below can compare against it by reference. Composing the stream signal with the timeout signal
104
+ // yields one interrupt source whose reason names which side fired: our own timeoutReason, or - since lifecycle.ts aborts a stream with no argument - the
105
+ // platform's AbortError for a stream termination. Those two can never be confused, and an evaluate rejection is never the signal's reason at all, so it falls
106
+ // through verbatim. When there is no stream signal, composeSignals hands back the timeout signal unwrapped and the bound is the whole story.
107
+ const timeoutReason = new EvaluateTimeoutError(timeout);
108
+ const timeoutHandle = timeoutSignal(timeout, timeoutReason);
109
+ const signal = composeSignals(streamSignal, timeoutHandle.signal);
110
+ try {
111
+ return await waitWithSignal(evaluatePromise, signal);
112
+ }
113
+ catch (error) {
114
+ if ((error === signal.reason) && (error !== timeoutReason)) {
115
+ throw new EvaluateAbortError();
112
116
  }
113
- return Promise.race([timeoutRace, abortPromise]);
117
+ throw error;
118
+ }
119
+ finally {
120
+ timeoutHandle.cancel();
114
121
  }
115
- return timeoutRace;
116
122
  }
117
123
  //# sourceMappingURL=evaluate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/utils/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AAEH,sDAAsD;AACtD,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAEvC,gKAAgK;AAChK,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAmB,EAAE,UAA2B;IAEtF,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAE3D,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED;;;;G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G;IAC7G,IAAG,YAAY,EAAE,OAAO,EAAE,CAAC;QAEzB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,gKAAgK;IAChK,mDAAmD;IACnD,MAAM,eAAe,GAAG,IAAI,CAAC,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC,YAAoD,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACjF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEjC,yJAAyJ;IACzJ,yJAAyJ;IACzJ,8JAA8J;IAC9J,6IAA6I;IAC7I,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAElE,IAAI,CAAC;QAEH,OAAO,MAAM,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAAC,OAAM,KAAK,EAAE,CAAC;QAEd,IAAG,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,aAAa,CAAC,EAAE,CAAC;YAE1D,MAAM,IAAI,kBAAkB,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QAET,aAAa,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -4,3 +4,4 @@ import type { FFmpegContext } from "./ffmpeg.ts";
4
4
  * @returns An FFmpegContext populated from the live process.
5
5
  */
6
6
  export declare function createDefaultFFmpegContext(): FFmpegContext;
7
+ //# sourceMappingURL=ffmpeg.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ffmpeg.context.d.ts","sourceRoot":"","sources":["../../src/utils/ffmpeg.context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBjD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,aAAa,CAU1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ffmpeg.context.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.context.ts"],"names":[],"mappings":"AAOA,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;GAKG;AACH,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IAElD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAW,CAAC;IAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,CAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAE,EAAE,CAAC,CAAC;IAE7F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IAExC,OAAO;QAEL,WAAW,EAAE,iBAAiB;QAC9B,MAAM,EAAE,UAAU;QAClB,OAAO;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,iBAAiB;KACzB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"ffmpeg.context.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.context.ts"],"names":[],"mappings":"AAQA,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;GAKG;AACH,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IAElD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAW,CAAC;IAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,CAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAE,EAAE,CAAC,CAAC;IAE7F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IAExC,OAAO;QAEL,WAAW,EAAE,iBAAiB;QAC9B,MAAM,EAAE,UAAU;QAClB,OAAO;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,iBAAiB;KACzB,CAAC;AACJ,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
2
  import type { ChildProcess } from "node:child_process";
3
3
  /**
4
- * The runtime context resolveFFmpegPath consumes. Models the I/O boundary used by path resolution: filesystem existence checks, the user's home directory, the
5
- * detected platform, the spawn-based probe, and the bundled FFmpeg path from the ffmpeg-for-homebridge npm package. Production wires it through
6
- * createDefaultFFmpegContext (in ffmpeg.context.ts); tests pass a context literal.
4
+ * The runtime context probeFFmpegPath (and getBundledFFmpegPath) consume. Models the I/O boundary used by path resolution: filesystem existence checks, the
5
+ * user's home directory, the detected platform, the spawn-based probe, and the bundled FFmpeg path from the ffmpeg-for-homebridge npm package. Production wires
6
+ * it through createDefaultFFmpegContext (in ffmpeg.context.ts); tests pass a context literal.
7
7
  */
8
8
  export interface FFmpegContext {
9
9
  readonly bundledPath: string | undefined;
@@ -41,8 +41,8 @@ export declare function probeFFmpegPath(ctx?: FFmpegContext): Promise<string | u
41
41
  /**
42
42
  * Resolves the FFmpeg executable path against the production filesystem. Memoized via memoizeAsync: first call probes; subsequent calls return the cached
43
43
  * result. Used by production code paths (server startup, health checks, stream setup). Tests should use probeFFmpegPath against synthetic contexts instead -
44
- * this function intentionally has no parameters and no test seam so its caching contract is sealed. The memoization correctness (single-shot probe,
45
- * concurrent-caller dedup, sticky rejection) is exercised by memo.test.ts against the underlying primitive.
44
+ * this function intentionally takes no parameters, so tests have no way to substitute its dependencies and the caching contract stays sealed. The
45
+ * memoization correctness (single-shot probe, concurrent-caller dedup, sticky rejection) is exercised by memo.test.ts against the underlying primitive.
46
46
  *
47
47
  * Sticky-rejection caveat: memoizeAsync caches a probe rejection for the lifetime of the process - all future callers receive the same rejected promise
48
48
  * without re-probing. probeFFmpegPath today returns undefined for the "not found" case rather than throwing, so this branch never fires in practice. Future
@@ -61,6 +61,27 @@ export interface FFmpegProcess {
61
61
  stdin: Writable;
62
62
  stdout: Readable;
63
63
  }
64
+ /**
65
+ * The outcome of classifying an FFmpeg process exit event. A discriminated union on outcome so callers can branch without inspecting an optional message field.
66
+ */
67
+ export type FfmpegExitOutcome = {
68
+ outcome: "error";
69
+ message: string;
70
+ } | {
71
+ outcome: "normal";
72
+ };
73
+ /**
74
+ * Classifies an FFmpeg process exit from its reported code and signal. Pure: the shuttingDown suppression happens in the caller before this function is ever
75
+ * invoked, so this function only ever classifies exits the caller actually wants judged. SIGTERM is graceful termination via kill() and always classifies as
76
+ * normal regardless of the exit code, because a killed process can still report whatever code it happened to be mid-exit with. A non-zero code is checked before
77
+ * signal presence, so a non-zero code accompanied by a signal still yields the code-based message; a truthy signal that is not SIGTERM (e.g. SIGKILL, SIGSEGV)
78
+ * only produces its own message when the code was null.
79
+ * @param code - The process exit code, or null if the process was terminated by a signal.
80
+ * @param signal - The signal that terminated the process, or null if it exited via a normal code.
81
+ * @param label - Descriptive label for the error message (e.g., "FFmpeg", "MPEG-TS remuxer").
82
+ * @returns The classified outcome: normal, or error with a formatted message.
83
+ */
84
+ export declare function classifyFfmpegExit(code: number | null, signal: NodeJS.Signals | null, label: string): FfmpegExitOutcome;
64
85
  /**
65
86
  * Options for buildSpawnFFmpegArgs. Keeping the platform as an injected option (defaulting to process.platform) lets tests verify both the macOS and non-macOS
66
87
  * branches independently rather than re-asserting whatever branch the host happens to take.
@@ -116,8 +137,9 @@ export declare function spawnFFmpeg(ffmpegBin: string, audioBitrate: number, onE
116
137
  export declare function spawnMpegTsRemuxer(ffmpegBin: string, onError: (error: Error) => void, streamId?: string): FFmpegProcess;
117
138
  /**
118
139
  * Checks if FFmpeg is available on the system. Wraps the production-cached resolveFFmpegPath, so first call probes the filesystem and subsequent calls return
119
- * the memoized result. Tests should use probeFFmpegPath against synthetic contexts instead - this function delegates to the singleton resolver and has no test
120
- * seam.
140
+ * the memoized result. Tests should use probeFFmpegPath against synthetic contexts instead - this function delegates to the singleton resolver and offers no
141
+ * way for tests to substitute its dependencies.
121
142
  * @returns Promise resolving to true if FFmpeg is available, false otherwise.
122
143
  */
123
144
  export declare function isFFmpegAvailable(): Promise<boolean>;
145
+ //# sourceMappingURL=ffmpeg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ffmpeg.d.ts","sourceRoot":"","sources":["../../src/utils/ffmpeg.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,O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oGD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAGjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAG1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CACrC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,MAAM,EAAE,CAkCrG;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAYjD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,CAUxJ;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,CAUvH;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG1D"}
@@ -90,8 +90,8 @@ export async function probeFFmpegPath(ctx = createDefaultFFmpegContext()) {
90
90
  /**
91
91
  * Resolves the FFmpeg executable path against the production filesystem. Memoized via memoizeAsync: first call probes; subsequent calls return the cached
92
92
  * result. Used by production code paths (server startup, health checks, stream setup). Tests should use probeFFmpegPath against synthetic contexts instead -
93
- * this function intentionally has no parameters and no test seam so its caching contract is sealed. The memoization correctness (single-shot probe,
94
- * concurrent-caller dedup, sticky rejection) is exercised by memo.test.ts against the underlying primitive.
93
+ * this function intentionally takes no parameters, so tests have no way to substitute its dependencies and the caching contract stays sealed. The
94
+ * memoization correctness (single-shot probe, concurrent-caller dedup, sticky rejection) is exercised by memo.test.ts against the underlying primitive.
95
95
  *
96
96
  * Sticky-rejection caveat: memoizeAsync caches a probe rejection for the lifetime of the process - all future callers receive the same rejected promise
97
97
  * without re-probing. probeFFmpegPath today returns undefined for the "not found" case rather than throwing, so this branch never fires in practice. Future
@@ -116,6 +116,30 @@ const MPEGTS_OUTPUT_FLAGS = [
116
116
  "-pcr_period", "40",
117
117
  "-flush_packets", "1"
118
118
  ];
119
+ /**
120
+ * Classifies an FFmpeg process exit from its reported code and signal. Pure: the shuttingDown suppression happens in the caller before this function is ever
121
+ * invoked, so this function only ever classifies exits the caller actually wants judged. SIGTERM is graceful termination via kill() and always classifies as
122
+ * normal regardless of the exit code, because a killed process can still report whatever code it happened to be mid-exit with. A non-zero code is checked before
123
+ * signal presence, so a non-zero code accompanied by a signal still yields the code-based message; a truthy signal that is not SIGTERM (e.g. SIGKILL, SIGSEGV)
124
+ * only produces its own message when the code was null.
125
+ * @param code - The process exit code, or null if the process was terminated by a signal.
126
+ * @param signal - The signal that terminated the process, or null if it exited via a normal code.
127
+ * @param label - Descriptive label for the error message (e.g., "FFmpeg", "MPEG-TS remuxer").
128
+ * @returns The classified outcome: normal, or error with a formatted message.
129
+ */
130
+ export function classifyFfmpegExit(code, signal, label) {
131
+ if (signal === "SIGTERM") {
132
+ // Normal termination via kill() - do not treat as error.
133
+ return { outcome: "normal" };
134
+ }
135
+ if ((code !== null) && (code !== 0)) {
136
+ return { message: label + " exited with code " + String(code) + ".", outcome: "error" };
137
+ }
138
+ if (signal) {
139
+ return { message: label + " killed by signal " + signal + ".", outcome: "error" };
140
+ }
141
+ return { outcome: "normal" };
142
+ }
119
143
  // Internal Helper.
120
144
  /**
121
145
  * Spawns an FFmpeg process with shared lifecycle management. Handles stderr logging with noise filtering, exit and error callbacks, and graceful shutdown for all
@@ -150,15 +174,9 @@ function spawnFFmpegProcess({ args, ffmpegBin, label, onError, streamId }) {
150
174
  if (shuttingDown) {
151
175
  return;
152
176
  }
153
- if (signal === "SIGTERM") {
154
- // Normal termination via kill() - do not treat as error.
155
- return;
156
- }
157
- if ((code !== null) && (code !== 0)) {
158
- onError(new Error(label + " exited with code " + String(code) + "."));
159
- }
160
- else if (signal) {
161
- onError(new Error(label + " killed by signal " + signal + "."));
177
+ const result = classifyFfmpegExit(code, signal, label);
178
+ if (result.outcome === "error") {
179
+ onError(new Error(result.message));
162
180
  }
163
181
  });
164
182
  // Handle spawn errors (e.g., FFmpeg not found).
@@ -284,8 +302,8 @@ export function spawnMpegTsRemuxer(ffmpegBin, onError, streamId) {
284
302
  }
285
303
  /**
286
304
  * Checks if FFmpeg is available on the system. Wraps the production-cached resolveFFmpegPath, so first call probes the filesystem and subsequent calls return
287
- * the memoized result. Tests should use probeFFmpegPath against synthetic contexts instead - this function delegates to the singleton resolver and has no test
288
- * seam.
305
+ * the memoized result. Tests should use probeFFmpegPath against synthetic contexts instead - this function delegates to the singleton resolver and offers no
306
+ * way for tests to substitute its dependencies.
289
307
  * @returns Promise resolving to true if FFmpeg is available, false otherwise.
290
308
  */
291
309
  export async function isFFmpegAvailable() {
@@ -1 +1 @@
1
- {"version":3,"file":"ffmpeg.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,iKAAiK;AACjK,2EAA2E;AAC3E,MAAM,qBAAqB,GAAG,CAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAE,CAAC;AAyBxG;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAqB,0BAA0B,EAAE;IA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ACT,KAAK,EAAE,QAAQ;QACf,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,OAA+B,EAAE,QAAiB;IAEtG,OAAO,kBAAkB,CAAC;QAExB,IAAI,EAAE,sBAAsB,EAAE;QAC9B,SAAS;QACT,KAAK,EAAE,iBAAiB;QACxB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IAErC,OAAO,CAAC,MAAM,iBAAiB,EAAE,CAAC,KAAK,SAAS,CAAC;AACnD,CAAC"}
@@ -15,7 +15,8 @@ export declare function initializeFileLogger(logPath: string, maxSize: number):
15
15
  */
16
16
  export declare function writeLogEntry(level: string, message: string, color: LogColor, categoryTag?: string): void;
17
17
  /**
18
- * Flushes the write buffer to disk asynchronously. Called periodically by the flush timer.
18
+ * Flushes the write buffer to disk asynchronously. Called periodically by the flush timer. The append is routed through the write-ordering chain so it cannot
19
+ * interleave with an in-flight trim, which would otherwise discard the appended lines when the trim renames its stale snapshot over the file.
19
20
  */
20
21
  export declare function flushLogBuffer(): Promise<void>;
21
22
  /**
@@ -40,3 +41,4 @@ export declare function computeTrimmedLogContent(content: string, maxSize: numbe
40
41
  * Shuts down the file logger, flushing any remaining buffer synchronously.
41
42
  */
42
43
  export declare function shutdownFileLogger(): void;
44
+ //# sourceMappingURL=fileLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileLogger.d.ts","sourceRoot":"","sources":["../../src/utils/fileLogger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAYlD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC;AAsExD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C1F;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAqCzG;AAwBD;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAgCpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAoBzC;AAwCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CA4B3F;AAiDD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CA6BzC"}
@@ -34,6 +34,13 @@ let writeCount = 0;
34
34
  let flushTimer = null;
35
35
  // Flag indicating whether the file logger is initialized and operational.
36
36
  let isInitialized = false;
37
+ /* Tail of the write-ordering chain. Every asynchronous mutation of the log file (buffer flushes and trims) is appended to this promise so that the operations run
38
+ * strictly one after another. Without this serialization a flush's appendFile could land between a trim's readFile and its rename, and the rename would then
39
+ * overwrite the just-appended lines with stale trimmed content - silently dropping log entries. Routing both paths through a single ordering primitive makes
40
+ * "read-modify-rename" and "append" mutually exclusive without an explicit lock. The tail never rejects: the helper that enqueues work swallows the settled
41
+ * outcome before chaining the next operation, so one failing operation cannot poison the chain for subsequent writes.
42
+ */
43
+ let writeChain = Promise.resolve();
37
44
  // Flag to temporarily disable logging on write errors, preventing error cascades.
38
45
  let isDisabled = false;
39
46
  // Timestamp when logging was disabled due to error, for retry timing.
@@ -122,29 +129,48 @@ export function writeLogEntry(level, message, color, categoryTag) {
122
129
  void checkAndTrimFile();
123
130
  }
124
131
  }
132
+ // Write Ordering.
133
+ /**
134
+ * Serializes an asynchronous log-file mutation against every other such mutation. The supplied operation is appended to the module-scoped write chain so that
135
+ * flushes and trims execute one at a time, never interleaving their read/append/rename steps. The returned promise resolves when this specific operation has
136
+ * settled. The chain itself is advanced with the settled (caught) result so a rejecting operation cannot poison subsequent writes - each operation is responsible
137
+ * for its own error handling, exactly as the inline try/catch blocks did before serialization.
138
+ * @param operation - The async mutation to run after all previously enqueued mutations have completed.
139
+ */
140
+ async function serializeWrite(operation) {
141
+ // Chain this operation after the current tail, then advance the tail to a promise that always resolves so a single failure does not break ordering for the next
142
+ // caller. We capture the run promise to return it, while the tail intentionally swallows the outcome.
143
+ const run = writeChain.then(operation);
144
+ writeChain = run.then(() => undefined, () => undefined);
145
+ return run;
146
+ }
125
147
  // Buffer Flushing.
126
148
  /**
127
- * Flushes the write buffer to disk asynchronously. Called periodically by the flush timer.
149
+ * Flushes the write buffer to disk asynchronously. Called periodically by the flush timer. The append is routed through the write-ordering chain so it cannot
150
+ * interleave with an in-flight trim, which would otherwise discard the appended lines when the trim renames its stale snapshot over the file.
128
151
  */
129
152
  export async function flushLogBuffer() {
130
153
  if (!isInitialized || !logFilePath || (writeBuffer.length === 0)) {
131
154
  return;
132
155
  }
133
- // Take the current buffer and reset.
156
+ // Take the current buffer and reset. We snapshot the path as well so the serialized operation is not affected by a concurrent shutdown clearing logFilePath.
134
157
  const entries = writeBuffer;
158
+ const targetPath = logFilePath;
135
159
  writeBuffer = [];
136
160
  const content = entries.join("");
137
- try {
138
- await fsPromises.appendFile(logFilePath, content, "utf-8");
139
- }
140
- catch (error) {
141
- // Disable logging temporarily to prevent error cascade.
142
- isDisabled = true;
143
- disabledAt = Date.now();
144
- // Log to console as fallback.
145
- // eslint-disable-next-line no-console
146
- console.error("Failed to write to log file: %s. File logging disabled for %s seconds.", (error instanceof Error) ? error.message : String(error), ERROR_RETRY_DELAY_MS / 1000);
147
- }
161
+ return serializeWrite(async () => {
162
+ try {
163
+ await fsPromises.appendFile(targetPath, content, "utf-8");
164
+ }
165
+ catch (error) {
166
+ // Disable logging temporarily to prevent error cascade.
167
+ isDisabled = true;
168
+ disabledAt = Date.now();
169
+ // Log to console as fallback.
170
+ // eslint-disable-next-line no-console
171
+ console.error("Failed to write to log file: %s. File logging disabled for %s seconds.", (error instanceof Error) ? error.message : String(error), ERROR_RETRY_DELAY_MS / 1000);
172
+ }
173
+ });
148
174
  }
149
175
  /**
150
176
  * Flushes the write buffer to disk synchronously. Used during shutdown to ensure final logs are written.
@@ -228,28 +254,35 @@ export function computeTrimmedLogContent(content, maxSize) {
228
254
  /**
229
255
  * Trims the log file to half the maximum size, keeping only complete lines. The most recent logs are preserved. Pure cut logic lives in
230
256
  * computeTrimmedLogContent; this function is the I/O orchestration shell around it.
257
+ *
258
+ * The entire read/write/rename critical section runs inside the write-ordering chain so it is serialized against buffer flushes. This closes the trim/flush race:
259
+ * an appendFile cannot land between this function's readFile and its rename, so the rename never overwrites freshly appended lines with a stale snapshot.
231
260
  */
232
261
  async function trimLogFile() {
233
262
  if (!logFilePath) {
234
263
  return;
235
264
  }
236
- try {
237
- const content = await fsPromises.readFile(logFilePath, "utf-8");
238
- const trimmedContent = computeTrimmedLogContent(content, maxLogSize);
239
- if (trimmedContent === null) {
240
- return;
265
+ // Snapshot the path so a concurrent shutdown clearing logFilePath cannot redirect the rename target mid-operation.
266
+ const targetPath = logFilePath;
267
+ return serializeWrite(async () => {
268
+ try {
269
+ const content = await fsPromises.readFile(targetPath, "utf-8");
270
+ const trimmedContent = computeTrimmedLogContent(content, maxLogSize);
271
+ if (trimmedContent === null) {
272
+ return;
273
+ }
274
+ // Write to temp file, then rename (atomic replace).
275
+ const tempPath = targetPath + ".tmp";
276
+ await fsPromises.writeFile(tempPath, trimmedContent, "utf-8");
277
+ await fsPromises.rename(tempPath, targetPath);
278
+ approximateSize = trimmedContent.length;
241
279
  }
242
- // Write to temp file, then rename (atomic replace).
243
- const tempPath = logFilePath + ".tmp";
244
- await fsPromises.writeFile(tempPath, trimmedContent, "utf-8");
245
- await fsPromises.rename(tempPath, logFilePath);
246
- approximateSize = trimmedContent.length;
247
- }
248
- catch (error) {
249
- // Log to console but continue operating - trim will be retried on next check.
250
- // eslint-disable-next-line no-console
251
- console.warn("Error trimming log file: %s.", (error instanceof Error) ? error.message : String(error));
252
- }
280
+ catch (error) {
281
+ // Log to console but continue operating - trim will be retried on next check.
282
+ // eslint-disable-next-line no-console
283
+ console.warn("Error trimming log file: %s.", (error instanceof Error) ? error.message : String(error));
284
+ }
285
+ });
253
286
  }
254
287
  // Shutdown.
255
288
  /**
@@ -275,5 +308,7 @@ export function shutdownFileLogger() {
275
308
  approximateSize = 0;
276
309
  writeCount = 0;
277
310
  logFilePath = null;
311
+ // Reset the write-ordering chain so the next run starts from a fresh, already-resolved tail rather than chaining onto the previous run's last operation.
312
+ writeChain = Promise.resolve();
278
313
  }
279
314
  //# sourceMappingURL=fileLogger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileLogger.js","sourceRoot":"","sources":["../../src/utils/fileLogger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AAOpC;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AAEH,mDAAmD;AACnD,IAAI,WAAW,GAAqB,IAAI,CAAC;AAEzC,6DAA6D;AAC7D,IAAI,WAAW,GAAa,EAAE,CAAC;AAE/B,2EAA2E;AAC3E,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,0DAA0D;AAC1D,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,sCAAsC;AACtC,IAAI,UAAU,GAA6C,IAAI,CAAC;AAEhE,0EAA0E;AAC1E,IAAI,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CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzG,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,YAAY;AAEZ;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAEhC,IAAG,CAAC,aAAa,EAAE,CAAC;QAElB,OAAO;IACT,CAAC;IAED,wBAAwB;IACxB,IAAG,UAAU,EAAE,CAAC;QAEd,aAAa,CAAC,UAAU,CAAC,CAAC;QAC1B,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,wCAAwC;IACxC,kBAAkB,EAAE,CAAC;IAErB,2JAA2J;IAC3J,uJAAuJ;IACvJ,aAAa,GAAG,KAAK,CAAC;IACtB,UAAU,GAAG,KAAK,CAAC;IACnB,UAAU,GAAG,CAAC,CAAC;IACf,WAAW,GAAG,EAAE,CAAC;IACjB,eAAe,GAAG,CAAC,CAAC;IACpB,UAAU,GAAG,CAAC,CAAC;IACf,WAAW,GAAG,IAAI,CAAC;IAEnB,yJAAyJ;IACzJ,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AACjC,CAAC"}
@@ -1,6 +1,8 @@
1
+ import type { Nullable } from "../types/index.ts";
1
2
  /**
2
3
  * Formats the current date and time as a log timestamp string: `yyyy/mm/dd hh:mm:ss.mmm AM/PM`. Uses 12-hour time with decimalized seconds and AM/PM.
3
- * Single source of truth for all log timestamp formatting - used by the console wrapper in app.ts, the file logger, and the Morgan HTTP request logger.
4
+ * Single source of truth for all log timestamp formatting - used by the console wrapper in app.ts, the file logger, the Morgan HTTP request logger, and the SSE log
5
+ * emitter.
4
6
  * @returns Formatted timestamp string.
5
7
  */
6
8
  export declare function formatTimestamp(): string;
@@ -30,6 +32,16 @@ export declare function formatTimeAgo(timestamp: number): string;
30
32
  * @returns The concise domain, or the original URL if parsing fails.
31
33
  */
32
34
  export declare function extractDomain(url: string): string;
35
+ /**
36
+ * Extracts the pathname portion of a URL - everything from the leading slash up to but excluding the query string and fragment - or null when the URL cannot be
37
+ * parsed. Placed beside extractDomain as the shared home for URL-part extraction, but with the opposite parse-failure contract: extractDomain returns the original
38
+ * string as a display fallback, while extractPathname returns null so a caller can tell could-not-parse apart from a genuinely parsed pathname. Membership
39
+ * comparisons need that distinction - treating an unparseable URL as a non-matching pathname would be actively wrong, so null lets the caller stay
40
+ * member-conservative instead.
41
+ * @param url - The URL to extract the pathname from.
42
+ * @returns The pathname, or null when parsing fails.
43
+ */
44
+ export declare function extractPathname(url: string): Nullable<string>;
33
45
  /**
34
46
  * Capitalizes the first letter of a string.
35
47
  * @param str - The string to capitalize.
@@ -44,3 +56,4 @@ export declare function capitalize(str: string): string;
44
56
  * @returns The JSON string.
45
57
  */
46
58
  export declare function stringifySorted(data: unknown, indent?: number): string;
59
+ //# sourceMappingURL=format.d.ts.map