prismcast 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +41 -1
- package/dist/app.js +164 -76
- package/dist/app.js.map +1 -1
- package/dist/browser/blockedPage.d.ts +0 -1
- package/dist/browser/browserSupervisor.d.ts +34 -5
- package/dist/browser/browserSupervisor.js +39 -12
- package/dist/browser/browserSupervisor.js.map +1 -1
- package/dist/browser/cdp.d.ts +58 -6
- package/dist/browser/cdp.js +147 -9
- package/dist/browser/cdp.js.map +1 -1
- package/dist/browser/channelSelection.d.ts +18 -6
- package/dist/browser/channelSelection.js +47 -36
- package/dist/browser/channelSelection.js.map +1 -1
- package/dist/browser/consent.d.ts +33 -4
- package/dist/browser/consent.js +87 -50
- package/dist/browser/consent.js.map +1 -1
- package/dist/browser/display.d.ts +0 -1
- package/dist/browser/hlsPlaylistObserver.d.ts +3 -2
- package/dist/browser/hlsPlaylistObserver.js +11 -6
- package/dist/browser/hlsPlaylistObserver.js.map +1 -1
- package/dist/browser/index.d.ts +273 -59
- package/dist/browser/index.js +768 -255
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/launchGovernor.d.ts +0 -1
- package/dist/browser/login.d.ts +11 -10
- package/dist/browser/login.js +42 -33
- package/dist/browser/login.js.map +1 -1
- package/dist/browser/manifestInterceptor.d.ts +14 -5
- package/dist/browser/manifestInterceptor.js +26 -13
- package/dist/browser/manifestInterceptor.js.map +1 -1
- package/dist/browser/navigation.d.ts +28 -0
- package/dist/browser/navigation.js +57 -0
- package/dist/browser/navigation.js.map +1 -0
- package/dist/browser/pageStaleness.d.ts +1 -2
- package/dist/browser/pageStaleness.js +9 -9
- package/dist/browser/pageStaleness.js.map +1 -1
- package/dist/browser/precaching.d.ts +27 -13
- package/dist/browser/precaching.js +219 -73
- package/dist/browser/precaching.js.map +1 -1
- package/dist/browser/tabCapture.d.ts +97 -0
- package/dist/browser/tabCapture.js +314 -0
- package/dist/browser/tabCapture.js.map +1 -0
- package/dist/browser/tabNetworkObserver.d.ts +0 -1
- package/dist/browser/tabSelection.d.ts +117 -0
- package/dist/browser/tabSelection.js +547 -0
- package/dist/browser/tabSelection.js.map +1 -0
- package/dist/browser/tuning/cache.d.ts +0 -1
- package/dist/browser/tuning/comcastPolymer.d.ts +0 -1
- package/dist/browser/tuning/comcastPolymer.js +18 -19
- package/dist/browser/tuning/comcastPolymer.js.map +1 -1
- package/dist/browser/tuning/cox.d.ts +0 -1
- package/dist/browser/tuning/directv.d.ts +0 -1
- package/dist/browser/tuning/directv.js +12 -13
- package/dist/browser/tuning/directv.js.map +1 -1
- package/dist/browser/tuning/fox.d.ts +0 -1
- package/dist/browser/tuning/fox.js +2 -2
- package/dist/browser/tuning/fox.js.map +1 -1
- package/dist/browser/tuning/gridSearch.d.ts +0 -1
- package/dist/browser/tuning/hbo.d.ts +0 -1
- package/dist/browser/tuning/hbo.js +2 -2
- package/dist/browser/tuning/hbo.js.map +1 -1
- package/dist/browser/tuning/hulu.d.ts +14 -2
- package/dist/browser/tuning/hulu.js +150 -24
- package/dist/browser/tuning/hulu.js.map +1 -1
- package/dist/browser/tuning/shared.d.ts +1 -2
- package/dist/browser/tuning/shared.js +1 -1
- package/dist/browser/tuning/sling.d.ts +0 -1
- package/dist/browser/tuning/sling.js +17 -22
- package/dist/browser/tuning/sling.js.map +1 -1
- package/dist/browser/tuning/spectrum.d.ts +0 -1
- package/dist/browser/tuning/thumbnailRow.d.ts +0 -1
- package/dist/browser/tuning/tileClick.d.ts +0 -1
- package/dist/browser/tuning/xfinity.d.ts +0 -1
- package/dist/browser/tuning/youtubeTv.d.ts +0 -1
- package/dist/browser/tuning/youtubeTv.js +1 -2
- package/dist/browser/tuning/youtubeTv.js.map +1 -1
- package/dist/browser/video.d.ts +55 -33
- package/dist/browser/video.js +213 -169
- package/dist/browser/video.js.map +1 -1
- package/dist/browser/windowSync.d.ts +45 -0
- package/dist/browser/windowSync.js +153 -0
- package/dist/browser/windowSync.js.map +1 -0
- package/dist/channels/index.d.ts +7 -1
- package/dist/channels/index.js +24 -8
- package/dist/channels/index.js.map +1 -1
- package/dist/config/channelForm.d.ts +0 -1
- package/dist/config/channelIdentity.d.ts +27 -0
- package/dist/config/channelIdentity.js +72 -0
- package/dist/config/channelIdentity.js.map +1 -0
- package/dist/config/channelSort.d.ts +25 -0
- package/dist/config/channelSort.js +101 -0
- package/dist/config/channelSort.js.map +1 -0
- package/dist/config/consistencyProbe.d.ts +0 -1
- package/dist/config/consistencyProbe.js +1 -1
- package/dist/config/consistencyProbe.js.map +1 -1
- package/dist/config/health.d.ts +3 -2
- package/dist/config/health.js +41 -31
- package/dist/config/health.js.map +1 -1
- package/dist/config/index.d.ts +12 -1
- package/dist/config/index.js +77 -31
- package/dist/config/index.js.map +1 -1
- package/dist/config/paths.d.ts +17 -2
- package/dist/config/paths.js +21 -1
- package/dist/config/paths.js.map +1 -1
- package/dist/config/persistence.context.d.ts +0 -1
- package/dist/config/persistence.d.ts +8 -4
- package/dist/config/persistence.js +143 -82
- package/dist/config/persistence.js.map +1 -1
- package/dist/config/presets.d.ts +0 -1
- package/dist/config/profiles.d.ts +9 -4
- package/dist/config/profiles.js +39 -6
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/providerLineups.d.ts +0 -1
- package/dist/config/providerLineups.js +0 -3
- package/dist/config/providerLineups.js.map +1 -1
- package/dist/config/reactivity.d.ts +0 -1
- package/dist/config/servicePacks.d.ts +0 -1
- package/dist/config/services.d.ts +1 -47
- package/dist/config/services.js +4 -135
- package/dist/config/services.js.map +1 -1
- package/dist/config/sites.d.ts +0 -9
- package/dist/config/sites.js +82 -98
- package/dist/config/sites.js.map +1 -1
- package/dist/config/userChannels.d.ts +22 -29
- package/dist/config/userChannels.js +47 -65
- package/dist/config/userChannels.js.map +1 -1
- package/dist/config/userConfig.d.ts +19 -4
- package/dist/config/userConfig.js +123 -25
- package/dist/config/userConfig.js.map +1 -1
- package/dist/config/userProfiles.d.ts +2 -3
- package/dist/config/userProfiles.js +16 -13
- package/dist/config/userProfiles.js.map +1 -1
- package/dist/hdhr/channelMap.d.ts +0 -1
- package/dist/hdhr/deviceId.d.ts +0 -1
- package/dist/hdhr/discover.d.ts +0 -1
- package/dist/hdhr/getHandlers.d.ts +0 -1
- package/dist/hdhr/identity.d.ts +0 -1
- package/dist/hdhr/index.d.ts +0 -1
- package/dist/hdhr/protocol.d.ts +1 -2
- package/dist/hdhr/protocol.js +1 -1
- package/dist/hdhr/tunerState.d.ts +0 -1
- package/dist/hdhr/udp.d.ts +0 -1
- package/dist/hdhr/udp.js +16 -4
- package/dist/hdhr/udp.js.map +1 -1
- package/dist/identity.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/native/codecInference.d.ts +5 -4
- package/dist/native/codecInference.js +12 -7
- package/dist/native/codecInference.js.map +1 -1
- package/dist/native/decrypt.d.ts +10 -3
- package/dist/native/decrypt.js +9 -5
- package/dist/native/decrypt.js.map +1 -1
- package/dist/native/index.d.ts +26 -24
- package/dist/native/index.js +26 -20
- package/dist/native/index.js.map +1 -1
- package/dist/native/probe.d.ts +7 -10
- package/dist/native/probe.js +41 -37
- package/dist/native/probe.js.map +1 -1
- package/dist/native/proxy.d.ts +3 -4
- package/dist/native/proxy.js +91 -69
- package/dist/native/proxy.js.map +1 -1
- package/dist/native/tokenExpiry.d.ts +0 -1
- package/dist/routes/assets.d.ts +0 -1
- package/dist/routes/auth.d.ts +0 -1
- package/dist/routes/auth.js +1 -1
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/cdp.d.ts +11 -5
- package/dist/routes/cdp.js +91 -63
- package/dist/routes/cdp.js.map +1 -1
- package/dist/routes/channels.d.ts +0 -1
- package/dist/routes/clientActions.d.ts +0 -1
- package/dist/routes/components.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/browse.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/bulk.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/bulk.js +3 -3
- package/dist/routes/config/channels/endpoints/bulk.js.map +1 -1
- package/dist/routes/config/channels/endpoints/crud.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/crud.js +4 -3
- package/dist/routes/config/channels/endpoints/crud.js.map +1 -1
- package/dist/routes/config/channels/endpoints/importExport.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/importExport.js +7 -3
- package/dist/routes/config/channels/endpoints/importExport.js.map +1 -1
- package/dist/routes/config/channels/endpoints/predefined.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/prefs.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/prefs.js +1 -1
- package/dist/routes/config/channels/endpoints/prefs.js.map +1 -1
- package/dist/routes/config/channels/endpoints/service.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/service.js +8 -5
- package/dist/routes/config/channels/endpoints/service.js.map +1 -1
- package/dist/routes/config/channels/endpoints/tags.d.ts +0 -1
- package/dist/routes/config/channels/endpoints/tags.js +3 -3
- package/dist/routes/config/channels/endpoints/tags.js.map +1 -1
- package/dist/routes/config/channels/healthBridge.d.ts +4 -1
- package/dist/routes/config/channels/healthBridge.js +9 -5
- package/dist/routes/config/channels/healthBridge.js.map +1 -1
- package/dist/routes/config/channels/http/handler.d.ts +0 -1
- package/dist/routes/config/channels/http/playlistHint.d.ts +0 -1
- package/dist/routes/config/channels/http/serviceWarning.d.ts +0 -1
- package/dist/routes/config/channels/http/serviceWarning.js +1 -1
- package/dist/routes/config/channels/http/serviceWarning.js.map +1 -1
- package/dist/routes/config/channels/index.d.ts +0 -1
- package/dist/routes/config/channels/setup.d.ts +0 -1
- package/dist/routes/config/channels/table.d.ts +0 -1
- package/dist/routes/config/channels/table.js +66 -134
- package/dist/routes/config/channels/table.js.map +1 -1
- package/dist/routes/config/http/envelope.d.ts +1 -2
- package/dist/routes/config/index.d.ts +5 -5
- package/dist/routes/config/index.js +7 -5
- package/dist/routes/config/index.js.map +1 -1
- package/dist/routes/config/services.d.ts +0 -1
- package/dist/routes/config/services.js +17 -19
- package/dist/routes/config/services.js.map +1 -1
- package/dist/routes/config/settings.d.ts +6 -15
- package/dist/routes/config/settings.js +16 -35
- package/dist/routes/config/settings.js.map +1 -1
- package/dist/routes/debug.d.ts +0 -1
- package/dist/routes/debug.js +1 -1
- package/dist/routes/debug.js.map +1 -1
- package/dist/routes/health.d.ts +16 -8
- package/dist/routes/health.js +27 -12
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/hls.d.ts +0 -1
- package/dist/routes/icons.d.ts +0 -1
- package/dist/routes/index.d.ts +0 -1
- package/dist/routes/logs.d.ts +3 -2
- package/dist/routes/logs.js +54 -14
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/mpegts.d.ts +0 -1
- package/dist/routes/play.d.ts +0 -1
- package/dist/routes/playlist.d.ts +0 -1
- package/dist/routes/playlist.js +2 -1
- package/dist/routes/playlist.js.map +1 -1
- package/dist/routes/root/content.d.ts +0 -1
- package/dist/routes/root/content.js +32 -11
- package/dist/routes/root/content.js.map +1 -1
- package/dist/routes/root/index.d.ts +10 -1
- package/dist/routes/root/index.js +17 -7
- package/dist/routes/root/index.js.map +1 -1
- package/dist/routes/root/scripts/channels.d.ts +0 -1
- package/dist/routes/root/scripts/channels.js +10 -20
- package/dist/routes/root/scripts/channels.js.map +1 -1
- package/dist/routes/root/scripts/clientEscape.d.ts +0 -1
- package/dist/routes/root/scripts/clientEscape.js +1 -1
- package/dist/routes/root/scripts/clientUrl.d.ts +0 -1
- package/dist/routes/root/scripts/config.d.ts +0 -1
- package/dist/routes/root/scripts/config.js +8 -29
- package/dist/routes/root/scripts/config.js.map +1 -1
- package/dist/routes/root/scripts/index.d.ts +0 -1
- package/dist/routes/root/scripts/shared.d.ts +0 -1
- package/dist/routes/root/scripts/shared.js +16 -13
- package/dist/routes/root/scripts/shared.js.map +1 -1
- package/dist/routes/root/scripts/status.d.ts +0 -1
- package/dist/routes/root/scripts/status.handlers.d.ts +3 -1
- package/dist/routes/root/scripts/status.handlers.js +52 -26
- package/dist/routes/root/scripts/status.handlers.js.map +1 -1
- package/dist/routes/root/styles.d.ts +0 -1
- package/dist/routes/root/styles.js +10 -18
- package/dist/routes/root/styles.js.map +1 -1
- package/dist/routes/services.d.ts +0 -1
- package/dist/routes/services.js +1 -1
- package/dist/routes/services.js.map +1 -1
- package/dist/routes/sse.d.ts +3 -2
- package/dist/routes/sse.js +7 -3
- package/dist/routes/sse.js.map +1 -1
- package/dist/routes/streams.d.ts +4 -2
- package/dist/routes/streams.js +8 -5
- package/dist/routes/streams.js.map +1 -1
- package/dist/routes/theme.d.ts +0 -1
- package/dist/routes/theme.js +3 -3
- package/dist/routes/theme.js.map +1 -1
- package/dist/routes/ui.d.ts +0 -1
- package/dist/routes/ui.js +5 -5
- package/dist/routes/ui.js.map +1 -1
- package/dist/routes/upgrade.d.ts +0 -1
- package/dist/routes/upgrade.js +2 -1
- package/dist/routes/upgrade.js.map +1 -1
- package/dist/service/commands.context.d.ts +0 -1
- package/dist/service/commands.context.js +7 -1
- package/dist/service/commands.context.js.map +1 -1
- package/dist/service/commands.d.ts +0 -1
- package/dist/service/generators.context.d.ts +0 -1
- package/dist/service/generators.d.ts +0 -1
- package/dist/service/index.d.ts +0 -1
- package/dist/streaming/captureLock.d.ts +1 -2
- package/dist/streaming/captureLock.js +8 -7
- package/dist/streaming/captureLock.js.map +1 -1
- package/dist/streaming/captureSession.d.ts +0 -1
- package/dist/streaming/clients.d.ts +4 -3
- package/dist/streaming/clients.js +5 -4
- package/dist/streaming/clients.js.map +1 -1
- package/dist/streaming/codec.d.ts +0 -1
- package/dist/streaming/fmp4Segmenter.d.ts +11 -6
- package/dist/streaming/fmp4Segmenter.js +39 -17
- package/dist/streaming/fmp4Segmenter.js.map +1 -1
- package/dist/streaming/hls.d.ts +96 -3
- package/dist/streaming/hls.js +282 -171
- package/dist/streaming/hls.js.map +1 -1
- package/dist/streaming/hlsResume.d.ts +8 -5
- package/dist/streaming/hlsResume.js +10 -8
- package/dist/streaming/hlsResume.js.map +1 -1
- package/dist/streaming/hlsSegments.d.ts +11 -8
- package/dist/streaming/hlsSegments.js +38 -18
- package/dist/streaming/hlsSegments.js.map +1 -1
- package/dist/streaming/lifecycle.d.ts +5 -4
- package/dist/streaming/lifecycle.js +43 -13
- package/dist/streaming/lifecycle.js.map +1 -1
- package/dist/streaming/monitor.d.ts +14 -3
- package/dist/streaming/monitor.js +447 -234
- package/dist/streaming/monitor.js.map +1 -1
- package/dist/streaming/mp4Parser.d.ts +0 -1
- package/dist/streaming/mpegts.d.ts +11 -1
- package/dist/streaming/mpegts.js +92 -28
- package/dist/streaming/mpegts.js.map +1 -1
- package/dist/streaming/playlistBuilder.d.ts +0 -1
- package/dist/streaming/preroll.d.ts +34 -15
- package/dist/streaming/preroll.js +32 -30
- package/dist/streaming/preroll.js.map +1 -1
- package/dist/streaming/pretune.d.ts +2 -3
- package/dist/streaming/pretune.js +45 -45
- package/dist/streaming/pretune.js.map +1 -1
- package/dist/streaming/pretuneTimers.d.ts +16 -12
- package/dist/streaming/pretuneTimers.js +27 -37
- package/dist/streaming/pretuneTimers.js.map +1 -1
- package/dist/streaming/recovery.d.ts +97 -9
- package/dist/streaming/recovery.js +96 -18
- package/dist/streaming/recovery.js.map +1 -1
- package/dist/streaming/registry.d.ts +102 -15
- package/dist/streaming/registry.js +90 -5
- package/dist/streaming/registry.js.map +1 -1
- package/dist/streaming/setup.d.ts +90 -32
- package/dist/streaming/setup.js +379 -248
- package/dist/streaming/setup.js.map +1 -1
- package/dist/streaming/showInfo.d.ts +8 -4
- package/dist/streaming/showInfo.js +54 -45
- package/dist/streaming/showInfo.js.map +1 -1
- package/dist/streaming/statusEmitter.d.ts +5 -3
- package/dist/streaming/statusEmitter.js +20 -8
- package/dist/streaming/statusEmitter.js.map +1 -1
- package/dist/types/channels.d.ts +0 -1
- package/dist/types/channels.js +0 -4
- package/dist/types/channels.js.map +1 -1
- package/dist/types/config.d.ts +0 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/profiles.d.ts +51 -9
- package/dist/types/profiles.js +35 -1
- package/dist/types/profiles.js.map +1 -1
- package/dist/types/selection.d.ts +10 -1
- package/dist/types/shared.d.ts +0 -1
- package/dist/types/streaming.d.ts +8 -1
- package/dist/types/streaming.js +7 -0
- package/dist/types/streaming.js.map +1 -1
- package/dist/upgrade/commands.context.d.ts +0 -1
- package/dist/upgrade/commands.d.ts +0 -1
- package/dist/upgrade/commands.js +1 -1
- package/dist/upgrade/commands.js.map +1 -1
- package/dist/upgrade/detection.context.d.ts +0 -1
- package/dist/upgrade/detection.d.ts +1 -2
- package/dist/upgrade/index.d.ts +0 -1
- package/dist/upgrade/lifecycle.context.d.ts +2 -1
- package/dist/upgrade/lifecycle.context.js +9 -4
- package/dist/upgrade/lifecycle.context.js.map +1 -1
- package/dist/upgrade/lifecycle.d.ts +0 -1
- package/dist/upgrade/pathHandle.d.ts +0 -1
- package/dist/utils/bootSession.context.d.ts +0 -1
- package/dist/utils/bootSession.context.js +3 -2
- package/dist/utils/bootSession.context.js.map +1 -1
- package/dist/utils/bootSession.d.ts +0 -1
- package/dist/utils/chromeFetch.d.ts +0 -1
- package/dist/utils/cliOutput.d.ts +0 -1
- package/dist/utils/debugFilter.d.ts +0 -1
- package/dist/utils/debugFilter.js +5 -3
- package/dist/utils/debugFilter.js.map +1 -1
- package/dist/utils/delay.d.ts +65 -13
- package/dist/utils/delay.js +96 -23
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/errors.d.ts +0 -11
- package/dist/utils/errors.js +3 -14
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/evaluate.d.ts +11 -3
- package/dist/utils/evaluate.js +4 -3
- package/dist/utils/evaluate.js.map +1 -1
- package/dist/utils/ffmpeg.context.d.ts +0 -1
- package/dist/utils/ffmpeg.d.ts +1 -1
- package/dist/utils/ffmpeg.js +2 -1
- package/dist/utils/ffmpeg.js.map +1 -1
- package/dist/utils/fileLogger.d.ts +26 -7
- package/dist/utils/fileLogger.js +241 -102
- package/dist/utils/fileLogger.js.map +1 -1
- package/dist/utils/format.d.ts +36 -4
- package/dist/utils/format.js +66 -12
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logEmitter.d.ts +0 -1
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/m3u.d.ts +0 -1
- package/dist/utils/markup.d.ts +0 -1
- package/dist/utils/memo.d.ts +0 -1
- package/dist/utils/morganStream.d.ts +2 -3
- package/dist/utils/morganStream.js +6 -8
- package/dist/utils/morganStream.js.map +1 -1
- package/dist/utils/network.d.ts +0 -1
- package/dist/utils/never.d.ts +8 -0
- package/dist/utils/never.js +20 -0
- package/dist/utils/never.js.map +1 -0
- package/dist/utils/pid.d.ts +0 -1
- package/dist/utils/platform.d.ts +0 -1
- package/dist/utils/processInspector.context.d.ts +32 -2
- package/dist/utils/processInspector.context.js +117 -1
- package/dist/utils/processInspector.context.js.map +1 -1
- package/dist/utils/processInspector.d.ts +0 -32
- package/dist/utils/processInspector.js +10 -117
- package/dist/utils/processInspector.js.map +1 -1
- package/dist/utils/retry.d.ts +5 -4
- package/dist/utils/retry.js +43 -33
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/runtimeIdentity.context.d.ts +0 -1
- package/dist/utils/runtimeIdentity.context.js +3 -1
- package/dist/utils/runtimeIdentity.context.js.map +1 -1
- package/dist/utils/runtimeIdentity.d.ts +1 -1
- package/dist/utils/runtimeIdentity.js +1 -1
- package/dist/utils/runtimeIdentity.js.map +1 -1
- package/dist/utils/sanitize.d.ts +8 -1
- package/dist/utils/sanitize.js +19 -0
- package/dist/utils/sanitize.js.map +1 -1
- package/dist/utils/streamContext.d.ts +0 -1
- package/dist/utils/timing.d.ts +3 -4
- package/dist/utils/timing.js +4 -4
- package/dist/utils/timing.js.map +1 -1
- package/dist/utils/version.d.ts +14 -8
- package/dist/utils/version.js +35 -24
- package/dist/utils/version.js.map +1 -1
- package/package.json +7 -7
- package/dist/app.d.ts.map +0 -1
- package/dist/browser/blockedPage.d.ts.map +0 -1
- package/dist/browser/browserSupervisor.d.ts.map +0 -1
- package/dist/browser/cdp.d.ts.map +0 -1
- package/dist/browser/channelSelection.d.ts.map +0 -1
- package/dist/browser/consent.d.ts.map +0 -1
- package/dist/browser/display.d.ts.map +0 -1
- package/dist/browser/hlsPlaylistObserver.d.ts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/launchGovernor.d.ts.map +0 -1
- package/dist/browser/login.d.ts.map +0 -1
- package/dist/browser/manifestInterceptor.d.ts.map +0 -1
- package/dist/browser/pageStaleness.d.ts.map +0 -1
- package/dist/browser/precaching.d.ts.map +0 -1
- package/dist/browser/tabNetworkObserver.d.ts.map +0 -1
- package/dist/browser/tuning/cache.d.ts.map +0 -1
- package/dist/browser/tuning/comcastPolymer.d.ts.map +0 -1
- package/dist/browser/tuning/cox.d.ts.map +0 -1
- package/dist/browser/tuning/directv.d.ts.map +0 -1
- package/dist/browser/tuning/fox.d.ts.map +0 -1
- package/dist/browser/tuning/gridSearch.d.ts.map +0 -1
- package/dist/browser/tuning/hbo.d.ts.map +0 -1
- package/dist/browser/tuning/hulu.d.ts.map +0 -1
- package/dist/browser/tuning/shared.d.ts.map +0 -1
- package/dist/browser/tuning/sling.d.ts.map +0 -1
- package/dist/browser/tuning/spectrum.d.ts.map +0 -1
- package/dist/browser/tuning/thumbnailRow.d.ts.map +0 -1
- package/dist/browser/tuning/tileClick.d.ts.map +0 -1
- package/dist/browser/tuning/xfinity.d.ts.map +0 -1
- package/dist/browser/tuning/youtubeTv.d.ts.map +0 -1
- package/dist/browser/video.d.ts.map +0 -1
- package/dist/channels/index.d.ts.map +0 -1
- package/dist/config/channelForm.d.ts.map +0 -1
- package/dist/config/consistencyProbe.d.ts.map +0 -1
- package/dist/config/health.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/paths.d.ts.map +0 -1
- package/dist/config/persistence.context.d.ts.map +0 -1
- package/dist/config/persistence.d.ts.map +0 -1
- package/dist/config/presets.d.ts.map +0 -1
- package/dist/config/profiles.d.ts.map +0 -1
- package/dist/config/providerLineups.d.ts.map +0 -1
- package/dist/config/reactivity.d.ts.map +0 -1
- package/dist/config/servicePacks.d.ts.map +0 -1
- package/dist/config/services.d.ts.map +0 -1
- package/dist/config/sites.d.ts.map +0 -1
- package/dist/config/userChannels.d.ts.map +0 -1
- package/dist/config/userConfig.d.ts.map +0 -1
- package/dist/config/userProfiles.d.ts.map +0 -1
- package/dist/hdhr/channelMap.d.ts.map +0 -1
- package/dist/hdhr/deviceId.d.ts.map +0 -1
- package/dist/hdhr/discover.d.ts.map +0 -1
- package/dist/hdhr/getHandlers.d.ts.map +0 -1
- package/dist/hdhr/identity.d.ts.map +0 -1
- package/dist/hdhr/index.d.ts.map +0 -1
- package/dist/hdhr/protocol.d.ts.map +0 -1
- package/dist/hdhr/tunerState.d.ts.map +0 -1
- package/dist/hdhr/udp.d.ts.map +0 -1
- package/dist/identity.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/native/codecInference.d.ts.map +0 -1
- package/dist/native/decrypt.d.ts.map +0 -1
- package/dist/native/index.d.ts.map +0 -1
- package/dist/native/probe.d.ts.map +0 -1
- package/dist/native/proxy.d.ts.map +0 -1
- package/dist/native/tokenExpiry.d.ts.map +0 -1
- package/dist/routes/assets.d.ts.map +0 -1
- package/dist/routes/auth.d.ts.map +0 -1
- package/dist/routes/cdp.d.ts.map +0 -1
- package/dist/routes/channels.d.ts.map +0 -1
- package/dist/routes/clientActions.d.ts.map +0 -1
- package/dist/routes/components.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/browse.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/bulk.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/crud.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/importExport.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/predefined.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/prefs.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/service.d.ts.map +0 -1
- package/dist/routes/config/channels/endpoints/tags.d.ts.map +0 -1
- package/dist/routes/config/channels/healthBridge.d.ts.map +0 -1
- package/dist/routes/config/channels/http/handler.d.ts.map +0 -1
- package/dist/routes/config/channels/http/playlistHint.d.ts.map +0 -1
- package/dist/routes/config/channels/http/serviceWarning.d.ts.map +0 -1
- package/dist/routes/config/channels/index.d.ts.map +0 -1
- package/dist/routes/config/channels/setup.d.ts.map +0 -1
- package/dist/routes/config/channels/table.d.ts.map +0 -1
- package/dist/routes/config/http/envelope.d.ts.map +0 -1
- package/dist/routes/config/index.d.ts.map +0 -1
- package/dist/routes/config/services.d.ts.map +0 -1
- package/dist/routes/config/settings.d.ts.map +0 -1
- package/dist/routes/debug.d.ts.map +0 -1
- package/dist/routes/health.d.ts.map +0 -1
- package/dist/routes/hls.d.ts.map +0 -1
- package/dist/routes/icons.d.ts.map +0 -1
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/logs.d.ts.map +0 -1
- package/dist/routes/mpegts.d.ts.map +0 -1
- package/dist/routes/play.d.ts.map +0 -1
- package/dist/routes/playlist.d.ts.map +0 -1
- package/dist/routes/root/content.d.ts.map +0 -1
- package/dist/routes/root/index.d.ts.map +0 -1
- package/dist/routes/root/scripts/channels.d.ts.map +0 -1
- package/dist/routes/root/scripts/clientEscape.d.ts.map +0 -1
- package/dist/routes/root/scripts/clientUrl.d.ts.map +0 -1
- package/dist/routes/root/scripts/config.d.ts.map +0 -1
- package/dist/routes/root/scripts/index.d.ts.map +0 -1
- package/dist/routes/root/scripts/shared.d.ts.map +0 -1
- package/dist/routes/root/scripts/status.d.ts.map +0 -1
- package/dist/routes/root/scripts/status.handlers.d.ts.map +0 -1
- package/dist/routes/root/styles.d.ts.map +0 -1
- package/dist/routes/services.d.ts.map +0 -1
- package/dist/routes/sse.d.ts.map +0 -1
- package/dist/routes/streams.d.ts.map +0 -1
- package/dist/routes/theme.d.ts.map +0 -1
- package/dist/routes/ui.d.ts.map +0 -1
- package/dist/routes/upgrade.d.ts.map +0 -1
- package/dist/service/commands.context.d.ts.map +0 -1
- package/dist/service/commands.d.ts.map +0 -1
- package/dist/service/generators.context.d.ts.map +0 -1
- package/dist/service/generators.d.ts.map +0 -1
- package/dist/service/index.d.ts.map +0 -1
- package/dist/streaming/captureLock.d.ts.map +0 -1
- package/dist/streaming/captureSession.d.ts.map +0 -1
- package/dist/streaming/clients.d.ts.map +0 -1
- package/dist/streaming/codec.d.ts.map +0 -1
- package/dist/streaming/fmp4Segmenter.d.ts.map +0 -1
- package/dist/streaming/hls.d.ts.map +0 -1
- package/dist/streaming/hlsResume.d.ts.map +0 -1
- package/dist/streaming/hlsSegments.d.ts.map +0 -1
- package/dist/streaming/lifecycle.d.ts.map +0 -1
- package/dist/streaming/monitor.d.ts.map +0 -1
- package/dist/streaming/mp4Parser.d.ts.map +0 -1
- package/dist/streaming/mpegts.d.ts.map +0 -1
- package/dist/streaming/playlistBuilder.d.ts.map +0 -1
- package/dist/streaming/preroll.d.ts.map +0 -1
- package/dist/streaming/pretune.d.ts.map +0 -1
- package/dist/streaming/pretuneTimers.d.ts.map +0 -1
- package/dist/streaming/recovery.d.ts.map +0 -1
- package/dist/streaming/registry.d.ts.map +0 -1
- package/dist/streaming/setup.d.ts.map +0 -1
- package/dist/streaming/showInfo.d.ts.map +0 -1
- package/dist/streaming/statusEmitter.d.ts.map +0 -1
- package/dist/types/channels.d.ts.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/profiles.d.ts.map +0 -1
- package/dist/types/selection.d.ts.map +0 -1
- package/dist/types/shared.d.ts.map +0 -1
- package/dist/types/streaming.d.ts.map +0 -1
- package/dist/upgrade/commands.context.d.ts.map +0 -1
- package/dist/upgrade/commands.d.ts.map +0 -1
- package/dist/upgrade/detection.context.d.ts.map +0 -1
- package/dist/upgrade/detection.d.ts.map +0 -1
- package/dist/upgrade/index.d.ts.map +0 -1
- package/dist/upgrade/lifecycle.context.d.ts.map +0 -1
- package/dist/upgrade/lifecycle.d.ts.map +0 -1
- package/dist/upgrade/pathHandle.d.ts.map +0 -1
- package/dist/utils/bootSession.context.d.ts.map +0 -1
- package/dist/utils/bootSession.d.ts.map +0 -1
- package/dist/utils/chromeFetch.d.ts.map +0 -1
- package/dist/utils/cliOutput.d.ts.map +0 -1
- package/dist/utils/clock.d.ts +0 -15
- package/dist/utils/clock.d.ts.map +0 -1
- package/dist/utils/clock.js +0 -31
- package/dist/utils/clock.js.map +0 -1
- package/dist/utils/debugFilter.d.ts.map +0 -1
- package/dist/utils/delay.d.ts.map +0 -1
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/evaluate.d.ts.map +0 -1
- package/dist/utils/ffmpeg.context.d.ts.map +0 -1
- package/dist/utils/ffmpeg.d.ts.map +0 -1
- package/dist/utils/fileLogger.d.ts.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/logEmitter.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/m3u.d.ts.map +0 -1
- package/dist/utils/markup.d.ts.map +0 -1
- package/dist/utils/memo.d.ts.map +0 -1
- package/dist/utils/morganStream.d.ts.map +0 -1
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/pid.d.ts.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/processInspector.context.d.ts.map +0 -1
- package/dist/utils/processInspector.d.ts.map +0 -1
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/runtimeIdentity.context.d.ts.map +0 -1
- package/dist/utils/runtimeIdentity.d.ts.map +0 -1
- package/dist/utils/sanitize.d.ts.map +0 -1
- package/dist/utils/streamContext.d.ts.map +0 -1
- package/dist/utils/timing.d.ts.map +0 -1
- package/dist/utils/version.d.ts.map +0 -1
package/dist/utils/delay.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Clock } from "homebridge-plugin-utils";
|
|
1
2
|
import type { Nullable } from "../types/index.ts";
|
|
2
3
|
/**
|
|
3
4
|
* A timeout expressed as an abort signal, paired with the disposal its consumer owes. The signal aborts with the caller's own error object as its reason, which
|
|
@@ -10,20 +11,32 @@ export interface TimeoutSignal {
|
|
|
10
11
|
signal: AbortSignal;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* What a bound needs beyond its duration: where its time comes from, and what its lapse says. Every policy in this file accepts this shape, so one clock
|
|
15
|
+
* injected at a call site drives whichever bound that call site builds.
|
|
16
|
+
*/
|
|
17
|
+
export interface BoundOptions {
|
|
18
|
+
readonly clock?: Clock;
|
|
19
|
+
readonly reason?: Error;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a timeout signal that aborts after the given duration, carrying the supplied error as its abort reason. The bound is a one-shot armed on the clock,
|
|
23
|
+
* so it comes due wherever that clock's time comes from - a platform timer under the system clock, an advance under a virtual one.
|
|
14
24
|
*
|
|
15
25
|
* The consumer owns the returned handle and must cancel() it once its wait settles. That discipline is what keeps a timer from being disposed at process exit
|
|
16
26
|
* instead of at settlement: on Windows, libuv disposing a still-pending timeout handle during natural exit can race pending socket cleanup and trip the
|
|
17
27
|
* UV_HANDLE_CLOSING assertion in libuv's async.c. Cancelling at settlement disposes the handle while the event loop is still healthy, which sidesteps the race
|
|
18
|
-
* regardless of how soon afterwards the process exits.
|
|
19
|
-
*
|
|
28
|
+
* regardless of how soon afterwards the process exits. A bound left pending holds the loop open for at most its own duration, and that never delays exit,
|
|
29
|
+
* because shutdown ends the process explicitly (see app.ts) rather than waiting for the loop to empty.
|
|
30
|
+
*
|
|
31
|
+
* The system clock reads the host's wall clock, so a step in that clock while a bound is pending shifts the bound by the size of the step, once; the next
|
|
32
|
+
* reading corrects it.
|
|
20
33
|
*
|
|
21
34
|
* The default error is built inside the timer callback so a wait that finishes in time allocates nothing.
|
|
22
35
|
* @param ms - The timeout duration in milliseconds.
|
|
23
|
-
* @param
|
|
36
|
+
* @param options - The clock the bound runs on and the reason it aborts with when it lapses.
|
|
24
37
|
* @returns A handle exposing the timeout's signal and the cancel function that disposes its timer.
|
|
25
38
|
*/
|
|
26
|
-
export declare function timeoutSignal(ms: number,
|
|
39
|
+
export declare function timeoutSignal(ms: number, options?: BoundOptions): TimeoutSignal;
|
|
27
40
|
/**
|
|
28
41
|
* Waits for a promise, bounded by a timeout that throws. If the promise settles first its outcome passes through unchanged; if the bound lapses first, the
|
|
29
42
|
* caller's exact error object is thrown, so a call site can identify its own lapse by reference or by instanceof rather than by parsing a message.
|
|
@@ -32,11 +45,11 @@ export declare function timeoutSignal(ms: number, reason?: Error): TimeoutSignal
|
|
|
32
45
|
* and cancelled in the finally on every exit path - so no call site can forget the cleanup.
|
|
33
46
|
* @param promise - The promise to wait on.
|
|
34
47
|
* @param timeoutMs - The timeout duration in milliseconds.
|
|
35
|
-
* @param
|
|
48
|
+
* @param options - The clock the bound runs on and the reason thrown when it lapses.
|
|
36
49
|
* @returns The resolved value of the promise.
|
|
37
50
|
* @throws The supplied error (or the default) when the bound lapses first, or the promise's own rejection when it settles first.
|
|
38
51
|
*/
|
|
39
|
-
export declare function waitWithTimeout<T>(promise: Promise<T>, timeoutMs: number,
|
|
52
|
+
export declare function waitWithTimeout<T>(promise: Promise<T>, timeoutMs: number, options?: BoundOptions): Promise<T>;
|
|
40
53
|
/**
|
|
41
54
|
* Waits for a promise, bounded by a timeout that yields null. If the promise settles first its value is returned; if the bound lapses first the result is null,
|
|
42
55
|
* so the caller branches on a value rather than unwinding through a catch.
|
|
@@ -47,20 +60,59 @@ export declare function waitWithTimeout<T>(promise: Promise<T>, timeoutMs: numbe
|
|
|
47
60
|
*
|
|
48
61
|
* The composition is deliberate. runWithAbort performs no race of its own; it composes the bounds into one signal, hands that signal to the factory, and maps
|
|
49
62
|
* an abort-time rejection to null. So the factory forwards the signal into waitWithSignal, and that forwarding is what makes the bound genuinely bind on a
|
|
50
|
-
* promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound
|
|
51
|
-
* runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and
|
|
52
|
-
*
|
|
63
|
+
* promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound uses timeoutSignal rather than
|
|
64
|
+
* runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and runs on an
|
|
65
|
+
* injected clock.
|
|
66
|
+
*
|
|
67
|
+
* The lapse carries no reason, because there is no rejection to carry it on: a caller that needs to tell its own lapse apart reaches for waitWithTimeout.
|
|
53
68
|
*
|
|
54
69
|
* One constraint belongs to the caller: a promise that can itself resolve null cannot be told apart from a lapse. Callers own that fit.
|
|
55
70
|
* @param promise - The promise to wait on.
|
|
56
71
|
* @param timeoutMs - The timeout duration in milliseconds.
|
|
72
|
+
* @param options - The clock the bound runs on.
|
|
57
73
|
* @returns The resolved value of the promise, or null if the bound lapsed first.
|
|
58
74
|
*/
|
|
59
|
-
export declare function boundedWait<T>(promise: Promise<T>, timeoutMs: number): Promise<Nullable<T>>;
|
|
75
|
+
export declare function boundedWait<T>(promise: Promise<T>, timeoutMs: number, options?: Pick<BoundOptions, "clock">): Promise<Nullable<T>>;
|
|
60
76
|
/**
|
|
61
|
-
* Creates a promise that resolves after the specified delay.
|
|
77
|
+
* Creates a promise that resolves after the specified delay. This is the project's one canonical "sleep" name, over the system clock's delay, for the call
|
|
78
|
+
* sites that hold no clock of their own; a consumer that does hold one calls clock.delay instead, so its sleep runs on the same time source as its bounds.
|
|
62
79
|
* @param ms - The delay duration in milliseconds.
|
|
63
80
|
* @returns A promise that resolves after the specified delay.
|
|
64
81
|
*/
|
|
65
82
|
export declare function delay(ms: number): Promise<void>;
|
|
66
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The inputs to one poll: what to read, when to stop reading, how often to ask, how long to keep asking, and what ends the asking early.
|
|
85
|
+
*/
|
|
86
|
+
export interface PollUntilOptions<T> {
|
|
87
|
+
readonly cadenceMs: number;
|
|
88
|
+
readonly ceilingMs: number;
|
|
89
|
+
readonly clock?: Clock;
|
|
90
|
+
readonly read: () => Promise<T>;
|
|
91
|
+
readonly signal?: AbortSignal;
|
|
92
|
+
readonly until: (value: T) => boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A poll that ended on its own terms: satisfied by a read, or lapsed at its ceiling. The value is the satisfying read in the first case and the last read in the
|
|
96
|
+
* second, and the read count says how many it took - a satisfied-on-arrival signal reads once.
|
|
97
|
+
*/
|
|
98
|
+
export interface PollSettled<T> {
|
|
99
|
+
readonly reads: number;
|
|
100
|
+
readonly status: "lapsed" | "satisfied";
|
|
101
|
+
readonly value: T;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A poll its signal ended: before its first read, or between a read and the sleep that would have followed, or inside a cadence sleep. There is no value to
|
|
105
|
+
* report, because the state the caller was asking for was never confirmed and the caller has stopped caring; the read count says how far the poll got.
|
|
106
|
+
*/
|
|
107
|
+
export interface PollAborted {
|
|
108
|
+
readonly reads: number;
|
|
109
|
+
readonly status: "aborted";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The result of one poll.
|
|
113
|
+
*/
|
|
114
|
+
export type PollOutcome<T> = PollAborted | PollSettled<T>;
|
|
115
|
+
export declare function pollUntil<T>(options: PollUntilOptions<T> & {
|
|
116
|
+
readonly signal?: undefined;
|
|
117
|
+
}): Promise<PollSettled<T>>;
|
|
118
|
+
export declare function pollUntil<T>(options: PollUntilOptions<T>): Promise<PollOutcome<T>>;
|
package/dist/utils/delay.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
/* Copyright(C) 2024-2026, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
2
2
|
*
|
|
3
3
|
* delay.ts: The project's wait policies. homebridge-plugin-utils owns the wait mechanisms - waitWithSignal races a held promise against an interrupt signal,
|
|
4
|
-
*
|
|
5
|
-
* reason-carrying interrupt source, waitWithTimeout is the throw-shaped bounded wait, boundedWait is the value-shaped one,
|
|
6
|
-
* code path that needs "promise with a bound" consumes a policy here rather
|
|
4
|
+
* runWithAbort carries the return-null-on-abort policy, and Clock is the time source the waits run on - and this file names the policies built over them
|
|
5
|
+
* exactly once: timeoutSignal is the reason-carrying interrupt source, waitWithTimeout is the throw-shaped bounded wait, boundedWait is the value-shaped one,
|
|
6
|
+
* delay is the named sleep, and pollUntil is the read-a-reported-state shape. Any code path that needs "promise with a bound" consumes a policy here rather
|
|
7
|
+
* than re-rolling the timer, race, and cleanup sequence.
|
|
8
|
+
*
|
|
9
|
+
* Every policy takes its clock through its options and defaults to systemClock, so a test drives the whole policy set from one TestClock: the bound, the
|
|
10
|
+
* cadence, and the sleep settle on a single virtual timeline, and a wait binds on a deadline the test crosses rather than resolving whenever a double decides
|
|
11
|
+
* it should. The system clock reads the host's wall clock, so a step in that clock while a bound or a poll is pending shifts that wait by the size of the
|
|
12
|
+
* step, once; the next reading corrects it.
|
|
13
|
+
*
|
|
14
|
+
* pollUntil sits beside the two bounded waits rather than among them because it binds a different thing. The bounded waits hold a promise somebody else
|
|
15
|
+
* produced and decide what a lapse means; pollUntil has no promise to hold - the state it is waiting on is one the caller can only ask for - so it asks on a
|
|
16
|
+
* cadence and reports what it last saw. That is why its ceiling is a bound to log rather than a delay the healthy path pays: a signal that is already true
|
|
17
|
+
* costs exactly one read. It is also the one policy here that takes an abort signal, because the state it asks for is one its caller may stop caring about
|
|
18
|
+
* before the ceiling, and an abort is a third outcome beside satisfied and lapsed rather than a lapse in disguise.
|
|
7
19
|
*
|
|
8
20
|
* Choosing between the two bounded waits is a question about semantics, not mechanism. A wait whose interruption is exceptional - the operation was supposed
|
|
9
21
|
* to finish and did not - throws through waitWithTimeout, so the failure travels as an error the caller can distinguish by identity or type. A wait whose
|
|
@@ -14,27 +26,34 @@
|
|
|
14
26
|
* what keeps a forgotten cleanup from leaking a timer at any call site, and it is what guarantees the handle is disposed at settlement while the event loop is
|
|
15
27
|
* still healthy (see the rationale on timeoutSignal).
|
|
16
28
|
*/
|
|
17
|
-
import { runWithAbort, waitWithSignal } from "homebridge-plugin-utils";
|
|
18
|
-
import { setTimeout as nodeSleep } from "node:timers/promises";
|
|
29
|
+
import { runWithAbort, systemClock, waitWithSignal } from "homebridge-plugin-utils";
|
|
19
30
|
/**
|
|
20
|
-
* Creates a timeout signal that aborts after the given duration, carrying the supplied error as its abort reason.
|
|
31
|
+
* Creates a timeout signal that aborts after the given duration, carrying the supplied error as its abort reason. The bound is a one-shot armed on the clock,
|
|
32
|
+
* so it comes due wherever that clock's time comes from - a platform timer under the system clock, an advance under a virtual one.
|
|
21
33
|
*
|
|
22
34
|
* The consumer owns the returned handle and must cancel() it once its wait settles. That discipline is what keeps a timer from being disposed at process exit
|
|
23
35
|
* instead of at settlement: on Windows, libuv disposing a still-pending timeout handle during natural exit can race pending socket cleanup and trip the
|
|
24
36
|
* UV_HANDLE_CLOSING assertion in libuv's async.c. Cancelling at settlement disposes the handle while the event loop is still healthy, which sidesteps the race
|
|
25
|
-
* regardless of how soon afterwards the process exits.
|
|
26
|
-
*
|
|
37
|
+
* regardless of how soon afterwards the process exits. A bound left pending holds the loop open for at most its own duration, and that never delays exit,
|
|
38
|
+
* because shutdown ends the process explicitly (see app.ts) rather than waiting for the loop to empty.
|
|
39
|
+
*
|
|
40
|
+
* The system clock reads the host's wall clock, so a step in that clock while a bound is pending shifts the bound by the size of the step, once; the next
|
|
41
|
+
* reading corrects it.
|
|
27
42
|
*
|
|
28
43
|
* The default error is built inside the timer callback so a wait that finishes in time allocates nothing.
|
|
29
44
|
* @param ms - The timeout duration in milliseconds.
|
|
30
|
-
* @param
|
|
45
|
+
* @param options - The clock the bound runs on and the reason it aborts with when it lapses.
|
|
31
46
|
* @returns A handle exposing the timeout's signal and the cancel function that disposes its timer.
|
|
32
47
|
*/
|
|
33
|
-
export function timeoutSignal(ms,
|
|
48
|
+
export function timeoutSignal(ms, options = {}) {
|
|
49
|
+
const { clock = systemClock, reason } = options;
|
|
34
50
|
const controller = new AbortController();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
// The bound is a one-shot on the clock, so a virtual clock fires it inside advance and disposing the handle cancels it before it fires. The default reason is
|
|
52
|
+
// built when the bound fires, so a wait that finishes in time allocates nothing.
|
|
53
|
+
const timer = clock.schedule(() => {
|
|
54
|
+
controller.abort(reason ?? new Error("Operation timed out after " + String(ms) + "ms."));
|
|
55
|
+
}, ms);
|
|
56
|
+
return { cancel: () => { timer[Symbol.dispose](); }, signal: controller.signal };
|
|
38
57
|
}
|
|
39
58
|
/**
|
|
40
59
|
* Waits for a promise, bounded by a timeout that throws. If the promise settles first its outcome passes through unchanged; if the bound lapses first, the
|
|
@@ -44,12 +63,12 @@ export function timeoutSignal(ms, reason) {
|
|
|
44
63
|
* and cancelled in the finally on every exit path - so no call site can forget the cleanup.
|
|
45
64
|
* @param promise - The promise to wait on.
|
|
46
65
|
* @param timeoutMs - The timeout duration in milliseconds.
|
|
47
|
-
* @param
|
|
66
|
+
* @param options - The clock the bound runs on and the reason thrown when it lapses.
|
|
48
67
|
* @returns The resolved value of the promise.
|
|
49
68
|
* @throws The supplied error (or the default) when the bound lapses first, or the promise's own rejection when it settles first.
|
|
50
69
|
*/
|
|
51
|
-
export async function waitWithTimeout(promise, timeoutMs,
|
|
52
|
-
const timeout = timeoutSignal(timeoutMs,
|
|
70
|
+
export async function waitWithTimeout(promise, timeoutMs, options = {}) {
|
|
71
|
+
const timeout = timeoutSignal(timeoutMs, options);
|
|
53
72
|
try {
|
|
54
73
|
return await waitWithSignal(promise, timeout.signal);
|
|
55
74
|
}
|
|
@@ -67,17 +86,20 @@ export async function waitWithTimeout(promise, timeoutMs, timeoutError) {
|
|
|
67
86
|
*
|
|
68
87
|
* The composition is deliberate. runWithAbort performs no race of its own; it composes the bounds into one signal, hands that signal to the factory, and maps
|
|
69
88
|
* an abort-time rejection to null. So the factory forwards the signal into waitWithSignal, and that forwarding is what makes the bound genuinely bind on a
|
|
70
|
-
* promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound
|
|
71
|
-
* runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and
|
|
72
|
-
*
|
|
89
|
+
* promise this code does not own - a factory that ignored its signal would leave a held promise waiting forever. The bound uses timeoutSignal rather than
|
|
90
|
+
* runWithAbort's own timeout option so every bound in the project flows through the one source that can carry a reason, owns its timer, and runs on an
|
|
91
|
+
* injected clock.
|
|
92
|
+
*
|
|
93
|
+
* The lapse carries no reason, because there is no rejection to carry it on: a caller that needs to tell its own lapse apart reaches for waitWithTimeout.
|
|
73
94
|
*
|
|
74
95
|
* One constraint belongs to the caller: a promise that can itself resolve null cannot be told apart from a lapse. Callers own that fit.
|
|
75
96
|
* @param promise - The promise to wait on.
|
|
76
97
|
* @param timeoutMs - The timeout duration in milliseconds.
|
|
98
|
+
* @param options - The clock the bound runs on.
|
|
77
99
|
* @returns The resolved value of the promise, or null if the bound lapsed first.
|
|
78
100
|
*/
|
|
79
|
-
export async function boundedWait(promise, timeoutMs) {
|
|
80
|
-
const timeout = timeoutSignal(timeoutMs);
|
|
101
|
+
export async function boundedWait(promise, timeoutMs, options = {}) {
|
|
102
|
+
const timeout = timeoutSignal(timeoutMs, { clock: options.clock });
|
|
81
103
|
try {
|
|
82
104
|
return await runWithAbort((signal) => waitWithSignal(promise, signal), { signal: timeout.signal });
|
|
83
105
|
}
|
|
@@ -86,11 +108,62 @@ export async function boundedWait(promise, timeoutMs) {
|
|
|
86
108
|
}
|
|
87
109
|
}
|
|
88
110
|
/**
|
|
89
|
-
* Creates a promise that resolves after the specified delay.
|
|
111
|
+
* Creates a promise that resolves after the specified delay. This is the project's one canonical "sleep" name, over the system clock's delay, for the call
|
|
112
|
+
* sites that hold no clock of their own; a consumer that does hold one calls clock.delay instead, so its sleep runs on the same time source as its bounds.
|
|
90
113
|
* @param ms - The delay duration in milliseconds.
|
|
91
114
|
* @returns A promise that resolves after the specified delay.
|
|
92
115
|
*/
|
|
93
116
|
export async function delay(ms) {
|
|
94
|
-
await
|
|
117
|
+
await systemClock.delay(ms);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reads a signal on a cadence until it satisfies a predicate, a ceiling lapses, or an abort signal ends the asking. This is the shape every "wait for a reported
|
|
121
|
+
* state" call in the project shares: a state that only its owner can report, asked for on a cadence, under a ceiling that exists to be logged rather than to be
|
|
122
|
+
* waited out, and stoppable by the caller that no longer needs the answer.
|
|
123
|
+
*
|
|
124
|
+
* The first read runs immediately, with no sleep ahead of it, so a signal that is already true costs one round trip and nothing else. A read that rejects
|
|
125
|
+
* propagates unchanged: the poll has no opinion on what a failed read means, and swallowing it would hide a fault behind a lapse. A supplied signal ends the poll
|
|
126
|
+
* at the next checkpoint - before a read, before a sleep, or inside a sleep - and the outcome says so.
|
|
127
|
+
* @param options - The poll's read, predicate, cadence, ceiling, clock, and signal.
|
|
128
|
+
* @returns The outcome: satisfied or lapsed with the last value read, or aborted with the reads that ran.
|
|
129
|
+
*/
|
|
130
|
+
export async function pollUntil(options) {
|
|
131
|
+
const { cadenceMs, ceilingMs, clock = systemClock, read, signal, until } = options;
|
|
132
|
+
const startedAt = clock.now();
|
|
133
|
+
// The sleep's init is built once: a signal is forwarded so the clock ends the sleep when it aborts, and an absent signal forwards nothing at all.
|
|
134
|
+
const init = signal ? { signal } : undefined;
|
|
135
|
+
let reads = 0;
|
|
136
|
+
for (;;) {
|
|
137
|
+
if (signal?.aborted) {
|
|
138
|
+
return { reads, status: "aborted" };
|
|
139
|
+
}
|
|
140
|
+
// eslint-disable-next-line no-await-in-loop -- A poll is sequential by definition: each read has to settle before the cadence sleep and the next read.
|
|
141
|
+
const value = await read();
|
|
142
|
+
reads++;
|
|
143
|
+
if (until(value)) {
|
|
144
|
+
return { reads, status: "satisfied", value };
|
|
145
|
+
}
|
|
146
|
+
// An abort that landed during the read wins over a lapse at the ceiling and registers no sleep: the caller's own stop is checked before the ceiling and
|
|
147
|
+
// before the cadence, because a lapse would hand back a value the caller has already stopped caring about.
|
|
148
|
+
if (signal?.aborted) {
|
|
149
|
+
return { reads, status: "aborted" };
|
|
150
|
+
}
|
|
151
|
+
// The ceiling is checked only after a read has already happened, so the poll always reports a value and a zero ceiling still asks once.
|
|
152
|
+
if ((clock.now() - startedAt) >= ceilingMs) {
|
|
153
|
+
return { reads, status: "lapsed", value };
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
// eslint-disable-next-line no-await-in-loop -- The cadence is the point: the next read must not start until this wait completes.
|
|
157
|
+
await clock.delay(cadenceMs, init);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
// The clock rejects an aborted sleep with its own AbortError rather than the signal's reason, so the poll identifies its abort by the signal it holds and
|
|
161
|
+
// lets any other rejection propagate unchanged.
|
|
162
|
+
if (signal?.aborted) {
|
|
163
|
+
return { reads, status: "aborted" };
|
|
164
|
+
}
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
95
168
|
}
|
|
96
169
|
//# 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
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/utils/delay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA+BpF;;;;;;;;;;;;;;;;;GAiB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,wIAAwI;QACxI,IAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,IAAI,SAAS,EAAE,CAAC;YAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC;YAEH,iIAAiI;YACjI,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACrC,CAAC;QAAC,OAAM,KAAK,EAAE,CAAC;YAEd,0JAA0J;YAC1J,gDAAgD;YAChD,IAAG,MAAM,EAAE,OAAO,EAAE,CAAC;gBAEnB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YACtC,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -34,14 +34,3 @@ export declare function isSessionClosedError(error: unknown): boolean;
|
|
|
34
34
|
* @returns True if the error indicates the page, execution context, or frame the operation ran in is gone.
|
|
35
35
|
*/
|
|
36
36
|
export declare function isPageDeathError(error: unknown): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Checks whether an error is the stale-capture-mutex signal: Chrome's tabCapture extension rejects a second concurrent getStream() with "Cannot capture a tab with
|
|
39
|
-
* an active stream", and that rejection leaks puppeteer-stream's module-level mutex permanently, so the only recovery is a full process restart. This is the single
|
|
40
|
-
* home for that one literal - every site that must decide the process-exit escalation reads it from here. The predicate is deliberately narrow: session-closed-shaped
|
|
41
|
-
* rejections are common and benign, so widening it would exit the process on ordinary browser crashes. The related, broader capture-infrastructure classifier
|
|
42
|
-
* (isCaptureInfrastructureError in recovery.ts) matches this message too, but the process-exit decision this predicate gates stays its own distinct check.
|
|
43
|
-
* @param error - The error or message to check.
|
|
44
|
-
* @returns True if the error carries the stale-capture-mutex signature.
|
|
45
|
-
*/
|
|
46
|
-
export declare function isStaleCaptureMutexError(error: unknown): boolean;
|
|
47
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/utils/errors.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
*
|
|
3
3
|
* errors.ts: Error formatting and handling utilities for PrismCast.
|
|
4
4
|
*/
|
|
5
|
-
/* These helpers group the error-handling primitives shared across the application: one normalizes arbitrary errors into log-ready text,
|
|
6
|
-
* browser-state failures
|
|
5
|
+
/* These helpers group the error-handling primitives shared across the application: one normalizes arbitrary errors into log-ready text, and two classify
|
|
6
|
+
* browser-state failures - one so a retry loop aborts as soon as the session it was retrying against is gone, the other so a caller can tell a page that
|
|
7
|
+
* died apart from a subject that was never there.
|
|
7
8
|
*/
|
|
8
9
|
/**
|
|
9
10
|
* Formats an error for logging by extracting the message if available, falling back to string conversion for non-Error objects. Trailing punctuation is stripped
|
|
@@ -66,16 +67,4 @@ export function isPageDeathError(error) {
|
|
|
66
67
|
"frame got detached", "frame was detached"];
|
|
67
68
|
return contextDeathPatterns.some((pattern) => message.includes(pattern));
|
|
68
69
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks whether an error is the stale-capture-mutex signal: Chrome's tabCapture extension rejects a second concurrent getStream() with "Cannot capture a tab with
|
|
71
|
-
* an active stream", and that rejection leaks puppeteer-stream's module-level mutex permanently, so the only recovery is a full process restart. This is the single
|
|
72
|
-
* home for that one literal - every site that must decide the process-exit escalation reads it from here. The predicate is deliberately narrow: session-closed-shaped
|
|
73
|
-
* rejections are common and benign, so widening it would exit the process on ordinary browser crashes. The related, broader capture-infrastructure classifier
|
|
74
|
-
* (isCaptureInfrastructureError in recovery.ts) matches this message too, but the process-exit decision this predicate gates stays its own distinct check.
|
|
75
|
-
* @param error - The error or message to check.
|
|
76
|
-
* @returns True if the error carries the stale-capture-mutex signature.
|
|
77
|
-
*/
|
|
78
|
-
export function isStaleCaptureMutexError(error) {
|
|
79
|
-
return formatError(error).includes("Cannot capture a tab with an active stream");
|
|
80
|
-
}
|
|
81
70
|
//# sourceMappingURL=errors.js.map
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IAExC,IAAI,OAAe,CAAC;IAEpB,IAAG,KAAK,YAAY,KAAK,EAAE,CAAC;QAE1B,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1B,CAAC;SAAM,IAAG,KAAK,IAAI,CAAC,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC;QAElF,OAAO,GAAI,KAA6B,CAAC,OAAO,CAAC;IACnD,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,uFAAuF;IACvF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAEjD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjD,MAAM,qBAAqB,GAAG,CAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,CAAE,CAAC;IAEtF,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAE7C,IAAG,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjD,MAAM,oBAAoB,GAAG,CAAE,uCAAuC,EAAE,oCAAoC,EAAE,iCAAiC;QAC7I,oBAAoB,EAAE,oBAAoB,CAAE,CAAC;IAE/C,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
package/dist/utils/evaluate.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Frame, Page } from "puppeteer-core";
|
|
2
|
+
import type { Clock } from "homebridge-plugin-utils";
|
|
2
3
|
/**
|
|
3
4
|
* Registers an AbortController for a stream. Called when a stream is created.
|
|
4
5
|
* @param streamIdStr - The stream ID string (e.g., "cnn-5jecl6").
|
|
@@ -34,6 +35,14 @@ export declare class EvaluateTimeoutError extends Error {
|
|
|
34
35
|
export declare class EvaluateAbortError extends Error {
|
|
35
36
|
constructor();
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* What a call can say about its own bound: where the bound's time comes from, and how long it is. One options object rather than a second positional parameter,
|
|
40
|
+
* because only a few call sites name a timeout at all and none of them should have to write an undefined placeholder to reach past it.
|
|
41
|
+
*/
|
|
42
|
+
export interface EvaluateOptions {
|
|
43
|
+
readonly clock?: Clock;
|
|
44
|
+
readonly timeoutMs?: number;
|
|
45
|
+
}
|
|
37
46
|
/**
|
|
38
47
|
* Executes a Puppeteer evaluate call with abort and timeout support. This wrapper provides immediate cancellation when a stream is terminated and a safety timeout to
|
|
39
48
|
* prevent hanging on unresponsive browsers.
|
|
@@ -42,11 +51,10 @@ export declare class EvaluateAbortError extends Error {
|
|
|
42
51
|
* @param context - The Page or Frame to evaluate in.
|
|
43
52
|
* @param pageFunction - The function to evaluate in the browser context.
|
|
44
53
|
* @param args - Arguments to pass to the function (optional).
|
|
45
|
-
* @param
|
|
54
|
+
* @param options - The clock the bound arms on and how long the bound is.
|
|
46
55
|
* @returns The result of the evaluate call.
|
|
47
56
|
* @throws EvaluateAbortError if the stream was terminated.
|
|
48
57
|
* @throws EvaluateTimeoutError if the timeout was reached.
|
|
49
58
|
* @throws Any error from the underlying evaluate call.
|
|
50
59
|
*/
|
|
51
|
-
export declare function evaluateWithAbort<T, Args extends unknown[]>(context: Frame | Page, pageFunction: (...args: Args) => T, args?: Args,
|
|
52
|
-
//# sourceMappingURL=evaluate.d.ts.map
|
|
60
|
+
export declare function evaluateWithAbort<T, Args extends unknown[]>(context: Frame | Page, pageFunction: (...args: Args) => T, args?: Args, options?: EvaluateOptions): Promise<T>;
|
package/dist/utils/evaluate.js
CHANGED
|
@@ -80,13 +80,14 @@ export class EvaluateAbortError extends Error {
|
|
|
80
80
|
* @param context - The Page or Frame to evaluate in.
|
|
81
81
|
* @param pageFunction - The function to evaluate in the browser context.
|
|
82
82
|
* @param args - Arguments to pass to the function (optional).
|
|
83
|
-
* @param
|
|
83
|
+
* @param options - The clock the bound arms on and how long the bound is.
|
|
84
84
|
* @returns The result of the evaluate call.
|
|
85
85
|
* @throws EvaluateAbortError if the stream was terminated.
|
|
86
86
|
* @throws EvaluateTimeoutError if the timeout was reached.
|
|
87
87
|
* @throws Any error from the underlying evaluate call.
|
|
88
88
|
*/
|
|
89
|
-
export async function evaluateWithAbort(context, pageFunction, args,
|
|
89
|
+
export async function evaluateWithAbort(context, pageFunction, args, options = {}) {
|
|
90
|
+
const { clock, timeoutMs } = options;
|
|
90
91
|
const timeout = timeoutMs ?? DEFAULT_EVALUATE_TIMEOUT;
|
|
91
92
|
// Get stream context to find the abort signal.
|
|
92
93
|
const streamIdStr = getStreamId();
|
|
@@ -105,7 +106,7 @@ export async function evaluateWithAbort(context, pageFunction, args, timeoutMs)
|
|
|
105
106
|
// platform's AbortError for a stream termination. Those two can never be confused, and an evaluate rejection is never the signal's reason at all, so it falls
|
|
106
107
|
// through verbatim. When there is no stream signal, composeSignals hands back the timeout signal unwrapped and the bound is the whole story.
|
|
107
108
|
const timeoutReason = new EvaluateTimeoutError(timeout);
|
|
108
|
-
const timeoutHandle = timeoutSignal(timeout, timeoutReason);
|
|
109
|
+
const timeoutHandle = timeoutSignal(timeout, { clock, reason: timeoutReason });
|
|
109
110
|
const signal = composeSignals(streamSignal, timeoutHandle.signal);
|
|
110
111
|
try {
|
|
111
112
|
return await waitWithSignal(evaluatePromise, signal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/utils/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/utils/evaluate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;;;;GAiBG;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,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C,yJAAyJ;IACzJ,yJAAyJ;IACzJ,8JAA8J;IAC9J,6IAA6I;IAC7I,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAElE,IAAI,CAAC;QAEH,OAAO,MAAM,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAAC,OAAM,KAAK,EAAE,CAAC;QAEd,IAAG,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,aAAa,CAAC,EAAE,CAAC;YAE1D,MAAM,IAAI,kBAAkB,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QAET,aAAa,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/dist/utils/ffmpeg.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare const resolvePrerollFFmpegPath: () => Promise<string | undefined>
|
|
|
71
71
|
* Result from spawning an FFmpeg process.
|
|
72
72
|
*/
|
|
73
73
|
export interface FFmpegProcess {
|
|
74
|
+
isShuttingDown: () => boolean;
|
|
74
75
|
kill: () => void;
|
|
75
76
|
process: ChildProcess;
|
|
76
77
|
stdin: Writable;
|
|
@@ -157,4 +158,3 @@ export declare function spawnMpegTsRemuxer(ffmpegBin: string, onError: (error: E
|
|
|
157
158
|
* @returns Promise resolving to true if FFmpeg is available, false otherwise.
|
|
158
159
|
*/
|
|
159
160
|
export declare function isFFmpegAvailable(): Promise<boolean>;
|
|
160
|
-
//# sourceMappingURL=ffmpeg.d.ts.map
|
package/dist/utils/ffmpeg.js
CHANGED
|
@@ -181,7 +181,7 @@ export function classifyFfmpegExit(code, signal, label) {
|
|
|
181
181
|
* @param options.label - Descriptive label for log messages and error strings (e.g., "FFmpeg", "MPEG-TS remuxer").
|
|
182
182
|
* @param options.onError - Callback invoked when FFmpeg exits unexpectedly or encounters an error.
|
|
183
183
|
* @param options.streamId - Optional stream identifier for log prefixing.
|
|
184
|
-
* @returns FFmpeg process wrapper with stdin, stdout,
|
|
184
|
+
* @returns FFmpeg process wrapper with stdin, stdout, a kill function, and the teardown-requested read its stream listeners gate on.
|
|
185
185
|
*/
|
|
186
186
|
function spawnFFmpegProcess({ args, ffmpegBin, label, onError, streamId }) {
|
|
187
187
|
const ffmpeg = spawn(ffmpegBin, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
@@ -226,6 +226,7 @@ function spawnFFmpegProcess({ args, ffmpegBin, label, onError, streamId }) {
|
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
return {
|
|
229
|
+
isShuttingDown: () => shuttingDown,
|
|
229
230
|
kill,
|
|
230
231
|
process: ffmpeg,
|
|
231
232
|
stdin: ffmpeg.stdin,
|
package/dist/utils/ffmpeg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ffmpeg.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,iKAAiK;AACjK,2EAA2E;AAC3E,MAAM,qBAAqB,GAAG,CAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAE,CAAC;AAyBxG;;;;;;;GAOG;AACH,KAAK,UAAU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AAmB;QACtB,2BAA2B;QAC3B,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,0BAA0B;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,YAAoB,EAAE,OAA+B,EAAE,QAAiB,EAAE,OAAgB;IAEvI,OAAO,kBAAkB,CAAC;QAExB,IAAI,EAAE,oBAAoB,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC;QACrD,SAAS;QACT,KAAK,EAAE,QAAQ;QACf,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,OAA+B,EAAE,QAAiB;IAEtG,OAAO,kBAAkB,CAAC;QAExB,IAAI,EAAE,sBAAsB,EAAE;QAC9B,SAAS;QACT,KAAK,EAAE,iBAAiB;QACxB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IAErC,OAAO,CAAC,MAAM,iBAAiB,EAAE,CAAC,KAAK,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { Clock } from "homebridge-plugin-utils";
|
|
1
2
|
import type { Nullable } from "../types/index.ts";
|
|
2
3
|
export type LogColor = "cyan" | "red" | "yellow" | null;
|
|
3
4
|
/**
|
|
4
|
-
* Initializes the file logger. Creates the log file if it does not exist. Must be called after the data directory is ensured to exist.
|
|
5
|
+
* Initializes the file logger. Creates the log file if it does not exist. Must be called after the data directory is ensured to exist. A call is the one
|
|
6
|
+
* initialization of the process: it enters open, leaving the window's entries in the buffer for the first flush to append, or off, discarding them. Either
|
|
7
|
+
* outcome leaves the startup window behind.
|
|
5
8
|
* @param logPath - Absolute path to the log file, resolved by the caller via getLogFilePath().
|
|
6
9
|
* @param maxSize - Maximum log file size in bytes from CONFIG.logging.maxSize.
|
|
10
|
+
* @param clock - The clock the flush interval arms on and the pause stamps read; defaults to the system clock.
|
|
7
11
|
*/
|
|
8
|
-
export declare function initializeFileLogger(logPath: string, maxSize: number): Promise<void>;
|
|
12
|
+
export declare function initializeFileLogger(logPath: string, maxSize: number, clock?: Clock): Promise<void>;
|
|
9
13
|
/**
|
|
10
14
|
* Writes a log entry to the buffer. Entries are flushed to disk periodically.
|
|
11
15
|
* @param level - Log level ("info", "warn", "error", "debug").
|
|
@@ -20,9 +24,12 @@ export declare function writeLogEntry(level: string, message: string, color: Log
|
|
|
20
24
|
*/
|
|
21
25
|
export declare function flushLogBuffer(): Promise<void>;
|
|
22
26
|
/**
|
|
23
|
-
* Flushes the write buffer to disk synchronously.
|
|
27
|
+
* Flushes the write buffer to disk synchronously. Shutdown reaches it while the logger is closing and writes to the configured log file, and the process exit
|
|
28
|
+
* handler reaches it on either side of initialization. The fallback path serves that second position - an exit in the startup window, where the buffer holds
|
|
29
|
+
* the window's entries and no log file was ever opened - and a logger holding a file of its own ignores it in favor of that file.
|
|
30
|
+
* @param fallbackPath - Absolute path to write to when the logger never initialized. Shutdown omits it, and so does console mode, whose lines never enter the buffer.
|
|
24
31
|
*/
|
|
25
|
-
export declare function flushLogBufferSync(): void;
|
|
32
|
+
export declare function flushLogBufferSync(fallbackPath?: string): void;
|
|
26
33
|
/**
|
|
27
34
|
* Pure trim logic: given the current log file content and the configured maximum size, returns the trimmed content (keeping complete lines from the file's tail)
|
|
28
35
|
* or null when no trim is needed (file is already at or below half maxSize). Extracted from trimLogFile so the cut-at-newline algorithm is testable in isolation
|
|
@@ -38,7 +45,19 @@ export declare function flushLogBufferSync(): void;
|
|
|
38
45
|
*/
|
|
39
46
|
export declare function computeTrimmedLogContent(content: string, maxSize: number): Nullable<string>;
|
|
40
47
|
/**
|
|
41
|
-
* Shuts down the file logger,
|
|
48
|
+
* Shuts down the file logger: enters the closing state, waits for the write chain to drain, then flushes any remaining buffer synchronously and enters closed.
|
|
49
|
+
*
|
|
50
|
+
* The flush timer stops the moment the logger enters closing, because the chokepoint disposes a timer the next state does not carry, so no periodic flush can
|
|
51
|
+
* fire into the drain.
|
|
52
|
+
*
|
|
53
|
+
* The drain is what keeps shutdown from racing the writes it is meant to finish. A trim holds the log file across a read, a temp write, and a rename; a synchronous
|
|
54
|
+
* final flush issued while that rename is still pending appends to the file the rename is about to replace, so the last entries of the run are discarded along with
|
|
55
|
+
* the stale snapshot. Awaiting the chain first puts the final flush strictly after every mutation already in flight.
|
|
56
|
+
*
|
|
57
|
+
* The wait is bounded because a wedged filesystem operation must not hold the process open through its own shutdown. When the bound lapses the flush and the move
|
|
58
|
+
* to closed proceed anyway, which is the same outcome an unbounded wait would eventually reach minus the hang.
|
|
59
|
+
*
|
|
60
|
+
* The closed state keeps the path of the file it closed, so a line logged after this point - the exit handler's Chrome cleanup, a late process-level handler - is
|
|
61
|
+
* appended to that file synchronously instead of falling into the gap between the shutdown and the process exit.
|
|
42
62
|
*/
|
|
43
|
-
export declare function shutdownFileLogger(): void
|
|
44
|
-
//# sourceMappingURL=fileLogger.d.ts.map
|
|
63
|
+
export declare function shutdownFileLogger(): Promise<void>;
|