prismcast 1.12.0 → 1.13.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 (631) hide show
  1. package/dist/app.d.ts +41 -1
  2. package/dist/app.js +164 -76
  3. package/dist/app.js.map +1 -1
  4. package/dist/browser/blockedPage.d.ts +0 -1
  5. package/dist/browser/browserSupervisor.d.ts +34 -5
  6. package/dist/browser/browserSupervisor.js +39 -12
  7. package/dist/browser/browserSupervisor.js.map +1 -1
  8. package/dist/browser/cdp.d.ts +58 -6
  9. package/dist/browser/cdp.js +147 -9
  10. package/dist/browser/cdp.js.map +1 -1
  11. package/dist/browser/channelSelection.d.ts +18 -6
  12. package/dist/browser/channelSelection.js +47 -36
  13. package/dist/browser/channelSelection.js.map +1 -1
  14. package/dist/browser/consent.d.ts +33 -4
  15. package/dist/browser/consent.js +87 -50
  16. package/dist/browser/consent.js.map +1 -1
  17. package/dist/browser/display.d.ts +0 -1
  18. package/dist/browser/hlsPlaylistObserver.d.ts +3 -2
  19. package/dist/browser/hlsPlaylistObserver.js +11 -6
  20. package/dist/browser/hlsPlaylistObserver.js.map +1 -1
  21. package/dist/browser/index.d.ts +273 -59
  22. package/dist/browser/index.js +768 -255
  23. package/dist/browser/index.js.map +1 -1
  24. package/dist/browser/launchGovernor.d.ts +0 -1
  25. package/dist/browser/login.d.ts +11 -10
  26. package/dist/browser/login.js +42 -33
  27. package/dist/browser/login.js.map +1 -1
  28. package/dist/browser/manifestInterceptor.d.ts +14 -5
  29. package/dist/browser/manifestInterceptor.js +26 -13
  30. package/dist/browser/manifestInterceptor.js.map +1 -1
  31. package/dist/browser/navigation.d.ts +28 -0
  32. package/dist/browser/navigation.js +57 -0
  33. package/dist/browser/navigation.js.map +1 -0
  34. package/dist/browser/pageStaleness.d.ts +1 -2
  35. package/dist/browser/pageStaleness.js +9 -9
  36. package/dist/browser/pageStaleness.js.map +1 -1
  37. package/dist/browser/precaching.d.ts +27 -13
  38. package/dist/browser/precaching.js +219 -73
  39. package/dist/browser/precaching.js.map +1 -1
  40. package/dist/browser/tabCapture.d.ts +97 -0
  41. package/dist/browser/tabCapture.js +314 -0
  42. package/dist/browser/tabCapture.js.map +1 -0
  43. package/dist/browser/tabNetworkObserver.d.ts +0 -1
  44. package/dist/browser/tabSelection.d.ts +117 -0
  45. package/dist/browser/tabSelection.js +547 -0
  46. package/dist/browser/tabSelection.js.map +1 -0
  47. package/dist/browser/tuning/cache.d.ts +0 -1
  48. package/dist/browser/tuning/comcastPolymer.d.ts +0 -1
  49. package/dist/browser/tuning/comcastPolymer.js +18 -19
  50. package/dist/browser/tuning/comcastPolymer.js.map +1 -1
  51. package/dist/browser/tuning/cox.d.ts +0 -1
  52. package/dist/browser/tuning/directv.d.ts +0 -1
  53. package/dist/browser/tuning/directv.js +12 -13
  54. package/dist/browser/tuning/directv.js.map +1 -1
  55. package/dist/browser/tuning/fox.d.ts +0 -1
  56. package/dist/browser/tuning/fox.js +2 -2
  57. package/dist/browser/tuning/fox.js.map +1 -1
  58. package/dist/browser/tuning/gridSearch.d.ts +0 -1
  59. package/dist/browser/tuning/hbo.d.ts +0 -1
  60. package/dist/browser/tuning/hbo.js +2 -2
  61. package/dist/browser/tuning/hbo.js.map +1 -1
  62. package/dist/browser/tuning/hulu.d.ts +14 -2
  63. package/dist/browser/tuning/hulu.js +150 -24
  64. package/dist/browser/tuning/hulu.js.map +1 -1
  65. package/dist/browser/tuning/shared.d.ts +1 -2
  66. package/dist/browser/tuning/shared.js +1 -1
  67. package/dist/browser/tuning/sling.d.ts +0 -1
  68. package/dist/browser/tuning/sling.js +17 -22
  69. package/dist/browser/tuning/sling.js.map +1 -1
  70. package/dist/browser/tuning/spectrum.d.ts +0 -1
  71. package/dist/browser/tuning/thumbnailRow.d.ts +0 -1
  72. package/dist/browser/tuning/tileClick.d.ts +0 -1
  73. package/dist/browser/tuning/xfinity.d.ts +0 -1
  74. package/dist/browser/tuning/youtubeTv.d.ts +0 -1
  75. package/dist/browser/tuning/youtubeTv.js +1 -2
  76. package/dist/browser/tuning/youtubeTv.js.map +1 -1
  77. package/dist/browser/video.d.ts +55 -33
  78. package/dist/browser/video.js +213 -169
  79. package/dist/browser/video.js.map +1 -1
  80. package/dist/browser/windowSync.d.ts +45 -0
  81. package/dist/browser/windowSync.js +153 -0
  82. package/dist/browser/windowSync.js.map +1 -0
  83. package/dist/channels/index.d.ts +7 -1
  84. package/dist/channels/index.js +24 -8
  85. package/dist/channels/index.js.map +1 -1
  86. package/dist/config/channelForm.d.ts +0 -1
  87. package/dist/config/channelIdentity.d.ts +27 -0
  88. package/dist/config/channelIdentity.js +72 -0
  89. package/dist/config/channelIdentity.js.map +1 -0
  90. package/dist/config/channelSort.d.ts +25 -0
  91. package/dist/config/channelSort.js +101 -0
  92. package/dist/config/channelSort.js.map +1 -0
  93. package/dist/config/consistencyProbe.d.ts +0 -1
  94. package/dist/config/consistencyProbe.js +1 -1
  95. package/dist/config/consistencyProbe.js.map +1 -1
  96. package/dist/config/health.d.ts +3 -2
  97. package/dist/config/health.js +41 -31
  98. package/dist/config/health.js.map +1 -1
  99. package/dist/config/index.d.ts +12 -1
  100. package/dist/config/index.js +77 -31
  101. package/dist/config/index.js.map +1 -1
  102. package/dist/config/paths.d.ts +17 -2
  103. package/dist/config/paths.js +21 -1
  104. package/dist/config/paths.js.map +1 -1
  105. package/dist/config/persistence.context.d.ts +0 -1
  106. package/dist/config/persistence.d.ts +8 -4
  107. package/dist/config/persistence.js +143 -82
  108. package/dist/config/persistence.js.map +1 -1
  109. package/dist/config/presets.d.ts +0 -1
  110. package/dist/config/profiles.d.ts +9 -4
  111. package/dist/config/profiles.js +39 -6
  112. package/dist/config/profiles.js.map +1 -1
  113. package/dist/config/providerLineups.d.ts +0 -1
  114. package/dist/config/providerLineups.js +0 -3
  115. package/dist/config/providerLineups.js.map +1 -1
  116. package/dist/config/reactivity.d.ts +0 -1
  117. package/dist/config/servicePacks.d.ts +0 -1
  118. package/dist/config/services.d.ts +1 -47
  119. package/dist/config/services.js +4 -135
  120. package/dist/config/services.js.map +1 -1
  121. package/dist/config/sites.d.ts +0 -9
  122. package/dist/config/sites.js +82 -98
  123. package/dist/config/sites.js.map +1 -1
  124. package/dist/config/userChannels.d.ts +22 -29
  125. package/dist/config/userChannels.js +47 -65
  126. package/dist/config/userChannels.js.map +1 -1
  127. package/dist/config/userConfig.d.ts +19 -4
  128. package/dist/config/userConfig.js +123 -25
  129. package/dist/config/userConfig.js.map +1 -1
  130. package/dist/config/userProfiles.d.ts +2 -3
  131. package/dist/config/userProfiles.js +16 -13
  132. package/dist/config/userProfiles.js.map +1 -1
  133. package/dist/hdhr/channelMap.d.ts +0 -1
  134. package/dist/hdhr/deviceId.d.ts +0 -1
  135. package/dist/hdhr/discover.d.ts +0 -1
  136. package/dist/hdhr/getHandlers.d.ts +0 -1
  137. package/dist/hdhr/identity.d.ts +0 -1
  138. package/dist/hdhr/index.d.ts +0 -1
  139. package/dist/hdhr/protocol.d.ts +1 -2
  140. package/dist/hdhr/protocol.js +1 -1
  141. package/dist/hdhr/tunerState.d.ts +0 -1
  142. package/dist/hdhr/udp.d.ts +0 -1
  143. package/dist/hdhr/udp.js +16 -4
  144. package/dist/hdhr/udp.js.map +1 -1
  145. package/dist/identity.d.ts +0 -1
  146. package/dist/index.d.ts +0 -1
  147. package/dist/index.js +10 -3
  148. package/dist/index.js.map +1 -1
  149. package/dist/native/codecInference.d.ts +5 -4
  150. package/dist/native/codecInference.js +12 -7
  151. package/dist/native/codecInference.js.map +1 -1
  152. package/dist/native/decrypt.d.ts +10 -3
  153. package/dist/native/decrypt.js +9 -5
  154. package/dist/native/decrypt.js.map +1 -1
  155. package/dist/native/index.d.ts +26 -24
  156. package/dist/native/index.js +26 -20
  157. package/dist/native/index.js.map +1 -1
  158. package/dist/native/probe.d.ts +7 -10
  159. package/dist/native/probe.js +41 -37
  160. package/dist/native/probe.js.map +1 -1
  161. package/dist/native/proxy.d.ts +3 -4
  162. package/dist/native/proxy.js +91 -69
  163. package/dist/native/proxy.js.map +1 -1
  164. package/dist/native/tokenExpiry.d.ts +0 -1
  165. package/dist/routes/assets.d.ts +0 -1
  166. package/dist/routes/auth.d.ts +0 -1
  167. package/dist/routes/auth.js +1 -1
  168. package/dist/routes/auth.js.map +1 -1
  169. package/dist/routes/cdp.d.ts +11 -5
  170. package/dist/routes/cdp.js +91 -63
  171. package/dist/routes/cdp.js.map +1 -1
  172. package/dist/routes/channels.d.ts +0 -1
  173. package/dist/routes/clientActions.d.ts +0 -1
  174. package/dist/routes/components.d.ts +0 -1
  175. package/dist/routes/config/channels/endpoints/browse.d.ts +0 -1
  176. package/dist/routes/config/channels/endpoints/bulk.d.ts +0 -1
  177. package/dist/routes/config/channels/endpoints/bulk.js +3 -3
  178. package/dist/routes/config/channels/endpoints/bulk.js.map +1 -1
  179. package/dist/routes/config/channels/endpoints/crud.d.ts +0 -1
  180. package/dist/routes/config/channels/endpoints/crud.js +4 -3
  181. package/dist/routes/config/channels/endpoints/crud.js.map +1 -1
  182. package/dist/routes/config/channels/endpoints/importExport.d.ts +0 -1
  183. package/dist/routes/config/channels/endpoints/importExport.js +7 -3
  184. package/dist/routes/config/channels/endpoints/importExport.js.map +1 -1
  185. package/dist/routes/config/channels/endpoints/predefined.d.ts +0 -1
  186. package/dist/routes/config/channels/endpoints/prefs.d.ts +0 -1
  187. package/dist/routes/config/channels/endpoints/prefs.js +1 -1
  188. package/dist/routes/config/channels/endpoints/prefs.js.map +1 -1
  189. package/dist/routes/config/channels/endpoints/service.d.ts +0 -1
  190. package/dist/routes/config/channels/endpoints/service.js +8 -5
  191. package/dist/routes/config/channels/endpoints/service.js.map +1 -1
  192. package/dist/routes/config/channels/endpoints/tags.d.ts +0 -1
  193. package/dist/routes/config/channels/endpoints/tags.js +3 -3
  194. package/dist/routes/config/channels/endpoints/tags.js.map +1 -1
  195. package/dist/routes/config/channels/healthBridge.d.ts +4 -1
  196. package/dist/routes/config/channels/healthBridge.js +9 -5
  197. package/dist/routes/config/channels/healthBridge.js.map +1 -1
  198. package/dist/routes/config/channels/http/handler.d.ts +0 -1
  199. package/dist/routes/config/channels/http/playlistHint.d.ts +0 -1
  200. package/dist/routes/config/channels/http/serviceWarning.d.ts +0 -1
  201. package/dist/routes/config/channels/http/serviceWarning.js +1 -1
  202. package/dist/routes/config/channels/http/serviceWarning.js.map +1 -1
  203. package/dist/routes/config/channels/index.d.ts +0 -1
  204. package/dist/routes/config/channels/setup.d.ts +0 -1
  205. package/dist/routes/config/channels/table.d.ts +0 -1
  206. package/dist/routes/config/channels/table.js +66 -134
  207. package/dist/routes/config/channels/table.js.map +1 -1
  208. package/dist/routes/config/http/envelope.d.ts +1 -2
  209. package/dist/routes/config/index.d.ts +5 -5
  210. package/dist/routes/config/index.js +7 -5
  211. package/dist/routes/config/index.js.map +1 -1
  212. package/dist/routes/config/services.d.ts +0 -1
  213. package/dist/routes/config/services.js +17 -19
  214. package/dist/routes/config/services.js.map +1 -1
  215. package/dist/routes/config/settings.d.ts +6 -15
  216. package/dist/routes/config/settings.js +16 -35
  217. package/dist/routes/config/settings.js.map +1 -1
  218. package/dist/routes/debug.d.ts +0 -1
  219. package/dist/routes/debug.js +1 -1
  220. package/dist/routes/debug.js.map +1 -1
  221. package/dist/routes/health.d.ts +16 -8
  222. package/dist/routes/health.js +27 -12
  223. package/dist/routes/health.js.map +1 -1
  224. package/dist/routes/hls.d.ts +0 -1
  225. package/dist/routes/icons.d.ts +0 -1
  226. package/dist/routes/index.d.ts +0 -1
  227. package/dist/routes/logs.d.ts +3 -2
  228. package/dist/routes/logs.js +54 -14
  229. package/dist/routes/logs.js.map +1 -1
  230. package/dist/routes/mpegts.d.ts +0 -1
  231. package/dist/routes/play.d.ts +0 -1
  232. package/dist/routes/playlist.d.ts +0 -1
  233. package/dist/routes/playlist.js +2 -1
  234. package/dist/routes/playlist.js.map +1 -1
  235. package/dist/routes/root/content.d.ts +0 -1
  236. package/dist/routes/root/content.js +32 -11
  237. package/dist/routes/root/content.js.map +1 -1
  238. package/dist/routes/root/index.d.ts +10 -1
  239. package/dist/routes/root/index.js +17 -7
  240. package/dist/routes/root/index.js.map +1 -1
  241. package/dist/routes/root/scripts/channels.d.ts +0 -1
  242. package/dist/routes/root/scripts/channels.js +10 -20
  243. package/dist/routes/root/scripts/channels.js.map +1 -1
  244. package/dist/routes/root/scripts/clientEscape.d.ts +0 -1
  245. package/dist/routes/root/scripts/clientEscape.js +1 -1
  246. package/dist/routes/root/scripts/clientUrl.d.ts +0 -1
  247. package/dist/routes/root/scripts/config.d.ts +0 -1
  248. package/dist/routes/root/scripts/config.js +8 -29
  249. package/dist/routes/root/scripts/config.js.map +1 -1
  250. package/dist/routes/root/scripts/index.d.ts +0 -1
  251. package/dist/routes/root/scripts/shared.d.ts +0 -1
  252. package/dist/routes/root/scripts/shared.js +16 -13
  253. package/dist/routes/root/scripts/shared.js.map +1 -1
  254. package/dist/routes/root/scripts/status.d.ts +0 -1
  255. package/dist/routes/root/scripts/status.handlers.d.ts +3 -1
  256. package/dist/routes/root/scripts/status.handlers.js +52 -26
  257. package/dist/routes/root/scripts/status.handlers.js.map +1 -1
  258. package/dist/routes/root/styles.d.ts +0 -1
  259. package/dist/routes/root/styles.js +10 -18
  260. package/dist/routes/root/styles.js.map +1 -1
  261. package/dist/routes/services.d.ts +0 -1
  262. package/dist/routes/services.js +1 -1
  263. package/dist/routes/services.js.map +1 -1
  264. package/dist/routes/sse.d.ts +3 -2
  265. package/dist/routes/sse.js +7 -3
  266. package/dist/routes/sse.js.map +1 -1
  267. package/dist/routes/streams.d.ts +4 -2
  268. package/dist/routes/streams.js +8 -5
  269. package/dist/routes/streams.js.map +1 -1
  270. package/dist/routes/theme.d.ts +0 -1
  271. package/dist/routes/theme.js +3 -3
  272. package/dist/routes/theme.js.map +1 -1
  273. package/dist/routes/ui.d.ts +0 -1
  274. package/dist/routes/ui.js +5 -5
  275. package/dist/routes/ui.js.map +1 -1
  276. package/dist/routes/upgrade.d.ts +0 -1
  277. package/dist/routes/upgrade.js +2 -1
  278. package/dist/routes/upgrade.js.map +1 -1
  279. package/dist/service/commands.context.d.ts +0 -1
  280. package/dist/service/commands.context.js +7 -1
  281. package/dist/service/commands.context.js.map +1 -1
  282. package/dist/service/commands.d.ts +0 -1
  283. package/dist/service/generators.context.d.ts +0 -1
  284. package/dist/service/generators.d.ts +0 -1
  285. package/dist/service/index.d.ts +0 -1
  286. package/dist/streaming/captureLock.d.ts +1 -2
  287. package/dist/streaming/captureLock.js +8 -7
  288. package/dist/streaming/captureLock.js.map +1 -1
  289. package/dist/streaming/captureSession.d.ts +0 -1
  290. package/dist/streaming/clients.d.ts +4 -3
  291. package/dist/streaming/clients.js +5 -4
  292. package/dist/streaming/clients.js.map +1 -1
  293. package/dist/streaming/codec.d.ts +0 -1
  294. package/dist/streaming/fmp4Segmenter.d.ts +11 -6
  295. package/dist/streaming/fmp4Segmenter.js +39 -17
  296. package/dist/streaming/fmp4Segmenter.js.map +1 -1
  297. package/dist/streaming/hls.d.ts +96 -3
  298. package/dist/streaming/hls.js +282 -171
  299. package/dist/streaming/hls.js.map +1 -1
  300. package/dist/streaming/hlsResume.d.ts +8 -5
  301. package/dist/streaming/hlsResume.js +10 -8
  302. package/dist/streaming/hlsResume.js.map +1 -1
  303. package/dist/streaming/hlsSegments.d.ts +11 -8
  304. package/dist/streaming/hlsSegments.js +38 -18
  305. package/dist/streaming/hlsSegments.js.map +1 -1
  306. package/dist/streaming/lifecycle.d.ts +5 -4
  307. package/dist/streaming/lifecycle.js +43 -13
  308. package/dist/streaming/lifecycle.js.map +1 -1
  309. package/dist/streaming/monitor.d.ts +14 -3
  310. package/dist/streaming/monitor.js +447 -234
  311. package/dist/streaming/monitor.js.map +1 -1
  312. package/dist/streaming/mp4Parser.d.ts +0 -1
  313. package/dist/streaming/mpegts.d.ts +11 -1
  314. package/dist/streaming/mpegts.js +92 -28
  315. package/dist/streaming/mpegts.js.map +1 -1
  316. package/dist/streaming/playlistBuilder.d.ts +0 -1
  317. package/dist/streaming/preroll.d.ts +34 -15
  318. package/dist/streaming/preroll.js +32 -30
  319. package/dist/streaming/preroll.js.map +1 -1
  320. package/dist/streaming/pretune.d.ts +2 -3
  321. package/dist/streaming/pretune.js +45 -45
  322. package/dist/streaming/pretune.js.map +1 -1
  323. package/dist/streaming/pretuneTimers.d.ts +16 -12
  324. package/dist/streaming/pretuneTimers.js +27 -37
  325. package/dist/streaming/pretuneTimers.js.map +1 -1
  326. package/dist/streaming/recovery.d.ts +97 -9
  327. package/dist/streaming/recovery.js +96 -18
  328. package/dist/streaming/recovery.js.map +1 -1
  329. package/dist/streaming/registry.d.ts +102 -15
  330. package/dist/streaming/registry.js +90 -5
  331. package/dist/streaming/registry.js.map +1 -1
  332. package/dist/streaming/setup.d.ts +90 -32
  333. package/dist/streaming/setup.js +379 -248
  334. package/dist/streaming/setup.js.map +1 -1
  335. package/dist/streaming/showInfo.d.ts +8 -4
  336. package/dist/streaming/showInfo.js +54 -45
  337. package/dist/streaming/showInfo.js.map +1 -1
  338. package/dist/streaming/statusEmitter.d.ts +5 -3
  339. package/dist/streaming/statusEmitter.js +20 -8
  340. package/dist/streaming/statusEmitter.js.map +1 -1
  341. package/dist/types/channels.d.ts +0 -1
  342. package/dist/types/channels.js +0 -4
  343. package/dist/types/channels.js.map +1 -1
  344. package/dist/types/config.d.ts +0 -1
  345. package/dist/types/index.d.ts +4 -4
  346. package/dist/types/index.js +2 -1
  347. package/dist/types/index.js.map +1 -1
  348. package/dist/types/profiles.d.ts +51 -9
  349. package/dist/types/profiles.js +35 -1
  350. package/dist/types/profiles.js.map +1 -1
  351. package/dist/types/selection.d.ts +10 -1
  352. package/dist/types/shared.d.ts +0 -1
  353. package/dist/types/streaming.d.ts +8 -1
  354. package/dist/types/streaming.js +7 -0
  355. package/dist/types/streaming.js.map +1 -1
  356. package/dist/upgrade/commands.context.d.ts +0 -1
  357. package/dist/upgrade/commands.d.ts +0 -1
  358. package/dist/upgrade/commands.js +1 -1
  359. package/dist/upgrade/commands.js.map +1 -1
  360. package/dist/upgrade/detection.context.d.ts +0 -1
  361. package/dist/upgrade/detection.d.ts +1 -2
  362. package/dist/upgrade/index.d.ts +0 -1
  363. package/dist/upgrade/lifecycle.context.d.ts +2 -1
  364. package/dist/upgrade/lifecycle.context.js +9 -4
  365. package/dist/upgrade/lifecycle.context.js.map +1 -1
  366. package/dist/upgrade/lifecycle.d.ts +0 -1
  367. package/dist/upgrade/pathHandle.d.ts +0 -1
  368. package/dist/utils/bootSession.context.d.ts +0 -1
  369. package/dist/utils/bootSession.context.js +3 -2
  370. package/dist/utils/bootSession.context.js.map +1 -1
  371. package/dist/utils/bootSession.d.ts +0 -1
  372. package/dist/utils/chromeFetch.d.ts +0 -1
  373. package/dist/utils/cliOutput.d.ts +0 -1
  374. package/dist/utils/debugFilter.d.ts +0 -1
  375. package/dist/utils/debugFilter.js +5 -3
  376. package/dist/utils/debugFilter.js.map +1 -1
  377. package/dist/utils/delay.d.ts +65 -13
  378. package/dist/utils/delay.js +96 -23
  379. package/dist/utils/delay.js.map +1 -1
  380. package/dist/utils/errors.d.ts +0 -11
  381. package/dist/utils/errors.js +3 -14
  382. package/dist/utils/errors.js.map +1 -1
  383. package/dist/utils/evaluate.d.ts +11 -3
  384. package/dist/utils/evaluate.js +4 -3
  385. package/dist/utils/evaluate.js.map +1 -1
  386. package/dist/utils/ffmpeg.context.d.ts +0 -1
  387. package/dist/utils/ffmpeg.d.ts +1 -1
  388. package/dist/utils/ffmpeg.js +2 -1
  389. package/dist/utils/ffmpeg.js.map +1 -1
  390. package/dist/utils/fileLogger.d.ts +26 -7
  391. package/dist/utils/fileLogger.js +241 -102
  392. package/dist/utils/fileLogger.js.map +1 -1
  393. package/dist/utils/format.d.ts +36 -4
  394. package/dist/utils/format.js +66 -12
  395. package/dist/utils/format.js.map +1 -1
  396. package/dist/utils/index.d.ts +1 -2
  397. package/dist/utils/index.js +1 -1
  398. package/dist/utils/index.js.map +1 -1
  399. package/dist/utils/logEmitter.d.ts +0 -1
  400. package/dist/utils/logger.d.ts +0 -1
  401. package/dist/utils/m3u.d.ts +0 -1
  402. package/dist/utils/markup.d.ts +0 -1
  403. package/dist/utils/memo.d.ts +0 -1
  404. package/dist/utils/morganStream.d.ts +2 -3
  405. package/dist/utils/morganStream.js +6 -8
  406. package/dist/utils/morganStream.js.map +1 -1
  407. package/dist/utils/network.d.ts +0 -1
  408. package/dist/utils/never.d.ts +8 -0
  409. package/dist/utils/never.js +20 -0
  410. package/dist/utils/never.js.map +1 -0
  411. package/dist/utils/pid.d.ts +0 -1
  412. package/dist/utils/platform.d.ts +0 -1
  413. package/dist/utils/processInspector.context.d.ts +32 -2
  414. package/dist/utils/processInspector.context.js +117 -1
  415. package/dist/utils/processInspector.context.js.map +1 -1
  416. package/dist/utils/processInspector.d.ts +0 -32
  417. package/dist/utils/processInspector.js +10 -117
  418. package/dist/utils/processInspector.js.map +1 -1
  419. package/dist/utils/retry.d.ts +5 -4
  420. package/dist/utils/retry.js +43 -33
  421. package/dist/utils/retry.js.map +1 -1
  422. package/dist/utils/runtimeIdentity.context.d.ts +0 -1
  423. package/dist/utils/runtimeIdentity.context.js +3 -1
  424. package/dist/utils/runtimeIdentity.context.js.map +1 -1
  425. package/dist/utils/runtimeIdentity.d.ts +1 -1
  426. package/dist/utils/runtimeIdentity.js +1 -1
  427. package/dist/utils/runtimeIdentity.js.map +1 -1
  428. package/dist/utils/sanitize.d.ts +8 -1
  429. package/dist/utils/sanitize.js +19 -0
  430. package/dist/utils/sanitize.js.map +1 -1
  431. package/dist/utils/streamContext.d.ts +0 -1
  432. package/dist/utils/timing.d.ts +3 -4
  433. package/dist/utils/timing.js +4 -4
  434. package/dist/utils/timing.js.map +1 -1
  435. package/dist/utils/version.d.ts +14 -8
  436. package/dist/utils/version.js +35 -24
  437. package/dist/utils/version.js.map +1 -1
  438. package/package.json +7 -7
  439. package/dist/app.d.ts.map +0 -1
  440. package/dist/browser/blockedPage.d.ts.map +0 -1
  441. package/dist/browser/browserSupervisor.d.ts.map +0 -1
  442. package/dist/browser/cdp.d.ts.map +0 -1
  443. package/dist/browser/channelSelection.d.ts.map +0 -1
  444. package/dist/browser/consent.d.ts.map +0 -1
  445. package/dist/browser/display.d.ts.map +0 -1
  446. package/dist/browser/hlsPlaylistObserver.d.ts.map +0 -1
  447. package/dist/browser/index.d.ts.map +0 -1
  448. package/dist/browser/launchGovernor.d.ts.map +0 -1
  449. package/dist/browser/login.d.ts.map +0 -1
  450. package/dist/browser/manifestInterceptor.d.ts.map +0 -1
  451. package/dist/browser/pageStaleness.d.ts.map +0 -1
  452. package/dist/browser/precaching.d.ts.map +0 -1
  453. package/dist/browser/tabNetworkObserver.d.ts.map +0 -1
  454. package/dist/browser/tuning/cache.d.ts.map +0 -1
  455. package/dist/browser/tuning/comcastPolymer.d.ts.map +0 -1
  456. package/dist/browser/tuning/cox.d.ts.map +0 -1
  457. package/dist/browser/tuning/directv.d.ts.map +0 -1
  458. package/dist/browser/tuning/fox.d.ts.map +0 -1
  459. package/dist/browser/tuning/gridSearch.d.ts.map +0 -1
  460. package/dist/browser/tuning/hbo.d.ts.map +0 -1
  461. package/dist/browser/tuning/hulu.d.ts.map +0 -1
  462. package/dist/browser/tuning/shared.d.ts.map +0 -1
  463. package/dist/browser/tuning/sling.d.ts.map +0 -1
  464. package/dist/browser/tuning/spectrum.d.ts.map +0 -1
  465. package/dist/browser/tuning/thumbnailRow.d.ts.map +0 -1
  466. package/dist/browser/tuning/tileClick.d.ts.map +0 -1
  467. package/dist/browser/tuning/xfinity.d.ts.map +0 -1
  468. package/dist/browser/tuning/youtubeTv.d.ts.map +0 -1
  469. package/dist/browser/video.d.ts.map +0 -1
  470. package/dist/channels/index.d.ts.map +0 -1
  471. package/dist/config/channelForm.d.ts.map +0 -1
  472. package/dist/config/consistencyProbe.d.ts.map +0 -1
  473. package/dist/config/health.d.ts.map +0 -1
  474. package/dist/config/index.d.ts.map +0 -1
  475. package/dist/config/paths.d.ts.map +0 -1
  476. package/dist/config/persistence.context.d.ts.map +0 -1
  477. package/dist/config/persistence.d.ts.map +0 -1
  478. package/dist/config/presets.d.ts.map +0 -1
  479. package/dist/config/profiles.d.ts.map +0 -1
  480. package/dist/config/providerLineups.d.ts.map +0 -1
  481. package/dist/config/reactivity.d.ts.map +0 -1
  482. package/dist/config/servicePacks.d.ts.map +0 -1
  483. package/dist/config/services.d.ts.map +0 -1
  484. package/dist/config/sites.d.ts.map +0 -1
  485. package/dist/config/userChannels.d.ts.map +0 -1
  486. package/dist/config/userConfig.d.ts.map +0 -1
  487. package/dist/config/userProfiles.d.ts.map +0 -1
  488. package/dist/hdhr/channelMap.d.ts.map +0 -1
  489. package/dist/hdhr/deviceId.d.ts.map +0 -1
  490. package/dist/hdhr/discover.d.ts.map +0 -1
  491. package/dist/hdhr/getHandlers.d.ts.map +0 -1
  492. package/dist/hdhr/identity.d.ts.map +0 -1
  493. package/dist/hdhr/index.d.ts.map +0 -1
  494. package/dist/hdhr/protocol.d.ts.map +0 -1
  495. package/dist/hdhr/tunerState.d.ts.map +0 -1
  496. package/dist/hdhr/udp.d.ts.map +0 -1
  497. package/dist/identity.d.ts.map +0 -1
  498. package/dist/index.d.ts.map +0 -1
  499. package/dist/native/codecInference.d.ts.map +0 -1
  500. package/dist/native/decrypt.d.ts.map +0 -1
  501. package/dist/native/index.d.ts.map +0 -1
  502. package/dist/native/probe.d.ts.map +0 -1
  503. package/dist/native/proxy.d.ts.map +0 -1
  504. package/dist/native/tokenExpiry.d.ts.map +0 -1
  505. package/dist/routes/assets.d.ts.map +0 -1
  506. package/dist/routes/auth.d.ts.map +0 -1
  507. package/dist/routes/cdp.d.ts.map +0 -1
  508. package/dist/routes/channels.d.ts.map +0 -1
  509. package/dist/routes/clientActions.d.ts.map +0 -1
  510. package/dist/routes/components.d.ts.map +0 -1
  511. package/dist/routes/config/channels/endpoints/browse.d.ts.map +0 -1
  512. package/dist/routes/config/channels/endpoints/bulk.d.ts.map +0 -1
  513. package/dist/routes/config/channels/endpoints/crud.d.ts.map +0 -1
  514. package/dist/routes/config/channels/endpoints/importExport.d.ts.map +0 -1
  515. package/dist/routes/config/channels/endpoints/predefined.d.ts.map +0 -1
  516. package/dist/routes/config/channels/endpoints/prefs.d.ts.map +0 -1
  517. package/dist/routes/config/channels/endpoints/service.d.ts.map +0 -1
  518. package/dist/routes/config/channels/endpoints/tags.d.ts.map +0 -1
  519. package/dist/routes/config/channels/healthBridge.d.ts.map +0 -1
  520. package/dist/routes/config/channels/http/handler.d.ts.map +0 -1
  521. package/dist/routes/config/channels/http/playlistHint.d.ts.map +0 -1
  522. package/dist/routes/config/channels/http/serviceWarning.d.ts.map +0 -1
  523. package/dist/routes/config/channels/index.d.ts.map +0 -1
  524. package/dist/routes/config/channels/setup.d.ts.map +0 -1
  525. package/dist/routes/config/channels/table.d.ts.map +0 -1
  526. package/dist/routes/config/http/envelope.d.ts.map +0 -1
  527. package/dist/routes/config/index.d.ts.map +0 -1
  528. package/dist/routes/config/services.d.ts.map +0 -1
  529. package/dist/routes/config/settings.d.ts.map +0 -1
  530. package/dist/routes/debug.d.ts.map +0 -1
  531. package/dist/routes/health.d.ts.map +0 -1
  532. package/dist/routes/hls.d.ts.map +0 -1
  533. package/dist/routes/icons.d.ts.map +0 -1
  534. package/dist/routes/index.d.ts.map +0 -1
  535. package/dist/routes/logs.d.ts.map +0 -1
  536. package/dist/routes/mpegts.d.ts.map +0 -1
  537. package/dist/routes/play.d.ts.map +0 -1
  538. package/dist/routes/playlist.d.ts.map +0 -1
  539. package/dist/routes/root/content.d.ts.map +0 -1
  540. package/dist/routes/root/index.d.ts.map +0 -1
  541. package/dist/routes/root/scripts/channels.d.ts.map +0 -1
  542. package/dist/routes/root/scripts/clientEscape.d.ts.map +0 -1
  543. package/dist/routes/root/scripts/clientUrl.d.ts.map +0 -1
  544. package/dist/routes/root/scripts/config.d.ts.map +0 -1
  545. package/dist/routes/root/scripts/index.d.ts.map +0 -1
  546. package/dist/routes/root/scripts/shared.d.ts.map +0 -1
  547. package/dist/routes/root/scripts/status.d.ts.map +0 -1
  548. package/dist/routes/root/scripts/status.handlers.d.ts.map +0 -1
  549. package/dist/routes/root/styles.d.ts.map +0 -1
  550. package/dist/routes/services.d.ts.map +0 -1
  551. package/dist/routes/sse.d.ts.map +0 -1
  552. package/dist/routes/streams.d.ts.map +0 -1
  553. package/dist/routes/theme.d.ts.map +0 -1
  554. package/dist/routes/ui.d.ts.map +0 -1
  555. package/dist/routes/upgrade.d.ts.map +0 -1
  556. package/dist/service/commands.context.d.ts.map +0 -1
  557. package/dist/service/commands.d.ts.map +0 -1
  558. package/dist/service/generators.context.d.ts.map +0 -1
  559. package/dist/service/generators.d.ts.map +0 -1
  560. package/dist/service/index.d.ts.map +0 -1
  561. package/dist/streaming/captureLock.d.ts.map +0 -1
  562. package/dist/streaming/captureSession.d.ts.map +0 -1
  563. package/dist/streaming/clients.d.ts.map +0 -1
  564. package/dist/streaming/codec.d.ts.map +0 -1
  565. package/dist/streaming/fmp4Segmenter.d.ts.map +0 -1
  566. package/dist/streaming/hls.d.ts.map +0 -1
  567. package/dist/streaming/hlsResume.d.ts.map +0 -1
  568. package/dist/streaming/hlsSegments.d.ts.map +0 -1
  569. package/dist/streaming/lifecycle.d.ts.map +0 -1
  570. package/dist/streaming/monitor.d.ts.map +0 -1
  571. package/dist/streaming/mp4Parser.d.ts.map +0 -1
  572. package/dist/streaming/mpegts.d.ts.map +0 -1
  573. package/dist/streaming/playlistBuilder.d.ts.map +0 -1
  574. package/dist/streaming/preroll.d.ts.map +0 -1
  575. package/dist/streaming/pretune.d.ts.map +0 -1
  576. package/dist/streaming/pretuneTimers.d.ts.map +0 -1
  577. package/dist/streaming/recovery.d.ts.map +0 -1
  578. package/dist/streaming/registry.d.ts.map +0 -1
  579. package/dist/streaming/setup.d.ts.map +0 -1
  580. package/dist/streaming/showInfo.d.ts.map +0 -1
  581. package/dist/streaming/statusEmitter.d.ts.map +0 -1
  582. package/dist/types/channels.d.ts.map +0 -1
  583. package/dist/types/config.d.ts.map +0 -1
  584. package/dist/types/index.d.ts.map +0 -1
  585. package/dist/types/profiles.d.ts.map +0 -1
  586. package/dist/types/selection.d.ts.map +0 -1
  587. package/dist/types/shared.d.ts.map +0 -1
  588. package/dist/types/streaming.d.ts.map +0 -1
  589. package/dist/upgrade/commands.context.d.ts.map +0 -1
  590. package/dist/upgrade/commands.d.ts.map +0 -1
  591. package/dist/upgrade/detection.context.d.ts.map +0 -1
  592. package/dist/upgrade/detection.d.ts.map +0 -1
  593. package/dist/upgrade/index.d.ts.map +0 -1
  594. package/dist/upgrade/lifecycle.context.d.ts.map +0 -1
  595. package/dist/upgrade/lifecycle.d.ts.map +0 -1
  596. package/dist/upgrade/pathHandle.d.ts.map +0 -1
  597. package/dist/utils/bootSession.context.d.ts.map +0 -1
  598. package/dist/utils/bootSession.d.ts.map +0 -1
  599. package/dist/utils/chromeFetch.d.ts.map +0 -1
  600. package/dist/utils/cliOutput.d.ts.map +0 -1
  601. package/dist/utils/clock.d.ts +0 -15
  602. package/dist/utils/clock.d.ts.map +0 -1
  603. package/dist/utils/clock.js +0 -31
  604. package/dist/utils/clock.js.map +0 -1
  605. package/dist/utils/debugFilter.d.ts.map +0 -1
  606. package/dist/utils/delay.d.ts.map +0 -1
  607. package/dist/utils/errors.d.ts.map +0 -1
  608. package/dist/utils/evaluate.d.ts.map +0 -1
  609. package/dist/utils/ffmpeg.context.d.ts.map +0 -1
  610. package/dist/utils/ffmpeg.d.ts.map +0 -1
  611. package/dist/utils/fileLogger.d.ts.map +0 -1
  612. package/dist/utils/format.d.ts.map +0 -1
  613. package/dist/utils/index.d.ts.map +0 -1
  614. package/dist/utils/logEmitter.d.ts.map +0 -1
  615. package/dist/utils/logger.d.ts.map +0 -1
  616. package/dist/utils/m3u.d.ts.map +0 -1
  617. package/dist/utils/markup.d.ts.map +0 -1
  618. package/dist/utils/memo.d.ts.map +0 -1
  619. package/dist/utils/morganStream.d.ts.map +0 -1
  620. package/dist/utils/network.d.ts.map +0 -1
  621. package/dist/utils/pid.d.ts.map +0 -1
  622. package/dist/utils/platform.d.ts.map +0 -1
  623. package/dist/utils/processInspector.context.d.ts.map +0 -1
  624. package/dist/utils/processInspector.d.ts.map +0 -1
  625. package/dist/utils/retry.d.ts.map +0 -1
  626. package/dist/utils/runtimeIdentity.context.d.ts.map +0 -1
  627. package/dist/utils/runtimeIdentity.d.ts.map +0 -1
  628. package/dist/utils/sanitize.d.ts.map +0 -1
  629. package/dist/utils/streamContext.d.ts.map +0 -1
  630. package/dist/utils/timing.d.ts.map +0 -1
  631. package/dist/utils/version.d.ts.map +0 -1
