@tiledev/sdk-apptile-live-selling 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +443 -34
- package/dist/auctionComments.d.ts +25 -0
- package/dist/auctionComments.d.ts.map +1 -0
- package/dist/auctionComments.js +28 -0
- package/dist/auctionComments.js.map +1 -0
- package/dist/auctionRules.d.ts +76 -0
- package/dist/auctionRules.d.ts.map +1 -0
- package/dist/auctionRules.js +106 -0
- package/dist/auctionRules.js.map +1 -0
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +19 -10
- package/dist/auctions.js.map +1 -1
- package/dist/client.d.ts +51 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +123 -23
- package/dist/client.js.map +1 -1
- package/dist/commentHistory.d.ts +66 -0
- package/dist/commentHistory.d.ts.map +1 -0
- package/dist/commentHistory.js +125 -0
- package/dist/commentHistory.js.map +1 -0
- package/dist/engine.native.d.ts.map +1 -1
- package/dist/engine.native.js +17 -845
- package/dist/engine.native.js.map +1 -1
- package/dist/giveawayPrize.d.ts +13 -0
- package/dist/giveawayPrize.d.ts.map +1 -0
- package/dist/giveawayPrize.js +18 -0
- package/dist/giveawayPrize.js.map +1 -0
- package/dist/giveawayPrizeLines.d.ts +67 -0
- package/dist/giveawayPrizeLines.d.ts.map +1 -0
- package/dist/giveawayPrizeLines.js +48 -0
- package/dist/giveawayPrizeLines.js.map +1 -0
- package/dist/giveawayRoster.d.ts +53 -0
- package/dist/giveawayRoster.d.ts.map +1 -0
- package/dist/giveawayRoster.js +93 -0
- package/dist/giveawayRoster.js.map +1 -0
- package/dist/heldComments.d.ts +29 -0
- package/dist/heldComments.d.ts.map +1 -0
- package/dist/heldComments.js +61 -0
- package/dist/heldComments.js.map +1 -0
- package/dist/hiddenShows.d.ts +34 -0
- package/dist/hiddenShows.d.ts.map +1 -0
- package/dist/hiddenShows.js +42 -0
- package/dist/hiddenShows.js.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -3
- package/dist/index.js.map +1 -1
- package/dist/liveShow.d.ts +58 -0
- package/dist/liveShow.d.ts.map +1 -0
- package/dist/liveShow.js +55 -0
- package/dist/liveShow.js.map +1 -0
- package/dist/pipWindow.d.ts +85 -0
- package/dist/pipWindow.d.ts.map +1 -0
- package/dist/pipWindow.js +88 -0
- package/dist/pipWindow.js.map +1 -0
- package/dist/polls.d.ts.map +1 -1
- package/dist/polls.js +3 -0
- package/dist/polls.js.map +1 -1
- package/dist/react/LiveSellingProvider.d.ts +10 -1
- package/dist/react/LiveSellingProvider.d.ts.map +1 -1
- package/dist/react/LiveSellingProvider.js +6 -2
- package/dist/react/LiveSellingProvider.js.map +1 -1
- package/dist/react/LiveVideoTarget.d.ts.map +1 -1
- package/dist/react/LiveVideoTarget.js +41 -3
- package/dist/react/LiveVideoTarget.js.map +1 -1
- package/dist/react/clocks.d.ts +29 -0
- package/dist/react/clocks.d.ts.map +1 -0
- package/dist/react/clocks.js +124 -0
- package/dist/react/clocks.js.map +1 -0
- package/dist/react/index.d.ts +7 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +15 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.web.d.ts +9 -2
- package/dist/react/index.web.d.ts.map +1 -1
- package/dist/react/index.web.js +27 -4
- package/dist/react/index.web.js.map +1 -1
- package/dist/react/startSignIn.d.ts +3 -0
- package/dist/react/startSignIn.d.ts.map +1 -0
- package/dist/react/startSignIn.js +19 -0
- package/dist/react/startSignIn.js.map +1 -0
- package/dist/react/useAuctionBidGate.d.ts +54 -4
- package/dist/react/useAuctionBidGate.d.ts.map +1 -1
- package/dist/react/useAuctionBidGate.js +169 -25
- package/dist/react/useAuctionBidGate.js.map +1 -1
- package/dist/react/useAuctionWins.d.ts +9 -1
- package/dist/react/useAuctionWins.d.ts.map +1 -1
- package/dist/react/useAuctionWins.js +9 -3
- package/dist/react/useAuctionWins.js.map +1 -1
- package/dist/react/useGiveawayEntry.d.ts +59 -0
- package/dist/react/useGiveawayEntry.d.ts.map +1 -0
- package/dist/react/useGiveawayEntry.js +170 -0
- package/dist/react/useGiveawayEntry.js.map +1 -0
- package/dist/react/useGiveawayPrize.d.ts +12 -0
- package/dist/react/useGiveawayPrize.d.ts.map +1 -0
- package/dist/react/useGiveawayPrize.js +53 -0
- package/dist/react/useGiveawayPrize.js.map +1 -0
- package/dist/react/useHiddenShows.d.ts +10 -0
- package/dist/react/useHiddenShows.d.ts.map +1 -0
- package/dist/react/useHiddenShows.js +30 -0
- package/dist/react/useHiddenShows.js.map +1 -0
- package/dist/react/useLiveSession.d.ts +7 -3
- package/dist/react/useLiveSession.d.ts.map +1 -1
- package/dist/react/useLiveSession.js +522 -157
- package/dist/react/useLiveSession.js.map +1 -1
- package/dist/react/useLiveShow.d.ts +3 -0
- package/dist/react/useLiveShow.d.ts.map +1 -0
- package/dist/react/useLiveShow.js +21 -0
- package/dist/react/useLiveShow.js.map +1 -0
- package/dist/react/useLiveStreams.d.ts.map +1 -1
- package/dist/react/useLiveStreams.js +6 -2
- package/dist/react/useLiveStreams.js.map +1 -1
- package/dist/react/useOngoingLive.d.ts +1 -0
- package/dist/react/useOngoingLive.d.ts.map +1 -1
- package/dist/react/useOngoingLive.js +7 -1
- package/dist/react/useOngoingLive.js.map +1 -1
- package/dist/react/useReplays.d.ts +12 -0
- package/dist/react/useReplays.d.ts.map +1 -1
- package/dist/react/useReplays.js +56 -24
- package/dist/react/useReplays.js.map +1 -1
- package/dist/react/useStreamInfo.d.ts +13 -2
- package/dist/react/useStreamInfo.d.ts.map +1 -1
- package/dist/react/useStreamInfo.js +31 -5
- package/dist/react/useStreamInfo.js.map +1 -1
- package/dist/replayPages.d.ts +31 -0
- package/dist/replayPages.d.ts.map +1 -0
- package/dist/replayPages.js +34 -0
- package/dist/replayPages.js.map +1 -0
- package/dist/replays.d.ts +7 -0
- package/dist/replays.d.ts.map +1 -1
- package/dist/replays.js +52 -22
- package/dist/replays.js.map +1 -1
- package/dist/session.d.ts +39 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +209 -22
- package/dist/session.js.map +1 -1
- package/dist/sessionTypes.d.ts +190 -14
- package/dist/sessionTypes.d.ts.map +1 -1
- package/dist/sessionTypes.js +2 -1
- package/dist/sessionTypes.js.map +1 -1
- package/dist/shopifyCommerce.d.ts +149 -0
- package/dist/shopifyCommerce.d.ts.map +1 -0
- package/dist/shopifyCommerce.js +123 -0
- package/dist/shopifyCommerce.js.map +1 -0
- package/dist/shopifyIdentity.d.ts +51 -0
- package/dist/shopifyIdentity.d.ts.map +1 -0
- package/dist/shopifyIdentity.js +52 -0
- package/dist/shopifyIdentity.js.map +1 -0
- package/dist/shopifyIds.d.ts +9 -0
- package/dist/shopifyIds.d.ts.map +1 -0
- package/dist/shopifyIds.js +18 -0
- package/dist/shopifyIds.js.map +1 -0
- package/dist/showLinks.d.ts +24 -0
- package/dist/showLinks.d.ts.map +1 -0
- package/dist/showLinks.js +23 -0
- package/dist/showLinks.js.map +1 -0
- package/dist/showLots.d.ts +28 -0
- package/dist/showLots.d.ts.map +1 -0
- package/dist/showLots.js +51 -0
- package/dist/showLots.js.map +1 -0
- package/dist/showNames.d.ts +45 -0
- package/dist/showNames.d.ts.map +1 -0
- package/dist/showNames.js +74 -0
- package/dist/showNames.js.map +1 -0
- package/dist/streams.d.ts +27 -1
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +90 -21
- package/dist/streams.js.map +1 -1
- package/dist/types.d.ts +195 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/wire.d.ts +31 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +25 -0
- package/dist/wire.js.map +1 -1
- package/dist/zego.d.ts +3 -1
- package/dist/zego.d.ts.map +1 -1
- package/dist/zego.js +1 -1
- package/dist/zegoEngine.d.ts +168 -0
- package/dist/zegoEngine.d.ts.map +1 -0
- package/dist/zegoEngine.js +1052 -0
- package/dist/zegoEngine.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionComments.d.ts","sourceRoot":"","sources":["../src/auctionComments.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,yDAAyD;AACzD,MAAM,MAAM,WAAW;AACrB,2DAA2D;AACzD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;AACpB,qFAAqF;GACnF;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAKtB,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAK5E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The room's auction lines in the chat (0.9.0, "SDK move 8"): a bid and a winner arrive as plain text
|
|
4
|
+
* from the gateway, with no field or source to tell them apart, so they are known by their shape
|
|
5
|
+
* (Freckled Poppy's DEL-3012; amore-v2's chat used the same two patterns). Ordinary chat never takes
|
|
6
|
+
* these forms. Matching, not words a shopper reads.
|
|
7
|
+
*
|
|
8
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.classifyComment = classifyComment;
|
|
12
|
+
/** "Bid $64.00": the word and its space, then an amount that holds a digit (so "Bid now!" isn't one). */
|
|
13
|
+
const BID_LINE = /^(Bid\s+)(.*\d.*)$/;
|
|
14
|
+
/** "Congratulations!! Jane is the winner of …". */
|
|
15
|
+
const WINNER_LINE = /\bis the winner of\b/i;
|
|
16
|
+
const PLAIN = { kind: 'plain' };
|
|
17
|
+
const WINNER = { kind: 'winner' };
|
|
18
|
+
/** What kind of line `text` is: a winner's line (checked first), a bid, or plain chat. */
|
|
19
|
+
function classifyComment(text) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if (typeof text !== 'string' || !text)
|
|
22
|
+
return PLAIN;
|
|
23
|
+
if (WINNER_LINE.test(text))
|
|
24
|
+
return WINNER;
|
|
25
|
+
const bid = BID_LINE.exec(text);
|
|
26
|
+
return bid ? { kind: 'bid', label: (_a = bid[1]) !== null && _a !== void 0 ? _a : '', amount: (_b = bid[2]) !== null && _b !== void 0 ? _b : '' } : PLAIN;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=auctionComments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionComments.js","sourceRoot":"","sources":["../src/auctionComments.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAmBH,0CAKC;AAtBD,yGAAyG;AACzG,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AACtC,mDAAmD;AACnD,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAU5C,MAAM,KAAK,GAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC7C,MAAM,MAAM,GAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAE/C,0FAA0F;AAC1F,SAAgB,eAAe,CAAC,IAA+B;;IAC7D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC1C,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAA,GAAG,CAAC,CAAC,CAAC,mCAAI,EAAE,EAAE,MAAM,EAAE,MAAA,GAAG,CAAC,CAAC,CAAC,mCAAI,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules around a bid that every auction screen needs (0.9.0, "SDK move 8"): the last look before a
|
|
3
|
+
* bid goes, the custom bid's quick picks and its chance of winning, each lot's state, and whether the
|
|
4
|
+
* shopper won the round that just closed. amore-v2 and Freckled Poppy each kept their own copies.
|
|
5
|
+
*
|
|
6
|
+
* Pure, so it loads in plain Node for tests and in an app's own test runner.
|
|
7
|
+
*/
|
|
8
|
+
import type { AuctionState, LeaderWhenRoundClosed, LotState } from './sessionTypes';
|
|
9
|
+
import type { AuctionWin, LiveStream } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* How long, after a bid is handed to `placeBid`, a bid bar takes no other (old Amore's
|
|
12
|
+
* `BID_SPINNER_MS`, Freckled Poppy's too). The host answers on the room, not to the bid, so this is the
|
|
13
|
+
* moment a second tap would most likely be a mistake. `useAuctionBidGate`'s `bidOnItsWay`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BID_ON_ITS_WAY_MS = 1200;
|
|
16
|
+
/** The round as a bid is checked against it: `session.auction` has all of it. */
|
|
17
|
+
export type BidRound = Pick<AuctionState, 'biddingOpen' | 'nextBid' | 'bidCap' | 'closesAt' | 'storeProductId'>;
|
|
18
|
+
/** Why a bid isn't sent, found as it is about to go. */
|
|
19
|
+
export type BidRefusalReason = 'closed' | 'outbid' | 'overCap';
|
|
20
|
+
/**
|
|
21
|
+
* Why a bid of `amount` can't go out into `round` now, or null when it can: the last look before a bid
|
|
22
|
+
* goes (amore-v2's, "a bid goes out at the amount shown"). In order:
|
|
23
|
+
*
|
|
24
|
+
* - `closed`: no round open, or its clock has run out (`closesAt` at or before `now`, on the phone's
|
|
25
|
+
* clock). Nothing to tell the shopper: the bar has gone.
|
|
26
|
+
* - `overCap`: more than the host's ceiling. A bid of exactly the ceiling stands (old Amore's).
|
|
27
|
+
* - `outbid`: less than the next bid: the room moved past the amount the shopper saw.
|
|
28
|
+
*/
|
|
29
|
+
export declare function bidRefusal(amount: number, round: Pick<AuctionState, 'biddingOpen' | 'nextBid' | 'bidCap' | 'closesAt'>, now: number): BidRefusalReason | null;
|
|
30
|
+
/** Old Amore's quick picks on the custom bid sheet: the next bid, rounded up, plus each of these. */
|
|
31
|
+
export declare const QUICK_BID_STEPS: readonly number[];
|
|
32
|
+
/**
|
|
33
|
+
* The custom bid sheet's quick picks: the next bid rounded up to a whole amount, plus each step
|
|
34
|
+
* (`QUICK_BID_STEPS`: 5, 20, 60, 100), leaving out any over the host's ceiling. Old Amore's; Freckled
|
|
35
|
+
* Poppy's added the same steps without rounding the last three up, and offered picks over the ceiling.
|
|
36
|
+
*/
|
|
37
|
+
export declare function quickBids(nextBid: number, bidCap: number | null, steps?: readonly number[]): number[];
|
|
38
|
+
/** How good a chance a custom bid stands. */
|
|
39
|
+
export type WinChance = 'veryHigh' | 'good' | 'medium' | 'tooLow';
|
|
40
|
+
/** At least this much over the next bid is a very high chance of winning (old Amore's and Freckled Poppy's). */
|
|
41
|
+
export declare const VERY_HIGH_CHANCE_OVER = 50;
|
|
42
|
+
/** At least this much over the next bid is a good chance (old Amore's and Freckled Poppy's). */
|
|
43
|
+
export declare const GOOD_CHANCE_OVER = 20;
|
|
44
|
+
/**
|
|
45
|
+
* How good a chance `amount` stands against the next bid, as old Amore's custom bid sheet (and Freckled
|
|
46
|
+
* Poppy's, with the same numbers) says it: 50 or more over, or double the next bid, is `veryHigh`; 20
|
|
47
|
+
* or more over, or half as much again, `good`; anything over, `medium`; else `tooLow`, an amount that
|
|
48
|
+
* isn't a number included. Being over the ceiling, or outbid, is the sheet's to say first.
|
|
49
|
+
*/
|
|
50
|
+
export declare function winChance(amount: number, nextBid: number): WinChance;
|
|
51
|
+
/**
|
|
52
|
+
* Where a lot stands in the show's auction: `open` while a round is open on it, `closed` once it has
|
|
53
|
+
* been won (on the show's record, `winnerCount`, or seen won on this phone this show, `wonLotIds`: the
|
|
54
|
+
* record says so only once it is read again), else `upcoming`. A lot reads `open` only with a round
|
|
55
|
+
* open: between rounds the featured lot is still `upcoming` (old Amore's said "Bidding Live" for it).
|
|
56
|
+
*/
|
|
57
|
+
export declare function lotStateFor(storeProductId: string, auction: Pick<AuctionState, 'biddingOpen' | 'storeProductId' | 'wonLotIds'>, show: Pick<LiveStream, 'products'> | null | undefined): LotState;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the round's winner is this shopper: they led the round as it closed (`bidderId`, the id the
|
|
60
|
+
* host echoes) and the winning bid is theirs, the same amount, on the same lot when both name one. The
|
|
61
|
+
* room names the winner only by name (the README's backend ask), so this is the best a phone can tell.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isYourWin(win: AuctionWin | null | undefined, leader: LeaderWhenRoundClosed | null | undefined, bidderId: string | null | undefined): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The first bid on a lot, before the host has sent a next bid: its opening bid when it has one, else the
|
|
66
|
+
* lot's bid step, else the show's smallest step. Never 0 when any of them is set (Head of Engineering,
|
|
67
|
+
* 2026-10-06: "How will anyone bid if starting is 0 ... we should show bid incremented": a lot the host
|
|
68
|
+
* didn't price opened at "Bid $0.00", and sliding it sent nothing).
|
|
69
|
+
*/
|
|
70
|
+
export declare function openingBidFor(lot: {
|
|
71
|
+
baseBidPrice?: number | null;
|
|
72
|
+
bidIncrement?: number | null;
|
|
73
|
+
} | null | undefined, show: {
|
|
74
|
+
minimumBidIncrement?: number | null;
|
|
75
|
+
} | null | undefined): number;
|
|
76
|
+
//# sourceMappingURL=auctionRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionRules.d.ts","sourceRoot":"","sources":["../src/auctionRules.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpF,O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AAI,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,GACpD,QAAQ,CAKV;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EAClC,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,EAChD,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EACtF,IAAI,EAAE;IAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAC/D,MAAM,CAKR"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GOOD_CHANCE_OVER = exports.VERY_HIGH_CHANCE_OVER = exports.QUICK_BID_STEPS = exports.BID_ON_ITS_WAY_MS = void 0;
|
|
4
|
+
exports.bidRefusal = bidRefusal;
|
|
5
|
+
exports.quickBids = quickBids;
|
|
6
|
+
exports.winChance = winChance;
|
|
7
|
+
exports.lotStateFor = lotStateFor;
|
|
8
|
+
exports.isYourWin = isYourWin;
|
|
9
|
+
exports.openingBidFor = openingBidFor;
|
|
10
|
+
/**
|
|
11
|
+
* How long, after a bid is handed to `placeBid`, a bid bar takes no other (old Amore's
|
|
12
|
+
* `BID_SPINNER_MS`, Freckled Poppy's too). The host answers on the room, not to the bid, so this is the
|
|
13
|
+
* moment a second tap would most likely be a mistake. `useAuctionBidGate`'s `bidOnItsWay`.
|
|
14
|
+
*/
|
|
15
|
+
exports.BID_ON_ITS_WAY_MS = 1200;
|
|
16
|
+
/**
|
|
17
|
+
* Why a bid of `amount` can't go out into `round` now, or null when it can: the last look before a bid
|
|
18
|
+
* goes (amore-v2's, "a bid goes out at the amount shown"). In order:
|
|
19
|
+
*
|
|
20
|
+
* - `closed`: no round open, or its clock has run out (`closesAt` at or before `now`, on the phone's
|
|
21
|
+
* clock). Nothing to tell the shopper: the bar has gone.
|
|
22
|
+
* - `overCap`: more than the host's ceiling. A bid of exactly the ceiling stands (old Amore's).
|
|
23
|
+
* - `outbid`: less than the next bid: the room moved past the amount the shopper saw.
|
|
24
|
+
*/
|
|
25
|
+
function bidRefusal(amount, round, now) {
|
|
26
|
+
if (!round.biddingOpen || (round.closesAt !== null && round.closesAt <= now))
|
|
27
|
+
return 'closed';
|
|
28
|
+
if (round.bidCap !== null && amount > round.bidCap)
|
|
29
|
+
return 'overCap';
|
|
30
|
+
if (amount < round.nextBid)
|
|
31
|
+
return 'outbid';
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/** Old Amore's quick picks on the custom bid sheet: the next bid, rounded up, plus each of these. */
|
|
35
|
+
exports.QUICK_BID_STEPS = [5, 20, 60, 100];
|
|
36
|
+
/**
|
|
37
|
+
* The custom bid sheet's quick picks: the next bid rounded up to a whole amount, plus each step
|
|
38
|
+
* (`QUICK_BID_STEPS`: 5, 20, 60, 100), leaving out any over the host's ceiling. Old Amore's; Freckled
|
|
39
|
+
* Poppy's added the same steps without rounding the last three up, and offered picks over the ceiling.
|
|
40
|
+
*/
|
|
41
|
+
function quickBids(nextBid, bidCap, steps = exports.QUICK_BID_STEPS) {
|
|
42
|
+
const floor = Math.ceil(nextBid);
|
|
43
|
+
return steps.map((step) => floor + step).filter((amount) => bidCap === null || amount <= bidCap);
|
|
44
|
+
}
|
|
45
|
+
/** At least this much over the next bid is a very high chance of winning (old Amore's and Freckled Poppy's). */
|
|
46
|
+
exports.VERY_HIGH_CHANCE_OVER = 50;
|
|
47
|
+
/** At least this much over the next bid is a good chance (old Amore's and Freckled Poppy's). */
|
|
48
|
+
exports.GOOD_CHANCE_OVER = 20;
|
|
49
|
+
/**
|
|
50
|
+
* How good a chance `amount` stands against the next bid, as old Amore's custom bid sheet (and Freckled
|
|
51
|
+
* Poppy's, with the same numbers) says it: 50 or more over, or double the next bid, is `veryHigh`; 20
|
|
52
|
+
* or more over, or half as much again, `good`; anything over, `medium`; else `tooLow`, an amount that
|
|
53
|
+
* isn't a number included. Being over the ceiling, or outbid, is the sheet's to say first.
|
|
54
|
+
*/
|
|
55
|
+
function winChance(amount, nextBid) {
|
|
56
|
+
const over = amount - nextBid;
|
|
57
|
+
const ratio = nextBid > 0 ? amount / nextBid - 1 : 0;
|
|
58
|
+
if (over >= exports.VERY_HIGH_CHANCE_OVER || ratio >= 1)
|
|
59
|
+
return 'veryHigh';
|
|
60
|
+
if (over >= exports.GOOD_CHANCE_OVER || ratio >= 0.5)
|
|
61
|
+
return 'good';
|
|
62
|
+
if (over > 0)
|
|
63
|
+
return 'medium';
|
|
64
|
+
return 'tooLow';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Where a lot stands in the show's auction: `open` while a round is open on it, `closed` once it has
|
|
68
|
+
* been won (on the show's record, `winnerCount`, or seen won on this phone this show, `wonLotIds`: the
|
|
69
|
+
* record says so only once it is read again), else `upcoming`. A lot reads `open` only with a round
|
|
70
|
+
* open: between rounds the featured lot is still `upcoming` (old Amore's said "Bidding Live" for it).
|
|
71
|
+
*/
|
|
72
|
+
function lotStateFor(storeProductId, auction, show) {
|
|
73
|
+
var _a;
|
|
74
|
+
if (auction.biddingOpen && auction.storeProductId === storeProductId)
|
|
75
|
+
return 'open';
|
|
76
|
+
const onRecord = show === null || show === void 0 ? void 0 : show.products.find((product) => product.storeProductId === storeProductId);
|
|
77
|
+
if (((_a = onRecord === null || onRecord === void 0 ? void 0 : onRecord.winnerCount) !== null && _a !== void 0 ? _a : 0) > 0 || auction.wonLotIds.includes(storeProductId))
|
|
78
|
+
return 'closed';
|
|
79
|
+
return 'upcoming';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether the round's winner is this shopper: they led the round as it closed (`bidderId`, the id the
|
|
83
|
+
* host echoes) and the winning bid is theirs, the same amount, on the same lot when both name one. The
|
|
84
|
+
* room names the winner only by name (the README's backend ask), so this is the best a phone can tell.
|
|
85
|
+
*/
|
|
86
|
+
function isYourWin(win, leader, bidderId) {
|
|
87
|
+
if (!win || !leader || !bidderId || leader.userId !== bidderId)
|
|
88
|
+
return false;
|
|
89
|
+
if (leader.amount !== win.winningBid)
|
|
90
|
+
return false;
|
|
91
|
+
return win.storeProductId === null || leader.storeProductId === null || win.storeProductId === leader.storeProductId;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The first bid on a lot, before the host has sent a next bid: its opening bid when it has one, else the
|
|
95
|
+
* lot's bid step, else the show's smallest step. Never 0 when any of them is set (Head of Engineering,
|
|
96
|
+
* 2026-10-06: "How will anyone bid if starting is 0 ... we should show bid incremented": a lot the host
|
|
97
|
+
* didn't price opened at "Bid $0.00", and sliding it sent nothing).
|
|
98
|
+
*/
|
|
99
|
+
function openingBidFor(lot, show) {
|
|
100
|
+
for (const amount of [lot === null || lot === void 0 ? void 0 : lot.baseBidPrice, lot === null || lot === void 0 ? void 0 : lot.bidIncrement, show === null || show === void 0 ? void 0 : show.minimumBidIncrement]) {
|
|
101
|
+
if (typeof amount === 'number' && Number.isFinite(amount) && amount > 0)
|
|
102
|
+
return amount;
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=auctionRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionRules.js","sourceRoot":"","sources":["../src/auctionRules.ts"],"names":[],"mappings":";;;AAgCA,gCASC;AAUD,8BAOC;AAgBD,8BAOC;AAQD,kCASC;AAOD,8BAQC;AAQD,sCAQC;AAvHD;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,IAA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G;AACH,SAAgB,aAAa,CAC3B,GAAsF,EACtF,IAAgE;IAEhE,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,mBAAmB,CAAC,EAAE,CAAC;QACvF,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC;IACzF,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
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;AAuExE,eAAO,MAAM,QAAQ,EAAE,
|
|
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,WA+FtB,CAAC"}
|
package/dist/auctions.js
CHANGED
|
@@ -118,19 +118,27 @@ exports.auctions = {
|
|
|
118
118
|
if (!parsed)
|
|
119
119
|
return null;
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* Every stream with something payable, not just the first.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
123
|
+
* This used to read one stream, on the reasoning that the bid gate stops a customer accruing wins
|
|
124
|
+
* on a second stream while the first is unpaid. That holds for bids and not for giveaways:
|
|
125
|
+
* `enterGiveaway` has no such gate, so a shopper with an unpaid win from one show can win a
|
|
126
|
+
* giveaway in the next. The metafield then has two keys, and the giveaway under the second never
|
|
127
|
+
* reached the cart (production's DEL-2569). Each item keeps the stream it was won on.
|
|
128
|
+
*
|
|
129
|
+
* `streamingId` stays one stream — the first with something payable, not the first key, so a
|
|
130
|
+
* leftover empty key cannot hide a real win behind it — because `auction_id` is a single cart
|
|
131
|
+
* attribute and there is no honest value for a cart spanning two shows. That is a limitation, not
|
|
132
|
+
* a solved problem: per production's note on DEL-2569, the host marks that one stream's tab settled,
|
|
133
|
+
* so wins carried over from another stay flagged unpaid until it catches up. Accepted there for the
|
|
134
|
+
* same reason it is here: a prize the shopper paid for and can see beats one that silently does not
|
|
135
|
+
* exist, and the alternative (a cart per stream) needs a checkout that can open more than one.
|
|
127
136
|
*/
|
|
128
|
-
const
|
|
137
|
+
const streamingIds = payableStreamIds(parsed);
|
|
138
|
+
const [streamingId] = streamingIds;
|
|
129
139
|
if (!streamingId)
|
|
130
140
|
return null;
|
|
131
|
-
const items =
|
|
132
|
-
.filter(isPayable)
|
|
133
|
-
.map((raw) => {
|
|
141
|
+
const items = streamingIds.flatMap((stream) => parsed[stream].filter(isPayable).map((raw) => {
|
|
134
142
|
var _a;
|
|
135
143
|
return ({
|
|
136
144
|
productGid: `gid://shopify/Product/${raw.productId}`,
|
|
@@ -138,8 +146,9 @@ exports.auctions = {
|
|
|
138
146
|
winningBid: Number(raw.winningBid) || 0,
|
|
139
147
|
isGiveaway: !!raw.isGiveaway,
|
|
140
148
|
discountCode: (_a = raw.discountCode) !== null && _a !== void 0 ? _a : null,
|
|
149
|
+
streamingId: stream,
|
|
141
150
|
});
|
|
142
|
-
});
|
|
151
|
+
}));
|
|
143
152
|
return items.length ? { streamingId, items } : null;
|
|
144
153
|
},
|
|
145
154
|
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;;;;;;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,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;YAAC,OAAA,CAAC;gBAC7C,UAAU,EAAE,yBAAyB,GAAG,CAAC,SAAS,EAAE;gBACpD,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI,IAAI,GAAG,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;gBACvF,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;gBACvC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU;gBAC5B,YAAY,EAAE,MAAA,GAAG,CAAC,YAAY,mCAAI,IAAI;gBACtC,WAAW,EAAE,MAAM;aACpB,CAAC,CAAA;SAAA,CAAC,CACJ,CAAC;QAEF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,EAAE,WAAW,EAAE,KAAK,EAAyB,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9E,CAAC;IAED,gBAAgB,CAAC,eAAyB,EAAE,WAA0B;QACpE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAC9B,OAAO,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, LiveSellingConfig, Logger, StorageAdapter } from './types';
|
|
12
|
+
import type { CustomerAccountRequest, HiddenShows, 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,6 +23,28 @@ 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;
|
|
26
48
|
export declare function setConfig(config: LiveSellingConfig): void;
|
|
27
49
|
export declare function getConfig(): LiveSellingConfig;
|
|
28
50
|
export declare function isConfigured(): boolean;
|
|
@@ -48,11 +70,38 @@ export declare function getCommerce(): CommerceAdapter<unknown> | null;
|
|
|
48
70
|
* answers before `configure()` has run instead of throwing.
|
|
49
71
|
*/
|
|
50
72
|
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;
|
|
51
82
|
/** Null when nobody is identified beyond the per-install viewer id — bidding is then never offered. */
|
|
52
83
|
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>;
|
|
53
101
|
/**
|
|
54
102
|
* The gateway request. The company header is the only credential; a body implies JSON. `X-Request-Source`
|
|
55
|
-
* marks the traffic as first-party app rather than a web widget.
|
|
103
|
+
* marks the traffic as first-party app rather than a web widget. Every call is time-boxed — see
|
|
104
|
+
* `withRequestTimeout`.
|
|
56
105
|
*/
|
|
57
106
|
export declare function liveSellingRequest<T>(path: string, options?: {
|
|
58
107
|
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,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9G,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;AAED,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD;;;;;;;;GAQG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAE9C,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM;gBADjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM;CAK7B;AAID;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,cAAc,CAW9C;AAUD,wBAAgB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CASzD;AAED,wBAAgB,SAAS,IAAI,iBAAiB,CAG7C;AAED,wBAAgB,YAAY,IAAI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AC,EAAE,OAAO,CAAC;CAChB,GACA,OAAO,CAAC,CAAC,CAAC,CAoBZ;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAK,GAAG,MAAM,CAM5C;AAED,2FAA2F;AAC3F,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEpE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E"}
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LiveSellingError = void 0;
|
|
3
|
+
exports.DEFAULT_OFF_AIR_GRACE_MS = exports.LiveSellingTimeoutError = exports.DEFAULT_REQUEST_TIMEOUT_MS = exports.LiveSellingError = void 0;
|
|
4
4
|
exports.toProductGid = toProductGid;
|
|
5
|
+
exports.memoryStorage = memoryStorage;
|
|
5
6
|
exports.setConfig = setConfig;
|
|
6
7
|
exports.getConfig = getConfig;
|
|
7
8
|
exports.isConfigured = isConfigured;
|
|
@@ -12,7 +13,11 @@ exports.logWarning = logWarning;
|
|
|
12
13
|
exports.getCustomerAccountRequest = getCustomerAccountRequest;
|
|
13
14
|
exports.getCommerce = getCommerce;
|
|
14
15
|
exports.strictActiveProduct = strictActiveProduct;
|
|
16
|
+
exports.hiddenShowsRule = hiddenShowsRule;
|
|
17
|
+
exports.offAirGraceMs = offAirGraceMs;
|
|
15
18
|
exports.getIdentity = getIdentity;
|
|
19
|
+
exports.requestTimeoutMs = requestTimeoutMs;
|
|
20
|
+
exports.withRequestTimeout = withRequestTimeout;
|
|
16
21
|
exports.liveSellingRequest = liveSellingRequest;
|
|
17
22
|
exports.randomId = randomId;
|
|
18
23
|
exports.storageGet = storageGet;
|
|
@@ -36,12 +41,33 @@ class LiveSellingError extends Error {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
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;
|
|
39
64
|
const SILENT = { error: () => undefined };
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
/**
|
|
66
|
+
* A store that keeps things only in memory, for as long as the app runs. Used until `configure` is
|
|
67
|
+
* called (which requires the app's own `storage`), and by the tests. Not on the package's root: an app
|
|
68
|
+
* passes real storage.
|
|
69
|
+
*/
|
|
70
|
+
function memoryStorage() {
|
|
45
71
|
const mem = new Map();
|
|
46
72
|
return {
|
|
47
73
|
getItem: (key) => (mem.has(key) ? mem.get(key) : null),
|
|
@@ -53,16 +79,20 @@ function defaultStorage() {
|
|
|
53
79
|
},
|
|
54
80
|
};
|
|
55
81
|
}
|
|
56
|
-
const state = { config: null, storage:
|
|
82
|
+
const state = { config: null, storage: memoryStorage(), logger: SILENT };
|
|
57
83
|
function setConfig(config) {
|
|
58
|
-
var _a
|
|
84
|
+
var _a;
|
|
59
85
|
if (!config.apiUrl)
|
|
60
86
|
throw new Error('liveSelling.configure: apiUrl is required');
|
|
61
87
|
if (!config.companyId)
|
|
62
88
|
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)');
|
|
63
93
|
state.config = config;
|
|
64
|
-
state.storage =
|
|
65
|
-
state.logger = (
|
|
94
|
+
state.storage = config.storage;
|
|
95
|
+
state.logger = (_a = config.logger) !== null && _a !== void 0 ? _a : SILENT;
|
|
66
96
|
}
|
|
67
97
|
function getConfig() {
|
|
68
98
|
if (!state.config)
|
|
@@ -116,33 +146,103 @@ function strictActiveProduct() {
|
|
|
116
146
|
var _a;
|
|
117
147
|
return ((_a = state.config) === null || _a === void 0 ? void 0 : _a.strictActiveProduct) === true;
|
|
118
148
|
}
|
|
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
|
+
}
|
|
119
167
|
/** Null when nobody is identified beyond the per-install viewer id — bidding is then never offered. */
|
|
120
168
|
function getIdentity() {
|
|
121
169
|
var _a, _b;
|
|
122
170
|
return (_b = (_a = state.config) === null || _a === void 0 ? void 0 : _a.identity) !== null && _b !== void 0 ? _b : null;
|
|
123
171
|
}
|
|
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
|
+
}
|
|
124
219
|
/**
|
|
125
220
|
* The gateway request. The company header is the only credential; a body implies JSON. `X-Request-Source`
|
|
126
|
-
* marks the traffic as first-party app rather than a web widget.
|
|
221
|
+
* marks the traffic as first-party app rather than a web widget. Every call is time-boxed — see
|
|
222
|
+
* `withRequestTimeout`.
|
|
127
223
|
*/
|
|
128
224
|
async function liveSellingRequest(path, options) {
|
|
129
|
-
var _a, _b;
|
|
130
225
|
const config = getConfig();
|
|
131
226
|
const query = (options === null || options === void 0 ? void 0 : options.params)
|
|
132
227
|
? `?${new URLSearchParams(Object.entries(options.params).map(([k, v]) => [k, String(v)]))}`
|
|
133
228
|
: '';
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
229
|
+
const url = `${config.apiUrl}${path}${query}`;
|
|
230
|
+
return withRequestTimeout(url, async (signal) => {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
const response = await fetch(url, {
|
|
233
|
+
method: (_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET',
|
|
234
|
+
headers: {
|
|
235
|
+
'x-company-id': config.companyId,
|
|
236
|
+
'X-Request-Source': (_b = config.requestSource) !== null && _b !== void 0 ? _b : 'APPTILE',
|
|
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());
|
|
142
245
|
});
|
|
143
|
-
if (!response.ok)
|
|
144
|
-
throw new LiveSellingError(response.status);
|
|
145
|
-
return (await response.json());
|
|
146
246
|
}
|
|
147
247
|
/**
|
|
148
248
|
* 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;AA4CD,sCAWC;AAUD,8BASC;AAED,8BAGC;AAED,oCAEC;AAED,oCAEC;AAED,gCAEC;AAED,8BAEC;AASD,gCAIC;AAED,8DAEC;AAGD,kCAEC;AASD,kDAEC;AAMD,0CAEC;AAMD,sCAKC;AAGD,kCAEC;AASD,4CAKC;AAUD,gDAwBC;AAOD,gDA2BC;AAOD,4BAMC;AAGD,gCAEC;AAED,gCAEC;AArQD,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD,sFAAsF;AACtF,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,CAAC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