prismcast 1.10.2 → 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 (693) hide show
  1. package/dist/app.d.ts +6 -3
  2. package/dist/app.d.ts.map +1 -0
  3. package/dist/app.js +140 -86
  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 +55 -0
  28. package/dist/browser/hlsPlaylistObserver.d.ts.map +1 -0
  29. package/dist/browser/hlsPlaylistObserver.js +132 -0
  30. package/dist/browser/hlsPlaylistObserver.js.map +1 -0
  31. package/dist/browser/index.d.ts +67 -40
  32. package/dist/browser/index.d.ts.map +1 -0
  33. package/dist/browser/index.js +508 -300
  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 +102 -49
  44. package/dist/browser/manifestInterceptor.d.ts.map +1 -0
  45. package/dist/browser/manifestInterceptor.js +219 -237
  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 +49 -0
  56. package/dist/browser/tabNetworkObserver.d.ts.map +1 -0
  57. package/dist/browser/tabNetworkObserver.js +144 -0
  58. package/dist/browser/tabNetworkObserver.js.map +1 -0
  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 +27 -21
  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 +10 -9
  140. package/dist/config/paths.d.ts.map +1 -0
  141. package/dist/config/paths.js +11 -11
  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 +22 -15
  152. package/dist/config/profiles.d.ts.map +1 -0
  153. package/dist/config/profiles.js +81 -47
  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 +21 -15
  168. package/dist/config/services.d.ts.map +1 -0
  169. package/dist/config/services.js +35 -24
  170. package/dist/config/services.js.map +1 -1
  171. package/dist/config/sites.d.ts +6 -4
  172. package/dist/config/sites.d.ts.map +1 -0
  173. package/dist/config/sites.js +15 -11
  174. package/dist/config/sites.js.map +1 -1
  175. package/dist/config/userChannels.d.ts +129 -30
  176. package/dist/config/userChannels.d.ts.map +1 -0
  177. package/dist/config/userChannels.js +333 -68
  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 +10 -6
  184. package/dist/config/userProfiles.d.ts.map +1 -0
  185. package/dist/config/userProfiles.js +64 -39
  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 +11 -12
  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 +40 -17
  236. package/dist/native/index.d.ts.map +1 -0
  237. package/dist/native/index.js +281 -120
  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 +57 -5
  244. package/dist/native/proxy.d.ts.map +1 -0
  245. package/dist/native/proxy.js +604 -170
  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 +98 -0
  267. package/dist/routes/clientActions.d.ts.map +1 -0
  268. package/dist/routes/clientActions.js +113 -0
  269. package/dist/routes/clientActions.js.map +1 -0
  270. package/dist/routes/components.d.ts +5 -3
  271. package/dist/routes/components.d.ts.map +1 -0
  272. package/dist/routes/components.js +36 -39
  273. package/dist/routes/components.js.map +1 -1
  274. package/dist/routes/config/channels/endpoints/browse.d.ts +1 -0
  275. package/dist/routes/config/channels/endpoints/browse.d.ts.map +1 -0
  276. package/dist/routes/config/channels/endpoints/browse.js +23 -10
  277. package/dist/routes/config/channels/endpoints/browse.js.map +1 -1
  278. package/dist/routes/config/channels/endpoints/bulk.d.ts +1 -0
  279. package/dist/routes/config/channels/endpoints/bulk.d.ts.map +1 -0
  280. package/dist/routes/config/channels/endpoints/bulk.js +5 -3
  281. package/dist/routes/config/channels/endpoints/bulk.js.map +1 -1
  282. package/dist/routes/config/channels/endpoints/crud.d.ts +1 -0
  283. package/dist/routes/config/channels/endpoints/crud.d.ts.map +1 -0
  284. package/dist/routes/config/channels/endpoints/crud.js +85 -93
  285. package/dist/routes/config/channels/endpoints/crud.js.map +1 -1
  286. package/dist/routes/config/channels/endpoints/importExport.d.ts +1 -0
  287. package/dist/routes/config/channels/endpoints/importExport.d.ts.map +1 -0
  288. package/dist/routes/config/channels/endpoints/importExport.js +6 -3
  289. package/dist/routes/config/channels/endpoints/importExport.js.map +1 -1
  290. package/dist/routes/config/channels/endpoints/predefined.d.ts +1 -0
  291. package/dist/routes/config/channels/endpoints/predefined.d.ts.map +1 -0
  292. package/dist/routes/config/channels/endpoints/prefs.d.ts +1 -0
  293. package/dist/routes/config/channels/endpoints/prefs.d.ts.map +1 -0
  294. package/dist/routes/config/channels/endpoints/prefs.js +2 -1
  295. package/dist/routes/config/channels/endpoints/prefs.js.map +1 -1
  296. package/dist/routes/config/channels/endpoints/service.d.ts +2 -1
  297. package/dist/routes/config/channels/endpoints/service.d.ts.map +1 -0
  298. package/dist/routes/config/channels/endpoints/service.js +3 -1
  299. package/dist/routes/config/channels/endpoints/service.js.map +1 -1
  300. package/dist/routes/config/channels/endpoints/tags.d.ts +1 -0
  301. package/dist/routes/config/channels/endpoints/tags.d.ts.map +1 -0
  302. package/dist/routes/config/channels/endpoints/tags.js +13 -7
  303. package/dist/routes/config/channels/endpoints/tags.js.map +1 -1
  304. package/dist/routes/config/channels/healthBridge.d.ts +24 -0
  305. package/dist/routes/config/channels/healthBridge.d.ts.map +1 -0
  306. package/dist/routes/config/channels/healthBridge.js +71 -0
  307. package/dist/routes/config/channels/healthBridge.js.map +1 -0
  308. package/dist/routes/config/channels/http/handler.d.ts +1 -0
  309. package/dist/routes/config/channels/http/handler.d.ts.map +1 -0
  310. package/dist/routes/config/channels/http/playlistHint.d.ts +2 -1
  311. package/dist/routes/config/channels/http/playlistHint.d.ts.map +1 -0
  312. package/dist/routes/config/channels/http/playlistHint.js +16 -2
  313. package/dist/routes/config/channels/http/playlistHint.js.map +1 -1
  314. package/dist/routes/config/channels/http/serviceWarning.d.ts +4 -2
  315. package/dist/routes/config/channels/http/serviceWarning.d.ts.map +1 -0
  316. package/dist/routes/config/channels/http/serviceWarning.js +3 -2
  317. package/dist/routes/config/channels/http/serviceWarning.js.map +1 -1
  318. package/dist/routes/config/channels/index.d.ts +1 -0
  319. package/dist/routes/config/channels/index.d.ts.map +1 -0
  320. package/dist/routes/config/channels/setup.d.ts +1 -0
  321. package/dist/routes/config/channels/setup.d.ts.map +1 -0
  322. package/dist/routes/config/channels/table.d.ts +3 -3
  323. package/dist/routes/config/channels/table.d.ts.map +1 -0
  324. package/dist/routes/config/channels/table.js +148 -107
  325. package/dist/routes/config/channels/table.js.map +1 -1
  326. package/dist/routes/config/http/envelope.d.ts +1 -0
  327. package/dist/routes/config/http/envelope.d.ts.map +1 -0
  328. package/dist/routes/config/index.d.ts +35 -3
  329. package/dist/routes/config/index.d.ts.map +1 -0
  330. package/dist/routes/config/index.js +51 -2
  331. package/dist/routes/config/index.js.map +1 -1
  332. package/dist/routes/config/services.d.ts +5 -4
  333. package/dist/routes/config/services.d.ts.map +1 -0
  334. package/dist/routes/config/services.js +57 -43
  335. package/dist/routes/config/services.js.map +1 -1
  336. package/dist/routes/config/settings.d.ts +1 -0
  337. package/dist/routes/config/settings.d.ts.map +1 -0
  338. package/dist/routes/config/settings.js +98 -49
  339. package/dist/routes/config/settings.js.map +1 -1
  340. package/dist/routes/debug.d.ts +1 -0
  341. package/dist/routes/debug.d.ts.map +1 -0
  342. package/dist/routes/debug.js +277 -139
  343. package/dist/routes/debug.js.map +1 -1
  344. package/dist/routes/health.d.ts +39 -1
  345. package/dist/routes/health.d.ts.map +1 -0
  346. package/dist/routes/health.js +33 -27
  347. package/dist/routes/health.js.map +1 -1
  348. package/dist/routes/hls.d.ts +1 -0
  349. package/dist/routes/hls.d.ts.map +1 -0
  350. package/dist/routes/icons.d.ts +1 -0
  351. package/dist/routes/icons.d.ts.map +1 -0
  352. package/dist/routes/icons.js +1 -1
  353. package/dist/routes/index.d.ts +1 -0
  354. package/dist/routes/index.d.ts.map +1 -0
  355. package/dist/routes/logs.d.ts +1 -0
  356. package/dist/routes/logs.d.ts.map +1 -0
  357. package/dist/routes/logs.js +14 -4
  358. package/dist/routes/logs.js.map +1 -1
  359. package/dist/routes/mpegts.d.ts +1 -0
  360. package/dist/routes/mpegts.d.ts.map +1 -0
  361. package/dist/routes/play.d.ts +1 -0
  362. package/dist/routes/play.d.ts.map +1 -0
  363. package/dist/routes/playlist.d.ts +1 -0
  364. package/dist/routes/playlist.d.ts.map +1 -0
  365. package/dist/routes/playlist.js +7 -2
  366. package/dist/routes/playlist.js.map +1 -1
  367. package/dist/routes/root/content.d.ts +8 -5
  368. package/dist/routes/root/content.d.ts.map +1 -0
  369. package/dist/routes/root/content.js +29 -26
  370. package/dist/routes/root/content.js.map +1 -1
  371. package/dist/routes/root/index.d.ts +2 -1
  372. package/dist/routes/root/index.d.ts.map +1 -0
  373. package/dist/routes/root/index.js +26 -21
  374. package/dist/routes/root/index.js.map +1 -1
  375. package/dist/routes/root/scripts/channels.d.ts +6 -0
  376. package/dist/routes/root/scripts/channels.d.ts.map +1 -0
  377. package/dist/routes/root/scripts/channels.js +197 -118
  378. package/dist/routes/root/scripts/channels.js.map +1 -1
  379. package/dist/routes/root/scripts/clientEscape.d.ts +22 -0
  380. package/dist/routes/root/scripts/clientEscape.d.ts.map +1 -0
  381. package/dist/routes/root/scripts/clientEscape.js +41 -0
  382. package/dist/routes/root/scripts/clientEscape.js.map +1 -0
  383. package/dist/routes/root/scripts/clientUrl.d.ts +23 -0
  384. package/dist/routes/root/scripts/clientUrl.d.ts.map +1 -0
  385. package/dist/routes/root/scripts/clientUrl.js +44 -0
  386. package/dist/routes/root/scripts/clientUrl.js.map +1 -0
  387. package/dist/routes/root/scripts/config.d.ts +6 -0
  388. package/dist/routes/root/scripts/config.d.ts.map +1 -0
  389. package/dist/routes/root/scripts/config.js +110 -24
  390. package/dist/routes/root/scripts/config.js.map +1 -1
  391. package/dist/routes/root/scripts/index.d.ts +1 -0
  392. package/dist/routes/root/scripts/index.d.ts.map +1 -0
  393. package/dist/routes/root/scripts/shared.d.ts +1 -0
  394. package/dist/routes/root/scripts/shared.d.ts.map +1 -0
  395. package/dist/routes/root/scripts/shared.js +112 -26
  396. package/dist/routes/root/scripts/shared.js.map +1 -1
  397. package/dist/routes/root/scripts/status.d.ts +1 -0
  398. package/dist/routes/root/scripts/status.d.ts.map +1 -0
  399. package/dist/routes/root/scripts/status.handlers.d.ts +23 -33
  400. package/dist/routes/root/scripts/status.handlers.d.ts.map +1 -0
  401. package/dist/routes/root/scripts/status.handlers.js +46 -92
  402. package/dist/routes/root/scripts/status.handlers.js.map +1 -1
  403. package/dist/routes/root/scripts/status.js +21 -8
  404. package/dist/routes/root/scripts/status.js.map +1 -1
  405. package/dist/routes/root/styles.d.ts +1 -0
  406. package/dist/routes/root/styles.d.ts.map +1 -0
  407. package/dist/routes/root/styles.js +7 -4
  408. package/dist/routes/root/styles.js.map +1 -1
  409. package/dist/routes/services.d.ts +13 -1
  410. package/dist/routes/services.d.ts.map +1 -0
  411. package/dist/routes/services.js +81 -68
  412. package/dist/routes/services.js.map +1 -1
  413. package/dist/routes/sse.d.ts +1 -0
  414. package/dist/routes/sse.d.ts.map +1 -0
  415. package/dist/routes/sse.js +1 -1
  416. package/dist/routes/sse.js.map +1 -1
  417. package/dist/routes/streams.d.ts +2 -1
  418. package/dist/routes/streams.d.ts.map +1 -0
  419. package/dist/routes/streams.js +6 -4
  420. package/dist/routes/streams.js.map +1 -1
  421. package/dist/routes/theme.d.ts +3 -2
  422. package/dist/routes/theme.d.ts.map +1 -0
  423. package/dist/routes/theme.js +6 -5
  424. package/dist/routes/theme.js.map +1 -1
  425. package/dist/routes/ui.d.ts +3 -1
  426. package/dist/routes/ui.d.ts.map +1 -0
  427. package/dist/routes/ui.js +16 -4
  428. package/dist/routes/ui.js.map +1 -1
  429. package/dist/routes/upgrade.d.ts +1 -0
  430. package/dist/routes/upgrade.d.ts.map +1 -0
  431. package/dist/routes/upgrade.js +6 -2
  432. package/dist/routes/upgrade.js.map +1 -1
  433. package/dist/service/commands.context.d.ts +1 -0
  434. package/dist/service/commands.context.d.ts.map +1 -0
  435. package/dist/service/commands.context.js +4 -3
  436. package/dist/service/commands.context.js.map +1 -1
  437. package/dist/service/commands.d.ts +1 -0
  438. package/dist/service/commands.d.ts.map +1 -0
  439. package/dist/service/commands.js +10 -13
  440. package/dist/service/commands.js.map +1 -1
  441. package/dist/service/generators.context.d.ts +1 -0
  442. package/dist/service/generators.context.d.ts.map +1 -0
  443. package/dist/service/generators.context.js +1 -1
  444. package/dist/service/generators.context.js.map +1 -1
  445. package/dist/service/generators.d.ts +4 -3
  446. package/dist/service/generators.d.ts.map +1 -0
  447. package/dist/service/generators.js +111 -31
  448. package/dist/service/generators.js.map +1 -1
  449. package/dist/service/index.d.ts +1 -0
  450. package/dist/service/index.d.ts.map +1 -0
  451. package/dist/streaming/captureLock.d.ts +44 -0
  452. package/dist/streaming/captureLock.d.ts.map +1 -0
  453. package/dist/streaming/captureLock.js +95 -0
  454. package/dist/streaming/captureLock.js.map +1 -0
  455. package/dist/streaming/captureSession.d.ts +31 -0
  456. package/dist/streaming/captureSession.d.ts.map +1 -0
  457. package/dist/streaming/captureSession.js +54 -0
  458. package/dist/streaming/captureSession.js.map +1 -0
  459. package/dist/streaming/clients.d.ts +1 -0
  460. package/dist/streaming/clients.d.ts.map +1 -0
  461. package/dist/streaming/codec.d.ts +1 -0
  462. package/dist/streaming/codec.d.ts.map +1 -0
  463. package/dist/streaming/fmp4Segmenter.d.ts +29 -2
  464. package/dist/streaming/fmp4Segmenter.d.ts.map +1 -0
  465. package/dist/streaming/fmp4Segmenter.js +79 -26
  466. package/dist/streaming/fmp4Segmenter.js.map +1 -1
  467. package/dist/streaming/hls.d.ts +18 -7
  468. package/dist/streaming/hls.d.ts.map +1 -0
  469. package/dist/streaming/hls.js +220 -120
  470. package/dist/streaming/hls.js.map +1 -1
  471. package/dist/streaming/hlsResume.d.ts +1 -0
  472. package/dist/streaming/hlsResume.d.ts.map +1 -0
  473. package/dist/streaming/hlsResume.js +1 -1
  474. package/dist/streaming/hlsResume.js.map +1 -1
  475. package/dist/streaming/hlsSegments.d.ts +59 -2
  476. package/dist/streaming/hlsSegments.d.ts.map +1 -0
  477. package/dist/streaming/hlsSegments.js +147 -17
  478. package/dist/streaming/hlsSegments.js.map +1 -1
  479. package/dist/streaming/lifecycle.d.ts +4 -1
  480. package/dist/streaming/lifecycle.d.ts.map +1 -0
  481. package/dist/streaming/lifecycle.js +65 -85
  482. package/dist/streaming/lifecycle.js.map +1 -1
  483. package/dist/streaming/monitor.d.ts +6 -4
  484. package/dist/streaming/monitor.d.ts.map +1 -0
  485. package/dist/streaming/monitor.js +343 -145
  486. package/dist/streaming/monitor.js.map +1 -1
  487. package/dist/streaming/mp4Parser.d.ts +5 -4
  488. package/dist/streaming/mp4Parser.d.ts.map +1 -0
  489. package/dist/streaming/mp4Parser.js +36 -13
  490. package/dist/streaming/mp4Parser.js.map +1 -1
  491. package/dist/streaming/mpegts.d.ts +16 -0
  492. package/dist/streaming/mpegts.d.ts.map +1 -0
  493. package/dist/streaming/mpegts.js +61 -17
  494. package/dist/streaming/mpegts.js.map +1 -1
  495. package/dist/streaming/playlistBuilder.d.ts +1 -0
  496. package/dist/streaming/playlistBuilder.d.ts.map +1 -0
  497. package/dist/streaming/preroll.d.ts +32 -5
  498. package/dist/streaming/preroll.d.ts.map +1 -0
  499. package/dist/streaming/preroll.js +70 -32
  500. package/dist/streaming/preroll.js.map +1 -1
  501. package/dist/streaming/pretune.d.ts +26 -1
  502. package/dist/streaming/pretune.d.ts.map +1 -0
  503. package/dist/streaming/pretune.js +22 -24
  504. package/dist/streaming/pretune.js.map +1 -1
  505. package/dist/streaming/pretuneTimers.d.ts +24 -0
  506. package/dist/streaming/pretuneTimers.d.ts.map +1 -0
  507. package/dist/streaming/pretuneTimers.js +56 -0
  508. package/dist/streaming/pretuneTimers.js.map +1 -0
  509. package/dist/streaming/recovery.d.ts +139 -5
  510. package/dist/streaming/recovery.d.ts.map +1 -0
  511. package/dist/streaming/recovery.js +160 -16
  512. package/dist/streaming/recovery.js.map +1 -1
  513. package/dist/streaming/registry.d.ts +27 -9
  514. package/dist/streaming/registry.d.ts.map +1 -0
  515. package/dist/streaming/registry.js +21 -3
  516. package/dist/streaming/registry.js.map +1 -1
  517. package/dist/streaming/setup.d.ts +157 -29
  518. package/dist/streaming/setup.d.ts.map +1 -0
  519. package/dist/streaming/setup.js +1034 -458
  520. package/dist/streaming/setup.js.map +1 -1
  521. package/dist/streaming/showInfo.d.ts +21 -1
  522. package/dist/streaming/showInfo.d.ts.map +1 -0
  523. package/dist/streaming/showInfo.js +31 -16
  524. package/dist/streaming/showInfo.js.map +1 -1
  525. package/dist/streaming/statusEmitter.d.ts +10 -10
  526. package/dist/streaming/statusEmitter.d.ts.map +1 -0
  527. package/dist/streaming/statusEmitter.js +5 -8
  528. package/dist/streaming/statusEmitter.js.map +1 -1
  529. package/dist/types/channels.d.ts +16 -4
  530. package/dist/types/channels.d.ts.map +1 -0
  531. package/dist/types/channels.js +4 -2
  532. package/dist/types/channels.js.map +1 -1
  533. package/dist/types/config.d.ts +16 -5
  534. package/dist/types/config.d.ts.map +1 -0
  535. package/dist/types/index.d.ts +3 -2
  536. package/dist/types/index.d.ts.map +1 -0
  537. package/dist/types/profiles.d.ts +6 -4
  538. package/dist/types/profiles.d.ts.map +1 -0
  539. package/dist/types/selection.d.ts +31 -3
  540. package/dist/types/selection.d.ts.map +1 -0
  541. package/dist/types/selection.js +4 -2
  542. package/dist/types/selection.js.map +1 -1
  543. package/dist/types/shared.d.ts +1 -0
  544. package/dist/types/shared.d.ts.map +1 -0
  545. package/dist/types/streaming.d.ts +8 -0
  546. package/dist/types/streaming.d.ts.map +1 -0
  547. package/dist/upgrade/commands.context.d.ts +1 -0
  548. package/dist/upgrade/commands.context.d.ts.map +1 -0
  549. package/dist/upgrade/commands.context.js +14 -10
  550. package/dist/upgrade/commands.context.js.map +1 -1
  551. package/dist/upgrade/commands.d.ts +8 -15
  552. package/dist/upgrade/commands.d.ts.map +1 -0
  553. package/dist/upgrade/commands.js +27 -28
  554. package/dist/upgrade/commands.js.map +1 -1
  555. package/dist/upgrade/detection.context.d.ts +1 -0
  556. package/dist/upgrade/detection.context.d.ts.map +1 -0
  557. package/dist/upgrade/detection.context.js +4 -1
  558. package/dist/upgrade/detection.context.js.map +1 -1
  559. package/dist/upgrade/detection.d.ts +9 -7
  560. package/dist/upgrade/detection.d.ts.map +1 -0
  561. package/dist/upgrade/detection.js +23 -54
  562. package/dist/upgrade/detection.js.map +1 -1
  563. package/dist/upgrade/index.d.ts +2 -0
  564. package/dist/upgrade/index.d.ts.map +1 -0
  565. package/dist/upgrade/index.js +1 -0
  566. package/dist/upgrade/index.js.map +1 -1
  567. package/dist/upgrade/lifecycle.context.d.ts +20 -0
  568. package/dist/upgrade/lifecycle.context.d.ts.map +1 -0
  569. package/dist/upgrade/lifecycle.context.js +47 -0
  570. package/dist/upgrade/lifecycle.context.js.map +1 -0
  571. package/dist/upgrade/lifecycle.d.ts +72 -0
  572. package/dist/upgrade/lifecycle.d.ts.map +1 -0
  573. package/dist/upgrade/lifecycle.js +175 -0
  574. package/dist/upgrade/lifecycle.js.map +1 -0
  575. package/dist/upgrade/pathHandle.d.ts +30 -0
  576. package/dist/upgrade/pathHandle.d.ts.map +1 -0
  577. package/dist/upgrade/pathHandle.js +102 -0
  578. package/dist/upgrade/pathHandle.js.map +1 -0
  579. package/dist/utils/bootSession.context.d.ts +16 -0
  580. package/dist/utils/bootSession.context.d.ts.map +1 -0
  581. package/dist/utils/bootSession.context.js +60 -0
  582. package/dist/utils/bootSession.context.js.map +1 -0
  583. package/dist/utils/bootSession.d.ts +17 -0
  584. package/dist/utils/bootSession.d.ts.map +1 -0
  585. package/dist/utils/bootSession.js +20 -0
  586. package/dist/utils/bootSession.js.map +1 -0
  587. package/dist/utils/chromeFetch.d.ts +1 -0
  588. package/dist/utils/chromeFetch.d.ts.map +1 -0
  589. package/dist/utils/cliOutput.d.ts +1 -0
  590. package/dist/utils/cliOutput.d.ts.map +1 -0
  591. package/dist/utils/clock.d.ts +5 -4
  592. package/dist/utils/clock.d.ts.map +1 -0
  593. package/dist/utils/clock.js +19 -16
  594. package/dist/utils/clock.js.map +1 -1
  595. package/dist/utils/debugFilter.d.ts +9 -1
  596. package/dist/utils/debugFilter.d.ts.map +1 -0
  597. package/dist/utils/debugFilter.js +60 -33
  598. package/dist/utils/debugFilter.js.map +1 -1
  599. package/dist/utils/delay.d.ts +48 -15
  600. package/dist/utils/delay.d.ts.map +1 -0
  601. package/dist/utils/delay.js +73 -20
  602. package/dist/utils/delay.js.map +1 -1
  603. package/dist/utils/errors.d.ts +32 -0
  604. package/dist/utils/errors.d.ts.map +1 -0
  605. package/dist/utils/errors.js +45 -4
  606. package/dist/utils/errors.js.map +1 -1
  607. package/dist/utils/evaluate.d.ts +1 -0
  608. package/dist/utils/evaluate.d.ts.map +1 -0
  609. package/dist/utils/evaluate.js +29 -23
  610. package/dist/utils/evaluate.js.map +1 -1
  611. package/dist/utils/ffmpeg.context.d.ts +1 -0
  612. package/dist/utils/ffmpeg.context.d.ts.map +1 -0
  613. package/dist/utils/ffmpeg.context.js.map +1 -1
  614. package/dist/utils/ffmpeg.d.ts +29 -7
  615. package/dist/utils/ffmpeg.d.ts.map +1 -0
  616. package/dist/utils/ffmpeg.js +32 -14
  617. package/dist/utils/ffmpeg.js.map +1 -1
  618. package/dist/utils/fileLogger.d.ts +3 -1
  619. package/dist/utils/fileLogger.d.ts.map +1 -0
  620. package/dist/utils/fileLogger.js +64 -29
  621. package/dist/utils/fileLogger.js.map +1 -1
  622. package/dist/utils/format.d.ts +14 -1
  623. package/dist/utils/format.d.ts.map +1 -0
  624. package/dist/utils/format.js +19 -5
  625. package/dist/utils/format.js.map +1 -1
  626. package/dist/utils/index.d.ts +4 -0
  627. package/dist/utils/index.d.ts.map +1 -0
  628. package/dist/utils/index.js +3 -0
  629. package/dist/utils/index.js.map +1 -1
  630. package/dist/utils/logEmitter.d.ts +1 -0
  631. package/dist/utils/logEmitter.d.ts.map +1 -0
  632. package/dist/utils/logger.d.ts +1 -0
  633. package/dist/utils/logger.d.ts.map +1 -0
  634. package/dist/utils/logger.js +10 -6
  635. package/dist/utils/logger.js.map +1 -1
  636. package/dist/utils/m3u.d.ts +3 -2
  637. package/dist/utils/m3u.d.ts.map +1 -0
  638. package/dist/utils/m3u.js +4 -3
  639. package/dist/utils/m3u.js.map +1 -1
  640. package/dist/utils/markup.d.ts +13 -1
  641. package/dist/utils/markup.d.ts.map +1 -0
  642. package/dist/utils/markup.js +28 -4
  643. package/dist/utils/markup.js.map +1 -1
  644. package/dist/utils/memo.d.ts +3 -2
  645. package/dist/utils/memo.d.ts.map +1 -0
  646. package/dist/utils/memo.js +3 -3
  647. package/dist/utils/morganStream.d.ts +1 -0
  648. package/dist/utils/morganStream.d.ts.map +1 -0
  649. package/dist/utils/network.d.ts +1 -0
  650. package/dist/utils/network.d.ts.map +1 -0
  651. package/dist/utils/network.js +2 -2
  652. package/dist/utils/pid.d.ts +3 -25
  653. package/dist/utils/pid.d.ts.map +1 -0
  654. package/dist/utils/pid.js +10 -49
  655. package/dist/utils/pid.js.map +1 -1
  656. package/dist/utils/platform.d.ts +3 -1
  657. package/dist/utils/platform.d.ts.map +1 -0
  658. package/dist/utils/platform.js +2 -1
  659. package/dist/utils/platform.js.map +1 -1
  660. package/dist/utils/processInspector.context.d.ts +8 -0
  661. package/dist/utils/processInspector.context.d.ts.map +1 -0
  662. package/dist/utils/processInspector.context.js +106 -0
  663. package/dist/utils/processInspector.context.js.map +1 -0
  664. package/dist/utils/processInspector.d.ts +55 -0
  665. package/dist/utils/processInspector.d.ts.map +1 -0
  666. package/dist/utils/processInspector.js +127 -0
  667. package/dist/utils/processInspector.js.map +1 -0
  668. package/dist/utils/retry.d.ts +25 -2
  669. package/dist/utils/retry.d.ts.map +1 -0
  670. package/dist/utils/retry.js +33 -6
  671. package/dist/utils/retry.js.map +1 -1
  672. package/dist/utils/runtimeIdentity.context.d.ts +7 -0
  673. package/dist/utils/runtimeIdentity.context.d.ts.map +1 -0
  674. package/dist/utils/runtimeIdentity.context.js +43 -0
  675. package/dist/utils/runtimeIdentity.context.js.map +1 -0
  676. package/dist/utils/runtimeIdentity.d.ts +98 -0
  677. package/dist/utils/runtimeIdentity.d.ts.map +1 -0
  678. package/dist/utils/runtimeIdentity.js +181 -0
  679. package/dist/utils/runtimeIdentity.js.map +1 -0
  680. package/dist/utils/sanitize.d.ts +1 -0
  681. package/dist/utils/sanitize.d.ts.map +1 -0
  682. package/dist/utils/streamContext.d.ts +2 -1
  683. package/dist/utils/streamContext.d.ts.map +1 -0
  684. package/dist/utils/streamContext.js +1 -1
  685. package/dist/utils/timing.d.ts +2 -1
  686. package/dist/utils/timing.d.ts.map +1 -0
  687. package/dist/utils/timing.js +0 -5
  688. package/dist/utils/timing.js.map +1 -1
  689. package/dist/utils/version.d.ts +1 -0
  690. package/dist/utils/version.d.ts.map +1 -0
  691. package/dist/utils/version.js +47 -13
  692. package/dist/utils/version.js.map +1 -1
  693. package/package.json +26 -20