@@ -2,12 +2,15 @@
2
2
  *
3
3
  * video.ts: Video context and playback handling for PrismCast.
4
4
  */
5
- import { EvaluateAbortError, LOG, delay, evaluateWithAbort, extractDomain, formatError, startTimer, waitWithTimeout } from "../utils/index.js";
6
- import { getProvidersForDomain, invalidateDirectUrl, resolveDirectUrl, selectChannel } from "./channelSelection.js";
5
+ import { EvaluateAbortError, LOG, evaluateWithAbort, extractDomain, formatError, pollUntil, startTimer, waitWithTimeout } from "../utils/index.js";
6
+ import { getProvidersForDomain, getStrategyNavigator, invalidateDirectUrl, resolveDirectUrl, selectChannel } from "./channelSelection.js";
7
+ import { loadDocument, reloadDocument } from "./navigation.js";
7
8
  import { CONFIG } from "../config/index.js";
8
9
  import { classifyBlockedPage } from "./blockedPage.js";
9
10
  import { markDomainAuthRequired } from "../config/health.js";
10
11
  import { startOverlayHandling } from "./consent.js";
12
+ import { systemClock } from "homebridge-plugin-utils";
13
+ import { withTabSelected } from "./tabSelection.js";
11
14
  /* These functions manage the video element lifecycle for streaming capture. The key challenges we solve:
12
15
  *
13
16
  * 1. Video context resolution: Video elements may be in the main page or nested inside iframes. Some streaming sites (like those using Brightcove or JW Player
@@ -73,19 +76,30 @@ export async function injectVideoSelector(page) {
73
76
  };
74
77
  });
75
78
  }
76
- // Fullscreen activation queue. Chrome's Fullscreen API requires the target tab to be in the foreground (focused). When multiple streams start concurrently, each
77
- // tab must call page.bringToFront() before requestFullscreen() - but without serialization, tabs steal foreground from each other, causing silent failures. We
78
- // serialize the bringToFront -> triggerFullscreen -> verify sequence using a promise chain so each tab gets exclusive foreground access during fullscreen activation.
79
+ /* Fullscreen activation queue. Chrome grants the Fullscreen API to the tab its window has selected, so a sequence has to run with its own tab selected, and two
80
+ * streams activating at once would otherwise take the selection from each other mid-sequence. The queue serializes the sequences of concurrent streams and bounds
81
+ * each at ten seconds; inside a queue entry, the sequence holds the tab selection for its whole run through the selection executor and gives it back when it
82
+ * returns. The wrapper's lapse ends the queue entry, while the sequence's own steps are each bounded and finish the hold.
83
+ */
79
84
  let fullscreenQueue = Promise.resolve();
