@bnhf/prismcast 1.3.4-2026.2.19
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.
- package/LICENSE.md +7 -0
- package/README.md +347 -0
- package/bin/prismcast +6 -0
- package/dist/app.d.ts +6 -0
- package/dist/app.js +315 -0
- package/dist/app.js.map +1 -0
- package/dist/browser/cdp.d.ts +38 -0
- package/dist/browser/cdp.js +155 -0
- package/dist/browser/cdp.js.map +1 -0
- package/dist/browser/channelSelection.d.ts +65 -0
- package/dist/browser/channelSelection.js +202 -0
- package/dist/browser/channelSelection.js.map +1 -0
- package/dist/browser/display.d.ts +34 -0
- package/dist/browser/display.js +54 -0
- package/dist/browser/display.js.map +1 -0
- package/dist/browser/index.d.ts +205 -0
- package/dist/browser/index.js +1205 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/tuning/fox.d.ts +2 -0
- package/dist/browser/tuning/fox.js +83 -0
- package/dist/browser/tuning/fox.js.map +1 -0
- package/dist/browser/tuning/hbo.d.ts +2 -0
- package/dist/browser/tuning/hbo.js +237 -0
- package/dist/browser/tuning/hbo.js.map +1 -0
- package/dist/browser/tuning/hulu.d.ts +2 -0
- package/dist/browser/tuning/hulu.js +550 -0
- package/dist/browser/tuning/hulu.js.map +1 -0
- package/dist/browser/tuning/sling.d.ts +2 -0
- package/dist/browser/tuning/sling.js +518 -0
- package/dist/browser/tuning/sling.js.map +1 -0
- package/dist/browser/tuning/thumbnailRow.d.ts +2 -0
- package/dist/browser/tuning/thumbnailRow.js +108 -0
- package/dist/browser/tuning/thumbnailRow.js.map +1 -0
- package/dist/browser/tuning/tileClick.d.ts +2 -0
- package/dist/browser/tuning/tileClick.js +103 -0
- package/dist/browser/tuning/tileClick.js.map +1 -0
- package/dist/browser/tuning/youtubeTv.d.ts +2 -0
- package/dist/browser/tuning/youtubeTv.js +182 -0
- package/dist/browser/tuning/youtubeTv.js.map +1 -0
- package/dist/browser/video.d.ts +289 -0
- package/dist/browser/video.js +996 -0
- package/dist/browser/video.js.map +1 -0
- package/dist/channels/index.d.ts +3 -0
- package/dist/channels/index.js +392 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/config/index.d.ts +53 -0
- package/dist/config/index.js +233 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/presets.d.ts +98 -0
- package/dist/config/presets.js +241 -0
- package/dist/config/presets.js.map +1 -0
- package/dist/config/profiles.d.ts +79 -0
- package/dist/config/profiles.js +245 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/providers.d.ts +120 -0
- package/dist/config/providers.js +450 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/sites.d.ts +22 -0
- package/dist/config/sites.js +377 -0
- package/dist/config/sites.js.map +1 -0
- package/dist/config/userChannels.d.ts +178 -0
- package/dist/config/userChannels.js +543 -0
- package/dist/config/userChannels.js.map +1 -0
- package/dist/config/userConfig.d.ts +235 -0
- package/dist/config/userConfig.js +913 -0
- package/dist/config/userConfig.js.map +1 -0
- package/dist/hdhr/channelMap.d.ts +21 -0
- package/dist/hdhr/channelMap.js +82 -0
- package/dist/hdhr/channelMap.js.map +1 -0
- package/dist/hdhr/deviceId.d.ts +11 -0
- package/dist/hdhr/deviceId.js +84 -0
- package/dist/hdhr/deviceId.js.map +1 -0
- package/dist/hdhr/discover.d.ts +6 -0
- package/dist/hdhr/discover.js +155 -0
- package/dist/hdhr/discover.js.map +1 -0
- package/dist/hdhr/index.d.ts +9 -0
- package/dist/hdhr/index.js +87 -0
- package/dist/hdhr/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/assets.d.ts +6 -0
- package/dist/routes/assets.js +79 -0
- package/dist/routes/assets.js.map +1 -0
- package/dist/routes/auth.d.ts +6 -0
- package/dist/routes/auth.js +77 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/channels.d.ts +6 -0
- package/dist/routes/channels.js +40 -0
- package/dist/routes/channels.js.map +1 -0
- package/dist/routes/components.d.ts +138 -0
- package/dist/routes/components.js +210 -0
- package/dist/routes/components.js.map +1 -0
- package/dist/routes/config.d.ts +72 -0
- package/dist/routes/config.js +1977 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/debug.d.ts +6 -0
- package/dist/routes/debug.js +274 -0
- package/dist/routes/debug.js.map +1 -0
- package/dist/routes/health.d.ts +6 -0
- package/dist/routes/health.js +85 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/hls.d.ts +6 -0
- package/dist/routes/hls.js +25 -0
- package/dist/routes/hls.js.map +1 -0
- package/dist/routes/index.d.ts +19 -0
- package/dist/routes/index.js +49 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/logs.d.ts +6 -0
- package/dist/routes/logs.js +164 -0
- package/dist/routes/logs.js.map +1 -0
- package/dist/routes/mpegts.d.ts +6 -0
- package/dist/routes/mpegts.js +19 -0
- package/dist/routes/mpegts.js.map +1 -0
- package/dist/routes/play.d.ts +6 -0
- package/dist/routes/play.js +18 -0
- package/dist/routes/play.js.map +1 -0
- package/dist/routes/playlist.d.ts +36 -0
- package/dist/routes/playlist.js +134 -0
- package/dist/routes/playlist.js.map +1 -0
- package/dist/routes/root.d.ts +6 -0
- package/dist/routes/root.js +2920 -0
- package/dist/routes/root.js.map +1 -0
- package/dist/routes/streams.d.ts +6 -0
- package/dist/routes/streams.js +88 -0
- package/dist/routes/streams.js.map +1 -0
- package/dist/routes/theme.d.ts +15 -0
- package/dist/routes/theme.js +275 -0
- package/dist/routes/theme.js.map +1 -0
- package/dist/routes/ui.d.ts +56 -0
- package/dist/routes/ui.js +354 -0
- package/dist/routes/ui.js.map +1 -0
- package/dist/service/commands.d.ts +41 -0
- package/dist/service/commands.js +391 -0
- package/dist/service/commands.js.map +1 -0
- package/dist/service/generators.d.ts +33 -0
- package/dist/service/generators.js +432 -0
- package/dist/service/generators.js.map +1 -0
- package/dist/service/index.d.ts +2 -0
- package/dist/service/index.js +7 -0
- package/dist/service/index.js.map +1 -0
- package/dist/streaming/clients.d.ts +48 -0
- package/dist/streaming/clients.js +114 -0
- package/dist/streaming/clients.js.map +1 -0
- package/dist/streaming/fmp4Segmenter.d.ts +61 -0
- package/dist/streaming/fmp4Segmenter.js +461 -0
- package/dist/streaming/fmp4Segmenter.js.map +1 -0
- package/dist/streaming/hls.d.ts +120 -0
- package/dist/streaming/hls.js +722 -0
- package/dist/streaming/hls.js.map +1 -0
- package/dist/streaming/hlsSegments.d.ts +54 -0
- package/dist/streaming/hlsSegments.js +162 -0
- package/dist/streaming/hlsSegments.js.map +1 -0
- package/dist/streaming/lifecycle.d.ts +33 -0
- package/dist/streaming/lifecycle.js +185 -0
- package/dist/streaming/lifecycle.js.map +1 -0
- package/dist/streaming/monitor.d.ts +74 -0
- package/dist/streaming/monitor.js +1310 -0
- package/dist/streaming/monitor.js.map +1 -0
- package/dist/streaming/mp4Parser.d.ts +74 -0
- package/dist/streaming/mp4Parser.js +566 -0
- package/dist/streaming/mp4Parser.js.map +1 -0
- package/dist/streaming/mpegts.d.ts +14 -0
- package/dist/streaming/mpegts.js +248 -0
- package/dist/streaming/mpegts.js.map +1 -0
- package/dist/streaming/registry.d.ts +119 -0
- package/dist/streaming/registry.js +127 -0
- package/dist/streaming/registry.js.map +1 -0
- package/dist/streaming/setup.d.ts +135 -0
- package/dist/streaming/setup.js +670 -0
- package/dist/streaming/setup.js.map +1 -0
- package/dist/streaming/showInfo.d.ts +30 -0
- package/dist/streaming/showInfo.js +362 -0
- package/dist/streaming/showInfo.js.map +1 -0
- package/dist/streaming/statusEmitter.d.ts +125 -0
- package/dist/streaming/statusEmitter.js +139 -0
- package/dist/streaming/statusEmitter.js.map +1 -0
- package/dist/types/index.d.ts +403 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/debugFilter.d.ts +38 -0
- package/dist/utils/debugFilter.js +157 -0
- package/dist/utils/debugFilter.js.map +1 -0
- package/dist/utils/delay.d.ts +6 -0
- package/dist/utils/delay.js +15 -0
- package/dist/utils/delay.js.map +1 -0
- package/dist/utils/errors.d.ts +15 -0
- package/dist/utils/errors.js +40 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/evaluate.d.ts +51 -0
- package/dist/utils/evaluate.js +124 -0
- package/dist/utils/evaluate.js.map +1 -0
- package/dist/utils/ffmpeg.d.ts +65 -0
- package/dist/utils/ffmpeg.js +317 -0
- package/dist/utils/ffmpeg.js.map +1 -0
- package/dist/utils/fileLogger.d.ts +25 -0
- package/dist/utils/fileLogger.js +248 -0
- package/dist/utils/fileLogger.js.map +1 -0
- package/dist/utils/format.d.ts +16 -0
- package/dist/utils/format.js +46 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/html.d.ts +6 -0
- package/dist/utils/html.js +24 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logEmitter.d.ts +17 -0
- package/dist/utils/logEmitter.js +30 -0
- package/dist/utils/logEmitter.js.map +1 -0
- package/dist/utils/logger.d.ts +82 -0
- package/dist/utils/logger.js +219 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/m3u.d.ts +32 -0
- package/dist/utils/m3u.js +148 -0
- package/dist/utils/m3u.js.map +1 -0
- package/dist/utils/morganStream.d.ts +7 -0
- package/dist/utils/morganStream.js +33 -0
- package/dist/utils/morganStream.js.map +1 -0
- package/dist/utils/platform.d.ts +64 -0
- package/dist/utils/platform.js +157 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/retry.d.ts +15 -0
- package/dist/utils/retry.js +82 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/streamContext.d.ts +28 -0
- package/dist/utils/streamContext.js +33 -0
- package/dist/utils/streamContext.js.map +1 -0
- package/dist/utils/version.d.ts +37 -0
- package/dist/utils/version.js +228 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +92 -0
- package/prismcast.png +0 -0
- package/prismcast.svg +74 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import type { Frame, Page } from "puppeteer-core";
|
|
2
|
+
import type { Nullable, ResolvedSiteProfile, TuneResult, VideoSelectorType } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a selector type identifier for the video element based on the site profile. This returns a string that browser context code interprets to select the
|
|
5
|
+
* appropriate video element. Using a string identifier instead of passing functions avoids serialization issues with page.evaluate() and is more secure than
|
|
6
|
+
* eval()-based approaches.
|
|
7
|
+
* @param profile - The site profile indicating video selection strategy.
|
|
8
|
+
* @returns A selector type identifier: "selectReadyVideo" for sites with multiple videos, "selectFirstVideo" for standard sites.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildVideoSelectorType(profile: ResolvedSiteProfile): VideoSelectorType;
|
|
11
|
+
/**
|
|
12
|
+
* Video state information returned by getVideoState(). Contains all properties needed to assess playback health.
|
|
13
|
+
*/
|
|
14
|
+
export interface VideoStateInfo {
|
|
15
|
+
currentTime: number;
|
|
16
|
+
ended: boolean;
|
|
17
|
+
error: boolean;
|
|
18
|
+
muted: boolean;
|
|
19
|
+
networkState: number;
|
|
20
|
+
paused: boolean;
|
|
21
|
+
readyState: number;
|
|
22
|
+
volume: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the current state of the video element for health monitoring. Returns null if no video element is found.
|
|
26
|
+
* @param context - The frame or page containing the video element.
|
|
27
|
+
* @param selectorType - The video selector type for finding the element.
|
|
28
|
+
* @returns The video state or null if no video found.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getVideoState(context: Frame | Page, selectorType: VideoSelectorType): Promise<Nullable<VideoStateInfo>>;
|
|
31
|
+
/**
|
|
32
|
+
* 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
|
|
33
|
+
* aggressively mute videos.
|
|
34
|
+
* @param context - The frame or page containing the video element.
|
|
35
|
+
* @param selectorType - The video selector type for finding the element.
|
|
36
|
+
*/
|
|
37
|
+
export declare function enforceVideoVolume(context: Frame | Page, selectorType: VideoSelectorType): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Validation result for checking if a video element exists and is accessible.
|
|
40
|
+
*/
|
|
41
|
+
export interface VideoValidationResult {
|
|
42
|
+
found: boolean;
|
|
43
|
+
readyState?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validates that a video element exists and returns its ready state. Used after page navigation to verify recovery succeeded.
|
|
47
|
+
* @param context - The frame or page containing the video element.
|
|
48
|
+
* @param selectorType - The video selector type for finding the element.
|
|
49
|
+
* @returns Validation result indicating if video was found and its readyState.
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateVideoElement(context: Frame | Page, selectorType: VideoSelectorType): Promise<VideoValidationResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Result from checking video presence, distinguishing between "no video exists" and "video exists but not ready".
|
|
54
|
+
*/
|
|
55
|
+
export interface VideoPresenceResult {
|
|
56
|
+
anyVideoExists: boolean;
|
|
57
|
+
maxReadyState?: number;
|
|
58
|
+
readyVideoFound: boolean;
|
|
59
|
+
videoCount: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Checks video presence in the context, returning detailed information about what videos exist and their states. This helps distinguish between:
|
|
63
|
+
* - No video element exists at all (DOM issue, wrong context)
|
|
64
|
+
* - Video elements exist but none are ready (buffering, still loading)
|
|
65
|
+
* - Ready video exists (normal operation)
|
|
66
|
+
*
|
|
67
|
+
* This is useful when getVideoState returns null to determine if we should wait (video buffering) or escalate (no video at all).
|
|
68
|
+
* @param context - The frame or page containing the video element.
|
|
69
|
+
* @param selectorType - The video selector type for finding the element.
|
|
70
|
+
* @returns Detailed presence information.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkVideoPresence(context: Frame | Page, selectorType: VideoSelectorType): Promise<VideoPresenceResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Reloads the video source to force the player to reinitialize. This clears the src attribute, calls load() to reset the player state, restores the original src,
|
|
75
|
+
* and calls load() again. This is more disruptive than seeking but can fix players stuck in error states or with corrupted internal state.
|
|
76
|
+
* @param context - The frame or page containing the video element.
|
|
77
|
+
* @param selectorType - The video selector type for finding the element.
|
|
78
|
+
*/
|
|
79
|
+
export declare function reloadVideoSource(context: Frame | Page, selectorType: VideoSelectorType): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Starts video playback by ensuring the video is unmuted, at full volume, and playing. This combines volume enforcement with play() initiation for efficient single
|
|
82
|
+
* round-trip execution in the browser context.
|
|
83
|
+
* @param context - The frame or page containing the video element.
|
|
84
|
+
* @param selectorType - The video selector type for finding the element.
|
|
85
|
+
*/
|
|
86
|
+
export declare function startVideoPlayback(context: Frame | Page, selectorType: VideoSelectorType): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Navigates a browser page to the specified URL with site-appropriate wait conditions. The navigation strategy depends on the site's player implementation:
|
|
89
|
+
*
|
|
90
|
+
* - waitForNetworkIdle=true: Wait for network activity to settle (no requests for 500ms). This ensures all JavaScript has loaded and the player is fully
|
|
91
|
+
* initialized. Used for sites with complex async initialization.
|
|
92
|
+
*
|
|
93
|
+
* - waitForNetworkIdle=false: Return as soon as the page fires load event. Used for sites that have persistent connections or polling that would prevent
|
|
94
|
+
* networkidle from ever completing.
|
|
95
|
+
*
|
|
96
|
+
* Navigation timeouts are handled gracefully - we log a warning but don't throw, since the video may have loaded successfully even if networkidle never
|
|
97
|
+
* completed.
|
|
98
|
+
* @param page - The Puppeteer page object.
|
|
99
|
+
* @param url - The URL to navigate to.
|
|
100
|
+
* @param profile - The site profile containing navigation preferences.
|
|
101
|
+
*/
|
|
102
|
+
export declare function navigateToPage(page: Page, url: string, profile: ResolvedSiteProfile): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Finds the appropriate context (frame or page) containing the video element. Some streaming sites embed their video player in an iframe, which creates a
|
|
105
|
+
* separate document context. We need to find this iframe and operate within it to access the video element.
|
|
106
|
+
*
|
|
107
|
+
* The search process:
|
|
108
|
+
* 1. If the profile doesn't need iframe handling, return the main page directly
|
|
109
|
+
* 2. Wait for an iframe element to appear in the DOM
|
|
110
|
+
* 3. Allow time for the iframe content to initialize (embedded players often load additional resources)
|
|
111
|
+
* 4. Search through all frames to find one containing a video element
|
|
112
|
+
* 5. Fall back to the main page if no iframe contains a video
|
|
113
|
+
* @param page - The Puppeteer page object.
|
|
114
|
+
* @param profile - The site profile indicating whether iframe handling is needed.
|
|
115
|
+
* @returns The frame or page containing the video element.
|
|
116
|
+
*/
|
|
117
|
+
export declare function findVideoContext(page: Page, profile: ResolvedSiteProfile): Promise<Frame | Page>;
|
|
118
|
+
/**
|
|
119
|
+
* Waits for the video element to reach a ready state indicating it has loaded enough data to begin playback. We use readyState >= 3 (HAVE_FUTURE_DATA) as the
|
|
120
|
+
* threshold because:
|
|
121
|
+
*
|
|
122
|
+
* - readyState 0 (HAVE_NOTHING): No data available
|
|
123
|
+
* - readyState 1 (HAVE_METADATA): Duration and dimensions known, but no media data
|
|
124
|
+
* - readyState 2 (HAVE_CURRENT_DATA): Data for current position available, but not enough for playback
|
|
125
|
+
* - readyState 3 (HAVE_FUTURE_DATA): Enough data for current position plus at least a little ahead
|
|
126
|
+
* - readyState 4 (HAVE_ENOUGH_DATA): Enough data to play through without buffering (for known-length media)
|
|
127
|
+
*
|
|
128
|
+
* Live streams continuously receive data and may never reach readyState 4, so we use >= 3 as the threshold. The health monitor handles any subsequent buffering
|
|
129
|
+
* or playback issues.
|
|
130
|
+
* @param context - The frame or page containing the video element.
|
|
131
|
+
* @param profile - The site profile with video selection preferences.
|
|
132
|
+
*/
|
|
133
|
+
export declare function waitForVideoReady(context: Frame | Page, profile: ResolvedSiteProfile): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Applies fullscreen styling to the video element using CSS to maximize the capture area. This CSS-based approach works for all sites regardless of their native
|
|
136
|
+
* fullscreen mechanism (keyboard shortcuts, JavaScript API, etc.).
|
|
137
|
+
*
|
|
138
|
+
* The styling:
|
|
139
|
+
* - position: fixed - Removes the video from document flow and positions relative to viewport
|
|
140
|
+
* - top: 0; left: 0; width: 100%; height: 100% - Fills the entire viewport
|
|
141
|
+
* - zIndex: 999000 - Ensures the video appears above all other page content
|
|
142
|
+
* - objectFit: contain - Maintains aspect ratio while fitting within the viewport
|
|
143
|
+
* - background: black - Fills any letterbox/pillarbox areas with black
|
|
144
|
+
* - cursor: none - Hides the mouse cursor for cleaner capture
|
|
145
|
+
* @param context - The frame or page containing the video element.
|
|
146
|
+
* @param selectorType - The video selector type for finding the element.
|
|
147
|
+
* @param important - When true, applies styles with !important priority to override site JavaScript that actively fights style changes.
|
|
148
|
+
*/
|
|
149
|
+
export declare function applyVideoStyles(context: Frame | Page, selectorType: VideoSelectorType, important?: boolean): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Locks the volume properties on the video element to prevent the site's JavaScript from muting our stream. Some sites (like France24) aggressively mute videos
|
|
152
|
+
* or lower volume in response to various events. They may reset volume on play, on focus, on visibility change, or on a timer.
|
|
153
|
+
*
|
|
154
|
+
* This function uses Object.defineProperty to intercept property access, making it impossible for site JavaScript to change muted or volume values. The property
|
|
155
|
+
* descriptors are set to configurable: true so the browser can still access the underlying values for playback.
|
|
156
|
+
*
|
|
157
|
+
* The function is idempotent - a __volumeLocked flag on the video element prevents applying the lock multiple times.
|
|
158
|
+
* @param context - The frame or page containing the video element.
|
|
159
|
+
* @param selectorType - The video selector type for finding the element.
|
|
160
|
+
*/
|
|
161
|
+
export declare function lockVolumeProperties(context: Frame | Page, selectorType: VideoSelectorType): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Triggers fullscreen mode using the appropriate method for the site. Different sites have different fullscreen implementations:
|
|
164
|
+
*
|
|
165
|
+
* - Keyboard shortcuts (fullscreenKey): Many players use "f" as a keyboard shortcut for fullscreen. We send this keypress to activate the player's native
|
|
166
|
+
* fullscreen mode.
|
|
167
|
+
*
|
|
168
|
+
* - JavaScript Fullscreen API (useRequestFullscreen): Some players require calling video.requestFullscreen() directly. This may trigger browser permission
|
|
169
|
+
* prompts or be blocked by CSP, but works on many sites.
|
|
170
|
+
*
|
|
171
|
+
* Note that we also apply CSS-based fullscreen styling separately (in applyVideoStyles), which provides a reliable fallback when native fullscreen methods fail.
|
|
172
|
+
* @param page - The Puppeteer page object for keyboard input.
|
|
173
|
+
* @param context - The frame or page containing the video element.
|
|
174
|
+
* @param profile - The site profile indicating fullscreen method.
|
|
175
|
+
* @param selectorType - The video selector type for finding the element.
|
|
176
|
+
*/
|
|
177
|
+
export declare function triggerFullscreen(page: Page, context: Frame | Page, profile: ResolvedSiteProfile, selectorType: VideoSelectorType): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Verifies that the video element is filling the viewport, indicating that fullscreen styling was successfully applied. This function checks the video element's
|
|
180
|
+
* bounding rectangle against the viewport dimensions to determine if the video appears fullscreen.
|
|
181
|
+
*
|
|
182
|
+
* The verification allows for some tolerance because:
|
|
183
|
+
* - The video may have letterboxing/pillarboxing due to aspect ratio differences
|
|
184
|
+
* - Some browsers report slightly smaller dimensions due to scrollbars or UI chrome
|
|
185
|
+
* - CSS rounding may cause small discrepancies
|
|
186
|
+
*
|
|
187
|
+
* 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
|
|
188
|
+
* other dimension to catch obviously broken cases.
|
|
189
|
+
* @param context - The frame or page containing the video element.
|
|
190
|
+
* @param selectorType - The video selector type for finding the element.
|
|
191
|
+
* @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).
|
|
192
|
+
*/
|
|
193
|
+
export declare function verifyFullscreen(context: Frame | Page, selectorType: VideoSelectorType): Promise<Nullable<boolean>>;
|
|
194
|
+
/**
|
|
195
|
+
* Ensures the video is displayed fullscreen with verification and retry logic. This function orchestrates the fullscreen process:
|
|
196
|
+
*
|
|
197
|
+
* 1. Initial attempt: Apply CSS styles and trigger fullscreen API
|
|
198
|
+
* 2. Verify: Check video dimensions and, for fullscreenApi profiles, confirm document.fullscreenElement is set
|
|
199
|
+
* 3. Simple retry: If verification fails, click the video for user activation and retry (the Fullscreen API requires a recent user gesture)
|
|
200
|
+
* 4. Escalate: If simple retries fail, apply aggressive fullscreen techniques with a final Fullscreen API re-trigger
|
|
201
|
+
*
|
|
202
|
+
* The retry approach handles both timing issues (page still initializing) and user activation issues (requestFullscreen requires a recent user gesture).
|
|
203
|
+
* On retry, clicking the video provides fresh activation so the subsequent requestFullscreen() call can succeed. Escalation to aggressive techniques is a
|
|
204
|
+
* last resort that may break site functionality but ensures video fills the viewport.
|
|
205
|
+
* @param page - The Puppeteer page object for keyboard input.
|
|
206
|
+
* @param context - The frame or page containing the video element.
|
|
207
|
+
* @param profile - The site profile indicating fullscreen method.
|
|
208
|
+
* @param selectorType - The video selector type for finding the element.
|
|
209
|
+
* @param skipNativeFullscreen - When true, skips Fullscreen API-specific actions (click-for-activation, native fullscreen verification, API retries). CSS styling
|
|
210
|
+
* and keyboard shortcuts still run. Used during monitor recovery where user activation is unavailable and click-for-activation can interfere with playback.
|
|
211
|
+
*/
|
|
212
|
+
export declare function ensureFullscreen(page: Page, context: Frame | Page, profile: ResolvedSiteProfile, selectorType: VideoSelectorType, skipNativeFullscreen?: boolean): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Options for ensurePlayback() that control recovery behavior.
|
|
215
|
+
*/
|
|
216
|
+
interface EnsurePlaybackOptions {
|
|
217
|
+
/** The escalation level (1-2). Level 1 is basic play/unmute recovery. Level 2 adds video source reload. Defaults to 1. */
|
|
218
|
+
recoveryLevel?: number;
|
|
219
|
+
/** When true, skips native Fullscreen API actions (click-for-activation, API verification, API retries) during the fullscreen step. CSS styling and keyboard
|
|
220
|
+
* shortcuts still run. Used by the monitor during recovery where user activation is unavailable and click-for-activation can toggle playback state. The
|
|
221
|
+
* monitor's own lightweight fullscreen maintenance loop handles ongoing CSS reapplication independently. Defaults to false. */
|
|
222
|
+
skipNativeFullscreen?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Ensures the video is playing with proper audio settings. This is the core playback function that handles both initial setup and recovery from stalls. It is
|
|
226
|
+
* designed to be idempotent - safe to call multiple times without adverse effects.
|
|
227
|
+
*
|
|
228
|
+
* Recovery escalation levels (higher levels include all lower-level actions):
|
|
229
|
+
*
|
|
230
|
+
* LEVEL 1 - Basic recovery (default):
|
|
231
|
+
* - Set muted=false and volume=1
|
|
232
|
+
* - Call play() if video is paused
|
|
233
|
+
* - Ensure fullscreen with CSS styling, keyboard shortcuts, and dimension verification. When skipNativeFullscreen is set, Fullscreen API-specific actions are
|
|
234
|
+
* skipped because user activation is unavailable and click-for-activation can interfere with playback recovery.
|
|
235
|
+
* - Lock volume properties if profile requires it
|
|
236
|
+
*
|
|
237
|
+
* LEVEL 2 - Reload video source:
|
|
238
|
+
* - All level 1 actions, plus:
|
|
239
|
+
* - Reset video.src to empty, call load()
|
|
240
|
+
* - Restore original src, call load() again
|
|
241
|
+
* - Wait for source to reinitialize
|
|
242
|
+
* - This forces the player to completely reinitialize, fixing stuck players
|
|
243
|
+
*
|
|
244
|
+
* Level 3 (full page navigation) is handled by the playback monitor, not this function.
|
|
245
|
+
* @param page - The Puppeteer page object.
|
|
246
|
+
* @param context - The frame or page containing the video element.
|
|
247
|
+
* @param profile - The site profile containing all behavior flags.
|
|
248
|
+
* @param options - Optional recovery configuration. Omit for initial tune (full fullscreen behavior, level 1).
|
|
249
|
+
*/
|
|
250
|
+
export declare function ensurePlayback(page: Page, context: Frame | Page, profile: ResolvedSiteProfile, options?: EnsurePlaybackOptions): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Performs all post-navigation channel initialization: selects the channel, finds the video context, clicks to play if needed, waits for video readiness, and
|
|
253
|
+
* ensures playback with fullscreen styling. This function is separated from navigateToPage() so that retryOperation() in setup.ts can wrap only navigation with a
|
|
254
|
+
* timeout, while channel selection and video setup run with their own internal time budgets (click retry loops, videoTimeout, etc.) without being killed by the
|
|
255
|
+
* navigation timeout.
|
|
256
|
+
*
|
|
257
|
+
* For guideGrid channel selection failures, the function attempts a single retry after dismissing any stale overlay that may be covering the guide grid. This
|
|
258
|
+
* handles the case where a failed click attempt left an overlay open, causing subsequent locateOnNowCell calls to fail.
|
|
259
|
+
*
|
|
260
|
+
* @param page - The Puppeteer page object.
|
|
261
|
+
* @param profile - The site profile containing all behavior flags.
|
|
262
|
+
* @param skipChannelSelection - When true, skip the channel selection phase entirely. Used when navigating directly to a cached watch URL that already targets
|
|
263
|
+
* the correct channel — only video detection, playback, and fullscreen setup are needed.
|
|
264
|
+
* @returns The video context (frame or page) for subsequent monitoring.
|
|
265
|
+
*/
|
|
266
|
+
export declare function initializePlayback(page: Page, profile: ResolvedSiteProfile, skipChannelSelection?: boolean): Promise<TuneResult>;
|
|
267
|
+
/**
|
|
268
|
+
* Tunes to a channel by navigating to the URL and initializing video playback. This is the single source of truth for channel initialization, used by both initial
|
|
269
|
+
* stream setup and recovery. Having one authoritative function ensures consistent behavior and prevents code divergence between setup and recovery paths.
|
|
270
|
+
*
|
|
271
|
+
* The tuning process:
|
|
272
|
+
* 0. Check cache: If a direct watch URL is cached, navigate to it and skip channel selection. On failure, invalidate and fall through.
|
|
273
|
+
* 1. Navigate: Load the target URL using site-appropriate wait conditions
|
|
274
|
+
* 2. Select channel: For multi-channel players, click the desired channel in the UI
|
|
275
|
+
* 3. Find video: Locate the video element (which may be in an iframe)
|
|
276
|
+
* 4. Click to play: For Brightcove-style players, click the video to start playback
|
|
277
|
+
* 5. Wait for ready: Ensure the video has buffered enough data to play
|
|
278
|
+
* 6. Ensure playback: Start playback, unmute, and apply fullscreen styling
|
|
279
|
+
*
|
|
280
|
+
* Note: Stream context for logging is automatically retrieved from AsyncLocalStorage. Callers should wrap their stream handling code in runWithStreamContext() to
|
|
281
|
+
* ensure log messages include the stream ID prefix.
|
|
282
|
+
*
|
|
283
|
+
* @param page - The Puppeteer page object.
|
|
284
|
+
* @param url - The URL to navigate to.
|
|
285
|
+
* @param profile - The site profile containing all behavior flags.
|
|
286
|
+
* @returns The video context (frame or page) for subsequent monitoring.
|
|
287
|
+
*/
|
|
288
|
+
export declare function tuneToChannel(page: Page, url: string, profile: ResolvedSiteProfile): Promise<TuneResult>;
|
|
289
|
+
export {};
|