@@ -1,33 +1,66 @@
1
+ import type { Nullable } from "../types/index.ts";
1
2
  /**
2
- * A cancellable timeout that can be used with Promise.race. The promise resolves to false when the timeout fires, and cancel() clears the timer to prevent it
3
- * from holding an event loop reference after the race is won by another promise.
3
+ * A timeout expressed as an abort signal, paired with the disposal its consumer owes. The signal aborts with the caller's own error object as its reason, which
4
+ * is what the platform's AbortSignal.timeout() cannot express - it always aborts with a generic TimeoutError, forcing every consumer that needs to tell its own
5
+ * lapse apart from anyone else's to translate at the catch site. Carrying the reason instead means a caller can compare the rejection by reference or by type
6
+ * and get an exact answer.
4
7
  */
5
- export interface CancellableTimeout {
8
+ export interface TimeoutSignal {
6
9
  cancel: () => void;
7
- promise: Promise<false>;
10
+ signal: AbortSignal;
8
11
  }
9
12
  /**
10
- * Creates a cancellable timeout for use with Promise.race. Returns a promise that resolves to false after the specified delay, and a cancel function that clears
11
- * the timer so it does not hold an event loop reference after the race is won by another promise.
13
+ * Creates a timeout signal that aborts after the given duration, carrying the supplied error as its abort reason.
14
+ *
15
+ * The consumer owns the returned handle and must cancel() it once its wait settles. That discipline is what keeps a timer from being disposed at process exit
16
+ * instead of at settlement: on Windows, libuv disposing a still-pending timeout handle during natural exit can race pending socket cleanup and trip the
17
+ * UV_HANDLE_CLOSING assertion in libuv's async.c. Cancelling at settlement disposes the handle while the event loop is still healthy, which sidesteps the race
18
+ * regardless of how soon afterwards the process exits. The timer is also unref'd, so during its bounded pre-settlement window it never by itself holds open an
19
+ * otherwise-empty loop.
20
+ *
21
+ * The default error is built inside the timer callback so a wait that finishes in time allocates nothing.
12
22
  * @param ms - The timeout duration in milliseconds.
13
- * @returns An object with the timeout promise and a cancel function.
23
+ * @param reason - Optional error to abort with. Defaults to a generic Error naming the duration.
24
+ * @returns A handle exposing the timeout's signal and the cancel function that disposes its timer.
14
25
  */
15
- export declare function cancellableTimeout(ms: number): CancellableTimeout;
26
+ export declare function timeoutSignal(ms: number, reason?: Error): TimeoutSignal;
16
27
  /**
17
- * Races a promise against a timeout. If the promise resolves before the timeout, its value is returned. If the timeout fires first, the provided error is thrown
18
- * (or a default Error if none is provided). The timer is always cleaned up via .finally() to prevent orphaned event loop references.
28
+ * Waits for a promise, bounded by a timeout that throws. If the promise settles first its outcome passes through unchanged; if the bound lapses first, the
29
+ * caller's exact error object is thrown, so a call site can identify its own lapse by reference or by instanceof rather than by parsing a message.
19
30
  *
20
- * This is the single implementation of the timeout-race-with-cleanup pattern. All code paths that need "promise with timeout" should use this rather than manually
21
- * constructing timer/promise/race/cleanup sequences.
22
- * @param promise - The promise to race against the timeout.
31
+ * This is the throw-shaped wait policy: reach for it when a lapse means the operation failed. The timer's full lifecycle lives here - created before the race
32
+ * and cancelled in the finally on every exit path - so no call site can forget the cleanup.
33
+ * @param promise - The promise to wait on.
23
34
  * @param timeoutMs - The timeout duration in milliseconds.
24
- * @param timeoutError - Optional error to throw on timeout. Defaults to a generic Error with the timeout duration.
35
+ * @param timeoutError - Optional error to throw on timeout. Defaults to a generic Error naming the duration.
25
36
  * @returns The resolved value of the promise.
37
+ * @throws The supplied error (or the default) when the bound lapses first, or the promise's own rejection when it settles first.
38
+ */
39
+ export declare function waitWithTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutError?: Error): Promise<T>;
40
+ /**
41
+ * Waits for a promise, bounded by a timeout that yields null. If the promise settles first its value is returned; if the bound lapses first the result is null,
42
+ * so the caller branches on a value rather than unwinding through a catch.
43
+ *
44
+ * This is the value-shaped wait policy: reach for it when a lapse is an ordinary outcome the caller already handles - a shutdown escalating from SIGTERM to
45
+ * SIGKILL, a tune that did not land, an interception that never arrived. A promise's own rejection still propagates, because a rejection is a failure rather
46
+ * than a lapse.
47
+ *
48
+ * The composition is deliberate. runWithAbort performs no race of its own; it composes the bounds into one signal, hands that signal to the factory, and maps
49
+ * an abort-time rejection to null. So the factory forwards the signal into waitWithSignal, and that forwarding is what makes the bound genuinely bind on a
50
+ * promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound rides timeoutSignal rather than
51
+ * runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and is controllable
52
+ * from a fake clock.
53
+ *
54
+ * One constraint belongs to the caller: a promise that can itself resolve null cannot be told apart from a lapse. Callers own that fit.
55
+ * @param promise - The promise to wait on.
56
+ * @param timeoutMs - The timeout duration in milliseconds.
57
+ * @returns The resolved value of the promise, or null if the bound lapsed first.
26
58
  */
