@tiledev/sdk-apptile-live-selling 0.16.0-beta.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/README.md +5 -1
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +11 -41
- package/dist/auctions.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 +3 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -233
- 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 -46
- package/dist/react/LiveSellingProvider.d.ts.map +1 -1
- package/dist/react/LiveSellingProvider.js +3 -57
- 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 -561
- 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 +5 -31
- 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 +2 -2
- 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 -58
- package/dist/liveShow.d.ts.map +0 -1
- package/dist/liveShow.js +0 -55
- package/dist/liveShow.js.map +0 -1
- package/dist/pageOptions.d.ts +0 -134
- package/dist/pageOptions.d.ts.map +0 -1
- package/dist/pageOptions.js +0 -102
- 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 -74
- package/dist/react/shopifyProviders.d.ts.map +0 -1
- package/dist/react/shopifyProviders.js +0 -110
- 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 -253
- package/dist/react/useLiveAuction.js.map +0 -1
- package/dist/react/useLiveChat.d.ts +0 -115
- package/dist/react/useLiveChat.d.ts.map +0 -1
- package/dist/react/useLiveChat.js +0 -231
- 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 -140
- 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 -96
- package/dist/react/useLiveShop.d.ts.map +0 -1
- package/dist/react/useLiveShop.js +0 -195
- 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 -578
- 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 -214
- 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 -87
- 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 -28
- package/dist/showLots.d.ts.map +0 -1
- package/dist/showLots.js +0 -51
- 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 -236
- package/dist/silentAuctionRules.d.ts.map +0 -1
- package/dist/silentAuctionRules.js +0 -478
- 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 -45
- package/dist/storeData.d.ts.map +0 -1
- package/dist/storeData.js +0 -35
- 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 -37
- package/dist/ui/LiveBubble.d.ts.map +0 -1
- package/dist/ui/LiveBubble.js +0 -101
- 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/viewerRules.d.ts +0 -39
- package/dist/viewerRules.d.ts.map +0 -1
- package/dist/viewerRules.js +0 -46
- package/dist/viewerRules.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/README.md
CHANGED
|
@@ -494,6 +494,10 @@ const routes: LiveSellingRoutes = {
|
|
|
494
494
|
shopName={APP_NAME}
|
|
495
495
|
// 0.15.0: the names nobody watching may go by, from a list the app publishes (`blockedNamesFrom`).
|
|
496
496
|
blockedNames={blockedNamesFrom(publishedBlockedNames)}
|
|
497
|
+
// 0.16.0, optional: a limit on each viewer's reactions, refilled when the host features another product;
|
|
498
|
+
// past it a tap sends nothing and onReactionLimitReached is called. Unset: no limit.
|
|
499
|
+
reactionLimit={15}
|
|
500
|
+
onReactionLimitReached={() => showToast('Please wait before reacting again.')}
|
|
497
501
|
>
|
|
498
502
|
<ShopifyLiveSessionProvider>
|
|
499
503
|
<ReplayPlayerProvider>
|
|
@@ -798,7 +802,7 @@ gate.bidOnItsWay; // true for BID_ON_ITS_WAY_MS (1.2 s) after a bid goes
|
|
|
798
802
|
```
|
|
799
803
|
|
|
800
804
|
The store's bar (0.16.0): the provider's `viewerRestrictions` (on Shopify, the customer's `BIDBLOCKED` /
|
|
801
|
-
`APPBLOCKED` tags). Barred, a bid stops at `blocked`, before unpaid wins. Not read yet, it waits at
|
|
805
|
+
`APPBLOCKED` tags, read by `viewerRestrictionsFromTags`). Barred, a bid stops at `blocked`, before unpaid wins. Not read yet, it waits at
|
|
802
806
|
`checkingAccount` ("Checking your account…") while they are read again, then goes on (or stops at `blocked`);
|
|
803
807
|
not read within `ACCOUNT_CHECK_LIMIT_MS` (10 s) it is dropped at `accountUnknown`.
|
|
804
808
|
|
package/dist/auctions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctions.d.ts","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"auctions.d.ts","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,SAAS,CAAC;AAuExE,eAAO,MAAM,QAAQ,EAAE,WAoFtB,CAAC"}
|
package/dist/auctions.js
CHANGED
|
@@ -24,8 +24,6 @@ const UNPAID_WINS_QUERY = /* GraphQL */ `
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
`;
|
|
27
|
-
/** A silent auction's wins are recorded under a key of their own, `silent_…` (0.12.0). */
|
|
28
|
-
const SILENT_KEY_PREFIX = 'silent_';
|
|
29
27
|
async function fetchWinnerMetafield() {
|
|
30
28
|
var _a, _b;
|
|
31
29
|
const customerAccountRequest = (0, client_1.getCustomerAccountRequest)();
|
|
@@ -61,22 +59,6 @@ function isPayable(raw) {
|
|
|
61
59
|
* The error is deliberately one-sided. Skipping an unpayable key can at worst let through a bid the
|
|
62
60
|
* host refuses; counting one blocks a paying customer permanently.
|
|
63
61
|
*/
|
|
64
|
-
/**
|
|
65
|
-
* The streams whose unpaid wins block bidding elsewhere (0.12.0): every stream with something payable,
|
|
66
|
-
* save a silent auction's (`silent_…`) whose payment deadlines haven't passed. A silent win's winner
|
|
67
|
-
* has until its `purchaseDeadline` to pay and is expected to go on shopping and bidding meanwhile; one
|
|
68
|
-
* with no deadline never becomes overdue, so never blocks (Sparkl's rule). Live wins are unchanged.
|
|
69
|
-
*/
|
|
70
|
-
function blockingStreamIds(parsed, nowMs) {
|
|
71
|
-
return payableStreamIds(parsed).filter((streamingId) => {
|
|
72
|
-
if (!streamingId.startsWith(SILENT_KEY_PREFIX))
|
|
73
|
-
return true;
|
|
74
|
-
return parsed[streamingId].filter(isPayable).some((raw) => {
|
|
75
|
-
const deadline = raw.purchaseDeadline ? Date.parse(raw.purchaseDeadline) : Number.NaN;
|
|
76
|
-
return Number.isFinite(deadline) && deadline < nowMs;
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
62
|
function payableStreamIds(parsed) {
|
|
81
63
|
return Object.keys(parsed).filter((streamingId) => {
|
|
82
64
|
const entries = parsed[streamingId];
|
|
@@ -124,7 +106,7 @@ exports.auctions = {
|
|
|
124
106
|
async unpaidStreamIds() {
|
|
125
107
|
try {
|
|
126
108
|
const parsed = await fetchWinnerMetafield();
|
|
127
|
-
return parsed ?
|
|
109
|
+
return parsed ? payableStreamIds(parsed) : [];
|
|
128
110
|
}
|
|
129
111
|
catch {
|
|
130
112
|
// A metafield read failing must not lock a customer out of bidding.
|
|
@@ -136,27 +118,19 @@ exports.auctions = {
|
|
|
136
118
|
if (!parsed)
|
|
137
119
|
return null;
|
|
138
120
|
/**
|
|
139
|
-
*
|
|
121
|
+
* The first stream with something payable, rather than the first key.
|
|
140
122
|
*
|
|
141
|
-
*
|
|
142
|
-
* on a second stream while the first is unpaid
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* reached the cart (production's DEL-2569). Each item keeps the stream it was won on.
|
|
146
|
-
*
|
|
147
|
-
* `streamingId` stays one stream — the first with something payable, not the first key, so a
|
|
148
|
-
* leftover empty key cannot hide a real win behind it — because `auction_id` is a single cart
|
|
149
|
-
* attribute and there is no honest value for a cart spanning two shows. That is a limitation, not
|
|
150
|
-
* a solved problem: per production's note on DEL-2569, the host marks that one stream's tab settled,
|
|
151
|
-
* so wins carried over from another stay flagged unpaid until it catches up. Accepted there for the
|
|
152
|
-
* same reason it is here: a prize the shopper paid for and can see beats one that silently does not
|
|
153
|
-
* exist, and the alternative (a cart per stream) needs a checkout that can open more than one.
|
|
123
|
+
* One tab per checkout is the host's model — the cart carries a single `auction_id` and the gate
|
|
124
|
+
* stops a customer accruing wins on a second stream while the first is unpaid — so in practice
|
|
125
|
+
* there is one. Taking `Object.keys()[0]` regardless meant a leftover empty key hid a real win
|
|
126
|
+
* sitting behind it, and the customer was blocked by the very win the tab refused to show.
|
|
154
127
|
*/
|
|
155
|
-
const
|
|
156
|
-
const [streamingId] = streamingIds;
|
|
128
|
+
const [streamingId] = payableStreamIds(parsed);
|
|
157
129
|
if (!streamingId)
|
|
158
130
|
return null;
|
|
159
|
-
const items =
|
|
131
|
+
const items = (Array.isArray(parsed[streamingId]) ? parsed[streamingId] : [])
|
|
132
|
+
.filter(isPayable)
|
|
133
|
+
.map((raw) => {
|
|
160
134
|
var _a;
|
|
161
135
|
return ({
|
|
162
136
|
productGid: `gid://shopify/Product/${raw.productId}`,
|
|
@@ -164,12 +138,8 @@ exports.auctions = {
|
|
|
164
138
|
winningBid: Number(raw.winningBid) || 0,
|
|
165
139
|
isGiveaway: !!raw.isGiveaway,
|
|
166
140
|
discountCode: (_a = raw.discountCode) !== null && _a !== void 0 ? _a : null,
|
|
167
|
-
streamingId: stream,
|
|
168
|
-
// A silent auction's two fields, only when it has them, so a live win is as it was.
|
|
169
|
-
...(typeof raw.lotNumber === 'number' ? { lotNumber: raw.lotNumber } : {}),
|
|
170
|
-
...(raw.purchaseDeadline ? { purchaseDeadline: raw.purchaseDeadline } : {}),
|
|
171
141
|
});
|
|
172
|
-
})
|
|
142
|
+
});
|
|
173
143
|
return items.length ? { streamingId, items } : null;
|
|
174
144
|
},
|
|
175
145
|
isBiddingBlocked(unpaidStreamIds, streamingId) {
|
package/dist/auctions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctions.js","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,qCAOkB;AAKlB,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,aAAa,CAAC;;;;;;;;CAQvC,CAAC;
|
|
1
|
+
{"version":3,"file":"auctions.js","sourceRoot":"","sources":["../src/auctions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,qCAOkB;AAKlB,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,aAAa,CAAC;;;;;;;;CAQvC,CAAC;AAYF,KAAK,UAAU,oBAAoB;;IACjC,MAAM,sBAAsB,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAC3D,IAAI,CAAC,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,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AAO,CAAC,eAAe,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;CACF,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Replaces the app's `APP_CONFIG.liveSelling` / `LIVE_CONFIG` globals with an explicit `configure`.
|
|
11
11
|
*/
|
|
12
|
-
import type { CustomerAccountRequest,
|
|
12
|
+
import type { CustomerAccountRequest, LiveSellingConfig, Logger, StorageAdapter } from './types';
|
|
13
13
|
import type { CommerceAdapter, IdentityAdapter } from './sessionTypes';
|
|
14
14
|
/** The service stores bare numeric Shopify ids; everything downstream speaks GIDs. */
|
|
15
15
|
export declare function toProductGid(id: string): string;
|
|
@@ -23,28 +23,6 @@ export declare class LiveSellingError extends Error {
|
|
|
23
23
|
readonly status: number;
|
|
24
24
|
constructor(status: number);
|
|
25
25
|
}
|
|
26
|
-
/** How long a request may take before it is given up on, unless `requestTimeoutMs` says otherwise. */
|
|
27
|
-
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 10000;
|
|
28
|
-
/**
|
|
29
|
-
* A request that took longer than `requestTimeoutMs` and was given up on.
|
|
30
|
-
*
|
|
31
|
-
* Its own class rather than a `LiveSellingError`, because there is no HTTP status to carry: the server
|
|
32
|
-
* never answered. A caller tells the two apart with `instanceof`; `url` says which call it was.
|
|
33
|
-
*
|
|
34
|
-
* Before 0.9.0 nothing had a timeout, so a request on a dead connection never settled — a join waiting
|
|
35
|
-
* on its room token, or a record read, hung for as long as the OS kept the socket open.
|
|
36
|
-
*/
|
|
37
|
-
export declare class LiveSellingTimeoutError extends Error {
|
|
38
|
-
readonly url: string;
|
|
39
|
-
readonly timeoutMs: number;
|
|
40
|
-
constructor(url: string, timeoutMs: number);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A store that keeps things only in memory, for as long as the app runs. Used until `configure` is
|
|
44
|
-
* called (which requires the app's own `storage`), and by the tests. Not on the package's root: an app
|
|
45
|
-
* passes real storage.
|
|
46
|
-
*/
|
|
47
|
-
export declare function memoryStorage(): StorageAdapter;
|
|
48
26
|
export declare function setConfig(config: LiveSellingConfig): void;
|
|
49
27
|
export declare function getConfig(): LiveSellingConfig;
|
|
50
28
|
export declare function isConfigured(): boolean;
|
|
@@ -70,38 +48,11 @@ export declare function getCommerce(): CommerceAdapter<unknown> | null;
|
|
|
70
48
|
* answers before `configure()` has run instead of throwing.
|
|
71
49
|
*/
|
|
72
50
|
export declare function strictActiveProduct(): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* The shows to keep from shoppers (`hiddenShows` on the config), or null when the app hides none.
|
|
75
|
-
* Read through here so it answers before `configure()` has run instead of throwing.
|
|
76
|
-
*/
|
|
77
|
-
export declare function hiddenShowsRule(): HiddenShows | null;
|
|
78
|
-
/** How long the session waits with nothing on air before it calls the show ended. */
|
|
79
|
-
export declare const DEFAULT_OFF_AIR_GRACE_MS = 4000;
|
|
80
|
-
/** `offAirGraceMs` from the config, or 4 seconds. Same fallback rules as `requestTimeoutMs`. */
|
|
81
|
-
export declare function offAirGraceMs(): number;
|
|
82
51
|
/** Null when nobody is identified beyond the per-install viewer id — bidding is then never offered. */
|
|
83
52
|
export declare function getIdentity(): IdentityAdapter | null;
|
|
84
|
-
/**
|
|
85
|
-
* The timeout every request gets: `requestTimeoutMs` from the config, or 10 seconds.
|
|
86
|
-
*
|
|
87
|
-
* Read through here so it answers before `configure()` has run (the CDN comment file needs no config)
|
|
88
|
-
* and so a nonsense value — zero, negative, not a number — falls back rather than making every request
|
|
89
|
-
* fail at once.
|
|
90
|
-
*/
|
|
91
|
-
export declare function requestTimeoutMs(): number;
|
|
92
|
-
/**
|
|
93
|
-
* Runs one HTTP exchange — the fetch AND reading its body — under a deadline.
|
|
94
|
-
*
|
|
95
|
-
* The deadline covers the body too, because a server can send headers and then stall. Two things
|
|
96
|
-
* enforce it: an `AbortController`, so the socket is actually released, and a timer that rejects on
|
|
97
|
-
* its own, because a `fetch` that ignores `signal` (an old polyfill, a test double) would otherwise
|
|
98
|
-
* still hang. Either way the caller sees a `LiveSellingTimeoutError`, never a bare `AbortError`.
|
|
99
|
-
*/
|
|
100
|
-
export declare function withRequestTimeout<T>(url: string, exchange: (signal: AbortSignal | undefined) => Promise<T>, timeoutMs?: number): Promise<T>;
|
|
101
53
|
/**
|
|
102
54
|
* The gateway request. The company header is the only credential; a body implies JSON. `X-Request-Source`
|
|
103
|
-
* marks the traffic as first-party app rather than a web widget.
|
|
104
|
-
* `withRequestTimeout`.
|
|
55
|
+
* marks the traffic as first-party app rather than a web widget.
|
|
105
56
|
*/
|
|
106
57
|
export declare function liveSellingRequest<T>(path: string, options?: {
|
|
107
58
|
params?: Record<string, string | number>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIvE,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAIpC;AA4BD,wBAAgB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAMzD;AAED,wBAAgB,SAAS,IAAI,iBAAiB,CAG7C;AAED,wBAAgB,YAAY,IAAI,OAA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|
3
|
-
exports.
|
|
3
|
+
exports.LiveSellingError = void 0;
|
|
4
4
|
exports.toProductGid = toProductGid;
|
|
5
|
-
exports.memoryStorage = memoryStorage;
|
|
6
5
|
exports.setConfig = setConfig;
|
|
7
6
|
exports.getConfig = getConfig;
|
|
8
7
|
exports.isConfigured = isConfigured;
|
|
@@ -13,11 +12,7 @@ exports.logWarning = logWarning;
|
|
|
13
12
|
exports.getCustomerAccountRequest = getCustomerAccountRequest;
|
|
14
13
|
exports.getCommerce = getCommerce;
|
|
15
14
|
exports.strictActiveProduct = strictActiveProduct;
|
|
16
|
-
exports.hiddenShowsRule = hiddenShowsRule;
|
|
17
|
-
exports.offAirGraceMs = offAirGraceMs;
|
|
18
15
|
exports.getIdentity = getIdentity;
|
|
19
|
-
exports.requestTimeoutMs = requestTimeoutMs;
|
|
20
|
-
exports.withRequestTimeout = withRequestTimeout;
|
|
21
16
|
exports.liveSellingRequest = liveSellingRequest;
|
|
22
17
|
exports.randomId = randomId;
|
|
23
18
|
exports.storageGet = storageGet;
|
|
@@ -41,33 +36,12 @@ class LiveSellingError extends Error {
|
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
exports.LiveSellingError = LiveSellingError;
|
|
44
|
-
/** How long a request may take before it is given up on, unless `requestTimeoutMs` says otherwise. */
|
|
45
|
-
exports.DEFAULT_REQUEST_TIMEOUT_MS = 10000;
|
|
46
|
-
/**
|
|
47
|
-
* A request that took longer than `requestTimeoutMs` and was given up on.
|
|
48
|
-
*
|
|
49
|
-
* Its own class rather than a `LiveSellingError`, because there is no HTTP status to carry: the server
|
|
50
|
-
* never answered. A caller tells the two apart with `instanceof`; `url` says which call it was.
|
|
51
|
-
*
|
|
52
|
-
* Before 0.9.0 nothing had a timeout, so a request on a dead connection never settled — a join waiting
|
|
53
|
-
* on its room token, or a record read, hung for as long as the OS kept the socket open.
|
|
54
|
-
*/
|
|
55
|
-
class LiveSellingTimeoutError extends Error {
|
|
56
|
-
constructor(url, timeoutMs) {
|
|
57
|
-
super(`Live-selling request timed out after ${timeoutMs}ms: ${url}`);
|
|
58
|
-
this.url = url;
|
|
59
|
-
this.timeoutMs = timeoutMs;
|
|
60
|
-
this.name = 'LiveSellingTimeoutError';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.LiveSellingTimeoutError = LiveSellingTimeoutError;
|
|
64
39
|
const SILENT = { error: () => undefined };
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
function memoryStorage() {
|
|
40
|
+
/** Prefers `window.localStorage`; falls back to a process-lifetime in-memory map. */
|
|
41
|
+
function defaultStorage() {
|
|
42
|
+
const ls = globalThis.localStorage;
|
|
43
|
+
if (ls && typeof ls.getItem === 'function')
|
|
44
|
+
return ls;
|
|
71
45
|
const mem = new Map();
|
|
72
46
|
return {
|
|
73
47
|
getItem: (key) => (mem.has(key) ? mem.get(key) : null),
|
|
@@ -79,20 +53,16 @@ function memoryStorage() {
|
|
|
79
53
|
},
|
|
80
54
|
};
|
|
81
55
|
}
|
|
82
|
-
const state = { config: null, storage:
|
|
56
|
+
const state = { config: null, storage: defaultStorage(), logger: SILENT };
|
|
83
57
|
function setConfig(config) {
|
|
84
|
-
var _a;
|
|
58
|
+
var _a, _b;
|
|
85
59
|
if (!config.apiUrl)
|
|
86
60
|
throw new Error('liveSelling.configure: apiUrl is required');
|
|
87
61
|
if (!config.companyId)
|
|
88
62
|
throw new Error('liveSelling.configure: companyId is required');
|
|
89
|
-
// Required since 0.9.0: without it a phone forgot poll votes (counted twice), the viewer's name and
|
|
90
|
-
// the accepted terms on every relaunch. AsyncStorage on a phone, window.localStorage on the web.
|
|
91
|
-
if (!config.storage)
|
|
92
|
-
throw new Error('liveSelling.configure: storage is required (AsyncStorage on a phone, localStorage on the web)');
|
|
93
63
|
state.config = config;
|
|
94
|
-
state.storage = config.storage;
|
|
95
|
-
state.logger = (
|
|
64
|
+
state.storage = (_a = config.storage) !== null && _a !== void 0 ? _a : defaultStorage();
|
|
65
|
+
state.logger = (_b = config.logger) !== null && _b !== void 0 ? _b : SILENT;
|
|
96
66
|
}
|
|
97
67
|
function getConfig() {
|
|
98
68
|
if (!state.config)
|
|
@@ -146,103 +116,33 @@ function strictActiveProduct() {
|
|
|
146
116
|
var _a;
|
|
147
117
|
return ((_a = state.config) === null || _a === void 0 ? void 0 : _a.strictActiveProduct) === true;
|
|
148
118
|
}
|
|
149
|
-
/**
|
|
150
|
-
* The shows to keep from shoppers (`hiddenShows` on the config), or null when the app hides none.
|
|
151
|
-
* Read through here so it answers before `configure()` has run instead of throwing.
|
|
152
|
-
*/
|
|
153
|
-
function hiddenShowsRule() {
|
|
154
|
-
var _a, _b;
|
|
155
|
-
return (_b = (_a = state.config) === null || _a === void 0 ? void 0 : _a.hiddenShows) !== null && _b !== void 0 ? _b : null;
|
|
156
|
-
}
|
|
157
|
-
/** How long the session waits with nothing on air before it calls the show ended. */
|
|
158
|
-
exports.DEFAULT_OFF_AIR_GRACE_MS = 4000;
|
|
159
|
-
/** `offAirGraceMs` from the config, or 4 seconds. Same fallback rules as `requestTimeoutMs`. */
|
|
160
|
-
function offAirGraceMs() {
|
|
161
|
-
var _a;
|
|
162
|
-
const configured = (_a = state.config) === null || _a === void 0 ? void 0 : _a.offAirGraceMs;
|
|
163
|
-
return typeof configured === 'number' && Number.isFinite(configured) && configured > 0
|
|
164
|
-
? configured
|
|
165
|
-
: exports.DEFAULT_OFF_AIR_GRACE_MS;
|
|
166
|
-
}
|
|
167
119
|
/** Null when nobody is identified beyond the per-install viewer id — bidding is then never offered. */
|
|
168
120
|
function getIdentity() {
|
|
169
121
|
var _a, _b;
|
|
170
122
|
return (_b = (_a = state.config) === null || _a === void 0 ? void 0 : _a.identity) !== null && _b !== void 0 ? _b : null;
|
|
171
123
|
}
|
|
172
|
-
/**
|
|
173
|
-
* The timeout every request gets: `requestTimeoutMs` from the config, or 10 seconds.
|
|
174
|
-
*
|
|
175
|
-
* Read through here so it answers before `configure()` has run (the CDN comment file needs no config)
|
|
176
|
-
* and so a nonsense value — zero, negative, not a number — falls back rather than making every request
|
|
177
|
-
* fail at once.
|
|
178
|
-
*/
|
|
179
|
-
function requestTimeoutMs() {
|
|
180
|
-
var _a;
|
|
181
|
-
const configured = (_a = state.config) === null || _a === void 0 ? void 0 : _a.requestTimeoutMs;
|
|
182
|
-
return typeof configured === 'number' && Number.isFinite(configured) && configured > 0
|
|
183
|
-
? configured
|
|
184
|
-
: exports.DEFAULT_REQUEST_TIMEOUT_MS;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Runs one HTTP exchange — the fetch AND reading its body — under a deadline.
|
|
188
|
-
*
|
|
189
|
-
* The deadline covers the body too, because a server can send headers and then stall. Two things
|
|
190
|
-
* enforce it: an `AbortController`, so the socket is actually released, and a timer that rejects on
|
|
191
|
-
* its own, because a `fetch` that ignores `signal` (an old polyfill, a test double) would otherwise
|
|
192
|
-
* still hang. Either way the caller sees a `LiveSellingTimeoutError`, never a bare `AbortError`.
|
|
193
|
-
*/
|
|
194
|
-
async function withRequestTimeout(url, exchange, timeoutMs = requestTimeoutMs()) {
|
|
195
|
-
const controller = typeof AbortController === 'function' ? new AbortController() : null;
|
|
196
|
-
let timer = null;
|
|
197
|
-
let timedOut = false;
|
|
198
|
-
const deadline = new Promise((_, reject) => {
|
|
199
|
-
timer = setTimeout(() => {
|
|
200
|
-
timedOut = true;
|
|
201
|
-
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
202
|
-
reject(new LiveSellingTimeoutError(url, timeoutMs));
|
|
203
|
-
}, timeoutMs);
|
|
204
|
-
});
|
|
205
|
-
try {
|
|
206
|
-
return await Promise.race([exchange(controller === null || controller === void 0 ? void 0 : controller.signal), deadline]);
|
|
207
|
-
}
|
|
208
|
-
catch (caught) {
|
|
209
|
-
// The abort above makes `fetch` reject with an `AbortError` of its own; that IS the timeout.
|
|
210
|
-
if (timedOut)
|
|
211
|
-
throw new LiveSellingTimeoutError(url, timeoutMs);
|
|
212
|
-
throw caught;
|
|
213
|
-
}
|
|
214
|
-
finally {
|
|
215
|
-
if (timer)
|
|
216
|
-
clearTimeout(timer);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
124
|
/**
|
|
220
125
|
* The gateway request. The company header is the only credential; a body implies JSON. `X-Request-Source`
|
|
221
|
-
* marks the traffic as first-party app rather than a web widget.
|
|
222
|
-
* `withRequestTimeout`.
|
|
126
|
+
* marks the traffic as first-party app rather than a web widget.
|
|
223
127
|
*/
|
|
224
128
|
async function liveSellingRequest(path, options) {
|
|
129
|
+
var _a, _b;
|
|
225
130
|
const config = getConfig();
|
|
226
131
|
const query = (options === null || options === void 0 ? void 0 : options.params)
|
|
227
132
|
? `?${new URLSearchParams(Object.entries(options.params).map(([k, v]) => [k, String(v)]))}`
|
|
228
133
|
: '';
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
...((options === null || options === void 0 ? void 0 : options.body) ? { 'Content-Type': 'application/json' } : {}),
|
|
238
|
-
},
|
|
239
|
-
body: (options === null || options === void 0 ? void 0 : options.body) ? JSON.stringify(options.body) : undefined,
|
|
240
|
-
signal,
|
|
241
|
-
});
|
|
242
|
-
if (!response.ok)
|
|
243
|
-
throw new LiveSellingError(response.status);
|
|
244
|
-
return (await response.json());
|
|
134
|
+
const response = await fetch(`${config.apiUrl}${path}${query}`, {
|
|
135
|
+
method: (_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET',
|
|
136
|
+
headers: {
|
|
137
|
+
'x-company-id': config.companyId,
|
|
138
|
+
'X-Request-Source': (_b = config.requestSource) !== null && _b !== void 0 ? _b : 'APPTILE',
|
|
139
|
+
...((options === null || options === void 0 ? void 0 : options.body) ? { 'Content-Type': 'application/json' } : {}),
|
|
140
|
+
},
|
|
141
|
+
body: (options === null || options === void 0 ? void 0 : options.body) ? JSON.stringify(options.body) : undefined,
|
|
245
142
|
});
|
|
143
|
+
if (!response.ok)
|
|
144
|
+
throw new LiveSellingError(response.status);
|
|
145
|
+
return (await response.json());
|
|
246
146
|
}
|
|
247
147
|
/**
|
|
248
148
|
* A stable random id. Uses the platform `crypto.randomUUID` when present (browsers, modern React
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAiBA,oCAEC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAiBA,oCAEC;AAyCD,8BAMC;AAED,8BAGC;AAED,oCAEC;AAED,oCAEC;AAED,gCAEC;AAED,8BAEC;AASD,gCAIC;AAED,8DAEC;AAGD,kCAEC;AASD,kDAEC;AAGD,kCAEC;AAMD,gDAuBC;AAOD,4BAMC;AAGD,gCAEC;AAED,gCAEC;AAlKD,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD,sFAAsF;AACtF,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mBAAmB,GAAG,EAAE,EAAE,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAqB,MAAc;QACjC,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;QAD3B,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AAED,MAAM,MAAM,GAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AAElD,qFAAqF;AACrF,SAAS,cAAc;IACrB,MAAM,EAAE,GAAI,UAAgD,CAAC,YAAY,CAAC;IAC1E,I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KAAK,UAAU;QACjD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE;QAChC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/G,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED,2FAA2F;AACpF,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,KAAa;IACzD,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/clips.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* The featured clip among a product's clips (`rows`, or the gateway's `{ data: rows }`): the first ranked 1
|
|
4
|
-
* (`pdp_rank` 1 or "1"; the gateway puts it first), active, with a playlist and an id; null when the merchant
|
|
5
|
-
* has featured none. Its window, products and poster as above; `recordingId` / `streamingId` open it on
|
|
6
|
-
* Replay with its chat (0.16.0). Pure, for tests.
|
|
7
|
-
*/
|
|
8
|
-
export declare function featuredClipOf(rows: unknown): ClipItem | null;
|
|
9
|
-
/** A Shopify product video is the clip worker's copy of `clip` (its alt names the clip), so not shown twice. */
|
|
10
|
-
export declare function isCopyOfClip(media: {
|
|
11
|
-
alt?: string | null;
|
|
12
|
-
} | null | undefined, clip: Pick<ClipItem, 'id'> | null | undefined): boolean;
|
|
1
|
+
import type { ClipsAPI } from './types';
|
|
13
2
|
export declare const clips: ClipsAPI;
|
|
14
3
|
//# sourceMappingURL=clips.d.ts.map
|
package/dist/clips.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clips.d.ts","sourceRoot":"","sources":["../src/clips.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"clips.d.ts","sourceRoot":"","sources":["../src/clips.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAwBlD,eAAO,MAAM,KAAK,EAAE,QAyBnB,CAAC"}
|
package/dist/clips.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clips = void 0;
|
|
4
|
-
exports.featuredClipOf = featuredClipOf;
|
|
5
|
-
exports.isCopyOfClip = isCopyOfClip;
|
|
6
4
|
/**
|
|
7
5
|
* Clips, from the gateway's video collections.
|
|
8
6
|
*
|
|
@@ -13,93 +11,18 @@ exports.isCopyOfClip = isCopyOfClip;
|
|
|
13
11
|
* applied, and each clip silently plays a whole show from the top.
|
|
14
12
|
*/
|
|
15
13
|
const client_1 = require("./client");
|
|
16
|
-
/** Recordings read, and of those how many asked for their clips, by `clips.recent()`. */
|
|
17
|
-
const RECENT_CLIPS_RECORDINGS = 10;
|
|
18
|
-
const RECENT_CLIPS_PROBES = 4;
|
|
19
|
-
function chunkToClip(chunk, index, recordingId) {
|
|
20
|
-
var _a, _b, _c;
|
|
21
|
-
const source = (chunk.streaming_url || chunk.url || '').trim();
|
|
22
|
-
if (!source)
|
|
23
|
-
return null;
|
|
24
|
-
return {
|
|
25
|
-
id: chunk._id || `${recordingId}-clip-${index}`,
|
|
26
|
-
title: ((_a = chunk.title) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
27
|
-
posterUrl: ((_b = chunk.thumbnail) === null || _b === void 0 ? void 0 : _b.trim()) || ((_c = chunk.thumbnail_image) === null || _c === void 0 ? void 0 : _c.trim()) || null,
|
|
28
|
-
productIds: clipProductIds(chunk),
|
|
29
|
-
recordingId: chunk.feed_id || recordingId,
|
|
30
|
-
...clipWindowOf(source, chunk),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
14
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* before the start is dropped. Read with a regex rather than `URL.searchParams`, which React Native does not
|
|
37
|
-
* implement for reading a parsed URL back.
|
|
15
|
+
* Splits the trim window off the playlist URL. Read with a regex rather than `URL.searchParams`, which
|
|
16
|
+
* React Native does not implement for reading a parsed URL back.
|
|
38
17
|
*/
|
|
39
|
-
function
|
|
18
|
+
function readTrimWindow(url) {
|
|
40
19
|
const [videoUrl, query = ''] = url.split('?');
|
|
41
|
-
const start = segment === null || segment === void 0 ? void 0 : segment.segment_start_time;
|
|
42
|
-
const end = segment === null || segment === void 0 ? void 0 : segment.segment_end_time;
|
|
43
|
-
if (typeof start === 'number' && typeof end === 'number' && end > start)
|
|
44
|
-
return { videoUrl, startMs: start, endMs: end };
|
|
45
20
|
const readMs = (key) => {
|
|
46
|
-
const found = query.match(new RegExp(`(?:^|&)${key}=(\\d+
|
|
21
|
+
const found = query.match(new RegExp(`(?:^|&)${key}=(\\d+)`));
|
|
47
22
|
return found ? Number(found[1]) : null;
|
|
48
23
|
};
|
|
49
|
-
|
|
50
|
-
const endMs = readMs('end');
|
|
51
|
-
return { videoUrl, startMs, endMs: endMs !== null && startMs !== null && endMs <= startMs ? null : endMs };
|
|
52
|
-
}
|
|
53
|
-
/** The products a clip sells: its lots (`product_info`, links left out), else `product_ids`; as Shopify gids. */
|
|
54
|
-
function clipProductIds(row) {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
const lots = ((_a = row.product_info) !== null && _a !== void 0 ? _a : [])
|
|
57
|
-
.filter((info) => !!(info === null || info === void 0 ? void 0 : info.store_product_id) && info.product_type !== 'url')
|
|
58
|
-
.map((info) => info.store_product_id);
|
|
59
|
-
return (lots.length ? lots : (_b = row.product_ids) !== null && _b !== void 0 ? _b : []).map(client_1.toProductGid);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* The featured clip among a product's clips (`rows`, or the gateway's `{ data: rows }`): the first ranked 1
|
|
63
|
-
* (`pdp_rank` 1 or "1"; the gateway puts it first), active, with a playlist and an id; null when the merchant
|
|
64
|
-
* has featured none. Its window, products and poster as above; `recordingId` / `streamingId` open it on
|
|
65
|
-
* Replay with its chat (0.16.0). Pure, for tests.
|
|
66
|
-
*/
|
|
67
|
-
function featuredClipOf(rows) {
|
|
68
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
69
|
-
const list = Array.isArray(rows) ? rows : rows === null || rows === void 0 ? void 0 : rows.data;
|
|
70
|
-
if (!Array.isArray(list))
|
|
71
|
-
return null;
|
|
72
|
-
for (const row of list) {
|
|
73
|
-
// eslint-disable-next-line eqeqeq -- the gateway sends the rank as a number or a string.
|
|
74
|
-
if (!row || row.pdp_rank == null || row.pdp_rank != 1 || row.is_active === false)
|
|
75
|
-
continue;
|
|
76
|
-
const url = ((_a = row.streaming_url) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = row.url) === null || _b === void 0 ? void 0 : _b.trim());
|
|
77
|
-
const id = ((_c = row._id) === null || _c === void 0 ? void 0 : _c.trim()) || ((_d = row.feed_id) === null || _d === void 0 ? void 0 : _d.trim());
|
|
78
|
-
if (!url || !id)
|
|
79
|
-
continue;
|
|
80
|
-
return {
|
|
81
|
-
id,
|
|
82
|
-
title: ((_e = row.title) === null || _e === void 0 ? void 0 : _e.trim()) || '',
|
|
83
|
-
posterUrl: ((_f = row.thumbnail) === null || _f === void 0 ? void 0 : _f.trim()) || ((_g = row.thumbnail_image) === null || _g === void 0 ? void 0 : _g.trim()) || null,
|
|
84
|
-
productIds: clipProductIds(row),
|
|
85
|
-
recordingId: ((_h = row.feed_id) === null || _h === void 0 ? void 0 : _h.trim()) || null,
|
|
86
|
-
streamingId: ((_j = row.streaming_id) === null || _j === void 0 ? void 0 : _j.trim()) || null,
|
|
87
|
-
...clipWindowOf(url, row),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
/** The alt the clip worker gives Shopify's copy of a clip it uploads to the product. */
|
|
93
|
-
const COPY_ALT = /^Apptile product clip (\S+)$/;
|
|
94
|
-
/** A Shopify product video is the clip worker's copy of `clip` (its alt names the clip), so not shown twice. */
|
|
95
|
-
function isCopyOfClip(media, clip) {
|
|
96
|
-
var _a, _b, _c;
|
|
97
|
-
if (!media || !clip)
|
|
98
|
-
return false;
|
|
99
|
-
return ((_c = COPY_ALT.exec((_b = (_a = media.alt) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c[1]) === clip.id;
|
|
24
|
+
return { videoUrl, startMs: readMs('start'), endMs: readMs('end') };
|
|
100
25
|
}
|
|
101
|
-
/** A product gid's number: the gateway names a product by it. */
|
|
102
|
-
const productNumberOf = (productId) => { var _a; return (_a = productId.trim().split('/').pop()) !== null && _a !== void 0 ? _a : ''; };
|
|
103
26
|
exports.clips = {
|
|
104
27
|
async list() {
|
|
105
28
|
var _a, _b;
|
|
@@ -122,40 +45,9 @@ exports.clips = {
|
|
|
122
45
|
title: ((_a = item.title) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
123
46
|
posterUrl: ((_b = item.thumbnail) === null || _b === void 0 ? void 0 : _b.trim()) || null,
|
|
124
47
|
productIds: ((_c = item.product_ids) !== null && _c !== void 0 ? _c : []).map(client_1.toProductGid),
|
|
125
|
-
...
|
|
48
|
+
...readTrimWindow(item.url),
|
|
126
49
|
});
|
|
127
50
|
});
|
|
128
51
|
},
|
|
129
|
-
async recent({ recordings = RECENT_CLIPS_RECORDINGS, probes = RECENT_CLIPS_PROBES } = {}) {
|
|
130
|
-
var _a, _b, _c, _d;
|
|
131
|
-
const body = await (0, client_1.liveSellingRequest)(
|
|
132
|
-
// The service resolves the company from the header and never reads this path segment.
|
|
133
|
-
'/widget/plugin/shoppable-feeds/app', { params: { limit: recordings } });
|
|
134
|
-
const recordingIds = ((_b = (_a = body.data) === null || _a === void 0 ? void 0 : _a.feeds) !== null && _b !== void 0 ? _b : []).map((feed) => feed === null || feed === void 0 ? void 0 : feed.feed_id).filter((id) => !!id);
|
|
135
|
-
for (const recordingId of recordingIds.slice(0, probes)) {
|
|
136
|
-
let rows = [];
|
|
137
|
-
try {
|
|
138
|
-
const page = await (0, client_1.liveSellingRequest)('/live-streaming/plugin/shoppable-feeds/chunks', { params: { shoppable_feed_id: recordingId, page: 1 } });
|
|
139
|
-
rows = (_d = (_c = page.data) === null || _c === void 0 ? void 0 : _c.streaming_shoppable_feeds) !== null && _d !== void 0 ? _d : [];
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// A recording that can't be cut into clips isn't the reel failing: the next one is asked.
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
const found = rows.map((row, index) => chunkToClip(row, index, recordingId)).filter((clip) => !!clip);
|
|
146
|
-
if (found.length)
|
|
147
|
-
return found;
|
|
148
|
-
}
|
|
149
|
-
return [];
|
|
150
|
-
},
|
|
151
|
-
async featuredForProduct(productId) {
|
|
152
|
-
const productNumber = productNumberOf(productId);
|
|
153
|
-
if (!productNumber)
|
|
154
|
-
return null;
|
|
155
|
-
const body = await (0, client_1.liveSellingRequest)('/shoppable-feeds/product/v2', {
|
|
156
|
-
params: { store_product_id: productNumber, company_id: (0, client_1.getConfig)().companyId },
|
|
157
|
-
});
|
|
158
|
-
return featuredClipOf(body);
|
|
159
|
-
},
|
|
160
52
|
};
|
|
161
53
|
//# sourceMappingURL=clips.js.map
|