85
+ /* The ceiling on a fullscreen sequence's hold of the tab selection. A sequence is three attempts of roughly 1.2 s - the retry click, the styles, the trigger with
86
+ * its 300 ms settle, the 200 ms verify wait, the 500 ms retry delay - plus the escalation tail, so about 4.4 s on a responsive page. Six seconds leaves that room
87
+ * and still bounds a slow page: past the ceiling the selection goes back and the sequence's remaining steps run deselected into its own escalation and warning,
88
+ * and a capture start queued behind it keeps at least four seconds of its default ten-second deadline.
89
+ */
90
+ const FULLSCREEN_SELECTION_CEILING_MS = 6000;
91
+ // The production collaborator.
92
+ export const defaultFullscreenDeps = { clock: systemClock, withTabSelected };
80
93
  /**
81
94
  * Gets the current state of the video element for health monitoring. Returns null if no video element is found.
82
95
  * @param context - The frame or page containing the video element.
83
96
  * @param selectorType - The video selector type for finding the element.
84
- * @param timeoutMs - How long to wait for the read before giving up. Omit for the evaluate wrapper's default bound; a caller that already has reason to suspect
85
- * an unresponsive tab passes a shorter one, since it needs to tell a hung page from a live one rather than wait out a slow answer.
97
+ * @param options - The clock the read's bound arms on and how long that bound is. Omit the bound for the evaluate wrapper's default; a caller that already has
98
+ * reason to suspect an unresponsive tab passes a shorter one, since it needs to tell a hung page from a live one rather than wait out a slow
99
+ * answer.
86
100
  * @returns The video state or null if no video found.
87
101
  */