27
- export declare function raceWithTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutError?: Error): Promise<T>;
59
+ export declare function boundedWait<T>(promise: Promise<T>, timeoutMs: number): Promise<Nullable<T>>;
28
60
  /**
29
61
  * Creates a promise that resolves after the specified delay. Wraps node:timers/promises.setTimeout so the codebase has a single canonical "sleep" name.
30
62
  * @param ms - The delay duration in milliseconds.
31
63
  * @returns A promise that resolves after the specified delay.
32
64
  */
33
65
  export declare function delay(ms: number): Promise<void>;
66
+ //# sourceMappingURL=delay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAE5B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,aAAa,CAQvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAWjH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAWjG;AAED;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrD"}
@@ -1,36 +1,89 @@
1
1
  /* Copyright(C) 2024-2026, HJD (https://github.com/hjdhjd). All rights reserved.
2
2
  *
3
- * delay.ts: Async delay and timeout utilities for PrismCast.
3
+ * delay.ts: The project's wait policies. homebridge-plugin-utils owns the wait mechanisms - waitWithSignal races a held promise against an interrupt signal,
4
+ * and runWithAbort carries the return-null-on-abort policy - and this file names the policies built over them exactly once: timeoutSignal is the
5
+ * reason-carrying interrupt source, waitWithTimeout is the throw-shaped bounded wait, boundedWait is the value-shaped one, and delay is the named sleep. Any
6
+ * code path that needs "promise with a bound" consumes a policy here rather than re-rolling the timer, race, and cleanup sequence.
7
+ *
8
+ * Choosing between the two bounded waits is a question about semantics, not mechanism. A wait whose interruption is exceptional - the operation was supposed
9
+ * to finish and did not - throws through waitWithTimeout, so the failure travels as an error the caller can distinguish by identity or type. A wait whose
10
+ * lapse is an ordinary branch the caller was already going to take returns null through boundedWait, so the caller reads it as a value rather than unwinding
11
+ * through a catch it did not need.
12
+ *
13
+ * Each policy owns its timer's entire lifecycle: it creates the handle, races through the library, and cancels in a finally. Centralizing that ownership is
14
+ * what keeps a forgotten cleanup from leaking a timer at any call site, and it is what guarantees the handle is disposed at settlement while the event loop is
15
+ * still healthy (see the rationale on timeoutSignal).
4
16
  */
