prismcast 1.9.0 → 1.10.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.
- package/dist/app.d.ts +1 -1
- package/dist/app.js +27 -9
- package/dist/app.js.map +1 -1
- package/dist/browser/cdp.js +7 -7
- package/dist/browser/cdp.js.map +1 -1
- package/dist/browser/channelSelection.d.ts +41 -11
- package/dist/browser/channelSelection.js +75 -24
- package/dist/browser/channelSelection.js.map +1 -1
- package/dist/browser/display.d.ts +1 -1
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.js +42 -43
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/login.d.ts +2 -2
- package/dist/browser/login.js +1 -1
- package/dist/browser/manifestInterceptor.d.ts +77 -0
- package/dist/browser/manifestInterceptor.js +323 -0
- package/dist/browser/manifestInterceptor.js.map +1 -0
- package/dist/browser/precaching.js +4 -4
- package/dist/browser/tuning/comcastPolymer.d.ts +1 -1
- package/dist/browser/tuning/cox.d.ts +1 -1
- package/dist/browser/tuning/directv.d.ts +1 -1
- package/dist/browser/tuning/directv.js +61 -62
- package/dist/browser/tuning/directv.js.map +1 -1
- package/dist/browser/tuning/fox.d.ts +1 -1
- package/dist/browser/tuning/fox.js +171 -14
- package/dist/browser/tuning/fox.js.map +1 -1
- package/dist/browser/tuning/hbo.d.ts +1 -1
- package/dist/browser/tuning/hbo.js +6 -6
- package/dist/browser/tuning/hbo.js.map +1 -1
- package/dist/browser/tuning/hulu.d.ts +1 -1
- package/dist/browser/tuning/hulu.js +117 -110
- package/dist/browser/tuning/hulu.js.map +1 -1
- package/dist/browser/tuning/shared.d.ts +3 -3
- package/dist/browser/tuning/shared.js +5 -5
- package/dist/browser/tuning/sling.d.ts +1 -1
- package/dist/browser/tuning/sling.js +28 -28
- package/dist/browser/tuning/sling.js.map +1 -1
- package/dist/browser/tuning/spectrum.d.ts +1 -1
- package/dist/browser/tuning/spectrum.js +21 -22
- package/dist/browser/tuning/spectrum.js.map +1 -1
- package/dist/browser/tuning/thumbnailRow.d.ts +1 -1
- package/dist/browser/tuning/thumbnailRow.js +1 -1
- package/dist/browser/tuning/tileClick.d.ts +1 -1
- package/dist/browser/tuning/tileClick.js +5 -5
- package/dist/browser/tuning/xfinity.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.js +17 -18
- package/dist/browser/tuning/youtubeTv.js.map +1 -1
- package/dist/browser/video.d.ts +20 -6
- package/dist/browser/video.js +30 -38
- package/dist/browser/video.js.map +1 -1
- package/dist/channels/index.d.ts +1 -2
- package/dist/channels/index.js +73 -40
- package/dist/channels/index.js.map +1 -1
- package/dist/config/channelForm.d.ts +58 -0
- package/dist/config/channelForm.js +129 -0
- package/dist/config/channelForm.js.map +1 -0
- package/dist/config/consistencyProbe.d.ts +7 -0
- package/dist/config/consistencyProbe.js +143 -0
- package/dist/config/consistencyProbe.js.map +1 -0
- package/dist/config/health.d.ts +4 -3
- package/dist/config/health.js +75 -62
- package/dist/config/health.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +19 -12
- package/dist/config/index.js.map +1 -1
- package/dist/config/paths.d.ts +9 -3
- package/dist/config/paths.js +12 -4
- package/dist/config/paths.js.map +1 -1
- package/dist/config/persistence.context.d.ts +8 -0
- package/dist/config/persistence.context.js +30 -0
- package/dist/config/persistence.context.js.map +1 -0
- package/dist/config/persistence.d.ts +110 -12
- package/dist/config/persistence.js +351 -32
- package/dist/config/persistence.js.map +1 -1
- package/dist/config/presets.d.ts +14 -4
- package/dist/config/presets.js +84 -75
- package/dist/config/presets.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -2
- package/dist/config/profiles.js +7 -9
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/servicePacks.d.ts +2 -2
- package/dist/config/servicePacks.js +28 -28
- package/dist/config/servicePacks.js.map +1 -1
- package/dist/config/services.d.ts +62 -36
- package/dist/config/services.js +150 -136
- package/dist/config/services.js.map +1 -1
- package/dist/config/sites.d.ts +3 -3
- package/dist/config/sites.js +16 -16
- package/dist/config/sites.js.map +1 -1
- package/dist/config/userChannels.d.ts +500 -41
- package/dist/config/userChannels.js +1201 -312
- package/dist/config/userChannels.js.map +1 -1
- package/dist/config/userConfig.d.ts +103 -10
- package/dist/config/userConfig.js +277 -117
- package/dist/config/userConfig.js.map +1 -1
- package/dist/config/userProfiles.d.ts +4 -2
- package/dist/config/userProfiles.js +72 -26
- package/dist/config/userProfiles.js.map +1 -1
- package/dist/hdhr/channelMap.js +8 -11
- package/dist/hdhr/channelMap.js.map +1 -1
- package/dist/hdhr/deviceId.js +10 -9
- package/dist/hdhr/deviceId.js.map +1 -1
- package/dist/hdhr/discover.js +4 -5
- package/dist/hdhr/discover.js.map +1 -1
- package/dist/hdhr/index.js +6 -10
- package/dist/hdhr/index.js.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/native/codecInference.d.ts +44 -0
- package/dist/native/codecInference.js +327 -0
- package/dist/native/codecInference.js.map +1 -0
- package/dist/native/decrypt.d.ts +1 -1
- package/dist/native/index.d.ts +5 -5
- package/dist/native/index.js +42 -64
- package/dist/native/index.js.map +1 -1
- package/dist/native/probe.d.ts +27 -9
- package/dist/native/probe.js +158 -67
- package/dist/native/probe.js.map +1 -1
- package/dist/native/proxy.d.ts +4 -2
- package/dist/native/proxy.js +52 -49
- package/dist/native/proxy.js.map +1 -1
- package/dist/native/tokenExpiry.d.ts +22 -0
- package/dist/native/tokenExpiry.js +153 -0
- package/dist/native/tokenExpiry.js.map +1 -0
- package/dist/routes/auth.js +6 -10
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/components.js +2 -2
- package/dist/routes/components.js.map +1 -1
- package/dist/routes/config/channels/endpoints/browse.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/browse.js +195 -0
- package/dist/routes/config/channels/endpoints/browse.js.map +1 -0
- package/dist/routes/config/channels/endpoints/bulk.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/bulk.js +128 -0
- package/dist/routes/config/channels/endpoints/bulk.js.map +1 -0
- package/dist/routes/config/channels/endpoints/crud.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/crud.js +504 -0
- package/dist/routes/config/channels/endpoints/crud.js.map +1 -0
- package/dist/routes/config/channels/endpoints/importExport.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/importExport.js +131 -0
- package/dist/routes/config/channels/endpoints/importExport.js.map +1 -0
- package/dist/routes/config/channels/endpoints/predefined.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/predefined.js +78 -0
- package/dist/routes/config/channels/endpoints/predefined.js.map +1 -0
- package/dist/routes/config/channels/endpoints/prefs.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/prefs.js +58 -0
- package/dist/routes/config/channels/endpoints/prefs.js.map +1 -0
- package/dist/routes/config/channels/endpoints/service.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/service.js +149 -0
- package/dist/routes/config/channels/endpoints/service.js.map +1 -0
- package/dist/routes/config/channels/endpoints/tags.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/tags.js +185 -0
- package/dist/routes/config/channels/endpoints/tags.js.map +1 -0
- package/dist/routes/config/channels/http/handler.d.ts +10 -0
- package/dist/routes/config/channels/http/handler.js +20 -0
- package/dist/routes/config/channels/http/handler.js.map +1 -0
- package/dist/routes/config/channels/http/playlistHint.d.ts +25 -0
- package/dist/routes/config/channels/http/playlistHint.js +40 -0
- package/dist/routes/config/channels/http/playlistHint.js.map +1 -0
- package/dist/routes/config/channels/http/serviceWarning.d.ts +10 -0
- package/dist/routes/config/channels/http/serviceWarning.js +28 -0
- package/dist/routes/config/channels/http/serviceWarning.js.map +1 -0
- package/dist/routes/config/channels/index.d.ts +3 -3
- package/dist/routes/config/channels/index.js +1 -1
- package/dist/routes/config/channels/index.js.map +1 -1
- package/dist/routes/config/channels/{routes.d.ts → setup.d.ts} +1 -1
- package/dist/routes/config/channels/setup.js +23 -0
- package/dist/routes/config/channels/setup.js.map +1 -0
- package/dist/routes/config/channels/table.d.ts +9 -9
- package/dist/routes/config/channels/table.js +124 -76
- package/dist/routes/config/channels/table.js.map +1 -1
- package/dist/routes/config/http/envelope.d.ts +111 -0
- package/dist/routes/config/http/envelope.js +103 -0
- package/dist/routes/config/http/envelope.js.map +1 -0
- package/dist/routes/config/index.d.ts +9 -9
- package/dist/routes/config/index.js +2 -2
- package/dist/routes/config/index.js.map +1 -1
- package/dist/routes/config/services.js +69 -68
- package/dist/routes/config/services.js.map +1 -1
- package/dist/routes/config/settings.d.ts +1 -1
- package/dist/routes/config/settings.js +45 -38
- package/dist/routes/config/settings.js.map +1 -1
- package/dist/routes/debug.js +12 -11
- package/dist/routes/debug.js.map +1 -1
- package/dist/routes/icons.js +2 -2
- package/dist/routes/icons.js.map +1 -1
- package/dist/routes/logs.js +19 -30
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/mpegts.js +1 -1
- package/dist/routes/playlist.d.ts +1 -1
- package/dist/routes/playlist.js +37 -26
- package/dist/routes/playlist.js.map +1 -1
- package/dist/routes/root/content.js +27 -6
- package/dist/routes/root/content.js.map +1 -1
- package/dist/routes/root/index.js +2 -5
- package/dist/routes/root/index.js.map +1 -1
- package/dist/routes/root/scripts/channels.js +16 -16
- package/dist/routes/root/scripts/channels.js.map +1 -1
- package/dist/routes/root/scripts/config.js +59 -59
- package/dist/routes/root/scripts/config.js.map +1 -1
- package/dist/routes/root/scripts/index.d.ts +4 -4
- package/dist/routes/root/scripts/shared.js +24 -10
- package/dist/routes/root/scripts/shared.js.map +1 -1
- package/dist/routes/root/scripts/status.d.ts +4 -0
- package/dist/routes/root/scripts/status.handlers.d.ts +182 -0
- package/dist/routes/root/scripts/status.handlers.js +713 -0
- package/dist/routes/root/scripts/status.handlers.js.map +1 -0
- package/dist/routes/root/scripts/status.js +86 -488
- package/dist/routes/root/scripts/status.js.map +1 -1
- package/dist/routes/root/styles.js +5 -5
- package/dist/routes/services.js +18 -15
- package/dist/routes/services.js.map +1 -1
- package/dist/routes/sse.d.ts +16 -0
- package/dist/routes/sse.js +29 -0
- package/dist/routes/sse.js.map +1 -0
- package/dist/routes/streams.js +10 -23
- package/dist/routes/streams.js.map +1 -1
- package/dist/routes/ui.d.ts +2 -2
- package/dist/routes/upgrade.js +6 -7
- package/dist/routes/upgrade.js.map +1 -1
- package/dist/service/commands.context.d.ts +6 -0
- package/dist/service/commands.context.js +47 -0
- package/dist/service/commands.context.js.map +1 -0
- package/dist/service/commands.d.ts +53 -8
- package/dist/service/commands.js +171 -188
- package/dist/service/commands.js.map +1 -1
- package/dist/service/generators.context.d.ts +6 -0
- package/dist/service/generators.context.js +45 -0
- package/dist/service/generators.context.js.map +1 -0
- package/dist/service/generators.d.ts +56 -16
- package/dist/service/generators.js +499 -383
- package/dist/service/generators.js.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/streaming/clients.d.ts +2 -2
- package/dist/streaming/clients.js +2 -2
- package/dist/streaming/codec.d.ts +2 -2
- package/dist/streaming/codec.js +0 -1
- package/dist/streaming/codec.js.map +1 -1
- package/dist/streaming/fmp4Segmenter.d.ts +2 -2
- package/dist/streaming/fmp4Segmenter.js +12 -12
- package/dist/streaming/hls.d.ts +3 -3
- package/dist/streaming/hls.js +81 -70
- package/dist/streaming/hls.js.map +1 -1
- package/dist/streaming/hlsResume.d.ts +3 -3
- package/dist/streaming/hlsResume.js +5 -5
- package/dist/streaming/hlsSegments.d.ts +5 -2
- package/dist/streaming/hlsSegments.js +14 -9
- package/dist/streaming/hlsSegments.js.map +1 -1
- package/dist/streaming/monitor.d.ts +12 -12
- package/dist/streaming/monitor.js +80 -54
- package/dist/streaming/monitor.js.map +1 -1
- package/dist/streaming/mp4Parser.d.ts +34 -4
- package/dist/streaming/mp4Parser.js +111 -29
- package/dist/streaming/mp4Parser.js.map +1 -1
- package/dist/streaming/mpegts.d.ts +1 -1
- package/dist/streaming/mpegts.js +13 -10
- package/dist/streaming/mpegts.js.map +1 -1
- package/dist/streaming/playlistBuilder.d.ts +1 -1
- package/dist/streaming/playlistBuilder.js +2 -2
- package/dist/streaming/preroll.d.ts +9 -9
- package/dist/streaming/preroll.js +39 -41
- package/dist/streaming/preroll.js.map +1 -1
- package/dist/streaming/pretune.js +4 -4
- package/dist/streaming/pretune.js.map +1 -1
- package/dist/streaming/recovery.d.ts +3 -3
- package/dist/streaming/recovery.js +4 -4
- package/dist/streaming/registry.d.ts +6 -6
- package/dist/streaming/setup.d.ts +9 -8
- package/dist/streaming/setup.js +97 -49
- package/dist/streaming/setup.js.map +1 -1
- package/dist/streaming/showInfo.d.ts +9 -3
- package/dist/streaming/showInfo.js +26 -18
- package/dist/streaming/showInfo.js.map +1 -1
- package/dist/streaming/statusEmitter.d.ts +4 -4
- package/dist/streaming/statusEmitter.js +2 -2
- package/dist/types/channels.d.ts +133 -34
- package/dist/types/channels.js +39 -1
- package/dist/types/channels.js.map +1 -1
- package/dist/types/config.d.ts +20 -1
- package/dist/types/index.d.ts +9 -8
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/profiles.d.ts +5 -4
- package/dist/types/selection.d.ts +48 -4
- package/dist/types/streaming.d.ts +1 -1
- package/dist/upgrade/commands.context.d.ts +6 -0
- package/dist/upgrade/commands.context.js +29 -0
- package/dist/upgrade/commands.context.js.map +1 -0
- package/dist/upgrade/commands.d.ts +29 -2
- package/dist/upgrade/commands.js +87 -134
- package/dist/upgrade/commands.js.map +1 -1
- package/dist/upgrade/detection.context.d.ts +6 -0
- package/dist/upgrade/detection.context.js +24 -0
- package/dist/upgrade/detection.context.js.map +1 -0
- package/dist/upgrade/detection.d.ts +140 -10
- package/dist/upgrade/detection.js +153 -66
- package/dist/upgrade/detection.js.map +1 -1
- package/dist/upgrade/index.d.ts +2 -2
- package/dist/utils/chromeFetch.d.ts +1 -1
- package/dist/utils/chromeFetch.js +1 -1
- package/dist/utils/clock.d.ts +14 -0
- package/dist/utils/clock.js +28 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/debugFilter.d.ts +1 -1
- package/dist/utils/debugFilter.js +6 -4
- package/dist/utils/debugFilter.js.map +1 -1
- package/dist/utils/delay.d.ts +2 -3
- package/dist/utils/delay.js +10 -16
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/evaluate.js +12 -14
- package/dist/utils/evaluate.js.map +1 -1
- package/dist/utils/ffmpeg.context.d.ts +6 -0
- package/dist/utils/ffmpeg.context.js +31 -0
- package/dist/utils/ffmpeg.context.js.map +1 -0
- package/dist/utils/ffmpeg.d.ts +85 -29
- package/dist/utils/ffmpeg.js +126 -129
- package/dist/utils/ffmpeg.js.map +1 -1
- package/dist/utils/fileLogger.d.ts +18 -2
- package/dist/utils/fileLogger.js +58 -30
- package/dist/utils/fileLogger.js.map +1 -1
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.js +2 -2
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/html.js +1 -3
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/index.d.ts +21 -20
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +16 -20
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/m3u.d.ts +18 -3
- package/dist/utils/m3u.js +28 -14
- package/dist/utils/m3u.js.map +1 -1
- package/dist/utils/memo.d.ts +19 -0
- package/dist/utils/memo.js +53 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/morganStream.js +2 -2
- package/dist/utils/morganStream.js.map +1 -1
- package/dist/utils/pid.d.ts +2 -2
- package/dist/utils/pid.js +2 -2
- package/dist/utils/platform.d.ts +1 -1
- package/dist/utils/platform.js +3 -3
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.js +9 -7
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/sanitize.d.ts +2 -2
- package/dist/utils/sanitize.js +4 -4
- package/dist/utils/timing.d.ts +6 -3
- package/dist/utils/timing.js +10 -6
- package/dist/utils/timing.js.map +1 -1
- package/dist/utils/version.d.ts +3 -2
- package/dist/utils/version.js +14 -27
- package/dist/utils/version.js.map +1 -1
- package/package.json +13 -7
- package/dist/native/intercept.d.ts +0 -35
- package/dist/native/intercept.js +0 -181
- package/dist/native/intercept.js.map +0 -1
- package/dist/routes/config/channels/routes.js +0 -1505
- package/dist/routes/config/channels/routes.js.map +0 -1
|
@@ -1,75 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* Copyright(C) 2024-2026, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* detection.ts: Installation method detection for PrismCast upgrade.
|
|
4
|
+
*
|
|
5
|
+
* The architecture is ports-and-adapters with a strategy registry whose entries are the single source of truth for everything PrismCast knows about its
|
|
6
|
+
* installation methods - including the InstallMethod type, which is derived from the registry rather than declared in parallel with it.
|
|
7
|
+
*
|
|
8
|
+
* - DetectionContext (this file) - the runtime-input port; what every strategy needs to make its decision
|
|
9
|
+
* - ResolvableFields (this file) - the narrow set of InstallInfo fields a strategy's resolver may compute (today: packageDir)
|
|
10
|
+
* - InstallStrategy<M> (this file) - a discriminated union over `upgradeable`; non-upgradeable variants carry manualUpgradeMessage
|
|
11
|
+
* - INSTALL_STRATEGIES (this file) - the registry; the SSOT for what install methods PrismCast recognizes, in priority order
|
|
12
|
+
* - RegisteredMethod, InstallMethod (derived) - the literal-union types produced from the registry; cannot drift from the strategies
|
|
13
|
+
* - InstallInfo (this file) - the dispatcher's output; mirrors the strategy union so non-upgradeable infos carry the message
|
|
14
|
+
* - detectInstallMethod (this file) - the dispatcher; a fold over the registry that builds the right InstallInfo variant
|
|
15
|
+
* - createDefaultDetectionContext (detection.context) - the adapter; the only place that reads import.meta.url, runs subprocesses, or touches the FS
|
|
16
|
+
*
|
|
17
|
+
* Adding a new install method is appending one record to INSTALL_STRATEGIES. The InstallMethod type updates automatically. The dispatcher and the adapter never
|
|
18
|
+
* change. Tests construct DetectionContext literals inline; production calls detectInstallMethod() with no arguments and the default-argument wires through to
|
|
19
|
+
* createDefaultDetectionContext.
|
|
20
|
+
*
|
|
21
|
+
* Why the discriminated union on `upgradeable`. Boolean flags that gate the presence of other fields are a smell - they let callers ask for fields that are not
|
|
22
|
+
* meaningful in the current state, and they push the responsibility for "is this field present?" onto every consumer's runtime check. Splitting the strategy
|
|
23
|
+
* (and its corresponding InstallInfo) into upgradeable vs non-upgradeable variants lets TypeScript enforce that manualUpgradeMessage exists exactly when
|
|
24
|
+
* upgradeable is false. Consumers narrow on `if(!info.upgradeable)` and read the message field with full type safety; the structural impossibility of an
|
|
25
|
+
* upgradeable strategy carrying manual instructions, or a non-upgradeable one omitting them, is enforced at the type level rather than by convention.
|
|
26
|
+
*/
|
|
27
|
+
import { createDefaultDetectionContext } from "./detection.context.js";
|
|
4
28
|
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
29
|
+
// Path marker that distinguishes Homebrew formula installs from npm-on-Homebrew installs. The npm global directory under Homebrew lives at /opt/homebrew/lib/
|
|
30
|
+
// node_modules/prismcast/ on Apple Silicon, which would otherwise produce a false-positive homebrew match; checking for /Cellar/prismcast/ specifically avoids
|
|
31
|
+
// that.
|
|
32
|
+
const HOMEBREW_MARKER = "/Cellar/prismcast/";
|
|
33
|
+
// Path marker for npm local installs. The package's source files live under <project>/node_modules/prismcast/...; the npm-local resolver extracts the project
|
|
34
|
+
// root by slicing the path before this marker. The npm-global strategy also uses the broader "/node_modules/" substring as a cheap prefilter to skip the
|
|
35
|
+
// subprocess call when the path could not possibly be an npm install.
|
|
36
|
+
const NPM_LOCAL_MARKER = "/node_modules/prismcast/";
|
|
37
|
+
const ANY_NODE_MODULES = "/node_modules/";
|
|
8
38
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
39
|
+
* Docker strategy. Matched via the container-environment probe rather than the path - inside a container, path-based detection is irrelevant because the path
|
|
40
|
+
* looks like any other npm install but the upgrade flow is fundamentally different (recreate the container, not run a package manager). Carries the manual
|
|
41
|
+
* upgrade message the consumer prints before the indented command.
|
|
11
42
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
const DOCKER_STRATEGY = {
|
|
44
|
+
displayName: "Docker",
|
|
45
|
+
id: "docker",
|
|
46
|
+
manualUpgradeMessage: [
|
|
47
|
+
"Docker containers cannot be upgraded in-place.",
|
|
48
|
+
"To upgrade, pull the latest image and recreate the container:"
|
|
49
|
+
],
|
|
50
|
+
matches: (ctx) => ctx.isContainer,
|
|
51
|
+
upgradeCommand: "docker pull ghcr.io/hjdhjd/prismcast:latest && docker compose up -d",
|
|
52
|
+
upgradeable: false
|
|
53
|
+
};
|
|
20
54
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
55
|
+
* Homebrew strategy. Matched via the /Cellar/prismcast/ path marker. Homebrew formula installs always live under <prefix>/Cellar/<formula>/<version>/, so the
|
|
56
|
+
* marker is a reliable discriminator on both Intel (/usr/local/Cellar) and Apple Silicon (/opt/homebrew/Cellar) layouts.
|
|
23
57
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
const HOMEBREW_STRATEGY = {
|
|
59
|
+
displayName: "Homebrew",
|
|
60
|
+
id: "homebrew",
|
|
61
|
+
matches: (ctx) => ctx.currentFile.includes(HOMEBREW_MARKER),
|
|
62
|
+
upgradeCommand: "brew update && brew upgrade prismcast",
|
|
63
|
+
upgradeable: true
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* npm global strategy. Matched in two stages: a cheap path prefilter (the running file must be under SOME node_modules tree), then the authoritative subprocess
|
|
67
|
+
* call to `npm prefix -g`. The prefilter avoids spawning npm for paths that obviously can not be an npm install (e.g., a development checkout, a Homebrew Cellar
|
|
68
|
+
* path), keeping the matches predicate inexpensive in the common no-match case.
|
|
69
|
+
*/
|
|
70
|
+
const NPM_GLOBAL_STRATEGY = {
|
|
71
|
+
displayName: "npm (global)",
|
|
72
|
+
id: "npm-global",
|
|
73
|
+
matches: (ctx) => {
|
|
74
|
+
if (!ctx.currentFile.includes(ANY_NODE_MODULES)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const globalPrefix = ctx.runCommand("npm prefix -g");
|
|
78
|
+
if (!globalPrefix) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return ctx.currentFile.startsWith(globalPrefix);
|
|
82
|
+
},
|
|
83
|
+
upgradeCommand: "npm install -g prismcast@latest",
|
|
84
|
+
upgradeable: true
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* npm local strategy. Matched via the /node_modules/prismcast/ path marker; the resolver computes packageDir as the directory above node_modules, but only when
|
|
88
|
+
* that directory actually has a package.json (some weird layouts have an orphaned node_modules without a manifest, and the upgrade runner needs the right cwd
|
|
89
|
+
* for npm install).
|
|
90
|
+
*/
|
|
91
|
+
const NPM_LOCAL_STRATEGY = {
|
|
92
|
+
displayName: "npm (local)",
|
|
93
|
+
id: "npm-local",
|
|
94
|
+
matches: (ctx) => ctx.currentFile.includes(NPM_LOCAL_MARKER),
|
|
95
|
+
resolve: (ctx) => {
|
|
96
|
+
const localIndex = ctx.currentFile.indexOf(NPM_LOCAL_MARKER);
|
|
97
|
+
const projectRoot = ctx.currentFile.slice(0, localIndex);
|
|
98
|
+
return ctx.fileExists(path.join(projectRoot, "package.json")) ? { packageDir: projectRoot } : {};
|
|
99
|
+
},
|
|
100
|
+
upgradeCommand: "npm install prismcast@latest",
|
|
101
|
+
upgradeable: true
|
|
102
|
+
};
|
|
103
|
+
/* The strategy registry as a narrow tuple. Declared `as const` so each entry retains its literal id type, which the RegisteredMethod type derivation below
|
|
104
|
+
* harvests. This name is module-private because consumers don't need the narrow tuple type - they iterate via INSTALL_STRATEGIES (the public, wide-typed alias)
|
|
105
|
+
* which carries the InstallStrategy<RegisteredMethod> shape they want.
|
|
106
|
+
*/
|
|
107
|
+
const STRATEGY_TUPLE = [
|
|
108
|
+
DOCKER_STRATEGY,
|
|
109
|
+
HOMEBREW_STRATEGY,
|
|
110
|
+
NPM_GLOBAL_STRATEGY,
|
|
111
|
+
NPM_LOCAL_STRATEGY
|
|
112
|
+
];
|
|
113
|
+
/**
|
|
114
|
+
* The install-method strategy registry. Same runtime data as STRATEGY_TUPLE; the public name carries the wide InstallStrategy<RegisteredMethod> type so the
|
|
115
|
+
* dispatcher (and any future consumer that iterates) sees the union uniformly. Order is priority order: docker first (container probe is unambiguous), homebrew
|
|
116
|
+
* (path marker is unambiguous), npm-global (requires successful npm prefix lookup), npm-local (broader path marker). Adding a new install method is appending an
|
|
117
|
+
* entry to STRATEGY_TUPLE.
|
|
118
|
+
*/
|
|
119
|
+
export const INSTALL_STRATEGIES = STRATEGY_TUPLE;
|
|
120
|
+
/**
|
|
121
|
+
* The fallback InstallInfo returned when no strategy in the registry matches. Development builds, npx invocations, and unrecognized layouts land here. The
|
|
122
|
+
* upgrade command points at the canonical npm-global install path because that is the most likely successful manual upgrade, but upgradeable is false so the
|
|
123
|
+
* tool prints instructions rather than running the command.
|
|
124
|
+
*/
|
|
125
|
+
export const UNKNOWN_INSTALL = {
|
|
126
|
+
displayName: "Unknown",
|
|
127
|
+
manualUpgradeMessage: ["Unable to detect installation method. Please upgrade manually:"],
|
|
128
|
+
method: "unknown",
|
|
129
|
+
upgradeCommand: "npm install -g prismcast@latest",
|
|
130
|
+
upgradeable: false
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Detects the installation method. Walks INSTALL_STRATEGIES in priority order; on the first match, builds an InstallInfo by composing the strategy's optional
|
|
134
|
+
* resolver output with the strategy's constant fields. The resolver's return type is restricted to ResolvableFields, so it cannot override id, displayName,
|
|
135
|
+
* upgradeCommand, or upgradeable; the spread order also places constants after the resolved fields as belt-and-suspenders. The strategy's `upgradeable`
|
|
136
|
+
* discriminator selects which InstallInfo variant the dispatcher emits, carrying manualUpgradeMessage through for the non-upgradeable case.
|
|
137
|
+
*
|
|
138
|
+
* Pure function of DetectionContext - all I/O happens inside the context's runCommand and fileExists callbacks, which the default adapter wires to real system
|
|
139
|
+
* calls and tests stub inline. Falls back to UNKNOWN_INSTALL when no strategy matches.
|
|
140
|
+
*
|
|
141
|
+
* @param ctx - The runtime context. Defaults to createDefaultDetectionContext() which builds one from real I/O.
|
|
142
|
+
* @returns Installation information.
|
|
143
|
+
*/
|
|
144
|
+
export function detectInstallMethod(ctx = createDefaultDetectionContext()) {
|
|
145
|
+
for (const strategy of INSTALL_STRATEGIES) {
|
|
146
|
+
if (!strategy.matches(ctx)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const base = {
|
|
150
|
+
...strategy.resolve?.(ctx),
|
|
151
|
+
displayName: strategy.displayName,
|
|
152
|
+
method: strategy.id,
|
|
153
|
+
upgradeCommand: strategy.upgradeCommand
|
|
66
154
|
};
|
|
155
|
+
if (strategy.upgradeable) {
|
|
156
|
+
return { ...base, upgradeable: true };
|
|
157
|
+
}
|
|
158
|
+
return { ...base, manualUpgradeMessage: strategy.manualUpgradeMessage, upgradeable: false };
|
|
67
159
|
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
method: "unknown",
|
|
71
|
-
upgradeCommand: "npm install -g prismcast@latest",
|
|
72
|
-
upgradeable: false
|
|
73
|
-
};
|
|
160
|
+
return UNKNOWN_INSTALL;
|
|
74
161
|
}
|
|
75
162
|
//# sourceMappingURL=detection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detection.js","sourceRoot":"","sources":["../../src/upgrade/detection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detection.js","sourceRoot":"","sources":["../../src/upgrade/detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,IAAI,MAAM,WAAW,CAAC;AA4F7B,8JAA8J;AAC9J,+JAA+J;AAC/J,QAAQ;AACR,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAE7C,8JAA8J;AAC9J,yJAAyJ;AACzJ,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,eAAe,GAAG;IAEtB,WAAW,EAAE,QAAQ;IACrB,EAAE,EAAE,QAAQ;IACZ,oBAAoB,EAAE;QAEpB,gDAAgD;QAChD,+DAA+D;KAChE;IACD,OAAO,EAAE,CAAC,GAAqB,EAAW,EAAE,CAAC,GAAG,CAAC,WAAW;IAC5D,cAAc,EAAE,qEAAqE;IACrF,WAAW,EAAE,KAAK;CAC0B,CAAC;AAE/C;;;GAGG;AACH,MAAM,iBAAiB,GAAG;IAExB,WAAW,EAAE,UAAU;IACvB,EAAE,EAAE,UAAU;IACd,OAAO,EAAE,CAAC,GAAqB,EAAW,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC;IACtF,cAAc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./detection.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from "../types/index.
|
|
1
|
+
import type { Nullable } from "../types/index.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Sets the Chrome User-Agent string. Called by browser/index.ts when the browser launches (with the UA) and when it disconnects or closes (with null).
|
|
4
4
|
* @param ua - The User-Agent string from the Chrome browser, or null to clear.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* When PrismCast fetches manifests, segments, decryption keys, and other resources from service CDNs, the requests should appear to originate from the same Chrome
|
|
2
2
|
* browser that is rendering the page. This module stores the Chrome User-Agent string (captured at browser launch) and provides a drop-in fetch() wrapper that
|
|
3
|
-
* injects it into outgoing requests. The setter/getter pattern avoids a circular dependency between utils/ and browser/
|
|
3
|
+
* injects it into outgoing requests. The setter/getter pattern avoids a circular dependency between utils/ and browser/ - browser/index.ts calls the setter at
|
|
4
4
|
* launch and cleanup, while consumer modules import chromeFetch() without importing from browser/.
|
|
5
5
|
*/
|
|
6
6
|
// The Chrome User-Agent string captured at browser launch. Null when the browser is not running.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The time-dependent capability set: sleep, race-with-timeout, and read-the-clock. Decision logic that consumes a Clock is a pure function of this shape -
|
|
3
|
+
* production wires it from real I/O via realClock, tests pass a fake clock literal.
|
|
4
|
+
*/
|
|
5
|
+
export interface Clock {
|
|
6
|
+
readonly now: () => number;
|
|
7
|
+
readonly raceWithTimeout: <T>(promise: Promise<T>, timeoutMs: number, timeoutError?: Error) => Promise<T>;
|
|
8
|
+
readonly sleep: (ms: number) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The default Clock implementation. Delegates to performance.now() for current time, to raceWithTimeout() in delay.ts for promise-vs-timeout races, and to
|
|
12
|
+
* delay() in delay.ts for sleeps. Production callers consume this via the default-arg pattern; tests bypass it by passing a fake-clock literal.
|
|
13
|
+
*/
|
|
14
|
+
export declare const realClock: Clock;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* Copyright(C) 2024-2026, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* clock.ts: The Clock port - the project's abstraction for time-dependent operations. Production code that needs to sleep, race a promise against a timeout, or
|
|
4
|
+
* read the high-resolution clock should consume a Clock when those operations live inside an async chain that tests need to control deterministically. The
|
|
5
|
+
* default realClock delegates to delay() and raceWithTimeout() in delay.ts and to performance.now() in the runtime; tests pass a fake-clock literal that resolves
|
|
6
|
+
* sleeps instantly and chooses raceWithTimeout outcomes explicitly.
|
|
7
|
+
*
|
|
8
|
+
* Why this exists. Node's built-in node:test mock.timers exposes only synchronous tick() and runAll() - it has never shipped a tickAsync/runAllAsync variant on
|
|
9
|
+
* any version. Synchronous tick advances the fake clock but does not drain microtask chains across nested Promise.race / .finally / await delay() patterns; the
|
|
10
|
+
* promises stay pending past the tick. retryOperation is the canonical case: its internal raceWithTimeout -> Promise.race -> .finally -> await delay() chain is
|
|
11
|
+
* exactly the shape mock.timers cannot deterministically resolve. Injecting a Clock sidesteps the runtime gap entirely - tests provide a sleep() that resolves
|
|
12
|
+
* immediately and a raceWithTimeout() that forwards or rejects on demand.
|
|
13
|
+
*
|
|
14
|
+
* When to use a Clock vs. a direct delay()/raceWithTimeout() import. Use the direct imports when the production code's tests can fake time with mock.timers and
|
|
15
|
+
* the call sites are shallow enough for synchronous tick() to drain. Reach for Clock injection only when nested async chains break that pattern, or when the
|
|
16
|
+
* test surface needs to assert on the *schedule* (number and durations of sleeps) rather than just the eventual outcome.
|
|
17
|
+
*/
|
|
18
|
+
import { delay, raceWithTimeout } from "./delay.js";
|
|
19
|
+
/**
|
|
20
|
+
* The default Clock implementation. Delegates to performance.now() for current time, to raceWithTimeout() in delay.ts for promise-vs-timeout races, and to
|
|
21
|
+
* delay() in delay.ts for sleeps. Production callers consume this via the default-arg pattern; tests bypass it by passing a fake-clock literal.
|
|
22
|
+
*/
|
|
23
|
+
export const realClock = {
|
|
24
|
+
now: () => performance.now(),
|
|
25
|
+
raceWithTimeout,
|
|
26
|
+
sleep: delay
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/utils/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuBpD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAU;IAE9B,GAAG,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;IAC5B,eAAe;IACf,KAAK,EAAE,KAAK;CACb,CAAC"}
|
|
@@ -28,6 +28,6 @@ export interface DebugCategory {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Static registry of all known debug categories with descriptions. Sorted alphabetically by category. The /debug endpoint uses this to render hierarchical checkboxes.
|
|
31
|
-
* Parent groups (e.g., "streaming", "timing", "tuning") are derived by the UI from the colon-separated namespaces
|
|
31
|
+
* Parent groups (e.g., "streaming", "timing", "tuning") are derived by the UI from the colon-separated namespaces - only leaf categories are declared here.
|
|
32
32
|
*/
|
|
33
33
|
export declare const DEBUG_CATEGORIES: readonly DebugCategory[];
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
// Whether any debug output is configured at all. Fast-path check avoids category string work when debug is off.
|
|
19
19
|
let anyEnabled = false;
|
|
20
|
-
// Whether wildcard (*) was specified
|
|
20
|
+
// Whether wildcard (*) was specified - all categories pass unless explicitly excluded.
|
|
21
21
|
let wildcardEnabled = false;
|
|
22
22
|
// Categories to include (exact or prefix match).
|
|
23
23
|
const includeSet = new Set();
|
|
@@ -117,7 +117,7 @@ export function getCurrentPattern() {
|
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Static registry of all known debug categories with descriptions. Sorted alphabetically by category. The /debug endpoint uses this to render hierarchical checkboxes.
|
|
120
|
-
* Parent groups (e.g., "streaming", "timing", "tuning") are derived by the UI from the colon-separated namespaces
|
|
120
|
+
* Parent groups (e.g., "streaming", "timing", "tuning") are derived by the UI from the colon-separated namespaces - only leaf categories are declared here.
|
|
121
121
|
*/
|
|
122
122
|
export const DEBUG_CATEGORIES = [
|
|
123
123
|
{ category: "browser:lifecycle", description: "Browser lifecycle: launch, close, stale page cleanup, restart." },
|
|
@@ -126,14 +126,15 @@ export const DEBUG_CATEGORIES = [
|
|
|
126
126
|
{ category: "native:coordinator", description: "Native streaming decisions: interception result, probe result, capture teardown, proxy start." },
|
|
127
127
|
{ category: "native:decrypt", description: "AES-128 decryption: key fetch, IV source (explicit vs. sequence), segment sizes." },
|
|
128
128
|
{ category: "native:intercept", description: "CDP manifest interception: listener installed, .m3u8 URLs observed, master identified, timeout." },
|
|
129
|
-
{ category: "native:manifest", description: "Raw variant manifest body from service
|
|
129
|
+
{ category: "native:manifest", description: "Raw variant manifest body from service - verbose, use for diagnosing DAI/ad stitching issues." },
|
|
130
130
|
{ category: "native:monitor", description: "Native health: segment staleness, error counts, L2/L3 recovery actions, capture fallback." },
|
|
131
131
|
{ category: "native:probe", description: "DRM probe: variant count, bandwidths, encryption classification, key accessibility, cache hit/miss." },
|
|
132
132
|
{ category: "native:proxy", description: "Manifest polling, segment fetch/store, playlist generation, segment rotation, key rotation." },
|
|
133
133
|
{ category: "native:token", description: "Token refresh: expiry parsed, timer scheduled, refresh triggered, manifest acquired." },
|
|
134
|
+
{ category: "persistence:write", description: "File store writes: per-mutation save to disk after successful atomic temp+rename and integrity check." },
|
|
134
135
|
{ category: "precache", description: "Channel lineup precaching: deferred runs, service filter skips." },
|
|
135
|
-
{ category: "recovery:general", description: "General recovery: browser re-minimize, monitor abort." },
|
|
136
136
|
{ category: "recovery:context", description: "Video context: frame detachment, re-search." },
|
|
137
|
+
{ category: "recovery:general", description: "General recovery: browser re-minimize, monitor abort." },
|
|
137
138
|
{ category: "recovery:nav", description: "Page navigation recovery: new tab detection, URL validation." },
|
|
138
139
|
{ category: "recovery:resolution", description: "Video resolution monitoring: ABR degradation detection, grace periods, recovery escalation." },
|
|
139
140
|
{ category: "recovery:segments", description: "Segment production: self-heal detection." },
|
|
@@ -158,6 +159,7 @@ export const DEBUG_CATEGORIES = [
|
|
|
158
159
|
{ category: "timing:tune", description: "Tune waterfall: navigation, channel selection, video ready." },
|
|
159
160
|
{ category: "tuning:cox", description: "Cox Contour TV: channelmap API interception, SPA channel switching, Watch Now modal dismissal." },
|
|
160
161
|
{ category: "tuning:directv", description: "DirecTV Stream: interceptor tuning, cache, logo click fallback." },
|
|
162
|
+
{ category: "tuning:fox", description: "Fox.com guide grid: console bridge, page errors, request failures, channel-switch diagnostics." },
|
|
161
163
|
{ category: "tuning:hbo", description: "HBO Max: tab URL discovery, channel rail, navigation." },
|
|
162
164
|
{ category: "tuning:hulu", description: "Hulu Live guide grid: binary search, cache, click retries." },
|
|
163
165
|
{ category: "tuning:sling", description: "Sling TV guide grid: binary search, cache, click retries." },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugFilter.js","sourceRoot":"","sources":["../../src/utils/debugFilter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,gHAAgH;AAChH,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,uFAAuF;AACvF,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,iDAAiD;AACjD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;AAErC,4FAA4F;AAC5F,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;AAErC;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,QAAgB,EAAE,QAAqB;IAEzD,IAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAI,MAAM,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4FAA4F,EAAE;IAC3I,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,gGAAgG,EAAE;IAC7I,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,iCAAiC,EAAE;CAC5E,CAAC"}
|
package/dist/utils/delay.d.ts
CHANGED
|
@@ -8,8 +8,7 @@ export interface CancellableTimeout {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Creates a cancellable timeout for use with Promise.race. Returns a promise that resolves to false after the specified delay, and a cancel function that clears
|
|
11
|
-
* the timer
|
|
12
|
-
* Promise.race.
|
|
11
|
+
* the timer so it does not hold an event loop reference after the race is won by another promise.
|
|
13
12
|
* @param ms - The timeout duration in milliseconds.
|
|
14
13
|
* @returns An object with the timeout promise and a cancel function.
|
|
15
14
|
*/
|
|
@@ -27,7 +26,7 @@ export declare function cancellableTimeout(ms: number): CancellableTimeout;
|
|
|
27
26
|
*/
|
|
28
27
|
export declare function raceWithTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutError?: Error): Promise<T>;
|
|
29
28
|
/**
|
|
30
|
-
* Creates a promise that resolves after the specified delay.
|
|
29
|
+
* Creates a promise that resolves after the specified delay. Wraps node:timers/promises.setTimeout so the codebase has a single canonical "sleep" name.
|
|
31
30
|
* @param ms - The delay duration in milliseconds.
|
|
32
31
|
* @returns A promise that resolves after the specified delay.
|
|
33
32
|
*/
|
package/dist/utils/delay.js
CHANGED
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
*
|
|
3
3
|
* delay.ts: Async delay and timeout utilities for PrismCast.
|
|
4
4
|
*/
|
|
5
|
+
import { setTimeout as nodeSleep } from "node:timers/promises";
|
|
5
6
|
/**
|
|
6
7
|
* Creates a cancellable timeout for use with Promise.race. Returns a promise that resolves to false after the specified delay, and a cancel function that clears
|
|
7
|
-
* the timer
|
|
8
|
-
* Promise.race.
|
|
8
|
+
* the timer so it does not hold an event loop reference after the race is won by another promise.
|
|
9
9
|
* @param ms - The timeout duration in milliseconds.
|
|
10
10
|
* @returns An object with the timeout promise and a cancel function.
|
|
11
11
|
*/
|
|
12
12
|
export function cancellableTimeout(ms) {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
timer = setTimeout(() => { resolve(false); }, ms);
|
|
16
|
-
});
|
|
13
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
14
|
+
const timer = setTimeout(() => { resolve(false); }, ms);
|
|
17
15
|
return { cancel: () => { clearTimeout(timer); }, promise };
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
@@ -28,22 +26,18 @@ export function cancellableTimeout(ms) {
|
|
|
28
26
|
* @returns The resolved value of the promise.
|
|
29
27
|
*/
|
|
30
28
|
export async function raceWithTimeout(promise, timeoutMs, timeoutError) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, timeoutMs);
|
|
36
|
-
});
|
|
29
|
+
const { promise: timeoutPromise, reject: signalTimeout } = Promise.withResolvers();
|
|
30
|
+
const timer = setTimeout(() => {
|
|
31
|
+
signalTimeout(timeoutError ?? new Error("Operation timed out after " + String(timeoutMs) + "ms."));
|
|
32
|
+
}, timeoutMs);
|
|
37
33
|
return Promise.race([promise, timeoutPromise]).finally(() => { clearTimeout(timer); });
|
|
38
34
|
}
|
|
39
35
|
/**
|
|
40
|
-
* Creates a promise that resolves after the specified delay.
|
|
36
|
+
* Creates a promise that resolves after the specified delay. Wraps node:timers/promises.setTimeout so the codebase has a single canonical "sleep" name.
|
|
41
37
|
* @param ms - The delay duration in milliseconds.
|
|
42
38
|
* @returns A promise that resolves after the specified delay.
|
|
43
39
|
*/
|
|
44
40
|
export async function delay(ms) {
|
|
45
|
-
|
|
46
|
-
setTimeout(resolve, ms);
|
|
47
|
-
});
|
|
41
|
+
await nodeSleep(ms);
|
|
48
42
|
}
|
|
49
43
|
//# sourceMappingURL=delay.js.map
|
package/dist/utils/delay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAY/D;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAE3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAExD,OAAO,EAAE,MAAM,EAAE,GAAS,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAI,OAAmB,EAAE,SAAiB,EAAE,YAAoB;IAEnG,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC1F,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAE5B,aAAa,CAAC,YAAY,IAAI,IAAI,KAAK,CAAC,4BAA4B,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACrG,CAAC,EAAE,SAAS,CAAC,CAAC;IAEd,OAAO,OAAO,CAAC,IAAI,CAAC,CAAE,OAAO,EAAE,cAAc,CAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,EAAU;IAEpC,MAAM,SAAS,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/utils/evaluate.js
CHANGED
|
@@ -8,11 +8,11 @@ import { raceWithTimeout } from "./delay.js";
|
|
|
8
8
|
* 2. Timeout: A configurable timeout (default 15 seconds) provides a safety net for evaluate calls that hang. This catches cases where the browser is unresponsive but
|
|
9
9
|
* the stream hasn't been explicitly terminated yet.
|
|
10
10
|
*
|
|
11
|
-
* The wrapper automatically retrieves the abort signal from
|
|
12
|
-
* (e.g., during browser initialization), it falls back to timeout-only behavior.
|
|
11
|
+
* The wrapper automatically retrieves the abort signal from this module's local AbortController map using the stream context from AsyncLocalStorage. If no
|
|
12
|
+
* stream context is available (e.g., during browser initialization), it falls back to timeout-only behavior.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* When aborting or timing out, the underlying CDP call is still pending in Puppeteer - we just stop waiting for it locally. We attach a no-op .catch() to the
|
|
15
|
+
* evaluate promise to suppress unhandled rejection warnings when the CDP call eventually completes or times out.
|
|
16
16
|
*/
|
|
17
17
|
// Default timeout for evaluate calls in milliseconds.
|
|
18
18
|
const DEFAULT_EVALUATE_TIMEOUT = 15000;
|
|
@@ -102,16 +102,14 @@ export async function evaluateWithAbort(context, pageFunction, args, timeoutMs)
|
|
|
102
102
|
const timeoutRace = raceWithTimeout(evaluatePromise, timeout, new EvaluateTimeoutError(timeout));
|
|
103
103
|
// If we have an abort signal, add a third racer that rejects when the abort fires.
|
|
104
104
|
if (signal) {
|
|
105
|
-
const abortPromise =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
signal.addEventListener("abort", () => {
|
|
112
|
-
|
|
113
|
-
}, { once: true });
|
|
114
|
-
});
|
|
105
|
+
const { promise: abortPromise, reject: rejectAbort } = Promise.withResolvers();
|
|
106
|
+
// Check if already aborted (race condition protection).
|
|
107
|
+
if (signal.aborted) {
|
|
108
|
+
rejectAbort(new EvaluateAbortError());
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
signal.addEventListener("abort", () => { rejectAbort(new EvaluateAbortError()); }, { once: true });
|
|
112
|
+
}
|
|
115
113
|
return Promise.race([timeoutRace, abortPromise]);
|
|
116
114
|
}
|
|
117
115
|
return timeoutRace;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/utils/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AAEH,sDAAsD;AACtD,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAEvC,gKAAgK;AAChK,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAmB,EAAE,UAA2B;IAEtF,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAE3D,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAEhD,OAAO,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IAEpD,OAAO,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,SAAiB;QAE3B,KAAK,CAAC,2BAA2B,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,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C;QAEnB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,gKAAgK;IAChK,mDAAmD;IACnD,MAAM,eAAe,GAAG,IAAI,CAAC,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC,YAAoD,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACjF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEjC,mKAAmK;IACnK,gHAAgH;IAChH,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,GAAkF,CAAC,CAAC,CAAC;IAEhH,oHAAoH;IACpH,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjG,mFAAmF;IACnF,IAAG,MAAM,EAAE,CAAC;QAEV,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;QAEtF,wDAAwD;QACxD,IAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YAElB,WAAW,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YAEN,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACrG,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAE,WAAW,EAAE,YAAY,CAAE,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import bundledFFmpegPath from "ffmpeg-for-homebridge";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
/**
|
|
6
|
+
* Probes whether FFmpeg works at the given path by running it with -version. Resolves to true when the spawn succeeds and exit code is 0; false on any spawn
|
|
7
|
+
* error (binary not found, permission denied) or non-zero exit. Used by the path-resolution loop to confirm a candidate path actually launches.
|
|
8
|
+
* @param pathToCheck - Full path to the FFmpeg executable.
|
|
9
|
+
* @returns Promise resolving to true if FFmpeg runs successfully at this path.
|
|
10
|
+
*/
|
|
11
|
+
async function checkFFmpegAtPath(pathToCheck) {
|
|
12
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
13
|
+
const ffmpeg = spawn(pathToCheck, ["-version"], { stdio: ["ignore", "ignore", "ignore"] });
|
|
14
|
+
ffmpeg.on("error", () => { resolve(false); });
|
|
15
|
+
ffmpeg.on("exit", (code) => { resolve(code === 0); });
|
|
16
|
+
return promise;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds the default FFmpegContext from real runtime I/O.
|
|
20
|
+
* @returns An FFmpegContext populated from the live process.
|
|
21
|
+
*/
|
|
22
|
+
export function createDefaultFFmpegContext() {
|
|
23
|
+
return {
|
|
24
|
+
bundledPath: bundledFFmpegPath,
|
|
25
|
+
exists: existsSync,
|
|
26
|
+
homedir,
|
|
27
|
+
platform: process.platform,
|
|
28
|
+
probe: checkFFmpegAtPath
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ffmpeg.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffmpeg.context.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.context.ts"],"names":[],"mappings":"AAOA,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;GAKG;AACH,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IAElD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAW,CAAC;IAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,CAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAE,EAAE,CAAC,CAAC;IAE7F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IAExC,OAAO;QAEL,WAAW,EAAE,iBAAiB;QAC9B,MAAM,EAAE,UAAU;QAClB,OAAO;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,iBAAiB;KACzB,CAAC;AACJ,CAAC"}
|