@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,120 @@
|
|
|
1
|
+
import type { Channel, Nullable } from "../types/index.js";
|
|
2
|
+
import type { Request, Response } from "express";
|
|
3
|
+
/**
|
|
4
|
+
* Result of channel validation. On success, contains the resolved channel and provider key. On failure, contains the HTTP error details. The body field carries
|
|
5
|
+
* either a plain string (for text error responses) or an object (for JSON error responses), so callers can use typeof to pick res.send() vs res.json().
|
|
6
|
+
*/
|
|
7
|
+
export type ValidateChannelResult = {
|
|
8
|
+
channel: Channel;
|
|
9
|
+
resolvedKey: string;
|
|
10
|
+
valid: true;
|
|
11
|
+
} | {
|
|
12
|
+
body: Record<string, string> | string;
|
|
13
|
+
statusCode: number;
|
|
14
|
+
valid: false;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Validates a channel name for streaming. Performs all fast, synchronous checks: disabled status, provider resolution, channel lookup, and login mode. Returns a
|
|
18
|
+
* discriminated union so callers can handle success and failure without coupling to Express response objects.
|
|
19
|
+
*
|
|
20
|
+
* This is extracted from ensureChannelStream() so it can be called by both HLS and MPEG-TS code paths without duplicating the validation logic.
|
|
21
|
+
*
|
|
22
|
+
* @param channelName - The channel key to validate.
|
|
23
|
+
* @returns Validation result with channel data on success, or error details on failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateChannel(channelName: string): ValidateChannelResult;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a validation error response to the client. Handles both plain text bodies (via res.send) and object bodies (via res.json).
|
|
28
|
+
* @param validation - The failed validation result.
|
|
29
|
+
* @param res - Express response object.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sendValidationError(validation: {
|
|
32
|
+
body: Record<string, string> | string;
|
|
33
|
+
statusCode: number;
|
|
34
|
+
}, res: Response): void;
|
|
35
|
+
/**
|
|
36
|
+
* Ensures a stream is running for a channel. If no stream exists, starts one. If a stream startup is in progress (-1 sentinel), waits for it to complete. Returns
|
|
37
|
+
* the stream ID if successful, or null if an error occurred (with the error response already sent to the client).
|
|
38
|
+
*
|
|
39
|
+
* The existing-stream check runs first so that ad-hoc streams (registered under synthetic keys like "play-a1b2c3d4") can be served without failing the
|
|
40
|
+
* "Channel not found" check.
|
|
41
|
+
*
|
|
42
|
+
* For channels with multiple providers (e.g., ESPN via ESPN.com or Disney+), the user's provider selection is resolved before looking up the channel definition.
|
|
43
|
+
* The stream is registered under the canonical key (channelName) for deduplication, but uses the resolved provider's URL and settings.
|
|
44
|
+
*
|
|
45
|
+
* @param channelName - The channel key (or synthetic ad-hoc key) to stream.
|
|
46
|
+
* @param req - Express request object (for profile override and client IP).
|
|
47
|
+
* @param res - Express response object (for error responses).
|
|
48
|
+
* @returns The stream ID if a stream is running, or null if an error occurred.
|
|
49
|
+
*/
|
|
50
|
+
export declare function ensureChannelStream(channelName: string, req: Request, res: Response): Promise<Nullable<number>>;
|
|
51
|
+
/**
|
|
52
|
+
* Handles HLS playlist requests. Ensures a stream is running for the channel (blocking until ready if a new stream must start), then returns the playlist.
|
|
53
|
+
*
|
|
54
|
+
* Route: GET /hls/:name/stream.m3u8
|
|
55
|
+
*
|
|
56
|
+
* @param req - Express request object.
|
|
57
|
+
* @param res - Express response object.
|
|
58
|
+
*/
|
|
59
|
+
export declare function handleHLSPlaylist(req: Request, res: Response): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Handles HLS segment requests. Returns the requested segment from memory. Supports both the fMP4 initialization segment (init.mp4) and media segments (.m4s).
|
|
62
|
+
*
|
|
63
|
+
* Route: GET /hls/:name/:segment
|
|
64
|
+
*
|
|
65
|
+
* @param req - Express request object.
|
|
66
|
+
* @param res - Express response object.
|
|
67
|
+
*/
|
|
68
|
+
export declare function handleHLSSegment(req: Request, res: Response): void;
|
|
69
|
+
/**
|
|
70
|
+
* Handles ad-hoc stream requests for arbitrary URLs. Generates a deterministic synthetic key from the URL and profile, starts a stream if none exists, and redirects
|
|
71
|
+
* to the standard HLS playlist path. This enables streaming URLs that are not predefined as channels.
|
|
72
|
+
*
|
|
73
|
+
* The synthetic key includes the profile so that the same URL with different profiles produces separate streams. The "play-" prefix prevents collisions with
|
|
74
|
+
* predefined channel names.
|
|
75
|
+
*
|
|
76
|
+
* Route: GET /play?url=<url>&profile=<name>
|
|
77
|
+
*
|
|
78
|
+
* @param req - Express request object.
|
|
79
|
+
* @param res - Express response object.
|
|
80
|
+
*/
|
|
81
|
+
export declare function handlePlayStream(req: Request, res: Response): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Waits for a stream startup to complete without sending any HTTP responses. Used by MPEG-TS when headers have already been flushed and error responses cannot be
|
|
84
|
+
* sent.
|
|
85
|
+
*
|
|
86
|
+
* @param channelName - The channel name (or synthetic ad-hoc key) to poll.
|
|
87
|
+
* @returns The resolved stream ID on success, or null if startup failed or timed out.
|
|
88
|
+
*/
|
|
89
|
+
export declare function awaitStreamReadySilent(channelName: string): Promise<Nullable<number>>;
|
|
90
|
+
/**
|
|
91
|
+
* Options for initializing a stream.
|
|
92
|
+
*/
|
|
93
|
+
interface InitializeStreamOptions {
|
|
94
|
+
channel?: Channel;
|
|
95
|
+
channelSelector?: string;
|
|
96
|
+
channelName: string;
|
|
97
|
+
clientAddress: Nullable<string>;
|
|
98
|
+
clickSelector?: string;
|
|
99
|
+
clickToPlay?: boolean;
|
|
100
|
+
profileOverride?: string;
|
|
101
|
+
url: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Initializes a new HLS stream. This is the shared stream startup logic used by both channel-based and ad-hoc streams. It handles browser capture setup, segmenter
|
|
105
|
+
* creation, stream registration, and event emission.
|
|
106
|
+
*
|
|
107
|
+
* A -1 sentinel is set in channelToStreamId during setup to prevent duplicate stream starts. On success, the sentinel is replaced with the real stream ID. On
|
|
108
|
+
* failure, the sentinel is removed and the error is re-thrown for the caller to handle HTTP error responses appropriately (channel-based streams need HDHomeRun
|
|
109
|
+
* headers, ad-hoc streams do not).
|
|
110
|
+
*
|
|
111
|
+
* @param options - Stream initialization options.
|
|
112
|
+
* @returns The stream ID on success, or null if the stream was terminated during the narrow setup window (orphaned setup race condition).
|
|
113
|
+
* @throws StreamSetupError if setup fails, or Error for unexpected failures.
|
|
114
|
+
*/
|
|
115
|
+
export declare function initializeStream(options: InitializeStreamOptions): Promise<Nullable<number>>;
|
|
116
|
+
/**
|
|
117
|
+
* Checks for idle streams and terminates them. Called periodically by the idle detection interval.
|
|
118
|
+
*/
|
|
119
|
+
export declare function cleanupIdleStreams(): void;
|
|
120
|
+
export {};
|