88
- export async function getVideoState(context, selectorType, timeoutMs) {
102
+ export async function getVideoState(context, selectorType, options = {}) {
89
103
  return evaluateWithAbort(context, (type) => {
90
104
  const video = window.__prismcastSelectVideo?.(type) ?? null;
91
105
  if (!video) {
@@ -103,7 +117,7 @@ export async function getVideoState(context, selectorType, timeoutMs) {
103
117
  videoWidth: video.videoWidth,
104
118
  volume: video.volume
105
119
  };
106
- }, [selectorType], timeoutMs);
120
+ }, [selectorType], options);
107
121
  }
108
122
  /**
109
123
  * Enforces volume settings on the video element. Sets muted to false and volume to 1. This is called periodically during health monitoring to counter sites that
@@ -170,7 +184,7 @@ export async function suppressPageAudio(page) {
170
184
  }
171
185
  catch {
172
186
  // Best-effort, exactly like the immediate mute below. The page may be mid-navigation or tearing down as the stream switches to native delivery, and a failed
173
- // override must not abort the switch it rides along with. Future navigations on this page then play unmuted until the next suppression pass runs, which is
187
+ // override must not abort the switch it accompanies. Future navigations on this page then play unmuted until the next suppression pass runs, which is
174
188
  // the cost the best-effort contract accepts.
175
189
  }
176
190
  // Mute any videos that are already playing. The prototype override only affects future play() calls, so existing playback needs a direct mute.
@@ -270,67 +284,36 @@ export async function startVideoPlayback(context, selectorType) {
270
284
  }, [selectorType]);
271
285
  }
272
286
  /**
273
- * Navigates a browser page to the specified URL with site-appropriate wait conditions. The navigation strategy depends on the site's player implementation:
274
- *
275
- * - waitForNetworkIdle=true: Wait for network activity to settle, allowing up to 2 concurrent connections for 500ms. This ensures all JavaScript has loaded
276
- * and the player is fully initialized. Used for sites with complex async initialization.
277
- *
278
- * - waitForNetworkIdle=false: Return as soon as the page fires load event. Used for sites that have persistent connections or polling that would prevent
279
- * networkidle from ever completing.
280
- *
281
- * Navigation timeouts are handled gracefully - we log a warning but don't throw, since the video may have loaded successfully even if networkidle never
282
- * completed.
287
+ * Puts the page on the given URL the way the profile's strategy enters its site: through the strategy's own navigator when its provider declares one, and
288
+ * otherwise through a plain document load under the profile's wait preference. Every navigation on the tune path, the re-establishment path, and the recovery
289
+ * route comes through here, which is what lets a provider that cannot always load its guide by URL take over the route without any caller knowing.
283
290
  * @param page - The Puppeteer page object.
284
291
  * @param url - The URL to navigate to.
285
- * @param profile - The site profile containing navigation preferences.
292
+ * @param profile - The site profile whose strategy and wait preference select the route.
286
293
  */
