@tiledev/sdk-apptile-live-selling 0.16.0 → 0.16.1
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/attribution.d.ts +2 -16
- package/dist/attribution.d.ts.map +1 -1
- package/dist/attribution.js +4 -10
- package/dist/attribution.js.map +1 -1
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +11 -42
- package/dist/auctions.js.map +1 -1
- package/dist/cartAttributes.d.ts +0 -10
- package/dist/cartAttributes.d.ts.map +1 -1
- package/dist/cartAttributes.js +1 -20
- package/dist/cartAttributes.js.map +1 -1
- package/dist/client.d.ts +2 -51
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +23 -123
- package/dist/client.js.map +1 -1
- package/dist/clips.d.ts +1 -12
- package/dist/clips.d.ts.map +1 -1
- package/dist/clips.js +6 -114
- package/dist/clips.js.map +1 -1
- package/dist/commentLinks.d.ts +0 -29
- package/dist/commentLinks.d.ts.map +1 -1
- package/dist/commentLinks.js.map +1 -1
- package/dist/engine.native.d.ts.map +1 -1
- package/dist/engine.native.js +845 -17
- package/dist/engine.native.js.map +1 -1
- package/dist/index.d.ts +4 -48
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -240
- package/dist/index.js.map +1 -1
- package/dist/polls.d.ts.map +1 -1
- package/dist/polls.js +0 -3
- package/dist/polls.js.map +1 -1
- package/dist/react/LiveSellingProvider.d.ts +1 -54
- package/dist/react/LiveSellingProvider.d.ts.map +1 -1
- package/dist/react/LiveSellingProvider.js +3 -60
- package/dist/react/LiveSellingProvider.js.map +1 -1
- package/dist/react/LiveVideoTarget.d.ts.map +1 -1
- package/dist/react/LiveVideoTarget.js +3 -41
- package/dist/react/LiveVideoTarget.js.map +1 -1
- package/dist/react/index.d.ts +3 -30
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -79
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.web.d.ts +32 -36
- package/dist/react/index.web.d.ts.map +1 -1
- package/dist/react/index.web.js +122 -102
- package/dist/react/index.web.js.map +1 -1
- package/dist/react/useAuctionBidGate.d.ts +6 -62
- package/dist/react/useAuctionBidGate.d.ts.map +1 -1
- package/dist/react/useAuctionBidGate.js +27 -228
- package/dist/react/useAuctionBidGate.js.map +1 -1
- package/dist/react/useAuctionWins.d.ts +4 -14
- package/dist/react/useAuctionWins.d.ts.map +1 -1
- package/dist/react/useAuctionWins.js +5 -16
- package/dist/react/useAuctionWins.js.map +1 -1
- package/dist/react/useClips.d.ts +1 -7
- package/dist/react/useClips.d.ts.map +1 -1
- package/dist/react/useClips.js +7 -20
- package/dist/react/useClips.js.map +1 -1
- package/dist/react/useLiveSession.d.ts +3 -15
- package/dist/react/useLiveSession.d.ts.map +1 -1
- package/dist/react/useLiveSession.js +199 -612
- package/dist/react/useLiveSession.js.map +1 -1
- package/dist/react/useLiveStreams.d.ts.map +1 -1
- package/dist/react/useLiveStreams.js +2 -6
- package/dist/react/useLiveStreams.js.map +1 -1
- package/dist/react/useOngoingLive.d.ts +0 -1
- package/dist/react/useOngoingLive.d.ts.map +1 -1
- package/dist/react/useOngoingLive.js +1 -7
- package/dist/react/useOngoingLive.js.map +1 -1
- package/dist/react/useReplays.d.ts +0 -12
- package/dist/react/useReplays.d.ts.map +1 -1
- package/dist/react/useReplays.js +24 -56
- package/dist/react/useReplays.js.map +1 -1
- package/dist/react/useStreamInfo.d.ts +2 -13
- package/dist/react/useStreamInfo.d.ts.map +1 -1
- package/dist/react/useStreamInfo.js +8 -36
- package/dist/react/useStreamInfo.js.map +1 -1
- package/dist/replays.d.ts +0 -14
- package/dist/replays.d.ts.map +1 -1
- package/dist/replays.js +22 -68
- package/dist/replays.js.map +1 -1
- package/dist/session.d.ts +6 -39
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +22 -209
- package/dist/session.js.map +1 -1
- package/dist/sessionTypes.d.ts +18 -217
- package/dist/sessionTypes.d.ts.map +1 -1
- package/dist/sessionTypes.js +1 -2
- package/dist/sessionTypes.js.map +1 -1
- package/dist/streams.d.ts +1 -27
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +21 -84
- package/dist/streams.js.map +1 -1
- package/dist/types.d.ts +10 -288
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/wire.d.ts +0 -31
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +0 -25
- package/dist/wire.js.map +1 -1
- package/dist/zego.d.ts +1 -3
- package/dist/zego.d.ts.map +1 -1
- package/dist/zego.js +1 -1
- package/package.json +1 -1
- package/dist/auctionComments.d.ts +0 -25
- package/dist/auctionComments.d.ts.map +0 -1
- package/dist/auctionComments.js +0 -28
- package/dist/auctionComments.js.map +0 -1
- package/dist/auctionRules.d.ts +0 -77
- package/dist/auctionRules.d.ts.map +0 -1
- package/dist/auctionRules.js +0 -107
- package/dist/auctionRules.js.map +0 -1
- package/dist/cartExtension.d.ts +0 -39
- package/dist/cartExtension.d.ts.map +0 -1
- package/dist/cartExtension.js +0 -51
- package/dist/cartExtension.js.map +0 -1
- package/dist/checkoutRefused.d.ts +0 -9
- package/dist/checkoutRefused.d.ts.map +0 -1
- package/dist/checkoutRefused.js +0 -16
- package/dist/checkoutRefused.js.map +0 -1
- package/dist/clipsPage.d.ts +0 -29
- package/dist/clipsPage.d.ts.map +0 -1
- package/dist/clipsPage.js +0 -49
- package/dist/clipsPage.js.map +0 -1
- package/dist/commentHistory.d.ts +0 -70
- package/dist/commentHistory.d.ts.map +0 -1
- package/dist/commentHistory.js +0 -133
- package/dist/commentHistory.js.map +0 -1
- package/dist/commentLinkCards.d.ts +0 -11
- package/dist/commentLinkCards.d.ts.map +0 -1
- package/dist/commentLinkCards.js +0 -70
- package/dist/commentLinkCards.js.map +0 -1
- package/dist/giveawayPrize.d.ts +0 -13
- package/dist/giveawayPrize.d.ts.map +0 -1
- package/dist/giveawayPrize.js +0 -18
- package/dist/giveawayPrize.js.map +0 -1
- package/dist/giveawayPrizeLines.d.ts +0 -120
- package/dist/giveawayPrizeLines.d.ts.map +0 -1
- package/dist/giveawayPrizeLines.js +0 -97
- package/dist/giveawayPrizeLines.js.map +0 -1
- package/dist/giveawayPrizes.d.ts +0 -20
- package/dist/giveawayPrizes.d.ts.map +0 -1
- package/dist/giveawayPrizes.js +0 -50
- package/dist/giveawayPrizes.js.map +0 -1
- package/dist/giveawayRoster.d.ts +0 -53
- package/dist/giveawayRoster.d.ts.map +0 -1
- package/dist/giveawayRoster.js +0 -93
- package/dist/giveawayRoster.js.map +0 -1
- package/dist/heldComments.d.ts +0 -40
- package/dist/heldComments.d.ts.map +0 -1
- package/dist/heldComments.js +0 -75
- package/dist/heldComments.js.map +0 -1
- package/dist/hiddenShows.d.ts +0 -44
- package/dist/hiddenShows.d.ts.map +0 -1
- package/dist/hiddenShows.js +0 -53
- package/dist/hiddenShows.js.map +0 -1
- package/dist/linkLots.d.ts +0 -64
- package/dist/linkLots.d.ts.map +0 -1
- package/dist/linkLots.js +0 -84
- package/dist/linkLots.js.map +0 -1
- package/dist/liveHaptics.d.ts +0 -7
- package/dist/liveHaptics.d.ts.map +0 -1
- package/dist/liveHaptics.js +0 -11
- package/dist/liveHaptics.js.map +0 -1
- package/dist/liveHaptics.native.d.ts +0 -7
- package/dist/liveHaptics.native.d.ts.map +0 -1
- package/dist/liveHaptics.native.js +0 -12
- package/dist/liveHaptics.native.js.map +0 -1
- package/dist/livePages.d.ts +0 -176
- package/dist/livePages.d.ts.map +0 -1
- package/dist/livePages.js +0 -216
- package/dist/livePages.js.map +0 -1
- package/dist/liveRoom.d.ts +0 -21
- package/dist/liveRoom.d.ts.map +0 -1
- package/dist/liveRoom.js +0 -28
- package/dist/liveRoom.js.map +0 -1
- package/dist/liveShow.d.ts +0 -65
- package/dist/liveShow.d.ts.map +0 -1
- package/dist/liveShow.js +0 -65
- package/dist/liveShow.js.map +0 -1
- package/dist/missedPolls.d.ts +0 -27
- package/dist/missedPolls.d.ts.map +0 -1
- package/dist/missedPolls.js +0 -16
- package/dist/missedPolls.js.map +0 -1
- package/dist/pageOptions.d.ts +0 -149
- package/dist/pageOptions.d.ts.map +0 -1
- package/dist/pageOptions.js +0 -123
- package/dist/pageOptions.js.map +0 -1
- package/dist/pageTypes.d.ts +0 -185
- package/dist/pageTypes.d.ts.map +0 -1
- package/dist/pageTypes.js +0 -3
- package/dist/pageTypes.js.map +0 -1
- package/dist/phoneTaps.d.ts +0 -25
- package/dist/phoneTaps.d.ts.map +0 -1
- package/dist/phoneTaps.js +0 -47
- package/dist/phoneTaps.js.map +0 -1
- package/dist/pipWindow.d.ts +0 -85
- package/dist/pipWindow.d.ts.map +0 -1
- package/dist/pipWindow.js +0 -88
- package/dist/pipWindow.js.map +0 -1
- package/dist/react/clocks.d.ts +0 -29
- package/dist/react/clocks.d.ts.map +0 -1
- package/dist/react/clocks.js +0 -124
- package/dist/react/clocks.js.map +0 -1
- package/dist/react/navigation.d.ts +0 -13
- package/dist/react/navigation.d.ts.map +0 -1
- package/dist/react/navigation.js +0 -7
- package/dist/react/navigation.js.map +0 -1
- package/dist/react/platformSession.d.ts +0 -16
- package/dist/react/platformSession.d.ts.map +0 -1
- package/dist/react/platformSession.js +0 -28
- package/dist/react/platformSession.js.map +0 -1
- package/dist/react/platformSession.web.d.ts +0 -35
- package/dist/react/platformSession.web.d.ts.map +0 -1
- package/dist/react/platformSession.web.js +0 -148
- package/dist/react/platformSession.web.js.map +0 -1
- package/dist/react/replayPlayer.d.ts +0 -83
- package/dist/react/replayPlayer.d.ts.map +0 -1
- package/dist/react/replayPlayer.js +0 -315
- package/dist/react/replayPlayer.js.map +0 -1
- package/dist/react/share.d.ts +0 -22
- package/dist/react/share.d.ts.map +0 -1
- package/dist/react/share.js +0 -45
- package/dist/react/share.js.map +0 -1
- package/dist/react/shopifyProviders.d.ts +0 -82
- package/dist/react/shopifyProviders.d.ts.map +0 -1
- package/dist/react/shopifyProviders.js +0 -113
- package/dist/react/shopifyProviders.js.map +0 -1
- package/dist/react/showPages.d.ts +0 -106
- package/dist/react/showPages.d.ts.map +0 -1
- package/dist/react/showPages.js +0 -166
- package/dist/react/showPages.js.map +0 -1
- package/dist/react/showPagesOnDevice.d.ts +0 -18
- package/dist/react/showPagesOnDevice.d.ts.map +0 -1
- package/dist/react/showPagesOnDevice.js +0 -31
- package/dist/react/showPagesOnDevice.js.map +0 -1
- package/dist/react/startSignIn.d.ts +0 -3
- package/dist/react/startSignIn.d.ts.map +0 -1
- package/dist/react/startSignIn.js +0 -19
- package/dist/react/startSignIn.js.map +0 -1
- package/dist/react/systemPictureInPicture.d.ts +0 -34
- package/dist/react/systemPictureInPicture.d.ts.map +0 -1
- package/dist/react/systemPictureInPicture.js +0 -93
- package/dist/react/systemPictureInPicture.js.map +0 -1
- package/dist/react/useAccountName.d.ts +0 -8
- package/dist/react/useAccountName.d.ts.map +0 -1
- package/dist/react/useAccountName.js +0 -49
- package/dist/react/useAccountName.js.map +0 -1
- package/dist/react/useClipsPage.d.ts +0 -47
- package/dist/react/useClipsPage.d.ts.map +0 -1
- package/dist/react/useClipsPage.js +0 -130
- package/dist/react/useClipsPage.js.map +0 -1
- package/dist/react/useCommentLinkCards.d.ts +0 -6
- package/dist/react/useCommentLinkCards.d.ts.map +0 -1
- package/dist/react/useCommentLinkCards.js +0 -67
- package/dist/react/useCommentLinkCards.js.map +0 -1
- package/dist/react/useFeaturedClip.d.ts +0 -15
- package/dist/react/useFeaturedClip.d.ts.map +0 -1
- package/dist/react/useFeaturedClip.js +0 -52
- package/dist/react/useFeaturedClip.js.map +0 -1
- package/dist/react/useGiveawayEntry.d.ts +0 -59
- package/dist/react/useGiveawayEntry.d.ts.map +0 -1
- package/dist/react/useGiveawayEntry.js +0 -170
- package/dist/react/useGiveawayEntry.js.map +0 -1
- package/dist/react/useGiveawayPrize.d.ts +0 -12
- package/dist/react/useGiveawayPrize.d.ts.map +0 -1
- package/dist/react/useGiveawayPrize.js +0 -53
- package/dist/react/useGiveawayPrize.js.map +0 -1
- package/dist/react/useGiveawayPrizes.d.ts +0 -4
- package/dist/react/useGiveawayPrizes.d.ts.map +0 -1
- package/dist/react/useGiveawayPrizes.js +0 -58
- package/dist/react/useGiveawayPrizes.js.map +0 -1
- package/dist/react/useHiddenShows.d.ts +0 -10
- package/dist/react/useHiddenShows.d.ts.map +0 -1
- package/dist/react/useHiddenShows.js +0 -30
- package/dist/react/useHiddenShows.js.map +0 -1
- package/dist/react/useKeepScreenAwake.d.ts +0 -2
- package/dist/react/useKeepScreenAwake.d.ts.map +0 -1
- package/dist/react/useKeepScreenAwake.js +0 -34
- package/dist/react/useKeepScreenAwake.js.map +0 -1
- package/dist/react/useLiveAuction.d.ts +0 -106
- package/dist/react/useLiveAuction.d.ts.map +0 -1
- package/dist/react/useLiveAuction.js +0 -255
- package/dist/react/useLiveAuction.js.map +0 -1
- package/dist/react/useLiveChat.d.ts +0 -110
- package/dist/react/useLiveChat.d.ts.map +0 -1
- package/dist/react/useLiveChat.js +0 -230
- package/dist/react/useLiveChat.js.map +0 -1
- package/dist/react/useLiveGiveawaysAndPolls.d.ts +0 -95
- package/dist/react/useLiveGiveawaysAndPolls.d.ts.map +0 -1
- package/dist/react/useLiveGiveawaysAndPolls.js +0 -225
- package/dist/react/useLiveGiveawaysAndPolls.js.map +0 -1
- package/dist/react/useLivePage.d.ts +0 -136
- package/dist/react/useLivePage.d.ts.map +0 -1
- package/dist/react/useLivePage.js +0 -319
- package/dist/react/useLivePage.js.map +0 -1
- package/dist/react/useLiveShop.d.ts +0 -97
- package/dist/react/useLiveShop.d.ts.map +0 -1
- package/dist/react/useLiveShop.js +0 -197
- package/dist/react/useLiveShop.js.map +0 -1
- package/dist/react/useLiveShow.d.ts +0 -3
- package/dist/react/useLiveShow.d.ts.map +0 -1
- package/dist/react/useLiveShow.js +0 -21
- package/dist/react/useLiveShow.js.map +0 -1
- package/dist/react/useMySilentAuctionBids.d.ts +0 -29
- package/dist/react/useMySilentAuctionBids.d.ts.map +0 -1
- package/dist/react/useMySilentAuctionBids.js +0 -157
- package/dist/react/useMySilentAuctionBids.js.map +0 -1
- package/dist/react/useReplayPage.d.ts +0 -155
- package/dist/react/useReplayPage.d.ts.map +0 -1
- package/dist/react/useReplayPage.js +0 -580
- package/dist/react/useReplayPage.js.map +0 -1
- package/dist/react/useSilentAuctionLot.d.ts +0 -44
- package/dist/react/useSilentAuctionLot.d.ts.map +0 -1
- package/dist/react/useSilentAuctionLot.js +0 -168
- package/dist/react/useSilentAuctionLot.js.map +0 -1
- package/dist/react/useSilentAuctionLots.d.ts +0 -41
- package/dist/react/useSilentAuctionLots.d.ts.map +0 -1
- package/dist/react/useSilentAuctionLots.js +0 -64
- package/dist/react/useSilentAuctionLots.js.map +0 -1
- package/dist/react/useSilentAuctionRounds.d.ts +0 -15
- package/dist/react/useSilentAuctionRounds.d.ts.map +0 -1
- package/dist/react/useSilentAuctionRounds.js +0 -44
- package/dist/react/useSilentAuctionRounds.js.map +0 -1
- package/dist/replayPages.d.ts +0 -31
- package/dist/replayPages.d.ts.map +0 -1
- package/dist/replayPages.js +0 -34
- package/dist/replayPages.js.map +0 -1
- package/dist/shopifyCommerce.d.ts +0 -204
- package/dist/shopifyCommerce.d.ts.map +0 -1
- package/dist/shopifyCommerce.js +0 -217
- package/dist/shopifyCommerce.js.map +0 -1
- package/dist/shopifyIdentity.d.ts +0 -61
- package/dist/shopifyIdentity.d.ts.map +0 -1
- package/dist/shopifyIdentity.js +0 -61
- package/dist/shopifyIdentity.js.map +0 -1
- package/dist/shopifyIds.d.ts +0 -9
- package/dist/shopifyIds.d.ts.map +0 -1
- package/dist/shopifyIds.js +0 -18
- package/dist/shopifyIds.js.map +0 -1
- package/dist/showCredit.d.ts +0 -89
- package/dist/showCredit.d.ts.map +0 -1
- package/dist/showCredit.js +0 -120
- package/dist/showCredit.js.map +0 -1
- package/dist/showLinks.d.ts +0 -24
- package/dist/showLinks.d.ts.map +0 -1
- package/dist/showLinks.js +0 -23
- package/dist/showLinks.js.map +0 -1
- package/dist/showLots.d.ts +0 -44
- package/dist/showLots.d.ts.map +0 -1
- package/dist/showLots.js +0 -70
- package/dist/showLots.js.map +0 -1
- package/dist/showNames.d.ts +0 -77
- package/dist/showNames.d.ts.map +0 -1
- package/dist/showNames.js +0 -143
- package/dist/showNames.js.map +0 -1
- package/dist/showPages.d.ts +0 -56
- package/dist/showPages.d.ts.map +0 -1
- package/dist/showPages.js +0 -48
- package/dist/showPages.js.map +0 -1
- package/dist/silentAuctionFeed.d.ts +0 -49
- package/dist/silentAuctionFeed.d.ts.map +0 -1
- package/dist/silentAuctionFeed.js +0 -242
- package/dist/silentAuctionFeed.js.map +0 -1
- package/dist/silentAuctionRules.d.ts +0 -253
- package/dist/silentAuctionRules.d.ts.map +0 -1
- package/dist/silentAuctionRules.js +0 -489
- package/dist/silentAuctionRules.js.map +0 -1
- package/dist/silentAuctions.d.ts +0 -65
- package/dist/silentAuctions.d.ts.map +0 -1
- package/dist/silentAuctions.js +0 -272
- package/dist/silentAuctions.js.map +0 -1
- package/dist/storeData.d.ts +0 -16
- package/dist/storeData.d.ts.map +0 -1
- package/dist/storeData.js +0 -19
- package/dist/storeData.js.map +0 -1
- package/dist/ui/BubbleFrame.d.ts +0 -38
- package/dist/ui/BubbleFrame.d.ts.map +0 -1
- package/dist/ui/BubbleFrame.js +0 -181
- package/dist/ui/BubbleFrame.js.map +0 -1
- package/dist/ui/LiveBubble.d.ts +0 -43
- package/dist/ui/LiveBubble.d.ts.map +0 -1
- package/dist/ui/LiveBubble.js +0 -116
- package/dist/ui/LiveBubble.js.map +0 -1
- package/dist/ui/ReplayBubble.d.ts +0 -23
- package/dist/ui/ReplayBubble.d.ts.map +0 -1
- package/dist/ui/ReplayBubble.js +0 -71
- package/dist/ui/ReplayBubble.js.map +0 -1
- package/dist/ui.d.ts +0 -27
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -34
- package/dist/ui.js.map +0 -1
- package/dist/unreadRoomMessages.d.ts +0 -26
- package/dist/unreadRoomMessages.d.ts.map +0 -1
- package/dist/unreadRoomMessages.js +0 -62
- package/dist/unreadRoomMessages.js.map +0 -1
- package/dist/viewerRules.d.ts +0 -38
- package/dist/viewerRules.d.ts.map +0 -1
- package/dist/viewerRules.js +0 -46
- package/dist/viewerRules.js.map +0 -1
- package/dist/winsAttribution.d.ts +0 -22
- package/dist/winsAttribution.d.ts.map +0 -1
- package/dist/winsAttribution.js +0 -49
- package/dist/winsAttribution.js.map +0 -1
- package/dist/zegoEngine.d.ts +0 -173
- package/dist/zegoEngine.d.ts.map +0 -1
- package/dist/zegoEngine.js +0 -1069
- package/dist/zegoEngine.js.map +0 -1
package/dist/zegoEngine.js
DELETED
|
@@ -1,1069 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZegoLiveEngine = exports.ZegoLoginError = exports.TOKEN_RENEW_RETRY_MS = exports.TOKEN_RENEW_ATTEMPTS = exports.JOIN_RETRY_BASE_MS = exports.JOIN_ATTEMPTS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The live engine over `zego-express-engine-reactnative` — the whole of it, with the native pieces
|
|
6
|
-
* passed in.
|
|
7
|
-
*
|
|
8
|
-
* `engine.native.ts` builds the one instance an app uses, handing it the real Zego module, the real
|
|
9
|
-
* `Platform.OS`, the picture-in-picture module and the token call. Keeping those out of this file is
|
|
10
|
-
* what lets the tests drive the engine in Node with a stand-in Zego: before 0.9.0 the class imported
|
|
11
|
-
* `react-native` and the native package directly, so nothing in it could be tested and the
|
|
12
|
-
* batched-message, join and token bugs below shipped.
|
|
13
|
-
*
|
|
14
|
-
* Sole owner of the Zego engine: one instance, because the engine *is* a process-wide singleton. The
|
|
15
|
-
* room is joined and left and the render target is rebindable, rather than the engine being created and
|
|
16
|
-
* destroyed per mount (which caused the re-login churn blamed for an Android NetworkCallback leak).
|
|
17
|
-
*
|
|
18
|
-
* The engine also feeds the system picture-in-picture module — which stream is playing, and nothing
|
|
19
|
-
* more. It has to be told here rather than by the session, because only this file knows when the
|
|
20
|
-
* played id actually changes: a co-host mixer swap moves it from `{id}` to `{id}_mixed` with no
|
|
21
|
-
* involvement from React at all.
|
|
22
|
-
*
|
|
23
|
-
* Nothing here imports React, React Native, Zego or the native package.
|
|
24
|
-
*/
|
|
25
|
-
const client_1 = require("./client");
|
|
26
|
-
const wire_1 = require("./wire");
|
|
27
|
-
const commentLinks_1 = require("./commentLinks");
|
|
28
|
-
const guest_1 = require("./guest");
|
|
29
|
-
const showNames_1 = require("./showNames");
|
|
30
|
-
const polls_1 = require("./polls");
|
|
31
|
-
/** How many times a room login is tried before the join fails. */
|
|
32
|
-
exports.JOIN_ATTEMPTS = 3;
|
|
33
|
-
/** The wait before the second login attempt; it doubles for each one after (1 s, then 2 s). */
|
|
34
|
-
exports.JOIN_RETRY_BASE_MS = 1000;
|
|
35
|
-
/** How many times a token renewal is tried. Zego warns once, about 30 s before the token expires. */
|
|
36
|
-
exports.TOKEN_RENEW_ATTEMPTS = 3;
|
|
37
|
-
/** The wait between token renewal attempts. */
|
|
38
|
-
exports.TOKEN_RENEW_RETRY_MS = 2000;
|
|
39
|
-
/** A room login the Zego SDK refused, with its error code. */
|
|
40
|
-
class ZegoLoginError extends Error {
|
|
41
|
-
constructor(errorCode) {
|
|
42
|
-
super(`loginRoom failed with ${errorCode}`);
|
|
43
|
-
this.errorCode = errorCode;
|
|
44
|
-
this.name = 'ZegoLoginError';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ZegoLoginError = ZegoLoginError;
|
|
48
|
-
/**
|
|
49
|
-
* Every handler this package has attached to Zego, kept on `globalThis` rather than on the instance.
|
|
50
|
-
*
|
|
51
|
-
* Zego keeps its listeners in a static map that outlives this module: a Fast Refresh, or a second copy
|
|
52
|
-
* of the package in one bundle, builds a new engine object while the old one's handlers are still
|
|
53
|
-
* attached. Detaching by the handler references stored HERE removes exactly ours, wherever they came
|
|
54
|
-
* from. Before 0.9.0 the engine called `off(event)` with no handler, which removes EVERY listener on
|
|
55
|
-
* that event — including any other code in the app listening to the same Zego engine — and it left
|
|
56
|
-
* `playerQualityUpdate` out of the list altogether, so that one was attached twice (L16).
|
|
57
|
-
*/
|
|
58
|
-
const ATTACHED_KEY = Symbol.for('@tiledev/sdk-apptile-live-selling/zego-listeners');
|
|
59
|
-
function attachedHandlers() {
|
|
60
|
-
const holder = globalThis;
|
|
61
|
-
if (!holder[ATTACHED_KEY])
|
|
62
|
-
holder[ATTACHED_KEY] = [];
|
|
63
|
-
return holder[ATTACHED_KEY];
|
|
64
|
-
}
|
|
65
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
66
|
-
/**
|
|
67
|
-
* A name the room sent, as the SDK hands it out: never an email (`publicName`). Null when there is
|
|
68
|
-
* none, so the caller's fallback applies. Every name read off a room message goes through here.
|
|
69
|
-
*/
|
|
70
|
-
const roomName = (value) => (0, showNames_1.publicName)((0, wire_1.str)(value));
|
|
71
|
-
/** A reaction-style message's style: `mode` or `reactionType`, top level or under `data`; anything but `multiple` is `single`. */
|
|
72
|
-
function reactionModeOf(payload) {
|
|
73
|
-
var _a, _b, _c;
|
|
74
|
-
const value = (_c = (_b = (_a = (0, wire_1.str)((0, wire_1.path)(payload, 'data', 'mode'))) !== null && _a !== void 0 ? _a : (0, wire_1.str)((0, wire_1.path)(payload, 'data', 'reactionType'))) !== null && _b !== void 0 ? _b : (0, wire_1.str)(payload.mode)) !== null && _c !== void 0 ? _c : (0, wire_1.str)(payload.reactionType);
|
|
75
|
-
return value === 'multiple' ? 'multiple' : 'single';
|
|
76
|
-
}
|
|
77
|
-
class ZegoLiveEngine {
|
|
78
|
-
constructor(deps) {
|
|
79
|
-
this.deps = deps;
|
|
80
|
-
this.isNoop = false;
|
|
81
|
-
this.Z = null;
|
|
82
|
-
this.engineReady = false;
|
|
83
|
-
this.creating = null;
|
|
84
|
-
this.queue = Promise.resolve();
|
|
85
|
-
this.listeners = new Set();
|
|
86
|
-
/** The room this viewer is IN. Set only once `loginRoom` has succeeded. */
|
|
87
|
-
this.joined = null;
|
|
88
|
-
/** The room a login is in flight for. Room events that land mid-login are read against it. */
|
|
89
|
-
this.joiningRoom = null;
|
|
90
|
-
this.playingStreamId = null;
|
|
91
|
-
this.boundTag = null;
|
|
92
|
-
this.playingTag = null;
|
|
93
|
-
this.mixerActive = false;
|
|
94
|
-
this.guest = null;
|
|
95
|
-
this.previewTag = null;
|
|
96
|
-
this.viewerNameOverride = null;
|
|
97
|
-
this.commentSeq = 0;
|
|
98
|
-
this.mutedDeviceIds = [];
|
|
99
|
-
/** The last speaker mute asked for, applied once the engine exists if it was asked for before. */
|
|
100
|
-
this.speakerMuted = null;
|
|
101
|
-
}
|
|
102
|
-
subscribe(listener) {
|
|
103
|
-
this.listeners.add(listener);
|
|
104
|
-
return () => {
|
|
105
|
-
this.listeners.delete(listener);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Hands an event to every subscriber, each on its own.
|
|
110
|
-
*
|
|
111
|
-
* A subscriber that throws is logged and skipped. Before 0.9.0 the throw escaped into the Zego
|
|
112
|
-
* callback, so one bad listener stopped every listener after it from hearing the event — and the
|
|
113
|
-
* rest of a batched message with it.
|
|
114
|
-
*/
|
|
115
|
-
emit(event) {
|
|
116
|
-
for (const listener of Array.from(this.listeners)) {
|
|
117
|
-
try {
|
|
118
|
-
listener(event);
|
|
119
|
-
}
|
|
120
|
-
catch (caught) {
|
|
121
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.listener', event: event.type });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
wait(ms) {
|
|
126
|
-
var _a;
|
|
127
|
-
return ((_a = this.deps.wait) !== null && _a !== void 0 ? _a : sleep)(ms);
|
|
128
|
-
}
|
|
129
|
-
/** The room events are read against: the one we are in, or the one we are logging into. */
|
|
130
|
-
get room() {
|
|
131
|
-
var _a;
|
|
132
|
-
return (_a = this.joined) !== null && _a !== void 0 ? _a : this.joiningRoom;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* The loaded SDK. Only valid after `createEngine`, and every caller below is downstream of it —
|
|
136
|
-
* throwing beats the `undefined is not a constructor` a missing enum would produce deeper in.
|
|
137
|
-
*/
|
|
138
|
-
get Zego() {
|
|
139
|
-
if (!this.Z)
|
|
140
|
-
throw new Error('Zego SDK is not loaded');
|
|
141
|
-
return this.Z;
|
|
142
|
-
}
|
|
143
|
-
/** The default export is the engine class; the enums/structs are named exports. */
|
|
144
|
-
get Engine() {
|
|
145
|
-
var _a;
|
|
146
|
-
const mod = this.Zego;
|
|
147
|
-
return ((_a = mod === null || mod === void 0 ? void 0 : mod.default) !== null && _a !== void 0 ? _a : mod);
|
|
148
|
-
}
|
|
149
|
-
async ensureEngine() {
|
|
150
|
-
if (this.engineReady)
|
|
151
|
-
return;
|
|
152
|
-
if (!this.creating)
|
|
153
|
-
this.creating = this.createEngine();
|
|
154
|
-
try {
|
|
155
|
-
await this.creating;
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
this.creating = null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async createEngine() {
|
|
162
|
-
var _a;
|
|
163
|
-
this.Z = this.deps.loadZego();
|
|
164
|
-
const Engine = this.Engine;
|
|
165
|
-
const { ZegoScenario } = this.Zego;
|
|
166
|
-
// The native engine outlives this module, so adopt an existing instance rather than creating a
|
|
167
|
-
// second — "multiple instances" is a documented failure.
|
|
168
|
-
let existing = null;
|
|
169
|
-
try {
|
|
170
|
-
existing = Engine.instance();
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
existing = null;
|
|
174
|
-
}
|
|
175
|
-
if (!existing) {
|
|
176
|
-
// appSign empty is the documented pairing for token auth; the token rides on the room config.
|
|
177
|
-
await Engine.createEngineWithProfile({
|
|
178
|
-
appID: (_a = (0, client_1.getConfig)().zegoAppId) !== null && _a !== void 0 ? _a : 0,
|
|
179
|
-
appSign: '',
|
|
180
|
-
scenario: ZegoScenario.Default,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
// After the engine exists and before anything plays, and every time rather than only after a
|
|
184
|
-
// fresh create: the engine outlives this module, so an adopted one may never have been configured
|
|
185
|
-
// by this process. The native side ignores a second call.
|
|
186
|
-
try {
|
|
187
|
-
await this.deps.pip.configure();
|
|
188
|
-
}
|
|
189
|
-
catch (caught) {
|
|
190
|
-
// A live stream without picture-in-picture is still a working live stream.
|
|
191
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.configurePip' });
|
|
192
|
-
}
|
|
193
|
-
this.attachListeners();
|
|
194
|
-
this.engineReady = true;
|
|
195
|
-
// A surface that asked for silence before the engine existed was told nothing: `setMuted` has
|
|
196
|
-
// nothing to call until now. The host was audible over a Home tab on a cold launch.
|
|
197
|
-
if (this.speakerMuted !== null)
|
|
198
|
-
this.applySpeakerMuted(this.speakerMuted);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Zego stops delivering video once the app leaves the foreground unless this is set. iOS only;
|
|
202
|
-
* Android's PIP window is the activity itself, which stays visible and keeps decoding.
|
|
203
|
-
*/
|
|
204
|
-
async setBackgroundVideoEnabled(enabled) {
|
|
205
|
-
if (!this.engineReady)
|
|
206
|
-
return;
|
|
207
|
-
if (this.deps.platform !== 'ios')
|
|
208
|
-
return;
|
|
209
|
-
await this.Engine.instance().callExperimentalAPI(JSON.stringify({ method: 'liveroom.video.enable_ios_multitask', params: { enable: enabled } }));
|
|
210
|
-
}
|
|
211
|
-
attachListeners() {
|
|
212
|
-
const engine = this.Engine.instance();
|
|
213
|
-
const { ZegoUpdateType } = this.Zego;
|
|
214
|
-
// Ours only, by reference — see `attachedHandlers`. Attaching twice would deliver every comment
|
|
215
|
-
// and reaction twice over.
|
|
216
|
-
const attached = attachedHandlers();
|
|
217
|
-
for (const [event, handler] of attached.splice(0)) {
|
|
218
|
-
try {
|
|
219
|
-
engine.off(event, handler);
|
|
220
|
-
}
|
|
221
|
-
catch {
|
|
222
|
-
// Already gone with a destroyed engine.
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const on = (event, handler) => {
|
|
226
|
-
engine.on(event, handler);
|
|
227
|
-
attached.push([event, handler]);
|
|
228
|
-
};
|
|
229
|
-
on('roomStateUpdate', (_roomId, stateVal) => {
|
|
230
|
-
this.emit({ type: 'roomState', connected: stateVal === 2 });
|
|
231
|
-
if (stateVal === 2)
|
|
232
|
-
this.announceJoin();
|
|
233
|
-
});
|
|
234
|
-
on('roomStreamUpdate', (_roomId, updateType, streamList) => {
|
|
235
|
-
const room = this.room;
|
|
236
|
-
const ids = (0, wire_1.arr)(streamList).map((entry) => (0, wire_1.str)((0, wire_1.get)(entry, 'streamID')));
|
|
237
|
-
const isHost = ids.some((id) => id === (room === null || room === void 0 ? void 0 : room.streamingId) || id === (room === null || room === void 0 ? void 0 : room.mixedStreamId));
|
|
238
|
-
if (!isHost)
|
|
239
|
-
return;
|
|
240
|
-
this.emit({ type: 'publisher', publishing: updateType === ZegoUpdateType.Add });
|
|
241
|
-
});
|
|
242
|
-
on('roomOnlineUserCountUpdate', (_roomId, count) => {
|
|
243
|
-
this.emit({ type: 'viewers', count });
|
|
244
|
-
});
|
|
245
|
-
on('playerMediaEvent', (_streamId, event) => {
|
|
246
|
-
// 4/6 = video break/resume, 5/7 = audio break/resume. One field per event.
|
|
247
|
-
if (event === 4)
|
|
248
|
-
this.emit({ type: 'hostMedia', kind: 'video', broken: true });
|
|
249
|
-
if (event === 6)
|
|
250
|
-
this.emit({ type: 'hostMedia', kind: 'video', broken: false });
|
|
251
|
-
if (event === 5)
|
|
252
|
-
this.emit({ type: 'hostMedia', kind: 'audio', broken: true });
|
|
253
|
-
if (event === 7)
|
|
254
|
-
this.emit({ type: 'hostMedia', kind: 'audio', broken: false });
|
|
255
|
-
});
|
|
256
|
-
on('playerQualityUpdate', (streamId, quality) => {
|
|
257
|
-
var _a;
|
|
258
|
-
if (streamId !== this.playingStreamId)
|
|
259
|
-
return;
|
|
260
|
-
this.emit({ type: 'hostVideo', receiving: ((_a = (0, wire_1.num)((0, wire_1.get)(quality, 'videoRecvFPS'))) !== null && _a !== void 0 ? _a : 0) > 0 });
|
|
261
|
-
});
|
|
262
|
-
/*
|
|
263
|
-
* The three message channels below hand over a LIST. Zego batches whatever arrived together, so
|
|
264
|
-
* a list of two is an ordinary event — a pin and a bid in the same instant. Before 0.9.0 only
|
|
265
|
-
* `[0]` was read and the rest were dropped without a trace.
|
|
266
|
-
*/
|
|
267
|
-
on('roomStreamExtraInfoUpdate', (_roomId, streamList) => {
|
|
268
|
-
for (const entry of (0, wire_1.arr)(streamList)) {
|
|
269
|
-
const extra = (0, wire_1.get)(entry, 'extraInfo');
|
|
270
|
-
if (extra)
|
|
271
|
-
this.handleExtraInfo(extra);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
on('IMRecvBarrageMessage', (_roomId, messageList) => {
|
|
275
|
-
for (const message of (0, wire_1.arr)(messageList))
|
|
276
|
-
this.handleBarrage(message);
|
|
277
|
-
});
|
|
278
|
-
on('IMRecvCustomCommand', (_roomId, _from, command) => {
|
|
279
|
-
this.handleCommand(command);
|
|
280
|
-
});
|
|
281
|
-
on('IMRecvBroadcastMessage', (_roomId, messageList) => {
|
|
282
|
-
var _a;
|
|
283
|
-
// `sendTime` is the host's clock — the only reference an auction deadline can be read against.
|
|
284
|
-
for (const message of (0, wire_1.arr)(messageList)) {
|
|
285
|
-
this.handleBroadcast((0, wire_1.get)(message, 'message'), (_a = (0, wire_1.num)((0, wire_1.get)(message, 'sendTime'))) !== null && _a !== void 0 ? _a : 0);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
on('roomTokenWillExpire', (roomId) => {
|
|
289
|
-
void this.renewToken(roomId);
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Fetches a new room token and hands it to Zego before the old one runs out.
|
|
294
|
-
*
|
|
295
|
-
* Zego warns once, about 30 s ahead. Before 0.9.0 nothing listened, so a viewer watching longer than
|
|
296
|
-
* the token's life was dropped from the room mid-show — and a dropped room only reports itself as
|
|
297
|
-
* `connecting`, so the shopper saw a spinner over a show that was still running.
|
|
298
|
-
*
|
|
299
|
-
* Only the viewer's own room: a guest's token comes from its invite and cannot be re-minted here.
|
|
300
|
-
*/
|
|
301
|
-
async renewToken(roomId) {
|
|
302
|
-
const room = this.joined;
|
|
303
|
-
if (!room || room.roomId !== roomId || this.guest)
|
|
304
|
-
return;
|
|
305
|
-
for (let attempt = 1; attempt <= exports.TOKEN_RENEW_ATTEMPTS; attempt += 1) {
|
|
306
|
-
try {
|
|
307
|
-
const token = await this.deps.fetchToken(room.viewerId, room.streamingId);
|
|
308
|
-
if (!token)
|
|
309
|
-
throw new Error('The gateway returned no room token');
|
|
310
|
-
// Left, or moved to another show, while the token was being fetched.
|
|
311
|
-
if (this.joined !== room)
|
|
312
|
-
return;
|
|
313
|
-
await this.Engine.instance().renewToken(roomId, token);
|
|
314
|
-
this.joined = { ...room, token };
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
catch (caught) {
|
|
318
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.renewToken', attempt, streamingId: room.streamingId });
|
|
319
|
-
if (attempt < exports.TOKEN_RENEW_ATTEMPTS)
|
|
320
|
-
await this.wait(exports.TOKEN_RENEW_RETRY_MS);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
handleExtraInfo(raw) {
|
|
325
|
-
const payload = (0, wire_1.parseJson)(raw);
|
|
326
|
-
if (!(0, wire_1.isRecord)(payload))
|
|
327
|
-
return;
|
|
328
|
-
const lot = () => { var _a; return (_a = (0, wire_1.str)((0, wire_1.path)(payload, 'data', 'store_product_id'))) !== null && _a !== void 0 ? _a : (0, wire_1.str)((0, wire_1.path)(payload, 'data', 'product_id')); };
|
|
329
|
-
switch ((0, wire_1.str)(payload.event)) {
|
|
330
|
-
case 'PRODUCT_CHANGE': {
|
|
331
|
-
const id = lot();
|
|
332
|
-
if (id)
|
|
333
|
-
this.emit({ type: 'productChange', storeProductId: id });
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
case 'DELETE_PRODUCT': {
|
|
337
|
-
const id = lot();
|
|
338
|
-
if (id)
|
|
339
|
-
this.emit({ type: 'productRemoved', storeProductId: id });
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
case 'MULTIPLIER_CHANGE': {
|
|
343
|
-
const multiplier = (0, wire_1.num)(payload.count);
|
|
344
|
-
this.emit({
|
|
345
|
-
type: 'viewerMultiplier',
|
|
346
|
-
multiplier: multiplier !== null && multiplier > 0 ? multiplier : 1,
|
|
347
|
-
});
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
default:
|
|
351
|
-
this.emit({ type: 'unknown', channel: 'extraInfo', payload });
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
handleBarrage(message) {
|
|
355
|
-
var _a, _b, _c;
|
|
356
|
-
const payload = (0, wire_1.parseJson)((0, wire_1.get)(message, 'message'));
|
|
357
|
-
if (!(0, wire_1.isRecord)(payload))
|
|
358
|
-
return;
|
|
359
|
-
// The host mutes a viewer for everyone by flagging their messages, not by dropping them.
|
|
360
|
-
if (payload.muted === true)
|
|
361
|
-
return;
|
|
362
|
-
// `payload.name` wins: a bid announcement is relayed by the host's own Zego identity, so
|
|
363
|
-
// `fromUser.userName` there is the HOST's name, not the bidder's.
|
|
364
|
-
const fromUser = roomName((0, wire_1.path)(message, 'fromUser', 'userName'));
|
|
365
|
-
const userName = (_b = (_a = roomName(payload.name)) !== null && _a !== void 0 ? _a : fromUser) !== null && _b !== void 0 ? _b : 'Anonymous';
|
|
366
|
-
this.emit({
|
|
367
|
-
type: 'comment',
|
|
368
|
-
comment: this.makeComment((_c = (0, wire_1.str)(payload.comment)) !== null && _c !== void 0 ? _c : '', userName, payload.source, undefined, false, payload.urlPreview),
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
makeComment(text, userName, source, tipAmount, isOwn, urlPreview) {
|
|
372
|
-
const known = source === 'HOST' || source === 'MODERATOR' || source === 'TIP' ? source : 'USER';
|
|
373
|
-
this.commentSeq += 1;
|
|
374
|
-
return {
|
|
375
|
-
id: `c${this.commentSeq}`,
|
|
376
|
-
text,
|
|
377
|
-
userName,
|
|
378
|
-
source: known,
|
|
379
|
-
tipAmount,
|
|
380
|
-
urlPreview: (0, commentLinks_1.toUrlPreview)(urlPreview),
|
|
381
|
-
isOwn,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
handleCommand(raw) {
|
|
385
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
386
|
-
const payload = (0, wire_1.parseJson)(raw);
|
|
387
|
-
if (!(0, wire_1.isRecord)(payload))
|
|
388
|
-
return;
|
|
389
|
-
switch ((0, wire_1.str)(payload.type)) {
|
|
390
|
-
case 'REACTION_ANNOUCEMENT':
|
|
391
|
-
this.emit({
|
|
392
|
-
type: 'reaction',
|
|
393
|
-
reactionUrl: (_a = (0, wire_1.str)(payload.reactionUrl)) !== null && _a !== void 0 ? _a : '',
|
|
394
|
-
userName: (_b = roomName(payload.userName)) !== null && _b !== void 0 ? _b : 'Anonymous',
|
|
395
|
-
});
|
|
396
|
-
return;
|
|
397
|
-
case 'CART_ANNOUCEMENT':
|
|
398
|
-
this.emit({
|
|
399
|
-
type: 'cartAnnouncement',
|
|
400
|
-
productTitle: (_c = (0, wire_1.str)(payload.productTitle)) !== null && _c !== void 0 ? _c : '',
|
|
401
|
-
userName: (_d = roomName(payload.userName)) !== null && _d !== void 0 ? _d : 'Anonymous',
|
|
402
|
-
sellId: (_e = (0, wire_1.str)(payload.sellId)) !== null && _e !== void 0 ? _e : null,
|
|
403
|
-
});
|
|
404
|
-
return;
|
|
405
|
-
case 'DONATION_ANNOUCEMENT':
|
|
406
|
-
this.emit({
|
|
407
|
-
type: 'comment',
|
|
408
|
-
comment: this.makeComment('Sent a tip', (_f = roomName(payload.userName)) !== null && _f !== void 0 ? _f : 'Anonymous', 'TIP', (_g = (0, wire_1.str)(payload.donationAmount)) !== null && _g !== void 0 ? _g : undefined, false),
|
|
409
|
-
});
|
|
410
|
-
return;
|
|
411
|
-
case 'PRODUCT_SOLD_ANNOUNCEMENT':
|
|
412
|
-
this.emit({
|
|
413
|
-
type: 'sold',
|
|
414
|
-
announcement: {
|
|
415
|
-
productName: (_h = (0, wire_1.str)(payload.productName)) !== null && _h !== void 0 ? _h : '',
|
|
416
|
-
variantLabel: (0, wire_1.str)(payload.variantLabel),
|
|
417
|
-
quantity: (_j = (0, wire_1.num)(payload.qty)) !== null && _j !== void 0 ? _j : 1,
|
|
418
|
-
productImage: (0, wire_1.str)(payload.productImage),
|
|
419
|
-
sellId: (_k = (0, wire_1.str)(payload.sellId)) !== null && _k !== void 0 ? _k : null,
|
|
420
|
-
},
|
|
421
|
-
});
|
|
422
|
-
return;
|
|
423
|
-
case 'START_POLL':
|
|
424
|
-
this.emitPollStarted((_l = payload.poll) !== null && _l !== void 0 ? _l : (0, wire_1.path)(payload, 'data', 'poll'));
|
|
425
|
-
return;
|
|
426
|
-
case 'MUTE_USER':
|
|
427
|
-
this.mutedDeviceIds = this.mutedIdsFrom(payload.mutedUsers);
|
|
428
|
-
this.emit({ type: 'mutedUsers', deviceIds: this.mutedDeviceIds });
|
|
429
|
-
return;
|
|
430
|
-
case 'START_BIDDING':
|
|
431
|
-
this.emitBiddingStarted(payload.data, (_m = (0, wire_1.num)((0, wire_1.path)(payload, 'data', 'timeStamp'))) !== null && _m !== void 0 ? _m : 0);
|
|
432
|
-
return;
|
|
433
|
-
case 'BROADCAST_BID_INFO':
|
|
434
|
-
this.emitBidInfo(payload.data, (_o = (0, wire_1.num)(payload.serverSentTime)) !== null && _o !== void 0 ? _o : 0);
|
|
435
|
-
return;
|
|
436
|
-
case 'giveaway_start':
|
|
437
|
-
this.emitGiveawayStarted(payload.eventData);
|
|
438
|
-
return;
|
|
439
|
-
case 'giveaway_end':
|
|
440
|
-
this.emitGiveawayEnded(payload.eventData);
|
|
441
|
-
return;
|
|
442
|
-
case 'user_registered': {
|
|
443
|
-
const count = (0, wire_1.num)((0, wire_1.path)(payload, 'eventData', 'usersCount'));
|
|
444
|
-
if (count !== null)
|
|
445
|
-
this.emit({ type: 'giveawayEntries', count });
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
case 'REACTION_TYPE_UPDATE':
|
|
449
|
-
this.emit({ type: 'reactionMode', mode: reactionModeOf(payload) });
|
|
450
|
-
return;
|
|
451
|
-
default:
|
|
452
|
-
this.emit({ type: 'unknown', channel: 'customCommand', payload });
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Device ids out of a host mute list.
|
|
457
|
-
*
|
|
458
|
-
* Entries with no id are dropped rather than passed through: the host dashboard can record a comment
|
|
459
|
-
* with no `deviceId`, and an id-less entry would match every viewer whose id is also absent —
|
|
460
|
-
* muting one person would silence the room.
|
|
461
|
-
*/
|
|
462
|
-
mutedIdsFrom(raw) {
|
|
463
|
-
return (0, wire_1.arr)(raw)
|
|
464
|
-
.map((entry) => (0, wire_1.str)((0, wire_1.get)(entry, 'deviceId')))
|
|
465
|
-
.filter((id) => !!id);
|
|
466
|
-
}
|
|
467
|
-
/** The moderator's Zego user id, whatever shape it arrived in — an object smuggled through crashes iOS. */
|
|
468
|
-
moderatorIdFrom(raw) {
|
|
469
|
-
var _a, _b;
|
|
470
|
-
if (!raw)
|
|
471
|
-
return null;
|
|
472
|
-
if (typeof raw === 'string')
|
|
473
|
-
return raw;
|
|
474
|
-
if (typeof raw === 'object') {
|
|
475
|
-
const record = raw;
|
|
476
|
-
const id = (_b = (_a = record.userID) !== null && _a !== void 0 ? _a : record.userId) !== null && _b !== void 0 ? _b : record.user_id;
|
|
477
|
-
if (typeof id === 'string' && id)
|
|
478
|
-
return id;
|
|
479
|
-
if (typeof id === 'number')
|
|
480
|
-
return String(id);
|
|
481
|
-
}
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
emitBiddingStarted(data, serverNowMs) {
|
|
485
|
-
const wire = data;
|
|
486
|
-
const endsAtMs = (0, wire_1.num)((0, wire_1.get)(wire, 'endTimeStamp'));
|
|
487
|
-
if (endsAtMs === null || endsAtMs <= 0)
|
|
488
|
-
return;
|
|
489
|
-
this.emit({
|
|
490
|
-
type: 'biddingStarted',
|
|
491
|
-
endsAtMs,
|
|
492
|
-
serverNowMs: serverNowMs || endsAtMs,
|
|
493
|
-
storeProductId: (0, wire_1.str)((0, wire_1.get)(wire, 'selectedProductId')),
|
|
494
|
-
moderatorId: this.moderatorIdFrom((0, wire_1.get)(wire, 'moderatorInCharge')),
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
emitBidInfo(data, serverNowMs) {
|
|
498
|
-
var _a, _b, _c, _d;
|
|
499
|
-
const wire = data;
|
|
500
|
-
if (!(0, wire_1.isRecord)(wire))
|
|
501
|
-
return;
|
|
502
|
-
const endsAtMs = (0, wire_1.num)(wire.newEndTimeStamp);
|
|
503
|
-
const user = wire.user;
|
|
504
|
-
this.emit({
|
|
505
|
-
type: 'bidInfo',
|
|
506
|
-
highestBid: (_a = (0, wire_1.num)(wire.newHighestBid)) !== null && _a !== void 0 ? _a : 0,
|
|
507
|
-
nextBid: (_b = (0, wire_1.num)(wire.nextBid)) !== null && _b !== void 0 ? _b : 0,
|
|
508
|
-
endsAtMs: endsAtMs !== null && endsAtMs > 0 ? endsAtMs : null,
|
|
509
|
-
serverNowMs,
|
|
510
|
-
leader: (0, wire_1.isRecord)(user)
|
|
511
|
-
? { userId: (_c = (0, wire_1.str)(user.userId)) !== null && _c !== void 0 ? _c : '', userName: (_d = roomName(user.userName)) !== null && _d !== void 0 ? _d : '' }
|
|
512
|
-
: null,
|
|
513
|
-
moderatorId: this.moderatorIdFrom(wire.moderatorInCharge),
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
emitGiveawayStarted(eventData) {
|
|
517
|
-
const wire = eventData;
|
|
518
|
-
const storeProductId = (0, wire_1.str)((0, wire_1.get)(wire, 'productId'));
|
|
519
|
-
if (!storeProductId)
|
|
520
|
-
return;
|
|
521
|
-
this.emit({
|
|
522
|
-
type: 'giveawayStarted',
|
|
523
|
-
storeProductId,
|
|
524
|
-
variantId: (0, wire_1.str)((0, wire_1.get)(wire, 'variantId')),
|
|
525
|
-
entryCount: (0, wire_1.num)((0, wire_1.get)(wire, 'userCount')),
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
emitGiveawayEnded(eventData) {
|
|
529
|
-
const storeProductId = (0, wire_1.str)((0, wire_1.get)(eventData, 'productId'));
|
|
530
|
-
if (!storeProductId)
|
|
531
|
-
return;
|
|
532
|
-
// The host sends the literal string "null" when a giveaway closes with nobody in it, so only an
|
|
533
|
-
// object is a real winner.
|
|
534
|
-
const winner = (0, wire_1.get)(eventData, 'winner');
|
|
535
|
-
const winnerName = (0, wire_1.isRecord)(winner) ? roomName(winner.displayName) : null;
|
|
536
|
-
this.emit({ type: 'giveawayEnded', storeProductId, winnerName });
|
|
537
|
-
}
|
|
538
|
-
handleBroadcast(raw, serverNowMs = 0) {
|
|
539
|
-
var _a, _b, _c, _d, _e, _f;
|
|
540
|
-
const payload = (0, wire_1.parseJson)(raw);
|
|
541
|
-
if (!(0, wire_1.isRecord)(payload))
|
|
542
|
-
return;
|
|
543
|
-
switch ((0, wire_1.str)(payload.type)) {
|
|
544
|
-
case 'START_BIDDING':
|
|
545
|
-
this.emitBiddingStarted(payload.data, serverNowMs);
|
|
546
|
-
return;
|
|
547
|
-
case 'CLOSE_BIDDING':
|
|
548
|
-
this.emit({ type: 'biddingClosed' });
|
|
549
|
-
return;
|
|
550
|
-
case 'BID_WINNER_ANNOUNCEMENT': {
|
|
551
|
-
const wire = payload.data;
|
|
552
|
-
const meta = (0, wire_1.path)(wire, 'bidWinner', 'meta');
|
|
553
|
-
this.emit({
|
|
554
|
-
type: 'auctionWon',
|
|
555
|
-
win: {
|
|
556
|
-
userName: (_a = roomName((0, wire_1.path)(meta, 'user', 'userName'))) !== null && _a !== void 0 ? _a : '',
|
|
557
|
-
winningBid: (_b = (0, wire_1.num)((0, wire_1.get)(meta, 'winningBid'))) !== null && _b !== void 0 ? _b : 0,
|
|
558
|
-
storeProductId: (0, wire_1.str)((0, wire_1.path)(wire, 'auctionedProduct', 'store_product_id')),
|
|
559
|
-
},
|
|
560
|
-
});
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
case 'START_POLL':
|
|
564
|
-
this.emitPollStarted((0, wire_1.path)(payload, 'data', 'poll'));
|
|
565
|
-
return;
|
|
566
|
-
case 'BROADCAST_POLL_RESULTS': {
|
|
567
|
-
const results = (0, polls_1.toLivePollResults)((0, wire_1.path)(payload, 'data', 'pollResults'));
|
|
568
|
-
if (results)
|
|
569
|
-
this.emit({ type: 'pollResults', results });
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
case 'REACTION_ANNOUCEMENT':
|
|
573
|
-
this.emit({
|
|
574
|
-
type: 'reaction',
|
|
575
|
-
reactionUrl: (_d = (_c = (0, wire_1.str)((0, wire_1.path)(payload, 'data', 'reactionUrl'))) !== null && _c !== void 0 ? _c : (0, wire_1.str)(payload.reactionUrl)) !== null && _d !== void 0 ? _d : '',
|
|
576
|
-
userName: (_f = (_e = roomName((0, wire_1.path)(payload, 'data', 'userName'))) !== null && _e !== void 0 ? _e : roomName(payload.userName)) !== null && _f !== void 0 ? _f : 'Anonymous',
|
|
577
|
-
});
|
|
578
|
-
return;
|
|
579
|
-
case 'END_POLL':
|
|
580
|
-
this.emit({ type: 'pollEnded' });
|
|
581
|
-
return;
|
|
582
|
-
/**
|
|
583
|
-
* The host's reaction setting, changed mid-show.
|
|
584
|
-
*
|
|
585
|
-
* On the BROADCAST channel deliberately, not stream extra info where `MULTIPLIER_CHANGE` lives:
|
|
586
|
-
* extra info is a single slot, so a third event there would overwrite whatever product change
|
|
587
|
-
* was in it and force the console to re-send all three every time the room's population moves.
|
|
588
|
-
* This channel is a message, so it competes with nothing.
|
|
589
|
-
*
|
|
590
|
-
* Wire: `{type: 'REACTION_MODE_CHANGE', data: {mode: 'single' | 'multiple'}}`, with a bare
|
|
591
|
-
* `mode` at the top level accepted too, because the channel's existing senders are split on it.
|
|
592
|
-
* Anything but `multiple` is `single` — the same reading `streams.ts` gives the stored record,
|
|
593
|
-
* so a typo degrades the same way in both places rather than throwing.
|
|
594
|
-
*
|
|
595
|
-
* Reaches only who is in the room NOW. A later joiner has the record, which is why the dashboard
|
|
596
|
-
* has to persist `meta.reactionType` as well as send this.
|
|
597
|
-
*/
|
|
598
|
-
case 'REACTION_MODE_CHANGE':
|
|
599
|
-
// The dashboard's name for the same change (0.16.0), with the style as `reactionType`.
|
|
600
|
-
case 'REACTION_TYPE_UPDATE':
|
|
601
|
-
this.emit({ type: 'reactionMode', mode: reactionModeOf(payload) });
|
|
602
|
-
return;
|
|
603
|
-
/**
|
|
604
|
-
* The host pinned, replaced or unpinned a comment: `{ type, comment }`, `comment: null` for an
|
|
605
|
-
* unpin. Sent by the gateway (`apptile-live-selling` `pinnedComment.ts`) when the dashboard
|
|
606
|
-
* saves the pin; the same pin is on the record as `pinned_comment` for anyone arriving later.
|
|
607
|
-
*/
|
|
608
|
-
case 'PINNED_COMMENT_CHANGED':
|
|
609
|
-
this.emit({ type: 'pinnedCommentChanged', comment: (0, wire_1.toPinnedComment)(payload.comment) });
|
|
610
|
-
return;
|
|
611
|
-
case 'MUTE_USER':
|
|
612
|
-
this.mutedDeviceIds = this.mutedIdsFrom((0, wire_1.path)(payload, 'data', 'mutedUsers'));
|
|
613
|
-
this.emit({ type: 'mutedUsers', deviceIds: this.mutedDeviceIds });
|
|
614
|
-
return;
|
|
615
|
-
case 'STREAM_ENDED':
|
|
616
|
-
this.emit({ type: 'streamEnded' });
|
|
617
|
-
return;
|
|
618
|
-
case 'MIXER_STATE':
|
|
619
|
-
void this.applyMixerState(!!payload.active);
|
|
620
|
-
return;
|
|
621
|
-
case 'COHOST_ADMITTED':
|
|
622
|
-
if (!this.isOurSlot(payload.slot))
|
|
623
|
-
return;
|
|
624
|
-
this.emit({
|
|
625
|
-
type: 'guestAdmitted',
|
|
626
|
-
slot: Number(payload.slot),
|
|
627
|
-
mixerLayout: (0, guest_1.toMixerLayout)(payload.mixerLayout),
|
|
628
|
-
});
|
|
629
|
-
return;
|
|
630
|
-
case 'COHOST_REMOVED':
|
|
631
|
-
if (!this.isOurSlot(payload.slot))
|
|
632
|
-
return;
|
|
633
|
-
this.emit({ type: 'guestRemoved', slot: Number(payload.slot) });
|
|
634
|
-
return;
|
|
635
|
-
case 'COHOST_MUTE_AUDIO':
|
|
636
|
-
if (!this.isOurSlot(payload.slot))
|
|
637
|
-
return;
|
|
638
|
-
this.emit({ type: 'guestMutedByHost', slot: Number(payload.slot), muted: !!payload.muted });
|
|
639
|
-
return;
|
|
640
|
-
case 'COHOST_CAM_OFF':
|
|
641
|
-
if (!this.isOurSlot(payload.slot))
|
|
642
|
-
return;
|
|
643
|
-
this.emit({ type: 'guestCameraOffByHost', slot: Number(payload.slot), off: !!payload.off });
|
|
644
|
-
return;
|
|
645
|
-
case 'LAYOUT_CHANGED': {
|
|
646
|
-
const layout = (0, guest_1.toMixerLayout)(payload.mixerLayout);
|
|
647
|
-
if (layout)
|
|
648
|
-
this.emit({ type: 'mixerLayout', layout });
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
case 'GUESTS_CHANGED':
|
|
652
|
-
return;
|
|
653
|
-
default:
|
|
654
|
-
this.emit({ type: 'unknown', channel: 'broadcast', payload });
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
isOurSlot(slot) {
|
|
658
|
-
return this.guest != null && Number(slot) === this.guest.slot;
|
|
659
|
-
}
|
|
660
|
-
emitPollStarted(raw) {
|
|
661
|
-
const poll = (0, polls_1.toLivePoll)(raw);
|
|
662
|
-
if (poll)
|
|
663
|
-
this.emit({ type: 'pollStarted', poll, results: (0, polls_1.toEmbeddedResults)(raw) });
|
|
664
|
-
}
|
|
665
|
-
async applyMixerState(active) {
|
|
666
|
-
this.mixerActive = active;
|
|
667
|
-
this.emit({ type: 'mixer', active });
|
|
668
|
-
const target = this.targetStreamId();
|
|
669
|
-
if (!target || target === this.playingStreamId)
|
|
670
|
-
return;
|
|
671
|
-
try {
|
|
672
|
-
await this.playStream(target);
|
|
673
|
-
}
|
|
674
|
-
catch (caught) {
|
|
675
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.mixerSwap', target });
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
targetStreamId() {
|
|
679
|
-
if (!this.joined)
|
|
680
|
-
return null;
|
|
681
|
-
return this.mixerActive && this.joined.mixedStreamId ? this.joined.mixedStreamId : this.joined.streamingId;
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Tells the room (the host's screen) this viewer joined, under their latest name: one set since the
|
|
685
|
-
* join was asked for (`setViewerName`) beats the one it was asked under. Before 0.9.2 it was always
|
|
686
|
-
* the join's, so a name that arrived after the login was never what the host saw join.
|
|
687
|
-
*/
|
|
688
|
-
announceJoin() {
|
|
689
|
-
var _a;
|
|
690
|
-
const room = this.room;
|
|
691
|
-
if (!room)
|
|
692
|
-
return;
|
|
693
|
-
const userName = (_a = this.viewerNameOverride) !== null && _a !== void 0 ? _a : room.viewerName;
|
|
694
|
-
this.Engine.instance()
|
|
695
|
-
.sendCustomCommand(room.roomId, JSON.stringify({ type: 'USER_JOINED', userName }), [])
|
|
696
|
-
.catch((error) => (0, client_1.getLogger)().error('[liveSelling] announceJoin', error));
|
|
697
|
-
}
|
|
698
|
-
enqueue(operation) {
|
|
699
|
-
const result = this.queue.then(operation, operation);
|
|
700
|
-
this.queue = result.catch(() => undefined);
|
|
701
|
-
return result;
|
|
702
|
-
}
|
|
703
|
-
join(params) {
|
|
704
|
-
var _a;
|
|
705
|
-
// The name the room shows for this viewer: never an email (`publicName`).
|
|
706
|
-
const safe = { ...params, viewerName: (_a = (0, showNames_1.publicName)(params.viewerName)) !== null && _a !== void 0 ? _a : 'Anonymous' };
|
|
707
|
-
return this.enqueue(() => this.joinNow(safe));
|
|
708
|
-
}
|
|
709
|
-
leave() {
|
|
710
|
-
// A guest owns the room login while one is active; `leaveGuest` is the way out of guest mode.
|
|
711
|
-
if (this.guest)
|
|
712
|
-
return Promise.resolve();
|
|
713
|
-
return this.enqueue(() => this.leaveNow());
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Enters the room, trying `JOIN_ATTEMPTS` times with a doubling wait between.
|
|
717
|
-
*
|
|
718
|
-
* **`joined` is set only once `loginRoom` has succeeded.** Before 0.9.0 it was set before the login,
|
|
719
|
-
* and a failed login left it set — so the next `join` for the same show returned early, believing it
|
|
720
|
-
* was already in, and the session sat on `connecting` until the app was killed. A failure now leaves
|
|
721
|
-
* the engine as if it had never tried, and a later `join` works.
|
|
722
|
-
*/
|
|
723
|
-
async joinNow(params) {
|
|
724
|
-
var _a;
|
|
725
|
-
await this.ensureEngine();
|
|
726
|
-
if (((_a = this.joined) === null || _a === void 0 ? void 0 : _a.streamingId) === params.streamingId)
|
|
727
|
-
return;
|
|
728
|
-
if (this.joined)
|
|
729
|
-
await this.leaveNow();
|
|
730
|
-
const { ZegoUser, ZegoRoomConfig } = this.Zego;
|
|
731
|
-
/**
|
|
732
|
-
* Seeded from the record, not assumed false.
|
|
733
|
-
*
|
|
734
|
-
* A guest admitted before this viewer arrived means the mixer is already publishing
|
|
735
|
-
* `{streamingId}_mixed`, and the `MIXER_STATE` broadcast that would have said so went out before
|
|
736
|
-
* they were in the room — broadcasts are never replayed. The mixer's output is a server-side
|
|
737
|
-
* task rather than a room participant, so `roomStreamUpdate` does not mention it either. Without
|
|
738
|
-
* this the viewer plays the host's solo stream for the rest of the show and the co-host simply
|
|
739
|
-
* never appears. Same reason `mutedDeviceIds` is seeded from the record beside it.
|
|
740
|
-
*/
|
|
741
|
-
this.mixerActive = params.hasActiveGuest && !!params.mixedStreamId;
|
|
742
|
-
// Before the room is entered, so the first comment after a cold rejoin is already checked.
|
|
743
|
-
this.mutedDeviceIds = params.mutedDeviceIds;
|
|
744
|
-
this.joiningRoom = params;
|
|
745
|
-
try {
|
|
746
|
-
for (let attempt = 1;; attempt += 1) {
|
|
747
|
-
try {
|
|
748
|
-
const result = await this.Engine.instance().loginRoom(params.roomId, new ZegoUser(params.viewerId, params.viewerName), new ZegoRoomConfig(0, true, params.token));
|
|
749
|
-
if (result === null || result === void 0 ? void 0 : result.errorCode)
|
|
750
|
-
throw new ZegoLoginError(result.errorCode);
|
|
751
|
-
this.joined = params;
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
catch (caught) {
|
|
755
|
-
// Zego may still hold a half-made session for the room; a fresh login wants it gone.
|
|
756
|
-
await this.logoutQuietly(params.roomId);
|
|
757
|
-
if (attempt >= exports.JOIN_ATTEMPTS)
|
|
758
|
-
throw caught;
|
|
759
|
-
(0, client_1.logWarning)(caught, { at: 'liveEngine.join', attempt, streamingId: params.streamingId });
|
|
760
|
-
await this.wait(exports.JOIN_RETRY_BASE_MS * 2 ** (attempt - 1));
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
finally {
|
|
765
|
-
this.joiningRoom = null;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
async logoutQuietly(roomId) {
|
|
769
|
-
try {
|
|
770
|
-
await this.Engine.instance().logoutRoom(roomId);
|
|
771
|
-
}
|
|
772
|
-
catch {
|
|
773
|
-
// Nothing to log out of — the login never got that far.
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
async bindView(reactTag, force = false) {
|
|
777
|
-
return this.enqueue(() => this.bindViewNow(reactTag, force));
|
|
778
|
-
}
|
|
779
|
-
async bindViewNow(reactTag, force = false) {
|
|
780
|
-
const target = this.targetStreamId();
|
|
781
|
-
if (!force &&
|
|
782
|
-
reactTag === this.boundTag &&
|
|
783
|
-
reactTag === this.playingTag &&
|
|
784
|
-
target &&
|
|
785
|
-
target === this.playingStreamId) {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
this.boundTag = reactTag;
|
|
789
|
-
if (!target || reactTag == null)
|
|
790
|
-
return;
|
|
791
|
-
await this.playStream(target);
|
|
792
|
-
}
|
|
793
|
-
async refreshPlayback() {
|
|
794
|
-
return this.enqueue(() => this.refreshPlaybackNow());
|
|
795
|
-
}
|
|
796
|
-
async refreshPlaybackNow() {
|
|
797
|
-
const target = this.targetStreamId();
|
|
798
|
-
if (!target || this.boundTag == null)
|
|
799
|
-
return;
|
|
800
|
-
const { ZegoView, ZegoPlayerConfig } = this.Zego;
|
|
801
|
-
this.playingStreamId = target;
|
|
802
|
-
this.playingTag = this.boundTag;
|
|
803
|
-
void this.deps.pip.setStream(target);
|
|
804
|
-
await this.Engine.instance().startPlayingStream(target, new ZegoView(this.boundTag, 1, 0), new ZegoPlayerConfig());
|
|
805
|
-
}
|
|
806
|
-
async stopPlayback() {
|
|
807
|
-
return this.enqueue(() => this.stopPlaybackNow());
|
|
808
|
-
}
|
|
809
|
-
async stopPlaybackNow() {
|
|
810
|
-
const playing = this.playingStreamId;
|
|
811
|
-
this.playingStreamId = null;
|
|
812
|
-
this.playingTag = null;
|
|
813
|
-
this.boundTag = null;
|
|
814
|
-
void this.deps.pip.setStream(null);
|
|
815
|
-
if (!playing)
|
|
816
|
-
return;
|
|
817
|
-
await this.Engine.instance().stopPlayingStream(playing);
|
|
818
|
-
}
|
|
819
|
-
async playStream(streamId) {
|
|
820
|
-
if (this.boundTag == null)
|
|
821
|
-
return;
|
|
822
|
-
const { ZegoView, ZegoPlayerConfig } = this.Zego;
|
|
823
|
-
const previous = this.playingStreamId;
|
|
824
|
-
// Stopped only for a different stream. The same stream moving to another view (the Live screen to
|
|
825
|
-
// the bubble or Android's picture-in-picture window, and back) is started again with the new view,
|
|
826
|
-
// which Zego documents as updating the canvas ("The developer can update the player canvas by
|
|
827
|
-
// calling this function again (the streamID must be the same)", `startPlayingStream`). The
|
|
828
|
-
// pictures keep coming. Before 0.9.2 every move stopped and restarted the stream, and the new view
|
|
829
|
-
// stayed dark until the next keyframe arrived (2026-10-08: "a dark screen" on entering PiP).
|
|
830
|
-
if (previous && previous !== streamId) {
|
|
831
|
-
await this.Engine.instance().stopPlayingStream(previous);
|
|
832
|
-
}
|
|
833
|
-
this.playingStreamId = streamId;
|
|
834
|
-
this.playingTag = this.boundTag;
|
|
835
|
-
await this.Engine.instance().startPlayingStream(streamId, new ZegoView(this.boundTag, 1, 0), new ZegoPlayerConfig());
|
|
836
|
-
// Tracks the mixed id through a co-host swap, which is why it is set here rather than at join.
|
|
837
|
-
void this.deps.pip.setStream(streamId);
|
|
838
|
-
this.emit({ type: 'videoBound', tag: this.playingTag });
|
|
839
|
-
}
|
|
840
|
-
// ─── Guest / co-host ──────────────────────────────────────────────────────
|
|
841
|
-
joinAsGuest(credentials, previewTag) {
|
|
842
|
-
return this.enqueue(() => this.joinAsGuestNow(credentials, previewTag));
|
|
843
|
-
}
|
|
844
|
-
async joinAsGuestNow(credentials, previewTag) {
|
|
845
|
-
await this.ensureEngine();
|
|
846
|
-
const engine = this.Engine.instance();
|
|
847
|
-
const { ZegoUser, ZegoRoomConfig, ZegoOrientation, ZegoPublishChannel } = this.Zego;
|
|
848
|
-
// The viewer login has to go first: one session per engine, and the publish privilege lives in
|
|
849
|
-
// the guest's token.
|
|
850
|
-
if (this.joined)
|
|
851
|
-
await this.leaveNow();
|
|
852
|
-
this.guest = credentials;
|
|
853
|
-
this.emit({ type: 'guestMode', active: true });
|
|
854
|
-
// Before publishing: without it the server-side MixStream output is rotated.
|
|
855
|
-
await engine.setAppOrientation(ZegoOrientation.PortraitUp, ZegoPublishChannel.Main);
|
|
856
|
-
await engine.useFrontCamera(true, ZegoPublishChannel.Main);
|
|
857
|
-
const result = await engine.loginRoom(credentials.roomId, new ZegoUser(credentials.userId, credentials.userName), new ZegoRoomConfig(0, true, credentials.token));
|
|
858
|
-
if (result === null || result === void 0 ? void 0 : result.errorCode) {
|
|
859
|
-
this.guest = null;
|
|
860
|
-
this.emit({ type: 'guestMode', active: false });
|
|
861
|
-
throw new Error(`guest loginRoom failed with ${result.errorCode}`);
|
|
862
|
-
}
|
|
863
|
-
if (previewTag != null)
|
|
864
|
-
await this.startPreviewNow(previewTag);
|
|
865
|
-
await engine.startPublishingStream(credentials.guestStreamId, ZegoPublishChannel.Main, {
|
|
866
|
-
roomID: credentials.roomId,
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
bindGuestPreview(reactTag) {
|
|
870
|
-
return this.enqueue(() => this.startPreviewNow(reactTag));
|
|
871
|
-
}
|
|
872
|
-
async startPreviewNow(reactTag) {
|
|
873
|
-
if (!this.guest || reactTag == null || reactTag === this.previewTag)
|
|
874
|
-
return;
|
|
875
|
-
const { ZegoView, ZegoPublishChannel } = this.Zego;
|
|
876
|
-
this.previewTag = reactTag;
|
|
877
|
-
await this.Engine.instance().startPreview(new ZegoView(reactTag, 1, 0), ZegoPublishChannel.Main);
|
|
878
|
-
}
|
|
879
|
-
bindGuestHostView(reactTag) {
|
|
880
|
-
return this.enqueue(async () => {
|
|
881
|
-
if (!this.guest || reactTag == null)
|
|
882
|
-
return;
|
|
883
|
-
const { ZegoView, ZegoPlayerConfig } = this.Zego;
|
|
884
|
-
// The host's raw stream, never `_mixed`: the mix contains this guest.
|
|
885
|
-
await this.Engine.instance().startPlayingStream(this.guest.streamingId, new ZegoView(reactTag, 1, 0), new ZegoPlayerConfig());
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
async setGuestMicMuted(muted) {
|
|
889
|
-
if (!this.guest)
|
|
890
|
-
return;
|
|
891
|
-
const engine = this.Engine.instance();
|
|
892
|
-
const { ZegoPublishChannel } = this.Zego;
|
|
893
|
-
await engine.muteMicrophone(muted);
|
|
894
|
-
await engine.mutePublishStreamAudio(muted, ZegoPublishChannel.Main);
|
|
895
|
-
}
|
|
896
|
-
async setGuestCameraOff(off) {
|
|
897
|
-
if (!this.guest)
|
|
898
|
-
return;
|
|
899
|
-
const engine = this.Engine.instance();
|
|
900
|
-
const { ZegoPublishChannel } = this.Zego;
|
|
901
|
-
await engine.enableCamera(!off, ZegoPublishChannel.Main);
|
|
902
|
-
await engine.mutePublishStreamVideo(off, ZegoPublishChannel.Main);
|
|
903
|
-
}
|
|
904
|
-
async flipGuestCamera(front) {
|
|
905
|
-
if (!this.guest)
|
|
906
|
-
return;
|
|
907
|
-
const { ZegoPublishChannel } = this.Zego;
|
|
908
|
-
await this.Engine.instance().useFrontCamera(front, ZegoPublishChannel.Main);
|
|
909
|
-
}
|
|
910
|
-
leaveGuest() {
|
|
911
|
-
return this.enqueue(() => this.leaveGuestNow());
|
|
912
|
-
}
|
|
913
|
-
async leaveGuestNow() {
|
|
914
|
-
const guest = this.guest;
|
|
915
|
-
if (!guest)
|
|
916
|
-
return;
|
|
917
|
-
const engine = this.Engine.instance();
|
|
918
|
-
const { ZegoPublishChannel } = this.Zego;
|
|
919
|
-
const logger = (0, client_1.getLogger)();
|
|
920
|
-
// Each guarded on its own: a failure part-way must not leave the room joined.
|
|
921
|
-
try {
|
|
922
|
-
await engine.stopPublishingStream(ZegoPublishChannel.Main);
|
|
923
|
-
}
|
|
924
|
-
catch (caught) {
|
|
925
|
-
logger.error('[liveSelling] stopPublishing', caught);
|
|
926
|
-
}
|
|
927
|
-
try {
|
|
928
|
-
await engine.stopPreview(ZegoPublishChannel.Main);
|
|
929
|
-
}
|
|
930
|
-
catch (caught) {
|
|
931
|
-
logger.error('[liveSelling] stopPreview', caught);
|
|
932
|
-
}
|
|
933
|
-
try {
|
|
934
|
-
await engine.stopPlayingStream(guest.streamingId);
|
|
935
|
-
}
|
|
936
|
-
catch {
|
|
937
|
-
// Nothing was playing — the guest may never have seen the host.
|
|
938
|
-
}
|
|
939
|
-
try {
|
|
940
|
-
await engine.logoutRoom(guest.roomId);
|
|
941
|
-
}
|
|
942
|
-
catch (caught) {
|
|
943
|
-
logger.error('[liveSelling] guestLogout', caught);
|
|
944
|
-
}
|
|
945
|
-
this.guest = null;
|
|
946
|
-
this.previewTag = null;
|
|
947
|
-
this.emit({ type: 'guestMode', active: false });
|
|
948
|
-
}
|
|
949
|
-
setMutedDeviceIds(ids) {
|
|
950
|
-
const changed = ids.length !== this.mutedDeviceIds.length || ids.some((id, index) => id !== this.mutedDeviceIds[index]);
|
|
951
|
-
if (!changed)
|
|
952
|
-
return;
|
|
953
|
-
this.mutedDeviceIds = ids;
|
|
954
|
-
this.emit({ type: 'mutedUsers', deviceIds: ids });
|
|
955
|
-
}
|
|
956
|
-
setViewerName(name) {
|
|
957
|
-
// Published to the whole room with every comment: never an email (`publicName`).
|
|
958
|
-
this.viewerNameOverride = (0, showNames_1.publicName)(name);
|
|
959
|
-
}
|
|
960
|
-
get publishedName() {
|
|
961
|
-
var _a, _b, _c;
|
|
962
|
-
return (_c = (_a = this.viewerNameOverride) !== null && _a !== void 0 ? _a : (_b = this.joined) === null || _b === void 0 ? void 0 : _b.viewerName) !== null && _c !== void 0 ? _c : 'Anonymous';
|
|
963
|
-
}
|
|
964
|
-
/** Remembered when the engine does not exist yet, and applied the moment it does. */
|
|
965
|
-
setMuted(muted) {
|
|
966
|
-
this.speakerMuted = muted;
|
|
967
|
-
if (!this.engineReady)
|
|
968
|
-
return;
|
|
969
|
-
this.applySpeakerMuted(muted);
|
|
970
|
-
}
|
|
971
|
-
applySpeakerMuted(muted) {
|
|
972
|
-
try {
|
|
973
|
-
void Promise.resolve(this.Engine.instance().muteSpeaker(muted)).catch((caught) => (0, client_1.getLogger)().error(caught, { at: 'liveEngine.muteSpeaker' }));
|
|
974
|
-
}
|
|
975
|
-
catch (caught) {
|
|
976
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.muteSpeaker' });
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
async sendComment(text, deviceId, options) {
|
|
980
|
-
if (!this.joined || !text.trim())
|
|
981
|
-
return null;
|
|
982
|
-
const muted = (options === null || options === void 0 ? void 0 : options.forceMuted) === true || this.mutedDeviceIds.includes(deviceId);
|
|
983
|
-
await this.Engine.instance().sendBarrageMessage(this.joined.roomId, JSON.stringify({ name: this.publishedName, comment: text, source: 'USER', deviceId, muted, isBanned: false }));
|
|
984
|
-
return this.makeComment(text, this.publishedName, 'USER', undefined, true);
|
|
985
|
-
}
|
|
986
|
-
async sendReaction(reactionUrl) {
|
|
987
|
-
if (!this.joined)
|
|
988
|
-
return;
|
|
989
|
-
const userName = this.publishedName;
|
|
990
|
-
// `sendCustomCommand` does not echo to the sender, so emit the local event here.
|
|
991
|
-
await this.Engine.instance().sendCustomCommand(this.joined.roomId, JSON.stringify({ type: 'REACTION_ANNOUCEMENT', reactionUrl, userName, roomId: this.joined.roomId }), []);
|
|
992
|
-
this.emit({ type: 'reaction', reactionUrl, userName });
|
|
993
|
-
}
|
|
994
|
-
async sendBid(params) {
|
|
995
|
-
var _a;
|
|
996
|
-
if (!this.joined || !params.moderatorId)
|
|
997
|
-
return;
|
|
998
|
-
const { ZegoUser } = this.Zego;
|
|
999
|
-
// Coerced at the crash boundary: a non-string recipient id is an uncatchable native crash on iOS.
|
|
1000
|
-
const moderatorId = String(params.moderatorId);
|
|
1001
|
-
await this.Engine.instance().sendCustomCommand(this.joined.roomId, JSON.stringify({
|
|
1002
|
-
type: 'BID_PLACED',
|
|
1003
|
-
data: {
|
|
1004
|
-
bidAmount: params.bidAmount,
|
|
1005
|
-
user: params.bidder,
|
|
1006
|
-
timeStamp: params.placedAtMs,
|
|
1007
|
-
userOptedVariantId: (_a = params.variantId) !== null && _a !== void 0 ? _a : '',
|
|
1008
|
-
},
|
|
1009
|
-
}), [new ZegoUser(moderatorId, moderatorId)]);
|
|
1010
|
-
}
|
|
1011
|
-
async sendCartAnnouncement(productTitle, sellId) {
|
|
1012
|
-
if (!this.joined || !productTitle.trim())
|
|
1013
|
-
return;
|
|
1014
|
-
const userName = this.publishedName;
|
|
1015
|
-
const code = sellId !== null && sellId !== void 0 ? sellId : null;
|
|
1016
|
-
await this.Engine.instance().sendCustomCommand(this.joined.roomId, JSON.stringify({
|
|
1017
|
-
type: 'CART_ANNOUCEMENT',
|
|
1018
|
-
productTitle,
|
|
1019
|
-
userName,
|
|
1020
|
-
sellId: code,
|
|
1021
|
-
roomId: this.joined.roomId,
|
|
1022
|
-
}), []);
|
|
1023
|
-
this.emit({ type: 'cartAnnouncement', productTitle, userName, sellId: code });
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* Leaves the room, and never throws.
|
|
1027
|
-
*
|
|
1028
|
-
* The engine forgets the room FIRST, then asks Zego to stop. Before 0.9.0 a failing
|
|
1029
|
-
* `stopPlayingStream` or `logoutRoom` threw out of here with `joined` still set, which wedged every
|
|
1030
|
-
* later join for that show (it returned early, believing it was in), and rejected the caller's
|
|
1031
|
-
* `leave()` for good measure.
|
|
1032
|
-
*/
|
|
1033
|
-
async leaveNow() {
|
|
1034
|
-
if (!this.engineReady || !this.joined)
|
|
1035
|
-
return;
|
|
1036
|
-
const room = this.joined;
|
|
1037
|
-
const playing = this.playingStreamId;
|
|
1038
|
-
this.playingStreamId = null;
|
|
1039
|
-
this.playingTag = null;
|
|
1040
|
-
this.boundTag = null;
|
|
1041
|
-
this.joined = null;
|
|
1042
|
-
const engine = this.Engine.instance();
|
|
1043
|
-
if (playing) {
|
|
1044
|
-
try {
|
|
1045
|
-
await engine.stopPlayingStream(playing);
|
|
1046
|
-
}
|
|
1047
|
-
catch (caught) {
|
|
1048
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.leave.stopPlaying', streamingId: room.streamingId });
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
try {
|
|
1052
|
-
await engine.logoutRoom(room.roomId);
|
|
1053
|
-
}
|
|
1054
|
-
catch (caught) {
|
|
1055
|
-
(0, client_1.getLogger)().error(caught, { at: 'liveEngine.leave.logout', streamingId: room.streamingId });
|
|
1056
|
-
}
|
|
1057
|
-
this.emit({ type: 'videoBound', tag: null });
|
|
1058
|
-
}
|
|
1059
|
-
async destroy() {
|
|
1060
|
-
if (!this.engineReady)
|
|
1061
|
-
return;
|
|
1062
|
-
await this.leave();
|
|
1063
|
-
this.creating = null;
|
|
1064
|
-
this.Engine.destroyEngine();
|
|
1065
|
-
this.engineReady = false;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
exports.ZegoLiveEngine = ZegoLiveEngine;
|
|
1069
|
-
//# sourceMappingURL=zegoEngine.js.map
|