17
+ import { runWithAbort, waitWithSignal } from "homebridge-plugin-utils";
5
18
  import { setTimeout as nodeSleep } from "node:timers/promises";
6
19
  /**
7
- * Creates a cancellable timeout for use with Promise.race. Returns a promise that resolves to false after the specified delay, and a cancel function that clears
8
- * the timer so it does not hold an event loop reference after the race is won by another promise.
20
+ * Creates a timeout signal that aborts after the given duration, carrying the supplied error as its abort reason.
21
+ *
22
+ * The consumer owns the returned handle and must cancel() it once its wait settles. That discipline is what keeps a timer from being disposed at process exit
23
+ * instead of at settlement: on Windows, libuv disposing a still-pending timeout handle during natural exit can race pending socket cleanup and trip the
24
+ * UV_HANDLE_CLOSING assertion in libuv's async.c. Cancelling at settlement disposes the handle while the event loop is still healthy, which sidesteps the race
25
+ * regardless of how soon afterwards the process exits. The timer is also unref'd, so during its bounded pre-settlement window it never by itself holds open an
26
+ * otherwise-empty loop.
27
+ *
28
+ * The default error is built inside the timer callback so a wait that finishes in time allocates nothing.
9
29
  * @param ms - The timeout duration in milliseconds.
10
- * @returns An object with the timeout promise and a cancel function.
30
+ * @param reason - Optional error to abort with. Defaults to a generic Error naming the duration.
31
+ * @returns A handle exposing the timeout's signal and the cancel function that disposes its timer.
11
32
  */