287
294
  export async function navigateToPage(page, url, profile) {
288
- if (profile.waitForNetworkIdle) {
289
- try {
290
- // Wait for network activity to settle. This ensures complex JavaScript players have fully initialized. The networkidle2 strategy allows up to 2
291
- // concurrent requests, which handles sites with persistent connections for analytics.
292
- await page.goto(url, { timeout: CONFIG.streaming.navigationTimeout, waitUntil: "networkidle2" });
293
- }
294
- catch (error) {
295
- // Timeout errors during navigation are common and often non-fatal - the video may have loaded successfully even if some background requests never
296
- // completed. We log a warning and continue rather than throwing.
297
- if (error && (error.name === "TimeoutError")) {
298
- LOG.warn("Page navigation timed out after %sms for %s.", CONFIG.streaming.navigationTimeout, url);
299
- }
300
- else {
301
- // Non-timeout errors (network failure, invalid URL, etc.) should be propagated for retry handling.
302
- throw error;
303
- }
304
- }
305
- }
306
- else {
307
- // Simple navigation without waiting for network idle. Returns after the load event fires. Used for sites that would never reach networkidle due to
308
- // persistent connections, streaming data, or continuous polling.
309
- await page.goto(url);
295
+ const navigate = getStrategyNavigator(profile);
296
+ if (navigate) {
297
+ await navigate(page, url);
298
+ return;
310
299
  }
300
+ await loadDocument(page, url, { waitForNetworkIdle: profile.waitForNetworkIdle });
311
301
  }
312
302
  /**
313
303
  * Reloads the current page, mirroring navigateToPage's wait strategy. Two callers, one mechanism. An accepted embedded-player consent gate only creates the player
314
304
  * iframe on a fresh load, so a reload re-renders the page with consent persisted and the video resolves on the second pass. A guide that never rendered is the
315
- * other: the reload is what gives channel selection a fresh surface to read.
305
+ * other: the reload is what gives channel selection a fresh surface to read. A strategy that owns its route re-enters at the page's current URL rather than
306
+ * reloading it, because a reload requests that URL directly - the load the strategy exists to avoid.
316
307
  * @param page - The Puppeteer page object.
317
- * @param profile - The site profile, whose waitForNetworkIdle flag selects the reload wait condition.
308
+ * @param profile - The site profile, whose strategy and waitForNetworkIdle flag select the reload route and its wait condition.
318
309
  */
319
310
  async function reloadPage(page, profile) {
320
- const waitUntil = profile.waitForNetworkIdle ? "networkidle2" : "load";
321
- try {
322
- await page.reload({ timeout: CONFIG.streaming.navigationTimeout, waitUntil });
323
- }
324
- catch (error) {
325
- // A reload timeout is often non-fatal - the player may already be present even if some background requests never settled. Mirror navigateToPage: warn and
326
- // continue on timeout, propagate other errors.
327
- if (error && (error.name === "TimeoutError")) {
328
- LOG.warn("Page reload timed out after %sms.", CONFIG.streaming.navigationTimeout);
329
- }
330
- else {
331
- throw error;
332
- }
311
+ const navigate = getStrategyNavigator(profile);
312
+ if (navigate) {
313
+ await navigate(page, page.url());
314
+ return;
333
315
  }
316
+ await reloadDocument(page, { waitForNetworkIdle: profile.waitForNetworkIdle });
334
317
  }
335
318
  /**
336
319
  * Finds the appropriate context (frame or page) containing the video element. Some streaming sites embed their video player in an iframe, which creates a
@@ -344,53 +327,52 @@ async function reloadPage(page, profile) {
344
327
  * 5. Fall back to the main page if no iframe contains a video
345
328
  * @param page - The Puppeteer page object.
346
329
  * @param profile - The site profile indicating whether iframe handling is needed.
330
+ * @param clock - The clock the search's cadence and ceiling read; defaults to the system clock.
347
331
  * @returns The frame or page containing the video element.
348
332
  */
349
- export async function findVideoContext(page, profile) {
333
+ export async function findVideoContext(page, profile, clock = systemClock) {
350
334
  // For sites that don't use iframes (most common case), the video is directly in the main page document. Skip the iframe search.
351
335
  if (!profile.needsIframeHandling) {
352
336
  return page;
353
337
  }
354
338
  // Wait for an iframe element to appear in the page DOM. This ensures the site has created the embedded player container.
355
339
  await page.waitForSelector("iframe", { timeout: CONFIG.streaming.videoTimeout });
356
- // Poll for a video element to appear in any iframe. Complex embedded players (Brightcove, JW Player, etc.) load additional resources and scripts after the
357
- // iframe element appears, so the video may not be immediately available. We retry the search with brief pauses, using the configured delay as the overall
358
- // timeout ceiling. Polling with early exit avoids waiting the full delay when the video appears quickly.
359
- const deadline = Date.now() + CONFIG.playback.iframeInitDelay;
360
- let iframeSearchComplete = false;
340
+ /* Poll for a video element to appear in any iframe, through the project's poll policy: one scan of every frame is the read, the 200 ms cadence spaces the scans,
341
+ * and the configured iframe delay is the ceiling. Complex embedded players (Brightcove, JW Player, etc.) load additional resources and scripts after the iframe
342
+ * element appears, so the video may not be immediately available; a scan that finds one ends the poll straight away rather than waiting the full budget out. A
343
+ * scan that meets a terminated stream answers "aborted", which ends the poll exactly as a hit does and falls through to the main-page fallback below.
344
+ */
361
345
  let lastFrameCount = 0;
362
- while (!iframeSearchComplete && (Date.now() < deadline)) {
363
- const pageFrames = page.frames();
364
- lastFrameCount = pageFrames.length;
365
- for (const frame of pageFrames) {
366
- // Skip the main frame since we're looking for video in iframes, not the main page.
367
- if (frame === page.mainFrame()) {
368
- continue;
369
- }
370
- try {
371
- // Check if this frame contains a video element. We use a short timeout (2 seconds) to prevent a single hanging frame from consuming the polling budget.
372
- // eslint-disable-next-line no-await-in-loop
373
- const hasVideo = await evaluateWithAbort(frame, () => {
374
- return !!document.querySelector("video");
375
- }, undefined, 2000);
376
- if (hasVideo) {
377
- return frame;
346
+ const search = await pollUntil({ cadenceMs: 200, ceilingMs: CONFIG.playback.iframeInitDelay, clock, read: async () => {
347
+ const pageFrames = page.frames();
348
+ lastFrameCount = pageFrames.length;
349
+ for (const frame of pageFrames) {
350
+ // Skip the main frame since we're looking for video in iframes, not the main page.
351
+ if (frame === page.mainFrame()) {
352
+ continue;
378
353
  }
379
- }
380
- catch (error) {
381
- // AbortError means stream was terminated - stop polling immediately.
382
- if (error instanceof EvaluateAbortError) {
383
- iframeSearchComplete = true;
384
- break;
354
+ try {
355
+ // Check if this frame contains a video element. We use a short timeout (2 seconds) to prevent a single hanging frame from consuming the polling budget.
356
+ // eslint-disable-next-line no-await-in-loop
357
+ const hasVideo = await evaluateWithAbort(frame, () => {
358
+ return !!document.querySelector("video");
359
+ }, undefined, { clock, timeoutMs: 2000 });
360
+ if (hasVideo) {
361
+ return frame;
362
+ }
363
+ }
364
+ catch (error) {
365
+ // AbortError means stream was terminated - stop scanning immediately.
366
+ if (error instanceof EvaluateAbortError) {
367
+ return "aborted";
368
+ }
369
+ // Other errors (cross-origin, detached frame) - skip this frame and continue searching.
385
370
  }
386
- // Other errors (cross-origin, detached frame) - skip this frame and continue searching.
387
371
  }
388
- }
389
- // Brief pause before re-checking. 200ms intervals provide responsive polling without excessive CDP overhead.
390
- if (!iframeSearchComplete && (Date.now() < deadline)) {
391
- // eslint-disable-next-line no-await-in-loop
392
- await delay(200);
393
- }
372
+ return null;
373
+ }, until: (found) => found !== null });
374
+ if ((search.value !== null) && (search.value !== "aborted")) {
375
+ return search.value;
394
376
  }
395
377
  // No iframe contained a video, so fall back to the main page. This is a designed branch of the function's contract, not an error: it is reached transiently and
396
378
  // recoverably whenever the embedded player has not loaded yet - most commonly on a consent-gated site's first pass, where the player iframe is withheld until the
@@ -496,7 +478,17 @@ export async function waitForVideoReady(context, profile, signal) {
496
478
  * The styling:
497
479
  * - position: fixed - Removes the video from document flow and positions relative to viewport
498
480
  * - top: 0; left: 0; width: 100%; height: 100% - Fills the entire viewport
499
- * - zIndex: 999000 - Ensures the video appears above all other page content
481
+ * - margin: 0 - A negative margin shifts an anchored box, so the offsets above are the whole position
482
+ * - max-height: none; max-width: none - A stylesheet max bounds the box without ever contesting the sizes above, because a max is a different property and the
483
+ * cascade never puts them against each other: an author's max wins over an inline size at any priority, so an inline none is what keeps the box ours
484
+ * - transform: none - A transform moves the box after it is positioned: a player that centers its video with its own translate slides the full-viewport element
485
+ * off-center, and the capture then composites whichever corner of the viewport the video still covers
486
+ * - rotate: none; scale: none; translate: none - The independent transform properties move, turn, and resize the box exactly as a transform does, and clearing
487
+ * transform says nothing about them, so each one is cleared on its own
488
+ * - transition: none - A transition on transform would animate the clear rather than snapping it, leaving a verification sampled moments later reading a box
489
+ * still in motion
490
+ * - zIndex: 999000 on the video and, within each one's own stacking context, on every ancestor - a z-index only ranks within its nearest stacking context,
491
+ * so the ancestors are lifted to the same layer
500
492
  * - objectFit: contain - Maintains aspect ratio while fitting within the viewport
501
493
  * - background: black - Fills any letterbox/pillarbox areas with black
502
494
  * - cursor: none - Hides the mouse cursor for cleaner capture
@@ -515,15 +507,43 @@ export async function applyVideoStyles(context, selectorType, important = false)
515
507
  // blocked by the site's CSP. When important is true, we use setProperty with "important" priority to override site JavaScript that re-applies its own
516
508
  // styles after our basic assignment.
517
509
  const priority = useImportant ? "important" : "";
510
+ // The layer the video and its ancestors paint at. One value for both, because an ancestor lifted to any other tier would not carry the video with it.
511
+ const layer = "999000";
518
512
  video.style.setProperty("background", "black", priority);
519
513
  video.style.setProperty("cursor", "none", priority);
520
514
  video.style.setProperty("height", "100%", priority);
521
515
  video.style.setProperty("left", "0", priority);
516
+ video.style.setProperty("margin", "0", priority);
517
+ video.style.setProperty("max-height", "none", priority);
518
+ video.style.setProperty("max-width", "none", priority);
522
519
  video.style.setProperty("object-fit", "contain", priority);
523
520
  video.style.setProperty("position", "fixed", priority);
521
+ video.style.setProperty("rotate", "none", priority);
522
+ video.style.setProperty("scale", "none", priority);
524
523
  video.style.setProperty("top", "0", priority);
524
+ video.style.setProperty("transform", "none", priority);
525
+ video.style.setProperty("transition", "none", priority);
526
+ video.style.setProperty("translate", "none", priority);
525
527
  video.style.setProperty("width", "100%", priority);
526
- video.style.setProperty("z-index", "999000", priority);
528
+ video.style.setProperty("z-index", layer, priority);
529
+ /* A z-index ranks an element only inside its nearest stacking context, so a positioned ancestor with a modest z-index caps the video beneath any
530
+ * page element that outranks that ancestor - a site header ranked above the player's container covers the video's top edge even though the video
531
+ * carries the highest z-index on the page. Every ancestor is therefore lifted to the video's layer within its own context: it becomes positioned
532
+ * where it was static so a z-index applies to it, and takes the layer unless it already ranks at or above it, so the aggressive path's higher
533
+ * tiers are never lowered by a later standard pass. The ancestor's own box does not move; a static ancestor made relative does become the
534
+ * containing block for absolutely positioned descendants inside it. The walk stops at the body, where the root context decides the order.
535
+ */
536
+ let ancestor = video.parentElement;
537
+ while (ancestor && (ancestor !== document.body)) {
538
+ const computed = window.getComputedStyle(ancestor);
539
+ if (computed.position === "static") {
540
+ ancestor.style.setProperty("position", "relative", priority);
541
+ }
542
+ if (!(Number(computed.zIndex) >= Number(layer))) {
543
+ ancestor.style.setProperty("z-index", layer, priority);
544
+ }
545
+ ancestor = ancestor.parentElement;
546
+ }
527
547
  }, [selectorType, important]);
528
548
  }
529
549
  /**
@@ -593,8 +613,9 @@ export async function lockVolumeProperties(context, selectorType) {
593
613
  * @param context - The frame or page containing the video element.
594
614
  * @param profile - The site profile indicating fullscreen method.
595
615
  * @param selectorType - The video selector type for finding the element.
616
+ * @param clock - The clock the settle pause after a button click runs on.
596
617
  */
597
- export async function triggerFullscreen(page, context, profile, selectorType) {
618
+ export async function triggerFullscreen(page, context, profile, selectorType, clock) {
598
619
  // Try clicking a fullscreen button if configured. This fires before keyboard and API methods because clicking the site's own fullscreen control is the most
599
620
  // reliable approach - it uses the site's native mechanism. The element existence check guards against toggle buttons that have changed state or disappeared
600
621
  // (e.g., after the player is already maximized). Keyboard and API methods serve as fallbacks below.
@@ -604,7 +625,7 @@ export async function triggerFullscreen(page, context, profile, selectorType) {
604
625
  if (buttonExists) {
605
626
  await page.click(profile.fullscreenSelector);
606
627
  // Brief delay for the site's fullscreen animation to complete before subsequent checks.
607
- await delay(300);
628
+ await clock.delay(300);
608
629
  }
609
630
  }
610
631
  catch (error) {
@@ -639,16 +660,14 @@ export async function triggerFullscreen(page, context, profile, selectorType) {
639
660
  }
640
661
  }
641
662
  /**
642
- * Verifies that the video element is filling the viewport, indicating that fullscreen styling was successfully applied. This function checks the video element's
643
- * bounding rectangle against the viewport dimensions to determine if the video appears fullscreen.
644
- *
645
- * The verification allows for some tolerance because:
646
- * - The video may have letterboxing/pillarboxing due to aspect ratio differences
647
- * - Some browsers report slightly smaller dimensions due to scrollbars or UI chrome
648
- * - CSS rounding may cause small discrepancies
663
+ * Verifies that the video element is filling the viewport, indicating that fullscreen styling was successfully applied. The measurement is the part of the video's
664
+ * bounding rectangle that lands inside the viewport, which is what the capture composites. The raw box dimensions are the wrong instrument: a full-sized element
665
+ * that a site's own transform has moved off-center still reports its full width and height while showing only the slice that remains on screen.
649
666
  *
650
- * We require the video to fill at least 85% of the viewport in at least one dimension (the constraining dimension for aspect ratio) and at least 50% in the
651
- * other dimension to catch obviously broken cases.
667
+ * The styling hands the video the viewport as its box and lets object-fit render the content's own aspect inside it, so a letterboxed picture is something the
668
+ * box shows rather than a smaller box. Both axes are therefore asked the same question: a box that covers one of them and falls short on the other has been
669
+ * clamped or moved by the page, which is the defeat this exists to catch. The threshold sits below a full viewport as measurement slack rather than shape
670
+ * slack - a scrollbar or a strip of browser chrome the viewport metric counts, and CSS rounding at the box's edges.
652
671
  * @param context - The frame or page containing the video element.
653
672
  * @param selectorType - The video selector type for finding the element.
654
673
  * @returns True if the video appears to be fullscreen, false if it does not, or null if the check could not be performed (e.g. context destroyed).
@@ -663,15 +682,18 @@ export async function verifyFullscreen(context, selectorType) {
663
682
  const rect = video.getBoundingClientRect();
664
683
  const viewportWidth = window.innerWidth;
665
684
  const viewportHeight = window.innerHeight;
685
+ /* How much of the box lands inside the viewport along one axis: the overlap between the box's span and the viewport's, clamped at zero for a box that
686
+ * misses the viewport entirely. One helper serves both axes so the clip is expressed once, and it reads only the four values every rectangle carries.
687
+ */
688
+ const visibleExtent = (start, size, limit) => Math.max(0, Math.min(start + size, limit) - Math.max(start, 0));
666
689
  // Calculate how much of the viewport the video fills in each dimension.
667
- const widthRatio = rect.width / viewportWidth;
668
- const heightRatio = rect.height / viewportHeight;
669
- // The video should fill at least 85% in at least one dimension (accounting for aspect ratio letterboxing) and at least 50% in the other dimension (to
670
- // catch obviously broken cases where the video is tiny or off-screen).
671
- const fillsWidth = widthRatio >= 0.85;
672
- const fillsHeight = heightRatio >= 0.85;
673
- const minimumCoverage = (widthRatio >= 0.5) && (heightRatio >= 0.5);
674
- return (fillsWidth || fillsHeight) && minimumCoverage;
690
+ const widthRatio = visibleExtent(rect.left, rect.width, viewportWidth) / viewportWidth;
691
+ const heightRatio = visibleExtent(rect.top, rect.height, viewportHeight) / viewportHeight;
692
+ // The share of each axis the box has to cover. What it leaves is room for the measurement to be slightly off, never room for a box of a different shape.
693
+ const FILL_THRESHOLD = 0.85;
694
+ const fillsWidth = widthRatio >= FILL_THRESHOLD;
695
+ const fillsHeight = heightRatio >= FILL_THRESHOLD;
696
+ return fillsWidth && fillsHeight;
675
697
  }, [selectorType]);
676
698
  }
677
699
  catch (_error) {
@@ -703,15 +725,16 @@ async function isNativeFullscreenActive(context) {
703
725
  * dispatches real pointer events that Chrome recognizes as user gestures. The click may toggle play/pause on some players - the health monitor handles
704
726
  * re-starting playback if needed.
705
727
  *
706
- * Note: page.mouse.click() uses page-level coordinates, while getBoundingClientRect() inside an iframe returns iframe-relative coordinates. The iframe-embedded
707
- * fullscreenApi profiles (the embeddedPlayer family) set both useRequestFullscreen and needsIframeHandling, so for those tunes the computed point can be offset
708
- * from the real video position. That is tolerated here: the click exists only to register a trusted user gesture for transient activation, which any in-page
728
+ * Note: page.mouse.click() uses page-level coordinates, while getBoundingClientRect() inside an iframe returns iframe-relative coordinates. A profile that turns
729
+ * the native call on for an iframe-embedded player carries both useRequestFullscreen and needsIframeHandling, so for those tunes the computed point can be
730
+ * offset from the real video position. That is tolerated here: the click exists only to register a trusted user gesture for transient activation, which any in-page
709
731
  * click satisfies - it does not need to land precisely on the video - and a missed activation is recovered by the health monitor.
710
732
  * @param page - The Puppeteer page object.
711
733
  * @param context - The frame or page containing the video element.
712
734
  * @param selectorType - The video selector type for finding the element.
735
+ * @param clock - The clock the pause after the click runs on.
713
736
  */
714
- async function clickVideoForActivation(page, context, selectorType) {
737
+ async function clickVideoForActivation(page, context, selectorType, clock) {
715
738
  try {
716
739
  const coords = await evaluateWithAbort(context, (type) => {
717
740
  const video = window.__prismcastSelectVideo?.(type) ?? null;
@@ -723,7 +746,7 @@ async function clickVideoForActivation(page, context, selectorType) {
723
746
  }, [selectorType]);
724
747
  if (coords) {
725
748
  await page.mouse.click(coords.x, coords.y);
726
- await delay(100);
749
+ await clock.delay(100);
727
750
  }
728
751
  }
729
752
  catch {
@@ -757,9 +780,17 @@ async function applyAggressiveFullscreen(context, selectorType) {
757
780
  "cursor: none !important",
758
781
  "height: 100% !important",
759
782
  "left: 0 !important",
783
+ "margin: 0 !important",
784
+ "max-height: none !important",
785
+ "max-width: none !important",
760
786
  "object-fit: contain !important",
761
787
  "position: fixed !important",
788
+ "rotate: none !important",
789
+ "scale: none !important",
762
790
  "top: 0 !important",
791
+ "transform: none !important",
792
+ "transition: none !important",
793
+ "translate: none !important",
763
794
  "width: 100% !important",
764
795
  "z-index: 999999 !important"
765
796
  ].join("; ");
@@ -772,14 +803,25 @@ async function applyAggressiveFullscreen(context, selectorType) {
772
803
  }
773
804
  }
774
805
  }
775
- // Expand parent containers up the DOM tree. Sites often wrap videos in multiple container divs with constrained dimensions. We need to break out of these.
806
+ /* Expand parent containers up the DOM tree. Sites often wrap videos in multiple container divs with constrained dimensions. We need to break out of these.
807
+ * Each container's transform is cleared alongside its dimensions because a transformed element becomes the containing block for fixed-position descendants
808
+ * inside it: the video would anchor to that ancestor's box rather than to the viewport, and no amount of styling on the video itself corrects that. The
809
+ * independent transform properties are cleared beside it because each one creates that containing block on its own, and clearing transform does not reach
810
+ * them. The paired transition clear makes the correction snap, so a verification sampled moments later reads the settled layout rather than a box still in
811
+ * motion.
812
+ */
776
813
  let container = video.parentElement;
777
814
  while (container && (container !== document.body)) {
778
815
  container.style.cssText = [
779
816
  "height: 100% !important",
780
817
  "left: 0 !important",
781
818
  "position: fixed !important",
819
+ "rotate: none !important",
820
+ "scale: none !important",
782
821
  "top: 0 !important",
822
+ "transform: none !important",
823
+ "transition: none !important",
824
+ "translate: none !important",
783
825
  "width: 100% !important",
784
826
  "z-index: 999998 !important"
785
827
  ].join("; ");
@@ -789,16 +831,18 @@ async function applyAggressiveFullscreen(context, selectorType) {
789
831
  }
790
832
  /**
791
833
  * Ensures the video is displayed fullscreen with verification and retry logic. For profiles that use the native Fullscreen API, this serializes through a
792
- * promise-chain mutex so only one tab activates fullscreen at a time - Chrome requires the tab to be in the foreground for requestFullscreen() to succeed, and
793
- * concurrent tabs would steal foreground from each other. When skipNativeFullscreen is true (monitor recovery), the mutex is bypassed entirely.
834
+ * promise-chain mutex so only one tab activates fullscreen at a time - Chrome grants the API to the tab its window has selected, and concurrent tabs would take
835
+ * the selection from each other. When skipNativeFullscreen is true (monitor recovery), the mutex is bypassed entirely.
794
836
  * @param page - The Puppeteer page object for keyboard input.
795
837
  * @param context - The frame or page containing the video element.
796
838
  * @param profile - The site profile indicating fullscreen method.
797
839
  * @param selectorType - The video selector type for finding the element.
798
840
  * @param skipNativeFullscreen - When true, skips Fullscreen API-specific actions (click-for-activation, native fullscreen verification, API retries). CSS styling
799
841
  * and keyboard shortcuts still run. Used during monitor recovery where user activation is unavailable and click-for-activation can interfere with playback.
842
+ * @param deps - The injected tab-selection collaborator; defaults to defaultFullscreenDeps. Threaded so a test observes the selection a sequence takes without a
843
+ * live Chrome, the same collaborator-injection boundary CreatePageWithCaptureDeps uses in streaming/setup.ts.
800
844
  */
801
- export async function ensureFullscreen(page, context, profile, selectorType, skipNativeFullscreen) {
845
+ export async function ensureFullscreen(page, context, profile, selectorType, skipNativeFullscreen, deps = defaultFullscreenDeps) {
802
846
  const useNativeFullscreen = profile.useRequestFullscreen && !skipNativeFullscreen;
803
847
  // Inject a persistent stylesheet to hide site-specific overlay elements (e.g., player control bars, toolbars) that would otherwise appear in the captured stream.
804
848
  // The style tag persists for the page lifetime. Duplicate injections from recovery calls are harmless because the reapplied rules produce the same computed
@@ -809,14 +853,14 @@ export async function ensureFullscreen(page, context, profile, selectorType, ski
809
853
  }
810
854
  // CSS-only path (monitor recovery or profiles without native fullscreen). No serialization needed - CSS styling works fine from background tabs.
811
855
  if (!useNativeFullscreen) {
812
- return runFullscreenSequence(page, context, profile, selectorType, false);
856
+ return runFullscreenSequence(page, context, profile, selectorType, false, deps.clock);
813
857
  }
814
- // Native fullscreen path. Serialize through the fullscreen queue so only one tab at a time goes through bringToFront -> requestFullscreen -> verify. Without
815
- // this, concurrent streams steal foreground from each other and all fullscreen attempts silently fail.
858
+ // Native fullscreen path. Serialize through the fullscreen queue so only one tab at a time goes through select -> requestFullscreen -> verify. Without this,
859
+ // concurrent streams take the selection from each other and all fullscreen attempts silently fail.
816
860
  const FULLSCREEN_QUEUE_TIMEOUT = 10000;
817
861
  fullscreenQueue = fullscreenQueue.then(async () => {
818
862
  try {
819
- await waitWithTimeout(runFullscreenSequence(page, context, profile, selectorType, true), FULLSCREEN_QUEUE_TIMEOUT, new Error("Fullscreen queue entry timed out."));
863
+ await waitWithTimeout(deps.withTabSelected(page, async () => runFullscreenSequence(page, context, profile, selectorType, true, deps.clock), { ceilingMs: FULLSCREEN_SELECTION_CEILING_MS }), FULLSCREEN_QUEUE_TIMEOUT, { clock: deps.clock, reason: new Error("Fullscreen queue entry timed out.") });
820
864
  }
821
865
  catch (error) {
822
866
  LOG.warn("Fullscreen queue entry failed: %s.", formatError(error));
@@ -828,9 +872,9 @@ export async function ensureFullscreen(page, context, profile, selectorType, ski
828
872
  * Runs the fullscreen sequence with verification and retry logic. This function orchestrates the fullscreen process:
829
873
  *
830
874
  * 1. Initial attempt: Apply CSS styles and trigger fullscreen API
831
- * 2. Verify: Check video dimensions and, for fullscreenApi profiles, confirm document.fullscreenElement is set
875
+ * 2. Verify: Check video dimensions and, when the native Fullscreen API is in use, confirm document.fullscreenElement is set
832
876
  * 3. Simple retry: If verification fails, click the video for user activation and retry (the Fullscreen API requires a recent user gesture)
833
- * 4. Escalate: If simple retries fail, apply aggressive fullscreen techniques with a final Fullscreen API re-trigger
877
+ * 4. Escalate: If simple retries fail, apply aggressive fullscreen styling, with a final Fullscreen API re-trigger when the native call is in use
834
878
  *
835
879
  * The retry approach handles both timing issues (page still initializing) and user activation issues (requestFullscreen requires a recent user gesture).
836
880
  * On retry, clicking the video provides fresh activation so the subsequent requestFullscreen() call can succeed. Escalation to aggressive techniques is a
@@ -839,35 +883,32 @@ export async function ensureFullscreen(page, context, profile, selectorType, ski
839
883
  * @param context - The frame or page containing the video element.
840
884
  * @param profile - The site profile indicating fullscreen method.
841
885
  * @param selectorType - The video selector type for finding the element.
842
- * @param useNativeFullscreen - Whether to use the native Fullscreen API (bringToFront, click-for-activation, API verification).
886
+ * @param useNativeFullscreen - Whether to use the native Fullscreen API (click-for-activation, API verification). The caller selects the tab for the whole
887
+ * sequence when this is set, because Chrome grants the API to the selected tab.
888
+ * @param clock - The clock every settle and retry pause in the ladder runs on.
843
889
  */
844
- async function runFullscreenSequence(page, context, profile, selectorType, useNativeFullscreen) {
890
+ async function runFullscreenSequence(page, context, profile, selectorType, useNativeFullscreen, clock) {
845
891
  // Configuration for retry behavior. These values are tuned for typical page load timing.
846
892
  const maxSimpleRetries = 3;
847
893
  const retryDelay = 500;
848
894
  const verifyDelay = 200;
849
895
  for (let attempt = 1; attempt <= maxSimpleRetries; attempt++) {
850
- // On retry for fullscreenApi profiles, click the video to provide fresh user activation. The Fullscreen API requires a recent user gesture (transient
896
+ // On retry when the native Fullscreen API is in use, click the video to provide fresh user activation. The Fullscreen API requires a recent user gesture (transient
851
897
  // activation) to succeed - without it, requestFullscreen() is silently rejected. The initial attempt relies on activation from page navigation, but retries
852
898
  // need an explicit click.
853
899
  if ((attempt > 1) && useNativeFullscreen) {
854
900
  // eslint-disable-next-line no-await-in-loop
855
- await clickVideoForActivation(page, context, selectorType);
901
+ await clickVideoForActivation(page, context, selectorType, clock);
856
902
  }
857
903
  // Apply CSS styles to make the video fill the viewport.
858
904
  // eslint-disable-next-line no-await-in-loop
859
905
  await applyVideoStyles(context, selectorType);
860
- // Bring the tab to the foreground before requesting fullscreen. Chrome requires the tab to be focused for requestFullscreen() to succeed.
861
- if (useNativeFullscreen) {
862
- // eslint-disable-next-line no-await-in-loop
863
- await page.bringToFront();
864
- }
865
906
  // Trigger native fullscreen using the site's preferred method (keyboard shortcut or JavaScript API).
866
907
  // eslint-disable-next-line no-await-in-loop
867
- await triggerFullscreen(page, context, profile, selectorType);
908
+ await triggerFullscreen(page, context, profile, selectorType, clock);
868
909
  // Wait a moment for fullscreen to take effect. The browser needs time to process the style changes and any fullscreen API calls.
869
910
  // eslint-disable-next-line no-await-in-loop
870
- await delay(verifyDelay);
911
+ await clock.delay(verifyDelay);
871
912
  // Verify that fullscreen succeeded by checking video dimensions.
872
913
  // eslint-disable-next-line no-await-in-loop
873
914
  const isFullscreen = await verifyFullscreen(context, selectorType);
@@ -881,7 +922,7 @@ async function runFullscreenSequence(page, context, profile, selectorType, useNa
881
922
  if (attempt < maxSimpleRetries) {
882
923
  LOG.debug("browser:video", "Native fullscreen not active (attempt %s/%s). Retrying with user activation.", attempt, maxSimpleRetries);
883
924
  // eslint-disable-next-line no-await-in-loop
884
- await delay(retryDelay);
925
+ await clock.delay(retryDelay);
885
926
  }
886
927
  continue;
887
928
  }
@@ -895,34 +936,28 @@ async function runFullscreenSequence(page, context, profile, selectorType, useNa
895
936
  if (attempt < maxSimpleRetries) {
896
937
  LOG.debug("browser:video", "Fullscreen verification failed (attempt %s/%s). Retrying after %sms.", attempt, maxSimpleRetries, retryDelay);
897
938
  // eslint-disable-next-line no-await-in-loop
898
- await delay(retryDelay);
939
+ await clock.delay(retryDelay);
899
940
  }
900
941
  }
901
942
  // All simple retries exhausted. Escalate to aggressive fullscreen techniques.
902
943
  LOG.warn("Fullscreen failed after %s attempts. Escalating to aggressive fullscreen.", maxSimpleRetries);
903
- // Click for user activation before the aggressive attempt for fullscreenApi profiles.
944
+ // Click for user activation before the aggressive attempt when the native Fullscreen API is in use.
904
945
  if (useNativeFullscreen) {
905
- await clickVideoForActivation(page, context, selectorType);
946
+ await clickVideoForActivation(page, context, selectorType, clock);
906
947
  }
907
948
  await applyAggressiveFullscreen(context, selectorType);
908
- // Also try keyboard "f" as a last resort if the profile doesn't already use it. Many players respond to the "f" key for fullscreen.
909
- if (!profile.fullscreenKey) {
910
- await page.keyboard.type("f");
911
- }
912
- // Re-trigger the Fullscreen API after aggressive styling - the aggressive CSS ensures the video fills the viewport, and the API call hides site UI. Bring the
913
- // tab to foreground first, since other tabs may have stolen focus while we were escalating.
949
+ // Re-trigger the Fullscreen API after aggressive styling - the aggressive CSS ensures the video fills the viewport, and the API call hides site UI.
914
950
  if (useNativeFullscreen) {
915
- await page.bringToFront();
916
- await triggerFullscreen(page, context, profile, selectorType);
951
+ await triggerFullscreen(page, context, profile, selectorType, clock);
917
952
  }
918
953
  // Final verification after aggressive techniques.
919
- await delay(verifyDelay);
954
+ await clock.delay(verifyDelay);
920
955
  const finalCheck = await verifyFullscreen(context, selectorType);
921
956
  if (!finalCheck) {
922
957
  LOG.warn("Fullscreen could not be verified even after aggressive techniques. Video may not fill viewport.");
923
958
  return;
924
959
  }
925
- // For fullscreenApi profiles, also verify native fullscreen is active after escalation.
960
+ // When the native Fullscreen API is in use, also verify native fullscreen is active after escalation.
926
961
  if (useNativeFullscreen) {
927
962
  const nativeActive = await isNativeFullscreenActive(context);
928
963
  if (!nativeActive) {
@@ -959,6 +994,7 @@ async function runFullscreenSequence(page, context, profile, selectorType, useNa
959
994
  * @param options - Optional recovery configuration. Omit for initial tune (full fullscreen behavior, level 1).
960
995
  */
961
996
  export async function ensurePlayback(page, context, profile, options) {
997
+ const clock = options?.clock ?? systemClock;
962
998
  const selectorType = buildVideoSelectorType(profile);
963
999
  const level = options?.recoveryLevel ?? 1;
964
1000
  // LEVEL 2: Reload video source. This forces the player to completely reinitialize by clearing and restoring the src attribute. This can fix players stuck in
@@ -967,7 +1003,7 @@ export async function ensurePlayback(page, context, profile, options) {
967
1003
  try {
968
1004
  await reloadVideoSource(context, selectorType);
969
1005
  // Wait for the source to reload. The player needs time to parse the manifest, establish connections, and buffer initial data.
970
- await delay(CONFIG.playback.sourceReloadDelay);
1006
+ await clock.delay(CONFIG.playback.sourceReloadDelay);
971
1007
  }
972
1008
  catch (_error) {
973
1009
  // Source reload errors are non-fatal - we continue with basic recovery actions.
@@ -983,13 +1019,16 @@ export async function ensurePlayback(page, context, profile, options) {
983
1019
  }
984
1020
  // Ensure fullscreen with verification and retry. This applies CSS styling, triggers native fullscreen, verifies the video fills the viewport, and retries with
985
1021
  // escalating techniques if needed.
986
- await ensureFullscreen(page, context, profile, selectorType, options?.skipNativeFullscreen);
1022
+ /* The default path hands the ladder the shared collaborator const and allocates nothing; a call that carries its own clock composes one deps object over
1023
+ * that const for this call alone, so the module default stays the object every other tune reads.
1024
+ */
1025
+ await ensureFullscreen(page, context, profile, selectorType, options?.skipNativeFullscreen, options?.clock ? { ...defaultFullscreenDeps, clock: options.clock } : defaultFullscreenDeps);
987
1026
  // Apply volume locking if the profile requires it. This prevents the site from muting the video after we've set volume.
988
1027
  if (profile.lockVolumeProperties) {
989
1028
  await lockVolumeProperties(context, selectorType);
990
1029
  }
991
1030
  }
992
- const defaultVideoTuneDeps = { classifyBlockedPage, getProvidersForDomain, selectChannel, startOverlayHandling };
1031
+ const defaultVideoTuneDeps = { classifyBlockedPage, clock: systemClock, getProvidersForDomain, selectChannel, startOverlayHandling };
993
1032
  /**
994
1033
  * Diagnoses a failed tune by classifying the still-open page, which holds the evidence of why the tune failed. A confirmed provider authentication wall marks the
995
1034
  * domain needs-sign-in and replaces the generic failure with an actionable error; a wall on a domain with no registered provider is reported without marking (there
@@ -1048,7 +1087,7 @@ async function diagnoseBlockedTune(page, requestedUrl, originalError, deps) {
1048
1087
  */
1049
1088
  async function withOverlayGuard(page, profile, phase, deps, run) {
1050
1089
  const controller = new AbortController();
1051
- void deps.startOverlayHandling(page, profile, { phase, signal: controller.signal });
1090
+ void deps.startOverlayHandling(page, profile, { clock: deps.clock, phase, signal: controller.signal });
1052
1091
  try {
1053
1092
  return await run(() => { controller.abort(); });
1054
1093
  }
@@ -1073,7 +1112,7 @@ async function withOverlayGuard(page, profile, phase, deps, run) {
1073
1112
  * @returns The video context (frame or page) for subsequent monitoring, and a directTune flag when the channel was tuned via API interception.
1074
1113
  */
1075
1114
  export async function initializePlayback(page, profile, options = {}, deps = defaultVideoTuneDeps) {
1076
- const elapsed = startTimer();
1115
+ const elapsed = startTimer(deps.clock);
1077
1116
  const { persistResolution, requestedUrl, skipChannelSelection = false } = options;
1078
1117
  // Mute any existing video elements to suppress wrong-channel audio during tuning. On SPA-based providers (Hulu, Fox, USA Network, etc.), a default livestream
1079
1118
  // auto-plays when the page loads. Since the capture pipeline is already running, this audio bleeds into the stream until channel selection completes and
@@ -1088,7 +1127,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1088
1127
  // since the URL already targets the correct channel.
1089
1128
  let directTune = false;
1090
1129
  if (!skipChannelSelection) {
1091
- let channelResult = await deps.selectChannel(page, profile, { persistResolution });
1130
+ let channelResult = await deps.selectChannel(page, profile, { clock: deps.clock, persistResolution });
1092
1131
  if (!channelResult.success) {
1093
1132
  /* The guide surface never rendered, so there was nothing for the strategy to read. That is the transient class - lazy tiles that never populated, an SPA
1094
1133
  * shell that did not come up, a stale overlay left across the grid - and a reload clears all of it at once, more thoroughly than dismissing anything
@@ -1105,7 +1144,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1105
1144
  // The reloaded page auto-plays its default channel again, and capture is live for the whole tune, so that audio would bleed into the recording until the
1106
1145
  // second selection lands. The re-establishment path mutes after its own reload for the same reason.
1107
1146
  await muteExistingVideos(page);
1108
- channelResult = await deps.selectChannel(page, profile, { persistResolution });
1147
+ channelResult = await deps.selectChannel(page, profile, { clock: deps.clock, persistResolution });
1109
1148
  }
1110
1149
  if (!channelResult.success) {
1111
1150
  const selectionError = new Error("Channel selection failed: " + (channelResult.reason ?? "Unknown reason."));
@@ -1128,7 +1167,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1128
1167
  // rejection unchanged.
1129
1168
  let context;
1130
1169
  try {
1131
- context = await findVideoContext(page, profile);
1170
+ context = await findVideoContext(page, profile, deps.clock);
1132
1171
  }
1133
1172
  catch (contextError) {
1134
1173
  if (requestedUrl !== undefined) {
@@ -1168,6 +1207,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1168
1207
  // Abandons the in-flight video wait when an embed gate is accepted, so the superseded wait rejects silently instead of logging a misleading readiness timeout.
1169
1208
  const waitController = new AbortController();
1170
1209
  void deps.startOverlayHandling(page, profile, {
1210
+ clock: deps.clock,
1171
1211
  onEmbedGateAccepted: () => {
1172
1212
  embedGate.resolve("gate");
1173
1213
  },
@@ -1191,7 +1231,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1191
1231
  // structurally impossible while keeping cookie rejection and modal dismissal live. A consent overlay that genuinely persists past the reload falls through to
1192
1232
  // the detect-and-guide path below.
1193
1233
  context = await withOverlayGuard(page, profile, "postGateReload", deps, async () => {
1194
- const reloadedContext = await findVideoContext(page, profile);
1234
+ const reloadedContext = await findVideoContext(page, profile, deps.clock);
1195
1235
  await waitForVideoReady(reloadedContext, profile);
1196
1236
  return reloadedContext;
1197
1237
  });
@@ -1212,7 +1252,7 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1212
1252
  }
1213
1253
  LOG.debug("timing:tune", "Video ready. (+%sms)", elapsed());
1214
1254
  // Ensure playback is started, unmuted, and fullscreen. This applies CSS styling, triggers native fullscreen, and enforces volume settings.
1215
- await ensurePlayback(page, context, profile);
1255
+ await ensurePlayback(page, context, profile, { clock: deps.clock });
1216
1256
  LOG.debug("timing:tune", "Playback ensured. (+%sms)", elapsed());
1217
1257
  return { context, directTune };
1218
1258
  }
@@ -1238,10 +1278,11 @@ export async function initializePlayback(page, profile, options = {}, deps = def
1238
1278
  * @param page - The Puppeteer page object.
1239
1279
  * @param url - The URL to navigate to.
1240
1280
  * @param profile - The site profile containing all behavior flags.
1281
+ * @param clock - The clock this tune's timing lines and every collaborator it composes run on; defaults to the system clock.
1241
1282
  * @returns The video context (frame or page) for subsequent monitoring, and a directTune flag when the channel was tuned via API interception.
1242
1283
  */
1243
- export async function tuneToChannel(page, url, profile) {
1244
- const tuneElapsed = startTimer();
1284
+ export async function tuneToChannel(page, url, profile, clock = systemClock) {
1285
+ const tuneElapsed = startTimer(clock);
1245
1286
  // Check for a direct watch URL. If available, navigate directly to it and skip channel selection, avoiding guide page navigation entirely. On failure, hand the
1246
1287
  // cause to the cache coordinator - which keeps the entry when the failure describes a dead page rather than a bad URL - and fall through to the normal
1247
1288
  // guide-based flow either way.
@@ -1251,7 +1292,10 @@ export async function tuneToChannel(page, url, profile) {
1251
1292
  LOG.debug("timing:tune", "Using cached direct URL for %s.", profile.channelSelector ?? "unknown");
1252
1293
  await navigateToPage(page, cachedUrl, profile);
1253
1294
  LOG.debug("timing:tune", "Direct URL navigation complete. (+%sms)", tuneElapsed());
1254
- const result = await initializePlayback(page, profile, { skipChannelSelection: true });
1295
+ /* The deps object is composed per tune only here - on a level-3 recovery, or under a test - because this is the one path that can be handed a clock other
1296
+ * than the system's. The module default stays the shared const every other tune reads.
1297
+ */
1298
+ const result = await initializePlayback(page, profile, { skipChannelSelection: true }, { ...defaultVideoTuneDeps, clock });
1255
1299
  LOG.debug("timing:tune", "Tune complete (cached). Total: %sms.", tuneElapsed());
1256
1300
  return result;
1257
1301
  }
@@ -1263,10 +1307,10 @@ export async function tuneToChannel(page, url, profile) {
1263
1307
  // Normal flow: navigate to the guide page URL and perform full channel selection.
1264
1308
  await navigateToPage(page, url, profile);
1265
1309
  LOG.debug("timing:tune", "Navigation complete. (+%sms)", tuneElapsed());
1266
- // Perform all post-navigation initialization: channel selection, video context resolution, click to play, video readiness, and fullscreen. The guide URL rides
1310
+ // Perform all post-navigation initialization: channel selection, video context resolution, click to play, video readiness, and fullscreen. The guide URL is carried
1267
1311
  // along so a failed tune can diagnose the blocked page; the cached-direct attempt above deliberately does not pass it, since its failure is swallowed and retried
1268
1312
  // through this authoritative path.
1269
- const result = await initializePlayback(page, profile, { requestedUrl: url });
1313
+ const result = await initializePlayback(page, profile, { requestedUrl: url }, { ...defaultVideoTuneDeps, clock });
1270
1314
  LOG.debug("timing:tune", "Tune complete. Total: %sms.", tuneElapsed());
1271
1315
  return result;
1272
1316
  }