12
- export function cancellableTimeout(ms) {
13
- const { promise, resolve } = Promise.withResolvers();
14
- const timer = setTimeout(() => { resolve(false); }, ms);
15
- return { cancel: () => { clearTimeout(timer); }, promise };
33
+ export function timeoutSignal(ms, reason) {
34
+ const controller = new AbortController();
35
+ const timer = setTimeout(() => { controller.abort(reason ?? new Error("Operation timed out after " + String(ms) + "ms.")); }, ms);
36
+ timer.unref();
37
+ return { cancel: () => { clearTimeout(timer); }, signal: controller.signal };
16
38
  }
17
39
  /**
18
- * Races a promise against a timeout. If the promise resolves before the timeout, its value is returned. If the timeout fires first, the provided error is thrown
19
- * (or a default Error if none is provided). The timer is always cleaned up via .finally() to prevent orphaned event loop references.
40
+ * Waits for a promise, bounded by a timeout that throws. If the promise settles first its outcome passes through unchanged; if the bound lapses first, the
41
+ * caller's exact error object is thrown, so a call site can identify its own lapse by reference or by instanceof rather than by parsing a message.
20
42
  *
21
- * This is the single implementation of the timeout-race-with-cleanup pattern. All code paths that need "promise with timeout" should use this rather than manually
22
- * constructing timer/promise/race/cleanup sequences.
23
- * @param promise - The promise to race against the timeout.
43
+ * This is the throw-shaped wait policy: reach for it when a lapse means the operation failed. The timer's full lifecycle lives here - created before the race
44
+ * and cancelled in the finally on every exit path - so no call site can forget the cleanup.
45
+ * @param promise - The promise to wait on.
24
46
  * @param timeoutMs - The timeout duration in milliseconds.
25
- * @param timeoutError - Optional error to throw on timeout. Defaults to a generic Error with the timeout duration.
47
+ * @param timeoutError - Optional error to throw on timeout. Defaults to a generic Error naming the duration.
26
48
  * @returns The resolved value of the promise.
49
+ * @throws The supplied error (or the default) when the bound lapses first, or the promise's own rejection when it settles first.
50
+ */
51
+ export async function waitWithTimeout(promise, timeoutMs, timeoutError) {
52
+ const timeout = timeoutSignal(timeoutMs, timeoutError);
53
+ try {
54
+ return await waitWithSignal(promise, timeout.signal);
55
+ }
56
+ finally {
57
+ timeout.cancel();
58
+ }
59
+ }
60
+ /**
61
+ * Waits for a promise, bounded by a timeout that yields null. If the promise settles first its value is returned; if the bound lapses first the result is null,
62
+ * so the caller branches on a value rather than unwinding through a catch.
63
+ *
64
+ * This is the value-shaped wait policy: reach for it when a lapse is an ordinary outcome the caller already handles - a shutdown escalating from SIGTERM to
65
+ * SIGKILL, a tune that did not land, an interception that never arrived. A promise's own rejection still propagates, because a rejection is a failure rather
66
+ * than a lapse.
67
+ *
68
+ * The composition is deliberate. runWithAbort performs no race of its own; it composes the bounds into one signal, hands that signal to the factory, and maps
69
+ * an abort-time rejection to null. So the factory forwards the signal into waitWithSignal, and that forwarding is what makes the bound genuinely bind on a
70
+ * promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound rides timeoutSignal rather than
71
+ * runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and is controllable
72
+ * from a fake clock.
73
+ *
74
+ * One constraint belongs to the caller: a promise that can itself resolve null cannot be told apart from a lapse. Callers own that fit.
75
+ * @param promise - The promise to wait on.
76
+ * @param timeoutMs - The timeout duration in milliseconds.
77
+ * @returns The resolved value of the promise, or null if the bound lapsed first.
27
78
  */
28
- export async function raceWithTimeout(promise, timeoutMs, timeoutError) {
29
- const { promise: timeoutPromise, reject: signalTimeout } = Promise.withResolvers();
30
- const timer = setTimeout(() => {
31
- signalTimeout(timeoutError ?? new Error("Operation timed out after " + String(timeoutMs) + "ms."));
32
- }, timeoutMs);
33
- return Promise.race([promise, timeoutPromise]).finally(() => { clearTimeout(timer); });
79
+ export async function boundedWait(promise, timeoutMs) {
80
+ const timeout = timeoutSignal(timeoutMs);
81
+ try {
82
+ return await runWithAbort((signal) => waitWithSignal(promise, signal), { signal: timeout.signal });
83
+ }
84
+ finally {
85
+ timeout.cancel();
86
+ }
34
87
  }
35
88
  /**
36
89
  * Creates a promise that resolves after the specified delay. Wraps node:timers/promises.setTimeout so the codebase has a single canonical "sleep" name.
@@ -1 +1 @@
1
- {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAY/D;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAE3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAExD,OAAO,EAAE,MAAM,EAAE,GAAS,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAI,OAAmB,EAAE,SAAiB,EAAE,YAAoB;IAEnG,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC1F,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAE5B,aAAa,CAAC,YAAY,IAAI,IAAI,KAAK,CAAC,4BAA4B,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACrG,CAAC,EAAE,SAAS,CAAC,CAAC;IAEd,OAAO,O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Ac,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QAET,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAI,OAAmB,EAAE,SAAiB;IAEzE,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAEzC,IAAI,CAAC;QAEH,OAAO,MAAM,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACrG,CAAC;YAAS,CAAC;QAET,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,EAAU;IAEpC,MAAM,SAAS,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC"}
@@ -9,7 +9,39 @@ export declare function formatError(error: unknown): string;
9
9
  * 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
10
10
  * any retry loops rather than continuing to retry an operation that will never succeed. Common unrecoverable errors include closed targets, closed sessions, and
11
11
  * detached frames (which occur when the page has been closed mid-operation).
12
+ *
13
+ * Matching ignores case. The same dead state reaches callers with different capitalization depending on which Puppeteer or CDP surface raised it, and a
14
+ * differently-capitalized closed target is the same closed target.
12
15
  * @param error - The error to check.
13
16
  * @returns True if the error indicates a closed or unrecoverable state.
14
17
  */
15
18
  export declare function isSessionClosedError(error: unknown): boolean;
19
+ /**
20
+ * 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
21
+ * 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.
22
+ *
23
+ * 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
24
+ * whether to discard cached state about that subject learns nothing from it and must keep the state.
25
+ *
26
+ * 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
27
+ * 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
28
+ * 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
29
+ * cannot-find-context wording into the context-destroyed one, but other Puppeteer surfaces still emit it directly.
30
+ *
31
+ * Composing isSessionClosedError formats the message twice on a call that matches neither family. That trade is deliberate: the session-closed patterns stay
32
+ * stated in exactly one place, and this runs only on an error path.
33
+ * @param error - The error to check.
34
+ * @returns True if the error indicates the page, execution context, or frame the operation ran in is gone.
35
+ */
36
+ export declare function isPageDeathError(error: unknown): boolean;
37
+ /**
38
+ * 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
39
+ * 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
40
+ * 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
41
+ * rejections are common and benign, so widening it would exit the process on ordinary browser crashes. The related, broader capture-infrastructure classifier
42
+ * (isCaptureInfrastructureError in recovery.ts) matches this message too, but the process-exit decision this predicate gates stays its own distinct check.
43
+ * @param error - The error or message to check.
44
+ * @returns True if the error carries the stale-capture-mutex signature.
45
+ */
46
+ export declare function isStaleCaptureMutexError(error: unknown): boolean;
47
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAaxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGhE"}
@@ -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,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5E,CAAC"}
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,IAA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;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;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAEhD,OAAO,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IAEpD,OAAO,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,SAAiB;QAE3B,KAAK,CAAC,2BAA2B,GAA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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,K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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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAWvD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAG5B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAGzC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAG3C,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAG/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAGnC,QAAQ,CAAC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